@selvajs/visualization 1.8.0-beta.8 → 1.8.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 (34) hide show
  1. package/dist/{gpu-dispose-0c_-KS12.cjs → gpu-dispose--5MA0CcI.cjs} +10 -9
  2. package/dist/{gpu-dispose-0c_-KS12.cjs.map → gpu-dispose--5MA0CcI.cjs.map} +1 -1
  3. package/dist/{gpu-dispose-k_Gq-ygL.js → gpu-dispose-m5ywfM1f.js} +8 -8
  4. package/dist/{gpu-dispose-k_Gq-ygL.js.map → gpu-dispose-m5ywfM1f.js.map} +1 -1
  5. package/dist/{gpu-ownership-Bs9l7hrU.js → gpu-ownership-5o7F_lc2.js} +1 -1
  6. package/dist/{gpu-ownership-Bs9l7hrU.js.map → gpu-ownership-5o7F_lc2.js.map} +1 -1
  7. package/dist/{gpu-ownership-ADRZBxxs.cjs → gpu-ownership-BtECafMd.cjs} +1 -28
  8. package/dist/{gpu-ownership-ADRZBxxs.cjs.map → gpu-ownership-BtECafMd.cjs.map} +1 -1
  9. package/dist/{merged-draw-CO4rr2Co.js → merged-draw-BE0616Nv.js} +2 -2
  10. package/dist/{merged-draw-CO4rr2Co.js.map → merged-draw-BE0616Nv.js.map} +1 -1
  11. package/dist/{merged-draw-ma_2r4N8.cjs → merged-draw-C9jFRnos.cjs} +4 -3
  12. package/dist/merged-draw-C9jFRnos.cjs.map +1 -0
  13. package/dist/parse.cjs +23 -25
  14. package/dist/parse.cjs.map +1 -1
  15. package/dist/parse.d.cts +9 -3
  16. package/dist/parse.d.ts +9 -3
  17. package/dist/parse.js +21 -24
  18. package/dist/parse.js.map +1 -1
  19. package/dist/render.cjs +35 -34
  20. package/dist/render.cjs.map +1 -1
  21. package/dist/render.d.cts +10 -6
  22. package/dist/render.d.ts +14 -7
  23. package/dist/render.js +33 -33
  24. package/dist/render.js.map +1 -1
  25. package/dist/rolldown-runtime-CmQyd0Gu.cjs +27 -0
  26. package/dist/scene.cjs +3 -3
  27. package/dist/scene.cjs.map +1 -1
  28. package/dist/scene.d.cts +10 -2
  29. package/dist/scene.d.ts +10 -2
  30. package/dist/scene.js +1 -1
  31. package/dist/{types-i9wRcHK7.d.ts → types-8Qx4xyyR.d.ts} +1 -2
  32. package/dist/{types-i9wRcHK7.d.cts → types-D1PpOP_H.d.cts} +1 -2
  33. package/package.json +8 -8
  34. package/dist/merged-draw-ma_2r4N8.cjs.map +0 -1
package/dist/render.d.cts CHANGED
@@ -1,10 +1,15 @@
1
- import { a as LookPreset, i as LookMaterialOverride, n as LOOKS, o as MaterialAppearanceOptions, r as Look, t as BloomOptions } from "./types-i9wRcHK7.cjs";
1
+ /**
2
+ * `render/` — the CAD viewer toolkit. See README for the layer map and the render↔parse seam.
3
+ *
4
+ * `initThree` owns the toolkit; factories aren't exported on purpose — reach live instances through
5
+ * the viewer (`viewer.grid`, `viewer.measureTool`, …), configured via {@link ThreeInitializerOptions}.
6
+ *
7
+ * @module render
8
+ */
2
9
  import * as THREE from "three";
10
+ import { a as LookPreset, i as LookMaterialOverride, n as LOOKS, o as MaterialAppearanceOptions, r as Look, t as BloomOptions } from "./types-D1PpOP_H.cjs";
3
11
  import { OrbitControls } from "three/addons/controls/OrbitControls.js";
4
- import "three/addons/lines/LineSegments2.js";
5
12
  import { CSS2DObject } from "three/addons/renderers/CSS2DRenderer.js";
6
- import "three/addons/postprocessing/Pass.js";
7
- import "three-mesh-bvh";
8
13
  /**
9
14
  * Errors for the visualization package. Replaces `@selvajs/compute`'s `RhinoComputeError`, which
10
15
  * mis-named failures on paths (e.g. the plugin WebSocket) that never touch Rhino.Compute. `code`
@@ -651,5 +656,4 @@ export declare function isHostOwned(object: THREE.Object3D): boolean;
651
656
  export declare function isOwnedBy(object: THREE.Object3D, id?: string): boolean;
652
657
  /** Replaces scene content with `meshes`, rescales the camera frustum to fit, and (first call only) positions the camera/controls. */
