three-cad-viewer 4.3.8 → 5.0.0
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 → Readme.md} +7 -5
- package/dist/core/picking-controller.d.ts +125 -0
- package/dist/core/studio-manager.d.ts +7 -0
- package/dist/core/types.d.ts +24 -6
- package/dist/core/viewer-state.d.ts +1 -1
- package/dist/core/viewer.d.ts +44 -47
- package/dist/index.d.ts +5 -5
- package/dist/rendering/environment.d.ts +3 -19
- package/dist/rendering/highlight.d.ts +209 -0
- package/dist/rendering/id-picking.d.ts +464 -0
- package/dist/rendering/light-detection.d.ts +3 -3
- package/dist/rendering/material-factory.d.ts +11 -7
- package/dist/rendering/picked.d.ts +55 -0
- package/dist/rendering/studio-composer.d.ts +3 -3
- package/dist/rendering/tree-model.d.ts +1 -1
- package/dist/scene/clipping.d.ts +53 -0
- package/dist/scene/nestedgroup.d.ts +46 -4
- package/dist/scene/objectgroup.d.ts +17 -0
- package/dist/scene/render-shape.d.ts +3 -19
- package/dist/three-cad-viewer.css +54 -20
- package/dist/three-cad-viewer.esm.js +4867 -1562
- package/dist/three-cad-viewer.esm.js.map +1 -1
- package/dist/three-cad-viewer.esm.min.js +3 -3
- package/dist/three-cad-viewer.js +4867 -1562
- package/dist/three-cad-viewer.min.js +4 -4
- package/dist/tools/cad_tools/measure.d.ts +8 -9
- package/dist/tools/cad_tools/mesh-measure.d.ts +264 -0
- package/dist/tools/cad_tools/select.d.ts +4 -3
- package/dist/tools/cad_tools/tools.d.ts +17 -5
- package/dist/tools/cad_tools/ui.d.ts +8 -6
- package/dist/ui/display.d.ts +25 -2
- package/dist/utils/utils.d.ts +1 -1
- package/package.json +4 -1
- package/dist/rendering/raycast.d.ts +0 -111
package/{README.md → Readme.md}
RENAMED
|
@@ -314,7 +314,7 @@ The keymap serves two purposes:
|
|
|
314
314
|
- **Modifier keys** (`shift`, `ctrl`, `meta`, `alt`) remap which physical modifier key is used for mouse interactions (e.g. shift-click to isolate, ctrl-rotate). Values are DOM event properties like `"shiftKey"`, `"ctrlKey"`, `"metaKey"`, `"altKey"`.
|
|
315
315
|
- **Action shortcuts** map single keys (with or without Shift) to toolbar buttons, camera presets, tab switches, and animation control. Only plain keys are supported — Ctrl/Alt/Meta combinations are reserved for modifier-based mouse interactions.
|
|
316
316
|
|
|
317
|
-
Click on the viewer to give it focus, then press shortcut keys to trigger actions. Button tooltips show
|
|
317
|
+
Click on the viewer to give it focus, then press shortcut keys to trigger actions. Button and tab tooltips show a `› key` suffix when shortcuts are configured.
|
|
318
318
|
|
|
319
319
|
The default keymap:
|
|
320
320
|
|
|
@@ -323,19 +323,19 @@ keymap: {
|
|
|
323
323
|
// Modifier keys (remap physical keys for mouse interactions)
|
|
324
324
|
shift: "shiftKey", ctrl: "ctrlKey", meta: "metaKey", alt: "altKey",
|
|
325
325
|
// Toggle buttons
|
|
326
|
-
axes: "
|
|
326
|
+
axes: "A", axes0: "0", grid: "g", gridxy: "G",
|
|
327
327
|
perspective: "p", transparent: "t", blackedges: "b",
|
|
328
328
|
explode: "x", zscale: "L",
|
|
329
|
-
distance: "D", properties: "P", select: "
|
|
329
|
+
distance: "D", properties: "P", select: "I",
|
|
330
330
|
// Execute buttons
|
|
331
331
|
reset: "R", resize: "r",
|
|
332
|
-
iso: "
|
|
332
|
+
iso: "5", front: "1", rear: "3", top: "8", bottom: "2", left: "4", right: "6",
|
|
333
333
|
// Help
|
|
334
334
|
help: "h",
|
|
335
335
|
// Animation
|
|
336
336
|
play: " ", stop: "Escape",
|
|
337
337
|
// Tab selection
|
|
338
|
-
tree: "T", clip: "C", material: "M", zebra: "Z",
|
|
338
|
+
tree: "T", clip: "C", material: "M", zebra: "Z", studio: "S",
|
|
339
339
|
}
|
|
340
340
|
```
|
|
341
341
|
|
|
@@ -347,6 +347,8 @@ const displayOptions = {
|
|
|
347
347
|
};
|
|
348
348
|
```
|
|
349
349
|
|
|
350
|
+
**Topo filter shortcuts.** When the shape filter is visible (B-rep models), the lowercase keys `a` (All), `v` (Vertex), `e` (Edge), `f` (Face), `s` (Solid) set the picking filter. These are fixed (not part of the configurable keymap) — which is why `axes` and `studio` default to the uppercase `A`/`S`.
|
|
351
|
+
|
|
350
352
|
## Examples
|
|
351
353
|
|
|
352
354
|
To understand the data format, a look at the simple 1 unit sized box might be helpful:
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import * as THREE from "three";
|
|
2
|
+
import { type IdPicker } from "../rendering/id-picking.js";
|
|
3
|
+
import { type PickedComponent } from "../rendering/picked.js";
|
|
4
|
+
import type { Shapes } from "./types.js";
|
|
5
|
+
import type { RenderedState } from "./viewer.js";
|
|
6
|
+
import type { Display } from "../ui/display.js";
|
|
7
|
+
import type { Tools } from "../tools/cad_tools/tools.js";
|
|
8
|
+
/**
|
|
9
|
+
* The narrow surface {@link PickingController} needs from its host (the Viewer).
|
|
10
|
+
* Keeps the controller decoupled from the rest of the Viewer god-object and
|
|
11
|
+
* unit-testable. `rendered` is a lazy getter that throws before render() — the
|
|
12
|
+
* controller must always read through it (never cache `nestedGroup`/`highlight`,
|
|
13
|
+
* which are rebuilt every render()).
|
|
14
|
+
*/
|
|
15
|
+
export interface PickHost {
|
|
16
|
+
readonly idPicker: IdPicker | null;
|
|
17
|
+
readonly ready: boolean;
|
|
18
|
+
readonly hasAnimationLoop: boolean;
|
|
19
|
+
/** True while the Studio (presentation) tab owns the render. */
|
|
20
|
+
readonly studioActive: boolean;
|
|
21
|
+
readonly shapes: Shapes | null;
|
|
22
|
+
readonly renderer: THREE.WebGLRenderer;
|
|
23
|
+
readonly rendered: RenderedState;
|
|
24
|
+
readonly display: Display;
|
|
25
|
+
readonly cadTools: Tools;
|
|
26
|
+
update(updateMarker: boolean, notify: boolean): void;
|
|
27
|
+
/** Restore the most recently meta-double-click-hidden leaf (hide-undo stack). */
|
|
28
|
+
showLastHidden(): void;
|
|
29
|
+
handlePick(path: string, name: string, meta: boolean, shift: boolean, alt: boolean, point: THREE.Vector3 | null, nodeType?: string | null, tree?: boolean): void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Owns all pointer-driven picking on the compact graph: hover preselection
|
|
33
|
+
* (highlight + status line), left-click selection commit, right-click/key removal,
|
|
34
|
+
* and double-click pick. Hover proposes the component under the cursor
|
|
35
|
+
* ({@link lastObject}); a left-click commits it ({@link lastSelection}) — one state
|
|
36
|
+
* machine, so both fields live here.
|
|
37
|
+
*
|
|
38
|
+
* Listener lifecycle: hover (pointermove/leave) is always-on and added at
|
|
39
|
+
* construction; selection (mousedown/mouseup + document keydown) is tool-scoped via
|
|
40
|
+
* {@link setSelectionInput}; double-click via {@link setPickHandler}. {@link dispose}
|
|
41
|
+
* tears them all down.
|
|
42
|
+
*/
|
|
43
|
+
export declare class PickingController {
|
|
44
|
+
private readonly host;
|
|
45
|
+
/** Component under the cursor (hover); committed on left-click. */
|
|
46
|
+
lastObject: PickedComponent | null;
|
|
47
|
+
/** Last committed selection. */
|
|
48
|
+
lastSelection: PickedComponent | null;
|
|
49
|
+
private idHoverClientX;
|
|
50
|
+
private idHoverClientY;
|
|
51
|
+
private idHoverInside;
|
|
52
|
+
private idHoverRenderQueued;
|
|
53
|
+
/** Per-component hover status text (fixed per mesh; cleared on reload / z-scale). */
|
|
54
|
+
private hoverStatusCache;
|
|
55
|
+
private selectionInputActive;
|
|
56
|
+
private selectDownPosition;
|
|
57
|
+
private pickHandlerActive;
|
|
58
|
+
constructor(host: PickHost);
|
|
59
|
+
/** Remove every listener this controller owns. */
|
|
60
|
+
dispose(): void;
|
|
61
|
+
/** Record the cursor position over the canvas. */
|
|
62
|
+
private onIdHoverMove;
|
|
63
|
+
/** Cursor left the canvas → clear any hover highlight. */
|
|
64
|
+
private onIdHoverLeave;
|
|
65
|
+
/**
|
|
66
|
+
* Whether hover preselection (highlight + status line) is active. Disabled for GDS:
|
|
67
|
+
* dense, stacked, instance-unrolled layout data where per-pixel hover flickers
|
|
68
|
+
* endlessly and the B-rep readout ("area ≈ …") is meaningless, so GDS is
|
|
69
|
+
* double-click-identify only. Also disabled in Studio (presentation) mode: hover
|
|
70
|
+
* tint/status is a CAD/analysis affordance, not wanted in Studio, and skipping it
|
|
71
|
+
* means the id buffer is never re-rendered for a bare mouse-move there.
|
|
72
|
+
*/
|
|
73
|
+
private hoverPreselectActive;
|
|
74
|
+
/**
|
|
75
|
+
* Called once per render: drive hover preselection unless a model is GDS or the
|
|
76
|
+
* camera is being dragged.
|
|
77
|
+
*/
|
|
78
|
+
handleHover(): void;
|
|
79
|
+
/**
|
|
80
|
+
* Hover via the GPU id picker on the compact graph: resolve the component under the
|
|
81
|
+
* cursor and drive the shader `HighlightController`. Sets {@link lastObject}
|
|
82
|
+
* (committed on left-click by {@link commitSelection} when a tool is active).
|
|
83
|
+
*/
|
|
84
|
+
private handleIdHover;
|
|
85
|
+
/** Drop the cached hover texts (e.g. on z-scale change — world lengths change). */
|
|
86
|
+
invalidateHoverCache(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Drop any lingering hover highlight + status line (keeping the committed selection).
|
|
89
|
+
* Called when entering Studio mode: hover preselection is disabled there, so the
|
|
90
|
+
* per-render {@link handleHover} no longer runs its own release and a stale tint/status
|
|
91
|
+
* from CAD mode would otherwise persist.
|
|
92
|
+
*/
|
|
93
|
+
clearHover(): void;
|
|
94
|
+
/**
|
|
95
|
+
* Whether the component a pick resolved to is currently visible — used to drop picks
|
|
96
|
+
* of hidden geometry. Visibility is the owning group's material `visible` flag
|
|
97
|
+
* (faces for solids/standalone faces; edge/vertex materials for standalone leaves).
|
|
98
|
+
*/
|
|
99
|
+
private pickVisible;
|
|
100
|
+
clearSelection: () => void;
|
|
101
|
+
private releaseLastSelected;
|
|
102
|
+
removeLastSelected(): void;
|
|
103
|
+
/** Drop selection state + hover cache + status line (on model reload). */
|
|
104
|
+
reset(): void;
|
|
105
|
+
/**
|
|
106
|
+
* Add/remove the canvas mousedown+mouseup and document keydown listeners
|
|
107
|
+
* (idempotent, guarded on `selectionInputActive`). Hover maintains
|
|
108
|
+
* {@link lastObject}; these handlers commit it on left-click and handle the key +
|
|
109
|
+
* right-click actions.
|
|
110
|
+
*/
|
|
111
|
+
setSelectionInput(flag: boolean): void;
|
|
112
|
+
private onSelectMouseDown;
|
|
113
|
+
private onSelectMouseUp;
|
|
114
|
+
private onSelectKeyDown;
|
|
115
|
+
private commitSelection;
|
|
116
|
+
setPickHandler(flag: boolean): void;
|
|
117
|
+
/**
|
|
118
|
+
* Double-click pick via the GPU id picker: `idPicker.pickAt` resolves the component
|
|
119
|
+
* under the cursor, the registry gives its owning tree-leaf path ({@link leafPath}),
|
|
120
|
+
* and the readback world-space `point` feeds `handlePick` (the `shift && meta` camera
|
|
121
|
+
* target, with a bbox-center fallback when `point` is null). No topo filter: a
|
|
122
|
+
* double-click selects whatever is under the cursor and resolves it to its leaf.
|
|
123
|
+
*/
|
|
124
|
+
private onDoubleClick;
|
|
125
|
+
}
|
|
@@ -48,6 +48,13 @@ declare class StudioManager {
|
|
|
48
48
|
private _savedClippingState;
|
|
49
49
|
private _shadowLights;
|
|
50
50
|
private _ctx;
|
|
51
|
+
/**
|
|
52
|
+
* Renderer pixel ratio saved on Studio entry, restored on leave.
|
|
53
|
+
* Studio mode bumps the pixel ratio to apply supersampling, which
|
|
54
|
+
* compensates for low DPR (e.g., VSCode webviews report DPR=1 even
|
|
55
|
+
* on Retina displays) and improves AA on shallow-angle edges.
|
|
56
|
+
*/
|
|
57
|
+
private _savedPixelRatio;
|
|
51
58
|
constructor(ctx: StudioManagerContext);
|
|
52
59
|
get isActive(): boolean;
|
|
53
60
|
get hasComposer(): boolean;
|
package/dist/core/types.d.ts
CHANGED
|
@@ -185,8 +185,12 @@ export interface DisplayOptions {
|
|
|
185
185
|
zebraTool?: boolean;
|
|
186
186
|
/** Show studio tool (default: true) */
|
|
187
187
|
studioTool?: boolean;
|
|
188
|
-
/**
|
|
189
|
-
|
|
188
|
+
/**
|
|
189
|
+
* Use an external (Python/`ocp_vscode`) measurement backend (default: false).
|
|
190
|
+
* When false, the built-in TypeScript mesh-based measurement backend answers
|
|
191
|
+
* measurements locally — so measure works without a backend connection.
|
|
192
|
+
*/
|
|
193
|
+
externalMeasurementBackend?: boolean;
|
|
190
194
|
/** External canvas element to use for the WebGL renderer, enabling shared WebGL context scenarios (default: undefined — renderer creates its own canvas) */
|
|
191
195
|
canvas?: HTMLCanvasElement;
|
|
192
196
|
/** External WebGL context to use for the renderer. When provided together with `canvas`, the renderer will use this context instead of creating a new one. Useful for sharing a context with other renderers like PixiJS. (default: undefined) */
|
|
@@ -271,6 +275,14 @@ export interface ViewerOptions extends StudioModeOptions {
|
|
|
271
275
|
zoomSpeed?: number;
|
|
272
276
|
/** Show timings in browser console (default: false) */
|
|
273
277
|
timeit?: boolean;
|
|
278
|
+
/**
|
|
279
|
+
* Tab to land on after render (default: "tree", i.e. CAD mode).
|
|
280
|
+
* When set to a non-tree tab, the initial CAD paint is skipped so the
|
|
281
|
+
* user doesn't see a brief CAD-mode flicker before the target tab takes
|
|
282
|
+
* over. Especially noticeable for "studio" (async env-map load) and
|
|
283
|
+
* "zebra" (material swap).
|
|
284
|
+
*/
|
|
285
|
+
tab?: ActiveTab;
|
|
274
286
|
}
|
|
275
287
|
/** Zebra tool options */
|
|
276
288
|
export interface ZebraOptions {
|
|
@@ -330,7 +342,7 @@ export interface ViewerStateShape {
|
|
|
330
342
|
zscaleTool: boolean;
|
|
331
343
|
zebraTool: boolean;
|
|
332
344
|
studioTool: boolean;
|
|
333
|
-
|
|
345
|
+
externalMeasurementBackend: boolean;
|
|
334
346
|
ambientIntensity: number;
|
|
335
347
|
directIntensity: number;
|
|
336
348
|
metalness: number;
|
|
@@ -493,9 +505,12 @@ export interface MaterialAppearance {
|
|
|
493
505
|
*
|
|
494
506
|
* This format is produced by the threejs-materials Python library, which catalogs
|
|
495
507
|
* PBR materials from ambientCG, GPUOpen, PolyHaven, and PhysicallyBased.
|
|
496
|
-
* `values` contains scalar properties (e.g., color as
|
|
497
|
-
* roughness as float).
|
|
498
|
-
*
|
|
508
|
+
* `values` contains scalar properties (e.g., color as an sRGB RGB array,
|
|
509
|
+
* roughness as float). Note the per-key color-space convention: `color` is
|
|
510
|
+
* sRGB-stored, while `emissive`/`specularColor`/`sheenColor`/`attenuationColor`
|
|
511
|
+
* are linear-stored (see MaterialFactory.createStudioMaterialFromMaterialX).
|
|
512
|
+
* `textures` contains texture references (inline data URIs or file paths)
|
|
513
|
+
* keyed by property name.
|
|
499
514
|
*
|
|
500
515
|
* Detected by the presence of the `values` key.
|
|
501
516
|
* Extra keys from threejs-materials (id, name, source, url, license) pass through
|
|
@@ -508,6 +523,9 @@ export interface MaterialXMaterial {
|
|
|
508
523
|
textures: Record<string, string>;
|
|
509
524
|
/** Optional texture tiling [u, v], default [1, 1]. Applied to all textures. */
|
|
510
525
|
textureRepeat?: [number, number];
|
|
526
|
+
/** Optional texture rotation in **radians**, counterclockwise. Pivot is
|
|
527
|
+
* the texture center (0.5, 0.5). Applied to all textures. */
|
|
528
|
+
textureRotation?: number;
|
|
511
529
|
}
|
|
512
530
|
/**
|
|
513
531
|
* Type guard to check if a material entry is a threejs-materials format dict.
|
package/dist/core/viewer.d.ts
CHANGED
|
@@ -19,7 +19,10 @@ import { Controls } from "../camera/controls.js";
|
|
|
19
19
|
import { Camera, type CameraDirection } from "../camera/camera.js";
|
|
20
20
|
import { BoundingBox, BoxHelper } from "../scene/bbox.js";
|
|
21
21
|
import { Tools } from "../tools/cad_tools/tools.js";
|
|
22
|
-
import {
|
|
22
|
+
import { MeshMeasureBackend } from "../tools/cad_tools/mesh-measure.js";
|
|
23
|
+
import { IdPicker } from "../rendering/id-picking.js";
|
|
24
|
+
import { type PickedComponent } from "../rendering/picked.js";
|
|
25
|
+
import { PickingController } from "./picking-controller.js";
|
|
23
26
|
import { ViewerState } from "./viewer-state.js";
|
|
24
27
|
import type { Display } from "../ui/display.js";
|
|
25
28
|
import type { Vector3Tuple, QuaternionTuple } from "three";
|
|
@@ -70,14 +73,6 @@ interface ImageResult {
|
|
|
70
73
|
task: string;
|
|
71
74
|
dataUrl: string | ArrayBuffer | null;
|
|
72
75
|
}
|
|
73
|
-
/**
|
|
74
|
-
* Raycast event from keyboard or mouse.
|
|
75
|
-
*/
|
|
76
|
-
interface RaycastEvent {
|
|
77
|
-
key?: string;
|
|
78
|
-
mouse?: "left" | "right";
|
|
79
|
-
shift?: boolean;
|
|
80
|
-
}
|
|
81
76
|
/**
|
|
82
77
|
* Backend response structure.
|
|
83
78
|
*/
|
|
@@ -90,7 +85,7 @@ interface BackendResponse {
|
|
|
90
85
|
*/
|
|
91
86
|
interface DisplayOptionsInternal {
|
|
92
87
|
measureTools?: boolean;
|
|
93
|
-
|
|
88
|
+
externalMeasurementBackend?: boolean;
|
|
94
89
|
selectTool?: boolean;
|
|
95
90
|
explodeTool?: boolean;
|
|
96
91
|
zscaleTool?: boolean;
|
|
@@ -106,7 +101,7 @@ interface DisplayOptionsInternal {
|
|
|
106
101
|
* State that exists only after render() and before clear().
|
|
107
102
|
* Groups all resources that are created together during rendering.
|
|
108
103
|
*/
|
|
109
|
-
interface RenderedState {
|
|
104
|
+
export interface RenderedState {
|
|
110
105
|
scene: THREE.Scene;
|
|
111
106
|
ambientLight: THREE.AmbientLight;
|
|
112
107
|
directLight: THREE.DirectionalLight;
|
|
@@ -167,6 +162,12 @@ declare class Viewer {
|
|
|
167
162
|
onAfterRender: (() => void) | null;
|
|
168
163
|
mouse: THREE.Vector2;
|
|
169
164
|
cadTools: Tools;
|
|
165
|
+
/**
|
|
166
|
+
* Internal mesh-based measurement backend, used when
|
|
167
|
+
* `externalMeasurementBackend === false` (the default). Resolves component paths
|
|
168
|
+
* against the compact group's {@link MeshGeometrySource}.
|
|
169
|
+
*/
|
|
170
|
+
meshBackend: MeshMeasureBackend;
|
|
170
171
|
animation: Animation;
|
|
171
172
|
clipNormals: [THREE.Vector3, THREE.Vector3, THREE.Vector3];
|
|
172
173
|
private _rendered;
|
|
@@ -193,19 +194,24 @@ declare class Viewer {
|
|
|
193
194
|
renderOptions: RenderOptions | null;
|
|
194
195
|
lastNotification: Record<string, unknown>;
|
|
195
196
|
lastBbox: LastBboxInfo | null;
|
|
196
|
-
|
|
197
|
-
lastSelection: PickedObject | null;
|
|
197
|
+
private _hiddenUndo;
|
|
198
198
|
lastPosition: THREE.Vector3 | null;
|
|
199
199
|
bboxNeedsUpdate: boolean;
|
|
200
200
|
keepHighlight: boolean;
|
|
201
|
-
expandedTree: ShapeTreeData | null;
|
|
202
201
|
compactTree: ShapeTreeData | null;
|
|
203
|
-
expandedNestedGroup: NestedGroup | null;
|
|
204
202
|
compactNestedGroup: NestedGroup | null;
|
|
205
|
-
|
|
203
|
+
private _lastPickCam;
|
|
204
|
+
private _lastPickProj;
|
|
205
|
+
private _lastClipSig;
|
|
206
|
+
private _suppressUpdate;
|
|
207
|
+
private _zebraSettingsApplied;
|
|
208
|
+
idPicker: IdPicker | null;
|
|
209
|
+
pickingController: PickingController;
|
|
206
210
|
private _studioManager;
|
|
207
211
|
/** Environment manager — proxied from StudioManager for display.ts access. */
|
|
208
212
|
get envManager(): import("../index.js").EnvironmentManager;
|
|
213
|
+
/** True while the Studio (presentation) tab owns the render. PickHost member. */
|
|
214
|
+
get studioActive(): boolean;
|
|
209
215
|
zScale: number;
|
|
210
216
|
clipNormal0: Vector3Tuple | null;
|
|
211
217
|
clipNormal1: Vector3Tuple | null;
|
|
@@ -250,11 +256,10 @@ declare class Viewer {
|
|
|
250
256
|
private getShapeRenderer;
|
|
251
257
|
/**
|
|
252
258
|
* Render the shapes of the CAD object.
|
|
253
|
-
* @param exploded - Whether to render the compact or exploded version
|
|
254
259
|
* @param shapes - The Shapes object.
|
|
255
260
|
* @returns A nested THREE.Group object and navigation tree.
|
|
256
261
|
*/
|
|
257
|
-
renderTessellatedShapes(
|
|
262
|
+
renderTessellatedShapes(shapes: Shapes): RenderResult;
|
|
258
263
|
/**
|
|
259
264
|
* Add a position animation track (full 3D translation).
|
|
260
265
|
* @param selector - path/id of group to be animated.
|
|
@@ -341,7 +346,7 @@ declare class Viewer {
|
|
|
341
346
|
* - WebGL renderer and context
|
|
342
347
|
* - All Three.js objects (geometries, materials, textures)
|
|
343
348
|
* - Event listeners
|
|
344
|
-
* - CAD tools and
|
|
349
|
+
* - CAD tools and id picker
|
|
345
350
|
*
|
|
346
351
|
* After calling dispose(), the viewer instance should not be used.
|
|
347
352
|
*
|
|
@@ -357,15 +362,6 @@ declare class Viewer {
|
|
|
357
362
|
* @public
|
|
358
363
|
*/
|
|
359
364
|
clear(): void;
|
|
360
|
-
/**
|
|
361
|
-
* Synchronizes the states of two tree structures recursively.
|
|
362
|
-
*
|
|
363
|
-
* @param compactTree - The compact tree structure.
|
|
364
|
-
* @param expandedTree - The expanded tree structure.
|
|
365
|
-
* @param exploded - Whether rendering in exploded mode.
|
|
366
|
-
* @param path - The current path in the tree structure.
|
|
367
|
-
*/
|
|
368
|
-
syncTreeStates: (compactTree: ShapeTreeData | VisibilityState, expandedTree: ShapeTreeData | VisibilityState, exploded: boolean, path: string) => void;
|
|
369
365
|
/**
|
|
370
366
|
* Get the color of a node from its path
|
|
371
367
|
* @param path - path of the CAD object
|
|
@@ -374,16 +370,9 @@ declare class Viewer {
|
|
|
374
370
|
/**
|
|
375
371
|
* Build nestedGroup and treeview for initial render.
|
|
376
372
|
* @param scene - The scene to add the group to
|
|
377
|
-
* @param expanded - whether to render the exploded or compact version
|
|
378
373
|
* @returns The nestedGroup and treeview
|
|
379
374
|
*/
|
|
380
375
|
private buildInitialGroup;
|
|
381
|
-
/**
|
|
382
|
-
* Toggle the two version of the NestedGroup.
|
|
383
|
-
* Must only be called after render() has completed.
|
|
384
|
-
* @param expanded - whether to render the exploded or compact version
|
|
385
|
-
*/
|
|
386
|
-
toggleGroup(expanded: boolean): void;
|
|
387
376
|
/**
|
|
388
377
|
* Set the active sidebar tab.
|
|
389
378
|
* @param tabName - Tab name: "tree", "clip", "material", "zebra", or "studio"
|
|
@@ -533,22 +522,30 @@ declare class Viewer {
|
|
|
533
522
|
* @param tree - whether from tree
|
|
534
523
|
*/
|
|
535
524
|
handlePick: (path: string, name: string, meta: boolean, shift: boolean, alt: boolean, point: THREE.Vector3 | null, nodeType?: string | null, tree?: boolean) => void;
|
|
536
|
-
setPickHandler(flag: boolean): void;
|
|
537
525
|
/**
|
|
538
|
-
*
|
|
539
|
-
*
|
|
526
|
+
* Record a leaf about to be hidden via meta-double-click onto the hide-undo stack,
|
|
527
|
+
* capturing its current (pre-hide) visibility state for a faithful restore. Dedups:
|
|
528
|
+
* an existing entry for the same id is dropped so the id moves to the top.
|
|
540
529
|
*/
|
|
541
|
-
|
|
542
|
-
clearSelection: () => void;
|
|
543
|
-
_releaseLastSelected: () => void;
|
|
544
|
-
_removeLastSelected: () => void;
|
|
530
|
+
private _recordHidden;
|
|
545
531
|
/**
|
|
546
|
-
*
|
|
547
|
-
*
|
|
532
|
+
* Restore the most recently meta-double-click-hidden leaf (LIFO), skipping entries
|
|
533
|
+
* that no longer apply — removed objects, or ones already shown again via the tree.
|
|
534
|
+
* In Studio the restored leaf keeps edges off (presentation); in CAD its pre-hide
|
|
535
|
+
* edge state is restored. Bound to a meta-double-click on empty space, so a hidden
|
|
536
|
+
* object can be brought back without the tree (notably in Studio). @public
|
|
548
537
|
*/
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
538
|
+
showLastHidden: () => void;
|
|
539
|
+
/** Component under the cursor (hover); committed on left-click. */
|
|
540
|
+
get lastObject(): PickedComponent | null;
|
|
541
|
+
/** Last committed selection. */
|
|
542
|
+
get lastSelection(): PickedComponent | null;
|
|
543
|
+
/** Enable/disable the double-click pick handler (on when no tool is active). */
|
|
544
|
+
setPickHandler(flag: boolean): void;
|
|
545
|
+
/** Enable/disable click+key selection input (on while a select/measure tool is active). */
|
|
546
|
+
setSelectionInput(flag: boolean): void;
|
|
547
|
+
/** Clear the current selection (and reset the select tool). */
|
|
548
|
+
clearSelection: () => void;
|
|
552
549
|
/**
|
|
553
550
|
* Handle a backend response sent by the backend
|
|
554
551
|
* The response is a JSON object sent by the Python backend through VSCode
|
package/dist/index.d.ts
CHANGED
|
@@ -15,10 +15,10 @@ import { Timer } from "./utils/timer.js";
|
|
|
15
15
|
import { logger } from "./utils/logger.js";
|
|
16
16
|
import { gpuTracker } from "./utils/gpu-tracker.js";
|
|
17
17
|
import { version } from "./_version.js";
|
|
18
|
-
export { Viewer, Display, EnvironmentManager, Timer, logger, gpuTracker, version };
|
|
19
|
-
export { MATERIAL_PRESETS, MATERIAL_PRESET_NAMES } from "./rendering/material-presets.js";
|
|
18
|
+
export { Viewer, Display, EnvironmentManager, Timer, logger, gpuTracker, version, };
|
|
19
|
+
export { MATERIAL_PRESETS, MATERIAL_PRESET_NAMES, } from "./rendering/material-presets.js";
|
|
20
20
|
export type { LogLevel } from "./utils/logger.js";
|
|
21
|
-
export type { ResourceType, TrackedResource, ResourceSummary } from "./utils/gpu-tracker.js";
|
|
21
|
+
export type { ResourceType, TrackedResource, ResourceSummary, } from "./utils/gpu-tracker.js";
|
|
22
22
|
export type { Vector3Tuple, QuaternionTuple } from "three";
|
|
23
23
|
export type { ThemeInput, Theme, ControlType, UpDirection, AnimationMode, ActiveTab, ZebraColorScheme, ZebraMappingMode, ShapeType, ShapeSubtype, Axis, ClipIndex, ColorValue, RGBColor, RGBAColor, AxisColors, AxisColorsFlatArray, } from "./core/types.js";
|
|
24
24
|
export { CLIP_INDICES, isClipIndex, CollapseState } from "./core/types.js";
|
|
@@ -27,12 +27,12 @@ export type { BoundingBox, BoundingSphere, BoundingBoxFlat, } from "./core/types
|
|
|
27
27
|
export type { PickInfo } from "./core/types.js";
|
|
28
28
|
export type { ChangeInfos, ChangeNotification, NotificationCallback, } from "./core/types.js";
|
|
29
29
|
export type { DisplayOptions, RenderOptions, ViewerOptions, ZebraOptions, CombinedOptions, } from "./core/types.js";
|
|
30
|
-
export type { ViewerStateShape, StateKey
|
|
30
|
+
export type { ViewerStateShape, StateKey } from "./core/types.js";
|
|
31
31
|
export type { Texture, Shape, ShapeBinary, ShapeNested, Location, VisibilityValue, VisibilityState, Shapes, } from "./core/types.js";
|
|
32
32
|
export { isShapeBinaryFormat, hasTrianglesPerFace, hasSegmentsPerEdge, } from "./core/types.js";
|
|
33
33
|
export type { DomEventCallback } from "./core/types.js";
|
|
34
34
|
export type { ColoredMaterial } from "./core/types.js";
|
|
35
35
|
export type { MaterialAppearance, MaterialXMaterial, StudioOptions, StudioBackground, StudioModeOptions, StudioEnvironment, StudioToneMapping, StudioTextureMapping, } from "./core/types.js";
|
|
36
36
|
export { isMaterialXMaterial } from "./core/types.js";
|
|
37
|
-
export { isInstancedFormat, decodeInstancedFormat } from "./utils/decode-instances.js";
|
|
37
|
+
export { isInstancedFormat, decodeInstancedFormat, } from "./utils/decode-instances.js";
|
|
38
38
|
export type { SubscribeOptions } from "./core/types.js";
|
|
@@ -31,14 +31,6 @@ interface EnvironmentManagerOptions {
|
|
|
31
31
|
declare class EnvironmentManager {
|
|
32
32
|
/** Cached PMREM render targets keyed by environment name or URL */
|
|
33
33
|
private _cache;
|
|
34
|
-
/**
|
|
35
|
-
* Cached raw equirectangular HDR textures keyed by the same name/URL.
|
|
36
|
-
* Preserved (not disposed after PMREM generation) so `scene.background`
|
|
37
|
-
* can sample the original HDR at full source resolution instead of the
|
|
38
|
-
* 256² PMREM cubemap. Only populated by `_loadHdr` — procedural
|
|
39
|
-
* environments have no source HDR.
|
|
40
|
-
*/
|
|
41
|
-
private _hdrCache;
|
|
42
34
|
/** Cached light detection results keyed by environment name or URL */
|
|
43
35
|
private _lightDetectionCache;
|
|
44
36
|
/** In-flight load promises keyed by environment name or URL */
|
|
@@ -55,13 +47,6 @@ declare class EnvironmentManager {
|
|
|
55
47
|
private _hdrLoader;
|
|
56
48
|
/** The last loaded PMREM texture (stateful — used by apply() for IBL) */
|
|
57
49
|
private _currentTexture;
|
|
58
|
-
/**
|
|
59
|
-
* Raw HDR texture corresponding to `_currentTexture`, used for
|
|
60
|
-
* `scene.background` to keep the backdrop at source resolution. Null when
|
|
61
|
-
* the current environment is procedural ("studio" RoomEnvironment) — in
|
|
62
|
-
* that case the background falls back to `_currentTexture` (the PMREM).
|
|
63
|
-
*/
|
|
64
|
-
private _currentBackgroundTexture;
|
|
65
50
|
/** Whether this manager has been disposed */
|
|
66
51
|
private _disposed;
|
|
67
52
|
/**
|
|
@@ -236,10 +221,9 @@ declare class EnvironmentManager {
|
|
|
236
221
|
* Load an HDR file and generate a PMREM texture from it.
|
|
237
222
|
*
|
|
238
223
|
* Uses HDRLoader to fetch the .hdr file, then PMREMGenerator.fromEquirectangular()
|
|
239
|
-
* to create the PMREM cubemap
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
* instead of the 256² PMREM cubemap.
|
|
224
|
+
* to create the PMREM cubemap. The source equirectangular HDR is disposed
|
|
225
|
+
* after PMREM generation. The PMREM texture itself serves as both the IBL
|
|
226
|
+
* environment and the background (in "environment" mode).
|
|
243
227
|
*
|
|
244
228
|
* @param url - URL of the .hdr file
|
|
245
229
|
* @param cacheKey - Cache key for the resulting PMREM render target
|