Skip to content

Commit

Permalink
A bunch of jscompiler fixes including updating to
Browse files Browse the repository at this point in the history
the latest jscompiler. 

There were a few issues.

For some reason o3djs.math.matrix4 was not working
in ff3.0 when compiled.  I spent about 8 hours trying
to reproduce the issue in a small case but had no luck. 
I finally just tried changing original code and it work.

In the process of trying to figure that out I got the
latest jscompiler and found there were a bunch of other
problems with our js code which are now fixed.

Also found out I was incorrectly striping @o3dparameter
tags from our code in build_docs.py

Also, I learned that properties of objects are strings
when returned in an "in" statement as in

for (key in object)

key is a string regardless of what each key is in
object.


Review URL: http://codereview.chromium.org/200089

git-svn-id: http://src.chromium.org/svn/trunk/src/o3d/samples/o3djs@25944 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
  • Loading branch information
[email protected] committed Sep 10, 2009
1 parent b3772b0 commit 6b379b2
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 21 deletions.
17 changes: 10 additions & 7 deletions debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,16 +650,16 @@ o3djs.debug.DebugLineGroup = function(debugHelper, root) {
this.currentColor_ = [1, 1, 1, 1];

/**
* The transforms for all the lines in this group indexed by clientId.
* The lines in this group indexed by clientId.
* @private
* @type {!Object.<number, !o3d.Transform>}
* @type {!Object.<number, !o3djs.debug.DebugLine>}
*/
this.lineTransforms_ = { };

/**
* The transforms for all the unused lines in this group indexed by clientId.
* The unused lines in this group indexed by clientId.
* @private
* @type {!Object.<number, !o3d.Transform>}
* @type {!Object.<number, !o3djs.debug.DebugLine>}
*/
this.freeLineTransforms_ = { };

Expand Down Expand Up @@ -725,7 +725,8 @@ o3djs.debug.DebugLineGroup.prototype.setColor = function(color) {
* @return {!o3djs.debug.DebugLine} The DebugLine.
*/
o3djs.debug.DebugLineGroup.prototype.getLine_ = function() {
for (var id in this.freeLineTransforms_) {
for (var sid in this.freeLineTransforms_) {
var id = /** @type {number} */ (sid);
var line = this.freeLineTransforms_[id];
delete this.freeLineTransforms_[id];
return line;
Expand Down Expand Up @@ -755,7 +756,8 @@ o3djs.debug.DebugLineGroup.prototype.addLine = function(opt_start,
* Clears all the lines in this group.
*/
o3djs.debug.DebugLineGroup.prototype.clear = function() {
for (var id in this.lineTransforms_) {
for (var sid in this.lineTransforms_) {
var id = /** @type {number} */ (sid);
var line = this.lineTransforms_[id];
line.setVisible(false);
this.freeLineTransforms_[id] = line;
Expand All @@ -768,7 +770,8 @@ o3djs.debug.DebugLineGroup.prototype.clear = function() {
*/
o3djs.debug.DebugLineGroup.prototype.destroy = function() {
this.clear();
for (var id in this.freeLineTransforms_) {
for (var sid in this.freeLineTransforms_) {
var id = /** @type {number} */ (sid);
this.freeLineTransforms_[id].destroy();
}
this.freeLineTransforms_ = { };
Expand Down
19 changes: 10 additions & 9 deletions math.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ o3djs.math.Matrix = goog.typedef;
*/
o3djs.math.pseudoRandom = function() {
var math = o3djs.math;
return (math.randomSeed_ =
(134775813 * math.randomSeed_ + 1) %
return (math.randomSeed_ =
(134775813 * math.randomSeed_ + 1) %
math.RANDOM_RANGE_) / math.RANDOM_RANGE_;
};

Expand Down Expand Up @@ -1441,31 +1441,32 @@ o3djs.math.inverse4 = function(m) {

var d = 1.0 / (m[0][0] * t0 + m[1][0] * t1 + m[2][0] * t2 + m[3][0] * t3);

return [[d * t0, d * t1, d * t2, d * t3],
[d * ((tmp_1 * m[1][0] + tmp_2 * m[2][0] + tmp_5 * m[3][0]) -
var row0 = [d * t0, d * t1, d * t2, d * t3];
var row1 = [d * ((tmp_1 * m[1][0] + tmp_2 * m[2][0] + tmp_5 * m[3][0]) -
(tmp_0 * m[1][0] + tmp_3 * m[2][0] + tmp_4 * m[3][0])),
d * ((tmp_0 * m[0][0] + tmp_7 * m[2][0] + tmp_8 * m[3][0]) -
(tmp_1 * m[0][0] + tmp_6 * m[2][0] + tmp_9 * m[3][0])),
d * ((tmp_3 * m[0][0] + tmp_6 * m[1][0] + tmp_11 * m[3][0]) -
(tmp_2 * m[0][0] + tmp_7 * m[1][0] + tmp_10 * m[3][0])),
d * ((tmp_4 * m[0][0] + tmp_9 * m[1][0] + tmp_10 * m[2][0]) -
(tmp_5 * m[0][0] + tmp_8 * m[1][0] + tmp_11 * m[2][0]))],
[d * ((tmp_12 * m[1][3] + tmp_15 * m[2][3] + tmp_16 * m[3][3]) -
(tmp_5 * m[0][0] + tmp_8 * m[1][0] + tmp_11 * m[2][0]))];
var row2 =[d * ((tmp_12 * m[1][3] + tmp_15 * m[2][3] + tmp_16 * m[3][3]) -
(tmp_13 * m[1][3] + tmp_14 * m[2][3] + tmp_17 * m[3][3])),
d * ((tmp_13 * m[0][3] + tmp_18 * m[2][3] + tmp_21 * m[3][3]) -
(tmp_12 * m[0][3] + tmp_19 * m[2][3] + tmp_20 * m[3][3])),
d * ((tmp_14 * m[0][3] + tmp_19 * m[1][3] + tmp_22 * m[3][3]) -
(tmp_15 * m[0][3] + tmp_18 * m[1][3] + tmp_23 * m[3][3])),
d * ((tmp_17 * m[0][3] + tmp_20 * m[1][3] + tmp_23 * m[2][3]) -
(tmp_16 * m[0][3] + tmp_21 * m[1][3] + tmp_22 * m[2][3]))],
[d * ((tmp_14 * m[2][2] + tmp_17 * m[3][2] + tmp_13 * m[1][2]) -
(tmp_16 * m[0][3] + tmp_21 * m[1][3] + tmp_22 * m[2][3]))];
var row3 = [d * ((tmp_14 * m[2][2] + tmp_17 * m[3][2] + tmp_13 * m[1][2]) -
(tmp_16 * m[3][2] + tmp_12 * m[1][2] + tmp_15 * m[2][2])),
d * ((tmp_20 * m[3][2] + tmp_12 * m[0][2] + tmp_19 * m[2][2]) -
(tmp_18 * m[2][2] + tmp_21 * m[3][2] + tmp_13 * m[0][2])),
d * ((tmp_18 * m[1][2] + tmp_23 * m[3][2] + tmp_15 * m[0][2]) -
(tmp_22 * m[3][2] + tmp_14 * m[0][2] + tmp_19 * m[1][2])),
d * ((tmp_22 * m[2][2] + tmp_16 * m[0][2] + tmp_21 * m[1][2]) -
(tmp_20 * m[1][2] + tmp_23 * m[2][2] + tmp_17 * m[0][2]))]];
(tmp_20 * m[1][2] + tmp_23 * m[2][2] + tmp_17 * m[0][2]))];
return [row0, row1, row2, row3];
};

/**
Expand Down
2 changes: 1 addition & 1 deletion picking.js
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ o3djs.picking.TransformInfo = function(transform, parent) {
*/
this.transform = transform;
/**
* The transform of this transform info.
* The parent of this transform info.
* @type {o3djs.picking.TransformInfo}
*/
this.parent = parent;
Expand Down
5 changes: 3 additions & 2 deletions simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ o3djs.simple.SimpleInfo.prototype.createSimpleShape = function(shape) {
* @param {number} elapsedTime Time elapsed since last frame.
*/
o3djs.simple.SimpleInfo.prototype.onRender_ = function(elapsedTime) {
for (var id in this.updateObjects_) {
for (var sid in this.updateObjects_) {
var id = /** @type {number} */ (sid);
this.updateObjects_[id].onUpdate(elapsedTime);
}
};
Expand All @@ -295,7 +296,7 @@ o3djs.simple.SimpleInfo.prototype.onRender_ = function(elapsedTime) {
*/
o3djs.simple.SimpleInfo.prototype.registerObjectForUpdate =
function (simpleObject) {
this.updateObjects_[simpleObject.id] = true;
this.updateObjects_[simpleObject.id] = simpleObject;
};

/**
Expand Down
6 changes: 4 additions & 2 deletions texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,17 @@ o3djs.texture.createTextureFromBitmaps = function(
}
texture = pack.createTextureCUBE(dstWidth, format, targetMips, false);
for (var ii = 0; ii < 6; ++ii) {
texture.setFromBitmap(ii, bitmaps[ii]);
texture.setFromBitmap(
/** @type {o3d.TextureCUBE.CubeFace} */ (ii),
bitmaps[ii]);
}
} else if (bitmaps.length == 1) {
texture = pack.createTexture2D(
dstWidth, dstHeight, format, targetMips, false);
texture.setFromBitmap(bitmaps[0]);
}

return texture;
return /** @type{!o3d.Texture} */ (texture);
};

/**
Expand Down
1 change: 1 addition & 0 deletions util.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ o3djs.util.getElementById = function(id) {

/**
* Identifies a JavaScript engine.
* @enum {number}
*/
o3djs.util.Engine = {
/**
Expand Down

0 comments on commit 6b379b2

Please sign in to comment.