Jump to content

Clone gltf object in three js scene.


Tunan
 Share

Recommended Posts

Hello everyone,I've search for two days for ways to clone a gltf object but no one works. I've trired deep clone the object, but no thing works. It seems like the object only be added once to the glTF render list when it be loaded. The clone body can't be render in screen.
Here is the result of scene.add(obj.clone());
`var gltfLoader = new THREE.GLTFLoader();
            gltfLoader.load('assets/model/gltf/tree/tree.gltf', function ( data ) {
                var gltf = data;
                var gltfobj = gltf.scene !== undefined ? gltf.scene : gltf.scenes[ 0 ];
                gltfobj.position.z += 5;
                gltfobj.name = "tree";
                scene.add(gltfobj);

                var tree2 = gltfobj.clone();
                tree2.position.x+=1;
                scene.add( tree2 );
            });
`

The cloned object only show shadow in the scene.

I've test the colladaLoader and the daeobject is working well, so now I don't know what is going wrong.So,what should I do to clone it in three js scene?

If anybody can help me?Thanks!

QQ截图20170214192400.png

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