@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,16 +1,16 @@
|
|
|
1
|
-
<!
|
|
1
|
+
<!doctype html>
|
|
2
2
|
<html lang="en">
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
session:
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
await api.ifc
|
|
41
|
-
|
|
42
|
-
//
|
|
43
|
-
await api.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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);
|