Forum

User posts Bani
26 February 2020 14:06 [ON MODERATION]
Hello folks,

i have the same project but with a little more function.
I can change my background with the code snippet function. But can i also switch between Normal background and Transperent background?
Bani
26 February 2020 14:04 [ON MODERATION]
Hello folks,

i have a question!!!
I have a background an change the background with this script:
//________________________________________________________________________________________World________________________________________________________________________________________

var world = ["World_Map"];
var book = ["HC","TB","obj_shrink_wrap","HC_SU","A_Compair","B_Compair","C_Compair","D_Compair"];
var map = ["grey_area.png", "sky_area.png", "spring.png", "autumn.png", "lighthouse.png", "grey.png", "stars.png", "black.png", "white.png", "greenscreen.png", "lighthouse.png", "hh_trainstation.png", "market_place.png"];
var img_map = [];
preload_world = function () {
for (var i in map) {
img_map.push(new Image());
img_map.onload = function () {
console.log("image file successfully preloaded");
}
img_map.src = "images/background/" + map;
}
}
switch_world = function (n) {
for (var i in world){
m_tex.replace_image(m_scs.get_world_by_name(world), "World_Map", img_map[n]);
}
for (var i in book) {
m_tex.replace_image(m_scs.get_object_by_name(book), "World_Map", img_map[n]);
}

m_tex.replace_image(m_scs.get_object_by_name("SHADOWPLANE"), "tex_world_map", img_map[n]);



if(n == 10){
m_scs.show_object(m_scs.get_object_by_name("b_custom_background"));
$("#upload_world").show();
}
else{
m_scs.hide_object(m_scs.get_object_by_name("b_custom_background"));
$("#upload_world").hide();
}

}


My question is: How can i have custom Backgrounds and as an option, a transparent background??
Is that possible?
Bani
19 February 2020 01:01
Hello,

none of my projects are deployed correctly anymore.
Every Project has this error:



What is the Problem?

The Projects worked one week ago :/

Kind regards,

Bani
Bani
08 January 2020 16:22 [ON MODERATION]
Hello folks,

i have the problem, that my object disappears, when I zoom in. I exported my project into a json-file and in my browser, i opened my project. There in my canvas, the object just disappears.
Does anyone have a clue, whats going on?

Kind regards,
Bani
Bani
17 December 2019 10:43
m_tex.replace_image(m_scs.get_object_by_name("OBJECT"), "TEXTURE", target);

My question is, can i do it also within a group for example like(it doesnt work, just for showing my idea):

m_tex.replace_image(m_scs.get_object_by_name("A_Compair"), "GROUP", "tex_compair_col", target);

Does anybody have an idea?

Kind regards,
Bani
Bani
17 December 2019 10:42
Hello folks and blend4web team,

i want to make a texture, wich is used multiple times, so i want to insert it into a group, so i can count it in the DOM/console as one texture!

As far as i know, i can change or replace images via this script:

m_tex.replace_image(m_scs.get_object_by_name("OBJECT"), "TEXTURE", target);

My question is, can i do it also within a group for example like(it doesnt work, just for showing my idea):

m_tex.replace_image(m_scs.get_object_by_name("A_Compair"), "GROUP", "tex_compair_col", target);

Here is the Group:
2019-12-17 08_40_36-Blender_ [F__002_blend4web_pro_projects_eMotion_Online_blender_eMotion_Online.bl.png
And here the content:
2019-12-17 08_40_51-Blender_ [F__002_blend4web_pro_projects_eMotion_Online_blender_eMotion_Online.bl.png

Does anybody have an idea?

Kind regards,
Bani
Bani
14 November 2019 17:27 [ON MODERATION]
hi
Bani
12 November 2019 12:53 [ON MODERATION]
Hello folks,

i have a little project, where i want to change the texture into another texture. (not replace an Image)
so there are two Textures: "Texture.001" and "Texture.002".

I have a Texture Node with "Texture.001" in it.
When I press a button, I want to change the Texture input to "Texture.002".
Is there any solution?
Bani
12 November 2019 12:46 [ON MODERATION]
When you want to use and variable, than you could do the script that way:


play_animation.oninput = function(e){
if(this.value =="Your_Value"){
// the apply and play block here

}
}
Bani
12 November 2019 12:43 [ON MODERATION]
Yes there are many solutions!
You can set a new project and use .json export for personal programming!
Than you export your project as an json file into your project folder.
After that you have to got to your Html and javascript file and connect them both via script!

Here an example:
HTML :
<button id="play_animation"></button>

js:
var m_app = require("app");
var m_anim = require("animation");
var m_scenes = require("scenes");

//put it to the 'place your code here' section
var your_button = document.getElementbyId("play_animation");

your_button.onclick = function(){
var anim_obj = m_scenes.get_object_by_name("YOUR_OBJECT_WICH_HAS_THE_ANIMATION");
m_anim.apply(anim_obj, "ANIMATION_NAME");
m_anim.play(anim_obj);
}


I hope it was helpfull!
Bani