Class: FluidRenderer
Defined in: src/components/renderer/FluidRenderer.ts:76
Renders a particle set as a continuous liquid surface (screen-space fluid rendering). Particles are drawn as sphere impostors into a depth buffer which is then smoothed and shaded in screen space.
Requires setting.render.fluid = true so ForwardRendererJob adds FluidPass. The fluid is drawn after opaque geometry and before transparent geometry.
Particle positions are in the local space of the owning Object3D (world space when it sits at the origin unscaled); particleSize is in world units. They come from either:
- setDataBuffer: a CPU
Float32Array, uploaded when set. - setDataBufferGPU: an existing storage buffer (e.g. written by a simulation compute shader), read directly without a copy.
Extends
Constructors
Constructor
new FluidRenderer():
FluidRenderer
Returns
FluidRenderer
Inherited from
Properties
object3D
object3D:
Object3D=null
Defined in: src/components/ComponentBase.ts:29
owner object3D
Inherited from
isDestroyed
isDestroyed:
boolean=false
Defined in: src/components/ComponentBase.ts:77
Inherited from
particleSize
particleSize:
number=0.1
Defined in: src/components/renderer/FluidRenderer.ts:78
Particle diameter in world units.
particleThicknessAlpha
particleThicknessAlpha:
number=0.05
Defined in: src/components/renderer/FluidRenderer.ts:80
Thickness one particle adds at its center; the fluid gets more opaque as it grows.
depthMapSize
depthMapSize:
number=null
Defined in: src/components/renderer/FluidRenderer.ts:83
Width of the depth map in pixels; height follows the screen aspect. null = screen size.
thicknessMapSize
thicknessMapSize:
number=null
Defined in: src/components/renderer/FluidRenderer.ts:85
Width of the thickness map in pixels; height follows the screen aspect. null = screen size.
fluidColor
fluidColor:
Color
Defined in: src/components/renderer/FluidRenderer.ts:88
Absorption color: light passing through the fluid is tinted toward it.
density
density:
number=2
Defined in: src/components/renderer/FluidRenderer.ts:90
Absorption strength; higher makes the fluid more opaque. With FluidThicknessMode.Geometric it is per world unit of thickness.
refractionStrength
refractionStrength:
number=1
Defined in: src/components/renderer/FluidRenderer.ts:92
Scale of the refraction offset: 1 follows the refracted ray to the scene behind, 0 disables refraction.
fresnelClamp
fresnelClamp:
number=1
Defined in: src/components/renderer/FluidRenderer.ts:94
Upper bound of the fresnel reflection weight (0 to 1).
specularPower
specularPower:
number=250
Defined in: src/components/renderer/FluidRenderer.ts:96
Specular exponent; higher gives a smaller, sharper highlight.
minimumThickness
minimumThickness:
number=0
Defined in: src/components/renderer/FluidRenderer.ts:98
Pixels with less thickness show the background. With useFixedThickness, the thickness used everywhere.
edgeSoftness
edgeSoftness:
number=0
Defined in: src/components/renderer/FluidRenderer.ts:104
Fade the fluid into the background where it is thinner than this many particles (particleThicknessAlpha each when accumulated, particleSize each when geometric); softens free edges. 0 disables.
useFixedThickness
useFixedThickness:
boolean=false
Defined in: src/components/renderer/FluidRenderer.ts:116
Skip the thickness pass and use minimumThickness as a constant thickness.
dirLight
dirLight:
Vector3=null
Defined in: src/components/renderer/FluidRenderer.ts:118
World-space direction the light travels, for the specular highlight. null uses the scene's first DirectLight, or (-2, -1, 1) without one.
environmentMap
environmentMap:
Texture=undefined
Defined in: src/components/renderer/FluidRenderer.ts:120
Cube map reflected by the fluid. undefined uses the scene's envMap; null disables reflection.
useAnisotropy
useAnisotropy:
boolean=false
Defined in: src/components/renderer/FluidRenderer.ts:126
Stretch each particle into an ellipsoid along its neighbor distribution, so flat regions stay flat and thin sheets stay thin. Adds a neighbor search on the GPU each frame.
anisotropyRadius
anisotropyRadius:
number=null
Defined in: src/components/renderer/FluidRenderer.ts:128
Neighbor search radius in world units. null uses 1.5 × particleSize.
anisotropyMaxRatio
anisotropyMaxRatio:
number=4
Defined in: src/components/renderer/FluidRenderer.ts:130
Largest ratio between the longest and shortest ellipsoid axis.
anisotropyMinNeighbors
anisotropyMinNeighbors:
number=10
Defined in: src/components/renderer/FluidRenderer.ts:132
Particles with fewer neighbors stay spheres (spray, droplets).
anisotropySmoothing
anisotropySmoothing:
number=0.5
Defined in: src/components/renderer/FluidRenderer.ts:134
How far (0 to 1) each particle moves toward the weighted mean of its neighbors, which smooths the surface.
enableBlurDepth
enableBlurDepth:
boolean=true
Defined in: src/components/renderer/FluidRenderer.ts:137
Smooth the depth map so the spheres merge into one surface.
blurDepthSizeDivisor
blurDepthSizeDivisor:
number=1
Defined in: src/components/renderer/FluidRenderer.ts:148
Depth blur runs at the depth map size divided by this.
blurDepthFilterSize
blurDepthFilterSize:
number=7
Defined in: src/components/renderer/FluidRenderer.ts:150
Depth blur radius, relative to the projected particle size.
blurDepthNumIterations
blurDepthNumIterations:
number=3
Defined in: src/components/renderer/FluidRenderer.ts:152
Depth blur passes (each is one horizontal + one vertical pass).
blurDepthMaxFilterSize
blurDepthMaxFilterSize:
number=100
Defined in: src/components/renderer/FluidRenderer.ts:154
Upper bound of the depth blur radius in pixels.
blurDepthDepthScale
blurDepthDepthScale:
number=10
Defined in: src/components/renderer/FluidRenderer.ts:156
Depth range, in particle radii, across which samples are still blended; larger merges more.
enableBlurThickness
enableBlurThickness:
boolean=true
Defined in: src/components/renderer/FluidRenderer.ts:159
Smooth the thickness map.
blurThicknessSizeDivisor
blurThicknessSizeDivisor:
number=1
Defined in: src/components/renderer/FluidRenderer.ts:161
Thickness blur runs at the thickness map size divided by this.
blurThicknessFilterSize
blurThicknessFilterSize:
number=5
Defined in: src/components/renderer/FluidRenderer.ts:163
Thickness blur radius in pixels.
blurThicknessNumIterations
blurThicknessNumIterations:
number=1
Defined in: src/components/renderer/FluidRenderer.ts:165
Thickness blur passes (each is one horizontal + one vertical pass).
debug
debug:
boolean=false
Defined in: src/components/renderer/FluidRenderer.ts:168
Show the image selected by debugFeature instead of the fluid.
Accessors
visibleLayer
Get Signature
get visibleLayer():
number
Defined in: src/components/ComponentBase.ts:46
Composition-layer membership bitmask. The pass / camera / collector filters via
(component.visibleLayer & pass.layerMask & camera.cullingMask) !== 0
Defaults to VisibleLayer.Default (bit 0) so a fresh subclass is visible to passes whose layerMask is VisibleLayer.All (which includes bit 0). Application code can assign project-specific bits (1..31) to organise the scene into composition layers.
Returns
number
Set Signature
set visibleLayer(
value):void
Defined in: src/components/ComponentBase.ts:50
Parameters
value
number
Returns
void
Inherited from
eventDispatcher
Get Signature
get eventDispatcher():
CEventDispatcher
Defined in: src/components/ComponentBase.ts:63
Returns
Set Signature
set eventDispatcher(
value):void
Defined in: src/components/ComponentBase.ts:68
Parameters
value
Returns
void
Inherited from
isStart
Get Signature
get isStart():
boolean
Defined in: src/components/ComponentBase.ts:79
Returns
boolean
Inherited from
transform
Get Signature
get transform():
Transform
Defined in: src/components/ComponentBase.ts:89
Return the Transform component attached to the Object3D. Null before the component is attached — addComponent assigns object3D only after construction — so constructor-time callers can probe safely via this.transform?..
Returns
Inherited from
enable
Get Signature
get enable():
boolean
Defined in: src/components/ComponentBase.ts:113
Enable/disable components. The enabled components can be updated, while the disabled components cannot be updated.
Returns
boolean
Set Signature
set enable(
value):void
Defined in: src/components/ComponentBase.ts:96
Enable/disable components. The enabled components can be updated, while the disabled components cannot be updated.
Parameters
value
boolean
Returns
void
Inherited from
thicknessMode
Get Signature
get thicknessMode():
FluidThicknessMode
Defined in: src/components/renderer/FluidRenderer.ts:108
How thickness is measured for absorption.
Returns
Set Signature
set thicknessMode(
value):void
Defined in: src/components/renderer/FluidRenderer.ts:111
Parameters
value
Returns
void
depthFilter
Get Signature
get depthFilter():
FluidDepthFilter
Defined in: src/components/renderer/FluidRenderer.ts:140
Filter used to smooth the depth map.
Returns
Set Signature
set depthFilter(
value):void
Defined in: src/components/renderer/FluidRenderer.ts:143
Parameters
value
Returns
void
debugFeature
Get Signature
get debugFeature():
FluidDebug
Defined in: src/components/renderer/FluidRenderer.ts:171
Returns
Set Signature
set debugFeature(
value):void
Defined in: src/components/renderer/FluidRenderer.ts:174
Parameters
value
Returns
void
particleCount
Get Signature
get particleCount():
number
Defined in: src/components/renderer/FluidRenderer.ts:218
Number of particles drawn. Can be lowered to draw a prefix of the buffer.
Returns
number
Set Signature
set particleCount(
value):void
Defined in: src/components/renderer/FluidRenderer.ts:221
Parameters
value
number
Returns
void
Methods
init()
init(
param?):void
Defined in: src/components/ComponentBase.ts:161
Parameters
param?
any
Returns
void
Inherited from
start()
start():
void
Defined in: src/components/ComponentBase.ts:162
Returns
void
Inherited from
stop()
stop():
void
Defined in: src/components/ComponentBase.ts:163
Returns
void
Inherited from
onEnable()?
optionalonEnable(view?):any
Defined in: src/components/ComponentBase.ts:164
Parameters
view?
Returns
any
Inherited from
onDisable()?
optionalonDisable(view?):any
Defined in: src/components/ComponentBase.ts:165
Parameters
view?
Returns
any
Inherited from
onUpdate()?
optionalonUpdate(view?):any
Defined in: src/components/ComponentBase.ts:166
Parameters
view?
Returns
any
Inherited from
onLateUpdate()?
optionalonLateUpdate(view?):any
Defined in: src/components/ComponentBase.ts:167
Parameters
view?
Returns
any
Inherited from
onBeforeUpdate()?
optionalonBeforeUpdate(view?):any
Defined in: src/components/ComponentBase.ts:168
Parameters
view?
Returns
any
Inherited from
onCompute()?
optionalonCompute(view?,command?):any
Defined in: src/components/ComponentBase.ts:169
Parameters
view?
command?
GPUCommandEncoder
Returns
any
Inherited from
onGraphic()?
optionalonGraphic(view?):any
Defined in: src/components/ComponentBase.ts:170
Parameters
view?
Returns
any
Inherited from
onParentChange()?
optionalonParentChange(lastParent?,currentParent?):any
Defined in: src/components/ComponentBase.ts:171
Parameters
lastParent?
currentParent?
Returns
any
Inherited from
onAddChild()?
optionalonAddChild(child):any
Defined in: src/components/ComponentBase.ts:172
Parameters
child
Returns
any
Inherited from
onRemoveChild()?
optionalonRemoveChild(child):any
Defined in: src/components/ComponentBase.ts:173
Parameters
child
Returns
any
Inherited from
cloneTo()
cloneTo(
obj):void
Defined in: src/components/ComponentBase.ts:180
clone component data to target object3D
Parameters
obj
target object3D
Returns
void
Inherited from
copyComponent()
copyComponent(
from):this
Defined in: src/components/ComponentBase.ts:182
Parameters
from
this
Returns
this
Inherited from
beforeDestroy()
beforeDestroy(
force?):void
Defined in: src/components/ComponentBase.ts:249
before release this component, object refrences are not be set null now.
Parameters
force?
boolean
Returns
void
Inherited from
destroy()
destroy(
force?):void
Defined in: src/components/ComponentBase.ts:256
release this component
Parameters
force?
boolean
Returns
void
Inherited from
setDataBuffer()
setDataBuffer(
data,count?,layout?):void
Defined in: src/components/renderer/FluidRenderer.ts:193
Use CPU particle data. The array is uploaded on the next frame; call again after modifying it in place to re-upload.
Parameters
data
Float32Array
particle data, laid out as described by layout
count?
number
number of particles; defaults to as many as data holds
layout?
particle byte layout
Returns
void
setDataBufferGPU()
setDataBufferGPU(
buffer,count,layout?):void
Defined in: src/components/renderer/FluidRenderer.ts:210
Use a GPU buffer as particle data. The buffer needs STORAGE usage and is read every frame, so updates made by compute shaders show up without further calls.
Parameters
buffer
GPUBufferBase
storage buffer holding the particles
count
number
number of particles to draw
layout?
particle byte layout
Returns
void

