Examples
Each example is a live panel and the code that makes it. Most run in Tweakpane and in Blueprint: switch the renderer on the page.
Writing configs
The same panel from a plain object, a class, TypeScript decorators, or generated from the data.
- Plain objects Put the config next to the data in a plain object. TweakpaneBlueprint
-
Classes
Build the config in a class field:
thisis the object that the components edit, and methods are the actions of the buttons. TweakpaneBlueprint - TypeScript decorators Decorators on the fields generate the config. TweakpaneBlueprint
-
Generated from data
generateUiFoldermakes a config from any object: the type of each value picks the component, and nested objects become folders. TweakpaneBlueprint
Binding to data
How a component reads and writes its value: a property of an object, the config itself, functions, or a path.
-
Property binding
property: [object, key]binds a component to a field. TweakpaneBlueprint -
Value in the config
Without a
property, the component keeps its value inconfig.value. TweakpaneBlueprint -
getValue and setValue
Functions instead of a field:
getValuegives the value to show,setValuegets the edited value. TweakpaneBlueprint -
Paths in nested data
A folder gets the data object as its
value, and its children pick their fields with a dotpath, array indices included. TweakpaneBlueprint
Components
The type of a config picks the component. Both renderers have the common set; Tweakpane adds a few.
-
Inputs, numbers and sliders
inputtakes its kind from the value: text, number or boolean. TweakpaneBlueprint -
Dropdowns
The options of a
dropdown(orselect) are itschildren. TweakpaneBlueprint -
Buttons
A
buttoncallsonClick, or the function that itspropertyorvaluepoints to. TweakpaneBlueprint -
Colors and vectors
coloredits a hex string, a number or a three.jsColor;vec2,vec3andvec4edit{x, y, z, w}objects. TweakpaneBlueprint -
Folders and panels
A
foldergroups its children and folds;expandedsets its state andonExpandruns when it opens. TweakpaneBlueprint -
Text areas, tabs and separators
Three components of uiconfig-tweakpane:
textareafor text on several lines,tabswith a folder on each tab, andseparator. Tweakpane
Dynamic panels
Panels that change with the data: computed properties, children that come and go, change events, undo.
-
Hidden, disabled and read-only
hidden,disabled,readOnlyandlabelcan be functions. TweakpaneBlueprint -
Dynamic children
A function in
childrenreturns the child configs on each refresh. TweakpaneBlueprint -
Change events
onChangegets a change event: the new and old value, the config that changed, andlast, which is false while a slider moves. TweakpaneBlueprint - Live text input Tweakpane sets the value of a text input on Enter or when it loses focus. TweakpaneBlueprint
-
Undo and redo
Each renderer records the edits in
ui.undoManagerand binds Ctrl+Z and Ctrl+Shift+Z. TweakpaneBlueprint
Renderers
Options of one renderer: the themes of uiconfig-tweakpane and components of your own.
three.js and threepipe
Colors and vectors of three.js objects, edited in place, and the panels of threepipe.
-
three.js objects
With
ui.THREEset, color and vector components edit three.js objects in place: the material color, the position and the scale of a mesh. TweakpaneBlueprint -
threepipe viewer
threepipe gives its viewer, plugins, objects and materials a
uiConfig. TweakpaneBlueprint - threepipe: edit the picked object Click a part of the model: the panel shows the config of that object and its material. TweakpaneBlueprint