@babylonjs/loaders 6.38.0 → 6.38.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -160,22 +160,20 @@ class TransmissionHelper {
160
160
  * @returns
161
161
  */
162
162
  _isRenderTargetValid() {
163
- var _a;
164
- return ((_a = this._opaqueRenderTarget) === null || _a === void 0 ? void 0 : _a.getInternalTexture()) !== null;
163
+ return this._opaqueRenderTarget?.getInternalTexture() !== null;
165
164
  }
166
165
  /**
167
166
  * @internal
168
167
  * Setup the render targets according to the specified options.
169
168
  */
170
169
  _setupRenderTargets() {
171
- var _a, _b;
172
170
  if (this._opaqueRenderTarget) {
173
171
  this._opaqueRenderTarget.dispose();
174
172
  }
175
173
  this._opaqueRenderTarget = new RenderTargetTexture("opaqueSceneTexture", this._options.renderSize, this._scene, this._options.generateMipmaps, undefined, this._options.renderTargetTextureType);
176
174
  this._opaqueRenderTarget.ignoreCameraViewport = true;
177
175
  this._opaqueRenderTarget.renderList = this._opaqueMeshesCache;
178
- 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();
176
+ this._opaqueRenderTarget.clearColor = this._options.clearColor?.clone() ?? this._scene.clearColor.clone();
179
177
  this._opaqueRenderTarget.gammaSpace = false;
180
178
  this._opaqueRenderTarget.lodGenerationScale = this._options.lodGenerationScale;
181
179
  this._opaqueRenderTarget.lodGenerationOffset = this._options.lodGenerationOffset;
@@ -261,7 +259,6 @@ export class KHR_materials_transmission {
261
259
  });
262
260
  }
263
261
  _loadTransparentPropertiesAsync(context, material, babylonMaterial, extension) {
264
- var _a, _b;
265
262
  if (!(babylonMaterial instanceof PBRMaterial)) {
266
263
  throw new Error(`${context}: Material type not supported`);
267
264
  }
@@ -278,9 +275,9 @@ export class KHR_materials_transmission {
278
275
  if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper) {
279
276
  new TransmissionHelper({}, pbrMaterial.getScene());
280
277
  }
281
- else if (pbrMaterial.subSurface.refractionIntensity && !((_a = scene._transmissionHelper) === null || _a === void 0 ? void 0 : _a._isRenderTargetValid())) {
278
+ else if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper?._isRenderTargetValid()) {
282
279
  // If the render target is not valid, recreate it.
283
- (_b = scene._transmissionHelper) === null || _b === void 0 ? void 0 : _b._setupRenderTargets();
280
+ scene._transmissionHelper?._setupRenderTargets();
284
281
  }
285
282
  }
