@babylonjs/loaders 5.0.0-alpha.58 → 5.0.0-alpha.61

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,30 @@
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
+ * [Experimental Spec](https://github.com/KhronosGroup/glTF/pull/1994)
8
+ */
9
+ export declare class KHR_materials_emissive_strength implements IGLTFLoaderExtension {
10
+ /**
11
+ * The name of this extension.
12
+ */
13
+ readonly name = "KHR_materials_emissive_strength";
14
+ /**
15
+ * Defines whether this extension is enabled.
16
+ */
17
+ enabled: boolean;
18
+ /**
19
+ * Defines a number that determines the order the extensions are applied.
20
+ */
21
+ order: number;
22
+ private _loader;
23
+ /** @hidden */
24
+ constructor(loader: GLTFLoader);
25
+ /** @hidden */
26
+ dispose(): void;
27
+ /** @hidden */
28
+ loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
29
+ private _loadEmissiveProperties;
30
+ }
@@ -0,0 +1,46 @@
1
+ import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
2
+ import { GLTFLoader } from "../glTFLoader.js";
3
+ var NAME = "KHR_materials_emissive_strength";
4
+ /**
5
+ * [Experimental Spec](https://github.com/KhronosGroup/glTF/pull/1994)
6
+ */
7
+ var KHR_materials_emissive_strength = /** @class */ (function () {
8
+ /** @hidden */
9
+ function KHR_materials_emissive_strength(loader) {
10
+ /**
11
+ * The name of this extension.
12
+ */
13
+ this.name = NAME;
14
+ /**
15
+ * Defines a number that determines the order the extensions are applied.
16
+ */
17
+ this.order = 170;
18
+ this._loader = loader;
19
+ this.enabled = this._loader.isExtensionUsed(NAME);
20
+ }
21
+ /** @hidden */
22
+ KHR_materials_emissive_strength.prototype.dispose = function () {
23
+ this._loader = null;
24
+ };
25
+ /** @hidden */
26
+ KHR_materials_emissive_strength.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) {
27
+ var _this = this;
28
+ return GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) {
29
+ return _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial).then(function () {
30
+ _this._loadEmissiveProperties(extensionContext, extension, babylonMaterial);
31
+ });
32
+ });
33
+ };
34
+ KHR_materials_emissive_strength.prototype._loadEmissiveProperties = function (context, properties, babylonMaterial) {
35
+ if (!(babylonMaterial instanceof PBRMaterial)) {
36
+ throw new Error(context + ": Material type not supported");
37
+ }
38
+ if (properties.emissiveStrength !== undefined) {
39
+ babylonMaterial.emissiveColor.scaleToRef(properties.emissiveStrength, babylonMaterial.emissiveColor);
40
+ }
41
+ };
42
+ return KHR_materials_emissive_strength;
43
+ }());
44
+ export { KHR_materials_emissive_strength };
45
+ GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_emissive_strength(loader); });
46
+ //# sourceMappingURL=KHR_materials_emissive_strength.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"KHR_materials_emissive_strength.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAKxE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,IAAM,IAAI,GAAG,iCAAiC,CAAC;AAE/C;;GAEG;AACH;IAkBI,cAAc;IACd,yCAAY,MAAkB;QAlB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QAMf,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,iDAAO,GAAd;QACK,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED,cAAc;IACP,qEAA2B,GAAlC,UAAmC,OAAe,EAAE,QAAmB,EAAE,eAAyB;QAAlG,iBAMC;QALG,OAAO,UAAU,CAAC,kBAAkB,CAAgC,OAAO,EAAE,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,UAAC,gBAAgB,EAAE,SAAS;YAC1H,OAAO,KAAI,CAAC,OAAO,CAAC,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,eAAe,CAAC,CAAC,IAAI,CAAC;gBACrF,KAAI,CAAC,uBAAuB,CAAC,gBAAgB,EAAE,SAAS,EAAE,eAAe,CAAC,CAAC;YAC/E,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAEO,iEAAuB,GAA/B,UAAgC,OAAe,EAAE,UAAyC,EAAE,eAAyB;QACjH,IAAI,CAAC,CAAC,eAAe,YAAY,WAAW,CAAC,EAAE;YAC3C,MAAM,IAAI,KAAK,CAAI,OAAO,kCAA+B,CAAC,CAAC;SAC9D;QAED,IAAI,UAAU,CAAC,gBAAgB,KAAK,SAAS,EAAE;YAC3C,eAAe,CAAC,aAAa,CAAC,UAAU,CAAC,UAAU,CAAC,gBAAgB,EAAE,eAAe,CAAC,aAAa,CAAC,CAAC;SACxG;IACL,CAAC;IACL,sCAAC;AAAD,CAAC,AA/CD,IA+CC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,+BAA+B,CAAC,MAAM,CAAC,EAA3C,CAA2C,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { PBRMaterial } from \"@babylonjs/core/Materials/PBR/pbrMaterial\";\nimport { Material } from \"@babylonjs/core/Materials/material\";\n\nimport { IMaterial } from \"../glTFLoaderInterfaces\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { GLTFLoader } from \"../glTFLoader\";\nimport { IKHRMaterialsEmissiveStrength } from 'babylonjs-gltf2interface';\n\nconst NAME = \"KHR_materials_emissive_strength\";\n\n/**\n * [Experimental Spec](https://github.com/KhronosGroup/glTF/pull/1994)\n */\nexport class KHR_materials_emissive_strength 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 = 170;\n\n private _loader: GLTFLoader;\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 /** @hidden */\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsEmissiveStrength>(context, material, this.name, (extensionContext, extension) => {\n return this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial).then(() => {\n this._loadEmissiveProperties(extensionContext, extension, babylonMaterial);\n });\n });\n }\n\n private _loadEmissiveProperties(context: string, properties: IKHRMaterialsEmissiveStrength, babylonMaterial: Material): void {\n if (!(babylonMaterial instanceof PBRMaterial)) {\n throw new Error(`${context}: Material type not supported`);\n }\n\n if (properties.emissiveStrength !== undefined) {\n babylonMaterial.emissiveColor.scaleToRef(properties.emissiveStrength, babylonMaterial.emissiveColor);\n }\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_emissive_strength(loader));"]}
@@ -171,11 +171,12 @@ var TransmissionHelper = /** @class */ (function () {
171
171
  else {
172
172
  opaqueRenderTarget.clearColor.copyFrom(_this._options.clearColor);
173
173
  }
174
- _this._scene.imageProcessingConfiguration.applyByPostProcess = true;
174
+ // we do not use the applyByPostProcess setter to avoid flagging all the materials as "image processing dirty"!
175
+ _this._scene.imageProcessingConfiguration._applyByPostProcess = true;
175
176
  });
176
177
  this._opaqueRenderTarget.onAfterUnbindObservable.add(function () {
177
178
  _this._scene.environmentIntensity = saveSceneEnvIntensity;
178
- _this._scene.imageProcessingConfiguration.applyByPostProcess = sceneImageProcessingapplyByPostProcess;
179
+ _this._scene.imageProcessingConfiguration._applyByPostProcess = sceneImageProcessingapplyByPostProcess;
179
180
  });
180
181
  this._transparentMeshesCache.forEach(function (mesh) {
181
182
  if (_this.shouldRenderAsTransmission(mesh.material)) {
@@ -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;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,OAA4C,EAAE,KAAY;QAAtE,iBAeC;QA/BO,wBAAmB,GAAkC,IAAI,CAAC;QAC1D,uBAAkB,GAAmB,EAAE,CAAC;QACxC,4BAAuB,GAAmB,EAAE,CAAC;QAC7C,uBAAkB,GAAuD,EAAE,CAAC;QAchF,IAAI,CAAC,QAAQ,yBACN,kBAAkB,CAAC,kBAAkB,EAAE,GACvC,OAAO,CACb,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,KAAY,CAAC;QAC3B,IAAI,CAAC,MAAM,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAEvC,IAAI,CAAC,iBAAiB,GAAG,IAAI,UAAU,EAAE,CAAC;QAC1C,IAAI,CAAC,MAAM,CAAC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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 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
+ {"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,OAA4C,EAAE,KAAY;QAAtE,iBAeC;QA/BO,wBAAmB,GAAkC,IAAI,CAAC;QAC1D,uBAAkB,GAAmB,EAAE,CAAC;QACxC,4BAAuB,GAAmB,EAAE,CAAC;QAC7C,uBAAkB,GAAuD,EAAE,CAAC;QAchF,IAAI,CAAC,QAAQ,yBACN,kBAAkB,CAAC,kBAAkB,EAAE,GACvC,OAAO,CACb,CAAC;QACF,IAAI,CAAC,MAAM,GAAG,KAAY,CAAC;QAC3B,IAAI,CAAC,MAAM,CAAC,mBAAmB,GAAG,IAAI,CAAC;QAEvC,IAAI,CAAC,iBAAiB,GAAG,IAAI,UAAU,EAAE,CAAC;QAC1C,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAC,OAAO,CAAC,UAAC,KAAK;YAC1C,KAAI,CAAC,OAAO,EAAE,CAAC;QACnB,CAAC,CAAC,CAAC;QAEH,IAAI,CAAC,WAAW,EAAE,CAAC;QACnB,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC/B,CAAC;IApDD;;OAEG;IACY,qCAAkB,GAAjC;QACI,OAAO;YACH,UAAU,EAAE,IAAI;YAChB,OAAO,EAAE,CAAC;YACV,kBAAkB,EAAE,CAAC;YACrB,mBAAmB,EAAE,CAAC,CAAC;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AE,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;aACtD;SACJ;aAAM;YACH,WAAW,CAAC,UAAU,CAAC,mBAAmB,GAAG,GAAG,CAAC;YACjD,WAAW,CAAC,UAAU,CAAC,mBAAmB,GAAG,KAAK,CAAC;YACnD,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC5B;QAED,WAAW,CAAC,UAAU,CAAC,gBAAgB,GAAG,GAAG,CAAC;QAC9C,WAAW,CAAC,UAAU,CAAC,gBAAgB,GAAG,GAAG,CAAC;QAC9C,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,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"]}
@@ -7,6 +7,7 @@ export * from "./KHR_lights_punctual";
7
7
  export * from "./KHR_materials_pbrSpecularGlossiness";
8
8
  export * from "./KHR_materials_unlit";
9
9
  export * from "./KHR_materials_clearcoat";
10
+ export * from "./KHR_materials_emissive_strength";
10
11
  export * from "./KHR_materials_sheen";
11
12
  export * from "./KHR_materials_specular";
12
13
  export * from "./KHR_materials_ior";
@@ -7,6 +7,7 @@ export * from "./KHR_lights_punctual.js";
7
7
  export * from "./KHR_materials_pbrSpecularGlossiness.js";
8
8
  export * from "./KHR_materials_unlit.js";
9
9
  export * from "./KHR_materials_clearcoat.js";
10
+ export * from "./KHR_materials_emissive_strength.js";
10
11
  export * from "./KHR_materials_sheen.js";
11
12
  export * from "./KHR_materials_specular.js";
12
13
  export * from "./KHR_materials_ior.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./EXT_lights_image_based\";\r\nexport * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./EXT_meshopt_compression\";\r\nexport * from \"./EXT_texture_webp\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_pbrSpecularGlossiness\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_variants\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_translucency\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./KHR_mesh_quantization\";\r\nexport * from \"./KHR_texture_basisu\";\r\nexport * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_xmp_json_ld\";\r\nexport * from \"./MSFT_audio_emitter\";\r\nexport * from \"./MSFT_lod\";\r\nexport * from \"./MSFT_minecraftMesh\";\r\nexport * from \"./MSFT_sRGBFactors\";\r\nexport * from \"./ExtrasAsMetadata\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./EXT_lights_image_based\";\r\nexport * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./EXT_meshopt_compression\";\r\nexport * from \"./EXT_texture_webp\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_pbrSpecularGlossiness\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_emissive_strength\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_variants\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_translucency\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./KHR_mesh_quantization\";\r\nexport * from \"./KHR_texture_basisu\";\r\nexport * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_xmp_json_ld\";\r\nexport * from \"./MSFT_audio_emitter\";\r\nexport * from \"./MSFT_lod\";\r\nexport * from \"./MSFT_minecraftMesh\";\r\nexport * from \"./MSFT_sRGBFactors\";\r\nexport * from \"./ExtrasAsMetadata\";\r\n"]}
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  },
5
5
  "name": "@babylonjs/loaders",
