Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Three.js 获取飞机的世界位置_Three.js - Fatal编程技术网

Three.js 获取飞机的世界位置

Three.js 获取飞机的世界位置,three.js,Three.js,我对three.js很陌生,所以我肯定我很想理解这里的一些东西 我用以下方式创建了一个平面: var planeGeom = new THREE.PlaneGeometry(0.2, 0.2); planeGeom.rotateX(-Math.PI / 2); var plane = new THREE.Mesh(planeGeom, new THREE.MeshBasicMaterial({color: 0xffff00, side: THREE.DoubleSide})); plane.po

我对three.js很陌生,所以我肯定我很想理解这里的一些东西

我用以下方式创建了一个平面:

var planeGeom = new THREE.PlaneGeometry(0.2, 0.2);
planeGeom.rotateX(-Math.PI / 2);
var plane = new THREE.Mesh(planeGeom, new THREE.MeshBasicMaterial({color: 0xffff00, side: THREE.DoubleSide}));
plane.position.set(0, 0.1, 0);
scene.add(plane);

var mathPlane = new THREE.Plane();
planePointA.copy(plane.geometry.vertices[plane.geometry.faces[0].a]);
planePointB.copy(plane.geometry.vertices[plane.geometry.faces[0].b]);
planePointC.copy(plane.geometry.vertices[plane.geometry.faces[0].c]);
plane.localToWorld(planePointA);
plane.localToWorld(planePointB);
plane.localToWorld(planePointC);
mathPlane.setFromCoplanarPoints(planePointA, planePointB, planePointC);

var helper = new THREE.PlaneHelper( mathPlane, 1, 0xffff00 );
scene.add( helper );
为什么PlaneGeometry对象和平面的位置不同?为什么.localToWorld()不能获取平面的世界位置


设置位置后,在
平面上使用
.updateMatrix World()

plane.position.set(0, 0.1, 0);
plane.updateMatrixWorld();
scene.add(plane);

非常感谢。我昨天花了整整一天的时间试图解决这个问题,在一行代码中,现在一切都正常了!=)