Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
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
15 changes: 7 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"homepage": "https://github.com/v1r0x/files_3d#readme",
"dependencies": {
"lil-gui": "^0.16.0",
"three": "^0.138",
"three": "^0.139.2",
"vue": "^2.6.14"
},
"devDependencies": {
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