Christopher Yovanovitch 7 lat temu
rodzic
commit
c8e169e7c7
75 zmienionych plików z 31979 dodań i 23935 usunięć
  1. 23935 23935
      dist/preview release/babylon.d.ts
  2. 77 0
      dist/preview release/loaders/babylon.objFileLoader.d.ts
  3. 803 0
      dist/preview release/loaders/babylon.objFileLoader.js
  4. 1 0
      dist/preview release/loaders/babylon.objFileLoader.min.js
  5. 17 0
      dist/preview release/loaders/babylon.stlFileLoader.d.ts
  6. 170 0
      dist/preview release/loaders/babylon.stlFileLoader.js
  7. 1 0
      dist/preview release/loaders/babylon.stlFileLoader.min.js
  8. 29 0
      dist/preview release/materialsLibrary/babylon.cellMaterial.d.ts
  9. 294 0
      dist/preview release/materialsLibrary/babylon.cellMaterial.js
  10. 50 0
      dist/preview release/materialsLibrary/babylon.customMaterial.d.ts
  11. 189 0
      dist/preview release/materialsLibrary/babylon.customMaterial.js
  12. 1 0
      dist/preview release/materialsLibrary/babylon.customMaterial.min.js
  13. 30 0
      dist/preview release/materialsLibrary/babylon.fireMaterial.d.ts
  14. 335 0
      dist/preview release/materialsLibrary/babylon.fireMaterial.js
  15. 46 0
      dist/preview release/materialsLibrary/babylon.furMaterial.d.ts
  16. 480 0
      dist/preview release/materialsLibrary/babylon.furMaterial.js
  17. 28 0
      dist/preview release/materialsLibrary/babylon.gradientMaterial.d.ts
  18. 299 0
      dist/preview release/materialsLibrary/babylon.gradientMaterial.js
  19. 61 0
      dist/preview release/materialsLibrary/babylon.gridMaterial.d.ts
  20. 212 0
      dist/preview release/materialsLibrary/babylon.gridMaterial.js
  21. 35 0
      dist/preview release/materialsLibrary/babylon.lavaMaterial.d.ts
  22. 372 0
      dist/preview release/materialsLibrary/babylon.lavaMaterial.js
  23. 27 0
      dist/preview release/materialsLibrary/babylon.normalMaterial.d.ts
  24. 326 0
      dist/preview release/materialsLibrary/babylon.normalMaterial.js
  25. 18 0
      dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.d.ts
  26. 211 0
      dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.js
  27. 27 0
      dist/preview release/materialsLibrary/babylon.simpleMaterial.d.ts
  28. 285 0
      dist/preview release/materialsLibrary/babylon.simpleMaterial.js
  29. 29 0
      dist/preview release/materialsLibrary/babylon.skyMaterial.d.ts
  30. 228 0
      dist/preview release/materialsLibrary/babylon.skyMaterial.js
  31. 41 0
      dist/preview release/materialsLibrary/babylon.terrainMaterial.d.ts
  32. 400 0
      dist/preview release/materialsLibrary/babylon.terrainMaterial.js
  33. 41 0
      dist/preview release/materialsLibrary/babylon.triPlanarMaterial.d.ts
  34. 395 0
      dist/preview release/materialsLibrary/babylon.triPlanarMaterial.js
  35. 106 0
      dist/preview release/materialsLibrary/babylon.waterMaterial.d.ts
  36. 629 0
      dist/preview release/materialsLibrary/babylon.waterMaterial.js
  37. 102 0
      dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.d.ts
  38. 222 0
      dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.js
  39. 1 0
      dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js
  40. 98 0
      dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.d.ts
  41. 231 0
      dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.js
  42. 1 0
      dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js
  43. 15 0
      dist/preview release/proceduralTexturesLibrary/babylon.brickProceduralTexture.d.ts
  44. 82 0
      dist/preview release/proceduralTexturesLibrary/babylon.brickProceduralTexture.js
  45. 1 0
      dist/preview release/proceduralTexturesLibrary/babylon.brickProceduralTexture.min.js
  46. 11 0
      dist/preview release/proceduralTexturesLibrary/babylon.cloudProceduralTexture.d.ts
  47. 56 0
      dist/preview release/proceduralTexturesLibrary/babylon.cloudProceduralTexture.js
  48. 1 0
      dist/preview release/proceduralTexturesLibrary/babylon.cloudProceduralTexture.min.js
  49. 21 0
      dist/preview release/proceduralTexturesLibrary/babylon.fireProceduralTexture.d.ts
  50. 152 0
      dist/preview release/proceduralTexturesLibrary/babylon.fireProceduralTexture.js
  51. 1 0
      dist/preview release/proceduralTexturesLibrary/babylon.fireProceduralTexture.min.js
  52. 11 0
      dist/preview release/proceduralTexturesLibrary/babylon.grassProceduralTexture.d.ts
  53. 62 0
      dist/preview release/proceduralTexturesLibrary/babylon.grassProceduralTexture.js
  54. 1 0
      dist/preview release/proceduralTexturesLibrary/babylon.grassProceduralTexture.min.js
  55. 15 0
      dist/preview release/proceduralTexturesLibrary/babylon.marbleProceduralTexture.d.ts
  56. 82 0
      dist/preview release/proceduralTexturesLibrary/babylon.marbleProceduralTexture.js
  57. 1 0
      dist/preview release/proceduralTexturesLibrary/babylon.marbleProceduralTexture.min.js
  58. 11 0
      dist/preview release/proceduralTexturesLibrary/babylon.normalMapProceduralTexture.d.ts
  59. 51 0
      dist/preview release/proceduralTexturesLibrary/babylon.normalMapProceduralTexture.js
  60. 1 0
      dist/preview release/proceduralTexturesLibrary/babylon.normalMapProceduralTexture.min.js
  61. 13 0
      dist/preview release/proceduralTexturesLibrary/babylon.perlinNoiseProceduralTexture.d.ts
  62. 51 0
      dist/preview release/proceduralTexturesLibrary/babylon.perlinNoiseProceduralTexture.js
  63. 1 0
      dist/preview release/proceduralTexturesLibrary/babylon.perlinNoiseProceduralTexture.min.js
  64. 9 0
      dist/preview release/proceduralTexturesLibrary/babylon.roadProceduralTexture.d.ts
  65. 43 0
      dist/preview release/proceduralTexturesLibrary/babylon.roadProceduralTexture.js
  66. 1 0
      dist/preview release/proceduralTexturesLibrary/babylon.roadProceduralTexture.min.js
  67. 29 0
      dist/preview release/proceduralTexturesLibrary/babylon.starfieldProceduralTexture.d.ts
  68. 173 0
      dist/preview release/proceduralTexturesLibrary/babylon.starfieldProceduralTexture.js
  69. 1 0
      dist/preview release/proceduralTexturesLibrary/babylon.starfieldProceduralTexture.min.js
  70. 11 0
      dist/preview release/proceduralTexturesLibrary/babylon.woodProceduralTexture.d.ts
  71. 56 0
      dist/preview release/proceduralTexturesLibrary/babylon.woodProceduralTexture.js
  72. 1 0
      dist/preview release/proceduralTexturesLibrary/babylon.woodProceduralTexture.min.js
  73. 7 0
      dist/preview release/serializers/babylon.objSerializer.d.ts
  74. 124 0
      dist/preview release/serializers/babylon.objSerializer.js
  75. 1 0
      dist/preview release/serializers/babylon.objSerializer.min.js

Plik diff jest za duży
+ 23935 - 23935
dist/preview release/babylon.d.ts


+ 77 - 0
dist/preview release/loaders/babylon.objFileLoader.d.ts

@@ -0,0 +1,77 @@
+
+declare module BABYLON {
+    /**
+     * Class reading and parsing the MTL file bundled with the obj file.
+     */
+    class MTLFileLoader {
+        materials: BABYLON.StandardMaterial[];
+        /**
+         * This function will read the mtl file and create each material described inside
+         * This function could be improve by adding :
+         * -some component missing (Ni, Tf...)
+         * -including the specific options available
+         *
+         * @param scene
+         * @param data
+         * @param rootUrl
+         */
+        parseMTL(scene: BABYLON.Scene, data: string | ArrayBuffer, rootUrl: string): void;
+        /**
+         * Gets the texture for the material.
+         *
+         * If the material is imported from input file,
+         * We sanitize the url to ensure it takes the textre from aside the material.
+         *
+         * @param rootUrl The root url to load from
+         * @param value The value stored in the mtl
+         * @return The Texture
+         */
+        private static _getTexture(rootUrl, value, scene);
+    }
+    class OBJFileLoader implements ISceneLoaderPlugin {
+        static OPTIMIZE_WITH_UV: boolean;
+        static INVERT_Y: boolean;
+        name: string;
+        extensions: string;
+        obj: RegExp;
+        group: RegExp;
+        mtllib: RegExp;
+        usemtl: RegExp;
+        smooth: RegExp;
+        vertexPattern: RegExp;
+        normalPattern: RegExp;
+        uvPattern: RegExp;
+        facePattern1: RegExp;
+        facePattern2: RegExp;
+        facePattern3: RegExp;
+        facePattern4: RegExp;
+        /**
+         * Calls synchronously the MTL file attached to this obj.
+         * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
+         * Without this function materials are not displayed in the first frame (but displayed after).
+         * In consequence it is impossible to get material information in your HTML file
+         *
+         * @param url The URL of the MTL file
+         * @param rootUrl
+         * @param onSuccess Callback function to be called when the MTL file is loaded
+         * @private
+         */
+        private _loadMTL(url, rootUrl, onSuccess);
+        importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<ParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
+        load(scene: Scene, data: string, rootUrl: string): boolean;
+        loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
+        /**
+         * Read the OBJ file and create an Array of meshes.
+         * Each mesh contains all information given by the OBJ and the MTL file.
+         * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
+         *
+         * @param meshesNames
+         * @param scene BABYLON.Scene The scene where are displayed the data
+         * @param data String The content of the obj file
+         * @param rootUrl String The path to the folder
+         * @returns Array<AbstractMesh>
+         * @private
+         */
+        private _parseSolid(meshesNames, scene, data, rootUrl);
+    }
+}

+ 803 - 0
dist/preview release/loaders/babylon.objFileLoader.js

