Jump to content

PlayAnimationAction with a imported mesh


hit2501
 Share

Recommended Posts

Hi.

 

I  imported a cube with a simple no bones animation (growth) from Blender to Babylon. Looks good with:

BABYLON.SceneLoader.ImportMesh("", "babylon/", "cube.babylon", scene, function (newMeshes) {      var C1 = newMeshes[0];      scene.beginAnimation(C1, 0, 100, false, 1.0);      camera.target = C1; }

but when I want the animation start when I click on the cube nothing happens, this is the code I use:

     	BABYLON.SceneLoader.ImportMesh("", "babylon/", "cube.babylon", scene, function (newMeshes) {     		var C1 = newMeshes[0];                C1.actionManager = new BABYLON.ActionManager(scene);                var action = new BABYLON.PlayAnimationAction(BABYLON.ActionManager.OnPickTrigger, C1, 0, 100, 0);                C1.actionManager.registerAction(action);    		camera.target = C1;	}

 

 
Link to comment
Share on other sites

FileLoader is organized primarily to load things in batches by type:   materials, lights, meshes, animations, etc. 

 

ImportMesh also does materials of the mesh, children meshes, particle systems, and skeletons.  Maybe it could be made to do animations as well.  I touched this file once, but changed were undone due to behavior changes.  Reconstituting scenes is very order dependent.  I would not mess with this file again.

 

If you have multiple .babylon files, Append instead of Load may get you through.  It does the same thing as Load, but instead of passing an engine,  you pass a scene you create yourself. You then get your animation, and can still append stuff from another .babylon.

Link to comment
Share on other sites

  • 4 years later...
On 2/19/2015 at 3:08 AM, hit2501 said:

Thanks Deltakosh, but still did not work, I modified my files to use my code in a


BABYLON.SceneLoader.Load 

and it worked. I wonder why it does not work when importing meshes instead of loading.

 

On 2/19/2015 at 3:08 AM, hit2501 said:

Thanks Deltakosh, but still did not work, I modified my files to use my code in a


BABYLON.SceneLoader.Load 

and it worked. I wonder why it does not work when importing meshes instead of loading.

hi,you said use 'SceneLoader.Load',but how can you get the imported mesh?

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...