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/checkers.html | |
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/checkers.html')
-rw-r--r-- | o3d/samples/checkers.html | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/o3d/samples/checkers.html b/o3d/samples/checkers.html index 219bc6f..9275bfe 100644 --- a/o3d/samples/checkers.html +++ b/o3d/samples/checkers.html @@ -74,7 +74,7 @@ var g_thisRot; var g_lastRot; var g_zoomFactor; var g_dragging = false; -var g_treeInfo; // information about the transform graph. +var g_pickManager; // information about the transform graph. var g_statusInfoElem; // Animation globals. @@ -354,7 +354,7 @@ function createCheckersBoard() { } // Update our tree info. - updateTreeInfo(); + updateg_pickManager(); // update status. updateStatus('Game starting... RED moves first.', true); @@ -391,11 +391,11 @@ function checkAndUpdateKing(x, y) { /** * Updates the transform tree info. */ -function updateTreeInfo() { - if (!g_treeInfo) { - g_treeInfo = o3djs.picking.createTransformInfo(g_client.root, null); +function updateg_pickManager() { + if (!g_pickManager) { + g_pickManager = o3djs.picking.createPickManager(g_client.root); } - g_treeInfo.update(); + g_pickManager.update(); } /** @@ -577,7 +577,7 @@ function detectSelection(e) { g_client.height); // check if we picked any objects. - var pickInfo = g_treeInfo.pick(worldRay); + var pickInfo = g_pickManager.pick(worldRay); if (pickInfo) { // get the parent transform of this object. var pickTrans = pickInfo.shapeInfo.parent.transform; @@ -774,7 +774,7 @@ function moveSelectedPiece(elapsedTime) { g_moveTimer = 0; // update the tree info. - updateTreeInfo(); + updateg_pickManager(); // check if current player can jump again. if (wasJump && pieceCanJump(g_board[x1][y1])) { |