Skip to content
This repository was archived by the owner on Apr 11, 2024. It is now read-only.

Commit 6c26d96

Browse files
authored
Merge pull request #4 from Autodesk-Forge/meshbased-hm
Adding meshbased example, upgrading package dependencies
2 parents 60669a4 + d58bf2c commit 6c26d96

21 files changed

+1748
-981
lines changed

client/loader/STLLoader.js

Lines changed: 435 additions & 0 deletions
Large diffs are not rendered by default.

client/pages/AnimatedSprites.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,6 @@ function AnimatedSprites(props) {
229229
* @alias Autodesk.DataVisualization.Examples.AnimatedSprites#onModelLoaded
230230
*/
231231
async function onModelLoaded(viewer, data) {
232-
233-
const dataVizExtension = await viewer.loadExtension("Autodesk.DataVisualization", { useInternal: true });
234-
235232
const viewerDocument = data.model.getDocumentNode().getDocument();
236233
const aecModelData = await viewerDocument.downloadAecModelData();
237234

@@ -242,6 +239,8 @@ function AnimatedSprites(props) {
242239
});
243240
}
244241

242+
const dataVizExtension = viewer.getExtension("Autodesk.DataVisualization")
243+
245244
if (levelsExtension) {
246245
levelsExtension.floorSelector.selectFloor(0, true);
247246
}
@@ -298,6 +297,7 @@ function AnimatedSprites(props) {
298297
env={env}
299298
docUrn={docUrn}
300299
onModelLoaded={onModelLoaded}
300+
extensions={{ "Autodesk.DataVisualization": { useInternal: true } }}
301301
getToken={async () =>
302302
await fetch("/api/token")
303303
.then((res) => res.json())

client/pages/App.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import AnimatedSprites from "./AnimatedSprites.jsx";
1212
import StructureInfo from "./StructureInfo.jsx";
1313
import Navisworks from "./Navisworks.jsx";
1414
import CustomPage from "./CustomPage.jsx";
15+
import MeshHeatmap from "./MeshHeatmap.jsx";
1516

1617
/**
1718
*
@@ -58,7 +59,10 @@ function App(props) {
5859
<Route path="/app">
5960
<CustomPage {...props} />
6061
</Route>
61-
<Route exact={true} path="/">
62+
<Route exact={true} path="/meshheatmap">
63+
<MeshHeatmap {...props} />
64+
</Route>
65+
<Route path="/">
6266
<ReferenceApp {...props} />
6367
</Route>
6468
</Switch>

client/pages/Dot.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function Dot(props) {
6666
* @param {Autodesk.Viewing.GuiViewer3D} viewer The viewer in which the model is loaded.
6767
*/
6868
async function onModelLoaded(viewer) {
69-
const dataVizExt = await viewer.loadExtension("Autodesk.DataVisualization", { useInternal: true });
69+
const dataVizExt = viewer.getExtension("Autodesk.DataVisualization");
7070
const DATAVIZEXTN = Autodesk.DataVisualization.Core;
7171
var styleMap = {};
7272

@@ -119,6 +119,7 @@ function Dot(props) {
119119
env={env}
120120
docUrn={docUrn}
121121
onModelLoaded={onModelLoaded}
122+
extensions={{ "Autodesk.DataVisualization": { useInternal: true } }}
122123
getToken={async () => await fetch("/api/token").then(res => res.json()).then(data => data.access_token)}
123124
/>
124125
</React.Fragment>

client/pages/EngineSimulation.jsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44

55
import React, { useEffect, useRef, useState } from "react";
6+
import { useLocation } from "react-router";
67
import { BaseApp } from "forge-dataviz-iot-react-components";
78
import DataHelper from "./DataHelper";
89
import { EventTypes } from "forge-dataviz-iot-react-components";
@@ -128,7 +129,7 @@ THREE.EventDispatcher.prototype.apply(EventBus.prototype);
128129
* @param {"derivativeV2"|"derivativeV2_EU"|"modelDerivativeV2"|"fluent"|"D3S"|"D3S_EU"} [props.appData.api] Please refer to LMV documentation for more information.
129130
* @param {Object} props.appContext Contains base urls used to query assets, LMV, data etc.
130131
* @param {string} [props.appContext.dataUrl] The base url used to configure a specific {@link DataAdapter}
131-
*
132+
* @param {number|undefined} geomIndex Index of geometry to be shown. Forwarded via URL params.
132133
* @memberof Autodesk.DataVisualization.Examples
133134
*/
134135
function EngineSimulation(props) {
@@ -138,6 +139,9 @@ function EngineSimulation(props) {
138139
const dataRef = useRef();
139140
const viewerRef = useRef(null);
140141

142+
const queryParams = new URLSearchParams(useLocation().search);
143+
const geomIndex = queryParams.get("geometryIndex") ? parseInt(queryParams.get("geometryIndex")) : undefined;
144+
141145
props.appData.docUrn = "urn:dXJuOmFkc2sub2JqZWN0czpvcy5vYmplY3Q6Zm9yZ2V0X2h5cGVyaW9uX3Rlc3QvRW5naW5lX1N0YW5kLmR3Zg";
142146
props.appData.adapterType = "synthetic";
143147

@@ -162,7 +166,7 @@ function EngineSimulation(props) {
162166

163167
return (
164168
<React.Fragment>
165-
<BaseApp {...props} eventBus={eventBusRef.current} data={data} />
169+
<BaseApp {...props} eventBus={eventBusRef.current} data={data} geomIndex={geomIndex} />
166170
</React.Fragment>
167171
);
168172
}

client/pages/Heatmap.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ function Heatmap(props) {
7474
* @param {Object} data Event data that contains the loaded model.
7575
*/
7676
async function onModelLoaded(viewer, data) {
77-
const dataVizExt = await viewer.loadExtension("Autodesk.DataVisualization", { useInternal: true });
77+
const dataVizExt = viewer.getExtension("Autodesk.DataVisualization");
7878
const DATAVIZEXTN = Autodesk.DataVisualization.Core;
7979
var styleMap = {};
8080

@@ -117,9 +117,7 @@ function Heatmap(props) {
117117

118118
const structureInfo = new DATAVIZEXTN.ModelStructureInfo(data.model);
119119
const heatmapData = await structureInfo.generateSurfaceShadingData(devices);
120-
121-
dataVizExt.setupSurfaceShading(data.model, heatmapData);
122-
120+
await dataVizExt.setupSurfaceShading(data.model, heatmapData);
123121
dataVizExt.registerSurfaceShadingColors("co2", [0x00ff00, 0xff0000]);
124122
dataVizExt.registerSurfaceShadingColors("temperature", [0xff0000, 0x0000ff]);
125123

@@ -145,6 +143,7 @@ function Heatmap(props) {
145143
env={env}
146144
docUrn={docUrn}
147145
onModelLoaded={onModelLoaded}
146+
extensions={{ "Autodesk.DataVisualization": { useInternal: true } }}
148147
getToken={async () => await fetch("/api/token").then(res => res.json()).then(data => data.access_token)}
149148
/>
150149
</React.Fragment>

0 commit comments

Comments
 (0)