diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-03 00:30:36 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-12-03 00:30:36 +0000 |
commit | 8dc465e39dd10bd23a4f24481d2bf146404596a7 (patch) | |
tree | e0da44eaee7bd4402a9844e1b68c50149cd290dd /o3d/samples/o3djs/manipulators.js | |
parent | acaae862120b887d04432fd81e2c2c47cbd1256c (diff) | |
download | chromium_src-8dc465e39dd10bd23a4f24481d2bf146404596a7.zip chromium_src-8dc465e39dd10bd23a4f24481d2bf146404596a7.tar.gz chromium_src-8dc465e39dd10bd23a4f24481d2bf146404596a7.tar.bz2 |
Updates the picking library to have a PickManager and
support both not picking invisible objects and
the option to pick even if invisible.
The idea is you can do something like this
// Make a picking manager
var pm = o3djs.picking.createPickManager(rootTransform);
... // add a bunch of transforms.
// generate picking objects.
pm.update();
// Get the picking object that was created for some specific transform
var info = pm.getTransformInfo(someTransform);
// Set properties on that object related to picking
info.pickEvenIfInvisible = true;
I think this is just a first step. How an object should
be defined as pickable is up for debate. As it is,
you can basically override info.isPickable.
as in
info.isPickable = function() {
// do something custom.
}
You can also start adding things easier like
info.onPick = function() {
// do something.
}
and then write code like
info = pm.pick(worldRay);
if (info) {
info.onPick();
}
While you could have done that before there was no
easy way to find a the TransformInfo for a
specific Transform. Now you can use
PickManager.getTransformInfo
Review URL: http://codereview.chromium.org/452027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@33632 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d/samples/o3djs/manipulators.js')
-rw-r--r-- | o3d/samples/o3djs/manipulators.js | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/o3d/samples/o3djs/manipulators.js b/o3d/samples/o3djs/manipulators.js index 7bea7a5..85fb611 100644 --- a/o3d/samples/o3djs/manipulators.js +++ b/o3d/samples/o3djs/manipulators.js @@ -511,11 +511,11 @@ o3djs.manipulators.Manager = function(pack, this.manipsByClientId = []; /** - * Presumably we need a TransformInfo for the parentTransform. + * A PickManager to manage picking for the manipulators. * @type {!o3djs.picking.TransformInfo} */ - this.transformInfo = - o3djs.picking.createTransformInfo(this.parentTransform, null); + this.pickManager = + o3djs.picking.createPickManager(this.parentTransform); /** * The currently-highlighted manipulator. @@ -614,7 +614,7 @@ o3djs.manipulators.Manager.prototype.handleMouse_ = function(x, width, height, func) { - this.transformInfo.update(); + this.pickManager.update(); // Create the world ray var worldRay = @@ -623,7 +623,7 @@ o3djs.manipulators.Manager.prototype.handleMouse_ = function(x, width, height); // Pick against all of the manipulators' geometry - var pickResult = this.transformInfo.pick(worldRay); + var pickResult = this.pickManager.pick(worldRay); if (pickResult != null) { // Find which manipulator we picked. // NOTE this assumes some things about the transform graph @@ -1159,8 +1159,9 @@ o3djs.manipulators.Translate1 = function(manager) { this.addShapes_([ shape ]); - this.transformInfo = o3djs.picking.createTransformInfo(this.getTransform(), - manager.transformInfo); + this.transformInfo = manager.pickManager.createTransformInfo( + this.getTransform(), + manager.transformInfo); /** * A parameter added to our transform to be able to change the @@ -1270,8 +1271,9 @@ o3djs.manipulators.Translate2 = function(manager) { this.addShapes_([ shape ]); - this.transformInfo = o3djs.picking.createTransformInfo(this.getTransform(), - manager.transformInfo); + this.transformInfo = manager.pickManager.createTransformInfo( + this.getTransform(), + manager.transformInfo); /** * A parameter added to our transform to be able to change the @@ -1383,8 +1385,9 @@ o3djs.manipulators.Rotate1 = function(manager) { this.addShapes_([ shape ]); - this.transformInfo = o3djs.picking.createTransformInfo(this.getTransform(), - manager.transformInfo); + this.transformInfo = manager.pickManager.createTransformInfo( + this.getTransform(), + manager.transformInfo); /** * A parameter added to our transform to be able to change the |