@selvajs/visualization 1.8.0-beta.7 → 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 +99 -53
  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 +97 -52
  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";
@@ -32,6 +32,36 @@ const LOOKS = [
32
32
  "wireframe",
33
33
  "night"
34
34
  ];
35
+ // src/render/fit.ts
36
+ /** Room left around a fitted box, as a factor on the tight distance. */
37
+ const FIT_MARGIN = 1.1;
38
+ /**
39
+ * How far from the box's center, along `direction` (target → camera), a perspective camera with
40
+ * vertical field of view `fovDegrees` and `aspect` must sit to see the whole box, with `margin`.
41
+ *
42
+ * Every corner is fitted across both the width and the height of the view. Fitting the box's
43
+ * largest side to the vertical field of view alone left a long part in a wide viewport filling a
44
+ * third of it.
45
+ */
46
+ function fitDistance(box, direction, up, fovDegrees, aspect, margin = FIT_MARGIN) {
47
+ if (box.isEmpty()) return margin;
48
+ const dir = direction.clone().normalize();
49
+ const center = box.getCenter(new THREE.Vector3());
50
+ const tanV = Math.tan(fovDegrees * Math.PI / 360);
51
+ const tanH = tanV * (aspect > 0 && Number.isFinite(aspect) ? aspect : 1);
52
+ const right = new THREE.Vector3().crossVectors(up, dir);
53
+ if (right.lengthSq() < 1e-12) right.crossVectors(Math.abs(dir.x) < .9 ? new THREE.Vector3(1, 0, 0) : new THREE.Vector3(0, 1, 0), dir);
54
+ right.normalize();
55
+ const viewUp = new THREE.Vector3().crossVectors(dir, right).normalize();
56
+ const corner = new THREE.Vector3();
57
+ let distance = 0;
58
+ for (const x of [box.min.x, box.max.x]) for (const y of [box.min.y, box.max.y]) for (const z of [box.min.z, box.max.z]) {
59
+ corner.set(x, y, z).sub(center);
60
+ const depth = corner.dot(dir);
61
+ distance = Math.max(distance, Math.abs(corner.dot(right)) / tanH + depth, Math.abs(corner.dot(viewUp)) / tanV + depth);
62
+ }
63
+ return (distance || 1) * margin;
64
+ }
35
65
  // src/render/scene-ownership.ts
36
66
  /** Geometry produced by a solve. Replaced wholesale on the next one. */
37
67
  const SOURCE_COMPUTE = "compute";
@@ -338,15 +368,15 @@ function applyDefaults(options) {
338
368
  sunlightPosition: options.lighting?.sunlightPosition || sunOffset(options.environment?.sceneUp ?? defaultUp, defaults.lightDistance, defaults.lightHeight),
339
369
  ambientLightColor: options.lighting?.ambientLightColor || new THREE.Color(4210752),
340
370
  ambientLightIntensity: options.lighting?.ambientLightIntensity ?? preset.ambientIntensity,
341
- sunlightColor: options.lighting?.sunlightColor || 16777215,
371
+ sunlightColor: options.lighting?.sunlightColor || 0xffffff,
342
372
  enableHemisphereLight: options.lighting?.enableHemisphereLight ?? preset.hemisphereIntensity > 0,
343
- hemisphereSkyColor: options.lighting?.hemisphereSkyColor ?? 14673663,
373
+ hemisphereSkyColor: options.lighting?.hemisphereSkyColor ?? 0xdfe6ff,
344
374
  hemisphereGroundColor: options.lighting?.hemisphereGroundColor ?? 7036754,
345
375
  hemisphereIntensity: options.lighting?.hemisphereIntensity ?? preset.hemisphereIntensity
346
376
  },