6
6
  "description": "The Babylon.js file loaders library is an extension you can use to load different 3D file types into a Babylon scene.",
7
- "version": "5.0.0-alpha.58",
7
+ "version": "5.0.0-alpha.61",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/BabylonJS/Babylon.js.git"
@@ -56,6 +56,9 @@
56
56
  "glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts",
57
57
  "glTF/2.0/Extensions/KHR_materials_clearcoat.js",
58
58
  "glTF/2.0/Extensions/KHR_materials_clearcoat.js.map",
59
+ "glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts",
60
+ "glTF/2.0/Extensions/KHR_materials_emissive_strength.js",
61
+ "glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map",
59
62
  "glTF/2.0/Extensions/KHR_materials_ior.d.ts",
60
63
  "glTF/2.0/Extensions/KHR_materials_ior.js",
61
64
  "glTF/2.0/Extensions/KHR_materials_ior.js.map",
@@ -191,8 +194,8 @@
191
194
  ],
192
195
  "license": "Apache-2.0",
193
196
  "dependencies": {
194
- "babylonjs-gltf2interface": "5.0.0-alpha.58",
195
- "@babylonjs/core": "5.0.0-alpha.58",
197
+ "babylonjs-gltf2interface": "5.0.0-alpha.61",
198
+ "@babylonjs/core": "5.0.0-alpha.61",
196
199
  "tslib": "^2.3.1"
197
200
  },
198
201
  "engines": {