Binding facade ​
addBinding(object, key, options?) creates a field for object[key] and returns its builder.
ts
pane.addBinding(settings, "opacity", { min: 0, max: 1, step: 0.01 })
.on("change", ({ value, last }) => {
preview.opacity = value;
if (last) {
saveSettings(settings);
}
});Options ​
ts
interface BindingOptions<TValue> extends FieldLayoutOptions {
label?: string; // default: the property key
align?: "start" | "end"; // default "end" for a checkbox, else "start"
path?: string; // lock path, see Presence below
min?: number;
max?: number;
step?: number;
options?: Record<string, TValue>; // label -> value, in declaration order
view?: DispatchView;
alpha?: boolean;
axisLabels?: Record<string, string>;
axes?: "xy" | "xz" | "yz";
axisStyle?: AxisStyle;
layout?: "segmented" | "grid";
columns?: number;
count?: number;
mode?: "mask" | "index";
start?: number;
names?: Record<number, string>;
}
type DispatchView =
| "buttons"
| "flags"
| "layers"
| "point2d"
| "quaternion"
| "spin"
| "toggle";labelPositionandstackBelowdefault to the pane's field layout.pathis forwarded to the field'spath. APresenceSourceon the pane matches peer locks against it. Leave it unset for a field no peer can hold.
Control selection ​
The first matching rule picks the element:
optionswithview: "buttons":jolly-button-group.optionswithview: "flags"on a number:jolly-flags.options:jolly-select.- Boolean with
view: "toggle":jolly-toggle. - Boolean:
jolly-checkbox. - Number with
view: "layers":jolly-layer-grid. - Number with
min,maxandview: "spin":jolly-spin-slider. - Number with
minandmax:jolly-slider. - Other number:
jolly-number. - Six- or eight-digit hex string:
jolly-color. - Other string:
jolly-text. - Object with numeric
fromandto:jolly-range. - Object with
x,y,zandw:jolly-vector4, orjolly-quaternionwithview: "quaternion". - Object with
x,yandz:jolly-vector3. - Object with
xandy:jolly-vector2, orjolly-point2dwithview: "point2d". - Object with
xandz, oryandz:jolly-vector2on that plane.
- A
viewthe value does not match is ignored.view: "flags"on a value that is not a number falls back tojolly-select, and drops option values that are not numbers. null,undefinedand other values throw aTypeError.jolly-transformis not dispatched. Compose it from three bindings, or use the element.
ts
folder.addBinding(settings, "mode", {
view: "buttons",
options: { Pos: "translate", Angle: "rotate", Scale: "scale" }
});
folder.addBinding(layer, "mask", {
view: "flags",
options: { Default: 1, Player: 2, Terrain: 4 }
});
folder.addBinding(camera, "cullMask", { view: "layers", count: 20 });Per-element options ​
min,max,step: numbers, ranges, vectors andjolly-point2d, shared by every axis.steponjolly-quaternion: degrees per scrub step or arrow key.alpha:jolly-colorwrites#rrggbbaa. On by default for an eight-digit value.axisLabels: per-axis accessible names, such as{ x: "pitch" }.axisStyle:"corner","chip"or"letter", see axis markers.axes: the plane ofjolly-vector2. Defaults to the pair the value carries, so{ x, z }edits and writes backxandz.layout,columns:jolly-button-grouplayout. Zerocolumnssizes the grid itself.columnsonjolly-layer-grid: cells per row of one block. Zero or less keeps the default5.count,mode,start,names: forwarded tojolly-layer-grid.
Write-back ​
- The builder listens to
jolly-inputandjolly-change, assigns the value toobject[key], then runs the handlers. - A math value is copied axis by axis onto the object already at
object[key], so aTHREE.Vector3keeps its identity. Axes the object does not carry are skipped.
ts
pane
.addBinding(area, "position", { step: 1, label: "Min corner" })
.on("change", ({ value }) => {
// Still the same THREE.Vector3.
mesh.position.copy(value);
});Builder ​
ts
interface FacadeBinding<TObject, TKey> extends FacadeItem {
on(name: "change", handler: BindingChangeHandler<TObject[TKey]>): this;
refresh(): void; // re-reads object[key]
}
interface BindingChangeEvent<TValue> {
value: TValue;
last: boolean; // false for jolly-input, true for jolly-change
}- Each
on()call adds a handler. - Use
lastto save or record history once per committed edit.