super-three 0.177.0 → 0.179.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 +1 -1
- package/build/three.cjs +959 -231
- package/build/three.core.js +751 -170
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +210 -64
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +78 -29
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +3269 -1545
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +3093 -1545
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +1 -2
- package/examples/jsm/capabilities/WebGL.js +0 -27
- package/examples/jsm/capabilities/WebGPU.js +1 -1
- package/examples/jsm/controls/ArcballControls.js +1 -1
- package/examples/jsm/controls/TransformControls.js +61 -14
- package/examples/jsm/csm/CSMShadowNode.js +4 -4
- package/examples/jsm/environments/RoomEnvironment.js +8 -3
- package/examples/jsm/exporters/USDZExporter.js +676 -299
- package/examples/jsm/geometries/RoundedBoxGeometry.js +47 -8
- package/examples/jsm/interactive/HTMLMesh.js +5 -3
- package/examples/jsm/libs/meshopt_decoder.module.js +75 -58
- package/examples/jsm/lights/LightProbeGenerator.js +14 -3
- package/examples/jsm/loaders/ColladaLoader.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +210 -22
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/MaterialXLoader.js +212 -30
- package/examples/jsm/loaders/TTFLoader.js +13 -1
- package/examples/jsm/loaders/USDLoader.js +219 -0
- package/examples/jsm/loaders/USDZLoader.js +4 -892
- package/examples/jsm/loaders/usd/USDAParser.js +741 -0
- package/examples/jsm/loaders/usd/USDCParser.js +17 -0
- package/examples/jsm/objects/LensflareMesh.js +3 -3
- package/examples/jsm/objects/SkyMesh.js +2 -2
- package/examples/jsm/physics/RapierPhysics.js +95 -16
- package/examples/jsm/postprocessing/GTAOPass.js +10 -9
- package/examples/jsm/postprocessing/OutlinePass.js +17 -17
- package/examples/jsm/postprocessing/SSAOPass.js +10 -9
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +11 -2
- package/examples/jsm/transpiler/AST.js +381 -30
- package/examples/jsm/transpiler/GLSLDecoder.js +226 -86
- package/examples/jsm/transpiler/Linker.js +327 -0
- package/examples/jsm/transpiler/TSLEncoder.js +197 -92
- package/examples/jsm/transpiler/Transpiler.js +17 -1
- package/examples/jsm/transpiler/TranspilerUtils.js +29 -0
- package/examples/jsm/transpiler/WGSLEncoder.js +788 -0
- package/examples/jsm/tsl/display/BloomNode.js +8 -7
- package/examples/jsm/tsl/display/ChromaticAberrationNode.js +206 -0
- package/examples/jsm/tsl/display/GaussianBlurNode.js +8 -10
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/{TRAAPassNode.js → TRAANode.js} +181 -172
- package/examples/jsm/tsl/display/hashBlur.js +3 -3
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +1 -1
- package/package.json +1 -1
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +77 -28
- package/src/Three.WebGPU.js +2 -0
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/cameras/Camera.js +14 -0
- package/src/cameras/OrthographicCamera.js +1 -1
- package/src/cameras/PerspectiveCamera.js +1 -1
- package/src/constants.js +3 -3
- package/src/core/BufferAttribute.js +3 -3
- package/src/core/Clock.js +2 -8
- package/src/core/GLBufferAttribute.js +13 -1
- package/src/core/Object3D.js +1 -1
- package/{examples/jsm/misc → src/core}/Timer.js +4 -42
- package/src/extras/PMREMGenerator.js +11 -0
- package/src/extras/core/Path.js +22 -22
- package/src/helpers/CameraHelper.js +41 -11
- package/src/helpers/SkeletonHelper.js +35 -6
- package/src/lights/LightShadow.js +21 -8
- package/src/lights/PointLightShadow.js +1 -1
- package/src/loaders/FileLoader.js +27 -4
- package/src/loaders/ImageBitmapLoader.js +27 -4
- package/src/loaders/ImageLoader.js +55 -8
- package/src/loaders/Loader.js +14 -0
- package/src/loaders/LoadingManager.js +23 -0
- package/src/materials/MeshBasicMaterial.js +1 -1
- package/src/materials/nodes/Line2NodeMaterial.js +0 -8
- package/src/materials/nodes/MeshBasicNodeMaterial.js +4 -3
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +1 -1
- package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -1
- package/src/materials/nodes/MeshSSSNodeMaterial.js +2 -2
- package/src/materials/nodes/NodeMaterial.js +28 -5
- package/src/materials/nodes/PointsNodeMaterial.js +5 -0
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -2
- package/src/math/Frustum.js +25 -9
- package/src/math/FrustumArray.js +10 -5
- package/src/math/Line3.js +129 -2
- package/src/math/Matrix4.js +48 -27
- package/src/math/Quaternion.js +1 -1
- package/src/math/Spherical.js +2 -2
- package/src/nodes/Nodes.js +2 -3
- package/src/nodes/TSL.js +5 -3
- package/src/nodes/accessors/AccessorsUtils.js +7 -8
- package/src/nodes/accessors/Bitangent.js +31 -25
- package/src/nodes/accessors/Camera.js +12 -12
- package/src/nodes/accessors/Normal.js +95 -29
- package/src/nodes/accessors/Object3DNode.js +1 -1
- package/src/nodes/accessors/Position.js +7 -7
- package/src/nodes/accessors/ReferenceNode.js +18 -3
- package/src/nodes/accessors/ReflectVector.js +3 -3
- package/src/nodes/accessors/SceneNode.js +1 -1
- package/src/nodes/accessors/StorageTextureNode.js +1 -1
- package/src/nodes/accessors/Tangent.js +25 -17
- package/src/nodes/accessors/TangentUtils.js +46 -0
- package/src/nodes/accessors/TextureBicubic.js +21 -3
- package/src/nodes/accessors/TextureNode.js +12 -0
- package/src/nodes/accessors/UniformArrayNode.js +0 -16
- package/src/nodes/core/ArrayNode.js +12 -0
- package/src/nodes/core/AssignNode.js +3 -0
- package/src/nodes/core/CacheNode.js +0 -14
- package/src/nodes/core/ContextNode.js +20 -1
- package/src/nodes/core/Node.js +15 -3
- package/src/nodes/core/NodeBuilder.js +228 -92
- package/src/nodes/core/NodeUtils.js +4 -1
- package/src/nodes/core/StackNode.js +49 -29
- package/src/nodes/core/SubBuildNode.js +89 -0
- package/src/nodes/core/UniformNode.js +63 -5
- package/src/nodes/core/VarNode.js +91 -2
- package/src/nodes/core/VaryingNode.js +6 -4
- package/src/nodes/display/BlendModes.js +2 -2
- package/src/nodes/display/FrontFacingNode.js +34 -2
- package/src/nodes/display/NormalMapNode.js +19 -50
- package/src/nodes/display/PassNode.js +157 -9
- package/src/nodes/display/ScreenNode.js +0 -26
- package/src/nodes/display/ViewportTextureNode.js +67 -7
- package/src/nodes/functions/BSDF/BRDF_GGX.js +2 -6
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +4 -4
- package/src/nodes/functions/PhongLightingModel.js +3 -3
- package/src/nodes/functions/PhysicalLightingModel.js +16 -16
- package/src/nodes/functions/material/getGeometryRoughness.js +2 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +1 -1
- package/src/nodes/gpgpu/ComputeNode.js +67 -23
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +28 -3
- package/src/nodes/lighting/EnvironmentNode.js +5 -5
- package/src/nodes/lighting/LightsNode.js +4 -4
- package/src/nodes/lighting/ProjectorLightNode.js +19 -6
- package/src/nodes/lighting/ShadowFilterNode.js +1 -1
- package/src/nodes/lighting/ShadowNode.js +2 -2
- package/src/nodes/materialx/MaterialXNodes.js +131 -2
- package/src/nodes/materialx/lib/mx_noise.js +165 -1
- package/src/nodes/math/ConditionalNode.js +1 -20
- package/src/nodes/math/MathNode.js +90 -55
- package/src/nodes/math/OperatorNode.js +22 -39
- package/src/nodes/tsl/TSLBase.js +1 -0
- package/src/nodes/tsl/TSLCore.js +114 -55
- package/src/nodes/utils/DebugNode.js +1 -1
- package/src/nodes/utils/EquirectUV.js +27 -0
- package/src/nodes/utils/EventNode.js +83 -0
- package/src/nodes/utils/LoopNode.js +0 -17
- package/src/nodes/utils/MatcapUV.js +22 -0
- package/src/nodes/utils/RTTNode.js +22 -5
- package/src/nodes/utils/ReflectorNode.js +11 -4
- package/src/nodes/utils/SampleNode.js +81 -0
- package/src/nodes/utils/TriplanarTextures.js +65 -0
- package/src/objects/BatchedMesh.js +4 -2
- package/src/renderers/WebGLRenderer.js +26 -24
- package/src/renderers/common/Background.js +2 -2
- package/src/renderers/common/Bindings.js +19 -18
- package/src/renderers/common/Color4.js +2 -2
- package/src/renderers/common/CubeRenderTarget.js +1 -1
- package/src/renderers/common/PostProcessing.js +60 -5
- package/src/renderers/common/RenderObject.js +68 -3
- package/src/renderers/common/Renderer.js +19 -16
- package/src/renderers/common/SampledTexture.js +3 -71
- package/src/renderers/common/Sampler.js +79 -0
- package/src/renderers/common/Storage3DTexture.js +100 -0
- package/src/renderers/common/StorageArrayTexture.js +84 -0
- package/src/renderers/common/StorageTexture.js +19 -0
- package/src/renderers/common/Textures.js +19 -3
- package/src/renderers/common/XRManager.js +31 -12
- package/src/renderers/common/XRRenderTarget.js +21 -4
- package/src/renderers/common/extras/PMREMGenerator.js +1 -1
- package/src/renderers/common/nodes/NodeSampledTexture.js +0 -12
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +20 -2
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +11 -2
- package/src/renderers/webgl/WebGLAttributes.js +4 -0
- package/src/renderers/webgl/WebGLCapabilities.js +2 -2
- package/src/renderers/webgl/WebGLProgram.js +12 -6
- package/src/renderers/webgl/WebGLPrograms.js +6 -4
- package/src/renderers/webgl/WebGLShadowMap.js +11 -1
- package/src/renderers/webgl/WebGLState.js +4 -4
- package/src/renderers/webgl/WebGLTextures.js +19 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +103 -72
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +3 -5
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +4 -0
- package/src/renderers/webgl-fallback/utils/WebGLState.js +4 -4
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +2 -0
- package/src/renderers/webgpu/WebGPUBackend.js +63 -16
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +64 -79
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +6 -0
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -31
- package/src/renderers/webgpu/utils/WebGPUConstants.js +7 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +5 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +12 -65
- package/src/renderers/webgpu/utils/WebGPUUtils.js +2 -17
- package/src/renderers/webxr/WebXRDepthSensing.js +6 -10
- package/src/renderers/webxr/WebXRManager.js +68 -6
- package/src/textures/ExternalTexture.js +45 -0
- package/src/textures/FramebufferTexture.js +2 -2
- package/src/textures/Source.js +11 -1
- package/src/textures/VideoTexture.js +30 -2
- package/src/nodes/utils/EquirectUVNode.js +0 -65
- package/src/nodes/utils/MatcapUVNode.js +0 -49
- package/src/nodes/utils/TriplanarTexturesNode.js +0 -148
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { WebGLCoordinateSystem } from '../../constants.js';
|
|
2
2
|
import TempNode from '../core/TempNode.js';
|
|
3
|
-
import { addMethodChaining, Fn, int,
|
|
3
|
+
import { addMethodChaining, Fn, int, nodeProxyIntent } from '../tsl/TSLCore.js';
|
|
4
4
|
|
|
5
5
|
const _vectorOperators = {
|
|
6
6
|
'==': 'equal',
|
|
@@ -419,7 +419,7 @@ export default OperatorNode;
|
|
|
419
419
|
* @param {...Node} params - Additional input parameters.
|
|
420
420
|
* @returns {OperatorNode}
|
|
421
421
|
*/
|
|
422
|
-
export const add = /*@__PURE__*/
|
|
422
|
+
export const add = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '+' ).setParameterLength( 2, Infinity ).setName( 'add' );
|
|
423
423
|
|
|
424
424
|
/**
|
|
425
425
|
* Returns the subtraction of two or more value.
|
|
@@ -431,7 +431,7 @@ export const add = /*@__PURE__*/ nodeProxy( OperatorNode, '+' ).setParameterLeng
|
|
|
431
431
|
* @param {...Node} params - Additional input parameters.
|
|
432
432
|
* @returns {OperatorNode}
|
|
433
433
|
*/
|
|
434
|
-
export const sub = /*@__PURE__*/
|
|
434
|
+
export const sub = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '-' ).setParameterLength( 2, Infinity ).setName( 'sub' );
|
|
435
435
|
|
|
436
436
|
/**
|
|
437
437
|
* Returns the multiplication of two or more value.
|
|
@@ -443,7 +443,7 @@ export const sub = /*@__PURE__*/ nodeProxy( OperatorNode, '-' ).setParameterLeng
|
|
|
443
443
|
* @param {...Node} params - Additional input parameters.
|
|
444
444
|
* @returns {OperatorNode}
|
|
445
445
|
*/
|
|
446
|
-
export const mul = /*@__PURE__*/
|
|
446
|
+
export const mul = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '*' ).setParameterLength( 2, Infinity ).setName( 'mul' );
|
|
447
447
|
|
|
448
448
|
/**
|
|
449
449
|
* Returns the division of two or more value.
|
|
@@ -455,7 +455,7 @@ export const mul = /*@__PURE__*/ nodeProxy( OperatorNode, '*' ).setParameterLeng
|
|
|
455
455
|
* @param {...Node} params - Additional input parameters.
|
|
456
456
|
* @returns {OperatorNode}
|
|
457
457
|
*/
|
|
458
|
-
export const div = /*@__PURE__*/
|
|
458
|
+
export const div = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '/' ).setParameterLength( 2, Infinity ).setName( 'div' );
|
|
459
459
|
|
|
460
460
|
/**
|
|
461
461
|
* Computes the remainder of dividing the first node by the second one.
|
|
@@ -466,7 +466,7 @@ export const div = /*@__PURE__*/ nodeProxy( OperatorNode, '/' ).setParameterLeng
|
|
|
466
466
|
* @param {Node} b - The second input.
|
|
467
467
|
* @returns {OperatorNode}
|
|
468
468
|
*/
|
|
469
|
-
export const mod = /*@__PURE__*/
|
|
469
|
+
export const mod = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '%' ).setParameterLength( 2 ).setName( 'mod' );
|
|
470
470
|
|
|
471
471
|
/**
|
|
472
472
|
* Checks if two nodes are equal.
|
|
@@ -477,7 +477,7 @@ export const mod = /*@__PURE__*/ nodeProxy( OperatorNode, '%' ).setParameterLeng
|
|
|
477
477
|
* @param {Node} b - The second input.
|
|
478
478
|
* @returns {OperatorNode}
|
|
479
479
|
*/
|
|
480
|
-
export const equal = /*@__PURE__*/
|
|
480
|
+
export const equal = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '==' ).setParameterLength( 2 ).setName( 'equal' );
|
|
481
481
|
|
|
482
482
|
/**
|
|
483
483
|
* Checks if two nodes are not equal.
|
|
@@ -488,7 +488,7 @@ export const equal = /*@__PURE__*/ nodeProxy( OperatorNode, '==' ).setParameterL
|
|
|
488
488
|
* @param {Node} b - The second input.
|
|
489
489
|
* @returns {OperatorNode}
|
|
490
490
|
*/
|
|
491
|
-
export const notEqual = /*@__PURE__*/
|
|
491
|
+
export const notEqual = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '!=' ).setParameterLength( 2 ).setName( 'notEqual' );
|
|
492
492
|
|
|
493
493
|
/**
|
|
494
494
|
* Checks if the first node is less than the second.
|
|
@@ -499,7 +499,7 @@ export const notEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '!=' ).setParamet
|
|
|
499
499
|
* @param {Node} b - The second input.
|
|
500
500
|
* @returns {OperatorNode}
|
|
501
501
|
*/
|
|
502
|
-
export const lessThan = /*@__PURE__*/
|
|
502
|
+
export const lessThan = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '<' ).setParameterLength( 2 ).setName( 'lessThan' );
|
|
503
503
|
|
|
504
504
|
/**
|
|
505
505
|
* Checks if the first node is greater than the second.
|
|
@@ -510,7 +510,7 @@ export const lessThan = /*@__PURE__*/ nodeProxy( OperatorNode, '<' ).setParamete
|
|
|
510
510
|
* @param {Node} b - The second input.
|
|
511
511
|
* @returns {OperatorNode}
|
|
512
512
|
*/
|
|
513
|
-
export const greaterThan = /*@__PURE__*/
|
|
513
|
+
export const greaterThan = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '>' ).setParameterLength( 2 ).setName( 'greaterThan' );
|
|
514
514
|
|
|
515
515
|
/**
|
|
516
516
|
* Checks if the first node is less than or equal to the second.
|
|
@@ -521,7 +521,7 @@ export const greaterThan = /*@__PURE__*/ nodeProxy( OperatorNode, '>' ).setParam
|
|
|
521
521
|
* @param {Node} b - The second input.
|
|
522
522
|
* @returns {OperatorNode}
|
|
523
523
|
*/
|
|
524
|
-
export const lessThanEqual = /*@__PURE__*/
|
|
524
|
+
export const lessThanEqual = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '<=' ).setParameterLength( 2 ).setName( 'lessThanEqual' );
|
|
525
525
|
|
|
526
526
|
/**
|
|
527
527
|
* Checks if the first node is greater than or equal to the second.
|
|
@@ -532,7 +532,7 @@ export const lessThanEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '<=' ).setPa
|
|
|
532
532
|
* @param {Node} b - The second input.
|
|
533
533
|
* @returns {OperatorNode}
|
|
534
534
|
*/
|
|
535
|
-
export const greaterThanEqual = /*@__PURE__*/
|
|
535
|
+
export const greaterThanEqual = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '>=' ).setParameterLength( 2 ).setName( 'greaterThanEqual' );
|
|
536
536
|
|
|
537
537
|
/**
|
|
538
538
|
* Performs a logical AND operation on multiple nodes.
|
|
@@ -542,7 +542,7 @@ export const greaterThanEqual = /*@__PURE__*/ nodeProxy( OperatorNode, '>=' ).se
|
|
|
542
542
|
* @param {...Node} nodes - The input nodes to be combined using AND.
|
|
543
543
|
* @returns {OperatorNode}
|
|
544
544
|
*/
|
|
545
|
-
export const and = /*@__PURE__*/
|
|
545
|
+
export const and = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '&&' ).setParameterLength( 2, Infinity ).setName( 'and' );
|
|
546
546
|
|
|
547
547
|
/**
|
|
548
548
|
* Performs a logical OR operation on multiple nodes.
|
|
@@ -552,7 +552,7 @@ export const and = /*@__PURE__*/ nodeProxy( OperatorNode, '&&' ).setParameterLen
|
|
|
552
552
|
* @param {...Node} nodes - The input nodes to be combined using OR.
|
|
553
553
|
* @returns {OperatorNode}
|
|
554
554
|
*/
|
|
555
|
-
export const or = /*@__PURE__*/
|
|
555
|
+
export const or = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '||' ).setParameterLength( 2, Infinity ).setName( 'or' );
|
|
556
556
|
|
|
557
557
|
/**
|
|
558
558
|
* Performs logical NOT on a node.
|
|
@@ -562,7 +562,7 @@ export const or = /*@__PURE__*/ nodeProxy( OperatorNode, '||' ).setParameterLeng
|
|
|
562
562
|
* @param {Node} value - The value.
|
|
563
563
|
* @returns {OperatorNode}
|
|
564
564
|
*/
|
|
565
|
-
export const not = /*@__PURE__*/
|
|
565
|
+
export const not = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '!' ).setParameterLength( 1 ).setName( 'not' );
|
|
566
566
|
|
|
567
567
|
/**
|
|
568
568
|
* Performs logical XOR on two nodes.
|
|
@@ -573,7 +573,7 @@ export const not = /*@__PURE__*/ nodeProxy( OperatorNode, '!' ).setParameterLeng
|
|
|
573
573
|
* @param {Node} b - The second input.
|
|
574
574
|
* @returns {OperatorNode}
|
|
575
575
|
*/
|
|
576
|
-
export const xor = /*@__PURE__*/
|
|
576
|
+
export const xor = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '^^' ).setParameterLength( 2 ).setName( 'xor' );
|
|
577
577
|
|
|
578
578
|
/**
|
|
579
579
|
* Performs bitwise AND on two nodes.
|
|
@@ -584,7 +584,7 @@ export const xor = /*@__PURE__*/ nodeProxy( OperatorNode, '^^' ).setParameterLen
|
|
|
584
584
|
* @param {Node} b - The second input.
|
|
585
585
|
* @returns {OperatorNode}
|
|
586
586
|
*/
|
|
587
|
-
export const bitAnd = /*@__PURE__*/
|
|
587
|
+
export const bitAnd = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '&' ).setParameterLength( 2 ).setName( 'bitAnd' );
|
|
588
588
|
|
|
589
589
|
/**
|
|
590
590
|
* Performs bitwise NOT on a node.
|
|
@@ -595,7 +595,7 @@ export const bitAnd = /*@__PURE__*/ nodeProxy( OperatorNode, '&' ).setParameterL
|
|
|
595
595
|
* @param {Node} b - The second input.
|
|
596
596
|
* @returns {OperatorNode}
|
|
597
597
|
*/
|
|
598
|
-
export const bitNot = /*@__PURE__*/
|
|
598
|
+
export const bitNot = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '~' ).setParameterLength( 2 ).setName( 'bitNot' );
|
|
599
599
|
|
|
600
600
|
/**
|
|
601
601
|
* Performs bitwise OR on two nodes.
|
|
@@ -606,7 +606,7 @@ export const bitNot = /*@__PURE__*/ nodeProxy( OperatorNode, '~' ).setParameterL
|
|
|
606
606
|
* @param {Node} b - The second input.
|
|
607
607
|
* @returns {OperatorNode}
|
|
608
608
|
*/
|
|
609
|
-
export const bitOr = /*@__PURE__*/
|
|
609
|
+
export const bitOr = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '|' ).setParameterLength( 2 ).setName( 'bitOr' );
|
|
610
610
|
|
|
611
611
|
/**
|
|
612
612
|
* Performs bitwise XOR on two nodes.
|
|
@@ -617,7 +617,7 @@ export const bitOr = /*@__PURE__*/ nodeProxy( OperatorNode, '|' ).setParameterLe
|
|
|
617
617
|
* @param {Node} b - The second input.
|
|
618
618
|
* @returns {OperatorNode}
|
|
619
619
|
*/
|
|
620
|
-
export const bitXor = /*@__PURE__*/
|
|
620
|
+
export const bitXor = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '^' ).setParameterLength( 2 ).setName( 'bitXor' );
|
|
621
621
|
|
|
622
622
|
/**
|
|
623
623
|
* Shifts a node to the left.
|
|
@@ -628,7 +628,7 @@ export const bitXor = /*@__PURE__*/ nodeProxy( OperatorNode, '^' ).setParameterL
|
|
|
628
628
|
* @param {Node} b - The value to shift.
|
|
629
629
|
* @returns {OperatorNode}
|
|
630
630
|
*/
|
|
631
|
-
export const shiftLeft = /*@__PURE__*/
|
|
631
|
+
export const shiftLeft = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '<<' ).setParameterLength( 2 ).setName( 'shiftLeft' );
|
|
632
632
|
|
|
633
633
|
/**
|
|
634
634
|
* Shifts a node to the right.
|
|
@@ -639,7 +639,7 @@ export const shiftLeft = /*@__PURE__*/ nodeProxy( OperatorNode, '<<' ).setParame
|
|
|
639
639
|
* @param {Node} b - The value to shift.
|
|
640
640
|
* @returns {OperatorNode}
|
|
641
641
|
*/
|
|
642
|
-
export const shiftRight = /*@__PURE__*/
|
|
642
|
+
export const shiftRight = /*@__PURE__*/ nodeProxyIntent( OperatorNode, '>>' ).setParameterLength( 2 ).setName( 'shiftRight' );
|
|
643
643
|
|
|
644
644
|
/**
|
|
645
645
|
* Increments a node by 1.
|
|
@@ -730,22 +730,6 @@ addMethodChaining( 'decrementBefore', decrementBefore );
|
|
|
730
730
|
addMethodChaining( 'increment', increment );
|
|
731
731
|
addMethodChaining( 'decrement', decrement );
|
|
732
732
|
|
|
733
|
-
/**
|
|
734
|
-
* @tsl
|
|
735
|
-
* @function
|
|
736
|
-
* @deprecated since r168. Use {@link mod} instead.
|
|
737
|
-
*
|
|
738
|
-
* @param {Node} a - The first input.
|
|
739
|
-
* @param {Node} b - The second input.
|
|
740
|
-
* @returns {OperatorNode}
|
|
741
|
-
*/
|
|
742
|
-
export const remainder = ( a, b ) => { // @deprecated, r168
|
|
743
|
-
|
|
744
|
-
console.warn( 'THREE.TSL: "remainder()" is deprecated. Use "mod( int( ... ) )" instead.' );
|
|
745
|
-
return mod( a, b );
|
|
746
|
-
|
|
747
|
-
};
|
|
748
|
-
|
|
749
733
|
/**
|
|
750
734
|
* @tsl
|
|
751
735
|
* @function
|
|
@@ -762,5 +746,4 @@ export const modInt = ( a, b ) => { // @deprecated, r175
|
|
|
762
746
|
|
|
763
747
|
};
|
|
764
748
|
|
|
765
|
-
addMethodChaining( 'remainder', remainder );
|
|
766
749
|
addMethodChaining( 'modInt', modInt );
|
package/src/nodes/tsl/TSLBase.js
CHANGED
|
@@ -24,6 +24,7 @@ export * from '../code/ExpressionNode.js'; // expression()
|
|
|
24
24
|
export * from '../utils/Discard.js'; // Discard(), Return()
|
|
25
25
|
export * from '../display/RenderOutputNode.js'; // .renderOutput()
|
|
26
26
|
export * from '../utils/DebugNode.js'; // debug()
|
|
27
|
+
export * from '../core/SubBuildNode.js'; // subBuild()
|
|
27
28
|
|
|
28
29
|
export function addNodeElement( name/*, nodeElement*/ ) {
|
|
29
30
|
|
package/src/nodes/tsl/TSLCore.js
CHANGED
|
@@ -61,6 +61,10 @@ const shaderNodeHandler = {
|
|
|
61
61
|
|
|
62
62
|
return node.isStackNode ? ( ...params ) => nodeObj.add( nodeElement( ...params ) ) : ( ...params ) => nodeElement( nodeObj, ...params );
|
|
63
63
|
|
|
64
|
+
} else if ( prop === 'toVarIntent' ) {
|
|
65
|
+
|
|
66
|
+
return () => nodeObj;
|
|
67
|
+
|
|
64
68
|
} else if ( prop === 'self' ) {
|
|
65
69
|
|
|
66
70
|
return node;
|
|
@@ -175,7 +179,7 @@ const ShaderNodeObject = function ( obj, altType = null ) {
|
|
|
175
179
|
|
|
176
180
|
} else if ( type === 'shader' ) {
|
|
177
181
|
|
|
178
|
-
return Fn( obj );
|
|
182
|
+
return obj.isFn ? obj : Fn( obj );
|
|
179
183
|
|
|
180
184
|
}
|
|
181
185
|
|
|
@@ -211,7 +215,28 @@ const ShaderNodeArray = function ( array, altType = null ) {
|
|
|
211
215
|
|
|
212
216
|
const ShaderNodeProxy = function ( NodeClass, scope = null, factor = null, settings = null ) {
|
|
213
217
|
|
|
214
|
-
|
|
218
|
+
function assignNode( node ) {
|
|
219
|
+
|
|
220
|
+
if ( settings !== null ) {
|
|
221
|
+
|
|
222
|
+
node = nodeObject( Object.assign( node, settings ) );
|
|
223
|
+
|
|
224
|
+
if ( settings.intent === true ) {
|
|
225
|
+
|
|
226
|
+
node = node.toVarIntent();
|
|
227
|
+
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
} else {
|
|
231
|
+
|
|
232
|
+
node = nodeObject( node );
|
|
233
|
+
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return node;
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
}
|
|
215
240
|
|
|
216
241
|
let fn, name = scope, minParams, maxParams;
|
|
217
242
|
|
|
@@ -325,16 +350,22 @@ class ShaderCallNodeInternal extends Node {
|
|
|
325
350
|
const { shaderNode, inputNodes } = this;
|
|
326
351
|
|
|
327
352
|
const properties = builder.getNodeProperties( shaderNode );
|
|
328
|
-
const onceNS = shaderNode.namespace && shaderNode.namespace === builder.namespace ? builder.getNamespace( 'once' ) : 'once';
|
|
329
353
|
|
|
330
|
-
|
|
354
|
+
const subBuild = builder.getClosestSubBuild( shaderNode.subBuilds ) || '';
|
|
355
|
+
const subBuildProperty = subBuild || 'default';
|
|
356
|
+
|
|
357
|
+
if ( properties[ subBuildProperty ] ) {
|
|
331
358
|
|
|
332
|
-
return properties[
|
|
359
|
+
return properties[ subBuildProperty ];
|
|
333
360
|
|
|
334
361
|
}
|
|
335
362
|
|
|
336
363
|
//
|
|
337
364
|
|
|
365
|
+
const previousSubBuildFn = builder.subBuildFn;
|
|
366
|
+
|
|
367
|
+
builder.subBuildFn = subBuild;
|
|
368
|
+
|
|
338
369
|
let result = null;
|
|
339
370
|
|
|
340
371
|
if ( shaderNode.layout ) {
|
|
@@ -365,16 +396,46 @@ class ShaderCallNodeInternal extends Node {
|
|
|
365
396
|
|
|
366
397
|
} else {
|
|
367
398
|
|
|
399
|
+
let inputs = inputNodes;
|
|
400
|
+
|
|
401
|
+
if ( Array.isArray( inputs ) ) {
|
|
402
|
+
|
|
403
|
+
// If inputs is an array, we need to convert it to a Proxy
|
|
404
|
+
// so we can call TSL functions using the syntax `Fn( ( { r, g, b } ) => { ... } )`
|
|
405
|
+
// and call through `fn( 0, 1, 0 )` or `fn( { r: 0, g: 1, b: 0 } )`
|
|
406
|
+
|
|
407
|
+
let index = 0;
|
|
408
|
+
|
|
409
|
+
inputs = new Proxy( inputs, {
|
|
410
|
+
get: ( target, property, receiver ) => {
|
|
411
|
+
|
|
412
|
+
if ( target[ property ] === undefined ) {
|
|
413
|
+
|
|
414
|
+
return target[ index ++ ];
|
|
415
|
+
|
|
416
|
+
} else {
|
|
417
|
+
|
|
418
|
+
return Reflect.get( target, property, receiver );
|
|
419
|
+
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
}
|
|
423
|
+
} );
|
|
424
|
+
|
|
425
|
+
}
|
|
426
|
+
|
|
368
427
|
const jsFunc = shaderNode.jsFunc;
|
|
369
|
-
const outputNode =
|
|
428
|
+
const outputNode = inputs !== null || jsFunc.length > 1 ? jsFunc( inputs || [], builder ) : jsFunc( builder );
|
|
370
429
|
|
|
371
430
|
result = nodeObject( outputNode );
|
|
372
431
|
|
|
373
432
|
}
|
|
374
433
|
|
|
434
|
+
builder.subBuildFn = previousSubBuildFn;
|
|
435
|
+
|
|
375
436
|
if ( shaderNode.once ) {
|
|
376
437
|
|
|
377
|
-
properties[
|
|
438
|
+
properties[ subBuildProperty ] = result;
|
|
378
439
|
|
|
379
440
|
}
|
|
380
441
|
|
|
@@ -395,11 +456,12 @@ class ShaderCallNodeInternal extends Node {
|
|
|
395
456
|
getOutputNode( builder ) {
|
|
396
457
|
|
|
397
458
|
const properties = builder.getNodeProperties( this );
|
|
398
|
-
const
|
|
459
|
+
const subBuildOutput = builder.getSubBuildOutput( this );
|
|
399
460
|
|
|
400
|
-
properties[
|
|
461
|
+
properties[ subBuildOutput ] = properties[ subBuildOutput ] || this.setupOutput( builder );
|
|
462
|
+
properties[ subBuildOutput ].subBuild = builder.getClosestSubBuild( this );
|
|
401
463
|
|
|
402
|
-
return properties[
|
|
464
|
+
return properties[ subBuildOutput ];
|
|
403
465
|
|
|
404
466
|
}
|
|
405
467
|
|
|
@@ -410,23 +472,45 @@ class ShaderCallNodeInternal extends Node {
|
|
|
410
472
|
const buildStage = builder.getBuildStage();
|
|
411
473
|
const properties = builder.getNodeProperties( this );
|
|
412
474
|
|
|
413
|
-
const
|
|
475
|
+
const subBuildOutput = builder.getSubBuildOutput( this );
|
|
414
476
|
const outputNode = this.getOutputNode( builder );
|
|
415
477
|
|
|
416
478
|
if ( buildStage === 'setup' ) {
|
|
417
479
|
|
|
418
|
-
const
|
|
480
|
+
const subBuildInitialized = builder.getSubBuildProperty( 'initialized', this );
|
|
481
|
+
|
|
482
|
+
if ( properties[ subBuildInitialized ] !== true ) {
|
|
483
|
+
|
|
484
|
+
properties[ subBuildInitialized ] = true;
|
|
485
|
+
|
|
486
|
+
properties[ subBuildOutput ] = this.getOutputNode( builder );
|
|
487
|
+
properties[ subBuildOutput ].build( builder );
|
|
488
|
+
|
|
489
|
+
// If the shaderNode has subBuilds, add them to the chaining nodes
|
|
490
|
+
// so they can be built later in the build process.
|
|
491
|
+
|
|
492
|
+
if ( this.shaderNode.subBuilds ) {
|
|
419
493
|
|
|
420
|
-
|
|
494
|
+
for ( const node of builder.chaining ) {
|
|
421
495
|
|
|
422
|
-
|
|
496
|
+
const nodeData = builder.getDataFromNode( node, 'any' );
|
|
497
|
+
nodeData.subBuilds = nodeData.subBuilds || new Set();
|
|
423
498
|
|
|
424
|
-
|
|
425
|
-
|
|
499
|
+
for ( const subBuild of this.shaderNode.subBuilds ) {
|
|
500
|
+
|
|
501
|
+
nodeData.subBuilds.add( subBuild );
|
|
502
|
+
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
//builder.getDataFromNode( node ).subBuilds = nodeData.subBuilds;
|
|
506
|
+
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
}
|
|
426
510
|
|
|
427
511
|
}
|
|
428
512
|
|
|
429
|
-
result = properties[
|
|
513
|
+
result = properties[ subBuildOutput ];
|
|
430
514
|
|
|
431
515
|
} else if ( buildStage === 'analyze' ) {
|
|
432
516
|
|
|
@@ -456,7 +540,6 @@ class ShaderNodeInternal extends Node {
|
|
|
456
540
|
this.global = true;
|
|
457
541
|
|
|
458
542
|
this.once = false;
|
|
459
|
-
this.namespace = null;
|
|
460
543
|
|
|
461
544
|
}
|
|
462
545
|
|
|
@@ -524,20 +607,6 @@ const getConstNode = ( value, type ) => {
|
|
|
524
607
|
|
|
525
608
|
};
|
|
526
609
|
|
|
527
|
-
const safeGetNodeType = ( node ) => {
|
|
528
|
-
|
|
529
|
-
try {
|
|
530
|
-
|
|
531
|
-
return node.getNodeType();
|
|
532
|
-
|
|
533
|
-
} catch ( _ ) {
|
|
534
|
-
|
|
535
|
-
return undefined;
|
|
536
|
-
|
|
537
|
-
}
|
|
538
|
-
|
|
539
|
-
};
|
|
540
|
-
|
|
541
610
|
const ConvertType = function ( type, cacheMap = null ) {
|
|
542
611
|
|
|
543
612
|
return ( ...params ) => {
|
|
@@ -550,20 +619,20 @@ const ConvertType = function ( type, cacheMap = null ) {
|
|
|
550
619
|
|
|
551
620
|
if ( params.length === 1 && cacheMap !== null && cacheMap.has( params[ 0 ] ) ) {
|
|
552
621
|
|
|
553
|
-
return
|
|
622
|
+
return nodeObjectIntent( cacheMap.get( params[ 0 ] ) );
|
|
554
623
|
|
|
555
624
|
}
|
|
556
625
|
|
|
557
626
|
if ( params.length === 1 ) {
|
|
558
627
|
|
|
559
628
|
const node = getConstNode( params[ 0 ], type );
|
|
560
|
-
if (
|
|
561
|
-
return
|
|
629
|
+
if ( node.nodeType === type ) return nodeObjectIntent( node );
|
|
630
|
+
return nodeObjectIntent( new ConvertNode( node, type ) );
|
|
562
631
|
|
|
563
632
|
}
|
|
564
633
|
|
|
565
634
|
const nodes = params.map( param => getConstNode( param ) );
|
|
566
|
-
return
|
|
635
|
+
return nodeObjectIntent( new JoinNode( nodes, type ) );
|
|
567
636
|
|
|
568
637
|
};
|
|
569
638
|
|
|
@@ -586,10 +655,12 @@ export function ShaderNode( jsFunc, nodeType ) {
|
|
|
586
655
|
}
|
|
587
656
|
|
|
588
657
|
export const nodeObject = ( val, altType = null ) => /* new */ ShaderNodeObject( val, altType );
|
|
658
|
+
export const nodeObjectIntent = ( val, altType = null ) => /* new */ nodeObject( val, altType ).toVarIntent();
|
|
589
659
|
export const nodeObjects = ( val, altType = null ) => new ShaderNodeObjects( val, altType );
|
|
590
660
|
export const nodeArray = ( val, altType = null ) => new ShaderNodeArray( val, altType );
|
|
591
|
-
export const nodeProxy = (
|
|
592
|
-
export const nodeImmutable = ( ...params ) => new ShaderNodeImmutable( ...params );
|
|
661
|
+
export const nodeProxy = ( NodeClass, scope = null, factor = null, settings = null ) => new ShaderNodeProxy( NodeClass, scope, factor, settings );
|
|
662
|
+
export const nodeImmutable = ( NodeClass, ...params ) => new ShaderNodeImmutable( NodeClass, ...params );
|
|
663
|
+
export const nodeProxyIntent = ( NodeClass, scope = null, factor = null, settings = {} ) => new ShaderNodeProxy( NodeClass, scope, factor, { intent: true, ...settings } );
|
|
593
664
|
|
|
594
665
|
let fnId = 0;
|
|
595
666
|
|
|
@@ -645,13 +716,15 @@ export const Fn = ( jsFunc, layout = null ) => {
|
|
|
645
716
|
|
|
646
717
|
if ( nodeType === 'void' ) fnCall.toStack();
|
|
647
718
|
|
|
648
|
-
return fnCall;
|
|
719
|
+
return fnCall.toVarIntent();
|
|
649
720
|
|
|
650
721
|
};
|
|
651
722
|
|
|
652
723
|
fn.shaderNode = shaderNode;
|
|
653
724
|
fn.id = shaderNode.id;
|
|
654
725
|
|
|
726
|
+
fn.isFn = true;
|
|
727
|
+
|
|
655
728
|
fn.getNodeType = ( ...params ) => shaderNode.getNodeType( ...params );
|
|
656
729
|
fn.getCacheKey = ( ...params ) => shaderNode.getCacheKey( ...params );
|
|
657
730
|
|
|
@@ -663,10 +736,10 @@ export const Fn = ( jsFunc, layout = null ) => {
|
|
|
663
736
|
|
|
664
737
|
};
|
|
665
738
|
|
|
666
|
-
fn.once = (
|
|
739
|
+
fn.once = ( subBuilds = null ) => {
|
|
667
740
|
|
|
668
741
|
shaderNode.once = true;
|
|
669
|
-
shaderNode.
|
|
742
|
+
shaderNode.subBuilds = subBuilds;
|
|
670
743
|
|
|
671
744
|
return fn;
|
|
672
745
|
|
|
@@ -853,17 +926,3 @@ addMethodChaining( 'append', ( node ) => { // @deprecated, r176
|
|
|
853
926
|
|
|
854
927
|
} );
|
|
855
928
|
|
|
856
|
-
/**
|
|
857
|
-
* @tsl
|
|
858
|
-
* @function
|
|
859
|
-
* @deprecated since r168. Use {@link Fn} instead.
|
|
860
|
-
*
|
|
861
|
-
* @param {...any} params
|
|
862
|
-
* @returns {Function}
|
|
863
|
-
*/
|
|
864
|
-
export const tslFn = ( ...params ) => { // @deprecated, r168
|
|
865
|
-
|
|
866
|
-
console.warn( 'THREE.TSL: tslFn() has been renamed to Fn().' );
|
|
867
|
-
return Fn( ...params );
|
|
868
|
-
|
|
869
|
-
};
|
|
@@ -77,6 +77,6 @@ export default DebugNode;
|
|
|
77
77
|
* @param {?Function} [callback=null] - Optional callback function to handle the debug output.
|
|
78
78
|
* @returns {DebugNode}
|
|
79
79
|
*/
|
|
80
|
-
export const debug = ( node, callback = null ) => nodeObject( new DebugNode( nodeObject( node ), callback ) );
|
|
80
|
+
export const debug = ( node, callback = null ) => nodeObject( new DebugNode( nodeObject( node ), callback ) ).toStack();
|
|
81
81
|
|
|
82
82
|
addMethodChaining( 'debug', debug );
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { positionWorldDirection } from '../accessors/Position.js';
|
|
2
|
+
import { Fn, vec2 } from '../tsl/TSLBase.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* TSL function for creating an equirect uv node.
|
|
6
|
+
*
|
|
7
|
+
* Can be used to compute texture coordinates for projecting an
|
|
8
|
+
* equirectangular texture onto a mesh for using it as the scene's
|
|
9
|
+
* background.
|
|
10
|
+
*
|
|
11
|
+
* ```js
|
|
12
|
+
* scene.backgroundNode = texture( equirectTexture, equirectUV() );
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @tsl
|
|
16
|
+
* @function
|
|
17
|
+
* @param {?Node<vec3>} [dirNode=positionWorldDirection] - A direction vector for sampling which is by default `positionWorldDirection`.
|
|
18
|
+
* @returns {Node<vec2>}
|
|
19
|
+
*/
|
|
20
|
+
export const equirectUV = /*@__PURE__*/ Fn( ( [ dir = positionWorldDirection ] ) => {
|
|
21
|
+
|
|
22
|
+
const u = dir.z.atan( dir.x ).mul( 1 / ( Math.PI * 2 ) ).add( 0.5 );
|
|
23
|
+
const v = dir.y.clamp( - 1.0, 1.0 ).asin().mul( 1 / Math.PI ).add( 0.5 );
|
|
24
|
+
|
|
25
|
+
return vec2( u, v );
|
|
26
|
+
|
|
27
|
+
} );
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import Node from '../core/Node.js';
|
|
2
|
+
import { NodeUpdateType } from '../core/constants.js';
|
|
3
|
+
import { nodeObject } from '../tsl/TSLCore.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* EventNode is a node that executes a callback during specific update phases.
|
|
7
|
+
*
|
|
8
|
+
* @augments Node
|
|
9
|
+
*/
|
|
10
|
+
class EventNode extends Node {
|
|
11
|
+
|
|
12
|
+
static get type() {
|
|
13
|
+
|
|
14
|
+
return 'EventNode';
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Creates an EventNode.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} eventType - The type of event
|
|
22
|
+
* @param {Function} callback - The callback to execute on update.
|
|
23
|
+
*/
|
|
24
|
+
constructor( eventType, callback ) {
|
|
25
|
+
|
|
26
|
+
super( 'void' );
|
|
27
|
+
|
|
28
|
+
this.eventType = eventType;
|
|
29
|
+
this.callback = callback;
|
|
30
|
+
|
|
31
|
+
if ( eventType === EventNode.OBJECT ) {
|
|
32
|
+
|
|
33
|
+
this.updateType = NodeUpdateType.OBJECT;
|
|
34
|
+
|
|
35
|
+
} else if ( eventType === EventNode.MATERIAL ) {
|
|
36
|
+
|
|
37
|
+
this.updateType = NodeUpdateType.RENDER;
|
|
38
|
+
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
update( frame ) {
|
|
44
|
+
|
|
45
|
+
this.callback( frame );
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
EventNode.OBJECT = 'object';
|
|
52
|
+
EventNode.MATERIAL = 'material';
|
|
53
|
+
|
|
54
|
+
export default EventNode;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Helper to create an EventNode and add it to the stack.
|
|
58
|
+
*
|
|
59
|
+
* @param {string} type - The event type.
|
|
60
|
+
* @param {Function} callback - The callback function.
|
|
61
|
+
* @returns {EventNode}
|
|
62
|
+
*/
|
|
63
|
+
const createEvent = ( type, callback ) => nodeObject( new EventNode( type, callback ) ).toStack();
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Creates an event that triggers a function every time an object (Mesh|Sprite) is rendered.
|
|
67
|
+
*
|
|
68
|
+
* The event will be bound to the declared TSL function `Fn()`; it must be declared within a `Fn()` or the JS function call must be inherited from one.
|
|
69
|
+
*
|
|
70
|
+
* @param {Function} callback - The callback function.
|
|
71
|
+
* @returns {EventNode}
|
|
72
|
+
*/
|
|
73
|
+
export const OnObjectUpdate = ( callback ) => createEvent( EventNode.OBJECT, callback );
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Creates an event that triggers a function when the first object that uses the material is rendered.
|
|
77
|
+
*
|
|
78
|
+
* The event will be bound to the declared TSL function `Fn()`; it must be declared within a `Fn()` or the JS function call must be inherited from one.
|
|
79
|
+
*
|
|
80
|
+
* @param {Function} callback - The callback function.
|
|
81
|
+
* @returns {EventNode}
|
|
82
|
+
*/
|
|
83
|
+
export const OnMaterialUpdate = ( callback ) => createEvent( EventNode.MATERIAL, callback );
|
|
@@ -351,20 +351,3 @@ export const Continue = () => expression( 'continue' ).toStack();
|
|
|
351
351
|
* @returns {ExpressionNode}
|
|
352
352
|
*/
|
|
353
353
|
export const Break = () => expression( 'break' ).toStack();
|
|
354
|
-
|
|
355
|
-
// Deprecated
|
|
356
|
-
|
|
357
|
-
/**
|
|
358
|
-
* @tsl
|
|
359
|
-
* @function
|
|
360
|
-
* @deprecated since r168. Use {@link Loop} instead.
|
|
361
|
-
*
|
|
362
|
-
* @param {...any} params
|
|
363
|
-
* @returns {LoopNode}
|
|
364
|
-
*/
|
|
365
|
-
export const loop = ( ...params ) => { // @deprecated, r168
|
|
366
|
-
|
|
367
|
-
console.warn( 'THREE.TSL: loop() has been renamed to Loop().' );
|
|
368
|
-
return Loop( ...params );
|
|
369
|
-
|
|
370
|
-
};
|