@@ -0,0 +1,803 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
+var BABYLON;
+(function (BABYLON) {
+    /**
+     * Class reading and parsing the MTL file bundled with the obj file.
+     */
+    var MTLFileLoader = /** @class */ (function () {
+        function MTLFileLoader() {
+            // All material loaded from the mtl will be set here
+            this.materials = [];
+        }
+        /**
+         * This function will read the mtl file and create each material described inside
+         * This function could be improve by adding :
+         * -some component missing (Ni, Tf...)
+         * -including the specific options available
+         *
+         * @param scene
+         * @param data
+         * @param rootUrl
+         */
+        MTLFileLoader.prototype.parseMTL = function (scene, data, rootUrl) {
+            if (data instanceof ArrayBuffer) {
+                return;
+            }
+            //Split the lines from the file
+            var lines = data.split('\n');
+            //Space char
+            var delimiter_pattern = /\s+/;
+            //Array with RGB colors
+            var color;
+            //New material
+            var material = null;
+            //Look at each line
+            for (var i = 0; i < lines.length; i++) {
+                var line = lines[i].trim();
+                // Blank line or comment
+                if (line.length === 0 || line.charAt(0) === '#') {
+                    continue;
+                }
+                //Get the first parameter (keyword)
+                var pos = line.indexOf(' ');
+                var key = (pos >= 0) ? line.substring(0, pos) : line;
+                key = key.toLowerCase();
+                //Get the data following the key
+                var value = (pos >= 0) ? line.substring(pos + 1).trim() : "";
+                //This mtl keyword will create the new material
+                if (key === "newmtl") {
+                    //Check if it is the first material.
+                    // Materials specifications are described after this keyword.
+                    if (material) {
+                        //Add the previous material in the material array.
+                        this.materials.push(material);
+                    }
+                    //Create a new material.
+                    // value is the name of the material read in the mtl file
+                    material = new BABYLON.StandardMaterial(value, scene);
+                }
+                else if (key === "kd" && material) {
+                    // Diffuse color (color under white light) using RGB values
+                    //value  = "r g b"
+                    color = value.split(delimiter_pattern, 3).map(parseFloat);
+                    //color = [r,g,b]
+                    //Set tghe color into the material
+                    material.diffuseColor = BABYLON.Color3.FromArray(color);
+                }
+                else if (key === "ka" && material) {
+                    // Ambient color (color under shadow) using RGB values
+                    //value = "r g b"
+                    color = value.split(delimiter_pattern, 3).map(parseFloat);
+                    //color = [r,g,b]
+                    //Set tghe color into the material
+                    material.ambientColor = BABYLON.Color3.FromArray(color);
+                }
+                else if (key === "ks" && material) {
+                    // Specular color (color when light is reflected from shiny surface) using RGB values
+                    //value = "r g b"
+                    color = value.split(delimiter_pattern, 3).map(parseFloat);
+                    //color = [r,g,b]
+                    //Set the color into the material
+                    material.specularColor = BABYLON.Color3.FromArray(color);
+                }
+                else if (key === "ke" && material) {
+                    // Emissive color using RGB values
+                    color = value.split(delimiter_pattern, 3).map(parseFloat);
+                    material.emissiveColor = BABYLON.Color3.FromArray(color);
+                }
+                else if (key === "ns" && material) {
+                    //value = "Integer"
+                    material.specularPower = parseFloat(value);
+                }
+                else if (key === "d" && material) {
+                    //d is dissolve for current material. It mean alpha for BABYLON
+                    material.alpha = parseFloat(value);
+                    //Texture
+                    //This part can be improved by adding the possible options of texture
+                }
+                else if (key === "map_ka" && material) {
+                    // ambient texture map with a loaded image
+                    //We must first get the folder of the image
+                    material.ambientTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
+                }
+                else if (key === "map_kd" && material) {
+                    // Diffuse texture map with a loaded image
+                    material.diffuseTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
+                }
+                else if (key === "map_ks" && material) {
+                    // Specular texture map with a loaded image
+                    //We must first get the folder of the image
+                    material.specularTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
+                }
+                else if (key === "map_ns") {
+                    //Specular
+                    //Specular highlight component
+                    //We must first get the folder of the image
+                    //
+                    //Not supported by BABYLON
+                    //
+                    //    continue;
+                }
+                else if (key === "map_bump" && material) {
+                    //The bump texture
+                    material.bumpTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
+                }
+                else if (key === "map_d" && material) {
+                    // The dissolve of the material
+                    material.opacityTexture = MTLFileLoader._getTexture(rootUrl, value, scene);
+                    //Options for illumination
+                }
+                else if (key === "illum") {
+                    //Illumination
+                    if (value === "0") {
+                        //That mean Kd == Kd
+                    }
+                    else if (value === "1") {
+                        //Color on and Ambient on
+                    }
+                    else if (value === "2") {
+                        //Highlight on
+                    }
+                    else if (value === "3") {
+                        //Reflection on and Ray trace on
+                    }
+                    else if (value === "4") {
+                        //Transparency: Glass on, Reflection: Ray trace on
+                    }
+                    else if (value === "5") {
+                        //Reflection: Fresnel on and Ray trace on
+                    }
+                    else if (value === "6") {
+                        //Transparency: Refraction on, Reflection: Fresnel off and Ray trace on
+                    }
+                    else if (value === "7") {
+                        //Transparency: Refraction on, Reflection: Fresnel on and Ray trace on
+                    }
+                    else if (value === "8") {
+                        //Reflection on and Ray trace off
+                    }
+                    else if (value === "9") {
+                        //Transparency: Glass on, Reflection: Ray trace off
+                    }
+                    else if (value === "10") {
+                        //Casts shadows onto invisible surfaces
+                    }
+                }
+                else {
+                    // console.log("Unhandled expression at line : " + i +'\n' + "with value : " + line);
+                }
+            }
+            //At the end of the file, add the last material
+            if (material) {
+                this.materials.push(material);
+            }
+        };
+        /**
+         * Gets the texture for the material.
+         *
+         * If the material is imported from input file,
+         * We sanitize the url to ensure it takes the textre from aside the material.
+         *
+         * @param rootUrl The root url to load from
+         * @param value The value stored in the mtl
+         * @return The Texture
+         */
+        MTLFileLoader._getTexture = function (rootUrl, value, scene) {
+            if (!value) {
+                return null;
+            }
+            var url = rootUrl;
+            // Load from input file.
+            if (rootUrl === "file:") {
+                var lastDelimiter = value.lastIndexOf("\\");
+                if (lastDelimiter === -1) {
+                    lastDelimiter = value.lastIndexOf("/");
+                }
+                if (lastDelimiter > -1) {
+                    url += value.substr(lastDelimiter + 1);
+                }
+                else {
+                    url += value;
+                }
+            }
+            // Not from input file.
+            else {
+                url += value;
+            }
+            return new BABYLON.Texture(url, scene);
+        };
+        return MTLFileLoader;
+    }());
+    BABYLON.MTLFileLoader = MTLFileLoader;
+    var OBJFileLoader = /** @class */ (function () {
+        function OBJFileLoader() {
+            this.name = "obj";
+            this.extensions = ".obj";
+            this.obj = /^o/;
+            this.group = /^g/;
+            this.mtllib = /^mtllib /;
+            this.usemtl = /^usemtl /;
+            this.smooth = /^s /;
+            this.vertexPattern = /v( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/;
+            // vn float float float
+            this.normalPattern = /vn( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/;
+            // vt float float
+            this.uvPattern = /vt( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/;
+            // f vertex vertex vertex ...
+            this.facePattern1 = /f\s+(([\d]{1,}[\s]?){3,})+/;
+            // f vertex/uvs vertex/uvs vertex/uvs ...
+            this.facePattern2 = /f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/;
+            // f vertex/uvs/normal vertex/uvs/normal vertex/uvs/normal ...
+            this.facePattern3 = /f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/;
+            // f vertex//normal vertex//normal vertex//normal ...
+            this.facePattern4 = /f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/;
+        }
+        /**
+         * Calls synchronously the MTL file attached to this obj.
+         * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
+         * Without this function materials are not displayed in the first frame (but displayed after).
+         * In consequence it is impossible to get material information in your HTML file
+         *
+         * @param url The URL of the MTL file
+         * @param rootUrl
+         * @param onSuccess Callback function to be called when the MTL file is loaded
+         * @private
+         */
+        OBJFileLoader.prototype._loadMTL = function (url, rootUrl, onSuccess) {
+            //The complete path to the mtl file
+            var pathOfFile = BABYLON.Tools.BaseUrl + rootUrl + url;
+            // Loads through the babylon tools to allow fileInput search.
+            BABYLON.Tools.LoadFile(pathOfFile, onSuccess, undefined, undefined, false, function () { console.warn("Error - Unable to load " + pathOfFile); });
+        };
+        OBJFileLoader.prototype.importMesh = function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons) {
+            //get the meshes from OBJ file
+            var loadedMeshes = this._parseSolid(meshesNames, scene, data, rootUrl);
+            //Push meshes from OBJ file into the variable mesh of this function
+            if (meshes) {
+                loadedMeshes.forEach(function (mesh) {
+                    meshes.push(mesh);
+                });
+            }
+            return true;
+        };
+        OBJFileLoader.prototype.load = function (scene, data, rootUrl) {
+            //Get the 3D model
+            return this.importMesh(null, scene, data, rootUrl, null, null, null);
+        };
+        OBJFileLoader.prototype.loadAssetContainer = function (scene, data, rootUrl, onError) {
+            var container = new BABYLON.AssetContainer(scene);
+            this.importMesh(null, scene, data, rootUrl, container.meshes, null, null);
+            container.removeAllFromScene();
+            return container;
+        };
+        /**
+         * Read the OBJ file and create an Array of meshes.
+         * Each mesh contains all information given by the OBJ and the MTL file.
+         * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
+         *
+         * @param meshesNames
+         * @param scene BABYLON.Scene The scene where are displayed the data
+         * @param data String The content of the obj file
+         * @param rootUrl String The path to the folder
+         * @returns Array<AbstractMesh>
+         * @private
+         */
+        OBJFileLoader.prototype._parseSolid = function (meshesNames, scene, data, rootUrl) {
+            var positions = []; //values for the positions of vertices
+            var normals = []; //Values for the normals
+            var uvs = []; //Values for the textures
+            var meshesFromObj = []; //[mesh] Contains all the obj meshes
+            var handledMesh; //The current mesh of meshes array
+            var indicesForBabylon = []; //The list of indices for VertexData
+            var wrappedPositionForBabylon = []; //The list of position in vectors
+            var wrappedUvsForBabylon = []; //Array with all value of uvs to match with the indices
+            var wrappedNormalsForBabylon = []; //Array with all value of normals to match with the indices
+            var tuplePosNorm = []; //Create a tuple with indice of Position, Normal, UV  [pos, norm, uvs]
+            var curPositionInIndices = 0;
+            var hasMeshes = false; //Meshes are defined in the file
+            var unwrappedPositionsForBabylon = []; //Value of positionForBabylon w/o Vector3() [x,y,z]
+            var unwrappedNormalsForBabylon = []; //Value of normalsForBabylon w/o Vector3()  [x,y,z]
+            var unwrappedUVForBabylon = []; //Value of uvsForBabylon w/o Vector3()      [x,y,z]
+            var triangles = []; //Indices from new triangles coming from polygons
+            var materialNameFromObj = ""; //The name of the current material
+            var fileToLoad = ""; //The name of the mtlFile to load
+            var materialsFromMTLFile = new MTLFileLoader();
+            var objMeshName = ""; //The name of the current obj mesh
+            var increment = 1; //Id for meshes created by the multimaterial
+            var isFirstMaterial = true;
+            /**
+             * Search for obj in the given array.
+             * This function is called to check if a couple of data already exists in an array.
+             *
+             * If found, returns the index of the founded tuple index. Returns -1 if not found
+             * @param arr Array<{ normals: Array<number>, idx: Array<number> }>
+             * @param obj Array<number>
+             * @returns {boolean}
+             */
+            var isInArray = function (arr, obj) {
+                if (!arr[obj[0]])
+                    arr[obj[0]] = { normals: [], idx: [] };
+                var idx = arr[obj[0]].normals.indexOf(obj[1]);
+                return idx === -1 ? -1 : arr[obj[0]].idx[idx];
+            };
+            var isInArrayUV = function (arr, obj) {
+                if (!arr[obj[0]])
+                    arr[obj[0]] = { normals: [], idx: [], uv: [] };
+                var idx = arr[obj[0]].normals.indexOf(obj[1]);
+                if (idx != 1 && (obj[2] == arr[obj[0]].uv[idx])) {
+                    return arr[obj[0]].idx[idx];
+                }
+                return -1;
+            };
+            /**
+             * This function set the data for each triangle.
+             * Data are position, normals and uvs
+             * If a tuple of (position, normal) is not set, add the data into the corresponding array
+             * If the tuple already exist, add only their indice
+             *
+             * @param indicePositionFromObj Integer The index in positions array
+             * @param indiceUvsFromObj Integer The index in uvs array
+             * @param indiceNormalFromObj Integer The index in normals array
+             * @param positionVectorFromOBJ Vector3 The value of position at index objIndice
+             * @param textureVectorFromOBJ Vector3 The value of uvs
+             * @param normalsVectorFromOBJ Vector3 The value of normals at index objNormale
+             */
+            var setData = function (indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positionVectorFromOBJ, textureVectorFromOBJ, normalsVectorFromOBJ) {
+                //Check if this tuple already exists in the list of tuples
+                var _index;
+                if (OBJFileLoader.OPTIMIZE_WITH_UV) {
+                    _index = isInArrayUV(tuplePosNorm, [
+                        indicePositionFromObj,
+                        indiceNormalFromObj,
+                        indiceUvsFromObj
+                    ]);
+                }
+                else {
+                    _index = isInArray(tuplePosNorm, [
+                        indicePositionFromObj,
+                        indiceNormalFromObj
+                    ]);
+                }
+                //If it not exists
+                if (_index == -1) {
+                    //Add an new indice.
+                    //The array of indices is only an array with his length equal to the number of triangles - 1.
+                    //We add vertices data in this order
+                    indicesForBabylon.push(wrappedPositionForBabylon.length);
+                    //Push the position of vertice for Babylon
+                    //Each element is a BABYLON.Vector3(x,y,z)
+                    wrappedPositionForBabylon.push(positionVectorFromOBJ);
+                    //Push the uvs for Babylon
+                    //Each element is a BABYLON.Vector3(u,v)
+                    wrappedUvsForBabylon.push(textureVectorFromOBJ);
+                    //Push the normals for Babylon
+                    //Each element is a BABYLON.Vector3(x,y,z)
+                    wrappedNormalsForBabylon.push(normalsVectorFromOBJ);
+                    //Add the tuple in the comparison list
+                    tuplePosNorm[indicePositionFromObj].normals.push(indiceNormalFromObj);
+                    tuplePosNorm[indicePositionFromObj].idx.push(curPositionInIndices++);
+                    if (OBJFileLoader.OPTIMIZE_WITH_UV)
+                        tuplePosNorm[indicePositionFromObj].uv.push(indiceUvsFromObj);
+                }
+                else {
+                    //The tuple already exists
+                    //Add the index of the already existing tuple
+                    //At this index we can get the value of position, normal and uvs of vertex
+                    indicesForBabylon.push(_index);
+                }
+            };
+            /**
+             * Transform BABYLON.Vector() object onto 3 digits in an array
+             */
+            var unwrapData = function () {
+                //Every array has the same length
+                for (var l = 0; l < wrappedPositionForBabylon.length; l++) {
+                    //Push the x, y, z values of each element in the unwrapped array
+                    unwrappedPositionsForBabylon.push(wrappedPositionForBabylon[l].x, wrappedPositionForBabylon[l].y, wrappedPositionForBabylon[l].z);
+                    unwrappedNormalsForBabylon.push(wrappedNormalsForBabylon[l].x, wrappedNormalsForBabylon[l].y, wrappedNormalsForBabylon[l].z);
+                    unwrappedUVForBabylon.push(wrappedUvsForBabylon[l].x, wrappedUvsForBabylon[l].y); //z is an optional value not supported by BABYLON
+                }
+                // Reset arrays for the next new meshes
+                wrappedPositionForBabylon = [];
+                wrappedNormalsForBabylon = [];
+                wrappedUvsForBabylon = [];
+                tuplePosNorm = [];
+                curPositionInIndices = 0;
+            };
+            /**
+             * Create triangles from polygons by recursion
+             * The best to understand how it works is to draw it in the same time you get the recursion.
+             * It is important to notice that a triangle is a polygon
+             * We get 4 patterns of face defined in OBJ File :
+             * facePattern1 = ["1","2","3","4","5","6"]
+             * facePattern2 = ["1/1","2/2","3/3","4/4","5/5","6/6"]
+             * facePattern3 = ["1/1/1","2/2/2","3/3/3","4/4/4","5/5/5","6/6/6"]
+             * facePattern4 = ["1//1","2//2","3//3","4//4","5//5","6//6"]
+             * Each pattern is divided by the same method
+             * @param face Array[String] The indices of elements
+             * @param v Integer The variable to increment
+             */
+            var getTriangles = function (face, v) {
+                //Work for each element of the array
+                if (v + 1 < face.length) {
+                    //Add on the triangle variable the indexes to obtain triangles
+                    triangles.push(face[0], face[v], face[v + 1]);
+                    //Incrementation for recursion
+                    v += 1;
+                    //Recursion
+                    getTriangles(face, v);
+                }
+                //Result obtained after 2 iterations:
+                //Pattern1 => triangle = ["1","2","3","1","3","4"];
+                //Pattern2 => triangle = ["1/1","2/2","3/3","1/1","3/3","4/4"];
+                //Pattern3 => triangle = ["1/1/1","2/2/2","3/3/3","1/1/1","3/3/3","4/4/4"];
+                //Pattern4 => triangle = ["1//1","2//2","3//3","1//1","3//3","4//4"];
+            };
+            /**
+             * Create triangles and push the data for each polygon for the pattern 1
+             * In this pattern we get vertice positions
+             * @param face
+             * @param v
+             */
+            var setDataForCurrentFaceWithPattern1 = function (face, v) {
+                //Get the indices of triangles for each polygon
+                getTriangles(face, v);
+                //For each element in the triangles array.
+                //This var could contains 1 to an infinity of triangles
+                for (var k = 0; k < triangles.length; k++) {
+                    // Set position indice
+                    var indicePositionFromObj = parseInt(triangles[k]) - 1;
+                    setData(indicePositionFromObj, 0, 0, //In the pattern 1, normals and uvs are not defined
+                    positions[indicePositionFromObj], //Get the vectors data
+                    BABYLON.Vector2.Zero(), BABYLON.Vector3.Up() //Create default vectors
+                    );
+                }
+                //Reset variable for the next line
+                triangles = [];
+            };
+            /**
+             * Create triangles and push the data for each polygon for the pattern 2
+             * In this pattern we get vertice positions and uvsu
+             * @param face
+             * @param v
+             */
+            var setDataForCurrentFaceWithPattern2 = function (face, v) {
+                //Get the indices of triangles for each polygon
+                getTriangles(face, v);
+                for (var k = 0; k < triangles.length; k++) {
+                    //triangle[k] = "1/1"
+                    //Split the data for getting position and uv
+                    var point = triangles[k].split("/"); // ["1", "1"]
+                    //Set position indice
+                    var indicePositionFromObj = parseInt(point[0]) - 1;
+                    //Set uv indice
+                    var indiceUvsFromObj = parseInt(point[1]) - 1;
+                    setData(indicePositionFromObj, indiceUvsFromObj, 0, //Default value for normals
+                    positions[indicePositionFromObj], //Get the values for each element
+                    uvs[indiceUvsFromObj], BABYLON.Vector3.Up() //Default value for normals
+                    );
+                }
+                //Reset variable for the next line
+                triangles = [];
+            };
+            /**
+             * Create triangles and push the data for each polygon for the pattern 3
+             * In this pattern we get vertice positions, uvs and normals
+             * @param face
+             * @param v
+             */
+            var setDataForCurrentFaceWithPattern3 = function (face, v) {
+                //Get the indices of triangles for each polygon
+                getTriangles(face, v);
+                for (var k = 0; k < triangles.length; k++) {
+                    //triangle[k] = "1/1/1"
+                    //Split the data for getting position, uv, and normals
+                    var point = triangles[k].split("/"); // ["1", "1", "1"]
+                    // Set position indice
+                    var indicePositionFromObj = parseInt(point[0]) - 1;
+                    // Set uv indice
+                    var indiceUvsFromObj = parseInt(point[1]) - 1;
+                    // Set normal indice
+                    var indiceNormalFromObj = parseInt(point[2]) - 1;
+                    setData(indicePositionFromObj, indiceUvsFromObj, indiceNormalFromObj, positions[indicePositionFromObj], uvs[indiceUvsFromObj], normals[indiceNormalFromObj] //Set the vector for each component
+                    );
+                }
+                //Reset variable for the next line
+                triangles = [];
+            };
+            /**
+             * Create triangles and push the data for each polygon for the pattern 4
+             * In this pattern we get vertice positions and normals
+             * @param face
+             * @param v
+             */
+            var setDataForCurrentFaceWithPattern4 = function (face, v) {
+                getTriangles(face, v);
+                for (var k = 0; k < triangles.length; k++) {
+                    //triangle[k] = "1//1"
+                    //Split the data for getting position and normals
+                    var point = triangles[k].split("//"); // ["1", "1"]
+                    // We check indices, and normals
+                    var indicePositionFromObj = parseInt(point[0]) - 1;
+                    var indiceNormalFromObj = parseInt(point[1]) - 1;
+                    setData(indicePositionFromObj, 1, //Default value for uv
+                    indiceNormalFromObj, positions[indicePositionFromObj], //Get each vector of data
+                    BABYLON.Vector2.Zero(), normals[indiceNormalFromObj]);
+                }
+                //Reset variable for the next line
+                triangles = [];
+            };
+            var addPreviousObjMesh = function () {
+                //Check if it is not the first mesh. Otherwise we don't have data.
+                if (meshesFromObj.length > 0) {
+                    //Get the previous mesh for applying the data about the faces
+                    //=> in obj file, faces definition append after the name of the mesh
+                    handledMesh = meshesFromObj[meshesFromObj.length - 1];
+                    //Set the data into Array for the mesh
+                    unwrapData();
+                    // Reverse tab. Otherwise face are displayed in the wrong sens
+                    indicesForBabylon.reverse();
+                    //Set the information for the mesh
+                    //Slice the array to avoid rewriting because of the fact this is the same var which be rewrited
+                    handledMesh.indices = indicesForBabylon.slice();
+                    handledMesh.positions = unwrappedPositionsForBabylon.slice();
+                    handledMesh.normals = unwrappedNormalsForBabylon.slice();
+                    handledMesh.uvs = unwrappedUVForBabylon.slice();
+                    //Reset the array for the next mesh
+                    indicesForBabylon = [];
+                    unwrappedPositionsForBabylon = [];
+                    unwrappedNormalsForBabylon = [];
+                    unwrappedUVForBabylon = [];
+                }
+            };
+            //Main function
+            //Split the file into lines
+            var lines = data.split('\n');
+            //Look at each line
+            for (var i = 0; i < lines.length; i++) {
+                var line = lines[i].trim();
+                var result;
+                //Comment or newLine
+                if (line.length === 0 || line.charAt(0) === '#') {
+                    continue;
+                    //Get information about one position possible for the vertices
+                }
+                else if ((result = this.vertexPattern.exec(line)) !== null) {
+                    //Create a Vector3 with the position x, y, z
+                    //Value of result:
+                    // ["v 1.0 2.0 3.0", "1.0", "2.0", "3.0"]
+                    //Add the Vector in the list of positions
+                    positions.push(new BABYLON.Vector3(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3])));
+                }
+                else if ((result = this.normalPattern.exec(line)) !== null) {
+                    //Create a Vector3 with the normals x, y, z
+                    //Value of result
+                    // ["vn 1.0 2.0 3.0", "1.0", "2.0", "3.0"]
+                    //Add the Vector in the list of normals
+                    normals.push(new BABYLON.Vector3(parseFloat(result[1]), parseFloat(result[2]), parseFloat(result[3])));
+                }
+                else if ((result = this.uvPattern.exec(line)) !== null) {
+                    //Create a Vector2 with the normals u, v
+                    //Value of result
+                    // ["vt 0.1 0.2 0.3", "0.1", "0.2"]
+                    //Add the Vector in the list of uvs
+                    uvs.push(new BABYLON.Vector2(parseFloat(result[1]), parseFloat(result[2])));
+                    //Identify patterns of faces
+                    //Face could be defined in different type of pattern
+                }
+                else if ((result = this.facePattern3.exec(line)) !== null) {
+                    //Value of result:
+                    //["f 1/1/1 2/2/2 3/3/3", "1/1/1 2/2/2 3/3/3"...]
+                    //Set the data for this face
+                    setDataForCurrentFaceWithPattern3(result[1].trim().split(" "), // ["1/1/1", "2/2/2", "3/3/3"]
+                    1);
+                }
+                else if ((result = this.facePattern4.exec(line)) !== null) {
+                    //Value of result:
+                    //["f 1//1 2//2 3//3", "1//1 2//2 3//3"...]
+                    //Set the data for this face
+                    setDataForCurrentFaceWithPattern4(result[1].trim().split(" "), // ["1//1", "2//2", "3//3"]
+                    1);
+                }
+                else if ((result = this.facePattern2.exec(line)) !== null) {
+                    //Value of result:
+                    //["f 1/1 2/2 3/3", "1/1 2/2 3/3"...]
+                    //Set the data for this face
+                    setDataForCurrentFaceWithPattern2(result[1].trim().split(" "), // ["1/1", "2/2", "3/3"]
+                    1);
+                }
+                else if ((result = this.facePattern1.exec(line)) !== null) {
+                    //Value of result
+                    //["f 1 2 3", "1 2 3"...]
+                    //Set the data for this face
+                    setDataForCurrentFaceWithPattern1(result[1].trim().split(" "), // ["1", "2", "3"]
+                    1);
+                    //Define a mesh or an object
+                    //Each time this keyword is analysed, create a new Object with all data for creating a babylonMesh
+                }
+                else if (this.group.test(line) || this.obj.test(line)) {
+                    //Create a new mesh corresponding to the name of the group.
+                    //Definition of the mesh
+                    var objMesh = 
+                    //Set the name of the current obj mesh
+                    {
+                        name: line.substring(2).trim(),
+                        indices: undefined,
+                        positions: undefined,
+                        normals: undefined,
+                        uvs: undefined,
+                        materialName: ""
+                    };
+                    addPreviousObjMesh();
+                    //Push the last mesh created with only the name
+                    meshesFromObj.push(objMesh);
+                    //Set this variable to indicate that now meshesFromObj has objects defined inside
+                    hasMeshes = true;
+                    isFirstMaterial = true;
+                    increment = 1;
+                    //Keyword for applying a material
+                }
+                else if (this.usemtl.test(line)) {
+                    //Get the name of the material
+                    materialNameFromObj = line.substring(7).trim();
+                    //If this new material is in the same mesh
+                    if (!isFirstMaterial) {
+                        //Set the data for the previous mesh
+                        addPreviousObjMesh();
+                        //Create a new mesh
+                        var objMesh = 
+                        //Set the name of the current obj mesh
+                        {
+                            name: objMeshName + "_mm" + increment.toString(),
+                            indices: undefined,
+                            positions: undefined,
+                            normals: undefined,
+                            uvs: undefined,
+                            materialName: materialNameFromObj
+                        };
+                        increment++;
+                        //If meshes are already defined
+                        meshesFromObj.push(objMesh);
+                    }
+                    //Set the material name if the previous line define a mesh
+                    if (hasMeshes && isFirstMaterial) {
+                        //Set the material name to the previous mesh (1 material per mesh)
+                        meshesFromObj[meshesFromObj.length - 1].materialName = materialNameFromObj;
+                        isFirstMaterial = false;
+                    }
+                    //Keyword for loading the mtl file
+                }
+                else if (this.mtllib.test(line)) {
+                    //Get the name of mtl file
+                    fileToLoad = line.substring(7).trim();
+                    //Apply smoothing
+                }
+                else if (this.smooth.test(line)) {
+                    // smooth shading => apply smoothing
+                    //Toda  y I don't know it work with babylon and with obj.
+                    //With the obj file  an integer is set
+                }
+                else {
+                    //If there is another possibility
+                    console.log("Unhandled expression at line : " + line);
+                }
+            }
+            //At the end of the file, add the last mesh into the meshesFromObj array
+            if (hasMeshes) {
+                //Set the data for the last mesh
+                handledMesh = meshesFromObj[meshesFromObj.length - 1];
+                //Reverse indices for displaying faces in the good sens
+                indicesForBabylon.reverse();
+                //Get the good array
+                unwrapData();
+                //Set array
+                handledMesh.indices = indicesForBabylon;
+                handledMesh.positions = unwrappedPositionsForBabylon;
+                handledMesh.normals = unwrappedNormalsForBabylon;
+                handledMesh.uvs = unwrappedUVForBabylon;
+            }
+            //If any o or g keyword found, create a mesj with a random id
+            if (!hasMeshes) {
+                // reverse tab of indices
+                indicesForBabylon.reverse();
+                //Get positions normals uvs
+                unwrapData();
+                //Set data for one mesh
+                meshesFromObj.push({
+                    name: BABYLON.Geometry.RandomId(),
+                    indices: indicesForBabylon,
+                    positions: unwrappedPositionsForBabylon,
+                    normals: unwrappedNormalsForBabylon,
+                    uvs: unwrappedUVForBabylon,
+                    materialName: materialNameFromObj
+                });
+            }
+            //Create a BABYLON.Mesh list
+            var babylonMeshesArray = []; //The mesh for babylon
+            var materialToUse = new Array();
+            //Set data for each mesh
+            for (var j = 0; j < meshesFromObj.length; j++) {
+                //check meshesNames (stlFileLoader)
+                if (meshesNames && meshesFromObj[j].name) {
+                    if (meshesNames instanceof Array) {
+                        if (meshesNames.indexOf(meshesFromObj[j].name) == -1) {
+                            continue;
+                        }
+                    }
+                    else {
+                        if (meshesFromObj[j].name !== meshesNames) {
+                            continue;
+                        }
+                    }
+                }
+                //Get the current mesh
+                //Set the data with VertexBuffer for each mesh
+                handledMesh = meshesFromObj[j];
+                //Create a BABYLON.Mesh with the name of the obj mesh
+                var babylonMesh = new BABYLON.Mesh(meshesFromObj[j].name, scene);
+                //Push the name of the material to an array
+                //This is indispensable for the importMesh function
+                materialToUse.push(meshesFromObj[j].materialName);
+                var vertexData = new BABYLON.VertexData(); //The container for the values
+                //Set the data for the babylonMesh
+                vertexData.positions = handledMesh.positions;
+                vertexData.normals = handledMesh.normals;
+                vertexData.uvs = handledMesh.uvs;
+                vertexData.indices = handledMesh.indices;
+                //Set the data from the VertexBuffer to the current BABYLON.Mesh
+                vertexData.applyToMesh(babylonMesh);
+                if (OBJFileLoader.INVERT_Y) {
+                    babylonMesh.scaling.y *= -1;
+                }
+                //Push the mesh into an array
+                babylonMeshesArray.push(babylonMesh);
+            }
+            //load the materials
+            //Check if we have a file to load
+            if (fileToLoad !== "") {
+                //Load the file synchronously
+                this._loadMTL(fileToLoad, rootUrl, function (dataLoaded) {
+                    //Create materials thanks MTLLoader function
+                    materialsFromMTLFile.parseMTL(scene, dataLoaded, rootUrl);
+                    //Look at each material loaded in the mtl file
+                    for (var n = 0; n < materialsFromMTLFile.materials.length; n++) {
+                        //Three variables to get all meshes with the same material
+                        var startIndex = 0;
+                        var _indices = [];
+                        var _index;
+                        //The material from MTL file is used in the meshes loaded
+                        //Push the indice in an array
+                        //Check if the material is not used for another mesh
+                        while ((_index = materialToUse.indexOf(materialsFromMTLFile.materials[n].name, startIndex)) > -1) {
+                            _indices.push(_index);
+                            startIndex = _index + 1;
+                        }
+                        //If the material is not used dispose it
+                        if (_index == -1 && _indices.length == 0) {
+                            //If the material is not needed, remove it
+                            materialsFromMTLFile.materials[n].dispose();
+                        }
+                        else {
+                            for (var o = 0; o < _indices.length; o++) {
+                                //Apply the material to the BABYLON.Mesh for each mesh with the material
+                                babylonMeshesArray[_indices[o]].material = materialsFromMTLFile.materials[n];
+                            }
+                        }
+                    }
+                });
+            }
+            //Return an array with all BABYLON.Mesh
+            return babylonMeshesArray;
+        };
+        OBJFileLoader.OPTIMIZE_WITH_UV = false;
+        OBJFileLoader.INVERT_Y = false;
+        return OBJFileLoader;
+    }());
+    BABYLON.OBJFileLoader = OBJFileLoader;
+    if (BABYLON.SceneLoader) {
+        //Add this loader into the register plugin
+        BABYLON.SceneLoader.RegisterPlugin(new OBJFileLoader());
+    }
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=babylon.objFileLoader.js.map

Plik diff jest za duży
+ 1 - 0
dist/preview release/loaders/babylon.objFileLoader.min.js


+ 17 - 0
dist/preview release/loaders/babylon.stlFileLoader.d.ts

@@ -0,0 +1,17 @@
+
+declare module BABYLON {
+    class STLFileLoader implements ISceneLoaderPlugin {
+        solidPattern: RegExp;
+        facetsPattern: RegExp;
+        normalPattern: RegExp;
+        vertexPattern: RegExp;
+        name: string;
+        extensions: ISceneLoaderPluginExtensions;
+        importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<ParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
+        load(scene: Scene, data: any, rootUrl: string): boolean;
+        loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
+        private isBinary(data);
+        private parseBinary(mesh, data);
+        private parseASCII(mesh, solidData);
+    }
+}

+ 170 - 0
dist/preview release/loaders/babylon.stlFileLoader.js

@@ -0,0 +1,170 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
+var BABYLON;
+(function (BABYLON) {
+    var STLFileLoader = /** @class */ (function () {
+        function STLFileLoader() {
+            this.solidPattern = /solid (\S*)([\S\s]*)endsolid[ ]*(\S*)/g;
+            this.facetsPattern = /facet([\s\S]*?)endfacet/g;
+            this.normalPattern = /normal[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g;
+            this.vertexPattern = /vertex[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g;
+            this.name = "stl";
+            // force data to come in as an ArrayBuffer
+            // we'll convert to string if it looks like it's an ASCII .stl
+            this.extensions = {
+                ".stl": { isBinary: true },
+            };
+        }
+        STLFileLoader.prototype.importMesh = function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons) {
+            var matches;
+            if (this.isBinary(data)) {
+                // binary .stl
+                var babylonMesh = new BABYLON.Mesh("stlmesh", scene);
+                this.parseBinary(babylonMesh, data);
+                if (meshes) {
+                    meshes.push(babylonMesh);
+                }
+                return true;
+            }
+            // ASCII .stl
+            // convert to string
+            var array_buffer = new Uint8Array(data);
+            var str = '';
+            for (var i = 0; i < data.byteLength; i++) {
+                str += String.fromCharCode(array_buffer[i]); // implicitly assumes little-endian
+            }
+            data = str;
+            while (matches = this.solidPattern.exec(data)) {
+                var meshName = matches[1];
+                var meshNameFromEnd = matches[3];
+                if (meshName != meshNameFromEnd) {
+                    BABYLON.Tools.Error("Error in STL, solid name != endsolid name");
+                    return false;
+                }
+                // check meshesNames
+                if (meshesNames && meshName) {
+                    if (meshesNames instanceof Array) {
+                        if (!meshesNames.indexOf(meshName)) {
+                            continue;
+                        }
+                    }
+                    else {
+                        if (meshName !== meshesNames) {
+                            continue;
+                        }
+                    }
+                }
+                // stl mesh name can be empty as well
+                meshName = meshName || "stlmesh";
+                var babylonMesh = new BABYLON.Mesh(meshName, scene);
+                this.parseASCII(babylonMesh, matches[2]);
+                if (meshes) {
+                    meshes.push(babylonMesh);
+                }
+            }
+            return true;
+        };
+        STLFileLoader.prototype.load = function (scene, data, rootUrl) {
+            var result = this.importMesh(null, scene, data, rootUrl, null, null, null);
+            if (result) {
+                scene.createDefaultCameraOrLight();
+            }
+            return result;
+        };
+        STLFileLoader.prototype.loadAssetContainer = function (scene, data, rootUrl, onError) {
+            var container = new BABYLON.AssetContainer(scene);
+            this.importMesh(null, scene, data, rootUrl, container.meshes, null, null);
+            container.removeAllFromScene();
+            return container;
+        };
+        STLFileLoader.prototype.isBinary = function (data) {
+            // check if file size is correct for binary stl
+            var faceSize, nFaces, reader;
+            reader = new DataView(data);
+            faceSize = (32 / 8 * 3) + ((32 / 8 * 3) * 3) + (16 / 8);
+            nFaces = reader.getUint32(80, true);
+            if (80 + (32 / 8) + (nFaces * faceSize) === reader.byteLength) {
+                return true;
+            }
+            // check characters higher than ASCII to confirm binary
+            var fileLength = reader.byteLength;
+            for (var index = 0; index < fileLength; index++) {
+                if (reader.getUint8(index) > 127) {
+                    return true;
+                }
+            }
+            return false;
+        };
+        STLFileLoader.prototype.parseBinary = function (mesh, data) {
+            var reader = new DataView(data);
+            var faces = reader.getUint32(80, true);
+            var dataOffset = 84;
+            var faceLength = 12 * 4 + 2;
+            var offset = 0;
+            var positions = new Float32Array(faces * 3 * 3);
+            var normals = new Float32Array(faces * 3 * 3);
+            var indices = new Uint32Array(faces * 3);
+            var indicesCount = 0;
+            for (var face = 0; face < faces; face++) {
+                var start = dataOffset + face * faceLength;
+                var normalX = reader.getFloat32(start, true);
+                var normalY = reader.getFloat32(start + 4, true);
+                var normalZ = reader.getFloat32(start + 8, true);
+                for (var i = 1; i <= 3; i++) {
+                    var vertexstart = start + i * 12;
+                    // ordering is intentional to match ascii import
+                    positions[offset] = reader.getFloat32(vertexstart, true);
+                    positions[offset + 2] = reader.getFloat32(vertexstart + 4, true);
+                    positions[offset + 1] = reader.getFloat32(vertexstart + 8, true);
+                    normals[offset] = normalX;
+                    normals[offset + 2] = normalY;
+                    normals[offset + 1] = normalZ;
+                    offset += 3;
+                }
+                indices[indicesCount] = indicesCount++;
+                indices[indicesCount] = indicesCount++;
+                indices[indicesCount] = indicesCount++;
+            }
+            mesh.setVerticesData(BABYLON.VertexBuffer.PositionKind, positions);
+            mesh.setVerticesData(BABYLON.VertexBuffer.NormalKind, normals);
+            mesh.setIndices(indices);
+            mesh.computeWorldMatrix(true);
+        };
+        STLFileLoader.prototype.parseASCII = function (mesh, solidData) {
+            var positions = [];
+            var normals = [];
+            var indices = [];
+            var indicesCount = 0;
+            //load facets, ignoring loop as the standard doesn't define it can contain more than vertices
+            var matches;
+            while (matches = this.facetsPattern.exec(solidData)) {
+                var facet = matches[1];
+                //one normal per face
+                var normalMatches = this.normalPattern.exec(facet);
+                this.normalPattern.lastIndex = 0;
+                if (!normalMatches) {
+                    continue;
+                }
+                var normal = [Number(normalMatches[1]), Number(normalMatches[5]), Number(normalMatches[3])];
+                var vertexMatch;
+                while (vertexMatch = this.vertexPattern.exec(facet)) {
+                    positions.push(Number(vertexMatch[1]), Number(vertexMatch[5]), Number(vertexMatch[3]));
+                    normals.push(normal[0], normal[1], normal[2]);
+                }
+                indices.push(indicesCount++, indicesCount++, indicesCount++);
+                this.vertexPattern.lastIndex = 0;
+            }
+            this.facetsPattern.lastIndex = 0;
+            mesh.setVerticesData(BABYLON.VertexBuffer.PositionKind, positions);
+            mesh.setVerticesData(BABYLON.VertexBuffer.NormalKind, normals);
+            mesh.setIndices(indices);
+            mesh.computeWorldMatrix(true);
+        };
+        return STLFileLoader;
+    }());
+    BABYLON.STLFileLoader = STLFileLoader;
+    if (BABYLON.SceneLoader) {
+        BABYLON.SceneLoader.RegisterPlugin(new STLFileLoader());
+    }
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=babylon.stlFileLoader.js.map

Plik diff jest za duży
+ 1 - 0
dist/preview release/loaders/babylon.stlFileLoader.min.js


+ 29 - 0
dist/preview release/materialsLibrary/babylon.cellMaterial.d.ts

@@ -0,0 +1,29 @@
+
+declare module BABYLON {
+    class CellMaterial extends PushMaterial {
+        private _diffuseTexture;
+        diffuseTexture: BaseTexture;
+        diffuseColor: Color3;
+        _computeHighLevel: boolean;
+        computeHighLevel: boolean;
+        private _disableLighting;
+        disableLighting: boolean;
+        private _maxSimultaneousLights;
+        maxSimultaneousLights: number;
+        private _renderId;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): Nullable<BaseTexture>;
+        isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
+        bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
+        getAnimatables(): IAnimatable[];
+        getActiveTextures(): BaseTexture[];
+        hasTexture(texture: BaseTexture): boolean;
+        dispose(forceDisposeEffect?: boolean): void;
+        getClassName(): string;
+        clone(name: string): CellMaterial;
+        serialize(): any;
+        static Parse(source: any, scene: Scene, rootUrl: string): CellMaterial;
+    }
+}

Plik diff jest za duży
+ 294 - 0
dist/preview release/materialsLibrary/babylon.cellMaterial.js


+ 50 - 0
dist/preview release/materialsLibrary/babylon.customMaterial.d.ts

@@ -0,0 +1,50 @@
+
+declare module BABYLON {
+    class CustomShaderStructure {
+        FragmentStore: string;
+        VertexStore: string;
+        constructor();
+    }
+    class ShaderSpecialParts {
+        constructor();
+        Fragment_Begin: string;
+        Fragment_Definitions: string;
+        Fragment_MainBegin: string;
+        Fragment_Custom_Diffuse: string;
+        Fragment_Custom_Alpha: string;
+        Fragment_Before_FragColor: string;
+        Vertex_Begin: string;
+        Vertex_Definitions: string;
+        Vertex_MainBegin: string;
+        Vertex_Before_PositionUpdated: string;
+        Vertex_Before_NormalUpdated: string;
+    }
+    class CustomMaterial extends StandardMaterial {
+        static ShaderIndexer: number;
+        CustomParts: ShaderSpecialParts;
+        _isCreatedShader: boolean;
+        _createdShaderName: string;
+        _customUniform: string[];
+        _newUniforms: string[];
+        _newUniformInstances: any[];
+        _newSamplerInstances: Texture[];
+        FragmentShader: string;
+        VertexShader: string;
+        AttachAfterBind(mesh: Mesh, effect: Effect): void;
+        ReviewUniform(name: string, arr: string[]): string[];
+        Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines): string;
+        constructor(name: string, scene: Scene);
+        AddUniform(name: string, kind: string, param: any): CustomMaterial;
+        Fragment_Begin(shaderPart: string): CustomMaterial;
+        Fragment_Definitions(shaderPart: string): CustomMaterial;
+        Fragment_MainBegin(shaderPart: string): CustomMaterial;
+        Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
+        Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
+        Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
+        Vertex_Begin(shaderPart: string): CustomMaterial;
+        Vertex_Definitions(shaderPart: string): CustomMaterial;
+        Vertex_MainBegin(shaderPart: string): CustomMaterial;
+        Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
+        Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
+    }
+}

+ 189 - 0
dist/preview release/materialsLibrary/babylon.customMaterial.js

@@ -0,0 +1,189 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
+var __extends = (this && this.__extends) || (function () {
+    var extendStatics = Object.setPrototypeOf ||
+        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
+        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
+    return function (d, b) {
+        extendStatics(d, b);
+        function __() { this.constructor = d; }
+        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
+    };
+})();
+var BABYLON;
+(function (BABYLON) {
+    var CustomShaderStructure = /** @class */ (function () {
+        function CustomShaderStructure() {
+        }
+        return CustomShaderStructure;
+    }());
+    BABYLON.CustomShaderStructure = CustomShaderStructure;
+    var ShaderSpecialParts = /** @class */ (function () {
+        function ShaderSpecialParts() {
+        }
+        return ShaderSpecialParts;
+    }());
+    BABYLON.ShaderSpecialParts = ShaderSpecialParts;
+    var CustomMaterial = /** @class */ (function (_super) {
+        __extends(CustomMaterial, _super);
+        function CustomMaterial(name, scene) {
+            var _this = _super.call(this, name, scene) || this;
+            _this.CustomParts = new ShaderSpecialParts();
+            _this.customShaderNameResolve = _this.Builder;
+            _this.FragmentShader = BABYLON.Effect.ShadersStore["defaultPixelShader"];
+            _this.VertexShader = BABYLON.Effect.ShadersStore["defaultVertexShader"];
+            return _this;
+        }
+        CustomMaterial.prototype.AttachAfterBind = function (mesh, effect) {
+            for (var el in this._newUniformInstances) {
+                var ea = el.toString().split('-');
+                if (ea[0] == 'vec2') {
+                    effect.setVector2(ea[1], this._newUniformInstances[el]);
+                }
+                else if (ea[0] == 'vec3') {
+                    effect.setVector3(ea[1], this._newUniformInstances[el]);
+                }
+                else if (ea[0] == 'vec4') {
+                    effect.setVector4(ea[1], this._newUniformInstances[el]);
+                }
+                else if (ea[0] == 'mat4') {
+                    effect.setMatrix(ea[1], this._newUniformInstances[el]);
+                }
+                else if (ea[0] == 'float') {
+                    effect.setFloat(ea[1], this._newUniformInstances[el]);
+                }
+            }
+            for (var el in this._newSamplerInstances) {
+                var ea = el.toString().split('-');
+                if (ea[0] == 'sampler2D' && this._newSamplerInstances[el].isReady && this._newSamplerInstances[el].isReady()) {
+                    effect.setTexture(ea[1], this._newSamplerInstances[el]);
+                }
+            }
+        };
+        CustomMaterial.prototype.ReviewUniform = function (name, arr) {
+            if (name == "uniform") {
+                for (var ind in this._newUniforms) {
+                    if (this._customUniform[ind].indexOf('sampler') == -1) {
+                        arr.push(this._newUniforms[ind]);
+                    }
+                }
+            }
+            if (name == "sampler") {
+                for (var ind in this._newUniforms) {
+                    if (this._customUniform[ind].indexOf('sampler') != -1) {
+                        arr.push(this._newUniforms[ind]);
+                    }
+                }
+            }
+            return arr;
+        };
+        CustomMaterial.prototype.Builder = function (shaderName, uniforms, uniformBuffers, samplers, defines) {
+            var _this = this;
+            if (this._isCreatedShader) {
+                return this._createdShaderName;
+            }
+            this._isCreatedShader = false;
+            CustomMaterial.ShaderIndexer++;
+            var name = "custom_" + CustomMaterial.ShaderIndexer;
+            this.ReviewUniform("uniform", uniforms);
+            this.ReviewUniform("sampler", samplers);
+            var fn_afterBind = this._afterBind.bind(this);
+            this._afterBind = function (m, e) {
+                if (!e) {
+                    return;
+                }
+                _this.AttachAfterBind(m, e);
+                try {
+                    fn_afterBind(m, e);
+                }
+                catch (e) { }
+            };
+            BABYLON.Effect.ShadersStore[name + "VertexShader"] = this.VertexShader
+                .replace('#define CUSTOM_VERTEX_BEGIN', (this.CustomParts.Vertex_Begin ? this.CustomParts.Vertex_Begin : ""))
+                .replace('#define CUSTOM_VERTEX_DEFINITIONS', (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Vertex_Definitions ? this.CustomParts.Vertex_Definitions : ""))
+                .replace('#define CUSTOM_VERTEX_MAIN_BEGIN', (this.CustomParts.Vertex_MainBegin ? this.CustomParts.Vertex_MainBegin : ""))
+                .replace('#define CUSTOM_VERTEX_UPDATE_POSITION', (this.CustomParts.Vertex_Before_PositionUpdated ? this.CustomParts.Vertex_Before_PositionUpdated : ""))
+                .replace('#define CUSTOM_VERTEX_UPDATE_NORMAL', (this.CustomParts.Vertex_Before_NormalUpdated ? this.CustomParts.Vertex_Before_NormalUpdated : ""));
+            // #define CUSTOM_VERTEX_MAIN_END
+            BABYLON.Effect.ShadersStore[name + "PixelShader"] = this.FragmentShader
+                .replace('#define CUSTOM_FRAGMENT_BEGIN', (this.CustomParts.Fragment_Begin ? this.CustomParts.Fragment_Begin : ""))
+                .replace('#define CUSTOM_FRAGMENT_MAIN_BEGIN', (this.CustomParts.Fragment_MainBegin ? this.CustomParts.Fragment_MainBegin : ""))
+                .replace('#define CUSTOM_FRAGMENT_DEFINITIONS', (this._customUniform ? this._customUniform.join("\n") : "") + (this.CustomParts.Fragment_Definitions ? this.CustomParts.Fragment_Definitions : ""))
+                .replace('#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE', (this.CustomParts.Fragment_Custom_Diffuse ? this.CustomParts.Fragment_Custom_Diffuse : ""))
+                .replace('#define CUSTOM_FRAGMENT_UPDATE_ALPHA', (this.CustomParts.Fragment_Custom_Alpha ? this.CustomParts.Fragment_Custom_Alpha : ""))
+                .replace('#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR', (this.CustomParts.Fragment_Before_FragColor ? this.CustomParts.Fragment_Before_FragColor : ""));
+            // #define CUSTOM_FRAGMENT_BEFORE_LIGHTS
+            // #define CUSTOM_FRAGMENT_BEFORE_FOG
+            this._isCreatedShader = true;
+            this._createdShaderName = name;
+            return name;
+        };
+        CustomMaterial.prototype.AddUniform = function (name, kind, param) {
+            if (!this._customUniform) {
+                this._customUniform = new Array();
+                this._newUniforms = new Array();
+                this._newSamplerInstances = new Array();
+                this._newUniformInstances = new Array();
+            }
+            if (param) {
+                if (kind.indexOf("sampler") == -1) {
+                    this._newUniformInstances[kind + "-" + name] = param;
+                }
+                else {
+                    this._newUniformInstances[kind + "-" + name] = param;
+                }
+            }
+            this._customUniform.push("uniform " + kind + " " + name + ";");
+            this._newUniforms.push(name);
+            return this;
+        };
+        CustomMaterial.prototype.Fragment_Begin = function (shaderPart) {
+            this.CustomParts.Fragment_Begin = shaderPart;
+            return this;
+        };
+        CustomMaterial.prototype.Fragment_Definitions = function (shaderPart) {
+            this.CustomParts.Fragment_Definitions = shaderPart;
+            return this;
+        };
+        CustomMaterial.prototype.Fragment_MainBegin = function (shaderPart) {
+            this.CustomParts.Fragment_MainBegin = shaderPart;
+            return this;
+        };
+        CustomMaterial.prototype.Fragment_Custom_Diffuse = function (shaderPart) {
+            this.CustomParts.Fragment_Custom_Diffuse = shaderPart.replace("result", "diffuseColor");
+            return this;
+        };
+        CustomMaterial.prototype.Fragment_Custom_Alpha = function (shaderPart) {
+            this.CustomParts.Fragment_Custom_Alpha = shaderPart.replace("result", "alpha");
+            return this;
+        };
+        CustomMaterial.prototype.Fragment_Before_FragColor = function (shaderPart) {
+            this.CustomParts.Fragment_Before_FragColor = shaderPart.replace("result", "color");
+            return this;
+        };
+        CustomMaterial.prototype.Vertex_Begin = function (shaderPart) {
+            this.CustomParts.Vertex_Begin = shaderPart;
+            return this;
+        };
+        CustomMaterial.prototype.Vertex_Definitions = function (shaderPart) {
+            this.CustomParts.Vertex_Definitions = shaderPart;
+            return this;
+        };
+        CustomMaterial.prototype.Vertex_MainBegin = function (shaderPart) {
+            this.CustomParts.Vertex_MainBegin = shaderPart;
+            return this;
+        };
+        CustomMaterial.prototype.Vertex_Before_PositionUpdated = function (shaderPart) {
+            this.CustomParts.Vertex_Before_PositionUpdated = shaderPart.replace("result", "positionUpdated");
+            return this;
+        };
+        CustomMaterial.prototype.Vertex_Before_NormalUpdated = function (shaderPart) {
+            this.CustomParts.Vertex_Before_NormalUpdated = shaderPart.replace("result", "normalUpdated");
+            return this;
+        };
+        CustomMaterial.ShaderIndexer = 1;
+        return CustomMaterial;
+    }(BABYLON.StandardMaterial));
+    BABYLON.CustomMaterial = CustomMaterial;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=babylon.customMaterial.js.map

Plik diff jest za duży
+ 1 - 0
dist/preview release/materialsLibrary/babylon.customMaterial.min.js


+ 30 - 0
dist/preview release/materialsLibrary/babylon.fireMaterial.d.ts

@@ -0,0 +1,30 @@
+
+declare module BABYLON {
+    class FireMaterial extends PushMaterial {
+        private _diffuseTexture;
+        diffuseTexture: Nullable<BaseTexture>;
+        private _distortionTexture;
+        distortionTexture: Nullable<BaseTexture>;
+        private _opacityTexture;
+        opacityTexture: Nullable<BaseTexture>;
+        diffuseColor: Color3;
+        speed: number;
+        private _scaledDiffuse;
+        private _renderId;
+        private _lastTime;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): Nullable<BaseTexture>;
+        isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
+        bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
+        getAnimatables(): IAnimatable[];
+        getActiveTextures(): BaseTexture[];
+        hasTexture(texture: BaseTexture): boolean;
+        getClassName(): string;
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): FireMaterial;
+        serialize(): any;
+        static Parse(source: any, scene: Scene, rootUrl: string): FireMaterial;
+    }
+}

Plik diff jest za duży
+ 335 - 0
dist/preview release/materialsLibrary/babylon.fireMaterial.js


+ 46 - 0
dist/preview release/materialsLibrary/babylon.furMaterial.d.ts

@@ -0,0 +1,46 @@
+
+declare module BABYLON {
+    class FurMaterial extends PushMaterial {
+        private _diffuseTexture;
+        diffuseTexture: BaseTexture;
+        private _heightTexture;
+        heightTexture: BaseTexture;
+        diffuseColor: Color3;
+        furLength: number;
+        furAngle: number;
+        furColor: Color3;
+        furOffset: number;
+        furSpacing: number;
+        furGravity: Vector3;
+        furSpeed: number;
+        furDensity: number;
+        furOcclusion: number;
+        furTexture: DynamicTexture;
+        private _disableLighting;
+        disableLighting: boolean;
+        private _maxSimultaneousLights;
+        maxSimultaneousLights: number;
+        highLevelFur: boolean;
+        _meshes: AbstractMesh[];
+        private _renderId;
+        private _furTime;
+        constructor(name: string, scene: Scene);
+        furTime: number;
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): Nullable<BaseTexture>;
+        updateFur(): void;
+        isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
+        bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
+        getAnimatables(): IAnimatable[];
+        getActiveTextures(): BaseTexture[];
+        hasTexture(texture: BaseTexture): boolean;
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): FurMaterial;
+        serialize(): any;
+        getClassName(): string;
+        static Parse(source: any, scene: Scene, rootUrl: string): FurMaterial;
+        static GenerateTexture(name: string, scene: Scene): DynamicTexture;
+        static FurifyMesh(sourceMesh: Mesh, quality: number): Mesh[];
+    }
+}

Plik diff jest za duży
+ 480 - 0
dist/preview release/materialsLibrary/babylon.furMaterial.js


+ 28 - 0
dist/preview release/materialsLibrary/babylon.gradientMaterial.d.ts

@@ -0,0 +1,28 @@
+
+declare module BABYLON {
+    class GradientMaterial extends PushMaterial {
+        private _maxSimultaneousLights;
+        maxSimultaneousLights: number;
+        topColor: Color3;
+        topColorAlpha: number;
+        bottomColor: Color3;
+        bottomColorAlpha: number;
+        offset: number;
+        smoothness: number;
+        disableLighting: boolean;
+        private _scaledDiffuse;
+        private _renderId;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): Nullable<BaseTexture>;
+        isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
+        bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
+        getAnimatables(): IAnimatable[];
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): GradientMaterial;
+        serialize(): any;
+        getClassName(): string;
+        static Parse(source: any, scene: Scene, rootUrl: string): GradientMaterial;
+    }
+}

