Damping factor controlling how smoothly the object follows the cursor (in seconds).
This value determines the "lag" or smoothness of the following motion:
0: Instant movement, no damping (object snaps directly to cursor position)0.1-0.2: Quick, responsive following with slight smoothing0.3-0.5: Noticeable smooth trailing effect1.0+: Slow, heavily damped movementThe damping uses delta time, so the movement speed is framerate-independent and provides consistent behavior across different devices.
Tip: For look-at effects, values between 0.2-0.4 typically feel most natural. For cursor indicators, 0.1 or less provides better responsiveness.
Reference to the GameObject this component is attached to This is a three.js Object3D with additional GameObject functionality
Unique identifier for this component instance, used for finding and tracking components
Whether to maintain the object's initial distance from the camera while following the cursor.
When true (default):
When false:
How it works: On the first update, the component measures the distance from the object to the camera. This initial distance is then maintained throughout the object's lifetime (unless updateDistance is called). The object moves along a ray from the camera through the cursor, staying at this fixed distance.
updateDistance to manually recalculate the distance
When enabled, the object snaps to the surfaces of other objects in the scene using raycasting.
How it works: After positioning the object at the cursor location, a raycast is performed backwards toward the camera. If the ray hits any surface, the object is moved to that hit point, effectively "snapping" to the surface.
Use cases:
Important notes:
false to allow depth changesDebug mode:
Add ?debugcursor to your URL to visualize the raycast hits with green debug lines.
OptionalsourceIdentifier for the source asset that created this component. For example, URL to the glTF file this component was loaded from
Whether the object should track the cursor across the entire webpage or only within the canvas.
When true (default):
When false:
Note: When enabled, the component listens to window.pointermove events to track the
full-page cursor position. When disabled, it uses the context's input system which is
canvas-relative.
Get the original component type name before minification (available if the component is registered in the TypeStore)
Checks if this component is currently active (enabled and part of an active GameObject hierarchy) Components that are inactive won't receive lifecycle method calls
True if the component is enabled and all parent GameObjects are active
Checks if this component has been destroyed
True if the component or its GameObject has been destroyed
Controls whether this component is enabled Disabled components don't receive lifecycle callbacks
Gets the forward direction vector (0,0,-1) of this component's GameObject in world space
The layer value of the GameObject this component is attached to Used for visibility and physics filtering
The name of the GameObject this component is attached to Used for debugging and finding objects
Gets the right direction vector (1,0,0) of this component's GameObject in world space
Shorthand accessor for the current scene from the context
The scene this component belongs to
Indicates whether the GameObject is marked as static Static objects typically don't move and can be optimized by the engine
The tag of the GameObject this component is attached to Used for categorizing objects and efficient lookup
Gets the up direction vector (0,1,0) of this component's GameObject in world space
Gets the rotation of this component's GameObject in world space as a quaternion
Note: This is equivalent to calling this.gameObject.worldQuaternion
Sets the rotation of this component's GameObject in world space using a quaternion
The world rotation quaternion to set
Gets the rotation of this component's GameObject in world space as Euler angles (in degrees)
Note: This is equivalent to calling this.gameObject.worldRotation
Sets the rotation of this component's GameObject in world space using Euler angles (in degrees)
The world rotation vector to set (in degrees)
Destroys this component and removes it from its GameObject After destruction, the component will no longer receive lifecycle callbacks
Dispatches an event to all registered listeners
The event object to dispatch
Always returns false (standard implementation of EventTarget)
OptionalearlyCalled at the beginning of each frame before regular updates. Use for logic that needs to run before standard update callbacks.
OptionalonCalled after the scene has been rendered. Use for post-processing or UI updates that should happen after rendering
OptionalonCalled immediately before the scene is rendered.
Current XRFrame if in an XR session, null otherwise
OptionalonCalled before an XR session is requested Use to modify session initialization parameters
The XR session mode being requested
The session initialization parameters that can be modified
OptionalonCalled when this component's collider begins colliding with another collider.
Information about the collision that occurred
OptionalonCalled when this component's collider stops colliding with another collider.
Information about the collision that ended
OptionalonCalled each frame while this component's collider is colliding with another collider
Information about the ongoing collision
Called when the component is destroyed. Use for cleanup operations like removing event listeners
OptionalonCalled when this component joins an XR session or becomes active in a running session
Event data for the XR session
OptionalonCalled when this component exits an XR session or becomes inactive during a session
Event data for the XR session
OptionalonCalled when the context's pause state changes.
Whether the context is currently paused
The previous pause state
OptionalonCalled when a pointer completes a click interaction with this component's GameObject
Data about the pointer event
OptionalonCalled when a pointer button is pressed while over this component's GameObject
Data about the pointer event
OptionalonCalled when a pointer enters this component's GameObject
Data about the pointer event
OptionalonCalled when a pointer exits this component's GameObject
Data about the pointer event
OptionalonCalled when a pointer moves while over this component's GameObject
Data about the pointer event
OptionalonCalled when a pointer button is released while over this component's GameObject
Data about the pointer event
OptionalonCalled when this component's trigger collider is entered by another collider
The collider that entered this trigger
OptionalonCalled when another collider exits this component's trigger collider
The collider that exited this trigger
OptionalonCalled each frame while another collider is inside this component's trigger collider
The collider that is inside this trigger
OptionalonCalled each frame while this component is active in an XR session
Event data for the current XR frame
OptionalonCalled when a field decorated with @validate() is modified.
Optionalprop: stringThe name of the field that was changed
OptionalonXRControllerCalled when an XR controller is connected or when this component becomes active in a session with existing controllers
Event data for the controller that was added
OptionalonXRControllerCalled when an XR controller is disconnected or when this component becomes inactive during a session with controllers
Event data for the controller that was removed
OptionalresolveCalled when this component needs to remap guids after an instantiate operation.
Mapping from old guids to newly generated guids
Sets the position of this component's GameObject in world space using individual coordinates
X-coordinate in world space
Y-coordinate in world space
Z-coordinate in world space
Sets the rotation of this component's GameObject in world space using quaternion components
X component of the quaternion
Y component of the quaternion
Z component of the quaternion
W component of the quaternion
Sets the rotation of this component's GameObject in world space using individual Euler angles
X-axis rotation
Y-axis rotation
Z-axis rotation
Whether the values are in degrees (true) or radians (false)
OptionalstartCalled once at the beginning of the first frame after the component is enabled. Use for initialization that requires other components to be awake.
Starts a coroutine that can yield to wait for events. Coroutines allow for time-based sequencing of operations without blocking. Coroutines are based on generator functions, a JavaScript language feature.
Generator function to start
Event to register the coroutine for (default: FrameEvent.Update)
The generator function that can be used to stop the coroutine
Stops a coroutine that was previously started with startCoroutine
The routine to be stopped
The frame event the routine was registered with
OptionalsupportsXRDetermines if this component supports a specific XR mode
The XR session mode to check support for
True if the component supports the specified mode
OptionalupdateCalled once per frame during the main update loop. The primary location for frame-based game logic.
Manually recalculates the distance between the object and the camera.
By default, the distance is calculated once when the component starts and then maintained when keepDistance is enabled. Use this method to update the reference distance if the camera or object has moved significantly.
Use cases:
If true, forces a recalculation even if keepDistance is enabled and distance was already set
CursorFollow makes an object smoothly follow the cursor or touch position in 3D space.
The component tracks pointer movement and updates the object's position to follow it, with optional damping for smooth motion.
How It Works:
The component creates a ray from the camera through the cursor position and places the object along that ray.
By default, it maintains the object's initial distance from the camera, creating a natural cursor-following effect
that works consistently regardless of camera movement.
Key Features:
Common Use Cases:
Example: Basic cursor follow with smooth damping
Example: Surface-snapping cursor with raycast
Example: Instant cursor following (no damping)
Example: Interactive 3D header that looks at cursor
See
Component