diff --git a/examples/jsm/loaders/usd/USDAParser.js b/examples/jsm/loaders/usd/USDAParser.js index aeca91fc1ef4cc..174438265e0064 100644 --- a/examples/jsm/loaders/usd/USDAParser.js +++ b/examples/jsm/loaders/usd/USDAParser.js @@ -699,6 +699,8 @@ class USDAParser { // Array types if ( valueType.endsWith( '[]' ) ) { + let result; + // Parse JSON-like arrays try { @@ -709,19 +711,13 @@ class USDAParser { const parsed = JSON.parse( cleaned ); // Flatten nested arrays for types like point3f[] - if ( Array.isArray( parsed ) && Array.isArray( parsed[ 0 ] ) ) { - - return parsed.flat(); - - } - - return parsed; + result = Array.isArray( parsed ) && Array.isArray( parsed[ 0 ] ) ? parsed.flat() : parsed; } catch ( e ) { // Try simple array parsing const cleaned = str.replace( /[\[\]]/g, '' ); - return cleaned.split( ',' ).map( s => { + result = cleaned.split( ',' ).map( s => { const trimmed = s.trim(); const num = parseFloat( trimmed ); @@ -731,6 +727,23 @@ class USDAParser { } + //reorder (w, x, y, z) to (x, y, z, w) + if ( valueType.startsWith( 'quat' ) ) { + + for ( let i = 0; i < result.length; i += 4 ) { + + const w = result[ i ]; + result[ i ] = result[ i + 1 ]; + result[ i + 1 ] = result[ i + 2 ]; + result[ i + 2 ] = result[ i + 3 ]; + result[ i + 3 ] = w; + + } + + } + + return result; + } // Vector types (double3, float3, point3f, etc.) diff --git a/src/renderers/common/ClippingContext.js b/src/renderers/common/ClippingContext.js index f556143fd50583..1ed98b973eeb54 100644 --- a/src/renderers/common/ClippingContext.js +++ b/src/renderers/common/ClippingContext.js @@ -1,4 +1,5 @@ import { Matrix3 } from '../../math/Matrix3.js'; +import { Matrix4 } from '../../math/Matrix4.js'; import { Plane } from '../../math/Plane.js'; import { Vector4 } from '../../math/Vector4.js'; @@ -52,6 +53,13 @@ class ClippingContext { */ this.shadowPass = false; + /** + * The view matrix. + * + * @type {Matrix4} + */ + this.viewMatrix = new Matrix4(); + /** * The view normal matrix. * @@ -90,11 +98,11 @@ class ClippingContext { if ( parentContext !== null ) { + this.viewMatrix = parentContext.viewMatrix; this.viewNormalMatrix = parentContext.viewNormalMatrix; this.clippingGroupContexts = parentContext.clippingGroupContexts; this.shadowPass = parentContext.shadowPass; - this.viewMatrix = parentContext.viewMatrix; } @@ -137,8 +145,8 @@ class ClippingContext { updateGlobal( scene, camera ) { this.shadowPass = ( scene.overrideMaterial !== null && scene.overrideMaterial.isShadowPassMaterial ); - this.viewMatrix = camera.matrixWorldInverse; + this.viewMatrix.copy( camera.matrixWorldInverse ); this.viewNormalMatrix.getNormalMatrix( this.viewMatrix ); }