Plik diff jest za duży
+ 299 - 0
dist/preview release/materialsLibrary/babylon.gradientMaterial.js


+ 61 - 0
dist/preview release/materialsLibrary/babylon.gridMaterial.d.ts

@@ -0,0 +1,61 @@
+
+declare module BABYLON {
+    /**
+     * The grid materials allows you to wrap any shape with a grid.
+     * Colors are customizable.
+     */
+    class GridMaterial extends BABYLON.PushMaterial {
+        /**
+         * Main color of the grid (e.g. between lines)
+         */
+        mainColor: Color3;
+        /**
+         * Color of the grid lines.
+         */
+        lineColor: Color3;
+        /**
+         * The scale of the grid compared to unit.
+         */
+        gridRatio: number;
+        /**
+         * Allows setting an offset for the grid lines.
+         */
+        gridOffset: Vector3;
+        /**
+         * The frequency of thicker lines.
+         */
+        majorUnitFrequency: number;
+        /**
+         * The visibility of minor units in the grid.
+         */
+        minorUnitVisibility: number;
+        /**
+         * The grid opacity outside of the lines.
+         */
+        opacity: number;
+        /**
+         * Determine RBG output is premultiplied by alpha value.
+         */
+        preMultiplyAlpha: boolean;
+        private _gridControl;
+        private _renderId;
+        /**
+         * constructor
+         * @param name The name given to the material in order to identify it afterwards.
+         * @param scene The scene the material is used in.
+         */
+        constructor(name: string, scene: Scene);
+        /**
+         * Returns wehter or not the grid requires alpha blending.
+         */
+        needAlphaBlending(): boolean;
+        needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
+        isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
+        bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): GridMaterial;
+        serialize(): any;
+        getClassName(): string;
+        static Parse(source: any, scene: Scene, rootUrl: string): GridMaterial;
+    }
+}