347
377
  environment: {
348
378
  hdrPath: options.environment?.hdrPath === false ? false : options.environment?.hdrPath || "/baseHDR.hdr",
349
- backgroundColor: options.environment?.backgroundColor || new THREE.Color(15790320),
379
+ backgroundColor: options.environment?.backgroundColor || new THREE.Color(0xf0f0f0),
350
380
  enableEnvironmentLighting: options.environment?.enableEnvironmentLighting ?? true,
351
381
  sceneUp: options.environment?.sceneUp || defaultUp,
352
382
  showEnvironment: options.environment?.showEnvironment ?? false,
@@ -385,7 +415,7 @@ function applyDefaults(options) {
385
415
  enableZoom: options.controls?.enableZoom ?? true,
386
416
  enablePan: options.controls?.enablePan ?? true,
387
417
  minDistance: options.controls?.minDistance || defaults.minDistance,
388
- maxDistance: options.controls?.maxDistance || Infinity
418
+ maxDistance: options.controls?.maxDistance || 1e400
389
419
  },
390
420
  grid: {
391
421
  enabled: options.grid?.enabled ?? false,
@@ -566,7 +596,7 @@ function setupLighting(scene, config) {
566
596
  hemisphere,
567
597
  sun: null
568
598
  };
569
- 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);
570
600
  const pos = config.lighting.sunlightPosition;
571
601
  if (pos) sunlight.position.set(pos.x, pos.y, pos.z);
572
602
  if (!config.render.enableShadows) {
@@ -647,8 +677,7 @@ const CAMERA_CONFIG = {
647
677
  HUGE: 100,
648
678
  LARGE: 50,
649
679
  NORMAL: 20
650
- },
651
- INITIAL_DISTANCE_MULTIPLIER: 4
680
+ }
652
681
  };
653
682
  /** Replaces scene content with `meshes`, rescales the camera frustum to fit, and (first call only) positions the camera/controls. */
