@lovelace_lol/embody 0.0.17 → 0.0.18

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.
@@ -1,5 +1,8 @@
1
1
  import { WebIO } from '@gltf-transform/core';
2
2
  import { MeshoptSimplifier } from 'meshoptimizer/simplifier';
3
+ import { readGlbSource as readSource } from './glb-source.mjs';
4
+
5
+ export { extractGarmentModel } from './extract-garment.mjs';
3
6
 
4
7
  const KINDS = new Set(['original', 'optimized', 'low-resolution', 'miniature', 'bust', 'outfit']);
5
8
 
@@ -16,35 +19,6 @@ async function yieldToCaller(signal) {
16
19
  abortIfNeeded(signal);
17
20
  }
18
21
 
19
- function readSource(source) {
20
- if (!(source instanceof Uint8Array)) throw new TypeError('Actor Model source must be a Uint8Array.');
21
- // Own both JSON and binary data before any asynchronous work can observe caller mutations.
22
- const bytes = new Uint8Array(source);
23
- if (bytes.byteLength < 20) throw new Error('Actor Model must be a glTF 2.0 binary (.glb).');
24
- const view = new DataView(bytes.buffer);
25
- if (view.getUint32(0, true) !== 0x46546c67 || view.getUint32(4, true) !== 2
26
- || view.getUint32(8, true) !== bytes.byteLength) {
27
- throw new Error('Actor Model has an invalid GLB header or length.');
28
- }
29
- let json;
30
- let chunkCount = 0;
31
- for (let offset = 12; offset < bytes.byteLength;) {
32
- if (offset + 8 > bytes.byteLength) throw new Error('Actor Model has an incomplete GLB chunk.');
33
- const length = view.getUint32(offset, true);
34
- const type = view.getUint32(offset + 4, true);
35
- if (length % 4 || offset + 8 + length > bytes.byteLength) throw new Error('Actor Model has an invalid GLB chunk length.');
36
- if (chunkCount === 0 && type === 0x4e4f534a) {
37
- json = JSON.parse(new TextDecoder().decode(bytes.subarray(offset + 8, offset + 8 + length)));
38
- } else if (chunkCount !== 1 || type !== 0x004e4942) {
39
- throw new Error('Actor Model must contain only the GLB JSON and optional binary chunks.');
40
- }
41
- offset += 8 + length;
42
- chunkCount++;
43
- }
44
- if (!json || json.asset?.version !== '2.0') throw new Error('Actor Model must declare glTF version 2.0.');
45
- return { bytes, json };
46
- }
47
-
48
22
  function inspectionOf(json, byteLength) {
49
23
  const warnings = [];
50
24
  const extensionNames = new Set([...(json.extensionsUsed ?? []), ...(json.extensionsRequired ?? [])]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovelace_lol/embody",
3
- "version": "0.0.17",
3
+ "version": "0.0.18",
4
4
  "description": "Renderer-agnostic character animation runtime for facial AUs, visemes, and bone-driven motion",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -106,5 +106,5 @@
106
106
  "@gltf-transform/core": "4.5.1",
107
107
  "meshoptimizer": "1.3.0"
108
108
  },
109
- "gitHead": "34543a554808e7f2d98edfc338f6caf61fc4e8fe"
109
+ "gitHead": "4653dd5c8d6dbfb5398968e49368f7d969e2e15e"
110
110
  }