Skip to content

Commit 39551ee

Browse files
authored
Merge pull request #20148 from mcneel/wip/3dmLoader
Editor: Add 3dm import
2 parents 7973773 + d28c286 commit 39551ee

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

editor/js/Loader.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { SVGLoader } from '../../examples/jsm/loaders/SVGLoader.js';
1616
import { TDSLoader } from '../../examples/jsm/loaders/TDSLoader.js';
1717
import { VTKLoader } from '../../examples/jsm/loaders/VTKLoader.js';
1818
import { VRMLLoader } from '../../examples/jsm/loaders/VRMLLoader.js';
19+
import { Rhino3dmLoader } from '../../examples/jsm/loaders/3DMLoader.js';
1920

2021
import { TGALoader } from '../../examples/jsm/loaders/TGALoader.js';
2122

@@ -94,6 +95,25 @@ function Loader( editor ) {
9495

9596
switch ( extension ) {
9697

98+
case '3dm':
99+
100+
reader.addEventListener( 'load', function ( event ) {
101+
102+
var contents = event.target.result;
103+
104+
var loader = new Rhino3dmLoader();
105+
loader.setLibraryPath( '../examples/jsm/libs/rhino3dm/' );
106+
loader.parse( contents, function ( object ) {
107+
108+
editor.execute( new AddObjectCommand( editor, object ) );
109+
110+
} );
111+
112+
}, false );
113+
reader.readAsArrayBuffer( file );
114+
115+
break;
116+
97117
case '3ds':
98118

99119
reader.addEventListener( 'load', function ( event ) {

editor/sw.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ const assets = [
2525
'../examples/js/libs/draco/gltf/draco_decoder.wasm',
2626
'../examples/js/libs/draco/gltf/draco_wasm_wrapper.js',
2727

28+
'../examples/jsm/libs/rhino3dm/rhino3dm.wasm',
29+
'../examples/jsm/libs/rhino3dm/rhino3dm.js',
30+
31+
'../examples/jsm/loaders/3DMLoader.js',
2832
'../examples/jsm/loaders/3MFLoader.js',
2933
'../examples/jsm/loaders/AMFLoader.js',
3034
'../examples/jsm/loaders/ColladaLoader.js',

examples/jsm/loaders/3DMLoader.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/**
2-
* @author Luis Fraguada / https://github.com/fraguada
3-
*/
4-
51
import {
62
BufferGeometryLoader,
73
FileLoader,
@@ -146,10 +142,11 @@ Rhino3dmLoader.prototype = Object.assign( Object.create( Loader.prototype ), {
146142

147143
},
148144

149-
parse: function () {
145+
parse: function ( data, onLoad, onError ) {
150146

151-
// parsing logic goes here
152-
console.warn( 'THREE.3DMLoader: TODO: Implement parse function' );
147+
this.decodeObjects( data, '' )
148+
.then( onLoad )
149+
.catch( onError );
153150

154151
},
155152

0 commit comments

Comments
 (0)