Skip to content

Commit 9513591

Browse files
committed
Setup file loading
1 parent a3caa5b commit 9513591

16 files changed

+238
-22
lines changed

examples/simple-angular/angular.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
"src/favicon.ico",
2727
"src/assets"
2828
],
29-
"styles": [
29+
"styles": [{
30+
"input": "src/my-theme.scss"
31+
},
3032
"src/styles.css"
3133
],
3234
"scripts": []
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"name": "web-ifc",
3+
"version": "0.0.19",
4+
"description": "ifc loading on the web",
5+
"main": "web-ifc-api.js",
6+
"watch": {
7+
"build-viewer": {
8+
"patterns": [
9+
"./examples/viewer"
10+
],
11+
"extensions": "ts"
12+
},
13+
"build-web-ifc-api-mjs": {
14+
"patterns": [
15+
"./src"
16+
],
17+
"extensions": "ts"
18+
}
19+
},
20+
"scripts": {
21+
"gen-schema": "cd src/schema && node gen.js",
22+
"setup-env": "emsdk_env",
23+
"init-repo": "git clone https://github.com/g-truc/glm ./src/wasm/deps/glm && git clone https://github.com/mapbox/earcut.hpp ./src/wasm/deps/earcut && git clone https://github.com/executionunit/csgjs-cpp ./src/wasm/deps/scgjs-cpp && npm run gen-schema",
24+
"build-release": "npm run build-wasm-release && npm run build-api && npm run add-wasm-path",
25+
"build-debug": "npm run build-wasm-debug && npm run build-api && npm run add-wasm-path",
26+
"release_publish": "npm run build-release && cd dist && npm publish",
27+
28+
"build-wasm-debug": "em++ --bind -O3 -g4 -std=c++17 --source-map-base http://localhost:5000/web-ifc-js/wasm-lib/ -flto -fno-exceptions ./src/wasm/web-ifc-api.cpp -s ALLOW_MEMORY_GROWTH=1 -s ASSERTIONS=1 -s FORCE_FILESYSTEM=1 -s EXPORT_NAME=WebIFCWasm -s MODULARIZE=1 -s EXTRA_EXPORTED_RUNTIME_METHODS=[\"FS\"] -O3 -o dist/web-ifc.js",
29+
"build-wasm-release": "em++ --bind -O3 -std=c++17 -flto -fno-exceptions ./src/wasm/web-ifc-api.cpp -s ALLOW_MEMORY_GROWTH=1 -s FORCE_FILESYSTEM=1 -s EXPORT_NAME=WebIFCWasm -s MODULARIZE=1 -s EXTRA_EXPORTED_RUNTIME_METHODS=[\"FS\"] -O3 -o dist/web-ifc.js",
30+
31+
"build-api": "cpy src/*.ts dist && npm run build-ts-api && npm run build-web-ifc-api-mjs && npm run build-web-ifc-api-node && npm run copy-to-dist",
32+
"build-ts-api": "tsc --emitDeclarationOnly && cpy dist/web-ifc-api.d.ts dist && cpy dist/web-ifc-api.d.ts dist --rename=web-ifc-api-node.d.ts",
33+
"build-web-ifc-api-mjs": "esbuild dist/web-ifc-api.ts --bundle --format=esm --external:path --external:fs --outfile=./dist/web-ifc-api.js",
34+
"build-web-ifc-api-node": "esbuild dist/web-ifc-api.ts --bundle --platform=node --outfile=./dist/web-ifc-api-node.js",
35+
"copy-to-dist": "cpy README.md dist && cpy package.json dist && cpy src/ifc2x4.ts dist",
36+
37+
"build-viewer": "npm run bundle-viewer && npm run copy-wasm-viewer",
38+
"bundle-viewer": "esbuild ./examples/viewer/web-ifc-viewer.ts --bundle --platform=node --outfile=./examples/viewer/web-ifc-viewer.js",
39+
"copy-wasm-viewer": "cpy dist/web-ifc.wasm examples/viewer",
40+
"add-wasm-path": "node src/utils/add-wasm-path.js",
41+
"serve-viewer": "serve examples/viewer",
42+
"dev": "concurrently --kill-others \"npm-watch\" \"npm run serve-viewer\""
43+
},
44+
"author": "tomvandig",
45+
"files": [
46+
"web-ifc.wasm",
47+
"web-ifc-api-node.js",
48+
"web-ifc-api-node.d.ts",
49+
"web-ifc-api.js",
50+
"web-ifc-api.d.ts",
51+
"ifc2x4.d.ts",
52+
"ifc2x4_helper.d.ts"
53+
],
54+
"devDependencies": {
55+
"@types/three": "^0.125.3",
56+
"three": "^0.126.0",
57+
"concurrently": "^6.0.0",
58+
"cpy-cli": "^3.1.1",
59+
"esbuild": "^0.8.49",
60+
"npm-watch": "^0.7.0",
61+
"serve": "^11.3.2",
62+
"typescript": "^4.1.5"
63+
},
64+
65+
"browser": {
66+
"crypto": false,
67+
"path": false,
68+
"fs": false
69+
}
70+
}

