From 3a0f9eef2d4a17af05c72755cc15ae96b1f7a859 Mon Sep 17 00:00:00 2001 From: yuliang <398780299@qq.com> Date: Wed, 18 Jun 2025 12:32:05 +0800 Subject: [PATCH] =?UTF-8?q?CLX=20=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/cl2/Cl23dObject.ts | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/modules/cl2/Cl23dObject.ts b/src/modules/cl2/Cl23dObject.ts index 5658d4c..37cae18 100644 --- a/src/modules/cl2/Cl23dObject.ts +++ b/src/modules/cl2/Cl23dObject.ts @@ -126,9 +126,8 @@ export default class Cl23dObject extends THREE.Object3D { extrudePath: curve // 设置挤出轨迹 } // 创建挤出几何体 - const geometry = new THREE.ExtrudeGeometry(shape, options) - // const material = new THREE.MeshBasicMaterial({color: 0xffdddbca}); - // const mesh = new THREE.Mesh(geometry, material); + let geometry = new THREE.ExtrudeGeometry(shape, options) + const fd = 0.03 @@ -170,8 +169,38 @@ export default class Cl23dObject extends THREE.Object3D { } // 创建挤出几何体 const geometryBf = new THREE.ExtrudeGeometry(shapeBf, optionsBf) + geometry = mergeGeometries([geometry, geometryBf]) + const material = new THREE.MeshBasicMaterial({color: 0xffdddbca}); + const mesh = new THREE.Mesh(geometry, material); + + const shapeD = new THREE.Shape(); + shapeD.moveTo(-0.3, -0.25); + shapeD.lineTo(-0.3, 0.25); + shapeD.lineTo(0.3, 0.25); + shapeD.lineTo(0.3, -0.25); + shapeD.closePath() - return mergeGeometries([geometry, geometryBf]) + const curveD = new THREE.CatmullRomCurve3( + [new THREE.Vector3(0, 1.45, -1), new THREE.Vector3(0, 1.45, 1)], + false, // 闭合曲线 + 'catmullrom', + 0 + ) + + const optionsD = { + steps: 1, + bevelSegments: 0.05, + bevelEnabled: true, + extrudePath: curveD // 设置挤出轨迹 + } + + const geometryD = new THREE.ExtrudeGeometry(shapeD, optionsD) + const meshD = new THREE.Mesh(geometryD, material); + mesh.updateMatrix() + meshD.updateMatrix() + const result = CSG.subtract(mesh, meshD) + + return result.geometry }