x
This commit is contained in:
@@ -210,6 +210,11 @@ class HTMLGenerator:
|
|||||||
const axesHelper = new THREE.AxesHelper(50);
|
const axesHelper = new THREE.AxesHelper(50);
|
||||||
scene.add(axesHelper);
|
scene.add(axesHelper);
|
||||||
|
|
||||||
|
// 添加轨道控制器 - 必须在使用之前定义
|
||||||
|
const controls = new THREE.OrbitControls(camera, renderer.domElement);
|
||||||
|
controls.enableDamping = true;
|
||||||
|
controls.dampingFactor = 0.25;
|
||||||
|
|
||||||
// 创建几何体(使用点云数据或模拟模具形状)
|
// 创建几何体(使用点云数据或模拟模具形状)
|
||||||
const geometryData = {json.dumps(geometry_data, indent=2)};
|
const geometryData = {json.dumps(geometry_data, indent=2)};
|
||||||
const cavityData = {json.dumps(cavity_data, indent=2) if cavity_data else 'null'};
|
const cavityData = {json.dumps(cavity_data, indent=2) if cavity_data else 'null'};
|
||||||
@@ -238,9 +243,9 @@ class HTMLGenerator:
|
|||||||
// 创建点云材质
|
// 创建点云材质
|
||||||
const pointMaterial = new THREE.PointsMaterial({{
|
const pointMaterial = new THREE.PointsMaterial({{
|
||||||
color: 0x4CAF50,
|
color: 0x4CAF50,
|
||||||
size: 0.5,
|
size: 1.0,
|
||||||
transparent: true,
|
transparent: true,
|
||||||
opacity: 0.8
|
opacity: 0.9
|
||||||
}});
|
}});
|
||||||
|
|
||||||
pointcloudMesh = new THREE.Points(pointGeometry, pointMaterial);
|
pointcloudMesh = new THREE.Points(pointGeometry, pointMaterial);
|
||||||
@@ -251,6 +256,12 @@ class HTMLGenerator:
|
|||||||
pointGeometry.computeBoundingBox();
|
pointGeometry.computeBoundingBox();
|
||||||
pointGeometry.boundingBox.getCenter(center);
|
pointGeometry.boundingBox.getCenter(center);
|
||||||
controls.target.set(center.x, center.y, center.z);
|
controls.target.set(center.x, center.y, center.z);
|
||||||
|
|
||||||
|
// 根据边界框大小调整相机距离
|
||||||
|
const boundingSphere = new THREE.Sphere();
|
||||||
|
pointGeometry.boundingBox.getBoundingSphere(boundingSphere);
|
||||||
|
const cameraDistance = boundingSphere.radius * 3;
|
||||||
|
camera.position.set(cameraDistance, cameraDistance, cameraDistance);
|
||||||
}} else {{
|
}} else {{
|
||||||
// 创建产品几何体(半透明绿色)
|
// 创建产品几何体(半透明绿色)
|
||||||
const productGeometry = new THREE.BoxGeometry(width * 0.9, height * 0.9, depth * 0.9);
|
const productGeometry = new THREE.BoxGeometry(width * 0.9, height * 0.9, depth * 0.9);
|
||||||
@@ -338,11 +349,6 @@ class HTMLGenerator:
|
|||||||
camera.position.set(200, 200, 200);
|
camera.position.set(200, 200, 200);
|
||||||
camera.lookAt(0, 0, 0);
|
camera.lookAt(0, 0, 0);
|
||||||
|
|
||||||
// 添加轨道控制器
|
|
||||||
const controls = new THREE.OrbitControls(camera, renderer.domElement);
|
|
||||||
controls.enableDamping = true;
|
|
||||||
controls.dampingFactor = 0.25;
|
|
||||||
|
|
||||||
// 动画循环
|
// 动画循环
|
||||||
function animate() {{
|
function animate() {{
|
||||||
requestAnimationFrame(animate);
|
requestAnimationFrame(animate);
|
||||||
|
|||||||
Reference in New Issue
Block a user