Skip to content

Commit

Permalink
- Fix test bug
Browse files Browse the repository at this point in the history
- Fix backwards sorting convention, three.js goes the other way
- Don't pollute material cache with uncacheables
- zindex test case
  • Loading branch information
unconed committed Jan 26, 2013
1 parent 4814431 commit a272331
Show file tree
Hide file tree
Showing 11 changed files with 219 additions and 42 deletions.
18 changes: 13 additions & 5 deletions build/MathBox-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -21280,7 +21280,8 @@ THREE.WebGLRenderer = function ( parameters ) {
buffer: buffer,
object: object,
opaque: null,
transparent: null
transparent: null,
z: 0,
}
);

Expand All @@ -21292,7 +21293,8 @@ THREE.WebGLRenderer = function ( parameters ) {
{
object: object,
opaque: null,
transparent: null
transparent: null,
z: 0,
}
);

Expand Down Expand Up @@ -43751,6 +43753,8 @@ MathBox.Materials.prototype = {
* Return a generic material.
*/
generic: function (options) {
options = options || {};

// Check for cached instance if not using custom shader
if (!options.shaders || !Object.keys(options.shaders).length) {
var hash = this.hash(options);
Expand All @@ -43761,7 +43765,6 @@ MathBox.Materials.prototype = {

// Prepare new shadergraph factory.
var factory = this.factory();
options = options || {};
var shaders = options.shaders || {};

// Read out vertex position.
Expand Down Expand Up @@ -43792,7 +43795,12 @@ MathBox.Materials.prototype = {

// Apply finalizing shaders.
var material = this.finalize(factory, options);
return (this.cache[hash] = material);

if (hash) {
// Cache material
this.cache[hash] = material;
}
return material;
},

/**
Expand Down Expand Up @@ -46059,7 +46067,7 @@ MathBox.Renderable.prototype = {
// Solid objects are drawn front to back
// Transparent objects are drawn back to front
// Always make sure positive zIndex makes it draw on top of everything else
var sign = (style.opacity < 1) ? 1 : -1;
var sign = (style.opacity == 1) ? 1 : -1;
this.object.renderDepth = style.zIndex * sign;
}
}
Expand Down
14 changes: 7 additions & 7 deletions build/MathBox-bundle.min.js

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions build/MathBox-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1156,6 +1156,8 @@ MathBox.Materials.prototype = {
* Return a generic material.
*/
generic: function (options) {
options = options || {};

// Check for cached instance if not using custom shader
if (!options.shaders || !Object.keys(options.shaders).length) {
var hash = this.hash(options);
Expand All @@ -1166,7 +1168,6 @@ MathBox.Materials.prototype = {

// Prepare new shadergraph factory.
var factory = this.factory();
options = options || {};
var shaders = options.shaders || {};

// Read out vertex position.
Expand Down Expand Up @@ -1197,7 +1198,12 @@ MathBox.Materials.prototype = {

// Apply finalizing shaders.
var material = this.finalize(factory, options);
return (this.cache[hash] = material);

if (hash) {
// Cache material
this.cache[hash] = material;
}
return material;
},

/**
Expand Down Expand Up @@ -3464,7 +3470,7 @@ MathBox.Renderable.prototype = {
// Solid objects are drawn front to back
// Transparent objects are drawn back to front
// Always make sure positive zIndex makes it draw on top of everything else
var sign = (style.opacity < 1) ? 1 : -1;
var sign = (style.opacity == 1) ? 1 : -1;
this.object.renderDepth = style.zIndex * sign;
}
}
Expand Down
10 changes: 5 additions & 5 deletions build/MathBox-core.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions build/MathBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -4130,6 +4130,8 @@ MathBox.Materials.prototype = {
* Return a generic material.
*/
generic: function (options) {
options = options || {};

// Check for cached instance if not using custom shader
if (!options.shaders || !Object.keys(options.shaders).length) {
var hash = this.hash(options);
Expand All @@ -4140,7 +4142,6 @@ MathBox.Materials.prototype = {

// Prepare new shadergraph factory.
var factory = this.factory();
options = options || {};
var shaders = options.shaders || {};

// Read out vertex position.
Expand Down Expand Up @@ -4171,7 +4172,12 @@ MathBox.Materials.prototype = {

// Apply finalizing shaders.
var material = this.finalize(factory, options);
return (this.cache[hash] = material);

if (hash) {
// Cache material
this.cache[hash] = material;
}
return material;
},

/**
Expand Down Expand Up @@ -6438,7 +6444,7 @@ MathBox.Renderable.prototype = {
// Solid objects are drawn front to back
// Transparent objects are drawn back to front
// Always make sure positive zIndex makes it draw on top of everything else
var sign = (style.opacity < 1) ? 1 : -1;
var sign = (style.opacity == 1) ? 1 : -1;
this.object.renderDepth = style.zIndex * sign;
}
}
Expand Down
Loading

0 comments on commit a272331

Please sign in to comment.