0

オブジェクトの作成に渡す一時変数THREE.Veector3があります

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

オブジェクトクラスには、posと呼ばれる新しいTHREE.Vector3に設定した可変テクスチャがあります。

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はyが1000になるように変更されています。なぜこれが発生するのかよくわかりません。変数の受け渡しに関するガイドを読みましたが、pos変数がどのように変更されるかについてはまだ少し混乱しています。どんな助けでも大歓迎です。

4

1 に答える 1

1

常に位置のクローンを取るようにオブジェクトを変更するだけです

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;
}
于 2012-10-01T08:42:38.043 に答える