瀏覽代碼

Serializers Added to new gulp

sevan 8 年之前
父節點
當前提交
9480ef459d

+ 1 - 1
.vscode/settings.json

@@ -12,7 +12,7 @@
         "**/temp": true,
         "**/.temp": true,
         "**/*.js.map": true,
-        "**/*.fx.js": true,
+        "**/*.js.fx": true,
         "**/*.js": { 
             "when":"$(basename).ts"
         }

+ 4 - 2
serializers/OBJ/babylon.objSerializer.js

@@ -1,4 +1,4 @@
-/// <reference path="../babylon.d.ts"/>
+/// <reference path="../../../dist/preview release/babylon.d.ts"/>
 var BABYLON;
 (function (BABYLON) {
     var OBJExport = (function () {
@@ -83,6 +83,8 @@ var BABYLON;
             return (text);
         };
         return OBJExport;
-    })();
+    }());
     BABYLON.OBJExport = OBJExport;
 })(BABYLON || (BABYLON = {}));
+
+//# sourceMappingURL=babylon.objSerializer.js.map

文件差異過大導致無法顯示
+ 1 - 0
dist/preview release/serializers/babylon.objSerializer.min.js


+ 0 - 17
serializers/.gitignore

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

+ 0 - 102
serializers/OBJ/babylon.objSerializer.ts

@@ -1,102 +0,0 @@
-/// <reference path="../babylon.d.ts"/>
-module BABYLON {
- 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);
-        }
-    }
-}

+ 0 - 2
serializers/OBJ/readme.md

@@ -1,2 +0,0 @@
-## Babylon.js OBJ serializer
-

文件差異過大導致無法顯示
+ 0 - 6319
serializers/babylon.d.ts


+ 0 - 5
serializers/config.json

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

+ 0 - 38
serializers/gulpfile.js

@@ -1,38 +0,0 @@
-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']);
-});

+ 0 - 24
serializers/package.json

@@ -1,24 +0,0 @@
-{
-  "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"
-  }
-}

+ 7 - 0
serializers/src/tsconfig.json

@@ -0,0 +1,7 @@
+{
+  "compilerOptions": {
+    "experimentalDecorators": true,
+    "module": "commonjs",
+    "target": "es5"
+  }
+}