Przeglądaj źródła

Adding new serializers folder

David catuhe 10 lat temu
rodzic
commit
bd40d34bd3

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


Plik diff jest za duży
+ 21 - 21
dist/preview release/babylon.js


+ 27 - 11
dist/preview release/babylon.max.js

@@ -4545,6 +4545,13 @@ var BABYLON;
                 reader.readAsArrayBuffer(fileToLoad);
             }
         };
+        //returns a downloadable url to a file content.
+        Tools.FileAsURL = function (content) {
+            var fileBlob = new Blob([content]);
+            var url = window.URL || window.webkitURL;
+            var link = url.createObjectURL(fileBlob);
+            return link;
+        };
         // Misc.   
         Tools.Clamp = function (value, min, max) {
             if (min === void 0) { min = 0; }
@@ -16157,13 +16164,14 @@ var BABYLON;
                 var returnRotation = function (i, distance) { return rotation; };
                 var rotate = custom ? rotateFunction : returnRotation;
                 var scl = custom ? scaleFunction : returnScale;
-                var index = (cap === Mesh.NO_CAP || cap === Mesh.CAP_END) ? 0 : 1;
+                var index = (cap === Mesh.NO_CAP || cap === Mesh.CAP_END) ? 0 : 2;
+                var rotationMatrix = BABYLON.Matrix.Zero();
                 for (var i = 0; i < curve.length; i++) {
                     var shapePath = new Array();
                     var angleStep = rotate(i, distances[i]);
                     var scaleRatio = scl(i, distances[i]);
                     for (var p = 0; p < shape.length; p++) {
-                        var rotationMatrix = BABYLON.Matrix.RotationAxis(tangents[i], angle);
+                        BABYLON.Matrix.RotationAxisToRef(tangents[i], angle, rotationMatrix);
                         var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
                         var rotated = BABYLON.Vector3.TransformCoordinates(planed, rotationMatrix).scaleInPlace(scaleRatio).add(curve[i]);
                         shapePath.push(rotated);
@@ -16190,14 +16198,18 @@ var BABYLON;
                     case Mesh.NO_CAP:
                         break;
                     case Mesh.CAP_START:
-                        shapePaths[0] = capPath(shapePaths[1]);
+                        shapePaths[0] = capPath(shapePaths[2]);
+                        shapePaths[1] = shapePaths[2].slice(0);
                         break;
                     case Mesh.CAP_END:
-                        shapePaths[index] = capPath(shapePaths[index - 1]);
+                        shapePaths[index] = shapePaths[index - 1];
+                        shapePaths[index + 1] = capPath(shapePaths[index - 1]);
                         break;
                     case Mesh.CAP_ALL:
-                        shapePaths[0] = capPath(shapePaths[1]);
-                        shapePaths[index] = capPath(shapePaths[index - 1]);
+                        shapePaths[0] = capPath(shapePaths[2]);
+                        shapePaths[1] = shapePaths[2].slice(0);
+                        shapePaths[index] = shapePaths[index - 1];
+                        shapePaths[index + 1] = capPath(shapePaths[index - 1]);
                         break;
                     default:
                         break;
@@ -16412,14 +16424,14 @@ var BABYLON;
                 var rad;
                 var normal;
                 var rotated;
-                var rotationMatrix;
-                var index = (cap === Mesh._NO_CAP || cap === Mesh.CAP_END) ? 0 : 1;
+                var rotationMatrix = BABYLON.Matrix.Zero();
+                var index = (cap === Mesh._NO_CAP || cap === Mesh.CAP_END) ? 0 : 2;
                 for (var i = 0; i < path.length; i++) {
                     rad = radiusFunctionFinal(i, distances[i]); // current radius
                     circlePath = Array(); // current circle array
                     normal = normals[i]; // current normal
                     for (var t = 0; t < tessellation; t++) {
-                        rotationMatrix = BABYLON.Matrix.RotationAxis(tangents[i], step * t);
+                        BABYLON.Matrix.RotationAxisToRef(tangents[i], step * t, rotationMatrix);
                         rotated = BABYLON.Vector3.TransformCoordinates(normal, rotationMatrix).scaleInPlace(rad).add(path[i]);
                         circlePath.push(rotated);
                     }
@@ -16439,13 +16451,17 @@ var BABYLON;
                         break;
                     case Mesh.CAP_START:
                         circlePaths[0] = capPath(tessellation, 0);
+                        circlePaths[1] = circlePaths[2].slice(0);
                         break;
                     case Mesh.CAP_END:
-                        circlePaths[index] = capPath(tessellation, path.length - 1);
+                        circlePaths[index] = circlePaths[index - 1].slice(0);
+                        circlePaths[index + 1] = capPath(tessellation, path.length - 1);
                         break;
                     case Mesh.CAP_ALL:
                         circlePaths[0] = capPath(tessellation, 0);
-                        circlePaths[index] = capPath(tessellation, path.length - 1);
+                        circlePaths[1] = circlePaths[2].slice(0);
+                        circlePaths[index] = circlePaths[index - 1].slice(0);
+                        circlePaths[index + 1] = capPath(tessellation, path.length - 1);
                         break;
                     default:
                         break;

Plik diff jest za duży
+ 21 - 21
dist/preview release/babylon.noworker.js


+ 1 - 0
dist/preview release/what's new.md

@@ -2,6 +2,7 @@
   - **Major updates**
     - New `StandardMaterial.lightmapTexture` which can be controlled with `StandardMaterial.lightmapThreshold`. [Demo here](#NEEDDEMO) ([deltakosh](https://github.com/deltakosh))
     - Support for reflection probes. [See documentation here](http://doc.babylonjs.com/tutorials/How_to_use_Reflection_probes) ([deltakosh](https://github.com/deltakosh))
+    - New serializers [folder](https://github.com/BabylonJS/Babylon.js/serializers) to host .babylon converter (like .obj) ([deltakosh](https://github.com/deltakosh))
   - **Updates**
     - New `Material.sideOrientation` property to define clockwise or counter-clockwise faces selection. [Demo here](http://www.babylonjs-playground.com/#1TZJQY) ([deltakosh](https://github.com/deltakosh))
     - It is now possible to create a custom loading screen [PR](https://github.com/BabylonJS/Babylon.js/pull/700) ([RaananW](https://github.com/RaananW))

+ 17 - 0
serializers/.gitignore

@@ -0,0 +1,17 @@
+#NodeJS
+node_modules
+
+
+# OS or Editor folders
+*.DS_Store
+._*
+Thumbs.db
+.cache
+.project
+.settings
+.tmproj
+nbproject
+*.sublime-project
+*.sublime-workspace
+.directory
+build

Plik diff jest za duży
+ 6319 - 0
serializers/babylon.d.ts


+ 5 - 0
serializers/config.json

@@ -0,0 +1,5 @@
+{
+  "typescript": [
+    "OBJ/babylon.objSerializer.ts"
+  ]
+}

+ 38 - 0
serializers/gulpfile.js

@@ -0,0 +1,38 @@
+var gulp = require("gulp");
+var uglify = require("gulp-uglify");
+var typescript = require("gulp-typescript");
+var sourcemaps = require("gulp-sourcemaps");
+var merge2 = require("merge2");
+var concat = require("gulp-concat");
+var rename = require("gulp-rename");
+var cleants = require('gulp-clean-ts-extends');
+var changed = require('gulp-changed');
+var runSequence = require('run-sequence');
+var replace = require("gulp-replace")
+
+var config = require("./config.json");
+
+/*
+Compiles all typescript files and creating a declaration file.
+*/
+gulp.task('default', function() {  
+    var tsResult = gulp.src(["**/*.ts", "!**/*.d.ts"])
+                .pipe(typescript({ 
+                    noExternalResolve: false, 
+                    target: 'ES5', 
+                    declarationFiles: true,
+                    typescript: require('typescript')
+                })).on('error', function(error) {
+                    console.log('Typescript compile failed');
+                    process.exit(1);
+                });
+                
+   return tsResult.js.pipe(gulp.dest("."));
+});
+
+/**
+ * Watch task, will call the default task if a js file is updated.
+ */
+gulp.task('watch', function() {
+  gulp.watch(config.core.typescript, ['default']);
+});

+ 24 - 0
serializers/package.json

@@ -0,0 +1,24 @@
+{
+  "name": "BabylonJS_Serializers",
+  "description": "Sserialization tools that you can use to generate different formats from .babylon",
+  "main": "",
+  "repository": { "url": "https://github.com/BabylonJS/Babylon.js/" },
+  "readme": "https://github.com/BabylonJS/Babylon.js/edit/master/serializers/readme.md",
+  "license": "(Apache-2.0)",
+  "devDependencies": {
+    "gulp": "^3.8.11",
+    "gulp-uglify": "~1.2.0",
+    "gulp-sourcemaps": "~1.5.2",
+    "typescript": "~1.6.2",
+    "gulp-typescript": "~2.9.0",
+    "through2": "~0.6.5",
+    "gulp-util": "~3.0.4",
+    "gulp-concat": "~2.5.2",
+    "merge2": "~0.3.5",
+    "gulp-rename": "~1.2.2",
+    "gulp-clean-ts-extends": "~0.1.1",
+    "gulp-changed": "~1.2.1",
+    "run-sequence": "~1.1.0",
+    "gulp-replace": "~0.5.3"
+  }
+}

+ 9 - 0
serializers/readme.md

@@ -0,0 +1,9 @@
+## Babylon.js serializers
+
+You will find here all serialization tools that you can use to generate different formats from .babylon
+
+To compile:
+```
+npm install
+gulp
+```

+ 20 - 11
src/Mesh/babylon.mesh.js

@@ -1465,13 +1465,14 @@ var BABYLON;
                 var returnRotation = function (i, distance) { return rotation; };
                 var rotate = custom ? rotateFunction : returnRotation;
                 var scl = custom ? scaleFunction : returnScale;
-                var index = (cap === Mesh.NO_CAP || cap === Mesh.CAP_END) ? 0 : 1;
+                var index = (cap === Mesh.NO_CAP || cap === Mesh.CAP_END) ? 0 : 2;
+                var rotationMatrix = BABYLON.Matrix.Zero();
                 for (var i = 0; i < curve.length; i++) {
                     var shapePath = new Array();
                     var angleStep = rotate(i, distances[i]);
                     var scaleRatio = scl(i, distances[i]);
                     for (var p = 0; p < shape.length; p++) {
-                        var rotationMatrix = BABYLON.Matrix.RotationAxis(tangents[i], angle);
+                        BABYLON.Matrix.RotationAxisToRef(tangents[i], angle, rotationMatrix);
                         var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
                         var rotated = BABYLON.Vector3.TransformCoordinates(planed, rotationMatrix).scaleInPlace(scaleRatio).add(curve[i]);
                         shapePath.push(rotated);
@@ -1498,14 +1499,18 @@ var BABYLON;
                     case Mesh.NO_CAP:
                         break;
                     case Mesh.CAP_START:
-                        shapePaths[0] = capPath(shapePaths[1]);
+                        shapePaths[0] = capPath(shapePaths[2]);
+                        shapePaths[1] = shapePaths[2].slice(0);
                         break;
                     case Mesh.CAP_END:
-                        shapePaths[index] = capPath(shapePaths[index - 1]);
+                        shapePaths[index] = shapePaths[index - 1];
+                        shapePaths[index + 1] = capPath(shapePaths[index - 1]);
                         break;
                     case Mesh.CAP_ALL:
-                        shapePaths[0] = capPath(shapePaths[1]);
-                        shapePaths[index] = capPath(shapePaths[index - 1]);
+                        shapePaths[0] = capPath(shapePaths[2]);
+                        shapePaths[1] = shapePaths[2].slice(0);
+                        shapePaths[index] = shapePaths[index - 1];
+                        shapePaths[index + 1] = capPath(shapePaths[index - 1]);
                         break;
                     default:
                         break;
@@ -1720,14 +1725,14 @@ var BABYLON;
                 var rad;
                 var normal;
                 var rotated;
-                var rotationMatrix;
-                var index = (cap === Mesh._NO_CAP || cap === Mesh.CAP_END) ? 0 : 1;
+                var rotationMatrix = BABYLON.Matrix.Zero();
+                var index = (cap === Mesh._NO_CAP || cap === Mesh.CAP_END) ? 0 : 2;
                 for (var i = 0; i < path.length; i++) {
                     rad = radiusFunctionFinal(i, distances[i]); // current radius
                     circlePath = Array(); // current circle array
                     normal = normals[i]; // current normal
                     for (var t = 0; t < tessellation; t++) {
-                        rotationMatrix = BABYLON.Matrix.RotationAxis(tangents[i], step * t);
+                        BABYLON.Matrix.RotationAxisToRef(tangents[i], step * t, rotationMatrix);
                         rotated = BABYLON.Vector3.TransformCoordinates(normal, rotationMatrix).scaleInPlace(rad).add(path[i]);
                         circlePath.push(rotated);
                     }
@@ -1747,13 +1752,17 @@ var BABYLON;
                         break;
                     case Mesh.CAP_START:
                         circlePaths[0] = capPath(tessellation, 0);
+                        circlePaths[1] = circlePaths[2].slice(0);
                         break;
                     case Mesh.CAP_END:
-                        circlePaths[index] = capPath(tessellation, path.length - 1);
+                        circlePaths[index] = circlePaths[index - 1].slice(0);
+                        circlePaths[index + 1] = capPath(tessellation, path.length - 1);
                         break;
                     case Mesh.CAP_ALL:
                         circlePaths[0] = capPath(tessellation, 0);
-                        circlePaths[index] = capPath(tessellation, path.length - 1);
+                        circlePaths[1] = circlePaths[2].slice(0);
+                        circlePaths[index] = circlePaths[index - 1].slice(0);
+                        circlePaths[index + 1] = capPath(tessellation, path.length - 1);
                         break;
                     default:
                         break;

+ 3 - 2
src/Mesh/babylon.mesh.ts

@@ -1905,7 +1905,7 @@
             return tiledGround;
         }
 
-        public static CreateGroundFromHeightMap(name: string, url: string, options: { width?: number, height?: number, subdivisions?: number, minHeight?: number, maxHeight?: number, updatable?: boolean, onReady?: (mesh: GroundMesh) => void}, scene: Scene);
+        public static CreateGroundFromHeightMap(name: string, url: string, options: { width?: number, height?: number, subdivisions?: number, minHeight?: number, maxHeight?: number, updatable?: boolean, onReady?: (mesh: GroundMesh) => void }, scene: Scene);
         public static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void);
         public static CreateGroundFromHeightMap(name: string, url: string, widthOrOptions?: any, heightorScene?: any, subdivisions?: number, minHeight?: number, maxHeight?: number, scene?: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void): GroundMesh {
             var width: number;
@@ -2070,7 +2070,7 @@
         }
 
         // Decals
-        public static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {position?: Vector3, normal?: Vector3, size?: Vector3, angle?: number});
+        public static CreateDecal(name: string, sourceMesh: AbstractMesh, options: { position?: Vector3, normal?: Vector3, size?: Vector3, angle?: number });
         public static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number);
         public static CreateDecal(name: string, sourceMesh: AbstractMesh, positionOrOptions: any, normal?: Vector3, size?: Vector3, angle: number = 0) {
             var indices = sourceMesh.getIndices();
@@ -2475,3 +2475,4 @@
 
 
 
+

+ 2 - 90
src/Tools/babylon.sceneSerializer.js

@@ -602,13 +602,10 @@ var BABYLON;
             var serializationInstance = {
                 name: instance.name,
                 position: instance.position.asArray(),
+                rotation: instance.rotation.asArray(),
+                rotationQuaternion: instance.rotationQuaternion.asArray(),
                 scaling: instance.scaling.asArray()
             };
-            if (instance.rotationQuaternion) {
-                serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
-            } else if (instance.rotation) {
-                serializationInstance.rotation = instance.rotation.asArray();
-            }
             serializationObject.instances.push(serializationInstance);
             // Animations
             appendAnimations(instance, serializationInstance);
@@ -805,89 +802,4 @@ var BABYLON;
         return SceneSerializer;
     })();
     BABYLON.SceneSerializer = SceneSerializer;
-    var OBJExport = (function () {
-        function OBJExport() {
-        }
-        //Exports the geometry of a Mesh in .OBJ file format (text)
-        OBJExport.OBJ = function (mesh, materials, matlibname) {
-            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();
-            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));
-            }
-            var text = output.join("\n");
-            return (text);
-        };
-        //Exports the material(s) of a mesh in .MTL file format (text)
-        OBJExport.MTL = function (mesh) {
-            var output = [];
-            var m = mesh.material;
-            console.log(m);
-            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);
-            }
-            if (m.specularTexture) {
-                output.push("  map_Ks " + 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 = {}));

+ 4 - 109
src/Tools/babylon.sceneSerializer.ts

@@ -720,16 +720,13 @@
         serializationObject.instances = [];
         for (var index = 0; index < mesh.instances.length; index++) {
             var instance = mesh.instances[index];
-            var serializationInstance : any = {
+            var serializationInstance = {
                 name: instance.name,
                 position: instance.position.asArray(),
+                rotation: instance.rotation.asArray(),
+                rotationQuaternion: instance.rotationQuaternion.asArray(),
                 scaling: instance.scaling.asArray()
             };
-            if (instance.rotationQuaternion) {
-                serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
-            } else if (instance.rotation) {
-                serializationInstance.rotation = instance.rotation.asArray();
-            }
             serializationObject.instances.push(serializationInstance);
 
             // Animations
@@ -954,112 +951,10 @@
             return serializationObject;
         }
     }
-
-    export class OBJExport {
-
-        //Exports the geometry of a Mesh in .OBJ file format (text)
-        public static OBJ(mesh:Mesh, materials?:boolean, matlibname?:string):string {
-            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();
-            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)
-                );
-            }
-            var text = output.join("\n");
-            return (text);
-        }
-
-        //Exports the material(s) of a mesh in .MTL file format (text)
-        public static MTL(mesh:Mesh):string {
-            var output = [];
-            var m = <StandardMaterial>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);
-        }
-
-    }
-
 }
 
 
 
 
 
+

+ 3 - 3
src/Tools/babylon.tools.ts

@@ -342,10 +342,10 @@
         }
 
         //returns a downloadable url to a file content.
-        public static FileAsURL(content:string): string {
+        public static FileAsURL(content: string): string {
             var fileBlob = new Blob([content]);
             var url = window.URL || window.webkitURL;
-            var link:string = url.createObjectURL(fileBlob);
+            var link: string = url.createObjectURL(fileBlob);
             return link;
         }
 
@@ -941,4 +941,4 @@
             }, callback);
         }
     }
-} 
+}