@twinfinity/templates 6.0.1-ci.28952 → 6.0.2-ci.29168

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twinfinity/templates",
3
- "version": "6.0.1-ci.28952",
3
+ "version": "6.0.2-ci.29168",
4
4
  "description": "CLI for scaffolding Twinfinity starter projects",
5
5
  "author": "Twinfinity",
6
6
  "license": "ISC",
@@ -1,16 +1,16 @@
1
- <!DOCTYPE html>
1
+ <!doctype html>
2
2
  <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <title><%= htmlWebpackPlugin.options.title %></title>
6
- <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <style>
8
- canvas {
9
- width: 100%;
10
- }
11
- </style>
12
- </head>
13
- <body>
14
- <canvas id="twinfinity-viewer"></canvas>
15
- </body>
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title><%= htmlWebpackPlugin.options.title %></title>
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <style>
8
+ canvas {
9
+ width: 100%;
10
+ }
11
+ </style>
12
+ </head>
13
+ <body>
14
+ <canvas id="twinfinity-viewer"></canvas>
15
+ </body>
16
16
  </html>
@@ -1,56 +1,60 @@
1
- import { TwinfinitySession } from '@twinfinity/authentication';
2
- import { BimApi } from '@twinfinity/core';
3
-
4
- const host = '{{twinfinityUrl}}';
5
- const clientId = '{{clientId}}';
6
-
7
- async function getApi(): Promise<BimApi> {
8
- // Establish an authenticated session
9
- const twinfinitySession = await TwinfinitySession.establish({
10
- clientId,
11
- openIdProviderUrl: `${host}/idp`,
12
- redirectUri: 'https://localhost:9000'
13
- });
14
-
15
- twinfinitySession.registerOnSessionTerminatedCallback((e) => {
16
- alert(`Twinfinity session ended: ${e.type}`);
17
- });
18
-
19
- return await BimApi.create('twinfinity-viewer', host, {
20
- session: twinfinitySession
21
- });
22
- }
23
-
24
- async function main(): Promise<void> {
25
- const api = await getApi();
26
-
27
- // Find a loadable project
28
- const containers = await api.backend.getContainers();
29
- const containerWithGeometry = containers.find((container) => container.hasGeometry);
30
- if (containerWithGeometry == null) {
31
- console.log('No container with geometry');
32
- return;
33
- }
34
-
35
- // Select the container without implicitly loading any IFC files.
36
- await api.setContainer(containerWithGeometry, 'skip-ifc-load');
37
-
38
- // Fetch the list of IFC files in the container and load their hierarchies.
39
- const ifcFiles = await api.backend.getIfcChanges(containerWithGeometry);
40
- await api.ifc.add(ifcFiles);
41
-
42
- // Load property sets for the IFC products.
43
- await api.ifc.loadPropertySets();
44
-
45
- // Frame the loaded scene with the camera before geometry starts streaming in.
46
- api.viewer.addOrUpdateEnvironment({
47
- boundingInfo: api.ifc.regionBoundingInfo,
48
- positionCameraToFitBounds: true
49
- });
50
-
51
- // Build geometry for the loaded IFC products and add it to the viewer as each mesh is ready.
52
- const geometryBuilder = await api.ifc.geometryBuilder();
53
- await geometryBuilder.build(({ geometry }) => api.viewer.addOrReplaceMesh(geometry));
54
- }
55
-
56
- main().catch(console.error);
1
+ import { TwinfinitySession } from '@twinfinity/authentication';
2
+ import { BimApi } from '@twinfinity/core';
3
+
4
+ const host = '{{twinfinityUrl}}';
5
+ const clientId = '{{clientId}}';
6
+
7
+ async function getApi(): Promise<BimApi> {
8
+ // Establish an authenticated session
9
+ const twinfinitySession = await TwinfinitySession.establish({
10
+ clientId,
11
+ // This sample runs on localhost but talks to a remote Twinfinity backend, so discovery is rooted
12
+ // at the backend host rather than the current origin. The apiUrl option derives the
13
+ // /.well-known/openid-configuration URL from that host (stripping a leading bim.); this also pins
14
+ // the session's origin to it, which is what BimApi.create below verifies against.
15
+ apiUrl: host,
16
+ redirectUri: 'https://localhost:9000'
17
+ });
18
+
19
+ twinfinitySession.registerOnSessionTerminatedCallback((e) => {
20
+ alert(`Twinfinity session ended: ${e.type}`);
21
+ });
22
+
23
+ return await BimApi.create('twinfinity-viewer', host, {
24
+ session: twinfinitySession
25
+ });
26
+ }
27
+
28
+ async function main(): Promise<void> {
29
+ const api = await getApi();
30
+
31
+ // Find a loadable project
32
+ const containers = await api.backend.getContainers();
33
+ const containerWithGeometry = containers.find((container) => container.hasGeometry);
34
+ if (containerWithGeometry == null) {
35
+ console.log('No container with geometry');
36
+ return;
37
+ }
38
+
39
+ // Select the container without implicitly loading any IFC files.
40
+ await api.setContainer(containerWithGeometry, 'skip-ifc-load');
41
+
42
+ // Fetch the list of IFC files in the container and load their hierarchies.
43
+ const ifcFiles = await api.backend.getIfcChanges(containerWithGeometry);
44
+ await api.ifc.add(ifcFiles);
45
+
46
+ // Load property sets for the IFC products.
47
+ await api.ifc.loadPropertySets();
48
+
49
+ // Frame the loaded scene with the camera before geometry starts streaming in.
50
+ api.viewer.addOrUpdateEnvironment({
51
+ boundingInfo: api.ifc.regionBoundingInfo,
52
+ positionCameraToFitBounds: true
53
+ });
54
+
55
+ // Build geometry for the loaded IFC products and add it to the viewer as each mesh is ready.
56
+ const geometryBuilder = await api.ifc.geometryBuilder();
57
+ await geometryBuilder.build(({ geometry }) => api.viewer.addOrReplaceMesh(geometry));
58
+ }
59
+
60
+ main().catch(console.error);