u-space 0.0.32 → 0.0.33
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.
- package/dist/index.cjs +3 -3
- package/dist/index.js +1174 -938
- package/dist/modelDecodeProtocol-CC2tkS8h.js +405 -0
- package/dist/modelDecodeProtocol-pgjndTph.cjs +1 -0
- package/dist/src/loaders/ModelLoaderManager.d.ts +13 -1
- package/dist/src/loaders/modelPersistentCache.d.ts +35 -0
- package/dist/src/objects/Model.d.ts +4 -0
- package/dist/src/worker/decodeGltfModel.d.ts +7 -1
- package/dist/src/worker/modelDecodeProtocol.d.ts +2 -0
- package/dist/worker/model-decoder.cjs +1 -1
- package/dist/worker/model-decoder.js +231 -205
- package/docs/api-objects.md +11 -2
- package/docs/changelog.md +7 -0
- package/docs/examples-guide.md +2 -2
- package/docs/getting-started.md +1 -1
- package/package.json +1 -1
- package/dist/modelDecodeProtocol-D1Apm9iG.cjs +0 -1
- package/dist/modelDecodeProtocol-wDB7ksYw.js +0 -56
package/docs/getting-started.md
CHANGED
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function h(n){const r=n.nodes??[];if(r.length>1e5)throw new Error(`Decoded glTF contains ${r.length} nodes; the safe limit is 100000.`);const D=new Uint8Array(r.length);for(let e=0;e<r.length;e++){const d=r[e].children??[],c=new Set;for(const o of d){if(!Number.isInteger(o)||o<0||o>=r.length)throw new Error(`Decoded glTF node ${e} references invalid child ${o}.`);if(c.has(o))throw new Error(`Decoded glTF node ${e} repeats child ${o}.`);if(c.add(o),D[o]++,D[o]>1)throw new Error(`Decoded glTF node ${o} has multiple parents.`)}}const t=new Uint8Array(r.length),E=(e,d)=>{if(d>512)throw new Error("Decoded glTF node graph exceeds the safe depth of 512.");if(t[e]===1)throw new Error(`Decoded glTF node graph contains a cycle at ${e}.`);if(t[e]!==2){t[e]=1;for(const c of r[e].children??[])E(c,d+1);t[e]=2}};for(let e=0;e<r.length;e++)E(e,1);const s=n.scene??0,l=n.scenes?.[s];if(!l)throw new Error(`Decoded glTF references missing scene ${s}.`);const i=new Set;for(const e of l.nodes??[]){if(!Number.isInteger(e)||e<0||e>=r.length)throw new Error(`Decoded glTF scene ${s} references invalid node ${e}.`);if(i.has(e))throw new Error(`Decoded glTF scene ${s} repeats root node ${e}.`);if(i.add(e),D[e]>0)throw new Error(`Decoded glTF scene root ${e} is also referenced as a child.`)}}class a extends Error{name="UnsupportedModelDecodeError";constructor(r){super(r)}}exports.MODEL_DECODE_PROTOCOL_VERSION=3;exports.UnsupportedModelDecodeError=a;exports.validateDecodedGltfNodeGraph=h;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
const h = 3;
|
|
2
|
-
function a(n) {
|
|
3
|
-
const r = n.nodes ?? [];
|
|
4
|
-
if (r.length > 1e5)
|
|
5
|
-
throw new Error(
|
|
6
|
-
`Decoded glTF contains ${r.length} nodes; the safe limit is 100000.`
|
|
7
|
-
);
|
|
8
|
-
const D = new Uint8Array(r.length);
|
|
9
|
-
for (let e = 0; e < r.length; e++) {
|
|
10
|
-
const c = r[e].children ?? [], d = /* @__PURE__ */ new Set();
|
|
11
|
-
for (const o of c) {
|
|
12
|
-
if (!Number.isInteger(o) || o < 0 || o >= r.length)
|
|
13
|
-
throw new Error(`Decoded glTF node ${e} references invalid child ${o}.`);
|
|
14
|
-
if (d.has(o))
|
|
15
|
-
throw new Error(`Decoded glTF node ${e} repeats child ${o}.`);
|
|
16
|
-
if (d.add(o), D[o]++, D[o] > 1)
|
|
17
|
-
throw new Error(`Decoded glTF node ${o} has multiple parents.`);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
const t = new Uint8Array(r.length), i = (e, c) => {
|
|
21
|
-
if (c > 512)
|
|
22
|
-
throw new Error(
|
|
23
|
-
"Decoded glTF node graph exceeds the safe depth of 512."
|
|
24
|
-
);
|
|
25
|
-
if (t[e] === 1)
|
|
26
|
-
throw new Error(`Decoded glTF node graph contains a cycle at ${e}.`);
|
|
27
|
-
if (t[e] !== 2) {
|
|
28
|
-
t[e] = 1;
|
|
29
|
-
for (const d of r[e].children ?? []) i(d, c + 1);
|
|
30
|
-
t[e] = 2;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
for (let e = 0; e < r.length; e++) i(e, 1);
|
|
34
|
-
const s = n.scene ?? 0, l = n.scenes?.[s];
|
|
35
|
-
if (!l) throw new Error(`Decoded glTF references missing scene ${s}.`);
|
|
36
|
-
const E = /* @__PURE__ */ new Set();
|
|
37
|
-
for (const e of l.nodes ?? []) {
|
|
38
|
-
if (!Number.isInteger(e) || e < 0 || e >= r.length)
|
|
39
|
-
throw new Error(`Decoded glTF scene ${s} references invalid node ${e}.`);
|
|
40
|
-
if (E.has(e))
|
|
41
|
-
throw new Error(`Decoded glTF scene ${s} repeats root node ${e}.`);
|
|
42
|
-
if (E.add(e), D[e] > 0)
|
|
43
|
-
throw new Error(`Decoded glTF scene root ${e} is also referenced as a child.`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
class f extends Error {
|
|
47
|
-
name = "UnsupportedModelDecodeError";
|
|
48
|
-
constructor(r) {
|
|
49
|
-
super(r);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
export {
|
|
53
|
-
h as M,
|
|
54
|
-
f as U,
|
|
55
|
-
a as v
|
|
56
|
-
};
|