-
-
Notifications
You must be signed in to change notification settings - Fork 151
/
Copy pathconstants.ts
162 lines (142 loc) · 3.75 KB
/
constants.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
// Injected at compile time, from $npm_package_version.
declare const PACKAGE_VERSION: string;
/**
* Current version of the package.
* @hidden
*/
export const VERSION = `v${PACKAGE_VERSION}`;
/** @internal */
export const NAME = '@gltf-transform/core';
/**
* Interface allowing Accessor setter/getter methods to be used interchangeably with gl-matrix
* arrays or with three.js math objects' fromArray/toArray methods. For example, THREE.Vector2,
* THREE.Vector3, THREE.Vector4, THREE.Quaternion, THREE.Matrix3, THREE.Matrix4, and THREE.Color.
*
* @internal
*/
export interface ArrayProxy {
/** Sets the value of the object from an array of values. */
fromArray(array: number[]): ArrayProxy;
/** Writes the value of the object into the given array. */
toArray(array: number[]): number[];
}
/**
* TypeScript utility for nullable types.
* @hidden
*/
export type Nullable<T> = { [P in keyof T]: T[P] | null };
/**
* 2-dimensional vector.
* @hidden
*/
export type vec2 = [number, number];
/**
* 3-dimensional vector.
* @hidden
*/
export type vec3 = [number, number, number];
/**
* 4-dimensional vector, e.g. RGBA or a quaternion.
* @hidden
*/
export type vec4 = [number, number, number, number];
// prettier-ignore
/**
* 3x3 matrix, e.g. an affine transform of a 2D vector.
* @hidden
*/
export type mat3 = [
number, number, number,
number, number, number,
number, number, number,
];
// prettier-ignore
/**
* 4x4 matrix, e.g. an affine transform of a 3D vector.
* @hidden
*/
export type mat4 = [
number, number, number, number,
number, number, number, number,
number, number, number, number,
number, number, number, number,
];
/** @hidden */
export type bbox = { min: vec3; max: vec3 };
/** @hidden */
export const GLB_BUFFER = '@glb.bin';
/**
* Abstraction representing any one of the typed array classes supported by glTF and JavaScript.
* @hidden
*/
export type TypedArray = Float32Array | Uint32Array | Uint16Array | Uint8Array | Int16Array | Int8Array;
/**
* Abstraction representing the typed array constructors supported by glTF and JavaScript.
* @hidden
*/
export type TypedArrayConstructor =
| Float32ArrayConstructor
| Uint32ArrayConstructor
| Uint16ArrayConstructor
| Uint8ArrayConstructor
| Int16ArrayConstructor
| Int8ArrayConstructor;
/** String IDs for core {@link Property} types. */
export enum PropertyType {
ACCESSOR = 'Accessor',
ANIMATION = 'Animation',
ANIMATION_CHANNEL = 'AnimationChannel',
ANIMATION_SAMPLER = 'AnimationSampler',
BUFFER = 'Buffer',
CAMERA = 'Camera',
MATERIAL = 'Material',
MESH = 'Mesh',
PRIMITIVE = 'Primitive',
PRIMITIVE_TARGET = 'PrimitiveTarget',
NODE = 'Node',
ROOT = 'Root',
SCENE = 'Scene',
SKIN = 'Skin',
TEXTURE = 'Texture',
TEXTURE_INFO = 'TextureInfo',
}
/** Vertex layout method. */
export enum VertexLayout {
/**
* Stores vertex attributes in a single buffer view per mesh primitive. Interleaving vertex
* data may improve performance by reducing page-thrashing in GPU memory.
*/
INTERLEAVED = 'interleaved',
/**
* Stores each vertex attribute in a separate buffer view. May decrease performance by causing
* page-thrashing in GPU memory. Some 3D engines may prefer this layout, e.g. for simplicity.
*/
SEPARATE = 'separate',
}
/** Accessor usage. */
export enum BufferViewUsage {
ARRAY_BUFFER = 'ARRAY_BUFFER',
ELEMENT_ARRAY_BUFFER = 'ELEMENT_ARRAY_BUFFER',
INVERSE_BIND_MATRICES = 'INVERSE_BIND_MATRICES',
OTHER = 'OTHER',
SPARSE = 'SPARSE',
}
/** Texture channels. */
export enum TextureChannel {
R = 0x1000,
G = 0x0100,
B = 0x0010,
A = 0x0001,
}
export enum Format {
GLTF = 'GLTF',
GLB = 'GLB',
}
export const ComponentTypeToTypedArray = {
'5120': Int8Array,
'5121': Uint8Array,
'5122': Int16Array,
'5123': Uint16Array,
'5125': Uint32Array,
'5126': Float32Array,
};