@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.
- package/build/three.cjs +3 -2
- package/build/three.core.js +3 -2
- package/build/three.core.min.js +1 -1
- package/build/three.webgpu.js +24 -24
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +24 -24
- package/build/three.webgpu.nodes.min.js +1 -1
- package/package.json +1 -1
- package/src/constants.js +1 -1
- package/src/extras/core/ShapePath.js +2 -1
- package/src/nodes/accessors/Instance.js +13 -20
- package/src/nodes/accessors/MaterialProperties.js +4 -3
- package/src/nodes/accessors/SceneProperties.js +1 -1
- package/src/nodes/core/MRTNode.js +4 -0
- package/src/nodes/functions/VolumetricLightingModel.js +2 -2
package/package.json
CHANGED
package/src/constants.js
CHANGED
|
@@ -285,7 +285,8 @@ class ShapePath {
|
|
|
285
285
|
for ( let j = i - 1; j >= 0; j -- ) {
|
|
286
286
|
|
|
287
287
|
const candidate = entries[ j ];
|
|
288
|
-
|
|
288
|
+
|
|
289
|
+
if ( ! candidate.boundingBox.containsBox( entry.boundingBox ) ) continue;
|
|
289
290
|
if ( ! pointInPolygon( entry.interiorPoint, candidate.points ) ) continue;
|
|
290
291
|
|
|
291
292
|
entry.container = candidate.exclude ? candidate.container : candidate;
|
|
@@ -23,26 +23,26 @@ const _previousInstanceMatrices = /*@__PURE__*/ new WeakMap();
|
|
|
23
23
|
*
|
|
24
24
|
* @param {NodeBuilder} builder - The current node builder.
|
|
25
25
|
* @param {InstancedBufferAttribute|StorageInstancedBufferAttribute} instanceMatrix - The matrix buffer attribute.
|
|
26
|
-
* @param {number} count - The instance count.
|
|
27
26
|
* @returns {Node} The matrix node.
|
|
28
27
|
*/
|
|
29
|
-
function createInstanceMatrixNode( builder, instanceMatrix
|
|
28
|
+
function createInstanceMatrixNode( builder, instanceMatrix ) {
|
|
30
29
|
|
|
31
30
|
let instanceMatrixNode;
|
|
31
|
+
const matrixCount = Math.max( instanceMatrix.count, 1 );
|
|
32
32
|
|
|
33
33
|
const isStorageMatrix = instanceMatrix.isStorageInstancedBufferAttribute === true;
|
|
34
34
|
|
|
35
35
|
if ( isStorageMatrix ) {
|
|
36
36
|
|
|
37
|
-
instanceMatrixNode = storage( instanceMatrix, 'mat4',
|
|
37
|
+
instanceMatrixNode = storage( instanceMatrix, 'mat4', matrixCount ).element( instanceIndex );
|
|
38
38
|
|
|
39
39
|
} else {
|
|
40
40
|
|
|
41
|
-
const uniformBufferSize =
|
|
41
|
+
const uniformBufferSize = matrixCount * 16 * 4;
|
|
42
42
|
|
|
43
43
|
if ( uniformBufferSize <= builder.getUniformBufferLimit() ) {
|
|
44
44
|
|
|
45
|
-
instanceMatrixNode = buffer( instanceMatrix.array, 'mat4',
|
|
45
|
+
instanceMatrixNode = buffer( instanceMatrix.array, 'mat4', matrixCount ).element( instanceIndex );
|
|
46
46
|
|
|
47
47
|
} else {
|
|
48
48
|
|
|
@@ -81,10 +81,9 @@ function createInstanceMatrixNode( builder, instanceMatrix, count ) {
|
|
|
81
81
|
* @param {InstancedMesh} instancedMesh - The instanced mesh object.
|
|
82
82
|
* @param {InstancedBufferAttribute|StorageInstancedBufferAttribute} instanceMatrix - The current matrix buffer attribute.
|
|
83
83
|
* @param {NodeBuilder} builder - The current node builder.
|
|
84
|
-
* @param {number} count - The instance count.
|
|
85
84
|
* @returns {Node} The previous frame instance matrix node.
|
|
86
85
|
*/
|
|
87
|
-
function getPreviousInstance( instancedMesh, instanceMatrix, builder
|
|
86
|
+
function getPreviousInstance( instancedMesh, instanceMatrix, builder ) {
|
|
88
87
|
|
|
89
88
|
let data = _previousInstanceMatrices.get( instancedMesh );
|
|
90
89
|
|
|
@@ -94,7 +93,7 @@ function getPreviousInstance( instancedMesh, instanceMatrix, builder, count ) {
|
|
|
94
93
|
|
|
95
94
|
data = {
|
|
96
95
|
previousInstanceMatrix,
|
|
97
|
-
node: createInstanceMatrixNode( builder, previousInstanceMatrix
|
|
96
|
+
node: createInstanceMatrixNode( builder, previousInstanceMatrix )
|
|
98
97
|
};
|
|
99
98
|
|
|
100
99
|
_previousInstanceMatrices.set( instancedMesh, data );
|
|
@@ -118,26 +117,22 @@ export const instanceColor = /*@__PURE__*/ varyingProperty( 'vec3', 'vInstanceCo
|
|
|
118
117
|
*
|
|
119
118
|
* @tsl
|
|
120
119
|
* @function
|
|
121
|
-
* @param {number} count - The instance count.
|
|
122
120
|
* @param {InstancedBufferAttribute|StorageInstancedBufferAttribute} matrices - The instanced transformation matrices.
|
|
123
121
|
* @param {?InstancedBufferAttribute|StorageInstancedBufferAttribute} [colors=null] - The optional instanced colors.
|
|
124
122
|
*/
|
|
125
|
-
export const instance = /*@__PURE__*/ Fn( ( [
|
|
126
|
-
|
|
127
|
-
// get numeric value (non-node)
|
|
128
|
-
count = count.value;
|
|
123
|
+
export const instance = /*@__PURE__*/ Fn( ( [ matrices, colors = null ], builder ) => {
|
|
129
124
|
|
|
130
125
|
const isStorageMatrix = matrices.isStorageInstancedBufferAttribute === true;
|
|
131
126
|
const isStorageColor = colors && colors.isStorageInstancedBufferAttribute === true;
|
|
132
127
|
|
|
133
|
-
const instanceMatrixNode = createInstanceMatrixNode( builder, matrices
|
|
128
|
+
const instanceMatrixNode = createInstanceMatrixNode( builder, matrices );
|
|
134
129
|
|
|
135
130
|
// interleaved buffer tracking for matrix
|
|
136
131
|
let interleavedMatrix = null;
|
|
137
132
|
|
|
138
133
|
if ( ! isStorageMatrix ) {
|
|
139
134
|
|
|
140
|
-
const uniformBufferSize = count * 16 * 4;
|
|
135
|
+
const uniformBufferSize = Math.max( matrices.count, 1 ) * 16 * 4;
|
|
141
136
|
|
|
142
137
|
if ( uniformBufferSize > builder.getUniformBufferLimit() ) {
|
|
143
138
|
|
|
@@ -229,7 +224,7 @@ export const instance = /*@__PURE__*/ Fn( ( [ count, matrices, colors = null ],
|
|
|
229
224
|
|
|
230
225
|
} );
|
|
231
226
|
|
|
232
|
-
const previousInstanceMatrixNode = getPreviousInstance( instancedMesh, matrices, builder
|
|
227
|
+
const previousInstanceMatrixNode = getPreviousInstance( instancedMesh, matrices, builder );
|
|
233
228
|
positionPrevious.assign( previousInstanceMatrixNode.mul( positionPrevious ).xyz );
|
|
234
229
|
|
|
235
230
|
}
|
|
@@ -262,10 +257,8 @@ export const instance = /*@__PURE__*/ Fn( ( [ count, matrices, colors = null ],
|
|
|
262
257
|
*/
|
|
263
258
|
export const instancedMesh = /*@__PURE__*/ Fn( ( [ instancedMesh ] ) => {
|
|
264
259
|
|
|
265
|
-
const {
|
|
260
|
+
const { instanceMatrix, instanceColor } = instancedMesh;
|
|
266
261
|
|
|
267
|
-
instance(
|
|
262
|
+
instance( instanceMatrix, instanceColor );
|
|
268
263
|
|
|
269
264
|
}, 'void' );
|
|
270
|
-
|
|
271
|
-
|
|
@@ -26,8 +26,8 @@ export const materialEnvIntensity = /*@__PURE__*/ uniform( 1 ).onReference( ( {
|
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* TSL object that represents the rotation of environment maps.
|
|
29
|
-
* When `material.envMap` is set, the value is `material.envMapRotation`.
|
|
30
|
-
* rotation of `scene.environment` instead.
|
|
29
|
+
* When `material.envMap` is set, the value is `material.envMapRotation`.
|
|
30
|
+
* `scene.environmentRotation` controls the rotation of `scene.environment` or `scene.environmentNode` instead.
|
|
31
31
|
*
|
|
32
32
|
* @tsl
|
|
33
33
|
* @type {Node<mat4>}
|
|
@@ -38,7 +38,8 @@ export const materialEnvRotation = /*@__PURE__*/ uniform( new Matrix4() ).onRefe
|
|
|
38
38
|
|
|
39
39
|
} ).onObjectUpdate( function ( { material, scene } ) {
|
|
40
40
|
|
|
41
|
-
const
|
|
41
|
+
const hasSceneEnvironment = ( scene.environment !== null ) || ( scene.environmentNode && scene.environmentNode.isNode );
|
|
42
|
+
const rotation = ( hasSceneEnvironment && material.envMap === null ) ? scene.environmentRotation : material.envMapRotation;
|
|
42
43
|
|
|
43
44
|
if ( rotation ) {
|
|
44
45
|
|
|
@@ -31,7 +31,7 @@ export const backgroundRotation = /*@__PURE__*/ uniform( new Matrix4() ).setGrou
|
|
|
31
31
|
|
|
32
32
|
const background = scene.background;
|
|
33
33
|
|
|
34
|
-
if ( background !== null && background.isTexture && background.mapping !== UVMapping ) {
|
|
34
|
+
if ( ( background !== null && background.isTexture && background.mapping !== UVMapping ) || ( scene.backgroundNode && scene.backgroundNode.isNode ) ) {
|
|
35
35
|
|
|
36
36
|
// note: since the matrix is orthonormal, we can use the more-efficient transpose() in lieu of invert()
|
|
37
37
|
_m1.makeRotationFromEuler( scene.backgroundRotation ).transpose();
|
|
@@ -170,6 +170,10 @@ class MRTNode extends OutputStructNode {
|
|
|
170
170
|
for ( const name in outputNodes ) {
|
|
171
171
|
|
|
172
172
|
const index = getTextureIndex( textures, name );
|
|
173
|
+
|
|
174
|
+
// Ignore if the output exists in the MRT but has never been used.
|
|
175
|
+
if ( index === - 1 ) continue;
|
|
176
|
+
|
|
173
177
|
const type = builder.getOutputType( index );
|
|
174
178
|
|
|
175
179
|
members[ index ] = outputNodes[ name ].convert( type );
|
|
@@ -172,9 +172,9 @@ class VolumetricLightingModel extends LightingModel {
|
|
|
172
172
|
|
|
173
173
|
direct( { lightNode, lightColor }, builder ) {
|
|
174
174
|
|
|
175
|
-
// Ignore lights with infinite distance
|
|
175
|
+
// Ignore non-analytical lights and lights with infinite distance
|
|
176
176
|
|
|
177
|
-
if ( lightNode.light.distance === undefined ) return;
|
|
177
|
+
if ( lightNode.isAnalyticLightNode !== true || lightNode.light.distance === undefined ) return;
|
|
178
178
|
|
|
179
179
|
// TODO: We need a viewportOpaque*() ( output, depth ) to fit with modern rendering approaches
|
|
180
180
|
|