summaryrefslogtreecommitdiffstats
path: root/o3d/samples/o3d-webgl
diff options
context:
space:
mode:
authorpetersont@google.com <petersont@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-17 22:24:58 +0000
committerpetersont@google.com <petersont@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-17 22:24:58 +0000
commitba5e15b350ba9bdbabca26990066b9c665779bef (patch)
tree5733d1365aa08f4487ca675d5e6fbaaf5e952265 /o3d/samples/o3d-webgl
parent7f793e3a983f2153bd812b686b95cd1eeda4fa40 (diff)
downloadchromium_src-ba5e15b350ba9bdbabca26990066b9c665779bef.zip
chromium_src-ba5e15b350ba9bdbabca26990066b9c665779bef.tar.gz
chromium_src-ba5e15b350ba9bdbabca26990066b9c665779bef.tar.bz2
Fixed a typo in pool code and made comments more google style
Implemented ParamObject.removeParam and ParamObject.copyParams. Minor style change in primitive.js. Review URL: http://codereview.chromium.org/2083004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47465 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/samples/o3d-webgl')
-rw-r--r--o3d/samples/o3d-webgl/bounding_box.js7
-rw-r--r--o3d/samples/o3d-webgl/param_object.js20
-rw-r--r--o3d/samples/o3d-webgl/primitive.js7
3 files changed, 22 insertions, 12 deletions
diff --git a/o3d/samples/o3d-webgl/bounding_box.js b/o3d/samples/o3d-webgl/bounding_box.js
index b585c31..ebd7d09 100644
--- a/o3d/samples/o3d-webgl/bounding_box.js
+++ b/o3d/samples/o3d-webgl/bounding_box.js
@@ -154,7 +154,6 @@ o3d.BoundingBox.prototype.add =
/**
* Checks if a ray defined in same coordinate system as this box intersects
* this bounding box.
- * TODO(petersont): this can also take six coordinates as input.
* @param {!o3d.math.Point3} start position of start of ray in local space.
* @param {!o3d.math.Point3} end position of end of ray in local space.
* @return {!o3d.RayIntersectionInfo} RayIntersectionInfo. If result.value
@@ -165,6 +164,12 @@ o3d.BoundingBox.prototype.add =
*/
o3d.BoundingBox.prototype.intersectRay =
function(start, end) {
+ // If there are six arguments, assume they are the coordinates of two points.
+ if (arguments.length == 6) {
+ start = [arguments[0], arguments[1], arguments[2]];
+ end = [arguments[3], arguments[4], arguments[5]];
+ }
+
var result = new RayIntersectionInfo;
if (this.valid) {
diff --git a/o3d/samples/o3d-webgl/param_object.js b/o3d/samples/o3d-webgl/param_object.js
index 27b567e..51e8688d 100644
--- a/o3d/samples/o3d-webgl/param_object.js
+++ b/o3d/samples/o3d-webgl/param_object.js
@@ -46,7 +46,7 @@ o3d.ParamObject.O3D_PREFIX_ = 'o3d.';
/**
* Creates a Param with the given name and type on the ParamObject.
* Will fail if a param with the same name already exists.
- *
+ *
* @param {string} param_name The name of the Param to be created.
* @param {string} param_type_name The type of Param to create.
* Valid types are
@@ -116,7 +116,7 @@ o3d.ParamObject.prototype.createParam =
/**
* Searches by name for a Param defined in the object.
- *
+ *
* @param {string} param_name Name to search for.
* @return {!o3d.Param} The Param with the given name, or null otherwise.
*/
@@ -153,30 +153,30 @@ o3d.ParamObject.prototype.getParam =
/**
* Removes a Param from a ParamObject.
- *
+ *
* This function will fail if the param does not exist on this ParamObject
* or if the param is unremovable.
- *
+ *
* @param {!o3d.Param} param param to remove.
* @return {boolean} True if the param was removed.
*/
o3d.ParamObject.prototype.removeParam =
function(param) {
- o3d.notImplemented();
+ o3d.removeFromArray(param, this.params_);
};
/**
* Gets all the param on this param object.
- *
+ *
* Each access to this field gets the entire list, so it is best to get it
* just once. For example:
- *
+ *
* var params = paramObject.params;
* for (var i = 0; i < params.length; i++) {
* var param = params[i];
* }
- *
+ *
* Note that modifications to this array [e.g. push()] will not affect
* the underlying ParamObject, while modifications to the array's members
* will affect them.
@@ -193,7 +193,9 @@ o3d.ParamObject.prototype.params_ = {};
*/
o3d.ParamObject.prototype.copyParams =
function(source_param_object) {
- o3d.notImplemented();
+ for (param in source_param_object.params_) {
+ this.createParam(param.name, param.className);
+ }
};
diff --git a/o3d/samples/o3d-webgl/primitive.js b/o3d/samples/o3d-webgl/primitive.js
index fe31ecb..904abf8 100644
--- a/o3d/samples/o3d-webgl/primitive.js
+++ b/o3d/samples/o3d-webgl/primitive.js
@@ -130,10 +130,13 @@ o3d.Primitive.prototype.render = function() {
this.gl.enableVertexAttribArray(gl_index);
enabled_attribs.push(gl_index);
- // TODO(petersont): Change that hard-coded 4 down there.
+ // TODO(petersont): When the constant WebGLFloatArray.BYTES_PER_ELEMENT
+ // becomes available in implementations, use that here instead of this
+ // hard-coded 4.
+ var kFloatSize = 4;
this.gl.vertexAttribPointer(
gl_index, field.numComponents, this.gl.FLOAT, false,
- buffer.totalComponents * 4, field.offset_ * 4);
+ buffer.totalComponents * kFloatSize, field.offset_ * kFloatSize);
}
}
}