David Catuhe 8 лет назад
Родитель
Сommit
d9c1002dd4
23 измененных файлов с 11907 добавлено и 11751 удалено
  1. 5776 5776
      dist/preview release/babylon.d.ts
  2. 36 36
      dist/preview release/babylon.js
  3. 12 6
      dist/preview release/babylon.max.js
  4. 5776 5776
      dist/preview release/babylon.module.d.ts
  5. 37 37
      dist/preview release/babylon.worker.js
  6. 11 11
      dist/preview release/canvas2D/babylon.canvas2d.min.js
  7. 17 17
      dist/preview release/inspector/babylon.inspector.bundle.js
  8. 36 36
      dist/preview release/inspector/babylon.inspector.d.ts
  9. 3 3
      dist/preview release/inspector/babylon.inspector.min.js
  10. 2 2
      dist/preview release/loaders/babylon.glTF1FileLoader.min.js
  11. 3 1
      dist/preview release/loaders/babylon.glTF2FileLoader.d.ts
  12. 71 7
      dist/preview release/loaders/babylon.glTF2FileLoader.js
  13. 1 1
      dist/preview release/loaders/babylon.glTF2FileLoader.min.js
  14. 3 1
      dist/preview release/loaders/babylon.glTFFileLoader.d.ts
  15. 71 7
      dist/preview release/loaders/babylon.glTFFileLoader.js
  16. 2 2
      dist/preview release/loaders/babylon.glTFFileLoader.min.js
  17. 1 1
      dist/preview release/loaders/babylon.objFileLoader.min.js
  18. 1 1
      dist/preview release/materialsLibrary/babylon.waterMaterial.min.js
  19. 1 1
      dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js
  20. 1 1
      dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js
  21. 1 1
      dist/preview release/serializers/babylon.objSerializer.d.ts
  22. 44 26
      dist/preview release/serializers/babylon.objSerializer.js
  23. 1 1
      dist/preview release/serializers/babylon.objSerializer.min.js

Разница между файлами не показана из-за своего большого размера
+ 5776 - 5776
dist/preview release/babylon.d.ts


Разница между файлами не показана из-за своего большого размера
+ 36 - 36
dist/preview release/babylon.js


+ 12 - 6
dist/preview release/babylon.max.js

@@ -7016,7 +7016,7 @@ var BABYLON;
             this.isPointerLock = false;
             this.cullBackFaces = true;
             this.renderEvenInBackground = true;
-            this.preventCacheWipeBetweenFrames = true;
+            this.preventCacheWipeBetweenFrames = false;
             // To enable/disable IDB support and avoid XHR on .manifest
             this.enableOfflineSupport = BABYLON.Database;
             this.scenes = new Array();
@@ -7734,6 +7734,14 @@ var BABYLON;
         Engine.prototype.setStencilOperationPass = function (operation) {
             this._stencilState.stencilOpStencilDepthPass = operation;
         };
