babylonjs-loaders 6.21.0 → 6.21.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -95,12 +95,7 @@ var STLFileLoader = /** @class */ (function () {
95
95
  }
96
96
  // ASCII .stl
97
97
  // convert to string
98
- var array_buffer = new Uint8Array(data);
99
- var str = "";
100
- for (var i = 0; i < data.byteLength; i++) {
101
- str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian
102
- }
103
- data = str;
98
+ data = new TextDecoder().decode(new Uint8Array(data));
104
99
  }
105
100
  //if arrived here, data is a string, containing the STLA data.
106
101
  while ((matches = this.solidPattern.exec(data))) {
@@ -1 +1 @@
1
- {"version":3,"file":"babylon.stlFileLoader.js","mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;;;;;;;;;;;;;;;ACVgC;;;;;;;;;;;;;;;;;ACEQ;AACW;AAEX;AAEe;AACF;AAGrD;;;GAGG;AACI;IAAP;QACI,gBAAgB;QACT,iBAAY,GAAG,yCAAyC,CAAC;QAEhE,gBAAgB;QACT,kBAAa,GAAG,0BAA0B,CAAC;QAClD,gBAAgB;QACT,kBAAa,GAAG,mJAAmJ,CAAC;QAC3K,gBAAgB;QACT,kBAAa,GAAG,mJAAmJ,CAAC;QAE3K;;WAEG;QACI,SAAI,GAAG,KAAK,CAAC;QAEpB;;;;WAIG;QACI,eAAU,GAAiC;YAC9C,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC7B,CAAC;IAkPN,CAAC;IAzOG;;;;;;;;OAQG;IACI,kCAAU,GAAjB,UAAkB,WAAgB,EAAE,KAAY,EAAE,IAAS,EAAE,OAAe,EAAE,MAAgC;QAC1G,IAAI,OAAO,CAAC;QAEZ,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC1B,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;gBACtB,cAAc;gBAC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IAAI,CAAO,YAAa,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YAC7B,YAAa,CAAC,OAAO,CAAC,GAAG,CAAC,GAAS,8CAAQ,CAAC,GAAG,CAAC,CAAC;SAC1D;KACJ;CACJ;AAEiC;;;;;;;;;;;AChBlC;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;;WCtBA;WACA;WACA;WACA;WACA;WACA,iCAAiC,WAAW;WAC5C;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;WACA;WACA;WACA;WACA,GAAG;WACH;WACA;WACA,CAAC;;;;;WCPD;;;;;WCAA;WACA;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;;;;;;ACNoE;AACjD;AACnB,iEAAe,qEAAO,EAAC","sources":["webpack://LOADERS/webpack/universalModuleDefinition","webpack://LOADERS/../../../dev/loaders/src/STL/index.ts","webpack://LOADERS/../../../dev/loaders/src/STL/stlFileLoader.ts","webpack://LOADERS/../../../lts/loaders/src/legacy/legacy-stlFileLoader.ts","webpack://LOADERS/external umd {\"root\":\"BABYLON\",\"commonjs\":\"babylonjs\",\"commonjs2\":\"babylonjs\",\"amd\":\"babylonjs\"}","webpack://LOADERS/webpack/bootstrap","webpack://LOADERS/webpack/runtime/compat get default export","webpack://LOADERS/webpack/runtime/define property getters","webpack://LOADERS/webpack/runtime/global","webpack://LOADERS/webpack/runtime/hasOwnProperty shorthand","webpack://LOADERS/webpack/runtime/make namespace object","webpack://LOADERS/./src/stlFileLoader.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"babylonjs\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"babylonjs-loaders\", [\"babylonjs\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"babylonjs-loaders\"] = factory(require(\"babylonjs\"));\n\telse\n\t\troot[\"LOADERS\"] = factory(root[\"BABYLON\"]);\n})((typeof self !== \"undefined\" ? self : typeof global !== \"undefined\" ? global : this), (__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__) => {\nreturn ","export * from \"./stlFileLoader\";\r\n","/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"core/types\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport type { ISceneLoaderPlugin, ISceneLoaderPluginExtensions } from \"core/Loading/sceneLoader\";\r\nimport { SceneLoader } from \"core/Loading/sceneLoader\";\r\nimport { AssetContainer } from \"core/assetContainer\";\r\nimport type { Scene } from \"core/scene\";\r\n\r\n/**\r\n * STL file type loader.\r\n * This is a babylon scene loader plugin.\r\n */\r\nexport class STLFileLoader implements ISceneLoaderPlugin {\r\n /** @internal */\r\n public solidPattern = /solid (\\S*)([\\S\\s]*?)endsolid[ ]*(\\S*)/g;\r\n\r\n /** @internal */\r\n public facetsPattern = /facet([\\s\\S]*?)endfacet/g;\r\n /** @internal */\r\n public normalPattern = /normal[\\s]+([-+]?[0-9]+\\.?[0-9]*([eE][-+]?[0-9]+)?)+[\\s]+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)+[\\s]+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)+/g;\r\n /** @internal */\r\n public vertexPattern = /vertex[\\s]+([-+]?[0-9]+\\.?[0-9]*([eE][-+]?[0-9]+)?)+[\\s]+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)+[\\s]+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)+/g;\r\n\r\n /**\r\n * Defines the name of the plugin.\r\n */\r\n public name = \"stl\";\r\n\r\n /**\r\n * Defines the extensions the stl loader is able to load.\r\n * force data to come in as an ArrayBuffer\r\n * we'll convert to string if it looks like it's an ASCII .stl\r\n */\r\n public extensions: ISceneLoaderPluginExtensions = {\r\n \".stl\": { isBinary: true },\r\n };\r\n\r\n /**\r\n * Defines if Y and Z axes are swapped or not when loading an STL file.\r\n * The default is false to maintain backward compatibility. When set to\r\n * true, coordinates from the STL file are used without change.\r\n */\r\n public static DO_NOT_ALTER_FILE_COORDINATES = false;\r\n\r\n /**\r\n * Import meshes into a scene.\r\n * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported\r\n * @param scene The scene to import into\r\n * @param data The data to import\r\n * @param rootUrl The root url for scene and resources\r\n * @param meshes The meshes array to import into\r\n * @returns True if successful or false otherwise\r\n */\r\n public importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>): boolean {\r\n let matches;\r\n\r\n if (typeof data !== \"string\") {\r\n if (this._isBinary(data)) {\r\n // binary .stl\r\n const babylonMesh = new Mesh(\"stlmesh\", scene);\r\n this._parseBinary(babylonMesh, data);\r\n if (meshes) {\r\n meshes.push(babylonMesh);\r\n }\r\n return true;\r\n }\r\n\r\n // ASCII .stl\r\n\r\n // convert to string\r\n const array_buffer = new Uint8Array(data);\r\n let str = \"\";\r\n for (let i = 0; i < data.byteLength; i++) {\r\n str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian\r\n }\r\n data = str;\r\n }\r\n\r\n //if arrived here, data is a string, containing the STLA data.\r\n\r\n while ((matches = this.solidPattern.exec(data))) {\r\n let meshName = matches[1];\r\n const meshNameFromEnd = matches[3];\r\n if (meshNameFromEnd && meshName != meshNameFromEnd) {\r\n Tools.Error(\"Error in STL, solid name != endsolid name\");\r\n return false;\r\n }\r\n\r\n // check meshesNames\r\n if (meshesNames && meshName) {\r\n if (meshesNames instanceof Array) {\r\n if (!meshesNames.indexOf(meshName)) {\r\n continue;\r\n }\r\n } else {\r\n if (meshName !== meshesNames) {\r\n continue;\r\n }\r\n }\r\n }\r\n\r\n // stl mesh name can be empty as well\r\n meshName = meshName || \"stlmesh\";\r\n\r\n const babylonMesh = new Mesh(meshName, scene);\r\n this._parseASCII(babylonMesh, matches[2]);\r\n if (meshes) {\r\n meshes.push(babylonMesh);\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Load into a scene.\r\n * @param scene The scene to load into\r\n * @param data The data to import\r\n * @param rootUrl The root url for scene and resources\r\n * @returns true if successful or false otherwise\r\n */\r\n public load(scene: Scene, data: any, rootUrl: string): boolean {\r\n const result = this.importMesh(null, scene, data, rootUrl, null);\r\n return result;\r\n }\r\n\r\n /**\r\n * Load into an asset container.\r\n * @param scene The scene to load into\r\n * @param data The data to import\r\n * @param rootUrl The root url for scene and resources\r\n * @returns The loaded asset container\r\n */\r\n public loadAssetContainer(scene: Scene, data: string, rootUrl: string): AssetContainer {\r\n const container = new AssetContainer(scene);\r\n scene._blockEntityCollection = true;\r\n this.importMesh(null, scene, data, rootUrl, container.meshes);\r\n scene._blockEntityCollection = false;\r\n return container;\r\n }\r\n\r\n private _isBinary(data: any) {\r\n // check if file size is correct for binary stl\r\n const reader = new DataView(data);\r\n\r\n // A Binary STL header is 80 bytes, if the data size is not great than\r\n // that then it's not a binary STL.\r\n if (reader.byteLength <= 80) {\r\n return false;\r\n }\r\n\r\n const faceSize = (32 / 8) * 3 + (32 / 8) * 3 * 3 + 16 / 8;\r\n const nFaces = reader.getUint32(80, true);\r\n\r\n if (80 + 32 / 8 + nFaces * faceSize === reader.byteLength) {\r\n return true;\r\n }\r\n\r\n // US-ASCII begin with 's', 'o', 'l', 'i', 'd'\r\n const ascii = [115, 111, 108, 105, 100];\r\n for (let off = 0; off < 5; off++) {\r\n if (reader.getUint8(off) !== ascii[off]) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n private _parseBinary(mesh: Mesh, data: ArrayBuffer) {\r\n const reader = new DataView(data);\r\n const faces = reader.getUint32(80, true);\r\n\r\n const dataOffset = 84;\r\n const faceLength = 12 * 4 + 2;\r\n\r\n let offset = 0;\r\n\r\n const positions = new Float32Array(faces * 3 * 3);\r\n const normals = new Float32Array(faces * 3 * 3);\r\n const indices = new Uint32Array(faces * 3);\r\n let indicesCount = 0;\r\n\r\n for (let face = 0; face < faces; face++) {\r\n const start = dataOffset + face * faceLength;\r\n const normalX = reader.getFloat32(start, true);\r\n const normalY = reader.getFloat32(start + 4, true);\r\n const normalZ = reader.getFloat32(start + 8, true);\r\n\r\n for (let i = 1; i <= 3; i++) {\r\n const vertexstart = start + i * 12;\r\n\r\n // ordering is intentional to match ascii import\r\n positions[offset] = reader.getFloat32(vertexstart, true);\r\n normals[offset] = normalX;\r\n\r\n if (!STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\r\n positions[offset + 2] = reader.getFloat32(vertexstart + 4, true);\r\n positions[offset + 1] = reader.getFloat32(vertexstart + 8, true);\r\n\r\n normals[offset + 2] = normalY;\r\n normals[offset + 1] = normalZ;\r\n } else {\r\n positions[offset + 1] = reader.getFloat32(vertexstart + 4, true);\r\n positions[offset + 2] = reader.getFloat32(vertexstart + 8, true);\r\n\r\n normals[offset + 1] = normalY;\r\n normals[offset + 2] = normalZ;\r\n }\r\n\r\n offset += 3;\r\n }\r\n\r\n if (STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\r\n indices[indicesCount] = indicesCount;\r\n indices[indicesCount + 1] = indicesCount + 2;\r\n indices[indicesCount + 2] = indicesCount + 1;\r\n indicesCount += 3;\r\n } else {\r\n indices[indicesCount] = indicesCount++;\r\n indices[indicesCount] = indicesCount++;\r\n indices[indicesCount] = indicesCount++;\r\n }\r\n }\r\n\r\n mesh.setVerticesData(VertexBuffer.PositionKind, positions);\r\n mesh.setVerticesData(VertexBuffer.NormalKind, normals);\r\n mesh.setIndices(indices);\r\n mesh.computeWorldMatrix(true);\r\n }\r\n\r\n private _parseASCII(mesh: Mesh, solidData: string) {\r\n const positions = [];\r\n const normals = [];\r\n const indices = [];\r\n let indicesCount = 0;\r\n\r\n //load facets, ignoring loop as the standard doesn't define it can contain more than vertices\r\n let matches;\r\n while ((matches = this.facetsPattern.exec(solidData))) {\r\n const facet = matches[1];\r\n //one normal per face\r\n const normalMatches = this.normalPattern.exec(facet);\r\n this.normalPattern.lastIndex = 0;\r\n if (!normalMatches) {\r\n continue;\r\n }\r\n const normal = [Number(normalMatches[1]), Number(normalMatches[5]), Number(normalMatches[3])];\r\n\r\n let vertexMatch;\r\n while ((vertexMatch = this.vertexPattern.exec(facet))) {\r\n if (!STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\r\n positions.push(Number(vertexMatch[1]), Number(vertexMatch[5]), Number(vertexMatch[3]));\r\n normals.push(normal[0], normal[1], normal[2]);\r\n } else {\r\n positions.push(Number(vertexMatch[1]), Number(vertexMatch[3]), Number(vertexMatch[5]));\r\n\r\n // Flipping the second and third component because inverted\r\n // when normal was declared.\r\n normals.push(normal[0], normal[2], normal[1]);\r\n }\r\n }\r\n if (STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\r\n indices.push(indicesCount, indicesCount + 2, indicesCount + 1);\r\n indicesCount += 3;\r\n } else {\r\n indices.push(indicesCount++, indicesCount++, indicesCount++);\r\n }\r\n this.vertexPattern.lastIndex = 0;\r\n }\r\n\r\n this.facetsPattern.lastIndex = 0;\r\n mesh.setVerticesData(VertexBuffer.PositionKind, positions);\r\n mesh.setVerticesData(VertexBuffer.NormalKind, normals);\r\n mesh.setIndices(indices);\r\n mesh.computeWorldMatrix(true);\r\n }\r\n}\r\n\r\nif (SceneLoader) {\r\n SceneLoader.RegisterPlugin(new STLFileLoader());\r\n}\r\n","/* eslint-disable import/no-internal-modules */\r\nimport * as Loaders from \"loaders/STL/index\";\r\n\r\n/**\r\n * This is the entry point for the UMD module.\r\n * The entry point for a future ESM package should be index.ts\r\n */\r\nconst globalObject = typeof global !== \"undefined\" ? global : typeof window !== \"undefined\" ? window : undefined;\r\nif (typeof globalObject !== \"undefined\") {\r\n for (const key in Loaders) {\r\n if (!(<any>globalObject).BABYLON[key]) {\r\n (<any>globalObject).BABYLON[key] = (<any>Loaders)[key];\r\n }\r\n }\r\n}\r\n\r\nexport * from \"loaders/STL/index\";\r\n","module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import * as loaders from \"@lts/loaders/legacy/legacy-stlFileLoader\";\r\nexport { loaders };\r\nexport default loaders;\r\n"],"names":[],"sourceRoot":""}
1
+ {"version":3,"file":"babylon.stlFileLoader.js","mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AACD,O;;;;;;;;;;;;;;;ACVgC;;;;;;;;;;;;;;;;;ACEQ;AACW;AAEX;AAEe;AACF;AAGrD;;;GAGG;AACI;IAAP;QACI,gBAAgB;QACT,iBAAY,GAAG,yCAAyC,CAAC;QAEhE,gBAAgB;QACT,kBAAa,GAAG,0BAA0B,CAAC;QAClD,gBAAgB;QACT,kBAAa,GAAG,mJAAmJ,CAAC;QAC3K,gBAAgB;QACT,kBAAa,GAAG,mJAAmJ,CAAC;QAE3K;;WAEG;QACI,SAAI,GAAG,KAAK,CAAC;QAEpB;;;;WAIG;QACI,eAAU,GAAiC;YAC9C,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE;SAC7B,CAAC;IA6ON,CAAC;IApOG;;;;;;;;OAQG;IACI,kCAAU,GAAjB,UAAkB,WAAgB,EAAE,KAAY,EAAE,IAAS,EAAE,OAAe,EAAE,MAAgC;QAC1G,IAAI,OAAO,CAAC;QAEZ,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC1B,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;gBACtB,cAAc;gBACd,IAAM,WAAW,GAAG,IAAI,sDAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;gBAC/C,IAAI,CAAC,YAAY,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;gBACrC,IAAI,MAAM,EAAE;oBACR,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;iBAC5B;gBACD,OAAO,IAAI,CAAC;aACf;YAED,aAAa;YAEb,oBAAoB;YACpB,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A;WACA;WACA,uDAAuD,iBAAiB;WACxE;WACA,gDAAgD,aAAa;WAC7D;;;;;;;;;;;;;;;;ACNoE;AACjD;AACnB,iEAAe,qEAAO,EAAC","sources":["webpack://LOADERS/webpack/universalModuleDefinition","webpack://LOADERS/../../../dev/loaders/src/STL/index.ts","webpack://LOADERS/../../../dev/loaders/src/STL/stlFileLoader.ts","webpack://LOADERS/../../../lts/loaders/src/legacy/legacy-stlFileLoader.ts","webpack://LOADERS/external umd {\"root\":\"BABYLON\",\"commonjs\":\"babylonjs\",\"commonjs2\":\"babylonjs\",\"amd\":\"babylonjs\"}","webpack://LOADERS/webpack/bootstrap","webpack://LOADERS/webpack/runtime/compat get default export","webpack://LOADERS/webpack/runtime/define property getters","webpack://LOADERS/webpack/runtime/global","webpack://LOADERS/webpack/runtime/hasOwnProperty shorthand","webpack://LOADERS/webpack/runtime/make namespace object","webpack://LOADERS/./src/stlFileLoader.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"babylonjs\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"babylonjs-loaders\", [\"babylonjs\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"babylonjs-loaders\"] = factory(require(\"babylonjs\"));\n\telse\n\t\troot[\"LOADERS\"] = factory(root[\"BABYLON\"]);\n})((typeof self !== \"undefined\" ? self : typeof global !== \"undefined\" ? global : this), (__WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__) => {\nreturn ","export * from \"./stlFileLoader\";\r\n","/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"core/types\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport type { ISceneLoaderPlugin, ISceneLoaderPluginExtensions } from \"core/Loading/sceneLoader\";\r\nimport { SceneLoader } from \"core/Loading/sceneLoader\";\r\nimport { AssetContainer } from \"core/assetContainer\";\r\nimport type { Scene } from \"core/scene\";\r\n\r\n/**\r\n * STL file type loader.\r\n * This is a babylon scene loader plugin.\r\n */\r\nexport class STLFileLoader implements ISceneLoaderPlugin {\r\n /** @internal */\r\n public solidPattern = /solid (\\S*)([\\S\\s]*?)endsolid[ ]*(\\S*)/g;\r\n\r\n /** @internal */\r\n public facetsPattern = /facet([\\s\\S]*?)endfacet/g;\r\n /** @internal */\r\n public normalPattern = /normal[\\s]+([-+]?[0-9]+\\.?[0-9]*([eE][-+]?[0-9]+)?)+[\\s]+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)+[\\s]+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)+/g;\r\n /** @internal */\r\n public vertexPattern = /vertex[\\s]+([-+]?[0-9]+\\.?[0-9]*([eE][-+]?[0-9]+)?)+[\\s]+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)+[\\s]+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)+/g;\r\n\r\n /**\r\n * Defines the name of the plugin.\r\n */\r\n public name = \"stl\";\r\n\r\n /**\r\n * Defines the extensions the stl loader is able to load.\r\n * force data to come in as an ArrayBuffer\r\n * we'll convert to string if it looks like it's an ASCII .stl\r\n */\r\n public extensions: ISceneLoaderPluginExtensions = {\r\n \".stl\": { isBinary: true },\r\n };\r\n\r\n /**\r\n * Defines if Y and Z axes are swapped or not when loading an STL file.\r\n * The default is false to maintain backward compatibility. When set to\r\n * true, coordinates from the STL file are used without change.\r\n */\r\n public static DO_NOT_ALTER_FILE_COORDINATES = false;\r\n\r\n /**\r\n * Import meshes into a scene.\r\n * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported\r\n * @param scene The scene to import into\r\n * @param data The data to import\r\n * @param rootUrl The root url for scene and resources\r\n * @param meshes The meshes array to import into\r\n * @returns True if successful or false otherwise\r\n */\r\n public importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>): boolean {\r\n let matches;\r\n\r\n if (typeof data !== \"string\") {\r\n if (this._isBinary(data)) {\r\n // binary .stl\r\n const babylonMesh = new Mesh(\"stlmesh\", scene);\r\n this._parseBinary(babylonMesh, data);\r\n if (meshes) {\r\n meshes.push(babylonMesh);\r\n }\r\n return true;\r\n }\r\n\r\n // ASCII .stl\r\n\r\n // convert to string\r\n data = new TextDecoder().decode(new Uint8Array(data));\r\n }\r\n\r\n //if arrived here, data is a string, containing the STLA data.\r\n\r\n while ((matches = this.solidPattern.exec(data))) {\r\n let meshName = matches[1];\r\n const meshNameFromEnd = matches[3];\r\n if (meshNameFromEnd && meshName != meshNameFromEnd) {\r\n Tools.Error(\"Error in STL, solid name != endsolid name\");\r\n return false;\r\n }\r\n\r\n // check meshesNames\r\n if (meshesNames && meshName) {\r\n if (meshesNames instanceof Array) {\r\n if (!meshesNames.indexOf(meshName)) {\r\n continue;\r\n }\r\n } else {\r\n if (meshName !== meshesNames) {\r\n continue;\r\n }\r\n }\r\n }\r\n\r\n // stl mesh name can be empty as well\r\n meshName = meshName || \"stlmesh\";\r\n\r\n const babylonMesh = new Mesh(meshName, scene);\r\n this._parseASCII(babylonMesh, matches[2]);\r\n if (meshes) {\r\n meshes.push(babylonMesh);\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Load into a scene.\r\n * @param scene The scene to load into\r\n * @param data The data to import\r\n * @param rootUrl The root url for scene and resources\r\n * @returns true if successful or false otherwise\r\n */\r\n public load(scene: Scene, data: any, rootUrl: string): boolean {\r\n const result = this.importMesh(null, scene, data, rootUrl, null);\r\n return result;\r\n }\r\n\r\n /**\r\n * Load into an asset container.\r\n * @param scene The scene to load into\r\n * @param data The data to import\r\n * @param rootUrl The root url for scene and resources\r\n * @returns The loaded asset container\r\n */\r\n public loadAssetContainer(scene: Scene, data: string, rootUrl: string): AssetContainer {\r\n const container = new AssetContainer(scene);\r\n scene._blockEntityCollection = true;\r\n this.importMesh(null, scene, data, rootUrl, container.meshes);\r\n scene._blockEntityCollection = false;\r\n return container;\r\n }\r\n\r\n private _isBinary(data: any) {\r\n // check if file size is correct for binary stl\r\n const reader = new DataView(data);\r\n\r\n // A Binary STL header is 80 bytes, if the data size is not great than\r\n // that then it's not a binary STL.\r\n if (reader.byteLength <= 80) {\r\n return false;\r\n }\r\n\r\n const faceSize = (32 / 8) * 3 + (32 / 8) * 3 * 3 + 16 / 8;\r\n const nFaces = reader.getUint32(80, true);\r\n\r\n if (80 + 32 / 8 + nFaces * faceSize === reader.byteLength) {\r\n return true;\r\n }\r\n\r\n // US-ASCII begin with 's', 'o', 'l', 'i', 'd'\r\n const ascii = [115, 111, 108, 105, 100];\r\n for (let off = 0; off < 5; off++) {\r\n if (reader.getUint8(off) !== ascii[off]) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n private _parseBinary(mesh: Mesh, data: ArrayBuffer) {\r\n const reader = new DataView(data);\r\n const faces = reader.getUint32(80, true);\r\n\r\n const dataOffset = 84;\r\n const faceLength = 12 * 4 + 2;\r\n\r\n let offset = 0;\r\n\r\n const positions = new Float32Array(faces * 3 * 3);\r\n const normals = new Float32Array(faces * 3 * 3);\r\n const indices = new Uint32Array(faces * 3);\r\n let indicesCount = 0;\r\n\r\n for (let face = 0; face < faces; face++) {\r\n const start = dataOffset + face * faceLength;\r\n const normalX = reader.getFloat32(start, true);\r\n const normalY = reader.getFloat32(start + 4, true);\r\n const normalZ = reader.getFloat32(start + 8, true);\r\n\r\n for (let i = 1; i <= 3; i++) {\r\n const vertexstart = start + i * 12;\r\n\r\n // ordering is intentional to match ascii import\r\n positions[offset] = reader.getFloat32(vertexstart, true);\r\n normals[offset] = normalX;\r\n\r\n if (!STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\r\n positions[offset + 2] = reader.getFloat32(vertexstart + 4, true);\r\n positions[offset + 1] = reader.getFloat32(vertexstart + 8, true);\r\n\r\n normals[offset + 2] = normalY;\r\n normals[offset + 1] = normalZ;\r\n } else {\r\n positions[offset + 1] = reader.getFloat32(vertexstart + 4, true);\r\n positions[offset + 2] = reader.getFloat32(vertexstart + 8, true);\r\n\r\n normals[offset + 1] = normalY;\r\n normals[offset + 2] = normalZ;\r\n }\r\n\r\n offset += 3;\r\n }\r\n\r\n if (STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\r\n indices[indicesCount] = indicesCount;\r\n indices[indicesCount + 1] = indicesCount + 2;\r\n indices[indicesCount + 2] = indicesCount + 1;\r\n indicesCount += 3;\r\n } else {\r\n indices[indicesCount] = indicesCount++;\r\n indices[indicesCount] = indicesCount++;\r\n indices[indicesCount] = indicesCount++;\r\n }\r\n }\r\n\r\n mesh.setVerticesData(VertexBuffer.PositionKind, positions);\r\n mesh.setVerticesData(VertexBuffer.NormalKind, normals);\r\n mesh.setIndices(indices);\r\n mesh.computeWorldMatrix(true);\r\n }\r\n\r\n private _parseASCII(mesh: Mesh, solidData: string) {\r\n const positions = [];\r\n const normals = [];\r\n const indices = [];\r\n let indicesCount = 0;\r\n\r\n //load facets, ignoring loop as the standard doesn't define it can contain more than vertices\r\n let matches;\r\n while ((matches = this.facetsPattern.exec(solidData))) {\r\n const facet = matches[1];\r\n //one normal per face\r\n const normalMatches = this.normalPattern.exec(facet);\r\n this.normalPattern.lastIndex = 0;\r\n if (!normalMatches) {\r\n continue;\r\n }\r\n const normal = [Number(normalMatches[1]), Number(normalMatches[5]), Number(normalMatches[3])];\r\n\r\n let vertexMatch;\r\n while ((vertexMatch = this.vertexPattern.exec(facet))) {\r\n if (!STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\r\n positions.push(Number(vertexMatch[1]), Number(vertexMatch[5]), Number(vertexMatch[3]));\r\n normals.push(normal[0], normal[1], normal[2]);\r\n } else {\r\n positions.push(Number(vertexMatch[1]), Number(vertexMatch[3]), Number(vertexMatch[5]));\r\n\r\n // Flipping the second and third component because inverted\r\n // when normal was declared.\r\n normals.push(normal[0], normal[2], normal[1]);\r\n }\r\n }\r\n if (STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\r\n indices.push(indicesCount, indicesCount + 2, indicesCount + 1);\r\n indicesCount += 3;\r\n } else {\r\n indices.push(indicesCount++, indicesCount++, indicesCount++);\r\n }\r\n this.vertexPattern.lastIndex = 0;\r\n }\r\n\r\n this.facetsPattern.lastIndex = 0;\r\n mesh.setVerticesData(VertexBuffer.PositionKind, positions);\r\n mesh.setVerticesData(VertexBuffer.NormalKind, normals);\r\n mesh.setIndices(indices);\r\n mesh.computeWorldMatrix(true);\r\n }\r\n}\r\n\r\nif (SceneLoader) {\r\n SceneLoader.RegisterPlugin(new STLFileLoader());\r\n}\r\n","/* eslint-disable import/no-internal-modules */\r\nimport * as Loaders from \"loaders/STL/index\";\r\n\r\n/**\r\n * This is the entry point for the UMD module.\r\n * The entry point for a future ESM package should be index.ts\r\n */\r\nconst globalObject = typeof global !== \"undefined\" ? global : typeof window !== \"undefined\" ? window : undefined;\r\nif (typeof globalObject !== \"undefined\") {\r\n for (const key in Loaders) {\r\n if (!(<any>globalObject).BABYLON[key]) {\r\n (<any>globalObject).BABYLON[key] = (<any>Loaders)[key];\r\n }\r\n }\r\n}\r\n\r\nexport * from \"loaders/STL/index\";\r\n","module.exports = __WEBPACK_EXTERNAL_MODULE_babylonjs_Misc_observable__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import * as loaders from \"@lts/loaders/legacy/legacy-stlFileLoader\";\r\nexport { loaders };\r\nexport default loaders;\r\n"],"names":[],"sourceRoot":""}
@@ -1,2 +1,2 @@
1
- !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}},r={};function n(e){var o=r[e];if(void 0!==o)return o.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 o={};return(()=>{n.d(o,{default:()=>l});var e={};n.r(e),n.d(e,{STLFileLoader:()=>i});var t={};n.r(t),n.d(t,{STLFileLoader:()=>i});var r=n(520),i=function(){function e(){this.solidPattern=/solid (\S*)([\S\s]*?)endsolid[ ]*(\S*)/g,this.facetsPattern=/facet([\s\S]*?)endfacet/g,this.normalPattern=/normal[\s]+([-+]?[0-9]+\.?[0-9]*([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+/g,this.vertexPattern=/vertex[\s]+([-+]?[0-9]+\.?[0-9]*([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+/g,this.name="stl",this.extensions={".stl":{isBinary:!0}}}return e.prototype.importMesh=function(e,t,n,o,i){var a;if("string"!=typeof n){if(this._isBinary(n)){var s=new r.Mesh("stlmesh",t);return this._parseBinary(s,n),i&&i.push(s),!0}for(var l=new Uint8Array(n),f="",u=0;u<n.byteLength;u++)f+=String.fromCharCode(l[u]);n=f}for(;a=this.solidPattern.exec(n);){var d=a[1],p=a[3];if(p&&d!=p)return r.Tools.Error("Error in STL, solid name != endsolid name"),!1;if(e&&d)if(e instanceof Array){if(!e.indexOf(d))continue}else if(d!==e)continue;d=d||"stlmesh",s=new r.Mesh(d,t),this._parseASCII(s,a[2]),i&&i.push(s)}return!0},e.prototype.load=function(e,t,r){return this.importMesh(null,e,t,r,null)},e.prototype.loadAssetContainer=function(e,t,n){var o=new r.AssetContainer(e);return e._blockEntityCollection=!0,this.importMesh(null,e,t,n,o.meshes),e._blockEntityCollection=!1,o},e.prototype._isBinary=function(e){var t=new DataView(e);if(t.byteLength<=80)return!1;if(84+50*t.getUint32(80,!0)===t.byteLength)return!0;for(var r=[115,111,108,105,100],n=0;n<5;n++)if(t.getUint8(n)!==r[n])return!0;return!1},e.prototype._parseBinary=function(t,n){for(var o=new DataView(n),i=o.getUint32(80,!0),a=0,s=new Float32Array(3*i*3),l=new Float32Array(3*i*3),f=new Uint32Array(3*i),u=0,d=0;d<i;d++){for(var p=84+50*d,c=o.getFloat32(p,!0),y=o.getFloat32(p+4,!0),h=o.getFloat32(p+8,!0),b=1;b<=3;b++){var g=p+12*b;s[a]=o.getFloat32(g,!0),l[a]=c,e.DO_NOT_ALTER_FILE_COORDINATES?(s[a+1]=o.getFloat32(g+4,!0),s[a+2]=o.getFloat32(g+8,!0),l[a+1]=y,l[a+2]=h):(s[a+2]=o.getFloat32(g+4,!0),s[a+1]=o.getFloat32(g+8,!0),l[a+2]=y,l[a+1]=h),a+=3}e.DO_NOT_ALTER_FILE_COORDINATES?(f[u]=u,f[u+1]=u+2,f[u+2]=u+1,u+=3):(f[u]=u++,f[u]=u++,f[u]=u++)}t.setVerticesData(r.VertexBuffer.PositionKind,s),t.setVerticesData(r.VertexBuffer.NormalKind,l),t.setIndices(f),t.computeWorldMatrix(!0)},e.prototype._parseASCII=function(t,n){for(var o,i=[],a=[],s=[],l=0;o=this.facetsPattern.exec(n);){var f=o[1],u=this.normalPattern.exec(f);if(this.normalPattern.lastIndex=0,u){for(var d=[Number(u[1]),Number(u[5]),Number(u[3])],p=void 0;p=this.vertexPattern.exec(f);)e.DO_NOT_ALTER_FILE_COORDINATES?(i.push(Number(p[1]),Number(p[3]),Number(p[5])),a.push(d[0],d[2],d[1])):(i.push(Number(p[1]),Number(p[5]),Number(p[3])),a.push(d[0],d[1],d[2]));e.DO_NOT_ALTER_FILE_COORDINATES?(s.push(l,l+2,l+1),l+=3):s.push(l++,l++,l++),this.vertexPattern.lastIndex=0}}this.facetsPattern.lastIndex=0,t.setVerticesData(r.VertexBuffer.PositionKind,i),t.setVerticesData(r.VertexBuffer.NormalKind,a),t.setIndices(s),t.computeWorldMatrix(!0)},e.DO_NOT_ALTER_FILE_COORDINATES=!1,e}();r.SceneLoader&&r.SceneLoader.RegisterPlugin(new i);var a=void 0!==n.g?n.g:"undefined"!=typeof window?window:void 0;if(void 0!==a)for(var s in e)a.BABYLON[s]||(a.BABYLON[s]=e[s]);const l=t})(),o.default})()));
1
+ !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}},r={};function n(e){var o=r[e];if(void 0!==o)return o.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 o={};return(()=>{n.d(o,{default:()=>l});var e={};n.r(e),n.d(e,{STLFileLoader:()=>i});var t={};n.r(t),n.d(t,{STLFileLoader:()=>i});var r=n(520),i=function(){function e(){this.solidPattern=/solid (\S*)([\S\s]*?)endsolid[ ]*(\S*)/g,this.facetsPattern=/facet([\s\S]*?)endfacet/g,this.normalPattern=/normal[\s]+([-+]?[0-9]+\.?[0-9]*([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+/g,this.vertexPattern=/vertex[\s]+([-+]?[0-9]+\.?[0-9]*([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+/g,this.name="stl",this.extensions={".stl":{isBinary:!0}}}return e.prototype.importMesh=function(e,t,n,o,i){var a;if("string"!=typeof n){if(this._isBinary(n)){var s=new r.Mesh("stlmesh",t);return this._parseBinary(s,n),i&&i.push(s),!0}n=(new TextDecoder).decode(new Uint8Array(n))}for(;a=this.solidPattern.exec(n);){var l=a[1],f=a[3];if(f&&l!=f)return r.Tools.Error("Error in STL, solid name != endsolid name"),!1;if(e&&l)if(e instanceof Array){if(!e.indexOf(l))continue}else if(l!==e)continue;l=l||"stlmesh",s=new r.Mesh(l,t),this._parseASCII(s,a[2]),i&&i.push(s)}return!0},e.prototype.load=function(e,t,r){return this.importMesh(null,e,t,r,null)},e.prototype.loadAssetContainer=function(e,t,n){var o=new r.AssetContainer(e);return e._blockEntityCollection=!0,this.importMesh(null,e,t,n,o.meshes),e._blockEntityCollection=!1,o},e.prototype._isBinary=function(e){var t=new DataView(e);if(t.byteLength<=80)return!1;if(84+50*t.getUint32(80,!0)===t.byteLength)return!0;for(var r=[115,111,108,105,100],n=0;n<5;n++)if(t.getUint8(n)!==r[n])return!0;return!1},e.prototype._parseBinary=function(t,n){for(var o=new DataView(n),i=o.getUint32(80,!0),a=0,s=new Float32Array(3*i*3),l=new Float32Array(3*i*3),f=new Uint32Array(3*i),u=0,d=0;d<i;d++){for(var c=84+50*d,p=o.getFloat32(c,!0),y=o.getFloat32(c+4,!0),h=o.getFloat32(c+8,!0),b=1;b<=3;b++){var m=c+12*b;s[a]=o.getFloat32(m,!0),l[a]=p,e.DO_NOT_ALTER_FILE_COORDINATES?(s[a+1]=o.getFloat32(m+4,!0),s[a+2]=o.getFloat32(m+8,!0),l[a+1]=y,l[a+2]=h):(s[a+2]=o.getFloat32(m+4,!0),s[a+1]=o.getFloat32(m+8,!0),l[a+2]=y,l[a+1]=h),a+=3}e.DO_NOT_ALTER_FILE_COORDINATES?(f[u]=u,f[u+1]=u+2,f[u+2]=u+1,u+=3):(f[u]=u++,f[u]=u++,f[u]=u++)}t.setVerticesData(r.VertexBuffer.PositionKind,s),t.setVerticesData(r.VertexBuffer.NormalKind,l),t.setIndices(f),t.computeWorldMatrix(!0)},e.prototype._parseASCII=function(t,n){for(var o,i=[],a=[],s=[],l=0;o=this.facetsPattern.exec(n);){var f=o[1],u=this.normalPattern.exec(f);if(this.normalPattern.lastIndex=0,u){for(var d=[Number(u[1]),Number(u[5]),Number(u[3])],c=void 0;c=this.vertexPattern.exec(f);)e.DO_NOT_ALTER_FILE_COORDINATES?(i.push(Number(c[1]),Number(c[3]),Number(c[5])),a.push(d[0],d[2],d[1])):(i.push(Number(c[1]),Number(c[5]),Number(c[3])),a.push(d[0],d[1],d[2]));e.DO_NOT_ALTER_FILE_COORDINATES?(s.push(l,l+2,l+1),l+=3):s.push(l++,l++,l++),this.vertexPattern.lastIndex=0}}this.facetsPattern.lastIndex=0,t.setVerticesData(r.VertexBuffer.PositionKind,i),t.setVerticesData(r.VertexBuffer.NormalKind,a),t.setIndices(s),t.computeWorldMatrix(!0)},e.DO_NOT_ALTER_FILE_COORDINATES=!1,e}();r.SceneLoader&&r.SceneLoader.RegisterPlugin(new i);var a=void 0!==n.g?n.g:"undefined"!=typeof window?window:void 0;if(void 0!==a)for(var s in e)a.BABYLON[s]||(a.BABYLON[s]=e[s]);const l=t})(),o.default})()));
2
2
  //# sourceMappingURL=babylon.stlFileLoader.min.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"babylon.stlFileLoader.min.js","mappings":"CAAA,SAA2CA,EAA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AAO,KAS9CZ,EAAcC,+BACdX,EAAQjC,KAAKmC,EAAcA,EAAe,EAAGA,EAAe,GAC5DA,GAAgB,GAEhBF,EAAQjC,KAAKmC,IAAgBA,IAAgBA,KAEjDnF,KAAKiC,cAAcqE,UAAY,C,EAGnCtG,KAAK+B,cAAcuE,UAAY,EAC/B3B,EAAKkB,gBAAgB,EAAAC,aAAaC,aAAcjB,GAChDH,EAAKkB,gBAAgB,EAAAC,aAAaE,WAAYhB,GAC9CL,EAAKsB,WAAWhB,GAChBN,EAAKuB,oBAAmB,EAC5B,EA1Oc,EAAAN,+BAAgC,EA2OlD,C,CAzQO,GA2QH,EAAAc,aACA,EAAAA,YAAYC,eAAe,IAAIhB,GCpRnC,IAAMiB,OAAiC,IAAX,EAAA5F,EAAyB,EAAAA,EAA2B,oBAAXI,OAAyBA,YAASd,EACvG,QAA4B,IAAjBsG,EACP,IAAK,IAAMlG,KAAO,EACHkG,EAAcC,QAAQnG,KACvBkG,EAAcC,QAAQnG,GAAa,EAASA,ICT9D,S","sources":["webpack://LOADERS/webpack/universalModuleDefinition","webpack://LOADERS/external umd {\"root\":\"BABYLON\",\"commonjs\":\"babylonjs\",\"commonjs2\":\"babylonjs\",\"amd\":\"babylonjs\"}","webpack://LOADERS/webpack/bootstrap","webpack://LOADERS/webpack/runtime/define property getters","webpack://LOADERS/webpack/runtime/global","webpack://LOADERS/webpack/runtime/hasOwnProperty shorthand","webpack://LOADERS/webpack/runtime/make namespace object","webpack://LOADERS/../../../dev/loaders/src/STL/stlFileLoader.ts","webpack://LOADERS/../../../lts/loaders/src/legacy/legacy-stlFileLoader.ts","webpack://LOADERS/./src/stlFileLoader.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"babylonjs\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"babylonjs-loaders\", [\"babylonjs\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"babylonjs-loaders\"] = factory(require(\"babylonjs\"));\n\telse\n\t\troot[\"LOADERS\"] = factory(root[\"BABYLON\"]);\n})((typeof self !== \"undefined\" ? self : typeof global !== \"undefined\" ? global : this), (__WEBPACK_EXTERNAL_MODULE__520__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__520__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"core/types\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport type { ISceneLoaderPlugin, ISceneLoaderPluginExtensions } from \"core/Loading/sceneLoader\";\r\nimport { SceneLoader } from \"core/Loading/sceneLoader\";\r\nimport { AssetContainer } from \"core/assetContainer\";\r\nimport type { Scene } from \"core/scene\";\r\n\r\n/**\r\n * STL file type loader.\r\n * This is a babylon scene loader plugin.\r\n */\r\nexport class STLFileLoader implements ISceneLoaderPlugin {\r\n /** @internal */\r\n public solidPattern = /solid (\\S*)([\\S\\s]*?)endsolid[ ]*(\\S*)/g;\r\n\r\n /** @internal */\r\n public facetsPattern = /facet([\\s\\S]*?)endfacet/g;\r\n /** @internal */\r\n public normalPattern = /normal[\\s]+([-+]?[0-9]+\\.?[0-9]*([eE][-+]?[0-9]+)?)+[\\s]+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)+[\\s]+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)+/g;\r\n /** @internal */\r\n public vertexPattern = /vertex[\\s]+([-+]?[0-9]+\\.?[0-9]*([eE][-+]?[0-9]+)?)+[\\s]+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)+[\\s]+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)+/g;\r\n\r\n /**\r\n * Defines the name of the plugin.\r\n */\r\n public name = \"stl\";\r\n\r\n /**\r\n * Defines the extensions the stl loader is able to load.\r\n * force data to come in as an ArrayBuffer\r\n * we'll convert to string if it looks like it's an ASCII .stl\r\n */\r\n public extensions: ISceneLoaderPluginExtensions = {\r\n \".stl\": { isBinary: true },\r\n };\r\n\r\n /**\r\n * Defines if Y and Z axes are swapped or not when loading an STL file.\r\n * The default is false to maintain backward compatibility. When set to\r\n * true, coordinates from the STL file are used without change.\r\n */\r\n public static DO_NOT_ALTER_FILE_COORDINATES = false;\r\n\r\n /**\r\n * Import meshes into a scene.\r\n * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported\r\n * @param scene The scene to import into\r\n * @param data The data to import\r\n * @param rootUrl The root url for scene and resources\r\n * @param meshes The meshes array to import into\r\n * @returns True if successful or false otherwise\r\n */\r\n public importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>): boolean {\r\n let matches;\r\n\r\n if (typeof data !== \"string\") {\r\n if (this._isBinary(data)) {\r\n // binary .stl\r\n const babylonMesh = new Mesh(\"stlmesh\", scene);\r\n this._parseBinary(babylonMesh, data);\r\n if (meshes) {\r\n meshes.push(babylonMesh);\r\n }\r\n return true;\r\n }\r\n\r\n // ASCII .stl\r\n\r\n // convert to string\r\n const array_buffer = new Uint8Array(data);\r\n let str = \"\";\r\n for (let i = 0; i < data.byteLength; i++) {\r\n str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian\r\n }\r\n data = str;\r\n }\r\n\r\n //if arrived here, data is a string, containing the STLA data.\r\n\r\n while ((matches = this.solidPattern.exec(data))) {\r\n let meshName = matches[1];\r\n const meshNameFromEnd = matches[3];\r\n if (meshNameFromEnd && meshName != meshNameFromEnd) {\r\n Tools.Error(\"Error in STL, solid name != endsolid name\");\r\n return false;\r\n }\r\n\r\n // check meshesNames\r\n if (meshesNames && meshName) {\r\n if (meshesNames instanceof Array) {\r\n if (!meshesNames.indexOf(meshName)) {\r\n continue;\r\n }\r\n } else {\r\n if (meshName !== meshesNames) {\r\n continue;\r\n }\r\n }\r\n }\r\n\r\n // stl mesh name can be empty as well\r\n meshName = meshName || \"stlmesh\";\r\n\r\n const babylonMesh = new Mesh(meshName, scene);\r\n this._parseASCII(babylonMesh, matches[2]);\r\n if (meshes) {\r\n meshes.push(babylonMesh);\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Load into a scene.\r\n * @param scene The scene to load into\r\n * @param data The data to import\r\n * @param rootUrl The root url for scene and resources\r\n * @returns true if successful or false otherwise\r\n */\r\n public load(scene: Scene, data: any, rootUrl: string): boolean {\r\n const result = this.importMesh(null, scene, data, rootUrl, null);\r\n return result;\r\n }\r\n\r\n /**\r\n * Load into an asset container.\r\n * @param scene The scene to load into\r\n * @param data The data to import\r\n * @param rootUrl The root url for scene and resources\r\n * @returns The loaded asset container\r\n */\r\n public loadAssetContainer(scene: Scene, data: string, rootUrl: string): AssetContainer {\r\n const container = new AssetContainer(scene);\r\n scene._blockEntityCollection = true;\r\n this.importMesh(null, scene, data, rootUrl, container.meshes);\r\n scene._blockEntityCollection = false;\r\n return container;\r\n }\r\n\r\n private _isBinary(data: any) {\r\n // check if file size is correct for binary stl\r\n const reader = new DataView(data);\r\n\r\n // A Binary STL header is 80 bytes, if the data size is not great than\r\n // that then it's not a binary STL.\r\n if (reader.byteLength <= 80) {\r\n return false;\r\n }\r\n\r\n const faceSize = (32 / 8) * 3 + (32 / 8) * 3 * 3 + 16 / 8;\r\n const nFaces = reader.getUint32(80, true);\r\n\r\n if (80 + 32 / 8 + nFaces * faceSize === reader.byteLength) {\r\n return true;\r\n }\r\n\r\n // US-ASCII begin with 's', 'o', 'l', 'i', 'd'\r\n const ascii = [115, 111, 108, 105, 100];\r\n for (let off = 0; off < 5; off++) {\r\n if (reader.getUint8(off) !== ascii[off]) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n private _parseBinary(mesh: Mesh, data: ArrayBuffer) {\r\n const reader = new DataView(data);\r\n const faces = reader.getUint32(80, true);\r\n\r\n const dataOffset = 84;\r\n const faceLength = 12 * 4 + 2;\r\n\r\n let offset = 0;\r\n\r\n const positions = new Float32Array(faces * 3 * 3);\r\n const normals = new Float32Array(faces * 3 * 3);\r\n const indices = new Uint32Array(faces * 3);\r\n let indicesCount = 0;\r\n\r\n for (let face = 0; face < faces; face++) {\r\n const start = dataOffset + face * faceLength;\r\n const normalX = reader.getFloat32(start, true);\r\n const normalY = reader.getFloat32(start + 4, true);\r\n const normalZ = reader.getFloat32(start + 8, true);\r\n\r\n for (let i = 1; i <= 3; i++) {\r\n const vertexstart = start + i * 12;\r\n\r\n // ordering is intentional to match ascii import\r\n positions[offset] = reader.getFloat32(vertexstart, true);\r\n normals[offset] = normalX;\r\n\r\n if (!STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\r\n positions[offset + 2] = reader.getFloat32(vertexstart + 4, true);\r\n positions[offset + 1] = reader.getFloat32(vertexstart + 8, true);\r\n\r\n normals[offset + 2] = normalY;\r\n normals[offset + 1] = normalZ;\r\n } else {\r\n positions[offset + 1] = reader.getFloat32(vertexstart + 4, true);\r\n positions[offset + 2] = reader.getFloat32(vertexstart + 8, true);\r\n\r\n normals[offset + 1] = normalY;\r\n normals[offset + 2] = normalZ;\r\n }\r\n\r\n offset += 3;\r\n }\r\n\r\n if (STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\r\n indices[indicesCount] = indicesCount;\r\n indices[indicesCount + 1] = indicesCount + 2;\r\n indices[indicesCount + 2] = indicesCount + 1;\r\n indicesCount += 3;\r\n } else {\r\n indices[indicesCount] = indicesCount++;\r\n indices[indicesCount] = indicesCount++;\r\n indices[indicesCount] = indicesCount++;\r\n }\r\n }\r\n\r\n mesh.setVerticesData(VertexBuffer.PositionKind, positions);\r\n mesh.setVerticesData(VertexBuffer.NormalKind, normals);\r\n mesh.setIndices(indices);\r\n mesh.computeWorldMatrix(true);\r\n }\r\n\r\n private _parseASCII(mesh: Mesh, solidData: string) {\r\n const positions = [];\r\n const normals = [];\r\n const indices = [];\r\n let indicesCount = 0;\r\n\r\n //load facets, ignoring loop as the standard doesn't define it can contain more than vertices\r\n let matches;\r\n while ((matches = this.facetsPattern.exec(solidData))) {\r\n const facet = matches[1];\r\n //one normal per face\r\n const normalMatches = this.normalPattern.exec(facet);\r\n this.normalPattern.lastIndex = 0;\r\n if (!normalMatches) {\r\n continue;\r\n }\r\n const normal = [Number(normalMatches[1]), Number(normalMatches[5]), Number(normalMatches[3])];\r\n\r\n let vertexMatch;\r\n while ((vertexMatch = this.vertexPattern.exec(facet))) {\r\n if (!STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\r\n positions.push(Number(vertexMatch[1]), Number(vertexMatch[5]), Number(vertexMatch[3]));\r\n normals.push(normal[0], normal[1], normal[2]);\r\n } else {\r\n positions.push(Number(vertexMatch[1]), Number(vertexMatch[3]), Number(vertexMatch[5]));\r\n\r\n // Flipping the second and third component because inverted\r\n // when normal was declared.\r\n normals.push(normal[0], normal[2], normal[1]);\r\n }\r\n }\r\n if (STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\r\n indices.push(indicesCount, indicesCount + 2, indicesCount + 1);\r\n indicesCount += 3;\r\n } else {\r\n indices.push(indicesCount++, indicesCount++, indicesCount++);\r\n }\r\n this.vertexPattern.lastIndex = 0;\r\n }\r\n\r\n this.facetsPattern.lastIndex = 0;\r\n mesh.setVerticesData(VertexBuffer.PositionKind, positions);\r\n mesh.setVerticesData(VertexBuffer.NormalKind, normals);\r\n mesh.setIndices(indices);\r\n mesh.computeWorldMatrix(true);\r\n }\r\n}\r\n\r\nif (SceneLoader) {\r\n SceneLoader.RegisterPlugin(new STLFileLoader());\r\n}\r\n","/* eslint-disable import/no-internal-modules */\r\nimport * as Loaders from \"loaders/STL/index\";\r\n\r\n/**\r\n * This is the entry point for the UMD module.\r\n * The entry point for a future ESM package should be index.ts\r\n */\r\nconst globalObject = typeof global !== \"undefined\" ? global : typeof window !== \"undefined\" ? window : undefined;\r\nif (typeof globalObject !== \"undefined\") {\r\n for (const key in Loaders) {\r\n if (!(<any>globalObject).BABYLON[key]) {\r\n (<any>globalObject).BABYLON[key] = (<any>Loaders)[key];\r\n }\r\n }\r\n}\r\n\r\nexport * from \"loaders/STL/index\";\r\n","import * as loaders from \"@lts/loaders/legacy/legacy-stlFileLoader\";\r\nexport { loaders };\r\nexport default loaders;\r\n"],"names":["root","factory","exports","module","require","define","amd","self","global","this","__WEBPACK_EXTERNAL_MODULE__520__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","g","globalThis","Function","e","window","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","solidPattern","facetsPattern","normalPattern","vertexPattern","name","extensions","isBinary","importMesh","meshesNames","scene","data","rootUrl","meshes","matches","_isBinary","babylonMesh","Mesh","_parseBinary","push","array_buffer","Uint8Array","str","i","byteLength","String","fromCharCode","exec","meshName","meshNameFromEnd","Tools","Error","Array","indexOf","_parseASCII","load","loadAssetContainer","container","AssetContainer","_blockEntityCollection","reader","DataView","getUint32","ascii","off","getUint8","mesh","faces","offset","positions","Float32Array","normals","indices","Uint32Array","indicesCount","face","start","normalX","getFloat32","normalY","normalZ","vertexstart","STLFileLoader","DO_NOT_ALTER_FILE_COORDINATES","setVerticesData","VertexBuffer","PositionKind","NormalKind","setIndices","computeWorldMatrix","solidData","facet","normalMatches","lastIndex","normal","Number","vertexMatch","SceneLoader","RegisterPlugin","globalObject","BABYLON"],"sourceRoot":""}
1
+ {"version":3,"file":"babylon.stlFileLoader.min.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,EAAQG,QAAQ,cACR,mBAAXC,QAAyBA,OAAOC,IAC9CD,OAAO,oBAAqB,CAAC,aAAcJ,GACjB,iBAAZC,QACdA,QAAQ,qBAAuBD,EAAQG,QAAQ,cAE/CJ,EAAc,QAAIC,EAAQD,EAAc,QACzC,CATD,CASoB,oBAATO,KAAuBA,KAAyB,oBAAXC,OAAyBA,OAASC,MAAQC,G,kCCT1FP,EAAOD,QAAUQ,C,GCCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaZ,QAGrB,IAAIC,EAASQ,EAAyBE,GAAY,CAGjDX,QAAS,CAAC,GAOX,OAHAc,EAAoBH,GAAUV,EAAQA,EAAOD,QAASU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inition","webpack://LOADERS/external umd {\"root\":\"BABYLON\",\"commonjs\":\"babylonjs\",\"commonjs2\":\"babylonjs\",\"amd\":\"babylonjs\"}","webpack://LOADERS/webpack/bootstrap","webpack://LOADERS/webpack/runtime/define property getters","webpack://LOADERS/webpack/runtime/global","webpack://LOADERS/webpack/runtime/hasOwnProperty shorthand","webpack://LOADERS/webpack/runtime/make namespace object","webpack://LOADERS/../../../dev/loaders/src/STL/stlFileLoader.ts","webpack://LOADERS/../../../lts/loaders/src/legacy/legacy-stlFileLoader.ts","webpack://LOADERS/./src/stlFileLoader.ts"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"babylonjs\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"babylonjs-loaders\", [\"babylonjs\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"babylonjs-loaders\"] = factory(require(\"babylonjs\"));\n\telse\n\t\troot[\"LOADERS\"] = factory(root[\"BABYLON\"]);\n})((typeof self !== \"undefined\" ? self : typeof global !== \"undefined\" ? global : this), (__WEBPACK_EXTERNAL_MODULE__520__) => {\nreturn ","module.exports = __WEBPACK_EXTERNAL_MODULE__520__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type { Nullable } from \"core/types\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport type { ISceneLoaderPlugin, ISceneLoaderPluginExtensions } from \"core/Loading/sceneLoader\";\r\nimport { SceneLoader } from \"core/Loading/sceneLoader\";\r\nimport { AssetContainer } from \"core/assetContainer\";\r\nimport type { Scene } from \"core/scene\";\r\n\r\n/**\r\n * STL file type loader.\r\n * This is a babylon scene loader plugin.\r\n */\r\nexport class STLFileLoader implements ISceneLoaderPlugin {\r\n /** @internal */\r\n public solidPattern = /solid (\\S*)([\\S\\s]*?)endsolid[ ]*(\\S*)/g;\r\n\r\n /** @internal */\r\n public facetsPattern = /facet([\\s\\S]*?)endfacet/g;\r\n /** @internal */\r\n public normalPattern = /normal[\\s]+([-+]?[0-9]+\\.?[0-9]*([eE][-+]?[0-9]+)?)+[\\s]+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)+[\\s]+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)+/g;\r\n /** @internal */\r\n public vertexPattern = /vertex[\\s]+([-+]?[0-9]+\\.?[0-9]*([eE][-+]?[0-9]+)?)+[\\s]+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)+[\\s]+([-+]?[0-9]*\\.?[0-9]+([eE][-+]?[0-9]+)?)+/g;\r\n\r\n /**\r\n * Defines the name of the plugin.\r\n */\r\n public name = \"stl\";\r\n\r\n /**\r\n * Defines the extensions the stl loader is able to load.\r\n * force data to come in as an ArrayBuffer\r\n * we'll convert to string if it looks like it's an ASCII .stl\r\n */\r\n public extensions: ISceneLoaderPluginExtensions = {\r\n \".stl\": { isBinary: true },\r\n };\r\n\r\n /**\r\n * Defines if Y and Z axes are swapped or not when loading an STL file.\r\n * The default is false to maintain backward compatibility. When set to\r\n * true, coordinates from the STL file are used without change.\r\n */\r\n public static DO_NOT_ALTER_FILE_COORDINATES = false;\r\n\r\n /**\r\n * Import meshes into a scene.\r\n * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported\r\n * @param scene The scene to import into\r\n * @param data The data to import\r\n * @param rootUrl The root url for scene and resources\r\n * @param meshes The meshes array to import into\r\n * @returns True if successful or false otherwise\r\n */\r\n public importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>): boolean {\r\n let matches;\r\n\r\n if (typeof data !== \"string\") {\r\n if (this._isBinary(data)) {\r\n // binary .stl\r\n const babylonMesh = new Mesh(\"stlmesh\", scene);\r\n this._parseBinary(babylonMesh, data);\r\n if (meshes) {\r\n meshes.push(babylonMesh);\r\n }\r\n return true;\r\n }\r\n\r\n // ASCII .stl\r\n\r\n // convert to string\r\n data = new TextDecoder().decode(new Uint8Array(data));\r\n }\r\n\r\n //if arrived here, data is a string, containing the STLA data.\r\n\r\n while ((matches = this.solidPattern.exec(data))) {\r\n let meshName = matches[1];\r\n const meshNameFromEnd = matches[3];\r\n if (meshNameFromEnd && meshName != meshNameFromEnd) {\r\n Tools.Error(\"Error in STL, solid name != endsolid name\");\r\n return false;\r\n }\r\n\r\n // check meshesNames\r\n if (meshesNames && meshName) {\r\n if (meshesNames instanceof Array) {\r\n if (!meshesNames.indexOf(meshName)) {\r\n continue;\r\n }\r\n } else {\r\n if (meshName !== meshesNames) {\r\n continue;\r\n }\r\n }\r\n }\r\n\r\n // stl mesh name can be empty as well\r\n meshName = meshName || \"stlmesh\";\r\n\r\n const babylonMesh = new Mesh(meshName, scene);\r\n this._parseASCII(babylonMesh, matches[2]);\r\n if (meshes) {\r\n meshes.push(babylonMesh);\r\n }\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /**\r\n * Load into a scene.\r\n * @param scene The scene to load into\r\n * @param data The data to import\r\n * @param rootUrl The root url for scene and resources\r\n * @returns true if successful or false otherwise\r\n */\r\n public load(scene: Scene, data: any, rootUrl: string): boolean {\r\n const result = this.importMesh(null, scene, data, rootUrl, null);\r\n return result;\r\n }\r\n\r\n /**\r\n * Load into an asset container.\r\n * @param scene The scene to load into\r\n * @param data The data to import\r\n * @param rootUrl The root url for scene and resources\r\n * @returns The loaded asset container\r\n */\r\n public loadAssetContainer(scene: Scene, data: string, rootUrl: string): AssetContainer {\r\n const container = new AssetContainer(scene);\r\n scene._blockEntityCollection = true;\r\n this.importMesh(null, scene, data, rootUrl, container.meshes);\r\n scene._blockEntityCollection = false;\r\n return container;\r\n }\r\n\r\n private _isBinary(data: any) {\r\n // check if file size is correct for binary stl\r\n const reader = new DataView(data);\r\n\r\n // A Binary STL header is 80 bytes, if the data size is not great than\r\n // that then it's not a binary STL.\r\n if (reader.byteLength <= 80) {\r\n return false;\r\n }\r\n\r\n const faceSize = (32 / 8) * 3 + (32 / 8) * 3 * 3 + 16 / 8;\r\n const nFaces = reader.getUint32(80, true);\r\n\r\n if (80 + 32 / 8 + nFaces * faceSize === reader.byteLength) {\r\n return true;\r\n }\r\n\r\n // US-ASCII begin with 's', 'o', 'l', 'i', 'd'\r\n const ascii = [115, 111, 108, 105, 100];\r\n for (let off = 0; off < 5; off++) {\r\n if (reader.getUint8(off) !== ascii[off]) {\r\n return true;\r\n }\r\n }\r\n\r\n return false;\r\n }\r\n\r\n private _parseBinary(mesh: Mesh, data: ArrayBuffer) {\r\n const reader = new DataView(data);\r\n const faces = reader.getUint32(80, true);\r\n\r\n const dataOffset = 84;\r\n const faceLength = 12 * 4 + 2;\r\n\r\n let offset = 0;\r\n\r\n const positions = new Float32Array(faces * 3 * 3);\r\n const normals = new Float32Array(faces * 3 * 3);\r\n const indices = new Uint32Array(faces * 3);\r\n let indicesCount = 0;\r\n\r\n for (let face = 0; face < faces; face++) {\r\n const start = dataOffset + face * faceLength;\r\n const normalX = reader.getFloat32(start, true);\r\n const normalY = reader.getFloat32(start + 4, true);\r\n const normalZ = reader.getFloat32(start + 8, true);\r\n\r\n for (let i = 1; i <= 3; i++) {\r\n const vertexstart = start + i * 12;\r\n\r\n // ordering is intentional to match ascii import\r\n positions[offset] = reader.getFloat32(vertexstart, true);\r\n normals[offset] = normalX;\r\n\r\n if (!STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\r\n positions[offset + 2] = reader.getFloat32(vertexstart + 4, true);\r\n positions[offset + 1] = reader.getFloat32(vertexstart + 8, true);\r\n\r\n normals[offset + 2] = normalY;\r\n normals[offset + 1] = normalZ;\r\n } else {\r\n positions[offset + 1] = reader.getFloat32(vertexstart + 4, true);\r\n positions[offset + 2] = reader.getFloat32(vertexstart + 8, true);\r\n\r\n normals[offset + 1] = normalY;\r\n normals[offset + 2] = normalZ;\r\n }\r\n\r\n offset += 3;\r\n }\r\n\r\n if (STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\r\n indices[indicesCount] = indicesCount;\r\n indices[indicesCount + 1] = indicesCount + 2;\r\n indices[indicesCount + 2] = indicesCount + 1;\r\n indicesCount += 3;\r\n } else {\r\n indices[indicesCount] = indicesCount++;\r\n indices[indicesCount] = indicesCount++;\r\n indices[indicesCount] = indicesCount++;\r\n }\r\n }\r\n\r\n mesh.setVerticesData(VertexBuffer.PositionKind, positions);\r\n mesh.setVerticesData(VertexBuffer.NormalKind, normals);\r\n mesh.setIndices(indices);\r\n mesh.computeWorldMatrix(true);\r\n }\r\n\r\n private _parseASCII(mesh: Mesh, solidData: string) {\r\n const positions = [];\r\n const normals = [];\r\n const indices = [];\r\n let indicesCount = 0;\r\n\r\n //load facets, ignoring loop as the standard doesn't define it can contain more than vertices\r\n let matches;\r\n while ((matches = this.facetsPattern.exec(solidData))) {\r\n const facet = matches[1];\r\n //one normal per face\r\n const normalMatches = this.normalPattern.exec(facet);\r\n this.normalPattern.lastIndex = 0;\r\n if (!normalMatches) {\r\n continue;\r\n }\r\n const normal = [Number(normalMatches[1]), Number(normalMatches[5]), Number(normalMatches[3])];\r\n\r\n let vertexMatch;\r\n while ((vertexMatch = this.vertexPattern.exec(facet))) {\r\n if (!STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\r\n positions.push(Number(vertexMatch[1]), Number(vertexMatch[5]), Number(vertexMatch[3]));\r\n normals.push(normal[0], normal[1], normal[2]);\r\n } else {\r\n positions.push(Number(vertexMatch[1]), Number(vertexMatch[3]), Number(vertexMatch[5]));\r\n\r\n // Flipping the second and third component because inverted\r\n // when normal was declared.\r\n normals.push(normal[0], normal[2], normal[1]);\r\n }\r\n }\r\n if (STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\r\n indices.push(indicesCount, indicesCount + 2, indicesCount + 1);\r\n indicesCount += 3;\r\n } else {\r\n indices.push(indicesCount++, indicesCount++, indicesCount++);\r\n }\r\n this.vertexPattern.lastIndex = 0;\r\n }\r\n\r\n this.facetsPattern.lastIndex = 0;\r\n mesh.setVerticesData(VertexBuffer.PositionKind, positions);\r\n mesh.setVerticesData(VertexBuffer.NormalKind, normals);\r\n mesh.setIndices(indices);\r\n mesh.computeWorldMatrix(true);\r\n }\r\n}\r\n\r\nif (SceneLoader) {\r\n SceneLoader.RegisterPlugin(new STLFileLoader());\r\n}\r\n","/* eslint-disable import/no-internal-modules */\r\nimport * as Loaders from \"loaders/STL/index\";\r\n\r\n/**\r\n * This is the entry point for the UMD module.\r\n * The entry point for a future ESM package should be index.ts\r\n */\r\nconst globalObject = typeof global !== \"undefined\" ? global : typeof window !== \"undefined\" ? window : undefined;\r\nif (typeof globalObject !== \"undefined\") {\r\n for (const key in Loaders) {\r\n if (!(<any>globalObject).BABYLON[key]) {\r\n (<any>globalObject).BABYLON[key] = (<any>Loaders)[key];\r\n }\r\n }\r\n}\r\n\r\nexport * from \"loaders/STL/index\";\r\n","import * as loaders from \"@lts/loaders/legacy/legacy-stlFileLoader\";\r\nexport { loaders };\r\nexport default loaders;\r\n"],"names":["root","factory","exports","module","require","define","amd","self","global","this","__WEBPACK_EXTERNAL_MODULE__520__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","d","definition","key","o","Object","defineProperty","enumerable","get","g","globalThis","Function","e","window","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","solidPattern","facetsPattern","normalPattern","vertexPattern","name","extensions","isBinary","importMesh","meshesNames","scene","data","rootUrl","meshes","matches","_isBinary","babylonMesh","Mesh","_parseBinary","push","TextDecoder","decode","Uint8Array","exec","meshName","meshNameFromEnd","Tools","Error","Array","indexOf","_parseASCII","load","loadAssetContainer","container","AssetContainer","_blockEntityCollection","reader","DataView","byteLength","getUint32","ascii","off","getUint8","mesh","faces","offset","positions","Float32Array","normals","indices","Uint32Array","indicesCount","face","start","normalX","getFloat32","normalY","normalZ","i","vertexstart","STLFileLoader","DO_NOT_ALTER_FILE_COORDINATES","setVerticesData","VertexBuffer","PositionKind","NormalKind","setIndices","computeWorldMatrix","solidData","facet","normalMatches","lastIndex","normal","Number","vertexMatch","SceneLoader","RegisterPlugin","globalObject","BABYLON"],"sourceRoot":""}
@@ -1069,6 +1069,10 @@ declare module BABYLON.GLTF2.Loader.Extensions {
1069
1069
  * Defines whether this extension is enabled.
1070
1070
  */
1071
1071
  enabled: boolean;
1072
+ /**
1073
+ * Defines whether to use the normalized flag from the glTF accessor instead of the Draco data. Defaults to true.
1074
+ */
1075
+ useNormalizedFlagFromAccessor: boolean;
1072
1076
  private _loader;
1073
1077
  /**
1074
1078
  * @internal
@@ -1982,6 +1986,13 @@ declare module BABYLON.GLTF2 {
1982
1986
  * @returns The array item
1983
1987
  */
1984
1988
  static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
1989
+ /**
1990
+ * Gets an item from the given array or returns null if not available.
1991
+ * @param array The array to get the item from
1992
+ * @param index The index to the array
1993
+ * @returns The array item or null
1994
+ */
1995
+ static TryGet<T>(array: ArrayLike<T> | undefined, index: number | undefined): Nullable<T>;
1985
1996
  /**
1986
1997
  * Assign an `index` field to each item of the given array.
1987
1998
  * @param array The array of items
@@ -1432,12 +1432,7 @@ var STLFileLoader = /** @class */ (function () {
1432
1432
  }
1433
1433
  // ASCII .stl
1434
1434
  // convert to string
1435
- var array_buffer = new Uint8Array(data);
1436
- var str = "";
1437
- for (var i = 0; i < data.byteLength; i++) {
1438
- str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian
1439
- }
1440
- data = str;
1435
+ data = new TextDecoder().decode(new Uint8Array(data));
1441
1436
  }
1442
1437
  //if arrived here, data is a string, containing the STLA data.
1443
1438
  while ((matches = this.solidPattern.exec(data))) {
@@ -4899,13 +4894,12 @@ __webpack_require__.r(__webpack_exports__);
4899
4894
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
4900
4895
  /* harmony export */ KHR_draco_mesh_compression: () => (/* binding */ KHR_draco_mesh_compression)
4901
4896
  /* harmony export */ });
4902
- /* harmony import */ var babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Meshes/geometry */ "babylonjs/Misc/observable");
4897
+ /* harmony import */ var babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! babylonjs/Buffers/buffer */ "babylonjs/Misc/observable");
4903
4898
  /* harmony import */ var babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__);
