three-cad-viewer 5.0.1 → 5.0.3

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.
@@ -11,7 +11,7 @@
11
11
  * instances via `"shape": { "ref": N }`. After decoding, the result is a
12
12
  * standard Shapes tree with TypedArrays — identical to the existing format.
13
13
  */
14
- import type { Shapes } from "../core/types.js";
14
+ import type { Shape, Shapes } from "../core/types.js";
15
15
  /** A single base64-encoded buffer entry. */
16
16
  interface EncodedBuffer {
17
17
  shape: number[];
@@ -48,13 +48,34 @@ declare function decodeInlineBuffers(shapes: Shapes): void;
48
48
  * Detected by the presence of an `instances` array and a `shapes` object.
49
49
  */
50
50
  declare function isInstancedFormat(data: unknown): data is InstancedData;
51
+ /**
52
+ * Decode every instance's buffers from base64 into TypedArrays.
53
+ *
54
+ * This is the leaf half of the instanced format: it knows the encoding and
55
+ * nothing about the shapes tree. A host that receives its geometry as raw
56
+ * binary rather than base64 skips this step and builds the `Shape[]` itself.
57
+ */
58
+ declare function decodeBuffers(instances: EncodedInstance[]): Shape[];
59
+ /**
60
+ * Resolve `{ ref: N }` entries in the shapes tree against decoded instances,
61
+ * and return the tree.
62
+ *
63
+ * This is the structural half: the same geometry referenced N times - twenty
64
+ * identical bolts - which every host needs whatever encoding it received the
65
+ * buffers in. Held separate from `decodeBuffers` so that a host holding
66
+ * TypedArrays already does not have to reimplement the walk.
67
+ */
68
+ declare function resolveInstances(shapes: Shapes, decoded: Shape[]): Shapes;
51
69
  /**
52
70
  * Decode the instanced format into a standard Shapes object.
53
71
  *
54
72
  * 1. Decode all instance buffers from base64 → TypedArrays
55
73
  * 2. Walk the shapes tree and replace { ref: N } with decoded instances
56
74
  * 3. Return the unwrapped Shapes object
75
+ *
76
+ * Kept as the composition of the two halves above, so existing callers see
77
+ * no change.
57
78
  */
58
79
  declare function decodeInstancedFormat(data: InstancedData): Shapes;
59
- export { isInstancedFormat, decodeInstancedFormat, decodeInlineBuffers };
80
+ export { isInstancedFormat, decodeBuffers, resolveInstances, decodeInstancedFormat, decodeInlineBuffers, };
60
81
  export type { InstancedData, EncodedBuffer, EncodedInstance };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "three-cad-viewer",
3
- "version": "5.0.1",
3
+ "version": "5.0.3",
4
4
  "type": "module",
5
5
  "description": "WebGL-based CAD viewer built on Three.js with clipping planes, measurement tools, and tree navigation",
6
6
  "repository": {