@masatomakino/threejs-interactive-object
    Preparing search index...

    Class RadioButtonManager<Value>

    Manages exclusive selection behavior for radio button interactive objects.

    RadioButtonManager coordinates multiple RadioButtonInteractionHandler instances to ensure exclusive selection (only one selected at a time). It extends EventEmitter to broadcast selection changes and provides convenient methods for adding/removing radio buttons from the managed group.

    // Create radio button meshes
    const option1 = new RadioButtonMesh(geometry, materials, { value: "option1" });
    const option2 = new RadioButtonMesh(geometry, materials, { value: "option2" });
    const option3 = new RadioButtonMesh(geometry, materials, { value: "option3" });

    // Create manager for exclusive selection
    const radioManager = new RadioButtonManager<string>();
    radioManager.addButton(option1, option2, option3);

    // Listen for selection changes
    radioManager.on("select", (event) => {
    console.log("Selected:", event.interactionHandler.value);
    });

    // Programmatically select an option
    radioManager.select(option2.interactionHandler);
    console.log(radioManager.selected.value); // "option2"

    select - Emitted when selection changes to a different radio button

    Type Parameters

    • Value = unknown

      Type of arbitrary data associated with the radio button objects

    Hierarchy

    Index

    Constructors

    Properties

    _interactionHandlers: RadioButtonInteractionHandler<Value>[] = []

    Array of radio button interaction handlers under management.

    _selected: undefined | RadioButtonInteractionHandler<Value>

    Currently selected radio button interaction handler.

    prefixed: string | boolean

    Accessors

    • get interactionHandlers(): RadioButtonInteractionHandler<Value>[]

      Gets a snapshot of all radio button interaction handlers under management.

      Returns RadioButtonInteractionHandler<Value>[]

      A new array of managed RadioButtonInteractionHandler instances

      Returns a shallow copy of the internal array of RadioButtonInteractionHandler instances. Mutate the managed set only via addButton/removeButton/removeInteractionHandler. External mutations to the returned array will not affect internal state.

    • get selected(): undefined | RadioButtonInteractionHandler<Value>

      Gets the currently selected radio button interaction handler.

      Returns undefined | RadioButtonInteractionHandler<Value>

      Currently selected RadioButtonInteractionHandler or undefined

      Returns the RadioButtonInteractionHandler instance that is currently selected in the managed group. Will be undefined if no selection has been made yet.

      const radioManager = new RadioButtonManager<string>();
      const option = new RadioButtonMesh(geometry, materials, { value: "test" });

      radioManager.addButton(option);
      radioManager.select(option.interactionHandler);

      console.log(radioManager.selected.value); // "test"

    Methods

    • Adds radio button interactive objects to the managed group.

      Parameters

      Returns void

      Registers multiple radio button objects for exclusive selection management. Each button's interaction handler will be added to the managed group and configured to participate in the exclusive selection behavior.

      const radioManager = new RadioButtonManager();
      const option1 = new RadioButtonMesh(geometry, materials);
      const option2 = new RadioButtonMesh(geometry, materials);

      // Add multiple buttons at once
      radioManager.addButton(option1, option2);
    • Return an array listing the events for which the emitter has registered listeners.

      Returns (keyof ThreeMouseEventMap<Value>)[]

    • Return the number of listeners listening to a given event.

      Parameters

      Returns number

    • Remove all listeners, or those of the specified event.

      Parameters

      • Optionalevent: keyof ThreeMouseEventMap<Value>

      Returns this

    • Removes a radio button interactive object from the managed group.

      Parameters

      Returns void

      Unregisters the radio button from exclusive selection management and removes event listeners. The button object itself is not destroyed.

    • Remove the listeners of a given event.

      Type Parameters

      Parameters

      Returns this

    • Programmatically selects a specific radio button in the managed group.

      Parameters

      Returns void

      Sets the specified RadioButtonInteractionHandler as selected and deselects all others in the group, implementing exclusive selection behavior. Emits a "select" event to notify listeners of the selection change.

      const radioManager = new RadioButtonManager();
      const option1 = new RadioButtonMesh(geometry, materials);
      const option2 = new RadioButtonMesh(geometry, materials);

      radioManager.addButton(option1, option2);

      // Programmatically select option2
      radioManager.select(option2.interactionHandler);

      select - Emitted when selection changes to the specified handler