Selaa lähdekoodia

Fixed shader generation issue for canvas2d

David Catuhe 8 vuotta sitten
vanhempi
commit
5571ac40da

+ 68 - 0
canvas2D/gulp-srcToVariable.js

@@ -0,0 +1,68 @@
+var through = require('through2');
+var gutil = require('gulp-util');
+var PluginError = gutil.PluginError;
+var path = require('path');
+var File = gutil.File;
+
+// Consts
+const PLUGIN_NAME = 'gulp-srcToVariable';
+
+var srcToVariable = function srcToVariable(varName, asMap, namingCallback) {
+
+    var content;
+    var firstFile;
+
+    namingCallback = namingCallback || function (filename) { return filename; };
+
+    function bufferContents(file, enc, cb) {
+        // ignore empty files
+        if (file.isNull()) {
+            cb();
+            return;
+        }
+
+        // no stream support, only files.
+        if (file.isStream()) {
+            this.emit('error', new PluginError('gulp-concat', 'Streaming not supported'));
+            cb();
+            return;
+        }
+
+        // set first file if not already set
+        if (!firstFile) {
+            firstFile = file;
+        }
+
+        // construct concat instance
+        if (!content) {
+            content = "";
+        }
+        var name = namingCallback(file.relative);
+        content += varName + "['" + name + "'] = " + JSON.stringify(file.contents.toString()) + ";\r\n";
+        cb();
+    }
+
+    function endStream(cb) {
+        if (!firstFile || !content) {
+            cb();
+            return;
+        }
+
+        var joinedPath = path.join(firstFile.base, varName);
+
+        var joinedFile = new File({
+            cwd: firstFile.cwd,
+            base: firstFile.base,
+            path: joinedPath,
+            contents: new Buffer(content)
+        });
+
+        this.push(joinedFile);
+
+        cb();
+    }
+
+    return through.obj(bufferContents, endStream);
+}
+
+module.exports = srcToVariable;

+ 3 - 4
canvas2D/gulpfile.js

@@ -2,7 +2,7 @@ var gulp = require("gulp");
 var uglify = require("gulp-uglify");
 var typescript = require("gulp-typescript");
 var sourcemaps = require("gulp-sourcemaps");
-var srcToVariable = require("gulp-content-to-variable");
+var srcToVariable = require("./gulp-srcToVariable");
 var addModuleExports = require("./gulp-addModuleExports");
 var merge2 = require("merge2");
 var concat = require("gulp-concat");
@@ -34,9 +34,8 @@ gulp.task("shaders", function (cb) {
         return gulp.src(shadersDef.files).
             pipe(expect.real({ errorOnFailure: true }, shadersDef.files)).
             pipe(uncommentShader()).
-            pipe(srcToVariable({
-            variableName: shadersDef.variable, asMap: true, namingCallback: shadersName
-        }));
+            pipe(srcToVariable("BABYLON.Effect.ShadersStore", true, shadersName)
+            );
     });
     cb();
 });

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 3 - 3
dist/preview release/babylon.canvas2d.js


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 11 - 1
dist/preview release/babylon.canvas2d.max.js