@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/parse.d.cts CHANGED
@@ -1,5 +1,12 @@
1
- import { o as MaterialAppearanceOptions } from "./types-i9wRcHK7.cjs";
1
+ /**
2
+ * `parse/` — backend payload → THREE meshes + metadata. Depends only on `shared/`; never imports
3
+ * from `render/` or `scene/`.
4
+ *
5
+ * The SLVA binary wire format (magics, version gates, flag bits, `parseBinaryMeshBatch`) is an
6
+ * implementation detail of `parseMeshBatch*` and stays unexported so it can change without a major bump.
7
+ */
2
8
  import * as THREE from "three";
9
+ import { o as MaterialAppearanceOptions } from "./types-D1PpOP_H.cjs";
3
10
  /** Structurally, not nominally, typed as `@selvajs/solve/client`'s `MeshPolicy<THREE.Object3D>` — avoids a dependency on solve. */
4
11
  export declare const meshPolicy: {
5
12
  clone(meshes: THREE.Object3D[]): THREE.Object3D[];
@@ -255,5 +262,4 @@ export declare function setTextureAnisotropy(value: number): void;
255
262
  * unrenderable item is logged and skipped.
256
263
  */
257
264
  export declare function parseDisplayItems(items: DisplayItem[] | undefined): THREE.Object3D[];
258
- export type { DisplayBatch, DisplayCurve, DisplayIdentity, DisplayItem, DisplayItemBase, DisplayPoint, DisplayPosition, MaterialGroup, MeshBatchParsingOptions, MeshExtractionOptions, MeshMetadata, SerializableMaterial };
259
- //# sourceMappingURL=parse.d.cts.map
265
+ export type { DisplayBatch, DisplayCurve, DisplayIdentity, DisplayItem, DisplayItemBase, DisplayPoint, DisplayPosition, MaterialGroup, MeshBatchParsingOptions, MeshExtractionOptions, MeshMetadata, SerializableMaterial };
package/dist/parse.d.ts CHANGED
@@ -1,5 +1,12 @@
1
- import { o as MaterialAppearanceOptions } from "./types-i9wRcHK7.js";
1
+ /**
2
+ * `parse/` — backend payload → THREE meshes + metadata. Depends only on `shared/`; never imports
3
+ * from `render/` or `scene/`.
4
+ *
5
+ * The SLVA binary wire format (magics, version gates, flag bits, `parseBinaryMeshBatch`) is an
6
+ * implementation detail of `parseMeshBatch*` and stays unexported so it can change without a major bump.
7
+ */
2
8
  import * as THREE from "three";
9
+ import { o as MaterialAppearanceOptions } from "./types-8Qx4xyyR.js";
3
10
  /** Structurally, not nominally, typed as `@selvajs/solve/client`'s `MeshPolicy<THREE.Object3D>` — avoids a dependency on solve. */
4
11
  export declare const meshPolicy: {
5
12
  clone(meshes: THREE.Object3D[]): THREE.Object3D[];
@@ -255,5 +262,4 @@ export declare function setTextureAnisotropy(value: number): void;
255
262
  * unrenderable item is logged and skipped.
256
263
  */
257
264
  export declare function parseDisplayItems(items: DisplayItem[] | undefined): THREE.Object3D[];
258
- export type { DisplayBatch, DisplayCurve, DisplayIdentity, DisplayItem, DisplayItemBase, DisplayPoint, DisplayPosition, MaterialGroup, MeshBatchParsingOptions, MeshExtractionOptions, MeshMetadata, SerializableMaterial };
259
- //# sourceMappingURL=parse.d.ts.map
265
+ export type { DisplayBatch, DisplayCurve, DisplayIdentity, DisplayItem, DisplayItemBase, DisplayPoint, DisplayPosition, MaterialGroup, MeshBatchParsingOptions, MeshExtractionOptions, MeshMetadata, SerializableMaterial };
package/dist/parse.js CHANGED
@@ -1,10 +1,10 @@
1
- import { S as VisualizationError, a as observeMaxAnisotropy, c as computeCombinedBoundingBox, d as EMISSIVE_LIGHT, h as lookEnvMapIntensity, i as isGlass, l as parseColor, m as OWN_ENV_MAP_INTENSITY, n as GLASS, p as OWN_EMISSIVE, s as applyOffset, t as disposeObjectTree, x as ErrorCodes, y as getLogger } from "./gpu-dispose-k_Gq-ygL.js";
2
- import { a as shareGeometry, o as unshareGeometry } from "./gpu-ownership-Bs9l7hrU.js";
3
- import * as THREE from "three";
1
+ import { S as VisualizationError, a as observeMaxAnisotropy, c as computeCombinedBoundingBox, d as EMISSIVE_LIGHT, h as lookEnvMapIntensity, i as isGlass, l as parseColor, m as OWN_ENV_MAP_INTENSITY, n as GLASS, p as OWN_EMISSIVE, s as applyOffset, t as disposeObjectTree, x as ErrorCodes, y as getLogger } from "./gpu-dispose-m5ywfM1f.js";
4
2
  import { Line2 } from "three/addons/lines/Line2.js";
5
3
  import { LineGeometry } from "three/addons/lines/LineGeometry.js";
6
4
  import { LineMaterial } from "three/addons/lines/LineMaterial.js";
5
+ import * as THREE from "three";
7
6
  import { inflate, inflateSync } from "fflate";
7
+ import { a as shareGeometry, o as unshareGeometry } from "./gpu-ownership-5o7F_lc2.js";
8
8
  // src/shared/encoding.ts
9
9
  function getNodeBuffer() {
10
10
  const buf = globalThis.Buffer;
@@ -214,7 +214,7 @@ function parseDisplayItems(items) {
214
214
  }
215
215
  // src/parse/webdisplay/binary/header.ts
216
216
  /** "SLVA" little-endian — an uncompressed mesh blob. */
217
- const BINARY_MESH_MAGIC = 1096174675;
217
+ const BINARY_MESH_MAGIC = 0x41564c53;
218
218
  /**
219
219
  * Header fields use explicit-LE `DataView` reads, but the zero-copy geometry readers build
220
220
  * typed-array views in *host* byte order (every mainstream JS target is little-endian, and
@@ -230,7 +230,7 @@ function toUint8Array(input) {
230
230
  return new Uint8Array(input);
231
231
  }
232
232
  function isSlvz(bytes) {
233
- return bytes.byteLength >= 8 && new DataView(bytes.buffer, bytes.byteOffset, 8).getUint32(0, true) === 1515605075;
233
+ return bytes.byteLength >= 8 && new DataView(bytes.buffer, bytes.byteOffset, 8).getUint32(0, true) === 0x5a564c53;
234
234
  }
235
235
  /** Size a SLVZ blob inflates to, as its header declares; 0 for anything else. Unvalidated. */
236
236
  function slvzInflatedBytes(bytes) {
@@ -539,12 +539,12 @@ function parseColorChunk(bytes, offset, vertexCount, deltaEncoded) {
539
539
  }
540
540
  return colors;
541
541
  }
542
- const CHUNK_GEOM = 1297040711;
543
- const CHUNK_TABL = 1279410516;
544
- const CHUNK_MATL = 1280590157;
545
- const CHUNK_TEXR = 1381516628;
542
+ const CHUNK_GEOM = 0x4d4f4547;
543
+ const CHUNK_TABL = 0x4c424154;
544
+ const CHUNK_MATL = 0x4c54414d;
545
+ const CHUNK_TEXR = 0x52584554;
546
546
  /** One byte per mesh row: 0 = unknown, 1 = open, 2 = closed solid. */
547
- const CHUNK_CLSD = 1146309699;
547
+ const CHUNK_CLSD = 0x44534c43;
548
548
  /** Reserved attr key carrying each object's identity — split out of the attr dict on read. */
549
549
  const ID_ATTR = "id";
550
550
  /** Material `map` prefix that references a TEXR chunk by index. */
@@ -553,7 +553,7 @@ const NAMES_NONE = 0;
553
553
  const NAMES_SEQUENTIAL = 1;
554
554
  const NAMES_POOL = 2;
555
555
  function isSlvmContainer(bytes) {
556
- return bytes.byteLength >= 4 && new DataView(bytes.buffer, bytes.byteOffset, 4).getUint32(0, true) === 1297501267;
556
+ return bytes.byteLength >= 4 && new DataView(bytes.buffer, bytes.byteOffset, 4).getUint32(0, true) === 0x4d564c53;
557
557
  }
558
558
  /**
559
559
  * Parses an SLVM v3 container down to its mesh geometry blob and the metadata the rest of the
@@ -598,7 +598,7 @@ function parseSlvmContainer(bytes) {
598
598
  }
599
599
  function readChunks(bytes) {
600
600
  const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
601
- if (bytes.byteLength < 12 || view.getUint32(0, true) !== 1297501267) throw fail("Not an SLVM container (bad magic).", { byteLength: bytes.byteLength });
601
+ if (bytes.byteLength < 12 || view.getUint32(0, true) !== 0x4d564c53) throw fail("Not an SLVM container (bad magic).", { byteLength: bytes.byteLength });
602
602
  const version = view.getUint32(4, true);
603
603
  if (version !== 3) throw fail(`Unsupported SLVM version: ${version}`, { expectedVersion: 3 });
604
604
  const count = view.getUint32(8, true);
@@ -908,7 +908,7 @@ function parseBinaryMeshBatchRaw(input) {
908
908
  let offset = 0;
909
909
  const magic = view.getUint32(offset, true);
910
910
  offset += 4;
911
- if (magic !== 1096174675) throw fail(`Invalid SLVA magic: 0x${magic.toString(16)}`, {
911
+ if (magic !== 0x41564c53) throw fail(`Invalid SLVA magic: 0x${magic.toString(16)}`, {
912
912
  expectedMagic: `0x${BINARY_MESH_MAGIC.toString(16)}`,
913
913
  actualMagic: `0x${magic.toString(16)}`
914
914
  });
@@ -1095,7 +1095,7 @@ function isClosedSolid(positions, indices, memberIndexCounts) {
1095
1095
  cellY = grown(cellY, weldSize);
1096
1096
  cellZ = grown(cellZ, weldSize);
1097
1097
  const cellSlot = (x, y, z) => {
1098
- let h = Math.imul(x, 2654435761) ^ Math.imul(y, 2246822519) ^ Math.imul(z, 3266489917);
1098
+ let h = Math.imul(x, 0x9e3779b1) ^ Math.imul(y, 0x85ebca77) ^ Math.imul(z, 0xc2b2ae3d);
1099
1099
  h = (h ^ h >>> 15) & weldMask;
1100
1100
  while (weldVertex[h] !== -1 && (cellX[h] !== x || cellY[h] !== y || cellZ[h] !== z)) h = h + 1 & weldMask;
1101
1101
  return h;
@@ -1244,7 +1244,7 @@ function splitCreases(positions, indices, uvs, colors) {
1244
1244
  {
1245
1245
  const posBits = new Uint32Array(positions.buffer, positions.byteOffset, positions.length);
1246
1246
  const uvBits = uvs ? new Uint32Array(uvs.buffer, uvs.byteOffset, uvs.length) : null;
1247
- const word = (bits, i) => bits[i] === 2147483648 ? 0 : bits[i];
1247
+ const word = (bits, i) => bits[i] === 0x80000000 ? 0 : bits[i];
1248
1248
  let size = 16;
1249
1249
  while (size < vertexCount * 2) size *= 2;
1250
1250
  const mask = size - 1;
@@ -1255,7 +1255,7 @@ function splitCreases(positions, indices, uvs, colors) {
1255
1255
  const x = word(posBits, v * 3);
1256
1256
  const y = word(posBits, v * 3 + 1);
1257
1257
  const z = word(posBits, v * 3 + 2);
1258
- let h = Math.imul(x, 2654435761) ^ Math.imul(y, 2246822519) ^ Math.imul(z, 3266489917);
1258
+ let h = Math.imul(x, 0x9e3779b1) ^ Math.imul(y, 0x85ebca77) ^ Math.imul(z, 0xc2b2ae3d);
1259
1259
  h = (h ^ h >>> 15) & mask;
1260
1260
  for (;;) {
1261
1261
  const other = slots[h];
@@ -2674,9 +2674,9 @@ function shapeOf(jobs) {
2674
2674
  function cacheKey(geometryBytes, jobShape) {
2675
2675
  const length = geometryBytes.length;
2676
2676
  const stride = Math.max(1, Math.floor(length / 1024));
2677
- let hash = 2166136261;
2677
+ let hash = 0x811c9dc5;
2678
2678
  for (let i = 0; i < length; i += stride) hash = Math.imul(hash ^ geometryBytes[i], 16777619);
2679
- let shapeHash = 2166136261;
2679
+ let shapeHash = 0x811c9dc5;
2680
2680
  for (let i = 0; i < jobShape.length; i++) shapeHash = Math.imul(shapeHash ^ jobShape[i], 16777619);
2681
2681
  return `${length}:${hash >>> 0}:${jobShape.length}:${shapeHash >>> 0}`;
2682
2682
  }
@@ -2761,17 +2761,14 @@ async function parseMeshBatchBlob(blob, options) {
2761
2761
  if (opened.meshes) return opened.meshes;
2762
2762
  const assembledMeshes = await tryBuildViaAssembly(opened, assemblyOptions);
2763
2763
  if (assembledMeshes) return assembledMeshes;
2764
- const parsed = decodeRawMeshBatch(opened.raw);
2765
- const decodeTime = performance.now() - decodeStart;
2766
- const blobBytes = blob.byteLength;
2767
- return buildMeshesFromParsed(parsed, {
2764
+ return buildMeshesFromParsed(decodeRawMeshBatch(opened.raw), {
2768
2765
  mergeByMaterial,
2769
2766
  debug,
2770
2767
  material,
2771
2768
  parseTime: 0,
2772
- decodeTime,
2769
+ decodeTime: performance.now() - decodeStart,
2773
2770
  perfStart,
2774
- blobBytes
2771
+ blobBytes: blob.byteLength
2775
2772
  });
2776
2773
  }
2777
2774
  const UNMERGED_MESH_WARN_THRESHOLD = 1e3;