Fix clipping box clipping planes error
This commit is contained in:
parent
ce20daeee2
commit
6bf44194b3
1 changed files with 9 additions and 15 deletions
|
@ -194,17 +194,23 @@ export function buildClippingplanes(
|
||||||
edgeMeshMap[p.orientation] = edges;
|
edgeMeshMap[p.orientation] = edges;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const o in Orientation) {
|
for (const p of planesData) {
|
||||||
const capMeshGroupName = `cap-mesh-group-${o}`;
|
// Create ClippingGroup for each cap mesh face
|
||||||
|
const capMeshGroupName = `cap-mesh-group-${p.orientation}`;
|
||||||
let capMeshGroup = scene.getObjectByName(capMeshGroupName) as ClippingGroup;
|
let capMeshGroup = scene.getObjectByName(capMeshGroupName) as ClippingGroup;
|
||||||
if (capMeshGroup) {
|
if (capMeshGroup) {
|
||||||
capMeshGroup.clear();
|
capMeshGroup.clear();
|
||||||
} else {
|
} else {
|
||||||
capMeshGroup = new ClippingGroup();
|
capMeshGroup = new ClippingGroup();
|
||||||
capMeshGroup.name = capMeshGroupName;
|
capMeshGroup.name = capMeshGroupName;
|
||||||
capMeshGroup.clippingPlanes = planes;
|
|
||||||
scene.add(capMeshGroup);
|
scene.add(capMeshGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set clipping planes for the cap meshes
|
||||||
|
const capMeshGroupPlanes = planes.filter(
|
||||||
|
(plane) => plane.normal.dot(p.normal) !== 1
|
||||||
|
);
|
||||||
|
capMeshGroup.clippingPlanes = capMeshGroupPlanes;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add meshes to the scene
|
// Add meshes to the scene
|
||||||
|
@ -668,18 +674,6 @@ function generateCapMeshes(
|
||||||
capMesh.visible = mesh.visible;
|
capMesh.visible = mesh.visible;
|
||||||
capMesh.name = mesh.name;
|
capMesh.name = mesh.name;
|
||||||
|
|
||||||
// Offset mesh to avoid flickering
|
|
||||||
const normal = plane.normal.clone().multiplyScalar(10);
|
|
||||||
|
|
||||||
const positionAttr = capMesh.geometry.attributes.position;
|
|
||||||
for (let i = 0; i < positionAttr.count; i++) {
|
|
||||||
const x = positionAttr.getX(i) + normal.x;
|
|
||||||
const y = positionAttr.getY(i) + normal.y;
|
|
||||||
const z = positionAttr.getZ(i) + normal.z;
|
|
||||||
positionAttr.setXYZ(i, x, y, z);
|
|
||||||
}
|
|
||||||
positionAttr.needsUpdate = true;
|
|
||||||
|
|
||||||
if (capMesh && geometry.index && geometry.index.count > 0) {
|
if (capMesh && geometry.index && geometry.index.count > 0) {
|
||||||
capMeshGroup.add(capMesh);
|
capMeshGroup.add(capMesh);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue