@babylonjs/loaders 5.0.0-alpha.5 → 5.0.0-alpha.53

Sign up to get free protection for your applications and to get access to all the features.
Files changed (119) hide show
  1. package/OBJ/index.d.ts +2 -0
  2. package/OBJ/index.js +4 -2
  3. package/OBJ/index.js.map +1 -1
  4. package/OBJ/mtlFileLoader.d.ts +4 -2
  5. package/OBJ/mtlFileLoader.js +7 -6
  6. package/OBJ/mtlFileLoader.js.map +1 -1
  7. package/OBJ/objFileLoader.d.ts +17 -78
  8. package/OBJ/objFileLoader.js +55 -619
  9. package/OBJ/objFileLoader.js.map +1 -1
  10. package/OBJ/objLoadingOptions.d.ts +43 -0
  11. package/OBJ/objLoadingOptions.js +2 -0
  12. package/OBJ/objLoadingOptions.js.map +1 -0
  13. package/OBJ/solidParser.d.ts +153 -0
  14. package/OBJ/solidParser.js +700 -0
  15. package/OBJ/solidParser.js.map +1 -0
  16. package/STL/index.js +1 -1
  17. package/STL/stlFileLoader.d.ts +6 -0
  18. package/STL/stlFileLoader.js +38 -11
  19. package/STL/stlFileLoader.js.map +1 -1
  20. package/glTF/1.0/glTFBinaryExtension.js +4 -4
  21. package/glTF/1.0/glTFLoader.d.ts +4 -4
  22. package/glTF/1.0/glTFLoader.js +60 -55
  23. package/glTF/1.0/glTFLoader.js.map +1 -1
  24. package/glTF/1.0/glTFLoaderInterfaces.d.ts +3 -1
  25. package/glTF/1.0/glTFLoaderInterfaces.js.map +1 -1
  26. package/glTF/1.0/glTFLoaderUtils.js +6 -6
  27. package/glTF/1.0/glTFMaterialsCommonExtension.js +12 -12
  28. package/glTF/1.0/index.js +5 -5
  29. package/glTF/2.0/Extensions/EXT_lights_image_based.js +8 -5
  30. package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
  31. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +3 -3
  32. package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
  33. package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +1 -5
  34. package/glTF/2.0/Extensions/EXT_meshopt_compression.js +5 -21
  35. package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
  36. package/glTF/2.0/Extensions/EXT_texture_webp.js +2 -2
  37. package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
  38. package/glTF/2.0/Extensions/ExtrasAsMetadata.js +1 -1
  39. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +8 -4
  40. package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
  41. package/glTF/2.0/Extensions/KHR_lights_punctual.js +9 -8
  42. package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
  43. package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +2 -2
  44. package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +1 -2
  45. package/glTF/2.0/Extensions/KHR_materials_ior.js +3 -4
  46. package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
  47. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +3 -4
  48. package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
  49. package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +0 -1
  50. package/glTF/2.0/Extensions/KHR_materials_sheen.js +3 -4
  51. package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
  52. package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +1 -2
  53. package/glTF/2.0/Extensions/KHR_materials_specular.js +12 -6
  54. package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
  55. package/glTF/2.0/Extensions/KHR_materials_translucency.js +6 -6
  56. package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
  57. package/glTF/2.0/Extensions/KHR_materials_transmission.js +92 -84
  58. package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
  59. package/glTF/2.0/Extensions/KHR_materials_unlit.js +3 -3
  60. package/glTF/2.0/Extensions/KHR_materials_variants.js +86 -22
  61. package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
  62. package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +31 -0
  63. package/glTF/2.0/Extensions/KHR_materials_volume.js +79 -0
  64. package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -0
  65. package/glTF/2.0/Extensions/KHR_mesh_quantization.js +1 -1
  66. package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +1 -2
  67. package/glTF/2.0/Extensions/KHR_texture_basisu.js +3 -4
  68. package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
  69. package/glTF/2.0/Extensions/KHR_texture_transform.js +2 -2
  70. package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +2 -2
  71. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +3 -3
  72. package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
  73. package/glTF/2.0/Extensions/MSFT_audio_emitter.js +6 -7
  74. package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
  75. package/glTF/2.0/Extensions/MSFT_lod.d.ts +2 -1
  76. package/glTF/2.0/Extensions/MSFT_lod.js +48 -8
  77. package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
  78. package/glTF/2.0/Extensions/MSFT_minecraftMesh.js +2 -2
  79. package/glTF/2.0/Extensions/MSFT_sRGBFactors.js +2 -2
  80. package/glTF/2.0/Extensions/index.d.ts +1 -0
  81. package/glTF/2.0/Extensions/index.js +25 -24
  82. package/glTF/2.0/Extensions/index.js.map +1 -1
  83. package/glTF/2.0/glTFLoader.d.ts +5 -10
  84. package/glTF/2.0/glTFLoader.js +125 -92
  85. package/glTF/2.0/glTFLoader.js.map +1 -1
  86. package/glTF/2.0/glTFLoaderInterfaces.d.ts +4 -2
  87. package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
  88. package/glTF/2.0/index.d.ts +1 -1
  89. package/glTF/2.0/index.js +4 -4
  90. package/glTF/2.0/index.js.map +1 -1
  91. package/glTF/glTFFileLoader.d.ts +15 -9
  92. package/glTF/glTFFileLoader.js +62 -76
  93. package/glTF/glTFFileLoader.js.map +1 -1
  94. package/glTF/glTFValidation.js +1 -1
  95. package/glTF/glTFValidation.js.map +1 -1
  96. package/glTF/index.d.ts +2 -2
  97. package/glTF/index.js +4 -4
  98. package/glTF/index.js.map +1 -1
  99. package/index.d.ts +3 -3
  100. package/index.js +3 -3
  101. package/index.js.map +1 -1
  102. package/legacy/legacy-glTF.js +4 -4
  103. package/legacy/legacy-glTF1.d.ts +1 -1
  104. package/legacy/legacy-glTF1.js +1 -1
  105. package/legacy/legacy-glTF1.js.map +1 -1
  106. package/legacy/legacy-glTF1FileLoader.js +2 -2
  107. package/legacy/legacy-glTF2.d.ts +1 -1
  108. package/legacy/legacy-glTF2.js +3 -3
  109. package/legacy/legacy-glTF2.js.map +1 -1
  110. package/legacy/legacy-glTF2FileLoader.js +2 -2
  111. package/legacy/legacy-glTFFileLoader.js +3 -3
  112. package/legacy/legacy-objFileLoader.d.ts +1 -1
  113. package/legacy/legacy-objFileLoader.js +2 -2
  114. package/legacy/legacy-objFileLoader.js.map +1 -1
  115. package/legacy/legacy-stlFileLoader.d.ts +1 -1
  116. package/legacy/legacy-stlFileLoader.js +2 -2
  117. package/legacy/legacy-stlFileLoader.js.map +1 -1
  118. package/legacy/legacy.js +6 -6
  119. package/package.json +13 -4
@@ -1,9 +1,9 @@
1
- import { Vector3 } from "@babylonjs/core/Maths/math.vector";
2
- import { Tools } from "@babylonjs/core/Misc/tools";
3
- import { AnimationEvent } from "@babylonjs/core/Animations/animationEvent";
4
- import { Sound } from "@babylonjs/core/Audio/sound";
5
- import { WeightedSound } from "@babylonjs/core/Audio/weightedsound";
6
- import { GLTFLoader, ArrayItem } from "../glTFLoader";
1
+ import { Vector3 } from "@babylonjs/core/Maths/math.vector.js";
2
+ import { Tools } from "@babylonjs/core/Misc/tools.js";
3
+ import { AnimationEvent } from "@babylonjs/core/Animations/animationEvent.js";
4
+ import { Sound } from "@babylonjs/core/Audio/sound.js";
5
+ import { WeightedSound } from "@babylonjs/core/Audio/weightedsound.js";
6
+ import { GLTFLoader, ArrayItem } from "../glTFLoader.js";
7
7
  var NAME = "MSFT_audio_emitter";
8
8
  /**
9
9
  * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
@@ -138,7 +138,6 @@ var MSFT_audio_emitter = /** @class */ (function () {
138
138
  sound.maxDistance = emitter.maxDistance || 256;
139
139
  sound.rolloffFactor = emitter.rolloffFactor || 1;
140
140
  sound.distanceModel = emitter.distanceModel || 'exponential';
141
- sound._positionInEmitterSpace = true;
142
141
  }));
143
142
  };
144
143
  var this_1 = this;
