Transform nodes are supposed to discard internally memoised
state when any super-transform properties have been modified via
setter methods.
Description
Problem found where if they start in memoLevel 1 (when
statically configured) and are lucky enough to ascend to memoLevel
2, they don't reset to memoLevel 1 when a super node has had an
attribute updated (eg. angle, translation, scale etc) because they
don't check.
SceneJS.Scale.prototype._render = function(traversalContext, data) {
if (this._memoLevel == 0) {
if (!this._fixedParams) {
this._init(this._getParams(data));
} else {
this._memoLevel = 1;
}
this._mat = SceneJS._math_scalingMat4v([this._x, this._y, this._z]);
}
var superXform = SceneJS._modelViewTransformModule.getTransform();
if (this._memoLevel < 2) {
var instancing = SceneJS._instancingModule.instancing();
var tempMat = SceneJS._math_mulMat4(superXform.matrix, this._mat);
this._xform = {
localMatrix: this._mat,
matrix: tempMat,
fixed: superXform.fixed && this._fixedParams && !instancing
};
////////////////////////
// Calculate memo level
////////////////////////
if (this._memoLevel == 1 && superXform.fixed && !instancing) { // Bump up memoization level if model-space fixed
this._memoLevel = 2;
}
}
SceneJS._modelViewTransformModule.setTransform(this._xform);
this._renderNodes(traversalContext, data);
SceneJS._modelViewTransformModule.setTransform(superXform);
};
Fix
Inherit memoLevels on the matrix stack:
SceneJS.Scale.prototype._render = function(traversalContext, data) {
if (this._memoLevel == 0) {
if (!this._fixedParams) {
this._init(this._getParams(data));
} else {
this._memoLevel = 1;
}
this._mat = SceneJS._math_scalingMat4v([this._x, this._y, this._z]);
}
var superXform = SceneJS._modelViewTransformModule.getTransform();
if (this._memoLevel < 2) {
var instancing = SceneJS._instancingModule.instancing();
//////////////////////////
// calculate memoLevel
//////////////////////////
if (this._memoLevel == 1 && superXform.fixed && !instancing) { // Bump up memoization level if model-space fixed
this._memoLevel = 2;
}
var tempMat = SceneJS._math_mulMat4(superXform.matrix, this._mat);
this._xform = {
localMatrix: this._mat,
matrix: tempMat,
fixed: this._memoLevel == 2 ///// Mark matrix on stack as fixed if at memoLevel 2
};
}
SceneJS._modelViewTransformModule.setTransform(this._xform);
this._renderNodes(traversalContext, data);
SceneJS._modelViewTransformModule.setTransform(superXform);
};