654
683
  function updateScene(scene, meshes, camera, controls, initialPositionSet) {
@@ -674,8 +703,9 @@ function updateScene(scene, meshes, camera, controls, initialPositionSet) {
674
703
  }
675
704
  camera.updateProjectionMatrix();
676
705
  if (!initialPositionSet) {
677
- const distance = maxDim * CAMERA_CONFIG.INITIAL_DISTANCE_MULTIPLIER;
678
- camera.position.copy(center).add(isoOffset(camera.up, distance));
706
+ const direction = isoOffset(camera.up, 1).normalize();
707
+ const distance = fitDistance(unionBoundingBox, direction, camera.up, camera.fov, camera.aspect);
708
+ camera.position.copy(center).addScaledVector(direction, distance);
679
709
  controls.target.copy(center);
680
710
  controls.update();
681
711
  }
@@ -815,10 +845,19 @@ function createCameraController(deps) {
815
845
  controls.update();
816
846
  onActiveCameraChange(active());
817
847
  };
818
- const frame = (center, maxDim, direction, animate) => {
819
- const fov = perspective.fov * (Math.PI / 180);
820
- const distance = maxDim / (2 * Math.tan(fov / 2)) * 1.5;
821
- const dir = nudgeOffPole(direction, up);
848
+ let lastFit = null;
849
+ const forgetFit = () => {
850
+ lastFit = null;
851
+ };
852
+ controls.addEventListener?.("start", forgetFit);
853
+ const frame = (box, direction, animate) => {
854
+ const center = box.getCenter(new THREE.Vector3());
855
+ const dir = nudgeOffPole(direction, up).clone().normalize();
856
+ const distance = fitDistance(box, dir, up, perspective.fov, aspect);
857
+ lastFit = {
858
+ box: box.clone(),
859
+ direction: dir.clone()
860
+ };
822
861
  const toPosition = center.clone().add(dir.clone().multiplyScalar(distance));
823
862
  const cam = active();
824
863
  if (projection === "orthographic") ortho.zoom = 1;
@@ -834,20 +873,15 @@ function createCameraController(deps) {
834
873
  }
835
874
  };
836
875
  const setViewDirection = (direction, animate = true) => {
837
- const box = computeContentBounds(scene);
838
- const center = box.isEmpty() ? controls.target.clone() : box.getCenter(new THREE.Vector3());
839
- const size = box.isEmpty() ? new THREE.Vector3(1, 1, 1) : box.getSize(new THREE.Vector3());
840
- const maxDim = Math.max(size.x, size.y, size.z) || 1;
841
- frame(center, maxDim, direction, animate);
876
+ const content = computeContentBounds(scene);
877
+ const box = content.isEmpty() ? new THREE.Box3().setFromCenterAndSize(controls.target.clone(), new THREE.Vector3(1, 1, 1)) : content;
878
+ frame(box, direction, animate);
842
879
  };
843
880
  const frameBounds = (box, animate = true) => {
844
881
  if (box.isEmpty()) return;
845
- const center = box.getCenter(new THREE.Vector3());
846
- const size = box.getSize(new THREE.Vector3());
847
- const maxDim = Math.max(size.x, size.y, size.z) || 1;
848
882
  const direction = active().position.clone().sub(controls.target);
849
883
  if (direction.lengthSq() < 1e-12) direction.copy(VIEW_DIRECTIONS.iso);
850
- frame(center, maxDim, direction.normalize(), animate);
884
+ frame(box, direction.normalize(), animate);
851
885
  };
852
886
  const setView = (preset, animate = true) => {
853
887
  setViewDirection(VIEW_DIRECTIONS[preset], animate);
@@ -868,6 +902,7 @@ function createCameraController(deps) {
868
902
  const target = toVector(view.target);
869
903
  if (position && target && position.distanceToSquared(target) > 1e-12) {
870
904
  cancelTween();
905
+ forgetFit();
871
906
  const cam = active();
872
907
  if (projection === "orthographic") ortho.zoom = 1;
873
908
  if (animate) {
@@ -890,7 +925,14 @@ function createCameraController(deps) {
890
925
  controls.enableRotate = enabled;
891
926
  };
892
927
  const updateAspect = (width, height) => {
893
- aspect = height === 0 ? aspect : width / height;
928
+ const next = height === 0 ? aspect : width / height;
929
+ const changed = Math.abs(next - aspect) > 1e-6;
930
+ aspect = next;
931
+ if (changed && lastFit) {
932
+ const { box, direction } = lastFit;
933
+ frame(box, direction, false);
934
+ return;
935
+ }
894
936
  if (projection === "orthographic") syncOrthoFrustum();
895
937
  };
896
938
  return {
@@ -909,7 +951,10 @@ function createCameraController(deps) {
909
951
  setRotateEnabled,
910
952
  isRotateEnabled: () => controls.enableRotate,
911
953
  updateAspect,
912
- dispose: cancelTween
954
+ dispose: () => {
955
+ cancelTween();
956
+ controls.removeEventListener?.("start", forgetFit);
957
+ }
913
958
  };
914
959
  }
915
960
  const rounded = (v) => [
@@ -965,7 +1010,7 @@ const SPACING_PERCENTILE = .15;
965
1010
  const SPACING_SAMPLE_LIMIT = 4096;
966
1011
  function edgeSpacingOf(segments) {
967
1012
  const segmentCount = Math.floor(segments.length / 6);
968
- if (segmentCount === 0) return Infinity;
1013
+ if (segmentCount === 0) return 1e400;
969
1014
  const stride = Math.max(1, Math.ceil(segmentCount / SPACING_SAMPLE_LIMIT));
970
1015
  const lengths = [];
971
1016
  for (let s = 0; s < segmentCount; s += stride) {
@@ -973,7 +1018,7 @@ function edgeSpacingOf(segments) {
973
1018
  const length = Math.hypot(segments[i + 3] - segments[i], segments[i + 4] - segments[i + 1], segments[i + 5] - segments[i + 2]);
974
1019
  if (length > 0) lengths.push(length);
975
1020
  }
976
- if (lengths.length === 0) return Infinity;
1021
+ if (lengths.length === 0) return 1e400;
977
1022
  lengths.sort((a, b) => a - b);
978
1023
  return lengths[Math.min(lengths.length - 1, Math.floor(lengths.length * SPACING_PERCENTILE))];
979
1024
  }
@@ -1241,7 +1286,7 @@ function fastPathData(geometry) {
1241
1286
  }
1242
1287
  function contentKey(data, thresholdAngle) {
1243
1288
  const SAMPLE_WORDS = 4096;
1244
- let hash = 2166136261;
1289
+ let hash = 0x811c9dc5;
1245
1290
  const mix = (word) => {
1246
1291
  hash ^= word;
1247
1292
  hash = Math.imul(hash, 16777619);
@@ -1562,22 +1607,22 @@ const _fadeCameraPos = new THREE.Vector3();
1562
1607
  function pixelsPerWorldUnit(overlay, camera, viewportHeightPx) {
1563
1608
  if (!overlay.geometry.boundingSphere) overlay.geometry.computeBoundingSphere();
1564
1609
  const sphere = overlay.geometry.boundingSphere;
1565
- if (!sphere) return Infinity;
1610
+ if (!sphere) return 1e400;
1566
1611
  if (camera.isPerspectiveCamera) {
1567
1612
  const perspective = camera;
1568
1613
  _fadeCenter.copy(sphere.center).applyMatrix4(overlay.matrixWorld);
1569
1614
  const distance = _fadeCameraPos.setFromMatrixPosition(camera.matrixWorld).distanceTo(_fadeCenter);
1570
- if (distance <= sphere.radius * overlay.matrixWorld.getMaxScaleOnAxis()) return Infinity;
1615
+ if (distance <= sphere.radius * overlay.matrixWorld.getMaxScaleOnAxis()) return 1e400;
1571
1616
  const tanHalfFov = Math.tan(THREE.MathUtils.degToRad(perspective.fov) * .5);
1572
1617
  const worldHeightAtCentre = 2 * distance * tanHalfFov;
1573
- return worldHeightAtCentre > 0 ? viewportHeightPx / worldHeightAtCentre : Infinity;
1618
+ return worldHeightAtCentre > 0 ? viewportHeightPx / worldHeightAtCentre : 1e400;
1574
1619
  }
1575
1620
  if (camera.isOrthographicCamera) {
1576
1621
  const ortho = camera;
1577
1622
  const worldHeight = (ortho.top - ortho.bottom) / ortho.zoom;
1578
- return worldHeight > 0 ? viewportHeightPx / worldHeight : Infinity;
1623
+ return worldHeight > 0 ? viewportHeightPx / worldHeight : 1e400;
1579
1624
  }
1580
- return Infinity;
1625
+ return 1e400;
1581
1626
  }
1582
1627
  function enableDistanceFade(overlay, edgeSpacing) {
1583
1628
  overlay.onBeforeRender = (renderer, _scene, camera) => {
@@ -2019,7 +2064,7 @@ function warmPickIndex(root) {
2019
2064
  }
2020
2065
  // src/render/measure.ts
2021
2066
  const DEFAULT_SNAP_PIXELS = 12;
2022
- const DEFAULT_COLOR = 16763904;
2067
+ const DEFAULT_COLOR = 0xffcc00;
2023
2068
  const LINE_PICK_FRACTION = .015;
2024
2069
  const RENDER_ORDER_LINE = 998;
2025
2070
  const RENDER_ORDER_MARKER = 999;
@@ -2511,7 +2556,7 @@ function createNearestDepthQuery() {
2511
2556
  const singleBox = /* @__PURE__ */ new Float32Array(6);
2512
2557
  let polygon = /* @__PURE__ */ new Float64Array(21);
2513
2558
  let clipped = /* @__PURE__ */ new Float64Array(21);
2514
- let nearest = Infinity;
2559
+ let nearest = 1e400;
2515
2560
  let sawContent = false;
2516
2561
  const chunksOf = (object, geometry) => {
2517
2562
  const position = geometry.getAttribute("position");
@@ -2532,7 +2577,7 @@ function createNearestDepthQuery() {
2532
2577
  const chunkDepth = (chunks, chunk, planes) => {
2533
2578
  const { position, index } = chunks;
2534
2579
  const indices = index?.array;
2535
- let best = Infinity;
2580
+ let best = 1e400;
2536
2581
  for (let t = chunks.ranges[chunk * 2]; t < chunks.ranges[chunk * 2 + 1]; t++) {
2537
2582
  for (let corner = 0; corner < 3; corner++) {
2538
2583
  const v = indices ? indices[t * 3 + corner] : t * 3 + corner;
@@ -2665,7 +2710,7 @@ function createNearestDepthQuery() {
2665
2710
  worldPlanes[17] = forward.y;
2666
2711
  worldPlanes[18] = forward.z;
2667
2712
  worldPlanes[19] = -forward.dot(camera.position);
2668
- nearest = Infinity;
2713
+ nearest = 1e400;
2669
2714
  sawContent = false;
2670
2715
  for (const child of scene.children) visit(child);
2671
2716
  return sawContent ? nearest : null;
@@ -2713,12 +2758,12 @@ function buildChunkBoxes(position, index, breaks) {
2713
2758
  const fast = plain && position.itemSize === 3 && !position.normalized;
2714
2759
  const indices = index?.array;
2715
2760
  for (let chunk = 0; chunk < chunkCount; chunk++) {
2716
- let minX = Infinity;
2717
- let minY = Infinity;
2718
- let minZ = Infinity;
2719
- let maxX = -Infinity;
2720
- let maxY = -Infinity;
2721
- 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;
2722
2767
  const end = ranges[chunk * 2 + 1] * 3;
2723
2768
  for (let corner = ranges[chunk * 2] * 3; corner < end; corner++) {
2724
2769
  const v = indices ? indices[corner] : corner;
@@ -3065,8 +3110,8 @@ function createEmissiveLights(scene) {
3065
3110
  const silenced = /* @__PURE__ */ new Set();
3066
3111
  const offset = new THREE.Vector3();
3067
3112
  const addLight = (shadowed) => {
3068
- const key = new THREE.PointLight(16777215, 1, 0, 2);
3069
- 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);
3070
3115
  if (shadowed) {
3071
3116
  key.castShadow = true;
3072
3117
  key.shadow.mapSize.setScalar(SHADOW_MAP_SIZE);
@@ -3200,7 +3245,7 @@ function applyMaterialOverride(material, override) {
3200
3245
  return;
3201
3246
  }
3202
3247
  if (!target[BASELINE_KEY]) target[BASELINE_KEY] = {
3203
- color: target.color?.getHex() ?? 16777215,
3248
+ color: target.color?.getHex() ?? 0xffffff,
3204
3249
  metalness: target.metalness ?? 0,
3205
3250
  roughness: target.roughness ?? 1,
3206
3251
  emissiveIntensity: target.emissiveIntensity ?? 0,
@@ -3814,7 +3859,7 @@ function setupControls(camera, canvas, config) {
3814
3859
  controls.enableZoom = config.controls.enableZoom ?? true;
3815
3860
  controls.enablePan = config.controls.enablePan ?? true;
3816
3861
  controls.minDistance = config.controls.minDistance || .001;
3817
- controls.maxDistance = config.controls.maxDistance || Infinity;
3862
+ controls.maxDistance = config.controls.maxDistance || 1e400;
3818
3863
  controls.screenSpacePanning = false;
3819
3864
  controls.maxPolarAngle = Math.PI;
3820
3865
  controls.update();