@@ -1 +1 @@
1
- {"version":3,"file":"MSFT_audio_emitter.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAE3E,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAIpE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGtD,IAAM,IAAI,GAAG,oBAAoB,CAAC;AA0BlC;;GAEG;AACH;IAeI,cAAc;IACd,4BAAY,MAAkB;QAf9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAaxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,cAAc;IACP,oCAAO,GAAd;QACK,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;QAC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O,GAAG,SAAS,CAAC,GAAG,CAAC,iBAAe,IAAI,CAAC,IAAI,cAAW,EAAE,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QACjG,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;YACjD,IAAM,KAAK,GAAG,OAAO,CAAC,YAAa,CAAC,KAAK,CAAC;YAC1C,IAAI,KAAK,EAAE;gBACP,IAAI,qBAAqB,GAAG,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,KAAI,CAAC,eAAe,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;gBAC9I,gBAAgB,CAAC,SAAS,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;gBAC3D,uEAAuE;gBACvE,qBAAqB,CAAC,6BAA6B,CAAC,GAAG,CAAC;oBACpD,KAAK,CAAC,IAAI,EAAE,CAAC;gBACjB,CAAC,CAAC,CAAC;gBACH,qBAAqB,CAAC,+BAA+B,CAAC,GAAG,CAAC;oBACtD,KAAK,CAAC,KAAK,EAAE,CAAC;gBAClB,CAAC,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IACL,yBAAC;AAAD,CAAC,AA5ND,IA4NC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,kBAAkB,CAAC,MAAM,CAAC,EAA9B,CAA8B,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { Vector3 } from \"@babylonjs/core/Maths/math.vector\";\nimport { Tools } from \"@babylonjs/core/Misc/tools\";\nimport { AnimationGroup } from \"@babylonjs/core/Animations/animationGroup\";\nimport { AnimationEvent } from \"@babylonjs/core/Animations/animationEvent\";\nimport { TransformNode } from \"@babylonjs/core/Meshes/transformNode\";\nimport { Sound } from \"@babylonjs/core/Audio/sound\";\nimport { WeightedSound } from \"@babylonjs/core/Audio/weightedsound\";\n\nimport { IArrayItem, IScene, INode, IAnimation } from \"../glTFLoaderInterfaces\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\nimport { IMSFTAudioEmitter_Clip, IMSFTAudioEmitter_Emitter, IMSFTAudioEmitter_EmittersReference, IMSFTAudioEmitter_AnimationEvent, IMSFTAudioEmitter_AnimationEventAction } from 'babylonjs-gltf2interface';\n\nconst NAME = \"MSFT_audio_emitter\";\n\ninterface ILoaderClip extends IMSFTAudioEmitter_Clip, IArrayItem {\n _objectURL?: Promise<string>;\n}\n\ninterface ILoaderEmitter extends IMSFTAudioEmitter_Emitter, IArrayItem {\n _babylonData?: {\n sound?: WeightedSound;\n loaded: Promise<void>;\n };\n _babylonSounds: Sound[];\n}\n\ninterface IMSFTAudioEmitter {\n clips: ILoaderClip[];\n emitters: ILoaderEmitter[];\n}\n\ninterface ILoaderAnimationEvent extends IMSFTAudioEmitter_AnimationEvent, IArrayItem {\n}\n\ninterface ILoaderAnimationEvents {\n events: ILoaderAnimationEvent[];\n}\n\n/**\n * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)\n */\nexport class MSFT_audio_emitter implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n private _loader: GLTFLoader;\n private _clips: Array<ILoaderClip>;\n private _emitters: Array<ILoaderEmitter>;\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n (this._clips as any) = null;\n (this._emitters as any) = null;\n }\n\n /** @hidden */\n public onLoading(): void {\n const extensions = this._loader.gltf.extensions;\n if (extensions && extensions[this.name]) {\n const extension = extensions[this.name] as IMSFTAudioEmitter;\n\n this._clips = extension.clips;\n this._emitters = extension.emitters;\n\n ArrayItem.Assign(this._clips);\n ArrayItem.Assign(this._emitters);\n }\n }\n\n /** @hidden */\n public loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>> {\n return GLTFLoader.LoadExtensionAsync<IMSFTAudioEmitter_EmittersReference>(context, scene, this.name, (extensionContext, extension) => {\n const promises = new Array<Promise<any>>();\n\n promises.push(this._loader.loadSceneAsync(context, scene));\n\n for (const emitterIndex of extension.emitters) {\n const emitter = ArrayItem.Get(`${extensionContext}/emitters`, this._emitters, emitterIndex);\n if (emitter.refDistance != undefined || emitter.maxDistance != undefined || emitter.rolloffFactor != undefined ||\n emitter.distanceModel != undefined || emitter.innerAngle != undefined || emitter.outerAngle != undefined) {\n throw new Error(`${extensionContext}: Direction or Distance properties are not allowed on emitters attached to a scene`);\n }\n\n promises.push(this._loadEmitterAsync(`${extensionContext}/emitters/${emitter.index}`, emitter));\n }\n\n return Promise.all(promises).then(() => { });\n });\n }\n\n /** @hidden */\n public loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>> {\n return GLTFLoader.LoadExtensionAsync<IMSFTAudioEmitter_EmittersReference, TransformNode>(context, node, this.name, (extensionContext, extension) => {\n const promises = new Array<Promise<any>>();\n\n return this._loader.loadNodeAsync(extensionContext, node, (babylonMesh) => {\n for (const emitterIndex of extension.emitters) {\n const emitter = ArrayItem.Get(`${extensionContext}/emitters`, this._emitters, emitterIndex);\n promises.push(this._loadEmitterAsync(`${extensionContext}/emitters/${emitter.index}`, emitter).then(() => {\n for (const sound of emitter._babylonSounds) {\n sound.attachToMesh(babylonMesh);\n if (emitter.innerAngle != undefined || emitter.outerAngle != undefined) {\n sound.setLocalDirectionToMesh(Vector3.Forward());\n sound.setDirectionalCone(\n 2 * Tools.ToDegrees(emitter.innerAngle == undefined ? Math.PI : emitter.innerAngle),\n 2 * Tools.ToDegrees(emitter.outerAngle == undefined ? Math.PI : emitter.outerAngle),\n 0);\n }\n }\n }));\n }\n\n assign(babylonMesh);\n }).then((babylonMesh) => {\n return Promise.all(promises).then(() => {\n return babylonMesh;\n });\n });\n });\n }\n\n /** @hidden */\n public loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>> {\n return GLTFLoader.LoadExtensionAsync<ILoaderAnimationEvents, AnimationGroup>(context, animation, this.name, (extensionContext, extension) => {\n return this._loader.loadAnimationAsync(context, animation).then((babylonAnimationGroup) => {\n const promises = new Array<Promise<any>>();\n\n ArrayItem.Assign(extension.events);\n for (const event of extension.events) {\n promises.push(this._loadAnimationEventAsync(`${extensionContext}/events/${event.index}`, context, animation, event, babylonAnimationGroup));\n }\n\n return Promise.all(promises).then(() => {\n return babylonAnimationGroup;\n });\n });\n });\n }\n\n private _loadClipAsync(context: string, clip: ILoaderClip): Promise<string> {\n if (clip._objectURL) {\n return clip._objectURL;\n }\n\n let promise: Promise<ArrayBufferView>;\n if (clip.uri) {\n promise = this._loader.loadUriAsync(context, clip, clip.uri);\n }\n else {\n const bufferView = ArrayItem.Get(`${context}/bufferView`, this._loader.gltf.bufferViews, clip.bufferView);\n promise = this._loader.loadBufferViewAsync(`/bufferViews/${bufferView.index}`, bufferView);\n }\n\n clip._objectURL = promise.then((data) => {\n return URL.createObjectURL(new Blob([data], { type: clip.mimeType }));\n });\n\n return clip._objectURL;\n }\n\n private _loadEmitterAsync(context: string, emitter: ILoaderEmitter): Promise<void> {\n emitter._babylonSounds = emitter._babylonSounds || [];\n if (!emitter._babylonData) {\n const clipPromises = new Array<Promise<any>>();\n const name = emitter.name || `emitter${emitter.index}`;\n const options = {\n loop: false,\n autoplay: false,\n volume: emitter.volume == undefined ? 1 : emitter.volume,\n };\n\n for (let i = 0; i < emitter.clips.length; i++) {\n const clipContext = `/extensions/${this.name}/clips`;\n const clip = ArrayItem.Get(clipContext, this._clips, emitter.clips[i].clip);\n clipPromises.push(this._loadClipAsync(`${clipContext}/${emitter.clips[i].clip}`, clip).then((objectURL: string) => {\n const sound = emitter._babylonSounds[i] = new Sound(name, objectURL, this._loader.babylonScene, null, options);\n sound.refDistance = emitter.refDistance || 1;\n sound.maxDistance = emitter.maxDistance || 256;\n sound.rolloffFactor = emitter.rolloffFactor || 1;\n sound.distanceModel = emitter.distanceModel || 'exponential';\n sound._positionInEmitterSpace = true;\n }));\n }\n\n const promise = Promise.all(clipPromises).then(() => {\n const weights = emitter.clips.map((clip) => { return clip.weight || 1; });\n const weightedSound = new WeightedSound(emitter.loop || false, emitter._babylonSounds, weights);\n if (emitter.innerAngle) { weightedSound.directionalConeInnerAngle = 2 * Tools.ToDegrees(emitter.innerAngle); }\n if (emitter.outerAngle) { weightedSound.directionalConeOuterAngle = 2 * Tools.ToDegrees(emitter.outerAngle); }\n if (emitter.volume) { weightedSound.volume = emitter.volume; }\n emitter._babylonData!.sound = weightedSound;\n });\n\n emitter._babylonData = {\n loaded: promise\n };\n }\n\n return emitter._babylonData.loaded;\n }\n\n private _getEventAction(context: string, sound: WeightedSound, action: IMSFTAudioEmitter_AnimationEventAction, time: number, startOffset?: number): (currentFrame: number) => void {\n switch (action) {\n case IMSFTAudioEmitter_AnimationEventAction.play: {\n return (currentFrame: number) => {\n const frameOffset = (startOffset || 0) + (currentFrame - time);\n sound.play(frameOffset);\n };\n }\n case IMSFTAudioEmitter_AnimationEventAction.stop: {\n return (currentFrame: number) => {\n sound.stop();\n };\n }\n case IMSFTAudioEmitter_AnimationEventAction.pause: {\n return (currentFrame: number) => {\n sound.pause();\n };\n }\n default: {\n throw new Error(`${context}: Unsupported action ${action}`);\n }\n }\n }\n\n private _loadAnimationEventAsync(context: string, animationContext: string, animation: IAnimation, event: ILoaderAnimationEvent, babylonAnimationGroup: AnimationGroup): Promise<void> {\n if (babylonAnimationGroup.targetedAnimations.length == 0) {\n return Promise.resolve();\n }\n const babylonAnimation = babylonAnimationGroup.targetedAnimations[0];\n const emitterIndex = event.emitter;\n const emitter = ArrayItem.Get(`/extensions/${this.name}/emitters`, this._emitters, emitterIndex);\n return this._loadEmitterAsync(context, emitter).then(() => {\n const sound = emitter._babylonData!.sound;\n if (sound) {\n var babylonAnimationEvent = new AnimationEvent(event.time, this._getEventAction(context, sound, event.action, event.time, event.startOffset));\n babylonAnimation.animation.addEvent(babylonAnimationEvent);\n // Make sure all started audio stops when this animation is terminated.\n babylonAnimationGroup.onAnimationGroupEndObservable.add(() => {\n sound.stop();\n });\n babylonAnimationGroup.onAnimationGroupPauseObservable.add(() => {\n sound.pause();\n });\n }\n });\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new MSFT_audio_emitter(loader));"]}
1
+ {"version":3,"file":"MSFT_audio_emitter.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,mCAAmC,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAEnD,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAE3E,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAIpE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGtD,IAAM,IAAI,GAAG,oBAAoB,CAAC;AA0BlC;;GAEG;AACH;IAeI,cAAc;IACd,4BAAY,MAAkB;QAf9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAaxB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtD,CAAC;IAED,cAAc;IACP,oCAAO,GAAd;QACK,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;QAC5B,IAAI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cAAW,EAAE,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QACjG,OAAO,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;YACjD,IAAM,KAAK,GAAG,OAAO,CAAC,YAAa,CAAC,KAAK,CAAC;YAC1C,IAAI,KAAK,EAAE;gBACP,IAAI,qBAAqB,GAAG,IAAI,cAAc,CAAC,KAAK,CAAC,IAAI,EAAE,KAAI,CAAC,eAAe,CAAC,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;gBAC9I,gBAAgB,CAAC,SAAS,CAAC,QAAQ,CAAC,qBAAqB,CAAC,CAAC;gBAC3D,uEAAuE;gBACvE,qBAAqB,CAAC,6BAA6B,CAAC,GAAG,CAAC;oBACpD,KAAK,CAAC,IAAI,EAAE,CAAC;gBACjB,CAAC,CAAC,CAAC;gBACH,qBAAqB,CAAC,+BAA+B,CAAC,GAAG,CAAC;oBACtD,KAAK,CAAC,KAAK,EAAE,CAAC;gBAClB,CAAC,CAAC,CAAC;aACN;QACL,CAAC,CAAC,CAAC;IACP,CAAC;IACL,yBAAC;AAAD,CAAC,AA3ND,IA2NC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,kBAAkB,CAAC,MAAM,CAAC,EAA9B,CAA8B,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { Vector3 } from \"@babylonjs/core/Maths/math.vector\";\nimport { Tools } from \"@babylonjs/core/Misc/tools\";\nimport { AnimationGroup } from \"@babylonjs/core/Animations/animationGroup\";\nimport { AnimationEvent } from \"@babylonjs/core/Animations/animationEvent\";\nimport { TransformNode } from \"@babylonjs/core/Meshes/transformNode\";\nimport { Sound } from \"@babylonjs/core/Audio/sound\";\nimport { WeightedSound } from \"@babylonjs/core/Audio/weightedsound\";\n\nimport { IArrayItem, IScene, INode, IAnimation } from \"../glTFLoaderInterfaces\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\nimport { IMSFTAudioEmitter_Clip, IMSFTAudioEmitter_Emitter, IMSFTAudioEmitter_EmittersReference, IMSFTAudioEmitter_AnimationEvent, IMSFTAudioEmitter_AnimationEventAction } from 'babylonjs-gltf2interface';\n\nconst NAME = \"MSFT_audio_emitter\";\n\ninterface ILoaderClip extends IMSFTAudioEmitter_Clip, IArrayItem {\n _objectURL?: Promise<string>;\n}\n\ninterface ILoaderEmitter extends IMSFTAudioEmitter_Emitter, IArrayItem {\n _babylonData?: {\n sound?: WeightedSound;\n loaded: Promise<void>;\n };\n _babylonSounds: Sound[];\n}\n\ninterface IMSFTAudioEmitter {\n clips: ILoaderClip[];\n emitters: ILoaderEmitter[];\n}\n\ninterface ILoaderAnimationEvent extends IMSFTAudioEmitter_AnimationEvent, IArrayItem {\n}\n\ninterface ILoaderAnimationEvents {\n events: ILoaderAnimationEvent[];\n}\n\n/**\n * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)\n */\nexport class MSFT_audio_emitter implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n private _loader: GLTFLoader;\n private _clips: Array<ILoaderClip>;\n private _emitters: Array<ILoaderEmitter>;\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n (this._clips as any) = null;\n (this._emitters as any) = null;\n }\n\n /** @hidden */\n public onLoading(): void {\n const extensions = this._loader.gltf.extensions;\n if (extensions && extensions[this.name]) {\n const extension = extensions[this.name] as IMSFTAudioEmitter;\n\n this._clips = extension.clips;\n this._emitters = extension.emitters;\n\n ArrayItem.Assign(this._clips);\n ArrayItem.Assign(this._emitters);\n }\n }\n\n /** @hidden */\n public loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>> {\n return GLTFLoader.LoadExtensionAsync<IMSFTAudioEmitter_EmittersReference>(context, scene, this.name, (extensionContext, extension) => {\n const promises = new Array<Promise<any>>();\n\n promises.push(this._loader.loadSceneAsync(context, scene));\n\n for (const emitterIndex of extension.emitters) {\n const emitter = ArrayItem.Get(`${extensionContext}/emitters`, this._emitters, emitterIndex);\n if (emitter.refDistance != undefined || emitter.maxDistance != undefined || emitter.rolloffFactor != undefined ||\n emitter.distanceModel != undefined || emitter.innerAngle != undefined || emitter.outerAngle != undefined) {\n throw new Error(`${extensionContext}: Direction or Distance properties are not allowed on emitters attached to a scene`);\n }\n\n promises.push(this._loadEmitterAsync(`${extensionContext}/emitters/${emitter.index}`, emitter));\n }\n\n return Promise.all(promises).then(() => { });\n });\n }\n\n /** @hidden */\n public loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>> {\n return GLTFLoader.LoadExtensionAsync<IMSFTAudioEmitter_EmittersReference, TransformNode>(context, node, this.name, (extensionContext, extension) => {\n const promises = new Array<Promise<any>>();\n\n return this._loader.loadNodeAsync(extensionContext, node, (babylonMesh) => {\n for (const emitterIndex of extension.emitters) {\n const emitter = ArrayItem.Get(`${extensionContext}/emitters`, this._emitters, emitterIndex);\n promises.push(this._loadEmitterAsync(`${extensionContext}/emitters/${emitter.index}`, emitter).then(() => {\n for (const sound of emitter._babylonSounds) {\n sound.attachToMesh(babylonMesh);\n if (emitter.innerAngle != undefined || emitter.outerAngle != undefined) {\n sound.setLocalDirectionToMesh(Vector3.Forward());\n sound.setDirectionalCone(\n 2 * Tools.ToDegrees(emitter.innerAngle == undefined ? Math.PI : emitter.innerAngle),\n 2 * Tools.ToDegrees(emitter.outerAngle == undefined ? Math.PI : emitter.outerAngle),\n 0);\n }\n }\n }));\n }\n\n assign(babylonMesh);\n }).then((babylonMesh) => {\n return Promise.all(promises).then(() => {\n return babylonMesh;\n });\n });\n });\n }\n\n /** @hidden */\n public loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>> {\n return GLTFLoader.LoadExtensionAsync<ILoaderAnimationEvents, AnimationGroup>(context, animation, this.name, (extensionContext, extension) => {\n return this._loader.loadAnimationAsync(context, animation).then((babylonAnimationGroup) => {\n const promises = new Array<Promise<any>>();\n\n ArrayItem.Assign(extension.events);\n for (const event of extension.events) {\n promises.push(this._loadAnimationEventAsync(`${extensionContext}/events/${event.index}`, context, animation, event, babylonAnimationGroup));\n }\n\n return Promise.all(promises).then(() => {\n return babylonAnimationGroup;\n });\n });\n });\n }\n\n private _loadClipAsync(context: string, clip: ILoaderClip): Promise<string> {\n if (clip._objectURL) {\n return clip._objectURL;\n }\n\n let promise: Promise<ArrayBufferView>;\n if (clip.uri) {\n promise = this._loader.loadUriAsync(context, clip, clip.uri);\n }\n else {\n const bufferView = ArrayItem.Get(`${context}/bufferView`, this._loader.gltf.bufferViews, clip.bufferView);\n promise = this._loader.loadBufferViewAsync(`/bufferViews/${bufferView.index}`, bufferView);\n }\n\n clip._objectURL = promise.then((data) => {\n return URL.createObjectURL(new Blob([data], { type: clip.mimeType }));\n });\n\n return clip._objectURL;\n }\n\n private _loadEmitterAsync(context: string, emitter: ILoaderEmitter): Promise<void> {\n emitter._babylonSounds = emitter._babylonSounds || [];\n if (!emitter._babylonData) {\n const clipPromises = new Array<Promise<any>>();\n const name = emitter.name || `emitter${emitter.index}`;\n const options = {\n loop: false,\n autoplay: false,\n volume: emitter.volume == undefined ? 1 : emitter.volume,\n };\n\n for (let i = 0; i < emitter.clips.length; i++) {\n const clipContext = `/extensions/${this.name}/clips`;\n const clip = ArrayItem.Get(clipContext, this._clips, emitter.clips[i].clip);\n clipPromises.push(this._loadClipAsync(`${clipContext}/${emitter.clips[i].clip}`, clip).then((objectURL: string) => {\n const sound = emitter._babylonSounds[i] = new Sound(name, objectURL, this._loader.babylonScene, null, options);\n sound.refDistance = emitter.refDistance || 1;\n sound.maxDistance = emitter.maxDistance || 256;\n sound.rolloffFactor = emitter.rolloffFactor || 1;\n sound.distanceModel = emitter.distanceModel || 'exponential';\n }));\n }\n\n const promise = Promise.all(clipPromises).then(() => {\n const weights = emitter.clips.map((clip) => { return clip.weight || 1; });\n const weightedSound = new WeightedSound(emitter.loop || false, emitter._babylonSounds, weights);\n if (emitter.innerAngle) { weightedSound.directionalConeInnerAngle = 2 * Tools.ToDegrees(emitter.innerAngle); }\n if (emitter.outerAngle) { weightedSound.directionalConeOuterAngle = 2 * Tools.ToDegrees(emitter.outerAngle); }\n if (emitter.volume) { weightedSound.volume = emitter.volume; }\n emitter._babylonData!.sound = weightedSound;\n });\n\n emitter._babylonData = {\n loaded: promise\n };\n }\n\n return emitter._babylonData.loaded;\n }\n\n private _getEventAction(context: string, sound: WeightedSound, action: IMSFTAudioEmitter_AnimationEventAction, time: number, startOffset?: number): (currentFrame: number) => void {\n switch (action) {\n case IMSFTAudioEmitter_AnimationEventAction.play: {\n return (currentFrame: number) => {\n const frameOffset = (startOffset || 0) + (currentFrame - time);\n sound.play(frameOffset);\n };\n }\n case IMSFTAudioEmitter_AnimationEventAction.stop: {\n return (currentFrame: number) => {\n sound.stop();\n };\n }\n case IMSFTAudioEmitter_AnimationEventAction.pause: {\n return (currentFrame: number) => {\n sound.pause();\n };\n }\n default: {\n throw new Error(`${context}: Unsupported action ${action}`);\n }\n }\n }\n\n private _loadAnimationEventAsync(context: string, animationContext: string, animation: IAnimation, event: ILoaderAnimationEvent, babylonAnimationGroup: AnimationGroup): Promise<void> {\n if (babylonAnimationGroup.targetedAnimations.length == 0) {\n return Promise.resolve();\n }\n const babylonAnimation = babylonAnimationGroup.targetedAnimations[0];\n const emitterIndex = event.emitter;\n const emitter = ArrayItem.Get(`/extensions/${this.name}/emitters`, this._emitters, emitterIndex);\n return this._loadEmitterAsync(context, emitter).then(() => {\n const sound = emitter._babylonData!.sound;\n if (sound) {\n var babylonAnimationEvent = new AnimationEvent(event.time, this._getEventAction(context, sound, event.action, event.time, event.startOffset));\n babylonAnimation.animation.addEvent(babylonAnimationEvent);\n // Make sure all started audio stops when this animation is terminated.\n babylonAnimationGroup.onAnimationGroupEndObservable.add(() => {\n sound.stop();\n });\n babylonAnimationGroup.onAnimationGroupPauseObservable.add(() => {\n sound.pause();\n });\n }\n });\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new MSFT_audio_emitter(loader));"]}
@@ -6,7 +6,7 @@ import { Mesh } from "@babylonjs/core/Meshes/mesh";
6
6
  import { INode, IMaterial, IBuffer, IScene } from "../glTFLoaderInterfaces";
