3Dlove Posted May 19, 2015 Share Posted May 19, 2015 Hello guys How to do an animation on a subMaterials property ? example :var animation = new BABYLON.Animation("anim", "material.subMaterials[3].diffuseColor.r", 30, BABYLON.Animation.ANIMATIONTYPE_FLOAT, BABYLON.Animation.ANIMATIONLOOPMODE_CYCLE); but the problem is with "[3]", so JavaScript show that "can't read property of undefined for diffuseColor" because it can't reade subMaterials[3]. If I haven't subMaterials, that work fine but how to do that with subMaterials ?^^ I like this method of animation because I can add it when I create a mesh and have the end event callback Thanks Quote Link to comment Share on other sites More sharing options...
RaananW Posted May 19, 2015 Share Posted May 19, 2015 (edited) Howdy! So, the problem is here - https://github.com/BabylonJS/Babylon.js/blob/master/Babylon/Animations/babylon.animation.ts#L338using this method, you cannot access an array's element. It is equivalent to:var array = ["a", "b", "c"];var obj = { array: array}console.log(obj["array[0]"]);You will sadly get undefined. A solution can be implemented. Wouldn't be too hard finding if the object is an array and simply using the parameter correctly. But it won't work as is. Come to think about it, seeing this implementation - simply use "subMaterials.3" instead of "subMaterials[3]" . It is not javascript conform, but it will work for sure :-) Here is a small demo - http://www.babylonjs-playground.com/#22WIWY Edited May 19, 2015 by RaananW 3Dlove 1 Quote Link to comment Share on other sites More sharing options...
dbawel Posted May 20, 2015 Share Posted May 20, 2015 That is an excellent attribute. Thanks for the example as I can use ths now. Quote Link to comment Share on other sites More sharing options...
3Dlove Posted May 20, 2015 Author Share Posted May 20, 2015 Wonderfull !!! Thank you a lot RaananW =D Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.