@automovie/ingest 0.3.4 → 0.4.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 (225) hide show
  1. package/README.md +9 -29
  2. package/lib/AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.d.ts +4 -1
  3. package/lib/AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.js +4 -1
  4. package/lib/AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.js.map +1 -1
  5. package/lib/AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.d.ts +4 -1
  6. package/lib/AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.js +4 -1
  7. package/lib/AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.js.map +1 -1
  8. package/lib/adoptAutoMovieExternalMotion.d.ts +21 -11
  9. package/lib/adoptAutoMovieExternalMotion.js +26 -12
  10. package/lib/adoptAutoMovieExternalMotion.js.map +1 -1
  11. package/lib/audio/admitProductionTtsReceipt.d.ts +25 -0
  12. package/lib/audio/admitProductionTtsReceipt.js +166 -0
  13. package/lib/audio/admitProductionTtsReceipt.js.map +1 -0
  14. package/lib/audio/decodeProductionAudioAsset.d.ts +42 -14
  15. package/lib/audio/decodeProductionAudioAsset.js +53 -30
  16. package/lib/audio/decodeProductionAudioAsset.js.map +1 -1
  17. package/lib/audio/index.d.ts +1 -0
  18. package/lib/audio/index.js +1 -0
  19. package/lib/audio/index.js.map +1 -1
  20. package/lib/audio/resampleProductionAudio.d.ts +22 -0
  21. package/lib/audio/resampleProductionAudio.js +103 -0
  22. package/lib/audio/resampleProductionAudio.js.map +1 -0
  23. package/lib/decodeAutoMoviePpmImage.d.ts +10 -18
  24. package/lib/decodeAutoMoviePpmImage.js +10 -18
  25. package/lib/decodeAutoMoviePpmImage.js.map +1 -1
  26. package/lib/font/TrueTypeByteReader.d.ts +34 -0
  27. package/lib/font/TrueTypeByteReader.js +67 -0
  28. package/lib/font/TrueTypeByteReader.js.map +1 -0
  29. package/lib/font/decodeAutoMovieTrueTypeFont.d.ts +31 -0
  30. package/lib/font/decodeAutoMovieTrueTypeFont.js +168 -0
  31. package/lib/font/decodeAutoMovieTrueTypeFont.js.map +1 -0
  32. package/lib/font/index.d.ts +1 -0
  33. package/lib/font/index.js +18 -0
  34. package/lib/font/index.js.map +1 -0
  35. package/lib/font/readTrueTypeCharacterMap.d.ts +23 -0
  36. package/lib/font/readTrueTypeCharacterMap.js +98 -0
  37. package/lib/font/readTrueTypeCharacterMap.js.map +1 -0
  38. package/lib/font/readTrueTypeGlyphOutline.d.ts +45 -0
  39. package/lib/font/readTrueTypeGlyphOutline.js +275 -0
  40. package/lib/font/readTrueTypeGlyphOutline.js.map +1 -0
  41. package/lib/font/readTrueTypeKerning.d.ts +19 -0
  42. package/lib/font/readTrueTypeKerning.js +63 -0
  43. package/lib/font/readTrueTypeKerning.js.map +1 -0
  44. package/lib/font/readTrueTypeNames.d.ts +20 -0
  45. package/lib/font/readTrueTypeNames.js +75 -0
  46. package/lib/font/readTrueTypeNames.js.map +1 -0
  47. package/lib/humanoidSkeleton.d.ts +28 -15
  48. package/lib/humanoidSkeleton.js +28 -15
  49. package/lib/humanoidSkeleton.js.map +1 -1
  50. package/lib/index.d.ts +1 -0
  51. package/lib/index.js +1 -0
  52. package/lib/index.js.map +1 -1
  53. package/lib/ingestDocument.d.ts +25 -12
  54. package/lib/ingestDocument.js +25 -12
  55. package/lib/ingestDocument.js.map +1 -1
  56. package/lib/inspectAutoMovieExternalModelBytes.d.ts +24 -12
  57. package/lib/inspectAutoMovieExternalModelBytes.js +24 -12
  58. package/lib/inspectAutoMovieExternalModelBytes.js.map +1 -1
  59. package/lib/internal/IAccessorSource.d.ts +11 -8
  60. package/lib/internal/IExternalModelAccessorReader.d.ts +1 -8
  61. package/lib/internal/IHumanoidSlot.d.ts +9 -10
  62. package/lib/internal/IParsedContainer.d.ts +10 -8
  63. package/lib/internal/SHAPE_COMPONENTS.d.ts +4 -1
  64. package/lib/internal/SHAPE_COMPONENTS.js +4 -1
  65. package/lib/internal/SHAPE_COMPONENTS.js.map +1 -1
  66. package/lib/internal/accessorElementByteLength.d.ts +1 -11
  67. package/lib/internal/accessorElementByteLength.js +1 -11
  68. package/lib/internal/accessorElementByteLength.js.map +1 -1
  69. package/lib/internal/accessorReader.d.ts +5 -9
  70. package/lib/internal/accessorReader.js +5 -9
  71. package/lib/internal/accessorReader.js.map +1 -1
  72. package/lib/internal/accessorValues.d.ts +10 -10
  73. package/lib/internal/accessorValues.js +10 -10
  74. package/lib/internal/collectExternalResources.d.ts +1 -11
  75. package/lib/internal/collectExternalResources.js +1 -11
  76. package/lib/internal/collectExternalResources.js.map +1 -1
  77. package/lib/internal/compareCodeUnits.d.ts +1 -11
  78. package/lib/internal/compareCodeUnits.js +1 -11
  79. package/lib/internal/compareCodeUnits.js.map +1 -1
  80. package/lib/internal/composeLocalTransform.d.ts +13 -10
  81. package/lib/internal/composeLocalTransform.js +13 -10
  82. package/lib/internal/composeLocalTransform.js.map +1 -1
  83. package/lib/internal/decodeDataUri.d.ts +4 -9
  84. package/lib/internal/decodeDataUri.js +4 -9
  85. package/lib/internal/decodeDataUri.js.map +1 -1
  86. package/lib/internal/decodeGlb.d.ts +1 -11
  87. package/lib/internal/decodeGlb.js +1 -11
  88. package/lib/internal/decodeGlb.js.map +1 -1
  89. package/lib/internal/decodeJson.d.ts +1 -11
  90. package/lib/internal/decodeJson.js +10 -12
  91. package/lib/internal/decodeJson.js.map +1 -1
  92. package/lib/internal/fileExtension.d.ts +2 -9
  93. package/lib/internal/fileExtension.js +2 -9
  94. package/lib/internal/fileExtension.js.map +1 -1
  95. package/lib/internal/finiteTuple.d.ts +4 -9
  96. package/lib/internal/finiteTuple.js +4 -9
  97. package/lib/internal/finiteTuple.js.map +1 -1
  98. package/lib/internal/gltfHumanoidBones.d.ts +5 -9
  99. package/lib/internal/gltfHumanoidBones.js +5 -9
  100. package/lib/internal/gltfHumanoidBones.js.map +1 -1
  101. package/lib/internal/humanoidBoneOfName.d.ts +7 -9
  102. package/lib/internal/humanoidBoneOfName.js +7 -9
  103. package/lib/internal/humanoidBoneOfName.js.map +1 -1
  104. package/lib/internal/inspectExternalModelHierarchy.d.ts +1 -11
  105. package/lib/internal/inspectExternalModelHierarchy.js +1 -11
  106. package/lib/internal/inspectExternalModelHierarchy.js.map +1 -1
  107. package/lib/internal/inspectExternalMotion.d.ts +8 -9
  108. package/lib/internal/inspectExternalMotion.js +8 -9
  109. package/lib/internal/inspectExternalMotion.js.map +1 -1
  110. package/lib/internal/inspectExternalMotionNodes.d.ts +6 -9
  111. package/lib/internal/inspectExternalMotionNodes.js +6 -9
  112. package/lib/internal/inspectExternalMotionNodes.js.map +1 -1
  113. package/lib/internal/integerIndex.d.ts +1 -11
  114. package/lib/internal/integerIndex.js +1 -11
  115. package/lib/internal/integerIndex.js.map +1 -1
  116. package/lib/internal/integerIndices.d.ts +1 -11
  117. package/lib/internal/integerIndices.js +1 -11
  118. package/lib/internal/integerIndices.js.map +1 -1
  119. package/lib/internal/nonNegativeInteger.d.ts +1 -11
  120. package/lib/internal/nonNegativeInteger.js +1 -11
  121. package/lib/internal/nonNegativeInteger.js.map +1 -1
  122. package/lib/internal/object.d.ts +1 -11
  123. package/lib/internal/object.js +1 -11
  124. package/lib/internal/object.js.map +1 -1
  125. package/lib/internal/optionalArray.d.ts +1 -11
  126. package/lib/internal/optionalArray.js +1 -11
  127. package/lib/internal/optionalArray.js.map +1 -1
  128. package/lib/internal/optionalObject.d.ts +1 -11
  129. package/lib/internal/optionalObject.js +1 -11
  130. package/lib/internal/optionalObject.js.map +1 -1
  131. package/lib/internal/optionalStringArray.d.ts +1 -11
  132. package/lib/internal/optionalStringArray.js +1 -11
  133. package/lib/internal/optionalStringArray.js.map +1 -1
  134. package/lib/internal/positiveInteger.d.ts +1 -11
  135. package/lib/internal/positiveInteger.js +1 -11
  136. package/lib/internal/positiveInteger.js.map +1 -1
  137. package/lib/internal/readMotionAccessor.d.ts +5 -9
  138. package/lib/internal/readMotionAccessor.js +5 -9
  139. package/lib/internal/readMotionAccessor.js.map +1 -1
  140. package/lib/internal/requiredArray.d.ts +1 -11
  141. package/lib/internal/requiredArray.js +1 -11
  142. package/lib/internal/requiredArray.js.map +1 -1
  143. package/lib/internal/uniqueStrings.d.ts +1 -11
  144. package/lib/internal/uniqueStrings.js +1 -11
  145. package/lib/internal/uniqueStrings.js.map +1 -1
  146. package/lib/internal/validNodeIndex.d.ts +1 -11
  147. package/lib/internal/validNodeIndex.js +1 -11
  148. package/lib/internal/validNodeIndex.js.map +1 -1
  149. package/lib/internal/validateAccessorRange.d.ts +6 -9
  150. package/lib/internal/validateAccessorRange.js +6 -9
  151. package/lib/internal/validateAccessorRange.js.map +1 -1
  152. package/lib/internal/validateHumanoidSkinning.d.ts +8 -10
  153. package/lib/internal/validateHumanoidSkinning.js +8 -10
  154. package/lib/internal/validateHumanoidSkinning.js.map +1 -1
  155. package/lib/internal/validatePayloadClosure.d.ts +8 -9
  156. package/lib/internal/validatePayloadClosure.js +8 -9
  157. package/lib/internal/validatePayloadClosure.js.map +1 -1
  158. package/lib/internal/validateSparseAccessor.d.ts +6 -9
  159. package/lib/internal/validateSparseAccessor.js +6 -9
  160. package/lib/internal/validateSparseAccessor.js.map +1 -1
  161. package/lib/internal/vrmHumanoidBones.d.ts +7 -9
  162. package/lib/internal/vrmHumanoidBones.js +12 -10
  163. package/lib/internal/vrmHumanoidBones.js.map +1 -1
  164. package/lib/isAutoMovieExternalModelIngestProfile.d.ts +4 -10
  165. package/lib/isAutoMovieExternalModelIngestProfile.js +4 -10
  166. package/lib/isAutoMovieExternalModelIngestProfile.js.map +1 -1
  167. package/package.json +7 -7
  168. package/src/AUTOMOVIE_GLTF_MOTION_INTERPRETATION_PROFILE.ts +4 -1
  169. package/src/AUTO_MOVIE_EXTERNAL_MODEL_INGEST_PROFILES.ts +4 -1
  170. package/src/adoptAutoMovieExternalMotion.ts +26 -12
  171. package/src/audio/admitProductionTtsReceipt.ts +262 -0
  172. package/src/audio/decodeProductionAudioAsset.ts +54 -39
  173. package/src/audio/index.ts +1 -0
  174. package/src/audio/resampleProductionAudio.ts +114 -0
  175. package/src/decodeAutoMoviePpmImage.ts +10 -18
  176. package/src/font/TrueTypeByteReader.ts +80 -0
  177. package/src/font/decodeAutoMovieTrueTypeFont.ts +217 -0
  178. package/src/font/index.ts +1 -0
  179. package/src/font/readTrueTypeCharacterMap.ts +115 -0
  180. package/src/font/readTrueTypeGlyphOutline.ts +375 -0
  181. package/src/font/readTrueTypeKerning.ts +73 -0
  182. package/src/font/readTrueTypeNames.ts +74 -0
  183. package/src/humanoidSkeleton.ts +28 -15
  184. package/src/index.ts +1 -0
  185. package/src/ingestDocument.ts +25 -12
  186. package/src/inspectAutoMovieExternalModelBytes.ts +24 -12
  187. package/src/internal/IAccessorSource.ts +11 -8
  188. package/src/internal/IExternalModelAccessorReader.ts +1 -8
  189. package/src/internal/IHumanoidSlot.ts +9 -10
  190. package/src/internal/IParsedContainer.ts +10 -8
  191. package/src/internal/SHAPE_COMPONENTS.ts +4 -1
  192. package/src/internal/accessorElementByteLength.ts +1 -11
  193. package/src/internal/accessorReader.ts +5 -9
  194. package/src/internal/accessorValues.ts +10 -10
  195. package/src/internal/collectExternalResources.ts +1 -11
  196. package/src/internal/compareCodeUnits.ts +1 -11
  197. package/src/internal/composeLocalTransform.ts +13 -10
  198. package/src/internal/decodeDataUri.ts +4 -9
  199. package/src/internal/decodeGlb.ts +1 -11
  200. package/src/internal/decodeJson.ts +10 -12
  201. package/src/internal/fileExtension.ts +2 -9
  202. package/src/internal/finiteTuple.ts +4 -9
  203. package/src/internal/gltfHumanoidBones.ts +5 -9
  204. package/src/internal/humanoidBoneOfName.ts +7 -9
  205. package/src/internal/inspectExternalModelHierarchy.ts +1 -11
  206. package/src/internal/inspectExternalMotion.ts +8 -9
  207. package/src/internal/inspectExternalMotionNodes.ts +6 -9
  208. package/src/internal/integerIndex.ts +1 -11
  209. package/src/internal/integerIndices.ts +1 -11
  210. package/src/internal/nonNegativeInteger.ts +1 -11
  211. package/src/internal/object.ts +1 -11
  212. package/src/internal/optionalArray.ts +1 -11
  213. package/src/internal/optionalObject.ts +1 -11
  214. package/src/internal/optionalStringArray.ts +1 -11
  215. package/src/internal/positiveInteger.ts +1 -11
  216. package/src/internal/readMotionAccessor.ts +5 -9
  217. package/src/internal/requiredArray.ts +1 -11
  218. package/src/internal/uniqueStrings.ts +1 -11
  219. package/src/internal/validNodeIndex.ts +1 -11
  220. package/src/internal/validateAccessorRange.ts +6 -9
  221. package/src/internal/validateHumanoidSkinning.ts +8 -10
  222. package/src/internal/validatePayloadClosure.ts +8 -9
  223. package/src/internal/validateSparseAccessor.ts +6 -9
  224. package/src/internal/vrmHumanoidBones.ts +12 -10
  225. package/src/isAutoMovieExternalModelIngestProfile.ts +4 -10