Plik diff jest za duży
+ 212 - 0
dist/preview release/materialsLibrary/babylon.gridMaterial.js


+ 35 - 0
dist/preview release/materialsLibrary/babylon.lavaMaterial.d.ts

@@ -0,0 +1,35 @@
+
+declare module BABYLON {
+    class LavaMaterial extends PushMaterial {
+        private _diffuseTexture;
+        diffuseTexture: BaseTexture;
+        noiseTexture: BaseTexture;
+        fogColor: Color3;
+        speed: number;
+        movingSpeed: number;
+        lowFrequencySpeed: number;
+        fogDensity: number;
+        private _lastTime;
+        diffuseColor: Color3;
+        private _disableLighting;
+        disableLighting: boolean;
+        private _maxSimultaneousLights;
+        maxSimultaneousLights: number;
+        private _scaledDiffuse;
+        private _renderId;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): Nullable<BaseTexture>;
+        isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
+        bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
+        getAnimatables(): IAnimatable[];
+        getActiveTextures(): BaseTexture[];
+        hasTexture(texture: BaseTexture): boolean;
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): LavaMaterial;
+        serialize(): any;
+        getClassName(): string;
+        static Parse(source: any, scene: Scene, rootUrl: string): LavaMaterial;
+    }
+}

Plik diff jest za duży
+ 372 - 0
dist/preview release/materialsLibrary/babylon.lavaMaterial.js


