Skip to content

Latest commit

 

History

History
77 lines (49 loc) · 3.81 KB

File metadata and controls

77 lines (49 loc) · 3.81 KB

iTwin Scenes Tutorial

This repository contains the completed sample application for the Working with iTwin Scenes in your Viewer Application tutorial. The app demonstrates how to integrate the Scenes API into an iTwin Viewer: listing scenes, creating a new scene that captures the current camera position, activating a scene to restore that camera position, and deleting a scene.

Prerequisites

Before running this app, you should have:

Environment Variables

Prior to running the app, add your OIDC client configuration to the variables in the .env file:

# ---- Authorization Client Settings ----
IMJS_AUTH_CLIENT_CLIENT_ID=""
IMJS_AUTH_CLIENT_REDIRECT_URI=""
IMJS_AUTH_CLIENT_LOGOUT_URI=""
IMJS_AUTH_CLIENT_SCOPES="itwin-platform"
  • The itwin-platform scope is already set in .env and grants access to both the iModel viewer and the Scenes API.
  • The redirect URI must match exactly what is registered for your application.

You should also add a valid iTwinId and iModelId in the same file:

# ---- Test ids ----
IMJS_ITWIN_ID = ""
IMJS_IMODEL_ID = ""
  • For IMJS_ITWIN_ID, use the id of one of your existing iTwins. You can obtain iTwin ids via the iTwin REST APIs.
  • For IMJS_IMODEL_ID, use the id of an iModel that belongs to the iTwin above. You can obtain iModel ids via the iModel REST APIs.
  • Alternatively, you can create a test iModel from a sample to get started without an existing iModel.

You can also switch the iModel at runtime by changing the iTwinId or iModelId query parameters in the URL (e.g. localhost:3000?iTwinId=myITwinId&iModelId=myIModelId).

Available Scripts

In the project directory, you can run:

npm install

Installs all dependencies listed in package.json.

npm start

Runs the app in development mode. It automatically opens http://localhost:3000 in your default browser.

The page will reload if you make edits.

npm run build

Builds the app for production to the dist folder. The build is minified and filenames include content hashes.

See the Vite static deploy guide for deployment options.

npm run preview

Once you have built the app using npm run build, you can test it locally by running this command. It boots up a local static web server that serves the files from dist at http://localhost:3000.

npm run lint

Runs ESLint on all source files to check for code style issues and potential errors.

Related Resources