@selvajs/visualization 1.6.0-beta.8 → 1.6.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.
Files changed (44) hide show
  1. package/dist/gpu-dispose-D66GqIWS.cjs +514 -0
  2. package/dist/gpu-dispose-D66GqIWS.cjs.map +1 -0
  3. package/dist/gpu-dispose-Di_nxeXF.js +382 -0
  4. package/dist/gpu-dispose-Di_nxeXF.js.map +1 -0
  5. package/dist/gpu-ownership-ADRZBxxs.cjs +102 -0
  6. package/dist/gpu-ownership-ADRZBxxs.cjs.map +1 -0
  7. package/dist/gpu-ownership-Bs9l7hrU.js +40 -0
  8. package/dist/gpu-ownership-Bs9l7hrU.js.map +1 -0
  9. package/dist/index.js +1 -1
  10. package/dist/merged-draw-CO4rr2Co.js +129 -0
  11. package/dist/merged-draw-CO4rr2Co.js.map +1 -0
  12. package/dist/merged-draw-ma_2r4N8.cjs +171 -0
  13. package/dist/merged-draw-ma_2r4N8.cjs.map +1 -0
  14. package/dist/parse.cjs +3036 -11
  15. package/dist/parse.cjs.map +1 -1
  16. package/dist/parse.d.cts +22 -3
  17. package/dist/parse.d.ts +22 -3
  18. package/dist/parse.js +3027 -11
  19. package/dist/parse.js.map +1 -1
  20. package/dist/render.cjs +4333 -6
  21. package/dist/render.cjs.map +1 -1
  22. package/dist/render.d.cts +43 -9
  23. package/dist/render.d.ts +43 -9
  24. package/dist/render.js +4312 -6
  25. package/dist/render.js.map +1 -1
  26. package/dist/scene.cjs +343 -1
  27. package/dist/scene.cjs.map +1 -1
  28. package/dist/scene.js +336 -1
  29. package/dist/scene.js.map +1 -1
  30. package/dist/{types-P5PyfYYE.d.ts → types-DW_qU4-Y.d.cts} +22 -3
  31. package/dist/{types-P5PyfYYE.d.cts → types-DW_qU4-Y.d.ts} +22 -3
  32. package/package.json +14 -8
  33. package/dist/gpu-dispose-Cestx__L.cjs +0 -2
  34. package/dist/gpu-dispose-Cestx__L.cjs.map +0 -1
  35. package/dist/gpu-dispose-gTGxGTL4.js +0 -2
  36. package/dist/gpu-dispose-gTGxGTL4.js.map +0 -1
  37. package/dist/gpu-ownership-DcHWbATk.js +0 -2
  38. package/dist/gpu-ownership-DcHWbATk.js.map +0 -1
  39. package/dist/gpu-ownership-ilj3JEdn.cjs +0 -2
  40. package/dist/gpu-ownership-ilj3JEdn.cjs.map +0 -1
  41. package/dist/merged-draw-DXJK-rdo.js +0 -2
  42. package/dist/merged-draw-DXJK-rdo.js.map +0 -1
  43. package/dist/merged-draw-oKAKlXCQ.cjs +0 -2
  44. package/dist/merged-draw-oKAKlXCQ.cjs.map +0 -1
package/dist/render.d.cts CHANGED
@@ -1,8 +1,9 @@
1
- import { a as MaterialAppearanceOptions, i as LookPreset, n as Look, r as LookMaterialOverride, t as LOOKS } from "./types-P5PyfYYE.cjs";
1
+ import { a as LookPreset, i as LookMaterialOverride, n as LOOKS, o as MaterialAppearanceOptions, r as Look, t as BloomOptions } from "./types-DW_qU4-Y.cjs";
2
2
  import * as THREE from "three";
3
3
  import { OrbitControls } from "three/addons/controls/OrbitControls.js";
4
4
  import "three/addons/lines/LineSegments2.js";
5
5
  import { CSS2DObject } from "three/addons/renderers/CSS2DRenderer.js";
6
+ import "three/addons/postprocessing/Pass.js";
6
7
  /**
7
8
  * Errors for the visualization package. Replaces `@selvajs/compute`'s `RhinoComputeError`, which
8
9
  * mis-named failures on paths (e.g. the plugin WebSocket) that never touch Rhino.Compute. `code`
@@ -121,8 +122,26 @@ type RenderConfig = {
121
122
  toneMapping?: THREE.ToneMapping;
122
123
  toneMappingExposure?: number;
123
124
  preserveDrawingBuffer?: boolean;
125
+ /**
126
+ * Cuts what the look's `lowPower` fields name; only `night` has any. Default: on for a touch
127
+ * device with a phone-sized screen. Set it to force the tier on or off.
128
+ */
129
+ lowPower?: boolean;
130
+ /**
131
+ * Frames averaged while the camera rests, for soft shadows and clean edges. Needs the composer,
132
+ * so looks without AO or bloom skip it. Costs nothing while orbiting. Default 32, or 0 on a
133
+ * `lowPower` device; 0 turns it off.
134
+ */
135
+ idleRefineFrames?: number;
136
+ /**
137
+ * Orbit frames slower than this fade ambient occlusion out while the camera moves, its largest
138
+ * cost. Needs `idleRefineFrames` to fade back in. Default 22. 0 always does; `Infinity` never does.
139
+ */
140
+ lightOrbitFrameMs?: number;
124
141
  /** Default false — switches rendering from `renderer.render` to an EffectComposer, which costs more. */
