質問

私はオブジェクトの作成に渡すThree.vecore3を一致させます。

object[i] = new Object(new THREE.Vector3(0,0,0));
.

クラスオブジェクトで、私は新しい3.Vector3に設定されている変数テクスチャを持っていますPOS

function Object(pos){
    this.texture = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { map:
    THREE.ImageUtils.loadTexture( '../img/img.png' ) } ) );

    this.texture.position = pos;

    this.texture.rotation.x = 0;
    this.texture.rotation.y = 1.57;
    this.texture.rotation.z = 1.57;

    this.texture.scale.x = 100;
    this.texture.scale.y = 50;
    this.texture.scale.z = 100;

    this.texture.position.y = 1000;
}
.

問題を抱えている問題は、このオブジェクト内で作成された別のオブジェクトにPOSを渡したいということです。

object2 = new Object2(pos);
.

POSは1000でYを持つように変更されました。なぜこれが起こっているのかわかりません。あらゆる助けが大いに評価されます。

役に立ちましたか?

解決

オブジェクトを変更するだけでポジションのクローンを取る

function Object(pos){
    this.texture = new THREE.Mesh( geometry, new THREE.MeshBasicMaterial( { map:
    THREE.ImageUtils.loadTexture( '../img/img.png' ) } ) );

    this.texture.position = pos.clone();

    this.texture.rotation.x = 0;
    this.texture.rotation.y = 1.57;
    this.texture.rotation.z = 1.57;

    this.texture.scale.x = 100;
    this.texture.scale.y = 50;
    this.texture.scale.z = 100;

    this.texture.position.y = 1000;
}
.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top