From faed8703f63e04e567ab310011b99728014c50c3 Mon Sep 17 00:00:00 2001 From: ivmartel Date: Mon, 19 May 2014 16:26:21 +0200 Subject: [PATCH 1/3] Added finding and storing of input scalars min/max. See #152. --- visualization/renderer3D.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/visualization/renderer3D.js b/visualization/renderer3D.js index 54f0a2adb..96953dc62 100755 --- a/visualization/renderer3D.js +++ b/visualization/renderer3D.js @@ -1149,6 +1149,22 @@ X.renderer3D.prototype.update_ = function(object) { } var glScalarBuffer = this._context.createBuffer(); + // find and store scalars min/max if not already done + if ( scalars.min === Infinity && scalars.max === -Infinity ) { + var scalarsMin = Infinity; + var scalarsMax = -Infinity; + var value = 0; + for ( var i = 0; i < scalarsArray.length; ++i ) { + value = scalarsArray[i]; + if ( !isNaN(value) ) { + scalarsMin = Math.min(scalarsMin, value); + scalarsMax = Math.max(scalarsMax, value); + } + } + scalars._min = scalarsMin; + scalars._max = scalarsMax; + } + // bind and fill with colors defined above this._context.bindBuffer(this._context.ARRAY_BUFFER, glScalarBuffer); this._context.bufferData(this._context.ARRAY_BUFFER, scalarsArray, From 3df1edcbde5e1546045b1657a298e0444dc30fd8 Mon Sep 17 00:00:00 2001 From: ivmartel Date: Mon, 3 Nov 2014 16:39:19 +0100 Subject: [PATCH 2/3] Change the call to goog.events.getUniqueId in core/events.js to fix the error: > event.js:96: ERROR - Id generator call must be in the global scope --- core/event.js | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/core/event.js b/core/event.js index 812ef2e06..bf275283a 100644 --- a/core/event.js +++ b/core/event.js @@ -91,11 +91,11 @@ goog.inherits(X.event, goog.events.Event); * @param {string} id The id. * @return {string} A unique id. */ -X.event.uniqueId = function(id) { - - return goog.events.getUniqueId(id); - -}; +//X.event.uniqueId = function(id) { +// +// return goog.events.getUniqueId(id); +// +//}; /** * The events of this class. @@ -104,49 +104,49 @@ X.event.uniqueId = function(id) { */ X.event.events = { // the pan event, where the event and focus get moved accordingly - PAN: X.event.uniqueId('pan'), + PAN: goog.events.getUniqueId('pan'), // the rotate event, where only the event gets moved - ROTATE: X.event.uniqueId('rotate'), + ROTATE: goog.events.getUniqueId('rotate'), // the zoom event, where the event Z coordinate changes - ZOOM: X.event.uniqueId('zoom'), + ZOOM: goog.events.getUniqueId('zoom'), // the scroll event - SCROLL: X.event.uniqueId('scroll'), + SCROLL: goog.events.getUniqueId('scroll'), // the render event - RENDER: X.event.uniqueId('render'), + RENDER: goog.events.getUniqueId('render'), // the reset view event - RESETVIEW: X.event.uniqueId('resetview'), + RESETVIEW: goog.events.getUniqueId('resetview'), // window_level modification event - WINDOWLEVEL: X.event.uniqueId('windowlevel'), + WINDOWLEVEL: goog.events.getUniqueId('windowlevel'), // the object modified event - MODIFIED: X.event.uniqueId('modified'), + MODIFIED: goog.events.getUniqueId('modified'), // the object remove event - REMOVE: X.event.uniqueId('remove'), + REMOVE: goog.events.getUniqueId('remove'), // the loading progress event - PROGRESS: X.event.uniqueId('progress'), + PROGRESS: goog.events.getUniqueId('progress'), // the hover event - HOVER: X.event.uniqueId('hover'), + HOVER: goog.events.getUniqueId('hover'), // the hover end event - HOVER_END: X.event.uniqueId('hover_end'), + HOVER_END: goog.events.getUniqueId('hover_end'), // the computing event - COMPUTING: X.event.uniqueId('computing'), + COMPUTING: goog.events.getUniqueId('computing'), // the computing end event - COMPUTING_END: X.event.uniqueId('computing_end'), + COMPUTING_END: goog.events.getUniqueId('computing_end'), // the computing progress event - COMPUTING_PROGRESS: X.event.uniqueId('computing_progress') + COMPUTING_PROGRESS: goog.events.getUniqueId('computing_progress') }; From bd20a007c2c4d031c484d5d4d38e03104cdd9233 Mon Sep 17 00:00:00 2001 From: ivmartel Date: Mon, 3 Nov 2014 16:40:32 +0100 Subject: [PATCH 3/3] Allow to set the shaders of a renderer. Allow to change a shaders vertex. --- visualization/renderer3D.js | 1 + visualization/shaders.js | 23 ++++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/visualization/renderer3D.js b/visualization/renderer3D.js index 90971eed3..249f28fd6 100755 --- a/visualization/renderer3D.js +++ b/visualization/renderer3D.js @@ -2434,3 +2434,4 @@ goog.exportSymbol('X.renderer3D.prototype.resetViewAndRender', goog.exportSymbol('X.renderer3D.prototype.pick', X.renderer3D.prototype.pick); goog.exportSymbol('X.renderer3D.prototype.pick3d', X.renderer3D.prototype.pick3d); goog.exportSymbol('X.renderer3D.prototype.afterRender', X.renderer3D.prototype.afterRender); +goog.exportSymbol('X.renderer3D.prototype.addShaders', X.renderer3D.prototype.addShaders); diff --git a/visualization/shaders.js b/visualization/shaders.js index bfc5d39af..bd6b0b845 100644 --- a/visualization/shaders.js +++ b/visualization/shaders.js @@ -263,7 +263,8 @@ X.shaders = function() { t2 += ' vec3 light = vec3(0.0, 0.0, 1.0);\n'; // t2 += ' vec3 lightDirection = vec3(-10.0, 4.0, -20.0);\n'; // I liked the following better - t2 += ' vec3 lightDirection = vec3(0,0,-10);\n'; + //t2 += ' vec3 lightDirection = vec3(0,0,-10);\n'; + t2 += ' vec3 lightDirection = vec3(-10,0,-10);\n'; t2 += ' lightDirection = normalize(lightDirection);\n'; t2 += ' vec3 eyeDirection = normalize(-fVertexPosition.xyz);\n'; t2 += ' vec3 reflectionDirection = reflect(-lightDirection, nNormal);\n'; @@ -271,12 +272,14 @@ X.shaders = function() { // configure specular (10.0 is material property), diffuse and ambient t2 += ' float specular = pow(max(dot(reflectionDirection, eyeDirection), 0.0), 10.0);\n'; t2 += ' float diffuse = 0.8 * max(dot(nNormal, light), 0.0);\n'; - t2 += ' float ambient = 0.3;\n'; + //t2 += ' float ambient = 0.3;\n'; + t2 += ' float ambient = 0.2;\n'; // .. and now setup the fragment color using these three values and the // opacity t2 += ' gl_FragColor = vec4(fragmentColor * ambient +\n'; t2 += ' fragmentColor * diffuse +\n'; - t2 += ' vec3(0.2, 0.2, 0.2) * specular,\n'; + //t2 += ' vec3(0.2, 0.2, 0.2) * specular,\n'; + t2 += ' vec3(0.0, 0.0, 0.0) * specular,\n'; t2 += ' objectOpacity);\n'; t2 += ' }\n'; t2 += '}\n'; @@ -358,6 +361,17 @@ X.shaders.prototype.vertex = function() { }; +/** + * Set the vertex shader source of this shader pair. + * + * @param {!string} The vertex shader source. + * @public + */ +X.shaders.prototype.__defineSetter__('vertex', function(vertex) { + + this._vertexshaderSource = vertex; + +}); /** * Get the fragment shader source of this shader pair. @@ -420,3 +434,6 @@ X.shaders.prototype.validate = function() { return true; }; + +// export symbols (required for advanced compilation) +goog.exportSymbol('X.shaders', X.shaders);