@babylonjs/loaders 5.0.0-alpha.7 → 5.0.0-beta.2
Sign up to get free protection for your applications and to get access to all the features.
- package/OBJ/index.d.ts +2 -0
- package/OBJ/index.js +4 -2
- package/OBJ/index.js.map +1 -1
- package/OBJ/mtlFileLoader.d.ts +4 -2
- package/OBJ/mtlFileLoader.js +7 -6
- package/OBJ/mtlFileLoader.js.map +1 -1
- package/OBJ/objFileLoader.d.ts +12 -84
- package/OBJ/objFileLoader.js +50 -667
- package/OBJ/objFileLoader.js.map +1 -1
- package/OBJ/objLoadingOptions.d.ts +43 -0
- package/OBJ/objLoadingOptions.js +2 -0
- package/OBJ/objLoadingOptions.js.map +1 -0
- package/OBJ/solidParser.d.ts +153 -0
- package/OBJ/solidParser.js +700 -0
- package/OBJ/solidParser.js.map +1 -0
- package/STL/index.js +1 -1
- package/STL/stlFileLoader.d.ts +6 -0
- package/STL/stlFileLoader.js +38 -11
- package/STL/stlFileLoader.js.map +1 -1
- package/glTF/1.0/glTFBinaryExtension.js +4 -4
- package/glTF/1.0/glTFLoader.d.ts +4 -4
- package/glTF/1.0/glTFLoader.js +60 -55
- package/glTF/1.0/glTFLoader.js.map +1 -1
- package/glTF/1.0/glTFLoaderInterfaces.d.ts +3 -1
- package/glTF/1.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/1.0/glTFLoaderUtils.js +6 -6
- package/glTF/1.0/glTFMaterialsCommonExtension.js +12 -12
- package/glTF/1.0/index.js +5 -5
- package/glTF/2.0/Extensions/EXT_lights_image_based.js +8 -5
- package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +3 -3
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +1 -5
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js +5 -21
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_texture_webp.js +2 -2
- package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js +1 -1
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +8 -4
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +9 -8
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +2 -2
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +30 -0
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +46 -0
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +1 -2
- package/glTF/2.0/Extensions/KHR_materials_ior.js +3 -4
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +3 -4
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +0 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +3 -4
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +1 -2
- package/glTF/2.0/Extensions/KHR_materials_specular.js +12 -6
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_translucency.js +6 -6
- package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +93 -84
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +3 -3
- package/glTF/2.0/Extensions/KHR_materials_variants.js +70 -5
- package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +31 -0
- package/glTF/2.0/Extensions/KHR_materials_volume.js +79 -0
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -0
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js +1 -1
- package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +1 -2
- package/glTF/2.0/Extensions/KHR_texture_basisu.js +3 -4
- package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.js +2 -2
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +2 -2
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +6 -3
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js +6 -7
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_lod.d.ts +2 -1
- package/glTF/2.0/Extensions/MSFT_lod.js +48 -8
- package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +2 -2
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +2 -2
- package/glTF/2.0/Extensions/index.d.ts +2 -0
- package/glTF/2.0/Extensions/index.js +26 -24
- package/glTF/2.0/Extensions/index.js.map +1 -1
- package/glTF/2.0/glTFLoader.d.ts +6 -11
- package/glTF/2.0/glTFLoader.js +129 -95
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/glTF/2.0/glTFLoaderInterfaces.d.ts +4 -2
- package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/2.0/index.d.ts +1 -1
- package/glTF/2.0/index.js +4 -4
- package/glTF/2.0/index.js.map +1 -1
- package/glTF/glTFFileLoader.d.ts +15 -9
- package/glTF/glTFFileLoader.js +62 -76
- package/glTF/glTFFileLoader.js.map +1 -1
- package/glTF/glTFValidation.js +1 -1
- package/glTF/glTFValidation.js.map +1 -1
- package/glTF/index.d.ts +2 -2
- package/glTF/index.js +4 -4
- package/glTF/index.js.map +1 -1
- package/index.d.ts +3 -3
- package/index.js +3 -3
- package/index.js.map +1 -1
- package/legacy/legacy-glTF.js +4 -4
- package/legacy/legacy-glTF1.d.ts +1 -1
- package/legacy/legacy-glTF1.js +1 -1
- package/legacy/legacy-glTF1.js.map +1 -1
- package/legacy/legacy-glTF1FileLoader.js +2 -2
- package/legacy/legacy-glTF2.d.ts +1 -1
- package/legacy/legacy-glTF2.js +3 -3
- package/legacy/legacy-glTF2.js.map +1 -1
- package/legacy/legacy-glTF2FileLoader.js +2 -2
- package/legacy/legacy-glTFFileLoader.js +3 -3
- package/legacy/legacy-objFileLoader.d.ts +1 -1
- package/legacy/legacy-objFileLoader.js +2 -2
- package/legacy/legacy-objFileLoader.js.map +1 -1
- package/legacy/legacy-stlFileLoader.d.ts +1 -1
- package/legacy/legacy-stlFileLoader.js +2 -2
- package/legacy/legacy-stlFileLoader.js.map +1 -1
- package/legacy/legacy.js +6 -6
- package/package.json +16 -4
@@ -1,9 +1,10 @@
|
|
1
1
|
import { __assign } from "tslib";
|
2
|
-
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial";
|
3
|
-
import { GLTFLoader } from "../glTFLoader";
|
4
|
-
import {
|
5
|
-
import {
|
6
|
-
import {
|
2
|
+
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
|
3
|
+
import { GLTFLoader } from "../glTFLoader.js";
|
4
|
+
import { RenderTargetTexture } from "@babylonjs/core/Materials/Textures/renderTargetTexture.js";
|
5
|
+
import { Observable } from "@babylonjs/core/Misc/observable.js";
|
6
|
+
import { Constants } from "@babylonjs/core/Engines/constants.js";
|
7
|
+
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
7
8
|
/**
|
8
9
|
* A class to handle setting up the rendering of opaque objects to be shown through transmissive objects.
|
9
10
|
*/
|
@@ -18,6 +19,7 @@ var TransmissionHelper = /** @class */ (function () {
|
|
18
19
|
this._opaqueRenderTarget = null;
|
19
20
|
this._opaqueMeshesCache = [];
|
20
21
|
this._transparentMeshesCache = [];
|
22
|
+
this._materialObservers = {};
|
21
23
|
this._options = __assign(__assign({}, TransmissionHelper._getDefaultOptions()), options);
|
22
24
|
this._scene = scene;
|
23
25
|
this._scene._transmissionHelper = this;
|
@@ -33,7 +35,12 @@ var TransmissionHelper = /** @class */ (function () {
|
|
33
35
|
*/
|
34
36
|
TransmissionHelper._getDefaultOptions = function () {
|
35
37
|
return {
|
36
|
-
renderSize: 1024
|
38
|
+
renderSize: 1024,
|
39
|
+
samples: 4,
|
40
|
+
lodGenerationScale: 1,
|
41
|
+
lodGenerationOffset: -4,
|
42
|
+
renderTargetTextureType: Constants.TEXTURETYPE_HALF_FLOAT,
|
43
|
+
generateMipmaps: true,
|
37
44
|
};
|
38
45
|
};
|
39
46
|
/**
|
@@ -51,9 +58,14 @@ var TransmissionHelper = /** @class */ (function () {
|
|
51
58
|
var oldOptions = this._options;
|
52
59
|
this._options = newOptions;
|
53
60
|
// If size changes, recreate everything
|
54
|
-
if (newOptions.renderSize !== oldOptions.renderSize) {
|
61
|
+
if (newOptions.renderSize !== oldOptions.renderSize || newOptions.renderTargetTextureType !== oldOptions.renderTargetTextureType || newOptions.generateMipmaps !== oldOptions.generateMipmaps || !this._opaqueRenderTarget) {
|
55
62
|
this._setupRenderTargets();
|
56
63
|
}
|
64
|
+
else {
|
65
|
+
this._opaqueRenderTarget.samples = newOptions.samples;
|
66
|
+
this._opaqueRenderTarget.lodGenerationScale = newOptions.lodGenerationScale;
|
67
|
+
this._opaqueRenderTarget.lodGenerationOffset = newOptions.lodGenerationOffset;
|
68
|
+
}
|
57
69
|
};
|
58
70
|
TransmissionHelper.prototype.getOpaqueTarget = function () {
|
59
71
|
return this._opaqueRenderTarget;
|
@@ -68,27 +80,30 @@ var TransmissionHelper = /** @class */ (function () {
|
|
68
80
|
return false;
|
69
81
|
};
|
70
82
|
TransmissionHelper.prototype._addMesh = function (mesh) {
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
83
|
+
var _this = this;
|
84
|
+
this._materialObservers[mesh.uniqueId] = mesh.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this));
|
85
|
+
// we need to defer the processing because _addMesh may be called as part as an instance mesh creation, in which case some
|
86
|
+
// internal properties are not setup yet, like _sourceMesh (needed when doing mesh.material below)
|
87
|
+
Tools.SetImmediate(function () {
|
88
|
+
if (_this.shouldRenderAsTransmission(mesh.material)) {
|
89
|
+
mesh.material.refractionTexture = _this._opaqueRenderTarget;
|
90
|
+
_this._transparentMeshesCache.push(mesh);
|
75
91
|
}
|
76
92
|
else {
|
77
|
-
|
93
|
+
_this._opaqueMeshesCache.push(mesh);
|
78
94
|
}
|
79
|
-
}
|
95
|
+
});
|
80
96
|
};
|
81
97
|
TransmissionHelper.prototype._removeMesh = function (mesh) {
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
}
|
98
|
+
mesh.onMaterialChangedObservable.remove(this._materialObservers[mesh.uniqueId]);
|
99
|
+
delete this._materialObservers[mesh.uniqueId];
|
100
|
+
var idx = this._transparentMeshesCache.indexOf(mesh);
|
101
|
+
if (idx !== -1) {
|
102
|
+
this._transparentMeshesCache.splice(idx, 1);
|
103
|
+
}
|
104
|
+
idx = this._opaqueMeshesCache.indexOf(mesh);
|
105
|
+
if (idx !== -1) {
|
106
|
+
this._opaqueMeshesCache.splice(idx, 1);
|
92
107
|
}
|
93
108
|
};
|
94
109
|
TransmissionHelper.prototype._parseScene = function () {
|
@@ -99,33 +114,31 @@ var TransmissionHelper = /** @class */ (function () {
|
|
99
114
|
this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this));
|
100
115
|
};
|
101
116
|
// When one of the meshes in the scene has its material changed, make sure that it's in the correct cache list.
|
102
|
-
TransmissionHelper.prototype.
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
if (
|
109
|
-
|
110
|
-
mesh.material.subSurface.refractionTexture = this._opaqueRenderTarget;
|
111
|
-
}
|
112
|
-
if (opaqueIdx !== -1) {
|
113
|
-
this._opaqueMeshesCache.splice(opaqueIdx, 1);
|
114
|
-
this._transparentMeshesCache.push(mesh);
|
115
|
-
}
|
116
|
-
else if (transparentIdx === -1) {
|
117
|
-
this._transparentMeshesCache.push(mesh);
|
118
|
-
}
|
119
|
-
// If the material is opaque, make sure that it's added to the opaque list and removed from the transparent list
|
117
|
+
TransmissionHelper.prototype._onMeshMaterialChanged = function (mesh) {
|
118
|
+
var transparentIdx = this._transparentMeshesCache.indexOf(mesh);
|
119
|
+
var opaqueIdx = this._opaqueMeshesCache.indexOf(mesh);
|
120
|
+
// If the material is transparent, make sure that it's added to the transparent list and removed from the opaque list
|
121
|
+
var useTransmission = this.shouldRenderAsTransmission(mesh.material);
|
122
|
+
if (useTransmission) {
|
123
|
+
if (mesh.material instanceof PBRMaterial) {
|
124
|
+
mesh.material.subSurface.refractionTexture = this._opaqueRenderTarget;
|
120
125
|
}
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
126
|
+
if (opaqueIdx !== -1) {
|
127
|
+
this._opaqueMeshesCache.splice(opaqueIdx, 1);
|
128
|
+
this._transparentMeshesCache.push(mesh);
|
129
|
+
}
|
130
|
+
else if (transparentIdx === -1) {
|
131
|
+
this._transparentMeshesCache.push(mesh);
|
132
|
+
}
|
133
|
+
// If the material is opaque, make sure that it's added to the opaque list and removed from the transparent list
|
134
|
+
}
|
135
|
+
else {
|
136
|
+
if (transparentIdx !== -1) {
|
137
|
+
this._transparentMeshesCache.splice(transparentIdx, 1);
|
138
|
+
this._opaqueMeshesCache.push(mesh);
|
139
|
+
}
|
140
|
+
else if (opaqueIdx === -1) {
|
141
|
+
this._opaqueMeshesCache.push(mesh);
|
129
142
|
}
|
130
143
|
}
|
131
144
|
};
|
@@ -134,45 +147,39 @@ var TransmissionHelper = /** @class */ (function () {
|
|
134
147
|
*/
|
135
148
|
TransmissionHelper.prototype._setupRenderTargets = function () {
|
136
149
|
var _this = this;
|
137
|
-
var
|
138
|
-
// Remove any layers rendering to the opaque scene.
|
139
|
-
if (this._scene.layers && this._opaqueRenderTarget) {
|
140
|
-
for (var _i = 0, _a = this._scene.layers; _i < _a.length; _i++) {
|
141
|
-
var layer = _a[_i];
|
142
|
-
var idx = layer.renderTargetTextures.indexOf(this._opaqueRenderTarget);
|
143
|
-
if (idx >= 0) {
|
144
|
-
layer.renderTargetTextures.splice(idx, 1);
|
145
|
-
}
|
146
|
-
}
|
147
|
-
}
|
148
|
-
// Remove opaque render target
|
150
|
+
var _a, _b;
|
149
151
|
if (this._opaqueRenderTarget) {
|
150
|
-
opaqueRTIndex = this._scene.customRenderTargets.indexOf(this._opaqueRenderTarget);
|
151
152
|
this._opaqueRenderTarget.dispose();
|
152
153
|
}
|
153
|
-
this._opaqueRenderTarget = new RenderTargetTexture("opaqueSceneTexture", this._options.renderSize, this._scene,
|
154
|
+
this._opaqueRenderTarget = new RenderTargetTexture("opaqueSceneTexture", this._options.renderSize, this._scene, this._options.generateMipmaps, undefined, this._options.renderTargetTextureType);
|
155
|
+
this._opaqueRenderTarget.ignoreCameraViewport = true;
|
154
156
|
this._opaqueRenderTarget.renderList = this._opaqueMeshesCache;
|
155
|
-
|
156
|
-
this._opaqueRenderTarget.gammaSpace =
|
157
|
-
this._opaqueRenderTarget.lodGenerationScale =
|
158
|
-
this._opaqueRenderTarget.lodGenerationOffset =
|
159
|
-
this._opaqueRenderTarget.samples =
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
if (this._scene.layers && this._opaqueRenderTarget) {
|
169
|
-
for (var _b = 0, _c = this._scene.layers; _b < _c.length; _b++) {
|
170
|
-
var layer = _c[_b];
|
171
|
-
layer.renderTargetTextures.push(this._opaqueRenderTarget);
|
157
|
+
this._opaqueRenderTarget.clearColor = (_b = (_a = this._options.clearColor) === null || _a === void 0 ? void 0 : _a.clone()) !== null && _b !== void 0 ? _b : this._scene.clearColor.clone();
|
158
|
+
this._opaqueRenderTarget.gammaSpace = false;
|
159
|
+
this._opaqueRenderTarget.lodGenerationScale = this._options.lodGenerationScale;
|
160
|
+
this._opaqueRenderTarget.lodGenerationOffset = this._options.lodGenerationOffset;
|
161
|
+
this._opaqueRenderTarget.samples = this._options.samples;
|
162
|
+
var sceneImageProcessingapplyByPostProcess;
|
163
|
+
var saveSceneEnvIntensity;
|
164
|
+
this._opaqueRenderTarget.onBeforeBindObservable.add(function (opaqueRenderTarget) {
|
165
|
+
saveSceneEnvIntensity = _this._scene.environmentIntensity;
|
166
|
+
_this._scene.environmentIntensity = 1.0;
|
167
|
+
sceneImageProcessingapplyByPostProcess = _this._scene.imageProcessingConfiguration.applyByPostProcess;
|
168
|
+
if (!_this._options.clearColor) {
|
169
|
+
_this._scene.clearColor.toLinearSpaceToRef(opaqueRenderTarget.clearColor);
|
172
170
|
}
|
173
|
-
|
171
|
+
else {
|
172
|
+
opaqueRenderTarget.clearColor.copyFrom(_this._options.clearColor);
|
173
|
+
}
|
174
|
+
// we do not use the applyByPostProcess setter to avoid flagging all the materials as "image processing dirty"!
|
175
|
+
_this._scene.imageProcessingConfiguration._applyByPostProcess = true;
|
176
|
+
});
|
177
|
+
this._opaqueRenderTarget.onAfterUnbindObservable.add(function () {
|
178
|
+
_this._scene.environmentIntensity = saveSceneEnvIntensity;
|
179
|
+
_this._scene.imageProcessingConfiguration._applyByPostProcess = sceneImageProcessingapplyByPostProcess;
|
180
|
+
});
|
174
181
|
this._transparentMeshesCache.forEach(function (mesh) {
|
175
|
-
if (_this.shouldRenderAsTransmission(mesh.material)
|
182
|
+
if (_this.shouldRenderAsTransmission(mesh.material)) {
|
176
183
|
mesh.material.refractionTexture = _this._opaqueRenderTarget;
|
177
184
|
}
|
178
185
|
});
|
@@ -250,12 +257,14 @@ var KHR_materials_transmission = /** @class */ (function () {
|
|
250
257
|
pbrMaterial.subSurface.isRefractionEnabled = false;
|
251
258
|
return Promise.resolve();
|
252
259
|
}
|
260
|
+
pbrMaterial.subSurface.minimumThickness = 0.0;
|
261
|
+
pbrMaterial.subSurface.maximumThickness = 0.0;
|
253
262
|
if (extension.transmissionTexture) {
|
254
263
|
extension.transmissionTexture.nonColorData = true;
|
255
264
|
return this._loader.loadTextureInfoAsync(context + "/transmissionTexture", extension.transmissionTexture, undefined)
|
256
265
|
.then(function (texture) {
|
257
|
-
pbrMaterial.subSurface.
|
258
|
-
pbrMaterial.subSurface.
|
266
|
+
pbrMaterial.subSurface.refractionIntensityTexture = texture;
|
267
|
+
pbrMaterial.subSurface.useGltfStyleTextures = true;
|
259
268
|
});
|
260
269
|
}
|
261
270
|
else {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KHR_materials_transmission.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAKxE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAI3C,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAEnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAgB7D;;GAEG;AACH;IA4BI;;;;OAIG;IACH,4BAAY,OAA4C,EAAE,KAAY;QAAtE,iBAeC;QA9BO,wBAAmB,GAAkC,IAAI,CAAC;QAC1D,uBAAkB,GAAW,EAAE,CAAC;QAChC,4BAAuB,GAAW,EAAE,CAAC;QAczC,IAAI,CAAC,QAAQ,yBACN,kBAAkB,CAAC,kBAAkB,EAAE,GACvC,OAAO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UAAU,CAAC,mBAAmB,GAAG,KAAK,CAAC;YACnD,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC5B;QAED,IAAI,SAAS,CAAC,mBAAmB,EAAE;YAC9B,SAAS,CAAC,mBAAoC,CAAC,YAAY,GAAG,IAAI,CAAC;YACpE,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAI,OAAO,yBAAsB,EAAE,SAAS,CAAC,mBAAmB,EAAE,SAAS,CAAC;iBAC/G,IAAI,CAAC,UAAC,OAAoB;gBACvB,WAAW,CAAC,UAAU,CAAC,gBAAgB,GAAG,OAAO,CAAC;gBAClD,WAAW,CAAC,UAAU,CAAC,+BAA+B,GAAG,IAAI,CAAC;YAClE,CAAC,CAAC,CAAC;SACV;aAAM;YACH,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC5B;IACL,CAAC;IACL,iCAAC;AAAD,CAAC,AAjFD,IAiFC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,0BAA0B,CAAC,MAAM,CAAC,EAAtC,CAAsC,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { PBRMaterial } from \"@babylonjs/core/Materials/PBR/pbrMaterial\";\nimport { Material } from \"@babylonjs/core/Materials/material\";\nimport { BaseTexture } from \"@babylonjs/core/Materials/Textures/baseTexture\";\nimport { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { GLTFLoader } from \"../glTFLoader\";\nimport { IKHRMaterialsTransmission } from 'babylonjs-gltf2interface';\nimport { Scene } from \"@babylonjs/core/scene\";\nimport { AbstractMesh } from \"@babylonjs/core/Meshes/abstractMesh\";\nimport { Mesh } from \"@babylonjs/core/Meshes/mesh\";\nimport { Texture } from \"@babylonjs/core/Materials/Textures/texture\";\nimport { RenderTargetTexture } from \"@babylonjs/core/Materials/Textures/renderTargetTexture\";\nimport { Observable } from \"@babylonjs/core/Misc/observable\";\n\ninterface ITransmissionHelperHolder {\n /**\n * @hidden\n */\n _transmissionHelper: TransmissionHelper | undefined;\n}\n\ninterface ITransmissionHelperOptions {\n /**\n * The size of the render buffers\n */\n renderSize: number;\n}\n\n/**\n * A class to handle setting up the rendering of opaque objects to be shown through transmissive objects.\n */\nclass TransmissionHelper {\n\n /**\n * Creates the default options for the helper.\n */\n private static _getDefaultOptions(): ITransmissionHelperOptions {\n return {\n renderSize: 1024\n };\n }\n\n /**\n * Stores the creation options.\n */\n private readonly _scene: Scene & ITransmissionHelperHolder;\n\n private _options: ITransmissionHelperOptions;\n\n private _opaqueRenderTarget: Nullable<RenderTargetTexture> = null;\n private _opaqueMeshesCache: Mesh[] = [];\n private _transparentMeshesCache: Mesh[] = [];\n\n /**\n * This observable will be notified with any error during the creation of the environment,\n * mainly texture creation errors.\n */\n public onErrorObservable: Observable<{ message?: string, exception?: any }>;\n\n /**\n * constructor\n * @param options Defines the options we want to customize the helper\n * @param scene The scene to add the material to\n */\n constructor(options: Partial<ITransmissionHelperOptions>, scene: Scene) {\n this._options = {\n ...TransmissionHelper._getDefaultOptions(),\n ...options\n };\n this._scene = scene as any;\n this._scene._transmissionHelper = this;\n\n this.onErrorObservable = new Observable();\n this._scene.onDisposeObservable.addOnce((scene) => {\n this.dispose();\n });\n\n this._parseScene();\n this._setupRenderTargets();\n }\n\n /**\n * Updates the background according to the new options\n * @param options\n */\n public updateOptions(options: Partial<ITransmissionHelperOptions>) {\n // First check if any options are actually being changed. If not, exit.\n const newValues = Object.keys(options).filter((key: string) => (this._options as any)[key] !== (options as any)[key]);\n if (!newValues.length) {\n return;\n }\n\n const newOptions = {\n ...this._options,\n ...options\n };\n\n const oldOptions = this._options;\n this._options = newOptions;\n\n // If size changes, recreate everything\n if (newOptions.renderSize !== oldOptions.renderSize) {\n this._setupRenderTargets();\n }\n }\n\n public getOpaqueTarget(): Nullable<Texture> {\n return this._opaqueRenderTarget;\n }\n\n private shouldRenderAsTransmission(material: Nullable<Material>): boolean {\n if (!material) {\n return false;\n }\n if (material instanceof PBRMaterial && (material.subSurface.isRefractionEnabled)) {\n return true;\n }\n return false;\n }\n\n private _addMesh(mesh: AbstractMesh): void {\n if (mesh instanceof Mesh) {\n mesh.onMaterialChangedObservable.add(this.onMeshMaterialChanged.bind(this));\n if (this.shouldRenderAsTransmission(mesh.material)) {\n this._transparentMeshesCache.push(mesh);\n } else {\n this._opaqueMeshesCache.push(mesh);\n }\n }\n }\n\n private _removeMesh(mesh: AbstractMesh): void {\n if (mesh instanceof Mesh) {\n mesh.onMaterialChangedObservable.remove(this.onMeshMaterialChanged.bind(this));\n let idx = this._transparentMeshesCache.indexOf(mesh);\n if (idx !== -1) {\n this._transparentMeshesCache.splice(idx, 1);\n }\n idx = this._opaqueMeshesCache.indexOf(mesh);\n if (idx !== -1) {\n this._opaqueMeshesCache.splice(idx, 1);\n }\n }\n }\n\n private _parseScene(): void {\n this._scene.meshes.forEach(this._addMesh.bind(this));\n // Listen for when a mesh is added to the scene and add it to our cache lists.\n this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this));\n // Listen for when a mesh is removed from to the scene and remove it from our cache lists.\n this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this));\n }\n\n // When one of the meshes in the scene has its material changed, make sure that it's in the correct cache list.\n private onMeshMaterialChanged(mesh: AbstractMesh) {\n if (mesh instanceof Mesh) {\n const transparentIdx = this._transparentMeshesCache.indexOf(mesh);\n const opaqueIdx = this._opaqueMeshesCache.indexOf(mesh);\n\n // If the material is transparent, make sure that it's added to the transparent list and removed from the opaque list\n const useTransmission = this.shouldRenderAsTransmission(mesh.material);\n if (useTransmission) {\n if (mesh.material instanceof PBRMaterial) {\n mesh.material.subSurface.refractionTexture = this._opaqueRenderTarget;\n }\n if (opaqueIdx !== -1) {\n this._opaqueMeshesCache.splice(opaqueIdx, 1);\n this._transparentMeshesCache.push(mesh);\n } else if (transparentIdx === -1) {\n this._transparentMeshesCache.push(mesh);\n }\n // If the material is opaque, make sure that it's added to the opaque list and removed from the transparent list\n } else {\n if (transparentIdx !== -1) {\n this._transparentMeshesCache.splice(transparentIdx, 1);\n this._opaqueMeshesCache.push(mesh);\n } else if (opaqueIdx === -1) {\n this._opaqueMeshesCache.push(mesh);\n }\n }\n }\n }\n\n /**\n * Setup the render targets according to the specified options.\n */\n private _setupRenderTargets(): void {\n\n let opaqueRTIndex = -1;\n\n // Remove any layers rendering to the opaque scene.\n if (this._scene.layers && this._opaqueRenderTarget) {\n for (let layer of this._scene.layers) {\n const idx = layer.renderTargetTextures.indexOf(this._opaqueRenderTarget);\n if (idx >= 0) {\n layer.renderTargetTextures.splice(idx, 1);\n }\n }\n }\n\n // Remove opaque render target\n if (this._opaqueRenderTarget) {\n opaqueRTIndex = this._scene.customRenderTargets.indexOf(this._opaqueRenderTarget);\n this._opaqueRenderTarget.dispose();\n }\n\n this._opaqueRenderTarget = new RenderTargetTexture(\"opaqueSceneTexture\", this._options.renderSize, this._scene, true);\n this._opaqueRenderTarget.renderList = this._opaqueMeshesCache;\n // this._opaqueRenderTarget.clearColor = new Color4(0.0, 0.0, 0.0, 0.0);\n this._opaqueRenderTarget.gammaSpace = true;\n this._opaqueRenderTarget.lodGenerationScale = 1;\n this._opaqueRenderTarget.lodGenerationOffset = -4;\n this._opaqueRenderTarget.samples = 4;\n\n if (opaqueRTIndex >= 0) {\n this._scene.customRenderTargets.splice(opaqueRTIndex, 0, this._opaqueRenderTarget);\n } else {\n opaqueRTIndex = this._scene.customRenderTargets.length;\n this._scene.customRenderTargets.push(this._opaqueRenderTarget);\n }\n\n // If there are other layers, they should be included in the render of the opaque background.\n if (this._scene.layers && this._opaqueRenderTarget) {\n for (let layer of this._scene.layers) {\n layer.renderTargetTextures.push(this._opaqueRenderTarget);\n }\n }\n\n this._transparentMeshesCache.forEach((mesh: AbstractMesh) => {\n if (this.shouldRenderAsTransmission(mesh.material) && mesh.material instanceof PBRMaterial) {\n mesh.material.refractionTexture = this._opaqueRenderTarget;\n }\n });\n }\n\n /**\n * Dispose all the elements created by the Helper.\n */\n public dispose(): void {\n this._scene._transmissionHelper = undefined;\n if (this._opaqueRenderTarget) {\n this._opaqueRenderTarget.dispose();\n this._opaqueRenderTarget = null;\n }\n this._transparentMeshesCache = [];\n this._opaqueMeshesCache = [];\n }\n}\n\nconst NAME = \"KHR_materials_transmission\";\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)\n */\nexport class KHR_materials_transmission implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n /**\n * Defines a number that determines the order the extensions are applied.\n */\n public order = 175;\n\n private _loader: GLTFLoader;\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n if (this.enabled) {\n loader.parent.transparencyAsCoverage = true;\n }\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n }\n\n /** @hidden */\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsTransmission>(context, material, this.name, (extensionContext, extension) => {\n const promises = new Array<Promise<any>>();\n promises.push(this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\n promises.push(this._loadTransparentPropertiesAsync(extensionContext, material, babylonMaterial, extension));\n return Promise.all(promises).then(() => { });\n });\n }\n\n private _loadTransparentPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material, extension: IKHRMaterialsTransmission): Promise<void> {\n if (!(babylonMaterial instanceof PBRMaterial)) {\n throw new Error(`${context}: Material type not supported`);\n }\n let pbrMaterial = babylonMaterial as PBRMaterial;\n\n // Enables \"refraction\" texture which represents transmitted light.\n pbrMaterial.subSurface.isRefractionEnabled = true;\n\n // Since this extension models thin-surface transmission only, we must make IOR = 1.0\n pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0;\n\n // Albedo colour will tint transmission.\n pbrMaterial.subSurface.useAlbedoToTintRefraction = true;\n\n if (extension.transmissionFactor !== undefined) {\n pbrMaterial.subSurface.refractionIntensity = extension.transmissionFactor;\n const scene = pbrMaterial.getScene() as unknown as ITransmissionHelperHolder;\n if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper) {\n new TransmissionHelper({}, pbrMaterial.getScene());\n }\n } else {\n pbrMaterial.subSurface.refractionIntensity = 0.0;\n pbrMaterial.subSurface.isRefractionEnabled = false;\n return Promise.resolve();\n }\n\n if (extension.transmissionTexture) {\n (extension.transmissionTexture as ITextureInfo).nonColorData = true;\n return this._loader.loadTextureInfoAsync(`${context}/transmissionTexture`, extension.transmissionTexture, undefined)\n .then((texture: BaseTexture) => {\n pbrMaterial.subSurface.thicknessTexture = texture;\n pbrMaterial.subSurface.useMaskFromThicknessTextureGltf = true;\n });\n } else {\n return Promise.resolve();\n }\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_transmission(loader));\n"]}
|
1
|
+
{"version":3,"file":"KHR_materials_transmission.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAKxE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wDAAwD,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAY,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAgDnD;;GAEG;AACH;IAkCI;;;;OAIG;IACH,4BAAY,OA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OAAO,CAAC,oBAAoB,CAAI,OAAO,yBAAsB,EAAE,SAAS,CAAC,mBAAmB,EAAE,SAAS,CAAC;iBAC/G,IAAI,CAAC,UAAC,OAAoB;gBACvB,WAAW,CAAC,UAAU,CAAC,0BAA0B,GAAG,OAAO,CAAC;gBAC5D,WAAW,CAAC,UAAU,CAAC,oBAAoB,GAAG,IAAI,CAAC;YACvD,CAAC,CAAC,CAAC;SACV;aAAM;YACH,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC5B;IACL,CAAC;IACL,iCAAC;AAAD,CAAC,AAnFD,IAmFC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,0BAA0B,CAAC,MAAM,CAAC,EAAtC,CAAsC,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { PBRMaterial } from \"@babylonjs/core/Materials/PBR/pbrMaterial\";\nimport { Material } from \"@babylonjs/core/Materials/material\";\nimport { BaseTexture } from \"@babylonjs/core/Materials/Textures/baseTexture\";\nimport { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { GLTFLoader } from \"../glTFLoader\";\nimport { IKHRMaterialsTransmission } from 'babylonjs-gltf2interface';\nimport { Scene } from \"@babylonjs/core/scene\";\nimport { AbstractMesh } from \"@babylonjs/core/Meshes/abstractMesh\";\nimport { Texture } from \"@babylonjs/core/Materials/Textures/texture\";\nimport { RenderTargetTexture } from \"@babylonjs/core/Materials/Textures/renderTargetTexture\";\nimport { Observable, Observer } from \"@babylonjs/core/Misc/observable\";\nimport { Constants } from \"@babylonjs/core/Engines/constants\";\nimport { Tools } from \"@babylonjs/core/Misc/tools\";\nimport { Color4 } from \"@babylonjs/core/Maths/math.color\";\n\ninterface ITransmissionHelperHolder {\n /**\n * @hidden\n */\n _transmissionHelper: TransmissionHelper | undefined;\n}\n\ninterface ITransmissionHelperOptions {\n /**\n * The size of the render buffers (default: 1024)\n */\n renderSize: number;\n\n /**\n * The number of samples to use when generating the render target texture for opaque meshes (default: 4)\n */\n samples: number;\n\n /**\n * Scale to apply when selecting the LOD level to sample the refraction texture (default: 1)\n */\n lodGenerationScale: number;\n\n /**\n * Offset to apply when selecting the LOD level to sample the refraction texture (default: -4)\n */\n lodGenerationOffset: number;\n\n /**\n * Type of the refraction render target texture (default: TEXTURETYPE_HALF_FLOAT)\n */\n renderTargetTextureType: number;\n\n /**\n * Defines if the mipmaps for the refraction render target texture must be generated (default: true)\n */\n generateMipmaps: boolean;\n\n /**\n * Clear color of the opaque texture. If not provided, use the scene clear color (which will be converted to linear space).\n * If provided, should be in linear space\n */\n clearColor?: Color4;\n}\n\n/**\n * A class to handle setting up the rendering of opaque objects to be shown through transmissive objects.\n */\nclass TransmissionHelper {\n\n /**\n * Creates the default options for the helper.\n */\n private static _getDefaultOptions(): ITransmissionHelperOptions {\n return {\n renderSize: 1024,\n samples: 4,\n lodGenerationScale: 1,\n lodGenerationOffset: -4,\n renderTargetTextureType: Constants.TEXTURETYPE_HALF_FLOAT,\n generateMipmaps: true,\n };\n }\n\n /**\n * Stores the creation options.\n */\n private readonly _scene: Scene & ITransmissionHelperHolder;\n\n private _options: ITransmissionHelperOptions;\n\n private _opaqueRenderTarget: Nullable<RenderTargetTexture> = null;\n private _opaqueMeshesCache: AbstractMesh[] = [];\n private _transparentMeshesCache: AbstractMesh[] = [];\n private _materialObservers: { [id: string]: Nullable<Observer<AbstractMesh>> } = {};\n\n /**\n * This observable will be notified with any error during the creation of the environment,\n * mainly texture creation errors.\n */\n public onErrorObservable: Observable<{ message?: string, exception?: any }>;\n\n /**\n * constructor\n * @param options Defines the options we want to customize the helper\n * @param scene The scene to add the material to\n */\n constructor(options: Partial<ITransmissionHelperOptions>, scene: Scene) {\n this._options = {\n ...TransmissionHelper._getDefaultOptions(),\n ...options\n };\n this._scene = scene as any;\n this._scene._transmissionHelper = this;\n\n this.onErrorObservable = new Observable();\n this._scene.onDisposeObservable.addOnce((scene) => {\n this.dispose();\n });\n\n this._parseScene();\n this._setupRenderTargets();\n }\n\n /**\n * Updates the background according to the new options\n * @param options\n */\n public updateOptions(options: Partial<ITransmissionHelperOptions>) {\n // First check if any options are actually being changed. If not, exit.\n const newValues = Object.keys(options).filter((key: string) => (this._options as any)[key] !== (options as any)[key]);\n if (!newValues.length) {\n return;\n }\n\n const newOptions = {\n ...this._options,\n ...options\n };\n\n const oldOptions = this._options;\n this._options = newOptions;\n\n // If size changes, recreate everything\n if (newOptions.renderSize !== oldOptions.renderSize || newOptions.renderTargetTextureType !== oldOptions.renderTargetTextureType || newOptions.generateMipmaps !== oldOptions.generateMipmaps || !this._opaqueRenderTarget) {\n this._setupRenderTargets();\n } else {\n this._opaqueRenderTarget.samples = newOptions.samples;\n this._opaqueRenderTarget.lodGenerationScale = newOptions.lodGenerationScale;\n this._opaqueRenderTarget.lodGenerationOffset = newOptions.lodGenerationOffset;\n }\n }\n\n public getOpaqueTarget(): Nullable<Texture> {\n return this._opaqueRenderTarget;\n }\n\n private shouldRenderAsTransmission(material: Nullable<Material>): boolean {\n if (!material) {\n return false;\n }\n if (material instanceof PBRMaterial && (material.subSurface.isRefractionEnabled)) {\n return true;\n }\n return false;\n }\n\n private _addMesh(mesh: AbstractMesh): void {\n this._materialObservers[mesh.uniqueId] = mesh.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this));\n\n // we need to defer the processing because _addMesh may be called as part as an instance mesh creation, in which case some\n // internal properties are not setup yet, like _sourceMesh (needed when doing mesh.material below)\n Tools.SetImmediate(() => {\n if (this.shouldRenderAsTransmission(mesh.material)) {\n (mesh.material as PBRMaterial).refractionTexture = this._opaqueRenderTarget;\n this._transparentMeshesCache.push(mesh);\n } else {\n this._opaqueMeshesCache.push(mesh);\n }\n });\n }\n\n private _removeMesh(mesh: AbstractMesh): void {\n mesh.onMaterialChangedObservable.remove(this._materialObservers[mesh.uniqueId]);\n delete this._materialObservers[mesh.uniqueId];\n let idx = this._transparentMeshesCache.indexOf(mesh);\n if (idx !== -1) {\n this._transparentMeshesCache.splice(idx, 1);\n }\n idx = this._opaqueMeshesCache.indexOf(mesh);\n if (idx !== -1) {\n this._opaqueMeshesCache.splice(idx, 1);\n }\n }\n\n private _parseScene(): void {\n this._scene.meshes.forEach(this._addMesh.bind(this));\n // Listen for when a mesh is added to the scene and add it to our cache lists.\n this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this));\n // Listen for when a mesh is removed from to the scene and remove it from our cache lists.\n this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this));\n }\n\n // When one of the meshes in the scene has its material changed, make sure that it's in the correct cache list.\n private _onMeshMaterialChanged(mesh: AbstractMesh) {\n const transparentIdx = this._transparentMeshesCache.indexOf(mesh);\n const opaqueIdx = this._opaqueMeshesCache.indexOf(mesh);\n\n // If the material is transparent, make sure that it's added to the transparent list and removed from the opaque list\n const useTransmission = this.shouldRenderAsTransmission(mesh.material);\n if (useTransmission) {\n if (mesh.material instanceof PBRMaterial) {\n mesh.material.subSurface.refractionTexture = this._opaqueRenderTarget;\n }\n if (opaqueIdx !== -1) {\n this._opaqueMeshesCache.splice(opaqueIdx, 1);\n this._transparentMeshesCache.push(mesh);\n } else if (transparentIdx === -1) {\n this._transparentMeshesCache.push(mesh);\n }\n // If the material is opaque, make sure that it's added to the opaque list and removed from the transparent list\n } else {\n if (transparentIdx !== -1) {\n this._transparentMeshesCache.splice(transparentIdx, 1);\n this._opaqueMeshesCache.push(mesh);\n } else if (opaqueIdx === -1) {\n this._opaqueMeshesCache.push(mesh);\n }\n }\n }\n\n /**\n * Setup the render targets according to the specified options.\n */\n private _setupRenderTargets(): void {\n if (this._opaqueRenderTarget) {\n this._opaqueRenderTarget.dispose();\n }\n this._opaqueRenderTarget = new RenderTargetTexture(\"opaqueSceneTexture\", this._options.renderSize, this._scene, this._options.generateMipmaps, undefined, this._options.renderTargetTextureType);\n this._opaqueRenderTarget.ignoreCameraViewport = true;\n this._opaqueRenderTarget.renderList = this._opaqueMeshesCache;\n this._opaqueRenderTarget.clearColor = this._options.clearColor?.clone() ?? this._scene.clearColor.clone();\n this._opaqueRenderTarget.gammaSpace = false;\n this._opaqueRenderTarget.lodGenerationScale = this._options.lodGenerationScale;\n this._opaqueRenderTarget.lodGenerationOffset = this._options.lodGenerationOffset;\n this._opaqueRenderTarget.samples = this._options.samples;\n\n let sceneImageProcessingapplyByPostProcess: boolean;\n\n let saveSceneEnvIntensity: number;\n this._opaqueRenderTarget.onBeforeBindObservable.add((opaqueRenderTarget) => {\n saveSceneEnvIntensity = this._scene.environmentIntensity;\n this._scene.environmentIntensity = 1.0;\n sceneImageProcessingapplyByPostProcess = this._scene.imageProcessingConfiguration.applyByPostProcess;\n if (!this._options.clearColor) {\n this._scene.clearColor.toLinearSpaceToRef(opaqueRenderTarget.clearColor);\n } else {\n opaqueRenderTarget.clearColor.copyFrom(this._options.clearColor);\n }\n // we do not use the applyByPostProcess setter to avoid flagging all the materials as \"image processing dirty\"!\n this._scene.imageProcessingConfiguration._applyByPostProcess = true;\n });\n this._opaqueRenderTarget.onAfterUnbindObservable.add(() => {\n this._scene.environmentIntensity = saveSceneEnvIntensity;\n this._scene.imageProcessingConfiguration._applyByPostProcess = sceneImageProcessingapplyByPostProcess;\n });\n\n this._transparentMeshesCache.forEach((mesh: AbstractMesh) => {\n if (this.shouldRenderAsTransmission(mesh.material)) {\n (mesh.material as PBRMaterial).refractionTexture = this._opaqueRenderTarget;\n }\n });\n }\n\n /**\n * Dispose all the elements created by the Helper.\n */\n public dispose(): void {\n this._scene._transmissionHelper = undefined;\n if (this._opaqueRenderTarget) {\n this._opaqueRenderTarget.dispose();\n this._opaqueRenderTarget = null;\n }\n this._transparentMeshesCache = [];\n this._opaqueMeshesCache = [];\n }\n}\n\nconst NAME = \"KHR_materials_transmission\";\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)\n */\nexport class KHR_materials_transmission implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n /**\n * Defines a number that determines the order the extensions are applied.\n */\n public order = 175;\n\n private _loader: GLTFLoader;\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n if (this.enabled) {\n loader.parent.transparencyAsCoverage = true;\n }\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n }\n\n /** @hidden */\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsTransmission>(context, material, this.name, (extensionContext, extension) => {\n const promises = new Array<Promise<any>>();\n promises.push(this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\n promises.push(this._loadTransparentPropertiesAsync(extensionContext, material, babylonMaterial, extension));\n return Promise.all(promises).then(() => { });\n });\n }\n\n private _loadTransparentPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material, extension: IKHRMaterialsTransmission): Promise<void> {\n if (!(babylonMaterial instanceof PBRMaterial)) {\n throw new Error(`${context}: Material type not supported`);\n }\n let pbrMaterial = babylonMaterial as PBRMaterial;\n\n // Enables \"refraction\" texture which represents transmitted light.\n pbrMaterial.subSurface.isRefractionEnabled = true;\n\n // Since this extension models thin-surface transmission only, we must make IOR = 1.0\n pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0;\n\n // Albedo colour will tint transmission.\n pbrMaterial.subSurface.useAlbedoToTintRefraction = true;\n\n if (extension.transmissionFactor !== undefined) {\n pbrMaterial.subSurface.refractionIntensity = extension.transmissionFactor;\n const scene = pbrMaterial.getScene() as unknown as ITransmissionHelperHolder;\n if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper) {\n new TransmissionHelper({}, pbrMaterial.getScene());\n }\n } else {\n pbrMaterial.subSurface.refractionIntensity = 0.0;\n pbrMaterial.subSurface.isRefractionEnabled = false;\n return Promise.resolve();\n }\n\n pbrMaterial.subSurface.minimumThickness = 0.0;\n pbrMaterial.subSurface.maximumThickness = 0.0;\n if (extension.transmissionTexture) {\n (extension.transmissionTexture as ITextureInfo).nonColorData = true;\n return this._loader.loadTextureInfoAsync(`${context}/transmissionTexture`, extension.transmissionTexture, undefined)\n .then((texture: BaseTexture) => {\n pbrMaterial.subSurface.refractionIntensityTexture = texture;\n pbrMaterial.subSurface.useGltfStyleTextures = true;\n });\n } else {\n return Promise.resolve();\n }\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_transmission(loader));\n"]}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { Color3 } from "@babylonjs/core/Maths/math.color";
|
2
|
-
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial";
|
3
|
-
import { GLTFLoader } from "../glTFLoader";
|
1
|
+
import { Color3 } from "@babylonjs/core/Maths/math.color.js";
|
2
|
+
import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
|
3
|
+
import { GLTFLoader } from "../glTFLoader.js";
|
4
4
|
var NAME = "KHR_materials_unlit";
|
5
5
|
/**
|
6
6
|
* [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { GLTFLoader, ArrayItem } from "../glTFLoader";
|
2
|
-
import { Mesh } from '@babylonjs/core/Meshes/mesh';
|
1
|
+
import { GLTFLoader, ArrayItem } from "../glTFLoader.js";
|
2
|
+
import { Mesh } from '@babylonjs/core/Meshes/mesh.js';
|
3
3
|
var NAME = "KHR_materials_variants";
|
4
4
|
/**
|
5
5
|
* [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
|
@@ -139,8 +139,8 @@ var KHR_materials_variants = /** @class */ (function () {
|
|
139
139
|
assign(babylonMesh);
|
140
140
|
if (babylonMesh instanceof Mesh) {
|
141
141
|
var babylonDrawMode = GLTFLoader._GetDrawMode(context, primitive.mode);
|
142
|
-
var
|
143
|
-
var metadata = (
|
142
|
+
var root_1 = _this._loader.rootBabylonMesh;
|
143
|
+
var metadata = (root_1 ? root_1.metadata = root_1.metadata || {} : {});
|
144
144
|
var gltf = (metadata.gltf = metadata.gltf || {});
|
145
145
|
var extensionMetadata_1 = (gltf[NAME] = gltf[NAME] || { lastSelected: null, original: [], variants: {} });
|
146
146
|
// Store the original material.
|
@@ -149,7 +149,7 @@ var KHR_materials_variants = /** @class */ (function () {
|
|
149
149
|
var mapping = extension.mappings[mappingIndex];
|
150
150
|
var material = ArrayItem.Get(extensionContext + "/mappings/" + mappingIndex + "/material", _this._loader.gltf.materials, mapping.material);
|
151
151
|
promises.push(_this._loader._loadMaterialAsync("#/materials/" + mapping.material, material, babylonMesh, babylonDrawMode, function (babylonMaterial) {
|
152
|
-
|
152
|
+
var _loop_2 = function (mappingVariantIndex) {
|
153
153
|
var variantIndex = mapping.variants[mappingVariantIndex];
|
154
154
|
var variant = ArrayItem.Get("/extensions/" + NAME + "/variants/" + variantIndex, _this._variants, variantIndex);
|
155
155
|
extensionMetadata_1.variants[variant.name] = extensionMetadata_1.variants[variant.name] || [];
|
@@ -157,6 +157,71 @@ var KHR_materials_variants = /** @class */ (function () {
|
|
157
157
|
mesh: babylonMesh,
|
158
158
|
material: babylonMaterial
|
159
159
|
});
|
160
|
+
// Replace the target when original mesh is cloned
|
161
|
+
babylonMesh.onClonedObservable.add(function (newOne) {
|
162
|
+
var newMesh = newOne;
|
163
|
+
var metadata = null;
|
164
|
+
var newRoot = newMesh;
|
165
|
+
// Find root to get medata
|
166
|
+
do {
|
167
|
+
newRoot = newRoot.parent;
|
168
|
+
if (!newRoot) {
|
169
|
+
return;
|
170
|
+
}
|
171
|
+
metadata = KHR_materials_variants._GetExtensionMetadata(newRoot);
|
172
|
+
} while (metadata === null);
|
173
|
+
// Need to clone the metadata on the root (first time only)
|
174
|
+
if (root_1 && metadata === KHR_materials_variants._GetExtensionMetadata(root_1)) {
|
175
|
+
// Copy main metadata
|
176
|
+
newRoot.metadata = {};
|
177
|
+
for (var key in root_1.metadata) {
|
178
|
+
newRoot.metadata[key] = root_1.metadata[key];
|
179
|
+
}
|
180
|
+
// Copy the gltf metadata
|
181
|
+
newRoot.metadata.gltf = [];
|
182
|
+
for (var key in root_1.metadata.gltf) {
|
183
|
+
newRoot.metadata.gltf[key] = root_1.metadata.gltf[key];
|
184
|
+
}
|
185
|
+
// Duplicate the extension specific metadata
|
186
|
+
newRoot.metadata.gltf[NAME] = { lastSelected: null, original: [], variants: {} };
|
187
|
+
for (var _i = 0, _a = metadata.original; _i < _a.length; _i++) {
|
188
|
+
var original = _a[_i];
|
189
|
+
newRoot.metadata.gltf[NAME].original.push({
|
190
|
+
mesh: original.mesh,
|
191
|
+
material: original.material
|
192
|
+
});
|
193
|
+
}
|
194
|
+
for (var key in metadata.variants) {
|
195
|
+
if (metadata.variants.hasOwnProperty(key)) {
|
196
|
+
newRoot.metadata.gltf[NAME].variants[key] = [];
|
197
|
+
for (var _b = 0, _c = metadata.variants[key]; _b < _c.length; _b++) {
|
198
|
+
var variantEntry = _c[_b];
|
199
|
+
newRoot.metadata.gltf[NAME].variants[key].push({
|
200
|
+
mesh: variantEntry.mesh,
|
201
|
+
material: variantEntry.material
|
202
|
+
});
|
203
|
+
}
|
204
|
+
}
|
205
|
+
}
|
206
|
+
metadata = newRoot.metadata.gltf[NAME];
|
207
|
+
}
|
208
|
+
// Relocate
|
209
|
+
for (var _d = 0, _e = metadata.original; _d < _e.length; _d++) {
|
210
|
+
var target = _e[_d];
|
211
|
+
if (target.mesh === babylonMesh) {
|
212
|
+
target.mesh = newMesh;
|
213
|
+
}
|
214
|
+
}
|
215
|
+
for (var _f = 0, _g = metadata.variants[variant.name]; _f < _g.length; _f++) {
|
216
|
+
var target = _g[_f];
|
217
|
+
if (target.mesh === babylonMesh) {
|
218
|
+
target.mesh = newMesh;
|
219
|
+
}
|
220
|
+
}
|
221
|
+
});
|
222
|
+
};
|
223
|
+
for (var mappingVariantIndex = 0; mappingVariantIndex < mapping.variants.length; ++mappingVariantIndex) {
|
224
|
+
_loop_2(mappingVariantIndex);
|
160
225
|
}
|
161
226
|
}));
|
162
227
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KHR_materials_variants.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/KHR_materials_variants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAKnD,IAAM,IAAI,GAAG,wBAAwB,CAAC;AAYtC;;GAEG;AACH;IAeI,cAAc;IACd,gCAAY,MAAkB;QAf9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAaxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,cAAc;IACP,wCAAO,GAAd;QACK,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACW,2CAAoB,GAAlC,UAAmC,QAAc;QAC7C,IAAM,iBAAiB,GAAG,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QAC/D,IAAI,CAAC,iBAAiB,EAAE;YACpB,OAAO,EAAE,CAAC;SACb;QAED,OAAO,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IACnD,CAAC;IAED;;;;OAIG;IACI,qDAAoB,GAA3B,UAA4B,QAAc;QACtC,OAAO,sBAAsB,CAAC,oBAAoB,C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AI,CAAC,UAAC,EAAa;oBAAZ,WAAW,QAAA;gBAC3C,OAAO,WAAW,CAAC;YACvB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IACL,6BAAC;AAAD,CAAC,AA/LD,IA+LC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,sBAAsB,CAAC,MAAM,CAAC,EAAlC,CAAkC,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\n\nimport { Material } from '@babylonjs/core/Materials/material';\nimport { Mesh } from '@babylonjs/core/Meshes/mesh';\nimport { AbstractMesh } from '@babylonjs/core/Meshes/abstractMesh';\nimport { INode, IMeshPrimitive, IMesh } from '../glTFLoaderInterfaces';\nimport { IKHRMaterialVariants_Mapping, IKHRMaterialVariants_Variant, IKHRMaterialVariants_Variants } from 'babylonjs-gltf2interface';\n\nconst NAME = \"KHR_materials_variants\";\n\ninterface IVariantsMap {\n [key: string]: Array<{ mesh: AbstractMesh, material: Nullable<Material> }>;\n}\n\ninterface IExtensionMetadata {\n lastSelected: Nullable<string | Array<string>>;\n original: Array<{ mesh: AbstractMesh, material: Nullable<Material> }>;\n variants: IVariantsMap;\n}\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)\n */\nexport class KHR_materials_variants implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n private _loader: GLTFLoader;\n\n private _variants?: Array<IKHRMaterialVariants_Variant>;\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n }\n\n /**\n * Gets the list of available variant names for this asset.\n * @param rootMesh The glTF root mesh\n * @returns the list of all the variant names for this model\n */\n public static GetAvailableVariants(rootMesh: Mesh): string[] {\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\n if (!extensionMetadata) {\n return [];\n }\n\n return Object.keys(extensionMetadata.variants);\n }\n\n /**\n * Gets the list of available variant names for this asset.\n * @param rootMesh The glTF root mesh\n * @returns the list of all the variant names for this model\n */\n public getAvailableVariants(rootMesh: Mesh): string[] {\n return KHR_materials_variants.GetAvailableVariants(rootMesh);\n }\n\n /**\n * Select a variant given a variant name or a list of variant names.\n * @param rootMesh The glTF root mesh\n * @param variantName The variant name(s) to select.\n */\n public static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void {\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\n if (!extensionMetadata) {\n throw new Error(`Cannot select variant on a glTF mesh that does not have the ${NAME} extension`);\n }\n\n const select = (variantName: string): void => {\n const entries = extensionMetadata.variants[variantName];\n if (entries) {\n for (const entry of entries) {\n entry.mesh.material = entry.material;\n }\n }\n };\n\n if (variantName instanceof Array) {\n for (const name of variantName) {\n select(name);\n }\n } else {\n select(variantName);\n }\n\n extensionMetadata.lastSelected = variantName;\n }\n\n /**\n * Select a variant given a variant name or a list of variant names.\n * @param rootMesh The glTF root mesh\n * @param variantName The variant name(s) to select.\n */\n public selectVariant(rootMesh: Mesh, variantName: string | string[]): void {\n return KHR_materials_variants.SelectVariant(rootMesh, variantName);\n }\n\n /**\n * Reset back to the original before selecting a variant.\n * @param rootMesh The glTF root mesh\n */\n public static Reset(rootMesh: Mesh): void {\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\n if (!extensionMetadata) {\n throw new Error(`Cannot reset on a glTF mesh that does not have the ${NAME} extension`);\n }\n\n for (const entry of extensionMetadata.original) {\n entry.mesh.material = entry.material;\n }\n\n extensionMetadata.lastSelected = null;\n }\n\n /**\n * Reset back to the original before selecting a variant.\n * @param rootMesh The glTF root mesh\n */\n public reset(rootMesh: Mesh): void {\n return KHR_materials_variants.Reset(rootMesh);\n }\n\n /**\n * Gets the last selected variant name(s) or null if original.\n * @param rootMesh The glTF root mesh\n * @returns The selected variant name(s).\n */\n public static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]> {\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\n if (!extensionMetadata) {\n throw new Error(`Cannot get the last selected variant on a glTF mesh that does not have the ${NAME} extension`);\n }\n\n return extensionMetadata.lastSelected;\n }\n\n /**\n * Gets the last selected variant name(s) or null if original.\n * @param rootMesh The glTF root mesh\n * @returns The selected variant name(s).\n */\n public getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]> {\n return KHR_materials_variants.GetLastSelectedVariant(rootMesh);\n }\n\n private static _GetExtensionMetadata(rootMesh: Mesh): Nullable<IExtensionMetadata> {\n return rootMesh?.metadata?.gltf?.[NAME] || null;\n }\n\n /** @hidden */\n public onLoading(): void {\n const extensions = this._loader.gltf.extensions;\n if (extensions && extensions[this.name]) {\n const extension = extensions[this.name] as IKHRMaterialVariants_Variants;\n this._variants = extension.variants;\n }\n }\n\n /** @hidden */\n public _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>> {\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialVariants_Mapping, AbstractMesh>(context, primitive, this.name, (extensionContext, extension) => {\n const promises = new Array<Promise<any>>();\n promises.push(this._loader._loadMeshPrimitiveAsync(context, name, node, mesh, primitive, (babylonMesh) => {\n assign(babylonMesh);\n\n if (babylonMesh instanceof Mesh) {\n const babylonDrawMode = GLTFLoader._GetDrawMode(context, primitive.mode);\n\n const root = this._loader.rootBabylonMesh;\n const metadata = (root.metadata = root.metadata || {});\n const gltf = (metadata.gltf = metadata.gltf || {});\n const extensionMetadata: IExtensionMetadata = (gltf[NAME] = gltf[NAME] || { lastSelected: null, original: [], variants: {} });\n\n // Store the original material.\n extensionMetadata.original.push({ mesh: babylonMesh, material: babylonMesh.material });\n\n // For each mapping, look at the variants and make a new entry for them.\n for (let mappingIndex = 0; mappingIndex < extension.mappings.length; ++mappingIndex) {\n const mapping = extension.mappings[mappingIndex];\n const material = ArrayItem.Get(`${extensionContext}/mappings/${mappingIndex}/material`, this._loader.gltf.materials, mapping.material);\n promises.push(this._loader._loadMaterialAsync(`#/materials/${mapping.material}`, material, babylonMesh, babylonDrawMode, (babylonMaterial) => {\n for (let mappingVariantIndex = 0; mappingVariantIndex < mapping.variants.length; ++mappingVariantIndex) {\n const variantIndex = mapping.variants[mappingVariantIndex];\n const variant = ArrayItem.Get(`/extensions/${NAME}/variants/${variantIndex}`, this._variants, variantIndex);\n extensionMetadata.variants[variant.name] = extensionMetadata.variants[variant.name] || [];\n extensionMetadata.variants[variant.name].push({\n mesh: babylonMesh,\n material: babylonMaterial\n });\n }\n }));\n }\n }\n }));\n return Promise.all(promises).then(([babylonMesh]) => {\n return babylonMesh;\n });\n });\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_variants(loader));\n"]}
|
1
|
+
{"version":3,"file":"KHR_materials_variants.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/KHR_materials_variants.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGtD,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AAMnD,IAAM,IAAI,GAAG,wBAAwB,CAAC;AAYtC;;GAEG;AACH;IAeI,cAAc;IACd,gCAAY,MAAkB;QAf9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAaxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,cAAc;IACP,wCAAO,GAA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OAAO,CAAC;yCACzB;qCACJ;oCACD,KAAmB,UAAgC,EAAhC,KAAA,QAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,EAAhC,cAAgC,EAAhC,IAAgC,EAAE;wCAAhD,IAAI,MAAM,SAAA;wCACX,IAAI,MAAM,CAAC,IAAI,KAAK,WAAW,EAAE;4CAC7B,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC;yCACzB;qCACJ;gCACL,CAAC,CAAC,CAAC;;4BAzEP,KAAK,IAAI,mBAAmB,GAAG,CAAC,EAAE,mBAAmB,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,mBAAmB;wCAA7F,mBAAmB;6BA0E3B;wBACL,CAAC,CAAC,CAAC,CAAC;;oBAhFR,wEAAwE;oBACxE,KAAK,IAAI,YAAY,GAAG,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,YAAY;gCAA1E,YAAY;qBAgFpB;iBACJ;YACL,CAAC,CAAC,CAAC,CAAC;YACJ,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAC,EAAa;oBAAZ,WAAW,QAAA;gBAC3C,OAAO,WAAW,CAAC;YACvB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IACL,6BAAC;AAAD,CAAC,AAjQD,IAiQC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,sBAAsB,CAAC,MAAM,CAAC,EAAlC,CAAkC,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\n\nimport { Material } from '@babylonjs/core/Materials/material';\nimport { Mesh } from '@babylonjs/core/Meshes/mesh';\nimport { Node } from '@babylonjs/core/node';\nimport { AbstractMesh } from '@babylonjs/core/Meshes/abstractMesh';\nimport { INode, IMeshPrimitive, IMesh } from '../glTFLoaderInterfaces';\nimport { IKHRMaterialVariants_Mapping, IKHRMaterialVariants_Variant, IKHRMaterialVariants_Variants } from 'babylonjs-gltf2interface';\n\nconst NAME = \"KHR_materials_variants\";\n\ninterface IVariantsMap {\n [key: string]: Array<{ mesh: AbstractMesh, material: Nullable<Material> }>;\n}\n\ninterface IExtensionMetadata {\n lastSelected: Nullable<string | Array<string>>;\n original: Array<{ mesh: AbstractMesh, material: Nullable<Material> }>;\n variants: IVariantsMap;\n}\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)\n */\nexport class KHR_materials_variants implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n private _loader: GLTFLoader;\n\n private _variants?: Array<IKHRMaterialVariants_Variant>;\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n }\n\n /**\n * Gets the list of available variant names for this asset.\n * @param rootMesh The glTF root mesh\n * @returns the list of all the variant names for this model\n */\n public static GetAvailableVariants(rootMesh: Mesh): string[] {\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\n if (!extensionMetadata) {\n return [];\n }\n\n return Object.keys(extensionMetadata.variants);\n }\n\n /**\n * Gets the list of available variant names for this asset.\n * @param rootMesh The glTF root mesh\n * @returns the list of all the variant names for this model\n */\n public getAvailableVariants(rootMesh: Mesh): string[] {\n return KHR_materials_variants.GetAvailableVariants(rootMesh);\n }\n\n /**\n * Select a variant given a variant name or a list of variant names.\n * @param rootMesh The glTF root mesh\n * @param variantName The variant name(s) to select.\n */\n public static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void {\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\n if (!extensionMetadata) {\n throw new Error(`Cannot select variant on a glTF mesh that does not have the ${NAME} extension`);\n }\n\n const select = (variantName: string): void => {\n const entries = extensionMetadata.variants[variantName];\n if (entries) {\n for (const entry of entries) {\n entry.mesh.material = entry.material;\n }\n }\n };\n\n if (variantName instanceof Array) {\n for (const name of variantName) {\n select(name);\n }\n } else {\n select(variantName);\n }\n\n extensionMetadata.lastSelected = variantName;\n }\n\n /**\n * Select a variant given a variant name or a list of variant names.\n * @param rootMesh The glTF root mesh\n * @param variantName The variant name(s) to select.\n */\n public selectVariant(rootMesh: Mesh, variantName: string | string[]): void {\n return KHR_materials_variants.SelectVariant(rootMesh, variantName);\n }\n\n /**\n * Reset back to the original before selecting a variant.\n * @param rootMesh The glTF root mesh\n */\n public static Reset(rootMesh: Mesh): void {\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\n if (!extensionMetadata) {\n throw new Error(`Cannot reset on a glTF mesh that does not have the ${NAME} extension`);\n }\n\n for (const entry of extensionMetadata.original) {\n entry.mesh.material = entry.material;\n }\n\n extensionMetadata.lastSelected = null;\n }\n\n /**\n * Reset back to the original before selecting a variant.\n * @param rootMesh The glTF root mesh\n */\n public reset(rootMesh: Mesh): void {\n return KHR_materials_variants.Reset(rootMesh);\n }\n\n /**\n * Gets the last selected variant name(s) or null if original.\n * @param rootMesh The glTF root mesh\n * @returns The selected variant name(s).\n */\n public static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]> {\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\n if (!extensionMetadata) {\n throw new Error(`Cannot get the last selected variant on a glTF mesh that does not have the ${NAME} extension`);\n }\n\n return extensionMetadata.lastSelected;\n }\n\n /**\n * Gets the last selected variant name(s) or null if original.\n * @param rootMesh The glTF root mesh\n * @returns The selected variant name(s).\n */\n public getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]> {\n return KHR_materials_variants.GetLastSelectedVariant(rootMesh);\n }\n\n private static _GetExtensionMetadata(rootMesh: Nullable<Mesh>): Nullable<IExtensionMetadata> {\n return rootMesh?.metadata?.gltf?.[NAME] || null;\n }\n\n /** @hidden */\n public onLoading(): void {\n const extensions = this._loader.gltf.extensions;\n if (extensions && extensions[this.name]) {\n const extension = extensions[this.name] as IKHRMaterialVariants_Variants;\n this._variants = extension.variants;\n }\n }\n\n /** @hidden */\n public _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>> {\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialVariants_Mapping, AbstractMesh>(context, primitive, this.name, (extensionContext, extension) => {\n const promises = new Array<Promise<any>>();\n promises.push(this._loader._loadMeshPrimitiveAsync(context, name, node, mesh, primitive, (babylonMesh) => {\n assign(babylonMesh);\n\n if (babylonMesh instanceof Mesh) {\n const babylonDrawMode = GLTFLoader._GetDrawMode(context, primitive.mode);\n\n const root = this._loader.rootBabylonMesh;\n const metadata = (root ? root.metadata = root.metadata || {} : {});\n const gltf = (metadata.gltf = metadata.gltf || {});\n const extensionMetadata: IExtensionMetadata = (gltf[NAME] = gltf[NAME] || { lastSelected: null, original: [], variants: {} });\n\n // Store the original material.\n extensionMetadata.original.push({ mesh: babylonMesh, material: babylonMesh.material });\n\n // For each mapping, look at the variants and make a new entry for them.\n for (let mappingIndex = 0; mappingIndex < extension.mappings.length; ++mappingIndex) {\n const mapping = extension.mappings[mappingIndex];\n const material = ArrayItem.Get(`${extensionContext}/mappings/${mappingIndex}/material`, this._loader.gltf.materials, mapping.material);\n promises.push(this._loader._loadMaterialAsync(`#/materials/${mapping.material}`, material, babylonMesh, babylonDrawMode, (babylonMaterial) => {\n for (let mappingVariantIndex = 0; mappingVariantIndex < mapping.variants.length; ++mappingVariantIndex) {\n const variantIndex = mapping.variants[mappingVariantIndex];\n const variant = ArrayItem.Get(`/extensions/${NAME}/variants/${variantIndex}`, this._variants, variantIndex);\n extensionMetadata.variants[variant.name] = extensionMetadata.variants[variant.name] || [];\n extensionMetadata.variants[variant.name].push({\n mesh: babylonMesh,\n material: babylonMaterial\n });\n\n // Replace the target when original mesh is cloned\n babylonMesh.onClonedObservable.add((newOne: Node) => {\n const newMesh = newOne as Mesh;\n let metadata: Nullable<IExtensionMetadata> = null;\n let newRoot: Nullable<Node> = newMesh;\n\n // Find root to get medata\n do {\n newRoot = newRoot!.parent;\n if (!newRoot) {\n return;\n }\n metadata = KHR_materials_variants._GetExtensionMetadata(newRoot as Mesh);\n }\n while (metadata === null);\n\n // Need to clone the metadata on the root (first time only)\n if (root && metadata === KHR_materials_variants._GetExtensionMetadata(root)) {\n // Copy main metadata\n newRoot.metadata = {};\n for (var key in root.metadata) {\n newRoot.metadata[key] = root.metadata[key];\n }\n\n // Copy the gltf metadata\n newRoot.metadata.gltf = [];\n for (var key in root.metadata.gltf) {\n newRoot.metadata.gltf[key] = root.metadata.gltf[key];\n }\n\n // Duplicate the extension specific metadata\n newRoot.metadata.gltf[NAME] = { lastSelected: null, original: [], variants: {} };\n for (var original of metadata.original) {\n newRoot.metadata.gltf[NAME].original.push({\n mesh: original.mesh,\n material: original.material\n });\n }\n for (var key in metadata.variants) {\n if (metadata.variants.hasOwnProperty(key)) {\n newRoot.metadata.gltf[NAME].variants[key] = [];\n for (var variantEntry of metadata.variants[key]) {\n newRoot.metadata.gltf[NAME].variants[key].push({\n mesh: variantEntry.mesh,\n material: variantEntry.material\n });\n }\n }\n }\n\n metadata = newRoot.metadata.gltf[NAME];\n }\n\n // Relocate\n for (var target of metadata!.original) {\n if (target.mesh === babylonMesh) {\n target.mesh = newMesh;\n }\n }\n for (var target of metadata!.variants[variant.name]) {\n if (target.mesh === babylonMesh) {\n target.mesh = newMesh;\n }\n }\n });\n }\n }));\n }\n }\n }));\n return Promise.all(promises).then(([babylonMesh]) => {\n return babylonMesh;\n });\n });\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_variants(loader));\n"]}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import { Nullable } from "@babylonjs/core/types";
|
2
|
+
import { Material } from "@babylonjs/core/Materials/material";
|
3
|
+
import { IMaterial } from "../glTFLoaderInterfaces";
|
4
|
+
import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
|
5
|
+
import { GLTFLoader } from "../glTFLoader";
|
6
|
+
/**
|
7
|
+
* [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_volume)
|
8
|
+
* @since 5.0.0
|
9
|
+
*/
|
10
|
+
export declare class KHR_materials_volume implements IGLTFLoaderExtension {
|
11
|
+
/**
|
12
|
+
* The name of this extension.
|
13
|
+
*/
|
14
|
+
readonly name = "KHR_materials_volume";
|
15
|
+
/**
|
16
|
+
* Defines whether this extension is enabled.
|
17
|
+
*/
|
18
|
+
enabled: boolean;
|
19
|
+
/**
|
20
|
+
* Defines a number that determines the order the extensions are applied.
|
21
|
+
*/
|
22
|
+
order: number;
|
23
|
+
private _loader;
|
24
|
+
/** @hidden */
|
25
|
+
constructor(loader: GLTFLoader);
|
26
|
+
/** @hidden */
|
27
|
+
dispose(): void;
|
28
|
+
/** @hidden */
|
29
|
+
loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
|
30
|
+
private _loadVolumePropertiesAsync;
|
31
|
+
}
|