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
|
@@ -1,442 +0,0 @@
|
|
|
1
|
-
import { DataTexture, FloatType, RGBAFormat, Vector2, Vector3, LightsNode, NodeUpdateType } from 'three/webgpu';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
attributeArray, nodeProxy, int, float, vec2, ivec2, ivec4, uniform, Break, Loop, positionView,
|
|
5
|
-
Fn, If, Return, textureLoad, instanceIndex, screenCoordinate, directPointLight
|
|
6
|
-
} from 'three/tsl';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* TSL function that checks if a circle intersects with an axis-aligned bounding box (AABB).
|
|
10
|
-
*
|
|
11
|
-
* @tsl
|
|
12
|
-
* @function
|
|
13
|
-
* @param {Node<vec2>} circleCenter - The center of the circle.
|
|
14
|
-
* @param {Node<float>} radius - The radius of the circle.
|
|
15
|
-
* @param {Node<vec2>} minBounds - The minimum bounds of the AABB.
|
|
16
|
-
* @param {Node<vec2>} maxBounds - The maximum bounds of the AABB.
|
|
17
|
-
* @return {Node<bool>} True if the circle intersects the AABB.
|
|
18
|
-
*/
|
|
19
|
-
export const circleIntersectsAABB = /*@__PURE__*/ Fn( ( [ circleCenter, radius, minBounds, maxBounds ] ) => {
|
|
20
|
-
|
|
21
|
-
// Find the closest point on the AABB to the circle's center using method chaining
|
|
22
|
-
const closestX = minBounds.x.max( circleCenter.x.min( maxBounds.x ) );
|
|
23
|
-
const closestY = minBounds.y.max( circleCenter.y.min( maxBounds.y ) );
|
|
24
|
-
|
|
25
|
-
// Compute the distance between the circle's center and the closest point
|
|
26
|
-
const distX = circleCenter.x.sub( closestX );
|
|
27
|
-
const distY = circleCenter.y.sub( closestY );
|
|
28
|
-
|
|
29
|
-
// Calculate the squared distance
|
|
30
|
-
const distSquared = distX.mul( distX ).add( distY.mul( distY ) );
|
|
31
|
-
|
|
32
|
-
return distSquared.lessThanEqual( radius.mul( radius ) );
|
|
33
|
-
|
|
34
|
-
} ).setLayout( {
|
|
35
|
-
name: 'circleIntersectsAABB',
|
|
36
|
-
type: 'bool',
|
|
37
|
-
inputs: [
|
|
38
|
-
{ name: 'circleCenter', type: 'vec2' },
|
|
39
|
-
{ name: 'radius', type: 'float' },
|
|
40
|
-
{ name: 'minBounds', type: 'vec2' },
|
|
41
|
-
{ name: 'maxBounds', type: 'vec2' }
|
|
42
|
-
]
|
|
43
|
-
} );
|
|
44
|
-
|
|
45
|
-
const _vector3 = /*@__PURE__*/ new Vector3();
|
|
46
|
-
const _size = /*@__PURE__*/ new Vector2();
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* A custom version of `LightsNode` implementing tiled lighting. This node is used in
|
|
50
|
-
* {@link TiledLighting} to overwrite the renderer's default lighting with
|
|
51
|
-
* a custom implementation.
|
|
52
|
-
*
|
|
53
|
-
* @augments LightsNode
|
|
54
|
-
* @three_import import { tiledLights } from 'three/addons/tsl/lighting/TiledLightsNode.js';
|
|
55
|
-
*/
|
|
56
|
-
class TiledLightsNode extends LightsNode {
|
|
57
|
-
|
|
58
|
-
static get type() {
|
|
59
|
-
|
|
60
|
-
return 'TiledLightsNode';
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Constructs a new tiled lights node.
|
|
66
|
-
*
|
|
67
|
-
* @param {number} [maxLights=1024] - The maximum number of lights.
|
|
68
|
-
* @param {number} [tileSize=32] - The tile size.
|
|
69
|
-
*/
|
|
70
|
-
constructor( maxLights = 1024, tileSize = 32 ) {
|
|
71
|
-
|
|
72
|
-
super();
|
|
73
|
-
|
|
74
|
-
this.materialLights = [];
|
|
75
|
-
this.tiledLights = [];
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* The maximum number of lights.
|
|
79
|
-
*
|
|
80
|
-
* @type {number}
|
|
81
|
-
* @default 1024
|
|
82
|
-
*/
|
|
83
|
-
this.maxLights = maxLights;
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* The tile size.
|
|
87
|
-
*
|
|
88
|
-
* @type {number}
|
|
89
|
-
* @default 32
|
|
90
|
-
*/
|
|
91
|
-
this.tileSize = tileSize;
|
|
92
|
-
|
|
93
|
-
this._bufferSize = null;
|
|
94
|
-
this._lightIndexes = null;
|
|
95
|
-
this._screenTileIndex = null;
|
|
96
|
-
this._compute = null;
|
|
97
|
-
this._lightsTexture = null;
|
|
98
|
-
|
|
99
|
-
this._lightsCount = uniform( 0, 'int' );
|
|
100
|
-
this._tileLightCount = 8;
|
|
101
|
-
this._screenSize = uniform( new Vector2() );
|
|
102
|
-
this._cameraProjectionMatrix = uniform( 'mat4' );
|
|
103
|
-
this._cameraViewMatrix = uniform( 'mat4' );
|
|
104
|
-
|
|
105
|
-
this.updateBeforeType = NodeUpdateType.RENDER;
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
customCacheKey() {
|
|
110
|
-
|
|
111
|
-
return this._compute.getCacheKey() + super.customCacheKey();
|
|
112
|
-
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
updateLightsTexture() {
|
|
116
|
-
|
|
117
|
-
const { _lightsTexture: lightsTexture, tiledLights } = this;
|
|
118
|
-
|
|
119
|
-
const data = lightsTexture.image.data;
|
|
120
|
-
const lineSize = lightsTexture.image.width * 4;
|
|
121
|
-
|
|
122
|
-
this._lightsCount.value = tiledLights.length;
|
|
123
|
-
|
|
124
|
-
for ( let i = 0; i < tiledLights.length; i ++ ) {
|
|
125
|
-
|
|
126
|
-
const light = tiledLights[ i ];
|
|
127
|
-
|
|
128
|
-
// world position
|
|
129
|
-
|
|
130
|
-
_vector3.setFromMatrixPosition( light.matrixWorld );
|
|
131
|
-
|
|
132
|
-
// store data
|
|
133
|
-
|
|
134
|
-
const offset = i * 4;
|
|
135
|
-
|
|
136
|
-
data[ offset + 0 ] = _vector3.x;
|
|
137
|
-
data[ offset + 1 ] = _vector3.y;
|
|
138
|
-
data[ offset + 2 ] = _vector3.z;
|
|
139
|
-
data[ offset + 3 ] = light.distance;
|
|
140
|
-
|
|
141
|
-
data[ lineSize + offset + 0 ] = light.color.r * light.intensity;
|
|
142
|
-
data[ lineSize + offset + 1 ] = light.color.g * light.intensity;
|
|
143
|
-
data[ lineSize + offset + 2 ] = light.color.b * light.intensity;
|
|
144
|
-
data[ lineSize + offset + 3 ] = light.decay;
|
|
145
|
-
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
lightsTexture.needsUpdate = true;
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
updateBefore( frame ) {
|
|
153
|
-
|
|
154
|
-
const { renderer, camera } = frame;
|
|
155
|
-
|
|
156
|
-
this.updateProgram( renderer );
|
|
157
|
-
|
|
158
|
-
this.updateLightsTexture( camera );
|
|
159
|
-
|
|
160
|
-
this._cameraProjectionMatrix.value = camera.projectionMatrix;
|
|
161
|
-
this._cameraViewMatrix.value = camera.matrixWorldInverse;
|
|
162
|
-
|
|
163
|
-
renderer.getDrawingBufferSize( _size );
|
|
164
|
-
this._screenSize.value.copy( _size );
|
|
165
|
-
|
|
166
|
-
renderer.compute( this._compute );
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
setLights( lights ) {
|
|
171
|
-
|
|
172
|
-
const { tiledLights, materialLights } = this;
|
|
173
|
-
|
|
174
|
-
let materialindex = 0;
|
|
175
|
-
let tiledIndex = 0;
|
|
176
|
-
|
|
177
|
-
for ( const light of lights ) {
|
|
178
|
-
|
|
179
|
-
if ( light.isPointLight === true ) {
|
|
180
|
-
|
|
181
|
-
tiledLights[ tiledIndex ++ ] = light;
|
|
182
|
-
|
|
183
|
-
} else {
|
|
184
|
-
|
|
185
|
-
materialLights[ materialindex ++ ] = light;
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
materialLights.length = materialindex;
|
|
192
|
-
tiledLights.length = tiledIndex;
|
|
193
|
-
|
|
194
|
-
return super.setLights( materialLights );
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
getBlock( block = 0 ) {
|
|
199
|
-
|
|
200
|
-
return this._lightIndexes.element( this._screenTileIndex.mul( int( 2 ).add( int( block ) ) ) );
|
|
201
|
-
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
getTile( element ) {
|
|
205
|
-
|
|
206
|
-
element = int( element );
|
|
207
|
-
|
|
208
|
-
const stride = int( 4 );
|
|
209
|
-
const tileOffset = element.div( stride );
|
|
210
|
-
const tileIndex = this._screenTileIndex.mul( int( 2 ) ).add( tileOffset );
|
|
211
|
-
|
|
212
|
-
return this._lightIndexes.element( tileIndex ).element( element.mod( stride ) );
|
|
213
|
-
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
getLightData( index ) {
|
|
217
|
-
|
|
218
|
-
index = int( index );
|
|
219
|
-
|
|
220
|
-
const dataA = textureLoad( this._lightsTexture, ivec2( index, 0 ) );
|
|
221
|
-
const dataB = textureLoad( this._lightsTexture, ivec2( index, 1 ) );
|
|
222
|
-
|
|
223
|
-
const position = dataA.xyz;
|
|
224
|
-
const viewPosition = this._cameraViewMatrix.mul( position );
|
|
225
|
-
const distance = dataA.w;
|
|
226
|
-
const color = dataB.rgb;
|
|
227
|
-
const decay = dataB.w;
|
|
228
|
-
|
|
229
|
-
return {
|
|
230
|
-
position,
|
|
231
|
-
viewPosition,
|
|
232
|
-
distance,
|
|
233
|
-
color,
|
|
234
|
-
decay
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
setupLights( builder, lightNodes ) {
|
|
240
|
-
|
|
241
|
-
this.updateProgram( builder.renderer );
|
|
242
|
-
|
|
243
|
-
//
|
|
244
|
-
|
|
245
|
-
const lightingModel = builder.context.reflectedLight;
|
|
246
|
-
|
|
247
|
-
// force declaration order, before of the loop
|
|
248
|
-
lightingModel.directDiffuse.toStack();
|
|
249
|
-
lightingModel.directSpecular.toStack();
|
|
250
|
-
|
|
251
|
-
super.setupLights( builder, lightNodes );
|
|
252
|
-
|
|
253
|
-
Fn( () => {
|
|
254
|
-
|
|
255
|
-
Loop( this._tileLightCount, ( { i } ) => {
|
|
256
|
-
|
|
257
|
-
const lightIndex = this.getTile( i );
|
|
258
|
-
|
|
259
|
-
If( lightIndex.equal( int( 0 ) ), () => {
|
|
260
|
-
|
|
261
|
-
Break();
|
|
262
|
-
|
|
263
|
-
} );
|
|
264
|
-
|
|
265
|
-
const { color, decay, viewPosition, distance } = this.getLightData( lightIndex.sub( 1 ) );
|
|
266
|
-
|
|
267
|
-
builder.lightsNode.setupDirectLight( builder, this, directPointLight( {
|
|
268
|
-
color,
|
|
269
|
-
lightVector: viewPosition.sub( positionView ),
|
|
270
|
-
cutoffDistance: distance,
|
|
271
|
-
decayExponent: decay
|
|
272
|
-
} ) );
|
|
273
|
-
|
|
274
|
-
} );
|
|
275
|
-
|
|
276
|
-
}, 'void' )();
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
getBufferFitSize( value ) {
|
|
281
|
-
|
|
282
|
-
const multiple = this.tileSize;
|
|
283
|
-
|
|
284
|
-
return Math.ceil( value / multiple ) * multiple;
|
|
285
|
-
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
setSize( width, height ) {
|
|
289
|
-
|
|
290
|
-
width = this.getBufferFitSize( width );
|
|
291
|
-
height = this.getBufferFitSize( height );
|
|
292
|
-
|
|
293
|
-
if ( ! this._bufferSize || this._bufferSize.width !== width || this._bufferSize.height !== height ) {
|
|
294
|
-
|
|
295
|
-
this.create( width, height );
|
|
296
|
-
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
return this;
|
|
300
|
-
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
updateProgram( renderer ) {
|
|
304
|
-
|
|
305
|
-
renderer.getDrawingBufferSize( _size );
|
|
306
|
-
|
|
307
|
-
const width = this.getBufferFitSize( _size.width );
|
|
308
|
-
const height = this.getBufferFitSize( _size.height );
|
|
309
|
-
|
|
310
|
-
if ( this._bufferSize === null ) {
|
|
311
|
-
|
|
312
|
-
this.create( width, height );
|
|
313
|
-
|
|
314
|
-
} else if ( this._bufferSize.width !== width || this._bufferSize.height !== height ) {
|
|
315
|
-
|
|
316
|
-
this.create( width, height );
|
|
317
|
-
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
create( width, height ) {
|
|
323
|
-
|
|
324
|
-
const { tileSize, maxLights } = this;
|
|
325
|
-
|
|
326
|
-
const bufferSize = new Vector2( width, height );
|
|
327
|
-
const lineSize = Math.floor( bufferSize.width / tileSize );
|
|
328
|
-
const count = Math.floor( ( bufferSize.width * bufferSize.height ) / tileSize );
|
|
329
|
-
|
|
330
|
-
// buffers
|
|
331
|
-
|
|
332
|
-
const lightsData = new Float32Array( maxLights * 4 * 2 ); // 2048 lights, 4 elements(rgba), 2 components, 1 component per line (position, distance, color, decay)
|
|
333
|
-
const lightsTexture = new DataTexture( lightsData, lightsData.length / 8, 2, RGBAFormat, FloatType );
|
|
334
|
-
|
|
335
|
-
const lightIndexesArray = new Int32Array( count * 4 * 2 );
|
|
336
|
-
const lightIndexes = attributeArray( lightIndexesArray, 'ivec4' ).setName( 'lightIndexes' );
|
|
337
|
-
|
|
338
|
-
// compute
|
|
339
|
-
|
|
340
|
-
const getBlock = ( index ) => {
|
|
341
|
-
|
|
342
|
-
const tileIndex = instanceIndex.mul( int( 2 ) ).add( int( index ) );
|
|
343
|
-
|
|
344
|
-
return lightIndexes.element( tileIndex );
|
|
345
|
-
|
|
346
|
-
};
|
|
347
|
-
|
|
348
|
-
const getTile = ( elementIndex ) => {
|
|
349
|
-
|
|
350
|
-
elementIndex = int( elementIndex );
|
|
351
|
-
|
|
352
|
-
const stride = int( 4 );
|
|
353
|
-
const tileOffset = elementIndex.div( stride );
|
|
354
|
-
const tileIndex = instanceIndex.mul( int( 2 ) ).add( tileOffset );
|
|
355
|
-
|
|
356
|
-
return lightIndexes.element( tileIndex ).element( elementIndex.mod( stride ) );
|
|
357
|
-
|
|
358
|
-
};
|
|
359
|
-
|
|
360
|
-
const compute = Fn( () => {
|
|
361
|
-
|
|
362
|
-
const { _cameraProjectionMatrix: cameraProjectionMatrix, _bufferSize: bufferSize, _screenSize: screenSize } = this;
|
|
363
|
-
|
|
364
|
-
const tiledBufferSize = bufferSize.clone().divideScalar( tileSize ).floor();
|
|
365
|
-
|
|
366
|
-
const tileScreen = vec2(
|
|
367
|
-
instanceIndex.mod( tiledBufferSize.width ),
|
|
368
|
-
instanceIndex.div( tiledBufferSize.width )
|
|
369
|
-
).mul( tileSize ).div( screenSize );
|
|
370
|
-
|
|
371
|
-
const blockSize = float( tileSize ).div( screenSize );
|
|
372
|
-
const minBounds = tileScreen;
|
|
373
|
-
const maxBounds = minBounds.add( blockSize );
|
|
374
|
-
|
|
375
|
-
const index = int( 0 ).toVar();
|
|
376
|
-
|
|
377
|
-
getBlock( 0 ).assign( ivec4( 0 ) );
|
|
378
|
-
getBlock( 1 ).assign( ivec4( 0 ) );
|
|
379
|
-
|
|
380
|
-
Loop( this.maxLights, ( { i } ) => {
|
|
381
|
-
|
|
382
|
-
If( index.greaterThanEqual( this._tileLightCount ).or( int( i ).greaterThanEqual( int( this._lightsCount ) ) ), () => {
|
|
383
|
-
|
|
384
|
-
Return();
|
|
385
|
-
|
|
386
|
-
} );
|
|
387
|
-
|
|
388
|
-
const { viewPosition, distance } = this.getLightData( i );
|
|
389
|
-
|
|
390
|
-
const projectedPosition = cameraProjectionMatrix.mul( viewPosition );
|
|
391
|
-
const ndc = projectedPosition.div( projectedPosition.w );
|
|
392
|
-
const screenPosition = ndc.xy.mul( 0.5 ).add( 0.5 ).flipY();
|
|
393
|
-
|
|
394
|
-
const distanceFromCamera = viewPosition.z;
|
|
395
|
-
const pointRadius = distance.div( distanceFromCamera );
|
|
396
|
-
|
|
397
|
-
If( circleIntersectsAABB( screenPosition, pointRadius, minBounds, maxBounds ), () => {
|
|
398
|
-
|
|
399
|
-
getTile( index ).assign( i.add( int( 1 ) ) );
|
|
400
|
-
index.addAssign( int( 1 ) );
|
|
401
|
-
|
|
402
|
-
} );
|
|
403
|
-
|
|
404
|
-
} );
|
|
405
|
-
|
|
406
|
-
} )().compute( count ).setName( 'Update Tiled Lights' );
|
|
407
|
-
|
|
408
|
-
// screen coordinate lighting indexes
|
|
409
|
-
|
|
410
|
-
const screenTile = screenCoordinate.div( tileSize ).floor().toVar();
|
|
411
|
-
const screenTileIndex = screenTile.x.add( screenTile.y.mul( lineSize ) );
|
|
412
|
-
|
|
413
|
-
// assigns
|
|
414
|
-
|
|
415
|
-
this._bufferSize = bufferSize;
|
|
416
|
-
this._lightIndexes = lightIndexes;
|
|
417
|
-
this._screenTileIndex = screenTileIndex;
|
|
418
|
-
this._compute = compute;
|
|
419
|
-
this._lightsTexture = lightsTexture;
|
|
420
|
-
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
get hasLights() {
|
|
424
|
-
|
|
425
|
-
return super.hasLights || this.tiledLights.length > 0;
|
|
426
|
-
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
export default TiledLightsNode;
|
|
432
|
-
|
|
433
|
-
/**
|
|
434
|
-
* TSL function that creates a tiled lights node.
|
|
435
|
-
*
|
|
436
|
-
* @tsl
|
|
437
|
-
* @function
|
|
438
|
-
* @param {number} [maxLights=1024] - The maximum number of lights.
|
|
439
|
-
* @param {number} [tileSize=32] - The tile size.
|
|
440
|
-
* @return {TiledLightsNode} The tiled lights node.
|
|
441
|
-
*/
|
|
442
|
-
export const tiledLights = /*@__PURE__*/ nodeProxy( TiledLightsNode );
|
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import Node from '../core/Node.js';
|
|
2
|
-
import { normalLocal } from './Normal.js';
|
|
3
|
-
import { positionLocal } from './Position.js';
|
|
4
|
-
import { nodeProxy, vec3, mat3, mat4, int, ivec2, float, Fn } from '../tsl/TSLBase.js';
|
|
5
|
-
import { textureLoad } from './TextureNode.js';
|
|
6
|
-
import { textureSize } from './TextureSizeNode.js';
|
|
7
|
-
import { tangentLocal } from './Tangent.js';
|
|
8
|
-
import { instanceIndex, drawIndex } from '../core/IndexNode.js';
|
|
9
|
-
import { varyingProperty } from '../core/PropertyNode.js';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* This node implements the vertex shader logic which is required
|
|
13
|
-
* when rendering 3D objects via batching. `BatchNode` must be used
|
|
14
|
-
* with instances of {@link BatchedMesh}.
|
|
15
|
-
*
|
|
16
|
-
* @augments Node
|
|
17
|
-
*/
|
|
18
|
-
class BatchNode extends Node {
|
|
19
|
-
|
|
20
|
-
static get type() {
|
|
21
|
-
|
|
22
|
-
return 'BatchNode';
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Constructs a new batch node.
|
|
28
|
-
*
|
|
29
|
-
* @param {BatchedMesh} batchMesh - A reference to batched mesh.
|
|
30
|
-
*/
|
|
31
|
-
constructor( batchMesh ) {
|
|
32
|
-
|
|
33
|
-
super( 'void' );
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* A reference to batched mesh.
|
|
37
|
-
*
|
|
38
|
-
* @type {BatchedMesh}
|
|
39
|
-
*/
|
|
40
|
-
this.batchMesh = batchMesh;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* The batching index node.
|
|
44
|
-
*
|
|
45
|
-
* @type {?IndexNode}
|
|
46
|
-
* @default null
|
|
47
|
-
*/
|
|
48
|
-
this.batchingIdNode = null;
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Setups the internal buffers and nodes and assigns the transformed vertex data
|
|
54
|
-
* to predefined node variables for accumulation. That follows the same patterns
|
|
55
|
-
* like with morph and skinning nodes.
|
|
56
|
-
*
|
|
57
|
-
* @param {NodeBuilder} builder - The current node builder.
|
|
58
|
-
*/
|
|
59
|
-
setup( builder ) {
|
|
60
|
-
|
|
61
|
-
if ( this.batchingIdNode === null ) {
|
|
62
|
-
|
|
63
|
-
if ( builder.getDrawIndex() === null ) {
|
|
64
|
-
|
|
65
|
-
this.batchingIdNode = instanceIndex;
|
|
66
|
-
|
|
67
|
-
} else {
|
|
68
|
-
|
|
69
|
-
this.batchingIdNode = drawIndex;
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const getIndirectIndex = Fn( ( [ id ] ) => {
|
|
76
|
-
|
|
77
|
-
const size = int( textureSize( textureLoad( this.batchMesh._indirectTexture ), 0 ).x ).toConst();
|
|
78
|
-
const x = int( id ).mod( size ).toConst();
|
|
79
|
-
const y = int( id ).div( size ).toConst();
|
|
80
|
-
return textureLoad( this.batchMesh._indirectTexture, ivec2( x, y ) ).x;
|
|
81
|
-
|
|
82
|
-
} ).setLayout( {
|
|
83
|
-
name: 'getIndirectIndex',
|
|
84
|
-
type: 'uint',
|
|
85
|
-
inputs: [
|
|
86
|
-
{ name: 'id', type: 'int' }
|
|
87
|
-
]
|
|
88
|
-
} );
|
|
89
|
-
|
|
90
|
-
const indirectId = getIndirectIndex( int( this.batchingIdNode ) );
|
|
91
|
-
|
|
92
|
-
const matricesTexture = this.batchMesh._matricesTexture;
|
|
93
|
-
|
|
94
|
-
const size = int( textureSize( textureLoad( matricesTexture ), 0 ).x ).toConst();
|
|
95
|
-
const j = float( indirectId ).mul( 4 ).toInt().toConst();
|
|
96
|
-
|
|
97
|
-
const x = j.mod( size ).toConst();
|
|
98
|
-
const y = j.div( size ).toConst();
|
|
99
|
-
const batchingMatrix = mat4(
|
|
100
|
-
textureLoad( matricesTexture, ivec2( x, y ) ),
|
|
101
|
-
textureLoad( matricesTexture, ivec2( x.add( 1 ), y ) ),
|
|
102
|
-
textureLoad( matricesTexture, ivec2( x.add( 2 ), y ) ),
|
|
103
|
-
textureLoad( matricesTexture, ivec2( x.add( 3 ), y ) )
|
|
104
|
-
);
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const colorsTexture = this.batchMesh._colorsTexture;
|
|
108
|
-
|
|
109
|
-
if ( colorsTexture !== null ) {
|
|
110
|
-
|
|
111
|
-
const getBatchingColor = Fn( ( [ id ] ) => {
|
|
112
|
-
|
|
113
|
-
const size = int( textureSize( textureLoad( colorsTexture ), 0 ).x ).toConst();
|
|
114
|
-
const j = id;
|
|
115
|
-
const x = j.mod( size ).toConst();
|
|
116
|
-
const y = j.div( size ).toConst();
|
|
117
|
-
return textureLoad( colorsTexture, ivec2( x, y ) ).rgb;
|
|
118
|
-
|
|
119
|
-
} ).setLayout( {
|
|
120
|
-
name: 'getBatchingColor',
|
|
121
|
-
type: 'vec3',
|
|
122
|
-
inputs: [
|
|
123
|
-
{ name: 'id', type: 'int' }
|
|
124
|
-
]
|
|
125
|
-
} );
|
|
126
|
-
|
|
127
|
-
const color = getBatchingColor( indirectId );
|
|
128
|
-
|
|
129
|
-
varyingProperty( 'vec3', 'vBatchColor' ).assign( color );
|
|
130
|
-
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
const bm = mat3( batchingMatrix );
|
|
134
|
-
|
|
135
|
-
positionLocal.assign( batchingMatrix.mul( positionLocal ) );
|
|
136
|
-
|
|
137
|
-
const transformedNormal = normalLocal.div( vec3( bm[ 0 ].dot( bm[ 0 ] ), bm[ 1 ].dot( bm[ 1 ] ), bm[ 2 ].dot( bm[ 2 ] ) ) );
|
|
138
|
-
|
|
139
|
-
const batchingNormal = bm.mul( transformedNormal ).xyz;
|
|
140
|
-
|
|
141
|
-
normalLocal.assign( batchingNormal );
|
|
142
|
-
|
|
143
|
-
if ( builder.hasGeometryAttribute( 'tangent' ) ) {
|
|
144
|
-
|
|
145
|
-
tangentLocal.mulAssign( bm );
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
export default BatchNode;
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* TSL function for creating a batch node.
|
|
157
|
-
*
|
|
158
|
-
* @tsl
|
|
159
|
-
* @function
|
|
160
|
-
* @param {BatchedMesh} batchMesh - A reference to batched mesh.
|
|
161
|
-
* @returns {BatchNode}
|
|
162
|
-
*/
|
|
163
|
-
export const batch = /*@__PURE__*/ nodeProxy( BatchNode ).setParameterLength( 1 );
|