11/**
22 * @author technohippy / https://github.com/technohippy
3+ * @author Mugen87 / https://github.com/Mugen87
4+ *
5+ * 3D Manufacturing Format (3MF) specification: https://3mf.io/specification/
6+ *
7+ * The following features from the core specification are supported:
8+ *
9+ * - 3D Models
10+ * - Object Resources (Meshes and Components)
11+ * - Material Resources (Base Materials)
12+ *
13+ * 3MF Materials and Properties Extension (e.g. textures) are not yet supported.
14+ *
315 */
416
517THREE . ThreeMFLoader = function ( manager ) {
@@ -63,7 +75,7 @@ THREE.ThreeMFLoader.prototype = {
6375
6476 if ( e instanceof ReferenceError ) {
6577
66- console . error ( 'THREE.ThreeMFLoader : jszip missing and file is compressed.' ) ;
78+ console . error ( 'THREE.3MFLoader : jszip missing and file is compressed.' ) ;
6779 return null ;
6880
6981 }
@@ -110,7 +122,7 @@ THREE.ThreeMFLoader.prototype = {
110122
111123 if ( xmlData . documentElement . nodeName . toLowerCase ( ) !== 'model' ) {
112124
113- console . error ( 'THREE.ThreeMFLoader : Error loading 3MF - no 3MF document found: ' , modelPart ) ;
125+ console . error ( 'THREE.3MFLoader : Error loading 3MF - no 3MF document found: ' , modelPart ) ;
114126
115127 }
116128
@@ -596,14 +608,20 @@ THREE.ThreeMFLoader.prototype = {
596608
597609 var material ;
598610
611+ // add material if an object-level definition is present
612+
599613 if ( basematerialsData && ( basematerialsData . id === objectData . pid ) ) {
600614
601615 var materialIndex = objectData . pindex ;
602616 var basematerialData = basematerialsData . basematerials [ materialIndex ] ;
603617
604618 material = getBuild ( basematerialData , objects , modelData , objectData , buildBasematerial ) ;
605619
606- } else if ( geometry . groups . length > 0 ) {
620+ }
621+
622+ // add/overwrite material if definitions on triangles are present
623+
624+ if ( geometry . groups . length > 0 ) {
607625
608626 var groups = geometry . groups ;
609627 material = [ ] ;
@@ -617,13 +635,11 @@ THREE.ThreeMFLoader.prototype = {
617635
618636 }
619637
620- } else {
621-
622- // default material
638+ }
623639
624- material = new THREE . MeshPhongMaterial ( { color : 0xaaaaff , flatShading : true } ) ;
640+ // default material
625641
626- }
642+ if ( material === undefined ) material = new THREE . MeshPhongMaterial ( { color : 0xaaaaff , flatShading : true } ) ;
627643
628644 return new THREE . Mesh ( geometry , material ) ;
629645
0 commit comments