File tree Expand file tree Collapse file tree 1 file changed +47
-1
lines changed Expand file tree Collapse file tree 1 file changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -472,7 +472,7 @@ var Loader = function ( editor ) {
472472
473473 var zip = new JSZip ( contents ) ;
474474
475- // BLOCKS
475+ // Poly
476476
477477 if ( zip . files [ 'model.obj' ] && zip . files [ 'materials.mtl' ] ) {
478478
@@ -482,6 +482,52 @@ var Loader = function ( editor ) {
482482
483483 }
484484
485+ //
486+
487+ zip . filter ( function ( path , file ) {
488+
489+ // GLB
490+
491+ if ( file . name . search ( / \. g l b $ / i ) > - 1 ) {
492+
493+ var loader = new THREE . GLTFLoader ( manager ) ;
494+ loader . parse ( file . asArrayBuffer ( ) , '' , function ( result ) {
495+
496+ editor . execute ( new AddObjectCommand ( result . scene ) ) ;
497+
498+ } ) ;
499+
500+ }
501+
502+ // GLTF
503+
504+ if ( file . name . search ( / \. g l t f $ / i ) > - 1 ) {
505+
506+ var manager = new THREE . LoadingManager ( ) ;
507+ manager . setURLModifier ( function ( url ) {
508+
509+ var file = zip . files [ url ] ;
510+
511+ if ( file ) {
512+
513+ var blob = new Blob ( [ file . asArrayBuffer ( ) ] , { type : 'application/octet-stream' } ) ;
514+ return URL . createObjectURL ( blob ) ;
515+
516+ }
517+
518+ } ) ;
519+
520+ var loader = new THREE . GLTFLoader ( manager ) ;
521+ loader . parse ( file . asText ( ) , '' , function ( result ) {
522+
523+ editor . execute ( new AddObjectCommand ( result . scene ) ) ;
524+
525+ } ) ;
526+
527+ }
528+
529+ } ) ;
530+
485531 } , false ) ;
486532 reader . readAsBinaryString ( file ) ;
487533
You can’t perform that action at this time.
0 commit comments