@babylonjs/loaders 5.0.0-rc.1 → 5.0.0-rc.12
Sign up to get free protection for your applications and to get access to all the features.
- package/OBJ/index.d.ts +4 -4
- package/OBJ/index.js +4 -4
- package/OBJ/index.js.map +1 -1
- package/OBJ/mtlFileLoader.d.ts +41 -40
- package/OBJ/mtlFileLoader.js +232 -231
- package/OBJ/mtlFileLoader.js.map +1 -1
- package/OBJ/objFileLoader.d.ts +126 -133
- package/OBJ/objFileLoader.js +296 -300
- package/OBJ/objFileLoader.js.map +1 -1
- package/OBJ/objLoadingOptions.d.ts +43 -43
- package/OBJ/objLoadingOptions.js +1 -1
- package/OBJ/objLoadingOptions.js.map +1 -1
- package/OBJ/solidParser.d.ts +154 -153
- package/OBJ/solidParser.js +693 -699
- package/OBJ/solidParser.js.map +1 -1
- package/STL/index.d.ts +1 -1
- package/STL/index.js +1 -1
- package/STL/index.js.map +1 -1
- package/STL/stlFileLoader.d.ts +64 -71
- package/STL/stlFileLoader.js +233 -239
- package/STL/stlFileLoader.js.map +1 -1
- package/glTF/1.0/glTFBinaryExtension.d.ts +13 -13
- package/glTF/1.0/glTFBinaryExtension.js +60 -61
- package/glTF/1.0/glTFBinaryExtension.js.map +1 -1
- package/glTF/1.0/glTFLoader.d.ts +136 -106
- package/glTF/1.0/glTFLoader.js +1814 -1696
- package/glTF/1.0/glTFLoader.js.map +1 -1
- package/glTF/1.0/glTFLoaderInterfaces.d.ts +412 -412
- package/glTF/1.0/glTFLoaderInterfaces.js +95 -95
- package/glTF/1.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/1.0/glTFLoaderUtils.d.ts +63 -62
- package/glTF/1.0/glTFLoaderUtils.js +250 -232
- package/glTF/1.0/glTFLoaderUtils.js.map +1 -1
- package/glTF/1.0/glTFMaterialsCommonExtension.d.ts +10 -10
- package/glTF/1.0/glTFMaterialsCommonExtension.js +129 -127
- package/glTF/1.0/glTFMaterialsCommonExtension.js.map +1 -1
- package/glTF/1.0/index.d.ts +5 -5
- package/glTF/1.0/index.js +5 -5
- package/glTF/1.0/index.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_lights_image_based.d.ts +43 -36
- package/glTF/2.0/Extensions/EXT_lights_image_based.js +117 -110
- package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +36 -28
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +88 -80
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +34 -27
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js +49 -42
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +29 -21
- package/glTF/2.0/Extensions/EXT_texture_webp.js +40 -32
- package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
- package/glTF/2.0/Extensions/ExtrasAsMetadata.d.ts +50 -32
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js +73 -55
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +39 -31
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +112 -101
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +36 -28
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +89 -81
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +39 -31
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +94 -86
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +38 -30
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +53 -45
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +42 -34
- package/glTF/2.0/Extensions/KHR_materials_ior.js +62 -54
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.d.ts +38 -30
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +80 -72
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +39 -31
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +84 -76
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +38 -30
- package/glTF/2.0/Extensions/KHR_materials_specular.js +74 -66
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_translucency.d.ts +39 -31
- package/glTF/2.0/Extensions/KHR_materials_translucency.js +83 -76
- package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +38 -30
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +288 -277
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +38 -30
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +73 -65
- package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_variants.d.ts +87 -76
- package/glTF/2.0/Extensions/KHR_materials_variants.js +254 -243
- package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +39 -31
- package/glTF/2.0/Extensions/KHR_materials_volume.js +85 -78
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_mesh_quantization.d.ts +22 -19
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js +23 -21
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +29 -21
- package/glTF/2.0/Extensions/KHR_texture_basisu.js +40 -32
- package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +33 -25
- package/glTF/2.0/Extensions/KHR_texture_transform.js +61 -53
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +32 -29
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +49 -46
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_audio_emitter.d.ts +54 -38
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js +240 -216
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_lod.d.ts +109 -75
- package/glTF/2.0/Extensions/MSFT_lod.js +369 -333
- package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.d.ts +14 -14
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +36 -36
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.d.ts +14 -14
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +36 -36
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
- package/glTF/2.0/Extensions/index.d.ts +26 -26
- package/glTF/2.0/Extensions/index.js +26 -26
- package/glTF/2.0/Extensions/index.js.map +1 -1
- package/glTF/2.0/glTFLoader.d.ts +406 -357
- package/glTF/2.0/glTFLoader.js +2366 -2266
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/glTF/2.0/glTFLoaderExtension.d.ts +152 -152
- package/glTF/2.0/glTFLoaderExtension.js +1 -1
- package/glTF/2.0/glTFLoaderExtension.js.map +1 -1
- package/glTF/2.0/glTFLoaderInterfaces.d.ts +211 -209
- package/glTF/2.0/glTFLoaderInterfaces.js +1 -1
- package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/2.0/index.d.ts +4 -4
- package/glTF/2.0/index.js +5 -4
- package/glTF/2.0/index.js.map +1 -1
- package/glTF/glTFFileLoader.d.ts +433 -373
- package/glTF/glTFFileLoader.js +927 -870
- package/glTF/glTFFileLoader.js.map +1 -1
- package/glTF/glTFValidation.d.ts +29 -29
- package/glTF/glTFValidation.js +123 -121
- package/glTF/glTFValidation.js.map +1 -1
- package/glTF/index.d.ts +5 -5
- package/glTF/index.js +6 -5
- package/glTF/index.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +4 -3
- package/index.js.map +1 -1
- package/legacy/legacy-glTF.d.ts +2 -2
- package/legacy/legacy-glTF.js +18 -18
- package/legacy/legacy-glTF.js.map +1 -1
- package/legacy/legacy-glTF1.d.ts +2 -2
- package/legacy/legacy-glTF1.js +15 -14
- package/legacy/legacy-glTF1.js.map +1 -1
- package/legacy/legacy-glTF1FileLoader.d.ts +2 -2
- package/legacy/legacy-glTF1FileLoader.js +3 -2
- package/legacy/legacy-glTF1FileLoader.js.map +1 -1
- package/legacy/legacy-glTF2.d.ts +2 -2
- package/legacy/legacy-glTF2.js +33 -32
- package/legacy/legacy-glTF2.js.map +1 -1
- package/legacy/legacy-glTF2FileLoader.d.ts +2 -2
- package/legacy/legacy-glTF2FileLoader.js +3 -2
- package/legacy/legacy-glTF2FileLoader.js.map +1 -1
- package/legacy/legacy-glTFFileLoader.d.ts +3 -3
- package/legacy/legacy-glTFFileLoader.js +4 -3
- package/legacy/legacy-glTFFileLoader.js.map +1 -1
- package/legacy/legacy-objFileLoader.d.ts +1 -1
- package/legacy/legacy-objFileLoader.js +13 -12
- package/legacy/legacy-objFileLoader.js.map +1 -1
- package/legacy/legacy-stlFileLoader.d.ts +1 -1
- package/legacy/legacy-stlFileLoader.js +13 -12
- package/legacy/legacy-stlFileLoader.js.map +1 -1
- package/legacy/legacy.d.ts +6 -6
- package/legacy/legacy.js +8 -6
- package/legacy/legacy.js.map +1 -1
- package/license.md +71 -0
- package/package.json +37 -193
- package/readme.md +2 -2
@@ -1,31 +1,39 @@
|
|
1
|
-
import { DracoCompression } from "@babylonjs/core/Meshes/Compression/dracoCompression";
|
2
|
-
import { Nullable } from "@babylonjs/core/types";
|
3
|
-
import { Geometry } from "@babylonjs/core/Meshes/geometry";
|
4
|
-
import { Mesh } from "@babylonjs/core/Meshes/mesh";
|
5
|
-
import { IMeshPrimitive } from "../glTFLoaderInterfaces";
|
6
|
-
import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
|
7
|
-
import { GLTFLoader } from "../glTFLoader";
|
8
|
-
/**
|
9
|
-
* [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
|
10
|
-
*/
|
11
|
-
export declare class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
|
12
|
-
/**
|
13
|
-
* The name of this extension.
|
14
|
-
*/
|
15
|
-
readonly name = "KHR_draco_mesh_compression";
|
16
|
-
/**
|
17
|
-
* The draco compression used to decode vertex data or DracoCompression.Default if not defined
|
18
|
-
*/
|
19
|
-
dracoCompression?: DracoCompression;
|
20
|
-
/**
|
21
|
-
* Defines whether this extension is enabled.
|
22
|
-
*/
|
23
|
-
enabled: boolean;
|
24
|
-
private _loader;
|
25
|
-
/**
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
1
|
+
import { DracoCompression } from "@babylonjs/core/Meshes/Compression/dracoCompression.js";
|
2
|
+
import type { Nullable } from "@babylonjs/core/types.js";
|
3
|
+
import { Geometry } from "@babylonjs/core/Meshes/geometry.js";
|
4
|
+
import type { Mesh } from "@babylonjs/core/Meshes/mesh.js";
|
5
|
+
import type { IMeshPrimitive } from "../glTFLoaderInterfaces";
|
6
|
+
import type { IGLTFLoaderExtension } from "../glTFLoaderExtension";
|
7
|
+
import { GLTFLoader } from "../glTFLoader";
|
8
|
+
/**
|
9
|
+
* [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
|
10
|
+
*/
|
11
|
+
export declare class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
|
12
|
+
/**
|
13
|
+
* The name of this extension.
|
14
|
+
*/
|
15
|
+
readonly name = "KHR_draco_mesh_compression";
|
16
|
+
/**
|
17
|
+
* The draco compression used to decode vertex data or DracoCompression.Default if not defined
|
18
|
+
*/
|
19
|
+
dracoCompression?: DracoCompression;
|
20
|
+
/**
|
21
|
+
* Defines whether this extension is enabled.
|
22
|
+
*/
|
23
|
+
enabled: boolean;
|
24
|
+
private _loader;
|
25
|
+
/**
|
26
|
+
* @param loader
|
27
|
+
* @hidden
|
28
|
+
*/
|
29
|
+
constructor(loader: GLTFLoader);
|
30
|
+
/** @hidden */
|
31
|
+
dispose(): void;
|
32
|
+
/**
|
33
|
+
* @param context
|
34
|
+
* @param primitive
|
35
|
+
* @param babylonMesh
|
36
|
+
* @hidden
|
37
|
+
*/
|
38
|
+
_loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
|
39
|
+
}
|
@@ -1,102 +1,113 @@
|
|
1
|
-
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
if (
|
43
|
-
|
44
|
-
}
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
loadAttribute("
|
79
|
-
loadAttribute("
|
80
|
-
loadAttribute("
|
81
|
-
loadAttribute("
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
1
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
2
|
+
import { DracoCompression } from "@babylonjs/core/Meshes/Compression/dracoCompression.js";
|
3
|
+
import { VertexBuffer } from "@babylonjs/core/Buffers/buffer.js";
|
4
|
+
import { Geometry } from "@babylonjs/core/Meshes/geometry.js";
|
5
|
+
import { GLTFLoader, ArrayItem } from "../glTFLoader";
|
6
|
+
var NAME = "KHR_draco_mesh_compression";
|
7
|
+
/**
|
8
|
+
* [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
|
9
|
+
*/
|
10
|
+
var KHR_draco_mesh_compression = /** @class */ (function () {
|
11
|
+
/**
|
12
|
+
* @param loader
|
13
|
+
* @hidden
|
14
|
+
*/
|
15
|
+
function KHR_draco_mesh_compression(loader) {
|
16
|
+
/**
|
17
|
+
* The name of this extension.
|
18
|
+
*/
|
19
|
+
this.name = NAME;
|
20
|
+
this._loader = loader;
|
21
|
+
this.enabled = DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME);
|
22
|
+
}
|
23
|
+
/** @hidden */
|
24
|
+
KHR_draco_mesh_compression.prototype.dispose = function () {
|
25
|
+
delete this.dracoCompression;
|
26
|
+
this._loader = null;
|
27
|
+
};
|
28
|
+
/**
|
29
|
+
* @param context
|
30
|
+
* @param primitive
|
31
|
+
* @param babylonMesh
|
32
|
+
* @hidden
|
33
|
+
*/
|
34
|
+
KHR_draco_mesh_compression.prototype._loadVertexDataAsync = function (context, primitive, babylonMesh) {
|
35
|
+
var _this = this;
|
36
|
+
return GLTFLoader.LoadExtensionAsync(context, primitive, this.name, function (extensionContext, extension) {
|
37
|
+
if (primitive.mode != undefined) {
|
38
|
+
if (primitive.mode !== 5 /* TRIANGLE_STRIP */ && primitive.mode !== 4 /* TRIANGLES */) {
|
39
|
+
throw new Error("".concat(context, ": Unsupported mode ").concat(primitive.mode));
|
40
|
+
}
|
41
|
+
// TODO: handle triangle strips
|
42
|
+
if (primitive.mode === 5 /* TRIANGLE_STRIP */) {
|
43
|
+
throw new Error("".concat(context, ": Mode ").concat(primitive.mode, " is not currently supported"));
|
44
|
+
}
|
45
|
+
}
|
46
|
+
var attributes = {};
|
47
|
+
var dividers = {};
|
48
|
+
var loadAttribute = function (name, kind) {
|
49
|
+
var uniqueId = extension.attributes[name];
|
50
|
+
if (uniqueId === undefined || primitive.attributes[name] === undefined) {
|
51
|
+
return;
|
52
|
+
}
|
53
|
+
attributes[kind] = uniqueId;
|
54
|
+
var accessor = ArrayItem.Get("".concat(context, "/attributes/").concat(name), _this._loader.gltf.accessors, primitive.attributes[name]);
|
55
|
+
if (accessor.normalized && accessor.componentType !== 5126 /* FLOAT */) {
|
56
|
+
var divider = 1;
|
57
|
+
switch (accessor.componentType) {
|
58
|
+
case 5120 /* BYTE */:
|
59
|
+
divider = 127.0;
|
60
|
+
break;
|
61
|
+
case 5121 /* UNSIGNED_BYTE */:
|
62
|
+
divider = 255.0;
|
63
|
+
break;
|
64
|
+
case 5122 /* SHORT */:
|
65
|
+
divider = 32767.0;
|
66
|
+
break;
|
67
|
+
case 5123 /* UNSIGNED_SHORT */:
|
68
|
+
divider = 65535.0;
|
69
|
+
break;
|
70
|
+
}
|
71
|
+
dividers[kind] = divider;
|
72
|
+
}
|
73
|
+
babylonMesh._delayInfo = babylonMesh._delayInfo || [];
|
74
|
+
if (babylonMesh._delayInfo.indexOf(kind) === -1) {
|
75
|
+
babylonMesh._delayInfo.push(kind);
|
76
|
+
}
|
77
|
+
};
|
78
|
+
loadAttribute("POSITION", VertexBuffer.PositionKind);
|
79
|
+
loadAttribute("NORMAL", VertexBuffer.NormalKind);
|
80
|
+
loadAttribute("TANGENT", VertexBuffer.TangentKind);
|
81
|
+
loadAttribute("TEXCOORD_0", VertexBuffer.UVKind);
|
82
|
+
loadAttribute("TEXCOORD_1", VertexBuffer.UV2Kind);
|
83
|
+
loadAttribute("TEXCOORD_2", VertexBuffer.UV3Kind);
|
84
|
+
loadAttribute("TEXCOORD_3", VertexBuffer.UV4Kind);
|
85
|
+
loadAttribute("TEXCOORD_4", VertexBuffer.UV5Kind);
|
86
|
+
loadAttribute("TEXCOORD_5", VertexBuffer.UV6Kind);
|
87
|
+
loadAttribute("JOINTS_0", VertexBuffer.MatricesIndicesKind);
|
88
|
+
loadAttribute("WEIGHTS_0", VertexBuffer.MatricesWeightsKind);
|
89
|
+
loadAttribute("COLOR_0", VertexBuffer.ColorKind);
|
90
|
+
var bufferView = ArrayItem.Get(extensionContext, _this._loader.gltf.bufferViews, extension.bufferView);
|
91
|
+
if (!bufferView._dracoBabylonGeometry) {
|
92
|
+
bufferView._dracoBabylonGeometry = _this._loader.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) {
|
93
|
+
var dracoCompression = _this.dracoCompression || DracoCompression.Default;
|
94
|
+
return dracoCompression
|
95
|
+
.decodeMeshAsync(data, attributes, dividers)
|
96
|
+
.then(function (babylonVertexData) {
|
97
|
+
var babylonGeometry = new Geometry(babylonMesh.name, _this._loader.babylonScene);
|
98
|
+
babylonVertexData.applyToGeometry(babylonGeometry);
|
99
|
+
return babylonGeometry;
|
100
|
+
})
|
101
|
+
.catch(function (error) {
|
102
|
+
throw new Error("".concat(context, ": ").concat(error.message));
|
103
|
+
});
|
104
|
+
});
|
105
|
+
}
|
106
|
+
return bufferView._dracoBabylonGeometry;
|
107
|
+
});
|
108
|
+
};
|
109
|
+
return KHR_draco_mesh_compression;
|
110
|
+
}());
|
111
|
+
export { KHR_draco_mesh_compression };
|
112
|
+
GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_draco_mesh_compression(loader); });
|
102
113
|
//# sourceMappingURL=KHR_draco_mesh_compression.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KHR_draco_mesh_compression.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,qDAAqD,CAAC;AAEvF,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAM3D,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEtD,IAAM,IAAI,GAAG,4BAA4B,CAAC;AAM1C;;GAEG;AACH;IAkBI,cAAc;IACd,oCAAY,MAAkB;QAlB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAgBxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC,gBAAgB,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC3F,CAAC;IAED,cAAc;IACP,4CAAO,GAAd;QACI,OAAO,IAAI,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,MAAM,CAAC,EAAtC,CAAsC,CAAC,CAAC","sourcesContent":["import { DracoCompression } from \"@babylonjs/core/Meshes/Compression/dracoCompression\";\r\nimport { Nullable } from \"@babylonjs/core/types\";\r\nimport { VertexBuffer } from \"@babylonjs/core/Buffers/buffer\";\r\nimport { Geometry } from \"@babylonjs/core/Meshes/geometry\";\r\nimport { Mesh } from \"@babylonjs/core/Meshes/mesh\";\r\n\r\nimport { MeshPrimitiveMode, IKHRDracoMeshCompression, AccessorComponentType } from \"babylonjs-gltf2interface\";\r\nimport { IMeshPrimitive, IBufferView } from \"../glTFLoaderInterfaces\";\r\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\n\r\nconst NAME = \"KHR_draco_mesh_compression\";\r\n\r\ninterface IBufferViewDraco extends IBufferView {\r\n _dracoBabylonGeometry?: Promise<Geometry>;\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)\r\n */\r\nexport class KHR_draco_mesh_compression implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * The draco compression used to decode vertex data or DracoCompression.Default if not defined\r\n */\r\n public dracoCompression?: DracoCompression;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /** @hidden */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @hidden */\r\n public dispose(): void {\r\n delete this.dracoCompression;\r\n (this._loader as any) = null;\r\n }\r\n\r\n /** @hidden */\r\n public _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRDracoMeshCompression, Geometry>(context, primitive, this.name, (extensionContext, extension) => {\r\n if (primitive.mode != undefined) {\r\n if (primitive.mode !== MeshPrimitiveMode.TRIANGLE_STRIP &&\r\n primitive.mode !== MeshPrimitiveMode.TRIANGLES) {\r\n throw new Error(`${context}: Unsupported mode ${primitive.mode}`);\r\n }\r\n\r\n // TODO: handle triangle strips\r\n if (primitive.mode === MeshPrimitiveMode.TRIANGLE_STRIP) {\r\n throw new Error(`${context}: Mode ${primitive.mode} is not currently supported`);\r\n }\r\n }\r\n\r\n const attributes: {\r\n [kind: string]: number\r\n } = {};\r\n const dividers: {\r\n [kind: string]: number\r\n } = {};\r\n const loadAttribute = (name: string, kind: string) => {\r\n const uniqueId = extension.attributes[name];\r\n if (uniqueId === undefined || primitive.attributes[name] === undefined) {\r\n return;\r\n }\r\n\r\n attributes[kind] = uniqueId;\r\n const accessor = ArrayItem.Get(`${context}/attributes/${name}`, this._loader.gltf.accessors, primitive.attributes[name]);\r\n if (accessor.normalized && accessor.componentType !== AccessorComponentType.FLOAT) {\r\n let divider = 1;\r\n switch (accessor.componentType) {\r\n case AccessorComponentType.BYTE:\r\n divider = 127.0;\r\n break;\r\n case AccessorComponentType.UNSIGNED_BYTE:\r\n divider = 255.0;\r\n break;\r\n case AccessorComponentType.SHORT:\r\n divider = 32767.0;\r\n break;\r\n case AccessorComponentType.UNSIGNED_SHORT:\r\n divider = 65535.0;\r\n break;\r\n }\r\n dividers[kind] = divider;\r\n }\r\n\r\n babylonMesh._delayInfo = babylonMesh._delayInfo || [];\r\n if (babylonMesh._delayInfo.indexOf(kind) === -1) {\r\n babylonMesh._delayInfo.push(kind);\r\n }\r\n\r\n };\r\n\r\n loadAttribute(\"POSITION\", VertexBuffer.PositionKind);\r\n loadAttribute(\"NORMAL\", VertexBuffer.NormalKind);\r\n loadAttribute(\"TANGENT\", VertexBuffer.TangentKind);\r\n loadAttribute(\"TEXCOORD_0\", VertexBuffer.UVKind);\r\n loadAttribute(\"TEXCOORD_1\", VertexBuffer.UV2Kind);\r\n loadAttribute(\"TEXCOORD_2\", VertexBuffer.UV3Kind);\r\n loadAttribute(\"TEXCOORD_3\", VertexBuffer.UV4Kind);\r\n loadAttribute(\"TEXCOORD_4\", VertexBuffer.UV5Kind);\r\n loadAttribute(\"TEXCOORD_5\", VertexBuffer.UV6Kind);\r\n loadAttribute(\"JOINTS_0\", VertexBuffer.MatricesIndicesKind);\r\n loadAttribute(\"WEIGHTS_0\", VertexBuffer.MatricesWeightsKind);\r\n loadAttribute(\"COLOR_0\", VertexBuffer.ColorKind);\r\n\r\n var bufferView = ArrayItem.Get(extensionContext, this._loader.gltf.bufferViews, extension.bufferView) as IBufferViewDraco;\r\n if (!bufferView._dracoBabylonGeometry) {\r\n bufferView._dracoBabylonGeometry = this._loader.loadBufferViewAsync(`/bufferViews/${bufferView.index}`, bufferView).then((data) => {\r\n const dracoCompression = this.dracoCompression || DracoCompression.Default;\r\n return dracoCompression.decodeMeshAsync(data, attributes, dividers).then((babylonVertexData) => {\r\n const babylonGeometry = new Geometry(babylonMesh.name, this._loader.babylonScene);\r\n babylonVertexData.applyToGeometry(babylonGeometry);\r\n return babylonGeometry;\r\n }).catch((error) => {\r\n throw new Error(`${context}: ${error.message}`);\r\n });\r\n });\r\n }\r\n\r\n return bufferView._dracoBabylonGeometry;\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_draco_mesh_compression(loader));"]}
|
1
|
+
{"version":3,"file":"KHR_draco_mesh_compression.js","sourceRoot":"","sources":["../../../../../../../lts/loaders/generated/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,gBAAgB,EAAE,+DAAiD;AAE5E,OAAO,EAAE,YAAY,EAAE,0CAA4B;AACnD,OAAO,EAAE,QAAQ,EAAE,2CAA6B;AAOhD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEtD,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C,UAAC,KAAK;wBACT,MAAM,IAAI,KAAK,CAAC,UAAG,OAAO,eAAK,KAAK,CAAC,OAAO,CAAE,CAAC,CAAC;oBACpD,CAAC,CAAC,CAAC;gBACX,CAAC,CAAC,CAAC;aACN;YAED,OAAO,UAAU,CAAC,qBAAqB,CAAC;QAC5C,CAAC,CAAC,CAAC;IACP,CAAC;IACL,iCAAC;AAAD,CAAC,AA5HD,IA4HC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,0BAA0B,CAAC,MAAM,CAAC,EAAtC,CAAsC,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { DracoCompression } from \"core/Meshes/Compression/dracoCompression\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport { Geometry } from \"core/Meshes/geometry\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\n\r\nimport type { IKHRDracoMeshCompression } from \"babylonjs-gltf2interface\";\r\nimport { MeshPrimitiveMode, AccessorComponentType } from \"babylonjs-gltf2interface\";\r\nimport type { IMeshPrimitive, IBufferView } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\n\r\nconst NAME = \"KHR_draco_mesh_compression\";\r\n\r\ninterface IBufferViewDraco extends IBufferView {\r\n _dracoBabylonGeometry?: Promise<Geometry>;\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)\r\n */\r\nexport class KHR_draco_mesh_compression implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * The draco compression used to decode vertex data or DracoCompression.Default if not defined\r\n */\r\n public dracoCompression?: DracoCompression;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @param loader\r\n * @hidden\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @hidden */\r\n public dispose(): void {\r\n delete this.dracoCompression;\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @param context\r\n * @param primitive\r\n * @param babylonMesh\r\n * @hidden\r\n */\r\n public _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRDracoMeshCompression, Geometry>(context, primitive, this.name, (extensionContext, extension) => {\r\n if (primitive.mode != undefined) {\r\n if (primitive.mode !== MeshPrimitiveMode.TRIANGLE_STRIP && primitive.mode !== MeshPrimitiveMode.TRIANGLES) {\r\n throw new Error(`${context}: Unsupported mode ${primitive.mode}`);\r\n }\r\n\r\n // TODO: handle triangle strips\r\n if (primitive.mode === MeshPrimitiveMode.TRIANGLE_STRIP) {\r\n throw new Error(`${context}: Mode ${primitive.mode} is not currently supported`);\r\n }\r\n }\r\n\r\n const attributes: {\r\n [kind: string]: number;\r\n } = {};\r\n const dividers: {\r\n [kind: string]: number;\r\n } = {};\r\n const loadAttribute = (name: string, kind: string) => {\r\n const uniqueId = extension.attributes[name];\r\n if (uniqueId === undefined || primitive.attributes[name] === undefined) {\r\n return;\r\n }\r\n\r\n attributes[kind] = uniqueId;\r\n const accessor = ArrayItem.Get(`${context}/attributes/${name}`, this._loader.gltf.accessors, primitive.attributes[name]);\r\n if (accessor.normalized && accessor.componentType !== AccessorComponentType.FLOAT) {\r\n let divider = 1;\r\n switch (accessor.componentType) {\r\n case AccessorComponentType.BYTE:\r\n divider = 127.0;\r\n break;\r\n case AccessorComponentType.UNSIGNED_BYTE:\r\n divider = 255.0;\r\n break;\r\n case AccessorComponentType.SHORT:\r\n divider = 32767.0;\r\n break;\r\n case AccessorComponentType.UNSIGNED_SHORT:\r\n divider = 65535.0;\r\n break;\r\n }\r\n dividers[kind] = divider;\r\n }\r\n\r\n babylonMesh._delayInfo = babylonMesh._delayInfo || [];\r\n if (babylonMesh._delayInfo.indexOf(kind) === -1) {\r\n babylonMesh._delayInfo.push(kind);\r\n }\r\n };\r\n\r\n loadAttribute(\"POSITION\", VertexBuffer.PositionKind);\r\n loadAttribute(\"NORMAL\", VertexBuffer.NormalKind);\r\n loadAttribute(\"TANGENT\", VertexBuffer.TangentKind);\r\n loadAttribute(\"TEXCOORD_0\", VertexBuffer.UVKind);\r\n loadAttribute(\"TEXCOORD_1\", VertexBuffer.UV2Kind);\r\n loadAttribute(\"TEXCOORD_2\", VertexBuffer.UV3Kind);\r\n loadAttribute(\"TEXCOORD_3\", VertexBuffer.UV4Kind);\r\n loadAttribute(\"TEXCOORD_4\", VertexBuffer.UV5Kind);\r\n loadAttribute(\"TEXCOORD_5\", VertexBuffer.UV6Kind);\r\n loadAttribute(\"JOINTS_0\", VertexBuffer.MatricesIndicesKind);\r\n loadAttribute(\"WEIGHTS_0\", VertexBuffer.MatricesWeightsKind);\r\n loadAttribute(\"COLOR_0\", VertexBuffer.ColorKind);\r\n\r\n const bufferView = ArrayItem.Get(extensionContext, this._loader.gltf.bufferViews, extension.bufferView) as IBufferViewDraco;\r\n if (!bufferView._dracoBabylonGeometry) {\r\n bufferView._dracoBabylonGeometry = this._loader.loadBufferViewAsync(`/bufferViews/${bufferView.index}`, bufferView).then((data) => {\r\n const dracoCompression = this.dracoCompression || DracoCompression.Default;\r\n return dracoCompression\r\n .decodeMeshAsync(data, attributes, dividers)\r\n .then((babylonVertexData) => {\r\n const babylonGeometry = new Geometry(babylonMesh.name, this._loader.babylonScene);\r\n babylonVertexData.applyToGeometry(babylonGeometry);\r\n return babylonGeometry;\r\n })\r\n .catch((error) => {\r\n throw new Error(`${context}: ${error.message}`);\r\n });\r\n });\r\n }\r\n\r\n return bufferView._dracoBabylonGeometry;\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_draco_mesh_compression(loader));\r\n"]}
|
@@ -1,28 +1,36 @@
|
|
1
|
-
import { Nullable } from "@babylonjs/core/types";
|
2
|
-
import { TransformNode } from "@babylonjs/core/Meshes/transformNode";
|
3
|
-
import { INode } from "../glTFLoaderInterfaces";
|
4
|
-
import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
|
5
|
-
import { GLTFLoader } from "../glTFLoader";
|
6
|
-
/**
|
7
|
-
* [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
|
8
|
-
*/
|
9
|
-
export declare class KHR_lights implements IGLTFLoaderExtension {
|
10
|
-
/**
|
11
|
-
* The name of this extension.
|
12
|
-
*/
|
13
|
-
readonly name = "KHR_lights_punctual";
|
14
|
-
/**
|
15
|
-
* Defines whether this extension is enabled.
|
16
|
-
*/
|
17
|
-
enabled: boolean;
|
18
|
-
private _loader;
|
19
|
-
private _lights?;
|
20
|
-
/**
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
1
|
+
import type { Nullable } from "@babylonjs/core/types.js";
|
2
|
+
import type { TransformNode } from "@babylonjs/core/Meshes/transformNode.js";
|
3
|
+
import type { INode } from "../glTFLoaderInterfaces";
|
4
|
+
import type { IGLTFLoaderExtension } from "../glTFLoaderExtension";
|
5
|
+
import { GLTFLoader } from "../glTFLoader";
|
6
|
+
/**
|
7
|
+
* [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
|
8
|
+
*/
|
9
|
+
export declare class KHR_lights implements IGLTFLoaderExtension {
|
10
|
+
/**
|
11
|
+
* The name of this extension.
|
12
|
+
*/
|
13
|
+
readonly name = "KHR_lights_punctual";
|
14
|
+
/**
|
15
|
+
* Defines whether this extension is enabled.
|
16
|
+
*/
|
17
|
+
enabled: boolean;
|
18
|
+
private _loader;
|
19
|
+
private _lights?;
|
20
|
+
/**
|
21
|
+
* @param loader
|
22
|
+
* @hidden
|
23
|
+
*/
|
24
|
+
constructor(loader: GLTFLoader);
|
25
|
+
/** @hidden */
|
26
|
+
dispose(): void;
|
27
|
+
/** @hidden */
|
28
|
+
onLoading(): void;
|
29
|
+
/**
|
30
|
+
* @param context
|
31
|
+
* @param node
|
32
|
+
* @param assign
|
33
|
+
* @hidden
|
34
|
+
*/
|
35
|
+
loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
|
36
|
+
}
|
@@ -1,82 +1,90 @@
|
|
1
|
-
import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
2
|
-
import { Color3 } from
|
3
|
-
import { DirectionalLight } from "@babylonjs/core/Lights/directionalLight.js";
|
4
|
-
import { PointLight } from "@babylonjs/core/Lights/pointLight.js";
|
5
|
-
import { SpotLight } from "@babylonjs/core/Lights/spotLight.js";
|
6
|
-
import { Light } from "@babylonjs/core/Lights/light.js";
|
7
|
-
import { GLTFLoader, ArrayItem } from "../glTFLoader
|
8
|
-
var NAME = "KHR_lights_punctual";
|
9
|
-
/**
|
10
|
-
* [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
|
11
|
-
*/
|
12
|
-
var KHR_lights = /** @class */ (function () {
|
13
|
-
/**
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
case "
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
GLTFLoader.
|
1
|
+
import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
2
|
+
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
3
|
+
import { DirectionalLight } from "@babylonjs/core/Lights/directionalLight.js";
|
4
|
+
import { PointLight } from "@babylonjs/core/Lights/pointLight.js";
|
5
|
+
import { SpotLight } from "@babylonjs/core/Lights/spotLight.js";
|
6
|
+
import { Light } from "@babylonjs/core/Lights/light.js";
|
7
|
+
import { GLTFLoader, ArrayItem } from "../glTFLoader";
|
8
|
+
var NAME = "KHR_lights_punctual";
|
9
|
+
/**
|
10
|
+
* [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
|
11
|
+
*/
|
12
|
+
var KHR_lights = /** @class */ (function () {
|
13
|
+
/**
|
14
|
+
* @param loader
|
15
|
+
* @hidden
|
16
|
+
*/
|
17
|
+
function KHR_lights(loader) {
|
18
|
+
/**
|
19
|
+
* The name of this extension.
|
20
|
+
*/
|
21
|
+
this.name = NAME;
|
22
|
+
this._loader = loader;
|
23
|
+
this.enabled = this._loader.isExtensionUsed(NAME);
|
24
|
+
}
|
25
|
+
/** @hidden */
|
26
|
+
KHR_lights.prototype.dispose = function () {
|
27
|
+
this._loader = null;
|
28
|
+
delete this._lights;
|
29
|
+
};
|
30
|
+
/** @hidden */
|
31
|
+
KHR_lights.prototype.onLoading = function () {
|
32
|
+
var extensions = this._loader.gltf.extensions;
|
33
|
+
if (extensions && extensions[this.name]) {
|
34
|
+
var extension = extensions[this.name];
|
35
|
+
this._lights = extension.lights;
|
36
|
+
}
|
37
|
+
};
|
38
|
+
/**
|
39
|
+
* @param context
|
40
|
+
* @param node
|
41
|
+
* @param assign
|
42
|
+
* @hidden
|
43
|
+
*/
|
44
|
+
KHR_lights.prototype.loadNodeAsync = function (context, node, assign) {
|
45
|
+
var _this = this;
|
46
|
+
return GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) {
|
47
|
+
return _this._loader.loadNodeAsync(context, node, function (babylonMesh) {
|
48
|
+
var babylonLight;
|
49
|
+
var light = ArrayItem.Get(extensionContext, _this._lights, extension.light);
|
50
|
+
var name = light.name || babylonMesh.name;
|
51
|
+
_this._loader.babylonScene._blockEntityCollection = !!_this._loader._assetContainer;
|
52
|
+
switch (light.type) {
|
53
|
+
case "directional" /* DIRECTIONAL */: {
|
54
|
+
babylonLight = new DirectionalLight(name, Vector3.Backward(), _this._loader.babylonScene);
|
55
|
+
break;
|
56
|
+
}
|
57
|
+
case "point" /* POINT */: {
|
58
|
+
babylonLight = new PointLight(name, Vector3.Zero(), _this._loader.babylonScene);
|
59
|
+
break;
|
60
|
+
}
|
61
|
+
case "spot" /* SPOT */: {
|
62
|
+
var babylonSpotLight = new SpotLight(name, Vector3.Zero(), Vector3.Backward(), 0, 1, _this._loader.babylonScene);
|
63
|
+
babylonSpotLight.angle = ((light.spot && light.spot.outerConeAngle) || Math.PI / 4) * 2;
|
64
|
+
babylonSpotLight.innerAngle = ((light.spot && light.spot.innerConeAngle) || 0) * 2;
|
65
|
+
babylonLight = babylonSpotLight;
|
66
|
+
break;
|
67
|
+
}
|
68
|
+
default: {
|
69
|
+
_this._loader.babylonScene._blockEntityCollection = false;
|
70
|
+
throw new Error("".concat(extensionContext, ": Invalid light type (").concat(light.type, ")"));
|
71
|
+
}
|
72
|
+
}
|
73
|
+
babylonLight._parentContainer = _this._loader._assetContainer;
|
74
|
+
_this._loader.babylonScene._blockEntityCollection = false;
|
75
|
+
babylonLight.falloffType = Light.FALLOFF_GLTF;
|
76
|
+
babylonLight.diffuse = light.color ? Color3.FromArray(light.color) : Color3.White();
|
77
|
+
babylonLight.intensity = light.intensity == undefined ? 1 : light.intensity;
|
78
|
+
babylonLight.range = light.range == undefined ? Number.MAX_VALUE : light.range;
|
79
|
+
babylonLight.parent = babylonMesh;
|
80
|
+
_this._loader._babylonLights.push(babylonLight);
|
81
|
+
GLTFLoader.AddPointerMetadata(babylonLight, extensionContext);
|
82
|
+
assign(babylonMesh);
|
83
|
+
});
|
84
|
+
});
|
85
|
+
};
|
86
|
+
return KHR_lights;
|
87
|
+
}());
|
88
|
+
export { KHR_lights };
|
89
|
+
GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_lights(loader); });
|
82
90
|
//# sourceMappingURL=KHR_lights_punctual.js.map
|