286
283
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_transmission.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,OAAO,EAAE,mBAAmB,EAAE,kEAAoD;AAElF,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,SAAS,EAAE,6CAA+B;AACnD,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAgDxC;;GAEG;AACH,MAAM,kBAAkB;IACpB;;OAEG;IACK,MAAM,CAAC,kBAAkB;QAC7B,OAAO;YACH,UAAU,EAAE,IAAI;YAChB,OAAO,EAAE,CAAC;YACV,kBAAkB,EAAE,CAAC;YACrB,mBAAmB,EAAE,CAAC,CAAC;YACvB,uBAAuB,EAAE,SAAS,CAAC,sBAAsB;YACzD,eAAe,EAAE,IAAI;SACxB,CAAC;IACN,CAAC;IAoBD;;;;OAIG;IACH,YAAY,OAA4C,EAAE,KAAY;QAhB9D,wBAAmB,GAAkC,IAAI,CAAC;QAC1D,uBAAkB,GAAmB,EAAE,CAAC;QACxC,4BAAuB,GAAmB,EAAE,CAAC;QAC7C,uBAAkB,GAAuD,EAAE,CAAC;QAchF,IAAI,CAAC,QAAQ,GAAG;YACZ,GAAG,kBAAkB,CAAC,kBAAkB,EAAE;YAC1C,GAAG,OAAO;SACb,CAAC;QACF,IAA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AG,CAAC;QAC9C,IAAI,SAAS,CAAC,mBAAmB,EAAE;YAC9B,SAAS,CAAC,mBAAoC,CAAC,YAAY,GAAG,IAAI,CAAC;YACpE,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,CAAC,GAAG,OAAO,sBAAsB,EAAE,SAAS,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,OAAoB,EAAE,EAAE;gBAC/I,WAAW,CAAC,UAAU,CAAC,0BAA0B,GAAG,OAAO,CAAC;gBAC5D,WAAW,CAAC,UAAU,CAAC,oBAAoB,GAAG,IAAI,CAAC;YACvD,CAAC,CAAC,CAAC;SACN;aAAM;YACH,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC5B;IACL,CAAC;CACJ;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRMaterialsTransmission } from \"babylonjs-gltf2interface\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { Color4 } from \"core/Maths/math.color\";\r\n\r\ninterface ITransmissionHelperHolder {\r\n /**\r\n * @internal\r\n */\r\n _transmissionHelper: TransmissionHelper | undefined;\r\n}\r\n\r\ninterface ITransmissionHelperOptions {\r\n /**\r\n * The size of the render buffers (default: 1024)\r\n */\r\n renderSize: number;\r\n\r\n /**\r\n * The number of samples to use when generating the render target texture for opaque meshes (default: 4)\r\n */\r\n samples: number;\r\n\r\n /**\r\n * Scale to apply when selecting the LOD level to sample the refraction texture (default: 1)\r\n */\r\n lodGenerationScale: number;\r\n\r\n /**\r\n * Offset to apply when selecting the LOD level to sample the refraction texture (default: -4)\r\n */\r\n lodGenerationOffset: number;\r\n\r\n /**\r\n * Type of the refraction render target texture (default: TEXTURETYPE_HALF_FLOAT)\r\n */\r\n renderTargetTextureType: number;\r\n\r\n /**\r\n * Defines if the mipmaps for the refraction render target texture must be generated (default: true)\r\n */\r\n generateMipmaps: boolean;\r\n\r\n /**\r\n * Clear color of the opaque texture. If not provided, use the scene clear color (which will be converted to linear space).\r\n * If provided, should be in linear space\r\n */\r\n clearColor?: Color4;\r\n}\r\n\r\n/**\r\n * A class to handle setting up the rendering of opaque objects to be shown through transmissive objects.\r\n */\r\nclass TransmissionHelper {\r\n /**\r\n * Creates the default options for the helper.\r\n */\r\n private static _GetDefaultOptions(): ITransmissionHelperOptions {\r\n return {\r\n renderSize: 1024,\r\n samples: 4,\r\n lodGenerationScale: 1,\r\n lodGenerationOffset: -4,\r\n renderTargetTextureType: Constants.TEXTURETYPE_HALF_FLOAT,\r\n generateMipmaps: true,\r\n };\r\n }\r\n\r\n /**\r\n * Stores the creation options.\r\n */\r\n private readonly _scene: Scene & ITransmissionHelperHolder;\r\n\r\n private _options: ITransmissionHelperOptions;\r\n\r\n private _opaqueRenderTarget: Nullable<RenderTargetTexture> = null;\r\n private _opaqueMeshesCache: AbstractMesh[] = [];\r\n private _transparentMeshesCache: AbstractMesh[] = [];\r\n private _materialObservers: { [id: string]: Nullable<Observer<AbstractMesh>> } = {};\r\n\r\n /**\r\n * This observable will be notified with any error during the creation of the environment,\r\n * mainly texture creation errors.\r\n */\r\n public onErrorObservable: Observable<{ message?: string; exception?: any }>;\r\n\r\n /**\r\n * constructor\r\n * @param options Defines the options we want to customize the helper\r\n * @param scene The scene to add the material to\r\n */\r\n constructor(options: Partial<ITransmissionHelperOptions>, scene: Scene) {\r\n this._options = {\r\n ...TransmissionHelper._GetDefaultOptions(),\r\n ...options,\r\n };\r\n this._scene = scene as any;\r\n this._scene._transmissionHelper = this;\r\n\r\n this.onErrorObservable = new Observable();\r\n this._scene.onDisposeObservable.addOnce(() => {\r\n this.dispose();\r\n });\r\n\r\n this._parseScene();\r\n this._setupRenderTargets();\r\n }\r\n\r\n /**\r\n * Updates the background according to the new options\r\n * @param options\r\n */\r\n public updateOptions(options: Partial<ITransmissionHelperOptions>) {\r\n // First check if any options are actually being changed. If not, exit.\r\n const newValues = Object.keys(options).filter((key: string) => (this._options as any)[key] !== (options as any)[key]);\r\n if (!newValues.length) {\r\n return;\r\n }\r\n\r\n const newOptions = {\r\n ...this._options,\r\n ...options,\r\n };\r\n\r\n const oldOptions = this._options;\r\n this._options = newOptions;\r\n\r\n // If size changes, recreate everything\r\n if (\r\n newOptions.renderSize !== oldOptions.renderSize ||\r\n newOptions.renderTargetTextureType !== oldOptions.renderTargetTextureType ||\r\n newOptions.generateMipmaps !== oldOptions.generateMipmaps ||\r\n !this._opaqueRenderTarget\r\n ) {\r\n this._setupRenderTargets();\r\n } else {\r\n this._opaqueRenderTarget.samples = newOptions.samples;\r\n this._opaqueRenderTarget.lodGenerationScale = newOptions.lodGenerationScale;\r\n this._opaqueRenderTarget.lodGenerationOffset = newOptions.lodGenerationOffset;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the opaque render target texture or null if not available.\r\n */\r\n public getOpaqueTarget(): Nullable<Texture> {\r\n return this._opaqueRenderTarget;\r\n }\r\n\r\n private _shouldRenderAsTransmission(material: Nullable<Material>): boolean {\r\n if (!material) {\r\n return false;\r\n }\r\n if (material instanceof PBRMaterial && material.subSurface.isRefractionEnabled) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n private _addMesh(mesh: AbstractMesh): void {\r\n this._materialObservers[mesh.uniqueId] = mesh.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this));\r\n\r\n // we need to defer the processing because _addMesh may be called as part as an instance mesh creation, in which case some\r\n // internal properties are not setup yet, like _sourceMesh (needed when doing mesh.material below)\r\n Tools.SetImmediate(() => {\r\n if (this._shouldRenderAsTransmission(mesh.material)) {\r\n (mesh.material as PBRMaterial).refractionTexture = this._opaqueRenderTarget;\r\n if (this._transparentMeshesCache.indexOf(mesh) === -1) {\r\n this._transparentMeshesCache.push(mesh);\r\n }\r\n } else {\r\n if (this._opaqueMeshesCache.indexOf(mesh) === -1) {\r\n this._opaqueMeshesCache.push(mesh);\r\n }\r\n }\r\n });\r\n }\r\n\r\n private _removeMesh(mesh: AbstractMesh): void {\r\n mesh.onMaterialChangedObservable.remove(this._materialObservers[mesh.uniqueId]);\r\n delete this._materialObservers[mesh.uniqueId];\r\n let idx = this._transparentMeshesCache.indexOf(mesh);\r\n if (idx !== -1) {\r\n this._transparentMeshesCache.splice(idx, 1);\r\n }\r\n idx = this._opaqueMeshesCache.indexOf(mesh);\r\n if (idx !== -1) {\r\n this._opaqueMeshesCache.splice(idx, 1);\r\n }\r\n }\r\n\r\n private _parseScene(): void {\r\n this._scene.meshes.forEach(this._addMesh.bind(this));\r\n // Listen for when a mesh is added to the scene and add it to our cache lists.\r\n this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this));\r\n // Listen for when a mesh is removed from to the scene and remove it from our cache lists.\r\n this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this));\r\n }\r\n\r\n // When one of the meshes in the scene has its material changed, make sure that it's in the correct cache list.\r\n private _onMeshMaterialChanged(mesh: AbstractMesh) {\r\n const transparentIdx = this._transparentMeshesCache.indexOf(mesh);\r\n const opaqueIdx = this._opaqueMeshesCache.indexOf(mesh);\r\n\r\n // If the material is transparent, make sure that it's added to the transparent list and removed from the opaque list\r\n const useTransmission = this._shouldRenderAsTransmission(mesh.material);\r\n if (useTransmission) {\r\n if (mesh.material instanceof PBRMaterial) {\r\n mesh.material.subSurface.refractionTexture = this._opaqueRenderTarget;\r\n }\r\n if (opaqueIdx !== -1) {\r\n this._opaqueMeshesCache.splice(opaqueIdx, 1);\r\n this._transparentMeshesCache.push(mesh);\r\n } else if (transparentIdx === -1) {\r\n this._transparentMeshesCache.push(mesh);\r\n }\r\n // If the material is opaque, make sure that it's added to the opaque list and removed from the transparent list\r\n } else {\r\n if (transparentIdx !== -1) {\r\n this._transparentMeshesCache.splice(transparentIdx, 1);\r\n this._opaqueMeshesCache.push(mesh);\r\n } else if (opaqueIdx === -1) {\r\n this._opaqueMeshesCache.push(mesh);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n * Check if the opaque render target has not been disposed and can still be used.\r\n * @returns\r\n */\r\n public _isRenderTargetValid() {\r\n return this._opaqueRenderTarget?.getInternalTexture() !== null;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Setup the render targets according to the specified options.\r\n */\r\n public _setupRenderTargets(): void {\r\n if (this._opaqueRenderTarget) {\r\n this._opaqueRenderTarget.dispose();\r\n }\r\n this._opaqueRenderTarget = new RenderTargetTexture(\r\n \"opaqueSceneTexture\",\r\n this._options.renderSize,\r\n this._scene,\r\n this._options.generateMipmaps,\r\n undefined,\r\n this._options.renderTargetTextureType\r\n );\r\n this._opaqueRenderTarget.ignoreCameraViewport = true;\r\n this._opaqueRenderTarget.renderList = this._opaqueMeshesCache;\r\n this._opaqueRenderTarget.clearColor = this._options.clearColor?.clone() ?? this._scene.clearColor.clone();\r\n this._opaqueRenderTarget.gammaSpace = false;\r\n this._opaqueRenderTarget.lodGenerationScale = this._options.lodGenerationScale;\r\n this._opaqueRenderTarget.lodGenerationOffset = this._options.lodGenerationOffset;\r\n this._opaqueRenderTarget.samples = this._options.samples;\r\n this._opaqueRenderTarget.renderSprites = true;\r\n this._opaqueRenderTarget.renderParticles = true;\r\n\r\n let sceneImageProcessingapplyByPostProcess: boolean;\r\n\r\n let saveSceneEnvIntensity: number;\r\n this._opaqueRenderTarget.onBeforeBindObservable.add((opaqueRenderTarget) => {\r\n saveSceneEnvIntensity = this._scene.environmentIntensity;\r\n this._scene.environmentIntensity = 1.0;\r\n sceneImageProcessingapplyByPostProcess = this._scene.imageProcessingConfiguration.applyByPostProcess;\r\n if (!this._options.clearColor) {\r\n this._scene.clearColor.toLinearSpaceToRef(opaqueRenderTarget.clearColor, this._scene.getEngine().useExactSrgbConversions);\r\n } else {\r\n opaqueRenderTarget.clearColor.copyFrom(this._options.clearColor);\r\n }\r\n // we do not use the applyByPostProcess setter to avoid flagging all the materials as \"image processing dirty\"!\r\n this._scene.imageProcessingConfiguration._applyByPostProcess = true;\r\n });\r\n this._opaqueRenderTarget.onAfterUnbindObservable.add(() => {\r\n this._scene.environmentIntensity = saveSceneEnvIntensity;\r\n this._scene.imageProcessingConfiguration._applyByPostProcess = sceneImageProcessingapplyByPostProcess;\r\n });\r\n\r\n this._transparentMeshesCache.forEach((mesh: AbstractMesh) => {\r\n if (this._shouldRenderAsTransmission(mesh.material)) {\r\n (mesh.material as PBRMaterial).refractionTexture = this._opaqueRenderTarget;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Dispose all the elements created by the Helper.\r\n */\r\n public dispose(): void {\r\n this._scene._transmissionHelper = undefined;\r\n if (this._opaqueRenderTarget) {\r\n this._opaqueRenderTarget.dispose();\r\n this._opaqueRenderTarget = null;\r\n }\r\n this._transparentMeshesCache = [];\r\n this._opaqueMeshesCache = [];\r\n }\r\n}\r\n\r\nconst NAME = \"KHR_materials_transmission\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_transmission/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_transmission implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 175;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n if (this.enabled) {\r\n loader.parent.transparencyAsCoverage = true;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsTransmission>(context, material, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadTransparentPropertiesAsync(extensionContext, material, babylonMaterial, extension));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadTransparentPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material, extension: IKHRMaterialsTransmission): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n const pbrMaterial = babylonMaterial as PBRMaterial;\r\n\r\n // Enables \"refraction\" texture which represents transmitted light.\r\n pbrMaterial.subSurface.isRefractionEnabled = true;\r\n\r\n // Since this extension models thin-surface transmission only, we must make IOR = 1.0\r\n pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0;\r\n\r\n // Albedo colour will tint transmission.\r\n pbrMaterial.subSurface.useAlbedoToTintRefraction = true;\r\n\r\n if (extension.transmissionFactor !== undefined) {\r\n pbrMaterial.subSurface.refractionIntensity = extension.transmissionFactor;\r\n const scene = pbrMaterial.getScene() as unknown as ITransmissionHelperHolder;\r\n if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper) {\r\n new TransmissionHelper({}, pbrMaterial.getScene());\r\n } else if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper?._isRenderTargetValid()) {\r\n // If the render target is not valid, recreate it.\r\n scene._transmissionHelper?._setupRenderTargets();\r\n }\r\n } else {\r\n pbrMaterial.subSurface.refractionIntensity = 0.0;\r\n pbrMaterial.subSurface.isRefractionEnabled = false;\r\n return Promise.resolve();\r\n }\r\n\r\n pbrMaterial.subSurface.minimumThickness = 0.0;\r\n pbrMaterial.subSurface.maximumThickness = 0.0;\r\n if (extension.transmissionTexture) {\r\n (extension.transmissionTexture as ITextureInfo).nonColorData = true;\r\n return this._loader.loadTextureInfoAsync(`${context}/transmissionTexture`, extension.transmissionTexture, undefined).then((texture: BaseTexture) => {\r\n pbrMaterial.subSurface.refractionIntensityTexture = texture;\r\n pbrMaterial.subSurface.useGltfStyleTextures = true;\r\n });\r\n } else {\r\n return Promise.resolve();\r\n }\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_transmission(loader));\r\n"]}
1
+ {"version":3,"file":"KHR_materials_transmission.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,qDAAuC;AAK7D,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAK3C,OAAO,EAAE,mBAAmB,EAAE,kEAAoD;AAElF,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,SAAS,EAAE,6CAA+B;AACnD,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAgDxC;;GAEG;AACH,MAAM,kBAAkB;IACpB;;OAEG;IACK,MAAM,CAAC,kBAAkB;QAC7B,OAAO;YACH,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,CAAC,mBAAmB,IAAI,CAAC,KAAK,CAAC,mBAAmB,EAAE,oBAAoB,EAAE,EAAE;gBACzG,kDAAkD;gBAClD,KAAK,CAAC,mBAAmB,EAAE,mBAAmB,EAAE,CAAC;aACpD;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,CAAC,GAAG,OAAO,sBAAsB,EAAE,SAAS,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,OAAoB,EAAE,EAAE;gBAC/I,WAAW,CAAC,UAAU,CAAC,0BAA0B,GAAG,OAAO,CAAC;gBAC5D,WAAW,CAAC,UAAU,CAAC,oBAAoB,GAAG,IAAI,CAAC;YACvD,CAAC,CAAC,CAAC;SACN;aAAM;YACH,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;SAC5B;IACL,CAAC;CACJ;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport { PBRMaterial } from \"core/Materials/PBR/pbrMaterial\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { IMaterial, ITextureInfo } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRMaterialsTransmission } from \"babylonjs-gltf2interface\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type { Texture } from \"core/Materials/Textures/texture\";\r\nimport { RenderTargetTexture } from \"core/Materials/Textures/renderTargetTexture\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { Constants } from \"core/Engines/constants\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { Color4 } from \"core/Maths/math.color\";\r\n\r\ninterface ITransmissionHelperHolder {\r\n /**\r\n * @internal\r\n */\r\n _transmissionHelper: TransmissionHelper | undefined;\r\n}\r\n\r\ninterface ITransmissionHelperOptions {\r\n /**\r\n * The size of the render buffers (default: 1024)\r\n */\r\n renderSize: number;\r\n\r\n /**\r\n * The number of samples to use when generating the render target texture for opaque meshes (default: 4)\r\n */\r\n samples: number;\r\n\r\n /**\r\n * Scale to apply when selecting the LOD level to sample the refraction texture (default: 1)\r\n */\r\n lodGenerationScale: number;\r\n\r\n /**\r\n * Offset to apply when selecting the LOD level to sample the refraction texture (default: -4)\r\n */\r\n lodGenerationOffset: number;\r\n\r\n /**\r\n * Type of the refraction render target texture (default: TEXTURETYPE_HALF_FLOAT)\r\n */\r\n renderTargetTextureType: number;\r\n\r\n /**\r\n * Defines if the mipmaps for the refraction render target texture must be generated (default: true)\r\n */\r\n generateMipmaps: boolean;\r\n\r\n /**\r\n * Clear color of the opaque texture. If not provided, use the scene clear color (which will be converted to linear space).\r\n * If provided, should be in linear space\r\n */\r\n clearColor?: Color4;\r\n}\r\n\r\n/**\r\n * A class to handle setting up the rendering of opaque objects to be shown through transmissive objects.\r\n */\r\nclass TransmissionHelper {\r\n /**\r\n * Creates the default options for the helper.\r\n */\r\n private static _GetDefaultOptions(): ITransmissionHelperOptions {\r\n return {\r\n renderSize: 1024,\r\n samples: 4,\r\n lodGenerationScale: 1,\r\n lodGenerationOffset: -4,\r\n renderTargetTextureType: Constants.TEXTURETYPE_HALF_FLOAT,\r\n generateMipmaps: true,\r\n };\r\n }\r\n\r\n /**\r\n * Stores the creation options.\r\n */\r\n private readonly _scene: Scene & ITransmissionHelperHolder;\r\n\r\n private _options: ITransmissionHelperOptions;\r\n\r\n private _opaqueRenderTarget: Nullable<RenderTargetTexture> = null;\r\n private _opaqueMeshesCache: AbstractMesh[] = [];\r\n private _transparentMeshesCache: AbstractMesh[] = [];\r\n private _materialObservers: { [id: string]: Nullable<Observer<AbstractMesh>> } = {};\r\n\r\n /**\r\n * This observable will be notified with any error during the creation of the environment,\r\n * mainly texture creation errors.\r\n */\r\n public onErrorObservable: Observable<{ message?: string; exception?: any }>;\r\n\r\n /**\r\n * constructor\r\n * @param options Defines the options we want to customize the helper\r\n * @param scene The scene to add the material to\r\n */\r\n constructor(options: Partial<ITransmissionHelperOptions>, scene: Scene) {\r\n this._options = {\r\n ...TransmissionHelper._GetDefaultOptions(),\r\n ...options,\r\n };\r\n this._scene = scene as any;\r\n this._scene._transmissionHelper = this;\r\n\r\n this.onErrorObservable = new Observable();\r\n this._scene.onDisposeObservable.addOnce(() => {\r\n this.dispose();\r\n });\r\n\r\n this._parseScene();\r\n this._setupRenderTargets();\r\n }\r\n\r\n /**\r\n * Updates the background according to the new options\r\n * @param options\r\n */\r\n public updateOptions(options: Partial<ITransmissionHelperOptions>) {\r\n // First check if any options are actually being changed. If not, exit.\r\n const newValues = Object.keys(options).filter((key: string) => (this._options as any)[key] !== (options as any)[key]);\r\n if (!newValues.length) {\r\n return;\r\n }\r\n\r\n const newOptions = {\r\n ...this._options,\r\n ...options,\r\n };\r\n\r\n const oldOptions = this._options;\r\n this._options = newOptions;\r\n\r\n // If size changes, recreate everything\r\n if (\r\n newOptions.renderSize !== oldOptions.renderSize ||\r\n newOptions.renderTargetTextureType !== oldOptions.renderTargetTextureType ||\r\n newOptions.generateMipmaps !== oldOptions.generateMipmaps ||\r\n !this._opaqueRenderTarget\r\n ) {\r\n this._setupRenderTargets();\r\n } else {\r\n this._opaqueRenderTarget.samples = newOptions.samples;\r\n this._opaqueRenderTarget.lodGenerationScale = newOptions.lodGenerationScale;\r\n this._opaqueRenderTarget.lodGenerationOffset = newOptions.lodGenerationOffset;\r\n }\r\n }\r\n\r\n /**\r\n * Gets the opaque render target texture or null if not available.\r\n */\r\n public getOpaqueTarget(): Nullable<Texture> {\r\n return this._opaqueRenderTarget;\r\n }\r\n\r\n private _shouldRenderAsTransmission(material: Nullable<Material>): boolean {\r\n if (!material) {\r\n return false;\r\n }\r\n if (material instanceof PBRMaterial && material.subSurface.isRefractionEnabled) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n private _addMesh(mesh: AbstractMesh): void {\r\n this._materialObservers[mesh.uniqueId] = mesh.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this));\r\n\r\n // we need to defer the processing because _addMesh may be called as part as an instance mesh creation, in which case some\r\n // internal properties are not setup yet, like _sourceMesh (needed when doing mesh.material below)\r\n Tools.SetImmediate(() => {\r\n if (this._shouldRenderAsTransmission(mesh.material)) {\r\n (mesh.material as PBRMaterial).refractionTexture = this._opaqueRenderTarget;\r\n if (this._transparentMeshesCache.indexOf(mesh) === -1) {\r\n this._transparentMeshesCache.push(mesh);\r\n }\r\n } else {\r\n if (this._opaqueMeshesCache.indexOf(mesh) === -1) {\r\n this._opaqueMeshesCache.push(mesh);\r\n }\r\n }\r\n });\r\n }\r\n\r\n private _removeMesh(mesh: AbstractMesh): void {\r\n mesh.onMaterialChangedObservable.remove(this._materialObservers[mesh.uniqueId]);\r\n delete this._materialObservers[mesh.uniqueId];\r\n let idx = this._transparentMeshesCache.indexOf(mesh);\r\n if (idx !== -1) {\r\n this._transparentMeshesCache.splice(idx, 1);\r\n }\r\n idx = this._opaqueMeshesCache.indexOf(mesh);\r\n if (idx !== -1) {\r\n this._opaqueMeshesCache.splice(idx, 1);\r\n }\r\n }\r\n\r\n private _parseScene(): void {\r\n this._scene.meshes.forEach(this._addMesh.bind(this));\r\n // Listen for when a mesh is added to the scene and add it to our cache lists.\r\n this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this));\r\n // Listen for when a mesh is removed from to the scene and remove it from our cache lists.\r\n this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this));\r\n }\r\n\r\n // When one of the meshes in the scene has its material changed, make sure that it's in the correct cache list.\r\n private _onMeshMaterialChanged(mesh: AbstractMesh) {\r\n const transparentIdx = this._transparentMeshesCache.indexOf(mesh);\r\n const opaqueIdx = this._opaqueMeshesCache.indexOf(mesh);\r\n\r\n // If the material is transparent, make sure that it's added to the transparent list and removed from the opaque list\r\n const useTransmission = this._shouldRenderAsTransmission(mesh.material);\r\n if (useTransmission) {\r\n if (mesh.material instanceof PBRMaterial) {\r\n mesh.material.subSurface.refractionTexture = this._opaqueRenderTarget;\r\n }\r\n if (opaqueIdx !== -1) {\r\n this._opaqueMeshesCache.splice(opaqueIdx, 1);\r\n this._transparentMeshesCache.push(mesh);\r\n } else if (transparentIdx === -1) {\r\n this._transparentMeshesCache.push(mesh);\r\n }\r\n // If the material is opaque, make sure that it's added to the opaque list and removed from the transparent list\r\n } else {\r\n if (transparentIdx !== -1) {\r\n this._transparentMeshesCache.splice(transparentIdx, 1);\r\n this._opaqueMeshesCache.push(mesh);\r\n } else if (opaqueIdx === -1) {\r\n this._opaqueMeshesCache.push(mesh);\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n * Check if the opaque render target has not been disposed and can still be used.\r\n * @returns\r\n */\r\n public _isRenderTargetValid() {\r\n return this._opaqueRenderTarget?.getInternalTexture() !== null;\r\n }\r\n\r\n /**\r\n * @internal\r\n * Setup the render targets according to the specified options.\r\n */\r\n public _setupRenderTargets(): void {\r\n if (this._opaqueRenderTarget) {\r\n this._opaqueRenderTarget.dispose();\r\n }\r\n this._opaqueRenderTarget = new RenderTargetTexture(\r\n \"opaqueSceneTexture\",\r\n this._options.renderSize,\r\n this._scene,\r\n this._options.generateMipmaps,\r\n undefined,\r\n this._options.renderTargetTextureType\r\n );\r\n this._opaqueRenderTarget.ignoreCameraViewport = true;\r\n this._opaqueRenderTarget.renderList = this._opaqueMeshesCache;\r\n this._opaqueRenderTarget.clearColor = this._options.clearColor?.clone() ?? this._scene.clearColor.clone();\r\n this._opaqueRenderTarget.gammaSpace = false;\r\n this._opaqueRenderTarget.lodGenerationScale = this._options.lodGenerationScale;\r\n this._opaqueRenderTarget.lodGenerationOffset = this._options.lodGenerationOffset;\r\n this._opaqueRenderTarget.samples = this._options.samples;\r\n this._opaqueRenderTarget.renderSprites = true;\r\n this._opaqueRenderTarget.renderParticles = true;\r\n\r\n let sceneImageProcessingapplyByPostProcess: boolean;\r\n\r\n let saveSceneEnvIntensity: number;\r\n this._opaqueRenderTarget.onBeforeBindObservable.add((opaqueRenderTarget) => {\r\n saveSceneEnvIntensity = this._scene.environmentIntensity;\r\n this._scene.environmentIntensity = 1.0;\r\n sceneImageProcessingapplyByPostProcess = this._scene.imageProcessingConfiguration.applyByPostProcess;\r\n if (!this._options.clearColor) {\r\n this._scene.clearColor.toLinearSpaceToRef(opaqueRenderTarget.clearColor, this._scene.getEngine().useExactSrgbConversions);\r\n } else {\r\n opaqueRenderTarget.clearColor.copyFrom(this._options.clearColor);\r\n }\r\n // we do not use the applyByPostProcess setter to avoid flagging all the materials as \"image processing dirty\"!\r\n this._scene.imageProcessingConfiguration._applyByPostProcess = true;\r\n });\r\n this._opaqueRenderTarget.onAfterUnbindObservable.add(() => {\r\n this._scene.environmentIntensity = saveSceneEnvIntensity;\r\n this._scene.imageProcessingConfiguration._applyByPostProcess = sceneImageProcessingapplyByPostProcess;\r\n });\r\n\r\n this._transparentMeshesCache.forEach((mesh: AbstractMesh) => {\r\n if (this._shouldRenderAsTransmission(mesh.material)) {\r\n (mesh.material as PBRMaterial).refractionTexture = this._opaqueRenderTarget;\r\n }\r\n });\r\n }\r\n\r\n /**\r\n * Dispose all the elements created by the Helper.\r\n */\r\n public dispose(): void {\r\n this._scene._transmissionHelper = undefined;\r\n if (this._opaqueRenderTarget) {\r\n this._opaqueRenderTarget.dispose();\r\n this._opaqueRenderTarget = null;\r\n }\r\n this._transparentMeshesCache = [];\r\n this._opaqueMeshesCache = [];\r\n }\r\n}\r\n\r\nconst NAME = \"KHR_materials_transmission\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_transmission/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_transmission implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 175;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n if (this.enabled) {\r\n loader.parent.transparencyAsCoverage = true;\r\n }\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialsTransmission>(context, material, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial));\r\n promises.push(this._loadTransparentPropertiesAsync(extensionContext, material, babylonMaterial, extension));\r\n return Promise.all(promises).then(() => {});\r\n });\r\n }\r\n\r\n private _loadTransparentPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material, extension: IKHRMaterialsTransmission): Promise<void> {\r\n if (!(babylonMaterial instanceof PBRMaterial)) {\r\n throw new Error(`${context}: Material type not supported`);\r\n }\r\n const pbrMaterial = babylonMaterial as PBRMaterial;\r\n\r\n // Enables \"refraction\" texture which represents transmitted light.\r\n pbrMaterial.subSurface.isRefractionEnabled = true;\r\n\r\n // Since this extension models thin-surface transmission only, we must make IOR = 1.0\r\n pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0;\r\n\r\n // Albedo colour will tint transmission.\r\n pbrMaterial.subSurface.useAlbedoToTintRefraction = true;\r\n\r\n if (extension.transmissionFactor !== undefined) {\r\n pbrMaterial.subSurface.refractionIntensity = extension.transmissionFactor;\r\n const scene = pbrMaterial.getScene() as unknown as ITransmissionHelperHolder;\r\n if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper) {\r\n new TransmissionHelper({}, pbrMaterial.getScene());\r\n } else if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper?._isRenderTargetValid()) {\r\n // If the render target is not valid, recreate it.\r\n scene._transmissionHelper?._setupRenderTargets();\r\n }\r\n } else {\r\n pbrMaterial.subSurface.refractionIntensity = 0.0;\r\n pbrMaterial.subSurface.isRefractionEnabled = false;\r\n return Promise.resolve();\r\n }\r\n\r\n pbrMaterial.subSurface.minimumThickness = 0.0;\r\n pbrMaterial.subSurface.maximumThickness = 0.0;\r\n if (extension.transmissionTexture) {\r\n (extension.transmissionTexture as ITextureInfo).nonColorData = true;\r\n return this._loader.loadTextureInfoAsync(`${context}/transmissionTexture`, extension.transmissionTexture, undefined).then((texture: BaseTexture) => {\r\n pbrMaterial.subSurface.refractionIntensityTexture = texture;\r\n pbrMaterial.subSurface.useGltfStyleTextures = true;\r\n });\r\n } else {\r\n return Promise.resolve();\r\n }\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_transmission(loader));\r\n"]}
@@ -119,8 +119,7 @@ export class KHR_materials_variants {
119
119
  return KHR_materials_variants.GetLastSelectedVariant(rootMesh);
120
120
  }
