diff options
author | gman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-16 23:56:24 +0000 |
---|---|---|
committer | gman@google.com <gman@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-16 23:56:24 +0000 |
commit | cd4740dba6b65213baa16dd31ede47731b092412 (patch) | |
tree | 5ddce879fcec2b47c0150bb6a411c751168780e4 /o3d/samples/o3djs | |
parent | 9b9f2e5d435484c6cb05c6a47604cbd0022455df (diff) | |
download | chromium_src-cd4740dba6b65213baa16dd31ede47731b092412.zip chromium_src-cd4740dba6b65213baa16dd31ede47731b092412.tar.gz chromium_src-cd4740dba6b65213baa16dd31ede47731b092412.tar.bz2 |
JSCompiler fixes
*) Generate goog.exportSymbol for all o3djs classes,
methods and properties so the JSCompiler does not
delete them
*) Remove goog.exportSymbol from the compiled result.
*) Remove o3djs.require from the compiled result.
*) Add docs to undocumented items in o3djs.
Review URL: http://codereview.chromium.org/155665
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20919 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/samples/o3djs')
-rw-r--r-- | o3d/samples/o3djs/arcball.js | 47 | ||||
-rw-r--r-- | o3d/samples/o3djs/canvas.js | 71 | ||||
-rw-r--r-- | o3d/samples/o3djs/debug.js | 56 | ||||
-rw-r--r-- | o3d/samples/o3djs/util.js | 2 |
4 files changed, 137 insertions, 39 deletions
diff --git a/o3d/samples/o3djs/arcball.js b/o3d/samples/o3djs/arcball.js index 0f511ab..e37e92c 100644 --- a/o3d/samples/o3djs/arcball.js +++ b/o3d/samples/o3djs/arcball.js @@ -74,10 +74,33 @@ o3djs.arcball.create = function(areaWidth, areaHeight) { * @see o3djs.arcball */ o3djs.arcball.ArcBall = function(areaWidth, areaHeight) { - this.startVector = [0, 0, 0]; - this.endVector = [0, 0, 0]; - this.areaWidth = areaWidth; - this.areaHeight = areaHeight; + /** + * The start vector. + * @private + * @type {!o3djs.math.Vector3} + */ + this.startVector_ = [0, 0, 0]; + + /** + * The end vector. + * @private + * @type {!o3djs.math.Vector3} + */ + this.endVector_ = [0, 0, 0]; + + /** + * The width of the arcBall area. + * @private + * @type {number} + */ + this.areaWidth_ = areaWidth; + + /** + * The height of the arcBall area. + * @private + * @type {number} + */ + this.areaHeight_ = areaHeight; }; @@ -87,8 +110,8 @@ o3djs.arcball.ArcBall = function(areaWidth, areaHeight) { * @param {number} areaHeight height of area arcball should cover. */ o3djs.arcball.ArcBall.prototype.setAreaSize = function(areaWidth, areaHeight) { - this.areaWidth = areaWidth; - this.areaHeight = areaHeight; + this.areaWidth_ = areaWidth; + this.areaHeight_ = areaHeight; }; /** @@ -101,8 +124,8 @@ o3djs.arcball.ArcBall.prototype.mapToSphere = function(newPoint) { var tempPoint = o3djs.math.copyVector(newPoint); // Scale to -1.0 <-> 1.0 - tempPoint[0] = tempPoint[0] / this.areaWidth * 2.0 - 1.0; - tempPoint[1] = 1.0 - tempPoint[1] / this.areaHeight * 2.0; + tempPoint[0] = tempPoint[0] / this.areaWidth_ * 2.0 - 1.0; + tempPoint[1] = 1.0 - tempPoint[1] / this.areaHeight_ * 2.0; // Compute square of length from center var lengthSquared = o3djs.math.lengthSquared(tempPoint); @@ -121,7 +144,7 @@ o3djs.arcball.ArcBall.prototype.mapToSphere = function(newPoint) { * @param {!o3djs.math.Vector2} newPoint point in 2d. */ o3djs.arcball.ArcBall.prototype.click = function(newPoint) { - this.startVector = this.mapToSphere(newPoint); + this.startVector_ = this.mapToSphere(newPoint); }; /** @@ -132,8 +155,8 @@ o3djs.arcball.ArcBall.prototype.click = function(newPoint) { * orientation. */ o3djs.arcball.ArcBall.prototype.drag = function(newPoint) { - this.endVector = this.mapToSphere(newPoint); + this.endVector_ = this.mapToSphere(newPoint); - return o3djs.math.cross(this.startVector, this.endVector).concat( - o3djs.math.dot(this.startVector, this.endVector)); + return o3djs.math.cross(this.startVector_, this.endVector_).concat( + o3djs.math.dot(this.startVector_, this.endVector_)); }; diff --git a/o3d/samples/o3djs/canvas.js b/o3d/samples/o3djs/canvas.js index aa5070f..3c264b7 100644 --- a/o3d/samples/o3djs/canvas.js +++ b/o3d/samples/o3djs/canvas.js @@ -167,34 +167,47 @@ o3djs.canvas.CanvasInfo = function(pack, root, viewInfo) { */ this.root = root; - // Create the Effect object shared by all CanvasQuad instances. - this.effect = this.pack.createObject('Effect'); - this.effect.loadFromFXString(o3djs.canvas.FX_STRING); - - // Create two materials: One used for canvases with transparent content - // and one for opaque canvases. - this.transparentMaterial = this.pack.createObject('Material'); - this.opaqueMaterial = this.pack.createObject('Material'); - - this.transparentMaterial.effect = this.effect; - this.opaqueMaterial.effect = this.effect; - - this.transparentMaterial.drawList = viewInfo.zOrderedDrawList; - this.opaqueMaterial.drawList = viewInfo.performanceDrawList; - - // Create a state object to handle the transparency blending mode - // for transparent canvas quads. - // The canvas bitmap already multiplies the color values by alpha. In order - // to avoid a black halo around text drawn on a transparent background we - // need to set the blending mode as follows. - this.transparentState = this.pack.createObject('State'); - this.transparentState.getStateParam('AlphaBlendEnable').value = true; - this.transparentState.getStateParam('SourceBlendFunction').value = + /** + * The Effect object shared by all CanvasQuad instances. + * @type {!o3d.Effect} + */ + this.effect_ = this.pack.createObject('Effect'); + this.effect_.loadFromFXString(o3djs.canvas.FX_STRING); + + /** + * Material for canvases with transparent content + * @type {!o3d.Material} + */ + this.transparentMaterial_ = this.pack.createObject('Material'); + + /** + * Material for canvases with opaque content. + * @type {!o3d.Material} + */ + this.opaqueMaterial_ = this.pack.createObject('Material'); + + this.transparentMaterial_.effect = this.effect_; + this.opaqueMaterial_.effect = this.effect_; + + this.transparentMaterial_.drawList = viewInfo.zOrderedDrawList; + this.opaqueMaterial_.drawList = viewInfo.performanceDrawList; + + /** + * State object to handle the transparency blending mode + * for transparent canvas quads. + * The canvas bitmap already multiplies the color values by alpha. In order + * to avoid a black halo around text drawn on a transparent background we + * need to set the blending mode as follows. + * @type {!o3d.State} + */ + this.transparentState_ = this.pack.createObject('State'); + this.transparentState_.getStateParam('AlphaBlendEnable').value = true; + this.transparentState_.getStateParam('SourceBlendFunction').value = o3djs.base.o3d.State.BLENDFUNC_ONE; - this.transparentState.getStateParam('DestinationBlendFunction').value = + this.transparentState_.getStateParam('DestinationBlendFunction').value = o3djs.base.o3d.State.BLENDFUNC_INVERSE_SOURCE_ALPHA; - this.transparentMaterial.state = this.transparentState; + this.transparentMaterial_.state = this.transparentState_; // Create 2d plane shapes. createPlane makes an XZ plane by default // so we pass in matrix to rotate it to an XY plane. We could do @@ -206,7 +219,7 @@ o3djs.canvas.CanvasInfo = function(pack, root, viewInfo) { */ this.transparentQuadShape = o3djs.primitives.createPlane( this.pack, - this.transparentMaterial, + this.transparentMaterial_, 1, 1, 1, @@ -222,7 +235,7 @@ o3djs.canvas.CanvasInfo = function(pack, root, viewInfo) { */ this.opaqueQuadShape = o3djs.primitives.createPlane( this.pack, - this.opaqueMaterial, + this.opaqueMaterial_, 1, 1, 1, @@ -261,6 +274,10 @@ o3djs.canvas.CanvasQuad = function(canvasInfo, height, transparent, opt_parent) { + /** + * The CanvasInfo managing this CanvasQuad + * @type {!o3djs.canvas.CanvasInfo} + */ this.canvasInfo = canvasInfo; var parentTransform = opt_parent || canvasInfo.root; diff --git a/o3d/samples/o3djs/debug.js b/o3d/samples/o3djs/debug.js index 8b1dc8d..9589c50 100644 --- a/o3d/samples/o3djs/debug.js +++ b/o3d/samples/o3djs/debug.js @@ -223,7 +223,16 @@ o3djs.debug.createLineShape = function(pack, * @param {!Array.<number>} opt_indices array of indices in pairs. */ o3djs.debug.VertexInfo = function(opt_vertices, opt_indices) { + /** + * The vertices for this VertexInfo. + * @type {!Array.<o3djs.math.Vector3>} + */ this.vertices = opt_vertices || []; + + /** + * The vertex indices this VertexInfo. + * @type {!Array.<number>} + */ this.indices = opt_indices || []; }; @@ -490,8 +499,26 @@ o3djs.debug.DebugLine = function(debugLineGroup) { this.transform_ = pack.createObject('Transform'); this.transform_.name = O3D_DEBUG_LINE_SHAPE_NAME; this.transform_.addShape(debugLineGroup.getLineShape()); + + /** + * The start position of the line. + * @private + * @type {!o3djs.math.Vector3} + */ this.start_ = [0, 0, 0]; + + /** + * The start position of the line. + * @private + * @type {!o3djs.math.Vector3} + */ this.end_ = [0, 0, 0]; + + /** + * The color param for the line. + * @private + * @type {!o3d.ParamFloat4} + */ this.colorParam_ = this.transform_.createParam( O3D_DEBUG_COLOR_PARAM_NAME, 'ParamFloat4'); this.colorParam_.value = debugLineGroup.getColor(); @@ -599,10 +626,39 @@ o3djs.debug.DebugLine.prototype.remove = function() { * @param {!o3d.Transform} root Transform to put debug lines under. */ o3djs.debug.DebugLineGroup = function(debugHelper, root) { + /** + * The default color to make new lines. + * @private + * @type {!o3djs.math.Vector4} + */ this.currentColor_ = [1, 1, 1, 1]; + + /** + * The transforms for all the lines in this group indexed by clientId. + * @private + * @type {!Object.<number, !o3d.Transform>} + */ this.lineTransforms_ = { }; + + /** + * The transforms for all the unused lines in this group indexed by clientId. + * @private + * @type {!Object.<number, !o3d.Transform>} + */ this.freeLineTransforms_ = { }; + + /** + * The DebugHelper managing this DebugLineGroup. + * @private + * @type {!o3djs.debug.DebugHelper} + */ this.debugHelper_ = debugHelper; + + /** + * The root transform for lines in this group. + * @private + * @type {!o3d.Transform} + */ this.root_ = root; }; diff --git a/o3d/samples/o3djs/util.js b/o3d/samples/o3djs/util.js index 563c696..c5cd6e1 100644 --- a/o3d/samples/o3djs/util.js +++ b/o3d/samples/o3djs/util.js @@ -632,6 +632,7 @@ o3djs.util.toAbsoluteUri = function(uri) { /** * The script URIs. + * @private * @type {!Array.<string>} */ o3djs.util.scriptUris_ = []; @@ -669,6 +670,7 @@ o3djs.util.isScriptUri = function(uri) { * Concatenate the text of all the script tags in the document and invokes * the callback when complete. This function is asynchronous if any of the * script tags reference JavaScript through a URI. + * @private * @return {string} The script tag text. */ o3djs.util.getScriptTagText_ = function() { |