@loaders.gl/gltf 3.1.0-alpha.1 → 3.1.0-alpha.5
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/bundle.d.ts +1 -0
- package/dist/dist.min.js +1 -1
- package/dist/dist.min.js.map +1 -1
- package/dist/es5/bundle.js +7 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/glb-loader.js +47 -0
- package/dist/es5/glb-loader.js.map +1 -0
- package/dist/es5/glb-writer.js +42 -0
- package/dist/es5/glb-writer.js.map +1 -0
- package/dist/es5/gltf-loader.js +59 -0
- package/dist/es5/gltf-loader.js.map +1 -0
- package/dist/es5/gltf-writer.js +40 -0
- package/dist/es5/gltf-writer.js.map +1 -0
- package/dist/es5/index.js +56 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/lib/api/gltf-extensions.js +58 -0
- package/dist/es5/lib/api/gltf-extensions.js.map +1 -0
- package/dist/es5/lib/api/gltf-scenegraph.js +529 -0
- package/dist/es5/lib/api/gltf-scenegraph.js.map +1 -0
- package/dist/es5/lib/api/normalize-gltf-v1.js +259 -0
- package/dist/es5/lib/api/normalize-gltf-v1.js.map +1 -0
- package/dist/es5/lib/api/post-process-gltf.js +401 -0
- package/dist/es5/lib/api/post-process-gltf.js.map +1 -0
- package/dist/es5/lib/encoders/encode-glb.js +72 -0
- package/dist/es5/lib/encoders/encode-glb.js.map +1 -0
- package/dist/es5/lib/encoders/encode-gltf.js +24 -0
- package/dist/es5/lib/encoders/encode-gltf.js.map +1 -0
- package/dist/es5/lib/extensions/EXT_meshopt_compression.js +72 -0
- package/dist/es5/lib/extensions/EXT_meshopt_compression.js.map +1 -0
- package/dist/es5/lib/extensions/EXT_texture_webp.js +46 -0
- package/dist/es5/lib/extensions/EXT_texture_webp.js.map +1 -0
- package/dist/es5/lib/extensions/KHR_binary_gltf.js +39 -0
- package/dist/es5/lib/extensions/KHR_binary_gltf.js.map +1 -0
- package/dist/es5/lib/extensions/KHR_draco_mesh_compression.js +146 -0
- package/dist/es5/lib/extensions/KHR_draco_mesh_compression.js.map +1 -0
- package/dist/es5/lib/extensions/KHR_texture_basisu.js +35 -0
- package/dist/es5/lib/extensions/KHR_texture_basisu.js.map +1 -0
- package/dist/es5/lib/extensions/deprecated/KHR_lights_punctual.js +65 -0
- package/dist/es5/lib/extensions/deprecated/KHR_lights_punctual.js.map +1 -0
- package/dist/es5/lib/extensions/deprecated/KHR_materials_unlit.js +52 -0
- package/dist/es5/lib/extensions/deprecated/KHR_materials_unlit.js.map +1 -0
- package/dist/es5/lib/extensions/deprecated/KHR_techniques_webgl.js +83 -0
- package/dist/es5/lib/extensions/deprecated/KHR_techniques_webgl.js.map +1 -0
- package/dist/es5/lib/gltf-utils/get-typed-array.js +26 -0
- package/dist/es5/lib/gltf-utils/get-typed-array.js.map +1 -0
- package/dist/es5/lib/gltf-utils/gltf-attribute-utils.js +83 -0
- package/dist/es5/lib/gltf-utils/gltf-attribute-utils.js.map +1 -0
- package/dist/es5/lib/gltf-utils/gltf-constants.js +48 -0
- package/dist/es5/lib/gltf-utils/gltf-constants.js.map +1 -0
- package/dist/es5/lib/gltf-utils/gltf-utils.js +69 -0
- package/dist/es5/lib/gltf-utils/gltf-utils.js.map +1 -0
- package/dist/es5/lib/gltf-utils/resolve-url.js +23 -0
- package/dist/es5/lib/gltf-utils/resolve-url.js.map +1 -0
- package/dist/es5/lib/parsers/parse-glb.js +138 -0
- package/dist/es5/lib/parsers/parse-glb.js.map +1 -0
- package/dist/es5/lib/parsers/parse-gltf.js +193 -0
- package/dist/es5/lib/parsers/parse-gltf.js.map +1 -0
- package/dist/es5/lib/types/glb-types.js +2 -0
- package/dist/{lib → es5/lib}/types/glb-types.js.map +0 -0
- package/dist/es5/lib/types/gltf-json-schema.js +2 -0
- package/dist/{lib → es5/lib}/types/gltf-json-schema.js.map +0 -0
- package/dist/es5/lib/types/gltf-postprocessed-schema.js +2 -0
- package/dist/{lib → es5/lib}/types/gltf-postprocessed-schema.js.map +0 -0
- package/dist/es5/lib/types/gltf-types.js +2 -0
- package/dist/{lib → es5/lib}/types/gltf-types.js.map +0 -0
- package/dist/es5/lib/utils/assert.js +13 -0
- package/dist/es5/lib/utils/assert.js.map +1 -0
- package/dist/es5/lib/utils/version.js +9 -0
- package/dist/es5/lib/utils/version.js.map +1 -0
- package/dist/es5/meshopt/meshopt-decoder.js +119 -0
- package/dist/es5/meshopt/meshopt-decoder.js.map +1 -0
- package/dist/{meshopt → es5/meshopt}/meshopt-encoder.ts.disabled +0 -0
- package/dist/es5/webp/webp.js +36 -0
- package/dist/es5/webp/webp.js.map +1 -0
- package/dist/esm/bundle.js +5 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/{glb-loader.js → esm/glb-loader.js} +0 -0
- package/dist/esm/glb-loader.js.map +1 -0
- package/dist/{glb-writer.js → esm/glb-writer.js} +0 -0
- package/dist/esm/glb-writer.js.map +1 -0
- package/dist/{gltf-loader.js → esm/gltf-loader.js} +0 -0
- package/dist/esm/gltf-loader.js.map +1 -0
- package/dist/{gltf-writer.js → esm/gltf-writer.js} +0 -0
- package/dist/esm/gltf-writer.js.map +1 -0
- package/dist/{index.js → esm/index.js} +0 -1
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/api/gltf-extensions.js +35 -0
- package/dist/esm/lib/api/gltf-extensions.js.map +1 -0
- package/dist/{lib → esm/lib}/api/gltf-scenegraph.js +1 -1
- package/dist/esm/lib/api/gltf-scenegraph.js.map +1 -0
- package/dist/{lib → esm/lib}/api/normalize-gltf-v1.js +4 -4
- package/dist/esm/lib/api/normalize-gltf-v1.js.map +1 -0
- package/dist/{lib → esm/lib}/api/post-process-gltf.js +12 -12
- package/dist/esm/lib/api/post-process-gltf.js.map +1 -0
- package/dist/{lib → esm/lib}/encoders/encode-glb.js +0 -0
- package/dist/esm/lib/encoders/encode-glb.js.map +1 -0
- package/dist/{lib → esm/lib}/encoders/encode-gltf.js +0 -0
- package/dist/esm/lib/encoders/encode-gltf.js.map +1 -0
- package/dist/{lib → esm/lib}/extensions/EXT_meshopt_compression.js +16 -8
- package/dist/esm/lib/extensions/EXT_meshopt_compression.js.map +1 -0
- 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 +26 -0
- package/dist/esm/lib/extensions/KHR_binary_gltf.js.map +1 -0
- package/dist/{lib → esm/lib}/extensions/KHR_draco_mesh_compression.js +9 -1
- package/dist/esm/lib/extensions/KHR_draco_mesh_compression.js.map +1 -0
- 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/{lib/extensions → esm/lib/extensions/deprecated}/KHR_lights_punctual.js +4 -3
- package/dist/esm/lib/extensions/deprecated/KHR_lights_punctual.js.map +1 -0
- package/dist/{lib/extensions → esm/lib/extensions/deprecated}/KHR_materials_unlit.js +3 -2
- package/dist/esm/lib/extensions/deprecated/KHR_materials_unlit.js.map +1 -0
- package/dist/{lib/extensions → esm/lib/extensions/deprecated}/KHR_techniques_webgl.js +3 -2
- package/dist/esm/lib/extensions/deprecated/KHR_techniques_webgl.js.map +1 -0
- package/dist/{lib → esm/lib}/gltf-utils/get-typed-array.js +0 -0
- package/dist/esm/lib/gltf-utils/get-typed-array.js.map +1 -0
- package/dist/{lib → esm/lib}/gltf-utils/gltf-attribute-utils.js +0 -0
- package/dist/esm/lib/gltf-utils/gltf-attribute-utils.js.map +1 -0
- package/dist/{lib → esm/lib}/gltf-utils/gltf-constants.js +0 -6
- package/dist/esm/lib/gltf-utils/gltf-constants.js.map +1 -0
- package/dist/{lib → esm/lib}/gltf-utils/gltf-utils.js +0 -0
- package/dist/esm/lib/gltf-utils/gltf-utils.js.map +1 -0
- package/dist/{lib → esm/lib}/gltf-utils/resolve-url.js +1 -1
- package/dist/esm/lib/gltf-utils/resolve-url.js.map +1 -0
- package/dist/{lib → esm/lib}/parsers/parse-glb.js +2 -6
- package/dist/esm/lib/parsers/parse-glb.js.map +1 -0
- package/dist/{lib → esm/lib}/parsers/parse-gltf.js +42 -7
- package/dist/esm/lib/parsers/parse-gltf.js.map +1 -0
- package/dist/{lib → esm/lib}/types/glb-types.js +0 -0
- package/dist/esm/lib/types/glb-types.js.map +1 -0
- package/dist/{lib → esm/lib}/types/gltf-json-schema.js +0 -0
- package/dist/esm/lib/types/gltf-json-schema.js.map +1 -0
- package/dist/{lib → esm/lib}/types/gltf-postprocessed-schema.js +0 -0
- package/dist/esm/lib/types/gltf-postprocessed-schema.js.map +1 -0
- package/dist/{lib → esm/lib}/types/gltf-types.js +0 -0
- package/dist/esm/lib/types/gltf-types.js.map +1 -0
- package/dist/{lib → esm/lib}/utils/assert.js +0 -0
- package/dist/esm/lib/utils/assert.js.map +1 -0
- package/dist/esm/lib/utils/version.js +2 -0
- package/dist/esm/lib/utils/version.js.map +1 -0
- package/dist/{meshopt → esm/meshopt}/meshopt-decoder.js +1 -1
- package/dist/esm/meshopt/meshopt-decoder.js.map +1 -0
- package/dist/esm/meshopt/meshopt-encoder.ts.disabled +409 -0
- package/dist/esm/webp/webp.js +29 -0
- package/dist/esm/webp/webp.js.map +1 -0
- package/dist/glb-loader.d.ts +12 -0
- package/dist/glb-writer.d.ts +21 -0
- package/dist/gltf-loader.d.ts +17 -0
- package/dist/gltf-writer.d.ts +24 -0
- package/dist/index.d.ts +10 -0
- package/dist/lib/api/gltf-extensions.d.ts +25 -0
- package/dist/lib/api/gltf-scenegraph.d.ts +182 -0
- package/dist/lib/api/normalize-gltf-v1.d.ts +1 -0
- package/dist/lib/api/post-process-gltf.d.ts +1 -0
- package/dist/lib/encoders/encode-glb.d.ts +1 -0
- package/dist/lib/encoders/encode-gltf.d.ts +1 -0
- package/dist/lib/extensions/EXT_meshopt_compression.d.ts +9 -0
- package/dist/lib/extensions/EXT_texture_webp.d.ts +11 -0
- package/dist/lib/extensions/KHR_binary_gltf.d.ts +6 -0
- package/dist/lib/extensions/KHR_draco_mesh_compression.d.ts +12 -0
- package/dist/lib/extensions/KHR_texture_basisu.d.ts +11 -0
- package/dist/lib/extensions/deprecated/KHR_lights_punctual.d.ts +6 -0
- package/dist/lib/extensions/deprecated/KHR_materials_unlit.d.ts +6 -0
- package/dist/lib/extensions/deprecated/KHR_techniques_webgl.d.ts +6 -0
- package/dist/lib/gltf-utils/get-typed-array.d.ts +2 -0
- package/dist/lib/gltf-utils/gltf-attribute-utils.d.ts +5 -0
- package/dist/lib/gltf-utils/gltf-constants.d.ts +3 -0
- package/dist/lib/gltf-utils/gltf-utils.d.ts +7 -0
- package/dist/lib/gltf-utils/resolve-url.d.ts +1 -0
- package/dist/lib/parsers/parse-glb.d.ts +7 -0
- package/dist/lib/parsers/parse-gltf.d.ts +13 -0
- package/dist/lib/types/glb-types.d.ts +16 -0
- package/dist/lib/types/gltf-json-schema.d.ts +719 -0
- package/dist/lib/types/gltf-postprocessed-schema.d.ts +684 -0
- package/dist/lib/types/gltf-types.d.ts +9 -0
- package/dist/lib/utils/assert.d.ts +1 -0
- package/dist/lib/utils/version.d.ts +1 -0
- package/dist/meshopt/meshopt-decoder.d.ts +5 -0
- package/dist/webp/webp.d.ts +6 -0
- package/package.json +13 -9
- 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 +29 -4
- 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 +72 -20
- 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/bundle.js +0 -7
- package/dist/bundle.js.map +0 -1
- package/dist/glb-loader.js.map +0 -1
- package/dist/glb-writer.js.map +0 -1
- package/dist/gltf-loader.js.map +0 -1
- package/dist/gltf-writer.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/api/gltf-scenegraph.js.map +0 -1
- package/dist/lib/api/normalize-gltf-v1.js.map +0 -1
- package/dist/lib/api/post-process-gltf.js.map +0 -1
- package/dist/lib/encoders/encode-glb.js.map +0 -1
- package/dist/lib/encoders/encode-gltf.js.map +0 -1
- package/dist/lib/extensions/EXT_meshopt_compression.js.map +0 -1
- package/dist/lib/extensions/KHR_binary_gltf.js +0 -26
- package/dist/lib/extensions/KHR_binary_gltf.js.map +0 -1
- package/dist/lib/extensions/KHR_draco_mesh_compression.js.map +0 -1
- package/dist/lib/extensions/KHR_lights_punctual.js.map +0 -1
- package/dist/lib/extensions/KHR_materials_unlit.js.map +0 -1
- package/dist/lib/extensions/KHR_techniques_webgl.js.map +0 -1
- package/dist/lib/extensions/gltf-extensions.js +0 -24
- package/dist/lib/extensions/gltf-extensions.js.map +0 -1
- package/dist/lib/gltf-utils/get-typed-array.js.map +0 -1
- package/dist/lib/gltf-utils/gltf-attribute-utils.js.map +0 -1
- package/dist/lib/gltf-utils/gltf-constants.js.map +0 -1
- package/dist/lib/gltf-utils/gltf-utils.js.map +0 -1
- package/dist/lib/gltf-utils/resolve-url.js.map +0 -1
- package/dist/lib/parsers/parse-glb.js.map +0 -1
- package/dist/lib/parsers/parse-gltf.js.map +0 -1
- package/dist/lib/utils/assert.js.map +0 -1
- package/dist/lib/utils/version.js +0 -2
- package/dist/lib/utils/version.js.map +0 -1
- package/dist/meshopt/meshopt-decoder.js.map +0 -1
- package/src/lib/extensions/gltf-extensions.ts +0 -48
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
/* eslint-disable camelcase, max-statements, no-restricted-globals */
|
|
2
2
|
import type {LoaderContext} from '@loaders.gl/loader-utils';
|
|
3
|
+
import {BasisLoader, selectSupportedBasisFormat} from '@loaders.gl/textures';
|
|
4
|
+
import type {GLTFLoaderOptions} from '../../gltf-loader';
|
|
3
5
|
import type {GLB} from '../types/glb-types';
|
|
4
|
-
import type {
|
|
6
|
+
import type {GLTFWithBuffers} from '../types/gltf-types';
|
|
5
7
|
|
|
6
8
|
import {ImageLoader} from '@loaders.gl/images';
|
|
7
9
|
import {parseJSON, sliceArrayBuffer} from '@loaders.gl/loader-utils';
|
|
8
10
|
import {assert} from '../utils/assert';
|
|
9
11
|
import {resolveUrl} from '../gltf-utils/resolve-url';
|
|
10
12
|
import {getTypedArrayForBufferView} from '../gltf-utils/get-typed-array';
|
|
11
|
-
import {decodeExtensions} from '../
|
|
13
|
+
import {preprocessExtensions, decodeExtensions} from '../api/gltf-extensions';
|
|
12
14
|
import {normalizeGLTFV1} from '../api/normalize-gltf-v1';
|
|
13
15
|
import {postProcessGLTF} from '../api/post-process-gltf';
|
|
14
16
|
import parseGLBSync, {isGLB} from './parse-glb';
|
|
15
17
|
|
|
16
18
|
export type GLTFParseOptions = {
|
|
17
|
-
excludeExtensions?: string[];
|
|
18
|
-
decompressMeshes?: boolean;
|
|
19
19
|
normalize?: boolean;
|
|
20
|
-
loadBuffers?: boolean;
|
|
21
20
|
loadImages?: boolean;
|
|
21
|
+
loadBuffers?: boolean;
|
|
22
|
+
decompressMeshes?: boolean;
|
|
22
23
|
postProcess?: boolean;
|
|
24
|
+
excludeExtensions?: string[];
|
|
23
25
|
};
|
|
24
26
|
|
|
25
27
|
// export type GLTFOptions = {
|
|
@@ -32,19 +34,18 @@ export function isGLTF(arrayBuffer, options?): boolean {
|
|
|
32
34
|
}
|
|
33
35
|
|
|
34
36
|
export async function parseGLTF(
|
|
35
|
-
gltf,
|
|
37
|
+
gltf: GLTFWithBuffers,
|
|
36
38
|
arrayBufferOrString,
|
|
37
39
|
byteOffset = 0,
|
|
38
|
-
options:
|
|
39
|
-
gltf?: GLTFParseOptions;
|
|
40
|
-
glb?: GLBParseOptions;
|
|
41
|
-
},
|
|
40
|
+
options: GLTFLoaderOptions,
|
|
42
41
|
context: LoaderContext
|
|
43
42
|
) {
|
|
44
43
|
parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options);
|
|
45
44
|
|
|
46
45
|
normalizeGLTFV1(gltf, {normalize: options?.gltf?.normalize});
|
|
47
46
|
|
|
47
|
+
preprocessExtensions(gltf, options, context);
|
|
48
|
+
|
|
48
49
|
const promises: Promise<any>[] = [];
|
|
49
50
|
|
|
50
51
|
// Load linked buffers asynchronously and decodes base64 buffers in parallel
|
|
@@ -120,10 +121,14 @@ function parseGLTFContainerSync(gltf, data, byteOffset, options) {
|
|
|
120
121
|
gltf.images = new Array(images.length).fill({});
|
|
121
122
|
}
|
|
122
123
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
124
|
+
/** Asynchronously fetch and parse buffers, store in buffers array outside of json
|
|
125
|
+
* TODO - traverse gltf and determine which buffers are actually needed
|
|
126
|
+
*/
|
|
127
|
+
async function loadBuffers(gltf: GLTFWithBuffers, options, context: LoaderContext) {
|
|
128
|
+
// TODO
|
|
129
|
+
const buffers = gltf.json.buffers || [];
|
|
130
|
+
for (let i = 0; i < buffers.length; ++i) {
|
|
131
|
+
const buffer = buffers[i];
|
|
127
132
|
if (buffer.uri) {
|
|
128
133
|
const {fetch} = context;
|
|
129
134
|
assert(fetch);
|
|
@@ -143,19 +148,49 @@ async function loadBuffers(gltf, options, context: LoaderContext) {
|
|
|
143
148
|
}
|
|
144
149
|
}
|
|
145
150
|
|
|
146
|
-
|
|
151
|
+
/**
|
|
152
|
+
* Loads all images
|
|
153
|
+
* TODO - traverse gltf and determine which images are actually needed
|
|
154
|
+
* @param gltf
|
|
155
|
+
* @param options
|
|
156
|
+
* @param context
|
|
157
|
+
* @returns
|
|
158
|
+
*/
|
|
159
|
+
async function loadImages(gltf: GLTFWithBuffers, options, context: LoaderContext) {
|
|
160
|
+
const imageIndices = getReferencesImageIndices(gltf);
|
|
161
|
+
|
|
147
162
|
const images = gltf.json.images || [];
|
|
148
163
|
|
|
149
164
|
const promises: Promise<any>[] = [];
|
|
150
|
-
for (
|
|
151
|
-
promises.push(loadImage(gltf, images[
|
|
165
|
+
for (const imageIndex of imageIndices) {
|
|
166
|
+
promises.push(loadImage(gltf, images[imageIndex], imageIndex, options, context));
|
|
152
167
|
}
|
|
153
168
|
|
|
154
169
|
return await Promise.all(promises);
|
|
155
170
|
}
|
|
156
171
|
|
|
157
|
-
|
|
158
|
-
|
|
172
|
+
/** Make sure we only load images that are actually referenced by textures */
|
|
173
|
+
function getReferencesImageIndices(gltf: GLTFWithBuffers): number[] {
|
|
174
|
+
const imageIndices = new Set<number>();
|
|
175
|
+
|
|
176
|
+
const textures = gltf.json.textures || [];
|
|
177
|
+
for (const texture of textures) {
|
|
178
|
+
if (texture.source !== undefined) {
|
|
179
|
+
imageIndices.add(texture.source);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return Array.from(imageIndices).sort();
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Asynchronously fetches and parses one image, store in images array outside of json */
|
|
187
|
+
async function loadImage(
|
|
188
|
+
gltf: GLTFWithBuffers,
|
|
189
|
+
image,
|
|
190
|
+
index: number,
|
|
191
|
+
options,
|
|
192
|
+
context: LoaderContext
|
|
193
|
+
) {
|
|
159
194
|
const {fetch, parse} = context;
|
|
160
195
|
|
|
161
196
|
let arrayBuffer;
|
|
@@ -174,9 +209,26 @@ async function loadImage(gltf, image, index: number, options, context: LoaderCon
|
|
|
174
209
|
assert(arrayBuffer, 'glTF image has no data');
|
|
175
210
|
|
|
176
211
|
// Call `parse`
|
|
177
|
-
|
|
212
|
+
let parsedImage = await parse(
|
|
213
|
+
arrayBuffer,
|
|
214
|
+
[ImageLoader, BasisLoader],
|
|
215
|
+
{mimeType: image.mimeType, basis: {format: selectSupportedBasisFormat()}},
|
|
216
|
+
context
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
if (parsedImage && parsedImage[0]) {
|
|
220
|
+
parsedImage = {
|
|
221
|
+
compressed: true,
|
|
222
|
+
mipmaps: false,
|
|
223
|
+
width: parsedImage[0].width,
|
|
224
|
+
height: parsedImage[0].height,
|
|
225
|
+
data: parsedImage
|
|
226
|
+
};
|
|
227
|
+
}
|
|
178
228
|
// TODO making sure ImageLoader is overridable by using array of loaders
|
|
179
229
|
// const parsedImage = await parse(arrayBuffer, [ImageLoader]);
|
|
180
230
|
|
|
231
|
+
// Store the loaded image
|
|
232
|
+
gltf.images = gltf.images || [];
|
|
181
233
|
gltf.images[index] = parsedImage;
|
|
182
234
|
}
|
|
@@ -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
|
-
// };
|
package/src/webp/webp.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const WEBP_TEST_IMAGES = {
|
|
2
|
+
lossy: 'UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA',
|
|
3
|
+
lossless: 'UklGRhoAAABXRUJQVlA4TA0AAAAvAAAAEAcQERGIiP4HAA==',
|
|
4
|
+
alpha:
|
|
5
|
+
'UklGRkoAAABXRUJQVlA4WAoAAAAQAAAAAAAAAAAAQUxQSAwAAAARBxAR/Q9ERP8DAABWUDggGAAAABQBAJ0BKgEAAQAAAP4AAA3AAP7mtQAAAA==',
|
|
6
|
+
animation:
|
|
7
|
+
'UklGRlIAAABXRUJQVlA4WAoAAAASAAAAAAAAAAAAQU5JTQYAAAD/////AABBTk1GJgAAAAAAAAAAAAAAAAAAAGQAAABWUDhMDQAAAC8AAAAQBxAREYiI/gcA'
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type WebPFeature = 'lossy' | 'lossless' | 'alpha' | 'animation';
|
|
11
|
+
|
|
12
|
+
const WEBP_FEATURES: WebPFeature[] = ['lossy', 'lossless', 'alpha', 'animation'];
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Checks if WebP is supported
|
|
16
|
+
* @param features Array, can include 'lossy', 'lossless', 'alpha' or 'animation'
|
|
17
|
+
*/
|
|
18
|
+
export async function isWebPSupported(features: WebPFeature[] = WEBP_FEATURES): Promise<boolean> {
|
|
19
|
+
const promises = features.map((feature) => checkWebPFeature(feature));
|
|
20
|
+
const statuses = await Promise.all(promises);
|
|
21
|
+
return statuses.every((_) => _);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Checks if a specific WebP feature is supported
|
|
26
|
+
* @param feature 'feature' can be one of 'lossy', 'lossless', 'alpha' or 'animation'.
|
|
27
|
+
*
|
|
28
|
+
* Based on Google's official recommended checks
|
|
29
|
+
* @see https://developers.google.com/speed/webp/faq#how_can_i_detect_browser_support_for_webp
|
|
30
|
+
*/
|
|
31
|
+
async function checkWebPFeature(feature: WebPFeature): Promise<boolean> {
|
|
32
|
+
if (typeof Image === 'undefined') {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return await new Promise((resolve, reject) => {
|
|
36
|
+
const img = new Image();
|
|
37
|
+
img.onload = () => resolve(img.width > 0 && img.height > 0);
|
|
38
|
+
img.onerror = () => resolve(false);
|
|
39
|
+
img.src = `data:image/webp;base64,${WEBP_TEST_IMAGES[feature]}`;
|
|
40
|
+
});
|
|
41
|
+
}
|
package/dist/bundle.js
DELETED
package/dist/bundle.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/bundle.ts"],"names":["moduleExports","require","_global","window","global","loaders","module","exports","Object","assign"],"mappings":"AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACA,MAAMC,OAAO,GAAG,OAAOC,MAAP,KAAkB,WAAlB,GAAgCC,MAAhC,GAAyCD,MAAzD;;AACAD,OAAO,CAACG,OAAR,GAAkBH,OAAO,CAACG,OAAR,IAAmB,EAArC;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcP,OAAO,CAACG,OAAtB,EAA+BL,aAA/B,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nconst _global = typeof window === 'undefined' ? global : window;\n_global.loaders = _global.loaders || {};\nmodule.exports = Object.assign(_global.loaders, moduleExports);\n"],"file":"bundle.js"}
|
package/dist/glb-loader.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/glb-loader.ts"],"names":["VERSION","parseGLBSync","GLBLoader","name","id","module","version","extensions","mimeTypes","binary","parse","parseSync","options","glb","strict","arrayBuffer","byteOffset","_TypecheckGLBLoader"],"mappings":"AAGA,SAAQA,OAAR,QAAsB,qBAAtB;AACA,OAAOC,YAAP,MAAyB,yBAAzB;AAWA,OAAO,MAAMC,SAA2B,GAAG;AACzCC,EAAAA,IAAI,EAAE,KADmC;AAEzCC,EAAAA,EAAE,EAAE,KAFqC;AAGzCC,EAAAA,MAAM,EAAE,MAHiC;AAIzCC,EAAAA,OAAO,EAAEN,OAJgC;AAKzCO,EAAAA,UAAU,EAAE,CAAC,KAAD,CAL6B;AAMzCC,EAAAA,SAAS,EAAE,CAAC,mBAAD,CAN8B;AAOzCC,EAAAA,MAAM,EAAE,IAPiC;AAQzCC,EAAAA,KARyC;AASzCC,EAAAA,SATyC;AAUzCC,EAAAA,OAAO,EAAE;AACPC,IAAAA,GAAG,EAAE;AACHC,MAAAA,MAAM,EAAE;AADL;AADE;AAVgC,CAApC;;AAiBP,eAAeJ,KAAf,CAAqBK,WAArB,EAA+CH,OAA/C,EAAyF;AACvF,SAAOD,SAAS,CAACI,WAAD,EAAcH,OAAd,CAAhB;AACD;;AAED,SAASD,SAAT,CAAmBI,WAAnB,EAA6CH,OAA7C,EAA8E;AAC5E,QAAM;AAACI,IAAAA,UAAU,GAAG;AAAd,MAAmBJ,OAAO,IAAI,EAApC;AACA,QAAMC,GAAQ,GAAG,EAAjB;AACAZ,EAAAA,YAAY,CAACY,GAAD,EAAME,WAAN,EAAmBC,UAAnB,EAA+BJ,OAA/B,aAA+BA,OAA/B,uBAA+BA,OAAO,CAAEC,GAAxC,CAAZ;AACA,SAAOA,GAAP;AACD;;AAGD,OAAO,MAAMI,mBAAqC,GAAGf,SAA9C","sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {GLB} from './lib/types/glb-types';\nimport type {GLBParseOptions} from './lib/parsers/parse-glb';\nimport {VERSION} from './lib/utils/version';\nimport parseGLBSync from './lib/parsers/parse-glb';\n\nexport type GLBLoaderOptions = LoaderOptions & {\n glb?: GLBParseOptions;\n byteOffset?: number;\n};\n\n/**\n * GLB Loader -\n * GLB is the binary container format for GLTF\n */\nexport const GLBLoader: LoaderWithParser = {\n name: 'GLB',\n id: 'glb',\n module: 'gltf',\n version: VERSION,\n extensions: ['glb'],\n mimeTypes: ['model/gltf-binary'],\n binary: true,\n parse,\n parseSync,\n options: {\n glb: {\n strict: false // Enables deprecated XVIZ support (illegal CHUNK formats)\n }\n }\n};\n\nasync function parse(arrayBuffer: ArrayBuffer, options?: GLBLoaderOptions): Promise<GLB> {\n return parseSync(arrayBuffer, options);\n}\n\nfunction parseSync(arrayBuffer: ArrayBuffer, options?: GLBLoaderOptions): GLB {\n const {byteOffset = 0} = options || {};\n const glb: GLB = {} as GLB;\n parseGLBSync(glb, arrayBuffer, byteOffset, options?.glb);\n return glb;\n}\n\n// TYPE TESTS - TODO find a better way than exporting junk\nexport const _TypecheckGLBLoader: LoaderWithParser = GLBLoader;\n"],"file":"glb-loader.js"}
|
package/dist/glb-writer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/glb-writer.ts"],"names":["VERSION","encodeGLBSync","GLBWriter","name","id","module","version","extensions","mimeTypes","binary","encodeSync","options","glb","byteOffset","byteLength","arrayBuffer","ArrayBuffer","dataView","DataView","_TypecheckGLBLoader"],"mappings":"AACA,SAAQA,OAAR,QAAsB,qBAAtB;AACA,OAAOC,aAAP,MAA0B,2BAA1B;AAMA,OAAO,MAAMC,SAAS,GAAG;AACvBC,EAAAA,IAAI,EAAE,KADiB;AAEvBC,EAAAA,EAAE,EAAE,KAFmB;AAGvBC,EAAAA,MAAM,EAAE,MAHe;AAIvBC,EAAAA,OAAO,EAAEN,OAJc;AAMvBO,EAAAA,UAAU,EAAE,CAAC,KAAD,CANW;AAOvBC,EAAAA,SAAS,EAAE,CAAC,mBAAD,CAPY;AAQvBC,EAAAA,MAAM,EAAE,IARe;AAUvBC,EAAAA,UAVuB;AAYvBC,EAAAA,OAAO,EAAE;AACPC,IAAAA,GAAG,EAAE;AADE;AAZc,CAAlB;;AAiBP,SAASF,UAAT,CAAoBE,GAApB,EAAyBD,OAAzB,EAAkC;AAChC,QAAM;AAACE,IAAAA,UAAU,GAAG;AAAd,MAAmBF,OAAzB;AAGA,QAAMG,UAAU,GAAGb,aAAa,CAACW,GAAD,EAAM,IAAN,EAAYC,UAAZ,EAAwBF,OAAxB,CAAhC;AACA,QAAMI,WAAW,GAAG,IAAIC,WAAJ,CAAgBF,UAAhB,CAApB;AAGA,QAAMG,QAAQ,GAAG,IAAIC,QAAJ,CAAaH,WAAb,CAAjB;AACAd,EAAAA,aAAa,CAACW,GAAD,EAAMK,QAAN,EAAgBJ,UAAhB,EAA4BF,OAA5B,CAAb;AAEA,SAAOI,WAAP;AACD;;AAGD,OAAO,MAAMI,mBAA2B,GAAGjB,SAApC","sourcesContent":["import type {Writer} from '@loaders.gl/loader-utils';\nimport {VERSION} from './lib/utils/version';\nimport encodeGLBSync from './lib/encoders/encode-glb';\n\n/**\n * GLB exporter\n * GLB is the binary container format for GLTF\n */\nexport const GLBWriter = {\n name: 'GLB',\n id: 'glb',\n module: 'gltf',\n version: VERSION,\n\n extensions: ['glb'],\n mimeTypes: ['model/gltf-binary'],\n binary: true,\n\n encodeSync,\n\n options: {\n glb: {}\n }\n};\n\nfunction encodeSync(glb, options) {\n const {byteOffset = 0} = options;\n\n // Calculate length and allocate buffer\n const byteLength = encodeGLBSync(glb, null, byteOffset, options);\n const arrayBuffer = new ArrayBuffer(byteLength);\n\n // Encode into buffer\n const dataView = new DataView(arrayBuffer);\n encodeGLBSync(glb, dataView, byteOffset, options);\n\n return arrayBuffer;\n}\n\n// TYPE TESTS - TODO find a better way than exporting junk\nexport const _TypecheckGLBLoader: Writer = GLBWriter;\n"],"file":"glb-writer.js"}
|
package/dist/gltf-loader.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/gltf-loader.ts"],"names":["VERSION","parseGLTF","GLTFLoader","name","id","module","version","extensions","mimeTypes","text","binary","tests","parse","options","gltf","normalize","loadBuffers","loadImages","decompressMeshes","postProcess","log","console","deprecatedOptions","fetchImages","createImages","decompress","arrayBuffer","context","byteOffset"],"mappings":"AAKA,SAAQA,OAAR,QAAsB,qBAAtB;AACA,SAAQC,SAAR,QAAwB,0BAAxB;AAeA,OAAO,MAAMC,UAA4B,GAAG;AAC1CC,EAAAA,IAAI,EAAE,MADoC;AAE1CC,EAAAA,EAAE,EAAE,MAFsC;AAG1CC,EAAAA,MAAM,EAAE,MAHkC;AAI1CC,EAAAA,OAAO,EAAEN,OAJiC;AAK1CO,EAAAA,UAAU,EAAE,CAAC,MAAD,EAAS,KAAT,CAL8B;AAM1CC,EAAAA,SAAS,EAAE,CAAC,iBAAD,EAAoB,mBAApB,CAN+B;AAQ1CC,EAAAA,IAAI,EAAE,IARoC;AAS1CC,EAAAA,MAAM,EAAE,IATkC;AAU1CC,EAAAA,KAAK,EAAE,CAAC,MAAD,CAVmC;AAW1CC,EAAAA,KAX0C;AAa1CC,EAAAA,OAAO,EAAE;AACPC,IAAAA,IAAI,EAAE;AACJC,MAAAA,SAAS,EAAE,IADP;AAEJC,MAAAA,WAAW,EAAE,IAFT;AAGJC,MAAAA,UAAU,EAAE,IAHR;AAIJC,MAAAA,gBAAgB,EAAE,IAJd;AAKJC,MAAAA,WAAW,EAAE;AALT,KADC;AAUPC,IAAAA,GAAG,EAAEC;AAVE,GAbiC;AAyB1CC,EAAAA,iBAAiB,EAAE;AACjBC,IAAAA,WAAW,EAAE,iBADI;AAEjBC,IAAAA,YAAY,EAAE,iBAFG;AAGjBC,IAAAA,UAAU,EAAE,uBAHK;AAIjBN,IAAAA,WAAW,EAAE,kBAJI;AAKjBL,IAAAA,IAAI,EAAE;AACJW,MAAAA,UAAU,EAAE;AADR;AALW;AAzBuB,CAArC;AAoCP,OAAO,eAAeb,KAAf,CAAqBc,WAArB,EAAkCb,OAA0B,GAAG,EAA/D,EAAmEc,OAAnE,EAA4E;AAEjFd,EAAAA,OAAO,GAAG,EAAC,GAAGX,UAAU,CAACW,OAAf;AAAwB,OAAGA;AAA3B,GAAV;AAEAA,EAAAA,OAAO,CAACC,IAAR,GAAe,EAAC,GAAGZ,UAAU,CAACW,OAAX,CAAmBC,IAAvB;AAA6B,OAAGD,OAAO,CAACC;AAAxC,GAAf;AAEA,QAAM;AAACc,IAAAA,UAAU,GAAG;AAAd,MAAmBf,OAAzB;AACA,QAAMC,IAAI,GAAG,EAAb;AACA,SAAO,MAAMb,SAAS,CAACa,IAAD,EAAOY,WAAP,EAAoBE,UAApB,EAAgCf,OAAhC,EAAyCc,OAAzC,CAAtB;AACD","sourcesContent":["import type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {DracoLoaderOptions} from '@loaders.gl/draco';\n// import type {ImageLoaderOptions} from '@loaders.gl/images';\n// import type {TextureLoaderOptions} from '@loaders.gl/textures';\nimport type {GLTFParseOptions} from './lib/parsers/parse-gltf';\nimport {VERSION} from './lib/utils/version';\nimport {parseGLTF} from './lib/parsers/parse-gltf';\nimport {GLBLoaderOptions} from './glb-loader';\n\n/**\n * GLTF loader options\n */\nexport type GLTFLoaderOptions = LoaderOptions &\n GLBLoaderOptions &\n DracoLoaderOptions & {\n gltf?: GLTFParseOptions;\n };\n\n/**\n * GLTF loader\n */\nexport const GLTFLoader: LoaderWithParser = {\n name: 'glTF',\n id: 'gltf',\n module: 'gltf',\n version: VERSION,\n extensions: ['gltf', 'glb'],\n mimeTypes: ['model/gltf+json', 'model/gltf-binary'],\n\n text: true,\n binary: true,\n tests: ['glTF'],\n parse,\n\n options: {\n gltf: {\n normalize: true, // Normalize glTF v1 to glTF v2 format (not yet stable)\n loadBuffers: true, // Fetch any linked .BIN buffers, decode base64\n loadImages: true, // Create image objects\n decompressMeshes: true, // Decompress Draco encoded meshes\n postProcess: true // Postprocess glTF and return json structure directly\n },\n\n // common?\n log: console // eslint-disable-line\n },\n deprecatedOptions: {\n fetchImages: 'gltf.loadImages',\n createImages: 'gltf.loadImages',\n decompress: 'gltf.decompressMeshes',\n postProcess: 'gltf.postProcess',\n gltf: {\n decompress: 'gltf.decompressMeshes'\n }\n }\n};\n\nexport async function parse(arrayBuffer, options: GLTFLoaderOptions = {}, context) {\n // Apps can call the parse method directly, we so apply default options here\n options = {...GLTFLoader.options, ...options};\n // @ts-ignore\n options.gltf = {...GLTFLoader.options.gltf, ...options.gltf};\n\n const {byteOffset = 0} = options;\n const gltf = {};\n return await parseGLTF(gltf, arrayBuffer, byteOffset, options, context);\n}\n"],"file":"gltf-loader.js"}
|
package/dist/gltf-writer.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/gltf-writer.ts"],"names":["VERSION","encodeGLTFSync","GLTFWriter","name","id","module","version","extensions","mimeTypes","binary","encodeSync","options","gltf","byteOffset","byteLength","arrayBuffer","ArrayBuffer","dataView","DataView","_TypecheckGLBLoader"],"mappings":"AACA,SAAQA,OAAR,QAAsB,qBAAtB;AACA,SAAQC,cAAR,QAA6B,4BAA7B;AAUA,OAAO,MAAMC,UAAU,GAAG;AACxBC,EAAAA,IAAI,EAAE,MADkB;AAExBC,EAAAA,EAAE,EAAE,MAFoB;AAGxBC,EAAAA,MAAM,EAAE,MAHgB;AAIxBC,EAAAA,OAAO,EAAEN,OAJe;AAMxBO,EAAAA,UAAU,EAAE,CAAC,KAAD,CANY;AAOxBC,EAAAA,SAAS,EAAE,CAAC,mBAAD,CAPa;AAQxBC,EAAAA,MAAM,EAAE,IARgB;AAUxBC,EAAAA,UAVwB;AAYxBC,EAAAA,OAAO,EAAE;AACPC,IAAAA,IAAI,EAAE;AADC;AAZe,CAAnB;;AAiBP,SAASF,UAAT,CAAoBE,IAApB,EAA0BD,OAA0B,GAAG,EAAvD,EAA2D;AACzD,QAAM;AAACE,IAAAA,UAAU,GAAG;AAAd,MAAmBF,OAAzB;AAGA,QAAMG,UAAU,GAAGb,cAAc,CAACW,IAAD,EAAO,IAAP,EAAaC,UAAb,EAAyBF,OAAzB,CAAjC;AACA,QAAMI,WAAW,GAAG,IAAIC,WAAJ,CAAgBF,UAAhB,CAApB;AACA,QAAMG,QAAQ,GAAG,IAAIC,QAAJ,CAAaH,WAAb,CAAjB;AACAd,EAAAA,cAAc,CAACW,IAAD,EAAOK,QAAP,EAAiBJ,UAAjB,EAA6BF,OAA7B,CAAd;AAEA,SAAOI,WAAP;AACD;;AAGD,OAAO,MAAMI,mBAA2B,GAAGjB,UAApC","sourcesContent":["import type {Writer} from '@loaders.gl/loader-utils';\nimport {VERSION} from './lib/utils/version';\nimport {encodeGLTFSync} from './lib/encoders/encode-gltf';\n\nexport type GLTFWriterOptions = {\n gltf?: {};\n byteOffset?: number;\n};\n\n/**\n * GLTF exporter\n */\nexport const GLTFWriter = {\n name: 'glTF',\n id: 'gltf',\n module: 'gltf',\n version: VERSION,\n\n extensions: ['glb'], // We only support encoding to binary GLB, not to JSON GLTF\n mimeTypes: ['model/gltf-binary'], // 'model/gltf+json',\n binary: true,\n\n encodeSync,\n\n options: {\n gltf: {}\n }\n};\n\nfunction encodeSync(gltf, options: GLTFWriterOptions = {}) {\n const {byteOffset = 0} = options;\n\n // Calculate length, then create arraybuffer and encode\n const byteLength = encodeGLTFSync(gltf, null, byteOffset, options);\n const arrayBuffer = new ArrayBuffer(byteLength);\n const dataView = new DataView(arrayBuffer);\n encodeGLTFSync(gltf, dataView, byteOffset, options);\n\n return arrayBuffer;\n}\n\n// TYPE TESTS - TODO find a better way than exporting junk\nexport const _TypecheckGLBLoader: Writer = GLTFWriter;\n"],"file":"gltf-writer.js"}
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["KHR_DRACO_MESH_COMPRESSION","GLTFLoader","GLTFWriter","GLBLoader","GLBWriter","default","GLTFScenegraph","postProcessGLTF"],"mappings":"AAkBA,SAAQA,0BAAR,QAAyC,iCAAzC;AAGA,SAAQC,UAAR,QAAyB,eAAzB;AACA,SAAQC,UAAR,QAAyB,eAAzB;AAGA,SAAQC,SAAR,QAAwB,cAAxB;AACA,SAAQC,SAAR,QAAwB,cAAxB;AAGA,SAAQC,OAAO,IAAIC,cAAnB,QAAwC,2BAAxC;AACA,SAAQC,eAAR,QAA8B,6BAA9B","sourcesContent":["export type {GLB} from './lib/types/glb-types';\nexport type {\n GLTF,\n GLTFAccessor,\n GLTFBuffer,\n GLTFBufferView,\n GLTFMeshPrimitive,\n GLTFMesh,\n GLTFNode,\n GLTFMaterial,\n GLTFSampler,\n GLTFScene,\n GLTFSkin,\n GLTFTexture,\n GLTFImage\n} from './lib/types/gltf-types';\n\n// Constants\nexport {KHR_DRACO_MESH_COMPRESSION} from './lib/gltf-utils/gltf-constants';\n\n// glTF loader/writer definition objects\nexport {GLTFLoader} from './gltf-loader';\nexport {GLTFWriter} from './gltf-writer';\n\n// GLB Loader & Writer (for custom formats that want to leverage the GLB binary \"envelope\")\nexport {GLBLoader} from './glb-loader';\nexport {GLBWriter} from './glb-writer';\n\n// glTF Data Access Helper Class\nexport {default as GLTFScenegraph} from './lib/api/gltf-scenegraph';\nexport {postProcessGLTF} from './lib/api/post-process-gltf';\nexport type {Mesh} from './lib/types/gltf-json-schema';\nexport type {GLTFObject} from './lib/types/gltf-types';\n"],"file":"index.js"}
|