diff --git a/examples/babylonjs/index.html b/examples/babylonjs/index.html index 015faffc..a4ad47b0 100644 --- a/examples/babylonjs/index.html +++ b/examples/babylonjs/index.html @@ -13,15 +13,15 @@ - - + + - + - + - + diff --git a/libs/babylonjs/6.23.0/babylon.glTF2FileLoader.js b/libs/babylonjs/6.23.0/babylon.glTF2FileLoader.js new file mode 100644 index 00000000..b50de18f --- /dev/null +++ b/libs/babylonjs/6.23.0/babylon.glTF2FileLoader.js @@ -0,0 +1,7953 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("babylonjs")); + else if(typeof define === 'function' && define.amd) + define("babylonjs-loaders", ["babylonjs"], factory); + else if(typeof exports === 'object') + exports["babylonjs-loaders"] = factory(require("babylonjs")); + else + root["LOADERS"] = factory(root["BABYLON"]); +})((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), (__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__) => { +return /******/ (() => { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.ts": +/*!******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.ts ***! + \******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_lights_image_based: () => (/* binding */ EXT_lights_image_based) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/Textures/rawCubeTexture */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + + + +var NAME = "EXT_lights_image_based"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_lights_image_based/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var EXT_lights_image_based = /** @class */ (function () { + /** + * @internal + */ + function EXT_lights_image_based(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + EXT_lights_image_based.prototype.dispose = function () { + this._loader = null; + delete this._lights; + }; + /** @internal */ + EXT_lights_image_based.prototype.onLoading = function () { + var extensions = this._loader.gltf.extensions; + if (extensions && extensions[this.name]) { + var extension = extensions[this.name]; + this._lights = extension.lights; + } + }; + /** + * @internal + */ + EXT_lights_image_based.prototype.loadSceneAsync = function (context, scene) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, scene, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadSceneAsync(context, scene)); + _this._loader.logOpen("".concat(extensionContext)); + var light = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/light"), _this._lights, extension.light); + promises.push(_this._loadLightAsync("/extensions/".concat(_this.name, "/lights/").concat(extension.light), light).then(function (texture) { + _this._loader.babylonScene.environmentTexture = texture; + })); + _this._loader.logClose(); + return Promise.all(promises).then(function () { }); + }); + }; + EXT_lights_image_based.prototype._loadLightAsync = function (context, light) { + var _this = this; + if (!light._loaded) { + var promises = new Array(); + this._loader.logOpen("".concat(context)); + var imageData_1 = new Array(light.specularImages.length); + var _loop_1 = function (mipmap) { + var faces = light.specularImages[mipmap]; + imageData_1[mipmap] = new Array(faces.length); + var _loop_2 = function (face) { + var specularImageContext = "".concat(context, "/specularImages/").concat(mipmap, "/").concat(face); + this_1._loader.logOpen("".concat(specularImageContext)); + var index = faces[face]; + var image = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(specularImageContext, this_1._loader.gltf.images, index); + promises.push(this_1._loader.loadImageAsync("/images/".concat(index), image).then(function (data) { + imageData_1[mipmap][face] = data; + })); + this_1._loader.logClose(); + }; + for (var face = 0; face < faces.length; face++) { + _loop_2(face); + } + }; + var this_1 = this; + for (var mipmap = 0; mipmap < light.specularImages.length; mipmap++) { + _loop_1(mipmap); + } + this._loader.logClose(); + light._loaded = Promise.all(promises).then(function () { + var babylonTexture = new babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.RawCubeTexture(_this._loader.babylonScene, null, light.specularImageSize); + babylonTexture.name = light.name || "environment"; + light._babylonTexture = babylonTexture; + if (light.intensity != undefined) { + babylonTexture.level = light.intensity; + } + if (light.rotation) { + var rotation = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(light.rotation); + // Invert the rotation so that positive rotation is counter-clockwise. + if (!_this._loader.babylonScene.useRightHandedSystem) { + rotation = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Inverse(rotation); + } + babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromQuaternionToRef(rotation, babylonTexture.getReflectionTextureMatrix()); + } + if (!light.irradianceCoefficients) { + throw new Error("".concat(context, ": Irradiance coefficients are missing")); + } + var sphericalHarmonics = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.SphericalHarmonics.FromArray(light.irradianceCoefficients); + sphericalHarmonics.scaleInPlace(light.intensity); + sphericalHarmonics.convertIrradianceToLambertianRadiance(); + var sphericalPolynomial = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.SphericalPolynomial.FromHarmonics(sphericalHarmonics); + // Compute the lod generation scale to fit exactly to the number of levels available. + var lodGenerationScale = (imageData_1.length - 1) / babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Scalar.Log2(light.specularImageSize); + return babylonTexture.updateRGBDAsync(imageData_1, sphericalPolynomial, lodGenerationScale); + }); + } + return light._loaded.then(function () { + return light._babylonTexture; + }); + }; + return EXT_lights_image_based; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_lights_image_based(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts": +/*!*******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* binding */ EXT_mesh_gpu_instancing) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Meshes/thinInstanceMesh */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "EXT_mesh_gpu_instancing"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_mesh_gpu_instancing/README.md) + * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var EXT_mesh_gpu_instancing = /** @class */ (function () { + /** + * @internal + */ + function EXT_mesh_gpu_instancing(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + EXT_mesh_gpu_instancing.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + EXT_mesh_gpu_instancing.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) { + _this._loader._disableInstancedMesh++; + var promise = _this._loader.loadNodeAsync("/nodes/".concat(node.index), node, assign); + _this._loader._disableInstancedMesh--; + if (!node._primitiveBabylonMeshes) { + return promise; + } + var promises = new Array(); + var instanceCount = 0; + var loadAttribute = function (attribute) { + if (extension.attributes[attribute] == undefined) { + promises.push(Promise.resolve(null)); + return; + } + var accessor = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/attributes/").concat(attribute), _this._loader.gltf.accessors, extension.attributes[attribute]); + promises.push(_this._loader._loadFloatAccessorAsync("/accessors/".concat(accessor.bufferView), accessor)); + if (instanceCount === 0) { + instanceCount = accessor.count; + } + else if (instanceCount !== accessor.count) { + throw new Error("".concat(extensionContext, "/attributes: Instance buffer accessors do not have the same count.")); + } + }; + loadAttribute("TRANSLATION"); + loadAttribute("ROTATION"); + loadAttribute("SCALE"); + return promise.then(function (babylonTransformNode) { + return Promise.all(promises).then(function (_a) { + var translationBuffer = _a[0], rotationBuffer = _a[1], scaleBuffer = _a[2]; + var matrices = new Float32Array(instanceCount * 16); + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0].copyFromFloats(0, 0, 0); // translation + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0].copyFromFloats(0, 0, 0, 1); // rotation + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1].copyFromFloats(1, 1, 1); // scale + for (var i = 0; i < instanceCount; ++i) { + translationBuffer && babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(translationBuffer, i * 3, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0]); + rotationBuffer && babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArrayToRef(rotationBuffer, i * 4, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0]); + scaleBuffer && babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(scaleBuffer, i * 3, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1]); + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Matrix.ComposeToRef(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1], babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0], babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0], babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[0]); + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[0].copyToArray(matrices, i * 16); + } + for (var _i = 0, _b = node._primitiveBabylonMeshes; _i < _b.length; _i++) { + var babylonMesh = _b[_i]; + babylonMesh.thinInstanceSetBuffer("matrix", matrices, 16, true); + } + return babylonTransformNode; + }); + }); + }); + }; + return EXT_mesh_gpu_instancing; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_mesh_gpu_instancing(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_meshopt_compression.ts": +/*!*******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/EXT_meshopt_compression.ts ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_meshopt_compression: () => (/* binding */ EXT_meshopt_compression) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); +/* harmony import */ var babylonjs_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/Compression/meshoptCompression */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "EXT_meshopt_compression"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_meshopt_compression/README.md) + * + * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js + * @since 5.0.0 + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var EXT_meshopt_compression = /** @class */ (function () { + /** + * @internal + */ + function EXT_meshopt_compression(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this.enabled = loader.isExtensionUsed(NAME); + this._loader = loader; + } + /** @internal */ + EXT_meshopt_compression.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + EXT_meshopt_compression.prototype.loadBufferViewAsync = function (context, bufferView) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, bufferView, this.name, function (extensionContext, extension) { + var bufferViewMeshopt = bufferView; + if (bufferViewMeshopt._meshOptData) { + return bufferViewMeshopt._meshOptData; + } + var buffer = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/buffer"), _this._loader.gltf.buffers, extension.buffer); + bufferViewMeshopt._meshOptData = _this._loader.loadBufferAsync("/buffers/".concat(buffer.index), buffer, extension.byteOffset || 0, extension.byteLength).then(function (buffer) { + return babylonjs_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1__.MeshoptCompression.Default.decodeGltfBufferAsync(buffer, extension.count, extension.byteStride, extension.mode, extension.filter); + }); + return bufferViewMeshopt._meshOptData; + }); + }; + return EXT_meshopt_compression; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_meshopt_compression(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_texture_webp.ts": +/*!************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/EXT_texture_webp.ts ***! + \************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_texture_webp: () => (/* binding */ EXT_texture_webp) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "EXT_texture_webp"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_texture_webp/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var EXT_texture_webp = /** @class */ (function () { + /** + * @internal + */ + function EXT_texture_webp(loader) { + /** The name of this extension. */ + this.name = NAME; + this._loader = loader; + this.enabled = loader.isExtensionUsed(NAME); + } + /** @internal */ + EXT_texture_webp.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + EXT_texture_webp.prototype._loadTextureAsync = function (context, texture, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, texture, this.name, function (extensionContext, extension) { + var sampler = texture.sampler == undefined ? _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.DefaultSampler : _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/sampler"), _this._loader.gltf.samplers, texture.sampler); + var image = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(extensionContext, "/source"), _this._loader.gltf.images, extension.source); + return _this._loader._createTextureAsync(context, sampler, image, function (babylonTexture) { + assign(babylonTexture); + }, undefined, !texture._textureInfo.nonColorData); + }); + }; + return EXT_texture_webp; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_texture_webp(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts": +/*!************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts ***! + \************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ ExtrasAsMetadata: () => (/* binding */ ExtrasAsMetadata) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "ExtrasAsMetadata"; +/** + * Store glTF extras (if present) in BJS objects' metadata + */ +var ExtrasAsMetadata = /** @class */ (function () { + /** + * @internal + */ + function ExtrasAsMetadata(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines whether this extension is enabled. + */ + this.enabled = true; + this._loader = loader; + } + ExtrasAsMetadata.prototype._assignExtras = function (babylonObject, gltfProp) { + if (gltfProp.extras && Object.keys(gltfProp.extras).length > 0) { + var metadata = (babylonObject.metadata = babylonObject.metadata || {}); + var gltf = (metadata.gltf = metadata.gltf || {}); + gltf.extras = gltfProp.extras; + } + }; + /** @internal */ + ExtrasAsMetadata.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + ExtrasAsMetadata.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return this._loader.loadNodeAsync(context, node, function (babylonTransformNode) { + _this._assignExtras(babylonTransformNode, node); + assign(babylonTransformNode); + }); + }; + /** + * @internal + */ + ExtrasAsMetadata.prototype.loadCameraAsync = function (context, camera, assign) { + var _this = this; + return this._loader.loadCameraAsync(context, camera, function (babylonCamera) { + _this._assignExtras(babylonCamera, camera); + assign(babylonCamera); + }); + }; + /** + * @internal + */ + ExtrasAsMetadata.prototype.createMaterial = function (context, material, babylonDrawMode) { + var babylonMaterial = this._loader.createMaterial(context, material, babylonDrawMode); + this._assignExtras(babylonMaterial, material); + return babylonMaterial; + }; + return ExtrasAsMetadata; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new ExtrasAsMetadata(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.data.ts": +/*!**********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.data.ts ***! + \**********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ animationPointerTree: () => (/* binding */ animationPointerTree) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.color */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoaderAnimation */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts"); +/* eslint-disable @typescript-eslint/naming-convention */ + + + + +function getColor3(_target, source, offset, scale) { + return babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(source, offset).scale(scale); +} +function getAlpha(_target, source, offset, scale) { + return source[offset + 3] * scale; +} +function getFloat(_target, source, offset, scale) { + return source[offset] * scale; +} +function getMinusFloat(_target, source, offset, scale) { + return -source[offset] * scale; +} +function getNextFloat(_target, source, offset, scale) { + return source[offset + 1] * scale; +} +function getFloatBy2(_target, source, offset, scale) { + return source[offset] * scale * 2; +} +function getTextureTransformTree(textureName) { + return { + scale: [ + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".uScale"), getFloat, function () { return 2; }), + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".vScale"), getNextFloat, function () { return 2; }), + ], + offset: [ + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".uOffset"), getFloat, function () { return 2; }), + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".vOffset"), getNextFloat, function () { return 2; }), + ], + rotation: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".wAng"), getMinusFloat, function () { return 1; })], + }; +} +var CameraAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(CameraAnimationPropertyInfo, _super); + function CameraAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** @internal */ + CameraAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + callback(target._babylonCamera, this._buildAnimation(name, fps, keys)); + }; + return CameraAnimationPropertyInfo; +}(_glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__.AnimationPropertyInfo)); +var MaterialAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(MaterialAnimationPropertyInfo, _super); + function MaterialAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** @internal */ + MaterialAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + for (var fillMode in target._data) { + callback(target._data[fillMode].babylonMaterial, this._buildAnimation(name, fps, keys)); + } + }; + return MaterialAnimationPropertyInfo; +}(_glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__.AnimationPropertyInfo)); +var LightAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(LightAnimationPropertyInfo, _super); + function LightAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** @internal */ + LightAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + callback(target._babylonLight, this._buildAnimation(name, fps, keys)); + }; + return LightAnimationPropertyInfo; +}(_glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__.AnimationPropertyInfo)); +var nodesTree = { + __array__: (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({ __target__: true }, _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__.nodeAnimationData), +}; +var camerasTree = { + __array__: { + __target__: true, + orthographic: { + xmag: [ + new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "orthoLeft", getMinusFloat, function () { return 1; }), + new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "orthoRight", getNextFloat, function () { return 1; }), + ], + ymag: [ + new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "orthoBottom", getMinusFloat, function () { return 1; }), + new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "orthoTop", getNextFloat, function () { return 1; }), + ], + zfar: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "maxZ", getFloat, function () { return 1; })], + znear: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "minZ", getFloat, function () { return 1; })], + }, + perspective: { + yfov: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "fov", getFloat, function () { return 1; })], + zfar: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "maxZ", getFloat, function () { return 1; })], + znear: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "minZ", getFloat, function () { return 1; })], + }, + }, +}; +var materialsTree = { + __array__: { + __target__: true, + pbrMetallicRoughness: { + baseColorFactor: [ + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "albedoColor", getColor3, function () { return 4; }), + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "alpha", getAlpha, function () { return 4; }), + ], + metallicFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "metallic", getFloat, function () { return 1; })], + roughnessFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "roughness", getFloat, function () { return 1; })], + baseColorTexture: { + extensions: { + KHR_texture_transform: getTextureTransformTree("albedoTexture"), + }, + }, + }, + emissiveFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "emissiveColor", getColor3, function () { return 3; })], + normalTexture: { + scale: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "bumpTexture.level", getFloat, function () { return 1; })], + }, + occlusionTexture: { + strength: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "ambientTextureStrength", getFloat, function () { return 1; })], + extensions: { + KHR_texture_transform: getTextureTransformTree("ambientTexture"), + }, + }, + emissiveTexture: { + extensions: { + KHR_texture_transform: getTextureTransformTree("emissiveTexture"), + }, + }, + extensions: { + KHR_materials_ior: { + ior: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "indexOfRefraction", getFloat, function () { return 1; })], + }, + KHR_materials_clearcoat: { + clearcoatFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "clearCoat.intensity", getFloat, function () { return 1; })], + clearcoatRoughnessFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "clearCoat.roughness", getFloat, function () { return 1; })], + }, + KHR_materials_sheen: { + sheenColorFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "sheen.color", getColor3, function () { return 3; })], + sheenRoughnessFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "sheen.roughness", getFloat, function () { return 1; })], + }, + KHR_materials_specular: { + specularFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "metallicF0Factor", getFloat, function () { return 1; })], + specularColorFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "metallicReflectanceColor", getColor3, function () { return 3; })], + }, + KHR_materials_emissive_strength: { + emissiveStrength: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "emissiveIntensity", getFloat, function () { return 1; })], + }, + KHR_materials_transmission: { + transmissionFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "subSurface.refractionIntensity", getFloat, function () { return 1; })], + }, + KHR_materials_volume: { + attenuationColor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "subSurface.tintColor", getColor3, function () { return 3; })], + attenuationDistance: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "subSurface.tintColorAtDistance", getFloat, function () { return 1; })], + thicknessFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "subSurface.maximumThickness", getFloat, function () { return 1; })], + }, + KHR_materials_iridescence: { + iridescenceFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.intensity", getFloat, function () { return 1; })], + iridescenceIor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.indexOfRefraction", getFloat, function () { return 1; })], + iridescenceThicknessMinimum: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.minimumThickness", getFloat, function () { return 1; })], + iridescenceThicknessMaximum: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.maximumThickness", getFloat, function () { return 1; })], + }, + KHR_materials_anisotropy: { + anisotropyStrength: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "anisotropy.intensity", getFloat, function () { return 1; })], + anisotropyRotation: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "anisotropy.angle", getFloat, function () { return 1; })], + }, + }, + }, +}; +var extensionsTree = { + KHR_lights_punctual: { + lights: { + __array__: { + __target__: true, + color: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "diffuse", getColor3, function () { return 3; })], + intensity: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "intensity", getFloat, function () { return 1; })], + range: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "range", getFloat, function () { return 1; })], + spot: { + innerConeAngle: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "innerAngle", getFloatBy2, function () { return 1; })], + outerConeAngle: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "angle", getFloatBy2, function () { return 1; })], + }, + }, + }, + }, +}; +/** @internal */ +var animationPointerTree = { + nodes: nodesTree, + materials: materialsTree, + cameras: camerasTree, + extensions: extensionsTree, +}; + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.ts": +/*!*****************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.ts ***! + \*****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_animation_pointer: () => (/* binding */ KHR_animation_pointer) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); +/* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _KHR_animation_pointer_data__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./KHR_animation_pointer.data */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.data.ts"); + + + +var NAME = "KHR_animation_pointer"; +/** + * [Specification PR](https://github.com/KhronosGroup/glTF/pull/2147) + * !!! Experimental Extension Subject to Changes !!! + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_animation_pointer = /** @class */ (function () { + /** + * @internal + */ + function KHR_animation_pointer(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + } + Object.defineProperty(KHR_animation_pointer.prototype, "enabled", { + /** + * Defines whether this extension is enabled. + */ + get: function () { + return this._loader.isExtensionUsed(NAME); + }, + enumerable: false, + configurable: true + }); + /** @internal */ + KHR_animation_pointer.prototype.dispose = function () { + this._loader = null; + }; + /** + * Loads a glTF animation channel. + * @param context The context when loading the asset + * @param animationContext The context of the animation when loading the asset + * @param animation The glTF animation property + * @param channel The glTF animation channel property + * @param onLoad Called for each animation loaded + * @returns A void promise that resolves when the load is complete or null if not handled + */ + KHR_animation_pointer.prototype._loadAnimationChannelAsync = function (context, animationContext, animation, channel, onLoad) { + var _a; + var extension = (_a = channel.target.extensions) === null || _a === void 0 ? void 0 : _a.KHR_animation_pointer; + if (!extension) { + return null; + } + if (channel.target.path !== "pointer" /* AnimationChannelTargetPath.POINTER */) { + babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.Warn("".concat(context, "/target/path: Value (").concat(channel.target.path, ") must be (").concat("pointer" /* AnimationChannelTargetPath.POINTER */, ") when using the ").concat(this.name, " extension")); + } + if (channel.target.node != undefined) { + babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.Warn("".concat(context, "/target/node: Value (").concat(channel.target.node, ") must not be present when using the ").concat(this.name, " extension")); + } + var extensionContext = "".concat(context, "/extensions/").concat(this.name); + var pointer = extension.pointer; + if (!pointer) { + throw new Error("".concat(extensionContext, ": Pointer is missing")); + } + var targetInfo = this._parseAnimationPointer("".concat(extensionContext, "/pointer"), pointer); + if (!targetInfo) { + babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.Warn("".concat(extensionContext, "/pointer: Invalid pointer (").concat(pointer, ") skipped")); + return null; + } + return this._loader._loadAnimationChannelFromTargetInfoAsync(context, animationContext, animation, channel, targetInfo, onLoad); + }; + /** + * The pointer string is represented by a [JSON pointer](https://datatracker.ietf.org/doc/html/rfc6901). + * := /// + * := "nodes" | "materials" | "meshes" | "cameras" | "extensions" + * := | + * := | + * := "extensions"// + * := | / + * := W+ + * := D+ + * + * Examples: + * - "/nodes/0/rotation" + * - "/materials/2/emissiveFactor" + * - "/materials/2/pbrMetallicRoughness/baseColorFactor" + * - "/materials/2/extensions/KHR_materials_emissive_strength/emissiveStrength" + */ + KHR_animation_pointer.prototype._parseAnimationPointer = function (context, pointer) { + if (!pointer.startsWith("/")) { + babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.Warn("".concat(context, ": Value (").concat(pointer, ") must start with a slash")); + return null; + } + var parts = pointer.split("/"); + // Remove the first part since it will be empty string as pointers must start with a slash. + parts.shift(); + var node = _KHR_animation_pointer_data__WEBPACK_IMPORTED_MODULE_2__.animationPointerTree; + var gltfCurrentNode = this._loader.gltf; + var gltfTargetNode = undefined; + for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { + var part = parts_1[_i]; + if (node.__array__) { + node = node.__array__; + } + else { + node = node[part]; + if (!node) { + return null; + } + } + gltfCurrentNode = gltfCurrentNode && gltfCurrentNode[part]; + if (node.__target__) { + gltfTargetNode = gltfCurrentNode; + } + } + if (!gltfTargetNode || !Array.isArray(node)) { + return null; + } + return { + target: gltfTargetNode, + properties: node, + }; + }; + return KHR_animation_pointer; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_animation_pointer(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts": +/*!**********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts ***! + \**********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_draco_mesh_compression: () => (/* binding */ KHR_draco_mesh_compression) +/* harmony export */ }); +/* harmony import */ var babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Buffers/buffer */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_draco_mesh_compression"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_draco_mesh_compression/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_draco_mesh_compression = /** @class */ (function () { + /** + * @internal + */ + function KHR_draco_mesh_compression(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines whether to use the normalized flag from the glTF accessor instead of the Draco data. Defaults to true. + */ + this.useNormalizedFlagFromAccessor = true; + this._loader = loader; + this.enabled = babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_draco_mesh_compression.prototype.dispose = function () { + delete this.dracoCompression; + this._loader = null; + }; + /** + * @internal + */ + KHR_draco_mesh_compression.prototype._loadVertexDataAsync = function (context, primitive, babylonMesh) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, primitive, this.name, function (extensionContext, extension) { + if (primitive.mode != undefined) { + if (primitive.mode !== 5 /* MeshPrimitiveMode.TRIANGLE_STRIP */ && primitive.mode !== 4 /* MeshPrimitiveMode.TRIANGLES */) { + throw new Error("".concat(context, ": Unsupported mode ").concat(primitive.mode)); + } + // TODO: handle triangle strips + if (primitive.mode === 5 /* MeshPrimitiveMode.TRIANGLE_STRIP */) { + throw new Error("".concat(context, ": Mode ").concat(primitive.mode, " is not currently supported")); + } + } + var attributes = {}; + var normalized = {}; + var loadAttribute = function (name, kind) { + var uniqueId = extension.attributes[name]; + if (uniqueId == undefined) { + return; + } + babylonMesh._delayInfo = babylonMesh._delayInfo || []; + if (babylonMesh._delayInfo.indexOf(kind) === -1) { + babylonMesh._delayInfo.push(kind); + } + attributes[kind] = uniqueId; + if (_this.useNormalizedFlagFromAccessor) { + var accessor = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.TryGet(_this._loader.gltf.accessors, primitive.attributes[name]); + if (accessor) { + normalized[kind] = accessor.normalized || false; + } + } + }; + loadAttribute("POSITION", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind); + loadAttribute("NORMAL", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind); + loadAttribute("TANGENT", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind); + loadAttribute("TEXCOORD_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind); + loadAttribute("TEXCOORD_1", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind); + loadAttribute("TEXCOORD_2", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV3Kind); + loadAttribute("TEXCOORD_3", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV4Kind); + loadAttribute("TEXCOORD_4", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV5Kind); + loadAttribute("TEXCOORD_5", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV6Kind); + loadAttribute("JOINTS_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind); + loadAttribute("WEIGHTS_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsKind); + loadAttribute("COLOR_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind); + var bufferView = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(extensionContext, _this._loader.gltf.bufferViews, extension.bufferView); + if (!bufferView._dracoBabylonGeometry) { + bufferView._dracoBabylonGeometry = _this._loader.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) { + var dracoCompression = _this.dracoCompression || babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.DracoCompression.Default; + return dracoCompression._decodeMeshToGeometryForGltfAsync(babylonMesh.name, _this._loader.babylonScene, data, attributes, normalized).catch(function (error) { + throw new Error("".concat(context, ": ").concat(error.message)); + }); + }); + } + return bufferView._dracoBabylonGeometry; + }); + }; + return KHR_draco_mesh_compression; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_draco_mesh_compression(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts": +/*!***************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts ***! + \***************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_lights: () => (/* binding */ KHR_lights) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Lights/light */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + + + + + +var NAME = "KHR_lights_punctual"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_lights_punctual/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_lights = /** @class */ (function () { + /** + * @internal + */ + function KHR_lights(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_lights.prototype.dispose = function () { + this._loader = null; + delete this._lights; + }; + /** @internal */ + KHR_lights.prototype.onLoading = function () { + var extensions = this._loader.gltf.extensions; + if (extensions && extensions[this.name]) { + var extension = extensions[this.name]; + this._lights = extension.lights; + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(this._lights); + } + }; + /** + * @internal + */ + KHR_lights.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) { + return _this._loader.loadNodeAsync(context, node, function (babylonMesh) { + var babylonLight; + var light = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(extensionContext, _this._lights, extension.light); + var name = light.name || babylonMesh.name; + _this._loader.babylonScene._blockEntityCollection = !!_this._loader._assetContainer; + switch (light.type) { + case "directional" /* KHRLightsPunctual_LightType.DIRECTIONAL */: { + var babylonDirectionalLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.DirectionalLight(name, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Backward(), _this._loader.babylonScene); + babylonDirectionalLight.position.setAll(0); + babylonLight = babylonDirectionalLight; + break; + } + case "point" /* KHRLightsPunctual_LightType.POINT */: { + babylonLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.PointLight(name, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(), _this._loader.babylonScene); + break; + } + case "spot" /* KHRLightsPunctual_LightType.SPOT */: { + var babylonSpotLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.SpotLight(name, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Backward(), 0, 1, _this._loader.babylonScene); + babylonSpotLight.angle = ((light.spot && light.spot.outerConeAngle) || Math.PI / 4) * 2; + babylonSpotLight.innerAngle = ((light.spot && light.spot.innerConeAngle) || 0) * 2; + babylonLight = babylonSpotLight; + break; + } + default: { + _this._loader.babylonScene._blockEntityCollection = false; + throw new Error("".concat(extensionContext, ": Invalid light type (").concat(light.type, ")")); + } + } + babylonLight._parentContainer = _this._loader._assetContainer; + _this._loader.babylonScene._blockEntityCollection = false; + light._babylonLight = babylonLight; + babylonLight.falloffType = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Light.FALLOFF_GLTF; + babylonLight.diffuse = light.color ? babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(light.color) : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + babylonLight.intensity = light.intensity == undefined ? 1 : light.intensity; + babylonLight.range = light.range == undefined ? Number.MAX_VALUE : light.range; + babylonLight.parent = babylonMesh; + _this._loader._babylonLights.push(babylonLight); + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.AddPointerMetadata(babylonLight, extensionContext); + assign(babylonMesh); + }); + }); + }; + return KHR_lights; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_lights(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts": +/*!********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts ***! + \********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_anisotropy: () => (/* binding */ KHR_materials_anisotropy) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_anisotropy"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_anisotropy) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_anisotropy = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_anisotropy(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 195; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_anisotropy.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_anisotropy.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadIridescencePropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_anisotropy.prototype._loadIridescencePropertiesAsync = function (context, properties, babylonMaterial) { + var _a, _b; + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.anisotropy.isEnabled = true; + babylonMaterial.anisotropy.intensity = (_a = properties.anisotropyStrength) !== null && _a !== void 0 ? _a : 0; + babylonMaterial.anisotropy.angle = (_b = properties.anisotropyRotation) !== null && _b !== void 0 ? _b : 0; + if (properties.anisotropyTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/anisotropyTexture"), properties.anisotropyTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Anisotropy Intensity)"); + babylonMaterial.anisotropy.texture = texture; + })); + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_anisotropy; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_anisotropy(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts": +/*!*******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_clearcoat: () => (/* binding */ KHR_materials_clearcoat) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_clearcoat"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md) + * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_clearcoat = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_clearcoat(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 190; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_clearcoat.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_clearcoat.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadClearCoatPropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_clearcoat.prototype._loadClearCoatPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.clearCoat.isEnabled = true; + babylonMaterial.clearCoat.useRoughnessFromMainTexture = false; + babylonMaterial.clearCoat.remapF0OnInterfaceChange = false; + if (properties.clearcoatFactor != undefined) { + babylonMaterial.clearCoat.intensity = properties.clearcoatFactor; + } + else { + babylonMaterial.clearCoat.intensity = 0; + } + if (properties.clearcoatTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/clearcoatTexture"), properties.clearcoatTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (ClearCoat Intensity)"); + babylonMaterial.clearCoat.texture = texture; + })); + } + if (properties.clearcoatRoughnessFactor != undefined) { + babylonMaterial.clearCoat.roughness = properties.clearcoatRoughnessFactor; + } + else { + babylonMaterial.clearCoat.roughness = 0; + } + if (properties.clearcoatRoughnessTexture) { + properties.clearcoatRoughnessTexture.nonColorData = true; + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/clearcoatRoughnessTexture"), properties.clearcoatRoughnessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (ClearCoat Roughness)"); + babylonMaterial.clearCoat.textureRoughness = texture; + })); + } + if (properties.clearcoatNormalTexture) { + properties.clearcoatNormalTexture.nonColorData = true; + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/clearcoatNormalTexture"), properties.clearcoatNormalTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (ClearCoat Normal)"); + babylonMaterial.clearCoat.bumpTexture = texture; + })); + babylonMaterial.invertNormalMapX = !babylonMaterial.getScene().useRightHandedSystem; + babylonMaterial.invertNormalMapY = babylonMaterial.getScene().useRightHandedSystem; + if (properties.clearcoatNormalTexture.scale != undefined) { + babylonMaterial.clearCoat.bumpTexture.level = properties.clearcoatNormalTexture.scale; + } + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_clearcoat; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_clearcoat(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts": +/*!***************************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts ***! + \***************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_emissive_strength: () => (/* binding */ KHR_materials_emissive_strength) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_emissive_strength"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_emissive_strength = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_emissive_strength(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 170; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_emissive_strength.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_emissive_strength.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + return _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial).then(function () { + _this._loadEmissiveProperties(extensionContext, extension, babylonMaterial); + }); + }); + }; + KHR_materials_emissive_strength.prototype._loadEmissiveProperties = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + if (properties.emissiveStrength !== undefined) { + babylonMaterial.emissiveColor.scaleToRef(properties.emissiveStrength, babylonMaterial.emissiveColor); + } + }; + return KHR_materials_emissive_strength; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_emissive_strength(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_ior.ts": +/*!*************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_ior.ts ***! + \*************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_ior: () => (/* binding */ KHR_materials_ior) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_ior"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_ior/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_ior = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_ior(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 180; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_ior.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_ior.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadIorPropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_ior.prototype._loadIorPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + if (properties.ior !== undefined) { + babylonMaterial.indexOfRefraction = properties.ior; + } + else { + babylonMaterial.indexOfRefraction = KHR_materials_ior._DEFAULT_IOR; + } + return Promise.resolve(); + }; + /** + * Default ior Value from the spec. + */ + KHR_materials_ior._DEFAULT_IOR = 1.5; + return KHR_materials_ior; +}()); +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_ior(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts": +/*!*********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts ***! + \*********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_iridescence: () => (/* binding */ KHR_materials_iridescence) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_iridescence"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_iridescence/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_iridescence = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_iridescence(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 195; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_iridescence.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_iridescence.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadIridescencePropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_iridescence.prototype._loadIridescencePropertiesAsync = function (context, properties, babylonMaterial) { + var _a, _b, _c, _d, _e; + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.iridescence.isEnabled = true; + babylonMaterial.iridescence.intensity = (_a = properties.iridescenceFactor) !== null && _a !== void 0 ? _a : 0; + babylonMaterial.iridescence.indexOfRefraction = (_c = (_b = properties.iridescenceIor) !== null && _b !== void 0 ? _b : properties.iridescenceIOR) !== null && _c !== void 0 ? _c : 1.3; + babylonMaterial.iridescence.minimumThickness = (_d = properties.iridescenceThicknessMinimum) !== null && _d !== void 0 ? _d : 100; + babylonMaterial.iridescence.maximumThickness = (_e = properties.iridescenceThicknessMaximum) !== null && _e !== void 0 ? _e : 400; + if (properties.iridescenceTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/iridescenceTexture"), properties.iridescenceTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Iridescence Intensity)"); + babylonMaterial.iridescence.texture = texture; + })); + } + if (properties.iridescenceThicknessTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/iridescenceThicknessTexture"), properties.iridescenceThicknessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Iridescence Thickness)"); + babylonMaterial.iridescence.thicknessTexture = texture; + })); + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_iridescence; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_iridescence(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts": +/*!*******************************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts ***! + \*******************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_pbrSpecularGlossiness: () => (/* binding */ KHR_materials_pbrSpecularGlossiness) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_materials_pbrSpecularGlossiness"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_pbrSpecularGlossiness = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_pbrSpecularGlossiness(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 200; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_pbrSpecularGlossiness.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_pbrSpecularGlossiness.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadSpecularGlossinessPropertiesAsync(extensionContext, material, extension, babylonMaterial)); + _this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_pbrSpecularGlossiness.prototype._loadSpecularGlossinessPropertiesAsync = function (context, material, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.metallic = null; + babylonMaterial.roughness = null; + if (properties.diffuseFactor) { + babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.diffuseFactor); + babylonMaterial.alpha = properties.diffuseFactor[3]; + } + else { + babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + } + babylonMaterial.reflectivityColor = properties.specularFactor ? babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.specularFactor) : babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + babylonMaterial.microSurface = properties.glossinessFactor == undefined ? 1 : properties.glossinessFactor; + if (properties.diffuseTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/diffuseTexture"), properties.diffuseTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Diffuse)"); + babylonMaterial.albedoTexture = texture; + })); + } + if (properties.specularGlossinessTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularGlossinessTexture"), properties.specularGlossinessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Specular Glossiness)"); + babylonMaterial.reflectivityTexture = texture; + babylonMaterial.reflectivityTexture.hasAlpha = true; + })); + babylonMaterial.useMicroSurfaceFromReflectivityMapAlpha = true; + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_pbrSpecularGlossiness; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_pbrSpecularGlossiness(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_sheen.ts": +/*!***************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_sheen.ts ***! + \***************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_sheen: () => (/* binding */ KHR_materials_sheen) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.color */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_materials_sheen"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_sheen/README.md) + * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_sheen = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_sheen(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 190; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_sheen.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_sheen.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadSheenPropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_sheen.prototype._loadSheenPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.sheen.isEnabled = true; + babylonMaterial.sheen.intensity = 1; + if (properties.sheenColorFactor != undefined) { + babylonMaterial.sheen.color = babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.sheenColorFactor); + } + else { + babylonMaterial.sheen.color = babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Color3.Black(); + } + if (properties.sheenColorTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/sheenColorTexture"), properties.sheenColorTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Sheen Color)"); + babylonMaterial.sheen.texture = texture; + })); + } + if (properties.sheenRoughnessFactor !== undefined) { + babylonMaterial.sheen.roughness = properties.sheenRoughnessFactor; + } + else { + babylonMaterial.sheen.roughness = 0; + } + if (properties.sheenRoughnessTexture) { + properties.sheenRoughnessTexture.nonColorData = true; + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/sheenRoughnessTexture"), properties.sheenRoughnessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Sheen Roughness)"); + babylonMaterial.sheen.textureRoughness = texture; + })); + } + babylonMaterial.sheen.albedoScaling = true; + babylonMaterial.sheen.useRoughnessFromMainTexture = false; + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_sheen; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_sheen(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts": +/*!******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts ***! + \******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_specular: () => (/* binding */ KHR_materials_specular) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.color */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_materials_specular"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_specular/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_specular = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_specular(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 190; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_specular.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_specular.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadSpecularPropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_specular.prototype._loadSpecularPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + if (properties.specularFactor !== undefined) { + babylonMaterial.metallicF0Factor = properties.specularFactor; + } + if (properties.specularColorFactor !== undefined) { + babylonMaterial.metallicReflectanceColor = babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.specularColorFactor); + } + if (properties.specularTexture) { + properties.specularTexture.nonColorData = true; + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularTexture"), properties.specularTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Specular F0 Strength)"); + babylonMaterial.metallicReflectanceTexture = texture; + babylonMaterial.useOnlyMetallicFromMetallicReflectanceTexture = true; + })); + } + if (properties.specularColorTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularColorTexture"), properties.specularColorTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Specular F0 Color)"); + babylonMaterial.reflectanceTexture = texture; + })); + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_specular; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_specular(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_translucency.ts": +/*!**********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_translucency.ts ***! + \**********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_translucency: () => (/* binding */ KHR_materials_translucency) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_translucency"; +/** + * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825) + * !!! Experimental Extension Subject to Changes !!! + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_translucency = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_translucency(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 174; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + if (this.enabled) { + loader.parent.transparencyAsCoverage = true; + } + } + /** @internal */ + KHR_materials_translucency.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_translucency.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadTranslucentPropertiesAsync(extensionContext, material, babylonMaterial, extension)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_translucency.prototype._loadTranslucentPropertiesAsync = function (context, material, babylonMaterial, extension) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var pbrMaterial = babylonMaterial; + // Enables "translucency" texture which represents diffusely-transmitted light. + pbrMaterial.subSurface.isTranslucencyEnabled = true; + // Since this extension models thin-surface transmission only, we must make the + // internal IOR == 1.0 and set the thickness to 0. + pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0; + pbrMaterial.subSurface.minimumThickness = 0.0; + pbrMaterial.subSurface.maximumThickness = 0.0; + // Albedo colour will tint transmission. + pbrMaterial.subSurface.useAlbedoToTintTranslucency = true; + if (extension.translucencyFactor !== undefined) { + pbrMaterial.subSurface.translucencyIntensity = extension.translucencyFactor; + } + else { + pbrMaterial.subSurface.translucencyIntensity = 0.0; + pbrMaterial.subSurface.isTranslucencyEnabled = false; + return Promise.resolve(); + } + if (extension.translucencyTexture) { + extension.translucencyTexture.nonColorData = true; + return this._loader.loadTextureInfoAsync("".concat(context, "/translucencyTexture"), extension.translucencyTexture).then(function (texture) { + pbrMaterial.subSurface.translucencyIntensityTexture = texture; + }); + } + else { + return Promise.resolve(); + } + }; + return KHR_materials_translucency; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_translucency(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts": +/*!**********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts ***! + \**********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_transmission: () => (/* binding */ KHR_materials_transmission) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + + + + + +/** + * A class to handle setting up the rendering of opaque objects to be shown through transmissive objects. + */ +var TransmissionHelper = /** @class */ (function () { + /** + * constructor + * @param options Defines the options we want to customize the helper + * @param scene The scene to add the material to + */ + function TransmissionHelper(options, scene) { + var _this = this; + this._opaqueRenderTarget = null; + this._opaqueMeshesCache = []; + this._transparentMeshesCache = []; + this._materialObservers = {}; + this._options = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, TransmissionHelper._GetDefaultOptions()), options); + this._scene = scene; + this._scene._transmissionHelper = this; + this.onErrorObservable = new babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Observable(); + this._scene.onDisposeObservable.addOnce(function () { + _this.dispose(); + }); + this._parseScene(); + this._setupRenderTargets(); + } + /** + * Creates the default options for the helper. + */ + TransmissionHelper._GetDefaultOptions = function () { + return { + renderSize: 1024, + samples: 4, + lodGenerationScale: 1, + lodGenerationOffset: -4, + renderTargetTextureType: babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Constants.TEXTURETYPE_HALF_FLOAT, + generateMipmaps: true, + }; + }; + /** + * Updates the background according to the new options + * @param options + */ + TransmissionHelper.prototype.updateOptions = function (options) { + var _this = this; + // First check if any options are actually being changed. If not, exit. + var newValues = Object.keys(options).filter(function (key) { return _this._options[key] !== options[key]; }); + if (!newValues.length) { + return; + } + var newOptions = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, this._options), options); + var oldOptions = this._options; + this._options = newOptions; + // If size changes, recreate everything + if (newOptions.renderSize !== oldOptions.renderSize || + newOptions.renderTargetTextureType !== oldOptions.renderTargetTextureType || + newOptions.generateMipmaps !== oldOptions.generateMipmaps || + !this._opaqueRenderTarget) { + this._setupRenderTargets(); + } + else { + this._opaqueRenderTarget.samples = newOptions.samples; + this._opaqueRenderTarget.lodGenerationScale = newOptions.lodGenerationScale; + this._opaqueRenderTarget.lodGenerationOffset = newOptions.lodGenerationOffset; + } + }; + /** + * Gets the opaque render target texture or null if not available. + */ + TransmissionHelper.prototype.getOpaqueTarget = function () { + return this._opaqueRenderTarget; + }; + TransmissionHelper.prototype._shouldRenderAsTransmission = function (material) { + if (!material) { + return false; + } + if (material instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial && material.subSurface.isRefractionEnabled) { + return true; + } + return false; + }; + TransmissionHelper.prototype._addMesh = function (mesh) { + var _this = this; + this._materialObservers[mesh.uniqueId] = mesh.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this)); + // we need to defer the processing because _addMesh may be called as part as an instance mesh creation, in which case some + // internal properties are not setup yet, like _sourceMesh (needed when doing mesh.material below) + babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Tools.SetImmediate(function () { + if (_this._shouldRenderAsTransmission(mesh.material)) { + mesh.material.refractionTexture = _this._opaqueRenderTarget; + if (_this._transparentMeshesCache.indexOf(mesh) === -1) { + _this._transparentMeshesCache.push(mesh); + } + } + else { + if (_this._opaqueMeshesCache.indexOf(mesh) === -1) { + _this._opaqueMeshesCache.push(mesh); + } + } + }); + }; + TransmissionHelper.prototype._removeMesh = function (mesh) { + mesh.onMaterialChangedObservable.remove(this._materialObservers[mesh.uniqueId]); + delete this._materialObservers[mesh.uniqueId]; + var idx = this._transparentMeshesCache.indexOf(mesh); + if (idx !== -1) { + this._transparentMeshesCache.splice(idx, 1); + } + idx = this._opaqueMeshesCache.indexOf(mesh); + if (idx !== -1) { + this._opaqueMeshesCache.splice(idx, 1); + } + }; + TransmissionHelper.prototype._parseScene = function () { + this._scene.meshes.forEach(this._addMesh.bind(this)); + // Listen for when a mesh is added to the scene and add it to our cache lists. + this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this)); + // Listen for when a mesh is removed from to the scene and remove it from our cache lists. + this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this)); + }; + // When one of the meshes in the scene has its material changed, make sure that it's in the correct cache list. + TransmissionHelper.prototype._onMeshMaterialChanged = function (mesh) { + var transparentIdx = this._transparentMeshesCache.indexOf(mesh); + var opaqueIdx = this._opaqueMeshesCache.indexOf(mesh); + // If the material is transparent, make sure that it's added to the transparent list and removed from the opaque list + var useTransmission = this._shouldRenderAsTransmission(mesh.material); + if (useTransmission) { + if (mesh.material instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial) { + mesh.material.subSurface.refractionTexture = this._opaqueRenderTarget; + } + if (opaqueIdx !== -1) { + this._opaqueMeshesCache.splice(opaqueIdx, 1); + this._transparentMeshesCache.push(mesh); + } + else if (transparentIdx === -1) { + this._transparentMeshesCache.push(mesh); + } + // If the material is opaque, make sure that it's added to the opaque list and removed from the transparent list + } + else { + if (transparentIdx !== -1) { + this._transparentMeshesCache.splice(transparentIdx, 1); + this._opaqueMeshesCache.push(mesh); + } + else if (opaqueIdx === -1) { + this._opaqueMeshesCache.push(mesh); + } + } + }; + /** + * @internal + * Check if the opaque render target has not been disposed and can still be used. + * @returns + */ + TransmissionHelper.prototype._isRenderTargetValid = function () { + var _a; + return ((_a = this._opaqueRenderTarget) === null || _a === void 0 ? void 0 : _a.getInternalTexture()) !== null; + }; + /** + * @internal + * Setup the render targets according to the specified options. + */ + TransmissionHelper.prototype._setupRenderTargets = function () { + var _this = this; + var _a, _b; + if (this._opaqueRenderTarget) { + this._opaqueRenderTarget.dispose(); + } + this._opaqueRenderTarget = new babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.RenderTargetTexture("opaqueSceneTexture", this._options.renderSize, this._scene, this._options.generateMipmaps, undefined, this._options.renderTargetTextureType); + this._opaqueRenderTarget.ignoreCameraViewport = true; + this._opaqueRenderTarget.renderList = this._opaqueMeshesCache; + 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(); + this._opaqueRenderTarget.gammaSpace = false; + this._opaqueRenderTarget.lodGenerationScale = this._options.lodGenerationScale; + this._opaqueRenderTarget.lodGenerationOffset = this._options.lodGenerationOffset; + this._opaqueRenderTarget.samples = this._options.samples; + var sceneImageProcessingapplyByPostProcess; + var saveSceneEnvIntensity; + this._opaqueRenderTarget.onBeforeBindObservable.add(function (opaqueRenderTarget) { + saveSceneEnvIntensity = _this._scene.environmentIntensity; + _this._scene.environmentIntensity = 1.0; + sceneImageProcessingapplyByPostProcess = _this._scene.imageProcessingConfiguration.applyByPostProcess; + if (!_this._options.clearColor) { + _this._scene.clearColor.toLinearSpaceToRef(opaqueRenderTarget.clearColor, _this._scene.getEngine().useExactSrgbConversions); + } + else { + opaqueRenderTarget.clearColor.copyFrom(_this._options.clearColor); + } + // we do not use the applyByPostProcess setter to avoid flagging all the materials as "image processing dirty"! + _this._scene.imageProcessingConfiguration._applyByPostProcess = true; + }); + this._opaqueRenderTarget.onAfterUnbindObservable.add(function () { + _this._scene.environmentIntensity = saveSceneEnvIntensity; + _this._scene.imageProcessingConfiguration._applyByPostProcess = sceneImageProcessingapplyByPostProcess; + }); + this._transparentMeshesCache.forEach(function (mesh) { + if (_this._shouldRenderAsTransmission(mesh.material)) { + mesh.material.refractionTexture = _this._opaqueRenderTarget; + } + }); + }; + /** + * Dispose all the elements created by the Helper. + */ + TransmissionHelper.prototype.dispose = function () { + this._scene._transmissionHelper = undefined; + if (this._opaqueRenderTarget) { + this._opaqueRenderTarget.dispose(); + this._opaqueRenderTarget = null; + } + this._transparentMeshesCache = []; + this._opaqueMeshesCache = []; + }; + return TransmissionHelper; +}()); +var NAME = "KHR_materials_transmission"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_transmission/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_transmission = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_transmission(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 175; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + if (this.enabled) { + loader.parent.transparencyAsCoverage = true; + } + } + /** @internal */ + KHR_materials_transmission.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_transmission.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadTransparentPropertiesAsync(extensionContext, material, babylonMaterial, extension)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_transmission.prototype._loadTransparentPropertiesAsync = function (context, material, babylonMaterial, extension) { + var _a, _b; + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var pbrMaterial = babylonMaterial; + // Enables "refraction" texture which represents transmitted light. + pbrMaterial.subSurface.isRefractionEnabled = true; + // Since this extension models thin-surface transmission only, we must make IOR = 1.0 + pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0; + // Albedo colour will tint transmission. + pbrMaterial.subSurface.useAlbedoToTintRefraction = true; + if (extension.transmissionFactor !== undefined) { + pbrMaterial.subSurface.refractionIntensity = extension.transmissionFactor; + var scene = pbrMaterial.getScene(); + if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper) { + new TransmissionHelper({}, pbrMaterial.getScene()); + } + else if (pbrMaterial.subSurface.refractionIntensity && !((_a = scene._transmissionHelper) === null || _a === void 0 ? void 0 : _a._isRenderTargetValid())) { + // If the render target is not valid, recreate it. + (_b = scene._transmissionHelper) === null || _b === void 0 ? void 0 : _b._setupRenderTargets(); + } + } + else { + pbrMaterial.subSurface.refractionIntensity = 0.0; + pbrMaterial.subSurface.isRefractionEnabled = false; + return Promise.resolve(); + } + pbrMaterial.subSurface.minimumThickness = 0.0; + pbrMaterial.subSurface.maximumThickness = 0.0; + if (extension.transmissionTexture) { + extension.transmissionTexture.nonColorData = true; + return this._loader.loadTextureInfoAsync("".concat(context, "/transmissionTexture"), extension.transmissionTexture, undefined).then(function (texture) { + pbrMaterial.subSurface.refractionIntensityTexture = texture; + pbrMaterial.subSurface.useGltfStyleTextures = true; + }); + } + else { + return Promise.resolve(); + } + }; + return KHR_materials_transmission; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_transmission(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_unlit.ts": +/*!***************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_unlit.ts ***! + \***************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_unlit: () => (/* binding */ KHR_materials_unlit) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_materials_unlit"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_unlit/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_unlit = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_unlit(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 210; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_unlit.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_unlit.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function () { + return _this._loadUnlitPropertiesAsync(context, material, babylonMaterial); + }); + }; + KHR_materials_unlit.prototype._loadUnlitPropertiesAsync = function (context, material, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.unlit = true; + var properties = material.pbrMetallicRoughness; + if (properties) { + if (properties.baseColorFactor) { + babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.baseColorFactor); + babylonMaterial.alpha = properties.baseColorFactor[3]; + } + else { + babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + } + if (properties.baseColorTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/baseColorTexture"), properties.baseColorTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Base Color)"); + babylonMaterial.albedoTexture = texture; + })); + } + } + if (material.doubleSided) { + babylonMaterial.backFaceCulling = false; + babylonMaterial.twoSidedLighting = true; + } + this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial); + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_unlit; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_unlit(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_variants.ts": +/*!******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_variants.ts ***! + \******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_variants: () => (/* binding */ KHR_materials_variants) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); +/* harmony import */ var babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/mesh */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_variants"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_variants/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_variants = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_variants(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_variants.prototype.dispose = function () { + this._loader = null; + }; + /** + * Gets the list of available variant names for this asset. + * @param rootMesh The glTF root mesh + * @returns the list of all the variant names for this model + */ + KHR_materials_variants.GetAvailableVariants = function (rootMesh) { + var extensionMetadata = this._GetExtensionMetadata(rootMesh); + if (!extensionMetadata) { + return []; + } + return Object.keys(extensionMetadata.variants); + }; + /** + * Gets the list of available variant names for this asset. + * @param rootMesh The glTF root mesh + * @returns the list of all the variant names for this model + */ + KHR_materials_variants.prototype.getAvailableVariants = function (rootMesh) { + return KHR_materials_variants.GetAvailableVariants(rootMesh); + }; + /** + * Select a variant given a variant name or a list of variant names. + * @param rootMesh The glTF root mesh + * @param variantName The variant name(s) to select. + */ + KHR_materials_variants.SelectVariant = function (rootMesh, variantName) { + var extensionMetadata = this._GetExtensionMetadata(rootMesh); + if (!extensionMetadata) { + throw new Error("Cannot select variant on a glTF mesh that does not have the ".concat(NAME, " extension")); + } + var select = function (variantName) { + var entries = extensionMetadata.variants[variantName]; + if (entries) { + for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { + var entry = entries_1[_i]; + entry.mesh.material = entry.material; + } + } + }; + if (variantName instanceof Array) { + for (var _i = 0, variantName_1 = variantName; _i < variantName_1.length; _i++) { + var name_1 = variantName_1[_i]; + select(name_1); + } + } + else { + select(variantName); + } + extensionMetadata.lastSelected = variantName; + }; + /** + * Select a variant given a variant name or a list of variant names. + * @param rootMesh The glTF root mesh + * @param variantName The variant name(s) to select. + */ + KHR_materials_variants.prototype.selectVariant = function (rootMesh, variantName) { + return KHR_materials_variants.SelectVariant(rootMesh, variantName); + }; + /** + * Reset back to the original before selecting a variant. + * @param rootMesh The glTF root mesh + */ + KHR_materials_variants.Reset = function (rootMesh) { + var extensionMetadata = this._GetExtensionMetadata(rootMesh); + if (!extensionMetadata) { + throw new Error("Cannot reset on a glTF mesh that does not have the ".concat(NAME, " extension")); + } + for (var _i = 0, _a = extensionMetadata.original; _i < _a.length; _i++) { + var entry = _a[_i]; + entry.mesh.material = entry.material; + } + extensionMetadata.lastSelected = null; + }; + /** + * Reset back to the original before selecting a variant. + * @param rootMesh The glTF root mesh + */ + KHR_materials_variants.prototype.reset = function (rootMesh) { + return KHR_materials_variants.Reset(rootMesh); + }; + /** + * Gets the last selected variant name(s) or null if original. + * @param rootMesh The glTF root mesh + * @returns The selected variant name(s). + */ + KHR_materials_variants.GetLastSelectedVariant = function (rootMesh) { + var extensionMetadata = this._GetExtensionMetadata(rootMesh); + if (!extensionMetadata) { + throw new Error("Cannot get the last selected variant on a glTF mesh that does not have the ".concat(NAME, " extension")); + } + return extensionMetadata.lastSelected; + }; + /** + * Gets the last selected variant name(s) or null if original. + * @param rootMesh The glTF root mesh + * @returns The selected variant name(s). + */ + KHR_materials_variants.prototype.getLastSelectedVariant = function (rootMesh) { + return KHR_materials_variants.GetLastSelectedVariant(rootMesh); + }; + KHR_materials_variants._GetExtensionMetadata = function (rootMesh) { + var _a, _b; + 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; + }; + /** @internal */ + KHR_materials_variants.prototype.onLoading = function () { + var extensions = this._loader.gltf.extensions; + if (extensions && extensions[this.name]) { + var extension = extensions[this.name]; + this._variants = extension.variants; + } + }; + /** + * @internal + */ + KHR_materials_variants.prototype._loadMeshPrimitiveAsync = function (context, name, node, mesh, primitive, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, primitive, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader._loadMeshPrimitiveAsync(context, name, node, mesh, primitive, function (babylonMesh) { + assign(babylonMesh); + if (babylonMesh instanceof babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.Mesh) { + var babylonDrawMode = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader._GetDrawMode(context, primitive.mode); + var root_1 = _this._loader.rootBabylonMesh; + var metadata = root_1 ? (root_1._internalMetadata = root_1._internalMetadata || {}) : {}; + var gltf = (metadata.gltf = metadata.gltf || {}); + var extensionMetadata_1 = (gltf[NAME] = gltf[NAME] || { lastSelected: null, original: [], variants: {} }); + // Store the original material. + extensionMetadata_1.original.push({ mesh: babylonMesh, material: babylonMesh.material }); + var _loop_1 = function (mappingIndex) { + var mapping = extension.mappings[mappingIndex]; + var material = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(extensionContext, "/mappings/").concat(mappingIndex, "/material"), _this._loader.gltf.materials, mapping.material); + promises.push(_this._loader._loadMaterialAsync("#/materials/".concat(mapping.material), material, babylonMesh, babylonDrawMode, function (babylonMaterial) { + var _loop_2 = function (mappingVariantIndex) { + var variantIndex = mapping.variants[mappingVariantIndex]; + var variant = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("/extensions/".concat(NAME, "/variants/").concat(variantIndex), _this._variants, variantIndex); + extensionMetadata_1.variants[variant.name] = extensionMetadata_1.variants[variant.name] || []; + extensionMetadata_1.variants[variant.name].push({ + mesh: babylonMesh, + material: babylonMaterial, + }); + // Replace the target when original mesh is cloned + babylonMesh.onClonedObservable.add(function (newOne) { + var newMesh = newOne; + var metadata = null; + var newRoot = newMesh; + // Find root to get medata + do { + newRoot = newRoot.parent; + if (!newRoot) { + return; + } + metadata = KHR_materials_variants._GetExtensionMetadata(newRoot); + } while (metadata === null); + // Need to clone the metadata on the root (first time only) + if (root_1 && metadata === KHR_materials_variants._GetExtensionMetadata(root_1)) { + // Copy main metadata + newRoot._internalMetadata = {}; + for (var key in root_1._internalMetadata) { + newRoot._internalMetadata[key] = root_1._internalMetadata[key]; + } + // Copy the gltf metadata + newRoot._internalMetadata.gltf = []; + for (var key in root_1._internalMetadata.gltf) { + newRoot._internalMetadata.gltf[key] = root_1._internalMetadata.gltf[key]; + } + // Duplicate the extension specific metadata + newRoot._internalMetadata.gltf[NAME] = { lastSelected: null, original: [], variants: {} }; + for (var _i = 0, _a = metadata.original; _i < _a.length; _i++) { + var original = _a[_i]; + newRoot._internalMetadata.gltf[NAME].original.push({ + mesh: original.mesh, + material: original.material, + }); + } + for (var key in metadata.variants) { + if (Object.prototype.hasOwnProperty.call(metadata.variants, key)) { + newRoot._internalMetadata.gltf[NAME].variants[key] = []; + for (var _b = 0, _c = metadata.variants[key]; _b < _c.length; _b++) { + var variantEntry = _c[_b]; + newRoot._internalMetadata.gltf[NAME].variants[key].push({ + mesh: variantEntry.mesh, + material: variantEntry.material, + }); + } + } + } + metadata = newRoot._internalMetadata.gltf[NAME]; + } + // Relocate + for (var _d = 0, _e = metadata.original; _d < _e.length; _d++) { + var target = _e[_d]; + if (target.mesh === babylonMesh) { + target.mesh = newMesh; + } + } + for (var _f = 0, _g = metadata.variants[variant.name]; _f < _g.length; _f++) { + var target = _g[_f]; + if (target.mesh === babylonMesh) { + target.mesh = newMesh; + } + } + }); + }; + for (var mappingVariantIndex = 0; mappingVariantIndex < mapping.variants.length; ++mappingVariantIndex) { + _loop_2(mappingVariantIndex); + } + })); + }; + // For each mapping, look at the variants and make a new entry for them. + for (var mappingIndex = 0; mappingIndex < extension.mappings.length; ++mappingIndex) { + _loop_1(mappingIndex); + } + } + })); + return Promise.all(promises).then(function (_a) { + var babylonMesh = _a[0]; + return babylonMesh; + }); + }); + }; + return KHR_materials_variants; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_variants(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_volume.ts": +/*!****************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_volume.ts ***! + \****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_volume: () => (/* binding */ KHR_materials_volume) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_volume"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_volume/README.md) + * @since 5.0.0 + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_volume = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_volume(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 173; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + if (this.enabled) { + // We need to disable instance usage because the attenuation factor depends on the node scale of each individual mesh + this._loader._disableInstancedMesh++; + } + } + /** @internal */ + KHR_materials_volume.prototype.dispose = function () { + if (this.enabled) { + this._loader._disableInstancedMesh--; + } + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_volume.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadVolumePropertiesAsync(extensionContext, material, babylonMaterial, extension)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_volume.prototype._loadVolumePropertiesAsync = function (context, material, babylonMaterial, extension) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + // If transparency isn't enabled already, this extension shouldn't do anything. + // i.e. it requires either the KHR_materials_transmission or KHR_materials_translucency extensions. + if ((!babylonMaterial.subSurface.isRefractionEnabled && !babylonMaterial.subSurface.isTranslucencyEnabled) || !extension.thicknessFactor) { + return Promise.resolve(); + } + // IOR in this extension only affects interior. + babylonMaterial.subSurface.volumeIndexOfRefraction = babylonMaterial.indexOfRefraction; + var attenuationDistance = extension.attenuationDistance !== undefined ? extension.attenuationDistance : Number.MAX_VALUE; + babylonMaterial.subSurface.tintColorAtDistance = attenuationDistance; + if (extension.attenuationColor !== undefined && extension.attenuationColor.length == 3) { + babylonMaterial.subSurface.tintColor.copyFromFloats(extension.attenuationColor[0], extension.attenuationColor[1], extension.attenuationColor[2]); + } + babylonMaterial.subSurface.minimumThickness = 0.0; + babylonMaterial.subSurface.maximumThickness = extension.thicknessFactor; + babylonMaterial.subSurface.useThicknessAsDepth = true; + if (extension.thicknessTexture) { + extension.thicknessTexture.nonColorData = true; + return this._loader.loadTextureInfoAsync("".concat(context, "/thicknessTexture"), extension.thicknessTexture).then(function (texture) { + babylonMaterial.subSurface.thicknessTexture = texture; + babylonMaterial.subSurface.useGltfStyleTextures = true; + }); + } + else { + return Promise.resolve(); + } + }; + return KHR_materials_volume; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_volume(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_mesh_quantization.ts": +/*!*****************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_mesh_quantization.ts ***! + \*****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_mesh_quantization: () => (/* binding */ KHR_mesh_quantization) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "KHR_mesh_quantization"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_mesh_quantization = /** @class */ (function () { + /** + * @internal + */ + function KHR_mesh_quantization(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this.enabled = loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_mesh_quantization.prototype.dispose = function () { }; + return KHR_mesh_quantization; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_mesh_quantization(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_basisu.ts": +/*!**************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_basisu.ts ***! + \**************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_texture_basisu: () => (/* binding */ KHR_texture_basisu) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "KHR_texture_basisu"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_basisu/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_texture_basisu = /** @class */ (function () { + /** + * @internal + */ + function KHR_texture_basisu(loader) { + /** The name of this extension. */ + this.name = NAME; + this._loader = loader; + this.enabled = loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_texture_basisu.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_texture_basisu.prototype._loadTextureAsync = function (context, texture, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, texture, this.name, function (extensionContext, extension) { + var sampler = texture.sampler == undefined ? _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.DefaultSampler : _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/sampler"), _this._loader.gltf.samplers, texture.sampler); + var image = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(extensionContext, "/source"), _this._loader.gltf.images, extension.source); + return _this._loader._createTextureAsync(context, sampler, image, function (babylonTexture) { + assign(babylonTexture); + }, texture._textureInfo.nonColorData ? { useRGBAIfASTCBC7NotAvailableWhenUASTC: true } : undefined, !texture._textureInfo.nonColorData); + }); + }; + return KHR_texture_basisu; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_texture_basisu(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_transform.ts": +/*!*****************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_transform.ts ***! + \*****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_texture_transform: () => (/* binding */ KHR_texture_transform) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/Textures/texture */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_texture_transform"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_transform/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_texture_transform = /** @class */ (function () { + /** + * @internal + */ + function KHR_texture_transform(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_texture_transform.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_texture_transform.prototype.loadTextureInfoAsync = function (context, textureInfo, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, textureInfo, this.name, function (extensionContext, extension) { + return _this._loader.loadTextureInfoAsync(context, textureInfo, function (babylonTexture) { + if (!(babylonTexture instanceof babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__.Texture)) { + throw new Error("".concat(extensionContext, ": Texture type not supported")); + } + if (extension.offset) { + babylonTexture.uOffset = extension.offset[0]; + babylonTexture.vOffset = extension.offset[1]; + } + // Always rotate around the origin. + babylonTexture.uRotationCenter = 0; + babylonTexture.vRotationCenter = 0; + if (extension.rotation) { + babylonTexture.wAng = -extension.rotation; + } + if (extension.scale) { + babylonTexture.uScale = extension.scale[0]; + babylonTexture.vScale = extension.scale[1]; + } + if (extension.texCoord != undefined) { + babylonTexture.coordinatesIndex = extension.texCoord; + } + assign(babylonTexture); + }); + }); + }; + return KHR_texture_transform; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_texture_transform(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_xmp_json_ld.ts": +/*!***********************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_xmp_json_ld.ts ***! + \***********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_xmp_json_ld: () => (/* binding */ KHR_xmp_json_ld) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "KHR_xmp_json_ld"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_xmp_json_ld/README.md) + * @since 5.0.0 + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_xmp_json_ld = /** @class */ (function () { + /** + * @internal + */ + function KHR_xmp_json_ld(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 100; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_xmp_json_ld.prototype.dispose = function () { + this._loader = null; + }; + /** + * Called after the loader state changes to LOADING. + */ + KHR_xmp_json_ld.prototype.onLoading = function () { + var _a, _b, _c; + if (this._loader.rootBabylonMesh === null) { + return; + } + var xmp_gltf = (_a = this._loader.gltf.extensions) === null || _a === void 0 ? void 0 : _a.KHR_xmp_json_ld; + var 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; + if (xmp_gltf && xmp_node) { + var packet = +xmp_node.packet; + if (xmp_gltf.packets && packet < xmp_gltf.packets.length) { + this._loader.rootBabylonMesh.metadata = this._loader.rootBabylonMesh.metadata || {}; + this._loader.rootBabylonMesh.metadata.xmp = xmp_gltf.packets[packet]; + } + } + }; + return KHR_xmp_json_ld; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_xmp_json_ld(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts": +/*!**************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts ***! + \**************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ MSFT_audio_emitter: () => (/* binding */ MSFT_audio_emitter) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Audio/weightedsound */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + + + + +var NAME = "MSFT_audio_emitter"; +/** + * [Specification](https://github.com/najadojo/glTF/blob/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter/README.md) + * !!! Experimental Extension Subject to Changes !!! + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var MSFT_audio_emitter = /** @class */ (function () { + /** + * @internal + */ + function MSFT_audio_emitter(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + MSFT_audio_emitter.prototype.dispose = function () { + this._loader = null; + this._clips = null; + this._emitters = null; + }; + /** @internal */ + MSFT_audio_emitter.prototype.onLoading = function () { + var extensions = this._loader.gltf.extensions; + if (extensions && extensions[this.name]) { + var extension = extensions[this.name]; + this._clips = extension.clips; + this._emitters = extension.emitters; + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(this._clips); + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(this._emitters); + } + }; + /** + * @internal + */ + MSFT_audio_emitter.prototype.loadSceneAsync = function (context, scene) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, scene, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadSceneAsync(context, scene)); + for (var _i = 0, _a = extension.emitters; _i < _a.length; _i++) { + var emitterIndex = _a[_i]; + var emitter = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/emitters"), _this._emitters, emitterIndex); + if (emitter.refDistance != undefined || + emitter.maxDistance != undefined || + emitter.rolloffFactor != undefined || + emitter.distanceModel != undefined || + emitter.innerAngle != undefined || + emitter.outerAngle != undefined) { + throw new Error("".concat(extensionContext, ": Direction or Distance properties are not allowed on emitters attached to a scene")); + } + promises.push(_this._loadEmitterAsync("".concat(extensionContext, "/emitters/").concat(emitter.index), emitter)); + } + return Promise.all(promises).then(function () { }); + }); + }; + /** + * @internal + */ + MSFT_audio_emitter.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) { + var promises = new Array(); + return _this._loader + .loadNodeAsync(extensionContext, node, function (babylonMesh) { + var _loop_1 = function (emitterIndex) { + var emitter = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/emitters"), _this._emitters, emitterIndex); + promises.push(_this._loadEmitterAsync("".concat(extensionContext, "/emitters/").concat(emitter.index), emitter).then(function () { + for (var _i = 0, _a = emitter._babylonSounds; _i < _a.length; _i++) { + var sound = _a[_i]; + sound.attachToMesh(babylonMesh); + if (emitter.innerAngle != undefined || emitter.outerAngle != undefined) { + sound.setLocalDirectionToMesh(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Forward()); + sound.setDirectionalCone(2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.innerAngle == undefined ? Math.PI : emitter.innerAngle), 2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.outerAngle == undefined ? Math.PI : emitter.outerAngle), 0); + } + } + })); + }; + for (var _i = 0, _a = extension.emitters; _i < _a.length; _i++) { + var emitterIndex = _a[_i]; + _loop_1(emitterIndex); + } + assign(babylonMesh); + }) + .then(function (babylonMesh) { + return Promise.all(promises).then(function () { + return babylonMesh; + }); + }); + }); + }; + /** + * @internal + */ + MSFT_audio_emitter.prototype.loadAnimationAsync = function (context, animation) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, animation, this.name, function (extensionContext, extension) { + return _this._loader.loadAnimationAsync(context, animation).then(function (babylonAnimationGroup) { + var promises = new Array(); + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(extension.events); + for (var _i = 0, _a = extension.events; _i < _a.length; _i++) { + var event_1 = _a[_i]; + promises.push(_this._loadAnimationEventAsync("".concat(extensionContext, "/events/").concat(event_1.index), context, animation, event_1, babylonAnimationGroup)); + } + return Promise.all(promises).then(function () { + return babylonAnimationGroup; + }); + }); + }); + }; + MSFT_audio_emitter.prototype._loadClipAsync = function (context, clip) { + if (clip._objectURL) { + return clip._objectURL; + } + var promise; + if (clip.uri) { + promise = this._loader.loadUriAsync(context, clip, clip.uri); + } + else { + var bufferView = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(context, "/bufferView"), this._loader.gltf.bufferViews, clip.bufferView); + promise = this._loader.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView); + } + clip._objectURL = promise.then(function (data) { + return URL.createObjectURL(new Blob([data], { type: clip.mimeType })); + }); + return clip._objectURL; + }; + MSFT_audio_emitter.prototype._loadEmitterAsync = function (context, emitter) { + var _this = this; + emitter._babylonSounds = emitter._babylonSounds || []; + if (!emitter._babylonData) { + var clipPromises = new Array(); + var name_1 = emitter.name || "emitter".concat(emitter.index); + var options_1 = { + loop: false, + autoplay: false, + volume: emitter.volume == undefined ? 1 : emitter.volume, + }; + var _loop_2 = function (i) { + var clipContext = "/extensions/".concat(this_1.name, "/clips"); + var clip = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(clipContext, this_1._clips, emitter.clips[i].clip); + clipPromises.push(this_1._loadClipAsync("".concat(clipContext, "/").concat(emitter.clips[i].clip), clip).then(function (objectURL) { + var sound = (emitter._babylonSounds[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Sound(name_1, objectURL, _this._loader.babylonScene, null, options_1)); + sound.refDistance = emitter.refDistance || 1; + sound.maxDistance = emitter.maxDistance || 256; + sound.rolloffFactor = emitter.rolloffFactor || 1; + sound.distanceModel = emitter.distanceModel || "exponential"; + })); + }; + var this_1 = this; + for (var i = 0; i < emitter.clips.length; i++) { + _loop_2(i); + } + var promise = Promise.all(clipPromises).then(function () { + var weights = emitter.clips.map(function (clip) { + return clip.weight || 1; + }); + var weightedSound = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.WeightedSound(emitter.loop || false, emitter._babylonSounds, weights); + if (emitter.innerAngle) { + weightedSound.directionalConeInnerAngle = 2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.innerAngle); + } + if (emitter.outerAngle) { + weightedSound.directionalConeOuterAngle = 2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.outerAngle); + } + if (emitter.volume) { + weightedSound.volume = emitter.volume; + } + emitter._babylonData.sound = weightedSound; + }); + emitter._babylonData = { + loaded: promise, + }; + } + return emitter._babylonData.loaded; + }; + MSFT_audio_emitter.prototype._getEventAction = function (context, sound, action, time, startOffset) { + switch (action) { + case "play" /* IMSFTAudioEmitter_AnimationEventAction.play */: { + return function (currentFrame) { + var frameOffset = (startOffset || 0) + (currentFrame - time); + sound.play(frameOffset); + }; + } + case "stop" /* IMSFTAudioEmitter_AnimationEventAction.stop */: { + return function () { + sound.stop(); + }; + } + case "pause" /* IMSFTAudioEmitter_AnimationEventAction.pause */: { + return function () { + sound.pause(); + }; + } + default: { + throw new Error("".concat(context, ": Unsupported action ").concat(action)); + } + } + }; + MSFT_audio_emitter.prototype._loadAnimationEventAsync = function (context, animationContext, animation, event, babylonAnimationGroup) { + var _this = this; + if (babylonAnimationGroup.targetedAnimations.length == 0) { + return Promise.resolve(); + } + var babylonAnimation = babylonAnimationGroup.targetedAnimations[0]; + var emitterIndex = event.emitter; + var emitter = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("/extensions/".concat(this.name, "/emitters"), this._emitters, emitterIndex); + return this._loadEmitterAsync(context, emitter).then(function () { + var sound = emitter._babylonData.sound; + if (sound) { + var babylonAnimationEvent = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.AnimationEvent(event.time, _this._getEventAction(context, sound, event.action, event.time, event.startOffset)); + babylonAnimation.animation.addEvent(babylonAnimationEvent); + // Make sure all started audio stops when this animation is terminated. + babylonAnimationGroup.onAnimationGroupEndObservable.add(function () { + sound.stop(); + }); + babylonAnimationGroup.onAnimationGroupPauseObservable.add(function () { + sound.pause(); + }); + } + }); + }; + return MSFT_audio_emitter; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_audio_emitter(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts": +/*!****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ MSFT_lod: () => (/* binding */ MSFT_lod) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/deferred */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "MSFT_lod"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/MSFT_lod/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var MSFT_lod = /** @class */ (function () { + /** + * @internal + */ + function MSFT_lod(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 100; + /** + * Maximum number of LODs to load, starting from the lowest LOD. + */ + this.maxLODsToLoad = 10; + /** + * Observable raised when all node LODs of one level are loaded. + * The event data is the index of the loaded LOD starting from zero. + * Dispose the loader to cancel the loading of the next level of LODs. + */ + this.onNodeLODsLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when all material LODs of one level are loaded. + * The event data is the index of the loaded LOD starting from zero. + * Dispose the loader to cancel the loading of the next level of LODs. + */ + this.onMaterialLODsLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + this._bufferLODs = new Array(); + this._nodeIndexLOD = null; + this._nodeSignalLODs = new Array(); + this._nodePromiseLODs = new Array(); + this._nodeBufferLODs = new Array(); + this._materialIndexLOD = null; + this._materialSignalLODs = new Array(); + this._materialPromiseLODs = new Array(); + this._materialBufferLODs = new Array(); + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + MSFT_lod.prototype.dispose = function () { + this._loader = null; + this._nodeIndexLOD = null; + this._nodeSignalLODs.length = 0; + this._nodePromiseLODs.length = 0; + this._nodeBufferLODs.length = 0; + this._materialIndexLOD = null; + this._materialSignalLODs.length = 0; + this._materialPromiseLODs.length = 0; + this._materialBufferLODs.length = 0; + this.onMaterialLODsLoadedObservable.clear(); + this.onNodeLODsLoadedObservable.clear(); + }; + /** @internal */ + MSFT_lod.prototype.onReady = function () { + var _this = this; + var _loop_1 = function (indexLOD) { + var promise = Promise.all(this_1._nodePromiseLODs[indexLOD]).then(function () { + if (indexLOD !== 0) { + _this._loader.endPerformanceCounter("Node LOD ".concat(indexLOD)); + _this._loader.log("Loaded node LOD ".concat(indexLOD)); + } + _this.onNodeLODsLoadedObservable.notifyObservers(indexLOD); + if (indexLOD !== _this._nodePromiseLODs.length - 1) { + _this._loader.startPerformanceCounter("Node LOD ".concat(indexLOD + 1)); + _this._loadBufferLOD(_this._nodeBufferLODs, indexLOD + 1); + if (_this._nodeSignalLODs[indexLOD]) { + _this._nodeSignalLODs[indexLOD].resolve(); + } + } + }); + this_1._loader._completePromises.push(promise); + }; + var this_1 = this; + for (var indexLOD = 0; indexLOD < this._nodePromiseLODs.length; indexLOD++) { + _loop_1(indexLOD); + } + var _loop_2 = function (indexLOD) { + var promise = Promise.all(this_2._materialPromiseLODs[indexLOD]).then(function () { + if (indexLOD !== 0) { + _this._loader.endPerformanceCounter("Material LOD ".concat(indexLOD)); + _this._loader.log("Loaded material LOD ".concat(indexLOD)); + } + _this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD); + if (indexLOD !== _this._materialPromiseLODs.length - 1) { + _this._loader.startPerformanceCounter("Material LOD ".concat(indexLOD + 1)); + _this._loadBufferLOD(_this._materialBufferLODs, indexLOD + 1); + if (_this._materialSignalLODs[indexLOD]) { + _this._materialSignalLODs[indexLOD].resolve(); + } + } + }); + this_2._loader._completePromises.push(promise); + }; + var this_2 = this; + for (var indexLOD = 0; indexLOD < this._materialPromiseLODs.length; indexLOD++) { + _loop_2(indexLOD); + } + }; + /** + * @internal + */ + MSFT_lod.prototype.loadSceneAsync = function (context, scene) { + var promise = this._loader.loadSceneAsync(context, scene); + this._loadBufferLOD(this._bufferLODs, 0); + return promise; + }; + /** + * @internal + */ + MSFT_lod.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) { + var firstPromise; + var nodeLODs = _this._getLODs(extensionContext, node, _this._loader.gltf.nodes, extension.ids); + _this._loader.logOpen("".concat(extensionContext)); + var _loop_3 = function (indexLOD) { + var nodeLOD = nodeLODs[indexLOD]; + if (indexLOD !== 0) { + _this._nodeIndexLOD = indexLOD; + _this._nodeSignalLODs[indexLOD] = _this._nodeSignalLODs[indexLOD] || new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred(); + } + var assignWrap = function (babylonTransformNode) { + assign(babylonTransformNode); + babylonTransformNode.setEnabled(false); + }; + var promise = _this._loader.loadNodeAsync("/nodes/".concat(nodeLOD.index), nodeLOD, assignWrap).then(function (babylonMesh) { + if (indexLOD !== 0) { + // TODO: should not rely on _babylonTransformNode + var previousNodeLOD = nodeLODs[indexLOD - 1]; + if (previousNodeLOD._babylonTransformNode) { + _this._disposeTransformNode(previousNodeLOD._babylonTransformNode); + delete previousNodeLOD._babylonTransformNode; + } + } + babylonMesh.setEnabled(true); + return babylonMesh; + }); + _this._nodePromiseLODs[indexLOD] = _this._nodePromiseLODs[indexLOD] || []; + if (indexLOD === 0) { + firstPromise = promise; + } + else { + _this._nodeIndexLOD = null; + _this._nodePromiseLODs[indexLOD].push(promise); + } + }; + for (var indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) { + _loop_3(indexLOD); + } + _this._loader.logClose(); + return firstPromise; + }); + }; + /** + * @internal + */ + MSFT_lod.prototype._loadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) { + var _this = this; + // Don't load material LODs if already loading a node LOD. + if (this._nodeIndexLOD) { + return null; + } + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var firstPromise; + var materialLODs = _this._getLODs(extensionContext, material, _this._loader.gltf.materials, extension.ids); + _this._loader.logOpen("".concat(extensionContext)); + var _loop_4 = function (indexLOD) { + var materialLOD = materialLODs[indexLOD]; + if (indexLOD !== 0) { + _this._materialIndexLOD = indexLOD; + } + var promise = _this._loader + ._loadMaterialAsync("/materials/".concat(materialLOD.index), materialLOD, babylonMesh, babylonDrawMode, function (babylonMaterial) { + if (indexLOD === 0) { + assign(babylonMaterial); + } + }) + .then(function (babylonMaterial) { + if (indexLOD !== 0) { + assign(babylonMaterial); + // TODO: should not rely on _data + var previousDataLOD = materialLODs[indexLOD - 1]._data; + if (previousDataLOD[babylonDrawMode]) { + _this._disposeMaterials([previousDataLOD[babylonDrawMode].babylonMaterial]); + delete previousDataLOD[babylonDrawMode]; + } + } + return babylonMaterial; + }); + _this._materialPromiseLODs[indexLOD] = _this._materialPromiseLODs[indexLOD] || []; + if (indexLOD === 0) { + firstPromise = promise; + } + else { + _this._materialIndexLOD = null; + _this._materialPromiseLODs[indexLOD].push(promise); + } + }; + for (var indexLOD = 0; indexLOD < materialLODs.length; indexLOD++) { + _loop_4(indexLOD); + } + _this._loader.logClose(); + return firstPromise; + }); + }; + /** + * @internal + */ + MSFT_lod.prototype._loadUriAsync = function (context, property, uri) { + var _this = this; + // Defer the loading of uris if loading a node or material LOD. + if (this._nodeIndexLOD !== null) { + this._loader.log("deferred"); + var previousIndexLOD = this._nodeIndexLOD - 1; + this._nodeSignalLODs[previousIndexLOD] = this._nodeSignalLODs[previousIndexLOD] || new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred(); + return this._nodeSignalLODs[this._nodeIndexLOD - 1].promise.then(function () { + return _this._loader.loadUriAsync(context, property, uri); + }); + } + else if (this._materialIndexLOD !== null) { + this._loader.log("deferred"); + var previousIndexLOD = this._materialIndexLOD - 1; + this._materialSignalLODs[previousIndexLOD] = this._materialSignalLODs[previousIndexLOD] || new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred(); + return this._materialSignalLODs[previousIndexLOD].promise.then(function () { + return _this._loader.loadUriAsync(context, property, uri); + }); + } + return null; + }; + /** + * @internal + */ + MSFT_lod.prototype.loadBufferAsync = function (context, buffer, byteOffset, byteLength) { + if (this._loader.parent.useRangeRequests && !buffer.uri) { + if (!this._loader.bin) { + throw new Error("".concat(context, ": Uri is missing or the binary glTF is missing its binary chunk")); + } + var loadAsync = function (bufferLODs, indexLOD) { + var start = byteOffset; + var end = start + byteLength - 1; + var bufferLOD = bufferLODs[indexLOD]; + if (bufferLOD) { + bufferLOD.start = Math.min(bufferLOD.start, start); + bufferLOD.end = Math.max(bufferLOD.end, end); + } + else { + bufferLOD = { start: start, end: end, loaded: new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred() }; + bufferLODs[indexLOD] = bufferLOD; + } + return bufferLOD.loaded.promise.then(function (data) { + return new Uint8Array(data.buffer, data.byteOffset + byteOffset - bufferLOD.start, byteLength); + }); + }; + this._loader.log("deferred"); + if (this._nodeIndexLOD !== null) { + return loadAsync(this._nodeBufferLODs, this._nodeIndexLOD); + } + else if (this._materialIndexLOD !== null) { + return loadAsync(this._materialBufferLODs, this._materialIndexLOD); + } + else { + return loadAsync(this._bufferLODs, 0); + } + } + return null; + }; + MSFT_lod.prototype._loadBufferLOD = function (bufferLODs, indexLOD) { + var bufferLOD = bufferLODs[indexLOD]; + if (bufferLOD) { + this._loader.log("Loading buffer range [".concat(bufferLOD.start, "-").concat(bufferLOD.end, "]")); + this._loader.bin.readAsync(bufferLOD.start, bufferLOD.end - bufferLOD.start + 1).then(function (data) { + bufferLOD.loaded.resolve(data); + }, function (error) { + bufferLOD.loaded.reject(error); + }); + } + }; + /** + * Gets an array of LOD properties from lowest to highest. + * @param context + * @param property + * @param array + * @param ids + */ + MSFT_lod.prototype._getLODs = function (context, property, array, ids) { + if (this.maxLODsToLoad <= 0) { + throw new Error("maxLODsToLoad must be greater than zero"); + } + var properties = new Array(); + for (var i = ids.length - 1; i >= 0; i--) { + properties.push(_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(context, "/ids/").concat(ids[i]), array, ids[i])); + if (properties.length === this.maxLODsToLoad) { + return properties; + } + } + properties.push(property); + return properties; + }; + MSFT_lod.prototype._disposeTransformNode = function (babylonTransformNode) { + var _this = this; + var babylonMaterials = new Array(); + var babylonMaterial = babylonTransformNode.material; + if (babylonMaterial) { + babylonMaterials.push(babylonMaterial); + } + for (var _i = 0, _a = babylonTransformNode.getChildMeshes(); _i < _a.length; _i++) { + var babylonMesh = _a[_i]; + if (babylonMesh.material) { + babylonMaterials.push(babylonMesh.material); + } + } + babylonTransformNode.dispose(); + var babylonMaterialsToDispose = babylonMaterials.filter(function (babylonMaterial) { return _this._loader.babylonScene.meshes.every(function (mesh) { return mesh.material != babylonMaterial; }); }); + this._disposeMaterials(babylonMaterialsToDispose); + }; + MSFT_lod.prototype._disposeMaterials = function (babylonMaterials) { + var babylonTextures = {}; + for (var _i = 0, babylonMaterials_1 = babylonMaterials; _i < babylonMaterials_1.length; _i++) { + var babylonMaterial = babylonMaterials_1[_i]; + for (var _a = 0, _b = babylonMaterial.getActiveTextures(); _a < _b.length; _a++) { + var babylonTexture = _b[_a]; + babylonTextures[babylonTexture.uniqueId] = babylonTexture; + } + babylonMaterial.dispose(); + } + for (var uniqueId in babylonTextures) { + for (var _c = 0, _d = this._loader.babylonScene.materials; _c < _d.length; _c++) { + var babylonMaterial = _d[_c]; + if (babylonMaterial.hasTexture(babylonTextures[uniqueId])) { + delete babylonTextures[uniqueId]; + } + } + } + for (var uniqueId in babylonTextures) { + babylonTextures[uniqueId].dispose(); + } + }; + return MSFT_lod; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_lod(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.ts": +/*!**************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.ts ***! + \**************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ MSFT_minecraftMesh: () => (/* binding */ MSFT_minecraftMesh) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "MSFT_minecraftMesh"; +/** @internal */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var MSFT_minecraftMesh = /** @class */ (function () { + /** @internal */ + function MSFT_minecraftMesh(loader) { + /** @internal */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + MSFT_minecraftMesh.prototype.dispose = function () { + this._loader = null; + }; + /** @internal */ + MSFT_minecraftMesh.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtraAsync(context, material, this.name, function (extraContext, extra) { + if (extra) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(extraContext, ": Material type not supported")); + } + var promise = _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial); + if (babylonMaterial.needAlphaBlending()) { + babylonMaterial.forceDepthWrite = true; + babylonMaterial.separateCullingPass = true; + } + babylonMaterial.backFaceCulling = babylonMaterial.forceDepthWrite; + babylonMaterial.twoSidedLighting = true; + return promise; + } + return null; + }); + }; + return MSFT_minecraftMesh; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_minecraftMesh(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts": +/*!************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts ***! + \************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ MSFT_sRGBFactors: () => (/* binding */ MSFT_sRGBFactors) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "MSFT_sRGBFactors"; +/** @internal */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var MSFT_sRGBFactors = /** @class */ (function () { + /** @internal */ + function MSFT_sRGBFactors(loader) { + /** @internal */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + MSFT_sRGBFactors.prototype.dispose = function () { + this._loader = null; + }; + /** @internal */ + MSFT_sRGBFactors.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtraAsync(context, material, this.name, function (extraContext, extra) { + if (extra) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(extraContext, ": Material type not supported")); + } + var promise = _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial); + var useExactSrgbConversions = babylonMaterial.getScene().getEngine().useExactSrgbConversions; + if (!babylonMaterial.albedoTexture) { + babylonMaterial.albedoColor.toLinearSpaceToRef(babylonMaterial.albedoColor, useExactSrgbConversions); + } + if (!babylonMaterial.reflectivityTexture) { + babylonMaterial.reflectivityColor.toLinearSpaceToRef(babylonMaterial.reflectivityColor, useExactSrgbConversions); + } + return promise; + } + return null; + }); + }; + return MSFT_sRGBFactors; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_sRGBFactors(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/index.ts": +/*!*************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/index.ts ***! + \*************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_lights_image_based: () => (/* reexport safe */ _EXT_lights_image_based__WEBPACK_IMPORTED_MODULE_0__.EXT_lights_image_based), +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* reexport safe */ _EXT_mesh_gpu_instancing__WEBPACK_IMPORTED_MODULE_1__.EXT_mesh_gpu_instancing), +/* harmony export */ EXT_meshopt_compression: () => (/* reexport safe */ _EXT_meshopt_compression__WEBPACK_IMPORTED_MODULE_2__.EXT_meshopt_compression), +/* harmony export */ EXT_texture_webp: () => (/* reexport safe */ _EXT_texture_webp__WEBPACK_IMPORTED_MODULE_3__.EXT_texture_webp), +/* harmony export */ ExtrasAsMetadata: () => (/* reexport safe */ _ExtrasAsMetadata__WEBPACK_IMPORTED_MODULE_28__.ExtrasAsMetadata), +/* harmony export */ KHR_animation_pointer: () => (/* reexport safe */ _KHR_animation_pointer__WEBPACK_IMPORTED_MODULE_23__.KHR_animation_pointer), +/* harmony export */ KHR_draco_mesh_compression: () => (/* reexport safe */ _KHR_draco_mesh_compression__WEBPACK_IMPORTED_MODULE_4__.KHR_draco_mesh_compression), +/* harmony export */ KHR_lights: () => (/* reexport safe */ _KHR_lights_punctual__WEBPACK_IMPORTED_MODULE_5__.KHR_lights), +/* harmony export */ KHR_materials_anisotropy: () => (/* reexport safe */ _KHR_materials_anisotropy__WEBPACK_IMPORTED_MODULE_10__.KHR_materials_anisotropy), +/* harmony export */ KHR_materials_clearcoat: () => (/* reexport safe */ _KHR_materials_clearcoat__WEBPACK_IMPORTED_MODULE_8__.KHR_materials_clearcoat), +/* harmony export */ KHR_materials_emissive_strength: () => (/* reexport safe */ _KHR_materials_emissive_strength__WEBPACK_IMPORTED_MODULE_11__.KHR_materials_emissive_strength), +/* harmony export */ KHR_materials_ior: () => (/* reexport safe */ _KHR_materials_ior__WEBPACK_IMPORTED_MODULE_14__.KHR_materials_ior), +/* harmony export */ KHR_materials_iridescence: () => (/* reexport safe */ _KHR_materials_iridescence__WEBPACK_IMPORTED_MODULE_9__.KHR_materials_iridescence), +/* harmony export */ KHR_materials_pbrSpecularGlossiness: () => (/* reexport safe */ _KHR_materials_pbrSpecularGlossiness__WEBPACK_IMPORTED_MODULE_6__.KHR_materials_pbrSpecularGlossiness), +/* harmony export */ KHR_materials_sheen: () => (/* reexport safe */ _KHR_materials_sheen__WEBPACK_IMPORTED_MODULE_12__.KHR_materials_sheen), +/* harmony export */ KHR_materials_specular: () => (/* reexport safe */ _KHR_materials_specular__WEBPACK_IMPORTED_MODULE_13__.KHR_materials_specular), +/* harmony export */ KHR_materials_translucency: () => (/* reexport safe */ _KHR_materials_translucency__WEBPACK_IMPORTED_MODULE_17__.KHR_materials_translucency), +/* harmony export */ KHR_materials_transmission: () => (/* reexport safe */ _KHR_materials_transmission__WEBPACK_IMPORTED_MODULE_16__.KHR_materials_transmission), +/* harmony export */ KHR_materials_unlit: () => (/* reexport safe */ _KHR_materials_unlit__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_unlit), +/* harmony export */ KHR_materials_variants: () => (/* reexport safe */ _KHR_materials_variants__WEBPACK_IMPORTED_MODULE_15__.KHR_materials_variants), +/* harmony export */ KHR_materials_volume: () => (/* reexport safe */ _KHR_materials_volume__WEBPACK_IMPORTED_MODULE_18__.KHR_materials_volume), +/* harmony export */ KHR_mesh_quantization: () => (/* reexport safe */ _KHR_mesh_quantization__WEBPACK_IMPORTED_MODULE_19__.KHR_mesh_quantization), +/* harmony export */ KHR_texture_basisu: () => (/* reexport safe */ _KHR_texture_basisu__WEBPACK_IMPORTED_MODULE_20__.KHR_texture_basisu), +/* harmony export */ KHR_texture_transform: () => (/* reexport safe */ _KHR_texture_transform__WEBPACK_IMPORTED_MODULE_21__.KHR_texture_transform), +/* harmony export */ KHR_xmp_json_ld: () => (/* reexport safe */ _KHR_xmp_json_ld__WEBPACK_IMPORTED_MODULE_22__.KHR_xmp_json_ld), +/* harmony export */ MSFT_audio_emitter: () => (/* reexport safe */ _MSFT_audio_emitter__WEBPACK_IMPORTED_MODULE_24__.MSFT_audio_emitter), +/* harmony export */ MSFT_lod: () => (/* reexport safe */ _MSFT_lod__WEBPACK_IMPORTED_MODULE_25__.MSFT_lod), +/* harmony export */ MSFT_minecraftMesh: () => (/* reexport safe */ _MSFT_minecraftMesh__WEBPACK_IMPORTED_MODULE_26__.MSFT_minecraftMesh), +/* harmony export */ MSFT_sRGBFactors: () => (/* reexport safe */ _MSFT_sRGBFactors__WEBPACK_IMPORTED_MODULE_27__.MSFT_sRGBFactors) +/* harmony export */ }); +/* harmony import */ var _EXT_lights_image_based__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./EXT_lights_image_based */ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.ts"); +/* harmony import */ var _EXT_mesh_gpu_instancing__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EXT_mesh_gpu_instancing */ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts"); +/* harmony import */ var _EXT_meshopt_compression__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./EXT_meshopt_compression */ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_meshopt_compression.ts"); +/* harmony import */ var _EXT_texture_webp__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./EXT_texture_webp */ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_texture_webp.ts"); +/* harmony import */ var _KHR_draco_mesh_compression__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./KHR_draco_mesh_compression */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts"); +/* harmony import */ var _KHR_lights_punctual__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./KHR_lights_punctual */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts"); +/* harmony import */ var _KHR_materials_pbrSpecularGlossiness__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./KHR_materials_pbrSpecularGlossiness */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts"); +/* harmony import */ var _KHR_materials_unlit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./KHR_materials_unlit */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_unlit.ts"); +/* harmony import */ var _KHR_materials_clearcoat__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./KHR_materials_clearcoat */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts"); +/* harmony import */ var _KHR_materials_iridescence__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./KHR_materials_iridescence */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts"); +/* harmony import */ var _KHR_materials_anisotropy__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./KHR_materials_anisotropy */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts"); +/* harmony import */ var _KHR_materials_emissive_strength__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./KHR_materials_emissive_strength */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts"); +/* harmony import */ var _KHR_materials_sheen__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./KHR_materials_sheen */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_sheen.ts"); +/* harmony import */ var _KHR_materials_specular__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./KHR_materials_specular */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts"); +/* harmony import */ var _KHR_materials_ior__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./KHR_materials_ior */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_ior.ts"); +/* harmony import */ var _KHR_materials_variants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./KHR_materials_variants */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_variants.ts"); +/* harmony import */ var _KHR_materials_transmission__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./KHR_materials_transmission */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts"); +/* harmony import */ var _KHR_materials_translucency__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./KHR_materials_translucency */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_translucency.ts"); +/* harmony import */ var _KHR_materials_volume__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./KHR_materials_volume */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_volume.ts"); +/* harmony import */ var _KHR_mesh_quantization__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./KHR_mesh_quantization */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_mesh_quantization.ts"); +/* harmony import */ var _KHR_texture_basisu__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./KHR_texture_basisu */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_basisu.ts"); +/* harmony import */ var _KHR_texture_transform__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./KHR_texture_transform */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_transform.ts"); +/* harmony import */ var _KHR_xmp_json_ld__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./KHR_xmp_json_ld */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_xmp_json_ld.ts"); +/* harmony import */ var _KHR_animation_pointer__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./KHR_animation_pointer */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.ts"); +/* harmony import */ var _MSFT_audio_emitter__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./MSFT_audio_emitter */ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts"); +/* harmony import */ var _MSFT_lod__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./MSFT_lod */ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts"); +/* harmony import */ var _MSFT_minecraftMesh__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./MSFT_minecraftMesh */ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.ts"); +/* harmony import */ var _MSFT_sRGBFactors__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./MSFT_sRGBFactors */ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts"); +/* harmony import */ var _ExtrasAsMetadata__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./ExtrasAsMetadata */ "../../../dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts"); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts": +/*!*******************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/glTFLoader.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ ArrayItem: () => (/* binding */ ArrayItem), +/* harmony export */ GLTFLoader: () => (/* binding */ GLTFLoader) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Culling/boundingInfo */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFFileLoader */ "../../../dev/loaders/src/glTF/glTFFileLoader.ts"); +/* harmony import */ var _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderAnimation */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts"); + + + + + + + + + + + + + + + + + + + + + + + + +// https://stackoverflow.com/a/48218209 +function mergeDeep() { + var objects = []; + for (var _i = 0; _i < arguments.length; _i++) { + objects[_i] = arguments[_i]; + } + var isObject = function (obj) { return obj && typeof obj === "object"; }; + return objects.reduce(function (prev, obj) { + Object.keys(obj).forEach(function (key) { + var pVal = prev[key]; + var oVal = obj[key]; + if (Array.isArray(pVal) && Array.isArray(oVal)) { + prev[key] = pVal.concat.apply(pVal, oVal); + } + else if (isObject(pVal) && isObject(oVal)) { + prev[key] = mergeDeep(pVal, oVal); + } + else { + prev[key] = oVal; + } + }); + return prev; + }, {}); +} +/** + * Helper class for working with arrays when loading the glTF asset + */ +var ArrayItem = /** @class */ (function () { + function ArrayItem() { + } + /** + * Gets an item from the given array. + * @param context The context when loading the asset + * @param array The array to get the item from + * @param index The index to the array + * @returns The array item + */ + ArrayItem.Get = function (context, array, index) { + if (!array || index == undefined || !array[index]) { + throw new Error("".concat(context, ": Failed to find index (").concat(index, ")")); + } + return array[index]; + }; + /** + * Gets an item from the given array or returns null if not available. + * @param array The array to get the item from + * @param index The index to the array + * @returns The array item or null + */ + ArrayItem.TryGet = function (array, index) { + if (!array || index == undefined || !array[index]) { + return null; + } + return array[index]; + }; + /** + * Assign an `index` field to each item of the given array. + * @param array The array of items + */ + ArrayItem.Assign = function (array) { + if (array) { + for (var index = 0; index < array.length; index++) { + array[index].index = index; + } + } + }; + return ArrayItem; +}()); + +/** + * The glTF 2.0 loader + */ +var GLTFLoader = /** @class */ (function () { + /** + * @internal + */ + function GLTFLoader(parent) { + /** @internal */ + this._completePromises = new Array(); + /** @internal */ + this._assetContainer = null; + /** Storage */ + this._babylonLights = []; + /** @internal */ + this._disableInstancedMesh = 0; + this._extensions = new Array(); + this._disposed = false; + this._rootUrl = null; + this._fileName = null; + this._uniqueRootUrl = null; + this._bin = null; + this._rootBabylonMesh = null; + this._defaultBabylonMaterialData = {}; + this._postSceneLoadActions = new Array(); + this._parent = parent; + } + /** + * Registers a loader extension. + * @param name The name of the loader extension. + * @param factory The factory function that creates the loader extension. + */ + GLTFLoader.RegisterExtension = function (name, factory) { + if (GLTFLoader.UnregisterExtension(name)) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Extension with the name '".concat(name, "' already exists")); + } + GLTFLoader._RegisteredExtensions[name] = { + factory: factory, + }; + }; + /** + * Unregisters a loader extension. + * @param name The name of the loader extension. + * @returns A boolean indicating whether the extension has been unregistered + */ + GLTFLoader.UnregisterExtension = function (name) { + if (!GLTFLoader._RegisteredExtensions[name]) { + return false; + } + delete GLTFLoader._RegisteredExtensions[name]; + return true; + }; + Object.defineProperty(GLTFLoader.prototype, "gltf", { + /** + * The object that represents the glTF JSON. + */ + get: function () { + if (!this._gltf) { + throw new Error("glTF JSON is not available"); + } + return this._gltf; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFLoader.prototype, "bin", { + /** + * The BIN chunk of a binary glTF. + */ + get: function () { + return this._bin; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFLoader.prototype, "parent", { + /** + * The parent file loader. + */ + get: function () { + return this._parent; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFLoader.prototype, "babylonScene", { + /** + * The Babylon scene when loading the asset. + */ + get: function () { + if (!this._babylonScene) { + throw new Error("Scene is not available"); + } + return this._babylonScene; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFLoader.prototype, "rootBabylonMesh", { + /** + * The root Babylon mesh when loading the asset. + */ + get: function () { + return this._rootBabylonMesh; + }, + enumerable: false, + configurable: true + }); + /** @internal */ + GLTFLoader.prototype.dispose = function () { + if (this._disposed) { + return; + } + this._disposed = true; + this._completePromises.length = 0; + this._extensions.forEach(function (extension) { return extension.dispose && extension.dispose(); }); + this._extensions.length = 0; + this._gltf = null; // TODO + this._bin = null; + this._babylonScene = null; // TODO + this._rootBabylonMesh = null; + this._defaultBabylonMaterialData = {}; + this._postSceneLoadActions.length = 0; + this._parent.dispose(); + }; + /** + * @internal + */ + GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, container, data, rootUrl, onProgress, fileName) { + var _this = this; + if (fileName === void 0) { fileName = ""; } + return Promise.resolve().then(function () { + _this._babylonScene = scene; + _this._assetContainer = container; + _this._loadData(data); + var nodes = null; + if (meshesNames) { + var nodeMap_1 = {}; + if (_this._gltf.nodes) { + for (var _i = 0, _a = _this._gltf.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.name) { + nodeMap_1[node.name] = node.index; + } + } + } + var names = meshesNames instanceof Array ? meshesNames : [meshesNames]; + nodes = names.map(function (name) { + var node = nodeMap_1[name]; + if (node === undefined) { + throw new Error("Failed to find node '".concat(name, "'")); + } + return node; + }); + } + return _this._loadAsync(rootUrl, fileName, nodes, function () { + return { + meshes: _this._getMeshes(), + particleSystems: [], + skeletons: _this._getSkeletons(), + animationGroups: _this._getAnimationGroups(), + lights: _this._babylonLights, + transformNodes: _this._getTransformNodes(), + geometries: _this._getGeometries(), + }; + }); + }); + }; + /** + * @internal + */ + GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) { + var _this = this; + if (fileName === void 0) { fileName = ""; } + return Promise.resolve().then(function () { + _this._babylonScene = scene; + _this._loadData(data); + return _this._loadAsync(rootUrl, fileName, null, function () { return undefined; }); + }); + }; + GLTFLoader.prototype._loadAsync = function (rootUrl, fileName, nodes, resultFunc) { + var _this = this; + return Promise.resolve() + .then(function () { + _this._rootUrl = rootUrl; + _this._uniqueRootUrl = !rootUrl.startsWith("file:") && fileName ? rootUrl : "".concat(rootUrl).concat(Date.now(), "/"); + _this._fileName = fileName; + _this._loadExtensions(); + _this._checkExtensions(); + var loadingToReadyCounterName = "".concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.LOADING], " => ").concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.READY]); + var loadingToCompleteCounterName = "".concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.LOADING], " => ").concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.COMPLETE]); + _this._parent._startPerformanceCounter(loadingToReadyCounterName); + _this._parent._startPerformanceCounter(loadingToCompleteCounterName); + _this._parent._setState(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.LOADING); + _this._extensionsOnLoading(); + var promises = new Array(); + // Block the marking of materials dirty until the scene is loaded. + var oldBlockMaterialDirtyMechanism = _this._babylonScene.blockMaterialDirtyMechanism; + _this._babylonScene.blockMaterialDirtyMechanism = true; + if (!_this.parent.loadOnlyMaterials) { + if (nodes) { + promises.push(_this.loadSceneAsync("/nodes", { nodes: nodes, index: -1 })); + } + else if (_this._gltf.scene != undefined || (_this._gltf.scenes && _this._gltf.scenes[0])) { + var scene = ArrayItem.Get("/scene", _this._gltf.scenes, _this._gltf.scene || 0); + promises.push(_this.loadSceneAsync("/scenes/".concat(scene.index), scene)); + } + } + if (!_this.parent.skipMaterials && _this.parent.loadAllMaterials && _this._gltf.materials) { + for (var m = 0; m < _this._gltf.materials.length; ++m) { + var material = _this._gltf.materials[m]; + var context_1 = "/materials/" + m; + var babylonDrawMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFillMode; + promises.push(_this._loadMaterialAsync(context_1, material, null, babylonDrawMode, function () { })); + } + } + // Restore the blocking of material dirty. + _this._babylonScene.blockMaterialDirtyMechanism = oldBlockMaterialDirtyMechanism; + if (_this._parent.compileMaterials) { + promises.push(_this._compileMaterialsAsync()); + } + if (_this._parent.compileShadowGenerators) { + promises.push(_this._compileShadowGeneratorsAsync()); + } + var resultPromise = Promise.all(promises).then(function () { + if (_this._rootBabylonMesh) { + _this._rootBabylonMesh.setEnabled(true); + } + _this._extensionsOnReady(); + _this._parent._setState(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.READY); + _this._startAnimations(); + return resultFunc(); + }); + return resultPromise.then(function (result) { + _this._parent._endPerformanceCounter(loadingToReadyCounterName); + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Tools.SetImmediate(function () { + if (!_this._disposed) { + Promise.all(_this._completePromises).then(function () { + _this._parent._endPerformanceCounter(loadingToCompleteCounterName); + _this._parent._setState(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.COMPLETE); + _this._parent.onCompleteObservable.notifyObservers(undefined); + _this._parent.onCompleteObservable.clear(); + _this.dispose(); + }, function (error) { + _this._parent.onErrorObservable.notifyObservers(error); + _this._parent.onErrorObservable.clear(); + _this.dispose(); + }); + } + }); + return result; + }); + }) + .catch(function (error) { + if (!_this._disposed) { + _this._parent.onErrorObservable.notifyObservers(error); + _this._parent.onErrorObservable.clear(); + _this.dispose(); + } + throw error; + }); + }; + GLTFLoader.prototype._loadData = function (data) { + this._gltf = data.json; + this._setupData(); + if (data.bin) { + var buffers = this._gltf.buffers; + if (buffers && buffers[0] && !buffers[0].uri) { + var binaryBuffer = buffers[0]; + if (binaryBuffer.byteLength < data.bin.byteLength - 3 || binaryBuffer.byteLength > data.bin.byteLength) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Binary buffer length (".concat(binaryBuffer.byteLength, ") from JSON does not match chunk length (").concat(data.bin.byteLength, ")")); + } + this._bin = data.bin; + } + else { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Unexpected BIN chunk"); + } + } + }; + GLTFLoader.prototype._setupData = function () { + ArrayItem.Assign(this._gltf.accessors); + ArrayItem.Assign(this._gltf.animations); + ArrayItem.Assign(this._gltf.buffers); + ArrayItem.Assign(this._gltf.bufferViews); + ArrayItem.Assign(this._gltf.cameras); + ArrayItem.Assign(this._gltf.images); + ArrayItem.Assign(this._gltf.materials); + ArrayItem.Assign(this._gltf.meshes); + ArrayItem.Assign(this._gltf.nodes); + ArrayItem.Assign(this._gltf.samplers); + ArrayItem.Assign(this._gltf.scenes); + ArrayItem.Assign(this._gltf.skins); + ArrayItem.Assign(this._gltf.textures); + if (this._gltf.nodes) { + var nodeParents = {}; + for (var _i = 0, _a = this._gltf.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.children) { + for (var _b = 0, _c = node.children; _b < _c.length; _b++) { + var index = _c[_b]; + nodeParents[index] = node.index; + } + } + } + var rootNode = this._createRootNode(); + for (var _d = 0, _e = this._gltf.nodes; _d < _e.length; _d++) { + var node = _e[_d]; + var parentIndex = nodeParents[node.index]; + node.parent = parentIndex === undefined ? rootNode : this._gltf.nodes[parentIndex]; + } + } + }; + GLTFLoader.prototype._loadExtensions = function () { + for (var name_1 in GLTFLoader._RegisteredExtensions) { + var extension = GLTFLoader._RegisteredExtensions[name_1].factory(this); + if (extension.name !== name_1) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("The name of the glTF loader extension instance does not match the registered name: ".concat(extension.name, " !== ").concat(name_1)); + } + this._extensions.push(extension); + this._parent.onExtensionLoadedObservable.notifyObservers(extension); + } + this._extensions.sort(function (a, b) { return (a.order || Number.MAX_VALUE) - (b.order || Number.MAX_VALUE); }); + this._parent.onExtensionLoadedObservable.clear(); + }; + GLTFLoader.prototype._checkExtensions = function () { + if (this._gltf.extensionsRequired) { + var _loop_1 = function (name_2) { + var available = this_1._extensions.some(function (extension) { return extension.name === name_2 && extension.enabled; }); + if (!available) { + throw new Error("Require extension ".concat(name_2, " is not available")); + } + }; + var this_1 = this; + for (var _i = 0, _a = this._gltf.extensionsRequired; _i < _a.length; _i++) { + var name_2 = _a[_i]; + _loop_1(name_2); + } + } + }; + GLTFLoader.prototype._createRootNode = function () { + this._babylonScene._blockEntityCollection = !!this._assetContainer; + this._rootBabylonMesh = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Mesh("__root__", this._babylonScene); + this._rootBabylonMesh._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + this._rootBabylonMesh.setEnabled(false); + var rootNode = { + _babylonTransformNode: this._rootBabylonMesh, + index: -1, + }; + switch (this._parent.coordinateSystemMode) { + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderCoordinateSystemMode.AUTO: { + if (!this._babylonScene.useRightHandedSystem) { + rootNode.rotation = [0, 1, 0, 0]; + rootNode.scale = [1, 1, -1]; + GLTFLoader._LoadTransform(rootNode, this._rootBabylonMesh); + } + break; + } + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED: { + this._babylonScene.useRightHandedSystem = true; + break; + } + default: { + throw new Error("Invalid coordinate system mode (".concat(this._parent.coordinateSystemMode, ")")); + } + } + this._parent.onMeshLoadedObservable.notifyObservers(this._rootBabylonMesh); + return rootNode; + }; + /** + * Loads a glTF scene. + * @param context The context when loading the asset + * @param scene The glTF scene property + * @returns A promise that resolves when the load is complete + */ + GLTFLoader.prototype.loadSceneAsync = function (context, scene) { + var _this = this; + var extensionPromise = this._extensionsLoadSceneAsync(context, scene); + if (extensionPromise) { + return extensionPromise; + } + var promises = new Array(); + this.logOpen("".concat(context, " ").concat(scene.name || "")); + if (scene.nodes) { + for (var _i = 0, _a = scene.nodes; _i < _a.length; _i++) { + var index = _a[_i]; + var node = ArrayItem.Get("".concat(context, "/nodes/").concat(index), this._gltf.nodes, index); + promises.push(this.loadNodeAsync("/nodes/".concat(node.index), node, function (babylonMesh) { + babylonMesh.parent = _this._rootBabylonMesh; + })); + } + } + for (var _b = 0, _c = this._postSceneLoadActions; _b < _c.length; _b++) { + var action = _c[_b]; + action(); + } + promises.push(this._loadAnimationsAsync()); + this.logClose(); + return Promise.all(promises).then(function () { }); + }; + GLTFLoader.prototype._forEachPrimitive = function (node, callback) { + if (node._primitiveBabylonMeshes) { + for (var _i = 0, _a = node._primitiveBabylonMeshes; _i < _a.length; _i++) { + var babylonMesh = _a[_i]; + callback(babylonMesh); + } + } + }; + GLTFLoader.prototype._getGeometries = function () { + var geometries = new Array(); + var nodes = this._gltf.nodes; + if (nodes) { + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; + this._forEachPrimitive(node, function (babylonMesh) { + var geometry = babylonMesh.geometry; + if (geometry && geometries.indexOf(geometry) === -1) { + geometries.push(geometry); + } + }); + } + } + return geometries; + }; + GLTFLoader.prototype._getMeshes = function () { + var meshes = new Array(); + // Root mesh is always first, if available. + if (this._rootBabylonMesh) { + meshes.push(this._rootBabylonMesh); + } + var nodes = this._gltf.nodes; + if (nodes) { + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var node = nodes_2[_i]; + this._forEachPrimitive(node, function (babylonMesh) { + meshes.push(babylonMesh); + }); + } + } + return meshes; + }; + GLTFLoader.prototype._getTransformNodes = function () { + var transformNodes = new Array(); + var nodes = this._gltf.nodes; + if (nodes) { + for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) { + var node = nodes_3[_i]; + if (node._babylonTransformNode && node._babylonTransformNode.getClassName() === "TransformNode") { + transformNodes.push(node._babylonTransformNode); + } + if (node._babylonTransformNodeForSkin) { + transformNodes.push(node._babylonTransformNodeForSkin); + } + } + } + return transformNodes; + }; + GLTFLoader.prototype._getSkeletons = function () { + var skeletons = new Array(); + var skins = this._gltf.skins; + if (skins) { + for (var _i = 0, skins_1 = skins; _i < skins_1.length; _i++) { + var skin = skins_1[_i]; + if (skin._data) { + skeletons.push(skin._data.babylonSkeleton); + } + } + } + return skeletons; + }; + GLTFLoader.prototype._getAnimationGroups = function () { + var animationGroups = new Array(); + var animations = this._gltf.animations; + if (animations) { + for (var _i = 0, animations_1 = animations; _i < animations_1.length; _i++) { + var animation = animations_1[_i]; + if (animation._babylonAnimationGroup) { + animationGroups.push(animation._babylonAnimationGroup); + } + } + } + return animationGroups; + }; + GLTFLoader.prototype._startAnimations = function () { + switch (this._parent.animationStartMode) { + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderAnimationStartMode.NONE: { + // do nothing + break; + } + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderAnimationStartMode.FIRST: { + var babylonAnimationGroups = this._getAnimationGroups(); + if (babylonAnimationGroups.length !== 0) { + babylonAnimationGroups[0].start(true); + } + break; + } + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderAnimationStartMode.ALL: { + var babylonAnimationGroups = this._getAnimationGroups(); + for (var _i = 0, babylonAnimationGroups_1 = babylonAnimationGroups; _i < babylonAnimationGroups_1.length; _i++) { + var babylonAnimationGroup = babylonAnimationGroups_1[_i]; + babylonAnimationGroup.start(true); + } + break; + } + default: { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Error("Invalid animation start mode (".concat(this._parent.animationStartMode, ")")); + return; + } + } + }; + /** + * Loads a glTF node. + * @param context The context when loading the asset + * @param node The glTF node property + * @param assign A function called synchronously after parsing the glTF properties + * @returns A promise that resolves with the loaded Babylon mesh when the load is complete + */ + GLTFLoader.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadNodeAsync(context, node, assign); + if (extensionPromise) { + return extensionPromise; + } + if (node._babylonTransformNode) { + throw new Error("".concat(context, ": Invalid recursive node hierarchy")); + } + var promises = new Array(); + this.logOpen("".concat(context, " ").concat(node.name || "")); + var loadNode = function (babylonTransformNode) { + GLTFLoader.AddPointerMetadata(babylonTransformNode, context); + GLTFLoader._LoadTransform(node, babylonTransformNode); + if (node.camera != undefined) { + var camera = ArrayItem.Get("".concat(context, "/camera"), _this._gltf.cameras, node.camera); + promises.push(_this.loadCameraAsync("/cameras/".concat(camera.index), camera, function (babylonCamera) { + babylonCamera.parent = babylonTransformNode; + })); + } + if (node.children) { + for (var _i = 0, _a = node.children; _i < _a.length; _i++) { + var index = _a[_i]; + var childNode = ArrayItem.Get("".concat(context, "/children/").concat(index), _this._gltf.nodes, index); + promises.push(_this.loadNodeAsync("/nodes/".concat(childNode.index), childNode, function (childBabylonMesh) { + childBabylonMesh.parent = babylonTransformNode; + })); + } + } + assign(babylonTransformNode); + }; + if (node.mesh == undefined || node.skin != undefined) { + var nodeName = node.name || "node".concat(node.index); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var transformNode = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TransformNode(nodeName, this._babylonScene); + transformNode._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + if (node.mesh == undefined) { + node._babylonTransformNode = transformNode; + } + else { + node._babylonTransformNodeForSkin = transformNode; + } + loadNode(transformNode); + } + if (node.mesh != undefined) { + if (node.skin == undefined) { + var mesh = ArrayItem.Get("".concat(context, "/mesh"), this._gltf.meshes, node.mesh); + promises.push(this._loadMeshAsync("/meshes/".concat(mesh.index), node, mesh, loadNode)); + } + else { + // See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note) + // This code path will place the skinned mesh as a sibling of the skeleton root node without loading the + // transform, which effectively ignores the transform of the skinned mesh, as per spec. + var mesh = ArrayItem.Get("".concat(context, "/mesh"), this._gltf.meshes, node.mesh); + promises.push(this._loadMeshAsync("/meshes/".concat(mesh.index), node, mesh, function (babylonTransformNode) { + var babylonTransformNodeForSkin = node._babylonTransformNodeForSkin; + // Merge the metadata from the skin node to the skinned mesh in case a loader extension added metadata. + babylonTransformNode.metadata = mergeDeep(babylonTransformNodeForSkin.metadata, babylonTransformNode.metadata || {}); + var skin = ArrayItem.Get("".concat(context, "/skin"), _this._gltf.skins, node.skin); + promises.push(_this._loadSkinAsync("/skins/".concat(skin.index), node, skin, function (babylonSkeleton) { + _this._forEachPrimitive(node, function (babylonMesh) { + babylonMesh.skeleton = babylonSkeleton; + }); + // Wait until all the nodes are parented before parenting the skinned mesh. + _this._postSceneLoadActions.push(function () { + if (skin.skeleton != undefined) { + // Place the skinned mesh node as a sibling of the skeleton root node. + // Handle special case when the parent of the skeleton root is the skinned mesh. + var parentNode = ArrayItem.Get("/skins/".concat(skin.index, "/skeleton"), _this._gltf.nodes, skin.skeleton).parent; + if (node.index === parentNode.index) { + babylonTransformNode.parent = babylonTransformNodeForSkin.parent; + } + else { + babylonTransformNode.parent = parentNode._babylonTransformNode; + } + } + else { + babylonTransformNode.parent = _this._rootBabylonMesh; + } + _this._parent.onSkinLoadedObservable.notifyObservers({ node: babylonTransformNodeForSkin, skinnedNode: babylonTransformNode }); + }); + })); + })); + } + } + this.logClose(); + return Promise.all(promises).then(function () { + _this._forEachPrimitive(node, function (babylonMesh) { + if (babylonMesh.geometry && babylonMesh.geometry.useBoundingInfoFromGeometry) { + // simply apply the world matrices to the bounding info - the extends are already ok + babylonMesh._updateBoundingInfo(); + } + else { + babylonMesh.refreshBoundingInfo(true); + } + }); + return node._babylonTransformNode; + }); + }; + GLTFLoader.prototype._loadMeshAsync = function (context, node, mesh, assign) { + var primitives = mesh.primitives; + if (!primitives || !primitives.length) { + throw new Error("".concat(context, ": Primitives are missing")); + } + if (primitives[0].index == undefined) { + ArrayItem.Assign(primitives); + } + var promises = new Array(); + this.logOpen("".concat(context, " ").concat(mesh.name || "")); + var name = node.name || "node".concat(node.index); + if (primitives.length === 1) { + var primitive = mesh.primitives[0]; + promises.push(this._loadMeshPrimitiveAsync("".concat(context, "/primitives/").concat(primitive.index), name, node, mesh, primitive, function (babylonMesh) { + node._babylonTransformNode = babylonMesh; + node._primitiveBabylonMeshes = [babylonMesh]; + })); + } + else { + this._babylonScene._blockEntityCollection = !!this._assetContainer; + node._babylonTransformNode = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TransformNode(name, this._babylonScene); + node._babylonTransformNode._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + node._primitiveBabylonMeshes = []; + for (var _i = 0, primitives_1 = primitives; _i < primitives_1.length; _i++) { + var primitive = primitives_1[_i]; + promises.push(this._loadMeshPrimitiveAsync("".concat(context, "/primitives/").concat(primitive.index), "".concat(name, "_primitive").concat(primitive.index), node, mesh, primitive, function (babylonMesh) { + babylonMesh.parent = node._babylonTransformNode; + node._primitiveBabylonMeshes.push(babylonMesh); + })); + } + } + assign(node._babylonTransformNode); + this.logClose(); + return Promise.all(promises).then(function () { + return node._babylonTransformNode; + }); + }; + /** + * @internal Define this method to modify the default behavior when loading data for mesh primitives. + * @param context The context when loading the asset + * @param name The mesh name when loading the asset + * @param node The glTF node when loading the asset + * @param mesh The glTF mesh when loading the asset + * @param primitive The glTF mesh primitive property + * @param assign A function called synchronously after parsing the glTF properties + * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled + */ + GLTFLoader.prototype._loadMeshPrimitiveAsync = function (context, name, node, mesh, primitive, assign) { + var _this = this; + var extensionPromise = this._extensionsLoadMeshPrimitiveAsync(context, name, node, mesh, primitive, assign); + if (extensionPromise) { + return extensionPromise; + } + this.logOpen("".concat(context)); + var shouldInstance = this._disableInstancedMesh === 0 && this._parent.createInstances && node.skin == undefined && !mesh.primitives[0].targets; + var babylonAbstractMesh; + var promise; + if (shouldInstance && primitive._instanceData) { + this._babylonScene._blockEntityCollection = !!this._assetContainer; + babylonAbstractMesh = primitive._instanceData.babylonSourceMesh.createInstance(name); + babylonAbstractMesh._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + promise = primitive._instanceData.promise; + } + else { + var promises = new Array(); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonMesh_1 = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Mesh(name, this._babylonScene); + babylonMesh_1._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + babylonMesh_1.overrideMaterialSideOrientation = this._babylonScene.useRightHandedSystem ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.CounterClockWiseSideOrientation : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.ClockWiseSideOrientation; + this._createMorphTargets(context, node, mesh, primitive, babylonMesh_1); + promises.push(this._loadVertexDataAsync(context, primitive, babylonMesh_1).then(function (babylonGeometry) { + return _this._loadMorphTargetsAsync(context, primitive, babylonMesh_1, babylonGeometry).then(function () { + if (_this._disposed) { + return; + } + _this._babylonScene._blockEntityCollection = !!_this._assetContainer; + babylonGeometry.applyToMesh(babylonMesh_1); + babylonGeometry._parentContainer = _this._assetContainer; + _this._babylonScene._blockEntityCollection = false; + }); + })); + var babylonDrawMode = GLTFLoader._GetDrawMode(context, primitive.mode); + if (primitive.material == undefined) { + var babylonMaterial = this._defaultBabylonMaterialData[babylonDrawMode]; + if (!babylonMaterial) { + babylonMaterial = this._createDefaultMaterial("__GLTFLoader._default", babylonDrawMode); + this._parent.onMaterialLoadedObservable.notifyObservers(babylonMaterial); + this._defaultBabylonMaterialData[babylonDrawMode] = babylonMaterial; + } + babylonMesh_1.material = babylonMaterial; + } + else if (!this.parent.skipMaterials) { + var material = ArrayItem.Get("".concat(context, "/material"), this._gltf.materials, primitive.material); + promises.push(this._loadMaterialAsync("/materials/".concat(material.index), material, babylonMesh_1, babylonDrawMode, function (babylonMaterial) { + babylonMesh_1.material = babylonMaterial; + })); + } + promise = Promise.all(promises); + if (shouldInstance) { + primitive._instanceData = { + babylonSourceMesh: babylonMesh_1, + promise: promise, + }; + } + babylonAbstractMesh = babylonMesh_1; + } + GLTFLoader.AddPointerMetadata(babylonAbstractMesh, context); + this._parent.onMeshLoadedObservable.notifyObservers(babylonAbstractMesh); + assign(babylonAbstractMesh); + this.logClose(); + return promise.then(function () { + return babylonAbstractMesh; + }); + }; + GLTFLoader.prototype._loadVertexDataAsync = function (context, primitive, babylonMesh) { + var _this = this; + var extensionPromise = this._extensionsLoadVertexDataAsync(context, primitive, babylonMesh); + if (extensionPromise) { + return extensionPromise; + } + var attributes = primitive.attributes; + if (!attributes) { + throw new Error("".concat(context, ": Attributes are missing")); + } + var promises = new Array(); + var babylonGeometry = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Geometry(babylonMesh.name, this._babylonScene); + if (primitive.indices == undefined) { + babylonMesh.isUnIndexed = true; + } + else { + var accessor = ArrayItem.Get("".concat(context, "/indices"), this._gltf.accessors, primitive.indices); + promises.push(this._loadIndicesAccessorAsync("/accessors/".concat(accessor.index), accessor).then(function (data) { + babylonGeometry.setIndices(data); + })); + } + var loadAttribute = function (name, kind, callback) { + if (attributes[name] == undefined) { + return; + } + babylonMesh._delayInfo = babylonMesh._delayInfo || []; + if (babylonMesh._delayInfo.indexOf(kind) === -1) { + babylonMesh._delayInfo.push(kind); + } + var accessor = ArrayItem.Get("".concat(context, "/attributes/").concat(name), _this._gltf.accessors, attributes[name]); + promises.push(_this._loadVertexAccessorAsync("/accessors/".concat(accessor.index), accessor, kind).then(function (babylonVertexBuffer) { + var _a, _b; + if (babylonVertexBuffer.getKind() === babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind && !_this.parent.alwaysComputeBoundingBox && !babylonMesh.skeleton) { + if (accessor.min && accessor.max) { + var min = (_a = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0]).copyFromFloats.apply(_a, accessor.min); + var max = (_b = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1]).copyFromFloats.apply(_b, accessor.max); + if (accessor.normalized && accessor.componentType !== 5126 /* AccessorComponentType.FLOAT */) { + var divider = 1; + switch (accessor.componentType) { + case 5120 /* AccessorComponentType.BYTE */: + divider = 127.0; + break; + case 5121 /* AccessorComponentType.UNSIGNED_BYTE */: + divider = 255.0; + break; + case 5122 /* AccessorComponentType.SHORT */: + divider = 32767.0; + break; + case 5123 /* AccessorComponentType.UNSIGNED_SHORT */: + divider = 65535.0; + break; + } + var oneOverDivider = 1 / divider; + min.scaleInPlace(oneOverDivider); + max.scaleInPlace(oneOverDivider); + } + babylonGeometry._boundingInfo = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.BoundingInfo(min, max); + babylonGeometry.useBoundingInfoFromGeometry = true; + } + } + babylonGeometry.setVerticesBuffer(babylonVertexBuffer, accessor.count); + })); + if (kind == babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind) { + babylonMesh.numBoneInfluencers = 8; + } + if (callback) { + callback(accessor); + } + }; + loadAttribute("POSITION", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind); + loadAttribute("NORMAL", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind); + loadAttribute("TANGENT", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind); + loadAttribute("TEXCOORD_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind); + loadAttribute("TEXCOORD_1", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind); + loadAttribute("TEXCOORD_2", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV3Kind); + loadAttribute("TEXCOORD_3", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV4Kind); + loadAttribute("TEXCOORD_4", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV5Kind); + loadAttribute("TEXCOORD_5", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV6Kind); + loadAttribute("JOINTS_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind); + loadAttribute("WEIGHTS_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsKind); + loadAttribute("JOINTS_1", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind); + loadAttribute("WEIGHTS_1", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsExtraKind); + loadAttribute("COLOR_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind, function (accessor) { + if (accessor.type === "VEC4" /* AccessorType.VEC4 */) { + babylonMesh.hasVertexAlpha = true; + } + }); + return Promise.all(promises).then(function () { + return babylonGeometry; + }); + }; + GLTFLoader.prototype._createMorphTargets = function (context, node, mesh, primitive, babylonMesh) { + if (!primitive.targets) { + return; + } + if (node._numMorphTargets == undefined) { + node._numMorphTargets = primitive.targets.length; + } + else if (primitive.targets.length !== node._numMorphTargets) { + throw new Error("".concat(context, ": Primitives do not have the same number of targets")); + } + var targetNames = mesh.extras ? mesh.extras.targetNames : null; + this._babylonScene._blockEntityCollection = !!this._assetContainer; + babylonMesh.morphTargetManager = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.MorphTargetManager(this._babylonScene); + babylonMesh.morphTargetManager._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + babylonMesh.morphTargetManager.areUpdatesFrozen = true; + for (var index = 0; index < primitive.targets.length; index++) { + var weight = node.weights ? node.weights[index] : mesh.weights ? mesh.weights[index] : 0; + var name_3 = targetNames ? targetNames[index] : "morphTarget".concat(index); + babylonMesh.morphTargetManager.addTarget(new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.MorphTarget(name_3, weight, babylonMesh.getScene())); + // TODO: tell the target whether it has positions, normals, tangents + } + }; + GLTFLoader.prototype._loadMorphTargetsAsync = function (context, primitive, babylonMesh, babylonGeometry) { + if (!primitive.targets) { + return Promise.resolve(); + } + var promises = new Array(); + var morphTargetManager = babylonMesh.morphTargetManager; + for (var index = 0; index < morphTargetManager.numTargets; index++) { + var babylonMorphTarget = morphTargetManager.getTarget(index); + promises.push(this._loadMorphTargetVertexDataAsync("".concat(context, "/targets/").concat(index), babylonGeometry, primitive.targets[index], babylonMorphTarget)); + } + return Promise.all(promises).then(function () { + morphTargetManager.areUpdatesFrozen = false; + }); + }; + GLTFLoader.prototype._loadMorphTargetVertexDataAsync = function (context, babylonGeometry, attributes, babylonMorphTarget) { + var _this = this; + var promises = new Array(); + var loadAttribute = function (attribute, kind, setData) { + if (attributes[attribute] == undefined) { + return; + } + var babylonVertexBuffer = babylonGeometry.getVertexBuffer(kind); + if (!babylonVertexBuffer) { + return; + } + var accessor = ArrayItem.Get("".concat(context, "/").concat(attribute), _this._gltf.accessors, attributes[attribute]); + promises.push(_this._loadFloatAccessorAsync("/accessors/".concat(accessor.index), accessor).then(function (data) { + setData(babylonVertexBuffer, data); + })); + }; + loadAttribute("POSITION", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind, function (babylonVertexBuffer, data) { + var positions = new Float32Array(data.length); + babylonVertexBuffer.forEach(data.length, function (value, index) { + positions[index] = data[index] + value; + }); + babylonMorphTarget.setPositions(positions); + }); + loadAttribute("NORMAL", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind, function (babylonVertexBuffer, data) { + var normals = new Float32Array(data.length); + babylonVertexBuffer.forEach(normals.length, function (value, index) { + normals[index] = data[index] + value; + }); + babylonMorphTarget.setNormals(normals); + }); + loadAttribute("TANGENT", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind, function (babylonVertexBuffer, data) { + var tangents = new Float32Array((data.length / 3) * 4); + var dataIndex = 0; + babylonVertexBuffer.forEach((data.length / 3) * 4, function (value, index) { + // Tangent data for morph targets is stored as xyz delta. + // The vertexData.tangent is stored as xyzw. + // So we need to skip every fourth vertexData.tangent. + if ((index + 1) % 4 !== 0) { + tangents[dataIndex] = data[dataIndex] + value; + dataIndex++; + } + }); + babylonMorphTarget.setTangents(tangents); + }); + return Promise.all(promises).then(function () { }); + }; + GLTFLoader._LoadTransform = function (node, babylonNode) { + // Ignore the TRS of skinned nodes. + // See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note) + if (node.skin != undefined) { + return; + } + var position = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(); + var rotation = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Identity(); + var scaling = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.One(); + if (node.matrix) { + var matrix = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromArray(node.matrix); + matrix.decompose(scaling, rotation, position); + } + else { + if (node.translation) { + position = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.translation); + } + if (node.rotation) { + rotation = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(node.rotation); + } + if (node.scale) { + scaling = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.scale); + } + } + babylonNode.position = position; + babylonNode.rotationQuaternion = rotation; + babylonNode.scaling = scaling; + }; + GLTFLoader.prototype._loadSkinAsync = function (context, node, skin, assign) { + var _this = this; + var extensionPromise = this._extensionsLoadSkinAsync(context, node, skin); + if (extensionPromise) { + return extensionPromise; + } + if (skin._data) { + assign(skin._data.babylonSkeleton); + return skin._data.promise; + } + var skeletonId = "skeleton".concat(skin.index); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonSkeleton = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Skeleton(skin.name || skeletonId, skeletonId, this._babylonScene); + babylonSkeleton._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + this._loadBones(context, skin, babylonSkeleton); + var promise = this._loadSkinInverseBindMatricesDataAsync(context, skin).then(function (inverseBindMatricesData) { + _this._updateBoneMatrices(babylonSkeleton, inverseBindMatricesData); + }); + skin._data = { + babylonSkeleton: babylonSkeleton, + promise: promise, + }; + assign(babylonSkeleton); + return promise; + }; + GLTFLoader.prototype._loadBones = function (context, skin, babylonSkeleton) { + if (skin.skeleton == undefined || this._parent.alwaysComputeSkeletonRootNode) { + var rootNode = this._findSkeletonRootNode("".concat(context, "/joints"), skin.joints); + if (rootNode) { + if (skin.skeleton === undefined) { + skin.skeleton = rootNode.index; + } + else { + var isParent = function (a, b) { + for (; b.parent; b = b.parent) { + if (b.parent === a) { + return true; + } + } + return false; + }; + var skeletonNode = ArrayItem.Get("".concat(context, "/skeleton"), this._gltf.nodes, skin.skeleton); + if (skeletonNode !== rootNode && !isParent(skeletonNode, rootNode)) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root")); + skin.skeleton = rootNode.index; + } + } + } + else { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Failed to find common root")); + } + } + var babylonBones = {}; + for (var _i = 0, _a = skin.joints; _i < _a.length; _i++) { + var index = _a[_i]; + var node = ArrayItem.Get("".concat(context, "/joints/").concat(index), this._gltf.nodes, index); + this._loadBone(node, skin, babylonSkeleton, babylonBones); + } + }; + GLTFLoader.prototype._findSkeletonRootNode = function (context, joints) { + if (joints.length === 0) { + return null; + } + var paths = {}; + for (var _i = 0, joints_1 = joints; _i < joints_1.length; _i++) { + var index = joints_1[_i]; + var path = new Array(); + var node = ArrayItem.Get("".concat(context, "/").concat(index), this._gltf.nodes, index); + while (node.index !== -1) { + path.unshift(node); + node = node.parent; + } + paths[index] = path; + } + var rootNode = null; + for (var i = 0;; ++i) { + var path = paths[joints[0]]; + if (i >= path.length) { + return rootNode; + } + var node = path[i]; + for (var j = 1; j < joints.length; ++j) { + path = paths[joints[j]]; + if (i >= path.length || node !== path[i]) { + return rootNode; + } + } + rootNode = node; + } + }; + GLTFLoader.prototype._loadBone = function (node, skin, babylonSkeleton, babylonBones) { + var babylonBone = babylonBones[node.index]; + if (babylonBone) { + return babylonBone; + } + var parentBabylonBone = null; + if (node.index !== skin.skeleton) { + if (node.parent && node.parent.index !== -1) { + parentBabylonBone = this._loadBone(node.parent, skin, babylonSkeleton, babylonBones); + } + else if (skin.skeleton !== undefined) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("/skins/".concat(skin.index, "/skeleton: Skeleton node is not a common root")); + } + } + var boneIndex = skin.joints.indexOf(node.index); + babylonBone = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Bone(node.name || "joint".concat(node.index), babylonSkeleton, parentBabylonBone, this._getNodeMatrix(node), null, null, boneIndex); + babylonBones[node.index] = babylonBone; + // Wait until the scene is loaded to ensure the transform nodes are loaded. + this._postSceneLoadActions.push(function () { + // Link the Babylon bone with the corresponding Babylon transform node. + // A glTF joint is a pointer to a glTF node in the glTF node hierarchy similar to Unity3D. + babylonBone.linkTransformNode(node._babylonTransformNode); + }); + return babylonBone; + }; + GLTFLoader.prototype._loadSkinInverseBindMatricesDataAsync = function (context, skin) { + if (skin.inverseBindMatrices == undefined) { + return Promise.resolve(null); + } + var accessor = ArrayItem.Get("".concat(context, "/inverseBindMatrices"), this._gltf.accessors, skin.inverseBindMatrices); + return this._loadFloatAccessorAsync("/accessors/".concat(accessor.index), accessor); + }; + GLTFLoader.prototype._updateBoneMatrices = function (babylonSkeleton, inverseBindMatricesData) { + for (var _i = 0, _a = babylonSkeleton.bones; _i < _a.length; _i++) { + var babylonBone = _a[_i]; + var baseMatrix = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.Identity(); + var boneIndex = babylonBone._index; + if (inverseBindMatricesData && boneIndex !== -1) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromArrayToRef(inverseBindMatricesData, boneIndex * 16, baseMatrix); + baseMatrix.invertToRef(baseMatrix); + } + var babylonParentBone = babylonBone.getParent(); + if (babylonParentBone) { + baseMatrix.multiplyToRef(babylonParentBone.getAbsoluteInverseBindMatrix(), baseMatrix); + } + babylonBone.updateMatrix(baseMatrix, false, false); + babylonBone._updateAbsoluteBindMatrices(undefined, false); + } + }; + GLTFLoader.prototype._getNodeMatrix = function (node) { + return node.matrix + ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromArray(node.matrix) + : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.Compose(node.scale ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.scale) : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.One(), node.rotation ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(node.rotation) : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Identity(), node.translation ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.translation) : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero()); + }; + /** + * Loads a glTF camera. + * @param context The context when loading the asset + * @param camera The glTF camera property + * @param assign A function called synchronously after parsing the glTF properties + * @returns A promise that resolves with the loaded Babylon camera when the load is complete + */ + GLTFLoader.prototype.loadCameraAsync = function (context, camera, assign) { + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadCameraAsync(context, camera, assign); + if (extensionPromise) { + return extensionPromise; + } + var promises = new Array(); + this.logOpen("".concat(context, " ").concat(camera.name || "")); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonCamera = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.FreeCamera(camera.name || "camera".concat(camera.index), babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(), this._babylonScene, false); + babylonCamera._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + babylonCamera.ignoreParentScaling = true; + camera._babylonCamera = babylonCamera; + babylonCamera.rotation = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3(0, Math.PI, 0); + switch (camera.type) { + case "perspective" /* CameraType.PERSPECTIVE */: { + var perspective = camera.perspective; + if (!perspective) { + throw new Error("".concat(context, ": Camera perspective properties are missing")); + } + babylonCamera.fov = perspective.yfov; + babylonCamera.minZ = perspective.znear; + babylonCamera.maxZ = perspective.zfar || 0; + break; + } + case "orthographic" /* CameraType.ORTHOGRAPHIC */: { + if (!camera.orthographic) { + throw new Error("".concat(context, ": Camera orthographic properties are missing")); + } + babylonCamera.mode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Camera.ORTHOGRAPHIC_CAMERA; + babylonCamera.orthoLeft = -camera.orthographic.xmag; + babylonCamera.orthoRight = camera.orthographic.xmag; + babylonCamera.orthoBottom = -camera.orthographic.ymag; + babylonCamera.orthoTop = camera.orthographic.ymag; + babylonCamera.minZ = camera.orthographic.znear; + babylonCamera.maxZ = camera.orthographic.zfar; + break; + } + default: { + throw new Error("".concat(context, ": Invalid camera type (").concat(camera.type, ")")); + } + } + GLTFLoader.AddPointerMetadata(babylonCamera, context); + this._parent.onCameraLoadedObservable.notifyObservers(babylonCamera); + assign(babylonCamera); + this.logClose(); + return Promise.all(promises).then(function () { + return babylonCamera; + }); + }; + GLTFLoader.prototype._loadAnimationsAsync = function () { + var animations = this._gltf.animations; + if (!animations) { + return Promise.resolve(); + } + var promises = new Array(); + for (var index = 0; index < animations.length; index++) { + var animation = animations[index]; + promises.push(this.loadAnimationAsync("/animations/".concat(animation.index), animation).then(function (animationGroup) { + // Delete the animation group if it ended up not having any animations in it. + if (animationGroup.targetedAnimations.length === 0) { + animationGroup.dispose(); + } + })); + } + return Promise.all(promises).then(function () { }); + }; + /** + * Loads a glTF animation. + * @param context The context when loading the asset + * @param animation The glTF animation property + * @returns A promise that resolves with the loaded Babylon animation group when the load is complete + */ + GLTFLoader.prototype.loadAnimationAsync = function (context, animation) { + var promise = this._extensionsLoadAnimationAsync(context, animation); + if (promise) { + return promise; + } + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonAnimationGroup = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.AnimationGroup(animation.name || "animation".concat(animation.index), this._babylonScene); + babylonAnimationGroup._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + animation._babylonAnimationGroup = babylonAnimationGroup; + var promises = new Array(); + ArrayItem.Assign(animation.channels); + ArrayItem.Assign(animation.samplers); + for (var _i = 0, _a = animation.channels; _i < _a.length; _i++) { + var channel = _a[_i]; + promises.push(this._loadAnimationChannelAsync("".concat(context, "/channels/").concat(channel.index), context, animation, channel, function (babylonTarget, babylonAnimation) { + babylonTarget.animations = babylonTarget.animations || []; + babylonTarget.animations.push(babylonAnimation); + babylonAnimationGroup.addTargetedAnimation(babylonAnimation, babylonTarget); + })); + } + return Promise.all(promises).then(function () { + babylonAnimationGroup.normalize(0); + return babylonAnimationGroup; + }); + }; + /** + * @hidden + * Loads a glTF animation channel. + * @param context The context when loading the asset + * @param animationContext The context of the animation when loading the asset + * @param animation The glTF animation property + * @param channel The glTF animation channel property + * @param onLoad Called for each animation loaded + * @returns A void promise that resolves when the load is complete + */ + GLTFLoader.prototype._loadAnimationChannelAsync = function (context, animationContext, animation, channel, onLoad) { + var promise = this._extensionsLoadAnimationChannelAsync(context, animationContext, animation, channel, onLoad); + if (promise) { + return promise; + } + if (channel.target.node == undefined) { + return Promise.resolve(); + } + var targetNode = ArrayItem.Get("".concat(context, "/target/node"), this._gltf.nodes, channel.target.node); + // Ignore animations that have no animation targets. + if ((channel.target.path === "weights" /* AnimationChannelTargetPath.WEIGHTS */ && !targetNode._numMorphTargets) || + (channel.target.path !== "weights" /* AnimationChannelTargetPath.WEIGHTS */ && !targetNode._babylonTransformNode)) { + return Promise.resolve(); + } + var properties; + switch (channel.target.path) { + case "translation" /* AnimationChannelTargetPath.TRANSLATION */: { + properties = _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__.nodeAnimationData.translation; + break; + } + case "rotation" /* AnimationChannelTargetPath.ROTATION */: { + properties = _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__.nodeAnimationData.rotation; + break; + } + case "scale" /* AnimationChannelTargetPath.SCALE */: { + properties = _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__.nodeAnimationData.scale; + break; + } + case "weights" /* AnimationChannelTargetPath.WEIGHTS */: { + properties = _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__.nodeAnimationData.weights; + break; + } + default: { + throw new Error("".concat(context, "/target/path: Invalid value (").concat(channel.target.path, ")")); + } + } + var targetInfo = { + target: targetNode, + properties: properties, + }; + return this._loadAnimationChannelFromTargetInfoAsync(context, animationContext, animation, channel, targetInfo, onLoad); + }; + /** + * @hidden + * Loads a glTF animation channel. + * @param context The context when loading the asset + * @param animationContext The context of the animation when loading the asset + * @param animation The glTF animation property + * @param channel The glTF animation channel property + * @param targetInfo The glTF target and properties + * @param onLoad Called for each animation loaded + * @returns A void promise that resolves when the load is complete + */ + GLTFLoader.prototype._loadAnimationChannelFromTargetInfoAsync = function (context, animationContext, animation, channel, targetInfo, onLoad) { + var fps = this.parent.targetFps; + var invfps = 1 / fps; + var sampler = ArrayItem.Get("".concat(context, "/sampler"), animation.samplers, channel.sampler); + return this._loadAnimationSamplerAsync("".concat(animationContext, "/samplers/").concat(channel.sampler), sampler).then(function (data) { + var numAnimations = 0; + // Extract the corresponding values from the read value. + // GLTF values may be dispatched to several Babylon properties. + // For example, baseColorFactor [`r`, `g`, `b`, `a`] is dispatched to + // - albedoColor as Color3(`r`, `g`, `b`) + // - alpha as `a` + for (var _i = 0, _a = targetInfo.properties; _i < _a.length; _i++) { + var property = _a[_i]; + var stride = property.getStride(targetInfo.target); + var input = data.input; + var output = data.output; + var keys = new Array(input.length); + var outputOffset = 0; + switch (data.interpolation) { + case "STEP" /* AnimationSamplerInterpolation.STEP */: { + for (var index = 0; index < input.length; index++) { + var value = property.getValue(targetInfo.target, output, outputOffset, 1); + outputOffset += stride; + keys[index] = { + frame: input[index] * fps, + value: value, + interpolation: babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.AnimationKeyInterpolation.STEP, + }; + } + break; + } + case "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */: { + for (var index = 0; index < input.length; index++) { + var inTangent = property.getValue(targetInfo.target, output, outputOffset, invfps); + outputOffset += stride; + var value = property.getValue(targetInfo.target, output, outputOffset, 1); + outputOffset += stride; + var outTangent = property.getValue(targetInfo.target, output, outputOffset, invfps); + outputOffset += stride; + keys[index] = { + frame: input[index] * fps, + inTangent: inTangent, + value: value, + outTangent: outTangent, + }; + } + break; + } + case "LINEAR" /* AnimationSamplerInterpolation.LINEAR */: { + for (var index = 0; index < input.length; index++) { + var value = property.getValue(targetInfo.target, output, outputOffset, 1); + outputOffset += stride; + keys[index] = { + frame: input[index] * fps, + value: value, + }; + } + break; + } + } + if (outputOffset > 0) { + var name_4 = "".concat(animation.name || "animation".concat(animation.index), "_channel").concat(channel.index, "_").concat(numAnimations); + property.buildAnimations(targetInfo.target, name_4, fps, keys, function (babylonAnimatable, babylonAnimation) { + ++numAnimations; + onLoad(babylonAnimatable, babylonAnimation); + }); + } + } + }); + }; + GLTFLoader.prototype._loadAnimationSamplerAsync = function (context, sampler) { + if (sampler._data) { + return sampler._data; + } + var interpolation = sampler.interpolation || "LINEAR" /* AnimationSamplerInterpolation.LINEAR */; + switch (interpolation) { + case "STEP" /* AnimationSamplerInterpolation.STEP */: + case "LINEAR" /* AnimationSamplerInterpolation.LINEAR */: + case "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */: { + break; + } + default: { + throw new Error("".concat(context, "/interpolation: Invalid value (").concat(sampler.interpolation, ")")); + } + } + var inputAccessor = ArrayItem.Get("".concat(context, "/input"), this._gltf.accessors, sampler.input); + var outputAccessor = ArrayItem.Get("".concat(context, "/output"), this._gltf.accessors, sampler.output); + sampler._data = Promise.all([ + this._loadFloatAccessorAsync("/accessors/".concat(inputAccessor.index), inputAccessor), + this._loadFloatAccessorAsync("/accessors/".concat(outputAccessor.index), outputAccessor), + ]).then(function (_a) { + var inputData = _a[0], outputData = _a[1]; + return { + input: inputData, + interpolation: interpolation, + output: outputData, + }; + }); + return sampler._data; + }; + /** + * Loads a glTF buffer. + * @param context The context when loading the asset + * @param buffer The glTF buffer property + * @param byteOffset The byte offset to use + * @param byteLength The byte length to use + * @returns A promise that resolves with the loaded data when the load is complete + */ + GLTFLoader.prototype.loadBufferAsync = function (context, buffer, byteOffset, byteLength) { + var extensionPromise = this._extensionsLoadBufferAsync(context, buffer, byteOffset, byteLength); + if (extensionPromise) { + return extensionPromise; + } + if (!buffer._data) { + if (buffer.uri) { + buffer._data = this.loadUriAsync("".concat(context, "/uri"), buffer, buffer.uri); + } + else { + if (!this._bin) { + throw new Error("".concat(context, ": Uri is missing or the binary glTF is missing its binary chunk")); + } + buffer._data = this._bin.readAsync(0, buffer.byteLength); + } + } + return buffer._data.then(function (data) { + try { + return new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength); + } + catch (e) { + throw new Error("".concat(context, ": ").concat(e.message)); + } + }); + }; + /** + * Loads a glTF buffer view. + * @param context The context when loading the asset + * @param bufferView The glTF buffer view property + * @returns A promise that resolves with the loaded data when the load is complete + */ + GLTFLoader.prototype.loadBufferViewAsync = function (context, bufferView) { + var extensionPromise = this._extensionsLoadBufferViewAsync(context, bufferView); + if (extensionPromise) { + return extensionPromise; + } + if (bufferView._data) { + return bufferView._data; + } + var buffer = ArrayItem.Get("".concat(context, "/buffer"), this._gltf.buffers, bufferView.buffer); + bufferView._data = this.loadBufferAsync("/buffers/".concat(buffer.index), buffer, bufferView.byteOffset || 0, bufferView.byteLength); + return bufferView._data; + }; + GLTFLoader.prototype._loadAccessorAsync = function (context, accessor, constructor) { + var _this = this; + if (accessor._data) { + return accessor._data; + } + var numComponents = GLTFLoader._GetNumComponents(context, accessor.type); + var byteStride = numComponents * babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(accessor.componentType); + var length = numComponents * accessor.count; + if (accessor.bufferView == undefined) { + accessor._data = Promise.resolve(new constructor(length)); + } + else { + var bufferView_1 = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView); + accessor._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView_1.index), bufferView_1).then(function (data) { + if (accessor.componentType === 5126 /* AccessorComponentType.FLOAT */ && !accessor.normalized && (!bufferView_1.byteStride || bufferView_1.byteStride === byteStride)) { + return GLTFLoader._GetTypedArray(context, accessor.componentType, data, accessor.byteOffset, length); + } + else { + var typedArray_1 = new constructor(length); + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ForEach(data, accessor.byteOffset || 0, bufferView_1.byteStride || byteStride, numComponents, accessor.componentType, typedArray_1.length, accessor.normalized || false, function (value, index) { + typedArray_1[index] = value; + }); + return typedArray_1; + } + }); + } + if (accessor.sparse) { + var sparse_1 = accessor.sparse; + accessor._data = accessor._data.then(function (data) { + var typedArray = data; + var indicesBufferView = ArrayItem.Get("".concat(context, "/sparse/indices/bufferView"), _this._gltf.bufferViews, sparse_1.indices.bufferView); + var valuesBufferView = ArrayItem.Get("".concat(context, "/sparse/values/bufferView"), _this._gltf.bufferViews, sparse_1.values.bufferView); + return Promise.all([ + _this.loadBufferViewAsync("/bufferViews/".concat(indicesBufferView.index), indicesBufferView), + _this.loadBufferViewAsync("/bufferViews/".concat(valuesBufferView.index), valuesBufferView), + ]).then(function (_a) { + var indicesData = _a[0], valuesData = _a[1]; + var indices = GLTFLoader._GetTypedArray("".concat(context, "/sparse/indices"), sparse_1.indices.componentType, indicesData, sparse_1.indices.byteOffset, sparse_1.count); + var sparseLength = numComponents * sparse_1.count; + var values; + if (accessor.componentType === 5126 /* AccessorComponentType.FLOAT */ && !accessor.normalized) { + values = GLTFLoader._GetTypedArray("".concat(context, "/sparse/values"), accessor.componentType, valuesData, sparse_1.values.byteOffset, sparseLength); + } + else { + var sparseData = GLTFLoader._GetTypedArray("".concat(context, "/sparse/values"), accessor.componentType, valuesData, sparse_1.values.byteOffset, sparseLength); + values = new constructor(sparseLength); + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ForEach(sparseData, 0, byteStride, numComponents, accessor.componentType, values.length, accessor.normalized || false, function (value, index) { + values[index] = value; + }); + } + var valuesIndex = 0; + for (var indicesIndex = 0; indicesIndex < indices.length; indicesIndex++) { + var dataIndex = indices[indicesIndex] * numComponents; + for (var componentIndex = 0; componentIndex < numComponents; componentIndex++) { + typedArray[dataIndex++] = values[valuesIndex++]; + } + } + return typedArray; + }); + }); + } + return accessor._data; + }; + /** + * @internal + */ + GLTFLoader.prototype._loadFloatAccessorAsync = function (context, accessor) { + return this._loadAccessorAsync(context, accessor, Float32Array); + }; + /** + * @internal + */ + GLTFLoader.prototype._loadIndicesAccessorAsync = function (context, accessor) { + if (accessor.type !== "SCALAR" /* AccessorType.SCALAR */) { + throw new Error("".concat(context, "/type: Invalid value ").concat(accessor.type)); + } + if (accessor.componentType !== 5121 /* AccessorComponentType.UNSIGNED_BYTE */ && + accessor.componentType !== 5123 /* AccessorComponentType.UNSIGNED_SHORT */ && + accessor.componentType !== 5125 /* AccessorComponentType.UNSIGNED_INT */) { + throw new Error("".concat(context, "/componentType: Invalid value ").concat(accessor.componentType)); + } + if (accessor._data) { + return accessor._data; + } + if (accessor.sparse) { + var constructor = GLTFLoader._GetTypedArrayConstructor("".concat(context, "/componentType"), accessor.componentType); + accessor._data = this._loadAccessorAsync(context, accessor, constructor); + } + else { + var bufferView = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView); + accessor._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) { + return GLTFLoader._GetTypedArray(context, accessor.componentType, data, accessor.byteOffset, accessor.count); + }); + } + return accessor._data; + }; + /** + * @internal + */ + GLTFLoader.prototype._loadVertexBufferViewAsync = function (bufferView) { + if (bufferView._babylonBuffer) { + return bufferView._babylonBuffer; + } + var engine = this._babylonScene.getEngine(); + bufferView._babylonBuffer = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) { + return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Buffer(engine, data, false); + }); + return bufferView._babylonBuffer; + }; + /** + * @internal + */ + GLTFLoader.prototype._loadVertexAccessorAsync = function (context, accessor, kind) { + var _a; + if ((_a = accessor._babylonVertexBuffer) === null || _a === void 0 ? void 0 : _a[kind]) { + return accessor._babylonVertexBuffer[kind]; + } + if (!accessor._babylonVertexBuffer) { + accessor._babylonVertexBuffer = {}; + } + var engine = this._babylonScene.getEngine(); + if (accessor.sparse) { + accessor._babylonVertexBuffer[kind] = this._loadFloatAccessorAsync(context, accessor).then(function (data) { + return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer(engine, data, kind, false); + }); + } + // Load joint indices as a float array since the shaders expect float data but glTF uses unsigned byte/short. + // This prevents certain platforms (e.g. D3D) from having to convert the data to float on the fly. + else if (kind === babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind || kind === babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind) { + accessor._babylonVertexBuffer[kind] = this._loadFloatAccessorAsync(context, accessor).then(function (data) { + return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer(engine, data, kind, false); + }); + } + else { + var bufferView_2 = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView); + accessor._babylonVertexBuffer[kind] = this._loadVertexBufferViewAsync(bufferView_2).then(function (babylonBuffer) { + var size = GLTFLoader._GetNumComponents(context, accessor.type); + return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer(engine, babylonBuffer, kind, false, false, bufferView_2.byteStride, false, accessor.byteOffset, size, accessor.componentType, accessor.normalized, true, 1, true); + }); + } + return accessor._babylonVertexBuffer[kind]; + }; + GLTFLoader.prototype._loadMaterialMetallicRoughnessPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + if (properties) { + if (properties.baseColorFactor) { + babylonMaterial.albedoColor = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.baseColorFactor); + babylonMaterial.alpha = properties.baseColorFactor[3]; + } + else { + babylonMaterial.albedoColor = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + } + babylonMaterial.metallic = properties.metallicFactor == undefined ? 1 : properties.metallicFactor; + babylonMaterial.roughness = properties.roughnessFactor == undefined ? 1 : properties.roughnessFactor; + if (properties.baseColorTexture) { + promises.push(this.loadTextureInfoAsync("".concat(context, "/baseColorTexture"), properties.baseColorTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Base Color)"); + babylonMaterial.albedoTexture = texture; + })); + } + if (properties.metallicRoughnessTexture) { + properties.metallicRoughnessTexture.nonColorData = true; + promises.push(this.loadTextureInfoAsync("".concat(context, "/metallicRoughnessTexture"), properties.metallicRoughnessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Metallic Roughness)"); + babylonMaterial.metallicTexture = texture; + })); + babylonMaterial.useMetallnessFromMetallicTextureBlue = true; + babylonMaterial.useRoughnessFromMetallicTextureGreen = true; + babylonMaterial.useRoughnessFromMetallicTextureAlpha = false; + } + } + return Promise.all(promises).then(function () { }); + }; + /** + * @internal + */ + GLTFLoader.prototype._loadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) { + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign); + if (extensionPromise) { + return extensionPromise; + } + material._data = material._data || {}; + var babylonData = material._data[babylonDrawMode]; + if (!babylonData) { + this.logOpen("".concat(context, " ").concat(material.name || "")); + var babylonMaterial = this.createMaterial(context, material, babylonDrawMode); + babylonData = { + babylonMaterial: babylonMaterial, + babylonMeshes: [], + promise: this.loadMaterialPropertiesAsync(context, material, babylonMaterial), + }; + material._data[babylonDrawMode] = babylonData; + GLTFLoader.AddPointerMetadata(babylonMaterial, context); + this._parent.onMaterialLoadedObservable.notifyObservers(babylonMaterial); + this.logClose(); + } + if (babylonMesh) { + babylonData.babylonMeshes.push(babylonMesh); + babylonMesh.onDisposeObservable.addOnce(function () { + var index = babylonData.babylonMeshes.indexOf(babylonMesh); + if (index !== -1) { + babylonData.babylonMeshes.splice(index, 1); + } + }); + } + assign(babylonData.babylonMaterial); + return babylonData.promise.then(function () { + return babylonData.babylonMaterial; + }); + }; + GLTFLoader.prototype._createDefaultMaterial = function (name, babylonDrawMode) { + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonMaterial = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial(name, this._babylonScene); + babylonMaterial._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + // Moved to mesh so user can change materials on gltf meshes: babylonMaterial.sideOrientation = this._babylonScene.useRightHandedSystem ? Material.CounterClockWiseSideOrientation : Material.ClockWiseSideOrientation; + babylonMaterial.fillMode = babylonDrawMode; + babylonMaterial.enableSpecularAntiAliasing = true; + babylonMaterial.useRadianceOverAlpha = !this._parent.transparencyAsCoverage; + babylonMaterial.useSpecularOverAlpha = !this._parent.transparencyAsCoverage; + babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_OPAQUE; + babylonMaterial.metallic = 1; + babylonMaterial.roughness = 1; + return babylonMaterial; + }; + /** + * Creates a Babylon material from a glTF material. + * @param context The context when loading the asset + * @param material The glTF material property + * @param babylonDrawMode The draw mode for the Babylon material + * @returns The Babylon material + */ + GLTFLoader.prototype.createMaterial = function (context, material, babylonDrawMode) { + var extensionPromise = this._extensionsCreateMaterial(context, material, babylonDrawMode); + if (extensionPromise) { + return extensionPromise; + } + var name = material.name || "material".concat(material.index); + var babylonMaterial = this._createDefaultMaterial(name, babylonDrawMode); + return babylonMaterial; + }; + /** + * Loads properties from a glTF material into a Babylon material. + * @param context The context when loading the asset + * @param material The glTF material property + * @param babylonMaterial The Babylon material + * @returns A promise that resolves when the load is complete + */ + GLTFLoader.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var extensionPromise = this._extensionsLoadMaterialPropertiesAsync(context, material, babylonMaterial); + if (extensionPromise) { + return extensionPromise; + } + var promises = new Array(); + promises.push(this.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + if (material.pbrMetallicRoughness) { + promises.push(this._loadMaterialMetallicRoughnessPropertiesAsync("".concat(context, "/pbrMetallicRoughness"), material.pbrMetallicRoughness, babylonMaterial)); + } + this.loadMaterialAlphaProperties(context, material, babylonMaterial); + return Promise.all(promises).then(function () { }); + }; + /** + * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material. + * @param context The context when loading the asset + * @param material The glTF material property + * @param babylonMaterial The Babylon material + * @returns A promise that resolves when the load is complete + */ + GLTFLoader.prototype.loadMaterialBasePropertiesAsync = function (context, material, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.emissiveColor = material.emissiveFactor ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(material.emissiveFactor) : new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3(0, 0, 0); + if (material.doubleSided) { + babylonMaterial.backFaceCulling = false; + babylonMaterial.twoSidedLighting = true; + } + if (material.normalTexture) { + material.normalTexture.nonColorData = true; + promises.push(this.loadTextureInfoAsync("".concat(context, "/normalTexture"), material.normalTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Normal)"); + babylonMaterial.bumpTexture = texture; + })); + babylonMaterial.invertNormalMapX = !this._babylonScene.useRightHandedSystem; + babylonMaterial.invertNormalMapY = this._babylonScene.useRightHandedSystem; + if (material.normalTexture.scale != undefined && babylonMaterial.bumpTexture) { + babylonMaterial.bumpTexture.level = material.normalTexture.scale; + } + babylonMaterial.forceIrradianceInFragment = true; + } + if (material.occlusionTexture) { + material.occlusionTexture.nonColorData = true; + promises.push(this.loadTextureInfoAsync("".concat(context, "/occlusionTexture"), material.occlusionTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Occlusion)"); + babylonMaterial.ambientTexture = texture; + })); + babylonMaterial.useAmbientInGrayScale = true; + if (material.occlusionTexture.strength != undefined) { + babylonMaterial.ambientTextureStrength = material.occlusionTexture.strength; + } + } + if (material.emissiveTexture) { + promises.push(this.loadTextureInfoAsync("".concat(context, "/emissiveTexture"), material.emissiveTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Emissive)"); + babylonMaterial.emissiveTexture = texture; + })); + } + return Promise.all(promises).then(function () { }); + }; + /** + * Loads the alpha properties from a glTF material into a Babylon material. + * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture. + * @param context The context when loading the asset + * @param material The glTF material property + * @param babylonMaterial The Babylon material + */ + GLTFLoader.prototype.loadMaterialAlphaProperties = function (context, material, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var alphaMode = material.alphaMode || "OPAQUE" /* MaterialAlphaMode.OPAQUE */; + switch (alphaMode) { + case "OPAQUE" /* MaterialAlphaMode.OPAQUE */: { + babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_OPAQUE; + break; + } + case "MASK" /* MaterialAlphaMode.MASK */: { + babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_ALPHATEST; + babylonMaterial.alphaCutOff = material.alphaCutoff == undefined ? 0.5 : material.alphaCutoff; + if (babylonMaterial.albedoTexture) { + babylonMaterial.albedoTexture.hasAlpha = true; + } + break; + } + case "BLEND" /* MaterialAlphaMode.BLEND */: { + babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_ALPHABLEND; + if (babylonMaterial.albedoTexture) { + babylonMaterial.albedoTexture.hasAlpha = true; + babylonMaterial.useAlphaFromAlbedoTexture = true; + } + break; + } + default: { + throw new Error("".concat(context, "/alphaMode: Invalid value (").concat(material.alphaMode, ")")); + } + } + }; + /** + * Loads a glTF texture info. + * @param context The context when loading the asset + * @param textureInfo The glTF texture info property + * @param assign A function called synchronously after parsing the glTF properties + * @returns A promise that resolves with the loaded Babylon texture when the load is complete + */ + GLTFLoader.prototype.loadTextureInfoAsync = function (context, textureInfo, assign) { + var _this = this; + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadTextureInfoAsync(context, textureInfo, assign); + if (extensionPromise) { + return extensionPromise; + } + this.logOpen("".concat(context)); + if (textureInfo.texCoord >= 6) { + throw new Error("".concat(context, "/texCoord: Invalid value (").concat(textureInfo.texCoord, ")")); + } + var texture = ArrayItem.Get("".concat(context, "/index"), this._gltf.textures, textureInfo.index); + texture._textureInfo = textureInfo; + var promise = this._loadTextureAsync("/textures/".concat(textureInfo.index), texture, function (babylonTexture) { + babylonTexture.coordinatesIndex = textureInfo.texCoord || 0; + GLTFLoader.AddPointerMetadata(babylonTexture, context); + _this._parent.onTextureLoadedObservable.notifyObservers(babylonTexture); + assign(babylonTexture); + }); + this.logClose(); + return promise; + }; + /** + * @internal + */ + GLTFLoader.prototype._loadTextureAsync = function (context, texture, assign) { + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadTextureAsync(context, texture, assign); + if (extensionPromise) { + return extensionPromise; + } + this.logOpen("".concat(context, " ").concat(texture.name || "")); + var sampler = texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get("".concat(context, "/sampler"), this._gltf.samplers, texture.sampler); + var image = ArrayItem.Get("".concat(context, "/source"), this._gltf.images, texture.source); + var promise = this._createTextureAsync(context, sampler, image, assign, undefined, !texture._textureInfo.nonColorData); + this.logClose(); + return promise; + }; + /** + * @internal + */ + GLTFLoader.prototype._createTextureAsync = function (context, sampler, image, assign, textureLoaderOptions, useSRGBBuffer) { + var _this = this; + if (assign === void 0) { assign = function () { }; } + var samplerData = this._loadSampler("/samplers/".concat(sampler.index), sampler); + var promises = new Array(); + var deferred = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Deferred(); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var textureCreationOptions = { + noMipmap: samplerData.noMipMaps, + invertY: false, + samplingMode: samplerData.samplingMode, + onLoad: function () { + if (!_this._disposed) { + deferred.resolve(); + } + }, + onError: function (message, exception) { + if (!_this._disposed) { + deferred.reject(new Error("".concat(context, ": ").concat(exception && exception.message ? exception.message : message || "Failed to load texture"))); + } + }, + mimeType: image.mimeType, + loaderOptions: textureLoaderOptions, + useSRGBBuffer: !!useSRGBBuffer && this._parent.useSRGBBuffers, + }; + var babylonTexture = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture(null, this._babylonScene, textureCreationOptions); + babylonTexture._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + promises.push(deferred.promise); + promises.push(this.loadImageAsync("/images/".concat(image.index), image).then(function (data) { + var name = image.uri || "".concat(_this._fileName, "#image").concat(image.index); + var dataUrl = "data:".concat(_this._uniqueRootUrl).concat(name); + babylonTexture.updateURL(dataUrl, data); + })); + babylonTexture.wrapU = samplerData.wrapU; + babylonTexture.wrapV = samplerData.wrapV; + assign(babylonTexture); + return Promise.all(promises).then(function () { + return babylonTexture; + }); + }; + GLTFLoader.prototype._loadSampler = function (context, sampler) { + if (!sampler._data) { + sampler._data = { + noMipMaps: sampler.minFilter === 9728 /* TextureMinFilter.NEAREST */ || sampler.minFilter === 9729 /* TextureMinFilter.LINEAR */, + samplingMode: GLTFLoader._GetTextureSamplingMode(context, sampler), + wrapU: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapS"), sampler.wrapS), + wrapV: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapT"), sampler.wrapT), + }; + } + return sampler._data; + }; + /** + * Loads a glTF image. + * @param context The context when loading the asset + * @param image The glTF image property + * @returns A promise that resolves with the loaded data when the load is complete + */ + GLTFLoader.prototype.loadImageAsync = function (context, image) { + if (!image._data) { + this.logOpen("".concat(context, " ").concat(image.name || "")); + if (image.uri) { + image._data = this.loadUriAsync("".concat(context, "/uri"), image, image.uri); + } + else { + var bufferView = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, image.bufferView); + image._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView); + } + this.logClose(); + } + return image._data; + }; + /** + * Loads a glTF uri. + * @param context The context when loading the asset + * @param property The glTF property associated with the uri + * @param uri The base64 or relative uri + * @returns A promise that resolves with the loaded data when the load is complete + */ + GLTFLoader.prototype.loadUriAsync = function (context, property, uri) { + var _this = this; + var extensionPromise = this._extensionsLoadUriAsync(context, property, uri); + if (extensionPromise) { + return extensionPromise; + } + if (!GLTFLoader._ValidateUri(uri)) { + throw new Error("".concat(context, ": '").concat(uri, "' is invalid")); + } + if ((0,babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.IsBase64DataUrl)(uri)) { + var data = new Uint8Array((0,babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.DecodeBase64UrlToBinary)(uri)); + this.log("".concat(context, ": Decoded ").concat(uri.substr(0, 64), "... (").concat(data.length, " bytes)")); + return Promise.resolve(data); + } + this.log("".concat(context, ": Loading ").concat(uri)); + return this._parent.preprocessUrlAsync(this._rootUrl + uri).then(function (url) { + return new Promise(function (resolve, reject) { + _this._parent._loadFile(_this._babylonScene, url, function (data) { + if (!_this._disposed) { + _this.log("".concat(context, ": Loaded ").concat(uri, " (").concat(data.byteLength, " bytes)")); + resolve(new Uint8Array(data)); + } + }, true, function (request) { + reject(new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.LoadFileError("".concat(context, ": Failed to load '").concat(uri, "'").concat(request ? ": " + request.status + " " + request.statusText : ""), request)); + }); + }); + }); + }; + /** + * Adds a JSON pointer to the _internalMetadata of the Babylon object at `._internalMetadata.gltf.pointers`. + * @param babylonObject the Babylon object with _internalMetadata + * @param pointer the JSON pointer + */ + GLTFLoader.AddPointerMetadata = function (babylonObject, pointer) { + babylonObject.metadata = babylonObject.metadata || {}; + var metadata = (babylonObject._internalMetadata = babylonObject._internalMetadata || {}); + var gltf = (metadata.gltf = metadata.gltf || {}); + var pointers = (gltf.pointers = gltf.pointers || []); + pointers.push(pointer); + }; + GLTFLoader._GetTextureWrapMode = function (context, mode) { + // Set defaults if undefined + mode = mode == undefined ? 10497 /* TextureWrapMode.REPEAT */ : mode; + switch (mode) { + case 33071 /* TextureWrapMode.CLAMP_TO_EDGE */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.CLAMP_ADDRESSMODE; + case 33648 /* TextureWrapMode.MIRRORED_REPEAT */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.MIRROR_ADDRESSMODE; + case 10497 /* TextureWrapMode.REPEAT */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.WRAP_ADDRESSMODE; + default: + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Invalid value (").concat(mode, ")")); + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.WRAP_ADDRESSMODE; + } + }; + GLTFLoader._GetTextureSamplingMode = function (context, sampler) { + // Set defaults if undefined + var magFilter = sampler.magFilter == undefined ? 9729 /* TextureMagFilter.LINEAR */ : sampler.magFilter; + var minFilter = sampler.minFilter == undefined ? 9987 /* TextureMinFilter.LINEAR_MIPMAP_LINEAR */ : sampler.minFilter; + if (magFilter === 9729 /* TextureMagFilter.LINEAR */) { + switch (minFilter) { + case 9728 /* TextureMinFilter.NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST; + case 9729 /* TextureMinFilter.LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR; + case 9984 /* TextureMinFilter.NEAREST_MIPMAP_NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST_MIPNEAREST; + case 9985 /* TextureMinFilter.LINEAR_MIPMAP_NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPNEAREST; + case 9986 /* TextureMinFilter.NEAREST_MIPMAP_LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST_MIPLINEAR; + case 9987 /* TextureMinFilter.LINEAR_MIPMAP_LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPLINEAR; + default: + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/minFilter: Invalid value (").concat(minFilter, ")")); + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPLINEAR; + } + } + else { + if (magFilter !== 9728 /* TextureMagFilter.NEAREST */) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/magFilter: Invalid value (").concat(magFilter, ")")); + } + switch (minFilter) { + case 9728 /* TextureMinFilter.NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST; + case 9729 /* TextureMinFilter.LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR; + case 9984 /* TextureMinFilter.NEAREST_MIPMAP_NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPNEAREST; + case 9985 /* TextureMinFilter.LINEAR_MIPMAP_NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR_MIPNEAREST; + case 9986 /* TextureMinFilter.NEAREST_MIPMAP_LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPLINEAR; + case 9987 /* TextureMinFilter.LINEAR_MIPMAP_LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR_MIPLINEAR; + default: + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/minFilter: Invalid value (").concat(minFilter, ")")); + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPNEAREST; + } + } + }; + GLTFLoader._GetTypedArrayConstructor = function (context, componentType) { + switch (componentType) { + case 5120 /* AccessorComponentType.BYTE */: + return Int8Array; + case 5121 /* AccessorComponentType.UNSIGNED_BYTE */: + return Uint8Array; + case 5122 /* AccessorComponentType.SHORT */: + return Int16Array; + case 5123 /* AccessorComponentType.UNSIGNED_SHORT */: + return Uint16Array; + case 5125 /* AccessorComponentType.UNSIGNED_INT */: + return Uint32Array; + case 5126 /* AccessorComponentType.FLOAT */: + return Float32Array; + default: + throw new Error("".concat(context, ": Invalid component type ").concat(componentType)); + } + }; + GLTFLoader._GetTypedArray = function (context, componentType, bufferView, byteOffset, length) { + var buffer = bufferView.buffer; + byteOffset = bufferView.byteOffset + (byteOffset || 0); + var constructor = GLTFLoader._GetTypedArrayConstructor("".concat(context, "/componentType"), componentType); + var componentTypeLength = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(componentType); + if (byteOffset % componentTypeLength !== 0) { + // HACK: Copy the buffer if byte offset is not a multiple of component type byte length. + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Copying buffer as byte offset (").concat(byteOffset, ") is not a multiple of component type byte length (").concat(componentTypeLength, ")")); + return new constructor(buffer.slice(byteOffset, byteOffset + length * componentTypeLength), 0); + } + return new constructor(buffer, byteOffset, length); + }; + GLTFLoader._GetNumComponents = function (context, type) { + switch (type) { + case "SCALAR": + return 1; + case "VEC2": + return 2; + case "VEC3": + return 3; + case "VEC4": + return 4; + case "MAT2": + return 4; + case "MAT3": + return 9; + case "MAT4": + return 16; + } + throw new Error("".concat(context, ": Invalid type (").concat(type, ")")); + }; + GLTFLoader._ValidateUri = function (uri) { + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Tools.IsBase64(uri) || uri.indexOf("..") === -1; + }; + /** + * @internal + */ + GLTFLoader._GetDrawMode = function (context, mode) { + if (mode == undefined) { + mode = 4 /* MeshPrimitiveMode.TRIANGLES */; + } + switch (mode) { + case 0 /* MeshPrimitiveMode.POINTS */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.PointListDrawMode; + case 1 /* MeshPrimitiveMode.LINES */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.LineListDrawMode; + case 2 /* MeshPrimitiveMode.LINE_LOOP */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.LineLoopDrawMode; + case 3 /* MeshPrimitiveMode.LINE_STRIP */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.LineStripDrawMode; + case 4 /* MeshPrimitiveMode.TRIANGLES */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFillMode; + case 5 /* MeshPrimitiveMode.TRIANGLE_STRIP */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleStripDrawMode; + case 6 /* MeshPrimitiveMode.TRIANGLE_FAN */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFanDrawMode; + } + throw new Error("".concat(context, ": Invalid mesh primitive mode (").concat(mode, ")")); + }; + GLTFLoader.prototype._compileMaterialsAsync = function () { + var _this = this; + this._parent._startPerformanceCounter("Compile materials"); + var promises = new Array(); + if (this._gltf.materials) { + for (var _i = 0, _a = this._gltf.materials; _i < _a.length; _i++) { + var material = _a[_i]; + if (material._data) { + for (var babylonDrawMode in material._data) { + var babylonData = material._data[babylonDrawMode]; + for (var _b = 0, _c = babylonData.babylonMeshes; _b < _c.length; _b++) { + var babylonMesh = _c[_b]; + // Ensure nonUniformScaling is set if necessary. + babylonMesh.computeWorldMatrix(true); + var babylonMaterial = babylonData.babylonMaterial; + promises.push(babylonMaterial.forceCompilationAsync(babylonMesh)); + promises.push(babylonMaterial.forceCompilationAsync(babylonMesh, { useInstances: true })); + if (this._parent.useClipPlane) { + promises.push(babylonMaterial.forceCompilationAsync(babylonMesh, { clipPlane: true })); + promises.push(babylonMaterial.forceCompilationAsync(babylonMesh, { clipPlane: true, useInstances: true })); + } + } + } + } + } + } + return Promise.all(promises).then(function () { + _this._parent._endPerformanceCounter("Compile materials"); + }); + }; + GLTFLoader.prototype._compileShadowGeneratorsAsync = function () { + var _this = this; + this._parent._startPerformanceCounter("Compile shadow generators"); + var promises = new Array(); + var lights = this._babylonScene.lights; + for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) { + var light = lights_1[_i]; + var generator = light.getShadowGenerator(); + if (generator) { + promises.push(generator.forceCompilationAsync()); + } + } + return Promise.all(promises).then(function () { + _this._parent._endPerformanceCounter("Compile shadow generators"); + }); + }; + GLTFLoader.prototype._forEachExtensions = function (action) { + for (var _i = 0, _a = this._extensions; _i < _a.length; _i++) { + var extension = _a[_i]; + if (extension.enabled) { + action(extension); + } + } + }; + GLTFLoader.prototype._applyExtensions = function (property, functionName, actionAsync) { + for (var _i = 0, _a = this._extensions; _i < _a.length; _i++) { + var extension = _a[_i]; + if (extension.enabled) { + var id = "".concat(extension.name, ".").concat(functionName); + var loaderProperty = property; + loaderProperty._activeLoaderExtensionFunctions = loaderProperty._activeLoaderExtensionFunctions || {}; + var activeLoaderExtensionFunctions = loaderProperty._activeLoaderExtensionFunctions; + if (!activeLoaderExtensionFunctions[id]) { + activeLoaderExtensionFunctions[id] = true; + try { + var result = actionAsync(extension); + if (result) { + return result; + } + } + finally { + delete activeLoaderExtensionFunctions[id]; + } + } + } + } + return null; + }; + GLTFLoader.prototype._extensionsOnLoading = function () { + this._forEachExtensions(function (extension) { return extension.onLoading && extension.onLoading(); }); + }; + GLTFLoader.prototype._extensionsOnReady = function () { + this._forEachExtensions(function (extension) { return extension.onReady && extension.onReady(); }); + }; + GLTFLoader.prototype._extensionsLoadSceneAsync = function (context, scene) { + return this._applyExtensions(scene, "loadScene", function (extension) { return extension.loadSceneAsync && extension.loadSceneAsync(context, scene); }); + }; + GLTFLoader.prototype._extensionsLoadNodeAsync = function (context, node, assign) { + return this._applyExtensions(node, "loadNode", function (extension) { return extension.loadNodeAsync && extension.loadNodeAsync(context, node, assign); }); + }; + GLTFLoader.prototype._extensionsLoadCameraAsync = function (context, camera, assign) { + return this._applyExtensions(camera, "loadCamera", function (extension) { return extension.loadCameraAsync && extension.loadCameraAsync(context, camera, assign); }); + }; + GLTFLoader.prototype._extensionsLoadVertexDataAsync = function (context, primitive, babylonMesh) { + return this._applyExtensions(primitive, "loadVertexData", function (extension) { return extension._loadVertexDataAsync && extension._loadVertexDataAsync(context, primitive, babylonMesh); }); + }; + GLTFLoader.prototype._extensionsLoadMeshPrimitiveAsync = function (context, name, node, mesh, primitive, assign) { + return this._applyExtensions(primitive, "loadMeshPrimitive", function (extension) { return extension._loadMeshPrimitiveAsync && extension._loadMeshPrimitiveAsync(context, name, node, mesh, primitive, assign); }); + }; + GLTFLoader.prototype._extensionsLoadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) { + return this._applyExtensions(material, "loadMaterial", function (extension) { return extension._loadMaterialAsync && extension._loadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign); }); + }; + GLTFLoader.prototype._extensionsCreateMaterial = function (context, material, babylonDrawMode) { + return this._applyExtensions(material, "createMaterial", function (extension) { return extension.createMaterial && extension.createMaterial(context, material, babylonDrawMode); }); + }; + GLTFLoader.prototype._extensionsLoadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + return this._applyExtensions(material, "loadMaterialProperties", function (extension) { return extension.loadMaterialPropertiesAsync && extension.loadMaterialPropertiesAsync(context, material, babylonMaterial); }); + }; + GLTFLoader.prototype._extensionsLoadTextureInfoAsync = function (context, textureInfo, assign) { + return this._applyExtensions(textureInfo, "loadTextureInfo", function (extension) { return extension.loadTextureInfoAsync && extension.loadTextureInfoAsync(context, textureInfo, assign); }); + }; + GLTFLoader.prototype._extensionsLoadTextureAsync = function (context, texture, assign) { + return this._applyExtensions(texture, "loadTexture", function (extension) { return extension._loadTextureAsync && extension._loadTextureAsync(context, texture, assign); }); + }; + GLTFLoader.prototype._extensionsLoadAnimationAsync = function (context, animation) { + return this._applyExtensions(animation, "loadAnimation", function (extension) { return extension.loadAnimationAsync && extension.loadAnimationAsync(context, animation); }); + }; + GLTFLoader.prototype._extensionsLoadAnimationChannelAsync = function (context, animationContext, animation, channel, onLoad) { + return this._applyExtensions(animation, "loadAnimationChannel", function (extension) { return extension._loadAnimationChannelAsync && extension._loadAnimationChannelAsync(context, animationContext, animation, channel, onLoad); }); + }; + GLTFLoader.prototype._extensionsLoadSkinAsync = function (context, node, skin) { + return this._applyExtensions(skin, "loadSkin", function (extension) { return extension._loadSkinAsync && extension._loadSkinAsync(context, node, skin); }); + }; + GLTFLoader.prototype._extensionsLoadUriAsync = function (context, property, uri) { + return this._applyExtensions(property, "loadUri", function (extension) { return extension._loadUriAsync && extension._loadUriAsync(context, property, uri); }); + }; + GLTFLoader.prototype._extensionsLoadBufferViewAsync = function (context, bufferView) { + return this._applyExtensions(bufferView, "loadBufferView", function (extension) { return extension.loadBufferViewAsync && extension.loadBufferViewAsync(context, bufferView); }); + }; + GLTFLoader.prototype._extensionsLoadBufferAsync = function (context, buffer, byteOffset, byteLength) { + return this._applyExtensions(buffer, "loadBuffer", function (extension) { return extension.loadBufferAsync && extension.loadBufferAsync(context, buffer, byteOffset, byteLength); }); + }; + /** + * Helper method called by a loader extension to load an glTF extension. + * @param context The context when loading the asset + * @param property The glTF property to load the extension from + * @param extensionName The name of the extension to load + * @param actionAsync The action to run + * @returns The promise returned by actionAsync or null if the extension does not exist + */ + GLTFLoader.LoadExtensionAsync = function (context, property, extensionName, actionAsync) { + if (!property.extensions) { + return null; + } + var extensions = property.extensions; + var extension = extensions[extensionName]; + if (!extension) { + return null; + } + return actionAsync("".concat(context, "/extensions/").concat(extensionName), extension); + }; + /** + * Helper method called by a loader extension to load a glTF extra. + * @param context The context when loading the asset + * @param property The glTF property to load the extra from + * @param extensionName The name of the extension to load + * @param actionAsync The action to run + * @returns The promise returned by actionAsync or null if the extra does not exist + */ + GLTFLoader.LoadExtraAsync = function (context, property, extensionName, actionAsync) { + if (!property.extras) { + return null; + } + var extras = property.extras; + var extra = extras[extensionName]; + if (!extra) { + return null; + } + return actionAsync("".concat(context, "/extras/").concat(extensionName), extra); + }; + /** + * Checks for presence of an extension. + * @param name The name of the extension to check + * @returns A boolean indicating the presence of the given extension name in `extensionsUsed` + */ + GLTFLoader.prototype.isExtensionUsed = function (name) { + return !!this._gltf.extensionsUsed && this._gltf.extensionsUsed.indexOf(name) !== -1; + }; + /** + * Increments the indentation level and logs a message. + * @param message The message to log + */ + GLTFLoader.prototype.logOpen = function (message) { + this._parent._logOpen(message); + }; + /** + * Decrements the indentation level. + */ + GLTFLoader.prototype.logClose = function () { + this._parent._logClose(); + }; + /** + * Logs a message + * @param message The message to log + */ + GLTFLoader.prototype.log = function (message) { + this._parent._log(message); + }; + /** + * Starts a performance counter. + * @param counterName The name of the performance counter + */ + GLTFLoader.prototype.startPerformanceCounter = function (counterName) { + this._parent._startPerformanceCounter(counterName); + }; + /** + * Ends a performance counter. + * @param counterName The name of the performance counter + */ + GLTFLoader.prototype.endPerformanceCounter = function (counterName) { + this._parent._endPerformanceCounter(counterName); + }; + GLTFLoader._RegisteredExtensions = {}; + /** + * The default glTF sampler. + */ + GLTFLoader.DefaultSampler = { index: -1 }; + return GLTFLoader; +}()); +_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFFileLoader._CreateGLTF2Loader = function (parent) { return new GLTFLoader(parent); }; + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts": +/*!****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ AnimationPropertyInfo: () => (/* binding */ AnimationPropertyInfo), +/* harmony export */ TransformNodeAnimationPropertyInfo: () => (/* binding */ TransformNodeAnimationPropertyInfo), +/* harmony export */ WeightAnimationPropertyInfo: () => (/* binding */ WeightAnimationPropertyInfo), +/* harmony export */ getQuaternion: () => (/* binding */ getQuaternion), +/* harmony export */ getVector3: () => (/* binding */ getVector3), +/* harmony export */ getWeights: () => (/* binding */ getWeights), +/* harmony export */ nodeAnimationData: () => (/* binding */ nodeAnimationData) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__); + + + +/** @internal */ +function getVector3(_target, source, offset, scale) { + return babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(source, offset).scaleInPlace(scale); +} +/** @internal */ +function getQuaternion(_target, source, offset, scale) { + return babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(source, offset).scaleInPlace(scale); +} +/** @internal */ +function getWeights(target, source, offset, scale) { + var value = new Array(target._numMorphTargets); + for (var i = 0; i < value.length; i++) { + value[i] = source[offset++] * scale; + } + return value; +} +/** @internal */ +var AnimationPropertyInfo = /** @class */ (function () { + /** @internal */ + function AnimationPropertyInfo(type, name, getValue, getStride) { + this.type = type; + this.name = name; + this.getValue = getValue; + this.getStride = getStride; + } + AnimationPropertyInfo.prototype._buildAnimation = function (name, fps, keys) { + var babylonAnimation = new babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation(name, this.name, fps, this.type); + babylonAnimation.setKeys(keys); + return babylonAnimation; + }; + return AnimationPropertyInfo; +}()); + +/** @internal */ +var TransformNodeAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__extends)(TransformNodeAnimationPropertyInfo, _super); + function TransformNodeAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** @internal */ + TransformNodeAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + callback(target._babylonTransformNode, this._buildAnimation(name, fps, keys)); + }; + return TransformNodeAnimationPropertyInfo; +}(AnimationPropertyInfo)); + +/** @internal */ +var WeightAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__extends)(WeightAnimationPropertyInfo, _super); + function WeightAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + WeightAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + if (target._numMorphTargets) { + var _loop_1 = function (targetIndex) { + var babylonAnimation = new babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation("".concat(name, "_").concat(targetIndex), this_1.name, fps, this_1.type); + babylonAnimation.setKeys(keys.map(function (key) { return ({ + frame: key.frame, + inTangent: key.inTangent ? key.inTangent[targetIndex] : undefined, + value: key.value[targetIndex], + outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined, + interpolation: key.interpolation, + }); })); + if (target._primitiveBabylonMeshes) { + for (var _i = 0, _a = target._primitiveBabylonMeshes; _i < _a.length; _i++) { + var babylonMesh = _a[_i]; + if (babylonMesh.morphTargetManager) { + var morphTarget = babylonMesh.morphTargetManager.getTarget(targetIndex); + var babylonAnimationClone = babylonAnimation.clone(); + morphTarget.animations.push(babylonAnimationClone); + callback(morphTarget, babylonAnimationClone); + } + } + } + }; + var this_1 = this; + for (var targetIndex = 0; targetIndex < target._numMorphTargets; targetIndex++) { + _loop_1(targetIndex); + } + } + }; + return WeightAnimationPropertyInfo; +}(AnimationPropertyInfo)); + +/** @internal */ +var nodeAnimationData = { + translation: [new TransformNodeAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_VECTOR3, "position", getVector3, function () { return 3; })], + rotation: [new TransformNodeAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_QUATERNION, "rotationQuaternion", getQuaternion, function () { return 4; })], + scale: [new TransformNodeAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_VECTOR3, "scaling", getVector3, function () { return 3; })], + weights: [new WeightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "influence", getWeights, function (target) { return target._numMorphTargets; })], +}; + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/glTFLoaderExtension.ts": +/*!****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/glTFLoaderExtension.ts ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts": +/*!*****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts ***! + \*****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/index.ts": +/*!**************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/index.ts ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ ArrayItem: () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem), +/* harmony export */ EXT_lights_image_based: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_lights_image_based), +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_mesh_gpu_instancing), +/* harmony export */ EXT_meshopt_compression: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_meshopt_compression), +/* harmony export */ EXT_texture_webp: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_texture_webp), +/* harmony export */ ExtrasAsMetadata: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.ExtrasAsMetadata), +/* harmony export */ GLTFLoader: () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader), +/* harmony export */ KHR_animation_pointer: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_animation_pointer), +/* harmony export */ KHR_draco_mesh_compression: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_draco_mesh_compression), +/* harmony export */ KHR_lights: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_lights), +/* harmony export */ KHR_materials_anisotropy: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_anisotropy), +/* harmony export */ KHR_materials_clearcoat: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_clearcoat), +/* harmony export */ KHR_materials_emissive_strength: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_emissive_strength), +/* harmony export */ KHR_materials_ior: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_ior), +/* harmony export */ KHR_materials_iridescence: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_iridescence), +/* harmony export */ KHR_materials_pbrSpecularGlossiness: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_pbrSpecularGlossiness), +/* harmony export */ KHR_materials_sheen: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_sheen), +/* harmony export */ KHR_materials_specular: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_specular), +/* harmony export */ KHR_materials_translucency: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_translucency), +/* harmony export */ KHR_materials_transmission: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_transmission), +/* harmony export */ KHR_materials_unlit: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_unlit), +/* harmony export */ KHR_materials_variants: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_variants), +/* harmony export */ KHR_materials_volume: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_volume), +/* harmony export */ KHR_mesh_quantization: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_mesh_quantization), +/* harmony export */ KHR_texture_basisu: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_texture_basisu), +/* harmony export */ KHR_texture_transform: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_texture_transform), +/* harmony export */ KHR_xmp_json_ld: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_xmp_json_ld), +/* harmony export */ MSFT_audio_emitter: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_audio_emitter), +/* harmony export */ MSFT_lod: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_lod), +/* harmony export */ MSFT_minecraftMesh: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_minecraftMesh), +/* harmony export */ MSFT_sRGBFactors: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_sRGBFactors) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); +/* harmony import */ var _glTFLoaderExtension__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFLoaderExtension */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderExtension.ts"); +/* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts"); +/* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Extensions/index */ "../../../dev/loaders/src/glTF/2.0/Extensions/index.ts"); +/* eslint-disable import/no-internal-modules */ + + + + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/glTFFileLoader.ts": +/*!*******************************************************!*\ + !*** ../../../dev/loaders/src/glTF/glTFFileLoader.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFFileLoader: () => (/* binding */ GLTFFileLoader), +/* harmony export */ GLTFLoaderAnimationStartMode: () => (/* binding */ GLTFLoaderAnimationStartMode), +/* harmony export */ GLTFLoaderCoordinateSystemMode: () => (/* binding */ GLTFLoaderCoordinateSystemMode), +/* harmony export */ GLTFLoaderState: () => (/* binding */ GLTFLoaderState) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/error */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFValidation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFValidation */ "../../../dev/loaders/src/glTF/glTFValidation.ts"); + + + + + + + + + +function readAsync(arrayBuffer, byteOffset, byteLength) { + try { + return Promise.resolve(new Uint8Array(arrayBuffer, byteOffset, byteLength)); + } + catch (e) { + return Promise.reject(e); + } +} +function readViewAsync(arrayBufferView, byteOffset, byteLength) { + try { + if (arrayBufferView.byteOffset + byteLength > arrayBufferView.byteLength) { + throw new Error("Array length out of bounds."); + } + return Promise.resolve(new Uint8Array(arrayBufferView.buffer, arrayBufferView.byteOffset + byteOffset, byteLength)); + } + catch (e) { + return Promise.reject(e); + } +} +/** + * Mode that determines the coordinate system to use. + */ +var GLTFLoaderCoordinateSystemMode; +(function (GLTFLoaderCoordinateSystemMode) { + /** + * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene. + */ + GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["AUTO"] = 0] = "AUTO"; + /** + * Sets the useRightHandedSystem flag on the scene. + */ + GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["FORCE_RIGHT_HANDED"] = 1] = "FORCE_RIGHT_HANDED"; +})(GLTFLoaderCoordinateSystemMode || (GLTFLoaderCoordinateSystemMode = {})); +/** + * Mode that determines what animations will start. + */ +var GLTFLoaderAnimationStartMode; +(function (GLTFLoaderAnimationStartMode) { + /** + * No animation will start. + */ + GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["NONE"] = 0] = "NONE"; + /** + * The first animation will start. + */ + GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["FIRST"] = 1] = "FIRST"; + /** + * All animations will start. + */ + GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["ALL"] = 2] = "ALL"; +})(GLTFLoaderAnimationStartMode || (GLTFLoaderAnimationStartMode = {})); +/** + * Loader state. + */ +var GLTFLoaderState; +(function (GLTFLoaderState) { + /** + * The asset is loading. + */ + GLTFLoaderState[GLTFLoaderState["LOADING"] = 0] = "LOADING"; + /** + * The asset is ready for rendering. + */ + GLTFLoaderState[GLTFLoaderState["READY"] = 1] = "READY"; + /** + * The asset is completely loaded. + */ + GLTFLoaderState[GLTFLoaderState["COMPLETE"] = 2] = "COMPLETE"; +})(GLTFLoaderState || (GLTFLoaderState = {})); +/** + * File loader for loading glTF files into a scene. + */ +var GLTFFileLoader = /** @class */ (function () { + function GLTFFileLoader() { + // -------------- + // Common options + // -------------- + /** + * Raised when the asset has been parsed + */ + this.onParsedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + // ---------- + // V2 options + // ---------- + /** + * The coordinate system mode. Defaults to AUTO. + */ + this.coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO; + /** + * The animation start mode. Defaults to FIRST. + */ + this.animationStartMode = GLTFLoaderAnimationStartMode.FIRST; + /** + * Defines if the loader should compile materials before raising the success callback. Defaults to false. + */ + this.compileMaterials = false; + /** + * Defines if the loader should also compile materials with clip planes. Defaults to false. + */ + this.useClipPlane = false; + /** + * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false. + */ + this.compileShadowGenerators = false; + /** + * Defines if the Alpha blended materials are only applied as coverage. + * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials. + * If true, no extra effects are applied to transparent pixels. + */ + this.transparencyAsCoverage = false; + /** + * Defines if the loader should use range requests when load binary glTF files from HTTP. + * Enabling will disable offline support and glTF validator. + * Defaults to false. + */ + this.useRangeRequests = false; + /** + * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true. + */ + this.createInstances = true; + /** + * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false. + */ + this.alwaysComputeBoundingBox = false; + /** + * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false. + */ + this.loadAllMaterials = false; + /** + * If true, load only the materials defined in the file. Defaults to false. + */ + this.loadOnlyMaterials = false; + /** + * If true, do not load any materials defined in the file. Defaults to false. + */ + this.skipMaterials = false; + /** + * If true, load the color (gamma encoded) textures into sRGB buffers (if supported by the GPU), which will yield more accurate results when sampling the texture. Defaults to true. + */ + this.useSRGBBuffers = true; + /** + * When loading glTF animations, which are defined in seconds, target them to this FPS. Defaults to 60. + */ + this.targetFps = 60; + /** + * Defines if the loader should always compute the nearest common ancestor of the skeleton joints instead of using `skin.skeleton`. Defaults to false. + * Set this to true if loading assets with invalid `skin.skeleton` values. + */ + this.alwaysComputeSkeletonRootNode = false; + /** + * Function called before loading a url referenced by the asset. + * @param url + */ + this.preprocessUrlAsync = function (url) { return Promise.resolve(url); }; + /** + * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh. + * Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...) + */ + this.onMeshLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Callback raised when the loader creates a skin after parsing the glTF properties of the skin node. + * @see https://doc.babylonjs.com/features/featuresDeepDive/importers/glTF/glTFSkinning#ignoring-the-transform-of-the-skinned-mesh + * @param node - the transform node that corresponds to the original glTF skin node used for animations + * @param skinnedNode - the transform node that is the skinned mesh itself or the parent of the skinned meshes + */ + this.onSkinLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when the loader creates a texture after parsing the glTF properties of the texture. + */ + this.onTextureLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when the loader creates a material after parsing the glTF properties of the material. + */ + this.onMaterialLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when the loader creates a camera after parsing the glTF properties of the camera. + */ + this.onCameraLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when the asset is completely loaded, immediately before the loader is disposed. + * For assets with LODs, raised when all of the LODs are complete. + * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise. + */ + this.onCompleteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when an error occurs. + */ + this.onErrorObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised after the loader is disposed. + */ + this.onDisposeObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised after a loader extension is created. + * Set additional options for a loader extension in this event. + */ + this.onExtensionLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Defines if the loader should validate the asset. + */ + this.validate = false; + /** + * Observable raised after validation when validate is set to true. The event data is the result of the validation. + */ + this.onValidatedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + this._loader = null; + this._state = null; + this._requests = new Array(); + /** + * Name of the loader ("gltf") + */ + this.name = "gltf"; + /** @internal */ + this.extensions = { + ".gltf": { isBinary: false }, + ".glb": { isBinary: true }, + }; + /** + * Observable raised when the loader state changes. + */ + this.onLoaderStateChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + this._logIndentLevel = 0; + this._loggingEnabled = false; + /** @internal */ + this._log = this._logDisabled; + this._capturePerformanceCounters = false; + /** @internal */ + this._startPerformanceCounter = this._startPerformanceCounterDisabled; + /** @internal */ + this._endPerformanceCounter = this._endPerformanceCounterDisabled; + } + Object.defineProperty(GLTFFileLoader.prototype, "onParsed", { + /** + * Raised when the asset has been parsed + */ + set: function (callback) { + if (this._onParsedObserver) { + this.onParsedObservable.remove(this._onParsedObserver); + } + this._onParsedObserver = this.onParsedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onMeshLoaded", { + /** + * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh. + * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...) + */ + set: function (callback) { + if (this._onMeshLoadedObserver) { + this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver); + } + this._onMeshLoadedObserver = this.onMeshLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onTextureLoaded", { + /** + * Callback raised when the loader creates a texture after parsing the glTF properties of the texture. + */ + set: function (callback) { + if (this._onTextureLoadedObserver) { + this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver); + } + this._onTextureLoadedObserver = this.onTextureLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onMaterialLoaded", { + /** + * Callback raised when the loader creates a material after parsing the glTF properties of the material. + */ + set: function (callback) { + if (this._onMaterialLoadedObserver) { + this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver); + } + this._onMaterialLoadedObserver = this.onMaterialLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onCameraLoaded", { + /** + * Callback raised when the loader creates a camera after parsing the glTF properties of the camera. + */ + set: function (callback) { + if (this._onCameraLoadedObserver) { + this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver); + } + this._onCameraLoadedObserver = this.onCameraLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onComplete", { + /** + * Callback raised when the asset is completely loaded, immediately before the loader is disposed. + * For assets with LODs, raised when all of the LODs are complete. + * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise. + */ + set: function (callback) { + if (this._onCompleteObserver) { + this.onCompleteObservable.remove(this._onCompleteObserver); + } + this._onCompleteObserver = this.onCompleteObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onError", { + /** + * Callback raised when an error occurs. + */ + set: function (callback) { + if (this._onErrorObserver) { + this.onErrorObservable.remove(this._onErrorObserver); + } + this._onErrorObserver = this.onErrorObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onDispose", { + /** + * Callback raised after the loader is disposed. + */ + set: function (callback) { + if (this._onDisposeObserver) { + this.onDisposeObservable.remove(this._onDisposeObserver); + } + this._onDisposeObserver = this.onDisposeObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onExtensionLoaded", { + /** + * Callback raised after a loader extension is created. + */ + set: function (callback) { + if (this._onExtensionLoadedObserver) { + this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver); + } + this._onExtensionLoadedObserver = this.onExtensionLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "loggingEnabled", { + /** + * Defines if the loader logging is enabled. + */ + get: function () { + return this._loggingEnabled; + }, + set: function (value) { + if (this._loggingEnabled === value) { + return; + } + this._loggingEnabled = value; + if (this._loggingEnabled) { + this._log = this._logEnabled; + } + else { + this._log = this._logDisabled; + } + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "capturePerformanceCounters", { + /** + * Defines if the loader should capture performance counters. + */ + get: function () { + return this._capturePerformanceCounters; + }, + set: function (value) { + if (this._capturePerformanceCounters === value) { + return; + } + this._capturePerformanceCounters = value; + if (this._capturePerformanceCounters) { + this._startPerformanceCounter = this._startPerformanceCounterEnabled; + this._endPerformanceCounter = this._endPerformanceCounterEnabled; + } + else { + this._startPerformanceCounter = this._startPerformanceCounterDisabled; + this._endPerformanceCounter = this._endPerformanceCounterDisabled; + } + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onValidated", { + /** + * Callback raised after a loader extension is created. + */ + set: function (callback) { + if (this._onValidatedObserver) { + this.onValidatedObservable.remove(this._onValidatedObserver); + } + this._onValidatedObserver = this.onValidatedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + /** + * Disposes the loader, releases resources during load, and cancels any outstanding requests. + */ + GLTFFileLoader.prototype.dispose = function () { + if (this._loader) { + this._loader.dispose(); + this._loader = null; + } + for (var _i = 0, _a = this._requests; _i < _a.length; _i++) { + var request = _a[_i]; + request.abort(); + } + this._requests.length = 0; + delete this._progressCallback; + this.preprocessUrlAsync = function (url) { return Promise.resolve(url); }; + this.onMeshLoadedObservable.clear(); + this.onSkinLoadedObservable.clear(); + this.onTextureLoadedObservable.clear(); + this.onMaterialLoadedObservable.clear(); + this.onCameraLoadedObservable.clear(); + this.onCompleteObservable.clear(); + this.onExtensionLoadedObservable.clear(); + this.onDisposeObservable.notifyObservers(undefined); + this.onDisposeObservable.clear(); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.loadFile = function (scene, fileOrUrl, rootUrl, onSuccess, onProgress, useArrayBuffer, onError, name) { + var _this = this; + if (ArrayBuffer.isView(fileOrUrl)) { + this._loadBinary(scene, fileOrUrl, rootUrl, onSuccess, onError, name); + return null; + } + this._progressCallback = onProgress; + var fileName = fileOrUrl.name || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.GetFilename(fileOrUrl); + if (useArrayBuffer) { + if (this.useRangeRequests) { + if (this.validate) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("glTF validation is not supported when range requests are enabled"); + } + var fileRequest_1 = { + abort: function () { }, + onCompleteObservable: new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(), + }; + var dataBuffer = { + readAsync: function (byteOffset, byteLength) { + return new Promise(function (resolve, reject) { + _this._loadFile(scene, fileOrUrl, function (data) { + resolve(new Uint8Array(data)); + }, true, function (error) { + reject(error); + }, function (webRequest) { + webRequest.setRequestHeader("Range", "bytes=".concat(byteOffset, "-").concat(byteOffset + byteLength - 1)); + }); + }); + }, + byteLength: 0, + }; + this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader(dataBuffer)).then(function (loaderData) { + fileRequest_1.onCompleteObservable.notifyObservers(fileRequest_1); + onSuccess(loaderData); + }, onError ? function (error) { return onError(undefined, error); } : undefined); + return fileRequest_1; + } + return this._loadFile(scene, fileOrUrl, function (data) { + _this._validate(scene, new Uint8Array(data), rootUrl, fileName); + _this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader({ + readAsync: function (byteOffset, byteLength) { return readAsync(data, byteOffset, byteLength); }, + byteLength: data.byteLength, + })).then(function (loaderData) { + onSuccess(loaderData); + }, onError ? function (error) { return onError(undefined, error); } : undefined); + }, true, onError); + } + return this._loadFile(scene, fileOrUrl, function (data) { + _this._validate(scene, new Uint8Array(data), rootUrl, fileName); + onSuccess({ json: _this._parseJson(data) }); + }, useArrayBuffer, onError); + }; + /** + * @internal + */ + GLTFFileLoader.prototype._loadBinary = function (scene, data, rootUrl, onSuccess, onError, fileName) { + this._validate(scene, data, rootUrl, fileName); + this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader({ + readAsync: function (byteOffset, byteLength) { return readViewAsync(data, byteOffset, byteLength); }, + byteLength: data.byteLength, + })).then(function (loaderData) { + onSuccess(loaderData); + }, onError ? function (error) { return onError(undefined, error); } : undefined); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onProgress, fileName) { + var _this = this; + return Promise.resolve().then(function () { + _this.onParsedObservable.notifyObservers(data); + _this.onParsedObservable.clear(); + _this._log("Loading ".concat(fileName || "")); + _this._loader = _this._getLoader(data); + return _this._loader.importMeshAsync(meshesNames, scene, null, data, rootUrl, onProgress, fileName); + }); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) { + var _this = this; + return Promise.resolve().then(function () { + _this.onParsedObservable.notifyObservers(data); + _this.onParsedObservable.clear(); + _this._log("Loading ".concat(fileName || "")); + _this._loader = _this._getLoader(data); + return _this._loader.loadAsync(scene, data, rootUrl, onProgress, fileName); + }); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.loadAssetContainerAsync = function (scene, data, rootUrl, onProgress, fileName) { + var _this = this; + return Promise.resolve().then(function () { + _this.onParsedObservable.notifyObservers(data); + _this.onParsedObservable.clear(); + _this._log("Loading ".concat(fileName || "")); + _this._loader = _this._getLoader(data); + // Prepare the asset container. + var container = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.AssetContainer(scene); + // Get materials/textures when loading to add to container + var materials = []; + _this.onMaterialLoadedObservable.add(function (material) { + materials.push(material); + }); + var textures = []; + _this.onTextureLoadedObservable.add(function (texture) { + textures.push(texture); + }); + var cameras = []; + _this.onCameraLoadedObservable.add(function (camera) { + cameras.push(camera); + }); + var morphTargetManagers = []; + _this.onMeshLoadedObservable.add(function (mesh) { + if (mesh.morphTargetManager) { + morphTargetManagers.push(mesh.morphTargetManager); + } + }); + return _this._loader.importMeshAsync(null, scene, container, data, rootUrl, onProgress, fileName).then(function (result) { + Array.prototype.push.apply(container.geometries, result.geometries); + Array.prototype.push.apply(container.meshes, result.meshes); + Array.prototype.push.apply(container.particleSystems, result.particleSystems); + Array.prototype.push.apply(container.skeletons, result.skeletons); + Array.prototype.push.apply(container.animationGroups, result.animationGroups); + Array.prototype.push.apply(container.materials, materials); + Array.prototype.push.apply(container.textures, textures); + Array.prototype.push.apply(container.lights, result.lights); + Array.prototype.push.apply(container.transformNodes, result.transformNodes); + Array.prototype.push.apply(container.cameras, cameras); + Array.prototype.push.apply(container.morphTargetManagers, morphTargetManagers); + return container; + }); + }); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.canDirectLoad = function (data) { + return ((data.indexOf("asset") !== -1 && data.indexOf("version") !== -1) || + data.startsWith("data:base64," + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat. + data.startsWith("data:;base64," + GLTFFileLoader._MagicBase64Encoded) || + data.startsWith("data:application/octet-stream;base64," + GLTFFileLoader._MagicBase64Encoded) || + data.startsWith("data:model/gltf-binary;base64," + GLTFFileLoader._MagicBase64Encoded)); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.directLoad = function (scene, data) { + if (data.startsWith("base64," + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat. + data.startsWith(";base64," + GLTFFileLoader._MagicBase64Encoded) || + data.startsWith("application/octet-stream;base64," + GLTFFileLoader._MagicBase64Encoded) || + data.startsWith("model/gltf-binary;base64," + GLTFFileLoader._MagicBase64Encoded)) { + var arrayBuffer_1 = (0,babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DecodeBase64UrlToBinary)(data); + this._validate(scene, new Uint8Array(arrayBuffer_1)); + return this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader({ + readAsync: function (byteOffset, byteLength) { return readAsync(arrayBuffer_1, byteOffset, byteLength); }, + byteLength: arrayBuffer_1.byteLength, + })); + } + this._validate(scene, data); + return Promise.resolve({ json: this._parseJson(data) }); + }; + /** @internal */ + GLTFFileLoader.prototype.createPlugin = function () { + return new GLTFFileLoader(); + }; + Object.defineProperty(GLTFFileLoader.prototype, "loaderState", { + /** + * The loader state or null if the loader is not active. + */ + get: function () { + return this._state; + }, + enumerable: false, + configurable: true + }); + /** + * Returns a promise that resolves when the asset is completely loaded. + * @returns a promise that resolves when the asset is completely loaded. + */ + GLTFFileLoader.prototype.whenCompleteAsync = function () { + var _this = this; + return new Promise(function (resolve, reject) { + _this.onCompleteObservable.addOnce(function () { + resolve(); + }); + _this.onErrorObservable.addOnce(function (reason) { + reject(reason); + }); + }); + }; + /** + * @internal + */ + GLTFFileLoader.prototype._setState = function (state) { + if (this._state === state) { + return; + } + this._state = state; + this.onLoaderStateChangedObservable.notifyObservers(this._state); + this._log(GLTFLoaderState[this._state]); + }; + /** + * @internal + */ + GLTFFileLoader.prototype._loadFile = function (scene, fileOrUrl, onSuccess, useArrayBuffer, onError, onOpened) { + var _this = this; + var request = scene._loadFile(fileOrUrl, onSuccess, function (event) { + _this._onProgress(event, request); + }, true, useArrayBuffer, onError, onOpened); + request.onCompleteObservable.add(function (request) { + _this._requests.splice(_this._requests.indexOf(request), 1); + }); + this._requests.push(request); + return request; + }; + GLTFFileLoader.prototype._onProgress = function (event, request) { + if (!this._progressCallback) { + return; + } + request._lengthComputable = event.lengthComputable; + request._loaded = event.loaded; + request._total = event.total; + var lengthComputable = true; + var loaded = 0; + var total = 0; + for (var _i = 0, _a = this._requests; _i < _a.length; _i++) { + var request_1 = _a[_i]; + if (request_1._lengthComputable === undefined || request_1._loaded === undefined || request_1._total === undefined) { + return; + } + lengthComputable = lengthComputable && request_1._lengthComputable; + loaded += request_1._loaded; + total += request_1._total; + } + this._progressCallback({ + lengthComputable: lengthComputable, + loaded: loaded, + total: lengthComputable ? total : 0, + }); + }; + GLTFFileLoader.prototype._validate = function (scene, data, rootUrl, fileName) { + var _this = this; + if (rootUrl === void 0) { rootUrl = ""; } + if (fileName === void 0) { fileName = ""; } + if (!this.validate) { + return; + } + this._startPerformanceCounter("Validate JSON"); + _glTFValidation__WEBPACK_IMPORTED_MODULE_1__.GLTFValidation.ValidateAsync(data, rootUrl, fileName, function (uri) { + return _this.preprocessUrlAsync(rootUrl + uri).then(function (url) { return scene._loadFileAsync(url, undefined, true, true); }); + }).then(function (result) { + _this._endPerformanceCounter("Validate JSON"); + _this.onValidatedObservable.notifyObservers(result); + _this.onValidatedObservable.clear(); + }, function (reason) { + _this._endPerformanceCounter("Validate JSON"); + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Failed to validate: ".concat(reason.message)); + _this.onValidatedObservable.clear(); + }); + }; + GLTFFileLoader.prototype._getLoader = function (loaderData) { + var asset = loaderData.json.asset || {}; + this._log("Asset version: ".concat(asset.version)); + asset.minVersion && this._log("Asset minimum version: ".concat(asset.minVersion)); + asset.generator && this._log("Asset generator: ".concat(asset.generator)); + var version = GLTFFileLoader._parseVersion(asset.version); + if (!version) { + throw new Error("Invalid version: " + asset.version); + } + if (asset.minVersion !== undefined) { + var minVersion = GLTFFileLoader._parseVersion(asset.minVersion); + if (!minVersion) { + throw new Error("Invalid minimum version: " + asset.minVersion); + } + if (GLTFFileLoader._compareVersion(minVersion, { major: 2, minor: 0 }) > 0) { + throw new Error("Incompatible minimum version: " + asset.minVersion); + } + } + var createLoaders = { + 1: GLTFFileLoader._CreateGLTF1Loader, + 2: GLTFFileLoader._CreateGLTF2Loader, + }; + var createLoader = createLoaders[version.major]; + if (!createLoader) { + throw new Error("Unsupported version: " + asset.version); + } + return createLoader(this); + }; + GLTFFileLoader.prototype._parseJson = function (json) { + this._startPerformanceCounter("Parse JSON"); + this._log("JSON length: ".concat(json.length)); + var parsed = JSON.parse(json); + this._endPerformanceCounter("Parse JSON"); + return parsed; + }; + GLTFFileLoader.prototype._unpackBinaryAsync = function (dataReader) { + var _this = this; + this._startPerformanceCounter("Unpack Binary"); + // Read magic + version + length + json length + json format + return dataReader.loadAsync(20).then(function () { + var Binary = { + Magic: 0x46546c67, + }; + var magic = dataReader.readUint32(); + if (magic !== Binary.Magic) { + throw new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.RuntimeError("Unexpected magic: " + magic, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.ErrorCodes.GLTFLoaderUnexpectedMagicError); + } + var version = dataReader.readUint32(); + if (_this.loggingEnabled) { + _this._log("Binary version: ".concat(version)); + } + var length = dataReader.readUint32(); + if (!_this.useRangeRequests && length !== dataReader.buffer.byteLength) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Length in header does not match actual data length: ".concat(length, " != ").concat(dataReader.buffer.byteLength)); + } + var unpacked; + switch (version) { + case 1: { + unpacked = _this._unpackBinaryV1Async(dataReader, length); + break; + } + case 2: { + unpacked = _this._unpackBinaryV2Async(dataReader, length); + break; + } + default: { + throw new Error("Unsupported version: " + version); + } + } + _this._endPerformanceCounter("Unpack Binary"); + return unpacked; + }); + }; + GLTFFileLoader.prototype._unpackBinaryV1Async = function (dataReader, length) { + var ContentFormat = { + JSON: 0, + }; + var contentLength = dataReader.readUint32(); + var contentFormat = dataReader.readUint32(); + if (contentFormat !== ContentFormat.JSON) { + throw new Error("Unexpected content format: ".concat(contentFormat)); + } + var bodyLength = length - dataReader.byteOffset; + var data = { json: this._parseJson(dataReader.readString(contentLength)), bin: null }; + if (bodyLength !== 0) { + var startByteOffset_1 = dataReader.byteOffset; + data.bin = { + readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_1 + byteOffset, byteLength); }, + byteLength: bodyLength, + }; + } + return Promise.resolve(data); + }; + GLTFFileLoader.prototype._unpackBinaryV2Async = function (dataReader, length) { + var _this = this; + var ChunkFormat = { + JSON: 0x4e4f534a, + BIN: 0x004e4942, + }; + // Read the JSON chunk header. + var chunkLength = dataReader.readUint32(); + var chunkFormat = dataReader.readUint32(); + if (chunkFormat !== ChunkFormat.JSON) { + throw new Error("First chunk format is not JSON"); + } + // Bail if there are no other chunks. + if (dataReader.byteOffset + chunkLength === length) { + return dataReader.loadAsync(chunkLength).then(function () { + return { json: _this._parseJson(dataReader.readString(chunkLength)), bin: null }; + }); + } + // Read the JSON chunk and the length and type of the next chunk. + return dataReader.loadAsync(chunkLength + 8).then(function () { + var data = { json: _this._parseJson(dataReader.readString(chunkLength)), bin: null }; + var readAsync = function () { + var chunkLength = dataReader.readUint32(); + var chunkFormat = dataReader.readUint32(); + switch (chunkFormat) { + case ChunkFormat.JSON: { + throw new Error("Unexpected JSON chunk"); + } + case ChunkFormat.BIN: { + var startByteOffset_2 = dataReader.byteOffset; + data.bin = { + readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_2 + byteOffset, byteLength); }, + byteLength: chunkLength, + }; + dataReader.skipBytes(chunkLength); + break; + } + default: { + // ignore unrecognized chunkFormat + dataReader.skipBytes(chunkLength); + break; + } + } + if (dataReader.byteOffset !== length) { + return dataReader.loadAsync(8).then(readAsync); + } + return Promise.resolve(data); + }; + return readAsync(); + }); + }; + GLTFFileLoader._parseVersion = function (version) { + if (version === "1.0" || version === "1.0.1") { + return { + major: 1, + minor: 0, + }; + } + var match = (version + "").match(/^(\d+)\.(\d+)/); + if (!match) { + return null; + } + return { + major: parseInt(match[1]), + minor: parseInt(match[2]), + }; + }; + GLTFFileLoader._compareVersion = function (a, b) { + if (a.major > b.major) { + return 1; + } + if (a.major < b.major) { + return -1; + } + if (a.minor > b.minor) { + return 1; + } + if (a.minor < b.minor) { + return -1; + } + return 0; + }; + /** + * @internal + */ + GLTFFileLoader.prototype._logOpen = function (message) { + this._log(message); + this._logIndentLevel++; + }; + /** @internal */ + GLTFFileLoader.prototype._logClose = function () { + --this._logIndentLevel; + }; + GLTFFileLoader.prototype._logEnabled = function (message) { + var spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2); + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Logger.Log("".concat(spaces).concat(message)); + }; + GLTFFileLoader.prototype._logDisabled = function (message) { }; + GLTFFileLoader.prototype._startPerformanceCounterEnabled = function (counterName) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.StartPerformanceCounter(counterName); + }; + GLTFFileLoader.prototype._startPerformanceCounterDisabled = function (counterName) { }; + GLTFFileLoader.prototype._endPerformanceCounterEnabled = function (counterName) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.EndPerformanceCounter(counterName); + }; + GLTFFileLoader.prototype._endPerformanceCounterDisabled = function (counterName) { }; + // ---------- + // V1 options + // ---------- + /** + * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders. + * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled. + * Defaults to true. + * @internal + */ + GLTFFileLoader.IncrementalLoading = true; + /** + * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters. + * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates. + * @internal + */ + GLTFFileLoader.HomogeneousCoordinates = false; + GLTFFileLoader._MagicBase64Encoded = "Z2xURg"; // "glTF" base64 encoded (without the quotes!) + GLTFFileLoader._logSpaces = " "; + return GLTFFileLoader; +}()); +if (babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.SceneLoader) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.SceneLoader.RegisterPlugin(new GLTFFileLoader()); +} + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/glTFValidation.ts": +/*!*******************************************************!*\ + !*** ../../../dev/loaders/src/glTF/glTFValidation.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFValidation: () => (/* binding */ GLTFValidation) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__); + +function validateAsync(data, rootUrl, fileName, getExternalResource) { + var options = { + externalResourceFunction: function (uri) { return getExternalResource(uri).then(function (value) { return new Uint8Array(value); }); }, + }; + if (fileName) { + options.uri = rootUrl === "file:" ? fileName : rootUrl + fileName; + } + return data instanceof ArrayBuffer ? GLTFValidator.validateBytes(new Uint8Array(data), options) : GLTFValidator.validateString(data, options); +} +/** + * The worker function that gets converted to a blob url to pass into a worker. + */ +function workerFunc() { + var pendingExternalResources = []; + onmessage = function (message) { + var data = message.data; + switch (data.id) { + case "init": { + importScripts(data.url); + break; + } + case "validate": { + validateAsync(data.data, data.rootUrl, data.fileName, function (uri) { + return new Promise(function (resolve, reject) { + var index = pendingExternalResources.length; + pendingExternalResources.push({ resolve: resolve, reject: reject }); + postMessage({ id: "getExternalResource", index: index, uri: uri }); + }); + }).then(function (value) { + postMessage({ id: "validate.resolve", value: value }); + }, function (reason) { + postMessage({ id: "validate.reject", reason: reason }); + }); + break; + } + case "getExternalResource.resolve": { + pendingExternalResources[data.index].resolve(data.value); + break; + } + case "getExternalResource.reject": { + pendingExternalResources[data.index].reject(data.reason); + break; + } + } + }; +} +/** + * glTF validation + */ +var GLTFValidation = /** @class */ (function () { + function GLTFValidation() { + } + /** + * Validate a glTF asset using the glTF-Validator. + * @param data The JSON of a glTF or the array buffer of a binary glTF + * @param rootUrl The root url for the glTF + * @param fileName The file name for the glTF + * @param getExternalResource The callback to get external resources for the glTF validator + * @returns A promise that resolves with the glTF validation results once complete + */ + GLTFValidation.ValidateAsync = function (data, rootUrl, fileName, getExternalResource) { + var _this = this; + var dataCopy = ArrayBuffer.isView(data) ? data.slice().buffer : data; + if (typeof Worker === "function") { + return new Promise(function (resolve, reject) { + var workerContent = "".concat(validateAsync, "(").concat(workerFunc, ")()"); + var workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: "application/javascript" })); + var worker = new Worker(workerBlobUrl); + var onError = function (error) { + worker.removeEventListener("error", onError); + worker.removeEventListener("message", onMessage); + reject(error); + }; + var onMessage = function (message) { + var data = message.data; + switch (data.id) { + case "getExternalResource": { + getExternalResource(data.uri).then(function (value) { + worker.postMessage({ id: "getExternalResource.resolve", index: data.index, value: value }, [value]); + }, function (reason) { + worker.postMessage({ id: "getExternalResource.reject", index: data.index, reason: reason }); + }); + break; + } + case "validate.resolve": { + worker.removeEventListener("error", onError); + worker.removeEventListener("message", onMessage); + resolve(data.value); + worker.terminate(); + break; + } + case "validate.reject": { + worker.removeEventListener("error", onError); + worker.removeEventListener("message", onMessage); + reject(data.reason); + worker.terminate(); + } + } + }; + worker.addEventListener("error", onError); + worker.addEventListener("message", onMessage); + worker.postMessage({ id: "init", url: _this.Configuration.url }); + worker.postMessage({ id: "validate", data: dataCopy, rootUrl: rootUrl, fileName: fileName }); + }); + } + else { + if (!this._LoadScriptPromise) { + this._LoadScriptPromise = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools.LoadScriptAsync(this.Configuration.url); + } + return this._LoadScriptPromise.then(function () { + return validateAsync(dataCopy, rootUrl, fileName, getExternalResource); + }); + } + }; + /** + * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`. + */ + GLTFValidation.Configuration = { + url: "https://preview.babylonjs.com/gltf_validator.js", + }; + return GLTFValidation; +}()); + + +/***/ }), + +/***/ "../../../lts/loaders/src/legacy/legacy-glTF.ts": +/*!******************************************************!*\ + !*** ../../../lts/loaders/src/legacy/legacy-glTF.ts ***! + \******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFFileLoader: () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFFileLoader), +/* harmony export */ GLTFLoaderAnimationStartMode: () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderAnimationStartMode), +/* harmony export */ GLTFLoaderCoordinateSystemMode: () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderCoordinateSystemMode), +/* harmony export */ GLTFLoaderState: () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderState), +/* harmony export */ GLTFValidation: () => (/* reexport safe */ loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__.GLTFValidation) +/* harmony export */ }); +/* harmony import */ var loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! loaders/glTF/glTFFileLoader */ "../../../dev/loaders/src/glTF/glTFFileLoader.ts"); +/* harmony import */ var loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! loaders/glTF/glTFValidation */ "../../../dev/loaders/src/glTF/glTFValidation.ts"); + + +/** + * This is the entry point for the UMD module. + * The entry point for a future ESM package should be index.ts + */ +var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined; +if (typeof globalObject !== "undefined") { + globalObject.BABYLON = globalObject.BABYLON || {}; + for (var key in loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__) { + globalObject.BABYLON[key] = loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__[key]; + } + for (var key in loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__) { + globalObject.BABYLON[key] = loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__[key]; + } +} + + + + +/***/ }), + +/***/ "../../../lts/loaders/src/legacy/legacy-glTF2.ts": +/*!*******************************************************!*\ + !*** ../../../lts/loaders/src/legacy/legacy-glTF2.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTF2: () => (/* reexport module object */ loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__) +/* harmony export */ }); +/* harmony import */ var loaders_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! loaders/glTF/2.0/Extensions/index */ "../../../dev/loaders/src/glTF/2.0/Extensions/index.ts"); +/* harmony import */ var loaders_glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! loaders/glTF/2.0/glTFLoaderInterfaces */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts"); +/* harmony import */ var loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! loaders/glTF/2.0/index */ "../../../dev/loaders/src/glTF/2.0/index.ts"); +/* eslint-disable import/no-internal-modules */ + + + +/** + * This is the entry point for the UMD module. + * The entry point for a future ESM package should be index.ts + */ +var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined; +if (typeof globalObject !== "undefined") { + globalObject.BABYLON = globalObject.BABYLON || {}; + var BABYLON_1 = globalObject.BABYLON; + BABYLON_1.GLTF2 = BABYLON_1.GLTF2 || {}; + BABYLON_1.GLTF2.Loader = BABYLON_1.GLTF2.Loader || {}; + BABYLON_1.GLTF2.Loader.Extensions = BABYLON_1.GLTF2.Loader.Extensions || {}; + var keys = []; + for (var key in loaders_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_0__) { + BABYLON_1.GLTF2.Loader.Extensions[key] = loaders_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_0__[key]; + keys.push(key); + } + for (var key in loaders_glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__) { + BABYLON_1.GLTF2.Loader[key] = loaders_glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__[key]; + keys.push(key); + } + for (var key in loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__) { + // Prevent Reassignment. + if (keys.indexOf(key) > -1) { + continue; + } + BABYLON_1.GLTF2[key] = loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__[key]; + } +} + + + +/***/ }), + +/***/ "../../../lts/loaders/src/legacy/legacy-glTF2FileLoader.ts": +/*!*****************************************************************!*\ + !*** ../../../lts/loaders/src/legacy/legacy-glTF2FileLoader.ts ***! + \*****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTF2: () => (/* reexport safe */ _legacy_glTF2__WEBPACK_IMPORTED_MODULE_1__.GLTF2), +/* harmony export */ GLTFFileLoader: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFFileLoader), +/* harmony export */ GLTFLoaderAnimationStartMode: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderAnimationStartMode), +/* harmony export */ GLTFLoaderCoordinateSystemMode: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderCoordinateSystemMode), +/* harmony export */ GLTFLoaderState: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderState), +/* harmony export */ GLTFValidation: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFValidation) +/* harmony export */ }); +/* harmony import */ var _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./legacy-glTF */ "../../../lts/loaders/src/legacy/legacy-glTF.ts"); +/* harmony import */ var _legacy_glTF2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./legacy-glTF2 */ "../../../lts/loaders/src/legacy/legacy-glTF2.ts"); +// eslint-disable-next-line import/export + + + + +/***/ }), + +/***/ "babylonjs/Misc/observable": +/*!****************************************************************************************************!*\ + !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***! + \****************************************************************************************************/ +/***/ ((module) => { + +module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__; + +/***/ }), + +/***/ "../../../../node_modules/tslib/tslib.es6.mjs": +/*!****************************************************!*\ + !*** ../../../../node_modules/tslib/tslib.es6.mjs ***! + \****************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ __addDisposableResource: () => (/* binding */ __addDisposableResource), +/* harmony export */ __assign: () => (/* binding */ __assign), +/* harmony export */ __asyncDelegator: () => (/* binding */ __asyncDelegator), +/* harmony export */ __asyncGenerator: () => (/* binding */ __asyncGenerator), +/* harmony export */ __asyncValues: () => (/* binding */ __asyncValues), +/* harmony export */ __await: () => (/* binding */ __await), +/* harmony export */ __awaiter: () => (/* binding */ __awaiter), +/* harmony export */ __classPrivateFieldGet: () => (/* binding */ __classPrivateFieldGet), +/* harmony export */ __classPrivateFieldIn: () => (/* binding */ __classPrivateFieldIn), +/* harmony export */ __classPrivateFieldSet: () => (/* binding */ __classPrivateFieldSet), +/* harmony export */ __createBinding: () => (/* binding */ __createBinding), +/* harmony export */ __decorate: () => (/* binding */ __decorate), +/* harmony export */ __disposeResources: () => (/* binding */ __disposeResources), +/* harmony export */ __esDecorate: () => (/* binding */ __esDecorate), +/* harmony export */ __exportStar: () => (/* binding */ __exportStar), +/* harmony export */ __extends: () => (/* binding */ __extends), +/* harmony export */ __generator: () => (/* binding */ __generator), +/* harmony export */ __importDefault: () => (/* binding */ __importDefault), +/* harmony export */ __importStar: () => (/* binding */ __importStar), +/* harmony export */ __makeTemplateObject: () => (/* binding */ __makeTemplateObject), +/* harmony export */ __metadata: () => (/* binding */ __metadata), +/* harmony export */ __param: () => (/* binding */ __param), +/* harmony export */ __propKey: () => (/* binding */ __propKey), +/* harmony export */ __read: () => (/* binding */ __read), +/* harmony export */ __rest: () => (/* binding */ __rest), +/* harmony export */ __runInitializers: () => (/* binding */ __runInitializers), +/* harmony export */ __setFunctionName: () => (/* binding */ __setFunctionName), +/* harmony export */ __spread: () => (/* binding */ __spread), +/* harmony export */ __spreadArray: () => (/* binding */ __spreadArray), +/* harmony export */ __spreadArrays: () => (/* binding */ __spreadArrays), +/* harmony export */ __values: () => (/* binding */ __values), +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global Reflect, Promise, SuppressedError, Symbol */ + +var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + } + return __assign.apply(this, arguments); +} + +function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; +} + +function __decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} + +function __param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +} + +function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { + function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } + var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; + var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; + var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); + var _, done = false; + for (var i = decorators.length - 1; i >= 0; i--) { + var context = {}; + for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; + for (var p in contextIn.access) context.access[p] = contextIn.access[p]; + context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; + var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); + if (kind === "accessor") { + if (result === void 0) continue; + if (result === null || typeof result !== "object") throw new TypeError("Object expected"); + if (_ = accept(result.get)) descriptor.get = _; + if (_ = accept(result.set)) descriptor.set = _; + if (_ = accept(result.init)) initializers.unshift(_); + } + else if (_ = accept(result)) { + if (kind === "field") initializers.unshift(_); + else descriptor[key] = _; + } + } + if (target) Object.defineProperty(target, contextIn.name, descriptor); + done = true; +}; + +function __runInitializers(thisArg, initializers, value) { + var useValue = arguments.length > 2; + for (var i = 0; i < initializers.length; i++) { + value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); + } + return useValue ? value : void 0; +}; + +function __propKey(x) { + return typeof x === "symbol" ? x : "".concat(x); +}; + +function __setFunctionName(f, name, prefix) { + if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; + return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); +}; + +function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); +} + +function __awaiter(thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +var __createBinding = Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +}); + +function __exportStar(m, o) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); +} + +function __values(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +} + +function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +/** @deprecated */ +function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; +} + +/** @deprecated */ +function __spreadArrays() { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +} + +function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +} + +function __await(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); +} + +function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +} + +function __asyncDelegator(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } +} + +function __asyncValues(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +} + +function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; + +var __setModuleDefault = Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}; + +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +} + +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { default: mod }; +} + +function __classPrivateFieldGet(receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +} + +function __classPrivateFieldSet(receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; +} + +function __classPrivateFieldIn(state, receiver) { + if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object"); + return typeof state === "function" ? receiver === state : state.has(receiver); +} + +function __addDisposableResource(env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +} + +var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}; + +function __disposeResources(env) { + function fail(e) { + env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); +} + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ + __extends, + __assign, + __rest, + __decorate, + __param, + __metadata, + __awaiter, + __generator, + __createBinding, + __exportStar, + __values, + __read, + __spread, + __spreadArrays, + __spreadArray, + __await, + __asyncGenerator, + __asyncDelegator, + __asyncValues, + __makeTemplateObject, + __importStar, + __importDefault, + __classPrivateFieldGet, + __classPrivateFieldSet, + __classPrivateFieldIn, + __addDisposableResource, + __disposeResources, +}); + + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ (() => { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = (module) => { +/******/ var getter = module && module.__esModule ? +/******/ () => (module['default']) : +/******/ () => (module); +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/global */ +/******/ (() => { +/******/ __webpack_require__.g = (function() { +/******/ if (typeof globalThis === 'object') return globalThis; +/******/ try { +/******/ return this || new Function('return this')(); +/******/ } catch (e) { +/******/ if (typeof window === 'object') return window; +/******/ } +/******/ })(); +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +(() => { +/*!********************************!*\ + !*** ./src/glTF2FileLoader.ts ***! + \********************************/ +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__), +/* harmony export */ loaders: () => (/* reexport module object */ _lts_loaders_legacy_legacy_glTF2FileLoader__WEBPACK_IMPORTED_MODULE_0__) +/* harmony export */ }); +/* harmony import */ var _lts_loaders_legacy_legacy_glTF2FileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @lts/loaders/legacy/legacy-glTF2FileLoader */ "../../../lts/loaders/src/legacy/legacy-glTF2FileLoader.ts"); + + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_lts_loaders_legacy_legacy_glTF2FileLoader__WEBPACK_IMPORTED_MODULE_0__); + +})(); + +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; +}); +//# sourceMappingURL=babylon.glTF2FileLoader.js.map \ No newline at end of file diff --git a/libs/babylonjs/6.23.0/babylon.glTF2FileLoader.min.js b/libs/babylonjs/6.23.0/babylon.glTF2FileLoader.min.js new file mode 100644 index 00000000..b2e1f2df --- /dev/null +++ b/libs/babylonjs/6.23.0/babylon.glTF2FileLoader.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-loaders",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-loaders"]=t(require("babylonjs")):e.LOADERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var t={520:t=>{t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{r.d(o,{default:()=>Qe});var e={};r.r(e),r.d(e,{GLTFValidation:()=>p});var t={};r.r(t),r.d(t,{GLTFFileLoader:()=>m,GLTFLoaderAnimationStartMode:()=>f,GLTFLoaderCoordinateSystemMode:()=>d,GLTFLoaderState:()=>h});var n={};r.r(n),r.d(n,{EXT_lights_image_based:()=>R,EXT_mesh_gpu_instancing:()=>I,EXT_meshopt_compression:()=>F,EXT_texture_webp:()=>D,ExtrasAsMetadata:()=>Ye,KHR_animation_pointer:()=>Be,KHR_draco_mesh_compression:()=>k,KHR_lights:()=>U,KHR_materials_anisotropy:()=>Q,KHR_materials_clearcoat:()=>W,KHR_materials_emissive_strength:()=>$,KHR_materials_ior:()=>ae,KHR_materials_iridescence:()=>z,KHR_materials_pbrSpecularGlossiness:()=>H,KHR_materials_sheen:()=>te,KHR_materials_specular:()=>re,KHR_materials_translucency:()=>fe,KHR_materials_transmission:()=>ue,KHR_materials_unlit:()=>q,KHR_materials_variants:()=>se,KHR_materials_volume:()=>pe,KHR_mesh_quantization:()=>me,KHR_texture_basisu:()=>be,KHR_texture_transform:()=>ve,KHR_xmp_json_ld:()=>Te,MSFT_audio_emitter:()=>Ve,MSFT_lod:()=>Ge,MSFT_minecraftMesh:()=>Ke,MSFT_sRGBFactors:()=>je});var a={};r.r(a);var i={};r.r(i),r.d(i,{ArrayItem:()=>L,EXT_lights_image_based:()=>R,EXT_mesh_gpu_instancing:()=>I,EXT_meshopt_compression:()=>F,EXT_texture_webp:()=>D,ExtrasAsMetadata:()=>Ye,GLTFLoader:()=>C,KHR_animation_pointer:()=>Be,KHR_draco_mesh_compression:()=>k,KHR_lights:()=>U,KHR_materials_anisotropy:()=>Q,KHR_materials_clearcoat:()=>W,KHR_materials_emissive_strength:()=>$,KHR_materials_ior:()=>ae,KHR_materials_iridescence:()=>z,KHR_materials_pbrSpecularGlossiness:()=>H,KHR_materials_sheen:()=>te,KHR_materials_specular:()=>re,KHR_materials_translucency:()=>fe,KHR_materials_transmission:()=>ue,KHR_materials_unlit:()=>q,KHR_materials_variants:()=>se,KHR_materials_volume:()=>pe,KHR_mesh_quantization:()=>me,KHR_texture_basisu:()=>be,KHR_texture_transform:()=>ve,KHR_xmp_json_ld:()=>Te,MSFT_audio_emitter:()=>Ve,MSFT_lod:()=>Ge,MSFT_minecraftMesh:()=>Ke,MSFT_sRGBFactors:()=>je});var s={};r.r(s),r.d(s,{GLTF2:()=>i,GLTFFileLoader:()=>m,GLTFLoaderAnimationStartMode:()=>f,GLTFLoaderCoordinateSystemMode:()=>d,GLTFLoaderState:()=>h,GLTFValidation:()=>p});var l=r(520);function c(e,t,n,r){var o={externalResourceFunction:function(e){return r(e).then((function(e){return new Uint8Array(e)}))}};return n&&(o.uri="file:"===t?n:t+n),e instanceof ArrayBuffer?GLTFValidator.validateBytes(new Uint8Array(e),o):GLTFValidator.validateString(e,o)}function u(){var e=[];onmessage=function(t){var n=t.data;switch(n.id){case"init":importScripts(n.url);break;case"validate":c(n.data,n.rootUrl,n.fileName,(function(t){return new Promise((function(n,r){var o=e.length;e.push({resolve:n,reject:r}),postMessage({id:"getExternalResource",index:o,uri:t})}))})).then((function(e){postMessage({id:"validate.resolve",value:e})}),(function(e){postMessage({id:"validate.reject",reason:e})}));break;case"getExternalResource.resolve":e[n.index].resolve(n.value);break;case"getExternalResource.reject":e[n.index].reject(n.reason)}}}var d,f,h,p=function(){function e(){}return e.ValidateAsync=function(e,t,n,r){var o=this,a=ArrayBuffer.isView(e)?e.slice().buffer:e;return"function"==typeof Worker?new Promise((function(e,i){var s="".concat(c,"(").concat(u,")()"),l=URL.createObjectURL(new Blob([s],{type:"application/javascript"})),d=new Worker(l),f=function(e){d.removeEventListener("error",f),d.removeEventListener("message",h),i(e)},h=function(t){var n=t.data;switch(n.id){case"getExternalResource":r(n.uri).then((function(e){d.postMessage({id:"getExternalResource.resolve",index:n.index,value:e},[e])}),(function(e){d.postMessage({id:"getExternalResource.reject",index:n.index,reason:e})}));break;case"validate.resolve":d.removeEventListener("error",f),d.removeEventListener("message",h),e(n.value),d.terminate();break;case"validate.reject":d.removeEventListener("error",f),d.removeEventListener("message",h),i(n.reason),d.terminate()}};d.addEventListener("error",f),d.addEventListener("message",h),d.postMessage({id:"init",url:o.Configuration.url}),d.postMessage({id:"validate",data:a,rootUrl:t,fileName:n})})):(this._LoadScriptPromise||(this._LoadScriptPromise=l.Tools.LoadScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then((function(){return c(a,t,n,r)})))},e.Configuration={url:"https://preview.babylonjs.com/gltf_validator.js"},e}();function _(e,t,n){try{return Promise.resolve(new Uint8Array(e,t,n))}catch(e){return Promise.reject(e)}}!function(e){e[e.AUTO=0]="AUTO",e[e.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"}(d||(d={})),function(e){e[e.NONE=0]="NONE",e[e.FIRST=1]="FIRST",e[e.ALL=2]="ALL"}(f||(f={})),function(e){e[e.LOADING=0]="LOADING",e[e.READY=1]="READY",e[e.COMPLETE=2]="COMPLETE"}(h||(h={}));var m=function(){function e(){this.onParsedObservable=new l.Observable,this.coordinateSystemMode=d.AUTO,this.animationStartMode=f.FIRST,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.transparencyAsCoverage=!1,this.useRangeRequests=!1,this.createInstances=!0,this.alwaysComputeBoundingBox=!1,this.loadAllMaterials=!1,this.loadOnlyMaterials=!1,this.skipMaterials=!1,this.useSRGBBuffers=!0,this.targetFps=60,this.alwaysComputeSkeletonRootNode=!1,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable=new l.Observable,this.onSkinLoadedObservable=new l.Observable,this.onTextureLoadedObservable=new l.Observable,this.onMaterialLoadedObservable=new l.Observable,this.onCameraLoadedObservable=new l.Observable,this.onCompleteObservable=new l.Observable,this.onErrorObservable=new l.Observable,this.onDisposeObservable=new l.Observable,this.onExtensionLoadedObservable=new l.Observable,this.validate=!1,this.onValidatedObservable=new l.Observable,this._loader=null,this._state=null,this._requests=new Array,this.name="gltf",this.extensions={".gltf":{isBinary:!1},".glb":{isBinary:!0}},this.onLoaderStateChangedObservable=new l.Observable,this._logIndentLevel=0,this._loggingEnabled=!1,this._log=this._logDisabled,this._capturePerformanceCounters=!1,this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled}return Object.defineProperty(e.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),this._onParsedObserver=this.onParsedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loggingEnabled",{get:function(){return this._loggingEnabled},set:function(e){this._loggingEnabled!==e&&(this._loggingEnabled=e,this._loggingEnabled?this._log=this._logEnabled:this._log=this._logDisabled)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"capturePerformanceCounters",{get:function(){return this._capturePerformanceCounters},set:function(e){this._capturePerformanceCounters!==e&&(this._capturePerformanceCounters=e,this._capturePerformanceCounters?(this._startPerformanceCounter=this._startPerformanceCounterEnabled,this._endPerformanceCounter=this._endPerformanceCounterEnabled):(this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null);for(var e=0,t=this._requests;ee.byteLength)throw new Error("Array length out of bounds.");return Promise.resolve(new Uint8Array(e.buffer,e.byteOffset+t,n))}catch(e){return Promise.reject(e)}}(t,e,n)},byteLength:t.byteLength})).then((function(e){r(e)}),o?function(e){return o(void 0,e)}:void 0)},e.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return Promise.resolve().then((function(){return i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading ".concat(a||"")),i._loader=i._getLoader(n),i._loader.importMeshAsync(e,t,null,n,r,o,a)}))},e.prototype.loadAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){return a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t),a._loader.loadAsync(e,t,n,r,o)}))},e.prototype.loadAssetContainerAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t);var i=new l.AssetContainer(e),s=[];a.onMaterialLoadedObservable.add((function(e){s.push(e)}));var c=[];a.onTextureLoadedObservable.add((function(e){c.push(e)}));var u=[];a.onCameraLoadedObservable.add((function(e){u.push(e)}));var d=[];return a.onMeshLoadedObservable.add((function(e){e.morphTargetManager&&d.push(e.morphTargetManager)})),a._loader.importMeshAsync(null,e,i,t,n,r,o).then((function(e){return Array.prototype.push.apply(i.geometries,e.geometries),Array.prototype.push.apply(i.meshes,e.meshes),Array.prototype.push.apply(i.particleSystems,e.particleSystems),Array.prototype.push.apply(i.skeletons,e.skeletons),Array.prototype.push.apply(i.animationGroups,e.animationGroups),Array.prototype.push.apply(i.materials,s),Array.prototype.push.apply(i.textures,c),Array.prototype.push.apply(i.lights,e.lights),Array.prototype.push.apply(i.transformNodes,e.transformNodes),Array.prototype.push.apply(i.cameras,u),Array.prototype.push.apply(i.morphTargetManagers,d),i}))}))},e.prototype.canDirectLoad=function(t){return-1!==t.indexOf("asset")&&-1!==t.indexOf("version")||t.startsWith("data:base64,"+e._MagicBase64Encoded)||t.startsWith("data:;base64,"+e._MagicBase64Encoded)||t.startsWith("data:application/octet-stream;base64,"+e._MagicBase64Encoded)||t.startsWith("data:model/gltf-binary;base64,"+e._MagicBase64Encoded)},e.prototype.directLoad=function(t,n){if(n.startsWith("base64,"+e._MagicBase64Encoded)||n.startsWith(";base64,"+e._MagicBase64Encoded)||n.startsWith("application/octet-stream;base64,"+e._MagicBase64Encoded)||n.startsWith("model/gltf-binary;base64,"+e._MagicBase64Encoded)){var r=(0,l.DecodeBase64UrlToBinary)(n);return this._validate(t,new Uint8Array(r)),this._unpackBinaryAsync(new l.DataReader({readAsync:function(e,t){return _(r,e,t)},byteLength:r.byteLength}))}return this._validate(t,n),Promise.resolve({json:this._parseJson(n)})},e.prototype.createPlugin=function(){return new e},Object.defineProperty(e.prototype,"loaderState",{get:function(){return this._state},enumerable:!1,configurable:!0}),e.prototype.whenCompleteAsync=function(){var e=this;return new Promise((function(t,n){e.onCompleteObservable.addOnce((function(){t()})),e.onErrorObservable.addOnce((function(e){n(e)}))}))},e.prototype._setState=function(e){this._state!==e&&(this._state=e,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(h[this._state]))},e.prototype._loadFile=function(e,t,n,r,o,a){var i=this,s=e._loadFile(t,n,(function(e){i._onProgress(e,s)}),!0,r,o,a);return s.onCompleteObservable.add((function(e){i._requests.splice(i._requests.indexOf(e),1)})),this._requests.push(s),s},e.prototype._onProgress=function(e,t){if(this._progressCallback){t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;for(var n=!0,r=0,o=0,a=0,i=this._requests;a0)throw new Error("Incompatible minimum version: "+n.minVersion)}var a={1:e._CreateGLTF1Loader,2:e._CreateGLTF2Loader}[r.major];if(!a)throw new Error("Unsupported version: "+n.version);return a(this)},e.prototype._parseJson=function(e){this._startPerformanceCounter("Parse JSON"),this._log("JSON length: ".concat(e.length));var t=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),t},e.prototype._unpackBinaryAsync=function(e){var t=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then((function(){var n=e.readUint32();if(1179937895!==n)throw new l.RuntimeError("Unexpected magic: "+n,l.ErrorCodes.GLTFLoaderUnexpectedMagicError);var r=e.readUint32();t.loggingEnabled&&t._log("Binary version: ".concat(r));var o,a=e.readUint32();switch(t.useRangeRequests||a===e.buffer.byteLength||l.Logger.Warn("Length in header does not match actual data length: ".concat(a," != ").concat(e.buffer.byteLength)),r){case 1:o=t._unpackBinaryV1Async(e,a);break;case 2:o=t._unpackBinaryV2Async(e,a);break;default:throw new Error("Unsupported version: "+r)}return t._endPerformanceCounter("Unpack Binary"),o}))},e.prototype._unpackBinaryV1Async=function(e,t){var n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error("Unexpected content format: ".concat(r));var o=t-e.byteOffset,a={json:this._parseJson(e.readString(n)),bin:null};if(0!==o){var i=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(i+t,n)},byteLength:o}}return Promise.resolve(a)},e.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,o=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+o===t?e.loadAsync(o).then((function(){return{json:n._parseJson(e.readString(o)),bin:null}})):e.loadAsync(o+8).then((function(){var a={json:n._parseJson(e.readString(o)),bin:null},i=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case 5130562:var o=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(o+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(i):Promise.resolve(a)};return i()}))},e._parseVersion=function(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};var t=(e+"").match(/^(\d+)\.(\d+)/);return t?{major:parseInt(t[1]),minor:parseInt(t[2])}:null},e._compareVersion=function(e,t){return e.major>t.major?1:e.majort.minor?1:e.minor ").concat(h[h.READY]),i="".concat(h[h.LOADING]," => ").concat(h[h.COMPLETE]);o._parent._startPerformanceCounter(a),o._parent._startPerformanceCounter(i),o._parent._setState(h.LOADING),o._extensionsOnLoading();var s=new Array,c=o._babylonScene.blockMaterialDirtyMechanism;if(o._babylonScene.blockMaterialDirtyMechanism=!0,!o.parent.loadOnlyMaterials)if(n)s.push(o.loadSceneAsync("/nodes",{nodes:n,index:-1}));else if(null!=o._gltf.scene||o._gltf.scenes&&o._gltf.scenes[0]){var u=L.Get("/scene",o._gltf.scenes,o._gltf.scene||0);s.push(o.loadSceneAsync("/scenes/".concat(u.index),u))}if(!o.parent.skipMaterials&&o.parent.loadAllMaterials&&o._gltf.materials)for(var d=0;de.bin.byteLength)&&l.Logger.Warn("Binary buffer length (".concat(n.byteLength,") from JSON does not match chunk length (").concat(e.bin.byteLength,")")),this._bin=e.bin}else l.Logger.Warn("Unexpected BIN chunk")}},e.prototype._setupData=function(){if(L.Assign(this._gltf.accessors),L.Assign(this._gltf.animations),L.Assign(this._gltf.buffers),L.Assign(this._gltf.bufferViews),L.Assign(this._gltf.cameras),L.Assign(this._gltf.images),L.Assign(this._gltf.materials),L.Assign(this._gltf.meshes),L.Assign(this._gltf.nodes),L.Assign(this._gltf.samplers),L.Assign(this._gltf.scenes),L.Assign(this._gltf.skins),L.Assign(this._gltf.textures),this._gltf.nodes){for(var e={},t=0,n=this._gltf.nodes;t=(i=n[t[0]]).length)return l;s=i[c];for(var u=1;u=(i=n[t[u]]).length||s!==i[c])return l;l=s}},e.prototype._loadBone=function(e,t,n,r){var o=r[e.index];if(o)return o;var a=null;e.index!==t.skeleton&&(e.parent&&-1!==e.parent.index?a=this._loadBone(e.parent,t,n,r):void 0!==t.skeleton&&l.Logger.Warn("/skins/".concat(t.index,"/skeleton: Skeleton node is not a common root")));var i=t.joints.indexOf(e.index);return o=new l.Bone(e.name||"joint".concat(e.index),n,a,this._getNodeMatrix(e),null,null,i),r[e.index]=o,this._postSceneLoadActions.push((function(){o.linkTransformNode(e._babylonTransformNode)})),o},e.prototype._loadSkinInverseBindMatricesDataAsync=function(e,t){if(null==t.inverseBindMatrices)return Promise.resolve(null);var n=L.Get("".concat(e,"/inverseBindMatrices"),this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync("/accessors/".concat(n.index),n)},e.prototype._updateBoneMatrices=function(e,t){for(var n=0,r=e.bones;n0){var A="".concat(n.name||"animation".concat(n.index),"_channel").concat(r.index,"_").concat(t);d.buildAnimations(o.target,A,i,_,(function(e,n){++t,a(e,n)}))}}}))},e.prototype._loadAnimationSamplerAsync=function(e,t){if(t._data)return t._data;var n=t.interpolation||"LINEAR";switch(n){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error("".concat(e,"/interpolation: Invalid value (").concat(t.interpolation,")"))}var r=L.Get("".concat(e,"/input"),this._gltf.accessors,t.input),o=L.Get("".concat(e,"/output"),this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync("/accessors/".concat(r.index),r),this._loadFloatAccessorAsync("/accessors/".concat(o.index),o)]).then((function(e){var t=e[0],r=e[1];return{input:t,interpolation:n,output:r}})),t._data},e.prototype.loadBufferAsync=function(e,t,n,r){var o=this._extensionsLoadBufferAsync(e,t,n,r);if(o)return o;if(!t._data)if(t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{if(!this._bin)throw new Error("".concat(e,": Uri is missing or the binary glTF is missing its binary chunk"));t._data=this._bin.readAsync(0,t.byteLength)}return t._data.then((function(t){try{return new Uint8Array(t.buffer,t.byteOffset+n,r)}catch(t){throw new Error("".concat(e,": ").concat(t.message))}}))},e.prototype.loadBufferViewAsync=function(e,t){var n=this._extensionsLoadBufferViewAsync(e,t);if(n)return n;if(t._data)return t._data;var r=L.Get("".concat(e,"/buffer"),this._gltf.buffers,t.buffer);return t._data=this.loadBufferAsync("/buffers/".concat(r.index),r,t.byteOffset||0,t.byteLength),t._data},e.prototype._loadAccessorAsync=function(t,n,r){var o=this;if(n._data)return n._data;var a=e._GetNumComponents(t,n.type),i=a*l.VertexBuffer.GetTypeByteLength(n.componentType),s=a*n.count;if(null==n.bufferView)n._data=Promise.resolve(new r(s));else{var c=L.Get("".concat(t,"/bufferView"),this._gltf.bufferViews,n.bufferView);n._data=this.loadBufferViewAsync("/bufferViews/".concat(c.index),c).then((function(o){if(5126!==n.componentType||n.normalized||c.byteStride&&c.byteStride!==i){var u=new r(s);return l.VertexBuffer.ForEach(o,n.byteOffset||0,c.byteStride||i,a,n.componentType,u.length,n.normalized||!1,(function(e,t){u[t]=e})),u}return e._GetTypedArray(t,n.componentType,o,n.byteOffset,s)}))}if(n.sparse){var u=n.sparse;n._data=n._data.then((function(s){var c=s,d=L.Get("".concat(t,"/sparse/indices/bufferView"),o._gltf.bufferViews,u.indices.bufferView),f=L.Get("".concat(t,"/sparse/values/bufferView"),o._gltf.bufferViews,u.values.bufferView);return Promise.all([o.loadBufferViewAsync("/bufferViews/".concat(d.index),d),o.loadBufferViewAsync("/bufferViews/".concat(f.index),f)]).then((function(o){var s,d=o[0],f=o[1],h=e._GetTypedArray("".concat(t,"/sparse/indices"),u.indices.componentType,d,u.indices.byteOffset,u.count),p=a*u.count;if(5126!==n.componentType||n.normalized){var _=e._GetTypedArray("".concat(t,"/sparse/values"),n.componentType,f,u.values.byteOffset,p);s=new r(p),l.VertexBuffer.ForEach(_,0,i,a,n.componentType,s.length,n.normalized||!1,(function(e,t){s[t]=e}))}else s=e._GetTypedArray("".concat(t,"/sparse/values"),n.componentType,f,u.values.byteOffset,p);for(var m=0,y=0;y=6)throw new Error("".concat(t,"/texCoord: Invalid value (").concat(n.texCoord,")"));var i=L.Get("".concat(t,"/index"),this._gltf.textures,n.index);i._textureInfo=n;var s=this._loadTextureAsync("/textures/".concat(n.index),i,(function(a){a.coordinatesIndex=n.texCoord||0,e.AddPointerMetadata(a,t),o._parent.onTextureLoadedObservable.notifyObservers(a),r(a)}));return this.logClose(),s},e.prototype._loadTextureAsync=function(t,n,r){void 0===r&&(r=function(){});var o=this._extensionsLoadTextureAsync(t,n,r);if(o)return o;this.logOpen("".concat(t," ").concat(n.name||""));var a=null==n.sampler?e.DefaultSampler:L.Get("".concat(t,"/sampler"),this._gltf.samplers,n.sampler),i=L.Get("".concat(t,"/source"),this._gltf.images,n.source),s=this._createTextureAsync(t,a,i,r,void 0,!n._textureInfo.nonColorData);return this.logClose(),s},e.prototype._createTextureAsync=function(e,t,n,r,o,a){var i=this;void 0===r&&(r=function(){});var s=this._loadSampler("/samplers/".concat(t.index),t),c=new Array,u=new l.Deferred;this._babylonScene._blockEntityCollection=!!this._assetContainer;var d={noMipmap:s.noMipMaps,invertY:!1,samplingMode:s.samplingMode,onLoad:function(){i._disposed||u.resolve()},onError:function(t,n){i._disposed||u.reject(new Error("".concat(e,": ").concat(n&&n.message?n.message:t||"Failed to load texture")))},mimeType:n.mimeType,loaderOptions:o,useSRGBBuffer:!!a&&this._parent.useSRGBBuffers},f=new l.Texture(null,this._babylonScene,d);return f._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,c.push(u.promise),c.push(this.loadImageAsync("/images/".concat(n.index),n).then((function(e){var t=n.uri||"".concat(i._fileName,"#image").concat(n.index),r="data:".concat(i._uniqueRootUrl).concat(t);f.updateURL(r,e)}))),f.wrapU=s.wrapU,f.wrapV=s.wrapV,r(f),Promise.all(c).then((function(){return f}))},e.prototype._loadSampler=function(t,n){return n._data||(n._data={noMipMaps:9728===n.minFilter||9729===n.minFilter,samplingMode:e._GetTextureSamplingMode(t,n),wrapU:e._GetTextureWrapMode("".concat(t,"/wrapS"),n.wrapS),wrapV:e._GetTextureWrapMode("".concat(t,"/wrapT"),n.wrapT)}),n._data},e.prototype.loadImageAsync=function(e,t){if(!t._data){if(this.logOpen("".concat(e," ").concat(t.name||"")),t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{var n=L.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/".concat(n.index),n)}this.logClose()}return t._data},e.prototype.loadUriAsync=function(t,n,r){var o=this,a=this._extensionsLoadUriAsync(t,n,r);if(a)return a;if(!e._ValidateUri(r))throw new Error("".concat(t,": '").concat(r,"' is invalid"));if((0,l.IsBase64DataUrl)(r)){var i=new Uint8Array((0,l.DecodeBase64UrlToBinary)(r));return this.log("".concat(t,": Decoded ").concat(r.substr(0,64),"... (").concat(i.length," bytes)")),Promise.resolve(i)}return this.log("".concat(t,": Loading ").concat(r)),this._parent.preprocessUrlAsync(this._rootUrl+r).then((function(e){return new Promise((function(n,a){o._parent._loadFile(o._babylonScene,e,(function(e){o._disposed||(o.log("".concat(t,": Loaded ").concat(r," (").concat(e.byteLength," bytes)")),n(new Uint8Array(e)))}),!0,(function(e){a(new l.LoadFileError("".concat(t,": Failed to load '").concat(r,"'").concat(e?": "+e.status+" "+e.statusText:""),e))}))}))}))},e.AddPointerMetadata=function(e,t){e.metadata=e.metadata||{};var n=e._internalMetadata=e._internalMetadata||{},r=n.gltf=n.gltf||{};(r.pointers=r.pointers||[]).push(t)},e._GetTextureWrapMode=function(e,t){switch(t=null==t?10497:t){case 33071:return l.Texture.CLAMP_ADDRESSMODE;case 33648:return l.Texture.MIRROR_ADDRESSMODE;case 10497:return l.Texture.WRAP_ADDRESSMODE;default:return l.Logger.Warn("".concat(e,": Invalid value (").concat(t,")")),l.Texture.WRAP_ADDRESSMODE}},e._GetTextureSamplingMode=function(e,t){var n=null==t.magFilter?9729:t.magFilter,r=null==t.minFilter?9987:t.minFilter;if(9729===n)switch(r){case 9728:return l.Texture.LINEAR_NEAREST;case 9729:return l.Texture.LINEAR_LINEAR;case 9984:return l.Texture.LINEAR_NEAREST_MIPNEAREST;case 9985:return l.Texture.LINEAR_LINEAR_MIPNEAREST;case 9986:return l.Texture.LINEAR_NEAREST_MIPLINEAR;case 9987:return l.Texture.LINEAR_LINEAR_MIPLINEAR;default:return l.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(r,")")),l.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==n&&l.Logger.Warn("".concat(e,"/magFilter: Invalid value (").concat(n,")")),r){case 9728:return l.Texture.NEAREST_NEAREST;case 9729:return l.Texture.NEAREST_LINEAR;case 9984:return l.Texture.NEAREST_NEAREST_MIPNEAREST;case 9985:return l.Texture.NEAREST_LINEAR_MIPNEAREST;case 9986:return l.Texture.NEAREST_NEAREST_MIPLINEAR;case 9987:return l.Texture.NEAREST_LINEAR_MIPLINEAR;default:return l.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(r,")")),l.Texture.NEAREST_NEAREST_MIPNEAREST}},e._GetTypedArrayConstructor=function(e,t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5125:return Uint32Array;case 5126:return Float32Array;default:throw new Error("".concat(e,": Invalid component type ").concat(t))}},e._GetTypedArray=function(t,n,r,o,a){var i=r.buffer;o=r.byteOffset+(o||0);var s=e._GetTypedArrayConstructor("".concat(t,"/componentType"),n),c=l.VertexBuffer.GetTypeByteLength(n);return o%c!=0?(l.Logger.Warn("".concat(t,": Copying buffer as byte offset (").concat(o,") is not a multiple of component type byte length (").concat(c,")")),new s(i.slice(o,o+a*c),0)):new s(i,o,a)},e._GetNumComponents=function(e,t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16}throw new Error("".concat(e,": Invalid type (").concat(t,")"))},e._ValidateUri=function(e){return l.Tools.IsBase64(e)||-1===e.indexOf("..")},e._GetDrawMode=function(e,t){switch(null==t&&(t=4),t){case 0:return l.Material.PointListDrawMode;case 1:return l.Material.LineListDrawMode;case 2:return l.Material.LineLoopDrawMode;case 3:return l.Material.LineStripDrawMode;case 4:return l.Material.TriangleFillMode;case 5:return l.Material.TriangleStripDrawMode;case 6:return l.Material.TriangleFanDrawMode}throw new Error("".concat(e,": Invalid mesh primitive mode (").concat(t,")"))},e.prototype._compileMaterialsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile materials");var t=new Array;if(this._gltf.materials)for(var n=0,r=this._gltf.materials;n=0;a--)if(o.push(L.Get("".concat(e,"/ids/").concat(r[a]),n,r[a])),o.length===this.maxLODsToLoad)return o;return o.push(t),o},e.prototype._disposeTransformNode=function(e){var t=this,n=new Array,r=e.material;r&&n.push(r);for(var o=0,a=e.getChildMeshes();o0){var n=e.metadata=e.metadata||{};(n.gltf=n.gltf||{}).extras=t.extras}},e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,t,n){var r=this;return this._loader.loadNodeAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.loadCameraAsync=function(e,t,n){var r=this;return this._loader.loadCameraAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.createMaterial=function(e,t,n){var r=this._loader.createMaterial(e,t,n);return this._assignExtras(r,t),r},e}();C.RegisterExtension(qe,(function(e){return new Ye(e)}));var We=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==We){We.BABYLON=We.BABYLON||{};var Xe=We.BABYLON;Xe.GLTF2=Xe.GLTF2||{},Xe.GLTF2.Loader=Xe.GLTF2.Loader||{},Xe.GLTF2.Loader.Extensions=Xe.GLTF2.Loader.Extensions||{};var ze=[];for(var Je in n)Xe.GLTF2.Loader.Extensions[Je]=n[Je],ze.push(Je);for(var Je in a)Xe.GLTF2.Loader[Je]=a[Je],ze.push(Je);for(var Je in i)ze.indexOf(Je)>-1||(Xe.GLTF2[Je]=i[Je])}const Qe=s})(),o.default})())); +//# sourceMappingURL=babylon.glTF2FileLoader.min.js.map \ No newline at end of file diff --git a/libs/babylonjs/6.23.0/babylon.glTF2Serializer.js b/libs/babylonjs/6.23.0/babylon.glTF2Serializer.js new file mode 100644 index 00000000..094642e8 --- /dev/null +++ b/libs/babylonjs/6.23.0/babylon.glTF2Serializer.js @@ -0,0 +1,6170 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("babylonjs")); + else if(typeof define === 'function' && define.amd) + define("babylonjs-serializers", ["babylonjs"], factory); + else if(typeof exports === 'object') + exports["babylonjs-serializers"] = factory(require("babylonjs")); + else + root["SERIALIZERS"] = factory(root["BABYLON"]); +})((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), (__WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math_vector__) => { +return /******/ (() => { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts": +/*!***********************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts ***! + \***********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* binding */ EXT_mesh_gpu_instancing) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Buffers/buffer */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__); + + + + + +var NAME = "EXT_mesh_gpu_instancing"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_mesh_gpu_instancing/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var EXT_mesh_gpu_instancing = /** @class */ (function () { + function EXT_mesh_gpu_instancing(exporter) { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + this._exporter = exporter; + } + EXT_mesh_gpu_instancing.prototype.dispose = function () { }; + Object.defineProperty(EXT_mesh_gpu_instancing.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + EXT_mesh_gpu_instancing.prototype.postExportNodeAsync = function (context, node, babylonNode, nodeMap, binaryWriter) { + var _this = this; + return new Promise(function (resolve) { + if (node && babylonNode instanceof babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.Mesh) { + if (babylonNode.hasThinInstances && binaryWriter) { + _this._wasUsed = true; + var noTranslation = babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(); + var noRotation = babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.Quaternion.Identity(); + var noScale = babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.Vector3.One(); + // retrieve all the instance world matrix + var matrix = babylonNode.thinInstanceGetWorldMatrices(); + var iwt = babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.TmpVectors.Vector3[2]; + var iwr = babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.TmpVectors.Quaternion[1]; + var iws = babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.TmpVectors.Vector3[3]; + var hasAnyInstanceWorldTranslation = false; + var hasAnyInstanceWorldRotation = false; + var hasAnyInstanceWorldScale = false; + // prepare temp buffers + var translationBuffer = new Float32Array(babylonNode.thinInstanceCount * 3); + var rotationBuffer = new Float32Array(babylonNode.thinInstanceCount * 4); + var scaleBuffer = new Float32Array(babylonNode.thinInstanceCount * 3); + var i = 0; + for (var _i = 0, matrix_1 = matrix; _i < matrix_1.length; _i++) { + var m = matrix_1[_i]; + m.decompose(iws, iwr, iwt); + // fill the temp buffer + translationBuffer.set(iwt.asArray(), i * 3); + rotationBuffer.set(iwr.normalize().asArray(), i * 4); // ensure the quaternion is normalized + scaleBuffer.set(iws.asArray(), i * 3); + // this is where we decide if there is any transformation + hasAnyInstanceWorldTranslation = hasAnyInstanceWorldTranslation || !iwt.equalsWithEpsilon(noTranslation); + hasAnyInstanceWorldRotation = hasAnyInstanceWorldRotation || !iwr.equalsWithEpsilon(noRotation); + hasAnyInstanceWorldScale = hasAnyInstanceWorldScale || !iws.equalsWithEpsilon(noScale); + i++; + } + var extension = { + attributes: {}, + }; + // do we need to write TRANSLATION ? + if (hasAnyInstanceWorldTranslation) { + extension.attributes["TRANSLATION"] = _this._buildAccessor(translationBuffer, "VEC3" /* AccessorType.VEC3 */, babylonNode.thinInstanceCount, binaryWriter, 5126 /* AccessorComponentType.FLOAT */); + } + // do we need to write ROTATION ? + if (hasAnyInstanceWorldRotation) { + var componentType = 5126 /* AccessorComponentType.FLOAT */; // we decided to stay on FLOAT for now see https://github.com/BabylonJS/Babylon.js/pull/12495 + extension.attributes["ROTATION"] = _this._buildAccessor(rotationBuffer, "VEC4" /* AccessorType.VEC4 */, babylonNode.thinInstanceCount, binaryWriter, componentType); + } + // do we need to write SCALE ? + if (hasAnyInstanceWorldScale) { + extension.attributes["SCALE"] = _this._buildAccessor(scaleBuffer, "VEC3" /* AccessorType.VEC3 */, babylonNode.thinInstanceCount, binaryWriter, 5126 /* AccessorComponentType.FLOAT */); + } + /* eslint-enable @typescript-eslint/naming-convention*/ + node.extensions = node.extensions || {}; + node.extensions[NAME] = extension; + } + } + resolve(node); + }); + }; + EXT_mesh_gpu_instancing.prototype._buildAccessor = function (buffer, type, count, binaryWriter, componentType) { + // write the buffer + var bufferOffset = binaryWriter.getByteOffset(); + switch (componentType) { + case 5126 /* AccessorComponentType.FLOAT */: { + for (var i = 0; i != buffer.length; i++) { + binaryWriter.setFloat32(buffer[i]); + } + break; + } + case 5120 /* AccessorComponentType.BYTE */: { + for (var i = 0; i != buffer.length; i++) { + binaryWriter.setByte(buffer[i] * 127); + } + break; + } + case 5122 /* AccessorComponentType.SHORT */: { + for (var i = 0; i != buffer.length; i++) { + binaryWriter.setInt16(buffer[i] * 32767); + } + break; + } + } + // build the buffer view + var bv = { buffer: 0, byteOffset: bufferOffset, byteLength: buffer.length * babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.VertexBuffer.GetTypeByteLength(componentType) }; + var bufferViewIndex = this._exporter._bufferViews.length; + this._exporter._bufferViews.push(bv); + // finally build the accessor + var accessorIndex = this._exporter._accessors.length; + var accessor = { + bufferView: bufferViewIndex, + componentType: componentType, + count: count, + type: type, + normalized: componentType == 5120 /* AccessorComponentType.BYTE */ || componentType == 5122 /* AccessorComponentType.SHORT */, + }; + this._exporter._accessors.push(accessor); + return accessorIndex; + }; + return EXT_mesh_gpu_instancing; +}()); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new EXT_mesh_gpu_instancing(exporter); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_lights_punctual.ts": +/*!*******************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_lights_punctual.ts ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_lights_punctual: () => (/* binding */ KHR_lights_punctual) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); + + + + + + +var NAME = "KHR_lights_punctual"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_lights_punctual = /** @class */ (function () { + /** + * @internal + */ + function KHR_lights_punctual(exporter) { + /** The name of this extension. */ + this.name = NAME; + /** Defines whether this extension is enabled. */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._exporter = exporter; + } + /** @internal */ + KHR_lights_punctual.prototype.dispose = function () { + this._lights = null; + }; + Object.defineProperty(KHR_lights_punctual.prototype, "wasUsed", { + /** @internal */ + get: function () { + return !!this._lights; + }, + enumerable: false, + configurable: true + }); + /** @internal */ + KHR_lights_punctual.prototype.onExporting = function () { + this._exporter._glTF.extensions[NAME] = this._lights; + }; + /** + * Define this method to modify the default behavior when exporting a node + * @param context The context when exporting the node + * @param node glTF node + * @param babylonNode BabylonJS node + * @param nodeMap Node mapping of unique id to glTF node index + * @returns nullable INode promise + */ + KHR_lights_punctual.prototype.postExportNodeAsync = function (context, node, babylonNode, nodeMap) { + var _this = this; + return new Promise(function (resolve) { + if (node && babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.ShadowLight) { + var light = void 0; + var lightType = babylonNode.getTypeID() == babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Light.LIGHTTYPEID_POINTLIGHT + ? "point" /* KHRLightsPunctual_LightType.POINT */ + : babylonNode.getTypeID() == babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Light.LIGHTTYPEID_DIRECTIONALLIGHT + ? "directional" /* KHRLightsPunctual_LightType.DIRECTIONAL */ + : babylonNode.getTypeID() == babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Light.LIGHTTYPEID_SPOTLIGHT + ? "spot" /* KHRLightsPunctual_LightType.SPOT */ + : null; + if (lightType == null) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Light ").concat(babylonNode.name, " is not supported in ").concat(NAME)); + } + else { + if (!babylonNode.position.equalsToFloats(0, 0, 0)) { + node.translation = babylonNode.position.asArray(); + } + if (lightType !== "point" /* KHRLightsPunctual_LightType.POINT */) { + var localAxis = babylonNode.direction; + var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2; + var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z); + var pitch = -Math.atan2(localAxis.y, len); + var lightRotationQuaternion = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.RotationYawPitchRoll(yaw + Math.PI, pitch, 0); + if (!babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.IsIdentity(lightRotationQuaternion)) { + node.rotation = lightRotationQuaternion.asArray(); + } + } + if (babylonNode.falloffType !== babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Light.FALLOFF_GLTF) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Light falloff for ").concat(babylonNode.name, " does not match the ").concat(NAME, " specification!")); + } + light = { + type: lightType, + }; + if (!babylonNode.diffuse.equals(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.White())) { + light.color = babylonNode.diffuse.asArray(); + } + if (babylonNode.intensity !== 1.0) { + light.intensity = babylonNode.intensity; + } + if (babylonNode.range !== Number.MAX_VALUE) { + light.range = babylonNode.range; + } + if (lightType === "spot" /* KHRLightsPunctual_LightType.SPOT */) { + var babylonSpotLight = babylonNode; + if (babylonSpotLight.angle !== Math.PI / 2.0) { + if (light.spot == null) { + light.spot = {}; + } + light.spot.outerConeAngle = babylonSpotLight.angle / 2.0; + } + if (babylonSpotLight.innerAngle !== 0) { + if (light.spot == null) { + light.spot = {}; + } + light.spot.innerConeAngle = babylonSpotLight.innerAngle / 2.0; + } + } + _this._lights || (_this._lights = { + lights: [], + }); + _this._lights.lights.push(light); + var lightReference = { + light: _this._lights.lights.length - 1, + }; + // Avoid duplicating the Light's parent node if possible. + var parentBabylonNode = babylonNode.parent; + if (parentBabylonNode && parentBabylonNode.getChildren().length == 1) { + var parentNode = _this._exporter._nodes[nodeMap[parentBabylonNode.uniqueId]]; + if (parentNode) { + var parentTranslation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(parentNode.translation || [0, 0, 0], 0, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0]); + var parentRotation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArrayToRef(parentNode.rotation || [0, 0, 0, 1], 0, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0]); + var parentScale = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(parentNode.scale || [1, 1, 1], 0, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1]); + var parentMatrix = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Matrix.ComposeToRef(parentScale, parentRotation, parentTranslation, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[0]); + var translation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(node.translation || [0, 0, 0], 0, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[2]); + var rotation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArrayToRef(node.rotation || [0, 0, 0, 1], 0, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[1]); + var matrix = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Matrix.ComposeToRef(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.OneReadOnly, rotation, translation, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[1]); + parentMatrix.multiplyToRef(matrix, matrix); + matrix.decompose(parentScale, parentRotation, parentTranslation); + if (parentTranslation.equalsToFloats(0, 0, 0)) { + delete parentNode.translation; + } + else { + parentNode.translation = parentTranslation.asArray(); + } + if (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.IsIdentity(parentRotation)) { + delete parentNode.rotation; + } + else { + parentNode.rotation = parentRotation.asArray(); + } + if (parentScale.equalsToFloats(1, 1, 1)) { + delete parentNode.scale; + } + else { + parentNode.scale = parentScale.asArray(); + } + parentNode.extensions || (parentNode.extensions = {}); + parentNode.extensions[NAME] = lightReference; + // Do not export the original node + resolve(null); + return; + } + } + node.extensions || (node.extensions = {}); + node.extensions[NAME] = lightReference; + } + } + resolve(node); + }); + }; + return KHR_lights_punctual; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_1__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_lights_punctual(exporter); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts": +/*!************************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts ***! + \************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_anisotropy: () => (/* binding */ KHR_materials_anisotropy) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrBaseMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_anisotropy"; +/** + * @internal + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_anisotropy = /** @class */ (function () { + function KHR_materials_anisotropy(exporter) { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + this._exporter = exporter; + } + KHR_materials_anisotropy.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_anisotropy.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_materials_anisotropy.prototype.postExportMaterialAdditionalTextures = function (context, node, babylonMaterial) { + var additionalTextures = []; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRBaseMaterial) { + if (babylonMaterial.anisotropy.isEnabled && !babylonMaterial.anisotropy.legacy) { + if (babylonMaterial.anisotropy.texture) { + additionalTextures.push(babylonMaterial.anisotropy.texture); + } + return additionalTextures; + } + } + return []; + }; + KHR_materials_anisotropy.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRBaseMaterial) { + if (!babylonMaterial.anisotropy.isEnabled || babylonMaterial.anisotropy.legacy) { + resolve(node); + return; + } + _this._wasUsed = true; + node.extensions = node.extensions || {}; + var anisotropyTextureInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.anisotropy.texture); + var anisotropyInfo_1 = { + anisotropyStrength: babylonMaterial.anisotropy.intensity, + anisotropyRotation: babylonMaterial.anisotropy.angle, + anisotropyTexture: anisotropyTextureInfo !== null && anisotropyTextureInfo !== void 0 ? anisotropyTextureInfo : undefined, + hasTextures: function () { + return anisotropyInfo_1.anisotropyTexture !== null; + }, + }; + node.extensions[NAME] = anisotropyInfo_1; + } + resolve(node); + }); + }; + return KHR_materials_anisotropy; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_anisotropy(exporter); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts": +/*!***********************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts ***! + \***********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_clearcoat: () => (/* binding */ KHR_materials_clearcoat) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__); + + + +var NAME = "KHR_materials_clearcoat"; +/** + * @internal + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_clearcoat = /** @class */ (function () { + function KHR_materials_clearcoat(exporter) { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + this._exporter = exporter; + } + KHR_materials_clearcoat.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_clearcoat.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_materials_clearcoat.prototype.postExportMaterialAdditionalTextures = function (context, node, babylonMaterial) { + var additionalTextures = []; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRBaseMaterial) { + if (babylonMaterial.clearCoat.isEnabled) { + if (babylonMaterial.clearCoat.texture) { + additionalTextures.push(babylonMaterial.clearCoat.texture); + } + if (!babylonMaterial.clearCoat.useRoughnessFromMainTexture && babylonMaterial.clearCoat.textureRoughness) { + additionalTextures.push(babylonMaterial.clearCoat.textureRoughness); + } + if (babylonMaterial.clearCoat.bumpTexture) { + additionalTextures.push(babylonMaterial.clearCoat.bumpTexture); + } + return additionalTextures; + } + } + return []; + }; + KHR_materials_clearcoat.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRBaseMaterial) { + if (!babylonMaterial.clearCoat.isEnabled) { + resolve(node); + return; + } + _this._wasUsed = true; + node.extensions = node.extensions || {}; + var clearCoatTextureInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.texture); + var clearCoatTextureRoughnessInfo = void 0; + if (babylonMaterial.clearCoat.useRoughnessFromMainTexture) { + clearCoatTextureRoughnessInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.texture); + } + else { + clearCoatTextureRoughnessInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.textureRoughness); + } + if (babylonMaterial.clearCoat.isTintEnabled) { + babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Clear Color tint is not supported for glTF export. Ignoring for: ".concat(babylonMaterial.name)); + } + if (babylonMaterial.clearCoat.remapF0OnInterfaceChange) { + babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Clear Color F0 remapping is not supported for glTF export. Ignoring for: ".concat(babylonMaterial.name)); + } + var clearCoatNormalTextureInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.clearCoat.bumpTexture); + var clearCoatInfo_1 = { + clearcoatFactor: babylonMaterial.clearCoat.intensity, + clearcoatTexture: clearCoatTextureInfo !== null && clearCoatTextureInfo !== void 0 ? clearCoatTextureInfo : undefined, + clearcoatRoughnessFactor: babylonMaterial.clearCoat.roughness, + clearcoatRoughnessTexture: clearCoatTextureRoughnessInfo !== null && clearCoatTextureRoughnessInfo !== void 0 ? clearCoatTextureRoughnessInfo : undefined, + clearcoatNormalTexture: clearCoatNormalTextureInfo !== null && clearCoatNormalTextureInfo !== void 0 ? clearCoatNormalTextureInfo : undefined, + hasTextures: function () { + return clearCoatInfo_1.clearcoatTexture !== null || clearCoatInfo_1.clearcoatRoughnessTexture !== null || clearCoatInfo_1.clearcoatRoughnessTexture !== null; + }, + }; + node.extensions[NAME] = clearCoatInfo_1; + } + resolve(node); + }); + }; + return KHR_materials_clearcoat; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_clearcoat(exporter); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts": +/*!*******************************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts ***! + \*******************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_emissive_strength: () => (/* binding */ KHR_materials_emissive_strength) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_emissive_strength"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_emissive_strength = /** @class */ (function () { + function KHR_materials_emissive_strength() { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + } + KHR_materials_emissive_strength.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_emissive_strength.prototype, "wasUsed", { + /** @interal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_materials_emissive_strength.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial)) { + return resolve(node); + } + var emissiveColor = babylonMaterial.emissiveColor.asArray(); + var tempEmissiveStrength = Math.max.apply(Math, emissiveColor); + if (tempEmissiveStrength > 1) { + _this._wasUsed = true; + node.extensions || (node.extensions = {}); + var emissiveStrengthInfo = { + emissiveStrength: tempEmissiveStrength, + }; + // Normalize each value of the emissive factor to have a max value of 1 + var newEmissiveFactor = babylonMaterial.emissiveColor.scale(1 / emissiveStrengthInfo.emissiveStrength); + node.emissiveFactor = newEmissiveFactor.asArray(); + node.extensions[NAME] = emissiveStrengthInfo; + } + return resolve(node); + }); + }; + return KHR_materials_emissive_strength; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_emissive_strength(); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_ior.ts": +/*!*****************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_ior.ts ***! + \*****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_ior: () => (/* binding */ KHR_materials_ior) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_ior"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_ior/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_ior = /** @class */ (function () { + function KHR_materials_ior() { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + } + KHR_materials_ior.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_ior.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_materials_ior.prototype._isExtensionEnabled = function (mat) { + // This extension must not be used on a material that also uses KHR_materials_unlit + if (mat.unlit) { + return false; + } + return mat.indexOfRefraction != undefined && mat.indexOfRefraction != 1.5; // 1.5 is normative default value. + }; + KHR_materials_ior.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial && _this._isExtensionEnabled(babylonMaterial)) { + _this._wasUsed = true; + var iorInfo = { + ior: babylonMaterial.indexOfRefraction, + }; + node.extensions = node.extensions || {}; + node.extensions[NAME] = iorInfo; + } + resolve(node); + }); + }; + return KHR_materials_ior; +}()); + +// eslint-disable-next-line @typescript-eslint/no-unused-vars +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_ior(); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts": +/*!*************************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts ***! + \*************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_iridescence: () => (/* binding */ KHR_materials_iridescence) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrBaseMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_iridescence"; +/** + * @internal + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_iridescence = /** @class */ (function () { + function KHR_materials_iridescence(exporter) { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + this._exporter = exporter; + } + KHR_materials_iridescence.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_iridescence.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_materials_iridescence.prototype.postExportMaterialAdditionalTextures = function (context, node, babylonMaterial) { + var additionalTextures = []; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRBaseMaterial) { + if (babylonMaterial.iridescence.isEnabled) { + if (babylonMaterial.iridescence.texture) { + additionalTextures.push(babylonMaterial.iridescence.texture); + } + if (babylonMaterial.iridescence.thicknessTexture && babylonMaterial.iridescence.thicknessTexture !== babylonMaterial.iridescence.texture) { + additionalTextures.push(babylonMaterial.iridescence.thicknessTexture); + } + return additionalTextures; + } + } + return []; + }; + KHR_materials_iridescence.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRBaseMaterial) { + if (!babylonMaterial.iridescence.isEnabled) { + resolve(node); + return; + } + _this._wasUsed = true; + node.extensions = node.extensions || {}; + var iridescenceTextureInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.iridescence.texture); + var iridescenceThicknessTextureInfo = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.iridescence.thicknessTexture); + var iridescenceInfo_1 = { + iridescenceFactor: babylonMaterial.iridescence.intensity, + iridescenceIor: babylonMaterial.iridescence.indexOfRefraction, + iridescenceThicknessMinimum: babylonMaterial.iridescence.minimumThickness, + iridescenceThicknessMaximum: babylonMaterial.iridescence.maximumThickness, + iridescenceTexture: iridescenceTextureInfo !== null && iridescenceTextureInfo !== void 0 ? iridescenceTextureInfo : undefined, + iridescenceThicknessTexture: iridescenceThicknessTextureInfo !== null && iridescenceThicknessTextureInfo !== void 0 ? iridescenceThicknessTextureInfo : undefined, + hasTextures: function () { + return iridescenceInfo_1.iridescenceTexture !== null || iridescenceInfo_1.iridescenceThicknessTexture !== null; + }, + }; + node.extensions[NAME] = iridescenceInfo_1; + } + resolve(node); + }); + }; + return KHR_materials_iridescence; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_iridescence(exporter); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_sheen.ts": +/*!*******************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_sheen.ts ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_sheen: () => (/* binding */ KHR_materials_sheen) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_sheen"; +/** + * @internal + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_sheen = /** @class */ (function () { + function KHR_materials_sheen(exporter) { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + this._exporter = exporter; + } + KHR_materials_sheen.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_sheen.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_materials_sheen.prototype.postExportMaterialAdditionalTextures = function (context, node, babylonMaterial) { + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial) { + if (babylonMaterial.sheen.isEnabled && babylonMaterial.sheen.texture) { + return [babylonMaterial.sheen.texture]; + } + } + return []; + }; + KHR_materials_sheen.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + var _a, _b, _c, _d; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial) { + if (!babylonMaterial.sheen.isEnabled) { + resolve(node); + return; + } + _this._wasUsed = true; + if (node.extensions == null) { + node.extensions = {}; + } + var sheenInfo_1 = { + sheenColorFactor: babylonMaterial.sheen.color.asArray(), + sheenRoughnessFactor: (_a = babylonMaterial.sheen.roughness) !== null && _a !== void 0 ? _a : 0, + hasTextures: function () { + return sheenInfo_1.sheenColorTexture !== null || sheenInfo_1.sheenRoughnessTexture !== null; + }, + }; + if (babylonMaterial.sheen.texture) { + sheenInfo_1.sheenColorTexture = (_b = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.sheen.texture)) !== null && _b !== void 0 ? _b : undefined; + } + if (babylonMaterial.sheen.textureRoughness && !babylonMaterial.sheen.useRoughnessFromMainTexture) { + sheenInfo_1.sheenRoughnessTexture = (_c = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.sheen.textureRoughness)) !== null && _c !== void 0 ? _c : undefined; + } + else if (babylonMaterial.sheen.texture && babylonMaterial.sheen.useRoughnessFromMainTexture) { + sheenInfo_1.sheenRoughnessTexture = (_d = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.sheen.texture)) !== null && _d !== void 0 ? _d : undefined; + } + node.extensions[NAME] = sheenInfo_1; + } + resolve(node); + }); + }; + return KHR_materials_sheen; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_sheen(exporter); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_specular.ts": +/*!**********************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_specular.ts ***! + \**********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_specular: () => (/* binding */ KHR_materials_specular) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_specular"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_specular/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_specular = /** @class */ (function () { + function KHR_materials_specular(exporter) { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + this._exporter = exporter; + } + KHR_materials_specular.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_specular.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_materials_specular.prototype.postExportMaterialAdditionalTextures = function (context, node, babylonMaterial) { + var additionalTextures = []; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial) { + if (this._isExtensionEnabled(babylonMaterial)) { + if (babylonMaterial.metallicReflectanceTexture) { + additionalTextures.push(babylonMaterial.metallicReflectanceTexture); + } + if (babylonMaterial.reflectanceTexture) { + additionalTextures.push(babylonMaterial.reflectanceTexture); + } + return additionalTextures; + } + } + return additionalTextures; + }; + KHR_materials_specular.prototype._isExtensionEnabled = function (mat) { + // This extension must not be used on a material that also uses KHR_materials_unlit + if (mat.unlit) { + return false; + } + return ((mat.metallicF0Factor != undefined && mat.metallicF0Factor != 1.0) || + (mat.metallicReflectanceColor != undefined && !mat.metallicReflectanceColor.equalsFloats(1.0, 1.0, 1.0)) || + this._hasTexturesExtension(mat)); + }; + KHR_materials_specular.prototype._hasTexturesExtension = function (mat) { + return mat.metallicReflectanceTexture != null || mat.reflectanceTexture != null; + }; + KHR_materials_specular.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + var _a, _b; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial && _this._isExtensionEnabled(babylonMaterial)) { + _this._wasUsed = true; + node.extensions = node.extensions || {}; + var metallicReflectanceTexture = (_a = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.metallicReflectanceTexture)) !== null && _a !== void 0 ? _a : undefined; + var reflectanceTexture = (_b = _this._exporter._glTFMaterialExporter._getTextureInfo(babylonMaterial.reflectanceTexture)) !== null && _b !== void 0 ? _b : undefined; + var metallicF0Factor = babylonMaterial.metallicF0Factor == 1.0 ? undefined : babylonMaterial.metallicF0Factor; + var metallicReflectanceColor = babylonMaterial.metallicReflectanceColor.equalsFloats(1.0, 1.0, 1.0) + ? undefined + : babylonMaterial.metallicReflectanceColor.asArray(); + var specularInfo = { + specularFactor: metallicF0Factor, + specularTexture: metallicReflectanceTexture, + specularColorFactor: metallicReflectanceColor, + specularColorTexture: reflectanceTexture, + hasTextures: function () { + return _this._hasTexturesExtension(babylonMaterial); + }, + }; + node.extensions[NAME] = specularInfo; + } + resolve(node); + }); + }; + return KHR_materials_specular; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_specular(exporter); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_transmission.ts": +/*!**************************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_transmission.ts ***! + \**************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_transmission: () => (/* binding */ KHR_materials_transmission) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_transmission"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_transmission/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_transmission = /** @class */ (function () { + function KHR_materials_transmission(exporter) { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + this._exporter = exporter; + } + KHR_materials_transmission.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_transmission.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_materials_transmission.prototype.postExportMaterialAdditionalTextures = function (context, node, babylonMaterial) { + var additionalTextures = []; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial) { + if (this._isExtensionEnabled(babylonMaterial)) { + if (babylonMaterial.subSurface.thicknessTexture) { + additionalTextures.push(babylonMaterial.subSurface.thicknessTexture); + } + return additionalTextures; + } + } + return additionalTextures; + }; + KHR_materials_transmission.prototype._isExtensionEnabled = function (mat) { + // This extension must not be used on a material that also uses KHR_materials_unlit + if (mat.unlit) { + return false; + } + var subs = mat.subSurface; + return (subs.isRefractionEnabled && subs.refractionIntensity != undefined && subs.refractionIntensity != 0) || this._hasTexturesExtension(mat); + }; + KHR_materials_transmission.prototype._hasTexturesExtension = function (mat) { + return mat.subSurface.refractionIntensityTexture != null; + }; + KHR_materials_transmission.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + var _a; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial && _this._isExtensionEnabled(babylonMaterial)) { + _this._wasUsed = true; + var subs = babylonMaterial.subSurface; + var transmissionFactor = subs.refractionIntensity === 0 ? undefined : subs.refractionIntensity; + var transmissionTexture = (_a = _this._exporter._glTFMaterialExporter._getTextureInfo(subs.refractionIntensityTexture)) !== null && _a !== void 0 ? _a : undefined; + var volumeInfo = { + transmissionFactor: transmissionFactor, + transmissionTexture: transmissionTexture, + hasTextures: function () { + return _this._hasTexturesExtension(babylonMaterial); + }, + }; + node.extensions = node.extensions || {}; + node.extensions[NAME] = volumeInfo; + } + resolve(node); + }); + }; + return KHR_materials_transmission; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_transmission(exporter); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_unlit.ts": +/*!*******************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_unlit.ts ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_unlit: () => (/* binding */ KHR_materials_unlit) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/standardMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__); + + + +var NAME = "KHR_materials_unlit"; +/** + * @internal + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_unlit = /** @class */ (function () { + function KHR_materials_unlit() { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + } + Object.defineProperty(KHR_materials_unlit.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_materials_unlit.prototype.dispose = function () { }; + KHR_materials_unlit.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + var unlitMaterial = false; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial) { + unlitMaterial = babylonMaterial.unlit; + } + else if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.StandardMaterial) { + unlitMaterial = babylonMaterial.disableLighting; + } + if (unlitMaterial) { + _this._wasUsed = true; + if (node.extensions == null) { + node.extensions = {}; + } + node.extensions[NAME] = {}; + } + resolve(node); + }); + }; + return KHR_materials_unlit; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function () { return new KHR_materials_unlit(); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_volume.ts": +/*!********************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_volume.ts ***! + \********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_volume: () => (/* binding */ KHR_materials_volume) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Maths/math.color */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__); + + + +var NAME = "KHR_materials_volume"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_volume/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_volume = /** @class */ (function () { + function KHR_materials_volume(exporter) { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + this._wasUsed = false; + this._exporter = exporter; + } + KHR_materials_volume.prototype.dispose = function () { }; + Object.defineProperty(KHR_materials_volume.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_materials_volume.prototype.postExportMaterialAdditionalTextures = function (context, node, babylonMaterial) { + var additionalTextures = []; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial) { + if (this._isExtensionEnabled(babylonMaterial)) { + if (babylonMaterial.subSurface.thicknessTexture) { + additionalTextures.push(babylonMaterial.subSurface.thicknessTexture); + } + return additionalTextures; + } + } + return additionalTextures; + }; + KHR_materials_volume.prototype._isExtensionEnabled = function (mat) { + // This extension must not be used on a material that also uses KHR_materials_unlit + if (mat.unlit) { + return false; + } + var subs = mat.subSurface; + // this extension requires either the KHR_materials_transmission or KHR_materials_translucency extensions. + if (!subs.isRefractionEnabled && !subs.isTranslucencyEnabled) { + return false; + } + return ((subs.maximumThickness != undefined && subs.maximumThickness != 0) || + (subs.tintColorAtDistance != undefined && subs.tintColorAtDistance != Number.POSITIVE_INFINITY) || + (subs.tintColor != undefined && subs.tintColor != babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.Color3.White()) || + this._hasTexturesExtension(mat)); + }; + KHR_materials_volume.prototype._hasTexturesExtension = function (mat) { + return mat.subSurface.thicknessTexture != null; + }; + KHR_materials_volume.prototype.postExportMaterialAsync = function (context, node, babylonMaterial) { + var _this = this; + return new Promise(function (resolve) { + var _a; + if (babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_1__.PBRMaterial && _this._isExtensionEnabled(babylonMaterial)) { + _this._wasUsed = true; + var subs = babylonMaterial.subSurface; + var thicknessFactor = subs.maximumThickness == 0 ? undefined : subs.maximumThickness; + var thicknessTexture = (_a = _this._exporter._glTFMaterialExporter._getTextureInfo(subs.thicknessTexture)) !== null && _a !== void 0 ? _a : undefined; + var attenuationDistance = subs.tintColorAtDistance == Number.POSITIVE_INFINITY ? undefined : subs.tintColorAtDistance; + var attenuationColor = subs.tintColor.equalsFloats(1.0, 1.0, 1.0) ? undefined : subs.tintColor.asArray(); + var volumeInfo = { + thicknessFactor: thicknessFactor, + thicknessTexture: thicknessTexture, + attenuationDistance: attenuationDistance, + attenuationColor: attenuationColor, + hasTextures: function () { + return _this._hasTexturesExtension(babylonMaterial); + }, + }; + node.extensions = node.extensions || {}; + node.extensions[NAME] = volumeInfo; + } + resolve(node); + }); + }; + return KHR_materials_volume; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter.RegisterExtension(NAME, function (exporter) { return new KHR_materials_volume(exporter); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_texture_transform.ts": +/*!*********************************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/KHR_texture_transform.ts ***! + \*********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_texture_transform: () => (/* binding */ KHR_texture_transform) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); + + +var NAME = "KHR_texture_transform"; +/** + * @internal + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_texture_transform = /** @class */ (function () { + function KHR_texture_transform() { + /** Name of this extension */ + this.name = NAME; + /** Defines whether this extension is enabled */ + this.enabled = true; + /** Defines whether this extension is required */ + this.required = false; + /** Reference to the glTF exporter */ + this._wasUsed = false; + } + KHR_texture_transform.prototype.dispose = function () { }; + Object.defineProperty(KHR_texture_transform.prototype, "wasUsed", { + /** @internal */ + get: function () { + return this._wasUsed; + }, + enumerable: false, + configurable: true + }); + KHR_texture_transform.prototype.postExportTexture = function (context, textureInfo, babylonTexture) { + var canUseExtension = babylonTexture && + ((babylonTexture.uAng === 0 && babylonTexture.wAng === 0 && babylonTexture.vAng === 0) || + (babylonTexture.uRotationCenter === 0 && babylonTexture.vRotationCenter === 0)); + if (canUseExtension) { + var textureTransform = {}; + var transformIsRequired = false; + if (babylonTexture.uOffset !== 0 || babylonTexture.vOffset !== 0) { + textureTransform.offset = [babylonTexture.uOffset, babylonTexture.vOffset]; + transformIsRequired = true; + } + if (babylonTexture.uScale !== 1 || babylonTexture.vScale !== 1) { + textureTransform.scale = [babylonTexture.uScale, babylonTexture.vScale]; + transformIsRequired = true; + } + if (babylonTexture.wAng !== 0) { + textureTransform.rotation = -babylonTexture.wAng; + transformIsRequired = true; + } + if (babylonTexture.coordinatesIndex !== 0) { + textureTransform.texCoord = babylonTexture.coordinatesIndex; + transformIsRequired = true; + } + if (!transformIsRequired) { + return; + } + this._wasUsed = true; + if (!textureInfo.extensions) { + textureInfo.extensions = {}; + } + textureInfo.extensions[NAME] = textureTransform; + } + }; + KHR_texture_transform.prototype.preExportTextureAsync = function (context, babylonTexture) { + return new Promise(function (resolve, reject) { + var scene = babylonTexture.getScene(); + if (!scene) { + reject("".concat(context, ": \"scene\" is not defined for Babylon texture ").concat(babylonTexture.name, "!")); + return; + } + /* + * The KHR_texture_transform schema only supports w rotation around the origin. + * See https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_transform#gltf-schema-updates. + */ + if (babylonTexture.uAng !== 0 || babylonTexture.vAng !== 0) { + babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("".concat(context, ": Texture ").concat(babylonTexture.name, " with rotation in the u or v axis is not supported in glTF.")); + resolve(null); + } + else if (babylonTexture.wAng !== 0 && (babylonTexture.uRotationCenter !== 0 || babylonTexture.vRotationCenter !== 0)) { + babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("".concat(context, ": Texture ").concat(babylonTexture.name, " with rotation not centered at the origin cannot be exported with ").concat(NAME)); + resolve(null); + } + else { + resolve(babylonTexture); + } + }); + }; + return KHR_texture_transform; +}()); + +_glTFExporter__WEBPACK_IMPORTED_MODULE_1__._Exporter.RegisterExtension(NAME, function () { return new KHR_texture_transform(); }); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/Extensions/index.ts": +/*!*****************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/Extensions/index.ts ***! + \*****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* reexport safe */ _EXT_mesh_gpu_instancing__WEBPACK_IMPORTED_MODULE_11__.EXT_mesh_gpu_instancing), +/* harmony export */ KHR_lights_punctual: () => (/* reexport safe */ _KHR_lights_punctual__WEBPACK_IMPORTED_MODULE_1__.KHR_lights_punctual), +/* harmony export */ KHR_materials_anisotropy: () => (/* reexport safe */ _KHR_materials_anisotropy__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_anisotropy), +/* harmony export */ KHR_materials_clearcoat: () => (/* reexport safe */ _KHR_materials_clearcoat__WEBPACK_IMPORTED_MODULE_2__.KHR_materials_clearcoat), +/* harmony export */ KHR_materials_emissive_strength: () => (/* reexport safe */ _KHR_materials_emissive_strength__WEBPACK_IMPORTED_MODULE_12__.KHR_materials_emissive_strength), +/* harmony export */ KHR_materials_ior: () => (/* reexport safe */ _KHR_materials_ior__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_ior), +/* harmony export */ KHR_materials_iridescence: () => (/* reexport safe */ _KHR_materials_iridescence__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_iridescence), +/* harmony export */ KHR_materials_sheen: () => (/* reexport safe */ _KHR_materials_sheen__WEBPACK_IMPORTED_MODULE_5__.KHR_materials_sheen), +/* harmony export */ KHR_materials_specular: () => (/* reexport safe */ _KHR_materials_specular__WEBPACK_IMPORTED_MODULE_8__.KHR_materials_specular), +/* harmony export */ KHR_materials_transmission: () => (/* reexport safe */ _KHR_materials_transmission__WEBPACK_IMPORTED_MODULE_10__.KHR_materials_transmission), +/* harmony export */ KHR_materials_unlit: () => (/* reexport safe */ _KHR_materials_unlit__WEBPACK_IMPORTED_MODULE_6__.KHR_materials_unlit), +/* harmony export */ KHR_materials_volume: () => (/* reexport safe */ _KHR_materials_volume__WEBPACK_IMPORTED_MODULE_9__.KHR_materials_volume), +/* harmony export */ KHR_texture_transform: () => (/* reexport safe */ _KHR_texture_transform__WEBPACK_IMPORTED_MODULE_0__.KHR_texture_transform) +/* harmony export */ }); +/* harmony import */ var _KHR_texture_transform__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./KHR_texture_transform */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_texture_transform.ts"); +/* harmony import */ var _KHR_lights_punctual__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./KHR_lights_punctual */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_lights_punctual.ts"); +/* harmony import */ var _KHR_materials_clearcoat__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./KHR_materials_clearcoat */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts"); +/* harmony import */ var _KHR_materials_iridescence__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./KHR_materials_iridescence */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts"); +/* harmony import */ var _KHR_materials_anisotropy__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./KHR_materials_anisotropy */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts"); +/* harmony import */ var _KHR_materials_sheen__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./KHR_materials_sheen */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_sheen.ts"); +/* harmony import */ var _KHR_materials_unlit__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./KHR_materials_unlit */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_unlit.ts"); +/* harmony import */ var _KHR_materials_ior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./KHR_materials_ior */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_ior.ts"); +/* harmony import */ var _KHR_materials_specular__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./KHR_materials_specular */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_specular.ts"); +/* harmony import */ var _KHR_materials_volume__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./KHR_materials_volume */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_volume.ts"); +/* harmony import */ var _KHR_materials_transmission__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./KHR_materials_transmission */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_transmission.ts"); +/* harmony import */ var _EXT_mesh_gpu_instancing__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./EXT_mesh_gpu_instancing */ "../../../dev/serializers/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts"); +/* harmony import */ var _KHR_materials_emissive_strength__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./KHR_materials_emissive_strength */ "../../../dev/serializers/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts"); + + + + + + + + + + + + + + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/glTFAnimation.ts": +/*!**************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/glTFAnimation.ts ***! + \**************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ _GLTFAnimation: () => (/* binding */ _GLTFAnimation) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Lights/light */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFUtilities__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFUtilities */ "../../../dev/serializers/src/glTF/2.0/glTFUtilities.ts"); + + + + + + + + + + +/** + * @internal + * Enum for handling in tangent and out tangent. + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var _TangentType; +(function (_TangentType) { + /** + * Specifies that input tangents are used. + */ + _TangentType[_TangentType["INTANGENT"] = 0] = "INTANGENT"; + /** + * Specifies that output tangents are used. + */ + _TangentType[_TangentType["OUTTANGENT"] = 1] = "OUTTANGENT"; +})(_TangentType || (_TangentType = {})); +/** + * @internal + * Utility class for generating glTF animation data from BabylonJS. + */ +var _GLTFAnimation = /** @class */ (function () { + function _GLTFAnimation() { + } + /** + * Determine if a node is transformable - ie has properties it should be part of animation of transformation. + * @param babylonNode the node to test + * @returns true if can be animated, false otherwise. False if the parameter is null or undefined. + */ + _GLTFAnimation._IsTransformable = function (babylonNode) { + return babylonNode && (babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TransformNode || babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Camera || babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Light); + }; + /** + * @ignore + * + * Creates glTF channel animation from BabylonJS animation. + * @param babylonTransformNode - BabylonJS mesh. + * @param animation - animation. + * @param animationChannelTargetPath - The target animation channel. + * @param useQuaternion - Specifies if quaternions are used. + * @returns nullable IAnimationData + */ + _GLTFAnimation._CreateNodeAnimation = function (babylonTransformNode, animation, animationChannelTargetPath, useQuaternion, animationSampleRate) { + if (this._IsTransformable(babylonTransformNode)) { + var inputs = []; + var outputs = []; + var keyFrames = animation.getKeys(); + var minMaxKeyFrames = _GLTFAnimation._CalculateMinMaxKeyFrames(keyFrames); + var interpolationOrBake = _GLTFAnimation._DeduceInterpolation(keyFrames, animationChannelTargetPath, useQuaternion); + var interpolation = interpolationOrBake.interpolationType; + var shouldBakeAnimation = interpolationOrBake.shouldBakeAnimation; + if (shouldBakeAnimation) { + _GLTFAnimation._CreateBakedAnimation(babylonTransformNode, animation, animationChannelTargetPath, minMaxKeyFrames.min, minMaxKeyFrames.max, animation.framePerSecond, animationSampleRate, inputs, outputs, minMaxKeyFrames, useQuaternion); + } + else { + if (interpolation === "LINEAR" /* AnimationSamplerInterpolation.LINEAR */ || interpolation === "STEP" /* AnimationSamplerInterpolation.STEP */) { + _GLTFAnimation._CreateLinearOrStepAnimation(babylonTransformNode, animation, animationChannelTargetPath, inputs, outputs, useQuaternion); + } + else if (interpolation === "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */) { + _GLTFAnimation._CreateCubicSplineAnimation(babylonTransformNode, animation, animationChannelTargetPath, inputs, outputs, useQuaternion); + } + else { + _GLTFAnimation._CreateBakedAnimation(babylonTransformNode, animation, animationChannelTargetPath, minMaxKeyFrames.min, minMaxKeyFrames.max, animation.framePerSecond, animationSampleRate, inputs, outputs, minMaxKeyFrames, useQuaternion); + } + } + if (inputs.length && outputs.length) { + var result = { + inputs: inputs, + outputs: outputs, + samplerInterpolation: interpolation, + inputsMin: shouldBakeAnimation ? minMaxKeyFrames.min : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.FloatRound(minMaxKeyFrames.min / animation.framePerSecond), + inputsMax: shouldBakeAnimation ? minMaxKeyFrames.max : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.FloatRound(minMaxKeyFrames.max / animation.framePerSecond), + }; + return result; + } + } + return null; + }; + _GLTFAnimation._DeduceAnimationInfo = function (animation) { + var animationChannelTargetPath = null; + var dataAccessorType = "VEC3" /* AccessorType.VEC3 */; + var useQuaternion = false; + var property = animation.targetProperty.split("."); + switch (property[0]) { + case "scaling": { + animationChannelTargetPath = "scale" /* AnimationChannelTargetPath.SCALE */; + break; + } + case "position": { + animationChannelTargetPath = "translation" /* AnimationChannelTargetPath.TRANSLATION */; + break; + } + case "rotation": { + dataAccessorType = "VEC4" /* AccessorType.VEC4 */; + animationChannelTargetPath = "rotation" /* AnimationChannelTargetPath.ROTATION */; + break; + } + case "rotationQuaternion": { + dataAccessorType = "VEC4" /* AccessorType.VEC4 */; + useQuaternion = true; + animationChannelTargetPath = "rotation" /* AnimationChannelTargetPath.ROTATION */; + break; + } + case "influence": { + dataAccessorType = "SCALAR" /* AccessorType.SCALAR */; + animationChannelTargetPath = "weights" /* AnimationChannelTargetPath.WEIGHTS */; + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("Unsupported animatable property ".concat(property[0])); + } + } + if (animationChannelTargetPath) { + return { animationChannelTargetPath: animationChannelTargetPath, dataAccessorType: dataAccessorType, useQuaternion: useQuaternion }; + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("animation channel target path and data accessor type could be deduced"); + } + return null; + }; + /** + * @ignore + * Create node animations from the transform node animations + * @param babylonNode + * @param runtimeGLTFAnimation + * @param idleGLTFAnimations + * @param nodeMap + * @param nodes + * @param binaryWriter + * @param bufferViews + * @param accessors + * @param animationSampleRate + */ + _GLTFAnimation._CreateNodeAnimationFromNodeAnimations = function (babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, nodes, binaryWriter, bufferViews, accessors, animationSampleRate, shouldExportAnimation) { + var glTFAnimation; + if (_GLTFAnimation._IsTransformable(babylonNode)) { + if (babylonNode.animations) { + for (var _i = 0, _a = babylonNode.animations; _i < _a.length; _i++) { + var animation = _a[_i]; + if (shouldExportAnimation && !shouldExportAnimation(animation)) { + continue; + } + var animationInfo = _GLTFAnimation._DeduceAnimationInfo(animation); + if (animationInfo) { + glTFAnimation = { + name: animation.name, + samplers: [], + channels: [], + }; + _GLTFAnimation._AddAnimation("".concat(animation.name), animation.hasRunningRuntimeAnimations ? runtimeGLTFAnimation : glTFAnimation, babylonNode, animation, animationInfo.dataAccessorType, animationInfo.animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, animationInfo.useQuaternion, animationSampleRate); + if (glTFAnimation.samplers.length && glTFAnimation.channels.length) { + idleGLTFAnimations.push(glTFAnimation); + } + } + } + } + } + }; + /** + * @ignore + * Create individual morph animations from the mesh's morph target animation tracks + * @param babylonNode + * @param runtimeGLTFAnimation + * @param idleGLTFAnimations + * @param nodeMap + * @param nodes + * @param binaryWriter + * @param bufferViews + * @param accessors + * @param animationSampleRate + */ + _GLTFAnimation._CreateMorphTargetAnimationFromMorphTargetAnimations = function (babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, nodes, binaryWriter, bufferViews, accessors, animationSampleRate, shouldExportAnimation) { + var glTFAnimation; + if (babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Mesh) { + var morphTargetManager = babylonNode.morphTargetManager; + if (morphTargetManager) { + for (var i = 0; i < morphTargetManager.numTargets; ++i) { + var morphTarget = morphTargetManager.getTarget(i); + for (var _i = 0, _a = morphTarget.animations; _i < _a.length; _i++) { + var animation = _a[_i]; + if (shouldExportAnimation && !shouldExportAnimation(animation)) { + continue; + } + var combinedAnimation = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Animation("".concat(animation.name), "influence", animation.framePerSecond, animation.dataType, animation.loopMode, animation.enableBlending); + var combinedAnimationKeys = []; + var animationKeys = animation.getKeys(); + for (var j = 0; j < animationKeys.length; ++j) { + var animationKey = animationKeys[j]; + for (var k = 0; k < morphTargetManager.numTargets; ++k) { + if (k == i) { + combinedAnimationKeys.push(animationKey); + } + else { + combinedAnimationKeys.push({ frame: animationKey.frame, value: 0 }); + } + } + } + combinedAnimation.setKeys(combinedAnimationKeys); + var animationInfo = _GLTFAnimation._DeduceAnimationInfo(combinedAnimation); + if (animationInfo) { + glTFAnimation = { + name: combinedAnimation.name, + samplers: [], + channels: [], + }; + _GLTFAnimation._AddAnimation(animation.name, animation.hasRunningRuntimeAnimations ? runtimeGLTFAnimation : glTFAnimation, babylonNode, combinedAnimation, animationInfo.dataAccessorType, animationInfo.animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, animationInfo.useQuaternion, animationSampleRate, morphTargetManager.numTargets); + if (glTFAnimation.samplers.length && glTFAnimation.channels.length) { + idleGLTFAnimations.push(glTFAnimation); + } + } + } + } + } + } + }; + /** + * @ignore + * Create node and morph animations from the animation groups + * @param babylonScene + * @param glTFAnimations + * @param nodeMap + * @param nodes + * @param binaryWriter + * @param bufferViews + * @param accessors + * @param animationSampleRate + */ + _GLTFAnimation._CreateNodeAndMorphAnimationFromAnimationGroups = function (babylonScene, glTFAnimations, nodeMap, binaryWriter, bufferViews, accessors, animationSampleRate, shouldExportAnimation) { + var _a; + var glTFAnimation; + if (babylonScene.animationGroups) { + var animationGroups = babylonScene.animationGroups; + var _loop_1 = function (animationGroup) { + var morphAnimations = new Map(); + var sampleAnimations = new Map(); + var morphAnimationMeshes = new Set(); + var animationGroupFrameDiff = animationGroup.to - animationGroup.from; + glTFAnimation = { + name: animationGroup.name, + channels: [], + samplers: [], + }; + var _loop_2 = function (i) { + var targetAnimation = animationGroup.targetedAnimations[i]; + var target = targetAnimation.target; + var animation = targetAnimation.animation; + if (shouldExportAnimation && !shouldExportAnimation(animation)) { + return "continue"; + } + if (this_1._IsTransformable(target) || (target.length === 1 && this_1._IsTransformable(target[0]))) { + var animationInfo = _GLTFAnimation._DeduceAnimationInfo(targetAnimation.animation); + if (animationInfo) { + var babylonTransformNode = this_1._IsTransformable(target) ? target : this_1._IsTransformable(target[0]) ? target[0] : null; + if (babylonTransformNode) { + _GLTFAnimation._AddAnimation("".concat(animation.name), glTFAnimation, babylonTransformNode, animation, animationInfo.dataAccessorType, animationInfo.animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, animationInfo.useQuaternion, animationSampleRate); + } + } + } + else if (target instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.MorphTarget || (target.length === 1 && target[0] instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.MorphTarget)) { + var animationInfo = _GLTFAnimation._DeduceAnimationInfo(targetAnimation.animation); + if (animationInfo) { + var babylonMorphTarget_1 = target instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.MorphTarget ? target : target[0]; + if (babylonMorphTarget_1) { + var babylonMorphTargetManager_1 = babylonScene.morphTargetManagers.find(function (morphTargetManager) { + for (var j = 0; j < morphTargetManager.numTargets; ++j) { + if (morphTargetManager.getTarget(j) === babylonMorphTarget_1) { + return true; + } + } + return false; + }); + if (babylonMorphTargetManager_1) { + var babylonMesh = babylonScene.meshes.find(function (mesh) { + return mesh.morphTargetManager === babylonMorphTargetManager_1; + }); + if (babylonMesh) { + if (!morphAnimations.has(babylonMesh)) { + morphAnimations.set(babylonMesh, new Map()); + } + (_a = morphAnimations.get(babylonMesh)) === null || _a === void 0 ? void 0 : _a.set(babylonMorphTarget_1, animation); + morphAnimationMeshes.add(babylonMesh); + sampleAnimations.set(babylonMesh, animation); + } + } + } + } + } + else { + // this is the place for the KHR_animation_pointer. + } + }; + for (var i = 0; i < animationGroup.targetedAnimations.length; ++i) { + _loop_2(i); + } + morphAnimationMeshes.forEach(function (mesh) { + var morphTargetManager = mesh.morphTargetManager; + var combinedAnimationGroup = null; + var animationKeys = []; + var sampleAnimation = sampleAnimations.get(mesh); + var sampleAnimationKeys = sampleAnimation.getKeys(); + var numAnimationKeys = sampleAnimationKeys.length; + /* + Due to how glTF expects morph target animation data to be formatted, we need to rearrange the individual morph target animation tracks, + such that we have a single animation, where a given keyframe input value has successive output values for each morph target belonging to the manager. + See: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#animations + + We do this via constructing a new Animation track, and interleaving the frames of each morph target animation track in the current Animation Group + We reuse the Babylon Animation data structure for ease of handling export of cubic spline animation keys, and to reuse the + existing _GLTFAnimation.AddAnimation codepath with minimal modification, however the constructed Babylon Animation is NOT intended for use in-engine. + */ + for (var i = 0; i < numAnimationKeys; ++i) { + for (var j = 0; j < morphTargetManager.numTargets; ++j) { + var morphTarget = morphTargetManager.getTarget(j); + var animationsByMorphTarget = morphAnimations.get(mesh); + if (animationsByMorphTarget) { + var morphTargetAnimation = animationsByMorphTarget.get(morphTarget); + if (morphTargetAnimation) { + if (!combinedAnimationGroup) { + combinedAnimationGroup = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Animation("".concat(animationGroup.name, "_").concat(mesh.name, "_MorphWeightAnimation"), "influence", morphTargetAnimation.framePerSecond, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, morphTargetAnimation.loopMode, morphTargetAnimation.enableBlending); + } + animationKeys.push(morphTargetAnimation.getKeys()[i]); + } + else { + animationKeys.push({ + frame: animationGroup.from + (animationGroupFrameDiff / numAnimationKeys) * i, + value: morphTarget.influence, + inTangent: sampleAnimationKeys[0].inTangent ? 0 : undefined, + outTangent: sampleAnimationKeys[0].outTangent ? 0 : undefined, + }); + } + } + } + } + combinedAnimationGroup.setKeys(animationKeys); + var animationInfo = _GLTFAnimation._DeduceAnimationInfo(combinedAnimationGroup); + if (animationInfo) { + _GLTFAnimation._AddAnimation("".concat(animationGroup.name, "_").concat(mesh.name, "_MorphWeightAnimation"), glTFAnimation, mesh, combinedAnimationGroup, animationInfo.dataAccessorType, animationInfo.animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, animationInfo.useQuaternion, animationSampleRate, morphTargetManager === null || morphTargetManager === void 0 ? void 0 : morphTargetManager.numTargets); + } + }); + if (glTFAnimation.channels.length && glTFAnimation.samplers.length) { + glTFAnimations.push(glTFAnimation); + } + }; + var this_1 = this; + for (var _i = 0, animationGroups_1 = animationGroups; _i < animationGroups_1.length; _i++) { + var animationGroup = animationGroups_1[_i]; + _loop_1(animationGroup); + } + } + }; + _GLTFAnimation._AddAnimation = function (name, glTFAnimation, babylonTransformNode, animation, dataAccessorType, animationChannelTargetPath, nodeMap, binaryWriter, bufferViews, accessors, useQuaternion, animationSampleRate, morphAnimationChannels) { + var animationData = _GLTFAnimation._CreateNodeAnimation(babylonTransformNode, animation, animationChannelTargetPath, useQuaternion, animationSampleRate); + var bufferView; + var accessor; + var keyframeAccessorIndex; + var dataAccessorIndex; + var outputLength; + var animationSampler; + var animationChannel; + if (animationData) { + /* + * Now that we have the glTF converted morph target animation data, + * we can remove redundant input data so that we have n input frames, + * and morphAnimationChannels * n output frames + */ + if (morphAnimationChannels) { + var index = 0; + var currentInput = 0; + var newInputs = []; + while (animationData.inputs.length > 0) { + currentInput = animationData.inputs.shift(); + if (index % morphAnimationChannels == 0) { + newInputs.push(currentInput); + } + index++; + } + animationData.inputs = newInputs; + } + var nodeIndex = nodeMap[babylonTransformNode.uniqueId]; + // Creates buffer view and accessor for key frames. + var byteLength = animationData.inputs.length * 4; + bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_1__._GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, undefined, "".concat(name, " keyframe data view")); + bufferViews.push(bufferView); + animationData.inputs.forEach(function (input) { + binaryWriter.setFloat32(input); + }); + accessor = _glTFUtilities__WEBPACK_IMPORTED_MODULE_1__._GLTFUtilities._CreateAccessor(bufferViews.length - 1, "".concat(name, " keyframes"), "SCALAR" /* AccessorType.SCALAR */, 5126 /* AccessorComponentType.FLOAT */, animationData.inputs.length, null, [animationData.inputsMin], [animationData.inputsMax]); + accessors.push(accessor); + keyframeAccessorIndex = accessors.length - 1; + // create bufferview and accessor for keyed values. + outputLength = animationData.outputs.length; + byteLength = _glTFUtilities__WEBPACK_IMPORTED_MODULE_1__._GLTFUtilities._GetDataAccessorElementCount(dataAccessorType) * 4 * animationData.outputs.length; + // check for in and out tangents + bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_1__._GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, undefined, "".concat(name, " data view")); + bufferViews.push(bufferView); + animationData.outputs.forEach(function (output) { + output.forEach(function (entry) { + binaryWriter.setFloat32(entry); + }); + }); + accessor = _glTFUtilities__WEBPACK_IMPORTED_MODULE_1__._GLTFUtilities._CreateAccessor(bufferViews.length - 1, "".concat(name, " data"), dataAccessorType, 5126 /* AccessorComponentType.FLOAT */, outputLength, null, null, null); + accessors.push(accessor); + dataAccessorIndex = accessors.length - 1; + // create sampler + animationSampler = { + interpolation: animationData.samplerInterpolation, + input: keyframeAccessorIndex, + output: dataAccessorIndex, + }; + glTFAnimation.samplers.push(animationSampler); + // create channel + animationChannel = { + sampler: glTFAnimation.samplers.length - 1, + target: { + node: nodeIndex, + path: animationChannelTargetPath, + }, + }; + glTFAnimation.channels.push(animationChannel); + } + }; + /** + * Create a baked animation + * @param babylonTransformNode BabylonJS mesh + * @param animation BabylonJS animation corresponding to the BabylonJS mesh + * @param animationChannelTargetPath animation target channel + * @param minFrame minimum animation frame + * @param maxFrame maximum animation frame + * @param fps frames per second of the animation + * @param sampleRate + * @param inputs input key frames of the animation + * @param outputs output key frame data of the animation + * @param minMaxFrames + * @param minMaxFrames.min + * @param minMaxFrames.max + * @param useQuaternion specifies if quaternions should be used + */ + _GLTFAnimation._CreateBakedAnimation = function (babylonTransformNode, animation, animationChannelTargetPath, minFrame, maxFrame, fps, sampleRate, inputs, outputs, minMaxFrames, useQuaternion) { + var value; + var quaternionCache = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Identity(); + var previousTime = null; + var time; + var maxUsedFrame = null; + var currKeyFrame = null; + var nextKeyFrame = null; + var prevKeyFrame = null; + var endFrame = null; + minMaxFrames.min = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.FloatRound(minFrame / fps); + var keyFrames = animation.getKeys(); + for (var i = 0, length_1 = keyFrames.length; i < length_1; ++i) { + endFrame = null; + currKeyFrame = keyFrames[i]; + if (i + 1 < length_1) { + nextKeyFrame = keyFrames[i + 1]; + if ((currKeyFrame.value.equals && currKeyFrame.value.equals(nextKeyFrame.value)) || currKeyFrame.value === nextKeyFrame.value) { + if (i === 0) { + // set the first frame to itself + endFrame = currKeyFrame.frame; + } + else { + continue; + } + } + else { + endFrame = nextKeyFrame.frame; + } + } + else { + // at the last key frame + prevKeyFrame = keyFrames[i - 1]; + if ((currKeyFrame.value.equals && currKeyFrame.value.equals(prevKeyFrame.value)) || currKeyFrame.value === prevKeyFrame.value) { + continue; + } + else { + endFrame = maxFrame; + } + } + if (endFrame) { + for (var f = currKeyFrame.frame; f <= endFrame; f += sampleRate) { + time = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.FloatRound(f / fps); + if (time === previousTime) { + continue; + } + previousTime = time; + maxUsedFrame = time; + var state = { + key: 0, + repeatCount: 0, + loopMode: animation.loopMode, + }; + value = animation._interpolate(f, state); + _GLTFAnimation._SetInterpolatedValue(babylonTransformNode, value, time, animation, animationChannelTargetPath, quaternionCache, inputs, outputs, useQuaternion); + } + } + } + if (maxUsedFrame) { + minMaxFrames.max = maxUsedFrame; + } + }; + _GLTFAnimation._ConvertFactorToVector3OrQuaternion = function (factor, babylonTransformNode, animation, animationChannelTargetPath, useQuaternion) { + var basePositionRotationOrScale = _GLTFAnimation._GetBasePositionRotationOrScale(babylonTransformNode, animationChannelTargetPath, useQuaternion); + // handles single component x, y, z or w component animation by using a base property and animating over a component. + var property = animation.targetProperty.split("."); + var componentName = property ? property[1] : ""; // x, y, z, or w component + var value = useQuaternion ? babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(basePositionRotationOrScale).normalize() : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(basePositionRotationOrScale); + switch (componentName) { + case "x": + case "y": + case "z": { + value[componentName] = factor; + break; + } + case "w": { + value.w = factor; + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("glTFAnimation: Unsupported component name \"".concat(componentName, "\"!")); + } + } + return value; + }; + _GLTFAnimation._SetInterpolatedValue = function (babylonTransformNode, value, time, animation, animationChannelTargetPath, quaternionCache, inputs, outputs, useQuaternion) { + var cacheValue; + inputs.push(time); + if (animationChannelTargetPath === "weights" /* AnimationChannelTargetPath.WEIGHTS */) { + outputs.push([value]); + return; + } + if (animation.dataType === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT) { + value = this._ConvertFactorToVector3OrQuaternion(value, babylonTransformNode, animation, animationChannelTargetPath, useQuaternion); + } + if (animationChannelTargetPath === "rotation" /* AnimationChannelTargetPath.ROTATION */) { + if (useQuaternion) { + quaternionCache = value; + } + else { + cacheValue = value; + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.RotationYawPitchRollToRef(cacheValue.y, cacheValue.x, cacheValue.z, quaternionCache); + } + outputs.push(quaternionCache.asArray()); + } + else { + // scaling and position animation + cacheValue = value; + outputs.push(cacheValue.asArray()); + } + }; + /** + * Creates linear animation from the animation key frames + * @param babylonTransformNode BabylonJS mesh + * @param animation BabylonJS animation + * @param animationChannelTargetPath The target animation channel + * @param inputs Array to store the key frame times + * @param outputs Array to store the key frame data + * @param useQuaternion Specifies if quaternions are used in the animation + */ + _GLTFAnimation._CreateLinearOrStepAnimation = function (babylonTransformNode, animation, animationChannelTargetPath, inputs, outputs, useQuaternion) { + for (var _i = 0, _a = animation.getKeys(); _i < _a.length; _i++) { + var keyFrame = _a[_i]; + inputs.push(keyFrame.frame / animation.framePerSecond); // keyframes in seconds. + _GLTFAnimation._AddKeyframeValue(keyFrame, animation, outputs, animationChannelTargetPath, babylonTransformNode, useQuaternion); + } + }; + /** + * Creates cubic spline animation from the animation key frames + * @param babylonTransformNode BabylonJS mesh + * @param animation BabylonJS animation + * @param animationChannelTargetPath The target animation channel + * @param frameDelta The difference between the last and first frame of the animation + * @param inputs Array to store the key frame times + * @param outputs Array to store the key frame data + * @param useQuaternion Specifies if quaternions are used in the animation + */ + _GLTFAnimation._CreateCubicSplineAnimation = function (babylonTransformNode, animation, animationChannelTargetPath, inputs, outputs, useQuaternion) { + animation.getKeys().forEach(function (keyFrame) { + inputs.push(keyFrame.frame / animation.framePerSecond); // keyframes in seconds. + _GLTFAnimation._AddSplineTangent(_TangentType.INTANGENT, outputs, animationChannelTargetPath, "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */, keyFrame, useQuaternion); + _GLTFAnimation._AddKeyframeValue(keyFrame, animation, outputs, animationChannelTargetPath, babylonTransformNode, useQuaternion); + _GLTFAnimation._AddSplineTangent(_TangentType.OUTTANGENT, outputs, animationChannelTargetPath, "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */, keyFrame, useQuaternion); + }); + }; + _GLTFAnimation._GetBasePositionRotationOrScale = function (babylonTransformNode, animationChannelTargetPath, useQuaternion) { + var basePositionRotationOrScale; + if (animationChannelTargetPath === "rotation" /* AnimationChannelTargetPath.ROTATION */) { + if (useQuaternion) { + var q = babylonTransformNode.rotationQuaternion; + basePositionRotationOrScale = (q !== null && q !== void 0 ? q : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Identity()).asArray(); + } + else { + var r = babylonTransformNode.rotation; + basePositionRotationOrScale = (r !== null && r !== void 0 ? r : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero()).asArray(); + } + } + else if (animationChannelTargetPath === "translation" /* AnimationChannelTargetPath.TRANSLATION */) { + var p = babylonTransformNode.position; + basePositionRotationOrScale = (p !== null && p !== void 0 ? p : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero()).asArray(); + } + else { + // scale + var s = babylonTransformNode.scaling; + basePositionRotationOrScale = (s !== null && s !== void 0 ? s : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.One()).asArray(); + } + return basePositionRotationOrScale; + }; + /** + * Adds a key frame value + * @param keyFrame + * @param animation + * @param outputs + * @param animationChannelTargetPath + * @param babylonTransformNode + * @param useQuaternion + */ + _GLTFAnimation._AddKeyframeValue = function (keyFrame, animation, outputs, animationChannelTargetPath, babylonTransformNode, useQuaternion) { + var newPositionRotationOrScale; + var animationType = animation.dataType; + if (animationType === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_VECTOR3) { + var value = keyFrame.value.asArray(); + if (animationChannelTargetPath === "rotation" /* AnimationChannelTargetPath.ROTATION */) { + var array = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(value); + var rotationQuaternion = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.RotationYawPitchRoll(array.y, array.x, array.z); + value = rotationQuaternion.asArray(); + } + outputs.push(value); // scale vector. + } + else if (animationType === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT) { + if (animationChannelTargetPath === "weights" /* AnimationChannelTargetPath.WEIGHTS */) { + outputs.push([keyFrame.value]); + } + else { + // handles single component x, y, z or w component animation by using a base property and animating over a component. + newPositionRotationOrScale = this._ConvertFactorToVector3OrQuaternion(keyFrame.value, babylonTransformNode, animation, animationChannelTargetPath, useQuaternion); + if (newPositionRotationOrScale) { + if (animationChannelTargetPath === "rotation" /* AnimationChannelTargetPath.ROTATION */) { + var posRotScale = useQuaternion + ? newPositionRotationOrScale + : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.RotationYawPitchRoll(newPositionRotationOrScale.y, newPositionRotationOrScale.x, newPositionRotationOrScale.z).normalize(); + outputs.push(posRotScale.asArray()); + } + outputs.push(newPositionRotationOrScale.asArray()); + } + } + } + else if (animationType === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_QUATERNION) { + outputs.push(keyFrame.value.normalize().asArray()); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("glTFAnimation: Unsupported key frame values for animation!"); + } + }; + /** + * Determine the interpolation based on the key frames + * @param keyFrames + * @param animationChannelTargetPath + * @param useQuaternion + */ + _GLTFAnimation._DeduceInterpolation = function (keyFrames, animationChannelTargetPath, useQuaternion) { + var interpolationType; + var shouldBakeAnimation = false; + var key; + if (animationChannelTargetPath === "rotation" /* AnimationChannelTargetPath.ROTATION */ && !useQuaternion) { + return { interpolationType: "LINEAR" /* AnimationSamplerInterpolation.LINEAR */, shouldBakeAnimation: true }; + } + for (var i = 0, length_2 = keyFrames.length; i < length_2; ++i) { + key = keyFrames[i]; + if (key.inTangent || key.outTangent) { + if (interpolationType) { + if (interpolationType !== "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */) { + interpolationType = "LINEAR" /* AnimationSamplerInterpolation.LINEAR */; + shouldBakeAnimation = true; + break; + } + } + else { + interpolationType = "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */; + } + } + else { + if (interpolationType) { + if (interpolationType === "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */ || + (key.interpolation && key.interpolation === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.AnimationKeyInterpolation.STEP && interpolationType !== "STEP" /* AnimationSamplerInterpolation.STEP */)) { + interpolationType = "LINEAR" /* AnimationSamplerInterpolation.LINEAR */; + shouldBakeAnimation = true; + break; + } + } + else { + if (key.interpolation && key.interpolation === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.AnimationKeyInterpolation.STEP) { + interpolationType = "STEP" /* AnimationSamplerInterpolation.STEP */; + } + else { + interpolationType = "LINEAR" /* AnimationSamplerInterpolation.LINEAR */; + } + } + } + } + if (!interpolationType) { + interpolationType = "LINEAR" /* AnimationSamplerInterpolation.LINEAR */; + } + return { interpolationType: interpolationType, shouldBakeAnimation: shouldBakeAnimation }; + }; + /** + * Adds an input tangent or output tangent to the output data + * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion + * @param babylonTransformNode + * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent) + * @param outputs The animation data by keyframe + * @param animationChannelTargetPath The target animation channel + * @param interpolation The interpolation type + * @param keyFrame The key frame with the animation data + * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta + * @param useQuaternion Specifies if quaternions are used + */ + _GLTFAnimation._AddSplineTangent = function (tangentType, outputs, animationChannelTargetPath, interpolation, keyFrame, useQuaternion) { + var tangent; + var tangentValue = tangentType === _TangentType.INTANGENT ? keyFrame.inTangent : keyFrame.outTangent; + if (interpolation === "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */) { + if (animationChannelTargetPath === "rotation" /* AnimationChannelTargetPath.ROTATION */) { + if (tangentValue) { + if (useQuaternion) { + tangent = tangentValue.asArray(); + } + else { + var array = tangentValue; + tangent = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.RotationYawPitchRoll(array.y, array.x, array.z).asArray(); + } + } + else { + tangent = [0, 0, 0, 0]; + } + } + else if (animationChannelTargetPath === "weights" /* AnimationChannelTargetPath.WEIGHTS */) { + if (tangentValue) { + tangent = [tangentValue]; + } + else { + tangent = [0]; + } + } + else { + if (tangentValue) { + tangent = tangentValue.asArray(); + } + else { + tangent = [0, 0, 0]; + } + } + outputs.push(tangent); + } + }; + /** + * Get the minimum and maximum key frames' frame values + * @param keyFrames animation key frames + * @returns the minimum and maximum key frame value + */ + _GLTFAnimation._CalculateMinMaxKeyFrames = function (keyFrames) { + var min = Infinity; + var max = -Infinity; + keyFrames.forEach(function (keyFrame) { + min = Math.min(min, keyFrame.frame); + max = Math.max(max, keyFrame.frame); + }); + return { min: min, max: max }; + }; + return _GLTFAnimation; +}()); + + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/glTFData.ts": +/*!*********************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/glTFData.ts ***! + \*********************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFData: () => (/* binding */ GLTFData) +/* harmony export */ }); +/** + * Class for holding and downloading glTF file data + */ +var GLTFData = /** @class */ (function () { + /** + * Initializes the glTF file object + */ + function GLTFData() { + this.glTFFiles = {}; + } + /** + * Downloads the glTF data as files based on their names and data + */ + GLTFData.prototype.downloadFiles = function () { + /** + * Checks for a matching suffix at the end of a string (for ES5 and lower) + * @param str Source string + * @param suffix Suffix to search for in the source string + * @returns Boolean indicating whether the suffix was found (true) or not (false) + */ + function endsWith(str, suffix) { + return str.indexOf(suffix, str.length - suffix.length) !== -1; + } + for (var key in this.glTFFiles) { + var link = document.createElement("a"); + document.body.appendChild(link); + link.setAttribute("type", "hidden"); + link.download = key; + var blob = this.glTFFiles[key]; + var mimeType = void 0; + if (endsWith(key, ".glb")) { + mimeType = { type: "model/gltf-binary" }; + } + else if (endsWith(key, ".bin")) { + mimeType = { type: "application/octet-stream" }; + } + else if (endsWith(key, ".gltf")) { + mimeType = { type: "model/gltf+json" }; + } + else if (endsWith(key, ".jpeg") || endsWith(key, ".jpg")) { + mimeType = { type: "image/jpeg" /* ImageMimeType.JPEG */ }; + } + else if (endsWith(key, ".png")) { + mimeType = { type: "image/png" /* ImageMimeType.PNG */ }; + } + link.href = window.URL.createObjectURL(new Blob([blob], mimeType)); + link.click(); + } + }; + return GLTFData; +}()); + + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts": +/*!*************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/glTFExporter.ts ***! + \*************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ _BinaryWriter: () => (/* binding */ _BinaryWriter), +/* harmony export */ _Exporter: () => (/* binding */ _Exporter) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/multiMaterial */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFMaterialExporter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFMaterialExporter */ "../../../dev/serializers/src/glTF/2.0/glTFMaterialExporter.ts"); +/* harmony import */ var _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFUtilities */ "../../../dev/serializers/src/glTF/2.0/glTFUtilities.ts"); +/* harmony import */ var _glTFData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./glTFData */ "../../../dev/serializers/src/glTF/2.0/glTFData.ts"); +/* harmony import */ var _glTFAnimation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./glTFAnimation */ "../../../dev/serializers/src/glTF/2.0/glTFAnimation.ts"); + + + + + + + + + + + + + + + + + + + +// Matrix that converts handedness on the X-axis. +var convertHandednessMatrix = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Matrix.Compose(new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3(-1, 1, 1), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Identity(), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero()); +function isNoopNode(node, useRightHandedSystem) { + if (!(node instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TransformNode)) { + return false; + } + // Transform + if (useRightHandedSystem) { + var matrix = node.getWorldMatrix(); + if (!matrix.isIdentity()) { + return false; + } + } + else { + var matrix = node.getWorldMatrix().multiplyToRef(convertHandednessMatrix, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[0]); + if (!matrix.isIdentity()) { + return false; + } + } + // Geometry + if ((node instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Mesh && node.geometry) || (node instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.InstancedMesh && node.sourceMesh.geometry)) { + return false; + } + return true; +} +function convertNodeHandedness(node) { + var translation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(node.translation || [0, 0, 0], 0, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0]); + var rotation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArrayToRef(node.rotation || [0, 0, 0, 1], 0, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0]); + var scale = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(node.scale || [1, 1, 1], 0, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1]); + var matrix = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Matrix.ComposeToRef(scale, rotation, translation, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[0]).multiplyToRef(convertHandednessMatrix, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[0]); + matrix.decompose(scale, rotation, translation); + if (translation.equalsToFloats(0, 0, 0)) { + delete node.translation; + } + else { + node.translation = translation.asArray(); + } + if (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.IsIdentity(rotation)) { + delete node.rotation; + } + else { + node.rotation = rotation.asArray(); + } + if (scale.equalsToFloats(1, 1, 1)) { + delete node.scale; + } + else { + node.scale = scale.asArray(); + } +} +/** + * Converts Babylon Scene into glTF 2.0. + * @internal + */ +var _Exporter = /** @class */ (function () { + /** + * Creates a glTF Exporter instance, which can accept optional exporter options + * @param babylonScene Babylon scene object + * @param options Options to modify the behavior of the exporter + */ + function _Exporter(babylonScene, options) { + this._extensions = {}; + this._glTF = { + asset: { generator: "Babylon.js v".concat(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Engine.Version), version: "2.0" }, + }; + babylonScene = babylonScene || babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.EngineStore.LastCreatedScene; + if (!babylonScene) { + return; + } + this._babylonScene = babylonScene; + this._bufferViews = []; + this._accessors = []; + this._meshes = []; + this._scenes = []; + this._cameras = []; + this._nodes = []; + this._images = []; + this._materials = []; + this._materialMap = []; + this._textures = []; + this._samplers = []; + this._skins = []; + this._animations = []; + this._imageData = {}; + this._orderedImageData = []; + this._options = options || {}; + this._animationSampleRate = this._options.animationSampleRate || 1 / 60; + this._glTFMaterialExporter = new _glTFMaterialExporter__WEBPACK_IMPORTED_MODULE_1__._GLTFMaterialExporter(this); + this._loadExtensions(); + } + _Exporter.prototype._applyExtension = function (node, extensions, index, actionAsync) { + var _this = this; + if (index >= extensions.length) { + return Promise.resolve(node); + } + var currentPromise = actionAsync(extensions[index], node); + if (!currentPromise) { + return this._applyExtension(node, extensions, index + 1, actionAsync); + } + return currentPromise.then(function (newNode) { return _this._applyExtension(newNode, extensions, index + 1, actionAsync); }); + }; + _Exporter.prototype._applyExtensions = function (node, actionAsync) { + var extensions = []; + for (var _i = 0, _a = _Exporter._ExtensionNames; _i < _a.length; _i++) { + var name_1 = _a[_i]; + extensions.push(this._extensions[name_1]); + } + return this._applyExtension(node, extensions, 0, actionAsync); + }; + _Exporter.prototype._extensionsPreExportTextureAsync = function (context, babylonTexture, mimeType) { + return this._applyExtensions(babylonTexture, function (extension, node) { return extension.preExportTextureAsync && extension.preExportTextureAsync(context, node, mimeType); }); + }; + _Exporter.prototype._extensionsPostExportMeshPrimitiveAsync = function (context, meshPrimitive, babylonSubMesh, binaryWriter) { + return this._applyExtensions(meshPrimitive, function (extension, node) { return extension.postExportMeshPrimitiveAsync && extension.postExportMeshPrimitiveAsync(context, node, babylonSubMesh, binaryWriter); }); + }; + _Exporter.prototype._extensionsPostExportNodeAsync = function (context, node, babylonNode, nodeMap, binaryWriter) { + return this._applyExtensions(node, function (extension, node) { return extension.postExportNodeAsync && extension.postExportNodeAsync(context, node, babylonNode, nodeMap, binaryWriter); }); + }; + _Exporter.prototype._extensionsPostExportMaterialAsync = function (context, material, babylonMaterial) { + return this._applyExtensions(material, function (extension, node) { return extension.postExportMaterialAsync && extension.postExportMaterialAsync(context, node, babylonMaterial); }); + }; + _Exporter.prototype._extensionsPostExportMaterialAdditionalTextures = function (context, material, babylonMaterial) { + var output = []; + for (var _i = 0, _a = _Exporter._ExtensionNames; _i < _a.length; _i++) { + var name_2 = _a[_i]; + var extension = this._extensions[name_2]; + if (extension.postExportMaterialAdditionalTextures) { + output.push.apply(output, extension.postExportMaterialAdditionalTextures(context, material, babylonMaterial)); + } + } + return output; + }; + _Exporter.prototype._extensionsPostExportTextures = function (context, textureInfo, babylonTexture) { + for (var _i = 0, _a = _Exporter._ExtensionNames; _i < _a.length; _i++) { + var name_3 = _a[_i]; + var extension = this._extensions[name_3]; + if (extension.postExportTexture) { + extension.postExportTexture(context, textureInfo, babylonTexture); + } + } + }; + _Exporter.prototype._forEachExtensions = function (action) { + for (var _i = 0, _a = _Exporter._ExtensionNames; _i < _a.length; _i++) { + var name_4 = _a[_i]; + var extension = this._extensions[name_4]; + if (extension.enabled) { + action(extension); + } + } + }; + _Exporter.prototype._extensionsOnExporting = function () { + var _this = this; + this._forEachExtensions(function (extension) { + if (extension.wasUsed) { + if (_this._glTF.extensionsUsed == null) { + _this._glTF.extensionsUsed = []; + } + if (_this._glTF.extensionsUsed.indexOf(extension.name) === -1) { + _this._glTF.extensionsUsed.push(extension.name); + } + if (extension.required) { + if (_this._glTF.extensionsRequired == null) { + _this._glTF.extensionsRequired = []; + } + if (_this._glTF.extensionsRequired.indexOf(extension.name) === -1) { + _this._glTF.extensionsRequired.push(extension.name); + } + } + if (_this._glTF.extensions == null) { + _this._glTF.extensions = {}; + } + if (extension.onExporting) { + extension.onExporting(); + } + } + }); + }; + /** + * Load glTF serializer extensions + */ + _Exporter.prototype._loadExtensions = function () { + for (var _i = 0, _a = _Exporter._ExtensionNames; _i < _a.length; _i++) { + var name_5 = _a[_i]; + var extension = _Exporter._ExtensionFactories[name_5](this); + this._extensions[name_5] = extension; + } + }; + _Exporter.prototype.dispose = function () { + for (var extensionKey in this._extensions) { + var extension = this._extensions[extensionKey]; + extension.dispose(); + } + }; + Object.defineProperty(_Exporter.prototype, "options", { + get: function () { + return this._options; + }, + enumerable: false, + configurable: true + }); + /** + * Registers a glTF exporter extension + * @param name Name of the extension to export + * @param factory The factory function that creates the exporter extension + */ + _Exporter.RegisterExtension = function (name, factory) { + if (_Exporter.UnregisterExtension(name)) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Extension with the name ".concat(name, " already exists")); + } + _Exporter._ExtensionFactories[name] = factory; + _Exporter._ExtensionNames.push(name); + }; + /** + * Un-registers an exporter extension + * @param name The name fo the exporter extension + * @returns A boolean indicating whether the extension has been un-registered + */ + _Exporter.UnregisterExtension = function (name) { + if (!_Exporter._ExtensionFactories[name]) { + return false; + } + delete _Exporter._ExtensionFactories[name]; + var index = _Exporter._ExtensionNames.indexOf(name); + if (index !== -1) { + _Exporter._ExtensionNames.splice(index, 1); + } + return true; + }; + _Exporter.prototype._reorderIndicesBasedOnPrimitiveMode = function (submesh, primitiveMode, babylonIndices, byteOffset, binaryWriter) { + switch (primitiveMode) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFillMode: { + if (!byteOffset) { + byteOffset = 0; + } + for (var i = submesh.indexStart, length_1 = submesh.indexStart + submesh.indexCount; i < length_1; i = i + 3) { + var index = byteOffset + i * 4; + // swap the second and third indices + var secondIndex = binaryWriter.getUInt32(index + 4); + var thirdIndex = binaryWriter.getUInt32(index + 8); + binaryWriter.setUInt32(thirdIndex, index + 4); + binaryWriter.setUInt32(secondIndex, index + 8); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFanDrawMode: { + for (var i = submesh.indexStart + submesh.indexCount - 1, start = submesh.indexStart; i >= start; --i) { + binaryWriter.setUInt32(babylonIndices[i], byteOffset); + byteOffset += 4; + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleStripDrawMode: { + if (submesh.indexCount >= 3) { + binaryWriter.setUInt32(babylonIndices[submesh.indexStart + 2], byteOffset + 4); + binaryWriter.setUInt32(babylonIndices[submesh.indexStart + 1], byteOffset + 8); + } + break; + } + } + }; + /** + * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is + * clock-wise during export to glTF + * @param submesh BabylonJS submesh + * @param primitiveMode Primitive mode of the mesh + * @param vertexBufferKind The type of vertex attribute + * @param meshAttributeArray The vertex attribute data + * @param byteOffset The offset to the binary data + * @param binaryWriter The binary data for the glTF file + */ + _Exporter.prototype._reorderVertexAttributeDataBasedOnPrimitiveMode = function (submesh, primitiveMode, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter) { + switch (primitiveMode) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFillMode: { + this._reorderTriangleFillMode(submesh, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter); + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleStripDrawMode: { + this._reorderTriangleStripDrawMode(submesh, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter); + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFanDrawMode: { + this._reorderTriangleFanMode(submesh, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter); + break; + } + } + }; + /** + * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is + * clock-wise during export to glTF + * @param submesh BabylonJS submesh + * @param vertexBufferKind The type of vertex attribute + * @param meshAttributeArray The vertex attribute data + * @param byteOffset The offset to the binary data + * @param binaryWriter The binary data for the glTF file + */ + _Exporter.prototype._reorderTriangleFillMode = function (submesh, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter) { + var vertexBuffer = this._getVertexBufferFromMesh(vertexBufferKind, submesh.getMesh()); + if (vertexBuffer) { + var stride = vertexBuffer.byteStride / babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(vertexBuffer.type); + if (submesh.verticesCount % 3 !== 0) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("The submesh vertices for the triangle fill mode is not divisible by 3!"); + } + else { + var vertexData = []; + var index = 0; + switch (vertexBufferKind) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind: + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind: { + for (var x = submesh.verticesStart; x < submesh.verticesStart + submesh.verticesCount; x = x + 3) { + index = x * stride; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index + 2 * stride)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index + stride)); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind: { + for (var x = submesh.verticesStart; x < submesh.verticesStart + submesh.verticesCount; x = x + 3) { + index = x * stride; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index + 2 * stride)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index + stride)); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind: { + var size = vertexBuffer.getSize(); + for (var x = submesh.verticesStart; x < submesh.verticesStart + submesh.verticesCount; x = x + size) { + index = x * stride; + if (size === 4) { + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index + 2 * stride)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index + stride)); + } + else { + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index + 2 * stride)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index + stride)); + } + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind: + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind: { + for (var x = submesh.verticesStart; x < submesh.verticesStart + submesh.verticesCount; x = x + 3) { + index = x * stride; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2.FromArray(meshAttributeArray, index)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2.FromArray(meshAttributeArray, index + 2 * stride)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2.FromArray(meshAttributeArray, index + stride)); + } + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("Unsupported Vertex Buffer type: ".concat(vertexBufferKind)); + } + } + this._writeVertexAttributeData(vertexData, byteOffset, vertexBufferKind, binaryWriter); + } + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("reorderTriangleFillMode: Vertex Buffer Kind ".concat(vertexBufferKind, " not present!")); + } + }; + /** + * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is + * clock-wise during export to glTF + * @param submesh BabylonJS submesh + * @param vertexBufferKind The type of vertex attribute + * @param meshAttributeArray The vertex attribute data + * @param byteOffset The offset to the binary data + * @param binaryWriter The binary data for the glTF file + */ + _Exporter.prototype._reorderTriangleStripDrawMode = function (submesh, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter) { + var vertexBuffer = this._getVertexBufferFromMesh(vertexBufferKind, submesh.getMesh()); + if (vertexBuffer) { + var stride = vertexBuffer.byteStride / babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(vertexBuffer.type); + var vertexData = []; + var index = 0; + switch (vertexBufferKind) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind: + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind: { + index = submesh.verticesStart; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index + 2 * stride)); + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index + stride)); + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind: { + for (var x = submesh.verticesStart + submesh.verticesCount - 1; x >= submesh.verticesStart; --x) { + index = x * stride; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index)); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind: { + for (var x = submesh.verticesStart + submesh.verticesCount - 1; x >= submesh.verticesStart; --x) { + index = x * stride; + vertexBuffer.getSize() === 4 + ? vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index)) + : vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index)); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind: + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind: { + for (var x = submesh.verticesStart + submesh.verticesCount - 1; x >= submesh.verticesStart; --x) { + index = x * stride; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2.FromArray(meshAttributeArray, index)); + } + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("Unsupported Vertex Buffer type: ".concat(vertexBufferKind)); + } + } + this._writeVertexAttributeData(vertexData, byteOffset + 12, vertexBufferKind, binaryWriter); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("reorderTriangleStripDrawMode: Vertex buffer kind ".concat(vertexBufferKind, " not present!")); + } + }; + /** + * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is + * clock-wise during export to glTF + * @param submesh BabylonJS submesh + * @param vertexBufferKind The type of vertex attribute + * @param meshAttributeArray The vertex attribute data + * @param byteOffset The offset to the binary data + * @param binaryWriter The binary data for the glTF file + */ + _Exporter.prototype._reorderTriangleFanMode = function (submesh, vertexBufferKind, meshAttributeArray, byteOffset, binaryWriter) { + var vertexBuffer = this._getVertexBufferFromMesh(vertexBufferKind, submesh.getMesh()); + if (vertexBuffer) { + var stride = vertexBuffer.byteStride / babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(vertexBuffer.type); + var vertexData = []; + var index = 0; + switch (vertexBufferKind) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind: + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind: { + for (var x = submesh.verticesStart + submesh.verticesCount - 1; x >= submesh.verticesStart; --x) { + index = x * stride; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index)); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind: { + for (var x = submesh.verticesStart + submesh.verticesCount - 1; x >= submesh.verticesStart; --x) { + index = x * stride; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index)); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind: { + for (var x = submesh.verticesStart + submesh.verticesCount - 1; x >= submesh.verticesStart; --x) { + index = x * stride; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index)); + vertexBuffer.getSize() === 4 + ? vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index)) + : vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index)); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind: + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind: { + for (var x = submesh.verticesStart + submesh.verticesCount - 1; x >= submesh.verticesStart; --x) { + index = x * stride; + vertexData.push(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2.FromArray(meshAttributeArray, index)); + } + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("Unsupported Vertex Buffer type: ".concat(vertexBufferKind)); + } + } + this._writeVertexAttributeData(vertexData, byteOffset, vertexBufferKind, binaryWriter); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("reorderTriangleFanMode: Vertex buffer kind ".concat(vertexBufferKind, " not present!")); + } + }; + /** + * Writes the vertex attribute data to binary + * @param vertices The vertices to write to the binary writer + * @param byteOffset The offset into the binary writer to overwrite binary data + * @param vertexAttributeKind The vertex attribute type + * @param binaryWriter The writer containing the binary data + */ + _Exporter.prototype._writeVertexAttributeData = function (vertices, byteOffset, vertexAttributeKind, binaryWriter) { + for (var _i = 0, vertices_1 = vertices; _i < vertices_1.length; _i++) { + var vertex = vertices_1[_i]; + if (vertexAttributeKind === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind) { + vertex.normalize(); + } + else if (vertexAttributeKind === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind && vertex instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4) { + _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._NormalizeTangentFromRef(vertex); + } + for (var _a = 0, _b = vertex.asArray(); _a < _b.length; _a++) { + var component = _b[_a]; + binaryWriter.setFloat32(component, byteOffset); + byteOffset += 4; + } + } + }; + /** + * Writes mesh attribute data to a data buffer + * Returns the bytelength of the data + * @param vertexBufferKind Indicates what kind of vertex data is being passed in + * @param attributeComponentKind + * @param meshAttributeArray Array containing the attribute data + * @param stride Specifies the space between data + * @param binaryWriter The buffer to write the binary data to + * @param babylonTransformNode + */ + _Exporter.prototype._writeAttributeData = function (vertexBufferKind, attributeComponentKind, meshAttributeArray, stride, binaryWriter, babylonTransformNode) { + var vertexAttributes = []; + var index; + switch (vertexBufferKind) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind: { + for (var k = 0, length_2 = meshAttributeArray.length / stride; k < length_2; ++k) { + index = k * stride; + var vertexData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index); + vertexAttributes.push(vertexData.asArray()); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind: { + for (var k = 0, length_3 = meshAttributeArray.length / stride; k < length_3; ++k) { + index = k * stride; + var vertexData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index); + vertexAttributes.push(vertexData.normalize().asArray()); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind: { + for (var k = 0, length_4 = meshAttributeArray.length / stride; k < length_4; ++k) { + index = k * stride; + var vertexData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index); + _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._NormalizeTangentFromRef(vertexData); + vertexAttributes.push(vertexData.asArray()); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind: { + var meshMaterial = babylonTransformNode.material; + var convertToLinear = meshMaterial ? meshMaterial.getClassName() === "StandardMaterial" : true; + var vertexData = stride === 3 ? new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3() : new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color4(); + var useExactSrgbConversions = this._babylonScene.getEngine().useExactSrgbConversions; + for (var k = 0, length_5 = meshAttributeArray.length / stride; k < length_5; ++k) { + index = k * stride; + if (stride === 3) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArrayToRef(meshAttributeArray, index, vertexData); + if (convertToLinear) { + vertexData.toLinearSpaceToRef(vertexData, useExactSrgbConversions); + } + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color4.FromArrayToRef(meshAttributeArray, index, vertexData); + if (convertToLinear) { + vertexData.toLinearSpaceToRef(vertexData, useExactSrgbConversions); + } + } + vertexAttributes.push(vertexData.asArray()); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind: + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind: { + for (var k = 0, length_6 = meshAttributeArray.length / stride; k < length_6; ++k) { + index = k * stride; + var vertexData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2.FromArray(meshAttributeArray, index); + vertexAttributes.push(vertexData.asArray()); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind: + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind: { + for (var k = 0, length_7 = meshAttributeArray.length / stride; k < length_7; ++k) { + index = k * stride; + var vertexData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index); + vertexAttributes.push(vertexData.asArray()); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsKind: + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsExtraKind: { + for (var k = 0, length_8 = meshAttributeArray.length / stride; k < length_8; ++k) { + index = k * stride; + var vertexData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index); + vertexAttributes.push(vertexData.asArray()); + } + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Unsupported Vertex Buffer Type: " + vertexBufferKind); + vertexAttributes = []; + } + } + var writeBinaryFunc; + switch (attributeComponentKind) { + case 5121 /* AccessorComponentType.UNSIGNED_BYTE */: { + writeBinaryFunc = binaryWriter.setUInt8.bind(binaryWriter); + break; + } + case 5123 /* AccessorComponentType.UNSIGNED_SHORT */: { + writeBinaryFunc = binaryWriter.setUInt16.bind(binaryWriter); + break; + } + case 5125 /* AccessorComponentType.UNSIGNED_INT */: { + writeBinaryFunc = binaryWriter.setUInt32.bind(binaryWriter); + break; + } + case 5126 /* AccessorComponentType.FLOAT */: { + writeBinaryFunc = binaryWriter.setFloat32.bind(binaryWriter); + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Unsupported Attribute Component kind: " + attributeComponentKind); + return; + } + } + for (var _i = 0, vertexAttributes_1 = vertexAttributes; _i < vertexAttributes_1.length; _i++) { + var vertexAttribute = vertexAttributes_1[_i]; + for (var _a = 0, vertexAttribute_1 = vertexAttribute; _a < vertexAttribute_1.length; _a++) { + var component = vertexAttribute_1[_a]; + writeBinaryFunc(component); + } + } + }; + /** + * Writes mesh attribute data to a data buffer + * Returns the bytelength of the data + * @param vertexBufferKind Indicates what kind of vertex data is being passed in + * @param attributeComponentKind + * @param meshPrimitive + * @param morphTarget + * @param meshAttributeArray Array containing the attribute data + * @param morphTargetAttributeArray + * @param stride Specifies the space between data + * @param binaryWriter The buffer to write the binary data to + * @param minMax + */ + _Exporter.prototype.writeMorphTargetAttributeData = function (vertexBufferKind, attributeComponentKind, meshPrimitive, meshAttributeArray, morphTargetAttributeArray, stride, binaryWriter, minMax) { + var vertexAttributes = []; + var index; + var difference = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3(); + var difference4 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4(0, 0, 0, 0); + switch (vertexBufferKind) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind: { + for (var k = meshPrimitive.verticesStart; k < meshPrimitive.verticesCount; ++k) { + index = meshPrimitive.indexStart + k * stride; + var vertexData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index); + var morphData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(morphTargetAttributeArray, index); + difference = morphData.subtractToRef(vertexData, difference); + if (minMax) { + minMax.min.copyFromFloats(Math.min(difference.x, minMax.min.x), Math.min(difference.y, minMax.min.y), Math.min(difference.z, minMax.min.z)); + minMax.max.copyFromFloats(Math.max(difference.x, minMax.max.x), Math.max(difference.y, minMax.max.y), Math.max(difference.z, minMax.max.z)); + } + vertexAttributes.push(difference.asArray()); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind: { + for (var k = meshPrimitive.verticesStart; k < meshPrimitive.verticesCount; ++k) { + index = meshPrimitive.indexStart + k * stride; + var vertexData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(meshAttributeArray, index).normalize(); + var morphData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(morphTargetAttributeArray, index).normalize(); + difference = morphData.subtractToRef(vertexData, difference); + vertexAttributes.push(difference.asArray()); + } + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind: { + for (var k = meshPrimitive.verticesStart; k < meshPrimitive.verticesCount; ++k) { + index = meshPrimitive.indexStart + k * (stride + 1); + var vertexData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(meshAttributeArray, index); + _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._NormalizeTangentFromRef(vertexData); + var morphData = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector4.FromArray(morphTargetAttributeArray, index); + _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._NormalizeTangentFromRef(morphData); + difference4 = morphData.subtractToRef(vertexData, difference4); + vertexAttributes.push([difference4.x, difference4.y, difference4.z]); + } + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Unsupported Vertex Buffer Type: " + vertexBufferKind); + vertexAttributes = []; + } + } + var writeBinaryFunc; + switch (attributeComponentKind) { + case 5121 /* AccessorComponentType.UNSIGNED_BYTE */: { + writeBinaryFunc = binaryWriter.setUInt8.bind(binaryWriter); + break; + } + case 5123 /* AccessorComponentType.UNSIGNED_SHORT */: { + writeBinaryFunc = binaryWriter.setUInt16.bind(binaryWriter); + break; + } + case 5125 /* AccessorComponentType.UNSIGNED_INT */: { + writeBinaryFunc = binaryWriter.setUInt32.bind(binaryWriter); + break; + } + case 5126 /* AccessorComponentType.FLOAT */: { + writeBinaryFunc = binaryWriter.setFloat32.bind(binaryWriter); + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Unsupported Attribute Component kind: " + attributeComponentKind); + return; + } + } + for (var _i = 0, vertexAttributes_2 = vertexAttributes; _i < vertexAttributes_2.length; _i++) { + var vertexAttribute = vertexAttributes_2[_i]; + for (var _a = 0, vertexAttribute_2 = vertexAttribute; _a < vertexAttribute_2.length; _a++) { + var component = vertexAttribute_2[_a]; + writeBinaryFunc(component); + } + } + }; + /** + * Generates glTF json data + * @param shouldUseGlb Indicates whether the json should be written for a glb file + * @param glTFPrefix Text to use when prefixing a glTF file + * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false) + * @returns json data as string + */ + _Exporter.prototype._generateJSON = function (shouldUseGlb, glTFPrefix, prettyPrint) { + var _this = this; + var buffer = { byteLength: this._totalByteLength }; + var imageName; + var imageData; + var bufferView; + var byteOffset = this._totalByteLength; + if (buffer.byteLength) { + this._glTF.buffers = [buffer]; + } + if (this._nodes && this._nodes.length) { + this._glTF.nodes = this._nodes; + } + if (this._meshes && this._meshes.length) { + this._glTF.meshes = this._meshes; + } + if (this._scenes && this._scenes.length) { + this._glTF.scenes = this._scenes; + this._glTF.scene = 0; + } + if (this._cameras && this._cameras.length) { + this._glTF.cameras = this._cameras; + } + if (this._bufferViews && this._bufferViews.length) { + this._glTF.bufferViews = this._bufferViews; + } + if (this._accessors && this._accessors.length) { + this._glTF.accessors = this._accessors; + } + if (this._animations && this._animations.length) { + this._glTF.animations = this._animations; + } + if (this._materials && this._materials.length) { + this._glTF.materials = this._materials; + } + if (this._textures && this._textures.length) { + this._glTF.textures = this._textures; + } + if (this._samplers && this._samplers.length) { + this._glTF.samplers = this._samplers; + } + if (this._skins && this._skins.length) { + this._glTF.skins = this._skins; + } + if (this._images && this._images.length) { + if (!shouldUseGlb) { + this._glTF.images = this._images; + } + else { + this._glTF.images = []; + this._images.forEach(function (image) { + if (image.uri) { + imageData = _this._imageData[image.uri]; + _this._orderedImageData.push(imageData); + imageName = image.uri.split(".")[0] + " image"; + bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateBufferView(0, byteOffset, imageData.data.byteLength, undefined, imageName); + byteOffset += imageData.data.byteLength; + _this._bufferViews.push(bufferView); + image.bufferView = _this._bufferViews.length - 1; + image.name = imageName; + image.mimeType = imageData.mimeType; + image.uri = undefined; + if (!_this._glTF.images) { + _this._glTF.images = []; + } + _this._glTF.images.push(image); + } + }); + // Replace uri with bufferview and mime type for glb + buffer.byteLength = byteOffset; + } + } + if (!shouldUseGlb) { + buffer.uri = glTFPrefix + ".bin"; + } + var jsonText = prettyPrint ? JSON.stringify(this._glTF, null, 2) : JSON.stringify(this._glTF); + return jsonText; + }; + /** + * Generates data for .gltf and .bin files based on the glTF prefix string + * @param glTFPrefix Text to use when prefixing a glTF file + * @param dispose Dispose the exporter + * @returns GLTFData with glTF file data + */ + _Exporter.prototype._generateGLTFAsync = function (glTFPrefix, dispose) { + var _this = this; + if (dispose === void 0) { dispose = true; } + return this._generateBinaryAsync().then(function (binaryBuffer) { + _this._extensionsOnExporting(); + var jsonText = _this._generateJSON(false, glTFPrefix, true); + var bin = new Blob([binaryBuffer], { type: "application/octet-stream" }); + var glTFFileName = glTFPrefix + ".gltf"; + var glTFBinFile = glTFPrefix + ".bin"; + var container = new _glTFData__WEBPACK_IMPORTED_MODULE_3__.GLTFData(); + container.glTFFiles[glTFFileName] = jsonText; + container.glTFFiles[glTFBinFile] = bin; + if (_this._imageData) { + for (var image in _this._imageData) { + container.glTFFiles[image] = new Blob([_this._imageData[image].data], { type: _this._imageData[image].mimeType }); + } + } + if (dispose) { + _this.dispose(); + } + return container; + }); + }; + /** + * Creates a binary buffer for glTF + * @returns array buffer for binary data + */ + _Exporter.prototype._generateBinaryAsync = function () { + var _this = this; + var binaryWriter = new _BinaryWriter(4); + return this._createSceneAsync(binaryWriter).then(function () { + if (_this._localEngine) { + _this._localEngine.dispose(); + } + return binaryWriter.getArrayBuffer(); + }); + }; + /** + * Pads the number to a multiple of 4 + * @param num number to pad + * @returns padded number + */ + _Exporter.prototype._getPadding = function (num) { + var remainder = num % 4; + var padding = remainder === 0 ? remainder : 4 - remainder; + return padding; + }; + /** + * @internal + */ + _Exporter.prototype._generateGLBAsync = function (glTFPrefix, dispose) { + var _this = this; + if (dispose === void 0) { dispose = true; } + return this._generateBinaryAsync().then(function (binaryBuffer) { + _this._extensionsOnExporting(); + var jsonText = _this._generateJSON(true); + var glbFileName = glTFPrefix + ".glb"; + var headerLength = 12; + var chunkLengthPrefix = 8; + var jsonLength = jsonText.length; + var encodedJsonText; + var imageByteLength = 0; + // make use of TextEncoder when available + if (typeof TextEncoder !== "undefined") { + var encoder = new TextEncoder(); + encodedJsonText = encoder.encode(jsonText); + jsonLength = encodedJsonText.length; + } + for (var i = 0; i < _this._orderedImageData.length; ++i) { + imageByteLength += _this._orderedImageData[i].data.byteLength; + } + var jsonPadding = _this._getPadding(jsonLength); + var binPadding = _this._getPadding(binaryBuffer.byteLength); + var imagePadding = _this._getPadding(imageByteLength); + var byteLength = headerLength + 2 * chunkLengthPrefix + jsonLength + jsonPadding + binaryBuffer.byteLength + binPadding + imageByteLength + imagePadding; + //header + var headerBuffer = new ArrayBuffer(headerLength); + var headerBufferView = new DataView(headerBuffer); + headerBufferView.setUint32(0, 0x46546c67, true); //glTF + headerBufferView.setUint32(4, 2, true); // version + headerBufferView.setUint32(8, byteLength, true); // total bytes in file + //json chunk + var jsonChunkBuffer = new ArrayBuffer(chunkLengthPrefix + jsonLength + jsonPadding); + var jsonChunkBufferView = new DataView(jsonChunkBuffer); + jsonChunkBufferView.setUint32(0, jsonLength + jsonPadding, true); + jsonChunkBufferView.setUint32(4, 0x4e4f534a, true); + //json chunk bytes + var jsonData = new Uint8Array(jsonChunkBuffer, chunkLengthPrefix); + // if TextEncoder was available, we can simply copy the encoded array + if (encodedJsonText) { + jsonData.set(encodedJsonText); + } + else { + var blankCharCode = "_".charCodeAt(0); + for (var i = 0; i < jsonLength; ++i) { + var charCode = jsonText.charCodeAt(i); + // if the character doesn't fit into a single UTF-16 code unit, just put a blank character + if (charCode != jsonText.codePointAt(i)) { + jsonData[i] = blankCharCode; + } + else { + jsonData[i] = charCode; + } + } + } + //json padding + var jsonPaddingView = new Uint8Array(jsonChunkBuffer, chunkLengthPrefix + jsonLength); + for (var i = 0; i < jsonPadding; ++i) { + jsonPaddingView[i] = 0x20; + } + //binary chunk + var binaryChunkBuffer = new ArrayBuffer(chunkLengthPrefix); + var binaryChunkBufferView = new DataView(binaryChunkBuffer); + binaryChunkBufferView.setUint32(0, binaryBuffer.byteLength + imageByteLength + imagePadding, true); + binaryChunkBufferView.setUint32(4, 0x004e4942, true); + // binary padding + var binPaddingBuffer = new ArrayBuffer(binPadding); + var binPaddingView = new Uint8Array(binPaddingBuffer); + for (var i = 0; i < binPadding; ++i) { + binPaddingView[i] = 0; + } + var imagePaddingBuffer = new ArrayBuffer(imagePadding); + var imagePaddingView = new Uint8Array(imagePaddingBuffer); + for (var i = 0; i < imagePadding; ++i) { + imagePaddingView[i] = 0; + } + var glbData = [headerBuffer, jsonChunkBuffer, binaryChunkBuffer, binaryBuffer]; + // binary data + for (var i = 0; i < _this._orderedImageData.length; ++i) { + glbData.push(_this._orderedImageData[i].data); + } + glbData.push(binPaddingBuffer); + glbData.push(imagePaddingBuffer); + var glbFile = new Blob(glbData, { type: "application/octet-stream" }); + var container = new _glTFData__WEBPACK_IMPORTED_MODULE_3__.GLTFData(); + container.glTFFiles[glbFileName] = glbFile; + if (_this._localEngine != null) { + _this._localEngine.dispose(); + } + if (dispose) { + _this.dispose(); + } + return container; + }); + }; + /** + * Sets the TRS for each node + * @param node glTF Node for storing the transformation data + * @param babylonTransformNode Babylon mesh used as the source for the transformation data + */ + _Exporter.prototype._setNodeTransformation = function (node, babylonTransformNode) { + if (!babylonTransformNode.getPivotPoint().equalsToFloats(0, 0, 0)) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Pivot points are not supported in the glTF serializer"); + } + if (!babylonTransformNode.position.equalsToFloats(0, 0, 0)) { + node.translation = babylonTransformNode.position.asArray(); + } + if (!babylonTransformNode.scaling.equalsToFloats(1, 1, 1)) { + node.scale = babylonTransformNode.scaling.asArray(); + } + var rotationQuaternion = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.RotationYawPitchRoll(babylonTransformNode.rotation.y, babylonTransformNode.rotation.x, babylonTransformNode.rotation.z); + if (babylonTransformNode.rotationQuaternion) { + rotationQuaternion.multiplyInPlace(babylonTransformNode.rotationQuaternion); + } + if (!babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.IsIdentity(rotationQuaternion)) { + node.rotation = rotationQuaternion.normalize().asArray(); + } + }; + _Exporter.prototype._setCameraTransformation = function (node, babylonCamera) { + if (!babylonCamera.position.equalsToFloats(0, 0, 0)) { + node.translation = babylonCamera.position.asArray(); + } + var rotationQuaternion = babylonCamera.rotationQuaternion; // we target the local transformation if one. + if (rotationQuaternion && !babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.IsIdentity(rotationQuaternion)) { + node.rotation = rotationQuaternion.normalize().asArray(); + } + }; + _Exporter.prototype._getVertexBufferFromMesh = function (attributeKind, bufferMesh) { + if (bufferMesh.isVerticesDataPresent(attributeKind, true)) { + var vertexBuffer = bufferMesh.getVertexBuffer(attributeKind, true); + if (vertexBuffer) { + return vertexBuffer; + } + } + return null; + }; + /** + * Creates a bufferview based on the vertices type for the Babylon mesh + * @param kind Indicates the type of vertices data + * @param attributeComponentKind Indicates the numerical type used to store the data + * @param babylonTransformNode The Babylon mesh to get the vertices data from + * @param binaryWriter The buffer to write the bufferview data to + * @param byteStride + */ + _Exporter.prototype._createBufferViewKind = function (kind, attributeComponentKind, babylonTransformNode, binaryWriter, byteStride) { + var bufferMesh = babylonTransformNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Mesh + ? babylonTransformNode + : babylonTransformNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.InstancedMesh + ? babylonTransformNode.sourceMesh + : null; + if (bufferMesh) { + var vertexBuffer = bufferMesh.getVertexBuffer(kind, true); + var vertexData = bufferMesh.getVerticesData(kind, undefined, undefined, true); + if (vertexBuffer && vertexData) { + var typeByteLength = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(attributeComponentKind); + var byteLength = vertexData.length * typeByteLength; + var bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, byteStride, kind + " - " + bufferMesh.name); + this._bufferViews.push(bufferView); + this._writeAttributeData(kind, attributeComponentKind, vertexData, byteStride / typeByteLength, binaryWriter, babylonTransformNode); + } + } + }; + /** + * Creates a bufferview based on the vertices type for the Babylon mesh + * @param babylonSubMesh The Babylon submesh that the morph target is applied to + * @param meshPrimitive + * @param babylonMorphTarget the morph target to be exported + * @param binaryWriter The buffer to write the bufferview data to + */ + _Exporter.prototype._setMorphTargetAttributes = function (babylonSubMesh, meshPrimitive, babylonMorphTarget, binaryWriter) { + if (babylonMorphTarget) { + if (!meshPrimitive.targets) { + meshPrimitive.targets = []; + } + var target = {}; + var mesh = babylonSubMesh.getMesh(); + if (babylonMorphTarget.hasNormals) { + var vertexNormals = mesh.getVerticesData(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind, undefined, undefined, true); + var morphNormals = babylonMorphTarget.getNormals(); + var count = babylonSubMesh.verticesCount; + var byteStride = 12; // 3 x 4 byte floats + var byteLength = count * byteStride; + var bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, byteStride, babylonMorphTarget.name + "_NORMAL"); + this._bufferViews.push(bufferView); + var bufferViewIndex = this._bufferViews.length - 1; + var accessor = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateAccessor(bufferViewIndex, babylonMorphTarget.name + " - " + "NORMAL", "VEC3" /* AccessorType.VEC3 */, 5126 /* AccessorComponentType.FLOAT */, count, 0, null, null); + this._accessors.push(accessor); + target.NORMAL = this._accessors.length - 1; + this.writeMorphTargetAttributeData(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind, 5126 /* AccessorComponentType.FLOAT */, babylonSubMesh, vertexNormals, morphNormals, byteStride / 4, binaryWriter); + } + if (babylonMorphTarget.hasPositions) { + var vertexPositions = mesh.getVerticesData(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind, undefined, undefined, true); + var morphPositions = babylonMorphTarget.getPositions(); + var count = babylonSubMesh.verticesCount; + var byteStride = 12; // 3 x 4 byte floats + var byteLength = count * byteStride; + var bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, byteStride, babylonMorphTarget.name + "_POSITION"); + this._bufferViews.push(bufferView); + var bufferViewIndex = this._bufferViews.length - 1; + var minMax = { min: new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3(Infinity, Infinity, Infinity), max: new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3(-Infinity, -Infinity, -Infinity) }; + var accessor = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateAccessor(bufferViewIndex, babylonMorphTarget.name + " - " + "POSITION", "VEC3" /* AccessorType.VEC3 */, 5126 /* AccessorComponentType.FLOAT */, count, 0, null, null); + this._accessors.push(accessor); + target.POSITION = this._accessors.length - 1; + this.writeMorphTargetAttributeData(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind, 5126 /* AccessorComponentType.FLOAT */, babylonSubMesh, vertexPositions, morphPositions, byteStride / 4, binaryWriter, minMax); + accessor.min = minMax.min.asArray(); + accessor.max = minMax.max.asArray(); + } + if (babylonMorphTarget.hasTangents) { + var vertexTangents = mesh.getVerticesData(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind, undefined, undefined, true); + var morphTangents = babylonMorphTarget.getTangents(); + var count = babylonSubMesh.verticesCount; + var byteStride = 12; // 3 x 4 byte floats + var byteLength = count * byteStride; + var bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, byteStride, babylonMorphTarget.name + "_NORMAL"); + this._bufferViews.push(bufferView); + var bufferViewIndex = this._bufferViews.length - 1; + var accessor = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateAccessor(bufferViewIndex, babylonMorphTarget.name + " - " + "TANGENT", "VEC3" /* AccessorType.VEC3 */, 5126 /* AccessorComponentType.FLOAT */, count, 0, null, null); + this._accessors.push(accessor); + target.TANGENT = this._accessors.length - 1; + this.writeMorphTargetAttributeData(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind, 5126 /* AccessorComponentType.FLOAT */, babylonSubMesh, vertexTangents, morphTangents, byteStride / 4, binaryWriter); + } + meshPrimitive.targets.push(target); + } + }; + /** + * The primitive mode of the Babylon mesh + * @param babylonMesh The BabylonJS mesh + */ + _Exporter.prototype._getMeshPrimitiveMode = function (babylonMesh) { + if (babylonMesh instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.LinesMesh) { + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.LineListDrawMode; + } + if (babylonMesh instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.InstancedMesh || babylonMesh instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Mesh) { + var baseMesh = babylonMesh instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Mesh ? babylonMesh : babylonMesh.sourceMesh; + if (typeof baseMesh.overrideRenderingFillMode === "number") { + return baseMesh.overrideRenderingFillMode; + } + } + return babylonMesh.material ? babylonMesh.material.fillMode : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFillMode; + }; + /** + * Sets the primitive mode of the glTF mesh primitive + * @param meshPrimitive glTF mesh primitive + * @param primitiveMode The primitive mode + */ + _Exporter.prototype._setPrimitiveMode = function (meshPrimitive, primitiveMode) { + switch (primitiveMode) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFillMode: { + // glTF defaults to using Triangle Mode + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleStripDrawMode: { + meshPrimitive.mode = 5 /* MeshPrimitiveMode.TRIANGLE_STRIP */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFanDrawMode: { + meshPrimitive.mode = 6 /* MeshPrimitiveMode.TRIANGLE_FAN */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.PointListDrawMode: { + meshPrimitive.mode = 0 /* MeshPrimitiveMode.POINTS */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.PointFillMode: { + meshPrimitive.mode = 0 /* MeshPrimitiveMode.POINTS */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.LineLoopDrawMode: { + meshPrimitive.mode = 2 /* MeshPrimitiveMode.LINE_LOOP */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.LineListDrawMode: { + meshPrimitive.mode = 1 /* MeshPrimitiveMode.LINES */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.LineStripDrawMode: { + meshPrimitive.mode = 3 /* MeshPrimitiveMode.LINE_STRIP */; + break; + } + } + }; + /** + * Sets the vertex attribute accessor based of the glTF mesh primitive + * @param meshPrimitive glTF mesh primitive + * @param attributeKind vertex attribute + * @returns boolean specifying if uv coordinates are present + */ + _Exporter.prototype._setAttributeKind = function (meshPrimitive, attributeKind) { + switch (attributeKind) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind: { + meshPrimitive.attributes.POSITION = this._accessors.length - 1; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind: { + meshPrimitive.attributes.NORMAL = this._accessors.length - 1; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind: { + meshPrimitive.attributes.COLOR_0 = this._accessors.length - 1; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind: { + meshPrimitive.attributes.TANGENT = this._accessors.length - 1; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind: { + meshPrimitive.attributes.TEXCOORD_0 = this._accessors.length - 1; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind: { + meshPrimitive.attributes.TEXCOORD_1 = this._accessors.length - 1; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind: { + meshPrimitive.attributes.JOINTS_0 = this._accessors.length - 1; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind: { + meshPrimitive.attributes.JOINTS_1 = this._accessors.length - 1; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsKind: { + meshPrimitive.attributes.WEIGHTS_0 = this._accessors.length - 1; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsExtraKind: { + meshPrimitive.attributes.WEIGHTS_1 = this._accessors.length - 1; + break; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Unsupported Vertex Buffer Type: " + attributeKind); + } + } + }; + /** + * Sets data for the primitive attributes of each submesh + * @param mesh glTF Mesh object to store the primitive attribute information + * @param babylonTransformNode Babylon mesh to get the primitive attribute data from + * @param binaryWriter Buffer to write the attribute data to + */ + _Exporter.prototype._setPrimitiveAttributesAsync = function (mesh, babylonTransformNode, binaryWriter) { + var promises = []; + var bufferMesh = null; + var bufferView; + var minMax; + if (babylonTransformNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Mesh) { + bufferMesh = babylonTransformNode; + } + else if (babylonTransformNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.InstancedMesh) { + bufferMesh = babylonTransformNode.sourceMesh; + } + var attributeData = [ + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind, accessorType: "VEC3" /* AccessorType.VEC3 */, accessorComponentType: 5126 /* AccessorComponentType.FLOAT */, byteStride: 12 }, + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind, accessorType: "VEC3" /* AccessorType.VEC3 */, accessorComponentType: 5126 /* AccessorComponentType.FLOAT */, byteStride: 12 }, + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind, accessorType: "VEC4" /* AccessorType.VEC4 */, accessorComponentType: 5126 /* AccessorComponentType.FLOAT */, byteStride: 16 }, + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind, accessorType: "VEC4" /* AccessorType.VEC4 */, accessorComponentType: 5126 /* AccessorComponentType.FLOAT */, byteStride: 16 }, + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind, accessorType: "VEC2" /* AccessorType.VEC2 */, accessorComponentType: 5126 /* AccessorComponentType.FLOAT */, byteStride: 8 }, + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind, accessorType: "VEC2" /* AccessorType.VEC2 */, accessorComponentType: 5126 /* AccessorComponentType.FLOAT */, byteStride: 8 }, + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind, accessorType: "VEC4" /* AccessorType.VEC4 */, accessorComponentType: 5123 /* AccessorComponentType.UNSIGNED_SHORT */, byteStride: 8 }, + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind, accessorType: "VEC4" /* AccessorType.VEC4 */, accessorComponentType: 5123 /* AccessorComponentType.UNSIGNED_SHORT */, byteStride: 8 }, + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsKind, accessorType: "VEC4" /* AccessorType.VEC4 */, accessorComponentType: 5126 /* AccessorComponentType.FLOAT */, byteStride: 16 }, + { kind: babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsExtraKind, accessorType: "VEC4" /* AccessorType.VEC4 */, accessorComponentType: 5126 /* AccessorComponentType.FLOAT */, byteStride: 16 }, + ]; + if (bufferMesh) { + var indexBufferViewIndex = null; + var primitiveMode = this._getMeshPrimitiveMode(bufferMesh); + var vertexAttributeBufferViews = {}; + var morphTargetManager = bufferMesh.morphTargetManager; + // For each BabylonMesh, create bufferviews for each 'kind' + for (var _i = 0, attributeData_1 = attributeData; _i < attributeData_1.length; _i++) { + var attribute = attributeData_1[_i]; + var attributeKind = attribute.kind; + var attributeComponentKind = attribute.accessorComponentType; + if (bufferMesh.isVerticesDataPresent(attributeKind, true)) { + var vertexBuffer = this._getVertexBufferFromMesh(attributeKind, bufferMesh); + attribute.byteStride = vertexBuffer + ? vertexBuffer.getSize() * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(attribute.accessorComponentType) + : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.DeduceStride(attributeKind) * 4; + if (attribute.byteStride === 12) { + attribute.accessorType = "VEC3" /* AccessorType.VEC3 */; + } + this._createBufferViewKind(attributeKind, attributeComponentKind, babylonTransformNode, binaryWriter, attribute.byteStride); + attribute.bufferViewIndex = this._bufferViews.length - 1; + vertexAttributeBufferViews[attributeKind] = attribute.bufferViewIndex; + } + } + if (bufferMesh.getTotalIndices()) { + var indices = bufferMesh.getIndices(); + if (indices) { + var byteLength = indices.length * 4; + bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateBufferView(0, binaryWriter.getByteOffset(), byteLength, undefined, "Indices - " + bufferMesh.name); + this._bufferViews.push(bufferView); + indexBufferViewIndex = this._bufferViews.length - 1; + for (var k = 0, length_9 = indices.length; k < length_9; ++k) { + binaryWriter.setUInt32(indices[k]); + } + } + } + if (bufferMesh.subMeshes) { + // go through all mesh primitives (submeshes) + for (var _a = 0, _b = bufferMesh.subMeshes; _a < _b.length; _a++) { + var submesh = _b[_a]; + var babylonMaterial = submesh.getMaterial() || bufferMesh.getScene().defaultMaterial; + var materialIndex = null; + if (babylonMaterial) { + if (bufferMesh instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.LinesMesh) { + // get the color from the lines mesh and set it in the material + var material = { + name: bufferMesh.name + " material", + }; + if (!bufferMesh.color.equals(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.White()) || bufferMesh.alpha < 1) { + material.pbrMetallicRoughness = { + baseColorFactor: bufferMesh.color.asArray().concat([bufferMesh.alpha]), + }; + } + this._materials.push(material); + materialIndex = this._materials.length - 1; + } + else if (babylonMaterial instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.MultiMaterial) { + var subMaterial = babylonMaterial.subMaterials[submesh.materialIndex]; + if (subMaterial) { + babylonMaterial = subMaterial; + materialIndex = this._materialMap[babylonMaterial.uniqueId]; + } + } + else { + materialIndex = this._materialMap[babylonMaterial.uniqueId]; + } + } + var glTFMaterial = materialIndex != null ? this._materials[materialIndex] : null; + var meshPrimitive = { attributes: {} }; + this._setPrimitiveMode(meshPrimitive, primitiveMode); + for (var _c = 0, attributeData_2 = attributeData; _c < attributeData_2.length; _c++) { + var attribute = attributeData_2[_c]; + var attributeKind = attribute.kind; + if ((attributeKind === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind || attributeKind === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind) && !this._options.exportUnusedUVs) { + if (!glTFMaterial || !this._glTFMaterialExporter._hasTexturesPresent(glTFMaterial)) { + continue; + } + } + var vertexData = bufferMesh.getVerticesData(attributeKind, undefined, undefined, true); + if (vertexData) { + var vertexBuffer = this._getVertexBufferFromMesh(attributeKind, bufferMesh); + if (vertexBuffer) { + var stride = vertexBuffer.getSize(); + var bufferViewIndex = attribute.bufferViewIndex; + if (bufferViewIndex != undefined) { + // check to see if bufferviewindex has a numeric value assigned. + minMax = { min: null, max: null }; + if (attributeKind == babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind) { + minMax = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CalculateMinMaxPositions(vertexData, 0, vertexData.length / stride); + } + var accessor = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateAccessor(bufferViewIndex, attributeKind + " - " + babylonTransformNode.name, attribute.accessorType, attribute.accessorComponentType, vertexData.length / stride, 0, minMax.min, minMax.max); + this._accessors.push(accessor); + this._setAttributeKind(meshPrimitive, attributeKind); + } + } + } + } + if (indexBufferViewIndex) { + // Create accessor + var accessor = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateAccessor(indexBufferViewIndex, "indices - " + babylonTransformNode.name, "SCALAR" /* AccessorType.SCALAR */, 5125 /* AccessorComponentType.UNSIGNED_INT */, submesh.indexCount, submesh.indexStart * 4, null, null); + this._accessors.push(accessor); + meshPrimitive.indices = this._accessors.length - 1; + } + if (materialIndex != null && Object.keys(meshPrimitive.attributes).length > 0) { + var sideOrientation = bufferMesh.overrideMaterialSideOrientation !== null ? bufferMesh.overrideMaterialSideOrientation : babylonMaterial.sideOrientation; + if (sideOrientation === (this._babylonScene.useRightHandedSystem ? babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.ClockWiseSideOrientation : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Material.CounterClockWiseSideOrientation)) { + var byteOffset = indexBufferViewIndex != null ? this._bufferViews[indexBufferViewIndex].byteOffset : null; + if (byteOffset == null) { + byteOffset = 0; + } + var babylonIndices = null; + if (indexBufferViewIndex != null) { + babylonIndices = bufferMesh.getIndices(); + } + if (babylonIndices) { + this._reorderIndicesBasedOnPrimitiveMode(submesh, primitiveMode, babylonIndices, byteOffset, binaryWriter); + } + else { + for (var _d = 0, attributeData_3 = attributeData; _d < attributeData_3.length; _d++) { + var attribute = attributeData_3[_d]; + var vertexData = bufferMesh.getVerticesData(attribute.kind, undefined, undefined, true); + if (vertexData) { + var byteOffset_1 = this._bufferViews[vertexAttributeBufferViews[attribute.kind]].byteOffset || 0; + this._reorderVertexAttributeDataBasedOnPrimitiveMode(submesh, primitiveMode, attribute.kind, vertexData, byteOffset_1, binaryWriter); + } + } + } + } + meshPrimitive.material = materialIndex; + } + if (morphTargetManager) { + // By convention, morph target names are stored in the mesh extras. + if (!mesh.extras) { + mesh.extras = {}; + } + mesh.extras.targetNames = []; + for (var i = 0; i < morphTargetManager.numTargets; ++i) { + var target = morphTargetManager.getTarget(i); + this._setMorphTargetAttributes(submesh, meshPrimitive, target, binaryWriter); + mesh.extras.targetNames.push(target.name); + } + } + mesh.primitives.push(meshPrimitive); + this._extensionsPostExportMeshPrimitiveAsync("postExport", meshPrimitive, submesh, binaryWriter); + promises.push(); + } + } + } + return Promise.all(promises).then(function () { + /* do nothing */ + }); + }; + /** + * Creates a glTF scene based on the array of meshes + * Returns the the total byte offset + * @param babylonScene Babylon scene to get the mesh data from + * @param binaryWriter Buffer to write binary data to + */ + _Exporter.prototype._createSceneAsync = function (binaryWriter) { + var _a; + var _this = this; + var _b; + var scene = { nodes: [] }; + var glTFNodeIndex; + var glTFNode; + var directDescendents; + var nodes = (0,tslib__WEBPACK_IMPORTED_MODULE_5__.__spreadArray)((0,tslib__WEBPACK_IMPORTED_MODULE_5__.__spreadArray)((0,tslib__WEBPACK_IMPORTED_MODULE_5__.__spreadArray)((0,tslib__WEBPACK_IMPORTED_MODULE_5__.__spreadArray)([], this._babylonScene.transformNodes, true), this._babylonScene.meshes, true), this._babylonScene.lights, true), this._babylonScene.cameras, true); + var removedRootNodes = new Set(); + // Scene metadata + if (this._babylonScene.metadata) { + if (this._options.metadataSelector) { + scene.extras = this._options.metadataSelector(this._babylonScene.metadata); + } + else if (this._babylonScene.metadata.gltf) { + scene.extras = this._babylonScene.metadata.gltf.extras; + } + } + // Remove no-op root nodes + if (((_b = this._options.removeNoopRootNodes) !== null && _b !== void 0 ? _b : true) && !this._options.includeCoordinateSystemConversionNodes) { + for (var _i = 0, _c = this._babylonScene.rootNodes; _i < _c.length; _i++) { + var rootNode = _c[_i]; + if (isNoopNode(rootNode, this._babylonScene.useRightHandedSystem)) { + removedRootNodes.add(rootNode); + // Exclude the node from list of nodes to export + nodes.splice(nodes.indexOf(rootNode), 1); + } + } + } + // Export babylon cameras to glTFCamera + var cameraMap = new Map(); + this._babylonScene.cameras.forEach(function (camera) { + if (!_this._options.shouldExportNode || _this._options.shouldExportNode(camera)) { + var glTFCamera = { + type: camera.mode === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Camera.PERSPECTIVE_CAMERA ? "perspective" /* CameraType.PERSPECTIVE */ : "orthographic" /* CameraType.ORTHOGRAPHIC */, + }; + if (camera.name) { + glTFCamera.name = camera.name; + } + if (glTFCamera.type === "perspective" /* CameraType.PERSPECTIVE */) { + glTFCamera.perspective = { + aspectRatio: camera.getEngine().getAspectRatio(camera), + yfov: camera.fovMode === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Camera.FOVMODE_VERTICAL_FIXED ? camera.fov : camera.fov * camera.getEngine().getAspectRatio(camera), + znear: camera.minZ, + zfar: camera.maxZ, + }; + } + else if (glTFCamera.type === "orthographic" /* CameraType.ORTHOGRAPHIC */) { + var halfWidth = camera.orthoLeft && camera.orthoRight ? 0.5 * (camera.orthoRight - camera.orthoLeft) : camera.getEngine().getRenderWidth() * 0.5; + var halfHeight = camera.orthoBottom && camera.orthoTop ? 0.5 * (camera.orthoTop - camera.orthoBottom) : camera.getEngine().getRenderHeight() * 0.5; + glTFCamera.orthographic = { + xmag: halfWidth, + ymag: halfHeight, + znear: camera.minZ, + zfar: camera.maxZ, + }; + } + cameraMap.set(camera, _this._cameras.length); + _this._cameras.push(glTFCamera); + } + }); + var exportNodes = (_a = this._getExportNodes(nodes), _a[0]), exportMaterials = _a[1]; + return this._glTFMaterialExporter._convertMaterialsToGLTFAsync(exportMaterials, "image/png" /* ImageMimeType.PNG */, true).then(function () { + return _this._createNodeMapAndAnimationsAsync(exportNodes, binaryWriter).then(function (nodeMap) { + return _this._createSkinsAsync(nodeMap, binaryWriter).then(function (skinMap) { + _this._nodeMap = nodeMap; + _this._totalByteLength = binaryWriter.getByteOffset(); + if (_this._totalByteLength == undefined) { + throw new Error("undefined byte length!"); + } + // Build Hierarchy with the node map. + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var babylonNode = nodes_1[_i]; + glTFNodeIndex = _this._nodeMap[babylonNode.uniqueId]; + if (glTFNodeIndex !== undefined) { + glTFNode = _this._nodes[glTFNodeIndex]; + if (babylonNode.metadata) { + if (_this._options.metadataSelector) { + glTFNode.extras = _this._options.metadataSelector(babylonNode.metadata); + } + else if (babylonNode.metadata.gltf) { + glTFNode.extras = babylonNode.metadata.gltf.extras; + } + } + if (babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Camera) { + glTFNode.camera = cameraMap.get(babylonNode); + } + if (_this._options.shouldExportNode && !_this._options.shouldExportNode(babylonNode)) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Log("Omitting " + babylonNode.name + " from scene."); + } + else { + if (!babylonNode.parent && !_this._babylonScene.useRightHandedSystem) { + convertNodeHandedness(glTFNode); + } + if (!babylonNode.parent || removedRootNodes.has(babylonNode.parent)) { + scene.nodes.push(glTFNodeIndex); + } + } + if (babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Mesh) { + if (babylonNode.skeleton) { + glTFNode.skin = skinMap[babylonNode.skeleton.uniqueId]; + } + } + directDescendents = babylonNode.getDescendants(true); + if (!glTFNode.children && directDescendents && directDescendents.length) { + var children = []; + for (var _a = 0, directDescendents_1 = directDescendents; _a < directDescendents_1.length; _a++) { + var descendent = directDescendents_1[_a]; + if (_this._nodeMap[descendent.uniqueId] != null) { + children.push(_this._nodeMap[descendent.uniqueId]); + } + } + if (children.length) { + glTFNode.children = children; + } + } + } + } + if (scene.nodes.length) { + _this._scenes.push(scene); + } + }); + }); + }); + }; + /** + * Getting the nodes and materials that would be exported. + * @param nodes Babylon transform nodes + * @returns Array of nodes which would be exported. + * @returns Set of materials which would be exported. + */ + _Exporter.prototype._getExportNodes = function (nodes) { + var exportNodes = []; + var exportMaterials = new Set(); + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var babylonNode = nodes_2[_i]; + if (!this._options.shouldExportNode || this._options.shouldExportNode(babylonNode)) { + exportNodes.push(babylonNode); + var babylonMesh = babylonNode; + if (babylonMesh.subMeshes && babylonMesh.subMeshes.length > 0) { + var material = babylonMesh.material || babylonMesh.getScene().defaultMaterial; + if (material instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.MultiMaterial) { + for (var _a = 0, _b = material.subMaterials; _a < _b.length; _a++) { + var subMaterial = _b[_a]; + if (subMaterial) { + exportMaterials.add(subMaterial); + } + } + } + else { + exportMaterials.add(material); + } + } + } + else { + "Excluding node ".concat(babylonNode.name); + } + } + return [exportNodes, exportMaterials]; + }; + /** + * Creates a mapping of Node unique id to node index and handles animations + * @param nodes Babylon transform nodes + * @param binaryWriter Buffer to write binary data to + * @returns Node mapping of unique id to index + */ + _Exporter.prototype._createNodeMapAndAnimationsAsync = function (nodes, binaryWriter) { + var _this = this; + var promiseChain = Promise.resolve(); + var nodeMap = {}; + var nodeIndex; + var runtimeGLTFAnimation = { + name: "runtime animations", + channels: [], + samplers: [], + }; + var idleGLTFAnimations = []; + var _loop_1 = function (babylonNode) { + promiseChain = promiseChain.then(function () { + return _this._createNodeAsync(babylonNode, binaryWriter).then(function (node) { + var promise = _this._extensionsPostExportNodeAsync("createNodeAsync", node, babylonNode, nodeMap, binaryWriter); + if (promise == null) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Not exporting node ".concat(babylonNode.name)); + return Promise.resolve(); + } + else { + return promise.then(function (node) { + if (!node) { + return; + } + _this._nodes.push(node); + nodeIndex = _this._nodes.length - 1; + nodeMap[babylonNode.uniqueId] = nodeIndex; + if (!_this._babylonScene.animationGroups.length) { + _glTFAnimation__WEBPACK_IMPORTED_MODULE_4__._GLTFAnimation._CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, _this._nodes, binaryWriter, _this._bufferViews, _this._accessors, _this._animationSampleRate, _this._options.shouldExportAnimation); + if (babylonNode.animations.length) { + _glTFAnimation__WEBPACK_IMPORTED_MODULE_4__._GLTFAnimation._CreateNodeAnimationFromNodeAnimations(babylonNode, runtimeGLTFAnimation, idleGLTFAnimations, nodeMap, _this._nodes, binaryWriter, _this._bufferViews, _this._accessors, _this._animationSampleRate, _this._options.shouldExportAnimation); + } + } + }); + } + }); + }); + }; + for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) { + var babylonNode = nodes_3[_i]; + _loop_1(babylonNode); + } + return promiseChain.then(function () { + if (runtimeGLTFAnimation.channels.length && runtimeGLTFAnimation.samplers.length) { + _this._animations.push(runtimeGLTFAnimation); + } + idleGLTFAnimations.forEach(function (idleGLTFAnimation) { + if (idleGLTFAnimation.channels.length && idleGLTFAnimation.samplers.length) { + _this._animations.push(idleGLTFAnimation); + } + }); + if (_this._babylonScene.animationGroups.length) { + _glTFAnimation__WEBPACK_IMPORTED_MODULE_4__._GLTFAnimation._CreateNodeAndMorphAnimationFromAnimationGroups(_this._babylonScene, _this._animations, nodeMap, binaryWriter, _this._bufferViews, _this._accessors, _this._animationSampleRate, _this._options.shouldExportAnimation); + } + return nodeMap; + }); + }; + /** + * Creates a glTF node from a Babylon mesh + * @param babylonNode Source Babylon mesh + * @param binaryWriter Buffer for storing geometry data + * @returns glTF node + */ + _Exporter.prototype._createNodeAsync = function (babylonNode, binaryWriter) { + var _this = this; + return Promise.resolve().then(function () { + // create node to hold translation/rotation/scale and the mesh + var node = {}; + // create mesh + var mesh = { primitives: [] }; + if (babylonNode.name) { + node.name = babylonNode.name; + } + if (babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TransformNode) { + // Set transformation + _this._setNodeTransformation(node, babylonNode); + if (babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Mesh) { + var morphTargetManager = babylonNode.morphTargetManager; + if (morphTargetManager && morphTargetManager.numTargets > 0) { + mesh.weights = []; + for (var i = 0; i < morphTargetManager.numTargets; ++i) { + mesh.weights.push(morphTargetManager.getTarget(i).influence); + } + } + } + return _this._setPrimitiveAttributesAsync(mesh, babylonNode, binaryWriter).then(function () { + if (mesh.primitives.length) { + _this._meshes.push(mesh); + node.mesh = _this._meshes.length - 1; + } + return node; + }); + } + else if (babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Camera) { + _this._setCameraTransformation(node, babylonNode); + return node; + } + else { + return node; + } + }); + }; + /** + * Creates a glTF skin from a Babylon skeleton + * @param babylonScene Babylon Scene + * @param nodeMap Babylon transform nodes + * @param binaryWriter Buffer to write binary data to + * @returns Node mapping of unique id to index + */ + _Exporter.prototype._createSkinsAsync = function (nodeMap, binaryWriter) { + var _a; + var promiseChain = Promise.resolve(); + var skinMap = {}; + for (var _i = 0, _b = this._babylonScene.skeletons; _i < _b.length; _i++) { + var skeleton = _b[_i]; + if (skeleton.bones.length <= 0) { + continue; + } + // create skin + var skin = { joints: [] }; + var inverseBindMatrices = []; + var boneIndexMap = {}; + var maxBoneIndex = -1; + for (var i = 0; i < skeleton.bones.length; ++i) { + var bone = skeleton.bones[i]; + var boneIndex = (_a = bone.getIndex()) !== null && _a !== void 0 ? _a : i; + if (boneIndex !== -1) { + boneIndexMap[boneIndex] = bone; + if (boneIndex > maxBoneIndex) { + maxBoneIndex = boneIndex; + } + } + } + for (var boneIndex = 0; boneIndex <= maxBoneIndex; ++boneIndex) { + var bone = boneIndexMap[boneIndex]; + inverseBindMatrices.push(bone.getInvertedAbsoluteTransform()); + var transformNode = bone.getTransformNode(); + if (transformNode && nodeMap[transformNode.uniqueId] !== null && nodeMap[transformNode.uniqueId] !== undefined) { + skin.joints.push(nodeMap[transformNode.uniqueId]); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Exporting a bone without a linked transform node is currently unsupported"); + } + } + if (skin.joints.length > 0) { + // create buffer view for inverse bind matrices + var byteStride = 64; // 4 x 4 matrix of 32 bit float + var byteLength = inverseBindMatrices.length * byteStride; + var bufferViewOffset = binaryWriter.getByteOffset(); + var bufferView = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateBufferView(0, bufferViewOffset, byteLength, undefined, "InverseBindMatrices" + " - " + skeleton.name); + this._bufferViews.push(bufferView); + var bufferViewIndex = this._bufferViews.length - 1; + var bindMatrixAccessor = _glTFUtilities__WEBPACK_IMPORTED_MODULE_2__._GLTFUtilities._CreateAccessor(bufferViewIndex, "InverseBindMatrices" + " - " + skeleton.name, "MAT4" /* AccessorType.MAT4 */, 5126 /* AccessorComponentType.FLOAT */, inverseBindMatrices.length, null, null, null); + var inverseBindAccessorIndex = this._accessors.push(bindMatrixAccessor) - 1; + skin.inverseBindMatrices = inverseBindAccessorIndex; + this._skins.push(skin); + skinMap[skeleton.uniqueId] = this._skins.length - 1; + inverseBindMatrices.forEach(function (mat) { + mat.m.forEach(function (cell) { + binaryWriter.setFloat32(cell); + }); + }); + } + } + return promiseChain.then(function () { + return skinMap; + }); + }; + _Exporter._ExtensionNames = new Array(); + _Exporter._ExtensionFactories = {}; + return _Exporter; +}()); +/** + * @internal + * + * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically + */ +var _BinaryWriter = /** @class */ (function () { + /** + * Initialize binary writer with an initial byte length + * @param byteLength Initial byte length of the array buffer + */ + function _BinaryWriter(byteLength) { + this._arrayBuffer = new ArrayBuffer(byteLength); + this._dataView = new DataView(this._arrayBuffer); + this._byteOffset = 0; + } + /** + * Resize the array buffer to the specified byte length + * @param byteLength + */ + _BinaryWriter.prototype._resizeBuffer = function (byteLength) { + var newBuffer = new ArrayBuffer(byteLength); + var copyOldBufferSize = Math.min(this._arrayBuffer.byteLength, byteLength); + var oldUint8Array = new Uint8Array(this._arrayBuffer, 0, copyOldBufferSize); + var newUint8Array = new Uint8Array(newBuffer); + newUint8Array.set(oldUint8Array, 0); + this._arrayBuffer = newBuffer; + this._dataView = new DataView(this._arrayBuffer); + return newBuffer; + }; + /** + * Get an array buffer with the length of the byte offset + * @returns ArrayBuffer resized to the byte offset + */ + _BinaryWriter.prototype.getArrayBuffer = function () { + return this._resizeBuffer(this.getByteOffset()); + }; + /** + * Get the byte offset of the array buffer + * @returns byte offset + */ + _BinaryWriter.prototype.getByteOffset = function () { + if (this._byteOffset == undefined) { + throw new Error("Byte offset is undefined!"); + } + return this._byteOffset; + }; + /** + * Stores an UInt8 in the array buffer + * @param entry + * @param byteOffset If defined, specifies where to set the value as an offset. + */ + _BinaryWriter.prototype.setUInt8 = function (entry, byteOffset) { + if (byteOffset != null) { + if (byteOffset < this._byteOffset) { + this._dataView.setUint8(byteOffset, entry); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + } + else { + if (this._byteOffset + 1 > this._arrayBuffer.byteLength) { + this._resizeBuffer(this._arrayBuffer.byteLength * 2); + } + this._dataView.setUint8(this._byteOffset, entry); + this._byteOffset += 1; + } + }; + /** + * Stores an UInt16 in the array buffer + * @param entry + * @param byteOffset If defined, specifies where to set the value as an offset. + */ + _BinaryWriter.prototype.setUInt16 = function (entry, byteOffset) { + if (byteOffset != null) { + if (byteOffset < this._byteOffset) { + this._dataView.setUint16(byteOffset, entry, true); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + } + else { + if (this._byteOffset + 2 > this._arrayBuffer.byteLength) { + this._resizeBuffer(this._arrayBuffer.byteLength * 2); + } + this._dataView.setUint16(this._byteOffset, entry, true); + this._byteOffset += 2; + } + }; + /** + * Gets an UInt32 in the array buffer + * @param byteOffset If defined, specifies where to set the value as an offset. + */ + _BinaryWriter.prototype.getUInt32 = function (byteOffset) { + if (byteOffset < this._byteOffset) { + return this._dataView.getUint32(byteOffset, true); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + throw new Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + }; + _BinaryWriter.prototype.getVector3Float32FromRef = function (vector3, byteOffset) { + if (byteOffset + 8 > this._byteOffset) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + else { + vector3.x = this._dataView.getFloat32(byteOffset, true); + vector3.y = this._dataView.getFloat32(byteOffset + 4, true); + vector3.z = this._dataView.getFloat32(byteOffset + 8, true); + } + }; + _BinaryWriter.prototype.setVector3Float32FromRef = function (vector3, byteOffset) { + if (byteOffset + 8 > this._byteOffset) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + else { + this._dataView.setFloat32(byteOffset, vector3.x, true); + this._dataView.setFloat32(byteOffset + 4, vector3.y, true); + this._dataView.setFloat32(byteOffset + 8, vector3.z, true); + } + }; + _BinaryWriter.prototype.getVector4Float32FromRef = function (vector4, byteOffset) { + if (byteOffset + 12 > this._byteOffset) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + else { + vector4.x = this._dataView.getFloat32(byteOffset, true); + vector4.y = this._dataView.getFloat32(byteOffset + 4, true); + vector4.z = this._dataView.getFloat32(byteOffset + 8, true); + vector4.w = this._dataView.getFloat32(byteOffset + 12, true); + } + }; + _BinaryWriter.prototype.setVector4Float32FromRef = function (vector4, byteOffset) { + if (byteOffset + 12 > this._byteOffset) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + else { + this._dataView.setFloat32(byteOffset, vector4.x, true); + this._dataView.setFloat32(byteOffset + 4, vector4.y, true); + this._dataView.setFloat32(byteOffset + 8, vector4.z, true); + this._dataView.setFloat32(byteOffset + 12, vector4.w, true); + } + }; + /** + * Stores a Float32 in the array buffer + * @param entry + * @param byteOffset + */ + _BinaryWriter.prototype.setFloat32 = function (entry, byteOffset) { + if (isNaN(entry)) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("Invalid data being written!"); + } + if (byteOffset != null) { + if (byteOffset < this._byteOffset) { + this._dataView.setFloat32(byteOffset, entry, true); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary length!"); + } + } + if (this._byteOffset + 4 > this._arrayBuffer.byteLength) { + this._resizeBuffer(this._arrayBuffer.byteLength * 2); + } + this._dataView.setFloat32(this._byteOffset, entry, true); + this._byteOffset += 4; + }; + /** + * Stores an UInt32 in the array buffer + * @param entry + * @param byteOffset If defined, specifies where to set the value as an offset. + */ + _BinaryWriter.prototype.setUInt32 = function (entry, byteOffset) { + if (byteOffset != null) { + if (byteOffset < this._byteOffset) { + this._dataView.setUint32(byteOffset, entry, true); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + } + else { + if (this._byteOffset + 4 > this._arrayBuffer.byteLength) { + this._resizeBuffer(this._arrayBuffer.byteLength * 2); + } + this._dataView.setUint32(this._byteOffset, entry, true); + this._byteOffset += 4; + } + }; + /** + * Stores an Int16 in the array buffer + * @param entry + * @param byteOffset If defined, specifies where to set the value as an offset. + */ + _BinaryWriter.prototype.setInt16 = function (entry, byteOffset) { + if (byteOffset != null) { + if (byteOffset < this._byteOffset) { + this._dataView.setInt16(byteOffset, entry, true); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + } + else { + if (this._byteOffset + 2 > this._arrayBuffer.byteLength) { + this._resizeBuffer(this._arrayBuffer.byteLength * 2); + } + this._dataView.setInt16(this._byteOffset, entry, true); + this._byteOffset += 2; + } + }; + /** + * Stores a byte in the array buffer + * @param entry + * @param byteOffset If defined, specifies where to set the value as an offset. + */ + _BinaryWriter.prototype.setByte = function (entry, byteOffset) { + if (byteOffset != null) { + if (byteOffset < this._byteOffset) { + this._dataView.setInt8(byteOffset, entry); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"); + } + } + else { + if (this._byteOffset + 1 > this._arrayBuffer.byteLength) { + this._resizeBuffer(this._arrayBuffer.byteLength * 2); + } + this._dataView.setInt8(this._byteOffset, entry); + this._byteOffset++; + } + }; + return _BinaryWriter; +}()); + + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/glTFExporterExtension.ts": +/*!**********************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/glTFExporterExtension.ts ***! + \**********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ __IGLTFExporterExtensionV2: () => (/* binding */ __IGLTFExporterExtensionV2) +/* harmony export */ }); +/** @internal */ +// eslint-disable-next-line no-var, @typescript-eslint/naming-convention +var __IGLTFExporterExtensionV2 = 0; // I am here to allow dts to be created + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/glTFMaterialExporter.ts": +/*!*********************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/glTFMaterialExporter.ts ***! + \*********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ _GLTFMaterialExporter: () => (/* binding */ _GLTFMaterialExporter) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/dumpTools */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); + + + + + + + + + + +function getFileExtensionFromMimeType(mimeType) { + switch (mimeType) { + case "image/jpeg" /* ImageMimeType.JPEG */: + return ".jpg"; + case "image/png" /* ImageMimeType.PNG */: + return ".png"; + case "image/webp" /* ImageMimeType.WEBP */: + return ".webp"; + } +} +/** + * Utility methods for working with glTF material conversion properties. This class should only be used internally + * @internal + */ +var _GLTFMaterialExporter = /** @class */ (function () { + function _GLTFMaterialExporter(exporter) { + /** + * Mapping to store textures + */ + this._textureMap = {}; + // Mapping of internal textures to images to avoid exporting duplicate images. + this._internalTextureToImage = {}; + this._textureMap = {}; + this._exporter = exporter; + } + /** + * Specifies if two colors are approximately equal in value + * @param color1 first color to compare to + * @param color2 second color to compare to + * @param epsilon threshold value + */ + _GLTFMaterialExporter._FuzzyEquals = function (color1, color2, epsilon) { + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Scalar.WithinEpsilon(color1.r, color2.r, epsilon) && babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Scalar.WithinEpsilon(color1.g, color2.g, epsilon) && babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Scalar.WithinEpsilon(color1.b, color2.b, epsilon); + }; + /** + * Gets the materials from a Babylon scene and converts them to glTF materials + * @param exportMaterials + * @param mimeType texture mime type + * @param hasTextureCoords specifies if texture coordinates are present on the material + */ + _GLTFMaterialExporter.prototype._convertMaterialsToGLTFAsync = function (exportMaterials, mimeType, hasTextureCoords) { + var _this = this; + var promises = []; + exportMaterials.forEach(function (material) { + if (material.getClassName() === "StandardMaterial") { + promises.push(_this._convertStandardMaterialAsync(material, mimeType, hasTextureCoords)); + } + else if (material.getClassName().indexOf("PBR") !== -1) { + promises.push(_this._convertPBRMaterialAsync(material, mimeType, hasTextureCoords)); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Unsupported material type: ".concat(material.name)); + } + }); + return Promise.all(promises).then(function () { + /* do nothing */ + }); + }; + /** + * Makes a copy of the glTF material without the texture parameters + * @param originalMaterial original glTF material + * @returns glTF material without texture parameters + */ + _GLTFMaterialExporter.prototype._stripTexturesFromMaterial = function (originalMaterial) { + var newMaterial = {}; + if (originalMaterial) { + newMaterial.name = originalMaterial.name; + newMaterial.doubleSided = originalMaterial.doubleSided; + newMaterial.alphaMode = originalMaterial.alphaMode; + newMaterial.alphaCutoff = originalMaterial.alphaCutoff; + newMaterial.emissiveFactor = originalMaterial.emissiveFactor; + var originalPBRMetallicRoughness = originalMaterial.pbrMetallicRoughness; + if (originalPBRMetallicRoughness) { + newMaterial.pbrMetallicRoughness = {}; + newMaterial.pbrMetallicRoughness.baseColorFactor = originalPBRMetallicRoughness.baseColorFactor; + newMaterial.pbrMetallicRoughness.metallicFactor = originalPBRMetallicRoughness.metallicFactor; + newMaterial.pbrMetallicRoughness.roughnessFactor = originalPBRMetallicRoughness.roughnessFactor; + } + } + return newMaterial; + }; + /** + * Specifies if the material has any texture parameters present + * @param material glTF Material + * @returns boolean specifying if texture parameters are present + */ + _GLTFMaterialExporter.prototype._hasTexturesPresent = function (material) { + var _a; + if (material.emissiveTexture || material.normalTexture || material.occlusionTexture) { + return true; + } + var pbrMat = material.pbrMetallicRoughness; + if (pbrMat) { + if (pbrMat.baseColorTexture || pbrMat.metallicRoughnessTexture) { + return true; + } + } + if (material.extensions) { + for (var extension in material.extensions) { + var extensionObject = material.extensions[extension]; + if (extensionObject) { + return (_a = extensionObject.hasTextures) === null || _a === void 0 ? void 0 : _a.call(extensionObject); + } + } + } + return false; + }; + _GLTFMaterialExporter.prototype._getTextureInfo = function (babylonTexture) { + if (babylonTexture) { + var textureUid = babylonTexture.uid; + if (textureUid in this._textureMap) { + return this._textureMap[textureUid]; + } + } + return null; + }; + /** + * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material + * @param babylonStandardMaterial + * @returns glTF Metallic Roughness Material representation + */ + _GLTFMaterialExporter.prototype._convertToGLTFPBRMetallicRoughness = function (babylonStandardMaterial) { + // Defines a cubic bezier curve where x is specular power and y is roughness + var P0 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2(0, 1); + var P1 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2(0, 0.1); + var P2 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2(0, 0.1); + var P3 = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector2(1300, 0.1); + /** + * Given the control points, solve for x based on a given t for a cubic bezier curve + * @param t a value between 0 and 1 + * @param p0 first control point + * @param p1 second control point + * @param p2 third control point + * @param p3 fourth control point + * @returns number result of cubic bezier curve at the specified t + */ + function cubicBezierCurve(t, p0, p1, p2, p3) { + return (1 - t) * (1 - t) * (1 - t) * p0 + 3 * (1 - t) * (1 - t) * t * p1 + 3 * (1 - t) * t * t * p2 + t * t * t * p3; + } + /** + * Evaluates a specified specular power value to determine the appropriate roughness value, + * based on a pre-defined cubic bezier curve with specular on the abscissa axis (x-axis) + * and roughness on the ordinant axis (y-axis) + * @param specularPower specular power of standard material + * @returns Number representing the roughness value + */ + function solveForRoughness(specularPower) { + // Given P0.x = 0, P1.x = 0, P2.x = 0 + // x = t * t * t * P3.x + // t = (x / P3.x)^(1/3) + var t = Math.pow(specularPower / P3.x, 0.333333); + return cubicBezierCurve(t, P0.y, P1.y, P2.y, P3.y); + } + var diffuse = babylonStandardMaterial.diffuseColor.toLinearSpace(babylonStandardMaterial.getScene().getEngine().useExactSrgbConversions).scale(0.5); + var opacity = babylonStandardMaterial.alpha; + var specularPower = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Scalar.Clamp(babylonStandardMaterial.specularPower, 0, _GLTFMaterialExporter._MaxSpecularPower); + var roughness = solveForRoughness(specularPower); + var glTFPbrMetallicRoughness = { + baseColorFactor: [diffuse.r, diffuse.g, diffuse.b, opacity], + metallicFactor: 0, + roughnessFactor: roughness, + }; + return glTFPbrMetallicRoughness; + }; + /** + * Computes the metallic factor + * @param diffuse diffused value + * @param specular specular value + * @param oneMinusSpecularStrength one minus the specular strength + * @returns metallic value + */ + _GLTFMaterialExporter._SolveMetallic = function (diffuse, specular, oneMinusSpecularStrength) { + if (specular < this._DielectricSpecular.r) { + this._DielectricSpecular; + return 0; + } + var a = this._DielectricSpecular.r; + var b = (diffuse * oneMinusSpecularStrength) / (1.0 - this._DielectricSpecular.r) + specular - 2.0 * this._DielectricSpecular.r; + var c = this._DielectricSpecular.r - specular; + var D = b * b - 4.0 * a * c; + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Scalar.Clamp((-b + Math.sqrt(D)) / (2.0 * a), 0, 1); + }; + /** + * Sets the glTF alpha mode to a glTF material from the Babylon Material + * @param glTFMaterial glTF material + * @param babylonMaterial Babylon material + */ + _GLTFMaterialExporter._SetAlphaMode = function (glTFMaterial, babylonMaterial) { + if (babylonMaterial.needAlphaBlending()) { + glTFMaterial.alphaMode = "BLEND" /* MaterialAlphaMode.BLEND */; + } + else if (babylonMaterial.needAlphaTesting()) { + glTFMaterial.alphaMode = "MASK" /* MaterialAlphaMode.MASK */; + glTFMaterial.alphaCutoff = babylonMaterial.alphaCutOff; + } + }; + /** + * Converts a Babylon Standard Material to a glTF Material + * @param babylonStandardMaterial BJS Standard Material + * @param mimeType mime type to use for the textures + * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied + */ + _GLTFMaterialExporter.prototype._convertStandardMaterialAsync = function (babylonStandardMaterial, mimeType, hasTextureCoords) { + var materialMap = this._exporter._materialMap; + var materials = this._exporter._materials; + var promises = []; + var pbrMetallicRoughness = this._convertToGLTFPBRMetallicRoughness(babylonStandardMaterial); + var material = { name: babylonStandardMaterial.name }; + if (babylonStandardMaterial.backFaceCulling != null && !babylonStandardMaterial.backFaceCulling) { + if (!babylonStandardMaterial.twoSidedLighting) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn(babylonStandardMaterial.name + ": Back-face culling disabled and two-sided lighting disabled is not supported in glTF."); + } + material.doubleSided = true; + } + if (hasTextureCoords) { + if (babylonStandardMaterial.diffuseTexture) { + promises.push(this._exportTextureAsync(babylonStandardMaterial.diffuseTexture, mimeType).then(function (textureInfo) { + if (textureInfo) { + pbrMetallicRoughness.baseColorTexture = textureInfo; + } + })); + } + var bumpTexture_1 = babylonStandardMaterial.bumpTexture; + if (bumpTexture_1) { + promises.push(this._exportTextureAsync(bumpTexture_1, mimeType).then(function (textureInfo) { + if (textureInfo) { + material.normalTexture = textureInfo; + if (bumpTexture_1.level !== 1) { + material.normalTexture.scale = bumpTexture_1.level; + } + } + })); + } + if (babylonStandardMaterial.emissiveTexture) { + material.emissiveFactor = [1.0, 1.0, 1.0]; + promises.push(this._exportTextureAsync(babylonStandardMaterial.emissiveTexture, mimeType).then(function (textureInfo) { + if (textureInfo) { + material.emissiveTexture = textureInfo; + } + })); + } + if (babylonStandardMaterial.ambientTexture) { + promises.push(this._exportTextureAsync(babylonStandardMaterial.ambientTexture, mimeType).then(function (textureInfo) { + if (textureInfo) { + var occlusionTexture = { + index: textureInfo.index, + }; + material.occlusionTexture = occlusionTexture; + } + })); + } + } + if (babylonStandardMaterial.alpha < 1.0 || babylonStandardMaterial.opacityTexture) { + if (babylonStandardMaterial.alphaMode === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Constants.ALPHA_COMBINE) { + material.alphaMode = "BLEND" /* MaterialAlphaMode.BLEND */; + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn(babylonStandardMaterial.name + ": glTF 2.0 does not support alpha mode: " + babylonStandardMaterial.alphaMode.toString()); + } + } + if (babylonStandardMaterial.emissiveColor && !_GLTFMaterialExporter._FuzzyEquals(babylonStandardMaterial.emissiveColor, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.Black(), _GLTFMaterialExporter._Epsilon)) { + material.emissiveFactor = babylonStandardMaterial.emissiveColor.asArray(); + } + material.pbrMetallicRoughness = pbrMetallicRoughness; + _GLTFMaterialExporter._SetAlphaMode(material, babylonStandardMaterial); + materials.push(material); + materialMap[babylonStandardMaterial.uniqueId] = materials.length - 1; + return this._finishMaterial(promises, material, babylonStandardMaterial, mimeType); + }; + _GLTFMaterialExporter.prototype._finishMaterial = function (promises, glTFMaterial, babylonMaterial, mimeType) { + var _this = this; + return Promise.all(promises).then(function () { + var textures = _this._exporter._extensionsPostExportMaterialAdditionalTextures("exportMaterial", glTFMaterial, babylonMaterial); + var tasks = null; + for (var _i = 0, textures_1 = textures; _i < textures_1.length; _i++) { + var texture = textures_1[_i]; + if (!tasks) { + tasks = []; + } + tasks.push(_this._exportTextureAsync(texture, mimeType)); + } + if (!tasks) { + tasks = [Promise.resolve(null)]; + } + return Promise.all(tasks).then(function () { + var extensionWork = _this._exporter._extensionsPostExportMaterialAsync("exportMaterial", glTFMaterial, babylonMaterial); + if (!extensionWork) { + return glTFMaterial; + } + return extensionWork.then(function () { return glTFMaterial; }); + }); + }); + }; + /** + * Converts an image typed array buffer to a base64 image + * @param buffer typed array buffer + * @param width width of the image + * @param height height of the image + * @param mimeType mimetype of the image + * @returns base64 image string + */ + _GLTFMaterialExporter.prototype._getImageDataAsync = function (buffer, width, height, mimeType) { + return (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__awaiter)(this, void 0, void 0, function () { + var textureType, hostingScene, engine, tempTexture, data; + return (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__generator)(this, function (_a) { + switch (_a.label) { + case 0: + textureType = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Constants.TEXTURETYPE_UNSIGNED_INT; + hostingScene = this._exporter._babylonScene; + engine = hostingScene.getEngine(); + tempTexture = engine.createRawTexture(buffer, width, height, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Constants.TEXTUREFORMAT_RGBA, false, true, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_SAMPLINGMODE, null, textureType); + return [4 /*yield*/, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TextureTools.ApplyPostProcess("pass", tempTexture, hostingScene, textureType, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Constants.TEXTURE_NEAREST_SAMPLINGMODE, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Constants.TEXTUREFORMAT_RGBA)]; + case 1: + _a.sent(); + return [4 /*yield*/, engine._readTexturePixels(tempTexture, width, height)]; + case 2: + data = _a.sent(); + return [4 /*yield*/, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.DumpTools.DumpDataAsync(width, height, data, mimeType, undefined, true, true)]; + case 3: return [2 /*return*/, (_a.sent())]; + } + }); + }); + }; + /** + * Generates a white texture based on the specified width and height + * @param width width of the texture in pixels + * @param height height of the texture in pixels + * @param scene babylonjs scene + * @returns white texture + */ + _GLTFMaterialExporter.prototype._createWhiteTexture = function (width, height, scene) { + var data = new Uint8Array(width * height * 4); + for (var i = 0; i < data.length; i = i + 4) { + data[i] = data[i + 1] = data[i + 2] = data[i + 3] = 0xff; + } + var rawTexture = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.RawTexture.CreateRGBATexture(data, width, height, scene); + return rawTexture; + }; + /** + * Resizes the two source textures to the same dimensions. If a texture is null, a default white texture is generated. If both textures are null, returns null + * @param texture1 first texture to resize + * @param texture2 second texture to resize + * @param scene babylonjs scene + * @returns resized textures or null + */ + _GLTFMaterialExporter.prototype._resizeTexturesToSameDimensions = function (texture1, texture2, scene) { + var texture1Size = texture1 ? texture1.getSize() : { width: 0, height: 0 }; + var texture2Size = texture2 ? texture2.getSize() : { width: 0, height: 0 }; + var resizedTexture1; + var resizedTexture2; + if (texture1Size.width < texture2Size.width) { + if (texture1 && texture1 instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture) { + resizedTexture1 = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TextureTools.CreateResizedCopy(texture1, texture2Size.width, texture2Size.height, true); + } + else { + resizedTexture1 = this._createWhiteTexture(texture2Size.width, texture2Size.height, scene); + } + resizedTexture2 = texture2; + } + else if (texture1Size.width > texture2Size.width) { + if (texture2 && texture2 instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture) { + resizedTexture2 = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TextureTools.CreateResizedCopy(texture2, texture1Size.width, texture1Size.height, true); + } + else { + resizedTexture2 = this._createWhiteTexture(texture1Size.width, texture1Size.height, scene); + } + resizedTexture1 = texture1; + } + else { + resizedTexture1 = texture1; + resizedTexture2 = texture2; + } + return { + texture1: resizedTexture1, + texture2: resizedTexture2, + }; + }; + /** + * Converts an array of pixels to a Float32Array + * Throws an error if the pixel format is not supported + * @param pixels - array buffer containing pixel values + * @returns Float32 of pixels + */ + _GLTFMaterialExporter.prototype._convertPixelArrayToFloat32 = function (pixels) { + if (pixels instanceof Uint8Array) { + var length_1 = pixels.length; + var buffer = new Float32Array(pixels.length); + for (var i = 0; i < length_1; ++i) { + buffer[i] = pixels[i] / 255; + } + return buffer; + } + else if (pixels instanceof Float32Array) { + return pixels; + } + else { + throw new Error("Unsupported pixel format!"); + } + }; + /** + * Convert Specular Glossiness Textures to Metallic Roughness + * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness + * @link https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js + * @param diffuseTexture texture used to store diffuse information + * @param specularGlossinessTexture texture used to store specular and glossiness information + * @param factors specular glossiness material factors + * @param mimeType the mime type to use for the texture + * @returns pbr metallic roughness interface or null + */ + _GLTFMaterialExporter.prototype._convertSpecularGlossinessTexturesToMetallicRoughnessAsync = function (diffuseTexture, specularGlossinessTexture, factors, mimeType) { + var _a; + return (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__awaiter)(this, void 0, void 0, function () { + var promises, scene, resizedTextures, diffuseSize, diffuseBuffer, specularGlossinessBuffer, width, height, diffusePixels, specularPixels, byteLength, metallicRoughnessBuffer, baseColorBuffer, strideSize, maxBaseColor, maxMetallic, maxRoughness, h, w, offset, diffuseColor, specularColor, glossiness, specularGlossiness, metallicRoughness, metallicRoughnessFactors_1, writeOutMetallicRoughnessTexture, writeOutBaseColorTexture, h, w, destinationOffset, linearBaseColorPixel, sRGBBaseColorPixel, metallicRoughnessPixel; + return (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__generator)(this, function (_b) { + switch (_b.label) { + case 0: + promises = new Array(); + if (!(diffuseTexture || specularGlossinessTexture)) { + return [2 /*return*/, Promise.reject("_ConvertSpecularGlosinessTexturesToMetallicRoughness: diffuse and specular glossiness textures are not defined!")]; + } + scene = diffuseTexture ? diffuseTexture.getScene() : specularGlossinessTexture ? specularGlossinessTexture.getScene() : null; + if (!scene) return [3 /*break*/, 3]; + resizedTextures = this._resizeTexturesToSameDimensions(diffuseTexture, specularGlossinessTexture, scene); + diffuseSize = (_a = resizedTextures.texture1) === null || _a === void 0 ? void 0 : _a.getSize(); + diffuseBuffer = void 0; + specularGlossinessBuffer = void 0; + width = diffuseSize.width; + height = diffuseSize.height; + return [4 /*yield*/, resizedTextures.texture1.readPixels()]; + case 1: + diffusePixels = _b.sent(); + return [4 /*yield*/, resizedTextures.texture2.readPixels()]; + case 2: + specularPixels = _b.sent(); + if (diffusePixels) { + diffuseBuffer = this._convertPixelArrayToFloat32(diffusePixels); + } + else { + return [2 /*return*/, Promise.reject("Failed to retrieve pixels from diffuse texture!")]; + } + if (specularPixels) { + specularGlossinessBuffer = this._convertPixelArrayToFloat32(specularPixels); + } + else { + return [2 /*return*/, Promise.reject("Failed to retrieve pixels from specular glossiness texture!")]; + } + byteLength = specularGlossinessBuffer.byteLength; + metallicRoughnessBuffer = new Uint8Array(byteLength); + baseColorBuffer = new Uint8Array(byteLength); + strideSize = 4; + maxBaseColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.Black(); + maxMetallic = 0; + maxRoughness = 0; + for (h = 0; h < height; ++h) { + for (w = 0; w < width; ++w) { + offset = (width * h + w) * strideSize; + diffuseColor = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3(diffuseBuffer[offset], diffuseBuffer[offset + 1], diffuseBuffer[offset + 2]) + .toLinearSpace(scene.getEngine().useExactSrgbConversions) + .multiply(factors.diffuseColor); + specularColor = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3(specularGlossinessBuffer[offset], specularGlossinessBuffer[offset + 1], specularGlossinessBuffer[offset + 2]) + .toLinearSpace(scene.getEngine().useExactSrgbConversions) + .multiply(factors.specularColor); + glossiness = specularGlossinessBuffer[offset + 3] * factors.glossiness; + specularGlossiness = { + diffuseColor: diffuseColor, + specularColor: specularColor, + glossiness: glossiness, + }; + metallicRoughness = this._convertSpecularGlossinessToMetallicRoughness(specularGlossiness); + maxBaseColor.r = Math.max(maxBaseColor.r, metallicRoughness.baseColor.r); + maxBaseColor.g = Math.max(maxBaseColor.g, metallicRoughness.baseColor.g); + maxBaseColor.b = Math.max(maxBaseColor.b, metallicRoughness.baseColor.b); + maxMetallic = Math.max(maxMetallic, metallicRoughness.metallic); + maxRoughness = Math.max(maxRoughness, metallicRoughness.roughness); + baseColorBuffer[offset] = metallicRoughness.baseColor.r * 255; + baseColorBuffer[offset + 1] = metallicRoughness.baseColor.g * 255; + baseColorBuffer[offset + 2] = metallicRoughness.baseColor.b * 255; + baseColorBuffer[offset + 3] = resizedTextures.texture1.hasAlpha ? diffuseBuffer[offset + 3] * 255 : 255; + metallicRoughnessBuffer[offset] = 0; + metallicRoughnessBuffer[offset + 1] = metallicRoughness.roughness * 255; + metallicRoughnessBuffer[offset + 2] = metallicRoughness.metallic * 255; + metallicRoughnessBuffer[offset + 3] = 255; + } + } + metallicRoughnessFactors_1 = { + baseColor: maxBaseColor, + metallic: maxMetallic, + roughness: maxRoughness, + }; + writeOutMetallicRoughnessTexture = false; + writeOutBaseColorTexture = false; + for (h = 0; h < height; ++h) { + for (w = 0; w < width; ++w) { + destinationOffset = (width * h + w) * strideSize; + baseColorBuffer[destinationOffset] /= metallicRoughnessFactors_1.baseColor.r > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors_1.baseColor.r : 1; + baseColorBuffer[destinationOffset + 1] /= metallicRoughnessFactors_1.baseColor.g > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors_1.baseColor.g : 1; + baseColorBuffer[destinationOffset + 2] /= metallicRoughnessFactors_1.baseColor.b > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors_1.baseColor.b : 1; + linearBaseColorPixel = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.FromInts(baseColorBuffer[destinationOffset], baseColorBuffer[destinationOffset + 1], baseColorBuffer[destinationOffset + 2]); + sRGBBaseColorPixel = linearBaseColorPixel.toGammaSpace(scene.getEngine().useExactSrgbConversions); + baseColorBuffer[destinationOffset] = sRGBBaseColorPixel.r * 255; + baseColorBuffer[destinationOffset + 1] = sRGBBaseColorPixel.g * 255; + baseColorBuffer[destinationOffset + 2] = sRGBBaseColorPixel.b * 255; + if (!_GLTFMaterialExporter._FuzzyEquals(sRGBBaseColorPixel, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.White(), _GLTFMaterialExporter._Epsilon)) { + writeOutBaseColorTexture = true; + } + metallicRoughnessBuffer[destinationOffset + 1] /= + metallicRoughnessFactors_1.roughness > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors_1.roughness : 1; + metallicRoughnessBuffer[destinationOffset + 2] /= metallicRoughnessFactors_1.metallic > _GLTFMaterialExporter._Epsilon ? metallicRoughnessFactors_1.metallic : 1; + metallicRoughnessPixel = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.FromInts(255, metallicRoughnessBuffer[destinationOffset + 1], metallicRoughnessBuffer[destinationOffset + 2]); + if (!_GLTFMaterialExporter._FuzzyEquals(metallicRoughnessPixel, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.White(), _GLTFMaterialExporter._Epsilon)) { + writeOutMetallicRoughnessTexture = true; + } + } + } + if (writeOutMetallicRoughnessTexture) { + promises.push(this._getImageDataAsync(metallicRoughnessBuffer, width, height, mimeType).then(function (data) { + metallicRoughnessFactors_1.metallicRoughnessTextureData = data; + })); + } + if (writeOutBaseColorTexture) { + promises.push(this._getImageDataAsync(baseColorBuffer, width, height, mimeType).then(function (data) { + metallicRoughnessFactors_1.baseColorTextureData = data; + })); + } + return [2 /*return*/, Promise.all(promises).then(function () { + return metallicRoughnessFactors_1; + })]; + case 3: return [2 /*return*/, Promise.reject("_ConvertSpecularGlossinessTexturesToMetallicRoughness: Scene from textures is missing!")]; + } + }); + }); + }; + /** + * Converts specular glossiness material properties to metallic roughness + * @param specularGlossiness interface with specular glossiness material properties + * @returns interface with metallic roughness material properties + */ + _GLTFMaterialExporter.prototype._convertSpecularGlossinessToMetallicRoughness = function (specularGlossiness) { + var diffusePerceivedBrightness = this._getPerceivedBrightness(specularGlossiness.diffuseColor); + var specularPerceivedBrightness = this._getPerceivedBrightness(specularGlossiness.specularColor); + var oneMinusSpecularStrength = 1 - this._getMaxComponent(specularGlossiness.specularColor); + var metallic = _GLTFMaterialExporter._SolveMetallic(diffusePerceivedBrightness, specularPerceivedBrightness, oneMinusSpecularStrength); + var baseColorFromDiffuse = specularGlossiness.diffuseColor.scale(oneMinusSpecularStrength / (1.0 - _GLTFMaterialExporter._DielectricSpecular.r) / Math.max(1 - metallic, _GLTFMaterialExporter._Epsilon)); + var baseColorFromSpecular = specularGlossiness.specularColor + .subtract(_GLTFMaterialExporter._DielectricSpecular.scale(1 - metallic)) + .scale(1 / Math.max(metallic, _GLTFMaterialExporter._Epsilon)); + var baseColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.Lerp(baseColorFromDiffuse, baseColorFromSpecular, metallic * metallic); + baseColor = baseColor.clampToRef(0, 1, baseColor); + var metallicRoughness = { + baseColor: baseColor, + metallic: metallic, + roughness: 1 - specularGlossiness.glossiness, + }; + return metallicRoughness; + }; + /** + * Calculates the surface reflectance, independent of lighting conditions + * @param color Color source to calculate brightness from + * @returns number representing the perceived brightness, or zero if color is undefined + */ + _GLTFMaterialExporter.prototype._getPerceivedBrightness = function (color) { + if (color) { + return Math.sqrt(0.299 * color.r * color.r + 0.587 * color.g * color.g + 0.114 * color.b * color.b); + } + return 0; + }; + /** + * Returns the maximum color component value + * @param color + * @returns maximum color component value, or zero if color is null or undefined + */ + _GLTFMaterialExporter.prototype._getMaxComponent = function (color) { + if (color) { + return Math.max(color.r, Math.max(color.g, color.b)); + } + return 0; + }; + /** + * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors + * @param babylonPBRMaterial BJS PBR Metallic Roughness Material + * @param mimeType mime type to use for the textures + * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface + * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied + * @returns glTF PBR Metallic Roughness factors + */ + _GLTFMaterialExporter.prototype._convertMetalRoughFactorsToMetallicRoughnessAsync = function (babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords) { + var promises = []; + var baseColor = babylonPBRMaterial._albedoColor; + var metallic = babylonPBRMaterial._metallic; + var roughness = babylonPBRMaterial._roughness; + var metallicRoughness = { + baseColor: baseColor, + metallic: metallic, + roughness: roughness, + }; + if (hasTextureCoords) { + var albedoTexture = babylonPBRMaterial._albedoTexture; + if (albedoTexture) { + promises.push(this._exportTextureAsync(babylonPBRMaterial._albedoTexture, mimeType).then(function (glTFTexture) { + if (glTFTexture) { + glTFPbrMetallicRoughness.baseColorTexture = glTFTexture; + } + })); + } + var metallicTexture = babylonPBRMaterial._metallicTexture; + if (metallicTexture) { + promises.push(this._exportTextureAsync(metallicTexture, mimeType).then(function (glTFTexture) { + if (glTFTexture) { + glTFPbrMetallicRoughness.metallicRoughnessTexture = glTFTexture; + } + })); + } + } + return Promise.all(promises).then(function () { + return metallicRoughness; + }); + }; + _GLTFMaterialExporter.prototype._getTextureSampler = function (texture) { + var sampler = {}; + if (!texture || !(texture instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture)) { + return sampler; + } + var wrapS = this._getGLTFTextureWrapMode(texture.wrapU); + if (wrapS !== 10497 /* TextureWrapMode.REPEAT */) { + sampler.wrapS = wrapS; + } + var wrapT = this._getGLTFTextureWrapMode(texture.wrapV); + if (wrapT !== 10497 /* TextureWrapMode.REPEAT */) { + sampler.wrapT = wrapT; + } + switch (texture.samplingMode) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR: { + sampler.magFilter = 9729 /* TextureMagFilter.LINEAR */; + sampler.minFilter = 9729 /* TextureMinFilter.LINEAR */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST: { + sampler.magFilter = 9729 /* TextureMagFilter.LINEAR */; + sampler.minFilter = 9728 /* TextureMinFilter.NEAREST */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR: { + sampler.magFilter = 9728 /* TextureMagFilter.NEAREST */; + sampler.minFilter = 9729 /* TextureMinFilter.LINEAR */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR_MIPLINEAR: { + sampler.magFilter = 9728 /* TextureMagFilter.NEAREST */; + sampler.minFilter = 9987 /* TextureMinFilter.LINEAR_MIPMAP_LINEAR */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST: { + sampler.magFilter = 9728 /* TextureMagFilter.NEAREST */; + sampler.minFilter = 9728 /* TextureMinFilter.NEAREST */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR_MIPNEAREST: { + sampler.magFilter = 9728 /* TextureMagFilter.NEAREST */; + sampler.minFilter = 9985 /* TextureMinFilter.LINEAR_MIPMAP_NEAREST */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST_MIPNEAREST: { + sampler.magFilter = 9729 /* TextureMagFilter.LINEAR */; + sampler.minFilter = 9984 /* TextureMinFilter.NEAREST_MIPMAP_NEAREST */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST_MIPLINEAR: { + sampler.magFilter = 9729 /* TextureMagFilter.LINEAR */; + sampler.minFilter = 9986 /* TextureMinFilter.NEAREST_MIPMAP_LINEAR */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPLINEAR: { + sampler.magFilter = 9728 /* TextureMagFilter.NEAREST */; + sampler.minFilter = 9986 /* TextureMinFilter.NEAREST_MIPMAP_LINEAR */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPLINEAR: { + sampler.magFilter = 9729 /* TextureMagFilter.LINEAR */; + sampler.minFilter = 9987 /* TextureMinFilter.LINEAR_MIPMAP_LINEAR */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPNEAREST: { + sampler.magFilter = 9729 /* TextureMagFilter.LINEAR */; + sampler.minFilter = 9985 /* TextureMinFilter.LINEAR_MIPMAP_NEAREST */; + break; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPNEAREST: { + sampler.magFilter = 9728 /* TextureMagFilter.NEAREST */; + sampler.minFilter = 9984 /* TextureMinFilter.NEAREST_MIPMAP_NEAREST */; + break; + } + } + return sampler; + }; + _GLTFMaterialExporter.prototype._getGLTFTextureWrapMode = function (wrapMode) { + switch (wrapMode) { + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.WRAP_ADDRESSMODE: { + return 10497 /* TextureWrapMode.REPEAT */; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.CLAMP_ADDRESSMODE: { + return 33071 /* TextureWrapMode.CLAMP_TO_EDGE */; + } + case babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Texture.MIRROR_ADDRESSMODE: { + return 33648 /* TextureWrapMode.MIRRORED_REPEAT */; + } + default: { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Error("Unsupported Texture Wrap Mode ".concat(wrapMode, "!")); + return 10497 /* TextureWrapMode.REPEAT */; + } + } + }; + /** + * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors + * @param babylonPBRMaterial BJS PBR Metallic Roughness Material + * @param mimeType mime type to use for the textures + * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface + * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied + * @returns glTF PBR Metallic Roughness factors + */ + _GLTFMaterialExporter.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync = function (babylonPBRMaterial, mimeType, pbrMetallicRoughness, hasTextureCoords) { + var _this = this; + return Promise.resolve().then(function () { + var specGloss = { + diffuseColor: babylonPBRMaterial._albedoColor, + specularColor: babylonPBRMaterial._reflectivityColor, + glossiness: babylonPBRMaterial._microSurface, + }; + var albedoTexture = babylonPBRMaterial._albedoTexture; + var reflectivityTexture = babylonPBRMaterial._reflectivityTexture; + var useMicrosurfaceFromReflectivityMapAlpha = babylonPBRMaterial._useMicroSurfaceFromReflectivityMapAlpha; + if (reflectivityTexture && !useMicrosurfaceFromReflectivityMapAlpha) { + return Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported"); + } + if ((albedoTexture || reflectivityTexture) && hasTextureCoords) { + var samplerIndex_1 = _this._exportTextureSampler(albedoTexture || reflectivityTexture); + return _this._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(albedoTexture, reflectivityTexture, specGloss, mimeType).then(function (metallicRoughnessFactors) { + var textures = _this._exporter._textures; + if (metallicRoughnessFactors.baseColorTextureData) { + var imageIndex = _this._exportImage("baseColor".concat(textures.length), mimeType, metallicRoughnessFactors.baseColorTextureData); + pbrMetallicRoughness.baseColorTexture = _this._exportTextureInfo(imageIndex, samplerIndex_1, albedoTexture === null || albedoTexture === void 0 ? void 0 : albedoTexture.coordinatesIndex); + } + if (metallicRoughnessFactors.metallicRoughnessTextureData) { + var imageIndex = _this._exportImage("metallicRoughness".concat(textures.length), mimeType, metallicRoughnessFactors.metallicRoughnessTextureData); + pbrMetallicRoughness.metallicRoughnessTexture = _this._exportTextureInfo(imageIndex, samplerIndex_1, reflectivityTexture === null || reflectivityTexture === void 0 ? void 0 : reflectivityTexture.coordinatesIndex); + } + return metallicRoughnessFactors; + }); + } + else { + return _this._convertSpecularGlossinessToMetallicRoughness(specGloss); + } + }); + }; + /** + * Converts a Babylon PBR Base Material to a glTF Material + * @param babylonPBRMaterial BJS PBR Base Material + * @param mimeType mime type to use for the textures + * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied + */ + _GLTFMaterialExporter.prototype._convertPBRMaterialAsync = function (babylonPBRMaterial, mimeType, hasTextureCoords) { + var _this = this; + var glTFPbrMetallicRoughness = {}; + var glTFMaterial = { + name: babylonPBRMaterial.name, + }; + var useMetallicRoughness = babylonPBRMaterial.isMetallicWorkflow(); + if (useMetallicRoughness) { + var albedoColor = babylonPBRMaterial._albedoColor; + var alpha = babylonPBRMaterial.alpha; + if (albedoColor) { + glTFPbrMetallicRoughness.baseColorFactor = [albedoColor.r, albedoColor.g, albedoColor.b, alpha]; + } + return this._convertMetalRoughFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords).then(function (metallicRoughness) { + return _this._setMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, hasTextureCoords); + }); + } + else { + return this._convertSpecGlossFactorsToMetallicRoughnessAsync(babylonPBRMaterial, mimeType, glTFPbrMetallicRoughness, hasTextureCoords).then(function (metallicRoughness) { + return _this._setMetallicRoughnessPbrMaterial(metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, hasTextureCoords); + }); + } + }; + _GLTFMaterialExporter.prototype._setMetallicRoughnessPbrMaterial = function (metallicRoughness, babylonPBRMaterial, glTFMaterial, glTFPbrMetallicRoughness, mimeType, hasTextureCoords) { + var materialMap = this._exporter._materialMap; + var materials = this._exporter._materials; + var promises = []; + if (metallicRoughness) { + _GLTFMaterialExporter._SetAlphaMode(glTFMaterial, babylonPBRMaterial); + if (!(_GLTFMaterialExporter._FuzzyEquals(metallicRoughness.baseColor, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.White(), _GLTFMaterialExporter._Epsilon) && + babylonPBRMaterial.alpha >= _GLTFMaterialExporter._Epsilon)) { + glTFPbrMetallicRoughness.baseColorFactor = [metallicRoughness.baseColor.r, metallicRoughness.baseColor.g, metallicRoughness.baseColor.b, babylonPBRMaterial.alpha]; + } + if (metallicRoughness.metallic != null && metallicRoughness.metallic !== 1) { + glTFPbrMetallicRoughness.metallicFactor = metallicRoughness.metallic; + } + if (metallicRoughness.roughness != null && metallicRoughness.roughness !== 1) { + glTFPbrMetallicRoughness.roughnessFactor = metallicRoughness.roughness; + } + if (babylonPBRMaterial.backFaceCulling != null && !babylonPBRMaterial.backFaceCulling) { + if (!babylonPBRMaterial._twoSidedLighting) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn(babylonPBRMaterial.name + ": Back-face culling disabled and two-sided lighting disabled is not supported in glTF."); + } + glTFMaterial.doubleSided = true; + } + if (hasTextureCoords) { + var bumpTexture_2 = babylonPBRMaterial._bumpTexture; + if (bumpTexture_2) { + var promise = this._exportTextureAsync(bumpTexture_2, mimeType).then(function (glTFTexture) { + if (glTFTexture) { + glTFMaterial.normalTexture = glTFTexture; + if (bumpTexture_2.level !== 1) { + glTFMaterial.normalTexture.scale = bumpTexture_2.level; + } + } + }); + promises.push(promise); + } + var ambientTexture = babylonPBRMaterial._ambientTexture; + if (ambientTexture) { + var promise = this._exportTextureAsync(ambientTexture, mimeType).then(function (glTFTexture) { + if (glTFTexture) { + var occlusionTexture = { + index: glTFTexture.index, + texCoord: glTFTexture.texCoord, + extensions: glTFTexture.extensions, + }; + glTFMaterial.occlusionTexture = occlusionTexture; + var ambientTextureStrength = babylonPBRMaterial._ambientTextureStrength; + if (ambientTextureStrength) { + occlusionTexture.strength = ambientTextureStrength; + } + } + }); + promises.push(promise); + } + var emissiveTexture = babylonPBRMaterial._emissiveTexture; + if (emissiveTexture) { + var promise = this._exportTextureAsync(emissiveTexture, mimeType).then(function (glTFTexture) { + if (glTFTexture) { + glTFMaterial.emissiveTexture = glTFTexture; + } + }); + promises.push(promise); + } + } + var emissiveColor = babylonPBRMaterial._emissiveColor; + if (!_GLTFMaterialExporter._FuzzyEquals(emissiveColor, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.Black(), _GLTFMaterialExporter._Epsilon)) { + glTFMaterial.emissiveFactor = emissiveColor.asArray(); + } + glTFMaterial.pbrMetallicRoughness = glTFPbrMetallicRoughness; + materials.push(glTFMaterial); + materialMap[babylonPBRMaterial.uniqueId] = materials.length - 1; + } + return this._finishMaterial(promises, glTFMaterial, babylonPBRMaterial, mimeType); + }; + _GLTFMaterialExporter.prototype._getPixelsFromTexture = function (babylonTexture) { + var pixels = babylonTexture.textureType === babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Constants.TEXTURETYPE_UNSIGNED_INT + ? babylonTexture.readPixels() + : babylonTexture.readPixels(); + return pixels; + }; + /** + * Extracts a texture from a Babylon texture into file data and glTF data + * @param babylonTexture Babylon texture to extract + * @param mimeType Mime Type of the babylonTexture + * @returns glTF texture info, or null if the texture format is not supported + */ + _GLTFMaterialExporter.prototype._exportTextureAsync = function (babylonTexture, mimeType) { + var _this = this; + var extensionPromise = this._exporter._extensionsPreExportTextureAsync("exporter", babylonTexture, mimeType); + if (!extensionPromise) { + return this._exportTextureInfoAsync(babylonTexture, mimeType); + } + return extensionPromise.then(function (texture) { + if (!texture) { + return _this._exportTextureInfoAsync(babylonTexture, mimeType); + } + return _this._exportTextureInfoAsync(texture, mimeType); + }); + }; + _GLTFMaterialExporter.prototype._exportTextureInfoAsync = function (babylonTexture, mimeType) { + return (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__awaiter)(this, void 0, void 0, function () { + var textureUid, pixels_1, samplerIndex, textureMimeType, internalTextureToImage, internalTextureUniqueId, imageIndexPromise, size_1, textureInfo, _a; + var _this = this; + return (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__generator)(this, function (_b) { + switch (_b.label) { + case 0: + textureUid = babylonTexture.uid; + if (!!(textureUid in this._textureMap)) return [3 /*break*/, 3]; + return [4 /*yield*/, this._getPixelsFromTexture(babylonTexture)]; + case 1: + pixels_1 = _b.sent(); + if (!pixels_1) { + return [2 /*return*/, null]; + } + samplerIndex = this._exportTextureSampler(babylonTexture); + textureMimeType = babylonTexture.mimeType; + if (textureMimeType) { + switch (textureMimeType) { + case "image/jpeg": + case "image/png": + case "image/webp": + mimeType = textureMimeType; + break; + default: + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Unsupported media type: ".concat(textureMimeType)); + break; + } + } + internalTextureToImage = this._internalTextureToImage; + internalTextureUniqueId = babylonTexture.getInternalTexture().uniqueId; + internalTextureToImage[internalTextureUniqueId] || (internalTextureToImage[internalTextureUniqueId] = {}); + imageIndexPromise = internalTextureToImage[internalTextureUniqueId][mimeType]; + if (imageIndexPromise === undefined) { + size_1 = babylonTexture.getSize(); + imageIndexPromise = (function () { return (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__awaiter)(_this, void 0, void 0, function () { + var data; + return (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__generator)(this, function (_a) { + switch (_a.label) { + case 0: return [4 /*yield*/, this._getImageDataAsync(pixels_1, size_1.width, size_1.height, mimeType)]; + case 1: + data = _a.sent(); + return [2 /*return*/, this._exportImage(babylonTexture.name, mimeType, data)]; + } + }); + }); })(); + internalTextureToImage[internalTextureUniqueId][mimeType] = imageIndexPromise; + } + _a = this._exportTextureInfo; + return [4 /*yield*/, imageIndexPromise]; + case 2: + textureInfo = _a.apply(this, [_b.sent(), samplerIndex, babylonTexture.coordinatesIndex]); + this._textureMap[textureUid] = textureInfo; + this._exporter._extensionsPostExportTextures("exporter", this._textureMap[textureUid], babylonTexture); + _b.label = 3; + case 3: return [2 /*return*/, this._textureMap[textureUid]]; + } + }); + }); + }; + _GLTFMaterialExporter.prototype._exportImage = function (name, mimeType, data) { + var imageData = this._exporter._imageData; + var baseName = name.replace(/\.\/|\/|\.\\|\\/g, "_"); + var extension = getFileExtensionFromMimeType(mimeType); + var fileName = baseName + extension; + if (fileName in imageData) { + fileName = "".concat(baseName, "_").concat(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.RandomId()).concat(extension); + } + imageData[fileName] = { + data: data, + mimeType: mimeType, + }; + var images = this._exporter._images; + images.push({ + name: name, + uri: fileName, + }); + return images.length - 1; + }; + _GLTFMaterialExporter.prototype._exportTextureInfo = function (imageIndex, samplerIndex, coordinatesIndex) { + var textures = this._exporter._textures; + var textureIndex = textures.findIndex(function (t) { return t.sampler == samplerIndex && t.source === imageIndex; }); + if (textureIndex === -1) { + textureIndex = textures.length; + textures.push({ + source: imageIndex, + sampler: samplerIndex, + }); + } + var textureInfo = { index: textureIndex }; + if (coordinatesIndex) { + textureInfo.texCoord = coordinatesIndex; + } + return textureInfo; + }; + _GLTFMaterialExporter.prototype._exportTextureSampler = function (texture) { + var sampler = this._getTextureSampler(texture); + // if a pre-existing sampler with identical parameters exists, then reuse the previous sampler + var samplers = this._exporter._samplers; + var samplerIndex = samplers.findIndex(function (s) { return s.minFilter === sampler.minFilter && s.magFilter === sampler.magFilter && s.wrapS === sampler.wrapS && s.wrapT === sampler.wrapT; }); + if (samplerIndex !== -1) { + return samplerIndex; + } + samplers.push(sampler); + return samplers.length - 1; + }; + /** + * Represents the dielectric specular values for R, G and B + */ + _GLTFMaterialExporter._DielectricSpecular = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3(0.04, 0.04, 0.04); + /** + * Allows the maximum specular power to be defined for material calculations + */ + _GLTFMaterialExporter._MaxSpecularPower = 1024; + /** + * Numeric tolerance value + */ + _GLTFMaterialExporter._Epsilon = 1e-6; + return _GLTFMaterialExporter; +}()); + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/glTFSerializer.ts": +/*!***************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/glTFSerializer.ts ***! + \***************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTF2Export: () => (/* binding */ GLTF2Export) +/* harmony export */ }); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); + +/** + * Class for generating glTF data from a Babylon scene. + */ +var GLTF2Export = /** @class */ (function () { + function GLTF2Export() { + } + /** + * Exports the geometry of the scene to .gltf file format asynchronously + * @param scene Babylon scene with scene hierarchy information + * @param filePrefix File prefix to use when generating the glTF file + * @param options Exporter options + * @returns Returns an object with a .gltf file and associates texture names + * as keys and their data and paths as values + */ + GLTF2Export.GLTFAsync = function (scene, filePrefix, options) { + return scene.whenReadyAsync().then(function () { + var glTFPrefix = filePrefix.replace(/\.[^/.]+$/, ""); + var gltfGenerator = new _glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter(scene, options); + return gltfGenerator._generateGLTFAsync(glTFPrefix); + }); + }; + GLTF2Export._PreExportAsync = function (scene, options) { + return Promise.resolve().then(function () { + if (options && options.exportWithoutWaitingForScene) { + return Promise.resolve(); + } + else { + return scene.whenReadyAsync(); + } + }); + }; + GLTF2Export._PostExportAsync = function (scene, glTFData, options) { + return Promise.resolve().then(function () { + if (options && options.exportWithoutWaitingForScene) { + return glTFData; + } + else { + return glTFData; + } + }); + }; + /** + * Exports the geometry of the scene to .glb file format asychronously + * @param scene Babylon scene with scene hierarchy information + * @param filePrefix File prefix to use when generating glb file + * @param options Exporter options + * @returns Returns an object with a .glb filename as key and data as value + */ + GLTF2Export.GLBAsync = function (scene, filePrefix, options) { + var _this = this; + return this._PreExportAsync(scene, options).then(function () { + var glTFPrefix = filePrefix.replace(/\.[^/.]+$/, ""); + var gltfGenerator = new _glTFExporter__WEBPACK_IMPORTED_MODULE_0__._Exporter(scene, options); + return gltfGenerator._generateGLBAsync(glTFPrefix).then(function (glTFData) { + return _this._PostExportAsync(scene, glTFData, options); + }); + }); + }; + return GLTF2Export; +}()); + + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/glTFUtilities.ts": +/*!**************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/glTFUtilities.ts ***! + \**************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ _GLTFUtilities: () => (/* binding */ _GLTFUtilities) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Maths/math.vector"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); + +/** + * @internal + */ +var _GLTFUtilities = /** @class */ (function () { + function _GLTFUtilities() { + } + /** + * Creates a buffer view based on the supplied arguments + * @param bufferIndex index value of the specified buffer + * @param byteOffset byte offset value + * @param byteLength byte length of the bufferView + * @param byteStride byte distance between conequential elements + * @param name name of the buffer view + * @returns bufferView for glTF + */ + _GLTFUtilities._CreateBufferView = function (bufferIndex, byteOffset, byteLength, byteStride, name) { + var bufferview = { buffer: bufferIndex, byteLength: byteLength }; + if (byteOffset) { + bufferview.byteOffset = byteOffset; + } + if (name) { + bufferview.name = name; + } + if (byteStride) { + bufferview.byteStride = byteStride; + } + return bufferview; + }; + /** + * Creates an accessor based on the supplied arguments + * @param bufferviewIndex The index of the bufferview referenced by this accessor + * @param name The name of the accessor + * @param type The type of the accessor + * @param componentType The datatype of components in the attribute + * @param count The number of attributes referenced by this accessor + * @param byteOffset The offset relative to the start of the bufferView in bytes + * @param min Minimum value of each component in this attribute + * @param max Maximum value of each component in this attribute + * @returns accessor for glTF + */ + _GLTFUtilities._CreateAccessor = function (bufferviewIndex, name, type, componentType, count, byteOffset, min, max) { + var accessor = { name: name, bufferView: bufferviewIndex, componentType: componentType, count: count, type: type }; + if (min != null) { + accessor.min = min; + } + if (max != null) { + accessor.max = max; + } + if (byteOffset != null) { + accessor.byteOffset = byteOffset; + } + return accessor; + }; + /** + * Calculates the minimum and maximum values of an array of position floats + * @param positions Positions array of a mesh + * @param vertexStart Starting vertex offset to calculate min and max values + * @param vertexCount Number of vertices to check for min and max values + * @returns min number array and max number array + */ + _GLTFUtilities._CalculateMinMaxPositions = function (positions, vertexStart, vertexCount) { + var min = [Infinity, Infinity, Infinity]; + var max = [-Infinity, -Infinity, -Infinity]; + var positionStrideSize = 3; + var indexOffset; + var position; + var vector; + if (vertexCount) { + for (var i = vertexStart, length_1 = vertexStart + vertexCount; i < length_1; ++i) { + indexOffset = positionStrideSize * i; + position = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(positions, indexOffset); + vector = position.asArray(); + for (var j = 0; j < positionStrideSize; ++j) { + var num = vector[j]; + if (num < min[j]) { + min[j] = num; + } + if (num > max[j]) { + max[j] = num; + } + ++indexOffset; + } + } + } + return { min: min, max: max }; + }; + _GLTFUtilities._NormalizeTangentFromRef = function (tangent) { + var length = Math.sqrt(tangent.x * tangent.x + tangent.y * tangent.y + tangent.z * tangent.z); + if (length > 0) { + tangent.x /= length; + tangent.y /= length; + tangent.z /= length; + } + }; + _GLTFUtilities._GetDataAccessorElementCount = function (accessorType) { + switch (accessorType) { + case "MAT2" /* AccessorType.MAT2 */: + return 4; + case "MAT3" /* AccessorType.MAT3 */: + return 9; + case "MAT4" /* AccessorType.MAT4 */: + return 16; + case "SCALAR" /* AccessorType.SCALAR */: + return 1; + case "VEC2" /* AccessorType.VEC2 */: + return 2; + case "VEC3" /* AccessorType.VEC3 */: + return 3; + case "VEC4" /* AccessorType.VEC4 */: + return 4; + } + }; + return _GLTFUtilities; +}()); + + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/2.0/index.ts": +/*!******************************************************!*\ + !*** ../../../dev/serializers/src/glTF/2.0/index.ts ***! + \******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.EXT_mesh_gpu_instancing), +/* harmony export */ GLTF2Export: () => (/* reexport safe */ _glTFSerializer__WEBPACK_IMPORTED_MODULE_5__.GLTF2Export), +/* harmony export */ GLTFData: () => (/* reexport safe */ _glTFData__WEBPACK_IMPORTED_MODULE_1__.GLTFData), +/* harmony export */ KHR_lights_punctual: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_lights_punctual), +/* harmony export */ KHR_materials_anisotropy: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_anisotropy), +/* harmony export */ KHR_materials_clearcoat: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_clearcoat), +/* harmony export */ KHR_materials_emissive_strength: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_emissive_strength), +/* harmony export */ KHR_materials_ior: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_ior), +/* harmony export */ KHR_materials_iridescence: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_iridescence), +/* harmony export */ KHR_materials_sheen: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_sheen), +/* harmony export */ KHR_materials_specular: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_specular), +/* harmony export */ KHR_materials_transmission: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_transmission), +/* harmony export */ KHR_materials_unlit: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_unlit), +/* harmony export */ KHR_materials_volume: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_volume), +/* harmony export */ KHR_texture_transform: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_7__.KHR_texture_transform), +/* harmony export */ _BinaryWriter: () => (/* reexport safe */ _glTFExporter__WEBPACK_IMPORTED_MODULE_2__._BinaryWriter), +/* harmony export */ _Exporter: () => (/* reexport safe */ _glTFExporter__WEBPACK_IMPORTED_MODULE_2__._Exporter), +/* harmony export */ _GLTFAnimation: () => (/* reexport safe */ _glTFAnimation__WEBPACK_IMPORTED_MODULE_0__._GLTFAnimation), +/* harmony export */ _GLTFMaterialExporter: () => (/* reexport safe */ _glTFMaterialExporter__WEBPACK_IMPORTED_MODULE_4__._GLTFMaterialExporter), +/* harmony export */ _GLTFUtilities: () => (/* reexport safe */ _glTFUtilities__WEBPACK_IMPORTED_MODULE_6__._GLTFUtilities), +/* harmony export */ __IGLTFExporterExtensionV2: () => (/* reexport safe */ _glTFExporterExtension__WEBPACK_IMPORTED_MODULE_3__.__IGLTFExporterExtensionV2) +/* harmony export */ }); +/* harmony import */ var _glTFAnimation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFAnimation */ "../../../dev/serializers/src/glTF/2.0/glTFAnimation.ts"); +/* harmony import */ var _glTFData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFData */ "../../../dev/serializers/src/glTF/2.0/glTFData.ts"); +/* harmony import */ var _glTFExporter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFExporter */ "../../../dev/serializers/src/glTF/2.0/glTFExporter.ts"); +/* harmony import */ var _glTFExporterExtension__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./glTFExporterExtension */ "../../../dev/serializers/src/glTF/2.0/glTFExporterExtension.ts"); +/* harmony import */ var _glTFMaterialExporter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./glTFMaterialExporter */ "../../../dev/serializers/src/glTF/2.0/glTFMaterialExporter.ts"); +/* harmony import */ var _glTFSerializer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./glTFSerializer */ "../../../dev/serializers/src/glTF/2.0/glTFSerializer.ts"); +/* harmony import */ var _glTFUtilities__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./glTFUtilities */ "../../../dev/serializers/src/glTF/2.0/glTFUtilities.ts"); +/* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Extensions/index */ "../../../dev/serializers/src/glTF/2.0/Extensions/index.ts"); +/* eslint-disable import/no-internal-modules */ + + + + + + + + + + +/***/ }), + +/***/ "../../../dev/serializers/src/glTF/glTFFileExporter.ts": +/*!*************************************************************!*\ + !*** ../../../dev/serializers/src/glTF/glTFFileExporter.ts ***! + \*************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ __IGLTFExporterExtension: () => (/* binding */ __IGLTFExporterExtension) +/* harmony export */ }); +/** @internal */ +// eslint-disable-next-line no-var, @typescript-eslint/naming-convention +var __IGLTFExporterExtension = 0; // I am here to allow dts to be created + + +/***/ }), + +/***/ "../../../lts/serializers/src/legacy/legacy-glTF2Serializer.ts": +/*!*********************************************************************!*\ + !*** ../../../lts/serializers/src/legacy/legacy-glTF2Serializer.ts ***! + \*********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.EXT_mesh_gpu_instancing), +/* harmony export */ GLTF2Export: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.GLTF2Export), +/* harmony export */ GLTFData: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.GLTFData), +/* harmony export */ KHR_lights_punctual: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_lights_punctual), +/* harmony export */ KHR_materials_anisotropy: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_anisotropy), +/* harmony export */ KHR_materials_clearcoat: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_clearcoat), +/* harmony export */ KHR_materials_emissive_strength: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_emissive_strength), +/* harmony export */ KHR_materials_ior: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_ior), +/* harmony export */ KHR_materials_iridescence: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_iridescence), +/* harmony export */ KHR_materials_sheen: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_sheen), +/* harmony export */ KHR_materials_specular: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_specular), +/* harmony export */ KHR_materials_transmission: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_transmission), +/* harmony export */ KHR_materials_unlit: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_unlit), +/* harmony export */ KHR_materials_volume: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_materials_volume), +/* harmony export */ KHR_texture_transform: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.KHR_texture_transform), +/* harmony export */ _BinaryWriter: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__._BinaryWriter), +/* harmony export */ _Exporter: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__._Exporter), +/* harmony export */ _GLTFAnimation: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__._GLTFAnimation), +/* harmony export */ _GLTFMaterialExporter: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__._GLTFMaterialExporter), +/* harmony export */ _GLTFUtilities: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__._GLTFUtilities), +/* harmony export */ __IGLTFExporterExtension: () => (/* reexport safe */ serializers_glTF_glTFFileExporter__WEBPACK_IMPORTED_MODULE_0__.__IGLTFExporterExtension), +/* harmony export */ __IGLTFExporterExtensionV2: () => (/* reexport safe */ serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__.__IGLTFExporterExtensionV2) +/* harmony export */ }); +/* harmony import */ var serializers_glTF_glTFFileExporter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! serializers/glTF/glTFFileExporter */ "../../../dev/serializers/src/glTF/glTFFileExporter.ts"); +/* harmony import */ var serializers_glTF_2_0_glTFData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! serializers/glTF/2.0/glTFData */ "../../../dev/serializers/src/glTF/2.0/glTFData.ts"); +/* harmony import */ var serializers_glTF_2_0_glTFSerializer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! serializers/glTF/2.0/glTFSerializer */ "../../../dev/serializers/src/glTF/2.0/glTFSerializer.ts"); +/* harmony import */ var serializers_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! serializers/glTF/2.0/Extensions/index */ "../../../dev/serializers/src/glTF/2.0/Extensions/index.ts"); +/* harmony import */ var serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! serializers/glTF/2.0/index */ "../../../dev/serializers/src/glTF/2.0/index.ts"); +/* eslint-disable import/no-internal-modules */ + + + + + +/** + * This is the entry point for the UMD module. + * The entry point for a future ESM package should be index.ts + */ +var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined; +if (typeof globalObject !== "undefined") { + globalObject.BABYLON = globalObject.BABYLON || {}; + var BABYLON_1 = globalObject.BABYLON; + BABYLON_1.GLTF2 = BABYLON_1.GLTF2 || {}; + BABYLON_1.GLTF2.Exporter = BABYLON_1.GLTF2.Exporter || {}; + BABYLON_1.GLTF2.Exporter.Extensions = BABYLON_1.GLTF2.Exporter.Extensions || {}; + var keys = []; + for (var key in serializers_glTF_glTFFileExporter__WEBPACK_IMPORTED_MODULE_0__) { + BABYLON_1[key] = serializers_glTF_glTFFileExporter__WEBPACK_IMPORTED_MODULE_0__[key]; + keys.push(key); + } + for (var key in serializers_glTF_2_0_glTFData__WEBPACK_IMPORTED_MODULE_1__) { + BABYLON_1[key] = serializers_glTF_2_0_glTFData__WEBPACK_IMPORTED_MODULE_1__[key]; + keys.push(key); + } + for (var key in serializers_glTF_2_0_glTFSerializer__WEBPACK_IMPORTED_MODULE_2__) { + BABYLON_1[key] = serializers_glTF_2_0_glTFSerializer__WEBPACK_IMPORTED_MODULE_2__[key]; + keys.push(key); + } + for (var key in serializers_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_3__) { + BABYLON_1.GLTF2.Exporter.Extensions[key] = serializers_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_3__[key]; + keys.push(key); + } + for (var key in serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__) { + // Prevent Reassignment. + if (keys.indexOf(key) > -1) { + continue; + } + BABYLON_1.GLTF2.Exporter[key] = serializers_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_4__[key]; + } +} + + + + +/***/ }), + +/***/ "babylonjs/Maths/math.vector": +/*!****************************************************************************************************!*\ + !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***! + \****************************************************************************************************/ +/***/ ((module) => { + +module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Maths_math_vector__; + +/***/ }), + +/***/ "../../../../node_modules/tslib/tslib.es6.mjs": +/*!****************************************************!*\ + !*** ../../../../node_modules/tslib/tslib.es6.mjs ***! + \****************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ __addDisposableResource: () => (/* binding */ __addDisposableResource), +/* harmony export */ __assign: () => (/* binding */ __assign), +/* harmony export */ __asyncDelegator: () => (/* binding */ __asyncDelegator), +/* harmony export */ __asyncGenerator: () => (/* binding */ __asyncGenerator), +/* harmony export */ __asyncValues: () => (/* binding */ __asyncValues), +/* harmony export */ __await: () => (/* binding */ __await), +/* harmony export */ __awaiter: () => (/* binding */ __awaiter), +/* harmony export */ __classPrivateFieldGet: () => (/* binding */ __classPrivateFieldGet), +/* harmony export */ __classPrivateFieldIn: () => (/* binding */ __classPrivateFieldIn), +/* harmony export */ __classPrivateFieldSet: () => (/* binding */ __classPrivateFieldSet), +/* harmony export */ __createBinding: () => (/* binding */ __createBinding), +/* harmony export */ __decorate: () => (/* binding */ __decorate), +/* harmony export */ __disposeResources: () => (/* binding */ __disposeResources), +/* harmony export */ __esDecorate: () => (/* binding */ __esDecorate), +/* harmony export */ __exportStar: () => (/* binding */ __exportStar), +/* harmony export */ __extends: () => (/* binding */ __extends), +/* harmony export */ __generator: () => (/* binding */ __generator), +/* harmony export */ __importDefault: () => (/* binding */ __importDefault), +/* harmony export */ __importStar: () => (/* binding */ __importStar), +/* harmony export */ __makeTemplateObject: () => (/* binding */ __makeTemplateObject), +/* harmony export */ __metadata: () => (/* binding */ __metadata), +/* harmony export */ __param: () => (/* binding */ __param), +/* harmony export */ __propKey: () => (/* binding */ __propKey), +/* harmony export */ __read: () => (/* binding */ __read), +/* harmony export */ __rest: () => (/* binding */ __rest), +/* harmony export */ __runInitializers: () => (/* binding */ __runInitializers), +/* harmony export */ __setFunctionName: () => (/* binding */ __setFunctionName), +/* harmony export */ __spread: () => (/* binding */ __spread), +/* harmony export */ __spreadArray: () => (/* binding */ __spreadArray), +/* harmony export */ __spreadArrays: () => (/* binding */ __spreadArrays), +/* harmony export */ __values: () => (/* binding */ __values), +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global Reflect, Promise, SuppressedError, Symbol */ + +var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + } + return __assign.apply(this, arguments); +} + +function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; +} + +function __decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} + +function __param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +} + +function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { + function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } + var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; + var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; + var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); + var _, done = false; + for (var i = decorators.length - 1; i >= 0; i--) { + var context = {}; + for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; + for (var p in contextIn.access) context.access[p] = contextIn.access[p]; + context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; + var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); + if (kind === "accessor") { + if (result === void 0) continue; + if (result === null || typeof result !== "object") throw new TypeError("Object expected"); + if (_ = accept(result.get)) descriptor.get = _; + if (_ = accept(result.set)) descriptor.set = _; + if (_ = accept(result.init)) initializers.unshift(_); + } + else if (_ = accept(result)) { + if (kind === "field") initializers.unshift(_); + else descriptor[key] = _; + } + } + if (target) Object.defineProperty(target, contextIn.name, descriptor); + done = true; +}; + +function __runInitializers(thisArg, initializers, value) { + var useValue = arguments.length > 2; + for (var i = 0; i < initializers.length; i++) { + value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); + } + return useValue ? value : void 0; +}; + +function __propKey(x) { + return typeof x === "symbol" ? x : "".concat(x); +}; + +function __setFunctionName(f, name, prefix) { + if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; + return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); +}; + +function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); +} + +function __awaiter(thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +var __createBinding = Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +}); + +function __exportStar(m, o) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); +} + +function __values(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +} + +function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +/** @deprecated */ +function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; +} + +/** @deprecated */ +function __spreadArrays() { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +} + +function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +} + +function __await(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); +} + +function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +} + +function __asyncDelegator(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } +} + +function __asyncValues(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +} + +function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; + +var __setModuleDefault = Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}; + +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +} + +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { default: mod }; +} + +function __classPrivateFieldGet(receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +} + +function __classPrivateFieldSet(receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; +} + +function __classPrivateFieldIn(state, receiver) { + if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object"); + return typeof state === "function" ? receiver === state : state.has(receiver); +} + +function __addDisposableResource(env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +} + +var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}; + +function __disposeResources(env) { + function fail(e) { + env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); +} + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ + __extends, + __assign, + __rest, + __decorate, + __param, + __metadata, + __awaiter, + __generator, + __createBinding, + __exportStar, + __values, + __read, + __spread, + __spreadArrays, + __spreadArray, + __await, + __asyncGenerator, + __asyncDelegator, + __asyncValues, + __makeTemplateObject, + __importStar, + __importDefault, + __classPrivateFieldGet, + __classPrivateFieldSet, + __classPrivateFieldIn, + __addDisposableResource, + __disposeResources, +}); + + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ (() => { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = (module) => { +/******/ var getter = module && module.__esModule ? +/******/ () => (module['default']) : +/******/ () => (module); +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/global */ +/******/ (() => { +/******/ __webpack_require__.g = (function() { +/******/ if (typeof globalThis === 'object') return globalThis; +/******/ try { +/******/ return this || new Function('return this')(); +/******/ } catch (e) { +/******/ if (typeof window === 'object') return window; +/******/ } +/******/ })(); +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +(() => { +/*!**********************!*\ + !*** ./src/glTF2.ts ***! + \**********************/ +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__), +/* harmony export */ serializers: () => (/* reexport module object */ _lts_serializers_legacy_legacy_glTF2Serializer__WEBPACK_IMPORTED_MODULE_0__) +/* harmony export */ }); +/* harmony import */ var _lts_serializers_legacy_legacy_glTF2Serializer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @lts/serializers/legacy/legacy-glTF2Serializer */ "../../../lts/serializers/src/legacy/legacy-glTF2Serializer.ts"); + + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_lts_serializers_legacy_legacy_glTF2Serializer__WEBPACK_IMPORTED_MODULE_0__); + +})(); + +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; +}); +//# sourceMappingURL=babylon.glTF2Serializer.js.map \ No newline at end of file diff --git a/libs/babylonjs/6.23.0/babylon.glTF2Serializer.min.js b/libs/babylonjs/6.23.0/babylon.glTF2Serializer.min.js new file mode 100644 index 00000000..9d0b3811 --- /dev/null +++ b/libs/babylonjs/6.23.0/babylon.glTF2Serializer.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-serializers"]=t(require("babylonjs")):e.SERIALIZERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var t={520:t=>{t.exports=e}},r={};function n(e){var a=r[e];if(void 0!==a)return a.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};return(()=>{n.d(a,{default:()=>ee});var e={};n.r(e),n.d(e,{__IGLTFExporterExtension:()=>u});var t={};n.r(t),n.d(t,{GLTFData:()=>l});var r={};n.r(r),n.d(r,{GLTF2Export:()=>b});var i={};n.r(i),n.d(i,{EXT_mesh_gpu_instancing:()=>H,KHR_lights_punctual:()=>F,KHR_materials_anisotropy:()=>I,KHR_materials_clearcoat:()=>C,KHR_materials_emissive_strength:()=>Q,KHR_materials_ior:()=>k,KHR_materials_iridescence:()=>R,KHR_materials_sheen:()=>P,KHR_materials_specular:()=>K,KHR_materials_transmission:()=>z,KHR_materials_unlit:()=>L,KHR_materials_volume:()=>G,KHR_texture_transform:()=>E});var o={};n.r(o),n.d(o,{EXT_mesh_gpu_instancing:()=>H,GLTF2Export:()=>b,GLTFData:()=>l,KHR_lights_punctual:()=>F,KHR_materials_anisotropy:()=>I,KHR_materials_clearcoat:()=>C,KHR_materials_emissive_strength:()=>Q,KHR_materials_ior:()=>k,KHR_materials_iridescence:()=>R,KHR_materials_sheen:()=>P,KHR_materials_specular:()=>K,KHR_materials_transmission:()=>z,KHR_materials_unlit:()=>L,KHR_materials_volume:()=>G,KHR_texture_transform:()=>E,_BinaryWriter:()=>v,_Exporter:()=>T,_GLTFAnimation:()=>m,_GLTFMaterialExporter:()=>_,_GLTFUtilities:()=>g,__IGLTFExporterExtensionV2:()=>Y});var s={};n.r(s),n.d(s,{EXT_mesh_gpu_instancing:()=>H,GLTF2Export:()=>b,GLTFData:()=>l,KHR_lights_punctual:()=>F,KHR_materials_anisotropy:()=>I,KHR_materials_clearcoat:()=>C,KHR_materials_emissive_strength:()=>Q,KHR_materials_ior:()=>k,KHR_materials_iridescence:()=>R,KHR_materials_sheen:()=>P,KHR_materials_specular:()=>K,KHR_materials_transmission:()=>z,KHR_materials_unlit:()=>L,KHR_materials_volume:()=>G,KHR_texture_transform:()=>E,_BinaryWriter:()=>v,_Exporter:()=>T,_GLTFAnimation:()=>m,_GLTFMaterialExporter:()=>_,_GLTFUtilities:()=>g,__IGLTFExporterExtension:()=>u,__IGLTFExporterExtensionV2:()=>Y});var u=0,l=function(){function e(){this.glTFFiles={}}return e.prototype.downloadFiles=function(){function e(e,t){return-1!==e.indexOf(t,e.length-t.length)}for(var t in this.glTFFiles){var r=document.createElement("a");document.body.appendChild(r),r.setAttribute("type","hidden"),r.download=t;var n=this.glTFFiles[t],a=void 0;e(t,".glb")?a={type:"model/gltf-binary"}:e(t,".bin")?a={type:"application/octet-stream"}:e(t,".gltf")?a={type:"model/gltf+json"}:e(t,".jpeg")||e(t,".jpg")?a={type:"image/jpeg"}:e(t,".png")&&(a={type:"image/png"}),r.href=window.URL.createObjectURL(new Blob([n],a)),r.click()}},e}();function c(e,t,r,n){return new(r||(r=Promise))((function(a,i){function o(e){try{u(n.next(e))}catch(e){i(e)}}function s(e){try{u(n.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,s)}u((n=n.apply(e,t||[])).next())}))}function f(e,t){var r,n,a,i,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&s[0]?n.return:s[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,s[1])).done)return a;switch(n=0,a&&(s=[2&s[0],a.value]),s[0]){case 0:case 1:a=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,n=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!a||s[1]>a[0]&&s[1]o.width?(a=t&&t instanceof d.Texture?d.TextureTools.CreateResizedCopy(t,i.width,i.height,!0):this._createWhiteTexture(i.width,i.height,r),n=e):(n=e,a=t),{texture1:n,texture2:a}},e.prototype._convertPixelArrayToFloat32=function(e){if(e instanceof Uint8Array){for(var t=e.length,r=new Float32Array(e.length),n=0;ne._Epsilon?R.baseColor.r:1,T[N+1]/=R.baseColor.g>e._Epsilon?R.baseColor.g:1,T[N+2]/=R.baseColor.b>e._Epsilon?R.baseColor.b:1,L=d.Color3.FromInts(T[N],T[N+1],T[N+2]),O=L.toGammaSpace(s.getEngine().useExactSrgbConversions),T[N]=255*O.r,T[N+1]=255*O.g,T[N+2]=255*O.b,e._FuzzyEquals(O,d.Color3.White(),e._Epsilon)||(I=!0),y[N+1]/=R.roughness>e._Epsilon?R.roughness:1,y[N+2]/=R.metallic>e._Epsilon?R.metallic:1,k=d.Color3.FromInts(255,y[N+1],y[N+2]),e._FuzzyEquals(k,d.Color3.White(),e._Epsilon)||(S=!0);return S&&o.push(this._getImageDataAsync(y,p,_,a).then((function(e){R.metallicRoughnessTextureData=e}))),I&&o.push(this._getImageDataAsync(T,p,_,a).then((function(e){R.baseColorTextureData=e}))),[2,Promise.all(o).then((function(){return R}))];case 3:return[2,Promise.reject("_ConvertSpecularGlossinessTexturesToMetallicRoughness: Scene from textures is missing!")]}}))}))},e.prototype._convertSpecularGlossinessToMetallicRoughness=function(t){var r=this._getPerceivedBrightness(t.diffuseColor),n=this._getPerceivedBrightness(t.specularColor),a=1-this._getMaxComponent(t.specularColor),i=e._SolveMetallic(r,n,a),o=t.diffuseColor.scale(a/(1-e._DielectricSpecular.r)/Math.max(1-i,e._Epsilon)),s=t.specularColor.subtract(e._DielectricSpecular.scale(1-i)).scale(1/Math.max(i,e._Epsilon)),u=d.Color3.Lerp(o,s,i*i);return{baseColor:u=u.clampToRef(0,1,u),metallic:i,roughness:1-t.glossiness}},e.prototype._getPerceivedBrightness=function(e){return e?Math.sqrt(.299*e.r*e.r+.587*e.g*e.g+.114*e.b*e.b):0},e.prototype._getMaxComponent=function(e){return e?Math.max(e.r,Math.max(e.g,e.b)):0},e.prototype._convertMetalRoughFactorsToMetallicRoughnessAsync=function(e,t,r,n){var a=[],i={baseColor:e._albedoColor,metallic:e._metallic,roughness:e._roughness};if(n){e._albedoTexture&&a.push(this._exportTextureAsync(e._albedoTexture,t).then((function(e){e&&(r.baseColorTexture=e)})));var o=e._metallicTexture;o&&a.push(this._exportTextureAsync(o,t).then((function(e){e&&(r.metallicRoughnessTexture=e)})))}return Promise.all(a).then((function(){return i}))},e.prototype._getTextureSampler=function(e){var t={};if(!(e&&e instanceof d.Texture))return t;var r=this._getGLTFTextureWrapMode(e.wrapU);10497!==r&&(t.wrapS=r);var n=this._getGLTFTextureWrapMode(e.wrapV);switch(10497!==n&&(t.wrapT=n),e.samplingMode){case d.Texture.LINEAR_LINEAR:t.magFilter=9729,t.minFilter=9729;break;case d.Texture.LINEAR_NEAREST:t.magFilter=9729,t.minFilter=9728;break;case d.Texture.NEAREST_LINEAR:t.magFilter=9728,t.minFilter=9729;break;case d.Texture.NEAREST_LINEAR_MIPLINEAR:t.magFilter=9728,t.minFilter=9987;break;case d.Texture.NEAREST_NEAREST:t.magFilter=9728,t.minFilter=9728;break;case d.Texture.NEAREST_LINEAR_MIPNEAREST:t.magFilter=9728,t.minFilter=9985;break;case d.Texture.LINEAR_NEAREST_MIPNEAREST:t.magFilter=9729,t.minFilter=9984;break;case d.Texture.LINEAR_NEAREST_MIPLINEAR:t.magFilter=9729,t.minFilter=9986;break;case d.Texture.NEAREST_NEAREST_MIPLINEAR:t.magFilter=9728,t.minFilter=9986;break;case d.Texture.LINEAR_LINEAR_MIPLINEAR:t.magFilter=9729,t.minFilter=9987;break;case d.Texture.LINEAR_LINEAR_MIPNEAREST:t.magFilter=9729,t.minFilter=9985;break;case d.Texture.NEAREST_NEAREST_MIPNEAREST:t.magFilter=9728,t.minFilter=9984}return t},e.prototype._getGLTFTextureWrapMode=function(e){switch(e){case d.Texture.WRAP_ADDRESSMODE:return 10497;case d.Texture.CLAMP_ADDRESSMODE:return 33071;case d.Texture.MIRROR_ADDRESSMODE:return 33648;default:return d.Tools.Error("Unsupported Texture Wrap Mode ".concat(e,"!")),10497}},e.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync=function(e,t,r,n){var a=this;return Promise.resolve().then((function(){var i={diffuseColor:e._albedoColor,specularColor:e._reflectivityColor,glossiness:e._microSurface},o=e._albedoTexture,s=e._reflectivityTexture,u=e._useMicroSurfaceFromReflectivityMapAlpha;if(s&&!u)return Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported");if((o||s)&&n){var l=a._exportTextureSampler(o||s);return a._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(o,s,i,t).then((function(e){var n=a._exporter._textures;if(e.baseColorTextureData){var i=a._exportImage("baseColor".concat(n.length),t,e.baseColorTextureData);r.baseColorTexture=a._exportTextureInfo(i,l,null==o?void 0:o.coordinatesIndex)}return e.metallicRoughnessTextureData&&(i=a._exportImage("metallicRoughness".concat(n.length),t,e.metallicRoughnessTextureData),r.metallicRoughnessTexture=a._exportTextureInfo(i,l,null==s?void 0:s.coordinatesIndex)),e}))}return a._convertSpecularGlossinessToMetallicRoughness(i)}))},e.prototype._convertPBRMaterialAsync=function(e,t,r){var n=this,a={},i={name:e.name};if(e.isMetallicWorkflow()){var o=e._albedoColor,s=e.alpha;return o&&(a.baseColorFactor=[o.r,o.g,o.b,s]),this._convertMetalRoughFactorsToMetallicRoughnessAsync(e,t,a,r).then((function(o){return n._setMetallicRoughnessPbrMaterial(o,e,i,a,t,r)}))}return this._convertSpecGlossFactorsToMetallicRoughnessAsync(e,t,a,r).then((function(o){return n._setMetallicRoughnessPbrMaterial(o,e,i,a,t,r)}))},e.prototype._setMetallicRoughnessPbrMaterial=function(t,r,n,a,i,o){var s=this._exporter._materialMap,u=this._exporter._materials,l=[];if(t){if(e._SetAlphaMode(n,r),e._FuzzyEquals(t.baseColor,d.Color3.White(),e._Epsilon)&&r.alpha>=e._Epsilon||(a.baseColorFactor=[t.baseColor.r,t.baseColor.g,t.baseColor.b,r.alpha]),null!=t.metallic&&1!==t.metallic&&(a.metallicFactor=t.metallic),null!=t.roughness&&1!==t.roughness&&(a.roughnessFactor=t.roughness),null==r.backFaceCulling||r.backFaceCulling||(r._twoSidedLighting||d.Tools.Warn(r.name+": Back-face culling disabled and two-sided lighting disabled is not supported in glTF."),n.doubleSided=!0),o){var c=r._bumpTexture;if(c){var f=this._exportTextureAsync(c,i).then((function(e){e&&(n.normalTexture=e,1!==c.level&&(n.normalTexture.scale=c.level))}));l.push(f)}var h=r._ambientTexture;h&&(f=this._exportTextureAsync(h,i).then((function(e){if(e){var t={index:e.index,texCoord:e.texCoord,extensions:e.extensions};n.occlusionTexture=t;var a=r._ambientTextureStrength;a&&(t.strength=a)}})),l.push(f));var p=r._emissiveTexture;p&&(f=this._exportTextureAsync(p,i).then((function(e){e&&(n.emissiveTexture=e)})),l.push(f))}var _=r._emissiveColor;e._FuzzyEquals(_,d.Color3.Black(),e._Epsilon)||(n.emissiveFactor=_.asArray()),n.pbrMetallicRoughness=a,u.push(n),s[r.uniqueId]=u.length-1}return this._finishMaterial(l,n,r,i)},e.prototype._getPixelsFromTexture=function(e){return e.textureType,d.Constants.TEXTURETYPE_UNSIGNED_INT,e.readPixels()},e.prototype._exportTextureAsync=function(e,t){var r=this,n=this._exporter._extensionsPreExportTextureAsync("exporter",e,t);return n?n.then((function(n){return n?r._exportTextureInfoAsync(n,t):r._exportTextureInfoAsync(e,t)})):this._exportTextureInfoAsync(e,t)},e.prototype._exportTextureInfoAsync=function(e,t){return c(this,void 0,void 0,(function(){var r,n,a,i,o,s,u,l,h,p,_=this;return f(this,(function(g){switch(g.label){case 0:return(r=e.uid)in this._textureMap?[3,3]:[4,this._getPixelsFromTexture(e)];case 1:if(!(n=g.sent()))return[2,null];if(a=this._exportTextureSampler(e),i=e.mimeType)switch(i){case"image/jpeg":case"image/png":case"image/webp":t=i;break;default:d.Tools.Warn("Unsupported media type: ".concat(i))}return o=this._internalTextureToImage,s=e.getInternalTexture().uniqueId,o[s]||(o[s]={}),void 0===(u=o[s][t])&&(l=e.getSize(),u=c(_,void 0,void 0,(function(){var r;return f(this,(function(a){switch(a.label){case 0:return[4,this._getImageDataAsync(n,l.width,l.height,t)];case 1:return r=a.sent(),[2,this._exportImage(e.name,t,r)]}}))})),o[s][t]=u),p=this._exportTextureInfo,[4,u];case 2:h=p.apply(this,[g.sent(),a,e.coordinatesIndex]),this._textureMap[r]=h,this._exporter._extensionsPostExportTextures("exporter",this._textureMap[r],e),g.label=3;case 3:return[2,this._textureMap[r]]}}))}))},e.prototype._exportImage=function(e,t,r){var n=this._exporter._imageData,a=e.replace(/\.\/|\/|\.\\|\\/g,"_"),i=function(e){switch(e){case"image/jpeg":return".jpg";case"image/png":return".png";case"image/webp":return".webp"}}(t),o=a+i;o in n&&(o="".concat(a,"_").concat(d.Tools.RandomId()).concat(i)),n[o]={data:r,mimeType:t};var s=this._exporter._images;return s.push({name:e,uri:o}),s.length-1},e.prototype._exportTextureInfo=function(e,t,r){var n=this._exporter._textures,a=n.findIndex((function(r){return r.sampler==t&&r.source===e}));-1===a&&(a=n.length,n.push({source:e,sampler:t}));var i={index:a};return r&&(i.texCoord=r),i},e.prototype._exportTextureSampler=function(e){var t=this._getTextureSampler(e),r=this._exporter._samplers,n=r.findIndex((function(e){return e.minFilter===t.minFilter&&e.magFilter===t.magFilter&&e.wrapS===t.wrapS&&e.wrapT===t.wrapT}));return-1!==n?n:(r.push(t),r.length-1)},e._DielectricSpecular=new d.Color3(.04,.04,.04),e._MaxSpecularPower=1024,e._Epsilon=1e-6,e}(),g=function(){function e(){}return e._CreateBufferView=function(e,t,r,n,a){var i={buffer:e,byteLength:r};return t&&(i.byteOffset=t),a&&(i.name=a),n&&(i.byteStride=n),i},e._CreateAccessor=function(e,t,r,n,a,i,o,s){var u={name:t,bufferView:e,componentType:n,count:a,type:r};return null!=o&&(u.min=o),null!=s&&(u.max=s),null!=i&&(u.byteOffset=i),u},e._CalculateMinMaxPositions=function(e,t,r){var n,a,i=[1/0,1/0,1/0],o=[-1/0,-1/0,-1/0];if(r)for(var s=t,u=t+r;so[l]&&(o[l]=c),++n}}return{min:i,max:o}},e._NormalizeTangentFromRef=function(e){var t=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z);t>0&&(e.x/=t,e.y/=t,e.z/=t)},e._GetDataAccessorElementCount=function(e){switch(e){case"MAT2":case"VEC4":return 4;case"MAT3":return 9;case"MAT4":return 16;case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3}},e}();!function(e){e[e.INTANGENT=0]="INTANGENT",e[e.OUTTANGENT=1]="OUTTANGENT"}(p||(p={}));var m=function(){function e(){}return e._IsTransformable=function(e){return e&&(e instanceof d.TransformNode||e instanceof d.Camera||e instanceof d.Light)},e._CreateNodeAnimation=function(t,r,n,a,i){if(this._IsTransformable(t)){var o=[],s=[],u=r.getKeys(),l=e._CalculateMinMaxKeyFrames(u),c=e._DeduceInterpolation(u,n,a),f=c.interpolationType,h=c.shouldBakeAnimation;if(h?e._CreateBakedAnimation(t,r,n,l.min,l.max,r.framePerSecond,i,o,s,l,a):"LINEAR"===f||"STEP"===f?e._CreateLinearOrStepAnimation(t,r,n,o,s,a):"CUBICSPLINE"===f?e._CreateCubicSplineAnimation(t,r,n,o,s,a):e._CreateBakedAnimation(t,r,n,l.min,l.max,r.framePerSecond,i,o,s,l,a),o.length&&s.length)return{inputs:o,outputs:s,samplerInterpolation:f,inputsMin:h?l.min:d.Tools.FloatRound(l.min/r.framePerSecond),inputsMax:h?l.max:d.Tools.FloatRound(l.max/r.framePerSecond)}}return null},e._DeduceAnimationInfo=function(e){var t=null,r="VEC3",n=!1,a=e.targetProperty.split(".");switch(a[0]){case"scaling":t="scale";break;case"position":t="translation";break;case"rotation":r="VEC4",t="rotation";break;case"rotationQuaternion":r="VEC4",n=!0,t="rotation";break;case"influence":r="SCALAR",t="weights";break;default:d.Tools.Error("Unsupported animatable property ".concat(a[0]))}return t?{animationChannelTargetPath:t,dataAccessorType:r,useQuaternion:n}:(d.Tools.Error("animation channel target path and data accessor type could be deduced"),null)},e._CreateNodeAnimationFromNodeAnimations=function(t,r,n,a,i,o,s,u,l,c){var f;if(e._IsTransformable(t)&&t.animations)for(var h=0,p=t.animations;h0;)E=b.inputs.shift(),A%p==0&&M.push(E),A++;b.inputs=M}var F=s[n.uniqueId],w=4*b.inputs.length;d=g._CreateBufferView(0,u.getByteOffset(),w,void 0,"".concat(t," keyframe data view")),l.push(d),b.inputs.forEach((function(e){u.setFloat32(e)})),_=g._CreateAccessor(l.length-1,"".concat(t," keyframes"),"SCALAR",5126,b.inputs.length,null,[b.inputsMin],[b.inputsMax]),c.push(_),m=c.length-1,y=b.outputs.length,w=4*g._GetDataAccessorElementCount(i)*b.outputs.length,d=g._CreateBufferView(0,u.getByteOffset(),w,void 0,"".concat(t," data view")),l.push(d),b.outputs.forEach((function(e){e.forEach((function(e){u.setFloat32(e)}))})),_=g._CreateAccessor(l.length-1,"".concat(t," data"),i,5126,y,null,null,null),c.push(_),x=c.length-1,T={interpolation:b.samplerInterpolation,input:m,output:x},r.samplers.push(T),v={sampler:r.samplers.length-1,target:{node:F,path:o}},r.channels.push(v)}},e._CreateBakedAnimation=function(t,r,n,a,i,o,s,u,l,c,f){var h,p,_=d.Quaternion.Identity(),g=null,m=null,x=null,y=null,T=null,v=null;c.min=d.Tools.FloatRound(a/o);for(var b=r.getKeys(),A=0,E=b.length;A=t.length)return Promise.resolve(e);var i=n(t[r],e);return i?i.then((function(e){return a._applyExtension(e,t,r+1,n)})):this._applyExtension(e,t,r+1,n)},e.prototype._applyExtensions=function(t,r){for(var n=[],a=0,i=e._ExtensionNames;a=c;--i)a.setUInt32(r[i],n),n+=4;break;case d.Material.TriangleStripDrawMode:e.indexCount>=3&&(a.setUInt32(r[e.indexStart+2],n+4),a.setUInt32(r[e.indexStart+1],n+8))}},e.prototype._reorderVertexAttributeDataBasedOnPrimitiveMode=function(e,t,r,n,a,i){switch(t){case d.Material.TriangleFillMode:this._reorderTriangleFillMode(e,r,n,a,i);break;case d.Material.TriangleStripDrawMode:this._reorderTriangleStripDrawMode(e,r,n,a,i);break;case d.Material.TriangleFanDrawMode:this._reorderTriangleFanMode(e,r,n,a,i)}},e.prototype._reorderTriangleFillMode=function(e,t,r,n,a){var i=this._getVertexBufferFromMesh(t,e.getMesh());if(i){var o=i.byteStride/d.VertexBuffer.GetTypeByteLength(i.type);if(e.verticesCount%3!=0)d.Tools.Error("The submesh vertices for the triangle fill mode is not divisible by 3!");else{var s=[],u=0;switch(t){case d.VertexBuffer.PositionKind:case d.VertexBuffer.NormalKind:for(var l=e.verticesStart;l=e.verticesStart;--l)u=l*o,s.push(d.Vector4.FromArray(r,u));break;case d.VertexBuffer.ColorKind:for(l=e.verticesStart+e.verticesCount-1;l>=e.verticesStart;--l)u=l*o,4===i.getSize()?s.push(d.Vector4.FromArray(r,u)):s.push(d.Vector3.FromArray(r,u));break;case d.VertexBuffer.UVKind:case d.VertexBuffer.UV2Kind:for(l=e.verticesStart+e.verticesCount-1;l>=e.verticesStart;--l)u=l*o,s.push(d.Vector2.FromArray(r,u));break;default:d.Tools.Error("Unsupported Vertex Buffer type: ".concat(t))}this._writeVertexAttributeData(s,n+12,t,a)}else d.Tools.Warn("reorderTriangleStripDrawMode: Vertex buffer kind ".concat(t," not present!"))},e.prototype._reorderTriangleFanMode=function(e,t,r,n,a){var i=this._getVertexBufferFromMesh(t,e.getMesh());if(i){var o=i.byteStride/d.VertexBuffer.GetTypeByteLength(i.type),s=[],u=0;switch(t){case d.VertexBuffer.PositionKind:case d.VertexBuffer.NormalKind:for(var l=e.verticesStart+e.verticesCount-1;l>=e.verticesStart;--l)u=l*o,s.push(d.Vector3.FromArray(r,u));break;case d.VertexBuffer.TangentKind:for(l=e.verticesStart+e.verticesCount-1;l>=e.verticesStart;--l)u=l*o,s.push(d.Vector4.FromArray(r,u));break;case d.VertexBuffer.ColorKind:for(l=e.verticesStart+e.verticesCount-1;l>=e.verticesStart;--l)u=l*o,s.push(d.Vector4.FromArray(r,u)),4===i.getSize()?s.push(d.Vector4.FromArray(r,u)):s.push(d.Vector3.FromArray(r,u));break;case d.VertexBuffer.UVKind:case d.VertexBuffer.UV2Kind:for(l=e.verticesStart+e.verticesCount-1;l>=e.verticesStart;--l)u=l*o,s.push(d.Vector2.FromArray(r,u));break;default:d.Tools.Error("Unsupported Vertex Buffer type: ".concat(t))}this._writeVertexAttributeData(s,n,t,a)}else d.Tools.Warn("reorderTriangleFanMode: Vertex buffer kind ".concat(t," not present!"))},e.prototype._writeVertexAttributeData=function(e,t,r,n){for(var a=0,i=e;a0){if((null!==o.overrideMaterialSideOrientation?o.overrideMaterialSideOrientation:F.sideOrientation)===(this._babylonScene.useRightHandedSystem?d.Material.ClockWiseSideOrientation:d.Material.CounterClockWiseSideOrientation)){var O=null!=u?this._bufferViews[u].byteOffset:null;null==O&&(O=0);var k=null;if(null!=u&&(k=o.getIndices()),k)this._reorderIndicesBasedOnPrimitiveMode(M,l,k,O,r);else for(var U=0,K=s;U0){var s=o.material||o.getScene().defaultMaterial;if(s instanceof d.MultiMaterial)for(var u=0,l=s.subMaterials;u0){a.weights=[];for(var o=0;of&&(f=p));for(var p=0;p<=f;++p){var _=c[p];l.push(_.getInvertedAbsoluteTransform());var m=_.getTransformNode();m&&null!==e[m.uniqueId]&&void 0!==e[m.uniqueId]?u.joints.push(e[m.uniqueId]):d.Tools.Warn("Exporting a bone without a linked transform node is currently unsupported")}if(u.joints.length>0){var x=64*l.length,y=t.getByteOffset(),T=g._CreateBufferView(0,y,x,void 0,"InverseBindMatrices - "+s.name);this._bufferViews.push(T);var v=this._bufferViews.length-1,b=g._CreateAccessor(v,"InverseBindMatrices - "+s.name,"MAT4",5126,l.length,null,null,null),A=this._accessors.push(b)-1;u.inverseBindMatrices=A,this._skins.push(u),a[s.uniqueId]=this._skins.length-1,l.forEach((function(e){e.m.forEach((function(e){t.setFloat32(e)}))}))}}}return n.then((function(){return a}))},e._ExtensionNames=new Array,e._ExtensionFactories={},e}(),v=function(){function e(e){this._arrayBuffer=new ArrayBuffer(e),this._dataView=new DataView(this._arrayBuffer),this._byteOffset=0}return e.prototype._resizeBuffer=function(e){var t=new ArrayBuffer(e),r=Math.min(this._arrayBuffer.byteLength,e),n=new Uint8Array(this._arrayBuffer,0,r);return new Uint8Array(t).set(n,0),this._arrayBuffer=t,this._dataView=new DataView(this._arrayBuffer),t},e.prototype.getArrayBuffer=function(){return this._resizeBuffer(this.getByteOffset())},e.prototype.getByteOffset=function(){if(null==this._byteOffset)throw new Error("Byte offset is undefined!");return this._byteOffset},e.prototype.setUInt8=function(e,t){null!=t?tthis._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint8(this._byteOffset,e),this._byteOffset+=1)},e.prototype.setUInt16=function(e,t){null!=t?tthis._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint16(this._byteOffset,e,!0),this._byteOffset+=2)},e.prototype.getUInt32=function(e){if(ethis._byteOffset?d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(e.x=this._dataView.getFloat32(t,!0),e.y=this._dataView.getFloat32(t+4,!0),e.z=this._dataView.getFloat32(t+8,!0))},e.prototype.setVector3Float32FromRef=function(e,t){t+8>this._byteOffset?d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._dataView.setFloat32(t,e.x,!0),this._dataView.setFloat32(t+4,e.y,!0),this._dataView.setFloat32(t+8,e.z,!0))},e.prototype.getVector4Float32FromRef=function(e,t){t+12>this._byteOffset?d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(e.x=this._dataView.getFloat32(t,!0),e.y=this._dataView.getFloat32(t+4,!0),e.z=this._dataView.getFloat32(t+8,!0),e.w=this._dataView.getFloat32(t+12,!0))},e.prototype.setVector4Float32FromRef=function(e,t){t+12>this._byteOffset?d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._dataView.setFloat32(t,e.x,!0),this._dataView.setFloat32(t+4,e.y,!0),this._dataView.setFloat32(t+8,e.z,!0),this._dataView.setFloat32(t+12,e.w,!0))},e.prototype.setFloat32=function(e,t){isNaN(e)&&d.Tools.Error("Invalid data being written!"),null!=t&&(tthis._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setFloat32(this._byteOffset,e,!0),this._byteOffset+=4},e.prototype.setUInt32=function(e,t){null!=t?tthis._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint32(this._byteOffset,e,!0),this._byteOffset+=4)},e.prototype.setInt16=function(e,t){null!=t?tthis._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setInt16(this._byteOffset,e,!0),this._byteOffset+=2)},e.prototype.setByte=function(e,t){null!=t?tthis._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setInt8(this._byteOffset,e),this._byteOffset++)},e}(),b=function(){function e(){}return e.GLTFAsync=function(e,t,r){return e.whenReadyAsync().then((function(){var n=t.replace(/\.[^/.]+$/,"");return new T(e,r)._generateGLTFAsync(n)}))},e._PreExportAsync=function(e,t){return Promise.resolve().then((function(){return t&&t.exportWithoutWaitingForScene?Promise.resolve():e.whenReadyAsync()}))},e._PostExportAsync=function(e,t,r){return Promise.resolve().then((function(){return r&&r.exportWithoutWaitingForScene,t}))},e.GLBAsync=function(e,t,r){var n=this;return this._PreExportAsync(e,r).then((function(){var a=t.replace(/\.[^/.]+$/,"");return new T(e,r)._generateGLBAsync(a).then((function(t){return n._PostExportAsync(e,t,r)}))}))},e}(),A="KHR_texture_transform",E=function(){function e(){this.name=A,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportTexture=function(e,t,r){if(r&&(0===r.uAng&&0===r.wAng&&0===r.vAng||0===r.uRotationCenter&&0===r.vRotationCenter)){var n={},a=!1;if(0===r.uOffset&&0===r.vOffset||(n.offset=[r.uOffset,r.vOffset],a=!0),1===r.uScale&&1===r.vScale||(n.scale=[r.uScale,r.vScale],a=!0),0!==r.wAng&&(n.rotation=-r.wAng,a=!0),0!==r.coordinatesIndex&&(n.texCoord=r.coordinatesIndex,a=!0),!a)return;this._wasUsed=!0,t.extensions||(t.extensions={}),t.extensions[A]=n}},e.prototype.preExportTextureAsync=function(e,t){return new Promise((function(r,n){t.getScene()?0!==t.uAng||0!==t.vAng?(d.Tools.Warn("".concat(e,": Texture ").concat(t.name," with rotation in the u or v axis is not supported in glTF.")),r(null)):0===t.wAng||0===t.uRotationCenter&&0===t.vRotationCenter?r(t):(d.Tools.Warn("".concat(e,": Texture ").concat(t.name," with rotation not centered at the origin cannot be exported with ").concat(A)),r(null)):n("".concat(e,': "scene" is not defined for Babylon texture ').concat(t.name,"!"))}))},e}();T.RegisterExtension(A,(function(){return new E}));var M="KHR_lights_punctual",F=function(){function e(e){this.name=M,this.enabled=!0,this.required=!1,this._exporter=e}return e.prototype.dispose=function(){this._lights=null},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return!!this._lights},enumerable:!1,configurable:!0}),e.prototype.onExporting=function(){this._exporter._glTF.extensions[M]=this._lights},e.prototype.postExportNodeAsync=function(e,t,r,n){var a=this;return new Promise((function(i){if(t&&r instanceof d.ShadowLight){var o=void 0,s=r.getTypeID()==d.Light.LIGHTTYPEID_POINTLIGHT?"point":r.getTypeID()==d.Light.LIGHTTYPEID_DIRECTIONALLIGHT?"directional":r.getTypeID()==d.Light.LIGHTTYPEID_SPOTLIGHT?"spot":null;if(null==s)d.Logger.Warn("".concat(e,": Light ").concat(r.name," is not supported in ").concat(M));else{if(r.position.equalsToFloats(0,0,0)||(t.translation=r.position.asArray()),"point"!==s){var u=r.direction,l=-Math.atan2(u.z,u.x)+Math.PI/2,c=Math.sqrt(u.x*u.x+u.z*u.z),f=-Math.atan2(u.y,c),h=d.Quaternion.RotationYawPitchRoll(l+Math.PI,f,0);d.Quaternion.IsIdentity(h)||(t.rotation=h.asArray())}if(r.falloffType!==d.Light.FALLOFF_GLTF&&d.Logger.Warn("".concat(e,": Light falloff for ").concat(r.name," does not match the ").concat(M," specification!")),o={type:s},r.diffuse.equals(d.Color3.White())||(o.color=r.diffuse.asArray()),1!==r.intensity&&(o.intensity=r.intensity),r.range!==Number.MAX_VALUE&&(o.range=r.range),"spot"===s){var p=r;p.angle!==Math.PI/2&&(null==o.spot&&(o.spot={}),o.spot.outerConeAngle=p.angle/2),0!==p.innerAngle&&(null==o.spot&&(o.spot={}),o.spot.innerConeAngle=p.innerAngle/2)}a._lights||(a._lights={lights:[]}),a._lights.lights.push(o);var _={light:a._lights.lights.length-1},g=r.parent;if(g&&1==g.getChildren().length){var m=a._exporter._nodes[n[g.uniqueId]];if(m){var x=d.Vector3.FromArrayToRef(m.translation||[0,0,0],0,d.TmpVectors.Vector3[0]),y=d.Quaternion.FromArrayToRef(m.rotation||[0,0,0,1],0,d.TmpVectors.Quaternion[0]),T=d.Vector3.FromArrayToRef(m.scale||[1,1,1],0,d.TmpVectors.Vector3[1]),v=d.Matrix.ComposeToRef(T,y,x,d.TmpVectors.Matrix[0]),b=d.Vector3.FromArrayToRef(t.translation||[0,0,0],0,d.TmpVectors.Vector3[2]),A=d.Quaternion.FromArrayToRef(t.rotation||[0,0,0,1],0,d.TmpVectors.Quaternion[1]),E=d.Matrix.ComposeToRef(d.Vector3.OneReadOnly,A,b,d.TmpVectors.Matrix[1]);return v.multiplyToRef(E,E),E.decompose(T,y,x),x.equalsToFloats(0,0,0)?delete m.translation:m.translation=x.asArray(),d.Quaternion.IsIdentity(y)?delete m.rotation:m.rotation=y.asArray(),T.equalsToFloats(1,1,1)?delete m.scale:m.scale=T.asArray(),m.extensions||(m.extensions={}),m.extensions[M]=_,void i(null)}}t.extensions||(t.extensions={}),t.extensions[M]=_}}i(t)}))},e}();T.RegisterExtension(M,(function(e){return new F(e)}));var w="KHR_materials_clearcoat",C=function(){function e(e){this.name=w,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRBaseMaterial&&r.clearCoat.isEnabled?(r.clearCoat.texture&&n.push(r.clearCoat.texture),!r.clearCoat.useRoughnessFromMainTexture&&r.clearCoat.textureRoughness&&n.push(r.clearCoat.textureRoughness),r.clearCoat.bumpTexture&&n.push(r.clearCoat.bumpTexture),n):[]},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){if(r instanceof d.PBRBaseMaterial){if(!r.clearCoat.isEnabled)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var a,i=n._exporter._glTFMaterialExporter._getTextureInfo(r.clearCoat.texture);a=r.clearCoat.useRoughnessFromMainTexture?n._exporter._glTFMaterialExporter._getTextureInfo(r.clearCoat.texture):n._exporter._glTFMaterialExporter._getTextureInfo(r.clearCoat.textureRoughness),r.clearCoat.isTintEnabled&&d.Tools.Warn("Clear Color tint is not supported for glTF export. Ignoring for: ".concat(r.name)),r.clearCoat.remapF0OnInterfaceChange&&d.Tools.Warn("Clear Color F0 remapping is not supported for glTF export. Ignoring for: ".concat(r.name));var o=n._exporter._glTFMaterialExporter._getTextureInfo(r.clearCoat.bumpTexture),s={clearcoatFactor:r.clearCoat.intensity,clearcoatTexture:null!=i?i:void 0,clearcoatRoughnessFactor:r.clearCoat.roughness,clearcoatRoughnessTexture:null!=a?a:void 0,clearcoatNormalTexture:null!=o?o:void 0,hasTextures:function(){return null!==s.clearcoatTexture||null!==s.clearcoatRoughnessTexture||null!==s.clearcoatRoughnessTexture}};t.extensions[w]=s}e(t)}))},e}();T.RegisterExtension(w,(function(e){return new C(e)}));var V="KHR_materials_iridescence",R=function(){function e(e){this.name=V,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRBaseMaterial&&r.iridescence.isEnabled?(r.iridescence.texture&&n.push(r.iridescence.texture),r.iridescence.thicknessTexture&&r.iridescence.thicknessTexture!==r.iridescence.texture&&n.push(r.iridescence.thicknessTexture),n):[]},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){if(r instanceof d.PBRBaseMaterial){if(!r.iridescence.isEnabled)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var a=n._exporter._glTFMaterialExporter._getTextureInfo(r.iridescence.texture),i=n._exporter._glTFMaterialExporter._getTextureInfo(r.iridescence.thicknessTexture),o={iridescenceFactor:r.iridescence.intensity,iridescenceIor:r.iridescence.indexOfRefraction,iridescenceThicknessMinimum:r.iridescence.minimumThickness,iridescenceThicknessMaximum:r.iridescence.maximumThickness,iridescenceTexture:null!=a?a:void 0,iridescenceThicknessTexture:null!=i?i:void 0,hasTextures:function(){return null!==o.iridescenceTexture||null!==o.iridescenceThicknessTexture}};t.extensions[V]=o}e(t)}))},e}();T.RegisterExtension(V,(function(e){return new R(e)}));var S="KHR_materials_anisotropy",I=function(){function e(e){this.name=S,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRBaseMaterial&&r.anisotropy.isEnabled&&!r.anisotropy.legacy?(r.anisotropy.texture&&n.push(r.anisotropy.texture),n):[]},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){if(r instanceof d.PBRBaseMaterial){if(!r.anisotropy.isEnabled||r.anisotropy.legacy)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var a=n._exporter._glTFMaterialExporter._getTextureInfo(r.anisotropy.texture),i={anisotropyStrength:r.anisotropy.intensity,anisotropyRotation:r.anisotropy.angle,anisotropyTexture:null!=a?a:void 0,hasTextures:function(){return null!==i.anisotropyTexture}};t.extensions[S]=i}e(t)}))},e}();T.RegisterExtension(S,(function(e){return new I(e)}));var B="KHR_materials_sheen",P=function(){function e(e){this.name=B,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTextures=function(e,t,r){return r instanceof d.PBRMaterial&&r.sheen.isEnabled&&r.sheen.texture?[r.sheen.texture]:[]},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){var a,i,o,s;if(r instanceof d.PBRMaterial){if(!r.sheen.isEnabled)return void e(t);n._wasUsed=!0,null==t.extensions&&(t.extensions={});var u={sheenColorFactor:r.sheen.color.asArray(),sheenRoughnessFactor:null!==(a=r.sheen.roughness)&&void 0!==a?a:0,hasTextures:function(){return null!==u.sheenColorTexture||null!==u.sheenRoughnessTexture}};r.sheen.texture&&(u.sheenColorTexture=null!==(i=n._exporter._glTFMaterialExporter._getTextureInfo(r.sheen.texture))&&void 0!==i?i:void 0),r.sheen.textureRoughness&&!r.sheen.useRoughnessFromMainTexture?u.sheenRoughnessTexture=null!==(o=n._exporter._glTFMaterialExporter._getTextureInfo(r.sheen.textureRoughness))&&void 0!==o?o:void 0:r.sheen.texture&&r.sheen.useRoughnessFromMainTexture&&(u.sheenRoughnessTexture=null!==(s=n._exporter._glTFMaterialExporter._getTextureInfo(r.sheen.texture))&&void 0!==s?s:void 0),t.extensions[B]=u}e(t)}))},e}();T.RegisterExtension(B,(function(e){return new P(e)}));var N="KHR_materials_unlit",L=function(){function e(){this.name=N,this.enabled=!0,this.required=!1,this._wasUsed=!1}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){var a=!1;r instanceof d.PBRMaterial?a=r.unlit:r instanceof d.StandardMaterial&&(a=r.disableLighting),a&&(n._wasUsed=!0,null==t.extensions&&(t.extensions={}),t.extensions[N]={}),e(t)}))},e}();T.RegisterExtension(N,(function(){return new L}));var O="KHR_materials_ior",k=function(){function e(){this.name=O,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype._isExtensionEnabled=function(e){return!e.unlit&&null!=e.indexOfRefraction&&1.5!=e.indexOfRefraction},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){if(r instanceof d.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var a={ior:r.indexOfRefraction};t.extensions=t.extensions||{},t.extensions[O]=a}e(t)}))},e}();T.RegisterExtension(O,(function(e){return new k}));var U="KHR_materials_specular",K=function(){function e(e){this.name=U,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRMaterial&&this._isExtensionEnabled(r)?(r.metallicReflectanceTexture&&n.push(r.metallicReflectanceTexture),r.reflectanceTexture&&n.push(r.reflectanceTexture),n):n},e.prototype._isExtensionEnabled=function(e){return!e.unlit&&(null!=e.metallicF0Factor&&1!=e.metallicF0Factor||null!=e.metallicReflectanceColor&&!e.metallicReflectanceColor.equalsFloats(1,1,1)||this._hasTexturesExtension(e))},e.prototype._hasTexturesExtension=function(e){return null!=e.metallicReflectanceTexture||null!=e.reflectanceTexture},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){var a,i;if(r instanceof d.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0,t.extensions=t.extensions||{};var o=null!==(a=n._exporter._glTFMaterialExporter._getTextureInfo(r.metallicReflectanceTexture))&&void 0!==a?a:void 0,s=null!==(i=n._exporter._glTFMaterialExporter._getTextureInfo(r.reflectanceTexture))&&void 0!==i?i:void 0,u={specularFactor:1==r.metallicF0Factor?void 0:r.metallicF0Factor,specularTexture:o,specularColorFactor:r.metallicReflectanceColor.equalsFloats(1,1,1)?void 0:r.metallicReflectanceColor.asArray(),specularColorTexture:s,hasTextures:function(){return n._hasTexturesExtension(r)}};t.extensions[U]=u}e(t)}))},e}();T.RegisterExtension(U,(function(e){return new K(e)}));var D="KHR_materials_volume",G=function(){function e(e){this.name=D,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRMaterial&&this._isExtensionEnabled(r)?(r.subSurface.thicknessTexture&&n.push(r.subSurface.thicknessTexture),n):n},e.prototype._isExtensionEnabled=function(e){if(e.unlit)return!1;var t=e.subSurface;return!(!t.isRefractionEnabled&&!t.isTranslucencyEnabled)&&(null!=t.maximumThickness&&0!=t.maximumThickness||null!=t.tintColorAtDistance&&t.tintColorAtDistance!=Number.POSITIVE_INFINITY||null!=t.tintColor&&t.tintColor!=d.Color3.White()||this._hasTexturesExtension(e))},e.prototype._hasTexturesExtension=function(e){return null!=e.subSurface.thicknessTexture},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){var a;if(r instanceof d.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var i=r.subSurface,o={thicknessFactor:0==i.maximumThickness?void 0:i.maximumThickness,thicknessTexture:null!==(a=n._exporter._glTFMaterialExporter._getTextureInfo(i.thicknessTexture))&&void 0!==a?a:void 0,attenuationDistance:i.tintColorAtDistance==Number.POSITIVE_INFINITY?void 0:i.tintColorAtDistance,attenuationColor:i.tintColor.equalsFloats(1,1,1)?void 0:i.tintColor.asArray(),hasTextures:function(){return n._hasTexturesExtension(r)}};t.extensions=t.extensions||{},t.extensions[D]=o}e(t)}))},e}();T.RegisterExtension(D,(function(e){return new G(e)}));var W="KHR_materials_transmission",z=function(){function e(e){this.name=W,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRMaterial&&this._isExtensionEnabled(r)?(r.subSurface.thicknessTexture&&n.push(r.subSurface.thicknessTexture),n):n},e.prototype._isExtensionEnabled=function(e){if(e.unlit)return!1;var t=e.subSurface;return t.isRefractionEnabled&&null!=t.refractionIntensity&&0!=t.refractionIntensity||this._hasTexturesExtension(e)},e.prototype._hasTexturesExtension=function(e){return null!=e.subSurface.refractionIntensityTexture},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){var a;if(r instanceof d.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var i=r.subSurface,o={transmissionFactor:0===i.refractionIntensity?void 0:i.refractionIntensity,transmissionTexture:null!==(a=n._exporter._glTFMaterialExporter._getTextureInfo(i.refractionIntensityTexture))&&void 0!==a?a:void 0,hasTextures:function(){return n._hasTexturesExtension(r)}};t.extensions=t.extensions||{},t.extensions[W]=o}e(t)}))},e}();T.RegisterExtension(W,(function(e){return new z(e)}));var q="EXT_mesh_gpu_instancing",H=function(){function e(e){this.name=q,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportNodeAsync=function(e,t,r,n,a){var i=this;return new Promise((function(e){if(t&&r instanceof d.Mesh&&r.hasThinInstances&&a){i._wasUsed=!0;for(var n=d.Vector3.Zero(),o=d.Quaternion.Identity(),s=d.Vector3.One(),u=r.thinInstanceGetWorldMatrices(),l=d.TmpVectors.Vector3[2],c=d.TmpVectors.Quaternion[1],f=d.TmpVectors.Vector3[3],h=!1,p=!1,_=!1,g=new Float32Array(3*r.thinInstanceCount),m=new Float32Array(4*r.thinInstanceCount),x=new Float32Array(3*r.thinInstanceCount),y=0,T=0,v=u;T1){n._wasUsed=!0,t.extensions||(t.extensions={});var o={emissiveStrength:i},s=r.emissiveColor.scale(1/o.emissiveStrength);t.emissiveFactor=s.asArray(),t.extensions[j]=o}return e(t)}))},e}();T.RegisterExtension(j,(function(e){return new Q}));var Y=0,X=void 0!==n.g?n.g:"undefined"!=typeof window?window:void 0;if(void 0!==X){X.BABYLON=X.BABYLON||{};var Z=X.BABYLON;Z.GLTF2=Z.GLTF2||{},Z.GLTF2.Exporter=Z.GLTF2.Exporter||{},Z.GLTF2.Exporter.Extensions=Z.GLTF2.Exporter.Extensions||{};var J=[];for(var $ in e)Z[$]=e[$],J.push($);for(var $ in t)Z[$]=t[$],J.push($);for(var $ in r)Z[$]=r[$],J.push($);for(var $ in i)Z.GLTF2.Exporter.Extensions[$]=i[$],J.push($);for(var $ in o)J.indexOf($)>-1||(Z.GLTF2.Exporter[$]=o[$])}const ee=s})(),a.default})())); +//# sourceMappingURL=babylon.glTF2Serializer.min.js.map \ No newline at end of file diff --git a/libs/babylonjs/6.23.0/babylon.glTFFileLoader.js b/libs/babylonjs/6.23.0/babylon.glTFFileLoader.js new file mode 100644 index 00000000..b53daea8 --- /dev/null +++ b/libs/babylonjs/6.23.0/babylon.glTFFileLoader.js @@ -0,0 +1,10473 @@ +(function webpackUniversalModuleDefinition(root, factory) { + if(typeof exports === 'object' && typeof module === 'object') + module.exports = factory(require("babylonjs")); + else if(typeof define === 'function' && define.amd) + define("babylonjs-loaders", ["babylonjs"], factory); + else if(typeof exports === 'object') + exports["babylonjs-loaders"] = factory(require("babylonjs")); + else + root["LOADERS"] = factory(root["BABYLON"]); +})((typeof self !== "undefined" ? self : typeof global !== "undefined" ? global : this), (__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__) => { +return /******/ (() => { // webpackBootstrap +/******/ "use strict"; +/******/ var __webpack_modules__ = ({ + +/***/ "../../../dev/loaders/src/glTF/1.0/glTFBinaryExtension.ts": +/*!****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/1.0/glTFBinaryExtension.ts ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFBinaryExtension: () => (/* binding */ GLTFBinaryExtension) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoader */ "../../../dev/loaders/src/glTF/1.0/glTFLoader.ts"); +/* harmony import */ var _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFLoaderUtils */ "../../../dev/loaders/src/glTF/1.0/glTFLoaderUtils.ts"); +/* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../dev/loaders/src/glTF/1.0/glTFLoaderInterfaces.ts"); + + + + +var BinaryExtensionBufferName = "binary_glTF"; +/** + * @internal + * @deprecated + */ +var GLTFBinaryExtension = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_3__.__extends)(GLTFBinaryExtension, _super); + function GLTFBinaryExtension() { + return _super.call(this, "KHR_binary_glTF") || this; + } + GLTFBinaryExtension.prototype.loadRuntimeAsync = function (scene, data, rootUrl, onSuccess) { + var extensionsUsed = data.json.extensionsUsed; + if (!extensionsUsed || extensionsUsed.indexOf(this.name) === -1 || !data.bin) { + return false; + } + this._bin = data.bin; + onSuccess(_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderBase.CreateRuntime(data.json, scene, rootUrl)); + return true; + }; + GLTFBinaryExtension.prototype.loadBufferAsync = function (gltfRuntime, id, onSuccess, onError) { + if (gltfRuntime.extensionsUsed.indexOf(this.name) === -1) { + return false; + } + if (id !== BinaryExtensionBufferName) { + return false; + } + this._bin.readAsync(0, this._bin.byteLength).then(onSuccess, function (error) { return onError(error.message); }); + return true; + }; + GLTFBinaryExtension.prototype.loadTextureBufferAsync = function (gltfRuntime, id, onSuccess) { + var texture = gltfRuntime.textures[id]; + var source = gltfRuntime.images[texture.source]; + if (!source.extensions || !(this.name in source.extensions)) { + return false; + } + var sourceExt = source.extensions[this.name]; + var bufferView = gltfRuntime.bufferViews[sourceExt.bufferView]; + var buffer = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_1__.GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EComponentType.UNSIGNED_BYTE); + onSuccess(buffer); + return true; + }; + GLTFBinaryExtension.prototype.loadShaderStringAsync = function (gltfRuntime, id, onSuccess) { + var shader = gltfRuntime.shaders[id]; + if (!shader.extensions || !(this.name in shader.extensions)) { + return false; + } + var binaryExtensionShader = shader.extensions[this.name]; + var bufferView = gltfRuntime.bufferViews[binaryExtensionShader.bufferView]; + var shaderBytes = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_1__.GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EComponentType.UNSIGNED_BYTE); + setTimeout(function () { + var shaderString = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_1__.GLTFUtils.DecodeBufferToText(shaderBytes); + onSuccess(shaderString); + }); + return true; + }; + return GLTFBinaryExtension; +}(_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderExtension)); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(new GLTFBinaryExtension()); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/1.0/glTFLoader.ts": +/*!*******************************************************!*\ + !*** ../../../dev/loaders/src/glTF/1.0/glTFLoader.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFLoader: () => (/* binding */ GLTFLoader), +/* harmony export */ GLTFLoaderBase: () => (/* binding */ GLTFLoaderBase), +/* harmony export */ GLTFLoaderExtension: () => (/* binding */ GLTFLoaderExtension) +/* harmony export */ }); +/* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../dev/loaders/src/glTF/1.0/glTFLoaderInterfaces.ts"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Engines/constants */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderUtils */ "../../../dev/loaders/src/glTF/1.0/glTFLoaderUtils.ts"); +/* harmony import */ var _glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../glTFFileLoader */ "../../../dev/loaders/src/glTF/glTFFileLoader.ts"); + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/** + * Tokenizer. Used for shaders compatibility + * Automatically map world, view, projection, worldViewProjection, attributes and so on + */ +var ETokenType; +(function (ETokenType) { + ETokenType[ETokenType["IDENTIFIER"] = 1] = "IDENTIFIER"; + ETokenType[ETokenType["UNKNOWN"] = 2] = "UNKNOWN"; + ETokenType[ETokenType["END_OF_INPUT"] = 3] = "END_OF_INPUT"; +})(ETokenType || (ETokenType = {})); +var Tokenizer = /** @class */ (function () { + function Tokenizer(toParse) { + this._pos = 0; + this.currentToken = ETokenType.UNKNOWN; + this.currentIdentifier = ""; + this.currentString = ""; + this.isLetterOrDigitPattern = /^[a-zA-Z0-9]+$/; + this._toParse = toParse; + this._maxPos = toParse.length; + } + Tokenizer.prototype.getNextToken = function () { + if (this.isEnd()) { + return ETokenType.END_OF_INPUT; + } + this.currentString = this.read(); + this.currentToken = ETokenType.UNKNOWN; + if (this.currentString === "_" || this.isLetterOrDigitPattern.test(this.currentString)) { + this.currentToken = ETokenType.IDENTIFIER; + this.currentIdentifier = this.currentString; + while (!this.isEnd() && (this.isLetterOrDigitPattern.test((this.currentString = this.peek())) || this.currentString === "_")) { + this.currentIdentifier += this.currentString; + this.forward(); + } + } + return this.currentToken; + }; + Tokenizer.prototype.peek = function () { + return this._toParse[this._pos]; + }; + Tokenizer.prototype.read = function () { + return this._toParse[this._pos++]; + }; + Tokenizer.prototype.forward = function () { + this._pos++; + }; + Tokenizer.prototype.isEnd = function () { + return this._pos >= this._maxPos; + }; + return Tokenizer; +}()); +/** + * Values + */ +var glTFTransforms = ["MODEL", "VIEW", "PROJECTION", "MODELVIEW", "MODELVIEWPROJECTION", "JOINTMATRIX"]; +var babylonTransforms = ["world", "view", "projection", "worldView", "worldViewProjection", "mBones"]; +var glTFAnimationPaths = ["translation", "rotation", "scale"]; +var babylonAnimationPaths = ["position", "rotationQuaternion", "scaling"]; +/** + * Parse + * @param parsedBuffers + * @param gltfRuntime + */ +var parseBuffers = function (parsedBuffers, gltfRuntime) { + for (var buf in parsedBuffers) { + var parsedBuffer = parsedBuffers[buf]; + gltfRuntime.buffers[buf] = parsedBuffer; + gltfRuntime.buffersCount++; + } +}; +var parseShaders = function (parsedShaders, gltfRuntime) { + for (var sha in parsedShaders) { + var parsedShader = parsedShaders[sha]; + gltfRuntime.shaders[sha] = parsedShader; + gltfRuntime.shaderscount++; + } +}; +var parseObject = function (parsedObjects, runtimeProperty, gltfRuntime) { + for (var object in parsedObjects) { + var parsedObject = parsedObjects[object]; + gltfRuntime[runtimeProperty][object] = parsedObject; + } +}; +/** + * Utils + * @param buffer + */ +var normalizeUVs = function (buffer) { + if (!buffer) { + return; + } + for (var i = 0; i < buffer.length / 2; i++) { + buffer[i * 2 + 1] = 1.0 - buffer[i * 2 + 1]; + } +}; +var getAttribute = function (attributeParameter) { + if (attributeParameter.semantic === "NORMAL") { + return "normal"; + } + else if (attributeParameter.semantic === "POSITION") { + return "position"; + } + else if (attributeParameter.semantic === "JOINT") { + return "matricesIndices"; + } + else if (attributeParameter.semantic === "WEIGHT") { + return "matricesWeights"; + } + else if (attributeParameter.semantic === "COLOR") { + return "color"; + } + else if (attributeParameter.semantic && attributeParameter.semantic.indexOf("TEXCOORD_") !== -1) { + var channel = Number(attributeParameter.semantic.split("_")[1]); + return "uv" + (channel === 0 ? "" : channel + 1); + } + return null; +}; +/** + * Loads and creates animations + * @param gltfRuntime + */ +var loadAnimations = function (gltfRuntime) { + for (var anim in gltfRuntime.animations) { + var animation = gltfRuntime.animations[anim]; + if (!animation.channels || !animation.samplers) { + continue; + } + var lastAnimation = null; + for (var i = 0; i < animation.channels.length; i++) { + // Get parameters and load buffers + var channel = animation.channels[i]; + var sampler = animation.samplers[channel.sampler]; + if (!sampler) { + continue; + } + var inputData = null; + var outputData = null; + if (animation.parameters) { + inputData = animation.parameters[sampler.input]; + outputData = animation.parameters[sampler.output]; + } + else { + inputData = sampler.input; + outputData = sampler.output; + } + var bufferInput = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromAccessor(gltfRuntime, gltfRuntime.accessors[inputData]); + var bufferOutput = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromAccessor(gltfRuntime, gltfRuntime.accessors[outputData]); + var targetId = channel.target.id; + var targetNode = gltfRuntime.scene.getNodeById(targetId); + if (targetNode === null) { + targetNode = gltfRuntime.scene.getNodeByName(targetId); + } + if (targetNode === null) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Creating animation named " + anim + ". But cannot find node named " + targetId + " to attach to"); + continue; + } + var isBone = targetNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Bone; + // Get target path (position, rotation or scaling) + var targetPath = channel.target.path; + var targetPathIndex = glTFAnimationPaths.indexOf(targetPath); + if (targetPathIndex !== -1) { + targetPath = babylonAnimationPaths[targetPathIndex]; + } + // Determine animation type + var animationType = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_MATRIX; + if (!isBone) { + if (targetPath === "rotationQuaternion") { + animationType = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_QUATERNION; + targetNode.rotationQuaternion = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion(); + } + else { + animationType = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONTYPE_VECTOR3; + } + } + // Create animation and key frames + var babylonAnimation = null; + var keys = []; + var arrayOffset = 0; + var modifyKey = false; + if (isBone && lastAnimation && lastAnimation.getKeys().length === bufferInput.length) { + babylonAnimation = lastAnimation; + modifyKey = true; + } + if (!modifyKey) { + gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer; + babylonAnimation = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation(anim, isBone ? "_matrix" : targetPath, 1, animationType, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Animation.ANIMATIONLOOPMODE_CYCLE); + gltfRuntime.scene._blockEntityCollection = false; + } + // For each frame + for (var j = 0; j < bufferInput.length; j++) { + var value = null; + if (targetPath === "rotationQuaternion") { + // VEC4 + value = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromArray([bufferOutput[arrayOffset], bufferOutput[arrayOffset + 1], bufferOutput[arrayOffset + 2], bufferOutput[arrayOffset + 3]]); + arrayOffset += 4; + } + else { + // Position and scaling are VEC3 + value = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray([bufferOutput[arrayOffset], bufferOutput[arrayOffset + 1], bufferOutput[arrayOffset + 2]]); + arrayOffset += 3; + } + if (isBone) { + var bone = targetNode; + var translation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(); + var rotationQuaternion = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion(); + var scaling = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(); + // Warning on decompose + var mat = bone.getBaseMatrix(); + if (modifyKey && lastAnimation) { + mat = lastAnimation.getKeys()[j].value; + } + mat.decompose(scaling, rotationQuaternion, translation); + if (targetPath === "position") { + translation = value; + } + else if (targetPath === "rotationQuaternion") { + rotationQuaternion = value; + } + else { + scaling = value; + } + value = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.Compose(scaling, rotationQuaternion, translation); + } + if (!modifyKey) { + keys.push({ + frame: bufferInput[j], + value: value, + }); + } + else if (lastAnimation) { + lastAnimation.getKeys()[j].value = value; + } + } + // Finish + if (!modifyKey && babylonAnimation) { + babylonAnimation.setKeys(keys); + targetNode.animations.push(babylonAnimation); + } + lastAnimation = babylonAnimation; + gltfRuntime.scene.stopAnimation(targetNode); + gltfRuntime.scene.beginAnimation(targetNode, 0, bufferInput[bufferInput.length - 1], true, 1.0); + } + } +}; +/** + * Returns the bones transformation matrix + * @param node + */ +var configureBoneTransformation = function (node) { + var mat = null; + if (node.translation || node.rotation || node.scale) { + var scale = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(node.scale || [1, 1, 1]); + var rotation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromArray(node.rotation || [0, 0, 0, 1]); + var position = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(node.translation || [0, 0, 0]); + mat = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.Compose(scale, rotation, position); + } + else { + mat = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.FromArray(node.matrix); + } + return mat; +}; +/** + * Returns the parent bone + * @param gltfRuntime + * @param skins + * @param jointName + * @param newSkeleton + */ +var getParentBone = function (gltfRuntime, skins, jointName, newSkeleton) { + // Try to find + for (var i = 0; i < newSkeleton.bones.length; i++) { + if (newSkeleton.bones[i].name === jointName) { + return newSkeleton.bones[i]; + } + } + // Not found, search in gltf nodes + var nodes = gltfRuntime.nodes; + for (var nde in nodes) { + var node = nodes[nde]; + if (!node.jointName) { + continue; + } + var children = node.children; + for (var i = 0; i < children.length; i++) { + var child = gltfRuntime.nodes[children[i]]; + if (!child.jointName) { + continue; + } + if (child.jointName === jointName) { + var mat = configureBoneTransformation(node); + var bone = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Bone(node.name || "", newSkeleton, getParentBone(gltfRuntime, skins, node.jointName, newSkeleton), mat); + bone.id = nde; + return bone; + } + } + } + return null; +}; +/** + * Returns the appropriate root node + * @param nodesToRoot + * @param id + */ +var getNodeToRoot = function (nodesToRoot, id) { + for (var i = 0; i < nodesToRoot.length; i++) { + var nodeToRoot = nodesToRoot[i]; + for (var j = 0; j < nodeToRoot.node.children.length; j++) { + var child = nodeToRoot.node.children[j]; + if (child === id) { + return nodeToRoot.bone; + } + } + } + return null; +}; +/** + * Returns the node with the joint name + * @param gltfRuntime + * @param jointName + */ +var getJointNode = function (gltfRuntime, jointName) { + var nodes = gltfRuntime.nodes; + var node = nodes[jointName]; + if (node) { + return { + node: node, + id: jointName, + }; + } + for (var nde in nodes) { + node = nodes[nde]; + if (node.jointName === jointName) { + return { + node: node, + id: nde, + }; + } + } + return null; +}; +/** + * Checks if a nodes is in joints + * @param skins + * @param id + */ +var nodeIsInJoints = function (skins, id) { + for (var i = 0; i < skins.jointNames.length; i++) { + if (skins.jointNames[i] === id) { + return true; + } + } + return false; +}; +/** + * Fills the nodes to root for bones and builds hierarchy + * @param gltfRuntime + * @param newSkeleton + * @param skins + * @param nodesToRoot + */ +var getNodesToRoot = function (gltfRuntime, newSkeleton, skins, nodesToRoot) { + // Creates nodes for root + for (var nde in gltfRuntime.nodes) { + var node = gltfRuntime.nodes[nde]; + var id = nde; + if (!node.jointName || nodeIsInJoints(skins, node.jointName)) { + continue; + } + // Create node to root bone + var mat = configureBoneTransformation(node); + var bone = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Bone(node.name || "", newSkeleton, null, mat); + bone.id = id; + nodesToRoot.push({ bone: bone, node: node, id: id }); + } + // Parenting + for (var i = 0; i < nodesToRoot.length; i++) { + var nodeToRoot = nodesToRoot[i]; + var children = nodeToRoot.node.children; + for (var j = 0; j < children.length; j++) { + var child = null; + for (var k = 0; k < nodesToRoot.length; k++) { + if (nodesToRoot[k].id === children[j]) { + child = nodesToRoot[k]; + break; + } + } + if (child) { + child.bone._parent = nodeToRoot.bone; + nodeToRoot.bone.children.push(child.bone); + } + } + } +}; +/** + * Imports a skeleton + * @param gltfRuntime + * @param skins + * @param mesh + * @param newSkeleton + */ +var importSkeleton = function (gltfRuntime, skins, mesh, newSkeleton) { + if (!newSkeleton) { + newSkeleton = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Skeleton(skins.name || "", "", gltfRuntime.scene); + } + if (!skins.babylonSkeleton) { + return newSkeleton; + } + // Find the root bones + var nodesToRoot = []; + var nodesToRootToAdd = []; + getNodesToRoot(gltfRuntime, newSkeleton, skins, nodesToRoot); + newSkeleton.bones = []; + // Joints + for (var i = 0; i < skins.jointNames.length; i++) { + var jointNode = getJointNode(gltfRuntime, skins.jointNames[i]); + if (!jointNode) { + continue; + } + var node = jointNode.node; + if (!node) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Joint named " + skins.jointNames[i] + " does not exist"); + continue; + } + var id = jointNode.id; + // Optimize, if the bone already exists... + var existingBone = gltfRuntime.scene.getBoneById(id); + if (existingBone) { + newSkeleton.bones.push(existingBone); + continue; + } + // Search for parent bone + var foundBone = false; + var parentBone = null; + for (var j = 0; j < i; j++) { + var jointNode_1 = getJointNode(gltfRuntime, skins.jointNames[j]); + if (!jointNode_1) { + continue; + } + var joint = jointNode_1.node; + if (!joint) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Joint named " + skins.jointNames[j] + " does not exist when looking for parent"); + continue; + } + var children = joint.children; + if (!children) { + continue; + } + foundBone = false; + for (var k = 0; k < children.length; k++) { + if (children[k] === id) { + parentBone = getParentBone(gltfRuntime, skins, skins.jointNames[j], newSkeleton); + foundBone = true; + break; + } + } + if (foundBone) { + break; + } + } + // Create bone + var mat = configureBoneTransformation(node); + if (!parentBone && nodesToRoot.length > 0) { + parentBone = getNodeToRoot(nodesToRoot, id); + if (parentBone) { + if (nodesToRootToAdd.indexOf(parentBone) === -1) { + nodesToRootToAdd.push(parentBone); + } + } + } + var bone = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Bone(node.jointName || "", newSkeleton, parentBone, mat); + bone.id = id; + } + // Polish + var bones = newSkeleton.bones; + newSkeleton.bones = []; + for (var i = 0; i < skins.jointNames.length; i++) { + var jointNode = getJointNode(gltfRuntime, skins.jointNames[i]); + if (!jointNode) { + continue; + } + for (var j = 0; j < bones.length; j++) { + if (bones[j].id === jointNode.id) { + newSkeleton.bones.push(bones[j]); + break; + } + } + } + newSkeleton.prepare(); + // Finish + for (var i = 0; i < nodesToRootToAdd.length; i++) { + newSkeleton.bones.push(nodesToRootToAdd[i]); + } + return newSkeleton; +}; +/** + * Imports a mesh and its geometries + * @param gltfRuntime + * @param node + * @param meshes + * @param id + * @param newMesh + */ +var importMesh = function (gltfRuntime, node, meshes, id, newMesh) { + if (!newMesh) { + gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer; + newMesh = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Mesh(node.name || "", gltfRuntime.scene); + newMesh._parentContainer = gltfRuntime.assetContainer; + gltfRuntime.scene._blockEntityCollection = false; + newMesh.id = id; + } + if (!node.babylonNode) { + return newMesh; + } + var subMaterials = []; + var vertexData = null; + var verticesStarts = new Array(); + var verticesCounts = new Array(); + var indexStarts = new Array(); + var indexCounts = new Array(); + for (var meshIndex = 0; meshIndex < meshes.length; meshIndex++) { + var meshId = meshes[meshIndex]; + var mesh = gltfRuntime.meshes[meshId]; + if (!mesh) { + continue; + } + // Positions, normals and UVs + for (var i = 0; i < mesh.primitives.length; i++) { + // Temporary vertex data + var tempVertexData = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.VertexData(); + var primitive = mesh.primitives[i]; + if (primitive.mode !== 4) { + // continue; + } + var attributes = primitive.attributes; + var accessor = null; + var buffer = null; + // Set positions, normal and uvs + for (var semantic in attributes) { + // Link accessor and buffer view + accessor = gltfRuntime.accessors[attributes[semantic]]; + buffer = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromAccessor(gltfRuntime, accessor); + if (semantic === "NORMAL") { + tempVertexData.normals = new Float32Array(buffer.length); + tempVertexData.normals.set(buffer); + } + else if (semantic === "POSITION") { + if (_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.HomogeneousCoordinates) { + tempVertexData.positions = new Float32Array(buffer.length - buffer.length / 4); + for (var j = 0; j < buffer.length; j += 4) { + tempVertexData.positions[j] = buffer[j]; + tempVertexData.positions[j + 1] = buffer[j + 1]; + tempVertexData.positions[j + 2] = buffer[j + 2]; + } + } + else { + tempVertexData.positions = new Float32Array(buffer.length); + tempVertexData.positions.set(buffer); + } + verticesCounts.push(tempVertexData.positions.length); + } + else if (semantic.indexOf("TEXCOORD_") !== -1) { + var channel = Number(semantic.split("_")[1]); + var uvKind = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.VertexBuffer.UVKind + (channel === 0 ? "" : channel + 1); + var uvs = new Float32Array(buffer.length); + uvs.set(buffer); + normalizeUVs(uvs); + tempVertexData.set(uvs, uvKind); + } + else if (semantic === "JOINT") { + tempVertexData.matricesIndices = new Float32Array(buffer.length); + tempVertexData.matricesIndices.set(buffer); + } + else if (semantic === "WEIGHT") { + tempVertexData.matricesWeights = new Float32Array(buffer.length); + tempVertexData.matricesWeights.set(buffer); + } + else if (semantic === "COLOR") { + tempVertexData.colors = new Float32Array(buffer.length); + tempVertexData.colors.set(buffer); + } + } + // Indices + accessor = gltfRuntime.accessors[primitive.indices]; + if (accessor) { + buffer = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetBufferFromAccessor(gltfRuntime, accessor); + tempVertexData.indices = new Int32Array(buffer.length); + tempVertexData.indices.set(buffer); + indexCounts.push(tempVertexData.indices.length); + } + else { + // Set indices on the fly + var indices = []; + for (var j = 0; j < tempVertexData.positions.length / 3; j++) { + indices.push(j); + } + tempVertexData.indices = new Int32Array(indices); + indexCounts.push(tempVertexData.indices.length); + } + if (!vertexData) { + vertexData = tempVertexData; + } + else { + vertexData.merge(tempVertexData); + } + // Sub material + var material_1 = gltfRuntime.scene.getMaterialById(primitive.material); + subMaterials.push(material_1 === null ? _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetDefaultMaterial(gltfRuntime.scene) : material_1); + // Update vertices start and index start + verticesStarts.push(verticesStarts.length === 0 ? 0 : verticesStarts[verticesStarts.length - 1] + verticesCounts[verticesCounts.length - 2]); + indexStarts.push(indexStarts.length === 0 ? 0 : indexStarts[indexStarts.length - 1] + indexCounts[indexCounts.length - 2]); + } + } + var material; + gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer; + if (subMaterials.length > 1) { + material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.MultiMaterial("multimat" + id, gltfRuntime.scene); + material.subMaterials = subMaterials; + } + else { + material = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.StandardMaterial("multimat" + id, gltfRuntime.scene); + } + if (subMaterials.length === 1) { + material = subMaterials[0]; + } + material._parentContainer = gltfRuntime.assetContainer; + if (!newMesh.material) { + newMesh.material = material; + } + // Apply geometry + new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Geometry(id, gltfRuntime.scene, vertexData, false, newMesh); + newMesh.computeWorldMatrix(true); + gltfRuntime.scene._blockEntityCollection = false; + // Apply submeshes + newMesh.subMeshes = []; + var index = 0; + for (var meshIndex = 0; meshIndex < meshes.length; meshIndex++) { + var meshId = meshes[meshIndex]; + var mesh = gltfRuntime.meshes[meshId]; + if (!mesh) { + continue; + } + for (var i = 0; i < mesh.primitives.length; i++) { + if (mesh.primitives[i].mode !== 4) { + //continue; + } + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.SubMesh.AddToMesh(index, verticesStarts[index], verticesCounts[index], indexStarts[index], indexCounts[index], newMesh, newMesh, true); + index++; + } + } + // Finish + return newMesh; +}; +/** + * Configure node transformation from position, rotation and scaling + * @param newNode + * @param position + * @param rotation + * @param scaling + */ +var configureNode = function (newNode, position, rotation, scaling) { + if (newNode.position) { + newNode.position = position; + } + if (newNode.rotationQuaternion || newNode.rotation) { + newNode.rotationQuaternion = rotation; + } + if (newNode.scaling) { + newNode.scaling = scaling; + } +}; +/** + * Configures node from transformation matrix + * @param newNode + * @param node + */ +var configureNodeFromMatrix = function (newNode, node) { + if (node.matrix) { + var position = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 0); + var rotation = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion(); + var scaling = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 0, 0); + var mat = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.FromArray(node.matrix); + mat.decompose(scaling, rotation, position); + configureNode(newNode, position, rotation, scaling); + } + else if (node.translation && node.rotation && node.scale) { + configureNode(newNode, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(node.translation), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromArray(node.rotation), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(node.scale)); + } + newNode.computeWorldMatrix(true); +}; +/** + * Imports a node + * @param gltfRuntime + * @param node + * @param id + */ +var importNode = function (gltfRuntime, node, id) { + var lastNode = null; + if (gltfRuntime.importOnlyMeshes && (node.skin || node.meshes)) { + if (gltfRuntime.importMeshesNames && gltfRuntime.importMeshesNames.length > 0 && gltfRuntime.importMeshesNames.indexOf(node.name || "") === -1) { + return null; + } + } + // Meshes + if (node.skin) { + if (node.meshes) { + var skin = gltfRuntime.skins[node.skin]; + var newMesh = importMesh(gltfRuntime, node, node.meshes, id, node.babylonNode); + newMesh.skeleton = gltfRuntime.scene.getLastSkeletonById(node.skin); + if (newMesh.skeleton === null) { + newMesh.skeleton = importSkeleton(gltfRuntime, skin, newMesh, skin.babylonSkeleton); + if (!skin.babylonSkeleton) { + skin.babylonSkeleton = newMesh.skeleton; + } + } + lastNode = newMesh; + } + } + else if (node.meshes) { + /** + * Improve meshes property + */ + var newMesh = importMesh(gltfRuntime, node, node.mesh ? [node.mesh] : node.meshes, id, node.babylonNode); + lastNode = newMesh; + } + // Lights + else if (node.light && !node.babylonNode && !gltfRuntime.importOnlyMeshes) { + var light = gltfRuntime.lights[node.light]; + if (light) { + if (light.type === "ambient") { + var ambienLight = light[light.type]; + var hemiLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.HemisphericLight(node.light, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene); + hemiLight.name = node.name || ""; + if (ambienLight.color) { + hemiLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(ambienLight.color); + } + lastNode = hemiLight; + } + else if (light.type === "directional") { + var directionalLight = light[light.type]; + var dirLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.DirectionalLight(node.light, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene); + dirLight.name = node.name || ""; + if (directionalLight.color) { + dirLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(directionalLight.color); + } + lastNode = dirLight; + } + else if (light.type === "point") { + var pointLight = light[light.type]; + var ptLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.PointLight(node.light, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene); + ptLight.name = node.name || ""; + if (pointLight.color) { + ptLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(pointLight.color); + } + lastNode = ptLight; + } + else if (light.type === "spot") { + var spotLight = light[light.type]; + var spLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.SpotLight(node.light, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), 0, 0, gltfRuntime.scene); + spLight.name = node.name || ""; + if (spotLight.color) { + spLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(spotLight.color); + } + if (spotLight.fallOfAngle) { + spLight.angle = spotLight.fallOfAngle; + } + if (spotLight.fallOffExponent) { + spLight.exponent = spotLight.fallOffExponent; + } + lastNode = spLight; + } + } + } + // Cameras + else if (node.camera && !node.babylonNode && !gltfRuntime.importOnlyMeshes) { + var camera = gltfRuntime.cameras[node.camera]; + if (camera) { + gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer; + if (camera.type === "orthographic") { + var orthoCamera = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.FreeCamera(node.camera, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene, false); + orthoCamera.name = node.name || ""; + orthoCamera.mode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Camera.ORTHOGRAPHIC_CAMERA; + orthoCamera.attachControl(); + lastNode = orthoCamera; + orthoCamera._parentContainer = gltfRuntime.assetContainer; + } + else if (camera.type === "perspective") { + var perspectiveCamera = camera[camera.type]; + var persCamera = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.FreeCamera(node.camera, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.Zero(), gltfRuntime.scene, false); + persCamera.name = node.name || ""; + persCamera.attachControl(); + if (!perspectiveCamera.aspectRatio) { + perspectiveCamera.aspectRatio = gltfRuntime.scene.getEngine().getRenderWidth() / gltfRuntime.scene.getEngine().getRenderHeight(); + } + if (perspectiveCamera.znear && perspectiveCamera.zfar) { + persCamera.maxZ = perspectiveCamera.zfar; + persCamera.minZ = perspectiveCamera.znear; + } + lastNode = persCamera; + persCamera._parentContainer = gltfRuntime.assetContainer; + } + gltfRuntime.scene._blockEntityCollection = false; + } + } + // Empty node + if (!node.jointName) { + if (node.babylonNode) { + return node.babylonNode; + } + else if (lastNode === null) { + gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer; + var dummy = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Mesh(node.name || "", gltfRuntime.scene); + dummy._parentContainer = gltfRuntime.assetContainer; + gltfRuntime.scene._blockEntityCollection = false; + node.babylonNode = dummy; + lastNode = dummy; + } + } + if (lastNode !== null) { + if (node.matrix && lastNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Mesh) { + configureNodeFromMatrix(lastNode, node); + } + else { + var translation = node.translation || [0, 0, 0]; + var rotation = node.rotation || [0, 0, 0, 1]; + var scale = node.scale || [1, 1, 1]; + configureNode(lastNode, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(translation), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Quaternion.FromArray(rotation), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(scale)); + } + lastNode.updateCache(true); + node.babylonNode = lastNode; + } + return lastNode; +}; +/** + * Traverses nodes and creates them + * @param gltfRuntime + * @param id + * @param parent + * @param meshIncluded + */ +var traverseNodes = function (gltfRuntime, id, parent, meshIncluded) { + if (meshIncluded === void 0) { meshIncluded = false; } + var node = gltfRuntime.nodes[id]; + var newNode = null; + if (gltfRuntime.importOnlyMeshes && !meshIncluded && gltfRuntime.importMeshesNames) { + if (gltfRuntime.importMeshesNames.indexOf(node.name || "") !== -1 || gltfRuntime.importMeshesNames.length === 0) { + meshIncluded = true; + } + else { + meshIncluded = false; + } + } + else { + meshIncluded = true; + } + if (!node.jointName && meshIncluded) { + newNode = importNode(gltfRuntime, node, id); + if (newNode !== null) { + newNode.id = id; + newNode.parent = parent; + } + } + if (node.children) { + for (var i = 0; i < node.children.length; i++) { + traverseNodes(gltfRuntime, node.children[i], newNode, meshIncluded); + } + } +}; +/** + * do stuff after buffers, shaders are loaded (e.g. hook up materials, load animations, etc.) + * @param gltfRuntime + */ +var postLoad = function (gltfRuntime) { + // Nodes + var currentScene = gltfRuntime.currentScene; + if (currentScene) { + for (var i = 0; i < currentScene.nodes.length; i++) { + traverseNodes(gltfRuntime, currentScene.nodes[i], null); + } + } + else { + for (var thing in gltfRuntime.scenes) { + currentScene = gltfRuntime.scenes[thing]; + for (var i = 0; i < currentScene.nodes.length; i++) { + traverseNodes(gltfRuntime, currentScene.nodes[i], null); + } + } + } + // Set animations + loadAnimations(gltfRuntime); + for (var i = 0; i < gltfRuntime.scene.skeletons.length; i++) { + var skeleton = gltfRuntime.scene.skeletons[i]; + gltfRuntime.scene.beginAnimation(skeleton, 0, Number.MAX_VALUE, true, 1.0); + } +}; +/** + * onBind shaderrs callback to set uniforms and matrices + * @param mesh + * @param gltfRuntime + * @param unTreatedUniforms + * @param shaderMaterial + * @param technique + * @param material + * @param onSuccess + */ +var onBindShaderMaterial = function (mesh, gltfRuntime, unTreatedUniforms, shaderMaterial, technique, material, onSuccess) { + var materialValues = material.values || technique.parameters; + for (var unif in unTreatedUniforms) { + var uniform = unTreatedUniforms[unif]; + var type = uniform.type; + if (type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT2 || type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT3 || type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT4) { + if (uniform.semantic && !uniform.source && !uniform.node) { + _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.SetMatrix(gltfRuntime.scene, mesh, uniform, unif, shaderMaterial.getEffect()); + } + else if (uniform.semantic && (uniform.source || uniform.node)) { + var source = gltfRuntime.scene.getNodeByName(uniform.source || uniform.node || ""); + if (source === null) { + source = gltfRuntime.scene.getNodeById(uniform.source || uniform.node || ""); + } + if (source === null) { + continue; + } + _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.SetMatrix(gltfRuntime.scene, source, uniform, unif, shaderMaterial.getEffect()); + } + } + else { + var value = materialValues[technique.uniforms[unif]]; + if (!value) { + continue; + } + if (type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.SAMPLER_2D) { + var texture = gltfRuntime.textures[material.values ? value : uniform.value].babylonTexture; + if (texture === null || texture === undefined) { + continue; + } + shaderMaterial.getEffect().setTexture(unif, texture); + } + else { + _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.SetUniform(shaderMaterial.getEffect(), unif, value, type); + } + } + } + onSuccess(shaderMaterial); +}; +/** + * Prepare uniforms to send the only one time + * Loads the appropriate textures + * @param gltfRuntime + * @param shaderMaterial + * @param technique + * @param material + */ +var prepareShaderMaterialUniforms = function (gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms) { + var materialValues = material.values || technique.parameters; + var techniqueUniforms = technique.uniforms; + var _loop_1 = function (unif) { + var uniform = unTreatedUniforms[unif]; + var type = uniform.type; + var value = materialValues[techniqueUniforms[unif]]; + if (value === undefined) { + // In case the value is the same for all materials + value = uniform.value; + } + if (!value) { + return "continue"; + } + var onLoadTexture = function (uniformName) { + return function (texture) { + if (uniform.value && uniformName) { + // Static uniform + shaderMaterial.setTexture(uniformName, texture); + delete unTreatedUniforms[uniformName]; + } + }; + }; + // Texture (sampler2D) + if (type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.SAMPLER_2D) { + GLTFLoaderExtension.LoadTextureAsync(gltfRuntime, material.values ? value : uniform.value, onLoadTexture(unif), function () { return onLoadTexture(null); }); + } + // Others + else { + if (uniform.value && _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.SetUniform(shaderMaterial, unif, material.values ? value : uniform.value, type)) { + // Static uniform + delete unTreatedUniforms[unif]; + } + } + }; + /** + * Prepare values here (not matrices) + */ + for (var unif in unTreatedUniforms) { + _loop_1(unif); + } +}; +/** + * Shader compilation failed + * @param program + * @param shaderMaterial + * @param onError + */ +var onShaderCompileError = function (program, shaderMaterial, onError) { + return function (effect, error) { + shaderMaterial.dispose(true); + onError("Cannot compile program named " + program.name + ". Error: " + error + ". Default material will be applied"); + }; +}; +/** + * Shader compilation success + * @param gltfRuntime + * @param shaderMaterial + * @param technique + * @param material + * @param unTreatedUniforms + * @param onSuccess + */ +var onShaderCompileSuccess = function (gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms, onSuccess) { + return function (_) { + prepareShaderMaterialUniforms(gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms); + shaderMaterial.onBind = function (mesh) { + onBindShaderMaterial(mesh, gltfRuntime, unTreatedUniforms, shaderMaterial, technique, material, onSuccess); + }; + }; +}; +/** + * Returns the appropriate uniform if already handled by babylon + * @param tokenizer + * @param technique + */ +var parseShaderUniforms = function (tokenizer, technique, unTreatedUniforms) { + for (var unif in technique.uniforms) { + var uniform = technique.uniforms[unif]; + var uniformParameter = technique.parameters[uniform]; + if (tokenizer.currentIdentifier === unif) { + if (uniformParameter.semantic && !uniformParameter.source && !uniformParameter.node) { + var transformIndex = glTFTransforms.indexOf(uniformParameter.semantic); + if (transformIndex !== -1) { + delete unTreatedUniforms[unif]; + return babylonTransforms[transformIndex]; + } + } + } + } + return tokenizer.currentIdentifier; +}; +/** + * All shaders loaded. Create materials one by one + * @param gltfRuntime + */ +var importMaterials = function (gltfRuntime) { + // Create materials + for (var mat in gltfRuntime.materials) { + GLTFLoaderExtension.LoadMaterialAsync(gltfRuntime, mat, function () { }, function () { }); + } +}; +/** + * Implementation of the base glTF spec + * @internal + */ +var GLTFLoaderBase = /** @class */ (function () { + function GLTFLoaderBase() { + } + GLTFLoaderBase.CreateRuntime = function (parsedData, scene, rootUrl) { + var gltfRuntime = { + extensions: {}, + accessors: {}, + buffers: {}, + bufferViews: {}, + meshes: {}, + lights: {}, + cameras: {}, + nodes: {}, + images: {}, + textures: {}, + shaders: {}, + programs: {}, + samplers: {}, + techniques: {}, + materials: {}, + animations: {}, + skins: {}, + extensionsUsed: [], + scenes: {}, + buffersCount: 0, + shaderscount: 0, + scene: scene, + rootUrl: rootUrl, + loadedBufferCount: 0, + loadedBufferViews: {}, + loadedShaderCount: 0, + importOnlyMeshes: false, + dummyNodes: [], + assetContainer: null, + }; + // Parse + if (parsedData.extensions) { + parseObject(parsedData.extensions, "extensions", gltfRuntime); + } + if (parsedData.extensionsUsed) { + parseObject(parsedData.extensionsUsed, "extensionsUsed", gltfRuntime); + } + if (parsedData.buffers) { + parseBuffers(parsedData.buffers, gltfRuntime); + } + if (parsedData.bufferViews) { + parseObject(parsedData.bufferViews, "bufferViews", gltfRuntime); + } + if (parsedData.accessors) { + parseObject(parsedData.accessors, "accessors", gltfRuntime); + } + if (parsedData.meshes) { + parseObject(parsedData.meshes, "meshes", gltfRuntime); + } + if (parsedData.lights) { + parseObject(parsedData.lights, "lights", gltfRuntime); + } + if (parsedData.cameras) { + parseObject(parsedData.cameras, "cameras", gltfRuntime); + } + if (parsedData.nodes) { + parseObject(parsedData.nodes, "nodes", gltfRuntime); + } + if (parsedData.images) { + parseObject(parsedData.images, "images", gltfRuntime); + } + if (parsedData.textures) { + parseObject(parsedData.textures, "textures", gltfRuntime); + } + if (parsedData.shaders) { + parseShaders(parsedData.shaders, gltfRuntime); + } + if (parsedData.programs) { + parseObject(parsedData.programs, "programs", gltfRuntime); + } + if (parsedData.samplers) { + parseObject(parsedData.samplers, "samplers", gltfRuntime); + } + if (parsedData.techniques) { + parseObject(parsedData.techniques, "techniques", gltfRuntime); + } + if (parsedData.materials) { + parseObject(parsedData.materials, "materials", gltfRuntime); + } + if (parsedData.animations) { + parseObject(parsedData.animations, "animations", gltfRuntime); + } + if (parsedData.skins) { + parseObject(parsedData.skins, "skins", gltfRuntime); + } + if (parsedData.scenes) { + gltfRuntime.scenes = parsedData.scenes; + } + if (parsedData.scene && parsedData.scenes) { + gltfRuntime.currentScene = parsedData.scenes[parsedData.scene]; + } + return gltfRuntime; + }; + GLTFLoaderBase.LoadBufferAsync = function (gltfRuntime, id, onSuccess, onError, onProgress) { + var buffer = gltfRuntime.buffers[id]; + if (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.IsBase64(buffer.uri)) { + setTimeout(function () { return onSuccess(new Uint8Array(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.DecodeBase64(buffer.uri))); }); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.LoadFile(gltfRuntime.rootUrl + buffer.uri, function (data) { return onSuccess(new Uint8Array(data)); }, onProgress, undefined, true, function (request) { + if (request) { + onError(request.status + " " + request.statusText); + } + }); + } + }; + GLTFLoaderBase.LoadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) { + var texture = gltfRuntime.textures[id]; + if (!texture || !texture.source) { + onError(""); + return; + } + if (texture.babylonTexture) { + onSuccess(null); + return; + } + var source = gltfRuntime.images[texture.source]; + if (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.IsBase64(source.uri)) { + setTimeout(function () { return onSuccess(new Uint8Array(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.DecodeBase64(source.uri))); }); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.LoadFile(gltfRuntime.rootUrl + source.uri, function (data) { return onSuccess(new Uint8Array(data)); }, undefined, undefined, true, function (request) { + if (request) { + onError(request.status + " " + request.statusText); + } + }); + } + }; + GLTFLoaderBase.CreateTextureAsync = function (gltfRuntime, id, buffer, onSuccess) { + var texture = gltfRuntime.textures[id]; + if (texture.babylonTexture) { + onSuccess(texture.babylonTexture); + return; + } + var sampler = gltfRuntime.samplers[texture.sampler]; + var createMipMaps = sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.NEAREST_MIPMAP_NEAREST || + sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.NEAREST_MIPMAP_LINEAR || + sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR_MIPMAP_NEAREST || + sampler.minFilter === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR_MIPMAP_LINEAR; + var samplingMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.BILINEAR_SAMPLINGMODE; + var blob = buffer == null ? new Blob() : new Blob([buffer]); + var blobURL = URL.createObjectURL(blob); + var revokeBlobURL = function () { return URL.revokeObjectURL(blobURL); }; + var newTexture = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture(blobURL, gltfRuntime.scene, !createMipMaps, true, samplingMode, revokeBlobURL, revokeBlobURL); + if (sampler.wrapS !== undefined) { + newTexture.wrapU = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetWrapMode(sampler.wrapS); + } + if (sampler.wrapT !== undefined) { + newTexture.wrapV = _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_2__.GLTFUtils.GetWrapMode(sampler.wrapT); + } + newTexture.name = id; + texture.babylonTexture = newTexture; + onSuccess(newTexture); + }; + GLTFLoaderBase.LoadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) { + var shader = gltfRuntime.shaders[id]; + if (babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.IsBase64(shader.uri)) { + var shaderString = atob(shader.uri.split(",")[1]); + if (onSuccess) { + onSuccess(shaderString); + } + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.LoadFile(gltfRuntime.rootUrl + shader.uri, onSuccess, undefined, undefined, false, function (request) { + if (request && onError) { + onError(request.status + " " + request.statusText); + } + }); + } + }; + GLTFLoaderBase.LoadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) { + var material = gltfRuntime.materials[id]; + if (!material.technique) { + if (onError) { + onError("No technique found."); + } + return; + } + var technique = gltfRuntime.techniques[material.technique]; + if (!technique) { + gltfRuntime.scene._blockEntityCollection = !!gltfRuntime.assetContainer; + var defaultMaterial = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.StandardMaterial(id, gltfRuntime.scene); + defaultMaterial._parentContainer = gltfRuntime.assetContainer; + gltfRuntime.scene._blockEntityCollection = false; + defaultMaterial.diffuseColor = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3(0.5, 0.5, 0.5); + defaultMaterial.sideOrientation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Material.CounterClockWiseSideOrientation; + onSuccess(defaultMaterial); + return; + } + var program = gltfRuntime.programs[technique.program]; + var states = technique.states; + var vertexShader = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[program.vertexShader + "VertexShader"]; + var pixelShader = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[program.fragmentShader + "PixelShader"]; + var newVertexShader = ""; + var newPixelShader = ""; + var vertexTokenizer = new Tokenizer(vertexShader); + var pixelTokenizer = new Tokenizer(pixelShader); + var unTreatedUniforms = {}; + var uniforms = []; + var attributes = []; + var samplers = []; + // Fill uniform, sampler2D and attributes + for (var unif in technique.uniforms) { + var uniform = technique.uniforms[unif]; + var uniformParameter = technique.parameters[uniform]; + unTreatedUniforms[unif] = uniformParameter; + if (uniformParameter.semantic && !uniformParameter.node && !uniformParameter.source) { + var transformIndex = glTFTransforms.indexOf(uniformParameter.semantic); + if (transformIndex !== -1) { + uniforms.push(babylonTransforms[transformIndex]); + delete unTreatedUniforms[unif]; + } + else { + uniforms.push(unif); + } + } + else if (uniformParameter.type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.SAMPLER_2D) { + samplers.push(unif); + } + else { + uniforms.push(unif); + } + } + for (var attr in technique.attributes) { + var attribute = technique.attributes[attr]; + var attributeParameter = technique.parameters[attribute]; + if (attributeParameter.semantic) { + var name_1 = getAttribute(attributeParameter); + if (name_1) { + attributes.push(name_1); + } + } + } + // Configure vertex shader + while (!vertexTokenizer.isEnd() && vertexTokenizer.getNextToken()) { + var tokenType = vertexTokenizer.currentToken; + if (tokenType !== ETokenType.IDENTIFIER) { + newVertexShader += vertexTokenizer.currentString; + continue; + } + var foundAttribute = false; + for (var attr in technique.attributes) { + var attribute = technique.attributes[attr]; + var attributeParameter = technique.parameters[attribute]; + if (vertexTokenizer.currentIdentifier === attr && attributeParameter.semantic) { + newVertexShader += getAttribute(attributeParameter); + foundAttribute = true; + break; + } + } + if (foundAttribute) { + continue; + } + newVertexShader += parseShaderUniforms(vertexTokenizer, technique, unTreatedUniforms); + } + // Configure pixel shader + while (!pixelTokenizer.isEnd() && pixelTokenizer.getNextToken()) { + var tokenType = pixelTokenizer.currentToken; + if (tokenType !== ETokenType.IDENTIFIER) { + newPixelShader += pixelTokenizer.currentString; + continue; + } + newPixelShader += parseShaderUniforms(pixelTokenizer, technique, unTreatedUniforms); + } + // Create shader material + var shaderPath = { + vertex: program.vertexShader + id, + fragment: program.fragmentShader + id, + }; + var options = { + attributes: attributes, + uniforms: uniforms, + samplers: samplers, + needAlphaBlending: states && states.enable && states.enable.indexOf(3042) !== -1, + }; + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[program.vertexShader + id + "VertexShader"] = newVertexShader; + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[program.fragmentShader + id + "PixelShader"] = newPixelShader; + var shaderMaterial = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.ShaderMaterial(id, gltfRuntime.scene, shaderPath, options); + shaderMaterial.onError = onShaderCompileError(program, shaderMaterial, onError); + shaderMaterial.onCompiled = onShaderCompileSuccess(gltfRuntime, shaderMaterial, technique, material, unTreatedUniforms, onSuccess); + shaderMaterial.sideOrientation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Material.CounterClockWiseSideOrientation; + if (states && states.functions) { + var functions = states.functions; + if (functions.cullFace && functions.cullFace[0] !== _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ECullingType.BACK) { + shaderMaterial.backFaceCulling = false; + } + var blendFunc = functions.blendFuncSeparate; + if (blendFunc) { + if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.SRC_ALPHA && + blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE_MINUS_SRC_ALPHA && + blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE && + blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) { + shaderMaterial.alphaMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_COMBINE; + } + else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE && + blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE && + blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ZERO && + blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) { + shaderMaterial.alphaMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_ONEONE; + } + else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.SRC_ALPHA && + blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE && + blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ZERO && + blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) { + shaderMaterial.alphaMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_ADD; + } + else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ZERO && + blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE_MINUS_SRC_COLOR && + blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE && + blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) { + shaderMaterial.alphaMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_SUBTRACT; + } + else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.DST_COLOR && + blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ZERO && + blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE && + blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) { + shaderMaterial.alphaMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_MULTIPLY; + } + else if (blendFunc[0] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.SRC_ALPHA && + blendFunc[1] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE_MINUS_SRC_COLOR && + blendFunc[2] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE && + blendFunc[3] === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EBlendingFunction.ONE) { + shaderMaterial.alphaMode = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Constants.ALPHA_MAXIMIZED; + } + } + } + }; + return GLTFLoaderBase; +}()); + +/** + * glTF V1 Loader + * @internal + * @deprecated + */ +var GLTFLoader = /** @class */ (function () { + function GLTFLoader() { + } + GLTFLoader.RegisterExtension = function (extension) { + if (GLTFLoader.Extensions[extension.name]) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error('Tool with the same name "' + extension.name + '" already exists'); + return; + } + GLTFLoader.Extensions[extension.name] = extension; + }; + GLTFLoader.prototype.dispose = function () { + // do nothing + }; + GLTFLoader.prototype._importMeshAsync = function (meshesNames, scene, data, rootUrl, assetContainer, onSuccess, onProgress, onError) { + var _this = this; + scene.useRightHandedSystem = true; + GLTFLoaderExtension.LoadRuntimeAsync(scene, data, rootUrl, function (gltfRuntime) { + gltfRuntime.assetContainer = assetContainer; + gltfRuntime.importOnlyMeshes = true; + if (meshesNames === "") { + gltfRuntime.importMeshesNames = []; + } + else if (typeof meshesNames === "string") { + gltfRuntime.importMeshesNames = [meshesNames]; + } + else if (meshesNames && !(meshesNames instanceof Array)) { + gltfRuntime.importMeshesNames = [meshesNames]; + } + else { + gltfRuntime.importMeshesNames = []; + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn("Argument meshesNames must be of type string or string[]"); + } + // Create nodes + _this._createNodes(gltfRuntime); + var meshes = new Array(); + var skeletons = new Array(); + // Fill arrays of meshes and skeletons + for (var nde in gltfRuntime.nodes) { + var node = gltfRuntime.nodes[nde]; + if (node.babylonNode instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.AbstractMesh) { + meshes.push(node.babylonNode); + } + } + for (var skl in gltfRuntime.skins) { + var skin = gltfRuntime.skins[skl]; + if (skin.babylonSkeleton instanceof babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Skeleton) { + skeletons.push(skin.babylonSkeleton); + } + } + // Load buffers, shaders, materials, etc. + _this._loadBuffersAsync(gltfRuntime, function () { + _this._loadShadersAsync(gltfRuntime, function () { + importMaterials(gltfRuntime); + postLoad(gltfRuntime); + if (!_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.IncrementalLoading && onSuccess) { + onSuccess(meshes, skeletons); + } + }); + }); + if (_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.IncrementalLoading && onSuccess) { + onSuccess(meshes, skeletons); + } + }, onError); + return true; + }; + /** + * Imports one or more meshes from a loaded gltf file and adds them to the scene + * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file + * @param scene the scene the meshes should be added to + * @param assetContainer defines the asset container to use (can be null) + * @param data gltf data containing information of the meshes in a loaded file + * @param rootUrl root url to load from + * @param onProgress event that fires when loading progress has occured + * @returns a promise containg the loaded meshes, particles, skeletons and animations + */ + GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, assetContainer, data, rootUrl, onProgress) { + var _this = this; + return new Promise(function (resolve, reject) { + _this._importMeshAsync(meshesNames, scene, data, rootUrl, assetContainer, function (meshes, skeletons) { + resolve({ + meshes: meshes, + particleSystems: [], + skeletons: skeletons, + animationGroups: [], + lights: [], + transformNodes: [], + geometries: [], + }); + }, onProgress, function (message) { + reject(new Error(message)); + }); + }); + }; + GLTFLoader.prototype._loadAsync = function (scene, data, rootUrl, onSuccess, onProgress, onError) { + var _this = this; + scene.useRightHandedSystem = true; + GLTFLoaderExtension.LoadRuntimeAsync(scene, data, rootUrl, function (gltfRuntime) { + // Load runtime extensios + GLTFLoaderExtension.LoadRuntimeExtensionsAsync(gltfRuntime, function () { + // Create nodes + _this._createNodes(gltfRuntime); + // Load buffers, shaders, materials, etc. + _this._loadBuffersAsync(gltfRuntime, function () { + _this._loadShadersAsync(gltfRuntime, function () { + importMaterials(gltfRuntime); + postLoad(gltfRuntime); + if (!_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.IncrementalLoading) { + onSuccess(); + } + }); + }); + if (_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader.IncrementalLoading) { + onSuccess(); + } + }, onError); + }, onError); + }; + /** + * Imports all objects from a loaded gltf file and adds them to the scene + * @param scene the scene the objects should be added to + * @param data gltf data containing information of the meshes in a loaded file + * @param rootUrl root url to load from + * @param onProgress event that fires when loading progress has occured + * @returns a promise which completes when objects have been loaded to the scene + */ + GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress) { + var _this = this; + return new Promise(function (resolve, reject) { + _this._loadAsync(scene, data, rootUrl, function () { + resolve(); + }, onProgress, function (message) { + reject(new Error(message)); + }); + }); + }; + GLTFLoader.prototype._loadShadersAsync = function (gltfRuntime, onload) { + var hasShaders = false; + var processShader = function (sha, shader) { + GLTFLoaderExtension.LoadShaderStringAsync(gltfRuntime, sha, function (shaderString) { + if (shaderString instanceof ArrayBuffer) { + return; + } + gltfRuntime.loadedShaderCount++; + if (shaderString) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore[sha + (shader.type === _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EShaderType.VERTEX ? "VertexShader" : "PixelShader")] = shaderString; + } + if (gltfRuntime.loadedShaderCount === gltfRuntime.shaderscount) { + onload(); + } + }, function () { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("Error when loading shader program named " + sha + " located at " + shader.uri); + }); + }; + for (var sha in gltfRuntime.shaders) { + hasShaders = true; + var shader = gltfRuntime.shaders[sha]; + if (shader) { + processShader.bind(this, sha, shader)(); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("No shader named: " + sha); + } + } + if (!hasShaders) { + onload(); + } + }; + GLTFLoader.prototype._loadBuffersAsync = function (gltfRuntime, onLoad) { + var hasBuffers = false; + var processBuffer = function (buf, buffer) { + GLTFLoaderExtension.LoadBufferAsync(gltfRuntime, buf, function (bufferView) { + gltfRuntime.loadedBufferCount++; + if (bufferView) { + if (bufferView.byteLength != gltfRuntime.buffers[buf].byteLength) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("Buffer named " + buf + " is length " + bufferView.byteLength + ". Expected: " + buffer.byteLength); // Improve error message + } + gltfRuntime.loadedBufferViews[buf] = bufferView; + } + if (gltfRuntime.loadedBufferCount === gltfRuntime.buffersCount) { + onLoad(); + } + }, function () { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("Error when loading buffer named " + buf + " located at " + buffer.uri); + }); + }; + for (var buf in gltfRuntime.buffers) { + hasBuffers = true; + var buffer = gltfRuntime.buffers[buf]; + if (buffer) { + processBuffer.bind(this, buf, buffer)(); + } + else { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Error("No buffer named: " + buf); + } + } + if (!hasBuffers) { + onLoad(); + } + }; + GLTFLoader.prototype._createNodes = function (gltfRuntime) { + var currentScene = gltfRuntime.currentScene; + if (currentScene) { + // Only one scene even if multiple scenes are defined + for (var i = 0; i < currentScene.nodes.length; i++) { + traverseNodes(gltfRuntime, currentScene.nodes[i], null); + } + } + else { + // Load all scenes + for (var thing in gltfRuntime.scenes) { + currentScene = gltfRuntime.scenes[thing]; + for (var i = 0; i < currentScene.nodes.length; i++) { + traverseNodes(gltfRuntime, currentScene.nodes[i], null); + } + } + } + }; + GLTFLoader.Extensions = {}; + return GLTFLoader; +}()); +/** @internal */ +var GLTFLoaderExtension = /** @class */ (function () { + function GLTFLoaderExtension(name) { + this._name = name; + } + Object.defineProperty(GLTFLoaderExtension.prototype, "name", { + get: function () { + return this._name; + }, + enumerable: false, + configurable: true + }); + /** + * Defines an override for loading the runtime + * Return true to stop further extensions from loading the runtime + * @param scene + * @param data + * @param rootUrl + * @param onSuccess + * @param onError + */ + GLTFLoaderExtension.prototype.loadRuntimeAsync = function (scene, data, rootUrl, onSuccess, onError) { + return false; + }; + /** + * Defines an onverride for creating gltf runtime + * Return true to stop further extensions from creating the runtime + * @param gltfRuntime + * @param onSuccess + * @param onError + */ + GLTFLoaderExtension.prototype.loadRuntimeExtensionsAsync = function (gltfRuntime, onSuccess, onError) { + return false; + }; + /** + * Defines an override for loading buffers + * Return true to stop further extensions from loading this buffer + * @param gltfRuntime + * @param id + * @param onSuccess + * @param onError + * @param onProgress + */ + GLTFLoaderExtension.prototype.loadBufferAsync = function (gltfRuntime, id, onSuccess, onError, onProgress) { + return false; + }; + /** + * Defines an override for loading texture buffers + * Return true to stop further extensions from loading this texture data + * @param gltfRuntime + * @param id + * @param onSuccess + * @param onError + */ + GLTFLoaderExtension.prototype.loadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) { + return false; + }; + /** + * Defines an override for creating textures + * Return true to stop further extensions from loading this texture + * @param gltfRuntime + * @param id + * @param buffer + * @param onSuccess + * @param onError + */ + GLTFLoaderExtension.prototype.createTextureAsync = function (gltfRuntime, id, buffer, onSuccess, onError) { + return false; + }; + /** + * Defines an override for loading shader strings + * Return true to stop further extensions from loading this shader data + * @param gltfRuntime + * @param id + * @param onSuccess + * @param onError + */ + GLTFLoaderExtension.prototype.loadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) { + return false; + }; + /** + * Defines an override for loading materials + * Return true to stop further extensions from loading this material + * @param gltfRuntime + * @param id + * @param onSuccess + * @param onError + */ + GLTFLoaderExtension.prototype.loadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) { + return false; + }; + // --------- + // Utilities + // --------- + GLTFLoaderExtension.LoadRuntimeAsync = function (scene, data, rootUrl, onSuccess, onError) { + GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) { + return loaderExtension.loadRuntimeAsync(scene, data, rootUrl, onSuccess, onError); + }, function () { + setTimeout(function () { + if (!onSuccess) { + return; + } + onSuccess(GLTFLoaderBase.CreateRuntime(data.json, scene, rootUrl)); + }); + }); + }; + GLTFLoaderExtension.LoadRuntimeExtensionsAsync = function (gltfRuntime, onSuccess, onError) { + GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) { + return loaderExtension.loadRuntimeExtensionsAsync(gltfRuntime, onSuccess, onError); + }, function () { + setTimeout(function () { + onSuccess(); + }); + }); + }; + GLTFLoaderExtension.LoadBufferAsync = function (gltfRuntime, id, onSuccess, onError, onProgress) { + GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) { + return loaderExtension.loadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress); + }, function () { + GLTFLoaderBase.LoadBufferAsync(gltfRuntime, id, onSuccess, onError, onProgress); + }); + }; + GLTFLoaderExtension.LoadTextureAsync = function (gltfRuntime, id, onSuccess, onError) { + GLTFLoaderExtension._LoadTextureBufferAsync(gltfRuntime, id, function (buffer) { + if (buffer) { + GLTFLoaderExtension._CreateTextureAsync(gltfRuntime, id, buffer, onSuccess, onError); + } + }, onError); + }; + GLTFLoaderExtension.LoadShaderStringAsync = function (gltfRuntime, id, onSuccess, onError) { + GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) { + return loaderExtension.loadShaderStringAsync(gltfRuntime, id, onSuccess, onError); + }, function () { + GLTFLoaderBase.LoadShaderStringAsync(gltfRuntime, id, onSuccess, onError); + }); + }; + GLTFLoaderExtension.LoadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) { + GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) { + return loaderExtension.loadMaterialAsync(gltfRuntime, id, onSuccess, onError); + }, function () { + GLTFLoaderBase.LoadMaterialAsync(gltfRuntime, id, onSuccess, onError); + }); + }; + GLTFLoaderExtension._LoadTextureBufferAsync = function (gltfRuntime, id, onSuccess, onError) { + GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) { + return loaderExtension.loadTextureBufferAsync(gltfRuntime, id, onSuccess, onError); + }, function () { + GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, onSuccess, onError); + }); + }; + GLTFLoaderExtension._CreateTextureAsync = function (gltfRuntime, id, buffer, onSuccess, onError) { + GLTFLoaderExtension._ApplyExtensions(function (loaderExtension) { + return loaderExtension.createTextureAsync(gltfRuntime, id, buffer, onSuccess, onError); + }, function () { + GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, onSuccess); + }); + }; + GLTFLoaderExtension._ApplyExtensions = function (func, defaultFunc) { + for (var extensionName in GLTFLoader.Extensions) { + var loaderExtension = GLTFLoader.Extensions[extensionName]; + if (func(loaderExtension)) { + return; + } + } + defaultFunc(); + }; + return GLTFLoaderExtension; +}()); + +_glTFFileLoader__WEBPACK_IMPORTED_MODULE_3__.GLTFFileLoader._CreateGLTF1Loader = function () { return new GLTFLoader(); }; + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/1.0/glTFLoaderInterfaces.ts": +/*!*****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/1.0/glTFLoaderInterfaces.ts ***! + \*****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EBlendingFunction: () => (/* binding */ EBlendingFunction), +/* harmony export */ EComponentType: () => (/* binding */ EComponentType), +/* harmony export */ ECullingType: () => (/* binding */ ECullingType), +/* harmony export */ EParameterType: () => (/* binding */ EParameterType), +/* harmony export */ EShaderType: () => (/* binding */ EShaderType), +/* harmony export */ ETextureFilterType: () => (/* binding */ ETextureFilterType), +/* harmony export */ ETextureFormat: () => (/* binding */ ETextureFormat), +/* harmony export */ ETextureWrapMode: () => (/* binding */ ETextureWrapMode) +/* harmony export */ }); +/** + * Enums + * @internal + */ +var EComponentType; +(function (EComponentType) { + EComponentType[EComponentType["BYTE"] = 5120] = "BYTE"; + EComponentType[EComponentType["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE"; + EComponentType[EComponentType["SHORT"] = 5122] = "SHORT"; + EComponentType[EComponentType["UNSIGNED_SHORT"] = 5123] = "UNSIGNED_SHORT"; + EComponentType[EComponentType["FLOAT"] = 5126] = "FLOAT"; +})(EComponentType || (EComponentType = {})); +/** @internal */ +var EShaderType; +(function (EShaderType) { + EShaderType[EShaderType["FRAGMENT"] = 35632] = "FRAGMENT"; + EShaderType[EShaderType["VERTEX"] = 35633] = "VERTEX"; +})(EShaderType || (EShaderType = {})); +/** @internal */ +var EParameterType; +(function (EParameterType) { + EParameterType[EParameterType["BYTE"] = 5120] = "BYTE"; + EParameterType[EParameterType["UNSIGNED_BYTE"] = 5121] = "UNSIGNED_BYTE"; + EParameterType[EParameterType["SHORT"] = 5122] = "SHORT"; + EParameterType[EParameterType["UNSIGNED_SHORT"] = 5123] = "UNSIGNED_SHORT"; + EParameterType[EParameterType["INT"] = 5124] = "INT"; + EParameterType[EParameterType["UNSIGNED_INT"] = 5125] = "UNSIGNED_INT"; + EParameterType[EParameterType["FLOAT"] = 5126] = "FLOAT"; + EParameterType[EParameterType["FLOAT_VEC2"] = 35664] = "FLOAT_VEC2"; + EParameterType[EParameterType["FLOAT_VEC3"] = 35665] = "FLOAT_VEC3"; + EParameterType[EParameterType["FLOAT_VEC4"] = 35666] = "FLOAT_VEC4"; + EParameterType[EParameterType["INT_VEC2"] = 35667] = "INT_VEC2"; + EParameterType[EParameterType["INT_VEC3"] = 35668] = "INT_VEC3"; + EParameterType[EParameterType["INT_VEC4"] = 35669] = "INT_VEC4"; + EParameterType[EParameterType["BOOL"] = 35670] = "BOOL"; + EParameterType[EParameterType["BOOL_VEC2"] = 35671] = "BOOL_VEC2"; + EParameterType[EParameterType["BOOL_VEC3"] = 35672] = "BOOL_VEC3"; + EParameterType[EParameterType["BOOL_VEC4"] = 35673] = "BOOL_VEC4"; + EParameterType[EParameterType["FLOAT_MAT2"] = 35674] = "FLOAT_MAT2"; + EParameterType[EParameterType["FLOAT_MAT3"] = 35675] = "FLOAT_MAT3"; + EParameterType[EParameterType["FLOAT_MAT4"] = 35676] = "FLOAT_MAT4"; + EParameterType[EParameterType["SAMPLER_2D"] = 35678] = "SAMPLER_2D"; +})(EParameterType || (EParameterType = {})); +/** @internal */ +var ETextureWrapMode; +(function (ETextureWrapMode) { + ETextureWrapMode[ETextureWrapMode["CLAMP_TO_EDGE"] = 33071] = "CLAMP_TO_EDGE"; + ETextureWrapMode[ETextureWrapMode["MIRRORED_REPEAT"] = 33648] = "MIRRORED_REPEAT"; + ETextureWrapMode[ETextureWrapMode["REPEAT"] = 10497] = "REPEAT"; +})(ETextureWrapMode || (ETextureWrapMode = {})); +/** @internal */ +var ETextureFilterType; +(function (ETextureFilterType) { + ETextureFilterType[ETextureFilterType["NEAREST"] = 9728] = "NEAREST"; + ETextureFilterType[ETextureFilterType["LINEAR"] = 9728] = "LINEAR"; + ETextureFilterType[ETextureFilterType["NEAREST_MIPMAP_NEAREST"] = 9984] = "NEAREST_MIPMAP_NEAREST"; + ETextureFilterType[ETextureFilterType["LINEAR_MIPMAP_NEAREST"] = 9985] = "LINEAR_MIPMAP_NEAREST"; + ETextureFilterType[ETextureFilterType["NEAREST_MIPMAP_LINEAR"] = 9986] = "NEAREST_MIPMAP_LINEAR"; + ETextureFilterType[ETextureFilterType["LINEAR_MIPMAP_LINEAR"] = 9987] = "LINEAR_MIPMAP_LINEAR"; +})(ETextureFilterType || (ETextureFilterType = {})); +/** @internal */ +var ETextureFormat; +(function (ETextureFormat) { + ETextureFormat[ETextureFormat["ALPHA"] = 6406] = "ALPHA"; + ETextureFormat[ETextureFormat["RGB"] = 6407] = "RGB"; + ETextureFormat[ETextureFormat["RGBA"] = 6408] = "RGBA"; + ETextureFormat[ETextureFormat["LUMINANCE"] = 6409] = "LUMINANCE"; + ETextureFormat[ETextureFormat["LUMINANCE_ALPHA"] = 6410] = "LUMINANCE_ALPHA"; +})(ETextureFormat || (ETextureFormat = {})); +/** @internal */ +var ECullingType; +(function (ECullingType) { + ECullingType[ECullingType["FRONT"] = 1028] = "FRONT"; + ECullingType[ECullingType["BACK"] = 1029] = "BACK"; + ECullingType[ECullingType["FRONT_AND_BACK"] = 1032] = "FRONT_AND_BACK"; +})(ECullingType || (ECullingType = {})); +/** @internal */ +var EBlendingFunction; +(function (EBlendingFunction) { + EBlendingFunction[EBlendingFunction["ZERO"] = 0] = "ZERO"; + EBlendingFunction[EBlendingFunction["ONE"] = 1] = "ONE"; + EBlendingFunction[EBlendingFunction["SRC_COLOR"] = 768] = "SRC_COLOR"; + EBlendingFunction[EBlendingFunction["ONE_MINUS_SRC_COLOR"] = 769] = "ONE_MINUS_SRC_COLOR"; + EBlendingFunction[EBlendingFunction["DST_COLOR"] = 774] = "DST_COLOR"; + EBlendingFunction[EBlendingFunction["ONE_MINUS_DST_COLOR"] = 775] = "ONE_MINUS_DST_COLOR"; + EBlendingFunction[EBlendingFunction["SRC_ALPHA"] = 770] = "SRC_ALPHA"; + EBlendingFunction[EBlendingFunction["ONE_MINUS_SRC_ALPHA"] = 771] = "ONE_MINUS_SRC_ALPHA"; + EBlendingFunction[EBlendingFunction["DST_ALPHA"] = 772] = "DST_ALPHA"; + EBlendingFunction[EBlendingFunction["ONE_MINUS_DST_ALPHA"] = 773] = "ONE_MINUS_DST_ALPHA"; + EBlendingFunction[EBlendingFunction["CONSTANT_COLOR"] = 32769] = "CONSTANT_COLOR"; + EBlendingFunction[EBlendingFunction["ONE_MINUS_CONSTANT_COLOR"] = 32770] = "ONE_MINUS_CONSTANT_COLOR"; + EBlendingFunction[EBlendingFunction["CONSTANT_ALPHA"] = 32771] = "CONSTANT_ALPHA"; + EBlendingFunction[EBlendingFunction["ONE_MINUS_CONSTANT_ALPHA"] = 32772] = "ONE_MINUS_CONSTANT_ALPHA"; + EBlendingFunction[EBlendingFunction["SRC_ALPHA_SATURATE"] = 776] = "SRC_ALPHA_SATURATE"; +})(EBlendingFunction || (EBlendingFunction = {})); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/1.0/glTFLoaderUtils.ts": +/*!************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/1.0/glTFLoaderUtils.ts ***! + \************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFUtils: () => (/* binding */ GLTFUtils) +/* harmony export */ }); +/* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../dev/loaders/src/glTF/1.0/glTFLoaderInterfaces.ts"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Materials/Textures/texture */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__); + + + + + + +/** + * Utils functions for GLTF + * @internal + * @deprecated + */ +var GLTFUtils = /** @class */ (function () { + function GLTFUtils() { + } + /** + * Sets the given "parameter" matrix + * @param scene the Scene object + * @param source the source node where to pick the matrix + * @param parameter the GLTF technique parameter + * @param uniformName the name of the shader's uniform + * @param shaderMaterial the shader material + */ + GLTFUtils.SetMatrix = function (scene, source, parameter, uniformName, shaderMaterial) { + var mat = null; + if (parameter.semantic === "MODEL") { + mat = source.getWorldMatrix(); + } + else if (parameter.semantic === "PROJECTION") { + mat = scene.getProjectionMatrix(); + } + else if (parameter.semantic === "VIEW") { + mat = scene.getViewMatrix(); + } + else if (parameter.semantic === "MODELVIEWINVERSETRANSPOSE") { + mat = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.Transpose(source.getWorldMatrix().multiply(scene.getViewMatrix()).invert()); + } + else if (parameter.semantic === "MODELVIEW") { + mat = source.getWorldMatrix().multiply(scene.getViewMatrix()); + } + else if (parameter.semantic === "MODELVIEWPROJECTION") { + mat = source.getWorldMatrix().multiply(scene.getTransformMatrix()); + } + else if (parameter.semantic === "MODELINVERSE") { + mat = source.getWorldMatrix().invert(); + } + else if (parameter.semantic === "VIEWINVERSE") { + mat = scene.getViewMatrix().invert(); + } + else if (parameter.semantic === "PROJECTIONINVERSE") { + mat = scene.getProjectionMatrix().invert(); + } + else if (parameter.semantic === "MODELVIEWINVERSE") { + mat = source.getWorldMatrix().multiply(scene.getViewMatrix()).invert(); + } + else if (parameter.semantic === "MODELVIEWPROJECTIONINVERSE") { + mat = source.getWorldMatrix().multiply(scene.getTransformMatrix()).invert(); + } + else if (parameter.semantic === "MODELINVERSETRANSPOSE") { + mat = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.Transpose(source.getWorldMatrix().invert()); + } + if (mat) { + switch (parameter.type) { + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT2: + shaderMaterial.setMatrix2x2(uniformName, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.GetAsMatrix2x2(mat)); + break; + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT3: + shaderMaterial.setMatrix3x3(uniformName, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Matrix.GetAsMatrix3x3(mat)); + break; + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_MAT4: + shaderMaterial.setMatrix(uniformName, mat); + break; + default: + break; + } + } + }; + /** + * Sets the given "parameter" matrix + * @param shaderMaterial the shader material + * @param uniform the name of the shader's uniform + * @param value the value of the uniform + * @param type the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4) + */ + GLTFUtils.SetUniform = function (shaderMaterial, uniform, value, type) { + switch (type) { + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT: + shaderMaterial.setFloat(uniform, value); + return true; + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_VEC2: + shaderMaterial.setVector2(uniform, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector2.FromArray(value)); + return true; + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_VEC3: + shaderMaterial.setVector3(uniform, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3.FromArray(value)); + return true; + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EParameterType.FLOAT_VEC4: + shaderMaterial.setVector4(uniform, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector4.FromArray(value)); + return true; + default: + return false; + } + }; + /** + * Returns the wrap mode of the texture + * @param mode the mode value + */ + GLTFUtils.GetWrapMode = function (mode) { + switch (mode) { + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureWrapMode.CLAMP_TO_EDGE: + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.CLAMP_ADDRESSMODE; + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureWrapMode.MIRRORED_REPEAT: + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.MIRROR_ADDRESSMODE; + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureWrapMode.REPEAT: + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.WRAP_ADDRESSMODE; + default: + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.WRAP_ADDRESSMODE; + } + }; + /** + * Returns the byte stride giving an accessor + * @param accessor the GLTF accessor objet + */ + GLTFUtils.GetByteStrideFromType = function (accessor) { + // Needs this function since "byteStride" isn't requiered in glTF format + var type = accessor.type; + switch (type) { + case "VEC2": + return 2; + case "VEC3": + return 3; + case "VEC4": + return 4; + case "MAT2": + return 4; + case "MAT3": + return 9; + case "MAT4": + return 16; + default: + return 1; + } + }; + /** + * Returns the texture filter mode giving a mode value + * @param mode the filter mode value + * @returns the filter mode (TODO - needs to be a type?) + */ + GLTFUtils.GetTextureFilterMode = function (mode) { + switch (mode) { + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR: + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR_MIPMAP_NEAREST: + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.LINEAR_MIPMAP_LINEAR: + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.TRILINEAR_SAMPLINGMODE; + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.NEAREST: + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.ETextureFilterType.NEAREST_MIPMAP_NEAREST: + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.NEAREST_SAMPLINGMODE; + default: + return babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Texture.BILINEAR_SAMPLINGMODE; + } + }; + GLTFUtils.GetBufferFromBufferView = function (gltfRuntime, bufferView, byteOffset, byteLength, componentType) { + byteOffset = bufferView.byteOffset + byteOffset; + var loadedBufferView = gltfRuntime.loadedBufferViews[bufferView.buffer]; + if (byteOffset + byteLength > loadedBufferView.byteLength) { + throw new Error("Buffer access is out of range"); + } + var buffer = loadedBufferView.buffer; + byteOffset += loadedBufferView.byteOffset; + switch (componentType) { + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EComponentType.BYTE: + return new Int8Array(buffer, byteOffset, byteLength); + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EComponentType.UNSIGNED_BYTE: + return new Uint8Array(buffer, byteOffset, byteLength); + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EComponentType.SHORT: + return new Int16Array(buffer, byteOffset, byteLength); + case _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_0__.EComponentType.UNSIGNED_SHORT: + return new Uint16Array(buffer, byteOffset, byteLength); + default: + return new Float32Array(buffer, byteOffset, byteLength); + } + }; + /** + * Returns a buffer from its accessor + * @param gltfRuntime the GLTF runtime + * @param accessor the GLTF accessor + */ + GLTFUtils.GetBufferFromAccessor = function (gltfRuntime, accessor) { + var bufferView = gltfRuntime.bufferViews[accessor.bufferView]; + var byteLength = accessor.count * GLTFUtils.GetByteStrideFromType(accessor); + return GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, accessor.byteOffset, byteLength, accessor.componentType); + }; + /** + * Decodes a buffer view into a string + * @param view the buffer view + */ + GLTFUtils.DecodeBufferToText = function (view) { + var result = ""; + var length = view.byteLength; + for (var i = 0; i < length; ++i) { + result += String.fromCharCode(view[i]); + } + return result; + }; + /** + * Returns the default material of gltf. Related to + * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material + * @param scene the Babylon.js scene + */ + GLTFUtils.GetDefaultMaterial = function (scene) { + if (!GLTFUtils._DefaultMaterial) { + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore["GLTFDefaultMaterialVertexShader"] = [ + "precision highp float;", + "", + "uniform mat4 worldView;", + "uniform mat4 projection;", + "", + "attribute vec3 position;", + "", + "void main(void)", + "{", + " gl_Position = projection * worldView * vec4(position, 1.0);", + "}", + ].join("\n"); + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Effect.ShadersStore["GLTFDefaultMaterialPixelShader"] = [ + "precision highp float;", + "", + "uniform vec4 u_emission;", + "", + "void main(void)", + "{", + " gl_FragColor = u_emission;", + "}", + ].join("\n"); + var shaderPath = { + vertex: "GLTFDefaultMaterial", + fragment: "GLTFDefaultMaterial", + }; + var options = { + attributes: ["position"], + uniforms: ["worldView", "projection", "u_emission"], + samplers: new Array(), + needAlphaBlending: false, + }; + GLTFUtils._DefaultMaterial = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.ShaderMaterial("GLTFDefaultMaterial", scene, shaderPath, options); + GLTFUtils._DefaultMaterial.setColor4("u_emission", new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color4(0.5, 0.5, 0.5, 1.0)); + } + return GLTFUtils._DefaultMaterial; + }; + // The GLTF default material + GLTFUtils._DefaultMaterial = null; + return GLTFUtils; +}()); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/1.0/glTFMaterialsCommonExtension.ts": +/*!*************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/1.0/glTFMaterialsCommonExtension.ts ***! + \*************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFMaterialsCommonExtension: () => (/* binding */ GLTFMaterialsCommonExtension) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoader */ "../../../dev/loaders/src/glTF/1.0/glTFLoader.ts"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Lights/spotLight */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__); + + + + + + + + + + + +/** + * @internal + * @deprecated + */ +var GLTFMaterialsCommonExtension = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(GLTFMaterialsCommonExtension, _super); + function GLTFMaterialsCommonExtension() { + return _super.call(this, "KHR_materials_common") || this; + } + GLTFMaterialsCommonExtension.prototype.loadRuntimeExtensionsAsync = function (gltfRuntime) { + if (!gltfRuntime.extensions) { + return false; + } + var extension = gltfRuntime.extensions[this.name]; + if (!extension) { + return false; + } + // Create lights + var lights = extension.lights; + if (lights) { + for (var thing in lights) { + var light = lights[thing]; + switch (light.type) { + case "ambient": { + var ambientLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.HemisphericLight(light.name, new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 1, 0), gltfRuntime.scene); + var ambient = light.ambient; + if (ambient) { + ambientLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(ambient.color || [1, 1, 1]); + } + break; + } + case "point": { + var pointLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.PointLight(light.name, new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(10, 10, 10), gltfRuntime.scene); + var point = light.point; + if (point) { + pointLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(point.color || [1, 1, 1]); + } + break; + } + case "directional": { + var dirLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.DirectionalLight(light.name, new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, -1, 0), gltfRuntime.scene); + var directional = light.directional; + if (directional) { + dirLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(directional.color || [1, 1, 1]); + } + break; + } + case "spot": { + var spot = light.spot; + if (spot) { + var spotLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.SpotLight(light.name, new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, 10, 0), new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Vector3(0, -1, 0), spot.fallOffAngle || Math.PI, spot.fallOffExponent || 0.0, gltfRuntime.scene); + spotLight.diffuse = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(spot.color || [1, 1, 1]); + } + break; + } + default: + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Tools.Warn('GLTF Material Common extension: light type "' + light.type + "” not supported"); + break; + } + } + } + return false; + }; + GLTFMaterialsCommonExtension.prototype.loadMaterialAsync = function (gltfRuntime, id, onSuccess, onError) { + var material = gltfRuntime.materials[id]; + if (!material || !material.extensions) { + return false; + } + var extension = material.extensions[this.name]; + if (!extension) { + return false; + } + var standardMaterial = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.StandardMaterial(id, gltfRuntime.scene); + standardMaterial.sideOrientation = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Material.CounterClockWiseSideOrientation; + if (extension.technique === "CONSTANT") { + standardMaterial.disableLighting = true; + } + standardMaterial.backFaceCulling = extension.doubleSided === undefined ? false : !extension.doubleSided; + standardMaterial.alpha = extension.values.transparency === undefined ? 1.0 : extension.values.transparency; + standardMaterial.specularPower = extension.values.shininess === undefined ? 0.0 : extension.values.shininess; + // Ambient + if (typeof extension.values.ambient === "string") { + this._loadTexture(gltfRuntime, extension.values.ambient, standardMaterial, "ambientTexture", onError); + } + else { + standardMaterial.ambientColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(extension.values.ambient || [0, 0, 0]); + } + // Diffuse + if (typeof extension.values.diffuse === "string") { + this._loadTexture(gltfRuntime, extension.values.diffuse, standardMaterial, "diffuseTexture", onError); + } + else { + standardMaterial.diffuseColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(extension.values.diffuse || [0, 0, 0]); + } + // Emission + if (typeof extension.values.emission === "string") { + this._loadTexture(gltfRuntime, extension.values.emission, standardMaterial, "emissiveTexture", onError); + } + else { + standardMaterial.emissiveColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(extension.values.emission || [0, 0, 0]); + } + // Specular + if (typeof extension.values.specular === "string") { + this._loadTexture(gltfRuntime, extension.values.specular, standardMaterial, "specularTexture", onError); + } + else { + standardMaterial.specularColor = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_1__.Color3.FromArray(extension.values.specular || [0, 0, 0]); + } + return true; + }; + GLTFMaterialsCommonExtension.prototype._loadTexture = function (gltfRuntime, id, material, propertyPath, onError) { + // Create buffer from texture url + _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderBase.LoadTextureBufferAsync(gltfRuntime, id, function (buffer) { + // Create texture from buffer + _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderBase.CreateTextureAsync(gltfRuntime, id, buffer, function (texture) { return (material[propertyPath] = texture); }); + }, onError); + }; + return GLTFMaterialsCommonExtension; +}(_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderExtension)); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(new GLTFMaterialsCommonExtension()); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/1.0/index.ts": +/*!**************************************************!*\ + !*** ../../../dev/loaders/src/glTF/1.0/index.ts ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EBlendingFunction: () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EBlendingFunction), +/* harmony export */ EComponentType: () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EComponentType), +/* harmony export */ ECullingType: () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.ECullingType), +/* harmony export */ EParameterType: () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EParameterType), +/* harmony export */ EShaderType: () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.EShaderType), +/* harmony export */ ETextureFilterType: () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.ETextureFilterType), +/* harmony export */ ETextureFormat: () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.ETextureFormat), +/* harmony export */ ETextureWrapMode: () => (/* reexport safe */ _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__.ETextureWrapMode), +/* harmony export */ GLTFBinaryExtension: () => (/* reexport safe */ _glTFBinaryExtension__WEBPACK_IMPORTED_MODULE_0__.GLTFBinaryExtension), +/* harmony export */ GLTFLoader: () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader), +/* harmony export */ GLTFLoaderBase: () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderBase), +/* harmony export */ GLTFLoaderExtension: () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderExtension), +/* harmony export */ GLTFMaterialsCommonExtension: () => (/* reexport safe */ _glTFMaterialsCommonExtension__WEBPACK_IMPORTED_MODULE_4__.GLTFMaterialsCommonExtension), +/* harmony export */ GLTFUtils: () => (/* reexport safe */ _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_3__.GLTFUtils) +/* harmony export */ }); +/* harmony import */ var _glTFBinaryExtension__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFBinaryExtension */ "../../../dev/loaders/src/glTF/1.0/glTFBinaryExtension.ts"); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFLoader */ "../../../dev/loaders/src/glTF/1.0/glTFLoader.ts"); +/* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../dev/loaders/src/glTF/1.0/glTFLoaderInterfaces.ts"); +/* harmony import */ var _glTFLoaderUtils__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./glTFLoaderUtils */ "../../../dev/loaders/src/glTF/1.0/glTFLoaderUtils.ts"); +/* harmony import */ var _glTFMaterialsCommonExtension__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./glTFMaterialsCommonExtension */ "../../../dev/loaders/src/glTF/1.0/glTFMaterialsCommonExtension.ts"); + + + + + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.ts": +/*!******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.ts ***! + \******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_lights_image_based: () => (/* binding */ EXT_lights_image_based) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/Textures/rawCubeTexture */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + + + +var NAME = "EXT_lights_image_based"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_lights_image_based/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var EXT_lights_image_based = /** @class */ (function () { + /** + * @internal + */ + function EXT_lights_image_based(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + EXT_lights_image_based.prototype.dispose = function () { + this._loader = null; + delete this._lights; + }; + /** @internal */ + EXT_lights_image_based.prototype.onLoading = function () { + var extensions = this._loader.gltf.extensions; + if (extensions && extensions[this.name]) { + var extension = extensions[this.name]; + this._lights = extension.lights; + } + }; + /** + * @internal + */ + EXT_lights_image_based.prototype.loadSceneAsync = function (context, scene) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, scene, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadSceneAsync(context, scene)); + _this._loader.logOpen("".concat(extensionContext)); + var light = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/light"), _this._lights, extension.light); + promises.push(_this._loadLightAsync("/extensions/".concat(_this.name, "/lights/").concat(extension.light), light).then(function (texture) { + _this._loader.babylonScene.environmentTexture = texture; + })); + _this._loader.logClose(); + return Promise.all(promises).then(function () { }); + }); + }; + EXT_lights_image_based.prototype._loadLightAsync = function (context, light) { + var _this = this; + if (!light._loaded) { + var promises = new Array(); + this._loader.logOpen("".concat(context)); + var imageData_1 = new Array(light.specularImages.length); + var _loop_1 = function (mipmap) { + var faces = light.specularImages[mipmap]; + imageData_1[mipmap] = new Array(faces.length); + var _loop_2 = function (face) { + var specularImageContext = "".concat(context, "/specularImages/").concat(mipmap, "/").concat(face); + this_1._loader.logOpen("".concat(specularImageContext)); + var index = faces[face]; + var image = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(specularImageContext, this_1._loader.gltf.images, index); + promises.push(this_1._loader.loadImageAsync("/images/".concat(index), image).then(function (data) { + imageData_1[mipmap][face] = data; + })); + this_1._loader.logClose(); + }; + for (var face = 0; face < faces.length; face++) { + _loop_2(face); + } + }; + var this_1 = this; + for (var mipmap = 0; mipmap < light.specularImages.length; mipmap++) { + _loop_1(mipmap); + } + this._loader.logClose(); + light._loaded = Promise.all(promises).then(function () { + var babylonTexture = new babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.RawCubeTexture(_this._loader.babylonScene, null, light.specularImageSize); + babylonTexture.name = light.name || "environment"; + light._babylonTexture = babylonTexture; + if (light.intensity != undefined) { + babylonTexture.level = light.intensity; + } + if (light.rotation) { + var rotation = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(light.rotation); + // Invert the rotation so that positive rotation is counter-clockwise. + if (!_this._loader.babylonScene.useRightHandedSystem) { + rotation = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Inverse(rotation); + } + babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromQuaternionToRef(rotation, babylonTexture.getReflectionTextureMatrix()); + } + if (!light.irradianceCoefficients) { + throw new Error("".concat(context, ": Irradiance coefficients are missing")); + } + var sphericalHarmonics = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.SphericalHarmonics.FromArray(light.irradianceCoefficients); + sphericalHarmonics.scaleInPlace(light.intensity); + sphericalHarmonics.convertIrradianceToLambertianRadiance(); + var sphericalPolynomial = babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.SphericalPolynomial.FromHarmonics(sphericalHarmonics); + // Compute the lod generation scale to fit exactly to the number of levels available. + var lodGenerationScale = (imageData_1.length - 1) / babylonjs_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__.Scalar.Log2(light.specularImageSize); + return babylonTexture.updateRGBDAsync(imageData_1, sphericalPolynomial, lodGenerationScale); + }); + } + return light._loaded.then(function () { + return light._babylonTexture; + }); + }; + return EXT_lights_image_based; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_lights_image_based(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts": +/*!*******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* binding */ EXT_mesh_gpu_instancing) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Meshes/thinInstanceMesh */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "EXT_mesh_gpu_instancing"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_mesh_gpu_instancing/README.md) + * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var EXT_mesh_gpu_instancing = /** @class */ (function () { + /** + * @internal + */ + function EXT_mesh_gpu_instancing(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + EXT_mesh_gpu_instancing.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + EXT_mesh_gpu_instancing.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) { + _this._loader._disableInstancedMesh++; + var promise = _this._loader.loadNodeAsync("/nodes/".concat(node.index), node, assign); + _this._loader._disableInstancedMesh--; + if (!node._primitiveBabylonMeshes) { + return promise; + } + var promises = new Array(); + var instanceCount = 0; + var loadAttribute = function (attribute) { + if (extension.attributes[attribute] == undefined) { + promises.push(Promise.resolve(null)); + return; + } + var accessor = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/attributes/").concat(attribute), _this._loader.gltf.accessors, extension.attributes[attribute]); + promises.push(_this._loader._loadFloatAccessorAsync("/accessors/".concat(accessor.bufferView), accessor)); + if (instanceCount === 0) { + instanceCount = accessor.count; + } + else if (instanceCount !== accessor.count) { + throw new Error("".concat(extensionContext, "/attributes: Instance buffer accessors do not have the same count.")); + } + }; + loadAttribute("TRANSLATION"); + loadAttribute("ROTATION"); + loadAttribute("SCALE"); + return promise.then(function (babylonTransformNode) { + return Promise.all(promises).then(function (_a) { + var translationBuffer = _a[0], rotationBuffer = _a[1], scaleBuffer = _a[2]; + var matrices = new Float32Array(instanceCount * 16); + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0].copyFromFloats(0, 0, 0); // translation + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0].copyFromFloats(0, 0, 0, 1); // rotation + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1].copyFromFloats(1, 1, 1); // scale + for (var i = 0; i < instanceCount; ++i) { + translationBuffer && babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(translationBuffer, i * 3, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0]); + rotationBuffer && babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArrayToRef(rotationBuffer, i * 4, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0]); + scaleBuffer && babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArrayToRef(scaleBuffer, i * 3, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1]); + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Matrix.ComposeToRef(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1], babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Quaternion[0], babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0], babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[0]); + babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Matrix[0].copyToArray(matrices, i * 16); + } + for (var _i = 0, _b = node._primitiveBabylonMeshes; _i < _b.length; _i++) { + var babylonMesh = _b[_i]; + babylonMesh.thinInstanceSetBuffer("matrix", matrices, 16, true); + } + return babylonTransformNode; + }); + }); + }); + }; + return EXT_mesh_gpu_instancing; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_mesh_gpu_instancing(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_meshopt_compression.ts": +/*!*******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/EXT_meshopt_compression.ts ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_meshopt_compression: () => (/* binding */ EXT_meshopt_compression) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); +/* harmony import */ var babylonjs_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/Compression/meshoptCompression */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "EXT_meshopt_compression"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_meshopt_compression/README.md) + * + * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js + * @since 5.0.0 + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var EXT_meshopt_compression = /** @class */ (function () { + /** + * @internal + */ + function EXT_meshopt_compression(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this.enabled = loader.isExtensionUsed(NAME); + this._loader = loader; + } + /** @internal */ + EXT_meshopt_compression.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + EXT_meshopt_compression.prototype.loadBufferViewAsync = function (context, bufferView) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, bufferView, this.name, function (extensionContext, extension) { + var bufferViewMeshopt = bufferView; + if (bufferViewMeshopt._meshOptData) { + return bufferViewMeshopt._meshOptData; + } + var buffer = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/buffer"), _this._loader.gltf.buffers, extension.buffer); + bufferViewMeshopt._meshOptData = _this._loader.loadBufferAsync("/buffers/".concat(buffer.index), buffer, extension.byteOffset || 0, extension.byteLength).then(function (buffer) { + return babylonjs_Meshes_Compression_meshoptCompression__WEBPACK_IMPORTED_MODULE_1__.MeshoptCompression.Default.decodeGltfBufferAsync(buffer, extension.count, extension.byteStride, extension.mode, extension.filter); + }); + return bufferViewMeshopt._meshOptData; + }); + }; + return EXT_meshopt_compression; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_meshopt_compression(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_texture_webp.ts": +/*!************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/EXT_texture_webp.ts ***! + \************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_texture_webp: () => (/* binding */ EXT_texture_webp) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "EXT_texture_webp"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/EXT_texture_webp/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var EXT_texture_webp = /** @class */ (function () { + /** + * @internal + */ + function EXT_texture_webp(loader) { + /** The name of this extension. */ + this.name = NAME; + this._loader = loader; + this.enabled = loader.isExtensionUsed(NAME); + } + /** @internal */ + EXT_texture_webp.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + EXT_texture_webp.prototype._loadTextureAsync = function (context, texture, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, texture, this.name, function (extensionContext, extension) { + var sampler = texture.sampler == undefined ? _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.DefaultSampler : _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/sampler"), _this._loader.gltf.samplers, texture.sampler); + var image = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(extensionContext, "/source"), _this._loader.gltf.images, extension.source); + return _this._loader._createTextureAsync(context, sampler, image, function (babylonTexture) { + assign(babylonTexture); + }, undefined, !texture._textureInfo.nonColorData); + }); + }; + return EXT_texture_webp; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new EXT_texture_webp(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts": +/*!************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts ***! + \************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ ExtrasAsMetadata: () => (/* binding */ ExtrasAsMetadata) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "ExtrasAsMetadata"; +/** + * Store glTF extras (if present) in BJS objects' metadata + */ +var ExtrasAsMetadata = /** @class */ (function () { + /** + * @internal + */ + function ExtrasAsMetadata(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines whether this extension is enabled. + */ + this.enabled = true; + this._loader = loader; + } + ExtrasAsMetadata.prototype._assignExtras = function (babylonObject, gltfProp) { + if (gltfProp.extras && Object.keys(gltfProp.extras).length > 0) { + var metadata = (babylonObject.metadata = babylonObject.metadata || {}); + var gltf = (metadata.gltf = metadata.gltf || {}); + gltf.extras = gltfProp.extras; + } + }; + /** @internal */ + ExtrasAsMetadata.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + ExtrasAsMetadata.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return this._loader.loadNodeAsync(context, node, function (babylonTransformNode) { + _this._assignExtras(babylonTransformNode, node); + assign(babylonTransformNode); + }); + }; + /** + * @internal + */ + ExtrasAsMetadata.prototype.loadCameraAsync = function (context, camera, assign) { + var _this = this; + return this._loader.loadCameraAsync(context, camera, function (babylonCamera) { + _this._assignExtras(babylonCamera, camera); + assign(babylonCamera); + }); + }; + /** + * @internal + */ + ExtrasAsMetadata.prototype.createMaterial = function (context, material, babylonDrawMode) { + var babylonMaterial = this._loader.createMaterial(context, material, babylonDrawMode); + this._assignExtras(babylonMaterial, material); + return babylonMaterial; + }; + return ExtrasAsMetadata; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new ExtrasAsMetadata(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.data.ts": +/*!**********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.data.ts ***! + \**********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ animationPointerTree: () => (/* binding */ animationPointerTree) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.color */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoaderAnimation */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts"); +/* eslint-disable @typescript-eslint/naming-convention */ + + + + +function getColor3(_target, source, offset, scale) { + return babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(source, offset).scale(scale); +} +function getAlpha(_target, source, offset, scale) { + return source[offset + 3] * scale; +} +function getFloat(_target, source, offset, scale) { + return source[offset] * scale; +} +function getMinusFloat(_target, source, offset, scale) { + return -source[offset] * scale; +} +function getNextFloat(_target, source, offset, scale) { + return source[offset + 1] * scale; +} +function getFloatBy2(_target, source, offset, scale) { + return source[offset] * scale * 2; +} +function getTextureTransformTree(textureName) { + return { + scale: [ + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".uScale"), getFloat, function () { return 2; }), + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".vScale"), getNextFloat, function () { return 2; }), + ], + offset: [ + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".uOffset"), getFloat, function () { return 2; }), + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".vOffset"), getNextFloat, function () { return 2; }), + ], + rotation: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "".concat(textureName, ".wAng"), getMinusFloat, function () { return 1; })], + }; +} +var CameraAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(CameraAnimationPropertyInfo, _super); + function CameraAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** @internal */ + CameraAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + callback(target._babylonCamera, this._buildAnimation(name, fps, keys)); + }; + return CameraAnimationPropertyInfo; +}(_glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__.AnimationPropertyInfo)); +var MaterialAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(MaterialAnimationPropertyInfo, _super); + function MaterialAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** @internal */ + MaterialAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + for (var fillMode in target._data) { + callback(target._data[fillMode].babylonMaterial, this._buildAnimation(name, fps, keys)); + } + }; + return MaterialAnimationPropertyInfo; +}(_glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__.AnimationPropertyInfo)); +var LightAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__extends)(LightAnimationPropertyInfo, _super); + function LightAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** @internal */ + LightAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + callback(target._babylonLight, this._buildAnimation(name, fps, keys)); + }; + return LightAnimationPropertyInfo; +}(_glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__.AnimationPropertyInfo)); +var nodesTree = { + __array__: (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({ __target__: true }, _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_1__.nodeAnimationData), +}; +var camerasTree = { + __array__: { + __target__: true, + orthographic: { + xmag: [ + new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "orthoLeft", getMinusFloat, function () { return 1; }), + new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "orthoRight", getNextFloat, function () { return 1; }), + ], + ymag: [ + new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "orthoBottom", getMinusFloat, function () { return 1; }), + new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "orthoTop", getNextFloat, function () { return 1; }), + ], + zfar: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "maxZ", getFloat, function () { return 1; })], + znear: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "minZ", getFloat, function () { return 1; })], + }, + perspective: { + yfov: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "fov", getFloat, function () { return 1; })], + zfar: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "maxZ", getFloat, function () { return 1; })], + znear: [new CameraAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "minZ", getFloat, function () { return 1; })], + }, + }, +}; +var materialsTree = { + __array__: { + __target__: true, + pbrMetallicRoughness: { + baseColorFactor: [ + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "albedoColor", getColor3, function () { return 4; }), + new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "alpha", getAlpha, function () { return 4; }), + ], + metallicFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "metallic", getFloat, function () { return 1; })], + roughnessFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "roughness", getFloat, function () { return 1; })], + baseColorTexture: { + extensions: { + KHR_texture_transform: getTextureTransformTree("albedoTexture"), + }, + }, + }, + emissiveFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "emissiveColor", getColor3, function () { return 3; })], + normalTexture: { + scale: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "bumpTexture.level", getFloat, function () { return 1; })], + }, + occlusionTexture: { + strength: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "ambientTextureStrength", getFloat, function () { return 1; })], + extensions: { + KHR_texture_transform: getTextureTransformTree("ambientTexture"), + }, + }, + emissiveTexture: { + extensions: { + KHR_texture_transform: getTextureTransformTree("emissiveTexture"), + }, + }, + extensions: { + KHR_materials_ior: { + ior: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "indexOfRefraction", getFloat, function () { return 1; })], + }, + KHR_materials_clearcoat: { + clearcoatFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "clearCoat.intensity", getFloat, function () { return 1; })], + clearcoatRoughnessFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "clearCoat.roughness", getFloat, function () { return 1; })], + }, + KHR_materials_sheen: { + sheenColorFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "sheen.color", getColor3, function () { return 3; })], + sheenRoughnessFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "sheen.roughness", getFloat, function () { return 1; })], + }, + KHR_materials_specular: { + specularFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "metallicF0Factor", getFloat, function () { return 1; })], + specularColorFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "metallicReflectanceColor", getColor3, function () { return 3; })], + }, + KHR_materials_emissive_strength: { + emissiveStrength: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "emissiveIntensity", getFloat, function () { return 1; })], + }, + KHR_materials_transmission: { + transmissionFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "subSurface.refractionIntensity", getFloat, function () { return 1; })], + }, + KHR_materials_volume: { + attenuationColor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "subSurface.tintColor", getColor3, function () { return 3; })], + attenuationDistance: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "subSurface.tintColorAtDistance", getFloat, function () { return 1; })], + thicknessFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "subSurface.maximumThickness", getFloat, function () { return 1; })], + }, + KHR_materials_iridescence: { + iridescenceFactor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.intensity", getFloat, function () { return 1; })], + iridescenceIor: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.indexOfRefraction", getFloat, function () { return 1; })], + iridescenceThicknessMinimum: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.minimumThickness", getFloat, function () { return 1; })], + iridescenceThicknessMaximum: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "iridescence.maximumThickness", getFloat, function () { return 1; })], + }, + KHR_materials_anisotropy: { + anisotropyStrength: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "anisotropy.intensity", getFloat, function () { return 1; })], + anisotropyRotation: [new MaterialAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "anisotropy.angle", getFloat, function () { return 1; })], + }, + }, + }, +}; +var extensionsTree = { + KHR_lights_punctual: { + lights: { + __array__: { + __target__: true, + color: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_COLOR3, "diffuse", getColor3, function () { return 3; })], + intensity: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "intensity", getFloat, function () { return 1; })], + range: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "range", getFloat, function () { return 1; })], + spot: { + innerConeAngle: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "innerAngle", getFloatBy2, function () { return 1; })], + outerConeAngle: [new LightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "angle", getFloatBy2, function () { return 1; })], + }, + }, + }, + }, +}; +/** @internal */ +var animationPointerTree = { + nodes: nodesTree, + materials: materialsTree, + cameras: camerasTree, + extensions: extensionsTree, +}; + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.ts": +/*!*****************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.ts ***! + \*****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_animation_pointer: () => (/* binding */ KHR_animation_pointer) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); +/* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Misc/logger */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__); +/* harmony import */ var _KHR_animation_pointer_data__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./KHR_animation_pointer.data */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.data.ts"); + + + +var NAME = "KHR_animation_pointer"; +/** + * [Specification PR](https://github.com/KhronosGroup/glTF/pull/2147) + * !!! Experimental Extension Subject to Changes !!! + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_animation_pointer = /** @class */ (function () { + /** + * @internal + */ + function KHR_animation_pointer(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + } + Object.defineProperty(KHR_animation_pointer.prototype, "enabled", { + /** + * Defines whether this extension is enabled. + */ + get: function () { + return this._loader.isExtensionUsed(NAME); + }, + enumerable: false, + configurable: true + }); + /** @internal */ + KHR_animation_pointer.prototype.dispose = function () { + this._loader = null; + }; + /** + * Loads a glTF animation channel. + * @param context The context when loading the asset + * @param animationContext The context of the animation when loading the asset + * @param animation The glTF animation property + * @param channel The glTF animation channel property + * @param onLoad Called for each animation loaded + * @returns A void promise that resolves when the load is complete or null if not handled + */ + KHR_animation_pointer.prototype._loadAnimationChannelAsync = function (context, animationContext, animation, channel, onLoad) { + var _a; + var extension = (_a = channel.target.extensions) === null || _a === void 0 ? void 0 : _a.KHR_animation_pointer; + if (!extension) { + return null; + } + if (channel.target.path !== "pointer" /* AnimationChannelTargetPath.POINTER */) { + babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.Warn("".concat(context, "/target/path: Value (").concat(channel.target.path, ") must be (").concat("pointer" /* AnimationChannelTargetPath.POINTER */, ") when using the ").concat(this.name, " extension")); + } + if (channel.target.node != undefined) { + babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.Warn("".concat(context, "/target/node: Value (").concat(channel.target.node, ") must not be present when using the ").concat(this.name, " extension")); + } + var extensionContext = "".concat(context, "/extensions/").concat(this.name); + var pointer = extension.pointer; + if (!pointer) { + throw new Error("".concat(extensionContext, ": Pointer is missing")); + } + var targetInfo = this._parseAnimationPointer("".concat(extensionContext, "/pointer"), pointer); + if (!targetInfo) { + babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.Warn("".concat(extensionContext, "/pointer: Invalid pointer (").concat(pointer, ") skipped")); + return null; + } + return this._loader._loadAnimationChannelFromTargetInfoAsync(context, animationContext, animation, channel, targetInfo, onLoad); + }; + /** + * The pointer string is represented by a [JSON pointer](https://datatracker.ietf.org/doc/html/rfc6901). + * := /// + * := "nodes" | "materials" | "meshes" | "cameras" | "extensions" + * := | + * := | + * := "extensions"// + * := | / + * := W+ + * := D+ + * + * Examples: + * - "/nodes/0/rotation" + * - "/materials/2/emissiveFactor" + * - "/materials/2/pbrMetallicRoughness/baseColorFactor" + * - "/materials/2/extensions/KHR_materials_emissive_strength/emissiveStrength" + */ + KHR_animation_pointer.prototype._parseAnimationPointer = function (context, pointer) { + if (!pointer.startsWith("/")) { + babylonjs_Misc_logger__WEBPACK_IMPORTED_MODULE_1__.Logger.Warn("".concat(context, ": Value (").concat(pointer, ") must start with a slash")); + return null; + } + var parts = pointer.split("/"); + // Remove the first part since it will be empty string as pointers must start with a slash. + parts.shift(); + var node = _KHR_animation_pointer_data__WEBPACK_IMPORTED_MODULE_2__.animationPointerTree; + var gltfCurrentNode = this._loader.gltf; + var gltfTargetNode = undefined; + for (var _i = 0, parts_1 = parts; _i < parts_1.length; _i++) { + var part = parts_1[_i]; + if (node.__array__) { + node = node.__array__; + } + else { + node = node[part]; + if (!node) { + return null; + } + } + gltfCurrentNode = gltfCurrentNode && gltfCurrentNode[part]; + if (node.__target__) { + gltfTargetNode = gltfCurrentNode; + } + } + if (!gltfTargetNode || !Array.isArray(node)) { + return null; + } + return { + target: gltfTargetNode, + properties: node, + }; + }; + return KHR_animation_pointer; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_animation_pointer(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts": +/*!**********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts ***! + \**********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_draco_mesh_compression: () => (/* binding */ KHR_draco_mesh_compression) +/* harmony export */ }); +/* harmony import */ var babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Buffers/buffer */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_draco_mesh_compression"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_draco_mesh_compression/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_draco_mesh_compression = /** @class */ (function () { + /** + * @internal + */ + function KHR_draco_mesh_compression(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines whether to use the normalized flag from the glTF accessor instead of the Draco data. Defaults to true. + */ + this.useNormalizedFlagFromAccessor = true; + this._loader = loader; + this.enabled = babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_draco_mesh_compression.prototype.dispose = function () { + delete this.dracoCompression; + this._loader = null; + }; + /** + * @internal + */ + KHR_draco_mesh_compression.prototype._loadVertexDataAsync = function (context, primitive, babylonMesh) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, primitive, this.name, function (extensionContext, extension) { + if (primitive.mode != undefined) { + if (primitive.mode !== 5 /* MeshPrimitiveMode.TRIANGLE_STRIP */ && primitive.mode !== 4 /* MeshPrimitiveMode.TRIANGLES */) { + throw new Error("".concat(context, ": Unsupported mode ").concat(primitive.mode)); + } + // TODO: handle triangle strips + if (primitive.mode === 5 /* MeshPrimitiveMode.TRIANGLE_STRIP */) { + throw new Error("".concat(context, ": Mode ").concat(primitive.mode, " is not currently supported")); + } + } + var attributes = {}; + var normalized = {}; + var loadAttribute = function (name, kind) { + var uniqueId = extension.attributes[name]; + if (uniqueId == undefined) { + return; + } + babylonMesh._delayInfo = babylonMesh._delayInfo || []; + if (babylonMesh._delayInfo.indexOf(kind) === -1) { + babylonMesh._delayInfo.push(kind); + } + attributes[kind] = uniqueId; + if (_this.useNormalizedFlagFromAccessor) { + var accessor = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.TryGet(_this._loader.gltf.accessors, primitive.attributes[name]); + if (accessor) { + normalized[kind] = accessor.normalized || false; + } + } + }; + loadAttribute("POSITION", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind); + loadAttribute("NORMAL", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind); + loadAttribute("TANGENT", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind); + loadAttribute("TEXCOORD_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind); + loadAttribute("TEXCOORD_1", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind); + loadAttribute("TEXCOORD_2", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV3Kind); + loadAttribute("TEXCOORD_3", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV4Kind); + loadAttribute("TEXCOORD_4", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV5Kind); + loadAttribute("TEXCOORD_5", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV6Kind); + loadAttribute("JOINTS_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind); + loadAttribute("WEIGHTS_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsKind); + loadAttribute("COLOR_0", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind); + var bufferView = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(extensionContext, _this._loader.gltf.bufferViews, extension.bufferView); + if (!bufferView._dracoBabylonGeometry) { + bufferView._dracoBabylonGeometry = _this._loader.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) { + var dracoCompression = _this.dracoCompression || babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.DracoCompression.Default; + return dracoCompression._decodeMeshToGeometryForGltfAsync(babylonMesh.name, _this._loader.babylonScene, data, attributes, normalized).catch(function (error) { + throw new Error("".concat(context, ": ").concat(error.message)); + }); + }); + } + return bufferView._dracoBabylonGeometry; + }); + }; + return KHR_draco_mesh_compression; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_draco_mesh_compression(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts": +/*!***************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts ***! + \***************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_lights: () => (/* binding */ KHR_lights) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Lights/light */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + + + + + +var NAME = "KHR_lights_punctual"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_lights_punctual/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_lights = /** @class */ (function () { + /** + * @internal + */ + function KHR_lights(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_lights.prototype.dispose = function () { + this._loader = null; + delete this._lights; + }; + /** @internal */ + KHR_lights.prototype.onLoading = function () { + var extensions = this._loader.gltf.extensions; + if (extensions && extensions[this.name]) { + var extension = extensions[this.name]; + this._lights = extension.lights; + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(this._lights); + } + }; + /** + * @internal + */ + KHR_lights.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) { + return _this._loader.loadNodeAsync(context, node, function (babylonMesh) { + var babylonLight; + var light = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(extensionContext, _this._lights, extension.light); + var name = light.name || babylonMesh.name; + _this._loader.babylonScene._blockEntityCollection = !!_this._loader._assetContainer; + switch (light.type) { + case "directional" /* KHRLightsPunctual_LightType.DIRECTIONAL */: { + var babylonDirectionalLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.DirectionalLight(name, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Backward(), _this._loader.babylonScene); + babylonDirectionalLight.position.setAll(0); + babylonLight = babylonDirectionalLight; + break; + } + case "point" /* KHRLightsPunctual_LightType.POINT */: { + babylonLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.PointLight(name, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(), _this._loader.babylonScene); + break; + } + case "spot" /* KHRLightsPunctual_LightType.SPOT */: { + var babylonSpotLight = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.SpotLight(name, babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(), babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Backward(), 0, 1, _this._loader.babylonScene); + babylonSpotLight.angle = ((light.spot && light.spot.outerConeAngle) || Math.PI / 4) * 2; + babylonSpotLight.innerAngle = ((light.spot && light.spot.innerConeAngle) || 0) * 2; + babylonLight = babylonSpotLight; + break; + } + default: { + _this._loader.babylonScene._blockEntityCollection = false; + throw new Error("".concat(extensionContext, ": Invalid light type (").concat(light.type, ")")); + } + } + babylonLight._parentContainer = _this._loader._assetContainer; + _this._loader.babylonScene._blockEntityCollection = false; + light._babylonLight = babylonLight; + babylonLight.falloffType = babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Light.FALLOFF_GLTF; + babylonLight.diffuse = light.color ? babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(light.color) : babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + babylonLight.intensity = light.intensity == undefined ? 1 : light.intensity; + babylonLight.range = light.range == undefined ? Number.MAX_VALUE : light.range; + babylonLight.parent = babylonMesh; + _this._loader._babylonLights.push(babylonLight); + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.AddPointerMetadata(babylonLight, extensionContext); + assign(babylonMesh); + }); + }); + }; + return KHR_lights; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_lights(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts": +/*!********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts ***! + \********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_anisotropy: () => (/* binding */ KHR_materials_anisotropy) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_anisotropy"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_materials_anisotropy) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_anisotropy = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_anisotropy(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 195; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_anisotropy.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_anisotropy.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadIridescencePropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_anisotropy.prototype._loadIridescencePropertiesAsync = function (context, properties, babylonMaterial) { + var _a, _b; + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.anisotropy.isEnabled = true; + babylonMaterial.anisotropy.intensity = (_a = properties.anisotropyStrength) !== null && _a !== void 0 ? _a : 0; + babylonMaterial.anisotropy.angle = (_b = properties.anisotropyRotation) !== null && _b !== void 0 ? _b : 0; + if (properties.anisotropyTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/anisotropyTexture"), properties.anisotropyTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Anisotropy Intensity)"); + babylonMaterial.anisotropy.texture = texture; + })); + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_anisotropy; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_anisotropy(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts": +/*!*******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts ***! + \*******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_clearcoat: () => (/* binding */ KHR_materials_clearcoat) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_clearcoat"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md) + * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_clearcoat = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_clearcoat(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 190; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_clearcoat.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_clearcoat.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadClearCoatPropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_clearcoat.prototype._loadClearCoatPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.clearCoat.isEnabled = true; + babylonMaterial.clearCoat.useRoughnessFromMainTexture = false; + babylonMaterial.clearCoat.remapF0OnInterfaceChange = false; + if (properties.clearcoatFactor != undefined) { + babylonMaterial.clearCoat.intensity = properties.clearcoatFactor; + } + else { + babylonMaterial.clearCoat.intensity = 0; + } + if (properties.clearcoatTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/clearcoatTexture"), properties.clearcoatTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (ClearCoat Intensity)"); + babylonMaterial.clearCoat.texture = texture; + })); + } + if (properties.clearcoatRoughnessFactor != undefined) { + babylonMaterial.clearCoat.roughness = properties.clearcoatRoughnessFactor; + } + else { + babylonMaterial.clearCoat.roughness = 0; + } + if (properties.clearcoatRoughnessTexture) { + properties.clearcoatRoughnessTexture.nonColorData = true; + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/clearcoatRoughnessTexture"), properties.clearcoatRoughnessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (ClearCoat Roughness)"); + babylonMaterial.clearCoat.textureRoughness = texture; + })); + } + if (properties.clearcoatNormalTexture) { + properties.clearcoatNormalTexture.nonColorData = true; + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/clearcoatNormalTexture"), properties.clearcoatNormalTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (ClearCoat Normal)"); + babylonMaterial.clearCoat.bumpTexture = texture; + })); + babylonMaterial.invertNormalMapX = !babylonMaterial.getScene().useRightHandedSystem; + babylonMaterial.invertNormalMapY = babylonMaterial.getScene().useRightHandedSystem; + if (properties.clearcoatNormalTexture.scale != undefined) { + babylonMaterial.clearCoat.bumpTexture.level = properties.clearcoatNormalTexture.scale; + } + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_clearcoat; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_clearcoat(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts": +/*!***************************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts ***! + \***************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_emissive_strength: () => (/* binding */ KHR_materials_emissive_strength) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_emissive_strength"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_emissive_strength/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_emissive_strength = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_emissive_strength(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 170; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_emissive_strength.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_emissive_strength.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + return _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial).then(function () { + _this._loadEmissiveProperties(extensionContext, extension, babylonMaterial); + }); + }); + }; + KHR_materials_emissive_strength.prototype._loadEmissiveProperties = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + if (properties.emissiveStrength !== undefined) { + babylonMaterial.emissiveColor.scaleToRef(properties.emissiveStrength, babylonMaterial.emissiveColor); + } + }; + return KHR_materials_emissive_strength; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_emissive_strength(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_ior.ts": +/*!*************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_ior.ts ***! + \*************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_ior: () => (/* binding */ KHR_materials_ior) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_ior"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_ior/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_ior = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_ior(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 180; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_ior.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_ior.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadIorPropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_ior.prototype._loadIorPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + if (properties.ior !== undefined) { + babylonMaterial.indexOfRefraction = properties.ior; + } + else { + babylonMaterial.indexOfRefraction = KHR_materials_ior._DEFAULT_IOR; + } + return Promise.resolve(); + }; + /** + * Default ior Value from the spec. + */ + KHR_materials_ior._DEFAULT_IOR = 1.5; + return KHR_materials_ior; +}()); +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_ior(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts": +/*!*********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts ***! + \*********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_iridescence: () => (/* binding */ KHR_materials_iridescence) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_iridescence"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_iridescence/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_iridescence = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_iridescence(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 195; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_iridescence.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_iridescence.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadIridescencePropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_iridescence.prototype._loadIridescencePropertiesAsync = function (context, properties, babylonMaterial) { + var _a, _b, _c, _d, _e; + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.iridescence.isEnabled = true; + babylonMaterial.iridescence.intensity = (_a = properties.iridescenceFactor) !== null && _a !== void 0 ? _a : 0; + babylonMaterial.iridescence.indexOfRefraction = (_c = (_b = properties.iridescenceIor) !== null && _b !== void 0 ? _b : properties.iridescenceIOR) !== null && _c !== void 0 ? _c : 1.3; + babylonMaterial.iridescence.minimumThickness = (_d = properties.iridescenceThicknessMinimum) !== null && _d !== void 0 ? _d : 100; + babylonMaterial.iridescence.maximumThickness = (_e = properties.iridescenceThicknessMaximum) !== null && _e !== void 0 ? _e : 400; + if (properties.iridescenceTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/iridescenceTexture"), properties.iridescenceTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Iridescence Intensity)"); + babylonMaterial.iridescence.texture = texture; + })); + } + if (properties.iridescenceThicknessTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/iridescenceThicknessTexture"), properties.iridescenceThicknessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Iridescence Thickness)"); + babylonMaterial.iridescence.thicknessTexture = texture; + })); + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_iridescence; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_iridescence(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts": +/*!*******************************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts ***! + \*******************************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_pbrSpecularGlossiness: () => (/* binding */ KHR_materials_pbrSpecularGlossiness) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_materials_pbrSpecularGlossiness"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Archived/KHR_materials_pbrSpecularGlossiness/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_pbrSpecularGlossiness = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_pbrSpecularGlossiness(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 200; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_pbrSpecularGlossiness.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_pbrSpecularGlossiness.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadSpecularGlossinessPropertiesAsync(extensionContext, material, extension, babylonMaterial)); + _this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_pbrSpecularGlossiness.prototype._loadSpecularGlossinessPropertiesAsync = function (context, material, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.metallic = null; + babylonMaterial.roughness = null; + if (properties.diffuseFactor) { + babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.diffuseFactor); + babylonMaterial.alpha = properties.diffuseFactor[3]; + } + else { + babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + } + babylonMaterial.reflectivityColor = properties.specularFactor ? babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.specularFactor) : babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + babylonMaterial.microSurface = properties.glossinessFactor == undefined ? 1 : properties.glossinessFactor; + if (properties.diffuseTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/diffuseTexture"), properties.diffuseTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Diffuse)"); + babylonMaterial.albedoTexture = texture; + })); + } + if (properties.specularGlossinessTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularGlossinessTexture"), properties.specularGlossinessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Specular Glossiness)"); + babylonMaterial.reflectivityTexture = texture; + babylonMaterial.reflectivityTexture.hasAlpha = true; + })); + babylonMaterial.useMicroSurfaceFromReflectivityMapAlpha = true; + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_pbrSpecularGlossiness; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_pbrSpecularGlossiness(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_sheen.ts": +/*!***************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_sheen.ts ***! + \***************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_sheen: () => (/* binding */ KHR_materials_sheen) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.color */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_materials_sheen"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_sheen/README.md) + * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_sheen = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_sheen(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 190; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_sheen.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_sheen.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadSheenPropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_sheen.prototype._loadSheenPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.sheen.isEnabled = true; + babylonMaterial.sheen.intensity = 1; + if (properties.sheenColorFactor != undefined) { + babylonMaterial.sheen.color = babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.sheenColorFactor); + } + else { + babylonMaterial.sheen.color = babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Color3.Black(); + } + if (properties.sheenColorTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/sheenColorTexture"), properties.sheenColorTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Sheen Color)"); + babylonMaterial.sheen.texture = texture; + })); + } + if (properties.sheenRoughnessFactor !== undefined) { + babylonMaterial.sheen.roughness = properties.sheenRoughnessFactor; + } + else { + babylonMaterial.sheen.roughness = 0; + } + if (properties.sheenRoughnessTexture) { + properties.sheenRoughnessTexture.nonColorData = true; + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/sheenRoughnessTexture"), properties.sheenRoughnessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Sheen Roughness)"); + babylonMaterial.sheen.textureRoughness = texture; + })); + } + babylonMaterial.sheen.albedoScaling = true; + babylonMaterial.sheen.useRoughnessFromMainTexture = false; + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_sheen; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_sheen(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts": +/*!******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts ***! + \******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_specular: () => (/* binding */ KHR_materials_specular) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.color */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_materials_specular"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_specular/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_specular = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_specular(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 190; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_specular.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_specular.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadSpecularPropertiesAsync(extensionContext, extension, babylonMaterial)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_specular.prototype._loadSpecularPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + if (properties.specularFactor !== undefined) { + babylonMaterial.metallicF0Factor = properties.specularFactor; + } + if (properties.specularColorFactor !== undefined) { + babylonMaterial.metallicReflectanceColor = babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.specularColorFactor); + } + if (properties.specularTexture) { + properties.specularTexture.nonColorData = true; + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularTexture"), properties.specularTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Specular F0 Strength)"); + babylonMaterial.metallicReflectanceTexture = texture; + babylonMaterial.useOnlyMetallicFromMetallicReflectanceTexture = true; + })); + } + if (properties.specularColorTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/specularColorTexture"), properties.specularColorTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Specular F0 Color)"); + babylonMaterial.reflectanceTexture = texture; + })); + } + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_specular; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_specular(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_translucency.ts": +/*!**********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_translucency.ts ***! + \**********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_translucency: () => (/* binding */ KHR_materials_translucency) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_translucency"; +/** + * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825) + * !!! Experimental Extension Subject to Changes !!! + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_translucency = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_translucency(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 174; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + if (this.enabled) { + loader.parent.transparencyAsCoverage = true; + } + } + /** @internal */ + KHR_materials_translucency.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_translucency.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadTranslucentPropertiesAsync(extensionContext, material, babylonMaterial, extension)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_translucency.prototype._loadTranslucentPropertiesAsync = function (context, material, babylonMaterial, extension) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var pbrMaterial = babylonMaterial; + // Enables "translucency" texture which represents diffusely-transmitted light. + pbrMaterial.subSurface.isTranslucencyEnabled = true; + // Since this extension models thin-surface transmission only, we must make the + // internal IOR == 1.0 and set the thickness to 0. + pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0; + pbrMaterial.subSurface.minimumThickness = 0.0; + pbrMaterial.subSurface.maximumThickness = 0.0; + // Albedo colour will tint transmission. + pbrMaterial.subSurface.useAlbedoToTintTranslucency = true; + if (extension.translucencyFactor !== undefined) { + pbrMaterial.subSurface.translucencyIntensity = extension.translucencyFactor; + } + else { + pbrMaterial.subSurface.translucencyIntensity = 0.0; + pbrMaterial.subSurface.isTranslucencyEnabled = false; + return Promise.resolve(); + } + if (extension.translucencyTexture) { + extension.translucencyTexture.nonColorData = true; + return this._loader.loadTextureInfoAsync("".concat(context, "/translucencyTexture"), extension.translucencyTexture).then(function (texture) { + pbrMaterial.subSurface.translucencyIntensityTexture = texture; + }); + } + else { + return Promise.resolve(); + } + }; + return KHR_materials_translucency; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_translucency(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts": +/*!**********************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts ***! + \**********************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_transmission: () => (/* binding */ KHR_materials_transmission) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + + + + + +/** + * A class to handle setting up the rendering of opaque objects to be shown through transmissive objects. + */ +var TransmissionHelper = /** @class */ (function () { + /** + * constructor + * @param options Defines the options we want to customize the helper + * @param scene The scene to add the material to + */ + function TransmissionHelper(options, scene) { + var _this = this; + this._opaqueRenderTarget = null; + this._opaqueMeshesCache = []; + this._transparentMeshesCache = []; + this._materialObservers = {}; + this._options = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, TransmissionHelper._GetDefaultOptions()), options); + this._scene = scene; + this._scene._transmissionHelper = this; + this.onErrorObservable = new babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Observable(); + this._scene.onDisposeObservable.addOnce(function () { + _this.dispose(); + }); + this._parseScene(); + this._setupRenderTargets(); + } + /** + * Creates the default options for the helper. + */ + TransmissionHelper._GetDefaultOptions = function () { + return { + renderSize: 1024, + samples: 4, + lodGenerationScale: 1, + lodGenerationOffset: -4, + renderTargetTextureType: babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Constants.TEXTURETYPE_HALF_FLOAT, + generateMipmaps: true, + }; + }; + /** + * Updates the background according to the new options + * @param options + */ + TransmissionHelper.prototype.updateOptions = function (options) { + var _this = this; + // First check if any options are actually being changed. If not, exit. + var newValues = Object.keys(options).filter(function (key) { return _this._options[key] !== options[key]; }); + if (!newValues.length) { + return; + } + var newOptions = (0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)((0,tslib__WEBPACK_IMPORTED_MODULE_2__.__assign)({}, this._options), options); + var oldOptions = this._options; + this._options = newOptions; + // If size changes, recreate everything + if (newOptions.renderSize !== oldOptions.renderSize || + newOptions.renderTargetTextureType !== oldOptions.renderTargetTextureType || + newOptions.generateMipmaps !== oldOptions.generateMipmaps || + !this._opaqueRenderTarget) { + this._setupRenderTargets(); + } + else { + this._opaqueRenderTarget.samples = newOptions.samples; + this._opaqueRenderTarget.lodGenerationScale = newOptions.lodGenerationScale; + this._opaqueRenderTarget.lodGenerationOffset = newOptions.lodGenerationOffset; + } + }; + /** + * Gets the opaque render target texture or null if not available. + */ + TransmissionHelper.prototype.getOpaqueTarget = function () { + return this._opaqueRenderTarget; + }; + TransmissionHelper.prototype._shouldRenderAsTransmission = function (material) { + if (!material) { + return false; + } + if (material instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial && material.subSurface.isRefractionEnabled) { + return true; + } + return false; + }; + TransmissionHelper.prototype._addMesh = function (mesh) { + var _this = this; + this._materialObservers[mesh.uniqueId] = mesh.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this)); + // we need to defer the processing because _addMesh may be called as part as an instance mesh creation, in which case some + // internal properties are not setup yet, like _sourceMesh (needed when doing mesh.material below) + babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.Tools.SetImmediate(function () { + if (_this._shouldRenderAsTransmission(mesh.material)) { + mesh.material.refractionTexture = _this._opaqueRenderTarget; + if (_this._transparentMeshesCache.indexOf(mesh) === -1) { + _this._transparentMeshesCache.push(mesh); + } + } + else { + if (_this._opaqueMeshesCache.indexOf(mesh) === -1) { + _this._opaqueMeshesCache.push(mesh); + } + } + }); + }; + TransmissionHelper.prototype._removeMesh = function (mesh) { + mesh.onMaterialChangedObservable.remove(this._materialObservers[mesh.uniqueId]); + delete this._materialObservers[mesh.uniqueId]; + var idx = this._transparentMeshesCache.indexOf(mesh); + if (idx !== -1) { + this._transparentMeshesCache.splice(idx, 1); + } + idx = this._opaqueMeshesCache.indexOf(mesh); + if (idx !== -1) { + this._opaqueMeshesCache.splice(idx, 1); + } + }; + TransmissionHelper.prototype._parseScene = function () { + this._scene.meshes.forEach(this._addMesh.bind(this)); + // Listen for when a mesh is added to the scene and add it to our cache lists. + this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this)); + // Listen for when a mesh is removed from to the scene and remove it from our cache lists. + this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this)); + }; + // When one of the meshes in the scene has its material changed, make sure that it's in the correct cache list. + TransmissionHelper.prototype._onMeshMaterialChanged = function (mesh) { + var transparentIdx = this._transparentMeshesCache.indexOf(mesh); + var opaqueIdx = this._opaqueMeshesCache.indexOf(mesh); + // If the material is transparent, make sure that it's added to the transparent list and removed from the opaque list + var useTransmission = this._shouldRenderAsTransmission(mesh.material); + if (useTransmission) { + if (mesh.material instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial) { + mesh.material.subSurface.refractionTexture = this._opaqueRenderTarget; + } + if (opaqueIdx !== -1) { + this._opaqueMeshesCache.splice(opaqueIdx, 1); + this._transparentMeshesCache.push(mesh); + } + else if (transparentIdx === -1) { + this._transparentMeshesCache.push(mesh); + } + // If the material is opaque, make sure that it's added to the opaque list and removed from the transparent list + } + else { + if (transparentIdx !== -1) { + this._transparentMeshesCache.splice(transparentIdx, 1); + this._opaqueMeshesCache.push(mesh); + } + else if (opaqueIdx === -1) { + this._opaqueMeshesCache.push(mesh); + } + } + }; + /** + * @internal + * Check if the opaque render target has not been disposed and can still be used. + * @returns + */ + TransmissionHelper.prototype._isRenderTargetValid = function () { + var _a; + return ((_a = this._opaqueRenderTarget) === null || _a === void 0 ? void 0 : _a.getInternalTexture()) !== null; + }; + /** + * @internal + * Setup the render targets according to the specified options. + */ + TransmissionHelper.prototype._setupRenderTargets = function () { + var _this = this; + var _a, _b; + if (this._opaqueRenderTarget) { + this._opaqueRenderTarget.dispose(); + } + this._opaqueRenderTarget = new babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.RenderTargetTexture("opaqueSceneTexture", this._options.renderSize, this._scene, this._options.generateMipmaps, undefined, this._options.renderTargetTextureType); + this._opaqueRenderTarget.ignoreCameraViewport = true; + this._opaqueRenderTarget.renderList = this._opaqueMeshesCache; + 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(); + this._opaqueRenderTarget.gammaSpace = false; + this._opaqueRenderTarget.lodGenerationScale = this._options.lodGenerationScale; + this._opaqueRenderTarget.lodGenerationOffset = this._options.lodGenerationOffset; + this._opaqueRenderTarget.samples = this._options.samples; + var sceneImageProcessingapplyByPostProcess; + var saveSceneEnvIntensity; + this._opaqueRenderTarget.onBeforeBindObservable.add(function (opaqueRenderTarget) { + saveSceneEnvIntensity = _this._scene.environmentIntensity; + _this._scene.environmentIntensity = 1.0; + sceneImageProcessingapplyByPostProcess = _this._scene.imageProcessingConfiguration.applyByPostProcess; + if (!_this._options.clearColor) { + _this._scene.clearColor.toLinearSpaceToRef(opaqueRenderTarget.clearColor, _this._scene.getEngine().useExactSrgbConversions); + } + else { + opaqueRenderTarget.clearColor.copyFrom(_this._options.clearColor); + } + // we do not use the applyByPostProcess setter to avoid flagging all the materials as "image processing dirty"! + _this._scene.imageProcessingConfiguration._applyByPostProcess = true; + }); + this._opaqueRenderTarget.onAfterUnbindObservable.add(function () { + _this._scene.environmentIntensity = saveSceneEnvIntensity; + _this._scene.imageProcessingConfiguration._applyByPostProcess = sceneImageProcessingapplyByPostProcess; + }); + this._transparentMeshesCache.forEach(function (mesh) { + if (_this._shouldRenderAsTransmission(mesh.material)) { + mesh.material.refractionTexture = _this._opaqueRenderTarget; + } + }); + }; + /** + * Dispose all the elements created by the Helper. + */ + TransmissionHelper.prototype.dispose = function () { + this._scene._transmissionHelper = undefined; + if (this._opaqueRenderTarget) { + this._opaqueRenderTarget.dispose(); + this._opaqueRenderTarget = null; + } + this._transparentMeshesCache = []; + this._opaqueMeshesCache = []; + }; + return TransmissionHelper; +}()); +var NAME = "KHR_materials_transmission"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_transmission/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_transmission = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_transmission(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 175; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + if (this.enabled) { + loader.parent.transparencyAsCoverage = true; + } + } + /** @internal */ + KHR_materials_transmission.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_transmission.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadTransparentPropertiesAsync(extensionContext, material, babylonMaterial, extension)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_transmission.prototype._loadTransparentPropertiesAsync = function (context, material, babylonMaterial, extension) { + var _a, _b; + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var pbrMaterial = babylonMaterial; + // Enables "refraction" texture which represents transmitted light. + pbrMaterial.subSurface.isRefractionEnabled = true; + // Since this extension models thin-surface transmission only, we must make IOR = 1.0 + pbrMaterial.subSurface.volumeIndexOfRefraction = 1.0; + // Albedo colour will tint transmission. + pbrMaterial.subSurface.useAlbedoToTintRefraction = true; + if (extension.transmissionFactor !== undefined) { + pbrMaterial.subSurface.refractionIntensity = extension.transmissionFactor; + var scene = pbrMaterial.getScene(); + if (pbrMaterial.subSurface.refractionIntensity && !scene._transmissionHelper) { + new TransmissionHelper({}, pbrMaterial.getScene()); + } + else if (pbrMaterial.subSurface.refractionIntensity && !((_a = scene._transmissionHelper) === null || _a === void 0 ? void 0 : _a._isRenderTargetValid())) { + // If the render target is not valid, recreate it. + (_b = scene._transmissionHelper) === null || _b === void 0 ? void 0 : _b._setupRenderTargets(); + } + } + else { + pbrMaterial.subSurface.refractionIntensity = 0.0; + pbrMaterial.subSurface.isRefractionEnabled = false; + return Promise.resolve(); + } + pbrMaterial.subSurface.minimumThickness = 0.0; + pbrMaterial.subSurface.maximumThickness = 0.0; + if (extension.transmissionTexture) { + extension.transmissionTexture.nonColorData = true; + return this._loader.loadTextureInfoAsync("".concat(context, "/transmissionTexture"), extension.transmissionTexture, undefined).then(function (texture) { + pbrMaterial.subSurface.refractionIntensityTexture = texture; + pbrMaterial.subSurface.useGltfStyleTextures = true; + }); + } + else { + return Promise.resolve(); + } + }; + return KHR_materials_transmission; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_transmission(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_unlit.ts": +/*!***************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_unlit.ts ***! + \***************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_unlit: () => (/* binding */ KHR_materials_unlit) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "KHR_materials_unlit"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_unlit/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_unlit = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_unlit(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 210; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_unlit.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_unlit.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function () { + return _this._loadUnlitPropertiesAsync(context, material, babylonMaterial); + }); + }; + KHR_materials_unlit.prototype._loadUnlitPropertiesAsync = function (context, material, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.unlit = true; + var properties = material.pbrMetallicRoughness; + if (properties) { + if (properties.baseColorFactor) { + babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.baseColorFactor); + babylonMaterial.alpha = properties.baseColorFactor[3]; + } + else { + babylonMaterial.albedoColor = babylonjs_Maths_math_color__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + } + if (properties.baseColorTexture) { + promises.push(this._loader.loadTextureInfoAsync("".concat(context, "/baseColorTexture"), properties.baseColorTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Base Color)"); + babylonMaterial.albedoTexture = texture; + })); + } + } + if (material.doubleSided) { + babylonMaterial.backFaceCulling = false; + babylonMaterial.twoSidedLighting = true; + } + this._loader.loadMaterialAlphaProperties(context, material, babylonMaterial); + return Promise.all(promises).then(function () { }); + }; + return KHR_materials_unlit; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_unlit(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_variants.ts": +/*!******************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_variants.ts ***! + \******************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_variants: () => (/* binding */ KHR_materials_variants) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); +/* harmony import */ var babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! babylonjs/Meshes/mesh */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__); + + +var NAME = "KHR_materials_variants"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_variants/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_variants = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_variants(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_materials_variants.prototype.dispose = function () { + this._loader = null; + }; + /** + * Gets the list of available variant names for this asset. + * @param rootMesh The glTF root mesh + * @returns the list of all the variant names for this model + */ + KHR_materials_variants.GetAvailableVariants = function (rootMesh) { + var extensionMetadata = this._GetExtensionMetadata(rootMesh); + if (!extensionMetadata) { + return []; + } + return Object.keys(extensionMetadata.variants); + }; + /** + * Gets the list of available variant names for this asset. + * @param rootMesh The glTF root mesh + * @returns the list of all the variant names for this model + */ + KHR_materials_variants.prototype.getAvailableVariants = function (rootMesh) { + return KHR_materials_variants.GetAvailableVariants(rootMesh); + }; + /** + * Select a variant given a variant name or a list of variant names. + * @param rootMesh The glTF root mesh + * @param variantName The variant name(s) to select. + */ + KHR_materials_variants.SelectVariant = function (rootMesh, variantName) { + var extensionMetadata = this._GetExtensionMetadata(rootMesh); + if (!extensionMetadata) { + throw new Error("Cannot select variant on a glTF mesh that does not have the ".concat(NAME, " extension")); + } + var select = function (variantName) { + var entries = extensionMetadata.variants[variantName]; + if (entries) { + for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) { + var entry = entries_1[_i]; + entry.mesh.material = entry.material; + } + } + }; + if (variantName instanceof Array) { + for (var _i = 0, variantName_1 = variantName; _i < variantName_1.length; _i++) { + var name_1 = variantName_1[_i]; + select(name_1); + } + } + else { + select(variantName); + } + extensionMetadata.lastSelected = variantName; + }; + /** + * Select a variant given a variant name or a list of variant names. + * @param rootMesh The glTF root mesh + * @param variantName The variant name(s) to select. + */ + KHR_materials_variants.prototype.selectVariant = function (rootMesh, variantName) { + return KHR_materials_variants.SelectVariant(rootMesh, variantName); + }; + /** + * Reset back to the original before selecting a variant. + * @param rootMesh The glTF root mesh + */ + KHR_materials_variants.Reset = function (rootMesh) { + var extensionMetadata = this._GetExtensionMetadata(rootMesh); + if (!extensionMetadata) { + throw new Error("Cannot reset on a glTF mesh that does not have the ".concat(NAME, " extension")); + } + for (var _i = 0, _a = extensionMetadata.original; _i < _a.length; _i++) { + var entry = _a[_i]; + entry.mesh.material = entry.material; + } + extensionMetadata.lastSelected = null; + }; + /** + * Reset back to the original before selecting a variant. + * @param rootMesh The glTF root mesh + */ + KHR_materials_variants.prototype.reset = function (rootMesh) { + return KHR_materials_variants.Reset(rootMesh); + }; + /** + * Gets the last selected variant name(s) or null if original. + * @param rootMesh The glTF root mesh + * @returns The selected variant name(s). + */ + KHR_materials_variants.GetLastSelectedVariant = function (rootMesh) { + var extensionMetadata = this._GetExtensionMetadata(rootMesh); + if (!extensionMetadata) { + throw new Error("Cannot get the last selected variant on a glTF mesh that does not have the ".concat(NAME, " extension")); + } + return extensionMetadata.lastSelected; + }; + /** + * Gets the last selected variant name(s) or null if original. + * @param rootMesh The glTF root mesh + * @returns The selected variant name(s). + */ + KHR_materials_variants.prototype.getLastSelectedVariant = function (rootMesh) { + return KHR_materials_variants.GetLastSelectedVariant(rootMesh); + }; + KHR_materials_variants._GetExtensionMetadata = function (rootMesh) { + var _a, _b; + 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; + }; + /** @internal */ + KHR_materials_variants.prototype.onLoading = function () { + var extensions = this._loader.gltf.extensions; + if (extensions && extensions[this.name]) { + var extension = extensions[this.name]; + this._variants = extension.variants; + } + }; + /** + * @internal + */ + KHR_materials_variants.prototype._loadMeshPrimitiveAsync = function (context, name, node, mesh, primitive, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, primitive, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader._loadMeshPrimitiveAsync(context, name, node, mesh, primitive, function (babylonMesh) { + assign(babylonMesh); + if (babylonMesh instanceof babylonjs_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__.Mesh) { + var babylonDrawMode = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader._GetDrawMode(context, primitive.mode); + var root_1 = _this._loader.rootBabylonMesh; + var metadata = root_1 ? (root_1._internalMetadata = root_1._internalMetadata || {}) : {}; + var gltf = (metadata.gltf = metadata.gltf || {}); + var extensionMetadata_1 = (gltf[NAME] = gltf[NAME] || { lastSelected: null, original: [], variants: {} }); + // Store the original material. + extensionMetadata_1.original.push({ mesh: babylonMesh, material: babylonMesh.material }); + var _loop_1 = function (mappingIndex) { + var mapping = extension.mappings[mappingIndex]; + var material = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(extensionContext, "/mappings/").concat(mappingIndex, "/material"), _this._loader.gltf.materials, mapping.material); + promises.push(_this._loader._loadMaterialAsync("#/materials/".concat(mapping.material), material, babylonMesh, babylonDrawMode, function (babylonMaterial) { + var _loop_2 = function (mappingVariantIndex) { + var variantIndex = mapping.variants[mappingVariantIndex]; + var variant = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("/extensions/".concat(NAME, "/variants/").concat(variantIndex), _this._variants, variantIndex); + extensionMetadata_1.variants[variant.name] = extensionMetadata_1.variants[variant.name] || []; + extensionMetadata_1.variants[variant.name].push({ + mesh: babylonMesh, + material: babylonMaterial, + }); + // Replace the target when original mesh is cloned + babylonMesh.onClonedObservable.add(function (newOne) { + var newMesh = newOne; + var metadata = null; + var newRoot = newMesh; + // Find root to get medata + do { + newRoot = newRoot.parent; + if (!newRoot) { + return; + } + metadata = KHR_materials_variants._GetExtensionMetadata(newRoot); + } while (metadata === null); + // Need to clone the metadata on the root (first time only) + if (root_1 && metadata === KHR_materials_variants._GetExtensionMetadata(root_1)) { + // Copy main metadata + newRoot._internalMetadata = {}; + for (var key in root_1._internalMetadata) { + newRoot._internalMetadata[key] = root_1._internalMetadata[key]; + } + // Copy the gltf metadata + newRoot._internalMetadata.gltf = []; + for (var key in root_1._internalMetadata.gltf) { + newRoot._internalMetadata.gltf[key] = root_1._internalMetadata.gltf[key]; + } + // Duplicate the extension specific metadata + newRoot._internalMetadata.gltf[NAME] = { lastSelected: null, original: [], variants: {} }; + for (var _i = 0, _a = metadata.original; _i < _a.length; _i++) { + var original = _a[_i]; + newRoot._internalMetadata.gltf[NAME].original.push({ + mesh: original.mesh, + material: original.material, + }); + } + for (var key in metadata.variants) { + if (Object.prototype.hasOwnProperty.call(metadata.variants, key)) { + newRoot._internalMetadata.gltf[NAME].variants[key] = []; + for (var _b = 0, _c = metadata.variants[key]; _b < _c.length; _b++) { + var variantEntry = _c[_b]; + newRoot._internalMetadata.gltf[NAME].variants[key].push({ + mesh: variantEntry.mesh, + material: variantEntry.material, + }); + } + } + } + metadata = newRoot._internalMetadata.gltf[NAME]; + } + // Relocate + for (var _d = 0, _e = metadata.original; _d < _e.length; _d++) { + var target = _e[_d]; + if (target.mesh === babylonMesh) { + target.mesh = newMesh; + } + } + for (var _f = 0, _g = metadata.variants[variant.name]; _f < _g.length; _f++) { + var target = _g[_f]; + if (target.mesh === babylonMesh) { + target.mesh = newMesh; + } + } + }); + }; + for (var mappingVariantIndex = 0; mappingVariantIndex < mapping.variants.length; ++mappingVariantIndex) { + _loop_2(mappingVariantIndex); + } + })); + }; + // For each mapping, look at the variants and make a new entry for them. + for (var mappingIndex = 0; mappingIndex < extension.mappings.length; ++mappingIndex) { + _loop_1(mappingIndex); + } + } + })); + return Promise.all(promises).then(function (_a) { + var babylonMesh = _a[0]; + return babylonMesh; + }); + }); + }; + return KHR_materials_variants; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_variants(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_volume.ts": +/*!****************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_volume.ts ***! + \****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_materials_volume: () => (/* binding */ KHR_materials_volume) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_materials_volume"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_materials_volume/README.md) + * @since 5.0.0 + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_materials_volume = /** @class */ (function () { + /** + * @internal + */ + function KHR_materials_volume(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 173; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + if (this.enabled) { + // We need to disable instance usage because the attenuation factor depends on the node scale of each individual mesh + this._loader._disableInstancedMesh++; + } + } + /** @internal */ + KHR_materials_volume.prototype.dispose = function () { + if (this.enabled) { + this._loader._disableInstancedMesh--; + } + this._loader = null; + }; + /** + * @internal + */ + KHR_materials_volume.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial)); + promises.push(_this._loadVolumePropertiesAsync(extensionContext, material, babylonMaterial, extension)); + return Promise.all(promises).then(function () { }); + }); + }; + KHR_materials_volume.prototype._loadVolumePropertiesAsync = function (context, material, babylonMaterial, extension) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + // If transparency isn't enabled already, this extension shouldn't do anything. + // i.e. it requires either the KHR_materials_transmission or KHR_materials_translucency extensions. + if ((!babylonMaterial.subSurface.isRefractionEnabled && !babylonMaterial.subSurface.isTranslucencyEnabled) || !extension.thicknessFactor) { + return Promise.resolve(); + } + // IOR in this extension only affects interior. + babylonMaterial.subSurface.volumeIndexOfRefraction = babylonMaterial.indexOfRefraction; + var attenuationDistance = extension.attenuationDistance !== undefined ? extension.attenuationDistance : Number.MAX_VALUE; + babylonMaterial.subSurface.tintColorAtDistance = attenuationDistance; + if (extension.attenuationColor !== undefined && extension.attenuationColor.length == 3) { + babylonMaterial.subSurface.tintColor.copyFromFloats(extension.attenuationColor[0], extension.attenuationColor[1], extension.attenuationColor[2]); + } + babylonMaterial.subSurface.minimumThickness = 0.0; + babylonMaterial.subSurface.maximumThickness = extension.thicknessFactor; + babylonMaterial.subSurface.useThicknessAsDepth = true; + if (extension.thicknessTexture) { + extension.thicknessTexture.nonColorData = true; + return this._loader.loadTextureInfoAsync("".concat(context, "/thicknessTexture"), extension.thicknessTexture).then(function (texture) { + babylonMaterial.subSurface.thicknessTexture = texture; + babylonMaterial.subSurface.useGltfStyleTextures = true; + }); + } + else { + return Promise.resolve(); + } + }; + return KHR_materials_volume; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_materials_volume(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_mesh_quantization.ts": +/*!*****************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_mesh_quantization.ts ***! + \*****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_mesh_quantization: () => (/* binding */ KHR_mesh_quantization) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "KHR_mesh_quantization"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_mesh_quantization/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_mesh_quantization = /** @class */ (function () { + /** + * @internal + */ + function KHR_mesh_quantization(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this.enabled = loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_mesh_quantization.prototype.dispose = function () { }; + return KHR_mesh_quantization; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_mesh_quantization(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_basisu.ts": +/*!**************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_basisu.ts ***! + \**************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_texture_basisu: () => (/* binding */ KHR_texture_basisu) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "KHR_texture_basisu"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_basisu/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_texture_basisu = /** @class */ (function () { + /** + * @internal + */ + function KHR_texture_basisu(loader) { + /** The name of this extension. */ + this.name = NAME; + this._loader = loader; + this.enabled = loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_texture_basisu.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_texture_basisu.prototype._loadTextureAsync = function (context, texture, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.LoadExtensionAsync(context, texture, this.name, function (extensionContext, extension) { + var sampler = texture.sampler == undefined ? _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.DefaultSampler : _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(context, "/sampler"), _this._loader.gltf.samplers, texture.sampler); + var image = _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem.Get("".concat(extensionContext, "/source"), _this._loader.gltf.images, extension.source); + return _this._loader._createTextureAsync(context, sampler, image, function (babylonTexture) { + assign(babylonTexture); + }, texture._textureInfo.nonColorData ? { useRGBAIfASTCBC7NotAvailableWhenUASTC: true } : undefined, !texture._textureInfo.nonColorData); + }); + }; + return KHR_texture_basisu; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_texture_basisu(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_transform.ts": +/*!*****************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_transform.ts ***! + \*****************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_texture_transform: () => (/* binding */ KHR_texture_transform) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/Textures/texture */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "KHR_texture_transform"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_texture_transform/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_texture_transform = /** @class */ (function () { + /** + * @internal + */ + function KHR_texture_transform(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_texture_transform.prototype.dispose = function () { + this._loader = null; + }; + /** + * @internal + */ + KHR_texture_transform.prototype.loadTextureInfoAsync = function (context, textureInfo, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, textureInfo, this.name, function (extensionContext, extension) { + return _this._loader.loadTextureInfoAsync(context, textureInfo, function (babylonTexture) { + if (!(babylonTexture instanceof babylonjs_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__.Texture)) { + throw new Error("".concat(extensionContext, ": Texture type not supported")); + } + if (extension.offset) { + babylonTexture.uOffset = extension.offset[0]; + babylonTexture.vOffset = extension.offset[1]; + } + // Always rotate around the origin. + babylonTexture.uRotationCenter = 0; + babylonTexture.vRotationCenter = 0; + if (extension.rotation) { + babylonTexture.wAng = -extension.rotation; + } + if (extension.scale) { + babylonTexture.uScale = extension.scale[0]; + babylonTexture.vScale = extension.scale[1]; + } + if (extension.texCoord != undefined) { + babylonTexture.coordinatesIndex = extension.texCoord; + } + assign(babylonTexture); + }); + }); + }; + return KHR_texture_transform; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_texture_transform(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_xmp_json_ld.ts": +/*!***********************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/KHR_xmp_json_ld.ts ***! + \***********************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ KHR_xmp_json_ld: () => (/* binding */ KHR_xmp_json_ld) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + +var NAME = "KHR_xmp_json_ld"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_xmp_json_ld/README.md) + * @since 5.0.0 + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var KHR_xmp_json_ld = /** @class */ (function () { + /** + * @internal + */ + function KHR_xmp_json_ld(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 100; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + KHR_xmp_json_ld.prototype.dispose = function () { + this._loader = null; + }; + /** + * Called after the loader state changes to LOADING. + */ + KHR_xmp_json_ld.prototype.onLoading = function () { + var _a, _b, _c; + if (this._loader.rootBabylonMesh === null) { + return; + } + var xmp_gltf = (_a = this._loader.gltf.extensions) === null || _a === void 0 ? void 0 : _a.KHR_xmp_json_ld; + var 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; + if (xmp_gltf && xmp_node) { + var packet = +xmp_node.packet; + if (xmp_gltf.packets && packet < xmp_gltf.packets.length) { + this._loader.rootBabylonMesh.metadata = this._loader.rootBabylonMesh.metadata || {}; + this._loader.rootBabylonMesh.metadata.xmp = xmp_gltf.packets[packet]; + } + } + }; + return KHR_xmp_json_ld; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new KHR_xmp_json_ld(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts": +/*!**************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts ***! + \**************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ MSFT_audio_emitter: () => (/* binding */ MSFT_audio_emitter) +/* harmony export */ }); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Audio/weightedsound */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + + + + +var NAME = "MSFT_audio_emitter"; +/** + * [Specification](https://github.com/najadojo/glTF/blob/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter/README.md) + * !!! Experimental Extension Subject to Changes !!! + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var MSFT_audio_emitter = /** @class */ (function () { + /** + * @internal + */ + function MSFT_audio_emitter(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + MSFT_audio_emitter.prototype.dispose = function () { + this._loader = null; + this._clips = null; + this._emitters = null; + }; + /** @internal */ + MSFT_audio_emitter.prototype.onLoading = function () { + var extensions = this._loader.gltf.extensions; + if (extensions && extensions[this.name]) { + var extension = extensions[this.name]; + this._clips = extension.clips; + this._emitters = extension.emitters; + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(this._clips); + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(this._emitters); + } + }; + /** + * @internal + */ + MSFT_audio_emitter.prototype.loadSceneAsync = function (context, scene) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, scene, this.name, function (extensionContext, extension) { + var promises = new Array(); + promises.push(_this._loader.loadSceneAsync(context, scene)); + for (var _i = 0, _a = extension.emitters; _i < _a.length; _i++) { + var emitterIndex = _a[_i]; + var emitter = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/emitters"), _this._emitters, emitterIndex); + if (emitter.refDistance != undefined || + emitter.maxDistance != undefined || + emitter.rolloffFactor != undefined || + emitter.distanceModel != undefined || + emitter.innerAngle != undefined || + emitter.outerAngle != undefined) { + throw new Error("".concat(extensionContext, ": Direction or Distance properties are not allowed on emitters attached to a scene")); + } + promises.push(_this._loadEmitterAsync("".concat(extensionContext, "/emitters/").concat(emitter.index), emitter)); + } + return Promise.all(promises).then(function () { }); + }); + }; + /** + * @internal + */ + MSFT_audio_emitter.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) { + var promises = new Array(); + return _this._loader + .loadNodeAsync(extensionContext, node, function (babylonMesh) { + var _loop_1 = function (emitterIndex) { + var emitter = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(extensionContext, "/emitters"), _this._emitters, emitterIndex); + promises.push(_this._loadEmitterAsync("".concat(extensionContext, "/emitters/").concat(emitter.index), emitter).then(function () { + for (var _i = 0, _a = emitter._babylonSounds; _i < _a.length; _i++) { + var sound = _a[_i]; + sound.attachToMesh(babylonMesh); + if (emitter.innerAngle != undefined || emitter.outerAngle != undefined) { + sound.setLocalDirectionToMesh(babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Vector3.Forward()); + sound.setDirectionalCone(2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.innerAngle == undefined ? Math.PI : emitter.innerAngle), 2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.outerAngle == undefined ? Math.PI : emitter.outerAngle), 0); + } + } + })); + }; + for (var _i = 0, _a = extension.emitters; _i < _a.length; _i++) { + var emitterIndex = _a[_i]; + _loop_1(emitterIndex); + } + assign(babylonMesh); + }) + .then(function (babylonMesh) { + return Promise.all(promises).then(function () { + return babylonMesh; + }); + }); + }); + }; + /** + * @internal + */ + MSFT_audio_emitter.prototype.loadAnimationAsync = function (context, animation) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, animation, this.name, function (extensionContext, extension) { + return _this._loader.loadAnimationAsync(context, animation).then(function (babylonAnimationGroup) { + var promises = new Array(); + _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Assign(extension.events); + for (var _i = 0, _a = extension.events; _i < _a.length; _i++) { + var event_1 = _a[_i]; + promises.push(_this._loadAnimationEventAsync("".concat(extensionContext, "/events/").concat(event_1.index), context, animation, event_1, babylonAnimationGroup)); + } + return Promise.all(promises).then(function () { + return babylonAnimationGroup; + }); + }); + }); + }; + MSFT_audio_emitter.prototype._loadClipAsync = function (context, clip) { + if (clip._objectURL) { + return clip._objectURL; + } + var promise; + if (clip.uri) { + promise = this._loader.loadUriAsync(context, clip, clip.uri); + } + else { + var bufferView = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(context, "/bufferView"), this._loader.gltf.bufferViews, clip.bufferView); + promise = this._loader.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView); + } + clip._objectURL = promise.then(function (data) { + return URL.createObjectURL(new Blob([data], { type: clip.mimeType })); + }); + return clip._objectURL; + }; + MSFT_audio_emitter.prototype._loadEmitterAsync = function (context, emitter) { + var _this = this; + emitter._babylonSounds = emitter._babylonSounds || []; + if (!emitter._babylonData) { + var clipPromises = new Array(); + var name_1 = emitter.name || "emitter".concat(emitter.index); + var options_1 = { + loop: false, + autoplay: false, + volume: emitter.volume == undefined ? 1 : emitter.volume, + }; + var _loop_2 = function (i) { + var clipContext = "/extensions/".concat(this_1.name, "/clips"); + var clip = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get(clipContext, this_1._clips, emitter.clips[i].clip); + clipPromises.push(this_1._loadClipAsync("".concat(clipContext, "/").concat(emitter.clips[i].clip), clip).then(function (objectURL) { + var sound = (emitter._babylonSounds[i] = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Sound(name_1, objectURL, _this._loader.babylonScene, null, options_1)); + sound.refDistance = emitter.refDistance || 1; + sound.maxDistance = emitter.maxDistance || 256; + sound.rolloffFactor = emitter.rolloffFactor || 1; + sound.distanceModel = emitter.distanceModel || "exponential"; + })); + }; + var this_1 = this; + for (var i = 0; i < emitter.clips.length; i++) { + _loop_2(i); + } + var promise = Promise.all(clipPromises).then(function () { + var weights = emitter.clips.map(function (clip) { + return clip.weight || 1; + }); + var weightedSound = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.WeightedSound(emitter.loop || false, emitter._babylonSounds, weights); + if (emitter.innerAngle) { + weightedSound.directionalConeInnerAngle = 2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.innerAngle); + } + if (emitter.outerAngle) { + weightedSound.directionalConeOuterAngle = 2 * babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.Tools.ToDegrees(emitter.outerAngle); + } + if (emitter.volume) { + weightedSound.volume = emitter.volume; + } + emitter._babylonData.sound = weightedSound; + }); + emitter._babylonData = { + loaded: promise, + }; + } + return emitter._babylonData.loaded; + }; + MSFT_audio_emitter.prototype._getEventAction = function (context, sound, action, time, startOffset) { + switch (action) { + case "play" /* IMSFTAudioEmitter_AnimationEventAction.play */: { + return function (currentFrame) { + var frameOffset = (startOffset || 0) + (currentFrame - time); + sound.play(frameOffset); + }; + } + case "stop" /* IMSFTAudioEmitter_AnimationEventAction.stop */: { + return function () { + sound.stop(); + }; + } + case "pause" /* IMSFTAudioEmitter_AnimationEventAction.pause */: { + return function () { + sound.pause(); + }; + } + default: { + throw new Error("".concat(context, ": Unsupported action ").concat(action)); + } + } + }; + MSFT_audio_emitter.prototype._loadAnimationEventAsync = function (context, animationContext, animation, event, babylonAnimationGroup) { + var _this = this; + if (babylonAnimationGroup.targetedAnimations.length == 0) { + return Promise.resolve(); + } + var babylonAnimation = babylonAnimationGroup.targetedAnimations[0]; + var emitterIndex = event.emitter; + var emitter = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("/extensions/".concat(this.name, "/emitters"), this._emitters, emitterIndex); + return this._loadEmitterAsync(context, emitter).then(function () { + var sound = emitter._babylonData.sound; + if (sound) { + var babylonAnimationEvent = new babylonjs_Maths_math_vector__WEBPACK_IMPORTED_MODULE_0__.AnimationEvent(event.time, _this._getEventAction(context, sound, event.action, event.time, event.startOffset)); + babylonAnimation.animation.addEvent(babylonAnimationEvent); + // Make sure all started audio stops when this animation is terminated. + babylonAnimationGroup.onAnimationGroupEndObservable.add(function () { + sound.stop(); + }); + babylonAnimationGroup.onAnimationGroupPauseObservable.add(function () { + sound.pause(); + }); + } + }); + }; + return MSFT_audio_emitter; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_audio_emitter(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts": +/*!****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ MSFT_lod: () => (/* binding */ MSFT_lod) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/deferred */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + + +var NAME = "MSFT_lod"; +/** + * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Vendor/MSFT_lod/README.md) + */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var MSFT_lod = /** @class */ (function () { + /** + * @internal + */ + function MSFT_lod(loader) { + /** + * The name of this extension. + */ + this.name = NAME; + /** + * Defines a number that determines the order the extensions are applied. + */ + this.order = 100; + /** + * Maximum number of LODs to load, starting from the lowest LOD. + */ + this.maxLODsToLoad = 10; + /** + * Observable raised when all node LODs of one level are loaded. + * The event data is the index of the loaded LOD starting from zero. + * Dispose the loader to cancel the loading of the next level of LODs. + */ + this.onNodeLODsLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when all material LODs of one level are loaded. + * The event data is the index of the loaded LOD starting from zero. + * Dispose the loader to cancel the loading of the next level of LODs. + */ + this.onMaterialLODsLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + this._bufferLODs = new Array(); + this._nodeIndexLOD = null; + this._nodeSignalLODs = new Array(); + this._nodePromiseLODs = new Array(); + this._nodeBufferLODs = new Array(); + this._materialIndexLOD = null; + this._materialSignalLODs = new Array(); + this._materialPromiseLODs = new Array(); + this._materialBufferLODs = new Array(); + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + MSFT_lod.prototype.dispose = function () { + this._loader = null; + this._nodeIndexLOD = null; + this._nodeSignalLODs.length = 0; + this._nodePromiseLODs.length = 0; + this._nodeBufferLODs.length = 0; + this._materialIndexLOD = null; + this._materialSignalLODs.length = 0; + this._materialPromiseLODs.length = 0; + this._materialBufferLODs.length = 0; + this.onMaterialLODsLoadedObservable.clear(); + this.onNodeLODsLoadedObservable.clear(); + }; + /** @internal */ + MSFT_lod.prototype.onReady = function () { + var _this = this; + var _loop_1 = function (indexLOD) { + var promise = Promise.all(this_1._nodePromiseLODs[indexLOD]).then(function () { + if (indexLOD !== 0) { + _this._loader.endPerformanceCounter("Node LOD ".concat(indexLOD)); + _this._loader.log("Loaded node LOD ".concat(indexLOD)); + } + _this.onNodeLODsLoadedObservable.notifyObservers(indexLOD); + if (indexLOD !== _this._nodePromiseLODs.length - 1) { + _this._loader.startPerformanceCounter("Node LOD ".concat(indexLOD + 1)); + _this._loadBufferLOD(_this._nodeBufferLODs, indexLOD + 1); + if (_this._nodeSignalLODs[indexLOD]) { + _this._nodeSignalLODs[indexLOD].resolve(); + } + } + }); + this_1._loader._completePromises.push(promise); + }; + var this_1 = this; + for (var indexLOD = 0; indexLOD < this._nodePromiseLODs.length; indexLOD++) { + _loop_1(indexLOD); + } + var _loop_2 = function (indexLOD) { + var promise = Promise.all(this_2._materialPromiseLODs[indexLOD]).then(function () { + if (indexLOD !== 0) { + _this._loader.endPerformanceCounter("Material LOD ".concat(indexLOD)); + _this._loader.log("Loaded material LOD ".concat(indexLOD)); + } + _this.onMaterialLODsLoadedObservable.notifyObservers(indexLOD); + if (indexLOD !== _this._materialPromiseLODs.length - 1) { + _this._loader.startPerformanceCounter("Material LOD ".concat(indexLOD + 1)); + _this._loadBufferLOD(_this._materialBufferLODs, indexLOD + 1); + if (_this._materialSignalLODs[indexLOD]) { + _this._materialSignalLODs[indexLOD].resolve(); + } + } + }); + this_2._loader._completePromises.push(promise); + }; + var this_2 = this; + for (var indexLOD = 0; indexLOD < this._materialPromiseLODs.length; indexLOD++) { + _loop_2(indexLOD); + } + }; + /** + * @internal + */ + MSFT_lod.prototype.loadSceneAsync = function (context, scene) { + var promise = this._loader.loadSceneAsync(context, scene); + this._loadBufferLOD(this._bufferLODs, 0); + return promise; + }; + /** + * @internal + */ + MSFT_lod.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, node, this.name, function (extensionContext, extension) { + var firstPromise; + var nodeLODs = _this._getLODs(extensionContext, node, _this._loader.gltf.nodes, extension.ids); + _this._loader.logOpen("".concat(extensionContext)); + var _loop_3 = function (indexLOD) { + var nodeLOD = nodeLODs[indexLOD]; + if (indexLOD !== 0) { + _this._nodeIndexLOD = indexLOD; + _this._nodeSignalLODs[indexLOD] = _this._nodeSignalLODs[indexLOD] || new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred(); + } + var assignWrap = function (babylonTransformNode) { + assign(babylonTransformNode); + babylonTransformNode.setEnabled(false); + }; + var promise = _this._loader.loadNodeAsync("/nodes/".concat(nodeLOD.index), nodeLOD, assignWrap).then(function (babylonMesh) { + if (indexLOD !== 0) { + // TODO: should not rely on _babylonTransformNode + var previousNodeLOD = nodeLODs[indexLOD - 1]; + if (previousNodeLOD._babylonTransformNode) { + _this._disposeTransformNode(previousNodeLOD._babylonTransformNode); + delete previousNodeLOD._babylonTransformNode; + } + } + babylonMesh.setEnabled(true); + return babylonMesh; + }); + _this._nodePromiseLODs[indexLOD] = _this._nodePromiseLODs[indexLOD] || []; + if (indexLOD === 0) { + firstPromise = promise; + } + else { + _this._nodeIndexLOD = null; + _this._nodePromiseLODs[indexLOD].push(promise); + } + }; + for (var indexLOD = 0; indexLOD < nodeLODs.length; indexLOD++) { + _loop_3(indexLOD); + } + _this._loader.logClose(); + return firstPromise; + }); + }; + /** + * @internal + */ + MSFT_lod.prototype._loadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) { + var _this = this; + // Don't load material LODs if already loading a node LOD. + if (this._nodeIndexLOD) { + return null; + } + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtensionAsync(context, material, this.name, function (extensionContext, extension) { + var firstPromise; + var materialLODs = _this._getLODs(extensionContext, material, _this._loader.gltf.materials, extension.ids); + _this._loader.logOpen("".concat(extensionContext)); + var _loop_4 = function (indexLOD) { + var materialLOD = materialLODs[indexLOD]; + if (indexLOD !== 0) { + _this._materialIndexLOD = indexLOD; + } + var promise = _this._loader + ._loadMaterialAsync("/materials/".concat(materialLOD.index), materialLOD, babylonMesh, babylonDrawMode, function (babylonMaterial) { + if (indexLOD === 0) { + assign(babylonMaterial); + } + }) + .then(function (babylonMaterial) { + if (indexLOD !== 0) { + assign(babylonMaterial); + // TODO: should not rely on _data + var previousDataLOD = materialLODs[indexLOD - 1]._data; + if (previousDataLOD[babylonDrawMode]) { + _this._disposeMaterials([previousDataLOD[babylonDrawMode].babylonMaterial]); + delete previousDataLOD[babylonDrawMode]; + } + } + return babylonMaterial; + }); + _this._materialPromiseLODs[indexLOD] = _this._materialPromiseLODs[indexLOD] || []; + if (indexLOD === 0) { + firstPromise = promise; + } + else { + _this._materialIndexLOD = null; + _this._materialPromiseLODs[indexLOD].push(promise); + } + }; + for (var indexLOD = 0; indexLOD < materialLODs.length; indexLOD++) { + _loop_4(indexLOD); + } + _this._loader.logClose(); + return firstPromise; + }); + }; + /** + * @internal + */ + MSFT_lod.prototype._loadUriAsync = function (context, property, uri) { + var _this = this; + // Defer the loading of uris if loading a node or material LOD. + if (this._nodeIndexLOD !== null) { + this._loader.log("deferred"); + var previousIndexLOD = this._nodeIndexLOD - 1; + this._nodeSignalLODs[previousIndexLOD] = this._nodeSignalLODs[previousIndexLOD] || new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred(); + return this._nodeSignalLODs[this._nodeIndexLOD - 1].promise.then(function () { + return _this._loader.loadUriAsync(context, property, uri); + }); + } + else if (this._materialIndexLOD !== null) { + this._loader.log("deferred"); + var previousIndexLOD = this._materialIndexLOD - 1; + this._materialSignalLODs[previousIndexLOD] = this._materialSignalLODs[previousIndexLOD] || new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred(); + return this._materialSignalLODs[previousIndexLOD].promise.then(function () { + return _this._loader.loadUriAsync(context, property, uri); + }); + } + return null; + }; + /** + * @internal + */ + MSFT_lod.prototype.loadBufferAsync = function (context, buffer, byteOffset, byteLength) { + if (this._loader.parent.useRangeRequests && !buffer.uri) { + if (!this._loader.bin) { + throw new Error("".concat(context, ": Uri is missing or the binary glTF is missing its binary chunk")); + } + var loadAsync = function (bufferLODs, indexLOD) { + var start = byteOffset; + var end = start + byteLength - 1; + var bufferLOD = bufferLODs[indexLOD]; + if (bufferLOD) { + bufferLOD.start = Math.min(bufferLOD.start, start); + bufferLOD.end = Math.max(bufferLOD.end, end); + } + else { + bufferLOD = { start: start, end: end, loaded: new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Deferred() }; + bufferLODs[indexLOD] = bufferLOD; + } + return bufferLOD.loaded.promise.then(function (data) { + return new Uint8Array(data.buffer, data.byteOffset + byteOffset - bufferLOD.start, byteLength); + }); + }; + this._loader.log("deferred"); + if (this._nodeIndexLOD !== null) { + return loadAsync(this._nodeBufferLODs, this._nodeIndexLOD); + } + else if (this._materialIndexLOD !== null) { + return loadAsync(this._materialBufferLODs, this._materialIndexLOD); + } + else { + return loadAsync(this._bufferLODs, 0); + } + } + return null; + }; + MSFT_lod.prototype._loadBufferLOD = function (bufferLODs, indexLOD) { + var bufferLOD = bufferLODs[indexLOD]; + if (bufferLOD) { + this._loader.log("Loading buffer range [".concat(bufferLOD.start, "-").concat(bufferLOD.end, "]")); + this._loader.bin.readAsync(bufferLOD.start, bufferLOD.end - bufferLOD.start + 1).then(function (data) { + bufferLOD.loaded.resolve(data); + }, function (error) { + bufferLOD.loaded.reject(error); + }); + } + }; + /** + * Gets an array of LOD properties from lowest to highest. + * @param context + * @param property + * @param array + * @param ids + */ + MSFT_lod.prototype._getLODs = function (context, property, array, ids) { + if (this.maxLODsToLoad <= 0) { + throw new Error("maxLODsToLoad must be greater than zero"); + } + var properties = new Array(); + for (var i = ids.length - 1; i >= 0; i--) { + properties.push(_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(context, "/ids/").concat(ids[i]), array, ids[i])); + if (properties.length === this.maxLODsToLoad) { + return properties; + } + } + properties.push(property); + return properties; + }; + MSFT_lod.prototype._disposeTransformNode = function (babylonTransformNode) { + var _this = this; + var babylonMaterials = new Array(); + var babylonMaterial = babylonTransformNode.material; + if (babylonMaterial) { + babylonMaterials.push(babylonMaterial); + } + for (var _i = 0, _a = babylonTransformNode.getChildMeshes(); _i < _a.length; _i++) { + var babylonMesh = _a[_i]; + if (babylonMesh.material) { + babylonMaterials.push(babylonMesh.material); + } + } + babylonTransformNode.dispose(); + var babylonMaterialsToDispose = babylonMaterials.filter(function (babylonMaterial) { return _this._loader.babylonScene.meshes.every(function (mesh) { return mesh.material != babylonMaterial; }); }); + this._disposeMaterials(babylonMaterialsToDispose); + }; + MSFT_lod.prototype._disposeMaterials = function (babylonMaterials) { + var babylonTextures = {}; + for (var _i = 0, babylonMaterials_1 = babylonMaterials; _i < babylonMaterials_1.length; _i++) { + var babylonMaterial = babylonMaterials_1[_i]; + for (var _a = 0, _b = babylonMaterial.getActiveTextures(); _a < _b.length; _a++) { + var babylonTexture = _b[_a]; + babylonTextures[babylonTexture.uniqueId] = babylonTexture; + } + babylonMaterial.dispose(); + } + for (var uniqueId in babylonTextures) { + for (var _c = 0, _d = this._loader.babylonScene.materials; _c < _d.length; _c++) { + var babylonMaterial = _d[_c]; + if (babylonMaterial.hasTexture(babylonTextures[uniqueId])) { + delete babylonTextures[uniqueId]; + } + } + } + for (var uniqueId in babylonTextures) { + babylonTextures[uniqueId].dispose(); + } + }; + return MSFT_lod; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_lod(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.ts": +/*!**************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.ts ***! + \**************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ MSFT_minecraftMesh: () => (/* binding */ MSFT_minecraftMesh) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "MSFT_minecraftMesh"; +/** @internal */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var MSFT_minecraftMesh = /** @class */ (function () { + /** @internal */ + function MSFT_minecraftMesh(loader) { + /** @internal */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + MSFT_minecraftMesh.prototype.dispose = function () { + this._loader = null; + }; + /** @internal */ + MSFT_minecraftMesh.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtraAsync(context, material, this.name, function (extraContext, extra) { + if (extra) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(extraContext, ": Material type not supported")); + } + var promise = _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial); + if (babylonMaterial.needAlphaBlending()) { + babylonMaterial.forceDepthWrite = true; + babylonMaterial.separateCullingPass = true; + } + babylonMaterial.backFaceCulling = babylonMaterial.forceDepthWrite; + babylonMaterial.twoSidedLighting = true; + return promise; + } + return null; + }); + }; + return MSFT_minecraftMesh; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_minecraftMesh(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts": +/*!************************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts ***! + \************************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ MSFT_sRGBFactors: () => (/* binding */ MSFT_sRGBFactors) +/* harmony export */ }); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Materials/PBR/pbrMaterial */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); + + +var NAME = "MSFT_sRGBFactors"; +/** @internal */ +// eslint-disable-next-line @typescript-eslint/naming-convention +var MSFT_sRGBFactors = /** @class */ (function () { + /** @internal */ + function MSFT_sRGBFactors(loader) { + /** @internal */ + this.name = NAME; + this._loader = loader; + this.enabled = this._loader.isExtensionUsed(NAME); + } + /** @internal */ + MSFT_sRGBFactors.prototype.dispose = function () { + this._loader = null; + }; + /** @internal */ + MSFT_sRGBFactors.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var _this = this; + return _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.LoadExtraAsync(context, material, this.name, function (extraContext, extra) { + if (extra) { + if (!(babylonMaterial instanceof babylonjs_Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(extraContext, ": Material type not supported")); + } + var promise = _this._loader.loadMaterialPropertiesAsync(context, material, babylonMaterial); + var useExactSrgbConversions = babylonMaterial.getScene().getEngine().useExactSrgbConversions; + if (!babylonMaterial.albedoTexture) { + babylonMaterial.albedoColor.toLinearSpaceToRef(babylonMaterial.albedoColor, useExactSrgbConversions); + } + if (!babylonMaterial.reflectivityTexture) { + babylonMaterial.reflectivityColor.toLinearSpaceToRef(babylonMaterial.reflectivityColor, useExactSrgbConversions); + } + return promise; + } + return null; + }); + }; + return MSFT_sRGBFactors; +}()); + +_glTFLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoader.RegisterExtension(NAME, function (loader) { return new MSFT_sRGBFactors(loader); }); + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/Extensions/index.ts": +/*!*************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/Extensions/index.ts ***! + \*************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ EXT_lights_image_based: () => (/* reexport safe */ _EXT_lights_image_based__WEBPACK_IMPORTED_MODULE_0__.EXT_lights_image_based), +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* reexport safe */ _EXT_mesh_gpu_instancing__WEBPACK_IMPORTED_MODULE_1__.EXT_mesh_gpu_instancing), +/* harmony export */ EXT_meshopt_compression: () => (/* reexport safe */ _EXT_meshopt_compression__WEBPACK_IMPORTED_MODULE_2__.EXT_meshopt_compression), +/* harmony export */ EXT_texture_webp: () => (/* reexport safe */ _EXT_texture_webp__WEBPACK_IMPORTED_MODULE_3__.EXT_texture_webp), +/* harmony export */ ExtrasAsMetadata: () => (/* reexport safe */ _ExtrasAsMetadata__WEBPACK_IMPORTED_MODULE_28__.ExtrasAsMetadata), +/* harmony export */ KHR_animation_pointer: () => (/* reexport safe */ _KHR_animation_pointer__WEBPACK_IMPORTED_MODULE_23__.KHR_animation_pointer), +/* harmony export */ KHR_draco_mesh_compression: () => (/* reexport safe */ _KHR_draco_mesh_compression__WEBPACK_IMPORTED_MODULE_4__.KHR_draco_mesh_compression), +/* harmony export */ KHR_lights: () => (/* reexport safe */ _KHR_lights_punctual__WEBPACK_IMPORTED_MODULE_5__.KHR_lights), +/* harmony export */ KHR_materials_anisotropy: () => (/* reexport safe */ _KHR_materials_anisotropy__WEBPACK_IMPORTED_MODULE_10__.KHR_materials_anisotropy), +/* harmony export */ KHR_materials_clearcoat: () => (/* reexport safe */ _KHR_materials_clearcoat__WEBPACK_IMPORTED_MODULE_8__.KHR_materials_clearcoat), +/* harmony export */ KHR_materials_emissive_strength: () => (/* reexport safe */ _KHR_materials_emissive_strength__WEBPACK_IMPORTED_MODULE_11__.KHR_materials_emissive_strength), +/* harmony export */ KHR_materials_ior: () => (/* reexport safe */ _KHR_materials_ior__WEBPACK_IMPORTED_MODULE_14__.KHR_materials_ior), +/* harmony export */ KHR_materials_iridescence: () => (/* reexport safe */ _KHR_materials_iridescence__WEBPACK_IMPORTED_MODULE_9__.KHR_materials_iridescence), +/* harmony export */ KHR_materials_pbrSpecularGlossiness: () => (/* reexport safe */ _KHR_materials_pbrSpecularGlossiness__WEBPACK_IMPORTED_MODULE_6__.KHR_materials_pbrSpecularGlossiness), +/* harmony export */ KHR_materials_sheen: () => (/* reexport safe */ _KHR_materials_sheen__WEBPACK_IMPORTED_MODULE_12__.KHR_materials_sheen), +/* harmony export */ KHR_materials_specular: () => (/* reexport safe */ _KHR_materials_specular__WEBPACK_IMPORTED_MODULE_13__.KHR_materials_specular), +/* harmony export */ KHR_materials_translucency: () => (/* reexport safe */ _KHR_materials_translucency__WEBPACK_IMPORTED_MODULE_17__.KHR_materials_translucency), +/* harmony export */ KHR_materials_transmission: () => (/* reexport safe */ _KHR_materials_transmission__WEBPACK_IMPORTED_MODULE_16__.KHR_materials_transmission), +/* harmony export */ KHR_materials_unlit: () => (/* reexport safe */ _KHR_materials_unlit__WEBPACK_IMPORTED_MODULE_7__.KHR_materials_unlit), +/* harmony export */ KHR_materials_variants: () => (/* reexport safe */ _KHR_materials_variants__WEBPACK_IMPORTED_MODULE_15__.KHR_materials_variants), +/* harmony export */ KHR_materials_volume: () => (/* reexport safe */ _KHR_materials_volume__WEBPACK_IMPORTED_MODULE_18__.KHR_materials_volume), +/* harmony export */ KHR_mesh_quantization: () => (/* reexport safe */ _KHR_mesh_quantization__WEBPACK_IMPORTED_MODULE_19__.KHR_mesh_quantization), +/* harmony export */ KHR_texture_basisu: () => (/* reexport safe */ _KHR_texture_basisu__WEBPACK_IMPORTED_MODULE_20__.KHR_texture_basisu), +/* harmony export */ KHR_texture_transform: () => (/* reexport safe */ _KHR_texture_transform__WEBPACK_IMPORTED_MODULE_21__.KHR_texture_transform), +/* harmony export */ KHR_xmp_json_ld: () => (/* reexport safe */ _KHR_xmp_json_ld__WEBPACK_IMPORTED_MODULE_22__.KHR_xmp_json_ld), +/* harmony export */ MSFT_audio_emitter: () => (/* reexport safe */ _MSFT_audio_emitter__WEBPACK_IMPORTED_MODULE_24__.MSFT_audio_emitter), +/* harmony export */ MSFT_lod: () => (/* reexport safe */ _MSFT_lod__WEBPACK_IMPORTED_MODULE_25__.MSFT_lod), +/* harmony export */ MSFT_minecraftMesh: () => (/* reexport safe */ _MSFT_minecraftMesh__WEBPACK_IMPORTED_MODULE_26__.MSFT_minecraftMesh), +/* harmony export */ MSFT_sRGBFactors: () => (/* reexport safe */ _MSFT_sRGBFactors__WEBPACK_IMPORTED_MODULE_27__.MSFT_sRGBFactors) +/* harmony export */ }); +/* harmony import */ var _EXT_lights_image_based__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./EXT_lights_image_based */ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_lights_image_based.ts"); +/* harmony import */ var _EXT_mesh_gpu_instancing__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EXT_mesh_gpu_instancing */ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.ts"); +/* harmony import */ var _EXT_meshopt_compression__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./EXT_meshopt_compression */ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_meshopt_compression.ts"); +/* harmony import */ var _EXT_texture_webp__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./EXT_texture_webp */ "../../../dev/loaders/src/glTF/2.0/Extensions/EXT_texture_webp.ts"); +/* harmony import */ var _KHR_draco_mesh_compression__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./KHR_draco_mesh_compression */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts"); +/* harmony import */ var _KHR_lights_punctual__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./KHR_lights_punctual */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_lights_punctual.ts"); +/* harmony import */ var _KHR_materials_pbrSpecularGlossiness__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./KHR_materials_pbrSpecularGlossiness */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.ts"); +/* harmony import */ var _KHR_materials_unlit__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./KHR_materials_unlit */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_unlit.ts"); +/* harmony import */ var _KHR_materials_clearcoat__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./KHR_materials_clearcoat */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_clearcoat.ts"); +/* harmony import */ var _KHR_materials_iridescence__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./KHR_materials_iridescence */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_iridescence.ts"); +/* harmony import */ var _KHR_materials_anisotropy__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./KHR_materials_anisotropy */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_anisotropy.ts"); +/* harmony import */ var _KHR_materials_emissive_strength__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./KHR_materials_emissive_strength */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_emissive_strength.ts"); +/* harmony import */ var _KHR_materials_sheen__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./KHR_materials_sheen */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_sheen.ts"); +/* harmony import */ var _KHR_materials_specular__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./KHR_materials_specular */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_specular.ts"); +/* harmony import */ var _KHR_materials_ior__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./KHR_materials_ior */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_ior.ts"); +/* harmony import */ var _KHR_materials_variants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./KHR_materials_variants */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_variants.ts"); +/* harmony import */ var _KHR_materials_transmission__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./KHR_materials_transmission */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_transmission.ts"); +/* harmony import */ var _KHR_materials_translucency__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./KHR_materials_translucency */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_translucency.ts"); +/* harmony import */ var _KHR_materials_volume__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./KHR_materials_volume */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_materials_volume.ts"); +/* harmony import */ var _KHR_mesh_quantization__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./KHR_mesh_quantization */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_mesh_quantization.ts"); +/* harmony import */ var _KHR_texture_basisu__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./KHR_texture_basisu */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_basisu.ts"); +/* harmony import */ var _KHR_texture_transform__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./KHR_texture_transform */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_texture_transform.ts"); +/* harmony import */ var _KHR_xmp_json_ld__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./KHR_xmp_json_ld */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_xmp_json_ld.ts"); +/* harmony import */ var _KHR_animation_pointer__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./KHR_animation_pointer */ "../../../dev/loaders/src/glTF/2.0/Extensions/KHR_animation_pointer.ts"); +/* harmony import */ var _MSFT_audio_emitter__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./MSFT_audio_emitter */ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_audio_emitter.ts"); +/* harmony import */ var _MSFT_lod__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./MSFT_lod */ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_lod.ts"); +/* harmony import */ var _MSFT_minecraftMesh__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./MSFT_minecraftMesh */ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_minecraftMesh.ts"); +/* harmony import */ var _MSFT_sRGBFactors__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./MSFT_sRGBFactors */ "../../../dev/loaders/src/glTF/2.0/Extensions/MSFT_sRGBFactors.ts"); +/* harmony import */ var _ExtrasAsMetadata__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./ExtrasAsMetadata */ "../../../dev/loaders/src/glTF/2.0/Extensions/ExtrasAsMetadata.ts"); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts": +/*!*******************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/glTFLoader.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ ArrayItem: () => (/* binding */ ArrayItem), +/* harmony export */ GLTFLoader: () => (/* binding */ GLTFLoader) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Culling/boundingInfo */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFFileLoader */ "../../../dev/loaders/src/glTF/glTFFileLoader.ts"); +/* harmony import */ var _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderAnimation */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts"); + + + + + + + + + + + + + + + + + + + + + + + + +// https://stackoverflow.com/a/48218209 +function mergeDeep() { + var objects = []; + for (var _i = 0; _i < arguments.length; _i++) { + objects[_i] = arguments[_i]; + } + var isObject = function (obj) { return obj && typeof obj === "object"; }; + return objects.reduce(function (prev, obj) { + Object.keys(obj).forEach(function (key) { + var pVal = prev[key]; + var oVal = obj[key]; + if (Array.isArray(pVal) && Array.isArray(oVal)) { + prev[key] = pVal.concat.apply(pVal, oVal); + } + else if (isObject(pVal) && isObject(oVal)) { + prev[key] = mergeDeep(pVal, oVal); + } + else { + prev[key] = oVal; + } + }); + return prev; + }, {}); +} +/** + * Helper class for working with arrays when loading the glTF asset + */ +var ArrayItem = /** @class */ (function () { + function ArrayItem() { + } + /** + * Gets an item from the given array. + * @param context The context when loading the asset + * @param array The array to get the item from + * @param index The index to the array + * @returns The array item + */ + ArrayItem.Get = function (context, array, index) { + if (!array || index == undefined || !array[index]) { + throw new Error("".concat(context, ": Failed to find index (").concat(index, ")")); + } + return array[index]; + }; + /** + * Gets an item from the given array or returns null if not available. + * @param array The array to get the item from + * @param index The index to the array + * @returns The array item or null + */ + ArrayItem.TryGet = function (array, index) { + if (!array || index == undefined || !array[index]) { + return null; + } + return array[index]; + }; + /** + * Assign an `index` field to each item of the given array. + * @param array The array of items + */ + ArrayItem.Assign = function (array) { + if (array) { + for (var index = 0; index < array.length; index++) { + array[index].index = index; + } + } + }; + return ArrayItem; +}()); + +/** + * The glTF 2.0 loader + */ +var GLTFLoader = /** @class */ (function () { + /** + * @internal + */ + function GLTFLoader(parent) { + /** @internal */ + this._completePromises = new Array(); + /** @internal */ + this._assetContainer = null; + /** Storage */ + this._babylonLights = []; + /** @internal */ + this._disableInstancedMesh = 0; + this._extensions = new Array(); + this._disposed = false; + this._rootUrl = null; + this._fileName = null; + this._uniqueRootUrl = null; + this._bin = null; + this._rootBabylonMesh = null; + this._defaultBabylonMaterialData = {}; + this._postSceneLoadActions = new Array(); + this._parent = parent; + } + /** + * Registers a loader extension. + * @param name The name of the loader extension. + * @param factory The factory function that creates the loader extension. + */ + GLTFLoader.RegisterExtension = function (name, factory) { + if (GLTFLoader.UnregisterExtension(name)) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Extension with the name '".concat(name, "' already exists")); + } + GLTFLoader._RegisteredExtensions[name] = { + factory: factory, + }; + }; + /** + * Unregisters a loader extension. + * @param name The name of the loader extension. + * @returns A boolean indicating whether the extension has been unregistered + */ + GLTFLoader.UnregisterExtension = function (name) { + if (!GLTFLoader._RegisteredExtensions[name]) { + return false; + } + delete GLTFLoader._RegisteredExtensions[name]; + return true; + }; + Object.defineProperty(GLTFLoader.prototype, "gltf", { + /** + * The object that represents the glTF JSON. + */ + get: function () { + if (!this._gltf) { + throw new Error("glTF JSON is not available"); + } + return this._gltf; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFLoader.prototype, "bin", { + /** + * The BIN chunk of a binary glTF. + */ + get: function () { + return this._bin; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFLoader.prototype, "parent", { + /** + * The parent file loader. + */ + get: function () { + return this._parent; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFLoader.prototype, "babylonScene", { + /** + * The Babylon scene when loading the asset. + */ + get: function () { + if (!this._babylonScene) { + throw new Error("Scene is not available"); + } + return this._babylonScene; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFLoader.prototype, "rootBabylonMesh", { + /** + * The root Babylon mesh when loading the asset. + */ + get: function () { + return this._rootBabylonMesh; + }, + enumerable: false, + configurable: true + }); + /** @internal */ + GLTFLoader.prototype.dispose = function () { + if (this._disposed) { + return; + } + this._disposed = true; + this._completePromises.length = 0; + this._extensions.forEach(function (extension) { return extension.dispose && extension.dispose(); }); + this._extensions.length = 0; + this._gltf = null; // TODO + this._bin = null; + this._babylonScene = null; // TODO + this._rootBabylonMesh = null; + this._defaultBabylonMaterialData = {}; + this._postSceneLoadActions.length = 0; + this._parent.dispose(); + }; + /** + * @internal + */ + GLTFLoader.prototype.importMeshAsync = function (meshesNames, scene, container, data, rootUrl, onProgress, fileName) { + var _this = this; + if (fileName === void 0) { fileName = ""; } + return Promise.resolve().then(function () { + _this._babylonScene = scene; + _this._assetContainer = container; + _this._loadData(data); + var nodes = null; + if (meshesNames) { + var nodeMap_1 = {}; + if (_this._gltf.nodes) { + for (var _i = 0, _a = _this._gltf.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.name) { + nodeMap_1[node.name] = node.index; + } + } + } + var names = meshesNames instanceof Array ? meshesNames : [meshesNames]; + nodes = names.map(function (name) { + var node = nodeMap_1[name]; + if (node === undefined) { + throw new Error("Failed to find node '".concat(name, "'")); + } + return node; + }); + } + return _this._loadAsync(rootUrl, fileName, nodes, function () { + return { + meshes: _this._getMeshes(), + particleSystems: [], + skeletons: _this._getSkeletons(), + animationGroups: _this._getAnimationGroups(), + lights: _this._babylonLights, + transformNodes: _this._getTransformNodes(), + geometries: _this._getGeometries(), + }; + }); + }); + }; + /** + * @internal + */ + GLTFLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) { + var _this = this; + if (fileName === void 0) { fileName = ""; } + return Promise.resolve().then(function () { + _this._babylonScene = scene; + _this._loadData(data); + return _this._loadAsync(rootUrl, fileName, null, function () { return undefined; }); + }); + }; + GLTFLoader.prototype._loadAsync = function (rootUrl, fileName, nodes, resultFunc) { + var _this = this; + return Promise.resolve() + .then(function () { + _this._rootUrl = rootUrl; + _this._uniqueRootUrl = !rootUrl.startsWith("file:") && fileName ? rootUrl : "".concat(rootUrl).concat(Date.now(), "/"); + _this._fileName = fileName; + _this._loadExtensions(); + _this._checkExtensions(); + var loadingToReadyCounterName = "".concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.LOADING], " => ").concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.READY]); + var loadingToCompleteCounterName = "".concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.LOADING], " => ").concat(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState[_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.COMPLETE]); + _this._parent._startPerformanceCounter(loadingToReadyCounterName); + _this._parent._startPerformanceCounter(loadingToCompleteCounterName); + _this._parent._setState(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.LOADING); + _this._extensionsOnLoading(); + var promises = new Array(); + // Block the marking of materials dirty until the scene is loaded. + var oldBlockMaterialDirtyMechanism = _this._babylonScene.blockMaterialDirtyMechanism; + _this._babylonScene.blockMaterialDirtyMechanism = true; + if (!_this.parent.loadOnlyMaterials) { + if (nodes) { + promises.push(_this.loadSceneAsync("/nodes", { nodes: nodes, index: -1 })); + } + else if (_this._gltf.scene != undefined || (_this._gltf.scenes && _this._gltf.scenes[0])) { + var scene = ArrayItem.Get("/scene", _this._gltf.scenes, _this._gltf.scene || 0); + promises.push(_this.loadSceneAsync("/scenes/".concat(scene.index), scene)); + } + } + if (!_this.parent.skipMaterials && _this.parent.loadAllMaterials && _this._gltf.materials) { + for (var m = 0; m < _this._gltf.materials.length; ++m) { + var material = _this._gltf.materials[m]; + var context_1 = "/materials/" + m; + var babylonDrawMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFillMode; + promises.push(_this._loadMaterialAsync(context_1, material, null, babylonDrawMode, function () { })); + } + } + // Restore the blocking of material dirty. + _this._babylonScene.blockMaterialDirtyMechanism = oldBlockMaterialDirtyMechanism; + if (_this._parent.compileMaterials) { + promises.push(_this._compileMaterialsAsync()); + } + if (_this._parent.compileShadowGenerators) { + promises.push(_this._compileShadowGeneratorsAsync()); + } + var resultPromise = Promise.all(promises).then(function () { + if (_this._rootBabylonMesh) { + _this._rootBabylonMesh.setEnabled(true); + } + _this._extensionsOnReady(); + _this._parent._setState(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.READY); + _this._startAnimations(); + return resultFunc(); + }); + return resultPromise.then(function (result) { + _this._parent._endPerformanceCounter(loadingToReadyCounterName); + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Tools.SetImmediate(function () { + if (!_this._disposed) { + Promise.all(_this._completePromises).then(function () { + _this._parent._endPerformanceCounter(loadingToCompleteCounterName); + _this._parent._setState(_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderState.COMPLETE); + _this._parent.onCompleteObservable.notifyObservers(undefined); + _this._parent.onCompleteObservable.clear(); + _this.dispose(); + }, function (error) { + _this._parent.onErrorObservable.notifyObservers(error); + _this._parent.onErrorObservable.clear(); + _this.dispose(); + }); + } + }); + return result; + }); + }) + .catch(function (error) { + if (!_this._disposed) { + _this._parent.onErrorObservable.notifyObservers(error); + _this._parent.onErrorObservable.clear(); + _this.dispose(); + } + throw error; + }); + }; + GLTFLoader.prototype._loadData = function (data) { + this._gltf = data.json; + this._setupData(); + if (data.bin) { + var buffers = this._gltf.buffers; + if (buffers && buffers[0] && !buffers[0].uri) { + var binaryBuffer = buffers[0]; + if (binaryBuffer.byteLength < data.bin.byteLength - 3 || binaryBuffer.byteLength > data.bin.byteLength) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Binary buffer length (".concat(binaryBuffer.byteLength, ") from JSON does not match chunk length (").concat(data.bin.byteLength, ")")); + } + this._bin = data.bin; + } + else { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Unexpected BIN chunk"); + } + } + }; + GLTFLoader.prototype._setupData = function () { + ArrayItem.Assign(this._gltf.accessors); + ArrayItem.Assign(this._gltf.animations); + ArrayItem.Assign(this._gltf.buffers); + ArrayItem.Assign(this._gltf.bufferViews); + ArrayItem.Assign(this._gltf.cameras); + ArrayItem.Assign(this._gltf.images); + ArrayItem.Assign(this._gltf.materials); + ArrayItem.Assign(this._gltf.meshes); + ArrayItem.Assign(this._gltf.nodes); + ArrayItem.Assign(this._gltf.samplers); + ArrayItem.Assign(this._gltf.scenes); + ArrayItem.Assign(this._gltf.skins); + ArrayItem.Assign(this._gltf.textures); + if (this._gltf.nodes) { + var nodeParents = {}; + for (var _i = 0, _a = this._gltf.nodes; _i < _a.length; _i++) { + var node = _a[_i]; + if (node.children) { + for (var _b = 0, _c = node.children; _b < _c.length; _b++) { + var index = _c[_b]; + nodeParents[index] = node.index; + } + } + } + var rootNode = this._createRootNode(); + for (var _d = 0, _e = this._gltf.nodes; _d < _e.length; _d++) { + var node = _e[_d]; + var parentIndex = nodeParents[node.index]; + node.parent = parentIndex === undefined ? rootNode : this._gltf.nodes[parentIndex]; + } + } + }; + GLTFLoader.prototype._loadExtensions = function () { + for (var name_1 in GLTFLoader._RegisteredExtensions) { + var extension = GLTFLoader._RegisteredExtensions[name_1].factory(this); + if (extension.name !== name_1) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("The name of the glTF loader extension instance does not match the registered name: ".concat(extension.name, " !== ").concat(name_1)); + } + this._extensions.push(extension); + this._parent.onExtensionLoadedObservable.notifyObservers(extension); + } + this._extensions.sort(function (a, b) { return (a.order || Number.MAX_VALUE) - (b.order || Number.MAX_VALUE); }); + this._parent.onExtensionLoadedObservable.clear(); + }; + GLTFLoader.prototype._checkExtensions = function () { + if (this._gltf.extensionsRequired) { + var _loop_1 = function (name_2) { + var available = this_1._extensions.some(function (extension) { return extension.name === name_2 && extension.enabled; }); + if (!available) { + throw new Error("Require extension ".concat(name_2, " is not available")); + } + }; + var this_1 = this; + for (var _i = 0, _a = this._gltf.extensionsRequired; _i < _a.length; _i++) { + var name_2 = _a[_i]; + _loop_1(name_2); + } + } + }; + GLTFLoader.prototype._createRootNode = function () { + this._babylonScene._blockEntityCollection = !!this._assetContainer; + this._rootBabylonMesh = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Mesh("__root__", this._babylonScene); + this._rootBabylonMesh._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + this._rootBabylonMesh.setEnabled(false); + var rootNode = { + _babylonTransformNode: this._rootBabylonMesh, + index: -1, + }; + switch (this._parent.coordinateSystemMode) { + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderCoordinateSystemMode.AUTO: { + if (!this._babylonScene.useRightHandedSystem) { + rootNode.rotation = [0, 1, 0, 0]; + rootNode.scale = [1, 1, -1]; + GLTFLoader._LoadTransform(rootNode, this._rootBabylonMesh); + } + break; + } + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED: { + this._babylonScene.useRightHandedSystem = true; + break; + } + default: { + throw new Error("Invalid coordinate system mode (".concat(this._parent.coordinateSystemMode, ")")); + } + } + this._parent.onMeshLoadedObservable.notifyObservers(this._rootBabylonMesh); + return rootNode; + }; + /** + * Loads a glTF scene. + * @param context The context when loading the asset + * @param scene The glTF scene property + * @returns A promise that resolves when the load is complete + */ + GLTFLoader.prototype.loadSceneAsync = function (context, scene) { + var _this = this; + var extensionPromise = this._extensionsLoadSceneAsync(context, scene); + if (extensionPromise) { + return extensionPromise; + } + var promises = new Array(); + this.logOpen("".concat(context, " ").concat(scene.name || "")); + if (scene.nodes) { + for (var _i = 0, _a = scene.nodes; _i < _a.length; _i++) { + var index = _a[_i]; + var node = ArrayItem.Get("".concat(context, "/nodes/").concat(index), this._gltf.nodes, index); + promises.push(this.loadNodeAsync("/nodes/".concat(node.index), node, function (babylonMesh) { + babylonMesh.parent = _this._rootBabylonMesh; + })); + } + } + for (var _b = 0, _c = this._postSceneLoadActions; _b < _c.length; _b++) { + var action = _c[_b]; + action(); + } + promises.push(this._loadAnimationsAsync()); + this.logClose(); + return Promise.all(promises).then(function () { }); + }; + GLTFLoader.prototype._forEachPrimitive = function (node, callback) { + if (node._primitiveBabylonMeshes) { + for (var _i = 0, _a = node._primitiveBabylonMeshes; _i < _a.length; _i++) { + var babylonMesh = _a[_i]; + callback(babylonMesh); + } + } + }; + GLTFLoader.prototype._getGeometries = function () { + var geometries = new Array(); + var nodes = this._gltf.nodes; + if (nodes) { + for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) { + var node = nodes_1[_i]; + this._forEachPrimitive(node, function (babylonMesh) { + var geometry = babylonMesh.geometry; + if (geometry && geometries.indexOf(geometry) === -1) { + geometries.push(geometry); + } + }); + } + } + return geometries; + }; + GLTFLoader.prototype._getMeshes = function () { + var meshes = new Array(); + // Root mesh is always first, if available. + if (this._rootBabylonMesh) { + meshes.push(this._rootBabylonMesh); + } + var nodes = this._gltf.nodes; + if (nodes) { + for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) { + var node = nodes_2[_i]; + this._forEachPrimitive(node, function (babylonMesh) { + meshes.push(babylonMesh); + }); + } + } + return meshes; + }; + GLTFLoader.prototype._getTransformNodes = function () { + var transformNodes = new Array(); + var nodes = this._gltf.nodes; + if (nodes) { + for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) { + var node = nodes_3[_i]; + if (node._babylonTransformNode && node._babylonTransformNode.getClassName() === "TransformNode") { + transformNodes.push(node._babylonTransformNode); + } + if (node._babylonTransformNodeForSkin) { + transformNodes.push(node._babylonTransformNodeForSkin); + } + } + } + return transformNodes; + }; + GLTFLoader.prototype._getSkeletons = function () { + var skeletons = new Array(); + var skins = this._gltf.skins; + if (skins) { + for (var _i = 0, skins_1 = skins; _i < skins_1.length; _i++) { + var skin = skins_1[_i]; + if (skin._data) { + skeletons.push(skin._data.babylonSkeleton); + } + } + } + return skeletons; + }; + GLTFLoader.prototype._getAnimationGroups = function () { + var animationGroups = new Array(); + var animations = this._gltf.animations; + if (animations) { + for (var _i = 0, animations_1 = animations; _i < animations_1.length; _i++) { + var animation = animations_1[_i]; + if (animation._babylonAnimationGroup) { + animationGroups.push(animation._babylonAnimationGroup); + } + } + } + return animationGroups; + }; + GLTFLoader.prototype._startAnimations = function () { + switch (this._parent.animationStartMode) { + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderAnimationStartMode.NONE: { + // do nothing + break; + } + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderAnimationStartMode.FIRST: { + var babylonAnimationGroups = this._getAnimationGroups(); + if (babylonAnimationGroups.length !== 0) { + babylonAnimationGroups[0].start(true); + } + break; + } + case _glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFLoaderAnimationStartMode.ALL: { + var babylonAnimationGroups = this._getAnimationGroups(); + for (var _i = 0, babylonAnimationGroups_1 = babylonAnimationGroups; _i < babylonAnimationGroups_1.length; _i++) { + var babylonAnimationGroup = babylonAnimationGroups_1[_i]; + babylonAnimationGroup.start(true); + } + break; + } + default: { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Error("Invalid animation start mode (".concat(this._parent.animationStartMode, ")")); + return; + } + } + }; + /** + * Loads a glTF node. + * @param context The context when loading the asset + * @param node The glTF node property + * @param assign A function called synchronously after parsing the glTF properties + * @returns A promise that resolves with the loaded Babylon mesh when the load is complete + */ + GLTFLoader.prototype.loadNodeAsync = function (context, node, assign) { + var _this = this; + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadNodeAsync(context, node, assign); + if (extensionPromise) { + return extensionPromise; + } + if (node._babylonTransformNode) { + throw new Error("".concat(context, ": Invalid recursive node hierarchy")); + } + var promises = new Array(); + this.logOpen("".concat(context, " ").concat(node.name || "")); + var loadNode = function (babylonTransformNode) { + GLTFLoader.AddPointerMetadata(babylonTransformNode, context); + GLTFLoader._LoadTransform(node, babylonTransformNode); + if (node.camera != undefined) { + var camera = ArrayItem.Get("".concat(context, "/camera"), _this._gltf.cameras, node.camera); + promises.push(_this.loadCameraAsync("/cameras/".concat(camera.index), camera, function (babylonCamera) { + babylonCamera.parent = babylonTransformNode; + })); + } + if (node.children) { + for (var _i = 0, _a = node.children; _i < _a.length; _i++) { + var index = _a[_i]; + var childNode = ArrayItem.Get("".concat(context, "/children/").concat(index), _this._gltf.nodes, index); + promises.push(_this.loadNodeAsync("/nodes/".concat(childNode.index), childNode, function (childBabylonMesh) { + childBabylonMesh.parent = babylonTransformNode; + })); + } + } + assign(babylonTransformNode); + }; + if (node.mesh == undefined || node.skin != undefined) { + var nodeName = node.name || "node".concat(node.index); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var transformNode = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TransformNode(nodeName, this._babylonScene); + transformNode._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + if (node.mesh == undefined) { + node._babylonTransformNode = transformNode; + } + else { + node._babylonTransformNodeForSkin = transformNode; + } + loadNode(transformNode); + } + if (node.mesh != undefined) { + if (node.skin == undefined) { + var mesh = ArrayItem.Get("".concat(context, "/mesh"), this._gltf.meshes, node.mesh); + promises.push(this._loadMeshAsync("/meshes/".concat(mesh.index), node, mesh, loadNode)); + } + else { + // See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note) + // This code path will place the skinned mesh as a sibling of the skeleton root node without loading the + // transform, which effectively ignores the transform of the skinned mesh, as per spec. + var mesh = ArrayItem.Get("".concat(context, "/mesh"), this._gltf.meshes, node.mesh); + promises.push(this._loadMeshAsync("/meshes/".concat(mesh.index), node, mesh, function (babylonTransformNode) { + var babylonTransformNodeForSkin = node._babylonTransformNodeForSkin; + // Merge the metadata from the skin node to the skinned mesh in case a loader extension added metadata. + babylonTransformNode.metadata = mergeDeep(babylonTransformNodeForSkin.metadata, babylonTransformNode.metadata || {}); + var skin = ArrayItem.Get("".concat(context, "/skin"), _this._gltf.skins, node.skin); + promises.push(_this._loadSkinAsync("/skins/".concat(skin.index), node, skin, function (babylonSkeleton) { + _this._forEachPrimitive(node, function (babylonMesh) { + babylonMesh.skeleton = babylonSkeleton; + }); + // Wait until all the nodes are parented before parenting the skinned mesh. + _this._postSceneLoadActions.push(function () { + if (skin.skeleton != undefined) { + // Place the skinned mesh node as a sibling of the skeleton root node. + // Handle special case when the parent of the skeleton root is the skinned mesh. + var parentNode = ArrayItem.Get("/skins/".concat(skin.index, "/skeleton"), _this._gltf.nodes, skin.skeleton).parent; + if (node.index === parentNode.index) { + babylonTransformNode.parent = babylonTransformNodeForSkin.parent; + } + else { + babylonTransformNode.parent = parentNode._babylonTransformNode; + } + } + else { + babylonTransformNode.parent = _this._rootBabylonMesh; + } + _this._parent.onSkinLoadedObservable.notifyObservers({ node: babylonTransformNodeForSkin, skinnedNode: babylonTransformNode }); + }); + })); + })); + } + } + this.logClose(); + return Promise.all(promises).then(function () { + _this._forEachPrimitive(node, function (babylonMesh) { + if (babylonMesh.geometry && babylonMesh.geometry.useBoundingInfoFromGeometry) { + // simply apply the world matrices to the bounding info - the extends are already ok + babylonMesh._updateBoundingInfo(); + } + else { + babylonMesh.refreshBoundingInfo(true); + } + }); + return node._babylonTransformNode; + }); + }; + GLTFLoader.prototype._loadMeshAsync = function (context, node, mesh, assign) { + var primitives = mesh.primitives; + if (!primitives || !primitives.length) { + throw new Error("".concat(context, ": Primitives are missing")); + } + if (primitives[0].index == undefined) { + ArrayItem.Assign(primitives); + } + var promises = new Array(); + this.logOpen("".concat(context, " ").concat(mesh.name || "")); + var name = node.name || "node".concat(node.index); + if (primitives.length === 1) { + var primitive = mesh.primitives[0]; + promises.push(this._loadMeshPrimitiveAsync("".concat(context, "/primitives/").concat(primitive.index), name, node, mesh, primitive, function (babylonMesh) { + node._babylonTransformNode = babylonMesh; + node._primitiveBabylonMeshes = [babylonMesh]; + })); + } + else { + this._babylonScene._blockEntityCollection = !!this._assetContainer; + node._babylonTransformNode = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TransformNode(name, this._babylonScene); + node._babylonTransformNode._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + node._primitiveBabylonMeshes = []; + for (var _i = 0, primitives_1 = primitives; _i < primitives_1.length; _i++) { + var primitive = primitives_1[_i]; + promises.push(this._loadMeshPrimitiveAsync("".concat(context, "/primitives/").concat(primitive.index), "".concat(name, "_primitive").concat(primitive.index), node, mesh, primitive, function (babylonMesh) { + babylonMesh.parent = node._babylonTransformNode; + node._primitiveBabylonMeshes.push(babylonMesh); + })); + } + } + assign(node._babylonTransformNode); + this.logClose(); + return Promise.all(promises).then(function () { + return node._babylonTransformNode; + }); + }; + /** + * @internal Define this method to modify the default behavior when loading data for mesh primitives. + * @param context The context when loading the asset + * @param name The mesh name when loading the asset + * @param node The glTF node when loading the asset + * @param mesh The glTF mesh when loading the asset + * @param primitive The glTF mesh primitive property + * @param assign A function called synchronously after parsing the glTF properties + * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled + */ + GLTFLoader.prototype._loadMeshPrimitiveAsync = function (context, name, node, mesh, primitive, assign) { + var _this = this; + var extensionPromise = this._extensionsLoadMeshPrimitiveAsync(context, name, node, mesh, primitive, assign); + if (extensionPromise) { + return extensionPromise; + } + this.logOpen("".concat(context)); + var shouldInstance = this._disableInstancedMesh === 0 && this._parent.createInstances && node.skin == undefined && !mesh.primitives[0].targets; + var babylonAbstractMesh; + var promise; + if (shouldInstance && primitive._instanceData) { + this._babylonScene._blockEntityCollection = !!this._assetContainer; + babylonAbstractMesh = primitive._instanceData.babylonSourceMesh.createInstance(name); + babylonAbstractMesh._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + promise = primitive._instanceData.promise; + } + else { + var promises = new Array(); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonMesh_1 = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Mesh(name, this._babylonScene); + babylonMesh_1._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + babylonMesh_1.overrideMaterialSideOrientation = this._babylonScene.useRightHandedSystem ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.CounterClockWiseSideOrientation : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.ClockWiseSideOrientation; + this._createMorphTargets(context, node, mesh, primitive, babylonMesh_1); + promises.push(this._loadVertexDataAsync(context, primitive, babylonMesh_1).then(function (babylonGeometry) { + return _this._loadMorphTargetsAsync(context, primitive, babylonMesh_1, babylonGeometry).then(function () { + if (_this._disposed) { + return; + } + _this._babylonScene._blockEntityCollection = !!_this._assetContainer; + babylonGeometry.applyToMesh(babylonMesh_1); + babylonGeometry._parentContainer = _this._assetContainer; + _this._babylonScene._blockEntityCollection = false; + }); + })); + var babylonDrawMode = GLTFLoader._GetDrawMode(context, primitive.mode); + if (primitive.material == undefined) { + var babylonMaterial = this._defaultBabylonMaterialData[babylonDrawMode]; + if (!babylonMaterial) { + babylonMaterial = this._createDefaultMaterial("__GLTFLoader._default", babylonDrawMode); + this._parent.onMaterialLoadedObservable.notifyObservers(babylonMaterial); + this._defaultBabylonMaterialData[babylonDrawMode] = babylonMaterial; + } + babylonMesh_1.material = babylonMaterial; + } + else if (!this.parent.skipMaterials) { + var material = ArrayItem.Get("".concat(context, "/material"), this._gltf.materials, primitive.material); + promises.push(this._loadMaterialAsync("/materials/".concat(material.index), material, babylonMesh_1, babylonDrawMode, function (babylonMaterial) { + babylonMesh_1.material = babylonMaterial; + })); + } + promise = Promise.all(promises); + if (shouldInstance) { + primitive._instanceData = { + babylonSourceMesh: babylonMesh_1, + promise: promise, + }; + } + babylonAbstractMesh = babylonMesh_1; + } + GLTFLoader.AddPointerMetadata(babylonAbstractMesh, context); + this._parent.onMeshLoadedObservable.notifyObservers(babylonAbstractMesh); + assign(babylonAbstractMesh); + this.logClose(); + return promise.then(function () { + return babylonAbstractMesh; + }); + }; + GLTFLoader.prototype._loadVertexDataAsync = function (context, primitive, babylonMesh) { + var _this = this; + var extensionPromise = this._extensionsLoadVertexDataAsync(context, primitive, babylonMesh); + if (extensionPromise) { + return extensionPromise; + } + var attributes = primitive.attributes; + if (!attributes) { + throw new Error("".concat(context, ": Attributes are missing")); + } + var promises = new Array(); + var babylonGeometry = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Geometry(babylonMesh.name, this._babylonScene); + if (primitive.indices == undefined) { + babylonMesh.isUnIndexed = true; + } + else { + var accessor = ArrayItem.Get("".concat(context, "/indices"), this._gltf.accessors, primitive.indices); + promises.push(this._loadIndicesAccessorAsync("/accessors/".concat(accessor.index), accessor).then(function (data) { + babylonGeometry.setIndices(data); + })); + } + var loadAttribute = function (name, kind, callback) { + if (attributes[name] == undefined) { + return; + } + babylonMesh._delayInfo = babylonMesh._delayInfo || []; + if (babylonMesh._delayInfo.indexOf(kind) === -1) { + babylonMesh._delayInfo.push(kind); + } + var accessor = ArrayItem.Get("".concat(context, "/attributes/").concat(name), _this._gltf.accessors, attributes[name]); + promises.push(_this._loadVertexAccessorAsync("/accessors/".concat(accessor.index), accessor, kind).then(function (babylonVertexBuffer) { + var _a, _b; + if (babylonVertexBuffer.getKind() === babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind && !_this.parent.alwaysComputeBoundingBox && !babylonMesh.skeleton) { + if (accessor.min && accessor.max) { + var min = (_a = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[0]).copyFromFloats.apply(_a, accessor.min); + var max = (_b = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.TmpVectors.Vector3[1]).copyFromFloats.apply(_b, accessor.max); + if (accessor.normalized && accessor.componentType !== 5126 /* AccessorComponentType.FLOAT */) { + var divider = 1; + switch (accessor.componentType) { + case 5120 /* AccessorComponentType.BYTE */: + divider = 127.0; + break; + case 5121 /* AccessorComponentType.UNSIGNED_BYTE */: + divider = 255.0; + break; + case 5122 /* AccessorComponentType.SHORT */: + divider = 32767.0; + break; + case 5123 /* AccessorComponentType.UNSIGNED_SHORT */: + divider = 65535.0; + break; + } + var oneOverDivider = 1 / divider; + min.scaleInPlace(oneOverDivider); + max.scaleInPlace(oneOverDivider); + } + babylonGeometry._boundingInfo = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.BoundingInfo(min, max); + babylonGeometry.useBoundingInfoFromGeometry = true; + } + } + babylonGeometry.setVerticesBuffer(babylonVertexBuffer, accessor.count); + })); + if (kind == babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind) { + babylonMesh.numBoneInfluencers = 8; + } + if (callback) { + callback(accessor); + } + }; + loadAttribute("POSITION", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind); + loadAttribute("NORMAL", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind); + loadAttribute("TANGENT", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind); + loadAttribute("TEXCOORD_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UVKind); + loadAttribute("TEXCOORD_1", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV2Kind); + loadAttribute("TEXCOORD_2", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV3Kind); + loadAttribute("TEXCOORD_3", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV4Kind); + loadAttribute("TEXCOORD_4", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV5Kind); + loadAttribute("TEXCOORD_5", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.UV6Kind); + loadAttribute("JOINTS_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind); + loadAttribute("WEIGHTS_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsKind); + loadAttribute("JOINTS_1", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind); + loadAttribute("WEIGHTS_1", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesWeightsExtraKind); + loadAttribute("COLOR_0", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ColorKind, function (accessor) { + if (accessor.type === "VEC4" /* AccessorType.VEC4 */) { + babylonMesh.hasVertexAlpha = true; + } + }); + return Promise.all(promises).then(function () { + return babylonGeometry; + }); + }; + GLTFLoader.prototype._createMorphTargets = function (context, node, mesh, primitive, babylonMesh) { + if (!primitive.targets) { + return; + } + if (node._numMorphTargets == undefined) { + node._numMorphTargets = primitive.targets.length; + } + else if (primitive.targets.length !== node._numMorphTargets) { + throw new Error("".concat(context, ": Primitives do not have the same number of targets")); + } + var targetNames = mesh.extras ? mesh.extras.targetNames : null; + this._babylonScene._blockEntityCollection = !!this._assetContainer; + babylonMesh.morphTargetManager = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.MorphTargetManager(this._babylonScene); + babylonMesh.morphTargetManager._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + babylonMesh.morphTargetManager.areUpdatesFrozen = true; + for (var index = 0; index < primitive.targets.length; index++) { + var weight = node.weights ? node.weights[index] : mesh.weights ? mesh.weights[index] : 0; + var name_3 = targetNames ? targetNames[index] : "morphTarget".concat(index); + babylonMesh.morphTargetManager.addTarget(new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.MorphTarget(name_3, weight, babylonMesh.getScene())); + // TODO: tell the target whether it has positions, normals, tangents + } + }; + GLTFLoader.prototype._loadMorphTargetsAsync = function (context, primitive, babylonMesh, babylonGeometry) { + if (!primitive.targets) { + return Promise.resolve(); + } + var promises = new Array(); + var morphTargetManager = babylonMesh.morphTargetManager; + for (var index = 0; index < morphTargetManager.numTargets; index++) { + var babylonMorphTarget = morphTargetManager.getTarget(index); + promises.push(this._loadMorphTargetVertexDataAsync("".concat(context, "/targets/").concat(index), babylonGeometry, primitive.targets[index], babylonMorphTarget)); + } + return Promise.all(promises).then(function () { + morphTargetManager.areUpdatesFrozen = false; + }); + }; + GLTFLoader.prototype._loadMorphTargetVertexDataAsync = function (context, babylonGeometry, attributes, babylonMorphTarget) { + var _this = this; + var promises = new Array(); + var loadAttribute = function (attribute, kind, setData) { + if (attributes[attribute] == undefined) { + return; + } + var babylonVertexBuffer = babylonGeometry.getVertexBuffer(kind); + if (!babylonVertexBuffer) { + return; + } + var accessor = ArrayItem.Get("".concat(context, "/").concat(attribute), _this._gltf.accessors, attributes[attribute]); + promises.push(_this._loadFloatAccessorAsync("/accessors/".concat(accessor.index), accessor).then(function (data) { + setData(babylonVertexBuffer, data); + })); + }; + loadAttribute("POSITION", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind, function (babylonVertexBuffer, data) { + var positions = new Float32Array(data.length); + babylonVertexBuffer.forEach(data.length, function (value, index) { + positions[index] = data[index] + value; + }); + babylonMorphTarget.setPositions(positions); + }); + loadAttribute("NORMAL", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind, function (babylonVertexBuffer, data) { + var normals = new Float32Array(data.length); + babylonVertexBuffer.forEach(normals.length, function (value, index) { + normals[index] = data[index] + value; + }); + babylonMorphTarget.setNormals(normals); + }); + loadAttribute("TANGENT", babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.TangentKind, function (babylonVertexBuffer, data) { + var tangents = new Float32Array((data.length / 3) * 4); + var dataIndex = 0; + babylonVertexBuffer.forEach((data.length / 3) * 4, function (value, index) { + // Tangent data for morph targets is stored as xyz delta. + // The vertexData.tangent is stored as xyzw. + // So we need to skip every fourth vertexData.tangent. + if ((index + 1) % 4 !== 0) { + tangents[dataIndex] = data[dataIndex] + value; + dataIndex++; + } + }); + babylonMorphTarget.setTangents(tangents); + }); + return Promise.all(promises).then(function () { }); + }; + GLTFLoader._LoadTransform = function (node, babylonNode) { + // Ignore the TRS of skinned nodes. + // See https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#skins (second implementation note) + if (node.skin != undefined) { + return; + } + var position = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(); + var rotation = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Identity(); + var scaling = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.One(); + if (node.matrix) { + var matrix = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromArray(node.matrix); + matrix.decompose(scaling, rotation, position); + } + else { + if (node.translation) { + position = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.translation); + } + if (node.rotation) { + rotation = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(node.rotation); + } + if (node.scale) { + scaling = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.scale); + } + } + babylonNode.position = position; + babylonNode.rotationQuaternion = rotation; + babylonNode.scaling = scaling; + }; + GLTFLoader.prototype._loadSkinAsync = function (context, node, skin, assign) { + var _this = this; + var extensionPromise = this._extensionsLoadSkinAsync(context, node, skin); + if (extensionPromise) { + return extensionPromise; + } + if (skin._data) { + assign(skin._data.babylonSkeleton); + return skin._data.promise; + } + var skeletonId = "skeleton".concat(skin.index); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonSkeleton = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Skeleton(skin.name || skeletonId, skeletonId, this._babylonScene); + babylonSkeleton._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + this._loadBones(context, skin, babylonSkeleton); + var promise = this._loadSkinInverseBindMatricesDataAsync(context, skin).then(function (inverseBindMatricesData) { + _this._updateBoneMatrices(babylonSkeleton, inverseBindMatricesData); + }); + skin._data = { + babylonSkeleton: babylonSkeleton, + promise: promise, + }; + assign(babylonSkeleton); + return promise; + }; + GLTFLoader.prototype._loadBones = function (context, skin, babylonSkeleton) { + if (skin.skeleton == undefined || this._parent.alwaysComputeSkeletonRootNode) { + var rootNode = this._findSkeletonRootNode("".concat(context, "/joints"), skin.joints); + if (rootNode) { + if (skin.skeleton === undefined) { + skin.skeleton = rootNode.index; + } + else { + var isParent = function (a, b) { + for (; b.parent; b = b.parent) { + if (b.parent === a) { + return true; + } + } + return false; + }; + var skeletonNode = ArrayItem.Get("".concat(context, "/skeleton"), this._gltf.nodes, skin.skeleton); + if (skeletonNode !== rootNode && !isParent(skeletonNode, rootNode)) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root")); + skin.skeleton = rootNode.index; + } + } + } + else { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Failed to find common root")); + } + } + var babylonBones = {}; + for (var _i = 0, _a = skin.joints; _i < _a.length; _i++) { + var index = _a[_i]; + var node = ArrayItem.Get("".concat(context, "/joints/").concat(index), this._gltf.nodes, index); + this._loadBone(node, skin, babylonSkeleton, babylonBones); + } + }; + GLTFLoader.prototype._findSkeletonRootNode = function (context, joints) { + if (joints.length === 0) { + return null; + } + var paths = {}; + for (var _i = 0, joints_1 = joints; _i < joints_1.length; _i++) { + var index = joints_1[_i]; + var path = new Array(); + var node = ArrayItem.Get("".concat(context, "/").concat(index), this._gltf.nodes, index); + while (node.index !== -1) { + path.unshift(node); + node = node.parent; + } + paths[index] = path; + } + var rootNode = null; + for (var i = 0;; ++i) { + var path = paths[joints[0]]; + if (i >= path.length) { + return rootNode; + } + var node = path[i]; + for (var j = 1; j < joints.length; ++j) { + path = paths[joints[j]]; + if (i >= path.length || node !== path[i]) { + return rootNode; + } + } + rootNode = node; + } + }; + GLTFLoader.prototype._loadBone = function (node, skin, babylonSkeleton, babylonBones) { + var babylonBone = babylonBones[node.index]; + if (babylonBone) { + return babylonBone; + } + var parentBabylonBone = null; + if (node.index !== skin.skeleton) { + if (node.parent && node.parent.index !== -1) { + parentBabylonBone = this._loadBone(node.parent, skin, babylonSkeleton, babylonBones); + } + else if (skin.skeleton !== undefined) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("/skins/".concat(skin.index, "/skeleton: Skeleton node is not a common root")); + } + } + var boneIndex = skin.joints.indexOf(node.index); + babylonBone = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Bone(node.name || "joint".concat(node.index), babylonSkeleton, parentBabylonBone, this._getNodeMatrix(node), null, null, boneIndex); + babylonBones[node.index] = babylonBone; + // Wait until the scene is loaded to ensure the transform nodes are loaded. + this._postSceneLoadActions.push(function () { + // Link the Babylon bone with the corresponding Babylon transform node. + // A glTF joint is a pointer to a glTF node in the glTF node hierarchy similar to Unity3D. + babylonBone.linkTransformNode(node._babylonTransformNode); + }); + return babylonBone; + }; + GLTFLoader.prototype._loadSkinInverseBindMatricesDataAsync = function (context, skin) { + if (skin.inverseBindMatrices == undefined) { + return Promise.resolve(null); + } + var accessor = ArrayItem.Get("".concat(context, "/inverseBindMatrices"), this._gltf.accessors, skin.inverseBindMatrices); + return this._loadFloatAccessorAsync("/accessors/".concat(accessor.index), accessor); + }; + GLTFLoader.prototype._updateBoneMatrices = function (babylonSkeleton, inverseBindMatricesData) { + for (var _i = 0, _a = babylonSkeleton.bones; _i < _a.length; _i++) { + var babylonBone = _a[_i]; + var baseMatrix = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.Identity(); + var boneIndex = babylonBone._index; + if (inverseBindMatricesData && boneIndex !== -1) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromArrayToRef(inverseBindMatricesData, boneIndex * 16, baseMatrix); + baseMatrix.invertToRef(baseMatrix); + } + var babylonParentBone = babylonBone.getParent(); + if (babylonParentBone) { + baseMatrix.multiplyToRef(babylonParentBone.getAbsoluteInverseBindMatrix(), baseMatrix); + } + babylonBone.updateMatrix(baseMatrix, false, false); + babylonBone._updateAbsoluteBindMatrices(undefined, false); + } + }; + GLTFLoader.prototype._getNodeMatrix = function (node) { + return node.matrix + ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.FromArray(node.matrix) + : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Matrix.Compose(node.scale ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.scale) : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.One(), node.rotation ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(node.rotation) : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Quaternion.Identity(), node.translation ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(node.translation) : babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero()); + }; + /** + * Loads a glTF camera. + * @param context The context when loading the asset + * @param camera The glTF camera property + * @param assign A function called synchronously after parsing the glTF properties + * @returns A promise that resolves with the loaded Babylon camera when the load is complete + */ + GLTFLoader.prototype.loadCameraAsync = function (context, camera, assign) { + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadCameraAsync(context, camera, assign); + if (extensionPromise) { + return extensionPromise; + } + var promises = new Array(); + this.logOpen("".concat(context, " ").concat(camera.name || "")); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonCamera = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.FreeCamera(camera.name || "camera".concat(camera.index), babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3.Zero(), this._babylonScene, false); + babylonCamera._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + babylonCamera.ignoreParentScaling = true; + camera._babylonCamera = babylonCamera; + babylonCamera.rotation = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Vector3(0, Math.PI, 0); + switch (camera.type) { + case "perspective" /* CameraType.PERSPECTIVE */: { + var perspective = camera.perspective; + if (!perspective) { + throw new Error("".concat(context, ": Camera perspective properties are missing")); + } + babylonCamera.fov = perspective.yfov; + babylonCamera.minZ = perspective.znear; + babylonCamera.maxZ = perspective.zfar || 0; + break; + } + case "orthographic" /* CameraType.ORTHOGRAPHIC */: { + if (!camera.orthographic) { + throw new Error("".concat(context, ": Camera orthographic properties are missing")); + } + babylonCamera.mode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Camera.ORTHOGRAPHIC_CAMERA; + babylonCamera.orthoLeft = -camera.orthographic.xmag; + babylonCamera.orthoRight = camera.orthographic.xmag; + babylonCamera.orthoBottom = -camera.orthographic.ymag; + babylonCamera.orthoTop = camera.orthographic.ymag; + babylonCamera.minZ = camera.orthographic.znear; + babylonCamera.maxZ = camera.orthographic.zfar; + break; + } + default: { + throw new Error("".concat(context, ": Invalid camera type (").concat(camera.type, ")")); + } + } + GLTFLoader.AddPointerMetadata(babylonCamera, context); + this._parent.onCameraLoadedObservable.notifyObservers(babylonCamera); + assign(babylonCamera); + this.logClose(); + return Promise.all(promises).then(function () { + return babylonCamera; + }); + }; + GLTFLoader.prototype._loadAnimationsAsync = function () { + var animations = this._gltf.animations; + if (!animations) { + return Promise.resolve(); + } + var promises = new Array(); + for (var index = 0; index < animations.length; index++) { + var animation = animations[index]; + promises.push(this.loadAnimationAsync("/animations/".concat(animation.index), animation).then(function (animationGroup) { + // Delete the animation group if it ended up not having any animations in it. + if (animationGroup.targetedAnimations.length === 0) { + animationGroup.dispose(); + } + })); + } + return Promise.all(promises).then(function () { }); + }; + /** + * Loads a glTF animation. + * @param context The context when loading the asset + * @param animation The glTF animation property + * @returns A promise that resolves with the loaded Babylon animation group when the load is complete + */ + GLTFLoader.prototype.loadAnimationAsync = function (context, animation) { + var promise = this._extensionsLoadAnimationAsync(context, animation); + if (promise) { + return promise; + } + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonAnimationGroup = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.AnimationGroup(animation.name || "animation".concat(animation.index), this._babylonScene); + babylonAnimationGroup._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + animation._babylonAnimationGroup = babylonAnimationGroup; + var promises = new Array(); + ArrayItem.Assign(animation.channels); + ArrayItem.Assign(animation.samplers); + for (var _i = 0, _a = animation.channels; _i < _a.length; _i++) { + var channel = _a[_i]; + promises.push(this._loadAnimationChannelAsync("".concat(context, "/channels/").concat(channel.index), context, animation, channel, function (babylonTarget, babylonAnimation) { + babylonTarget.animations = babylonTarget.animations || []; + babylonTarget.animations.push(babylonAnimation); + babylonAnimationGroup.addTargetedAnimation(babylonAnimation, babylonTarget); + })); + } + return Promise.all(promises).then(function () { + babylonAnimationGroup.normalize(0); + return babylonAnimationGroup; + }); + }; + /** + * @hidden + * Loads a glTF animation channel. + * @param context The context when loading the asset + * @param animationContext The context of the animation when loading the asset + * @param animation The glTF animation property + * @param channel The glTF animation channel property + * @param onLoad Called for each animation loaded + * @returns A void promise that resolves when the load is complete + */ + GLTFLoader.prototype._loadAnimationChannelAsync = function (context, animationContext, animation, channel, onLoad) { + var promise = this._extensionsLoadAnimationChannelAsync(context, animationContext, animation, channel, onLoad); + if (promise) { + return promise; + } + if (channel.target.node == undefined) { + return Promise.resolve(); + } + var targetNode = ArrayItem.Get("".concat(context, "/target/node"), this._gltf.nodes, channel.target.node); + // Ignore animations that have no animation targets. + if ((channel.target.path === "weights" /* AnimationChannelTargetPath.WEIGHTS */ && !targetNode._numMorphTargets) || + (channel.target.path !== "weights" /* AnimationChannelTargetPath.WEIGHTS */ && !targetNode._babylonTransformNode)) { + return Promise.resolve(); + } + var properties; + switch (channel.target.path) { + case "translation" /* AnimationChannelTargetPath.TRANSLATION */: { + properties = _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__.nodeAnimationData.translation; + break; + } + case "rotation" /* AnimationChannelTargetPath.ROTATION */: { + properties = _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__.nodeAnimationData.rotation; + break; + } + case "scale" /* AnimationChannelTargetPath.SCALE */: { + properties = _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__.nodeAnimationData.scale; + break; + } + case "weights" /* AnimationChannelTargetPath.WEIGHTS */: { + properties = _glTFLoaderAnimation__WEBPACK_IMPORTED_MODULE_2__.nodeAnimationData.weights; + break; + } + default: { + throw new Error("".concat(context, "/target/path: Invalid value (").concat(channel.target.path, ")")); + } + } + var targetInfo = { + target: targetNode, + properties: properties, + }; + return this._loadAnimationChannelFromTargetInfoAsync(context, animationContext, animation, channel, targetInfo, onLoad); + }; + /** + * @hidden + * Loads a glTF animation channel. + * @param context The context when loading the asset + * @param animationContext The context of the animation when loading the asset + * @param animation The glTF animation property + * @param channel The glTF animation channel property + * @param targetInfo The glTF target and properties + * @param onLoad Called for each animation loaded + * @returns A void promise that resolves when the load is complete + */ + GLTFLoader.prototype._loadAnimationChannelFromTargetInfoAsync = function (context, animationContext, animation, channel, targetInfo, onLoad) { + var fps = this.parent.targetFps; + var invfps = 1 / fps; + var sampler = ArrayItem.Get("".concat(context, "/sampler"), animation.samplers, channel.sampler); + return this._loadAnimationSamplerAsync("".concat(animationContext, "/samplers/").concat(channel.sampler), sampler).then(function (data) { + var numAnimations = 0; + // Extract the corresponding values from the read value. + // GLTF values may be dispatched to several Babylon properties. + // For example, baseColorFactor [`r`, `g`, `b`, `a`] is dispatched to + // - albedoColor as Color3(`r`, `g`, `b`) + // - alpha as `a` + for (var _i = 0, _a = targetInfo.properties; _i < _a.length; _i++) { + var property = _a[_i]; + var stride = property.getStride(targetInfo.target); + var input = data.input; + var output = data.output; + var keys = new Array(input.length); + var outputOffset = 0; + switch (data.interpolation) { + case "STEP" /* AnimationSamplerInterpolation.STEP */: { + for (var index = 0; index < input.length; index++) { + var value = property.getValue(targetInfo.target, output, outputOffset, 1); + outputOffset += stride; + keys[index] = { + frame: input[index] * fps, + value: value, + interpolation: babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.AnimationKeyInterpolation.STEP, + }; + } + break; + } + case "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */: { + for (var index = 0; index < input.length; index++) { + var inTangent = property.getValue(targetInfo.target, output, outputOffset, invfps); + outputOffset += stride; + var value = property.getValue(targetInfo.target, output, outputOffset, 1); + outputOffset += stride; + var outTangent = property.getValue(targetInfo.target, output, outputOffset, invfps); + outputOffset += stride; + keys[index] = { + frame: input[index] * fps, + inTangent: inTangent, + value: value, + outTangent: outTangent, + }; + } + break; + } + case "LINEAR" /* AnimationSamplerInterpolation.LINEAR */: { + for (var index = 0; index < input.length; index++) { + var value = property.getValue(targetInfo.target, output, outputOffset, 1); + outputOffset += stride; + keys[index] = { + frame: input[index] * fps, + value: value, + }; + } + break; + } + } + if (outputOffset > 0) { + var name_4 = "".concat(animation.name || "animation".concat(animation.index), "_channel").concat(channel.index, "_").concat(numAnimations); + property.buildAnimations(targetInfo.target, name_4, fps, keys, function (babylonAnimatable, babylonAnimation) { + ++numAnimations; + onLoad(babylonAnimatable, babylonAnimation); + }); + } + } + }); + }; + GLTFLoader.prototype._loadAnimationSamplerAsync = function (context, sampler) { + if (sampler._data) { + return sampler._data; + } + var interpolation = sampler.interpolation || "LINEAR" /* AnimationSamplerInterpolation.LINEAR */; + switch (interpolation) { + case "STEP" /* AnimationSamplerInterpolation.STEP */: + case "LINEAR" /* AnimationSamplerInterpolation.LINEAR */: + case "CUBICSPLINE" /* AnimationSamplerInterpolation.CUBICSPLINE */: { + break; + } + default: { + throw new Error("".concat(context, "/interpolation: Invalid value (").concat(sampler.interpolation, ")")); + } + } + var inputAccessor = ArrayItem.Get("".concat(context, "/input"), this._gltf.accessors, sampler.input); + var outputAccessor = ArrayItem.Get("".concat(context, "/output"), this._gltf.accessors, sampler.output); + sampler._data = Promise.all([ + this._loadFloatAccessorAsync("/accessors/".concat(inputAccessor.index), inputAccessor), + this._loadFloatAccessorAsync("/accessors/".concat(outputAccessor.index), outputAccessor), + ]).then(function (_a) { + var inputData = _a[0], outputData = _a[1]; + return { + input: inputData, + interpolation: interpolation, + output: outputData, + }; + }); + return sampler._data; + }; + /** + * Loads a glTF buffer. + * @param context The context when loading the asset + * @param buffer The glTF buffer property + * @param byteOffset The byte offset to use + * @param byteLength The byte length to use + * @returns A promise that resolves with the loaded data when the load is complete + */ + GLTFLoader.prototype.loadBufferAsync = function (context, buffer, byteOffset, byteLength) { + var extensionPromise = this._extensionsLoadBufferAsync(context, buffer, byteOffset, byteLength); + if (extensionPromise) { + return extensionPromise; + } + if (!buffer._data) { + if (buffer.uri) { + buffer._data = this.loadUriAsync("".concat(context, "/uri"), buffer, buffer.uri); + } + else { + if (!this._bin) { + throw new Error("".concat(context, ": Uri is missing or the binary glTF is missing its binary chunk")); + } + buffer._data = this._bin.readAsync(0, buffer.byteLength); + } + } + return buffer._data.then(function (data) { + try { + return new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength); + } + catch (e) { + throw new Error("".concat(context, ": ").concat(e.message)); + } + }); + }; + /** + * Loads a glTF buffer view. + * @param context The context when loading the asset + * @param bufferView The glTF buffer view property + * @returns A promise that resolves with the loaded data when the load is complete + */ + GLTFLoader.prototype.loadBufferViewAsync = function (context, bufferView) { + var extensionPromise = this._extensionsLoadBufferViewAsync(context, bufferView); + if (extensionPromise) { + return extensionPromise; + } + if (bufferView._data) { + return bufferView._data; + } + var buffer = ArrayItem.Get("".concat(context, "/buffer"), this._gltf.buffers, bufferView.buffer); + bufferView._data = this.loadBufferAsync("/buffers/".concat(buffer.index), buffer, bufferView.byteOffset || 0, bufferView.byteLength); + return bufferView._data; + }; + GLTFLoader.prototype._loadAccessorAsync = function (context, accessor, constructor) { + var _this = this; + if (accessor._data) { + return accessor._data; + } + var numComponents = GLTFLoader._GetNumComponents(context, accessor.type); + var byteStride = numComponents * babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(accessor.componentType); + var length = numComponents * accessor.count; + if (accessor.bufferView == undefined) { + accessor._data = Promise.resolve(new constructor(length)); + } + else { + var bufferView_1 = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView); + accessor._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView_1.index), bufferView_1).then(function (data) { + if (accessor.componentType === 5126 /* AccessorComponentType.FLOAT */ && !accessor.normalized && (!bufferView_1.byteStride || bufferView_1.byteStride === byteStride)) { + return GLTFLoader._GetTypedArray(context, accessor.componentType, data, accessor.byteOffset, length); + } + else { + var typedArray_1 = new constructor(length); + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ForEach(data, accessor.byteOffset || 0, bufferView_1.byteStride || byteStride, numComponents, accessor.componentType, typedArray_1.length, accessor.normalized || false, function (value, index) { + typedArray_1[index] = value; + }); + return typedArray_1; + } + }); + } + if (accessor.sparse) { + var sparse_1 = accessor.sparse; + accessor._data = accessor._data.then(function (data) { + var typedArray = data; + var indicesBufferView = ArrayItem.Get("".concat(context, "/sparse/indices/bufferView"), _this._gltf.bufferViews, sparse_1.indices.bufferView); + var valuesBufferView = ArrayItem.Get("".concat(context, "/sparse/values/bufferView"), _this._gltf.bufferViews, sparse_1.values.bufferView); + return Promise.all([ + _this.loadBufferViewAsync("/bufferViews/".concat(indicesBufferView.index), indicesBufferView), + _this.loadBufferViewAsync("/bufferViews/".concat(valuesBufferView.index), valuesBufferView), + ]).then(function (_a) { + var indicesData = _a[0], valuesData = _a[1]; + var indices = GLTFLoader._GetTypedArray("".concat(context, "/sparse/indices"), sparse_1.indices.componentType, indicesData, sparse_1.indices.byteOffset, sparse_1.count); + var sparseLength = numComponents * sparse_1.count; + var values; + if (accessor.componentType === 5126 /* AccessorComponentType.FLOAT */ && !accessor.normalized) { + values = GLTFLoader._GetTypedArray("".concat(context, "/sparse/values"), accessor.componentType, valuesData, sparse_1.values.byteOffset, sparseLength); + } + else { + var sparseData = GLTFLoader._GetTypedArray("".concat(context, "/sparse/values"), accessor.componentType, valuesData, sparse_1.values.byteOffset, sparseLength); + values = new constructor(sparseLength); + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.ForEach(sparseData, 0, byteStride, numComponents, accessor.componentType, values.length, accessor.normalized || false, function (value, index) { + values[index] = value; + }); + } + var valuesIndex = 0; + for (var indicesIndex = 0; indicesIndex < indices.length; indicesIndex++) { + var dataIndex = indices[indicesIndex] * numComponents; + for (var componentIndex = 0; componentIndex < numComponents; componentIndex++) { + typedArray[dataIndex++] = values[valuesIndex++]; + } + } + return typedArray; + }); + }); + } + return accessor._data; + }; + /** + * @internal + */ + GLTFLoader.prototype._loadFloatAccessorAsync = function (context, accessor) { + return this._loadAccessorAsync(context, accessor, Float32Array); + }; + /** + * @internal + */ + GLTFLoader.prototype._loadIndicesAccessorAsync = function (context, accessor) { + if (accessor.type !== "SCALAR" /* AccessorType.SCALAR */) { + throw new Error("".concat(context, "/type: Invalid value ").concat(accessor.type)); + } + if (accessor.componentType !== 5121 /* AccessorComponentType.UNSIGNED_BYTE */ && + accessor.componentType !== 5123 /* AccessorComponentType.UNSIGNED_SHORT */ && + accessor.componentType !== 5125 /* AccessorComponentType.UNSIGNED_INT */) { + throw new Error("".concat(context, "/componentType: Invalid value ").concat(accessor.componentType)); + } + if (accessor._data) { + return accessor._data; + } + if (accessor.sparse) { + var constructor = GLTFLoader._GetTypedArrayConstructor("".concat(context, "/componentType"), accessor.componentType); + accessor._data = this._loadAccessorAsync(context, accessor, constructor); + } + else { + var bufferView = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView); + accessor._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) { + return GLTFLoader._GetTypedArray(context, accessor.componentType, data, accessor.byteOffset, accessor.count); + }); + } + return accessor._data; + }; + /** + * @internal + */ + GLTFLoader.prototype._loadVertexBufferViewAsync = function (bufferView) { + if (bufferView._babylonBuffer) { + return bufferView._babylonBuffer; + } + var engine = this._babylonScene.getEngine(); + bufferView._babylonBuffer = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) { + return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Buffer(engine, data, false); + }); + return bufferView._babylonBuffer; + }; + /** + * @internal + */ + GLTFLoader.prototype._loadVertexAccessorAsync = function (context, accessor, kind) { + var _a; + if ((_a = accessor._babylonVertexBuffer) === null || _a === void 0 ? void 0 : _a[kind]) { + return accessor._babylonVertexBuffer[kind]; + } + if (!accessor._babylonVertexBuffer) { + accessor._babylonVertexBuffer = {}; + } + var engine = this._babylonScene.getEngine(); + if (accessor.sparse) { + accessor._babylonVertexBuffer[kind] = this._loadFloatAccessorAsync(context, accessor).then(function (data) { + return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer(engine, data, kind, false); + }); + } + // Load joint indices as a float array since the shaders expect float data but glTF uses unsigned byte/short. + // This prevents certain platforms (e.g. D3D) from having to convert the data to float on the fly. + else if (kind === babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesKind || kind === babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.MatricesIndicesExtraKind) { + accessor._babylonVertexBuffer[kind] = this._loadFloatAccessorAsync(context, accessor).then(function (data) { + return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer(engine, data, kind, false); + }); + } + else { + var bufferView_2 = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, accessor.bufferView); + accessor._babylonVertexBuffer[kind] = this._loadVertexBufferViewAsync(bufferView_2).then(function (babylonBuffer) { + var size = GLTFLoader._GetNumComponents(context, accessor.type); + return new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer(engine, babylonBuffer, kind, false, false, bufferView_2.byteStride, false, accessor.byteOffset, size, accessor.componentType, accessor.normalized, true, 1, true); + }); + } + return accessor._babylonVertexBuffer[kind]; + }; + GLTFLoader.prototype._loadMaterialMetallicRoughnessPropertiesAsync = function (context, properties, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + if (properties) { + if (properties.baseColorFactor) { + babylonMaterial.albedoColor = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(properties.baseColorFactor); + babylonMaterial.alpha = properties.baseColorFactor[3]; + } + else { + babylonMaterial.albedoColor = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3.White(); + } + babylonMaterial.metallic = properties.metallicFactor == undefined ? 1 : properties.metallicFactor; + babylonMaterial.roughness = properties.roughnessFactor == undefined ? 1 : properties.roughnessFactor; + if (properties.baseColorTexture) { + promises.push(this.loadTextureInfoAsync("".concat(context, "/baseColorTexture"), properties.baseColorTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Base Color)"); + babylonMaterial.albedoTexture = texture; + })); + } + if (properties.metallicRoughnessTexture) { + properties.metallicRoughnessTexture.nonColorData = true; + promises.push(this.loadTextureInfoAsync("".concat(context, "/metallicRoughnessTexture"), properties.metallicRoughnessTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Metallic Roughness)"); + babylonMaterial.metallicTexture = texture; + })); + babylonMaterial.useMetallnessFromMetallicTextureBlue = true; + babylonMaterial.useRoughnessFromMetallicTextureGreen = true; + babylonMaterial.useRoughnessFromMetallicTextureAlpha = false; + } + } + return Promise.all(promises).then(function () { }); + }; + /** + * @internal + */ + GLTFLoader.prototype._loadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) { + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign); + if (extensionPromise) { + return extensionPromise; + } + material._data = material._data || {}; + var babylonData = material._data[babylonDrawMode]; + if (!babylonData) { + this.logOpen("".concat(context, " ").concat(material.name || "")); + var babylonMaterial = this.createMaterial(context, material, babylonDrawMode); + babylonData = { + babylonMaterial: babylonMaterial, + babylonMeshes: [], + promise: this.loadMaterialPropertiesAsync(context, material, babylonMaterial), + }; + material._data[babylonDrawMode] = babylonData; + GLTFLoader.AddPointerMetadata(babylonMaterial, context); + this._parent.onMaterialLoadedObservable.notifyObservers(babylonMaterial); + this.logClose(); + } + if (babylonMesh) { + babylonData.babylonMeshes.push(babylonMesh); + babylonMesh.onDisposeObservable.addOnce(function () { + var index = babylonData.babylonMeshes.indexOf(babylonMesh); + if (index !== -1) { + babylonData.babylonMeshes.splice(index, 1); + } + }); + } + assign(babylonData.babylonMaterial); + return babylonData.promise.then(function () { + return babylonData.babylonMaterial; + }); + }; + GLTFLoader.prototype._createDefaultMaterial = function (name, babylonDrawMode) { + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var babylonMaterial = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial(name, this._babylonScene); + babylonMaterial._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + // Moved to mesh so user can change materials on gltf meshes: babylonMaterial.sideOrientation = this._babylonScene.useRightHandedSystem ? Material.CounterClockWiseSideOrientation : Material.ClockWiseSideOrientation; + babylonMaterial.fillMode = babylonDrawMode; + babylonMaterial.enableSpecularAntiAliasing = true; + babylonMaterial.useRadianceOverAlpha = !this._parent.transparencyAsCoverage; + babylonMaterial.useSpecularOverAlpha = !this._parent.transparencyAsCoverage; + babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_OPAQUE; + babylonMaterial.metallic = 1; + babylonMaterial.roughness = 1; + return babylonMaterial; + }; + /** + * Creates a Babylon material from a glTF material. + * @param context The context when loading the asset + * @param material The glTF material property + * @param babylonDrawMode The draw mode for the Babylon material + * @returns The Babylon material + */ + GLTFLoader.prototype.createMaterial = function (context, material, babylonDrawMode) { + var extensionPromise = this._extensionsCreateMaterial(context, material, babylonDrawMode); + if (extensionPromise) { + return extensionPromise; + } + var name = material.name || "material".concat(material.index); + var babylonMaterial = this._createDefaultMaterial(name, babylonDrawMode); + return babylonMaterial; + }; + /** + * Loads properties from a glTF material into a Babylon material. + * @param context The context when loading the asset + * @param material The glTF material property + * @param babylonMaterial The Babylon material + * @returns A promise that resolves when the load is complete + */ + GLTFLoader.prototype.loadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + var extensionPromise = this._extensionsLoadMaterialPropertiesAsync(context, material, babylonMaterial); + if (extensionPromise) { + return extensionPromise; + } + var promises = new Array(); + promises.push(this.loadMaterialBasePropertiesAsync(context, material, babylonMaterial)); + if (material.pbrMetallicRoughness) { + promises.push(this._loadMaterialMetallicRoughnessPropertiesAsync("".concat(context, "/pbrMetallicRoughness"), material.pbrMetallicRoughness, babylonMaterial)); + } + this.loadMaterialAlphaProperties(context, material, babylonMaterial); + return Promise.all(promises).then(function () { }); + }; + /** + * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material. + * @param context The context when loading the asset + * @param material The glTF material property + * @param babylonMaterial The Babylon material + * @returns A promise that resolves when the load is complete + */ + GLTFLoader.prototype.loadMaterialBasePropertiesAsync = function (context, material, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var promises = new Array(); + babylonMaterial.emissiveColor = material.emissiveFactor ? babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3.FromArray(material.emissiveFactor) : new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Color3(0, 0, 0); + if (material.doubleSided) { + babylonMaterial.backFaceCulling = false; + babylonMaterial.twoSidedLighting = true; + } + if (material.normalTexture) { + material.normalTexture.nonColorData = true; + promises.push(this.loadTextureInfoAsync("".concat(context, "/normalTexture"), material.normalTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Normal)"); + babylonMaterial.bumpTexture = texture; + })); + babylonMaterial.invertNormalMapX = !this._babylonScene.useRightHandedSystem; + babylonMaterial.invertNormalMapY = this._babylonScene.useRightHandedSystem; + if (material.normalTexture.scale != undefined && babylonMaterial.bumpTexture) { + babylonMaterial.bumpTexture.level = material.normalTexture.scale; + } + babylonMaterial.forceIrradianceInFragment = true; + } + if (material.occlusionTexture) { + material.occlusionTexture.nonColorData = true; + promises.push(this.loadTextureInfoAsync("".concat(context, "/occlusionTexture"), material.occlusionTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Occlusion)"); + babylonMaterial.ambientTexture = texture; + })); + babylonMaterial.useAmbientInGrayScale = true; + if (material.occlusionTexture.strength != undefined) { + babylonMaterial.ambientTextureStrength = material.occlusionTexture.strength; + } + } + if (material.emissiveTexture) { + promises.push(this.loadTextureInfoAsync("".concat(context, "/emissiveTexture"), material.emissiveTexture, function (texture) { + texture.name = "".concat(babylonMaterial.name, " (Emissive)"); + babylonMaterial.emissiveTexture = texture; + })); + } + return Promise.all(promises).then(function () { }); + }; + /** + * Loads the alpha properties from a glTF material into a Babylon material. + * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture. + * @param context The context when loading the asset + * @param material The glTF material property + * @param babylonMaterial The Babylon material + */ + GLTFLoader.prototype.loadMaterialAlphaProperties = function (context, material, babylonMaterial) { + if (!(babylonMaterial instanceof babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial)) { + throw new Error("".concat(context, ": Material type not supported")); + } + var alphaMode = material.alphaMode || "OPAQUE" /* MaterialAlphaMode.OPAQUE */; + switch (alphaMode) { + case "OPAQUE" /* MaterialAlphaMode.OPAQUE */: { + babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_OPAQUE; + break; + } + case "MASK" /* MaterialAlphaMode.MASK */: { + babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_ALPHATEST; + babylonMaterial.alphaCutOff = material.alphaCutoff == undefined ? 0.5 : material.alphaCutoff; + if (babylonMaterial.albedoTexture) { + babylonMaterial.albedoTexture.hasAlpha = true; + } + break; + } + case "BLEND" /* MaterialAlphaMode.BLEND */: { + babylonMaterial.transparencyMode = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.PBRMaterial.PBRMATERIAL_ALPHABLEND; + if (babylonMaterial.albedoTexture) { + babylonMaterial.albedoTexture.hasAlpha = true; + babylonMaterial.useAlphaFromAlbedoTexture = true; + } + break; + } + default: { + throw new Error("".concat(context, "/alphaMode: Invalid value (").concat(material.alphaMode, ")")); + } + } + }; + /** + * Loads a glTF texture info. + * @param context The context when loading the asset + * @param textureInfo The glTF texture info property + * @param assign A function called synchronously after parsing the glTF properties + * @returns A promise that resolves with the loaded Babylon texture when the load is complete + */ + GLTFLoader.prototype.loadTextureInfoAsync = function (context, textureInfo, assign) { + var _this = this; + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadTextureInfoAsync(context, textureInfo, assign); + if (extensionPromise) { + return extensionPromise; + } + this.logOpen("".concat(context)); + if (textureInfo.texCoord >= 6) { + throw new Error("".concat(context, "/texCoord: Invalid value (").concat(textureInfo.texCoord, ")")); + } + var texture = ArrayItem.Get("".concat(context, "/index"), this._gltf.textures, textureInfo.index); + texture._textureInfo = textureInfo; + var promise = this._loadTextureAsync("/textures/".concat(textureInfo.index), texture, function (babylonTexture) { + babylonTexture.coordinatesIndex = textureInfo.texCoord || 0; + GLTFLoader.AddPointerMetadata(babylonTexture, context); + _this._parent.onTextureLoadedObservable.notifyObservers(babylonTexture); + assign(babylonTexture); + }); + this.logClose(); + return promise; + }; + /** + * @internal + */ + GLTFLoader.prototype._loadTextureAsync = function (context, texture, assign) { + if (assign === void 0) { assign = function () { }; } + var extensionPromise = this._extensionsLoadTextureAsync(context, texture, assign); + if (extensionPromise) { + return extensionPromise; + } + this.logOpen("".concat(context, " ").concat(texture.name || "")); + var sampler = texture.sampler == undefined ? GLTFLoader.DefaultSampler : ArrayItem.Get("".concat(context, "/sampler"), this._gltf.samplers, texture.sampler); + var image = ArrayItem.Get("".concat(context, "/source"), this._gltf.images, texture.source); + var promise = this._createTextureAsync(context, sampler, image, assign, undefined, !texture._textureInfo.nonColorData); + this.logClose(); + return promise; + }; + /** + * @internal + */ + GLTFLoader.prototype._createTextureAsync = function (context, sampler, image, assign, textureLoaderOptions, useSRGBBuffer) { + var _this = this; + if (assign === void 0) { assign = function () { }; } + var samplerData = this._loadSampler("/samplers/".concat(sampler.index), sampler); + var promises = new Array(); + var deferred = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Deferred(); + this._babylonScene._blockEntityCollection = !!this._assetContainer; + var textureCreationOptions = { + noMipmap: samplerData.noMipMaps, + invertY: false, + samplingMode: samplerData.samplingMode, + onLoad: function () { + if (!_this._disposed) { + deferred.resolve(); + } + }, + onError: function (message, exception) { + if (!_this._disposed) { + deferred.reject(new Error("".concat(context, ": ").concat(exception && exception.message ? exception.message : message || "Failed to load texture"))); + } + }, + mimeType: image.mimeType, + loaderOptions: textureLoaderOptions, + useSRGBBuffer: !!useSRGBBuffer && this._parent.useSRGBBuffers, + }; + var babylonTexture = new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture(null, this._babylonScene, textureCreationOptions); + babylonTexture._parentContainer = this._assetContainer; + this._babylonScene._blockEntityCollection = false; + promises.push(deferred.promise); + promises.push(this.loadImageAsync("/images/".concat(image.index), image).then(function (data) { + var name = image.uri || "".concat(_this._fileName, "#image").concat(image.index); + var dataUrl = "data:".concat(_this._uniqueRootUrl).concat(name); + babylonTexture.updateURL(dataUrl, data); + })); + babylonTexture.wrapU = samplerData.wrapU; + babylonTexture.wrapV = samplerData.wrapV; + assign(babylonTexture); + return Promise.all(promises).then(function () { + return babylonTexture; + }); + }; + GLTFLoader.prototype._loadSampler = function (context, sampler) { + if (!sampler._data) { + sampler._data = { + noMipMaps: sampler.minFilter === 9728 /* TextureMinFilter.NEAREST */ || sampler.minFilter === 9729 /* TextureMinFilter.LINEAR */, + samplingMode: GLTFLoader._GetTextureSamplingMode(context, sampler), + wrapU: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapS"), sampler.wrapS), + wrapV: GLTFLoader._GetTextureWrapMode("".concat(context, "/wrapT"), sampler.wrapT), + }; + } + return sampler._data; + }; + /** + * Loads a glTF image. + * @param context The context when loading the asset + * @param image The glTF image property + * @returns A promise that resolves with the loaded data when the load is complete + */ + GLTFLoader.prototype.loadImageAsync = function (context, image) { + if (!image._data) { + this.logOpen("".concat(context, " ").concat(image.name || "")); + if (image.uri) { + image._data = this.loadUriAsync("".concat(context, "/uri"), image, image.uri); + } + else { + var bufferView = ArrayItem.Get("".concat(context, "/bufferView"), this._gltf.bufferViews, image.bufferView); + image._data = this.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView); + } + this.logClose(); + } + return image._data; + }; + /** + * Loads a glTF uri. + * @param context The context when loading the asset + * @param property The glTF property associated with the uri + * @param uri The base64 or relative uri + * @returns A promise that resolves with the loaded data when the load is complete + */ + GLTFLoader.prototype.loadUriAsync = function (context, property, uri) { + var _this = this; + var extensionPromise = this._extensionsLoadUriAsync(context, property, uri); + if (extensionPromise) { + return extensionPromise; + } + if (!GLTFLoader._ValidateUri(uri)) { + throw new Error("".concat(context, ": '").concat(uri, "' is invalid")); + } + if ((0,babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.IsBase64DataUrl)(uri)) { + var data = new Uint8Array((0,babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.DecodeBase64UrlToBinary)(uri)); + this.log("".concat(context, ": Decoded ").concat(uri.substr(0, 64), "... (").concat(data.length, " bytes)")); + return Promise.resolve(data); + } + this.log("".concat(context, ": Loading ").concat(uri)); + return this._parent.preprocessUrlAsync(this._rootUrl + uri).then(function (url) { + return new Promise(function (resolve, reject) { + _this._parent._loadFile(_this._babylonScene, url, function (data) { + if (!_this._disposed) { + _this.log("".concat(context, ": Loaded ").concat(uri, " (").concat(data.byteLength, " bytes)")); + resolve(new Uint8Array(data)); + } + }, true, function (request) { + reject(new babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.LoadFileError("".concat(context, ": Failed to load '").concat(uri, "'").concat(request ? ": " + request.status + " " + request.statusText : ""), request)); + }); + }); + }); + }; + /** + * Adds a JSON pointer to the _internalMetadata of the Babylon object at `._internalMetadata.gltf.pointers`. + * @param babylonObject the Babylon object with _internalMetadata + * @param pointer the JSON pointer + */ + GLTFLoader.AddPointerMetadata = function (babylonObject, pointer) { + babylonObject.metadata = babylonObject.metadata || {}; + var metadata = (babylonObject._internalMetadata = babylonObject._internalMetadata || {}); + var gltf = (metadata.gltf = metadata.gltf || {}); + var pointers = (gltf.pointers = gltf.pointers || []); + pointers.push(pointer); + }; + GLTFLoader._GetTextureWrapMode = function (context, mode) { + // Set defaults if undefined + mode = mode == undefined ? 10497 /* TextureWrapMode.REPEAT */ : mode; + switch (mode) { + case 33071 /* TextureWrapMode.CLAMP_TO_EDGE */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.CLAMP_ADDRESSMODE; + case 33648 /* TextureWrapMode.MIRRORED_REPEAT */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.MIRROR_ADDRESSMODE; + case 10497 /* TextureWrapMode.REPEAT */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.WRAP_ADDRESSMODE; + default: + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Invalid value (").concat(mode, ")")); + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.WRAP_ADDRESSMODE; + } + }; + GLTFLoader._GetTextureSamplingMode = function (context, sampler) { + // Set defaults if undefined + var magFilter = sampler.magFilter == undefined ? 9729 /* TextureMagFilter.LINEAR */ : sampler.magFilter; + var minFilter = sampler.minFilter == undefined ? 9987 /* TextureMinFilter.LINEAR_MIPMAP_LINEAR */ : sampler.minFilter; + if (magFilter === 9729 /* TextureMagFilter.LINEAR */) { + switch (minFilter) { + case 9728 /* TextureMinFilter.NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST; + case 9729 /* TextureMinFilter.LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR; + case 9984 /* TextureMinFilter.NEAREST_MIPMAP_NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST_MIPNEAREST; + case 9985 /* TextureMinFilter.LINEAR_MIPMAP_NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPNEAREST; + case 9986 /* TextureMinFilter.NEAREST_MIPMAP_LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_NEAREST_MIPLINEAR; + case 9987 /* TextureMinFilter.LINEAR_MIPMAP_LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPLINEAR; + default: + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/minFilter: Invalid value (").concat(minFilter, ")")); + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.LINEAR_LINEAR_MIPLINEAR; + } + } + else { + if (magFilter !== 9728 /* TextureMagFilter.NEAREST */) { + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/magFilter: Invalid value (").concat(magFilter, ")")); + } + switch (minFilter) { + case 9728 /* TextureMinFilter.NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST; + case 9729 /* TextureMinFilter.LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR; + case 9984 /* TextureMinFilter.NEAREST_MIPMAP_NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPNEAREST; + case 9985 /* TextureMinFilter.LINEAR_MIPMAP_NEAREST */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR_MIPNEAREST; + case 9986 /* TextureMinFilter.NEAREST_MIPMAP_LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPLINEAR; + case 9987 /* TextureMinFilter.LINEAR_MIPMAP_LINEAR */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_LINEAR_MIPLINEAR; + default: + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, "/minFilter: Invalid value (").concat(minFilter, ")")); + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Texture.NEAREST_NEAREST_MIPNEAREST; + } + } + }; + GLTFLoader._GetTypedArrayConstructor = function (context, componentType) { + switch (componentType) { + case 5120 /* AccessorComponentType.BYTE */: + return Int8Array; + case 5121 /* AccessorComponentType.UNSIGNED_BYTE */: + return Uint8Array; + case 5122 /* AccessorComponentType.SHORT */: + return Int16Array; + case 5123 /* AccessorComponentType.UNSIGNED_SHORT */: + return Uint16Array; + case 5125 /* AccessorComponentType.UNSIGNED_INT */: + return Uint32Array; + case 5126 /* AccessorComponentType.FLOAT */: + return Float32Array; + default: + throw new Error("".concat(context, ": Invalid component type ").concat(componentType)); + } + }; + GLTFLoader._GetTypedArray = function (context, componentType, bufferView, byteOffset, length) { + var buffer = bufferView.buffer; + byteOffset = bufferView.byteOffset + (byteOffset || 0); + var constructor = GLTFLoader._GetTypedArrayConstructor("".concat(context, "/componentType"), componentType); + var componentTypeLength = babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.GetTypeByteLength(componentType); + if (byteOffset % componentTypeLength !== 0) { + // HACK: Copy the buffer if byte offset is not a multiple of component type byte length. + babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("".concat(context, ": Copying buffer as byte offset (").concat(byteOffset, ") is not a multiple of component type byte length (").concat(componentTypeLength, ")")); + return new constructor(buffer.slice(byteOffset, byteOffset + length * componentTypeLength), 0); + } + return new constructor(buffer, byteOffset, length); + }; + GLTFLoader._GetNumComponents = function (context, type) { + switch (type) { + case "SCALAR": + return 1; + case "VEC2": + return 2; + case "VEC3": + return 3; + case "VEC4": + return 4; + case "MAT2": + return 4; + case "MAT3": + return 9; + case "MAT4": + return 16; + } + throw new Error("".concat(context, ": Invalid type (").concat(type, ")")); + }; + GLTFLoader._ValidateUri = function (uri) { + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Tools.IsBase64(uri) || uri.indexOf("..") === -1; + }; + /** + * @internal + */ + GLTFLoader._GetDrawMode = function (context, mode) { + if (mode == undefined) { + mode = 4 /* MeshPrimitiveMode.TRIANGLES */; + } + switch (mode) { + case 0 /* MeshPrimitiveMode.POINTS */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.PointListDrawMode; + case 1 /* MeshPrimitiveMode.LINES */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.LineListDrawMode; + case 2 /* MeshPrimitiveMode.LINE_LOOP */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.LineLoopDrawMode; + case 3 /* MeshPrimitiveMode.LINE_STRIP */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.LineStripDrawMode; + case 4 /* MeshPrimitiveMode.TRIANGLES */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFillMode; + case 5 /* MeshPrimitiveMode.TRIANGLE_STRIP */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleStripDrawMode; + case 6 /* MeshPrimitiveMode.TRIANGLE_FAN */: + return babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.Material.TriangleFanDrawMode; + } + throw new Error("".concat(context, ": Invalid mesh primitive mode (").concat(mode, ")")); + }; + GLTFLoader.prototype._compileMaterialsAsync = function () { + var _this = this; + this._parent._startPerformanceCounter("Compile materials"); + var promises = new Array(); + if (this._gltf.materials) { + for (var _i = 0, _a = this._gltf.materials; _i < _a.length; _i++) { + var material = _a[_i]; + if (material._data) { + for (var babylonDrawMode in material._data) { + var babylonData = material._data[babylonDrawMode]; + for (var _b = 0, _c = babylonData.babylonMeshes; _b < _c.length; _b++) { + var babylonMesh = _c[_b]; + // Ensure nonUniformScaling is set if necessary. + babylonMesh.computeWorldMatrix(true); + var babylonMaterial = babylonData.babylonMaterial; + promises.push(babylonMaterial.forceCompilationAsync(babylonMesh)); + promises.push(babylonMaterial.forceCompilationAsync(babylonMesh, { useInstances: true })); + if (this._parent.useClipPlane) { + promises.push(babylonMaterial.forceCompilationAsync(babylonMesh, { clipPlane: true })); + promises.push(babylonMaterial.forceCompilationAsync(babylonMesh, { clipPlane: true, useInstances: true })); + } + } + } + } + } + } + return Promise.all(promises).then(function () { + _this._parent._endPerformanceCounter("Compile materials"); + }); + }; + GLTFLoader.prototype._compileShadowGeneratorsAsync = function () { + var _this = this; + this._parent._startPerformanceCounter("Compile shadow generators"); + var promises = new Array(); + var lights = this._babylonScene.lights; + for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) { + var light = lights_1[_i]; + var generator = light.getShadowGenerator(); + if (generator) { + promises.push(generator.forceCompilationAsync()); + } + } + return Promise.all(promises).then(function () { + _this._parent._endPerformanceCounter("Compile shadow generators"); + }); + }; + GLTFLoader.prototype._forEachExtensions = function (action) { + for (var _i = 0, _a = this._extensions; _i < _a.length; _i++) { + var extension = _a[_i]; + if (extension.enabled) { + action(extension); + } + } + }; + GLTFLoader.prototype._applyExtensions = function (property, functionName, actionAsync) { + for (var _i = 0, _a = this._extensions; _i < _a.length; _i++) { + var extension = _a[_i]; + if (extension.enabled) { + var id = "".concat(extension.name, ".").concat(functionName); + var loaderProperty = property; + loaderProperty._activeLoaderExtensionFunctions = loaderProperty._activeLoaderExtensionFunctions || {}; + var activeLoaderExtensionFunctions = loaderProperty._activeLoaderExtensionFunctions; + if (!activeLoaderExtensionFunctions[id]) { + activeLoaderExtensionFunctions[id] = true; + try { + var result = actionAsync(extension); + if (result) { + return result; + } + } + finally { + delete activeLoaderExtensionFunctions[id]; + } + } + } + } + return null; + }; + GLTFLoader.prototype._extensionsOnLoading = function () { + this._forEachExtensions(function (extension) { return extension.onLoading && extension.onLoading(); }); + }; + GLTFLoader.prototype._extensionsOnReady = function () { + this._forEachExtensions(function (extension) { return extension.onReady && extension.onReady(); }); + }; + GLTFLoader.prototype._extensionsLoadSceneAsync = function (context, scene) { + return this._applyExtensions(scene, "loadScene", function (extension) { return extension.loadSceneAsync && extension.loadSceneAsync(context, scene); }); + }; + GLTFLoader.prototype._extensionsLoadNodeAsync = function (context, node, assign) { + return this._applyExtensions(node, "loadNode", function (extension) { return extension.loadNodeAsync && extension.loadNodeAsync(context, node, assign); }); + }; + GLTFLoader.prototype._extensionsLoadCameraAsync = function (context, camera, assign) { + return this._applyExtensions(camera, "loadCamera", function (extension) { return extension.loadCameraAsync && extension.loadCameraAsync(context, camera, assign); }); + }; + GLTFLoader.prototype._extensionsLoadVertexDataAsync = function (context, primitive, babylonMesh) { + return this._applyExtensions(primitive, "loadVertexData", function (extension) { return extension._loadVertexDataAsync && extension._loadVertexDataAsync(context, primitive, babylonMesh); }); + }; + GLTFLoader.prototype._extensionsLoadMeshPrimitiveAsync = function (context, name, node, mesh, primitive, assign) { + return this._applyExtensions(primitive, "loadMeshPrimitive", function (extension) { return extension._loadMeshPrimitiveAsync && extension._loadMeshPrimitiveAsync(context, name, node, mesh, primitive, assign); }); + }; + GLTFLoader.prototype._extensionsLoadMaterialAsync = function (context, material, babylonMesh, babylonDrawMode, assign) { + return this._applyExtensions(material, "loadMaterial", function (extension) { return extension._loadMaterialAsync && extension._loadMaterialAsync(context, material, babylonMesh, babylonDrawMode, assign); }); + }; + GLTFLoader.prototype._extensionsCreateMaterial = function (context, material, babylonDrawMode) { + return this._applyExtensions(material, "createMaterial", function (extension) { return extension.createMaterial && extension.createMaterial(context, material, babylonDrawMode); }); + }; + GLTFLoader.prototype._extensionsLoadMaterialPropertiesAsync = function (context, material, babylonMaterial) { + return this._applyExtensions(material, "loadMaterialProperties", function (extension) { return extension.loadMaterialPropertiesAsync && extension.loadMaterialPropertiesAsync(context, material, babylonMaterial); }); + }; + GLTFLoader.prototype._extensionsLoadTextureInfoAsync = function (context, textureInfo, assign) { + return this._applyExtensions(textureInfo, "loadTextureInfo", function (extension) { return extension.loadTextureInfoAsync && extension.loadTextureInfoAsync(context, textureInfo, assign); }); + }; + GLTFLoader.prototype._extensionsLoadTextureAsync = function (context, texture, assign) { + return this._applyExtensions(texture, "loadTexture", function (extension) { return extension._loadTextureAsync && extension._loadTextureAsync(context, texture, assign); }); + }; + GLTFLoader.prototype._extensionsLoadAnimationAsync = function (context, animation) { + return this._applyExtensions(animation, "loadAnimation", function (extension) { return extension.loadAnimationAsync && extension.loadAnimationAsync(context, animation); }); + }; + GLTFLoader.prototype._extensionsLoadAnimationChannelAsync = function (context, animationContext, animation, channel, onLoad) { + return this._applyExtensions(animation, "loadAnimationChannel", function (extension) { return extension._loadAnimationChannelAsync && extension._loadAnimationChannelAsync(context, animationContext, animation, channel, onLoad); }); + }; + GLTFLoader.prototype._extensionsLoadSkinAsync = function (context, node, skin) { + return this._applyExtensions(skin, "loadSkin", function (extension) { return extension._loadSkinAsync && extension._loadSkinAsync(context, node, skin); }); + }; + GLTFLoader.prototype._extensionsLoadUriAsync = function (context, property, uri) { + return this._applyExtensions(property, "loadUri", function (extension) { return extension._loadUriAsync && extension._loadUriAsync(context, property, uri); }); + }; + GLTFLoader.prototype._extensionsLoadBufferViewAsync = function (context, bufferView) { + return this._applyExtensions(bufferView, "loadBufferView", function (extension) { return extension.loadBufferViewAsync && extension.loadBufferViewAsync(context, bufferView); }); + }; + GLTFLoader.prototype._extensionsLoadBufferAsync = function (context, buffer, byteOffset, byteLength) { + return this._applyExtensions(buffer, "loadBuffer", function (extension) { return extension.loadBufferAsync && extension.loadBufferAsync(context, buffer, byteOffset, byteLength); }); + }; + /** + * Helper method called by a loader extension to load an glTF extension. + * @param context The context when loading the asset + * @param property The glTF property to load the extension from + * @param extensionName The name of the extension to load + * @param actionAsync The action to run + * @returns The promise returned by actionAsync or null if the extension does not exist + */ + GLTFLoader.LoadExtensionAsync = function (context, property, extensionName, actionAsync) { + if (!property.extensions) { + return null; + } + var extensions = property.extensions; + var extension = extensions[extensionName]; + if (!extension) { + return null; + } + return actionAsync("".concat(context, "/extensions/").concat(extensionName), extension); + }; + /** + * Helper method called by a loader extension to load a glTF extra. + * @param context The context when loading the asset + * @param property The glTF property to load the extra from + * @param extensionName The name of the extension to load + * @param actionAsync The action to run + * @returns The promise returned by actionAsync or null if the extra does not exist + */ + GLTFLoader.LoadExtraAsync = function (context, property, extensionName, actionAsync) { + if (!property.extras) { + return null; + } + var extras = property.extras; + var extra = extras[extensionName]; + if (!extra) { + return null; + } + return actionAsync("".concat(context, "/extras/").concat(extensionName), extra); + }; + /** + * Checks for presence of an extension. + * @param name The name of the extension to check + * @returns A boolean indicating the presence of the given extension name in `extensionsUsed` + */ + GLTFLoader.prototype.isExtensionUsed = function (name) { + return !!this._gltf.extensionsUsed && this._gltf.extensionsUsed.indexOf(name) !== -1; + }; + /** + * Increments the indentation level and logs a message. + * @param message The message to log + */ + GLTFLoader.prototype.logOpen = function (message) { + this._parent._logOpen(message); + }; + /** + * Decrements the indentation level. + */ + GLTFLoader.prototype.logClose = function () { + this._parent._logClose(); + }; + /** + * Logs a message + * @param message The message to log + */ + GLTFLoader.prototype.log = function (message) { + this._parent._log(message); + }; + /** + * Starts a performance counter. + * @param counterName The name of the performance counter + */ + GLTFLoader.prototype.startPerformanceCounter = function (counterName) { + this._parent._startPerformanceCounter(counterName); + }; + /** + * Ends a performance counter. + * @param counterName The name of the performance counter + */ + GLTFLoader.prototype.endPerformanceCounter = function (counterName) { + this._parent._endPerformanceCounter(counterName); + }; + GLTFLoader._RegisteredExtensions = {}; + /** + * The default glTF sampler. + */ + GLTFLoader.DefaultSampler = { index: -1 }; + return GLTFLoader; +}()); +_glTFFileLoader__WEBPACK_IMPORTED_MODULE_1__.GLTFFileLoader._CreateGLTF2Loader = function (parent) { return new GLTFLoader(parent); }; + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts": +/*!****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/glTFLoaderAnimation.ts ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ AnimationPropertyInfo: () => (/* binding */ AnimationPropertyInfo), +/* harmony export */ TransformNodeAnimationPropertyInfo: () => (/* binding */ TransformNodeAnimationPropertyInfo), +/* harmony export */ WeightAnimationPropertyInfo: () => (/* binding */ WeightAnimationPropertyInfo), +/* harmony export */ getQuaternion: () => (/* binding */ getQuaternion), +/* harmony export */ getVector3: () => (/* binding */ getVector3), +/* harmony export */ getWeights: () => (/* binding */ getWeights), +/* harmony export */ nodeAnimationData: () => (/* binding */ nodeAnimationData) +/* harmony export */ }); +/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! tslib */ "../../../../node_modules/tslib/tslib.es6.mjs"); +/* harmony import */ var babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Maths/math.vector */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__); + + + +/** @internal */ +function getVector3(_target, source, offset, scale) { + return babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Vector3.FromArray(source, offset).scaleInPlace(scale); +} +/** @internal */ +function getQuaternion(_target, source, offset, scale) { + return babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Quaternion.FromArray(source, offset).scaleInPlace(scale); +} +/** @internal */ +function getWeights(target, source, offset, scale) { + var value = new Array(target._numMorphTargets); + for (var i = 0; i < value.length; i++) { + value[i] = source[offset++] * scale; + } + return value; +} +/** @internal */ +var AnimationPropertyInfo = /** @class */ (function () { + /** @internal */ + function AnimationPropertyInfo(type, name, getValue, getStride) { + this.type = type; + this.name = name; + this.getValue = getValue; + this.getStride = getStride; + } + AnimationPropertyInfo.prototype._buildAnimation = function (name, fps, keys) { + var babylonAnimation = new babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation(name, this.name, fps, this.type); + babylonAnimation.setKeys(keys); + return babylonAnimation; + }; + return AnimationPropertyInfo; +}()); + +/** @internal */ +var TransformNodeAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__extends)(TransformNodeAnimationPropertyInfo, _super); + function TransformNodeAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + /** @internal */ + TransformNodeAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + callback(target._babylonTransformNode, this._buildAnimation(name, fps, keys)); + }; + return TransformNodeAnimationPropertyInfo; +}(AnimationPropertyInfo)); + +/** @internal */ +var WeightAnimationPropertyInfo = /** @class */ (function (_super) { + (0,tslib__WEBPACK_IMPORTED_MODULE_1__.__extends)(WeightAnimationPropertyInfo, _super); + function WeightAnimationPropertyInfo() { + return _super !== null && _super.apply(this, arguments) || this; + } + WeightAnimationPropertyInfo.prototype.buildAnimations = function (target, name, fps, keys, callback) { + if (target._numMorphTargets) { + var _loop_1 = function (targetIndex) { + var babylonAnimation = new babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation("".concat(name, "_").concat(targetIndex), this_1.name, fps, this_1.type); + babylonAnimation.setKeys(keys.map(function (key) { return ({ + frame: key.frame, + inTangent: key.inTangent ? key.inTangent[targetIndex] : undefined, + value: key.value[targetIndex], + outTangent: key.outTangent ? key.outTangent[targetIndex] : undefined, + interpolation: key.interpolation, + }); })); + if (target._primitiveBabylonMeshes) { + for (var _i = 0, _a = target._primitiveBabylonMeshes; _i < _a.length; _i++) { + var babylonMesh = _a[_i]; + if (babylonMesh.morphTargetManager) { + var morphTarget = babylonMesh.morphTargetManager.getTarget(targetIndex); + var babylonAnimationClone = babylonAnimation.clone(); + morphTarget.animations.push(babylonAnimationClone); + callback(morphTarget, babylonAnimationClone); + } + } + } + }; + var this_1 = this; + for (var targetIndex = 0; targetIndex < target._numMorphTargets; targetIndex++) { + _loop_1(targetIndex); + } + } + }; + return WeightAnimationPropertyInfo; +}(AnimationPropertyInfo)); + +/** @internal */ +var nodeAnimationData = { + translation: [new TransformNodeAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_VECTOR3, "position", getVector3, function () { return 3; })], + rotation: [new TransformNodeAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_QUATERNION, "rotationQuaternion", getQuaternion, function () { return 4; })], + scale: [new TransformNodeAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_VECTOR3, "scaling", getVector3, function () { return 3; })], + weights: [new WeightAnimationPropertyInfo(babylonjs_Animations_animation__WEBPACK_IMPORTED_MODULE_0__.Animation.ANIMATIONTYPE_FLOAT, "influence", getWeights, function (target) { return target._numMorphTargets; })], +}; + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/glTFLoaderExtension.ts": +/*!****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/glTFLoaderExtension.ts ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts": +/*!*****************************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts ***! + \*****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/2.0/index.ts": +/*!**************************************************!*\ + !*** ../../../dev/loaders/src/glTF/2.0/index.ts ***! + \**************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ ArrayItem: () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.ArrayItem), +/* harmony export */ EXT_lights_image_based: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_lights_image_based), +/* harmony export */ EXT_mesh_gpu_instancing: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_mesh_gpu_instancing), +/* harmony export */ EXT_meshopt_compression: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_meshopt_compression), +/* harmony export */ EXT_texture_webp: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.EXT_texture_webp), +/* harmony export */ ExtrasAsMetadata: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.ExtrasAsMetadata), +/* harmony export */ GLTFLoader: () => (/* reexport safe */ _glTFLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoader), +/* harmony export */ KHR_animation_pointer: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_animation_pointer), +/* harmony export */ KHR_draco_mesh_compression: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_draco_mesh_compression), +/* harmony export */ KHR_lights: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_lights), +/* harmony export */ KHR_materials_anisotropy: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_anisotropy), +/* harmony export */ KHR_materials_clearcoat: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_clearcoat), +/* harmony export */ KHR_materials_emissive_strength: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_emissive_strength), +/* harmony export */ KHR_materials_ior: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_ior), +/* harmony export */ KHR_materials_iridescence: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_iridescence), +/* harmony export */ KHR_materials_pbrSpecularGlossiness: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_pbrSpecularGlossiness), +/* harmony export */ KHR_materials_sheen: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_sheen), +/* harmony export */ KHR_materials_specular: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_specular), +/* harmony export */ KHR_materials_translucency: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_translucency), +/* harmony export */ KHR_materials_transmission: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_transmission), +/* harmony export */ KHR_materials_unlit: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_unlit), +/* harmony export */ KHR_materials_variants: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_variants), +/* harmony export */ KHR_materials_volume: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_materials_volume), +/* harmony export */ KHR_mesh_quantization: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_mesh_quantization), +/* harmony export */ KHR_texture_basisu: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_texture_basisu), +/* harmony export */ KHR_texture_transform: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_texture_transform), +/* harmony export */ KHR_xmp_json_ld: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.KHR_xmp_json_ld), +/* harmony export */ MSFT_audio_emitter: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_audio_emitter), +/* harmony export */ MSFT_lod: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_lod), +/* harmony export */ MSFT_minecraftMesh: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_minecraftMesh), +/* harmony export */ MSFT_sRGBFactors: () => (/* reexport safe */ _Extensions_index__WEBPACK_IMPORTED_MODULE_3__.MSFT_sRGBFactors) +/* harmony export */ }); +/* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts"); +/* harmony import */ var _glTFLoaderExtension__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFLoaderExtension */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderExtension.ts"); +/* harmony import */ var _glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glTFLoaderInterfaces */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts"); +/* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Extensions/index */ "../../../dev/loaders/src/glTF/2.0/Extensions/index.ts"); +/* eslint-disable import/no-internal-modules */ + + + + + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/glTFFileLoader.ts": +/*!*******************************************************!*\ + !*** ../../../dev/loaders/src/glTF/glTFFileLoader.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFFileLoader: () => (/* binding */ GLTFFileLoader), +/* harmony export */ GLTFLoaderAnimationStartMode: () => (/* binding */ GLTFLoaderAnimationStartMode), +/* harmony export */ GLTFLoaderCoordinateSystemMode: () => (/* binding */ GLTFLoaderCoordinateSystemMode), +/* harmony export */ GLTFLoaderState: () => (/* binding */ GLTFLoaderState) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/error */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__); +/* harmony import */ var _glTFValidation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./glTFValidation */ "../../../dev/loaders/src/glTF/glTFValidation.ts"); + + + + + + + + + +function readAsync(arrayBuffer, byteOffset, byteLength) { + try { + return Promise.resolve(new Uint8Array(arrayBuffer, byteOffset, byteLength)); + } + catch (e) { + return Promise.reject(e); + } +} +function readViewAsync(arrayBufferView, byteOffset, byteLength) { + try { + if (arrayBufferView.byteOffset + byteLength > arrayBufferView.byteLength) { + throw new Error("Array length out of bounds."); + } + return Promise.resolve(new Uint8Array(arrayBufferView.buffer, arrayBufferView.byteOffset + byteOffset, byteLength)); + } + catch (e) { + return Promise.reject(e); + } +} +/** + * Mode that determines the coordinate system to use. + */ +var GLTFLoaderCoordinateSystemMode; +(function (GLTFLoaderCoordinateSystemMode) { + /** + * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene. + */ + GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["AUTO"] = 0] = "AUTO"; + /** + * Sets the useRightHandedSystem flag on the scene. + */ + GLTFLoaderCoordinateSystemMode[GLTFLoaderCoordinateSystemMode["FORCE_RIGHT_HANDED"] = 1] = "FORCE_RIGHT_HANDED"; +})(GLTFLoaderCoordinateSystemMode || (GLTFLoaderCoordinateSystemMode = {})); +/** + * Mode that determines what animations will start. + */ +var GLTFLoaderAnimationStartMode; +(function (GLTFLoaderAnimationStartMode) { + /** + * No animation will start. + */ + GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["NONE"] = 0] = "NONE"; + /** + * The first animation will start. + */ + GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["FIRST"] = 1] = "FIRST"; + /** + * All animations will start. + */ + GLTFLoaderAnimationStartMode[GLTFLoaderAnimationStartMode["ALL"] = 2] = "ALL"; +})(GLTFLoaderAnimationStartMode || (GLTFLoaderAnimationStartMode = {})); +/** + * Loader state. + */ +var GLTFLoaderState; +(function (GLTFLoaderState) { + /** + * The asset is loading. + */ + GLTFLoaderState[GLTFLoaderState["LOADING"] = 0] = "LOADING"; + /** + * The asset is ready for rendering. + */ + GLTFLoaderState[GLTFLoaderState["READY"] = 1] = "READY"; + /** + * The asset is completely loaded. + */ + GLTFLoaderState[GLTFLoaderState["COMPLETE"] = 2] = "COMPLETE"; +})(GLTFLoaderState || (GLTFLoaderState = {})); +/** + * File loader for loading glTF files into a scene. + */ +var GLTFFileLoader = /** @class */ (function () { + function GLTFFileLoader() { + // -------------- + // Common options + // -------------- + /** + * Raised when the asset has been parsed + */ + this.onParsedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + // ---------- + // V2 options + // ---------- + /** + * The coordinate system mode. Defaults to AUTO. + */ + this.coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO; + /** + * The animation start mode. Defaults to FIRST. + */ + this.animationStartMode = GLTFLoaderAnimationStartMode.FIRST; + /** + * Defines if the loader should compile materials before raising the success callback. Defaults to false. + */ + this.compileMaterials = false; + /** + * Defines if the loader should also compile materials with clip planes. Defaults to false. + */ + this.useClipPlane = false; + /** + * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false. + */ + this.compileShadowGenerators = false; + /** + * Defines if the Alpha blended materials are only applied as coverage. + * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials. + * If true, no extra effects are applied to transparent pixels. + */ + this.transparencyAsCoverage = false; + /** + * Defines if the loader should use range requests when load binary glTF files from HTTP. + * Enabling will disable offline support and glTF validator. + * Defaults to false. + */ + this.useRangeRequests = false; + /** + * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true. + */ + this.createInstances = true; + /** + * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false. + */ + this.alwaysComputeBoundingBox = false; + /** + * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false. + */ + this.loadAllMaterials = false; + /** + * If true, load only the materials defined in the file. Defaults to false. + */ + this.loadOnlyMaterials = false; + /** + * If true, do not load any materials defined in the file. Defaults to false. + */ + this.skipMaterials = false; + /** + * If true, load the color (gamma encoded) textures into sRGB buffers (if supported by the GPU), which will yield more accurate results when sampling the texture. Defaults to true. + */ + this.useSRGBBuffers = true; + /** + * When loading glTF animations, which are defined in seconds, target them to this FPS. Defaults to 60. + */ + this.targetFps = 60; + /** + * Defines if the loader should always compute the nearest common ancestor of the skeleton joints instead of using `skin.skeleton`. Defaults to false. + * Set this to true if loading assets with invalid `skin.skeleton` values. + */ + this.alwaysComputeSkeletonRootNode = false; + /** + * Function called before loading a url referenced by the asset. + * @param url + */ + this.preprocessUrlAsync = function (url) { return Promise.resolve(url); }; + /** + * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh. + * Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...) + */ + this.onMeshLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Callback raised when the loader creates a skin after parsing the glTF properties of the skin node. + * @see https://doc.babylonjs.com/features/featuresDeepDive/importers/glTF/glTFSkinning#ignoring-the-transform-of-the-skinned-mesh + * @param node - the transform node that corresponds to the original glTF skin node used for animations + * @param skinnedNode - the transform node that is the skinned mesh itself or the parent of the skinned meshes + */ + this.onSkinLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when the loader creates a texture after parsing the glTF properties of the texture. + */ + this.onTextureLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when the loader creates a material after parsing the glTF properties of the material. + */ + this.onMaterialLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when the loader creates a camera after parsing the glTF properties of the camera. + */ + this.onCameraLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when the asset is completely loaded, immediately before the loader is disposed. + * For assets with LODs, raised when all of the LODs are complete. + * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise. + */ + this.onCompleteObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised when an error occurs. + */ + this.onErrorObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised after the loader is disposed. + */ + this.onDisposeObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Observable raised after a loader extension is created. + * Set additional options for a loader extension in this event. + */ + this.onExtensionLoadedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + /** + * Defines if the loader should validate the asset. + */ + this.validate = false; + /** + * Observable raised after validation when validate is set to true. The event data is the result of the validation. + */ + this.onValidatedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + this._loader = null; + this._state = null; + this._requests = new Array(); + /** + * Name of the loader ("gltf") + */ + this.name = "gltf"; + /** @internal */ + this.extensions = { + ".gltf": { isBinary: false }, + ".glb": { isBinary: true }, + }; + /** + * Observable raised when the loader state changes. + */ + this.onLoaderStateChangedObservable = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(); + this._logIndentLevel = 0; + this._loggingEnabled = false; + /** @internal */ + this._log = this._logDisabled; + this._capturePerformanceCounters = false; + /** @internal */ + this._startPerformanceCounter = this._startPerformanceCounterDisabled; + /** @internal */ + this._endPerformanceCounter = this._endPerformanceCounterDisabled; + } + Object.defineProperty(GLTFFileLoader.prototype, "onParsed", { + /** + * Raised when the asset has been parsed + */ + set: function (callback) { + if (this._onParsedObserver) { + this.onParsedObservable.remove(this._onParsedObserver); + } + this._onParsedObserver = this.onParsedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onMeshLoaded", { + /** + * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh. + * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...) + */ + set: function (callback) { + if (this._onMeshLoadedObserver) { + this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver); + } + this._onMeshLoadedObserver = this.onMeshLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onTextureLoaded", { + /** + * Callback raised when the loader creates a texture after parsing the glTF properties of the texture. + */ + set: function (callback) { + if (this._onTextureLoadedObserver) { + this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver); + } + this._onTextureLoadedObserver = this.onTextureLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onMaterialLoaded", { + /** + * Callback raised when the loader creates a material after parsing the glTF properties of the material. + */ + set: function (callback) { + if (this._onMaterialLoadedObserver) { + this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver); + } + this._onMaterialLoadedObserver = this.onMaterialLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onCameraLoaded", { + /** + * Callback raised when the loader creates a camera after parsing the glTF properties of the camera. + */ + set: function (callback) { + if (this._onCameraLoadedObserver) { + this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver); + } + this._onCameraLoadedObserver = this.onCameraLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onComplete", { + /** + * Callback raised when the asset is completely loaded, immediately before the loader is disposed. + * For assets with LODs, raised when all of the LODs are complete. + * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise. + */ + set: function (callback) { + if (this._onCompleteObserver) { + this.onCompleteObservable.remove(this._onCompleteObserver); + } + this._onCompleteObserver = this.onCompleteObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onError", { + /** + * Callback raised when an error occurs. + */ + set: function (callback) { + if (this._onErrorObserver) { + this.onErrorObservable.remove(this._onErrorObserver); + } + this._onErrorObserver = this.onErrorObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onDispose", { + /** + * Callback raised after the loader is disposed. + */ + set: function (callback) { + if (this._onDisposeObserver) { + this.onDisposeObservable.remove(this._onDisposeObserver); + } + this._onDisposeObserver = this.onDisposeObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onExtensionLoaded", { + /** + * Callback raised after a loader extension is created. + */ + set: function (callback) { + if (this._onExtensionLoadedObserver) { + this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver); + } + this._onExtensionLoadedObserver = this.onExtensionLoadedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "loggingEnabled", { + /** + * Defines if the loader logging is enabled. + */ + get: function () { + return this._loggingEnabled; + }, + set: function (value) { + if (this._loggingEnabled === value) { + return; + } + this._loggingEnabled = value; + if (this._loggingEnabled) { + this._log = this._logEnabled; + } + else { + this._log = this._logDisabled; + } + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "capturePerformanceCounters", { + /** + * Defines if the loader should capture performance counters. + */ + get: function () { + return this._capturePerformanceCounters; + }, + set: function (value) { + if (this._capturePerformanceCounters === value) { + return; + } + this._capturePerformanceCounters = value; + if (this._capturePerformanceCounters) { + this._startPerformanceCounter = this._startPerformanceCounterEnabled; + this._endPerformanceCounter = this._endPerformanceCounterEnabled; + } + else { + this._startPerformanceCounter = this._startPerformanceCounterDisabled; + this._endPerformanceCounter = this._endPerformanceCounterDisabled; + } + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(GLTFFileLoader.prototype, "onValidated", { + /** + * Callback raised after a loader extension is created. + */ + set: function (callback) { + if (this._onValidatedObserver) { + this.onValidatedObservable.remove(this._onValidatedObserver); + } + this._onValidatedObserver = this.onValidatedObservable.add(callback); + }, + enumerable: false, + configurable: true + }); + /** + * Disposes the loader, releases resources during load, and cancels any outstanding requests. + */ + GLTFFileLoader.prototype.dispose = function () { + if (this._loader) { + this._loader.dispose(); + this._loader = null; + } + for (var _i = 0, _a = this._requests; _i < _a.length; _i++) { + var request = _a[_i]; + request.abort(); + } + this._requests.length = 0; + delete this._progressCallback; + this.preprocessUrlAsync = function (url) { return Promise.resolve(url); }; + this.onMeshLoadedObservable.clear(); + this.onSkinLoadedObservable.clear(); + this.onTextureLoadedObservable.clear(); + this.onMaterialLoadedObservable.clear(); + this.onCameraLoadedObservable.clear(); + this.onCompleteObservable.clear(); + this.onExtensionLoadedObservable.clear(); + this.onDisposeObservable.notifyObservers(undefined); + this.onDisposeObservable.clear(); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.loadFile = function (scene, fileOrUrl, rootUrl, onSuccess, onProgress, useArrayBuffer, onError, name) { + var _this = this; + if (ArrayBuffer.isView(fileOrUrl)) { + this._loadBinary(scene, fileOrUrl, rootUrl, onSuccess, onError, name); + return null; + } + this._progressCallback = onProgress; + var fileName = fileOrUrl.name || babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.GetFilename(fileOrUrl); + if (useArrayBuffer) { + if (this.useRangeRequests) { + if (this.validate) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("glTF validation is not supported when range requests are enabled"); + } + var fileRequest_1 = { + abort: function () { }, + onCompleteObservable: new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Observable(), + }; + var dataBuffer = { + readAsync: function (byteOffset, byteLength) { + return new Promise(function (resolve, reject) { + _this._loadFile(scene, fileOrUrl, function (data) { + resolve(new Uint8Array(data)); + }, true, function (error) { + reject(error); + }, function (webRequest) { + webRequest.setRequestHeader("Range", "bytes=".concat(byteOffset, "-").concat(byteOffset + byteLength - 1)); + }); + }); + }, + byteLength: 0, + }; + this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader(dataBuffer)).then(function (loaderData) { + fileRequest_1.onCompleteObservable.notifyObservers(fileRequest_1); + onSuccess(loaderData); + }, onError ? function (error) { return onError(undefined, error); } : undefined); + return fileRequest_1; + } + return this._loadFile(scene, fileOrUrl, function (data) { + _this._validate(scene, new Uint8Array(data), rootUrl, fileName); + _this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader({ + readAsync: function (byteOffset, byteLength) { return readAsync(data, byteOffset, byteLength); }, + byteLength: data.byteLength, + })).then(function (loaderData) { + onSuccess(loaderData); + }, onError ? function (error) { return onError(undefined, error); } : undefined); + }, true, onError); + } + return this._loadFile(scene, fileOrUrl, function (data) { + _this._validate(scene, new Uint8Array(data), rootUrl, fileName); + onSuccess({ json: _this._parseJson(data) }); + }, useArrayBuffer, onError); + }; + /** + * @internal + */ + GLTFFileLoader.prototype._loadBinary = function (scene, data, rootUrl, onSuccess, onError, fileName) { + this._validate(scene, data, rootUrl, fileName); + this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader({ + readAsync: function (byteOffset, byteLength) { return readViewAsync(data, byteOffset, byteLength); }, + byteLength: data.byteLength, + })).then(function (loaderData) { + onSuccess(loaderData); + }, onError ? function (error) { return onError(undefined, error); } : undefined); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.importMeshAsync = function (meshesNames, scene, data, rootUrl, onProgress, fileName) { + var _this = this; + return Promise.resolve().then(function () { + _this.onParsedObservable.notifyObservers(data); + _this.onParsedObservable.clear(); + _this._log("Loading ".concat(fileName || "")); + _this._loader = _this._getLoader(data); + return _this._loader.importMeshAsync(meshesNames, scene, null, data, rootUrl, onProgress, fileName); + }); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.loadAsync = function (scene, data, rootUrl, onProgress, fileName) { + var _this = this; + return Promise.resolve().then(function () { + _this.onParsedObservable.notifyObservers(data); + _this.onParsedObservable.clear(); + _this._log("Loading ".concat(fileName || "")); + _this._loader = _this._getLoader(data); + return _this._loader.loadAsync(scene, data, rootUrl, onProgress, fileName); + }); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.loadAssetContainerAsync = function (scene, data, rootUrl, onProgress, fileName) { + var _this = this; + return Promise.resolve().then(function () { + _this.onParsedObservable.notifyObservers(data); + _this.onParsedObservable.clear(); + _this._log("Loading ".concat(fileName || "")); + _this._loader = _this._getLoader(data); + // Prepare the asset container. + var container = new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.AssetContainer(scene); + // Get materials/textures when loading to add to container + var materials = []; + _this.onMaterialLoadedObservable.add(function (material) { + materials.push(material); + }); + var textures = []; + _this.onTextureLoadedObservable.add(function (texture) { + textures.push(texture); + }); + var cameras = []; + _this.onCameraLoadedObservable.add(function (camera) { + cameras.push(camera); + }); + var morphTargetManagers = []; + _this.onMeshLoadedObservable.add(function (mesh) { + if (mesh.morphTargetManager) { + morphTargetManagers.push(mesh.morphTargetManager); + } + }); + return _this._loader.importMeshAsync(null, scene, container, data, rootUrl, onProgress, fileName).then(function (result) { + Array.prototype.push.apply(container.geometries, result.geometries); + Array.prototype.push.apply(container.meshes, result.meshes); + Array.prototype.push.apply(container.particleSystems, result.particleSystems); + Array.prototype.push.apply(container.skeletons, result.skeletons); + Array.prototype.push.apply(container.animationGroups, result.animationGroups); + Array.prototype.push.apply(container.materials, materials); + Array.prototype.push.apply(container.textures, textures); + Array.prototype.push.apply(container.lights, result.lights); + Array.prototype.push.apply(container.transformNodes, result.transformNodes); + Array.prototype.push.apply(container.cameras, cameras); + Array.prototype.push.apply(container.morphTargetManagers, morphTargetManagers); + return container; + }); + }); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.canDirectLoad = function (data) { + return ((data.indexOf("asset") !== -1 && data.indexOf("version") !== -1) || + data.startsWith("data:base64," + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat. + data.startsWith("data:;base64," + GLTFFileLoader._MagicBase64Encoded) || + data.startsWith("data:application/octet-stream;base64," + GLTFFileLoader._MagicBase64Encoded) || + data.startsWith("data:model/gltf-binary;base64," + GLTFFileLoader._MagicBase64Encoded)); + }; + /** + * @internal + */ + GLTFFileLoader.prototype.directLoad = function (scene, data) { + if (data.startsWith("base64," + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat. + data.startsWith(";base64," + GLTFFileLoader._MagicBase64Encoded) || + data.startsWith("application/octet-stream;base64," + GLTFFileLoader._MagicBase64Encoded) || + data.startsWith("model/gltf-binary;base64," + GLTFFileLoader._MagicBase64Encoded)) { + var arrayBuffer_1 = (0,babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DecodeBase64UrlToBinary)(data); + this._validate(scene, new Uint8Array(arrayBuffer_1)); + return this._unpackBinaryAsync(new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.DataReader({ + readAsync: function (byteOffset, byteLength) { return readAsync(arrayBuffer_1, byteOffset, byteLength); }, + byteLength: arrayBuffer_1.byteLength, + })); + } + this._validate(scene, data); + return Promise.resolve({ json: this._parseJson(data) }); + }; + /** @internal */ + GLTFFileLoader.prototype.createPlugin = function () { + return new GLTFFileLoader(); + }; + Object.defineProperty(GLTFFileLoader.prototype, "loaderState", { + /** + * The loader state or null if the loader is not active. + */ + get: function () { + return this._state; + }, + enumerable: false, + configurable: true + }); + /** + * Returns a promise that resolves when the asset is completely loaded. + * @returns a promise that resolves when the asset is completely loaded. + */ + GLTFFileLoader.prototype.whenCompleteAsync = function () { + var _this = this; + return new Promise(function (resolve, reject) { + _this.onCompleteObservable.addOnce(function () { + resolve(); + }); + _this.onErrorObservable.addOnce(function (reason) { + reject(reason); + }); + }); + }; + /** + * @internal + */ + GLTFFileLoader.prototype._setState = function (state) { + if (this._state === state) { + return; + } + this._state = state; + this.onLoaderStateChangedObservable.notifyObservers(this._state); + this._log(GLTFLoaderState[this._state]); + }; + /** + * @internal + */ + GLTFFileLoader.prototype._loadFile = function (scene, fileOrUrl, onSuccess, useArrayBuffer, onError, onOpened) { + var _this = this; + var request = scene._loadFile(fileOrUrl, onSuccess, function (event) { + _this._onProgress(event, request); + }, true, useArrayBuffer, onError, onOpened); + request.onCompleteObservable.add(function (request) { + _this._requests.splice(_this._requests.indexOf(request), 1); + }); + this._requests.push(request); + return request; + }; + GLTFFileLoader.prototype._onProgress = function (event, request) { + if (!this._progressCallback) { + return; + } + request._lengthComputable = event.lengthComputable; + request._loaded = event.loaded; + request._total = event.total; + var lengthComputable = true; + var loaded = 0; + var total = 0; + for (var _i = 0, _a = this._requests; _i < _a.length; _i++) { + var request_1 = _a[_i]; + if (request_1._lengthComputable === undefined || request_1._loaded === undefined || request_1._total === undefined) { + return; + } + lengthComputable = lengthComputable && request_1._lengthComputable; + loaded += request_1._loaded; + total += request_1._total; + } + this._progressCallback({ + lengthComputable: lengthComputable, + loaded: loaded, + total: lengthComputable ? total : 0, + }); + }; + GLTFFileLoader.prototype._validate = function (scene, data, rootUrl, fileName) { + var _this = this; + if (rootUrl === void 0) { rootUrl = ""; } + if (fileName === void 0) { fileName = ""; } + if (!this.validate) { + return; + } + this._startPerformanceCounter("Validate JSON"); + _glTFValidation__WEBPACK_IMPORTED_MODULE_1__.GLTFValidation.ValidateAsync(data, rootUrl, fileName, function (uri) { + return _this.preprocessUrlAsync(rootUrl + uri).then(function (url) { return scene._loadFileAsync(url, undefined, true, true); }); + }).then(function (result) { + _this._endPerformanceCounter("Validate JSON"); + _this.onValidatedObservable.notifyObservers(result); + _this.onValidatedObservable.clear(); + }, function (reason) { + _this._endPerformanceCounter("Validate JSON"); + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.Warn("Failed to validate: ".concat(reason.message)); + _this.onValidatedObservable.clear(); + }); + }; + GLTFFileLoader.prototype._getLoader = function (loaderData) { + var asset = loaderData.json.asset || {}; + this._log("Asset version: ".concat(asset.version)); + asset.minVersion && this._log("Asset minimum version: ".concat(asset.minVersion)); + asset.generator && this._log("Asset generator: ".concat(asset.generator)); + var version = GLTFFileLoader._parseVersion(asset.version); + if (!version) { + throw new Error("Invalid version: " + asset.version); + } + if (asset.minVersion !== undefined) { + var minVersion = GLTFFileLoader._parseVersion(asset.minVersion); + if (!minVersion) { + throw new Error("Invalid minimum version: " + asset.minVersion); + } + if (GLTFFileLoader._compareVersion(minVersion, { major: 2, minor: 0 }) > 0) { + throw new Error("Incompatible minimum version: " + asset.minVersion); + } + } + var createLoaders = { + 1: GLTFFileLoader._CreateGLTF1Loader, + 2: GLTFFileLoader._CreateGLTF2Loader, + }; + var createLoader = createLoaders[version.major]; + if (!createLoader) { + throw new Error("Unsupported version: " + asset.version); + } + return createLoader(this); + }; + GLTFFileLoader.prototype._parseJson = function (json) { + this._startPerformanceCounter("Parse JSON"); + this._log("JSON length: ".concat(json.length)); + var parsed = JSON.parse(json); + this._endPerformanceCounter("Parse JSON"); + return parsed; + }; + GLTFFileLoader.prototype._unpackBinaryAsync = function (dataReader) { + var _this = this; + this._startPerformanceCounter("Unpack Binary"); + // Read magic + version + length + json length + json format + return dataReader.loadAsync(20).then(function () { + var Binary = { + Magic: 0x46546c67, + }; + var magic = dataReader.readUint32(); + if (magic !== Binary.Magic) { + throw new babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.RuntimeError("Unexpected magic: " + magic, babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.ErrorCodes.GLTFLoaderUnexpectedMagicError); + } + var version = dataReader.readUint32(); + if (_this.loggingEnabled) { + _this._log("Binary version: ".concat(version)); + } + var length = dataReader.readUint32(); + if (!_this.useRangeRequests && length !== dataReader.buffer.byteLength) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Logger.Warn("Length in header does not match actual data length: ".concat(length, " != ").concat(dataReader.buffer.byteLength)); + } + var unpacked; + switch (version) { + case 1: { + unpacked = _this._unpackBinaryV1Async(dataReader, length); + break; + } + case 2: { + unpacked = _this._unpackBinaryV2Async(dataReader, length); + break; + } + default: { + throw new Error("Unsupported version: " + version); + } + } + _this._endPerformanceCounter("Unpack Binary"); + return unpacked; + }); + }; + GLTFFileLoader.prototype._unpackBinaryV1Async = function (dataReader, length) { + var ContentFormat = { + JSON: 0, + }; + var contentLength = dataReader.readUint32(); + var contentFormat = dataReader.readUint32(); + if (contentFormat !== ContentFormat.JSON) { + throw new Error("Unexpected content format: ".concat(contentFormat)); + } + var bodyLength = length - dataReader.byteOffset; + var data = { json: this._parseJson(dataReader.readString(contentLength)), bin: null }; + if (bodyLength !== 0) { + var startByteOffset_1 = dataReader.byteOffset; + data.bin = { + readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_1 + byteOffset, byteLength); }, + byteLength: bodyLength, + }; + } + return Promise.resolve(data); + }; + GLTFFileLoader.prototype._unpackBinaryV2Async = function (dataReader, length) { + var _this = this; + var ChunkFormat = { + JSON: 0x4e4f534a, + BIN: 0x004e4942, + }; + // Read the JSON chunk header. + var chunkLength = dataReader.readUint32(); + var chunkFormat = dataReader.readUint32(); + if (chunkFormat !== ChunkFormat.JSON) { + throw new Error("First chunk format is not JSON"); + } + // Bail if there are no other chunks. + if (dataReader.byteOffset + chunkLength === length) { + return dataReader.loadAsync(chunkLength).then(function () { + return { json: _this._parseJson(dataReader.readString(chunkLength)), bin: null }; + }); + } + // Read the JSON chunk and the length and type of the next chunk. + return dataReader.loadAsync(chunkLength + 8).then(function () { + var data = { json: _this._parseJson(dataReader.readString(chunkLength)), bin: null }; + var readAsync = function () { + var chunkLength = dataReader.readUint32(); + var chunkFormat = dataReader.readUint32(); + switch (chunkFormat) { + case ChunkFormat.JSON: { + throw new Error("Unexpected JSON chunk"); + } + case ChunkFormat.BIN: { + var startByteOffset_2 = dataReader.byteOffset; + data.bin = { + readAsync: function (byteOffset, byteLength) { return dataReader.buffer.readAsync(startByteOffset_2 + byteOffset, byteLength); }, + byteLength: chunkLength, + }; + dataReader.skipBytes(chunkLength); + break; + } + default: { + // ignore unrecognized chunkFormat + dataReader.skipBytes(chunkLength); + break; + } + } + if (dataReader.byteOffset !== length) { + return dataReader.loadAsync(8).then(readAsync); + } + return Promise.resolve(data); + }; + return readAsync(); + }); + }; + GLTFFileLoader._parseVersion = function (version) { + if (version === "1.0" || version === "1.0.1") { + return { + major: 1, + minor: 0, + }; + } + var match = (version + "").match(/^(\d+)\.(\d+)/); + if (!match) { + return null; + } + return { + major: parseInt(match[1]), + minor: parseInt(match[2]), + }; + }; + GLTFFileLoader._compareVersion = function (a, b) { + if (a.major > b.major) { + return 1; + } + if (a.major < b.major) { + return -1; + } + if (a.minor > b.minor) { + return 1; + } + if (a.minor < b.minor) { + return -1; + } + return 0; + }; + /** + * @internal + */ + GLTFFileLoader.prototype._logOpen = function (message) { + this._log(message); + this._logIndentLevel++; + }; + /** @internal */ + GLTFFileLoader.prototype._logClose = function () { + --this._logIndentLevel; + }; + GLTFFileLoader.prototype._logEnabled = function (message) { + var spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2); + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Logger.Log("".concat(spaces).concat(message)); + }; + GLTFFileLoader.prototype._logDisabled = function (message) { }; + GLTFFileLoader.prototype._startPerformanceCounterEnabled = function (counterName) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.StartPerformanceCounter(counterName); + }; + GLTFFileLoader.prototype._startPerformanceCounterDisabled = function (counterName) { }; + GLTFFileLoader.prototype._endPerformanceCounterEnabled = function (counterName) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.Tools.EndPerformanceCounter(counterName); + }; + GLTFFileLoader.prototype._endPerformanceCounterDisabled = function (counterName) { }; + // ---------- + // V1 options + // ---------- + /** + * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders. + * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled. + * Defaults to true. + * @internal + */ + GLTFFileLoader.IncrementalLoading = true; + /** + * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters. + * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates. + * @internal + */ + GLTFFileLoader.HomogeneousCoordinates = false; + GLTFFileLoader._MagicBase64Encoded = "Z2xURg"; // "glTF" base64 encoded (without the quotes!) + GLTFFileLoader._logSpaces = " "; + return GLTFFileLoader; +}()); +if (babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.SceneLoader) { + babylonjs_Misc_observable__WEBPACK_IMPORTED_MODULE_0__.SceneLoader.RegisterPlugin(new GLTFFileLoader()); +} + + +/***/ }), + +/***/ "../../../dev/loaders/src/glTF/glTFValidation.ts": +/*!*******************************************************!*\ + !*** ../../../dev/loaders/src/glTF/glTFValidation.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFValidation: () => (/* binding */ GLTFValidation) +/* harmony export */ }); +/* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Misc/tools */ "babylonjs/Misc/observable"); +/* harmony import */ var babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__); + +function validateAsync(data, rootUrl, fileName, getExternalResource) { + var options = { + externalResourceFunction: function (uri) { return getExternalResource(uri).then(function (value) { return new Uint8Array(value); }); }, + }; + if (fileName) { + options.uri = rootUrl === "file:" ? fileName : rootUrl + fileName; + } + return data instanceof ArrayBuffer ? GLTFValidator.validateBytes(new Uint8Array(data), options) : GLTFValidator.validateString(data, options); +} +/** + * The worker function that gets converted to a blob url to pass into a worker. + */ +function workerFunc() { + var pendingExternalResources = []; + onmessage = function (message) { + var data = message.data; + switch (data.id) { + case "init": { + importScripts(data.url); + break; + } + case "validate": { + validateAsync(data.data, data.rootUrl, data.fileName, function (uri) { + return new Promise(function (resolve, reject) { + var index = pendingExternalResources.length; + pendingExternalResources.push({ resolve: resolve, reject: reject }); + postMessage({ id: "getExternalResource", index: index, uri: uri }); + }); + }).then(function (value) { + postMessage({ id: "validate.resolve", value: value }); + }, function (reason) { + postMessage({ id: "validate.reject", reason: reason }); + }); + break; + } + case "getExternalResource.resolve": { + pendingExternalResources[data.index].resolve(data.value); + break; + } + case "getExternalResource.reject": { + pendingExternalResources[data.index].reject(data.reason); + break; + } + } + }; +} +/** + * glTF validation + */ +var GLTFValidation = /** @class */ (function () { + function GLTFValidation() { + } + /** + * Validate a glTF asset using the glTF-Validator. + * @param data The JSON of a glTF or the array buffer of a binary glTF + * @param rootUrl The root url for the glTF + * @param fileName The file name for the glTF + * @param getExternalResource The callback to get external resources for the glTF validator + * @returns A promise that resolves with the glTF validation results once complete + */ + GLTFValidation.ValidateAsync = function (data, rootUrl, fileName, getExternalResource) { + var _this = this; + var dataCopy = ArrayBuffer.isView(data) ? data.slice().buffer : data; + if (typeof Worker === "function") { + return new Promise(function (resolve, reject) { + var workerContent = "".concat(validateAsync, "(").concat(workerFunc, ")()"); + var workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: "application/javascript" })); + var worker = new Worker(workerBlobUrl); + var onError = function (error) { + worker.removeEventListener("error", onError); + worker.removeEventListener("message", onMessage); + reject(error); + }; + var onMessage = function (message) { + var data = message.data; + switch (data.id) { + case "getExternalResource": { + getExternalResource(data.uri).then(function (value) { + worker.postMessage({ id: "getExternalResource.resolve", index: data.index, value: value }, [value]); + }, function (reason) { + worker.postMessage({ id: "getExternalResource.reject", index: data.index, reason: reason }); + }); + break; + } + case "validate.resolve": { + worker.removeEventListener("error", onError); + worker.removeEventListener("message", onMessage); + resolve(data.value); + worker.terminate(); + break; + } + case "validate.reject": { + worker.removeEventListener("error", onError); + worker.removeEventListener("message", onMessage); + reject(data.reason); + worker.terminate(); + } + } + }; + worker.addEventListener("error", onError); + worker.addEventListener("message", onMessage); + worker.postMessage({ id: "init", url: _this.Configuration.url }); + worker.postMessage({ id: "validate", data: dataCopy, rootUrl: rootUrl, fileName: fileName }); + }); + } + else { + if (!this._LoadScriptPromise) { + this._LoadScriptPromise = babylonjs_Misc_tools__WEBPACK_IMPORTED_MODULE_0__.Tools.LoadScriptAsync(this.Configuration.url); + } + return this._LoadScriptPromise.then(function () { + return validateAsync(dataCopy, rootUrl, fileName, getExternalResource); + }); + } + }; + /** + * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`. + */ + GLTFValidation.Configuration = { + url: "https://preview.babylonjs.com/gltf_validator.js", + }; + return GLTFValidation; +}()); + + +/***/ }), + +/***/ "../../../lts/loaders/src/legacy/legacy-glTF.ts": +/*!******************************************************!*\ + !*** ../../../lts/loaders/src/legacy/legacy-glTF.ts ***! + \******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTFFileLoader: () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFFileLoader), +/* harmony export */ GLTFLoaderAnimationStartMode: () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderAnimationStartMode), +/* harmony export */ GLTFLoaderCoordinateSystemMode: () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderCoordinateSystemMode), +/* harmony export */ GLTFLoaderState: () => (/* reexport safe */ loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderState), +/* harmony export */ GLTFValidation: () => (/* reexport safe */ loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__.GLTFValidation) +/* harmony export */ }); +/* harmony import */ var loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! loaders/glTF/glTFFileLoader */ "../../../dev/loaders/src/glTF/glTFFileLoader.ts"); +/* harmony import */ var loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! loaders/glTF/glTFValidation */ "../../../dev/loaders/src/glTF/glTFValidation.ts"); + + +/** + * This is the entry point for the UMD module. + * The entry point for a future ESM package should be index.ts + */ +var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined; +if (typeof globalObject !== "undefined") { + globalObject.BABYLON = globalObject.BABYLON || {}; + for (var key in loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__) { + globalObject.BABYLON[key] = loaders_glTF_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__[key]; + } + for (var key in loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__) { + globalObject.BABYLON[key] = loaders_glTF_glTFValidation__WEBPACK_IMPORTED_MODULE_1__[key]; + } +} + + + + +/***/ }), + +/***/ "../../../lts/loaders/src/legacy/legacy-glTF1.ts": +/*!*******************************************************!*\ + !*** ../../../lts/loaders/src/legacy/legacy-glTF1.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTF1: () => (/* reexport module object */ loaders_glTF_1_0_index__WEBPACK_IMPORTED_MODULE_0__) +/* harmony export */ }); +/* harmony import */ var loaders_glTF_1_0_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! loaders/glTF/1.0/index */ "../../../dev/loaders/src/glTF/1.0/index.ts"); +/* eslint-disable import/no-internal-modules */ + +/** + * This is the entry point for the UMD module. + * The entry point for a future ESM package should be index.ts + */ +var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined; +if (typeof globalObject !== "undefined") { + globalObject.BABYLON = globalObject.BABYLON || {}; + globalObject.BABYLON.GLTF1 = globalObject.BABYLON.GLTF1 || {}; + for (var key in loaders_glTF_1_0_index__WEBPACK_IMPORTED_MODULE_0__) { + globalObject.BABYLON.GLTF1[key] = loaders_glTF_1_0_index__WEBPACK_IMPORTED_MODULE_0__[key]; + } +} + + + +/***/ }), + +/***/ "../../../lts/loaders/src/legacy/legacy-glTF2.ts": +/*!*******************************************************!*\ + !*** ../../../lts/loaders/src/legacy/legacy-glTF2.ts ***! + \*******************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTF2: () => (/* reexport module object */ loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__) +/* harmony export */ }); +/* harmony import */ var loaders_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! loaders/glTF/2.0/Extensions/index */ "../../../dev/loaders/src/glTF/2.0/Extensions/index.ts"); +/* harmony import */ var loaders_glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! loaders/glTF/2.0/glTFLoaderInterfaces */ "../../../dev/loaders/src/glTF/2.0/glTFLoaderInterfaces.ts"); +/* harmony import */ var loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! loaders/glTF/2.0/index */ "../../../dev/loaders/src/glTF/2.0/index.ts"); +/* eslint-disable import/no-internal-modules */ + + + +/** + * This is the entry point for the UMD module. + * The entry point for a future ESM package should be index.ts + */ +var globalObject = typeof __webpack_require__.g !== "undefined" ? __webpack_require__.g : typeof window !== "undefined" ? window : undefined; +if (typeof globalObject !== "undefined") { + globalObject.BABYLON = globalObject.BABYLON || {}; + var BABYLON_1 = globalObject.BABYLON; + BABYLON_1.GLTF2 = BABYLON_1.GLTF2 || {}; + BABYLON_1.GLTF2.Loader = BABYLON_1.GLTF2.Loader || {}; + BABYLON_1.GLTF2.Loader.Extensions = BABYLON_1.GLTF2.Loader.Extensions || {}; + var keys = []; + for (var key in loaders_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_0__) { + BABYLON_1.GLTF2.Loader.Extensions[key] = loaders_glTF_2_0_Extensions_index__WEBPACK_IMPORTED_MODULE_0__[key]; + keys.push(key); + } + for (var key in loaders_glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__) { + BABYLON_1.GLTF2.Loader[key] = loaders_glTF_2_0_glTFLoaderInterfaces__WEBPACK_IMPORTED_MODULE_1__[key]; + keys.push(key); + } + for (var key in loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__) { + // Prevent Reassignment. + if (keys.indexOf(key) > -1) { + continue; + } + BABYLON_1.GLTF2[key] = loaders_glTF_2_0_index__WEBPACK_IMPORTED_MODULE_2__[key]; + } +} + + + +/***/ }), + +/***/ "../../../lts/loaders/src/legacy/legacy-glTFFileLoader.ts": +/*!****************************************************************!*\ + !*** ../../../lts/loaders/src/legacy/legacy-glTFFileLoader.ts ***! + \****************************************************************/ +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ GLTF1: () => (/* reexport safe */ _legacy_glTF1__WEBPACK_IMPORTED_MODULE_1__.GLTF1), +/* harmony export */ GLTF2: () => (/* reexport safe */ _legacy_glTF2__WEBPACK_IMPORTED_MODULE_2__.GLTF2), +/* harmony export */ GLTFFileLoader: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFFileLoader), +/* harmony export */ GLTFLoaderAnimationStartMode: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderAnimationStartMode), +/* harmony export */ GLTFLoaderCoordinateSystemMode: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderCoordinateSystemMode), +/* harmony export */ GLTFLoaderState: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFLoaderState), +/* harmony export */ GLTFValidation: () => (/* reexport safe */ _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__.GLTFValidation) +/* harmony export */ }); +/* harmony import */ var _legacy_glTF__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./legacy-glTF */ "../../../lts/loaders/src/legacy/legacy-glTF.ts"); +/* harmony import */ var _legacy_glTF1__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./legacy-glTF1 */ "../../../lts/loaders/src/legacy/legacy-glTF1.ts"); +/* harmony import */ var _legacy_glTF2__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./legacy-glTF2 */ "../../../lts/loaders/src/legacy/legacy-glTF2.ts"); +// eslint-disable-next-line import/export + + + + + +/***/ }), + +/***/ "babylonjs/Misc/observable": +/*!****************************************************************************************************!*\ + !*** external {"root":"BABYLON","commonjs":"babylonjs","commonjs2":"babylonjs","amd":"babylonjs"} ***! + \****************************************************************************************************/ +/***/ ((module) => { + +module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__; + +/***/ }), + +/***/ "../../../../node_modules/tslib/tslib.es6.mjs": +/*!****************************************************!*\ + !*** ../../../../node_modules/tslib/tslib.es6.mjs ***! + \****************************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ __addDisposableResource: () => (/* binding */ __addDisposableResource), +/* harmony export */ __assign: () => (/* binding */ __assign), +/* harmony export */ __asyncDelegator: () => (/* binding */ __asyncDelegator), +/* harmony export */ __asyncGenerator: () => (/* binding */ __asyncGenerator), +/* harmony export */ __asyncValues: () => (/* binding */ __asyncValues), +/* harmony export */ __await: () => (/* binding */ __await), +/* harmony export */ __awaiter: () => (/* binding */ __awaiter), +/* harmony export */ __classPrivateFieldGet: () => (/* binding */ __classPrivateFieldGet), +/* harmony export */ __classPrivateFieldIn: () => (/* binding */ __classPrivateFieldIn), +/* harmony export */ __classPrivateFieldSet: () => (/* binding */ __classPrivateFieldSet), +/* harmony export */ __createBinding: () => (/* binding */ __createBinding), +/* harmony export */ __decorate: () => (/* binding */ __decorate), +/* harmony export */ __disposeResources: () => (/* binding */ __disposeResources), +/* harmony export */ __esDecorate: () => (/* binding */ __esDecorate), +/* harmony export */ __exportStar: () => (/* binding */ __exportStar), +/* harmony export */ __extends: () => (/* binding */ __extends), +/* harmony export */ __generator: () => (/* binding */ __generator), +/* harmony export */ __importDefault: () => (/* binding */ __importDefault), +/* harmony export */ __importStar: () => (/* binding */ __importStar), +/* harmony export */ __makeTemplateObject: () => (/* binding */ __makeTemplateObject), +/* harmony export */ __metadata: () => (/* binding */ __metadata), +/* harmony export */ __param: () => (/* binding */ __param), +/* harmony export */ __propKey: () => (/* binding */ __propKey), +/* harmony export */ __read: () => (/* binding */ __read), +/* harmony export */ __rest: () => (/* binding */ __rest), +/* harmony export */ __runInitializers: () => (/* binding */ __runInitializers), +/* harmony export */ __setFunctionName: () => (/* binding */ __setFunctionName), +/* harmony export */ __spread: () => (/* binding */ __spread), +/* harmony export */ __spreadArray: () => (/* binding */ __spreadArray), +/* harmony export */ __spreadArrays: () => (/* binding */ __spreadArrays), +/* harmony export */ __values: () => (/* binding */ __values), +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/****************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ +/* global Reflect, Promise, SuppressedError, Symbol */ + +var extendStatics = function(d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); +}; + +function __extends(d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} + +var __assign = function() { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + return t; + } + return __assign.apply(this, arguments); +} + +function __rest(s, e) { + var t = {}; + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) + t[p] = s[p]; + if (s != null && typeof Object.getOwnPropertySymbols === "function") + for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) + t[p[i]] = s[p[i]]; + } + return t; +} + +function __decorate(decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} + +function __param(paramIndex, decorator) { + return function (target, key) { decorator(target, key, paramIndex); } +} + +function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { + function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } + var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; + var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; + var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); + var _, done = false; + for (var i = decorators.length - 1; i >= 0; i--) { + var context = {}; + for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; + for (var p in contextIn.access) context.access[p] = contextIn.access[p]; + context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; + var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); + if (kind === "accessor") { + if (result === void 0) continue; + if (result === null || typeof result !== "object") throw new TypeError("Object expected"); + if (_ = accept(result.get)) descriptor.get = _; + if (_ = accept(result.set)) descriptor.set = _; + if (_ = accept(result.init)) initializers.unshift(_); + } + else if (_ = accept(result)) { + if (kind === "field") initializers.unshift(_); + else descriptor[key] = _; + } + } + if (target) Object.defineProperty(target, contextIn.name, descriptor); + done = true; +}; + +function __runInitializers(thisArg, initializers, value) { + var useValue = arguments.length > 2; + for (var i = 0; i < initializers.length; i++) { + value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); + } + return useValue ? value : void 0; +}; + +function __propKey(x) { + return typeof x === "symbol" ? x : "".concat(x); +}; + +function __setFunctionName(f, name, prefix) { + if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; + return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); +}; + +function __metadata(metadataKey, metadataValue) { + if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); +} + +function __awaiter(thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +} + +function __generator(thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +} + +var __createBinding = Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +}); + +function __exportStar(m, o) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); +} + +function __values(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +} + +function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), r, ar = [], e; + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } + catch (error) { e = { error: error }; } + finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } + finally { if (e) throw e.error; } + } + return ar; +} + +/** @deprecated */ +function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) + ar = ar.concat(__read(arguments[i])); + return ar; +} + +/** @deprecated */ +function __spreadArrays() { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + for (var r = Array(s), k = 0, i = 0; i < il; i++) + for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) + r[k] = a[j]; + return r; +} + +function __spreadArray(to, from, pack) { + if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { + if (ar || !(i in from)) { + if (!ar) ar = Array.prototype.slice.call(from, 0, i); + ar[i] = from[i]; + } + } + return to.concat(ar || Array.prototype.slice.call(from)); +} + +function __await(v) { + return this instanceof __await ? (this.v = v, this) : new __await(v); +} + +function __asyncGenerator(thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +} + +function __asyncDelegator(o) { + var i, p; + return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; + function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; } +} + +function __asyncValues(o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +} + +function __makeTemplateObject(cooked, raw) { + if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } + return cooked; +}; + +var __setModuleDefault = Object.create ? (function(o, v) { + Object.defineProperty(o, "default", { enumerable: true, value: v }); +}) : function(o, v) { + o["default"] = v; +}; + +function __importStar(mod) { + if (mod && mod.__esModule) return mod; + var result = {}; + if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); + __setModuleDefault(result, mod); + return result; +} + +function __importDefault(mod) { + return (mod && mod.__esModule) ? mod : { default: mod }; +} + +function __classPrivateFieldGet(receiver, state, kind, f) { + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); + return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); +} + +function __classPrivateFieldSet(receiver, state, value, kind, f) { + if (kind === "m") throw new TypeError("Private method is not writable"); + if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); + if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); + return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; +} + +function __classPrivateFieldIn(state, receiver) { + if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object"); + return typeof state === "function" ? receiver === state : state.has(receiver); +} + +function __addDisposableResource(env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +} + +var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}; + +function __disposeResources(env) { + function fail(e) { + env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); +} + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = ({ + __extends, + __assign, + __rest, + __decorate, + __param, + __metadata, + __awaiter, + __generator, + __createBinding, + __exportStar, + __values, + __read, + __spread, + __spreadArrays, + __spreadArray, + __await, + __asyncGenerator, + __asyncDelegator, + __asyncValues, + __makeTemplateObject, + __importStar, + __importDefault, + __classPrivateFieldGet, + __classPrivateFieldSet, + __classPrivateFieldIn, + __addDisposableResource, + __disposeResources, +}); + + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ // no module.id needed +/******/ // no module.loaded needed +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ (() => { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = (module) => { +/******/ var getter = module && module.__esModule ? +/******/ () => (module['default']) : +/******/ () => (module); +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/global */ +/******/ (() => { +/******/ __webpack_require__.g = (function() { +/******/ if (typeof globalThis === 'object') return globalThis; +/******/ try { +/******/ return this || new Function('return this')(); +/******/ } catch (e) { +/******/ if (typeof window === 'object') return window; +/******/ } +/******/ })(); +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. +(() => { +/*!*******************************!*\ + !*** ./src/glTFFileLoader.ts ***! + \*******************************/ +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__), +/* harmony export */ loaders: () => (/* reexport module object */ _lts_loaders_legacy_legacy_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__) +/* harmony export */ }); +/* harmony import */ var _lts_loaders_legacy_legacy_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @lts/loaders/legacy/legacy-glTFFileLoader */ "../../../lts/loaders/src/legacy/legacy-glTFFileLoader.ts"); + + +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (_lts_loaders_legacy_legacy_glTFFileLoader__WEBPACK_IMPORTED_MODULE_0__); + +})(); + +__webpack_exports__ = __webpack_exports__["default"]; +/******/ return __webpack_exports__; +/******/ })() +; +}); +//# sourceMappingURL=babylon.glTFFileLoader.js.map \ No newline at end of file diff --git a/libs/babylonjs/6.23.0/babylon.glTFFileLoader.min.js b/libs/babylonjs/6.23.0/babylon.glTFFileLoader.min.js new file mode 100644 index 00000000..24cd00fa --- /dev/null +++ b/libs/babylonjs/6.23.0/babylon.glTFFileLoader.min.js @@ -0,0 +1,2 @@ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-loaders",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-loaders"]=t(require("babylonjs")):e.LOADERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var t={520:t=>{t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};return(()=>{r.d(o,{default:()=>Ft});var e={};r.r(e),r.d(e,{GLTFValidation:()=>_});var t={};r.r(t),r.d(t,{GLTFFileLoader:()=>y,GLTFLoaderAnimationStartMode:()=>h,GLTFLoaderCoordinateSystemMode:()=>f,GLTFLoaderState:()=>p});var n={};r.r(n),r.d(n,{EBlendingFunction:()=>w,EComponentType:()=>T,ECullingType:()=>C,EParameterType:()=>E,EShaderType:()=>x,ETextureFilterType:()=>M,ETextureFormat:()=>L,ETextureWrapMode:()=>O,GLTFBinaryExtension:()=>ne,GLTFLoader:()=>ee,GLTFLoaderBase:()=>$,GLTFLoaderExtension:()=>te,GLTFMaterialsCommonExtension:()=>re,GLTFUtils:()=>N});var a={};r.r(a),r.d(a,{EXT_lights_image_based:()=>_e,EXT_mesh_gpu_instancing:()=>ye,EXT_meshopt_compression:()=>ve,EXT_texture_webp:()=>be,ExtrasAsMetadata:()=>St,KHR_animation_pointer:()=>gt,KHR_draco_mesh_compression:()=>xe,KHR_lights:()=>Oe,KHR_materials_anisotropy:()=>Fe,KHR_materials_clearcoat:()=>Re,KHR_materials_emissive_strength:()=>De,KHR_materials_ior:()=>Ke,KHR_materials_iridescence:()=>Pe,KHR_materials_pbrSpecularGlossiness:()=>Le,KHR_materials_sheen:()=>ke,KHR_materials_specular:()=>Ue,KHR_materials_translucency:()=>Qe,KHR_materials_transmission:()=>Xe,KHR_materials_unlit:()=>we,KHR_materials_variants:()=>We,KHR_materials_volume:()=>Je,KHR_mesh_quantization:()=>et,KHR_texture_basisu:()=>nt,KHR_texture_transform:()=>ot,KHR_xmp_json_ld:()=>it,MSFT_audio_emitter:()=>Tt,MSFT_lod:()=>Et,MSFT_minecraftMesh:()=>Mt,MSFT_sRGBFactors:()=>Ct});var i={};r.r(i);var s={};r.r(s),r.d(s,{ArrayItem:()=>fe,EXT_lights_image_based:()=>_e,EXT_mesh_gpu_instancing:()=>ye,EXT_meshopt_compression:()=>ve,EXT_texture_webp:()=>be,ExtrasAsMetadata:()=>St,GLTFLoader:()=>he,KHR_animation_pointer:()=>gt,KHR_draco_mesh_compression:()=>xe,KHR_lights:()=>Oe,KHR_materials_anisotropy:()=>Fe,KHR_materials_clearcoat:()=>Re,KHR_materials_emissive_strength:()=>De,KHR_materials_ior:()=>Ke,KHR_materials_iridescence:()=>Pe,KHR_materials_pbrSpecularGlossiness:()=>Le,KHR_materials_sheen:()=>ke,KHR_materials_specular:()=>Ue,KHR_materials_translucency:()=>Qe,KHR_materials_transmission:()=>Xe,KHR_materials_unlit:()=>we,KHR_materials_variants:()=>We,KHR_materials_volume:()=>Je,KHR_mesh_quantization:()=>et,KHR_texture_basisu:()=>nt,KHR_texture_transform:()=>ot,KHR_xmp_json_ld:()=>it,MSFT_audio_emitter:()=>Tt,MSFT_lod:()=>Et,MSFT_minecraftMesh:()=>Mt,MSFT_sRGBFactors:()=>Ct});var l={};r.r(l),r.d(l,{GLTF1:()=>n,GLTF2:()=>s,GLTFFileLoader:()=>y,GLTFLoaderAnimationStartMode:()=>h,GLTFLoaderCoordinateSystemMode:()=>f,GLTFLoaderState:()=>p,GLTFValidation:()=>_});var c=r(520);function u(e,t,n,r){var o={externalResourceFunction:function(e){return r(e).then((function(e){return new Uint8Array(e)}))}};return n&&(o.uri="file:"===t?n:t+n),e instanceof ArrayBuffer?GLTFValidator.validateBytes(new Uint8Array(e),o):GLTFValidator.validateString(e,o)}function d(){var e=[];onmessage=function(t){var n=t.data;switch(n.id){case"init":importScripts(n.url);break;case"validate":u(n.data,n.rootUrl,n.fileName,(function(t){return new Promise((function(n,r){var o=e.length;e.push({resolve:n,reject:r}),postMessage({id:"getExternalResource",index:o,uri:t})}))})).then((function(e){postMessage({id:"validate.resolve",value:e})}),(function(e){postMessage({id:"validate.reject",reason:e})}));break;case"getExternalResource.resolve":e[n.index].resolve(n.value);break;case"getExternalResource.reject":e[n.index].reject(n.reason)}}}var f,h,p,_=function(){function e(){}return e.ValidateAsync=function(e,t,n,r){var o=this,a=ArrayBuffer.isView(e)?e.slice().buffer:e;return"function"==typeof Worker?new Promise((function(e,i){var s="".concat(u,"(").concat(d,")()"),l=URL.createObjectURL(new Blob([s],{type:"application/javascript"})),c=new Worker(l),f=function(e){c.removeEventListener("error",f),c.removeEventListener("message",h),i(e)},h=function(t){var n=t.data;switch(n.id){case"getExternalResource":r(n.uri).then((function(e){c.postMessage({id:"getExternalResource.resolve",index:n.index,value:e},[e])}),(function(e){c.postMessage({id:"getExternalResource.reject",index:n.index,reason:e})}));break;case"validate.resolve":c.removeEventListener("error",f),c.removeEventListener("message",h),e(n.value),c.terminate();break;case"validate.reject":c.removeEventListener("error",f),c.removeEventListener("message",h),i(n.reason),c.terminate()}};c.addEventListener("error",f),c.addEventListener("message",h),c.postMessage({id:"init",url:o.Configuration.url}),c.postMessage({id:"validate",data:a,rootUrl:t,fileName:n})})):(this._LoadScriptPromise||(this._LoadScriptPromise=c.Tools.LoadScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then((function(){return u(a,t,n,r)})))},e.Configuration={url:"https://preview.babylonjs.com/gltf_validator.js"},e}();function m(e,t,n){try{return Promise.resolve(new Uint8Array(e,t,n))}catch(e){return Promise.reject(e)}}!function(e){e[e.AUTO=0]="AUTO",e[e.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"}(f||(f={})),function(e){e[e.NONE=0]="NONE",e[e.FIRST=1]="FIRST",e[e.ALL=2]="ALL"}(h||(h={})),function(e){e[e.LOADING=0]="LOADING",e[e.READY=1]="READY",e[e.COMPLETE=2]="COMPLETE"}(p||(p={}));var y=function(){function e(){this.onParsedObservable=new c.Observable,this.coordinateSystemMode=f.AUTO,this.animationStartMode=h.FIRST,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.transparencyAsCoverage=!1,this.useRangeRequests=!1,this.createInstances=!0,this.alwaysComputeBoundingBox=!1,this.loadAllMaterials=!1,this.loadOnlyMaterials=!1,this.skipMaterials=!1,this.useSRGBBuffers=!0,this.targetFps=60,this.alwaysComputeSkeletonRootNode=!1,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable=new c.Observable,this.onSkinLoadedObservable=new c.Observable,this.onTextureLoadedObservable=new c.Observable,this.onMaterialLoadedObservable=new c.Observable,this.onCameraLoadedObservable=new c.Observable,this.onCompleteObservable=new c.Observable,this.onErrorObservable=new c.Observable,this.onDisposeObservable=new c.Observable,this.onExtensionLoadedObservable=new c.Observable,this.validate=!1,this.onValidatedObservable=new c.Observable,this._loader=null,this._state=null,this._requests=new Array,this.name="gltf",this.extensions={".gltf":{isBinary:!1},".glb":{isBinary:!0}},this.onLoaderStateChangedObservable=new c.Observable,this._logIndentLevel=0,this._loggingEnabled=!1,this._log=this._logDisabled,this._capturePerformanceCounters=!1,this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled}return Object.defineProperty(e.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),this._onParsedObserver=this.onParsedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loggingEnabled",{get:function(){return this._loggingEnabled},set:function(e){this._loggingEnabled!==e&&(this._loggingEnabled=e,this._loggingEnabled?this._log=this._logEnabled:this._log=this._logDisabled)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"capturePerformanceCounters",{get:function(){return this._capturePerformanceCounters},set:function(e){this._capturePerformanceCounters!==e&&(this._capturePerformanceCounters=e,this._capturePerformanceCounters?(this._startPerformanceCounter=this._startPerformanceCounterEnabled,this._endPerformanceCounter=this._endPerformanceCounterEnabled):(this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null);for(var e=0,t=this._requests;ee.byteLength)throw new Error("Array length out of bounds.");return Promise.resolve(new Uint8Array(e.buffer,e.byteOffset+t,n))}catch(e){return Promise.reject(e)}}(t,e,n)},byteLength:t.byteLength})).then((function(e){r(e)}),o?function(e){return o(void 0,e)}:void 0)},e.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return Promise.resolve().then((function(){return i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading ".concat(a||"")),i._loader=i._getLoader(n),i._loader.importMeshAsync(e,t,null,n,r,o,a)}))},e.prototype.loadAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){return a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t),a._loader.loadAsync(e,t,n,r,o)}))},e.prototype.loadAssetContainerAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t);var i=new c.AssetContainer(e),s=[];a.onMaterialLoadedObservable.add((function(e){s.push(e)}));var l=[];a.onTextureLoadedObservable.add((function(e){l.push(e)}));var u=[];a.onCameraLoadedObservable.add((function(e){u.push(e)}));var d=[];return a.onMeshLoadedObservable.add((function(e){e.morphTargetManager&&d.push(e.morphTargetManager)})),a._loader.importMeshAsync(null,e,i,t,n,r,o).then((function(e){return Array.prototype.push.apply(i.geometries,e.geometries),Array.prototype.push.apply(i.meshes,e.meshes),Array.prototype.push.apply(i.particleSystems,e.particleSystems),Array.prototype.push.apply(i.skeletons,e.skeletons),Array.prototype.push.apply(i.animationGroups,e.animationGroups),Array.prototype.push.apply(i.materials,s),Array.prototype.push.apply(i.textures,l),Array.prototype.push.apply(i.lights,e.lights),Array.prototype.push.apply(i.transformNodes,e.transformNodes),Array.prototype.push.apply(i.cameras,u),Array.prototype.push.apply(i.morphTargetManagers,d),i}))}))},e.prototype.canDirectLoad=function(t){return-1!==t.indexOf("asset")&&-1!==t.indexOf("version")||t.startsWith("data:base64,"+e._MagicBase64Encoded)||t.startsWith("data:;base64,"+e._MagicBase64Encoded)||t.startsWith("data:application/octet-stream;base64,"+e._MagicBase64Encoded)||t.startsWith("data:model/gltf-binary;base64,"+e._MagicBase64Encoded)},e.prototype.directLoad=function(t,n){if(n.startsWith("base64,"+e._MagicBase64Encoded)||n.startsWith(";base64,"+e._MagicBase64Encoded)||n.startsWith("application/octet-stream;base64,"+e._MagicBase64Encoded)||n.startsWith("model/gltf-binary;base64,"+e._MagicBase64Encoded)){var r=(0,c.DecodeBase64UrlToBinary)(n);return this._validate(t,new Uint8Array(r)),this._unpackBinaryAsync(new c.DataReader({readAsync:function(e,t){return m(r,e,t)},byteLength:r.byteLength}))}return this._validate(t,n),Promise.resolve({json:this._parseJson(n)})},e.prototype.createPlugin=function(){return new e},Object.defineProperty(e.prototype,"loaderState",{get:function(){return this._state},enumerable:!1,configurable:!0}),e.prototype.whenCompleteAsync=function(){var e=this;return new Promise((function(t,n){e.onCompleteObservable.addOnce((function(){t()})),e.onErrorObservable.addOnce((function(e){n(e)}))}))},e.prototype._setState=function(e){this._state!==e&&(this._state=e,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(p[this._state]))},e.prototype._loadFile=function(e,t,n,r,o,a){var i=this,s=e._loadFile(t,n,(function(e){i._onProgress(e,s)}),!0,r,o,a);return s.onCompleteObservable.add((function(e){i._requests.splice(i._requests.indexOf(e),1)})),this._requests.push(s),s},e.prototype._onProgress=function(e,t){if(this._progressCallback){t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;for(var n=!0,r=0,o=0,a=0,i=this._requests;a0)throw new Error("Incompatible minimum version: "+n.minVersion)}var a={1:e._CreateGLTF1Loader,2:e._CreateGLTF2Loader}[r.major];if(!a)throw new Error("Unsupported version: "+n.version);return a(this)},e.prototype._parseJson=function(e){this._startPerformanceCounter("Parse JSON"),this._log("JSON length: ".concat(e.length));var t=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),t},e.prototype._unpackBinaryAsync=function(e){var t=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then((function(){var n=e.readUint32();if(1179937895!==n)throw new c.RuntimeError("Unexpected magic: "+n,c.ErrorCodes.GLTFLoaderUnexpectedMagicError);var r=e.readUint32();t.loggingEnabled&&t._log("Binary version: ".concat(r));var o,a=e.readUint32();switch(t.useRangeRequests||a===e.buffer.byteLength||c.Logger.Warn("Length in header does not match actual data length: ".concat(a," != ").concat(e.buffer.byteLength)),r){case 1:o=t._unpackBinaryV1Async(e,a);break;case 2:o=t._unpackBinaryV2Async(e,a);break;default:throw new Error("Unsupported version: "+r)}return t._endPerformanceCounter("Unpack Binary"),o}))},e.prototype._unpackBinaryV1Async=function(e,t){var n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error("Unexpected content format: ".concat(r));var o=t-e.byteOffset,a={json:this._parseJson(e.readString(n)),bin:null};if(0!==o){var i=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(i+t,n)},byteLength:o}}return Promise.resolve(a)},e.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,o=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+o===t?e.loadAsync(o).then((function(){return{json:n._parseJson(e.readString(o)),bin:null}})):e.loadAsync(o+8).then((function(){var a={json:n._parseJson(e.readString(o)),bin:null},i=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case 5130562:var o=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(o+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(i):Promise.resolve(a)};return i()}))},e._parseVersion=function(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};var t=(e+"").match(/^(\d+)\.(\d+)/);return t?{major:parseInt(t[1]),minor:parseInt(t[2])}:null},e._compareVersion=function(e,t){return e.major>t.major?1:e.majort.minor?1:e.minora.byteLength)throw new Error("Buffer access is out of range");var i=a.buffer;switch(n+=a.byteOffset,o){case T.BYTE:return new Int8Array(i,n,r);case T.UNSIGNED_BYTE:return new Uint8Array(i,n,r);case T.SHORT:return new Int16Array(i,n,r);case T.UNSIGNED_SHORT:return new Uint16Array(i,n,r);default:return new Float32Array(i,n,r)}},e.GetBufferFromAccessor=function(t,n){var r=t.bufferViews[n.bufferView],o=n.count*e.GetByteStrideFromType(n);return e.GetBufferFromBufferView(t,r,n.byteOffset,o,n.componentType)},e.DecodeBufferToText=function(e){for(var t="",n=e.byteLength,r=0;r=this._maxPos},e}(),I=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],F=["world","view","projection","worldView","worldViewProjection","mBones"],B=["translation","rotation","scale"],D=["position","rotationQuaternion","scaling"],V=function(e,t,n){for(var r in e){var o=e[r];n[t][r]=o}},k=function(e){if(e)for(var t=0;t1?(a=new c.MultiMaterial("multimat"+r,e.scene)).subMaterials=i:a=new c.StandardMaterial("multimat"+r,e.scene),1===i.length&&(a=i[0]),a._parentContainer=e.assetContainer,o.material||(o.material=a),new c.Geometry(r,e.scene,s,!1,o),o.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,o.subMeshes=[];var w=0;for(h=0;h0&&-1===e.importMeshesNames.indexOf(t.name||""))return null;if(t.skin){if(t.meshes){var o=e.skins[t.skin];(a=Y(e,t,t.meshes,n,t.babylonNode)).skeleton=e.scene.getLastSkeletonById(t.skin),null===a.skeleton&&(a.skeleton=function(e,t,n,r){if(r||(r=new c.Skeleton(t.name||"","",e.scene)),!t.babylonSkeleton)return r;var o=[],a=[];!function(e,t,n,r){for(var o in e.nodes){var a=e.nodes[o],i=o;if(a.jointName&&!W(n,a.jointName)){var s=U(a),l=new c.Bone(a.name||"",t,null,s);l.id=i,r.push({bone:l,node:a,id:i})}}for(var u=0;u0&&(f=K(o,l))&&-1===a.indexOf(f)&&a.push(f),new c.Bone(s.jointName||"",r,f,A).id=l}}else c.Tools.Warn("Joint named "+t.jointNames[i]+" does not exist")}var v=r.bones;for(r.bones=[],i=0;i ").concat(p[p.READY]),i="".concat(p[p.LOADING]," => ").concat(p[p.COMPLETE]);o._parent._startPerformanceCounter(a),o._parent._startPerformanceCounter(i),o._parent._setState(p.LOADING),o._extensionsOnLoading();var s=new Array,l=o._babylonScene.blockMaterialDirtyMechanism;if(o._babylonScene.blockMaterialDirtyMechanism=!0,!o.parent.loadOnlyMaterials)if(n)s.push(o.loadSceneAsync("/nodes",{nodes:n,index:-1}));else if(null!=o._gltf.scene||o._gltf.scenes&&o._gltf.scenes[0]){var u=fe.Get("/scene",o._gltf.scenes,o._gltf.scene||0);s.push(o.loadSceneAsync("/scenes/".concat(u.index),u))}if(!o.parent.skipMaterials&&o.parent.loadAllMaterials&&o._gltf.materials)for(var d=0;de.bin.byteLength)&&c.Logger.Warn("Binary buffer length (".concat(n.byteLength,") from JSON does not match chunk length (").concat(e.bin.byteLength,")")),this._bin=e.bin}else c.Logger.Warn("Unexpected BIN chunk")}},e.prototype._setupData=function(){if(fe.Assign(this._gltf.accessors),fe.Assign(this._gltf.animations),fe.Assign(this._gltf.buffers),fe.Assign(this._gltf.bufferViews),fe.Assign(this._gltf.cameras),fe.Assign(this._gltf.images),fe.Assign(this._gltf.materials),fe.Assign(this._gltf.meshes),fe.Assign(this._gltf.nodes),fe.Assign(this._gltf.samplers),fe.Assign(this._gltf.scenes),fe.Assign(this._gltf.skins),fe.Assign(this._gltf.textures),this._gltf.nodes){for(var e={},t=0,n=this._gltf.nodes;t=(i=n[t[0]]).length)return l;s=i[c];for(var u=1;u=(i=n[t[u]]).length||s!==i[c])return l;l=s}},e.prototype._loadBone=function(e,t,n,r){var o=r[e.index];if(o)return o;var a=null;e.index!==t.skeleton&&(e.parent&&-1!==e.parent.index?a=this._loadBone(e.parent,t,n,r):void 0!==t.skeleton&&c.Logger.Warn("/skins/".concat(t.index,"/skeleton: Skeleton node is not a common root")));var i=t.joints.indexOf(e.index);return o=new c.Bone(e.name||"joint".concat(e.index),n,a,this._getNodeMatrix(e),null,null,i),r[e.index]=o,this._postSceneLoadActions.push((function(){o.linkTransformNode(e._babylonTransformNode)})),o},e.prototype._loadSkinInverseBindMatricesDataAsync=function(e,t){if(null==t.inverseBindMatrices)return Promise.resolve(null);var n=fe.Get("".concat(e,"/inverseBindMatrices"),this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync("/accessors/".concat(n.index),n)},e.prototype._updateBoneMatrices=function(e,t){for(var n=0,r=e.bones;n0){var b="".concat(n.name||"animation".concat(n.index),"_channel").concat(r.index,"_").concat(t);d.buildAnimations(o.target,b,i,_,(function(e,n){++t,a(e,n)}))}}}))},e.prototype._loadAnimationSamplerAsync=function(e,t){if(t._data)return t._data;var n=t.interpolation||"LINEAR";switch(n){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error("".concat(e,"/interpolation: Invalid value (").concat(t.interpolation,")"))}var r=fe.Get("".concat(e,"/input"),this._gltf.accessors,t.input),o=fe.Get("".concat(e,"/output"),this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync("/accessors/".concat(r.index),r),this._loadFloatAccessorAsync("/accessors/".concat(o.index),o)]).then((function(e){var t=e[0],r=e[1];return{input:t,interpolation:n,output:r}})),t._data},e.prototype.loadBufferAsync=function(e,t,n,r){var o=this._extensionsLoadBufferAsync(e,t,n,r);if(o)return o;if(!t._data)if(t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{if(!this._bin)throw new Error("".concat(e,": Uri is missing or the binary glTF is missing its binary chunk"));t._data=this._bin.readAsync(0,t.byteLength)}return t._data.then((function(t){try{return new Uint8Array(t.buffer,t.byteOffset+n,r)}catch(t){throw new Error("".concat(e,": ").concat(t.message))}}))},e.prototype.loadBufferViewAsync=function(e,t){var n=this._extensionsLoadBufferViewAsync(e,t);if(n)return n;if(t._data)return t._data;var r=fe.Get("".concat(e,"/buffer"),this._gltf.buffers,t.buffer);return t._data=this.loadBufferAsync("/buffers/".concat(r.index),r,t.byteOffset||0,t.byteLength),t._data},e.prototype._loadAccessorAsync=function(t,n,r){var o=this;if(n._data)return n._data;var a=e._GetNumComponents(t,n.type),i=a*c.VertexBuffer.GetTypeByteLength(n.componentType),s=a*n.count;if(null==n.bufferView)n._data=Promise.resolve(new r(s));else{var l=fe.Get("".concat(t,"/bufferView"),this._gltf.bufferViews,n.bufferView);n._data=this.loadBufferViewAsync("/bufferViews/".concat(l.index),l).then((function(o){if(5126!==n.componentType||n.normalized||l.byteStride&&l.byteStride!==i){var u=new r(s);return c.VertexBuffer.ForEach(o,n.byteOffset||0,l.byteStride||i,a,n.componentType,u.length,n.normalized||!1,(function(e,t){u[t]=e})),u}return e._GetTypedArray(t,n.componentType,o,n.byteOffset,s)}))}if(n.sparse){var u=n.sparse;n._data=n._data.then((function(s){var l=s,d=fe.Get("".concat(t,"/sparse/indices/bufferView"),o._gltf.bufferViews,u.indices.bufferView),f=fe.Get("".concat(t,"/sparse/values/bufferView"),o._gltf.bufferViews,u.values.bufferView);return Promise.all([o.loadBufferViewAsync("/bufferViews/".concat(d.index),d),o.loadBufferViewAsync("/bufferViews/".concat(f.index),f)]).then((function(o){var s,d=o[0],f=o[1],h=e._GetTypedArray("".concat(t,"/sparse/indices"),u.indices.componentType,d,u.indices.byteOffset,u.count),p=a*u.count;if(5126!==n.componentType||n.normalized){var _=e._GetTypedArray("".concat(t,"/sparse/values"),n.componentType,f,u.values.byteOffset,p);s=new r(p),c.VertexBuffer.ForEach(_,0,i,a,n.componentType,s.length,n.normalized||!1,(function(e,t){s[t]=e}))}else s=e._GetTypedArray("".concat(t,"/sparse/values"),n.componentType,f,u.values.byteOffset,p);for(var m=0,y=0;y=6)throw new Error("".concat(t,"/texCoord: Invalid value (").concat(n.texCoord,")"));var i=fe.Get("".concat(t,"/index"),this._gltf.textures,n.index);i._textureInfo=n;var s=this._loadTextureAsync("/textures/".concat(n.index),i,(function(a){a.coordinatesIndex=n.texCoord||0,e.AddPointerMetadata(a,t),o._parent.onTextureLoadedObservable.notifyObservers(a),r(a)}));return this.logClose(),s},e.prototype._loadTextureAsync=function(t,n,r){void 0===r&&(r=function(){});var o=this._extensionsLoadTextureAsync(t,n,r);if(o)return o;this.logOpen("".concat(t," ").concat(n.name||""));var a=null==n.sampler?e.DefaultSampler:fe.Get("".concat(t,"/sampler"),this._gltf.samplers,n.sampler),i=fe.Get("".concat(t,"/source"),this._gltf.images,n.source),s=this._createTextureAsync(t,a,i,r,void 0,!n._textureInfo.nonColorData);return this.logClose(),s},e.prototype._createTextureAsync=function(e,t,n,r,o,a){var i=this;void 0===r&&(r=function(){});var s=this._loadSampler("/samplers/".concat(t.index),t),l=new Array,u=new c.Deferred;this._babylonScene._blockEntityCollection=!!this._assetContainer;var d={noMipmap:s.noMipMaps,invertY:!1,samplingMode:s.samplingMode,onLoad:function(){i._disposed||u.resolve()},onError:function(t,n){i._disposed||u.reject(new Error("".concat(e,": ").concat(n&&n.message?n.message:t||"Failed to load texture")))},mimeType:n.mimeType,loaderOptions:o,useSRGBBuffer:!!a&&this._parent.useSRGBBuffers},f=new c.Texture(null,this._babylonScene,d);return f._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,l.push(u.promise),l.push(this.loadImageAsync("/images/".concat(n.index),n).then((function(e){var t=n.uri||"".concat(i._fileName,"#image").concat(n.index),r="data:".concat(i._uniqueRootUrl).concat(t);f.updateURL(r,e)}))),f.wrapU=s.wrapU,f.wrapV=s.wrapV,r(f),Promise.all(l).then((function(){return f}))},e.prototype._loadSampler=function(t,n){return n._data||(n._data={noMipMaps:9728===n.minFilter||9729===n.minFilter,samplingMode:e._GetTextureSamplingMode(t,n),wrapU:e._GetTextureWrapMode("".concat(t,"/wrapS"),n.wrapS),wrapV:e._GetTextureWrapMode("".concat(t,"/wrapT"),n.wrapT)}),n._data},e.prototype.loadImageAsync=function(e,t){if(!t._data){if(this.logOpen("".concat(e," ").concat(t.name||"")),t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{var n=fe.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/".concat(n.index),n)}this.logClose()}return t._data},e.prototype.loadUriAsync=function(t,n,r){var o=this,a=this._extensionsLoadUriAsync(t,n,r);if(a)return a;if(!e._ValidateUri(r))throw new Error("".concat(t,": '").concat(r,"' is invalid"));if((0,c.IsBase64DataUrl)(r)){var i=new Uint8Array((0,c.DecodeBase64UrlToBinary)(r));return this.log("".concat(t,": Decoded ").concat(r.substr(0,64),"... (").concat(i.length," bytes)")),Promise.resolve(i)}return this.log("".concat(t,": Loading ").concat(r)),this._parent.preprocessUrlAsync(this._rootUrl+r).then((function(e){return new Promise((function(n,a){o._parent._loadFile(o._babylonScene,e,(function(e){o._disposed||(o.log("".concat(t,": Loaded ").concat(r," (").concat(e.byteLength," bytes)")),n(new Uint8Array(e)))}),!0,(function(e){a(new c.LoadFileError("".concat(t,": Failed to load '").concat(r,"'").concat(e?": "+e.status+" "+e.statusText:""),e))}))}))}))},e.AddPointerMetadata=function(e,t){e.metadata=e.metadata||{};var n=e._internalMetadata=e._internalMetadata||{},r=n.gltf=n.gltf||{};(r.pointers=r.pointers||[]).push(t)},e._GetTextureWrapMode=function(e,t){switch(t=null==t?10497:t){case 33071:return c.Texture.CLAMP_ADDRESSMODE;case 33648:return c.Texture.MIRROR_ADDRESSMODE;case 10497:return c.Texture.WRAP_ADDRESSMODE;default:return c.Logger.Warn("".concat(e,": Invalid value (").concat(t,")")),c.Texture.WRAP_ADDRESSMODE}},e._GetTextureSamplingMode=function(e,t){var n=null==t.magFilter?9729:t.magFilter,r=null==t.minFilter?9987:t.minFilter;if(9729===n)switch(r){case 9728:return c.Texture.LINEAR_NEAREST;case 9729:return c.Texture.LINEAR_LINEAR;case 9984:return c.Texture.LINEAR_NEAREST_MIPNEAREST;case 9985:return c.Texture.LINEAR_LINEAR_MIPNEAREST;case 9986:return c.Texture.LINEAR_NEAREST_MIPLINEAR;case 9987:return c.Texture.LINEAR_LINEAR_MIPLINEAR;default:return c.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(r,")")),c.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==n&&c.Logger.Warn("".concat(e,"/magFilter: Invalid value (").concat(n,")")),r){case 9728:return c.Texture.NEAREST_NEAREST;case 9729:return c.Texture.NEAREST_LINEAR;case 9984:return c.Texture.NEAREST_NEAREST_MIPNEAREST;case 9985:return c.Texture.NEAREST_LINEAR_MIPNEAREST;case 9986:return c.Texture.NEAREST_NEAREST_MIPLINEAR;case 9987:return c.Texture.NEAREST_LINEAR_MIPLINEAR;default:return c.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(r,")")),c.Texture.NEAREST_NEAREST_MIPNEAREST}},e._GetTypedArrayConstructor=function(e,t){switch(t){case 5120:return Int8Array;case 5121:return Uint8Array;case 5122:return Int16Array;case 5123:return Uint16Array;case 5125:return Uint32Array;case 5126:return Float32Array;default:throw new Error("".concat(e,": Invalid component type ").concat(t))}},e._GetTypedArray=function(t,n,r,o,a){var i=r.buffer;o=r.byteOffset+(o||0);var s=e._GetTypedArrayConstructor("".concat(t,"/componentType"),n),l=c.VertexBuffer.GetTypeByteLength(n);return o%l!=0?(c.Logger.Warn("".concat(t,": Copying buffer as byte offset (").concat(o,") is not a multiple of component type byte length (").concat(l,")")),new s(i.slice(o,o+a*l),0)):new s(i,o,a)},e._GetNumComponents=function(e,t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16}throw new Error("".concat(e,": Invalid type (").concat(t,")"))},e._ValidateUri=function(e){return c.Tools.IsBase64(e)||-1===e.indexOf("..")},e._GetDrawMode=function(e,t){switch(null==t&&(t=4),t){case 0:return c.Material.PointListDrawMode;case 1:return c.Material.LineListDrawMode;case 2:return c.Material.LineLoopDrawMode;case 3:return c.Material.LineStripDrawMode;case 4:return c.Material.TriangleFillMode;case 5:return c.Material.TriangleStripDrawMode;case 6:return c.Material.TriangleFanDrawMode}throw new Error("".concat(e,": Invalid mesh primitive mode (").concat(t,")"))},e.prototype._compileMaterialsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile materials");var t=new Array;if(this._gltf.materials)for(var n=0,r=this._gltf.materials;n=0;a--)if(o.push(fe.Get("".concat(e,"/ids/").concat(r[a]),n,r[a])),o.length===this.maxLODsToLoad)return o;return o.push(t),o},e.prototype._disposeTransformNode=function(e){var t=this,n=new Array,r=e.material;r&&n.push(r);for(var o=0,a=e.getChildMeshes();o0){var n=e.metadata=e.metadata||{};(n.gltf=n.gltf||{}).extras=t.extras}},e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,t,n){var r=this;return this._loader.loadNodeAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.loadCameraAsync=function(e,t,n){var r=this;return this._loader.loadCameraAsync(e,t,(function(e){r._assignExtras(e,t),n(e)}))},e.prototype.createMaterial=function(e,t,n){var r=this._loader.createMaterial(e,t,n);return this._assignExtras(r,t),r},e}();he.RegisterExtension(wt,(function(e){return new St(e)}));var Rt=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==Rt){Rt.BABYLON=Rt.BABYLON||{};var Nt=Rt.BABYLON;Nt.GLTF2=Nt.GLTF2||{},Nt.GLTF2.Loader=Nt.GLTF2.Loader||{},Nt.GLTF2.Loader.Extensions=Nt.GLTF2.Loader.Extensions||{};var Pt=[];for(var It in a)Nt.GLTF2.Loader.Extensions[It]=a[It],Pt.push(It);for(var It in i)Nt.GLTF2.Loader[It]=i[It],Pt.push(It);for(var It in s)Pt.indexOf(It)>-1||(Nt.GLTF2[It]=s[It])}const Ft=l})(),o.default})())); +//# sourceMappingURL=babylon.glTFFileLoader.min.js.map \ No newline at end of file diff --git a/libs/babylonjs/6.23.0/babylon.inspector.bundle.js b/libs/babylonjs/6.23.0/babylon.inspector.bundle.js new file mode 100644 index 00000000..96fa9409 --- /dev/null +++ b/libs/babylonjs/6.23.0/babylon.inspector.bundle.js @@ -0,0 +1,3 @@ +/*! For license information please see babylon.inspector.bundle.js.LICENSE.txt */ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs"),require("babylonjs-materials"),require("babylonjs"),require("babylonjs-gui"),require("babylonjs-gui-editor"),require("babylonjs-loaders"),require("babylonjs-serializers")):"function"==typeof define&&define.amd?define("babylonjs-inspector",["babylonjs","babylonjs-materials","babylonjs","babylonjs-gui","babylonjs-gui-editor","babylonjs-loaders","babylonjs-serializers"],t):"object"==typeof exports?exports["babylonjs-inspector"]=t(require("babylonjs"),require("babylonjs-materials"),require("babylonjs"),require("babylonjs-gui"),require("babylonjs-gui-editor"),require("babylonjs-loaders"),require("babylonjs-serializers")):e.INSPECTOR=t(e.BABYLON,e.BABYLON,e.BABYLON.Debug,e.BABYLON.GUI,e.BABYLON,e.BABYLON,e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,((e,t,r,n,o,s,a)=>(()=>{var i={4548:(e,t,r)=>{"use strict";r.d(t,{Z:()=>h});var n=r(4864),o=r.n(n),s=r(7885),a=r.n(s),i=r(287),l=r.n(i),p=new URL(r(5290),r.b),c=a()(o()),d=l()(p);c.push([e.id,`#inspector-host{position:absolute;right:0px;top:0px;bottom:0px}#__resizable_base__{display:none}#actionTabs{background:#333;height:100%;margin:0;padding:0;display:grid;grid-template-rows:auto 1fr;font:14px "Arial";overflow:hidden}#actionTabs .hoverIcon:hover{opacity:.8}#actionTabs #header{height:30px;font-size:16px;color:#fff;background:#222;grid-row:1;text-align:center;display:grid;grid-template-columns:30px 1fr 50px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#actionTabs #header #logo{grid-column:1;width:24px;height:24px;display:flex;align-self:center;justify-self:center}#actionTabs #header #back{grid-column:1;display:grid;align-self:center;justify-self:center;cursor:pointer}#actionTabs #header #title{grid-column:2;display:grid;align-items:center;text-align:center}#actionTabs #header #commands{grid-column:3;display:grid;align-items:center;grid-template-columns:1fr 1fr}#actionTabs #header #commands .expand{grid-column:1;display:grid;align-items:center;justify-items:center;cursor:pointer}#actionTabs #header #commands .close{grid-column:2;display:grid;align-items:center;justify-items:center;cursor:pointer}#actionTabs .tabsMenu{display:grid;grid-row:2;grid-template-rows:40px 1fr;font:14px "Arial";overflow:hidden}#actionTabs .tabsMenu .labels{grid-row:1;display:flex;align-items:center;justify-items:center;border-bottom:1px solid #fff;margin:0;padding:0}#actionTabs .tabsMenu .labels .label{font-size:24px;color:#fff;width:40px;display:flex;align-content:center;justify-content:center;border:1px solid rgba(0,0,0,0);border-bottom:none;background:#333;padding:5px;height:28px;cursor:pointer}#actionTabs .tabsMenu .labels .label.active{border-color:#fff;border-bottom:2px solid rgba(0,0,0,0);margin-bottom:-2px}#actionTabs .tabsMenu .panes{grid-row:2;display:grid;grid-template-rows:100%;overflow:hidden}#actionTabs .tabsMenu .panes .infoMessage{opacity:.5;color:#fff;margin:15px 5px 0px 5px}#actionTabs .tabsMenu .panes .gradient-step{display:grid;grid-template-rows:100%;grid-template-columns:20px 30px 40px auto 20px 30px;padding-top:5px;padding-left:5px;padding-bottom:5px;align-items:center}#actionTabs .tabsMenu .panes .gradient-step .step{grid-row:1;grid-column:1}#actionTabs .tabsMenu .panes .gradient-step .color1{height:100%}#actionTabs .tabsMenu .panes .gradient-step .color2{height:100%;padding-left:5px}#actionTabs .tabsMenu .panes .gradient-step .factor1{grid-row:1;grid-column:2;cursor:pointer}#actionTabs .tabsMenu .panes .gradient-step .factor2{padding-left:5px;grid-row:1;grid-column:3;cursor:pointer}#actionTabs .tabsMenu .panes .gradient-step .factor2 .grayed{background:gray;border-color:gray}#actionTabs .tabsMenu .panes .gradient-step .numeric-input{width:calc(100% - 5px)}#actionTabs .tabsMenu .panes .gradient-step .icon{cursor:pointer}#actionTabs .tabsMenu .panes .gradient-step .step-value{margin-left:5px;grid-row:1;grid-column:3;text-align:right;margin-right:5px}#actionTabs .tabsMenu .panes .gradient-step .step-slider{grid-row:1;grid-column:4;display:grid;justify-content:stretch;align-content:center;margin-right:12px}#actionTabs .tabsMenu .panes .gradient-step .step-slider input{width:100%}#actionTabs .tabsMenu .panes .gradient-step .step-slider .range:hover{opacity:1}#actionTabs .tabsMenu .panes .gradient-step .step-slider .range{-webkit-appearance:none;height:6px;background:#d3d3d3;border-radius:5px;outline:none;opacity:.7;-webkit-transition:.2s;transition:opacity .2s}#actionTabs .tabsMenu .panes .gradient-step .step-slider .range::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:#337ab7;cursor:pointer}#actionTabs .tabsMenu .panes .gradient-step .step-slider .range::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:#337ab7;cursor:pointer}#actionTabs .tabsMenu .panes .gradient-step .gradient-copy{grid-row:1;grid-column:5;display:grid;align-content:center;justify-content:center}#actionTabs .tabsMenu .panes .gradient-step .gradient-copy .img{height:20px;width:20px}#actionTabs .tabsMenu .panes .gradient-step .gradient-copy .img:hover{cursor:pointer}#actionTabs .tabsMenu .panes .gradient-step .gradient-delete{grid-row:1;grid-column:6;display:grid;align-content:center;justify-content:center}#actionTabs .tabsMenu .panes .gradient-step .gradient-delete .img{height:20px;width:20px}#actionTabs .tabsMenu .panes .gradient-step .gradient-delete .img:hover{cursor:pointer}#actionTabs .tabsMenu .panes .pane{color:#fff;overflow-x:hidden;overflow-y:auto;height:100%;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#actionTabs .tabsMenu .panes .pane .animation-info{border-left:#adff2f 3px solid;margin-left:5px;padding-left:5px !important}#actionTabs .tabsMenu .panes .pane .underline{border-bottom:.5px solid rgba(255,255,255,.5)}#actionTabs .tabsMenu .panes .pane .textureLinkLine{display:grid;grid-template-columns:auto 1fr}#actionTabs .tabsMenu .panes .pane .textureLinkLine .debug{grid-column:1;margin-left:5px;margin-right:5px;display:block;align-items:center;justify-items:center;cursor:pointer;opacity:.5}#actionTabs .tabsMenu .panes .pane .textureLinkLine .debug.selected{opacity:1}#actionTabs .tabsMenu .panes .pane .textureLinkLine .textLine{grid-column:2}#actionTabs .tabsMenu .panes .pane .textureLinkLine .actionIcon{display:inline-block;margin-top:6px;margin-right:4px}#actionTabs .tabsMenu .panes .pane .messageLine{text-align:center;font-size:12px;font-style:italic;opacity:.6}#actionTabs .tabsMenu .panes .pane .iconMessageLine{padding-left:2px;height:30px;display:grid;grid-template-columns:30px 1fr}#actionTabs .tabsMenu .panes .pane .iconMessageLine .icon{grid-column:1;display:grid;align-items:center;justify-items:center}#actionTabs .tabsMenu .panes .pane .iconMessageLine .value{grid-column:2;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .color-picker{height:calc(100% - 8px);margin:4px;width:100%}#actionTabs .tabsMenu .panes .pane .color-picker .color-rect{height:calc(100% - 4px);border:2px #fff solid;cursor:pointer;min-height:18px}#actionTabs .tabsMenu .panes .pane .color-picker .color-picker-cover{position:fixed;top:0px;right:0px;bottom:0px;left:0px;z-index:100}#actionTabs .tabsMenu .panes .pane .color-picker .color-picker-float{position:absolute}#actionTabs .tabsMenu .panes .pane .linkButtonLine{padding-left:2px;height:30px;display:grid;grid-template-columns:1fr auto 20px}#actionTabs .tabsMenu .panes .pane .linkButtonLine .link{grid-column:1;display:flex;align-items:center;text-decoration:underline;cursor:pointer}#actionTabs .tabsMenu .panes .pane .linkButtonLine .link-button{grid-column:2}#actionTabs .tabsMenu .panes .pane .linkButtonLine .link-button button{background:#222;border:1px solid #337ab7;margin:5px 10px 5px 10px;color:#fff;padding:4px 5px;opacity:.9;cursor:pointer}#actionTabs .tabsMenu .panes .pane .linkButtonLine .link-button button:hover{opacity:1}#actionTabs .tabsMenu .panes .pane .linkButtonLine .link-button button:active{background:#282828}#actionTabs .tabsMenu .panes .pane .linkButtonLine .link-button button:focus{border:1px solid #337ab7;outline:0px}#actionTabs .tabsMenu .panes .pane .linkButtonLine .link-icon{grid-column:3;display:grid;align-content:center}#actionTabs .tabsMenu .panes .pane .textLine{padding-left:2px;height:30px;display:grid;grid-template-columns:1fr auto}#actionTabs .tabsMenu .panes .pane .textLine.indented{grid-template-columns:100%}#actionTabs .tabsMenu .panes .pane .textLine.indented .link-value{grid-column:1;text-align:start;margin-left:20px;opacity:.6;max-width:unset}#actionTabs .tabsMenu .panes .pane .textLine.indented .value{grid-column:1;text-align:start;margin-left:20px;opacity:.6;max-width:unset}#actionTabs .tabsMenu .panes .pane .textLine.reduced-opacity{opacity:.6;padding-left:25px}#actionTabs .tabsMenu .panes .pane .textLine .label{grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .textLine .link-value{grid-column:2;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-align:end;opacity:.8;margin:5px;margin-top:7px;max-width:140px;text-decoration:underline;cursor:pointer}#actionTabs .tabsMenu .panes .pane .textLine .value{grid-column:2;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;text-align:end;opacity:.8;margin:5px;margin-top:7px;max-width:200px;-webkit-user-select:text;-moz-user-select:text;-ms-user-select:text;user-select:text}#actionTabs .tabsMenu .panes .pane .textLine .value.check{color:green}#actionTabs .tabsMenu .panes .pane .textLine .value.uncheck{color:red}#actionTabs .tabsMenu .panes .pane .gradient-container{margin-top:3px}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-label{height:30px;display:grid;align-content:center}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step{display:grid;grid-template-rows:100%;grid-template-columns:25px 50px 55px 40px auto 20px 5px;padding-top:5px;padding-left:5px;padding-bottom:5px;align-items:center;border-left:orange 3px solid}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .step{grid-row:1;grid-column:1}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .color1{height:100%}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .color2{height:100%;padding-left:5px}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .factor1{grid-row:1;grid-column:2;cursor:pointer}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .factor2{padding-left:5px;grid-row:1;grid-column:3;cursor:pointer}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .factor2 .grayed{background:gray;border-color:gray}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .numeric-input{width:calc(100% - 5px)}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .step-value{margin-left:5px;grid-row:1;grid-column:4;text-align:right;margin-right:5px}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .step-slider{grid-row:1;grid-column:5;display:grid;justify-content:stretch;align-content:center;margin-right:5px}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .step-slider input{width:100%}#actionTabs .tabsMenu .panes .pane .gradient-container .gradient-step .gradient-delete{grid-row:1;grid-column:6;display:grid;align-content:center;justify-content:center}#actionTabs .tabsMenu .panes .pane .textInputLine{padding-left:2px;height:30px;display:grid;grid-template-columns:1fr 120px}#actionTabs .tabsMenu .panes .pane .textInputLine .label{grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .textInputLine .value{display:flex;align-items:center;grid-column:2}#actionTabs .tabsMenu .panes .pane .textInputLine .value input{width:110px}#actionTabs .tabsMenu .panes .pane .buttonLine{height:30px;display:grid;align-items:center;justify-items:stretch}#actionTabs .tabsMenu .panes .pane .buttonLine input[type=file]{display:none}#actionTabs .tabsMenu .panes .pane .buttonLine .file-upload{background:#222;border:1px solid #337ab7;margin:5px 10px 5px 10px;color:#fff;padding:4px 5px;font-size:13px;opacity:.9;cursor:pointer;text-align:center}#actionTabs .tabsMenu .panes .pane .buttonLine .file-upload:hover{opacity:1}#actionTabs .tabsMenu .panes .pane .buttonLine .file-upload:active{transform:scale(0.98);transform-origin:.5 .5}#actionTabs .tabsMenu .panes .pane .buttonLine button{background:#222;border:1px solid #337ab7;margin:5px 10px 5px 10px;color:#fff;padding:4px 5px;opacity:.9;cursor:pointer}#actionTabs .tabsMenu .panes .pane .buttonLine button:hover{opacity:1}#actionTabs .tabsMenu .panes .pane .buttonLine button:active{background:#282828}#actionTabs .tabsMenu .panes .pane .buttonLine button:focus{border:1px solid #337ab7;outline:0px}#actionTabs .tabsMenu .panes .pane .radioLine{padding-left:2px;height:30px;display:grid;grid-template-columns:1fr 24px}#actionTabs .tabsMenu .panes .pane .radioLine .label{grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .radioLine .radioContainer{display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .radioLine .radioContainer .radio{grid-column:2;display:none}#actionTabs .tabsMenu .panes .pane .radioLine .radioContainer .radio:checked+label:before{border-color:#337ab7}#actionTabs .tabsMenu .panes .pane .radioLine .radioContainer .radio:checked+label:after{transform:scale(1)}#actionTabs .tabsMenu .panes .pane .radioLine .radioContainer .labelForRadio{display:inline-block;height:14px;position:relative;padding:0 24px;margin-bottom:0;cursor:pointer;vertical-align:bottom}#actionTabs .tabsMenu .panes .pane .radioLine .radioContainer .labelForRadio:before,#actionTabs .tabsMenu .panes .pane .radioLine .radioContainer .labelForRadio:after{position:absolute;content:"";border-radius:50%;transition:all .3s ease;transition-property:transform,border-color}#actionTabs .tabsMenu .panes .pane .radioLine .radioContainer .labelForRadio:before{left:0px;top:0;width:16px;height:16px;border:2px solid #fff}#actionTabs .tabsMenu .panes .pane .radioLine .radioContainer .labelForRadio:after{top:6px;left:6px;width:8px;height:8px;transform:scale(0);background:#337ab7}#actionTabs .tabsMenu .panes .pane .vector3Line{padding-left:2px;display:grid}#actionTabs .tabsMenu .panes .pane .vector3Line .firstLine{display:grid;grid-template-columns:1fr auto 20px;height:30px}#actionTabs .tabsMenu .panes .pane .vector3Line .firstLine .label{grid-column:1;display:flex;align-items:center;white-space:nowrap;overflow:hidden}#actionTabs .tabsMenu .panes .pane .vector3Line .firstLine .vector{grid-column:2;display:flex;align-items:center;text-align:right;opacity:.8;padding-left:5px}#actionTabs .tabsMenu .panes .pane .vector3Line .firstLine .expand{grid-column:3;display:grid;align-items:center;justify-items:center;cursor:pointer}#actionTabs .tabsMenu .panes .pane .vector3Line .secondLine{display:grid;padding-right:5px;border-left:1px solid #337ab7}#actionTabs .tabsMenu .panes .pane .vector3Line .secondLine .numeric{display:grid;grid-template-columns:1fr auto}#actionTabs .tabsMenu .panes .pane .vector3Line .secondLine .numeric-label{text-align:right;grid-column:1;display:flex;align-items:center;justify-self:right;margin-right:10px}#actionTabs .tabsMenu .panes .pane .vector3Line .secondLine .numeric-value{width:120px;grid-column:2;display:flex;align-items:center;border:1px solid #337ab7}#actionTabs .tabsMenu .panes .pane .checkBoxLine{padding-left:2px;height:30px;display:grid;grid-template-columns:1fr auto}#actionTabs .tabsMenu .panes .pane .checkBoxLine .label{grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .checkBoxLine .checkBox{grid-column:2;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .checkBoxLine .checkBox .lbl{position:relative;display:block;height:14px;width:34px;margin-right:5px;background:#898989;border-radius:100px;cursor:pointer;transition:all .3s ease}#actionTabs .tabsMenu .panes .pane .checkBoxLine .checkBox .lbl.checked{background:#337ab7}#actionTabs .tabsMenu .panes .pane .checkBoxLine .checkBox .lbl:after{position:absolute;left:3px;top:2px;display:block;width:10px;height:10px;border-radius:100px;background:#fff;box-shadow:0px 3px 3px rgba(0,0,0,.05);content:"";transition:all .15s ease}#actionTabs .tabsMenu .panes .pane .checkBoxLine .checkBox .lbl:after.checked{left:20px;background:#164975}#actionTabs .tabsMenu .panes .pane .checkBoxLine .checkBox .lbl.checked:after{position:absolute;top:2px;display:block;width:10px;height:10px;border-radius:100px;background:#fff;box-shadow:0px 3px 3px rgba(0,0,0,.05);content:"";transition:all .15s ease;left:20px;background:#164975}#actionTabs .tabsMenu .panes .pane .checkBoxLine .checkBox .lbl:active:after{transform:scale(1.15, 0.85)}#actionTabs .tabsMenu .panes .pane .checkBoxLine .checkBox .hidden{display:none}#actionTabs .tabsMenu .panes .pane .checkBoxLine .checkBox .icon{display:none}#actionTabs .tabsMenu .panes .pane .textureLine{display:grid;grid-template-rows:30px auto}#actionTabs .tabsMenu .panes .pane .textureLine .control{margin-top:2px;grid-row:1;display:grid;grid-template-columns:1fr 40px 40px 40px 40px 40px 1fr}#actionTabs .tabsMenu .panes .pane .textureLine .control .red{grid-column:2}#actionTabs .tabsMenu .panes .pane .textureLine .control .green{grid-column:3}#actionTabs .tabsMenu .panes .pane .textureLine .control .blue{grid-column:4}#actionTabs .tabsMenu .panes .pane .textureLine .control .alpha{grid-column:5}#actionTabs .tabsMenu .panes .pane .textureLine .control .all{grid-column:6}#actionTabs .tabsMenu .panes .pane .textureLine .control3D{margin-top:2px;grid-row:1;display:grid;grid-template-columns:1fr 40px 40px 40px 40px 40px 40px 1fr}#actionTabs .tabsMenu .panes .pane .textureLine .control3D .px{grid-column:2}#actionTabs .tabsMenu .panes .pane .textureLine .control3D .nx{grid-column:3}#actionTabs .tabsMenu .panes .pane .textureLine .control3D .py{grid-column:4}#actionTabs .tabsMenu .panes .pane .textureLine .control3D .ny{grid-column:5}#actionTabs .tabsMenu .panes .pane .textureLine .control3D .pz{grid-column:6}#actionTabs .tabsMenu .panes .pane .textureLine .control3D .nz{grid-column:7}#actionTabs .tabsMenu .panes .pane .textureLine .command{border:1px solid rgba(0,0,0,0);background:rgba(0,0,0,0);color:#fff}#actionTabs .tabsMenu .panes .pane .textureLine .selected{border:1px solid #337ab7}#actionTabs .tabsMenu .panes .pane .textureLine .preview{grid-row:2;display:grid;align-self:center;justify-self:center;height:256px;width:256px;margin-top:5px;margin-bottom:5px;border:1px solid #fff;background-size:32px 32px;background-color:#fff;background-image:url(${d})}#actionTabs .tabsMenu .panes .pane .gltf-extension-property{margin-left:30px;border-left:1px solid #337ab7}#actionTabs .tabsMenu .panes .pane .floatLine{padding-left:2px;height:30px;display:grid;grid-template-columns:1fr 120px}#actionTabs .tabsMenu .panes .pane .floatLine .label{grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .floatLine .value{grid-column:2;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .floatLine .value input{width:110px}#actionTabs .tabsMenu .panes .pane .sliderLine{padding-left:2px;height:30px;display:grid;grid-template-rows:100%;grid-template-columns:1fr 50px auto}#actionTabs .tabsMenu .panes .pane .sliderLine .label{grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .sliderLine .withMargins{margin-left:5px}#actionTabs .tabsMenu .panes .pane .sliderLine .floatLine{padding-left:2px}#actionTabs .tabsMenu .panes .pane .sliderLine .floatLine .short{grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .sliderLine .floatLine .short input{width:35px}#actionTabs .tabsMenu .panes .pane .sliderLine .floatLine .short input::-webkit-outer-spin-button,#actionTabs .tabsMenu .panes .pane .sliderLine .floatLine .short input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}#actionTabs .tabsMenu .panes .pane .sliderLine .floatLine .short input[type=number]{-moz-appearance:textfield}#actionTabs .tabsMenu .panes .pane .sliderLine .slider{grid-column:3;grid-row:1;margin-right:5px;width:90%;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .sliderLine .slider .range{-webkit-appearance:none;width:100%;height:6px;background:#d3d3d3;border-radius:5px;outline:none;opacity:.7;-webkit-transition:.2s;transition:opacity .2s}#actionTabs .tabsMenu .panes .pane .sliderLine .slider .range:hover{opacity:1}#actionTabs .tabsMenu .panes .pane .sliderLine .slider .range::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:14px;height:14px;border-radius:50%;background:#337ab7;cursor:pointer}#actionTabs .tabsMenu .panes .pane .sliderLine .slider .range::-moz-range-thumb{width:14px;height:14px;border-radius:50%;background:#337ab7;cursor:pointer}#actionTabs .tabsMenu .panes .pane .color3Line{padding-left:2px;display:grid}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine{height:30px;display:grid;grid-template-columns:1fr auto 20px 20px}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine .label{grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine .color3{grid-column:2;width:50px;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine .color3 input[type=color]{-webkit-appearance:none;border:1px solid rgba(255,255,255,.5);padding:0;width:30px;height:20px}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine .color3 input[type=color]::-webkit-color-swatch-wrapper{padding:0}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine .color3 input[type=color]::-webkit-color-swatch{border:none}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine .color3 input{margin-right:5px}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine .copy{grid-column:3;display:grid;align-items:center;justify-items:center;cursor:pointer}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine .copy img{height:100%}#actionTabs .tabsMenu .panes .pane .color3Line .firstLine .expand{grid-column:4;display:grid;align-items:center;justify-items:center;cursor:pointer}#actionTabs .tabsMenu .panes .pane .color3Line .secondLine{display:grid;padding-right:5px;border-left:1px solid #337ab7}#actionTabs .tabsMenu .panes .pane .color3Line .secondLine .numeric{display:grid;grid-template-columns:1fr auto}#actionTabs .tabsMenu .panes .pane .color3Line .secondLine .numeric-label{text-align:right;grid-column:1;display:flex;align-items:center;justify-self:right;margin-right:10px}#actionTabs .tabsMenu .panes .pane .color3Line .secondLine .numeric-value{width:120px;grid-column:2;display:flex;align-items:center;border:1px solid #337ab7}#actionTabs .tabsMenu .panes .pane .listLine{padding-left:2px;height:30px;display:grid;grid-template-columns:1fr auto}#actionTabs .tabsMenu .panes .pane .listLine .label{grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .listLine .options{grid-column:2;display:flex;align-items:center;margin-right:5px}#actionTabs .tabsMenu .panes .pane .listLine .options select{width:115px}#actionTabs .tabsMenu .panes .pane .paneContainer{margin-top:3px;display:grid;grid-template-rows:100%;grid-template-columns:100%}#actionTabs .tabsMenu .panes .pane .paneContainer .paneList{border-left:3px solid rgba(0,0,0,0)}#actionTabs .tabsMenu .panes .pane .paneContainer:hover .paneList{border-left:3px solid rgba(51,122,183,.8)}#actionTabs .tabsMenu .panes .pane .paneContainer:hover .paneContainer-content .header .title{border-left:3px solid #337ab7}#actionTabs .tabsMenu .panes .pane .paneContainer .paneContainer-highlight-border{grid-row:1;grid-column:1;opacity:1;border:3px solid red;margin-bottom:-5px;z-index:100;transition:opacity 250ms;pointer-events:none}#actionTabs .tabsMenu .panes .pane .paneContainer .paneContainer-highlight-border.transparent{opacity:0}#actionTabs .tabsMenu .panes .pane .paneContainer .paneContainer-content{grid-row:1;grid-column:1}#actionTabs .tabsMenu .panes .pane .paneContainer .paneContainer-content .header{display:grid;grid-template-columns:1fr auto;background:#555;height:30px;padding-right:5px;cursor:pointer}#actionTabs .tabsMenu .panes .pane .paneContainer .paneContainer-content .header .title{border-left:3px solid rgba(0,0,0,0);padding-left:5px;grid-column:1;display:flex;align-items:center}#actionTabs .tabsMenu .panes .pane .paneContainer .paneContainer-content .header .collapse{grid-column:2;display:flex;align-items:center;justify-items:center;transform-origin:center}#actionTabs .tabsMenu .panes .pane .paneContainer .paneContainer-content .header .collapse.closed{transform:rotate(180deg)}#actionTabs .tabsMenu .panes .pane .paneContainer .paneContainer-content .paneList>div:not(:last-child){border-bottom:.5px solid rgba(255,255,255,.1)}#actionTabs .tabsMenu .panes .pane .paneContainer .paneContainer-content .fragment>div:not(:last-child){border-bottom:.5px solid rgba(255,255,255,.1)}`,"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/actionTabs/actionTabs.scss"],names:[],mappings:"AAEA,gBACI,iBAAA,CACA,SAAA,CACA,OAAA,CACA,UAAA,CAGJ,oBACI,YAAA,CAGJ,YACI,eAAA,CACA,WAAA,CACA,QAAA,CACA,SAAA,CACA,YAAA,CACA,2BAAA,CACA,iBAAA,CACA,eAAA,CAEA,6BACI,UAAA,CAGJ,oBACI,WAAA,CACA,cAAA,CACA,UAAA,CACA,eAAA,CACA,UAAA,CACA,iBAAA,CACA,YAAA,CACA,mCAAA,CACA,wBAAA,CACA,qBAAA,CACA,oBAAA,CACA,gBAAA,CAEA,0BACI,aAAA,CACA,UAAA,CACA,WAAA,CACA,YAAA,CACA,iBAAA,CACA,mBAAA,CAGJ,0BACI,aAAA,CACA,YAAA,CACA,iBAAA,CACA,mBAAA,CACA,cAAA,CAGJ,2BACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,iBAAA,CAGJ,8BACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,6BAAA,CAEA,sCACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CACA,cAAA,CAGJ,qCACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CACA,cAAA,CAKZ,sBACI,YAAA,CACA,UAAA,CACA,2BAAA,CACA,iBAAA,CACA,eAAA,CAEA,8BACI,UAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CACA,4BAAA,CACA,QAAA,CACA,SAAA,CAEA,qCACI,cAAA,CACA,UAAA,CACA,UAAA,CACA,YAAA,CACA,oBAAA,CACA,sBAAA,CACA,8BAAA,CACA,kBAAA,CACA,eAAA,CACA,WAAA,CACA,WAAA,CACA,cAAA,CAEA,4CACI,iBAAA,CACA,qCAAA,CACA,kBAAA,CAKZ,6BACI,UAAA,CACA,YAAA,CACA,uBAAA,CAEA,eAAA,CAEA,0CACI,UAAA,CACA,UAAA,CACA,uBAAA,CAGJ,4CACI,YAAA,CACA,uBAAA,CACA,mDAAA,CACA,eAAA,CACA,gBAAA,CACA,kBAAA,CACA,kBAAA,CAEA,kDACI,UAAA,CACA,aAAA,CAGJ,oDACI,WAAA,CAGJ,oDACI,WAAA,CACA,gBAAA,CAGJ,qDACI,UAAA,CACA,aAAA,CACA,cAAA,CAGJ,qDACI,gBAAA,CACA,UAAA,CACA,aAAA,CACA,cAAA,CAEA,6DACI,eAAA,CACA,iBAAA,CAIR,2DACI,sBAAA,CAGJ,kDACI,cAAA,CAGJ,wDACI,eAAA,CACA,UAAA,CACA,aAAA,CACA,gBAAA,CACA,gBAAA,CAGJ,yDACI,UAAA,CACA,aAAA,CACA,YAAA,CACA,uBAAA,CACA,oBAAA,CACA,iBAAA,CAEA,+DACI,UAAA,CAEJ,sEACI,SAAA,CAGJ,gEACI,uBAAA,CACA,UAAA,CACA,kBAAA,CACA,iBAAA,CACA,YAAA,CACA,UAAA,CACA,sBAAA,CACA,sBAAA,CAEJ,sFACI,uBAAA,CACA,eAAA,CACA,UAAA,CACA,WAAA,CACA,iBAAA,CACA,kBAAA,CACA,cAAA,CAGJ,kFACI,UAAA,CACA,WAAA,CACA,iBAAA,CACA,kBAAA,CACA,cAAA,CAIR,2DACI,UAAA,CACA,aAAA,CACA,YAAA,CACA,oBAAA,CACA,sBAAA,CAEA,gEACI,WAAA,CACA,UAAA,CAEJ,sEACI,cAAA,CAGR,6DACI,UAAA,CACA,aAAA,CACA,YAAA,CACA,oBAAA,CACA,sBAAA,CACA,kEACI,WAAA,CACA,UAAA,CAEJ,wEACI,cAAA,CAKZ,mCACI,UAAA,CAEA,iBAAA,CACA,eAAA,CACA,WAAA,CAEA,wBAAA,CACA,qBAAA,CACA,oBAAA,CACA,gBAAA,CAEA,mDACI,6BAAA,CACA,eAAA,CACA,2BAAA,CAGJ,8CACI,6CAAA,CAGJ,oDACI,YAAA,CACA,8BAAA,CAEA,2DACI,aAAA,CACA,eAAA,CACA,gBAAA,CACA,aAAA,CACA,kBAAA,CACA,oBAAA,CACA,cAAA,CACA,UAAA,CAEA,oEACI,SAAA,CAIR,8DACI,aAAA,CAGJ,gEACI,oBAAA,CACA,cAAA,CACA,gBAAA,CAIR,gDACI,iBAAA,CACA,cAAA,CACA,iBAAA,CACA,UAAA,CAGJ,oDACI,gBA5UA,CA6UA,WAAA,CACA,YAAA,CACA,8BAAA,CAEA,0DACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CAGJ,2DACI,aAAA,CACA,YAAA,CACA,kBAAA,CAIR,iDACI,uBAAA,CACA,UAAA,CACA,UAAA,CAEA,6DACI,uBAAA,CACA,qBAAA,CACA,cAAA,CACA,eAAA,CAGJ,qEACI,cAAA,CACA,OAAA,CACA,SAAA,CACA,UAAA,CACA,QAAA,CACA,WAAA,CAGJ,qEACI,iBAAA,CAIR,mDACI,gBA1XA,CA2XA,WAAA,CACA,YAAA,CACA,mCAAA,CAEA,yDACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,yBAAA,CACA,cAAA,CAGJ,gEACI,aAAA,CAEA,uEACI,eAAA,CACA,wBAAA,CACA,wBAAA,CACA,UAAA,CACA,eAAA,CACA,UAAA,CACA,cAAA,CAGJ,6EACI,SAAA,CAGJ,8EACI,kBAAA,CAGJ,6EACI,wBAAA,CACA,WAAA,CAIR,8DACI,aAAA,CACA,YAAA,CACA,oBAAA,CAIR,6CACI,gBA1aA,CA2aA,WAAA,CACA,YAAA,CACA,8BAAA,CAEA,sDACI,0BAAA,CAEA,kEACI,aAAA,CACA,gBAAA,CACA,gBAAA,CACA,UAAA,CACA,eAAA,CAGJ,6DACI,aAAA,CACA,gBAAA,CACA,gBAAA,CACA,UAAA,CACA,eAAA,CAIR,6DACI,UAAA,CACA,iBAAA,CAGJ,oDACI,aAAA,CACA,YAAA,CACA,kBAAA,CAGJ,yDACI,aAAA,CACA,kBAAA,CACA,sBAAA,CACA,eAAA,CACA,cAAA,CACA,UAAA,CACA,UAAA,CACA,cAAA,CACA,eAAA,CACA,yBAAA,CACA,cAAA,CAGJ,oDACI,aAAA,CACA,kBAAA,CACA,sBAAA,CACA,eAAA,CACA,cAAA,CACA,UAAA,CACA,UAAA,CACA,cAAA,CACA,eAAA,CACA,wBAAA,CACA,qBAAA,CACA,oBAAA,CACA,gBAAA,CAEA,0DACI,WAAA,CAGJ,4DACI,SAAA,CAKZ,uDACI,cAAA,CAEA,uEACI,WAAA,CACA,YAAA,CACA,oBAAA,CAGJ,sEACI,YAAA,CACA,uBAAA,CACA,uDAAA,CACA,eAAA,CACA,gBAAA,CACA,kBAAA,CACA,kBAAA,CACA,4BAAA,CAEA,4EACI,UAAA,CACA,aAAA,CAGJ,8EACI,WAAA,CAGJ,8EACI,WAAA,CACA,gBAAA,CAGJ,+EACI,UAAA,CACA,aAAA,CACA,cAAA,CAGJ,+EACI,gBAAA,CACA,UAAA,CACA,aAAA,CACA,cAAA,CAEA,uFACI,eAAA,CACA,iBAAA,CAIR,qFACI,sBAAA,CAGJ,kFACI,eAAA,CACA,UAAA,CACA,aAAA,CACA,gBAAA,CACA,gBAAA,CAGJ,mFACI,UAAA,CACA,aAAA,CACA,YAAA,CACA,uBAAA,CACA,oBAAA,CACA,gBAAA,CAEA,yFACI,UAAA,CAIR,uFACI,UAAA,CACA,aAAA,CACA,YAAA,CACA,oBAAA,CACA,sBAAA,CAKZ,kDACI,gBA5kBA,CA6kBA,WAAA,CACA,YAAA,CACA,+BAAA,CAEA,yDACI,aAAA,CACA,YAAA,CACA,kBAAA,CAGJ,yDACI,YAAA,CACA,kBAAA,CACA,aAAA,CAEA,+DACI,WAAA,CAKZ,+CACI,WAAA,CACA,YAAA,CACA,kBAAA,CACA,qBAAA,CAEA,gEACI,YAAA,CAGJ,4DACI,eAAA,CACA,wBAAA,CACA,wBAAA,CACA,UAAA,CACA,eAAA,CACA,cAAA,CACA,UAAA,CACA,cAAA,CACA,iBAAA,CAGJ,kEACI,SAAA,CAGJ,mEACI,qBAAA,CACA,sBAAA,CAGJ,sDACI,eAAA,CACA,wBAAA,CACA,wBAAA,CACA,UAAA,CACA,eAAA,CACA,UAAA,CACA,cAAA,CAGJ,4DACI,SAAA,CAGJ,6DACI,kBAAA,CAGJ,4DACI,wBAAA,CACA,WAAA,CAIR,8CACI,gBA1pBA,CA2pBA,WAAA,CACA,YAAA,CACA,8BAAA,CAEA,qDACI,aAAA,CACA,YAAA,CACA,kBAAA,CAGJ,8DACI,YAAA,CACA,kBAAA,CAEA,qEACI,aAAA,CACA,YAAA,CAEA,0FACI,oBAAA,CAEJ,yFACI,kBAAA,CAIR,6EACI,oBAAA,CACA,WAAA,CACA,iBAAA,CACA,cAAA,CACA,eAAA,CACA,cAAA,CACA,qBAAA,CACA,uKAEI,iBAAA,CACA,UAAA,CACA,iBAAA,CACA,uBAAA,CACA,0CAAA,CAEJ,oFACI,QAAA,CACA,KAAA,CACA,UAAA,CACA,WAAA,CACA,qBAAA,CAEJ,mFACI,OAAA,CACA,QAAA,CACA,SAAA,CACA,UAAA,CACA,kBAAA,CACA,kBAAA,CAMhB,gDACI,gBAztBA,CA0tBA,YAAA,CAEA,2DACI,YAAA,CACA,mCAAA,CACA,WAAA,CAEA,kEACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,kBAAA,CACA,eAAA,CAGJ,mEACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,gBAAA,CACA,UAAA,CACA,gBAAA,CAGJ,mEACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CACA,cAAA,CAIR,4DACI,YAAA,CACA,iBAAA,CACA,6BAAA,CAEA,qEACI,YAAA,CACA,8BAAA,CAGJ,2EACI,gBAAA,CACA,aAAA,CACA,YAAA,CACA,kBAAA,CACA,kBAAA,CACA,iBAAA,CAGJ,2EACI,WAAA,CACA,aAAA,CACA,YAAA,CACA,kBAAA,CACA,wBAAA,CAKZ,iDACI,gBAzxBA,CA0xBA,WAAA,CACA,YAAA,CACA,8BAAA,CAEA,wDACI,aAAA,CACA,YAAA,CACA,kBAAA,CAGJ,2DACI,aAAA,CAEA,YAAA,CACA,kBAAA,CAEA,gEACI,iBAAA,CACA,aAAA,CACA,WAAA,CACA,UAAA,CACA,gBAAA,CACA,kBAAA,CACA,mBAAA,CACA,cAAA,CACA,uBAAA,CAEA,wEACI,kBAAA,CAIR,sEACI,iBAAA,CACA,QAAA,CACA,OAAA,CACA,aAAA,CACA,UAAA,CACA,WAAA,CACA,mBAAA,CACA,eAAA,CACA,sCAAA,CACA,UAAA,CACA,wBAAA,CAEA,8EACI,SAAA,CACA,kBAAA,CAIR,8EACI,iBAAA,CACA,OAAA,CACA,aAAA,CACA,UAAA,CACA,WAAA,CACA,mBAAA,CACA,eAAA,CACA,sCAAA,CACA,UAAA,CACA,wBAAA,CACA,SAAA,CACA,kBAAA,CAGJ,6EACI,2BAAA,CAGJ,mEACI,YAAA,CAGJ,iEACI,YAAA,CAKZ,gDACI,YAAA,CACA,4BAAA,CAEA,yDACI,cAAA,CACA,UAAA,CACA,YAAA,CACA,sDAAA,CAEA,8DACI,aAAA,CAGJ,gEACI,aAAA,CAGJ,+DACI,aAAA,CAGJ,gEACI,aAAA,CAGJ,8DACI,aAAA,CAIR,2DACI,cAAA,CACA,UAAA,CACA,YAAA,CACA,2DAAA,CAEA,+DACI,aAAA,CAGJ,+DACI,aAAA,CAGJ,+DACI,aAAA,CAGJ,+DACI,aAAA,CAGJ,+DACI,aAAA,CAGJ,+DACI,aAAA,CAIR,yDACI,8BAAA,CACA,wBAAA,CACA,UAAA,CAGJ,0DACI,wBAAA,CAGJ,yDACI,UAAA,CACA,YAAA,CACA,iBAAA,CACA,mBAAA,CACA,YAAA,CACA,WAAA,CACA,cAAA,CACA,iBAAA,CACA,qBAAA,CACA,yBAAA,CACA,qBAAA,CACA,wDAAA,CAIR,4DACI,gBAAA,CACA,6BAAA,CAGJ,8CACI,gBAx8BA,CAy8BA,WAAA,CACA,YAAA,CACA,+BAAA,CAEA,qDACI,aAAA,CACA,YAAA,CACA,kBAAA,CAGJ,qDACI,aAAA,CAEA,YAAA,CACA,kBAAA,CAEA,2DACI,WAAA,CAKZ,+CACI,gBAh+BA,CAi+BA,WAAA,CACA,YAAA,CACA,uBAAA,CACA,mCAAA,CAEA,sDACI,aAAA,CACA,YAAA,CACA,kBAAA,CAGJ,4DACI,eAAA,CAGJ,0DACI,gBAj/BJ,CAm/BI,iEACI,aAAA,CACA,YAAA,CACA,kBAAA,CAEA,uEACI,UAAA,CAGJ,oMAEI,uBAAA,CACA,QAAA,CAGJ,oFACI,yBAAA,CAKZ,uDACI,aAAA,CACA,UAAA,CACA,gBAAA,CACA,SAAA,CACA,YAAA,CACA,kBAAA,CAEA,8DACI,uBAAA,CACA,UAAA,CACA,UAAA,CACA,kBAAA,CACA,iBAAA,CACA,YAAA,CACA,UAAA,CACA,sBAAA,CACA,sBAAA,CAGJ,oEACI,SAAA,CAGJ,oFACI,uBAAA,CACA,eAAA,CACA,UAAA,CACA,WAAA,CACA,iBAAA,CACA,kBAAA,CACA,cAAA,CAGJ,gFACI,UAAA,CACA,WAAA,CACA,iBAAA,CACA,kBAAA,CACA,cAAA,CAKZ,+CACI,gBArjCA,CAsjCA,YAAA,CAEA,0DACI,WAAA,CACA,YAAA,CACA,wCAAA,CAEA,iEACI,aAAA,CACA,YAAA,CACA,kBAAA,CAGJ,kEACI,aAAA,CACA,UAAA,CAEA,YAAA,CACA,kBAAA,CAEA,oFACI,uBAAA,CACA,qCAAA,CACA,SAAA,CACA,UAAA,CACA,WAAA,CAEJ,kHACI,SAAA,CAEJ,0GACI,WAAA,CAGJ,wEACI,gBAAA,CAIR,gEACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CACA,cAAA,CACA,oEACI,WAAA,CAIR,kEACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CACA,cAAA,CAIR,2DACI,YAAA,CACA,iBAAA,CACA,6BAAA,CAEA,oEACI,YAAA,CACA,8BAAA,CAGJ,0EACI,gBAAA,CACA,aAAA,CACA,YAAA,CACA,kBAAA,CACA,kBAAA,CACA,iBAAA,CAGJ,0EACI,WAAA,CACA,aAAA,CACA,YAAA,CACA,kBAAA,CACA,wBAAA,CAKZ,6CACI,gBA/oCA,CAgpCA,WAAA,CACA,YAAA,CACA,8BAAA,CAEA,oDACI,aAAA,CACA,YAAA,CACA,kBAAA,CAGJ,sDACI,aAAA,CAEA,YAAA,CACA,kBAAA,CACA,gBAAA,CAEA,6DACI,WAAA,CAKZ,kDACI,cAAA,CACA,YAAA,CACA,uBAAA,CACA,0BAAA,CAEA,4DACI,mCAAA,CAIA,kEACI,yCAAA,CAKI,8FACI,6BAAA,CAMhB,kFACI,UAAA,CACA,aAAA,CACA,SAAA,CACA,oBAAA,CACA,kBAAA,CACA,WAAA,CACA,wBAAA,CACA,mBAAA,CAEA,8FACI,SAAA,CAIR,yEACI,UAAA,CACA,aAAA,CAEA,iFACI,YAAA,CACA,8BAAA,CACA,eAAA,CACA,WAAA,CACA,iBAAA,CACA,cAAA,CAEA,wFACI,mCAAA,CACA,gBAAA,CACA,aAAA,CACA,YAAA,CACA,kBAAA,CAGJ,2FACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CACA,uBAAA,CAEA,kGACI,wBAAA,CAKZ,wGACI,6CAAA,CAGJ,wGACI,6CAAA",sourcesContent:['$line-padding-left: 2px;\r\n\r\n#inspector-host {\r\n position: absolute;\r\n right: 0px;\r\n top: 0px;\r\n bottom: 0px;\r\n}\r\n\r\n#__resizable_base__ {\r\n display: none;\r\n}\r\n\r\n#actionTabs {\r\n background: #333333;\r\n height: 100%;\r\n margin: 0;\r\n padding: 0;\r\n display: grid;\r\n grid-template-rows: auto 1fr;\r\n font: 14px "Arial";\r\n overflow: hidden;\r\n\r\n .hoverIcon:hover {\r\n opacity: 0.8;\r\n }\r\n\r\n #header {\r\n height: 30px;\r\n font-size: 16px;\r\n color: white;\r\n background: #222222;\r\n grid-row: 1;\r\n text-align: center;\r\n display: grid;\r\n grid-template-columns: 30px 1fr 50px;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n\r\n #logo {\r\n grid-column: 1;\r\n width: 24px;\r\n height: 24px;\r\n display: flex;\r\n align-self: center;\r\n justify-self: center;\r\n }\r\n\r\n #back {\r\n grid-column: 1;\r\n display: grid;\r\n align-self: center;\r\n justify-self: center;\r\n cursor: pointer;\r\n }\r\n\r\n #title {\r\n grid-column: 2;\r\n display: grid;\r\n align-items: center;\r\n text-align: center;\r\n }\r\n\r\n #commands {\r\n grid-column: 3;\r\n display: grid;\r\n align-items: center;\r\n grid-template-columns: 1fr 1fr;\r\n\r\n .expand {\r\n grid-column: 1;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n\r\n .close {\r\n grid-column: 2;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n }\r\n }\r\n\r\n .tabsMenu {\r\n display: grid;\r\n grid-row: 2;\r\n grid-template-rows: 40px 1fr;\r\n font: 14px "Arial";\r\n overflow: hidden;\r\n\r\n .labels {\r\n grid-row: 1;\r\n display: flex;\r\n align-items: center;\r\n justify-items: center;\r\n border-bottom: 1px solid #ffffff;\r\n margin: 0;\r\n padding: 0;\r\n\r\n .label {\r\n font-size: 24px;\r\n color: white;\r\n width: 40px;\r\n display: flex;\r\n align-content: center;\r\n justify-content: center;\r\n border: 1px solid transparent;\r\n border-bottom: none;\r\n background: #333333;\r\n padding: 5px;\r\n height: 28px;\r\n cursor: pointer;\r\n\r\n &.active {\r\n border-color: #ffffff;\r\n border-bottom: 2px solid transparent;\r\n margin-bottom: -2px;\r\n }\r\n }\r\n }\r\n\r\n .panes {\r\n grid-row: 2;\r\n display: grid;\r\n grid-template-rows: 100%;\r\n\r\n overflow: hidden;\r\n\r\n .infoMessage {\r\n opacity: 0.5;\r\n color: white;\r\n margin: 15px 5px 0px 5px;\r\n }\r\n\r\n .gradient-step {\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 20px 30px 40px auto 20px 30px;\r\n padding-top: 5px;\r\n padding-left: 5px;\r\n padding-bottom: 5px;\r\n align-items: center;\r\n\r\n .step {\r\n grid-row: 1;\r\n grid-column: 1;\r\n }\r\n\r\n .color1 {\r\n height: 100%;\r\n }\r\n\r\n .color2 {\r\n height: 100%;\r\n padding-left: 5px;\r\n }\r\n\r\n .factor1 {\r\n grid-row: 1;\r\n grid-column: 2;\r\n cursor: pointer;\r\n }\r\n\r\n .factor2 {\r\n padding-left: 5px;\r\n grid-row: 1;\r\n grid-column: 3;\r\n cursor: pointer;\r\n\r\n .grayed {\r\n background: gray;\r\n border-color: gray;\r\n }\r\n }\r\n\r\n .numeric-input {\r\n width: calc(100% - 5px);\r\n }\r\n\r\n .icon {\r\n cursor: pointer;\r\n }\r\n\r\n .step-value {\r\n margin-left: 5px;\r\n grid-row: 1;\r\n grid-column: 3;\r\n text-align: right;\r\n margin-right: 5px;\r\n }\r\n\r\n .step-slider {\r\n grid-row: 1;\r\n grid-column: 4;\r\n display: grid;\r\n justify-content: stretch;\r\n align-content: center;\r\n margin-right: 12px;\r\n\r\n input {\r\n width: 100%;\r\n }\r\n .range:hover {\r\n opacity: 1;\r\n }\r\n\r\n .range {\r\n -webkit-appearance: none;\r\n height: 6px;\r\n background: #d3d3d3;\r\n border-radius: 5px;\r\n outline: none;\r\n opacity: 0.7;\r\n -webkit-transition: 0.2s;\r\n transition: opacity 0.2s;\r\n }\r\n .range::-webkit-slider-thumb {\r\n -webkit-appearance: none;\r\n appearance: none;\r\n width: 14px;\r\n height: 14px;\r\n border-radius: 50%;\r\n background: rgb(51, 122, 183);\r\n cursor: pointer;\r\n }\r\n\r\n .range::-moz-range-thumb {\r\n width: 14px;\r\n height: 14px;\r\n border-radius: 50%;\r\n background: rgb(51, 122, 183);\r\n cursor: pointer;\r\n }\r\n }\r\n\r\n .gradient-copy {\r\n grid-row: 1;\r\n grid-column: 5;\r\n display: grid;\r\n align-content: center;\r\n justify-content: center;\r\n\r\n .img {\r\n height: 20px;\r\n width: 20px;\r\n }\r\n .img:hover {\r\n cursor: pointer;\r\n }\r\n }\r\n .gradient-delete {\r\n grid-row: 1;\r\n grid-column: 6;\r\n display: grid;\r\n align-content: center;\r\n justify-content: center;\r\n .img {\r\n height: 20px;\r\n width: 20px;\r\n }\r\n .img:hover {\r\n cursor: pointer;\r\n }\r\n }\r\n }\r\n\r\n .pane {\r\n color: white;\r\n\r\n overflow-x: hidden;\r\n overflow-y: auto;\r\n height: 100%;\r\n\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n\r\n .animation-info {\r\n border-left: greenyellow 3px solid;\r\n margin-left: 5px;\r\n padding-left: 5px !important;\r\n }\r\n\r\n .underline {\r\n border-bottom: 0.5px solid rgba(255, 255, 255, 0.5);\r\n }\r\n\r\n .textureLinkLine {\r\n display: grid;\r\n grid-template-columns: auto 1fr;\r\n\r\n .debug {\r\n grid-column: 1;\r\n margin-left: 5px;\r\n margin-right: 5px;\r\n display: block;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n opacity: 0.5;\r\n\r\n &.selected {\r\n opacity: 1;\r\n }\r\n }\r\n\r\n .textLine {\r\n grid-column: 2;\r\n }\r\n\r\n .actionIcon {\r\n display: inline-block;\r\n margin-top: 6px;\r\n margin-right: 4px;\r\n }\r\n }\r\n\r\n .messageLine {\r\n text-align: center;\r\n font-size: 12px;\r\n font-style: italic;\r\n opacity: 0.6;\r\n }\r\n\r\n .iconMessageLine {\r\n padding-left: $line-padding-left;\r\n height: 30px;\r\n display: grid;\r\n grid-template-columns: 30px 1fr;\r\n\r\n .icon {\r\n grid-column: 1;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n }\r\n\r\n .value {\r\n grid-column: 2;\r\n display: flex;\r\n align-items: center;\r\n }\r\n }\r\n\r\n .color-picker {\r\n height: calc(100% - 8px);\r\n margin: 4px;\r\n width: 100%;\r\n\r\n .color-rect {\r\n height: calc(100% - 4px);\r\n border: 2px white solid;\r\n cursor: pointer;\r\n min-height: 18px;\r\n }\r\n\r\n .color-picker-cover {\r\n position: fixed;\r\n top: 0px;\r\n right: 0px;\r\n bottom: 0px;\r\n left: 0px;\r\n z-index: 100;\r\n }\r\n\r\n .color-picker-float {\r\n position: absolute;\r\n }\r\n }\r\n\r\n .linkButtonLine {\r\n padding-left: $line-padding-left;\r\n height: 30px;\r\n display: grid;\r\n grid-template-columns: 1fr auto 20px;\r\n\r\n .link {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n text-decoration: underline;\r\n cursor: pointer;\r\n }\r\n\r\n .link-button {\r\n grid-column: 2;\r\n\r\n button {\r\n background: #222222;\r\n border: 1px solid rgb(51, 122, 183);\r\n margin: 5px 10px 5px 10px;\r\n color: white;\r\n padding: 4px 5px;\r\n opacity: 0.9;\r\n cursor: pointer;\r\n }\r\n\r\n button:hover {\r\n opacity: 1;\r\n }\r\n\r\n button:active {\r\n background: #282828;\r\n }\r\n\r\n button:focus {\r\n border: 1px solid rgb(51, 122, 183);\r\n outline: 0px;\r\n }\r\n }\r\n\r\n .link-icon {\r\n grid-column: 3;\r\n display: grid;\r\n align-content: center;\r\n }\r\n }\r\n\r\n .textLine {\r\n padding-left: $line-padding-left;\r\n height: 30px;\r\n display: grid;\r\n grid-template-columns: 1fr auto;\r\n\r\n &.indented {\r\n grid-template-columns: 100%;\r\n\r\n .link-value {\r\n grid-column: 1;\r\n text-align: start;\r\n margin-left: 20px;\r\n opacity: 0.6;\r\n max-width: unset;\r\n }\r\n\r\n .value {\r\n grid-column: 1;\r\n text-align: start;\r\n margin-left: 20px;\r\n opacity: 0.6;\r\n max-width: unset;\r\n }\r\n }\r\n\r\n &.reduced-opacity {\r\n opacity: 0.6;\r\n padding-left: 25px;\r\n }\r\n\r\n .label {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .link-value {\r\n grid-column: 2;\r\n white-space: nowrap;\r\n text-overflow: ellipsis;\r\n overflow: hidden;\r\n text-align: end;\r\n opacity: 0.8;\r\n margin: 5px;\r\n margin-top: 7px;\r\n max-width: 140px;\r\n text-decoration: underline;\r\n cursor: pointer;\r\n }\r\n\r\n .value {\r\n grid-column: 2;\r\n white-space: nowrap;\r\n text-overflow: ellipsis;\r\n overflow: hidden;\r\n text-align: end;\r\n opacity: 0.8;\r\n margin: 5px;\r\n margin-top: 7px;\r\n max-width: 200px;\r\n -webkit-user-select: text;\r\n -moz-user-select: text;\r\n -ms-user-select: text;\r\n user-select: text;\r\n\r\n &.check {\r\n color: green;\r\n }\r\n\r\n &.uncheck {\r\n color: red;\r\n }\r\n }\r\n }\r\n\r\n .gradient-container {\r\n margin-top: 3px;\r\n\r\n .gradient-label {\r\n height: 30px;\r\n display: grid;\r\n align-content: center;\r\n }\r\n\r\n .gradient-step {\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 25px 50px 55px 40px auto 20px 5px;\r\n padding-top: 5px;\r\n padding-left: 5px;\r\n padding-bottom: 5px;\r\n align-items: center;\r\n border-left: orange 3px solid;\r\n\r\n .step {\r\n grid-row: 1;\r\n grid-column: 1;\r\n }\r\n\r\n .color1 {\r\n height: 100%;\r\n }\r\n\r\n .color2 {\r\n height: 100%;\r\n padding-left: 5px;\r\n }\r\n\r\n .factor1 {\r\n grid-row: 1;\r\n grid-column: 2;\r\n cursor: pointer;\r\n }\r\n\r\n .factor2 {\r\n padding-left: 5px;\r\n grid-row: 1;\r\n grid-column: 3;\r\n cursor: pointer;\r\n\r\n .grayed {\r\n background: gray;\r\n border-color: gray;\r\n }\r\n }\r\n\r\n .numeric-input {\r\n width: calc(100% - 5px);\r\n }\r\n\r\n .step-value {\r\n margin-left: 5px;\r\n grid-row: 1;\r\n grid-column: 4;\r\n text-align: right;\r\n margin-right: 5px;\r\n }\r\n\r\n .step-slider {\r\n grid-row: 1;\r\n grid-column: 5;\r\n display: grid;\r\n justify-content: stretch;\r\n align-content: center;\r\n margin-right: 5px;\r\n\r\n input {\r\n width: 100%;\r\n }\r\n }\r\n\r\n .gradient-delete {\r\n grid-row: 1;\r\n grid-column: 6;\r\n display: grid;\r\n align-content: center;\r\n justify-content: center;\r\n }\r\n }\r\n }\r\n\r\n .textInputLine {\r\n padding-left: $line-padding-left;\r\n height: 30px;\r\n display: grid;\r\n grid-template-columns: 1fr 120px;\r\n\r\n .label {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .value {\r\n display: flex;\r\n align-items: center;\r\n grid-column: 2;\r\n\r\n input {\r\n width: 110px;\r\n }\r\n }\r\n }\r\n\r\n .buttonLine {\r\n height: 30px;\r\n display: grid;\r\n align-items: center;\r\n justify-items: stretch;\r\n\r\n input[type="file"] {\r\n display: none;\r\n }\r\n\r\n .file-upload {\r\n background: #222222;\r\n border: 1px solid rgb(51, 122, 183);\r\n margin: 5px 10px 5px 10px;\r\n color: white;\r\n padding: 4px 5px;\r\n font-size: 13px;\r\n opacity: 0.9;\r\n cursor: pointer;\r\n text-align: center;\r\n }\r\n\r\n .file-upload:hover {\r\n opacity: 1;\r\n }\r\n\r\n .file-upload:active {\r\n transform: scale(0.98);\r\n transform-origin: 0.5 0.5;\r\n }\r\n\r\n button {\r\n background: #222222;\r\n border: 1px solid rgb(51, 122, 183);\r\n margin: 5px 10px 5px 10px;\r\n color: white;\r\n padding: 4px 5px;\r\n opacity: 0.9;\r\n cursor: pointer;\r\n }\r\n\r\n button:hover {\r\n opacity: 1;\r\n }\r\n\r\n button:active {\r\n background: #282828;\r\n }\r\n\r\n button:focus {\r\n border: 1px solid rgb(51, 122, 183);\r\n outline: 0px;\r\n }\r\n }\r\n\r\n .radioLine {\r\n padding-left: $line-padding-left;\r\n height: 30px;\r\n display: grid;\r\n grid-template-columns: 1fr 24px;\r\n\r\n .label {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .radioContainer {\r\n display: flex;\r\n align-items: center;\r\n\r\n .radio {\r\n grid-column: 2;\r\n display: none;\r\n\r\n &:checked + label:before {\r\n border-color: rgb(51, 122, 183);\r\n }\r\n &:checked + label:after {\r\n transform: scale(1);\r\n }\r\n }\r\n\r\n .labelForRadio {\r\n display: inline-block;\r\n height: 14px;\r\n position: relative;\r\n padding: 0 24px;\r\n margin-bottom: 0;\r\n cursor: pointer;\r\n vertical-align: bottom;\r\n &:before,\r\n &:after {\r\n position: absolute;\r\n content: "";\r\n border-radius: 50%;\r\n transition: all 0.3s ease;\r\n transition-property: transform, border-color;\r\n }\r\n &:before {\r\n left: 0px;\r\n top: 0;\r\n width: 16px;\r\n height: 16px;\r\n border: 2px solid white;\r\n }\r\n &:after {\r\n top: 6px;\r\n left: 6px;\r\n width: 8px;\r\n height: 8px;\r\n transform: scale(0);\r\n background: rgb(51, 122, 183);\r\n }\r\n }\r\n }\r\n }\r\n\r\n .vector3Line {\r\n padding-left: $line-padding-left;\r\n display: grid;\r\n\r\n .firstLine {\r\n display: grid;\r\n grid-template-columns: 1fr auto 20px;\r\n height: 30px;\r\n\r\n .label {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n }\r\n\r\n .vector {\r\n grid-column: 2;\r\n display: flex;\r\n align-items: center;\r\n text-align: right;\r\n opacity: 0.8;\r\n padding-left: 5px;\r\n }\r\n\r\n .expand {\r\n grid-column: 3;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n }\r\n\r\n .secondLine {\r\n display: grid;\r\n padding-right: 5px;\r\n border-left: 1px solid rgb(51, 122, 183);\r\n\r\n .numeric {\r\n display: grid;\r\n grid-template-columns: 1fr auto;\r\n }\r\n\r\n .numeric-label {\r\n text-align: right;\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n justify-self: right;\r\n margin-right: 10px;\r\n }\r\n\r\n .numeric-value {\r\n width: 120px;\r\n grid-column: 2;\r\n display: flex;\r\n align-items: center;\r\n border: 1px solid rgb(51, 122, 183);\r\n }\r\n }\r\n }\r\n\r\n .checkBoxLine {\r\n padding-left: $line-padding-left;\r\n height: 30px;\r\n display: grid;\r\n grid-template-columns: 1fr auto;\r\n\r\n .label {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .checkBox {\r\n grid-column: 2;\r\n\r\n display: flex;\r\n align-items: center;\r\n\r\n .lbl {\r\n position: relative;\r\n display: block;\r\n height: 14px;\r\n width: 34px;\r\n margin-right: 5px;\r\n background: #898989;\r\n border-radius: 100px;\r\n cursor: pointer;\r\n transition: all 0.3s ease;\r\n\r\n &.checked {\r\n background: rgb(51, 122, 183);\r\n }\r\n }\r\n\r\n .lbl:after {\r\n position: absolute;\r\n left: 3px;\r\n top: 2px;\r\n display: block;\r\n width: 10px;\r\n height: 10px;\r\n border-radius: 100px;\r\n background: #fff;\r\n box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.05);\r\n content: "";\r\n transition: all 0.15s ease;\r\n\r\n &.checked {\r\n left: 20px;\r\n background: rgb(22, 73, 117);\r\n }\r\n }\r\n\r\n .lbl.checked:after {\r\n position: absolute;\r\n top: 2px;\r\n display: block;\r\n width: 10px;\r\n height: 10px;\r\n border-radius: 100px;\r\n background: #fff;\r\n box-shadow: 0px 3px 3px rgba(0, 0, 0, 0.05);\r\n content: "";\r\n transition: all 0.15s ease;\r\n left: 20px;\r\n background: rgb(22, 73, 117);\r\n }\r\n\r\n .lbl:active:after {\r\n transform: scale(1.15, 0.85);\r\n }\r\n\r\n .hidden {\r\n display: none;\r\n }\r\n\r\n .icon {\r\n display: none;\r\n }\r\n }\r\n }\r\n\r\n .textureLine {\r\n display: grid;\r\n grid-template-rows: 30px auto;\r\n\r\n .control {\r\n margin-top: 2px;\r\n grid-row: 1;\r\n display: grid;\r\n grid-template-columns: 1fr 40px 40px 40px 40px 40px 1fr;\r\n\r\n .red {\r\n grid-column: 2;\r\n }\r\n\r\n .green {\r\n grid-column: 3;\r\n }\r\n\r\n .blue {\r\n grid-column: 4;\r\n }\r\n\r\n .alpha {\r\n grid-column: 5;\r\n }\r\n\r\n .all {\r\n grid-column: 6;\r\n }\r\n }\r\n\r\n .control3D {\r\n margin-top: 2px;\r\n grid-row: 1;\r\n display: grid;\r\n grid-template-columns: 1fr 40px 40px 40px 40px 40px 40px 1fr;\r\n\r\n .px {\r\n grid-column: 2;\r\n }\r\n\r\n .nx {\r\n grid-column: 3;\r\n }\r\n\r\n .py {\r\n grid-column: 4;\r\n }\r\n\r\n .ny {\r\n grid-column: 5;\r\n }\r\n\r\n .pz {\r\n grid-column: 6;\r\n }\r\n\r\n .nz {\r\n grid-column: 7;\r\n }\r\n }\r\n\r\n .command {\r\n border: 1px solid transparent;\r\n background: transparent;\r\n color: white;\r\n }\r\n\r\n .selected {\r\n border: 1px solid rgb(51, 122, 183);\r\n }\r\n\r\n .preview {\r\n grid-row: 2;\r\n display: grid;\r\n align-self: center;\r\n justify-self: center;\r\n height: 256px;\r\n width: 256px;\r\n margin-top: 5px;\r\n margin-bottom: 5px;\r\n border: 1px solid white;\r\n background-size: 32px 32px;\r\n background-color: white;\r\n background-image: url("data:image/svg+xml,%3Csvg xmlns=\'http://www.w3.org/2000/svg\' viewBox=\'0 0 2 2\'%3E%3Cpath fill=\'rgba(1.0,1.0,1.0,0.3)\' fill-rule=\'evenodd\' d=\'M0 0h1v1H0V0zm1 1h1v1H1V1z\'/%3E%3C/svg%3E");\r\n }\r\n }\r\n\r\n .gltf-extension-property {\r\n margin-left: 30px;\r\n border-left: 1px solid rgb(51, 122, 183);\r\n }\r\n\r\n .floatLine {\r\n padding-left: $line-padding-left;\r\n height: 30px;\r\n display: grid;\r\n grid-template-columns: 1fr 120px;\r\n\r\n .label {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .value {\r\n grid-column: 2;\r\n\r\n display: flex;\r\n align-items: center;\r\n\r\n input {\r\n width: 110px;\r\n }\r\n }\r\n }\r\n\r\n .sliderLine {\r\n padding-left: $line-padding-left;\r\n height: 30px;\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 1fr 50px auto;\r\n\r\n .label {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .withMargins {\r\n margin-left: 5px;\r\n }\r\n\r\n .floatLine {\r\n padding-left: $line-padding-left;\r\n\r\n .short {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n\r\n input {\r\n width: 35px;\r\n }\r\n\r\n input::-webkit-outer-spin-button,\r\n input::-webkit-inner-spin-button {\r\n -webkit-appearance: none;\r\n margin: 0;\r\n }\r\n\r\n input[type="number"] {\r\n -moz-appearance: textfield;\r\n }\r\n }\r\n }\r\n\r\n .slider {\r\n grid-column: 3;\r\n grid-row: 1;\r\n margin-right: 5px;\r\n width: 90%;\r\n display: flex;\r\n align-items: center;\r\n\r\n .range {\r\n -webkit-appearance: none;\r\n width: 100%;\r\n height: 6px;\r\n background: #d3d3d3;\r\n border-radius: 5px;\r\n outline: none;\r\n opacity: 0.7;\r\n -webkit-transition: 0.2s;\r\n transition: opacity 0.2s;\r\n }\r\n\r\n .range:hover {\r\n opacity: 1;\r\n }\r\n\r\n .range::-webkit-slider-thumb {\r\n -webkit-appearance: none;\r\n appearance: none;\r\n width: 14px;\r\n height: 14px;\r\n border-radius: 50%;\r\n background: rgb(51, 122, 183);\r\n cursor: pointer;\r\n }\r\n\r\n .range::-moz-range-thumb {\r\n width: 14px;\r\n height: 14px;\r\n border-radius: 50%;\r\n background: rgb(51, 122, 183);\r\n cursor: pointer;\r\n }\r\n }\r\n }\r\n\r\n .color3Line {\r\n padding-left: $line-padding-left;\r\n display: grid;\r\n\r\n .firstLine {\r\n height: 30px;\r\n display: grid;\r\n grid-template-columns: 1fr auto 20px 20px;\r\n\r\n .label {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .color3 {\r\n grid-column: 2;\r\n width: 50px;\r\n\r\n display: flex;\r\n align-items: center;\r\n\r\n input[type="color"] {\r\n -webkit-appearance: none;\r\n border: 1px solid rgba(255, 255, 255, 0.5);\r\n padding: 0;\r\n width: 30px;\r\n height: 20px;\r\n }\r\n input[type="color"]::-webkit-color-swatch-wrapper {\r\n padding: 0;\r\n }\r\n input[type="color"]::-webkit-color-swatch {\r\n border: none;\r\n }\r\n\r\n input {\r\n margin-right: 5px;\r\n }\r\n }\r\n\r\n .copy {\r\n grid-column: 3;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n img {\r\n height: 100%;\r\n }\r\n }\r\n\r\n .expand {\r\n grid-column: 4;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n }\r\n\r\n .secondLine {\r\n display: grid;\r\n padding-right: 5px;\r\n border-left: 1px solid rgb(51, 122, 183);\r\n\r\n .numeric {\r\n display: grid;\r\n grid-template-columns: 1fr auto;\r\n }\r\n\r\n .numeric-label {\r\n text-align: right;\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n justify-self: right;\r\n margin-right: 10px;\r\n }\r\n\r\n .numeric-value {\r\n width: 120px;\r\n grid-column: 2;\r\n display: flex;\r\n align-items: center;\r\n border: 1px solid rgb(51, 122, 183);\r\n }\r\n }\r\n }\r\n\r\n .listLine {\r\n padding-left: $line-padding-left;\r\n height: 30px;\r\n display: grid;\r\n grid-template-columns: 1fr auto;\r\n\r\n .label {\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .options {\r\n grid-column: 2;\r\n\r\n display: flex;\r\n align-items: center;\r\n margin-right: 5px;\r\n\r\n select {\r\n width: 115px;\r\n }\r\n }\r\n }\r\n\r\n .paneContainer {\r\n margin-top: 3px;\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 100%;\r\n\r\n .paneList {\r\n border-left: 3px solid transparent;\r\n }\r\n\r\n &:hover {\r\n .paneList {\r\n border-left: 3px solid rgba(51, 122, 183, 0.8);\r\n }\r\n\r\n .paneContainer-content {\r\n .header {\r\n .title {\r\n border-left: 3px solid rgb(51, 122, 183);\r\n }\r\n }\r\n }\r\n }\r\n\r\n .paneContainer-highlight-border {\r\n grid-row: 1;\r\n grid-column: 1;\r\n opacity: 1;\r\n border: 3px solid red;\r\n margin-bottom: -5px;\r\n z-index: 100;\r\n transition: opacity 250ms;\r\n pointer-events: none;\r\n\r\n &.transparent {\r\n opacity: 0;\r\n }\r\n }\r\n\r\n .paneContainer-content {\r\n grid-row: 1;\r\n grid-column: 1;\r\n\r\n .header {\r\n display: grid;\r\n grid-template-columns: 1fr auto;\r\n background: #555555;\r\n height: 30px;\r\n padding-right: 5px;\r\n cursor: pointer;\r\n\r\n .title {\r\n border-left: 3px solid transparent;\r\n padding-left: 5px;\r\n grid-column: 1;\r\n display: flex;\r\n align-items: center;\r\n }\r\n\r\n .collapse {\r\n grid-column: 2;\r\n display: flex;\r\n align-items: center;\r\n justify-items: center;\r\n transform-origin: center;\r\n\r\n &.closed {\r\n transform: rotate(180deg);\r\n }\r\n }\r\n }\r\n\r\n .paneList > div:not(:last-child) {\r\n border-bottom: 0.5px solid rgba(255, 255, 255, 0.1);\r\n }\r\n\r\n .fragment > div:not(:last-child) {\r\n border-bottom: 0.5px solid rgba(255, 255, 255, 0.1);\r\n }\r\n }\r\n }\r\n }\r\n }\r\n }\r\n}\r\n'],sourceRoot:""}]),c.locals={};const h=c},8560:(e,t,r)=>{"use strict";r.d(t,{Z:()=>i});var n=r(4864),o=r.n(n),s=r(7885),a=r.n(s)()(o());a.push([e.id,'#performance-viewer{display:grid;height:100%;width:100%;grid-template-columns:300px 1fr;font-family:"acumin-pro"}#performance-viewer .performancePlayheadButton{grid-area:liveButton;height:30px;width:100px;justify-self:right;background-color:#dcdfe1;color:#2e3f47;outline:2px #2e3f47;margin:5px;position:absolute;top:10px;right:10px}#performance-viewer #performance-viewer-sidebar{display:flex;flex-direction:column;overflow-y:scroll;border:2px solid gray}#performance-viewer #performance-viewer-sidebar .sidebar-item{display:grid;width:100%;height:30px;font-size:14px;padding:2.5px 0px;align-items:center}#performance-viewer #performance-viewer-sidebar .header{color:#fff;grid-template-columns:10px 9fr 1fr 10px}#performance-viewer #performance-viewer-sidebar .header .category{grid-column:2}#performance-viewer #performance-viewer-sidebar .header .value{grid-column:3}#performance-viewer #performance-viewer-sidebar .version-header{background-color:#2e3f47;color:#fff;grid-template-columns:10px 1fr 1fr 10px;font-size:14px;height:35px}#performance-viewer #performance-viewer-sidebar .version-header .category{grid-column:2}#performance-viewer #performance-viewer-sidebar .version-header .value{grid-column:3;display:flex;justify-content:end}#performance-viewer #performance-viewer-sidebar .category-header{background-color:#4a5960;text-transform:uppercase;font-size:14px;height:30px}#performance-viewer #performance-viewer-sidebar .category-header .checkBoxLine{color:#dcdfe1}#performance-viewer #performance-viewer-sidebar .measure{color:#000;grid-template-columns:18px 6fr 1fr;font-family:"acumin-pro-condensed"}#performance-viewer #performance-viewer-sidebar .measure .category{display:grid;grid-template-columns:18px 7px 18px 10px 1fr;grid-column:2;align-items:center}#performance-viewer #performance-viewer-sidebar .measure .category .color-picker{grid-column:3}#performance-viewer #performance-viewer-sidebar .measure .category .sidebar-item-label{grid-column:5}#performance-viewer #performance-viewer-sidebar .measure .value{grid-column:3}#performance-viewer #performance-viewer-sidebar .measure:nth-child(odd){background-color:#dcdfe1}#performance-viewer #performance-viewer-sidebar .measure:nth-child(even){background-color:#ebedee}#performance-viewer #performance-viewer-sidebar .checkBoxLine{color:#4a5960;width:100%;height:100%;display:flex;justify-content:center;align-items:center}#performance-viewer #performance-viewer-sidebar .checkBoxLine .disabled{color:#d3d3d3}#performance-viewer #performance-viewer-sidebar .color-picker{width:100%}#performance-viewer #performance-viewer-sidebar .color-picker .color-rect{height:18px;width:18px;cursor:pointer}#performance-viewer #performance-viewer-sidebar .color-picker .color-picker-cover{position:fixed;top:0px;right:0px;bottom:0px;left:0px;z-index:100}#performance-viewer #performance-viewer-sidebar .color-picker .color-picker-float{position:absolute}#performance-viewer #performance-viewer-sidebar .color-picker .color-picker-float .color-picker-container{width:200px}',"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/actionTabs/tabs/performanceViewer/scss/performanceViewer.scss"],names:[],mappings:"AAGA,oBACI,YAAA,CACA,WAAA,CACA,UAAA,CACA,+BAAA,CACA,wBAAA,CAEA,+CACI,oBAAA,CACA,WAZO,CAaP,WAAA,CACA,kBAAA,CACA,wBAAA,CACA,aAAA,CACA,mBAAA,CACA,UAAA,CACA,iBAAA,CACA,QAAA,CACA,UAAA,CAGJ,gDACI,YAAA,CACA,qBAAA,CACA,iBAAA,CAEA,qBAAA,CAEA,8DACI,YAAA,CACA,UAAA,CACA,WAAA,CACA,cAAA,CACA,iBAAA,CACA,kBAAA,CAGJ,wDACI,UAAA,CACA,uCAAA,CAEA,kEACI,aAAA,CAGJ,+DACI,aAAA,CAIR,gEACI,wBAAA,CACA,UAAA,CACA,uCAAA,CACA,cAAA,CACA,WAAA,CAEA,0EACI,aAAA,CAGJ,uEACI,aAAA,CACA,YAAA,CACA,mBAAA,CAKR,iEACI,wBAAA,CACA,wBAAA,CACA,cAAA,CACA,WAAA,CAEA,+EACI,aAAA,CAIR,yDACI,UAAA,CACA,kCAAA,CACA,kCAAA,CAEA,mEACI,YAAA,CACA,4CAAA,CACA,aAAA,CACA,kBAAA,CAEA,iFACI,aAAA,CAGJ,uFACI,aAAA,CAIR,gEACI,aAAA,CAKR,wEACI,wBAAA,CAIJ,yEACI,wBAAA,CAGJ,8DACI,aAAA,CACA,UAAA,CACA,WAAA,CACA,YAAA,CACA,sBAAA,CACA,kBAAA,CACA,wEACI,aAAA,CAIR,8DACI,UAAA,CAEA,0EACI,WArIH,CAsIG,UAtIH,CAuIG,cAAA,CAGJ,kFACI,cAAA,CACA,OAAA,CACA,SAAA,CACA,UAAA,CACA,QAAA,CACA,WAAA,CAGJ,kFACI,iBAAA,CAEA,0GACI,WAAA",sourcesContent:['$buttonHeight: 30px;\r\n$squareSize: 18px;\r\n\r\n#performance-viewer {\r\n display: grid;\r\n height: 100%;\r\n width: 100%;\r\n grid-template-columns: 300px 1fr;\r\n font-family: "acumin-pro";\r\n\r\n .performancePlayheadButton {\r\n grid-area: liveButton;\r\n height: $buttonHeight;\r\n width: 100px;\r\n justify-self: right;\r\n background-color: #dcdfe1;\r\n color: #2e3f47;\r\n outline: 2px #2e3f47;\r\n margin: 5px;\r\n position: absolute;\r\n top: 10px;\r\n right: 10px;\r\n }\r\n\r\n #performance-viewer-sidebar {\r\n display: flex;\r\n flex-direction: column;\r\n overflow-y: scroll;\r\n\r\n border: 2px solid gray;\r\n\r\n .sidebar-item {\r\n display: grid;\r\n width: 100%;\r\n height: 30px;\r\n font-size: 14px;\r\n padding: 2.5px 0px;\r\n align-items: center;\r\n }\r\n\r\n .header {\r\n color: white;\r\n grid-template-columns: 10px 9fr 1fr 10px;\r\n\r\n .category {\r\n grid-column: 2;\r\n }\r\n\r\n .value {\r\n grid-column: 3;\r\n }\r\n }\r\n\r\n .version-header {\r\n background-color: #2e3f47;\r\n color: white;\r\n grid-template-columns: 10px 1fr 1fr 10px;\r\n font-size: 14px;\r\n height: 35px; // with padding, we get 40px\r\n\r\n .category {\r\n grid-column: 2;\r\n }\r\n\r\n .value {\r\n grid-column: 3;\r\n display: flex;\r\n justify-content: end;\r\n }\r\n }\r\n\r\n // mid-dark color\r\n .category-header {\r\n background-color: #4a5960;\r\n text-transform: uppercase;\r\n font-size: 14px;\r\n height: 30px;\r\n\r\n .checkBoxLine {\r\n color: #dcdfe1;\r\n }\r\n }\r\n\r\n .measure {\r\n color: black;\r\n grid-template-columns: $squareSize 6fr 1fr;\r\n font-family: "acumin-pro-condensed";\r\n\r\n .category {\r\n display: grid;\r\n grid-template-columns: $squareSize 7px $squareSize 10px 1fr;\r\n grid-column: 2;\r\n align-items: center;\r\n\r\n .color-picker {\r\n grid-column: 3;\r\n }\r\n\r\n .sidebar-item-label {\r\n grid-column: 5;\r\n }\r\n }\r\n\r\n .value {\r\n grid-column: 3;\r\n }\r\n }\r\n\r\n //darker color\r\n .measure:nth-child(odd) {\r\n background-color: #dcdfe1;\r\n }\r\n\r\n // lighter color\r\n .measure:nth-child(even) {\r\n background-color: #ebedee;\r\n }\r\n\r\n .checkBoxLine {\r\n color: #4a5960;\r\n width: 100%;\r\n height: 100%;\r\n display: flex;\r\n justify-content: center;\r\n align-items: center;\r\n .disabled {\r\n color: lightgray;\r\n }\r\n }\r\n\r\n .color-picker {\r\n width: 100%;\r\n\r\n .color-rect {\r\n height: $squareSize;\r\n width: $squareSize;\r\n cursor: pointer;\r\n }\r\n\r\n .color-picker-cover {\r\n position: fixed;\r\n top: 0px;\r\n right: 0px;\r\n bottom: 0px;\r\n left: 0px;\r\n z-index: 100;\r\n }\r\n\r\n .color-picker-float {\r\n position: absolute;\r\n\r\n .color-picker-container {\r\n width: 200px;\r\n }\r\n }\r\n }\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},7452:(e,t,r)=>{"use strict";r.d(t,{Z:()=>i});var n=r(4864),o=r.n(n),s=r(7885),a=r.n(s)()(o());a.push([e.id,'#bottom-bar{display:grid;grid-template-rows:100%;grid-template-columns:10px 210px 10px 1fr 10px 61px 10px}#bottom-bar #bottom-bar-total{grid-row:1;grid-column:6;color:#fff;background:#222;height:25px;align-self:center;font-size:12pt}#bottom-bar #bottom-bar-total #clip-range{width:100%}#bottom-bar .control-button .control-button-image{display:unset}#bottom-bar .control-button .control-button-hover-image{display:none}#bottom-bar .control-button:hover{cursor:pointer}#bottom-bar .control-button:hover .control-button-image{display:none}#bottom-bar .control-button:hover .control-button-hover-image{display:unset}#bottom-bar .control-button:active{transform-origin:50% 50%;transform:scale(0.96)}#bottom-bar #media-player{grid-row:1;grid-column:2;display:grid;align-self:center;justify-self:center;grid-template-rows:100%;grid-template-columns:23px 23px 23px 23px 23px 23px 23px}#bottom-bar #media-player #start-key{grid-row:1;grid-column:1}#bottom-bar #media-player #prev-frame{grid-row:1;grid-column:2}#bottom-bar #media-player #first-key{grid-row:1;grid-column:3}#bottom-bar #media-player #rev-key{grid-row:1;grid-column:4}#bottom-bar #media-player #fwd-key{grid-row:1;grid-column:5}#bottom-bar #media-player #next-key{grid-row:1;grid-column:6}#bottom-bar #media-player #next-frame{grid-row:1;grid-column:7}#bottom-bar #media-player #end-key{grid-row:1;grid-column:8}#bottom-bar #range-selector{grid-row:1;grid-column:4;background:#222;width:100%;height:calc(100% - 20px);margin:10px 0;position:relative}#bottom-bar #range-selector #range-scrollbar{position:absolute;left:2px;top:2px;right:2px;bottom:2px;background:#666;display:grid;grid-template-rows:100%;grid-template-columns:20px auto 1fr auto 20px;color:#222;font-family:"acumin-pro-condensed";font-size:14px;min-width:70px}#bottom-bar #range-selector #range-scrollbar #left-handle{grid-row:1;grid-column:1}#bottom-bar #range-selector #range-scrollbar #right-handle{grid-row:1;grid-column:5}#bottom-bar #range-selector #range-scrollbar #from-key{grid-row:1;grid-column:2;align-self:center;justify-self:center;user-select:none;pointer-events:none}#bottom-bar #range-selector #range-scrollbar #to-key{grid-row:1;grid-column:4;align-self:center;justify-self:center;user-select:none;pointer-events:none}#bottom-bar #range-selector #range-scrollbar .handle{width:20px;align-self:center;justify-self:center;cursor:pointer;user-select:none}#bottom-bar #range-selector #range-scrollbar .handle img{pointer-events:none}',"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/actionTabs/tabs/propertyGrids/animations/curveEditor/scss/bottomBar.scss"],names:[],mappings:"AAAA,YACI,YAAA,CACA,uBAAA,CACA,wDAAA,CAEA,8BACI,UAAA,CACA,aAAA,CACA,UAAA,CACA,eAAA,CACA,WAAA,CACA,iBAAA,CACA,cAAA,CAEA,0CACI,UAAA,CAKJ,kDACI,aAAA,CAGJ,wDACI,YAAA,CAGJ,kCACI,cAAA,CAEA,wDACI,YAAA,CAGJ,8DACI,aAAA,CAIR,mCACI,wBAAA,CACA,qBAAA,CAIR,0BACI,UAAA,CACA,aAAA,CACA,YAAA,CACA,iBAAA,CACA,mBAAA,CACA,uBAAA,CACA,wDAAA,CAEA,qCACI,UAAA,CACA,aAAA,CAGJ,sCACI,UAAA,CACA,aAAA,CAGJ,qCACI,UAAA,CACA,aAAA,CAGJ,mCACI,UAAA,CACA,aAAA,CAGJ,mCACI,UAAA,CACA,aAAA,CAGJ,oCACI,UAAA,CACA,aAAA,CAGJ,sCACI,UAAA,CACA,aAAA,CAGJ,mCACI,UAAA,CACA,aAAA,CAIR,4BACI,UAAA,CACA,aAAA,CACA,eAAA,CACA,UAAA,CACA,wBAAA,CACA,aAAA,CACA,iBAAA,CAEA,6CACI,iBAAA,CACA,QAAA,CACA,OAAA,CACA,SAAA,CACA,UAAA,CACA,eAAA,CACA,YAAA,CACA,uBAAA,CACA,6CAAA,CACA,UAAA,CACA,kCAAA,CACA,cAAA,CACA,cAAA,CAEA,0DACI,UAAA,CACA,aAAA,CAGJ,2DACI,UAAA,CACA,aAAA,CAGJ,uDACI,UAAA,CACA,aAAA,CACA,iBAAA,CACA,mBAAA,CACA,gBAAA,CACA,mBAAA,CAGJ,qDACI,UAAA,CACA,aAAA,CACA,iBAAA,CACA,mBAAA,CACA,gBAAA,CACA,mBAAA,CAGJ,qDACI,UAAA,CACA,iBAAA,CACA,mBAAA,CACA,cAAA,CACA,gBAAA,CAEA,yDACI,mBAAA",sourcesContent:['#bottom-bar {\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 10px 210px 10px 1fr 10px 61px 10px;\r\n\r\n #bottom-bar-total {\r\n grid-row: 1;\r\n grid-column: 6;\r\n color: white;\r\n background: #222222;\r\n height: 25px;\r\n align-self: center;\r\n font-size: 12pt;\r\n\r\n #clip-range {\r\n width: 100%;\r\n }\r\n }\r\n\r\n .control-button {\r\n .control-button-image {\r\n display: unset;\r\n }\r\n\r\n .control-button-hover-image {\r\n display: none;\r\n }\r\n\r\n &:hover {\r\n cursor: pointer;\r\n\r\n .control-button-image {\r\n display: none;\r\n }\r\n\r\n .control-button-hover-image {\r\n display: unset;\r\n }\r\n }\r\n\r\n &:active {\r\n transform-origin: 50% 50%;\r\n transform: scale(0.96);\r\n }\r\n }\r\n\r\n #media-player {\r\n grid-row: 1;\r\n grid-column: 2;\r\n display: grid;\r\n align-self: center;\r\n justify-self: center;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 23px 23px 23px 23px 23px 23px 23px;\r\n\r\n #start-key {\r\n grid-row: 1;\r\n grid-column: 1;\r\n }\r\n\r\n #prev-frame {\r\n grid-row: 1;\r\n grid-column: 2;\r\n }\r\n\r\n #first-key {\r\n grid-row: 1;\r\n grid-column: 3;\r\n }\r\n\r\n #rev-key {\r\n grid-row: 1;\r\n grid-column: 4;\r\n }\r\n\r\n #fwd-key {\r\n grid-row: 1;\r\n grid-column: 5;\r\n }\r\n\r\n #next-key {\r\n grid-row: 1;\r\n grid-column: 6;\r\n }\r\n\r\n #next-frame {\r\n grid-row: 1;\r\n grid-column: 7;\r\n }\r\n\r\n #end-key {\r\n grid-row: 1;\r\n grid-column: 8;\r\n }\r\n }\r\n\r\n #range-selector {\r\n grid-row: 1;\r\n grid-column: 4;\r\n background: #222222;\r\n width: 100%;\r\n height: calc(100% - 20px);\r\n margin: 10px 0;\r\n position: relative;\r\n\r\n #range-scrollbar {\r\n position: absolute;\r\n left: 2px;\r\n top: 2px;\r\n right: 2px;\r\n bottom: 2px;\r\n background: #666666;\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 20px auto 1fr auto 20px;\r\n color: #222222;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 14px;\r\n min-width: 70px;\r\n\r\n #left-handle {\r\n grid-row: 1;\r\n grid-column: 1;\r\n }\r\n\r\n #right-handle {\r\n grid-row: 1;\r\n grid-column: 5;\r\n }\r\n\r\n #from-key {\r\n grid-row: 1;\r\n grid-column: 2;\r\n align-self: center;\r\n justify-self: center;\r\n user-select: none;\r\n pointer-events: none;\r\n }\r\n\r\n #to-key {\r\n grid-row: 1;\r\n grid-column: 4;\r\n align-self: center;\r\n justify-self: center;\r\n user-select: none;\r\n pointer-events: none;\r\n }\r\n\r\n .handle {\r\n width: 20px;\r\n align-self: center;\r\n justify-self: center;\r\n cursor: pointer;\r\n user-select: none;\r\n\r\n img {\r\n pointer-events: none;\r\n }\r\n }\r\n }\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},8143:(e,t,r)=>{"use strict";r.d(t,{Z:()=>i});var n=r(4864),o=r.n(n),s=r(7885),a=r.n(s)()(o());a.push([e.id,'#canvas-zone{display:grid;grid-template-columns:100%;grid-template-rows:30px 1fr 10px 40px;overflow:hidden;position:relative}#canvas-zone #graph{grid-column:1;grid-row:2;width:100%;height:100%;background:#222;display:grid;grid-template-columns:100%;grid-template-rows:100%;overflow:hidden;position:relative}#canvas-zone #graph #svg-graph-grid{grid-column:1;grid-row:1;width:100%;height:100%;pointer-events:none;z-index:1}#canvas-zone #graph #svg-graph-grid:focus{outline:none}#canvas-zone #graph #svg-graph-horizontal{grid-column:1;grid-row:1;margin-left:40px;width:calc(100% - 40px);height:100%;pointer-events:none;z-index:1}#canvas-zone #graph #svg-graph-horizontal:focus{outline:none}#canvas-zone #graph #dark-rectangle{grid-column:1;grid-row:1;margin-left:40px;width:calc(100% - 40px);height:100%;background:#111;opacity:.2;pointer-events:none;position:absolute}#canvas-zone #graph #block-rectangle{grid-column:1;grid-row:1;width:40px;height:100%;background:#222;z-index:1}#canvas-zone #graph #svg-graph-curves{grid-column:1;grid-row:1;margin-left:40px;width:calc(100% - 40px);height:100%;z-index:2}#canvas-zone #graph #svg-graph-curves:focus{outline:none}#canvas-zone #graph #selection-rectangle{grid-column:1;grid-row:1;width:calc(100% - 40px);height:100%;pointer-events:none;position:absolute;left:40px;visibility:hidden;border:1px dashed #fff}#canvas-zone #range-frame-bar{grid-column:1;grid-row:4;width:100%;height:100%;background:#222;pointer-events:none;display:grid;grid-template-rows:100%;grid-template-columns:100%;pointer-events:none;user-select:none}#canvas-zone #range-frame-bar #svg-range-frames{grid-column:1;grid-row:1;width:100%;height:100%}#canvas-zone #frame-bar{grid-column:1;grid-row:1;width:100%;height:100%;background:#222;pointer-events:none;display:grid;grid-template-rows:100%;grid-template-columns:40px 1fr}#canvas-zone #frame-bar #angle-unit{grid-column:1;grid-row:1;background:#111}#canvas-zone #frame-bar #frames{grid-column:1/3;grid-row:1;width:100%;height:100%;display:grid;grid-template-rows:100%;grid-template-columns:100%}#canvas-zone #frame-bar #frames #svg-frames{margin-left:40px;grid-column:1;grid-row:1;width:calc(100% - 40px);height:100%}#canvas-zone #play-head-control{grid-column:1;grid-row:1;position:absolute;height:30px;left:40px;width:calc(100% - 40px)}#canvas-zone #play-head-control-2{grid-column:1;grid-row:4;position:absolute;height:30px;left:0px;width:100%}#canvas-zone #play-head{grid-column:1;grid-row:1/3;position:absolute;top:0;height:calc(100% - 5px);width:22px;margin-left:40px;display:grid;grid-template-columns:100%;grid-template-rows:22px 1fr;transform:translateX(-50%);pointer-events:none;z-index:3}#canvas-zone #play-head #play-head-bar{grid-row:2;grid-column:1;justify-self:center;width:1.5px;background:#fff;height:100%;pointer-events:none}#canvas-zone #play-head #play-head-circle{grid-row:1;grid-column:1;width:22px;height:22px;border-radius:50%;background:#fff;font-family:"acumin-pro-condensed";font-size:8pt;display:grid;align-content:center;justify-content:center;color:#555;cursor:pointer}#canvas-zone #angle-mode{grid-column:1;grid-row:1;width:40px;height:100%;z-index:1;background:#222}',"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/actionTabs/tabs/propertyGrids/animations/curveEditor/scss/canvas.scss"],names:[],mappings:"AAAA,aACI,YAAA,CACA,0BAAA,CACA,qCAAA,CACA,eAAA,CACA,iBAAA,CAEA,oBACI,aAAA,CACA,UAAA,CACA,UAAA,CACA,WAAA,CACA,eAAA,CACA,YAAA,CACA,0BAAA,CACA,uBAAA,CACA,eAAA,CACA,iBAAA,CAEA,oCACI,aAAA,CACA,UAAA,CACA,UAAA,CACA,WAAA,CACA,mBAAA,CAKA,SAAA,CAHA,0CACI,YAAA,CAKR,0CACI,aAAA,CACA,UAAA,CACA,gBAAA,CACA,uBAAA,CACA,WAAA,CACA,mBAAA,CAKA,SAAA,CAHA,gDACI,YAAA,CAKR,oCACI,aAAA,CACA,UAAA,CACA,gBAAA,CACA,uBAAA,CACA,WAAA,CACA,eAAA,CACA,UAAA,CACA,mBAAA,CACA,iBAAA,CAGJ,qCACI,aAAA,CACA,UAAA,CACA,UAAA,CACA,WAAA,CACA,eAAA,CACA,SAAA,CAGJ,sCACI,aAAA,CACA,UAAA,CACA,gBAAA,CACA,uBAAA,CACA,WAAA,CACA,SAAA,CAEA,4CACI,YAAA,CAIR,yCACI,aAAA,CACA,UAAA,CACA,uBAAA,CACA,WAAA,CACA,mBAAA,CACA,iBAAA,CACA,SAAA,CACA,iBAAA,CAEA,sBAAA,CAIR,8BACI,aAAA,CACA,UAAA,CACA,UAAA,CACA,WAAA,CACA,eAAA,CACA,mBAAA,CACA,YAAA,CACA,uBAAA,CACA,0BAAA,CACA,mBAAA,CACA,gBAAA,CAEA,gDACI,aAAA,CACA,UAAA,CACA,UAAA,CACA,WAAA,CAIR,wBACI,aAAA,CACA,UAAA,CACA,UAAA,CACA,WAAA,CACA,eAAA,CACA,mBAAA,CAEA,YAAA,CACA,uBAAA,CACA,8BAAA,CAEA,oCACI,aAAA,CACA,UAAA,CACA,eAAA,CAGJ,gCACI,eAAA,CAEA,UAAA,CACA,UAAA,CACA,WAAA,CACA,YAAA,CACA,uBAAA,CACA,0BAAA,CAEA,4CACI,gBAAA,CACA,aAAA,CACA,UAAA,CACA,uBAAA,CACA,WAAA,CAKZ,gCACI,aAAA,CACA,UAAA,CACA,iBAAA,CACA,WAAA,CACA,SAAA,CACA,uBAAA,CAGJ,kCACI,aAAA,CACA,UAAA,CACA,iBAAA,CACA,WAAA,CACA,QAAA,CACA,UAAA,CAGJ,wBACI,aAAA,CACA,YAAA,CACA,iBAAA,CACA,KAAA,CACA,uBAAA,CACA,UAAA,CACA,gBAAA,CACA,YAAA,CACA,0BAAA,CACA,2BAAA,CACA,0BAAA,CACA,mBAAA,CACA,SAAA,CAEA,uCACI,UAAA,CACA,aAAA,CACA,mBAAA,CACA,WAAA,CACA,eAAA,CACA,WAAA,CACA,mBAAA,CAGJ,0CACI,UAAA,CACA,aAAA,CACA,UAAA,CACA,WAAA,CACA,iBAAA,CACA,eAAA,CACA,kCAAA,CACA,aAAA,CACA,YAAA,CACA,oBAAA,CACA,sBAAA,CACA,UAAA,CACA,cAAA,CAIR,yBACI,aAAA,CACA,UAAA,CACA,UAAA,CACA,WAAA,CACA,SAAA,CACA,eAAA",sourcesContent:['#canvas-zone {\r\n display: grid;\r\n grid-template-columns: 100%;\r\n grid-template-rows: 30px 1fr 10px 40px;\r\n overflow: hidden;\r\n position: relative;\r\n\r\n #graph {\r\n grid-column: 1;\r\n grid-row: 2;\r\n width: 100%;\r\n height: 100%;\r\n background: #222222;\r\n display: grid;\r\n grid-template-columns: 100%;\r\n grid-template-rows: 100%;\r\n overflow: hidden;\r\n position: relative;\r\n\r\n #svg-graph-grid {\r\n grid-column: 1;\r\n grid-row: 1;\r\n width: 100%;\r\n height: 100%;\r\n pointer-events: none;\r\n\r\n &:focus {\r\n outline: none;\r\n }\r\n z-index: 1;\r\n }\r\n\r\n #svg-graph-horizontal {\r\n grid-column: 1;\r\n grid-row: 1;\r\n margin-left: 40px;\r\n width: calc(100% - 40px);\r\n height: 100%;\r\n pointer-events: none;\r\n\r\n &:focus {\r\n outline: none;\r\n }\r\n z-index: 1;\r\n }\r\n\r\n #dark-rectangle {\r\n grid-column: 1;\r\n grid-row: 1;\r\n margin-left: 40px;\r\n width: calc(100% - 40px);\r\n height: 100%;\r\n background: #111111;\r\n opacity: 0.2;\r\n pointer-events: none;\r\n position: absolute;\r\n }\r\n\r\n #block-rectangle {\r\n grid-column: 1;\r\n grid-row: 1;\r\n width: 40px;\r\n height: 100%;\r\n background: #222222;\r\n z-index: 1;\r\n }\r\n\r\n #svg-graph-curves {\r\n grid-column: 1;\r\n grid-row: 1;\r\n margin-left: 40px;\r\n width: calc(100% - 40px);\r\n height: 100%;\r\n z-index: 2;\r\n\r\n &:focus {\r\n outline: none;\r\n }\r\n }\r\n\r\n #selection-rectangle {\r\n grid-column: 1;\r\n grid-row: 1;\r\n width: calc(100% - 40px);\r\n height: 100%;\r\n pointer-events: none;\r\n position: absolute;\r\n left: 40px;\r\n visibility: hidden;\r\n\r\n border: 1px dashed white;\r\n }\r\n }\r\n\r\n #range-frame-bar {\r\n grid-column: 1;\r\n grid-row: 4;\r\n width: 100%;\r\n height: 100%;\r\n background: #222222;\r\n pointer-events: none;\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 100%;\r\n pointer-events: none;\r\n user-select: none;\r\n\r\n #svg-range-frames {\r\n grid-column: 1;\r\n grid-row: 1;\r\n width: 100%;\r\n height: 100%;\r\n }\r\n }\r\n\r\n #frame-bar {\r\n grid-column: 1;\r\n grid-row: 1;\r\n width: 100%;\r\n height: 100%;\r\n background: #222222;\r\n pointer-events: none;\r\n\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 40px 1fr;\r\n\r\n #angle-unit {\r\n grid-column: 1;\r\n grid-row: 1;\r\n background: #111111;\r\n }\r\n\r\n #frames {\r\n grid-column: 1 / 3;\r\n\r\n grid-row: 1;\r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 100%;\r\n\r\n #svg-frames {\r\n margin-left: 40px;\r\n grid-column: 1;\r\n grid-row: 1;\r\n width: calc(100% - 40px);\r\n height: 100%;\r\n }\r\n }\r\n }\r\n\r\n #play-head-control {\r\n grid-column: 1;\r\n grid-row: 1;\r\n position: absolute;\r\n height: 30px;\r\n left: 40px;\r\n width: calc(100% - 40px);\r\n }\r\n\r\n #play-head-control-2 {\r\n grid-column: 1;\r\n grid-row: 4;\r\n position: absolute;\r\n height: 30px;\r\n left: 0px;\r\n width: 100%;\r\n }\r\n\r\n #play-head {\r\n grid-column: 1;\r\n grid-row: 1 / 3;\r\n position: absolute;\r\n top: 0;\r\n height: calc(100% - 5px);\r\n width: 22px;\r\n margin-left: 40px;\r\n display: grid;\r\n grid-template-columns: 100%;\r\n grid-template-rows: 22px 1fr;\r\n transform: translateX(-50%);\r\n pointer-events: none;\r\n z-index: 3;\r\n\r\n #play-head-bar {\r\n grid-row: 2;\r\n grid-column: 1;\r\n justify-self: center;\r\n width: 1.5px;\r\n background: #ffffff;\r\n height: 100%;\r\n pointer-events: none;\r\n }\r\n\r\n #play-head-circle {\r\n grid-row: 1;\r\n grid-column: 1;\r\n width: 22px;\r\n height: 22px;\r\n border-radius: 50%;\r\n background: #ffffff;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 8pt;\r\n display: grid;\r\n align-content: center;\r\n justify-content: center;\r\n color: #555555;\r\n cursor: pointer;\r\n }\r\n }\r\n\r\n #angle-mode {\r\n grid-column: 1;\r\n grid-row: 1;\r\n width: 40px;\r\n height: 100%;\r\n z-index: 1;\r\n background: #222222;\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},8712:(e,t,r)=>{"use strict";r.d(t,{Z:()=>i});var n=r(4864),o=r.n(n),s=r(7885),a=r.n(s)()(o());a.push([e.id,'#curve-editor{background:#333;width:100%;height:100%;display:grid;grid-template-rows:40px calc(100% - 85px) 45px;grid-template-columns:10px 210px 10px 1fr 10px}#curve-editor #top-bar{background:#333;grid-row:1;grid-column:1/6;width:100%;height:100%}#curve-editor #bottom-bar{background:#333;grid-row:3;grid-column:1/6;width:100%;height:100%}#curve-editor #canvas-zone{grid-row:2;grid-column:4;width:100%;height:100%;background:#333}#curve-editor #sidebar{grid-row:2;grid-column:2;width:100%;height:100%;background:#111}#curve-editor .action-button:hover{background:#666;color:#fff;cursor:pointer}#curve-editor .action-button.active{background:#111}#curve-editor .action-button:active{transform-origin:50% 50%;transform:scale(0.96)}#curve-editor .push-button{cursor:pointer}#curve-editor .push-button.active{background:#666}#curve-editor .text-input{color:#fff;background:#000;font-family:"acumin-pro-condensed";font-size:11pt;border:0;margin:3px 1px;text-align:end;padding-right:4px}#curve-editor .text-input:focus{outline:none}#curve-editor .text-input:disabled{background:#444;border:#555 solid 1px}',"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/actionTabs/tabs/propertyGrids/animations/curveEditor/scss/curveEditor.scss"],names:[],mappings:"AAAA,cACI,eAAA,CACA,UAAA,CACA,WAAA,CACA,YAAA,CACA,8CAAA,CACA,8CAAA,CAEA,uBACI,eAAA,CACA,UAAA,CACA,eAAA,CACA,UAAA,CACA,WAAA,CAGJ,0BACI,eAAA,CACA,UAAA,CACA,eAAA,CACA,UAAA,CACA,WAAA,CAGJ,2BACI,UAAA,CACA,aAAA,CACA,UAAA,CACA,WAAA,CACA,eAAA,CAGJ,uBACI,UAAA,CACA,aAAA,CACA,UAAA,CACA,WAAA,CACA,eAAA,CAIA,mCACI,eAAA,CACA,UAAA,CACA,cAAA,CAGJ,oCACI,eAAA,CAGJ,oCACI,wBAAA,CACA,qBAAA,CAIR,2BACI,cAAA,CACA,kCACI,eAAA,CAIR,0BACI,UAAA,CACA,eAAA,CACA,kCAAA,CACA,cAAA,CACA,QAAA,CACA,cAAA,CACA,cAAA,CACA,iBAAA,CAEA,gCACI,YAAA,CAGJ,mCACI,eAAA,CACA,qBAAA",sourcesContent:['#curve-editor {\r\n background: #333333;\r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-template-rows: 40px calc(100% - 85px) 45px;\r\n grid-template-columns: 10px 210px 10px 1fr 10px;\r\n\r\n #top-bar {\r\n background: #333333;\r\n grid-row: 1;\r\n grid-column: 1 / 6;\r\n width: 100%;\r\n height: 100%;\r\n }\r\n\r\n #bottom-bar {\r\n background: #333333;\r\n grid-row: 3;\r\n grid-column: 1 / 6;\r\n width: 100%;\r\n height: 100%;\r\n }\r\n\r\n #canvas-zone {\r\n grid-row: 2;\r\n grid-column: 4;\r\n width: 100%;\r\n height: 100%;\r\n background: #333333;\r\n }\r\n\r\n #sidebar {\r\n grid-row: 2;\r\n grid-column: 2;\r\n width: 100%;\r\n height: 100%;\r\n background: #111111;\r\n }\r\n\r\n .action-button {\r\n &:hover {\r\n background: #666666;\r\n color: white;\r\n cursor: pointer;\r\n }\r\n\r\n &.active {\r\n background: #111111;\r\n }\r\n\r\n &:active {\r\n transform-origin: 50% 50%;\r\n transform: scale(0.96);\r\n }\r\n }\r\n\r\n .push-button {\r\n cursor: pointer;\r\n &.active {\r\n background: #666666;\r\n }\r\n }\r\n\r\n .text-input {\r\n color: white;\r\n background: #000000;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 11pt;\r\n border: 0;\r\n margin: 3px 1px;\r\n text-align: end;\r\n padding-right: 4px;\r\n\r\n &:focus {\r\n outline: none;\r\n }\r\n\r\n &:disabled {\r\n background: #444444;\r\n border: #555555 solid 1px;\r\n }\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},1367:(e,t,r)=>{"use strict";r.d(t,{Z:()=>i});var n=r(4864),o=r.n(n),s=r(7885),a=r.n(s)()(o());a.push([e.id,'#sideBar{display:grid;grid-template-columns:100%;grid-template-rows:30px 1fr}#sideBar #menu-bar{background:#252525;grid-row:1;grid-column:1;width:100%;height:100%;display:grid;grid-template-rows:100%;grid-template-columns:30px 30px 30px 30px 1fr 52px 3px}#sideBar #menu-bar.small{grid-template-columns:0px 0px 30px 30px 1fr 52px 3px}#sideBar #menu-bar #add-animation{grid-row:1;grid-column:1}#sideBar #menu-bar #load-animation{grid-row:1;grid-column:2}#sideBar #menu-bar #save-animation{grid-row:1;grid-column:3}#sideBar #menu-bar #edit-animation{grid-row:1;grid-column:4}#sideBar #menu-bar #framerate-animation{grid-row:1;grid-column:6}#sideBar .simple-button{width:80px;height:20px;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt;background:#444;border:0;line-height:12px;cursor:pointer;align-self:center;justify-self:center;border-radius:0}#sideBar .simple-button:active{transform-origin:center;transform:scale(0.95)}#sideBar #save-animation-pane{width:100%;height:100%;display:grid;grid-template-columns:100%;grid-template-rows:1fr 40px auto}#sideBar #save-animation-pane #save-animation-list{grid-row:1;grid-column:1;width:100%;height:100%;display:flex;flex-direction:column;padding-top:5px}#sideBar #save-animation-pane #save-animation-list .save-animation-list-entry{height:20px;margin-left:10px;display:flex;align-content:center;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt;line-height:15px}#sideBar #save-animation-pane #save-animation-buttons{grid-row:2;grid-column:1;width:100%;height:100%;display:grid;grid-template-rows:100%;grid-template-columns:10px 1fr 10px 1fr 10px;align-items:center}#sideBar #save-animation-pane #save-animation-buttons #save-snippet{grid-row:1;grid-column:2}#sideBar #save-animation-pane #save-animation-buttons #save-file{grid-row:1;grid-column:4}#sideBar #save-animation-pane #save-animation-snippet{grid-row:3;grid-column:1;width:calc(100% - 31px);height:20px;align-content:center;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt;padding-left:31px;background:#252525}#sideBar #load-animation-pane{width:100%;height:100%;display:grid;grid-template-columns:75px 1fr;grid-template-rows:10px 20px 10px 20px 10px 20px 1fr auto;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt}#sideBar #load-animation-pane #load-animation-snippet-id-label{grid-row:2;grid-column:1;justify-self:end;margin-right:10px}#sideBar #load-animation-pane #load-animation-local-file-label{grid-row:6;grid-column:1;justify-self:end;margin-right:10px}#sideBar #load-animation-pane #load-snippet-id{grid-row:2;grid-column:2;margin-right:10px;border:0;background:#252525;width:127px;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt}#sideBar #load-animation-pane #load-snippet{grid-row:4;grid-column:2;width:60px;justify-self:left}#sideBar #load-animation-pane input[type=file]{display:none}#sideBar #load-animation-pane #file-snippet-label{grid-row:6;grid-column:2;width:60px;justify-self:left;text-align:center;line-height:18px}#sideBar #load-animation-pane #load-animation-snippet{grid-row:8;grid-column:1/3;width:calc(100% - 31px);height:20px;align-content:center;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt;padding-left:31px;background:#252525}#sideBar #add-animation-pane{grid-column:1;grid-row:2;width:100%;height:100%;display:grid;grid-template-columns:75px 1fr;grid-template-rows:10px 20px 10px 20px 10px 20px 10px 20px 10px 20px 10px 20px 1fr;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt}#sideBar #add-animation-pane .input-text{border:0;background:#252525;width:127px;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt}#sideBar #add-animation-pane .option{background:#252525;color:#fff;border:0}#sideBar #add-animation-pane #add-animation-display-name-label{grid-row:2;grid-column:1;justify-self:end;margin-right:10px}#sideBar #add-animation-pane #add-animation-mode-label{grid-row:4;grid-column:1;justify-self:end;margin-right:10px}#sideBar #add-animation-pane #add-animation-property-label{grid-row:6;grid-column:1;justify-self:end;margin-right:10px}#sideBar #add-animation-pane #add-animation-type-label{grid-row:8;grid-column:1;justify-self:end;margin-right:10px}#sideBar #add-animation-pane #add-animation-loop-mode-label{grid-row:10;grid-column:1;justify-self:end;margin-right:10px}#sideBar #add-animation-pane #add-animation-name{grid-row:2;grid-column:2;margin-right:10px}#sideBar #add-animation-pane #add-animation-mode{grid-row:4;grid-column:2;margin-right:10px;width:calc(100% - 10px)}#sideBar #add-animation-pane #add-animation-property{grid-row:6;grid-column:2;margin-right:10px;width:calc(100% - 10px)}#sideBar #add-animation-pane #add-animation-type{grid-row:8;grid-column:2;margin-right:10px}#sideBar #add-animation-pane #add-animation-loop-mode{grid-row:10;grid-column:2;margin-right:10px}#sideBar #add-animation-pane #add-animation{grid-row:12;grid-column:2;justify-self:left}#sideBar #edit-animation-pane{grid-column:1;grid-row:2;width:100%;height:100%;display:grid;grid-template-columns:75px 1fr;grid-template-rows:10px 20px 10px 20px 10px 20px 10px 20px 1fr;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt;background:#111}#sideBar #edit-animation-pane .input-text{border:0;background:#252525;width:127px;color:#fff;font-family:"acumin-pro-condensed";font-size:10pt}#sideBar #edit-animation-pane .option{background:#252525;color:#fff;border:0}#sideBar #edit-animation-pane #edit-animation-display-name-label{grid-row:2;grid-column:1;justify-self:end;margin-right:10px}#sideBar #edit-animation-pane #edit-animation-property-label{grid-row:4;grid-column:1;justify-self:end;margin-right:10px}#sideBar #edit-animation-pane #edit-animation-loop-mode-label{grid-row:6;grid-column:1;justify-self:end;margin-right:10px}#sideBar #edit-animation-pane #edit-animation-name{grid-row:2;grid-column:2;margin-right:10px}#sideBar #edit-animation-pane #edit-animation-property{grid-row:4;grid-column:2;margin-right:10px}#sideBar #edit-animation-pane #edit-animation-loop-mode{grid-row:6;grid-column:2;margin-right:10px}#sideBar #edit-animation-pane #edit-animation{grid-row:8;grid-column:1/3;display:grid;grid-template-columns:50% 50%;grid-template-rows:100%}#sideBar #edit-animation-pane #edit-animation #edit-animation-ok{grid-row:1;grid-column:1}#sideBar #edit-animation-pane #edit-animation #edit-animation-cancel{grid-row:1;grid-column:2}#sideBar #animation-list{background:#111;grid-row:2;grid-column:1;width:100%;height:100%}#sideBar #animation-list .animation-entry{height:20px;display:grid;grid-template-columns:20px 10px 1fr 20px 20px;grid-template-rows:100%}#sideBar #animation-list .animation-entry.isActive{background:#444}#sideBar #animation-list .animation-entry .animation-active-indicator{grid-row:1;grid-column:1;display:grid;margin:5px;padding-top:2px}#sideBar #animation-list .animation-entry .animation-chevron{grid-row:1;grid-column:2;display:grid;align-content:center;padding-top:5px;cursor:pointer}#sideBar #animation-list .animation-entry .animation-chevron .animation-chevron-image.collapsed{transform-origin:50% 50%;transform:rotateZ(-90deg)}#sideBar #animation-list .animation-entry .animation-name{cursor:pointer;grid-row:1;grid-column:3;font-family:"acumin-pro-condensed";font-size:10.5pt;color:#fff;display:grid;align-self:center;margin-left:5px;user-select:none}#sideBar #animation-list .animation-entry .animation-options{grid-row:1;grid-column:4}#sideBar #animation-list .animation-entry .animation-delete{grid-row:1;grid-column:5}',"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/actionTabs/tabs/propertyGrids/animations/curveEditor/scss/sideBar.scss"],names:[],mappings:"AAAA,SACI,YAAA,CACA,0BAAA,CACA,2BAAA,CAEA,mBACI,kBAAA,CACA,UAAA,CACA,aAAA,CACA,UAAA,CACA,WAAA,CACA,YAAA,CACA,uBAAA,CACA,sDAAA,CAEA,yBACI,oDAAA,CAGJ,kCACI,UAAA,CACA,aAAA,CAGJ,mCACI,UAAA,CACA,aAAA,CAGJ,mCACI,UAAA,CACA,aAAA,CAGJ,mCACI,UAAA,CACA,aAAA,CAGJ,wCACI,UAAA,CACA,aAAA,CAIR,wBACI,UAAA,CACA,WAAA,CACA,UAAA,CACA,kCAAA,CACA,cAAA,CACA,eAAA,CACA,QAAA,CACA,gBAAA,CACA,cAAA,CACA,iBAAA,CACA,mBAAA,CACA,eAAA,CAEA,+BACI,uBAAA,CACA,qBAAA,CAIR,8BACI,UAAA,CACA,WAAA,CACA,YAAA,CACA,0BAAA,CACA,gCAAA,CAEA,mDACI,UAAA,CACA,aAAA,CACA,UAAA,CACA,WAAA,CACA,YAAA,CACA,qBAAA,CACA,eAAA,CAEA,8EACI,WAAA,CACA,gBAAA,CACA,YAAA,CACA,oBAAA,CACA,UAAA,CAEA,kCAAA,CACA,cAAA,CACA,gBAAA,CAIR,sDACI,UAAA,CACA,aAAA,CACA,UAAA,CACA,WAAA,CACA,YAAA,CACA,uBAAA,CACA,4CAAA,CACA,kBAAA,CAEA,oEACI,UAAA,CACA,aAAA,CAGJ,iEACI,UAAA,CACA,aAAA,CAIR,sDACI,UAAA,CACA,aAAA,CACA,uBAAA,CACA,WAAA,CACA,oBAAA,CACA,UAAA,CACA,kCAAA,CACA,cAAA,CACA,iBAAA,CACA,kBAAA,CAIR,8BACI,UAAA,CACA,WAAA,CACA,YAAA,CACA,8BAAA,CACA,yDAAA,CACA,UAAA,CACA,kCAAA,CACA,cAAA,CAEA,+DACI,UAAA,CACA,aAAA,CACA,gBAAA,CACA,iBAAA,CAGJ,+DACI,UAAA,CACA,aAAA,CACA,gBAAA,CACA,iBAAA,CAGJ,+CACI,UAAA,CACA,aAAA,CACA,iBAAA,CACA,QAAA,CACA,kBAAA,CACA,WAAA,CACA,UAAA,CACA,kCAAA,CACA,cAAA,CAGJ,4CACI,UAAA,CACA,aAAA,CACA,UAAA,CACA,iBAAA,CAGJ,+CACI,YAAA,CAGJ,kDACI,UAAA,CACA,aAAA,CACA,UAAA,CACA,iBAAA,CACA,iBAAA,CACA,gBAAA,CAGJ,sDACI,UAAA,CACA,eAAA,CACA,uBAAA,CACA,WAAA,CACA,oBAAA,CACA,UAAA,CACA,kCAAA,CACA,cAAA,CACA,iBAAA,CACA,kBAAA,CAIR,6BACI,aAAA,CACA,UAAA,CACA,UAAA,CACA,WAAA,CACA,YAAA,CACA,8BAAA,CACA,kFAAA,CACA,UAAA,CACA,kCAAA,CACA,cAAA,CAEA,yCACI,QAAA,CACA,kBAAA,CACA,WAAA,CACA,UAAA,CACA,kCAAA,CACA,cAAA,CAGJ,qCACI,kBAAA,CACA,UAAA,CACA,QAAA,CAGJ,+DACI,UAAA,CACA,aAAA,CACA,gBAAA,CACA,iBAAA,CAGJ,uDACI,UAAA,CACA,aAAA,CACA,gBAAA,CACA,iBAAA,CAGJ,2DACI,UAAA,CACA,aAAA,CACA,gBAAA,CACA,iBAAA,CAGJ,uDACI,UAAA,CACA,aAAA,CACA,gBAAA,CACA,iBAAA,CAGJ,4DACI,WAAA,CACA,aAAA,CACA,gBAAA,CACA,iBAAA,CAGJ,iDACI,UAAA,CACA,aAAA,CACA,iBAAA,CAGJ,iDACI,UAAA,CACA,aAAA,CACA,iBAAA,CACA,uBAAA,CAGJ,qDACI,UAAA,CACA,aAAA,CACA,iBAAA,CACA,uBAAA,CAGJ,iDACI,UAAA,CACA,aAAA,CACA,iBAAA,CAGJ,sDACI,WAAA,CACA,aAAA,CACA,iBAAA,CAGJ,4CACI,WAAA,CACA,aAAA,CACA,iBAAA,CAIR,8BACI,aAAA,CACA,UAAA,CAEA,UAAA,CACA,WAAA,CACA,YAAA,CACA,8BAAA,CACA,8DAAA,CACA,UAAA,CACA,kCAAA,CACA,cAAA,CACA,eAAA,CAEA,0CACI,QAAA,CACA,kBAAA,CACA,WAAA,CACA,UAAA,CACA,kCAAA,CACA,cAAA,CAGJ,sCACI,kBAAA,CACA,UAAA,CACA,QAAA,CAGJ,iEACI,UAAA,CACA,aAAA,CACA,gBAAA,CACA,iBAAA,CAGJ,6DACI,UAAA,CACA,aAAA,CACA,gBAAA,CACA,iBAAA,CAGJ,8DACI,UAAA,CACA,aAAA,CACA,gBAAA,CACA,iBAAA,CAGJ,mDACI,UAAA,CACA,aAAA,CACA,iBAAA,CAGJ,uDACI,UAAA,CACA,aAAA,CACA,iBAAA,CAGJ,wDACI,UAAA,CACA,aAAA,CACA,iBAAA,CAGJ,8CACI,UAAA,CACA,eAAA,CACA,YAAA,CACA,6BAAA,CACA,uBAAA,CAEA,iEACI,UAAA,CACA,aAAA,CAGJ,qEACI,UAAA,CACA,aAAA,CAKZ,yBACI,eAAA,CACA,UAAA,CACA,aAAA,CACA,UAAA,CACA,WAAA,CAEA,0CACI,WAAA,CACA,YAAA,CACA,6CAAA,CACA,uBAAA,CAEA,mDACI,eAAA,CAGJ,sEACI,UAAA,CACA,aAAA,CACA,YAAA,CACA,UAAA,CACA,eAAA,CAGJ,6DACI,UAAA,CACA,aAAA,CACA,YAAA,CACA,oBAAA,CACA,eAAA,CACA,cAAA,CAGI,gGACI,wBAAA,CACA,yBAAA,CAKZ,0DACI,cAAA,CACA,UAAA,CACA,aAAA,CACA,kCAAA,CACA,gBAAA,CACA,UAAA,CACA,YAAA,CACA,iBAAA,CACA,eAAA,CACA,gBAAA,CAGJ,6DACI,UAAA,CACA,aAAA,CAGJ,4DACI,UAAA,CACA,aAAA",sourcesContent:['#sideBar {\r\n display: grid;\r\n grid-template-columns: 100%;\r\n grid-template-rows: 30px 1fr;\r\n\r\n #menu-bar {\r\n background: #252525;\r\n grid-row: 1;\r\n grid-column: 1;\r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 30px 30px 30px 30px 1fr 52px 3px;\r\n\r\n &.small {\r\n grid-template-columns: 0px 0px 30px 30px 1fr 52px 3px;\r\n }\r\n\r\n #add-animation {\r\n grid-row: 1;\r\n grid-column: 1;\r\n }\r\n\r\n #load-animation {\r\n grid-row: 1;\r\n grid-column: 2;\r\n }\r\n\r\n #save-animation {\r\n grid-row: 1;\r\n grid-column: 3;\r\n }\r\n\r\n #edit-animation {\r\n grid-row: 1;\r\n grid-column: 4;\r\n }\r\n\r\n #framerate-animation {\r\n grid-row: 1;\r\n grid-column: 6;\r\n }\r\n }\r\n\r\n .simple-button {\r\n width: 80px;\r\n height: 20px;\r\n color: white;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n background: #444444;\r\n border: 0;\r\n line-height: 12px;\r\n cursor: pointer;\r\n align-self: center;\r\n justify-self: center;\r\n border-radius: 0;\r\n\r\n &:active {\r\n transform-origin: center;\r\n transform: scale(0.95);\r\n }\r\n }\r\n\r\n #save-animation-pane {\r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-template-columns: 100%;\r\n grid-template-rows: 1fr 40px auto;\r\n\r\n #save-animation-list {\r\n grid-row: 1;\r\n grid-column: 1;\r\n width: 100%;\r\n height: 100%;\r\n display: flex;\r\n flex-direction: column;\r\n padding-top: 5px;\r\n\r\n .save-animation-list-entry {\r\n height: 20px;\r\n margin-left: 10px;\r\n display: flex;\r\n align-content: center;\r\n color: white;\r\n\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n line-height: 15px;\r\n }\r\n }\r\n\r\n #save-animation-buttons {\r\n grid-row: 2;\r\n grid-column: 1;\r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-template-rows: 100%;\r\n grid-template-columns: 10px 1fr 10px 1fr 10px;\r\n align-items: center;\r\n\r\n #save-snippet {\r\n grid-row: 1;\r\n grid-column: 2;\r\n }\r\n\r\n #save-file {\r\n grid-row: 1;\r\n grid-column: 4;\r\n }\r\n }\r\n\r\n #save-animation-snippet {\r\n grid-row: 3;\r\n grid-column: 1;\r\n width: calc(100% - 31px);\r\n height: 20px;\r\n align-content: center;\r\n color: white;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n padding-left: 31px;\r\n background: #252525;\r\n }\r\n }\r\n\r\n #load-animation-pane {\r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-template-columns: 75px 1fr;\r\n grid-template-rows: 10px 20px 10px 20px 10px 20px 1fr auto;\r\n color: white;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n\r\n #load-animation-snippet-id-label {\r\n grid-row: 2;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #load-animation-local-file-label {\r\n grid-row: 6;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #load-snippet-id {\r\n grid-row: 2;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n border: 0;\r\n background: #252525;\r\n width: 127px;\r\n color: white;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n }\r\n\r\n #load-snippet {\r\n grid-row: 4;\r\n grid-column: 2;\r\n width: 60px;\r\n justify-self: left;\r\n }\r\n\r\n input[type="file"] {\r\n display: none;\r\n }\r\n\r\n #file-snippet-label {\r\n grid-row: 6;\r\n grid-column: 2;\r\n width: 60px;\r\n justify-self: left;\r\n text-align: center;\r\n line-height: 18px;\r\n }\r\n\r\n #load-animation-snippet {\r\n grid-row: 8;\r\n grid-column: 1 / 3;\r\n width: calc(100% - 31px);\r\n height: 20px;\r\n align-content: center;\r\n color: white;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n padding-left: 31px;\r\n background: #252525;\r\n }\r\n }\r\n\r\n #add-animation-pane {\r\n grid-column: 1;\r\n grid-row: 2;\r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-template-columns: 75px 1fr;\r\n grid-template-rows: 10px 20px 10px 20px 10px 20px 10px 20px 10px 20px 10px 20px 1fr;\r\n color: white;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n\r\n .input-text {\r\n border: 0;\r\n background: #252525;\r\n width: 127px;\r\n color: white;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n }\r\n\r\n .option {\r\n background: #252525;\r\n color: white;\r\n border: 0;\r\n }\r\n\r\n #add-animation-display-name-label {\r\n grid-row: 2;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #add-animation-mode-label {\r\n grid-row: 4;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #add-animation-property-label {\r\n grid-row: 6;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #add-animation-type-label {\r\n grid-row: 8;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #add-animation-loop-mode-label {\r\n grid-row: 10;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #add-animation-name {\r\n grid-row: 2;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n }\r\n\r\n #add-animation-mode {\r\n grid-row: 4;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n width: calc(100% - 10px);\r\n }\r\n\r\n #add-animation-property {\r\n grid-row: 6;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n width: calc(100% - 10px);\r\n }\r\n\r\n #add-animation-type {\r\n grid-row: 8;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n }\r\n\r\n #add-animation-loop-mode {\r\n grid-row: 10;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n }\r\n\r\n #add-animation {\r\n grid-row: 12;\r\n grid-column: 2;\r\n justify-self: left;\r\n }\r\n }\r\n\r\n #edit-animation-pane {\r\n grid-column: 1;\r\n grid-row: 2;\r\n\r\n width: 100%;\r\n height: 100%;\r\n display: grid;\r\n grid-template-columns: 75px 1fr;\r\n grid-template-rows: 10px 20px 10px 20px 10px 20px 10px 20px 1fr;\r\n color: white;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n background: #111111;\r\n\r\n .input-text {\r\n border: 0;\r\n background: #252525;\r\n width: 127px;\r\n color: white;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10pt;\r\n }\r\n\r\n .option {\r\n background: #252525;\r\n color: white;\r\n border: 0;\r\n }\r\n\r\n #edit-animation-display-name-label {\r\n grid-row: 2;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #edit-animation-property-label {\r\n grid-row: 4;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #edit-animation-loop-mode-label {\r\n grid-row: 6;\r\n grid-column: 1;\r\n justify-self: end;\r\n margin-right: 10px;\r\n }\r\n\r\n #edit-animation-name {\r\n grid-row: 2;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n }\r\n\r\n #edit-animation-property {\r\n grid-row: 4;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n }\r\n\r\n #edit-animation-loop-mode {\r\n grid-row: 6;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n }\r\n\r\n #edit-animation {\r\n grid-row: 8;\r\n grid-column: 1 / 3;\r\n display: grid;\r\n grid-template-columns: 50% 50%;\r\n grid-template-rows: 100%;\r\n\r\n #edit-animation-ok {\r\n grid-row: 1;\r\n grid-column: 1;\r\n }\r\n\r\n #edit-animation-cancel {\r\n grid-row: 1;\r\n grid-column: 2;\r\n }\r\n }\r\n }\r\n\r\n #animation-list {\r\n background: #111111;\r\n grid-row: 2;\r\n grid-column: 1;\r\n width: 100%;\r\n height: 100%;\r\n\r\n .animation-entry {\r\n height: 20px;\r\n display: grid;\r\n grid-template-columns: 20px 10px 1fr 20px 20px;\r\n grid-template-rows: 100%;\r\n\r\n &.isActive {\r\n background: #444444;\r\n }\r\n\r\n .animation-active-indicator {\r\n grid-row: 1;\r\n grid-column: 1;\r\n display: grid;\r\n margin: 5px;\r\n padding-top: 2px;\r\n }\r\n\r\n .animation-chevron {\r\n grid-row: 1;\r\n grid-column: 2;\r\n display: grid;\r\n align-content: center;\r\n padding-top: 5px;\r\n cursor: pointer;\r\n\r\n .animation-chevron-image {\r\n &.collapsed {\r\n transform-origin: 50% 50%;\r\n transform: rotateZ(-90deg);\r\n }\r\n }\r\n }\r\n\r\n .animation-name {\r\n cursor: pointer;\r\n grid-row: 1;\r\n grid-column: 3;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 10.5pt;\r\n color: white;\r\n display: grid;\r\n align-self: center;\r\n margin-left: 5px;\r\n user-select: none;\r\n }\r\n\r\n .animation-options {\r\n grid-row: 1;\r\n grid-column: 4;\r\n }\r\n\r\n .animation-delete {\r\n grid-row: 1;\r\n grid-column: 5;\r\n }\r\n }\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},9388:(e,t,r)=>{"use strict";r.d(t,{Z:()=>i});var n=r(4864),o=r.n(n),s=r(7885),a=r.n(s)()(o());a.push([e.id,'#top-bar{display:grid;grid-template-columns:40px 200px 75px 8px 75px 8px 40px 40px 40px 40px 40px 40px 40px 40px 1fr 40px;grid-template-rows:100%}#top-bar .disabled{opacity:20%;pointer-events:none}#top-bar #top-bar-logo{grid-row:1;grid-column:1}#top-bar #top-bar-parent-name{grid-row:1;grid-column:2;font-family:"acumin-pro-condensed";font-size:15pt;color:#fff;display:grid;align-content:center;padding-bottom:5px}#top-bar #key-frame{grid-row:1;grid-column:3;height:24px;display:grid;align-self:center}#top-bar #key-value{grid-row:1;grid-column:5;height:24px;display:grid;align-self:center}#top-bar #new-key{grid-row:1;grid-column:7}#top-bar #frame-canvas{grid-row:1;grid-column:8}#top-bar #flatten-tangent{grid-row:1;grid-column:9}#top-bar #linear-tangent{grid-row:1;grid-column:10}#top-bar #break-tangent{grid-row:1;grid-column:11}#top-bar #unify-tangent{grid-row:1;grid-column:12}#top-bar #step-tangent{grid-row:1;grid-column:13}',"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/actionTabs/tabs/propertyGrids/animations/curveEditor/scss/topBar.scss"],names:[],mappings:"AAAA,SACI,YAAA,CACA,mGAAA,CACA,uBAAA,CAEA,mBACI,WAAA,CACA,mBAAA,CAGJ,uBACI,UAAA,CACA,aAAA,CAGJ,8BACI,UAAA,CACA,aAAA,CACA,kCAAA,CACA,cAAA,CACA,UAAA,CACA,YAAA,CACA,oBAAA,CACA,kBAAA,CAGJ,oBACI,UAAA,CACA,aAAA,CACA,WAAA,CACA,YAAA,CACA,iBAAA,CAGJ,oBACI,UAAA,CACA,aAAA,CACA,WAAA,CACA,YAAA,CACA,iBAAA,CAGJ,kBACI,UAAA,CACA,aAAA,CAGJ,uBACI,UAAA,CACA,aAAA,CAGJ,0BACI,UAAA,CACA,aAAA,CAGJ,yBACI,UAAA,CACA,cAAA,CAGJ,wBACI,UAAA,CACA,cAAA,CAGJ,wBACI,UAAA,CACA,cAAA,CAGJ,uBACI,UAAA,CACA,cAAA",sourcesContent:['#top-bar {\r\n display: grid;\r\n grid-template-columns: 40px 200px 75px 8px 75px 8px 40px 40px 40px 40px 40px 40px 40px 40px 1fr 40px;\r\n grid-template-rows: 100%;\r\n\r\n .disabled {\r\n opacity: 20%;\r\n pointer-events: none;\r\n }\r\n\r\n #top-bar-logo {\r\n grid-row: 1;\r\n grid-column: 1;\r\n }\r\n\r\n #top-bar-parent-name {\r\n grid-row: 1;\r\n grid-column: 2;\r\n font-family: "acumin-pro-condensed";\r\n font-size: 15pt;\r\n color: white;\r\n display: grid;\r\n align-content: center;\r\n padding-bottom: 5px;\r\n }\r\n\r\n #key-frame {\r\n grid-row: 1;\r\n grid-column: 3;\r\n height: 24px;\r\n display: grid;\r\n align-self: center;\r\n }\r\n\r\n #key-value {\r\n grid-row: 1;\r\n grid-column: 5;\r\n height: 24px;\r\n display: grid;\r\n align-self: center;\r\n }\r\n\r\n #new-key {\r\n grid-row: 1;\r\n grid-column: 7;\r\n }\r\n\r\n #frame-canvas {\r\n grid-row: 1;\r\n grid-column: 8;\r\n }\r\n\r\n #flatten-tangent {\r\n grid-row: 1;\r\n grid-column: 9;\r\n }\r\n\r\n #linear-tangent {\r\n grid-row: 1;\r\n grid-column: 10;\r\n }\r\n\r\n #break-tangent {\r\n grid-row: 1;\r\n grid-column: 11;\r\n }\r\n\r\n #unify-tangent {\r\n grid-row: 1;\r\n grid-column: 12;\r\n }\r\n\r\n #step-tangent {\r\n grid-row: 1;\r\n grid-column: 13;\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},4703:(e,t,r)=>{"use strict";r.d(t,{Z:()=>i});var n=r(4864),o=r.n(n),s=r(7885),a=r.n(s)()(o());a.push([e.id,'#texture-editor{height:100%;width:100%;color:#fff;background-color:#1e1e1e;font-family:"acumin-pro-condensed"}#texture-editor .icon{width:40px;height:40px}#texture-editor .icon.button{background-color:#333}#texture-editor .icon.button:hover{background-color:#4a4a4a;cursor:pointer}#texture-editor .icon.button.active{background-color:#666}#texture-editor .icon.button:active{background-color:#837c7c}#texture-editor .has-tooltip{display:inline-block}#texture-editor .has-tooltip .tooltip{visibility:hidden;background-color:#fff;z-index:1;position:absolute;opacity:0;transition:opacity .5s;line-height:normal;font-size:14px;padding:0px 5px;color:#000}#texture-editor .has-tooltip:hover .tooltip{visibility:visible;opacity:1}#texture-editor #properties{width:100%;height:40px;display:flex;align-items:center;font-size:12px;color:#fff;user-select:none;background-color:#333}#texture-editor #properties .tab{display:inline-flex;line-height:40px;height:40px;flex-shrink:0;flex-grow:0;border-right:2px solid #1e1e1e;background-color:#333}#texture-editor #properties #left{overflow:hidden;height:40px;flex-grow:1;flex-shrink:1;display:flex;flex-wrap:wrap}#texture-editor #properties #left #dimensions-tab form{display:flex}#texture-editor #properties #left #dimensions-tab label{margin-left:15px;font-size:15px;color:#afafaf}#texture-editor #properties #left #dimensions-tab label input{width:40px;height:24px;background-color:#000;color:#fff;border:0;font-size:12px;text-align:"left";font-family:"acumin-pro-condensed";font-size:15px;padding-left:8px}#texture-editor #properties #left #dimensions-tab label:last-of-type{margin-right:8px}#texture-editor #properties #right-tab{margin-right:0;flex-grow:0;flex-shrink:0}#texture-editor #properties #right-tab input[type=file]{display:none}#texture-editor #properties .pixel-data{width:45px;color:#afafaf;display:flex;justify-content:space-between;font-size:15px}#texture-editor #properties .pixel-data:first-of-type{margin-left:15px}#texture-editor #properties .pixel-data:last-of-type{padding-right:15px}#texture-editor #properties .pixel-data .value{display:inline-block;width:30px;color:#fff}#texture-editor #toolbar{position:absolute;top:60px;left:0;width:40px;display:flex;flex-direction:column;justify-content:left}#texture-editor #toolbar #tools{display:flex;flex-direction:column}#texture-editor #toolbar #add-tool{position:relative}#texture-editor #toolbar #add-tool #add-tool-popup{background-color:#333;width:348px;margin-left:40px;position:absolute;top:0px;height:40px;padding-left:4px;line-height:40px;user-select:none}#texture-editor #toolbar #add-tool #add-tool-popup button{background:#222;border:1px solid #337ab7;margin:5px 10px 5px 10px;color:#fff;padding:4px 5px;opacity:.9;cursor:pointer}#texture-editor #toolbar #color{margin-top:8px}#texture-editor #toolbar #color #active-color-bg{border-radius:50%;width:20px;height:20px;margin:10px;position:relative;background-image:linear-gradient(45deg, #808080 25%, transparent 25%),linear-gradient(-45deg, #808080 25%, transparent 25%),linear-gradient(45deg, transparent 75%, #808080 75%),linear-gradient(-45deg, transparent 75%, #808080 75%);background-size:20px 20px;background-position:0 0,0 10px,10px -10px,-10px 0px}#texture-editor #toolbar #color #active-color{width:20px;height:20px;position:absolute;top:0;left:0;border-radius:50%}#texture-editor #toolbar #color-picker{position:absolute;margin-left:40px}#texture-editor #channels-bar{position:absolute;top:60px;right:0;width:80px;background:#666;user-select:none}#texture-editor #channels-bar .channel{color:#fff;border-bottom:2px solid #232323;width:80px;height:40px;font-size:16px;display:flex;align-items:center}#texture-editor #channels-bar .channel.uneditable{background:#333}#texture-editor #channels-bar .channel:hover{cursor:pointer}#texture-editor #channels-bar .channel:last-of-type{border-bottom:none}#texture-editor #canvas-ui{width:100%;height:calc(100% - 70px);outline:none}#texture-editor #tool-ui{background-color:#333;position:absolute;right:0;bottom:30px}#texture-editor #tool-ui label{display:flex;flex-direction:column;align-items:center}#texture-editor #tool-ui input[type=range]{background:#d3d3d3}#texture-editor #bottom-bar{height:30px;width:100%;background-color:#333;font-size:14px;user-select:none;line-height:30px;position:relative}#texture-editor #bottom-bar #file-url{left:30px;position:absolute}#texture-editor #bottom-bar #mip-level{right:30px;position:absolute}',"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/actionTabs/tabs/propertyGrids/materials/textures/textureEditor.scss"],names:[],mappings:"AAAA,gBACI,WAAA,CACA,UAAA,CACA,UAAA,CACA,wBAAA,CACA,kCAAA,CAEA,sBACI,UAAA,CACA,WAAA,CACA,6BACI,qBAAA,CACA,mCACI,wBAAA,CACA,cAAA,CAGJ,oCACI,qBAAA,CAGJ,oCACI,wBAAA,CAKZ,6BACI,oBAAA,CACA,sCACI,iBAAA,CACA,qBAAA,CACA,SAAA,CACA,iBAAA,CACA,SAAA,CACA,sBAAA,CACA,kBAAA,CACA,cAAA,CACA,eAAA,CACA,UAAA,CAGJ,4CACI,kBAAA,CACA,SAAA,CAIR,4BACI,UAAA,CACA,WAAA,CAEA,YAAA,CACA,kBAAA,CACA,cAAA,CACA,UAAA,CACA,gBAAA,CACA,qBAAA,CAEA,iCACI,mBAAA,CACA,gBAAA,CACA,WAAA,CACA,aAAA,CACA,WAAA,CACA,8BAAA,CACA,qBAAA,CAEJ,kCACI,eAAA,CACA,WAAA,CACA,WAAA,CACA,aAAA,CACA,YAAA,CACA,cAAA,CAEI,uDACI,YAAA,CAEJ,wDACI,gBAAA,CACA,cAAA,CACA,aAAA,CACA,8DACI,UAAA,CACA,WAAA,CACA,qBAAA,CACA,UAAA,CACA,QAAA,CACA,cAAA,CACA,iBAAA,CACA,kCAAA,CACA,cAAA,CACA,gBAAA,CAGJ,qEACI,gBAAA,CAKhB,uCACI,cAAA,CACA,WAAA,CACA,aAAA,CAEA,wDACI,YAAA,CAIR,wCAOI,UAAA,CACA,aAAA,CACA,YAAA,CACA,6BAAA,CAMA,cAAA,CAfA,sDACI,gBAAA,CAEJ,qDACI,kBAAA,CAMJ,+CACI,oBAAA,CACA,UAAA,CACA,UAAA,CAMZ,yBACI,iBAAA,CACA,QAAA,CACA,MAAA,CACA,UAAA,CACA,YAAA,CACA,qBAAA,CACA,oBAAA,CAEA,gCACI,YAAA,CACA,qBAAA,CAGJ,mCACI,iBAAA,CACA,mDACI,qBAAA,CACA,WAAA,CACA,gBAAA,CACA,iBAAA,CACA,OAAA,CACA,WAAA,CACA,gBAAA,CACA,gBAAA,CACA,gBAAA,CACA,0DACI,eAAA,CACA,wBAAA,CACA,wBAAA,CACA,UAAA,CACA,eAAA,CACA,UAAA,CACA,cAAA,CAKZ,gCACI,cAAA,CACA,iDACI,iBAAA,CACA,UAAA,CACA,WAAA,CACA,WAAA,CACA,iBAAA,CACA,sOAAA,CAEA,yBAAA,CACA,mDAAA,CAEJ,8CACI,UAAA,CACA,WAAA,CACA,iBAAA,CACA,KAAA,CACA,MAAA,CACA,iBAAA,CAGR,uCACI,iBAAA,CACA,gBAAA,CAIR,8BACI,iBAAA,CACA,QAAA,CACA,OAAA,CACA,UAAA,CACA,eAAA,CAsBA,gBAAA,CArBA,uCACI,UAAA,CACA,+BAAA,CACA,UAAA,CACA,WAAA,CACA,cAAA,CACA,YAAA,CACA,kBAAA,CAEA,kDACI,eAAA,CAGJ,6CACI,cAAA,CAGJ,oDACI,kBAAA,CAMZ,2BACI,UAAA,CACA,wBAAA,CACA,YAAA,CAGJ,yBACI,qBAAA,CACA,iBAAA,CACA,OAAA,CACA,WAAA,CAEA,+BACI,YAAA,CACA,qBAAA,CACA,kBAAA,CAGJ,2CACI,kBAAA,CAIR,4BACI,WAAA,CACA,UAAA,CACA,qBAAA,CACA,cAAA,CACA,gBAAA,CACA,gBAAA,CACA,iBAAA,CACA,sCACI,SAAA,CACA,iBAAA,CAEJ,uCACI,UAAA,CACA,iBAAA",sourcesContent:['#texture-editor {\r\n height: 100%;\r\n width: 100%;\r\n color: white;\r\n background-color: #1e1e1e;\r\n font-family: "acumin-pro-condensed";\r\n\r\n .icon {\r\n width: 40px;\r\n height: 40px;\r\n &.button {\r\n background-color: #333333;\r\n &:hover {\r\n background-color: #4a4a4a;\r\n cursor: pointer;\r\n }\r\n // When the button is selected - className=\'active\'\r\n &.active {\r\n background-color: #666666;\r\n }\r\n // When the button is clicked\r\n &:active {\r\n background-color: #837c7c;\r\n }\r\n }\r\n }\r\n\r\n .has-tooltip {\r\n display: inline-block;\r\n .tooltip {\r\n visibility: hidden;\r\n background-color: rgb(255, 255, 255);\r\n z-index: 1;\r\n position: absolute;\r\n opacity: 0;\r\n transition: opacity 0.5s;\r\n line-height: normal;\r\n font-size: 14px;\r\n padding: 0px 5px;\r\n color: black;\r\n }\r\n\r\n &:hover .tooltip {\r\n visibility: visible;\r\n opacity: 1;\r\n }\r\n }\r\n\r\n #properties {\r\n width: 100%;\r\n height: 40px;\r\n\r\n display: flex;\r\n align-items: center;\r\n font-size: 12px;\r\n color: white;\r\n user-select: none;\r\n background-color: #333333;\r\n\r\n .tab {\r\n display: inline-flex;\r\n line-height: 40px;\r\n height: 40px;\r\n flex-shrink: 0;\r\n flex-grow: 0;\r\n border-right: 2px solid #1e1e1e;\r\n background-color: #333333;\r\n }\r\n #left {\r\n overflow: hidden;\r\n height: 40px;\r\n flex-grow: 1;\r\n flex-shrink: 1;\r\n display: flex;\r\n flex-wrap: wrap;\r\n #dimensions-tab {\r\n form {\r\n display: flex;\r\n }\r\n label {\r\n margin-left: 15px;\r\n font-size: 15px;\r\n color: #afafaf;\r\n input {\r\n width: 40px;\r\n height: 24px;\r\n background-color: #000000;\r\n color: #ffffff;\r\n border: 0;\r\n font-size: 12px;\r\n text-align: "left";\r\n font-family: "acumin-pro-condensed";\r\n font-size: 15px;\r\n padding-left: 8px;\r\n }\r\n\r\n &:last-of-type {\r\n margin-right: 8px;\r\n }\r\n }\r\n }\r\n }\r\n #right-tab {\r\n margin-right: 0;\r\n flex-grow: 0;\r\n flex-shrink: 0;\r\n\r\n input[type="file"] {\r\n display: none;\r\n }\r\n }\r\n\r\n .pixel-data {\r\n &:first-of-type {\r\n margin-left: 15px;\r\n }\r\n &:last-of-type {\r\n padding-right: 15px;\r\n }\r\n width: 45px;\r\n color: #afafaf;\r\n display: flex;\r\n justify-content: space-between;\r\n .value {\r\n display: inline-block;\r\n width: 30px;\r\n color: white;\r\n }\r\n font-size: 15px;\r\n }\r\n }\r\n\r\n #toolbar {\r\n position: absolute;\r\n top: 60px;\r\n left: 0;\r\n width: 40px;\r\n display: flex;\r\n flex-direction: column;\r\n justify-content: left;\r\n\r\n #tools {\r\n display: flex;\r\n flex-direction: column;\r\n }\r\n\r\n #add-tool {\r\n position: relative;\r\n #add-tool-popup {\r\n background-color: #333333;\r\n width: 348px;\r\n margin-left: 40px;\r\n position: absolute;\r\n top: 0px;\r\n height: 40px;\r\n padding-left: 4px;\r\n line-height: 40px;\r\n user-select: none;\r\n button {\r\n background: #222222;\r\n border: 1px solid rgb(51, 122, 183);\r\n margin: 5px 10px 5px 10px;\r\n color: white;\r\n padding: 4px 5px;\r\n opacity: 0.9;\r\n cursor: pointer;\r\n }\r\n }\r\n }\r\n\r\n #color {\r\n margin-top: 8px;\r\n #active-color-bg {\r\n border-radius: 50%;\r\n width: 20px;\r\n height: 20px;\r\n margin: 10px;\r\n position: relative;\r\n background-image: linear-gradient(45deg, #808080 25%, transparent 25%), linear-gradient(-45deg, #808080 25%, transparent 25%),\r\n linear-gradient(45deg, transparent 75%, #808080 75%), linear-gradient(-45deg, transparent 75%, #808080 75%);\r\n background-size: 20px 20px;\r\n background-position: 0 0, 0 10px, 10px -10px, -10px 0px;\r\n }\r\n #active-color {\r\n width: 20px;\r\n height: 20px;\r\n position: absolute;\r\n top: 0;\r\n left: 0;\r\n border-radius: 50%;\r\n }\r\n }\r\n #color-picker {\r\n position: absolute;\r\n margin-left: 40px;\r\n }\r\n }\r\n\r\n #channels-bar {\r\n position: absolute;\r\n top: 60px;\r\n right: 0;\r\n width: 80px;\r\n background: #666666;\r\n .channel {\r\n color: white;\r\n border-bottom: 2px solid #232323;\r\n width: 80px;\r\n height: 40px;\r\n font-size: 16px;\r\n display: flex;\r\n align-items: center;\r\n\r\n &.uneditable {\r\n background: #333333;\r\n }\r\n\r\n &:hover {\r\n cursor: pointer;\r\n }\r\n\r\n &:last-of-type {\r\n border-bottom: none;\r\n }\r\n }\r\n user-select: none;\r\n }\r\n\r\n #canvas-ui {\r\n width: 100%;\r\n height: calc(100% - 70px);\r\n outline: none;\r\n }\r\n\r\n #tool-ui {\r\n background-color: #333;\r\n position: absolute;\r\n right: 0;\r\n bottom: 30px;\r\n\r\n label {\r\n display: flex;\r\n flex-direction: column;\r\n align-items: center;\r\n }\r\n\r\n input[type="range"] {\r\n background: #d3d3d3;\r\n }\r\n }\r\n\r\n #bottom-bar {\r\n height: 30px;\r\n width: 100%;\r\n background-color: #333333;\r\n font-size: 14px;\r\n user-select: none;\r\n line-height: 30px;\r\n position: relative;\r\n #file-url {\r\n left: 30px;\r\n position: absolute;\r\n }\r\n #mip-level {\r\n right: 30px;\r\n position: absolute;\r\n }\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},499:(e,t,r)=>{"use strict";r.d(t,{Z:()=>i});var n=r(4864),o=r.n(n),s=r(7885),a=r.n(s)()(o());a.push([e.id,"#metadata-container textarea{display:block;margin:4px;width:calc(100% - 14px);min-height:100px;max-height:500px;resize:vertical}.meta-string textarea{background:#fe9}.meta-json textarea{background:#9df}.meta-object textarea{background:#d9f}.meta-object-protect textarea{background:#b0b0b0}.buttonLine.disabled{opacity:20%;pointer-events:none}.copy-root{display:grid;justify-content:end;height:30px}.copy-container{height:30px;width:30px;cursor:pointer}.hoverIcon:hover{opacity:.8}.type-status{padding:5px 15px}","",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/actionTabs/tabs/propertyGrids/metadata/metadataPropertyGrid.scss"],names:[],mappings:"AACI,6BACI,aAAA,CACA,UAAA,CACA,uBAAA,CACA,gBAAA,CACA,gBAAA,CACA,eAAA,CAKJ,sBACI,eAAA,CAKJ,oBACI,eAAA,CAKJ,sBACI,eAAA,CAKJ,8BACI,kBAAA,CAKJ,qBACI,WAAA,CACA,mBAAA,CAIR,WACI,YAAA,CACA,mBAAA,CACA,WAAA,CAGJ,gBACI,WAAA,CACA,UAAA,CACA,cAAA,CAGJ,iBACI,UAAA,CAGJ,aACI,gBAAA",sourcesContent:["#metadata-container {\r\n textarea {\r\n display: block;\r\n margin: 4px;\r\n width: calc(100% - 14px);\r\n min-height: 100px;\r\n max-height: 500px;\r\n resize: vertical;\r\n }\r\n}\r\n\r\n.meta-string {\r\n textarea {\r\n background: #ffee99;\r\n }\r\n}\r\n\r\n.meta-json {\r\n textarea {\r\n background: #99ddff;\r\n }\r\n}\r\n\r\n.meta-object {\r\n textarea {\r\n background: #dd99ff;\r\n }\r\n}\r\n\r\n.meta-object-protect {\r\n textarea {\r\n background: #b0b0b0;\r\n }\r\n}\r\n\r\n.buttonLine {\r\n &.disabled {\r\n opacity: 20%;\r\n pointer-events: none;\r\n }\r\n}\r\n\r\n.copy-root {\r\n display: grid;\r\n justify-content: end;\r\n height: 30px;\r\n}\r\n\r\n.copy-container {\r\n height: 30px;\r\n width: 30px;\r\n cursor: pointer;\r\n}\r\n\r\n.hoverIcon:hover {\r\n opacity: 0.8;\r\n}\r\n\r\n.type-status {\r\n padding: 5px 15px;\r\n}\r\n"],sourceRoot:""}]),a.locals={};const i=a},7018:(e,t,r)=>{"use strict";r.d(t,{Z:()=>i});var n=r(4864),o=r.n(n),s=r(7885),a=r.n(s)()(o());a.push([e.id,'#embed-host{position:absolute;right:0px;top:0px;bottom:0px;z-index:10}#__resizable_base__{display:none}#embed{background:#333;height:100%;margin:0;padding:0;display:grid;grid-template-rows:30px 1fr;font:14px "Arial";overflow:hidden}#embed #header{font-size:16px;color:#fff;background:#222;grid-row:1;text-align:center;display:grid;grid-template-columns:30px 1fr 50px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#embed #header #logo{grid-column:1;width:24px;height:24px;display:flex;align-self:center;justify-self:center}#embed #header #back{grid-column:1;display:grid;align-self:center;justify-self:center;cursor:pointer}#embed #header #title{grid-column:2;display:grid;align-items:center;text-align:center}#embed #header #commands{grid-column:3;display:grid;align-items:center;grid-template-columns:1fr 1fr}#embed #header #commands .expand{grid-column:1;display:grid;align-items:center;justify-items:center;cursor:pointer}#embed #header #commands .close{grid-column:2;display:grid;align-items:center;justify-items:center;cursor:pointer}#embed #split{grid-row:2;overflow:hidden}#embed #split.splitPopup{display:grid;grid-template-rows:300px 2px 1fr}#embed #split.splitPopup .panes{margin-bottom:1px}#embed #split #topPart{grid-row:1;overflow:hidden;display:grid;grid-auto-rows:100%}#embed #split #separator{grid-row:2;background:#fff;opacity:.1}#embed #split #bottomPart{overflow:hidden;grid-row:3;display:grid;grid-auto-rows:100%}#embed #split .gutter.gutter-vertical{background-image:none;background:#444;cursor:row-resize}',"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/embedHost/embedHost.scss"],names:[],mappings:"AAAA,YACI,iBAAA,CACA,SAAA,CACA,OAAA,CACA,UAAA,CACA,UAAA,CAGJ,oBACI,YAAA,CAGJ,OACI,eAAA,CACA,WAAA,CACA,QAAA,CACA,SAAA,CACA,YAAA,CACA,2BAAA,CACA,iBAAA,CACA,eAAA,CAEA,eACI,cAAA,CACA,UAAA,CACA,eAAA,CACA,UAAA,CACA,iBAAA,CACA,YAAA,CACA,mCAAA,CACA,wBAAA,CACA,qBAAA,CACA,oBAAA,CACA,gBAAA,CAEA,qBACI,aAAA,CACA,UAAA,CACA,WAAA,CACA,YAAA,CACA,iBAAA,CACA,mBAAA,CAGJ,qBACI,aAAA,CACA,YAAA,CACA,iBAAA,CACA,mBAAA,CACA,cAAA,CAGJ,sBACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,iBAAA,CAGJ,yBACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,6BAAA,CAEA,iCACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CACA,cAAA,CAGJ,gCACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CACA,cAAA,CAKZ,cACI,UAAA,CACA,eAAA,CAEA,yBACI,YAAA,CACA,gCAAA,CAEA,gCACI,iBAAA,CAIR,uBACI,UAAA,CACA,eAAA,CACA,YAAA,CACA,mBAAA,CAGJ,yBACI,UAAA,CACA,eAAA,CACA,UAAA,CAGJ,0BACI,eAAA,CACA,UAAA,CACA,YAAA,CACA,mBAAA,CAGJ,sCACI,qBAAA,CACA,eAAA,CACA,iBAAA",sourcesContent:['#embed-host {\r\n position: absolute;\r\n right: 0px;\r\n top: 0px;\r\n bottom: 0px;\r\n z-index: 10;\r\n}\r\n\r\n#__resizable_base__ {\r\n display: none;\r\n}\r\n\r\n#embed {\r\n background: #333333;\r\n height: 100%;\r\n margin: 0;\r\n padding: 0;\r\n display: grid;\r\n grid-template-rows: 30px 1fr;\r\n font: 14px "Arial";\r\n overflow: hidden;\r\n\r\n #header {\r\n font-size: 16px;\r\n color: white;\r\n background: #222222;\r\n grid-row: 1;\r\n text-align: center;\r\n display: grid;\r\n grid-template-columns: 30px 1fr 50px;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n\r\n #logo {\r\n grid-column: 1;\r\n width: 24px;\r\n height: 24px;\r\n display: flex;\r\n align-self: center;\r\n justify-self: center;\r\n }\r\n\r\n #back {\r\n grid-column: 1;\r\n display: grid;\r\n align-self: center;\r\n justify-self: center;\r\n cursor: pointer;\r\n }\r\n\r\n #title {\r\n grid-column: 2;\r\n display: grid;\r\n align-items: center;\r\n text-align: center;\r\n }\r\n\r\n #commands {\r\n grid-column: 3;\r\n display: grid;\r\n align-items: center;\r\n grid-template-columns: 1fr 1fr;\r\n\r\n .expand {\r\n grid-column: 1;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n\r\n .close {\r\n grid-column: 2;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n }\r\n }\r\n\r\n #split {\r\n grid-row: 2;\r\n overflow: hidden;\r\n\r\n &.splitPopup {\r\n display: grid;\r\n grid-template-rows: 300px 2px 1fr;\r\n\r\n .panes {\r\n margin-bottom: 1px;\r\n }\r\n }\r\n\r\n #topPart {\r\n grid-row: 1;\r\n overflow: hidden;\r\n display: grid;\r\n grid-auto-rows: 100%;\r\n }\r\n\r\n #separator {\r\n grid-row: 2;\r\n background: white;\r\n opacity: 0.1;\r\n }\r\n\r\n #bottomPart {\r\n overflow: hidden;\r\n grid-row: 3;\r\n display: grid;\r\n grid-auto-rows: 100%;\r\n }\r\n\r\n .gutter.gutter-vertical {\r\n background-image: none;\r\n background: #444444;\r\n cursor: row-resize;\r\n }\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},9814:(e,t,r)=>{"use strict";r.d(t,{Z:()=>i});var n=r(4864),o=r.n(n),s=r(7885),a=r.n(s)()(o());a.push([e.id,'#scene-explorer-host{position:absolute;left:0px;top:0px;bottom:0px}#scene-explorer-host:focus{outline:none}#__resizable_base__{display:none}.context-menu{background:#222}.context-menu .react-contextmenu-item{padding:10px;cursor:pointer}.context-menu .react-contextmenu-item:hover{background:#555}.react-contextmenu.context-menu.react-contextmenu--visible{z-index:99;transform:scale(1)}#sceneExplorer{background:#333;height:100%;margin:0;padding:0;display:grid;grid-template-rows:auto 1fr;font:14px "Arial"}#sceneExplorer:focus{outline:none}#sceneExplorer #header{height:30px;font-size:16px;color:#fff;background:#222;grid-row:1;text-align:center;display:grid;grid-template-columns:30px 1fr 50px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#sceneExplorer #header #logo{position:relative;grid-column:1;width:24px;height:24px;left:0;display:flex;align-self:center;justify-self:center}#sceneExplorer #header #title{grid-column:2;display:grid;align-items:center;text-align:center}#sceneExplorer #header #commands{grid-column:3;display:grid;align-items:center;grid-template-columns:1fr 1fr}#sceneExplorer #header #commands .expand{grid-column:1;display:grid;align-items:center;justify-items:center;cursor:pointer}#sceneExplorer #header #commands .close{grid-column:2;display:grid;align-items:center;justify-items:center;cursor:pointer}#sceneExplorer #tree{grid-row:2;overflow-x:hidden;overflow-y:auto}#sceneExplorer .filter{display:flex;align-items:stretch}#sceneExplorer .filter input{width:100%;margin:10px 40px 5px 40px;display:block;border:none;padding:0;border-bottom:solid 1px #337ab7;background:linear-gradient(to bottom, rgba(255, 255, 255, 0) 96%, rgb(51, 122, 183) 4%);background-position:-1000px 0;background-size:1000px 100%;background-repeat:no-repeat;color:#fff}#sceneExplorer .filter input::placeholder{color:#d3d3d3}#sceneExplorer .filter input:focus{box-shadow:none;outline:none;background-position:0 0}#sceneExplorer .groupContainer{margin-left:0px;color:#fff;margin-top:0px;margin-bottom:0px;height:24px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;align-self:center;display:grid;align-items:center}#sceneExplorer .groupContainer:hover{background:#444}#sceneExplorer .groupContainer .expandableHeader{display:grid;grid-template-columns:1fr 20px}#sceneExplorer .groupContainer .expandableHeader .text{grid-column:1;display:grid;grid-template-columns:20px 1fr}#sceneExplorer .groupContainer .expandableHeader .text .arrow{grid-column:1;margin-left:0px;color:#fff;cursor:pointer;display:inline-block;margin-right:6px;opacity:.5}#sceneExplorer .groupContainer .expandableHeader .text .text-value{grid-column:2;display:flex;align-items:center}#sceneExplorer .groupContainer .expandableHeader .expandAll{opacity:.5;grid-column:2;margin-right:10px}#sceneExplorer .icon{display:grid;align-items:center;justify-items:center;cursor:pointer}#sceneExplorer .itemContainer{margin-left:0px;color:#fff;margin-top:0px;margin-bottom:0px;height:24px;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:grid;grid-template-columns:20px 1fr}#sceneExplorer .itemContainer:hover{background:#444}#sceneExplorer .itemContainer.selected{background:#bbb;color:#000}#sceneExplorer .itemContainer .isNotActive{opacity:.3}#sceneExplorer .itemContainer .arrow{grid-column:1;color:#fff;opacity:.6}#sceneExplorer .itemContainer .popup{width:200px;visibility:hidden;background-color:#444;color:#fff;border:1px solid rgba(255,255,255,.5);position:absolute;z-index:1;margin-left:-180px;box-sizing:border-box}#sceneExplorer .itemContainer .popup.show{visibility:visible}#sceneExplorer .itemContainer .popup:focus{outline:none}#sceneExplorer .itemContainer .popup .popupMenu{padding:6px 5px 5px 10px;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;height:18px}#sceneExplorer .itemContainer .popup .popupMenu:hover{background:#fff;color:#333}#sceneExplorer .itemContainer .sceneNode{grid-column:2;margin-left:-10px;display:grid;grid-template-columns:1fr 20px 20px 20px 20px 10px 20px 20px auto 5px;align-items:center;cursor:pointer}#sceneExplorer .itemContainer .sceneNode .sceneTitle{grid-column:1;margin-right:5px;display:flex;align-items:center;height:24px}#sceneExplorer .itemContainer .sceneNode .translation{grid-column:2;opacity:.6}#sceneExplorer .itemContainer .sceneNode .translation.selected{opacity:1}#sceneExplorer .itemContainer .sceneNode .rotation{grid-column:3;opacity:.6}#sceneExplorer .itemContainer .sceneNode .rotation.selected{opacity:1}#sceneExplorer .itemContainer .sceneNode .scaling{grid-column:4;opacity:.6}#sceneExplorer .itemContainer .sceneNode .scaling.selected{opacity:1}#sceneExplorer .itemContainer .sceneNode .bounding{grid-column:5;opacity:.6}#sceneExplorer .itemContainer .sceneNode .bounding.selected{opacity:1}#sceneExplorer .itemContainer .sceneNode .separator{grid-column:6;margin-left:5px;width:5px;display:flex;align-items:center;height:18px;border-left:solid 1px #337ab7}#sceneExplorer .itemContainer .sceneNode .pickingMode{grid-column:7;opacity:.6}#sceneExplorer .itemContainer .sceneNode .pickingMode.selected{opacity:1}#sceneExplorer .itemContainer .sceneNode .coordinates{grid-column:8;opacity:.6}#sceneExplorer .itemContainer .sceneNode .coordinates.selected{opacity:1}#sceneExplorer .itemContainer .sceneNode .refresh{grid-column:9}#sceneExplorer .itemContainer .sceneNode .extensions{width:20px;grid-column:10}#sceneExplorer .itemContainer .targetedAnimationTools{grid-column:2;width:100%;display:grid;grid-template-columns:1fr auto 5px;align-items:center;min-width:0}#sceneExplorer .itemContainer .targetedAnimationTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .animationGroupTools{grid-column:2;width:100%;display:grid;grid-template-columns:1fr auto 5px;align-items:center;min-width:0}#sceneExplorer .itemContainer .animationGroupTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .soundTools{grid-column:2;width:100%;display:grid;grid-template-columns:1fr auto 5px;align-items:center;min-width:0}#sceneExplorer .itemContainer .soundTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .meshTools{grid-column:2;width:100%;display:grid;grid-template-columns:1fr 20px 20px auto 5px;align-items:center;min-width:0}#sceneExplorer .itemContainer .meshTools .bounding-box{grid-column:2;opacity:.5}#sceneExplorer .itemContainer .meshTools .bounding-box.selected{opacity:1}#sceneExplorer .itemContainer .meshTools .visibility{grid-column:3}#sceneExplorer .itemContainer .meshTools .extensions{width:20px;grid-column:4}#sceneExplorer .itemContainer .cameraTools{grid-column:2;display:grid;grid-template-columns:1fr 20px 20px auto 5px;align-items:center}#sceneExplorer .itemContainer .cameraTools .activeCamera{grid-column:2}#sceneExplorer .itemContainer .cameraTools .enableGizmo{grid-column:3}#sceneExplorer .itemContainer .cameraTools .extensions{width:20px;grid-column:4}#sceneExplorer .itemContainer .lightTools{grid-column:2;display:grid;grid-template-columns:1fr 20px 20px auto 5px;align-items:center}#sceneExplorer .itemContainer .lightTools .visibility{grid-column:2}#sceneExplorer .itemContainer .lightTools .enableGizmo{grid-column:3}#sceneExplorer .itemContainer .lightTools .extensions{width:20px;grid-column:4}#sceneExplorer .itemContainer .spriteTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .spriteTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .spriteManagerTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .spriteManagerTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .materialTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .materialTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .materialTools .icon{display:grid;align-items:center;justify-items:center;cursor:pointer}#sceneExplorer .itemContainer .particleSystemTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .particleSystemTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .effectLayerTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .effectLayerTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .postProcessTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .postProcessTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .renderingPipelineTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .renderingPipelineTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .textureTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .textureTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .adtextureTools{grid-column:2;display:grid;grid-template-columns:1fr 20px 20px auto 5px;align-items:center}#sceneExplorer .itemContainer .adtextureTools .edit{grid-column:2}#sceneExplorer .itemContainer .adtextureTools .pickingMode{grid-column:3;opacity:.6}#sceneExplorer .itemContainer .adtextureTools .pickingMode.selected{opacity:1}#sceneExplorer .itemContainer .adtextureTools .extensions{width:20px;grid-column:3}#sceneExplorer .itemContainer .controlTools{grid-column:2;display:grid;grid-template-columns:1fr 20px 20px auto 5px;align-items:center}#sceneExplorer .itemContainer .controlTools .highlight{grid-column:2}#sceneExplorer .itemContainer .controlTools .visibility{grid-column:3}#sceneExplorer .itemContainer .controlTools .extensions{width:20px;grid-column:4}#sceneExplorer .itemContainer .transformNodeTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .transformNodeTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .skeletonTools{grid-column:2;display:grid;grid-template-columns:1fr auto 5px;align-items:center}#sceneExplorer .itemContainer .skeletonTools .extensions{width:20px;grid-column:2}#sceneExplorer .itemContainer .title{grid-column:1;background:rgba(0,0,0,0);white-space:nowrap;overflow:hidden;min-width:0;margin-right:5px;display:grid;align-items:center;grid-template-columns:25px 1fr;height:24px;cursor:pointer}#sceneExplorer .itemContainer .title .titleIcon{grid-column:1;display:grid;align-items:center;justify-items:center}#sceneExplorer .itemContainer .title .titleText{grid-column:2;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}',"",{version:3,sources:["webpack://./../../../dev/inspector/dist/components/sceneExplorer/sceneExplorer.scss"],names:[],mappings:"AAAA,qBACI,iBAAA,CACA,QAAA,CACA,OAAA,CACA,UAAA,CAEA,2BACI,YAAA,CAIR,oBACI,YAAA,CAGJ,cACI,eAAA,CAEA,sCACI,YAAA,CACA,cAAA,CAEA,4CACI,eAAA,CAKZ,2DACI,UAAA,CACA,kBAAA,CAGJ,eACI,eAAA,CACA,WAAA,CACA,QAAA,CACA,SAAA,CACA,YAAA,CACA,2BAAA,CACA,iBAAA,CAEA,qBACI,YAAA,CAGJ,uBACI,WAAA,CACA,cAAA,CACA,UAAA,CACA,eAAA,CACA,UAAA,CACA,iBAAA,CACA,YAAA,CACA,mCAAA,CACA,wBAAA,CACA,qBAAA,CACA,oBAAA,CACA,gBAAA,CAEA,6BACI,iBAAA,CACA,aAAA,CACA,UAAA,CACA,WAAA,CACA,MAAA,CACA,YAAA,CACA,iBAAA,CACA,mBAAA,CAGJ,8BACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,iBAAA,CAGJ,iCACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,6BAAA,CAEA,yCACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CACA,cAAA,CAGJ,wCACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CACA,cAAA,CAKZ,qBACI,UAAA,CAEA,iBAAA,CACA,eAAA,CAGJ,uBACI,YAAA,CACA,mBAAA,CAEA,6BACI,UAAA,CACA,yBAAA,CACA,aAAA,CACA,WAAA,CACA,SAAA,CACA,+BAAA,CACA,uFAAA,CACA,6BAAA,CACA,2BAAA,CACA,2BAAA,CACA,UAAA,CAGJ,0CACI,aAAA,CAGJ,mCACI,eAAA,CACA,YAAA,CACA,uBAAA,CAIR,+BACI,eAAA,CACA,UAAA,CACA,cAAA,CACA,iBAAA,CACA,WAAA,CAEA,wBAAA,CACA,qBAAA,CACA,oBAAA,CACA,gBAAA,CAEA,iBAAA,CACA,YAAA,CACA,kBAAA,CAEA,qCACI,eAAA,CAGJ,iDACI,YAAA,CACA,8BAAA,CAEA,uDACI,aAAA,CACA,YAAA,CACA,8BAAA,CAEA,8DACI,aAAA,CACA,eAAA,CACA,UAAA,CACA,cAAA,CACA,oBAAA,CACA,gBAAA,CACA,UAAA,CAGJ,mEACI,aAAA,CACA,YAAA,CACA,kBAAA,CAIR,4DACI,UAAA,CACA,aAAA,CACA,iBAAA,CAKZ,qBACI,YAAA,CACA,kBAAA,CACA,oBAAA,CACA,cAAA,CAGJ,8BACI,eAAA,CACA,UAAA,CACA,cAAA,CACA,iBAAA,CACA,WAAA,CACA,wBAAA,CACA,qBAAA,CACA,oBAAA,CACA,gBAAA,CACA,YAAA,CACA,8BAAA,CAEA,oCACI,eAAA,CAGJ,uCACI,eAAA,CACA,UAAA,CAGJ,2CACI,UAAA,CAGJ,qCACI,aAAA,CACA,UAAA,CACA,UAAA,CAGJ,qCACI,WAAA,CACA,iBAAA,CACA,qBAAA,CACA,UAAA,CACA,qCAAA,CACA,iBAAA,CACA,SAAA,CACA,kBAAA,CACA,qBAAA,CAEA,0CACI,kBAAA,CAGJ,2CACI,YAAA,CAGJ,gDACI,wBAAA,CACA,eAAA,CACA,kBAAA,CACA,sBAAA,CACA,WAAA,CAEA,sDACI,eAAA,CACA,UAAA,CAKZ,yCACI,aAAA,CACA,iBAAA,CACA,YAAA,CACA,qEAAA,CACA,kBAAA,CACA,cAAA,CAEA,qDACI,aAAA,CACA,gBAAA,CACA,YAAA,CACA,kBAAA,CACA,WAAA,CAGJ,sDACI,aAAA,CACA,UAAA,CAEA,+DACI,SAAA,CAIR,mDACI,aAAA,CACA,UAAA,CAEA,4DACI,SAAA,CAIR,kDACI,aAAA,CACA,UAAA,CACA,2DACI,SAAA,CAIR,mDACI,aAAA,CACA,UAAA,CACA,4DACI,SAAA,CAIR,oDACI,aAAA,CACA,eAAA,CACA,SAAA,CACA,YAAA,CACA,kBAAA,CACA,WAAA,CACA,6BAAA,CAGJ,sDACI,aAAA,CACA,UAAA,CAEA,+DACI,SAAA,CAIR,sDACI,aAAA,CACA,UAAA,CAEA,+DACI,SAAA,CAIR,kDACI,aAAA,CAGJ,qDACI,UAAA,CACA,cAAA,CAIR,sDACI,aAAA,CACA,UAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CACA,WAAA,CAEA,kEACI,UAAA,CACA,aAAA,CAIR,mDACI,aAAA,CACA,UAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CACA,WAAA,CAEA,+DACI,UAAA,CACA,aAAA,CAIR,0CACI,aAAA,CACA,UAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CACA,WAAA,CAEA,sDACI,UAAA,CACA,aAAA,CAIR,yCACI,aAAA,CACA,UAAA,CACA,YAAA,CACA,4CAAA,CACA,kBAAA,CACA,WAAA,CAEA,uDACI,aAAA,CACA,UAAA,CAEA,gEACI,SAAA,CAIR,qDACI,aAAA,CAGJ,qDACI,UAAA,CACA,aAAA,CAIR,2CACI,aAAA,CACA,YAAA,CACA,4CAAA,CACA,kBAAA,CAEA,yDACI,aAAA,CAGJ,wDACI,aAAA,CAGJ,uDACI,UAAA,CACA,aAAA,CAIR,0CACI,aAAA,CACA,YAAA,CACA,4CAAA,CACA,kBAAA,CAEA,sDACI,aAAA,CAGJ,uDACI,aAAA,CAGJ,sDACI,UAAA,CACA,aAAA,CAIR,2CACI,aAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CAEA,uDACI,UAAA,CACA,aAAA,CAIR,kDACI,aAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CAEA,8DACI,UAAA,CACA,aAAA,CAIR,6CACI,aAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CAEA,yDACI,UAAA,CACA,aAAA,CAGJ,mDACI,YAAA,CACA,kBAAA,CACA,oBAAA,CACA,cAAA,CAIR,mDACI,aAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CAEA,+DACI,UAAA,CACA,aAAA,CAIR,gDACI,aAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CAEA,4DACI,UAAA,CACA,aAAA,CAIR,gDACI,aAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CAEA,4DACI,UAAA,CACA,aAAA,CAIR,sDACI,aAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CAEA,kEACI,UAAA,CACA,aAAA,CAIR,4CACI,aAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CAEA,wDACI,UAAA,CACA,aAAA,CAIR,8CACI,aAAA,CACA,YAAA,CACA,4CAAA,CACA,kBAAA,CAEA,oDACI,aAAA,CAGJ,2DACI,aAAA,CACA,UAAA,CAEA,oEACI,SAAA,CAIR,0DACI,UAAA,CACA,aAAA,CAIR,4CACI,aAAA,CACA,YAAA,CACA,4CAAA,CACA,kBAAA,CAEA,uDACI,aAAA,CAGJ,wDACI,aAAA,CAGJ,wDACI,UAAA,CACA,aAAA,CAIR,kDACI,aAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CAEA,8DACI,UAAA,CACA,aAAA,CAIR,6CACI,aAAA,CACA,YAAA,CACA,kCAAA,CACA,kBAAA,CAEA,yDACI,UAAA,CACA,aAAA,CAIR,qCACI,aAAA,CACA,wBAAA,CACA,kBAAA,CACA,eAAA,CACA,WAAA,CACA,gBAAA,CACA,YAAA,CACA,kBAAA,CACA,8BAAA,CACA,WAAA,CACA,cAAA,CAEA,gDACI,aAAA,CACA,YAAA,CACA,kBAAA,CACA,oBAAA,CAGJ,gDACI,aAAA,CACA,kBAAA,CACA,sBAAA,CACA,eAAA",sourcesContent:['#scene-explorer-host {\r\n position: absolute;\r\n left: 0px;\r\n top: 0px;\r\n bottom: 0px;\r\n\r\n &:focus {\r\n outline: none;\r\n }\r\n}\r\n\r\n#__resizable_base__ {\r\n display: none;\r\n}\r\n\r\n.context-menu {\r\n background: #222222;\r\n\r\n .react-contextmenu-item {\r\n padding: 10px;\r\n cursor: pointer;\r\n\r\n &:hover {\r\n background: #555555;\r\n }\r\n }\r\n}\r\n\r\n.react-contextmenu.context-menu.react-contextmenu--visible {\r\n z-index: 99;\r\n transform: scale(1);\r\n}\r\n\r\n#sceneExplorer {\r\n background: #333333;\r\n height: 100%;\r\n margin: 0;\r\n padding: 0;\r\n display: grid;\r\n grid-template-rows: auto 1fr;\r\n font: 14px "Arial";\r\n\r\n &:focus {\r\n outline: none;\r\n }\r\n\r\n #header {\r\n height: 30px;\r\n font-size: 16px;\r\n color: white;\r\n background: #222222;\r\n grid-row: 1;\r\n text-align: center;\r\n display: grid;\r\n grid-template-columns: 30px 1fr 50px;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n\r\n #logo {\r\n position: relative;\r\n grid-column: 1;\r\n width: 24px;\r\n height: 24px;\r\n left: 0;\r\n display: flex;\r\n align-self: center;\r\n justify-self: center;\r\n }\r\n\r\n #title {\r\n grid-column: 2;\r\n display: grid;\r\n align-items: center;\r\n text-align: center;\r\n }\r\n\r\n #commands {\r\n grid-column: 3;\r\n display: grid;\r\n align-items: center;\r\n grid-template-columns: 1fr 1fr;\r\n\r\n .expand {\r\n grid-column: 1;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n\r\n .close {\r\n grid-column: 2;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n }\r\n }\r\n\r\n #tree {\r\n grid-row: 2;\r\n\r\n overflow-x: hidden;\r\n overflow-y: auto;\r\n }\r\n\r\n .filter {\r\n display: flex;\r\n align-items: stretch;\r\n\r\n input {\r\n width: 100%;\r\n margin: 10px 40px 5px 40px;\r\n display: block;\r\n border: none;\r\n padding: 0;\r\n border-bottom: solid 1px rgb(51, 122, 183);\r\n background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 96%, rgb(51, 122, 183) 4%);\r\n background-position: -1000px 0;\r\n background-size: 1000px 100%;\r\n background-repeat: no-repeat;\r\n color: white;\r\n }\r\n\r\n input::placeholder {\r\n color: lightgray;\r\n }\r\n\r\n input:focus {\r\n box-shadow: none;\r\n outline: none;\r\n background-position: 0 0;\r\n }\r\n }\r\n\r\n .groupContainer {\r\n margin-left: 0px;\r\n color: white;\r\n margin-top: 0px;\r\n margin-bottom: 0px;\r\n height: 24px;\r\n\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n\r\n align-self: center;\r\n display: grid;\r\n align-items: center;\r\n\r\n &:hover {\r\n background: #444444;\r\n }\r\n\r\n .expandableHeader {\r\n display: grid;\r\n grid-template-columns: 1fr 20px;\r\n\r\n .text {\r\n grid-column: 1;\r\n display: grid;\r\n grid-template-columns: 20px 1fr;\r\n\r\n .arrow {\r\n grid-column: 1;\r\n margin-left: 0px;\r\n color: white;\r\n cursor: pointer;\r\n display: inline-block;\r\n margin-right: 6px;\r\n opacity: 0.5;\r\n }\r\n\r\n .text-value {\r\n grid-column: 2;\r\n display: flex;\r\n align-items: center;\r\n }\r\n }\r\n\r\n .expandAll {\r\n opacity: 0.5;\r\n grid-column: 2;\r\n margin-right: 10px;\r\n }\r\n }\r\n }\r\n\r\n .icon {\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n\r\n .itemContainer {\r\n margin-left: 0px;\r\n color: white;\r\n margin-top: 0px;\r\n margin-bottom: 0px;\r\n height: 24px;\r\n -webkit-user-select: none;\r\n -moz-user-select: none;\r\n -ms-user-select: none;\r\n user-select: none;\r\n display: grid;\r\n grid-template-columns: 20px 1fr;\r\n\r\n &:hover {\r\n background: #444444;\r\n }\r\n\r\n &.selected {\r\n background: #bbbbbb;\r\n color: black;\r\n }\r\n\r\n .isNotActive {\r\n opacity: 0.3;\r\n }\r\n\r\n .arrow {\r\n grid-column: 1;\r\n color: white;\r\n opacity: 0.6;\r\n }\r\n\r\n .popup {\r\n width: 200px;\r\n visibility: hidden;\r\n background-color: #444444;\r\n color: #fff;\r\n border: 1px solid rgba(255, 255, 255, 0.5);\r\n position: absolute;\r\n z-index: 1;\r\n margin-left: -180px;\r\n box-sizing: border-box;\r\n\r\n &.show {\r\n visibility: visible;\r\n }\r\n\r\n &:focus {\r\n outline: none;\r\n }\r\n\r\n .popupMenu {\r\n padding: 6px 5px 5px 10px;\r\n overflow: hidden;\r\n white-space: nowrap;\r\n text-overflow: ellipsis;\r\n height: 18px;\r\n\r\n &:hover {\r\n background: white;\r\n color: #333333;\r\n }\r\n }\r\n }\r\n\r\n .sceneNode {\r\n grid-column: 2;\r\n margin-left: -10px;\r\n display: grid;\r\n grid-template-columns: 1fr 20px 20px 20px 20px 10px 20px 20px auto 5px;\r\n align-items: center;\r\n cursor: pointer;\r\n\r\n .sceneTitle {\r\n grid-column: 1;\r\n margin-right: 5px;\r\n display: flex;\r\n align-items: center;\r\n height: 24px;\r\n }\r\n\r\n .translation {\r\n grid-column: 2;\r\n opacity: 0.6;\r\n\r\n &.selected {\r\n opacity: 1;\r\n }\r\n }\r\n\r\n .rotation {\r\n grid-column: 3;\r\n opacity: 0.6;\r\n\r\n &.selected {\r\n opacity: 1;\r\n }\r\n }\r\n\r\n .scaling {\r\n grid-column: 4;\r\n opacity: 0.6;\r\n &.selected {\r\n opacity: 1;\r\n }\r\n }\r\n\r\n .bounding {\r\n grid-column: 5;\r\n opacity: 0.6;\r\n &.selected {\r\n opacity: 1;\r\n }\r\n }\r\n\r\n .separator {\r\n grid-column: 6;\r\n margin-left: 5px;\r\n width: 5px;\r\n display: flex;\r\n align-items: center;\r\n height: 18px;\r\n border-left: solid 1px rgb(51, 122, 183);\r\n }\r\n\r\n .pickingMode {\r\n grid-column: 7;\r\n opacity: 0.6;\r\n\r\n &.selected {\r\n opacity: 1;\r\n }\r\n }\r\n\r\n .coordinates {\r\n grid-column: 8;\r\n opacity: 0.6;\r\n\r\n &.selected {\r\n opacity: 1;\r\n }\r\n }\r\n\r\n .refresh {\r\n grid-column: 9;\r\n }\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 10;\r\n }\r\n }\r\n\r\n .targetedAnimationTools {\r\n grid-column: 2;\r\n width: 100%;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n min-width: 0;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .animationGroupTools {\r\n grid-column: 2;\r\n width: 100%;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n min-width: 0;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .soundTools {\r\n grid-column: 2;\r\n width: 100%;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n min-width: 0;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .meshTools {\r\n grid-column: 2;\r\n width: 100%;\r\n display: grid;\r\n grid-template-columns: 1fr 20px 20px auto 5px;\r\n align-items: center;\r\n min-width: 0;\r\n\r\n .bounding-box {\r\n grid-column: 2;\r\n opacity: 0.5;\r\n\r\n &.selected {\r\n opacity: 1;\r\n }\r\n }\r\n\r\n .visibility {\r\n grid-column: 3;\r\n }\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 4;\r\n }\r\n }\r\n\r\n .cameraTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr 20px 20px auto 5px;\r\n align-items: center;\r\n\r\n .activeCamera {\r\n grid-column: 2;\r\n }\r\n\r\n .enableGizmo {\r\n grid-column: 3;\r\n }\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 4;\r\n }\r\n }\r\n\r\n .lightTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr 20px 20px auto 5px;\r\n align-items: center;\r\n\r\n .visibility {\r\n grid-column: 2;\r\n }\r\n\r\n .enableGizmo {\r\n grid-column: 3;\r\n }\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 4;\r\n }\r\n }\r\n\r\n .spriteTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .spriteManagerTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .materialTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n\r\n .icon {\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n cursor: pointer;\r\n }\r\n }\r\n\r\n .particleSystemTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .effectLayerTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .postProcessTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .renderingPipelineTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .textureTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .adtextureTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr 20px 20px auto 5px;\r\n align-items: center;\r\n\r\n .edit {\r\n grid-column: 2;\r\n }\r\n\r\n .pickingMode {\r\n grid-column: 3;\r\n opacity: 0.6;\r\n\r\n &.selected {\r\n opacity: 1;\r\n }\r\n }\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 3;\r\n }\r\n }\r\n\r\n .controlTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr 20px 20px auto 5px;\r\n align-items: center;\r\n\r\n .highlight {\r\n grid-column: 2;\r\n }\r\n\r\n .visibility {\r\n grid-column: 3;\r\n }\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 4;\r\n }\r\n }\r\n\r\n .transformNodeTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .skeletonTools {\r\n grid-column: 2;\r\n display: grid;\r\n grid-template-columns: 1fr auto 5px;\r\n align-items: center;\r\n\r\n .extensions {\r\n width: 20px;\r\n grid-column: 2;\r\n }\r\n }\r\n\r\n .title {\r\n grid-column: 1;\r\n background: transparent;\r\n white-space: nowrap;\r\n overflow: hidden;\r\n min-width: 0;\r\n margin-right: 5px;\r\n display: grid;\r\n align-items: center;\r\n grid-template-columns: 25px 1fr;\r\n height: 24px;\r\n cursor: pointer;\r\n\r\n .titleIcon {\r\n grid-column: 1;\r\n display: grid;\r\n align-items: center;\r\n justify-items: center;\r\n }\r\n\r\n .titleText {\r\n grid-column: 2;\r\n white-space: nowrap;\r\n text-overflow: ellipsis;\r\n overflow: hidden;\r\n }\r\n }\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},3883:(e,t,r)=>{"use strict";r.d(t,{Z:()=>i});var n=r(4864),o=r.n(n),s=r(7885),a=r.n(s)()(o());a.push([e.id,'.color-picker-container{width:320px;height:300px;background-color:#fff;display:grid;grid-template-columns:100%;grid-template-rows:50% 50px 60px 40px 1fr auto;font-family:"acumin-pro-condensed";font-weight:normal;font-size:14px}.color-picker-container.with-hints{height:380px}.color-picker-container .color-picker-saturation{grid-row:1;grid-column:1;display:grid;grid-template-columns:100%;grid-template-rows:100%;position:relative;cursor:pointer}.color-picker-container .color-picker-saturation .color-picker-saturation-white{grid-row:1;grid-column:1;background:-webkit-linear-gradient(to right, #fff, rgba(255, 255, 255, 0));background:linear-gradient(to right, #fff, rgba(255, 255, 255, 0))}.color-picker-container .color-picker-saturation .color-picker-saturation-black{grid-row:1;grid-column:1;background:-webkit-linear-gradient(to top, #000, rgba(0, 0, 0, 0));background:linear-gradient(to top, #000, rgba(0, 0, 0, 0))}.color-picker-container .color-picker-saturation .color-picker-saturation-cursor{pointer-events:none;width:4px;height:4px;box-shadow:0 0 0 1.5px #fff,inset 0 0 1px 1px rgba(0,0,0,.3),0 0 1px 2px rgba(0,0,0,.4);border-radius:50%;transform:translate(-2px, -2px);position:absolute}.color-picker-container .color-picker-hue{grid-row:2;grid-column:1;display:grid;margin:10px;grid-template-columns:24% 76%;grid-template-rows:100%}.color-picker-container .color-picker-hue .color-picker-hue-color{grid-row:1;grid-column:1;align-self:center;justify-self:center;width:30px;height:30px;border-radius:15px;border:1px solid #000}.color-picker-container .color-picker-hue .color-picker-hue-slider{grid-row:1;grid-column:2;align-self:center;height:16px;position:relative;cursor:pointer;background:linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);background:-webkit-linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%)}.color-picker-container .color-picker-hue .color-picker-hue-slider .color-picker-hue-cursor{pointer-events:none;width:8px;height:18px;transform:translate(-4px, -2px);background-color:#f8f8f8;box-shadow:0 1px 4px 0 rgba(0,0,0,.37);position:absolute}.color-picker-container .color-picker-component{display:grid;margin:5px;grid-template-columns:100%;grid-template-rows:50% 50%}.color-picker-container .color-picker-component .color-picker-component-value{justify-self:center;align-self:center;grid-row:1;grid-column:1;margin-bottom:4px}.color-picker-container .color-picker-component .color-picker-component-value input{width:50px}.color-picker-container .color-picker-component .color-picker-component-label{justify-self:center;align-self:center;grid-row:2;grid-column:1;color:#000}.color-picker-container .color-picker-rgb{grid-row:3;grid-column:1;display:grid;margin:10px;grid-template-columns:20% 6.66% 20% 6.66% 20% 6.66% 20%;grid-template-rows:100%}.color-picker-container .red{grid-row:1;grid-column:1}.color-picker-container .green{grid-row:1;grid-column:3}.color-picker-container .blue{grid-row:1;grid-column:5}.color-picker-container .alpha{grid-row:1;grid-column:7}.color-picker-container .alpha.grayed{opacity:.5}.color-picker-container .color-picker-hex{grid-row:4;grid-column:1;display:grid;grid-template-columns:20% 80%;grid-template-rows:100%}.color-picker-container .color-picker-hex .color-picker-hex-label{justify-self:center;align-self:center;grid-row:1;grid-column:1;margin-left:10px;color:#000}.color-picker-container .color-picker-hex .color-picker-hex-value{justify-self:left;align-self:center;grid-row:1;grid-column:2;margin-left:10px;margin-right:10px}.color-picker-container .color-picker-hex .color-picker-hex-value input{width:70px}.color-picker-container .color-picker-warning{color:#000;font-size:11px;padding:4px;justify-self:left;align-self:center;grid-row:6;grid-column:1}',"",{version:3,sources:["webpack://./../../../dev/sharedUiComponents/dist/colorPicker/colorPicker.scss"],names:[],mappings:"AAAA,wBACI,WAAA,CACA,YAAA,CACA,qBAAA,CACA,YAAA,CACA,0BAAA,CACA,8CAAA,CACA,kCAAA,CACA,kBAAA,CACA,cAAA,CAEA,mCACI,YAAA,CAGJ,iDACI,UAAA,CACA,aAAA,CACA,YAAA,CACA,0BAAA,CACA,uBAAA,CACA,iBAAA,CACA,cAAA,CAEA,gFACI,UAAA,CACA,aAAA,CAEA,0EAAA,CACA,kEAAA,CAGJ,gFACI,UAAA,CACA,aAAA,CAEA,kEAAA,CACA,0DAAA,CAGJ,iFACI,mBAAA,CACA,SAAA,CACA,UAAA,CACA,uFAAA,CACA,iBAAA,CACA,+BAAA,CACA,iBAAA,CAIR,0CACI,UAAA,CACA,aAAA,CACA,YAAA,CACA,WAAA,CACA,6BAAA,CACA,uBAAA,CAEA,kEACI,UAAA,CACA,aAAA,CACA,iBAAA,CACA,mBAAA,CACA,UAAA,CACA,WAAA,CACA,kBAAA,CACA,qBAAA,CAGJ,mEACI,UAAA,CACA,aAAA,CACA,iBAAA,CACA,WAAA,CACA,iBAAA,CACA,cAAA,CAEA,0GAAA,CACA,kHAAA,CAEA,4FACI,mBAAA,CACA,SAAA,CACA,WAAA,CACA,+BAAA,CACA,wBAAA,CACA,sCAAA,CACA,iBAAA,CAKZ,gDACI,YAAA,CACA,UAAA,CACA,0BAAA,CACA,0BAAA,CAEA,8EACI,mBAAA,CACA,iBAAA,CACA,UAAA,CACA,aAAA,CACA,iBAAA,CAEA,oFACI,UAAA,CAIR,8EACI,mBAAA,CACA,iBAAA,CACA,UAAA,CACA,aAAA,CACA,UAAA,CAIR,0CACI,UAAA,CACA,aAAA,CACA,YAAA,CACA,WAAA,CACA,uDAAA,CACA,uBAAA,CAGJ,6BACI,UAAA,CACA,aAAA,CAGJ,+BACI,UAAA,CACA,aAAA,CAGJ,8BACI,UAAA,CACA,aAAA,CAGJ,+BACI,UAAA,CACA,aAAA,CAEA,sCACI,UAAA,CAIR,0CACI,UAAA,CACA,aAAA,CACA,YAAA,CACA,6BAAA,CACA,uBAAA,CAEA,kEACI,mBAAA,CACA,iBAAA,CACA,UAAA,CACA,aAAA,CACA,gBAAA,CACA,UAAA,CAGJ,kEACI,iBAAA,CACA,iBAAA,CACA,UAAA,CACA,aAAA,CACA,gBAAA,CACA,iBAAA,CAEA,wEACI,UAAA,CAKZ,8CACI,UAAA,CACA,cAAA,CACA,WAAA,CACA,iBAAA,CACA,iBAAA,CACA,UAAA,CACA,aAAA",sourcesContent:['.color-picker-container {\r\n width: 320px;\r\n height: 300px;\r\n background-color: white;\r\n display: grid;\r\n grid-template-columns: 100%;\r\n grid-template-rows: 50% 50px 60px 40px 1fr auto;\r\n font-family: "acumin-pro-condensed";\r\n font-weight: normal;\r\n font-size: 14px;\r\n\r\n &.with-hints {\r\n height: 380px;\r\n }\r\n\r\n .color-picker-saturation {\r\n grid-row: 1;\r\n grid-column: 1;\r\n display: grid;\r\n grid-template-columns: 100%;\r\n grid-template-rows: 100%;\r\n position: relative;\r\n cursor: pointer;\r\n\r\n .color-picker-saturation-white {\r\n grid-row: 1;\r\n grid-column: 1;\r\n\r\n background: -webkit-linear-gradient(to right, #fff, rgba(255, 255, 255, 0));\r\n background: linear-gradient(to right, #fff, rgba(255, 255, 255, 0));\r\n }\r\n\r\n .color-picker-saturation-black {\r\n grid-row: 1;\r\n grid-column: 1;\r\n\r\n background: -webkit-linear-gradient(to top, #000, rgba(0, 0, 0, 0));\r\n background: linear-gradient(to top, #000, rgba(0, 0, 0, 0));\r\n }\r\n\r\n .color-picker-saturation-cursor {\r\n pointer-events: none;\r\n width: 4px;\r\n height: 4px;\r\n box-shadow: 0 0 0 1.5px #fff, inset 0 0 1px 1px rgba(0, 0, 0, 0.3), 0 0 1px 2px rgba(0, 0, 0, 0.4);\r\n border-radius: 50%;\r\n transform: translate(-2px, -2px);\r\n position: absolute;\r\n }\r\n }\r\n\r\n .color-picker-hue {\r\n grid-row: 2;\r\n grid-column: 1;\r\n display: grid;\r\n margin: 10px;\r\n grid-template-columns: 24% 76%;\r\n grid-template-rows: 100%;\r\n\r\n .color-picker-hue-color {\r\n grid-row: 1;\r\n grid-column: 1;\r\n align-self: center;\r\n justify-self: center;\r\n width: 30px;\r\n height: 30px;\r\n border-radius: 15px;\r\n border: 1px solid black;\r\n }\r\n\r\n .color-picker-hue-slider {\r\n grid-row: 1;\r\n grid-column: 2;\r\n align-self: center;\r\n height: 16px;\r\n position: relative;\r\n cursor: pointer;\r\n\r\n background: linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);\r\n background: -webkit-linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%);\r\n\r\n .color-picker-hue-cursor {\r\n pointer-events: none;\r\n width: 8px;\r\n height: 18px;\r\n transform: translate(-4px, -2px);\r\n background-color: rgb(248, 248, 248);\r\n box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.37);\r\n position: absolute;\r\n }\r\n }\r\n }\r\n\r\n .color-picker-component {\r\n display: grid;\r\n margin: 5px;\r\n grid-template-columns: 100%;\r\n grid-template-rows: 50% 50%;\r\n\r\n .color-picker-component-value {\r\n justify-self: center;\r\n align-self: center;\r\n grid-row: 1;\r\n grid-column: 1;\r\n margin-bottom: 4px;\r\n\r\n input {\r\n width: 50px;\r\n }\r\n }\r\n\r\n .color-picker-component-label {\r\n justify-self: center;\r\n align-self: center;\r\n grid-row: 2;\r\n grid-column: 1;\r\n color: black;\r\n }\r\n }\r\n\r\n .color-picker-rgb {\r\n grid-row: 3;\r\n grid-column: 1;\r\n display: grid;\r\n margin: 10px;\r\n grid-template-columns: 20% 6.66% 20% 6.66% 20% 6.66% 20%;\r\n grid-template-rows: 100%;\r\n }\r\n\r\n .red {\r\n grid-row: 1;\r\n grid-column: 1;\r\n }\r\n\r\n .green {\r\n grid-row: 1;\r\n grid-column: 3;\r\n }\r\n\r\n .blue {\r\n grid-row: 1;\r\n grid-column: 5;\r\n }\r\n\r\n .alpha {\r\n grid-row: 1;\r\n grid-column: 7;\r\n\r\n &.grayed {\r\n opacity: 0.5;\r\n }\r\n }\r\n\r\n .color-picker-hex {\r\n grid-row: 4;\r\n grid-column: 1;\r\n display: grid;\r\n grid-template-columns: 20% 80%;\r\n grid-template-rows: 100%;\r\n\r\n .color-picker-hex-label {\r\n justify-self: center;\r\n align-self: center;\r\n grid-row: 1;\r\n grid-column: 1;\r\n margin-left: 10px;\r\n color: black;\r\n }\r\n\r\n .color-picker-hex-value {\r\n justify-self: left;\r\n align-self: center;\r\n grid-row: 1;\r\n grid-column: 2;\r\n margin-left: 10px;\r\n margin-right: 10px;\r\n\r\n input {\r\n width: 70px;\r\n }\r\n }\r\n }\r\n\r\n .color-picker-warning {\r\n color: black;\r\n font-size: 11px;\r\n padding: 4px;\r\n justify-self: left;\r\n align-self: center;\r\n grid-row: 6;\r\n grid-column: 1;\r\n }\r\n}\r\n'],sourceRoot:""}]),a.locals={};const i=a},2387:(e,t)=>{var r;!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t{"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var r="",n=void 0!==t[5];return t[4]&&(r+="@supports (".concat(t[4],") {")),t[2]&&(r+="@media ".concat(t[2]," {")),n&&(r+="@layer".concat(t[5].length>0?" ".concat(t[5]):""," {")),r+=e(t),n&&(r+="}"),t[2]&&(r+="}"),t[4]&&(r+="}"),r})).join("")},t.i=function(e,r,n,o,s){"string"==typeof e&&(e=[[null,e,void 0]]);var a={};if(n)for(var i=0;i0?" ".concat(c[5]):""," {").concat(c[1],"}")),c[5]=s),r&&(c[2]?(c[1]="@media ".concat(c[2]," {").concat(c[1],"}"),c[2]=r):c[2]=r),o&&(c[4]?(c[1]="@supports (".concat(c[4],") {").concat(c[1],"}"),c[4]=o):c[4]="".concat(o)),t.push(c))}},t}},287:e=>{"use strict";e.exports=function(e,t){return t||(t={}),e?(e=String(e.__esModule?e.default:e),/^['"].*['"]$/.test(e)&&(e=e.slice(1,-1)),t.hash&&(e+=t.hash),/["'() \t\n]|(%20)/.test(e)||t.needQuotes?'"'.concat(e.replace(/"/g,'\\"').replace(/\n/g,"\\n"),'"'):e):e}},4864:e=>{"use strict";e.exports=function(e){var t=e[1],r=e[3];if(!r)return t;if("function"==typeof btoa){var n=btoa(unescape(encodeURIComponent(JSON.stringify(r)))),o="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(n),s="/*# ".concat(o," */");return[t].concat([s]).join("\n")}return[t].join("\n")}},6696:function(e){e.exports=function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}([function(e,t,r){var n,o,s={}.hasOwnProperty,a=[].indexOf||function(e){for(var t=0,r=this.length;t0&&r.data&&(this.groups.has(r.data)?this.groups.get(r.data).push(o):this.groups.set(r.data,[o])),this.frames.push(r)},t.prototype.render=function(){var e,t,r;if(this.running)throw new Error("Already running");if(null==this.options.width||null==this.options.height)throw new Error("Width and height must be set prior to rendering");if(this.running=!0,this.nextFrame=0,this.finishedFrames=0,this.imageParts=function(){var e,t,r;for(r=[],e=0,t=this.frames.length;0<=t?et;0<=t?++e:--e)r.push(null);return r}.call(this),t=this.spawnWorkers(),!0===this.options.globalPalette)this.renderNextFrame();else for(e=0,r=t;0<=r?er;0<=r?++e:--e)this.renderNextFrame();return this.emit("start"),this.emit("progress",0)},t.prototype.abort=function(){for(var e;null!=(e=this.activeWorkers.shift());)this.log("killing active worker"),e.terminate();return this.running=!1,this.emit("abort")},t.prototype.spawnWorkers=function(){var e,t,r;return e=Math.min(this.options.workers,this.frames.length),function(){r=[];for(var n=t=this.freeWorkers.length;t<=e?ne;t<=e?n++:n--)r.push(n);return r}.apply(this).forEach(function(e){return function(t){var r;return e.log("spawning worker "+t),(r=new Worker(e.options.workerScript)).onmessage=function(t){return e.activeWorkers.splice(e.activeWorkers.indexOf(r),1),e.freeWorkers.push(r),e.frameFinished(t.data,!1)},e.freeWorkers.push(r)}}(this)),e},t.prototype.frameFinished=function(e,t){var r,n,o,s;if(this.finishedFrames++,t?(r=this.frames.indexOf(e),n=this.groups.get(e.data)[0],this.log("frame "+(r+1)+" is duplicate of "+n+" - "+this.activeWorkers.length+" active"),this.imageParts[r]={indexOfFirstInGroup:n}):(this.log("frame "+(e.index+1)+" finished - "+this.activeWorkers.length+" active"),this.emit("progress",this.finishedFrames/this.frames.length),this.imageParts[e.index]=e),!0===this.options.globalPalette&&!t&&(this.options.globalPalette=e.globalPalette,this.log("global palette analyzed"),this.frames.length>2))for(o=1,s=this.freeWorkers.length;1<=s?os;1<=s?++o:--o)this.renderNextFrame();return a.call(this.imageParts,null)>=0?this.renderNextFrame():this.finishRendering()},t.prototype.finishRendering=function(){var e,t,r,n,o,s,a,i,l,p,c,d,h,u,b,g,m,A,C,f;for(o=s=0,p=(m=this.imageParts).length;s=this.frames.length))return e=this.frames[this.nextFrame++],(t=this.frames.indexOf(e))>0&&this.groups.has(e.data)&&this.groups.get(e.data)[0]!==t?void setTimeout(function(t){return function(){return t.frameFinished(e,!0)}}(this),0):(n=this.freeWorkers.shift(),r=this.getTask(e),this.log("starting frame "+(r.index+1)+" of "+this.frames.length),this.activeWorkers.push(n),n.postMessage(r))},t.prototype.getContextData=function(e){return e.getImageData(0,0,this.options.width,this.options.height).data},t.prototype.getImageData=function(e){var t;return null==this._canvas&&(this._canvas=document.createElement("canvas"),this._canvas.width=this.options.width,this._canvas.height=this.options.height),(t=this._canvas.getContext("2d")).setFill=this.options.background,t.fillRect(0,0,this.options.width,this.options.height),t.drawImage(e,0,0),this.getContextData(t)},t.prototype.getTask=function(e){var t,r;if(r={index:t=this.frames.indexOf(e),last:t===this.frames.length-1,delay:e.delay,transparent:e.transparent,width:this.options.width,height:this.options.height,quality:this.options.quality,dither:this.options.dither,globalPalette:this.options.globalPalette,repeat:this.options.repeat,canTransfer:!0},null!=e.data)r.data=e.data;else if(null!=e.context)r.data=this.getContextData(e.context);else{if(null==e.image)throw new Error("Invalid frame");r.data=this.getImageData(e.image)}return r},t.prototype.log=function(e){if(this.options.debug)return console.log(e)},t}(n),e.exports=o},function(e,t){function r(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function n(e){return"function"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}e.exports=r,r.EventEmitter=r,r.prototype._events=void 0,r.prototype._maxListeners=void 0,r.defaultMaxListeners=10,r.prototype.setMaxListeners=function(e){if(!function(e){return"number"==typeof e}(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},r.prototype.emit=function(e){var t,r,a,i,l,p;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length)){if((t=arguments[1])instanceof Error)throw t;var c=new Error('Uncaught, unspecified "error" event. ('+t+")");throw c.context=t,c}if(s(r=this._events[e]))return!1;if(n(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:i=Array.prototype.slice.call(arguments,1),r.apply(this,i)}else if(o(r))for(i=Array.prototype.slice.call(arguments,1),a=(p=r.slice()).length,l=0;l0&&this._events[e].length>a&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace()),this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){function r(){this.removeListener(e,r),o||(o=!0,t.apply(this,arguments))}if(!n(t))throw TypeError("listener must be a function");var o=!1;return r.listener=t,this.on(e,r),this},r.prototype.removeListener=function(e,t){var r,s,a,i;if(!n(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(a=(r=this._events[e]).length,s=-1,r===t||n(r.listener)&&r.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(r)){for(i=a;i-- >0;)if(r[i]===t||r[i].listener&&r[i].listener===t){s=i;break}if(s<0)return this;1===r.length?(r.length=0,delete this._events[e]):r.splice(s,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},r.prototype.removeAllListeners=function(e){var t,r;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n(r=this._events[e]))this.removeListener(e,r);else if(r)for(;r.length;)this.removeListener(e,r[r.length-1]);return delete this._events[e],this},r.prototype.listeners=function(e){return this._events&&this._events[e]?n(this._events[e])?[this._events[e]]:this._events[e].slice():[]},r.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(n(t))return 1;if(t)return t.length}return 0},r.listenerCount=function(e,t){return e.listenerCount(t)}},function(e,t){var r,n,o,s,a;a=navigator.userAgent.toLowerCase(),s=navigator.platform.toLowerCase(),o="ie"===(r=a.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/)||[null,"unknown",0])[1]&&document.documentMode,(n={name:"version"===r[1]?r[3]:r[1],version:o||parseFloat("opera"===r[1]&&r[4]?r[4]:r[2]),platform:{name:a.match(/ip(?:ad|od|hone)/)?"ios":(a.match(/(?:webos|android)/)||s.match(/mac|win|linux/)||["other"])[0]}})[n.name]=!0,n[n.name+parseInt(n.version,10)]=!0,n.platform[n.platform.name]=!0,e.exports=n}])},7030:e=>{"use strict";var t=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;e.exports=function(){try{if(!Object.assign)return!1;var e=new String("abc");if(e[5]="de","5"===Object.getOwnPropertyNames(e)[0])return!1;for(var t={},r=0;r<10;r++)t["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(t).map((function(e){return t[e]})).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e})),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(e){return!1}}()?Object.assign:function(e,o){for(var s,a,i=function(e){if(null==e)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(e)}(e),l=1;l{"use strict";var n=r(9117);function o(){}function s(){}s.resetWarningCache=o,e.exports=function(){function e(e,t,r,o,s,a){if(a!==n){var i=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw i.name="Invariant Violation",i}}function t(){return e}e.isRequired=e;var r={array:e,bigint:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:s,resetWarningCache:o};return r.PropTypes=r,r}},2866:(e,t,r)=>{e.exports=r(2656)()},9117:e=>{"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},4990:(e,t,r)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var r=l(t);if(r&&r.has(e))return r.get(e);var o={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var i=s?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(o,a,i):o[a]=e[a]}return o.default=e,r&&r.set(e,o),o}(r(9700)),s=i(r(2866)),a=i(r(2889));function i(e){return e&&e.__esModule?e:{default:e}}function l(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(l=function(e){return e?r:t})(e)}function p(e,t){return p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},p(e,t)}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function d(e){return d=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},d(e)}function h(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var u=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}(l,e);var t,r,s,i=(r=l,s=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=d(r);if(s){var o=d(this).constructor;e=Reflect.construct(t,arguments,o)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return c(e)}(this,e)});function l(e){var t;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,l),h(c(t=i.call(this,e)),"handleKeyNavigation",(function(e){if(!1!==t.state.isVisible)switch(e.keyCode){case 37:case 27:e.preventDefault(),t.hideMenu(e);break;case 38:e.preventDefault(),t.selectChildren(!0);break;case 40:e.preventDefault(),t.selectChildren(!1);break;case 39:t.tryToOpenSubMenu(e);break;case 13:e.preventDefault(),t.tryToOpenSubMenu(e);var r=t.seletedItemRef&&t.seletedItemRef.props&&t.seletedItemRef.props.disabled;t.seletedItemRef&&t.seletedItemRef.ref instanceof HTMLElement&&!r?t.seletedItemRef.ref.click():t.hideMenu(e)}})),h(c(t),"handleForceClose",(function(){t.setState({forceSubMenuOpen:!1})})),h(c(t),"tryToOpenSubMenu",(function(e){t.state.selectedItem&&t.state.selectedItem.type===t.getSubMenuType()&&(e.preventDefault(),t.setState({forceSubMenuOpen:!0}))})),h(c(t),"selectChildren",(function(e){var r=t.state.selectedItem,n=[],s=0,i={};if(o.default.Children.forEach(t.props.children,(function e(r,l){r&&([a.default,t.getSubMenuType()].indexOf(r.type)<0?o.default.Children.forEach(r.props.children,e):r.props.divider||(r.props.disabled&&(++s,i[l]=!0),n.push(r)))})),s!==n.length){var l=function(t){var r=t;do{e?--r:++r,r<0?r=n.length-1:r>=n.length&&(r=0)}while(r!==t&&i[r]);return r===t?null:r}(n.indexOf(r));null!==l&&t.setState({selectedItem:n[l],forceSubMenuOpen:!1})}})),h(c(t),"onChildMouseMove",(function(e){t.state.selectedItem!==e&&t.setState({selectedItem:e,forceSubMenuOpen:!1})})),h(c(t),"onChildMouseLeave",(function(){t.setState({selectedItem:null,forceSubMenuOpen:!1})})),h(c(t),"renderChildren",(function(e){return o.default.Children.map(e,(function(e){var r={};return o.default.isValidElement(e)?[a.default,t.getSubMenuType()].indexOf(e.type)<0?(r.children=t.renderChildren(e.props.children),o.default.cloneElement(e,r)):(r.onMouseLeave=t.onChildMouseLeave.bind(c(t)),e.type===t.getSubMenuType()&&(r.forceOpen=t.state.forceSubMenuOpen&&t.state.selectedItem===e,r.forceClose=t.handleForceClose,r.parentKeyNavigationHandler=t.handleKeyNavigation),e.props.divider||t.state.selectedItem!==e?(r.onMouseMove=function(){return t.onChildMouseMove(e)},o.default.cloneElement(e,r)):(r.selected=!0,r.ref=function(e){t.seletedItemRef=e},o.default.cloneElement(e,r))):e}))})),t.seletedItemRef=null,t.state={selectedItem:null,forceSubMenuOpen:!1},t}return t=l,Object.defineProperty(t,"prototype",{writable:!1}),t}(o.Component);t.default=u,h(u,"propTypes",{children:s.default.node.isRequired})},1861:(e,t,r)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=u(r(9700)),s=u(r(2866)),a=u(r(2387)),i=u(r(7030)),l=u(r(1663)),p=u(r(4990)),c=u(r(841)),d=r(4330),h=r(5843);function u(e){return e&&e.__esModule?e:{default:e}}function b(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n={top:r,left:e};if(!t.menu)return n;var o=window,s=o.innerWidth,a=o.innerHeight,i=t.menu.getBoundingClientRect();return r+i.height>a&&(n.top-=i.height),e+i.width>s&&(n.left-=i.width),n.top<0&&(n.top=i.height0&&void 0!==arguments[0]?arguments[0]:0,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n={top:r,left:e};if(!t.menu)return n;var o=window,s=o.innerWidth,a=o.innerHeight,i=t.menu.getBoundingClientRect();return n.left=e-i.width,r+i.height>a&&(n.top-=i.height),n.left<0&&(n.left+=i.width),n.top<0&&(n.top=i.heights&&(n.left=i.width{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var r=d(t);if(r&&r.has(e))return r.get(e);var o={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var i=s?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(o,a,i):o[a]=e[a]}return o.default=e,r&&r.set(e,o),o}(r(9700)),s=c(r(2866)),a=c(r(2387)),i=c(r(7030)),l=r(4330),p=r(5843);function c(e){return e&&e.__esModule?e:{default:e}}function d(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(d=function(e){return e?r:t})(e)}function h(e,t){for(var r=0;r=0&&0===t.button&&(t.persist(),t.stopPropagation(),e.mouseDownTimeoutId=setTimeout((function(){return e.handleContextClick(t)}),e.props.holdToDisplay)),(0,p.callIfExists)(e.props.attributes.onMouseDown,t)})),m(b(e),"handleMouseUp",(function(t){0===t.button&&clearTimeout(e.mouseDownTimeoutId),(0,p.callIfExists)(e.props.attributes.onMouseUp,t)})),m(b(e),"handleMouseOut",(function(t){0===t.button&&clearTimeout(e.mouseDownTimeoutId),(0,p.callIfExists)(e.props.attributes.onMouseOut,t)})),m(b(e),"handleTouchstart",(function(t){e.touchHandled=!1,e.props.holdToDisplay>=0&&(t.persist(),t.stopPropagation(),e.touchstartTimeoutId=setTimeout((function(){e.handleContextClick(t),e.touchHandled=!0}),e.props.holdToDisplay)),(0,p.callIfExists)(e.props.attributes.onTouchStart,t)})),m(b(e),"handleTouchEnd",(function(t){e.touchHandled&&t.preventDefault(),clearTimeout(e.touchstartTimeoutId),(0,p.callIfExists)(e.props.attributes.onTouchEnd,t)})),m(b(e),"handleContextMenu",(function(t){t.button===e.props.mouseButton&&e.handleContextClick(t),(0,p.callIfExists)(e.props.attributes.onContextMenu,t)})),m(b(e),"handleMouseClick",(function(t){t.button===e.props.mouseButton&&e.handleContextClick(t),(0,p.callIfExists)(e.props.attributes.onClick,t)})),m(b(e),"handleContextClick",(function(t){if(!(e.props.disable||e.props.disableIfShiftIsPressed&&t.shiftKey)){t.preventDefault(),t.stopPropagation();var r=t.clientX||t.touches&&t.touches[0].pageX,n=t.clientY||t.touches&&t.touches[0].pageY;e.props.posX&&(r-=e.props.posX),e.props.posY&&(n-=e.props.posY),(0,l.hideMenu)();var o=(0,p.callIfExists)(e.props.collect,e.props),s={position:{x:r,y:n},target:e.elem,id:e.props.id};o&&"function"==typeof o.then?o.then((function(e){s.data=(0,i.default)({},e,{target:t.target}),(0,l.showMenu)(s)})):(s.data=(0,i.default)({},o,{target:t.target}),(0,l.showMenu)(s))}})),m(b(e),"elemRef",(function(t){e.elem=t})),e}return t=A,(r=[{key:"render",value:function(){var e=this.props,t=e.renderTag,r=e.attributes,n=e.children,s=(0,i.default)({},r,{className:(0,a.default)(p.cssClasses.menuWrapper,r.className),onContextMenu:this.handleContextMenu,onClick:this.handleMouseClick,onMouseDown:this.handleMouseDown,onMouseUp:this.handleMouseUp,onTouchStart:this.handleTouchstart,onTouchEnd:this.handleTouchEnd,onMouseOut:this.handleMouseOut,ref:this.elemRef});return o.default.createElement(t,s,n)}}])&&h(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),A}(o.Component);t.default=A,m(A,"propTypes",{id:s.default.string.isRequired,children:s.default.node.isRequired,attributes:s.default.object,collect:s.default.func,disable:s.default.bool,holdToDisplay:s.default.number,posX:s.default.number,posY:s.default.number,renderTag:s.default.elementType,mouseButton:s.default.number,disableIfShiftIsPressed:s.default.bool}),m(A,"defaultProps",{attributes:{},collect:function(){return null},disable:!1,holdToDisplay:1e3,renderTag:"div",posX:0,posY:0,mouseButton:2,disableIfShiftIsPressed:!1})},2889:(e,t,r)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var r=d(t);if(r&&r.has(e))return r.get(e);var o={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var i=s?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(o,a,i):o[a]=e[a]}return o.default=e,r&&r.set(e,o),o}(r(9700)),s=c(r(2866)),a=c(r(2387)),i=c(r(7030)),l=r(4330),p=r(5843);function c(e){return e&&e.__esModule?e:{default:e}}function d(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(d=function(e){return e?r:t})(e)}function h(){return h=Object.assign||function(e){for(var t=1;t{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=h(r(9700)),s=h(r(2866)),a=h(r(2387)),i=h(r(7030)),l=r(4330),p=h(r(4990)),c=r(5843),d=h(r(1663));function h(e){return e&&e.__esModule?e:{default:e}}function u(){return u=Object.assign||function(e){for(var t=1;tn?s.bottom=0:s.top=0,o.righte?n.bottom=0:n.top=0,r.left<0?n.left="100%":n.right="100%",n})),C(m(t),"hideMenu",(function(e){e.preventDefault(),t.hideSubMenu(e)})),C(m(t),"hideSubMenu",(function(e){e.detail&&e.detail.id&&t.menu&&e.detail.id!==t.menu.id||(t.props.forceOpen&&t.props.forceClose(),t.setState({visible:!1,selectedItem:null}),t.unregisterHandlers())})),C(m(t),"handleClick",(function(e){e.preventDefault(),t.props.disabled||((0,c.callIfExists)(t.props.onClick,e,(0,i.default)({},t.props.data,c.store.data),c.store.target),t.props.onClick&&!t.props.preventCloseOnClick&&(0,l.hideMenu)())})),C(m(t),"handleMouseEnter",(function(){t.closetimer&&clearTimeout(t.closetimer),t.props.disabled||t.state.visible||(t.opentimer=setTimeout((function(){return t.setState({visible:!0,selectedItem:null})}),t.props.hoverDelay))})),C(m(t),"handleMouseLeave",(function(){t.opentimer&&clearTimeout(t.opentimer),t.state.visible&&(t.closetimer=setTimeout((function(){return t.setState({visible:!1,selectedItem:null})}),t.props.hoverDelay))})),C(m(t),"menuRef",(function(e){t.menu=e})),C(m(t),"subMenuRef",(function(e){t.subMenu=e})),C(m(t),"registerHandlers",(function(){document.removeEventListener("keydown",t.props.parentKeyNavigationHandler),document.addEventListener("keydown",t.handleKeyNavigation)})),C(m(t),"unregisterHandlers",(function(e){document.removeEventListener("keydown",t.handleKeyNavigation),e||document.addEventListener("keydown",t.props.parentKeyNavigationHandler)})),t.state=(0,i.default)({},t.state,{visible:!1}),t}return t=f,(r=[{key:"componentDidMount",value:function(){this.listenId=d.default.register((function(){}),this.hideSubMenu)}},{key:"getSubMenuType",value:function(){return f}},{key:"shouldComponentUpdate",value:function(e,t){return this.isVisibilityChange=!(this.state.visible===t.visible&&this.props.forceOpen===e.forceOpen||this.state.visible&&e.forceOpen||this.props.forceOpen&&t.visible),!0}},{key:"componentDidUpdate",value:function(){var e=this;this.isVisibilityChange&&(this.props.forceOpen||this.state.visible?(window.requestAnimationFrame||setTimeout)((function(){var t=e.props.rtl?e.getRTLMenuPosition():e.getMenuPosition();e.subMenu.style.removeProperty("top"),e.subMenu.style.removeProperty("bottom"),e.subMenu.style.removeProperty("left"),e.subMenu.style.removeProperty("right"),(0,c.hasOwnProp)(t,"top")&&(e.subMenu.style.top=t.top),(0,c.hasOwnProp)(t,"left")&&(e.subMenu.style.left=t.left),(0,c.hasOwnProp)(t,"bottom")&&(e.subMenu.style.bottom=t.bottom),(0,c.hasOwnProp)(t,"right")&&(e.subMenu.style.right=t.right),e.subMenu.classList.add(c.cssClasses.menuVisible),e.registerHandlers(),e.setState({selectedItem:null})})):(this.subMenu.addEventListener("transitionend",(function t(){e.subMenu.removeEventListener("transitionend",t),e.subMenu.style.removeProperty("bottom"),e.subMenu.style.removeProperty("right"),e.subMenu.style.top=0,e.subMenu.style.left="100%",e.unregisterHandlers()})),this.subMenu.classList.remove(c.cssClasses.menuVisible)))}},{key:"componentWillUnmount",value:function(){this.listenId&&d.default.unregister(this.listenId),this.opentimer&&clearTimeout(this.opentimer),this.closetimer&&clearTimeout(this.closetimer),this.unregisterHandlers(!0)}},{key:"render",value:function(){var e,t=this.props,r=t.children,n=t.attributes,s=t.disabled,i=t.title,l=t.selected,p=this.state.visible,d={ref:this.menuRef,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,className:(0,a.default)(c.cssClasses.menuItem,c.cssClasses.subMenu,n.listClassName),style:{position:"relative"}},h={className:(0,a.default)(c.cssClasses.menuItem,n.className,(e={},C(e,(0,a.default)(c.cssClasses.menuItemDisabled,n.disabledClassName),s),C(e,(0,a.default)(c.cssClasses.menuItemActive,n.visibleClassName),p),C(e,(0,a.default)(c.cssClasses.menuItemSelected,n.selectedClassName),l),e)),onMouseMove:this.props.onMouseMove,onMouseOut:this.props.onMouseOut,onClick:this.handleClick},b={ref:this.subMenuRef,style:{position:"absolute",transition:"opacity 1ms",top:0,left:"100%"},className:(0,a.default)(c.cssClasses.menu,this.props.className)};return o.default.createElement("nav",u({},d,{role:"menuitem",tabIndex:"-1","aria-haspopup":"true"}),o.default.createElement("div",u({},n,h),i),o.default.createElement("nav",u({},b,{role:"menu",tabIndex:"-1"}),this.renderChildren(r)))}}])&&b(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),f}(p.default);t.default=f,C(f,"propTypes",{children:s.default.node.isRequired,attributes:s.default.object,title:s.default.node.isRequired,className:s.default.string,disabled:s.default.bool,hoverDelay:s.default.number,rtl:s.default.bool,selected:s.default.bool,onMouseMove:s.default.func,onMouseOut:s.default.func,forceOpen:s.default.bool,forceClose:s.default.func,parentKeyNavigationHandler:s.default.func}),C(f,"defaultProps",{disabled:!1,hoverDelay:500,attributes:{},className:"",rtl:!1,selected:!1,onMouseMove:function(){return null},onMouseOut:function(){return null},forceOpen:!1,forceClose:function(){return null},parentKeyNavigationHandler:function(){return null}})},4330:(e,t,r)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MENU_SHOW=t.MENU_HIDE=void 0,t.dispatchGlobalEvent=l,t.hideMenu=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;l(i,(0,o.default)({},e,{type:i}),t)},t.showMenu=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1?arguments[1]:void 0;l(a,(0,o.default)({},e,{type:a}),t)};var n,o=(n=r(7030))&&n.__esModule?n:{default:n},s=r(5843),a="REACT_CONTEXTMENU_SHOW";t.MENU_SHOW=a;var i="REACT_CONTEXTMENU_HIDE";function l(e,t){var r,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:window;"function"==typeof window.CustomEvent?r=new window.CustomEvent(e,{detail:t}):(r=document.createEvent("CustomEvent")).initCustomEvent(e,!1,!0,t),n&&(n.dispatchEvent(r),(0,o.default)(s.store,t))}t.MENU_HIDE=i},2455:(e,t,r)=>{"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(t){return function(r){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&d(e,t)}(C,r);var s,i,l,g,m=(s=C,i=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}(),function(){var e,t=u(s);if(i){var r=u(this).constructor;e=Reflect.construct(t,arguments,r)}else e=t.apply(this,arguments);return function(e,t){if(t&&("object"===n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return h(e)}(this,e)});function C(t){var r;return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,C),b(h(r=m.call(this,t)),"handleShow",(function(t){if(t.detail.id===e){var n=t.detail.data,o={};for(var s in n)A.includes(s)||(o[s]=n[s]);r.setState({trigger:o})}})),b(h(r),"handleHide",(function(){r.setState({trigger:null})})),r.state={trigger:null},r}return l=C,(g=[{key:"componentDidMount",value:function(){this.listenId=a.default.register(this.handleShow,this.handleHide)}},{key:"componentWillUnmount",value:function(){this.listenId&&a.default.unregister(this.listenId)}},{key:"render",value:function(){return o.default.createElement(t,p({},this.props,{id:e,trigger:this.state.trigger}))}}])&&c(l.prototype,g),Object.defineProperty(l,"prototype",{writable:!1}),C}(o.Component)}};var o=function(e,t){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var r=l(t);if(r&&r.has(e))return r.get(e);var o={},s=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if("default"!==a&&Object.prototype.hasOwnProperty.call(e,a)){var i=s?Object.getOwnPropertyDescriptor(e,a):null;i&&(i.get||i.set)?Object.defineProperty(o,a,i):o[a]=e[a]}return o.default=e,r&&r.set(e,o),o}(r(9700)),s=i(r(9436)),a=i(r(1663));function i(e){return e&&e.__esModule?e:{default:e}}function l(e){if("function"!=typeof WeakMap)return null;var t=new WeakMap,r=new WeakMap;return(l=function(e){return e?r:t})(e)}function p(){return p=Object.assign||function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=r(4330),o=r(5843);function s(e,t){for(var r=0;r{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.callIfExists=function(e){for(var t=arguments.length,r=new Array(t>1?t-1:0),n=1;n{"use strict";Object.defineProperty(t,"xV",{enumerable:!0,get:function(){return n.default}}),Object.defineProperty(t,"W4",{enumerable:!0,get:function(){return o.default}}),Object.defineProperty(t,"sN",{enumerable:!0,get:function(){return s.default}});var n=a(r(1861)),o=a(r(9436)),s=a(r(2889));a(r(841)),a(r(2455)),r(4330);function a(e){return e&&e.__esModule?e:{default:e}}},3340:(e,t,r)=>{"use strict";var n=r(9700),o=r(7030),s=r(5945);function a(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,r=1;r