+ 27 - 0
dist/preview release/materialsLibrary/babylon.normalMaterial.d.ts

@@ -0,0 +1,27 @@
+
+declare module BABYLON {
+    class NormalMaterial extends PushMaterial {
+        private _diffuseTexture;
+        diffuseTexture: BaseTexture;
+        diffuseColor: Color3;
+        private _disableLighting;
+        disableLighting: boolean;
+        private _maxSimultaneousLights;
+        maxSimultaneousLights: number;
+        private _renderId;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): Nullable<BaseTexture>;
+        isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
+        bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
+        getAnimatables(): IAnimatable[];
+        getActiveTextures(): BaseTexture[];
+        hasTexture(texture: BaseTexture): boolean;
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): NormalMaterial;
+        serialize(): any;
+        getClassName(): string;
+        static Parse(source: any, scene: Scene, rootUrl: string): NormalMaterial;
+    }
+}

Plik diff jest za duży
+ 326 - 0
dist/preview release/materialsLibrary/babylon.normalMaterial.js


+ 18 - 0
dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.d.ts

@@ -0,0 +1,18 @@
+
+declare module BABYLON {
+    class ShadowOnlyMaterial extends PushMaterial {
+        private _renderId;
+        private _activeLight;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): Nullable<BaseTexture>;
+        activeLight: IShadowLight;
+        isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
+        bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
+        clone(name: string): ShadowOnlyMaterial;
+        serialize(): any;
+        getClassName(): string;
+        static Parse(source: any, scene: Scene, rootUrl: string): ShadowOnlyMaterial;
+    }
+}

