com_palette

com_palette

English | 日本語

com_palette

Overview

com_palette demonstrates how to use the core webg/CommandPalette.js as a UI component independently of WebgApp. It places buttons, toggles, steppers, selects, and an exclusive mode switch in one palette and shows how command definitions connect to application state.

The center 2D preview and HUD read the same state that the palette updates. Switching Obj / Edit / Scpt changes both the active button and the preview. Toggle and stepper changes affect the background or shape on the next frame. This keeps application-specific state in the caller while CommandPalette only displays and updates it.

How to Run

webg Features Used

Implementation Flow

state stores pause, grid, glow, wire, mode, brush, radius, strength, and theme. The command value functions and getCommandState read this object to display the current toggle, stepper, select, and mode-switch state.

Buttons are handled by onCommand, while toggles, steppers, and selects update state through onChange. Calling palette.render() and updating the HUD after changes keeps the palette, preview, and HUD synchronized. pageRows: 4 provides the global limit and pageRowsByPage: [4, 3] changes only the second page to three rows. Buttons count as one cell, while steppers and selects occupy a complete row.

Checkpoints

Controls