From 9321b1d7ab2d23e165ac90e9eea3287f72463948 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 17 May 2012 09:51:11 -0700 Subject: Linear & radial gradients for runtime fixes --- assets/canvas-runtime.js | 6 ++++++ js/document/html-document.js | 4 ++-- js/io/system/ninjalibrary.json | 2 +- js/lib/rdge/materials/linear-gradient-material.js | 24 ++++++++++++++++++++--- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/assets/canvas-runtime.js b/assets/canvas-runtime.js index eeafaab6..b6682493 100644 --- a/assets/canvas-runtime.js +++ b/assets/canvas-runtime.js @@ -1456,6 +1456,8 @@ NinjaCvsRt.RuntimeRadialGradientMaterial = Object.create(NinjaCvsRt.RuntimeMater _colorStop3: { value: 0.6, writable: true }, _colorStop4: { value: 1.0, writable: true }, + _textureTransform: { value: [1,0,0, 0,1,0, 0,0,1], writable: true }, + init: { value: function(world) { var material = this._materialNode; @@ -1477,6 +1479,8 @@ NinjaCvsRt.RuntimeRadialGradientMaterial = Object.create(NinjaCvsRt.RuntimeMater this._shader["default"].u_colorStop3.set( [this._colorStop3] ); this._shader["default"].u_colorStop4.set( [this._colorStop4] ); + this._shader["default"].u_texTransform.set( this._textureTransform ); + if (this._angle !== undefined) this._shader["default"].u_cos_sin_angle.set([Math.cos(this._angle), Math.sin(this._angle)]); } @@ -1496,6 +1500,8 @@ NinjaCvsRt.RuntimeRadialGradientMaterial = Object.create(NinjaCvsRt.RuntimeMater this._colorStop3 = jObj.colorStop3; this._colorStop4 = jObj.colorStop4; + this._textureTransform = jObj.textureTransform; + if (this._angle !== undefined) this._angle = jObj.angle; } diff --git a/js/document/html-document.js b/js/document/html-document.js index 9d083dd8..61223499 100755 --- a/js/document/html-document.js +++ b/js/document/html-document.js @@ -209,8 +209,8 @@ exports.HTMLDocument = Montage.create(TextDocument, { { /* // Use this code to test the runtime version of WebGL - var cdm = new NinjaCvsRt.CanvasDataManager(); - cdm.loadGLData(elt, value, null ); + var cvsDataMngr = Object.create(NinjaCvsRt.CanvasDataManager, {}); + cvsDataMngr.loadGLData(elt, value); */ // /* diff --git a/js/io/system/ninjalibrary.json b/js/io/system/ninjalibrary.json index feced079..5bacb28a 100644 --- a/js/io/system/ninjalibrary.json +++ b/js/io/system/ninjalibrary.json @@ -1,6 +1,6 @@ { "libraries": [ {"name": "Montage", "path": "/node_modules/descriptor.json", "version": "0.8.0.0"}, - {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.6.0"} + {"name": "RDGE", "path": "/assets/descriptor.json", "version": "0.5.6.1"} ] } \ No newline at end of file diff --git a/js/lib/rdge/materials/linear-gradient-material.js b/js/lib/rdge/materials/linear-gradient-material.js index 79f323db..9b331fa7 100755 --- a/js/lib/rdge/materials/linear-gradient-material.js +++ b/js/lib/rdge/materials/linear-gradient-material.js @@ -26,6 +26,8 @@ var LinearGradientMaterial = function LinearGradientMaterial() { // this._colorCount = 4; this._angle = 0.0; // the shader takes [cos(a), sin(a)] + this._textureTransform = [1,0,0, 0,1,0, 0,0,1]; + /////////////////////////////////////////////////////////////////////// // Property Accessors /////////////////////////////////////////////////////////////////////// @@ -195,7 +197,21 @@ var LinearGradientMaterial = function LinearGradientMaterial() { // Methods /////////////////////////////////////////////////////////////////////// // duplcate method requirde - this.dup = function () { return new LinearGradientMaterial(); }; + this.dup = function () { + // allocate a new material + var newMat = new LinearGradientMaterial(); + + // copy over the current values; + var propNames = [], propValues = [], propTypes = [], propLabels = []; + this.getAllProperties( propNames, propValues, propTypes, propLabels); + var n = propNames.length; + for (var i=0; i