@@ -0,0 +1,375 @@
1
+ import type {
2
+ AutoMovieVector2Tuple,
3
+ IAutoMovieFontSegment,
4
+ } from "@automovie/interface";
5
+
6
+ import type { TrueTypeByteReader } from "./TrueTypeByteReader";
7
+
8
+ /**
9
+ * Deepest component nesting a composite glyph may use; real fonts nest one or
10
+ * two levels.
11
+ */
12
+ const MAX_COMPONENT_DEPTH: number = 16;
13
+
14
+ /**
15
+ * Composite glyph flag (ISO/IEC 14496-22, section 5.3.4, the `glyf` composite
16
+ * glyph description): the component's two arguments are 16-bit, else 8-bit.
17
+ */
18
+ const ARG_1_AND_2_ARE_WORDS: number = 0x0001;
19
+
20
+ /** Composite flag: the arguments are signed x/y offsets, else point numbers. */
21
+ const ARGS_ARE_XY_VALUES: number = 0x0002;
22
+
23
+ /** Composite flag: one scale applies to both axes of the component. */
24
+ const WE_HAVE_A_SCALE: number = 0x0008;
25
+
26
+ /** Composite flag: another component follows this one. */
27
+ const MORE_COMPONENTS: number = 0x0020;
28
+
29
+ /** Composite flag: the component has separate x and y scales. */
30
+ const WE_HAVE_AN_X_AND_Y_SCALE: number = 0x0040;
31
+
32
+ /** Composite flag: a 2 × 2 matrix transforms the component. */
33
+ const WE_HAVE_A_TWO_BY_TWO: number = 0x0080;
34
+
35
+ /** Composite flag: the component's offset is scaled by its transform. */
36
+ const SCALED_COMPONENT_OFFSET: number = 0x0800;
37
+
38
+ /** Composite flag: the component's offset is not scaled by its transform. */
39
+ const UNSCALED_COMPONENT_OFFSET: number = 0x1000;
40
+
41
+ /**
42
+ * Read one glyph's outline from `glyf` as closed chains of quadratic segments
43
+ * in font units, resolving a composite glyph into its transformed components.
44
+ *
45
+ * A simple glyph's points are decoded from their run-length flags and delta
46
+ * coordinates. Each contour is then walked in order: two consecutive off-curve
47
+ * points imply an on-curve point at their midpoint, and a straight piece is
48
+ * written as a quadratic with its control at the midpoint of its ends (ISO/IEC
49
+ * 14496-22, section 5.3.4). A contour that starts off-curve starts at its last
50
+ * point when that is on-curve, else at the midpoint of its last and first
51
+ * points. Zero-length pieces are dropped, and a contour left with no piece,
52
+ * such as a lone anchor point, is dropped.
53
+ *
54
+ * A composite glyph places each component by its x/y offset and its 2 × 2
55
+ * transform, `x' = a·x + c·y + dx`, `y' = b·x + d·y + dy` with `a = xscale`, `b
56
+ * = scale01`, `c = scale10`, `d = yscale`; the offset is transformed only when
57
+ * `SCALED_COMPONENT_OFFSET` is set without `UNSCALED_COMPONENT_OFFSET`, the
58
+ * Open Font Format default. Components placed by matching point numbers are
59
+ * refused. Nesting deeper than 16 levels and a component that contains itself
60
+ * are refused.
61
+ *
62
+ * Results are cached per glyph index in `cache`, so a component shared by
63
+ * several glyphs is decoded once; callers must not mutate the returned arrays.
64
+ *
65
+ * @throws {Error} A field lies outside the glyph's `loca` span, a simple
66
+ * glyph's end points do not increase, a component uses point matching, nests
67
+ * too deep or contains itself.
68
+ */
69
+ export function readTrueTypeGlyphOutline(props: {
70
+ /** Bounds-checked reader over the font bytes. */
71
+ reader: TrueTypeByteReader;
72
+
73
+ /** Byte offset of the `glyf` table. */
74
+ glyf: number;
75
+
76
+ /**
77
+ * `loca` offsets relative to `glyf`, one more than the glyph count, already
78
+ * checked to increase within `glyf`.
79
+ */
80
+ loca: readonly number[];
81
+
82
+ /** Glyph index to read. */
83
+ glyph: number;
84
+
85
+ /** Outlines already read, by glyph index. */
86
+ cache: Map<number, IAutoMovieFontSegment[][]>;
87
+ }): IAutoMovieFontSegment[][] {
88
+ return read(props, props.glyph, []);
89
+ }
90
+
91
+ /** Read one glyph with the component stack above it. */
92
+ function read(
93
+ props: Parameters<typeof readTrueTypeGlyphOutline>[0],
94
+ glyph: number,
95
+ stack: readonly number[],
96
+ ): IAutoMovieFontSegment[][] {
97
+ const cached: IAutoMovieFontSegment[][] | undefined = props.cache.get(glyph);
98
+ if (cached !== undefined) return cached;
99
+ if (stack.includes(glyph))
100
+ throw new Error(
101
+ `TrueType composite glyph ${stack[0]} contains itself through glyph ${glyph}`,
102
+ );
103
+ if (stack.length > MAX_COMPONENT_DEPTH)
104
+ throw new Error(
105
+ `TrueType composite glyph ${stack[0]} nests components deeper than ${MAX_COMPONENT_DEPTH} levels`,
106
+ );
107
+ if (glyph < 0 || glyph + 1 >= props.loca.length)
108
+ throw new Error(
109
+ `TrueType glyph ${glyph} is past the font's ${props.loca.length - 1} glyphs`,
110
+ );
111
+
112
+ const start: number = props.glyf + props.loca[glyph]!;
113
+ const end: number = props.glyf + props.loca[glyph + 1]!;
114
+ let contours: IAutoMovieFontSegment[][];
115
+ if (end === start) contours = [];
116
+ else {
117
+ const span: ISpan = { reader: props.reader, end, glyph };
118
+ const count: number = at(span, start, 2, "i16");
119
+ contours =
120
+ count >= 0
121
+ ? simple(span, start + 10, count)
122
+ : composite(props, span, start + 10, [...stack, glyph]);
123
+ }
124
+ props.cache.set(glyph, contours);
125
+ return contours;
126
+ }
127
+
128
+ /** The byte span one glyph owns, for reads that must stay inside it. */
129
+ interface ISpan {
130
+ /** Reader over the font bytes. */
131
+ reader: TrueTypeByteReader;
132
+
133
+ /** First byte past the glyph's `loca` span. */
134
+ end: number;
135
+
136
+ /** Glyph index, for diagnostics. */
137
+ glyph: number;
138
+ }
139
+
140
+ /** Read one field that must lie inside the glyph's span. */
141
+ function at(
142
+ span: ISpan,
143
+ offset: number,
144
+ size: 1 | 2,
145
+ type: "u8" | "i8" | "u16" | "i16",
146
+ ): number {
147
+ if (offset + size > span.end)
148
+ throw new Error(
149
+ `TrueType glyph ${span.glyph} reads byte ${offset + size - 1}, past its loca span ending at byte ${span.end}`,
150
+ );
151
+ const what: string = `glyph ${span.glyph}`;
152
+ switch (type) {
153
+ case "u8":
154
+ return span.reader.u8(offset, what);
155
+ case "i8":
156
+ return span.reader.i8(offset, what);
157
+ case "u16":
158
+ return span.reader.u16(offset, what);
159
+ case "i16":
160
+ return span.reader.i16(offset, what);
161
+ }
162
+ }
163
+
164
+ /** Decode a simple glyph's contours. */
165
+ function simple(
166
+ span: ISpan,
167
+ offset: number,
168
+ count: number,
169
+ ): IAutoMovieFontSegment[][] {
170
+ if (count === 0) return [];
171
+ const ends: number[] = [];
172
+ for (let contour: number = 0; contour < count; ++contour) {
173
+ const last: number = at(span, offset + contour * 2, 2, "u16");
174
+ if (contour > 0 && last <= ends[contour - 1]!)
175
+ throw new Error(
176
+ `TrueType glyph ${span.glyph} contour end points must increase`,
177
+ );
178
+ ends.push(last);
179
+ }
180
+ const points: number = ends[count - 1]! + 1;
181
+ const instructions: number = at(span, offset + count * 2, 2, "u16");
182
+ let cursor: number = offset + count * 2 + 2 + instructions;
183
+
184
+ // Flags, with bit 3 repeating a flag the following byte's count of times.
185
+ const flags: number[] = [];
186
+ while (flags.length < points) {
187
+ const flag: number = at(span, cursor++, 1, "u8");
188
+ flags.push(flag);
189
+ if ((flag & 0x08) !== 0) {
190
+ const repeat: number = at(span, cursor++, 1, "u8");
191
+ for (let r: number = 0; r < repeat && flags.length < points; ++r)
192
+ flags.push(flag);
193
+ }
194
+ }
195
+
196
+ // Coordinates are deltas: a short delta is one unsigned byte signed by the
197
+ // "same" bit, a long one an i16, and "same" without "short" repeats the last.
198
+ const axis: (short: number, same: number) => number[] = (
199
+ short: number,
200
+ same: number,
201
+ ): number[] => {
202
+ const values: number[] = [];
203
+ let value: number = 0;
204
+ for (const flag of flags) {
205
+ if ((flag & short) !== 0) {
206
+ const delta: number = at(span, cursor++, 1, "u8");
207
+ value += (flag & same) !== 0 ? delta : -delta;
208
+ } else if ((flag & same) === 0) {
209
+ value += at(span, cursor, 2, "i16");
210
+ cursor += 2;
211
+ }
212
+ values.push(value);
213
+ }
214
+ return values;
215
+ };
216
+ const xs: number[] = axis(0x02, 0x10);
217
+ const ys: number[] = axis(0x04, 0x20);
218
+
219
+ const contours: IAutoMovieFontSegment[][] = [];
220
+ let first: number = 0;
221
+ for (const last of ends) {
222
+ const ring: { point: AutoMovieVector2Tuple; on: boolean }[] = [];
223
+ for (let index: number = first; index <= last; ++index)
224
+ ring.push({
225
+ point: [xs[index]!, ys[index]!],
226
+ on: (flags[index]! & 1) !== 0,
227
+ });
228
+ first = last + 1;
229
+ const segments: IAutoMovieFontSegment[] = quadratics(ring);
230
+ if (segments.length > 0) contours.push(segments);
231
+ }
232
+ return contours;
233
+ }
234
+
235
+ /** Turn one contour's on- and off-curve points into closed quadratic segments. */
236
+ function quadratics(
237
+ ring: readonly { point: AutoMovieVector2Tuple; on: boolean }[],
238
+ ): IAutoMovieFontSegment[] {
239
+ const n: number = ring.length;
240
+ const first: { point: AutoMovieVector2Tuple; on: boolean } = ring[0]!;
241
+ const last: { point: AutoMovieVector2Tuple; on: boolean } = ring[n - 1]!;
242
+ let start: AutoMovieVector2Tuple;
243
+ let sequence: readonly { point: AutoMovieVector2Tuple; on: boolean }[];
244
+ if (first.on) {
245
+ start = first.point;
246
+ sequence = ring.slice(1);
247
+ } else if (last.on) {
248
+ start = last.point;
249
+ sequence = ring.slice(0, n - 1);
250
+ } else {
251
+ start = midpoint(last.point, first.point);
252
+ sequence = ring;
253
+ }
254
+
255
+ const segments: IAutoMovieFontSegment[] = [];
256
+ const push: (
257
+ from: AutoMovieVector2Tuple,
258
+ control: AutoMovieVector2Tuple,
259
+ to: AutoMovieVector2Tuple,
260
+ ) => void = (
261
+ from: AutoMovieVector2Tuple,
262
+ control: AutoMovieVector2Tuple,
263
+ to: AutoMovieVector2Tuple,
264
+ ): void => {
265
+ if (
266
+ from[0] === to[0] &&
267
+ from[1] === to[1] &&
268
+ control[0] === to[0] &&
269
+ control[1] === to[1]
270
+ )
271
+ return;
272
+ segments.push({ start: [...from], control: [...control], end: [...to] });
273
+ };
274
+ let current: AutoMovieVector2Tuple = start;
275
+ let pending: AutoMovieVector2Tuple | null = null;
276
+ for (const entry of [...sequence, { point: start, on: true }]) {
277
+ if (entry.on) {
278
+ push(current, pending ?? midpoint(current, entry.point), entry.point);
279
+ current = entry.point;
280
+ pending = null;
281
+ } else if (pending === null) pending = entry.point;
282
+ else {
283
+ const implied: AutoMovieVector2Tuple = midpoint(pending, entry.point);
284
+ push(current, pending, implied);
285
+ current = implied;
286
+ pending = entry.point;
287
+ }
288
+ }
289
+ return segments;
290
+ }
291
+
292
+ /** The point halfway between two points. */
293
+ function midpoint(
294
+ a: AutoMovieVector2Tuple,
295
+ b: AutoMovieVector2Tuple,
296
+ ): AutoMovieVector2Tuple {
297
+ return [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2];
298
+ }
299
+
300
+ /** Resolve a composite glyph's components into transformed contours. */
301
+ function composite(
302
+ props: Parameters<typeof readTrueTypeGlyphOutline>[0],
303
+ span: ISpan,
304
+ offset: number,
305
+ stack: readonly number[],
306
+ ): IAutoMovieFontSegment[][] {
307
+ const contours: IAutoMovieFontSegment[][] = [];
308
+ let cursor: number = offset;
309
+ let flags: number;
310
+ do {
311
+ flags = at(span, cursor, 2, "u16");
312
+ const component: number = at(span, cursor + 2, 2, "u16");
313
+ cursor += 4;
314
+ if ((flags & ARGS_ARE_XY_VALUES) === 0)
315
+ throw new Error(
316
+ `TrueType composite glyph ${span.glyph} places component ${component} by matching point numbers, which is not supported; use x/y offsets`,
317
+ );
318
+ let dx: number;
319
+ let dy: number;
320
+ if ((flags & ARG_1_AND_2_ARE_WORDS) !== 0) {
321
+ dx = at(span, cursor, 2, "i16");
322
+ dy = at(span, cursor + 2, 2, "i16");
323
+ cursor += 4;
324
+ } else {
325
+ dx = at(span, cursor, 1, "i8");
326
+ dy = at(span, cursor + 1, 1, "i8");
327
+ cursor += 2;
328
+ }
329
+
330
+ let a: number = 1;
331
+ let b: number = 0;
332
+ let c: number = 0;
333
+ let d: number = 1;
334
+ const fixed: (index: number) => number = (index: number): number =>
335
+ at(span, cursor + index * 2, 2, "i16") / 16384;
336
+ if ((flags & WE_HAVE_A_SCALE) !== 0) {
337
+ a = fixed(0);
338
+ d = a;
339
+ cursor += 2;
340
+ } else if ((flags & WE_HAVE_AN_X_AND_Y_SCALE) !== 0) {
341
+ a = fixed(0);
342
+ d = fixed(1);
343
+ cursor += 4;
344
+ } else if ((flags & WE_HAVE_A_TWO_BY_TWO) !== 0) {
345
+ a = fixed(0);
346
+ b = fixed(1);
347
+ c = fixed(2);
348
+ d = fixed(3);
349
+ cursor += 8;
350
+ }
351
+ if (
352
+ (flags & SCALED_COMPONENT_OFFSET) !== 0 &&
353
+ (flags & UNSCALED_COMPONENT_OFFSET) === 0
354
+ )
355
+ [dx, dy] = [a * dx + c * dy, b * dx + d * dy];
356
+
357
+ const map: (point: AutoMovieVector2Tuple) => AutoMovieVector2Tuple = (
358
+ point: AutoMovieVector2Tuple,
359
+ ): AutoMovieVector2Tuple => [
360
+ a * point[0] + c * point[1] + dx,
361
+ b * point[0] + d * point[1] + dy,
362
+ ];
363
+ for (const contour of read(props, component, stack))
364
+ contours.push(
365
+ contour.map(
366
+ (segment: IAutoMovieFontSegment): IAutoMovieFontSegment => ({
367
+ start: map(segment.start),
368
+ control: map(segment.control),
369
+ end: map(segment.end),
370
+ }),
371
+ ),
372
+ );
373
+ } while ((flags & MORE_COMPONENTS) !== 0);
374
+ return contours;
375
+ }
@@ -0,0 +1,73 @@
1
+ import type { TrueTypeByteReader } from "./TrueTypeByteReader";
2
+
3
+ /**
4
+ * `kern` subtable coverage bit 0 (ISO/IEC 14496-22, section 5.7.4): set when
5
+ * the subtable holds horizontal data, clear for vertical.
6
+ */
7
+ const HORIZONTAL: number = 0x01;
8
+
9
+ /** Coverage bit 1: set when the subtable holds minimum values, not kerning. */
10
+ const MINIMUM: number = 0x02;
11
+
12
+ /** Coverage bit 2: set when the kerning is perpendicular to the text flow. */
13
+ const CROSS_STREAM: number = 0x04;
14
+
15
+ /**
16
+ * Coverage bit 3: set when the subtable's value replaces the value accumulated
17
+ * so far rather than adding to it.
18
+ */
19
+ const OVERRIDE: number = 0x08;
20
+
21
+ /**
22
+ * Read the horizontal kerning pairs of a `kern` table's format 0 subtables, by
23
+ * glyph index (ISO/IEC 14496-22, section 5.7.4).
24
+ *
25
+ * Only subtables that kern horizontally and hold kerning values, not minimum
26
+ * values or cross-stream adjustments, contribute, since those are what advance
27
+ * glyphs along a line. Their values add across subtables, as the format
28
+ * specifies, unless a subtable's override bit replaces the accumulated value.
29
+ * Subtables of other formats are skipped by their declared length.
30
+ *
31
+ * @param reader Bounds-checked reader over the font bytes.
32
+ * @param offset Byte offset of the `kern` table.
33
+ * @returns Adjustment in font units keyed by `left * 65536 + right` glyph
34
+ * indices. An Apple-format table, whose 32-bit version is 1.0, contributes no
35
+ * pairs.
36
+ * @throws {Error} A field lies outside the bytes.
37
+ */
38
+ export function readTrueTypeKerning(
39
+ reader: TrueTypeByteReader,
40
+ offset: number,
41
+ ): Map<number, number> {
42
+ // The Apple-format table (a 32-bit version 1.0) is not the OpenType one and
43
+ // contributes no pairs, like a font without kerning.
44
+ if (reader.u16(offset, "kern header") !== 0) return new Map();
45
+ const tables: number = reader.u16(offset + 2, "kern header");
46
+ const pairs: Map<number, number> = new Map();
47
+ let cursor: number = offset + 4;
48
+ for (let table: number = 0; table < tables; ++table) {
49
+ const length: number = reader.u16(cursor + 2, "kern subtable header");
50
+ const coverage: number = reader.u16(cursor + 4, "kern subtable header");
51
+ reader.require(cursor, length, "kern subtable");
52
+ if (
53
+ coverage >> 8 === 0 &&
54
+ (coverage & HORIZONTAL) !== 0 &&
55
+ (coverage & (MINIMUM | CROSS_STREAM)) === 0
56
+ ) {
57
+ const count: number = reader.u16(cursor + 6, "kern format 0 header");
58
+ reader.require(cursor + 14, count * 6, "kern format 0 pairs");
59
+ for (let pair: number = 0; pair < count; ++pair) {
60
+ const at: number = cursor + 14 + pair * 6;
61
+ const key: number =
62
+ reader.u16(at, "kern pair") * 65536 + reader.u16(at + 2, "kern pair");
63
+ const value: number = reader.i16(at + 4, "kern pair");
64
+ pairs.set(
65
+ key,
66
+ (coverage & OVERRIDE) !== 0 ? value : (pairs.get(key) ?? 0) + value,
67
+ );
68
+ }
69
+ }
70
+ cursor += length;
71
+ }
72
+ return pairs;
73
+ }
@@ -0,0 +1,74 @@
1
+ import type { IAutoMovieFont } from "@automovie/interface";
2
+
3
+ import type { TrueTypeByteReader } from "./TrueTypeByteReader";
4
+
5
+ /**
6
+ * Read name IDs 1 (family), 13 (licence description) and 14 (licence URL) from
7
+ * a `name` table (ISO/IEC 14496-22, section 5.2.6).
8
+ *
9
+ * For each ID the Windows Unicode record in US English (platform 3, encoding 1
10
+ * or 10, language 0x0409) is preferred, then any Windows Unicode record, then a
11
+ * Unicode-platform record (platform 0); all three are UTF-16BE. A Macintosh
12
+ * Roman record (platform 1, encoding 0) is used last, and only when every byte
13
+ * is ASCII, because Mac Roman differs from Latin-1 above 0x7F and a guessed
14
+ * decoding would misstate a licence. Records are only described here; no rights
15
+ * are judged.
16
+ *
17
+ * @param reader Bounds-checked reader over the font bytes.
18
+ * @param offset Byte offset of the `name` table.
19
+ * @returns The three names, each `null` when no usable record carries it.
20
+ * @throws {Error} A record or its string lies outside the bytes.
21
+ */
22
+ export function readTrueTypeNames(
23
+ reader: TrueTypeByteReader,
24
+ offset: number,
25
+ ): IAutoMovieFont["names"] {
26
+ const count: number = reader.u16(offset + 2, "name header");
27
+ const strings: number = offset + reader.u16(offset + 4, "name header");
28
+ const best: Map<number, { rank: number; text: string }> = new Map();
29
+ for (let index: number = 0; index < count; ++index) {
30
+ const record: number = offset + 6 + index * 12;
31
+ const platform: number = reader.u16(record, "name record");
32
+ const encoding: number = reader.u16(record + 2, "name record");
33
+ const language: number = reader.u16(record + 4, "name record");
34
+ const id: number = reader.u16(record + 6, "name record");
35
+ if (id !== 1 && id !== 13 && id !== 14) continue;
36
+ const length: number = reader.u16(record + 8, "name record");
37
+ const at: number = strings + reader.u16(record + 10, "name record");
38
+ reader.require(at, length, "name string");
39
+
40
+ let rank: number;
41
+ let text: string | null = null;
42
+ if (platform === 3 && (encoding === 1 || encoding === 10)) {
43
+ rank = language === 0x0409 ? 0 : 1;
44
+ text = utf16(reader, at, length);
45
+ } else if (platform === 0) {
46
+ rank = 2;
47
+ text = utf16(reader, at, length);
48
+ } else if (platform === 1 && encoding === 0) {
49
+ rank = 3;
50
+ const codes: number[] = [];
51
+ for (let byte: number = 0; byte < length; ++byte)
52
+ codes.push(reader.u8(at + byte, "name string"));
53
+ if (codes.every((code: number): boolean => code < 0x80))
54
+ text = String.fromCharCode(...codes);
55
+ } else continue;
56
+ if (text === null) continue;
57
+ const previous: { rank: number; text: string } | undefined = best.get(id);
58
+ if (previous === undefined || rank < previous.rank)
59
+ best.set(id, { rank, text });
60
+ }
61
+ return {
62
+ family: best.get(1)?.text ?? null,
63
+ licenseDescription: best.get(13)?.text ?? null,
64
+ licenseUrl: best.get(14)?.text ?? null,
65
+ };
66
+ }
67
+
68
+ /** Decode UTF-16BE code units, surrogate pairs included. */
69
+ function utf16(reader: TrueTypeByteReader, at: number, length: number): string {
70
+ const units: number[] = [];
71
+ for (let unit: number = 0; unit + 1 < length; unit += 2)
72
+ units.push(reader.u16(at + unit, "name string"));
73
+ return String.fromCharCode(...units);
74
+ }
@@ -16,26 +16,39 @@ import { composeLocalTransform } from "./internal/composeLocalTransform";
16
16
  import { humanoidBoneOfName } from "./internal/humanoidBoneOfName";