653
658
  export declare function updateScene(scene: THREE.Scene, meshes: THREE.Object3D[], camera: THREE.PerspectiveCamera, controls: OrbitControls, initialPositionSet: boolean): void;
654
- export { type CameraConfig, type CameraController, type CameraProjection, type CameraView, 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 };
655
- //# sourceMappingURL=render.d.cts.map
659
+ export { type CameraConfig, type CameraController, type CameraProjection, type CameraView, 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 };
package/dist/render.d.ts CHANGED
@@ -1,10 +1,18 @@
1
- import { a as LookPreset, i as LookMaterialOverride, n as LOOKS, o as MaterialAppearanceOptions, r as Look, t as BloomOptions } from "./types-i9wRcHK7.js";
1
+ /**
2
+ * `render/` — the CAD viewer toolkit. See README for the layer map and the render↔parse seam.
3
+ *
4
+ * `initThree` owns the toolkit; factories aren't exported on purpose — reach live instances through
5
+ * the viewer (`viewer.grid`, `viewer.measureTool`, …), configured via {@link ThreeInitializerOptions}.
6
+ *
7
+ * @module render
8
+ */
2
9
  import * as THREE from "three";
3
- import { LineSegments2 } from "three/addons/lines/LineSegments2.js";
4
- import { CSS2DObject } from "three/addons/renderers/CSS2DRenderer.js";
5
- import { MeshBVH } from "three-mesh-bvh";
6
- import { Pass } from "three/addons/postprocessing/Pass.js";
10
+ import { a as LookPreset, i as LookMaterialOverride, n as LOOKS, o as MaterialAppearanceOptions, r as Look, t as BloomOptions } from "./types-8Qx4xyyR.js";
7
11
  import { OrbitControls } from "three/addons/controls/OrbitControls.js";
12
+ import "three/addons/lines/LineSegments2.js";
13
+ import { CSS2DObject } from "three/addons/renderers/CSS2DRenderer.js";
14
+ import "three/addons/postprocessing/Pass.js";
15
+ import "three-mesh-bvh";
8
16
  /**
9
17
  * Errors for the visualization package. Replaces `@selvajs/compute`'s `RhinoComputeError`, which
10
18
  * mis-named failures on paths (e.g. the plugin WebSocket) that never touch Rhino.Compute. `code`
@@ -651,5 +659,4 @@ export declare function isHostOwned(object: THREE.Object3D): boolean;
651
659
  export declare function isOwnedBy(object: THREE.Object3D, id?: string): boolean;
652
660
  /** Replaces scene content with `meshes`, rescales the camera frustum to fit, and (first call only) positions the camera/controls. */
653
661
  export declare function updateScene(scene: THREE.Scene, meshes: THREE.Object3D[], camera: THREE.PerspectiveCamera, controls: OrbitControls, initialPositionSet: boolean): void;
654
- export { type CameraConfig, type CameraController, type CameraProjection, type CameraView, 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 };
655
- //# sourceMappingURL=render.d.ts.map
662
+ export { type CameraConfig, type CameraController, type CameraProjection, type CameraView, 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 };
package/dist/render.js CHANGED
@@ -1,13 +1,13 @@
1
- import { S as VisualizationError, _ as materialAppearanceForLook, b as setLogger, c as computeCombinedBoundingBox, d as EMISSIVE_LIGHT, f as LOOK_PRESETS, g as lookPreset, h as lookEnvMapIntensity, m as OWN_ENV_MAP_INTENSITY, o as publishMaxAnisotropy, r as hideGlass, t as disposeObjectTree, u as DEFAULT_LOOK, v as enableDebugLogging, x as ErrorCodes, y as getLogger } from "./gpu-dispose-k_Gq-ygL.js";
2
- import { n as cachedSourceOf } from "./gpu-ownership-Bs9l7hrU.js";
3
- import { a as onMemberDrawChange, i as getHiddenMembers, n as cloneForTint, r as getBaseMaterial, s as setMemberHighlight, t as clearMemberHighlight } from "./merged-draw-CO4rr2Co.js";
4
1
  import * as THREE from "three";
