Class: MirrorComponent
Defined in: src/components/MirrorComponent.ts:68
One-stop planar mirror component. Attach to an Object3D that already carries a MeshRenderer with a MirrorMaterial (any geometry — plane, terrain patch, irregular puddle) and the component sets up the rest:
- Spawns an off-screen Camera3D at the plane-mirror of the main camera (refreshed every frame from MirrorComponent.onUpdate).
- Attaches a SceneCaptureCameraComponent so that camera renders the scene into a render target every frame.
- Tags the host renderer with MirrorComponent.MIRROR_MASK and configures the capture's
excludeMaskso the mirror surface does not capture itself (avoids feedback / "mirror in mirror" recursion artefacts). - Binds the capture RT into the host's MirrorMaterial as soon as the capture pass has produced a texture (lazy — runs once on the first frame the RT becomes non-null).
Usage
const floor = new Object3D();
const mr = floor.addComponent(MeshRenderer);
mr.geometry = new PlaneGeometry(40, 40);
mr.material = new MirrorMaterial();
const mirror = floor.addComponent(MirrorComponent);
mirror.mainTarget = new Vector3(0, 1, 0); // what the main camera looks at
scene.addChild(floor);The component reads mainCamera from View3D.camera on enable when not explicitly set, so a single-camera scene needs no other configuration. The mirror plane (point + normal) is also snapshot from the host's world transform on first start — so a tilted/rotated host produces a correctly oriented mirror without any manual plane setup.
Limits
- The mirror plane is snapshot once at start from the host transform. If the host moves or rotates afterwards, update mirrorPlanePoint / mirrorPlaneNormal explicitly.
- Multiple mirrors in the same scene all share MIRROR_MASK — that means no mirror captures any other mirror surface (good — prevents feedback) but it also means a mirror can not appear in another mirror's reflection. If you need cross-mirror reflections, give each mirror a unique bit on MeshRenderer.rendererMask + a matching
excludeMaskset on its captureComponent manually.
Extends
Constructors
Constructor
new MirrorComponent():
MirrorComponent
Returns
MirrorComponent
Inherited from
Properties
MIRROR_MASK
readonlystaticMIRROR_MASK:number
Defined in: src/components/MirrorComponent.ts:76
Custom RendererMask bit reserved for "this is a mirror surface and should not appear in other mirrors". Bit 11 is unclaimed by the engine's built-in mask values (highest is RendererMask.Graphic3D = 1 << 10). Exposed so user code can check / clear it on hand-managed renderers.
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
width
width:
number=1024
Defined in: src/components/MirrorComponent.ts:81
Capture render-target width in pixels. Forwarded to SceneCaptureCameraComponent.width. Setting this after enable triggers an RT reallocation on the next frame.
height
height:
number=1024
Defined in: src/components/MirrorComponent.ts:84
Capture render-target height in pixels.
mirrorPlanePoint
mirrorPlanePoint:
Vector3
Defined in: src/components/MirrorComponent.ts:90
A world-space point lying on the mirror plane. Defaults to the host Object3D's world position on first start, so a flat floor needs no manual setup. Override before/after start to move the reflection plane independently of the host.
mirrorPlaneNormal
mirrorPlaneNormal:
Vector3
Defined in: src/components/MirrorComponent.ts:96
Unit normal of the mirror plane in world space. Defaults to the host Object3D's world-space +Y axis (i.e. transform.up) on first start — matching a PlaneGeometry whose face is up. Override for tilted glass, vertical mirrors, etc.
mainCamera
mainCamera:
Camera3D=null
Defined in: src/components/MirrorComponent.ts:101
The scene's main camera that this mirror reflects. When left null, resolves to View3D.camera on enable. Set explicitly if your scene swaps cameras at runtime.
mainTarget
mainTarget:
Vector3
Defined in: src/components/MirrorComponent.ts:108
World-space point the main camera looks at — the mirror camera is aimed at the reflection of this point across the mirror plane. Default is the world origin; override to match your camera controller's pivot (e.g. HoverCameraController.setCamera's target argument).
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
captureComponent
Get Signature
get captureComponent():
SceneCaptureCameraComponent
Defined in: src/components/MirrorComponent.ts:124
Live reference to the auto-created scene-capture component, in case advanced users want to tweak its properties (clearColor, includeSky, updateMode, …). Null until enable.
Returns
material
Get Signature
get material():
MirrorMaterial
Defined in: src/components/MirrorComponent.ts:132
The MirrorMaterial the component bound. Resolved from the host MeshRenderer on enable. Null if no MirrorMaterial was found (the component logs a warning and no-ops in that case).
Returns
Methods
init()
init(
param?):void
Defined in: src/components/ComponentBase.ts:161
Parameters
param?
any
Returns
void
Inherited from
stop()
stop():
void
Defined in: src/components/ComponentBase.ts:163
Returns
void
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
start()
start():
void
Defined in: src/components/MirrorComponent.ts:136
Returns
void
Overrides
onEnable()
onEnable(
_view?):void
Defined in: src/components/MirrorComponent.ts:153
Parameters
_view?
Returns
void
Overrides
onDisable()
onDisable(
_view?):void
Defined in: src/components/MirrorComponent.ts:160
Parameters
_view?
Returns
void
Overrides
onUpdate()
onUpdate(
_view?):void
Defined in: src/components/MirrorComponent.ts:169
Parameters
_view?
Returns
void
Overrides
destroy()
destroy(
force?):void
Defined in: src/components/MirrorComponent.ts:292
release this component
Parameters
force?
boolean
Returns
void