125
142
  ambientOcclusion?: boolean;
143
+ /** Glow around emissive parts. The look decides; `night` sets it. */
144
+ bloom?: BloomOptions;
126
145
  /** AO strength 0–1 when {@link RenderConfig.ambientOcclusion} is on. Default 1. */
127
146
  aoIntensity?: number;
128
147
  /**
@@ -357,12 +376,13 @@ interface LabelLayer {
357
376
  dispose(): void;
358
377
  }
359
378
  /**
360
- * Two-click distance measurement. Click a point, click a second, read the distance off a label on
361
- * the connecting line; a third click starts fresh.
379
+ * Point-to-point distance measurement. Click a start point; a rubber band and live readout follow
380
+ * the cursor until the second click commits it. Committed measurements stay until Escape (which
381
+ * first drops an unfinished start point) or until the tool is disabled.
362
382
  *
363
- * Picking snaps to the nearest vertex within {@link MeasureOptions.snapPixels} so measurements
364
- * land exactly on vertices rather than wherever the ray happened to hit — a cheap local snap
365
- * against the struck primitive's own vertices, no spatial index.
383
+ * Picking snaps to the nearest vertex of the struck triangle, segment or point within
384
+ * {@link MeasureOptions.snapPixels}; the hover marker turns solid when it has snapped. Meshes are
385
+ * picked through a BVH (`scene-pick.ts`), so hovering stays cheap on large models.
366
386
  *
367
387
  * Dormant until {@link MeasureTool.setEnabled}(true). While enabled it intercepts clicks (caller
368
388
  * forwards them and swallows the event when {@link MeasureTool.handleClick} returns true) so
@@ -373,8 +393,10 @@ interface MeasureTool {
373
393
  isEnabled(): boolean;
374
394
  /** Returns true if the tool consumed the click (caller should not also select). */
375
395
  handleClick(event: MouseEvent): boolean;
376
- /** Preview the next snap point via a ghost marker. No-op when disabled; never consumes the event. */
396
+ /** Preview the next snap point and the rubber band. No-op when disabled; never consumes the event. */
377
397
  handleMove(event: MouseEvent): void;
398
+ /** Drops the unfinished start point, or every measurement when there is none. Bound to Escape. */
399
+ cancel(): void;
378
400
  clear(): void;
379
401
  dispose(): void;
380
402
  }
@@ -465,6 +487,13 @@ interface ViewGizmo {
465
487
  isVisible(): boolean;
466
488
  dispose(): void;
467
489
  }
490
+ type SetLookOptions = {
491
+ /**
492
+ * Skips the sync, which walks every glowing part. The caller runs `syncEmissiveLights()` itself
493
+ * once visibility settles.
494
+ */
495
+ deferEmissiveLights?: boolean;
496
+ };
468
497
  /** One thing to select: a whole object, or one member of a merged mesh. */
