Jump to content

Animations on subMaterials property


3Dlove
 Share

Recommended Posts

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 ;)

Link to comment
Share on other sites

Howdy!

 

So, the problem is here - https://github.com/BabylonJS/Babylon.js/blob/master/Babylon/Animations/babylon.animation.ts#L338

using 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 by RaananW
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...