@selvajs/visualization 1.0.0-beta.0 → 1.0.0-beta.2
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 +11 -10
- package/dist/gpu-dispose-Dkj-BKt4.js +2 -0
- package/dist/gpu-dispose-Dkj-BKt4.js.map +1 -0
- package/dist/gpu-dispose-DrN-ryj5.cjs +2 -0
- package/dist/gpu-dispose-DrN-ryj5.cjs.map +1 -0
- package/dist/index.cjs +0 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -1
- package/dist/parse.cjs +3 -3
- package/dist/parse.cjs.map +1 -1
- package/dist/parse.d.cts +135 -142
- package/dist/parse.d.ts +135 -142
- package/dist/parse.js +3 -3
- package/dist/parse.js.map +1 -1
- package/dist/render.cjs +8 -10
- package/dist/render.cjs.map +1 -1
- package/dist/render.d.cts +335 -333
- package/dist/render.d.ts +335 -333
- package/dist/render.js +8 -10
- package/dist/render.js.map +1 -1
- package/dist/rolldown-runtime-BocRIvOZ.cjs +1 -0
- package/dist/scene.cjs +1 -1
- package/dist/scene.cjs.map +1 -1
- package/dist/scene.d.cts +95 -95
- package/dist/scene.d.ts +95 -95
- package/dist/scene.js +1 -1
- package/dist/scene.js.map +1 -1
- package/dist/types-Di80Y609.d.cts +34 -0
- package/dist/types-Di80Y609.d.ts +34 -0
- package/package.json +14 -10
- package/dist/chunk-5XGN7UAV.js +0 -2
- package/dist/chunk-5XGN7UAV.js.map +0 -1
- package/dist/chunk-AQJPVUH3.cjs +0 -2
- package/dist/chunk-AQJPVUH3.cjs.map +0 -1
- package/dist/chunk-BYLIBOAU.cjs +0 -2
- package/dist/chunk-BYLIBOAU.cjs.map +0 -1
- package/dist/chunk-EXAI6IC5.js +0 -2
- package/dist/chunk-EXAI6IC5.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/types-CdF9R3qA.d.cts +0 -41
- package/dist/types-CdF9R3qA.d.ts +0 -41
package/dist/render.d.ts
CHANGED
|
@@ -1,50 +1,52 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
import { OrbitControls } from
|
|
5
|
-
|
|
1
|
+
import { i as MaterialAppearanceOptions, n as Look, r as LookPreset, t as LOOKS } from "./types-Di80Y609.js";
|
|
2
|
+
import * as THREE from "three";
|
|
3
|
+
import { CSS2DObject } from "three/addons/renderers/CSS2DRenderer.js";
|
|
4
|
+
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
|
|
5
|
+
//#region src/shared/errors.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Errors for the visualization package. Replaces `@selvajs/compute`'s `RhinoComputeError`, which
|
|
8
8
|
* mis-named failures on paths (e.g. the plugin WebSocket) that never touch Rhino.Compute. `code`
|
|
9
9
|
* values match compute's so existing catch-sites keep working.
|
|
10
10
|
*/
|
|
11
11
|
declare const ErrorCodes: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
/** Structural check failed: bad magic bytes, out-of-window index, malformed metadata. */
|
|
13
|
+
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
14
|
+
readonly INVALID_STATE: "INVALID_STATE";
|
|
15
|
+
/** No `DecompressionStream`, no WebGL context, etc. */
|
|
16
|
+
readonly ENVIRONMENT_ERROR: "ENVIRONMENT_ERROR";
|
|
17
|
+
readonly INVALID_CONFIG: "INVALID_CONFIG";
|
|
18
|
+
/** Base64 input could not be decoded. */
|
|
19
|
+
readonly ENCODING_ERROR: "ENCODING_ERROR";
|
|
20
|
+
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
21
21
|
};
|
|
22
22
|
type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
23
23
|
declare class VisualizationError extends Error {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
readonly code: ErrorCode;
|
|
25
|
+
readonly context?: Record<string, unknown>;
|
|
26
|
+
readonly originalError?: Error;
|
|
27
|
+
constructor(message: string, code?: ErrorCode, options?: {
|
|
28
|
+
context?: Record<string, unknown>;
|
|
29
|
+
originalError?: Error;
|
|
30
|
+
});
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/shared/logger.d.ts
|
|
33
34
|
/**
|
|
34
35
|
* Logging facility for the visualization package. Deliberately local rather than imported from
|
|
35
36
|
* `@selvajs/compute` (logging isn't a compute concern). Mirrors compute's logger shape so a host
|
|
36
37
|
* wanting one sink for both can call `setLogger(computeLogger.getLogger())`.
|
|
37
38
|
*/
|
|
38
39
|
interface Logger {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
debug(message: string, ...args: unknown[]): void;
|
|
41
|
+
info(message: string, ...args: unknown[]): void;
|
|
42
|
+
warn(message: string, ...args: unknown[]): void;
|
|
43
|
+
error(message: string, ...args: unknown[]): void;
|
|
43
44
|
}
|
|
44
45
|
declare function getLogger(): Logger;
|
|
45
46
|
declare function setLogger(logger: Logger | Console | null): void;
|
|
46
47
|
declare function enableDebugLogging(): void;
|
|
47
|
-
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/shared/looks.d.ts
|
|
48
50
|
/** The look applied when the caller passes no `look` option. */
|
|
49
51
|
declare const DEFAULT_LOOK: Look;
|
|
50
52
|
/**
|
|
@@ -57,209 +59,206 @@ declare const DEFAULT_LOOK: Look;
|
|
|
57
59
|
declare const LOOK_PRESETS: Record<Look, LookPreset>;
|
|
58
60
|
/** Baked at parse time (not toggleable at runtime). */
|
|
59
61
|
declare function materialAppearanceForLook(look: Look): MaterialAppearanceOptions;
|
|
60
|
-
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/render/types.d.ts
|
|
61
64
|
type CameraConfig = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
65
|
+
position?: THREE.Vector3;
|
|
66
|
+
fov?: number;
|
|
67
|
+
near?: number;
|
|
68
|
+
far?: number;
|
|
69
|
+
target?: THREE.Vector3;
|
|
70
|
+
/**
|
|
71
|
+
* Refit the near plane to the camera↔content gap every frame (default true) — recovers
|
|
72
|
+
* depth-buffer precision when zoomed out, preventing distant z-fighting. `near` is only ever
|
|
73
|
+
* raised, never lowered below the configured value.
|
|
74
|
+
*/
|
|
75
|
+
dynamicNear?: boolean;
|
|
73
76
|
};
|
|
74
77
|
type LightingConfig = {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
78
|
+
enableSunlight?: boolean;
|
|
79
|
+
sunlightIntensity?: number;
|
|
80
|
+
sunlightPosition?: THREE.Vector3;
|
|
81
|
+
ambientLightColor?: THREE.Color;
|
|
82
|
+
ambientLightIntensity?: number;
|
|
83
|
+
sunlightColor?: THREE.Color | number;
|
|
84
|
+
/**
|
|
85
|
+
* Direction-aware fill (sky color above, ground color below) so surfaces facing away from the
|
|
86
|
+
* sun don't collapse to black under a dark HDR. Default false — enabling it shifts the look.
|
|
87
|
+
*/
|
|
88
|
+
enableHemisphereLight?: boolean;
|
|
89
|
+
/** Default white. */
|
|
90
|
+
hemisphereSkyColor?: THREE.Color | number;
|
|
91
|
+
/** Default a mid grey. */
|
|
92
|
+
hemisphereGroundColor?: THREE.Color | number;
|
|
93
|
+
/** Default 0.6. Only applies when {@link LightingConfig.enableHemisphereLight}. */
|
|
94
|
+
hemisphereIntensity?: number;
|
|
92
95
|
};
|
|
93
96
|
type EnvironmentConfig = {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
*/
|
|
109
|
-
environmentIntensity?: number;
|
|
97
|
+
hdrPath?: string;
|
|
98
|
+
backgroundColor?: THREE.Color | string;
|
|
99
|
+
enableEnvironmentLighting?: boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Default `(0, 0, 1)` — Rhino's Z-up. Every orientation default derives from this (see `up-axis.ts`);
|
|
102
|
+
* overriding it reorients the viewer only, it does not rotate incoming geometry.
|
|
103
|
+
*/
|
|
104
|
+
sceneUp?: THREE.Vector3;
|
|
105
|
+
showEnvironment?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Multiplier on the HDR's image-based lighting contribution — normalizes brightness across HDRs
|
|
108
|
+
* of differing exposure. Default 1 (unchanged look).
|
|
109
|
+
*/
|
|
110
|
+
environmentIntensity?: number;
|
|
110
111
|
};
|
|
111
112
|
type FloorConfig = {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
enabled?: boolean;
|
|
114
|
+
size?: number;
|
|
115
|
+
color?: THREE.Color | string;
|
|
116
|
+
roughness?: number;
|
|
117
|
+
metalness?: number;
|
|
118
|
+
receiveShadow?: boolean;
|
|
118
119
|
};
|
|
119
120
|
type RenderConfig = {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
121
|
+
enableShadows?: boolean;
|
|
122
|
+
shadowMapSize?: number;
|
|
123
|
+
antialias?: boolean;
|
|
124
|
+
pixelRatio?: number;
|
|
125
|
+
toneMapping?: THREE.ToneMapping;
|
|
126
|
+
toneMappingExposure?: number;
|
|
127
|
+
preserveDrawingBuffer?: boolean;
|
|
128
|
+
/** Default false — switches rendering from `renderer.render` to an EffectComposer, which costs more. */
|
|
129
|
+
ambientOcclusion?: boolean;
|
|
130
|
+
/** AO strength 0–1 when {@link RenderConfig.ambientOcclusion} is on. Default 1. */
|
|
131
|
+
aoIntensity?: number;
|
|
132
|
+
/**
|
|
133
|
+
* DPR cap for AO buffers — AO is low-frequency, so sampling below display DPR is nearly invisible
|
|
134
|
+
* but much cheaper (a DPR-2 display would otherwise push 4× the pixels through GTAO's per-pixel
|
|
135
|
+
* sample loop). Default 1; only relevant when AO is enabled.
|
|
136
|
+
*/
|
|
137
|
+
aoPixelRatio?: number;
|
|
138
|
+
/**
|
|
139
|
+
* Render only on change (camera motion, invalidate(), pointer input, resize) plus a ~500ms safety
|
|
140
|
+
* repaint, instead of every frame. Default true — cuts idle GPU/battery use. Set false to restore
|
|
141
|
+
* a continuous loop.
|
|
142
|
+
*/
|
|
143
|
+
onDemand?: boolean;
|
|
143
144
|
};
|
|
144
|
-
|
|
145
|
-
/** Crisp boundary/crease edge overlays on meshes. See `addEdges`. */
|
|
145
|
+
/** Crisp boundary/crease edge overlays on meshes. Field rationale: see `EdgeOptions` in `edges/options.ts`. */
|
|
146
146
|
type EdgesConfig = {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
* (constant cost regardless of triangle count). Default true. */
|
|
165
|
-
screenSpaceFallback?: boolean;
|
|
147
|
+
/** Default false (opt-in). */
|
|
148
|
+
enabled?: boolean;
|
|
149
|
+
color?: THREE.ColorRepresentation;
|
|
150
|
+
/** 0–1, default 0.75. Ignored when `color` is set. */
|
|
151
|
+
darken?: number;
|
|
152
|
+
/** CSS px. Default 1.5. */
|
|
153
|
+
width?: number;
|
|
154
|
+
/** Degrees. Default 44. */
|
|
155
|
+
thresholdAngle?: number;
|
|
156
|
+
/** Default true. */
|
|
157
|
+
distanceFade?: boolean;
|
|
158
|
+
/** Default 4M. */
|
|
159
|
+
maxTriangles?: number;
|
|
160
|
+
/** Default 2M. */
|
|
161
|
+
maxSegments?: number;
|
|
162
|
+
/** Fall back to the screen-space edge-detection pass for meshes skipped by `maxTriangles`. Default true. */
|
|
163
|
+
screenSpaceFallback?: boolean;
|
|
166
164
|
};
|
|
167
165
|
type ControlsConfig = {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
166
|
+
enableDamping?: boolean;
|
|
167
|
+
dampingFactor?: number;
|
|
168
|
+
autoRotate?: boolean;
|
|
169
|
+
autoRotateSpeed?: number;
|
|
170
|
+
enableZoom?: boolean;
|
|
171
|
+
enablePan?: boolean;
|
|
172
|
+
minDistance?: number;
|
|
173
|
+
maxDistance?: number;
|
|
176
174
|
};
|
|
177
175
|
/** Infinite distance-fading reference grid. See `createGrid`. */
|
|
178
176
|
type GridConfig = {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
177
|
+
/** Default false (opt-in). */
|
|
178
|
+
enabled?: boolean;
|
|
179
|
+
/** World units (meters). Default 1. */
|
|
180
|
+
cellSize?: number;
|
|
181
|
+
/** Minor cells per major line. Default 10. */
|
|
182
|
+
majorEvery?: number;
|
|
183
|
+
cellColor?: THREE.ColorRepresentation;
|
|
184
|
+
majorColor?: THREE.ColorRepresentation;
|
|
185
|
+
/** World radius at which the grid fully fades. Default 100. */
|
|
186
|
+
fadeDistance?: number;
|
|
187
|
+
/**
|
|
188
|
+
* Axis the grid lies perpendicular to. Defaults to whichever axis `sceneUp` points along
|
|
189
|
+
* (`'z'` unless `sceneUp` is overridden); set explicitly to force an orientation that ignores it.
|
|
190
|
+
*/
|
|
191
|
+
plane?: 'x' | 'y' | 'z';
|
|
194
192
|
};
|
|
195
193
|
/** Corner nav-cube/axis gizmo that snaps to preset views. See `createViewGizmo`. */
|
|
196
194
|
type GizmoConfig = {
|
|
197
|
-
|
|
198
|
-
|
|
195
|
+
/** Default false (opt-in). */
|
|
196
|
+
enabled?: boolean;
|
|
199
197
|
};
|
|
200
198
|
/** Two-click distance measurement tool. See `createMeasureTool`. */
|
|
201
199
|
type MeasureConfig = {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
200
|
+
/** Default false. Only builds the tool; start measuring via `measureTool.setEnabled(true)` on the init result. */
|
|
201
|
+
enabled?: boolean;
|
|
202
|
+
/** Snap to a vertex within this many screen px. Default 12. */
|
|
203
|
+
snapPixels?: number;
|
|
204
|
+
/** Default yellow. */
|
|
205
|
+
color?: THREE.ColorRepresentation;
|
|
206
|
+
/** CSS class for the distance label. */
|
|
207
|
+
labelClassName?: string;
|
|
208
|
+
/** Scene is in meters; pass the response's `modelunits` to convert the label (e.g. "25.0 mm"). Default meters. Ignored if `format` is set. */
|
|
209
|
+
displayUnit?: string;
|
|
210
|
+
/** Receives the straight-line `distance` and per-axis `delta`. Default renders the total plus a Δx/Δy/Δz breakdown. */
|
|
211
|
+
format?: (distance: number, delta: THREE.Vector3) => string;
|
|
214
212
|
};
|
|
215
213
|
type ThreeInitializerOptions = {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
214
|
+
sceneScale?: 'mm' | 'cm' | 'm' | 'inches' | 'feet';
|
|
215
|
+
/**
|
|
216
|
+
* Seeds lighting/material defaults (tone mapping, AO, IBL strength, hemisphere fill); explicit
|
|
217
|
+
* `lighting`/`environment`/`render` options still win. Does NOT touch edges/grid. Default
|
|
218
|
+
* 'technical'. Re-apply later via the init result's `setLook`.
|
|
219
|
+
*/
|
|
220
|
+
look?: Look;
|
|
221
|
+
camera?: CameraConfig;
|
|
222
|
+
lighting?: LightingConfig;
|
|
223
|
+
environment?: EnvironmentConfig;
|
|
224
|
+
floor?: FloorConfig;
|
|
225
|
+
render?: RenderConfig;
|
|
226
|
+
controls?: ControlsConfig;
|
|
227
|
+
grid?: GridConfig;
|
|
228
|
+
gizmo?: GizmoConfig;
|
|
229
|
+
edges?: EdgesConfig;
|
|
230
|
+
measure?: MeasureConfig;
|
|
231
|
+
events?: EventConfig;
|
|
232
|
+
/**
|
|
233
|
+
* Called once at init with the GPU's max anisotropy. Not needed for sharp textures — `parse/`'s
|
|
234
|
+
* texture cache subscribes to this value on its own (see README's render↔parse seam). Only for
|
|
235
|
+
* hosts doing their own texture work.
|
|
236
|
+
*/
|
|
237
|
+
onMaxAnisotropy?: (value: number) => void;
|
|
240
238
|
};
|
|
241
239
|
type EventConfig = {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
240
|
+
onBackgroundClicked?: (event: {
|
|
241
|
+
x: number;
|
|
242
|
+
y: number;
|
|
243
|
+
}) => void;
|
|
244
|
+
onObjectSelected?: (object: THREE.Object3D) => void;
|
|
245
|
+
/** Receives the clicked mesh's `userData`; only fires for meshes with non-empty `userData`. */
|
|
246
|
+
onMeshMetadataClicked?: (metadata: Record<string, unknown>) => void;
|
|
247
|
+
onMeshDoubleClicked?: (object: THREE.Object3D) => void;
|
|
248
|
+
/** Default red (#ff0000). */
|
|
249
|
+
selectionColor?: THREE.Color | string;
|
|
250
|
+
/** Enable all event handlers (click/selection/metadata). Default true. */
|
|
251
|
+
enableEventHandlers?: boolean;
|
|
252
|
+
enableKeyboardControls?: boolean;
|
|
253
|
+
enableClickToFocus?: boolean;
|
|
254
|
+
/** Default true. */
|
|
255
|
+
enableDoubleClickZoom?: boolean;
|
|
256
|
+
onReady?: () => void;
|
|
257
|
+
/** Fires every animation frame, after controls update and before render. */
|
|
258
|
+
onFrame?: (delta: number) => void;
|
|
261
259
|
};
|
|
262
|
-
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/render/camera-controller.d.ts
|
|
263
262
|
/**
|
|
264
263
|
* Runtime camera control: preset views, perspective⇄orthographic toggle, rotate lock.
|
|
265
264
|
*
|
|
@@ -267,164 +266,167 @@ type EventConfig = {
|
|
|
267
266
|
* render loop renders, resize reshapes, and the raycaster picks with — {@link getActiveCamera} is
|
|
268
267
|
* the one source of truth for all four call sites.
|
|
269
268
|
*
|
|
270
|
-
* Orthographic
|
|
271
|
-
* distance
|
|
269
|
+
* Orthographic mirrors perspective's position/target with a frustum derived from perspective's FOV
|
|
270
|
+
* and distance, so switching projections doesn't visually jump.
|
|
272
271
|
*/
|
|
273
272
|
type ViewPreset = 'top' | 'bottom' | 'front' | 'back' | 'left' | 'right' | 'iso';
|
|
274
273
|
type CameraProjection = 'perspective' | 'orthographic';
|
|
275
274
|
interface CameraController {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
275
|
+
/** Swaps identity on {@link setProjection}. */
|
|
276
|
+
getActiveCamera(): THREE.Camera;
|
|
277
|
+
getProjection(): CameraProjection;
|
|
278
|
+
setProjection(projection: CameraProjection): void;
|
|
279
|
+
toggleProjection(): CameraProjection;
|
|
280
|
+
setView(preset: ViewPreset, animate?: boolean): void;
|
|
281
|
+
/**
|
|
282
|
+
* Frame current content from an explicit world-space direction (target → camera) instead of a
|
|
283
|
+
* named preset — used by the nav-cube, whose clicked axis is a world axis.
|
|
284
|
+
*/
|
|
285
|
+
setViewDirection(direction: THREE.Vector3, animate?: boolean): void;
|
|
286
|
+
/** Frame a world-space box from the current view direction. No-op on an empty box. */
|
|
287
|
+
frameBounds(box: THREE.Box3, animate?: boolean): void;
|
|
288
|
+
setRotateEnabled(enabled: boolean): void;
|
|
289
|
+
isRotateEnabled(): boolean;
|
|
290
|
+
updateAspect(width: number, height: number): void;
|
|
291
|
+
/** Cancel any in-flight camera tween. Call on viewer teardown so ticks can't touch disposed controls. */
|
|
292
|
+
dispose(): void;
|
|
294
293
|
}
|
|
295
|
-
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region src/render/grid.d.ts
|
|
296
296
|
interface Grid {
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
297
|
+
/** Tagged `userData.id = 'grid'` so pick/fit code skips it. */
|
|
298
|
+
readonly object: THREE.Mesh;
|
|
299
|
+
/** Re-centers the fade on the camera so the grid feels infinite as you move. Call per frame. */
|
|
300
|
+
update(cameraPosition: THREE.Vector3): void;
|
|
301
|
+
/**
|
|
302
|
+
* Rescales cell spacing and fade radius to the content's extent, so a 3-unit or 3000-unit part
|
|
303
|
+
* both get sensible cells. No-op for empty/degenerate bounds.
|
|
304
|
+
*/
|
|
305
|
+
fitToContent(bounds: THREE.Box3): void;
|
|
306
|
+
setVisible(visible: boolean): void;
|
|
307
|
+
dispose(): void;
|
|
308
308
|
}
|
|
309
|
-
|
|
309
|
+
//#endregion
|
|
310
|
+
//#region src/render/measure.d.ts
|
|
310
311
|
/**
|
|
311
312
|
* Two-click distance measurement. Click a point, click a second, read the distance off a label on
|
|
312
313
|
* the connecting line; a third click starts fresh.
|
|
313
314
|
*
|
|
314
|
-
* Picking snaps to the nearest vertex
|
|
315
|
-
*
|
|
316
|
-
*
|
|
315
|
+
* Picking snaps to the nearest vertex within {@link MeasureOptions.snapPixels} so measurements
|
|
316
|
+
* land exactly on vertices rather than wherever the ray happened to hit — a cheap local snap
|
|
317
|
+
* against the struck primitive's own vertices, no spatial index.
|
|
317
318
|
*
|
|
318
319
|
* Dormant until {@link MeasureTool.setEnabled}(true). While enabled it intercepts clicks (caller
|
|
319
320
|
* forwards them and swallows the event when {@link MeasureTool.handleClick} returns true) so
|
|
320
321
|
* measuring doesn't also select objects.
|
|
321
322
|
*/
|
|
322
323
|
interface MeasureTool {
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
324
|
+
setEnabled(enabled: boolean): void;
|
|
325
|
+
isEnabled(): boolean;
|
|
326
|
+
/** Returns true if the tool consumed the click (caller should not also select). */
|
|
327
|
+
handleClick(event: MouseEvent): boolean;
|
|
328
|
+
/** Preview the next snap point via a ghost marker. No-op when disabled; never consumes the event. */
|
|
329
|
+
handleMove(event: MouseEvent): void;
|
|
330
|
+
clear(): void;
|
|
331
|
+
dispose(): void;
|
|
331
332
|
}
|
|
332
|
-
|
|
333
|
+
//#endregion
|
|
334
|
+
//#region src/render/view-gizmo.d.ts
|
|
333
335
|
/**
|
|
334
|
-
* Corner nav-cube/axis gizmo. Uses three's {@link ViewHelper} only as the rendered widget,
|
|
336
|
+
* Corner nav-cube/axis gizmo. Uses three's {@link ViewHelper} only as the rendered widget, not its
|
|
335
337
|
* click→animate behavior: ViewHelper's snap assumes Y-up and animates straight onto the up axis,
|
|
336
|
-
* which rolls the view and jitters the gizmo at the pole in
|
|
337
|
-
* axis sprites
|
|
338
|
-
* with a pole nudge so the orbit basis never degenerates.
|
|
338
|
+
* which rolls the view and jitters the gizmo at the pole in a Z-up scene. Instead this hit-tests
|
|
339
|
+
* the axis sprites directly and drives the viewer's up-aware camera controller, which snaps
|
|
340
|
+
* instantly with a pole nudge so the orbit basis never degenerates.
|
|
339
341
|
*
|
|
340
|
-
* A click frames the current orbit target (not the world origin)
|
|
341
|
-
*
|
|
342
|
+
* A click frames the current orbit target (not the world origin) and switches back to perspective
|
|
343
|
+
* first if orthographic — the cube is a 3D-orientation tool.
|
|
342
344
|
*
|
|
343
|
-
* Caller contract (mirrors ViewHelper's own): call {@link ViewGizmo.render}
|
|
345
|
+
* Caller contract (mirrors ViewHelper's own): call {@link ViewGizmo.render} after the main scene
|
|
344
346
|
* render each frame, and forward pointer clicks to {@link ViewGizmo.handleClick}.
|
|
345
347
|
*/
|
|
346
348
|
interface ViewGizmo {
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
349
|
+
render(renderer: THREE.WebGLRenderer): void;
|
|
350
|
+
/** Returns true if it hit the gizmo (and a view change started). */
|
|
351
|
+
handleClick(event: MouseEvent): boolean;
|
|
352
|
+
setVisible(visible: boolean): void;
|
|
353
|
+
isVisible(): boolean;
|
|
354
|
+
dispose(): void;
|
|
353
355
|
}
|
|
354
|
-
|
|
356
|
+
//#endregion
|
|
357
|
+
//#region src/render/scene-setup/viewer.d.ts
|
|
355
358
|
interface ThreeViewer {
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
addUserGeometry: (object: THREE.Object3D) => void;
|
|
420
|
-
removeUserGeometry: (object: THREE.Object3D) => void;
|
|
421
|
-
/** Removes and disposes everything added via `addUserGeometry`. */
|
|
422
|
-
clearUserGeometry: () => void;
|
|
359
|
+
scene: THREE.Scene;
|
|
360
|
+
camera: THREE.PerspectiveCamera;
|
|
361
|
+
controls: OrbitControls;
|
|
362
|
+
renderer: THREE.WebGLRenderer;
|
|
363
|
+
cameraController: CameraController;
|
|
364
|
+
grid: Grid | null;
|
|
365
|
+
gizmo: ViewGizmo | null;
|
|
366
|
+
/** Null unless `measure.enabled`. */
|
|
367
|
+
measureTool: MeasureTool | null;
|
|
368
|
+
/**
|
|
369
|
+
* No-op unless `edges.enabled`. Extraction runs off-thread for large meshes, so overlays can
|
|
370
|
+
* attach a beat later; meshes over `edges.maxTriangles` fall back to the screen-space edge shader.
|
|
371
|
+
*/
|
|
372
|
+
applyEdges: (root: THREE.Object3D) => void;
|
|
373
|
+
/**
|
|
374
|
+
* Prefer over `removeEdges` directly — also cancels in-flight async attaches and stands down the
|
|
375
|
+
* screen-space edge fallback if active.
|
|
376
|
+
*/
|
|
377
|
+
clearEdges: (root: THREE.Object3D) => void;
|
|
378
|
+
/**
|
|
379
|
+
* Request a repaint from the on-demand render loop. Built-in setters and input invalidate
|
|
380
|
+
* automatically; call this after mutating the scene externally. No-op when `render.onDemand` is false.
|
|
381
|
+
*/
|
|
382
|
+
invalidate: () => void;
|
|
383
|
+
setAmbientOcclusion: (enabled: boolean) => void;
|
|
384
|
+
/**
|
|
385
|
+
* Retunes lighting/material (tone mapping, fill, IBL, AO) only — never edges/grid. Overwrites
|
|
386
|
+
* any granular lighting dials set earlier with the preset's values.
|
|
387
|
+
*/
|
|
388
|
+
setLook: (look: 'studio' | 'technical' | 'showcase') => void;
|
|
389
|
+
/**
|
|
390
|
+
* Raising `hemisphereIntensity` is the most effective way to lift shadowed surfaces a dark HDR
|
|
391
|
+
* leaves black. Lazily creates the hemisphere light if the viewer was built without one; `0` turns
|
|
392
|
+
* it back off.
|
|
393
|
+
*/
|
|
394
|
+
setFillLights: (opts: {
|
|
395
|
+
hemisphereIntensity?: number;
|
|
396
|
+
hemisphereSkyColor?: THREE.Color | number;
|
|
397
|
+
hemisphereGroundColor?: THREE.Color | number;
|
|
398
|
+
ambientIntensity?: number;
|
|
399
|
+
}) => void;
|
|
400
|
+
/**
|
|
401
|
+
* Normalizes IBL brightness across HDRs of differing exposure. Applies even before the HDR
|
|
402
|
+
* finishes decoding.
|
|
403
|
+
*/
|
|
404
|
+
setEnvironmentIntensity: (intensity: number) => void;
|
|
405
|
+
setToneMappingExposure: (exposure: number) => void;
|
|
406
|
+
/** GTAO strength (0-1). No-op when ambient occlusion isn't active. */
|
|
407
|
+
setAoIntensity: (intensity: number) => void;
|
|
408
|
+
/** Feed into the batch parser's `material` option so freshly-loaded meshes match the active look. */
|
|
409
|
+
getMaterialAppearance: () => MaterialAppearanceOptions;
|
|
410
|
+
/** Call after loading or replacing geometry. No-op when sunlight/shadows are off. */
|
|
411
|
+
updateShadowBounds: () => void;
|
|
412
|
+
/** Call after loading or replacing geometry. No-op when the grid is off or empty. */
|
|
413
|
+
updateGridScale: () => void;
|
|
414
|
+
dispose: () => void;
|
|
415
|
+
fitToView: () => void;
|
|
416
|
+
clearSelection: () => void;
|
|
417
|
+
/** Tagged `userData.source = 'user'` so it survives `updateScene` solves and counts for fit-to-view. */
|
|
418
|
+
addUserGeometry: (object: THREE.Object3D) => void;
|
|
419
|
+
removeUserGeometry: (object: THREE.Object3D) => void;
|
|
420
|
+
/** Removes and disposes everything added via `addUserGeometry`. */
|
|
421
|
+
clearUserGeometry: () => void;
|
|
423
422
|
}
|
|
424
|
-
|
|
423
|
+
//#endregion
|
|
424
|
+
//#region src/render/scene-setup/init-three.d.ts
|
|
425
425
|
declare const initThree: (canvas: HTMLCanvasElement, options?: ThreeInitializerOptions) => ThreeViewer;
|
|
426
|
-
|
|
426
|
+
//#endregion
|
|
427
|
+
//#region src/render/three-helpers.d.ts
|
|
427
428
|
/** Replaces scene content with `meshes`, rescales the camera frustum to fit, and (first call only) positions the camera/controls. */
|
|
428
429
|
declare function updateScene(scene: THREE.Scene, meshes: THREE.Object3D[], camera: THREE.PerspectiveCamera, controls: OrbitControls, initialPositionSet: boolean): void;
|
|
429
|
-
|
|
430
|
-
export { type CameraConfig, type CameraController, type CameraProjection, type ControlsConfig, DEFAULT_LOOK, type EdgesConfig, type EnvironmentConfig, type ErrorCode, ErrorCodes, type EventConfig, type FloorConfig, type GizmoConfig, type Grid, type GridConfig, LOOK_PRESETS, type LightingConfig, type Logger, Look, LookPreset, MaterialAppearanceOptions, type MeasureConfig, type MeasureTool, type RenderConfig, type ThreeInitializerOptions, type ThreeViewer, type ViewGizmo, type ViewPreset, VisualizationError, enableDebugLogging, getLogger, initThree, materialAppearanceForLook, setLogger, updateScene };
|
|
430
|
+
//#endregion
|
|
431
|
+
export { type CameraConfig, type CameraController, type CameraProjection, type ControlsConfig, DEFAULT_LOOK, type EdgesConfig, type EnvironmentConfig, type ErrorCode, ErrorCodes, type EventConfig, type FloorConfig, type GizmoConfig, type Grid, type GridConfig, LOOKS, LOOK_PRESETS, type LightingConfig, type Logger, type Look, type LookPreset, type MaterialAppearanceOptions, type MeasureConfig, type MeasureTool, type RenderConfig, type ThreeInitializerOptions, type ThreeViewer, type ViewGizmo, type ViewPreset, VisualizationError, enableDebugLogging, getLogger, initThree, materialAppearanceForLook, setLogger, updateScene };
|
|
432
|
+
//# sourceMappingURL=render.d.ts.map
|