0

使用 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 );
4

0 回答 0