Hi Larry,
re:
> First, is there a way to constrain the pointpicker to only allow picking an object's corner or end points?
>
> Using pointpicker.restrictToObject( rect) at least constrains to the rectangle, but non-corner points can be picked by mistake.
You would need to use a custom snap function on the pointpicker for that. But it might be difficult to get it working entirely from script right now.
The snap function itself is a script function that takes a pointpicker as a function argument, like:
function SnapFunc( pointpicker )
{
...
}
You enable the snap function on the pointpicker by calling pointpicker.addSnapFunc( SnapFunc );
The pointpicker will then call the snap function at the beginning of the pointpick calculation and if the snap function has provided a snap point by calling pointpicker.setSnapFuncPoint( pt_xyz, 'label' ); then it will use that snap point.
You can also set pointpicker.onlyUseSnapFunc = true; so that it won't fall back to a regular point pick if there is no snap point provided.
The tricky part is it is up to the snap function to determine which snap point is targeted using the screen coordinates of the mouse.
The hit testing functions for helping with that are not currently exposed to script, nor is the screen coordinates. I'll see about adding those in.
- Michael
|