I am trying to figure out how to create a 3D Javascript that overwrites the default behavior for a selected 3D object. By default, the 3D object turns red and shows a bounding box when selected.
I would like to 1) turn off the bounding box display and 2) do something different like use a hidden line rendering (white with black outlines).
I need to do this via Javascript so the behavior is embedded in the file. (i.e., I cannot rely on the 3D preferences that enable you to disable the bounding box.)
I tried looking at the 3D Javascript API but see nothing obvious. I have a 3D PDF that exhibits this behavior but cannot access the 3D Javascript attached to the 3D Annot.
Simple example that opens an alert when you click something - paste this into a .js file and load as the embedded script of a 3D annotation:
// start of script example
runtime.overrideSelection = true;
var myMouseHandler = function( event ) {
if ( event.isMouseUp ) {
var myMesh = null;
if ( event.hits.length > 0 ) myMesh = event.hits[0].target;
if ( myMesh != null ) {
// do your selection-based stuff here
host.app.alert("You clicked on " + myMesh.name);
}
}
}
var mouseEventHandler = new MouseEventHandler();
mouseEventHandler.onMouseDown = false;
mouseEventHandler.onMouseMove = false;
mouseEventHandler.onMouseUp = true;
mouseEventHandler.onEvent = myMouseHandler;
runtime.addEventHandler( mouseEventHandler );
// end of script example