Forum

nla animation with javascript

17 February 2017 21:51
well i have read tutorial try a lot of thinks ……………
i have an object ( let say a cube) i want to animate move along y and at the same time make it disappear (use a value input in node tree to control alpha)
alright it works with fastpreview ( i check apply default animation)
if i open animation tab in fastpreview i see
object:myCube
animation slot:0 object 1 material
animation: cube.move shader NodetreeAction

but if i want to control it via javascript ( apply defaut animation unchecked) i can t have the both
whever i can move the cube whever i can make it disappear but not the two in same time
my script is

m_anim.apply(myCube, "Cube.move");
//i have tried with m_anim.apply(myCube, "Cube.move",0);

m_anim.apply(myCube, "Shader NodetreeAction");
m_anim.set_behavior(myCube,m_anim.AB_FINISH_STOP);
m_anim.play(myCube);


suppose there is something i don t understand but that?
and if it works with fastpreview suppose it can work with javascript control
ps if i do
m_anim.apply(myCube, "Shader NodetreeAction",1); ok my cube disappears but it don t move no more

so how can i make my cube move and disappears with javascript controling animation
18 February 2017 12:37
if i use
m_anim.apply_to_first_empty_slot(myCube, "Shader NodetreeAction");
i get error message
B4W ERROR: Unsupported object: "Cube.000" or animation name: "1"

and il also encountered the probleme with animation call back
m_anim.play(mycube,callbackfunction(textActif));

function callbackfunction(textActif){console.log("function textVisible");
console.log(m_anim.get_frame(textActif));
}
it show 1 so the callbackfunction is thrown at the begining of the animation not at the end
18 February 2017 15:21
ok i have solve my probleme

1/i export with apply default animation

2/in the javascript i stop the animation as soon it s loaded

m_anim.set_behavior(textJoyeuxNoel,m_anim.AB_FINISH_STOP,0);m_anim.set_behavior(textJoyeuxNoel,m_anim.AB_FINISH_STOP,1);

m_anim.stop(textJoyeuxNoel,0);console.log(m_anim.get_slot_num_by_anim(textJoyeuxNoel,"Text.hide") );

m_anim.stop(textJoyeuxNoel,1);console.log(m_anim.get_slot_num_by_anim(textJoyeuxNoel,"Shader NodetreeAction.003") );

3/when i need to animate
m_anim.set_first_frame(textJoyeuxNoel,1);m_anim.play(textJoyeuxNoel,null,1);
m_anim.set_first_frame(textJoyeuxNoel,0);m_anim.play(textJoyeuxNoel,callbackfunction,0);

i forget the null in anim.play and it does'nt work if you forget it ( m_anim.play(textJoyeuxNoel,0);)
fot the callback function the probleme comes from my first frame was 0 and it has to be 1

one problem solve i can go to the next problem now
19 February 2017 14:54
ok here is my new probleme
i want to change the diffuse color of my object material
if i use a simple material it work with

m_mat.set_diffuse_color(myObject,"Material.000", m_rgba.from_values(0.0, 0.0, 0.0, 1.0));
// m_mat.set_emit_factor(myObject, "Material.000", 10)

but i f i use a node Material.000 & Node Material.000 well it does'nt work no more

so how can i proceed?
19 February 2017 15:07
oh sorry i have found
get to use
m_mat.set_nodemat_rgb(textJoyeuxNoel, ["Text.000", "RGB"], 0.1, 1, 0);
 
Please register or log in to leave a reply.