examples/simple-angular/package.json

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,25 @@
33
"version": "0.0.0",
44
"scripts": {
55
"ng": "ng",
6-
"start": "ng serve",
6+
"start": "npm run config-web-ifc && ng serve",
77
"build": "ng build",
88
"watch": "ng build --watch --configuration development",
9-
"test": "ng test"
9+
"test": "ng test",
10+
"config-web-ifc": "cpy config/package.json ../../node_modules/web-ifc"
1011
},
1112
"private": true,
1213
"dependencies": {
13-
"@angular/animations": "~12.0.5",
14+
"@angular/animations": "^12.0.5",
15+
"@angular/cdk": "^12.0.5",
1416
"@angular/common": "~12.0.5",
1517
"@angular/compiler": "~12.0.5",
1618
"@angular/core": "~12.0.5",
1719
"@angular/forms": "~12.0.5",
20+
"@angular/material": "^12.0.5",
1821
"@angular/platform-browser": "~12.0.5",
1922
"@angular/platform-browser-dynamic": "~12.0.5",
2023
"@angular/router": "~12.0.5",
24+
"hammerjs": "^2.0.8",
2125
"rxjs": "~6.6.0",
2226
"tslib": "^2.1.0",
2327
"web-ifc-viewer": "^1.0.11",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
.navbar-button {
2+
position: absolute;
3+
margin: 1rem;
4+
}
5+
6+
#viewer-container {
7+
width: 100vw;
8+
height: 100vh;
9+
}
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,13 @@
1-
<aside class="side-menu" id="side-menu-left"></aside>
2-
<div id="viewer-container" style="width: 100vw; height: 100vh"></div>
1+
<mat-sidenav-container class="example-container">
2+
<mat-sidenav #sidenav opened="false" mode="side" opened>
3+
<app-toolbar
4+
(onOpenIfc)="loadIfc($event)"
5+
></app-toolbar>
6+
</mat-sidenav>
7+
<mat-sidenav-content>
8+
<button mat-fab color="accent" (click)="sidenav.toggle()" class="navbar-button">
9+
<mat-icon>menu</mat-icon>
10+
</button>
11+
<div id="viewer-container"></div>
12+
</mat-sidenav-content>
13+
</mat-sidenav-container>

examples/simple-angular/src/app/app.component.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, OnInit, ViewChild, ElementRef } from '@angular/core';
2+
import { MatSidenav } from '@angular/material/sidenav';
23
import { IfcViewerAPI } from 'web-ifc-viewer';
34

45
@Component({
@@ -9,8 +10,11 @@ import { IfcViewerAPI } from 'web-ifc-viewer';
910
export class AppComponent implements OnInit {
1011
title = 'ifcjs-angular-example';
1112
viewer?: IfcViewerAPI;
13+
@ViewChild('sidenav', {static: true}) serverContentInput?: MatSidenav;
1214

1315
ngOnInit(){
16+
17+
if(this.serverContentInput) this.serverContentInput.close();
1418

1519
const container = document.getElementById("viewer-container")!;
1620
this.viewer = new IfcViewerAPI({container});
@@ -19,8 +23,8 @@ export class AppComponent implements OnInit {
1923
this.viewer.addGrid();
2024
this.viewer.setWasmPath("assets/");
2125

22-
const url = "https://raw.githubusercontent.com/IFCjs/test-ifc-files/main/Revit/TESTED_Simple_project_01.ifc";
23-
this.viewer.loadIfcUrl(url);
26+
// const url = "https://raw.githubusercontent.com/IFCjs/test-ifc-files/main/Revit/TESTED_Simple_project_01.ifc";
27+
// this.viewer.loadIfcUrl(url);
2428

2529
//Setup loader
2630
// const loadIfc = async (event) => {
@@ -60,4 +64,8 @@ export class AppComponent implements OnInit {
6064
// viewer.openDropboxWindow();
6165
// });
6266
}
67+
68+
loadIfc(file: File){
69+
this.viewer?.loadIfc(file);
70+
}
6371
}

examples/simple-angular/src/app/app.module.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
import { NgModule } from '@angular/core';
22
import { BrowserModule } from '@angular/platform-browser';
3+
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
34

45
import { AppComponent } from './app.component';
6+
import { ToolbarComponent } from './toolbar/toolbar.component';
7+
import { MatSidenavModule } from '@angular/material/sidenav';
8+
import { MatButtonModule } from '@angular/material/button';
9+
import { MatIconModule } from '@angular/material/icon';
510

611
@NgModule({
712
declarations: [
8-
AppComponent
13+
AppComponent,
14+
ToolbarComponent
915
],
1016
imports: [
11-
BrowserModule
17+
BrowserModule,
18+
BrowserAnimationsModule,
19+
MatSidenavModule,
20+
MatButtonModule,
21+
MatIconModule
1222
],
1323
providers: [],
1424
bootstrap: [AppComponent]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
button {
2+
display: block;
3+
margin: 0.5rem;
4+
}
5+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<button mat-icon-button>
2+
<mat-icon (click)="openIfc()" >folder</mat-icon>
3+
</button>
4+
5+
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ComponentFixture, TestBed } from '@angular/core/testing';
2+
3+
import { ToolbarComponent } from './toolbar.component';
4+
5+
describe('ToolbarComponent', () => {
6+
let component: ToolbarComponent;
7+
let fixture: ComponentFixture<ToolbarComponent>;
8+
9+
beforeEach(async () => {
10+
await TestBed.configureTestingModule({
11+
declarations: [ ToolbarComponent ]
12+
})
13+
.compileComponents();
14+
});
15+
16+
beforeEach(() => {
17+
fixture = TestBed.createComponent(ToolbarComponent);
18+
component = fixture.componentInstance;
19+
fixture.detectChanges();
20+
});
21+
22+
it('should create', () => {
23+
expect(component).toBeTruthy();
24+
});
25+
});

0 commit comments

Comments
 (0)