@babylonjs/loaders 6.34.1 → 6.34.3
Sign up to get free protection for your applications and to get access to all the features.
- package/OBJ/solidParser.js +2 -1
- package/OBJ/solidParser.js.map +1 -1
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js +1 -5
- package/glTF/2.0/Extensions/KHR_draco_mesh_compression.js.map +1 -1
- package/glTF/glTFFileLoader.js +14 -8
- package/glTF/glTFFileLoader.js.map +1 -1
- package/glTF/glTFValidation.d.ts +1 -1
- package/glTF/glTFValidation.js +11 -5
- package/glTF/glTFValidation.js.map +1 -1
- package/package.json +3 -3
package/OBJ/solidParser.js
CHANGED
@@ -5,6 +5,7 @@ import { Vector2, Vector3 } from "@babylonjs/core/Maths/math.vector.js";
|
|
5
5
|
import { Geometry } from "@babylonjs/core/Meshes/geometry.js";
|
6
6
|
import { Mesh } from "@babylonjs/core/Meshes/mesh.js";
|
7
7
|
import { VertexData } from "@babylonjs/core/Meshes/mesh.vertexData.js";
|
8
|
+
import { Logger } from "@babylonjs/core/Misc/logger.js";
|
8
9
|
/**
|
9
10
|
* Class used to load mesh data from OBJ content
|
10
11
|
*/
|
@@ -551,7 +552,7 @@ export class SolidParser {
|
|
551
552
|
}
|
552
553
|
else {
|
553
554
|
//If there is another possibility
|
554
|
-
|
555
|
+
Logger.Log("Unhandled expression at line : " + line);
|
555
556
|
}
|
556
557
|
}
|
557
558
|
// At the end of the file, add the last mesh into the meshesFromObj array
|
package/OBJ/solidParser.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solidParser.js","sourceRoot":"","sources":["../../../../dev/loaders/src/OBJ/solidParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,0CAA4B;AAEnD,OAAO,EAAE,gBAAgB,EAAE,sDAAwC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,4CAA8B;AACvD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,6CAA+B;AAE1D,OAAO,EAAE,QAAQ,EAAE,2CAA6B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BD,aAAa;AACb,wBAAwB;AACV,4BAAgB,GAAG,IAAI,AAAP,CAAQ;AACtC,uBAAuB;AACT,2BAAe,GAAG,IAAI,AAAP,CAAQ;AACrC,8BAA8B;AAChB,iCAAqB,GAAG,UAAU,AAAb,CAAc;AACjD,gCAAgC;AAClB,4BAAgB,GAAG,UAAU,AAAb,CAAc;AAC5C,wBAAwB;AACV,4BAAgB,GAAG,KAAK,AAAR,CAAS;AAEvC,WAAW;AACX,sCAAsC;AACxB,yBAAa,GAAG,8BAA8B,AAAjC,CAAkC;AAC7D,sCAAsC;AACxB,yBAAa,GAAG,kEAAkE,AAArE,CAAsE;AACjG,sCAAsC;AACxB,qBAAS,GAAG,8CAA8C,AAAjD,CAAkD;AACzE,2EAA2E;AAC7D,wBAAY,GAAG,6BAA6B,AAAhC,CAAiC;AAC3D,wFAAwF;AAC1E,wBAAY,GAAG,yCAAyC,AAA5C,CAA6C;AACvE,4GAA4G;AAC9F,wBAAY,GAAG,mDAAmD,AAAtD,CAAuD;AACjF,mGAAmG;AACrF,wBAAY,GAAG,2CAA2C,AAA9C,CAA+C;AACzE,qHAAqH;AACvG,wBAAY,GAAG,sDAAsD,AAAzD,CAA0D;AACpF,qDAAqD;AACvC,wBAAY,GAAG,6BAA6B,AAAhC,CAAiC;AAC3D,6EAA6E;AAC/D,wBAAY,GAAG,yCAAyC,AAA5C,CAA6C;AACvE,0FAA0F;AAC5E,wBAAY,GAAG,mDAAmD,AAAtD,CAAuD","sourcesContent":["import type { AssetContainer } from \"core/assetContainer\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { StandardMaterial } from \"core/Materials/standardMaterial\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport { Vector2, Vector3 } from \"core/Maths/math.vector\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport { Geometry } from \"core/Meshes/geometry\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport { VertexData } from \"core/Meshes/mesh.vertexData\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { FloatArray, IndicesArray, Nullable } from \"core/types\";\r\nimport type { OBJLoadingOptions } from \"./objLoadingOptions\";\r\n\r\ntype MeshObject = {\r\n name: string;\r\n indices?: Array<number>;\r\n positions?: Array<number>;\r\n normals?: Array<number>;\r\n colors?: Array<number>;\r\n uvs?: Array<number>;\r\n materialName: string;\r\n directMaterial?: Nullable<Material>;\r\n isObject: boolean; // If the entity is defined as an object (\"o\"), or group (\"g\")\r\n _babylonMesh?: AbstractMesh; // The corresponding Babylon mesh\r\n};\r\n\r\n/**\r\n * Class used to load mesh data from OBJ content\r\n */\r\nexport class SolidParser {\r\n // Descriptor\r\n /** Object descriptor */\r\n public static ObjectDescriptor = /^o/;\r\n /** Group descriptor */\r\n public static GroupDescriptor = /^g/;\r\n /** Material lib descriptor */\r\n public static MtlLibGroupDescriptor = /^mtllib /;\r\n /** Use a material descriptor */\r\n public static UseMtlDescriptor = /^usemtl /;\r\n /** Smooth descriptor */\r\n public static SmoothDescriptor = /^s /;\r\n\r\n // Patterns\r\n /** Pattern used to detect a vertex */\r\n public static VertexPattern = /^v(\\s+[\\d|.|+|\\-|e|E]+){3,7}/;\r\n /** Pattern used to detect a normal */\r\n public static NormalPattern = /^vn(\\s+[\\d|.|+|\\-|e|E]+)( +[\\d|.|+|\\-|e|E]+)( +[\\d|.|+|\\-|e|E]+)/;\r\n /** Pattern used to detect a UV set */\r\n public static UVPattern = /^vt(\\s+[\\d|.|+|\\-|e|E]+)( +[\\d|.|+|\\-|e|E]+)/;\r\n /** Pattern used to detect a first kind of face (f vertex vertex vertex) */\r\n public static FacePattern1 = /^f\\s+(([\\d]{1,}[\\s]?){3,})+/;\r\n /** Pattern used to detect a second kind of face (f vertex/uvs vertex/uvs vertex/uvs) */\r\n public static FacePattern2 = /^f\\s+((([\\d]{1,}\\/[\\d]{1,}[\\s]?){3,})+)/;\r\n /** Pattern used to detect a third kind of face (f vertex/uvs/normal vertex/uvs/normal vertex/uvs/normal) */\r\n public static FacePattern3 = /^f\\s+((([\\d]{1,}\\/[\\d]{1,}\\/[\\d]{1,}[\\s]?){3,})+)/;\r\n /** Pattern used to detect a fourth kind of face (f vertex//normal vertex//normal vertex//normal)*/\r\n public static FacePattern4 = /^f\\s+((([\\d]{1,}\\/\\/[\\d]{1,}[\\s]?){3,})+)/;\r\n /** Pattern used to detect a fifth kind of face (f -vertex/-uvs/-normal -vertex/-uvs/-normal -vertex/-uvs/-normal) */\r\n public static FacePattern5 = /^f\\s+(((-[\\d]{1,}\\/-[\\d]{1,}\\/-[\\d]{1,}[\\s]?){3,})+)/;\r\n /** Pattern used to detect a line(l vertex vertex) */\r\n public static LinePattern1 = /^l\\s+(([\\d]{1,}[\\s]?){2,})+/;\r\n /** Pattern used to detect a second kind of line (l vertex/uvs vertex/uvs) */\r\n public static LinePattern2 = /^l\\s+((([\\d]{1,}\\/[\\d]{1,}[\\s]?){2,})+)/;\r\n /** Pattern used to detect a third kind of line (l vertex/uvs/normal vertex/uvs/normal) */\r\n public static LinePattern3 = /^l\\s+((([\\d]{1,}\\/[\\d]{1,}\\/[\\d]{1,}[\\s]?){2,})+)/;\r\n\r\n private _loadingOptions: OBJLoadingOptions;\r\n private _positions: Array<Vector3> = []; //values for the positions of vertices\r\n private _normals: Array<Vector3> = []; //Values for the normals\r\n private _uvs: Array<Vector2> = []; //Values for the textures\r\n private _colors: Array<Color4> = [];\r\n private _meshesFromObj: Array<MeshObject> = []; //[mesh] Contains all the obj meshes\r\n private _handledMesh: MeshObject; //The current mesh of meshes array\r\n private _indicesForBabylon: Array<number> = []; //The list of indices for VertexData\r\n private _wrappedPositionForBabylon: Array<Vector3> = []; //The list of position in vectors\r\n private _wrappedUvsForBabylon: Array<Vector2> = []; //Array with all value of uvs to match with the indices\r\n private _wrappedColorsForBabylon: Array<Color4> = []; // Array with all color values to match with the indices\r\n private _wrappedNormalsForBabylon: Array<Vector3> = []; //Array with all value of normals to match with the indices\r\n private _tuplePosNorm: Array<{ normals: Array<number>; idx: Array<number>; uv: Array<number> }> = []; //Create a tuple with indice of Position, Normal, UV [pos, norm, uvs]\r\n private _curPositionInIndices = 0;\r\n private _hasMeshes: Boolean = false; //Meshes are defined in the file\r\n private _unwrappedPositionsForBabylon: Array<number> = []; //Value of positionForBabylon w/o Vector3() [x,y,z]\r\n private _unwrappedColorsForBabylon: Array<number> = []; // Value of colorForBabylon w/o Color4() [r,g,b,a]\r\n private _unwrappedNormalsForBabylon: Array<number> = []; //Value of normalsForBabylon w/o Vector3() [x,y,z]\r\n private _unwrappedUVForBabylon: Array<number> = []; //Value of uvsForBabylon w/o Vector3() [x,y,z]\r\n private _triangles: Array<string> = []; //Indices from new triangles coming from polygons\r\n private _materialNameFromObj: string = \"\"; //The name of the current material\r\n private _objMeshName: string = \"\"; //The name of the current obj mesh\r\n private _increment: number = 1; //Id for meshes created by the multimaterial\r\n private _isFirstMaterial: boolean = true;\r\n private _grayColor = new Color4(0.5, 0.5, 0.5, 1);\r\n private _materialToUse: string[];\r\n private _babylonMeshesArray: Array<Mesh>;\r\n\r\n /**\r\n * Creates a new SolidParser\r\n * @param materialToUse defines the array to fill with the list of materials to use (it will be filled by the parse function)\r\n * @param babylonMeshesArray defines the array to fill with the list of loaded meshes (it will be filled by the parse function)\r\n * @param loadingOptions defines the loading options to use\r\n */\r\n public constructor(materialToUse: string[], babylonMeshesArray: Array<Mesh>, loadingOptions: OBJLoadingOptions) {\r\n this._materialToUse = materialToUse;\r\n this._babylonMeshesArray = babylonMeshesArray;\r\n this._loadingOptions = loadingOptions;\r\n }\r\n\r\n /**\r\n * Search for obj in the given array.\r\n * This function is called to check if a couple of data already exists in an array.\r\n *\r\n * If found, returns the index of the founded tuple index. Returns -1 if not found\r\n * @param arr Array<{ normals: Array<number>, idx: Array<number> }>\r\n * @param obj Array<number>\r\n * @returns {boolean}\r\n */\r\n private _isInArray(arr: Array<{ normals: Array<number>; idx: Array<number> }>, obj: Array<number>) {\r\n if (!arr[obj[0]]) {\r\n arr[obj[0]] = { normals: [], idx: [] };\r\n }\r\n const idx = arr[obj[0]].normals.indexOf(obj[1]);\r\n\r\n return idx === -1 ? -1 : arr[obj[0]].idx[idx];\r\n }\r\n\r\n private _isInArrayUV(arr: Array<{ normals: Array<number>; idx: Array<number>; uv: Array<number> }>, obj: Array<number>) {\r\n if (!arr[obj[0]]) {\r\n arr[obj[0]] = { normals: [], idx: [], uv: [] };\r\n }\r\n const idx = arr[obj[0]].normals.indexOf(obj[1]);\r\n\r\n if (idx != 1 && obj[2] === arr[obj[0]].uv[idx]) {\r\n return arr[obj[0]].idx[idx];\r\n }\r\n return -1;\r\n }\r\n\r\n /**\r\n * This function set the data for each triangle.\r\n * Data are position, normals and uvs\r\n * If a tuple of (position, normal) is not set, add the data into the corresponding array\r\n * If the tuple already exist, add only their indice\r\n *\r\n * @param indicePositionFromObj Integer The index in positions array\r\n * @param indiceUvsFromObj Integer The index in uvs array\r\n * @param indiceNormalFromObj Integer The index in normals array\r\n * @param positionVectorFromOBJ Vector3 The value of position at index objIndice\r\n * @param textureVectorFromOBJ Vector3 The value of uvs\r\n * @param normalsVectorFromOBJ Vector3 The value of normals at index objNormale\r\n * @param positionColorsFromOBJ\r\n */\r\n private _setData(\r\n indicePositionFromObj: number,\r\n indiceUvsFromObj: number,\r\n indiceNormalFromObj: number,\r\n positionVectorFromOBJ: Vector3,\r\n textureVectorFromOBJ: Vector2,\r\n normalsVectorFromOBJ: Vector3,\r\n positionColorsFromOBJ?: Color4\r\n ) {\r\n //Check if this tuple already exists in the list of tuples\r\n let _index: number;\r\n if (this._loadingOptions.optimizeWithUV) {\r\n _index = this._isInArrayUV(this._tuplePosNorm, [indicePositionFromObj, indiceNormalFromObj, indiceUvsFromObj]);\r\n } else {\r\n _index = this._isInArray(this._tuplePosNorm, [indicePositionFromObj, indiceNormalFromObj]);\r\n }\r\n\r\n //If it not exists\r\n if (_index === -1) {\r\n //Add an new indice.\r\n //The array of indices is only an array with his length equal to the number of triangles - 1.\r\n //We add vertices data in this order\r\n this._indicesForBabylon.push(this._wrappedPositionForBabylon.length);\r\n //Push the position of vertice for Babylon\r\n //Each element is a Vector3(x,y,z)\r\n this._wrappedPositionForBabylon.push(positionVectorFromOBJ);\r\n //Push the uvs for Babylon\r\n //Each element is a Vector3(u,v)\r\n this._wrappedUvsForBabylon.push(textureVectorFromOBJ);\r\n //Push the normals for Babylon\r\n //Each element is a Vector3(x,y,z)\r\n this._wrappedNormalsForBabylon.push(normalsVectorFromOBJ);\r\n\r\n if (positionColorsFromOBJ !== undefined) {\r\n //Push the colors for Babylon\r\n //Each element is a BABYLON.Color4(r,g,b,a)\r\n this._wrappedColorsForBabylon.push(positionColorsFromOBJ);\r\n }\r\n\r\n //Add the tuple in the comparison list\r\n this._tuplePosNorm[indicePositionFromObj].normals.push(indiceNormalFromObj);\r\n this._tuplePosNorm[indicePositionFromObj].idx.push(this._curPositionInIndices++);\r\n if (this._loadingOptions.optimizeWithUV) {\r\n this._tuplePosNorm[indicePositionFromObj].uv.push(indiceUvsFromObj);\r\n }\r\n } else {\r\n //The tuple already exists\r\n //Add the index of the already existing tuple\r\n //At this index we can get the value of position, normal, color and uvs of vertex\r\n this._indicesForBabylon.push(_index);\r\n }\r\n }\r\n\r\n /**\r\n * Transform Vector() and BABYLON.Color() objects into numbers in an array\r\n */\r\n private _unwrapData() {\r\n //Every array has the same length\r\n for (let l = 0; l < this._wrappedPositionForBabylon.length; l++) {\r\n //Push the x, y, z values of each element in the unwrapped array\r\n this._unwrappedPositionsForBabylon.push(this._wrappedPositionForBabylon[l].x, this._wrappedPositionForBabylon[l].y, this._wrappedPositionForBabylon[l].z);\r\n this._unwrappedNormalsForBabylon.push(this._wrappedNormalsForBabylon[l].x, this._wrappedNormalsForBabylon[l].y, this._wrappedNormalsForBabylon[l].z);\r\n this._unwrappedUVForBabylon.push(this._wrappedUvsForBabylon[l].x, this._wrappedUvsForBabylon[l].y); //z is an optional value not supported by BABYLON\r\n if (this._loadingOptions.importVertexColors) {\r\n //Push the r, g, b, a values of each element in the unwrapped array\r\n this._unwrappedColorsForBabylon.push(\r\n this._wrappedColorsForBabylon[l].r,\r\n this._wrappedColorsForBabylon[l].g,\r\n this._wrappedColorsForBabylon[l].b,\r\n this._wrappedColorsForBabylon[l].a\r\n );\r\n }\r\n }\r\n // Reset arrays for the next new meshes\r\n this._wrappedPositionForBabylon.length = 0;\r\n this._wrappedNormalsForBabylon.length = 0;\r\n this._wrappedUvsForBabylon.length = 0;\r\n this._wrappedColorsForBabylon.length = 0;\r\n this._tuplePosNorm.length = 0;\r\n this._curPositionInIndices = 0;\r\n }\r\n\r\n /**\r\n * Create triangles from polygons\r\n * It is important to notice that a triangle is a polygon\r\n * We get 5 patterns of face defined in OBJ File :\r\n * facePattern1 = [\"1\",\"2\",\"3\",\"4\",\"5\",\"6\"]\r\n * facePattern2 = [\"1/1\",\"2/2\",\"3/3\",\"4/4\",\"5/5\",\"6/6\"]\r\n * facePattern3 = [\"1/1/1\",\"2/2/2\",\"3/3/3\",\"4/4/4\",\"5/5/5\",\"6/6/6\"]\r\n * facePattern4 = [\"1//1\",\"2//2\",\"3//3\",\"4//4\",\"5//5\",\"6//6\"]\r\n * facePattern5 = [\"-1/-1/-1\",\"-2/-2/-2\",\"-3/-3/-3\",\"-4/-4/-4\",\"-5/-5/-5\",\"-6/-6/-6\"]\r\n * Each pattern is divided by the same method\r\n * @param faces Array[String] The indices of elements\r\n * @param v Integer The variable to increment\r\n */\r\n private _getTriangles(faces: Array<string>, v: number) {\r\n //Work for each element of the array\r\n for (let faceIndex = v; faceIndex < faces.length - 1; faceIndex++) {\r\n //Add on the triangle variable the indexes to obtain triangles\r\n this._triangles.push(faces[0], faces[faceIndex], faces[faceIndex + 1]);\r\n }\r\n\r\n //Result obtained after 2 iterations:\r\n //Pattern1 => triangle = [\"1\",\"2\",\"3\",\"1\",\"3\",\"4\"];\r\n //Pattern2 => triangle = [\"1/1\",\"2/2\",\"3/3\",\"1/1\",\"3/3\",\"4/4\"];\r\n //Pattern3 => triangle = [\"1/1/1\",\"2/2/2\",\"3/3/3\",\"1/1/1\",\"3/3/3\",\"4/4/4\"];\r\n //Pattern4 => triangle = [\"1//1\",\"2//2\",\"3//3\",\"1//1\",\"3//3\",\"4//4\"];\r\n //Pattern5 => triangle = [\"-1/-1/-1\",\"-2/-2/-2\",\"-3/-3/-3\",\"-1/-1/-1\",\"-3/-3/-3\",\"-4/-4/-4\"];\r\n }\r\n\r\n /**\r\n * Create triangles and push the data for each polygon for the pattern 1\r\n * In this pattern we get vertice positions\r\n * @param face\r\n * @param v\r\n */\r\n private _setDataForCurrentFaceWithPattern1(face: Array<string>, v: number) {\r\n //Get the indices of triangles for each polygon\r\n this._getTriangles(face, v);\r\n //For each element in the triangles array.\r\n //This var could contains 1 to an infinity of triangles\r\n for (let k = 0; k < this._triangles.length; k++) {\r\n // Set position indice\r\n const indicePositionFromObj = parseInt(this._triangles[k]) - 1;\r\n\r\n this._setData(\r\n indicePositionFromObj,\r\n 0,\r\n 0, // In the pattern 1, normals and uvs are not defined\r\n this._positions[indicePositionFromObj], // Get the vectors data\r\n Vector2.Zero(),\r\n Vector3.Up(), // Create default vectors\r\n this._loadingOptions.importVertexColors ? this._colors[indicePositionFromObj] : undefined\r\n );\r\n }\r\n //Reset variable for the next line\r\n this._triangles.length = 0;\r\n }\r\n\r\n /**\r\n * Create triangles and push the data for each polygon for the pattern 2\r\n * In this pattern we get vertice positions and uvs\r\n * @param face\r\n * @param v\r\n */\r\n private _setDataForCurrentFaceWithPattern2(face: Array<string>, v: number) {\r\n //Get the indices of triangles for each polygon\r\n this._getTriangles(face, v);\r\n for (let k = 0; k < this._triangles.length; k++) {\r\n //triangle[k] = \"1/1\"\r\n //Split the data for getting position and uv\r\n const point = this._triangles[k].split(\"/\"); // [\"1\", \"1\"]\r\n //Set position indice\r\n const indicePositionFromObj = parseInt(point[0]) - 1;\r\n //Set uv indice\r\n const indiceUvsFromObj = parseInt(point[1]) - 1;\r\n\r\n this._setData(\r\n indicePositionFromObj,\r\n indiceUvsFromObj,\r\n 0, //Default value for normals\r\n this._positions[indicePositionFromObj], //Get the values for each element\r\n this._uvs[indiceUvsFromObj],\r\n Vector3.Up(), //Default value for normals\r\n this._loadingOptions.importVertexColors ? this._colors[indicePositionFromObj] : undefined\r\n );\r\n }\r\n\r\n //Reset variable for the next line\r\n this._triangles.length = 0;\r\n }\r\n\r\n /**\r\n * Create triangles and push the data for each polygon for the pattern 3\r\n * In this pattern we get vertice positions, uvs and normals\r\n * @param face\r\n * @param v\r\n */\r\n private _setDataForCurrentFaceWithPattern3(face: Array<string>, v: number) {\r\n //Get the indices of triangles for each polygon\r\n this._getTriangles(face, v);\r\n\r\n for (let k = 0; k < this._triangles.length; k++) {\r\n //triangle[k] = \"1/1/1\"\r\n //Split the data for getting position, uv, and normals\r\n const point = this._triangles[k].split(\"/\"); // [\"1\", \"1\", \"1\"]\r\n // Set position indice\r\n const indicePositionFromObj = parseInt(point[0]) - 1;\r\n // Set uv indice\r\n const indiceUvsFromObj = parseInt(point[1]) - 1;\r\n // Set normal indice\r\n const indiceNormalFromObj = parseInt(point[2]) - 1;\r\n\r\n this._setData(\r\n indicePositionFromObj,\r\n indiceUvsFromObj,\r\n indiceNormalFromObj,\r\n this._positions[indicePositionFromObj],\r\n this._uvs[indiceUvsFromObj],\r\n this._normals[indiceNormalFromObj] //Set the vector for each component\r\n );\r\n }\r\n //Reset variable for the next line\r\n this._triangles.length = 0;\r\n }\r\n\r\n /**\r\n * Create triangles and push the data for each polygon for the pattern 4\r\n * In this pattern we get vertice positions and normals\r\n * @param face\r\n * @param v\r\n */\r\n private _setDataForCurrentFaceWithPattern4(face: Array<string>, v: number) {\r\n this._getTriangles(face, v);\r\n\r\n for (let k = 0; k < this._triangles.length; k++) {\r\n //triangle[k] = \"1//1\"\r\n //Split the data for getting position and normals\r\n const point = this._triangles[k].split(\"//\"); // [\"1\", \"1\"]\r\n // We check indices, and normals\r\n const indicePositionFromObj = parseInt(point[0]) - 1;\r\n const indiceNormalFromObj = parseInt(point[1]) - 1;\r\n\r\n this._setData(\r\n indicePositionFromObj,\r\n 1, //Default value for uv\r\n indiceNormalFromObj,\r\n this._positions[indicePositionFromObj], //Get each vector of data\r\n Vector2.Zero(),\r\n this._normals[indiceNormalFromObj],\r\n this._loadingOptions.importVertexColors ? this._colors[indicePositionFromObj] : undefined\r\n );\r\n }\r\n //Reset variable for the next line\r\n this._triangles.length = 0;\r\n }\r\n\r\n /*\r\n * Create triangles and push the data for each polygon for the pattern 3\r\n * In this pattern we get vertice positions, uvs and normals\r\n * @param face\r\n * @param v\r\n */\r\n private _setDataForCurrentFaceWithPattern5(face: Array<string>, v: number) {\r\n //Get the indices of triangles for each polygon\r\n this._getTriangles(face, v);\r\n\r\n for (let k = 0; k < this._triangles.length; k++) {\r\n //triangle[k] = \"-1/-1/-1\"\r\n //Split the data for getting position, uv, and normals\r\n const point = this._triangles[k].split(\"/\"); // [\"-1\", \"-1\", \"-1\"]\r\n // Set position indice\r\n const indicePositionFromObj = this._positions.length + parseInt(point[0]);\r\n // Set uv indice\r\n const indiceUvsFromObj = this._uvs.length + parseInt(point[1]);\r\n // Set normal indice\r\n const indiceNormalFromObj = this._normals.length + parseInt(point[2]);\r\n\r\n this._setData(\r\n indicePositionFromObj,\r\n indiceUvsFromObj,\r\n indiceNormalFromObj,\r\n this._positions[indicePositionFromObj],\r\n this._uvs[indiceUvsFromObj],\r\n this._normals[indiceNormalFromObj], //Set the vector for each component\r\n this._loadingOptions.importVertexColors ? this._colors[indicePositionFromObj] : undefined\r\n );\r\n }\r\n //Reset variable for the next line\r\n this._triangles.length = 0;\r\n }\r\n\r\n private _addPreviousObjMesh() {\r\n //Check if it is not the first mesh. Otherwise we don't have data.\r\n if (this._meshesFromObj.length > 0) {\r\n //Get the previous mesh for applying the data about the faces\r\n //=> in obj file, faces definition append after the name of the mesh\r\n this._handledMesh = this._meshesFromObj[this._meshesFromObj.length - 1];\r\n\r\n //Set the data into Array for the mesh\r\n this._unwrapData();\r\n\r\n // Reverse tab. Otherwise face are displayed in the wrong sens\r\n this._indicesForBabylon.reverse();\r\n //Set the information for the mesh\r\n //Slice the array to avoid rewriting because of the fact this is the same var which be rewrited\r\n this._handledMesh.indices = this._indicesForBabylon.slice();\r\n this._handledMesh.positions = this._unwrappedPositionsForBabylon.slice();\r\n this._handledMesh.normals = this._unwrappedNormalsForBabylon.slice();\r\n this._handledMesh.uvs = this._unwrappedUVForBabylon.slice();\r\n\r\n if (this._loadingOptions.importVertexColors) {\r\n this._handledMesh.colors = this._unwrappedColorsForBabylon.slice();\r\n }\r\n\r\n //Reset the array for the next mesh\r\n this._indicesForBabylon.length = 0;\r\n this._unwrappedPositionsForBabylon.length = 0;\r\n this._unwrappedColorsForBabylon.length = 0;\r\n this._unwrappedNormalsForBabylon.length = 0;\r\n this._unwrappedUVForBabylon.length = 0;\r\n }\r\n }\r\n\r\n private _optimizeNormals(mesh: AbstractMesh): void {\r\n const positions = mesh.getVerticesData(VertexBuffer.PositionKind);\r\n const normals = mesh.getVerticesData(VertexBuffer.NormalKind);\r\n const mapVertices: { [key: string]: number[] } = {};\r\n\r\n if (!positions || !normals) {\r\n return;\r\n }\r\n\r\n for (let i = 0; i < positions.length / 3; i++) {\r\n const x = positions[i * 3 + 0];\r\n const y = positions[i * 3 + 1];\r\n const z = positions[i * 3 + 2];\r\n const key = x + \"_\" + y + \"_\" + z;\r\n\r\n let lst = mapVertices[key];\r\n if (!lst) {\r\n lst = [];\r\n mapVertices[key] = lst;\r\n }\r\n lst.push(i);\r\n }\r\n\r\n const normal = new Vector3();\r\n for (const key in mapVertices) {\r\n const lst = mapVertices[key];\r\n if (lst.length < 2) {\r\n continue;\r\n }\r\n\r\n const v0Idx = lst[0];\r\n for (let i = 1; i < lst.length; ++i) {\r\n const vIdx = lst[i];\r\n normals[v0Idx * 3 + 0] += normals[vIdx * 3 + 0];\r\n normals[v0Idx * 3 + 1] += normals[vIdx * 3 + 1];\r\n normals[v0Idx * 3 + 2] += normals[vIdx * 3 + 2];\r\n }\r\n\r\n normal.copyFromFloats(normals[v0Idx * 3 + 0], normals[v0Idx * 3 + 1], normals[v0Idx * 3 + 2]);\r\n normal.normalize();\r\n\r\n for (let i = 0; i < lst.length; ++i) {\r\n const vIdx = lst[i];\r\n normals[vIdx * 3 + 0] = normal.x;\r\n normals[vIdx * 3 + 1] = normal.y;\r\n normals[vIdx * 3 + 2] = normal.z;\r\n }\r\n }\r\n mesh.setVerticesData(VertexBuffer.NormalKind, normals);\r\n }\r\n\r\n /**\r\n * Function used to parse an OBJ string\r\n * @param meshesNames defines the list of meshes to load (all if not defined)\r\n * @param data defines the OBJ string\r\n * @param scene defines the hosting scene\r\n * @param assetContainer defines the asset container to load data in\r\n * @param onFileToLoadFound defines a callback that will be called if a MTL file is found\r\n */\r\n public parse(meshesNames: any, data: string, scene: Scene, assetContainer: Nullable<AssetContainer>, onFileToLoadFound: (fileToLoad: string) => void): void {\r\n // Split the file into lines\r\n const lines = data.split(\"\\n\");\r\n // Look at each line\r\n for (let i = 0; i < lines.length; i++) {\r\n const line = lines[i].trim().replace(/\\s\\s/g, \" \");\r\n let result;\r\n\r\n // Comment or newLine\r\n if (line.length === 0 || line.charAt(0) === \"#\") {\r\n continue;\r\n\r\n //Get information about one position possible for the vertices\r\n } else if (SolidParser.VertexPattern.test(line)) {\r\n result = line.match(/[^ ]+/g)!; // match will return non-null due to passing regex pattern\r\n\r\n // Value of result with line: \"v 1.0 2.0 3.0\"\r\n // [\"v\", \"1.0\", \"2.0\", \"3.0\"]\r\n // Create a Vector3 with the position x, y, z\r\n this._positions.push(new Vector3(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3])));\r\n\r\n if (this._loadingOptions.importVertexColors) {\r\n if (result.length >= 7) {\r\n const r = parseFloat(result[4]);\r\n const g = parseFloat(result[5]);\r\n const b = parseFloat(result[6]);\r\n\r\n this._colors.push(\r\n new Color4(r > 1 ? r / 255 : r, g > 1 ? g / 255 : g, b > 1 ? b / 255 : b, result.length === 7 || result[7] === undefined ? 1 : parseFloat(result[7]))\r\n );\r\n } else {\r\n // TODO: maybe push NULL and if all are NULL to skip (and remove grayColor var).\r\n this._colors.push(this._grayColor);\r\n }\r\n }\r\n } else if ((result = SolidParser.NormalPattern.exec(line)) !== null) {\r\n //Create a Vector3 with the normals x, y, z\r\n //Value of result\r\n // [\"vn 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\r\n //Add the Vector in the list of normals\r\n this._normals.push(new Vector3(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3])));\r\n } else if ((result = SolidParser.UVPattern.exec(line)) !== null) {\r\n //Create a Vector2 with the normals u, v\r\n //Value of result\r\n // [\"vt 0.1 0.2 0.3\", \"0.1\", \"0.2\"]\r\n //Add the Vector in the list of uvs\r\n this._uvs.push(new Vector2(parseFloat(result[1]) * this._loadingOptions.UVScaling.x, parseFloat(result[2]) * this._loadingOptions.UVScaling.y));\r\n\r\n //Identify patterns of faces\r\n //Face could be defined in different type of pattern\r\n } else if ((result = SolidParser.FacePattern3.exec(line)) !== null) {\r\n //Value of result:\r\n //[\"f 1/1/1 2/2/2 3/3/3\", \"1/1/1 2/2/2 3/3/3\"...]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern3(\r\n result[1].trim().split(\" \"), // [\"1/1/1\", \"2/2/2\", \"3/3/3\"]\r\n 1\r\n );\r\n } else if ((result = SolidParser.FacePattern4.exec(line)) !== null) {\r\n //Value of result:\r\n //[\"f 1//1 2//2 3//3\", \"1//1 2//2 3//3\"...]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern4(\r\n result[1].trim().split(\" \"), // [\"1//1\", \"2//2\", \"3//3\"]\r\n 1\r\n );\r\n } else if ((result = SolidParser.FacePattern5.exec(line)) !== null) {\r\n //Value of result:\r\n //[\"f -1/-1/-1 -2/-2/-2 -3/-3/-3\", \"-1/-1/-1 -2/-2/-2 -3/-3/-3\"...]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern5(\r\n result[1].trim().split(\" \"), // [\"-1/-1/-1\", \"-2/-2/-2\", \"-3/-3/-3\"]\r\n 1\r\n );\r\n } else if ((result = SolidParser.FacePattern2.exec(line)) !== null) {\r\n //Value of result:\r\n //[\"f 1/1 2/2 3/3\", \"1/1 2/2 3/3\"...]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern2(\r\n result[1].trim().split(\" \"), // [\"1/1\", \"2/2\", \"3/3\"]\r\n 1\r\n );\r\n } else if ((result = SolidParser.FacePattern1.exec(line)) !== null) {\r\n //Value of result\r\n //[\"f 1 2 3\", \"1 2 3\"...]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern1(\r\n result[1].trim().split(\" \"), // [\"1\", \"2\", \"3\"]\r\n 1\r\n );\r\n\r\n // Define a mesh or an object\r\n // Each time this keyword is analyzed, create a new Object with all data for creating a babylonMesh\r\n } else if ((result = SolidParser.LinePattern1.exec(line)) !== null) {\r\n //Value of result\r\n //[\"l 1 2\"]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern1(\r\n result[1].trim().split(\" \"), // [\"1\", \"2\"]\r\n 0\r\n );\r\n\r\n // Define a mesh or an object\r\n // Each time this keyword is analyzed, create a new Object with all data for creating a babylonMesh\r\n } else if ((result = SolidParser.LinePattern2.exec(line)) !== null) {\r\n //Value of result\r\n //[\"l 1/1 2/2\"]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern2(\r\n result[1].trim().split(\" \"), // [\"1/1\", \"2/2\"]\r\n 0\r\n );\r\n\r\n // Define a mesh or an object\r\n // Each time this keyword is analyzed, create a new Object with all data for creating a babylonMesh\r\n } else if ((result = SolidParser.LinePattern3.exec(line)) !== null) {\r\n //Value of result\r\n //[\"l 1/1/1 2/2/2\"]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern3(\r\n result[1].trim().split(\" \"), // [\"1/1/1\", \"2/2/2\"]\r\n 0\r\n );\r\n\r\n // Define a mesh or an object\r\n // Each time this keyword is analyzed, create a new Object with all data for creating a babylonMesh\r\n } else if (SolidParser.GroupDescriptor.test(line) || SolidParser.ObjectDescriptor.test(line)) {\r\n // Create a new mesh corresponding to the name of the group.\r\n // Definition of the mesh\r\n const objMesh: MeshObject = {\r\n name: line.substring(2).trim(), //Set the name of the current obj mesh\r\n indices: undefined,\r\n positions: undefined,\r\n normals: undefined,\r\n uvs: undefined,\r\n colors: undefined,\r\n materialName: this._materialNameFromObj,\r\n isObject: SolidParser.ObjectDescriptor.test(line),\r\n };\r\n this._addPreviousObjMesh();\r\n\r\n //Push the last mesh created with only the name\r\n this._meshesFromObj.push(objMesh);\r\n\r\n //Set this variable to indicate that now meshesFromObj has objects defined inside\r\n this._hasMeshes = true;\r\n this._isFirstMaterial = true;\r\n this._increment = 1;\r\n //Keyword for applying a material\r\n } else if (SolidParser.UseMtlDescriptor.test(line)) {\r\n //Get the name of the material\r\n this._materialNameFromObj = line.substring(7).trim();\r\n\r\n //If this new material is in the same mesh\r\n\r\n if (!this._isFirstMaterial || !this._hasMeshes) {\r\n //Set the data for the previous mesh\r\n this._addPreviousObjMesh();\r\n //Create a new mesh\r\n const objMesh: MeshObject =\r\n //Set the name of the current obj mesh\r\n {\r\n name: (this._objMeshName || \"mesh\") + \"_mm\" + this._increment.toString(), //Set the name of the current obj mesh\r\n indices: undefined,\r\n positions: undefined,\r\n normals: undefined,\r\n uvs: undefined,\r\n colors: undefined,\r\n materialName: this._materialNameFromObj,\r\n isObject: false,\r\n };\r\n this._increment++;\r\n //If meshes are already defined\r\n this._meshesFromObj.push(objMesh);\r\n this._hasMeshes = true;\r\n }\r\n //Set the material name if the previous line define a mesh\r\n\r\n if (this._hasMeshes && this._isFirstMaterial) {\r\n //Set the material name to the previous mesh (1 material per mesh)\r\n this._meshesFromObj[this._meshesFromObj.length - 1].materialName = this._materialNameFromObj;\r\n this._isFirstMaterial = false;\r\n }\r\n // Keyword for loading the mtl file\r\n } else if (SolidParser.MtlLibGroupDescriptor.test(line)) {\r\n // Get the name of mtl file\r\n onFileToLoadFound(line.substring(7).trim());\r\n\r\n // Apply smoothing\r\n } else if (SolidParser.SmoothDescriptor.test(line)) {\r\n // smooth shading => apply smoothing\r\n // Today I don't know it work with babylon and with obj.\r\n // With the obj file an integer is set\r\n } else {\r\n //If there is another possibility\r\n console.log(\"Unhandled expression at line : \" + line);\r\n }\r\n }\r\n\r\n // At the end of the file, add the last mesh into the meshesFromObj array\r\n if (this._hasMeshes) {\r\n // Set the data for the last mesh\r\n this._handledMesh = this._meshesFromObj[this._meshesFromObj.length - 1];\r\n\r\n //Reverse indices for displaying faces in the good sense\r\n this._indicesForBabylon.reverse();\r\n //Get the good array\r\n this._unwrapData();\r\n //Set array\r\n this._handledMesh.indices = this._indicesForBabylon;\r\n this._handledMesh.positions = this._unwrappedPositionsForBabylon;\r\n this._handledMesh.normals = this._unwrappedNormalsForBabylon;\r\n this._handledMesh.uvs = this._unwrappedUVForBabylon;\r\n\r\n if (this._loadingOptions.importVertexColors) {\r\n this._handledMesh.colors = this._unwrappedColorsForBabylon;\r\n }\r\n }\r\n\r\n // If any o or g keyword not found, create a mesh with a random id\r\n if (!this._hasMeshes) {\r\n let newMaterial: Nullable<StandardMaterial> = null;\r\n if (this._indicesForBabylon.length) {\r\n // reverse tab of indices\r\n this._indicesForBabylon.reverse();\r\n //Get positions normals uvs\r\n this._unwrapData();\r\n } else {\r\n // There is no indices in the file. We will have to switch to point cloud rendering\r\n for (const pos of this._positions) {\r\n this._unwrappedPositionsForBabylon.push(pos.x, pos.y, pos.z);\r\n }\r\n\r\n if (this._normals.length) {\r\n for (const normal of this._normals) {\r\n this._unwrappedNormalsForBabylon.push(normal.x, normal.y, normal.z);\r\n }\r\n }\r\n\r\n if (this._uvs.length) {\r\n for (const uv of this._uvs) {\r\n this._unwrappedUVForBabylon.push(uv.x, uv.y);\r\n }\r\n }\r\n\r\n if (this._colors.length) {\r\n for (const color of this._colors) {\r\n this._unwrappedColorsForBabylon.push(color.r, color.g, color.b, color.a);\r\n }\r\n }\r\n\r\n if (!this._materialNameFromObj) {\r\n // Create a material with point cloud on\r\n newMaterial = new StandardMaterial(Geometry.RandomId(), scene);\r\n\r\n newMaterial.pointsCloud = true;\r\n\r\n this._materialNameFromObj = newMaterial.name;\r\n\r\n if (!this._normals.length) {\r\n newMaterial.disableLighting = true;\r\n newMaterial.emissiveColor = Color3.White();\r\n }\r\n }\r\n }\r\n\r\n //Set data for one mesh\r\n this._meshesFromObj.push({\r\n name: Geometry.RandomId(),\r\n indices: this._indicesForBabylon,\r\n positions: this._unwrappedPositionsForBabylon,\r\n colors: this._unwrappedColorsForBabylon,\r\n normals: this._unwrappedNormalsForBabylon,\r\n uvs: this._unwrappedUVForBabylon,\r\n materialName: this._materialNameFromObj,\r\n directMaterial: newMaterial,\r\n isObject: true,\r\n });\r\n }\r\n\r\n //Set data for each mesh\r\n for (let j = 0; j < this._meshesFromObj.length; j++) {\r\n //check meshesNames (stlFileLoader)\r\n if (meshesNames && this._meshesFromObj[j].name) {\r\n if (meshesNames instanceof Array) {\r\n if (meshesNames.indexOf(this._meshesFromObj[j].name) === -1) {\r\n continue;\r\n }\r\n } else {\r\n if (this._meshesFromObj[j].name !== meshesNames) {\r\n continue;\r\n }\r\n }\r\n }\r\n\r\n //Get the current mesh\r\n //Set the data with VertexBuffer for each mesh\r\n this._handledMesh = this._meshesFromObj[j];\r\n //Create a Mesh with the name of the obj mesh\r\n\r\n scene._blockEntityCollection = !!assetContainer;\r\n const babylonMesh = new Mesh(this._meshesFromObj[j].name, scene);\r\n babylonMesh._parentContainer = assetContainer;\r\n scene._blockEntityCollection = false;\r\n this._handledMesh._babylonMesh = babylonMesh;\r\n // If this is a group mesh, it should have an object mesh as a parent. So look for the first object mesh that appears before it.\r\n if (!this._handledMesh.isObject) {\r\n for (let k = j - 1; k >= 0; --k) {\r\n if (this._meshesFromObj[k].isObject && this._meshesFromObj[k]._babylonMesh) {\r\n babylonMesh.parent = this._meshesFromObj[k]._babylonMesh!;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n //Push the name of the material to an array\r\n //This is indispensable for the importMesh function\r\n this._materialToUse.push(this._meshesFromObj[j].materialName);\r\n\r\n if (this._handledMesh.positions?.length === 0) {\r\n //Push the mesh into an array\r\n this._babylonMeshesArray.push(babylonMesh);\r\n continue;\r\n }\r\n\r\n const vertexData: VertexData = new VertexData(); //The container for the values\r\n //Set the data for the babylonMesh\r\n vertexData.uvs = this._handledMesh.uvs as FloatArray;\r\n vertexData.indices = this._handledMesh.indices as IndicesArray;\r\n vertexData.positions = this._handledMesh.positions as FloatArray;\r\n if (this._loadingOptions.computeNormals) {\r\n const normals: Array<number> = new Array<number>();\r\n VertexData.ComputeNormals(this._handledMesh.positions, this._handledMesh.indices, normals);\r\n vertexData.normals = normals;\r\n } else {\r\n vertexData.normals = this._handledMesh.normals as FloatArray;\r\n }\r\n if (this._loadingOptions.importVertexColors) {\r\n vertexData.colors = this._handledMesh.colors as FloatArray;\r\n }\r\n //Set the data from the VertexBuffer to the current Mesh\r\n vertexData.applyToMesh(babylonMesh);\r\n if (this._loadingOptions.invertY) {\r\n babylonMesh.scaling.y *= -1;\r\n }\r\n if (this._loadingOptions.optimizeNormals) {\r\n this._optimizeNormals(babylonMesh);\r\n }\r\n\r\n //Push the mesh into an array\r\n this._babylonMeshesArray.push(babylonMesh);\r\n\r\n if (this._handledMesh.directMaterial) {\r\n babylonMesh.material = this._handledMesh.directMaterial;\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
1
|
+
{"version":3,"file":"solidParser.js","sourceRoot":"","sources":["../../../../dev/loaders/src/OBJ/solidParser.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,0CAA4B;AAEnD,OAAO,EAAE,gBAAgB,EAAE,sDAAwC;AACnE,OAAO,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,WAAW,CAAC,CAAC;YAE3C,IAAI,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE;gBAClC,WAAW,CAAC,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC;aAC3D;SACJ;IACL,CAAC;;AA/0BD,aAAa;AACb,wBAAwB;AACV,4BAAgB,GAAG,IAAI,AAAP,CAAQ;AACtC,uBAAuB;AACT,2BAAe,GAAG,IAAI,AAAP,CAAQ;AACrC,8BAA8B;AAChB,iCAAqB,GAAG,UAAU,AAAb,CAAc;AACjD,gCAAgC;AAClB,4BAAgB,GAAG,UAAU,AAAb,CAAc;AAC5C,wBAAwB;AACV,4BAAgB,GAAG,KAAK,AAAR,CAAS;AAEvC,WAAW;AACX,sCAAsC;AACxB,yBAAa,GAAG,8BAA8B,AAAjC,CAAkC;AAC7D,sCAAsC;AACxB,yBAAa,GAAG,kEAAkE,AAArE,CAAsE;AACjG,sCAAsC;AACxB,qBAAS,GAAG,8CAA8C,AAAjD,CAAkD;AACzE,2EAA2E;AAC7D,wBAAY,GAAG,6BAA6B,AAAhC,CAAiC;AAC3D,wFAAwF;AAC1E,wBAAY,GAAG,yCAAyC,AAA5C,CAA6C;AACvE,4GAA4G;AAC9F,wBAAY,GAAG,mDAAmD,AAAtD,CAAuD;AACjF,mGAAmG;AACrF,wBAAY,GAAG,2CAA2C,AAA9C,CAA+C;AACzE,qHAAqH;AACvG,wBAAY,GAAG,sDAAsD,AAAzD,CAA0D;AACpF,qDAAqD;AACvC,wBAAY,GAAG,6BAA6B,AAAhC,CAAiC;AAC3D,6EAA6E;AAC/D,wBAAY,GAAG,yCAAyC,AAA5C,CAA6C;AACvE,0FAA0F;AAC5E,wBAAY,GAAG,mDAAmD,AAAtD,CAAuD","sourcesContent":["import type { AssetContainer } from \"core/assetContainer\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport { StandardMaterial } from \"core/Materials/standardMaterial\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport { Vector2, Vector3 } from \"core/Maths/math.vector\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport { Geometry } from \"core/Meshes/geometry\";\r\nimport { Mesh } from \"core/Meshes/mesh\";\r\nimport { VertexData } from \"core/Meshes/mesh.vertexData\";\r\nimport type { Scene } from \"core/scene\";\r\nimport type { FloatArray, IndicesArray, Nullable } from \"core/types\";\r\nimport type { OBJLoadingOptions } from \"./objLoadingOptions\";\r\nimport { Logger } from \"core/Misc/logger\";\r\n\r\ntype MeshObject = {\r\n name: string;\r\n indices?: Array<number>;\r\n positions?: Array<number>;\r\n normals?: Array<number>;\r\n colors?: Array<number>;\r\n uvs?: Array<number>;\r\n materialName: string;\r\n directMaterial?: Nullable<Material>;\r\n isObject: boolean; // If the entity is defined as an object (\"o\"), or group (\"g\")\r\n _babylonMesh?: AbstractMesh; // The corresponding Babylon mesh\r\n};\r\n\r\n/**\r\n * Class used to load mesh data from OBJ content\r\n */\r\nexport class SolidParser {\r\n // Descriptor\r\n /** Object descriptor */\r\n public static ObjectDescriptor = /^o/;\r\n /** Group descriptor */\r\n public static GroupDescriptor = /^g/;\r\n /** Material lib descriptor */\r\n public static MtlLibGroupDescriptor = /^mtllib /;\r\n /** Use a material descriptor */\r\n public static UseMtlDescriptor = /^usemtl /;\r\n /** Smooth descriptor */\r\n public static SmoothDescriptor = /^s /;\r\n\r\n // Patterns\r\n /** Pattern used to detect a vertex */\r\n public static VertexPattern = /^v(\\s+[\\d|.|+|\\-|e|E]+){3,7}/;\r\n /** Pattern used to detect a normal */\r\n public static NormalPattern = /^vn(\\s+[\\d|.|+|\\-|e|E]+)( +[\\d|.|+|\\-|e|E]+)( +[\\d|.|+|\\-|e|E]+)/;\r\n /** Pattern used to detect a UV set */\r\n public static UVPattern = /^vt(\\s+[\\d|.|+|\\-|e|E]+)( +[\\d|.|+|\\-|e|E]+)/;\r\n /** Pattern used to detect a first kind of face (f vertex vertex vertex) */\r\n public static FacePattern1 = /^f\\s+(([\\d]{1,}[\\s]?){3,})+/;\r\n /** Pattern used to detect a second kind of face (f vertex/uvs vertex/uvs vertex/uvs) */\r\n public static FacePattern2 = /^f\\s+((([\\d]{1,}\\/[\\d]{1,}[\\s]?){3,})+)/;\r\n /** Pattern used to detect a third kind of face (f vertex/uvs/normal vertex/uvs/normal vertex/uvs/normal) */\r\n public static FacePattern3 = /^f\\s+((([\\d]{1,}\\/[\\d]{1,}\\/[\\d]{1,}[\\s]?){3,})+)/;\r\n /** Pattern used to detect a fourth kind of face (f vertex//normal vertex//normal vertex//normal)*/\r\n public static FacePattern4 = /^f\\s+((([\\d]{1,}\\/\\/[\\d]{1,}[\\s]?){3,})+)/;\r\n /** Pattern used to detect a fifth kind of face (f -vertex/-uvs/-normal -vertex/-uvs/-normal -vertex/-uvs/-normal) */\r\n public static FacePattern5 = /^f\\s+(((-[\\d]{1,}\\/-[\\d]{1,}\\/-[\\d]{1,}[\\s]?){3,})+)/;\r\n /** Pattern used to detect a line(l vertex vertex) */\r\n public static LinePattern1 = /^l\\s+(([\\d]{1,}[\\s]?){2,})+/;\r\n /** Pattern used to detect a second kind of line (l vertex/uvs vertex/uvs) */\r\n public static LinePattern2 = /^l\\s+((([\\d]{1,}\\/[\\d]{1,}[\\s]?){2,})+)/;\r\n /** Pattern used to detect a third kind of line (l vertex/uvs/normal vertex/uvs/normal) */\r\n public static LinePattern3 = /^l\\s+((([\\d]{1,}\\/[\\d]{1,}\\/[\\d]{1,}[\\s]?){2,})+)/;\r\n\r\n private _loadingOptions: OBJLoadingOptions;\r\n private _positions: Array<Vector3> = []; //values for the positions of vertices\r\n private _normals: Array<Vector3> = []; //Values for the normals\r\n private _uvs: Array<Vector2> = []; //Values for the textures\r\n private _colors: Array<Color4> = [];\r\n private _meshesFromObj: Array<MeshObject> = []; //[mesh] Contains all the obj meshes\r\n private _handledMesh: MeshObject; //The current mesh of meshes array\r\n private _indicesForBabylon: Array<number> = []; //The list of indices for VertexData\r\n private _wrappedPositionForBabylon: Array<Vector3> = []; //The list of position in vectors\r\n private _wrappedUvsForBabylon: Array<Vector2> = []; //Array with all value of uvs to match with the indices\r\n private _wrappedColorsForBabylon: Array<Color4> = []; // Array with all color values to match with the indices\r\n private _wrappedNormalsForBabylon: Array<Vector3> = []; //Array with all value of normals to match with the indices\r\n private _tuplePosNorm: Array<{ normals: Array<number>; idx: Array<number>; uv: Array<number> }> = []; //Create a tuple with indice of Position, Normal, UV [pos, norm, uvs]\r\n private _curPositionInIndices = 0;\r\n private _hasMeshes: Boolean = false; //Meshes are defined in the file\r\n private _unwrappedPositionsForBabylon: Array<number> = []; //Value of positionForBabylon w/o Vector3() [x,y,z]\r\n private _unwrappedColorsForBabylon: Array<number> = []; // Value of colorForBabylon w/o Color4() [r,g,b,a]\r\n private _unwrappedNormalsForBabylon: Array<number> = []; //Value of normalsForBabylon w/o Vector3() [x,y,z]\r\n private _unwrappedUVForBabylon: Array<number> = []; //Value of uvsForBabylon w/o Vector3() [x,y,z]\r\n private _triangles: Array<string> = []; //Indices from new triangles coming from polygons\r\n private _materialNameFromObj: string = \"\"; //The name of the current material\r\n private _objMeshName: string = \"\"; //The name of the current obj mesh\r\n private _increment: number = 1; //Id for meshes created by the multimaterial\r\n private _isFirstMaterial: boolean = true;\r\n private _grayColor = new Color4(0.5, 0.5, 0.5, 1);\r\n private _materialToUse: string[];\r\n private _babylonMeshesArray: Array<Mesh>;\r\n\r\n /**\r\n * Creates a new SolidParser\r\n * @param materialToUse defines the array to fill with the list of materials to use (it will be filled by the parse function)\r\n * @param babylonMeshesArray defines the array to fill with the list of loaded meshes (it will be filled by the parse function)\r\n * @param loadingOptions defines the loading options to use\r\n */\r\n public constructor(materialToUse: string[], babylonMeshesArray: Array<Mesh>, loadingOptions: OBJLoadingOptions) {\r\n this._materialToUse = materialToUse;\r\n this._babylonMeshesArray = babylonMeshesArray;\r\n this._loadingOptions = loadingOptions;\r\n }\r\n\r\n /**\r\n * Search for obj in the given array.\r\n * This function is called to check if a couple of data already exists in an array.\r\n *\r\n * If found, returns the index of the founded tuple index. Returns -1 if not found\r\n * @param arr Array<{ normals: Array<number>, idx: Array<number> }>\r\n * @param obj Array<number>\r\n * @returns {boolean}\r\n */\r\n private _isInArray(arr: Array<{ normals: Array<number>; idx: Array<number> }>, obj: Array<number>) {\r\n if (!arr[obj[0]]) {\r\n arr[obj[0]] = { normals: [], idx: [] };\r\n }\r\n const idx = arr[obj[0]].normals.indexOf(obj[1]);\r\n\r\n return idx === -1 ? -1 : arr[obj[0]].idx[idx];\r\n }\r\n\r\n private _isInArrayUV(arr: Array<{ normals: Array<number>; idx: Array<number>; uv: Array<number> }>, obj: Array<number>) {\r\n if (!arr[obj[0]]) {\r\n arr[obj[0]] = { normals: [], idx: [], uv: [] };\r\n }\r\n const idx = arr[obj[0]].normals.indexOf(obj[1]);\r\n\r\n if (idx != 1 && obj[2] === arr[obj[0]].uv[idx]) {\r\n return arr[obj[0]].idx[idx];\r\n }\r\n return -1;\r\n }\r\n\r\n /**\r\n * This function set the data for each triangle.\r\n * Data are position, normals and uvs\r\n * If a tuple of (position, normal) is not set, add the data into the corresponding array\r\n * If the tuple already exist, add only their indice\r\n *\r\n * @param indicePositionFromObj Integer The index in positions array\r\n * @param indiceUvsFromObj Integer The index in uvs array\r\n * @param indiceNormalFromObj Integer The index in normals array\r\n * @param positionVectorFromOBJ Vector3 The value of position at index objIndice\r\n * @param textureVectorFromOBJ Vector3 The value of uvs\r\n * @param normalsVectorFromOBJ Vector3 The value of normals at index objNormale\r\n * @param positionColorsFromOBJ\r\n */\r\n private _setData(\r\n indicePositionFromObj: number,\r\n indiceUvsFromObj: number,\r\n indiceNormalFromObj: number,\r\n positionVectorFromOBJ: Vector3,\r\n textureVectorFromOBJ: Vector2,\r\n normalsVectorFromOBJ: Vector3,\r\n positionColorsFromOBJ?: Color4\r\n ) {\r\n //Check if this tuple already exists in the list of tuples\r\n let _index: number;\r\n if (this._loadingOptions.optimizeWithUV) {\r\n _index = this._isInArrayUV(this._tuplePosNorm, [indicePositionFromObj, indiceNormalFromObj, indiceUvsFromObj]);\r\n } else {\r\n _index = this._isInArray(this._tuplePosNorm, [indicePositionFromObj, indiceNormalFromObj]);\r\n }\r\n\r\n //If it not exists\r\n if (_index === -1) {\r\n //Add an new indice.\r\n //The array of indices is only an array with his length equal to the number of triangles - 1.\r\n //We add vertices data in this order\r\n this._indicesForBabylon.push(this._wrappedPositionForBabylon.length);\r\n //Push the position of vertice for Babylon\r\n //Each element is a Vector3(x,y,z)\r\n this._wrappedPositionForBabylon.push(positionVectorFromOBJ);\r\n //Push the uvs for Babylon\r\n //Each element is a Vector3(u,v)\r\n this._wrappedUvsForBabylon.push(textureVectorFromOBJ);\r\n //Push the normals for Babylon\r\n //Each element is a Vector3(x,y,z)\r\n this._wrappedNormalsForBabylon.push(normalsVectorFromOBJ);\r\n\r\n if (positionColorsFromOBJ !== undefined) {\r\n //Push the colors for Babylon\r\n //Each element is a BABYLON.Color4(r,g,b,a)\r\n this._wrappedColorsForBabylon.push(positionColorsFromOBJ);\r\n }\r\n\r\n //Add the tuple in the comparison list\r\n this._tuplePosNorm[indicePositionFromObj].normals.push(indiceNormalFromObj);\r\n this._tuplePosNorm[indicePositionFromObj].idx.push(this._curPositionInIndices++);\r\n if (this._loadingOptions.optimizeWithUV) {\r\n this._tuplePosNorm[indicePositionFromObj].uv.push(indiceUvsFromObj);\r\n }\r\n } else {\r\n //The tuple already exists\r\n //Add the index of the already existing tuple\r\n //At this index we can get the value of position, normal, color and uvs of vertex\r\n this._indicesForBabylon.push(_index);\r\n }\r\n }\r\n\r\n /**\r\n * Transform Vector() and BABYLON.Color() objects into numbers in an array\r\n */\r\n private _unwrapData() {\r\n //Every array has the same length\r\n for (let l = 0; l < this._wrappedPositionForBabylon.length; l++) {\r\n //Push the x, y, z values of each element in the unwrapped array\r\n this._unwrappedPositionsForBabylon.push(this._wrappedPositionForBabylon[l].x, this._wrappedPositionForBabylon[l].y, this._wrappedPositionForBabylon[l].z);\r\n this._unwrappedNormalsForBabylon.push(this._wrappedNormalsForBabylon[l].x, this._wrappedNormalsForBabylon[l].y, this._wrappedNormalsForBabylon[l].z);\r\n this._unwrappedUVForBabylon.push(this._wrappedUvsForBabylon[l].x, this._wrappedUvsForBabylon[l].y); //z is an optional value not supported by BABYLON\r\n if (this._loadingOptions.importVertexColors) {\r\n //Push the r, g, b, a values of each element in the unwrapped array\r\n this._unwrappedColorsForBabylon.push(\r\n this._wrappedColorsForBabylon[l].r,\r\n this._wrappedColorsForBabylon[l].g,\r\n this._wrappedColorsForBabylon[l].b,\r\n this._wrappedColorsForBabylon[l].a\r\n );\r\n }\r\n }\r\n // Reset arrays for the next new meshes\r\n this._wrappedPositionForBabylon.length = 0;\r\n this._wrappedNormalsForBabylon.length = 0;\r\n this._wrappedUvsForBabylon.length = 0;\r\n this._wrappedColorsForBabylon.length = 0;\r\n this._tuplePosNorm.length = 0;\r\n this._curPositionInIndices = 0;\r\n }\r\n\r\n /**\r\n * Create triangles from polygons\r\n * It is important to notice that a triangle is a polygon\r\n * We get 5 patterns of face defined in OBJ File :\r\n * facePattern1 = [\"1\",\"2\",\"3\",\"4\",\"5\",\"6\"]\r\n * facePattern2 = [\"1/1\",\"2/2\",\"3/3\",\"4/4\",\"5/5\",\"6/6\"]\r\n * facePattern3 = [\"1/1/1\",\"2/2/2\",\"3/3/3\",\"4/4/4\",\"5/5/5\",\"6/6/6\"]\r\n * facePattern4 = [\"1//1\",\"2//2\",\"3//3\",\"4//4\",\"5//5\",\"6//6\"]\r\n * facePattern5 = [\"-1/-1/-1\",\"-2/-2/-2\",\"-3/-3/-3\",\"-4/-4/-4\",\"-5/-5/-5\",\"-6/-6/-6\"]\r\n * Each pattern is divided by the same method\r\n * @param faces Array[String] The indices of elements\r\n * @param v Integer The variable to increment\r\n */\r\n private _getTriangles(faces: Array<string>, v: number) {\r\n //Work for each element of the array\r\n for (let faceIndex = v; faceIndex < faces.length - 1; faceIndex++) {\r\n //Add on the triangle variable the indexes to obtain triangles\r\n this._triangles.push(faces[0], faces[faceIndex], faces[faceIndex + 1]);\r\n }\r\n\r\n //Result obtained after 2 iterations:\r\n //Pattern1 => triangle = [\"1\",\"2\",\"3\",\"1\",\"3\",\"4\"];\r\n //Pattern2 => triangle = [\"1/1\",\"2/2\",\"3/3\",\"1/1\",\"3/3\",\"4/4\"];\r\n //Pattern3 => triangle = [\"1/1/1\",\"2/2/2\",\"3/3/3\",\"1/1/1\",\"3/3/3\",\"4/4/4\"];\r\n //Pattern4 => triangle = [\"1//1\",\"2//2\",\"3//3\",\"1//1\",\"3//3\",\"4//4\"];\r\n //Pattern5 => triangle = [\"-1/-1/-1\",\"-2/-2/-2\",\"-3/-3/-3\",\"-1/-1/-1\",\"-3/-3/-3\",\"-4/-4/-4\"];\r\n }\r\n\r\n /**\r\n * Create triangles and push the data for each polygon for the pattern 1\r\n * In this pattern we get vertice positions\r\n * @param face\r\n * @param v\r\n */\r\n private _setDataForCurrentFaceWithPattern1(face: Array<string>, v: number) {\r\n //Get the indices of triangles for each polygon\r\n this._getTriangles(face, v);\r\n //For each element in the triangles array.\r\n //This var could contains 1 to an infinity of triangles\r\n for (let k = 0; k < this._triangles.length; k++) {\r\n // Set position indice\r\n const indicePositionFromObj = parseInt(this._triangles[k]) - 1;\r\n\r\n this._setData(\r\n indicePositionFromObj,\r\n 0,\r\n 0, // In the pattern 1, normals and uvs are not defined\r\n this._positions[indicePositionFromObj], // Get the vectors data\r\n Vector2.Zero(),\r\n Vector3.Up(), // Create default vectors\r\n this._loadingOptions.importVertexColors ? this._colors[indicePositionFromObj] : undefined\r\n );\r\n }\r\n //Reset variable for the next line\r\n this._triangles.length = 0;\r\n }\r\n\r\n /**\r\n * Create triangles and push the data for each polygon for the pattern 2\r\n * In this pattern we get vertice positions and uvs\r\n * @param face\r\n * @param v\r\n */\r\n private _setDataForCurrentFaceWithPattern2(face: Array<string>, v: number) {\r\n //Get the indices of triangles for each polygon\r\n this._getTriangles(face, v);\r\n for (let k = 0; k < this._triangles.length; k++) {\r\n //triangle[k] = \"1/1\"\r\n //Split the data for getting position and uv\r\n const point = this._triangles[k].split(\"/\"); // [\"1\", \"1\"]\r\n //Set position indice\r\n const indicePositionFromObj = parseInt(point[0]) - 1;\r\n //Set uv indice\r\n const indiceUvsFromObj = parseInt(point[1]) - 1;\r\n\r\n this._setData(\r\n indicePositionFromObj,\r\n indiceUvsFromObj,\r\n 0, //Default value for normals\r\n this._positions[indicePositionFromObj], //Get the values for each element\r\n this._uvs[indiceUvsFromObj],\r\n Vector3.Up(), //Default value for normals\r\n this._loadingOptions.importVertexColors ? this._colors[indicePositionFromObj] : undefined\r\n );\r\n }\r\n\r\n //Reset variable for the next line\r\n this._triangles.length = 0;\r\n }\r\n\r\n /**\r\n * Create triangles and push the data for each polygon for the pattern 3\r\n * In this pattern we get vertice positions, uvs and normals\r\n * @param face\r\n * @param v\r\n */\r\n private _setDataForCurrentFaceWithPattern3(face: Array<string>, v: number) {\r\n //Get the indices of triangles for each polygon\r\n this._getTriangles(face, v);\r\n\r\n for (let k = 0; k < this._triangles.length; k++) {\r\n //triangle[k] = \"1/1/1\"\r\n //Split the data for getting position, uv, and normals\r\n const point = this._triangles[k].split(\"/\"); // [\"1\", \"1\", \"1\"]\r\n // Set position indice\r\n const indicePositionFromObj = parseInt(point[0]) - 1;\r\n // Set uv indice\r\n const indiceUvsFromObj = parseInt(point[1]) - 1;\r\n // Set normal indice\r\n const indiceNormalFromObj = parseInt(point[2]) - 1;\r\n\r\n this._setData(\r\n indicePositionFromObj,\r\n indiceUvsFromObj,\r\n indiceNormalFromObj,\r\n this._positions[indicePositionFromObj],\r\n this._uvs[indiceUvsFromObj],\r\n this._normals[indiceNormalFromObj] //Set the vector for each component\r\n );\r\n }\r\n //Reset variable for the next line\r\n this._triangles.length = 0;\r\n }\r\n\r\n /**\r\n * Create triangles and push the data for each polygon for the pattern 4\r\n * In this pattern we get vertice positions and normals\r\n * @param face\r\n * @param v\r\n */\r\n private _setDataForCurrentFaceWithPattern4(face: Array<string>, v: number) {\r\n this._getTriangles(face, v);\r\n\r\n for (let k = 0; k < this._triangles.length; k++) {\r\n //triangle[k] = \"1//1\"\r\n //Split the data for getting position and normals\r\n const point = this._triangles[k].split(\"//\"); // [\"1\", \"1\"]\r\n // We check indices, and normals\r\n const indicePositionFromObj = parseInt(point[0]) - 1;\r\n const indiceNormalFromObj = parseInt(point[1]) - 1;\r\n\r\n this._setData(\r\n indicePositionFromObj,\r\n 1, //Default value for uv\r\n indiceNormalFromObj,\r\n this._positions[indicePositionFromObj], //Get each vector of data\r\n Vector2.Zero(),\r\n this._normals[indiceNormalFromObj],\r\n this._loadingOptions.importVertexColors ? this._colors[indicePositionFromObj] : undefined\r\n );\r\n }\r\n //Reset variable for the next line\r\n this._triangles.length = 0;\r\n }\r\n\r\n /*\r\n * Create triangles and push the data for each polygon for the pattern 3\r\n * In this pattern we get vertice positions, uvs and normals\r\n * @param face\r\n * @param v\r\n */\r\n private _setDataForCurrentFaceWithPattern5(face: Array<string>, v: number) {\r\n //Get the indices of triangles for each polygon\r\n this._getTriangles(face, v);\r\n\r\n for (let k = 0; k < this._triangles.length; k++) {\r\n //triangle[k] = \"-1/-1/-1\"\r\n //Split the data for getting position, uv, and normals\r\n const point = this._triangles[k].split(\"/\"); // [\"-1\", \"-1\", \"-1\"]\r\n // Set position indice\r\n const indicePositionFromObj = this._positions.length + parseInt(point[0]);\r\n // Set uv indice\r\n const indiceUvsFromObj = this._uvs.length + parseInt(point[1]);\r\n // Set normal indice\r\n const indiceNormalFromObj = this._normals.length + parseInt(point[2]);\r\n\r\n this._setData(\r\n indicePositionFromObj,\r\n indiceUvsFromObj,\r\n indiceNormalFromObj,\r\n this._positions[indicePositionFromObj],\r\n this._uvs[indiceUvsFromObj],\r\n this._normals[indiceNormalFromObj], //Set the vector for each component\r\n this._loadingOptions.importVertexColors ? this._colors[indicePositionFromObj] : undefined\r\n );\r\n }\r\n //Reset variable for the next line\r\n this._triangles.length = 0;\r\n }\r\n\r\n private _addPreviousObjMesh() {\r\n //Check if it is not the first mesh. Otherwise we don't have data.\r\n if (this._meshesFromObj.length > 0) {\r\n //Get the previous mesh for applying the data about the faces\r\n //=> in obj file, faces definition append after the name of the mesh\r\n this._handledMesh = this._meshesFromObj[this._meshesFromObj.length - 1];\r\n\r\n //Set the data into Array for the mesh\r\n this._unwrapData();\r\n\r\n // Reverse tab. Otherwise face are displayed in the wrong sens\r\n this._indicesForBabylon.reverse();\r\n //Set the information for the mesh\r\n //Slice the array to avoid rewriting because of the fact this is the same var which be rewrited\r\n this._handledMesh.indices = this._indicesForBabylon.slice();\r\n this._handledMesh.positions = this._unwrappedPositionsForBabylon.slice();\r\n this._handledMesh.normals = this._unwrappedNormalsForBabylon.slice();\r\n this._handledMesh.uvs = this._unwrappedUVForBabylon.slice();\r\n\r\n if (this._loadingOptions.importVertexColors) {\r\n this._handledMesh.colors = this._unwrappedColorsForBabylon.slice();\r\n }\r\n\r\n //Reset the array for the next mesh\r\n this._indicesForBabylon.length = 0;\r\n this._unwrappedPositionsForBabylon.length = 0;\r\n this._unwrappedColorsForBabylon.length = 0;\r\n this._unwrappedNormalsForBabylon.length = 0;\r\n this._unwrappedUVForBabylon.length = 0;\r\n }\r\n }\r\n\r\n private _optimizeNormals(mesh: AbstractMesh): void {\r\n const positions = mesh.getVerticesData(VertexBuffer.PositionKind);\r\n const normals = mesh.getVerticesData(VertexBuffer.NormalKind);\r\n const mapVertices: { [key: string]: number[] } = {};\r\n\r\n if (!positions || !normals) {\r\n return;\r\n }\r\n\r\n for (let i = 0; i < positions.length / 3; i++) {\r\n const x = positions[i * 3 + 0];\r\n const y = positions[i * 3 + 1];\r\n const z = positions[i * 3 + 2];\r\n const key = x + \"_\" + y + \"_\" + z;\r\n\r\n let lst = mapVertices[key];\r\n if (!lst) {\r\n lst = [];\r\n mapVertices[key] = lst;\r\n }\r\n lst.push(i);\r\n }\r\n\r\n const normal = new Vector3();\r\n for (const key in mapVertices) {\r\n const lst = mapVertices[key];\r\n if (lst.length < 2) {\r\n continue;\r\n }\r\n\r\n const v0Idx = lst[0];\r\n for (let i = 1; i < lst.length; ++i) {\r\n const vIdx = lst[i];\r\n normals[v0Idx * 3 + 0] += normals[vIdx * 3 + 0];\r\n normals[v0Idx * 3 + 1] += normals[vIdx * 3 + 1];\r\n normals[v0Idx * 3 + 2] += normals[vIdx * 3 + 2];\r\n }\r\n\r\n normal.copyFromFloats(normals[v0Idx * 3 + 0], normals[v0Idx * 3 + 1], normals[v0Idx * 3 + 2]);\r\n normal.normalize();\r\n\r\n for (let i = 0; i < lst.length; ++i) {\r\n const vIdx = lst[i];\r\n normals[vIdx * 3 + 0] = normal.x;\r\n normals[vIdx * 3 + 1] = normal.y;\r\n normals[vIdx * 3 + 2] = normal.z;\r\n }\r\n }\r\n mesh.setVerticesData(VertexBuffer.NormalKind, normals);\r\n }\r\n\r\n /**\r\n * Function used to parse an OBJ string\r\n * @param meshesNames defines the list of meshes to load (all if not defined)\r\n * @param data defines the OBJ string\r\n * @param scene defines the hosting scene\r\n * @param assetContainer defines the asset container to load data in\r\n * @param onFileToLoadFound defines a callback that will be called if a MTL file is found\r\n */\r\n public parse(meshesNames: any, data: string, scene: Scene, assetContainer: Nullable<AssetContainer>, onFileToLoadFound: (fileToLoad: string) => void): void {\r\n // Split the file into lines\r\n const lines = data.split(\"\\n\");\r\n // Look at each line\r\n for (let i = 0; i < lines.length; i++) {\r\n const line = lines[i].trim().replace(/\\s\\s/g, \" \");\r\n let result;\r\n\r\n // Comment or newLine\r\n if (line.length === 0 || line.charAt(0) === \"#\") {\r\n continue;\r\n\r\n //Get information about one position possible for the vertices\r\n } else if (SolidParser.VertexPattern.test(line)) {\r\n result = line.match(/[^ ]+/g)!; // match will return non-null due to passing regex pattern\r\n\r\n // Value of result with line: \"v 1.0 2.0 3.0\"\r\n // [\"v\", \"1.0\", \"2.0\", \"3.0\"]\r\n // Create a Vector3 with the position x, y, z\r\n this._positions.push(new Vector3(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3])));\r\n\r\n if (this._loadingOptions.importVertexColors) {\r\n if (result.length >= 7) {\r\n const r = parseFloat(result[4]);\r\n const g = parseFloat(result[5]);\r\n const b = parseFloat(result[6]);\r\n\r\n this._colors.push(\r\n new Color4(r > 1 ? r / 255 : r, g > 1 ? g / 255 : g, b > 1 ? b / 255 : b, result.length === 7 || result[7] === undefined ? 1 : parseFloat(result[7]))\r\n );\r\n } else {\r\n // TODO: maybe push NULL and if all are NULL to skip (and remove grayColor var).\r\n this._colors.push(this._grayColor);\r\n }\r\n }\r\n } else if ((result = SolidParser.NormalPattern.exec(line)) !== null) {\r\n //Create a Vector3 with the normals x, y, z\r\n //Value of result\r\n // [\"vn 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\r\n //Add the Vector in the list of normals\r\n this._normals.push(new Vector3(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3])));\r\n } else if ((result = SolidParser.UVPattern.exec(line)) !== null) {\r\n //Create a Vector2 with the normals u, v\r\n //Value of result\r\n // [\"vt 0.1 0.2 0.3\", \"0.1\", \"0.2\"]\r\n //Add the Vector in the list of uvs\r\n this._uvs.push(new Vector2(parseFloat(result[1]) * this._loadingOptions.UVScaling.x, parseFloat(result[2]) * this._loadingOptions.UVScaling.y));\r\n\r\n //Identify patterns of faces\r\n //Face could be defined in different type of pattern\r\n } else if ((result = SolidParser.FacePattern3.exec(line)) !== null) {\r\n //Value of result:\r\n //[\"f 1/1/1 2/2/2 3/3/3\", \"1/1/1 2/2/2 3/3/3\"...]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern3(\r\n result[1].trim().split(\" \"), // [\"1/1/1\", \"2/2/2\", \"3/3/3\"]\r\n 1\r\n );\r\n } else if ((result = SolidParser.FacePattern4.exec(line)) !== null) {\r\n //Value of result:\r\n //[\"f 1//1 2//2 3//3\", \"1//1 2//2 3//3\"...]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern4(\r\n result[1].trim().split(\" \"), // [\"1//1\", \"2//2\", \"3//3\"]\r\n 1\r\n );\r\n } else if ((result = SolidParser.FacePattern5.exec(line)) !== null) {\r\n //Value of result:\r\n //[\"f -1/-1/-1 -2/-2/-2 -3/-3/-3\", \"-1/-1/-1 -2/-2/-2 -3/-3/-3\"...]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern5(\r\n result[1].trim().split(\" \"), // [\"-1/-1/-1\", \"-2/-2/-2\", \"-3/-3/-3\"]\r\n 1\r\n );\r\n } else if ((result = SolidParser.FacePattern2.exec(line)) !== null) {\r\n //Value of result:\r\n //[\"f 1/1 2/2 3/3\", \"1/1 2/2 3/3\"...]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern2(\r\n result[1].trim().split(\" \"), // [\"1/1\", \"2/2\", \"3/3\"]\r\n 1\r\n );\r\n } else if ((result = SolidParser.FacePattern1.exec(line)) !== null) {\r\n //Value of result\r\n //[\"f 1 2 3\", \"1 2 3\"...]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern1(\r\n result[1].trim().split(\" \"), // [\"1\", \"2\", \"3\"]\r\n 1\r\n );\r\n\r\n // Define a mesh or an object\r\n // Each time this keyword is analyzed, create a new Object with all data for creating a babylonMesh\r\n } else if ((result = SolidParser.LinePattern1.exec(line)) !== null) {\r\n //Value of result\r\n //[\"l 1 2\"]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern1(\r\n result[1].trim().split(\" \"), // [\"1\", \"2\"]\r\n 0\r\n );\r\n\r\n // Define a mesh or an object\r\n // Each time this keyword is analyzed, create a new Object with all data for creating a babylonMesh\r\n } else if ((result = SolidParser.LinePattern2.exec(line)) !== null) {\r\n //Value of result\r\n //[\"l 1/1 2/2\"]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern2(\r\n result[1].trim().split(\" \"), // [\"1/1\", \"2/2\"]\r\n 0\r\n );\r\n\r\n // Define a mesh or an object\r\n // Each time this keyword is analyzed, create a new Object with all data for creating a babylonMesh\r\n } else if ((result = SolidParser.LinePattern3.exec(line)) !== null) {\r\n //Value of result\r\n //[\"l 1/1/1 2/2/2\"]\r\n\r\n //Set the data for this face\r\n this._setDataForCurrentFaceWithPattern3(\r\n result[1].trim().split(\" \"), // [\"1/1/1\", \"2/2/2\"]\r\n 0\r\n );\r\n\r\n // Define a mesh or an object\r\n // Each time this keyword is analyzed, create a new Object with all data for creating a babylonMesh\r\n } else if (SolidParser.GroupDescriptor.test(line) || SolidParser.ObjectDescriptor.test(line)) {\r\n // Create a new mesh corresponding to the name of the group.\r\n // Definition of the mesh\r\n const objMesh: MeshObject = {\r\n name: line.substring(2).trim(), //Set the name of the current obj mesh\r\n indices: undefined,\r\n positions: undefined,\r\n normals: undefined,\r\n uvs: undefined,\r\n colors: undefined,\r\n materialName: this._materialNameFromObj,\r\n isObject: SolidParser.ObjectDescriptor.test(line),\r\n };\r\n this._addPreviousObjMesh();\r\n\r\n //Push the last mesh created with only the name\r\n this._meshesFromObj.push(objMesh);\r\n\r\n //Set this variable to indicate that now meshesFromObj has objects defined inside\r\n this._hasMeshes = true;\r\n this._isFirstMaterial = true;\r\n this._increment = 1;\r\n //Keyword for applying a material\r\n } else if (SolidParser.UseMtlDescriptor.test(line)) {\r\n //Get the name of the material\r\n this._materialNameFromObj = line.substring(7).trim();\r\n\r\n //If this new material is in the same mesh\r\n\r\n if (!this._isFirstMaterial || !this._hasMeshes) {\r\n //Set the data for the previous mesh\r\n this._addPreviousObjMesh();\r\n //Create a new mesh\r\n const objMesh: MeshObject =\r\n //Set the name of the current obj mesh\r\n {\r\n name: (this._objMeshName || \"mesh\") + \"_mm\" + this._increment.toString(), //Set the name of the current obj mesh\r\n indices: undefined,\r\n positions: undefined,\r\n normals: undefined,\r\n uvs: undefined,\r\n colors: undefined,\r\n materialName: this._materialNameFromObj,\r\n isObject: false,\r\n };\r\n this._increment++;\r\n //If meshes are already defined\r\n this._meshesFromObj.push(objMesh);\r\n this._hasMeshes = true;\r\n }\r\n //Set the material name if the previous line define a mesh\r\n\r\n if (this._hasMeshes && this._isFirstMaterial) {\r\n //Set the material name to the previous mesh (1 material per mesh)\r\n this._meshesFromObj[this._meshesFromObj.length - 1].materialName = this._materialNameFromObj;\r\n this._isFirstMaterial = false;\r\n }\r\n // Keyword for loading the mtl file\r\n } else if (SolidParser.MtlLibGroupDescriptor.test(line)) {\r\n // Get the name of mtl file\r\n onFileToLoadFound(line.substring(7).trim());\r\n\r\n // Apply smoothing\r\n } else if (SolidParser.SmoothDescriptor.test(line)) {\r\n // smooth shading => apply smoothing\r\n // Today I don't know it work with babylon and with obj.\r\n // With the obj file an integer is set\r\n } else {\r\n //If there is another possibility\r\n Logger.Log(\"Unhandled expression at line : \" + line);\r\n }\r\n }\r\n\r\n // At the end of the file, add the last mesh into the meshesFromObj array\r\n if (this._hasMeshes) {\r\n // Set the data for the last mesh\r\n this._handledMesh = this._meshesFromObj[this._meshesFromObj.length - 1];\r\n\r\n //Reverse indices for displaying faces in the good sense\r\n this._indicesForBabylon.reverse();\r\n //Get the good array\r\n this._unwrapData();\r\n //Set array\r\n this._handledMesh.indices = this._indicesForBabylon;\r\n this._handledMesh.positions = this._unwrappedPositionsForBabylon;\r\n this._handledMesh.normals = this._unwrappedNormalsForBabylon;\r\n this._handledMesh.uvs = this._unwrappedUVForBabylon;\r\n\r\n if (this._loadingOptions.importVertexColors) {\r\n this._handledMesh.colors = this._unwrappedColorsForBabylon;\r\n }\r\n }\r\n\r\n // If any o or g keyword not found, create a mesh with a random id\r\n if (!this._hasMeshes) {\r\n let newMaterial: Nullable<StandardMaterial> = null;\r\n if (this._indicesForBabylon.length) {\r\n // reverse tab of indices\r\n this._indicesForBabylon.reverse();\r\n //Get positions normals uvs\r\n this._unwrapData();\r\n } else {\r\n // There is no indices in the file. We will have to switch to point cloud rendering\r\n for (const pos of this._positions) {\r\n this._unwrappedPositionsForBabylon.push(pos.x, pos.y, pos.z);\r\n }\r\n\r\n if (this._normals.length) {\r\n for (const normal of this._normals) {\r\n this._unwrappedNormalsForBabylon.push(normal.x, normal.y, normal.z);\r\n }\r\n }\r\n\r\n if (this._uvs.length) {\r\n for (const uv of this._uvs) {\r\n this._unwrappedUVForBabylon.push(uv.x, uv.y);\r\n }\r\n }\r\n\r\n if (this._colors.length) {\r\n for (const color of this._colors) {\r\n this._unwrappedColorsForBabylon.push(color.r, color.g, color.b, color.a);\r\n }\r\n }\r\n\r\n if (!this._materialNameFromObj) {\r\n // Create a material with point cloud on\r\n newMaterial = new StandardMaterial(Geometry.RandomId(), scene);\r\n\r\n newMaterial.pointsCloud = true;\r\n\r\n this._materialNameFromObj = newMaterial.name;\r\n\r\n if (!this._normals.length) {\r\n newMaterial.disableLighting = true;\r\n newMaterial.emissiveColor = Color3.White();\r\n }\r\n }\r\n }\r\n\r\n //Set data for one mesh\r\n this._meshesFromObj.push({\r\n name: Geometry.RandomId(),\r\n indices: this._indicesForBabylon,\r\n positions: this._unwrappedPositionsForBabylon,\r\n colors: this._unwrappedColorsForBabylon,\r\n normals: this._unwrappedNormalsForBabylon,\r\n uvs: this._unwrappedUVForBabylon,\r\n materialName: this._materialNameFromObj,\r\n directMaterial: newMaterial,\r\n isObject: true,\r\n });\r\n }\r\n\r\n //Set data for each mesh\r\n for (let j = 0; j < this._meshesFromObj.length; j++) {\r\n //check meshesNames (stlFileLoader)\r\n if (meshesNames && this._meshesFromObj[j].name) {\r\n if (meshesNames instanceof Array) {\r\n if (meshesNames.indexOf(this._meshesFromObj[j].name) === -1) {\r\n continue;\r\n }\r\n } else {\r\n if (this._meshesFromObj[j].name !== meshesNames) {\r\n continue;\r\n }\r\n }\r\n }\r\n\r\n //Get the current mesh\r\n //Set the data with VertexBuffer for each mesh\r\n this._handledMesh = this._meshesFromObj[j];\r\n //Create a Mesh with the name of the obj mesh\r\n\r\n scene._blockEntityCollection = !!assetContainer;\r\n const babylonMesh = new Mesh(this._meshesFromObj[j].name, scene);\r\n babylonMesh._parentContainer = assetContainer;\r\n scene._blockEntityCollection = false;\r\n this._handledMesh._babylonMesh = babylonMesh;\r\n // If this is a group mesh, it should have an object mesh as a parent. So look for the first object mesh that appears before it.\r\n if (!this._handledMesh.isObject) {\r\n for (let k = j - 1; k >= 0; --k) {\r\n if (this._meshesFromObj[k].isObject && this._meshesFromObj[k]._babylonMesh) {\r\n babylonMesh.parent = this._meshesFromObj[k]._babylonMesh!;\r\n break;\r\n }\r\n }\r\n }\r\n\r\n //Push the name of the material to an array\r\n //This is indispensable for the importMesh function\r\n this._materialToUse.push(this._meshesFromObj[j].materialName);\r\n\r\n if (this._handledMesh.positions?.length === 0) {\r\n //Push the mesh into an array\r\n this._babylonMeshesArray.push(babylonMesh);\r\n continue;\r\n }\r\n\r\n const vertexData: VertexData = new VertexData(); //The container for the values\r\n //Set the data for the babylonMesh\r\n vertexData.uvs = this._handledMesh.uvs as FloatArray;\r\n vertexData.indices = this._handledMesh.indices as IndicesArray;\r\n vertexData.positions = this._handledMesh.positions as FloatArray;\r\n if (this._loadingOptions.computeNormals) {\r\n const normals: Array<number> = new Array<number>();\r\n VertexData.ComputeNormals(this._handledMesh.positions, this._handledMesh.indices, normals);\r\n vertexData.normals = normals;\r\n } else {\r\n vertexData.normals = this._handledMesh.normals as FloatArray;\r\n }\r\n if (this._loadingOptions.importVertexColors) {\r\n vertexData.colors = this._handledMesh.colors as FloatArray;\r\n }\r\n //Set the data from the VertexBuffer to the current Mesh\r\n vertexData.applyToMesh(babylonMesh);\r\n if (this._loadingOptions.invertY) {\r\n babylonMesh.scaling.y *= -1;\r\n }\r\n if (this._loadingOptions.optimizeNormals) {\r\n this._optimizeNormals(babylonMesh);\r\n }\r\n\r\n //Push the mesh into an array\r\n this._babylonMeshesArray.push(babylonMesh);\r\n\r\n if (this._handledMesh.directMaterial) {\r\n babylonMesh.material = this._handledMesh.directMaterial;\r\n }\r\n }\r\n }\r\n}\r\n"]}
|
@@ -33,13 +33,9 @@ export class KHR_draco_mesh_compression {
|
|
33
33
|
_loadVertexDataAsync(context, primitive, babylonMesh) {
|
34
34
|
return GLTFLoader.LoadExtensionAsync(context, primitive, this.name, (extensionContext, extension) => {
|
35
35
|
if (primitive.mode != undefined) {
|
36
|
-
if (primitive.mode !==
|
36
|
+
if (primitive.mode !== 4 /* MeshPrimitiveMode.TRIANGLES */ && primitive.mode !== 5 /* MeshPrimitiveMode.TRIANGLE_STRIP */) {
|
37
37
|
throw new Error(`${context}: Unsupported mode ${primitive.mode}`);
|
38
38
|
}
|
39
|
-
// TODO: handle triangle strips
|
40
|
-
if (primitive.mode === 5 /* MeshPrimitiveMode.TRIANGLE_STRIP */) {
|
41
|
-
throw new Error(`${context}: Mode ${primitive.mode} is not currently supported`);
|
42
|
-
}
|
43
39
|
}
|
44
40
|
const attributes = {};
|
45
41
|
const normalized = {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"KHR_draco_mesh_compression.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,+DAAiD;AAE5E,OAAO,EAAE,YAAY,EAAE,0CAA4B;AAQnD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,IAAI,GAAG,4BAA4B,CAAC;AAM1C;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,0BAA0B;IAuBnC;;OAEG;IACH,YAAY,MAAkB;QAzB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAY5B;;WAEG;QACI,kCAA6B,GAAG,IAAI,CAAC;QAQxC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC,gBAAgB,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC3F,CAAC;IAED,gBAAgB;IACT,OAAO;QACV,OAAO,IAAI,CAAC,gBAAgB,CAAC;QAC5B,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,oBAAoB,CAAC,OAAe,EAAE,SAAyB,EAAE,WAAiB;QACrF,OAAO,UAAU,CAAC,kBAAkB,CAAqC,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,gBAAgB,EAAE,SAAS,EAAE,EAAE;YACpI,IAAI,SAAS,CAAC,IAAI,IAAI,SAAS,EAAE;gBAC7B,IAAI,SAAS,CAAC,IAAI,
|
1
|
+
{"version":3,"file":"KHR_draco_mesh_compression.js","sourceRoot":"","sources":["../../../../../../dev/loaders/src/glTF/2.0/Extensions/KHR_draco_mesh_compression.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,+DAAiD;AAE5E,OAAO,EAAE,YAAY,EAAE,0CAA4B;AAQnD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAEtD,MAAM,IAAI,GAAG,4BAA4B,CAAC;AAM1C;;GAEG;AACH,gEAAgE;AAChE,MAAM,OAAO,0BAA0B;IAuBnC;;OAEG;IACH,YAAY,MAAkB;QAzB9B;;WAEG;QACa,SAAI,GAAG,IAAI,CAAC;QAY5B;;WAEG;QACI,kCAA6B,GAAG,IAAI,CAAC;QAQxC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC,gBAAgB,IAAI,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC3F,CAAC;IAED,gBAAgB;IACT,OAAO;QACV,OAAO,IAAI,CAAC,gBAAgB,CAAC;QAC5B,IAAI,CAAC,OAAe,GAAG,IAAI,CAAC;IACjC,CAAC;IAED;;OAEG;IACI,oBAAoB,CAAC,OAAe,EAAE,SAAyB,EAAE,W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CAAC,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;wBACjJ,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;oBACpD,CAAC,CAAC,CAAC;gBACP,CAAC,CAAC,CAAC;aACN;YAED,OAAO,UAAU,CAAC,qBAAqB,CAAC;QAC5C,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAED,UAAU,CAAC,iBAAiB,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,0BAA0B,CAAC,MAAM,CAAC,CAAC,CAAC","sourcesContent":["import { DracoCompression } from \"core/Meshes/Compression/dracoCompression\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { VertexBuffer } from \"core/Buffers/buffer\";\r\nimport type { Geometry } from \"core/Meshes/geometry\";\r\nimport type { Mesh } from \"core/Meshes/mesh\";\r\n\r\nimport { MeshPrimitiveMode } from \"babylonjs-gltf2interface\";\r\nimport type { IKHRDracoMeshCompression } from \"babylonjs-gltf2interface\";\r\nimport type { IMeshPrimitive, IBufferView } from \"../glTFLoaderInterfaces\";\r\nimport type { IGLTFLoaderExtension } from \"../glTFLoaderExtension\";\r\nimport { GLTFLoader, ArrayItem } from \"../glTFLoader\";\r\n\r\nconst NAME = \"KHR_draco_mesh_compression\";\r\n\r\ninterface IBufferViewDraco extends IBufferView {\r\n _dracoBabylonGeometry?: Promise<Geometry>;\r\n}\r\n\r\n/**\r\n * [Specification](https://github.com/KhronosGroup/glTF/blob/main/extensions/2.0/Khronos/KHR_draco_mesh_compression/README.md)\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport class KHR_draco_mesh_compression implements IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n public readonly name = NAME;\r\n\r\n /**\r\n * The draco compression used to decode vertex data or DracoCompression.Default if not defined\r\n */\r\n public dracoCompression?: DracoCompression;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n public enabled: boolean;\r\n\r\n /**\r\n * Defines whether to use the normalized flag from the glTF accessor instead of the Draco data. Defaults to true.\r\n */\r\n public useNormalizedFlagFromAccessor = true;\r\n\r\n private _loader: GLTFLoader;\r\n\r\n /**\r\n * @internal\r\n */\r\n constructor(loader: GLTFLoader) {\r\n this._loader = loader;\r\n this.enabled = DracoCompression.DecoderAvailable && this._loader.isExtensionUsed(NAME);\r\n }\r\n\r\n /** @internal */\r\n public dispose(): void {\r\n delete this.dracoCompression;\r\n (this._loader as any) = null;\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>> {\r\n return GLTFLoader.LoadExtensionAsync<IKHRDracoMeshCompression, Geometry>(context, primitive, this.name, (extensionContext, extension) => {\r\n if (primitive.mode != undefined) {\r\n if (primitive.mode !== MeshPrimitiveMode.TRIANGLES && primitive.mode !== MeshPrimitiveMode.TRIANGLE_STRIP) {\r\n throw new Error(`${context}: Unsupported mode ${primitive.mode}`);\r\n }\r\n }\r\n\r\n const attributes: { [kind: string]: number } = {};\r\n const normalized: { [kind: string]: boolean } = {};\r\n const loadAttribute = (name: string, kind: string) => {\r\n const uniqueId = extension.attributes[name];\r\n if (uniqueId == undefined) {\r\n return;\r\n }\r\n\r\n babylonMesh._delayInfo = babylonMesh._delayInfo || [];\r\n if (babylonMesh._delayInfo.indexOf(kind) === -1) {\r\n babylonMesh._delayInfo.push(kind);\r\n }\r\n\r\n attributes[kind] = uniqueId;\r\n\r\n if (this.useNormalizedFlagFromAccessor) {\r\n const accessor = ArrayItem.TryGet(this._loader.gltf.accessors, primitive.attributes[name]);\r\n if (accessor) {\r\n normalized[kind] = accessor.normalized || false;\r\n }\r\n }\r\n };\r\n\r\n loadAttribute(\"POSITION\", VertexBuffer.PositionKind);\r\n loadAttribute(\"NORMAL\", VertexBuffer.NormalKind);\r\n loadAttribute(\"TANGENT\", VertexBuffer.TangentKind);\r\n loadAttribute(\"TEXCOORD_0\", VertexBuffer.UVKind);\r\n loadAttribute(\"TEXCOORD_1\", VertexBuffer.UV2Kind);\r\n loadAttribute(\"TEXCOORD_2\", VertexBuffer.UV3Kind);\r\n loadAttribute(\"TEXCOORD_3\", VertexBuffer.UV4Kind);\r\n loadAttribute(\"TEXCOORD_4\", VertexBuffer.UV5Kind);\r\n loadAttribute(\"TEXCOORD_5\", VertexBuffer.UV6Kind);\r\n loadAttribute(\"JOINTS_0\", VertexBuffer.MatricesIndicesKind);\r\n loadAttribute(\"WEIGHTS_0\", VertexBuffer.MatricesWeightsKind);\r\n loadAttribute(\"COLOR_0\", VertexBuffer.ColorKind);\r\n\r\n const bufferView = ArrayItem.Get(extensionContext, this._loader.gltf.bufferViews, extension.bufferView) as IBufferViewDraco;\r\n if (!bufferView._dracoBabylonGeometry) {\r\n bufferView._dracoBabylonGeometry = this._loader.loadBufferViewAsync(`/bufferViews/${bufferView.index}`, bufferView).then((data) => {\r\n const dracoCompression = this.dracoCompression || DracoCompression.Default;\r\n return dracoCompression._decodeMeshToGeometryForGltfAsync(babylonMesh.name, this._loader.babylonScene, data, attributes, normalized).catch((error) => {\r\n throw new Error(`${context}: ${error.message}`);\r\n });\r\n });\r\n }\r\n\r\n return bufferView._dracoBabylonGeometry;\r\n });\r\n }\r\n}\r\n\r\nGLTFLoader.RegisterExtension(NAME, (loader) => new KHR_draco_mesh_compression(loader));\r\n"]}
|
package/glTF/glTFFileLoader.js
CHANGED
@@ -436,7 +436,7 @@ export class GLTFFileLoader {
|
|
436
436
|
return fileRequest;
|
437
437
|
}
|
438
438
|
return this._loadFile(scene, fileOrUrl, (data) => {
|
439
|
-
this._validate(scene, new Uint8Array(data), rootUrl, fileName);
|
439
|
+
this._validate(scene, new Uint8Array(data, 0, data.byteLength), rootUrl, fileName);
|
440
440
|
this._unpackBinaryAsync(new DataReader({
|
441
441
|
readAsync: (byteOffset, byteLength) => readAsync(data, byteOffset, byteLength),
|
442
442
|
byteLength: data.byteLength,
|
@@ -445,13 +445,15 @@ export class GLTFFileLoader {
|
|
445
445
|
}, onError ? (error) => onError(undefined, error) : undefined);
|
446
446
|
}, true, onError);
|
447
447
|
}
|
448
|
-
|
449
|
-
this.
|
450
|
-
|
451
|
-
|
448
|
+
else {
|
449
|
+
return this._loadFile(scene, fileOrUrl, (data) => {
|
450
|
+
this._validate(scene, data, rootUrl, fileName);
|
451
|
+
onSuccess({ json: this._parseJson(data) });
|
452
|
+
}, false, onError);
|
453
|
+
}
|
452
454
|
}
|
453
455
|
_loadBinary(scene, data, rootUrl, onSuccess, onError, fileName) {
|
454
|
-
this._validate(scene, data, rootUrl, fileName);
|
456
|
+
this._validate(scene, new Uint8Array(data.buffer, data.byteOffset, data.byteLength), rootUrl, fileName);
|
455
457
|
this._unpackBinaryAsync(new DataReader({
|
456
458
|
readAsync: (byteOffset, byteLength) => readViewAsync(data, byteOffset, byteLength),
|
457
459
|
byteLength: data.byteLength,
|
@@ -548,7 +550,7 @@ export class GLTFFileLoader {
|
|
548
550
|
data.startsWith("application/octet-stream;base64," + GLTFFileLoader._MagicBase64Encoded) ||
|
549
551
|
data.startsWith("model/gltf-binary;base64," + GLTFFileLoader._MagicBase64Encoded)) {
|
550
552
|
const arrayBuffer = DecodeBase64UrlToBinary(data);
|
551
|
-
this._validate(scene, new Uint8Array(arrayBuffer));
|
553
|
+
this._validate(scene, new Uint8Array(arrayBuffer, 0, arrayBuffer.byteLength));
|
552
554
|
return this._unpackBinaryAsync(new DataReader({
|
553
555
|
readAsync: (byteOffset, byteLength) => readAsync(arrayBuffer, byteOffset, byteLength),
|
554
556
|
byteLength: arrayBuffer.byteLength,
|
@@ -635,7 +637,11 @@ export class GLTFFileLoader {
|
|
635
637
|
}
|
636
638
|
this._startPerformanceCounter("Validate JSON");
|
637
639
|
GLTFValidation.ValidateAsync(data, rootUrl, fileName, (uri) => {
|
638
|
-
return this.preprocessUrlAsync(rootUrl + uri).then((url) =>
|
640
|
+
return this.preprocessUrlAsync(rootUrl + uri).then((url) => {
|
641
|
+
return scene._loadFileAsync(url, undefined, true, true).then((data) => {
|
642
|
+
return new Uint8Array(data, 0, data.byteLength);
|
643
|
+
});
|
644
|
+
});
|
639
645
|
}).then((result) => {
|
640
646
|
this._endPerformanceCounter("Validate JSON");
|
641
647
|
this.onValidatedObservable.notifyObservers(result);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"glTFFileLoader.js","sourceRoot":"","sources":["../../../../dev/loaders/src/glTF/glTFFileLoader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAaxC,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,OAAO,EAAE,cAAc,EAAE,0CAA4B;AAIrD,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAE1C,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,uBAAuB,EAAE,0CAA4B;AAC9D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,sCAAwB;AAU3D,SAAS,SAAS,CAAC,WAAwB,EAAE,UAAkB,EAAE,UAAkB;IAC/E,IAAI;QACA,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,UAAU,CAAC,WAAW,EAAE,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;KAC/E;IAAC,OAAO,CAAC,EAAE;QACR,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;KAC5B;AACL,CAAC;AAED,SAAS,aAAa,CAAC,eAAgC,EAAE,UAAkB,EAAE,UAAkB;IAC3F,IAAI;QACA,IAAI,UAAU,GAAG,CAAC,IAAI,UAAU,IAAI,eAAe,CAAC,UAAU,EAAE;YAC5D,MAAM,IAAI,UAAU,CAAC,yBAAy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B;QACvD,KAAK,CAAC,uBAAuB,CAAC,WAAW,CAAC,CAAC;IAC/C,CAAC;IAEO,gCAAgC,CAAC,WAAmB,IAAS,CAAC;IAE9D,6BAA6B,CAAC,WAAmB;QACrD,KAAK,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC;IAC7C,CAAC;IAEO,8BAA8B,CAAC,WAAmB,IAAS,CAAC;;AAl/BpE,aAAa;AACb,aAAa;AACb,aAAa;AAEb;;;;;GAKG;AACW,iCAAkB,GAAG,IAAI,AAAP,CAAQ;AAExC;;;;GAIG;AACW,qCAAsB,GAAG,KAAK,AAAR,CAAS;AA0T9B,kCAAmB,GAAG,QAAQ,AAAX,CAAY,CAAC,8CAA8C;AA0nBrE,yBAAU,GAAG,kCAAkC,AAArC,CAAsC;AAgD5E,IAAI,WAAW,EAAE;IACb,WAAW,CAAC,cAAc,CAAC,IAAI,cAAc,EAAE,CAAC,CAAC;CACpD","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type * as GLTF2 from \"babylonjs-gltf2interface\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { Camera } from \"core/Cameras/camera\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type {\r\n ISceneLoaderPluginFactory,\r\n ISceneLoaderPlugin,\r\n ISceneLoaderPluginAsync,\r\n ISceneLoaderProgressEvent,\r\n ISceneLoaderPluginExtensions,\r\n ISceneLoaderAsyncResult,\r\n} from \"core/Loading/sceneLoader\";\r\nimport { SceneLoader } from \"core/Loading/sceneLoader\";\r\nimport { AssetContainer } from \"core/assetContainer\";\r\nimport type { Scene, IDisposable } from \"core/scene\";\r\nimport type { WebRequest } from \"core/Misc/webRequest\";\r\nimport type { IFileRequest } from \"core/Misc/fileRequest\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport type { IDataBuffer } from \"core/Misc/dataReader\";\r\nimport { DataReader } from \"core/Misc/dataReader\";\r\nimport { GLTFValidation } from \"./glTFValidation\";\r\nimport type { LoadFileError } from \"core/Misc/fileTools\";\r\nimport { DecodeBase64UrlToBinary } from \"core/Misc/fileTools\";\r\nimport { RuntimeError, ErrorCodes } from \"core/Misc/error\";\r\nimport type { TransformNode } from \"core/Meshes/transformNode\";\r\nimport type { MorphTargetManager } from \"core/Morph/morphTargetManager\";\r\n\r\ninterface IFileRequestInfo extends IFileRequest {\r\n _lengthComputable?: boolean;\r\n _loaded?: number;\r\n _total?: number;\r\n}\r\n\r\nfunction readAsync(arrayBuffer: ArrayBuffer, byteOffset: number, byteLength: number): Promise<Uint8Array> {\r\n try {\r\n return Promise.resolve(new Uint8Array(arrayBuffer, byteOffset, byteLength));\r\n } catch (e) {\r\n return Promise.reject(e);\r\n }\r\n}\r\n\r\nfunction readViewAsync(arrayBufferView: ArrayBufferView, byteOffset: number, byteLength: number): Promise<Uint8Array> {\r\n try {\r\n if (byteOffset < 0 || byteOffset >= arrayBufferView.byteLength) {\r\n throw new RangeError(\"Offset is out of range.\");\r\n }\r\n\r\n if (byteOffset + byteLength > arrayBufferView.byteLength) {\r\n throw new RangeError(\"Length is out of range.\");\r\n }\r\n\r\n return Promise.resolve(new Uint8Array(arrayBufferView.buffer, arrayBufferView.byteOffset + byteOffset, byteLength));\r\n } catch (e) {\r\n return Promise.reject(e);\r\n }\r\n}\r\n\r\n/**\r\n * Mode that determines the coordinate system to use.\r\n */\r\nexport enum GLTFLoaderCoordinateSystemMode {\r\n /**\r\n * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.\r\n */\r\n AUTO,\r\n\r\n /**\r\n * Sets the useRightHandedSystem flag on the scene.\r\n */\r\n FORCE_RIGHT_HANDED,\r\n}\r\n\r\n/**\r\n * Mode that determines what animations will start.\r\n */\r\nexport enum GLTFLoaderAnimationStartMode {\r\n /**\r\n * No animation will start.\r\n */\r\n NONE,\r\n\r\n /**\r\n * The first animation will start.\r\n */\r\n FIRST,\r\n\r\n /**\r\n * All animations will start.\r\n */\r\n ALL,\r\n}\r\n\r\n/**\r\n * Interface that contains the data for the glTF asset.\r\n */\r\nexport interface IGLTFLoaderData {\r\n /**\r\n * The object that represents the glTF JSON.\r\n */\r\n json: Object;\r\n\r\n /**\r\n * The BIN chunk of a binary glTF.\r\n */\r\n bin: Nullable<IDataBuffer>;\r\n}\r\n\r\n/**\r\n * Interface for extending the loader.\r\n */\r\nexport interface IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n readonly name: string;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n enabled: boolean;\r\n\r\n /**\r\n * Defines the order of this extension.\r\n * The loader sorts the extensions using these values when loading.\r\n */\r\n order?: number;\r\n}\r\n\r\n/**\r\n * Loader state.\r\n */\r\nexport enum GLTFLoaderState {\r\n /**\r\n * The asset is loading.\r\n */\r\n LOADING,\r\n\r\n /**\r\n * The asset is ready for rendering.\r\n */\r\n READY,\r\n\r\n /**\r\n * The asset is completely loaded.\r\n */\r\n COMPLETE,\r\n}\r\n\r\n/** @internal */\r\nexport interface IGLTFLoader extends IDisposable {\r\n importMeshAsync: (\r\n meshesNames: any,\r\n scene: Scene,\r\n container: Nullable<AssetContainer>,\r\n data: IGLTFLoaderData,\r\n rootUrl: string,\r\n onProgress?: (event: ISceneLoaderProgressEvent) => void,\r\n fileName?: string\r\n ) => Promise<ISceneLoaderAsyncResult>;\r\n loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;\r\n}\r\n\r\n/**\r\n * File loader for loading glTF files into a scene.\r\n */\r\nexport class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {\r\n /** @internal */\r\n public static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;\r\n\r\n /** @internal */\r\n public static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;\r\n\r\n // --------------\r\n // Common options\r\n // --------------\r\n\r\n /**\r\n * Raised when the asset has been parsed\r\n */\r\n public onParsedObservable = new Observable<IGLTFLoaderData>();\r\n\r\n private _onParsedObserver: Nullable<Observer<IGLTFLoaderData>>;\r\n\r\n /**\r\n * Raised when the asset has been parsed\r\n */\r\n public set onParsed(callback: (loaderData: IGLTFLoaderData) => void) {\r\n if (this._onParsedObserver) {\r\n this.onParsedObservable.remove(this._onParsedObserver);\r\n }\r\n this._onParsedObserver = this.onParsedObservable.add(callback);\r\n }\r\n\r\n // ----------\r\n // V1 options\r\n // ----------\r\n\r\n /**\r\n * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders.\r\n * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.\r\n * Defaults to true.\r\n * @internal\r\n */\r\n public static IncrementalLoading = true;\r\n\r\n /**\r\n * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.\r\n * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.\r\n * @internal\r\n */\r\n public static HomogeneousCoordinates = false;\r\n\r\n // ----------\r\n // V2 options\r\n // ----------\r\n\r\n /**\r\n * The coordinate system mode. Defaults to AUTO.\r\n */\r\n public coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO;\r\n\r\n /**\r\n * The animation start mode. Defaults to FIRST.\r\n */\r\n public animationStartMode = GLTFLoaderAnimationStartMode.FIRST;\r\n\r\n /**\r\n * Defines if the loader should compile materials before raising the success callback. Defaults to false.\r\n */\r\n public compileMaterials = false;\r\n\r\n /**\r\n * Defines if the loader should also compile materials with clip planes. Defaults to false.\r\n */\r\n public useClipPlane = false;\r\n\r\n /**\r\n * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.\r\n */\r\n public compileShadowGenerators = false;\r\n\r\n /**\r\n * Defines if the Alpha blended materials are only applied as coverage.\r\n * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.\r\n * If true, no extra effects are applied to transparent pixels.\r\n */\r\n public transparencyAsCoverage = false;\r\n\r\n /**\r\n * Defines if the loader should use range requests when load binary glTF files from HTTP.\r\n * Enabling will disable offline support and glTF validator.\r\n * Defaults to false.\r\n */\r\n public useRangeRequests = false;\r\n\r\n /**\r\n * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.\r\n */\r\n public createInstances = true;\r\n\r\n /**\r\n * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false.\r\n */\r\n public alwaysComputeBoundingBox = false;\r\n\r\n /**\r\n * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.\r\n */\r\n public loadAllMaterials = false;\r\n\r\n /**\r\n * If true, load only the materials defined in the file. Defaults to false.\r\n */\r\n public loadOnlyMaterials = false;\r\n\r\n /**\r\n * If true, do not load any materials defined in the file. Defaults to false.\r\n */\r\n public skipMaterials = false;\r\n\r\n /**\r\n * If true, load the color (gamma encoded) textures into sRGB buffers (if supported by the GPU), which will yield more accurate results when sampling the texture. Defaults to true.\r\n */\r\n public useSRGBBuffers = true;\r\n\r\n /**\r\n * When loading glTF animations, which are defined in seconds, target them to this FPS. Defaults to 60.\r\n */\r\n public targetFps = 60;\r\n\r\n /**\r\n * Defines if the loader should always compute the nearest common ancestor of the skeleton joints instead of using `skin.skeleton`. Defaults to false.\r\n * Set this to true if loading assets with invalid `skin.skeleton` values.\r\n */\r\n public alwaysComputeSkeletonRootNode = false;\r\n\r\n /**\r\n * Function called before loading a url referenced by the asset.\r\n * @param url\r\n */\r\n public preprocessUrlAsync = (url: string) => Promise.resolve(url);\r\n\r\n /**\r\n * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.\r\n * Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)\r\n */\r\n public readonly onMeshLoadedObservable = new Observable<AbstractMesh>();\r\n\r\n private _onMeshLoadedObserver: Nullable<Observer<AbstractMesh>>;\r\n\r\n /**\r\n * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.\r\n * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)\r\n */\r\n public set onMeshLoaded(callback: (mesh: AbstractMesh) => void) {\r\n if (this._onMeshLoadedObserver) {\r\n this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver);\r\n }\r\n this._onMeshLoadedObserver = this.onMeshLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Callback raised when the loader creates a skin after parsing the glTF properties of the skin node.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/importers/glTF/glTFSkinning#ignoring-the-transform-of-the-skinned-mesh\r\n * @param node - the transform node that corresponds to the original glTF skin node used for animations\r\n * @param skinnedNode - the transform node that is the skinned mesh itself or the parent of the skinned meshes\r\n */\r\n public readonly onSkinLoadedObservable = new Observable<{ node: TransformNode; skinnedNode: TransformNode }>();\r\n\r\n /**\r\n * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.\r\n */\r\n public readonly onTextureLoadedObservable = new Observable<BaseTexture>();\r\n\r\n private _onTextureLoadedObserver: Nullable<Observer<BaseTexture>>;\r\n\r\n /**\r\n * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.\r\n */\r\n public set onTextureLoaded(callback: (texture: BaseTexture) => void) {\r\n if (this._onTextureLoadedObserver) {\r\n this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver);\r\n }\r\n this._onTextureLoadedObserver = this.onTextureLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised when the loader creates a material after parsing the glTF properties of the material.\r\n */\r\n public readonly onMaterialLoadedObservable = new Observable<Material>();\r\n\r\n private _onMaterialLoadedObserver: Nullable<Observer<Material>>;\r\n\r\n /**\r\n * Callback raised when the loader creates a material after parsing the glTF properties of the material.\r\n */\r\n public set onMaterialLoaded(callback: (material: Material) => void) {\r\n if (this._onMaterialLoadedObserver) {\r\n this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver);\r\n }\r\n this._onMaterialLoadedObserver = this.onMaterialLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.\r\n */\r\n public readonly onCameraLoadedObservable = new Observable<Camera>();\r\n\r\n private _onCameraLoadedObserver: Nullable<Observer<Camera>>;\r\n\r\n /**\r\n * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.\r\n */\r\n public set onCameraLoaded(callback: (camera: Camera) => void) {\r\n if (this._onCameraLoadedObserver) {\r\n this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver);\r\n }\r\n this._onCameraLoadedObserver = this.onCameraLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised when the asset is completely loaded, immediately before the loader is disposed.\r\n * For assets with LODs, raised when all of the LODs are complete.\r\n * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.\r\n */\r\n public readonly onCompleteObservable = new Observable<void>();\r\n\r\n private _onCompleteObserver: Nullable<Observer<void>>;\r\n\r\n /**\r\n * Callback raised when the asset is completely loaded, immediately before the loader is disposed.\r\n * For assets with LODs, raised when all of the LODs are complete.\r\n * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.\r\n */\r\n public set onComplete(callback: () => void) {\r\n if (this._onCompleteObserver) {\r\n this.onCompleteObservable.remove(this._onCompleteObserver);\r\n }\r\n this._onCompleteObserver = this.onCompleteObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised when an error occurs.\r\n */\r\n public readonly onErrorObservable = new Observable<any>();\r\n\r\n private _onErrorObserver: Nullable<Observer<any>>;\r\n\r\n /**\r\n * Callback raised when an error occurs.\r\n */\r\n public set onError(callback: (reason: any) => void) {\r\n if (this._onErrorObserver) {\r\n this.onErrorObservable.remove(this._onErrorObserver);\r\n }\r\n this._onErrorObserver = this.onErrorObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised after the loader is disposed.\r\n */\r\n public readonly onDisposeObservable = new Observable<void>();\r\n\r\n private _onDisposeObserver: Nullable<Observer<void>>;\r\n\r\n /**\r\n * Callback raised after the loader is disposed.\r\n */\r\n public set onDispose(callback: () => void) {\r\n if (this._onDisposeObserver) {\r\n this.onDisposeObservable.remove(this._onDisposeObserver);\r\n }\r\n this._onDisposeObserver = this.onDisposeObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised after a loader extension is created.\r\n * Set additional options for a loader extension in this event.\r\n */\r\n public readonly onExtensionLoadedObservable = new Observable<IGLTFLoaderExtension>();\r\n\r\n private _onExtensionLoadedObserver: Nullable<Observer<IGLTFLoaderExtension>>;\r\n\r\n /**\r\n * Callback raised after a loader extension is created.\r\n */\r\n public set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void) {\r\n if (this._onExtensionLoadedObserver) {\r\n this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver);\r\n }\r\n this._onExtensionLoadedObserver = this.onExtensionLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Defines if the loader logging is enabled.\r\n */\r\n public get loggingEnabled(): boolean {\r\n return this._loggingEnabled;\r\n }\r\n\r\n public set loggingEnabled(value: boolean) {\r\n if (this._loggingEnabled === value) {\r\n return;\r\n }\r\n\r\n this._loggingEnabled = value;\r\n\r\n if (this._loggingEnabled) {\r\n this._log = this._logEnabled;\r\n } else {\r\n this._log = this._logDisabled;\r\n }\r\n }\r\n\r\n /**\r\n * Defines if the loader should capture performance counters.\r\n */\r\n public get capturePerformanceCounters(): boolean {\r\n return this._capturePerformanceCounters;\r\n }\r\n\r\n public set capturePerformanceCounters(value: boolean) {\r\n if (this._capturePerformanceCounters === value) {\r\n return;\r\n }\r\n\r\n this._capturePerformanceCounters = value;\r\n\r\n if (this._capturePerformanceCounters) {\r\n this._startPerformanceCounter = this._startPerformanceCounterEnabled;\r\n this._endPerformanceCounter = this._endPerformanceCounterEnabled;\r\n } else {\r\n this._startPerformanceCounter = this._startPerformanceCounterDisabled;\r\n this._endPerformanceCounter = this._endPerformanceCounterDisabled;\r\n }\r\n }\r\n\r\n /**\r\n * Defines if the loader should validate the asset.\r\n */\r\n public validate = false;\r\n\r\n /**\r\n * Observable raised after validation when validate is set to true. The event data is the result of the validation.\r\n */\r\n public readonly onValidatedObservable = new Observable<GLTF2.IGLTFValidationResults>();\r\n\r\n private _onValidatedObserver: Nullable<Observer<GLTF2.IGLTFValidationResults>>;\r\n\r\n /**\r\n * Callback raised after a loader extension is created.\r\n */\r\n public set onValidated(callback: (results: GLTF2.IGLTFValidationResults) => void) {\r\n if (this._onValidatedObserver) {\r\n this.onValidatedObservable.remove(this._onValidatedObserver);\r\n }\r\n this._onValidatedObserver = this.onValidatedObservable.add(callback);\r\n }\r\n\r\n private _loader: Nullable<IGLTFLoader> = null;\r\n private _state: Nullable<GLTFLoaderState> = null;\r\n private _progressCallback?: (event: ISceneLoaderProgressEvent) => void;\r\n private _requests = new Array<IFileRequestInfo>();\r\n\r\n private static _MagicBase64Encoded = \"Z2xURg\"; // \"glTF\" base64 encoded (without the quotes!)\r\n\r\n /**\r\n * Name of the loader (\"gltf\")\r\n */\r\n public name = \"gltf\";\r\n\r\n /** @internal */\r\n public extensions: ISceneLoaderPluginExtensions = {\r\n \".gltf\": { isBinary: false },\r\n \".glb\": { isBinary: true },\r\n };\r\n\r\n /**\r\n * Disposes the loader, releases resources during load, and cancels any outstanding requests.\r\n */\r\n public dispose(): void {\r\n if (this._loader) {\r\n this._loader.dispose();\r\n this._loader = null;\r\n }\r\n\r\n for (const request of this._requests) {\r\n request.abort();\r\n }\r\n\r\n this._requests.length = 0;\r\n\r\n delete this._progressCallback;\r\n\r\n this.preprocessUrlAsync = (url) => Promise.resolve(url);\r\n\r\n this.onMeshLoadedObservable.clear();\r\n this.onSkinLoadedObservable.clear();\r\n this.onTextureLoadedObservable.clear();\r\n this.onMaterialLoadedObservable.clear();\r\n this.onCameraLoadedObservable.clear();\r\n this.onCompleteObservable.clear();\r\n this.onExtensionLoadedObservable.clear();\r\n\r\n this.onDisposeObservable.notifyObservers(undefined);\r\n this.onDisposeObservable.clear();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadFile(\r\n scene: Scene,\r\n fileOrUrl: File | string | ArrayBufferView,\r\n rootUrl: string,\r\n onSuccess: (data: any, responseURL?: string) => void,\r\n onProgress?: (ev: ISceneLoaderProgressEvent) => void,\r\n useArrayBuffer?: boolean,\r\n onError?: (request?: WebRequest, exception?: LoadFileError) => void,\r\n name?: string\r\n ): Nullable<IFileRequest> {\r\n if (ArrayBuffer.isView(fileOrUrl)) {\r\n this._loadBinary(scene, fileOrUrl as ArrayBufferView, rootUrl, onSuccess, onError, name);\r\n return null;\r\n }\r\n\r\n this._progressCallback = onProgress;\r\n\r\n const fileName = (fileOrUrl as File).name || Tools.GetFilename(fileOrUrl as string);\r\n\r\n if (useArrayBuffer) {\r\n if (this.useRangeRequests) {\r\n if (this.validate) {\r\n Logger.Warn(\"glTF validation is not supported when range requests are enabled\");\r\n }\r\n\r\n const fileRequest: IFileRequest = {\r\n abort: () => {},\r\n onCompleteObservable: new Observable<IFileRequest>(),\r\n };\r\n\r\n const dataBuffer = {\r\n readAsync: (byteOffset: number, byteLength: number) => {\r\n return new Promise<ArrayBufferView>((resolve, reject) => {\r\n this._loadFile(\r\n scene,\r\n fileOrUrl as File | string,\r\n (data) => {\r\n resolve(new Uint8Array(data as ArrayBuffer));\r\n },\r\n true,\r\n (error) => {\r\n reject(error);\r\n },\r\n (webRequest) => {\r\n webRequest.setRequestHeader(\"Range\", `bytes=${byteOffset}-${byteOffset + byteLength - 1}`);\r\n }\r\n );\r\n });\r\n },\r\n byteLength: 0,\r\n };\r\n\r\n this._unpackBinaryAsync(new DataReader(dataBuffer)).then(\r\n (loaderData) => {\r\n fileRequest.onCompleteObservable.notifyObservers(fileRequest);\r\n onSuccess(loaderData);\r\n },\r\n onError ? (error) => onError(undefined, error) : undefined\r\n );\r\n\r\n return fileRequest;\r\n }\r\n\r\n return this._loadFile(\r\n scene,\r\n fileOrUrl as File | string,\r\n (data) => {\r\n this._validate(scene, new Uint8Array(data as ArrayBuffer), rootUrl, fileName);\r\n this._unpackBinaryAsync(\r\n new DataReader({\r\n readAsync: (byteOffset, byteLength) => readAsync(data as ArrayBuffer, byteOffset, byteLength),\r\n byteLength: (data as ArrayBuffer).byteLength,\r\n })\r\n ).then(\r\n (loaderData) => {\r\n onSuccess(loaderData);\r\n },\r\n onError ? (error) => onError(undefined, error) : undefined\r\n );\r\n },\r\n true,\r\n onError\r\n );\r\n }\r\n\r\n return this._loadFile(\r\n scene,\r\n fileOrUrl as File | string,\r\n (data) => {\r\n this._validate(scene, new Uint8Array(data as ArrayBuffer), rootUrl, fileName);\r\n onSuccess({ json: this._parseJson(data as string) });\r\n },\r\n useArrayBuffer,\r\n onError\r\n );\r\n }\r\n\r\n private _loadBinary(\r\n scene: Scene,\r\n data: ArrayBufferView,\r\n rootUrl: string,\r\n onSuccess: (data: any, responseURL?: string) => void,\r\n onError?: (request?: WebRequest, exception?: LoadFileError) => void,\r\n fileName?: string\r\n ): void {\r\n this._validate(scene, data, rootUrl, fileName);\r\n this._unpackBinaryAsync(\r\n new DataReader({\r\n readAsync: (byteOffset, byteLength) => readViewAsync(data, byteOffset, byteLength),\r\n byteLength: data.byteLength,\r\n })\r\n ).then(\r\n (loaderData) => {\r\n onSuccess(loaderData);\r\n },\r\n onError ? (error) => onError(undefined, error) : undefined\r\n );\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public importMeshAsync(\r\n meshesNames: any,\r\n scene: Scene,\r\n data: any,\r\n rootUrl: string,\r\n onProgress?: (event: ISceneLoaderProgressEvent) => void,\r\n fileName?: string\r\n ): Promise<ISceneLoaderAsyncResult> {\r\n return Promise.resolve().then(() => {\r\n this.onParsedObservable.notifyObservers(data);\r\n this.onParsedObservable.clear();\r\n\r\n this._log(`Loading ${fileName || \"\"}`);\r\n this._loader = this._getLoader(data);\r\n return this._loader.importMeshAsync(meshesNames, scene, null, data, rootUrl, onProgress, fileName);\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void> {\r\n return Promise.resolve().then(() => {\r\n this.onParsedObservable.notifyObservers(data);\r\n this.onParsedObservable.clear();\r\n\r\n this._log(`Loading ${fileName || \"\"}`);\r\n this._loader = this._getLoader(data);\r\n return this._loader.loadAsync(scene, data, rootUrl, onProgress, fileName);\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer> {\r\n return Promise.resolve().then(() => {\r\n this.onParsedObservable.notifyObservers(data);\r\n this.onParsedObservable.clear();\r\n\r\n this._log(`Loading ${fileName || \"\"}`);\r\n this._loader = this._getLoader(data);\r\n\r\n // Prepare the asset container.\r\n const container = new AssetContainer(scene);\r\n\r\n // Get materials/textures when loading to add to container\r\n const materials: Array<Material> = [];\r\n this.onMaterialLoadedObservable.add((material) => {\r\n materials.push(material);\r\n });\r\n const textures: Array<BaseTexture> = [];\r\n this.onTextureLoadedObservable.add((texture) => {\r\n textures.push(texture);\r\n });\r\n const cameras: Array<Camera> = [];\r\n this.onCameraLoadedObservable.add((camera) => {\r\n cameras.push(camera);\r\n });\r\n\r\n const morphTargetManagers: Array<MorphTargetManager> = [];\r\n this.onMeshLoadedObservable.add((mesh) => {\r\n if (mesh.morphTargetManager) {\r\n morphTargetManagers.push(mesh.morphTargetManager);\r\n }\r\n });\r\n\r\n return this._loader.importMeshAsync(null, scene, container, data, rootUrl, onProgress, fileName).then((result) => {\r\n Array.prototype.push.apply(container.geometries, result.geometries);\r\n Array.prototype.push.apply(container.meshes, result.meshes);\r\n Array.prototype.push.apply(container.particleSystems, result.particleSystems);\r\n Array.prototype.push.apply(container.skeletons, result.skeletons);\r\n Array.prototype.push.apply(container.animationGroups, result.animationGroups);\r\n Array.prototype.push.apply(container.materials, materials);\r\n Array.prototype.push.apply(container.textures, textures);\r\n Array.prototype.push.apply(container.lights, result.lights);\r\n Array.prototype.push.apply(container.transformNodes, result.transformNodes);\r\n Array.prototype.push.apply(container.cameras, cameras);\r\n Array.prototype.push.apply(container.morphTargetManagers, morphTargetManagers);\r\n return container;\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public canDirectLoad(data: string): boolean {\r\n return (\r\n (data.indexOf(\"asset\") !== -1 && data.indexOf(\"version\") !== -1) ||\r\n data.startsWith(\"data:base64,\" + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat.\r\n data.startsWith(\"data:;base64,\" + GLTFFileLoader._MagicBase64Encoded) ||\r\n data.startsWith(\"data:application/octet-stream;base64,\" + GLTFFileLoader._MagicBase64Encoded) ||\r\n data.startsWith(\"data:model/gltf-binary;base64,\" + GLTFFileLoader._MagicBase64Encoded)\r\n );\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public directLoad(scene: Scene, data: string): Promise<any> {\r\n if (\r\n data.startsWith(\"base64,\" + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat.\r\n data.startsWith(\";base64,\" + GLTFFileLoader._MagicBase64Encoded) ||\r\n data.startsWith(\"application/octet-stream;base64,\" + GLTFFileLoader._MagicBase64Encoded) ||\r\n data.startsWith(\"model/gltf-binary;base64,\" + GLTFFileLoader._MagicBase64Encoded)\r\n ) {\r\n const arrayBuffer = DecodeBase64UrlToBinary(data);\r\n\r\n this._validate(scene, new Uint8Array(arrayBuffer));\r\n return this._unpackBinaryAsync(\r\n new DataReader({\r\n readAsync: (byteOffset, byteLength) => readAsync(arrayBuffer, byteOffset, byteLength),\r\n byteLength: arrayBuffer.byteLength,\r\n })\r\n );\r\n }\r\n\r\n this._validate(scene, data);\r\n return Promise.resolve({ json: this._parseJson(data) });\r\n }\r\n\r\n /**\r\n * The callback that allows custom handling of the root url based on the response url.\r\n * @param rootUrl the original root url\r\n * @param responseURL the response url if available\r\n * @returns the new root url\r\n */\r\n public rewriteRootURL?(rootUrl: string, responseURL?: string): string;\r\n\r\n /** @internal */\r\n public createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync {\r\n return new GLTFFileLoader();\r\n }\r\n\r\n /**\r\n * The loader state or null if the loader is not active.\r\n */\r\n public get loaderState(): Nullable<GLTFLoaderState> {\r\n return this._state;\r\n }\r\n\r\n /**\r\n * Observable raised when the loader state changes.\r\n */\r\n public onLoaderStateChangedObservable = new Observable<Nullable<GLTFLoaderState>>();\r\n\r\n /**\r\n * Returns a promise that resolves when the asset is completely loaded.\r\n * @returns a promise that resolves when the asset is completely loaded.\r\n */\r\n public whenCompleteAsync(): Promise<void> {\r\n return new Promise((resolve, reject) => {\r\n this.onCompleteObservable.addOnce(() => {\r\n resolve();\r\n });\r\n this.onErrorObservable.addOnce((reason) => {\r\n reject(reason);\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _setState(state: GLTFLoaderState): void {\r\n if (this._state === state) {\r\n return;\r\n }\r\n\r\n this._state = state;\r\n this.onLoaderStateChangedObservable.notifyObservers(this._state);\r\n this._log(GLTFLoaderState[this._state]);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _loadFile(\r\n scene: Scene,\r\n fileOrUrl: File | string,\r\n onSuccess: (data: string | ArrayBuffer) => void,\r\n useArrayBuffer?: boolean,\r\n onError?: (request?: WebRequest) => void,\r\n onOpened?: (request: WebRequest) => void\r\n ): IFileRequest {\r\n const request = scene._loadFile(\r\n fileOrUrl,\r\n onSuccess,\r\n (event) => {\r\n this._onProgress(event, request);\r\n },\r\n true,\r\n useArrayBuffer,\r\n onError,\r\n onOpened\r\n ) as IFileRequestInfo;\r\n request.onCompleteObservable.add((request) => {\r\n this._requests.splice(this._requests.indexOf(request), 1);\r\n });\r\n this._requests.push(request);\r\n return request;\r\n }\r\n\r\n private _onProgress(event: ProgressEvent, request: IFileRequestInfo): void {\r\n if (!this._progressCallback) {\r\n return;\r\n }\r\n\r\n request._lengthComputable = event.lengthComputable;\r\n request._loaded = event.loaded;\r\n request._total = event.total;\r\n\r\n let lengthComputable = true;\r\n let loaded = 0;\r\n let total = 0;\r\n for (const request of this._requests) {\r\n if (request._lengthComputable === undefined || request._loaded === undefined || request._total === undefined) {\r\n return;\r\n }\r\n\r\n lengthComputable = lengthComputable && request._lengthComputable;\r\n loaded += request._loaded;\r\n total += request._total;\r\n }\r\n\r\n this._progressCallback({\r\n lengthComputable: lengthComputable,\r\n loaded: loaded,\r\n total: lengthComputable ? total : 0,\r\n });\r\n }\r\n\r\n private _validate(scene: Scene, data: string | ArrayBufferView, rootUrl = \"\", fileName = \"\"): void {\r\n if (!this.validate) {\r\n return;\r\n }\r\n\r\n this._startPerformanceCounter(\"Validate JSON\");\r\n GLTFValidation.ValidateAsync(data, rootUrl, fileName, (uri) => {\r\n return this.preprocessUrlAsync(rootUrl + uri).then((url) => scene._loadFileAsync(url, undefined, true, true) as Promise<ArrayBuffer>);\r\n }).then(\r\n (result) => {\r\n this._endPerformanceCounter(\"Validate JSON\");\r\n this.onValidatedObservable.notifyObservers(result);\r\n this.onValidatedObservable.clear();\r\n },\r\n (reason) => {\r\n this._endPerformanceCounter(\"Validate JSON\");\r\n Tools.Warn(`Failed to validate: ${reason.message}`);\r\n this.onValidatedObservable.clear();\r\n }\r\n );\r\n }\r\n\r\n private _getLoader(loaderData: IGLTFLoaderData): IGLTFLoader {\r\n const asset = (<any>loaderData.json).asset || {};\r\n\r\n this._log(`Asset version: ${asset.version}`);\r\n asset.minVersion && this._log(`Asset minimum version: ${asset.minVersion}`);\r\n asset.generator && this._log(`Asset generator: ${asset.generator}`);\r\n\r\n const version = GLTFFileLoader._parseVersion(asset.version);\r\n if (!version) {\r\n throw new Error(\"Invalid version: \" + asset.version);\r\n }\r\n\r\n if (asset.minVersion !== undefined) {\r\n const minVersion = GLTFFileLoader._parseVersion(asset.minVersion);\r\n if (!minVersion) {\r\n throw new Error(\"Invalid minimum version: \" + asset.minVersion);\r\n }\r\n\r\n if (GLTFFileLoader._compareVersion(minVersion, { major: 2, minor: 0 }) > 0) {\r\n throw new Error(\"Incompatible minimum version: \" + asset.minVersion);\r\n }\r\n }\r\n\r\n const createLoaders: { [key: number]: (parent: GLTFFileLoader) => IGLTFLoader } = {\r\n 1: GLTFFileLoader._CreateGLTF1Loader,\r\n 2: GLTFFileLoader._CreateGLTF2Loader,\r\n };\r\n\r\n const createLoader = createLoaders[version.major];\r\n if (!createLoader) {\r\n throw new Error(\"Unsupported version: \" + asset.version);\r\n }\r\n\r\n return createLoader(this);\r\n }\r\n\r\n private _parseJson(json: string): Object {\r\n this._startPerformanceCounter(\"Parse JSON\");\r\n this._log(`JSON length: ${json.length}`);\r\n const parsed = JSON.parse(json);\r\n this._endPerformanceCounter(\"Parse JSON\");\r\n return parsed;\r\n }\r\n\r\n private _unpackBinaryAsync(dataReader: DataReader): Promise<IGLTFLoaderData> {\r\n this._startPerformanceCounter(\"Unpack Binary\");\r\n\r\n // Read magic + version + length + json length + json format\r\n return dataReader.loadAsync(20).then(() => {\r\n const Binary = {\r\n Magic: 0x46546c67,\r\n };\r\n\r\n const magic = dataReader.readUint32();\r\n if (magic !== Binary.Magic) {\r\n throw new RuntimeError(\"Unexpected magic: \" + magic, ErrorCodes.GLTFLoaderUnexpectedMagicError);\r\n }\r\n\r\n const version = dataReader.readUint32();\r\n\r\n if (this.loggingEnabled) {\r\n this._log(`Binary version: ${version}`);\r\n }\r\n\r\n const length = dataReader.readUint32();\r\n if (!this.useRangeRequests && length !== dataReader.buffer.byteLength) {\r\n Logger.Warn(`Length in header does not match actual data length: ${length} != ${dataReader.buffer.byteLength}`);\r\n }\r\n\r\n let unpacked: Promise<IGLTFLoaderData>;\r\n switch (version) {\r\n case 1: {\r\n unpacked = this._unpackBinaryV1Async(dataReader, length);\r\n break;\r\n }\r\n case 2: {\r\n unpacked = this._unpackBinaryV2Async(dataReader, length);\r\n break;\r\n }\r\n default: {\r\n throw new Error(\"Unsupported version: \" + version);\r\n }\r\n }\r\n\r\n this._endPerformanceCounter(\"Unpack Binary\");\r\n\r\n return unpacked;\r\n });\r\n }\r\n\r\n private _unpackBinaryV1Async(dataReader: DataReader, length: number): Promise<IGLTFLoaderData> {\r\n const ContentFormat = {\r\n JSON: 0,\r\n };\r\n\r\n const contentLength = dataReader.readUint32();\r\n const contentFormat = dataReader.readUint32();\r\n\r\n if (contentFormat !== ContentFormat.JSON) {\r\n throw new Error(`Unexpected content format: ${contentFormat}`);\r\n }\r\n\r\n const bodyLength = length - dataReader.byteOffset;\r\n\r\n const data: IGLTFLoaderData = { json: this._parseJson(dataReader.readString(contentLength)), bin: null };\r\n if (bodyLength !== 0) {\r\n const startByteOffset = dataReader.byteOffset;\r\n data.bin = {\r\n readAsync: (byteOffset, byteLength) => dataReader.buffer.readAsync(startByteOffset + byteOffset, byteLength),\r\n byteLength: bodyLength,\r\n };\r\n }\r\n\r\n return Promise.resolve(data);\r\n }\r\n\r\n private _unpackBinaryV2Async(dataReader: DataReader, length: number): Promise<IGLTFLoaderData> {\r\n const ChunkFormat = {\r\n JSON: 0x4e4f534a,\r\n BIN: 0x004e4942,\r\n };\r\n\r\n // Read the JSON chunk header.\r\n const chunkLength = dataReader.readUint32();\r\n const chunkFormat = dataReader.readUint32();\r\n if (chunkFormat !== ChunkFormat.JSON) {\r\n throw new Error(\"First chunk format is not JSON\");\r\n }\r\n\r\n // Bail if there are no other chunks.\r\n if (dataReader.byteOffset + chunkLength === length) {\r\n return dataReader.loadAsync(chunkLength).then(() => {\r\n return { json: this._parseJson(dataReader.readString(chunkLength)), bin: null };\r\n });\r\n }\r\n\r\n // Read the JSON chunk and the length and type of the next chunk.\r\n return dataReader.loadAsync(chunkLength + 8).then(() => {\r\n const data: IGLTFLoaderData = { json: this._parseJson(dataReader.readString(chunkLength)), bin: null };\r\n\r\n const readAsync = (): Promise<IGLTFLoaderData> => {\r\n const chunkLength = dataReader.readUint32();\r\n const chunkFormat = dataReader.readUint32();\r\n\r\n switch (chunkFormat) {\r\n case ChunkFormat.JSON: {\r\n throw new Error(\"Unexpected JSON chunk\");\r\n }\r\n case ChunkFormat.BIN: {\r\n const startByteOffset = dataReader.byteOffset;\r\n data.bin = {\r\n readAsync: (byteOffset, byteLength) => dataReader.buffer.readAsync(startByteOffset + byteOffset, byteLength),\r\n byteLength: chunkLength,\r\n };\r\n dataReader.skipBytes(chunkLength);\r\n break;\r\n }\r\n default: {\r\n // ignore unrecognized chunkFormat\r\n dataReader.skipBytes(chunkLength);\r\n break;\r\n }\r\n }\r\n\r\n if (dataReader.byteOffset !== length) {\r\n return dataReader.loadAsync(8).then(readAsync);\r\n }\r\n\r\n return Promise.resolve(data);\r\n };\r\n\r\n return readAsync();\r\n });\r\n }\r\n\r\n private static _parseVersion(version: string): Nullable<{ major: number; minor: number }> {\r\n if (version === \"1.0\" || version === \"1.0.1\") {\r\n return {\r\n major: 1,\r\n minor: 0,\r\n };\r\n }\r\n\r\n const match = (version + \"\").match(/^(\\d+)\\.(\\d+)/);\r\n if (!match) {\r\n return null;\r\n }\r\n\r\n return {\r\n major: parseInt(match[1]),\r\n minor: parseInt(match[2]),\r\n };\r\n }\r\n\r\n private static _compareVersion(a: { major: number; minor: number }, b: { major: number; minor: number }): number {\r\n if (a.major > b.major) {\r\n return 1;\r\n }\r\n if (a.major < b.major) {\r\n return -1;\r\n }\r\n if (a.minor > b.minor) {\r\n return 1;\r\n }\r\n if (a.minor < b.minor) {\r\n return -1;\r\n }\r\n return 0;\r\n }\r\n\r\n private static readonly _logSpaces = \" \";\r\n private _logIndentLevel = 0;\r\n private _loggingEnabled = false;\r\n\r\n /** @internal */\r\n public _log = this._logDisabled;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _logOpen(message: string): void {\r\n this._log(message);\r\n this._logIndentLevel++;\r\n }\r\n\r\n /** @internal */\r\n public _logClose(): void {\r\n --this._logIndentLevel;\r\n }\r\n\r\n private _logEnabled(message: string): void {\r\n const spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);\r\n Logger.Log(`${spaces}${message}`);\r\n }\r\n\r\n private _logDisabled(message: string): void {}\r\n\r\n private _capturePerformanceCounters = false;\r\n\r\n /** @internal */\r\n public _startPerformanceCounter = this._startPerformanceCounterDisabled;\r\n\r\n /** @internal */\r\n public _endPerformanceCounter = this._endPerformanceCounterDisabled;\r\n\r\n private _startPerformanceCounterEnabled(counterName: string): void {\r\n Tools.StartPerformanceCounter(counterName);\r\n }\r\n\r\n private _startPerformanceCounterDisabled(counterName: string): void {}\r\n\r\n private _endPerformanceCounterEnabled(counterName: string): void {\r\n Tools.EndPerformanceCounter(counterName);\r\n }\r\n\r\n private _endPerformanceCounterDisabled(counterName: string): void {}\r\n}\r\n\r\nif (SceneLoader) {\r\n SceneLoader.RegisterPlugin(new GLTFFileLoader());\r\n}\r\n"]}
|
1
|
+
{"version":3,"file":"glTFFileLoader.js","sourceRoot":"","sources":["../../../../dev/loaders/src/glTF/glTFFileLoader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,KAAK,EAAE,sCAAwB;AAaxC,OAAO,EAAE,WAAW,EAAE,+CAAiC;AACvD,OAAO,EAAE,cAAc,EAAE,0CAA4B;AAIrD,OAAO,EAAE,MAAM,EAAE,uCAAyB;AAE1C,OAAO,EAAE,UAAU,EAAE,2CAA6B;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,uBAAuB,EAAE,0CAA4B;AAC9D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,sCA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AAkC,AAArC,CAAsC;AAgD5E,IAAI,WAAW,EAAE;IACb,WAAW,CAAC,cAAc,CAAC,IAAI,cAAc,EAAE,CAAC,CAAC;CACpD","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\nimport type * as GLTF2 from \"babylonjs-gltf2interface\";\r\nimport type { Nullable } from \"core/types\";\r\nimport type { Observer } from \"core/Misc/observable\";\r\nimport { Observable } from \"core/Misc/observable\";\r\nimport { Tools } from \"core/Misc/tools\";\r\nimport type { Camera } from \"core/Cameras/camera\";\r\nimport type { BaseTexture } from \"core/Materials/Textures/baseTexture\";\r\nimport type { Material } from \"core/Materials/material\";\r\nimport type { AbstractMesh } from \"core/Meshes/abstractMesh\";\r\nimport type {\r\n ISceneLoaderPluginFactory,\r\n ISceneLoaderPlugin,\r\n ISceneLoaderPluginAsync,\r\n ISceneLoaderProgressEvent,\r\n ISceneLoaderPluginExtensions,\r\n ISceneLoaderAsyncResult,\r\n} from \"core/Loading/sceneLoader\";\r\nimport { SceneLoader } from \"core/Loading/sceneLoader\";\r\nimport { AssetContainer } from \"core/assetContainer\";\r\nimport type { Scene, IDisposable } from \"core/scene\";\r\nimport type { WebRequest } from \"core/Misc/webRequest\";\r\nimport type { IFileRequest } from \"core/Misc/fileRequest\";\r\nimport { Logger } from \"core/Misc/logger\";\r\nimport type { IDataBuffer } from \"core/Misc/dataReader\";\r\nimport { DataReader } from \"core/Misc/dataReader\";\r\nimport { GLTFValidation } from \"./glTFValidation\";\r\nimport type { LoadFileError } from \"core/Misc/fileTools\";\r\nimport { DecodeBase64UrlToBinary } from \"core/Misc/fileTools\";\r\nimport { RuntimeError, ErrorCodes } from \"core/Misc/error\";\r\nimport type { TransformNode } from \"core/Meshes/transformNode\";\r\nimport type { MorphTargetManager } from \"core/Morph/morphTargetManager\";\r\n\r\ninterface IFileRequestInfo extends IFileRequest {\r\n _lengthComputable?: boolean;\r\n _loaded?: number;\r\n _total?: number;\r\n}\r\n\r\nfunction readAsync(arrayBuffer: ArrayBuffer, byteOffset: number, byteLength: number): Promise<Uint8Array> {\r\n try {\r\n return Promise.resolve(new Uint8Array(arrayBuffer, byteOffset, byteLength));\r\n } catch (e) {\r\n return Promise.reject(e);\r\n }\r\n}\r\n\r\nfunction readViewAsync(arrayBufferView: ArrayBufferView, byteOffset: number, byteLength: number): Promise<Uint8Array> {\r\n try {\r\n if (byteOffset < 0 || byteOffset >= arrayBufferView.byteLength) {\r\n throw new RangeError(\"Offset is out of range.\");\r\n }\r\n\r\n if (byteOffset + byteLength > arrayBufferView.byteLength) {\r\n throw new RangeError(\"Length is out of range.\");\r\n }\r\n\r\n return Promise.resolve(new Uint8Array(arrayBufferView.buffer, arrayBufferView.byteOffset + byteOffset, byteLength));\r\n } catch (e) {\r\n return Promise.reject(e);\r\n }\r\n}\r\n\r\n/**\r\n * Mode that determines the coordinate system to use.\r\n */\r\nexport enum GLTFLoaderCoordinateSystemMode {\r\n /**\r\n * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.\r\n */\r\n AUTO,\r\n\r\n /**\r\n * Sets the useRightHandedSystem flag on the scene.\r\n */\r\n FORCE_RIGHT_HANDED,\r\n}\r\n\r\n/**\r\n * Mode that determines what animations will start.\r\n */\r\nexport enum GLTFLoaderAnimationStartMode {\r\n /**\r\n * No animation will start.\r\n */\r\n NONE,\r\n\r\n /**\r\n * The first animation will start.\r\n */\r\n FIRST,\r\n\r\n /**\r\n * All animations will start.\r\n */\r\n ALL,\r\n}\r\n\r\n/**\r\n * Interface that contains the data for the glTF asset.\r\n */\r\nexport interface IGLTFLoaderData {\r\n /**\r\n * The object that represents the glTF JSON.\r\n */\r\n json: Object;\r\n\r\n /**\r\n * The BIN chunk of a binary glTF.\r\n */\r\n bin: Nullable<IDataBuffer>;\r\n}\r\n\r\n/**\r\n * Interface for extending the loader.\r\n */\r\nexport interface IGLTFLoaderExtension {\r\n /**\r\n * The name of this extension.\r\n */\r\n readonly name: string;\r\n\r\n /**\r\n * Defines whether this extension is enabled.\r\n */\r\n enabled: boolean;\r\n\r\n /**\r\n * Defines the order of this extension.\r\n * The loader sorts the extensions using these values when loading.\r\n */\r\n order?: number;\r\n}\r\n\r\n/**\r\n * Loader state.\r\n */\r\nexport enum GLTFLoaderState {\r\n /**\r\n * The asset is loading.\r\n */\r\n LOADING,\r\n\r\n /**\r\n * The asset is ready for rendering.\r\n */\r\n READY,\r\n\r\n /**\r\n * The asset is completely loaded.\r\n */\r\n COMPLETE,\r\n}\r\n\r\n/** @internal */\r\nexport interface IGLTFLoader extends IDisposable {\r\n importMeshAsync: (\r\n meshesNames: any,\r\n scene: Scene,\r\n container: Nullable<AssetContainer>,\r\n data: IGLTFLoaderData,\r\n rootUrl: string,\r\n onProgress?: (event: ISceneLoaderProgressEvent) => void,\r\n fileName?: string\r\n ) => Promise<ISceneLoaderAsyncResult>;\r\n loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;\r\n}\r\n\r\n/**\r\n * File loader for loading glTF files into a scene.\r\n */\r\nexport class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {\r\n /** @internal */\r\n public static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;\r\n\r\n /** @internal */\r\n public static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;\r\n\r\n // --------------\r\n // Common options\r\n // --------------\r\n\r\n /**\r\n * Raised when the asset has been parsed\r\n */\r\n public onParsedObservable = new Observable<IGLTFLoaderData>();\r\n\r\n private _onParsedObserver: Nullable<Observer<IGLTFLoaderData>>;\r\n\r\n /**\r\n * Raised when the asset has been parsed\r\n */\r\n public set onParsed(callback: (loaderData: IGLTFLoaderData) => void) {\r\n if (this._onParsedObserver) {\r\n this.onParsedObservable.remove(this._onParsedObserver);\r\n }\r\n this._onParsedObserver = this.onParsedObservable.add(callback);\r\n }\r\n\r\n // ----------\r\n // V1 options\r\n // ----------\r\n\r\n /**\r\n * Set this property to false to disable incremental loading which delays the loader from calling the success callback until after loading the meshes and shaders.\r\n * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.\r\n * Defaults to true.\r\n * @internal\r\n */\r\n public static IncrementalLoading = true;\r\n\r\n /**\r\n * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.\r\n * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.\r\n * @internal\r\n */\r\n public static HomogeneousCoordinates = false;\r\n\r\n // ----------\r\n // V2 options\r\n // ----------\r\n\r\n /**\r\n * The coordinate system mode. Defaults to AUTO.\r\n */\r\n public coordinateSystemMode = GLTFLoaderCoordinateSystemMode.AUTO;\r\n\r\n /**\r\n * The animation start mode. Defaults to FIRST.\r\n */\r\n public animationStartMode = GLTFLoaderAnimationStartMode.FIRST;\r\n\r\n /**\r\n * Defines if the loader should compile materials before raising the success callback. Defaults to false.\r\n */\r\n public compileMaterials = false;\r\n\r\n /**\r\n * Defines if the loader should also compile materials with clip planes. Defaults to false.\r\n */\r\n public useClipPlane = false;\r\n\r\n /**\r\n * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.\r\n */\r\n public compileShadowGenerators = false;\r\n\r\n /**\r\n * Defines if the Alpha blended materials are only applied as coverage.\r\n * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.\r\n * If true, no extra effects are applied to transparent pixels.\r\n */\r\n public transparencyAsCoverage = false;\r\n\r\n /**\r\n * Defines if the loader should use range requests when load binary glTF files from HTTP.\r\n * Enabling will disable offline support and glTF validator.\r\n * Defaults to false.\r\n */\r\n public useRangeRequests = false;\r\n\r\n /**\r\n * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.\r\n */\r\n public createInstances = true;\r\n\r\n /**\r\n * Defines if the loader should always compute the bounding boxes of meshes and not use the min/max values from the position accessor. Defaults to false.\r\n */\r\n public alwaysComputeBoundingBox = false;\r\n\r\n /**\r\n * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.\r\n */\r\n public loadAllMaterials = false;\r\n\r\n /**\r\n * If true, load only the materials defined in the file. Defaults to false.\r\n */\r\n public loadOnlyMaterials = false;\r\n\r\n /**\r\n * If true, do not load any materials defined in the file. Defaults to false.\r\n */\r\n public skipMaterials = false;\r\n\r\n /**\r\n * If true, load the color (gamma encoded) textures into sRGB buffers (if supported by the GPU), which will yield more accurate results when sampling the texture. Defaults to true.\r\n */\r\n public useSRGBBuffers = true;\r\n\r\n /**\r\n * When loading glTF animations, which are defined in seconds, target them to this FPS. Defaults to 60.\r\n */\r\n public targetFps = 60;\r\n\r\n /**\r\n * Defines if the loader should always compute the nearest common ancestor of the skeleton joints instead of using `skin.skeleton`. Defaults to false.\r\n * Set this to true if loading assets with invalid `skin.skeleton` values.\r\n */\r\n public alwaysComputeSkeletonRootNode = false;\r\n\r\n /**\r\n * Function called before loading a url referenced by the asset.\r\n * @param url\r\n */\r\n public preprocessUrlAsync = (url: string) => Promise.resolve(url);\r\n\r\n /**\r\n * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.\r\n * Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)\r\n */\r\n public readonly onMeshLoadedObservable = new Observable<AbstractMesh>();\r\n\r\n private _onMeshLoadedObserver: Nullable<Observer<AbstractMesh>>;\r\n\r\n /**\r\n * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.\r\n * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)\r\n */\r\n public set onMeshLoaded(callback: (mesh: AbstractMesh) => void) {\r\n if (this._onMeshLoadedObserver) {\r\n this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver);\r\n }\r\n this._onMeshLoadedObserver = this.onMeshLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Callback raised when the loader creates a skin after parsing the glTF properties of the skin node.\r\n * @see https://doc.babylonjs.com/features/featuresDeepDive/importers/glTF/glTFSkinning#ignoring-the-transform-of-the-skinned-mesh\r\n * @param node - the transform node that corresponds to the original glTF skin node used for animations\r\n * @param skinnedNode - the transform node that is the skinned mesh itself or the parent of the skinned meshes\r\n */\r\n public readonly onSkinLoadedObservable = new Observable<{ node: TransformNode; skinnedNode: TransformNode }>();\r\n\r\n /**\r\n * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.\r\n */\r\n public readonly onTextureLoadedObservable = new Observable<BaseTexture>();\r\n\r\n private _onTextureLoadedObserver: Nullable<Observer<BaseTexture>>;\r\n\r\n /**\r\n * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.\r\n */\r\n public set onTextureLoaded(callback: (texture: BaseTexture) => void) {\r\n if (this._onTextureLoadedObserver) {\r\n this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver);\r\n }\r\n this._onTextureLoadedObserver = this.onTextureLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised when the loader creates a material after parsing the glTF properties of the material.\r\n */\r\n public readonly onMaterialLoadedObservable = new Observable<Material>();\r\n\r\n private _onMaterialLoadedObserver: Nullable<Observer<Material>>;\r\n\r\n /**\r\n * Callback raised when the loader creates a material after parsing the glTF properties of the material.\r\n */\r\n public set onMaterialLoaded(callback: (material: Material) => void) {\r\n if (this._onMaterialLoadedObserver) {\r\n this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver);\r\n }\r\n this._onMaterialLoadedObserver = this.onMaterialLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.\r\n */\r\n public readonly onCameraLoadedObservable = new Observable<Camera>();\r\n\r\n private _onCameraLoadedObserver: Nullable<Observer<Camera>>;\r\n\r\n /**\r\n * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.\r\n */\r\n public set onCameraLoaded(callback: (camera: Camera) => void) {\r\n if (this._onCameraLoadedObserver) {\r\n this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver);\r\n }\r\n this._onCameraLoadedObserver = this.onCameraLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised when the asset is completely loaded, immediately before the loader is disposed.\r\n * For assets with LODs, raised when all of the LODs are complete.\r\n * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.\r\n */\r\n public readonly onCompleteObservable = new Observable<void>();\r\n\r\n private _onCompleteObserver: Nullable<Observer<void>>;\r\n\r\n /**\r\n * Callback raised when the asset is completely loaded, immediately before the loader is disposed.\r\n * For assets with LODs, raised when all of the LODs are complete.\r\n * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.\r\n */\r\n public set onComplete(callback: () => void) {\r\n if (this._onCompleteObserver) {\r\n this.onCompleteObservable.remove(this._onCompleteObserver);\r\n }\r\n this._onCompleteObserver = this.onCompleteObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised when an error occurs.\r\n */\r\n public readonly onErrorObservable = new Observable<any>();\r\n\r\n private _onErrorObserver: Nullable<Observer<any>>;\r\n\r\n /**\r\n * Callback raised when an error occurs.\r\n */\r\n public set onError(callback: (reason: any) => void) {\r\n if (this._onErrorObserver) {\r\n this.onErrorObservable.remove(this._onErrorObserver);\r\n }\r\n this._onErrorObserver = this.onErrorObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised after the loader is disposed.\r\n */\r\n public readonly onDisposeObservable = new Observable<void>();\r\n\r\n private _onDisposeObserver: Nullable<Observer<void>>;\r\n\r\n /**\r\n * Callback raised after the loader is disposed.\r\n */\r\n public set onDispose(callback: () => void) {\r\n if (this._onDisposeObserver) {\r\n this.onDisposeObservable.remove(this._onDisposeObserver);\r\n }\r\n this._onDisposeObserver = this.onDisposeObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Observable raised after a loader extension is created.\r\n * Set additional options for a loader extension in this event.\r\n */\r\n public readonly onExtensionLoadedObservable = new Observable<IGLTFLoaderExtension>();\r\n\r\n private _onExtensionLoadedObserver: Nullable<Observer<IGLTFLoaderExtension>>;\r\n\r\n /**\r\n * Callback raised after a loader extension is created.\r\n */\r\n public set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void) {\r\n if (this._onExtensionLoadedObserver) {\r\n this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver);\r\n }\r\n this._onExtensionLoadedObserver = this.onExtensionLoadedObservable.add(callback);\r\n }\r\n\r\n /**\r\n * Defines if the loader logging is enabled.\r\n */\r\n public get loggingEnabled(): boolean {\r\n return this._loggingEnabled;\r\n }\r\n\r\n public set loggingEnabled(value: boolean) {\r\n if (this._loggingEnabled === value) {\r\n return;\r\n }\r\n\r\n this._loggingEnabled = value;\r\n\r\n if (this._loggingEnabled) {\r\n this._log = this._logEnabled;\r\n } else {\r\n this._log = this._logDisabled;\r\n }\r\n }\r\n\r\n /**\r\n * Defines if the loader should capture performance counters.\r\n */\r\n public get capturePerformanceCounters(): boolean {\r\n return this._capturePerformanceCounters;\r\n }\r\n\r\n public set capturePerformanceCounters(value: boolean) {\r\n if (this._capturePerformanceCounters === value) {\r\n return;\r\n }\r\n\r\n this._capturePerformanceCounters = value;\r\n\r\n if (this._capturePerformanceCounters) {\r\n this._startPerformanceCounter = this._startPerformanceCounterEnabled;\r\n this._endPerformanceCounter = this._endPerformanceCounterEnabled;\r\n } else {\r\n this._startPerformanceCounter = this._startPerformanceCounterDisabled;\r\n this._endPerformanceCounter = this._endPerformanceCounterDisabled;\r\n }\r\n }\r\n\r\n /**\r\n * Defines if the loader should validate the asset.\r\n */\r\n public validate = false;\r\n\r\n /**\r\n * Observable raised after validation when validate is set to true. The event data is the result of the validation.\r\n */\r\n public readonly onValidatedObservable = new Observable<GLTF2.IGLTFValidationResults>();\r\n\r\n private _onValidatedObserver: Nullable<Observer<GLTF2.IGLTFValidationResults>>;\r\n\r\n /**\r\n * Callback raised after a loader extension is created.\r\n */\r\n public set onValidated(callback: (results: GLTF2.IGLTFValidationResults) => void) {\r\n if (this._onValidatedObserver) {\r\n this.onValidatedObservable.remove(this._onValidatedObserver);\r\n }\r\n this._onValidatedObserver = this.onValidatedObservable.add(callback);\r\n }\r\n\r\n private _loader: Nullable<IGLTFLoader> = null;\r\n private _state: Nullable<GLTFLoaderState> = null;\r\n private _progressCallback?: (event: ISceneLoaderProgressEvent) => void;\r\n private _requests = new Array<IFileRequestInfo>();\r\n\r\n private static _MagicBase64Encoded = \"Z2xURg\"; // \"glTF\" base64 encoded (without the quotes!)\r\n\r\n /**\r\n * Name of the loader (\"gltf\")\r\n */\r\n public name = \"gltf\";\r\n\r\n /** @internal */\r\n public extensions: ISceneLoaderPluginExtensions = {\r\n \".gltf\": { isBinary: false },\r\n \".glb\": { isBinary: true },\r\n };\r\n\r\n /**\r\n * Disposes the loader, releases resources during load, and cancels any outstanding requests.\r\n */\r\n public dispose(): void {\r\n if (this._loader) {\r\n this._loader.dispose();\r\n this._loader = null;\r\n }\r\n\r\n for (const request of this._requests) {\r\n request.abort();\r\n }\r\n\r\n this._requests.length = 0;\r\n\r\n delete this._progressCallback;\r\n\r\n this.preprocessUrlAsync = (url) => Promise.resolve(url);\r\n\r\n this.onMeshLoadedObservable.clear();\r\n this.onSkinLoadedObservable.clear();\r\n this.onTextureLoadedObservable.clear();\r\n this.onMaterialLoadedObservable.clear();\r\n this.onCameraLoadedObservable.clear();\r\n this.onCompleteObservable.clear();\r\n this.onExtensionLoadedObservable.clear();\r\n\r\n this.onDisposeObservable.notifyObservers(undefined);\r\n this.onDisposeObservable.clear();\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadFile(\r\n scene: Scene,\r\n fileOrUrl: File | string | ArrayBufferView,\r\n rootUrl: string,\r\n onSuccess: (data: any, responseURL?: string) => void,\r\n onProgress?: (ev: ISceneLoaderProgressEvent) => void,\r\n useArrayBuffer?: boolean,\r\n onError?: (request?: WebRequest, exception?: LoadFileError) => void,\r\n name?: string\r\n ): Nullable<IFileRequest> {\r\n if (ArrayBuffer.isView(fileOrUrl)) {\r\n this._loadBinary(scene, fileOrUrl as ArrayBufferView, rootUrl, onSuccess, onError, name);\r\n return null;\r\n }\r\n\r\n this._progressCallback = onProgress;\r\n\r\n const fileName = (fileOrUrl as File).name || Tools.GetFilename(fileOrUrl as string);\r\n\r\n if (useArrayBuffer) {\r\n if (this.useRangeRequests) {\r\n if (this.validate) {\r\n Logger.Warn(\"glTF validation is not supported when range requests are enabled\");\r\n }\r\n\r\n const fileRequest: IFileRequest = {\r\n abort: () => {},\r\n onCompleteObservable: new Observable<IFileRequest>(),\r\n };\r\n\r\n const dataBuffer = {\r\n readAsync: (byteOffset: number, byteLength: number) => {\r\n return new Promise<ArrayBufferView>((resolve, reject) => {\r\n this._loadFile(\r\n scene,\r\n fileOrUrl as File | string,\r\n (data) => {\r\n resolve(new Uint8Array(data as ArrayBuffer));\r\n },\r\n true,\r\n (error) => {\r\n reject(error);\r\n },\r\n (webRequest) => {\r\n webRequest.setRequestHeader(\"Range\", `bytes=${byteOffset}-${byteOffset + byteLength - 1}`);\r\n }\r\n );\r\n });\r\n },\r\n byteLength: 0,\r\n };\r\n\r\n this._unpackBinaryAsync(new DataReader(dataBuffer)).then(\r\n (loaderData) => {\r\n fileRequest.onCompleteObservable.notifyObservers(fileRequest);\r\n onSuccess(loaderData);\r\n },\r\n onError ? (error) => onError(undefined, error) : undefined\r\n );\r\n\r\n return fileRequest;\r\n }\r\n\r\n return this._loadFile(\r\n scene,\r\n fileOrUrl as File | string,\r\n (data) => {\r\n this._validate(scene, new Uint8Array(data as ArrayBuffer, 0, (data as ArrayBuffer).byteLength), rootUrl, fileName);\r\n this._unpackBinaryAsync(\r\n new DataReader({\r\n readAsync: (byteOffset, byteLength) => readAsync(data as ArrayBuffer, byteOffset, byteLength),\r\n byteLength: (data as ArrayBuffer).byteLength,\r\n })\r\n ).then(\r\n (loaderData) => {\r\n onSuccess(loaderData);\r\n },\r\n onError ? (error) => onError(undefined, error) : undefined\r\n );\r\n },\r\n true,\r\n onError\r\n );\r\n } else {\r\n return this._loadFile(\r\n scene,\r\n fileOrUrl,\r\n (data) => {\r\n this._validate(scene, data as string, rootUrl, fileName);\r\n onSuccess({ json: this._parseJson(data as string) });\r\n },\r\n false,\r\n onError\r\n );\r\n }\r\n }\r\n\r\n private _loadBinary(\r\n scene: Scene,\r\n data: ArrayBufferView,\r\n rootUrl: string,\r\n onSuccess: (data: any, responseURL?: string) => void,\r\n onError?: (request?: WebRequest, exception?: LoadFileError) => void,\r\n fileName?: string\r\n ): void {\r\n this._validate(scene, new Uint8Array(data.buffer, data.byteOffset, data.byteLength), rootUrl, fileName);\r\n this._unpackBinaryAsync(\r\n new DataReader({\r\n readAsync: (byteOffset, byteLength) => readViewAsync(data, byteOffset, byteLength),\r\n byteLength: data.byteLength,\r\n })\r\n ).then(\r\n (loaderData) => {\r\n onSuccess(loaderData);\r\n },\r\n onError ? (error) => onError(undefined, error) : undefined\r\n );\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public importMeshAsync(\r\n meshesNames: any,\r\n scene: Scene,\r\n data: any,\r\n rootUrl: string,\r\n onProgress?: (event: ISceneLoaderProgressEvent) => void,\r\n fileName?: string\r\n ): Promise<ISceneLoaderAsyncResult> {\r\n return Promise.resolve().then(() => {\r\n this.onParsedObservable.notifyObservers(data);\r\n this.onParsedObservable.clear();\r\n\r\n this._log(`Loading ${fileName || \"\"}`);\r\n this._loader = this._getLoader(data);\r\n return this._loader.importMeshAsync(meshesNames, scene, null, data, rootUrl, onProgress, fileName);\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void> {\r\n return Promise.resolve().then(() => {\r\n this.onParsedObservable.notifyObservers(data);\r\n this.onParsedObservable.clear();\r\n\r\n this._log(`Loading ${fileName || \"\"}`);\r\n this._loader = this._getLoader(data);\r\n return this._loader.loadAsync(scene, data, rootUrl, onProgress, fileName);\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer> {\r\n return Promise.resolve().then(() => {\r\n this.onParsedObservable.notifyObservers(data);\r\n this.onParsedObservable.clear();\r\n\r\n this._log(`Loading ${fileName || \"\"}`);\r\n this._loader = this._getLoader(data);\r\n\r\n // Prepare the asset container.\r\n const container = new AssetContainer(scene);\r\n\r\n // Get materials/textures when loading to add to container\r\n const materials: Array<Material> = [];\r\n this.onMaterialLoadedObservable.add((material) => {\r\n materials.push(material);\r\n });\r\n const textures: Array<BaseTexture> = [];\r\n this.onTextureLoadedObservable.add((texture) => {\r\n textures.push(texture);\r\n });\r\n const cameras: Array<Camera> = [];\r\n this.onCameraLoadedObservable.add((camera) => {\r\n cameras.push(camera);\r\n });\r\n\r\n const morphTargetManagers: Array<MorphTargetManager> = [];\r\n this.onMeshLoadedObservable.add((mesh) => {\r\n if (mesh.morphTargetManager) {\r\n morphTargetManagers.push(mesh.morphTargetManager);\r\n }\r\n });\r\n\r\n return this._loader.importMeshAsync(null, scene, container, data, rootUrl, onProgress, fileName).then((result) => {\r\n Array.prototype.push.apply(container.geometries, result.geometries);\r\n Array.prototype.push.apply(container.meshes, result.meshes);\r\n Array.prototype.push.apply(container.particleSystems, result.particleSystems);\r\n Array.prototype.push.apply(container.skeletons, result.skeletons);\r\n Array.prototype.push.apply(container.animationGroups, result.animationGroups);\r\n Array.prototype.push.apply(container.materials, materials);\r\n Array.prototype.push.apply(container.textures, textures);\r\n Array.prototype.push.apply(container.lights, result.lights);\r\n Array.prototype.push.apply(container.transformNodes, result.transformNodes);\r\n Array.prototype.push.apply(container.cameras, cameras);\r\n Array.prototype.push.apply(container.morphTargetManagers, morphTargetManagers);\r\n return container;\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public canDirectLoad(data: string): boolean {\r\n return (\r\n (data.indexOf(\"asset\") !== -1 && data.indexOf(\"version\") !== -1) ||\r\n data.startsWith(\"data:base64,\" + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat.\r\n data.startsWith(\"data:;base64,\" + GLTFFileLoader._MagicBase64Encoded) ||\r\n data.startsWith(\"data:application/octet-stream;base64,\" + GLTFFileLoader._MagicBase64Encoded) ||\r\n data.startsWith(\"data:model/gltf-binary;base64,\" + GLTFFileLoader._MagicBase64Encoded)\r\n );\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public directLoad(scene: Scene, data: string): Promise<any> {\r\n if (\r\n data.startsWith(\"base64,\" + GLTFFileLoader._MagicBase64Encoded) || // this is technically incorrect, but will continue to support for backcompat.\r\n data.startsWith(\";base64,\" + GLTFFileLoader._MagicBase64Encoded) ||\r\n data.startsWith(\"application/octet-stream;base64,\" + GLTFFileLoader._MagicBase64Encoded) ||\r\n data.startsWith(\"model/gltf-binary;base64,\" + GLTFFileLoader._MagicBase64Encoded)\r\n ) {\r\n const arrayBuffer = DecodeBase64UrlToBinary(data);\r\n\r\n this._validate(scene, new Uint8Array(arrayBuffer, 0, arrayBuffer.byteLength));\r\n return this._unpackBinaryAsync(\r\n new DataReader({\r\n readAsync: (byteOffset, byteLength) => readAsync(arrayBuffer, byteOffset, byteLength),\r\n byteLength: arrayBuffer.byteLength,\r\n })\r\n );\r\n }\r\n\r\n this._validate(scene, data);\r\n return Promise.resolve({ json: this._parseJson(data) });\r\n }\r\n\r\n /**\r\n * The callback that allows custom handling of the root url based on the response url.\r\n * @param rootUrl the original root url\r\n * @param responseURL the response url if available\r\n * @returns the new root url\r\n */\r\n public rewriteRootURL?(rootUrl: string, responseURL?: string): string;\r\n\r\n /** @internal */\r\n public createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync {\r\n return new GLTFFileLoader();\r\n }\r\n\r\n /**\r\n * The loader state or null if the loader is not active.\r\n */\r\n public get loaderState(): Nullable<GLTFLoaderState> {\r\n return this._state;\r\n }\r\n\r\n /**\r\n * Observable raised when the loader state changes.\r\n */\r\n public onLoaderStateChangedObservable = new Observable<Nullable<GLTFLoaderState>>();\r\n\r\n /**\r\n * Returns a promise that resolves when the asset is completely loaded.\r\n * @returns a promise that resolves when the asset is completely loaded.\r\n */\r\n public whenCompleteAsync(): Promise<void> {\r\n return new Promise((resolve, reject) => {\r\n this.onCompleteObservable.addOnce(() => {\r\n resolve();\r\n });\r\n this.onErrorObservable.addOnce((reason) => {\r\n reject(reason);\r\n });\r\n });\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _setState(state: GLTFLoaderState): void {\r\n if (this._state === state) {\r\n return;\r\n }\r\n\r\n this._state = state;\r\n this.onLoaderStateChangedObservable.notifyObservers(this._state);\r\n this._log(GLTFLoaderState[this._state]);\r\n }\r\n\r\n /**\r\n * @internal\r\n */\r\n public _loadFile(\r\n scene: Scene,\r\n fileOrUrl: File | string,\r\n onSuccess: (data: string | ArrayBuffer) => void,\r\n useArrayBuffer?: boolean,\r\n onError?: (request?: WebRequest) => void,\r\n onOpened?: (request: WebRequest) => void\r\n ): IFileRequest {\r\n const request = scene._loadFile(\r\n fileOrUrl,\r\n onSuccess,\r\n (event) => {\r\n this._onProgress(event, request);\r\n },\r\n true,\r\n useArrayBuffer,\r\n onError,\r\n onOpened\r\n ) as IFileRequestInfo;\r\n request.onCompleteObservable.add((request) => {\r\n this._requests.splice(this._requests.indexOf(request), 1);\r\n });\r\n this._requests.push(request);\r\n return request;\r\n }\r\n\r\n private _onProgress(event: ProgressEvent, request: IFileRequestInfo): void {\r\n if (!this._progressCallback) {\r\n return;\r\n }\r\n\r\n request._lengthComputable = event.lengthComputable;\r\n request._loaded = event.loaded;\r\n request._total = event.total;\r\n\r\n let lengthComputable = true;\r\n let loaded = 0;\r\n let total = 0;\r\n for (const request of this._requests) {\r\n if (request._lengthComputable === undefined || request._loaded === undefined || request._total === undefined) {\r\n return;\r\n }\r\n\r\n lengthComputable = lengthComputable && request._lengthComputable;\r\n loaded += request._loaded;\r\n total += request._total;\r\n }\r\n\r\n this._progressCallback({\r\n lengthComputable: lengthComputable,\r\n loaded: loaded,\r\n total: lengthComputable ? total : 0,\r\n });\r\n }\r\n\r\n private _validate(scene: Scene, data: string | Uint8Array, rootUrl = \"\", fileName = \"\"): void {\r\n if (!this.validate) {\r\n return;\r\n }\r\n\r\n this._startPerformanceCounter(\"Validate JSON\");\r\n GLTFValidation.ValidateAsync(data, rootUrl, fileName, (uri) => {\r\n return this.preprocessUrlAsync(rootUrl + uri).then((url) => {\r\n return scene._loadFileAsync(url, undefined, true, true).then((data) => {\r\n return new Uint8Array(data, 0, data.byteLength);\r\n });\r\n });\r\n }).then(\r\n (result) => {\r\n this._endPerformanceCounter(\"Validate JSON\");\r\n this.onValidatedObservable.notifyObservers(result);\r\n this.onValidatedObservable.clear();\r\n },\r\n (reason) => {\r\n this._endPerformanceCounter(\"Validate JSON\");\r\n Tools.Warn(`Failed to validate: ${reason.message}`);\r\n this.onValidatedObservable.clear();\r\n }\r\n );\r\n }\r\n\r\n private _getLoader(loaderData: IGLTFLoaderData): IGLTFLoader {\r\n const asset = (<any>loaderData.json).asset || {};\r\n\r\n this._log(`Asset version: ${asset.version}`);\r\n asset.minVersion && this._log(`Asset minimum version: ${asset.minVersion}`);\r\n asset.generator && this._log(`Asset generator: ${asset.generator}`);\r\n\r\n const version = GLTFFileLoader._parseVersion(asset.version);\r\n if (!version) {\r\n throw new Error(\"Invalid version: \" + asset.version);\r\n }\r\n\r\n if (asset.minVersion !== undefined) {\r\n const minVersion = GLTFFileLoader._parseVersion(asset.minVersion);\r\n if (!minVersion) {\r\n throw new Error(\"Invalid minimum version: \" + asset.minVersion);\r\n }\r\n\r\n if (GLTFFileLoader._compareVersion(minVersion, { major: 2, minor: 0 }) > 0) {\r\n throw new Error(\"Incompatible minimum version: \" + asset.minVersion);\r\n }\r\n }\r\n\r\n const createLoaders: { [key: number]: (parent: GLTFFileLoader) => IGLTFLoader } = {\r\n 1: GLTFFileLoader._CreateGLTF1Loader,\r\n 2: GLTFFileLoader._CreateGLTF2Loader,\r\n };\r\n\r\n const createLoader = createLoaders[version.major];\r\n if (!createLoader) {\r\n throw new Error(\"Unsupported version: \" + asset.version);\r\n }\r\n\r\n return createLoader(this);\r\n }\r\n\r\n private _parseJson(json: string): Object {\r\n this._startPerformanceCounter(\"Parse JSON\");\r\n this._log(`JSON length: ${json.length}`);\r\n const parsed = JSON.parse(json);\r\n this._endPerformanceCounter(\"Parse JSON\");\r\n return parsed;\r\n }\r\n\r\n private _unpackBinaryAsync(dataReader: DataReader): Promise<IGLTFLoaderData> {\r\n this._startPerformanceCounter(\"Unpack Binary\");\r\n\r\n // Read magic + version + length + json length + json format\r\n return dataReader.loadAsync(20).then(() => {\r\n const Binary = {\r\n Magic: 0x46546c67,\r\n };\r\n\r\n const magic = dataReader.readUint32();\r\n if (magic !== Binary.Magic) {\r\n throw new RuntimeError(\"Unexpected magic: \" + magic, ErrorCodes.GLTFLoaderUnexpectedMagicError);\r\n }\r\n\r\n const version = dataReader.readUint32();\r\n\r\n if (this.loggingEnabled) {\r\n this._log(`Binary version: ${version}`);\r\n }\r\n\r\n const length = dataReader.readUint32();\r\n if (!this.useRangeRequests && length !== dataReader.buffer.byteLength) {\r\n Logger.Warn(`Length in header does not match actual data length: ${length} != ${dataReader.buffer.byteLength}`);\r\n }\r\n\r\n let unpacked: Promise<IGLTFLoaderData>;\r\n switch (version) {\r\n case 1: {\r\n unpacked = this._unpackBinaryV1Async(dataReader, length);\r\n break;\r\n }\r\n case 2: {\r\n unpacked = this._unpackBinaryV2Async(dataReader, length);\r\n break;\r\n }\r\n default: {\r\n throw new Error(\"Unsupported version: \" + version);\r\n }\r\n }\r\n\r\n this._endPerformanceCounter(\"Unpack Binary\");\r\n\r\n return unpacked;\r\n });\r\n }\r\n\r\n private _unpackBinaryV1Async(dataReader: DataReader, length: number): Promise<IGLTFLoaderData> {\r\n const ContentFormat = {\r\n JSON: 0,\r\n };\r\n\r\n const contentLength = dataReader.readUint32();\r\n const contentFormat = dataReader.readUint32();\r\n\r\n if (contentFormat !== ContentFormat.JSON) {\r\n throw new Error(`Unexpected content format: ${contentFormat}`);\r\n }\r\n\r\n const bodyLength = length - dataReader.byteOffset;\r\n\r\n const data: IGLTFLoaderData = { json: this._parseJson(dataReader.readString(contentLength)), bin: null };\r\n if (bodyLength !== 0) {\r\n const startByteOffset = dataReader.byteOffset;\r\n data.bin = {\r\n readAsync: (byteOffset, byteLength) => dataReader.buffer.readAsync(startByteOffset + byteOffset, byteLength),\r\n byteLength: bodyLength,\r\n };\r\n }\r\n\r\n return Promise.resolve(data);\r\n }\r\n\r\n private _unpackBinaryV2Async(dataReader: DataReader, length: number): Promise<IGLTFLoaderData> {\r\n const ChunkFormat = {\r\n JSON: 0x4e4f534a,\r\n BIN: 0x004e4942,\r\n };\r\n\r\n // Read the JSON chunk header.\r\n const chunkLength = dataReader.readUint32();\r\n const chunkFormat = dataReader.readUint32();\r\n if (chunkFormat !== ChunkFormat.JSON) {\r\n throw new Error(\"First chunk format is not JSON\");\r\n }\r\n\r\n // Bail if there are no other chunks.\r\n if (dataReader.byteOffset + chunkLength === length) {\r\n return dataReader.loadAsync(chunkLength).then(() => {\r\n return { json: this._parseJson(dataReader.readString(chunkLength)), bin: null };\r\n });\r\n }\r\n\r\n // Read the JSON chunk and the length and type of the next chunk.\r\n return dataReader.loadAsync(chunkLength + 8).then(() => {\r\n const data: IGLTFLoaderData = { json: this._parseJson(dataReader.readString(chunkLength)), bin: null };\r\n\r\n const readAsync = (): Promise<IGLTFLoaderData> => {\r\n const chunkLength = dataReader.readUint32();\r\n const chunkFormat = dataReader.readUint32();\r\n\r\n switch (chunkFormat) {\r\n case ChunkFormat.JSON: {\r\n throw new Error(\"Unexpected JSON chunk\");\r\n }\r\n case ChunkFormat.BIN: {\r\n const startByteOffset = dataReader.byteOffset;\r\n data.bin = {\r\n readAsync: (byteOffset, byteLength) => dataReader.buffer.readAsync(startByteOffset + byteOffset, byteLength),\r\n byteLength: chunkLength,\r\n };\r\n dataReader.skipBytes(chunkLength);\r\n break;\r\n }\r\n default: {\r\n // ignore unrecognized chunkFormat\r\n dataReader.skipBytes(chunkLength);\r\n break;\r\n }\r\n }\r\n\r\n if (dataReader.byteOffset !== length) {\r\n return dataReader.loadAsync(8).then(readAsync);\r\n }\r\n\r\n return Promise.resolve(data);\r\n };\r\n\r\n return readAsync();\r\n });\r\n }\r\n\r\n private static _parseVersion(version: string): Nullable<{ major: number; minor: number }> {\r\n if (version === \"1.0\" || version === \"1.0.1\") {\r\n return {\r\n major: 1,\r\n minor: 0,\r\n };\r\n }\r\n\r\n const match = (version + \"\").match(/^(\\d+)\\.(\\d+)/);\r\n if (!match) {\r\n return null;\r\n }\r\n\r\n return {\r\n major: parseInt(match[1]),\r\n minor: parseInt(match[2]),\r\n };\r\n }\r\n\r\n private static _compareVersion(a: { major: number; minor: number }, b: { major: number; minor: number }): number {\r\n if (a.major > b.major) {\r\n return 1;\r\n }\r\n if (a.major < b.major) {\r\n return -1;\r\n }\r\n if (a.minor > b.minor) {\r\n return 1;\r\n }\r\n if (a.minor < b.minor) {\r\n return -1;\r\n }\r\n return 0;\r\n }\r\n\r\n private static readonly _logSpaces = \" \";\r\n private _logIndentLevel = 0;\r\n private _loggingEnabled = false;\r\n\r\n /** @internal */\r\n public _log = this._logDisabled;\r\n\r\n /**\r\n * @internal\r\n */\r\n public _logOpen(message: string): void {\r\n this._log(message);\r\n this._logIndentLevel++;\r\n }\r\n\r\n /** @internal */\r\n public _logClose(): void {\r\n --this._logIndentLevel;\r\n }\r\n\r\n private _logEnabled(message: string): void {\r\n const spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);\r\n Logger.Log(`${spaces}${message}`);\r\n }\r\n\r\n private _logDisabled(message: string): void {}\r\n\r\n private _capturePerformanceCounters = false;\r\n\r\n /** @internal */\r\n public _startPerformanceCounter = this._startPerformanceCounterDisabled;\r\n\r\n /** @internal */\r\n public _endPerformanceCounter = this._endPerformanceCounterDisabled;\r\n\r\n private _startPerformanceCounterEnabled(counterName: string): void {\r\n Tools.StartPerformanceCounter(counterName);\r\n }\r\n\r\n private _startPerformanceCounterDisabled(counterName: string): void {}\r\n\r\n private _endPerformanceCounterEnabled(counterName: string): void {\r\n Tools.EndPerformanceCounter(counterName);\r\n }\r\n\r\n private _endPerformanceCounterDisabled(counterName: string): void {}\r\n}\r\n\r\nif (SceneLoader) {\r\n SceneLoader.RegisterPlugin(new GLTFFileLoader());\r\n}\r\n"]}
|
package/glTF/glTFValidation.d.ts
CHANGED
@@ -25,5 +25,5 @@ export declare class GLTFValidation {
|
|
25
25
|
* @param getExternalResource The callback to get external resources for the glTF validator
|
26
26
|
* @returns A promise that resolves with the glTF validation results once complete
|
27
27
|
*/
|
28
|
-
static ValidateAsync(data: string |
|
28
|
+
static ValidateAsync(data: string | Uint8Array, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<Uint8Array>): Promise<GLTF2.IGLTFValidationResults>;
|
29
29
|
}
|
package/glTF/glTFValidation.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
import { Tools } from "@babylonjs/core/Misc/tools.js";
|
2
2
|
function validateAsync(data, rootUrl, fileName, getExternalResource) {
|
3
3
|
const options = {
|
4
|
-
externalResourceFunction:
|
4
|
+
externalResourceFunction: getExternalResource,
|
5
5
|
};
|
6
6
|
if (fileName) {
|
7
7
|
options.uri = rootUrl === "file:" ? fileName : rootUrl + fileName;
|
8
8
|
}
|
9
|
-
return data
|
9
|
+
return ArrayBuffer.isView(data) ? GLTFValidator.validateBytes(data, options) : GLTFValidator.validateString(data, options);
|
10
10
|
}
|
11
11
|
/**
|
12
12
|
* The worker function that gets converted to a blob url to pass into a worker.
|
@@ -56,7 +56,6 @@ export class GLTFValidation {
|
|
56
56
|
* @returns A promise that resolves with the glTF validation results once complete
|
57
57
|
*/
|
58
58
|
static ValidateAsync(data, rootUrl, fileName, getExternalResource) {
|
59
|
-
const dataCopy = ArrayBuffer.isView(data) ? data.slice().buffer : data;
|
60
59
|
if (typeof Worker === "function") {
|
61
60
|
return new Promise((resolve, reject) => {
|
62
61
|
const workerContent = `${validateAsync}(${workerFunc})()`;
|
@@ -96,7 +95,14 @@ export class GLTFValidation {
|
|
96
95
|
worker.addEventListener("error", onError);
|
97
96
|
worker.addEventListener("message", onMessage);
|
98
97
|
worker.postMessage({ id: "init", url: Tools.GetBabylonScriptURL(this.Configuration.url) });
|
99
|
-
|
98
|
+
if (ArrayBuffer.isView(data)) {
|
99
|
+
// Slice the data to avoid copying the whole array buffer.
|
100
|
+
const slicedData = data.slice();
|
101
|
+
worker.postMessage({ id: "validate", data: slicedData, rootUrl: rootUrl, fileName: fileName }, [slicedData.buffer]);
|
102
|
+
}
|
103
|
+
else {
|
104
|
+
worker.postMessage({ id: "validate", data: data, rootUrl: rootUrl, fileName: fileName });
|
105
|
+
}
|
100
106
|
});
|
101
107
|
}
|
102
108
|
else {
|
@@ -104,7 +110,7 @@ export class GLTFValidation {
|
|
104
110
|
this._LoadScriptPromise = Tools.LoadBabylonScriptAsync(this.Configuration.url);
|
105
111
|
}
|
106
112
|
return this._LoadScriptPromise.then(() => {
|
107
|
-
return validateAsync(
|
113
|
+
return validateAsync(data, rootUrl, fileName, getExternalResource);
|
108
114
|
});
|
109
115
|
}
|
110
116
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"glTFValidation.js","sourceRoot":"","sources":["../../../../dev/loaders/src/glTF/glTFValidation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,sCAAwB;AASxC,SAAS,aAAa,CAClB,IAA0B,EAC1B,OAAe,EACf,QAAgB,EAChB,mBAA0D;IAE1D,MAAM,OAAO,GAAiC;QAC1C,wBAAwB,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,K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AAC;4BAC7C,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;4BACjD,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;4BACpB,MAAM,CAAC,SAAS,EAAE,CAAC;yBACtB;qBACJ;gBACL,CAAC,CAAC;gBAEF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;gBAC1C,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;gBAE9C,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,mBAAmB,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC3F,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;YACjG,CAAC,CAAC,CAAC;SACN;aAAM;YACH,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;gBAC1B,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC,sBAAsB,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;aAClF;YAED,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,EAAE;gBACrC,OAAO,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,CAAC,CAAC;YAC3E,CAAC,CAAC,CAAC;SACN;IACL,CAAC;;AAlFD;;GAEG;AACW,4BAAa,GAAiC;IACxD,GAAG,EAAE,GAAG,KAAK,CAAC,cAAc,oBAAoB;CACnD,CAAC","sourcesContent":["import type * as GLTF2 from \"babylonjs-gltf2interface\";\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let GLTFValidator: GLTF2.IGLTFValidator;\r\n\r\n// WorkerGlobalScope\r\ndeclare function importScripts(...urls: string[]): void;\r\ndeclare function postMessage(message: any, transfer?: any[]): void;\r\n\r\nfunction validateAsync(\r\n data: string | ArrayBuffer,\r\n rootUrl: string,\r\n fileName: string,\r\n getExternalResource: (uri: string) => Promise<ArrayBuffer>\r\n): Promise<GLTF2.IGLTFValidationResults> {\r\n const options: GLTF2.IGLTFValidationOptions = {\r\n externalResourceFunction: (uri) => getExternalResource(uri).then((value) => new Uint8Array(value)),\r\n };\r\n\r\n if (fileName) {\r\n options.uri = rootUrl === \"file:\" ? fileName : rootUrl + fileName;\r\n }\r\n\r\n return data instanceof ArrayBuffer ? GLTFValidator.validateBytes(new Uint8Array(data), options) : GLTFValidator.validateString(data, options);\r\n}\r\n\r\n/**\r\n * The worker function that gets converted to a blob url to pass into a worker.\r\n */\r\nfunction workerFunc(): void {\r\n const pendingExternalResources: Array<{ resolve: (data: any) => void; reject: (reason: any) => void }> = [];\r\n\r\n onmessage = (message) => {\r\n const data = message.data;\r\n switch (data.id) {\r\n case \"init\": {\r\n importScripts(data.url);\r\n break;\r\n }\r\n case \"validate\": {\r\n validateAsync(\r\n data.data,\r\n data.rootUrl,\r\n data.fileName,\r\n (uri) =>\r\n new Promise((resolve, reject) => {\r\n const index = pendingExternalResources.length;\r\n pendingExternalResources.push({ resolve, reject });\r\n postMessage({ id: \"getExternalResource\", index: index, uri: uri });\r\n })\r\n ).then(\r\n (value) => {\r\n postMessage({ id: \"validate.resolve\", value: value });\r\n },\r\n (reason) => {\r\n postMessage({ id: \"validate.reject\", reason: reason });\r\n }\r\n );\r\n break;\r\n }\r\n case \"getExternalResource.resolve\": {\r\n pendingExternalResources[data.index].resolve(data.value);\r\n break;\r\n }\r\n case \"getExternalResource.reject\": {\r\n pendingExternalResources[data.index].reject(data.reason);\r\n break;\r\n }\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * Configuration for glTF validation\r\n */\r\nexport interface IGLTFValidationConfiguration {\r\n /**\r\n * The url of the glTF validator.\r\n */\r\n url: string;\r\n}\r\n\r\n/**\r\n * glTF validation\r\n */\r\nexport class GLTFValidation {\r\n /**\r\n * The configuration. Defaults to `{ url: \"https://cdn.babylonjs.com/gltf_validator.js\" }`.\r\n */\r\n public static Configuration: IGLTFValidationConfiguration = {\r\n url: `${Tools._DefaultCdnUrl}/gltf_validator.js`,\r\n };\r\n\r\n private static _LoadScriptPromise: Promise<void>;\r\n\r\n /**\r\n * Validate a glTF asset using the glTF-Validator.\r\n * @param data The JSON of a glTF or the array buffer of a binary glTF\r\n * @param rootUrl The root url for the glTF\r\n * @param fileName The file name for the glTF\r\n * @param getExternalResource The callback to get external resources for the glTF validator\r\n * @returns A promise that resolves with the glTF validation results once complete\r\n */\r\n public static ValidateAsync(\r\n data: string | ArrayBufferView,\r\n rootUrl: string,\r\n fileName: string,\r\n getExternalResource: (uri: string) => Promise<ArrayBuffer>\r\n ): Promise<GLTF2.IGLTFValidationResults> {\r\n const dataCopy = ArrayBuffer.isView(data) ? (data as Uint8Array).slice().buffer : (data as string);\r\n\r\n if (typeof Worker === \"function\") {\r\n return new Promise((resolve, reject) => {\r\n const workerContent = `${validateAsync}(${workerFunc})()`;\r\n const workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: \"application/javascript\" }));\r\n const worker = new Worker(workerBlobUrl);\r\n\r\n const onError = (error: ErrorEvent) => {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n reject(error);\r\n };\r\n\r\n const onMessage = (message: MessageEvent) => {\r\n const data = message.data;\r\n switch (data.id) {\r\n case \"getExternalResource\": {\r\n getExternalResource(data.uri).then(\r\n (value) => {\r\n worker.postMessage({ id: \"getExternalResource.resolve\", index: data.index, value: value }, [value]);\r\n },\r\n (reason) => {\r\n worker.postMessage({ id: \"getExternalResource.reject\", index: data.index, reason: reason });\r\n }\r\n );\r\n break;\r\n }\r\n case \"validate.resolve\": {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n resolve(data.value);\r\n worker.terminate();\r\n break;\r\n }\r\n case \"validate.reject\": {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n reject(data.reason);\r\n worker.terminate();\r\n }\r\n }\r\n };\r\n\r\n worker.addEventListener(\"error\", onError);\r\n worker.addEventListener(\"message\", onMessage);\r\n\r\n worker.postMessage({ id: \"init\", url: Tools.GetBabylonScriptURL(this.Configuration.url) });\r\n worker.postMessage({ id: \"validate\", data: dataCopy, rootUrl: rootUrl, fileName: fileName });\r\n });\r\n } else {\r\n if (!this._LoadScriptPromise) {\r\n this._LoadScriptPromise = Tools.LoadBabylonScriptAsync(this.Configuration.url);\r\n }\r\n\r\n return this._LoadScriptPromise.then(() => {\r\n return validateAsync(dataCopy, rootUrl, fileName, getExternalResource);\r\n });\r\n }\r\n }\r\n}\r\n"]}
|
1
|
+
{"version":3,"file":"glTFValidation.js","sourceRoot":"","sources":["../../../../dev/loaders/src/glTF/glTFValidation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,sCAAwB;AASxC,SAAS,aAAa,CAClB,IAAyB,EACzB,OAAe,EACf,QAAgB,EAChB,mBAAyD;IAEzD,MAAM,OAAO,GAAiC;QAC1C,wBAAwB,EAAE,mBAAmB;KAChD,CAAC;IAEF,IAAI,QAAQ,EAAE;QACV,OAAO,CAAC,GAAG,GAAG,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,GAAG,QAAQ,CAAC;KACrE;IAED,OAAO,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC/H,CAAC;AAED;;GAEG;AACH,SAAS,UAAU;IACf,MAAM,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AAM,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;iBACvH;qBAAM;oBACH,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;iBAC5F;YACL,CAAC,CAAC,CAAC;SACN;aAAM;YACH,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE;gBAC1B,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC,sBAAsB,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;aAClF;YAED,OAAO,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,GAAG,EAAE;gBACrC,OAAO,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,mBAAmB,CAAC,CAAC;YACvE,CAAC,CAAC,CAAC;SACN;IACL,CAAC;;AAvFD;;GAEG;AACW,4BAAa,GAAiC;IACxD,GAAG,EAAE,GAAG,KAAK,CAAC,cAAc,oBAAoB;CACnD,CAAC","sourcesContent":["import type * as GLTF2 from \"babylonjs-gltf2interface\";\r\nimport { Tools } from \"core/Misc/tools\";\r\n\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\ndeclare let GLTFValidator: GLTF2.IGLTFValidator;\r\n\r\n// WorkerGlobalScope\r\ndeclare function importScripts(...urls: string[]): void;\r\ndeclare function postMessage(message: any, transfer?: any[]): void;\r\n\r\nfunction validateAsync(\r\n data: string | Uint8Array,\r\n rootUrl: string,\r\n fileName: string,\r\n getExternalResource: (uri: string) => Promise<Uint8Array>\r\n): Promise<GLTF2.IGLTFValidationResults> {\r\n const options: GLTF2.IGLTFValidationOptions = {\r\n externalResourceFunction: getExternalResource,\r\n };\r\n\r\n if (fileName) {\r\n options.uri = rootUrl === \"file:\" ? fileName : rootUrl + fileName;\r\n }\r\n\r\n return ArrayBuffer.isView(data) ? GLTFValidator.validateBytes(data, options) : GLTFValidator.validateString(data, options);\r\n}\r\n\r\n/**\r\n * The worker function that gets converted to a blob url to pass into a worker.\r\n */\r\nfunction workerFunc(): void {\r\n const pendingExternalResources: Array<{ resolve: (data: any) => void; reject: (reason: any) => void }> = [];\r\n\r\n onmessage = (message) => {\r\n const data = message.data;\r\n switch (data.id) {\r\n case \"init\": {\r\n importScripts(data.url);\r\n break;\r\n }\r\n case \"validate\": {\r\n validateAsync(\r\n data.data,\r\n data.rootUrl,\r\n data.fileName,\r\n (uri) =>\r\n new Promise((resolve, reject) => {\r\n const index = pendingExternalResources.length;\r\n pendingExternalResources.push({ resolve, reject });\r\n postMessage({ id: \"getExternalResource\", index: index, uri: uri });\r\n })\r\n ).then(\r\n (value) => {\r\n postMessage({ id: \"validate.resolve\", value: value });\r\n },\r\n (reason) => {\r\n postMessage({ id: \"validate.reject\", reason: reason });\r\n }\r\n );\r\n break;\r\n }\r\n case \"getExternalResource.resolve\": {\r\n pendingExternalResources[data.index].resolve(data.value);\r\n break;\r\n }\r\n case \"getExternalResource.reject\": {\r\n pendingExternalResources[data.index].reject(data.reason);\r\n break;\r\n }\r\n }\r\n };\r\n}\r\n\r\n/**\r\n * Configuration for glTF validation\r\n */\r\nexport interface IGLTFValidationConfiguration {\r\n /**\r\n * The url of the glTF validator.\r\n */\r\n url: string;\r\n}\r\n\r\n/**\r\n * glTF validation\r\n */\r\nexport class GLTFValidation {\r\n /**\r\n * The configuration. Defaults to `{ url: \"https://cdn.babylonjs.com/gltf_validator.js\" }`.\r\n */\r\n public static Configuration: IGLTFValidationConfiguration = {\r\n url: `${Tools._DefaultCdnUrl}/gltf_validator.js`,\r\n };\r\n\r\n private static _LoadScriptPromise: Promise<void>;\r\n\r\n /**\r\n * Validate a glTF asset using the glTF-Validator.\r\n * @param data The JSON of a glTF or the array buffer of a binary glTF\r\n * @param rootUrl The root url for the glTF\r\n * @param fileName The file name for the glTF\r\n * @param getExternalResource The callback to get external resources for the glTF validator\r\n * @returns A promise that resolves with the glTF validation results once complete\r\n */\r\n public static ValidateAsync(\r\n data: string | Uint8Array,\r\n rootUrl: string,\r\n fileName: string,\r\n getExternalResource: (uri: string) => Promise<Uint8Array>\r\n ): Promise<GLTF2.IGLTFValidationResults> {\r\n if (typeof Worker === \"function\") {\r\n return new Promise((resolve, reject) => {\r\n const workerContent = `${validateAsync}(${workerFunc})()`;\r\n const workerBlobUrl = URL.createObjectURL(new Blob([workerContent], { type: \"application/javascript\" }));\r\n const worker = new Worker(workerBlobUrl);\r\n\r\n const onError = (error: ErrorEvent) => {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n reject(error);\r\n };\r\n\r\n const onMessage = (message: MessageEvent) => {\r\n const data = message.data;\r\n switch (data.id) {\r\n case \"getExternalResource\": {\r\n getExternalResource(data.uri).then(\r\n (value) => {\r\n worker.postMessage({ id: \"getExternalResource.resolve\", index: data.index, value: value }, [value]);\r\n },\r\n (reason) => {\r\n worker.postMessage({ id: \"getExternalResource.reject\", index: data.index, reason: reason });\r\n }\r\n );\r\n break;\r\n }\r\n case \"validate.resolve\": {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n resolve(data.value);\r\n worker.terminate();\r\n break;\r\n }\r\n case \"validate.reject\": {\r\n worker.removeEventListener(\"error\", onError);\r\n worker.removeEventListener(\"message\", onMessage);\r\n reject(data.reason);\r\n worker.terminate();\r\n }\r\n }\r\n };\r\n\r\n worker.addEventListener(\"error\", onError);\r\n worker.addEventListener(\"message\", onMessage);\r\n\r\n worker.postMessage({ id: \"init\", url: Tools.GetBabylonScriptURL(this.Configuration.url) });\r\n\r\n if (ArrayBuffer.isView(data)) {\r\n // Slice the data to avoid copying the whole array buffer.\r\n const slicedData = data.slice();\r\n worker.postMessage({ id: \"validate\", data: slicedData, rootUrl: rootUrl, fileName: fileName }, [slicedData.buffer]);\r\n } else {\r\n worker.postMessage({ id: \"validate\", data: data, rootUrl: rootUrl, fileName: fileName });\r\n }\r\n });\r\n } else {\r\n if (!this._LoadScriptPromise) {\r\n this._LoadScriptPromise = Tools.LoadBabylonScriptAsync(this.Configuration.url);\r\n }\r\n\r\n return this._LoadScriptPromise.then(() => {\r\n return validateAsync(data, rootUrl, fileName, getExternalResource);\r\n });\r\n }\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@babylonjs/loaders",
|
3
|
-
"version": "6.34.
|
3
|
+
"version": "6.34.3",
|
4
4
|
"main": "index.js",
|
5
5
|
"module": "index.js",
|
6
6
|
"types": "index.d.ts",
|
@@ -18,10 +18,10 @@
|
|
18
18
|
"postcompile": "build-tools -c add-js-to-es6"
|
19
19
|
},
|
20
20
|
"devDependencies": {
|
21
|
-
"@babylonjs/core": "^6.34.
|
21
|
+
"@babylonjs/core": "^6.34.3",
|
22
22
|
"@dev/build-tools": "^1.0.0",
|
23
23
|
"@lts/loaders": "^1.0.0",
|
24
|
-
"babylonjs-gltf2interface": "^6.34.
|
24
|
+
"babylonjs-gltf2interface": "^6.34.3"
|
25
25
|
},
|
26
26
|
"peerDependencies": {
|
27
27
|
"@babylonjs/core": "^6.0.0",
|