|
1 | | -# Getting Started with the iTwin Viewer Template |
| 1 | +# iTwin Scenes Tutorial |
2 | 2 |
|
3 | | -This project was scaffolded with [degit](https://github.com/Rich-Harris/degit). |
| 3 | +This repository contains the completed sample application for the [Working with iTwin Scenes in your Viewer Application](https://developer.bentley.com/tutorials/scenes-tutorial/) tutorial. The app demonstrates how to integrate the [Scenes API](https://developer.bentley.com/apis/scenes/) 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. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +Before running this app, you should have: |
| 8 | + |
| 9 | +- A registered application on the [iTwin Developer Portal](https://developer.bentley.com/register/) with the `itwin-platform` OAuth scope. This scope covers both the viewer and the Scenes API. |
| 10 | + - See [Register an application](https://developer.bentley.com/tutorials/web-application-quick-start/#3-register-an-application) for step-by-step instructions. |
| 11 | +- An iTwin with appropriate permissions to manage scenes. |
| 12 | +- An iModel to open in the viewer. The tutorial uses the "House Model" sample iModel. |
| 13 | + - See [Create a test iModel from a Bentley provided sample](https://developer.bentley.com/tutorials/create-test-imodel-sample/) for instructions. |
4 | 14 |
|
5 | 15 | ## Environment Variables |
6 | 16 |
|
7 | | -Prior to running the app, you will need to add OIDC client configuration to the variables in the .env file: |
| 17 | +Prior to running the app, add your OIDC client configuration to the variables in the `.env` file: |
8 | 18 |
|
9 | 19 | ``` |
10 | 20 | # ---- Authorization Client Settings ---- |
11 | 21 | IMJS_AUTH_CLIENT_CLIENT_ID="" |
12 | 22 | IMJS_AUTH_CLIENT_REDIRECT_URI="" |
13 | 23 | IMJS_AUTH_CLIENT_LOGOUT_URI="" |
14 | | -IMJS_AUTH_CLIENT_SCOPES="" |
| 24 | +IMJS_AUTH_CLIENT_SCOPES="itwin-platform" |
15 | 25 | ``` |
16 | 26 |
|
17 | | -- You can generate a [test client](https://developer.bentley.com/tutorials/web-application-quick-start/#3-register-an-application) to get started. |
18 | | - |
19 | | -- Viewer expects the `itwin-platform` scope to be set. |
| 27 | +- The `itwin-platform` scope is already set in `.env` and grants access to both the iModel viewer and the Scenes API. |
| 28 | +- The redirect URI must match exactly what is registered for your application. |
20 | 29 |
|
21 | | -- The application will use the path of the redirect URI to handle the redirection, it must simply match what is defined in your client. |
22 | | - |
23 | | -- When you are ready to build a production application, [register here](https://developer.bentley.com/register/). |
24 | | - |
25 | | -You should also add a valid iTwinId and iModelId for your user in the this file: |
| 30 | +You should also add a valid iTwinId and iModelId in the same file: |
26 | 31 |
|
27 | 32 | ``` |
28 | 33 | # ---- Test ids ---- |
29 | 34 | IMJS_ITWIN_ID = "" |
30 | 35 | IMJS_IMODEL_ID = "" |
31 | 36 | ``` |
32 | 37 |
|
33 | | -- For the IMJS_ITWIN_ID variable, you can use the id of one of your existing iTwins. You can obtain their ids via the [iTwin REST APIs](https://developer.bentley.com/apis/itwins/operations/get-itwin/). |
34 | | - |
35 | | -- For the IMJS_IMODEL_ID variable, use the id of an iModel that belongs to the iTwin that you specified in the IMJS_ITWIN_ID variable. You can obtain iModel ids via the [iModel REST APIs](https://developer.bentley.com/apis/imodels-v2/operations/get-imodel-details/). |
| 38 | +- For `IMJS_ITWIN_ID`, use the id of one of your existing iTwins. You can obtain iTwin ids via the [iTwin REST APIs](https://developer.bentley.com/apis/itwins/operations/get-itwin/). |
| 39 | +- 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](https://developer.bentley.com/apis/imodels-v2/operations/get-imodel-details/). |
| 40 | +- Alternatively, you can [create a test iModel from a sample](https://developer.bentley.com/tutorials/create-test-imodel-sample/) to get started without an existing iModel. |
36 | 41 |
|
37 | | -- Alternatively, you can [generate a test iModel](https://developer.bentley.com/tutorials/web-application-quick-start/#4-create-an-imodel) to get started without an existing iModel. |
38 | | - |
39 | | -- If at any time you wish to change the iModel that you are viewing, you can change the values of the iTwinId or iModelId query parameters in the url (i.e. localhost:3000?iTwinId=myNewITwinId&iModelId=myNewIModelId) |
| 42 | +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`). |
40 | 43 |
|
41 | 44 | ## Available Scripts |
42 | 45 |
|
43 | 46 | In the project directory, you can run: |
44 | 47 |
|
45 | 48 | ### `npm install` |
46 | 49 |
|
47 | | -Installs all the dependencies listed in your package.json. |
| 50 | +Installs all dependencies listed in `package.json`. |
48 | 51 |
|
49 | 52 | ### `npm start` |
50 | 53 |
|
51 | | -Runs the app in the development mode.\ |
52 | | -It automatically opens [http://localhost:3000](http://localhost:3000) in your default browser. |
| 54 | +Runs the app in development mode. It automatically opens [http://localhost:3000](http://localhost:3000) in your default browser. |
53 | 55 |
|
54 | | -The page will reload if you make edits.\ |
| 56 | +The page will reload if you make edits. |
55 | 57 |
|
56 | 58 | ### `npm run build` |
57 | 59 |
|
58 | | -Builds the app for production to the `dist` folder.\ |
59 | | -It bundles your code in production mode and applies optimizations for best performance. |
60 | | - |
61 | | -The build is minified and the filenames include the hashes.\ |
62 | | -Your app is ready to be deployed! |
| 60 | +Builds the app for production to the `dist` folder. The build is minified and filenames include content hashes. |
63 | 61 |
|
64 | | -See the section about [deployment](https://vite.dev/guide/static-deploy.html) for more information. |
| 62 | +See the [Vite static deploy guide](https://vite.dev/guide/static-deploy.html) for deployment options. |
65 | 63 |
|
66 | 64 | ### `npm run preview` |
67 | 65 |
|
68 | | -Once you have built the app using `npm run build` you may test it locally by running this command. |
69 | | - |
70 | | -This will boot up a local static web server that serves the files from `dist` at [http://localhost:3000](http://localhost:3000). |
| 66 | +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](http://localhost:3000). |
71 | 67 |
|
72 | 68 | ### `npm run lint` |
73 | 69 |
|
74 | 70 | Runs ESLint on all source files to check for code style issues and potential errors. |
75 | 71 |
|
76 | | -## Next Steps |
77 | | - |
78 | | -- [iTwin Viewer options](https://www.npmjs.com/package/@itwin/web-viewer-react) |
79 | | - |
80 | | -- [Extending the iTwin Viewer](https://developer.bentley.com/tutorials/itwin-viewer-hello-world/) |
81 | | - |
82 | | -- [Using the iTwin Platform](https://developer.bentley.com/) |
| 72 | +## Related Resources |
83 | 73 |
|
84 | | -- [iTwin Developer Program](https://www.youtube.com/playlist?list=PL6YCKeNfXXd_dXq4u9vtSFfsP3OTVcL8N) |
| 74 | +- [Working with iTwin Scenes in your Viewer Application](https://developer.bentley.com/tutorials/scenes-tutorial/) — the tutorial this repository accompanies |
| 75 | +- [Scenes API documentation](https://developer.bentley.com/apis/scenes/overview/) |
| 76 | +- [iTwin Viewer React package](https://www.npmjs.com/package/@itwin/web-viewer-react) |
| 77 | +- [iTwin Platform](https://developer.bentley.com/) |
0 commit comments