@babylonjs/loaders 5.0.0-rc.1 → 5.0.0-rc.10
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/package.json +23 -198
- package/readme.md +2 -2
@@ -1,128 +1,130 @@
|
|
1
|
-
import { __extends } from "tslib";
|
2
|
-
import { GLTFLoaderExtension } from "./glTFLoader
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
7
|
-
import {
|
8
|
-
import {
|
9
|
-
import {
|
10
|
-
import {
|
11
|
-
import {
|
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
|
-
var
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
case "directional":
|
49
|
-
var dirLight = new DirectionalLight(light.name, new Vector3(0, -1, 0), gltfRuntime.scene);
|
50
|
-
var directional = light.directional;
|
51
|
-
if (directional) {
|
52
|
-
dirLight.diffuse = Color3.FromArray(directional.color || [1, 1, 1]);
|
53
|
-
}
|
54
|
-
break;
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
spotLight
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
standardMaterial.
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
}
|
126
|
-
|
127
|
-
|
1
|
+
import { __extends } from "tslib";
|
2
|
+
import { GLTFLoaderExtension, GLTFLoaderBase, GLTFLoader } from "./glTFLoader";
|
3
|
+
import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
4
|
+
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
5
|
+
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
6
|
+
import { Material } from "@babylonjs/core/Materials/material.js";
|
7
|
+
import { StandardMaterial } from "@babylonjs/core/Materials/standardMaterial.js";
|
8
|
+
import { HemisphericLight } from "@babylonjs/core/Lights/hemisphericLight.js";
|
9
|
+
import { DirectionalLight } from "@babylonjs/core/Lights/directionalLight.js";
|
10
|
+
import { PointLight } from "@babylonjs/core/Lights/pointLight.js";
|
11
|
+
import { SpotLight } from "@babylonjs/core/Lights/spotLight.js";
|
12
|
+
/** @hidden */
|
13
|
+
var GLTFMaterialsCommonExtension = /** @class */ (function (_super) {
|
14
|
+
__extends(GLTFMaterialsCommonExtension, _super);
|
15
|
+
function GLTFMaterialsCommonExtension() {
|
16
|
+
return _super.call(this, "KHR_materials_common") || this;
|
17
|
+
}
|
18
|
+
GLTFMaterialsCommonExtension.prototype.loadRuntimeExtensionsAsync = function (gltfRuntime) {
|
19
|
+
if (!gltfRuntime.extensions) {
|
20
|
+
return false;
|
21
|
+
}
|
22
|
+
var extension = gltfRuntime.extensions[this.name];
|
23
|
+
if (!extension) {
|
24
|
+
return false;
|
25
|
+
}
|
26
|
+
// Create lights
|
27
|
+
var lights = extension.lights;
|
28
|
+
if (lights) {
|
29
|
+
for (var thing in lights) {
|
30
|
+
var light = lights[thing];
|
31
|
+
switch (light.type) {
|
32
|
+
case "ambient": {
|
33
|
+
var ambientLight = new HemisphericLight(light.name, new Vector3(0, 1, 0), gltfRuntime.scene);
|
34
|
+
var ambient = light.ambient;
|
35
|
+
if (ambient) {
|
36
|
+
ambientLight.diffuse = Color3.FromArray(ambient.color || [1, 1, 1]);
|
37
|
+
}
|
38
|
+
break;
|
39
|
+
}
|
40
|
+
case "point": {
|
41
|
+
var pointLight = new PointLight(light.name, new Vector3(10, 10, 10), gltfRuntime.scene);
|
42
|
+
var point = light.point;
|
43
|
+
if (point) {
|
44
|
+
pointLight.diffuse = Color3.FromArray(point.color || [1, 1, 1]);
|
45
|
+
}
|
46
|
+
break;
|
47
|
+
}
|
48
|
+
case "directional": {
|
49
|
+
var dirLight = new DirectionalLight(light.name, new Vector3(0, -1, 0), gltfRuntime.scene);
|
50
|
+
var directional = light.directional;
|
51
|
+
if (directional) {
|
52
|
+
dirLight.diffuse = Color3.FromArray(directional.color || [1, 1, 1]);
|
53
|
+
}
|
54
|
+
break;
|
55
|
+
}
|
56
|
+
case "spot": {
|
57
|
+
var spot = light.spot;
|
58
|
+
if (spot) {
|
59
|
+
var spotLight = new SpotLight(light.name, new Vector3(0, 10, 0), new Vector3(0, -1, 0), spot.fallOffAngle || Math.PI, spot.fallOffExponent || 0.0, gltfRuntime.scene);
|
60
|
+
spotLight.diffuse = Color3.FromArray(spot.color || [1, 1, 1]);
|
61
|
+
}
|
62
|
+
break;
|
63
|
+
}
|
64
|
+
default:
|
65
|
+
Tools.Warn('GLTF Material Common extension: light type "' + light.type + "” not supported");
|
66
|
+
break;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
return false;
|
71
|
+
};
|
72
|
+
GLTFMaterialsCommonExtension.prototype.loadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) {
|
73
|
+
var material = gltfRuntime.materials[id];
|
74
|
+
if (!material || !material.extensions) {
|
75
|
+
return false;
|
76
|
+
}
|
77
|
+
var extension = material.extensions[this.name];
|
78
|
+
if (!extension) {
|
79
|
+
return false;
|
80
|
+
}
|
81
|
+
var standardMaterial = new StandardMaterial(id, gltfRuntime.scene);
|
82
|
+
standardMaterial.sideOrientation = Material.CounterClockWiseSideOrientation;
|
83
|
+
if (extension.technique === "CONSTANT") {
|
84
|
+
standardMaterial.disableLighting = true;
|
85
|
+
}
|
86
|
+
standardMaterial.backFaceCulling = extension.doubleSided === undefined ? false : !extension.doubleSided;
|
87
|
+
standardMaterial.alpha = extension.values.transparency === undefined ? 1.0 : extension.values.transparency;
|
88
|
+
standardMaterial.specularPower = extension.values.shininess === undefined ? 0.0 : extension.values.shininess;
|
89
|
+
// Ambient
|
90
|
+
if (typeof extension.values.ambient === "string") {
|
91
|
+
this._loadTexture(gltfRuntime, extension.values.ambient, standardMaterial, "ambientTexture", onError);
|
92
|
+
}
|
93
|
+
else {
|
94
|
+
standardMaterial.ambientColor = Color3.FromArray(extension.values.ambient || [0, 0, 0]);
|
95
|
+
}
|
96
|
+
// Diffuse
|
97
|
+
if (typeof extension.values.diffuse === "string") {
|
98
|
+
this._loadTexture(gltfRuntime, extension.values.diffuse, standardMaterial, "diffuseTexture", onError);
|
99
|
+
}
|
100
|
+
else {
|
101
|
+
standardMaterial.diffuseColor = Color3.FromArray(extension.values.diffuse || [0, 0, 0]);
|
102
|
+
}
|
103
|
+
// Emission
|
104
|
+
if (typeof extension.values.emission === "string") {
|
105
|
+
this._loadTexture(gltfRuntime, extension.values.emission, standardMaterial, "emissiveTexture", onError);
|
106
|
+
}
|
107
|
+
else {
|
108
|
+
standardMaterial.emissiveColor = Color3.FromArray(extension.values.emission || [0, 0, 0]);
|
109
|
+
}
|
110
|
+
// Specular
|
111
|
+
if (typeof extension.values.specular === "string") {
|
112
|
+
this._loadTexture(gltfRuntime, extension.values.specular, standardMaterial, "specularTexture", onError);
|
113
|
+
}
|
114
|
+
else {
|
115
|
+
standardMaterial.specularColor = Color3.FromArray(extension.values.specular || [0, 0, 0]);
|
116
|
+
}
|
117
|
+
return true;
|
118
|
+
};
|
119
|
+
GLTFMaterialsCommonExtension.prototype._loadTexture = function (gltfRuntime, id, material, propertyPath, onError) {
|
120
|
+
// Create buffer from texture url
|
121
|
+
GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, function (buffer) {
|
122
|
+
// Create texture from buffer
|
123
|
+
GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, function (texture) { return (material[propertyPath] = texture); });
|
124
|
+
}, onError);
|
125
|
+
};
|
126
|
+
return GLTFMaterialsCommonExtension;
|
127
|
+
}(GLTFLoaderExtension));
|
128
|
+
export { GLTFMaterialsCommonExtension };
|
129
|
+
GLTFLoader.RegisterExtension(new GLTFMaterialsCommonExtension());
|
128
130
|
//# sourceMappingURL=glTFMaterialsCommonExtension.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"glTFMaterialsCommonExtension.js","sourceRoot":"","sources":["../../../../sourceES6/loaders/src/glTF/1.0/glTFMaterialsCommonExtension.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAI9C,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC1D,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAC9E,OAAO,EAA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CAAC;SAC7F;QAED,WAAW;QACX,IAAI,OAAO,SAAS,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE;YAC/C,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAC;SAC3G;aACI;YACD,gBAAgB,CAAC,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SAC7F;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,mDAAY,GAApB,UAAqB,WAAyB,EAAE,EAAU,EAAE,QAA0B,EAAE,YAAoB,EAAE,OAAkC;QAC5I,iCAAiC;QACjC,cAAc,CAAC,sBAAsB,CAAC,WAAW,EAAE,EAAE,EAAE,UAAC,MAAM;YAC1D,6BAA6B;YAC7B,cAAc,CAAC,kBAAkB,CAAC,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,UAAC,OAAO,IAAK,OAAM,QAAS,CAAC,YAAY,CAAC,GAAG,OAAO,EAAvC,CAAuC,EAAE,OAAO,CAAC,CAAC;QAC9H,CAAC,EAAE,OAAO,CAAC,CAAC;IAChB,CAAC;IACL,mCAAC;AAAD,CAAC,AAtHD,CAAkD,mBAAmB,GAsHpE;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,4BAA4B,EAAE,CAAC,CAAC","sourcesContent":["import { GLTFLoaderExtension } from \"./glTFLoader\";\nimport { GLTFLoaderBase } from \"./glTFLoader\";\n\nimport { IGLTFRuntime, IGLTFMaterial } from \"./glTFLoaderInterfaces\";\n\nimport { Vector3 } from \"@babylonjs/core/Maths/math.vector\";\nimport { Color3 } from '@babylonjs/core/Maths/math.color';\nimport { Tools } from \"@babylonjs/core/Misc/tools\";\nimport { Material } from \"@babylonjs/core/Materials/material\";\nimport { StandardMaterial } from \"@babylonjs/core/Materials/standardMaterial\";\nimport { HemisphericLight } from \"@babylonjs/core/Lights/hemisphericLight\";\nimport { DirectionalLight } from \"@babylonjs/core/Lights/directionalLight\";\nimport { PointLight } from \"@babylonjs/core/Lights/pointLight\";\nimport { SpotLight } from \"@babylonjs/core/Lights/spotLight\";\n\nimport { GLTFLoader } from \"./glTFLoader\";\n\ninterface IGLTFMaterialsCommonExtensionValues {\n ambient?: number[] | string;\n diffuse?: number[] | string;\n emission?: number[] | string;\n specular?: number[] | string;\n shininess?: number;\n transparency?: number;\n}\n\ninterface IGLTFMaterialsCommonExtension {\n technique: string;\n transparent?: number;\n doubleSided?: boolean;\n values: IGLTFMaterialsCommonExtensionValues;\n}\n\ninterface IGLTFRuntimeCommonExtension {\n lights: { [key: string]: IGLTFLightCommonExtension };\n}\n\ninterface IGLTFLightCommonExtension {\n name: string;\n type: string;\n\n ambient?: IGLTFAmbientLightCommonExtension;\n point?: IGLTFPointLightCommonExtension;\n directional?: IGLTFDirectionalLightCommonExtension;\n spot?: IGLTFSpotLightCommonExtension;\n}\n\ninterface IGLTFPointLightCommonExtension {\n color: number[];\n constantAttenuation: number;\n linearAttenuation: number;\n quadraticAttenuation: number;\n}\n\ninterface IGLTFAmbientLightCommonExtension {\n color: number[];\n}\n\ninterface IGLTFDirectionalLightCommonExtension {\n color: number[];\n}\n\ninterface IGLTFSpotLightCommonExtension {\n color: number[];\n constantAttenuation: number;\n fallOffAngle: number;\n fallOffExponent: number;\n linearAttenuation: number;\n quadraticAttenuation: number;\n}\n\n/** @hidden */\nexport class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {\n\n constructor() {\n super(\"KHR_materials_common\");\n }\n\n public loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean {\n if (!gltfRuntime.extensions) { return false; }\n\n var extension: IGLTFRuntimeCommonExtension = gltfRuntime.extensions[this.name];\n if (!extension) { return false; }\n\n // Create lights\n var lights = extension.lights;\n if (lights) {\n for (var thing in lights) {\n var light: IGLTFLightCommonExtension = lights[thing];\n\n switch (light.type) {\n case \"ambient\":\n var ambientLight = new HemisphericLight(light.name, new Vector3(0, 1, 0), gltfRuntime.scene);\n var ambient = light.ambient;\n if (ambient) {\n ambientLight.diffuse = Color3.FromArray(ambient.color || [1, 1, 1]);\n }\n break;\n case \"point\":\n var pointLight = new PointLight(light.name, new Vector3(10, 10, 10), gltfRuntime.scene);\n var point = light.point;\n if (point) {\n pointLight.diffuse = Color3.FromArray(point.color || [1, 1, 1]);\n }\n break;\n case \"directional\":\n var dirLight = new DirectionalLight(light.name, new Vector3(0, -1, 0), gltfRuntime.scene);\n var directional = light.directional;\n if (directional) {\n dirLight.diffuse = Color3.FromArray(directional.color || [1, 1, 1]);\n }\n break;\n case \"spot\":\n var spot = light.spot;\n if (spot) {\n var spotLight = new SpotLight(light.name, new Vector3(0, 10, 0), new Vector3(0, -1, 0),\n spot.fallOffAngle || Math.PI,\n spot.fallOffExponent || 0.0,\n gltfRuntime.scene);\n spotLight.diffuse = Color3.FromArray(spot.color || [1, 1, 1]);\n }\n break;\n default: Tools.Warn(\"GLTF Material Common extension: light type \\\"\" + light.type + \"\\” not supported\"); break;\n }\n }\n }\n\n return false;\n }\n\n public loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean {\n var material: IGLTFMaterial = gltfRuntime.materials[id];\n if (!material || !material.extensions) { return false; }\n\n var extension: IGLTFMaterialsCommonExtension = material.extensions[this.name];\n if (!extension) { return false; }\n\n var standardMaterial = new StandardMaterial(id, gltfRuntime.scene);\n standardMaterial.sideOrientation = Material.CounterClockWiseSideOrientation;\n\n if (extension.technique === \"CONSTANT\") {\n standardMaterial.disableLighting = true;\n }\n\n standardMaterial.backFaceCulling = extension.doubleSided === undefined ? false : !extension.doubleSided;\n standardMaterial.alpha = extension.values.transparency === undefined ? 1.0 : extension.values.transparency;\n standardMaterial.specularPower = extension.values.shininess === undefined ? 0.0 : extension.values.shininess;\n\n // Ambient\n if (typeof extension.values.ambient === \"string\") {\n this._loadTexture(gltfRuntime, extension.values.ambient, standardMaterial, \"ambientTexture\", onError);\n }\n else {\n standardMaterial.ambientColor = Color3.FromArray(extension.values.ambient || [0, 0, 0]);\n }\n\n // Diffuse\n if (typeof extension.values.diffuse === \"string\") {\n this._loadTexture(gltfRuntime, extension.values.diffuse, standardMaterial, \"diffuseTexture\", onError);\n }\n else {\n standardMaterial.diffuseColor = Color3.FromArray(extension.values.diffuse || [0, 0, 0]);\n }\n\n // Emission\n if (typeof extension.values.emission === \"string\") {\n this._loadTexture(gltfRuntime, extension.values.emission, standardMaterial, \"emissiveTexture\", onError);\n }\n else {\n standardMaterial.emissiveColor = Color3.FromArray(extension.values.emission || [0, 0, 0]);\n }\n\n // Specular\n if (typeof extension.values.specular === \"string\") {\n this._loadTexture(gltfRuntime, extension.values.specular, standardMaterial, \"specularTexture\", onError);\n }\n else {\n standardMaterial.specularColor = Color3.FromArray(extension.values.specular || [0, 0, 0]);\n }\n\n return true;\n }\n\n private _loadTexture(gltfRuntime: IGLTFRuntime, id: string, material: StandardMaterial, propertyPath: string, onError: (message: string) => void): void {\n // Create buffer from texture url\n GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, (buffer) => {\n // Create texture from buffer\n GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, (texture) => (<any>material)[propertyPath] = texture, onError);\n }, onError);\n }\n}\n\nGLTFLoader.RegisterExtension(new GLTFMaterialsCommonExtension());\n"]}
|
1
|
+
{"version":3,"file":"glTFMaterialsCommonExtension.js","sourceRoot":"","sources":["../../../../../../lts/loaders/generated/glTF/1.0/glTFMaterialsCommonExtension.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAI/E,OAAO,EAAE,OAAO,EAAE,6CAA+B;AACjD,OAAO,EAAE,MAAM,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AAC,SAAS,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SAC7F;QAED,WAAW;QACX,IAAI,OAAO,SAAS,CAAC,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE;YAC/C,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,SAAS,CAAC,MAAM,CAAC,QAAQ,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,OAAO,CAAC,CAAC;SAC3G;aAAM;YACH,gBAAgB,CAAC,aAAa,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;SAC7F;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;IAEO,mDAAY,GAApB,UAAqB,WAAyB,EAAE,EAAU,EAAE,QAA0B,EAAE,YAAoB,EAAE,OAAkC;QAC5I,iCAAiC;QACjC,cAAc,CAAC,sBAAsB,CACjC,WAAW,EACX,EAAE,EACF,UAAC,MAAM;YACH,6BAA6B;YAC7B,cAAc,CAAC,kBAAkB,CAAC,WAAW,EAAE,EAAE,EAAE,MAAM,EAAE,UAAC,OAAO,IAAK,OAAA,CAAO,QAAS,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,EAAzC,CAAyC,CAAC,CAAC;QACvH,CAAC,EACD,OAAO,CACV,CAAC;IACN,CAAC;IACL,mCAAC;AAAD,CAAC,AAxID,CAAkD,mBAAmB,GAwIpE;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,4BAA4B,EAAE,CAAC,CAAC","sourcesContent":["import { GLTFLoaderExtension, GLTFLoaderBase, GLTFLoader } from \"./glTFLoader\";\r\n\r\nimport type { IGLTFRuntime, IGLTFMaterial } from \"./glTFLoaderInterfaces\";\r\n\r\nimport { Vector3 } from \"core/Maths/math.vector\";\r\nimport { Color3 } from \"core/Maths/math.color\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { Material } from \"core/Materials/material\";\r\nimport { StandardMaterial } from \"core/Materials/standardMaterial\";\r\nimport { HemisphericLight } from \"core/Lights/hemisphericLight\";\r\nimport { DirectionalLight } from \"core/Lights/directionalLight\";\r\nimport { PointLight } from \"core/Lights/pointLight\";\r\nimport { SpotLight } from \"core/Lights/spotLight\";\r\n\r\ninterface IGLTFMaterialsCommonExtensionValues {\r\n ambient?: number[] | string;\r\n diffuse?: number[] | string;\r\n emission?: number[] | string;\r\n specular?: number[] | string;\r\n shininess?: number;\r\n transparency?: number;\r\n}\r\n\r\ninterface IGLTFMaterialsCommonExtension {\r\n technique: string;\r\n transparent?: number;\r\n doubleSided?: boolean;\r\n values: IGLTFMaterialsCommonExtensionValues;\r\n}\r\n\r\ninterface IGLTFRuntimeCommonExtension {\r\n lights: { [key: string]: IGLTFLightCommonExtension };\r\n}\r\n\r\ninterface IGLTFLightCommonExtension {\r\n name: string;\r\n type: string;\r\n\r\n ambient?: IGLTFAmbientLightCommonExtension;\r\n point?: IGLTFPointLightCommonExtension;\r\n directional?: IGLTFDirectionalLightCommonExtension;\r\n spot?: IGLTFSpotLightCommonExtension;\r\n}\r\n\r\ninterface IGLTFPointLightCommonExtension {\r\n color: number[];\r\n constantAttenuation: number;\r\n linearAttenuation: number;\r\n quadraticAttenuation: number;\r\n}\r\n\r\ninterface IGLTFAmbientLightCommonExtension {\r\n color: number[];\r\n}\r\n\r\ninterface IGLTFDirectionalLightCommonExtension {\r\n color: number[];\r\n}\r\n\r\ninterface IGLTFSpotLightCommonExtension {\r\n color: number[];\r\n constantAttenuation: number;\r\n fallOffAngle: number;\r\n fallOffExponent: number;\r\n linearAttenuation: number;\r\n quadraticAttenuation: number;\r\n}\r\n\r\n/** @hidden */\r\nexport class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {\r\n constructor() {\r\n super(\"KHR_materials_common\");\r\n }\r\n\r\n public loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime): boolean {\r\n if (!gltfRuntime.extensions) {\r\n return false;\r\n }\r\n\r\n const extension: IGLTFRuntimeCommonExtension = gltfRuntime.extensions[this.name];\r\n if (!extension) {\r\n return false;\r\n }\r\n\r\n // Create lights\r\n const lights = extension.lights;\r\n if (lights) {\r\n for (const thing in lights) {\r\n const light: IGLTFLightCommonExtension = lights[thing];\r\n\r\n switch (light.type) {\r\n case \"ambient\": {\r\n const ambientLight = new HemisphericLight(light.name, new Vector3(0, 1, 0), gltfRuntime.scene);\r\n const ambient = light.ambient;\r\n if (ambient) {\r\n ambientLight.diffuse = Color3.FromArray(ambient.color || [1, 1, 1]);\r\n }\r\n break;\r\n }\r\n case \"point\": {\r\n const pointLight = new PointLight(light.name, new Vector3(10, 10, 10), gltfRuntime.scene);\r\n const point = light.point;\r\n if (point) {\r\n pointLight.diffuse = Color3.FromArray(point.color || [1, 1, 1]);\r\n }\r\n break;\r\n }\r\n case \"directional\": {\r\n const dirLight = new DirectionalLight(light.name, new Vector3(0, -1, 0), gltfRuntime.scene);\r\n const directional = light.directional;\r\n if (directional) {\r\n dirLight.diffuse = Color3.FromArray(directional.color || [1, 1, 1]);\r\n }\r\n break;\r\n }\r\n case \"spot\": {\r\n const spot = light.spot;\r\n if (spot) {\r\n const spotLight = new SpotLight(\r\n light.name,\r\n new Vector3(0, 10, 0),\r\n new Vector3(0, -1, 0),\r\n spot.fallOffAngle || Math.PI,\r\n spot.fallOffExponent || 0.0,\r\n gltfRuntime.scene\r\n );\r\n spotLight.diffuse = Color3.FromArray(spot.color || [1, 1, 1]);\r\n }\r\n break;\r\n }\r\n default:\r\n Tools.Warn('GLTF Material Common extension: light type \"' + light.type + \"” not supported\");\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n public loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean {\r\n const material: IGLTFMaterial = gltfRuntime.materials[id];\r\n if (!material || !material.extensions) {\r\n return false;\r\n }\r\n\r\n const extension: IGLTFMaterialsCommonExtension = material.extensions[this.name];\r\n if (!extension) {\r\n return false;\r\n }\r\n\r\n const standardMaterial = new StandardMaterial(id, gltfRuntime.scene);\r\n standardMaterial.sideOrientation = Material.CounterClockWiseSideOrientation;\r\n\r\n if (extension.technique === \"CONSTANT\") {\r\n standardMaterial.disableLighting = true;\r\n }\r\n\r\n standardMaterial.backFaceCulling = extension.doubleSided === undefined ? false : !extension.doubleSided;\r\n standardMaterial.alpha = extension.values.transparency === undefined ? 1.0 : extension.values.transparency;\r\n standardMaterial.specularPower = extension.values.shininess === undefined ? 0.0 : extension.values.shininess;\r\n\r\n // Ambient\r\n if (typeof extension.values.ambient === \"string\") {\r\n this._loadTexture(gltfRuntime, extension.values.ambient, standardMaterial, \"ambientTexture\", onError);\r\n } else {\r\n standardMaterial.ambientColor = Color3.FromArray(extension.values.ambient || [0, 0, 0]);\r\n }\r\n\r\n // Diffuse\r\n if (typeof extension.values.diffuse === \"string\") {\r\n this._loadTexture(gltfRuntime, extension.values.diffuse, standardMaterial, \"diffuseTexture\", onError);\r\n } else {\r\n standardMaterial.diffuseColor = Color3.FromArray(extension.values.diffuse || [0, 0, 0]);\r\n }\r\n\r\n // Emission\r\n if (typeof extension.values.emission === \"string\") {\r\n this._loadTexture(gltfRuntime, extension.values.emission, standardMaterial, \"emissiveTexture\", onError);\r\n } else {\r\n standardMaterial.emissiveColor = Color3.FromArray(extension.values.emission || [0, 0, 0]);\r\n }\r\n\r\n // Specular\r\n if (typeof extension.values.specular === \"string\") {\r\n this._loadTexture(gltfRuntime, extension.values.specular, standardMaterial, \"specularTexture\", onError);\r\n } else {\r\n standardMaterial.specularColor = Color3.FromArray(extension.values.specular || [0, 0, 0]);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n private _loadTexture(gltfRuntime: IGLTFRuntime, id: string, material: StandardMaterial, propertyPath: string, onError: (message: string) => void): void {\r\n // Create buffer from texture url\r\n GLTFLoaderBase.LoadTextureBufferAsync(\r\n gltfRuntime,\r\n id,\r\n (buffer) => {\r\n // Create texture from buffer\r\n GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, (texture) => ((<any>material)[propertyPath] = texture));\r\n },\r\n onError\r\n );\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(new GLTFMaterialsCommonExtension());\r\n"]}
|
package/glTF/1.0/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
export * from "./glTFBinaryExtension";
|
2
|
-
export * from "./glTFLoader";
|
3
|
-
export * from "./glTFLoaderInterfaces";
|
4
|
-
export * from "./glTFLoaderUtils";
|
5
|
-
export * from "./glTFMaterialsCommonExtension";
|
1
|
+
export * from "./glTFBinaryExtension";
|
2
|
+
export * from "./glTFLoader";
|
3
|
+
export * from "./glTFLoaderInterfaces";
|
4
|
+
export * from "./glTFLoaderUtils";
|
5
|
+
export * from "./glTFMaterialsCommonExtension";
|
package/glTF/1.0/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
export * from "./glTFBinaryExtension
|
2
|
-
export * from "./glTFLoader
|
3
|
-
export * from "./glTFLoaderInterfaces
|
4
|
-
export * from "./glTFLoaderUtils
|
5
|
-
export * from "./glTFMaterialsCommonExtension
|
1
|
+
export * from "./glTFBinaryExtension";
|
2
|
+
export * from "./glTFLoader";
|
3
|
+
export * from "./glTFLoaderInterfaces";
|
4
|
+
export * from "./glTFLoaderUtils";
|
5
|
+
export * from "./glTFMaterialsCommonExtension";
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/glTF/1.0/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../lts/loaders/generated/glTF/1.0/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,cAAc,CAAC;AAC7B,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gCAAgC,CAAC","sourcesContent":["export * from \"./glTFBinaryExtension\";\r\nexport * from \"./glTFLoader\";\r\nexport * from \"./glTFLoaderInterfaces\";\r\nexport * from \"./glTFLoaderUtils\";\r\nexport * from \"./glTFMaterialsCommonExtension\";\r\n"]}
|
@@ -1,36 +1,43 @@
|
|
1
|
-
import { Nullable } from "@babylonjs/core/types";
|
2
|
-
import { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture";
|
3
|
-
import { IScene } from "../glTFLoaderInterfaces";
|
4
|
-
import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
|
5
|
-
import { GLTFLoader } from "../glTFLoader";
|
6
|
-
declare module "babylonjs-gltf2interface" {
|
7
|
-
/** @hidden */
|
8
|
-
interface IEXTLightsImageBased_LightImageBased {
|
9
|
-
_babylonTexture?: BaseTexture;
|
10
|
-
_loaded?: Promise<void>;
|
11
|
-
}
|
12
|
-
}
|
13
|
-
/**
|
14
|
-
* [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
|
15
|
-
*/
|
16
|
-
export declare class EXT_lights_image_based implements IGLTFLoaderExtension {
|
17
|
-
/**
|
18
|
-
* The name of this extension.
|
19
|
-
*/
|
20
|
-
readonly name = "EXT_lights_image_based";
|
21
|
-
/**
|
22
|
-
* Defines whether this extension is enabled.
|
23
|
-
*/
|
24
|
-
enabled: boolean;
|
25
|
-
private _loader;
|
26
|
-
private _lights?;
|
27
|
-
/**
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
1
|
+
import type { Nullable } from "@babylonjs/core/types.js";
|
2
|
+
import type { BaseTexture } from "@babylonjs/core/Materials/Textures/baseTexture.js";
|
3
|
+
import type { IScene } from "../glTFLoaderInterfaces";
|
4
|
+
import type { IGLTFLoaderExtension } from "../glTFLoaderExtension";
|
5
|
+
import { GLTFLoader } from "../glTFLoader";
|
6
|
+
declare module "babylonjs-gltf2interface" {
|
7
|
+
/** @hidden */
|
8
|
+
interface IEXTLightsImageBased_LightImageBased {
|
9
|
+
_babylonTexture?: BaseTexture;
|
10
|
+
_loaded?: Promise<void>;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
/**
|
14
|
+
* [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
|
15
|
+
*/
|
16
|
+
export declare class EXT_lights_image_based implements IGLTFLoaderExtension {
|
17
|
+
/**
|
18
|
+
* The name of this extension.
|
19
|
+
*/
|
20
|
+
readonly name = "EXT_lights_image_based";
|
21
|
+
/**
|
22
|
+
* Defines whether this extension is enabled.
|
23
|
+
*/
|
24
|
+
enabled: boolean;
|
25
|
+
private _loader;
|
26
|
+
private _lights?;
|
27
|
+
/**
|
28
|
+
* @param loader
|
29
|
+
* @hidden
|
30
|
+
*/
|
31
|
+
constructor(loader: GLTFLoader);
|
32
|
+
/** @hidden */
|
33
|
+
dispose(): void;
|
34
|
+
/** @hidden */
|
35
|
+
onLoading(): void;
|
36
|
+
/**
|
37
|
+
* @param context
|
38
|
+
* @param scene
|
39
|
+
* @hidden
|
40
|
+
*/
|
41
|
+
loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
|
42
|
+
private _loadLightAsync;
|
43
|
+
}
|