Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ifc format #61

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add IFC loader
Signed-off-by: Vincent Petry <[email protected]>
  • Loading branch information
PVince81 committed Apr 1, 2022
commit 32cf9c735c99688f7a85f0ad2eaba62e0c30e43d
1 change: 1 addition & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public function register() {
$mimeTypeDetector->registerType('stl', 'application/sla', null);
// There is no standard type for gcode, therefore we use cura's mimetype for gcode
$mimeTypeDetector->registerType('gcode', 'text/x-gcode', null);
$mimeTypeDetector->registerType('ifc', 'application/x-step', null);

// Watch Viewer load event
$eventDispatcher->addServiceListener(LoadViewer::class, LoadFiles3dScript::class);
Expand Down
1 change: 1 addition & 0 deletions lib/Listener/CSPListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function handle(Event $event): void {

$csp = new ContentSecurityPolicy();
$csp->addAllowedConnectDomain('data:');
$csp->allowEvalScript(true); // required for IFC

$event->addPolicy($csp);
}
Expand Down
1 change: 1 addition & 0 deletions lib/Migration/AddMimetypeToFilecache.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function run(IOutput $output) {
'stl' => 'application/sla',
'ply' => 'model/vnd.ply',
'gcode' => 'text/x-gcode',
'ifc' => 'application/x-step',
];
foreach($mimes as $ext => $mime) {
$mimetypeId = $this->mimeTypeLoader->getId($mime);
Expand Down
17 changes: 16 additions & 1 deletion src/components/Files3d.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ import { MTLLoader } from 'three/examples/jsm/loaders/MTLLoader.js'
import { OBJLoader } from 'three/examples/jsm/loaders/OBJLoader.js'
import { PLYLoader } from 'three/examples/jsm/loaders/PLYLoader.js'
import { STLLoader } from 'three/examples/jsm/loaders/STLLoader.js'
import { VertexNormalsHelper } from 'three/examples/jsm/helpers/VertexNormalsHelper.js';
import { IFCLoader } from 'three/examples/jsm/loaders/IFCLoader.js'
import { VertexNormalsHelper } from 'three/examples/jsm/helpers/VertexNormalsHelper.js'
import { GUI } from 'lil-gui'

export default {
Expand Down Expand Up @@ -230,6 +231,9 @@ export default {
case 'text/x-gcode':
this.showGcode(this.davPath)
break
case 'application/x-step':
this.showIfc(this.davPath)
break
}
},
showCollada(path) {
Expand Down Expand Up @@ -357,6 +361,17 @@ export default {
event => { // onError
})
},
showIfc(path) {
const loader = new IFCLoader()
loader.load(path, data => {
const gltf = data
const object = gltf.scene
this.addModelToScene(object, gltf.animations)
}, event => { // onProgress
}, error => { // onError
console.error(error)
})
},
addModelToScene(model, animations) {
// Play first animation if available
const anim = animations || model.animations
Expand Down
1 change: 1 addition & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ if (OCA.Viewer) {
// PLY has no mime
'model/vnd.ply',
'text/x-gcode',
'application/x-step',
],

// your vue component view
Expand Down