Type of arbitrary data associated with this checkbox. Used for identifying specific checkboxes in multi-checkbox scenarios.
Creates a new ButtonInteractionHandler instance.
Configuration object containing view and optional material set
Initializes the interaction handler with the specified display object and optional material set. The handler immediately applies the initial material state upon creation.
This constructor is typically not called directly by end users. Instead, it is invoked internally by display object constructors (ClickableMesh, ClickableSprite) or conversion utility functions (convertToClickableMesh, convertToClickableSprite).
// Example 1: Creating clickable object from geometry and materials using ClickableMesh constructor
import { ClickableMesh, StateMaterialSet } from '@masatomakino/threejs-interactive-object';
import { BoxGeometry, MeshBasicMaterial } from 'three';
const materials = new StateMaterialSet({
normal: new MeshBasicMaterial({ color: 0x0000ff }),
over: new MeshBasicMaterial({ color: 0x00ff00 }),
down: new MeshBasicMaterial({ color: 0xff0000 })
});
const clickableMesh = new ClickableMesh({
geo: new BoxGeometry(1, 1, 1),
material: materials
});
clickableMesh.interactionHandler.value = { id: 'button1', action: 'save' };
// Example 2: Converting existing Mesh to clickable using convertToClickableMesh
import { convertToClickableMesh } from '@masatomakino/threejs-interactive-object';
import { Mesh } from 'three';
const existingMesh = new Mesh(new BoxGeometry(1, 1, 1), new MeshBasicMaterial());
const convertedClickable = convertToClickableMesh<string>(existingMesh);
convertedClickable.interactionHandler.value = 'converted-button';
// Listen for click events
convertedClickable.interactionHandler.on('click', (event) => {
console.log('Button clicked:', convertedClickable.interactionHandler.value);
});
For most use cases, prefer using ClickableMesh/ClickableSprite constructors for new objects or convertToClickable* utility functions for existing objects, rather than instantiating ButtonInteractionHandler directly.
Protected
Internal
_Internal alpha multiplier for opacity control.
Protected
Internal
_Internal state tracking enabled/disabled status.
Protected
Internal
_Internal state tracking pointer hover status.
Protected
Internal
_Internal state tracking pointer press status.
Protected
_Protected
Optional
Internal
_Internal reference to the material set.
Temporarily prevents interaction handling while maintaining current visual state.
Controls whether the object responds to pointer interactions.
Current visual interaction state of the object.
Arbitrary data associated with this interactive object.
Readonly
viewThe display object being managed by this interaction handler.
Static
prefixedSets the opacity alpha multiplier for the material set.
Alpha value between 0.0 (transparent) and 1.0 (opaque)
Indicates whether the pointer is currently hovering over the object.
True if pointer is over the object, false otherwise
Indicates whether the pointer is currently pressed down on the object.
True if pointer is pressed down, false otherwise
Gets the current StateMaterialSet managing visual states.
The current material set, or undefined if none is assigned
Sets the StateMaterialSet for managing visual states.
The material set to assign, or undefined to remove
Gets the current selection state of the checkbox.
True if the checkbox is currently selected, false otherwise
Optional
context: anyProtected
checkProtected
Checks if the object is currently active and can respond to interactions.
True if the object is enabled and not frozen, false otherwise
Calls each of the listeners registered for a given event.
Return an array listing the events for which the emitter has registered listeners.
Return the number of listeners listening to a given event.
Return the listeners registered for a given event.
Optional
fn: (Optional
context: anyOptional
once: booleanAdd a listener for a given event.
Optional
context: anyAdd a one-time listener for a given event.
Optional
context: anyHandles pointer down events and transitions to pressed state.
The pointer down event containing interaction details
Handles pointer out events.
The pointer out event containing interaction details
Handles pointer over events.
The pointer over event containing interaction details
Handles pointer up events and manages click detection logic.
The pointer up event containing interaction details
Remove all listeners, or those of the specified event.
Optional
event: keyof ThreeMouseEventMap<Value>Remove the listeners of a given event.
Optional
fn: (Optional
context: anyOptional
once: booleanSwitches the interactive object between enabled and disabled states.
True to enable, false to disable
Protected
updateProtected
Updates the display object's material based on current interaction and selection state.
Protected
updateProtected
Updates the current interaction state and refreshes the visual representation.
The new interaction state to apply
Checkbox interaction handler that extends ButtonInteractionHandler with selection state management.
Description
Extends ButtonInteractionHandler with checkbox-specific toggle selection behavior. Maintains internal selection state that toggles on pointer interactions and integrates with StateMaterialSet for selection-aware visual feedback.
Typically instantiated internally by CheckBoxMesh/CheckBoxSprite constructors or convertToCheckbox* utility functions rather than directly by end users.
Fires
select - Emitted when selection state changes via pointer interaction
Example
See