-
Notifications
You must be signed in to change notification settings - Fork 7
/
GLTF.ts
684 lines (684 loc) · 17.5 KB
/
GLTF.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
export type GlTfId = number;
/**
* Indices of those attributes that deviate from their initialization value.
*/
export interface AccessorSparseIndices {
/**
* The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target.
*/
'bufferView': GlTfId;
/**
* The offset relative to the start of the bufferView in bytes. Must be aligned.
*/
'byteOffset'?: number;
/**
* The indices data type.
*/
'componentType': 5121 | 5123 | 5125 | number;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* Array of size `accessor.sparse.count` times number of components storing the displaced accessor attributes pointed by `accessor.sparse.indices`.
*/
export interface AccessorSparseValues {
/**
* The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target.
*/
'bufferView': GlTfId;
/**
* The offset relative to the start of the bufferView in bytes. Must be aligned.
*/
'byteOffset'?: number;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* Sparse storage of attributes that deviate from their initialization value.
*/
export interface AccessorSparse {
/**
* Number of entries stored in the sparse array.
*/
'count': number;
/**
* Index array of size `count` that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase.
*/
'indices': AccessorSparseIndices;
/**
* Array of size `count` times number of components, storing the displaced accessor attributes pointed by `indices`. Substituted values must have the same `componentType` and number of components as the base accessor.
*/
'values': AccessorSparseValues;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* A typed view into a bufferView. A bufferView contains raw binary data. An accessor provides a typed view into a bufferView or a subset of a bufferView similar to how WebGL's `vertexAttribPointer()` defines an attribute in a buffer.
*/
export interface Accessor {
/**
* The index of the bufferView.
*/
'bufferView'?: GlTfId;
/**
* The offset relative to the start of the bufferView in bytes.
*/
'byteOffset'?: number;
/**
* The datatype of components in the attribute.
*/
'componentType': 5120 | 5121 | 5122 | 5123 | 5125 | 5126 | number;
/**
* Specifies whether integer data values should be normalized.
*/
'normalized'?: boolean;
/**
* The number of attributes referenced by this accessor.
*/
'count': number;
/**
* Specifies if the attribute is a scalar, vector, or matrix.
*/
'type': 'SCALAR' | 'VEC2' | 'VEC3' | 'VEC4' | 'MAT2' | 'MAT3' | 'MAT4' | string;
/**
* Maximum value of each component in this attribute.
*/
'max'?: number[];
/**
* Minimum value of each component in this attribute.
*/
'min'?: number[];
/**
* Sparse storage of attributes that deviate from their initialization value.
*/
'sparse'?: AccessorSparse;
'name'?: any;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* The index of the node and TRS property that an animation channel targets.
*/
export interface AnimationChannelTarget {
/**
* The index of the node to target.
*/
'node'?: GlTfId;
/**
* The name of the node's TRS property to modify, or the "weights" of the Morph Targets it instantiates. For the "translation" property, the values that are provided by the sampler are the translation along the x, y, and z axes. For the "rotation" property, the values are a quaternion in the order (x, y, z, w), where w is the scalar. For the "scale" property, the values are the scaling factors along the x, y, and z axes.
*/
'path': 'translation' | 'rotation' | 'scale' | 'weights' | string;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* Targets an animation's sampler at a node's property.
*/
export interface AnimationChannel {
/**
* The index of a sampler in this animation used to compute the value for the target.
*/
'sampler': GlTfId;
/**
* The index of the node and TRS property to target.
*/
'target': AnimationChannelTarget;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target).
*/
export interface AnimationSampler {
/**
* The index of an accessor containing keyframe input values, e.g., time.
*/
'input': GlTfId;
/**
* Interpolation algorithm.
*/
'interpolation'?: 'LINEAR' | 'STEP' | 'CUBICSPLINE' | string;
/**
* The index of an accessor, containing keyframe output values.
*/
'output': GlTfId;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* A keyframe animation.
*/
export interface Animation {
/**
* An array of channels, each of which targets an animation's sampler at a node's property. Different channels of the same animation can't have equal targets.
*/
'channels': AnimationChannel[];
/**
* An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target).
*/
'samplers': AnimationSampler[];
'name'?: any;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* Metadata about the glTF asset.
*/
export interface Asset {
/**
* A copyright message suitable for display to credit the content creator.
*/
'copyright'?: string;
/**
* Tool that generated this glTF model. Useful for debugging.
*/
'generator'?: string;
/**
* The glTF version that this asset targets.
*/
'version': string;
/**
* The minimum glTF version that this asset targets.
*/
'minVersion'?: string;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* A buffer points to binary geometry, animation, or skins.
*/
export interface Buffer {
/**
* The uri of the buffer.
*/
'uri'?: string;
/**
* The length of the buffer in bytes.
*/
'byteLength': number;
'name'?: any;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* A view into a buffer generally representing a subset of the buffer.
*/
export interface BufferView {
/**
* The index of the buffer.
*/
'buffer': GlTfId;
/**
* The offset into the buffer in bytes.
*/
'byteOffset'?: number;
/**
* The length of the bufferView in bytes.
*/
'byteLength': number;
/**
* The stride, in bytes.
*/
'byteStride'?: number;
/**
* The target that the GPU buffer should be bound to.
*/
'target'?: 34962 | 34963 | number;
'name'?: any;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* An orthographic camera containing properties to create an orthographic projection matrix.
*/
export interface CameraOrthographic {
/**
* The floating-point horizontal magnification of the view. Must not be zero.
*/
'xmag': number;
/**
* The floating-point vertical magnification of the view. Must not be zero.
*/
'ymag': number;
/**
* The floating-point distance to the far clipping plane. `zfar` must be greater than `znear`.
*/
'zfar': number;
/**
* The floating-point distance to the near clipping plane.
*/
'znear': number;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* A perspective camera containing properties to create a perspective projection matrix.
*/
export interface CameraPerspective {
/**
* The floating-point aspect ratio of the field of view.
*/
'aspectRatio'?: number;
/**
* The floating-point vertical field of view in radians.
*/
'yfov': number;
/**
* The floating-point distance to the far clipping plane.
*/
'zfar'?: number;
/**
* The floating-point distance to the near clipping plane.
*/
'znear': number;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene.
*/
export interface Camera {
/**
* An orthographic camera containing properties to create an orthographic projection matrix.
*/
'orthographic'?: CameraOrthographic;
/**
* A perspective camera containing properties to create a perspective projection matrix.
*/
'perspective'?: CameraPerspective;
/**
* Specifies if the camera uses a perspective or orthographic projection.
*/
'type': 'perspective' | 'orthographic' | string;
'name'?: any;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* Image data used to create a texture. Image can be referenced by URI or `bufferView` index. `mimeType` is required in the latter case.
*/
export interface Image {
/**
* The uri of the image.
*/
'uri'?: string;
/**
* The image's MIME type.
*/
'mimeType'?: 'image/jpeg' | 'image/png' | string;
/**
* The index of the bufferView that contains the image. Use this instead of the image's uri property.
*/
'bufferView'?: GlTfId;
'name'?: any;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* Reference to a texture.
*/
export interface TextureInfo {
/**
* The index of the texture.
*/
'index': GlTfId;
/**
* The set index of texture's TEXCOORD attribute used for texture coordinate mapping.
*/
'texCoord'?: number;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology.
*/
export interface MaterialPbrMetallicRoughness {
/**
* The material's base color factor.
*/
'baseColorFactor'?: number[];
/**
* The base color texture.
*/
'baseColorTexture'?: TextureInfo;
/**
* The metalness of the material.
*/
'metallicFactor'?: number;
/**
* The roughness of the material.
*/
'roughnessFactor'?: number;
/**
* The metallic-roughness texture.
*/
'metallicRoughnessTexture'?: TextureInfo;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
export interface MaterialNormalTextureInfo {
'index'?: any;
'texCoord'?: any;
/**
* The scalar multiplier applied to each normal vector of the normal texture.
*/
'scale'?: number;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
export interface MaterialOcclusionTextureInfo {
'index'?: any;
'texCoord'?: any;
/**
* A scalar multiplier controlling the amount of occlusion applied.
*/
'strength'?: number;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* The material appearance of a primitive.
*/
export abstract class Material {
'name'?: any;
'extensions'?: any;
'extras'?: any;
/**
* A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology. When not specified, all the default values of `pbrMetallicRoughness` apply.
*/
'pbrMetallicRoughness'?: MaterialPbrMetallicRoughness;
/**
* The normal map texture.
*/
'normalTexture'?: MaterialNormalTextureInfo;
/**
* The occlusion map texture.
*/
'occlusionTexture'?: MaterialOcclusionTextureInfo;
/**
* The emissive map texture.
*/
'emissiveTexture'?: TextureInfo;
/**
* The emissive color of the material.
*/
'emissiveFactor'?: number[];
/**
* The alpha rendering mode of the material.
*/
'alphaMode'?: 'OPAQUE' | 'MASK' | 'BLEND' | string;
/**
* The alpha cutoff value of the material.
*/
'alphaCutoff'?: number;
/**
* Specifies whether the material is double sided.
*/
'doubleSided'?: boolean;
[k: string]: any;
}
/**
* Geometry to be rendered with the given material.
*/
export interface MeshPrimitive {
/**
* A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data.
*/
'attributes': {
[k: string]: GlTfId;
};
/**
* The index of the accessor that contains the indices.
*/
'indices'?: GlTfId;
/**
* The index of the material to apply to this primitive when rendering.
*/
'material'?: GlTfId;
/**
* The type of primitives to render.
*/
'mode'?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | number;
/**
* An array of Morph Targets, each Morph Target is a dictionary mapping attributes (only `POSITION`, `NORMAL`, and `TANGENT` supported) to their deviations in the Morph Target.
*/
'targets'?: {
[k: string]: GlTfId;
}[];
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene.
*/
export interface Mesh {
/**
* An array of primitives, each defining geometry to be rendered with a material.
*/
'primitives': MeshPrimitive[];
/**
* Array of weights to be applied to the Morph Targets.
*/
'weights'?: number[];
'name'?: any;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* A node in the node hierarchy. When the node contains `skin`, all `mesh.primitives` must contain `JOINTS_0` and `WEIGHTS_0` attributes. A node can have either a `matrix` or any combination of `translation`/`rotation`/`scale` (TRS) properties. TRS properties are converted to matrices and postmultiplied in the `T * R * S` order to compose the transformation matrix; first the scale is applied to the vertices, then the rotation, and then the translation. If none are provided, the transform is the identity. When a node is targeted for animation (referenced by an animation.channel.target), only TRS properties may be present; `matrix` will not be present.
*/
export interface Node {
/**
* The index of the camera referenced by this node.
*/
'camera'?: GlTfId;
/**
* The indices of this node's children.
*/
'children'?: GlTfId[];
/**
* The index of the skin referenced by this node.
*/
'skin'?: GlTfId;
/**
* A floating-point 4x4 transformation matrix stored in column-major order.
*/
'matrix'?: number[];
/**
* The index of the mesh in this node.
*/
'mesh'?: GlTfId;
/**
* The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar.
*/
'rotation'?: number[];
/**
* The node's non-uniform scale, given as the scaling factors along the x, y, and z axes.
*/
'scale'?: number[];
/**
* The node's translation along the x, y, and z axes.
*/
'translation'?: number[];
/**
* The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh.
*/
'weights'?: number[];
'name'?: any;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* Texture sampler properties for filtering and wrapping modes.
*/
export interface Sampler {
/**
* Magnification filter.
*/
'magFilter'?: 9728 | 9729 | number;
/**
* Minification filter.
*/
'minFilter'?: 9728 | 9729 | 9984 | 9985 | 9986 | 9987 | number;
/**
* s wrapping mode.
*/
'wrapS'?: 33071 | 33648 | 10497 | number;
/**
* t wrapping mode.
*/
'wrapT'?: 33071 | 33648 | 10497 | number;
'name'?: any;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* The root nodes of a scene.
*/
export interface Scene {
/**
* The indices of each root node.
*/
'nodes'?: GlTfId[];
'name'?: any;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* Joints and matrices defining a skin.
*/
export interface Skin {
/**
* The index of the accessor containing the floating-point 4x4 inverse-bind matrices. The default is that each matrix is a 4x4 identity matrix, which implies that inverse-bind matrices were pre-applied.
*/
'inverseBindMatrices'?: GlTfId;
/**
* The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root.
*/
'skeleton'?: GlTfId;
/**
* Indices of skeleton nodes, used as joints in this skin.
*/
'joints': GlTfId[];
'name'?: any;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* A texture and its sampler.
*/
export interface Texture {
/**
* The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used.
*/
'sampler'?: GlTfId;
/**
* The index of the image used by this texture.
*/
'source'?: GlTfId;
'name'?: any;
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}
/**
* The root object for a glTF asset.
*/
export interface GlTf {
/**
* Names of glTF extensions used somewhere in this asset.
*/
'extensionsUsed'?: string[];
/**
* Names of glTF extensions required to properly load this asset.
*/
'extensionsRequired'?: string[];
/**
* An array of accessors.
*/
'accessors'?: Accessor[];
/**
* An array of keyframe animations.
*/
'animations'?: Animation[];
/**
* Metadata about the glTF asset.
*/
'asset': Asset;
/**
* An array of buffers.
*/
'buffers'?: Buffer[];
/**
* An array of bufferViews.
*/
'bufferViews'?: BufferView[];
/**
* An array of cameras.
*/
'cameras'?: Camera[];
/**
* An array of images.
*/
'images'?: Image[];
/**
* An array of materials.
*/
'materials'?: Material[];
/**
* An array of meshes.
*/
'meshes'?: Mesh[];
/**
* An array of nodes.
*/
'nodes'?: Node[];
/**
* An array of samplers.
*/
'samplers'?: Sampler[];
/**
* The index of the default scene.
*/
'scene'?: GlTfId;
/**
* An array of scenes.
*/
'scenes'?: Scene[];
/**
* An array of skins.
*/
'skins'?: Skin[];
/**
* An array of textures.
*/
'textures'?: Texture[];
'extensions'?: any;
'extras'?: any;
[k: string]: any;
}