Browse Source

USDZExporter: Added console warning when the material type is unsupported.

Mr.doob 3 năm trước cách đây
mục cha
commit
6e4f7a5fa7
1 tập tin đã thay đổi với 20 bổ sung12 xóa
  1. 20 12
      examples/jsm/exporters/USDZExporter.js

+ 20 - 12
examples/jsm/exporters/USDZExporter.js

@@ -17,27 +17,35 @@ class USDZExporter {
 
 
 		scene.traverseVisible( ( object ) => {
 		scene.traverseVisible( ( object ) => {
 
 
-			if ( object.isMesh && object.material.isMeshStandardMaterial ) {
+			if ( object.isMesh ) {
 
 
-				const geometry = object.geometry;
-				const material = object.material;
+				if ( object.material.isMeshStandardMaterial ) {
 
 
-				const geometryFileName = 'geometries/Geometry_' + geometry.id + '.usd';
+					const geometry = object.geometry;
+					const material = object.material;
 
 
-				if ( ! ( geometryFileName in files ) ) {
+					const geometryFileName = 'geometries/Geometry_' + geometry.id + '.usd';
 
 
-					const meshObject = buildMeshObject( geometry );
-					files[ geometryFileName ] = buildUSDFileAsString( meshObject );
+					if ( ! ( geometryFileName in files ) ) {
 
 
-				}
+						const meshObject = buildMeshObject( geometry );
+						files[ geometryFileName ] = buildUSDFileAsString( meshObject );
 
 
-				if ( ! ( material.uuid in materials ) ) {
+					}
 
 
-					materials[ material.uuid ] = material;
+					if ( ! ( material.uuid in materials ) ) {
 
 
-				}
+						materials[ material.uuid ] = material;
+
+					}
+
+					output += buildXform( object, geometry, material );
 
 
-				output += buildXform( object, geometry, material );
+				} else {
+
+					console.warn( 'THREE.USDZExporter: Unsupported material type (USDZ only supports MeshStandardMaterial)', object );
+
+				}
 
 
 			}
 			}