From 6321075d93044c6747682a8e7280b5996da7ec52 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 2 Feb 2012 11:57:58 -0800 Subject: added some additional shaders --- js/helper-classes/RDGE/Materials/DeformMaterial.js | 133 +++++++++++++++++++++ js/helper-classes/RDGE/Materials/FlyMaterial.js | 133 +++++++++++++++++++++ .../RDGE/Materials/ReliefTunnelMaterial.js | 133 +++++++++++++++++++++ .../RDGE/Materials/SquareTunnelMaterial.js | 133 +++++++++++++++++++++ js/helper-classes/RDGE/Materials/StarMaterial.js | 133 +++++++++++++++++++++ js/helper-classes/RDGE/Materials/WaterMaterial.js | 133 +++++++++++++++++++++ .../RDGE/Materials/ZInvertMaterial.js | 133 +++++++++++++++++++++ js/helper-classes/RDGE/MaterialsLibrary.js | 21 ++++ js/panels/Materials/Materials.xml | 7 ++ .../materials-popup.reel/materials-popup.js | 7 ++ js/preloader/Preloader.js | 7 ++ 11 files changed, 973 insertions(+) create mode 100644 js/helper-classes/RDGE/Materials/DeformMaterial.js create mode 100644 js/helper-classes/RDGE/Materials/FlyMaterial.js create mode 100644 js/helper-classes/RDGE/Materials/ReliefTunnelMaterial.js create mode 100644 js/helper-classes/RDGE/Materials/SquareTunnelMaterial.js create mode 100644 js/helper-classes/RDGE/Materials/StarMaterial.js create mode 100644 js/helper-classes/RDGE/Materials/WaterMaterial.js create mode 100644 js/helper-classes/RDGE/Materials/ZInvertMaterial.js (limited to 'js') diff --git a/js/helper-classes/RDGE/Materials/DeformMaterial.js b/js/helper-classes/RDGE/Materials/DeformMaterial.js new file mode 100644 index 00000000..ddc97383 --- /dev/null +++ b/js/helper-classes/RDGE/Materials/DeformMaterial.js @@ -0,0 +1,133 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + + + +/////////////////////////////////////////////////////////////////////// +// Class GLMaterial +// RDGE representation of a material. +/////////////////////////////////////////////////////////////////////// +function DeformMaterial() +{ + // initialize the inherited members + this.inheritedFrom = PulseMaterial; + this.inheritedFrom(); + + /////////////////////////////////////////////////////////////////////// + // Instance variables + /////////////////////////////////////////////////////////////////////// + this._name = "DeformMaterial"; + this._shaderName = "deform"; + + this._texMap = 'assets/images/rocky-normal.jpg'; + + this._time = 0.0; + this._dTime = 0.01; + + /////////////////////////////////////////////////////////////////////// + // Properties + /////////////////////////////////////////////////////////////////////// + // all defined in parent PulseMaterial.js + // load the local default value + this._propValues[ this._propNames[0] ] = this._texMap.slice(0); + + /////////////////////////////////////////////////////////////////////// + // Material Property Accessors + /////////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////////// + + + /////////////////////////////////////////////////////////////////////// + // Methods + /////////////////////////////////////////////////////////////////////// + // duplcate method requirde + this.dup = function( world ) + { + // allocate a new uber material + var newMat = new DeformMaterial(); + + // 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 + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. + */ + + + +/////////////////////////////////////////////////////////////////////// +// Class GLMaterial +// RDGE representation of a material. +/////////////////////////////////////////////////////////////////////// +function FlyMaterial() +{ + // initialize the inherited members + this.inheritedFrom = PulseMaterial; + this.inheritedFrom(); + + /////////////////////////////////////////////////////////////////////// + // Instance variables + /////////////////////////////////////////////////////////////////////// + this._name = "FlyMaterial"; + this._shaderName = "tunnel"; + + this._texMap = 'assets/images/rocky-normal.jpg'; + + this._time = 0.0; + this._dTime = 0.01; + + /////////////////////////////////////////////////////////////////////// + // Properties + /////////////////////////////////////////////////////////////////////// + // all defined in parent PulseMaterial.js + // load the local default value + this._propValues[ this._propNames[0] ] = this._texMap.slice(0); + + /////////////////////////////////////////////////////////////////////// + // Material Property Accessors + /////////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////////// + + + /////////////////////////////////////////////////////////////////////// + // Methods + /////////////////////////////////////////////////////////////////////// + // duplcate method requirde + this.dup = function( world ) + { + // allocate a new uber material + var newMat = new FlyMaterial(); + + // 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 + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. + */ + + + +/////////////////////////////////////////////////////////////////////// +// Class GLMaterial +// RDGE representation of a material. +/////////////////////////////////////////////////////////////////////// +function ReliefTunnelMaterial() +{ + // initialize the inherited members + this.inheritedFrom = PulseMaterial; + this.inheritedFrom(); + + /////////////////////////////////////////////////////////////////////// + // Instance variables + /////////////////////////////////////////////////////////////////////// + this._name = "ReliefTunnelMaterial"; + this._shaderName = "tunnel"; + + this._texMap = 'assets/images/rocky-normal.jpg'; + + this._time = 0.0; + this._dTime = 0.01; + + /////////////////////////////////////////////////////////////////////// + // Properties + /////////////////////////////////////////////////////////////////////// + // all defined in parent PulseMaterial.js + // load the local default value + this._propValues[ this._propNames[0] ] = this._texMap.slice(0); + + /////////////////////////////////////////////////////////////////////// + // Material Property Accessors + /////////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////////// + + + /////////////////////////////////////////////////////////////////////// + // Methods + /////////////////////////////////////////////////////////////////////// + // duplcate method requirde + this.dup = function( world ) + { + // allocate a new uber material + var newMat = new ReliefTunnelMaterial(); + + // 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 + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. + */ + + + +/////////////////////////////////////////////////////////////////////// +// Class GLMaterial +// RDGE representation of a material. +/////////////////////////////////////////////////////////////////////// +function SquareTunnelMaterial() +{ + // initialize the inherited members + this.inheritedFrom = PulseMaterial; + this.inheritedFrom(); + + /////////////////////////////////////////////////////////////////////// + // Instance variables + /////////////////////////////////////////////////////////////////////// + this._name = "SquareTunnelMaterial"; + this._shaderName = "tunnel"; + + this._texMap = 'assets/images/rocky-normal.jpg'; + + this._time = 0.0; + this._dTime = 0.01; + + /////////////////////////////////////////////////////////////////////// + // Properties + /////////////////////////////////////////////////////////////////////// + // all defined in parent PulseMaterial.js + // load the local default value + this._propValues[ this._propNames[0] ] = this._texMap.slice(0); + + /////////////////////////////////////////////////////////////////////// + // Material Property Accessors + /////////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////////// + + + /////////////////////////////////////////////////////////////////////// + // Methods + /////////////////////////////////////////////////////////////////////// + // duplcate method requirde + this.dup = function( world ) + { + // allocate a new uber material + var newMat = new SquareTunnelMaterial(); + + // 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 + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. + */ + + + +/////////////////////////////////////////////////////////////////////// +// Class GLMaterial +// RDGE representation of a material. +/////////////////////////////////////////////////////////////////////// +function StarMaterial() +{ + // initialize the inherited members + this.inheritedFrom = PulseMaterial; + this.inheritedFrom(); + + /////////////////////////////////////////////////////////////////////// + // Instance variables + /////////////////////////////////////////////////////////////////////// + this._name = "StarMaterial"; + this._shaderName = "star"; + + this._texMap = 'assets/images/rocky-normal.jpg'; + + this._time = 0.0; + this._dTime = 0.01; + + /////////////////////////////////////////////////////////////////////// + // Properties + /////////////////////////////////////////////////////////////////////// + // all defined in parent PulseMaterial.js + // load the local default value + this._propValues[ this._propNames[0] ] = this._texMap.slice(0); + + /////////////////////////////////////////////////////////////////////// + // Material Property Accessors + /////////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////////// + + + /////////////////////////////////////////////////////////////////////// + // Methods + /////////////////////////////////////////////////////////////////////// + // duplcate method requirde + this.dup = function( world ) + { + // allocate a new uber material + var newMat = new StarMaterial(); + + // 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 + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. + */ + + + +/////////////////////////////////////////////////////////////////////// +// Class GLMaterial +// RDGE representation of a material. +/////////////////////////////////////////////////////////////////////// +function WaterMaterial() +{ + // initialize the inherited members + this.inheritedFrom = PulseMaterial; + this.inheritedFrom(); + + /////////////////////////////////////////////////////////////////////// + // Instance variables + /////////////////////////////////////////////////////////////////////// + this._name = "WaterMaterial"; + this._shaderName = "water"; + + this._texMap = 'assets/images/rocky-normal.jpg'; + + this._time = 0.0; + this._dTime = 0.01; + + /////////////////////////////////////////////////////////////////////// + // Properties + /////////////////////////////////////////////////////////////////////// + // all defined in parent PulseMaterial.js + // load the local default value + this._propValues[ this._propNames[0] ] = this._texMap.slice(0); + + /////////////////////////////////////////////////////////////////////// + // Material Property Accessors + /////////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////////// + + + /////////////////////////////////////////////////////////////////////// + // Methods + /////////////////////////////////////////////////////////////////////// + // duplcate method requirde + this.dup = function( world ) + { + // allocate a new uber material + var newMat = new WaterMaterial(); + + // 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 + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. + */ + + + +/////////////////////////////////////////////////////////////////////// +// Class GLMaterial +// RDGE representation of a material. +/////////////////////////////////////////////////////////////////////// +function ZInvertMaterial() +{ + // initialize the inherited members + this.inheritedFrom = PulseMaterial; + this.inheritedFrom(); + + /////////////////////////////////////////////////////////////////////// + // Instance variables + /////////////////////////////////////////////////////////////////////// + this._name = "ZInvertMaterial"; + this._shaderName = "zinvert"; + + this._texMap = 'assets/images/rocky-normal.jpg'; + + this._time = 0.0; + this._dTime = 0.01; + + /////////////////////////////////////////////////////////////////////// + // Properties + /////////////////////////////////////////////////////////////////////// + // all defined in parent PulseMaterial.js + // load the local default value + this._propValues[ this._propNames[0] ] = this._texMap.slice(0); + + /////////////////////////////////////////////////////////////////////// + // Material Property Accessors + /////////////////////////////////////////////////////////////////////// + + /////////////////////////////////////////////////////////////////////// + + + /////////////////////////////////////////////////////////////////////// + // Methods + /////////////////////////////////////////////////////////////////////// + // duplcate method requirde + this.dup = function( world ) + { + // allocate a new uber material + var newMat = new ZInvertMaterial(); + + // 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 + + + + + + + diff --git a/js/panels/Materials/materials-popup.reel/materials-popup.js b/js/panels/Materials/materials-popup.reel/materials-popup.js index afdc3628..bce2e42b 100644 --- a/js/panels/Materials/materials-popup.reel/materials-popup.js +++ b/js/panels/Materials/materials-popup.reel/materials-popup.js @@ -246,6 +246,13 @@ exports.MaterialsPopup = Montage.create(Component, { (materialID === "RadialBlurMaterial") || (materialID === "PulseMaterial") || (materialID === "TunnelMaterial") || + (materialID === "ReliefTunnelMaterial") || + (materialID === "SquareTunnelMaterial") || + (materialID === "FlyMaterial") || + (materialID === "WaterMaterial") || + (materialID === "ZInvertMaterial") || + (materialID === "DeformMaterial") || + (materialID === "StarMaterial") || (materialID === "TwistMaterial") || (materialID === "KeleidoscopeMaterial") || (materialID === "JuliaMaterial") || diff --git a/js/preloader/Preloader.js b/js/preloader/Preloader.js index 3daeb1b4..12028e32 100755 --- a/js/preloader/Preloader.js +++ b/js/preloader/Preloader.js @@ -70,6 +70,13 @@ exports.Preloader = Montage.create(Component, { {"type":"js", "url":"js/helper-classes/RDGE/Materials/RadialBlurMaterial.js"}, {"type":"js", "url":"js/helper-classes/RDGE/Materials/PulseMaterial.js"}, {"type":"js", "url":"js/helper-classes/RDGE/Materials/TunnelMaterial.js"}, + {"type":"js", "url":"js/helper-classes/RDGE/Materials/ReliefTunnelMaterial.js"}, + {"type":"js", "url":"js/helper-classes/RDGE/Materials/SquareTunnelMaterial.js"}, + {"type":"js", "url":"js/helper-classes/RDGE/Materials/FlyMaterial.js"}, + {"type":"js", "url":"js/helper-classes/RDGE/Materials/WaterMaterial.js"}, + {"type":"js", "url":"js/helper-classes/RDGE/Materials/ZInvertMaterial.js"}, + {"type":"js", "url":"js/helper-classes/RDGE/Materials/DeformMaterial.js"}, + {"type":"js", "url":"js/helper-classes/RDGE/Materials/StarMaterial.js"}, {"type":"js", "url":"js/helper-classes/RDGE/Materials/TwistMaterial.js"}, {"type":"js", "url":"js/helper-classes/RDGE/Materials/KeleidoscopeMaterial.js"}, {"type":"js", "url":"js/helper-classes/RDGE/Materials/JuliaMaterial.js"}, -- cgit v1.2.3 From 4ebae7378608750192f8d3bb392a54222ca0ec2f Mon Sep 17 00:00:00 2001 From: hwc487 Date: Thu, 2 Feb 2012 13:56:25 -0800 Subject: Added the 'animate' flag to the pulse material --- js/helper-classes/RDGE/Materials/RadialBlurMaterial.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'js') diff --git a/js/helper-classes/RDGE/Materials/RadialBlurMaterial.js b/js/helper-classes/RDGE/Materials/RadialBlurMaterial.js index 9acb4213..732800cf 100644 --- a/js/helper-classes/RDGE/Materials/RadialBlurMaterial.js +++ b/js/helper-classes/RDGE/Materials/RadialBlurMaterial.js @@ -37,6 +37,8 @@ function RadialBlurMaterial() this.getTextureMap = function() { return this._texMap.slice(0); } this.setTextureMap = function(m) { this._propValues[this._propNames[0]] = m.slice(0); this.updateTexture(); } + this.isAnimated = function() { return true; } + /////////////////////////////////////////////////////////////////////// // Material Property Accessors /////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 2082fa6912eec2ffabd2081b7706e8e1b88a9711 Mon Sep 17 00:00:00 2001 From: Armen Kesablyan Date: Thu, 2 Feb 2012 19:03:59 -0800 Subject: Initial Text Tool Implementation Has rich-text-editor in place need to place with finalized version when complete --- js/panels/CSSPanel/CSSPanel.js | 6 +-- js/stage/stage.reel/stage.html | 12 +++++- js/stage/stage.reel/stage.js | 7 +++ js/tools/TextTool.js | 96 +++++++++++++++++++++++++++++++++++++++--- 4 files changed, 111 insertions(+), 10 deletions(-) (limited to 'js') diff --git a/js/panels/CSSPanel/CSSPanel.js b/js/panels/CSSPanel/CSSPanel.js index 94860b30..cf8880a3 100644 --- a/js/panels/CSSPanel/CSSPanel.js +++ b/js/panels/CSSPanel/CSSPanel.js @@ -20,9 +20,9 @@ exports.CSSPanel = Montage.create(PanelBase, { init : { enumerable:true, value : function (){ - this.minHeight = 300; - this.contentHeight = 300; - this.defaultHeight= 300; + this.minHeight = 195; + this.contentHeight = 195; + this.defaultHeight= 195; /* OLD WAY -- Removing the temporary div // TODO: Remove this comment once this is tested. diff --git a/js/stage/stage.reel/stage.html b/js/stage/stage.reel/stage.html index 49d10baf..07b823a7 100644 --- a/js/stage/stage.reel/stage.html +++ b/js/stage/stage.reel/stage.html @@ -34,6 +34,14 @@ } } }, + + "textTool": { + "module": "montage/ui/rich-text-editor.reel", + "name": "RichTextEditor", + "properties": { + "element" : {"#": "textToolObject"} + } + }, "owner": { "module": "js/stage/stage.reel", @@ -46,7 +54,8 @@ "_canvas": {"#": "stageCanvas"}, "_drawingCanvas": {"#": "drawingCanvas"}, "stageDeps": {"@": "StageDeps1"}, - "layout": {"@": "layout1"} + "layout": {"@": "layout1"}, + "textTool": {"@": "textTool"} }, "bindings": { "currentDocumentStageView": { @@ -64,6 +73,7 @@
+
asdasd asd asd asd asd asd
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 3e0b852e..96bfccdd 100644 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js @@ -12,6 +12,7 @@ var vecUtils = require("js/helper-classes/3D/vec-utils").VecUtils; exports.Stage = Montage.create(Component, { + textTool: { value: null }, // TODO - Need to figure out how to remove this dependency // Needed by some tools that depend on selectionDrawn event to set up some logic drawNow: { value : false }, @@ -780,6 +781,12 @@ exports.Stage = Montage.create(Component, { } }, + toViewportCoordinates: { + value: function(x,y) { + return [x + this._userContentLeft, y + this._userContentTop]; + } + }, + setZoom: { value: function(value) { if(!this._firstDraw) diff --git a/js/tools/TextTool.js b/js/tools/TextTool.js index 538583ee..8b48ff4f 100644 --- a/js/tools/TextTool.js +++ b/js/tools/TextTool.js @@ -6,12 +6,30 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot var Montage = require("montage/core/core").Montage, DrawingTool = require("js/tools/drawing-tool").DrawingTool; + RichTextEditor = require("montage/ui/rich-text-editor.reel").RichTextEditor; exports.TextTool = Montage.create(DrawingTool, { + + _selectedElement: { value : null }, + + selectedElement: { + get: function() { + return this._selectedElement; + }, + set: function(val) { + if(this._selectedElement !== null) { + + } + this._selectedElement = val; + } + }, + + drawingFeedback: { value: { mode: "Draw3D", type: "rectangle" } }, HandleLeftButtonDown: { value: function(event) { + this.deselectText(); this.startDraw(event); } }, @@ -50,24 +68,88 @@ exports.TextTool = Montage.create(DrawingTool, { if(drawData) { //this.insertElement(drawData); } - + this._hasDraw = false; this.endDraw(event); } else { - this.doSelection(event); + console.log("im here"); + if (this.application.ninja.selectedElements.length !== 0 ) { + this.selectedElement = this.application.ninja.selectedElements[0]._element; + this.drawTextTool(); + } this._isDrawing = false; } } }, + applyElementStyles : { + value: function(fromElement, toElement, styles) { + styles.forEach(function(style) { + var styleCamelCase = style.replace(/(\-[a-z])/g, function($1){return $1.toUpperCase().replace('-','');}); + console.log(styleCamelCase, style, window.getComputedStyle(fromElement)[style]); + toElement.style[styleCamelCase] = window.getComputedStyle(fromElement)[style]; + }, this); + } + }, + + drawTextTool: { + value: function() { + console.log(" now im here"); + this.application.ninja.stage.textTool.value = this.selectedElement.innerHTML; + if(this.application.ninja.stage.textTool.value === "") { this.application.ninja.stage.textTool.value = " "; } + this.selectedElement.innerHTML = ""; + + //Styling Options for text tool to look identical to the text you are manipulating. + this.application.ninja.stage.textTool.element.style.display = "block"; + this.application.ninja.stage.textTool.element.style.position = "absolute"; + + // Set Top & Left Positions + var textToolCoordinates = this.application.ninja.stage.toViewportCoordinates(this.selectedElement.offsetLeft, this.selectedElement.offsetTop); + this.application.ninja.stage.textTool.element.style.left = textToolCoordinates[0] + "px"; + this.application.ninja.stage.textTool.element.style.top = textToolCoordinates[1] + "px"; + + // Set Width, Height + this.application.ninja.stage.textTool.element.style.width = this.selectedElement.offsetWidth + "px"; + this.application.ninja.stage.textTool.element.style.height = this.selectedElement.offsetHeight + "px"; + + + // Set font styling (Size, Style, Weight) + + me = this; + this.application.ninja.stage.textTool.didDraw = function() { + me.applyElementStyles(me.selectedElement, me.application.ninja.stage.textTool.element, ["overflow"]); + me.applyElementStyles(me.selectedElement, me.application.ninja.stage.textTool.element.firstChild, ["font","padding-left","padding-top","padding-right","padding-bottom", "color"]); + var range = document.createRange(), + sel = window.getSelection(); + sel.removeAllRanges(); + range.selectNodeContents(this.application.ninja.stage.textTool.element.firstChild); + sel.addRange(range); + this.didDraw = function() {}; + console.log("im drew here"); + } + console.log("i end here"); + } + }, + + + deselectText: { + value: function() { + this.application.ninja.stage.textTool.element.style.display = "none"; + this.selectedElement.innerHTML = this.application.ninja.stage.textTool.value; + this.application.ninja.stage.textTool.value = ""; + } + }, + HandleDoubleClick: { value: function(e) { - console.log(this.application.ninja.selectedElements[0]._element); - this.application.ninja.selectedElements[0]._element.setAttribute("contenteditable", true); - this.application.ninja.stage._iframeContainer.style.zIndex = 200; - this.application.ninja.selectedElements[0]._element.focus(); + //this.application.ninja.selectedElements[0]._element.setAttribute("contenteditable", true); + + //if (!this.application.ninja.textTool) { + + //} + } @@ -75,10 +157,12 @@ exports.TextTool = Montage.create(DrawingTool, { Configure: { value: function(wasSelected) { + if(wasSelected) { NJevent("enableStageMove"); this.application.ninja.stage.stageDeps.snapManager.setupDragPlaneFromPlane( workingPlane ); } else { + this.deselectText(); NJevent("disableStageMove"); } } -- cgit v1.2.3 From 3d5b5f7c5efb25b5e605d5d120b57f2dde33fd23 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Fri, 3 Feb 2012 15:18:45 -0800 Subject: Added a counter to the renderer that tracks the number of unloaded texture maps. Started vertex deformations. --- js/helper-classes/RDGE/GLMaterial.js | 11 ++ js/helper-classes/RDGE/GLRectangle.js | 148 +++++++++++++++++++-- js/helper-classes/RDGE/GLWorld.js | 25 ++-- js/helper-classes/RDGE/Materials/FlatMaterial.js | 1 + .../RDGE/Materials/LinearGradientMaterial.js | 4 +- js/helper-classes/RDGE/src/core/script/renderer.js | 13 ++ 6 files changed, 178 insertions(+), 24 deletions(-) (limited to 'js') diff --git a/js/helper-classes/RDGE/GLMaterial.js b/js/helper-classes/RDGE/GLMaterial.js index c633f679..07a98ab5 100644 --- a/js/helper-classes/RDGE/GLMaterial.js +++ b/js/helper-classes/RDGE/GLMaterial.js @@ -31,6 +31,11 @@ function GLMaterial( world ) this._texture; + // vertex deformation variables + this._hasVertexDeformation = false; + this._vertexDeformationRange = [0, 0, 1, 1]; // (xMin, yMin, xMax, yMax) + this._vertexDeformationTolerance = 0.05; + // RDGE variables this._shader; this._materialNode; @@ -66,6 +71,12 @@ function GLMaterial( world ) // Any material needing continuous rendering should override this method this.isAnimated = function() { return false; } + // the vertex shader can apply deformations requiring refinement in + // certain areas. + this.hasVertexDeformation = function() { return this._hasVertexDeformation; } + this.getVertexDeformationRange = function() { return this._vertexDeformationRange.slice(); } + this.getVertexDeformationTolerance = function() { return this._vertexDeformationTolerance; } + /////////////////////////////////////////////////////////////////////// // Common Material Methods diff --git a/js/helper-classes/RDGE/GLRectangle.js b/js/helper-classes/RDGE/GLRectangle.js index 1bb4bcac..e72b4488 100644 --- a/js/helper-classes/RDGE/GLRectangle.js +++ b/js/helper-classes/RDGE/GLRectangle.js @@ -280,7 +280,7 @@ function GLRectangle() // stroke var strokeMaterial = this.makeStrokeMaterial(); - prim = this.createStroke([x,y], 2*xFill, 2*yFill, strokeSize, tlRadius, blRadius, brRadius, trRadius, strokeMaterial) + prim = this.createStroke([x,y], 2*xFill, 2*yFill, strokeSize, tlRadius, blRadius, brRadius, trRadius); this._primArray.push( prim ); this._materialNodeArray.push( strokeMaterial.getMaterialNode() ); @@ -486,7 +486,7 @@ function GLRectangle() this.createStroke = function(ctr, width, height, strokeWidth, tlRad, blRad, brRad, trRad, material) { // create the geometry - var prim = RectangleStroke.create( ctr, width, height, strokeWidth, tlRad, blRad, brRad, trRad) + var prim = RectangleStroke.create( ctr, width, height, strokeWidth, tlRad, blRad, brRad, trRad, material) return prim; } @@ -496,9 +496,9 @@ function GLRectangle() // special the (common) case of no rounded corners var prim if ((tlRad <= 0) && (blRad <= 0) && (brRad <= 0) && (trRad <= 0)) - prim = RectangleGeometry.create( ctr, width, height ); + prim = RectangleGeometry.create( ctr, width, height, material ); else - prim = RectangleFill.create( ctr, width, height, tlRad, blRad, brRad, trRad); + prim = RectangleFill.create( ctr, width, height, tlRad, blRad, brRad, trRad, material); return prim; } @@ -747,7 +747,7 @@ function GLRectangle() } RectangleFill = {}; -RectangleFill.create = function( rectCtr, width, height, tlRad, blRad, brRad, trRad) +RectangleFill.create = function( rectCtr, width, height, tlRad, blRad, brRad, trRad, material) { var x = rectCtr[0], y = rectCtr[1], z = 0.0; var hw = 0.5*width, hh = 0.5*height; @@ -834,6 +834,17 @@ RectangleFill.create = function( rectCtr, width, height, tlRad, blRad, brRad, j++; } + //refine the mesh for vertex deformations + if (material) + { + if (material.hasVertexDeformation()) + { + var paramRange = material.getVertexDeformationRange(); + var tolerance = material.getVertexDeformationTolerance(); + nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); + } + } + // create the RDGE primitive var prim = ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); return prim; @@ -906,7 +917,7 @@ RectangleFill.getRoundedCorner = function(ctr, startPt, vertices) RectangleStroke = {}; -RectangleStroke.create = function( rectCtr, width, height, strokeWidth, tlRad, blRad, brRad, trRad) +RectangleStroke.create = function( rectCtr, width, height, strokeWidth, tlRad, blRad, brRad, trRad, material) { var x = rectCtr[0], y = rectCtr[1], z = 0.0; var hw = 0.5*width, hh = 0.5*height, sw = strokeWidth; @@ -1097,6 +1108,17 @@ RectangleStroke.create = function( rectCtr, width, height, strokeWidth, tlRad, k++; } + //refine the mesh for vertex deformations + if (material) + { + if (material.hasVertexDeformation()) + { + var paramRange = material.getVertexDeformationRange(); + var tolerance = material.getVertexDeformationTolerance(); + nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); + } + } + // create the RDGE primitive var prim = ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); return prim; @@ -1141,7 +1163,7 @@ RectangleStroke.getUV = RectangleFill.getUV; // Helper function for generating Three.js geometry RectangleGeometry = {}; -RectangleGeometry.create = function( ctr, width, height ) +RectangleGeometry.create = function( ctr, width, height, material ) { var x = ctr[0], y = ctr[1], z = 0.0; var hw = 0.5*width, hh = 0.5*height; @@ -1179,6 +1201,17 @@ RectangleGeometry.create = function( ctr, width, height ) RectangleGeometry.pushIndices( 2, 1, 0 ); RectangleGeometry.pushIndices( 0, 3, 2 ); + //refine the mesh for vertex deformations + if (material) + { + if (material.hasVertexDeformation()) + { + var paramRange = material.getVertexDeformationRange(); + var tolerance = material.getVertexDeformationTolerance(); + nVertices = ShapePrimitive.refineMesh( this.vertices, this.normals, this.uvs, this.indices, nVertices, paramRange, tolerance ); + } + } + // create the RDGE primitive var prim = ShapePrimitive.create(this.vertices, this.normals, this.uvs, this.indices, g_Engine.getContext().renderer.TRIANGLES, nVertices); return prim; @@ -1249,4 +1282,103 @@ ShapePrimitive.create = function(coords, normals, uvs, indices, primType, ver renderer.createPrimitive(prim, vertexCount); return prim; -} \ No newline at end of file +} + + +ShapePrimitive.refineMesh = function( verts, norms, uvs, indices, nVertices, paramRange, tolerance ) +{ + // get the param range + var pUMin = paramRange[0], pVMin = paramRange[1], + pUMax = paramRange[2], pVMax = paramRange[3]; + var iTriangle = 0; + var nTriangles = indices.length/3; + var index = 0; + while (iTriangle < nTriangles) + { + // get the indices of the 3 vertices + var i0 = indices[index], + i1 = indices[index+1], + i2 = indices[index+2]; + + // get the uv values + var vrtIndex = 3*iTriangle; + var iuv0 = 2 * i0, + iuv1 = 2 * i1, + iuv2 = 2 * i2; + var u0 = uvs[iuv0], v0 = uvs[iuv0+1], + u1 = uvs[iuv1], v1 = uvs[iuv1+1], + u2 = uvs[iuv2], v2 = uvs[iuv2+1]; + + // find the u and v range + var uMin = u0, vMin = v0; + if (u1 < uMin) uMin = u1; if (v1 < vMin) vMin = v1; + if (u2 < uMin) uMin = u2; if (v2 < vMin) vMin = v2; + var uMax = u0, vMax = v0; + if (u1 > uMax) uMax = u1; if (v1 > vMax) vMax = v1; + if (u2 > uMax) uMax = u2; if (v2 > vMax) vMax = v2; + + // if the parameter range of the triangle is outside the + // desired parameter range, advance to the next polygon and continue + if ((uMin > pUMax) || (uMax < pUMin) || (vMin > pVMax) || (vMax < pVMin)) + { + // go to the next triangle + iTriangle++; + index += 3; + } + else + { + // check thesize of the triangle in uv space. If small enough, advance + // to the next triangle. If not small enough, split the triangle into 3; + var du = uMax - uMin, dv = vMax - vMin; + if ((du < tolerance) && (dv < tolerance)) + { + iTriangle++; + index += 3; + } + else // split the triangle + { + //calculate the position of the new vertex + var iPt0 = 3 * i0, + iPt1 = 3 * i1, + iPt2 = 3 * i2; + var x0 = verts[iPt0], y0 = verts[iPt0+1], z0 = verts[iPt0+2], + x1 = verts[iPt1], y1 = verts[iPt1+1], z1 = verts[iPt1+2], + x2 = verts[iPt2], y2 = verts[iPt2+1], z2 = verts[iPt2+2]; + var xMid = (x0 + x1 + x2)/3.0, + yMid = (y0 + y1 + y2)/3.0, + zMid = (z0 + z1 + z2)/3.0; + + // calculate the uv value of the new coordinate + var uMid = (u0 + u1 + u2)/3.0, + vMid = (v0 + v1 + v2)/3.0; + + // calculate the normal for the new coordinate + var nx0 = norms[iPt0], ny0 = norms[iPt0+1], nz0 = norms[iPt0+2], + nx1 = norms[iPt1], ny1 = norms[iPt1+1], nz1 = norms[iPt1+2], + nx2 = norms[iPt2], ny2 = norms[iPt2+1], nz2 = norms[iPt2+2]; + var nxMid = (nx0 + nx1 + nx2), + nyMid = (ny0 + ny1 + ny2), + nzMid = (nz0 + nz1 + nz2); + var nrm = VecUtils.vecNormalize(3, [nxMid, nyMid, nzMid], 1.0 ); + + // push the new vertex + verts.push(nrm[0]); verts.push(nrm[1]); verts.push(nrm[2]); + uvs.push(uMid), uvs.push(vMid); + norms.push(nrm[0]); norms.push(nrm[1]); norms.push(nrm[2]); + var iMidVrt = nVertices; + nVertices++; + + // split the current triangle into 3 + indices[index+2] = iMidVrt; + indices.push(i1); indices.push(i2); indices.push(iMidVrt); nTriangles++; + indices.push(i2); indices.push(i0); indices.push(iMidVrt); nTriangles++; + + // by not advancing 'index', we examine the first of the 3 triangles generated above + } + } + } + return nVertices; +} + + + diff --git a/js/helper-classes/RDGE/GLWorld.js b/js/helper-classes/RDGE/GLWorld.js index 819f89db..c97e29d4 100644 --- a/js/helper-classes/RDGE/GLWorld.js +++ b/js/helper-classes/RDGE/GLWorld.js @@ -225,19 +225,15 @@ function GLWorld( canvas, use3D ) { if (this._useWebGL) { - if (this._allMapsLoaded) + var ctx = g_Engine.getContext(); + var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle); + if (ctx1 != ctx) console.log( "***** different contexts (2) *****" ); + var aRenderer = ctx1.renderer; + var renderer = ctx.renderer; + if (renderer != aRenderer) console.log( "***** DIFFERENT RENDERERS *****" ); + + if (renderer.unloadedTextureCount <= 0) { - var ctx = g_Engine.getContext(); - //console.log( "RDGE state: " + ctx.ctxStateManager.currentState().name); - - ///////////////////////////// - var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle); - if (ctx1 != ctx) console.log( "***** different contexts (2) *****" ); - var aRenderer = ctx1.renderer; - ////////////////////////////////////////// - - var renderer = ctx.renderer; - if (renderer != aRenderer) console.log( "***** DIFFERENT RENDERERS *****" ); renderer.disableCulling(); this.myScene.render(); //console.log( "render" ); @@ -249,8 +245,8 @@ function GLWorld( canvas, use3D ) if (!this.hasAnimatedMaterials()) { //this.myScene.render(); - //this._canvas.task.stop(); - this._renderCount = 10; + this._canvas.task.stop(); + //this._renderCount = 10; } } else if (this._renderCount >= 0) @@ -259,7 +255,6 @@ function GLWorld( canvas, use3D ) if (this._renderCount <= 0) this._canvas.task.stop(); } - } } else diff --git a/js/helper-classes/RDGE/Materials/FlatMaterial.js b/js/helper-classes/RDGE/Materials/FlatMaterial.js index 3e3ae25e..c8eb3b6c 100644 --- a/js/helper-classes/RDGE/Materials/FlatMaterial.js +++ b/js/helper-classes/RDGE/Materials/FlatMaterial.js @@ -121,6 +121,7 @@ function FlatMaterial() flatShaderDef = { 'shaders': { // shader files + //'defaultVShader':"assets/shaders/Taper.vert.glsl", 'defaultVShader':"assets/shaders/Basic.vert.glsl", 'defaultFShader':"assets/shaders/Basic.frag.glsl", }, diff --git a/js/helper-classes/RDGE/Materials/LinearGradientMaterial.js b/js/helper-classes/RDGE/Materials/LinearGradientMaterial.js index ce965296..8b23d77e 100644 --- a/js/helper-classes/RDGE/Materials/LinearGradientMaterial.js +++ b/js/helper-classes/RDGE/Materials/LinearGradientMaterial.js @@ -135,8 +135,10 @@ function LinearGradientMaterial() // duplcate method requirde this.dup = function() { return new LinearGradientMaterial(); } - this.init = function() + this.init = function( world ) { + this.setWorld( world ); + // set up the shader this._shader = new jshader(); this._shader.def = linearGradientMaterialDef; diff --git a/js/helper-classes/RDGE/src/core/script/renderer.js b/js/helper-classes/RDGE/src/core/script/renderer.js index 517947df..04cb36a7 100644 --- a/js/helper-classes/RDGE/src/core/script/renderer.js +++ b/js/helper-classes/RDGE/src/core/script/renderer.js @@ -359,9 +359,11 @@ _renderer = function(canvas) { * @param wrap - optional "CLAMP or "REPEAT", default is clamp * @param mips - optional true/false value to create mipmaps, the default is true */ + this.unloadedTextureCount = 0; _texparams = function(wrap, mips) { this.wrap = wrap, this.mips = mips }; this.createTexture = function(url, wrap, mips) { var texture = this.ctx.createTexture(); + this.unloadedTextureCount++; if (wrap === undefined) wrap = "CLAMP"; @@ -379,7 +381,18 @@ _renderer = function(canvas) { stateMan.RDGEInitState.loadTexture(texture); //console.log( "loaded texture: " + texture.lookUpName ); if (texture.callback) texture.callback( texture ); + this.context.renderer.unloadedTextureCount--; + if (this.context.renderer.unloadedTextureCount < 0) + console.log( "more textures loaded then created..." ); }; + texture.image.onerror = function() { + this.context.renderer.unloadedTextureCount--; + if (texture.callback) texture.callback( texture ); + console.log( "Error loading texture: " + texture.image.src ); + if (this.context.renderer.unloadedTextureCount < 0) + console.log( "more textures loaded then created..." ); + } + } return texture; } -- cgit v1.2.3 From 465636cc0676d7fb83939d6fdb9204e474d47d46 Mon Sep 17 00:00:00 2001 From: hwc487 Date: Mon, 6 Feb 2012 13:08:26 -0800 Subject: Removed an unnecessary (and incorrect) snapping calculation. --- js/helper-classes/3D/snap-manager.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'js') diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index 8819f637..7e1260bf 100644 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js @@ -977,7 +977,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { viewUtils.setViewportObj( stage ); MathUtils.makeDimension3( screenPt ); - this.hSnapToElements( stage, screenPt, hitRecs, 0, screenPt ); + this.hSnapToElements( stage, hitRecs, 0, screenPt ); return; } @@ -985,7 +985,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { hSnapToElements : { - value: function( elt, parentPt, hitRecs, depth, globalScrPt ) + value: function( elt, hitRecs, depth, globalScrPt ) { // hit test the current object var hit; @@ -994,8 +994,7 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { // if the element is in the 2D cache snapping is done there if (elt.elementModel && !elt.elementModel.isIn2DSnapCache) { - var scrPt = viewUtils.parentToChild( parentPt, elt, false ); - hit = this.snapToElement( elt, scrPt, globalScrPt ); + hit = this.snapToElement( elt, globalScrPt ); if (hit) { //hitRecs.push( hit ); @@ -1017,14 +1016,14 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { } // test the rest of the tree var n = elt.childElementCount; - var eltPt = viewUtils.parentToChild( parentPt, elt, true ); + //var eltPt = viewUtils.parentToChild( parentPt, elt, true ); if (n > 0) { for (var i=0; i --- js/components/editable.reel/editable.js | 250 +++++++++ js/components/hintable.reel/hintable.js | 360 ++++++++++++ js/ninja.reel/ninja.html | 3 +- js/panels/Timeline/Collapser.js | 319 +++++++++++ js/panels/Timeline/Keyframe.reel/Keyframe.html | 27 + js/panels/Timeline/Keyframe.reel/Keyframe.js | 147 +++++ js/panels/Timeline/Keyframe.reel/css/Keyframe.css | 11 + js/panels/Timeline/Layer.reel/Layer.html | 158 ++++++ js/panels/Timeline/Layer.reel/Layer.js | 511 +++++++++++++++++ js/panels/Timeline/Layer.reel/css/Layer.css | 322 +++++++++++ js/panels/Timeline/Layer.reel/images/eye.png | Bin 0 -> 1331 bytes .../Timeline/Layer.reel/images/icon-collapsed.png | Bin 0 -> 325 bytes js/panels/Timeline/Layer.reel/images/icon-eye.png | Bin 0 -> 550 bytes js/panels/Timeline/Layer.reel/images/icon-lock.png | Bin 0 -> 475 bytes .../Timeline/Layer.reel/images/icon-minus.png | Bin 0 -> 161 bytes js/panels/Timeline/Layer.reel/images/icon-open.png | Bin 0 -> 323 bytes js/panels/Timeline/Layer.reel/images/icon-plus.png | Bin 0