Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/three.js/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
WEBGL Three.js如何创建相同大小的网格?_Webgl_Three.js_Collision_Aabb - Fatal编程技术网

WEBGL Three.js如何创建相同大小的网格?

WEBGL Three.js如何创建相同大小的网格?,webgl,three.js,collision,aabb,Webgl,Three.js,Collision,Aabb,我想做一个相同大小的立方体 我试试这个。 但效果并不好 zmesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial( { /*map: THREE.ImageUtils.loadTexture( filepath )*/ } )); zmesh.position.set( x, y, z ); zmesh.scale.set( s, s, s ); zmesh.rotation.x = - Math.PI / 2; scen

我想做一个相同大小的立方体 我试试这个。 但效果并不好

zmesh = new THREE.Mesh( geometry, new THREE.MeshLambertMaterial(  { /*map: THREE.ImageUtils.loadTexture( filepath )*/ }  ));
zmesh.position.set( x, y, z );
zmesh.scale.set( s, s, s );
zmesh.rotation.x = - Math.PI / 2;
scene.add( zmesh ); 
Object.push( zmesh );

var BOX =   new THREE.Mesh( new THREE.CubeGeometry(10, 10, 10 ), new THREE.MeshLambertMaterial({ color : 0xFFF0FF }));
BOX.position.set( x, y, z );
scene.add(BOX);
COLLISION.push( BOX );

如何创建相同大小的网格?

这是我在上使用的代码:

[历史参考文献(r50)]



NB:的当前(2015-4-30)版本可在中找到。

我还有一个问题。如何使用几何体设置边界框??
var selectionBox = new THREE.Mesh( new THREE.CubeGeometry( 1, 1, 1 ), new THREE.MeshBasicMaterial( { color: 0xffff00, wireframe: true } ) );
selectionBox.geometry.dynamic = true;
selectionBox.matrixAutoUpdate = false;
selectionBox.visible = false;
sceneHelpers.add( selectionBox );
var geometry = object.geometry;

if ( geometry.boundingBox === null ) {

    geometry.computeBoundingBox();

}

selectionBox.geometry.vertices[ 0 ].x = geometry.boundingBox.max.x;
selectionBox.geometry.vertices[ 0 ].y = geometry.boundingBox.max.y;
selectionBox.geometry.vertices[ 0 ].z = geometry.boundingBox.max.z;

selectionBox.geometry.vertices[ 1 ].x = geometry.boundingBox.max.x;
selectionBox.geometry.vertices[ 1 ].y = geometry.boundingBox.max.y;
selectionBox.geometry.vertices[ 1 ].z = geometry.boundingBox.min.z;

selectionBox.geometry.vertices[ 2 ].x = geometry.boundingBox.max.x;
selectionBox.geometry.vertices[ 2 ].y = geometry.boundingBox.min.y;
selectionBox.geometry.vertices[ 2 ].z = geometry.boundingBox.max.z;

selectionBox.geometry.vertices[ 3 ].x = geometry.boundingBox.max.x;
selectionBox.geometry.vertices[ 3 ].y = geometry.boundingBox.min.y;
selectionBox.geometry.vertices[ 3 ].z = geometry.boundingBox.min.z;

selectionBox.geometry.vertices[ 4 ].x = geometry.boundingBox.min.x;
selectionBox.geometry.vertices[ 4 ].y = geometry.boundingBox.max.y;
selectionBox.geometry.vertices[ 4 ].z = geometry.boundingBox.min.z;

selectionBox.geometry.vertices[ 5 ].x = geometry.boundingBox.min.x;
selectionBox.geometry.vertices[ 5 ].y = geometry.boundingBox.max.y;
selectionBox.geometry.vertices[ 5 ].z = geometry.boundingBox.max.z;

selectionBox.geometry.vertices[ 6 ].x = geometry.boundingBox.min.x;
selectionBox.geometry.vertices[ 6 ].y = geometry.boundingBox.min.y;
selectionBox.geometry.vertices[ 6 ].z = geometry.boundingBox.min.z;

selectionBox.geometry.vertices[ 7 ].x = geometry.boundingBox.min.x;
selectionBox.geometry.vertices[ 7 ].y = geometry.boundingBox.min.y;
selectionBox.geometry.vertices[ 7 ].z = geometry.boundingBox.max.z;

selectionBox.geometry.computeBoundingSphere();

selectionBox.geometry.verticesNeedUpdate = true;

selectionBox.matrixWorld.copy( object.matrixWorld );

selectionBox.visible = true;