5
- import { Line2 } from "three/addons/lines/Line2.js";
6
- import { LineGeometry } from "three/addons/lines/LineGeometry.js";
7
- import { LineMaterial } from "three/addons/lines/LineMaterial.js";
2
+ import { S as VisualizationError, _ as materialAppearanceForLook, b as setLogger, c as computeCombinedBoundingBox, d as EMISSIVE_LIGHT, f as LOOK_PRESETS, g as lookPreset, h as lookEnvMapIntensity, m as OWN_ENV_MAP_INTENSITY, o as publishMaxAnisotropy, r as hideGlass, t as disposeObjectTree, u as DEFAULT_LOOK, v as enableDebugLogging, x as ErrorCodes, y as getLogger } from "./gpu-dispose-m5ywfM1f.js";
3
+ import { n as cachedSourceOf } from "./gpu-ownership-5o7F_lc2.js";
8
4
  import { LineSegments2 } from "three/addons/lines/LineSegments2.js";
9
5
  import { LineSegmentsGeometry } from "three/addons/lines/LineSegmentsGeometry.js";
6
+ import { a as onMemberDrawChange, i as getHiddenMembers, n as cloneForTint, r as getBaseMaterial, s as setMemberHighlight, t as clearMemberHighlight } from "./merged-draw-BE0616Nv.js";
7
+ import { LineMaterial } from "three/addons/lines/LineMaterial.js";
10
8
  import { CSS2DObject, CSS2DRenderer } from "three/addons/renderers/CSS2DRenderer.js";
9
+ import { Line2 } from "three/addons/lines/Line2.js";
10
+ import { LineGeometry } from "three/addons/lines/LineGeometry.js";
11
11
  import { MeshBVH } from "three-mesh-bvh";
12
12
  import { ViewHelper } from "three/addons/helpers/ViewHelper.js";
13
13
  import { EffectComposer } from "three/addons/postprocessing/EffectComposer.js";
@@ -368,15 +368,15 @@ function applyDefaults(options) {
368
368
  sunlightPosition: options.lighting?.sunlightPosition || sunOffset(options.environment?.sceneUp ?? defaultUp, defaults.lightDistance, defaults.lightHeight),
369
369
  ambientLightColor: options.lighting?.ambientLightColor || new THREE.Color(4210752),
370
370
  ambientLightIntensity: options.lighting?.ambientLightIntensity ?? preset.ambientIntensity,
371
- sunlightColor: options.lighting?.sunlightColor || 16777215,
371
+ sunlightColor: options.lighting?.sunlightColor || 0xffffff,
372
372
  enableHemisphereLight: options.lighting?.enableHemisphereLight ?? preset.hemisphereIntensity > 0,
373
- hemisphereSkyColor: options.lighting?.hemisphereSkyColor ?? 14673663,
373
+ hemisphereSkyColor: options.lighting?.hemisphereSkyColor ?? 0xdfe6ff,
374
374
  hemisphereGroundColor: options.lighting?.hemisphereGroundColor ?? 7036754,
375
375
  hemisphereIntensity: options.lighting?.hemisphereIntensity ?? preset.hemisphereIntensity
376
376
  },
