Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

feat(editor): themed dropdowns, flag pickers & an asset picker in Details

esenginea1482f417989
diff --git a/desktop/electron/extractSchemas.ts b/desktop/electron/extractSchemas.ts
index b0b78b440..14c86e681 100644
--- a/desktop/electron/extractSchemas.ts
+++ b/desktop/electron/extractSchemas.ts
@@ -62,6 +62,7 @@ export interface ComponentSchema {
/** The serialized editor metadata of one component field. */
export interface SerializedFieldMeta {
enum?: Array<{ label: string; value: number }>;
+ flags?: Array<{ label: string; value: number }>;
min?: number;
max?: number;
step?: number;
@@ -193,7 +194,7 @@ interface UserComponentDef {
assetFields?: readonly unknown[];
spineFields?: unknown;
entityFields?: readonly string[];
- fieldMeta?: Record<string, SerializedFieldMeta & { advanced?: boolean; category?: string }>;
+ fieldMeta?: Record<string, SerializedFieldMeta & { advanced?: boolean; category?: string; flags?: Array<{ label: string; value: number }> }>;
}
// Keep only fields the inspector actually consumes (enum / numeric range / unit),
@@ -206,6 +207,7 @@ function pickFieldMeta(
for (const [key, meta] of Object.entries(fieldMeta)) {
const m: SerializedFieldMeta = {};
if (meta.enum && meta.enum.length) m.enum = meta.enum.map((o) => ({ ...o }));
+ if (meta.flags && meta.flags.length) m.flags = meta.flags.map((o) => ({ ...o }));
if (meta.min != null) m.min = meta.min;
if (meta.max != null) m.max = meta.max;
if (meta.step != null) m.step = meta.step;
diff --git a/desktop/src/components/Popover.tsx b/desktop/src/components/Popover.tsx
new file mode 100644
index 000000000..c1bcf946d
--- /dev/null
+++ b/desktop/src/components/Popover.tsx
@@ -0,0 +1,88 @@
+// SPDX-License-Identifier: LicenseRef-PolyForm-Noncommercial-1.0.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file Popover.tsx
+ * @brief A trigger-anchored popover — the one primitive behind the inspector's
+ * themed dropdowns, flag pickers, and asset pickers (and anything else
+ * that needs a floating panel under a field). Portaled to the body,
+ * positioned under the anchor rect, clamped to the viewport (flips above
+ * when it would overflow the bottom), and dismissed on an outside press,
+ * a scroll, a resize, or Escape — the same mechanics as ContextMenu, but
+ * anchored to an element instead of the cursor.
+ */
+import { useEffect, useLayoutEffect, useRef, useState, type ReactNode } from 'react';
+import { createPortal } from 'react-dom';
+
+export function Popover({
+ anchor,
+ width,
+ onClose,
+ children,
+}: {
+ /** The trigger's bounding rect, captured at open time. */
+ anchor: DOMRect;
+ /** Panel width; defaults to the anchor's width (so a dropdown lines up). */
+ width?: number;
+ onClose: () => void;
+ children: ReactNode;
+}) {
+ const ref = useRef<HTMLDivElement>(null);
+ const [pos, setPos] = useState<{ left: number; top: number }>({ left: anchor.left, top: anchor.bottom + 2 });
+
+ // Measure then clamp before paint so the first frame is already on-screen.
+ useLayoutEffect(() => {
+ const el = ref.current;
+ if (!el) return;
+ const r = el.getBoundingClientRect();
+ const pad = 8;
+ let left = anchor.left;
+ if (left + r.width > window.innerWidth - pad) left = Math.max(pad, window.innerWidth - r.width - pad);
+ let top = anchor.bottom + 2;
+ // No room below → flip above the anchor.
+ if (top + r.height > window.innerHeight - pad) top = Math.max(pad, anchor.top - r.height - 2);
+ setPos({ left, top });
+ }, [anchor]);
+
+ useEffect(() => {
+ const close = () => onClose();
+ const onKey = (e: KeyboardEvent) => {
+ if (e.key === 'Escape') onClose();
+ };
+ window.addEventListener('mousedown', close);
+ window.addEventListener('scroll', close, true);
+ window.addEventListener('resize', close);
+ window.addEventListener('keydown', onKey);
+ return () => {
+ window.removeEventListener('mousedown', close);
+ window.removeEventListener('scroll', close, true);
+ window.removeEventListener('resize', close);
+ window.removeEventListener('keydown', onKey);
+ };
+ }, [onClose]);
+
+ return createPortal(
+ <div
+ ref={ref}
+ className="popover"
+ style={{ left: pos.left, top: pos.top, width: width ?? anchor.width }}
+ onMouseDown={(e) => e.stopPropagation()}
+ >
+ {children}
+ </div>,
+ document.body,
+ );
+}
+
+/**
+ * Trigger state for a popover anchored to a button: tracks open + the captured
+ * anchor rect. `open(el)` snapshots the trigger's rect; `close()` clears it.
+ */
+export function usePopover() {
+ const [anchor, setAnchor] = useState<DOMRect | null>(null);
+ return {
+ anchor,
+ isOpen: anchor != null,
+ open: (el: HTMLElement | null) => setAnchor(el?.getBoundingClientRect() ?? null),
+ close: () => setAnchor(null),
+ };
+}
diff --git a/desktop/src/engine/SceneCommands.ts b/desktop/src/engine/SceneCommands.ts
index 03806a276..d5cb0fbea 100644
--- a/desktop/src/engine/SceneCommands.ts
+++ b/desktop/src/engine/SceneCommands.ts
@@ -80,6 +80,7 @@ export function toModelValue(
switch (type) {
case 'number':
case 'enum':
+ case 'flags':
return Number(value);
case 'bool':
return Boolean(value);
diff --git a/desktop/src/engine/schema.ts b/desktop/src/engine/schema.ts
index 31a7bca81..c33495c2e 100644
--- a/desktop/src/engine/schema.ts
+++ b/desktop/src/engine/schema.ts
@@ -184,6 +184,7 @@ export interface UserComponentSchema {
/** A serialized field's editor metadata, as carried in `schemas.json`. */
export interface UserFieldMeta {
enum?: EnumOption[];
+ flags?: EnumOption[];
min?: number;
max?: number;
step?: number;
@@ -258,6 +259,7 @@ export function fieldMetaFor(compType: string, key: string): UserFieldMeta | nul
if (fromDef) {
return {
enum: fromDef.enum?.map((o) => ({ label: o.label, value: o.value })),
+ flags: fromDef.flags?.map((o) => ({ label: o.label, value: o.value })),
min: fromDef.min,
max: fromDef.max,
step: fromDef.step,
@@ -291,6 +293,8 @@ function fieldFor(
let field: InspectorField | null;
if (at) {
field = { key, label: prettyLabel(key), type: 'asset', value: typeof value === 'string' ? value : 0, assetType: at };
+ } else if (meta?.flags && meta.flags.length) {
+ field = { key, label: prettyLabel(key), type: 'flags', value: Number(value) || 0, options: meta.flags.map((o) => ({ ...o })) };
} else if (meta?.enum && meta.enum.length) {
field = { key, label: prettyLabel(key), type: 'enum', value: Number(value) || 0, options: meta.enum.map((o) => ({ ...o })) };
} else {
diff --git a/desktop/src/panels/Details.tsx b/desktop/src/panels/Details.tsx
index cf5b97cf8..32216e6bc 100644
--- a/desktop/src/panels/Details.tsx
+++ b/desktop/src/panels/Details.tsx
@@ -5,6 +5,7 @@ import {
Box,
Camera,
Check,
+ ChevronDown,
ChevronRight,
Code2,
Component as ComponentIcon,
@@ -39,8 +40,9 @@ import type { SceneData } from 'esengine';
import { modelAddableComponentEntries, subscribeSchemas, getSchemaRevision, prettyLabel } from '@/engine/schema';
import { ProjectStore } from '@/project/ProjectStore';
import { ContextMenu } from '@/components/Menu';
+import { Popover, usePopover } from '@/components/Popover';
import { AddComponentMenu } from '@/components/AddComponentMenu';
-import type { InspectorComponent, InspectorField, InspectorFieldValue, EntityId, NodeKind, EnumOption } from '@/types';
+import type { InspectorComponent, InspectorField, InspectorFieldValue, EntityId, NodeKind, EnumOption, AssetType } from '@/types';
const AXES = ['x', 'y', 'z'];
const fmt = (n: number) => String(Math.round(n * 1000) / 1000);
@@ -243,9 +245,9 @@ function VecControl({
);
}
-// A named-int dropdown (e.g. Camera projection, body type). The stored value is
-// the option's int; an out-of-range value keeps a synthetic row so the select
-// never silently misrepresents the model.
+// A named-int dropdown (e.g. Camera projection, body type) — a themed popover, not
+// a native <select>, so the list matches the editor and searches when long. The
+// stored value is the option's int; an unknown value shows a "(n)" placeholder.
function EnumControl({
value,
options,
@@ -254,25 +256,107 @@ function EnumControl({
onEnd,
onChange,
}: ControlGesture & { value: number; options: EnumOption[]; mixed?: boolean; onChange: (v: number) => void }) {
- const known = options.some((o) => o.value === value);
+ const pop = usePopover();
+ const trigger = useRef<HTMLButtonElement>(null);
+ const [q, setQ] = useState('');
+ const cur = options.find((o) => o.value === value);
+ const label = mixed ? '' : cur ? prettyLabel(cur.label) : `(${value})`;
+ const searchable = options.length > 8;
+ const ql = q.trim().toLowerCase();
+ const filtered = ql ? options.filter((o) => prettyLabel(o.label).toLowerCase().includes(ql)) : options;
+ const close = () => {
+ pop.close();
+ onEnd?.();
+ };
+ const toggle = () => {
+ if (pop.isOpen) return close();
+ setQ('');
+ onBegin?.();
+ pop.open(trigger.current);
+ };
return (
- <span className="field">
- <select
- value={mixed ? '' : String(value)}
- onChange={(e) => {
- onBegin?.();
- onChange(Number(e.target.value));
- onEnd?.();
- }}
- >
- {mixed && <option value="">—</option>}
- {!mixed && !known && <option value={String(value)}>{`(${value})`}</option>}
- {options.map((o) => (
- <option key={o.value} value={String(o.value)}>
- {prettyLabel(o.label)}
- </option>
- ))}
- </select>
+ <span className="field dropdown">
+ <button ref={trigger} type="button" className="dd-trigger" onMouseDown={(e) => e.stopPropagation()} onClick={toggle}>
+ <span className={`dd-val${mixed ? ' mixed' : ''}`}>{mixed ? '—' : label}</span>
+ <ChevronDown size={12} strokeWidth={2} />
+ </button>
+ {pop.anchor && (
+ <Popover anchor={pop.anchor} width={Math.max(pop.anchor.width, 150)} onClose={close}>
+ {searchable && (
+ <div className="dd-search">
+ <Search size={12} strokeWidth={2} />
+ <input autoFocus placeholder="Search" value={q} spellCheck={false} onChange={(e) => setQ(e.target.value)} />
+ </div>
+ )}
+ <div className="dd-list">
+ {filtered.map((o) => (
+ <button
+ key={o.value}
+ type="button"
+ className={`dd-opt${o.value === value && !mixed ? ' on' : ''}`}
+ onClick={() => {
+ onChange(o.value);
+ close();
+ }}
+ >
+ <span className="dd-opt-label">{prettyLabel(o.label)}</span>
+ {o.value === value && !mixed && <Check size={12} strokeWidth={2.4} />}
+ </button>
+ ))}
+ {filtered.length === 0 && <div className="dd-empty">No match</div>}
+ </div>
+ </Popover>
+ )}
+ </span>
+ );
+}
+
+// An int bitmask, edited as a multi-select of its bits (e.g. Camera clear flags).
+// The popover stays open across toggles; the whole burst is one undo step (the
+// field's gesture coalesces). The summary reads "Color | Depth" or "None".
+function FlagsControl({
+ value,
+ options,
+ mixed,
+ onBegin,
+ onEnd,
+ onChange,
+}: ControlGesture & { value: number; options: EnumOption[]; mixed?: boolean; onChange: (v: number) => void }) {
+ const pop = usePopover();
+ const trigger = useRef<HTMLButtonElement>(null);
+ const bits = options.filter((o) => o.value !== 0);
+ const active = bits.filter((o) => (value & o.value) === o.value);
+ const summary = mixed ? '—' : active.length ? active.map((o) => prettyLabel(o.label)).join(' | ') : 'None';
+ const close = () => {
+ pop.close();
+ onEnd?.();
+ };
+ const toggle = () => {
+ if (pop.isOpen) return close();
+ onBegin?.();
+ pop.open(trigger.current);
+ };
+ return (
+ <span className="field dropdown">
+ <button ref={trigger} type="button" className="dd-trigger" onMouseDown={(e) => e.stopPropagation()} onClick={toggle}>
+ <span className={`dd-val${mixed ? ' mixed' : ''}`}>{summary}</span>
+ <ChevronDown size={12} strokeWidth={2} />
+ </button>
+ {pop.anchor && (
+ <Popover anchor={pop.anchor} width={Math.max(pop.anchor.width, 150)} onClose={close}>
+ <div className="dd-list">
+ {bits.map((o) => {
+ const on = !mixed && (value & o.value) === o.value;
+ return (
+ <button key={o.value} type="button" className="dd-opt" onClick={() => onChange(value ^ o.value)}>
+ <span className={`fchk${on ? ' on' : ''}`}>{on && <Check size={10} strokeWidth={3.2} />}</span>
+ <span className="dd-opt-label">{prettyLabel(o.label)}</span>
+ </button>
+ );
+ })}
+ </div>
+ </Popover>
+ )}
</span>
);
}
@@ -428,8 +512,11 @@ function ColorControl({
);
}
-// An asset-ref field: a drop target showing the bound asset (thumbnail + name).
-// The trailing button clears when bound (×), or reads as the pick affordance.
+const isImageAsset = (t: AssetType): boolean => t === 'texture' || t === 'sprite';
+
+// An asset-ref field: a drop target showing the bound asset, PLUS a pick popover
+// (search + thumbnail grid of the project's matching assets) on the lens button —
+// so a ref can be set without dragging from the Content Browser. Clear with ×.
function AssetControl({
value,
assetType,
@@ -442,22 +529,46 @@ function AssetControl({
onChange: (v: string | number) => void;
}) {
const [over, setOver] = useState(false);
+ const box = useRef<HTMLDivElement>(null);
+ const pop = usePopover();
+ const [q, setQ] = useState('');
const info = ProjectStore.assetInfo(value);
- const onDrop = (e: React.DragEvent) => {
- e.preventDefault();
- setOver(false);
- const path = e.dataTransfer.getData('application/x-estella-asset') || e.dataTransfer.getData('text/plain');
- if (!path) return;
+ const setRefFromPath = (path: string) => {
onBegin?.();
void ProjectStore.assetRefForPath(path, assetType).then((ref) => {
if (ref) onChange(ref);
onEnd?.();
});
};
+ const onDrop = (e: React.DragEvent) => {
+ e.preventDefault();
+ setOver(false);
+ const path = e.dataTransfer.getData('application/x-estella-asset') || e.dataTransfer.getData('text/plain');
+ if (path) setRefFromPath(path);
+ };
+
+ const openPick = () => {
+ setQ('');
+ onBegin?.();
+ pop.open(box.current);
+ };
+ const close = () => {
+ pop.close();
+ onEnd?.();
+ };
+ const pick = (ref: string | number) => {
+ onChange(ref);
+ close();
+ };
+ const ql = q.trim().toLowerCase();
+ const assets = pop.isOpen
+ ? ProjectStore.listAssets(assetType).filter((a) => !ql || a.name.toLowerCase().includes(ql))
+ : [];
return (
<div
+ ref={box}
className={`assetref${over ? ' is-over' : ''}`}
title={info?.path}
onDragOver={(e) => {
@@ -475,19 +586,52 @@ function AssetControl({
)}
</span>
<span className="an">{info ? info.name : 'None'}</span>
- <button
- type="button"
- className="pk"
- title={info ? 'Clear' : 'Pick'}
- onClick={() => {
- if (!info) return;
- onBegin?.();
- onChange(0);
- onEnd?.();
- }}
- >
- {info ? <X size={11} strokeWidth={2} /> : <Search size={11} strokeWidth={2} />}
+ <button type="button" className="pk" title="Pick asset" onMouseDown={(e) => e.stopPropagation()} onClick={openPick}>
+ <Search size={11} strokeWidth={2} />
</button>
+ {info && (
+ <button
+ type="button"
+ className="pk"
+ title="Clear"
+ onClick={() => {
+ onBegin?.();
+ onChange(0);
+ onEnd?.();
+ }}
+ >
+ <X size={11} strokeWidth={2} />
+ </button>
+ )}
+ {pop.anchor && (
+ <Popover anchor={pop.anchor} width={Math.max(pop.anchor.width, 240)} onClose={close}>
+ <div className="dd-search">
+ <Search size={12} strokeWidth={2} />
+ <input autoFocus placeholder="Search assets" value={q} spellCheck={false} onChange={(e) => setQ(e.target.value)} />
+ </div>
+ <div className="asset-grid">
+ <button type="button" className={`asset-opt${value === 0 || !info ? ' on' : ''}`} onClick={() => pick(0)}>
+ <span className="th">
+ <X size={13} strokeWidth={2} />
+ </span>
+ <span className="an">None</span>
+ </button>
+ {assets.map((a) => (
+ <button key={a.ref} type="button" className={`asset-opt${a.ref === value ? ' on' : ''}`} title={a.path} onClick={() => pick(a.ref)}>
+ <span className="th">
+ {isImageAsset(a.type) ? (
+ <img src={`estella://project/${a.path}`} alt="" draggable={false} />
+ ) : (
+ <AssetIcon type={a.type} size={18} />
+ )}
+ </span>
+ <span className="an">{a.name}</span>
+ </button>
+ ))}
+ {assets.length === 0 && <div className="dd-empty">No matching assets</div>}
+ </div>
+ </Popover>
+ )}
</div>
);
}
@@ -567,6 +711,18 @@ function FieldRow({ entities, comp, field, write }: { entities: EntityId[]; comp
/>
);
break;
+ case 'flags':
+ control = (
+ <FlagsControl
+ value={field.value as number}
+ options={field.options ?? []}
+ mixed={mixed}
+ onBegin={begin}
+ onEnd={end}
+ onChange={apply}
+ />
+ );
+ break;
case 'color':
control = <ColorControl value={field.value as string} onBegin={begin} onEnd={end} onChange={apply} />;
break;
diff --git a/desktop/src/project/ProjectStore.ts b/desktop/src/project/ProjectStore.ts
index f689f25cd..0e0359810 100644
--- a/desktop/src/project/ProjectStore.ts
+++ b/desktop/src/project/ProjectStore.ts
@@ -13,8 +13,26 @@ import { setPrefabBaseResolver } from '@/engine/SceneQuery';
import { setUserSchemas, userSchema, type UserComponentSchema } from '@/engine/schema';
import { useSelection } from '@/store/selectionStore';
import { Toasts } from '@/store/Toasts';
+import { assetTypeOf } from '@/project/assetMeta';
+import type { AssetType } from '@/types';
import { resolveLayout, WORKSPACE_DIR, PROJECT_MANIFEST_FILE, type OpenedProject, type ProjectFeatures, type ProjectLayout, type WorkspaceState } from './format';
+/** Whether an asset of the editor `type` is a valid pick for a `fieldType` slot. */
+function assetMatchesSlot(type: AssetType, fieldType?: string): boolean {
+ if (!fieldType) return true;
+ // A 'texture' slot accepts any image (texture or sprite); others match by name.
+ if (fieldType === 'texture') return type === 'texture' || type === 'sprite';
+ return type === fieldType;
+}
+
+/** A pickable asset for the inspector's asset picker. */
+export interface AssetEntry {
+ ref: string;
+ path: string;
+ name: string;
+ type: AssetType;
+}
+
/**
* Editor-side project/workspace model (RC12 §E7-3 / §E6-1).
*
@@ -522,6 +540,18 @@ class ProjectStoreImpl {
return path ? { path, name: path.split('/').pop() ?? path } : null;
}
+ /** Project assets valid for an asset slot (the inspector's asset picker), by name. */
+ listAssets(fieldType?: string): AssetEntry[] {
+ const out: AssetEntry[] = [];
+ for (const [uuid, path] of this.uuidToPath) {
+ const name = path.split('/').pop() ?? path;
+ const type = assetTypeOf(name);
+ if (!assetMatchesSlot(type, fieldType)) continue;
+ out.push({ ref: UUID_PREFIX + uuid, path, name, type });
+ }
+ return out.sort((a, b) => a.name.localeCompare(b.name));
+ }
+
/**
* Turn a Content-Browser drag (a project-relative path) into a portable
* `@uuid:` ref, preloading the asset so the Reconciler's synchronous projection
diff --git a/desktop/src/theme/inspector.css b/desktop/src/theme/inspector.css
index 159060350..ff8a84de5 100644
--- a/desktop/src/theme/inspector.css
+++ b/desktop/src/theme/inspector.css
@@ -121,6 +121,38 @@
/* compact exact-entry box paired with a slider track */
.snum { width: 54px; flex-shrink: 0; display: flex; }
+/* ── themed dropdown / flags / asset picker (a Popover under the field) ── */
+.field.dropdown { padding: 0; overflow: hidden; }
+.dd-trigger { width: 100%; height: 100%; display: flex; align-items: center; gap: 4px; padding: 0 4px 0 7px; background: none; border: none; color: var(--text); font-size: var(--fs-sm); cursor: pointer; min-width: 0; }
+.dd-val { flex: 1; min-width: 0; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.dd-val.mixed { color: var(--text-mute); }
+.dd-trigger > svg { color: var(--text-mute); flex-shrink: 0; }
+.dd-trigger:hover > svg { color: var(--text-dim); }
+
+.popover { position: fixed; z-index: 150; background: var(--srf-3); border: 1px solid var(--border-line); border-radius: var(--r-md); box-shadow: var(--shadow-3); padding: 3px; max-height: 320px; display: flex; flex-direction: column; min-width: 0; }
+.dd-search { display: flex; align-items: center; gap: 6px; padding: 4px 7px; margin-bottom: 2px; border-bottom: 1px solid var(--border); color: var(--text-mute); flex-shrink: 0; }
+.dd-search input { flex: 1; min-width: 0; background: none; border: none; outline: none; color: var(--text); font-size: var(--fs-sm); }
+.dd-search input::placeholder { color: var(--text-mute); }
+.dd-list { overflow-y: auto; display: flex; flex-direction: column; min-height: 0; }
+.dd-opt { display: flex; align-items: center; gap: 7px; height: 25px; padding: 0 8px; background: none; border: none; color: var(--text-dim); font-size: var(--fs-sm); text-align: left; cursor: pointer; border-radius: var(--r-sm); }
+.dd-opt:hover { background: var(--acc-soft); color: var(--text); }
+.dd-opt.on { color: var(--acc-hi); }
+.dd-opt-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.dd-opt > svg { color: var(--acc-hi); flex-shrink: 0; }
+.dd-opt .fchk { width: 13px; height: 13px; border: 1px solid var(--border-line); border-radius: var(--r-xs); display: grid; place-items: center; color: transparent; flex-shrink: 0; }
+.dd-opt .fchk.on { background: var(--acc); border-color: var(--acc); color: #fff; }
+.dd-empty { padding: 9px; text-align: center; color: var(--text-mute); font-size: var(--fs-xs); }
+
+/* asset picker — a thumbnail grid in the popover */
+.asset-grid { overflow-y: auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 2px; min-height: 0; max-height: 280px; }
+.asset-opt { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px; background: none; border: 1px solid transparent; border-radius: var(--r-sm); color: var(--text-dim); font-size: var(--fs-2xs); cursor: pointer; min-width: 0; }
+.asset-opt:hover { background: var(--acc-soft); color: var(--text); }
+.asset-opt.on { border-color: var(--acc); color: var(--acc-hi); }
+.asset-opt .th { width: 42px; height: 42px; border-radius: var(--r-xs); background: var(--inset); display: grid; place-items: center; color: var(--text-mute); overflow: hidden; flex-shrink: 0; }
+.asset-opt .th img { width: 100%; height: 100%; object-fit: contain; }
+.asset-opt .an { width: 100%; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
+.asset-grid .dd-empty { grid-column: 1 / -1; }
+
/* multi-select: a value the selection disagrees on (shows a "—" placeholder) */
.prop.mixed .prop-label { color: var(--text-mute); }
.toggle.mixed { background: var(--srf-5); }
diff --git a/desktop/src/types.ts b/desktop/src/types.ts
index 1b1fd9c32..d96389bac 100644
--- a/desktop/src/types.ts
+++ b/desktop/src/types.ts
@@ -36,6 +36,7 @@ export type InspectorFieldType =
| 'angle' // 2D rotation: a quaternion shown/edited as Z degrees
| 'color'
| 'enum' // an int field with named options, shown as a dropdown
+ | 'flags' // an int bitmask, shown as a multi-select of its bits
| 'asset'; // a texture/material/font/... ref (@uuid: string, or 0 for none)
/** A dropdown option for an `enum` field: the label shown, the int stored. */
diff --git a/desktop/tests/inspector-model.test.ts b/desktop/tests/inspector-model.test.ts
index fbc45d713..7ce88e460 100644
--- a/desktop/tests/inspector-model.test.ts
+++ b/desktop/tests/inspector-model.test.ts
@@ -113,6 +113,22 @@ describe('Unknown-component inspector (schemas.json consumer)', () => {
expect(enumFieldOptions('Camera', 'orthoSize')).toBeNull(); // a plain number, not an enum
});
+ it("builds a bitmask field as type 'flags' carrying its bit options", () => {
+ const fresh = EditorSession.create();
+ fresh.model.adopt(
+ {
+ version: '1.0',
+ name: 'cam',
+ entities: [{ id: 1, name: 'Cam', parent: null, children: [], components: [{ type: 'Camera', data: { clearFlags: 3 } }] }],
+ } as unknown as SceneData,
+ new Map([[1, 1]]),
+ );
+ const cf = fresh.query.readInspector(1).find((c) => c.name === 'Camera')!.fields.find((f) => f.key === 'clearFlags')!;
+ expect(cf.type).toBe('flags');
+ expect(cf.value).toBe(3); // Color | Depth
+ expect(cf.options!.map((o) => o.label)).toEqual(['Color', 'Depth']);
+ });
+
it("builds an enum field as type 'enum' carrying its options + stored int", () => {
const fresh = EditorSession.create();
fresh.model.adopt(
diff --git a/sdk/src/component.ts b/sdk/src/component.ts
index a08679c72..6fad16e51 100644
--- a/sdk/src/component.ts
+++ b/sdk/src/component.ts
@@ -34,6 +34,8 @@ export interface AssetRef {
export interface FieldMeta {
/** Render as a dropdown of these options; the stored value is the option's int. */
enum?: ReadonlyArray<{ label: string; value: number }>;
+ /** Render as a bitmask multi-select; each option is a single bit. */
+ flags?: ReadonlyArray<{ label: string; value: number }>;
/** Hard numeric range — clamps both typed entry and drag-scrub. */
min?: number;
max?: number;
@@ -589,7 +591,8 @@ export const Camera = defineBuiltin<CameraData>('Camera',
{
fields: {
projectionType: { enum: enumOptions(ProjectionType) },
- clearFlags: { enum: enumOptions(ClearFlags) },
+ // A bitmask (ColorAndDepth = Color | Depth), so a multi-select, not a dropdown.
+ clearFlags: { flags: [{ label: 'Color', value: 1 }, { label: 'Depth', value: 2 }] },
fov: { min: 1, max: 179, unit: '°' },
orthoSize: { min: 0 },
nearPlane: { min: 0, advanced: true },