0

This question is aimed at the Autodesk Forge experts here. I have started looking into Forge recently and wondered if Forge can do what I have in mind. I have a few location data (x,y,z) and a simple BIM model of a room created with Revit. I wanted to know if I could show the movement path using the locations I have in Forge. Also, I was wondering if Forge could tell I might hit the wall instead of successfully going out of the room from the door frame.

Thank you!

1 Answers1

0

It sounds most like my traveling path sample:

https://forge.autodesk.com/blog/move-viewers-camera-along-drawing-travelwalking-paths-forge-viewer

To use the location data, you can pass them to the _createLineMesh function like the below

const ext = await viewer.loadExtension( 'Autodesk.ADN.WalkingPathToolExtension' );

ext._createLineMesh( locations );

To check if you hit walls, you could try to do ray casting from the camera position and along the sight direction in the first-person mode when moving the camera.

viewer.addEventListener(
    Autodesk.Viewing.CAMERA_CHANGE_EVENT,
    ( camera ) => {
        const ray = new THREE.Ray( viewer.navigation.getPosition().clone(), viewer.navigation.getEyeVector().clone().normalize() );
        let ignoreTransparent = false;

         let intersection = viewer.impl.rayIntersect( ray, ignoreTransparent );
         if( !intersection ) return;
         
         console.log( 'hit something' );

         // intersection.dbId //!<< interseted object id
         // intersection.distance //!<< the distance between the hit target and the ray position
     });

ref: https://forge.autodesk.com/en/docs/viewer/v7/reference/Viewing/GuiViewer3D/

Eason Kang
  • 6,155
  • 1
  • 7
  • 24