4904
4899
  /* harmony import */ var _glTFLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../glTFLoader */ "../../../dev/loaders/src/glTF/2.0/glTFLoader.ts");
4905
4900
 
4906
4901
 
4907
4902
 
4908
-
4909
4903
  var NAME = "KHR_draco_mesh_compression";
4910
4904
  /**
4911
4905
  * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_draco_mesh_compression/README.md)
@@ -4920,6 +4914,10 @@ var KHR_draco_mesh_compression = /** @class */ (function () {
4920
4914
  * The name of this extension.
4921
4915
  */
4922
4916
  this.name = NAME;
4917
+ /**
4918
+ * Defines whether to use the normalized flag from the glTF accessor instead of the Draco data. Defaults to true.
4919
+ */
4920
+ this.useNormalizedFlagFromAccessor = true;
4923
4921
  this._loader = loader;
4924
4922
  this.enabled = babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME);
4925
4923
  }
@@ -4944,36 +4942,23 @@ var KHR_draco_mesh_compression = /** @class */ (function () {
4944
4942
  }
4945
4943
  }
4946
4944
  var attributes = {};
4947
- var dividers = {};
4945
+ var normalized = {};
4948
4946
  var loadAttribute = function (name, kind) {
4949
4947
  var uniqueId = extension.attributes[name];
4950
- if (uniqueId === undefined || primitive.attributes[name] === undefined) {
4948
+ if (uniqueId == undefined) {
4951
4949
  return;
4952
4950
  }
4953
- attributes[kind] = uniqueId;
4954
- var accessor = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.Get("".concat(context, "/attributes/").concat(name), _this._loader.gltf.accessors, primitive.attributes[name]);
4955
- if (accessor.normalized && accessor.componentType !== 5126 /* AccessorComponentType.FLOAT */) {
4956
- var divider = 1;
4957
- switch (accessor.componentType) {
4958
- case 5120 /* AccessorComponentType.BYTE */:
4959
- divider = 127.0;
4960
- break;
4961
- case 5121 /* AccessorComponentType.UNSIGNED_BYTE */:
4962
- divider = 255.0;
4963
- break;
4964
- case 5122 /* AccessorComponentType.SHORT */:
4965
- divider = 32767.0;
4966
- break;
4967
- case 5123 /* AccessorComponentType.UNSIGNED_SHORT */:
4968
- divider = 65535.0;
4969
- break;
4970
- }
4971
- dividers[kind] = divider;
4972
- }
4973
4951
  babylonMesh._delayInfo = babylonMesh._delayInfo || [];
4974
4952
  if (babylonMesh._delayInfo.indexOf(kind) === -1) {
4975
4953
  babylonMesh._delayInfo.push(kind);
4976
4954
  }
4955
+ attributes[kind] = uniqueId;
4956
+ if (_this.useNormalizedFlagFromAccessor) {
4957
+ var accessor = _glTFLoader__WEBPACK_IMPORTED_MODULE_1__.ArrayItem.TryGet(_this._loader.gltf.accessors, primitive.attributes[name]);
4958
+ if (accessor) {
4959
+ normalized[kind] = accessor.normalized || false;
4960
+ }
4961
+ }
4977
4962
  };
4978
4963
  loadAttribute("POSITION", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind);
4979
4964
  loadAttribute("NORMAL", babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.NormalKind);
@@ -4991,14 +4976,7 @@ var KHR_draco_mesh_compression = /** @class */ (function () {
4991
4976
  if (!bufferView._dracoBabylonGeometry) {
4992
4977
  bufferView._dracoBabylonGeometry = _this._loader.loadBufferViewAsync("/bufferViews/".concat(bufferView.index), bufferView).then(function (data) {
4993
4978
  var dracoCompression = _this.dracoCompression || babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.DracoCompression.Default;
4994
- return dracoCompression
4995
- .decodeMeshAsync(data, attributes, dividers)
4996
- .then(function (babylonVertexData) {
4997
- var babylonGeometry = new babylonjs_Meshes_Compression_dracoCompression__WEBPACK_IMPORTED_MODULE_0__.Geometry(babylonMesh.name, _this._loader.babylonScene);
4998
- babylonVertexData.applyToGeometry(babylonGeometry);
4999
- return babylonGeometry;
5000
- })
5001
- .catch(function (error) {
4979
+ return dracoCompression._decodeMeshToGeometryForGltfAsync(babylonMesh.name, _this._loader.babylonScene, data, attributes, normalized).catch(function (error) {
5002
4980
  throw new Error("".concat(context, ": ").concat(error.message));
5003
4981
  });
5004
4982
  });
@@ -7818,6 +7796,18 @@ var ArrayItem = /** @class */ (function () {
7818
7796
  }
7819
7797
  return array[index];
7820
7798
  };
7799
+ /**
7800
+ * Gets an item from the given array or returns null if not available.
7801
+ * @param array The array to get the item from
7802
+ * @param index The index to the array
7803
+ * @returns The array item or null
7804
+ */
7805
+ ArrayItem.TryGet = function (array, index) {
7806
+ if (!array || index == undefined || !array[index]) {
7807
+ return null;
7808
+ }
7809
+ return array[index];
7810
+ };
7821
7811
  /**
7822
7812
  * Assign an `index` field to each item of the given array.
7823
7813
  * @param array The array of items
@@ -8588,15 +8578,15 @@ var GLTFLoader = /** @class */ (function () {
8588
8578
  babylonGeometry.setIndices(data);
8589
8579
  }));
8590
8580
  }
8591
- var loadAttribute = function (attribute, kind, callback) {
8592
- if (attributes[attribute] == undefined) {
8581
+ var loadAttribute = function (name, kind, callback) {
8582
+ if (attributes[name] == undefined) {
8593
8583
  return;
8594
8584
  }
8595
8585
  babylonMesh._delayInfo = babylonMesh._delayInfo || [];
8596
8586
  if (babylonMesh._delayInfo.indexOf(kind) === -1) {
8597
8587
  babylonMesh._delayInfo.push(kind);
8598
8588
  }
8599
- var accessor = ArrayItem.Get("".concat(context, "/attributes/").concat(attribute), _this._gltf.accessors, attributes[attribute]);
8589
+ var accessor = ArrayItem.Get("".concat(context, "/attributes/").concat(name), _this._gltf.accessors, attributes[name]);
8600
8590
  promises.push(_this._loadVertexAccessorAsync("/accessors/".concat(accessor.index), accessor, kind).then(function (babylonVertexBuffer) {
8601
8591
  var _a, _b;
8602
8592
  if (babylonVertexBuffer.getKind() === babylonjs_Misc_deferred__WEBPACK_IMPORTED_MODULE_0__.VertexBuffer.PositionKind && !_this.parent.alwaysComputeBoundingBox && !babylonMesh.skeleton) {