Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions core/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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')

};

Expand Down
19 changes: 18 additions & 1 deletion visualization/renderer3D.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -2417,4 +2433,5 @@ goog.exportSymbol('X.renderer3D.prototype.resetViewAndRender',
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.afterRender', X.renderer3D.prototype.afterRender);
goog.exportSymbol('X.renderer3D.prototype.addShaders', X.renderer3D.prototype.addShaders);
23 changes: 20 additions & 3 deletions visualization/shaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,20 +263,23 @@ 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';
// t2 += ' vec3 reflectionDirection = nNormal;\n'; <-- to disable reflection
// 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';
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -420,3 +434,6 @@ X.shaders.prototype.validate = function() {
return true;

};

// export symbols (required for advanced compilation)
goog.exportSymbol('X.shaders', X.shaders);