Plik diff jest za duży
+ 211 - 0
dist/preview release/materialsLibrary/babylon.shadowOnlyMaterial.js


+ 27 - 0
dist/preview release/materialsLibrary/babylon.simpleMaterial.d.ts

@@ -0,0 +1,27 @@
+
+declare module BABYLON {
+    class SimpleMaterial extends PushMaterial {
+        private _diffuseTexture;
+        diffuseTexture: BaseTexture;
+        diffuseColor: Color3;
+        private _disableLighting;
+        disableLighting: boolean;
+        private _maxSimultaneousLights;
+        maxSimultaneousLights: number;
+        private _renderId;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): Nullable<BaseTexture>;
+        isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
+        bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
+        getAnimatables(): IAnimatable[];
+        getActiveTextures(): BaseTexture[];
+        hasTexture(texture: BaseTexture): boolean;
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): SimpleMaterial;
+        serialize(): any;
+        getClassName(): string;
+        static Parse(source: any, scene: Scene, rootUrl: string): SimpleMaterial;
+    }
+}

Plik diff jest za duży
+ 285 - 0
dist/preview release/materialsLibrary/babylon.simpleMaterial.js


+ 29 - 0
dist/preview release/materialsLibrary/babylon.skyMaterial.d.ts

@@ -0,0 +1,29 @@
+
+declare module BABYLON {
+    class SkyMaterial extends PushMaterial {
+        luminance: number;
+        turbidity: number;
+        rayleigh: number;
+        mieCoefficient: number;
+        mieDirectionalG: number;
+        distance: number;
+        inclination: number;
+        azimuth: number;
+        sunPosition: Vector3;
+        useSunPosition: boolean;
+        private _cameraPosition;
+        private _renderId;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): Nullable<BaseTexture>;
+        isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
+        bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
+        getAnimatables(): IAnimatable[];
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): SkyMaterial;
+        serialize(): any;
+        getClassName(): string;
+        static Parse(source: any, scene: Scene, rootUrl: string): SkyMaterial;
+    }
+}

Plik diff jest za duży
+ 228 - 0
dist/preview release/materialsLibrary/babylon.skyMaterial.js


+ 41 - 0
dist/preview release/materialsLibrary/babylon.terrainMaterial.d.ts

@@ -0,0 +1,41 @@
+
+declare module BABYLON {
+    class TerrainMaterial extends PushMaterial {
+        private _mixTexture;
+        mixTexture: BaseTexture;
+        private _diffuseTexture1;
+        diffuseTexture1: Texture;
+        private _diffuseTexture2;
+        diffuseTexture2: Texture;
+        private _diffuseTexture3;
+        diffuseTexture3: Texture;
+        private _bumpTexture1;
+        bumpTexture1: Texture;
+        private _bumpTexture2;
+        bumpTexture2: Texture;
+        private _bumpTexture3;
+        bumpTexture3: Texture;
+        diffuseColor: Color3;
+        specularColor: Color3;
+        specularPower: number;
+        private _disableLighting;
+        disableLighting: boolean;
+        private _maxSimultaneousLights;
+        maxSimultaneousLights: number;
+        private _renderId;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): Nullable<BaseTexture>;
+        isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
+        bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
+        getAnimatables(): IAnimatable[];
+        getActiveTextures(): BaseTexture[];
+        hasTexture(texture: BaseTexture): boolean;
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): TerrainMaterial;
+        serialize(): any;
+        getClassName(): string;
+        static Parse(source: any, scene: Scene, rootUrl: string): TerrainMaterial;
+    }
+}

Plik diff jest za duży
+ 400 - 0
dist/preview release/materialsLibrary/babylon.terrainMaterial.js


+ 41 - 0
dist/preview release/materialsLibrary/babylon.triPlanarMaterial.d.ts

@@ -0,0 +1,41 @@
+
+declare module BABYLON {
+    class TriPlanarMaterial extends PushMaterial {
+        mixTexture: BaseTexture;
+        private _diffuseTextureX;
+        diffuseTextureX: BaseTexture;
+        private _diffuseTextureY;
+        diffuseTextureY: BaseTexture;
+        private _diffuseTextureZ;
+        diffuseTextureZ: BaseTexture;
+        private _normalTextureX;
+        normalTextureX: BaseTexture;
+        private _normalTextureY;
+        normalTextureY: BaseTexture;
+        private _normalTextureZ;
+        normalTextureZ: BaseTexture;
+        tileSize: number;
+        diffuseColor: Color3;
+        specularColor: Color3;
+        specularPower: number;
+        private _disableLighting;
+        disableLighting: boolean;
+        private _maxSimultaneousLights;
+        maxSimultaneousLights: number;
+        private _renderId;
+        constructor(name: string, scene: Scene);
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): Nullable<BaseTexture>;
+        isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
+        bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
+        getAnimatables(): IAnimatable[];
+        getActiveTextures(): BaseTexture[];
+        hasTexture(texture: BaseTexture): boolean;
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): TriPlanarMaterial;
+        serialize(): any;
+        getClassName(): string;
+        static Parse(source: any, scene: Scene, rootUrl: string): TriPlanarMaterial;
+    }
+}

