@babylonjs/loaders 5.0.0-rc.4 → 5.0.0-rc.7
Sign up to get free protection for your applications and to get access to all the features.
- package/OBJ/index.js.map +1 -1
- package/OBJ/mtlFileLoader.d.ts +7 -6
- package/OBJ/mtlFileLoader.js +15 -14
- package/OBJ/mtlFileLoader.js.map +1 -1
- package/OBJ/objFileLoader.d.ts +11 -18
- package/OBJ/objFileLoader.js +19 -23
- package/OBJ/objFileLoader.js.map +1 -1
- package/OBJ/objLoadingOptions.d.ts +1 -1
- package/OBJ/objLoadingOptions.js.map +1 -1
- package/OBJ/solidParser.d.ts +6 -5
- package/OBJ/solidParser.js +15 -21
- package/OBJ/solidParser.js.map +1 -1
- package/STL/index.js.map +1 -1
- package/STL/stlFileLoader.d.ts +7 -14
- package/STL/stlFileLoader.js +15 -21
- package/STL/stlFileLoader.js.map +1 -1
- package/glTF/1.0/glTFBinaryExtension.d.ts +4 -4
- package/glTF/1.0/glTFBinaryExtension.js +4 -5
- package/glTF/1.0/glTFBinaryExtension.js.map +1 -1
- package/glTF/1.0/glTFLoader.d.ts +80 -50
- package/glTF/1.0/glTFLoader.js +265 -146
- package/glTF/1.0/glTFLoader.js.map +1 -1
- package/glTF/1.0/glTFLoaderInterfaces.d.ts +10 -10
- package/glTF/1.0/glTFLoaderInterfaces.js +3 -3
- package/glTF/1.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/1.0/glTFLoaderUtils.d.ts +25 -25
- package/glTF/1.0/glTFLoaderUtils.js +70 -52
- package/glTF/1.0/glTFLoaderUtils.js.map +1 -1
- package/glTF/1.0/glTFMaterialsCommonExtension.d.ts +2 -2
- package/glTF/1.0/glTFMaterialsCommonExtension.js +13 -11
- package/glTF/1.0/glTFMaterialsCommonExtension.js.map +1 -1
- package/glTF/1.0/index.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_lights_image_based.d.ts +11 -4
- package/glTF/2.0/Extensions/EXT_lights_image_based.js +9 -2
- package/glTF/2.0/Extensions/EXT_lights_image_based.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.d.ts +13 -5
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js +12 -4
- package/glTF/2.0/Extensions/EXT_mesh_gpu_instancing.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_meshopt_compression.d.ts +10 -3
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js +10 -3
- package/glTF/2.0/Extensions/EXT_meshopt_compression.js.map +1 -1
- package/glTF/2.0/Extensions/EXT_texture_webp.d.ts +12 -4
- package/glTF/2.0/Extensions/EXT_texture_webp.js +11 -3
- package/glTF/2.0/Extensions/EXT_texture_webp.js.map +1 -1
- package/glTF/2.0/Extensions/ExtrasAsMetadata.d.ts +26 -8
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js +22 -4
- package/glTF/2.0/Extensions/ExtrasAsMetadata.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.d.ts +14 -6
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +17 -6
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_lights_punctual.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_lights_punctual.js +11 -3
- package/glTF/2.0/Extensions/KHR_lights_punctual.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_clearcoat.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_emissive_strength.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_ior.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_ior.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_ior.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_pbrSpecularGlossiness.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_sheen.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_sheen.js +11 -3
- package/glTF/2.0/Extensions/KHR_materials_sheen.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_specular.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_specular.js +11 -3
- package/glTF/2.0/Extensions/KHR_materials_specular.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_translucency.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_translucency.js +11 -4
- package/glTF/2.0/Extensions/KHR_materials_translucency.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_transmission.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_transmission.js +24 -13
- package/glTF/2.0/Extensions/KHR_materials_transmission.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_unlit.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_unlit.js +10 -2
- package/glTF/2.0/Extensions/KHR_materials_unlit.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_variants.d.ts +17 -6
- package/glTF/2.0/Extensions/KHR_materials_variants.js +19 -8
- package/glTF/2.0/Extensions/KHR_materials_variants.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_materials_volume.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_materials_volume.js +12 -5
- package/glTF/2.0/Extensions/KHR_materials_volume.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_mesh_quantization.d.ts +4 -1
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js +5 -3
- package/glTF/2.0/Extensions/KHR_mesh_quantization.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_basisu.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_texture_basisu.js +11 -3
- package/glTF/2.0/Extensions/KHR_texture_basisu.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_texture_transform.d.ts +12 -4
- package/glTF/2.0/Extensions/KHR_texture_transform.js +10 -2
- package/glTF/2.0/Extensions/KHR_texture_transform.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.d.ts +4 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js +4 -1
- package/glTF/2.0/Extensions/KHR_xmp_json_ld.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_audio_emitter.d.ts +23 -7
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js +38 -14
- package/glTF/2.0/Extensions/MSFT_audio_emitter.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_lod.d.ts +45 -11
- package/glTF/2.0/Extensions/MSFT_lod.js +44 -8
- package/glTF/2.0/Extensions/MSFT_lod.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.d.ts +2 -2
- package/glTF/2.0/Extensions/MSFT_minecraftMesh.js.map +1 -1
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.d.ts +2 -2
- package/glTF/2.0/Extensions/MSFT_sRGBFactors.js.map +1 -1
- package/glTF/2.0/Extensions/index.js.map +1 -1
- package/glTF/2.0/glTFLoader.d.ts +70 -22
- package/glTF/2.0/glTFLoader.js +170 -85
- package/glTF/2.0/glTFLoader.js.map +1 -1
- package/glTF/2.0/glTFLoaderExtension.d.ts +11 -11
- package/glTF/2.0/glTFLoaderExtension.js.map +1 -1
- package/glTF/2.0/glTFLoaderInterfaces.d.ts +7 -7
- package/glTF/2.0/glTFLoaderInterfaces.js.map +1 -1
- package/glTF/2.0/index.js.map +1 -1
- package/glTF/glTFFileLoader.d.ts +79 -27
- package/glTF/glTFFileLoader.js +94 -45
- package/glTF/glTFFileLoader.js.map +1 -1
- package/glTF/glTFValidation.d.ts +1 -1
- package/glTF/glTFValidation.js +12 -12
- package/glTF/glTFValidation.js.map +1 -1
- package/glTF/index.js.map +1 -1
- package/index.js.map +1 -1
- package/legacy/legacy-glTF.d.ts +2 -2
- package/legacy/legacy-glTF.js +5 -5
- package/legacy/legacy-glTF.js.map +1 -1
- package/legacy/legacy-glTF1.d.ts +1 -1
- package/legacy/legacy-glTF1.js +2 -2
- package/legacy/legacy-glTF1.js.map +1 -1
- package/legacy/legacy-glTF1FileLoader.js +1 -0
- package/legacy/legacy-glTF1FileLoader.js.map +1 -1
- package/legacy/legacy-glTF2.d.ts +1 -1
- package/legacy/legacy-glTF2.js +11 -11
- package/legacy/legacy-glTF2.js.map +1 -1
- package/legacy/legacy-glTF2FileLoader.js +1 -0
- package/legacy/legacy-glTF2FileLoader.js.map +1 -1
- package/legacy/legacy-glTFFileLoader.js +1 -0
- package/legacy/legacy-glTFFileLoader.js.map +1 -1
- package/legacy/legacy-objFileLoader.d.ts +1 -1
- package/legacy/legacy-objFileLoader.js +3 -3
- package/legacy/legacy-objFileLoader.js.map +1 -1
- package/legacy/legacy-stlFileLoader.d.ts +1 -1
- package/legacy/legacy-stlFileLoader.js +3 -3
- package/legacy/legacy-stlFileLoader.js.map +1 -1
- package/legacy/legacy.d.ts +1 -1
- package/legacy/legacy.js +2 -1
- package/legacy/legacy.js.map +1 -1
- package/package.json +23 -198
- package/readme.md +2 -2
package/STL/stlFileLoader.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"stlFileLoader.js","sourceRoot":"","sources":["../../../sourceES6/loaders/src/STL/stlFileLoader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAI9D,OAAO,EAAE,IAAI,EAAE,MAAM,6BAA6B,CAAC;AACnD,OAAO,EAAE,WAAW,EAAoD,MAAM,qCAAqC,CAAC;AACpH,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGhE;;;GAGG;AACH;IAAA;QA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,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;iBACjD;qBACI;oBAED,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;oBAEvF,2DAA2D;oBAC3D,4BAA4B;oBAC5B,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;iBACjD;aACJ;YACD,OAAO,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,EAAE,YAAY,EAAE,CAAC,CAAC;YAC7D,IAAI,CAAC,aAAa,CAAC,SAAS,GAAG,CAAC,CAAC;SACpC;QAED,IAAI,CAAC,aAAa,CAAC,SAAS,GAAG,CAAC,CAAC;QACjC,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;QAC3D,IAAI,CAAC,eAAe,CAAC,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;QACvD,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAtPD;;;;OAIG;IACW,2CAA6B,GAAG,KAAK,CAAC;IAkPxD,oBAAC;CAAA,AAjRD,IAiRC;SAjRY,aAAa;AAmR1B,IAAI,WAAW,EAAE;IACb,WAAW,CAAC,cAAc,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC;CACnD","sourcesContent":["import { Nullable } from \"@babylonjs/core/types\";\nimport { Tools } from \"@babylonjs/core/Misc/tools\";\nimport { VertexBuffer } from \"@babylonjs/core/Buffers/buffer\";\nimport { Skeleton } from \"@babylonjs/core/Bones/skeleton\";\nimport { IParticleSystem } from \"@babylonjs/core/Particles/IParticleSystem\";\nimport { AbstractMesh } from \"@babylonjs/core/Meshes/abstractMesh\";\nimport { Mesh } from \"@babylonjs/core/Meshes/mesh\";\nimport { SceneLoader, ISceneLoaderPlugin, ISceneLoaderPluginExtensions } from \"@babylonjs/core/Loading/sceneLoader\";\nimport { AssetContainer } from \"@babylonjs/core/assetContainer\";\nimport { Scene } from \"@babylonjs/core/scene\";\n\n/**\n * STL file type loader.\n * This is a babylon scene loader plugin.\n */\nexport class STLFileLoader implements ISceneLoaderPlugin {\n\n /** @hidden */\n public solidPattern = /solid (\\S*)([\\S\\s]*?)endsolid[ ]*(\\S*)/g;\n\n /** @hidden */\n public facetsPattern = /facet([\\s\\S]*?)endfacet/g;\n /** @hidden */\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;\n /** @hidden */\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;\n\n /**\n * Defines the name of the plugin.\n */\n public name = \"stl\";\n\n /**\n * Defines the extensions the stl loader is able to load.\n * force data to come in as an ArrayBuffer\n * we'll convert to string if it looks like it's an ASCII .stl\n */\n public extensions: ISceneLoaderPluginExtensions = {\n \".stl\": { isBinary: true },\n };\n\n /**\n * Defines if Y and Z axes are swapped or not when loading an STL file.\n * The default is false to maintain backward compatibility. When set to\n * true, coordinates from the STL file are used without change.\n */\n public static DO_NOT_ALTER_FILE_COORDINATES = false;\n\n /**\n * Import meshes into a scene.\n * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported\n * @param scene The scene to import into\n * @param data The data to import\n * @param rootUrl The root url for scene and resources\n * @param meshes The meshes array to import into\n * @param particleSystems The particle systems array to import into\n * @param skeletons The skeletons array to import into\n * @param onError The callback when import fails\n * @returns True if successful or false otherwise\n */\n public importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean {\n var matches;\n\n if (typeof data !== \"string\") {\n\n if (this._isBinary(data)) {\n // binary .stl\n var babylonMesh = new Mesh(\"stlmesh\", scene);\n this._parseBinary(babylonMesh, data);\n if (meshes) {\n meshes.push(babylonMesh);\n }\n return true;\n }\n\n // ASCII .stl\n\n // convert to string\n var array_buffer = new Uint8Array(data);\n var str = '';\n for (var i = 0; i < data.byteLength; i++) {\n str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian\n }\n data = str;\n }\n\n //if arrived here, data is a string, containing the STLA data.\n\n while (matches = this.solidPattern.exec(data)) {\n var meshName = matches[1];\n var meshNameFromEnd = matches[3];\n if (meshName != meshNameFromEnd) {\n Tools.Error(\"Error in STL, solid name != endsolid name\");\n return false;\n }\n\n // check meshesNames\n if (meshesNames && meshName) {\n if (meshesNames instanceof Array) {\n if (!meshesNames.indexOf(meshName)) {\n continue;\n }\n } else {\n if (meshName !== meshesNames) {\n continue;\n }\n }\n }\n\n // stl mesh name can be empty as well\n meshName = meshName || \"stlmesh\";\n\n var babylonMesh = new Mesh(meshName, scene);\n this._parseASCII(babylonMesh, matches[2]);\n if (meshes) {\n meshes.push(babylonMesh);\n }\n }\n\n return true;\n\n }\n\n /**\n * Load into a scene.\n * @param scene The scene to load into\n * @param data The data to import\n * @param rootUrl The root url for scene and resources\n * @param onError The callback when import fails\n * @returns true if successful or false otherwise\n */\n public load(scene: Scene, data: any, rootUrl: string): boolean {\n var result = this.importMesh(null, scene, data, rootUrl, null, null, null);\n return result;\n }\n\n /**\n * Load into an asset container.\n * @param scene The scene to load into\n * @param data The data to import\n * @param rootUrl The root url for scene and resources\n * @param onError The callback when import fails\n * @returns The loaded asset container\n */\n public loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer {\n var container = new AssetContainer(scene);\n scene._blockEntityCollection = true;\n this.importMesh(null, scene, data, rootUrl, container.meshes, null, null);\n scene._blockEntityCollection = false;\n return container;\n }\n\n private _isBinary(data: any) {\n\n // check if file size is correct for binary stl\n var faceSize, nFaces, reader;\n reader = new DataView(data);\n\n // A Binary STL header is 80 bytes, if the data size is not great than\n // that then it's not a binary STL.\n if (reader.byteLength <= 80) {\n return false;\n }\n\n faceSize = (32 / 8 * 3) + ((32 / 8 * 3) * 3) + (16 / 8);\n nFaces = reader.getUint32(80, true);\n\n if (80 + (32 / 8) + (nFaces * faceSize) === reader.byteLength) {\n return true;\n }\n\n // check characters higher than ASCII to confirm binary\n var fileLength = reader.byteLength;\n for (var index = 0; index < fileLength; index++) {\n if (reader.getUint8(index) > 127) {\n return true;\n }\n }\n\n return false;\n }\n\n private _parseBinary(mesh: Mesh, data: ArrayBuffer) {\n\n var reader = new DataView(data);\n var faces = reader.getUint32(80, true);\n\n var dataOffset = 84;\n var faceLength = 12 * 4 + 2;\n\n var offset = 0;\n\n var positions = new Float32Array(faces * 3 * 3);\n var normals = new Float32Array(faces * 3 * 3);\n var indices = new Uint32Array(faces * 3);\n var indicesCount = 0;\n\n for (var face = 0; face < faces; face++) {\n\n var start = dataOffset + face * faceLength;\n var normalX = reader.getFloat32(start, true);\n var normalY = reader.getFloat32(start + 4, true);\n var normalZ = reader.getFloat32(start + 8, true);\n\n for (var i = 1; i <= 3; i++) {\n\n var vertexstart = start + i * 12;\n\n // ordering is intentional to match ascii import\n positions[offset] = reader.getFloat32(vertexstart, true);\n normals[offset] = normalX;\n\n if (!STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\n\n positions[offset + 2] = reader.getFloat32(vertexstart + 4, true);\n positions[offset + 1] = reader.getFloat32(vertexstart + 8, true);\n\n normals[offset + 2] = normalY;\n normals[offset + 1] = normalZ;\n }\n else {\n\n positions[offset + 1] = reader.getFloat32(vertexstart + 4, true);\n positions[offset + 2] = reader.getFloat32(vertexstart + 8, true);\n\n normals[offset + 1] = normalY;\n normals[offset + 2] = normalZ;\n }\n\n offset += 3;\n }\n indices[indicesCount] = indicesCount++;\n indices[indicesCount] = indicesCount++;\n indices[indicesCount] = indicesCount++;\n }\n\n mesh.setVerticesData(VertexBuffer.PositionKind, positions);\n mesh.setVerticesData(VertexBuffer.NormalKind, normals);\n mesh.setIndices(indices);\n mesh.computeWorldMatrix(true);\n }\n\n private _parseASCII(mesh: Mesh, solidData: string) {\n\n var positions = [];\n var normals = [];\n var indices = [];\n var indicesCount = 0;\n\n //load facets, ignoring loop as the standard doesn't define it can contain more than vertices\n var matches;\n while (matches = this.facetsPattern.exec(solidData)) {\n var facet = matches[1];\n //one normal per face\n var normalMatches = this.normalPattern.exec(facet);\n this.normalPattern.lastIndex = 0;\n if (!normalMatches) {\n continue;\n }\n var normal = [Number(normalMatches[1]), Number(normalMatches[5]), Number(normalMatches[3])];\n\n var vertexMatch;\n while (vertexMatch = this.vertexPattern.exec(facet)) {\n\n if (!STLFileLoader.DO_NOT_ALTER_FILE_COORDINATES) {\n\n positions.push(Number(vertexMatch[1]), Number(vertexMatch[5]), Number(vertexMatch[3]));\n normals.push(normal[0], normal[1], normal[2]);\n }\n else {\n\n positions.push(Number(vertexMatch[1]), Number(vertexMatch[3]), Number(vertexMatch[5]));\n\n // Flipping the second and third component because inverted\n // when normal was declared.\n normals.push(normal[0], normal[2], normal[1]);\n }\n }\n indices.push(indicesCount++, indicesCount++, indicesCount++);\n this.vertexPattern.lastIndex = 0;\n }\n\n this.facetsPattern.lastIndex = 0;\n mesh.setVerticesData(VertexBuffer.PositionKind, positions);\n mesh.setVerticesData(VertexBuffer.NormalKind, normals);\n mesh.setIndices(indices);\n mesh.computeWorldMatrix(true);\n }\n}\n\nif (SceneLoader) {\n SceneLoader.RegisterPlugin(new STLFileLoader());\n}"]}
|
1
|
+
{"version":3,"file":"stlFileLoader.js","sourceRoot":"","sources":["../../../../../lts/loaders/generated/STL/stlFileLoader.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,sCAAwB;AACxC,OAAO,EAAE,YAAY,EAAE,0CAA4B;AAEnD,OAAO,EAAE,IAAI,EAAE,uCAAyB;AACxC,OAAO,EAAE,WAAW,EAAoD,+CAAiC;AACzG,OAAO,EAAE,cAAc,EAAE,0CAA4B;AAGrD;;;GAGG;AACH;IAAA;QACI,cAAc;QACP,iBAAY,GAAG,yCAAyC,CAAC;QAEhE,cAAc;QACP,kBAAa,GAAG,0BAA0B,CAAC;QAClD,cAAc;QACP,kBAAa,GAAG,mJAAmJ,CAAC;QAC3K,cAAc;QACP,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;IAqON,CAAC;IA5NG;;;;;;;;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,IAAI,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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IG;IACW,2CAA6B,GAAG,KAAK,CAAC;IA8NxD,oBAAC;CAAA,AA5PD,IA4PC;SA5PY,aAAa;AA8P1B,IAAI,WAAW,EAAE;IACb,WAAW,CAAC,cAAc,CAAC,IAAI,aAAa,EAAE,CAAC,CAAC;CACnD","sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\r\nimport { Nullable } from \"core/types\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport { SceneLoader, ISceneLoaderPlugin, ISceneLoaderPluginExtensions } from \"core/Loading/sceneLoader\";\r\nimport { AssetContainer } from \"core/assetContainer\";\r\nimport { 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 /** @hidden */\r\n public solidPattern = /solid (\\S*)([\\S\\s]*?)endsolid[ ]*(\\S*)/g;\r\n\r\n /** @hidden */\r\n public facetsPattern = /facet([\\s\\S]*?)endfacet/g;\r\n /** @hidden */\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 /** @hidden */\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 (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 // check characters higher than ASCII to confirm binary\r\n const fileLength = reader.byteLength;\r\n for (let index = 0; index < fileLength; index++) {\r\n if (reader.getUint8(index) > 127) {\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 indices[indicesCount] = indicesCount++;\r\n indices[indicesCount] = indicesCount++;\r\n indices[indicesCount] = indicesCount++;\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 indices.push(indicesCount++, indicesCount++, indicesCount++);\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"]}
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import { GLTFLoaderExtension } from "./glTFLoader";
|
2
|
-
import { Scene } from "@babylonjs/core/scene";
|
2
|
+
import { Scene } from "@babylonjs/core/scene.js";
|
3
3
|
import { IGLTFLoaderData } from "../glTFFileLoader";
|
4
4
|
import { IGLTFRuntime } from "./glTFLoaderInterfaces";
|
5
5
|
/** @hidden */
|
6
6
|
export declare class GLTFBinaryExtension extends GLTFLoaderExtension {
|
7
7
|
private _bin;
|
8
8
|
constructor();
|
9
|
-
loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void
|
9
|
+
loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void): boolean;
|
10
10
|
loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
|
11
|
-
loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void
|
12
|
-
loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void
|
11
|
+
loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void): boolean;
|
12
|
+
loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void): boolean;
|
13
13
|
}
|
@@ -1,8 +1,7 @@
|
|
1
1
|
import { __extends } from "tslib";
|
2
|
-
import { GLTFLoaderExtension } from "./glTFLoader.js";
|
2
|
+
import { GLTFLoaderExtension, GLTFLoader, GLTFLoaderBase } from "./glTFLoader.js";
|
3
3
|
import { GLTFUtils } from "./glTFLoaderUtils.js";
|
4
4
|
import { EComponentType } from "./glTFLoaderInterfaces.js";
|
5
|
-
import { GLTFLoader, GLTFLoaderBase } from "./glTFLoader.js";
|
6
5
|
var BinaryExtensionBufferName = "binary_glTF";
|
7
6
|
/** @hidden */
|
8
7
|
var GLTFBinaryExtension = /** @class */ (function (_super) {
|
@@ -10,7 +9,7 @@ var GLTFBinaryExtension = /** @class */ (function (_super) {
|
|
10
9
|
function GLTFBinaryExtension() {
|
11
10
|
return _super.call(this, "KHR_binary_glTF") || this;
|
12
11
|
}
|
13
|
-
GLTFBinaryExtension.prototype.loadRuntimeAsync = function (scene, data, rootUrl, onSuccess
|
12
|
+
GLTFBinaryExtension.prototype.loadRuntimeAsync = function (scene, data, rootUrl, onSuccess) {
|
14
13
|
var extensionsUsed = data.json.extensionsUsed;
|
15
14
|
if (!extensionsUsed || extensionsUsed.indexOf(this.name) === -1 || !data.bin) {
|
16
15
|
return false;
|
@@ -29,7 +28,7 @@ var GLTFBinaryExtension = /** @class */ (function (_super) {
|
|
29
28
|
this._bin.readAsync(0, this._bin.byteLength).then(onSuccess, function (error) { return onError(error.message); });
|
30
29
|
return true;
|
31
30
|
};
|
32
|
-
GLTFBinaryExtension.prototype.loadTextureBufferAsync = function (gltfRuntime, id, onSuccess
|
31
|
+
GLTFBinaryExtension.prototype.loadTextureBufferAsync = function (gltfRuntime, id, onSuccess) {
|
33
32
|
var texture = gltfRuntime.textures[id];
|
34
33
|
var source = gltfRuntime.images[texture.source];
|
35
34
|
if (!source.extensions || !(this.name in source.extensions)) {
|
@@ -41,7 +40,7 @@ var GLTFBinaryExtension = /** @class */ (function (_super) {
|
|
41
40
|
onSuccess(buffer);
|
42
41
|
return true;
|
43
42
|
};
|
44
|
-
GLTFBinaryExtension.prototype.loadShaderStringAsync = function (gltfRuntime, id, onSuccess
|
43
|
+
GLTFBinaryExtension.prototype.loadShaderStringAsync = function (gltfRuntime, id, onSuccess) {
|
45
44
|
var shader = gltfRuntime.shaders[id];
|
46
45
|
if (!shader.extensions || !(this.name in shader.extensions)) {
|
47
46
|
return false;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"glTFBinaryExtension.js","sourceRoot":"","sources":["
|
1
|
+
{"version":3,"file":"glTFBinaryExtension.js","sourceRoot":"","sources":["../../../../../../lts/loaders/generated/glTF/1.0/glTFBinaryExtension.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,mBAAmB,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG9C,OAAO,EAA2D,cAAc,EAAe,MAAM,wBAAwB,CAAC;AAI9H,IAAM,yBAAyB,GAAG,aAAa,CAAC;AAahD,cAAc;AACd;IAAyC,uCAAmB;IAGxD;eACI,kBAAM,iBAAiB,CAAC;IAC5B,CAAC;IAEM,8CAAgB,GAAvB,UAAwB,KAAY,EAAE,IAAqB,EAAE,OAAe,EAAE,SAA8C;QACxH,IAAM,cAAc,GAAS,IAAI,CAAC,IAAK,CAA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,CAAC,CAAC","sourcesContent":["import { GLTFLoaderExtension, GLTFLoader, GLTFLoaderBase } from \"./glTFLoader\";\r\nimport { GLTFUtils } from \"./glTFLoaderUtils\";\r\nimport { Scene } from \"core/scene\";\r\nimport { IGLTFLoaderData } from \"../glTFFileLoader\";\r\nimport { IGLTFRuntime, IGLTFTexture, IGLTFImage, IGLTFBufferView, EComponentType, IGLTFShader } from \"./glTFLoaderInterfaces\";\r\n\r\nimport { IDataBuffer } from \"core/Misc/dataReader\";\r\n\r\nconst BinaryExtensionBufferName = \"binary_glTF\";\r\n\r\ninterface IGLTFBinaryExtensionShader {\r\n bufferView: string;\r\n}\r\n\r\ninterface IGLTFBinaryExtensionImage {\r\n bufferView: string;\r\n mimeType: string;\r\n height: number;\r\n width: number;\r\n}\r\n\r\n/** @hidden */\r\nexport class GLTFBinaryExtension extends GLTFLoaderExtension {\r\n private _bin: IDataBuffer;\r\n\r\n public constructor() {\r\n super(\"KHR_binary_glTF\");\r\n }\r\n\r\n public loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void): boolean {\r\n const extensionsUsed = (<any>data.json).extensionsUsed;\r\n if (!extensionsUsed || extensionsUsed.indexOf(this.name) === -1 || !data.bin) {\r\n return false;\r\n }\r\n\r\n this._bin = data.bin;\r\n onSuccess(GLTFLoaderBase.CreateRuntime(data.json, scene, rootUrl));\r\n return true;\r\n }\r\n\r\n public loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean {\r\n if (gltfRuntime.extensionsUsed.indexOf(this.name) === -1) {\r\n return false;\r\n }\r\n\r\n if (id !== BinaryExtensionBufferName) {\r\n return false;\r\n }\r\n\r\n this._bin.readAsync(0, this._bin.byteLength).then(onSuccess, (error) => onError(error.message));\r\n return true;\r\n }\r\n\r\n public loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void): boolean {\r\n const texture: IGLTFTexture = gltfRuntime.textures[id];\r\n const source: IGLTFImage = gltfRuntime.images[texture.source];\r\n if (!source.extensions || !(this.name in source.extensions)) {\r\n return false;\r\n }\r\n\r\n const sourceExt: IGLTFBinaryExtensionImage = source.extensions[this.name];\r\n const bufferView: IGLTFBufferView = gltfRuntime.bufferViews[sourceExt.bufferView];\r\n const buffer = GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, EComponentType.UNSIGNED_BYTE);\r\n onSuccess(buffer);\r\n return true;\r\n }\r\n\r\n public loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void): boolean {\r\n const shader: IGLTFShader = gltfRuntime.shaders[id];\r\n if (!shader.extensions || !(this.name in shader.extensions)) {\r\n return false;\r\n }\r\n\r\n const binaryExtensionShader: IGLTFBinaryExtensionShader = shader.extensions[this.name];\r\n const bufferView: IGLTFBufferView = gltfRuntime.bufferViews[binaryExtensionShader.bufferView];\r\n const shaderBytes = GLTFUtils.GetBufferFromBufferView(gltfRuntime, bufferView, 0, bufferView.byteLength, EComponentType.UNSIGNED_BYTE);\r\n\r\n setTimeout(() => {\r\n const shaderString = GLTFUtils.DecodeBufferToText(shaderBytes);\r\n onSuccess(shaderString);\r\n });\r\n\r\n return true;\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(new GLTFBinaryExtension());\r\n"]}
|
package/glTF/1.0/glTFLoader.d.ts
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
import { IGLTFRuntime } from "./glTFLoaderInterfaces";
|
2
|
-
import { Nullable } from "@babylonjs/core/types";
|
3
|
-
import { Material } from "@babylonjs/core/Materials/material";
|
4
|
-
import { Texture } from "@babylonjs/core/Materials/Textures/texture";
|
5
|
-
import { ISceneLoaderAsyncResult, ISceneLoaderProgressEvent } from "@babylonjs/core/Loading/sceneLoader";
|
6
|
-
import { Scene } from "@babylonjs/core/scene";
|
2
|
+
import { Nullable } from "@babylonjs/core/types.js";
|
3
|
+
import { Material } from "@babylonjs/core/Materials/material.js";
|
4
|
+
import { Texture } from "@babylonjs/core/Materials/Textures/texture.js";
|
5
|
+
import { ISceneLoaderAsyncResult, ISceneLoaderProgressEvent } from "@babylonjs/core/Loading/sceneLoader.js";
|
6
|
+
import { Scene } from "@babylonjs/core/scene.js";
|
7
7
|
import { IGLTFLoader, IGLTFLoaderData } from "../glTFFileLoader";
|
8
|
-
import { AssetContainer } from "@babylonjs/core/assetContainer";
|
8
|
+
import { AssetContainer } from "@babylonjs/core/assetContainer.js";
|
9
9
|
/**
|
10
|
-
* Implementation of the base glTF spec
|
11
|
-
* @hidden
|
12
|
-
*/
|
10
|
+
* Implementation of the base glTF spec
|
11
|
+
* @hidden
|
12
|
+
*/
|
13
13
|
export declare class GLTFLoaderBase {
|
14
14
|
static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
|
15
15
|
static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
|
16
16
|
static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
|
17
|
-
static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void
|
17
|
+
static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void): void;
|
18
18
|
static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
|
19
19
|
static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
|
20
20
|
}
|
21
21
|
/**
|
22
|
-
* glTF V1 Loader
|
23
|
-
* @hidden
|
24
|
-
*/
|
22
|
+
* glTF V1 Loader
|
23
|
+
* @hidden
|
24
|
+
*/
|
25
25
|
export declare class GLTFLoader implements IGLTFLoader {
|
26
26
|
static Extensions: {
|
27
27
|
[name: string]: GLTFLoaderExtension;
|
@@ -30,25 +30,25 @@ export declare class GLTFLoader implements IGLTFLoader {
|
|
30
30
|
dispose(): void;
|
31
31
|
private _importMeshAsync;
|
32
32
|
/**
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
33
|
+
* Imports one or more meshes from a loaded gltf file and adds them to the scene
|
34
|
+
* @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
|
35
|
+
* @param scene the scene the meshes should be added to
|
36
|
+
* @param assetContainer defines the asset container to use (can be null)
|
37
|
+
* @param data gltf data containing information of the meshes in a loaded file
|
38
|
+
* @param rootUrl root url to load from
|
39
|
+
* @param onProgress event that fires when loading progress has occured
|
40
|
+
* @returns a promise containg the loaded meshes, particles, skeletons and animations
|
41
|
+
*/
|
42
42
|
importMeshAsync(meshesNames: any, scene: Scene, assetContainer: Nullable<AssetContainer>, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
|
43
43
|
private _loadAsync;
|
44
44
|
/**
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
* Imports all objects from a loaded gltf file and adds them to the scene
|
46
|
+
* @param scene the scene the objects should be added to
|
47
|
+
* @param data gltf data containing information of the meshes in a loaded file
|
48
|
+
* @param rootUrl root url to load from
|
49
|
+
* @param onProgress event that fires when loading progress has occured
|
50
|
+
* @returns a promise which completes when objects have been loaded to the scene
|
51
|
+
*/
|
52
52
|
loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
|
53
53
|
private _loadShadersAsync;
|
54
54
|
private _loadBuffersAsync;
|
@@ -60,39 +60,69 @@ export declare abstract class GLTFLoaderExtension {
|
|
60
60
|
constructor(name: string);
|
61
61
|
get name(): string;
|
62
62
|
/**
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
* Defines an override for loading the runtime
|
64
|
+
* Return true to stop further extensions from loading the runtime
|
65
|
+
* @param scene
|
66
|
+
* @param data
|
67
|
+
* @param rootUrl
|
68
|
+
* @param onSuccess
|
69
|
+
* @param onError
|
70
|
+
*/
|
66
71
|
loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
|
67
72
|
/**
|
68
73
|
* Defines an onverride for creating gltf runtime
|
69
74
|
* Return true to stop further extensions from creating the runtime
|
75
|
+
* @param gltfRuntime
|
76
|
+
* @param onSuccess
|
77
|
+
* @param onError
|
70
78
|
*/
|
71
79
|
loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
|
72
80
|
/**
|
73
|
-
|
74
|
-
|
75
|
-
|
81
|
+
* Defines an override for loading buffers
|
82
|
+
* Return true to stop further extensions from loading this buffer
|
83
|
+
* @param gltfRuntime
|
84
|
+
* @param id
|
85
|
+
* @param onSuccess
|
86
|
+
* @param onError
|
87
|
+
* @param onProgress
|
88
|
+
*/
|
76
89
|
loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
|
77
90
|
/**
|
78
|
-
|
79
|
-
|
80
|
-
|
91
|
+
* Defines an override for loading texture buffers
|
92
|
+
* Return true to stop further extensions from loading this texture data
|
93
|
+
* @param gltfRuntime
|
94
|
+
* @param id
|
95
|
+
* @param onSuccess
|
96
|
+
* @param onError
|
97
|
+
*/
|
81
98
|
loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
|
82
99
|
/**
|
83
|
-
|
84
|
-
|
85
|
-
|
100
|
+
* Defines an override for creating textures
|
101
|
+
* Return true to stop further extensions from loading this texture
|
102
|
+
* @param gltfRuntime
|
103
|
+
* @param id
|
104
|
+
* @param buffer
|
105
|
+
* @param onSuccess
|
106
|
+
* @param onError
|
107
|
+
*/
|
86
108
|
createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
|
87
109
|
/**
|
88
|
-
|
89
|
-
|
90
|
-
|
110
|
+
* Defines an override for loading shader strings
|
111
|
+
* Return true to stop further extensions from loading this shader data
|
112
|
+
* @param gltfRuntime
|
113
|
+
* @param id
|
114
|
+
* @param onSuccess
|
115
|
+
* @param onError
|
116
|
+
*/
|
91
117
|
loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
|
92
118
|
/**
|
93
|
-
|
94
|
-
|
95
|
-
|
119
|
+
* Defines an override for loading materials
|
120
|
+
* Return true to stop further extensions from loading this material
|
121
|
+
* @param gltfRuntime
|
122
|
+
* @param id
|
123
|
+
* @param onSuccess
|
124
|
+
* @param onError
|
125
|
+
*/
|
96
126
|
loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
|
97
127
|
static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
|
98
128
|
static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
|
@@ -100,7 +130,7 @@ export declare abstract class GLTFLoaderExtension {
|
|
100
130
|
static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
|
101
131
|
static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
|
102
132
|
static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
|
103
|
-
private static
|
104
|
-
private static
|
105
|
-
private static
|
133
|
+
private static _LoadTextureBufferAsync;
|
134
|
+
private static _CreateTextureAsync;
|
135
|
+
private static _ApplyExtensions;
|
106
136
|
}
|