@loaders.gl/scene 5.0.0-beta.4 → 5.0.0-beta.5

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 (177) hide show
  1. package/DRACO-README.md +1 -1
  2. package/GLTF-README.md +1 -1
  3. package/OBJ-README.md +1 -1
  4. package/README.md +6 -1
  5. package/THIRD-PARTY-NOTICES.md +6 -0
  6. package/dist/dist.dev.js +2958 -750
  7. package/dist/dist.min.js +18 -18
  8. package/dist/draco/draco-javascript-loader-with-parser.d.ts +2 -2
  9. package/dist/draco/draco-loader-types.cjs +3 -3
  10. package/dist/draco/draco-loader-types.cjs.map +2 -2
  11. package/dist/draco/draco-loader-types.d.ts +1 -1
  12. package/dist/draco/draco-loader-types.d.ts.map +1 -1
  13. package/dist/draco/draco-loader-types.js +1 -1
  14. package/dist/draco/draco-loader-types.js.map +1 -1
  15. package/dist/draco/draco-loader.d.ts +2 -2
  16. package/dist/draco/draco-wasm-loader-with-parser.d.ts +2 -2
  17. package/dist/draco/draco3d-loader-with-parser.d.ts +2 -2
  18. package/dist/draco/lib/utils/version.cjs +1 -1
  19. package/dist/draco/lib/utils/version.js +1 -1
  20. package/dist/draco-worker-node.js +400 -113
  21. package/dist/draco-worker-node.js.map +4 -4
  22. package/dist/draco-worker.js +394 -113
  23. package/dist/draco-worker.js.map +4 -4
  24. package/dist/draco-writer-worker-node.cjs +654 -85
  25. package/dist/draco-writer-worker-node.cjs.map +4 -4
  26. package/dist/draco-writer-worker.js +624 -69
  27. package/dist/draco-writer-worker.js.map +4 -4
  28. package/dist/gltf/lib/extensions/KHR_gaussian_splatting.cjs +11 -4
  29. package/dist/gltf/lib/extensions/KHR_gaussian_splatting.cjs.map +2 -2
  30. package/dist/gltf/lib/extensions/KHR_gaussian_splatting.d.ts.map +1 -1
  31. package/dist/gltf/lib/extensions/KHR_gaussian_splatting.js +12 -2
  32. package/dist/gltf/lib/extensions/KHR_gaussian_splatting.js.map +1 -1
  33. package/dist/gltf/lib/parsers/parse-gltf.cjs.map +2 -2
  34. package/dist/gltf/lib/parsers/parse-gltf.d.ts +2 -0
  35. package/dist/gltf/lib/parsers/parse-gltf.d.ts.map +1 -1
  36. package/dist/gltf/lib/parsers/parse-gltf.js.map +1 -1
  37. package/dist/gltf/lib/types/gltf-additional-extension-schemas.cjs +22 -0
  38. package/dist/gltf/lib/types/gltf-additional-extension-schemas.cjs.map +2 -2
  39. package/dist/gltf/lib/types/gltf-additional-extension-schemas.d.ts +23 -0
  40. package/dist/gltf/lib/types/gltf-additional-extension-schemas.d.ts.map +1 -1
  41. package/dist/gltf/lib/types/gltf-additional-extension-schemas.js +22 -0
  42. package/dist/gltf/lib/types/gltf-additional-extension-schemas.js.map +1 -1
  43. package/dist/gltf/lib/types/gltf-extension-schemas.cjs +8 -0
  44. package/dist/gltf/lib/types/gltf-extension-schemas.cjs.map +2 -2
  45. package/dist/gltf/lib/types/gltf-extension-schemas.d.ts +27 -0
  46. package/dist/gltf/lib/types/gltf-extension-schemas.d.ts.map +1 -1
  47. package/dist/gltf/lib/types/gltf-extension-schemas.js +8 -1
  48. package/dist/gltf/lib/types/gltf-extension-schemas.js.map +1 -1
  49. package/dist/gltf/lib/types/gltf-json-schema.cjs.map +1 -1
  50. package/dist/gltf/lib/types/gltf-json-schema.d.ts +2 -2
  51. package/dist/gltf/lib/types/gltf-json-schema.d.ts.map +1 -1
  52. package/dist/gltf/lib/types/gltf-version-zod-schemas.d.ts +34 -0
  53. package/dist/gltf/lib/types/gltf-version-zod-schemas.d.ts.map +1 -1
  54. package/dist/gltf/lib/types/gltf-zod-schema.cjs +1 -1
  55. package/dist/gltf/lib/types/gltf-zod-schema.cjs.map +2 -2
  56. package/dist/gltf/lib/types/gltf-zod-schema.d.ts +51 -0
  57. package/dist/gltf/lib/types/gltf-zod-schema.d.ts.map +1 -1
  58. package/dist/gltf/lib/types/gltf-zod-schema.js +2 -2
  59. package/dist/gltf/lib/types/gltf-zod-schema.js.map +1 -1
  60. package/dist/gltf/lib/utils/version.cjs +1 -1
  61. package/dist/gltf/lib/utils/version.js +1 -1
  62. package/dist/index.cjs +4 -1
  63. package/dist/index.cjs.map +2 -2
  64. package/dist/index.d.ts +1 -0
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +2 -1
  67. package/dist/index.js.map +1 -1
  68. package/dist/mtl-loader-types.cjs +1 -1
  69. package/dist/obj/mtl-loader-types.cjs +1 -1
  70. package/dist/obj/mtl-loader-types.js +1 -1
  71. package/dist/obj/obj-loader-types.cjs +3 -3
  72. package/dist/obj/obj-loader-types.cjs.map +2 -2
  73. package/dist/obj/obj-loader-types.d.ts +1 -1
  74. package/dist/obj/obj-loader-types.d.ts.map +1 -1
  75. package/dist/obj/obj-loader-types.js +2 -2
  76. package/dist/obj/obj-loader-types.js.map +1 -1
  77. package/dist/obj/obj-loader.cjs +5 -5
  78. package/dist/obj/obj-loader.cjs.map +2 -2
  79. package/dist/obj/obj-loader.d.ts +1 -1
  80. package/dist/obj/obj-loader.d.ts.map +1 -1
  81. package/dist/obj/obj-loader.js +1 -1
  82. package/dist/obj/obj-loader.js.map +1 -1
  83. package/dist/obj/obj-writer.cjs +1 -1
  84. package/dist/obj/obj-writer.js +1 -1
  85. package/dist/obj-loader-types.cjs +3 -3
  86. package/dist/obj-loader-types.cjs.map +2 -2
  87. package/dist/obj-loader.cjs +5 -5
  88. package/dist/obj-loader.cjs.map +2 -2
  89. package/dist/obj-worker.js +568 -287
  90. package/dist/obj-writer.cjs +1 -1
  91. package/dist/stl/parse-stl.cjs +100 -0
  92. package/dist/stl/parse-stl.cjs.map +7 -0
  93. package/dist/stl/parse-stl.d.ts +4 -0
  94. package/dist/stl/parse-stl.d.ts.map +1 -0
  95. package/dist/stl/parse-stl.js +84 -0
  96. package/dist/stl/parse-stl.js.map +1 -0
  97. package/dist/stl-loader-types.cjs +58 -0
  98. package/dist/stl-loader-types.cjs.map +7 -0
  99. package/dist/stl-loader-types.d.ts +32 -0
  100. package/dist/stl-loader-types.d.ts.map +1 -0
  101. package/dist/stl-loader-types.js +25 -0
  102. package/dist/stl-loader-types.js.map +1 -0
  103. package/dist/stl-loader.cjs +38 -0
  104. package/dist/stl-loader.cjs.map +7 -0
  105. package/dist/stl-loader.d.ts +17 -0
  106. package/dist/stl-loader.d.ts.map +1 -0
  107. package/dist/stl-loader.js +13 -0
  108. package/dist/stl-loader.js.map +1 -0
  109. package/dist/usd/index.cjs.map +1 -1
  110. package/dist/usd/index.d.ts +1 -1
  111. package/dist/usd/index.d.ts.map +1 -1
  112. package/dist/usd/lib/parse-usd.cjs +42 -5
  113. package/dist/usd/lib/parse-usd.cjs.map +2 -2
  114. package/dist/usd/lib/parse-usd.d.ts.map +1 -1
  115. package/dist/usd/lib/parse-usd.js +53 -6
  116. package/dist/usd/lib/parse-usd.js.map +1 -1
  117. package/dist/usd/lib/parse-usdc.cjs +187 -0
  118. package/dist/usd/lib/parse-usdc.cjs.map +7 -0
  119. package/dist/usd/lib/parse-usdc.d.ts +4 -0
  120. package/dist/usd/lib/parse-usdc.d.ts.map +1 -0
  121. package/dist/usd/lib/parse-usdc.js +176 -0
  122. package/dist/usd/lib/parse-usdc.js.map +1 -0
  123. package/dist/usd/lib/parse-usdz.cjs +22 -0
  124. package/dist/usd/lib/parse-usdz.cjs.map +2 -2
  125. package/dist/usd/lib/parse-usdz.d.ts.map +1 -1
  126. package/dist/usd/lib/parse-usdz.js +26 -0
  127. package/dist/usd/lib/parse-usdz.js.map +1 -1
  128. package/dist/usd/lib/usd-types.cjs.map +1 -1
  129. package/dist/usd/lib/usd-types.d.ts +14 -1
  130. package/dist/usd/lib/usd-types.d.ts.map +1 -1
  131. package/dist/usd/lib/usd-types.js +1 -1
  132. package/dist/usd/lib/usd-types.js.map +1 -1
  133. package/dist/usd/libs/README.md +27 -0
  134. package/dist/usd/libs/THREE-LICENSE +21 -0
  135. package/dist/usd/libs/usdc-parser.d.ts +78 -0
  136. package/dist/usd/libs/usdc-parser.d.ts.map +1 -0
  137. package/dist/usd/libs/usdc-parser.js +1669 -0
  138. package/dist/usd/libs/usdc-parser.js.map +1 -0
  139. package/dist/usd/usd-loader-types.cjs +4 -4
  140. package/dist/usd/usd-loader-types.cjs.map +2 -2
  141. package/dist/usd/usd-loader-types.d.ts +7 -7
  142. package/dist/usd/usd-loader-types.d.ts.map +1 -1
  143. package/dist/usd/usd-loader-types.js +6 -6
  144. package/dist/usd/usd-loader-types.js.map +1 -1
  145. package/dist/usd/usd-loader.cjs.map +1 -1
  146. package/dist/usd/usd-loader.d.ts +4 -4
  147. package/dist/usd/usd-loader.d.ts.map +1 -1
  148. package/dist/usd/usd-loader.js +2 -2
  149. package/dist/usd/usd-loader.js.map +1 -1
  150. package/dist/usd-loader-types.cjs +4 -4
  151. package/dist/usd-loader-types.cjs.map +2 -2
  152. package/dist/usd-loader.cjs.map +1 -1
  153. package/package.json +14 -8
  154. package/src/draco/draco-loader-types.ts +1 -1
  155. package/src/gltf/lib/extensions/KHR_gaussian_splatting.ts +14 -4
  156. package/src/gltf/lib/parsers/parse-gltf.ts +2 -0
  157. package/src/gltf/lib/types/gltf-additional-extension-schemas.ts +32 -0
  158. package/src/gltf/lib/types/gltf-extension-schemas.ts +12 -0
  159. package/src/gltf/lib/types/gltf-json-schema.ts +2 -1
  160. package/src/gltf/lib/types/gltf-zod-schema.ts +2 -1
  161. package/src/index.ts +3 -1
  162. package/src/obj/obj-loader-types.ts +1 -1
  163. package/src/obj/obj-loader.ts +1 -1
  164. package/src/stl/parse-stl.ts +90 -0
  165. package/src/stl-loader-types.ts +28 -0
  166. package/src/stl-loader.ts +12 -0
  167. package/src/usd/index.ts +1 -0
  168. package/src/usd/lib/parse-usd.ts +68 -7
  169. package/src/usd/lib/parse-usdc.ts +188 -0
  170. package/src/usd/lib/parse-usdz.ts +28 -0
  171. package/src/usd/lib/usd-types.ts +16 -2
  172. package/src/usd/libs/README.md +27 -0
  173. package/src/usd/libs/THREE-LICENSE +21 -0
  174. package/src/usd/libs/usdc-parser.d.ts +18 -0
  175. package/src/usd/libs/usdc-parser.js +1669 -0
  176. package/src/usd/usd-loader-types.ts +5 -5
  177. package/src/usd/usd-loader.ts +2 -2
