super-three 0.172.0 → 0.173.0
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/LICENSE +1 -1
- package/build/three.cjs +439 -380
- package/build/three.core.js +413 -41
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +28 -344
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +11 -3
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +7550 -1798
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +7551 -1798
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/animation/CCDIKSolver.js +6 -5
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +23 -21
- package/examples/jsm/exporters/GLTFExporter.js +26 -25
- package/examples/jsm/geometries/TextGeometry.js +1 -12
- package/examples/jsm/interactive/InteractiveGroup.js +108 -51
- package/examples/jsm/libs/demuxer_mp4.js +109 -0
- package/examples/jsm/loaders/GCodeLoader.js +3 -1
- package/examples/jsm/loaders/GLTFLoader.js +0 -2
- package/examples/jsm/loaders/TDSLoader.js +0 -1
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -0
- package/examples/jsm/misc/GPUComputationRenderer.js +6 -7
- package/examples/jsm/misc/ProgressiveLightMap.js +4 -3
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +4 -3
- package/examples/jsm/misc/Volume.js +7 -5
- package/examples/jsm/misc/VolumeSlice.js +5 -3
- package/examples/jsm/objects/WaterMesh.js +25 -20
- package/examples/jsm/physics/JoltPhysics.js +7 -7
- package/examples/jsm/physics/RapierPhysics.js +4 -4
- package/examples/jsm/postprocessing/OutputPass.js +2 -0
- package/examples/jsm/shaders/OutputShader.js +5 -1
- package/examples/jsm/transpiler/GLSLDecoder.js +2 -2
- package/examples/jsm/transpiler/TSLEncoder.js +2 -0
- package/package.json +1 -1
- package/src/Three.Core.js +2 -0
- package/src/Three.TSL.js +9 -1
- package/src/cameras/ArrayCamera.js +1 -0
- package/src/constants.js +6 -1
- package/src/core/BufferAttribute.js +4 -0
- package/src/core/EventDispatcher.js +8 -6
- package/src/extras/ImageUtils.js +1 -11
- package/src/loaders/nodes/NodeObjectLoader.js +1 -1
- package/src/materials/nodes/MeshBasicNodeMaterial.js +1 -1
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +1 -1
- package/src/materials/nodes/NodeMaterial.js +5 -5
- package/src/materials/nodes/NodeMaterials.js +0 -1
- package/src/materials/nodes/PointsNodeMaterial.js +109 -7
- package/src/materials/nodes/SpriteNodeMaterial.js +1 -1
- package/src/materials/nodes/VolumeNodeMaterial.js +3 -3
- package/src/materials/nodes/manager/NodeMaterialObserver.js +8 -0
- package/src/nodes/Nodes.js +4 -0
- package/src/nodes/TSL.js +4 -0
- package/src/nodes/accessors/Arrays.js +30 -8
- package/src/nodes/accessors/BatchNode.js +3 -3
- package/src/nodes/accessors/BufferAttributeNode.js +1 -1
- package/src/nodes/accessors/Camera.js +64 -3
- package/src/nodes/accessors/InstanceNode.js +1 -1
- package/src/nodes/accessors/MaterialNode.js +9 -9
- package/src/nodes/accessors/ModelViewProjectionNode.js +1 -1
- package/src/nodes/accessors/Normal.js +6 -2
- package/src/nodes/accessors/Object3DNode.js +0 -1
- package/src/nodes/accessors/Position.js +6 -6
- package/src/nodes/accessors/ReferenceBaseNode.js +2 -4
- package/src/nodes/accessors/ReferenceNode.js +2 -3
- package/src/nodes/accessors/StorageBufferNode.js +42 -5
- package/src/nodes/accessors/Tangent.js +2 -2
- package/src/nodes/accessors/Texture3DNode.js +1 -1
- package/src/nodes/accessors/TextureNode.js +12 -5
- package/src/nodes/accessors/UniformArrayNode.js +9 -3
- package/src/nodes/accessors/VelocityNode.js +0 -2
- package/src/nodes/code/ScriptableNode.js +3 -3
- package/src/nodes/core/ArrayNode.js +125 -0
- package/src/nodes/core/ConstNode.js +8 -0
- package/src/nodes/core/Node.js +14 -1
- package/src/nodes/core/NodeBuilder.js +229 -19
- package/src/nodes/core/NodeUtils.js +11 -1
- package/src/nodes/core/NodeVar.js +17 -1
- package/src/nodes/core/OutputStructNode.js +19 -9
- package/src/nodes/core/StackNode.js +20 -1
- package/src/nodes/core/StructNode.js +121 -0
- package/src/nodes/core/StructType.js +13 -0
- package/src/nodes/core/StructTypeNode.js +82 -21
- package/src/nodes/core/TempNode.js +1 -1
- package/src/nodes/core/VarNode.js +94 -7
- package/src/nodes/core/VaryingNode.js +19 -3
- package/src/nodes/display/BlendModes.js +88 -1
- package/src/nodes/display/BumpMapNode.js +6 -6
- package/src/nodes/display/NormalMapNode.js +6 -6
- package/src/nodes/display/PassNode.js +3 -1
- package/src/nodes/display/ScreenNode.js +9 -0
- package/src/nodes/fog/Fog.js +17 -0
- package/src/nodes/gpgpu/AtomicFunctionNode.js +20 -4
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +8 -0
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +1 -1
- package/src/nodes/lighting/ShadowNode.js +1 -1
- package/src/nodes/math/ConditionalNode.js +8 -1
- package/src/nodes/math/MathNode.js +14 -1
- package/src/nodes/math/OperatorNode.js +96 -18
- package/src/nodes/pmrem/PMREMUtils.js +1 -1
- package/src/nodes/shapes/Shapes.js +33 -0
- package/src/nodes/tsl/TSLBase.js +1 -0
- package/src/nodes/tsl/TSLCore.js +22 -2
- package/src/nodes/utils/ArrayElementNode.js +1 -1
- package/src/nodes/utils/LoopNode.js +8 -1
- package/src/nodes/utils/MemberNode.js +68 -0
- package/src/nodes/utils/StorageArrayElementNode.js +14 -0
- package/src/nodes/utils/Timer.js +21 -0
- package/src/objects/BatchedMesh.js +1 -1
- package/src/objects/Line.js +6 -6
- package/src/renderers/WebGLRenderer.js +7 -0
- package/src/renderers/common/Animation.js +23 -1
- package/src/renderers/common/Backend.js +58 -15
- package/src/renderers/common/Background.js +14 -0
- package/src/renderers/common/Binding.js +1 -1
- package/src/renderers/common/BufferUtils.js +1 -1
- package/src/renderers/common/BundleGroup.js +1 -1
- package/src/renderers/common/ChainMap.js +9 -7
- package/src/renderers/common/ClippingContext.js +1 -1
- package/src/renderers/common/Color4.js +7 -3
- package/src/renderers/common/Geometries.js +2 -23
- package/src/renderers/common/Info.js +1 -45
- package/src/renderers/common/Lighting.js +8 -6
- package/src/renderers/common/Pipelines.js +3 -3
- package/src/renderers/common/PostProcessing.js +24 -8
- package/src/renderers/common/QuadMesh.js +1 -1
- package/src/renderers/common/RenderBundles.js +9 -3
- package/src/renderers/common/RenderContext.js +37 -3
- package/src/renderers/common/RenderContexts.js +30 -17
- package/src/renderers/common/RenderList.js +2 -2
- package/src/renderers/common/RenderLists.js +9 -3
- package/src/renderers/common/RenderObject.js +76 -17
- package/src/renderers/common/RenderObjects.js +9 -7
- package/src/renderers/common/Renderer.js +86 -67
- package/src/renderers/common/SampledTexture.js +0 -1
- package/src/renderers/common/StorageBufferAttribute.js +1 -1
- package/src/renderers/common/StorageInstancedBufferAttribute.js +1 -1
- package/src/renderers/common/StorageTexture.js +1 -1
- package/src/renderers/common/Textures.js +14 -7
- package/src/renderers/common/TimestampQueryPool.js +39 -0
- package/src/renderers/common/Uniform.js +37 -1
- package/src/renderers/common/UniformsGroup.js +2 -0
- package/src/renderers/common/XRManager.js +1193 -0
- package/src/renderers/common/XRRenderTarget.js +74 -0
- package/src/renderers/common/extras/PMREMGenerator.js +53 -8
- package/src/renderers/common/nodes/NodeBuilderState.js +4 -4
- package/src/renderers/common/nodes/NodeLibrary.js +5 -5
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -1
- package/src/renderers/common/nodes/NodeUniform.js +54 -2
- package/src/renderers/common/nodes/Nodes.js +25 -18
- package/src/renderers/webgl/WebGLBackground.js +4 -0
- package/src/renderers/webgl-fallback/WebGLBackend.js +295 -110
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +347 -17
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +57 -0
- package/src/renderers/webgl-fallback/utils/WebGLCapabilities.js +28 -0
- package/src/renderers/webgl-fallback/utils/WebGLExtensions.js +45 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +323 -11
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +167 -21
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +359 -0
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +43 -0
- package/src/renderers/webgpu/WebGPUBackend.js +132 -149
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +6 -4
- package/src/renderers/webgpu/WebGPURenderer.js +5 -4
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +615 -41
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +85 -6
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +85 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +102 -3
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +98 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +257 -9
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +274 -0
- package/src/renderers/webgpu/utils/WebGPUUtils.js +86 -4
- package/src/renderers/webxr/WebXRManager.js +13 -2
- package/src/textures/VideoFrameTexture.js +35 -0
- package/examples/jsm/geometries/InstancedPointsGeometry.js +0 -176
- package/examples/jsm/objects/InstancedPoints.js +0 -19
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +0 -209
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +0 -37
|
@@ -204,6 +204,14 @@ export const numWorkgroups = /*@__PURE__*/ computeBuiltin( 'numWorkgroups', 'uve
|
|
|
204
204
|
*/
|
|
205
205
|
export const workgroupId = /*@__PURE__*/ computeBuiltin( 'workgroupId', 'uvec3' );
|
|
206
206
|
|
|
207
|
+
/**
|
|
208
|
+
* TSL function for creating a `globalId` builtin node. A non-linearized 3-dimensional
|
|
209
|
+
* representation of the current invocation's position within a 3D global grid.
|
|
210
|
+
*
|
|
211
|
+
* @function
|
|
212
|
+
* @returns {ComputeBuiltinNode<uvec3>}
|
|
213
|
+
*/
|
|
214
|
+
export const globalId = /*@__PURE__*/ computeBuiltin( 'globalId', 'uvec3' );
|
|
207
215
|
/**
|
|
208
216
|
* TSL function for creating a `localId` builtin node. A non-linearized 3-dimensional
|
|
209
217
|
* representation of the current invocation's position within a 3D workgroup grid.
|
|
@@ -58,7 +58,7 @@ class WorkgroupInfoElementNode extends ArrayElementNode {
|
|
|
58
58
|
/**
|
|
59
59
|
* A node allowing the user to create a 'workgroup' scoped buffer within the
|
|
60
60
|
* context of a compute shader. Typically, workgroup scoped buffers are
|
|
61
|
-
* created to hold data that is
|
|
61
|
+
* created to hold data that is transferred from a global storage scope into
|
|
62
62
|
* a local workgroup scope. For invocations within a workgroup, data
|
|
63
63
|
* access speeds on 'workgroup' scoped buffers can be significantly faster
|
|
64
64
|
* than similar access operations on globally accessible storage buffers.
|
|
@@ -56,7 +56,7 @@ const getShadowMaterial = ( light ) => {
|
|
|
56
56
|
material = new NodeMaterial();
|
|
57
57
|
material.colorNode = vec4( 0, 0, 0, 1 );
|
|
58
58
|
material.depthNode = depthNode;
|
|
59
|
-
material.
|
|
59
|
+
material.isShadowPassMaterial = true; // Use to avoid other overrideMaterial override material.colorNode unintentionally when using material.shadowNode
|
|
60
60
|
material.name = 'ShadowMaterial';
|
|
61
61
|
material.fog = false;
|
|
62
62
|
|
|
@@ -211,8 +211,15 @@ export const select = /*@__PURE__*/ nodeProxy( ConditionalNode );
|
|
|
211
211
|
|
|
212
212
|
addMethodChaining( 'select', select );
|
|
213
213
|
|
|
214
|
-
//
|
|
214
|
+
// Deprecated
|
|
215
215
|
|
|
216
|
+
/**
|
|
217
|
+
* @function
|
|
218
|
+
* @deprecated since r168. Use {@link select} instead.
|
|
219
|
+
*
|
|
220
|
+
* @param {...any} params
|
|
221
|
+
* @returns {ConditionalNode}
|
|
222
|
+
*/
|
|
216
223
|
export const cond = ( ...params ) => { // @deprecated, r168
|
|
217
224
|
|
|
218
225
|
console.warn( 'TSL.ConditionalNode: cond() has been renamed to select().' );
|
|
@@ -65,6 +65,15 @@ class MathNode extends TempNode {
|
|
|
65
65
|
*/
|
|
66
66
|
this.cNode = cNode;
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* This flag can be used for type testing.
|
|
70
|
+
*
|
|
71
|
+
* @type {Boolean}
|
|
72
|
+
* @readonly
|
|
73
|
+
* @default true
|
|
74
|
+
*/
|
|
75
|
+
this.isMathNode = true;
|
|
76
|
+
|
|
68
77
|
}
|
|
69
78
|
|
|
70
79
|
/**
|
|
@@ -534,9 +543,11 @@ export const acos = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ACOS );
|
|
|
534
543
|
|
|
535
544
|
/**
|
|
536
545
|
* Returns the arc-tangent of the parameter.
|
|
546
|
+
* If two parameters are provided, the result is `atan2(y/x)`.
|
|
537
547
|
*
|
|
538
548
|
* @function
|
|
539
|
-
* @param {Node | Number}
|
|
549
|
+
* @param {Node | Number} y - The y parameter.
|
|
550
|
+
* @param {(Node | Number)?} x - The x parameter.
|
|
540
551
|
* @returns {Node}
|
|
541
552
|
*/
|
|
542
553
|
export const atan = /*@__PURE__*/ nodeProxy( MathNode, MathNode.ATAN );
|
|
@@ -932,6 +943,8 @@ export const smoothstepElement = ( x, low, high ) => smoothstep( low, high, x );
|
|
|
932
943
|
* Returns the arc-tangent of the quotient of its parameters.
|
|
933
944
|
*
|
|
934
945
|
* @function
|
|
946
|
+
* @deprecated since r172. Use {@link atan} instead.
|
|
947
|
+
*
|
|
935
948
|
* @param {Node | Number} y - The y parameter.
|
|
936
949
|
* @param {Node | Number} x - The x parameter.
|
|
937
950
|
* @returns {Node}
|
|
@@ -65,6 +65,15 @@ class OperatorNode extends TempNode {
|
|
|
65
65
|
*/
|
|
66
66
|
this.bNode = bNode;
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* This flag can be used for type testing.
|
|
70
|
+
*
|
|
71
|
+
* @type {Boolean}
|
|
72
|
+
* @readonly
|
|
73
|
+
* @default true
|
|
74
|
+
*/
|
|
75
|
+
this.isOperatorNode = true;
|
|
76
|
+
|
|
68
77
|
}
|
|
69
78
|
|
|
70
79
|
/**
|
|
@@ -109,23 +118,39 @@ class OperatorNode extends TempNode {
|
|
|
109
118
|
|
|
110
119
|
} else {
|
|
111
120
|
|
|
112
|
-
|
|
121
|
+
// Handle matrix operations
|
|
122
|
+
if ( builder.isMatrix( typeA ) ) {
|
|
113
123
|
|
|
114
|
-
|
|
124
|
+
if ( typeB === 'float' ) {
|
|
125
|
+
|
|
126
|
+
return typeA; // matrix * scalar = matrix
|
|
127
|
+
|
|
128
|
+
} else if ( builder.isVector( typeB ) ) {
|
|
129
|
+
|
|
130
|
+
return builder.getVectorFromMatrix( typeA ); // matrix * vector
|
|
131
|
+
|
|
132
|
+
} else if ( builder.isMatrix( typeB ) ) {
|
|
133
|
+
|
|
134
|
+
return typeA; // matrix * matrix
|
|
135
|
+
|
|
136
|
+
}
|
|
115
137
|
|
|
116
|
-
} else if ( builder.isMatrix(
|
|
138
|
+
} else if ( builder.isMatrix( typeB ) ) {
|
|
117
139
|
|
|
118
|
-
|
|
140
|
+
if ( typeA === 'float' ) {
|
|
119
141
|
|
|
120
|
-
|
|
142
|
+
return typeB; // scalar * matrix = matrix
|
|
121
143
|
|
|
122
|
-
|
|
144
|
+
} else if ( builder.isVector( typeA ) ) {
|
|
123
145
|
|
|
124
|
-
|
|
146
|
+
return builder.getVectorFromMatrix( typeB ); // vector * matrix
|
|
125
147
|
|
|
126
|
-
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
}
|
|
127
151
|
|
|
128
|
-
|
|
152
|
+
// Handle non-matrix cases
|
|
153
|
+
if ( builder.getTypeLength( typeB ) > builder.getTypeLength( typeA ) ) {
|
|
129
154
|
|
|
130
155
|
// anytype x anytype: use the greater length vector
|
|
131
156
|
|
|
@@ -173,17 +198,43 @@ class OperatorNode extends TempNode {
|
|
|
173
198
|
typeA = type;
|
|
174
199
|
typeB = builder.changeComponentType( typeB, 'uint' );
|
|
175
200
|
|
|
176
|
-
} else if ( builder.isMatrix( typeA )
|
|
201
|
+
} else if ( builder.isMatrix( typeA ) ) {
|
|
202
|
+
|
|
203
|
+
if ( typeB === 'float' ) {
|
|
204
|
+
|
|
205
|
+
// Keep matrix type for typeA, but ensure typeB stays float
|
|
206
|
+
typeB = 'float';
|
|
207
|
+
|
|
208
|
+
} else if ( builder.isVector( typeB ) ) {
|
|
209
|
+
|
|
210
|
+
// matrix x vector
|
|
211
|
+
typeB = builder.getVectorFromMatrix( typeA );
|
|
212
|
+
|
|
213
|
+
} else if ( builder.isMatrix( typeB ) ) {
|
|
214
|
+
// matrix x matrix - keep both types
|
|
215
|
+
} else {
|
|
216
|
+
|
|
217
|
+
typeA = typeB = type;
|
|
218
|
+
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
} else if ( builder.isMatrix( typeB ) ) {
|
|
222
|
+
|
|
223
|
+
if ( typeA === 'float' ) {
|
|
224
|
+
|
|
225
|
+
// Keep matrix type for typeB, but ensure typeA stays float
|
|
226
|
+
typeA = 'float';
|
|
177
227
|
|
|
178
|
-
|
|
228
|
+
} else if ( builder.isVector( typeA ) ) {
|
|
179
229
|
|
|
180
|
-
|
|
230
|
+
// vector x matrix
|
|
231
|
+
typeA = builder.getVectorFromMatrix( typeB );
|
|
181
232
|
|
|
182
|
-
|
|
233
|
+
} else {
|
|
183
234
|
|
|
184
|
-
|
|
235
|
+
typeA = typeB = type;
|
|
185
236
|
|
|
186
|
-
|
|
237
|
+
}
|
|
187
238
|
|
|
188
239
|
} else {
|
|
189
240
|
|
|
@@ -265,7 +316,20 @@ class OperatorNode extends TempNode {
|
|
|
265
316
|
|
|
266
317
|
} else {
|
|
267
318
|
|
|
268
|
-
|
|
319
|
+
// Handle matrix operations
|
|
320
|
+
if ( builder.isMatrix( typeA ) && typeB === 'float' ) {
|
|
321
|
+
|
|
322
|
+
return builder.format( `( ${ b } ${ op } ${ a } )`, type, output );
|
|
323
|
+
|
|
324
|
+
} else if ( typeA === 'float' && builder.isMatrix( typeB ) ) {
|
|
325
|
+
|
|
326
|
+
return builder.format( `${ a } ${ op } ${ b }`, type, output );
|
|
327
|
+
|
|
328
|
+
} else {
|
|
329
|
+
|
|
330
|
+
return builder.format( `( ${ a } ${ op } ${ b } )`, type, output );
|
|
331
|
+
|
|
332
|
+
}
|
|
269
333
|
|
|
270
334
|
}
|
|
271
335
|
|
|
@@ -277,7 +341,15 @@ class OperatorNode extends TempNode {
|
|
|
277
341
|
|
|
278
342
|
} else {
|
|
279
343
|
|
|
280
|
-
|
|
344
|
+
if ( builder.isMatrix( typeA ) && typeB === 'float' ) {
|
|
345
|
+
|
|
346
|
+
return builder.format( `${ b } ${ op } ${ a }`, type, output );
|
|
347
|
+
|
|
348
|
+
} else {
|
|
349
|
+
|
|
350
|
+
return builder.format( `${ a } ${ op } ${ b }`, type, output );
|
|
351
|
+
|
|
352
|
+
}
|
|
281
353
|
|
|
282
354
|
}
|
|
283
355
|
|
|
@@ -541,7 +613,13 @@ addMethodChaining( 'bitXor', bitXor );
|
|
|
541
613
|
addMethodChaining( 'shiftLeft', shiftLeft );
|
|
542
614
|
addMethodChaining( 'shiftRight', shiftRight );
|
|
543
615
|
|
|
544
|
-
|
|
616
|
+
/**
|
|
617
|
+
* @function
|
|
618
|
+
* @deprecated since r168. Use {@link modInt} instead.
|
|
619
|
+
*
|
|
620
|
+
* @param {...any} params
|
|
621
|
+
* @returns {Function}
|
|
622
|
+
*/
|
|
545
623
|
export const remainder = ( ...params ) => { // @deprecated, r168
|
|
546
624
|
|
|
547
625
|
console.warn( 'TSL.OperatorNode: .remainder() has been renamed to .modInt().' );
|
|
@@ -267,7 +267,7 @@ export const blur = /*@__PURE__*/ Fn( ( { n, latitudinal, poleAxis, outputDirect
|
|
|
267
267
|
axis.assign( normalize( axis ) );
|
|
268
268
|
|
|
269
269
|
const gl_FragColor = vec3().toVar();
|
|
270
|
-
gl_FragColor.addAssign( weights.element(
|
|
270
|
+
gl_FragColor.addAssign( weights.element( 0 ).mul( getSample( { theta: 0.0, axis, outputDirection, mipInt, envMap, CUBEUV_TEXEL_WIDTH, CUBEUV_TEXEL_HEIGHT, CUBEUV_MAX_MIP } ) ) );
|
|
271
271
|
|
|
272
272
|
Loop( { start: int( 1 ), end: n }, ( { i } ) => {
|
|
273
273
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Fn, float } from '../tsl/TSLBase.js';
|
|
2
|
+
import { lengthSq, smoothstep } from '../math/MathNode.js';
|
|
3
|
+
import { uv } from '../accessors/UV.js';
|
|
4
|
+
|
|
5
|
+
/** @module Shapes **/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Generates a circle based on the uv coordinates.
|
|
9
|
+
*
|
|
10
|
+
* @method
|
|
11
|
+
* @param {Node<vec2>} coord - The uv to generate the circle.
|
|
12
|
+
* @return {Node<float>} The circle shape.
|
|
13
|
+
*/
|
|
14
|
+
export const shapeCircle = Fn( ( [ coord = uv() ], { renderer, material } ) => {
|
|
15
|
+
|
|
16
|
+
const alpha = float( 1 ).toVar();
|
|
17
|
+
const len2 = lengthSq( coord.mul( 2 ).sub( 1 ) );
|
|
18
|
+
|
|
19
|
+
if ( material.alphaToCoverage && renderer.samples > 1 ) {
|
|
20
|
+
|
|
21
|
+
const dlen = float( len2.fwidth() ).toVar();
|
|
22
|
+
|
|
23
|
+
alpha.assign( smoothstep( dlen.oneMinus(), dlen.add( 1 ), len2 ).oneMinus() );
|
|
24
|
+
|
|
25
|
+
} else {
|
|
26
|
+
|
|
27
|
+
len2.greaterThan( 1.0 ).discard();
|
|
28
|
+
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return alpha;
|
|
32
|
+
|
|
33
|
+
} );
|
package/src/nodes/tsl/TSLBase.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// TSL Base Syntax
|
|
3
3
|
|
|
4
4
|
export * from './TSLCore.js'; // float(), vec2(), vec3(), vec4(), mat3(), mat4(), Fn(), If(), element(), nodeObject(), nodeProxy(), ...
|
|
5
|
+
export * from '../core/ArrayNode.js'; // array(), .toArray()
|
|
5
6
|
export * from '../core/UniformNode.js'; // uniform()
|
|
6
7
|
export * from '../core/PropertyNode.js'; // property() <-> TODO: Separate Material Properties in other file
|
|
7
8
|
export * from '../core/AssignNode.js'; // .assign()
|
package/src/nodes/tsl/TSLCore.js
CHANGED
|
@@ -6,9 +6,10 @@ import SplitNode from '../utils/SplitNode.js';
|
|
|
6
6
|
import SetNode from '../utils/SetNode.js';
|
|
7
7
|
import FlipNode from '../utils/FlipNode.js';
|
|
8
8
|
import ConstNode from '../core/ConstNode.js';
|
|
9
|
+
import MemberNode from '../utils/MemberNode.js';
|
|
9
10
|
import { getValueFromType, getValueType } from '../core/NodeUtils.js';
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
/** @module TSLCore **/
|
|
12
13
|
|
|
13
14
|
let currentStack = null;
|
|
14
15
|
|
|
@@ -112,6 +113,12 @@ const shaderNodeHandler = {
|
|
|
112
113
|
|
|
113
114
|
return nodeObject( new ArrayElementNode( nodeObj, new ConstNode( Number( prop ), 'uint' ) ) );
|
|
114
115
|
|
|
116
|
+
} else if ( /^get$/.test( prop ) === true ) {
|
|
117
|
+
|
|
118
|
+
// accessing properties
|
|
119
|
+
|
|
120
|
+
return ( value ) => nodeObject( new MemberNode( nodeObj, value ) );
|
|
121
|
+
|
|
115
122
|
}
|
|
116
123
|
|
|
117
124
|
}
|
|
@@ -261,6 +268,12 @@ class ShaderCallNodeInternal extends Node {
|
|
|
261
268
|
|
|
262
269
|
}
|
|
263
270
|
|
|
271
|
+
getMemberType( builder, name ) {
|
|
272
|
+
|
|
273
|
+
return this.getOutputNode( builder ).getMemberType( builder, name );
|
|
274
|
+
|
|
275
|
+
}
|
|
276
|
+
|
|
264
277
|
call( builder ) {
|
|
265
278
|
|
|
266
279
|
const { shaderNode, inputNodes } = this;
|
|
@@ -305,7 +318,7 @@ class ShaderCallNodeInternal extends Node {
|
|
|
305
318
|
} else {
|
|
306
319
|
|
|
307
320
|
const jsFunc = shaderNode.jsFunc;
|
|
308
|
-
const outputNode = inputNodes !== null ? jsFunc( inputNodes, builder ) : jsFunc( builder );
|
|
321
|
+
const outputNode = inputNodes !== null || jsFunc.length > 1 ? jsFunc( inputNodes || [], builder ) : jsFunc( builder );
|
|
309
322
|
|
|
310
323
|
result = nodeObject( outputNode );
|
|
311
324
|
|
|
@@ -553,6 +566,13 @@ export const Fn = ( jsFunc, nodeType ) => {
|
|
|
553
566
|
|
|
554
567
|
};
|
|
555
568
|
|
|
569
|
+
/**
|
|
570
|
+
* @function
|
|
571
|
+
* @deprecated since r168. Use {@link Fn} instead.
|
|
572
|
+
*
|
|
573
|
+
* @param {...any} params
|
|
574
|
+
* @returns {Function}
|
|
575
|
+
*/
|
|
556
576
|
export const tslFn = ( ...params ) => { // @deprecated, r168
|
|
557
577
|
|
|
558
578
|
console.warn( 'TSL.ShaderNode: tslFn() has been renamed to Fn().' );
|
|
@@ -66,7 +66,7 @@ class ArrayElementNode extends Node { // @TODO: If extending from TempNode it br
|
|
|
66
66
|
const nodeSnippet = this.node.build( builder );
|
|
67
67
|
const indexSnippet = this.indexNode.build( builder, 'uint' );
|
|
68
68
|
|
|
69
|
-
return `${nodeSnippet}[ ${indexSnippet} ]`;
|
|
69
|
+
return `${ nodeSnippet }[ ${ indexSnippet } ]`;
|
|
70
70
|
|
|
71
71
|
}
|
|
72
72
|
|
|
@@ -274,8 +274,15 @@ export const Continue = () => expression( 'continue' ).append();
|
|
|
274
274
|
*/
|
|
275
275
|
export const Break = () => expression( 'break' ).append();
|
|
276
276
|
|
|
277
|
-
//
|
|
277
|
+
// Deprecated
|
|
278
278
|
|
|
279
|
+
/**
|
|
280
|
+
* @function
|
|
281
|
+
* @deprecated since r168. Use {@link Loop} instead.
|
|
282
|
+
*
|
|
283
|
+
* @param {...any} params
|
|
284
|
+
* @returns {LoopNode}
|
|
285
|
+
*/
|
|
279
286
|
export const loop = ( ...params ) => { // @deprecated, r168
|
|
280
287
|
|
|
281
288
|
console.warn( 'TSL.LoopNode: loop() has been renamed to Loop().' );
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Base class for representing member access on an object-like
|
|
5
|
+
* node data structures.
|
|
6
|
+
*
|
|
7
|
+
* @augments Node
|
|
8
|
+
*/
|
|
9
|
+
class MemberNode extends Node {
|
|
10
|
+
|
|
11
|
+
static get type() {
|
|
12
|
+
|
|
13
|
+
return 'MemberNode';
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Constructs an array element node.
|
|
19
|
+
*
|
|
20
|
+
* @param {Node} node - The array-like node.
|
|
21
|
+
* @param {String} property - The property name.
|
|
22
|
+
*/
|
|
23
|
+
constructor( node, property ) {
|
|
24
|
+
|
|
25
|
+
super();
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The array-like node.
|
|
29
|
+
*
|
|
30
|
+
* @type {Node}
|
|
31
|
+
*/
|
|
32
|
+
this.node = node;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The property name.
|
|
36
|
+
*
|
|
37
|
+
* @type {Node}
|
|
38
|
+
*/
|
|
39
|
+
this.property = property;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* This flag can be used for type testing.
|
|
43
|
+
*
|
|
44
|
+
* @type {Boolean}
|
|
45
|
+
* @readonly
|
|
46
|
+
* @default true
|
|
47
|
+
*/
|
|
48
|
+
this.isMemberNode = true;
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
getNodeType( builder ) {
|
|
53
|
+
|
|
54
|
+
return this.node.getMemberType( builder, this.property );
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
generate( builder ) {
|
|
59
|
+
|
|
60
|
+
const propertyName = this.node.build( builder );
|
|
61
|
+
|
|
62
|
+
return propertyName + '.' + this.property;
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default MemberNode;
|
|
@@ -61,6 +61,20 @@ class StorageArrayElementNode extends ArrayElementNode {
|
|
|
61
61
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
getMemberType( builder, name ) {
|
|
65
|
+
|
|
66
|
+
const structTypeNode = this.storageBufferNode.structTypeNode;
|
|
67
|
+
|
|
68
|
+
if ( structTypeNode ) {
|
|
69
|
+
|
|
70
|
+
return structTypeNode.getMemberType( builder, name );
|
|
71
|
+
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return 'void';
|
|
75
|
+
|
|
76
|
+
}
|
|
77
|
+
|
|
64
78
|
setup( builder ) {
|
|
65
79
|
|
|
66
80
|
if ( builder.isAvailable( 'storageBuffer' ) === false ) {
|
package/src/nodes/utils/Timer.js
CHANGED
|
@@ -26,6 +26,13 @@ export const frameId = /*@__PURE__*/ uniform( 0, 'uint' ).setGroup( renderGroup
|
|
|
26
26
|
|
|
27
27
|
// Deprecated
|
|
28
28
|
|
|
29
|
+
/**
|
|
30
|
+
* @function
|
|
31
|
+
* @deprecated since r170. Use {@link time} instead.
|
|
32
|
+
*
|
|
33
|
+
* @param {Number} [timeScale=1] - The time scale.
|
|
34
|
+
* @returns {UniformNode<float>}
|
|
35
|
+
*/
|
|
29
36
|
export const timerLocal = ( timeScale = 1 ) => { // @deprecated, r170
|
|
30
37
|
|
|
31
38
|
console.warn( 'TSL: timerLocal() is deprecated. Use "time" instead.' );
|
|
@@ -33,6 +40,13 @@ export const timerLocal = ( timeScale = 1 ) => { // @deprecated, r170
|
|
|
33
40
|
|
|
34
41
|
};
|
|
35
42
|
|
|
43
|
+
/**
|
|
44
|
+
* @function
|
|
45
|
+
* @deprecated since r170. Use {@link time} instead.
|
|
46
|
+
*
|
|
47
|
+
* @param {Number} [timeScale=1] - The time scale.
|
|
48
|
+
* @returns {UniformNode<float>}
|
|
49
|
+
*/
|
|
36
50
|
export const timerGlobal = ( timeScale = 1 ) => { // @deprecated, r170
|
|
37
51
|
|
|
38
52
|
console.warn( 'TSL: timerGlobal() is deprecated. Use "time" instead.' );
|
|
@@ -40,6 +54,13 @@ export const timerGlobal = ( timeScale = 1 ) => { // @deprecated, r170
|
|
|
40
54
|
|
|
41
55
|
};
|
|
42
56
|
|
|
57
|
+
/**
|
|
58
|
+
* @function
|
|
59
|
+
* @deprecated since r170. Use {@link deltaTime} instead.
|
|
60
|
+
*
|
|
61
|
+
* @param {Number} [timeScale=1] - The time scale.
|
|
62
|
+
* @returns {UniformNode<float>}
|
|
63
|
+
*/
|
|
43
64
|
export const timerDelta = ( timeScale = 1 ) => { // @deprecated, r170
|
|
44
65
|
|
|
45
66
|
console.warn( 'TSL: timerDelta() is deprecated. Use "deltaTime" instead.' );
|
|
@@ -656,7 +656,7 @@ class BatchedMesh extends Mesh {
|
|
|
656
656
|
const instanceInfo = this._instanceInfo;
|
|
657
657
|
for ( let i = 0, l = instanceInfo.length; i < l; i ++ ) {
|
|
658
658
|
|
|
659
|
-
if ( instanceInfo[ i ].geometryIndex === geometryId ) {
|
|
659
|
+
if ( instanceInfo[ i ].active && instanceInfo[ i ].geometryIndex === geometryId ) {
|
|
660
660
|
|
|
661
661
|
this.deleteInstance( i );
|
|
662
662
|
|
package/src/objects/Line.js
CHANGED
|
@@ -119,7 +119,7 @@ class Line extends Object3D {
|
|
|
119
119
|
const a = index.getX( i );
|
|
120
120
|
const b = index.getX( i + 1 );
|
|
121
121
|
|
|
122
|
-
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, a, b );
|
|
122
|
+
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, a, b, i );
|
|
123
123
|
|
|
124
124
|
if ( intersect ) {
|
|
125
125
|
|
|
@@ -134,7 +134,7 @@ class Line extends Object3D {
|
|
|
134
134
|
const a = index.getX( end - 1 );
|
|
135
135
|
const b = index.getX( start );
|
|
136
136
|
|
|
137
|
-
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, a, b );
|
|
137
|
+
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, a, b, end - 1 );
|
|
138
138
|
|
|
139
139
|
if ( intersect ) {
|
|
140
140
|
|
|
@@ -151,7 +151,7 @@ class Line extends Object3D {
|
|
|
151
151
|
|
|
152
152
|
for ( let i = start, l = end - 1; i < l; i += step ) {
|
|
153
153
|
|
|
154
|
-
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, i, i + 1 );
|
|
154
|
+
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, i, i + 1, i );
|
|
155
155
|
|
|
156
156
|
if ( intersect ) {
|
|
157
157
|
|
|
@@ -163,7 +163,7 @@ class Line extends Object3D {
|
|
|
163
163
|
|
|
164
164
|
if ( this.isLineLoop ) {
|
|
165
165
|
|
|
166
|
-
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, end - 1, start );
|
|
166
|
+
const intersect = checkIntersection( this, raycaster, _ray, localThresholdSq, end - 1, start, end - 1 );
|
|
167
167
|
|
|
168
168
|
if ( intersect ) {
|
|
169
169
|
|
|
@@ -210,7 +210,7 @@ class Line extends Object3D {
|
|
|
210
210
|
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
-
function checkIntersection( object, raycaster, ray, thresholdSq, a, b ) {
|
|
213
|
+
function checkIntersection( object, raycaster, ray, thresholdSq, a, b, i ) {
|
|
214
214
|
|
|
215
215
|
const positionAttribute = object.geometry.attributes.position;
|
|
216
216
|
|
|
@@ -233,7 +233,7 @@ function checkIntersection( object, raycaster, ray, thresholdSq, a, b ) {
|
|
|
233
233
|
// What do we want? intersection point on the ray or on the segment??
|
|
234
234
|
// point: raycaster.ray.at( distance ),
|
|
235
235
|
point: _intersectPointOnSegment.clone().applyMatrix4( object.matrixWorld ),
|
|
236
|
-
index:
|
|
236
|
+
index: i,
|
|
237
237
|
face: null,
|
|
238
238
|
faceIndex: null,
|
|
239
239
|
barycoord: null,
|
|
@@ -2335,6 +2335,13 @@ class WebGLRenderer {
|
|
|
2335
2335
|
const _scratchFrameBuffer = _gl.createFramebuffer();
|
|
2336
2336
|
this.setRenderTarget = function ( renderTarget, activeCubeFace = 0, activeMipmapLevel = 0 ) {
|
|
2337
2337
|
|
|
2338
|
+
// Render to base layer instead of canvas in WebXR
|
|
2339
|
+
if ( renderTarget === null && this.xr.isPresenting ) {
|
|
2340
|
+
|
|
2341
|
+
renderTarget = this.xr.getRenderTarget();
|
|
2342
|
+
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2338
2345
|
_currentRenderTarget = renderTarget;
|
|
2339
2346
|
_currentActiveCubeFace = activeCubeFace;
|
|
2340
2347
|
_currentActiveMipmapLevel = activeMipmapLevel;
|
|
@@ -45,7 +45,7 @@ class Animation {
|
|
|
45
45
|
this._animationLoop = null;
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* The requestId
|
|
48
|
+
* The requestId which is returned from the `requestAnimationFrame()` call.
|
|
49
49
|
* Can be used to cancel the stop the animation loop.
|
|
50
50
|
*
|
|
51
51
|
* @type {Number?}
|
|
@@ -89,6 +89,17 @@ class Animation {
|
|
|
89
89
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
/**
|
|
93
|
+
* Returns the user-level animation loop.
|
|
94
|
+
*
|
|
95
|
+
* @return {Function} The animation loop.
|
|
96
|
+
*/
|
|
97
|
+
getAnimationLoop() {
|
|
98
|
+
|
|
99
|
+
return this._animationLoop;
|
|
100
|
+
|
|
101
|
+
}
|
|
102
|
+
|
|
92
103
|
/**
|
|
93
104
|
* Defines the user-level animation loop.
|
|
94
105
|
*
|
|
@@ -100,6 +111,17 @@ class Animation {
|
|
|
100
111
|
|
|
101
112
|
}
|
|
102
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Returns the animation context.
|
|
116
|
+
*
|
|
117
|
+
* @return {Window|XRSession} The animation context.
|
|
118
|
+
*/
|
|
119
|
+
getContext() {
|
|
120
|
+
|
|
121
|
+
return this._context;
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
|
|
103
125
|
/**
|
|
104
126
|
* Defines the context in which `requestAnimationFrame()` is executed.
|
|
105
127
|
*
|