0
私はgroupChairという名前の空のTHREE.Object3D()を作成しました。そして、3 objファイルをロードし、コールバック関数でgroupChairに追加します。 groupChairをシーンに追加します。できます。なぜこのグループをコピーできないのですか?以下 ロードされた.objモデルを含むグループをクローンする方法は?
はコードです:すべてのオブジェクトがロードされる前に、コード例で var groupChair = new THREE.Object3D();
var cloneChair;
var cushion;
var backrest;
var frame;
var loader = new THREE.OBJLoader(manager);
//load the 1st obj file
loader.load('model-stuff/chair/obj/cushion.obj', function(object) {
object.traverse(function (child){
if (child instanceof THREE.Mesh) {
child.material = new THREE.MeshStandardMaterial({
map: textureColorForCushion,
roughness: 3,
metalness:0.6,
blending: THREE.NormalBlending,
shading: THREE.SmoothShading,
envMap: textureCube,
});
child.receiveShadow = true;
child.castShadow = true;
}
});
cushion = object;
groupChair.add(cushion);
}, onProgress, onError);
//load the 2nd obj file
loader.load('model-stuff/chair/obj/backrest.obj', function(object) {
object.traverse(function (child){
if (child instanceof THREE.Mesh) {
child.material = new THREE.MeshStandardMaterial({
map: textureColorForCushion,
roughness: 3,
metalness:0.6,
blending: THREE.NormalBlending,
shading: THREE.SmoothShading,
envMap: textureCube,
});
child.receiveShadow = true;
child.castShadow = true;
}
});
backrest = object;
groupChair.add(backrest);
}, onProgress, onError);
//load the 3th obj file
loader.load('model-stuff/chair/obj/frame.obj', function(object) {
object.traverse(function (child){
if (child instanceof THREE.Mesh) {
child.material = new THREE.MeshStandardMaterial({
map: textureColorForFrame,
roughness: 0.9,
metalness:0.4,
blending: THREE.NormalBlending,
shading: THREE.SmoothShading,
envMap: textureCube,
});
child.receiveShadow = true;
child.castShadow = true;
}
});
frame = object;
groupChair.add(frame);
}, onProgress, onError);
scene.add(groupChair);
//clone groupChair object, but it doesn't work
cloneChair = groupChair.clone();
cloneChair.position.set(30,0,0);
scene.add(cloneChair);
本当にありがとうございます。できます。 –