7
7
  import { IGLTFLoaderExtension } from "../glTFLoaderExtension";
8
8
  import { GLTFLoader } from "../glTFLoader";
9
- import { IProperty } from 'babylonjs-gltf2interface';
9
+ import { IProperty } from "babylonjs-gltf2interface";
10
10
  /**
11
11
  * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
12
12
  */
@@ -65,6 +65,7 @@ export declare class MSFT_lod implements IGLTFLoaderExtension {
65
65
  _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
66
66
  /** @hidden */
67
67
  loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
68
+ private _isMesh;
68
69
  private _loadBufferLOD;
69
70
  /**
70
71
  * Gets an array of LOD properties from lowest to highest.
@@ -1,6 +1,6 @@
1
- import { Observable } from "@babylonjs/core/Misc/observable";
2
- import { Deferred } from "@babylonjs/core/Misc/deferred";
3
- import { GLTFLoader, ArrayItem } from "../glTFLoader";
1
+ import { Observable } from "@babylonjs/core/Misc/observable.js";
2
+ import { Deferred } from "@babylonjs/core/Misc/deferred.js";
3
+ import { GLTFLoader, ArrayItem } from "../glTFLoader.js";
4
4
  var NAME = "MSFT_lod";
5
5
  /**
6
6
  * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
@@ -117,15 +117,49 @@ var MSFT_lod = /** @class */ (function () {
117
117
  var firstPromise;
118
118
  var nodeLODs = _this._getLODs(extensionContext, node, _this._loader.gltf.nodes, extension.ids);
119
119
  _this._loader.logOpen("" + extensionContext);
120
+ var transformNodes = [];
121
+ for (var indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) {
122
+ transformNodes.push(null);
123
+ }
120
124
  var _loop_3 = function (indexLOD) {
121
125
  var nodeLOD = nodeLODs[indexLOD];
122
126
  if (indexLOD !== 0) {
123
127
  _this._nodeIndexLOD = indexLOD;
124
128
  _this._nodeSignalLODs[indexLOD] = _this._nodeSignalLODs[indexLOD] || new Deferred();
125
129
  }
126
- var assign_1 = function (babylonTransformNode) { babylonTransformNode.setEnabled(false); };
127
- var promise = _this._loader.loadNodeAsync("/nodes/" + nodeLOD.index, nodeLOD, assign_1).then(function (babylonMesh) {
128
- if (indexLOD !== 0) {
130
+ var assignChild = function (babylonTransformNode, index) {
131
+ var _a, _b, _c;
132
+ babylonTransformNode.setEnabled(false);
133
+ transformNodes[index] = babylonTransformNode;
134
+ var fullArray = true;
135
+ for (var i = 0; i < transformNodes.length; i++) {
136
+ if (!transformNodes[i]) {
137
+ fullArray = false;
138
+ }
139
+ }
140
+ var lod0 = transformNodes[transformNodes.length - 1];
141
+ if (fullArray && lod0 && _this._isMesh(lod0)) {
142
+ var screenCoverages = (_c = (_b = (_a = lod0.metadata) === null || _a === void 0 ? void 0 : _a.gltf) === null || _b === void 0 ? void 0 : _b.extras) === null || _c === void 0 ? void 0 : _c.MSFT_screencoverage;
143
+ if (screenCoverages && screenCoverages.length) {
144
+ screenCoverages.reverse();
145
+ lod0.useLODScreenCoverage = true;
146
+ for (var i = 0; i < transformNodes.length - 1; i++) {
147
+ var transformNode = transformNodes[i];
148
+ if (transformNode && _this._isMesh(transformNode)) {
149
+ lod0.addLODLevel(screenCoverages[i + 1], transformNode);
150
+ }
151
+ }
152
+ if (screenCoverages[0] > 0) {
153
+ // Adding empty LOD
154
+ lod0.addLODLevel(screenCoverages[0], null);
155
+ }
156
+ }
157
+ }
158
+ };
159
+ var promise = _this._loader.loadNodeAsync("/nodes/" + nodeLOD.index, nodeLOD, function (node) { return assignChild(node, indexLOD); }).then(function (babylonMesh) {
160
+ var _a, _b, _c;
161
+ var screenCoverages = (_c = (_b = (_a = nodeLODs[nodeLODs.length - 1]._babylonTransformNode.metadata) === null || _a === void 0 ? void 0 : _a.gltf) === null || _b === void 0 ? void 0 : _b.extras) === null || _c === void 0 ? void 0 : _c.MSFT_screencoverage;
162
+ if (indexLOD !== 0 && !screenCoverages) {
129
163
  // TODO: should not rely on _babylonTransformNode
130
164
  var previousNodeLOD = nodeLODs[indexLOD - 1];
131
165
  if (previousNodeLOD._babylonTransformNode) {
@@ -133,6 +167,7 @@ var MSFT_lod = /** @class */ (function () {
133
167
  delete previousNodeLOD._babylonTransformNode;
134
168
  }
135
169
  }
170
+ assign(babylonMesh);
136
171
  babylonMesh.setEnabled(true);
137
172
  return babylonMesh;
138
173
  });
@@ -168,11 +203,13 @@ var MSFT_lod = /** @class */ (function () {
168
203
  if (indexLOD !== 0) {
169
204
  _this._materialIndexLOD = indexLOD;
170
205
  }
171
- var promise = _this._loader._loadMaterialAsync("/materials/" + materialLOD.index, materialLOD, babylonMesh, babylonDrawMode, function (babylonMaterial) {
206
+ var promise = _this._loader
207
+ ._loadMaterialAsync("/materials/" + materialLOD.index, materialLOD, babylonMesh, babylonDrawMode, function (babylonMaterial) {
172
208
  if (indexLOD === 0) {
173
209
  assign(babylonMaterial);
174
210
  }
175
- }).then(function (babylonMaterial) {
211
+ })
212
+ .then(function (babylonMaterial) {
176
213
  if (indexLOD !== 0) {
177
214
  assign(babylonMaterial);
178
215
  // TODO: should not rely on _data
@@ -257,6 +294,9 @@ var MSFT_lod = /** @class */ (function () {
257
294
  }
258
295
  return null;
259
296
  };
297
+ MSFT_lod.prototype._isMesh = function (mesh) {
298
+ return !!mesh.addLODLevel;
299
+ };
260
300
  MSFT_lod.prototype._loadBufferLOD = function (bufferLODs, indexLOD) {
261
301
  var bufferLOD = bufferLODs[indexLOD];
262
302
  if (bufferLOD) {
@@ -1 +1 @@
1
- {"version":3,"file":"MSFT_lod.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAOzD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGtD,IAAM,IAAI,GAAG,UAAU,CAAC;AAQxB;;GAEG;AACH;IAiDI,cAAc;IACd,kBAAY,MAAkB;QAjD9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QAEnB;;WAEG;QACI,kBAAa,GAAG,EAAE,CAAC;QAE1B;;;;WAIG;QACI,+BAA0B,GAAG,IAAI,UAAU,EAAU,CAAC;QAE7D;;;;WAIG;QACI,mCAA8B,GAAG,IAAI,UAAU,EAAU,CAAC;QAIzD,gBAAW,GAAG,IAAI,KAAK,EAAe,CAAC;QAEvC,kBAAa,GAAqB,IAAI,CAAC;QACvC,oBAAe,GAAG,IAAI,KAAK,EAAkB,CAAC;QAC9C,qBAAgB,GAAG,IAAI,KAAK,EAAuB,CAAC;QACpD,oBAAe,GAAG,IAAI,KAAK,EAAe,CAAC;QAE3C,sBAAiB,GAAqB,IAAI,CAAC;QAC3C,wBAAmB,GAAG,IAAI,KAAK,EAAkB,CAAC;QAClD,yBAAoB,GAAG,IAAI,KAAK,EAAuB,CAAC;QACxD,wBAAmB,GAAG,IAAI,KAAK,EAAe,CAAC;QAInD,IAAI,CAAC,OAAO,GAAG,MAAM,CA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S,EAAnC,cAAmC,EAAnC,IAAmC,EAAE;gBAA9D,IAAM,eAAe,SAAA;gBACtB,IAAI,eAAe,CAAC,UAAU,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC,EAAE;oBACvD,OAAO,eAAe,CAAC,QAAQ,CAAC,CAAC;iBACpC;aACJ;SACJ;QAED,KAAK,IAAM,QAAQ,IAAI,eAAe,EAAE;YACpC,eAAe,CAAC,QAAQ,CAAC,CAAC,OAAO,EAAE,CAAC;SACvC;IACL,CAAC;IACL,eAAC;AAAD,CAAC,AA7WD,IA6WC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,QAAQ,CAAC,MAAM,CAAC,EAApB,CAAoB,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { Observable } from \"@babylonjs/core/Misc/observable\";\nimport { Deferred } from \"@babylonjs/core/Misc/deferred\";\nimport { Material } from \"@babylonjs/core/Materials/material\";\nimport { TransformNode } from \"@babylonjs/core/Meshes/transformNode\";\nimport { Mesh } from \"@babylonjs/core/Meshes/mesh\";\nimport { BaseTexture } from '@babylonjs/core/Materials/Textures/baseTexture';\nimport { INode, IMaterial, IBuffer, IScene } from \"../glTFLoaderInterfaces\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\nimport { IProperty, IMSFTLOD } from 'babylonjs-gltf2interface';\n\nconst NAME = \"MSFT_lod\";\n\ninterface IBufferInfo {\n start: number;\n end: number;\n loaded: Deferred<ArrayBufferView>;\n}\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)\n */\nexport class MSFT_lod implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n /**\n * Defines a number that determines the order the extensions are applied.\n */\n public order = 100;\n\n /**\n * Maximum number of LODs to load, starting from the lowest LOD.\n */\n public maxLODsToLoad = 10;\n\n /**\n * Observable raised when all node LODs of one level are loaded.\n * The event data is the index of the loaded LOD starting from zero.\n * Dispose the loader to cancel the loading of the next level of LODs.\n */\n public onNodeLODsLoadedObservable = new Observable<number>();\n\n /**\n * Observable raised when all material LODs of one level are loaded.\n * The event data is the index of the loaded LOD starting from zero.\n * Dispose the loader to cancel the loading of the next level of LODs.\n */\n public onMaterialLODsLoadedObservable = new Observable<number>();\n\n private _loader: GLTFLoader;\n\n private _bufferLODs = new Array<IBufferInfo>();\n\n private _nodeIndexLOD: Nullable<number> = null;\n private _nodeSignalLODs = new Array<Deferred<void>>();\n private _nodePromiseLODs = new Array<Array<Promise<any>>>();\n private _nodeBufferLODs = new Array<IBufferInfo>();\n\n private _materialIndexLOD: Nullable<number> = null;\n private _materialSignalLODs = new Array<Deferred<void>>();\n private _materialPromiseLODs = new Array<Array<Promise<any>>>();\n private _materialBufferLODs = new Array<IBufferInfo>();\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n\n this._nodeIndexLOD = null;\n this._nodeSignalLODs.length = 0;\n this._nodePromiseLODs.length = 0;\n this._nodeBufferLODs.length = 0;\n\n this._materialIndexLOD = null;\n this._materialSignalLODs.length = 0;\n this._materialPromiseLODs.length = 0;\n this._materialBufferLODs.length = 0;\n\n this.onMaterialLODsLoadedObservable.clear();\n this.onNodeLODsLoadedObservable.clear();\n }\n\n /** @hidden */\n public onReady(): void {\n for (let indexLOD = 0; indexLOD < this._nodePromiseLODs.length; indexLOD++) {\n const promise = Promise.all(this._nodePromiseLODs[indexLOD]).then(() => {\n if (indexLOD !== 0) {\n this._loader.endPerformanceCounter(`Node LOD ${indexLOD}`);\n this._loader.log(`Loaded node LOD ${indexLOD}`);\n }\n\n this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);\n\n if (indexLOD !== this._nodePromiseLODs.length - 1) {\n this._loader.startPerformanceCounter(`Node LOD ${indexLOD + 1}`);\n this._loadBufferLOD(this._nodeBufferLODs, indexLOD + 1);\n if (this._nodeSignalLODs[indexLOD]) {\n this._nodeSignalLODs[indexLOD].resolve();\n }\n }\n });\n\n this._loader._completePromises.push(promise);\n }\n\n for (let indexLOD = 0; indexLOD < this._materialPromiseLODs.length; indexLOD++) {\n const promise = Promise.all(this._materialPromiseLODs[indexLOD]).then(() => {\n if (indexLOD !== 0) {\n this._loader.endPerformanceCounter(`Material LOD ${indexLOD}`);\n this._loader.log(`Loaded material LOD ${indexLOD}`);\n }\n\n this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);\n\n if (indexLOD !== this._materialPromiseLODs.length - 1) {\n this._loader.startPerformanceCounter(`Material LOD ${indexLOD + 1}`);\n this._loadBufferLOD(this._materialBufferLODs, indexLOD + 1);\n if (this._materialSignalLODs[indexLOD]) {\n this._materialSignalLODs[indexLOD].resolve();\n }\n }\n });\n\n this._loader._completePromises.push(promise);\n }\n }\n\n /** @hidden */\n public loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>> {\n const promise = this._loader.loadSceneAsync(context, scene);\n this._loadBufferLOD(this._bufferLODs, 0);\n return promise;\n }\n\n /** @hidden */\n public loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>> {\n return GLTFLoader.LoadExtensionAsync<IMSFTLOD, TransformNode>(context, node, this.name, (extensionContext, extension) => {\n let firstPromise: Promise<TransformNode>;\n\n const nodeLODs = this._getLODs(extensionContext, node, this._loader.gltf.nodes, extension.ids);\n this._loader.logOpen(`${extensionContext}`);\n\n for (let indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) {\n const nodeLOD = nodeLODs[indexLOD];\n\n if (indexLOD !== 0) {\n this._nodeIndexLOD = indexLOD;\n this._nodeSignalLODs[indexLOD] = this._nodeSignalLODs[indexLOD] || new Deferred();\n }\n\n const assign = (babylonTransformNode: TransformNode) => { babylonTransformNode.setEnabled(false); };\n const promise = this._loader.loadNodeAsync(`/nodes/${nodeLOD.index}`, nodeLOD, assign).then((babylonMesh) => {\n if (indexLOD !== 0) {\n // TODO: should not rely on _babylonTransformNode\n const previousNodeLOD = nodeLODs[indexLOD - 1];\n if (previousNodeLOD._babylonTransformNode) {\n this._disposeTransformNode(previousNodeLOD._babylonTransformNode);\n delete previousNodeLOD._babylonTransformNode;\n }\n }\n\n babylonMesh.setEnabled(true);\n return babylonMesh;\n });\n\n this._nodePromiseLODs[indexLOD] = this._nodePromiseLODs[indexLOD] || [];\n\n if (indexLOD === 0) {\n firstPromise = promise;\n }\n else {\n this._nodeIndexLOD = null;\n this._nodePromiseLODs[indexLOD].push(promise);\n }\n }\n\n this._loader.logClose();\n return firstPromise!;\n });\n }\n\n /** @hidden */\n public _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>> {\n // Don't load material LODs if already loading a node LOD.\n if (this._nodeIndexLOD) {\n return null;\n }\n\n return GLTFLoader.LoadExtensionAsync<IMSFTLOD, Material>(context, material, this.name, (extensionContext, extension) => {\n let firstPromise: Promise<Material>;\n\n const materialLODs = this._getLODs(extensionContext, material, this._loader.gltf.materials, extension.ids);\n this._loader.logOpen(`${extensionContext}`);\n\n for (let indexLOD = 0; indexLOD < materialLODs.length; indexLOD++) {\n const materialLOD = materialLODs[indexLOD];\n\n if (indexLOD !== 0) {\n this._materialIndexLOD = indexLOD;\n }\n\n const promise = this._loader._loadMaterialAsync(`/materials/${materialLOD.index}`, materialLOD, babylonMesh, babylonDrawMode, (babylonMaterial) => {\n if (indexLOD === 0) {\n assign(babylonMaterial);\n }\n }).then((babylonMaterial) => {\n if (indexLOD !== 0) {\n assign(babylonMaterial);\n\n // TODO: should not rely on _data\n const previousDataLOD = materialLODs[indexLOD - 1]._data!;\n if (previousDataLOD[babylonDrawMode]) {\n this._disposeMaterials([previousDataLOD[babylonDrawMode].babylonMaterial]);\n delete previousDataLOD[babylonDrawMode];\n }\n }\n\n return babylonMaterial;\n });\n\n this._materialPromiseLODs[indexLOD] = this._materialPromiseLODs[indexLOD] || [];\n\n if (indexLOD === 0) {\n firstPromise = promise;\n }\n else {\n this._materialIndexLOD = null;\n this._materialPromiseLODs[indexLOD].push(promise);\n }\n }\n\n this._loader.logClose();\n return firstPromise!;\n });\n }\n\n /** @hidden */\n public _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>> {\n // Defer the loading of uris if loading a node or material LOD.\n if (this._nodeIndexLOD !== null) {\n this._loader.log(`deferred`);\n const previousIndexLOD = this._nodeIndexLOD - 1;\n this._nodeSignalLODs[previousIndexLOD] = this._nodeSignalLODs[previousIndexLOD] || new Deferred<void>();\n return this._nodeSignalLODs[this._nodeIndexLOD - 1].promise.then(() => {\n return this._loader.loadUriAsync(context, property, uri);\n });\n }\n else if (this._materialIndexLOD !== null) {\n this._loader.log(`deferred`);\n const previousIndexLOD = this._materialIndexLOD - 1;\n this._materialSignalLODs[previousIndexLOD] = this._materialSignalLODs[previousIndexLOD] || new Deferred<void>();\n return this._materialSignalLODs[previousIndexLOD].promise.then(() => {\n return this._loader.loadUriAsync(context, property, uri);\n });\n }\n\n return null;\n }\n\n /** @hidden */\n public loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>> {\n if (this._loader.parent.useRangeRequests && !buffer.uri) {\n if (!this._loader.bin) {\n throw new Error(`${context}: Uri is missing or the binary glTF is missing its binary chunk`);\n }\n\n const loadAsync = (bufferLODs: Array<IBufferInfo>, indexLOD: number) => {\n const start = byteOffset;\n const end = start + byteLength - 1;\n let bufferLOD = bufferLODs[indexLOD];\n if (bufferLOD) {\n bufferLOD.start = Math.min(bufferLOD.start, start);\n bufferLOD.end = Math.max(bufferLOD.end, end);\n }\n else {\n bufferLOD = { start: start, end: end, loaded: new Deferred() };\n bufferLODs[indexLOD] = bufferLOD;\n }\n\n return bufferLOD.loaded.promise.then((data) => {\n return new Uint8Array(data.buffer, data.byteOffset + byteOffset - bufferLOD.start, byteLength);\n });\n };\n\n this._loader.log(`deferred`);\n\n if (this._nodeIndexLOD !== null) {\n return loadAsync(this._nodeBufferLODs, this._nodeIndexLOD);\n }\n else if (this._materialIndexLOD !== null) {\n return loadAsync(this._materialBufferLODs, this._materialIndexLOD);\n }\n else {\n return loadAsync(this._bufferLODs, 0);\n }\n }\n\n return null;\n }\n\n private _loadBufferLOD(bufferLODs: Array<IBufferInfo>, indexLOD: number): void {\n const bufferLOD = bufferLODs[indexLOD];\n if (bufferLOD) {\n this._loader.log(`Loading buffer range [${bufferLOD.start}-${bufferLOD.end}]`);\n this._loader.bin!.readAsync(bufferLOD.start, bufferLOD.end - bufferLOD.start + 1).then((data) => {\n bufferLOD.loaded.resolve(data);\n }, (error) => {\n bufferLOD.loaded.reject(error);\n });\n }\n }\n\n /**\n * Gets an array of LOD properties from lowest to highest.\n */\n private _getLODs<T>(context: string, property: T, array: ArrayLike<T> | undefined, ids: number[]): T[] {\n if (this.maxLODsToLoad <= 0) {\n throw new Error(\"maxLODsToLoad must be greater than zero\");\n }\n\n const properties = new Array<T>();\n\n for (let i = ids.length - 1; i >= 0; i--) {\n properties.push(ArrayItem.Get(`${context}/ids/${ids[i]}`, array, ids[i]));\n if (properties.length === this.maxLODsToLoad) {\n return properties;\n }\n }\n\n properties.push(property);\n return properties;\n }\n\n private _disposeTransformNode(babylonTransformNode: TransformNode): void {\n const babylonMaterials = new Array<Material>();\n const babylonMaterial = (babylonTransformNode as Mesh).material;\n if (babylonMaterial) {\n babylonMaterials.push(babylonMaterial);\n }\n for (const babylonMesh of babylonTransformNode.getChildMeshes()) {\n if (babylonMesh.material) {\n babylonMaterials.push(babylonMesh.material);\n }\n }\n\n babylonTransformNode.dispose();\n\n const babylonMaterialsToDispose = babylonMaterials.filter((babylonMaterial) => this._loader.babylonScene.meshes.every((mesh) => mesh.material != babylonMaterial));\n this._disposeMaterials(babylonMaterialsToDispose);\n }\n\n private _disposeMaterials(babylonMaterials: Material[]): void {\n const babylonTextures: { [uniqueId: number]: BaseTexture } = {};\n\n for (const babylonMaterial of babylonMaterials) {\n for (const babylonTexture of babylonMaterial.getActiveTextures()) {\n babylonTextures[babylonTexture.uniqueId] = babylonTexture;\n }\n\n babylonMaterial.dispose();\n }\n\n for (const uniqueId in babylonTextures) {\n for (const babylonMaterial of this._loader.babylonScene.materials) {\n if (babylonMaterial.hasTexture(babylonTextures[uniqueId])) {\n delete babylonTextures[uniqueId];\n }\n }\n }\n\n for (const uniqueId in babylonTextures) {\n babylonTextures[uniqueId].dispose();\n }\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new MSFT_lod(loader));"]}
1
+ {"version":3,"file":"MSFT_lod.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAAE,QAAQ,EAAE,MAAM,+BAA+B,CAAC;AAOzD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAGtD,IAAM,IAAI,GAAG,UAAU,CAAC;AAQxB;;GAEG;AACH;IAiDI,cAAc;IACd,kBAAY,MAAkB;QAjD9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAO5B;;WAEG;QACI,UAAK,GAAG,GAAG,CAAC;QAEnB;;WAEG;QACI,kBAAa,GAAG,EAAE,CAAC;QAE1B;;;;WAIG;QACI,+BAA0B,GAAG,IAAI,UAAU,EAAU,CAAC;QAE7D;;;;WAIG;QACI,mCAA8B,GAAG,IAAI,UAAU,EAAU,CAAC;QAIzD,gBAAW,GAAG,IAAI,KAAK,EAAe,CAAC;QAEvC,kBAAa,GAAqB,IAAI,CAAC;QACvC,o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L,eAAC;AAAD,CAAC,AA7ZD,IA6ZC;;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAC,MAAM,IAAK,OAAA,IAAI,QAAQ,CAAC,MAAM,CAAC,EAApB,CAAoB,CAAC,CAAC","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { Observable } from \"@babylonjs/core/Misc/observable\";\nimport { Deferred } from \"@babylonjs/core/Misc/deferred\";\nimport { Material } from \"@babylonjs/core/Materials/material\";\nimport { TransformNode } from \"@babylonjs/core/Meshes/transformNode\";\nimport { Mesh } from \"@babylonjs/core/Meshes/mesh\";\nimport { BaseTexture } from \"@babylonjs/core/Materials/Textures/baseTexture\";\nimport { INode, IMaterial, IBuffer, IScene } from \"../glTFLoaderInterfaces\";\nimport { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\nimport { IProperty, IMSFTLOD } from \"babylonjs-gltf2interface\";\n\nconst NAME = \"MSFT_lod\";\n\ninterface IBufferInfo {\n start: number;\n end: number;\n loaded: Deferred<ArrayBufferView>;\n}\n\n/**\n * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)\n */\nexport class MSFT_lod implements IGLTFLoaderExtension {\n /**\n * The name of this extension.\n */\n public readonly name = NAME;\n\n /**\n * Defines whether this extension is enabled.\n */\n public enabled: boolean;\n\n /**\n * Defines a number that determines the order the extensions are applied.\n */\n public order = 100;\n\n /**\n * Maximum number of LODs to load, starting from the lowest LOD.\n */\n public maxLODsToLoad = 10;\n\n /**\n * Observable raised when all node LODs of one level are loaded.\n * The event data is the index of the loaded LOD starting from zero.\n * Dispose the loader to cancel the loading of the next level of LODs.\n */\n public onNodeLODsLoadedObservable = new Observable<number>();\n\n /**\n * Observable raised when all material LODs of one level are loaded.\n * The event data is the index of the loaded LOD starting from zero.\n * Dispose the loader to cancel the loading of the next level of LODs.\n */\n public onMaterialLODsLoadedObservable = new Observable<number>();\n\n private _loader: GLTFLoader;\n\n private _bufferLODs = new Array<IBufferInfo>();\n\n private _nodeIndexLOD: Nullable<number> = null;\n private _nodeSignalLODs = new Array<Deferred<void>>();\n private _nodePromiseLODs = new Array<Array<Promise<any>>>();\n private _nodeBufferLODs = new Array<IBufferInfo>();\n\n private _materialIndexLOD: Nullable<number> = null;\n private _materialSignalLODs = new Array<Deferred<void>>();\n private _materialPromiseLODs = new Array<Array<Promise<any>>>();\n private _materialBufferLODs = new Array<IBufferInfo>();\n\n /** @hidden */\n constructor(loader: GLTFLoader) {\n this._loader = loader;\n this.enabled = this._loader.isExtensionUsed(NAME);\n }\n\n /** @hidden */\n public dispose() {\n (this._loader as any) = null;\n\n this._nodeIndexLOD = null;\n this._nodeSignalLODs.length = 0;\n this._nodePromiseLODs.length = 0;\n this._nodeBufferLODs.length = 0;\n\n this._materialIndexLOD = null;\n this._materialSignalLODs.length = 0;\n this._materialPromiseLODs.length = 0;\n this._materialBufferLODs.length = 0;\n\n this.onMaterialLODsLoadedObservable.clear();\n this.onNodeLODsLoadedObservable.clear();\n }\n\n /** @hidden */\n public onReady(): void {\n for (let indexLOD = 0; indexLOD < this._nodePromiseLODs.length; indexLOD++) {\n const promise = Promise.all(this._nodePromiseLODs[indexLOD]).then(() => {\n if (indexLOD !== 0) {\n this._loader.endPerformanceCounter(`Node LOD ${indexLOD}`);\n this._loader.log(`Loaded node LOD ${indexLOD}`);\n }\n\n this.onNodeLODsLoadedObservable.notifyObservers(indexLOD);\n\n if (indexLOD !== this._nodePromiseLODs.length - 1) {\n this._loader.startPerformanceCounter(`Node LOD ${indexLOD + 1}`);\n this._loadBufferLOD(this._nodeBufferLODs, indexLOD + 1);\n if (this._nodeSignalLODs[indexLOD]) {\n this._nodeSignalLODs[indexLOD].resolve();\n }\n }\n });\n\n this._loader._completePromises.push(promise);\n }\n\n for (let indexLOD = 0; indexLOD < this._materialPromiseLODs.length; indexLOD++) {\n const promise = Promise.all(this._materialPromiseLODs[indexLOD]).then(() => {\n if (indexLOD !== 0) {\n this._loader.endPerformanceCounter(`Material LOD ${indexLOD}`);\n this._loader.log(`Loaded material LOD ${indexLOD}`);\n }\n\n this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD);\n\n if (indexLOD !== this._materialPromiseLODs.length - 1) {\n this._loader.startPerformanceCounter(`Material LOD ${indexLOD + 1}`);\n this._loadBufferLOD(this._materialBufferLODs, indexLOD + 1);\n if (this._materialSignalLODs[indexLOD]) {\n this._materialSignalLODs[indexLOD].resolve();\n }\n }\n });\n\n this._loader._completePromises.push(promise);\n }\n }\n\n /** @hidden */\n public loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>> {\n const promise = this._loader.loadSceneAsync(context, scene);\n this._loadBufferLOD(this._bufferLODs, 0);\n return promise;\n }\n\n /** @hidden */\n public loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>> {\n return GLTFLoader.LoadExtensionAsync<IMSFTLOD, TransformNode>(context, node, this.name, (extensionContext, extension) => {\n let firstPromise: Promise<TransformNode>;\n\n const nodeLODs = this._getLODs(extensionContext, node, this._loader.gltf.nodes, extension.ids);\n this._loader.logOpen(`${extensionContext}`);\n const transformNodes: Nullable<TransformNode>[] = [];\n\n for (let indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) {\n transformNodes.push(null);\n }\n\n for (let indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) {\n const nodeLOD = nodeLODs[indexLOD];\n\n if (indexLOD !== 0) {\n this._nodeIndexLOD = indexLOD;\n this._nodeSignalLODs[indexLOD] = this._nodeSignalLODs[indexLOD] || new Deferred();\n }\n\n const assignChild = (babylonTransformNode: TransformNode, index: number) => {\n babylonTransformNode.setEnabled(false);\n transformNodes[index] = babylonTransformNode;\n\n let fullArray = true;\n for (let i = 0; i < transformNodes.length; i++) {\n if (!transformNodes[i]) {\n fullArray = false;\n }\n }\n\n const lod0 = transformNodes[transformNodes.length - 1];\n if (fullArray && lod0 && this._isMesh(lod0)) {\n const screenCoverages = lod0.metadata?.gltf?.extras?.MSFT_screencoverage as number[];\n\n if (screenCoverages && screenCoverages.length) {\n screenCoverages.reverse();\n lod0.useLODScreenCoverage = true;\n for (let i = 0; i < transformNodes.length - 1; i++) {\n const transformNode = transformNodes[i];\n if (transformNode && this._isMesh(transformNode)) {\n lod0.addLODLevel(screenCoverages[i + 1], transformNode);\n }\n }\n if (screenCoverages[0] > 0) {\n // Adding empty LOD\n lod0.addLODLevel(screenCoverages[0], null);\n }\n }\n }\n };\n\n const promise = this._loader.loadNodeAsync(`/nodes/${nodeLOD.index}`, nodeLOD, (node: TransformNode) => assignChild(node, indexLOD)).then((babylonMesh) => {\n const screenCoverages = (nodeLODs[nodeLODs.length - 1]._babylonTransformNode as Mesh).metadata?.gltf?.extras?.MSFT_screencoverage;\n\n if (indexLOD !== 0 && !screenCoverages) {\n // TODO: should not rely on _babylonTransformNode\n const previousNodeLOD = nodeLODs[indexLOD - 1];\n if (previousNodeLOD._babylonTransformNode) {\n this._disposeTransformNode(previousNodeLOD._babylonTransformNode);\n delete previousNodeLOD._babylonTransformNode;\n }\n }\n\n assign(babylonMesh);\n babylonMesh.setEnabled(true);\n return babylonMesh;\n });\n\n this._nodePromiseLODs[indexLOD] = this._nodePromiseLODs[indexLOD] || [];\n\n if (indexLOD === 0) {\n firstPromise = promise;\n } else {\n this._nodeIndexLOD = null;\n this._nodePromiseLODs[indexLOD].push(promise);\n }\n }\n\n this._loader.logClose();\n return firstPromise!;\n });\n }\n\n /** @hidden */\n public _loadMaterialAsync(\n context: string,\n material: IMaterial,\n babylonMesh: Nullable<Mesh>,\n babylonDrawMode: number,\n assign: (babylonMaterial: Material) => void\n ): Nullable<Promise<Material>> {\n // Don't load material LODs if already loading a node LOD.\n if (this._nodeIndexLOD) {\n return null;\n }\n\n return GLTFLoader.LoadExtensionAsync<IMSFTLOD, Material>(context, material, this.name, (extensionContext, extension) => {\n let firstPromise: Promise<Material>;\n\n const materialLODs = this._getLODs(extensionContext, material, this._loader.gltf.materials, extension.ids);\n this._loader.logOpen(`${extensionContext}`);\n\n for (let indexLOD = 0; indexLOD < materialLODs.length; indexLOD++) {\n const materialLOD = materialLODs[indexLOD];\n\n if (indexLOD !== 0) {\n this._materialIndexLOD = indexLOD;\n }\n\n const promise = this._loader\n ._loadMaterialAsync(`/materials/${materialLOD.index}`, materialLOD, babylonMesh, babylonDrawMode, (babylonMaterial) => {\n if (indexLOD === 0) {\n assign(babylonMaterial);\n }\n })\n .then((babylonMaterial) => {\n if (indexLOD !== 0) {\n assign(babylonMaterial);\n\n // TODO: should not rely on _data\n const previousDataLOD = materialLODs[indexLOD - 1]._data!;\n if (previousDataLOD[babylonDrawMode]) {\n this._disposeMaterials([previousDataLOD[babylonDrawMode].babylonMaterial]);\n delete previousDataLOD[babylonDrawMode];\n }\n }\n\n return babylonMaterial;\n });\n\n this._materialPromiseLODs[indexLOD] = this._materialPromiseLODs[indexLOD] || [];\n\n if (indexLOD === 0) {\n firstPromise = promise;\n } else {\n this._materialIndexLOD = null;\n this._materialPromiseLODs[indexLOD].push(promise);\n }\n }\n\n this._loader.logClose();\n return firstPromise!;\n });\n }\n\n /** @hidden */\n public _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>> {\n // Defer the loading of uris if loading a node or material LOD.\n if (this._nodeIndexLOD !== null) {\n this._loader.log(`deferred`);\n const previousIndexLOD = this._nodeIndexLOD - 1;\n this._nodeSignalLODs[previousIndexLOD] = this._nodeSignalLODs[previousIndexLOD] || new Deferred<void>();\n return this._nodeSignalLODs[this._nodeIndexLOD - 1].promise.then(() => {\n return this._loader.loadUriAsync(context, property, uri);\n });\n } else if (this._materialIndexLOD !== null) {\n this._loader.log(`deferred`);\n const previousIndexLOD = this._materialIndexLOD - 1;\n this._materialSignalLODs[previousIndexLOD] = this._materialSignalLODs[previousIndexLOD] || new Deferred<void>();\n return this._materialSignalLODs[previousIndexLOD].promise.then(() => {\n return this._loader.loadUriAsync(context, property, uri);\n });\n }\n\n return null;\n }\n\n /** @hidden */\n public loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>> {\n if (this._loader.parent.useRangeRequests && !buffer.uri) {\n if (!this._loader.bin) {\n throw new Error(`${context}: Uri is missing or the binary glTF is missing its binary chunk`);\n }\n\n const loadAsync = (bufferLODs: Array<IBufferInfo>, indexLOD: number) => {\n const start = byteOffset;\n const end = start + byteLength - 1;\n let bufferLOD = bufferLODs[indexLOD];\n if (bufferLOD) {\n bufferLOD.start = Math.min(bufferLOD.start, start);\n bufferLOD.end = Math.max(bufferLOD.end, end);\n } else {\n bufferLOD = { start: start, end: end, loaded: new Deferred() };\n bufferLODs[indexLOD] = bufferLOD;\n }\n\n return bufferLOD.loaded.promise.then((data) => {\n return new Uint8Array(data.buffer, data.byteOffset + byteOffset - bufferLOD.start, byteLength);\n });\n };\n\n this._loader.log(`deferred`);\n\n if (this._nodeIndexLOD !== null) {\n return loadAsync(this._nodeBufferLODs, this._nodeIndexLOD);\n } else if (this._materialIndexLOD !== null) {\n return loadAsync(this._materialBufferLODs, this._materialIndexLOD);\n } else {\n return loadAsync(this._bufferLODs, 0);\n }\n }\n\n return null;\n }\n\n private _isMesh(mesh: TransformNode | Mesh): mesh is Mesh {\n return !!(mesh as Mesh).addLODLevel;\n }\n\n private _loadBufferLOD(bufferLODs: Array<IBufferInfo>, indexLOD: number): void {\n const bufferLOD = bufferLODs[indexLOD];\n if (bufferLOD) {\n this._loader.log(`Loading buffer range [${bufferLOD.start}-${bufferLOD.end}]`);\n this._loader.bin!.readAsync(bufferLOD.start, bufferLOD.end - bufferLOD.start + 1).then(\n (data) => {\n bufferLOD.loaded.resolve(data);\n },\n (error) => {\n bufferLOD.loaded.reject(error);\n }\n );\n }\n }\n\n /**\n * Gets an array of LOD properties from lowest to highest.\n */\n private _getLODs<T>(context: string, property: T, array: ArrayLike<T> | undefined, ids: number[]): T[] {\n if (this.maxLODsToLoad <= 0) {\n throw new Error(\"maxLODsToLoad must be greater than zero\");\n }\n\n const properties = new Array<T>();\n\n for (let i = ids.length - 1; i >= 0; i--) {\n properties.push(ArrayItem.Get(`${context}/ids/${ids[i]}`, array, ids[i]));\n if (properties.length === this.maxLODsToLoad) {\n return properties;\n }\n }\n\n properties.push(property);\n return properties;\n }\n\n private _disposeTransformNode(babylonTransformNode: TransformNode): void {\n const babylonMaterials = new Array<Material>();\n const babylonMaterial = (babylonTransformNode as Mesh).material;\n if (babylonMaterial) {\n babylonMaterials.push(babylonMaterial);\n }\n for (const babylonMesh of babylonTransformNode.getChildMeshes()) {\n if (babylonMesh.material) {\n babylonMaterials.push(babylonMesh.material);\n }\n }\n\n babylonTransformNode.dispose();\n\n const babylonMaterialsToDispose = babylonMaterials.filter((babylonMaterial) => this._loader.babylonScene.meshes.every((mesh) => mesh.material != babylonMaterial));\n this._disposeMaterials(babylonMaterialsToDispose);\n }\n\n private _disposeMaterials(babylonMaterials: Material[]): void {\n const babylonTextures: { [uniqueId: number]: BaseTexture } = {};\n\n for (const babylonMaterial of babylonMaterials) {\n for (const babylonTexture of babylonMaterial.getActiveTextures()) {\n babylonTextures[babylonTexture.uniqueId] = babylonTexture;\n }\n\n babylonMaterial.dispose();\n }\n\n for (const uniqueId in babylonTextures) {\n for (const babylonMaterial of this._loader.babylonScene.materials) {\n if (babylonMaterial.hasTexture(babylonTextures[uniqueId])) {\n delete babylonTextures[uniqueId];\n }\n }\n }\n\n for (const uniqueId in babylonTextures) {\n babylonTextures[uniqueId].dispose();\n }\n }\n}\n\nGLTFLoader.RegisterExtension(NAME, (loader) => new MSFT_lod(loader));\n"]}
@@ -1,5 +1,5 @@
1
- import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial";
2
- import { GLTFLoader } from "../glTFLoader";
1
+ import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
2
+ import { GLTFLoader } from "../glTFLoader.js";
3
3
  var NAME = "MSFT_minecraftMesh";
4
4
  /** @hidden */
5
5
  var MSFT_minecraftMesh = /** @class */ (function () {
@@ -1,5 +1,5 @@
1
- import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial";
2
- import { GLTFLoader } from "../glTFLoader";
1
+ import { PBRMaterial } from "@babylonjs/core/Materials/PBR/pbrMaterial.js";
2
+ import { GLTFLoader } from "../glTFLoader.js";
3
3
  var NAME = "MSFT_sRGBFactors";
4
4
  /** @hidden */
5
5
  var MSFT_sRGBFactors = /** @class */ (function () {
@@ -13,6 +13,7 @@ export * from "./KHR_materials_ior";
13
13
  export * from "./KHR_materials_variants";
14
14
  export * from "./KHR_materials_transmission";
15
15
  export * from "./KHR_materials_translucency";
16
+ export * from "./KHR_materials_volume";
16
17
  export * from "./KHR_mesh_quantization";
17
18
  export * from "./KHR_texture_basisu";
18
19
  export * from "./KHR_texture_transform";
@@ -1,25 +1,26 @@
1
- export * from "./EXT_lights_image_based";
2
- export * from "./EXT_mesh_gpu_instancing";
3
- export * from "./EXT_meshopt_compression";
4
- export * from "./EXT_texture_webp";
5
- export * from "./KHR_draco_mesh_compression";
6
- export * from "./KHR_lights_punctual";
7
- export * from "./KHR_materials_pbrSpecularGlossiness";
8
- export * from "./KHR_materials_unlit";
9
- export * from "./KHR_materials_clearcoat";
10
- export * from "./KHR_materials_sheen";
11
- export * from "./KHR_materials_specular";
12
- export * from "./KHR_materials_ior";
13
- export * from "./KHR_materials_variants";
14
- export * from "./KHR_materials_transmission";
15
- export * from "./KHR_materials_translucency";
16
- export * from "./KHR_mesh_quantization";
17
- export * from "./KHR_texture_basisu";
18
- export * from "./KHR_texture_transform";
19
- export * from "./KHR_xmp_json_ld";
20
- export * from "./MSFT_audio_emitter";
21
- export * from "./MSFT_lod";
22
- export * from "./MSFT_minecraftMesh";
23
- export * from "./MSFT_sRGBFactors";
24
- export * from "./ExtrasAsMetadata";
1
+ export * from "./EXT_lights_image_based.js";
2
+ export * from "./EXT_mesh_gpu_instancing.js";
3
+ export * from "./EXT_meshopt_compression.js";
4
+ export * from "./EXT_texture_webp.js";
5
+ export * from "./KHR_draco_mesh_compression.js";
6
+ export * from "./KHR_lights_punctual.js";
7
+ export * from "./KHR_materials_pbrSpecularGlossiness.js";
8
+ export * from "./KHR_materials_unlit.js";
9
+ export * from "./KHR_materials_clearcoat.js";
10
+ export * from "./KHR_materials_sheen.js";
11
+ export * from "./KHR_materials_specular.js";
12
+ export * from "./KHR_materials_ior.js";
13
+ export * from "./KHR_materials_variants.js";
14
+ export * from "./KHR_materials_transmission.js";
15
+ export * from "./KHR_materials_translucency.js";
16
+ export * from "./KHR_materials_volume.js";
17
+ export * from "./KHR_mesh_quantization.js";
18
+ export * from "./KHR_texture_basisu.js";
19
+ export * from "./KHR_texture_transform.js";
20
+ export * from "./KHR_xmp_json_ld.js";
21
+ export * from "./MSFT_audio_emitter.js";
22
+ export * from "./MSFT_lod.js";
23
+ export * from "./MSFT_minecraftMesh.js";
24
+ export * from "./MSFT_sRGBFactors.js";
25
+ export * from "./ExtrasAsMetadata.js";
25
26
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./EXT_lights_image_based\";\r\nexport * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./EXT_meshopt_compression\";\r\nexport * from \"./EXT_texture_webp\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_pbrSpecularGlossiness\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_variants\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_translucency\";\r\nexport * from \"./KHR_mesh_quantization\";\r\nexport * from \"./KHR_texture_basisu\";\r\nexport * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_xmp_json_ld\";\r\nexport * from \"./MSFT_audio_emitter\";\r\nexport * from \"./MSFT_lod\";\r\nexport * from \"./MSFT_minecraftMesh\";\r\nexport * from \"./MSFT_sRGBFactors\";\r\nexport * from \"./ExtrasAsMetadata\";\r\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../sourceES6/loaders/src/glTF/2.0/Extensions/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,uCAAuC,CAAC;AACtD,cAAc,uBAAuB,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC","sourcesContent":["export * from \"./EXT_lights_image_based\";\r\nexport * from \"./EXT_mesh_gpu_instancing\";\r\nexport * from \"./EXT_meshopt_compression\";\r\nexport * from \"./EXT_texture_webp\";\r\nexport * from \"./KHR_draco_mesh_compression\";\r\nexport * from \"./KHR_lights_punctual\";\r\nexport * from \"./KHR_materials_pbrSpecularGlossiness\";\r\nexport * from \"./KHR_materials_unlit\";\r\nexport * from \"./KHR_materials_clearcoat\";\r\nexport * from \"./KHR_materials_sheen\";\r\nexport * from \"./KHR_materials_specular\";\r\nexport * from \"./KHR_materials_ior\";\r\nexport * from \"./KHR_materials_variants\";\r\nexport * from \"./KHR_materials_transmission\";\r\nexport * from \"./KHR_materials_translucency\";\r\nexport * from \"./KHR_materials_volume\";\r\nexport * from \"./KHR_mesh_quantization\";\r\nexport * from \"./KHR_texture_basisu\";\r\nexport * from \"./KHR_texture_transform\";\r\nexport * from \"./KHR_xmp_json_ld\";\r\nexport * from \"./MSFT_audio_emitter\";\r\nexport * from \"./MSFT_lod\";\r\nexport * from \"./MSFT_minecraftMesh\";\r\nexport * from \"./MSFT_sRGBFactors\";\r\nexport * from \"./ExtrasAsMetadata\";\r\n"]}
@@ -11,10 +11,11 @@ import { Scene } from "@babylonjs/core/scene";
11
11
  import { IProperty } from "babylonjs-gltf2interface";
12
12
  import { IGLTF, ISampler, INode, IScene, IMesh, IAccessor, ICamera, IAnimation, IAnimationChannel, IBuffer, IBufferView, IMaterial, ITextureInfo, ITexture, IImage, IMeshPrimitive, IArrayItem as IArrItem } from "./glTFLoaderInterfaces";
13
13
  import { IGLTFLoaderExtension } from "./glTFLoaderExtension";
14
- import { IGLTFLoader, GLTFFileLoader, GLTFLoaderState, IGLTFLoaderData } from "../glTFFileLoader";
14
+ import { IGLTFLoader, GLTFFileLoader, IGLTFLoaderData } from "../glTFFileLoader";
15
15
  import { IAnimatable } from '@babylonjs/core/Animations/animatable.interface';
16
16
  import { IDataBuffer } from '@babylonjs/core/Misc/dataReader';
17
17
  import { Light } from '@babylonjs/core/Lights/light';
18
+ import { AssetContainer } from "@babylonjs/core/assetContainer";
18
19
  /**
19
20
  * Helper class for working with arrays when loading the glTF asset
20
21
  */
@@ -40,14 +41,13 @@ export declare class GLTFLoader implements IGLTFLoader {
40
41
  /** @hidden */
41
42
  _completePromises: Promise<any>[];
42
43
  /** @hidden */
43
- _forAssetContainer: boolean;
44
+ _assetContainer: Nullable<AssetContainer>;
44
45
  /** Storage */
45
46
  _babylonLights: Light[];
46
47
  /** @hidden */
47
48
  _disableInstancedMesh: number;
48
49
  private _disposed;
49
50
  private _parent;
50
- private _state;
51
51
  private _extensions;
52
52
  private _rootUrl;
53
53
  private _fileName;
@@ -74,10 +74,6 @@ export declare class GLTFLoader implements IGLTFLoader {
74
74
  * @returns A boolean indicating whether the extension has been unregistered
75
75
  */
76
76
  static UnregisterExtension(name: string): boolean;
77
- /**
78
- * The loader state.
79
- */
80
- get state(): Nullable<GLTFLoaderState>;
81
77
  /**
82
78
  * The object that represents the glTF JSON.
83
79
  */
@@ -103,7 +99,7 @@ export declare class GLTFLoader implements IGLTFLoader {
103
99
  /** @hidden */
104
100
  dispose(): void;
105
101
  /** @hidden */
106
- importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
102
+ importMeshAsync(meshesNames: any, scene: Scene, container: Nullable<AssetContainer>, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
107
103
  /** @hidden */
108
104
  loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
109
105
  private _loadAsync;
@@ -111,7 +107,6 @@ export declare class GLTFLoader implements IGLTFLoader {
111
107
  private _setupData;
112
108
  private _loadExtensions;
113
109
  private _checkExtensions;
114
- private _setState;
115
110
  private _createRootNode;
116
111
  /**
117
112
  * Loads a glTF scene.
@@ -255,7 +250,7 @@ export declare class GLTFLoader implements IGLTFLoader {
255
250
  /** @hidden */
256
251
  _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
257
252
  /** @hidden */
258
- _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
253
+ _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any, useSRGBBuffer?: boolean): Promise<BaseTexture>;
259
254
  private _loadSampler;
260
255
  /**
261
256
  * Loads a glTF image.