super-three 0.171.0 → 0.172.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 +157 -49
- package/build/three.core.js +104 -42
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +53 -8
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +10 -5
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +21191 -1008
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +21189 -1008
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +0 -5
- package/examples/jsm/animation/CCDIKSolver.js +3 -2
- package/examples/jsm/controls/ArcballControls.js +28 -19
- package/examples/jsm/controls/OrbitControls.js +5 -4
- package/examples/jsm/csm/CSMShadowNode.js +16 -11
- package/examples/jsm/curves/NURBSCurve.js +1 -1
- package/examples/jsm/curves/NURBSUtils.js +3 -0
- package/examples/jsm/effects/OutlineEffect.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +11 -7
- package/examples/jsm/exporters/KTX2Exporter.js +1 -1
- package/examples/jsm/exporters/PLYExporter.js +2 -2
- package/examples/jsm/helpers/TextureHelperGPU.js +15 -5
- package/examples/jsm/helpers/VertexNormalsHelper.js +2 -0
- package/examples/jsm/lights/LightProbeGenerator.js +3 -3
- package/examples/jsm/lines/webgpu/LineSegments2.js +15 -6
- package/examples/jsm/loaders/3MFLoader.js +6 -3
- package/examples/jsm/loaders/BVHLoader.js +1 -1
- package/examples/jsm/loaders/ColladaLoader.js +5 -5
- package/examples/jsm/loaders/DDSLoader.js +42 -0
- package/examples/jsm/loaders/GCodeLoader.js +1 -1
- package/examples/jsm/loaders/GLTFLoader.js +22 -2
- package/examples/jsm/loaders/KTX2Loader.js +6 -1
- package/examples/jsm/loaders/KTXLoader.js +4 -4
- package/examples/jsm/loaders/LDrawLoader.js +1 -1
- package/examples/jsm/loaders/LottieLoader.js +1 -1
- package/examples/jsm/loaders/MTLLoader.js +1 -0
- package/examples/jsm/loaders/NRRDLoader.js +1 -1
- package/examples/jsm/loaders/PLYLoader.js +7 -7
- package/examples/jsm/loaders/PVRLoader.js +1 -1
- package/examples/jsm/loaders/SVGLoader.js +2 -2
- package/examples/jsm/loaders/TDSLoader.js +1 -1
- package/examples/jsm/loaders/VRMLLoader.js +7 -7
- package/examples/jsm/loaders/lwo/IFFParser.js +4 -4
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +1 -1
- package/examples/jsm/math/ConvexHull.js +1 -1
- package/examples/jsm/math/OBB.js +17 -0
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +10 -10
- package/examples/jsm/misc/Volume.js +20 -12
- package/examples/jsm/misc/VolumeSlice.js +2 -2
- package/examples/jsm/modifiers/CurveModifier.js +10 -8
- package/examples/jsm/modifiers/CurveModifierGPU.js +9 -7
- package/examples/jsm/modifiers/SimplifyModifier.js +2 -2
- package/examples/jsm/objects/GroundedSkybox.js +4 -4
- package/examples/jsm/objects/Sky.js +2 -2
- package/examples/jsm/objects/SkyMesh.js +3 -3
- package/examples/jsm/objects/Water2.js +1 -1
- package/examples/jsm/objects/Water2Mesh.js +2 -2
- package/examples/jsm/objects/WaterMesh.js +4 -4
- package/examples/jsm/postprocessing/BloomPass.js +2 -2
- package/examples/jsm/postprocessing/EffectComposer.js +1 -2
- package/examples/jsm/postprocessing/OutlinePass.js +4 -4
- package/examples/jsm/postprocessing/SAOPass.js +1 -2
- package/examples/jsm/postprocessing/SMAAPass.js +1 -3
- package/examples/jsm/postprocessing/SSAOPass.js +2 -4
- package/examples/jsm/postprocessing/SSRPass.js +2 -4
- package/examples/jsm/postprocessing/UnrealBloomPass.js +2 -2
- package/examples/jsm/renderers/SVGRenderer.js +6 -4
- package/examples/jsm/shaders/BokehShader2.js +1 -1
- package/examples/jsm/shaders/GodRaysShader.js +3 -3
- package/examples/jsm/shaders/SobelOperatorShader.js +1 -1
- package/examples/jsm/tsl/display/AfterImageNode.js +93 -4
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +46 -2
- package/examples/jsm/tsl/display/AnamorphicNode.js +118 -5
- package/examples/jsm/tsl/display/BleachBypass.js +10 -0
- package/examples/jsm/tsl/display/BloomNode.js +233 -26
- package/examples/jsm/tsl/display/DenoiseNode.js +141 -25
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +80 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +50 -5
- package/examples/jsm/tsl/display/FXAANode.js +52 -3
- package/examples/jsm/tsl/display/FilmNode.js +47 -1
- package/examples/jsm/tsl/display/GTAONode.js +210 -14
- package/examples/jsm/tsl/display/GaussianBlurNode.js +152 -8
- package/examples/jsm/tsl/display/LensflareNode.js +131 -13
- package/examples/jsm/tsl/display/Lut3DNode.js +55 -1
- package/examples/jsm/tsl/display/MotionBlur.js +12 -2
- package/examples/jsm/tsl/display/OutlineNode.js +343 -26
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +36 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +142 -9
- package/examples/jsm/tsl/display/RGBShiftNode.js +49 -2
- package/examples/jsm/tsl/display/SMAANode.js +187 -46
- package/examples/jsm/tsl/display/SSAAPassNode.js +110 -25
- package/examples/jsm/tsl/display/SSRNode.js +194 -21
- package/examples/jsm/tsl/display/Sepia.js +9 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +54 -4
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +79 -3
- package/examples/jsm/tsl/display/StereoPassNode.js +41 -3
- package/examples/jsm/tsl/display/TRAAPassNode.js +116 -21
- package/examples/jsm/tsl/display/TransitionNode.js +71 -6
- package/examples/jsm/tsl/display/hashBlur.js +14 -3
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +40 -34
- package/examples/jsm/utils/BufferGeometryUtils.js +1 -1
- package/examples/jsm/utils/CameraUtils.js +4 -1
- package/examples/jsm/utils/GeometryUtils.js +22 -19
- package/examples/jsm/utils/SceneUtils.js +2 -2
- package/examples/jsm/webxr/XRControllerModelFactory.js +6 -1
- package/examples/jsm/webxr/XREstimatedLight.js +1 -1
- package/package.json +8 -3
- package/src/Three.Core.js +2 -0
- package/src/Three.Legacy.js +0 -21
- package/src/Three.TSL.js +9 -4
- package/src/Three.WebGPU.Nodes.js +2 -2
- package/src/Three.WebGPU.js +2 -2
- package/src/animation/PropertyBinding.js +2 -2
- package/src/cameras/PerspectiveCamera.js +18 -2
- package/src/constants.js +1 -1
- package/src/core/RenderTarget.js +18 -0
- package/src/core/RenderTarget3D.js +22 -0
- package/src/core/RenderTargetArray.js +22 -0
- package/src/extras/Earcut.js +1 -1
- package/src/extras/PMREMGenerator.js +20 -0
- package/src/extras/TextureUtils.js +6 -0
- package/src/helpers/CameraHelper.js +16 -13
- package/src/loaders/nodes/NodeLoader.js +59 -0
- package/src/loaders/nodes/NodeMaterialLoader.js +45 -0
- package/src/loaders/nodes/NodeObjectLoader.js +61 -0
- package/src/materials/nodes/InstancedPointsNodeMaterial.js +72 -19
- package/src/materials/nodes/Line2NodeMaterial.js +128 -34
- package/src/materials/nodes/LineBasicNodeMaterial.js +17 -2
- package/src/materials/nodes/LineDashedNodeMaterial.js +78 -5
- package/src/materials/nodes/MeshBasicNodeMaterial.js +56 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +35 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +22 -2
- package/src/materials/nodes/MeshNormalNodeMaterial.js +21 -2
- package/src/materials/nodes/MeshPhongNodeMaterial.js +64 -1
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +269 -0
- package/src/materials/nodes/MeshSSSNodeMaterial.js +97 -6
- package/src/materials/nodes/MeshStandardNodeMaterial.js +78 -0
- package/src/materials/nodes/MeshToonNodeMaterial.js +28 -0
- package/src/materials/nodes/NodeMaterial.js +474 -21
- package/src/materials/nodes/PointsNodeMaterial.js +22 -13
- package/src/materials/nodes/ShadowNodeMaterial.js +29 -0
- package/src/materials/nodes/SpriteNodeMaterial.js +77 -19
- package/src/materials/nodes/VolumeNodeMaterial.js +80 -4
- package/src/materials/nodes/manager/NodeMaterialObserver.js +87 -0
- package/src/nodes/Nodes.js +1 -6
- package/src/nodes/TSL.js +2 -3
- package/src/nodes/accessors/AccessorsUtils.js +27 -0
- package/src/nodes/accessors/Arrays.js +24 -5
- package/src/nodes/accessors/BatchNode.js +39 -3
- package/src/nodes/accessors/Bitangent.js +37 -0
- package/src/nodes/accessors/BufferAttributeNode.js +178 -5
- package/src/nodes/accessors/BufferNode.js +63 -0
- package/src/nodes/accessors/BuiltinNode.js +38 -0
- package/src/nodes/accessors/Camera.js +49 -0
- package/src/nodes/accessors/ClippingNode.js +71 -2
- package/src/nodes/accessors/CubeTextureNode.js +64 -0
- package/src/nodes/accessors/InstanceNode.js +85 -2
- package/src/nodes/accessors/InstancedMeshNode.js +28 -3
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +13 -0
- package/src/nodes/accessors/Lights.js +50 -1
- package/src/nodes/accessors/MaterialNode.js +302 -8
- package/src/nodes/accessors/MaterialProperties.js +7 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +53 -13
- package/src/nodes/accessors/ModelNode.js +100 -5
- package/src/nodes/accessors/ModelViewProjectionNode.js +10 -38
- package/src/nodes/accessors/MorphNode.js +48 -4
- package/src/nodes/accessors/Normal.js +59 -3
- package/src/nodes/accessors/Object3DNode.js +102 -1
- package/src/nodes/accessors/PointUVNode.js +26 -0
- package/src/nodes/accessors/Position.js +53 -4
- package/src/nodes/accessors/ReferenceBaseNode.js +188 -0
- package/src/nodes/accessors/ReferenceNode.js +202 -2
- package/src/nodes/accessors/ReflectVector.js +24 -0
- package/src/nodes/accessors/RendererReferenceNode.js +46 -1
- package/src/nodes/accessors/SceneNode.js +54 -0
- package/src/nodes/accessors/SkinningNode.js +127 -1
- package/src/nodes/accessors/StorageBufferNode.js +168 -4
- package/src/nodes/accessors/StorageTextureNode.js +118 -0
- package/src/nodes/accessors/Tangent.js +36 -0
- package/src/nodes/accessors/Texture3DNode.js +89 -5
- package/src/nodes/accessors/TextureBicubic.js +12 -2
- package/src/nodes/accessors/TextureNode.js +309 -10
- package/src/nodes/accessors/TextureSizeNode.js +42 -0
- package/src/nodes/accessors/UV.js +10 -1
- package/src/nodes/accessors/UniformArrayNode.js +223 -23
- package/src/nodes/accessors/UserDataNode.js +46 -0
- package/src/nodes/accessors/VelocityNode.js +82 -0
- package/src/nodes/accessors/VertexColorNode.js +39 -2
- package/src/nodes/code/CodeNode.js +95 -1
- package/src/nodes/code/ExpressionNode.js +28 -0
- package/src/nodes/code/FunctionCallNode.js +37 -0
- package/src/nodes/code/FunctionNode.js +45 -0
- package/src/nodes/code/ScriptableNode.js +223 -1
- package/src/nodes/code/ScriptableValueNode.js +85 -1
- package/src/nodes/core/AssignNode.js +48 -2
- package/src/nodes/core/AttributeNode.js +43 -0
- package/src/nodes/core/BypassNode.js +47 -2
- package/src/nodes/core/CacheNode.js +53 -2
- package/src/nodes/core/ConstNode.js +24 -0
- package/src/nodes/core/ContextNode.js +65 -0
- package/src/nodes/core/IndexNode.js +68 -7
- package/src/nodes/core/InputNode.js +48 -0
- package/src/nodes/core/LightingModel.js +60 -0
- package/src/nodes/core/MRTNode.js +66 -0
- package/src/nodes/core/Node.js +337 -12
- package/src/nodes/core/NodeAttribute.js +38 -0
- package/src/nodes/core/NodeBuilder.js +945 -15
- package/src/nodes/core/NodeCache.js +41 -2
- package/src/nodes/core/NodeCode.js +31 -0
- package/src/nodes/core/NodeFrame.js +123 -2
- package/src/nodes/core/NodeFunction.js +46 -0
- package/src/nodes/core/NodeFunctionInput.js +44 -0
- package/src/nodes/core/NodeParser.js +11 -0
- package/src/nodes/core/NodeUniform.js +52 -0
- package/src/nodes/core/NodeUtils.js +141 -0
- package/src/nodes/core/NodeVar.js +30 -0
- package/src/nodes/core/NodeVarying.js +28 -0
- package/src/nodes/core/OutputStructNode.js +33 -2
- package/src/nodes/core/ParameterNode.js +28 -0
- package/src/nodes/core/PropertyNode.js +232 -0
- package/src/nodes/core/StackNode.js +78 -0
- package/src/nodes/core/StructTypeNode.js +39 -1
- package/src/nodes/core/TempNode.js +30 -4
- package/src/nodes/core/UniformGroupNode.js +82 -7
- package/src/nodes/core/UniformNode.js +66 -0
- package/src/nodes/core/VarNode.js +52 -0
- package/src/nodes/core/VaryingNode.js +83 -2
- package/src/nodes/core/constants.js +36 -0
- package/src/nodes/display/BumpMapNode.js +37 -0
- package/src/nodes/display/ColorAdjustment.js +53 -11
- package/src/nodes/display/ColorSpaceFunctions.js +16 -0
- package/src/nodes/display/ColorSpaceNode.js +82 -0
- package/src/nodes/display/FrontFacingNode.js +29 -0
- package/src/nodes/display/NormalMapNode.js +43 -0
- package/src/nodes/display/PassNode.js +298 -7
- package/src/nodes/display/PosterizeNode.js +33 -0
- package/src/nodes/display/RenderOutputNode.js +66 -1
- package/src/nodes/display/ScreenNode.js +87 -0
- package/src/nodes/display/ToneMappingFunctions.js +58 -10
- package/src/nodes/display/ToneMappingNode.js +55 -2
- package/src/nodes/display/ToonOutlinePassNode.js +73 -0
- package/src/nodes/display/ViewportDepthNode.js +122 -8
- package/src/nodes/display/ViewportDepthTextureNode.js +23 -0
- package/src/nodes/display/ViewportSharedTextureNode.js +23 -0
- package/src/nodes/display/ViewportTextureNode.js +57 -0
- package/src/nodes/fog/Fog.js +93 -0
- package/src/nodes/functions/BasicLightingModel.js +24 -0
- package/src/nodes/functions/PhongLightingModel.js +34 -2
- package/src/nodes/functions/PhysicalLightingModel.js +167 -8
- package/src/nodes/functions/ShadowMaskModel.js +23 -0
- package/src/nodes/functions/ToonLightingModel.js +20 -0
- package/src/nodes/functions/material/getAlphaHashThreshold.js +1 -3
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +16 -1
- package/src/nodes/geometry/RangeNode.js +54 -2
- package/src/nodes/gpgpu/AtomicFunctionNode.js +157 -1
- package/src/nodes/gpgpu/BarrierNode.js +47 -0
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +126 -0
- package/src/nodes/gpgpu/ComputeNode.js +106 -2
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +115 -6
- package/src/nodes/lighting/AONode.js +18 -0
- package/src/nodes/lighting/AmbientLightNode.js +10 -0
- package/src/nodes/lighting/AnalyticLightNode.js +97 -2
- package/src/nodes/lighting/BasicEnvironmentNode.js +19 -0
- package/src/nodes/lighting/BasicLightMapNode.js +17 -0
- package/src/nodes/lighting/DirectionalLightNode.js +10 -0
- package/src/nodes/lighting/EnvironmentNode.js +18 -0
- package/src/nodes/lighting/HemisphereLightNode.js +31 -0
- package/src/nodes/lighting/IESSpotLightNode.js +11 -0
- package/src/nodes/lighting/IrradianceNode.js +17 -0
- package/src/nodes/lighting/LightProbeNode.js +20 -0
- package/src/nodes/lighting/LightUtils.js +12 -0
- package/src/nodes/lighting/LightingContextNode.js +48 -0
- package/src/nodes/lighting/LightingNode.js +15 -6
- package/src/nodes/lighting/LightsNode.js +132 -1
- package/src/nodes/lighting/PointLightNode.js +32 -1
- package/src/nodes/lighting/PointShadowNode.js +54 -1
- package/src/nodes/lighting/RectAreaLightNode.js +44 -6
- package/src/nodes/lighting/ShadowBaseNode.js +93 -0
- package/src/nodes/lighting/ShadowNode.js +240 -34
- package/src/nodes/lighting/SpotLightNode.js +43 -0
- package/src/nodes/math/ConditionalNode.js +70 -3
- package/src/nodes/math/Hash.js +9 -0
- package/src/nodes/math/MathNode.js +614 -11
- package/src/nodes/math/MathUtils.js +45 -1
- package/src/nodes/math/OperatorNode.js +233 -0
- package/src/nodes/math/TriNoise3D.js +18 -7
- package/src/nodes/parsers/GLSLNodeFunction.js +16 -0
- package/src/nodes/parsers/GLSLNodeParser.js +11 -0
- package/src/nodes/pmrem/PMREMNode.js +133 -0
- package/src/nodes/pmrem/PMREMUtils.js +1 -1
- package/src/nodes/procedural/Checker.js +9 -0
- package/src/nodes/tsl/TSLBase.js +2 -2
- package/src/nodes/utils/ArrayElementNode.js +38 -2
- package/src/nodes/utils/ConvertNode.js +31 -0
- package/src/nodes/utils/CubeMapNode.js +78 -0
- package/src/nodes/utils/Discard.js +16 -0
- package/src/nodes/utils/EquirectUVNode.js +31 -1
- package/src/nodes/utils/FlipNode.js +38 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +53 -1
- package/src/nodes/utils/JoinNode.js +25 -0
- package/src/nodes/utils/LoopNode.js +74 -1
- package/src/nodes/utils/MatcapUVNode.js +17 -0
- package/src/nodes/utils/MaxMipLevelNode.js +49 -0
- package/src/nodes/utils/Oscillators.js +33 -0
- package/src/nodes/utils/Packing.js +17 -0
- package/src/nodes/utils/PostProcessingUtils.js +28 -23
- package/src/nodes/utils/RTTNode.js +123 -2
- package/src/nodes/utils/ReflectorNode.js +174 -4
- package/src/nodes/utils/RemapNode.js +79 -0
- package/src/nodes/utils/RotateNode.js +41 -0
- package/src/nodes/utils/SetNode.js +44 -1
- package/src/nodes/utils/SplitNode.js +55 -3
- package/src/nodes/utils/SpriteSheetUVNode.js +46 -0
- package/src/nodes/utils/SpriteUtils.js +17 -0
- package/src/nodes/utils/StorageArrayElementNode.js +40 -0
- package/src/nodes/utils/Timer.js +19 -0
- package/src/nodes/utils/TriplanarTexturesNode.js +84 -0
- package/src/nodes/utils/UVUtils.js +20 -0
- package/src/nodes/utils/ViewportUtils.js +13 -0
- package/src/objects/BatchedMesh.js +1 -2
- package/src/objects/ClippingGroup.js +49 -0
- package/src/renderers/WebGLRenderer.js +23 -4
- package/src/renderers/common/Animation.js +63 -0
- package/src/renderers/common/Attributes.js +36 -0
- package/src/renderers/common/Backend.js +467 -52
- package/src/renderers/common/Background.js +34 -1
- package/src/renderers/common/BindGroup.js +43 -0
- package/src/renderers/common/Binding.js +35 -0
- package/src/renderers/common/Bindings.js +93 -1
- package/src/renderers/common/Buffer.js +49 -0
- package/src/renderers/common/BufferUtils.js +27 -0
- package/src/renderers/common/BundleGroup.js +57 -0
- package/src/renderers/common/ChainMap.js +38 -1
- package/src/renderers/common/ClippingContext.js +107 -14
- package/src/renderers/common/Color4.js +36 -0
- package/src/renderers/common/ComputePipeline.js +24 -0
- package/src/renderers/common/CubeRenderTarget.js +13 -0
- package/src/renderers/common/DataMap.js +37 -1
- package/src/renderers/common/Geometries.js +98 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +25 -2
- package/src/renderers/common/Info.js +87 -0
- package/src/renderers/common/Lighting.js +26 -0
- package/src/renderers/common/Pipeline.js +22 -0
- package/src/renderers/common/Pipelines.js +148 -5
- package/src/renderers/common/PostProcessing.js +75 -3
- package/src/renderers/common/ProgrammableStage.js +60 -2
- package/src/renderers/common/QuadMesh.js +54 -5
- package/src/renderers/common/RenderBundle.js +14 -8
- package/src/renderers/common/RenderBundles.js +33 -10
- package/src/renderers/common/RenderContext.js +169 -4
- package/src/renderers/common/RenderContexts.js +42 -2
- package/src/renderers/common/RenderList.js +178 -0
- package/src/renderers/common/RenderLists.js +31 -0
- package/src/renderers/common/RenderObject.js +328 -4
- package/src/renderers/common/RenderObjects.js +101 -7
- package/src/renderers/common/RenderPipeline.js +24 -0
- package/src/renderers/common/Renderer.js +1096 -31
- package/src/renderers/common/RendererUtils.js +193 -0
- package/src/renderers/common/SampledTexture.js +121 -0
- package/src/renderers/common/Sampler.js +30 -0
- package/src/renderers/common/StorageBuffer.js +24 -0
- package/src/renderers/common/StorageBufferAttribute.js +31 -2
- package/src/renderers/common/StorageInstancedBufferAttribute.js +31 -2
- package/src/renderers/common/StorageTexture.js +38 -0
- package/src/renderers/common/Textures.js +83 -0
- package/src/renderers/common/Uniform.js +188 -2
- package/src/renderers/common/UniformBuffer.js +19 -0
- package/src/renderers/common/UniformsGroup.js +139 -2
- package/src/renderers/common/extras/PMREMGenerator.js +24 -3
- package/src/renderers/common/nodes/NodeBuilderState.js +95 -1
- package/src/renderers/common/nodes/NodeLibrary.js +89 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +91 -2
- package/src/renderers/common/nodes/NodeSampler.js +28 -0
- package/src/renderers/common/nodes/NodeStorageBuffer.js +35 -0
- package/src/renderers/common/nodes/NodeUniform.js +189 -0
- package/src/renderers/common/nodes/NodeUniformBuffer.js +29 -0
- package/src/renderers/common/nodes/NodeUniformsGroup.js +31 -18
- package/src/renderers/common/nodes/Nodes.js +327 -60
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +7 -7
- package/src/renderers/webgl-fallback/WebGLBackend.js +547 -29
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +0 -1
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +1 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +1 -1
- package/src/renderers/webgpu/WebGPUBackend.js +480 -49
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +34 -0
- package/src/renderers/webgpu/WebGPURenderer.js +35 -0
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +20 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +21 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +59 -11
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +17 -0
- package/src/renderers/webgpu/nodes/WGSLNodeParser.js +11 -0
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +10 -8
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +9 -1
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +5 -9
- package/src/renderers/webgpu/utils/WebGPUUtils.js +30 -0
- package/src/renderers/webxr/WebXRDepthSensing.js +1 -1
- package/src/renderers/webxr/WebXRManager.js +7 -1
- package/src/textures/Data3DTexture.js +2 -2
- package/src/textures/Texture.js +4 -0
- package/examples/jsm/animation/MMDAnimationHelper.js +0 -1209
- package/examples/jsm/animation/MMDPhysics.js +0 -1408
- package/examples/jsm/exporters/MMDExporter.js +0 -223
- package/examples/jsm/libs/mmdparser.module.js +0 -11530
- package/examples/jsm/loaders/MMDLoader.js +0 -2298
- package/examples/jsm/shaders/MMDToonShader.js +0 -134
- package/src/nodes/core/UniformGroup.js +0 -13
- package/src/nodes/fog/FogExp2Node.js +0 -35
- package/src/nodes/fog/FogNode.js +0 -50
- package/src/nodes/fog/FogRangeNode.js +0 -36
- package/src/renderers/common/PostProcessingUtils.js +0 -86
|
@@ -4,6 +4,17 @@ import { uniform } from '../core/UniformNode.js';
|
|
|
4
4
|
import { nodeObject } from '../tsl/TSLCore.js';
|
|
5
5
|
import ArrayElementNode from '../utils/ArrayElementNode.js';
|
|
6
6
|
|
|
7
|
+
// TODO: Avoid duplicated code and ues only ReferenceBaseNode or ReferenceNode
|
|
8
|
+
|
|
9
|
+
/** @module ReferenceBaseNode **/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This class is only relevant if the referenced property is array-like.
|
|
13
|
+
* In this case, `ReferenceElementNode` allows to refer to a specific
|
|
14
|
+
* element inside the data structure via an index.
|
|
15
|
+
*
|
|
16
|
+
* @augments ArrayElementNode
|
|
17
|
+
*/
|
|
7
18
|
class ReferenceElementNode extends ArrayElementNode {
|
|
8
19
|
|
|
9
20
|
static get type() {
|
|
@@ -12,16 +23,43 @@ class ReferenceElementNode extends ArrayElementNode {
|
|
|
12
23
|
|
|
13
24
|
}
|
|
14
25
|
|
|
26
|
+
/**
|
|
27
|
+
* Constructs a new reference element node.
|
|
28
|
+
*
|
|
29
|
+
* @param {Node?} referenceNode - The reference node.
|
|
30
|
+
* @param {Node} indexNode - The index node that defines the element access.
|
|
31
|
+
*/
|
|
15
32
|
constructor( referenceNode, indexNode ) {
|
|
16
33
|
|
|
17
34
|
super( referenceNode, indexNode );
|
|
18
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Similar to {@link module:ReferenceBaseNode~ReferenceBaseNode#reference}, an additional
|
|
38
|
+
* property references to the current node.
|
|
39
|
+
*
|
|
40
|
+
* @type {Node?}
|
|
41
|
+
* @default null
|
|
42
|
+
*/
|
|
19
43
|
this.referenceNode = referenceNode;
|
|
20
44
|
|
|
45
|
+
/**
|
|
46
|
+
* This flag can be used for type testing.
|
|
47
|
+
*
|
|
48
|
+
* @type {Boolean}
|
|
49
|
+
* @readonly
|
|
50
|
+
* @default true
|
|
51
|
+
*/
|
|
21
52
|
this.isReferenceElementNode = true;
|
|
22
53
|
|
|
23
54
|
}
|
|
24
55
|
|
|
56
|
+
/**
|
|
57
|
+
* This method is overwritten since the node type is inferred from
|
|
58
|
+
* the uniform type of the reference node.
|
|
59
|
+
*
|
|
60
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
61
|
+
* @return {String} The node type.
|
|
62
|
+
*/
|
|
25
63
|
getNodeType() {
|
|
26
64
|
|
|
27
65
|
return this.referenceNode.uniformType;
|
|
@@ -40,6 +78,14 @@ class ReferenceElementNode extends ArrayElementNode {
|
|
|
40
78
|
|
|
41
79
|
}
|
|
42
80
|
|
|
81
|
+
/**
|
|
82
|
+
* Base class for nodes which establishes a reference to a property of another object.
|
|
83
|
+
* In this way, the value of the node is automatically linked to the value of
|
|
84
|
+
* referenced object. Reference nodes internally represent the linked value
|
|
85
|
+
* as a uniform.
|
|
86
|
+
*
|
|
87
|
+
* @augments Node
|
|
88
|
+
*/
|
|
43
89
|
class ReferenceBaseNode extends Node {
|
|
44
90
|
|
|
45
91
|
static get type() {
|
|
@@ -48,24 +94,97 @@ class ReferenceBaseNode extends Node {
|
|
|
48
94
|
|
|
49
95
|
}
|
|
50
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Constructs a new reference base node.
|
|
99
|
+
*
|
|
100
|
+
* @param {String} property - The name of the property the node refers to.
|
|
101
|
+
* @param {String} uniformType - The uniform type that should be used to represent the property value.
|
|
102
|
+
* @param {Object?} [object=null] - The object the property belongs to.
|
|
103
|
+
* @param {Number?} [count=null] - When the linked property is an array-like, this parameter defines its length.
|
|
104
|
+
*/
|
|
51
105
|
constructor( property, uniformType, object = null, count = null ) {
|
|
52
106
|
|
|
53
107
|
super();
|
|
54
108
|
|
|
109
|
+
/**
|
|
110
|
+
* The name of the property the node refers to.
|
|
111
|
+
*
|
|
112
|
+
* @type {String}
|
|
113
|
+
*/
|
|
55
114
|
this.property = property;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The uniform type that should be used to represent the property value.
|
|
118
|
+
*
|
|
119
|
+
* @type {String}
|
|
120
|
+
*/
|
|
56
121
|
this.uniformType = uniformType;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The object the property belongs to.
|
|
125
|
+
*
|
|
126
|
+
* @type {Object?}
|
|
127
|
+
* @default null
|
|
128
|
+
*/
|
|
57
129
|
this.object = object;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* When the linked property is an array, this parameter defines its length.
|
|
133
|
+
*
|
|
134
|
+
* @type {Number?}
|
|
135
|
+
* @default null
|
|
136
|
+
*/
|
|
58
137
|
this.count = count;
|
|
59
138
|
|
|
139
|
+
/**
|
|
140
|
+
* The property name might have dots so nested properties can be referred.
|
|
141
|
+
* The hierarchy of the names is stored inside this array.
|
|
142
|
+
*
|
|
143
|
+
* @type {Array<String>}
|
|
144
|
+
*/
|
|
60
145
|
this.properties = property.split( '.' );
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Points to the current referred object. This property exists next to {@link module:ReferenceNode~ReferenceNode#object}
|
|
149
|
+
* since the final reference might be updated from calling code.
|
|
150
|
+
*
|
|
151
|
+
* @type {Object?}
|
|
152
|
+
* @default null
|
|
153
|
+
*/
|
|
61
154
|
this.reference = object;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* The uniform node that holds the value of the reference node.
|
|
158
|
+
*
|
|
159
|
+
* @type {UniformNode}
|
|
160
|
+
* @default null
|
|
161
|
+
*/
|
|
62
162
|
this.node = null;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* The uniform group of the internal uniform.
|
|
166
|
+
*
|
|
167
|
+
* @type {UniformGroupNode}
|
|
168
|
+
* @default null
|
|
169
|
+
*/
|
|
63
170
|
this.group = null;
|
|
64
171
|
|
|
172
|
+
/**
|
|
173
|
+
* Overwritten since reference nodes are updated per object.
|
|
174
|
+
*
|
|
175
|
+
* @type {String}
|
|
176
|
+
* @default 'object'
|
|
177
|
+
*/
|
|
65
178
|
this.updateType = NodeUpdateType.OBJECT;
|
|
66
179
|
|
|
67
180
|
}
|
|
68
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Sets the uniform group for this reference node.
|
|
184
|
+
*
|
|
185
|
+
* @param {UniformGroupNode} group - The uniform group to set.
|
|
186
|
+
* @return {ReferenceBaseNode} A reference to this node.
|
|
187
|
+
*/
|
|
69
188
|
setGroup( group ) {
|
|
70
189
|
|
|
71
190
|
this.group = group;
|
|
@@ -74,12 +193,25 @@ class ReferenceBaseNode extends Node {
|
|
|
74
193
|
|
|
75
194
|
}
|
|
76
195
|
|
|
196
|
+
/**
|
|
197
|
+
* When the referred property is array-like, this method can be used
|
|
198
|
+
* to access elements via an index node.
|
|
199
|
+
*
|
|
200
|
+
* @param {IndexNode} indexNode - indexNode.
|
|
201
|
+
* @return {ReferenceElementNode} A reference to an element.
|
|
202
|
+
*/
|
|
77
203
|
element( indexNode ) {
|
|
78
204
|
|
|
79
205
|
return nodeObject( new ReferenceElementNode( this, nodeObject( indexNode ) ) );
|
|
80
206
|
|
|
81
207
|
}
|
|
82
208
|
|
|
209
|
+
/**
|
|
210
|
+
* Sets the node type which automatically defines the internal
|
|
211
|
+
* uniform type.
|
|
212
|
+
*
|
|
213
|
+
* @param {String} uniformType - The type to set.
|
|
214
|
+
*/
|
|
83
215
|
setNodeType( uniformType ) {
|
|
84
216
|
|
|
85
217
|
const node = uniform( null, uniformType ).getSelf();
|
|
@@ -94,6 +226,13 @@ class ReferenceBaseNode extends Node {
|
|
|
94
226
|
|
|
95
227
|
}
|
|
96
228
|
|
|
229
|
+
/**
|
|
230
|
+
* This method is overwritten since the node type is inferred from
|
|
231
|
+
* the type of the reference node.
|
|
232
|
+
*
|
|
233
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
234
|
+
* @return {String} The node type.
|
|
235
|
+
*/
|
|
97
236
|
getNodeType( builder ) {
|
|
98
237
|
|
|
99
238
|
if ( this.node === null ) {
|
|
@@ -107,6 +246,12 @@ class ReferenceBaseNode extends Node {
|
|
|
107
246
|
|
|
108
247
|
}
|
|
109
248
|
|
|
249
|
+
/**
|
|
250
|
+
* Returns the property value from the given referred object.
|
|
251
|
+
*
|
|
252
|
+
* @param {Object} [object=this.reference] - The object to retrieve the property value from.
|
|
253
|
+
* @return {Any} The value.
|
|
254
|
+
*/
|
|
110
255
|
getValueFromReference( object = this.reference ) {
|
|
111
256
|
|
|
112
257
|
const { properties } = this;
|
|
@@ -123,6 +268,13 @@ class ReferenceBaseNode extends Node {
|
|
|
123
268
|
|
|
124
269
|
}
|
|
125
270
|
|
|
271
|
+
/**
|
|
272
|
+
* Allows to update the reference based on the given state. The state is only
|
|
273
|
+
* evaluated {@link module:ReferenceBaseNode~ReferenceBaseNode#object} is not set.
|
|
274
|
+
*
|
|
275
|
+
* @param {(NodeFrame|NodeBuilder)} state - The current state.
|
|
276
|
+
* @return {Object} The updated reference.
|
|
277
|
+
*/
|
|
126
278
|
updateReference( state ) {
|
|
127
279
|
|
|
128
280
|
this.reference = this.object !== null ? this.object : state.object;
|
|
@@ -131,6 +283,12 @@ class ReferenceBaseNode extends Node {
|
|
|
131
283
|
|
|
132
284
|
}
|
|
133
285
|
|
|
286
|
+
/**
|
|
287
|
+
* The output of the reference node is the internal uniform node.
|
|
288
|
+
*
|
|
289
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
290
|
+
* @return {UniformNode} The output node.
|
|
291
|
+
*/
|
|
134
292
|
setup() {
|
|
135
293
|
|
|
136
294
|
this.updateValue();
|
|
@@ -139,12 +297,21 @@ class ReferenceBaseNode extends Node {
|
|
|
139
297
|
|
|
140
298
|
}
|
|
141
299
|
|
|
300
|
+
/**
|
|
301
|
+
* Overwritten to to update the internal uniform value.
|
|
302
|
+
*
|
|
303
|
+
* @param {NodeFrame} frame - A reference to the current node frame.
|
|
304
|
+
*/
|
|
142
305
|
update( /*frame*/ ) {
|
|
143
306
|
|
|
144
307
|
this.updateValue();
|
|
145
308
|
|
|
146
309
|
}
|
|
147
310
|
|
|
311
|
+
/**
|
|
312
|
+
* Retrieves the value from the referred object property and uses it
|
|
313
|
+
* to updated the internal uniform.
|
|
314
|
+
*/
|
|
148
315
|
updateValue() {
|
|
149
316
|
|
|
150
317
|
if ( this.node === null ) this.setNodeType( this.uniformType );
|
|
@@ -167,5 +334,26 @@ class ReferenceBaseNode extends Node {
|
|
|
167
334
|
|
|
168
335
|
export default ReferenceBaseNode;
|
|
169
336
|
|
|
337
|
+
/**
|
|
338
|
+
* TSL function for creating a reference base node.
|
|
339
|
+
*
|
|
340
|
+
* @function
|
|
341
|
+
* @param {String} name - The name of the property the node refers to.
|
|
342
|
+
* @param {String} type - The uniform type that should be used to represent the property value.
|
|
343
|
+
* @param {Object} object - The object the property belongs to.
|
|
344
|
+
* @returns {ReferenceBaseNode}
|
|
345
|
+
*/
|
|
170
346
|
export const reference = ( name, type, object ) => nodeObject( new ReferenceBaseNode( name, type, object ) );
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* TSL function for creating a reference base node. Use this function if you want need a reference
|
|
350
|
+
* to an array-like property that should be represented as a uniform buffer.
|
|
351
|
+
*
|
|
352
|
+
* @function
|
|
353
|
+
* @param {String} name - The name of the property the node refers to.
|
|
354
|
+
* @param {String} type - The uniform type that should be used to represent the property value.
|
|
355
|
+
* @param {Number} count - The number of value inside the array-like object.
|
|
356
|
+
* @param {Object} object - An array-like object the property belongs to.
|
|
357
|
+
* @returns {ReferenceBaseNode}
|
|
358
|
+
*/
|
|
171
359
|
export const referenceBuffer = ( name, type, count, object ) => nodeObject( new ReferenceBaseNode( name, type, object, count ) );
|
|
@@ -8,6 +8,17 @@ import { nodeObject } from '../tsl/TSLBase.js';
|
|
|
8
8
|
import { uniformArray } from './UniformArrayNode.js';
|
|
9
9
|
import ArrayElementNode from '../utils/ArrayElementNode.js';
|
|
10
10
|
|
|
11
|
+
// TODO: Avoid duplicated code and ues only ReferenceBaseNode or ReferenceNode
|
|
12
|
+
|
|
13
|
+
/** @module ReferenceNode **/
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* This class is only relevant if the referenced property is array-like.
|
|
17
|
+
* In this case, `ReferenceElementNode` allows to refer to a specific
|
|
18
|
+
* element inside the data structure via an index.
|
|
19
|
+
*
|
|
20
|
+
* @augments ArrayElementNode
|
|
21
|
+
*/
|
|
11
22
|
class ReferenceElementNode extends ArrayElementNode {
|
|
12
23
|
|
|
13
24
|
static get type() {
|
|
@@ -16,16 +27,43 @@ class ReferenceElementNode extends ArrayElementNode {
|
|
|
16
27
|
|
|
17
28
|
}
|
|
18
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Constructs a new reference element node.
|
|
32
|
+
*
|
|
33
|
+
* @param {Node?} referenceNode - The reference node.
|
|
34
|
+
* @param {Node} indexNode - The index node that defines the element access.
|
|
35
|
+
*/
|
|
19
36
|
constructor( referenceNode, indexNode ) {
|
|
20
37
|
|
|
21
38
|
super( referenceNode, indexNode );
|
|
22
39
|
|
|
40
|
+
/**
|
|
41
|
+
* Similar to {@link module:ReferenceNode~ReferenceNode#reference}, an additional
|
|
42
|
+
* property references to the current node.
|
|
43
|
+
*
|
|
44
|
+
* @type {Node?}
|
|
45
|
+
* @default null
|
|
46
|
+
*/
|
|
23
47
|
this.referenceNode = referenceNode;
|
|
24
48
|
|
|
49
|
+
/**
|
|
50
|
+
* This flag can be used for type testing.
|
|
51
|
+
*
|
|
52
|
+
* @type {Boolean}
|
|
53
|
+
* @readonly
|
|
54
|
+
* @default true
|
|
55
|
+
*/
|
|
25
56
|
this.isReferenceElementNode = true;
|
|
26
57
|
|
|
27
58
|
}
|
|
28
59
|
|
|
60
|
+
/**
|
|
61
|
+
* This method is overwritten since the node type is inferred from
|
|
62
|
+
* the uniform type of the reference node.
|
|
63
|
+
*
|
|
64
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
65
|
+
* @return {String} The node type.
|
|
66
|
+
*/
|
|
29
67
|
getNodeType() {
|
|
30
68
|
|
|
31
69
|
return this.referenceNode.uniformType;
|
|
@@ -44,7 +82,14 @@ class ReferenceElementNode extends ArrayElementNode {
|
|
|
44
82
|
|
|
45
83
|
}
|
|
46
84
|
|
|
47
|
-
|
|
85
|
+
/**
|
|
86
|
+
* This type of node establishes a reference to a property of another object.
|
|
87
|
+
* In this way, the value of the node is automatically linked to the value of
|
|
88
|
+
* referenced object. Reference nodes internally represent the linked value
|
|
89
|
+
* as a uniform.
|
|
90
|
+
*
|
|
91
|
+
* @augments Node
|
|
92
|
+
*/
|
|
48
93
|
class ReferenceNode extends Node {
|
|
49
94
|
|
|
50
95
|
static get type() {
|
|
@@ -53,31 +98,118 @@ class ReferenceNode extends Node {
|
|
|
53
98
|
|
|
54
99
|
}
|
|
55
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Constructs a new reference node.
|
|
103
|
+
*
|
|
104
|
+
* @param {String} property - The name of the property the node refers to.
|
|
105
|
+
* @param {String} uniformType - The uniform type that should be used to represent the property value.
|
|
106
|
+
* @param {Object?} [object=null] - The object the property belongs to.
|
|
107
|
+
* @param {Number?} [count=null] - When the linked property is an array-like, this parameter defines its length.
|
|
108
|
+
*/
|
|
56
109
|
constructor( property, uniformType, object = null, count = null ) {
|
|
57
110
|
|
|
58
111
|
super();
|
|
59
112
|
|
|
113
|
+
/**
|
|
114
|
+
* The name of the property the node refers to.
|
|
115
|
+
*
|
|
116
|
+
* @type {String}
|
|
117
|
+
*/
|
|
60
118
|
this.property = property;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The uniform type that should be used to represent the property value.
|
|
122
|
+
*
|
|
123
|
+
* @type {String}
|
|
124
|
+
*/
|
|
61
125
|
this.uniformType = uniformType;
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The object the property belongs to.
|
|
129
|
+
*
|
|
130
|
+
* @type {Object?}
|
|
131
|
+
* @default null
|
|
132
|
+
*/
|
|
62
133
|
this.object = object;
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* When the linked property is an array, this parameter defines its length.
|
|
137
|
+
*
|
|
138
|
+
* @type {Number?}
|
|
139
|
+
* @default null
|
|
140
|
+
*/
|
|
63
141
|
this.count = count;
|
|
64
142
|
|
|
143
|
+
/**
|
|
144
|
+
* The property name might have dots so nested properties can be referred.
|
|
145
|
+
* The hierarchy of the names is stored inside this array.
|
|
146
|
+
*
|
|
147
|
+
* @type {Array<String>}
|
|
148
|
+
*/
|
|
65
149
|
this.properties = property.split( '.' );
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Points to the current referred object. This property exists next to {@link module:ReferenceNode~ReferenceNode#object}
|
|
153
|
+
* since the final reference might be updated from calling code.
|
|
154
|
+
*
|
|
155
|
+
* @type {Object?}
|
|
156
|
+
* @default null
|
|
157
|
+
*/
|
|
66
158
|
this.reference = object;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* The uniform node that holds the value of the reference node.
|
|
162
|
+
*
|
|
163
|
+
* @type {UniformNode}
|
|
164
|
+
* @default null
|
|
165
|
+
*/
|
|
67
166
|
this.node = null;
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* The uniform group of the internal uniform.
|
|
170
|
+
*
|
|
171
|
+
* @type {UniformGroupNode}
|
|
172
|
+
* @default null
|
|
173
|
+
*/
|
|
68
174
|
this.group = null;
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* An optional label of the internal uniform node.
|
|
178
|
+
*
|
|
179
|
+
* @type {String?}
|
|
180
|
+
* @default null
|
|
181
|
+
*/
|
|
69
182
|
this.name = null;
|
|
70
183
|
|
|
184
|
+
/**
|
|
185
|
+
* Overwritten since reference nodes are updated per object.
|
|
186
|
+
*
|
|
187
|
+
* @type {String}
|
|
188
|
+
* @default 'object'
|
|
189
|
+
*/
|
|
71
190
|
this.updateType = NodeUpdateType.OBJECT;
|
|
72
191
|
|
|
73
192
|
}
|
|
74
193
|
|
|
194
|
+
/**
|
|
195
|
+
* When the referred property is array-like, this method can be used
|
|
196
|
+
* to access elements via an index node.
|
|
197
|
+
*
|
|
198
|
+
* @param {IndexNode} indexNode - indexNode.
|
|
199
|
+
* @return {ReferenceElementNode} A reference to an element.
|
|
200
|
+
*/
|
|
75
201
|
element( indexNode ) {
|
|
76
202
|
|
|
77
203
|
return nodeObject( new ReferenceElementNode( this, nodeObject( indexNode ) ) );
|
|
78
204
|
|
|
79
205
|
}
|
|
80
206
|
|
|
207
|
+
/**
|
|
208
|
+
* Sets the uniform group for this reference node.
|
|
209
|
+
*
|
|
210
|
+
* @param {UniformGroupNode} group - The uniform group to set.
|
|
211
|
+
* @return {ReferenceNode} A reference to this node.
|
|
212
|
+
*/
|
|
81
213
|
setGroup( group ) {
|
|
82
214
|
|
|
83
215
|
this.group = group;
|
|
@@ -86,6 +218,12 @@ class ReferenceNode extends Node {
|
|
|
86
218
|
|
|
87
219
|
}
|
|
88
220
|
|
|
221
|
+
/**
|
|
222
|
+
* Sets the label for the internal uniform.
|
|
223
|
+
*
|
|
224
|
+
* @param {String} name - The label to set.
|
|
225
|
+
* @return {ReferenceNode} A reference to this node.
|
|
226
|
+
*/
|
|
89
227
|
label( name ) {
|
|
90
228
|
|
|
91
229
|
this.name = name;
|
|
@@ -94,6 +232,12 @@ class ReferenceNode extends Node {
|
|
|
94
232
|
|
|
95
233
|
}
|
|
96
234
|
|
|
235
|
+
/**
|
|
236
|
+
* Sets the node type which automatically defines the internal
|
|
237
|
+
* uniform type.
|
|
238
|
+
*
|
|
239
|
+
* @param {String} uniformType - The type to set.
|
|
240
|
+
*/
|
|
97
241
|
setNodeType( uniformType ) {
|
|
98
242
|
|
|
99
243
|
let node = null;
|
|
@@ -132,6 +276,13 @@ class ReferenceNode extends Node {
|
|
|
132
276
|
|
|
133
277
|
}
|
|
134
278
|
|
|
279
|
+
/**
|
|
280
|
+
* This method is overwritten since the node type is inferred from
|
|
281
|
+
* the type of the reference node.
|
|
282
|
+
*
|
|
283
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
284
|
+
* @return {String} The node type.
|
|
285
|
+
*/
|
|
135
286
|
getNodeType( builder ) {
|
|
136
287
|
|
|
137
288
|
if ( this.node === null ) {
|
|
@@ -145,6 +296,12 @@ class ReferenceNode extends Node {
|
|
|
145
296
|
|
|
146
297
|
}
|
|
147
298
|
|
|
299
|
+
/**
|
|
300
|
+
* Returns the property value from the given referred object.
|
|
301
|
+
*
|
|
302
|
+
* @param {Object} [object=this.reference] - The object to retrieve the property value from.
|
|
303
|
+
* @return {Any} The value.
|
|
304
|
+
*/
|
|
148
305
|
getValueFromReference( object = this.reference ) {
|
|
149
306
|
|
|
150
307
|
const { properties } = this;
|
|
@@ -161,6 +318,13 @@ class ReferenceNode extends Node {
|
|
|
161
318
|
|
|
162
319
|
}
|
|
163
320
|
|
|
321
|
+
/**
|
|
322
|
+
* Allows to update the reference based on the given state. The state is only
|
|
323
|
+
* evaluated {@link module:ReferenceNode~ReferenceNode#object} is not set.
|
|
324
|
+
*
|
|
325
|
+
* @param {(NodeFrame|NodeBuilder)} state - The current state.
|
|
326
|
+
* @return {Object} The updated reference.
|
|
327
|
+
*/
|
|
164
328
|
updateReference( state ) {
|
|
165
329
|
|
|
166
330
|
this.reference = this.object !== null ? this.object : state.object;
|
|
@@ -169,7 +333,13 @@ class ReferenceNode extends Node {
|
|
|
169
333
|
|
|
170
334
|
}
|
|
171
335
|
|
|
172
|
-
|
|
336
|
+
/**
|
|
337
|
+
* The output of the reference node is the internal uniform node.
|
|
338
|
+
*
|
|
339
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
340
|
+
* @return {UniformNode} The output node.
|
|
341
|
+
*/
|
|
342
|
+
setup( /* builder */ ) {
|
|
173
343
|
|
|
174
344
|
this.updateValue();
|
|
175
345
|
|
|
@@ -177,12 +347,21 @@ class ReferenceNode extends Node {
|
|
|
177
347
|
|
|
178
348
|
}
|
|
179
349
|
|
|
350
|
+
/**
|
|
351
|
+
* Overwritten to to update the internal uniform value.
|
|
352
|
+
*
|
|
353
|
+
* @param {NodeFrame} frame - A reference to the current node frame.
|
|
354
|
+
*/
|
|
180
355
|
update( /*frame*/ ) {
|
|
181
356
|
|
|
182
357
|
this.updateValue();
|
|
183
358
|
|
|
184
359
|
}
|
|
185
360
|
|
|
361
|
+
/**
|
|
362
|
+
* Retrieves the value from the referred object property and uses it
|
|
363
|
+
* to updated the internal uniform.
|
|
364
|
+
*/
|
|
186
365
|
updateValue() {
|
|
187
366
|
|
|
188
367
|
if ( this.node === null ) this.setNodeType( this.uniformType );
|
|
@@ -205,5 +384,26 @@ class ReferenceNode extends Node {
|
|
|
205
384
|
|
|
206
385
|
export default ReferenceNode;
|
|
207
386
|
|
|
387
|
+
/**
|
|
388
|
+
* TSL function for creating a reference node.
|
|
389
|
+
*
|
|
390
|
+
* @function
|
|
391
|
+
* @param {String} name - The name of the property the node refers to.
|
|
392
|
+
* @param {String} type - The uniform type that should be used to represent the property value.
|
|
393
|
+
* @param {Object} object - The object the property belongs to.
|
|
394
|
+
* @returns {ReferenceNode}
|
|
395
|
+
*/
|
|
208
396
|
export const reference = ( name, type, object ) => nodeObject( new ReferenceNode( name, type, object ) );
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* TSL function for creating a reference node. Use this function if you want need a reference
|
|
400
|
+
* to an array-like property that should be represented as a uniform buffer.
|
|
401
|
+
*
|
|
402
|
+
* @function
|
|
403
|
+
* @param {String} name - The name of the property the node refers to.
|
|
404
|
+
* @param {String} type - The uniform type that should be used to represent the property value.
|
|
405
|
+
* @param {Number} count - The number of value inside the array-like object.
|
|
406
|
+
* @param {Object} object - An array-like object the property belongs to.
|
|
407
|
+
* @returns {ReferenceNode}
|
|
408
|
+
*/
|
|
209
409
|
export const referenceBuffer = ( name, type, count, object ) => nodeObject( new ReferenceNode( name, type, object, count ) );
|
|
@@ -3,8 +3,32 @@ import { transformedNormalView } from './Normal.js';
|
|
|
3
3
|
import { positionViewDirection } from './Position.js';
|
|
4
4
|
import { materialRefractionRatio } from './MaterialProperties.js';
|
|
5
5
|
|
|
6
|
+
/** @module ReflectVector **/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The reflect vector in view space.
|
|
10
|
+
*
|
|
11
|
+
* @type {Node<vec3>}
|
|
12
|
+
*/
|
|
6
13
|
export const reflectView = /*@__PURE__*/ positionViewDirection.negate().reflect( transformedNormalView );
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The refract vector in view space.
|
|
17
|
+
*
|
|
18
|
+
* @type {Node<vec3>}
|
|
19
|
+
*/
|
|
7
20
|
export const refractView = /*@__PURE__*/ positionViewDirection.negate().refract( transformedNormalView, materialRefractionRatio );
|
|
8
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Used for sampling cube maps when using cube reflection mapping.
|
|
24
|
+
*
|
|
25
|
+
* @type {Node<vec3>}
|
|
26
|
+
*/
|
|
9
27
|
export const reflectVector = /*@__PURE__*/ reflectView.transformDirection( cameraViewMatrix ).toVar( 'reflectVector' );
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Used for sampling cube maps when using cube refraction mapping.
|
|
31
|
+
*
|
|
32
|
+
* @type {Node<vec3>}
|
|
33
|
+
*/
|
|
10
34
|
export const refractVector = /*@__PURE__*/ refractView.transformDirection( cameraViewMatrix ).toVar( 'reflectVector' );
|