Jump to content

Animate all models


Recommended Posts


So I've loaded a model multiple time using this code:

loader.load( "models/model.js", function( geometry ) {        var mat = new THREE.MeshLambertMaterial( { map: modelTex });        for (var i = 0; i < 5; i++) {             var mesh = new THREE.Mesh( geometry, mat );            mesh.position.set(i, i, i);            mesh.scale.set(5, 5, 5);            scene.add(mesh);        }});

Now I want to animate all of them individually in the animate() function.

But it only animates one of the models. When I use mesh it doesn't work.

How can I fix this? :huh:


Thanks in advance :)

Link to comment
Share on other sites

no that's not it.

I just don't know how I can make the other ones move as well.

I use this code to try to animate the meshes:

function animate() {    requestAnimationFrame( animate );	mesh.position.x += .1;}

Just the last one that's added to the scene is moving though.

How can I make the other ones move too?


The console gives me this error : ReferenceError: mesh is not defined

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.

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.


  • Recently Browsing   0 members

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