Skip to content

BeeInventor Forge Extension Documentation

Surya Kumara edited this page Nov 29, 2021 · 10 revisions

BeeInventor Extension

1

1. Credential for Autodesk Forge API

To use this extension, you will need Autodesk Developer credentials and API’s. Visit Autodesk Forge Portal, sign up and create an app.
Then, use http://localhost:3000/api/forge/callback/oauth as the Callback URL, although it is not used on a 2-legged flow. When making an app on forge, check the API’s you want to use. For this minimal viewer, please check the Model Derivative API and Data Management API. Finally take a note of the Client ID and Client Secret.

1

2. Setup Viewer

This step is to create a viewer in your application. Visit BeeInventor repository to create a minimal viewer or follow how to build a viewer from Autodesk Forge Official. One thing that needs to be considered in the setup viewer is the option when loading the model. Go to public/js/ForgeViewer.js. Use the following settings to keep the scale of the scene in meters.

 const beeOption = {
   applyScaling: { to: "meters" },
   globalOffset: { x: 0, y: 0, z: 0 },
   keepCurrentModels: true,
 };
 viewer.loadDocumentNode(doc, viewables, beeOption).then((i) => {
 });

3. Run the viewer and create environment.

Create .env file with the following variables :

 PORT=3000
 FORGE_CLIENT_ID="Your Forge Client Id"
 FORGE_CLIENT_SECRET="Your Forge Client Secret"
 FORGE_CALLBACK_URL=http://localhost:3000/api/forge/callback/oauth

To run the program locally, use the following command: Install dependencies with:

 npm install

Run locally :

 npm start

4. Upload 3D BIM Model

Please upload the model that you will use with this extension. Here there are several APIs used, namely the Data Management API and the Model Derivative API.
How to upload models:

  • Create a bucket
    Buckets are spaces that are created by applications and are used to store objects for later retrieval. A bucket is owned by the application that creates it.

  • When naming a bucket, make sure to give it a unique name that doesn't contain capital letters

  • Upload the model
    Right click on the bucket that you created and select the model you want to view in Forge. You could upload various kind of 3D model format in bucket.

  • Translation Model
    The Model Derivative API lets you translate a model into several types of output file formats simultaneously. Do a translation of the model to SVF format so that the model can be viewed in the browser.

5. Load The Extension

When the viewer is ready, now open the index.html file. There are several things that need to be setup.

  • Load Custom Font for 3D Text
<script src="https://lib.cdn.dasiot.site/forge/assets/font3d/Monaco_Regular.js"></script>
  • Load CSS
<script src="https://lib.cdn.dasiot.site/forge/v0.1.5/extension.min.js"></script>
  • Load BeeInventor Extension
<script src="https://lib.cdn.dasiot.site/forge/v0.1.5/extension.min.js"></script>
  • Load Websocket CDN
<script src="https://cdn.socket.io/4.3.2/socket.io.min.js" integrity="sha384-KAZ4DtjNhLChOB/hxXuKqhMLYvx3b5MlT55xPEiNmREKRzeEm+RVPlTnAn0ajQNs" crossorigin="anonymous"></script>
  • Below shows the expected structure :
    | 
    |-> websocket
    |-> assets/fonts/Monaco_Regular.js
    |-> extension/main.css
    |-> extension/beeinventor-extension.js
  • After the extension module is imported, go to the public/js/ForgeViewer.js folder and register the extension by:
   viewer = new Autodesk.Viewing.GuiViewer3D(
     document.getElementById("forgeViewer"),
     { extensions: ["BeeInventor"] }
   );

Notes :

Make sure the up direction on the building is on the z-axis.

1

Guidance for Tools

1 Object Info.

Represent tools that can provide information by clicking on 3D objects in the scene. The information includes:
Worker ID, Latitude and Longitude

1 Info Card.

To display the infocard or label on a specific object clicked by the cursor.

1 Transform Control.

A tool that is used to adjust the position of a model by dragging the transform in the direction (x, y, z).

1 Dark Mode.

To switch to the night mode.

1 Rotate Camera.

Tool to be able to do a 360-degree view of the building model automatically.

1 Building Setup.

Doing setup on the building when the building is not in the center or expected location.

1 Restricted Area Setup.

Perform manual setup for restricted area such as setting location or height of the area.


Contact or Questions :

Email : hello@beeinventor

Website :

https://www.beeinventor.com/en/



1

Clone this wiki locally