Jump to content

have problem when use scene.registerBeforeRender in importmesh


lousha
 Share

Recommended Posts

           BABYLON.SceneLoader.ImportMesh("", "model/", "weixin.babylon", scene, function (newMeshes, particleSystems, skeletons) {


                var alpha = 0;
                scene.registerBeforeRender( function () {

                    for (i = 0; i < 60; i++) {
                        newMeshes[i].position = new BABYLON.Vector3(newMeshes[i].position.x + 10 * 
                        Math.sin(alpha),
                            newMeshes[i].position.y + 0,
                            newMeshes[i].position.z + 10 * Math.cos(alpha));
                    }
                    alpha += 0.01;

                });
            });

here is  my code  why  it show "Cannot read property 'position' of undefined"

Link to comment
Share on other sites

Hi Lousha, welcome to the forum.  Could you please insert this line after the importMesh...

console.log(newMeshes.length);

Then RUN and check JS console.

We want to make sure that there are, at least... 60 mesh inside the newMeshes array.  (thx for check)

Another possible test... console.log(newMeshes[59])... this should NOT report undefined, of course.

Talk again soon.

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