@@ -0,0 +1,176 @@
1
+ // SPDX-License-Identifier: MIT
2
+ // Copyright (c) vis.gl contributors
3
+ import { USDCParser } from '../libs/usdc-parser.js';
4
+ /** Decodes the supported binary crate subset into the same stage model as USDA. */
5
+ export function parseUSDC(data, url) {
6
+ if (data.byteLength < 88 || data.byteLength > 64 * 1024 * 1024)
7
+ throw new Error('USDC: invalid input size');
8
+ const bytes = new Uint8Array(data);
9
+ if (bytes[8] !== 0 || bytes[9] !== 8 || bytes[10] !== 0)
10
+ throw new Error('USDC: initial decoder requires crate version 0.8.0');
11
+ const reader = new DataView(data);
12
+ const table = reader.getBigUint64(16, true);
13
+ if (table > BigInt(data.byteLength - 8))
14
+ throw new Error('USDC: invalid section table');
15
+ const offset = Number(table), count = reader.getBigUint64(offset, true);
16
+ if (count > 16n || offset + 8 + Number(count) * 32 > data.byteLength)
17
+ throw new Error('USDC: invalid section table length');
18
+ const sectionNames = new Set();
19
+ for (let index = 0; index < Number(count); index++) {
20
+ const entry = offset + 8 + index * 32;
21
+ const nameBytes = bytes.subarray(entry, entry + 16);
22
+ const terminator = nameBytes.indexOf(0);
23
+ const name = new TextDecoder().decode(nameBytes.subarray(0, terminator < 0 ? nameBytes.length : terminator));
24
+ if (sectionNames.has(name))
25
+ throw new Error('USDC: duplicate section');
26
+ sectionNames.add(name);
27
+ const start = reader.getBigUint64(entry + 16, true), size = reader.getBigUint64(entry + 24, true);
28
+ if (start < 88n || start + size > BigInt(data.byteLength))
29
+ throw new Error('USDC: section out of bounds');
30
+ }
31
+ for (const name of ['TOKENS', 'STRINGS', 'FIELDS', 'FIELDSETS', 'PATHS', 'SPECS'])
32
+ if (!sectionNames.has(name))
33
+ throw new Error('USDC: missing required section');
34
+ const { specsByPath } = new USDCParser().parseData(data);
35
+ const prims = new Map();
36
+ for (const [path, specification] of Object.entries(specsByPath)) {
37
+ if (specification.specType === 7 && path === '/')
38
+ continue;
39
+ if (specification.specType === 1 || specification.specType === 8)
40
+ continue;
41
+ if (specification.specType !== 6 || !/^\/(?:[A-Za-z_][\w:]*\/)*[A-Za-z_][\w:]*$/.test(path))
42
+ throw new Error('USDC: unsupported prim specification');
43
+ const fields = specification.fields;
44
+ const specifier = fields.specifier ?? 0;
45
+ if (specifier !== 0 && specifier !== 1 && specifier !== 2)
46
+ throw new Error('USDC: invalid prim specifier');
47
+ const metadata = convertFields(fields, new Set(['specifier', 'typeName', 'primChildren', 'properties']));
48
+ prims.set(path, {
49
+ name: path.slice(path.lastIndexOf('/') + 1),
50
+ path,
51
+ sourceUrl: url,
52
+ type: String(fields.typeName || ''),
53
+ specifier: ['def', 'over', 'class'][specifier],
54
+ attributes: Object.create(null),
55
+ metadata,
56
+ variants: Object.create(null),
57
+ children: []
58
+ });
59
+ }
60
+ const roots = [];
61
+ for (const prim of prims.values()) {
62
+ const parentPath = prim.path.slice(0, prim.path.lastIndexOf('/'));
63
+ if (!parentPath)
64
+ roots.push(prim);
65
+ else {
66
+ const parent = prims.get(parentPath);
67
+ if (!parent)
68
+ throw new Error('USDC: missing parent prim');
69
+ parent.children.push(prim);
70
+ }
71
+ }
72
+ orderPrims(roots, specsByPath['/']?.fields.primChildren);
73
+ for (const prim of prims.values())
74
+ orderPrims(prim.children, specsByPath[prim.path]?.fields.primChildren);
75
+ for (const [path, specification] of Object.entries(specsByPath)) {
76
+ if (specification.specType !== 1 && specification.specType !== 8)
77
+ continue;
78
+ const separator = path.indexOf('.');
79
+ const prim = prims.get(path.slice(0, separator));
80
+ if (separator < 0 || !prim)
81
+ throw new Error('USDC: property has no owning prim');
82
+ const name = path.slice(separator + 1), fields = specification.fields;
83
+ const type = specification.specType === 8 ? 'rel' : String(fields.typeName || '');
84
+ const value = convertAttributeValue(specification.specType === 8 ? fields.targetPaths : fields.default, type);
85
+ const metadata = convertFields(fields, new Set(['typeName', 'default', 'targetPaths', 'timeSamples']));
86
+ if (fields.timeSamples !== undefined)
87
+ metadata.timeSamples = convertTimeSamples(fields.timeSamples, type);
88
+ prim.attributes[name] = {
89
+ name,
90
+ type,
91
+ value,
92
+ metadata
93
+ };
94
+ }
95
+ return {
96
+ format: 'usdc',
97
+ url,
98
+ metadata: convertFields(specsByPath['/']?.fields || {}, new Set(['primChildren'])),
99
+ rootPrims: roots,
100
+ layers: []
101
+ };
102
+ }
103
+ /** Converts raw field dictionaries while retaining authored values and time samples. */
104
+ function convertFields(fields, excluded) {
105
+ const result = Object.create(null);
106
+ for (const [name, value] of Object.entries(fields))
107
+ if (!excluded.has(name))
108
+ result[name] = convertValue(value);
109
+ return result;
110
+ }
111
+ /** Converts decoded typed arrays to the existing renderer-independent USD value contract. */
112
+ function convertValue(value) {
113
+ if (value === undefined || value === null)
114
+ return null;
115
+ if (typeof value === 'number' || typeof value === 'string' || typeof value === 'boolean')
116
+ return value;
117
+ if (Array.isArray(value))
118
+ return value.map(convertValue);
119
+ if (ArrayBuffer.isView(value) && !(value instanceof DataView))
120
+ return Array.from(value);
121
+ if (typeof value === 'object')
122
+ return convertFields(value, new Set());
123
+ throw new Error('USDC: unsupported decoded value');
124
+ }
125
+ /** Preserves USDA-compatible asset/path values and vector-array tuple boundaries. */
126
+ function convertAttributeValue(raw, type) {
127
+ const value = convertValue(raw);
128
+ if (type === 'asset' && typeof value === 'string')
129
+ return { assetPath: value };
130
+ if (type === 'rel' && Array.isArray(value))
131
+ return value.map(path => (typeof path === 'string' ? { path } : path));
132
+ const tuple = /^(?:(?:point|normal|vector|color|texCoord)([234])[fdh]|(?:float|double|half|int)([234]))\[\]$/.exec(type);
133
+ if (tuple && Array.isArray(value)) {
134
+ const components = Number(tuple[1] || tuple[2]);
135
+ if (value.length % components)
136
+ throw new Error('USDC: incomplete vector tuple');
137
+ const tuples = [];
138
+ for (let offset = 0; offset < value.length; offset += components)
139
+ tuples.push(value.slice(offset, offset + components));
140
+ return tuples;
141
+ }
142
+ return value;
143
+ }
144
+ /** Applies authored child-name order while retaining any other decoded specifications. */
145
+ function orderPrims(prims, names) {
146
+ if (names === undefined)
147
+ return;
148
+ if (!Array.isArray(names))
149
+ throw new Error('USDC: invalid primChildren order');
150
+ const remaining = new Map(prims.map(prim => [prim.name, prim]));
151
+ const ordered = [];
152
+ for (const name of names) {
153
+ const prim = typeof name === 'string' ? remaining.get(name) : undefined;
154
+ if (!prim)
155
+ throw new Error('USDC: invalid primChildren reference');
156
+ ordered.push(prim);
157
+ remaining.delete(name);
158
+ }
159
+ for (const prim of remaining.values())
160
+ ordered.push(prim);
161
+ for (let index = 0; index < ordered.length; index++)
162
+ prims[index] = ordered[index];
163
+ }
164
+ /** Converts every authored sample through the same type-aware path as an attribute default. */
165
+ function convertTimeSamples(raw, type) {
166
+ if (!raw || typeof raw !== 'object')
167
+ throw new Error('USDC: invalid time samples');
168
+ const samples = raw;
169
+ const times = convertValue(samples.times);
170
+ if (!Array.isArray(times) ||
171
+ !Array.isArray(samples.values) ||
172
+ times.length !== samples.values.length)
173
+ throw new Error('USDC: invalid time samples');
174
+ return { times, values: samples.values.map(value => convertAttributeValue(value, type)) };
175
+ }
176
+ //# sourceMappingURL=parse-usdc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-usdc.js","sourceRoot":"","sources":["../../../src/usd/lib/parse-usdc.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,oCAAoC;AACpC,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAGlD,mFAAmF;AACnF,MAAM,UAAU,SAAS,CAAC,IAAiB,EAAE,GAAY;IACvD,IAAI,IAAI,CAAC,UAAU,GAAG,EAAE,IAAI,IAAI,CAAC,UAAU,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI;QAC5D,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,C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AI,CAAC,CAAC;QACnB,SAAS,CAAC,MAAM,CAAC,IAAc,CAAC,CAAC;IACnC,CAAC;IACD,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,MAAM,EAAE;QAAE,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC1D,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE;QAAE,KAAK,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AACrF,CAAC;AAED,+FAA+F;AAC/F,SAAS,kBAAkB,CAAC,GAAY,EAAE,IAAY;IACpD,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IACnF,MAAM,OAAO,GAAG,GAKf,CAAC;IACF,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1C,IACE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QACrB,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC;QAC9B,KAAK,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,MAAM;QAEtC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAChD,OAAO,EAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,EAAC,CAAC;AAC1F,CAAC"}
@@ -31,30 +31,52 @@ function parseUSDZArchive(arrayBuffer) {
31
31
  const directoryOffset = findCentralDirectory(view);
32
32
  const entryCount = view.getUint16(directoryOffset + 10, true);
33
33
  let entryOffset = view.getUint32(directoryOffset + 16, true);
34
+ const dataLimit = entryOffset;
34
35
  const files = /* @__PURE__ */ new Map();
35
36
  const textDecoder = new TextDecoder();
37
+ let extractedByteLength = 0;
36
38
  for (let entryIndex = 0; entryIndex < entryCount; entryIndex++) {
39
+ if (entryOffset + 46 > directoryOffset) {
40
+ throw new Error("USDZ archive contains a truncated ZIP central-directory entry.");
41
+ }
37
42
  if (view.getUint32(entryOffset, true) !== CENTRAL_DIRECTORY_ENTRY) {
38
43
  throw new Error("USDZ archive contains an invalid ZIP central-directory entry.");
39
44
  }
40
45
  const compression = view.getUint16(entryOffset + 10, true);
41
46
  const compressedLength = view.getUint32(entryOffset + 20, true);
47
+ const uncompressedLength = view.getUint32(entryOffset + 24, true);
42
48
  const filenameLength = view.getUint16(entryOffset + 28, true);
43
49
  const extraLength = view.getUint16(entryOffset + 30, true);
44
50
  const commentLength = view.getUint16(entryOffset + 32, true);
45
51
  const localOffset = view.getUint32(entryOffset + 42, true);
52
+ if (entryOffset + 46 + filenameLength + extraLength + commentLength > directoryOffset) {
53
+ throw new Error("USDZ archive contains a truncated ZIP filename or extra field.");
54
+ }
46
55
  const filename = textDecoder.decode(
47
56
  new Uint8Array(arrayBuffer, entryOffset + 46, filenameLength)
48
57
  );
49
58
  if (compression !== 0) {
50
59
  throw new Error(`USDZ entry "${filename}" is compressed; USDZ requires stored ZIP entries.`);
51
60
  }
61
+ if (localOffset + 30 > dataLimit || compressedLength !== uncompressedLength) {
62
+ throw new Error(`USDZ entry "${filename}" has invalid stored ZIP bounds.`);
63
+ }
52
64
  if (view.getUint32(localOffset, true) !== LOCAL_FILE_HEADER) {
53
65
  throw new Error(`USDZ entry "${filename}" has an invalid local ZIP header.`);
54
66
  }
55
67
  const localNameLength = view.getUint16(localOffset + 26, true);
56
68
  const localExtraLength = view.getUint16(localOffset + 28, true);
57
69
  const contentOffset = localOffset + 30 + localNameLength + localExtraLength;
70
+ if ((view.getUint16(entryOffset + 8, true) | view.getUint16(localOffset + 6, true)) & 1) {
71
+ throw new Error(`USDZ entry "${filename}" is encrypted.`);
72
+ }
73
+ if (contentOffset + compressedLength > dataLimit || view.getUint16(localOffset + 8, true) !== 0 || textDecoder.decode(new Uint8Array(arrayBuffer, localOffset + 30, localNameLength)) !== filename || files.has(filename)) {
74
+ throw new Error(`USDZ entry "${filename}" has invalid or duplicate stored ZIP data.`);
75
+ }
76
+ extractedByteLength += compressedLength;
77
+ if (extractedByteLength > arrayBuffer.byteLength) {
78
+ throw new Error("USDZ archive exceeds its stored data budget.");
79
+ }
58
80
  files.set(filename, arrayBuffer.slice(contentOffset, contentOffset + compressedLength));
59
81
  entryOffset += 46 + filenameLength + extraLength + commentLength;
60
82
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/usd/lib/parse-usdz.ts"],
4
- "sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nconst END_OF_CENTRAL_DIRECTORY = 0x06054b50;\nconst CENTRAL_DIRECTORY_ENTRY = 0x02014b50;\nconst LOCAL_FILE_HEADER = 0x04034b50;\n\n/** Extracts stored files from an uncompressed USDZ ZIP archive. */\nexport function parseUSDZArchive(arrayBuffer: ArrayBuffer): Map<string, ArrayBuffer> {\n const view = new DataView(arrayBuffer);\n const directoryOffset = findCentralDirectory(view);\n const entryCount = view.getUint16(directoryOffset + 10, true);\n let entryOffset = view.getUint32(directoryOffset + 16, true);\n const files = new Map<string, ArrayBuffer>();\n const textDecoder = new TextDecoder();\n\n for (let entryIndex = 0; entryIndex < entryCount; entryIndex++) {\n if (view.getUint32(entryOffset, true) !== CENTRAL_DIRECTORY_ENTRY) {\n throw new Error('USDZ archive contains an invalid ZIP central-directory entry.');\n }\n\n const compression = view.getUint16(entryOffset + 10, true);\n const compressedLength = view.getUint32(entryOffset + 20, true);\n const filenameLength = view.getUint16(entryOffset + 28, true);\n const extraLength = view.getUint16(entryOffset + 30, true);\n const commentLength = view.getUint16(entryOffset + 32, true);\n const localOffset = view.getUint32(entryOffset + 42, true);\n const filename = textDecoder.decode(\n new Uint8Array(arrayBuffer, entryOffset + 46, filenameLength)\n );\n\n if (compression !== 0) {\n throw new Error(`USDZ entry \"${filename}\" is compressed; USDZ requires stored ZIP entries.`);\n }\n if (view.getUint32(localOffset, true) !== LOCAL_FILE_HEADER) {\n throw new Error(`USDZ entry \"${filename}\" has an invalid local ZIP header.`);\n }\n\n const localNameLength = view.getUint16(localOffset + 26, true);\n const localExtraLength = view.getUint16(localOffset + 28, true);\n const contentOffset = localOffset + 30 + localNameLength + localExtraLength;\n files.set(filename, arrayBuffer.slice(contentOffset, contentOffset + compressedLength));\n entryOffset += 46 + filenameLength + extraLength + commentLength;\n }\n\n return files;\n}\n\n/** Finds the ZIP end-of-central-directory record. */\nfunction findCentralDirectory(view: DataView): number {\n const minimumOffset = Math.max(0, view.byteLength - 65557);\n for (let offset = view.byteLength - 22; offset >= minimumOffset; offset--) {\n if (view.getUint32(offset, true) === END_OF_CENTRAL_DIRECTORY) {\n return offset;\n }\n }\n throw new Error('USDZ archive does not contain a ZIP end-of-central-directory record.');\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,IAAM,2BAA2B;AACjC,IAAM,0BAA0B;AAChC,IAAM,oBAAoB;AAGnB,SAAS,iBAAiB,aAAoD;AACnF,QAAM,OAAO,IAAI,SAAS,WAAW;AACrC,QAAM,kBAAkB,qBAAqB,IAAI;AACjD,QAAM,aAAa,KAAK,UAAU,kBAAkB,IAAI,IAAI;AAC5D,MAAI,cAAc,KAAK,UAAU,kBAAkB,IAAI,IAAI;AAC3D,QAAM,QAAQ,oBAAI,IAAyB;AAC3C,QAAM,cAAc,IAAI,YAAY;AAEpC,WAAS,aAAa,GAAG,aAAa,YAAY,cAAc;AAC9D,QAAI,KAAK,UAAU,aAAa,IAAI,MAAM,yBAAyB;AACjE,YAAM,IAAI,MAAM,+DAA+D;AAAA,IACjF;AAEA,UAAM,cAAc,KAAK,UAAU,cAAc,IAAI,IAAI;AACzD,UAAM,mBAAmB,KA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\n/** Extracts stored files from an uncompressed USDZ ZIP archive. */\nexport function parseUSDZArchive(arrayBuffer: ArrayBuffer): Map<string, ArrayBuffer> {\n const view = new DataView(arrayBuffer);\n const directoryOffset = findCentralDirectory(view);\n const entryCount = view.getUint16(directoryOffset + 10, true);\n let entryOffset = view.getUint32(directoryOffset + 16, true);\n const dataLimit = entryOffset;\n const files = new Map<string, ArrayBuffer>();\n const textDecoder = new TextDecoder();\n let extractedByteLength = 0;\n\n for (let entryIndex = 0; entryIndex < entryCount; entryIndex++) {\n if (entryOffset + 46 > directoryOffset) {\n throw new Error('USDZ archive contains a truncated ZIP central-directory entry.');\n }\n if (view.getUint32(entryOffset, true) !== CENTRAL_DIRECTORY_ENTRY) {\n throw new Error('USDZ archive contains an invalid ZIP central-directory entry.');\n }\n\n const compression = view.getUint16(entryOffset + 10, true);\n const compressedLength = view.getUint32(entryOffset + 20, true);\n const uncompressedLength = view.getUint32(entryOffset + 24, true);\n const filenameLength = view.getUint16(entryOffset + 28, true);\n const extraLength = view.getUint16(entryOffset + 30, true);\n const commentLength = view.getUint16(entryOffset + 32, true);\n const localOffset = view.getUint32(entryOffset + 42, true);\n if (entryOffset + 46 + filenameLength + extraLength + commentLength > directoryOffset) {\n throw new Error('USDZ archive contains a truncated ZIP filename or extra field.');\n }\n const filename = textDecoder.decode(\n new Uint8Array(arrayBuffer, entryOffset + 46, filenameLength)\n );\n\n if (compression !== 0) {\n throw new Error(`USDZ entry \"${filename}\" is compressed; USDZ requires stored ZIP entries.`);\n }\n if (localOffset + 30 > dataLimit || compressedLength !== uncompressedLength) {\n throw new Error(`USDZ entry \"${filename}\" has invalid stored ZIP bounds.`);\n }\n if (view.getUint32(localOffset, true) !== LOCAL_FILE_HEADER) {\n throw new Error(`USDZ entry \"${filename}\" has an invalid local ZIP header.`);\n }\n\n const localNameLength = view.getUint16(localOffset + 26, true);\n const localExtraLength = view.getUint16(localOffset + 28, true);\n const contentOffset = localOffset + 30 + localNameLength + localExtraLength;\n if ((view.getUint16(entryOffset + 8, true) | view.getUint16(localOffset + 6, true)) & 1) {\n throw new Error(`USDZ entry \"${filename}\" is encrypted.`);\n }\n if (\n contentOffset + compressedLength > dataLimit ||\n view.getUint16(localOffset + 8, true) !== 0 ||\n textDecoder.decode(new Uint8Array(arrayBuffer, localOffset + 30, localNameLength)) !==\n filename ||\n files.has(filename)\n ) {\n throw new Error(`USDZ entry \"${filename}\" has invalid or duplicate stored ZIP data.`);\n }\n extractedByteLength += compressedLength;\n if (extractedByteLength > arrayBuffer.byteLength) {\n throw new Error('USDZ archive exceeds its stored data budget.');\n }\n files.set(filename, arrayBuffer.slice(contentOffset, contentOffset + compressedLength));\n entryOffset += 46 + filenameLength + extraLength + commentLength;\n }\n\n return files;\n}\n\n/** Finds the ZIP end-of-central-directory record. */\nfunction findCentralDirectory(view: DataView): number {\n const minimumOffset = Math.max(0, view.byteLength - 65557);\n for (let offset = view.byteLength - 22; offset >= minimumOffset; offset--) {\n if (view.getUint32(offset, true) === END_OF_CENTRAL_DIRECTORY) {\n return offset;\n }\n }\n throw new Error('USDZ archive does not contain a ZIP end-of-central-directory record.');\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,IAAM,2BAA2B;AACjC,IAAM,0BAA0B;AAChC,IAAM,oBAAoB;AAGnB,SAAS,iBAAiB,aAAoD;AACnF,QAAM,OAAO,IAAI,SAAS,WAAW;AACrC,QAAM,kBAAkB,qBAAqB,IAAI;AACjD,QAAM,aAAa,KAAK,UAAU,kBAAkB,IAAI,IAAI;AAC5D,MAAI,cAAc,KAAK,UAAU,kBAAkB,IAAI,IAAI;AAC3D,QAAM,YAAY;AAClB,QAAM,QAAQ,oBAAI,IAAyB;AAC3C,QAAM,cAAc,IAAI,YAAY;AACpC,MAAI,sBAAsB;AAE1B,WAAS,aAAa,GAAG,aAAa,YAAY,cAAc;AAC9D,QAAI,cAAc,KAAK,iBAAiB;AACtC,YAAM,I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,iBAAiB;AAAA,IAC1D;AACA,QACE,gBAAgB,mBAAmB,aACnC,KAAK,UAAU,cAAc,GAAG,IAAI,MAAM,KAC1C,YAAY,OAAO,IAAI,WAAW,aAAa,cAAc,IAAI,eAAe,CAAC,MAC/E,YACF,MAAM,IAAI,QAAQ,GAClB;AACA,YAAM,IAAI,MAAM,eAAe,QAAQ,6CAA6C;AAAA,IACtF;AACA,2BAAuB;AACvB,QAAI,sBAAsB,YAAY,YAAY;AAChD,YAAM,IAAI,MAAM,8CAA8C;AAAA,IAChE;AACA,UAAM,IAAI,UAAU,YAAY,MAAM,eAAe,gBAAgB,gBAAgB,CAAC;AACtF,mBAAe,KAAK,iBAAiB,cAAc;AAAA,EACrD;AAEA,SAAO;AACT;AAGA,SAAS,qBAAqB,MAAwB;AACpD,QAAM,gBAAgB,KAAK,IAAI,GAAG,KAAK,aAAa,KAAK;AACzD,WAAS,SAAS,KAAK,aAAa,IAAI,UAAU,eAAe,UAAU;AACzE,QAAI,KAAK,UAAU,QAAQ,IAAI,MAAM,0BAA0B;AAC7D,aAAO;AAAA,IACT;AAAA,EACF;AACA,QAAM,IAAI,MAAM,sEAAsE;AACxF;",
6
6
  "names": []
7
7
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parse-usdz.d.ts","sourceRoot":"","sources":["../../../src/usd/lib/parse-usdz.ts"],"names":[],"mappings":"AAQA,mEAAmE;AACnE,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAsCnF"}
1
+ {"version":3,"file":"parse-usdz.d.ts","sourceRoot":"","sources":["../../../src/usd/lib/parse-usdz.ts"],"names":[],"mappings":"AAQA,mEAAmE;AACnE,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,WAAW,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAkEnF"}
@@ -10,28 +10,54 @@ export function parseUSDZArchive(arrayBuffer) {
10
10
  const directoryOffset = findCentralDirectory(view);
11
11
  const entryCount = view.getUint16(directoryOffset + 10, true);
12
12
  let entryOffset = view.getUint32(directoryOffset + 16, true);
13
+ const dataLimit = entryOffset;
13
14
  const files = new Map();
14
15
  const textDecoder = new TextDecoder();
16
+ let extractedByteLength = 0;
15
17
  for (let entryIndex = 0; entryIndex < entryCount; entryIndex++) {
18
+ if (entryOffset + 46 > directoryOffset) {
19
+ throw new Error('USDZ archive contains a truncated ZIP central-directory entry.');
20
+ }
16
21
  if (view.getUint32(entryOffset, true) !== CENTRAL_DIRECTORY_ENTRY) {
17
22
  throw new Error('USDZ archive contains an invalid ZIP central-directory entry.');
18
23
  }
19
24
  const compression = view.getUint16(entryOffset + 10, true);
20
25
  const compressedLength = view.getUint32(entryOffset + 20, true);
26
+ const uncompressedLength = view.getUint32(entryOffset + 24, true);
21
27
  const filenameLength = view.getUint16(entryOffset + 28, true);
22
28
  const extraLength = view.getUint16(entryOffset + 30, true);
23
29
  const commentLength = view.getUint16(entryOffset + 32, true);
24
30
  const localOffset = view.getUint32(entryOffset + 42, true);
31
+ if (entryOffset + 46 + filenameLength + extraLength + commentLength > directoryOffset) {
32
+ throw new Error('USDZ archive contains a truncated ZIP filename or extra field.');
33
+ }
25
34
  const filename = textDecoder.decode(new Uint8Array(arrayBuffer, entryOffset + 46, filenameLength));
26
35
  if (compression !== 0) {
27
36
  throw new Error(`USDZ entry "${filename}" is compressed; USDZ requires stored ZIP entries.`);
28
37
  }
38
+ if (localOffset + 30 > dataLimit || compressedLength !== uncompressedLength) {
39
+ throw new Error(`USDZ entry "${filename}" has invalid stored ZIP bounds.`);
40
+ }
29
41
  if (view.getUint32(localOffset, true) !== LOCAL_FILE_HEADER) {
30
42
  throw new Error(`USDZ entry "${filename}" has an invalid local ZIP header.`);
31
43
  }
32
44
  const localNameLength = view.getUint16(localOffset + 26, true);
33
45
  const localExtraLength = view.getUint16(localOffset + 28, true);
34
46
  const contentOffset = localOffset + 30 + localNameLength + localExtraLength;
47
+ if ((view.getUint16(entryOffset + 8, true) | view.getUint16(localOffset + 6, true)) & 1) {
48
+ throw new Error(`USDZ entry "${filename}" is encrypted.`);
49
+ }
50
+ if (contentOffset + compressedLength > dataLimit ||
51
+ view.getUint16(localOffset + 8, true) !== 0 ||
52
+ textDecoder.decode(new Uint8Array(arrayBuffer, localOffset + 30, localNameLength)) !==
53
+ filename ||
54
+ files.has(filename)) {
55
+ throw new Error(`USDZ entry "${filename}" has invalid or duplicate stored ZIP data.`);
56
+ }
57
+ extractedByteLength += compressedLength;
58
+ if (extractedByteLength > arrayBuffer.byteLength) {
59
+ throw new Error('USDZ archive exceeds its stored data budget.');
60
+ }
35
61
  files.set(filename, arrayBuffer.slice(contentOffset, contentOffset + compressedLength));
36
62
  entryOffset += 46 + filenameLength + extraLength + commentLength;
37
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"parse-usdz.js","sourceRoot":"","sources":["../../../src/usd/lib/parse-usdz.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC;AAEpC,MAAM,wBAAwB,GAAG,UAAU,CAAC;AAC5C,MAAM,uBAAuB,GAAG,UAAU,CAAC;AAC3C,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAErC,mEAAmE;AACnE,MAAM,UAAU,gBAAgB,CAAC,WAAwB;IACvD,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,WAAW,CAAC,CAAC;IACvC,MAAM,eAAe,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC;IACnD,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;IAC9D,IAAI,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,eAAe,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;IAC7D,MAAM,KAAK,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC7C,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;IAEtC,KAAK,IAAI,UAAU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AI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,wBAAwB,EAAE,CAAC;YAC9D,OAAO,MAAM,CAAC;QAChB,CAAC;IACH,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;AAC1F,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/usd/lib/usd-types.ts"],
4
- "sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n\nimport type {LoaderOptions} from '@loaders.gl/core/loader-utils';\n\n/** Reference to an external OpenUSD layer and optional prim within that layer. */\nexport type USDAssetPath = {\n /** URL or relative path to the referenced layer. */\n assetPath: string;\n /** Optional prim path within the referenced layer. */\n primPath?: string;\n};\n\n/** Reference to a prim in an OpenUSD scene. */\nexport type USDScenePath = {\n /** Absolute or relative scene path. */\n path: string;\n};\n\n/** Value types represented by the OpenUSD ASCII parser. */\nexport type USDValue =\n | string\n | number\n | boolean\n | null\n | USDAssetPath\n | USDScenePath\n | USDValue[]\n | {[name: string]: USDValue};\n\n/** Parsed OpenUSD attribute declaration. */\nexport type USDAttribute = {\n /** Attribute name. */\n name: string;\n /** Authored OpenUSD type name. */\n type: string;\n /** Parsed attribute value. */\n value: USDValue;\n /** Attribute metadata. */\n metadata: Record<string, USDValue>;\n};\n\n/** Opinions authored by one variant. */\nexport type USDVariant = {\n /** Variant attributes. */\n attributes: Record<string, USDAttribute>;\n /** Variant metadata. */\n metadata: Record<string, USDValue>;\n /** Child prims introduced or overridden by the variant. */\n children: USDPrim[];\n};\n\n/** Parsed and optionally composed OpenUSD prim. */\nexport type USDPrim = {\n /** Prim name. */\n name: string;\n /** Absolute prim path. */\n path: string;\n /** URL of the layer that authored the prim. */\n sourceUrl?: string;\n /** Authored prim type, such as `Xform` or `Mesh`. */\n type: string;\n /** Prim specifier. */\n specifier: 'def' | 'over' | 'class';\n /** Authored attributes keyed by name. */\n attributes: Record<string, USDAttribute>;\n /** Prim metadata keyed by name. */\n metadata: Record<string, USDValue>;\n /** Variant sets keyed by set name and variant name. */\n variants: Record<string, Record<string, USDVariant>>;\n /** Child prims. */\n children: USDPrim[];\n};\n\n/** Parsed OpenUSD stage. */\nexport type USDStage = {\n /** Container format used for the root layer. */\n format: 'usda' | 'usdz';\n /** URL of the root layer when available. */\n url?: string;\n /** Root-layer metadata. */\n metadata: Record<string, USDValue>;\n /** Root prims in scene order. */\n rootPrims: USDPrim[];\n /** URLs of all layers used to compose the stage. */\n layers: string[];\n};\n\n/** Options for {@link USDLoader}. */\nexport type USDLoaderOptions = LoaderOptions & {\n /** OpenUSD-specific parser and composition options. */\n usd?: {\n /** Compose references and variants into the returned prim hierarchy. */\n compose?: boolean;\n /** Load referenced layers while composing the stage. */\n loadReferences?: boolean;\n /** Maximum recursive composition depth. */\n maxReferenceDepth?: number;\n /** Variant selections that override authored selections. */\n variantSelections?: Record<string, string>;\n };\n};\n"],
4
+ "sourcesContent": ["// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// loaders.gl\n\nimport type {LoaderOptions} from '@loaders.gl/core/loader-utils';\n\n/** Reference to an external OpenUSD layer and optional prim within that layer. */\nexport type USDAssetPath = {\n /** URL or relative path to the referenced layer. */\n assetPath: string;\n /** Optional prim path within the referenced layer. */\n primPath?: string;\n};\n\n/** Reference to a prim in an OpenUSD scene. */\nexport type USDScenePath = {\n /** Absolute or relative scene path. */\n path: string;\n};\n\n/** Value types represented by the OpenUSD ASCII parser. */\nexport type USDValue =\n | string\n | number\n | boolean\n | null\n | USDAssetPath\n | USDScenePath\n | USDValue[]\n | {[name: string]: USDValue};\n\n/** Parsed OpenUSD attribute declaration. */\nexport type USDAttribute = {\n /** URL of the layer that authored this attribute, retained through composition. */\n sourceUrl?: string;\n /** Attribute name. */\n name: string;\n /** Authored OpenUSD type name. */\n type: string;\n /** Parsed attribute value. */\n value: USDValue;\n /** Attribute metadata. */\n metadata: Record<string, USDValue>;\n};\n\n/** Opinions authored by one variant. */\nexport type USDVariant = {\n /** Variant attributes. */\n attributes: Record<string, USDAttribute>;\n /** Variant metadata. */\n metadata: Record<string, USDValue>;\n /** Child prims introduced or overridden by the variant. */\n children: USDPrim[];\n};\n\n/** Parsed and optionally composed OpenUSD prim. */\nexport type USDPrim = {\n /** Prim name. */\n name: string;\n /** Absolute prim path. */\n path: string;\n /** URL of the layer that authored the prim. */\n sourceUrl?: string;\n /** Authored prim type, such as `Xform` or `Mesh`. */\n type: string;\n /** Prim specifier. */\n specifier: 'def' | 'over' | 'class';\n /** Authored attributes keyed by name. */\n attributes: Record<string, USDAttribute>;\n /** Prim metadata keyed by name. */\n metadata: Record<string, USDValue>;\n /** Variant sets keyed by set name and variant name. */\n variants: Record<string, Record<string, USDVariant>>;\n /** Child prims. */\n children: USDPrim[];\n};\n\n/** Encoded file extracted from a USDZ package, without image decoding or renderer objects. */\nexport type USDEmbeddedAsset = {\n /** Original archive-relative filename, including its directories. */\n readonly path: string;\n /** Exact stored bytes, owned by the returned stage rather than the input archive. */\n readonly data: ArrayBuffer;\n /** MIME type hint inferred from a PNG or JPEG filename; other formats omit this field. */\n readonly mimeType?: string;\n};\n\n/** Parsed OpenUSD stage. */\nexport type USDStage = {\n /** Container format used for the root layer. */\n format: 'usda' | 'usdc' | 'usdz';\n /** URL of the root layer when available. */\n url?: string;\n /** Root-layer metadata. */\n metadata: Record<string, USDValue>;\n /** Root prims in scene order. */\n rootPrims: USDPrim[];\n /** URLs of all layers used to compose the stage. */\n layers: string[];\n /** USDZ files keyed by resolved package URL; absent for standalone layers. Includes layers and textures. */\n assets?: Record<string, USDEmbeddedAsset>;\n};\n\n/** Options for {@link USDLoader}. */\nexport type USDLoaderOptions = LoaderOptions & {\n /** OpenUSD-specific parser and composition options. */\n usd?: {\n /** Compose references and variants into the returned prim hierarchy. */\n compose?: boolean;\n /** Load referenced layers while composing the stage. */\n loadReferences?: boolean;\n /** Maximum recursive composition depth. */\n maxReferenceDepth?: number;\n /** Variant selections that override authored selections. */\n variantSelections?: Record<string, string>;\n };\n};\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;",
6
6
  "names": []
7
7
  }
@@ -17,6 +17,8 @@ export type USDValue = string | number | boolean | null | USDAssetPath | USDScen
17
17
  };
18
18
  /** Parsed OpenUSD attribute declaration. */
19
19
  export type USDAttribute = {
20
+ /** URL of the layer that authored this attribute, retained through composition. */
21
+ sourceUrl?: string;
20
22
  /** Attribute name. */
21
23
  name: string;
22
24
  /** Authored OpenUSD type name. */
@@ -56,10 +58,19 @@ export type USDPrim = {
56
58
  /** Child prims. */
57
59
  children: USDPrim[];
58
60
  };
61
+ /** Encoded file extracted from a USDZ package, without image decoding or renderer objects. */
62
+ export type USDEmbeddedAsset = {
63
+ /** Original archive-relative filename, including its directories. */
64
+ readonly path: string;
65
+ /** Exact stored bytes, owned by the returned stage rather than the input archive. */
66
+ readonly data: ArrayBuffer;
67
+ /** MIME type hint inferred from a PNG or JPEG filename; other formats omit this field. */
68
+ readonly mimeType?: string;
69
+ };
59
70
  /** Parsed OpenUSD stage. */
60
71
  export type USDStage = {
61
72
  /** Container format used for the root layer. */
62
- format: 'usda' | 'usdz';
73
+ format: 'usda' | 'usdc' | 'usdz';
63
74
  /** URL of the root layer when available. */
64
75
  url?: string;
65
76
  /** Root-layer metadata. */
@@ -68,6 +79,8 @@ export type USDStage = {
68
79
  rootPrims: USDPrim[];
69
80
  /** URLs of all layers used to compose the stage. */
70
81
  layers: string[];
82
+ /** USDZ files keyed by resolved package URL; absent for standalone layers. Includes layers and textures. */
83
+ assets?: Record<string, USDEmbeddedAsset>;
71
84
  };
72
85
  /** Options for {@link USDLoader}. */
73
86
  export type USDLoaderOptions = LoaderOptions & {
@@ -1 +1 @@
1
- {"version":3,"file":"usd-types.d.ts","sourceRoot":"","sources":["../../../src/usd/lib/usd-types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,aAAa,EAAC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,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,wDAAwD;QACxD,cAAc,CAAC,EAAE,OAAO,CAAC;QACzB,2CAA2C;QAC3C,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,4DAA4D;QAC5D,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC5C,CAAC;CACH,CAAC"}
@@ -1,5 +1,5 @@
1
- // loaders.gl
2
1
  // SPDX-License-Identifier: MIT
3
2
  // Copyright (c) vis.gl contributors
3
+ // loaders.gl
4
4
  export {};
5
5
  //# sourceMappingURL=usd-types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usd-types.js","sourceRoot":"","sources":["../../../src/usd/lib/usd-types.ts"],"names":[],"mappings":"AAAA,aAAa;AACb,+BAA+B;AAC/B,oCAAoC"}
1
+ {"version":3,"file":"usd-types.js","sourceRoot":"","sources":["../../../src/usd/lib/usd-types.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,oCAAoC;AACpC,aAAa"}
@@ -0,0 +1,27 @@
1
+ # USDC decoder source
2
+
3
+ `usdc-parser.js` is adapted from THREE.js r187, commit/tag r187:
4
+ https://github.com/mrdoob/three.js/blob/r187/examples/jsm/loaders/usd/USDCParser.js
5
+
6
+ Copyright © 2010–2026 three.js authors; MIT terms are in THREE-LICENSE.
7
+ This renderer-free source has no imports or package dependencies. It remains
8
+ vendored JavaScript; the adjacent declaration and handwritten parse-usdc.ts
9
+ adapter define the checked TypeScript boundary. Existing libs build/coverage
10
+ policy applies to this vendored decoder; adapter code remains fully instrumented.
11
+
12
+ Local changes bound aggregate allocations, integer precision and seek offsets,
13
+ support bounded dictionary values and reject unsupported list operations/encoding cases, validate LZ4
14
+ copies, use null-prototype dictionaries and correct signed inline integers.
15
+ The adapter restricts crate versions, validates section bounds, and converts the
16
+ supported specifications into USDStage. Broader upstream behavior is not promised.
17
+
18
+ Dictionary decoding uses string-table keys and forward offsets to complete value
19
+ representations, retaining false, empty strings, empty dictionaries and asset paths.
20
+ It rejects duplicate/invalid keys, cycles, nesting beyond 64, and unsupported
21
+ complex dictionary value types. These checks extend the r187 source while
22
+ preserving its MIT attribution; no THREE runtime is imported.
23
+
24
+ The authored-value extension decodes inline half and signed/unsigned 64-bit scalars,
25
+ string arrays, and compressed half/double arrays. Dictionary array support is an
26
+ explicit allowlist; unsupported representations fail before payload decoding.
27
+ Half integer compression uses ties-to-even rounding, and lookup indices are checked.
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright © 2010-2026 three.js authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,78 @@
1
+ export class USDCParser {
2
+ /**
3
+ * Parse USDC file and return raw spec data without building Three.js scene.
4
+ * Used by USDComposer for unified scene composition.
5
+ */
6
+ parseData(buffer: any): {
7
+ specsByPath: any;
8
+ };
9
+ _valueReadCount: any;
10
+ _activeDictionaries: Set<any> | undefined;
11
+ buffer: any;
12
+ reader: BinaryReader | undefined;
13
+ version: {
14
+ major: number;
15
+ minor: number;
16
+ patch: number;
17
+ } | undefined;
18
+ _conversionBuffer: ArrayBuffer | undefined;
19
+ _conversionView: DataView<ArrayBuffer> | undefined;
20
+ specsByPath: any;
21
+ _readBootstrap(): void;
22
+ tocOffset: number | undefined;
23
+ _readTOC(): void;
24
+ sections: any;
25
+ _readTokens(): void;
26
+ tokens: any[] | undefined;
27
+ _readStrings(): void;
28
+ strings: any[] | undefined;
29
+ _readFields(): void;
30
+ fields: any[] | undefined;
31
+ _readFieldSets(): void;
32
+ fieldSets: any[] | undefined;
33
+ _readPaths(): void;
34
+ paths: any[] | undefined;
35
+ _readPathsRecursive(parentPath: any, depth?: number): void;
36
+ /** Rebuilds compressed paths with an explicit stack instead of sibling recursion. */
37
+ _buildPathsFromCompressed(pathIndices: any, elementTokenIndices: any, jumps: any): void;
38
+ _readSpecs(): void;
39
+ specs: any[] | undefined;
40
+ _readValue(valueRep: any): any;
41
+ _readInlinedValue(valueRep: any): any;
42
+ _readTimeSamples(valueRep: any): {
43
+ times: any;
44
+ values: any[];
45
+ };
46
+ _readScalarValue(type: any): any;
47
+ /** Reads bounded string-keyed dictionary entries and their recursive value representations. */
48
+ _readDictionary(): any;
49
+ _readArrayValue(valueRep: any): string[] | Int32Array<any> | Uint32Array<any> | Float32Array<any> | Float64Array<any>;
50
+ _readCompressedArray(type: any, size: any): Int32Array<any> | Uint32Array<any> | Float32Array<any> | Float64Array<any>;
51
+ /** Rounds integer-compressed half samples using IEEE ties-to-even semantics. */
52
+ _convertHalfInteger(value: any): any;
53
+ _readHalf(): number;
54
+ _halfToFloat(h: any): number;
55
+ _getFieldsForSpec(spec: any): any;
56
+ }
57
+ declare class BinaryReader {
58
+ constructor(buffer: any);
59
+ buffer: any;
60
+ view: DataView<any>;
61
+ offset: number;
62
+ seek(offset: any): void;
63
+ tell(): number;
64
+ readUint8(): number;
65
+ readInt8(): number;
66
+ readUint16(): number;
67
+ readInt16(): number;
68
+ readUint32(): number;
69
+ readInt32(): number;
70
+ readUint64(): number;
71
+ readInt64(): number;
72
+ readFloat32(): number;
73
+ readFloat64(): number;
74
+ readBytes(length: any): Uint8Array<any>;
75
+ readString(length: any): string;
76
+ }
77
+ export {};
78
+ //# sourceMappingURL=usdc-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usdc-parser.d.ts","sourceRoot":"","sources":["../../../src/usd/libs/usdc-parser.js"],"names":[],"mappings":"AAmdA;IACE;;;OAGG;IACH;;MAiCC;IA/BC,qBAAwB;IACxB,0CAAoC;IAEpC,YAAoE;IACpE,iCAA2C;IAC3C;;;;kBAA6C;IAE7C,2CAA2C;IAC3C,mDAA2D;IAY3D,iBAAsC;IAaxC,uBAqBC;IAJC,8BAAoC;IAMtC,iBAgBC;IATC,cAAmC;IAWrC,oBA2CC;IAnCC,0BAAgB;IAqClB,qBAgBC;IAbG,2BAAiB;IAerB,oBAsDC;IA/CC,0BAAgB;IAiDlB,uBA+BC;IAxBC,6BAAmB;IA0BrB,mBAmDC;IA3CC,yBAAwD;IA6C1D,2DA+CC;IAED,qFAAqF;IACrF,wFAkDC;IAED,mBAmEC;IA5DC,yBAAe;IAkEjB,+BA2CC;IAED,sCAuGC;IAED;;;MA2DC;IAED,iCAsMC;IAED,+FAA+F;IAC/F,uBAyCC;IAED,sHA8HC;IAED,uHAmFC;IAED,gFAAgF;IAChF,qCAaC;IAED,oBAEC;IAED,6BAkBC;IAED,kCA6BC;CACF;AA5zCD;IACE,yBAIC;IAHC,YAAoB;IACpB,oBAAgC;IAChC,eAAe;IAGjB,wBAIC;IAED,eAEC;IAED,oBAIC;IAED,mBAIC;IAED,qBAIC;IAED,oBAIC;IAED,qBAIC;IAED,oBAIC;IAED,qBAQC;IAED,oBAOC;IAED,sBAIC;IAED,sBAIC;IAED,wCAIC;IAED,gCAKC;CACF"}