Skip to content

Commit

Permalink
✨ 3D widget and tab for 3D in Workorder app (#774)
Browse files Browse the repository at this point in the history
- Refactored and simplified ModelViewer component 
- Removed effects and state from most components
- Added lazy loading to support chunking
- Added support for environment variables
- Removed widgets
- Fixed styling
- Optimized viewer performance
  • Loading branch information
espenkalle authored Apr 11, 2024
1 parent 32222c5 commit 7aea030
Show file tree
Hide file tree
Showing 105 changed files with 2,651 additions and 3,180 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/fprd-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ jobs:
env:
#Runs out of memory when bundling more apps otherwise even though concurrency is 1
NODE_OPTIONS: '--max_old_space_size=4096'
run: npx turbo run fprd:deploy --since ${{github.event.before}} --concurrency 1 -- --token ${{ steps.get-fusion-token.outputs.token }} --ai '${{secrets.ai}}' --sha '${{github.sha}}'
run: npx turbo run fprd:deploy --since ${{github.event.before}} --concurrency 1 -- --token ${{ steps.get-fusion-token.outputs.token }} --ai '${{secrets.ai}}' --modelViewerConfig '${{vars.modelViewerConfig}}' --sha '${{github.sha}}'
2 changes: 1 addition & 1 deletion .github/workflows/manual-deploy-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ jobs:
env:
#Runs out of memory when bundling more apps otherwise even though concurrency is 1
NODE_OPTIONS: '--max_old_space_size=4096'
run: npx turbo run fprd:deploy --filter=${{inputs.appKey}} --concurrency 1 -- --token ${{ steps.get-fusion-token.outputs.token }} --ai '${{secrets.ai}}' --sha '${{github.sha}}'
run: npx turbo run fprd:deploy --filter=${{inputs.appKey}} --concurrency 1 -- --token ${{ steps.get-fusion-token.outputs.token }} --ai '${{secrets.ai}}' --modelViewerConfig '${{vars.modelViewerConfig}}' --sha '${{github.sha}}'
2 changes: 1 addition & 1 deletion .github/workflows/manual-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ jobs:
env:
#Runs out of memory when bundling more apps otherwise even though concurrency is 1
NODE_OPTIONS: '--max_old_space_size=4096'
run: npx turbo run pr:deploy --filter='${{inputs.category}}' --concurrency 1 -- --token ${{ steps.get-fusion-token.outputs.token }} --ai '${{secrets.ai}}' --sha '${{github.sha}}'
run: npx turbo run pr:deploy --filter='${{inputs.category}}' --concurrency 1 -- --token ${{ steps.get-fusion-token.outputs.token }} --ai '${{secrets.ai}}' --modelViewerConfig '${{vars.modelViewerConfig}}' --sha '${{github.sha}}'
2 changes: 1 addition & 1 deletion .github/workflows/pr-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
env:
#Runs out of memory when bundling more apps otherwise even though concurrency is 1
NODE_OPTIONS: '--max_old_space_size=4096'
run: npx turbo run pr:deploy --since origin/main --concurrency 1 -- --token ${{ steps.get-fusion-token.outputs.token }} --pr '${{ github.event.issue.number }}' --ai '${{secrets.ai}}' --sha '${{steps.comment-branch.outputs.head_sha}}'
run: npx turbo run pr:deploy --since origin/main --concurrency 1 -- --token ${{ steps.get-fusion-token.outputs.token }} --pr '${{ github.event.issue.number }}' --ai '${{secrets.ai}}' --modelViewerConfig '${{vars.modelViewerConfig}}' --sha '${{steps.comment-branch.outputs.head_sha}}'

- name: Comment pr
uses: actions/github-script@v7
Expand Down
3 changes: 0 additions & 3 deletions apps/modelviewer/README.md

This file was deleted.

20 changes: 0 additions & 20 deletions apps/modelviewer/package.json

This file was deleted.

61 changes: 0 additions & 61 deletions apps/modelviewer/src/main.tsx

This file was deleted.

22 changes: 0 additions & 22 deletions apps/modelviewer/tsconfig.app.json

This file was deleted.

22 changes: 0 additions & 22 deletions apps/modelviewer/tsconfig.json

This file was deleted.

4 changes: 0 additions & 4 deletions apps/modelviewer/vite.config.ts

This file was deleted.

8 changes: 8 additions & 0 deletions apps/workorder/app.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ export default () => ({
environment: {
uri: 'https://backend-fusion-data-gateway-test.radix.equinor.com',
defaultScopes: ['api://ed6de162-dd30-4757-95eb-0ffc8d34fbe0/access_as_user'],
modelViewerConfig: {
hierarchyClientBaseUrl: 'https://app-echo-hierarchy-dev.azurewebsites.net',
hierarchyClientScope: 'ebc04930-bf9c-43e5-98bc-bc90865600b8/user_impersonation',
modelClientBaseUrl: 'https://app-echomodeldist-dev.azurewebsites.net',
modelClientScope: 'd484c551-acf8-45bc-b1e8-3f4373bd0d42/user_impersonation',
echoClientBaseUrl: 'https://dt-echopedia-api-dev.azurewebsites.net',
echoClientScope: 'aef35d97-53d4-4fd0-adaf-c5a514b38436/user_impersonation',
},
},
endpoints: {},
});
8 changes: 8 additions & 0 deletions apps/workorder/app.config.local.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ export default () => ({
environment: {
uri: 'https://localhost:7074',
defaultScopes: ['api://ed6de162-dd30-4757-95eb-0ffc8d34fbe0/access_as_user'],
modelViewerConfig: {
hierarchyClientBaseUrl: 'https://app-echo-hierarchy-dev.azurewebsites.net',
hierarchyClientScope: 'ebc04930-bf9c-43e5-98bc-bc90865600b8/user_impersonation',
modelClientBaseUrl: 'https://app-echomodeldist-dev.azurewebsites.net',
modelClientScope: 'd484c551-acf8-45bc-b1e8-3f4373bd0d42/user_impersonation',
echoClientBaseUrl: 'https://dt-echopedia-api-dev.azurewebsites.net',
echoClientScope: 'aef35d97-53d4-4fd0-adaf-c5a514b38436/user_impersonation',
},
},
endpoints: {},
});
13 changes: 7 additions & 6 deletions apps/workorder/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { defineConfig } from 'vite';
import EnvironmentPlugin from 'vite-plugin-environment';
import { InjectProcessPlugin } from '../../patches/3d-patch.ts';

export default defineConfig({
plugins: [
EnvironmentPlugin({
NODE_ENV: 'production',
}),
],
appType: 'custom',
build: {
emptyOutDir: true,
rollupOptions: {
plugins: [InjectProcessPlugin],
output: {
inlineDynamicImports: true,
},
},
lib: {
entry: './src/main.tsx',
fileName: 'app-bundle',
Expand Down
12 changes: 11 additions & 1 deletion github-action/src/releaseMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,20 @@ program.name('Release');
type ReleaseArgs = {
token: string;
ai: string;
modelViewerConfig: string;
pr: string;
sha: string;
};

program
.command('release')
.option('-T, --token <token>', 'azure token')
.option('-pr, --pr <pr>', 'Pr number')
.option('-ai, --ai <ai>', 'ai key')
.option(
'-modelViewerConfig, --modelViewerConfig <modelViewerConfig>',
'modelviewer config'
)
.option('-sha, --sha <sha>', 'commit sha')
.action(async (args) => {
if (!args.token) {
Expand Down Expand Up @@ -61,7 +67,11 @@ export async function release(config: ReleaseArgs) {

await uploadBundle(prodUrl, config.token, pkg.name, zipped);
await patchAppConfig(
{ ai: config.ai, commit: config.sha },
{
ai: config.ai,
commit: config.sha,
modelViewerConfig: JSON.parse(config.modelViewerConfig),
},
config.token,
pkg.name,
prodUrl
Expand Down
12 changes: 11 additions & 1 deletion github-action/src/releasePr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ program.name('Release');
type ReleaseArgs = {
token: string;
ai: string;
modelViewerConfig: string;
pr: string;
sha: string;
};
Expand All @@ -27,6 +28,10 @@ program
.option('-T, --token <token>', 'azure token')
.option('-pr, --pr <pr>', 'Pr number')
.option('-ai, --ai <ai>', 'ai key')
.option(
'-modelViewerConfig, --modelViewerConfig <modelViewerConfig>',
'modelviewer config'
)
.option('-sha, --sha <sha>', 'commit sha')
.action(async (args) => {
if (!args.token) {
Expand All @@ -53,7 +58,12 @@ export async function release(context: ReleaseArgs) {
}
await uploadBundle(ciUrl, context.token, r.name, zipped);
await patchAppConfig(
{ ai: context.ai, commit: context.sha, pr: context.pr },
{
ai: context.ai,
commit: context.sha,
pr: context.pr,
modelViewerConfig: JSON.parse(context.modelViewerConfig),
},
context.token,
r.name,
ciUrl
Expand Down
8 changes: 8 additions & 0 deletions github-action/src/utils/patchAppConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ export async function getAppConfig(token: string, appKey: string, url: string) {
type AppConfig = {
commit: string;
ai: string;
modelViewerConfig: {
hierarchyClientBaseUrl: string;
hierarchyClientScope: string;
modelClientBaseUrl: string;
modelClientScope: string;
echoClientBaseUrl: string;
echoClientScope: string;
};
};

export async function patchAppConfig<T extends Record<PropertyKey, unknown> = {}>(
Expand Down
20 changes: 20 additions & 0 deletions libs/modelviewer/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,23 @@ sequenceDiagram
```

Get details about a clicked 3D element
```ts

useEffect(() => {
const callback = async (e: Event) => {
const index = (e as Test).detail.treeIndex;

const data = selectionControls.getNodeFromTreeId(index);
console.log({ data });
};

window.addEventListener('selectionStarted', callback);

return () => {
window.removeEventListener('selectionStarted', callback);
};
}, [selectionControls]);
```

3 changes: 2 additions & 1 deletion libs/modelviewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
"test:coverage": "vitest run --coverage"
},
"dependencies": {
"@equinor/echo-3d-viewer": "^0.0.1",
"@equinor/echo-3d-viewer": "^0.0.3",
"@cognite/reveal": "4.2.2",
"@cognite/sdk": "8.2.0",
"throttle-typescript": "^1.1.0",
"three": "0.154.0",
"rxjs": "^7.5.7"
},
Expand Down
Loading

0 comments on commit 7aea030

Please sign in to comment.