377
377
  environment: {
378
378
  hdrPath: options.environment?.hdrPath === false ? false : options.environment?.hdrPath || "/baseHDR.hdr",
379
- backgroundColor: options.environment?.backgroundColor || new THREE.Color(15790320),
379
+ backgroundColor: options.environment?.backgroundColor || new THREE.Color(0xf0f0f0),
380
380
  enableEnvironmentLighting: options.environment?.enableEnvironmentLighting ?? true,
381
381
  sceneUp: options.environment?.sceneUp || defaultUp,
382
382
  showEnvironment: options.environment?.showEnvironment ?? false,
@@ -415,7 +415,7 @@ function applyDefaults(options) {
415
415
  enableZoom: options.controls?.enableZoom ?? true,
416
416
  enablePan: options.controls?.enablePan ?? true,
417
417
  minDistance: options.controls?.minDistance || defaults.minDistance,
418
- maxDistance: options.controls?.maxDistance || Infinity
418
+ maxDistance: options.controls?.maxDistance || 1e400
419
419
  },
420
420
  grid: {
421
421
  enabled: options.grid?.enabled ?? false,
@@ -596,7 +596,7 @@ function setupLighting(scene, config) {
596
596
  hemisphere,
597
597
  sun: null
598
598
  };
599
- const sunlight = new THREE.DirectionalLight(config.lighting.sunlightColor ?? 16777215, config.lighting.sunlightIntensity);
599
+ const sunlight = new THREE.DirectionalLight(config.lighting.sunlightColor ?? 0xffffff, config.lighting.sunlightIntensity);
600
600
  const pos = config.lighting.sunlightPosition;
601
601
  if (pos) sunlight.position.set(pos.x, pos.y, pos.z);
602
602
  if (!config.render.enableShadows) {
@@ -1010,7 +1010,7 @@ const SPACING_PERCENTILE = .15;
1010
1010
  const SPACING_SAMPLE_LIMIT = 4096;
1011
1011
  function edgeSpacingOf(segments) {
1012
1012
  const segmentCount = Math.floor(segments.length / 6);
1013
- if (segmentCount === 0) return Infinity;
1013
+ if (segmentCount === 0) return 1e400;
1014
1014
  const stride = Math.max(1, Math.ceil(segmentCount / SPACING_SAMPLE_LIMIT));
1015
1015
  const lengths = [];
1016
1016
  for (let s = 0; s < segmentCount; s += stride) {
@@ -1018,7 +1018,7 @@ function edgeSpacingOf(segments) {
1018
1018
  const length = Math.hypot(segments[i + 3] - segments[i], segments[i + 4] - segments[i + 1], segments[i + 5] - segments[i + 2]);
1019
1019
  if (length > 0) lengths.push(length);
1020
1020
  }
1021
- if (lengths.length === 0) return Infinity;
1021
+ if (lengths.length === 0) return 1e400;
1022
1022
  lengths.sort((a, b) => a - b);
1023
1023
  return lengths[Math.min(lengths.length - 1, Math.floor(lengths.length * SPACING_PERCENTILE))];
1024
1024
  }
@@ -1286,7 +1286,7 @@ function fastPathData(geometry) {
1286
1286
  }
1287
1287
  function contentKey(data, thresholdAngle) {
1288
1288
  const SAMPLE_WORDS = 4096;
1289
- let hash = 2166136261;
1289
+ let hash = 0x811c9dc5;
1290
1290
  const mix = (word) => {
1291
1291
  hash ^= word;
1292
1292
  hash = Math.imul(hash, 16777619);
@@ -1607,22 +1607,22 @@ const _fadeCameraPos = new THREE.Vector3();
1607
1607
  function pixelsPerWorldUnit(overlay, camera, viewportHeightPx) {
1608
1608
  if (!overlay.geometry.boundingSphere) overlay.geometry.computeBoundingSphere();
1609
1609
  const sphere = overlay.geometry.boundingSphere;
1610
- if (!sphere) return Infinity;
1610
+ if (!sphere) return 1e400;
1611
1611
  if (camera.isPerspectiveCamera) {
1612
1612
  const perspective = camera;
1613
1613
  _fadeCenter.copy(sphere.center).applyMatrix4(overlay.matrixWorld);
1614
1614
  const distance = _fadeCameraPos.setFromMatrixPosition(camera.matrixWorld).distanceTo(_fadeCenter);
1615
- if (distance <= sphere.radius * overlay.matrixWorld.getMaxScaleOnAxis()) return Infinity;
1615
+ if (distance <= sphere.radius * overlay.matrixWorld.getMaxScaleOnAxis()) return 1e400;
1616
1616
  const tanHalfFov = Math.tan(THREE.MathUtils.degToRad(perspective.fov) * .5);
1617
1617
  const worldHeightAtCentre = 2 * distance * tanHalfFov;
1618
- return worldHeightAtCentre > 0 ? viewportHeightPx / worldHeightAtCentre : Infinity;
1618
+ return worldHeightAtCentre > 0 ? viewportHeightPx / worldHeightAtCentre : 1e400;
1619
1619
  }
1620
1620
  if (camera.isOrthographicCamera) {
1621
1621
  const ortho = camera;
1622
1622
  const worldHeight = (ortho.top - ortho.bottom) / ortho.zoom;
1623
- return worldHeight > 0 ? viewportHeightPx / worldHeight : Infinity;
1623
+ return worldHeight > 0 ? viewportHeightPx / worldHeight : 1e400;
1624
1624
  }
1625
- return Infinity;
1625
+ return 1e400;
1626
1626
  }
1627
1627
  function enableDistanceFade(overlay, edgeSpacing) {
1628
1628
  overlay.onBeforeRender = (renderer, _scene, camera) => {
@@ -2064,7 +2064,7 @@ function warmPickIndex(root) {
2064
2064
  }
2065
2065
  // src/render/measure.ts
2066
2066
  const DEFAULT_SNAP_PIXELS = 12;
2067
- const DEFAULT_COLOR = 16763904;
2067
+ const DEFAULT_COLOR = 0xffcc00;
2068
2068
  const LINE_PICK_FRACTION = .015;
2069
2069
  const RENDER_ORDER_LINE = 998;
2070
2070
  const RENDER_ORDER_MARKER = 999;
@@ -2556,7 +2556,7 @@ function createNearestDepthQuery() {
2556
2556
  const singleBox = /* @__PURE__ */ new Float32Array(6);
2557
2557
  let polygon = /* @__PURE__ */ new Float64Array(21);
2558
2558
  let clipped = /* @__PURE__ */ new Float64Array(21);
2559
- let nearest = Infinity;
2559
+ let nearest = 1e400;
2560
2560
  let sawContent = false;
2561
2561
  const chunksOf = (object, geometry) => {
2562
2562
  const position = geometry.getAttribute("position");
@@ -2577,7 +2577,7 @@ function createNearestDepthQuery() {
2577
2577
  const chunkDepth = (chunks, chunk, planes) => {
2578
2578
  const { position, index } = chunks;
2579
2579
  const indices = index?.array;
2580
- let best = Infinity;
2580
+ let best = 1e400;
2581
2581
  for (let t = chunks.ranges[chunk * 2]; t < chunks.ranges[chunk * 2 + 1]; t++) {
2582
2582
  for (let corner = 0; corner < 3; corner++) {
2583
2583
  const v = indices ? indices[t * 3 + corner] : t * 3 + corner;
@@ -2710,7 +2710,7 @@ function createNearestDepthQuery() {
2710
2710
  worldPlanes[17] = forward.y;
2711
2711
  worldPlanes[18] = forward.z;
2712
2712
  worldPlanes[19] = -forward.dot(camera.position);
2713
- nearest = Infinity;
2713
+ nearest = 1e400;
2714
2714
  sawContent = false;
2715
2715
  for (const child of scene.children) visit(child);
2716
2716
  return sawContent ? nearest : null;
@@ -2758,12 +2758,12 @@ function buildChunkBoxes(position, index, breaks) {
2758
2758
  const fast = plain && position.itemSize === 3 && !position.normalized;
2759
2759
  const indices = index?.array;
2760
2760
  for (let chunk = 0; chunk < chunkCount; chunk++) {
2761
- let minX = Infinity;
2762
- let minY = Infinity;
2763
- let minZ = Infinity;
2764
- let maxX = -Infinity;
2765
- let maxY = -Infinity;
2766
- let maxZ = -Infinity;
2761
+ let minX = 1e400;
2762
+ let minY = 1e400;
2763
+ let minZ = 1e400;
2764
+ let maxX = -1e400;
2765
+ let maxY = -1e400;
2766
+ let maxZ = -1e400;
2767
2767
  const end = ranges[chunk * 2 + 1] * 3;
2768
2768
  for (let corner = ranges[chunk * 2] * 3; corner < end; corner++) {
2769
2769
  const v = indices ? indices[corner] : corner;
@@ -3110,8 +3110,8 @@ function createEmissiveLights(scene) {
3110
3110
  const silenced = /* @__PURE__ */ new Set();
3111
3111
  const offset = new THREE.Vector3();
3112
3112
  const addLight = (shadowed) => {
3113
- const key = new THREE.PointLight(16777215, 1, 0, 2);
3114
- const bounce = new THREE.PointLight(16777215, 1, 0, 1);
3113
+ const key = new THREE.PointLight(0xffffff, 1, 0, 2);
3114
+ const bounce = new THREE.PointLight(0xffffff, 1, 0, 1);
3115
3115
  if (shadowed) {
3116
3116
  key.castShadow = true;
3117
3117
  key.shadow.mapSize.setScalar(SHADOW_MAP_SIZE);
@@ -3245,7 +3245,7 @@ function applyMaterialOverride(material, override) {
3245
3245
  return;
3246
3246
  }
3247
3247
  if (!target[BASELINE_KEY]) target[BASELINE_KEY] = {
3248
- color: target.color?.getHex() ?? 16777215,
3248
+ color: target.color?.getHex() ?? 0xffffff,
3249
3249
  metalness: target.metalness ?? 0,
3250
3250
  roughness: target.roughness ?? 1,
3251
3251
  emissiveIntensity: target.emissiveIntensity ?? 0,
@@ -3859,7 +3859,7 @@ function setupControls(camera, canvas, config) {
3859
3859
  controls.enableZoom = config.controls.enableZoom ?? true;
3860
3860
  controls.enablePan = config.controls.enablePan ?? true;
3861
3861
  controls.minDistance = config.controls.minDistance || .001;
3862
- controls.maxDistance = config.controls.maxDistance || Infinity;
3862
+ controls.maxDistance = config.controls.maxDistance || 1e400;
3863
3863
  controls.screenSpacePanning = false;
3864
3864
  controls.maxPolarAngle = Math.PI;
3865
3865
  controls.update();