问题
I wanted to use teleportation property of BimWalk extension in my own function of forge viewer. But, I was not able to find the implementation details of teleportation. Is there any way for teleporting to specific object of the model in forge viewer?
回答1:
The simplest approach would be to mimic the mouse interaction to trigger teleporting and set the
// when in first person mode
const bimWalk = viewer.getExtension('Autodesk.BimWalk')
bimWalkExt.tool.navigator.teleporting = true
viewer.select(dbid)
Alternatively you can set the destination of teleportation by calling the navigator tool of the BimWalk extension directly, something like:
const navigator = bimWalkExt.tool.navigator
const camera = viewer.navigation.getCamera()
navigator.teleporting = true;
navigator.teleportTime = 0;
navigator.teleportInitial.copy(camera.position);
// Set target position, collision plus camera's height.
const cameraUp = getTempVector(camera.worldup);
cameraUp.multiplyScalar(navigator.get('cameraDistanceFromFloor') * this.metersToModel);
this.teleportTarget.copy(intersection.intersectPoint).add(cameraUp);
// On floor teleport ends on the spot.
this.teleportVelocity.set(0,0,0);
As Eason has suggested to you earlier there's no official documentation available so you'd need to look through the code yourself ...
来源:https://stackoverflow.com/questions/61634660/forge-viewer-bimwalk-teleportation