@kupcad/ui 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -9
- package/package.json +5 -4
- package/src/ConsolePanel.svelte +2 -1
- package/src/PreviewPanel.svelte +25 -11
- package/src/ViewerPane.svelte +31 -1
- package/src/console.js +12 -3
- package/src/index.js +8 -1
- package/src/params.js +91 -12
- package/src/run-status.js +5 -1
- package/src/settings.js +53 -19
- package/src/viewer/appearance.js +2 -1
- package/src/viewer/brand.js +13 -0
- package/src/viewer/environment.js +8 -0
- package/src/viewer/faces.js +20 -151
- package/src/viewer/hits.js +41 -0
- package/src/viewer/hover-mark.js +5 -0
- package/src/viewer/model.js +17 -9
- package/src/viewer/section.js +12 -4
- package/src/viewer/theme.js +7 -5
- package/src/viewer/topology.js +223 -0
- package/src/viewer/viewer.js +12 -8
package/src/viewer/viewer.js
CHANGED
|
@@ -43,6 +43,7 @@ import { disposeObject } from './dispose.js';
|
|
|
43
43
|
import { axesOf, environmentOf } from './environment.js';
|
|
44
44
|
import { faceAt } from './faces.js';
|
|
45
45
|
import { HoverMark } from './hover-mark.js';
|
|
46
|
+
import { intersectMeshes } from './hits.js';
|
|
46
47
|
import { disposeScene, isDracoCompressed, sceneOf } from './model.js';
|
|
47
48
|
import { CameraMove, MOTION_MS, sameDirection, unit } from './motion.js';
|
|
48
49
|
import { RENDER_ORDER, SectionView } from './section.js';
|
|
@@ -124,7 +125,8 @@ export class Viewer extends EventTarget {
|
|
|
124
125
|
#sectionView;
|
|
125
126
|
#raycaster = new Raycaster();
|
|
126
127
|
/** The selected part's edges, in the selection's colour. */
|
|
127
|
-
|
|
128
|
+
// See-through to three.js, as a drawing's outlines are, so a selected one keeps its order
|
|
129
|
+
#selectionEdges = new LineBasicMaterial({ transparent: true });
|
|
128
130
|
/** What the pointer is over, marked. */
|
|
129
131
|
#hoverMark = new HoverMark(LIGHT.selection);
|
|
130
132
|
/** @type {SceneModel | null} */
|
|
@@ -305,7 +307,10 @@ export class Viewer extends EventTarget {
|
|
|
305
307
|
}
|
|
306
308
|
this.#model = built;
|
|
307
309
|
if (built) {
|
|
308
|
-
|
|
310
|
+
// A drawing's shapes keep their own order (model.js); a section cuts solids alone
|
|
311
|
+
if (built.kind === '3d') {
|
|
312
|
+
for (const shape of built.shapes) shape.mesh.renderOrder = RENDER_ORDER.model;
|
|
313
|
+
}
|
|
309
314
|
this.#content.add(built.root);
|
|
310
315
|
}
|
|
311
316
|
const dropped =
|
|
@@ -866,16 +871,15 @@ export class Viewer extends EventTarget {
|
|
|
866
871
|
this.#camera.updateMatrixWorld();
|
|
867
872
|
const pointer = new Vector2((x / this.#width) * 2 - 1, 1 - (y / this.#height) * 2);
|
|
868
873
|
this.#raycaster.setFromCamera(pointer, this.#camera);
|
|
874
|
+
const solid = this.#model.shapes.filter((shape) => !shape.ghost);
|
|
869
875
|
/** @type {Map<import('three').Object3D, Shape>} */
|
|
870
|
-
const
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
}
|
|
874
|
-
for (const hit of this.#raycaster.intersectObjects([...solid.keys()], false)) {
|
|
876
|
+
const shapeOf = new Map(solid.map((shape) => [shape.mesh, shape]));
|
|
877
|
+
const meshes = solid.map((shape) => shape.mesh);
|
|
878
|
+
for (const hit of intersectMeshes(this.#raycaster, meshes)) {
|
|
875
879
|
if (this.#sectionView.clipping && this.#sectionView.plane.distanceToPoint(hit.point) < 0) {
|
|
876
880
|
continue;
|
|
877
881
|
}
|
|
878
|
-
const shape = /** @type {Shape} */ (
|
|
882
|
+
const shape = /** @type {Shape} */ (shapeOf.get(hit.object));
|
|
879
883
|
return { shape, triangle: hit.faceIndex ?? null };
|
|
880
884
|
}
|
|
881
885
|
return null;
|