Three.js - CubeGeometry问题中的TubeGeometry

时间:2013-11-11 05:16:34

标签: three.js bounding-box

使用Three.js,我绘制了一个TubeGeometry和用于绘图的点,范围在-8000到+8000之间(用于绘图的点是从XML文件获得的,它可能会动态变化)。我试图使用边界框方法绘制一个封闭TubeGeometry的CubeGeometry。 当我放大/缩小或旋转立方体时,我希望TubeGeometry缩小并适合多维数据集。但它不会发生。 请帮我解决这个问题。

//指向绘图TubeGeometry是动态的,并从文件中读取

extrudePath = new THREE.SplineCurve3(points); 
extrudePath.dynamic = true;
var segments = points.length;

tube = new THREE.TubeGeometry(extrudePath, segments, 60, radiusSegments, closed, debug);
tube.dynamic = true;

THREE.GeometryUtils.explode(tube);

tube.verticesNeedUpdate = true;
tube.dynamic = true;

tube.computeBoundingBox();
var centerX = 0.5 * ( tube.boundingBox.max.x - tube.boundingBox.min.x ); 
var centerY = 0.5 * ( tube.boundingBox.max.y - tube.boundingBox.min.y ); 
var centerZ = 0.5 * ( tube.boundingBox.max.z - tube.boundingBox.min.z ); 

var boundingBoxGeometry = new THREE.CubeGeometry( centerX, centerY, centerZ );        

var boundingBoxMaterial = new THREE.MeshBasicMaterial( { color: 0xffffff, vertexColors: THREE.FaceColors, transparent: true, opacity: 0.7 } );
boundingBoxMesh = new THREE.Mesh( boundingBoxGeometry, boundingBoxMaterial);
scene.add( boundingBoxMesh );

0 个答案:

没有答案