@plastic-software/three 0.181.3 → 0.182.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/README.md +3 -4
- package/build/three.cjs +1192 -522
- package/build/three.core.js +345 -219
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +864 -328
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +15 -3
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +3660 -1545
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +3659 -1544
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/controls/MapControls.js +55 -1
- package/examples/jsm/controls/OrbitControls.js +6 -6
- package/examples/jsm/controls/TrackballControls.js +6 -6
- package/examples/jsm/csm/CSM.js +2 -1
- package/examples/jsm/environments/RoomEnvironment.js +2 -0
- package/examples/jsm/geometries/DecalGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelperGPU.js +1 -1
- package/examples/jsm/helpers/TextureHelperGPU.js +1 -1
- package/examples/jsm/inspector/Inspector.js +53 -9
- package/examples/jsm/inspector/RendererInspector.js +12 -2
- package/examples/jsm/inspector/tabs/Console.js +2 -2
- package/examples/jsm/inspector/tabs/Parameters.js +2 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Viewer.js +4 -4
- package/examples/jsm/inspector/ui/Profiler.js +1836 -31
- package/examples/jsm/inspector/ui/Style.js +948 -13
- package/examples/jsm/inspector/ui/Tab.js +188 -1
- package/examples/jsm/inspector/ui/Values.js +17 -1
- package/examples/jsm/loaders/3DMLoader.js +5 -4
- package/examples/jsm/loaders/DRACOLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +0 -2
- package/examples/jsm/loaders/HDRLoader.js +0 -1
- package/examples/jsm/loaders/KTX2Loader.js +16 -0
- package/examples/jsm/loaders/LDrawLoader.js +2 -3
- package/examples/jsm/loaders/PCDLoader.js +1 -0
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/TDSLoader.js +0 -2
- package/examples/jsm/loaders/TGALoader.js +0 -2
- package/examples/jsm/loaders/UltraHDRLoader.js +110 -137
- package/examples/jsm/loaders/VOXLoader.js +660 -117
- package/examples/jsm/loaders/VRMLLoader.js +2 -2
- package/examples/jsm/loaders/usd/USDCParser.js +1 -1
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +1 -1
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -1
- package/examples/jsm/materials/WoodNodeMaterial.js +11 -11
- package/examples/jsm/math/Octree.js +131 -1
- package/examples/jsm/misc/Volume.js +0 -1
- package/examples/jsm/misc/VolumeSlice.js +0 -1
- package/examples/jsm/objects/SkyMesh.js +13 -3
- package/examples/jsm/physics/AmmoPhysics.js +12 -7
- package/examples/jsm/physics/JoltPhysics.js +3 -1
- package/examples/jsm/physics/RapierPhysics.js +3 -1
- package/examples/jsm/postprocessing/OutputPass.js +9 -0
- package/examples/jsm/postprocessing/RenderPass.js +10 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +48 -18
- package/examples/jsm/renderers/Projector.js +268 -30
- package/examples/jsm/renderers/SVGRenderer.js +191 -58
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -4
- package/examples/jsm/transpiler/AST.js +44 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +61 -4
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -0
- package/examples/jsm/transpiler/TSLEncoder.js +46 -3
- package/examples/jsm/transpiler/TranspilerUtils.js +3 -3
- package/examples/jsm/transpiler/WGSLEncoder.js +27 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +2 -0
- package/examples/jsm/tsl/display/BloomNode.js +11 -1
- package/examples/jsm/tsl/display/GTAONode.js +3 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +2 -1
- package/examples/jsm/tsl/display/SSGINode.js +7 -19
- package/examples/jsm/tsl/display/SSRNode.js +1 -1
- package/examples/jsm/tsl/display/SSSNode.js +4 -2
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +8 -1
- package/examples/jsm/tsl/display/TRAANode.js +265 -114
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/utils/ShadowMapViewer.js +24 -10
- package/examples/jsm/utils/ShadowMapViewerGPU.js +1 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/package.json +14 -12
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +14 -2
- package/src/animation/AnimationUtils.js +1 -12
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/ColorKeyframeTrack.js +1 -1
- package/src/animation/tracks/NumberKeyframeTrack.js +1 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/animation/tracks/VectorKeyframeTrack.js +1 -1
- package/src/constants.js +61 -5
- package/src/core/BufferGeometry.js +14 -2
- package/src/core/Raycaster.js +2 -2
- package/src/extras/PMREMGenerator.js +3 -10
- package/src/extras/TextureUtils.js +5 -1
- package/src/geometries/ExtrudeGeometry.js +2 -2
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/helpers/PointLightHelper.js +1 -1
- package/src/lights/DirectionalLight.js +13 -0
- package/src/lights/HemisphereLight.js +10 -0
- package/src/lights/Light.js +1 -11
- package/src/lights/LightProbe.js +0 -15
- package/src/lights/LightShadow.js +0 -3
- package/src/lights/PointLight.js +15 -0
- package/src/lights/PointLightShadow.js +0 -86
- package/src/lights/SpotLight.js +22 -1
- package/src/loaders/MaterialLoader.js +2 -1
- package/src/loaders/ObjectLoader.js +3 -1
- package/src/loaders/nodes/NodeLoader.js +2 -2
- package/src/materials/Material.js +2 -0
- package/src/materials/ShaderMaterial.js +20 -1
- package/src/materials/nodes/Line2NodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +3 -2
- package/src/materials/nodes/MeshStandardNodeMaterial.js +5 -4
- package/src/materials/nodes/NodeMaterial.js +59 -3
- package/src/materials/nodes/manager/NodeMaterialObserver.js +1 -1
- package/src/math/Matrix4.js +40 -40
- package/src/math/Sphere.js +1 -1
- package/src/math/Vector3.js +0 -2
- package/src/nodes/TSL.js +4 -1
- package/src/nodes/accessors/BatchNode.js +10 -10
- package/src/nodes/accessors/BufferAttributeNode.js +98 -12
- package/src/nodes/accessors/BufferNode.js +29 -2
- package/src/nodes/accessors/ClippingNode.js +4 -4
- package/src/nodes/accessors/CubeTextureNode.js +20 -1
- package/src/nodes/accessors/InstanceNode.js +69 -29
- package/src/nodes/accessors/MaterialNode.js +9 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +1 -2
- package/src/nodes/accessors/ModelNode.js +1 -1
- package/src/nodes/accessors/Normal.js +2 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +4 -4
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/RendererReferenceNode.js +1 -2
- package/src/nodes/accessors/SkinningNode.js +15 -2
- package/src/nodes/accessors/StorageBufferNode.js +4 -2
- package/src/nodes/accessors/Tangent.js +1 -11
- package/src/nodes/accessors/Texture3DNode.js +26 -1
- package/src/nodes/accessors/UniformArrayNode.js +2 -2
- package/src/nodes/accessors/UserDataNode.js +1 -2
- package/src/nodes/accessors/VertexColorNode.js +1 -2
- package/src/nodes/code/FunctionNode.js +1 -2
- package/src/nodes/core/ArrayNode.js +20 -1
- package/src/nodes/core/AssignNode.js +2 -2
- package/src/nodes/core/AttributeNode.js +2 -2
- package/src/nodes/core/ContextNode.js +103 -4
- package/src/nodes/core/NodeBuilder.js +56 -14
- package/src/nodes/core/NodeFrame.js +12 -4
- package/src/nodes/core/NodeUtils.js +5 -5
- package/src/nodes/core/ParameterNode.js +1 -2
- package/src/nodes/core/PropertyNode.js +19 -3
- package/src/nodes/core/StackNode.js +56 -8
- package/src/nodes/core/StructNode.js +1 -2
- package/src/nodes/core/StructTypeNode.js +11 -17
- package/src/nodes/core/UniformNode.js +19 -4
- package/src/nodes/core/VarNode.js +46 -21
- package/src/nodes/display/NormalMapNode.js +37 -2
- package/src/nodes/display/PassNode.js +77 -7
- package/src/nodes/display/ScreenNode.js +1 -0
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +3 -3
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/PhysicalLightingModel.js +102 -43
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -2
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -3
- package/src/nodes/lighting/AnalyticLightNode.js +53 -0
- package/src/nodes/lighting/LightsNode.js +2 -2
- package/src/nodes/lighting/PointShadowNode.js +141 -140
- package/src/nodes/lighting/ShadowFilterNode.js +53 -37
- package/src/nodes/lighting/ShadowNode.js +53 -19
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/tsl/TSLCore.js +4 -4
- package/src/nodes/utils/ArrayElementNode.js +13 -0
- package/src/nodes/utils/EventNode.js +1 -2
- package/src/nodes/utils/Packing.js +13 -1
- package/src/nodes/utils/PostProcessingUtils.js +33 -1
- package/src/nodes/utils/ReflectorNode.js +1 -1
- package/src/nodes/utils/SampleNode.js +1 -1
- package/src/nodes/utils/UVUtils.js +26 -0
- package/src/objects/BatchedMesh.js +5 -2
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/Skeleton.js +9 -0
- package/src/renderers/WebGLRenderer.js +145 -33
- package/src/renderers/common/Backend.js +8 -0
- package/src/renderers/common/Background.js +19 -9
- package/src/renderers/common/Binding.js +11 -0
- package/src/renderers/common/Bindings.js +7 -7
- package/src/renderers/common/Buffer.js +40 -0
- package/src/renderers/common/ChainMap.js +30 -6
- package/src/renderers/common/Geometries.js +12 -0
- package/src/renderers/common/RenderContexts.js +8 -1
- package/src/renderers/common/RenderObject.js +14 -1
- package/src/renderers/common/Renderer.js +53 -35
- package/src/renderers/common/Textures.js +1 -1
- package/src/renderers/common/UniformsGroup.js +1 -0
- package/src/renderers/common/XRManager.js +1 -0
- package/src/renderers/common/extras/PMREMGenerator.js +2 -8
- package/src/renderers/common/nodes/NodeUniformBuffer.js +52 -0
- package/src/renderers/shaders/DFGLUTData.js +19 -34
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +90 -51
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +194 -186
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +3 -3
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +3 -3
- package/src/renderers/webgl/WebGLCapabilities.js +3 -4
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLOutput.js +267 -0
- package/src/renderers/webgl/WebGLProgram.js +43 -107
- package/src/renderers/webgl/WebGLPrograms.js +35 -45
- package/src/renderers/webgl/WebGLShadowMap.js +188 -25
- package/src/renderers/webgl/WebGLState.js +20 -20
- package/src/renderers/webgl/WebGLTextures.js +89 -28
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUtils.js +6 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +79 -13
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +59 -7
- package/src/renderers/webgl-fallback/utils/WebGLState.js +18 -3
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +5 -3
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -9
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +6 -2
- package/src/renderers/webgpu/WebGPUBackend.js +61 -4
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +65 -23
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +354 -186
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +20 -7
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +40 -17
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +7 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +7 -5
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +1 -1
- package/src/utils.js +13 -1
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -71
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import BufferNode from './BufferNode.js';
|
|
2
2
|
import { bufferAttribute } from './BufferAttributeNode.js';
|
|
3
|
-
import {
|
|
3
|
+
import { varying } from '../tsl/TSLBase.js';
|
|
4
4
|
import { storageElement } from '../utils/StorageArrayElementNode.js';
|
|
5
5
|
import { NodeAccess } from '../core/constants.js';
|
|
6
6
|
import { getTypeFromLength } from '../core/NodeUtils.js';
|
|
@@ -126,6 +126,7 @@ class StorageBufferNode extends BufferNode {
|
|
|
126
126
|
/**
|
|
127
127
|
* A reference to the internal buffer attribute node.
|
|
128
128
|
*
|
|
129
|
+
* @private
|
|
129
130
|
* @type {?BufferAttributeNode}
|
|
130
131
|
* @default null
|
|
131
132
|
*/
|
|
@@ -134,6 +135,7 @@ class StorageBufferNode extends BufferNode {
|
|
|
134
135
|
/**
|
|
135
136
|
* A reference to the internal varying node.
|
|
136
137
|
*
|
|
138
|
+
* @private
|
|
137
139
|
* @type {?VaryingNode}
|
|
138
140
|
* @default null
|
|
139
141
|
*/
|
|
@@ -395,7 +397,7 @@ export default StorageBufferNode;
|
|
|
395
397
|
* @param {number} [count=0] - The buffer count.
|
|
396
398
|
* @returns {StorageBufferNode}
|
|
397
399
|
*/
|
|
398
|
-
export const storage = ( value, type = null, count = 0 ) =>
|
|
400
|
+
export const storage = ( value, type = null, count = 0 ) => new StorageBufferNode( value, type, count );
|
|
399
401
|
|
|
400
402
|
/**
|
|
401
403
|
* @tsl
|
|
@@ -11,17 +11,7 @@ import { directionToFaceDirection } from '../display/FrontFacingNode.js';
|
|
|
11
11
|
* @tsl
|
|
12
12
|
* @type {Node<vec4>}
|
|
13
13
|
*/
|
|
14
|
-
export const tangentGeometry = /*@__PURE__*/
|
|
15
|
-
|
|
16
|
-
if ( builder.geometry.hasAttribute( 'tangent' ) === false ) {
|
|
17
|
-
|
|
18
|
-
builder.geometry.computeTangents();
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return attribute( 'tangent', 'vec4' );
|
|
23
|
-
|
|
24
|
-
} )();
|
|
14
|
+
export const tangentGeometry = /*@__PURE__*/ attribute( 'tangent', 'vec4' );
|
|
25
15
|
|
|
26
16
|
/**
|
|
27
17
|
* TSL object that represents the vertex tangent in local space of the current rendered object.
|
|
@@ -192,8 +192,33 @@ export default Texture3DNode;
|
|
|
192
192
|
* @tsl
|
|
193
193
|
* @function
|
|
194
194
|
* @param {Data3DTexture} value - The 3D texture.
|
|
195
|
-
* @param {?Node<
|
|
195
|
+
* @param {?Node<vec3>} [uvNode=null] - The uv node.
|
|
196
196
|
* @param {?Node<int>} [levelNode=null] - The level node.
|
|
197
197
|
* @returns {Texture3DNode}
|
|
198
198
|
*/
|
|
199
199
|
export const texture3D = /*@__PURE__*/ nodeProxy( Texture3DNode ).setParameterLength( 1, 3 );
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* TSL function for creating a texture node that fetches/loads texels without interpolation.
|
|
203
|
+
*
|
|
204
|
+
* @tsl
|
|
205
|
+
* @function
|
|
206
|
+
* @param {?(Texture|TextureNode)} [value=EmptyTexture] - The texture.
|
|
207
|
+
* @param {?Node<vec3>} [uvNode=null] - The uv node.
|
|
208
|
+
* @param {?Node<int>} [levelNode=null] - The level node.
|
|
209
|
+
* @param {?Node<float>} [biasNode=null] - The bias node.
|
|
210
|
+
* @returns {TextureNode}
|
|
211
|
+
*/
|
|
212
|
+
export const texture3DLoad = ( ...params ) => texture3D( ...params ).setSampler( false );
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* TSL function for creating a texture node that fetches/loads texels without interpolation.
|
|
216
|
+
*
|
|
217
|
+
* @tsl
|
|
218
|
+
* @function
|
|
219
|
+
* @param {?(Texture|TextureNode)} [value=EmptyTexture] - The texture.
|
|
220
|
+
* @param {?Node<vec3>} [uvNode=null] - The uv node.
|
|
221
|
+
* @param {?Node<int>} [levelNode=null] - The level node.
|
|
222
|
+
* @returns {TextureNode}
|
|
223
|
+
*/
|
|
224
|
+
export const texture3DLevel = ( value, uvNode, levelNode ) => texture3D( value, uvNode ).level( levelNode );
|
|
@@ -328,7 +328,7 @@ class UniformArrayNode extends BufferNode {
|
|
|
328
328
|
*/
|
|
329
329
|
element( indexNode ) {
|
|
330
330
|
|
|
331
|
-
return
|
|
331
|
+
return new UniformArrayElementNode( this, nodeObject( indexNode ) );
|
|
332
332
|
|
|
333
333
|
}
|
|
334
334
|
|
|
@@ -345,4 +345,4 @@ export default UniformArrayNode;
|
|
|
345
345
|
* @param {?string} [nodeType] - The data type of the array elements.
|
|
346
346
|
* @returns {UniformArrayNode}
|
|
347
347
|
*/
|
|
348
|
-
export const uniformArray = ( values, nodeType ) =>
|
|
348
|
+
export const uniformArray = ( values, nodeType ) => new UniformArrayNode( values, nodeType );
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import ReferenceNode from './ReferenceNode.js';
|
|
2
|
-
import { nodeObject } from '../tsl/TSLBase.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* A special type of reference node that allows to link values in
|
|
@@ -74,4 +73,4 @@ export default UserDataNode;
|
|
|
74
73
|
* @param {?Object} userData - A reference to the `userData` object. If not provided, the `userData` property of the 3D object that uses the node material is evaluated.
|
|
75
74
|
* @returns {UserDataNode}
|
|
76
75
|
*/
|
|
77
|
-
export const userData = ( name, inputType, userData ) =>
|
|
76
|
+
export const userData = ( name, inputType, userData ) => new UserDataNode( name, inputType, userData );
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import AttributeNode from '../core/AttributeNode.js';
|
|
2
|
-
import { nodeObject } from '../tsl/TSLBase.js';
|
|
3
2
|
import { Vector4 } from '../../math/Vector4.js';
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -107,4 +106,4 @@ export default VertexColorNode;
|
|
|
107
106
|
* @param {number} [index=0] - The attribute index.
|
|
108
107
|
* @returns {VertexColorNode}
|
|
109
108
|
*/
|
|
110
|
-
export const vertexColor = ( index = 0 ) =>
|
|
109
|
+
export const vertexColor = ( index = 0 ) => new VertexColorNode( index );
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import CodeNode from './CodeNode.js';
|
|
2
|
-
import { nodeObject } from '../tsl/TSLBase.js';
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* This class represents a native shader function. It can be used to implement
|
|
@@ -170,7 +169,7 @@ const nativeFn = ( code, includes = [], language = '' ) => {
|
|
|
170
169
|
|
|
171
170
|
}
|
|
172
171
|
|
|
173
|
-
const functionNode =
|
|
172
|
+
const functionNode = new FunctionNode( code, includes, language );
|
|
174
173
|
|
|
175
174
|
const fn = ( ...params ) => functionNode.call( ...params );
|
|
176
175
|
fn.functionNode = functionNode;
|
|
@@ -81,7 +81,7 @@ class ArrayNode extends TempNode {
|
|
|
81
81
|
|
|
82
82
|
if ( this.nodeType === null ) {
|
|
83
83
|
|
|
84
|
-
|
|
84
|
+
return this.values[ 0 ].getNodeType( builder );
|
|
85
85
|
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -101,6 +101,25 @@ class ArrayNode extends TempNode {
|
|
|
101
101
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
/**
|
|
105
|
+
* Returns the type of a member variable.
|
|
106
|
+
*
|
|
107
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
108
|
+
* @param {string} name - The name of the member variable.
|
|
109
|
+
* @return {string} The type of the member variable.
|
|
110
|
+
*/
|
|
111
|
+
getMemberType( builder, name ) {
|
|
112
|
+
|
|
113
|
+
if ( this.nodeType === null ) {
|
|
114
|
+
|
|
115
|
+
return this.values[ 0 ].getMemberType( builder, name );
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return super.getMemberType( builder, name );
|
|
120
|
+
|
|
121
|
+
}
|
|
122
|
+
|
|
104
123
|
/**
|
|
105
124
|
* This method builds the output node and returns the resulting array as a shader string.
|
|
106
125
|
*
|
|
@@ -99,8 +99,8 @@ class AssignNode extends TempNode {
|
|
|
99
99
|
|
|
100
100
|
const scope = targetNode.getScope();
|
|
101
101
|
|
|
102
|
-
const
|
|
103
|
-
|
|
102
|
+
const scopeData = builder.getDataFromNode( scope );
|
|
103
|
+
scopeData.assign = true;
|
|
104
104
|
|
|
105
105
|
const properties = builder.getNodeProperties( this );
|
|
106
106
|
properties.sourceNode = sourceNode;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Node from './Node.js';
|
|
2
|
-
import {
|
|
2
|
+
import { varying } from '../tsl/TSLBase.js';
|
|
3
3
|
import { warn } from '../../utils.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -165,4 +165,4 @@ export default AttributeNode;
|
|
|
165
165
|
* @param {?string} [nodeType=null] - The node type.
|
|
166
166
|
* @returns {AttributeNode}
|
|
167
167
|
*/
|
|
168
|
-
export const attribute = ( name, nodeType = null ) =>
|
|
168
|
+
export const attribute = ( name, nodeType = null ) => new AttributeNode( name, nodeType );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Node from './Node.js';
|
|
2
|
-
import { addMethodChaining
|
|
2
|
+
import { addMethodChaining } from '../tsl/TSLCore.js';
|
|
3
3
|
import { warn } from '../../utils.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -9,6 +9,12 @@ import { warn } from '../../utils.js';
|
|
|
9
9
|
*
|
|
10
10
|
* ```js
|
|
11
11
|
*node.context( { getUV: () => customCoord } );
|
|
12
|
+
*\// or
|
|
13
|
+
*material.contextNode = context( { getUV: () => customCoord } );
|
|
14
|
+
*\// or
|
|
15
|
+
*renderer.contextNode = context( { getUV: () => customCoord } );
|
|
16
|
+
*\// or
|
|
17
|
+
*scenePass.contextNode = context( { getUV: () => customCoord } );
|
|
12
18
|
*```
|
|
13
19
|
* @augments Node
|
|
14
20
|
*/
|
|
@@ -26,7 +32,7 @@ class ContextNode extends Node {
|
|
|
26
32
|
* @param {Node} node - The node whose context should be modified.
|
|
27
33
|
* @param {Object} [value={}] - The modified context data.
|
|
28
34
|
*/
|
|
29
|
-
constructor( node, value = {} ) {
|
|
35
|
+
constructor( node = null, value = {} ) {
|
|
30
36
|
|
|
31
37
|
super();
|
|
32
38
|
|
|
@@ -79,6 +85,29 @@ class ContextNode extends Node {
|
|
|
79
85
|
|
|
80
86
|
}
|
|
81
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Gathers the context data from all parent context nodes.
|
|
90
|
+
*
|
|
91
|
+
* @return {Object} The gathered context data.
|
|
92
|
+
*/
|
|
93
|
+
getFlowContextData() {
|
|
94
|
+
|
|
95
|
+
const children = [];
|
|
96
|
+
|
|
97
|
+
this.traverse( ( node ) => {
|
|
98
|
+
|
|
99
|
+
if ( node.isContextNode === true ) {
|
|
100
|
+
|
|
101
|
+
children.push( node.value );
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
} );
|
|
106
|
+
|
|
107
|
+
return Object.assign( {}, ...children );
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
82
111
|
/**
|
|
83
112
|
* This method is overwritten to ensure it returns the member type of {@link ContextNode#node}.
|
|
84
113
|
*
|
|
@@ -133,11 +162,24 @@ export default ContextNode;
|
|
|
133
162
|
*
|
|
134
163
|
* @tsl
|
|
135
164
|
* @function
|
|
136
|
-
* @param {Node}
|
|
165
|
+
* @param {Node|Object} [nodeOrValue={}] - The node whose context should be modified or the modified context data.
|
|
137
166
|
* @param {Object} [value={}] - The modified context data.
|
|
138
167
|
* @returns {ContextNode}
|
|
139
168
|
*/
|
|
140
|
-
export const context =
|
|
169
|
+
export const context = ( nodeOrValue = null, value = {} ) => {
|
|
170
|
+
|
|
171
|
+
let node = nodeOrValue;
|
|
172
|
+
|
|
173
|
+
if ( node === null || node.isNode !== true ) {
|
|
174
|
+
|
|
175
|
+
value = node || value;
|
|
176
|
+
node = null;
|
|
177
|
+
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return new ContextNode( node, value );
|
|
181
|
+
|
|
182
|
+
};
|
|
141
183
|
|
|
142
184
|
/**
|
|
143
185
|
* TSL function for defining a uniformFlow context value for a given node.
|
|
@@ -160,6 +202,61 @@ export const uniformFlow = ( node ) => context( node, { uniformFlow: true } );
|
|
|
160
202
|
*/
|
|
161
203
|
export const setName = ( node, name ) => context( node, { nodeName: name } );
|
|
162
204
|
|
|
205
|
+
/**
|
|
206
|
+
* TSL function for defining a built-in shadow context for a given node.
|
|
207
|
+
*
|
|
208
|
+
* @tsl
|
|
209
|
+
* @function
|
|
210
|
+
* @param {ShadowNode} shadowNode - The shadow node representing the light's shadow.
|
|
211
|
+
* @param {Light} light - The light associated with the shadow.
|
|
212
|
+
* @param {Node} [node=null] - The node whose context should be modified.
|
|
213
|
+
* @returns {ContextNode}
|
|
214
|
+
*/
|
|
215
|
+
export function builtinShadowContext( shadowNode, light, node = null ) {
|
|
216
|
+
|
|
217
|
+
return context( node, {
|
|
218
|
+
|
|
219
|
+
getShadow: ( { light: shadowLight, shadowColorNode } ) => {
|
|
220
|
+
|
|
221
|
+
if ( light === shadowLight ) {
|
|
222
|
+
|
|
223
|
+
return shadowColorNode.mul( shadowNode );
|
|
224
|
+
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
return shadowColorNode;
|
|
228
|
+
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
} );
|
|
232
|
+
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* TSL function for defining a built-in ambient occlusion context for a given node.
|
|
237
|
+
*
|
|
238
|
+
* @tsl
|
|
239
|
+
* @function
|
|
240
|
+
* @param {Node} aoNode - The ambient occlusion value node to apply.
|
|
241
|
+
* @param {Node} [node=null] - The node whose context should be modified.
|
|
242
|
+
* @returns {ContextNode}
|
|
243
|
+
*/
|
|
244
|
+
export function builtinAOContext( aoNode, node = null ) {
|
|
245
|
+
|
|
246
|
+
return context( node, {
|
|
247
|
+
|
|
248
|
+
getAO: ( inputNode, { material } ) => {
|
|
249
|
+
|
|
250
|
+
if ( material.transparent === true ) return inputNode;
|
|
251
|
+
|
|
252
|
+
return inputNode !== null ? inputNode.mul( aoNode ) : aoNode;
|
|
253
|
+
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
} );
|
|
257
|
+
|
|
258
|
+
}
|
|
259
|
+
|
|
163
260
|
/**
|
|
164
261
|
* TSL function for defining a label context value for a given node.
|
|
165
262
|
*
|
|
@@ -182,3 +279,5 @@ addMethodChaining( 'context', context );
|
|
|
182
279
|
addMethodChaining( 'label', label );
|
|
183
280
|
addMethodChaining( 'uniformFlow', uniformFlow );
|
|
184
281
|
addMethodChaining( 'setName', setName );
|
|
282
|
+
addMethodChaining( 'builtinShadowContext', ( node, shadowNode, light ) => builtinShadowContext( shadowNode, light, node ) );
|
|
283
|
+
addMethodChaining( 'builtinAOContext', ( node, aoValue ) => builtinAOContext( aoValue, node ) );
|
|
@@ -35,6 +35,8 @@ import { warn, error } from '../../utils.js';
|
|
|
35
35
|
|
|
36
36
|
let _id = 0;
|
|
37
37
|
|
|
38
|
+
const sharedNodeData = new WeakMap();
|
|
39
|
+
|
|
38
40
|
const rendererCache = new WeakMap();
|
|
39
41
|
|
|
40
42
|
const typeFromArray = new Map( [
|
|
@@ -951,8 +953,13 @@ class NodeBuilder {
|
|
|
951
953
|
const context = { ...this.context };
|
|
952
954
|
|
|
953
955
|
delete context.material;
|
|
956
|
+
delete context.getUV;
|
|
957
|
+
delete context.getOutput;
|
|
958
|
+
delete context.getTextureLevel;
|
|
959
|
+
delete context.getAO;
|
|
960
|
+
delete context.getShadow;
|
|
954
961
|
|
|
955
|
-
return
|
|
962
|
+
return context;
|
|
956
963
|
|
|
957
964
|
}
|
|
958
965
|
|
|
@@ -1224,9 +1231,9 @@ class NodeBuilder {
|
|
|
1224
1231
|
if ( type === 'float' || type === 'int' || type === 'uint' ) value = 0;
|
|
1225
1232
|
else if ( type === 'bool' ) value = false;
|
|
1226
1233
|
else if ( type === 'color' ) value = new Color();
|
|
1227
|
-
else if ( type === 'vec2' ) value = new Vector2();
|
|
1228
|
-
else if ( type === 'vec3' ) value = new Vector3();
|
|
1229
|
-
else if ( type === 'vec4' ) value = new Vector4();
|
|
1234
|
+
else if ( type === 'vec2' || type === 'uvec2' || type === 'ivec2' ) value = new Vector2();
|
|
1235
|
+
else if ( type === 'vec3' || type === 'uvec3' || type === 'ivec3' ) value = new Vector3();
|
|
1236
|
+
else if ( type === 'vec4' || type === 'uvec4' || type === 'ivec4' ) value = new Vector4();
|
|
1230
1237
|
|
|
1231
1238
|
}
|
|
1232
1239
|
|
|
@@ -1777,7 +1784,7 @@ class NodeBuilder {
|
|
|
1777
1784
|
*/
|
|
1778
1785
|
getBufferAttributeFromNode( node, type ) {
|
|
1779
1786
|
|
|
1780
|
-
const nodeData = this.getDataFromNode( node );
|
|
1787
|
+
const nodeData = this.getDataFromNode( node, 'vertex' );
|
|
1781
1788
|
|
|
1782
1789
|
let bufferAttribute = nodeData.bufferAttribute;
|
|
1783
1790
|
|
|
@@ -2951,6 +2958,26 @@ class NodeBuilder {
|
|
|
2951
2958
|
|
|
2952
2959
|
}
|
|
2953
2960
|
|
|
2961
|
+
/**
|
|
2962
|
+
* Returns shared data object for the given node.
|
|
2963
|
+
*
|
|
2964
|
+
* @param {Node} node - The node to get shared data from.
|
|
2965
|
+
* @return {Object} The shared data.
|
|
2966
|
+
*/
|
|
2967
|
+
getSharedDataFromNode( node ) {
|
|
2968
|
+
|
|
2969
|
+
let data = sharedNodeData.get( node );
|
|
2970
|
+
|
|
2971
|
+
if ( data === undefined ) {
|
|
2972
|
+
|
|
2973
|
+
data = {};
|
|
2974
|
+
|
|
2975
|
+
}
|
|
2976
|
+
|
|
2977
|
+
return data;
|
|
2978
|
+
|
|
2979
|
+
}
|
|
2980
|
+
|
|
2954
2981
|
/**
|
|
2955
2982
|
* Returns a uniform representation which is later used for UBO generation and rendering.
|
|
2956
2983
|
*
|
|
@@ -2960,16 +2987,31 @@ class NodeBuilder {
|
|
|
2960
2987
|
*/
|
|
2961
2988
|
getNodeUniform( uniformNode, type ) {
|
|
2962
2989
|
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
if (
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2990
|
+
const nodeData = this.getSharedDataFromNode( uniformNode );
|
|
2991
|
+
|
|
2992
|
+
let node = nodeData.cache;
|
|
2993
|
+
|
|
2994
|
+
if ( node === undefined ) {
|
|
2995
|
+
|
|
2996
|
+
if ( type === 'float' || type === 'int' || type === 'uint' ) node = new NumberNodeUniform( uniformNode );
|
|
2997
|
+
else if ( type === 'vec2' || type === 'ivec2' || type === 'uvec2' ) node = new Vector2NodeUniform( uniformNode );
|
|
2998
|
+
else if ( type === 'vec3' || type === 'ivec3' || type === 'uvec3' ) node = new Vector3NodeUniform( uniformNode );
|
|
2999
|
+
else if ( type === 'vec4' || type === 'ivec4' || type === 'uvec4' ) node = new Vector4NodeUniform( uniformNode );
|
|
3000
|
+
else if ( type === 'color' ) node = new ColorNodeUniform( uniformNode );
|
|
3001
|
+
else if ( type === 'mat2' ) node = new Matrix2NodeUniform( uniformNode );
|
|
3002
|
+
else if ( type === 'mat3' ) node = new Matrix3NodeUniform( uniformNode );
|
|
3003
|
+
else if ( type === 'mat4' ) node = new Matrix4NodeUniform( uniformNode );
|
|
3004
|
+
else {
|
|
3005
|
+
|
|
3006
|
+
throw new Error( `Uniform "${ type }" not implemented.` );
|
|
2971
3007
|
|
|
2972
|
-
|
|
3008
|
+
}
|
|
3009
|
+
|
|
3010
|
+
nodeData.cache = node;
|
|
3011
|
+
|
|
3012
|
+
}
|
|
3013
|
+
|
|
3014
|
+
return node;
|
|
2973
3015
|
|
|
2974
3016
|
}
|
|
2975
3017
|
|
|
@@ -155,9 +155,13 @@ class NodeFrame {
|
|
|
155
155
|
|
|
156
156
|
if ( nodeUpdateBeforeMap.frameId !== this.frameId ) {
|
|
157
157
|
|
|
158
|
-
|
|
158
|
+
const previousFrameId = nodeUpdateBeforeMap.frameId;
|
|
159
159
|
|
|
160
|
-
|
|
160
|
+
nodeUpdateBeforeMap.frameId = this.frameId;
|
|
161
|
+
|
|
162
|
+
if ( node.updateBefore( this ) === false ) {
|
|
163
|
+
|
|
164
|
+
nodeUpdateBeforeMap.frameId = previousFrameId;
|
|
161
165
|
|
|
162
166
|
}
|
|
163
167
|
|
|
@@ -169,9 +173,13 @@ class NodeFrame {
|
|
|
169
173
|
|
|
170
174
|
if ( nodeUpdateBeforeMap.renderId !== this.renderId ) {
|
|
171
175
|
|
|
172
|
-
|
|
176
|
+
const previousRenderId = nodeUpdateBeforeMap.renderId;
|
|
177
|
+
|
|
178
|
+
nodeUpdateBeforeMap.renderId = this.renderId;
|
|
179
|
+
|
|
180
|
+
if ( node.updateBefore( this ) === false ) {
|
|
173
181
|
|
|
174
|
-
nodeUpdateBeforeMap.renderId =
|
|
182
|
+
nodeUpdateBeforeMap.renderId = previousRenderId;
|
|
175
183
|
|
|
176
184
|
}
|
|
177
185
|
|
|
@@ -181,22 +181,22 @@ export function getMemoryLengthFromType( type ) {
|
|
|
181
181
|
}
|
|
182
182
|
|
|
183
183
|
/**
|
|
184
|
-
* Returns the
|
|
184
|
+
* Returns the alignment requirement for the given data type.
|
|
185
185
|
*
|
|
186
186
|
* @private
|
|
187
187
|
* @method
|
|
188
188
|
* @param {string} type - The data type.
|
|
189
|
-
* @return {number} The
|
|
189
|
+
* @return {number} The alignment requirement in bytes.
|
|
190
190
|
*/
|
|
191
|
-
export function
|
|
191
|
+
export function getAlignmentFromType( type ) {
|
|
192
192
|
|
|
193
193
|
if ( /float|int|uint/.test( type ) ) return 4;
|
|
194
194
|
if ( /vec2/.test( type ) ) return 8;
|
|
195
195
|
if ( /vec3/.test( type ) ) return 16;
|
|
196
196
|
if ( /vec4/.test( type ) ) return 16;
|
|
197
197
|
if ( /mat2/.test( type ) ) return 8;
|
|
198
|
-
if ( /mat3/.test( type ) ) return
|
|
199
|
-
if ( /mat4/.test( type ) ) return
|
|
198
|
+
if ( /mat3/.test( type ) ) return 16;
|
|
199
|
+
if ( /mat4/.test( type ) ) return 16;
|
|
200
200
|
|
|
201
201
|
error( 'TSL: Unsupported type:', type );
|
|
202
202
|
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { nodeObject } from '../tsl/TSLBase.js';
|
|
2
1
|
import { error } from '../../utils.js';
|
|
3
2
|
import PropertyNode from './PropertyNode.js';
|
|
4
3
|
|
|
@@ -91,4 +90,4 @@ export default ParameterNode;
|
|
|
91
90
|
* @param {?string} name - The name of the parameter in the shader.
|
|
92
91
|
* @returns {ParameterNode}
|
|
93
92
|
*/
|
|
94
|
-
export const parameter = ( type, name ) =>
|
|
93
|
+
export const parameter = ( type, name ) => new ParameterNode( type, name );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Node from './Node.js';
|
|
2
|
-
import { nodeImmutable
|
|
2
|
+
import { nodeImmutable } from '../tsl/TSLCore.js';
|
|
3
3
|
import { hashString } from './NodeUtils.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -113,7 +113,7 @@ export default PropertyNode;
|
|
|
113
113
|
* @param {?string} [name=null] - The name of the property in the shader.
|
|
114
114
|
* @returns {PropertyNode}
|
|
115
115
|
*/
|
|
116
|
-
export const property = ( type, name ) =>
|
|
116
|
+
export const property = ( type, name ) => new PropertyNode( type, name );
|
|
117
117
|
|
|
118
118
|
/**
|
|
119
119
|
* TSL function for creating a varying property node.
|
|
@@ -124,7 +124,7 @@ export const property = ( type, name ) => nodeObject( new PropertyNode( type, na
|
|
|
124
124
|
* @param {?string} [name=null] - The name of the varying in the shader.
|
|
125
125
|
* @returns {PropertyNode}
|
|
126
126
|
*/
|
|
127
|
-
export const varyingProperty = ( type, name ) =>
|
|
127
|
+
export const varyingProperty = ( type, name ) => new PropertyNode( type, name, true );
|
|
128
128
|
|
|
129
129
|
/**
|
|
130
130
|
* TSL object that represents the shader variable `DiffuseColor`.
|
|
@@ -134,6 +134,14 @@ export const varyingProperty = ( type, name ) => nodeObject( new PropertyNode( t
|
|
|
134
134
|
*/
|
|
135
135
|
export const diffuseColor = /*@__PURE__*/ nodeImmutable( PropertyNode, 'vec4', 'DiffuseColor' );
|
|
136
136
|
|
|
137
|
+
/**
|
|
138
|
+
* TSL object that represents the shader variable `DiffuseContribution`.
|
|
139
|
+
*
|
|
140
|
+
* @tsl
|
|
141
|
+
* @type {PropertyNode<vec3>}
|
|
142
|
+
*/
|
|
143
|
+
export const diffuseContribution = /*@__PURE__*/ nodeImmutable( PropertyNode, 'vec3', 'DiffuseContribution' );
|
|
144
|
+
|
|
137
145
|
/**
|
|
138
146
|
* TSL object that represents the shader variable `EmissiveColor`.
|
|
139
147
|
*
|
|
@@ -254,6 +262,14 @@ export const anisotropyB = /*@__PURE__*/ nodeImmutable( PropertyNode, 'vec3', 'A
|
|
|
254
262
|
*/
|
|
255
263
|
export const specularColor = /*@__PURE__*/ nodeImmutable( PropertyNode, 'color', 'SpecularColor' );
|
|
256
264
|
|
|
265
|
+
/**
|
|
266
|
+
* TSL object that represents the shader variable `SpecularColorBlended`.
|
|
267
|
+
*
|
|
268
|
+
* @tsl
|
|
269
|
+
* @type {PropertyNode<color>}
|
|
270
|
+
*/
|
|
271
|
+
export const specularColorBlended = /*@__PURE__*/ nodeImmutable( PropertyNode, 'color', 'SpecularColorBlended' );
|
|
272
|
+
|
|
257
273
|
/**
|
|
258
274
|
* TSL object that represents the shader variable `SpecularF90`.
|
|
259
275
|
*
|