diff options
author | petersont@google.com <petersont@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-29 22:17:57 +0000 |
---|---|---|
committer | petersont@google.com <petersont@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-29 22:17:57 +0000 |
commit | 8258a86b378bc6a41fa8947aee92375ec8ff615c (patch) | |
tree | d5c8cddbbaa23500f951c09cf4f89957459efdc1 /o3d/samples/o3d-webgl/field.js | |
parent | 0380c12a8f7fde532f95da39f48376d256367f9b (diff) | |
download | chromium_src-8258a86b378bc6a41fa8947aee92375ec8ff615c.zip chromium_src-8258a86b378bc6a41fa8947aee92375ec8ff615c.tar.gz chromium_src-8258a86b378bc6a41fa8947aee92375ec8ff615c.tar.bz2 |
Added culling sample.
Review URL: http://codereview.chromium.org/1703014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@45993 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/samples/o3d-webgl/field.js')
-rw-r--r-- | o3d/samples/o3d-webgl/field.js | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/o3d/samples/o3d-webgl/field.js b/o3d/samples/o3d-webgl/field.js index 23058bf..1ae89e4 100644 --- a/o3d/samples/o3d-webgl/field.js +++ b/o3d/samples/o3d-webgl/field.js @@ -72,21 +72,22 @@ o3d.Field.prototype.size = 0; /** * Sets the values of the data stored in the field. - * + * * The buffer for the field must have already been created either through * buffer.set or through buffer.allocateElements. - * + * * The number of values passed in must be a multiple of the number of * components needed for the field. - * + * * @param {number} start_index index of first value to set. - * @param {number} values Values to be stored in the buffer starting at index. + * @param {!Array.<number>} values Values to be stored in the buffer starting at + * index. */ o3d.Field.prototype.setAt = function(start_index, values) { this.buffer.lock(); var l = values.length / this.numComponents; - for (var i = 0; i < l; i++) { + for (var i = 0; i < l; ++i) { for (var c = 0; c < this.numComponents; ++c) { this.buffer.array_[ (start_index + i) * this.buffer.totalComponents + this.offset_ + c] = @@ -100,14 +101,21 @@ o3d.Field.prototype.setAt = /** * Gets the values stored in the field. - * + * * @param {number} start_index index of the first value to get. * @param {number} num_elements number of elements to read from field. - * @return {number} The values of the field. + * @return {!Array.<number>} The values of the field. */ o3d.Field.prototype.getAt = function(start_index, num_elements) { - o3d.notImplemented(); + var values = []; + for (var i = 0; i < num_elements; ++i) { + for (var c = 0; c < this.numComponents; ++c) { + values.push(this.buffer.array_[(start_index + i) * + this.buffer.totalComponents + this.offset_ + c]); + } + } + return values; }; |