@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.cjs CHANGED
@@ -1,15 +1,15 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_gpu_ownership = require("./gpu-ownership-ADRZBxxs.cjs");
3
- const require_gpu_dispose = require("./gpu-dispose-0c_-KS12.cjs");
4
- const require_merged_draw = require("./merged-draw-ma_2r4N8.cjs");
2
+ const require_rolldown_runtime = require("./rolldown-runtime-CmQyd0Gu.cjs");
5
3
  let three = require("three");
6
- three = require_gpu_ownership.__toESM(three, 1);
7
- let three_addons_lines_Line2_js = require("three/addons/lines/Line2.js");
8
- let three_addons_lines_LineGeometry_js = require("three/addons/lines/LineGeometry.js");
9
- let three_addons_lines_LineMaterial_js = require("three/addons/lines/LineMaterial.js");
4
+ const require_gpu_dispose = require("./gpu-dispose--5MA0CcI.cjs");
5
+ const require_gpu_ownership = require("./gpu-ownership-BtECafMd.cjs");
10
6
  let three_addons_lines_LineSegments2_js = require("three/addons/lines/LineSegments2.js");
11
7
  let three_addons_lines_LineSegmentsGeometry_js = require("three/addons/lines/LineSegmentsGeometry.js");
8
+ const require_merged_draw = require("./merged-draw-C9jFRnos.cjs");
9
+ let three_addons_lines_LineMaterial_js = require("three/addons/lines/LineMaterial.js");
12
10
  let three_addons_renderers_CSS2DRenderer_js = require("three/addons/renderers/CSS2DRenderer.js");
11
+ let three_addons_lines_Line2_js = require("three/addons/lines/Line2.js");
12
+ let three_addons_lines_LineGeometry_js = require("three/addons/lines/LineGeometry.js");
13
13
  let three_mesh_bvh = require("three-mesh-bvh");
14
14
  let three_addons_helpers_ViewHelper_js = require("three/addons/helpers/ViewHelper.js");
15
15
  let three_addons_postprocessing_EffectComposer_js = require("three/addons/postprocessing/EffectComposer.js");