17
17
 
18
18
  /**
19
- * Retarget a parsed glTF's skins onto a normalized humanoid {@link IAutoMovieSkeleton} by matching joint names to {@link AutoMovieHumanoidBone} slots.
19
+ * Retarget a parsed glTF's skins onto a normalized humanoid
20
+ * {@link IAutoMovieSkeleton} by matching joint names to
21
+ * {@link AutoMovieHumanoidBone} slots.
20
22
  *
21
- * This naming-based mapper currently has test callers in this repository. Production motion adoption uses an explicit mapping against inspected nodes, so this export does not establish a production rig-inference flow.
23
+ * This naming-based mapper currently has test callers in this repository.
24
+ * Production motion adoption uses an explicit mapping against inspected nodes,
25
+ * so this export does not establish a production rig-inference flow.
22
26
  *
23
- * Every skin is read in document order and the first joint to claim a slot keeps it, because exporters bind clothes, hair and accessories as separate skins in no guaranteed order and the body rig must be found wherever it sits. A joint name maps through the supported Blender-style, Mixamo, VRM-style and Unreal mannequin aliases; fingers, eyes and jaw are not mapped.
27
+ * Every skin is read in document order and the first joint to claim a slot
28
+ * keeps it, because exporters bind clothes, hair and accessories as separate
29
+ * skins in no guaranteed order and the body rig must be found wherever it sits.
30
+ * A joint name maps through the supported Blender-style, Mixamo, VRM-style and
31
+ * Unreal mannequin aliases; fingers, eyes and jaw are not mapped.
24
32
  *
25
- * The hierarchy is rebuilt over mapped joints only: a bone's parent is its nearest mapped ancestor in the node tree, and the local TRS of every skipped helper node between them composes into the bone's rest, because {@link IAutoMovieBone.rest} is relative to `parent` and a dropped helper offset or roll would misplace every bone beneath it. With finite unit-quaternion TRS inputs, composition represents the affine product up to floating-point rounding when each helper scale commutes with its child rotation; otherwise it drops shear. This mapper does not admit or normalize raw node TRS. A root bone keeps its own local TRS, since armature and scene transforms belong to the imported object rather than the skeleton. Bones carry no constraint.
33
+ * The hierarchy is rebuilt over mapped joints only: a bone's parent is its
34
+ * nearest mapped ancestor in the node tree, and the local TRS of every skipped
35
+ * helper node between them composes into the bone's rest, because
36
+ * {@link IAutoMovieBone.rest} is relative to `parent` and a dropped helper
37
+ * offset or roll would misplace every bone beneath it. With finite
38
+ * unit-quaternion TRS inputs, composition represents the affine product up to
39
+ * floating-point rounding when each helper scale commutes with its child
40
+ * rotation; otherwise it drops shear. This mapper does not admit or normalize
41
+ * raw node TRS. A root bone keeps its own local TRS, since armature and scene
42
+ * transforms belong to the imported object rather than the skeleton. Bones
43
+ * carry no constraint.
26
44
  *
27
45
  * @param doc Parsed document; it is only read.
28
- * @param skeletonId Id copied verbatim to the returned skeleton; defaults to "skeleton" and is not validated here.
29
- * @returns The skeleton with bones in first-claim order, or `null` when no skin joint maps to the required `hips` slot.
30
- * @throws {Error} When a mapped joint's ancestors loop, which no glTF node hierarchy may.
31
- *
32
- * @evidence contracts/development/implementation.md#principled-implementation Slots come from a normalized alias table, the hierarchy from a child-to-parent map walked to the nearest mapped ancestor and refusing an ancestor met twice, since a glTF hierarchy is a forest of strict trees, and each rest from composing skipped helper TRS with `composeLocalTransform`; that composition drops the shear a non-uniform helper scale under a rotated child would need, the limitation the documentation states.
33
- * @evidence contracts/development/implementation.md#clear-and-simple-structure The function owns slot claiming and hierarchy rebuilding, while name normalization and transform composition live in internal modules the byte inspector and motion adoption share, so the alias table and the composition formula each exist once.
34
- * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts The alias table is this importer's declared naming vocabulary, not proof of bone anatomy; the table is a `Map`, so a joint named after an `Object.prototype` member such as `constructor` maps to nothing instead of an inherited function, and first-claim order is the documented rule for duplicate slots.
35
- * @evidence contracts/development/common.md#meaningful-documentation The documentation states the every-skin first-claim rule and its reason, the covered naming conventions and unmapped fingers, eyes and jaw, the helper composition and its exactness, the root-bone exception, the null cases, the refused ancestor cycle, and that constraints are left empty.
36
- * @evidence contracts/development/implementation.md#efficient-algorithms Work follows skins and joints, joint-name text normalization, nodes and child links, and each mapped bone's walk to the nearest mapped ancestor; hash lookups have expected constant cost, while each helper walk may revisit ancestors another bone's walk read, and reads each node at most once itself.
37
- * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Slot and parent maps are call-local; repeated ancestor walks remain bounded by mapped slots and document depth, while mutable Document contents and the requested skeleton id preclude a retained identity-only cache.
38
- * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The slot and parent maps, the helper arrays and each walk's visited set are local and released on return or throw; the returned skeleton holds new transform objects proportional to the mapped bones, at most the humanoid slot count, owned by the caller.
46
+ * @param skeletonId Id copied verbatim to the returned skeleton; defaults to
47
+ * "skeleton" and is not validated here.
48
+ * @returns The skeleton with bones in first-claim order, or `null` when no skin
49
+ * joint maps to the required `hips` slot.
50
+ * @throws {Error} When a mapped joint's ancestors loop, which no glTF node
51
+ * hierarchy may.
39
52
  */
