Browse Source

USDZLoader: Added transforms support.

Mr.doob 2 years ago
parent
commit
141011da4a
1 changed files with 9 additions and 0 deletions
  1. 9 0
      examples/jsm/loaders/USDZLoader.js

+ 9 - 0
examples/jsm/loaders/USDZLoader.js

@@ -431,6 +431,15 @@ class USDZLoader extends Loader {
 
 			const mesh = new Mesh( geometry, material );
 
+			if ( 'matrix4d xformOp:transform' in data ) {
+
+				const array = JSON.parse( '[' + data[ 'matrix4d xformOp:transform'  ].replace( /[()]*/g, '' ) + ']' );
+
+				mesh.matrix.fromArray( array );
+				mesh.matrix.decompose( mesh.position, mesh.quaternion, mesh.scale );
+
+			}
+
 			return mesh;
 
 		}