Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 21 additions & 8 deletions examples/jsm/loaders/usd/USDAParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@ class USDAParser {
// Array types
if ( valueType.endsWith( '[]' ) ) {

let result;

// Parse JSON-like arrays
try {

Expand All @@ -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 );
Expand All @@ -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.)
Expand Down
12 changes: 10 additions & 2 deletions src/renderers/common/ClippingContext.js
Original file line number Diff line number Diff line change
@@ -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';

Expand Down Expand Up @@ -52,6 +53,13 @@ class ClippingContext {
*/
this.shadowPass = false;

/**
* The view matrix.
*
* @type {Matrix4}
*/
this.viewMatrix = new Matrix4();

/**
* The view normal matrix.
*
Expand Down Expand Up @@ -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;

}

Expand Down Expand Up @@ -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 );

}
Expand Down
Loading