@needle-tools/three 0.185.0 → 0.185.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15519,8 +15519,8 @@ const materialEnvIntensity = /*@__PURE__*/ uniform( 1 ).onReference( ( { materia
15519
15519
 
15520
15520
  /**
15521
15521
  * TSL object that represents the rotation of environment maps.
15522
- * When `material.envMap` is set, the value is `material.envMapRotation`. `scene.environmentRotation` controls the
15523
- * rotation of `scene.environment` instead.
15522
+ * When `material.envMap` is set, the value is `material.envMapRotation`.
15523
+ * `scene.environmentRotation` controls the rotation of `scene.environment` or `scene.environmentNode` instead.
15524
15524
  *
15525
15525
  * @tsl
15526
15526
  * @type {Node<mat4>}
@@ -15531,7 +15531,8 @@ const materialEnvRotation = /*@__PURE__*/ uniform( new Matrix4() ).onReference(
15531
15531
 
15532
15532
  } ).onObjectUpdate( function ( { material, scene } ) {
15533
15533
 
15534
- const rotation = ( scene.environment !== null && material.envMap === null ) ? scene.environmentRotation : material.envMapRotation;
15534
+ const hasSceneEnvironment = ( scene.environment !== null ) || ( scene.environmentNode && scene.environmentNode.isNode );
15535
+ const rotation = ( hasSceneEnvironment && material.envMap === null ) ? scene.environmentRotation : material.envMapRotation;
15535
15536
 
15536
15537
  if ( rotation ) {
15537
15538
 
@@ -18302,26 +18303,26 @@ const _previousInstanceMatrices = /*@__PURE__*/ new WeakMap();
18302
18303
  *
18303
18304
  * @param {NodeBuilder} builder - The current node builder.
18304
18305
  * @param {InstancedBufferAttribute|StorageInstancedBufferAttribute} instanceMatrix - The matrix buffer attribute.
18305
- * @param {number} count - The instance count.
18306
18306
  * @returns {Node} The matrix node.
18307
18307
  */
18308
- function createInstanceMatrixNode( builder, instanceMatrix, count ) {
18308
+ function createInstanceMatrixNode( builder, instanceMatrix ) {
18309
18309
 
18310
18310
  let instanceMatrixNode;
18311
+ const matrixCount = Math.max( instanceMatrix.count, 1 );
18311
18312
 
18312
18313
  const isStorageMatrix = instanceMatrix.isStorageInstancedBufferAttribute === true;
18313
18314
 
18314
18315
  if ( isStorageMatrix ) {
18315
18316
 
18316
- instanceMatrixNode = storage( instanceMatrix, 'mat4', Math.max( count, 1 ) ).element( instanceIndex );
18317
+ instanceMatrixNode = storage( instanceMatrix, 'mat4', matrixCount ).element( instanceIndex );
18317
18318
 
18318
18319
  } else {
18319
18320
 
18320
- const uniformBufferSize = count * 16 * 4;
18321
+ const uniformBufferSize = matrixCount * 16 * 4;
18321
18322
 
18322
18323
  if ( uniformBufferSize <= builder.getUniformBufferLimit() ) {
18323
18324
 
18324
- instanceMatrixNode = buffer( instanceMatrix.array, 'mat4', Math.max( count, 1 ) ).element( instanceIndex );
18325
+ instanceMatrixNode = buffer( instanceMatrix.array, 'mat4', matrixCount ).element( instanceIndex );
18325
18326
 
18326
18327
  } else {
18327
18328
 
@@ -18360,10 +18361,9 @@ function createInstanceMatrixNode( builder, instanceMatrix, count ) {
18360
18361
  * @param {InstancedMesh} instancedMesh - The instanced mesh object.
18361
18362
  * @param {InstancedBufferAttribute|StorageInstancedBufferAttribute} instanceMatrix - The current matrix buffer attribute.
18362
18363
  * @param {NodeBuilder} builder - The current node builder.
18363
- * @param {number} count - The instance count.
18364
18364
  * @returns {Node} The previous frame instance matrix node.
18365
18365
  */
18366
- function getPreviousInstance( instancedMesh, instanceMatrix, builder, count ) {
18366
+ function getPreviousInstance( instancedMesh, instanceMatrix, builder ) {
18367
18367
 
18368
18368
  let data = _previousInstanceMatrices.get( instancedMesh );
18369
18369
 
@@ -18373,7 +18373,7 @@ function getPreviousInstance( instancedMesh, instanceMatrix, builder, count ) {
18373
18373
 
18374
18374
  data = {
18375
18375
  previousInstanceMatrix,
18376
- node: createInstanceMatrixNode( builder, previousInstanceMatrix, count )
18376
+ node: createInstanceMatrixNode( builder, previousInstanceMatrix )
18377
18377
  };
18378
18378
 
18379
18379
  _previousInstanceMatrices.set( instancedMesh, data );
@@ -18397,26 +18397,22 @@ const instanceColor = /*@__PURE__*/ varyingProperty( 'vec3', 'vInstanceColor' );
18397
18397
  *
18398
18398
  * @tsl
18399
18399
  * @function
18400
- * @param {number} count - The instance count.
18401
18400
  * @param {InstancedBufferAttribute|StorageInstancedBufferAttribute} matrices - The instanced transformation matrices.
18402
18401
  * @param {?InstancedBufferAttribute|StorageInstancedBufferAttribute} [colors=null] - The optional instanced colors.
18403
18402
  */
18404
- const instance = /*@__PURE__*/ Fn( ( [ count, matrices, colors = null ], builder ) => {
18405
-
18406
- // get numeric value (non-node)
18407
- count = count.value;
18403
+ const instance = /*@__PURE__*/ Fn( ( [ matrices, colors = null ], builder ) => {
18408
18404
 
18409
18405
  const isStorageMatrix = matrices.isStorageInstancedBufferAttribute === true;
18410
18406
  const isStorageColor = colors && colors.isStorageInstancedBufferAttribute === true;
18411
18407
 
18412
- const instanceMatrixNode = createInstanceMatrixNode( builder, matrices, count );
18408
+ const instanceMatrixNode = createInstanceMatrixNode( builder, matrices );
18413
18409
 
18414
18410
  // interleaved buffer tracking for matrix
18415
18411
  let interleavedMatrix = null;
18416
18412
 
18417
18413
  if ( ! isStorageMatrix ) {
18418
18414
 
18419
- const uniformBufferSize = count * 16 * 4;
18415
+ const uniformBufferSize = Math.max( matrices.count, 1 ) * 16 * 4;
18420
18416
 
18421
18417
  if ( uniformBufferSize > builder.getUniformBufferLimit() ) {
18422
18418
 
@@ -18508,7 +18504,7 @@ const instance = /*@__PURE__*/ Fn( ( [ count, matrices, colors = null ], builder
18508
18504
 
18509
18505
  } );
18510
18506
 
18511
- const previousInstanceMatrixNode = getPreviousInstance( instancedMesh, matrices, builder, count );
18507
+ const previousInstanceMatrixNode = getPreviousInstance( instancedMesh, matrices, builder );
18512
18508
  positionPrevious.assign( previousInstanceMatrixNode.mul( positionPrevious ).xyz );
18513
18509
 
18514
18510
  }
@@ -18541,9 +18537,9 @@ const instance = /*@__PURE__*/ Fn( ( [ count, matrices, colors = null ], builder
18541
18537
  */
18542
18538
  const instancedMesh = /*@__PURE__*/ Fn( ( [ instancedMesh ] ) => {
18543
18539
 
18544
- const { count, instanceMatrix, instanceColor } = instancedMesh;
18540
+ const { instanceMatrix, instanceColor } = instancedMesh;
18545
18541
 
18546
- instance( count, instanceMatrix, instanceColor );
18542
+ instance( instanceMatrix, instanceColor );
18547
18543
 
18548
18544
  }, 'void' );
18549
18545
 
@@ -29221,9 +29217,9 @@ class VolumetricLightingModel extends LightingModel {
29221
29217
 
29222
29218
  direct( { lightNode, lightColor }, builder ) {
29223
29219
 
29224
- // Ignore lights with infinite distance
29220
+ // Ignore non-analytical lights and lights with infinite distance
29225
29221
 
29226
- if ( lightNode.light.distance === undefined ) return;
29222
+ if ( lightNode.isAnalyticLightNode !== true || lightNode.light.distance === undefined ) return;
29227
29223
 
29228
29224
  // TODO: We need a viewportOpaque*() ( output, depth ) to fit with modern rendering approaches
29229
29225
 
@@ -36054,6 +36050,10 @@ class MRTNode extends OutputStructNode {
36054
36050
  for ( const name in outputNodes ) {
36055
36051
 
36056
36052
  const index = getTextureIndex( textures, name );
36053
+
36054
+ // Ignore if the output exists in the MRT but has never been used.
36055
+ if ( index === -1 ) continue;
36056
+
36057
36057
  const type = builder.getOutputType( index );
36058
36058
 
36059
36059
  members[ index ] = outputNodes[ name ].convert( type );
@@ -38930,7 +38930,7 @@ const backgroundRotation = /*@__PURE__*/ uniform( new Matrix4() ).setGroup( rend
38930
38930
 
38931
38931
  const background = scene.background;
38932
38932
 
38933
- if ( background !== null && background.isTexture && background.mapping !== UVMapping ) {
38933
+ if ( ( background !== null && background.isTexture && background.mapping !== UVMapping ) || ( scene.backgroundNode && scene.backgroundNode.isNode ) ) {
38934
38934
 
38935
38935
  // note: since the matrix is orthonormal, we can use the more-efficient transpose() in lieu of invert()
38936
38936
  _m1.makeRotationFromEuler( scene.backgroundRotation ).transpose();