@driftengine/assets 3.61.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 (100) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +9 -0
  3. package/README.md +9 -0
  4. package/dist/assetPath.d.ts +51 -0
  5. package/dist/assetPath.js +59 -0
  6. package/dist/coarseLevel.d.ts +94 -0
  7. package/dist/coarseLevel.js +606 -0
  8. package/dist/dds.d.ts +41 -0
  9. package/dist/dds.js +425 -0
  10. package/dist/drawKey.d.ts +64 -0
  11. package/dist/drawKey.js +42 -0
  12. package/dist/drftLoader.d.ts +420 -0
  13. package/dist/drftLoader.js +996 -0
  14. package/dist/drftTextures.d.ts +87 -0
  15. package/dist/drftTextures.js +138 -0
  16. package/dist/fbx.d.ts +86 -0
  17. package/dist/fbx.js +792 -0
  18. package/dist/fbxHarness.d.ts +68 -0
  19. package/dist/fbxHarness.js +185 -0
  20. package/dist/fbxInflate.d.ts +60 -0
  21. package/dist/fbxInflate.js +204 -0
  22. package/dist/fbxMaterial.d.ts +87 -0
  23. package/dist/fbxMaterial.js +345 -0
  24. package/dist/fbxRig.d.ts +130 -0
  25. package/dist/fbxRig.js +601 -0
  26. package/dist/gltf.d.ts +242 -0
  27. package/dist/gltf.js +904 -0
  28. package/dist/gltfAccessor.d.ts +2 -0
  29. package/dist/gltfAccessor.js +106 -0
  30. package/dist/gltfSkin.d.ts +32 -0
  31. package/dist/gltfSkin.js +144 -0
  32. package/dist/iesPhotometry.d.ts +44 -0
  33. package/dist/iesPhotometry.js +94 -0
  34. package/dist/imageInfo.d.ts +31 -0
  35. package/dist/imageInfo.js +119 -0
  36. package/dist/index.d.ts +58 -0
  37. package/dist/index.js +132 -0
  38. package/dist/kn5.d.ts +158 -0
  39. package/dist/kn5.js +557 -0
  40. package/dist/loadProgress.d.ts +118 -0
  41. package/dist/loadProgress.js +1 -0
  42. package/dist/localise.d.ts +35 -0
  43. package/dist/localise.js +253 -0
  44. package/dist/obj.d.ts +54 -0
  45. package/dist/obj.js +335 -0
  46. package/dist/orient.d.ts +104 -0
  47. package/dist/orient.js +241 -0
  48. package/dist/radianceHdr.d.ts +36 -0
  49. package/dist/radianceHdr.js +172 -0
  50. package/dist/readModel.d.ts +153 -0
  51. package/dist/readModel.js +386 -0
  52. package/dist/recognise.d.ts +38 -0
  53. package/dist/recognise.js +97 -0
  54. package/dist/stl.d.ts +22 -0
  55. package/dist/stl.js +131 -0
  56. package/dist/tangentOrder.d.ts +24 -0
  57. package/dist/tangentOrder.js +31 -0
  58. package/dist/threemf.d.ts +46 -0
  59. package/dist/threemf.js +254 -0
  60. package/dist/uploadBudget.d.ts +82 -0
  61. package/dist/uploadBudget.js +86 -0
  62. package/dist/usd.d.ts +49 -0
  63. package/dist/usd.js +542 -0
  64. package/dist/weld.d.ts +44 -0
  65. package/dist/weld.js +237 -0
  66. package/dist/zip.d.ts +35 -0
  67. package/dist/zip.js +110 -0
  68. package/package.json +61 -0
  69. package/src/assetPath.ts +79 -0
  70. package/src/coarseLevel.ts +720 -0
  71. package/src/dds.ts +507 -0
  72. package/src/drawKey.ts +91 -0
  73. package/src/drftLoader.ts +1197 -0
  74. package/src/drftTextures.ts +153 -0
  75. package/src/fbx.ts +934 -0
  76. package/src/fbxHarness.ts +215 -0
  77. package/src/fbxInflate.ts +258 -0
  78. package/src/fbxMaterial.ts +410 -0
  79. package/src/fbxRig.ts +652 -0
  80. package/src/gltf.ts +1161 -0
  81. package/src/gltfAccessor.ts +127 -0
  82. package/src/gltfSkin.ts +210 -0
  83. package/src/iesPhotometry.ts +136 -0
  84. package/src/imageInfo.ts +130 -0
  85. package/src/index.ts +162 -0
  86. package/src/kn5.ts +705 -0
  87. package/src/loadProgress.ts +131 -0
  88. package/src/localise.ts +275 -0
  89. package/src/obj.ts +386 -0
  90. package/src/orient.ts +262 -0
  91. package/src/radianceHdr.ts +195 -0
  92. package/src/readModel.ts +515 -0
  93. package/src/recognise.ts +124 -0
  94. package/src/stl.ts +147 -0
  95. package/src/tangentOrder.ts +32 -0
  96. package/src/threemf.ts +303 -0
  97. package/src/uploadBudget.ts +90 -0
  98. package/src/usd.ts +642 -0
  99. package/src/weld.ts +264 -0
  100. package/src/zip.ts +130 -0
