How to clone an object3d in Three.js?

前端 未结 3 717
我在风中等你
我在风中等你 2020-12-10 03:23

I want to clone a model loaded with loader, I found this issue on github,but the solution doesn\'t work. It seems there has been an structural change in Object3D.

Ho

3条回答
  •  抹茶落季
    2020-12-10 04:07

    Actually mrdoob's answer is your answer...

    The loader output a geometry you use to create a mesh. You need to create a new mesh with the loader-created mesh's geometry and material.

    for ( var i = 0; i < 10; i ++ ) {
        var mesh = new THREE.Mesh( loadedMesh.geometry, loadedMesh.material );
        mesh.position.set( i * 100, 0, 0 );
        scene.add( mesh );
    }
    

    You want to clone a Mesh and not an Object3D because the output of the loader is a Mesh.

提交回复
热议问题