469
498
  interface SelectionTarget {
470
499
  object: THREE.Object3D;
@@ -516,7 +545,12 @@ interface ThreeViewer {
516
545
  * Retunes lighting/material (tone mapping, fill, IBL, AO) only — never edges/grid. Overwrites
517
546
  * any granular lighting dials set earlier with the preset's values.
518
547
  */
519
- setLook: (look: Look) => void;
548
+ setLook: (look: Look, options?: SetLookOptions) => void;
549
+ /**
550
+ * Call after showing or hiding objects, solve output included: a look that lights the scene from
551
+ * glowing parts reads what is drawn when it runs, so a hidden lamp would keep shining.
552
+ */
553
+ syncEmissiveLights: () => void;
520
554
  /**
521
555
  * Raising `hemisphereIntensity` is the most effective way to lift shadowed surfaces a dark HDR
522
556
  * leaves black. Lazily creates the hemisphere light if the viewer was built without one; `0` turns
@@ -591,5 +625,5 @@ export declare function isHostOwned(object: THREE.Object3D): boolean;
591
625
  export declare function isOwnedBy(object: THREE.Object3D, id?: string): boolean;
592
626
  /** Replaces scene content with `meshes`, rescales the camera frustum to fit, and (first call only) positions the camera/controls. */
593
627
  export declare function updateScene(scene: THREE.Scene, meshes: THREE.Object3D[], camera: THREE.PerspectiveCamera, controls: OrbitControls, initialPositionSet: boolean): void;
594
- export { type CameraConfig, type CameraController, type CameraProjection, type ControlsConfig, type EdgesConfig, type EnvironmentConfig, type ErrorCode, type EventConfig, type FloorConfig, type GizmoConfig, type Grid, type GridConfig, LOOKS, type LabelHandle, type LabelLayer, type LightingConfig, type Logger, type Look, type LookMaterialOverride, type LookPreset, type MaterialAppearanceOptions, type MeasureConfig, type MeasureTool, type PointerTool, type RenderConfig, type ThreeInitializerOptions, type ThreeViewer, type ToolRegistration, type ToolRegistry, type ViewGizmo, type ViewPreset };
628
+ export { type CameraConfig, type CameraController, type CameraProjection, type ControlsConfig, type EdgesConfig, type EnvironmentConfig, type ErrorCode, type EventConfig, type FloorConfig, type GizmoConfig, type Grid, type GridConfig, LOOKS, type LabelHandle, type LabelLayer, type LightingConfig, type Logger, type Look, type LookMaterialOverride, type LookPreset, type MaterialAppearanceOptions, type MeasureConfig, type MeasureTool, type PointerTool, type RenderConfig, type SetLookOptions, type ThreeInitializerOptions, type ThreeViewer, type ToolRegistration, type ToolRegistry, type ViewGizmo, type ViewPreset };
595
629
  //# sourceMappingURL=render.d.cts.map
package/dist/render.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { a as MaterialAppearanceOptions, i as LookPreset, n as Look, r as LookMaterialOverride, t as LOOKS } from "./types-P5PyfYYE.js";
1
+ import { a as LookPreset, i as LookMaterialOverride, n as LOOKS, o as MaterialAppearanceOptions, r as Look, t as BloomOptions } from "./types-DW_qU4-Y.js";
2
2
  import * as THREE from "three";
3
3
  import { LineSegments2 } from "three/addons/lines/LineSegments2.js";
4
4
  import { CSS2DObject } from "three/addons/renderers/CSS2DRenderer.js";
5
+ import { Pass } from "three/addons/postprocessing/Pass.js";
5
6
  import { OrbitControls } from "three/addons/controls/OrbitControls.js";
6
7
  /**
7
8
  * Errors for the visualization package. Replaces `@selvajs/compute`'s `RhinoComputeError`, which
@@ -121,8 +122,26 @@ type RenderConfig = {
121
122
  toneMapping?: THREE.ToneMapping;
122
123
  toneMappingExposure?: number;
123
124
  preserveDrawingBuffer?: boolean;
125
+ /**
126
+ * Cuts what the look's `lowPower` fields name; only `night` has any. Default: on for a touch
127
+ * device with a phone-sized screen. Set it to force the tier on or off.
128
+ */
129
+ lowPower?: boolean;
130
+ /**
131
+ * Frames averaged while the camera rests, for soft shadows and clean edges. Needs the composer,
132
+ * so looks without AO or bloom skip it. Costs nothing while orbiting. Default 32, or 0 on a
133
+ * `lowPower` device; 0 turns it off.
134
+ */
135
+ idleRefineFrames?: number;
136
+ /**
137
+ * Orbit frames slower than this fade ambient occlusion out while the camera moves, its largest
138
+ * cost. Needs `idleRefineFrames` to fade back in. Default 22. 0 always does; `Infinity` never does.
139
+ */
140
+ lightOrbitFrameMs?: number;
124
141
  /** Default false — switches rendering from `renderer.render` to an EffectComposer, which costs more. */
125
142
  ambientOcclusion?: boolean;
143
+ /** Glow around emissive parts. The look decides; `night` sets it. */
144
+ bloom?: BloomOptions;
126
145
  /** AO strength 0–1 when {@link RenderConfig.ambientOcclusion} is on. Default 1. */
127
146
  aoIntensity?: number;
128
147
  /**
@@ -357,12 +376,13 @@ interface LabelLayer {
357
376
  dispose(): void;
358
377
  }
359
378
  /**
360
- * Two-click distance measurement. Click a point, click a second, read the distance off a label on
361
- * the connecting line; a third click starts fresh.
379
+ * Point-to-point distance measurement. Click a start point; a rubber band and live readout follow
380
+ * the cursor until the second click commits it. Committed measurements stay until Escape (which
381
+ * first drops an unfinished start point) or until the tool is disabled.
362
382
  *
363
- * Picking snaps to the nearest vertex within {@link MeasureOptions.snapPixels} so measurements
364
- * land exactly on vertices rather than wherever the ray happened to hit — a cheap local snap
365
- * against the struck primitive's own vertices, no spatial index.
383
+ * Picking snaps to the nearest vertex of the struck triangle, segment or point within
384
+ * {@link MeasureOptions.snapPixels}; the hover marker turns solid when it has snapped. Meshes are
385
+ * picked through a BVH (`scene-pick.ts`), so hovering stays cheap on large models.
366
386
  *
367
387
  * Dormant until {@link MeasureTool.setEnabled}(true). While enabled it intercepts clicks (caller
368
388
  * forwards them and swallows the event when {@link MeasureTool.handleClick} returns true) so
@@ -373,8 +393,10 @@ interface MeasureTool {
373
393
  isEnabled(): boolean;
374
394
  /** Returns true if the tool consumed the click (caller should not also select). */
375
395
  handleClick(event: MouseEvent): boolean;
376
- /** Preview the next snap point via a ghost marker. No-op when disabled; never consumes the event. */
396
+ /** Preview the next snap point and the rubber band. No-op when disabled; never consumes the event. */
377
397
  handleMove(event: MouseEvent): void;
398
+ /** Drops the unfinished start point, or every measurement when there is none. Bound to Escape. */
399
+ cancel(): void;
378
400
  clear(): void;
379
401
  dispose(): void;
380
402
  }
@@ -465,6 +487,13 @@ interface ViewGizmo {
465
487
  isVisible(): boolean;
466
488
  dispose(): void;
467
489
  }
490
+ type SetLookOptions = {
491
+ /**
492
+ * Skips the sync, which walks every glowing part. The caller runs `syncEmissiveLights()` itself
493
+ * once visibility settles.
494
+ */
495
+ deferEmissiveLights?: boolean;
496
+ };
468
497
  /** One thing to select: a whole object, or one member of a merged mesh. */
469
498
  interface SelectionTarget {
470
499
  object: THREE.Object3D;
@@ -516,7 +545,12 @@ interface ThreeViewer {
516
545
  * Retunes lighting/material (tone mapping, fill, IBL, AO) only — never edges/grid. Overwrites
517
546
  * any granular lighting dials set earlier with the preset's values.
518
547
  */
519
- setLook: (look: Look) => void;
548
+ setLook: (look: Look, options?: SetLookOptions) => void;
549
+ /**
550
+ * Call after showing or hiding objects, solve output included: a look that lights the scene from
551
+ * glowing parts reads what is drawn when it runs, so a hidden lamp would keep shining.
552
+ */
553
+ syncEmissiveLights: () => void;
520
554
  /**
521
555
  * Raising `hemisphereIntensity` is the most effective way to lift shadowed surfaces a dark HDR
522
556
  * leaves black. Lazily creates the hemisphere light if the viewer was built without one; `0` turns
@@ -591,5 +625,5 @@ export declare function isHostOwned(object: THREE.Object3D): boolean;
591
625
  export declare function isOwnedBy(object: THREE.Object3D, id?: string): boolean;
592
626
  /** Replaces scene content with `meshes`, rescales the camera frustum to fit, and (first call only) positions the camera/controls. */
593
627
  export declare function updateScene(scene: THREE.Scene, meshes: THREE.Object3D[], camera: THREE.PerspectiveCamera, controls: OrbitControls, initialPositionSet: boolean): void;
594
- export { type CameraConfig, type CameraController, type CameraProjection, type ControlsConfig, type EdgesConfig, type EnvironmentConfig, type ErrorCode, type EventConfig, type FloorConfig, type GizmoConfig, type Grid, type GridConfig, LOOKS, type LabelHandle, type LabelLayer, type LightingConfig, type Logger, type Look, type LookMaterialOverride, type LookPreset, type MaterialAppearanceOptions, type MeasureConfig, type MeasureTool, type PointerTool, type RenderConfig, type ThreeInitializerOptions, type ThreeViewer, type ToolRegistration, type ToolRegistry, type ViewGizmo, type ViewPreset };
628
+ export { type CameraConfig, type CameraController, type CameraProjection, type ControlsConfig, type EdgesConfig, type EnvironmentConfig, type ErrorCode, type EventConfig, type FloorConfig, type GizmoConfig, type Grid, type GridConfig, LOOKS, type LabelHandle, type LabelLayer, type LightingConfig, type Logger, type Look, type LookMaterialOverride, type LookPreset, type MaterialAppearanceOptions, type MeasureConfig, type MeasureTool, type PointerTool, type RenderConfig, type SetLookOptions, type ThreeInitializerOptions, type ThreeViewer, type ToolRegistration, type ToolRegistry, type ViewGizmo, type ViewPreset };
595
629
  //# sourceMappingURL=render.d.ts.map