package/dist/gltf.d.ts ADDED
@@ -0,0 +1,242 @@
1
+ /**
2
+ * glTF 2.0 → `MeshData`, with no dependencies and no filesystem.
3
+ *
4
+ * glTF is the only third-party format this engine reads at tier 1, and it earns that by
5
+ * being an open Khronos standard with a published specification and a conformance suite.
6
+ * Everything the baker guarantees rests here; nothing guaranteed rests on a vendor's
7
+ * internal layout. See docs/FORMAT.md §2.
8
+ *
9
+ * **Buffers arrive as bytes, never as paths.** The parser takes the JSON and the binary
10
+ * blobs it refers to, so it runs identically in the CLI, in a test, and in a browser, and
11
+ * so a test can build a document by hand instead of shipping fixture files for cases that
12
+ * are three lines of JSON.
13
+ *
14
+ * **Transforms are baked.** `MeshData` has no node and no matrix — a mesh is geometry in
15
+ * world space, which is what makes drawing it one call with no per-object state. So the
16
+ * scene graph is flattened here: each primitive's vertices are transformed by its node's
17
+ * world matrix on the way through, and the graph does not survive into the engine.
18
+ */
19
+ import type { DrftNode, MeshData } from '@driftengine/drft';
20
+ import type { DrftMaterial } from '@driftengine/drft';
21
+ import type { AssetReference } from './assetPath.ts';
22
+ interface GltfAccessor {
23
+ bufferView?: number;
24
+ byteOffset?: number;
25
+ componentType: number;
26
+ count: number;
27
+ type: string;
28
+ normalized?: boolean;
29
+ sparse?: unknown;
30
+ }
31
+ interface GltfBufferView {
32
+ buffer: number;
33
+ byteOffset?: number;
34
+ byteLength: number;
35
+ byteStride?: number;
36
+ }
37
+ interface GltfPrimitive {
38
+ attributes: Record<string, number>;
39
+ indices?: number;
40
+ material?: number;
41
+ mode?: number;
42
+ /** Morph targets: one entry per target, each naming its own delta accessors. */
43
+ targets?: Record<string, number>[];
44
+ }
45
+ interface GltfPbrMetallicRoughness {
46
+ baseColorFactor?: number[];
47
+ metallicFactor?: number;
48
+ roughnessFactor?: number;
49
+ baseColorTexture?: {
50
+ index: number;
51
+ texCoord?: number;
52
+ };
53
+ metallicRoughnessTexture?: {
54
+ index: number;
55
+ texCoord?: number;
56
+ };
57
+ }
58
+ /**
59
+ * `KHR_materials_pbrSpecularGlossiness`: Khronos' first PBR material model, archived in 2020.
60
+ *
61
+ * A material stating it carries **no `pbrMetallicRoughness` object at all** — the colour map is
62
+ * `diffuseTexture` here, and reflection is a specular colour and a glossiness rather than a
63
+ * metalness and a roughness. It is still what an asset store serves for anything exported from a
64
+ * specular workflow, and a reader that knows only the core model reads such a file's images, binds
65
+ * none of them, and paints the result in one flat fallback colour.
66
+ */
67
+ interface GltfSpecularGlossiness {
68
+ /** RGB the diffuse colour, A the opacity. Multiplies `diffuseTexture` where there is one. */
69
+ diffuseFactor?: number[];
70
+ diffuseTexture?: {
71
+ index: number;
72
+ texCoord?: number;
73
+ };
74
+ /** The specular *colour*, which is what carries a metal's tint in this model. */
75
+ specularFactor?: number[];
76
+ glossinessFactor?: number;
77
+ /** RGB the specular colour, A the glossiness. Both multiply the factors above. */
78
+ specularGlossinessTexture?: {
79
+ index: number;
80
+ texCoord?: number;
81
+ };
82
+ }
83
+ interface GltfMaterial {
84
+ pbrMetallicRoughness?: GltfPbrMetallicRoughness;
85
+ /**
86
+ * The material extensions this reader knows. One, and everything else is ignored.
87
+ *
88
+ * Read as an optional field rather than as `Record<string, unknown>` so that adding a second
89
+ * costs a name here and a branch in `pbrOf`, and so that a typo in either is a compile error.
90
+ */
91
+ extensions?: {
92
+ KHR_materials_pbrSpecularGlossiness?: GltfSpecularGlossiness;
93
+ };
94
+ normalTexture?: {
95
+ index: number;
96
+ texCoord?: number;
97
+ scale?: number;
98
+ };
99
+ /** `strength` is a mix from 1, not a multiply: 0 means unoccluded. */
100
+ occlusionTexture?: {
101
+ index: number;
102
+ texCoord?: number;
103
+ strength?: number;
104
+ };
105
+ emissiveTexture?: {
106
+ index: number;
107
+ texCoord?: number;
108
+ };
109
+ emissiveFactor?: number[];
110
+ /** `OPAQUE`, `MASK` or `BLEND`. Absent means opaque, which the specification states. */
111
+ alphaMode?: string;
112
+ alphaCutoff?: number;
113
+ name?: string;
114
+ /**
115
+ * Whatever the authoring tool put here, and this reader wants exactly one field of it.
116
+ *
117
+ * `extras.substance` is a substance id — `oak`, `gypsum-board` — which the baker writes into the
118
+ * `SUBS` chunk so a consumer can hand it to `installChemistry().match`. **An artist labels the oak
119
+ * in Blender and the log burns like oak**, with no code in between; `§16` of the chemistry design
120
+ * is the argument, and glTF's `extras` is the standard place for exactly this.
121
+ *
122
+ * Read as `unknown` and checked, because `extras` is whatever somebody's exporter wrote.
123
+ */
124
+ extras?: Record<string, unknown>;
125
+ }
126
+ /** An image, either inside the binary chunk or beside the document. */
127
+ interface GltfImage {
128
+ uri?: string;
129
+ bufferView?: number;
130
+ mimeType?: string;
131
+ name?: string;
132
+ }
133
+ /** A sampler paired with an image. Only the image is used; sampler state is the engine's. */
134
+ interface GltfTexture {
135
+ source?: number;
136
+ sampler?: number;
137
+ }
138
+ interface GltfNode {
139
+ mesh?: number;
140
+ /** The skin this node's mesh is deformed by. Its presence is what stops the bake. */
141
+ skin?: number;
142
+ children?: number[];
143
+ matrix?: number[];
144
+ translation?: number[];
145
+ rotation?: number[];
146
+ scale?: number[];
147
+ name?: string;
148
+ }
149
+ export interface GltfDocument {
150
+ asset?: {
151
+ version?: string;
152
+ generator?: string;
153
+ };
154
+ scene?: number;
155
+ scenes?: {
156
+ nodes?: number[];
157
+ }[];
158
+ nodes?: GltfNode[];
159
+ meshes?: {
160
+ primitives: GltfPrimitive[];
161
+ name?: string;
162
+ }[];
163
+ accessors?: GltfAccessor[];
164
+ bufferViews?: GltfBufferView[];
165
+ buffers?: {
166
+ byteLength: number;
167
+ uri?: string;
168
+ }[];
169
+ materials?: GltfMaterial[];
170
+ images?: GltfImage[];
171
+ textures?: GltfTexture[];
172
+ skins?: GltfSkinDef[];
173
+ animations?: GltfAnimationDef[];
174
+ }
175
+ /** A skin, as glTF declares one. `skeleton` is a hint this reader does not need and ignores. */
176
+ export interface GltfSkinDef {
177
+ joints: number[];
178
+ inverseBindMatrices?: number;
179
+ skeleton?: number;
180
+ name?: string;
181
+ }
182
+ export interface GltfAnimationDef {
183
+ name?: string;
184
+ samplers: {
185
+ input: number;
186
+ output: number;
187
+ interpolation?: string;
188
+ }[];
189
+ channels: {
190
+ sampler: number;
191
+ target: {
192
+ node?: number;
193
+ path?: string;
194
+ };
195
+ }[];
196
+ }
197
+ /**
198
+ * Split a `.glb` into its JSON and its binary chunk.
199
+ *
200
+ * A `.glb` is the same document as a `.gltf` with the JSON and the buffer packed into one
201
+ * file, which is why an asset store hands you both — and why preferring it costs nothing.
202
+ */
203
+ export declare function readGlb(buffer: ArrayBuffer): {
204
+ json: GltfDocument;
205
+ binary: Uint8Array | null;
206
+ };
207
+ /** Everything a document needs to be read: its buffers, in `buffers` order. */
208
+ export type BufferResolver = (index: number, uri: string | undefined) => Uint8Array;
209
+ /** What a caller can tell the reader about what it is going to do with the result. */
210
+ export interface GltfReadOptions {
211
+ /**
212
+ * Derive a tangent frame where a material declares a normal map and the file supplies none.
213
+ *
214
+ * **On by default, and the baker turns it off.** The derivation accumulates per index, so run
215
+ * on a mesh stored as one vertex per triangle corner it gives every corner its own frame and
216
+ * leaves a following weld nothing to merge — measured at 9,600 corners welding to 9,482 rather
217
+ * than 1,681. A caller that welds should decline here and call `deriveTangentsFor` afterwards,
218
+ * which is both a smaller mesh and a better frame, since that is the sharing the derivation
219
+ * exists to average over.
220
+ *
221
+ * A caller that does *not* weld — anything reading a model straight into a renderer — wants the
222
+ * default, or a normal-mapped model draws with no frame to sample the map along.
223
+ *
224
+ * A frame the file supplies is kept either way. This gates inventing one, never believing one.
225
+ */
226
+ readonly deriveTangents?: boolean;
227
+ }
228
+ /**
229
+ * Turn a document into meshes in world space, one per primitive.
230
+ *
231
+ * One `MeshData` per primitive rather than per glTF mesh, because a primitive is the unit
232
+ * that carries a single material — and a `MeshData` has one material's worth of vertex
233
+ * attributes. Merging them would mean losing the distinction the file was drawing.
234
+ */
235
+ export declare function gltfToMeshes(doc: GltfDocument, buffers: readonly Uint8Array[], options?: GltfReadOptions): {
236
+ meshes: MeshData[];
237
+ warnings: string[];
238
+ materials: DrftMaterial[];
239
+ textures: AssetReference[];
240
+ nodes: DrftNode[];
241
+ };
242
+ export {};