Plik diff jest za duży
+ 395 - 0
dist/preview release/materialsLibrary/babylon.triPlanarMaterial.js


+ 106 - 0
dist/preview release/materialsLibrary/babylon.waterMaterial.d.ts

@@ -0,0 +1,106 @@
+
+declare module BABYLON {
+    class WaterMaterial extends PushMaterial {
+        renderTargetSize: Vector2;
+        private _bumpTexture;
+        bumpTexture: BaseTexture;
+        diffuseColor: Color3;
+        specularColor: Color3;
+        specularPower: number;
+        private _disableLighting;
+        disableLighting: boolean;
+        private _maxSimultaneousLights;
+        maxSimultaneousLights: number;
+        /**
+        * @param {number}: Represents the wind force
+        */
+        windForce: number;
+        /**
+        * @param {Vector2}: The direction of the wind in the plane (X, Z)
+        */
+        windDirection: Vector2;
+        /**
+        * @param {number}: Wave height, represents the height of the waves
+        */
+        waveHeight: number;
+        /**
+        * @param {number}: Bump height, represents the bump height related to the bump map
+        */
+        bumpHeight: number;
+        /**
+         * @param {boolean}: Add a smaller moving bump to less steady waves.
+         */
+        private _bumpSuperimpose;
+        bumpSuperimpose: boolean;
+        /**
+         * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
+         */
+        private _fresnelSeparate;
+        fresnelSeparate: boolean;
+        /**
+         * @param {boolean}: bump Waves modify the reflection.
+         */
+        private _bumpAffectsReflection;
+        bumpAffectsReflection: boolean;
+        /**
+        * @param {number}: The water color blended with the refraction (near)
+        */
+        waterColor: Color3;
+        /**
+        * @param {number}: The blend factor related to the water color
+        */
+        colorBlendFactor: number;
+        /**
+         * @param {number}: The water color blended with the reflection (far)
+         */
+        waterColor2: Color3;
+        /**
+         * @param {number}: The blend factor related to the water color (reflection, far)
+         */
+        colorBlendFactor2: number;
+        /**
+        * @param {number}: Represents the maximum length of a wave
+        */
+        waveLength: number;
+        /**
+        * @param {number}: Defines the waves speed
+        */
+        waveSpeed: number;
+        protected _renderTargets: SmartArray<RenderTargetTexture>;
+        private _mesh;
+        private _refractionRTT;
+        private _reflectionRTT;
+        private _reflectionTransform;
+        private _lastTime;
+        private _lastDeltaTime;
+        private _renderId;
+        private _useLogarithmicDepth;
+        private _waitingRenderList;
+        /**
+        * Constructor
+        */
+        constructor(name: string, scene: Scene, renderTargetSize?: Vector2);
+        useLogarithmicDepth: boolean;
+        readonly refractionTexture: Nullable<RenderTargetTexture>;
+        readonly reflectionTexture: Nullable<RenderTargetTexture>;
+        addToRenderList(node: any): void;
+        enableRenderTargets(enable: boolean): void;
+        getRenderList(): Nullable<AbstractMesh[]>;
+        readonly renderTargetsEnabled: boolean;
+        needAlphaBlending(): boolean;
+        needAlphaTesting(): boolean;
+        getAlphaTestTexture(): Nullable<BaseTexture>;
+        isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
+        bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
+        private _createRenderTargets(scene, renderTargetSize);
+        getAnimatables(): IAnimatable[];
+        getActiveTextures(): BaseTexture[];
+        hasTexture(texture: BaseTexture): boolean;
+        dispose(forceDisposeEffect?: boolean): void;
+        clone(name: string): WaterMaterial;
+        serialize(): any;
+        getClassName(): string;
+        static Parse(source: any, scene: Scene, rootUrl: string): WaterMaterial;
+        static CreateDefaultMesh(name: string, scene: Scene): Mesh;
+    }
+}

Plik diff jest za duży
+ 629 - 0
dist/preview release/materialsLibrary/babylon.waterMaterial.js


+ 102 - 0
dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.d.ts

@@ -0,0 +1,102 @@
+
+declare module BABYLON {
+    /**
+     * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
+     *
+     * It basically takes care rendering the font front the given font size to a texture.
+     * This is used later on in the postprocess.
+     */
+    class AsciiArtFontTexture extends BaseTexture {
+        private _font;
+        private _text;
+        private _charSize;
+        /**
+         * Gets the size of one char in the texture (each char fits in size * size space in the texture).
+         */
+        readonly charSize: number;
+        /**
+         * Create a new instance of the Ascii Art FontTexture class
+         * @param name the name of the texture
+         * @param font the font to use, use the W3C CSS notation
+         * @param text the caracter set to use in the rendering.
+         * @param scene the scene that owns the texture
+         */
+        constructor(name: string, font: string, text: string, scene?: Nullable<Scene>);
+        /**
+         * Gets the max char width of a font.
+         * @param font the font to use, use the W3C CSS notation
+         * @return the max char width
+         */
+        private getFontWidth(font);
+        /**
+         * Gets the max char height of a font.
+         * @param font the font to use, use the W3C CSS notation
+         * @return the max char height
+         */
+        private getFontHeight(font);
+        /**
+         * Clones the current AsciiArtTexture.
+         * @return the clone of the texture.
+         */
+        clone(): AsciiArtFontTexture;
+        /**
+         * Parses a json object representing the texture and returns an instance of it.
+         * @param source the source JSON representation
+         * @param scene the scene to create the texture for
+         * @return the parsed texture
+         */
+        static Parse(source: any, scene: Scene): AsciiArtFontTexture;
+    }
+    /**
+     * Option available in the Ascii Art Post Process.
+     */
+    interface IAsciiArtPostProcessOptions {
+        /**
+         * The font to use following the w3c font definition.
+         */
+        font?: string;
+        /**
+         * The character set to use in the postprocess.
+         */
+        characterSet?: string;
+        /**
+         * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
+         * This number is defined between 0 and 1;
+         */
+        mixToTile?: number;
+        /**
+         * This defines the amount you want to mix the normal rendering pass in the ascii art.
+         * This number is defined between 0 and 1;
+         */
+        mixToNormal?: number;
+    }
+    /**
+     * AsciiArtPostProcess helps rendering everithing in Ascii Art.
+     *
+     * Simmply add it to your scene and let the nerd that lives in you have fun.
+     * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
+     */
+    class AsciiArtPostProcess extends PostProcess {
+        /**
+         * The font texture used to render the char in the post process.
+         */
+        private _asciiArtFontTexture;
+        /**
+         * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
+         * This number is defined between 0 and 1;
+         */
+        mixToTile: number;
+        /**
+         * This defines the amount you want to mix the normal rendering pass in the ascii art.
+         * This number is defined between 0 and 1;
+         */
+        mixToNormal: number;
+        /**
+         * Instantiates a new Ascii Art Post Process.
+         * @param name the name to give to the postprocess
+         * @camera the camera to apply the post process to.
+         * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
+         */
+        constructor(name: string, camera: Camera, options?: string | IAsciiArtPostProcessOptions);
+    }
+}

Plik diff jest za duży
+ 222 - 0
dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.js


Plik diff jest za duży
+ 1 - 0
dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js


+ 98 - 0
dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.d.ts

@@ -0,0 +1,98 @@
+
+declare module BABYLON {
+    /**
+     * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
+     *
+     * It basically takes care rendering the font front the given font size to a texture.
+     * This is used later on in the postprocess.
+     */
+    class DigitalRainFontTexture extends BaseTexture {
+        private _font;
+        private _text;
+        private _charSize;
+        /**
+         * Gets the size of one char in the texture (each char fits in size * size space in the texture).
+         */
+        readonly charSize: number;
+        /**
+         * Create a new instance of the Digital Rain FontTexture class
+         * @param name the name of the texture
+         * @param font the font to use, use the W3C CSS notation
+         * @param text the caracter set to use in the rendering.
+         * @param scene the scene that owns the texture
+         */
+        constructor(name: string, font: string, text: string, scene?: Nullable<Scene>);
+        /**
+         * Gets the max char width of a font.
+         * @param font the font to use, use the W3C CSS notation
+         * @return the max char width
+         */
+        private getFontWidth(font);
+        /**
+         * Gets the max char height of a font.
+         * @param font the font to use, use the W3C CSS notation
+         * @return the max char height
+         */
+        private getFontHeight(font);
+        /**
+         * Clones the current DigitalRainFontTexture.
+         * @return the clone of the texture.
+         */
+        clone(): DigitalRainFontTexture;
+        /**
+         * Parses a json object representing the texture and returns an instance of it.
+         * @param source the source JSON representation
+         * @param scene the scene to create the texture for
+         * @return the parsed texture
+         */
+        static Parse(source: any, scene: Scene): DigitalRainFontTexture;
+    }
+    /**
+     * Option available in the Digital Rain Post Process.
+     */
+    interface IDigitalRainPostProcessOptions {
+        /**
+         * The font to use following the w3c font definition.
+         */
+        font?: string;
+        /**
+         * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
+         * This number is defined between 0 and 1;
+         */
+        mixToTile?: number;
+        /**
+         * This defines the amount you want to mix the normal rendering pass in the digital rain.
+         * This number is defined between 0 and 1;
+         */
+        mixToNormal?: number;
+    }
+    /**
+     * DigitalRainPostProcess helps rendering everithing in digital rain.
+     *
+     * Simmply add it to your scene and let the nerd that lives in you have fun.
+     * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
+     */
+    class DigitalRainPostProcess extends PostProcess {
+        /**
+         * The font texture used to render the char in the post process.
+         */
+        private _digitalRainFontTexture;
+        /**
+         * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
+         * This number is defined between 0 and 1;
+         */
+        mixToTile: number;
+        /**
+         * This defines the amount you want to mix the normal rendering pass in the digital rain.
+         * This number is defined between 0 and 1;
+         */
+        mixToNormal: number;
+        /**
+         * Instantiates a new Digital Rain Post Process.
+         * @param name the name to give to the postprocess
+         * @camera the camera to apply the post process to.
+         * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
+         */
+        constructor(name: string, camera: Camera, options?: string | IDigitalRainPostProcessOptions);
+    }
+}

Plik diff jest za duży
+ 231 - 0
dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.js


Plik diff jest za duży
+ 1 - 0
dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js


+ 15 - 0
dist/preview release/proceduralTexturesLibrary/babylon.brickProceduralTexture.d.ts

@@ -0,0 +1,15 @@
+
+declare module BABYLON {
+    class BrickProceduralTexture extends ProceduralTexture {
+        private _numberOfBricksHeight;
+        private _numberOfBricksWidth;
+        private _jointColor;
+        private _brickColor;
+        constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
+        updateShaderUniforms(): void;
+        numberOfBricksHeight: number;
+        numberOfBricksWidth: number;
+        jointColor: Color3;
+        brickColor: Color3;
+    }
+}

Plik diff jest za duży
+ 82 - 0
dist/preview release/proceduralTexturesLibrary/babylon.brickProceduralTexture.js


Plik diff jest za duży
+ 1 - 0
dist/preview release/proceduralTexturesLibrary/babylon.brickProceduralTexture.min.js


+ 11 - 0
dist/preview release/proceduralTexturesLibrary/babylon.cloudProceduralTexture.d.ts

@@ -0,0 +1,11 @@
+
+declare module BABYLON {
+    class CloudProceduralTexture extends ProceduralTexture {
+        private _skyColor;
+        private _cloudColor;
+        constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
+        updateShaderUniforms(): void;
+        skyColor: Color4;
+        cloudColor: Color4;
+    }
+}

Plik diff jest za duży
+ 56 - 0
dist/preview release/proceduralTexturesLibrary/babylon.cloudProceduralTexture.js


Plik diff jest za duży
+ 1 - 0
dist/preview release/proceduralTexturesLibrary/babylon.cloudProceduralTexture.min.js


+ 21 - 0
dist/preview release/proceduralTexturesLibrary/babylon.fireProceduralTexture.d.ts