@@ -22,6 +22,7 @@ let three_addons_postprocessing_Pass_js = require("three/addons/postprocessing/P
22
22
  let three_addons_postprocessing_UnrealBloomPass_js = require("three/addons/postprocessing/UnrealBloomPass.js");
23
23
  let three_addons_controls_OrbitControls_js = require("three/addons/controls/OrbitControls.js");
24
24
  let three_addons_loaders_HDRLoader_js = require("three/addons/loaders/HDRLoader.js");
25
+ three = require_rolldown_runtime.__toESM(three, 1);
25
26
  // src/shared/types.ts
26
27
  /** Source of truth for {@link Look} — lets consumers (e.g. a style picker) iterate instead of hardcoding names. */
27
28
  const LOOKS = [
@@ -370,15 +371,15 @@ function applyDefaults(options) {
370
371
  sunlightPosition: options.lighting?.sunlightPosition || sunOffset(options.environment?.sceneUp ?? defaultUp, defaults.lightDistance, defaults.lightHeight),
371
372
  ambientLightColor: options.lighting?.ambientLightColor || new three.Color(4210752),
372
373
  ambientLightIntensity: options.lighting?.ambientLightIntensity ?? preset.ambientIntensity,
373
- sunlightColor: options.lighting?.sunlightColor || 16777215,
374
+ sunlightColor: options.lighting?.sunlightColor || 0xffffff,
374
375
  enableHemisphereLight: options.lighting?.enableHemisphereLight ?? preset.hemisphereIntensity > 0,
375
- hemisphereSkyColor: options.lighting?.hemisphereSkyColor ?? 14673663,
376
+ hemisphereSkyColor: options.lighting?.hemisphereSkyColor ?? 0xdfe6ff,
376
377
  hemisphereGroundColor: options.lighting?.hemisphereGroundColor ?? 7036754,
377
378
  hemisphereIntensity: options.lighting?.hemisphereIntensity ?? preset.hemisphereIntensity
378
379
  },
379
380
  environment: {
380
381
  hdrPath: options.environment?.hdrPath === false ? false : options.environment?.hdrPath || "/baseHDR.hdr",
381
- backgroundColor: options.environment?.backgroundColor || new three.Color(15790320),
382
+ backgroundColor: options.environment?.backgroundColor || new three.Color(0xf0f0f0),
382
383
  enableEnvironmentLighting: options.environment?.enableEnvironmentLighting ?? true,
383
384
  sceneUp: options.environment?.sceneUp || defaultUp,
384
385
  showEnvironment: options.environment?.showEnvironment ?? false,
@@ -417,7 +418,7 @@ function applyDefaults(options) {
417
418
  enableZoom: options.controls?.enableZoom ?? true,
418
419
  enablePan: options.controls?.enablePan ?? true,
419
420
  minDistance: options.controls?.minDistance || defaults.minDistance,
420
- maxDistance: options.controls?.maxDistance || Infinity
421
+ maxDistance: options.controls?.maxDistance || 1e400
421
422
  },
422
423
  grid: {
423
424
  enabled: options.grid?.enabled ?? false,
@@ -598,7 +599,7 @@ function setupLighting(scene, config) {
598
599
  hemisphere,
599
600
  sun: null
600
601
  };
601
- const sunlight = new three.DirectionalLight(config.lighting.sunlightColor ?? 16777215, config.lighting.sunlightIntensity);
602
+ const sunlight = new three.DirectionalLight(config.lighting.sunlightColor ?? 0xffffff, config.lighting.sunlightIntensity);
602
603
  const pos = config.lighting.sunlightPosition;
603
604
  if (pos) sunlight.position.set(pos.x, pos.y, pos.z);
604
605
  if (!config.render.enableShadows) {
@@ -1012,7 +1013,7 @@ const SPACING_PERCENTILE = .15;
1012
1013
  const SPACING_SAMPLE_LIMIT = 4096;
1013
1014
  function edgeSpacingOf(segments) {
1014
1015
  const segmentCount = Math.floor(segments.length / 6);
1015
- if (segmentCount === 0) return Infinity;
1016
+ if (segmentCount === 0) return 1e400;
1016
1017
  const stride = Math.max(1, Math.ceil(segmentCount / SPACING_SAMPLE_LIMIT));
1017
1018
  const lengths = [];
1018
1019
  for (let s = 0; s < segmentCount; s += stride) {
@@ -1020,7 +1021,7 @@ function edgeSpacingOf(segments) {
1020
1021
  const length = Math.hypot(segments[i + 3] - segments[i], segments[i + 4] - segments[i + 1], segments[i + 5] - segments[i + 2]);
1021
1022
  if (length > 0) lengths.push(length);
1022
1023
  }
1023
- if (lengths.length === 0) return Infinity;
1024
+ if (lengths.length === 0) return 1e400;
1024
1025
  lengths.sort((a, b) => a - b);
1025
1026
  return lengths[Math.min(lengths.length - 1, Math.floor(lengths.length * SPACING_PERCENTILE))];
1026
1027
  }
@@ -1288,7 +1289,7 @@ function fastPathData(geometry) {
1288
1289
  }
1289
1290
  function contentKey(data, thresholdAngle) {
1290
1291
  const SAMPLE_WORDS = 4096;
1291
- let hash = 2166136261;
1292
+ let hash = 0x811c9dc5;
1292
1293
  const mix = (word) => {
1293
1294
  hash ^= word;
1294
1295
  hash = Math.imul(hash, 16777619);
@@ -1609,22 +1610,22 @@ const _fadeCameraPos = new three.Vector3();
1609
1610
  function pixelsPerWorldUnit(overlay, camera, viewportHeightPx) {
1610
1611
  if (!overlay.geometry.boundingSphere) overlay.geometry.computeBoundingSphere();
1611
1612
  const sphere = overlay.geometry.boundingSphere;
1612
- if (!sphere) return Infinity;
1613
+ if (!sphere) return 1e400;
1613
1614
  if (camera.isPerspectiveCamera) {
1614
1615
  const perspective = camera;
1615
1616
  _fadeCenter.copy(sphere.center).applyMatrix4(overlay.matrixWorld);
1616
1617
  const distance = _fadeCameraPos.setFromMatrixPosition(camera.matrixWorld).distanceTo(_fadeCenter);
1617
- if (distance <= sphere.radius * overlay.matrixWorld.getMaxScaleOnAxis()) return Infinity;
1618
+ if (distance <= sphere.radius * overlay.matrixWorld.getMaxScaleOnAxis()) return 1e400;
1618
1619
  const tanHalfFov = Math.tan(three.MathUtils.degToRad(perspective.fov) * .5);
1619
1620
  const worldHeightAtCentre = 2 * distance * tanHalfFov;
1620
- return worldHeightAtCentre > 0 ? viewportHeightPx / worldHeightAtCentre : Infinity;
1621
+ return worldHeightAtCentre > 0 ? viewportHeightPx / worldHeightAtCentre : 1e400;
1621
1622
  }
1622
1623
  if (camera.isOrthographicCamera) {
1623
1624
  const ortho = camera;
1624
1625
  const worldHeight = (ortho.top - ortho.bottom) / ortho.zoom;
1625
- return worldHeight > 0 ? viewportHeightPx / worldHeight : Infinity;
1626
+ return worldHeight > 0 ? viewportHeightPx / worldHeight : 1e400;
1626
1627
  }
1627
- return Infinity;
1628
+ return 1e400;
1628
1629
  }
1629
1630
  function enableDistanceFade(overlay, edgeSpacing) {
1630
1631
  overlay.onBeforeRender = (renderer, _scene, camera) => {
@@ -2066,7 +2067,7 @@ function warmPickIndex(root) {
2066
2067
  }
2067
2068
  // src/render/measure.ts
2068
2069
  const DEFAULT_SNAP_PIXELS = 12;
2069
- const DEFAULT_COLOR = 16763904;
2070
+ const DEFAULT_COLOR = 0xffcc00;
2070
2071
  const LINE_PICK_FRACTION = .015;
2071
2072
  const RENDER_ORDER_LINE = 998;
2072
2073
  const RENDER_ORDER_MARKER = 999;
@@ -2558,7 +2559,7 @@ function createNearestDepthQuery() {
2558
2559
  const singleBox = /* @__PURE__ */ new Float32Array(6);
2559
2560
  let polygon = /* @__PURE__ */ new Float64Array(21);
2560
2561
  let clipped = /* @__PURE__ */ new Float64Array(21);
2561
- let nearest = Infinity;
2562
+ let nearest = 1e400;
2562
2563
  let sawContent = false;
2563
2564
  const chunksOf = (object, geometry) => {
2564
2565
  const position = geometry.getAttribute("position");
@@ -2579,7 +2580,7 @@ function createNearestDepthQuery() {
2579
2580
  const chunkDepth = (chunks, chunk, planes) => {
2580
2581
  const { position, index } = chunks;
2581
2582
  const indices = index?.array;
2582
- let best = Infinity;
2583
+ let best = 1e400;
2583
2584
  for (let t = chunks.ranges[chunk * 2]; t < chunks.ranges[chunk * 2 + 1]; t++) {
2584
2585
  for (let corner = 0; corner < 3; corner++) {
2585
2586
  const v = indices ? indices[t * 3 + corner] : t * 3 + corner;
@@ -2712,7 +2713,7 @@ function createNearestDepthQuery() {
2712
2713
  worldPlanes[17] = forward.y;
2713
2714
  worldPlanes[18] = forward.z;
2714
2715
  worldPlanes[19] = -forward.dot(camera.position);
2715
- nearest = Infinity;
2716
+ nearest = 1e400;
2716
2717
  sawContent = false;
2717
2718
  for (const child of scene.children) visit(child);
2718
2719
  return sawContent ? nearest : null;
@@ -2760,12 +2761,12 @@ function buildChunkBoxes(position, index, breaks) {
2760
2761
  const fast = plain && position.itemSize === 3 && !position.normalized;
2761
2762
  const indices = index?.array;
2762
2763
  for (let chunk = 0; chunk < chunkCount; chunk++) {
2763
- let minX = Infinity;
2764
- let minY = Infinity;
2765
- let minZ = Infinity;
2766
- let maxX = -Infinity;
2767
- let maxY = -Infinity;
2768
- let maxZ = -Infinity;
2764
+ let minX = 1e400;
2765
+ let minY = 1e400;
2766
+ let minZ = 1e400;
2767
+ let maxX = -1e400;
2768
+ let maxY = -1e400;
2769
+ let maxZ = -1e400;
2769
2770
  const end = ranges[chunk * 2 + 1] * 3;
2770
2771
  for (let corner = ranges[chunk * 2] * 3; corner < end; corner++) {
2771
2772
  const v = indices ? indices[corner] : corner;
@@ -3112,8 +3113,8 @@ function createEmissiveLights(scene) {
3112
3113
  const silenced = /* @__PURE__ */ new Set();
3113
3114
  const offset = new three.Vector3();
3114
3115
  const addLight = (shadowed) => {
3115
- const key = new three.PointLight(16777215, 1, 0, 2);
3116
- const bounce = new three.PointLight(16777215, 1, 0, 1);
3116
+ const key = new three.PointLight(0xffffff, 1, 0, 2);
3117
+ const bounce = new three.PointLight(0xffffff, 1, 0, 1);
3117
3118
  if (shadowed) {
3118
3119
  key.castShadow = true;
3119
3120
  key.shadow.mapSize.setScalar(SHADOW_MAP_SIZE);
@@ -3247,7 +3248,7 @@ function applyMaterialOverride(material, override) {
3247
3248
  return;
3248
3249
  }
3249
3250
  if (!target[BASELINE_KEY]) target[BASELINE_KEY] = {
3250
- color: target.color?.getHex() ?? 16777215,
3251
+ color: target.color?.getHex() ?? 0xffffff,
3251
3252
  metalness: target.metalness ?? 0,
3252
3253
  roughness: target.roughness ?? 1,
3253
3254
  emissiveIntensity: target.emissiveIntensity ?? 0,
@@ -3861,7 +3862,7 @@ function setupControls(camera, canvas, config) {
3861
3862
  controls.enableZoom = config.controls.enableZoom ?? true;
3862
3863
  controls.enablePan = config.controls.enablePan ?? true;
3863
3864
  controls.minDistance = config.controls.minDistance || .001;
3864
- controls.maxDistance = config.controls.maxDistance || Infinity;
3865
+ controls.maxDistance = config.controls.maxDistance || 1e400;
3865
3866
  controls.screenSpacePanning = false;
3866
3867
  controls.maxPolarAngle = Math.PI;
3867
3868
  controls.update();