Three.js - load JSON model once and add it multiple times

前端 未结 2 649
醉酒成梦
醉酒成梦 2021-01-14 16:17

Is it possible to load a JSON model once and add it to the scene multiple times with different scales, positions, etc?

If I add the Object3D() to an array, give a po

2条回答
  •  猫巷女王i
    2021-01-14 17:01

    You can create new meshes from the same geometries and materials:

    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(i, i, i);
                scene.add(mesh);
            }
    });
    

提交回复
热议问题