Skip to main content
Practitioner ⭐️
Feb 8, 2023 5:26 AM UTC
Solved

Learn Cognite 3D Model

Learn Cognite 3d model, focus object, fit camera, search assets highlight object etc..

    Lars Moastuen
    Expert ⭐️⭐️⭐️⭐️
    Feb 8, 2023 7:01 PM UTC

    To focus at a clicked object in Reveal, you can do

    1. Get “Point intersection with the object” using Cognite3DViewer.getIntersectionFromPixel(offsetX, offsetY).
    2. Create a bounding box around intersection point like

      const boundingBox = new THREE.Box3();
      boundingBox.setFromCenterAndSize(intersection.point, new THREE.Vector3(1, 1, 1));
    3.  Use this bounding box in Cognite3DViewer.fitCameraToBoundingBox()
      viewer.fitCameraToBoundingBox(boundingBox, 250);

       

    Note that rather than using bounding box directly from the CDF API, it’s recommended to use https://cognitedata.github.io/reveal-docs/docs/api/classes/cognite_reveal.CogniteCadModel#getboundingboxbynodeid to get bounding box for a given node as this accounts for any transformation active on the model.

    Lars Moastuen (Software Engineer, Atlas AI)

    27 replies

    Practitioner ⭐️
    Feb 8, 2023 5:35 AM UTC
    1. How to search object through assets ?
    2. How to focus object?

     

    Practitioner ⭐️
    Feb 8, 2023 11:25 AM UTC

    How to use fitCameraToBoundingBox method? please share some info.

    https://cognitedata.github.io/reveal-docs/docs/api/classes/cognite_reveal.DefaultCameraManager

    Practitioner ⭐️⭐️⭐️
    Feb 8, 2023 3:20 PM UTC

    To focus at a clicked object in Reveal, you can do

    1. Get “Point intersection with the object” using Cognite3DViewer.getIntersectionFromPixel(offsetX, offsetY).
    2. Create a bounding box around intersection point like

      const boundingBox = new THREE.Box3();
      boundingBox.setFromCenterAndSize(intersection.point, new THREE.Vector3(1, 1, 1));
    3.  Use this bounding box in Cognite3DViewer.fitCameraToBoundingBox()
      viewer.fitCameraToBoundingBox(boundingBox, 250);

       

    Lars Moastuen
    Expert ⭐️⭐️⭐️⭐️
    Expert ⭐️⭐️⭐️⭐️
    Feb 8, 2023 7:01 PM UTC

    To focus at a clicked object in Reveal, you can do

    1. Get “Point intersection with the object” using Cognite3DViewer.getIntersectionFromPixel(offsetX, offsetY).
    2. Create a bounding box around intersection point like

      const boundingBox = new THREE.Box3();
      boundingBox.setFromCenterAndSize(intersection.point, new THREE.Vector3(1, 1, 1));
    3.  Use this bounding box in Cognite3DViewer.fitCameraToBoundingBox()
      viewer.fitCameraToBoundingBox(boundingBox, 250);

       

    Note that rather than using bounding box directly from the CDF API, it’s recommended to use https://cognitedata.github.io/reveal-docs/docs/api/classes/cognite_reveal.CogniteCadModel#getboundingboxbynodeid to get bounding box for a given node as this accounts for any transformation active on the model.

    Lars Moastuen (Software Engineer, Atlas AI)
    Practitioner ⭐️
    Feb 9, 2023 5:53 AM UTC

    thank you so mush, its working

    Practitioner ⭐️
    Feb 9, 2023 12:10 PM UTC
    Practitioner ⭐️⭐️⭐️
    Feb 9, 2023 12:22 PM UTC

    https://cognitedata.github.io/reveal-docs/docs/examples/click-reactions-cad

     

    How to enable and disable mouse click event?

     

    The documentation page you referred https://cognitedata.github.io/reveal-docs/docs/examples/click-reactions-cad/ shows how to enable mouse click event “viewer.on(‘click’, callbackFn)”, to disable, unsubscribe the event using “viewer.off(‘click’, callbackFn)”

    Practitioner ⭐️
    Feb 10, 2023 7:30 AM UTC
    Practitioner ⭐️⭐️⭐️
    Feb 10, 2023 9:28 AM UTC

    Hey, seems to be a small bug in our documentation. You need to await the viewer.add360ImageSet(...) method as it returns a promise.

    Practitioner ⭐️
    Feb 10, 2023 10:05 AM UTC

    I add await but again error comming.