diff options
author | luchen@google.com <luchen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-08 21:37:46 +0000 |
---|---|---|
committer | luchen@google.com <luchen@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-08 21:37:46 +0000 |
commit | c646f7c7cd58aba3a5c4cca7a0154aed09b76f38 (patch) | |
tree | 5ed6fe5a3d0ae3d686beaa0eadfb691104d7518e /o3d/samples/o3d-webgl | |
parent | cf7da7fd73884ee1abd919116ad667c1f45d214d (diff) | |
download | chromium_src-c646f7c7cd58aba3a5c4cca7a0154aed09b76f38.zip chromium_src-c646f7c7cd58aba3a5c4cca7a0154aed09b76f38.tar.gz chromium_src-c646f7c7cd58aba3a5c4cca7a0154aed09b76f38.tar.bz2 |
Adding debugging demo to o3d-webgl collection. Includes minor bug fix in param_object (removeFromArray fails because collection is an object, not an array).
Review URL: http://codereview.chromium.org/2716001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49192 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/samples/o3d-webgl')
-rw-r--r-- | o3d/samples/o3d-webgl/pack.js | 1 | ||||
-rw-r--r-- | o3d/samples/o3d-webgl/param_object.js | 6 | ||||
-rw-r--r-- | o3d/samples/o3d-webgl/primitive.js | 16 | ||||
-rw-r--r-- | o3d/samples/o3d-webgl/transform.js | 4 |
4 files changed, 20 insertions, 7 deletions
diff --git a/o3d/samples/o3d-webgl/pack.js b/o3d/samples/o3d-webgl/pack.js index 507d776..987fb9a 100644 --- a/o3d/samples/o3d-webgl/pack.js +++ b/o3d/samples/o3d-webgl/pack.js @@ -178,6 +178,7 @@ o3d.Pack.prototype.createObject = } var object = new foo(); object.gl = this.gl; + object.clientId = o3d.Client.nextId++; this.objects_.push(object); return object; }; diff --git a/o3d/samples/o3d-webgl/param_object.js b/o3d/samples/o3d-webgl/param_object.js index 51e8688d..253acde 100644 --- a/o3d/samples/o3d-webgl/param_object.js +++ b/o3d/samples/o3d-webgl/param_object.js @@ -162,7 +162,11 @@ o3d.ParamObject.prototype.getParam = */ o3d.ParamObject.prototype.removeParam = function(param) { - o3d.removeFromArray(param, this.params_); + for (var i in this.params_) { + if (this.params_[i] == param) { + delete this.params_[i]; + } + } }; diff --git a/o3d/samples/o3d-webgl/primitive.js b/o3d/samples/o3d-webgl/primitive.js index 4c74c69..5e8bcf3 100644 --- a/o3d/samples/o3d-webgl/primitive.js +++ b/o3d/samples/o3d-webgl/primitive.js @@ -178,11 +178,17 @@ o3d.Primitive.prototype.render = function() { break; } - this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, indexBuffer.gl_buffer_); - this.gl.drawElements(glMode, - glNumElements, - this.gl.UNSIGNED_SHORT, - 0); + if (!indexBuffer) { + this.gl.drawArrays(glMode, + 0, + glNumElements); + } else { + this.gl.bindBuffer(this.gl.ELEMENT_ARRAY_BUFFER, indexBuffer.gl_buffer_); + this.gl.drawElements(glMode, + glNumElements, + this.gl.UNSIGNED_SHORT, + 0); + } for (var i = 0; i < enabled_attribs.length; ++i) { this.gl.disableVertexAttribArray(enabled_attribs[i]); diff --git a/o3d/samples/o3d-webgl/transform.js b/o3d/samples/o3d-webgl/transform.js index 5c35a80..01231a1 100644 --- a/o3d/samples/o3d-webgl/transform.js +++ b/o3d/samples/o3d-webgl/transform.js @@ -146,7 +146,9 @@ o3d.ParamObject.setUpO3DParam_(o3d.Transform, o3d.Transform.prototype.__defineSetter__('parent', function(p) { - // TODO(petersont): handle removal from any old parent. + if (this.parent_ != null) { + o3d.removeFromArray(this.parent_.children, this); + } this.parent_ = p; if (p) { p.addChild(this); |