+        Engine.prototype.setDitheringState = function (value) {
+            if (value) {
+                this._gl.enable(this._gl.DITHER);
+            }
+            else {
+                this._gl.disable(this._gl.DITHER);
+            }
+        };
         /**
          * stop executing a render loop function and remove it from the execution array
          * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
@@ -8314,7 +8322,7 @@ var BABYLON;
             var boundBuffer;
             for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
                 var instancesBuffer = this._currentInstanceBuffers[i];
-                if (boundBuffer != instancesBuffer) {
+                if (boundBuffer != instancesBuffer && instancesBuffer.references) {
                     boundBuffer = instancesBuffer;
                     this.bindArrayBuffer(instancesBuffer);
                 }
@@ -31192,10 +31200,8 @@ var BABYLON;
                 _this._viewMatrix.m[13] += _this.targetScreenOffset.y;
                 _this._collisionTriggered = false;
             };
-            if (!target) {
-                _this._target = BABYLON.Vector3.Zero();
-            }
-            else {
+            _this._target = BABYLON.Vector3.Zero();
+            if (target) {
                 _this.setTarget(target);
             }
             _this.alpha = alpha;

Разница между файлами не показана из-за своего большого размера
+ 5776 - 5776
dist/preview release/babylon.module.d.ts


Разница между файлами не показана из-за своего большого размера
+ 37 - 37
dist/preview release/babylon.worker.js


Разница между файлами не показана из-за своего большого размера
+ 11 - 11
dist/preview release/canvas2D/babylon.canvas2d.min.js


Разница между файлами не показана из-за своего большого размера
+ 17 - 17
dist/preview release/inspector/babylon.inspector.bundle.js


+ 36 - 36
dist/preview release/inspector/babylon.inspector.d.ts

@@ -113,7 +113,7 @@ declare module INSPECTOR {
             type: typeof BABYLON.BaseTexture;
         };
         'FontTexture': {
-            type: any;
+            type: typeof BABYLON.FontTexture;
         };
         'Sound': {
             type: typeof BABYLON.Sound;
@@ -142,23 +142,23 @@ declare module INSPECTOR {
             format: (mat: BABYLON.StandardMaterial) => string;
         };
         'PrimitiveAlignment': {
-            type: any;
+            type: typeof BABYLON.PrimitiveAlignment;
             properties: string[];
         };
         'PrimitiveThickness': {
-            type: any;
+            type: typeof BABYLON.PrimitiveThickness;
             properties: string[];
         };
         'BoundingInfo2D': {
-            type: any;
+            type: typeof BABYLON.BoundingInfo2D;
             properties: string[];
         };
         'SolidColorBrush2D': {
-            type: any;
+            type: typeof BABYLON.SolidColorBrush2D;
             properties: string[];
         };
         'GradientColorBrush2D': {
-            type: any;
+            type: typeof BABYLON.GradientColorBrush2D;
             properties: string[];
         };
         'PBRMaterial': {
@@ -166,94 +166,94 @@ declare module INSPECTOR {
             properties: string[];
         };
         'Canvas2D': {
-            type: any;
+            type: typeof BABYLON.Canvas2D;
         };
         'Canvas2DEngineBoundData': {
-            type: any;
+            type: typeof BABYLON.Canvas2DEngineBoundData;
         };
         'Ellipse2D': {
-            type: any;
+            type: typeof BABYLON.Ellipse2D;
         };
         'Ellipse2DInstanceData': {
-            type: any;
+            type: typeof BABYLON.Ellipse2DInstanceData;
         };
         'Ellipse2DRenderCache': {
-            type: any;
+            type: typeof BABYLON.Ellipse2DRenderCache;
         };
         'Group2D': {
-            type: any;
+            type: typeof BABYLON.Group2D;
         };
         'IntersectInfo2D': {
-            type: any;
+            type: typeof BABYLON.IntersectInfo2D;
         };
         'Lines2D': {
-            type: any;
+            type: typeof BABYLON.Lines2D;
         };
         'Lines2DInstanceData': {
-            type: any;
+            type: typeof BABYLON.Lines2DInstanceData;
         };
         'Lines2DRenderCache': {
-            type: any;
+            type: typeof BABYLON.Lines2DRenderCache;
         };
         'PrepareRender2DContext': {
-            type: any;
+            type: typeof BABYLON.PrepareRender2DContext;
         };
         'Prim2DBase': {
-            type: any;
+            type: typeof BABYLON.Prim2DBase;
         };
         'Prim2DClassInfo': {
-            type: any;
+            type: typeof BABYLON.Prim2DClassInfo;
         };
         'Prim2DPropInfo': {
-            type: any;
+            type: typeof BABYLON.Prim2DPropInfo;
         };
         'Rectangle2D': {
-            type: any;
+            type: typeof BABYLON.Rectangle2D;
         };
         'Rectangle2DInstanceData': {
-            type: any;
+            type: typeof BABYLON.Rectangle2DInstanceData;
         };
         'Rectangle2DRenderCache': {
-            type: any;
+            type: typeof BABYLON.Rectangle2DRenderCache;
         };
         'Render2DContext': {
-            type: any;
+            type: typeof BABYLON.Render2DContext;
         };
         'RenderablePrim2D': {
-            type: any;
+            type: typeof BABYLON.RenderablePrim2D;
         };
         'ScreenSpaceCanvas2D': {
-            type: any;
+            type: typeof BABYLON.ScreenSpaceCanvas2D;
         };
         'Shape2D': {
-            type: any;
+            type: typeof BABYLON.Shape2D;
         };
         'Shape2DInstanceData': {
-            type: any;
+            type: typeof BABYLON.Shape2DInstanceData;
         };
         'Sprite2D': {
-            type: any;
+            type: typeof BABYLON.Sprite2D;
         };
         'Sprite2DInstanceData': {
-            type: any;
+            type: typeof BABYLON.Sprite2DInstanceData;
         };
         'Sprite2DRenderCache': {
-            type: any;
+            type: typeof BABYLON.Sprite2DRenderCache;
         };
         'Text2D': {
-            type: any;
+            type: typeof BABYLON.Text2D;
         };
         'Text2DInstanceData': {
-            type: any;
+            type: typeof BABYLON.Text2DInstanceData;
         };
         'Text2DRenderCache': {
-            type: any;
+            type: typeof BABYLON.Text2DRenderCache;
         };
         'WorldSpaceCanvas2D': {
-            type: any;
+            type: typeof BABYLON.WorldSpaceCanvas2D;
         };
         'WorldSpaceCanvas2DNode': {
-            type: any;
+            type: typeof BABYLON.WorldSpaceCanvas2DNode;
         };
     };
 }

Разница между файлами не показана из-за своего большого размера
+ 3 - 3
dist/preview release/inspector/babylon.inspector.min.js


Разница между файлами не показана из-за своего большого размера
+ 2 - 2
dist/preview release/loaders/babylon.glTF1FileLoader.min.js


+ 3 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.d.ts

@@ -236,7 +236,9 @@ declare module BABYLON.GLTF2 {
         indices?: number;
         material?: number;
         mode?: EMeshPrimitiveMode;
-        targets?: number[];
+        targets?: [{
+            [name: string]: number;
+        }];
     }
     interface IGLTFMesh extends IGLTFChildRootProperty {
         primitives: IGLTFMeshPrimitive[];

+ 71 - 7
dist/preview release/loaders/babylon.glTF2FileLoader.js

@@ -740,11 +740,12 @@ var BABYLON;
             var verticesCounts = [];
             var indexStarts = [];
             var indexCounts = [];
+            var morphTargetManager = new BABYLON.MorphTargetManager();
             // Positions, normals and UVs
-            for (var index = 0; index < mesh.primitives.length; index++) {
+            for (var primitiveIndex = 0; primitiveIndex < mesh.primitives.length; primitiveIndex++) {
                 // Temporary vertex data
                 var tempVertexData = new BABYLON.VertexData();
-                var primitive = mesh.primitives[index];
+                var primitive = mesh.primitives[primitiveIndex];
                 if (primitive.mode !== GLTF2.EMeshPrimitiveMode.TRIANGLES) {
                     // continue;
                 }
@@ -804,8 +805,8 @@ var BABYLON;
                 else {
                     // Set indices on the fly
                     var indices = [];
-                    for (var j = 0; j < tempVertexData.positions.length / 3; j++) {
-                        indices.push(j);
+                    for (var index = 0; index < tempVertexData.positions.length / 3; index++) {
+                        indices.push(index);
                     }
                     tempVertexData.indices = new Int32Array(indices);
                     indexCounts.push(tempVertexData.indices.length);
@@ -815,6 +816,65 @@ var BABYLON;
                 // Sub material
                 var material = getMaterial(runtime, primitive.material);
                 multiMat.subMaterials.push(material);
+                // Morph Targets
+                if (primitive.targets !== undefined) {
+                    for (var targetsIndex = 0; targetsIndex < primitive.targets.length; targetsIndex++) {
+                        var target = primitive.targets[targetsIndex];
+                        var weight = 0.0;
+                        if (node.weights !== undefined) {
+                            weight = node.weights[targetsIndex];
+                        }
+                        else if (mesh.weights !== undefined) {
+                            weight = mesh.weights[targetsIndex];
+                        }
+                        var morph = new BABYLON.MorphTarget("morph" + targetsIndex, weight);
+                        for (var semantic in target) {
+                            // Link accessor and buffer view
+                            accessor = runtime.gltf.accessors[target[semantic]];
+                            buffer = GLTF2.GLTFUtils.GetBufferFromAccessor(runtime, accessor);
+                            if (accessor.name !== undefined) {
+                                morph.name = accessor.name;
+                            }
+                            // glTF stores morph target information as deltas
+                            // while babylon.js expects the final data.
+                            // As a result we have to add the original data to the delta to calculate
+                            // the final data.
+                            if (semantic === "NORMAL") {
+                                for (var bufferIndex = 0; bufferIndex < buffer.length; bufferIndex++) {
+                                    buffer[bufferIndex] += vertexData.normals[bufferIndex];
+                                }
+                                morph.setNormals(buffer);
+                            }
+                            else if (semantic === "POSITION") {
+                                for (var bufferIndex = 0; bufferIndex < buffer.length; bufferIndex++) {
+                                    buffer[bufferIndex] += vertexData.positions[bufferIndex];
+                                }
+                                morph.setPositions(buffer);
+                            }
+                            else if (semantic === "TANGENT") {
+                                // Tangent data for morph targets is stored as xyz delta.
+                                // The vertexData.tangent is stored as xyzw.
+                                // So we need to skip every fourth vertexData.tangent.
+                                for (var bufferIndex = 0, tangentsIndex = 0; bufferIndex < buffer.length; bufferIndex++, tangentsIndex++) {
+                                    buffer[bufferIndex] += vertexData.tangents[tangentsIndex];
+                                    if ((bufferIndex + 1) % 3 == 0) {
+                                        tangentsIndex++;
+                                    }
+                                }
+                                morph.setTangents(buffer);
+                            }
+                            else {
+                                BABYLON.Tools.Warn("Ignoring unrecognized semantic '" + semantic + "'");
+                            }
+                        }
+                        if (morph.getPositions() !== undefined) {
+                            morphTargetManager.addTarget(morph);
+                        }
+                        else {
+                            BABYLON.Tools.Warn("Not adding morph target '" + morph.name + "' because it has no position data");
+                        }
+                    }
+                }
                 // Update vertices start and index start
                 verticesStarts.push(verticesStarts.length === 0 ? 0 : verticesStarts[verticesStarts.length - 1] + verticesCounts[verticesCounts.length - 2]);
                 indexStarts.push(indexStarts.length === 0 ? 0 : indexStarts[indexStarts.length - 1] + indexCounts[indexCounts.length - 2]);
@@ -822,13 +882,17 @@ var BABYLON;
             // Apply geometry
             geometry.setAllVerticesData(vertexData, false);
             babylonMesh.computeWorldMatrix(true);
+            // Set morph target manager after all vertices data has been processed
+            if (morphTargetManager !== undefined && morphTargetManager.numInfluencers > 0) {
+                babylonMesh.morphTargetManager = morphTargetManager;
+            }
             // Apply submeshes
             babylonMesh.subMeshes = [];
-            for (var index = 0; index < mesh.primitives.length; index++) {
-                if (mesh.primitives[index].mode !== GLTF2.EMeshPrimitiveMode.TRIANGLES) {
+            for (var primitiveIndex = 0; primitiveIndex < mesh.primitives.length; primitiveIndex++) {
+                if (mesh.primitives[primitiveIndex].mode !== GLTF2.EMeshPrimitiveMode.TRIANGLES) {
                     //continue;
                 }
-                var subMesh = new BABYLON.SubMesh(index, verticesStarts[index], verticesCounts[index], indexStarts[index], indexCounts[index], babylonMesh, babylonMesh, true);
+                var subMesh = new BABYLON.SubMesh(primitiveIndex, verticesStarts[primitiveIndex], verticesCounts[primitiveIndex], indexStarts[primitiveIndex], indexCounts[primitiveIndex], babylonMesh, babylonMesh, true);
             }
             // Finish
             return babylonMesh;

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
dist/preview release/loaders/babylon.glTF2FileLoader.min.js


+ 3 - 1
dist/preview release/loaders/babylon.glTFFileLoader.d.ts

@@ -731,7 +731,9 @@ declare module BABYLON.GLTF2 {
         indices?: number;
         material?: number;
         mode?: EMeshPrimitiveMode;
-        targets?: number[];
+        targets?: [{
+            [name: string]: number;
+        }];
     }
     interface IGLTFMesh extends IGLTFChildRootProperty {
         primitives: IGLTFMeshPrimitive[];

+ 71 - 7
dist/preview release/loaders/babylon.glTFFileLoader.js

@@ -2890,11 +2890,12 @@ var BABYLON;
             var verticesCounts = [];
             var indexStarts = [];
             var indexCounts = [];
+            var morphTargetManager = new BABYLON.MorphTargetManager();
             // Positions, normals and UVs
-            for (var index = 0; index < mesh.primitives.length; index++) {
+            for (var primitiveIndex = 0; primitiveIndex < mesh.primitives.length; primitiveIndex++) {
                 // Temporary vertex data
                 var tempVertexData = new BABYLON.VertexData();
-                var primitive = mesh.primitives[index];
+                var primitive = mesh.primitives[primitiveIndex];
                 if (primitive.mode !== GLTF2.EMeshPrimitiveMode.TRIANGLES) {
                     // continue;
                 }
@@ -2954,8 +2955,8 @@ var BABYLON;
                 else {
                     // Set indices on the fly
                     var indices = [];
-                    for (var j = 0; j < tempVertexData.positions.length / 3; j++) {
-                        indices.push(j);
+                    for (var index = 0; index < tempVertexData.positions.length / 3; index++) {
+                        indices.push(index);
                     }
                     tempVertexData.indices = new Int32Array(indices);
                     indexCounts.push(tempVertexData.indices.length);
@@ -2965,6 +2966,65 @@ var BABYLON;
                 // Sub material
                 var material = getMaterial(runtime, primitive.material);
                 multiMat.subMaterials.push(material);
+                // Morph Targets
+                if (primitive.targets !== undefined) {
+                    for (var targetsIndex = 0; targetsIndex < primitive.targets.length; targetsIndex++) {
+                        var target = primitive.targets[targetsIndex];
+                        var weight = 0.0;
+                        if (node.weights !== undefined) {
+                            weight = node.weights[targetsIndex];
+                        }
+                        else if (mesh.weights !== undefined) {
+                            weight = mesh.weights[targetsIndex];
+                        }
+                        var morph = new BABYLON.MorphTarget("morph" + targetsIndex, weight);
+                        for (var semantic in target) {
+                            // Link accessor and buffer view
+                            accessor = runtime.gltf.accessors[target[semantic]];
+                            buffer = GLTF2.GLTFUtils.GetBufferFromAccessor(runtime, accessor);
+                            if (accessor.name !== undefined) {
+                                morph.name = accessor.name;
+                            }
+                            // glTF stores morph target information as deltas
+                            // while babylon.js expects the final data.
+                            // As a result we have to add the original data to the delta to calculate
+                            // the final data.
+                            if (semantic === "NORMAL") {
+                                for (var bufferIndex = 0; bufferIndex < buffer.length; bufferIndex++) {
+                                    buffer[bufferIndex] += vertexData.normals[bufferIndex];
+                                }
+                                morph.setNormals(buffer);
+                            }
+                            else if (semantic === "POSITION") {
+                                for (var bufferIndex = 0; bufferIndex < buffer.length; bufferIndex++) {
+                                    buffer[bufferIndex] += vertexData.positions[bufferIndex];
+                                }
+                                morph.setPositions(buffer);
+                            }
+                            else if (semantic === "TANGENT") {
+                                // Tangent data for morph targets is stored as xyz delta.
+                                // The vertexData.tangent is stored as xyzw.
+                                // So we need to skip every fourth vertexData.tangent.
+                                for (var bufferIndex = 0, tangentsIndex = 0; bufferIndex < buffer.length; bufferIndex++, tangentsIndex++) {
+                                    buffer[bufferIndex] += vertexData.tangents[tangentsIndex];
+                                    if ((bufferIndex + 1) % 3 == 0) {
+                                        tangentsIndex++;
+                                    }
+                                }
+                                morph.setTangents(buffer);
+                            }
+                            else {
+                                BABYLON.Tools.Warn("Ignoring unrecognized semantic '" + semantic + "'");
+                            }
+                        }
+                        if (morph.getPositions() !== undefined) {
+                            morphTargetManager.addTarget(morph);
+                        }
+                        else {
+                            BABYLON.Tools.Warn("Not adding morph target '" + morph.name + "' because it has no position data");
+                        }
+                    }
+                }
                 // Update vertices start and index start
                 verticesStarts.push(verticesStarts.length === 0 ? 0 : verticesStarts[verticesStarts.length - 1] + verticesCounts[verticesCounts.length - 2]);
                 indexStarts.push(indexStarts.length === 0 ? 0 : indexStarts[indexStarts.length - 1] + indexCounts[indexCounts.length - 2]);
@@ -2972,13 +3032,17 @@ var BABYLON;
             // Apply geometry
             geometry.setAllVerticesData(vertexData, false);
             babylonMesh.computeWorldMatrix(true);
+            // Set morph target manager after all vertices data has been processed
+            if (morphTargetManager !== undefined && morphTargetManager.numInfluencers > 0) {
+                babylonMesh.morphTargetManager = morphTargetManager;
+            }
             // Apply submeshes
             babylonMesh.subMeshes = [];
-            for (var index = 0; index < mesh.primitives.length; index++) {
-                if (mesh.primitives[index].mode !== GLTF2.EMeshPrimitiveMode.TRIANGLES) {
+            for (var primitiveIndex = 0; primitiveIndex < mesh.primitives.length; primitiveIndex++) {
+                if (mesh.primitives[primitiveIndex].mode !== GLTF2.EMeshPrimitiveMode.TRIANGLES) {
                     //continue;
                 }
-                var subMesh = new BABYLON.SubMesh(index, verticesStarts[index], verticesCounts[index], indexStarts[index], indexCounts[index], babylonMesh, babylonMesh, true);
+                var subMesh = new BABYLON.SubMesh(primitiveIndex, verticesStarts[primitiveIndex], verticesCounts[primitiveIndex], indexStarts[primitiveIndex], indexCounts[primitiveIndex], babylonMesh, babylonMesh, true);
             }
             // Finish
             return babylonMesh;

Разница между файлами не показана из-за своего большого размера
+ 2 - 2
dist/preview release/loaders/babylon.glTFFileLoader.min.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 1
dist/preview release/loaders/babylon.objFileLoader.min.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 1
dist/preview release/materialsLibrary/babylon.waterMaterial.min.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.asciiArtPostProcess.min.js


Разница между файлами не показана из-за своего большого размера
+ 1 - 1
dist/preview release/postProcessesLibrary/babylon.digitalRainPostProcess.min.js


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

@@ -1,7 +1,7 @@
 /// <reference path="../../../dist/preview release/babylon.d.ts" />
 declare module BABYLON {
     class OBJExport {
-        static OBJ(mesh: Mesh, materials?: boolean, matlibname?: string): string;
+        static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
         static MTL(mesh: Mesh): string;
     }
 }

+ 44 - 26
dist/preview release/serializers/babylon.objSerializer.js

@@ -4,44 +4,62 @@ var BABYLON;
     var OBJExport = (function () {
         function OBJExport() {
         }
-        //Exports the geometry of a Mesh in .OBJ file format (text)
-        OBJExport.OBJ = function (mesh, materials, matlibname) {
+        //Exports the geometrys of a Mesh array in .OBJ file format (text)
+        OBJExport.OBJ = function (mesh, materials, matlibname, globalposition) {
             var output = [];
-            var g = mesh.geometry;
-            var trunkVerts = g.getVerticesData('position');
-            var trunkNormals = g.getVerticesData('normal');
-            var trunkUV = g.getVerticesData('uv');
-            var trunkFaces = g.getIndices();
+            var v = 1;
             if (materials) {
                 if (!matlibname) {
                     matlibname = 'mat';
                 }
                 output.push("mtllib " + matlibname + ".mtl");
             }
-            for (var i = 0; i < trunkVerts.length; i += 3) {
-                output.push("v " + trunkVerts[i] + " " + trunkVerts[i + 1] + " " + trunkVerts[i + 2]);
-            }
-            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]);
-            }
-            //TODO: submeshes (groups)
-            //TODO: smoothing groups (s 1, s off)
-            output.push("g gr1");
-            if (materials) {
-                output.push("usemtl mat1");
-            }
-            for (i = 0; i < trunkFaces.length; i += 3) {
-                output.push("f " + (trunkFaces[i + 2] + 1) + "/" + (trunkFaces[i + 2] + 1) + "/" + (trunkFaces[i + 2] + 1) +
-                    " " + (trunkFaces[i + 1] + 1) + "/" + (trunkFaces[i + 1] + 1) + "/" + (trunkFaces[i + 1] + 1) +
-                    " " + (trunkFaces[i] + 1) + "/" + (trunkFaces[i] + 1) + "/" + (trunkFaces[i] + 1));
+            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)
+                if (globalposition) {
+                    var newMatrix = BABYLON.Matrix.Translation(mesh[j].position.x, mesh[j].position.y, mesh[j].position.z);
+                    var 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) {
+                    output.push("usemtl " + mesh[j].material.id);
+                }
+                var g = mesh[j].geometry;
+                var trunkVerts = g.getVerticesData('position');
+                var trunkNormals = g.getVerticesData('normal');
+                var trunkUV = g.getVerticesData('uv');
+                var trunkFaces = g.getIndices();
+                var curV = 0;
+                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) {
+                    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;

Разница между файлами не показана из-за своего большого размера
+ 1 - 1
dist/preview release/serializers/babylon.objSerializer.min.js