super-three 0.184.0 → 0.185.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/build/three.cjs +1260 -927
- package/build/three.core.js +1104 -829
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +156 -98
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +11 -4
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +7538 -3367
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +7538 -3366
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +3 -0
- package/examples/jsm/controls/ArcballControls.js +6 -2
- package/examples/jsm/controls/FirstPersonControls.js +79 -42
- package/examples/jsm/controls/TransformControls.js +68 -15
- package/examples/jsm/csm/CSMFrustum.js +31 -6
- package/examples/jsm/csm/CSMShadowNode.js +4 -1
- package/examples/jsm/effects/AsciiEffect.js +14 -1
- package/examples/jsm/exporters/DRACOExporter.js +27 -6
- package/examples/jsm/exporters/GLTFExporter.js +114 -12
- package/examples/jsm/exporters/PLYExporter.js +286 -73
- package/examples/jsm/exporters/USDZExporter.js +347 -112
- package/examples/jsm/generators/CityGenerator.js +346 -0
- package/examples/jsm/generators/ForestGenerator.js +347 -0
- package/examples/jsm/generators/TerrainGenerator.js +504 -0
- package/examples/jsm/generators/TreeGenerator.js +377 -0
- package/examples/jsm/generators/city/SidewalkGenerator.js +253 -0
- package/examples/jsm/generators/city/SkyscraperGenerator.js +1357 -0
- package/examples/jsm/geometries/LoftGeometry.js +355 -0
- package/examples/jsm/helpers/LightProbeGridHelper.js +1 -1
- package/examples/jsm/helpers/LightProbeHelper.js +5 -4
- package/examples/jsm/helpers/ViewHelper.js +16 -6
- package/examples/jsm/inspector/Inspector.js +53 -15
- package/examples/jsm/inspector/RendererInspector.js +152 -36
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphEditor.js +1 -1
- package/examples/jsm/inspector/extensions/tsl-graph/TSLGraphLoader.js +1 -1
- package/examples/jsm/inspector/tabs/Console.js +200 -18
- package/examples/jsm/inspector/tabs/Memory.js +8 -0
- package/examples/jsm/inspector/tabs/Parameters.js +64 -4
- package/examples/jsm/inspector/tabs/Performance.js +21 -6
- package/examples/jsm/inspector/tabs/Settings.js +51 -9
- package/examples/jsm/inspector/tabs/Timeline.js +178 -93
- package/examples/jsm/inspector/tabs/Viewer.js +628 -16
- package/examples/jsm/inspector/ui/Graph.js +162 -25
- package/examples/jsm/inspector/ui/Item.js +92 -13
- package/examples/jsm/inspector/ui/List.js +1 -1
- package/examples/jsm/inspector/ui/Profiler.js +90 -45
- package/examples/jsm/inspector/ui/Style.js +1788 -1401
- package/examples/jsm/inspector/ui/Tab.js +5 -3
- package/examples/jsm/inspector/ui/Values.js +71 -6
- package/examples/jsm/inspector/ui/utils.js +130 -10
- package/examples/jsm/libs/basis/README.md +0 -1
- package/examples/jsm/libs/demuxer_mp4.js +3 -3
- package/examples/jsm/libs/draco/README.md +0 -1
- package/examples/jsm/libs/meshopt_clusterizer.module.js +421 -0
- package/examples/jsm/libs/meshopt_simplifier.module.js +627 -0
- package/examples/jsm/libs/mikktspace.module.js +34 -9
- package/examples/jsm/lighting/ClusteredLighting.js +55 -0
- package/examples/jsm/lighting/LightProbeGrid.js +106 -76
- package/examples/jsm/lines/LineMaterial.js +38 -15
- package/examples/jsm/lines/LineSegments2.js +8 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +8 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -1
- package/examples/jsm/loaders/DRACOLoader.js +46 -13
- package/examples/jsm/loaders/EXRLoader.js +27 -55
- package/examples/jsm/loaders/HDRLoader.js +6 -28
- package/examples/jsm/loaders/KTX2Loader.js +31 -12
- package/examples/jsm/loaders/LDrawLoader.js +8 -8
- package/examples/jsm/loaders/LUT3dlLoader.js +2 -2
- package/examples/jsm/loaders/LUTCubeLoader.js +2 -2
- package/examples/jsm/loaders/LWOLoader.js +4 -0
- package/examples/jsm/loaders/LottieLoader.js +1 -1
- package/examples/jsm/loaders/MaterialXLoader.js +31 -9
- package/examples/jsm/loaders/NRRDLoader.js +3 -3
- package/examples/jsm/loaders/PCDLoader.js +7 -7
- package/examples/jsm/loaders/PLYLoader.js +218 -55
- package/examples/jsm/loaders/SVGLoader.js +547 -495
- package/examples/jsm/loaders/TTFLoader.js +1 -1
- package/examples/jsm/loaders/USDLoader.js +33 -9
- package/examples/jsm/loaders/VRMLLoader.js +1 -1
- package/examples/jsm/loaders/usd/USDAParser.js +93 -20
- package/examples/jsm/loaders/usd/USDCParser.js +1 -1
- package/examples/jsm/loaders/usd/USDComposer.js +52 -19
- package/examples/jsm/misc/TileCreasedNormalsPlugin.js +270 -0
- package/examples/jsm/misc/Volume.js +2 -2
- package/examples/jsm/objects/GroundedSkybox.js +1 -1
- package/examples/jsm/objects/Reflector.js +2 -3
- package/examples/jsm/objects/Water2Mesh.js +1 -1
- package/examples/jsm/physics/AmmoPhysics.js +15 -8
- package/examples/jsm/physics/RapierPhysics.js +27 -2
- package/examples/jsm/shaders/VolumeShader.js +31 -44
- package/examples/jsm/transpiler/GLSLDecoder.js +6 -6
- package/examples/jsm/transpiler/Linker.js +1 -1
- package/examples/jsm/tsl/display/BloomNode.js +59 -19
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +2 -2
- package/examples/jsm/tsl/display/FXAANode.js +11 -12
- package/examples/jsm/tsl/display/GTAONode.js +34 -13
- package/examples/jsm/tsl/display/GodraysNode.js +1 -1
- package/examples/jsm/tsl/display/ImportanceSampledEnvironment.js +560 -0
- package/examples/jsm/tsl/display/PixelationPassNode.js +2 -2
- package/examples/jsm/tsl/display/RecurrentDenoiseNode.js +912 -0
- package/examples/jsm/tsl/display/SSAAPassNode.js +13 -25
- package/examples/jsm/tsl/display/SSGINode.js +89 -39
- package/examples/jsm/tsl/display/SSRNode.js +829 -132
- package/examples/jsm/tsl/display/SSSNode.js +2 -2
- package/examples/jsm/tsl/display/TemporalReprojectNode.js +1023 -0
- package/examples/jsm/tsl/lighting/ClusteredLightsNode.js +622 -0
- package/examples/jsm/tsl/lighting/DynamicLightsNode.js +1 -1
- package/examples/jsm/tsl/math/curlNoise.js +107 -0
- package/examples/jsm/tsl/shadows/TileShadowNode.js +1 -1
- package/examples/jsm/tsl/shadows/TileShadowNodeHelper.js +3 -3
- package/examples/jsm/tsl/utils/GroundedSkybox.js +62 -0
- package/examples/jsm/tsl/utils/RNoise.js +51 -0
- package/examples/jsm/tsl/utils/SpecularHelpers.js +325 -0
- package/examples/jsm/utils/BufferGeometryUtils.js +126 -59
- package/examples/jsm/utils/GeometryCompressionUtils.js +1 -1
- package/examples/jsm/utils/SceneOptimizer.js +1 -1
- package/examples/jsm/webxr/ARButton.js +1 -1
- package/examples/jsm/webxr/WebGLXRFallback.js +89 -0
- package/examples/jsm/webxr/XRControllerModelFactory.js +2 -2
- package/package.json +7 -7
- package/src/Three.TSL.js +10 -3
- package/src/Three.WebGPU.js +4 -0
- package/src/animation/AnimationAction.js +15 -11
- package/src/animation/AnimationClip.js +0 -139
- package/src/animation/KeyframeTrack.js +2 -2
- package/src/animation/PropertyBinding.js +2 -2
- package/src/cameras/Camera.js +2 -2
- package/src/cameras/StereoCamera.js +5 -2
- package/src/constants.js +1 -1
- package/src/core/BufferGeometry.js +29 -7
- package/src/core/Object3D.js +17 -7
- package/src/core/Raycaster.js +1 -1
- package/src/core/RenderTarget.js +15 -2
- package/src/extras/PMREMGenerator.js +6 -4
- package/src/extras/TextureUtils.js +1 -1
- package/src/extras/core/ShapePath.js +149 -160
- package/src/geometries/SphereGeometry.js +8 -3
- package/src/helpers/DirectionalLightHelper.js +2 -0
- package/src/helpers/HemisphereLightHelper.js +2 -0
- package/src/helpers/PointLightHelper.js +2 -0
- package/src/helpers/SpotLightHelper.js +1 -1
- package/src/loaders/DataTextureLoader.js +69 -38
- package/src/loaders/LoadingManager.js +5 -0
- package/src/loaders/MaterialLoader.js +36 -266
- package/src/loaders/ObjectLoader.js +3 -1
- package/src/materials/LineBasicMaterial.js +4 -0
- package/src/materials/Material.js +196 -1
- package/src/materials/MeshBasicMaterial.js +24 -0
- package/src/materials/MeshDepthMaterial.js +10 -0
- package/src/materials/MeshDistanceMaterial.js +10 -0
- package/src/materials/MeshLambertMaterial.js +40 -1
- package/src/materials/MeshMatcapMaterial.js +25 -1
- package/src/materials/MeshNormalMaterial.js +9 -1
- package/src/materials/MeshPhongMaterial.js +40 -1
- package/src/materials/MeshPhysicalMaterial.js +38 -0
- package/src/materials/MeshStandardMaterial.js +42 -1
- package/src/materials/MeshToonMaterial.js +34 -1
- package/src/materials/PointsMaterial.js +7 -0
- package/src/materials/ShaderMaterial.js +86 -0
- package/src/materials/SpriteMaterial.js +7 -0
- package/src/materials/nodes/Line2NodeMaterial.js +378 -322
- package/src/materials/nodes/MeshBasicNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshNormalNodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhongNodeMaterial.js +0 -9
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +0 -30
- package/src/materials/nodes/MeshSSSNodeMaterial.js +0 -13
- package/src/materials/nodes/MeshStandardNodeMaterial.js +0 -11
- package/src/materials/nodes/NodeMaterial.js +115 -71
- package/src/materials/nodes/SpriteNodeMaterial.js +0 -10
- package/src/materials/nodes/manager/NodeMaterialObserver.js +49 -20
- package/src/math/Box3.js +5 -0
- package/src/math/FrustumArray.js +103 -133
- package/src/math/Interpolant.js +1 -1
- package/src/math/MathUtils.js +2 -2
- package/src/math/Matrix3.js +11 -0
- package/src/math/Matrix4.js +28 -3
- package/src/math/Vector2.js +2 -2
- package/src/math/Vector3.js +2 -2
- package/src/math/Vector4.js +2 -2
- package/src/math/interpolants/BezierInterpolant.js +4 -6
- package/src/nodes/Nodes.js +2 -5
- package/src/nodes/TSL.js +8 -6
- package/src/nodes/accessors/Arrays.js +4 -4
- package/src/nodes/accessors/Batch.js +108 -0
- package/src/nodes/accessors/Bitangent.js +2 -2
- package/src/nodes/accessors/BufferAttributeNode.js +13 -2
- package/src/nodes/accessors/Camera.js +7 -7
- package/src/nodes/accessors/ClippingNode.js +1 -1
- package/src/nodes/accessors/Instance.js +264 -0
- package/src/nodes/accessors/MaterialNode.js +18 -2
- package/src/nodes/accessors/MaterialProperties.js +4 -3
- package/src/nodes/accessors/{MorphNode.js → Morph.js} +99 -112
- package/src/nodes/accessors/Normal.js +13 -13
- package/src/nodes/accessors/Position.js +5 -1
- package/src/nodes/accessors/ReferenceNode.js +1 -0
- package/src/nodes/accessors/ReflectVector.js +3 -3
- package/src/nodes/accessors/SceneProperties.js +1 -1
- package/src/nodes/accessors/Skinning.js +263 -0
- package/src/nodes/accessors/StorageBufferNode.js +2 -2
- package/src/nodes/accessors/StorageTexture3DNode.js +100 -0
- package/src/nodes/accessors/StorageTextureNode.js +39 -7
- package/src/nodes/accessors/Tangent.js +4 -4
- package/src/nodes/accessors/TextureNode.js +60 -5
- package/src/nodes/code/FunctionNode.js +2 -16
- package/src/nodes/core/MRTNode.js +7 -2
- package/src/nodes/core/Node.js +39 -2
- package/src/nodes/core/NodeBuilder.js +201 -41
- package/src/nodes/core/NodeUtils.js +13 -13
- package/src/nodes/core/OutputStructNode.js +1 -1
- package/src/nodes/core/OverrideContextNode.js +153 -0
- package/src/nodes/core/PropertyNode.js +51 -5
- package/src/nodes/core/StackNode.js +56 -34
- package/src/nodes/core/StructNode.js +4 -6
- package/src/nodes/core/StructTypeNode.js +6 -6
- package/src/nodes/core/VarNode.js +8 -0
- package/src/nodes/core/VaryingNode.js +12 -2
- package/src/nodes/display/BlendModes.js +1 -41
- package/src/nodes/display/BumpMapNode.js +6 -1
- package/src/nodes/display/ColorAdjustment.js +10 -9
- package/src/nodes/display/FrontFacingNode.js +38 -9
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +35 -43
- package/src/nodes/display/PremultiplyAlphaFunctions.js +39 -0
- package/src/nodes/display/RenderOutputNode.js +12 -3
- package/src/nodes/functions/VolumetricLightingModel.js +40 -7
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +1 -1
- package/src/nodes/lighting/EnvironmentNode.js +2 -2
- package/src/nodes/lighting/IESSpotLightNode.js +40 -2
- package/src/nodes/lighting/LightingContextNode.js +10 -2
- package/src/nodes/lighting/LightsNode.js +90 -37
- package/src/nodes/lighting/PointShadowNode.js +6 -1
- package/src/nodes/lighting/ShadowFilterNode.js +21 -52
- package/src/nodes/lighting/ShadowNode.js +34 -14
- package/src/nodes/materialx/lib/mx_noise.js +2 -2
- package/src/nodes/math/ConditionalNode.js +3 -3
- package/src/nodes/math/MathNode.js +39 -11
- package/src/nodes/math/OperatorNode.js +23 -23
- package/src/nodes/parsers/GLSLNodeFunction.js +1 -1
- package/src/nodes/pmrem/PMREMNode.js +33 -2
- package/src/nodes/tsl/TSLCore.js +63 -18
- package/src/nodes/utils/EquirectUV.js +30 -5
- package/src/nodes/utils/FunctionOverloadingNode.js +1 -1
- package/src/nodes/utils/Packing.js +35 -4
- package/src/nodes/utils/RTTNode.js +40 -24
- package/src/nodes/utils/ReflectorNode.js +1 -0
- package/src/nodes/utils/StorageArrayElementNode.js +1 -1
- package/src/objects/BatchedMesh.js +22 -14
- package/src/objects/InstancedMesh.js +0 -11
- package/src/objects/Skeleton.js +0 -9
- package/src/renderers/WebGLRenderer.js +19 -15
- package/src/renderers/common/Backend.js +49 -5
- package/src/renderers/common/Bindings.js +114 -45
- package/src/renderers/common/Buffer.js +9 -0
- package/src/renderers/common/ClippingContext.js +10 -2
- package/src/renderers/common/Info.js +63 -22
- package/src/renderers/common/Lighting.js +53 -5
- package/src/renderers/common/RenderList.js +41 -4
- package/src/renderers/common/RenderObject.js +73 -13
- package/src/renderers/common/Renderer.js +281 -108
- package/src/renderers/common/Sampler.js +16 -48
- package/src/renderers/common/Textures.js +32 -5
- package/src/renderers/common/TimestampQueryPool.js +1 -1
- package/src/renderers/common/UniformsGroup.js +31 -9
- package/src/renderers/common/XRManager.js +340 -22
- package/src/renderers/common/extras/PMREMGenerator.js +15 -38
- package/src/renderers/common/nodes/NodeBuilderState.js +9 -1
- package/src/renderers/common/nodes/NodeLibrary.js +4 -4
- package/src/renderers/common/nodes/NodeManager.js +63 -14
- package/src/renderers/common/nodes/NodeUniformBuffer.js +13 -0
- package/src/renderers/shaders/ShaderChunk/common.glsl.js +13 -4
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +0 -6
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/normal_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderLib/distance.glsl.js +1 -1
- package/src/renderers/webgl/WebGLOutput.js +2 -1
- package/src/renderers/webgl/WebGLProgram.js +5 -4
- package/src/renderers/webgl/WebGLPrograms.js +12 -5
- package/src/renderers/webgl/WebGLRenderLists.js +9 -1
- package/src/renderers/webgl/WebGLShaderCache.js +5 -11
- package/src/renderers/webgl/WebGLTextures.js +20 -7
- package/src/renderers/webgl/WebGLUniformsGroups.js +66 -38
- package/src/renderers/webgl-fallback/WebGLBackend.js +84 -25
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +138 -8
- package/src/renderers/webgl-fallback/utils/WebGLAttributeUtils.js +1 -1
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +52 -22
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +4 -2
- package/src/renderers/webgpu/WebGPUBackend.js +480 -169
- package/src/renderers/webgpu/descriptors/GPUBindGroupDescriptor.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUBufferDescriptor.js +57 -0
- package/src/renderers/webgpu/descriptors/GPUCommandEncoderDescriptor.js +30 -0
- package/src/renderers/webgpu/descriptors/GPUComputePassDescriptor.js +38 -0
- package/src/renderers/webgpu/descriptors/GPUComputePipelineDescriptor.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUCopyExternalImageDestInfo.js +47 -0
- package/src/renderers/webgpu/descriptors/GPUCopyExternalImageSourceInfo.js +50 -0
- package/src/renderers/webgpu/descriptors/GPUExtent3D.js +51 -0
- package/src/renderers/webgpu/descriptors/GPUPipelineLayoutDescriptor.js +39 -0
- package/src/renderers/webgpu/descriptors/GPUQuerySetDescriptor.js +47 -0
- package/src/renderers/webgpu/descriptors/GPURenderBundleEncoderDescriptor.js +74 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassColorAttachment.js +72 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassDepthStencilAttachment.js +99 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassDescriptor.js +72 -0
- package/src/renderers/webgpu/descriptors/GPURenderPassTimestampWrites.js +49 -0
- package/src/renderers/webgpu/descriptors/GPURenderPipelineDescriptor.js +130 -0
- package/src/renderers/webgpu/descriptors/GPUSamplerDescriptor.js +119 -0
- package/src/renderers/webgpu/descriptors/GPUShaderModuleDescriptor.js +46 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyBufferInfo.js +57 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyBufferLayout.js +48 -0
- package/src/renderers/webgpu/descriptors/GPUTexelCopyTextureInfo.js +61 -0
- package/src/renderers/webgpu/descriptors/GPUTextureDescriptor.js +99 -0
- package/src/renderers/webgpu/descriptors/GPUTextureViewDescriptor.js +108 -0
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +0 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +164 -7
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +98 -38
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +72 -68
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +164 -69
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +158 -95
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +297 -141
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +33 -18
- package/src/renderers/webgpu/utils/WebGPUUtils.js +38 -3
- package/src/textures/DepthTexture.js +1 -1
- package/src/textures/ExternalTexture.js +0 -3
- package/examples/fonts/LICENSE +0 -13
- package/examples/fonts/MPLUSRounded1c/MPLUSRounded1c-Regular.typeface.json.zip +0 -0
- package/examples/fonts/MPLUSRounded1c/OFL.txt +0 -91
- package/examples/fonts/README.md +0 -11
- package/examples/fonts/droid/NOTICE +0 -190
- package/examples/fonts/droid/README.txt +0 -18
- package/examples/fonts/droid/droid_sans_bold.typeface.json +0 -1
- package/examples/fonts/droid/droid_sans_mono_regular.typeface.json +0 -1
- package/examples/fonts/droid/droid_sans_regular.typeface.json +0 -1
- package/examples/fonts/droid/droid_serif_bold.typeface.json +0 -1
- package/examples/fonts/droid/droid_serif_regular.typeface.json +0 -1
- package/examples/fonts/gentilis_bold.typeface.json +0 -1
- package/examples/fonts/gentilis_regular.typeface.json +0 -1
- package/examples/fonts/helvetiker_bold.typeface.json +0 -1
- package/examples/fonts/helvetiker_regular.typeface.json +0 -1
- package/examples/fonts/optimer_bold.typeface.json +0 -1
- package/examples/fonts/optimer_regular.typeface.json +0 -1
- package/examples/fonts/ttf/README.md +0 -9
- package/examples/fonts/ttf/kenpixel.ttf +0 -0
- package/examples/jsm/inspector/extensions/extensions.json +0 -6
- package/examples/jsm/libs/ammo.wasm.js +0 -822
- package/examples/jsm/libs/ammo.wasm.wasm +0 -0
- package/examples/jsm/libs/draco/draco_encoder.js +0 -33
- package/examples/jsm/libs/draco/gltf/draco_encoder.js +0 -33
- package/examples/jsm/libs/lottie_canvas.module.js +0 -14849
- package/examples/jsm/libs/opentype.module.js +0 -14506
- package/examples/jsm/libs/rhino3dm/rhino3dm.js +0 -21
- package/examples/jsm/libs/rhino3dm/rhino3dm.module.js +0 -16
- package/examples/jsm/libs/rhino3dm/rhino3dm.wasm +0 -0
- package/examples/jsm/lighting/TiledLighting.js +0 -42
- package/examples/jsm/tsl/display/AnamorphicNode.js +0 -293
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +0 -442
- package/src/nodes/accessors/BatchNode.js +0 -163
- package/src/nodes/accessors/InstanceNode.js +0 -349
- package/src/nodes/accessors/InstancedMeshNode.js +0 -50
- package/src/nodes/accessors/SkinningNode.js +0 -328
package/src/nodes/core/Node.js
CHANGED
|
@@ -631,7 +631,8 @@ class Node extends EventDispatcher {
|
|
|
631
631
|
* This method is used during the build process of a node and ensures
|
|
632
632
|
* equal nodes are not built multiple times but just once. For example if
|
|
633
633
|
* `attribute( 'uv' )` is used multiple times by the user, the build
|
|
634
|
-
* process makes sure to process just the first node.
|
|
634
|
+
* process makes sure to process just the first node. It also handles
|
|
635
|
+
* node overrides if an override context is set.
|
|
635
636
|
*
|
|
636
637
|
* @param {NodeBuilder} builder - The current node builder.
|
|
637
638
|
* @return {Node} The shared node if possible. Otherwise `this` is returned.
|
|
@@ -641,7 +642,43 @@ class Node extends EventDispatcher {
|
|
|
641
642
|
const hash = this.getHash( builder );
|
|
642
643
|
const nodeFromHash = builder.getNodeFromHash( hash );
|
|
643
644
|
|
|
644
|
-
|
|
645
|
+
let sharedNode = null;
|
|
646
|
+
|
|
647
|
+
if ( nodeFromHash && nodeFromHash !== this ) {
|
|
648
|
+
|
|
649
|
+
sharedNode = nodeFromHash;
|
|
650
|
+
|
|
651
|
+
} else if ( builder.context.overrideNodes ) {
|
|
652
|
+
|
|
653
|
+
const callback = builder.context.overrideNodes.get( this );
|
|
654
|
+
|
|
655
|
+
if ( callback ) {
|
|
656
|
+
|
|
657
|
+
const nodeData = builder.getDataFromNode( this );
|
|
658
|
+
|
|
659
|
+
if ( nodeData.isOverwritten !== true ) {
|
|
660
|
+
|
|
661
|
+
nodeData.isOverwritten = true;
|
|
662
|
+
|
|
663
|
+
// cancel the override for use the same node inside the callback
|
|
664
|
+
|
|
665
|
+
sharedNode = callback( builder ).overrideNode( this, null );
|
|
666
|
+
|
|
667
|
+
nodeData.sharedNode = sharedNode;
|
|
668
|
+
|
|
669
|
+
} else {
|
|
670
|
+
|
|
671
|
+
// avoid recursive override calls
|
|
672
|
+
|
|
673
|
+
sharedNode = nodeData.sharedNode;
|
|
674
|
+
|
|
675
|
+
}
|
|
676
|
+
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
return sharedNode || this;
|
|
645
682
|
|
|
646
683
|
}
|
|
647
684
|
|
|
@@ -23,7 +23,7 @@ import CubeRenderTarget from '../../renderers/common/CubeRenderTarget.js';
|
|
|
23
23
|
|
|
24
24
|
import BindGroup from '../../renderers/common/BindGroup.js';
|
|
25
25
|
|
|
26
|
-
import { REVISION, IntType, UnsignedIntType, LinearFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, LinearMipmapLinearFilter, NormalBlending } from '../../constants.js';
|
|
26
|
+
import { REVISION, IntType, UnsignedIntType, LinearFilter, LinearMipmapNearestFilter, NearestMipmapLinearFilter, LinearMipmapLinearFilter, NormalBlending, RedFormat, RGFormat, RGBFormat, RedIntegerFormat, RGIntegerFormat, RGBIntegerFormat } from '../../constants.js';
|
|
27
27
|
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
28
28
|
import { Color } from '../../math/Color.js';
|
|
29
29
|
import { Vector2 } from '../../math/Vector2.js';
|
|
@@ -35,6 +35,7 @@ import { warn, error, yieldToMain } from '../../utils.js';
|
|
|
35
35
|
let _id = 0;
|
|
36
36
|
|
|
37
37
|
const _bindingGroupsCache = new WeakMap();
|
|
38
|
+
const _functionNodeCache = new WeakMap();
|
|
38
39
|
|
|
39
40
|
const sharedNodeData = new WeakMap();
|
|
40
41
|
|
|
@@ -48,7 +49,7 @@ const typeFromArray = new Map( [
|
|
|
48
49
|
[ Float32Array, 'float' ]
|
|
49
50
|
] );
|
|
50
51
|
|
|
51
|
-
const
|
|
52
|
+
const _toFloat = ( value ) => {
|
|
52
53
|
|
|
53
54
|
if ( /e/g.test( value ) ) {
|
|
54
55
|
|
|
@@ -64,6 +65,28 @@ const toFloat = ( value ) => {
|
|
|
64
65
|
|
|
65
66
|
};
|
|
66
67
|
|
|
68
|
+
const _checkWriteUsage = ( data ) => {
|
|
69
|
+
|
|
70
|
+
if ( data.writeUsageCount > 0 ) return true;
|
|
71
|
+
|
|
72
|
+
if ( data.subBuildsCache !== undefined ) {
|
|
73
|
+
|
|
74
|
+
for ( const subBuild in data.subBuildsCache ) {
|
|
75
|
+
|
|
76
|
+
if ( _checkWriteUsage( data.subBuildsCache[ subBuild ] ) ) {
|
|
77
|
+
|
|
78
|
+
return true;
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return false;
|
|
87
|
+
|
|
88
|
+
};
|
|
89
|
+
|
|
67
90
|
/**
|
|
68
91
|
* Base class for builders which generate a shader program based
|
|
69
92
|
* on a 3D object and its node material definition.
|
|
@@ -134,9 +157,9 @@ class NodeBuilder {
|
|
|
134
157
|
* A list of all nodes the builder is processing
|
|
135
158
|
* for this 3D object.
|
|
136
159
|
*
|
|
137
|
-
* @type {
|
|
160
|
+
* @type {Set<Node>}
|
|
138
161
|
*/
|
|
139
|
-
this.nodes =
|
|
162
|
+
this.nodes = new Set();
|
|
140
163
|
|
|
141
164
|
/**
|
|
142
165
|
* A list of all nodes the builder is processing in sequential order.
|
|
@@ -144,9 +167,9 @@ class NodeBuilder {
|
|
|
144
167
|
* This is used to determine the update order of nodes, which is important for
|
|
145
168
|
* {@link NodeUpdateType#UPDATE_BEFORE} and {@link NodeUpdateType#UPDATE_AFTER}.
|
|
146
169
|
*
|
|
147
|
-
* @type {
|
|
170
|
+
* @type {Set<Node>}
|
|
148
171
|
*/
|
|
149
|
-
this.sequentialNodes =
|
|
172
|
+
this.sequentialNodes = new Set();
|
|
150
173
|
|
|
151
174
|
/**
|
|
152
175
|
* A list of all nodes which {@link Node#update} method should be executed.
|
|
@@ -215,6 +238,14 @@ class NodeBuilder {
|
|
|
215
238
|
*/
|
|
216
239
|
this.clippingContext = null;
|
|
217
240
|
|
|
241
|
+
/**
|
|
242
|
+
* Whether the built material uses hardware clipping or not.
|
|
243
|
+
*
|
|
244
|
+
* @type {boolean}
|
|
245
|
+
* @default false
|
|
246
|
+
*/
|
|
247
|
+
this.hardwareClipping = false;
|
|
248
|
+
|
|
218
249
|
/**
|
|
219
250
|
* The generated vertex shader.
|
|
220
251
|
*
|
|
@@ -530,7 +561,62 @@ class NodeBuilder {
|
|
|
530
561
|
*/
|
|
531
562
|
includes( node ) {
|
|
532
563
|
|
|
533
|
-
return this.nodes.
|
|
564
|
+
return this.nodes.has( node );
|
|
565
|
+
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
/**
|
|
569
|
+
* Returns the type of the color output based on the renderer's render target.
|
|
570
|
+
*
|
|
571
|
+
* @param {number} [index=0] - The index of the render target texture.
|
|
572
|
+
* @return {string} The type.
|
|
573
|
+
*/
|
|
574
|
+
getOutputType( index = 0 ) {
|
|
575
|
+
|
|
576
|
+
let type = 'vec4';
|
|
577
|
+
|
|
578
|
+
const renderTarget = this.renderer.getRenderTarget();
|
|
579
|
+
|
|
580
|
+
if ( renderTarget !== null ) {
|
|
581
|
+
|
|
582
|
+
const renderTargetType = renderTarget.textures[ index ].type;
|
|
583
|
+
const renderTargetFormat = renderTarget.textures[ index ].format;
|
|
584
|
+
|
|
585
|
+
let typeStr = 'vec';
|
|
586
|
+
|
|
587
|
+
if ( renderTargetType === IntType ) {
|
|
588
|
+
|
|
589
|
+
typeStr = 'ivec';
|
|
590
|
+
|
|
591
|
+
} else if ( renderTargetType === UnsignedIntType ) {
|
|
592
|
+
|
|
593
|
+
typeStr = 'uvec';
|
|
594
|
+
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
if ( renderTargetFormat === RedFormat || renderTargetFormat === RedIntegerFormat ) {
|
|
598
|
+
|
|
599
|
+
if ( renderTargetType === IntType ) type = 'int';
|
|
600
|
+
else if ( renderTargetType === UnsignedIntType ) type = 'uint';
|
|
601
|
+
else type = 'float';
|
|
602
|
+
|
|
603
|
+
} else if ( renderTargetFormat === RGFormat || renderTargetFormat === RGIntegerFormat ) {
|
|
604
|
+
|
|
605
|
+
type = `${ typeStr }2`;
|
|
606
|
+
|
|
607
|
+
} else if ( renderTargetFormat === RGBFormat || renderTargetFormat === RGBIntegerFormat ) {
|
|
608
|
+
|
|
609
|
+
type = `${ typeStr }3`;
|
|
610
|
+
|
|
611
|
+
} else {
|
|
612
|
+
|
|
613
|
+
type = `${ typeStr }4`;
|
|
614
|
+
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
return type;
|
|
534
620
|
|
|
535
621
|
}
|
|
536
622
|
|
|
@@ -760,9 +846,9 @@ class NodeBuilder {
|
|
|
760
846
|
*/
|
|
761
847
|
addNode( node ) {
|
|
762
848
|
|
|
763
|
-
if ( this.nodes.
|
|
849
|
+
if ( this.nodes.has( node ) === false ) {
|
|
764
850
|
|
|
765
|
-
this.nodes.
|
|
851
|
+
this.nodes.add( node );
|
|
766
852
|
|
|
767
853
|
this.setHashNode( node, node.getHash( this ) );
|
|
768
854
|
|
|
@@ -784,11 +870,7 @@ class NodeBuilder {
|
|
|
784
870
|
|
|
785
871
|
if ( updateBeforeType !== NodeUpdateType.NONE || updateAfterType !== NodeUpdateType.NONE ) {
|
|
786
872
|
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
this.sequentialNodes.push( node );
|
|
790
|
-
|
|
791
|
-
}
|
|
873
|
+
this.sequentialNodes.add( node );
|
|
792
874
|
|
|
793
875
|
}
|
|
794
876
|
|
|
@@ -899,7 +981,7 @@ class NodeBuilder {
|
|
|
899
981
|
|
|
900
982
|
if ( lastChain !== node ) {
|
|
901
983
|
|
|
902
|
-
throw new Error( 'NodeBuilder: Invalid node chaining!' );
|
|
984
|
+
throw new Error( 'THREE.NodeBuilder: Invalid node chaining!' );
|
|
903
985
|
|
|
904
986
|
}
|
|
905
987
|
|
|
@@ -1148,6 +1230,17 @@ class NodeBuilder {
|
|
|
1148
1230
|
|
|
1149
1231
|
}
|
|
1150
1232
|
|
|
1233
|
+
/**
|
|
1234
|
+
* Returns whether the builder is currently in an assignment context.
|
|
1235
|
+
*
|
|
1236
|
+
* @return {boolean} Whether the builder is in an assignment context.
|
|
1237
|
+
*/
|
|
1238
|
+
isContextAssign() {
|
|
1239
|
+
|
|
1240
|
+
return this.context.assign === true;
|
|
1241
|
+
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1151
1244
|
/**
|
|
1152
1245
|
* Calling this method increases the usage count for the given node by one.
|
|
1153
1246
|
*
|
|
@@ -1159,10 +1252,50 @@ class NodeBuilder {
|
|
|
1159
1252
|
const nodeData = this.getDataFromNode( node );
|
|
1160
1253
|
nodeData.usageCount = nodeData.usageCount === undefined ? 1 : nodeData.usageCount + 1;
|
|
1161
1254
|
|
|
1255
|
+
if ( this.isContextAssign() ) {
|
|
1256
|
+
|
|
1257
|
+
nodeData.writeUsageCount = nodeData.writeUsageCount === undefined ? 1 : nodeData.writeUsageCount + 1;
|
|
1258
|
+
|
|
1259
|
+
} else {
|
|
1260
|
+
|
|
1261
|
+
nodeData.readUsageCount = nodeData.readUsageCount === undefined ? 1 : nodeData.readUsageCount + 1;
|
|
1262
|
+
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1162
1265
|
return nodeData.usageCount;
|
|
1163
1266
|
|
|
1164
1267
|
}
|
|
1165
1268
|
|
|
1269
|
+
/**
|
|
1270
|
+
* Returns whether the given node has been written to in any shader stage.
|
|
1271
|
+
*
|
|
1272
|
+
* @param {Node} node - The node to check.
|
|
1273
|
+
* @return {boolean} Whether the node has been written to.
|
|
1274
|
+
*/
|
|
1275
|
+
hasWriteUsage( node ) {
|
|
1276
|
+
|
|
1277
|
+
const refNode = node.getShared( this );
|
|
1278
|
+
const cache = refNode.isGlobal( this ) ? this.globalCache : this.cache;
|
|
1279
|
+
const nodeData = cache.getData( refNode );
|
|
1280
|
+
|
|
1281
|
+
if ( nodeData !== undefined ) {
|
|
1282
|
+
|
|
1283
|
+
for ( const shaderStage in nodeData ) {
|
|
1284
|
+
|
|
1285
|
+
if ( _checkWriteUsage( nodeData[ shaderStage ] ) ) {
|
|
1286
|
+
|
|
1287
|
+
return true;
|
|
1288
|
+
|
|
1289
|
+
}
|
|
1290
|
+
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
return false;
|
|
1296
|
+
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1166
1299
|
/**
|
|
1167
1300
|
* Generates a texture sample shader string for the given texture data.
|
|
1168
1301
|
*
|
|
@@ -1296,11 +1429,11 @@ class NodeBuilder {
|
|
|
1296
1429
|
|
|
1297
1430
|
}
|
|
1298
1431
|
|
|
1299
|
-
if ( type === 'float' ) return
|
|
1432
|
+
if ( type === 'float' ) return _toFloat( value );
|
|
1300
1433
|
if ( type === 'int' ) return `${ Math.round( value ) }`;
|
|
1301
1434
|
if ( type === 'uint' ) return value >= 0 ? `${ Math.round( value ) }u` : '0u';
|
|
1302
1435
|
if ( type === 'bool' ) return value ? 'true' : 'false';
|
|
1303
|
-
if ( type === 'color' ) return `${ this.getType( 'vec3' ) }( ${
|
|
1436
|
+
if ( type === 'color' ) return `${ this.getType( 'vec3' ) }( ${ _toFloat( value.r ) }, ${ _toFloat( value.g ) }, ${ _toFloat( value.b ) } )`;
|
|
1304
1437
|
|
|
1305
1438
|
const typeLength = this.getTypeLength( type );
|
|
1306
1439
|
|
|
@@ -1330,7 +1463,7 @@ class NodeBuilder {
|
|
|
1330
1463
|
|
|
1331
1464
|
}
|
|
1332
1465
|
|
|
1333
|
-
throw new Error( `NodeBuilder: Type '${type}' not found in generate constant attempt.` );
|
|
1466
|
+
throw new Error( `THREE.NodeBuilder: Type '${type}' not found in generate constant attempt.` );
|
|
1334
1467
|
|
|
1335
1468
|
}
|
|
1336
1469
|
|
|
@@ -1468,12 +1601,10 @@ class NodeBuilder {
|
|
|
1468
1601
|
|
|
1469
1602
|
const type = texture.type;
|
|
1470
1603
|
|
|
1471
|
-
if ( texture.
|
|
1472
|
-
|
|
1473
|
-
if ( type === IntType ) return 'int';
|
|
1474
|
-
if ( type === UnsignedIntType ) return 'uint';
|
|
1604
|
+
if ( texture.isDepthTexture === true ) return 'float';
|
|
1475
1605
|
|
|
1476
|
-
|
|
1606
|
+
if ( type === IntType ) return 'int';
|
|
1607
|
+
if ( type === UnsignedIntType ) return 'uint';
|
|
1477
1608
|
|
|
1478
1609
|
return 'float';
|
|
1479
1610
|
|
|
@@ -1699,7 +1830,7 @@ class NodeBuilder {
|
|
|
1699
1830
|
|
|
1700
1831
|
} else {
|
|
1701
1832
|
|
|
1702
|
-
throw new Error( 'NodeBuilder: Invalid active stack removal.' );
|
|
1833
|
+
throw new Error( 'THREE.NodeBuilder: Invalid active stack removal.' );
|
|
1703
1834
|
|
|
1704
1835
|
}
|
|
1705
1836
|
|
|
@@ -1798,6 +1929,8 @@ class NodeBuilder {
|
|
|
1798
1929
|
|
|
1799
1930
|
let data = nodeData[ shaderStage ];
|
|
1800
1931
|
|
|
1932
|
+
if ( this.subBuildLayers.length === 0 ) return data;
|
|
1933
|
+
|
|
1801
1934
|
const subBuilds = nodeData.any ? nodeData.any.subBuilds : null;
|
|
1802
1935
|
const subBuild = this.getClosestSubBuild( subBuilds );
|
|
1803
1936
|
|
|
@@ -1839,9 +1972,10 @@ class NodeBuilder {
|
|
|
1839
1972
|
*
|
|
1840
1973
|
* @param {BufferAttributeNode} node - The buffer attribute node.
|
|
1841
1974
|
* @param {string} type - The node type.
|
|
1975
|
+
* @param {?string} [name=null] - The name of the buffer attribute.
|
|
1842
1976
|
* @return {NodeAttribute} The node attribute.
|
|
1843
1977
|
*/
|
|
1844
|
-
getBufferAttributeFromNode( node, type ) {
|
|
1978
|
+
getBufferAttributeFromNode( node, type, name = null ) {
|
|
1845
1979
|
|
|
1846
1980
|
const nodeData = this.getDataFromNode( node, 'vertex' );
|
|
1847
1981
|
|
|
@@ -1851,7 +1985,13 @@ class NodeBuilder {
|
|
|
1851
1985
|
|
|
1852
1986
|
const index = this.uniforms.index ++;
|
|
1853
1987
|
|
|
1854
|
-
|
|
1988
|
+
if ( name === null ) {
|
|
1989
|
+
|
|
1990
|
+
name = 'nodeAttribute' + index;
|
|
1991
|
+
|
|
1992
|
+
}
|
|
1993
|
+
|
|
1994
|
+
bufferAttribute = new NodeAttribute( name, type, node );
|
|
1855
1995
|
|
|
1856
1996
|
this.bufferAttributes.push( bufferAttribute );
|
|
1857
1997
|
|
|
@@ -2128,28 +2268,29 @@ class NodeBuilder {
|
|
|
2128
2268
|
const shaderStage = this.shaderStage;
|
|
2129
2269
|
const declarations = this.declarations[ shaderStage ] || ( this.declarations[ shaderStage ] = {} );
|
|
2130
2270
|
|
|
2131
|
-
const
|
|
2271
|
+
const baseName = node.name;
|
|
2132
2272
|
|
|
2273
|
+
let name = baseName;
|
|
2274
|
+
let property = this.getPropertyName( node );
|
|
2133
2275
|
let index = 1;
|
|
2134
|
-
let name = property;
|
|
2135
2276
|
|
|
2136
2277
|
// Automatically renames the property if the name is already in use.
|
|
2137
2278
|
|
|
2138
|
-
while ( declarations[
|
|
2279
|
+
while ( declarations[ property ] !== undefined ) {
|
|
2139
2280
|
|
|
2140
|
-
name =
|
|
2281
|
+
name = baseName + '_' + index ++;
|
|
2282
|
+
node.name = name;
|
|
2283
|
+
property = this.getPropertyName( node );
|
|
2141
2284
|
|
|
2142
2285
|
}
|
|
2143
2286
|
|
|
2144
|
-
if (
|
|
2145
|
-
|
|
2146
|
-
node.name = name;
|
|
2287
|
+
if ( name !== baseName ) {
|
|
2147
2288
|
|
|
2148
|
-
warn( `TSL: Declaration name '${
|
|
2289
|
+
warn( `TSL: Declaration name '${ baseName }' of '${ node.type }' already in use. Renamed to '${ name }'.` );
|
|
2149
2290
|
|
|
2150
2291
|
}
|
|
2151
2292
|
|
|
2152
|
-
declarations[
|
|
2293
|
+
declarations[ property ] = node;
|
|
2153
2294
|
|
|
2154
2295
|
}
|
|
2155
2296
|
|
|
@@ -2371,15 +2512,34 @@ class NodeBuilder {
|
|
|
2371
2512
|
*/
|
|
2372
2513
|
buildFunctionNode( shaderNode ) {
|
|
2373
2514
|
|
|
2374
|
-
const
|
|
2515
|
+
const backend = this.renderer.backend;
|
|
2516
|
+
|
|
2517
|
+
let cache = _functionNodeCache.get( backend );
|
|
2518
|
+
|
|
2519
|
+
if ( cache === undefined ) {
|
|
2520
|
+
|
|
2521
|
+
cache = new WeakMap();
|
|
2522
|
+
_functionNodeCache.set( backend, cache );
|
|
2523
|
+
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
let fn = cache.get( shaderNode );
|
|
2527
|
+
|
|
2528
|
+
if ( fn === undefined ) {
|
|
2529
|
+
|
|
2530
|
+
fn = new FunctionNode();
|
|
2375
2531
|
|
|
2376
|
-
|
|
2532
|
+
const previous = this.currentFunctionNode;
|
|
2377
2533
|
|
|
2378
|
-
|
|
2534
|
+
this.currentFunctionNode = fn;
|
|
2379
2535
|
|
|
2380
|
-
|
|
2536
|
+
fn.code = this.buildFunctionCode( shaderNode );
|
|
2381
2537
|
|
|
2382
|
-
|
|
2538
|
+
this.currentFunctionNode = previous;
|
|
2539
|
+
|
|
2540
|
+
cache.set( shaderNode, fn );
|
|
2541
|
+
|
|
2542
|
+
}
|
|
2383
2543
|
|
|
2384
2544
|
return fn;
|
|
2385
2545
|
|
|
@@ -3165,7 +3325,7 @@ class NodeBuilder {
|
|
|
3165
3325
|
else if ( type === 'mat4' ) node = new Matrix4NodeUniform( uniformNode );
|
|
3166
3326
|
else {
|
|
3167
3327
|
|
|
3168
|
-
throw new Error( `Uniform "${ type }" not implemented.` );
|
|
3328
|
+
throw new Error( `THREE.NodeBuilder: Uniform "${ type }" not implemented.` );
|
|
3169
3329
|
|
|
3170
3330
|
}
|
|
3171
3331
|
|
|
@@ -148,7 +148,7 @@ export function getTypedArrayFromType( type ) {
|
|
|
148
148
|
*/
|
|
149
149
|
export function getLengthFromType( type ) {
|
|
150
150
|
|
|
151
|
-
if ( /float|int|uint/.test( type ) ) return 1;
|
|
151
|
+
if ( /float|int|uint|bool/.test( type ) ) return 1;
|
|
152
152
|
if ( /vec2/.test( type ) ) return 2;
|
|
153
153
|
if ( /vec3/.test( type ) ) return 3;
|
|
154
154
|
if ( /vec4/.test( type ) ) return 4;
|
|
@@ -161,16 +161,16 @@ export function getLengthFromType( type ) {
|
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
/**
|
|
164
|
-
* Returns the gpu memory length for the given data type.
|
|
164
|
+
* Returns the gpu memory length for the given data type in 4-byte elements.
|
|
165
165
|
*
|
|
166
166
|
* @private
|
|
167
167
|
* @method
|
|
168
168
|
* @param {string} type - The data type.
|
|
169
|
-
* @return {number} The length.
|
|
169
|
+
* @return {number} The memory length in 4-byte elements.
|
|
170
170
|
*/
|
|
171
171
|
export function getMemoryLengthFromType( type ) {
|
|
172
172
|
|
|
173
|
-
if ( /float|int|uint/.test( type ) ) return 1;
|
|
173
|
+
if ( /float|int|uint|bool/.test( type ) ) return 1;
|
|
174
174
|
if ( /vec2/.test( type ) ) return 2;
|
|
175
175
|
if ( /vec3/.test( type ) ) return 3;
|
|
176
176
|
if ( /vec4/.test( type ) ) return 4;
|
|
@@ -183,22 +183,22 @@ export function getMemoryLengthFromType( type ) {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
/**
|
|
186
|
-
* Returns the alignment requirement for the given data type.
|
|
186
|
+
* Returns the alignment requirement for the given data type in 4-byte elements.
|
|
187
187
|
*
|
|
188
188
|
* @private
|
|
189
189
|
* @method
|
|
190
190
|
* @param {string} type - The data type.
|
|
191
|
-
* @return {number} The alignment requirement in
|
|
191
|
+
* @return {number} The alignment requirement in 4-byte elements.
|
|
192
192
|
*/
|
|
193
193
|
export function getAlignmentFromType( type ) {
|
|
194
194
|
|
|
195
|
-
if ( /float|int|uint/.test( type ) ) return
|
|
196
|
-
if ( /vec2/.test( type ) ) return
|
|
197
|
-
if ( /vec3/.test( type ) ) return
|
|
198
|
-
if ( /vec4/.test( type ) ) return
|
|
199
|
-
if ( /mat2/.test( type ) ) return
|
|
200
|
-
if ( /mat3/.test( type ) ) return
|
|
201
|
-
if ( /mat4/.test( type ) ) return
|
|
195
|
+
if ( /float|int|uint|bool/.test( type ) ) return 1;
|
|
196
|
+
if ( /vec2/.test( type ) ) return 2;
|
|
197
|
+
if ( /vec3/.test( type ) ) return 4;
|
|
198
|
+
if ( /vec4/.test( type ) ) return 4;
|
|
199
|
+
if ( /mat2/.test( type ) ) return 2;
|
|
200
|
+
if ( /mat3/.test( type ) ) return 4;
|
|
201
|
+
if ( /mat4/.test( type ) ) return 4;
|
|
202
202
|
|
|
203
203
|
error( `TSL: Unsupported type: ${ type }`, new StackTrace() );
|
|
204
204
|
|
|
@@ -80,7 +80,7 @@ class OutputStructNode extends Node {
|
|
|
80
80
|
|
|
81
81
|
for ( let i = 0; i < members.length; i ++ ) {
|
|
82
82
|
|
|
83
|
-
const snippet = members[ i ].build( builder );
|
|
83
|
+
const snippet = members[ i ].build( builder, nodeData.membersLayout[ i ].type );
|
|
84
84
|
|
|
85
85
|
builder.addLineFlowCode( `${ structPrefix }m${ i } = ${ snippet }`, this );
|
|
86
86
|
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import ContextNode from './ContextNode.js';
|
|
2
|
+
import { addMethodChaining } from '../tsl/TSLCore.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A specialized context node designed to override specific target nodes within a
|
|
6
|
+
* node sub-graph or flow. This allows replacing specific inputs (e.g., normal
|
|
7
|
+
* and position vectors) dynamically during compilation for a specific flow node,
|
|
8
|
+
* without having to reconstruct or duplicate the source nodes.
|
|
9
|
+
*
|
|
10
|
+
* ```js
|
|
11
|
+
* // Method chaining example:
|
|
12
|
+
* node.overrideNode( positionLocal, () => positionLocal.add( vec3( 1, 0, 0 ) ) );
|
|
13
|
+
*
|
|
14
|
+
* // Context assignment example:
|
|
15
|
+
* material.contextNode = overrideNode( positionLocal, () => positionLocal.add( vec3( 1, 0, 0 ) ) );
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @augments ContextNode
|
|
19
|
+
*/
|
|
20
|
+
class OverrideContextNode extends ContextNode {
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Returns the type of the node.
|
|
24
|
+
*
|
|
25
|
+
* @type {string}
|
|
26
|
+
* @readonly
|
|
27
|
+
* @static
|
|
28
|
+
*/
|
|
29
|
+
static get type() {
|
|
30
|
+
|
|
31
|
+
return 'OverrideContextNode';
|
|
32
|
+
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Constructs a new override context node.
|
|
37
|
+
*
|
|
38
|
+
* @param {Map<Node, Function>} overrideNodes - A map mapping target nodes to their respective override callback functions.
|
|
39
|
+
* @param {Node|null} [flowNode=null] - The node whose context should be modified.
|
|
40
|
+
*/
|
|
41
|
+
constructor( overrideNodes, flowNode = null ) {
|
|
42
|
+
|
|
43
|
+
super( flowNode, {
|
|
44
|
+
overrideNodes
|
|
45
|
+
} );
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* This flag can be used for type testing.
|
|
49
|
+
*
|
|
50
|
+
* @type {boolean}
|
|
51
|
+
* @readonly
|
|
52
|
+
* @default true
|
|
53
|
+
*/
|
|
54
|
+
this.isOverrideContextNode = true;
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Gathers the context data from all parent context nodes by traversing the hierarchy,
|
|
60
|
+
* merging the `overrideNodes` maps from all encountered `OverrideContextNode` instances.
|
|
61
|
+
*
|
|
62
|
+
* @return {Object} The gathered context data, containing the merged `overrideNodes` map.
|
|
63
|
+
*/
|
|
64
|
+
getFlowContextData() {
|
|
65
|
+
|
|
66
|
+
const children = [];
|
|
67
|
+
|
|
68
|
+
this.traverse( ( node ) => {
|
|
69
|
+
|
|
70
|
+
if ( node.isOverrideContextNode === true ) {
|
|
71
|
+
|
|
72
|
+
children.push( node.value.overrideNodes );
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
} );
|
|
77
|
+
|
|
78
|
+
const overrideNodes = new Map( children.flatMap( ( map ) => Array.from( map.entries() ) ) );
|
|
79
|
+
|
|
80
|
+
const data = super.getFlowContextData();
|
|
81
|
+
data.overrideNodes = overrideNodes;
|
|
82
|
+
|
|
83
|
+
return data;
|
|
84
|
+
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export default OverrideContextNode;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* TSL function for creating an `OverrideContextNode` to override a single target node.
|
|
93
|
+
*
|
|
94
|
+
* ```js
|
|
95
|
+
* material.contextNode = overrideNode( positionLocal, ( builder ) => positionLocal.add( vec3( 1, 0, 0 ) ) );
|
|
96
|
+
* ```
|
|
97
|
+
*
|
|
98
|
+
* @tsl
|
|
99
|
+
* @function
|
|
100
|
+
* @param {Node} targetNode - The target node that should be overridden.
|
|
101
|
+
* @param {Function|Node|null} [callback=null] - A callback function returning the overriding node (which receives the builder as its argument), or the overriding node itself.
|
|
102
|
+
* @param {Node|null} [flowNode=null] - The node whose context should be modified.
|
|
103
|
+
* @return {OverrideContextNode} The created override context node.
|
|
104
|
+
*/
|
|
105
|
+
export function overrideNode( targetNode, callback = null, flowNode = null ) {
|
|
106
|
+
|
|
107
|
+
if ( callback && callback.isNode ) {
|
|
108
|
+
|
|
109
|
+
const node = callback;
|
|
110
|
+
|
|
111
|
+
callback = () => node;
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return new OverrideContextNode( new Map( [[ targetNode, callback ]] ), flowNode );
|
|
116
|
+
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
addMethodChaining( 'overrideNode', ( flowNode, node, callback ) => overrideNode( node, callback, flowNode ) );
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* TSL function for creating an `OverrideContextNode` to override multiple target nodes.
|
|
123
|
+
*
|
|
124
|
+
* ```js
|
|
125
|
+
* material.contextNode = overrideNodes( [
|
|
126
|
+
* [ positionView, customPositionView ],
|
|
127
|
+
* [ positionViewDirection, ( builder ) => customPositionViewDirection ]
|
|
128
|
+
* ] );
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @tsl
|
|
132
|
+
* @function
|
|
133
|
+
* @param {Map<Node, (Function|Node)>|Array<Array<Node|Function|Node>>} overrides - The overrides mapping target nodes to callback functions or overriding nodes.
|
|
134
|
+
* @param {Node|null} [flowNode=null] - The node whose context should be modified.
|
|
135
|
+
* @return {OverrideContextNode} The created override context node.
|
|
136
|
+
*/
|
|
137
|
+
export function overrideNodes( overrides, flowNode = null ) {
|
|
138
|
+
|
|
139
|
+
const overrideNodesMap = new Map();
|
|
140
|
+
|
|
141
|
+
for ( const [ node, value ] of overrides ) {
|
|
142
|
+
|
|
143
|
+
const callback = value !== null ? typeof value === 'function' ? value : () => value : null;
|
|
144
|
+
|
|
145
|
+
overrideNodesMap.set( node, callback );
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return new OverrideContextNode( overrideNodesMap, flowNode );
|
|
150
|
+
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
addMethodChaining( 'overrideNodes', ( flowNode, overrides ) => overrideNodes( overrides, flowNode ) );
|