@loaders.gl/gltf 3.1.0-alpha.1 → 4.0.0-alpha.1
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.js +2 -4
- package/dist/bundle.js.map +1 -1
- package/dist/gltf-loader.js.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/api/gltf-extensions.js +35 -0
- package/dist/lib/api/gltf-extensions.js.map +1 -0
- package/dist/lib/api/gltf-scenegraph.js +1 -1
- package/dist/lib/api/gltf-scenegraph.js.map +1 -1
- package/dist/lib/api/normalize-gltf-v1.js +4 -4
- package/dist/lib/api/normalize-gltf-v1.js.map +1 -1
- package/dist/lib/api/post-process-gltf.js +12 -12
- package/dist/lib/api/post-process-gltf.js.map +1 -1
- package/dist/lib/extensions/EXT_meshopt_compression.js +16 -8
- package/dist/lib/extensions/EXT_meshopt_compression.js.map +1 -1
- package/dist/lib/extensions/EXT_texture_webp.js +32 -0
- package/dist/lib/extensions/EXT_texture_webp.js.map +1 -0
- package/dist/lib/extensions/KHR_binary_gltf.js +8 -8
- package/dist/lib/extensions/KHR_binary_gltf.js.map +1 -1
- package/dist/lib/extensions/KHR_draco_mesh_compression.js +9 -1
- package/dist/lib/extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/dist/lib/extensions/KHR_texture_basisu.js +22 -0
- package/dist/lib/extensions/KHR_texture_basisu.js.map +1 -0
- package/dist/lib/extensions/{KHR_lights_punctual.js → deprecated/KHR_lights_punctual.js} +4 -3
- package/dist/lib/extensions/deprecated/KHR_lights_punctual.js.map +1 -0
- package/dist/lib/extensions/{KHR_materials_unlit.js → deprecated/KHR_materials_unlit.js} +3 -2
- package/dist/lib/extensions/deprecated/KHR_materials_unlit.js.map +1 -0
- package/dist/lib/extensions/{KHR_techniques_webgl.js → deprecated/KHR_techniques_webgl.js} +3 -2
- package/dist/lib/extensions/deprecated/KHR_techniques_webgl.js.map +1 -0
- package/dist/lib/gltf-utils/gltf-constants.js +0 -6
- package/dist/lib/gltf-utils/gltf-constants.js.map +1 -1
- package/dist/lib/gltf-utils/resolve-url.js +1 -1
- package/dist/lib/gltf-utils/resolve-url.js.map +1 -1
- package/dist/lib/parsers/parse-glb.js +2 -6
- package/dist/lib/parsers/parse-glb.js.map +1 -1
- package/dist/lib/parsers/parse-gltf.js +42 -7
- package/dist/lib/parsers/parse-gltf.js.map +1 -1
- package/dist/lib/utils/version.js +1 -1
- package/dist/meshopt/meshopt-decoder.js +1 -1
- package/dist/meshopt/meshopt-decoder.js.map +1 -1
- package/dist/webp/webp.js +29 -0
- package/dist/webp/webp.js.map +1 -0
- package/package.json +10 -7
- 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/dist.min.js +0 -2
- package/dist/dist.min.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/src/lib/extensions/gltf-extensions.ts +0 -48
|
@@ -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/dist.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var s=t[r]={i:r,l:!1,exports:{}};return e[r].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)n.d(r,s,function(t){return e[t]}.bind(null,s));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=9)}([function(e,t,n){"use strict";(function(e,r){n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return o})),n.d(t,"c",(function(){return a}));const s={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==e&&e,document:"undefined"!=typeof document&&document},i=s.global||s.self||s.window||{},o="object"!=typeof r||"[object process]"!==String(r)||r.browser,a="function"==typeof importScripts,c=("undefined"!=typeof window&&window.orientation,void 0!==r&&r.version&&/v([0-9]*)/.exec(r.version));c&&parseFloat(c[1])}).call(this,n(4),n(7))},function(e,t,n){"use strict";(function(e,r){n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return o}));const s={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==e&&e,document:"undefined"!=typeof document&&document},i=s.global||s.self||s.window,o="object"!=typeof r||"[object process]"!==String(r)||r.browser,a=void 0!==r&&r.version&&/v([0-9]*)/.exec(r.version);a&&parseFloat(a[1])}).call(this,n(4),n(7))},function(e,t){},,function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t){},,function(e,t){var n,r,s=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(e){r=o}}();var c,u=[],f=!1,d=-1;function l(){f&&c&&(f=!1,c.length?u=c.concat(u):d=-1,u.length&&h())}function h(){if(!f){var e=a(l);f=!0;for(var t=u.length;t;){for(c=u,u=[];++d<t;)c&&c[d].run();d=-1,t=u.length}c=null,f=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function m(e,t){this.fun=e,this.array=t}function g(){}s.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];u.push(new m(e,t)),1!==u.length||f||a(h)},m.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=g,s.addListener=g,s.once=g,s.off=g,s.removeListener=g,s.removeAllListeners=g,s.emit=g,s.prependListener=g,s.prependOnceListener=g,s.listeners=function(e){return[]},s.binding=function(e){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},,function(e,t,n){(function(t){const r=n(12),s="undefined"==typeof window?t:window;s.loaders=s.loaders||{},e.exports=Object.assign(s.loaders,r)}).call(this,n(4))},,,function(e,t,n){"use strict";n.r(t),n.d(t,"KHR_DRACO_MESH_COMPRESSION",(function(){return a})),n.d(t,"GLTFLoader",(function(){return yt})),n.d(t,"GLTFWriter",(function(){return _t})),n.d(t,"GLBLoader",(function(){return xt})),n.d(t,"GLBWriter",(function(){return It})),n.d(t,"GLTFScenegraph",(function(){return ze})),n.d(t,"postProcessGLTF",(function(){return ut}));var r={};n.r(r),n.d(r,"decode",(function(){return ke})),n.d(r,"encode",(function(){return qe}));var s={};n.r(s),n.d(s,"decode",(function(){return He})),n.d(s,"encode",(function(){return Ke}));var i={};n.r(i),n.d(i,"decode",(function(){return We})),n.d(i,"encode",(function(){return Xe}));var o={};n.r(o),n.d(o,"decode",(function(){return Qe})),n.d(o,"encode",(function(){return Je}));const a="KHR_draco_mesh_compression";const c="3.1.0-alpha.1";function u(e,t){if(!e)throw new Error(t)}var f=n(1);const{_parseImageNode:d}=f.a,l="undefined"!=typeof Image,h="undefined"!=typeof ImageBitmap,m=Boolean(d),g=!!f.b||m;function b(e){const t=p(e);if(!t)throw new Error("Not an image");return t}function y(e){switch(b(e)){case"data":return e;case"image":case"imagebitmap":const t=document.createElement("canvas"),n=t.getContext("2d");if(!n)throw new Error("getImageData");return t.width=e.width,t.height=e.height,n.drawImage(e,0,0),n.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}function p(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?"imagebitmap":"undefined"!=typeof Image&&e instanceof Image?"image":e&&"object"==typeof e&&e.data&&e.width&&e.height?"data":null}const w=/^data:image\/svg\+xml/,T=/\.svg((\?|#).*)?$/;function v(e){return e&&(w.test(e)||T.test(e))}function _(e,t){if(v(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function x(e,t,n){const r=function(e,t){if(v(t)){let t=(new TextDecoder).decode(e);try{"function"==typeof unescape&&"function"==typeof encodeURIComponent&&(t=unescape(encodeURIComponent(t)))}catch(e){throw new Error(e.message)}return"data:image/svg+xml;base64,"+btoa(t)}return _(e,t)}(e,n),s=self.URL||self.webkitURL,i="string"!=typeof r&&s.createObjectURL(r);try{return await async function(e,t){const n=new Image;if(n.src=e,t.image&&t.image.decode&&n.decode)return await n.decode(),n;return await new Promise((t,r)=>{try{n.onload=()=>t(n),n.onerror=t=>r(new Error(`Could not load image ${e}: ${t}`))}catch(e){r(e)}})}(i||r,t)}finally{i&&s.revokeObjectURL(i)}}const A={};let I=!0;async function j(e,t,n){let r;if(v(n)){r=await x(e,t,n)}else r=_(e,n);const s=t&&t.imagebitmap;return await async function(e,t=null){!function(e){for(const t in e||A)return!1;return!0}(t)&&I||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),I=!1}return await createImageBitmap(e)}(r,s)}function E(e){const t=O(e);return function(e){const t=O(e);if(!(t.byteLength>=24&&2303741511===t.getUint32(0,!1)))return null;return{mimeType:"image/png",width:t.getUint32(16,!1),height:t.getUint32(20,!1)}}(t)||function(e){const t=O(e);if(!(t.byteLength>=3&&65496===t.getUint16(0,!1)&&255===t.getUint8(2)))return null;const{tableMarkers:n,sofMarkers:r}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let s=2;for(;s+9<t.byteLength;){const e=t.getUint16(s,!1);if(r.has(e))return{mimeType:"image/jpeg",height:t.getUint16(s+5,!1),width:t.getUint16(s+7,!1)};if(!n.has(e))return null;s+=2,s+=t.getUint16(s,!1)}return null}(t)||function(e){const t=O(e);if(!(t.byteLength>=10&&1195984440===t.getUint32(0,!1)))return null;return{mimeType:"image/gif",width:t.getUint16(6,!0),height:t.getUint16(8,!0)}}(t)||function(e){const t=O(e);if(!(t.byteLength>=14&&16973===t.getUint16(0,!1)&&t.getUint32(2,!0)===t.byteLength))return null;return{mimeType:"image/bmp",width:t.getUint32(18,!0),height:t.getUint32(22,!0)}}(t)}function O(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}const S={id:"image",module:"images",name:"Images",version:"3.1.0-alpha.1",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg"],parse:async function(e,t,n){const r=((t=t||{}).image||{}).type||"auto",{url:s}=n||{};let i;switch(function(e){switch(e){case"auto":case"data":return function(){if(h)return"imagebitmap";if(l)return"image";if(g)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return h||l||g;case"imagebitmap":return h;case"image":return l;case"data":return g;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}(e),e}}(r)){case"imagebitmap":i=await j(e,t,s);break;case"image":i=await x(e,t,s);break;case"data":i=await function(e,t){const{mimeType:n}=E(e)||{},{_parseImageNode:r}=f.a;return u(r),r(e,n,t)}(e,t);break;default:u(!1)}return"data"===r&&(i=y(i)),i},tests:[e=>Boolean(E(new DataView(e)))],options:{image:{type:"auto",decode:!0}}};function U(e,t,n){if(e.byteLength<=t+n)return"";const r=new DataView(e);let s="";for(let e=0;e<n;e++)s+=String.fromCharCode(r.getUint8(t+e));return s}function M(e){try{return JSON.parse(e)}catch(t){throw new Error(`Failed to parse JSON from data starting with "${function(e,t=5){if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return U(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){return U(e,0,t)}return""}(e)}"`)}}n(5);function L(e,t,n){const r=void 0!==n?new Uint8Array(e).subarray(t,t+n):new Uint8Array(e).subarray(t);return new Uint8Array(r).buffer}function R(e,t){if(!e)throw new Error(t||"assert failed: gltf")}function B(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const n=t.baseUri||t.uri;if(!n)throw new Error("'baseUri' must be provided to resolve relative url "+e);return n.substr(0,n.lastIndexOf("/")+1)+e}function F(e,t,n){const r=e.bufferViews[n];R(r);const s=t[r.buffer];R(s);const i=(r.byteOffset||0)+s.byteOffset;return new Uint8Array(s.arrayBuffer,i,r.byteLength)}const D={name:"Draco",id:"draco",module:"draco",shapes:["mesh"],version:"3.1.0-alpha.1",worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:"object"==typeof WebAssembly?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}}};function N(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class V{constructor(e,t){N(this,"fields",void 0),N(this,"metadata",void 0),function(e,t){if(!e)throw new Error(t||"loader assertion failed.")}(Array.isArray(e)),function(e){const t={};for(const n of e)t[n.name]&&console.warn("Schema: duplicated field name",n.name,n),t[n.name]=!0}(e),this.fields=e,this.metadata=t||new Map}compareTo(e){if(this.metadata!==e.metadata)return!1;if(this.fields.length!==e.fields.length)return!1;for(let t=0;t<this.fields.length;++t)if(!this.fields[t].compareTo(e.fields[t]))return!1;return!0}select(...e){const t=Object.create(null);for(const n of e)t[n]=!0;const n=this.fields.filter(e=>t[e.name]);return new V(n,this.metadata)}selectAt(...e){const t=e.map(e=>this.fields[e]).filter(Boolean);return new V(t,this.metadata)}assign(e){let t,n=this.metadata;if(e instanceof V){const r=e;t=r.fields,n=C(C(new Map,this.metadata),r.metadata)}else t=e;const r=Object.create(null);for(const e of this.fields)r[e.name]=e;for(const e of t)r[e.name]=e;const s=Object.values(r);return new V(s,n)}}function C(e,t){return new Map([...e||new Map,...t||new Map])}function z(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class P{constructor(e,t,n=!1,r=new Map){z(this,"name",void 0),z(this,"type",void 0),z(this,"nullable",void 0),z(this,"metadata",void 0),this.name=e,this.type=t,this.nullable=n,this.metadata=r}get typeId(){return this.type&&this.type.typeId}clone(){return new P(this.name,this.type,this.nullable,this.metadata)}compareTo(e){return this.name===e.name&&this.type===e.type&&this.nullable===e.nullable&&this.metadata===e.metadata}toString(){return`${this.type}${this.nullable?", nullable":""}${this.metadata?", metadata: "+this.metadata:""}`}}let k,q,G,$,H,K,W,X,Q;function J(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}!function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth"}(k||(k={}));class Y{static isNull(e){return e&&e.typeId===k.Null}static isInt(e){return e&&e.typeId===k.Int}static isFloat(e){return e&&e.typeId===k.Float}static isBinary(e){return e&&e.typeId===k.Binary}static isUtf8(e){return e&&e.typeId===k.Utf8}static isBool(e){return e&&e.typeId===k.Bool}static isDecimal(e){return e&&e.typeId===k.Decimal}static isDate(e){return e&&e.typeId===k.Date}static isTime(e){return e&&e.typeId===k.Time}static isTimestamp(e){return e&&e.typeId===k.Timestamp}static isInterval(e){return e&&e.typeId===k.Interval}static isList(e){return e&&e.typeId===k.List}static isStruct(e){return e&&e.typeId===k.Struct}static isUnion(e){return e&&e.typeId===k.Union}static isFixedSizeBinary(e){return e&&e.typeId===k.FixedSizeBinary}static isFixedSizeList(e){return e&&e.typeId===k.FixedSizeList}static isMap(e){return e&&e.typeId===k.Map}static isDictionary(e){return e&&e.typeId===k.Dictionary}get typeId(){return k.NONE}compareTo(e){return this===e}}Symbol.toStringTag;Symbol.toStringTag;q=Symbol.toStringTag;class Z extends Y{constructor(e,t){super(),J(this,"isSigned",void 0),J(this,"bitWidth",void 0),this.isSigned=e,this.bitWidth=t}get typeId(){return k.Int}get[q](){return"Int"}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}class ee extends Z{constructor(){super(!0,8)}}class te extends Z{constructor(){super(!0,16)}}class ne extends Z{constructor(){super(!0,32)}}class re extends Z{constructor(){super(!1,8)}}class se extends Z{constructor(){super(!1,16)}}class ie extends Z{constructor(){super(!1,32)}}const oe=32,ae=64;G=Symbol.toStringTag;class ce extends Y{constructor(e){super(),J(this,"precision",void 0),this.precision=e}get typeId(){return k.Float}get[G](){return"Float"}toString(){return"Float"+this.precision}}class ue extends ce{constructor(){super(oe)}}class fe extends ce{constructor(){super(ae)}}Symbol.toStringTag;Symbol.toStringTag;$=Symbol.toStringTag;H=Symbol.toStringTag;K=Symbol.toStringTag;W=Symbol.toStringTag;X=Symbol.toStringTag;class de extends Y{constructor(e,t){super(),J(this,"listSize",void 0),J(this,"children",void 0),this.listSize=e,this.children=[t]}get typeId(){return k.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get[X](){return"FixedSizeList"}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}Q=Symbol.toStringTag;function le(e,t,n){const r=function(e){switch(e.constructor){case Int8Array:return new ee;case Uint8Array:return new re;case Int16Array:return new te;case Uint16Array:return new se;case Int32Array:return new ne;case Uint32Array:return new ie;case Float32Array:return new ue;case Float64Array:return new fe;default:throw new Error("array type not supported")}}(t.value),s=n||function(e){const t=new Map;"byteOffset"in e&&t.set("byteOffset",e.byteOffset.toString(10));"byteStride"in e&&t.set("byteStride",e.byteStride.toString(10));"normalized"in e&&t.set("normalized",e.normalized.toString());return t}(t);return new P(e,new de(t.size,new P("value",r)),!1,s)}function he(e,t,n){return le(e,t,n?me(n.metadata):void 0)}function me(e){const t=new Map;for(const n in e)t.set(n+".string",JSON.stringify(e[n]));return t}function ge(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const be={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},ye={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class pe{constructor(e){ge(this,"draco",void 0),ge(this,"decoder",void 0),ge(this,"metadataQuerier",void 0),this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,t={}){const n=new this.draco.DecoderBuffer;n.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const r=this.decoder.GetEncodedGeometryType(n),s=r===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(r){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(n,s);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(n,s);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!s.ptr){const t="DRACO decompression failed: "+e.error_msg();throw new Error(t)}const i=this._getDracoLoaderData(s,r,t),o=this._getMeshData(s,i,t),a=function(e){let t=1/0,n=1/0,r=1/0,s=-1/0,i=-1/0,o=-1/0;const a=e.POSITION?e.POSITION.value:[],c=a&&a.length;for(let e=0;e<c;e+=3){const c=a[e],u=a[e+1],f=a[e+2];t=c<t?c:t,n=u<n?u:n,r=f<r?f:r,s=c>s?c:s,i=u>i?u:i,o=f>o?f:o}return[[t,n,r],[s,i,o]]}(o.attributes),c=function(e,t,n){const r=me(t.metadata),s=[],i=function(e){const t={};for(const n in e){const r=e[n];t[r.name||"undefined"]=r}return t}(t.attributes);for(const t in e){const n=he(t,e[t],i[t]);s.push(n)}if(n){const e=he("indices",n);s.push(e)}return new V(s,r)}(o.attributes,i,o.indices);return{loader:"draco",loaderData:i,header:{vertexCount:s.num_points(),boundingBox:a},...o,schema:c}}finally{this.draco.destroy(n),s&&this.draco.destroy(s)}}_getDracoLoaderData(e,t,n){const r=this._getTopLevelMetadata(e),s=this._getDracoAttributes(e,n);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:r,attributes:s}}_getDracoAttributes(e,t){const n={};for(let r=0;r<e.num_attributes();r++){const s=this.decoder.GetAttribute(e,r),i=this._getAttributeMetadata(e,r);n[s.unique_id()]={unique_id:s.unique_id(),attribute_type:s.attribute_type(),data_type:s.data_type(),num_components:s.num_components(),byte_offset:s.byte_offset(),byte_stride:s.byte_stride(),normalized:s.normalized(),attribute_index:r,metadata:i};const o=this._getQuantizationTransform(s,t);o&&(n[s.unique_id()].quantization_transform=o);const a=this._getOctahedronTransform(s,t);a&&(n[s.unique_id()].octahedron_transform=a)}return n}_getMeshData(e,t,n){const r=this._getMeshAttributes(t,e,n);if(!r.POSITION)throw new Error("DRACO: No position attribute found.");if(e instanceof this.draco.Mesh)switch(n.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:r,indices:{value:this._getTriangleStripIndices(e),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:r,indices:{value:this._getTriangleListIndices(e),size:1}}}return{topology:"point-list",mode:0,attributes:r}}_getMeshAttributes(e,t,n){const r={};for(const s of Object.values(e.attributes)){const e=this._deduceAttributeName(s,n);s.name=e;const{value:i,size:o}=this._getAttributeValues(t,s);r[e]={value:i,size:o,byteOffset:s.byte_offset,byteStride:s.byte_stride,normalized:s.normalized}}return r}_getTriangleListIndices(e){const t=3*e.num_faces(),n=4*t,r=this.draco._malloc(n);try{return this.decoder.GetTrianglesUInt32Array(e,n,r),new Uint32Array(this.draco.HEAPF32.buffer,r,t).slice()}finally{this.draco._free(r)}}_getTriangleStripIndices(e){const t=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,t),function(e){const t=e.size(),n=new Int32Array(t);for(let r=0;r<t;r++)n[r]=e.GetValue(r);return n}(t)}finally{this.draco.destroy(t)}}_getAttributeValues(e,t){const n=ye[t.data_type],r=t.num_components,s=e.num_points()*r,i=s*n.BYTES_PER_ELEMENT,o=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32;default:return e.DT_INVALID}}(this.draco,n);let a;const c=this.draco._malloc(i);try{const r=this.decoder.GetAttribute(e,t.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,r,o,i,c),a=new n(this.draco.HEAPF32.buffer,c,s).slice()}finally{this.draco._free(c)}return{value:a,size:r}}_deduceAttributeName(e,t){const n=e.unique_id;for(const[e,r]of Object.entries(t.extraAttributes||{}))if(r===n)return e;const r=e.attribute_type;for(const e in be){if(this.draco[e]===r)return be[e]}const s=t.attributeNameEntry||"name";return e.metadata[s]?e.metadata[s].string:"CUSTOM_ATTRIBUTE_"+n}_getTopLevelMetadata(e){const t=this.decoder.GetMetadata(e);return this._getDracoMetadata(t)}_getAttributeMetadata(e,t){const n=this.decoder.GetAttributeMetadata(e,t);return this._getDracoMetadata(n)}_getDracoMetadata(e){if(!e||!e.ptr)return{};const t={},n=this.metadataQuerier.NumEntries(e);for(let r=0;r<n;r++){const n=this.metadataQuerier.GetEntryName(e,r);t[n]=this._getDracoMetadataField(e,n)}return t}_getDracoMetadataField(e,t){const n=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,t,n);const r=function(e){const t=e.size(),n=new Int32Array(t);for(let r=0;r<t;r++)n[r]=e.GetValue(r);return n}(n);return{int:this.metadataQuerier.GetIntEntry(e,t),string:this.metadataQuerier.GetStringEntry(e,t),double:this.metadataQuerier.GetDoubleEntry(e,t),intArray:r}}finally{this.draco.destroy(n)}}_disableAttributeTransforms(e){const{quantizedAttributes:t=[],octahedronAttributes:n=[]}=e,r=[...t,...n];for(const e of r)this.decoder.SkipAttributeTransform(this.draco[e])}_getQuantizationTransform(e,t){const{quantizedAttributes:n=[]}=t,r=e.attribute_type();if(n.map(e=>this.decoder[e]).includes(r)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map(e=>t.min_value(e))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:n=[]}=t,r=e.attribute_type();if(n.map(e=>this.decoder[e]).includes(r)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}var we=n(0),Te=n(2);const ve={};async function _e(e,t=null,n={}){return t&&(e=function(e,t,n){if(e.startsWith("http"))return e;const r=n.modules||{};if(r[e])return r[e];if(!we.b)return`modules/${t}/dist/libs/${e}`;if(n.CDN)return function(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}(n.CDN.startsWith("http")),`${n.CDN}/${t}@3.1.0-alpha.1/dist/libs/${e}`;if(we.c)return"../src/libs/"+e;return`modules/${t}/src/libs/${e}`}(e,t,n)),ve[e]=ve[e]||async function(e){if(e.endsWith("wasm")){const t=await fetch(e);return await t.arrayBuffer()}if(!we.b)return Te.requireFromFile&&await Te.requireFromFile(e);if(we.c)return importScripts(e);const t=await fetch(e);return function(e,t){if(!we.b)return Te.requireFromString&&Te.requireFromString(e,t);if(we.c)return eval.call(we.a,e),null;const n=document.createElement("script");n.id=t;try{n.appendChild(document.createTextNode(e))}catch(t){n.text=e}return document.body.appendChild(n),null}(await t.text(),e)}(e),await ve[e]}let xe;async function Ae(e){const t=e.modules||{};return xe=t.draco3d?xe||t.draco3d.createDecoderModule({}).then(e=>({draco:e})):xe||async function(e){let t,n;switch(e.draco&&e.draco.decoderType){case"js":t=await _e("https://www.gstatic.com/draco/versioned/decoders/1.4.1/draco_decoder.js","draco",e);break;case"wasm":default:[t,n]=await Promise.all([await _e("https://www.gstatic.com/draco/versioned/decoders/1.4.1/draco_wasm_wrapper.js","draco",e),await _e("https://www.gstatic.com/draco/versioned/decoders/1.4.1/draco_decoder.wasm","draco",e)])}return t=t||globalThis.DracoDecoderModule,await function(e,t){const n={};t&&(n.wasmBinary=t);return new Promise(t=>{e({...n,onModuleLoaded:e=>t({draco:e})})})}(t,n)}(e),await xe}const Ie={...D,parse:async function(e,t){const{draco:n}=await Ae(t),r=new pe(n);try{return r.parseSync(e,null==t?void 0:t.draco)}finally{r.destroy()}}};function je(e,t){if(!e)throw new Error(t||"loader assertion failed.")}function Ee(e,t){return je(e>=0),je(t>0),e+(t-1)&~(t-1)}function Oe(e,t,n){let r;if(e instanceof ArrayBuffer)r=new Uint8Array(e);else{const t=e.byteOffset,n=e.byteLength;r=new Uint8Array(e.buffer||e.arrayBuffer,t,n)}return t.set(r,n),n+Ee(r.byteLength,4)}const Se=["SCALAR","VEC2","VEC3","VEC4"],Ue=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],Me=new Map(Ue),Le={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Re={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Be={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Fe(e){return Se[e-1]||Se[0]}function De(e){const t=Me.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function Ne(e,t){const n=Be[e.componentType],r=Le[e.type],s=Re[e.componentType],i=e.count*r,o=e.count*r*s;return R(o>=0&&o<=t.byteLength),{ArrayType:n,length:i,byteLength:o}}function Ve(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const Ce={asset:{version:"2.0",generator:"loaders.gl"},buffers:[]};class ze{constructor(e){Ve(this,"gltf",void 0),Ve(this,"sourceBuffers",void 0),Ve(this,"byteLength",void 0),this.gltf=e||{json:{...Ce},buffers:[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}getExtension(e){const t=this.getUsedExtensions().find(t=>t===e),n=this.json.extensions||{};return t?n[e]||!0:null}getRequiredExtension(e){return this.getRequiredExtensions().find(t=>t===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getObjectExtension(e,t){return(e.extensions||{})[t]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,t){if("object"==typeof t)return t;const n=this.json[e]&&this.json[e][t];if(!n)throw new Error(`glTF file error: Could not find ${e}[${t}]`);return n}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,n=this.gltf.buffers[t];R(n);const r=(e.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,r,e.byteLength)}getTypedArrayForAccessor(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),n=this.getBuffer(t.buffer).data,{ArrayType:r,length:s}=Ne(e,t);return new r(n,t.byteOffset+e.byteOffset,s)}getTypedArrayForImageData(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),n=this.getBuffer(t.buffer).data,r=t.byteOffset||0;return new Uint8Array(n,r,t.byteLength)}addApplicationData(e,t){return this.json[e]=t,this}addExtraData(e,t){return this.json.extras=this.json.extras||{},this.json.extras[e]=t,this}addObjectExtension(e,t,n){return e.extensions=e.extensions||{},e.extensions[t]=n,this.registerUsedExtension(t),this}setObjectExtension(e,t,n){(e.extensions||{})[t]=n}removeObjectExtension(e,t){const n=e.extensions||{},r=n[t];return delete n[t],r}addExtension(e,t={}){return R(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),t}addRequiredExtension(e,t={}){return R(t),this.addExtension(e,t),this.registerRequiredExtension(e),t}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(t=>t===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(t=>t===e)||this.json.extensionsRequired.push(e)}removeExtension(e){this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e),this.json.extensions&&delete this.json.extensions[e]}setDefaultScene(e){this.json.scene=e}addScene(e){const{nodeIndices:t}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}addNode(e){const{meshIndex:t,matrix:n}=e;this.json.nodes=this.json.nodes||[];const r={mesh:t};return n&&(r.matrix=n),this.json.nodes.push(r),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:n,material:r,mode:s=4}=e,i={primitives:[{attributes:this._addAttributes(t),mode:s}]};if(n){const e=this._addIndices(n);i.primitives[0].indices=e}return Number.isFinite(r)&&(i.primitives[0].material=r),this.json.meshes=this.json.meshes||[],this.json.meshes.push(i),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addImage(e,t){const n=E(e),r=t||(null==n?void 0:n.mimeType),s={bufferView:this.addBufferView(e),mimeType:r};return this.json.images=this.json.images||[],this.json.images.push(s),this.json.images.length-1}addBufferView(e){const t=e.byteLength;R(Number.isFinite(t)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const n={buffer:0,byteOffset:this.byteLength,byteLength:t};return this.byteLength+=Ee(t,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(n),this.json.bufferViews.length-1}addAccessor(e,t){const n={bufferView:e,type:Fe(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(n),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const n=this.addBufferView(e);let r={min:t.min,max:t.max};r.min&&r.max||(r=this._getAccessorMinMax(e,t.size));const s={size:t.size,componentType:De(e),count:Math.round(e.length/t.size),min:r.min,max:r.max};return this.addAccessor(n,Object.assign(s,t))}addTexture(e){const{imageIndex:t}=e,n={source:t};return this.json.textures=this.json.textures||[],this.json.textures.push(n),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){var e,t;this.gltf.buffers=[];const n=this.byteLength,r=new ArrayBuffer(n),s=new Uint8Array(r);let i=0;for(const e of this.sourceBuffers||[])i=Oe(e,s,i);null!==(e=this.json)&&void 0!==e&&null!==(t=e.buffers)&&void 0!==t&&t[0]?this.json.buffers[0].byteLength=n:this.json.buffers=[{byteLength:n}],this.gltf.binary=r,this.sourceBuffers=[r]}_removeStringFromArray(e,t){let n=!0;for(;n;){const r=e.indexOf(t);r>-1?e.splice(r,1):n=!1}}_addAttributes(e={}){const t={};for(const n in e){const r=e[n],s=this._getGltfAttributeName(n),i=this.addBinaryBuffer(r.value,r);t[s]=i}return t}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return e}}_getAccessorMinMax(e,t){const n={min:null,max:null};if(e.length<t)return n;n.min=[],n.max=[];const r=e.subarray(0,t);for(const e of r)n.min.push(e),n.max.push(e);for(let r=t;r<e.length;r+=t)for(let s=0;s<t;s++)n.min[0+s]=Math.min(n.min[0+s],e[r+s]),n.max[0+s]=Math.max(n.max[0+s],e[r+s]);return n}}function Pe(e){const{buffer:t,size:n,count:r}=function(e){let t=e,n=1,r=0;e&&e.value&&(t=e.value,n=e.size||1);t&&(ArrayBuffer.isView(t)||(t=function(e,t,n=!1){if(!e)return null;if(Array.isArray(e))return new t(e);if(n&&!(e instanceof t))return new t(e);return e}(t,Float32Array)),r=t.length/n);return{buffer:t,size:n,count:r}}(e);return{value:t,size:n,byteOffset:0,count:r,type:Fe(n),componentType:De(t)}}async function ke(e,t,n){var r;if(null==t||null===(r=t.gltf)||void 0===r||!r.decompressMeshes)return;const s=new ze(e),i=[];for(const e of function*(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}(s))s.getObjectExtension(e,a)&&i.push(Ge(s,e,t,n));await Promise.all(i),s.removeExtension(a)}function qe(e,t={}){const n=new ze(e);for(const e of n.json.meshes||[])$e(e,t),n.addRequiredExtension(a)}async function Ge(e,t,n,r){const s=e.getObjectExtension(t,a);if(!s)return;const i=e.getTypedArrayForBufferView(s.bufferView),o=L(i.buffer,i.byteOffset),{parse:c}=r,u={...n};delete u["3d-tiles"];const f=await c(o,Ie,u,r),d=function(e){const t={};for(const n in e){const r=e[n];if("indices"!==n){const e=Pe(r);t[n]=e}}return t}(f.attributes);for(const[n,r]of Object.entries(d))if(n in t.attributes){const s=t.attributes[n],i=e.getAccessor(s);null!=i&&i.min&&null!=i&&i.max&&(r.min=i.min,r.max=i.max)}t.attributes=d,f.indices&&(t.indices=Pe(f.indices)),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function $e(e,t,n=4,r,s){var i;if(!r.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const o=r.DracoWriter.encodeSync({attributes:e}),c=null==s||null===(i=s.parseSync)||void 0===i?void 0:i.call(s,{attributes:e}),u=r._addFauxAttributes(c.attributes),f=r.addBufferView(o);return{primitives:[{attributes:u,mode:n,extensions:{[a]:{bufferView:f,attributes:u}}}]}}async function He(e){const t=new ze(e),{json:n}=t;t.removeExtension("KHR_materials_unlit");for(const e of n.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),t.removeObjectExtension(e,"KHR_materials_unlit")}}function Ke(e){const t=new ze(e),{json:n}=t;if(t.materials)for(const e of n.materials||[])e.unlit&&(delete e.unlit,t.addObjectExtension(e,"KHR_materials_unlit",{}),t.addExtension("KHR_materials_unlit"))}async function We(e){const t=new ze(e),{json:n}=t,r=t.getExtension("KHR_lights_punctual");r&&(t.json.lights=r.lights,t.removeExtension("KHR_lights_punctual"));for(const e of n.nodes||[]){const n=t.getObjectExtension(e,"KHR_lights_punctual");n&&(e.light=n.light),t.removeObjectExtension(e,"KHR_lights_punctual")}}async function Xe(e){const t=new ze(e),{json:n}=t;if(n.lights){const e=t.addExtension("KHR_lights_punctual");R(!e.lights),e.lights=n.lights,delete n.lights}if(t.json.lights){for(const e of t.json.lights){const n=e.node;t.addObjectExtension(n,"KHR_lights_punctual",e)}delete t.json.lights}}async function Qe(e){const t=new ze(e),{json:n}=t,r=t.getExtension("KHR_techniques_webgl");if(r){const e=function(e,t){const{programs:n=[],shaders:r=[],techniques:s=[]}=e,i=new TextDecoder;return r.forEach(e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=i.decode(t.getTypedArrayForBufferView(e.bufferView))}),n.forEach(e=>{e.fragmentShader=r[e.fragmentShader],e.vertexShader=r[e.vertexShader]}),s.forEach(e=>{e.program=n[e.program]}),s}(r,t);for(const r of n.materials||[]){const n=t.getObjectExtension(r,"KHR_techniques_webgl");n&&(r.technique=Object.assign({},n,e[n.technique]),r.technique.values=Ye(r.technique,t)),t.removeObjectExtension(r,"KHR_techniques_webgl")}t.removeExtension("KHR_techniques_webgl")}}async function Je(e,t){}function Ye(e,t){const n=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach(t=>{e.uniforms[t].value&&!(t in n)&&(n[t]=e.uniforms[t].value)}),Object.keys(n).forEach(e=>{"object"==typeof n[e]&&void 0!==n[e].index&&(n[e].texture=t.getTexture(n[e].index))}),n}const Ze={KHR_draco_mesh_compression:r,KHR_materials_unlit:s,KHR_lights_punctual:i,KHR_techniques_webgl:o};const et={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},tt={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class nt{constructor(e){this.idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}}}normalize(e,t){this.json=e.json;const n=e.json;switch(n.asset&&n.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return void console.warn("glTF: Unknown version "+n.asset.version)}if(!t.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(n),this._convertTopLevelObjectsToArrays(n),function(e){const t=new ze(e),{json:n}=t;for(const e of n.images||[]){const n=t.removeObjectExtension(e,"KHR_binary_glTF");n&&Object.assign(e,n)}n.buffers&&n.buffers[0]&&delete n.buffers[0].uri,t.removeExtension("KHR_binary_glTF")}(e),this._convertObjectIdsToArrayIndices(n),this._updateObjects(n),this._updateMaterial(n)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(const t in et)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const n=e[t];if(n&&!Array.isArray(n)){e[t]=[];for(const r in n){const s=n[r];s.id=s.id||r;const i=e[t].length;e[t].push(s),this.idToIndexMap[t][r]=i}}}_convertObjectIdsToArrayIndices(e){for(const t in et)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const t of e.textures)this._convertTextureIds(t);for(const t of e.meshes)this._convertMeshIds(t);for(const t of e.nodes)this._convertNodeIds(t);for(const t of e.scenes)this._convertSceneIds(t)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const t of e.primitives){const{attributes:e,indices:n,material:r}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");n&&(t.indices=this._convertIdToIndex(n,"accessor")),r&&(t.material=this._convertIdToIndex(r,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(e=>this._convertIdToIndex(e,"node"))),e.meshes&&(e.meshes=e.meshes.map(e=>this._convertIdToIndex(e,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(e=>this._convertIdToIndex(e,"node")))}_convertIdsToIndices(e,t){e[t]||(console.warn("gltf v1: json doesn't contain attribute "+t),e[t]=[]);for(const n of e[t])for(const e in n){const t=n[e],r=this._convertIdToIndex(t,e);n[e]=r}}_convertIdToIndex(e,t){const n=tt[t];if(n in this.idToIndexMap){const r=this.idToIndexMap[n][e];if(!Number.isFinite(r))throw new Error(`gltf v1: failed to resolve ${t} with id ${e}`);return r}return e}_updateObjects(e){for(const e of this.json.buffers)delete e.type}_updateMaterial(e){for(const t of e.materials){t.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const n=t.values&&t.values.tex,r=e.textures.findIndex(e=>e.id===n);-1!==r&&(t.pbrMetallicRoughness.baseColorTexture={index:r})}}}const rt={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},st={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},it={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},ot={magFilter:it.TEXTURE_MAG_FILTER,minFilter:it.TEXTURE_MIN_FILTER,wrapS:it.TEXTURE_WRAP_S,wrapT:it.TEXTURE_WRAP_T},at={[it.TEXTURE_MAG_FILTER]:it.LINEAR,[it.TEXTURE_MIN_FILTER]:it.NEAREST_MIPMAP_LINEAR,[it.TEXTURE_WRAP_S]:it.REPEAT,[it.TEXTURE_WRAP_]:it.REPEAT};class ct{postProcess(e,t={}){const{json:n,buffers:r=[],images:s=[],baseUri:i=""}=e;return R(n),this.baseUri=i,this.json=n,this.buffers=r,this.images=s,this._resolveTree(this.json,t),this.json}_resolveTree(e,t={}){e.bufferViews&&(e.bufferViews=e.bufferViews.map((e,t)=>this._resolveBufferView(e,t))),e.images&&(e.images=e.images.map((e,t)=>this._resolveImage(e,t))),e.samplers&&(e.samplers=e.samplers.map((e,t)=>this._resolveSampler(e,t))),e.textures&&(e.textures=e.textures.map((e,t)=>this._resolveTexture(e,t))),e.accessors&&(e.accessors=e.accessors.map((e,t)=>this._resolveAccessor(e,t))),e.materials&&(e.materials=e.materials.map((e,t)=>this._resolveMaterial(e,t))),e.meshes&&(e.meshes=e.meshes.map((e,t)=>this._resolveMesh(e,t))),e.nodes&&(e.nodes=e.nodes.map((e,t)=>this._resolveNode(e,t))),e.skins&&(e.skins=e.skins.map((e,t)=>this._resolveSkin(e,t))),e.scenes&&(e.scenes=e.scenes.map((e,t)=>this._resolveScene(e,t))),void 0!==e.scene&&(e.scene=e.scenes[this.json.scene])}getScene(e){return this._get("scenes",e)}getNode(e){return this._get("nodes",e)}getSkin(e){return this._get("skins",e)}getMesh(e){return this._get("meshes",e)}getMaterial(e){return this._get("materials",e)}getAccessor(e){return this._get("accessors",e)}getCamera(e){return null}getTexture(e){return this._get("textures",e)}getSampler(e){return this._get("samplers",e)}getImage(e){return this._get("images",e)}getBufferView(e){return this._get("bufferViews",e)}getBuffer(e){return this._get("buffers",e)}_get(e,t){if("object"==typeof t)return t;const n=this.json[e]&&this.json[e][t];return n||console.warn(`glTF file error: Could not find ${e}[${t}]`),n}_resolveScene(e,t){return e.id=e.id||"scene-"+t,e.nodes=(e.nodes||[]).map(e=>this.getNode(e)),e}_resolveNode(e,t){return e.id=e.id||"node-"+t,e.children&&(e.children=e.children.map(e=>this.getNode(e))),void 0!==e.mesh?e.mesh=this.getMesh(e.mesh):void 0!==e.meshes&&e.meshes.length&&(e.mesh=e.meshes.reduce((e,t)=>{const n=this.getMesh(t);return e.id=n.id,e.primitives=e.primitives.concat(n.primitives),e},{primitives:[]})),void 0!==e.camera&&(e.camera=this.getCamera(e.camera)),void 0!==e.skin&&(e.skin=this.getSkin(e.skin)),e}_resolveSkin(e,t){return e.id=e.id||"skin-"+t,e.inverseBindMatrices=this.getAccessor(e.inverseBindMatrices),e}_resolveMesh(e,t){return e.id=e.id||"mesh-"+t,e.primitives&&(e.primitives=e.primitives.map(e=>{const t=(e={...e}).attributes;e.attributes={};for(const n in t)e.attributes[n]=this.getAccessor(t[n]);return void 0!==e.indices&&(e.indices=this.getAccessor(e.indices)),void 0!==e.material&&(e.material=this.getMaterial(e.material)),e})),e}_resolveMaterial(e,t){if(e.id=e.id||"material-"+t,e.normalTexture&&(e.normalTexture={...e.normalTexture},e.normalTexture.texture=this.getTexture(e.normalTexture.index)),e.occlusionTexture&&(e.occlustionTexture={...e.occlustionTexture},e.occlusionTexture.texture=this.getTexture(e.occlusionTexture.index)),e.emissiveTexture&&(e.emmisiveTexture={...e.emmisiveTexture},e.emissiveTexture.texture=this.getTexture(e.emissiveTexture.index)),e.emissiveFactor||(e.emissiveFactor=e.emmisiveTexture?[1,1,1]:[0,0,0]),e.pbrMetallicRoughness){e.pbrMetallicRoughness={...e.pbrMetallicRoughness};const t=e.pbrMetallicRoughness;t.baseColorTexture&&(t.baseColorTexture={...t.baseColorTexture},t.baseColorTexture.texture=this.getTexture(t.baseColorTexture.index)),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture={...t.metallicRoughnessTexture},t.metallicRoughnessTexture.texture=this.getTexture(t.metallicRoughnessTexture.index))}return e}_resolveAccessor(e,t){var n,r;if(e.id=e.id||"accessor-"+t,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=(n=e.componentType,st[n]),e.components=(r=e.type,rt[r]),e.bytesPerElement=e.bytesPerComponent*e.components,e.bufferView){const t=e.bufferView.buffer,{ArrayType:n,byteLength:r}=Ne(e,e.bufferView),s=(e.bufferView.byteOffset||0)+(e.byteOffset||0)+t.byteOffset,i=t.arrayBuffer.slice(s,s+r);e.value=new n(i)}return e}_resolveTexture(e,t){return e.id=e.id||"texture-"+t,e.sampler="sampler"in e?this.getSampler(e.sampler):at,e.source=this.getImage(e.source),e}_resolveSampler(e,t){e.id=e.id||"sampler-"+t,e.parameters={};for(const t in e){const n=this._enumSamplerParameter(t);void 0!==n&&(e.parameters[n]=e[t])}return e}_enumSamplerParameter(e){return ot[e]}_resolveImage(e,t){e.id=e.id||"image-"+t,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView));const n=this.images[t];return n&&(e.image=n),e}_resolveBufferView(e,t){e.id=e.id||"bufferView-"+t;const n=e.buffer;e.buffer=this.buffers[n];const r=this.buffers[n].arrayBuffer;let s=this.buffers[n].byteOffset||0;return"byteOffset"in e&&(s+=e.byteOffset),e.data=new Uint8Array(r,s,e.byteLength),e}_resolveCamera(e,t){return e.id=e.id||"camera-"+t,e.perspective,e.orthographic,e}}function ut(e,t){return(new ct).postProcess(e,t)}const ft=1735152710;function dt(e,t=0,n={}){const r=new DataView(e),{magic:s=ft}=n,i=r.getUint32(t,!1);return i===s||i===ft}function lt(e,t,n=0,r={}){const s=new DataView(t),i=function(e,t=0){return`${String.fromCharCode(e.getUint8(t+0))}${String.fromCharCode(e.getUint8(t+1))}${String.fromCharCode(e.getUint8(t+2))}${String.fromCharCode(e.getUint8(t+3))}`}(s,n+0),o=s.getUint32(n+4,!0),a=s.getUint32(n+8,!0);switch(Object.assign(e,{header:{byteOffset:n,byteLength:a,hasBinChunk:!1},type:i,version:o,json:{},binChunks:[]}),n+=12,e.version){case 1:return function(e,t,n){je(e.header.byteLength>20);const r=t.getUint32(n+0,!0),s=t.getUint32(n+4,!0);return n+=8,je(0===s),ht(e,t,n,r),n+=r,n+=mt(e,t,n,e.header.byteLength)}(e,s,n);case 2:return function(e,t,n,r){return je(e.header.byteLength>20),function(e,t,n,r){for(;n+8<=e.header.byteLength;){const s=t.getUint32(n+0,!0),i=t.getUint32(n+4,!0);switch(n+=8,i){case 1313821514:ht(e,t,n,s);break;case 5130562:mt(e,t,n,s);break;case 0:r.strict||ht(e,t,n,s);break;case 1:r.strict||mt(e,t,n,s)}n+=Ee(s,4)}}(e,t,n,r),n+e.header.byteLength}(e,s,n,{});default:throw new Error(`Invalid GLB version ${e.version}. Only supports v1 and v2.`)}}function ht(e,t,n,r){const s=new Uint8Array(t.buffer,n,r),i=new TextDecoder("utf8").decode(s);return e.json=JSON.parse(i),Ee(r,4)}function mt(e,t,n,r){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:n,byteLength:r,arrayBuffer:t.buffer}),Ee(r,4)}async function gt(e,t,n=0,r,s){var i,o,a,c;!function(e,t,n,r){r.uri&&(e.baseUri=r.uri);if(t instanceof ArrayBuffer&&!dt(t,n,r)){const e=new TextDecoder;t=e.decode(t)}if("string"==typeof t)e.json=M(t);else if(t instanceof ArrayBuffer){const s={};n=lt(s,t,n,r.glb),R("glTF"===s.type,"Invalid GLB magic string "+s.type),e._glb=s,e.json=s.json}else R(!1,"GLTF: must be ArrayBuffer or string");const s=e.json.buffers||[];if(e.buffers=new Array(s.length).fill(null),e._glb&&e._glb.header.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const i=e.json.images||[];e.images=new Array(i.length).fill({})}(e,t,n,r),function(e,t={}){(new nt).normalize(e,t)}(e,{normalize:null==r||null===(i=r.gltf)||void 0===i?void 0:i.normalize});const u=[];if(null!=r&&null!==(o=r.gltf)&&void 0!==o&&o.loadBuffers&&e.json.buffers&&await async function(e,t,n){for(let i=0;i<e.json.buffers.length;++i){const o=e.json.buffers[i];if(o.uri){var r,s;const{fetch:a}=n;R(a);const c=B(o.uri,t),u=await(null==n||null===(r=n.fetch)||void 0===r?void 0:r.call(n,c)),f=await(null==u||null===(s=u.arrayBuffer)||void 0===s?void 0:s.call(u));e.buffers[i]={arrayBuffer:f,byteOffset:0,byteLength:f.byteLength},delete o.uri}}}(e,r,s),null!=r&&null!==(a=r.gltf)&&void 0!==a&&a.loadImages){const t=async function(e,t,n){const r=e.json.images||[],s=[];for(let i=0;i<r.length;++i)s.push(bt(e,r[i],i,t,n));return await Promise.all(s)}(e,r,s);u.push(t)}const f=async function(e,t={},n){for(const s in Ze){var r;const i=(null==t||null===(r=t.gltf)||void 0===r?void 0:r.excludeExtensions)||{};if(!(s in i&&!i[s])){const r=Ze[s];await r.decode(e,t,n)}}}(e,r,s);return u.push(f),await Promise.all(u),null!=r&&null!==(c=r.gltf)&&void 0!==c&&c.postProcess?ut(e,r):e}async function bt(e,t,n,r,s){const{fetch:i,parse:o}=s;let a;if(t.uri){const e=B(t.uri,r),n=await i(e);a=await n.arrayBuffer()}if(Number.isFinite(t.bufferView)){const n=F(e.json,e.buffers,t.bufferView);a=L(n.buffer,n.byteOffset,n.byteLength)}R(a,"glTF image has no data");const c=await o(a,S,{},s);e.images[n]=c}const yt={name:"glTF",id:"gltf",module:"gltf",version:c,extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e,t={},n){(t={...yt.options,...t}).gltf={...yt.options.gltf,...t.gltf};const{byteOffset:r=0}=t;return await gt({},e,r,t,n)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0,postProcess:!0},log:console},deprecatedOptions:{fetchImages:"gltf.loadImages",createImages:"gltf.loadImages",decompress:"gltf.decompressMeshes",postProcess:"gltf.postProcess",gltf:{decompress:"gltf.decompressMeshes"}}};function pt(e,t,n,r){const s=Ee(n.byteLength,r),i=s-n.byteLength;if(e){const r=new Uint8Array(e.buffer,e.byteOffset+t,n.byteLength),s=new Uint8Array(n);r.set(s);for(let r=0;r<i;++r)e.setUint8(t+n.byteLength+r,32)}return t+=s}const wt=1179937895;function Tt(e,t,n=0,r={}){const{magic:s=wt,version:i=2,json:o={},binary:a}=e,c=n;t&&(t.setUint32(n+0,s,!0),t.setUint32(n+4,i,!0),t.setUint32(n+8,0,!0));const u=n+8,f=n+=12;t&&(t.setUint32(n+0,0,!0),t.setUint32(n+4,1313821514,!0));if(n=function(e,t,n,r){return t=pt(e,t,(new TextEncoder).encode(n),r)}(t,n+=8,JSON.stringify(o),4),t){const e=n-f-8;t.setUint32(f+0,e,!0)}if(a){const e=n;if(t&&(t.setUint32(n+0,0,!0),t.setUint32(n+4,5130562,!0)),n=pt(t,n+=8,a,4),t){const r=n-e-8;t.setUint32(e+0,r,!0)}}if(t){const e=n-c;t.setUint32(u,e,!0)}return n}function vt(e,t,n,r){return function(e,{firstBuffer:t=0}={}){if(e.buffers&&e.buffers.length>t)throw new Error("encodeGLTF: multiple buffers not yet implemented")}(e),Tt(e,t,n,r)}const _t={name:"glTF",id:"gltf",module:"gltf",version:c,extensions:["glb"],mimeTypes:["model/gltf-binary"],binary:!0,encodeSync:function(e,t={}){const{byteOffset:n=0}=t,r=vt(e,null,n,t),s=new ArrayBuffer(r),i=new DataView(s);return vt(e,i,n,t),s},options:{gltf:{}}};const xt={name:"GLB",id:"glb",module:"gltf",version:c,extensions:["glb"],mimeTypes:["model/gltf-binary"],binary:!0,parse:async function(e,t){return At(e,t)},parseSync:At,options:{glb:{strict:!1}}};function At(e,t){const{byteOffset:n=0}=t||{},r={};return lt(r,e,n,null==t?void 0:t.glb),r}const It={name:"GLB",id:"glb",module:"gltf",version:c,extensions:["glb"],mimeTypes:["model/gltf-binary"],binary:!0,encodeSync:function(e,t){const{byteOffset:n=0}=t,r=Tt(e,null,n,t),s=new ArrayBuffer(r),i=new DataView(s);return Tt(e,i,n,t),s},options:{glb:{}}}}])}));
|
|
2
|
-
//# sourceMappingURL=dist.min.js.map
|