40
53
  export const humanoidSkeleton: (
41
54
  doc: Document,
package/src/index.ts CHANGED
@@ -7,3 +7,4 @@ export * from "./isAutoMovieExternalModelIngestProfile";
7
7
  export * from "./inspectAutoMovieExternalModelBytes";
8
8
  export * from "./adoptAutoMovieExternalMotion";
9
9
  export * from "./decodeAutoMoviePpmImage";
10
+ export * from "./font";
@@ -24,24 +24,37 @@ import type {
24
24
  import { accessorValues } from "./internal/accessorValues";
25
25
 
26
26
  /**
27
- * Map a parsed glTF/GLB {@link Document} onto automovie's core node graph and animation clips, with no three.js and no humanoid assumptions.
27
+ * Map a parsed glTF/GLB {@link Document} onto automovie's core node graph and
28
+ * animation clips, with no three.js and no humanoid assumptions.
28
29
  *
29
- * Current repository callers exercise this parsed-document mapper through tests. The production asset inventory uses the separate byte inspector and host loaders; this export does not establish a wired parsed-document runtime import flow.
30
+ * Current repository callers exercise this parsed-document mapper through
31
+ * tests. The production asset inventory uses the separate byte inspector and
32
+ * host loaders; this export does not establish a wired parsed-document runtime
33
+ * import flow.
30
34
  *
31
- * `@gltf-transform/core` parses the bytes headlessly, and this mapper rewrites its structures structurally so props, cameras and characters import the same way. Every node keeps its local TRS, its parent, and the mesh, camera and skin it carries; a skin joint is a `bone` even when it also carries a mesh, then a mesh node is `mesh`, a camera node `camera`, and anything else `group`. Lights are not read. Every animation channel becomes a node track with the glTF sampler's keyframes, its interpolation mapped LINEAR, STEP and CUBICSPLINE to `linear`, `step` and `cubicspline` with an absent one read as LINEAR as glTF specifies, and its values decoded from normalized integers where the accessor declares them. Naming-based humanoid skeleton mapping is the separate {@link humanoidSkeleton} stage.
35
+ * `@gltf-transform/core` parses the bytes headlessly, and this mapper rewrites
36
+ * its structures structurally so props, cameras and characters import the same
37
+ * way. Every node keeps its local TRS, its parent, and the mesh, camera and
38
+ * skin it carries; a skin joint is a `bone` even when it also carries a mesh,
39
+ * then a mesh node is `mesh`, a camera node `camera`, and anything else
40
+ * `group`. Lights are not read. Every animation channel becomes a node track
41
+ * with the glTF sampler's keyframes, its interpolation mapped LINEAR, STEP and
42
+ * CUBICSPLINE to `linear`, `step` and `cubicspline` with an absent one read as
43
+ * LINEAR as glTF specifies, and its values decoded from normalized integers
44
+ * where the accessor declares them. Naming-based humanoid skeleton mapping is
45
+ * the separate {@link humanoidSkeleton} stage.
32
46
  *
33
- * Channel checks refuse no target node, no or unknown target path, no sampler, no input or output data, an unknown interpolation, keyframe times that are not finite, non-negative and strictly increasing, non-finite output values, or an output length that disagrees with the keyframe count, the path's component count and the cubic-spline tangent triple. This is not complete model admission: node TRS, graph/resource membership, duplicate target channels, rotation magnitude and weights against the target morph count are caller premises rather than checks performed here.
47
+ * Channel checks refuse no target node, no or unknown target path, no sampler,
48
+ * no input or output data, an unknown interpolation, keyframe times that are
49
+ * not finite, non-negative and strictly increasing, non-finite output values,
50
+ * or an output length that disagrees with the keyframe count, the path's
51
+ * component count and the cubic-spline tangent triple. This is not complete
52
+ * model admission: node TRS, graph/resource membership, duplicate target
53
+ * channels, rotation magnitude and weights against the target morph count are
54
+ * caller premises rather than checks performed here.
34
55
  *
35
56
  * @param doc Parsed document; it is only read.
36
57
  * @returns New arrays the caller owns, sharing no storage with the document.
37
- *
38
- * @evidence contracts/development/implementation.md#principled-implementation Node and clip structure is mapped one to one with index ids, kinds follow a fixed precedence of joint, mesh, camera, then group, and each channel is checked against glTF's own sampler rules: an allowed path and interpolation, strictly increasing times, finite values, and output arity of keyframes times components times three for cubic splines; normalized accessors decode through `accessorValues`.
39
- * @evidence contracts/development/implementation.md#clear-and-simple-structure The function builds the id, parent, joint and resource-index maps once and maps nodes and animations; `toTrack` owns all channel validation, and the path and interpolation tables enumerate supported sampler vocabulary.
40
- * @evidence contracts/development/implementation.md#prohibited-implementation-shortcuts An unknown interpolation or target path throws rather than receiving a fallback interpretation, and no fixture-specific node, path or value is special-cased; lights are documented as not read.
41
- * @evidence contracts/development/common.md#meaningful-documentation The documentation states what each node keeps, the kind precedence, the interpolation mapping, normalized decoding, every refusal, and that the returned arrays share no storage with the document.
42
- * @evidence contracts/development/implementation.md#efficient-algorithms Work follows nodes and child links, meshes, cameras, skins and joints, animations and channels, and all per-track copied keyframe components; resource-index maps are built once and lookups use expected constant-time hash operations.
43
- * @evidenceExclude contracts/development/implementation.md#reuse-equivalent-work Maps are reused within one call over a mutable Document; a sampler shared by channels is copied per track so each track owns its arrays, and no cache coordinates separate calls.
44
- * @evidence contracts/development/implementation.md#bound-retention-and-release-resources The lookup maps are local and released on return or throw; the result retains new node records and per-track copies of keyframe data proportional to the document's animation size, owned by the caller, and no handle or task.
45
58
  */
46
59
  export const ingestDocument: (doc: Document) => IAutoMovieIngestResult = (
47
60
  doc: Document,