|
@@ -52,6 +52,18 @@ class USDAParser {
|
|
|
target[ lhs ] = group;
|
|
|
target = group;
|
|
|
|
|
|
+ } else if ( rhs.endsWith( '(' ) ) {
|
|
|
+
|
|
|
+ // see #28631
|
|
|
+
|
|
|
+ const values = rhs.slice( 0, - 1 );
|
|
|
+ target[ lhs ] = values;
|
|
|
+
|
|
|
+ const meta = {};
|
|
|
+ stack.push( meta );
|
|
|
+
|
|
|
+ target = meta;
|
|
|
+
|
|
|
} else {
|
|
|
|
|
|
target[ lhs ] = rhs;
|
|
@@ -305,30 +317,6 @@ class USDZLoader extends Loader {
|
|
|
|
|
|
if ( name.startsWith( 'def Mesh' ) ) {
|
|
|
|
|
|
- // Move points to Mesh
|
|
|
-
|
|
|
- if ( 'point3f[] points' in data ) {
|
|
|
-
|
|
|
- object[ 'point3f[] points' ] = data[ 'point3f[] points' ];
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- // Move st to Mesh
|
|
|
-
|
|
|
- if ( 'texCoord2f[] primvars:st' in data ) {
|
|
|
-
|
|
|
- object[ 'texCoord2f[] primvars:st' ] = data[ 'texCoord2f[] primvars:st' ];
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- // Move st indices to Mesh
|
|
|
-
|
|
|
- if ( 'int[] primvars:st:indices' in data ) {
|
|
|
-
|
|
|
- object[ 'int[] primvars:st:indices' ] = data[ 'int[] primvars:st:indices' ];
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
return object;
|
|
|
|
|
|
}
|
|
@@ -351,13 +339,9 @@ class USDZLoader extends Loader {
|
|
|
if ( ! data ) return undefined;
|
|
|
|
|
|
let geometry = new BufferGeometry();
|
|
|
+ let uvs = null;
|
|
|
|
|
|
- if ( 'int[] faceVertexIndices' in data ) {
|
|
|
-
|
|
|
- const indices = JSON.parse( data[ 'int[] faceVertexIndices' ] );
|
|
|
- geometry.setIndex( indices );
|
|
|
-
|
|
|
- }
|
|
|
+ // position
|
|
|
|
|
|
if ( 'point3f[] points' in data ) {
|
|
|
|
|
@@ -367,41 +351,55 @@ class USDZLoader extends Loader {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( 'normal3f[] normals' in data ) {
|
|
|
+ // uv
|
|
|
|
|
|
- const normals = JSON.parse( data[ 'normal3f[] normals' ].replace( /[()]*/g, '' ) );
|
|
|
- const attribute = new BufferAttribute( new Float32Array( normals ), 3 );
|
|
|
- geometry.setAttribute( 'normal', attribute );
|
|
|
+ if ( 'float2[] primvars:st' in data ) {
|
|
|
|
|
|
- } else {
|
|
|
+ data[ 'texCoord2f[] primvars:st' ] = data[ 'float2[] primvars:st' ];
|
|
|
|
|
|
- geometry.computeVertexNormals();
|
|
|
+ }
|
|
|
+
|
|
|
+ if ( 'texCoord2f[] primvars:st' in data ) {
|
|
|
+
|
|
|
+ uvs = JSON.parse( data[ 'texCoord2f[] primvars:st' ].replace( /[()]*/g, '' ) );
|
|
|
+ const attribute = new BufferAttribute( new Float32Array( uvs ), 2 );
|
|
|
+ geometry.setAttribute( 'uv', attribute );
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( 'float2[] primvars:st' in data ) {
|
|
|
+ // index
|
|
|
|
|
|
- data[ 'texCoord2f[] primvars:st' ] = data[ 'float2[] primvars:st' ];
|
|
|
+ if ( 'int[] faceVertexIndices' in data ) {
|
|
|
+
|
|
|
+ const indices = JSON.parse( data[ 'int[] faceVertexIndices' ] );
|
|
|
+ geometry.setIndex( indices );
|
|
|
+
|
|
|
+ geometry = geometry.toNonIndexed();
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( 'texCoord2f[] primvars:st' in data ) {
|
|
|
+ if ( 'int[] primvars:st:indices' in data && uvs !== null ) {
|
|
|
+
|
|
|
+ // custom uv index, overwrite uvs with new data
|
|
|
|
|
|
- const uvs = JSON.parse( data[ 'texCoord2f[] primvars:st' ].replace( /[()]*/g, '' ) );
|
|
|
const attribute = new BufferAttribute( new Float32Array( uvs ), 2 );
|
|
|
|
|
|
- if ( 'int[] primvars:st:indices' in data ) {
|
|
|
+ const indices = JSON.parse( data[ 'int[] primvars:st:indices' ] );
|
|
|
+ geometry.setAttribute( 'uv', toFlatBufferAttribute( attribute, indices ) );
|
|
|
|
|
|
- geometry = geometry.toNonIndexed();
|
|
|
+ }
|
|
|
|
|
|
- const indices = JSON.parse( data[ 'int[] primvars:st:indices' ] );
|
|
|
- geometry.setAttribute( 'uv', toFlatBufferAttribute( attribute, indices ) );
|
|
|
+ // normal
|
|
|
|
|
|
- } else {
|
|
|
+ if ( 'normal3f[] normals' in data ) {
|
|
|
|
|
|
- geometry.setAttribute( 'uv', attribute );
|
|
|
+ const normals = JSON.parse( data[ 'normal3f[] normals' ].replace( /[()]*/g, '' ) );
|
|
|
+ const attribute = new BufferAttribute( new Float32Array( normals ), 3 );
|
|
|
+ geometry.setAttribute( 'normal', attribute );
|
|
|
|
|
|
- }
|
|
|
+ } else {
|
|
|
+
|
|
|
+ geometry.computeVertexNormals();
|
|
|
|
|
|
}
|
|
|
|
|
@@ -729,7 +727,7 @@ class USDZLoader extends Loader {
|
|
|
|
|
|
if ( 'asset inputs:file' in data ) {
|
|
|
|
|
|
- const path = data[ 'asset inputs:file' ].replace( /@*/g, '' );
|
|
|
+ const path = data[ 'asset inputs:file' ].replace( /@*/g, '' ).trim();
|
|
|
|
|
|
const loader = new TextureLoader();
|
|
|
|