121
121
  static _GetExtensionMetadata(rootMesh) {
122
- var _a, _b;
123
- return ((_b = (_a = rootMesh === null || rootMesh === void 0 ? void 0 : rootMesh._internalMetadata) === null || _a === void 0 ? void 0 : _a.gltf) === null || _b === void 0 ? void 0 : _b[NAME]) || null;
122
+ return rootMesh?._internalMetadata?.gltf?.[NAME] || null;
124
123
  }
125
124
  /** @internal */
126
125
  onLoading() {
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_materials_variants.js","sourceRoot":"","sources":["../../../../../../dev/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,uCAAyB;AAMxC,MAAM,IAAI,GAAG,wBAAwB,CAAC;AAYtC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,sBAAsB;IAe/B;;OAEG;IACH,YAAY,MAAkB;QAjB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAexB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,gBAAgB;IACT,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,oBAAoB,CAAC,QAAc;QAC7C,MAAM,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,oBAAoB,CAAC,QAAc;QAC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CAAC,WAAW,CAAC,EAAE,EAAE;gBAChD,OAAO,WAAW,CAAC;YACvB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,sBAAsB,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { Nullable } from \"core/types\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\n\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport type { Node } from \"core/node\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type { INode, IMeshPrimitive, IMesh } from \"../glTFLoaderInterfaces\";\r\nimport type { IKHRMaterialVariants_Mapping, IKHRMaterialVariants_Variant, IKHRMaterialVariants_Variants } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"KHR_materials_variants\";\r\n\r\ninterface IVariantsMap {\r\n [key: string]: Array<{ mesh: AbstractMesh; material: Nullable<Material> }>;\r\n}\r\n\r\ninterface IExtensionMetadata {\r\n lastSelected: Nullable<string | Array<string>>;\r\n original: Array<{ mesh: AbstractMesh; material: Nullable<Material> }>;\r\n variants: IVariantsMap;\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_variants/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_variants implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n private _variants?: Array<IKHRMaterialVariants_Variant>;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * Gets the list of available variant names for this asset.\r\n * @param rootMesh The glTF root mesh\r\n * @returns the list of all the variant names for this model\r\n */\r\n public static GetAvailableVariants(rootMesh: Mesh): string[] {\r\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\r\n if (!extensionMetadata) {\r\n return [];\r\n }\r\n\r\n return Object.keys(extensionMetadata.variants);\r\n }\r\n\r\n /**\r\n * Gets the list of available variant names for this asset.\r\n * @param rootMesh The glTF root mesh\r\n * @returns the list of all the variant names for this model\r\n */\r\n public getAvailableVariants(rootMesh: Mesh): string[] {\r\n return KHR_materials_variants.GetAvailableVariants(rootMesh);\r\n }\r\n\r\n /**\r\n * Select a variant given a variant name or a list of variant names.\r\n * @param rootMesh The glTF root mesh\r\n * @param variantName The variant name(s) to select.\r\n */\r\n public static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void {\r\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\r\n if (!extensionMetadata) {\r\n throw new Error(`Cannot select variant on a glTF mesh that does not have the ${NAME} extension`);\r\n }\r\n\r\n const select = (variantName: string): void => {\r\n const entries = extensionMetadata.variants[variantName];\r\n if (entries) {\r\n for (const entry of entries) {\r\n entry.mesh.material = entry.material;\r\n }\r\n }\r\n };\r\n\r\n if (variantName instanceof Array) {\r\n for (const name of variantName) {\r\n select(name);\r\n }\r\n } else {\r\n select(variantName);\r\n }\r\n\r\n extensionMetadata.lastSelected = variantName;\r\n }\r\n\r\n /**\r\n * Select a variant given a variant name or a list of variant names.\r\n * @param rootMesh The glTF root mesh\r\n * @param variantName The variant name(s) to select.\r\n */\r\n public selectVariant(rootMesh: Mesh, variantName: string | string[]): void {\r\n return KHR_materials_variants.SelectVariant(rootMesh, variantName);\r\n }\r\n\r\n /**\r\n * Reset back to the original before selecting a variant.\r\n * @param rootMesh The glTF root mesh\r\n */\r\n public static Reset(rootMesh: Mesh): void {\r\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\r\n if (!extensionMetadata) {\r\n throw new Error(`Cannot reset on a glTF mesh that does not have the ${NAME} extension`);\r\n }\r\n\r\n for (const entry of extensionMetadata.original) {\r\n entry.mesh.material = entry.material;\r\n }\r\n\r\n extensionMetadata.lastSelected = null;\r\n }\r\n\r\n /**\r\n * Reset back to the original before selecting a variant.\r\n * @param rootMesh The glTF root mesh\r\n */\r\n public reset(rootMesh: Mesh): void {\r\n return KHR_materials_variants.Reset(rootMesh);\r\n }\r\n\r\n /**\r\n * Gets the last selected variant name(s) or null if original.\r\n * @param rootMesh The glTF root mesh\r\n * @returns The selected variant name(s).\r\n */\r\n public static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]> {\r\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\r\n if (!extensionMetadata) {\r\n throw new Error(`Cannot get the last selected variant on a glTF mesh that does not have the ${NAME} extension`);\r\n }\r\n\r\n return extensionMetadata.lastSelected;\r\n }\r\n\r\n /**\r\n * Gets the last selected variant name(s) or null if original.\r\n * @param rootMesh The glTF root mesh\r\n * @returns The selected variant name(s).\r\n */\r\n public getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]> {\r\n return KHR_materials_variants.GetLastSelectedVariant(rootMesh);\r\n }\r\n\r\n private static _GetExtensionMetadata(rootMesh: Nullable<Mesh>): Nullable<IExtensionMetadata> {\r\n return rootMesh?._internalMetadata?.gltf?.[NAME] || null;\r\n }\r\n\r\n /** @internal */\r\n public onLoading(): void {\r\n const extensions = this._loader.gltf.extensions;\r\n if (extensions && extensions[this.name]) {\r\n const extension = extensions[this.name] as IKHRMaterialVariants_Variants;\r\n this._variants = extension.variants;\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _loadMeshPrimitiveAsync(\r\n context: string,\r\n name: string,\r\n node: INode,\r\n mesh: IMesh,\r\n primitive: IMeshPrimitive,\r\n assign: (babylonMesh: AbstractMesh) => void\r\n ): Nullable<Promise<AbstractMesh>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialVariants_Mapping, AbstractMesh>(context, primitive, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(\r\n this._loader._loadMeshPrimitiveAsync(context, name, node, mesh, primitive, (babylonMesh) => {\r\n assign(babylonMesh);\r\n\r\n if (babylonMesh instanceof Mesh) {\r\n const babylonDrawMode = GLTFLoader._GetDrawMode(context, primitive.mode);\r\n\r\n const root = this._loader.rootBabylonMesh;\r\n const metadata = root ? (root._internalMetadata = root._internalMetadata || {}) : {};\r\n const gltf = (metadata.gltf = metadata.gltf || {});\r\n const extensionMetadata: IExtensionMetadata = (gltf[NAME] = gltf[NAME] || { lastSelected: null, original: [], variants: {} });\r\n\r\n // Store the original material.\r\n extensionMetadata.original.push({ mesh: babylonMesh, material: babylonMesh.material });\r\n\r\n // For each mapping, look at the variants and make a new entry for them.\r\n for (let mappingIndex = 0; mappingIndex < extension.mappings.length; ++mappingIndex) {\r\n const mapping = extension.mappings[mappingIndex];\r\n const material = ArrayItem.Get(`${extensionContext}/mappings/${mappingIndex}/material`, this._loader.gltf.materials, mapping.material);\r\n promises.push(\r\n this._loader._loadMaterialAsync(`#/materials/${mapping.material}`, material, babylonMesh, babylonDrawMode, (babylonMaterial) => {\r\n for (let mappingVariantIndex = 0; mappingVariantIndex < mapping.variants.length; ++mappingVariantIndex) {\r\n const variantIndex = mapping.variants[mappingVariantIndex];\r\n const variant = ArrayItem.Get(`/extensions/${NAME}/variants/${variantIndex}`, this._variants, variantIndex);\r\n extensionMetadata.variants[variant.name] = extensionMetadata.variants[variant.name] || [];\r\n extensionMetadata.variants[variant.name].push({\r\n mesh: babylonMesh,\r\n material: babylonMaterial,\r\n });\r\n\r\n // Replace the target when original mesh is cloned\r\n babylonMesh.onClonedObservable.add((newOne: Node) => {\r\n const newMesh = newOne as Mesh;\r\n let metadata: Nullable<IExtensionMetadata> = null;\r\n let newRoot: Nullable<Node> = newMesh;\r\n\r\n // Find root to get medata\r\n do {\r\n newRoot = newRoot!.parent;\r\n if (!newRoot) {\r\n return;\r\n }\r\n metadata = KHR_materials_variants._GetExtensionMetadata(newRoot as Mesh);\r\n } while (metadata === null);\r\n\r\n // Need to clone the metadata on the root (first time only)\r\n if (root && metadata === KHR_materials_variants._GetExtensionMetadata(root)) {\r\n // Copy main metadata\r\n newRoot._internalMetadata = {};\r\n for (const key in root._internalMetadata) {\r\n newRoot._internalMetadata[key] = root._internalMetadata[key];\r\n }\r\n\r\n // Copy the gltf metadata\r\n newRoot._internalMetadata.gltf = [];\r\n for (const key in root._internalMetadata.gltf) {\r\n newRoot._internalMetadata.gltf[key] = root._internalMetadata.gltf[key];\r\n }\r\n\r\n // Duplicate the extension specific metadata\r\n newRoot._internalMetadata.gltf[NAME] = { lastSelected: null, original: [], variants: {} };\r\n for (const original of metadata.original) {\r\n newRoot._internalMetadata.gltf[NAME].original.push({\r\n mesh: original.mesh,\r\n material: original.material,\r\n });\r\n }\r\n for (const key in metadata.variants) {\r\n if (Object.prototype.hasOwnProperty.call(metadata.variants, key)) {\r\n newRoot._internalMetadata.gltf[NAME].variants[key] = [];\r\n for (const variantEntry of metadata.variants[key]) {\r\n newRoot._internalMetadata.gltf[NAME].variants[key].push({\r\n mesh: variantEntry.mesh,\r\n material: variantEntry.material,\r\n });\r\n }\r\n }\r\n }\r\n\r\n metadata = newRoot._internalMetadata.gltf[NAME];\r\n }\r\n\r\n // Relocate\r\n for (const target of metadata!.original) {\r\n if (target.mesh === babylonMesh) {\r\n target.mesh = newMesh;\r\n }\r\n }\r\n for (const target of metadata!.variants[variant.name]) {\r\n if (target.mesh === babylonMesh) {\r\n target.mesh = newMesh;\r\n }\r\n }\r\n });\r\n }\r\n })\r\n );\r\n }\r\n }\r\n })\r\n );\r\n return Promise.all(promises).then(([babylonMesh]) => {\r\n return babylonMesh;\r\n });\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_variants(loader));\r\n"]}
1
+ {"version":3,"file":"KHR_materials_variants.js","sourceRoot":"","sources":["../../../../../../dev/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,uCAAyB;AAMxC,MAAM,IAAI,GAAG,wBAAwB,CAAC;AAYtC;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,sBAAsB;IAe/B;;OAEG;IACH,YAAY,MAAkB;QAjB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAexB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,gBAAgB;IACT,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,oBAAoB,CAAC,QAAc;QAC7C,MAAM,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,oBAAoB,CAAC,QAAc;QACtC,OAAO,sBAAsB,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IACjE,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,aAAa,CAAC,QAAc,EAAE,WAA8B;QACtE,MAAM,iBAAiB,GAAG,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC;QAC/D,IAAI,CAAC,iBAAiB,EAAE;YACpB,MAAM,IAA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TFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\n\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport type { Node } from \"core/node\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type { INode, IMeshPrimitive, IMesh } from \"../glTFLoaderInterfaces\";\r\nimport type { IKHRMaterialVariants_Mapping, IKHRMaterialVariants_Variant, IKHRMaterialVariants_Variants } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"KHR_materials_variants\";\r\n\r\ninterface IVariantsMap {\r\n [key: string]: Array<{ mesh: AbstractMesh; material: Nullable<Material> }>;\r\n}\r\n\r\ninterface IExtensionMetadata {\r\n lastSelected: Nullable<string | Array<string>>;\r\n original: Array<{ mesh: AbstractMesh; material: Nullable<Material> }>;\r\n variants: IVariantsMap;\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_variants/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_materials_variants implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n private _variants?: Array<IKHRMaterialVariants_Variant>;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * Gets the list of available variant names for this asset.\r\n * @param rootMesh The glTF root mesh\r\n * @returns the list of all the variant names for this model\r\n */\r\n public static GetAvailableVariants(rootMesh: Mesh): string[] {\r\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\r\n if (!extensionMetadata) {\r\n return [];\r\n }\r\n\r\n return Object.keys(extensionMetadata.variants);\r\n }\r\n\r\n /**\r\n * Gets the list of available variant names for this asset.\r\n * @param rootMesh The glTF root mesh\r\n * @returns the list of all the variant names for this model\r\n */\r\n public getAvailableVariants(rootMesh: Mesh): string[] {\r\n return KHR_materials_variants.GetAvailableVariants(rootMesh);\r\n }\r\n\r\n /**\r\n * Select a variant given a variant name or a list of variant names.\r\n * @param rootMesh The glTF root mesh\r\n * @param variantName The variant name(s) to select.\r\n */\r\n public static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void {\r\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\r\n if (!extensionMetadata) {\r\n throw new Error(`Cannot select variant on a glTF mesh that does not have the ${NAME} extension`);\r\n }\r\n\r\n const select = (variantName: string): void => {\r\n const entries = extensionMetadata.variants[variantName];\r\n if (entries) {\r\n for (const entry of entries) {\r\n entry.mesh.material = entry.material;\r\n }\r\n }\r\n };\r\n\r\n if (variantName instanceof Array) {\r\n for (const name of variantName) {\r\n select(name);\r\n }\r\n } else {\r\n select(variantName);\r\n }\r\n\r\n extensionMetadata.lastSelected = variantName;\r\n }\r\n\r\n /**\r\n * Select a variant given a variant name or a list of variant names.\r\n * @param rootMesh The glTF root mesh\r\n * @param variantName The variant name(s) to select.\r\n */\r\n public selectVariant(rootMesh: Mesh, variantName: string | string[]): void {\r\n return KHR_materials_variants.SelectVariant(rootMesh, variantName);\r\n }\r\n\r\n /**\r\n * Reset back to the original before selecting a variant.\r\n * @param rootMesh The glTF root mesh\r\n */\r\n public static Reset(rootMesh: Mesh): void {\r\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\r\n if (!extensionMetadata) {\r\n throw new Error(`Cannot reset on a glTF mesh that does not have the ${NAME} extension`);\r\n }\r\n\r\n for (const entry of extensionMetadata.original) {\r\n entry.mesh.material = entry.material;\r\n }\r\n\r\n extensionMetadata.lastSelected = null;\r\n }\r\n\r\n /**\r\n * Reset back to the original before selecting a variant.\r\n * @param rootMesh The glTF root mesh\r\n */\r\n public reset(rootMesh: Mesh): void {\r\n return KHR_materials_variants.Reset(rootMesh);\r\n }\r\n\r\n /**\r\n * Gets the last selected variant name(s) or null if original.\r\n * @param rootMesh The glTF root mesh\r\n * @returns The selected variant name(s).\r\n */\r\n public static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]> {\r\n const extensionMetadata = this._GetExtensionMetadata(rootMesh);\r\n if (!extensionMetadata) {\r\n throw new Error(`Cannot get the last selected variant on a glTF mesh that does not have the ${NAME} extension`);\r\n }\r\n\r\n return extensionMetadata.lastSelected;\r\n }\r\n\r\n /**\r\n * Gets the last selected variant name(s) or null if original.\r\n * @param rootMesh The glTF root mesh\r\n * @returns The selected variant name(s).\r\n */\r\n public getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]> {\r\n return KHR_materials_variants.GetLastSelectedVariant(rootMesh);\r\n }\r\n\r\n private static _GetExtensionMetadata(rootMesh: Nullable<Mesh>): Nullable<IExtensionMetadata> {\r\n return rootMesh?._internalMetadata?.gltf?.[NAME] || null;\r\n }\r\n\r\n /** @internal */\r\n public onLoading(): void {\r\n const extensions = this._loader.gltf.extensions;\r\n if (extensions && extensions[this.name]) {\r\n const extension = extensions[this.name] as IKHRMaterialVariants_Variants;\r\n this._variants = extension.variants;\r\n }\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _loadMeshPrimitiveAsync(\r\n context: string,\r\n name: string,\r\n node: INode,\r\n mesh: IMesh,\r\n primitive: IMeshPrimitive,\r\n assign: (babylonMesh: AbstractMesh) => void\r\n ): Nullable<Promise<AbstractMesh>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRMaterialVariants_Mapping, AbstractMesh>(context, primitive, this.name, (extensionContext, extension) => {\r\n const promises = new Array<Promise<any>>();\r\n promises.push(\r\n this._loader._loadMeshPrimitiveAsync(context, name, node, mesh, primitive, (babylonMesh) => {\r\n assign(babylonMesh);\r\n\r\n if (babylonMesh instanceof Mesh) {\r\n const babylonDrawMode = GLTFLoader._GetDrawMode(context, primitive.mode);\r\n\r\n const root = this._loader.rootBabylonMesh;\r\n const metadata = root ? (root._internalMetadata = root._internalMetadata || {}) : {};\r\n const gltf = (metadata.gltf = metadata.gltf || {});\r\n const extensionMetadata: IExtensionMetadata = (gltf[NAME] = gltf[NAME] || { lastSelected: null, original: [], variants: {} });\r\n\r\n // Store the original material.\r\n extensionMetadata.original.push({ mesh: babylonMesh, material: babylonMesh.material });\r\n\r\n // For each mapping, look at the variants and make a new entry for them.\r\n for (let mappingIndex = 0; mappingIndex < extension.mappings.length; ++mappingIndex) {\r\n const mapping = extension.mappings[mappingIndex];\r\n const material = ArrayItem.Get(`${extensionContext}/mappings/${mappingIndex}/material`, this._loader.gltf.materials, mapping.material);\r\n promises.push(\r\n this._loader._loadMaterialAsync(`#/materials/${mapping.material}`, material, babylonMesh, babylonDrawMode, (babylonMaterial) => {\r\n for (let mappingVariantIndex = 0; mappingVariantIndex < mapping.variants.length; ++mappingVariantIndex) {\r\n const variantIndex = mapping.variants[mappingVariantIndex];\r\n const variant = ArrayItem.Get(`/extensions/${NAME}/variants/${variantIndex}`, this._variants, variantIndex);\r\n extensionMetadata.variants[variant.name] = extensionMetadata.variants[variant.name] || [];\r\n extensionMetadata.variants[variant.name].push({\r\n mesh: babylonMesh,\r\n material: babylonMaterial,\r\n });\r\n\r\n // Replace the target when original mesh is cloned\r\n babylonMesh.onClonedObservable.add((newOne: Node) => {\r\n const newMesh = newOne as Mesh;\r\n let metadata: Nullable<IExtensionMetadata> = null;\r\n let newRoot: Nullable<Node> = newMesh;\r\n\r\n // Find root to get medata\r\n do {\r\n newRoot = newRoot!.parent;\r\n if (!newRoot) {\r\n return;\r\n }\r\n metadata = KHR_materials_variants._GetExtensionMetadata(newRoot as Mesh);\r\n } while (metadata === null);\r\n\r\n // Need to clone the metadata on the root (first time only)\r\n if (root && metadata === KHR_materials_variants._GetExtensionMetadata(root)) {\r\n // Copy main metadata\r\n newRoot._internalMetadata = {};\r\n for (const key in root._internalMetadata) {\r\n newRoot._internalMetadata[key] = root._internalMetadata[key];\r\n }\r\n\r\n // Copy the gltf metadata\r\n newRoot._internalMetadata.gltf = [];\r\n for (const key in root._internalMetadata.gltf) {\r\n newRoot._internalMetadata.gltf[key] = root._internalMetadata.gltf[key];\r\n }\r\n\r\n // Duplicate the extension specific metadata\r\n newRoot._internalMetadata.gltf[NAME] = { lastSelected: null, original: [], variants: {} };\r\n for (const original of metadata.original) {\r\n newRoot._internalMetadata.gltf[NAME].original.push({\r\n mesh: original.mesh,\r\n material: original.material,\r\n });\r\n }\r\n for (const key in metadata.variants) {\r\n if (Object.prototype.hasOwnProperty.call(metadata.variants, key)) {\r\n newRoot._internalMetadata.gltf[NAME].variants[key] = [];\r\n for (const variantEntry of metadata.variants[key]) {\r\n newRoot._internalMetadata.gltf[NAME].variants[key].push({\r\n mesh: variantEntry.mesh,\r\n material: variantEntry.material,\r\n });\r\n }\r\n }\r\n }\r\n\r\n metadata = newRoot._internalMetadata.gltf[NAME];\r\n }\r\n\r\n // Relocate\r\n for (const target of metadata!.original) {\r\n if (target.mesh === babylonMesh) {\r\n target.mesh = newMesh;\r\n }\r\n }\r\n for (const target of metadata!.variants[variant.name]) {\r\n if (target.mesh === babylonMesh) {\r\n target.mesh = newMesh;\r\n }\r\n }\r\n });\r\n }\r\n })\r\n );\r\n }\r\n }\r\n })\r\n );\r\n return Promise.all(promises).then(([babylonMesh]) => {\r\n return babylonMesh;\r\n });\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_materials_variants(loader));\r\n"]}
@@ -29,12 +29,11 @@ export class KHR_xmp_json_ld {
29
29
  * Called after the loader state changes to LOADING.
30
30
  */
31
31
  onLoading() {
32
- var _a, _b, _c;
33
32
  if (this._loader.rootBabylonMesh === null) {
34
33
  return;
35
34
  }
36
- const xmp_gltf = (_a = this._loader.gltf.extensions) === null || _a === void 0 ? void 0 : _a.KHR_xmp_json_ld;
37
- const xmp_node = (_c = (_b = this._loader.gltf.asset) === null || _b === void 0 ? void 0 : _b.extensions) === null || _c === void 0 ? void 0 : _c.KHR_xmp_json_ld;
35
+ const xmp_gltf = this._loader.gltf.extensions?.KHR_xmp_json_ld;
36
+ const xmp_node = this._loader.gltf.asset?.extensions?.KHR_xmp_json_ld;
38
37
  if (xmp_gltf && xmp_node) {
39
38
  const packet = +xmp_node.packet;
40
39
  if (xmp_gltf.packets && packet < xmp_gltf.packets.length) {
@@ -1 +1 @@
1
- {"version":3,"file":"KHR_xmp_json_ld.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_xmp_json_ld.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,IAAI,GAAG,iBAAiB,CAAC;AAE/B;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,eAAe;IAkBxB;;OAEG;IACH,YAAY,MAAkB;QApB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QAQf,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,gBAAgB;IACT,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,SAAS;;QACZ,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,KAAK,IAAI,EAAE;YACvC,OAAO;SACV;QAED,MAAM,QAAQ,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,0CAAE,eAAqC,CAAC;QACrF,MAAM,QAAQ,GAAG,MAAA,MAAA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,0CAAE,UAAU,0CAAE,eAAqC,CAAC;QAC5F,IAAI,QAAQ,IAAI,QAAQ,EAAE;YACtB,MAAM,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;YAChC,IAAI,QAAQ,CAAC,OAAO,IAAI,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE;gBACtD,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,IAAI,EAAE,CAAC;gBACpF,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;aACxE;SACJ;IACL,CAAC;CACJ;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRXmpJsonLd_Gltf, IKHRXmpJsonLd_Node } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"KHR_xmp_json_ld\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_xmp_json_ld/README.md)\r\n * @since 5.0.0\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_xmp_json_ld implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 100;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * Called after the loader state changes to LOADING.\r\n */\r\n public onLoading(): void {\r\n if (this._loader.rootBabylonMesh === null) {\r\n return;\r\n }\r\n\r\n const xmp_gltf = this._loader.gltf.extensions?.KHR_xmp_json_ld as IKHRXmpJsonLd_Gltf;\r\n const xmp_node = this._loader.gltf.asset?.extensions?.KHR_xmp_json_ld as IKHRXmpJsonLd_Node;\r\n if (xmp_gltf && xmp_node) {\r\n const packet = +xmp_node.packet;\r\n if (xmp_gltf.packets && packet < xmp_gltf.packets.length) {\r\n this._loader.rootBabylonMesh.metadata = this._loader.rootBabylonMesh.metadata || {};\r\n this._loader.rootBabylonMesh.metadata.xmp = xmp_gltf.packets[packet];\r\n }\r\n }\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_xmp_json_ld(loader));\r\n"]}
1
+ {"version":3,"file":"KHR_xmp_json_ld.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_xmp_json_ld.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,IAAI,GAAG,iBAAiB,CAAC;AAE/B;;;GAGG;AACH,gEAAgE;AAChE,MAAM,OAAO,eAAe;IAkBxB;;OAEG;IACH,YAAY,MAAkB;QApB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QAQf,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,gBAAgB;IACT,OAAO;QACT,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,SAAS;QACZ,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,KAAK,IAAI,EAAE;YACvC,OAAO;SACV;QAED,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,EAAE,eAAqC,CAAC;QACrF,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,eAAqC,CAAC;QAC5F,IAAI,QAAQ,IAAI,QAAQ,EAAE;YACtB,MAAM,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;YAChC,IAAI,QAAQ,CAAC,OAAO,IAAI,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE;gBACtD,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,IAAI,EAAE,CAAC;gBACpF,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,QAAQ,CAAC,GAAG,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;aACxE;SACJ;IACL,CAAC;CACJ;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader } from \"../glTFLoader\";\r\nimport type { IKHRXmpJsonLd_Gltf, IKHRXmpJsonLd_Node } from \"babylonjs-gltf2interface\";\r\n\r\nconst NAME = \"KHR_xmp_json_ld\";\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_xmp_json_ld/README.md)\r\n * @since 5.0.0\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_xmp_json_ld implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines a number that determines the order the extensions are applied.\r\n */\r\n public order = 100;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose() {\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * Called after the loader state changes to LOADING.\r\n */\r\n public onLoading(): void {\r\n if (this._loader.rootBabylonMesh === null) {\r\n return;\r\n }\r\n\r\n const xmp_gltf = this._loader.gltf.extensions?.KHR_xmp_json_ld as IKHRXmpJsonLd_Gltf;\r\n const xmp_node = this._loader.gltf.asset?.extensions?.KHR_xmp_json_ld as IKHRXmpJsonLd_Node;\r\n if (xmp_gltf && xmp_node) {\r\n const packet = +xmp_node.packet;\r\n if (xmp_gltf.packets && packet < xmp_gltf.packets.length) {\r\n this._loader.rootBabylonMesh.metadata = this._loader.rootBabylonMesh.metadata || {};\r\n this._loader.rootBabylonMesh.metadata.xmp = xmp_gltf.packets[packet];\r\n }\r\n }\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_xmp_json_ld(loader));\r\n"]}
@@ -23,9 +23,8 @@ function convertValueWithType(configObject, definition, context) {
23
23
  }
24
24
  }
25
25
  function convertConfiguration(gltfBlock, definition, id) {
26
- var _a;
27
26
  const converted = {};
28
- const configurationList = (_a = gltfBlock.configuration) !== null && _a !== void 0 ? _a : [];
27
+ const configurationList = gltfBlock.configuration ?? [];
29
28
  for (const configObject of configurationList) {
30
29
  if (configObject.id === "customEvent") {
31
30
  const customEvent = definition.customEvents && definition.customEvents[configObject.value];
@@ -83,7 +82,6 @@ function convertBlock(id, gltfBlock, definition) {
83
82
  * @returns a serialized flow graph
84
83
  */
85
84
  export function convertGLTFToSerializedFlowGraph(gltf) {
86
- var _a, _b, _c;
87
85
  // create an empty serialized context to store the values of the connections
88
86
  const context = {
89
87
  uniqueId: RandomGUID(),
@@ -103,7 +101,7 @@ export function convertGLTFToSerializedFlowGraph(gltf) {
103
101
  const gltfBlock = gltf.nodes[i];
104
102
  // get the block that was created in the previous step
105
103
  const fgBlock = flowGraphJsonBlocks[i];
106
- const gltfFlows = (_a = gltfBlock.flows) !== null && _a !== void 0 ? _a : [];
104
+ const gltfFlows = gltfBlock.flows ?? [];
107
105
  // for each output flow of the gltf block
108
106
  for (const flow of gltfFlows) {
109
107
  const socketOutName = flow.id;
@@ -140,7 +138,7 @@ export function convertGLTFToSerializedFlowGraph(gltf) {
140
138
  socketOut.connectedPointIds.push(socketIn.uniqueId);
141
139
  }
142
140
  // for each input value of the gltf block
143
- const gltfValues = (_b = gltfBlock.values) !== null && _b !== void 0 ? _b : [];
141
+ const gltfValues = gltfBlock.values ?? [];
144
142
  for (const value of gltfValues) {
145
143
  const socketInName = value.id;
146
144
  // create an input data connection for the flow graph block
@@ -186,7 +184,7 @@ export function convertGLTFToSerializedFlowGraph(gltf) {
186
184
  }
187
185
  }
188
186
  }
189
- const variables = (_c = gltf.variables) !== null && _c !== void 0 ? _c : [];
187
+ const variables = gltf.variables ?? [];
190
188
  // Parse variables
191
189
  for (let i = 0; i < variables.length; i++) {
192
190
  const variable = variables[i];
@@ -1 +1 @@
1
- {"version":3,"file":"interactivityFunctions.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/interactivityFunctions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,qCAAuB;AAC5C,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AACrF,OAAO,EAAE,uBAAuB,EAAE,yDAA2C;AAE7E,SAAS,oBAAoB,CAAC,YAA6C,EAAE,UAA6B,EAAE,OAAe;IACvH,IAAI,YAAY,CAAC,IAAI,KAAK,SAAS,EAAE;QACjC,sCAAsC;QACtC,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,IAAI,UAAU,CAAC,K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AE,iBAAiB;wBACvB,eAAe,EAAE,uBAAuB,CAAC,MAAM;wBAC/C,iBAAiB,EAAE,EAAE;qBACxB,CAAC;oBACF,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;iBACvC;gBACD,sBAAsB;gBACtB,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;gBACpD,SAAS,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;aACvD;iBAAM;gBACH,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,oBAAoB,YAAY,YAAY,CAAC,EAAE,CAAC,CAAC;aAC5G;SACJ;KACJ;IAED,MAAM,SAAS,GAAG,MAAA,IAAI,CAAC,SAAS,mCAAI,EAAE,CAAC;IACvC,kBAAkB;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,MAAM,QAAQ,GAA+B,SAAS,CAAC,CAAC,CAAC,CAAC;QAC1D,MAAM,YAAY,GAAG,QAAQ,CAAC,EAAE,CAAC;QACjC,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,GAAG,oBAAoB,CAAC,QAA2C,EAAE,IAAI,EAAE,2CAA2C,CAAC,EAAE,CAAC,CAAC;KAClK;IAED,OAAO;QACH,SAAS,EAAE,mBAAmB;QAC9B,iBAAiB;KACpB,CAAC;AACN,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { IKHRInteractivity, IKHRInteractivity_Configuration, IKHRInteractivity_Node, IKHRInteractivity_Variable } from \"babylonjs-gltf2interface\";\r\nimport type { IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\r\nimport type { ISerializedFlowGraph, ISerializedFlowGraphBlock, ISerializedFlowGraphConnection, ISerializedFlowGraphContext } from \"core/FlowGraph/typeDefinitions\";\r\nimport { RandomGUID } from \"core/Misc/guid\";\r\nimport { gltfToFlowGraphTypeMap, gltfTypeToBabylonType } from \"./interactivityUtils\";\r\nimport { FlowGraphConnectionType } from \"core/FlowGraph/flowGraphConnection\";\r\n\r\nfunction convertValueWithType(configObject: IKHRInteractivity_Configuration, definition: IKHRInteractivity, context: string) {\r\n if (configObject.type !== undefined) {\r\n // get the type on the gltf definition\r\n const type = definition.types && definition.types[configObject.type];\r\n if (!type) {\r\n throw new Error(`${context}: Unknown type: ${configObject.type}`);\r\n }\r\n const signature = type.signature;\r\n if (!signature) {\r\n throw new Error(`${context}: Type ${configObject.type} has no signature`);\r\n }\r\n const convertedType = gltfTypeToBabylonType[signature];\r\n return {\r\n value: configObject.value,\r\n className: convertedType,\r\n };\r\n } else {\r\n return configObject.value;\r\n }\r\n}\r\n\r\nfunction convertConfiguration(gltfBlock: IKHRInteractivity_Node, definition: IKHRInteractivity, id: string): IFlowGraphBlockConfiguration {\r\n const converted: IFlowGraphBlockConfiguration = {};\r\n const configurationList: IKHRInteractivity_Configuration[] = gltfBlock.configuration ?? [];\r\n for (const configObject of configurationList) {\r\n if (configObject.id === \"customEvent\") {\r\n const customEvent = definition.customEvents && definition.customEvents[configObject.value];\r\n if (!customEvent) {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown custom event: ${configObject.value}`);\r\n }\r\n converted.eventId = customEvent.id;\r\n converted.eventData = customEvent.values.map((v) => v.id);\r\n } else if (configObject.id === \"variable\") {\r\n const variable = definition.variables && definition.variables[configObject.value];\r\n if (!variable) {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown variable: ${configObject.value}`);\r\n }\r\n converted.variableName = variable.id;\r\n } else if (configObject.id === \"path\") {\r\n // Convert from a GLTF path to a reference to the Babylon.js object\r\n const pathValue = configObject.value as string;\r\n converted.path = pathValue;\r\n } else {\r\n converted[configObject.id] = convertValueWithType(configObject, definition, `/extensions/KHR_interactivity/nodes/${id}`);\r\n }\r\n }\r\n return converted;\r\n}\r\n\r\nfunction convertBlock(id: number, gltfBlock: IKHRInteractivity_Node, definition: IKHRInteractivity): ISerializedFlowGraphBlock {\r\n const className = gltfToFlowGraphTypeMap[gltfBlock.type];\r\n if (!className) {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown block type: ${gltfBlock.type}`);\r\n }\r\n const uniqueId = id.toString();\r\n const config = convertConfiguration(gltfBlock, definition, uniqueId);\r\n const metadata = gltfBlock.metadata;\r\n const dataInputs: ISerializedFlowGraphConnection[] = [];\r\n const dataOutputs: ISerializedFlowGraphConnection[] = [];\r\n const signalInputs: ISerializedFlowGraphConnection[] = [];\r\n const signalOutputs: ISerializedFlowGraphConnection[] = [];\r\n return {\r\n className,\r\n config,\r\n uniqueId,\r\n metadata,\r\n dataInputs,\r\n dataOutputs,\r\n signalInputs,\r\n signalOutputs,\r\n };\r\n}\r\n\r\n/**\r\n * @internal\r\n * Converts a glTF Interactivity Extension to a serialized flow graph.\r\n * @param gltf the interactivity data\r\n * @returns a serialized flow graph\r\n */\r\nexport function convertGLTFToSerializedFlowGraph(gltf: IKHRInteractivity): ISerializedFlowGraph {\r\n // create an empty serialized context to store the values of the connections\r\n const context: ISerializedFlowGraphContext = {\r\n uniqueId: RandomGUID(),\r\n _userVariables: {},\r\n _connectionValues: {},\r\n };\r\n const executionContexts = [context];\r\n\r\n // Blocks converted to the flow graph json format\r\n const flowGraphJsonBlocks: ISerializedFlowGraphBlock[] = [];\r\n\r\n for (let i = 0; i < gltf.nodes.length; i++) {\r\n const gltfBlock = gltf.nodes[i];\r\n const flowGraphJsonBlock = convertBlock(i, gltfBlock, gltf);\r\n flowGraphJsonBlocks.push(flowGraphJsonBlock);\r\n }\r\n\r\n // Parse the connections\r\n for (let i = 0; i < gltf.nodes.length; i++) {\r\n const gltfBlock = gltf.nodes[i];\r\n // get the block that was created in the previous step\r\n const fgBlock = flowGraphJsonBlocks[i];\r\n const gltfFlows = gltfBlock.flows ?? [];\r\n // for each output flow of the gltf block\r\n for (const flow of gltfFlows) {\r\n const socketOutName = flow.id;\r\n // create an output connection for the flow graph block\r\n const socketOut: ISerializedFlowGraphConnection = {\r\n uniqueId: RandomGUID(),\r\n name: socketOutName,\r\n _connectionType: FlowGraphConnectionType.Output, // Output\r\n connectedPointIds: [],\r\n };\r\n fgBlock.signalOutputs.push(socketOut);\r\n // get the input node of this flow\r\n const nodeInId = flow.node;\r\n const nodeInSocketName = flow.socket;\r\n // find the corresponding flow graph node\r\n const nodeIn = flowGraphJsonBlocks[nodeInId];\r\n if (!nodeIn) {\r\n throw new Error(\r\n `/extensions/KHR_interactivity/nodes/${i}: Could not find node with id ${nodeInId} that connects its input with with node ${i}'s output ${socketOutName}`\r\n );\r\n }\r\n // in all of the flow graph input connections, find the one with the same name as the socket\r\n let socketIn = nodeIn.signalInputs.find((s) => s.name === nodeInSocketName);\r\n // if the socket doesn't exist, create the input socket for the connection\r\n if (!socketIn) {\r\n socketIn = {\r\n uniqueId: RandomGUID(),\r\n name: nodeInSocketName,\r\n _connectionType: FlowGraphConnectionType.Input, // Input\r\n connectedPointIds: [],\r\n };\r\n nodeIn.signalInputs.push(socketIn);\r\n }\r\n // connect the sockets\r\n socketIn.connectedPointIds.push(socketOut.uniqueId);\r\n socketOut.connectedPointIds.push(socketIn.uniqueId);\r\n }\r\n // for each input value of the gltf block\r\n const gltfValues = gltfBlock.values ?? [];\r\n for (const value of gltfValues) {\r\n const socketInName = value.id;\r\n // create an input data connection for the flow graph block\r\n const socketIn: ISerializedFlowGraphConnection = {\r\n uniqueId: RandomGUID(),\r\n name: socketInName,\r\n _connectionType: FlowGraphConnectionType.Input,\r\n connectedPointIds: [],\r\n };\r\n fgBlock.dataInputs.push(socketIn);\r\n if (value.value !== undefined) {\r\n // if the value is set on the socket itself, store it in the context\r\n const convertedValue = convertValueWithType(value as IKHRInteractivity_Configuration, gltf, `/extensions/KHR_interactivity/nodes/${i}`);\r\n // convertBlockInputType(gltfBlock, value, convertedValue, `/extensions/KHR_interactivity/nodes/${i}`);\r\n context._connectionValues[socketIn.uniqueId] = convertedValue;\r\n } else if (value.node !== undefined && value.socket !== undefined) {\r\n // if the value is connected with the output data of another socket, connect the two\r\n const nodeOutId = value.node;\r\n const nodeOutSocketName = value.socket;\r\n // find the flow graph node that owns that output socket\r\n const nodeOut = flowGraphJsonBlocks[nodeOutId];\r\n if (!nodeOut) {\r\n throw new Error(\r\n `/extensions/KHR_interactivity/nodes/${i}: Could not find node with id ${nodeOutId} that connects its output with node${i}'s input ${socketInName}`\r\n );\r\n }\r\n let socketOut = nodeOut.dataOutputs.find((s) => s.name === nodeOutSocketName);\r\n // if the socket doesn't exist, create it\r\n if (!socketOut) {\r\n socketOut = {\r\n uniqueId: RandomGUID(),\r\n name: nodeOutSocketName,\r\n _connectionType: FlowGraphConnectionType.Output,\r\n connectedPointIds: [],\r\n };\r\n nodeOut.dataOutputs.push(socketOut);\r\n }\r\n // connect the sockets\r\n socketIn.connectedPointIds.push(socketOut.uniqueId);\r\n socketOut.connectedPointIds.push(socketIn.uniqueId);\r\n } else {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${i}: Invalid socket ${socketInName} in node ${i}`);\r\n }\r\n }\r\n }\r\n\r\n const variables = gltf.variables ?? [];\r\n // Parse variables\r\n for (let i = 0; i < variables.length; i++) {\r\n const variable: IKHRInteractivity_Variable = variables[i];\r\n const variableName = variable.id;\r\n context._userVariables[variableName] = convertValueWithType(variable as IKHRInteractivity_Configuration, gltf, `/extensions/KHR_interactivity/variables/${i}`);\r\n }\r\n\r\n return {\r\n allBlocks: flowGraphJsonBlocks,\r\n executionContexts,\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"interactivityFunctions.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/interactivityFunctions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,qCAAuB;AAC5C,OAAO,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,MAAM,s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,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,iBAAiB,CAAC,CAAC;gBAC9E,yCAAyC;gBACzC,IAAI,CAAC,SAAS,EAAE;oBACZ,SAAS,GAAG;wBACR,QAAQ,EAAE,UAAU,EAAE;wBACtB,IAAI,EAAE,iBAAiB;wBACvB,eAAe,EAAE,uBAAuB,CAAC,MAAM;wBAC/C,iBAAiB,EAAE,EAAE;qBACxB,CAAC;oBACF,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;iBACvC;gBACD,sBAAsB;gBACtB,QAAQ,CAAC,iBAAiB,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;gBACpD,SAAS,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;aACvD;iBAAM;gBACH,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,oBAAoB,YAAY,YAAY,CAAC,EAAE,CAAC,CAAC;aAC5G;SACJ;KACJ;IAED,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC;IACvC,kBAAkB;IAClB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,MAAM,QAAQ,GAA+B,SAAS,CAAC,CAAC,CAAC,CAAC;QAC1D,MAAM,YAAY,GAAG,QAAQ,CAAC,EAAE,CAAC;QACjC,OAAO,CAAC,cAAc,CAAC,YAAY,CAAC,GAAG,oBAAoB,CAAC,QAA2C,EAAE,IAAI,EAAE,2CAA2C,CAAC,EAAE,CAAC,CAAC;KAClK;IAED,OAAO;QACH,SAAS,EAAE,mBAAmB;QAC9B,iBAAiB;KACpB,CAAC;AACN,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { IKHRInteractivity, IKHRInteractivity_Configuration, IKHRInteractivity_Node, IKHRInteractivity_Variable } from \"babylonjs-gltf2interface\";\r\nimport type { IFlowGraphBlockConfiguration } from \"core/FlowGraph/flowGraphBlock\";\r\nimport type { ISerializedFlowGraph, ISerializedFlowGraphBlock, ISerializedFlowGraphConnection, ISerializedFlowGraphContext } from \"core/FlowGraph/typeDefinitions\";\r\nimport { RandomGUID } from \"core/Misc/guid\";\r\nimport { gltfToFlowGraphTypeMap, gltfTypeToBabylonType } from \"./interactivityUtils\";\r\nimport { FlowGraphConnectionType } from \"core/FlowGraph/flowGraphConnection\";\r\n\r\nfunction convertValueWithType(configObject: IKHRInteractivity_Configuration, definition: IKHRInteractivity, context: string) {\r\n if (configObject.type !== undefined) {\r\n // get the type on the gltf definition\r\n const type = definition.types && definition.types[configObject.type];\r\n if (!type) {\r\n throw new Error(`${context}: Unknown type: ${configObject.type}`);\r\n }\r\n const signature = type.signature;\r\n if (!signature) {\r\n throw new Error(`${context}: Type ${configObject.type} has no signature`);\r\n }\r\n const convertedType = gltfTypeToBabylonType[signature];\r\n return {\r\n value: configObject.value,\r\n className: convertedType,\r\n };\r\n } else {\r\n return configObject.value;\r\n }\r\n}\r\n\r\nfunction convertConfiguration(gltfBlock: IKHRInteractivity_Node, definition: IKHRInteractivity, id: string): IFlowGraphBlockConfiguration {\r\n const converted: IFlowGraphBlockConfiguration = {};\r\n const configurationList: IKHRInteractivity_Configuration[] = gltfBlock.configuration ?? [];\r\n for (const configObject of configurationList) {\r\n if (configObject.id === \"customEvent\") {\r\n const customEvent = definition.customEvents && definition.customEvents[configObject.value];\r\n if (!customEvent) {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown custom event: ${configObject.value}`);\r\n }\r\n converted.eventId = customEvent.id;\r\n converted.eventData = customEvent.values.map((v) => v.id);\r\n } else if (configObject.id === \"variable\") {\r\n const variable = definition.variables && definition.variables[configObject.value];\r\n if (!variable) {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown variable: ${configObject.value}`);\r\n }\r\n converted.variableName = variable.id;\r\n } else if (configObject.id === \"path\") {\r\n // Convert from a GLTF path to a reference to the Babylon.js object\r\n const pathValue = configObject.value as string;\r\n converted.path = pathValue;\r\n } else {\r\n converted[configObject.id] = convertValueWithType(configObject, definition, `/extensions/KHR_interactivity/nodes/${id}`);\r\n }\r\n }\r\n return converted;\r\n}\r\n\r\nfunction convertBlock(id: number, gltfBlock: IKHRInteractivity_Node, definition: IKHRInteractivity): ISerializedFlowGraphBlock {\r\n const className = gltfToFlowGraphTypeMap[gltfBlock.type];\r\n if (!className) {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${id}: Unknown block type: ${gltfBlock.type}`);\r\n }\r\n const uniqueId = id.toString();\r\n const config = convertConfiguration(gltfBlock, definition, uniqueId);\r\n const metadata = gltfBlock.metadata;\r\n const dataInputs: ISerializedFlowGraphConnection[] = [];\r\n const dataOutputs: ISerializedFlowGraphConnection[] = [];\r\n const signalInputs: ISerializedFlowGraphConnection[] = [];\r\n const signalOutputs: ISerializedFlowGraphConnection[] = [];\r\n return {\r\n className,\r\n config,\r\n uniqueId,\r\n metadata,\r\n dataInputs,\r\n dataOutputs,\r\n signalInputs,\r\n signalOutputs,\r\n };\r\n}\r\n\r\n/**\r\n * @internal\r\n * Converts a glTF Interactivity Extension to a serialized flow graph.\r\n * @param gltf the interactivity data\r\n * @returns a serialized flow graph\r\n */\r\nexport function convertGLTFToSerializedFlowGraph(gltf: IKHRInteractivity): ISerializedFlowGraph {\r\n // create an empty serialized context to store the values of the connections\r\n const context: ISerializedFlowGraphContext = {\r\n uniqueId: RandomGUID(),\r\n _userVariables: {},\r\n _connectionValues: {},\r\n };\r\n const executionContexts = [context];\r\n\r\n // Blocks converted to the flow graph json format\r\n const flowGraphJsonBlocks: ISerializedFlowGraphBlock[] = [];\r\n\r\n for (let i = 0; i < gltf.nodes.length; i++) {\r\n const gltfBlock = gltf.nodes[i];\r\n const flowGraphJsonBlock = convertBlock(i, gltfBlock, gltf);\r\n flowGraphJsonBlocks.push(flowGraphJsonBlock);\r\n }\r\n\r\n // Parse the connections\r\n for (let i = 0; i < gltf.nodes.length; i++) {\r\n const gltfBlock = gltf.nodes[i];\r\n // get the block that was created in the previous step\r\n const fgBlock = flowGraphJsonBlocks[i];\r\n const gltfFlows = gltfBlock.flows ?? [];\r\n // for each output flow of the gltf block\r\n for (const flow of gltfFlows) {\r\n const socketOutName = flow.id;\r\n // create an output connection for the flow graph block\r\n const socketOut: ISerializedFlowGraphConnection = {\r\n uniqueId: RandomGUID(),\r\n name: socketOutName,\r\n _connectionType: FlowGraphConnectionType.Output, // Output\r\n connectedPointIds: [],\r\n };\r\n fgBlock.signalOutputs.push(socketOut);\r\n // get the input node of this flow\r\n const nodeInId = flow.node;\r\n const nodeInSocketName = flow.socket;\r\n // find the corresponding flow graph node\r\n const nodeIn = flowGraphJsonBlocks[nodeInId];\r\n if (!nodeIn) {\r\n throw new Error(\r\n `/extensions/KHR_interactivity/nodes/${i}: Could not find node with id ${nodeInId} that connects its input with with node ${i}'s output ${socketOutName}`\r\n );\r\n }\r\n // in all of the flow graph input connections, find the one with the same name as the socket\r\n let socketIn = nodeIn.signalInputs.find((s) => s.name === nodeInSocketName);\r\n // if the socket doesn't exist, create the input socket for the connection\r\n if (!socketIn) {\r\n socketIn = {\r\n uniqueId: RandomGUID(),\r\n name: nodeInSocketName,\r\n _connectionType: FlowGraphConnectionType.Input, // Input\r\n connectedPointIds: [],\r\n };\r\n nodeIn.signalInputs.push(socketIn);\r\n }\r\n // connect the sockets\r\n socketIn.connectedPointIds.push(socketOut.uniqueId);\r\n socketOut.connectedPointIds.push(socketIn.uniqueId);\r\n }\r\n // for each input value of the gltf block\r\n const gltfValues = gltfBlock.values ?? [];\r\n for (const value of gltfValues) {\r\n const socketInName = value.id;\r\n // create an input data connection for the flow graph block\r\n const socketIn: ISerializedFlowGraphConnection = {\r\n uniqueId: RandomGUID(),\r\n name: socketInName,\r\n _connectionType: FlowGraphConnectionType.Input,\r\n connectedPointIds: [],\r\n };\r\n fgBlock.dataInputs.push(socketIn);\r\n if (value.value !== undefined) {\r\n // if the value is set on the socket itself, store it in the context\r\n const convertedValue = convertValueWithType(value as IKHRInteractivity_Configuration, gltf, `/extensions/KHR_interactivity/nodes/${i}`);\r\n // convertBlockInputType(gltfBlock, value, convertedValue, `/extensions/KHR_interactivity/nodes/${i}`);\r\n context._connectionValues[socketIn.uniqueId] = convertedValue;\r\n } else if (value.node !== undefined && value.socket !== undefined) {\r\n // if the value is connected with the output data of another socket, connect the two\r\n const nodeOutId = value.node;\r\n const nodeOutSocketName = value.socket;\r\n // find the flow graph node that owns that output socket\r\n const nodeOut = flowGraphJsonBlocks[nodeOutId];\r\n if (!nodeOut) {\r\n throw new Error(\r\n `/extensions/KHR_interactivity/nodes/${i}: Could not find node with id ${nodeOutId} that connects its output with node${i}'s input ${socketInName}`\r\n );\r\n }\r\n let socketOut = nodeOut.dataOutputs.find((s) => s.name === nodeOutSocketName);\r\n // if the socket doesn't exist, create it\r\n if (!socketOut) {\r\n socketOut = {\r\n uniqueId: RandomGUID(),\r\n name: nodeOutSocketName,\r\n _connectionType: FlowGraphConnectionType.Output,\r\n connectedPointIds: [],\r\n };\r\n nodeOut.dataOutputs.push(socketOut);\r\n }\r\n // connect the sockets\r\n socketIn.connectedPointIds.push(socketOut.uniqueId);\r\n socketOut.connectedPointIds.push(socketIn.uniqueId);\r\n } else {\r\n throw new Error(`/extensions/KHR_interactivity/nodes/${i}: Invalid socket ${socketInName} in node ${i}`);\r\n }\r\n }\r\n }\r\n\r\n const variables = gltf.variables ?? [];\r\n // Parse variables\r\n for (let i = 0; i < variables.length; i++) {\r\n const variable: IKHRInteractivity_Variable = variables[i];\r\n const variableName = variable.id;\r\n context._userVariables[variableName] = convertValueWithType(variable as IKHRInteractivity_Configuration, gltf, `/extensions/KHR_interactivity/variables/${i}`);\r\n }\r\n\r\n return {\r\n allBlocks: flowGraphJsonBlocks,\r\n executionContexts,\r\n };\r\n}\r\n"]}
@@ -8,7 +8,7 @@ import { FlowGraphReceiveCustomEventBlock } from "@babylonjs/core/FlowGraph/Bloc
8
8
  import { FlowGraphSequenceBlock } from "@babylonjs/core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock.js";
9
9
  import { FlowGraphGetPropertyBlock } from "@babylonjs/core/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock.js";
10
10
  import { FlowGraphSetPropertyBlock } from "@babylonjs/core/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock.js";
11
- import { FlowGraphAddBlock, FlowGraphRandomBlock, FlowGraphLessThanBlock, FlowGraphMultiplyBlock, FlowGraphSubtractBlock, FlowGraphDotBlock, FlowGraphEBlock, FlowGraphPiBlock, FlowGraphInfBlock, FlowGraphNaNBlock, FlowGraphAbsBlock, FlowGraphSignBlock, FlowGraphTruncBlock, FlowGraphFloorBlock, FlowGraphCeilBlock, FlowGraphFractBlock, FlowGraphNegBlock, FlowGraphDivideBlock, FlowGraphRemainderBlock, FlowGraphMinBlock, FlowGraphMaxBlock, FlowGraphClampBlock, FlowGraphSaturateBlock, FlowGraphInterpolateBlock, FlowGraphEqBlock, FlowGraphLessThanOrEqualBlock, FlowGraphGreaterThanBlock, FlowGraphGreaterThanOrEqualBlock, FlowGraphIsNanBlock, FlowGraphIsInfBlock, FlowGraphDegToRadBlock, FlowGraphRadToDegBlock, FlowGraphSinBlock, FlowGraphCosBlock, FlowGraphTanBlock, FlowGraphAsinBlock, FlowGraphAcosBlock, FlowGraphAtanBlock, FlowGraphAtan2Block, FlowGraphSinhBlock, FlowGraphCoshBlock, FlowGraphTanhBlock, FlowGraphAsinhBlock, FlowGraphAcoshBlock, FlowGraphAtanhBlock, FlowGraphExpBlock, FlowGraphLog2Block, FlowGraphLogBlock, FlowGraphLog10Block, FlowGraphSqrtBlock, FlowGraphCubeRootBlock, FlowGraphPowBlock, FlowGraphLengthBlock, FlowGraphNormalizeBlock, FlowGraphCrossBlock, FlowGraphRotate2DBlock, FlowGraphRotate3DBlock, } from "@babylonjs/core/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js";
11
+ import { FlowGraphAddBlock, FlowGraphRandomBlock, FlowGraphLessThanBlock, FlowGraphMultiplyBlock, FlowGraphSubtractBlock, FlowGraphDotBlock, FlowGraphEBlock, FlowGraphPiBlock, FlowGraphInfBlock, FlowGraphNaNBlock, FlowGraphAbsBlock, FlowGraphSignBlock, FlowGraphTruncBlock, FlowGraphFloorBlock, FlowGraphCeilBlock, FlowGraphFractBlock, FlowGraphNegBlock, FlowGraphDivideBlock, FlowGraphRemainderBlock, FlowGraphMinBlock, FlowGraphMaxBlock, FlowGraphClampBlock, FlowGraphSaturateBlock, FlowGraphInterpolateBlock, FlowGraphEqBlock, FlowGraphLessThanOrEqualBlock, FlowGraphGreaterThanBlock, FlowGraphGreaterThanOrEqualBlock, FlowGraphIsNanBlock, FlowGraphIsInfBlock, FlowGraphDegToRadBlock, FlowGraphRadToDegBlock, FlowGraphSinBlock, FlowGraphCosBlock, FlowGraphTanBlock, FlowGraphAsinBlock, FlowGraphAcosBlock, FlowGraphAtanBlock, FlowGraphAtan2Block, FlowGraphSinhBlock, FlowGraphCoshBlock, FlowGraphTanhBlock, FlowGraphAsinhBlock, FlowGraphAcoshBlock, FlowGraphAtanhBlock, FlowGraphExpBlock, FlowGraphLog2Block, FlowGraphLogBlock, FlowGraphLog10Block, FlowGraphSqrtBlock, FlowGraphCubeRootBlock, FlowGraphPowBlock, FlowGraphLengthBlock, FlowGraphNormalizeBlock, FlowGraphCrossBlock, FlowGraphRotate2DBlock, FlowGraphRotate3DBlock, FlowGraphTransposeBlock, FlowGraphDeterminantBlock, FlowGraphInvertMatrixBlock, FlowGraphMatMulBlock, FlowGraphBitwiseNotBlock, FlowGraphBitwiseAndBlock, FlowGraphBitwiseOrBlock, FlowGraphBitwiseXorBlock, FlowGraphBitwiseRightShiftBlock, FlowGraphBitwiseLeftShiftBlock, FlowGraphCountLeadingZerosBlock, FlowGraphCountTrailingZerosBlock, FlowGraphCountOneBitsBlock, } from "@babylonjs/core/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks.js";
12
12
  import { FlowGraphDoNBlock } from "@babylonjs/core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock.js";
13
13
  import { FlowGraphGetVariableBlock } from "@babylonjs/core/FlowGraph/Blocks/Data/flowGraphGetVariableBlock.js";
14
14
  import { FlowGraphSetVariableBlock } from "@babylonjs/core/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock.js";
@@ -84,10 +84,25 @@ export const gltfToFlowGraphTypeMap = {
84
84
  "math/cross": FlowGraphCrossBlock.ClassName,
85
85
  "math/rotate2d": FlowGraphRotate2DBlock.ClassName,
86
86
  "math/rotate3d": FlowGraphRotate3DBlock.ClassName,
87
+ "math/transpose": FlowGraphTransposeBlock.ClassName,
88
+ "math/determinant": FlowGraphDeterminantBlock.ClassName,
89
+ "math/inverse": FlowGraphInvertMatrixBlock.ClassName,
90
+ "math/matmul": FlowGraphMatMulBlock.ClassName,
91
+ "math/not": FlowGraphBitwiseNotBlock.ClassName,
92
+ "math/and": FlowGraphBitwiseAndBlock.ClassName,
93
+ "math/or": FlowGraphBitwiseOrBlock.ClassName,
94
+ "math/xor": FlowGraphBitwiseXorBlock.ClassName,
95
+ "math/asr": FlowGraphBitwiseRightShiftBlock.ClassName,
96
+ "math/lsl": FlowGraphBitwiseLeftShiftBlock.ClassName,
97
+ "math/clz": FlowGraphCountLeadingZerosBlock.ClassName,
98
+ "math/ctz": FlowGraphCountTrailingZerosBlock.ClassName,
99
+ "math/popcnt": FlowGraphCountOneBitsBlock.ClassName,
87
100
  };
88
101
  export const gltfTypeToBabylonType = {
89
102
  float2: "Vector2",
90
103
  float3: "Vector3",
91
104
  float4: "Vector4",
105
+ float4x4: "Matrix",
106
+ int: "FlowGraphInteger",
92
107
  };
93
108
  //# sourceMappingURL=interactivityUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interactivityUtils.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/interactivityUtils.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,6BAA6B,EAAE,gFAAkE;AAC1G,OAAO,EAAE,4BAA4B,EAAE,+EAAiE;AACxG,OAAO,EAAE,wBAAwB,EAAE,+EAAiE;AACpG,OAAO,EAAE,mBAAmB,EAAE,sFAAwE;AACtG,OAAO,EAAE,6BAA6B,EAAE,oFAAsE;AAC9G,OAAO,EAAE,gCAAgC,EAAE,mFAAqE;AAChH,OAAO,EAAE,sBAAsB,EAAE,yFAA2E;AAC5G,OAAO,EAAE,yBAAyB,EAAE,2EAA6D;AACjG,OAAO,EAAE,yBAAyB,EAAE,gFAAkE;AACtG,OAAO,EACH,iBAAiB,EACjB,oBAAoB,EACpB,sBAAsB,EACtB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,sBAAsB,EACtB,yBAAyB,EACzB,gBAAgB,EAChB,6BAA6B,EAC7B,yBAAyB,EACzB,gCAAgC,EAChC,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,iBAAiB,EACjB,o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mB,CAAC,SAAS;IAC3C,YAAY,EAAE,mBAAmB,CAAC,SAAS;IAC3C,UAAU,EAAE,iBAAiB,CAAC,SAAS;IACvC,UAAU,EAAE,iBAAiB,CAAC,SAAS;IACvC,WAAW,EAAE,kBAAkB,CAAC,SAAS;IACzC,YAAY,EAAE,mBAAmB,CAAC,SAAS;IAC3C,WAAW,EAAE,kBAAkB,CAAC,SAAS;IACzC,WAAW,EAAE,sBAAsB,CAAC,SAAS;IAC7C,UAAU,EAAE,iBAAiB,CAAC,SAAS;IACvC,aAAa,EAAE,oBAAoB,CAAC,SAAS;IAC7C,gBAAgB,EAAE,uBAAuB,CAAC,SAAS;IACnD,UAAU,EAAE,iBAAiB,CAAC,SAAS;IACvC,YAAY,EAAE,mBAAmB,CAAC,SAAS;IAC3C,eAAe,EAAE,sBAAsB,CAAC,SAAS;IACjD,eAAe,EAAE,sBAAsB,CAAC,SAAS;CACpD,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAQ;IACtC,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;CACpB,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { FlowGraphSceneReadyEventBlock } from \"core/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock\";\r\nimport { FlowGraphSceneTickEventBlock } from \"core/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock\";\r\nimport { FlowGraphConsoleLogBlock } from \"core/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock\";\r\nimport { FlowGraphTimerBlock } from \"core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock\";\r\nimport { FlowGraphSendCustomEventBlock } from \"core/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock\";\r\nimport { FlowGraphReceiveCustomEventBlock } from \"core/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock\";\r\nimport { FlowGraphSequenceBlock } from \"core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock\";\r\nimport { FlowGraphGetPropertyBlock } from \"core/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock\";\r\nimport { FlowGraphSetPropertyBlock } from \"core/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock\";\r\nimport {\r\n FlowGraphAddBlock,\r\n FlowGraphRandomBlock,\r\n FlowGraphLessThanBlock,\r\n FlowGraphMultiplyBlock,\r\n FlowGraphSubtractBlock,\r\n FlowGraphDotBlock,\r\n FlowGraphEBlock,\r\n FlowGraphPiBlock,\r\n FlowGraphInfBlock,\r\n FlowGraphNaNBlock,\r\n FlowGraphAbsBlock,\r\n FlowGraphSignBlock,\r\n FlowGraphTruncBlock,\r\n FlowGraphFloorBlock,\r\n FlowGraphCeilBlock,\r\n FlowGraphFractBlock,\r\n FlowGraphNegBlock,\r\n FlowGraphDivideBlock,\r\n FlowGraphRemainderBlock,\r\n FlowGraphMinBlock,\r\n FlowGraphMaxBlock,\r\n FlowGraphClampBlock,\r\n FlowGraphSaturateBlock,\r\n FlowGraphInterpolateBlock,\r\n FlowGraphEqBlock,\r\n FlowGraphLessThanOrEqualBlock,\r\n FlowGraphGreaterThanBlock,\r\n FlowGraphGreaterThanOrEqualBlock,\r\n FlowGraphIsNanBlock,\r\n FlowGraphIsInfBlock,\r\n FlowGraphDegToRadBlock,\r\n FlowGraphRadToDegBlock,\r\n FlowGraphSinBlock,\r\n FlowGraphCosBlock,\r\n FlowGraphTanBlock,\r\n FlowGraphAsinBlock,\r\n FlowGraphAcosBlock,\r\n FlowGraphAtanBlock,\r\n FlowGraphAtan2Block,\r\n FlowGraphSinhBlock,\r\n FlowGraphCoshBlock,\r\n FlowGraphTanhBlock,\r\n FlowGraphAsinhBlock,\r\n FlowGraphAcoshBlock,\r\n FlowGraphAtanhBlock,\r\n FlowGraphExpBlock,\r\n FlowGraphLog2Block,\r\n FlowGraphLogBlock,\r\n FlowGraphLog10Block,\r\n FlowGraphSqrtBlock,\r\n FlowGraphCubeRootBlock,\r\n FlowGraphPowBlock,\r\n FlowGraphLengthBlock,\r\n FlowGraphNormalizeBlock,\r\n FlowGraphCrossBlock,\r\n FlowGraphRotate2DBlock,\r\n FlowGraphRotate3DBlock,\r\n} from \"core/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks\";\r\nimport { FlowGraphDoNBlock } from \"core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock\";\r\nimport { FlowGraphGetVariableBlock } from \"core/FlowGraph/Blocks/Data/flowGraphGetVariableBlock\";\r\nimport { FlowGraphSetVariableBlock } from \"core/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock\";\r\nimport { FlowGraphWhileLoopBlock } from \"core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock\";\r\n\r\nexport const gltfToFlowGraphTypeMap: { [key: string]: string } = {\r\n \"lifecycle/onStart\": FlowGraphSceneReadyEventBlock.ClassName,\r\n \"lifecycle/onTick\": FlowGraphSceneTickEventBlock.ClassName,\r\n log: FlowGraphConsoleLogBlock.ClassName,\r\n \"flow/delay\": FlowGraphTimerBlock.ClassName,\r\n \"customEvent/send\": FlowGraphSendCustomEventBlock.ClassName,\r\n \"customEvent/receive\": FlowGraphReceiveCustomEventBlock.ClassName,\r\n \"flow/sequence\": FlowGraphSequenceBlock.ClassName,\r\n \"world/get\": FlowGraphGetPropertyBlock.ClassName,\r\n \"world/set\": FlowGraphSetPropertyBlock.ClassName,\r\n \"flow/doN\": FlowGraphDoNBlock.ClassName,\r\n \"variable/get\": FlowGraphGetVariableBlock.ClassName,\r\n \"variable/set\": FlowGraphSetVariableBlock.ClassName,\r\n \"flow/whileLoop\": FlowGraphWhileLoopBlock.ClassName,\r\n \"math/random\": FlowGraphRandomBlock.ClassName,\r\n \"math/e\": FlowGraphEBlock.ClassName,\r\n \"math/pi\": FlowGraphPiBlock.ClassName,\r\n \"math/inf\": FlowGraphInfBlock.ClassName,\r\n \"math/nan\": FlowGraphNaNBlock.ClassName,\r\n \"math/abs\": FlowGraphAbsBlock.ClassName,\r\n \"math/sign\": FlowGraphSignBlock.ClassName,\r\n \"math/trunc\": FlowGraphTruncBlock.ClassName,\r\n \"math/floor\": FlowGraphFloorBlock.ClassName,\r\n \"math/ceil\": FlowGraphCeilBlock.ClassName,\r\n \"math/fract\": FlowGraphFractBlock.ClassName,\r\n \"math/neg\": FlowGraphNegBlock.ClassName,\r\n \"math/add\": FlowGraphAddBlock.ClassName,\r\n \"math/sub\": FlowGraphSubtractBlock.ClassName,\r\n \"math/mul\": FlowGraphMultiplyBlock.ClassName,\r\n \"math/div\": FlowGraphDivideBlock.ClassName,\r\n \"math/rem\": FlowGraphRemainderBlock.ClassName,\r\n \"math/min\": FlowGraphMinBlock.ClassName,\r\n \"math/max\": FlowGraphMaxBlock.ClassName,\r\n \"math/clamp\": FlowGraphClampBlock.ClassName,\r\n \"math/saturate\": FlowGraphSaturateBlock.ClassName,\r\n \"math/mix\": FlowGraphInterpolateBlock.ClassName,\r\n \"math/eq\": FlowGraphEqBlock.ClassName,\r\n \"math/lt\": FlowGraphLessThanBlock.ClassName,\r\n \"math/le\": FlowGraphLessThanOrEqualBlock.ClassName,\r\n \"math/gt\": FlowGraphGreaterThanBlock.ClassName,\r\n \"math/ge\": FlowGraphGreaterThanOrEqualBlock.ClassName,\r\n \"math/isnan\": FlowGraphIsNanBlock.ClassName,\r\n \"math/isinf\": FlowGraphIsInfBlock.ClassName,\r\n \"math/rad\": FlowGraphDegToRadBlock.ClassName,\r\n \"math/deg\": FlowGraphRadToDegBlock.ClassName,\r\n \"math/sin\": FlowGraphSinBlock.ClassName,\r\n \"math/cos\": FlowGraphCosBlock.ClassName,\r\n \"math/tan\": FlowGraphTanBlock.ClassName,\r\n \"math/asin\": FlowGraphAsinBlock.ClassName,\r\n \"math/acos\": FlowGraphAcosBlock.ClassName,\r\n \"math/atan\": FlowGraphAtanBlock.ClassName,\r\n \"math/atan2\": FlowGraphAtan2Block.ClassName,\r\n \"math/sinh\": FlowGraphSinhBlock.ClassName,\r\n \"math/cosh\": FlowGraphCoshBlock.ClassName,\r\n \"math/tanh\": FlowGraphTanhBlock.ClassName,\r\n \"math/asinh\": FlowGraphAsinhBlock.ClassName,\r\n \"math/acosh\": FlowGraphAcoshBlock.ClassName,\r\n \"math/atanh\": FlowGraphAtanhBlock.ClassName,\r\n \"math/exp\": FlowGraphExpBlock.ClassName,\r\n \"math/log\": FlowGraphLogBlock.ClassName,\r\n \"math/log2\": FlowGraphLog2Block.ClassName,\r\n \"math/log10\": FlowGraphLog10Block.ClassName,\r\n \"math/sqrt\": FlowGraphSqrtBlock.ClassName,\r\n \"math/cbrt\": FlowGraphCubeRootBlock.ClassName,\r\n \"math/pow\": FlowGraphPowBlock.ClassName,\r\n \"math/length\": FlowGraphLengthBlock.ClassName,\r\n \"math/normalize\": FlowGraphNormalizeBlock.ClassName,\r\n \"math/dot\": FlowGraphDotBlock.ClassName,\r\n \"math/cross\": FlowGraphCrossBlock.ClassName,\r\n \"math/rotate2d\": FlowGraphRotate2DBlock.ClassName,\r\n \"math/rotate3d\": FlowGraphRotate3DBlock.ClassName,\r\n};\r\n\r\nexport const gltfTypeToBabylonType: any = {\r\n float2: \"Vector2\",\r\n float3: \"Vector3\",\r\n float4: \"Vector4\",\r\n};\r\n"]}
1
+ {"version":3,"file":"interactivityUtils.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/interactivityUtils.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD,OAAO,EAAE,6BAA6B,EAAE,gFAAkE;AAC1G,OAAO,EAAE,4BAA4B,EAAE,+EAAiE;AACxG,OAAO,EAAE,wBAAwB,EAAE,+EAAiE;AACpG,OAAO,EAAE,mBAAmB,EAAE,sFAAwE;AACtG,OAAO,EAAE,6BAA6B,EAAE,oFAAsE;AAC9G,OAAO,EAAE,gCAAgC,EAAE,mFAAqE;AAChH,OAAO,EAAE,sBAAsB,EAAE,yFAA2E;AAC5G,OAAO,EA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SAAS;IAC3C,WAAW,EAAE,kBAAkB,CAAC,SAAS;IACzC,WAAW,EAAE,sBAAsB,CAAC,SAAS;IAC7C,UAAU,EAAE,iBAAiB,CAAC,SAAS;IACvC,aAAa,EAAE,oBAAoB,CAAC,SAAS;IAC7C,gBAAgB,EAAE,uBAAuB,CAAC,SAAS;IACnD,UAAU,EAAE,iBAAiB,CAAC,SAAS;IACvC,YAAY,EAAE,mBAAmB,CAAC,SAAS;IAC3C,eAAe,EAAE,sBAAsB,CAAC,SAAS;IACjD,eAAe,EAAE,sBAAsB,CAAC,SAAS;IACjD,gBAAgB,EAAE,uBAAuB,CAAC,SAAS;IACnD,kBAAkB,EAAE,yBAAyB,CAAC,SAAS;IACvD,cAAc,EAAE,0BAA0B,CAAC,SAAS;IACpD,aAAa,EAAE,oBAAoB,CAAC,SAAS;IAC7C,UAAU,EAAE,wBAAwB,CAAC,SAAS;IAC9C,UAAU,EAAE,wBAAwB,CAAC,SAAS;IAC9C,SAAS,EAAE,uBAAuB,CAAC,SAAS;IAC5C,UAAU,EAAE,wBAAwB,CAAC,SAAS;IAC9C,UAAU,EAAE,+BAA+B,CAAC,SAAS;IACrD,UAAU,EAAE,8BAA8B,CAAC,SAAS;IACpD,UAAU,EAAE,+BAA+B,CAAC,SAAS;IACrD,UAAU,EAAE,gCAAgC,CAAC,SAAS;IACtD,aAAa,EAAE,0BAA0B,CAAC,SAAS;CACtD,CAAC;AAEF,MAAM,CAAC,MAAM,qBAAqB,GAAQ;IACtC,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE,QAAQ;IAClB,GAAG,EAAE,kBAAkB;CAC1B,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { FlowGraphSceneReadyEventBlock } from \"core/FlowGraph/Blocks/Event/flowGraphSceneReadyEventBlock\";\r\nimport { FlowGraphSceneTickEventBlock } from \"core/FlowGraph/Blocks/Event/flowGraphSceneTickEventBlock\";\r\nimport { FlowGraphConsoleLogBlock } from \"core/FlowGraph/Blocks/Execution/flowGraphConsoleLogBlock\";\r\nimport { FlowGraphTimerBlock } from \"core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphTimerBlock\";\r\nimport { FlowGraphSendCustomEventBlock } from \"core/FlowGraph/Blocks/Execution/flowGraphSendCustomEventBlock\";\r\nimport { FlowGraphReceiveCustomEventBlock } from \"core/FlowGraph/Blocks/Event/flowGraphReceiveCustomEventBlock\";\r\nimport { FlowGraphSequenceBlock } from \"core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphSequenceBlock\";\r\nimport { FlowGraphGetPropertyBlock } from \"core/FlowGraph/Blocks/Data/flowGraphGetPropertyBlock\";\r\nimport { FlowGraphSetPropertyBlock } from \"core/FlowGraph/Blocks/Execution/flowGraphSetPropertyBlock\";\r\nimport {\r\n FlowGraphAddBlock,\r\n FlowGraphRandomBlock,\r\n FlowGraphLessThanBlock,\r\n FlowGraphMultiplyBlock,\r\n FlowGraphSubtractBlock,\r\n FlowGraphDotBlock,\r\n FlowGraphEBlock,\r\n FlowGraphPiBlock,\r\n FlowGraphInfBlock,\r\n FlowGraphNaNBlock,\r\n FlowGraphAbsBlock,\r\n FlowGraphSignBlock,\r\n FlowGraphTruncBlock,\r\n FlowGraphFloorBlock,\r\n FlowGraphCeilBlock,\r\n FlowGraphFractBlock,\r\n FlowGraphNegBlock,\r\n FlowGraphDivideBlock,\r\n FlowGraphRemainderBlock,\r\n FlowGraphMinBlock,\r\n FlowGraphMaxBlock,\r\n FlowGraphClampBlock,\r\n FlowGraphSaturateBlock,\r\n FlowGraphInterpolateBlock,\r\n FlowGraphEqBlock,\r\n FlowGraphLessThanOrEqualBlock,\r\n FlowGraphGreaterThanBlock,\r\n FlowGraphGreaterThanOrEqualBlock,\r\n FlowGraphIsNanBlock,\r\n FlowGraphIsInfBlock,\r\n FlowGraphDegToRadBlock,\r\n FlowGraphRadToDegBlock,\r\n FlowGraphSinBlock,\r\n FlowGraphCosBlock,\r\n FlowGraphTanBlock,\r\n FlowGraphAsinBlock,\r\n FlowGraphAcosBlock,\r\n FlowGraphAtanBlock,\r\n FlowGraphAtan2Block,\r\n FlowGraphSinhBlock,\r\n FlowGraphCoshBlock,\r\n FlowGraphTanhBlock,\r\n FlowGraphAsinhBlock,\r\n FlowGraphAcoshBlock,\r\n FlowGraphAtanhBlock,\r\n FlowGraphExpBlock,\r\n FlowGraphLog2Block,\r\n FlowGraphLogBlock,\r\n FlowGraphLog10Block,\r\n FlowGraphSqrtBlock,\r\n FlowGraphCubeRootBlock,\r\n FlowGraphPowBlock,\r\n FlowGraphLengthBlock,\r\n FlowGraphNormalizeBlock,\r\n FlowGraphCrossBlock,\r\n FlowGraphRotate2DBlock,\r\n FlowGraphRotate3DBlock,\r\n FlowGraphTransposeBlock,\r\n FlowGraphDeterminantBlock,\r\n FlowGraphInvertMatrixBlock,\r\n FlowGraphMatMulBlock,\r\n FlowGraphBitwiseNotBlock,\r\n FlowGraphBitwiseAndBlock,\r\n FlowGraphBitwiseOrBlock,\r\n FlowGraphBitwiseXorBlock,\r\n FlowGraphBitwiseRightShiftBlock,\r\n FlowGraphBitwiseLeftShiftBlock,\r\n FlowGraphCountLeadingZerosBlock,\r\n FlowGraphCountTrailingZerosBlock,\r\n FlowGraphCountOneBitsBlock,\r\n} from \"core/FlowGraph/Blocks/Data/Math/flowGraphMathBlocks\";\r\nimport { FlowGraphDoNBlock } from \"core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphDoNBlock\";\r\nimport { FlowGraphGetVariableBlock } from \"core/FlowGraph/Blocks/Data/flowGraphGetVariableBlock\";\r\nimport { FlowGraphSetVariableBlock } from \"core/FlowGraph/Blocks/Execution/flowGraphSetVariableBlock\";\r\nimport { FlowGraphWhileLoopBlock } from \"core/FlowGraph/Blocks/Execution/ControlFlow/flowGraphWhileLoopBlock\";\r\n\r\nexport const gltfToFlowGraphTypeMap: { [key: string]: string } = {\r\n \"lifecycle/onStart\": FlowGraphSceneReadyEventBlock.ClassName,\r\n \"lifecycle/onTick\": FlowGraphSceneTickEventBlock.ClassName,\r\n log: FlowGraphConsoleLogBlock.ClassName,\r\n \"flow/delay\": FlowGraphTimerBlock.ClassName,\r\n \"customEvent/send\": FlowGraphSendCustomEventBlock.ClassName,\r\n \"customEvent/receive\": FlowGraphReceiveCustomEventBlock.ClassName,\r\n \"flow/sequence\": FlowGraphSequenceBlock.ClassName,\r\n \"world/get\": FlowGraphGetPropertyBlock.ClassName,\r\n \"world/set\": FlowGraphSetPropertyBlock.ClassName,\r\n \"flow/doN\": FlowGraphDoNBlock.ClassName,\r\n \"variable/get\": FlowGraphGetVariableBlock.ClassName,\r\n \"variable/set\": FlowGraphSetVariableBlock.ClassName,\r\n \"flow/whileLoop\": FlowGraphWhileLoopBlock.ClassName,\r\n \"math/random\": FlowGraphRandomBlock.ClassName,\r\n \"math/e\": FlowGraphEBlock.ClassName,\r\n \"math/pi\": FlowGraphPiBlock.ClassName,\r\n \"math/inf\": FlowGraphInfBlock.ClassName,\r\n \"math/nan\": FlowGraphNaNBlock.ClassName,\r\n \"math/abs\": FlowGraphAbsBlock.ClassName,\r\n \"math/sign\": FlowGraphSignBlock.ClassName,\r\n \"math/trunc\": FlowGraphTruncBlock.ClassName,\r\n \"math/floor\": FlowGraphFloorBlock.ClassName,\r\n \"math/ceil\": FlowGraphCeilBlock.ClassName,\r\n \"math/fract\": FlowGraphFractBlock.ClassName,\r\n \"math/neg\": FlowGraphNegBlock.ClassName,\r\n \"math/add\": FlowGraphAddBlock.ClassName,\r\n \"math/sub\": FlowGraphSubtractBlock.ClassName,\r\n \"math/mul\": FlowGraphMultiplyBlock.ClassName,\r\n \"math/div\": FlowGraphDivideBlock.ClassName,\r\n \"math/rem\": FlowGraphRemainderBlock.ClassName,\r\n \"math/min\": FlowGraphMinBlock.ClassName,\r\n \"math/max\": FlowGraphMaxBlock.ClassName,\r\n \"math/clamp\": FlowGraphClampBlock.ClassName,\r\n \"math/saturate\": FlowGraphSaturateBlock.ClassName,\r\n \"math/mix\": FlowGraphInterpolateBlock.ClassName,\r\n \"math/eq\": FlowGraphEqBlock.ClassName,\r\n \"math/lt\": FlowGraphLessThanBlock.ClassName,\r\n \"math/le\": FlowGraphLessThanOrEqualBlock.ClassName,\r\n \"math/gt\": FlowGraphGreaterThanBlock.ClassName,\r\n \"math/ge\": FlowGraphGreaterThanOrEqualBlock.ClassName,\r\n \"math/isnan\": FlowGraphIsNanBlock.ClassName,\r\n \"math/isinf\": FlowGraphIsInfBlock.ClassName,\r\n \"math/rad\": FlowGraphDegToRadBlock.ClassName,\r\n \"math/deg\": FlowGraphRadToDegBlock.ClassName,\r\n \"math/sin\": FlowGraphSinBlock.ClassName,\r\n \"math/cos\": FlowGraphCosBlock.ClassName,\r\n \"math/tan\": FlowGraphTanBlock.ClassName,\r\n \"math/asin\": FlowGraphAsinBlock.ClassName,\r\n \"math/acos\": FlowGraphAcosBlock.ClassName,\r\n \"math/atan\": FlowGraphAtanBlock.ClassName,\r\n \"math/atan2\": FlowGraphAtan2Block.ClassName,\r\n \"math/sinh\": FlowGraphSinhBlock.ClassName,\r\n \"math/cosh\": FlowGraphCoshBlock.ClassName,\r\n \"math/tanh\": FlowGraphTanhBlock.ClassName,\r\n \"math/asinh\": FlowGraphAsinhBlock.ClassName,\r\n \"math/acosh\": FlowGraphAcoshBlock.ClassName,\r\n \"math/atanh\": FlowGraphAtanhBlock.ClassName,\r\n \"math/exp\": FlowGraphExpBlock.ClassName,\r\n \"math/log\": FlowGraphLogBlock.ClassName,\r\n \"math/log2\": FlowGraphLog2Block.ClassName,\r\n \"math/log10\": FlowGraphLog10Block.ClassName,\r\n \"math/sqrt\": FlowGraphSqrtBlock.ClassName,\r\n \"math/cbrt\": FlowGraphCubeRootBlock.ClassName,\r\n \"math/pow\": FlowGraphPowBlock.ClassName,\r\n \"math/length\": FlowGraphLengthBlock.ClassName,\r\n \"math/normalize\": FlowGraphNormalizeBlock.ClassName,\r\n \"math/dot\": FlowGraphDotBlock.ClassName,\r\n \"math/cross\": FlowGraphCrossBlock.ClassName,\r\n \"math/rotate2d\": FlowGraphRotate2DBlock.ClassName,\r\n \"math/rotate3d\": FlowGraphRotate3DBlock.ClassName,\r\n \"math/transpose\": FlowGraphTransposeBlock.ClassName,\r\n \"math/determinant\": FlowGraphDeterminantBlock.ClassName,\r\n \"math/inverse\": FlowGraphInvertMatrixBlock.ClassName,\r\n \"math/matmul\": FlowGraphMatMulBlock.ClassName,\r\n \"math/not\": FlowGraphBitwiseNotBlock.ClassName,\r\n \"math/and\": FlowGraphBitwiseAndBlock.ClassName,\r\n \"math/or\": FlowGraphBitwiseOrBlock.ClassName,\r\n \"math/xor\": FlowGraphBitwiseXorBlock.ClassName,\r\n \"math/asr\": FlowGraphBitwiseRightShiftBlock.ClassName,\r\n \"math/lsl\": FlowGraphBitwiseLeftShiftBlock.ClassName,\r\n \"math/clz\": FlowGraphCountLeadingZerosBlock.ClassName,\r\n \"math/ctz\": FlowGraphCountTrailingZerosBlock.ClassName,\r\n \"math/popcnt\": FlowGraphCountOneBitsBlock.ClassName,\r\n};\r\n\r\nexport const gltfTypeToBabylonType: any = {\r\n float2: \"Vector2\",\r\n float3: \"Vector3\",\r\n float4: \"Vector4\",\r\n float4x4: \"Matrix\",\r\n int: \"FlowGraphInteger\",\r\n};\r\n"]}
@@ -1558,8 +1558,7 @@ export class GLTFLoader {
1558
1558
  * @internal
1559
1559
  */
1560
1560
  _loadVertexAccessorAsync(context, accessor, kind) {
1561
- var _a;
1562
- if ((_a = accessor._babylonVertexBuffer) === null || _a === void 0 ? void 0 : _a[kind]) {
1561
+ if (accessor._babylonVertexBuffer?.[kind]) {
1563
1562
  return accessor._babylonVertexBuffer[kind];
1564
1563
  }
1565
1564
  if (!accessor._babylonVertexBuffer) {