WebGl、Three.js を使用しています。誰が私が間違っているのか教えてもらえますか? カスタムメイドのメッシュの位置を取得しようとしています。どの方法を試しても、値(0,0,0)を取得するたびに。
どの方法もうまくいきませんでした:
- vector.getPositionFromMatrix( マトリックス );
- obj.matrix.getPosition().x
これが私のコードです:
squareGeometry = new THREE.Geometry();
squareGeometry.vertices.push(new THREE.Vector3( this.x, this.y, this.z));
squareGeometry.vertices.push(new THREE.Vector3( this.x + this.w, this.y, this.z));
squareGeometry.vertices.push(new THREE.Vector3( this.x + this.w, this.y - this.h, this.z));
squareGeometry.vertices.push(new THREE.Vector3( this.x, this.y - this.h, this.z));
squareGeometry.faces.push(new THREE.Face4(0, 1, 2, 3));
squareMaterial = new THREE.MeshBasicMaterial({
color:this.color,
side:THREE.DoubleSide
});
squareMesh = new THREE.Mesh(squareGeometry, squareMaterial);
scene.add(squareMesh);
squareMesh.updateMatrix()
scene.updateMatrixWorld();
vec = new THREE.Vector3();
matrix = squareMesh.matrix;
localPosition = squareMesh.position; // 0,0,0
worldPosition = vec.getPositionFromMatrix( matrix ); // 0,0,0
// this also doesnt work
squareMesh.matrix.getPosition().x // 0