@loaders.gl/gltf 3.0.12 → 3.1.0-alpha.4
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.
- package/dist/dist.min.js +1 -1
- package/dist/dist.min.js.map +1 -1
- package/dist/es5/bundle.js +2 -4
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/gltf-loader.js.map +1 -1
- package/dist/es5/index.js +0 -8
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/lib/api/gltf-extensions.js +146 -0
- package/dist/es5/lib/api/gltf-extensions.js.map +1 -0
- package/dist/es5/lib/api/gltf-scenegraph.js.map +1 -1
- package/dist/es5/lib/api/normalize-gltf-v1.js +1 -1
- package/dist/es5/lib/api/normalize-gltf-v1.js.map +1 -1
- package/dist/es5/lib/extensions/EXT_meshopt_compression.js +32 -21
- package/dist/es5/lib/extensions/EXT_meshopt_compression.js.map +1 -1
- package/dist/es5/lib/extensions/EXT_texture_webp.js +60 -0
- package/dist/es5/lib/extensions/EXT_texture_webp.js.map +1 -0
- package/dist/es5/lib/extensions/KHR_binary_gltf.js +13 -13
- package/dist/es5/lib/extensions/KHR_binary_gltf.js.map +1 -1
- package/dist/es5/lib/extensions/KHR_draco_mesh_compression.js +55 -32
- package/dist/es5/lib/extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/dist/es5/lib/extensions/KHR_texture_basisu.js +49 -0
- package/dist/es5/lib/extensions/KHR_texture_basisu.js.map +1 -0
- package/dist/es5/lib/extensions/{KHR_lights_punctual.js → deprecated/KHR_lights_punctual.js} +13 -10
- package/dist/es5/lib/extensions/deprecated/KHR_lights_punctual.js.map +1 -0
- package/dist/es5/lib/extensions/{KHR_materials_unlit.js → deprecated/KHR_materials_unlit.js} +10 -7
- package/dist/es5/lib/extensions/deprecated/KHR_materials_unlit.js.map +1 -0
- package/dist/es5/lib/extensions/{KHR_techniques_webgl.js → deprecated/KHR_techniques_webgl.js} +10 -7
- package/dist/es5/lib/extensions/deprecated/KHR_techniques_webgl.js.map +1 -0
- package/dist/es5/lib/gltf-utils/gltf-constants.js +0 -13
- package/dist/es5/lib/gltf-utils/gltf-constants.js.map +1 -1
- package/dist/es5/lib/parsers/parse-gltf.js +71 -28
- package/dist/es5/lib/parsers/parse-gltf.js.map +1 -1
- package/dist/es5/lib/utils/version.js +1 -1
- package/dist/es5/lib/utils/version.js.map +1 -1
- package/dist/es5/webp/webp.js +104 -0
- package/dist/es5/webp/webp.js.map +1 -0
- package/dist/esm/bundle.js +2 -4
- package/dist/esm/bundle.js.map +1 -1
- package/dist/esm/gltf-loader.js.map +1 -1
- package/dist/esm/index.js +0 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/api/gltf-extensions.js +35 -0
- package/dist/esm/lib/api/gltf-extensions.js.map +1 -0
- package/dist/esm/lib/api/gltf-scenegraph.js.map +1 -1
- package/dist/esm/lib/api/normalize-gltf-v1.js +1 -1
- package/dist/esm/lib/api/normalize-gltf-v1.js.map +1 -1
- package/dist/esm/lib/extensions/EXT_meshopt_compression.js +16 -8
- package/dist/esm/lib/extensions/EXT_meshopt_compression.js.map +1 -1
- package/dist/esm/lib/extensions/EXT_texture_webp.js +32 -0
- package/dist/esm/lib/extensions/EXT_texture_webp.js.map +1 -0
- package/dist/esm/lib/extensions/KHR_binary_gltf.js +8 -8
- package/dist/esm/lib/extensions/KHR_binary_gltf.js.map +1 -1
- package/dist/esm/lib/extensions/KHR_draco_mesh_compression.js +9 -1
- package/dist/esm/lib/extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/dist/esm/lib/extensions/KHR_texture_basisu.js +22 -0
- package/dist/esm/lib/extensions/KHR_texture_basisu.js.map +1 -0
- package/dist/esm/lib/extensions/{KHR_lights_punctual.js → deprecated/KHR_lights_punctual.js} +4 -3
- package/dist/esm/lib/extensions/deprecated/KHR_lights_punctual.js.map +1 -0
- package/dist/esm/lib/extensions/{KHR_materials_unlit.js → deprecated/KHR_materials_unlit.js} +3 -2
- package/dist/esm/lib/extensions/deprecated/KHR_materials_unlit.js.map +1 -0
- package/dist/esm/lib/extensions/{KHR_techniques_webgl.js → deprecated/KHR_techniques_webgl.js} +3 -2
- package/dist/esm/lib/extensions/deprecated/KHR_techniques_webgl.js.map +1 -0
- package/dist/esm/lib/gltf-utils/gltf-constants.js +0 -6
- package/dist/esm/lib/gltf-utils/gltf-constants.js.map +1 -1
- package/dist/esm/lib/parsers/parse-gltf.js +23 -5
- package/dist/esm/lib/parsers/parse-gltf.js.map +1 -1
- package/dist/esm/lib/utils/version.js +1 -1
- package/dist/esm/lib/utils/version.js.map +1 -1
- package/dist/esm/webp/webp.js +29 -0
- package/dist/esm/webp/webp.js.map +1 -0
- package/package.json +6 -6
- package/src/bundle.ts +2 -3
- package/src/gltf-loader.ts +7 -4
- package/src/index.ts +8 -4
- package/src/lib/api/gltf-extensions.ts +71 -0
- package/src/lib/api/gltf-scenegraph.ts +4 -6
- package/src/lib/api/normalize-gltf-v1.js +2 -1
- package/src/lib/extensions/EXT_meshopt_compression.ts +32 -23
- package/src/lib/extensions/EXT_texture_webp.ts +45 -0
- package/src/lib/extensions/KHR_binary_gltf.ts +19 -10
- package/src/lib/extensions/KHR_draco_mesh_compression.ts +31 -11
- package/src/lib/extensions/KHR_texture_basisu.ts +36 -0
- package/src/lib/extensions/{KHR_lights_punctual.ts → deprecated/KHR_lights_punctual.ts} +7 -4
- package/src/lib/extensions/{KHR_materials_unlit.ts → deprecated/KHR_materials_unlit.ts} +6 -3
- package/src/lib/extensions/{KHR_techniques_webgl.ts → deprecated/KHR_techniques_webgl.ts} +6 -3
- package/src/lib/gltf-utils/gltf-constants.ts +0 -12
- package/src/lib/parsers/parse-gltf.ts +55 -19
- package/src/lib/types/gltf-json-schema.ts +96 -3
- package/src/lib/types/gltf-types.ts +19 -21
- package/src/webp/webp.ts +41 -0
- package/dist/dist.es5.min.js +0 -2
- package/dist/dist.es5.min.js.map +0 -1
- package/dist/es5/lib/extensions/KHR_lights_punctual.js.map +0 -1
- package/dist/es5/lib/extensions/KHR_materials_unlit.js.map +0 -1
- package/dist/es5/lib/extensions/KHR_techniques_webgl.js.map +0 -1
- package/dist/es5/lib/extensions/gltf-extensions.js +0 -92
- package/dist/es5/lib/extensions/gltf-extensions.js.map +0 -1
- package/dist/esm/lib/extensions/KHR_lights_punctual.js.map +0 -1
- package/dist/esm/lib/extensions/KHR_materials_unlit.js.map +0 -1
- package/dist/esm/lib/extensions/KHR_techniques_webgl.js.map +0 -1
- package/dist/esm/lib/extensions/gltf-extensions.js +0 -24
- package/dist/esm/lib/extensions/gltf-extensions.js.map +0 -1
- package/src/lib/extensions/gltf-extensions.ts +0 -48
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
// GLTF EXTENSION: KHR_techniques_webgl
|
|
2
2
|
// https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_techniques_webgl
|
|
3
3
|
|
|
4
|
-
import type {GLTF} from '
|
|
4
|
+
import type {GLTF} from '../../types/gltf-types';
|
|
5
5
|
|
|
6
|
-
import GLTFScenegraph from '
|
|
7
|
-
|
|
6
|
+
import GLTFScenegraph from '../../api/gltf-scenegraph';
|
|
7
|
+
|
|
8
|
+
const KHR_TECHNIQUES_WEBGL = 'KHR_techniques_webgl';
|
|
9
|
+
|
|
10
|
+
export const name = KHR_TECHNIQUES_WEBGL;
|
|
8
11
|
|
|
9
12
|
export async function decode(gltfData: {json: GLTF}): Promise<void> {
|
|
10
13
|
const gltfScenegraph = new GLTFScenegraph(gltfData);
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
// GLTF 1.0 extensions
|
|
2
|
-
export const KHR_BINARY_GLTF = 'KHR_binary_glTF';
|
|
3
|
-
|
|
4
|
-
// GLTF 2.0 extensions
|
|
5
|
-
export const KHR_DRACO_MESH_COMPRESSION = 'KHR_draco_mesh_compression';
|
|
6
|
-
export const KHR_LIGHTS_PUNCTUAL = 'KHR_lights_punctual';
|
|
7
|
-
export const KHR_MATERIALS_UNLIT = 'KHR_materials_unlit';
|
|
8
|
-
export const KHR_TECHNIQUES_WEBGL = 'KHR_techniques_webgl';
|
|
9
|
-
|
|
10
|
-
// External extensions
|
|
11
|
-
export const EXT_MESHOPT_COMPRESSION = 'EXT_meshopt_compression';
|
|
12
|
-
|
|
13
1
|
const COMPONENTS = {
|
|
14
2
|
SCALAR: 1,
|
|
15
3
|
VEC2: 2,
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
/* eslint-disable camelcase, max-statements, no-restricted-globals */
|
|
2
2
|
import type {LoaderContext} from '@loaders.gl/loader-utils';
|
|
3
|
+
import type {GLTFLoaderOptions} from '../../gltf-loader';
|
|
3
4
|
import type {GLB} from '../types/glb-types';
|
|
4
|
-
import type {
|
|
5
|
+
import type {GLTFWithBuffers} from '../types/gltf-types';
|
|
5
6
|
|
|
6
7
|
import {ImageLoader} from '@loaders.gl/images';
|
|
7
8
|
import {parseJSON, sliceArrayBuffer} from '@loaders.gl/loader-utils';
|
|
8
9
|
import {assert} from '../utils/assert';
|
|
9
10
|
import {resolveUrl} from '../gltf-utils/resolve-url';
|
|
10
11
|
import {getTypedArrayForBufferView} from '../gltf-utils/get-typed-array';
|
|
11
|
-
import {decodeExtensions} from '../
|
|
12
|
+
import {preprocessExtensions, decodeExtensions} from '../api/gltf-extensions';
|
|
12
13
|
import {normalizeGLTFV1} from '../api/normalize-gltf-v1';
|
|
13
14
|
import {postProcessGLTF} from '../api/post-process-gltf';
|
|
14
15
|
import parseGLBSync, {isGLB} from './parse-glb';
|
|
15
16
|
|
|
16
17
|
export type GLTFParseOptions = {
|
|
17
|
-
excludeExtensions?: string[];
|
|
18
|
-
decompressMeshes?: boolean;
|
|
19
18
|
normalize?: boolean;
|
|
20
|
-
loadBuffers?: boolean;
|
|
21
19
|
loadImages?: boolean;
|
|
20
|
+
loadBuffers?: boolean;
|
|
21
|
+
decompressMeshes?: boolean;
|
|
22
22
|
postProcess?: boolean;
|
|
23
|
+
excludeExtensions?: string[];
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
// export type GLTFOptions = {
|
|
@@ -32,19 +33,18 @@ export function isGLTF(arrayBuffer, options?): boolean {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
export async function parseGLTF(
|
|
35
|
-
gltf,
|
|
36
|
+
gltf: GLTFWithBuffers,
|
|
36
37
|
arrayBufferOrString,
|
|
37
38
|
byteOffset = 0,
|
|
38
|
-
options:
|
|
39
|
-
gltf?: GLTFParseOptions;
|
|
40
|
-
glb?: GLBParseOptions;
|
|
41
|
-
},
|
|
39
|
+
options: GLTFLoaderOptions,
|
|
42
40
|
context: LoaderContext
|
|
43
41
|
) {
|
|
44
42
|
parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options);
|
|
45
43
|
|
|
46
44
|
normalizeGLTFV1(gltf, {normalize: options?.gltf?.normalize});
|
|
47
45
|
|
|
46
|
+
preprocessExtensions(gltf, options, context);
|
|
47
|
+
|
|
48
48
|
const promises: Promise<any>[] = [];
|
|
49
49
|
|
|
50
50
|
// Load linked buffers asynchronously and decodes base64 buffers in parallel
|
|
@@ -120,10 +120,14 @@ function parseGLTFContainerSync(gltf, data, byteOffset, options) {
|
|
|
120
120
|
gltf.images = new Array(images.length).fill({});
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
123
|
+
/** Asynchronously fetch and parse buffers, store in buffers array outside of json
|
|
124
|
+
* TODO - traverse gltf and determine which buffers are actually needed
|
|
125
|
+
*/
|
|
126
|
+
async function loadBuffers(gltf: GLTFWithBuffers, options, context: LoaderContext) {
|
|
127
|
+
// TODO
|
|
128
|
+
const buffers = gltf.json.buffers || [];
|
|
129
|
+
for (let i = 0; i < buffers.length; ++i) {
|
|
130
|
+
const buffer = buffers[i];
|
|
127
131
|
if (buffer.uri) {
|
|
128
132
|
const {fetch} = context;
|
|
129
133
|
assert(fetch);
|
|
@@ -143,19 +147,49 @@ async function loadBuffers(gltf, options, context: LoaderContext) {
|
|
|
143
147
|
}
|
|
144
148
|
}
|
|
145
149
|
|
|
146
|
-
|
|
150
|
+
/**
|
|
151
|
+
* Loads all images
|
|
152
|
+
* TODO - traverse gltf and determine which images are actually needed
|
|
153
|
+
* @param gltf
|
|
154
|
+
* @param options
|
|
155
|
+
* @param context
|
|
156
|
+
* @returns
|
|
157
|
+
*/
|
|
158
|
+
async function loadImages(gltf: GLTFWithBuffers, options, context: LoaderContext) {
|
|
159
|
+
const imageIndices = getReferencesImageIndices(gltf);
|
|
160
|
+
|
|
147
161
|
const images = gltf.json.images || [];
|
|
148
162
|
|
|
149
163
|
const promises: Promise<any>[] = [];
|
|
150
|
-
for (
|
|
151
|
-
promises.push(loadImage(gltf, images[
|
|
164
|
+
for (const imageIndex of imageIndices) {
|
|
165
|
+
promises.push(loadImage(gltf, images[imageIndex], imageIndex, options, context));
|
|
152
166
|
}
|
|
153
167
|
|
|
154
168
|
return await Promise.all(promises);
|
|
155
169
|
}
|
|
156
170
|
|
|
157
|
-
|
|
158
|
-
|
|
171
|
+
/** Make sure we only load images that are actually referenced by textures */
|
|
172
|
+
function getReferencesImageIndices(gltf: GLTFWithBuffers): number[] {
|
|
173
|
+
const imageIndices = new Set<number>();
|
|
174
|
+
|
|
175
|
+
const textures = gltf.json.textures || [];
|
|
176
|
+
for (const texture of textures) {
|
|
177
|
+
if (texture.source !== undefined) {
|
|
178
|
+
imageIndices.add(texture.source);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return Array.from(imageIndices).sort();
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Asynchronously fetches and parses one image, store in images array outside of json */
|
|
186
|
+
async function loadImage(
|
|
187
|
+
gltf: GLTFWithBuffers,
|
|
188
|
+
image,
|
|
189
|
+
index: number,
|
|
190
|
+
options,
|
|
191
|
+
context: LoaderContext
|
|
192
|
+
) {
|
|
159
193
|
const {fetch, parse} = context;
|
|
160
194
|
|
|
161
195
|
let arrayBuffer;
|
|
@@ -178,5 +212,7 @@ async function loadImage(gltf, image, index: number, options, context: LoaderCon
|
|
|
178
212
|
// TODO making sure ImageLoader is overridable by using array of loaders
|
|
179
213
|
// const parsedImage = await parse(arrayBuffer, [ImageLoader]);
|
|
180
214
|
|
|
215
|
+
// Store the loaded image
|
|
216
|
+
gltf.images = gltf.images || [];
|
|
181
217
|
gltf.images[index] = parsedImage;
|
|
182
218
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
// Types forked from https://github.com/bwasty/gltf-loader-ts under MIT license
|
|
2
2
|
// Generated from official JSON schema using `npm run generate-interface` on 2018-02-24
|
|
3
3
|
|
|
4
|
-
// tslint:disable:quotemark
|
|
5
|
-
// tslint:disable:max-line-length
|
|
6
|
-
|
|
7
4
|
export type GLTFId = number;
|
|
5
|
+
|
|
8
6
|
/**
|
|
9
7
|
* Indices of those attributes that deviate from their initialization value.
|
|
10
8
|
*/
|
|
@@ -25,6 +23,7 @@ export interface AccessorSparseIndices {
|
|
|
25
23
|
extras?: any;
|
|
26
24
|
// [k: string]: any;
|
|
27
25
|
}
|
|
26
|
+
|
|
28
27
|
/**
|
|
29
28
|
* Array of size `accessor.sparse.count` times number of components storing the displaced accessor attributes pointed by `accessor.sparse.indices`.
|
|
30
29
|
*/
|
|
@@ -41,6 +40,7 @@ export interface AccessorSparseValues {
|
|
|
41
40
|
extras?: any;
|
|
42
41
|
// [k: string]: any;
|
|
43
42
|
}
|
|
43
|
+
|
|
44
44
|
/**
|
|
45
45
|
* Sparse storage of attributes that deviate from their initialization value.
|
|
46
46
|
*/
|
|
@@ -61,6 +61,7 @@ export interface AccessorSparse {
|
|
|
61
61
|
extras?: any;
|
|
62
62
|
// [k: string]: any;
|
|
63
63
|
}
|
|
64
|
+
|
|
64
65
|
/**
|
|
65
66
|
* 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.
|
|
66
67
|
*/
|
|
@@ -106,6 +107,7 @@ export interface Accessor {
|
|
|
106
107
|
extras?: any;
|
|
107
108
|
// [k: string]: any;
|
|
108
109
|
}
|
|
110
|
+
|
|
109
111
|
/**
|
|
110
112
|
* The index of the node and TRS property that an animation channel targets.
|
|
111
113
|
*/
|
|
@@ -122,6 +124,7 @@ export interface AnimationChannelTarget {
|
|
|
122
124
|
extras?: any;
|
|
123
125
|
// [k: string]: any;
|
|
124
126
|
}
|
|
127
|
+
|
|
125
128
|
/**
|
|
126
129
|
* Targets an animation's sampler at a node's property.
|
|
127
130
|
*/
|
|
@@ -138,6 +141,7 @@ export interface AnimationChannel {
|
|
|
138
141
|
extras?: any;
|
|
139
142
|
// [k: string]: any;
|
|
140
143
|
}
|
|
144
|
+
|
|
141
145
|
/**
|
|
142
146
|
* Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target).
|
|
143
147
|
*/
|
|
@@ -158,6 +162,7 @@ export interface AnimationSampler {
|
|
|
158
162
|
extras?: any;
|
|
159
163
|
// [k: string]: any;
|
|
160
164
|
}
|
|
165
|
+
|
|
161
166
|
/**
|
|
162
167
|
* A keyframe animation.
|
|
163
168
|
*/
|
|
@@ -175,6 +180,7 @@ export interface Animation {
|
|
|
175
180
|
extras?: any;
|
|
176
181
|
// [k: string]: any;
|
|
177
182
|
}
|
|
183
|
+
|
|
178
184
|
/**
|
|
179
185
|
* Metadata about the glTF asset.
|
|
180
186
|
*/
|
|
@@ -199,6 +205,7 @@ export interface Asset {
|
|
|
199
205
|
extras?: any;
|
|
200
206
|
// [k: string]: any;
|
|
201
207
|
}
|
|
208
|
+
|
|
202
209
|
/**
|
|
203
210
|
* A buffer points to binary geometry, animation, or skins.
|
|
204
211
|
*/
|
|
@@ -216,6 +223,7 @@ export interface Buffer {
|
|
|
216
223
|
extras?: any;
|
|
217
224
|
// [k: string]: any;
|
|
218
225
|
}
|
|
226
|
+
|
|
219
227
|
/**
|
|
220
228
|
* A view into a buffer generally representing a subset of the buffer.
|
|
221
229
|
*/
|
|
@@ -245,6 +253,7 @@ export interface BufferView {
|
|
|
245
253
|
extras?: any;
|
|
246
254
|
// [k: string]: any;
|
|
247
255
|
}
|
|
256
|
+
|
|
248
257
|
/**
|
|
249
258
|
* An orthographic camera containing properties to create an orthographic projection matrix.
|
|
250
259
|
*/
|
|
@@ -269,6 +278,7 @@ export interface CameraOrthographic {
|
|
|
269
278
|
extras?: any;
|
|
270
279
|
// [k: string]: any;
|
|
271
280
|
}
|
|
281
|
+
|
|
272
282
|
/**
|
|
273
283
|
* A perspective camera containing properties to create a perspective projection matrix.
|
|
274
284
|
*/
|
|
@@ -293,6 +303,7 @@ export interface CameraPerspective {
|
|
|
293
303
|
extras?: any;
|
|
294
304
|
// [k: string]: any;
|
|
295
305
|
}
|
|
306
|
+
|
|
296
307
|
/**
|
|
297
308
|
* A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene.
|
|
298
309
|
*/
|
|
@@ -314,6 +325,7 @@ export interface Camera {
|
|
|
314
325
|
extras?: any;
|
|
315
326
|
// [k: string]: any;
|
|
316
327
|
}
|
|
328
|
+
|
|
317
329
|
/**
|
|
318
330
|
* Image data used to create a texture. Image can be referenced by URI or `bufferView` index. `mimeType` is required in the latter case.
|
|
319
331
|
*/
|
|
@@ -335,6 +347,7 @@ export interface Image {
|
|
|
335
347
|
extras?: any;
|
|
336
348
|
// [k: string]: any;
|
|
337
349
|
}
|
|
350
|
+
|
|
338
351
|
/**
|
|
339
352
|
* Reference to a texture.
|
|
340
353
|
*/
|
|
@@ -351,6 +364,7 @@ export interface TextureInfo {
|
|
|
351
364
|
extras?: any;
|
|
352
365
|
// [k: string]: any;
|
|
353
366
|
}
|
|
367
|
+
|
|
354
368
|
/**
|
|
355
369
|
* A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology.
|
|
356
370
|
*/
|
|
@@ -401,6 +415,7 @@ export interface MaterialOcclusionTextureInfo {
|
|
|
401
415
|
extras?: any;
|
|
402
416
|
// [k: string]: any;
|
|
403
417
|
}
|
|
418
|
+
|
|
404
419
|
/**
|
|
405
420
|
* The material appearance of a primitive.
|
|
406
421
|
*/
|
|
@@ -442,6 +457,7 @@ export interface Material {
|
|
|
442
457
|
doubleSided?: boolean;
|
|
443
458
|
// [k: string]: any;
|
|
444
459
|
}
|
|
460
|
+
|
|
445
461
|
/**
|
|
446
462
|
* Geometry to be rendered with the given material.
|
|
447
463
|
*/
|
|
@@ -474,6 +490,7 @@ export interface MeshPrimitive {
|
|
|
474
490
|
extras?: any;
|
|
475
491
|
// [k: string]: any;
|
|
476
492
|
}
|
|
493
|
+
|
|
477
494
|
/**
|
|
478
495
|
* A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene.
|
|
479
496
|
*/
|
|
@@ -493,6 +510,7 @@ export interface Mesh {
|
|
|
493
510
|
extras?: any;
|
|
494
511
|
// [k: string]: any;
|
|
495
512
|
}
|
|
513
|
+
|
|
496
514
|
/**
|
|
497
515
|
* 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.
|
|
498
516
|
*/
|
|
@@ -538,6 +556,7 @@ export interface Node {
|
|
|
538
556
|
extras?: any;
|
|
539
557
|
// [k: string]: any;
|
|
540
558
|
}
|
|
559
|
+
|
|
541
560
|
/**
|
|
542
561
|
* Texture sampler properties for filtering and wrapping modes.
|
|
543
562
|
*/
|
|
@@ -563,6 +582,7 @@ export interface Sampler {
|
|
|
563
582
|
extras?: any;
|
|
564
583
|
// [k: string]: any;
|
|
565
584
|
}
|
|
585
|
+
|
|
566
586
|
/**
|
|
567
587
|
* The root nodes of a scene.
|
|
568
588
|
*/
|
|
@@ -576,6 +596,7 @@ export interface Scene {
|
|
|
576
596
|
extras?: any;
|
|
577
597
|
// [k: string]: any;
|
|
578
598
|
}
|
|
599
|
+
|
|
579
600
|
/**
|
|
580
601
|
* Joints and matrices defining a skin.
|
|
581
602
|
*/
|
|
@@ -597,6 +618,7 @@ export interface Skin {
|
|
|
597
618
|
extras?: any;
|
|
598
619
|
// [k: string]: any;
|
|
599
620
|
}
|
|
621
|
+
|
|
600
622
|
/**
|
|
601
623
|
* A texture and its sampler.
|
|
602
624
|
*/
|
|
@@ -614,6 +636,7 @@ export interface Texture {
|
|
|
614
636
|
extras?: any;
|
|
615
637
|
// [k: string]: any;
|
|
616
638
|
}
|
|
639
|
+
|
|
617
640
|
/**
|
|
618
641
|
* The root object for a glTF asset.
|
|
619
642
|
*/
|
|
@@ -690,3 +713,73 @@ export interface GLTF {
|
|
|
690
713
|
extras?: any;
|
|
691
714
|
// [k: string]: any;
|
|
692
715
|
}
|
|
716
|
+
|
|
717
|
+
// GLTF Extensions
|
|
718
|
+
/* eslint-disable camelcase */
|
|
719
|
+
|
|
720
|
+
/**
|
|
721
|
+
* @see https://github.com/KhronosGroup/glTF/tree/master/extensions/1.0/Khronos/KHR_binary_glTF
|
|
722
|
+
* TODO - this can be used on both images and shaders
|
|
723
|
+
*/
|
|
724
|
+
export type GLTF_KHR_binary_glTF = {
|
|
725
|
+
bufferView: number;
|
|
726
|
+
// required for images but not shaders
|
|
727
|
+
mimeType?: string;
|
|
728
|
+
height?: number;
|
|
729
|
+
width?: number;
|
|
730
|
+
extras?: any;
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* @see https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression
|
|
735
|
+
*/
|
|
736
|
+
export type GLTF_KHR_draco_mesh_compression = {
|
|
737
|
+
bufferView: GLTFId;
|
|
738
|
+
attributes: {[name: string]: number};
|
|
739
|
+
extras?: any;
|
|
740
|
+
};
|
|
741
|
+
|
|
742
|
+
/**
|
|
743
|
+
* @see https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_texture_basisu
|
|
744
|
+
*/
|
|
745
|
+
export type GLTF_KHR_texture_basisu = {
|
|
746
|
+
source: GLTFId;
|
|
747
|
+
extras?: any;
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
/**
|
|
751
|
+
* @see https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression
|
|
752
|
+
* buffer: number; // The index of the buffer with compressed data. ✅ Required
|
|
753
|
+
* byteOffset integer The offset into the buffer in bytes. Default: 0
|
|
754
|
+
* byteLength integer The length of the compressed data in bytes. ✅ Required
|
|
755
|
+
* byteStride integer The stride, in bytes. ✅ Required
|
|
756
|
+
* count integer The number of elements. ✅ Required
|
|
757
|
+
* mode string The compression mode. ✅ Required
|
|
758
|
+
* filter string The compression filter. Default: "NONE"
|
|
759
|
+
*/
|
|
760
|
+
export type GLTF_EXT_meshopt_compression = {
|
|
761
|
+
buffer: number;
|
|
762
|
+
byteOffset?: number;
|
|
763
|
+
byteLength: number;
|
|
764
|
+
byteStride: number;
|
|
765
|
+
count: number;
|
|
766
|
+
mode: 'ATTRIBUTES' | 'TRIANGLES' | 'INDICES';
|
|
767
|
+
filter?: 'NONE' | 'OCTAHEDRAL' | 'QUATERNION' | 'EXPONENTIAL';
|
|
768
|
+
extras?: any;
|
|
769
|
+
};
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* @see https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_texture_webp
|
|
773
|
+
*/
|
|
774
|
+
export type GLTF_EXT_texture_webp = {
|
|
775
|
+
source: GLTFId;
|
|
776
|
+
extras?: any;
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* @see https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_texture_dds
|
|
781
|
+
*/
|
|
782
|
+
export type GLTF_MSFT_texture_dds = {
|
|
783
|
+
source: GLTFId;
|
|
784
|
+
extras?: any;
|
|
785
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable camelcase */
|
|
2
|
+
|
|
1
3
|
// Export renamed auto generated types
|
|
2
4
|
import type {
|
|
3
5
|
GLTF,
|
|
@@ -12,7 +14,12 @@ import type {
|
|
|
12
14
|
Scene as GLTFScene,
|
|
13
15
|
Skin as GLTFSkin,
|
|
14
16
|
Texture as GLTFTexture,
|
|
15
|
-
Image as GLTFImage
|
|
17
|
+
Image as GLTFImage,
|
|
18
|
+
GLTF_KHR_binary_glTF,
|
|
19
|
+
GLTF_KHR_draco_mesh_compression,
|
|
20
|
+
GLTF_KHR_texture_basisu,
|
|
21
|
+
GLTF_EXT_meshopt_compression,
|
|
22
|
+
GLTF_EXT_texture_webp
|
|
16
23
|
} from './gltf-json-schema';
|
|
17
24
|
|
|
18
25
|
export type {
|
|
@@ -28,7 +35,12 @@ export type {
|
|
|
28
35
|
GLTFScene,
|
|
29
36
|
GLTFSkin,
|
|
30
37
|
GLTFTexture,
|
|
31
|
-
GLTFImage
|
|
38
|
+
GLTFImage,
|
|
39
|
+
GLTF_KHR_binary_glTF,
|
|
40
|
+
GLTF_KHR_draco_mesh_compression,
|
|
41
|
+
GLTF_KHR_texture_basisu,
|
|
42
|
+
GLTF_EXT_meshopt_compression,
|
|
43
|
+
GLTF_EXT_texture_webp
|
|
32
44
|
};
|
|
33
45
|
|
|
34
46
|
export type GLTFObject =
|
|
@@ -45,23 +57,9 @@ export type GLTFObject =
|
|
|
45
57
|
| GLTFTexture
|
|
46
58
|
| GLTFImage;
|
|
47
59
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
extensions?: any;
|
|
54
|
-
extras?: any;
|
|
60
|
+
export type GLTFWithBuffers = {
|
|
61
|
+
json: GLTF;
|
|
62
|
+
buffers: any[];
|
|
63
|
+
binary?: ArrayBuffer;
|
|
64
|
+
images?: any[];
|
|
55
65
|
};
|
|
56
|
-
|
|
57
|
-
// export type GLTF = {
|
|
58
|
-
// json: GLTFRoot;
|
|
59
|
-
// buffers?: any[];
|
|
60
|
-
// images?: any[];
|
|
61
|
-
// }
|
|
62
|
-
|
|
63
|
-
// export type GLTFWithBuffers = {
|
|
64
|
-
// json: GLTF;
|
|
65
|
-
// buffers: any[];
|
|
66
|
-
// binary?: ArrayBuffer;
|
|
67
|
-
// };
|