@@ -0,0 +1,21 @@
+
+declare module BABYLON {
+    class FireProceduralTexture extends ProceduralTexture {
+        private _time;
+        private _speed;
+        private _autoGenerateTime;
+        private _fireColors;
+        private _alphaThreshold;
+        constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
+        updateShaderUniforms(): void;
+        render(useCameraPostProcess?: boolean): void;
+        static readonly PurpleFireColors: Color3[];
+        static readonly GreenFireColors: Color3[];
+        static readonly RedFireColors: Color3[];
+        static readonly BlueFireColors: Color3[];
+        fireColors: Color3[];
+        time: number;
+        speed: Vector2;
+        alphaThreshold: number;
+    }
+}

Plik diff jest za duży
+ 152 - 0
dist/preview release/proceduralTexturesLibrary/babylon.fireProceduralTexture.js


Plik diff jest za duży
+ 1 - 0
dist/preview release/proceduralTexturesLibrary/babylon.fireProceduralTexture.min.js


+ 11 - 0
dist/preview release/proceduralTexturesLibrary/babylon.grassProceduralTexture.d.ts

@@ -0,0 +1,11 @@
+
+declare module BABYLON {
+    class GrassProceduralTexture extends ProceduralTexture {
+        private _grassColors;
+        private _groundColor;
+        constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
+        updateShaderUniforms(): void;
+        grassColors: Color3[];
+        groundColor: Color3;
+    }
+}

Plik diff jest za duży
+ 62 - 0
dist/preview release/proceduralTexturesLibrary/babylon.grassProceduralTexture.js


Plik diff jest za duży
+ 1 - 0
dist/preview release/proceduralTexturesLibrary/babylon.grassProceduralTexture.min.js


+ 15 - 0
dist/preview release/proceduralTexturesLibrary/babylon.marbleProceduralTexture.d.ts

@@ -0,0 +1,15 @@
+
+declare module BABYLON {
+    class MarbleProceduralTexture extends ProceduralTexture {
+        private _numberOfTilesHeight;
+        private _numberOfTilesWidth;
+        private _amplitude;
+        private _jointColor;
+        constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
+        updateShaderUniforms(): void;
+        numberOfTilesHeight: number;
+        amplitude: number;
+        numberOfTilesWidth: number;
+        jointColor: Color3;
+    }
+}

Plik diff jest za duży
+ 82 - 0
dist/preview release/proceduralTexturesLibrary/babylon.marbleProceduralTexture.js


Plik diff jest za duży
+ 1 - 0
dist/preview release/proceduralTexturesLibrary/babylon.marbleProceduralTexture.min.js


+ 11 - 0
dist/preview release/proceduralTexturesLibrary/babylon.normalMapProceduralTexture.d.ts

@@ -0,0 +1,11 @@
+
+declare module BABYLON {
+    class NormalMapProceduralTexture extends ProceduralTexture {
+        private _baseTexture;
+        constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
+        updateShaderUniforms(): void;
+        render(useCameraPostProcess?: boolean): void;
+        resize(size: any, generateMipMaps: any): void;
+        baseTexture: Texture;
+    }
+}

Plik diff jest za duży
+ 51 - 0
dist/preview release/proceduralTexturesLibrary/babylon.normalMapProceduralTexture.js


Plik diff jest za duży
+ 1 - 0
dist/preview release/proceduralTexturesLibrary/babylon.normalMapProceduralTexture.min.js


+ 13 - 0
dist/preview release/proceduralTexturesLibrary/babylon.perlinNoiseProceduralTexture.d.ts

@@ -0,0 +1,13 @@
+
+declare module BABYLON {
+    class PerlinNoiseProceduralTexture extends ProceduralTexture {
+        time: number;
+        speed: number;
+        translationSpeed: number;
+        private _currentTranslation;
+        constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
+        updateShaderUniforms(): void;
+        render(useCameraPostProcess?: boolean): void;
+        resize(size: any, generateMipMaps: any): void;
+    }
+}

Plik diff jest za duży
+ 51 - 0
dist/preview release/proceduralTexturesLibrary/babylon.perlinNoiseProceduralTexture.js


Plik diff jest za duży
+ 1 - 0
dist/preview release/proceduralTexturesLibrary/babylon.perlinNoiseProceduralTexture.min.js


+ 9 - 0
dist/preview release/proceduralTexturesLibrary/babylon.roadProceduralTexture.d.ts

@@ -0,0 +1,9 @@
+
+declare module BABYLON {
+    class RoadProceduralTexture extends ProceduralTexture {
+        private _roadColor;
+        constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
+        updateShaderUniforms(): void;
+        roadColor: Color3;
+    }
+}

Plik diff jest za duży
+ 43 - 0
dist/preview release/proceduralTexturesLibrary/babylon.roadProceduralTexture.js


Plik diff jest za duży
+ 1 - 0
dist/preview release/proceduralTexturesLibrary/babylon.roadProceduralTexture.min.js


+ 29 - 0
dist/preview release/proceduralTexturesLibrary/babylon.starfieldProceduralTexture.d.ts

@@ -0,0 +1,29 @@
+
+declare module BABYLON {
+    class StarfieldProceduralTexture extends ProceduralTexture {
+        private _time;
+        private _alpha;
+        private _beta;
+        private _zoom;
+        private _formuparam;
+        private _stepsize;
+        private _tile;
+        private _brightness;
+        private _darkmatter;
+        private _distfading;
+        private _saturation;
+        constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
+        updateShaderUniforms(): void;
+        time: number;
+        alpha: number;
+        beta: number;
+        formuparam: number;
+        stepsize: number;
+        zoom: number;
+        tile: number;
+        brightness: number;
+        darkmatter: number;
+        distfading: number;
+        saturation: number;
+    }
+}

Plik diff jest za duży
+ 173 - 0
dist/preview release/proceduralTexturesLibrary/babylon.starfieldProceduralTexture.js


Plik diff jest za duży
+ 1 - 0
dist/preview release/proceduralTexturesLibrary/babylon.starfieldProceduralTexture.min.js


+ 11 - 0
dist/preview release/proceduralTexturesLibrary/babylon.woodProceduralTexture.d.ts

@@ -0,0 +1,11 @@
+
+declare module BABYLON {
+    class WoodProceduralTexture extends ProceduralTexture {
+        private _ampScale;
+        private _woodColor;
+        constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
+        updateShaderUniforms(): void;
+        ampScale: number;
+        woodColor: Color3;
+    }
+}

Plik diff jest za duży
+ 56 - 0
dist/preview release/proceduralTexturesLibrary/babylon.woodProceduralTexture.js


Plik diff jest za duży
+ 1 - 0
dist/preview release/proceduralTexturesLibrary/babylon.woodProceduralTexture.min.js


+ 7 - 0
dist/preview release/serializers/babylon.objSerializer.d.ts

@@ -0,0 +1,7 @@
+
+declare module BABYLON {
+    class OBJExport {
+        static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
+        static MTL(mesh: Mesh): string;
+    }
+}

+ 124 - 0
dist/preview release/serializers/babylon.objSerializer.js

@@ -0,0 +1,124 @@
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
+var BABYLON;
+(function (BABYLON) {
+    var OBJExport = /** @class */ (function () {
+        function OBJExport() {
+        }
+        //Exports the geometrys of a Mesh array in .OBJ file format (text)
+        OBJExport.OBJ = function (mesh, materials, matlibname, globalposition) {
+            var output = [];
+            var v = 1;
+            if (materials) {
+                if (!matlibname) {
+                    matlibname = 'mat';
+                }
+                output.push("mtllib " + matlibname + ".mtl");
+            }
+            for (var j = 0; j < mesh.length; j++) {
+                output.push("g object" + j);
+                output.push("o object_" + j);
+                //Uses the position of the item in the scene, to the file (this back to normal in the end)
+                var lastMatrix = null;
+                if (globalposition) {
+                    var newMatrix = BABYLON.Matrix.Translation(mesh[j].position.x, mesh[j].position.y, mesh[j].position.z);
+                    lastMatrix = BABYLON.Matrix.Translation(-(mesh[j].position.x), -(mesh[j].position.y), -(mesh[j].position.z));
+                    mesh[j].bakeTransformIntoVertices(newMatrix);
+                }
+                //TODO: submeshes (groups)
+                //TODO: smoothing groups (s 1, s off);
+                if (materials) {
+                    var mat = mesh[j].material;
+                    if (mat) {
+                        output.push("usemtl " + mat.id);
+                    }
+                }
+                var g = mesh[j].geometry;
+                if (!g) {
+                    continue;
+                }
+                var trunkVerts = g.getVerticesData('position');
+                var trunkNormals = g.getVerticesData('normal');
+                var trunkUV = g.getVerticesData('uv');
+                var trunkFaces = g.getIndices();
+                var curV = 0;
+                if (!trunkVerts || !trunkNormals || !trunkUV || !trunkFaces) {
+                    continue;
+                }
+                for (var i = 0; i < trunkVerts.length; i += 3) {
+                    output.push("v " + trunkVerts[i] + " " + trunkVerts[i + 1] + " " + trunkVerts[i + 2]);
+                    curV++;
+                }
+                for (i = 0; i < trunkNormals.length; i += 3) {
+                    output.push("vn " + trunkNormals[i] + " " + trunkNormals[i + 1] + " " + trunkNormals[i + 2]);
+                }
+                for (i = 0; i < trunkUV.length; i += 2) {
+                    output.push("vt " + trunkUV[i] + " " + trunkUV[i + 1]);
+                }
+                for (i = 0; i < trunkFaces.length; i += 3) {
+                    output.push("f " + (trunkFaces[i + 2] + v) + "/" + (trunkFaces[i + 2] + v) + "/" + (trunkFaces[i + 2] + v) +
+                        " " + (trunkFaces[i + 1] + v) + "/" + (trunkFaces[i + 1] + v) + "/" + (trunkFaces[i + 1] + v) +
+                        " " + (trunkFaces[i] + v) + "/" + (trunkFaces[i] + v) + "/" + (trunkFaces[i] + v));
+                }
+                //back de previous matrix, to not change the original mesh in the scene
+                if (globalposition && lastMatrix) {
+                    mesh[j].bakeTransformIntoVertices(lastMatrix);
+                }
+                v += curV;
+            }
+            var text = output.join("\n");
+            return (text);
+        };
+        //Exports the material(s) of a mesh in .MTL file format (text)
+        //TODO: Export the materials of mesh array
+        OBJExport.MTL = function (mesh) {
+            var output = [];
+            var m = mesh.material;
+            output.push("newmtl mat1");
+            output.push("  Ns " + m.specularPower.toFixed(4));
+            output.push("  Ni 1.5000");
+            output.push("  d " + m.alpha.toFixed(4));
+            output.push("  Tr 0.0000");
+            output.push("  Tf 1.0000 1.0000 1.0000");
+            output.push("  illum 2");
+            output.push("  Ka " + m.ambientColor.r.toFixed(4) + " " + m.ambientColor.g.toFixed(4) + " " + m.ambientColor.b.toFixed(4));
+            output.push("  Kd " + m.diffuseColor.r.toFixed(4) + " " + m.diffuseColor.g.toFixed(4) + " " + m.diffuseColor.b.toFixed(4));
+            output.push("  Ks " + m.specularColor.r.toFixed(4) + " " + m.specularColor.g.toFixed(4) + " " + m.specularColor.b.toFixed(4));
+            output.push("  Ke " + m.emissiveColor.r.toFixed(4) + " " + m.emissiveColor.g.toFixed(4) + " " + m.emissiveColor.b.toFixed(4));
+            //TODO: uv scale, offset, wrap
+            //TODO: UV mirrored in Blender? second UV channel? lightMap? reflection textures?
+            var uvscale = "";
+            if (m.ambientTexture) {
+                output.push("  map_Ka " + uvscale + m.ambientTexture.name);
+            }
+            if (m.diffuseTexture) {
+                output.push("  map_Kd " + uvscale + m.diffuseTexture.name);
+                //TODO: alpha testing, opacity in diffuse texture alpha channel (diffuseTexture.hasAlpha -> map_d)
+            }
+            if (m.specularTexture) {
+                output.push("  map_Ks " + uvscale + m.specularTexture.name);
+                /* TODO: glossiness = specular highlight component is in alpha channel of specularTexture. (???)
+                if (m.useGlossinessFromSpecularMapAlpha)  {
+                    output.push("  map_Ns "+uvscale + m.specularTexture.name);
+                }
+                */
+            }
+            /* TODO: emissive texture not in .MAT format (???)
+            if (m.emissiveTexture) {
+                output.push("  map_d "+uvscale+m.emissiveTexture.name);
+            }
+            */
+            if (m.bumpTexture) {
+                output.push("  map_bump -imfchan z " + uvscale + m.bumpTexture.name);
+            }
+            if (m.opacityTexture) {
+                output.push("  map_d " + uvscale + m.opacityTexture.name);
+            }
+            var text = output.join("\n");
+            return (text);
+        };
+        return OBJExport;
+    }());
+    BABYLON.OBJExport = OBJExport;
+})(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=babylon.objSerializer.js.map

Plik diff jest za duży
+ 1 - 0
dist/preview release/serializers/babylon.objSerializer.min.js