Visor Pixel 3D auténtico
Renderiza los modelos con el trazador analítico Pixel 3D de Vectrune, con sombreado curvo, brillo emisivo, sombras de contacto, papel cebolla y gizmos 3D para mover o redimensionar.
Esculpe modelos Pixel 3D sólidos con bloques y formas analíticas, crea múltiples clips @Animation en tiempo real y exporta código .rune válido.
No hay archivos coincidentes.
#!RUNE
import "parts"
@App
name = RuneModelStudio
version = 1.0
type = REST
port = 3002
@Frontend
type = rune-web
path = %ROOT%
page = model_studio
@Page/model_studio
title = Rune Model Studio — Pixel-3D Model Editor & Animator
style = model_studio
logic = model_studio
on_mount = initStudio
view:
main .model-studio-cabinet:
ModelStudioHeader
ModelProjectBar
div .model-workspace:
ModelToolsPanel
ModelViewportPanel
ModelInspectorPanel
ModelTimelinePanel
ModelCodeTabs
@Component/AxisStepper
props: [tag, axis_class, value, field, step]
view:
div .ms-axis-row:
span .ms-axis-tag .ax-{axis_class} "{tag}"
button .ms-nudge type=button click="nudgePrimitive('{field}', -{step})" "−"
span .ms-axis-val "{value}"
button .ms-nudge type=button click="nudgePrimitive('{field}', {step})" "+"
@Component/ModelCodeTabs
view:
section .ms-code-cabinet aria-label="Rune code export and import":
div .ms-tab-bar:
button .ms-tab-btn {.active when active_lower_tab == 'export'} type=button click="setLowerTab('export')" "Generated .rune code"
button .ms-tab-btn {.active when active_lower_tab == 'import'} type=button click="setLowerTab('import')" "Import .rune model"
div .ms-tab-body:
if active_lower_tab == 'export':
div .ms-code-toolbar:
label .ms-check-inline:
input type=checkbox checked="{export_include_animations}" change="toggleExportAnimations"
span "Include @Animation clips"
div .ms-code-actions:
button .ms-btn-sm type=button click="copyRuneCode" "Copy .rune"
button .ms-btn-sm .ms-btn-export type=button click="exportRune" "Download .rune"
pre .ms-code-preview tabindex=0 "{exported_rune}"
if active_lower_tab == 'import':
div .ms-import-box:
p .ms-import-hint "Paste any Pixel-3D @Palette, @Model, and @Animation declarations (blocks:, shapes:, unit, emissive, contact_shadow) from a Vectrune game to edit or animate them here."
textarea #ms-import-textarea .ms-import-textarea rows=10 data-preserve-draft=true placeholder="@Palette/hero\ncolors = {\"c\":\"#00e5ff\"}\n\n@Model/hero\npalette = hero\nunit = 0.125\nblocks:\n {\"from\":[-2,-2,0],\"size\":[4,4,6],\"color\":\"c\"}" on_input="setImportCode(this.value)" aria-label="Paste Rune model code" "{import_code}"
div .ms-import-actions:
button .ms-btn-storage .ms-btn-accent type=button click="importRuneCode" "Load into Model Studio"
@Component/ModelStudioHeader
view:
header .ms-header:
div .ms-brand:
h1 .ms-title "RUNE MODEL STUDIO"
span .ms-badge "PIXEL-3D"
p .ms-status role=status aria-live=polite "{status_message}"
div .ms-header-actions:
button .ms-btn-ghost type=button click="undoEdit" disabled="{!can_undo}" title="Undo last edit" "↩ Undo"
button .ms-btn-ghost type=button click="redoEdit" disabled="{!can_redo}" title="Redo edit" "↪ Redo"
button .ms-btn-fullscreen type=button click="toggleFullscreen" aria-pressed="{is_fullscreen}":
"{is_fullscreen ? 'Exit fullscreen' : 'Fullscreen'}"
@Component/ModelInspectorPanel
view:
aside .ms-panel .ms-inspector-panel aria-label="Selected part inspector":
div .ms-section:
div .ms-section-head:
h2 .ms-panel-title "Parts · {frame_label}"
span .ms-count "{primitive_count}"
div .ms-parts-list:
for prim in active_primitives:
div .ms-part-item {.selected when prim.is_selected}:
button .ms-part-select type=button click="selectPrimitive(prim.id)" title="{prim.name}":
span .ms-part-dot style="background: {prim.hex};"
span .ms-part-name "{prim.name}"
span .ms-part-meta "{prim.kind}"
div .ms-part-quick:
button .ms-mini-btn type=button click="duplicatePrimitive(prim.id)" title="Duplicate part" "⧉"
button .ms-mini-btn .danger type=button click="deletePrimitive(prim.id)" title="Delete part" "×"
if has_selection:
div .ms-section .ms-prop-section:
div .ms-section-head:
h2 .ms-panel-title "Inspector"
div .ms-prop-actions:
button .ms-btn-xs type=button click="duplicatePrimitive(selected_primitive_id)" title="Duplicate selected" "Dup"
button .ms-btn-xs type=button click="mirrorPrimitive(selected_primitive_id, 'y')" title="Mirror across Y axis" "Flip Y"
button .ms-btn-xs type=button click="mirrorPrimitive(selected_primitive_id, 'x')" title="Mirror across X axis" "Flip X"
div .ms-kind-row:
button .ms-pill {.active when sel_kind == 'box'} type=button click="setPrimitiveKind('box')" "Box"
button .ms-pill {.active when sel_kind == 'sphere'} type=button click="setPrimitiveKind('sphere')" "Sphere"
button .ms-pill {.active when sel_kind == 'cylinder'} type=button click="setPrimitiveKind('cylinder')" "Cyl"
button .ms-pill {.active when sel_kind == 'ramp'} type=button click="setPrimitiveKind('ramp')" "Ramp"
div .ms-prop-name-row:
span .ms-prop-lbl "Name"
input #ms-part-name .ms-input-sm type=text maxlength=32 value="{sel_name}" data-preserve-draft=true on_input="setPrimitiveField('name', this.value)" aria-label="Part name"
if sel_kind == 'box' or sel_kind == 'ramp':
div .ms-vec-group:
span .ms-vec-title "From (X · Y · Z)"
AxisStepper tag="X" axis_class="x" value="{sel_from_x}" field="from_x" step="1"
AxisStepper tag="Y" axis_class="y" value="{sel_from_y}" field="from_y" step="1"
AxisStepper tag="Z" axis_class="z" value="{sel_from_z}" field="from_z" step="1"
div .ms-vec-group:
span .ms-vec-title "Size (W · D · H)"
AxisStepper tag="W" axis_class="x" value="{sel_size_x}" field="size_x" step="1"
AxisStepper tag="D" axis_class="y" value="{sel_size_y}" field="size_y" step="1"
AxisStepper tag="H" axis_class="z" value="{sel_size_z}" field="size_z" step="1"
else:
div .ms-vec-group:
span .ms-vec-title "Center (X · Y · Z)"
AxisStepper tag="X" axis_class="x" value="{sel_center_x}" field="center_x" step="0.5"
AxisStepper tag="Y" axis_class="y" value="{sel_center_y}" field="center_y" step="0.5"
AxisStepper tag="Z" axis_class="z" value="{sel_center_z}" field="center_z" step="0.5"
div .ms-vec-group:
span .ms-vec-title "Dimensions"
AxisStepper tag="R" axis_class="r" value="{sel_radius}" field="radius" step="0.5"
if sel_kind == 'cylinder':
AxisStepper tag="H" axis_class="z" value="{sel_height}" field="height" step="0.5"
div .ms-vec-group:
span .ms-vec-title "Render Order"
AxisStepper tag="Ord" axis_class="z" value="{sel_order}" field="order" step="1"
@Component/ModelProjectBar
view:
section .ms-project-bar aria-label="Model project":
div .ms-project-fields:
label .ms-field-inline for=ms-model-title:
span .ms-label "Title"
input #ms-model-title .ms-input-text type=text maxlength=60 value="{model_title}" data-preserve-draft=true on_input="renameModel(this.value)" aria-label="Model title"
label .ms-field-inline for=ms-model-id:
span .ms-label "@Model/"
input #ms-model-id .ms-input-id type=text maxlength=40 value="{model_id}" data-preserve-draft=true on_input="setModelId(this.value)" aria-label="Model identifier"
div .ms-project-actions:
button .ms-btn-storage .ms-btn-accent type=button click="newModel" "New Model"
select .ms-select aria-label="Open model or preset" change="openModel(this.value)":
option value="" selected=true disabled=true "Open preset / saved…"
option value=reload_saved "Reload current saved model"
if saved_models.length > 0:
optgroup label="Saved models":
for entry in saved_models:
option value="{entry.key}" "{entry.title}"
optgroup label="Pixel-3D Presets":
option value=dungeon_knight "Dungeon Knight (4f Sword Pose)"
option value=neon_drone "Neon Hover Drone (Glow + Bob)"
option value=lagoon_clownfish "Lagoon Clownfish (3f Swim)"
option value=neighborhood_pup "Neighborhood Pup (4f Trot)"
option value=marble_sentry "Marble Sentry (4f Spin Patrol)"
button .ms-btn-storage type=button click="saveToStorage" "Save"
button .ms-btn-storage type=button click="setLowerTab('import')" "Import .rune"
button .ms-btn-storage .ms-btn-export type=button click="exportRune" "Export .rune"
@Component/ModelTimelinePanel
view:
section .ms-timeline-panel aria-label="Animation clips, timeline, and frame transforms":
div .ms-clips-bar:
div .ms-clips-list:
span .ms-label "Clips"
for c in clip_items:
button .ms-clip-tab {.active when c.is_active} type=button click="selectClip(c.index)":
span .ms-clip-name "{c.name}"
span .ms-clip-meta "{c.frame_count}f"
div .ms-clip-controls:
input #ms-clip-name .ms-input-sm .ms-clip-input type=text maxlength=24 value="{active_clip_name}" data-preserve-draft=true on_input="renameCurrentClip(this.value)" aria-label="Active clip name" title="Rename active animation clip"
span .ms-clip-path title="Exported @Animation path" "@Animation/{model_id}/{active_clip_id}"
button .ms-btn-sm .ms-btn-accent type=button click="addClip" title="Create a new animation clip from the current pose" "+ Clip"
button .ms-btn-sm type=button click="duplicateCurrentClip" title="Duplicate active clip" "Dup Clip"
button .ms-btn-sm .danger type=button click="deleteCurrentClip" title="Delete active clip" "Delete Clip"
div .ms-timeline-top:
div .ms-transport:
button .ms-btn-icon type=button click="stepFrame(-1)" aria-label="Previous frame" title="Previous frame" "‹"
if !is_playing:
button .ms-btn-play type=button click="playAnimation" "▶ Play"
if is_playing:
button .ms-btn-pause type=button click="pauseAnimation" "⏸ Pause"
button .ms-btn-icon type=button click="stopAnimation" aria-label="Stop animation" title="Stop and rewind" "■"
button .ms-btn-icon type=button click="stepFrame(1)" aria-label="Next frame" title="Next frame" "›"
div .ms-fps-group:
span .ms-label "FPS"
button .ms-nudge type=button click="changeFps(-1)" aria-label="Decrease FPS" "−"
span .ms-fps-val "{fps}"
button .ms-nudge type=button click="changeFps(1)" aria-label="Increase FPS" "+"
div .ms-mode-group:
button .ms-pill {.active when playback_mode == 'loop'} type=button click="setPlaybackMode('loop')" "Loop"
button .ms-pill {.active when playback_mode == 'pingpong'} type=button click="setPlaybackMode('pingpong')" "Ping-Pong"
button .ms-pill {.active when playback_mode == 'once'} type=button click="setPlaybackMode('once')" "Once"
button .ms-pill {.active when interpolate_transforms} type=button click="toggleInterpolate" aria-pressed="{interpolate_transforms}" title="Smoothly interpolate transforms between keyframes" "Tween"
div .ms-frame-ops:
button .ms-btn-sm .ms-btn-accent type=button click="duplicateCurrentFrame" "+ Duplicate Pose"
button .ms-btn-sm type=button click="addBlankFrame" "+ Blank Frame"
button .ms-btn-sm type=button click="copyCurrentPose" title="Copy pose to reuse in another clip" "Copy Pose"
if has_copied_pose:
button .ms-btn-sm .ms-btn-accent type=button click="pasteCopiedPose" title="Insert copied pose after current frame" "Paste Pose"
button .ms-btn-sm type=button click="moveCurrentFrame(-1)" title="Move frame left" "←"
button .ms-btn-sm type=button click="moveCurrentFrame(1)" title="Move frame right" "→"
button .ms-btn-sm .danger type=button click="deleteCurrentFrame" "Delete"
div .ms-frames-strip:
for item in frame_items:
button .ms-frame-card {.active when item.is_active} type=button click="selectFrame(item.index)":
span .ms-frame-num "F{item.number}"
span .ms-frame-name "{item.label}"
span .ms-frame-meta "{item.count} parts"
div .ms-transform-bar:
div .ms-tf-label-cell:
span .ms-label "Pose"
input #ms-frame-label .ms-input-sm type=text maxlength=24 value="{frame_label}" data-preserve-draft=true on_input="renameCurrentFrame(this.value)" aria-label="Frame label"
div .ms-tf-pill:
span .ms-tf-key "Z"
button .ms-nudge type=button click="nudgeFrameTransform('z', -0.1)" "−"
span .ms-tf-val "{frame_z}"
button .ms-nudge type=button click="nudgeFrameTransform('z', 0.1)" "+"
div .ms-tf-pill:
span .ms-tf-key "Angle"
button .ms-nudge type=button click="nudgeFrameTransform('angle', -15)" "−"
span .ms-tf-val "{frame_angle}°"
button .ms-nudge type=button click="nudgeFrameTransform('angle', 15)" "+"
div .ms-tf-pill:
span .ms-tf-key "Pitch"
button .ms-nudge type=button click="nudgeFrameTransform('pitch', -5)" "−"
span .ms-tf-val "{frame_pitch}°"
button .ms-nudge type=button click="nudgeFrameTransform('pitch', 5)" "+"
div .ms-tf-pill:
span .ms-tf-key "Scale"
button .ms-nudge type=button click="nudgeFrameTransform('scale', -0.1)" "−"
span .ms-tf-val "{frame_scale}"
button .ms-nudge type=button click="nudgeFrameTransform('scale', 0.1)" "+"
div .ms-tf-pill:
span .ms-tf-key "Dissolve"
button .ms-nudge type=button click="nudgeFrameTransform('dissolve', -0.1)" "−"
span .ms-tf-val "{frame_dissolve}"
button .ms-nudge type=button click="nudgeFrameTransform('dissolve', 0.1)" "+"
button .ms-btn-xs type=button click="resetFrameTransform" "Reset"
@Component/ModelToolsPanel
view:
aside .ms-panel .ms-tools-panel aria-label="Primitives and palette":
div .ms-section:
div .ms-section-head:
h2 .ms-panel-title "Add Primitive"
span .ms-count "{primitive_count}/256"
div .ms-prim-grid:
button .ms-prim-btn type=button click="addPrimitive('box')" title="Add integer grid block (blocks:)":
span .ms-prim-icon "▣"
span "Box"
button .ms-prim-btn type=button click="addPrimitive('sphere')" title="Add analytic sphere (shapes:)":
span .ms-prim-icon "●"
span "Sphere"
button .ms-prim-btn type=button click="addPrimitive('cylinder')" title="Add capped cylinder (shapes:)":
span .ms-prim-icon "▮"
span "Cylinder"
button .ms-prim-btn type=button click="addPrimitive('ramp')" title="Add wedge ramp (shapes:)":
span .ms-prim-icon "◢"
span "Ramp"
div .ms-section:
div .ms-section-head:
h2 .ms-panel-title "Model Settings"
div .ms-setting-row:
label .ms-setting-label for=ms-unit-select "Unit scale"
select #ms-unit-select .ms-select-sm aria-label="Model unit scale" change="setModelUnit(this.value)":
option value="0.05" selected="{unit == 0.05}" "0.05 (fine)"
option value="0.08" selected="{unit == 0.08}" "0.08"
option value="0.1" selected="{unit == 0.1}" "0.10"
option value="0.125" selected="{unit == 0.125}" "0.125 (default)"
option value="0.2" selected="{unit == 0.2}" "0.20"
option value="0.25" selected="{unit == 0.25}" "0.25"
option value="0.5" selected="{unit == 0.5}" "0.50"
option value="1" selected="{unit == 1}" "1.0 (tile)"
div .ms-setting-row:
label .ms-setting-label for=ms-shadow-select "Shadow"
select #ms-shadow-select .ms-select-sm aria-label="Contact shadow radius" change="setContactShadow(this.value)":
option value="0" selected="{contact_shadow == 0}" "Off"
option value="0.4" selected="{contact_shadow == 0.4}" "0.40"
option value="0.5" selected="{contact_shadow == 0.5}" "0.50"
option value="0.6" selected="{contact_shadow == 0.6}" "0.60"
option value="0.65" selected="{contact_shadow == 0.65}" "0.65"
option value="0.7" selected="{contact_shadow == 0.7}" "0.70"
option value="0.75" selected="{contact_shadow == 0.75}" "0.75"
option value="0.8" selected="{contact_shadow == 0.8}" "0.80"
option value="0.9" selected="{contact_shadow == 0.9}" "0.90"
option value="1.4" selected="{contact_shadow == 1.4}" "1.40"
div .ms-section .ms-palette-section:
div .ms-section-head:
h2 .ms-panel-title "Palette · {palette_name}"
div .ms-palette-list:
for swatch in palette:
div .ms-swatch-row {.active when active_color == swatch.symbol}:
button .ms-swatch-pick type=button click="selectColor(swatch.symbol)" title="Select & paint with '{swatch.symbol}' ({swatch.hex})":
span .ms-swatch-dot style="background: {swatch.hex};"
span .ms-swatch-sym "{swatch.symbol}"
span .ms-swatch-hex "{swatch.hex}"
input .ms-color-input type=color value="{swatch.hex}" aria-label="Color {swatch.symbol}" change="updateColorHex(swatch.symbol, this.value)"
button .ms-glow-btn {.on when swatch.emissive} type=button click="toggleEmissive(swatch.symbol)" aria-pressed="{swatch.emissive}" title="Toggle emissive bloom glow" "✦"
button .ms-del-btn type=button click="deleteColor(swatch.symbol)" title="Remove color" "×"
div .ms-add-color-row:
input .ms-color-input type=color value="{new_color_hex}" aria-label="New swatch color" change="setNewColorHex(this.value)"
button .ms-btn-sm .ms-btn-add-color type=button click="addPaletteColor" "+ Add color"
@Component/ModelViewportPanel
view:
section .ms-viewport-panel aria-label="Pixel-3D preview viewport":
div .ms-toolbox-bar role=toolbar aria-label="3D viewport tools":
div .ms-toolbox-modes:
button .ms-tool-btn {.active when tool_mode == 'select'} type=button click="setToolMode('select')" aria-pressed="{tool_mode == 'select'}" title="Select tool (1) — Click a part to select; drag to orbit":
span .ms-tool-icon "↖"
span .ms-tool-lbl "Select"
button .ms-tool-btn {.active when tool_mode == 'move'} type=button click="setToolMode('move')" aria-pressed="{tool_mode == 'move'}" title="Move tool (2) — Drag X/Y/Z arrows to move selected part":
span .ms-tool-icon "✥"
span .ms-tool-lbl "Move"
button .ms-tool-btn {.active when tool_mode == 'resize'} type=button click="setToolMode('resize')" aria-pressed="{tool_mode == 'resize'}" title="Resize tool (3) — Drag X/Y/Z handles to scale selected part":
span .ms-tool-icon "⤢"
span .ms-tool-lbl "Resize"
button .ms-tool-btn {.active when tool_mode == 'place'} type=button click="setToolMode('place')" aria-pressed="{tool_mode == 'place'}" title="Place tool (4) — Click a face or floor grid to place a new primitive":
span .ms-tool-icon "+"
span .ms-tool-lbl "Place"
button .ms-tool-btn {.active when tool_mode == 'paint'} type=button click="setToolMode('paint')" aria-pressed="{tool_mode == 'paint'}" title="Paint tool (5) — Click any part to paint with active color":
span .ms-tool-icon "✎"
span .ms-tool-lbl "Paint"
button .ms-tool-btn .danger {.active when tool_mode == 'erase'} type=button click="setToolMode('erase')" aria-pressed="{tool_mode == 'erase'}" title="Erase tool (6) — Click any part to remove it":
span .ms-tool-icon "⌫"
span .ms-tool-lbl "Erase"
div .ms-toolbox-context:
if tool_mode == 'place':
button .ms-pill {.active when place_kind == 'box'} type=button click="setPlaceKind('box')" title="Place Box" "▣ Box"
button .ms-pill {.active when place_kind == 'sphere'} type=button click="setPlaceKind('sphere')" title="Place Sphere" "● Sphere"
button .ms-pill {.active when place_kind == 'cylinder'} type=button click="setPlaceKind('cylinder')" title="Place Cylinder" "▮ Cyl"
button .ms-pill {.active when place_kind == 'ramp'} type=button click="setPlaceKind('ramp')" title="Place Ramp" "◢ Ramp"
if tool_mode == 'move' or tool_mode == 'resize':
span .ms-gizmo-legend:
span .ax-x "X"
span .ax-y "Y"
span .ax-z "Z"
span .ms-gizmo-tip "Drag handle"
if tool_mode == 'paint':
span .ms-paint-chip:
span .ms-part-dot style="background: {active_color_hex};"
span "Swatch {active_color}"
div .ms-viewport-toolbar:
div .ms-cam-presets:
button .ms-pill type=button click="setCameraPreset('iso')" "Iso"
button .ms-pill type=button click="setCameraPreset('front')" "Front"
button .ms-pill type=button click="setCameraPreset('side')" "Side"
button .ms-pill type=button click="setCameraPreset('back')" "Rear"
button .ms-pill type=button click="setCameraPreset('top')" "Top"
button .ms-pill type=button click="zoomCamera(-0.6)" aria-label="Zoom in" title="Zoom in" "+"
button .ms-pill type=button click="zoomCamera(0.6)" aria-label="Zoom out" title="Zoom out" "−"
div .ms-view-toggles:
button .ms-pill {.active when show_grid} type=button click="toggleGrid" aria-pressed="{show_grid}" "Grid"
button .ms-pill {.active when show_axes} type=button click="toggleAxes" aria-pressed="{show_axes}" "Axes"
button .ms-pill {.active when show_glow} type=button click="toggleGlow" aria-pressed="{show_glow}" "Glow"
button .ms-pill {.active when show_onion_skin} type=button click="toggleOnionSkin" aria-pressed="{show_onion_skin}" title="Show ghost of previous pose frame" "Onion"
button .ms-pill {.active when turntable} type=button click="toggleTurntable" aria-pressed="{turntable}" "Spin"
select .ms-select-sm aria-label="Viewport pixel resolution" change="setViewportResolution(this.value)":
option value="240x150" selected="{viewport_resolution == '240x150'}" "240×150"
option value="320x200" selected="{viewport_resolution == '320x200'}" "320×200"
option value="480x300" selected="{viewport_resolution == '480x300'}" "480×300"
option value="640x400" selected="{viewport_resolution == '640x400'}" "640×400"
option value="768x480" selected="{viewport_resolution == '768x480'}" "768×480"
option value="960x600" selected="{viewport_resolution == '960x600'}" "960×600"
option value="1280x800" selected="{viewport_resolution == '1280x800'}" "1280×800"
div .ms-canvas-stage:
canvas .ms-viewport-canvas data-pixel3d-view=main data-pixel3d-orbit=onViewportOrbit data-pixel3d-hit=onViewportHit data-pixel3d-gizmo=onViewportGizmo tabindex=0 aria-label="Interactive Pixel-3D model viewport. Use toolbar modes to select, move, resize, place, paint, or erase parts. Drag empty space or right-drag to orbit."
div .ms-viewport-hud:
span .ms-hud-readout data-pixel3d-hud=main "Yaw {camera_yaw}° · Pitch {camera_pitch}° · Zoom {camera_zoom} · Frame {frame_number}/{frame_count}"
span .ms-hud-hint "{hud_hint}"
@Logic/model_studio
func unique_clip_id(clps, raw, ignore_idx):
local base = slugify_id(raw, "clip")
local base_taken = false
for c, idx in clps:
if idx != ignore_idx and c.id == base:
base_taken = true
if !base_taken:
return base
for n in [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]:
local candidate = base + "_" + n
local taken = false
for c, idx in clps:
if idx != ignore_idx and c.id == candidate:
taken = true
if !taken:
return candidate
return base + "_alt"
action selectClip(idx):
is_playing = false
call syncPlaybackTimer
active_clip_index = clamp(floor(to_number(idx, 0)), 0, max(0, clips.length - 1))
active_frame_index = 0
call bindActiveClip
local cname = clips[active_clip_index].name
status_message = "Clip '" + cname + "' (" + frames.length + " frame" + (frames.length == 1 ? "" : "s") + ")"
call syncStudio
action addClip:
if clips.length >= 16:
status_message = "Reached 16 animation clips per model."
stop
is_playing = false
call syncPlaybackTimer
call pushUndo
local label = "Clip " + (clips.length + 1)
local cid = unique_clip_id(clips, "clip_" + (clips.length + 1), -1)
local cur = frames.length > 0 ? deep_clone(frames[active_frame_index]) : make_frame(1, "Pose 1", [box_prim(1, "Block 1", palette[0].symbol, [-2, -2, 0], [4, 4, 4])], 0, 0, 0, 0, 0, 1, 0)
local starter = make_frame(1, "Pose 1", cur.primitives, 0, 0, 0, 0, 0, 1, 0)
local next_clip = make_clip(cid, label, fps, "loop", true, [starter])
clips = [...clips, next_clip]
active_clip_index = clips.length - 1
active_frame_index = 0
call bindActiveClip
status_message = "Added clip '" + label + "' starting from current pose"
call syncStudio
action duplicateCurrentClip:
if clips.length >= 16:
status_message = "Reached 16 animation clips per model."
stop
is_playing = false
call syncPlaybackTimer
call pushUndo
local cur = deep_clone(clips[active_clip_index])
local label = (cur.name + " Copy").slice(0, 24)
local cid = unique_clip_id(clips, cur.id + "_copy", -1)
local dup = make_clip(cid, label, cur.fps, cur.mode, cur.interpolate, cur.frames)
clips = insert_at(clips, active_clip_index + 1, dup)
active_clip_index = active_clip_index + 1
active_frame_index = 0
call bindActiveClip
status_message = "Duplicated clip '" + cur.name + "' → '" + label + "'"
call syncStudio
action renameCurrentClip(name):
local clean = name.trim().slice(0, 24)
if clean == "" or clips.length == 0:
stop
clips[active_clip_index].name = clean
clips[active_clip_index].id = unique_clip_id(clips, clean, active_clip_index)
status_message = "Renamed clip to '" + clean + "' (@Animation/" + slugify_id(model_id, "custom_model") + "/" + clips[active_clip_index].id + ")"
call syncStudio
action deleteCurrentClip:
if clips.length <= 1:
status_message = "Keep at least one animation clip on the model."
stop
is_playing = false
call syncPlaybackTimer
call pushUndo
local removed_name = clips[active_clip_index].name
clips = remove_at(clips, active_clip_index)
active_clip_index = min(active_clip_index, clips.length - 1)
active_frame_index = 0
call bindActiveClip
status_message = "Deleted clip '" + removed_name + "'"
call syncStudio
action copyCurrentPose:
if frames.length == 0:
stop
copied_pose = deep_clone(frames[active_frame_index])
status_message = "Copied pose '" + copied_pose.label + "' — switch clips and click Paste Pose to reuse it"
action pasteCopiedPose:
if copied_pose == null:
status_message = "Copy a pose first to paste it into this clip."
stop
if frames.length >= 24:
status_message = "Reached 24 frame limit for this clip."
stop
is_playing = false
call syncPlaybackTimer
call pushUndo
local fid = next_frame_id(frames)
local p = deep_clone(copied_pose)
local next_f = make_frame(fid, p.label, p.primitives, p.x, p.y, p.z, p.angle, p.pitch, p.scale, p.dissolve)
frames = insert_at(frames, active_frame_index + 1, next_f)
clips[active_clip_index].frames = frames
active_frame_index = active_frame_index + 1
status_message = "Pasted pose '" + p.label + "' into '" + active_clip_name + "'"
call syncStudio
action playAnimation:
if frame_count <= 1:
status_message = "Add a second frame to preview animation playback."
stop
is_playing = true
play_start_ms = now()
status_message = "Playing '" + active_clip_name + "' (" + frame_count + " frames at " + fps + " FPS, " + playback_mode + ")"
call syncPlaybackTimer
action pauseAnimation:
if !is_playing:
stop
local elapsed = (now() - play_start_ms) / 1000
local sampled = sample_animation(frames, elapsed, fps, playback_mode, interpolate_transforms)
is_playing = false
call syncPlaybackTimer
active_frame_index = sampled.frame_index
call syncStudio
status_message = "Paused '" + active_clip_name + "' on frame " + frame_number + " / " + frame_count
action stopAnimation:
is_playing = false
call syncPlaybackTimer
active_frame_index = 0
call syncStudio
status_message = "Stopped '" + active_clip_name + "' · returned to frame 1"
action selectFrame(idx):
is_playing = false
call syncPlaybackTimer
active_frame_index = clamp(floor(to_number(idx, 0)), 0, max(0, frames.length - 1))
status_message = active_clip_name + " · Frame " + (active_frame_index + 1) + ": " + frames[active_frame_index].label
call syncStudio
action stepFrame(delta):
is_playing = false
call syncPlaybackTimer
local next = (active_frame_index + round(to_number(delta, 1)) + frames.length) % frames.length
active_frame_index = next
status_message = active_clip_name + " · Frame " + (next + 1) + ": " + frames[next].label
call syncStudio
action addBlankFrame:
if frames.length >= 24:
status_message = "Reached 24 frame limit."
stop
is_playing = false
call syncPlaybackTimer
call pushUndo
local fid = next_frame_id(frames)
local col = active_color != "" ? active_color : palette[0].symbol
local starter = box_prim(1, "Block 1", col, [-2, -2, 0], [4, 4, 4])
local next_f = make_frame(fid, "Pose " + (frames.length + 1), [starter], 0, 0, 0, 0, 0, 1, 0)
frames = insert_at(frames, active_frame_index + 1, next_f)
clips[active_clip_index].frames = frames
active_frame_index = active_frame_index + 1
status_message = "Added blank frame " + (active_frame_index + 1) + " to '" + active_clip_name + "'"
call syncStudio
action duplicateCurrentFrame:
if frames.length >= 24:
status_message = "Reached 24 frame limit."
stop
is_playing = false
call syncPlaybackTimer
call pushUndo
local fid = next_frame_id(frames)
local cur = deep_clone(frames[active_frame_index])
local next_f = make_frame(fid, "Pose " + (frames.length + 1), cur.primitives, cur.x, cur.y, cur.z, cur.angle, cur.pitch, cur.scale, cur.dissolve)
frames = insert_at(frames, active_frame_index + 1, next_f)
clips[active_clip_index].frames = frames
active_frame_index = active_frame_index + 1
status_message = "Duplicated frame " + active_frame_index + " → " + (active_frame_index + 1)
call syncStudio
action deleteCurrentFrame:
if frames.length <= 1:
status_message = "Keep at least one frame in the clip."
stop
is_playing = false
call syncPlaybackTimer
call pushUndo
local deleted_num = active_frame_index + 1
frames = remove_at(frames, active_frame_index)
clips[active_clip_index].frames = frames
active_frame_index = min(active_frame_index, frames.length - 1)
status_message = "Deleted frame " + deleted_num
call syncStudio
action moveCurrentFrame(delta):
local target = active_frame_index + round(to_number(delta, 1))
if target < 0 or target >= frames.length:
stop
is_playing = false
call syncPlaybackTimer
call pushUndo
local item = frames[active_frame_index]
local trimmed = remove_at(frames, active_frame_index)
frames = insert_at(trimmed, target, item)
clips[active_clip_index].frames = frames
active_frame_index = target
status_message = "Moved frame to slot " + (target + 1)
call syncStudio
action renameCurrentFrame(label):
local clean = label.trim().slice(0, 24)
if clean == "":
stop
frames[active_frame_index].label = clean
call syncStudio
action changeFps(delta):
fps = clamp(fps + round(to_number(delta, 0)), 1, 24)
clips[active_clip_index].fps = fps
if is_playing:
play_start_ms = now()
status_message = active_clip_name + " rate: " + fps + " FPS"
call syncStudio
action setPlaybackMode(mode):
playback_mode = mode
clips[active_clip_index].mode = mode
if is_playing:
play_start_ms = now()
status_message = active_clip_name + " playback mode: " + mode
call syncStudio
action toggleInterpolate:
interpolate_transforms = !interpolate_transforms
clips[active_clip_index].interpolate = interpolate_transforms
status_message = interpolate_transforms ? "Smooth transform interpolation enabled" : "Stepped transform playback enabled"
action setFrameTransform(field, val):
local n = to_number(val, 0)
call pushUndo
local f = frames[active_frame_index]
match field:
"x":
f.x = round_to(clamp(n, -16, 16), 2)
"y":
f.y = round_to(clamp(n, -16, 16), 2)
"z":
f.z = round_to(clamp(n, -16, 16), 2)
"angle":
f.angle = round_to(clamp(n, -360, 360), 1)
"pitch":
f.pitch = round_to(clamp(n, -90, 90), 1)
"scale":
f.scale = round_to(clamp(n, 0.1, 4), 2)
"dissolve":
f.dissolve = round_to(clamp(n, 0, 1), 2)
call syncStudio
action nudgeFrameTransform(field, delta):
local d = to_number(delta, 0)
call pushUndo
local f = frames[active_frame_index]
match field:
"x":
f.x = round_to(clamp(f.x + d, -16, 16), 2)
"y":
f.y = round_to(clamp(f.y + d, -16, 16), 2)
"z":
f.z = round_to(clamp(f.z + d, -16, 16), 2)
"angle":
f.angle = round_to(clamp(f.angle + d, -360, 360), 1)
"pitch":
f.pitch = round_to(clamp(f.pitch + d, -90, 90), 1)
"scale":
f.scale = round_to(clamp(f.scale + d, 0.1, 4), 2)
"dissolve":
f.dissolve = round_to(clamp(f.dissolve + d, 0, 1), 2)
call syncStudio
action resetFrameTransform:
call pushUndo
local f = frames[active_frame_index]
f.x = 0
f.y = 0
f.z = 0
f.angle = 0
f.pitch = 0
f.scale = 1
f.dissolve = 0
status_message = "Reset transforms for " + f.label
call syncStudio
@Logic/model_studio
func frame_geometry_sig(prims):
local parts = []
for p in prims:
local ord = round(clamp(to_number(p.order, 0), -1000, 1000))
match p.kind:
"box", "ramp":
parts.push([p.kind, p.color, p.from, p.size, ord])
"sphere":
parts.push([p.kind, p.color, p.center, p.radius, ord])
"cylinder":
parts.push([p.kind, p.color, p.center, p.radius, p.height, ord])
return json.stringify(parts)
func frame_has_transforms(f):
return f.x != 0 or f.y != 0 or f.z != 0 or f.angle != 0 or f.pitch != 0 or f.scale != 1 or f.dissolve != 0
func format_keyframe_entry(m_name, f):
local kf = {"model": m_name}
if (f.label ?? "") != "":
kf.label = f.label
if f.x != 0:
kf.x = round_to(f.x, 3)
if f.y != 0:
kf.y = round_to(f.y, 3)
if f.z != 0:
kf.z = round_to(f.z, 3)
if f.angle != 0:
kf.angle = round_to(f.angle, 1)
if f.pitch != 0:
kf.pitch = round_to(f.pitch, 1)
if f.scale != 1:
kf.scale = round_to(f.scale, 2)
if f.dissolve != 0:
kf.dissolve = round_to(f.dissolve, 2)
return json.stringify(kf)
func title_from_slug(raw):
local parts = regex_replace(raw.trim(), "[_-]+", " ").split(" ")
local words = []
for w in parts:
if w != "":
words.push(w.slice(0, 1).toUpperCase() + w.slice(1))
return words.length > 0 ? words.join(" ") : "Idle"
func format_model_section(m_name, pal_name, m_unit, emissive_syms, m_shadow, prims):
local lines = ["@Model/" + m_name, "palette = " + pal_name, "unit = " + round_to(clamp(to_number(m_unit, 0.125), 0.01, 1), 4)]
if emissive_syms != "":
lines.push("emissive = \"" + emissive_syms + "\"")
if to_number(m_shadow, 0) > 0:
lines.push("contact_shadow = " + round_to(clamp(to_number(m_shadow, 0), 0.05, 4), 2))
local boxes = prims.filter(p => p.kind == "box")
local shapes = prims.filter(p => p.kind != "box")
if boxes.length > 0:
lines.push("blocks:")
for b in boxes:
local from_arr = [round(clamp(b.from[0], -32, 32)), round(clamp(b.from[1], -32, 32)), round(clamp(b.from[2], -32, 32))]
local size_arr = [round(clamp(b.size[0], 1, 32)), round(clamp(b.size[1], 1, 32)), round(clamp(b.size[2], 1, 32))]
local entry = {"from": from_arr, "size": size_arr, "color": b.color}
local ord = round(clamp(to_number(b.order, 0), -1000, 1000))
if ord != 0:
entry.order = ord
lines.push(" " + json.stringify(entry))
if shapes.length > 0:
lines.push("shapes:")
for s in shapes:
local ord = round(clamp(to_number(s.order, 0), -1000, 1000))
match s.kind:
"sphere":
local sp = {"type": "sphere", "center": [round_to(s.center[0], 3), round_to(s.center[1], 3), round_to(s.center[2], 3)], "radius": round_to(s.radius, 3), "color": s.color}
if ord != 0:
sp.order = ord
lines.push(" " + json.stringify(sp))
"cylinder":
local cy = {"type": "cylinder", "center": [round_to(s.center[0], 3), round_to(s.center[1], 3), round_to(s.center[2], 3)], "radius": round_to(s.radius, 3), "height": round_to(s.height, 3), "color": s.color}
if ord != 0:
cy.order = ord
lines.push(" " + json.stringify(cy))
"ramp":
local rp = {"type": "ramp", "from": [round_to(s.from[0], 3), round_to(s.from[1], 3), round_to(s.from[2], 3)], "size": [round_to(s.size[0], 3), round_to(s.size[1], 3), round_to(s.size[2], 3)], "color": s.color}
if ord != 0:
rp.order = ord
lines.push(" " + json.stringify(rp))
return lines.join("\n")
func format_rune_code(m_id, m_title, p_name, m_unit, m_shadow, pal, clps, include_animations):
local mid = slugify_id(m_id, "custom_model")
local pname = slugify_id(p_name, mid)
local used_syms = ""
for c in clps:
for f in c.frames:
for p in f.primitives:
if !used_syms.includes(p.color):
used_syms += p.color
local emissive_syms = ""
local color_pairs = []
for entry in pal:
local hx = sanitize_hex(entry.hex, "#68e1e8")
color_pairs.push("\"" + entry.symbol + "\":\"" + hx + "\"")
if entry.emissive and used_syms.includes(entry.symbol):
emissive_syms += entry.symbol
local out = ["# " + (m_title == "" ? mid : m_title) + " — authored with Vectrune Model Studio", "", "@Palette/" + pname, "colors = {" + color_pairs.join(", ") + "}", ""]
local unique_sigs = []
local unique_models = []
local clip_frame_models = []
for c in clps:
local names_for_clip = []
for f in c.frames:
local sig = frame_geometry_sig(f.primitives)
local match_idx = unique_sigs.indexOf(sig)
if match_idx < 0:
local mname = unique_models.length == 0 ? mid : mid + "_f" + (unique_models.length + 1)
unique_sigs.push(sig)
unique_models.push({"name": mname, "primitives": f.primitives})
names_for_clip.push(mname)
else:
names_for_clip.push(unique_models[match_idx].name)
clip_frame_models.push(names_for_clip)
if unique_models.length > 1:
local first_old = unique_models[0].name
local first_new = mid + "_f1"
unique_models[0].name = first_new
clip_frame_models = clip_frame_models.map(arr => arr.map(fn => fn == first_old ? first_new : fn))
for item in unique_models:
out.push(format_model_section(item.name, pname, m_unit, emissive_syms, m_shadow, item.primitives))
out.push("")
if include_animations:
for c, c_idx in clps:
local has_tf = false
for f in c.frames:
if frame_has_transforms(f):
has_tf = true
if clps.length > 1 or c.frames.length > 1 or has_tf:
local cid = slugify_id(c.id, "clip_" + (c_idx + 1))
local clip_rate = clamp(round(to_number(c.fps, 6)), 1, 60)
local clip_mode = (c.mode == "once" or c.mode == "pingpong") ? c.mode : "loop"
local clip_interp = c.interpolate != false
local names = clip_frame_models[c_idx]
out = [...out, "@Animation/" + mid + "/" + cid, "fps = " + clip_rate, "mode = \"" + clip_mode + "\"", "interpolate = " + (clip_interp ? "true" : "false"), "frames:"]
for f, f_idx in c.frames:
out.push(" " + format_keyframe_entry(names[f_idx], f))
out.push("")
return rune.format(out.join("\n").trim() + "\n", 100)
func parse_rune_code(source):
local raw = replace_all(source, "\r\n", "\n")
if raw.trim() == "":
return {"error": "Paste @Palette, @Model, and optional @Animation Rune code first."}
local title_comment = ""
for line in raw.split("\n"):
local t = line.trim()
if t.startsWith("@"):
stop
if title_comment == "" and t.startsWith("#") and !t.startsWith("#!"):
title_comment = regex_replace(t, "^#+\\s*", "").split("—")[0].trim()
local doc = rune.parse(raw)
local pal_map = {}
local pal_first_name = ""
local models = []
local parsed_anims = []
local legacy_anim_meta = null
local legacy_anim_mode = "loop"
local legacy_anim_fps = 6
for sec in doc.sections:
match sec.kind:
"Palette":
if pal_first_name == "":
pal_first_name = sec.name
if sec.kv.colors != null:
pal_map[sec.name] = sec.kv.colors
"Model":
local prims = []
local nid = 1
for item in (sec.series.blocks ?? []):
if item == null or item.from == null:
return {"error": "Invalid blocks JSON entry in @Model/" + sec.name}
local bp = box_prim(nid, "Box " + nid, item.color ?? "a", item.from ?? [0, 0, 0], item.size ?? [1, 1, 1])
bp.order = round(clamp(to_number(item.order, 0), -1000, 1000))
prims.push(bp)
nid += 1
for item in (sec.series.shapes ?? []):
if item == null:
return {"error": "Invalid shapes JSON entry in @Model/" + sec.name}
local col = item.color ?? "a"
local sp = null
match (item.type ?? "sphere"):
"ramp":
sp = ramp_prim(nid, "Ramp " + nid, col, item.from ?? [0, 0, 0], item.size ?? [2, 2, 2])
"cylinder":
sp = cyl_prim(nid, "Cylinder " + nid, col, item.center ?? [0, 0, 1], item.radius ?? 1, item.height ?? 2)
else:
sp = sphere_prim(nid, "Sphere " + nid, col, item.center ?? [0, 0, 1], item.radius ?? 1)
sp.order = round(clamp(to_number(item.order, 0), -1000, 1000))
prims.push(sp)
nid += 1
if prims.length > 0:
models.push({"name": sec.name, "palette_name": sec.kv.palette ?? "", "unit": clamp(to_number(sec.kv.unit, 0.125), 0.01, 1), "emissive": sec.kv.emissive ?? "", "contact_shadow": clamp(to_number(sec.kv.contact_shadow, 0), 0, 4), "primitives": prims})
"Animation":
local raw_frames = sec.series.frames ?? sec.kv.frames ?? []
if raw_frames.length > 0:
local fps_val = clamp(round(to_number(sec.kv.fps, 8)), 1, 24)
local mode_raw = sec.kv.mode ?? "loop"
local mode_val = (mode_raw == "once" or mode_raw == "pingpong") ? mode_raw : "loop"
local interp_val = sec.kv.interpolate == true
parsed_anims.push({"name": sec.name, "fps": fps_val, "mode": mode_val, "interpolate": interp_val, "frames": raw_frames})
"Logic":
for st in (sec.series.state ?? []):
local s = st.trim()
if s.startsWith("anim_frames"):
local eq_f = s.indexOf("=")
if eq_f > 0:
local parsed_f = json.try_parse(s.slice(eq_f + 1).trim())
if parsed_f != null:
legacy_anim_meta = parsed_f
else if s.startsWith("anim_mode"):
local m_mode = regex_match(s, "\"(loop|pingpong|once)\"")
if m_mode != null:
legacy_anim_mode = m_mode[1]
else if s.startsWith("anim_step_ticks"):
local eq_s = s.indexOf("=")
if eq_s > 0:
legacy_anim_fps = clamp(round(30 / max(1, to_number(s.slice(eq_s + 1).trim(), 5))), 1, 24)
if models.length == 0:
return {"error": "No @Model/<name> section with blocks: or shapes: was found."}
local first = models[0]
local pname = first.palette_name != "" ? first.palette_name : (pal_first_name != "" ? pal_first_name : "custom")
local raw_pal = pal_map[pname] ?? (pal_first_name != "" ? pal_map[pal_first_name] : {})
local emissive_all = ""
for m in models:
emissive_all += m.emissive
local pal = []
local pal_syms = ""
for pair in entries(raw_pal):
if pair.key.length == 1 and pair.value != "transparent":
pal.push({"symbol": pair.key, "hex": sanitize_hex(pair.value, "#68e1e8"), "name": "Color " + pair.key.toUpperCase(), "emissive": emissive_all.includes(pair.key)})
pal_syms += pair.key
for m in models:
for p in m.primitives:
if !pal_syms.includes(p.color):
pal.push({"symbol": p.color, "hex": "#68e1e8", "name": "Color " + p.color.toUpperCase(), "emissive": emissive_all.includes(p.color)})
pal_syms += p.color
if pal.length == 0:
pal.push({"symbol": "a", "hex": "#68e1e8", "name": "Color A", "emissive": false})
local out_clips = []
if parsed_anims.length > 0:
for anim, a_idx in parsed_anims:
if a_idx < 16:
local parts_a = anim.name.split("/")
local raw_cid = parts_a[parts_a.length - 1]
local cid = unique_clip_id(out_clips, raw_cid, -1)
local cname = title_from_slug(raw_cid)
local c_frames = []
for entry, idx in anim.frames:
if idx < 24:
if entry != null and entry.model != null:
local found = models.find(m => m.name == entry.model) ?? first
c_frames.push(make_frame(idx + 1, entry.label ?? ("Pose " + (idx + 1)), deep_clone(found.primitives), entry.x ?? 0, entry.y ?? 0, entry.z ?? 0, entry.angle ?? 0, entry.pitch ?? 0, entry.scale ?? 1, entry.dissolve ?? 0))
else if entry != null:
local m_str = "" + entry
local found_s = models.find(m => m.name == m_str) ?? first
c_frames.push(make_frame(idx + 1, "Pose " + (idx + 1), deep_clone(found_s.primitives), 0, 0, 0, 0, 0, 1, 0))
if c_frames.length > 0:
out_clips.push(make_clip(cid, cname, anim.fps, anim.mode, anim.interpolate, c_frames))
else if legacy_anim_meta != null and legacy_anim_meta.length > 0:
local leg_frames = []
for meta, idx in legacy_anim_meta:
if idx < 24:
local found = models.find(m => m.name == meta.model) ?? first
leg_frames.push(make_frame(idx + 1, meta.label ?? ("Frame " + (idx + 1)), deep_clone(found.primitives), meta.x ?? 0, meta.y ?? 0, meta.z ?? 0, meta.angle ?? 0, meta.pitch ?? 0, meta.scale ?? 1, meta.dissolve ?? 0))
if leg_frames.length > 0:
out_clips.push(make_clip("idle", "Idle", legacy_anim_fps, legacy_anim_mode, true, leg_frames))
if out_clips.length == 0:
local fallback_frames = []
for m, idx in models:
if idx < 24:
local parts_n = m.name.split("/")
local lbl = models.length == 1 ? "Pose 1" : parts_n[parts_n.length - 1]
fallback_frames.push(make_frame(idx + 1, lbl, m.primitives, 0, 0, 0, 0, 0, 1, 0))
out_clips.push(make_clip("idle", "Idle", 6, "loop", true, fallback_frames))
local base_id = regex_replace(first.name, "_f1$", "")
local title = title_comment != "" ? title_comment : regex_replace(base_id, "[_/-]+", " ")
local first_frame = out_clips[0].frames[0]
return {"error": "", "snapshot": {"model_id": base_id, "model_title": title, "palette_name": pname, "unit": first.unit, "contact_shadow": first.contact_shadow, "palette": pal, "clips": out_clips, "active_clip_index": 0, "active_frame_index": 0, "selected_primitive_id": first_frame.primitives[0].id, "active_color": pal[0].symbol}}
@Logic/model_studio
func history_keys():
return ["model_id", "model_title", "palette_name", "unit", "contact_shadow", "palette", "clips", "active_clip_index", "active_frame_index", "selected_primitive_id", "active_color"]
func capture_snapshot(m_id, m_title, p_name, m_unit, m_shadow, pal, clps, c_idx, a_idx, sel_id, a_col):
return {"model_id": m_id, "model_title": m_title, "palette_name": p_name, "unit": m_unit, "contact_shadow": m_shadow, "palette": deep_clone(pal), "clips": deep_clone(clps), "active_clip_index": c_idx, "active_frame_index": a_idx, "selected_primitive_id": sel_id, "active_color": a_col}
func build_clip_rows(clps, c_idx):
local rows = []
for c, idx in clps:
rows.push({"id": c.id, "index": idx, "name": c.name, "frame_count": c.frames.length, "fps": c.fps, "mode": c.mode, "is_active": idx == c_idx})
return rows
func build_prim_rows(frame, pal, sel_id):
if frame == null:
return []
local rows = []
for p, idx in frame.primitives:
local sw = pal.find(c => c.symbol == p.color)
rows.push({"id": p.id, "index": idx, "kind": p.kind, "name": p.name, "color": p.color, "hex": sw != null ? sw.hex : "#68e1e8", "emissive": sw != null ? sw.emissive : false, "is_selected": p.id == sel_id})
return rows
func build_frame_rows(frms, a_idx):
local rows = []
for f, idx in frms:
rows.push({"id": f.id, "index": idx, "number": idx + 1, "label": f.label, "count": f.primitives.length, "is_active": idx == a_idx})
return rows
func next_prim_id(prims):
local best = 0
for p in prims:
if p.id > best:
best = p.id
return best + 1
func next_frame_id(frms):
local best = 0
for f in frms:
if f.id > best:
best = f.id
return best + 1
func next_palette_symbol(pal):
local used = ""
for entry in pal:
used += entry.symbol
for ch in "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split(""):
if !used.includes(ch):
return ch
return ""
action bindActiveClip:
if clips.length == 0:
frames = []
stop
active_clip_index = clamp(floor(to_number(active_clip_index, 0)), 0, clips.length - 1)
local c = clips[active_clip_index]
frames = c.frames
fps = clamp(round(to_number(c.fps, 6)), 1, 24)
playback_mode = c.mode ?? "loop"
interpolate_transforms = c.interpolate != false
active_frame_index = clamp(floor(to_number(active_frame_index, 0)), 0, max(0, frames.length - 1))
action applySnapshot(snap):
model_id = snap.model_id
model_title = snap.model_title
palette_name = snap.palette_name
unit = snap.unit
contact_shadow = snap.contact_shadow
palette = deep_clone(snap.palette)
if snap.clips != null and snap.clips.length > 0:
clips = deep_clone(snap.clips)
active_clip_index = clamp(floor(to_number(snap.active_clip_index, 0)), 0, clips.length - 1)
else:
local legacy_frames = deep_clone(snap.frames ?? [])
local legacy_clip = make_clip("idle", "Idle", snap.fps ?? 6, snap.playback_mode ?? "loop", snap.interpolate_transforms != false, legacy_frames)
clips = [legacy_clip]
active_clip_index = 0
active_frame_index = to_number(snap.active_frame_index, 0)
selected_primitive_id = to_number(snap.selected_primitive_id, -1)
active_color = snap.active_color
call bindActiveClip
action pushUndo:
history.checkpoint(history_keys(), 40)
action syncStudio:
if clips.length == 0:
local preset = build_preset("dungeon_knight")
call applySnapshot preset
call bindActiveClip
local frame = frames[active_frame_index]
if palette.find(c => c.symbol == active_color) == null and palette.length > 0:
active_color = palette[0].symbol
local sel = frame.primitives.find(p => p.id == selected_primitive_id)
if sel == null:
selected_primitive_id = frame.primitives.length > 0 ? frame.primitives[0].id : -1
action initStudio:
call loadModelLibrary
if clips.length == 0:
local preset = build_preset("dungeon_knight")
call applySnapshot preset
call syncStudio
call renderViewport
action toggleFullscreen:
fullscreen.toggle()
is_fullscreen = !is_fullscreen
status_message = is_fullscreen ? "Entered fullscreen workspace" : "Exited fullscreen workspace"
action undoEdit:
if !history.can_undo:
stop
history.undo()
call bindActiveClip
status_message = "Undid last edit"
call syncStudio
action redoEdit:
if !history.can_redo:
stop
history.redo()
call bindActiveClip
status_message = "Redid edit"
call syncStudio
action addPrimitive(kind):
local frame = frames[active_frame_index]
if frame.primitives.length >= 256:
status_message = "Pixel-3D models support up to 256 blocks and shapes."
stop
call pushUndo
local nid = next_prim_id(frame.primitives)
local sel = frame.primitives.find(p => p.id == selected_primitive_id)
local oz = 0
if sel != null:
match sel.kind:
"box", "ramp":
oz = sel.from[2] + sel.size[2]
"sphere", "cylinder":
oz = round(sel.center[2] + sel.radius)
local col = active_color != "" ? active_color : palette[0].symbol
local label = kind.slice(0, 1).toUpperCase() + kind.slice(1) + " " + nid
local sz = kind == "ramp" ? [6, 4, 3] : [4, 4, 4]
local p = make_prim(nid, kind, label, col, [-2, -2, clamp(round(oz), -24, 24)], sz, [0, 0, clamp(round_to(oz + 2, 2), -24, 24)], 2.5, 4)
frames[active_frame_index].primitives = [...frame.primitives, p]
selected_primitive_id = nid
status_message = "Added " + label
call syncStudio
action selectPrimitive(id):
local num_id = to_number(id, -1)
local found = frames[active_frame_index].primitives.find(p => p.id == num_id)
if found == null:
stop
selected_primitive_id = found.id
active_color = found.color
status_message = "Selected " + found.name + " (" + found.kind + ")"
action deletePrimitive(id):
local frame = frames[active_frame_index]
if frame.primitives.length <= 1:
status_message = "Each frame needs at least one block or shape."
stop
local num_id = to_number(id, selected_primitive_id)
local idx = frame.primitives.findIndex(p => p.id == num_id)
if idx < 0:
stop
call pushUndo
local removed = frame.primitives[idx]
local next_list = remove_at(frame.primitives, idx)
frames[active_frame_index].primitives = next_list
selected_primitive_id = next_list[min(idx, next_list.length - 1)].id
status_message = "Deleted " + removed.name
action duplicatePrimitive(id):
local frame = frames[active_frame_index]
if frame.primitives.length >= 256:
status_message = "Reached 256 primitive limit."
stop
local src = frame.primitives.find(p => p.id == to_number(id, selected_primitive_id))
if src == null:
stop
call pushUndo
local nid = next_prim_id(frame.primitives)
local copy = deep_clone(src)
local created = make_prim(nid, copy.kind, src.name + " copy", copy.color, [clamp(copy.from[0] + 1, -32, 32), copy.from[1], copy.from[2]], copy.size, [clamp(copy.center[0] + 1, -32, 32), copy.center[1], copy.center[2]], copy.radius, copy.height)
created.order = copy.order ?? 0
frames[active_frame_index].primitives = [...frame.primitives, created]
selected_primitive_id = nid
status_message = "Duplicated " + src.name
action mirrorPrimitive(id, axis):
local frame = frames[active_frame_index]
if frame.primitives.length >= 256:
status_message = "Reached 256 primitive limit."
stop
local src = frame.primitives.find(p => p.id == to_number(id, selected_primitive_id))
if src == null:
stop
call pushUndo
local nid = next_prim_id(frame.primitives)
local copy = deep_clone(src)
local ax = axis.toLowerCase()
match ax:
"x":
copy.from[0] = -(src.from[0] + src.size[0])
copy.center[0] = -src.center[0]
"y":
copy.from[1] = -(src.from[1] + src.size[1])
copy.center[1] = -src.center[1]
"z":
copy.from[2] = -(src.from[2] + src.size[2])
copy.center[2] = -src.center[2]
local created = make_prim(nid, copy.kind, src.name + " (" + ax.toUpperCase() + " mirror)", copy.color, copy.from, copy.size, copy.center, copy.radius, copy.height)
created.order = copy.order ?? 0
frames[active_frame_index].primitives = [...frame.primitives, created]
selected_primitive_id = nid
status_message = "Mirrored " + src.name + " across " + ax.toUpperCase()
action setPrimitiveKind(next_kind):
local frame = frames[active_frame_index]
local idx = frame.primitives.findIndex(p => p.id == selected_primitive_id)
if idx < 0:
stop
local prim = frame.primitives[idx]
if prim.kind == next_kind:
stop
call pushUndo
local copy = deep_clone(prim)
if (prim.kind == "box" or prim.kind == "ramp") and (next_kind == "sphere" or next_kind == "cylinder"):
copy.center = [round_to(prim.from[0] + prim.size[0] / 2, 3), round_to(prim.from[1] + prim.size[1] / 2, 3), round_to(prim.from[2] + prim.size[2] / 2, 3)]
copy.radius = round_to(max(0.5, min(prim.size[0], prim.size[1]) / 2), 3)
copy.height = round_to(max(0.5, prim.size[2]), 3)
else if (prim.kind == "sphere" or prim.kind == "cylinder") and (next_kind == "box" or next_kind == "ramp"):
local d = max(1, round(prim.radius * 2))
local h = next_kind == "box" ? max(1, round(prim.kind == "sphere" ? d : prim.height)) : max(0.5, prim.height)
copy.from = [round(prim.center[0] - d / 2), round(prim.center[1] - d / 2), round(prim.center[2] - h / 2)]
copy.size = [d, d, h]
local updated = make_prim(copy.id, next_kind, copy.name, copy.color, copy.from, copy.size, copy.center, copy.radius, copy.height)
updated.order = copy.order ?? 0
frames[active_frame_index].primitives[idx] = updated
status_message = "Changed " + updated.name + " to " + next_kind
action setPrimitiveColor(sym):
local swatch = palette.find(c => c.symbol == sym)
if swatch == null:
stop
active_color = sym
local frame = frames[active_frame_index]
local idx = frame.primitives.findIndex(p => p.id == selected_primitive_id)
if idx >= 0 and frame.primitives[idx].color != sym:
call pushUndo
frames[active_frame_index].primitives[idx].color = sym
status_message = "Painted " + frame.primitives[idx].name + " with '" + sym + "'"
action selectColor(sym):
if tool_mode == "paint" or tool_mode == "place":
local swatch = palette.find(c => c.symbol == sym)
if swatch == null:
stop
active_color = sym
if tool_mode == "paint":
hud_hint = "Click any part to paint with active swatch '" + active_color + "' · Drag to orbit"
status_message = "Active swatch: '" + sym + "' (" + swatch.hex + ")"
else:
call setPrimitiveColor sym
action setPrimitiveField(field, val):
local frame = frames[active_frame_index]
local idx = frame.primitives.findIndex(p => p.id == selected_primitive_id)
if idx < 0:
stop
if field == "name":
frames[active_frame_index].primitives[idx].name = val.slice(0, 32)
stop
local num = to_number(val, 0)
call pushUndo
local p = deep_clone(frame.primitives[idx])
match field:
"from_x":
p.from[0] = num
"from_y":
p.from[1] = num
"from_z":
p.from[2] = num
"size_x":
p.size[0] = num
"size_y":
p.size[1] = num
"size_z":
p.size[2] = num
"center_x":
p.center[0] = num
"center_y":
p.center[1] = num
"center_z":
p.center[2] = num
"radius":
p.radius = num
"height":
p.height = num
"order":
p.order = round(clamp(num, -1000, 1000))
local next_p = make_prim(p.id, p.kind, p.name, p.color, p.from, p.size, p.center, p.radius, p.height)
next_p.order = round(clamp(to_number(p.order, 0), -1000, 1000))
frames[active_frame_index].primitives[idx] = next_p
action nudgePrimitive(field, delta):
local frame = frames[active_frame_index]
local idx = frame.primitives.findIndex(p => p.id == selected_primitive_id)
if idx < 0:
stop
local d = to_number(delta, 0)
call pushUndo
local p = deep_clone(frame.primitives[idx])
match field:
"from_x":
p.from[0] += d
"from_y":
p.from[1] += d
"from_z":
p.from[2] += d
"size_x":
p.size[0] += d
"size_y":
p.size[1] += d
"size_z":
p.size[2] += d
"center_x":
p.center[0] += d
"center_y":
p.center[1] += d
"center_z":
p.center[2] += d
"radius":
p.radius += d
"height":
p.height += d
"order":
p.order = round(clamp(to_number(p.order, 0) + d, -1000, 1000))
local next_p = make_prim(p.id, p.kind, p.name, p.color, p.from, p.size, p.center, p.radius, p.height)
next_p.order = round(clamp(to_number(p.order, 0), -1000, 1000))
frames[active_frame_index].primitives[idx] = next_p
action setNewColorHex(hex):
new_color_hex = sanitize_hex(hex, "#ff5db5")
action addPaletteColor:
if palette.length >= 32:
status_message = "Palette reached 32 colors."
stop
local sym = next_palette_symbol(palette)
if sym == "":
stop
call pushUndo
local hx = sanitize_hex(new_color_hex, "#ff5db5")
palette = [...palette, {"symbol": sym, "hex": hx, "name": "Color " + sym.toUpperCase(), "emissive": false}]
active_color = sym
status_message = "Added color '" + sym + "' (" + hx + ")"
action updateColorHex(sym, hex):
local idx = palette.findIndex(c => c.symbol == sym)
if idx < 0:
stop
local hx = sanitize_hex(hex, palette[idx].hex)
palette[idx].hex = hx
status_message = "Updated '" + sym + "' to " + hx
action toggleEmissive(sym):
local idx = palette.findIndex(c => c.symbol == sym)
if idx < 0:
stop
call pushUndo
local next_em = !palette[idx].emissive
palette[idx].emissive = next_em
status_message = next_em ? ("Glow enabled on '" + sym + "'") : ("Glow disabled on '" + sym + "'")
action deleteColor(sym):
if palette.length <= 1:
status_message = "Palette needs at least one color."
stop
local idx = palette.findIndex(c => c.symbol == sym)
if idx < 0:
stop
call pushUndo
palette = remove_at(palette, idx)
local fallback_sym = palette[0].symbol
for clip in clips:
for f in clip.frames:
for p in f.primitives:
if p.color == sym:
p.color = fallback_sym
if active_color == sym:
active_color = fallback_sym
status_message = "Removed color '" + sym + "'"
action setModelUnit(val):
local n = to_number(val, 0)
if n <= 0 or n > 1:
stop
call pushUndo
unit = round_to(n, 4)
status_message = "Model unit set to " + unit
action setContactShadow(val):
local n = to_number(val, 0)
call pushUndo
contact_shadow = round_to(clamp(n, 0, 4), 2)
status_message = contact_shadow > 0 ? ("Contact shadow radius: " + contact_shadow) : "Contact shadow disabled"
action onViewportOrbit(yaw, pitch, zoom):
camera_yaw = round(to_number(yaw, camera_yaw))
camera_pitch = round(clamp(to_number(pitch, camera_pitch), -82, 60))
camera_zoom = round_to(clamp(to_number(zoom, camera_zoom), 1.4, 14), 2)
if turntable:
spin_start_ms = now()
action setCameraPreset(preset):
match preset:
"iso":
camera_yaw = -135
camera_pitch = -24
camera_zoom = 4.2
status_message = "Camera: Isometric"
"front":
camera_yaw = 180
camera_pitch = -10
camera_zoom = 4.0
status_message = "Camera: Front (+X facing)"
"side":
camera_yaw = -90
camera_pitch = -10
camera_zoom = 4.0
status_message = "Camera: Side"
"back":
camera_yaw = 0
camera_pitch = -14
camera_zoom = 4.0
status_message = "Camera: Rear"
"top":
camera_yaw = -90
camera_pitch = -78
camera_zoom = 4.6
status_message = "Camera: Top-down"
if turntable:
spin_start_ms = now()
action zoomCamera(delta):
camera_zoom = round_to(clamp(camera_zoom + to_number(delta, 0), 1.6, 12.0), 2)
action toggleGrid:
show_grid = !show_grid
action toggleAxes:
show_axes = !show_axes
action toggleGlow:
show_glow = !show_glow
action toggleOnionSkin:
show_onion_skin = !show_onion_skin
status_message = show_onion_skin ? "Onion skin on — showing previous pose ghost" : "Onion skin off"
action toggleTurntable:
if turntable:
local elapsed = (now() - spin_start_ms) / 1000
camera_yaw = round(((camera_yaw + elapsed * 36 + 540) % 360) - 180)
turntable = false
status_message = "Turntable rotation paused"
call syncPlaybackTimer
else:
turntable = true
spin_start_ms = now()
status_message = "Turntable rotation enabled"
call syncPlaybackTimer
action setViewportResolution(res):
viewport_resolution = res
status_message = "Viewport resolution: " + res
action setToolMode(mode):
tool_mode = mode
match mode:
"select":
hud_hint = "Click part to select · Drag to orbit · Wheel zoom · Keys 1–6 switch tools"
status_message = "Tool: Select — click any part in the 3D view to inspect it"
"move":
hud_hint = "Drag X / Y / Z arrows to move selected part · Click part to select · Right-drag orbits"
status_message = "Tool: Move — drag the red (X), green (Y), or blue (Z) arrow"
"resize":
hud_hint = "Drag X / Y / Z square handles to resize selected part · Click part to select"
status_message = "Tool: Resize — drag the X, Y, or Z handle to scale dimensions"
"place":
hud_hint = "Click any face or floor grid to snap-place a " + place_kind + " · Drag to orbit"
status_message = "Tool: Place (" + place_kind + ") — click a face or the floor grid"
"paint":
hud_hint = "Click any part to paint with active swatch '" + active_color + "' · Drag to orbit"
status_message = "Tool: Paint — click parts in 3D to paint with swatch '" + active_color + "'"
"erase":
hud_hint = "Click any part to erase it (Undoable) · Drag to orbit"
status_message = "Tool: Erase — click any part in 3D to remove it"
action setPlaceKind(kind):
place_kind = kind
call setToolMode "place"
action onViewportHit(hit):
if hit == null:
stop
match tool_mode:
"select", "move", "resize":
if hit.id != null:
call selectPrimitive hit.id
"paint":
if hit.id != null:
local frame = frames[active_frame_index]
local prim = frame.primitives.find(p => p.id == hit.id)
if prim == null:
stop
if prim.color == active_color:
call selectPrimitive hit.id
else:
call pushUndo
prim.color = active_color
selected_primitive_id = prim.id
status_message = "Painted " + prim.name + " with swatch '" + active_color + "'"
"erase":
if hit.id != null:
call deletePrimitive hit.id
"place":
if !hit.hit_floor and hit.id == null:
stop
local frame = frames[active_frame_index]
if frame.primitives.length >= 256:
status_message = "Maximum 256 primitives per model reached."
stop
call pushUndo
local nid = next_prim_id(frame.primitives)
local gx = to_number(hit.grid[0], 0)
local gy = to_number(hit.grid[1], 0)
local gz = to_number(hit.grid[2], 0)
local nx = to_number(hit.face[0], 0)
local ny = to_number(hit.face[1], 0)
local nz = to_number(hit.face[2], 1)
local min_x = gx
local max_x = gx
local min_y = gy
local max_y = gy
local min_z = gz
local max_z = gz
if hit.id != null:
local target = frame.primitives.find(p => p.id == hit.id)
if target != null:
match target.kind:
"box", "ramp":
min_x = target.from[0]
max_x = target.from[0] + target.size[0]
min_y = target.from[1]
max_y = target.from[1] + target.size[1]
min_z = target.from[2]
max_z = target.from[2] + target.size[2]
else:
local pr = target.radius
local ph = target.kind == "sphere" ? pr * 2 : target.height
min_x = target.center[0] - pr
max_x = target.center[0] + pr
min_y = target.center[1] - pr
max_y = target.center[1] + pr
min_z = target.center[2] - ph * 0.5
max_z = target.center[2] + ph * 0.5
local placed = null
match place_kind:
"box":
local fx = hit.id != null ? (nx > 0 ? round(max_x) : (nx < 0 ? round(min_x) - 2 : round(gx - 1))) : round(gx - 1)
local fy = hit.id != null ? (ny > 0 ? round(max_y) : (ny < 0 ? round(min_y) - 2 : round(gy - 1))) : round(gy - 1)
local fz = hit.id != null ? (nz > 0 ? round(max_z) : (nz < 0 ? round(min_z) - 2 : round(gz - 1))) : 0
placed = box_prim(nid, "Box " + nid, active_color, [clamp(fx, -32, 32), clamp(fy, -32, 32), clamp(fz, -32, 32)], [2, 2, 2])
"ramp":
local fx = hit.id != null ? (nx > 0 ? round(max_x) : (nx < 0 ? round(min_x) - 2 : round(gx - 1))) : round(gx - 1)
local fy = hit.id != null ? (ny > 0 ? round(max_y) : (ny < 0 ? round(min_y) - 2 : round(gy - 1))) : round(gy - 1)
local fz = hit.id != null ? (nz > 0 ? round(max_z) : (nz < 0 ? round(min_z) - 2 : round(gz - 1))) : 0
placed = ramp_prim(nid, "Ramp " + nid, active_color, [clamp(fx, -32, 32), clamp(fy, -32, 32), clamp(fz, -32, 32)], [2, 2, 2])
"sphere":
local r = 1.5
local cx = hit.id != null ? (nx > 0 ? max_x + r : (nx < 0 ? min_x - r : round_to(gx * 2, 0) * 0.5)) : round_to(gx * 2, 0) * 0.5
local cy = hit.id != null ? (ny > 0 ? max_y + r : (ny < 0 ? min_y - r : round_to(gy * 2, 0) * 0.5)) : round_to(gy * 2, 0) * 0.5
local cz = hit.id != null ? (nz > 0 ? max_z + r : (nz < 0 ? min_z - r : round_to(gz * 2, 0) * 0.5)) : r
placed = sphere_prim(nid, "Sphere " + nid, active_color, [clamp(round_to(cx, 2), -32, 32), clamp(round_to(cy, 2), -32, 32), clamp(round_to(cz, 2), -32, 32)], r)
"cylinder":
local r = 1.5
local h = 3
local cx = hit.id != null ? (nx > 0 ? max_x + r : (nx < 0 ? min_x - r : round_to(gx * 2, 0) * 0.5)) : round_to(gx * 2, 0) * 0.5
local cy = hit.id != null ? (ny > 0 ? max_y + r : (ny < 0 ? min_y - r : round_to(gy * 2, 0) * 0.5)) : round_to(gy * 2, 0) * 0.5
local cz = hit.id != null ? (nz > 0 ? max_z + h * 0.5 : (nz < 0 ? min_z - h * 0.5 : round_to(gz * 2, 0) * 0.5)) : h * 0.5
placed = cyl_prim(nid, "Cylinder " + nid, active_color, [clamp(round_to(cx, 2), -32, 32), clamp(round_to(cy, 2), -32, 32), clamp(round_to(cz, 2), -32, 32)], r, h)
if placed != null:
frames[active_frame_index].primitives = [...frame.primitives, placed]
selected_primitive_id = nid
status_message = "Placed " + placed.name
action onViewportGizmo(evt):
if evt == null or frames.length == 0:
stop
local frame = frames[active_frame_index]
local prim = frame.primitives.find(p => p.id == selected_primitive_id)
if prim == null:
stop
match evt.phase:
"start":
drag_snapshot = history.capture(history_keys())
drag_orig_prim = deep_clone(prim)
"drag":
if drag_orig_prim == null:
stop
local d = to_number(evt.delta, 0)
match evt.mode:
"move":
match prim.kind:
"box", "ramp":
match evt.axis:
"x":
prim.from = [clamp(round(drag_orig_prim.from[0] + d), -32, 32), drag_orig_prim.from[1], drag_orig_prim.from[2]]
"y":
prim.from = [drag_orig_prim.from[0], clamp(round(drag_orig_prim.from[1] + d), -32, 32), drag_orig_prim.from[2]]
"z":
prim.from = [drag_orig_prim.from[0], drag_orig_prim.from[1], clamp(round(drag_orig_prim.from[2] + d), -32, 32)]
else:
match evt.axis:
"x":
prim.center = [clamp(round_to(drag_orig_prim.center[0] + d, 2), -32, 32), drag_orig_prim.center[1], drag_orig_prim.center[2]]
"y":
prim.center = [drag_orig_prim.center[0], clamp(round_to(drag_orig_prim.center[1] + d, 2), -32, 32), drag_orig_prim.center[2]]
"z":
prim.center = [drag_orig_prim.center[0], drag_orig_prim.center[1], clamp(round_to(drag_orig_prim.center[2] + d, 2), -32, 32)]
status_message = "Moved " + prim.name + " (" + evt.axis + " " + (d >= 0 ? "+" : "") + d + ")"
"resize":
match prim.kind:
"box", "ramp":
match evt.axis:
"x":
prim.size = [clamp(round(drag_orig_prim.size[0] + d), 1, 32), drag_orig_prim.size[1], drag_orig_prim.size[2]]
"y":
prim.size = [drag_orig_prim.size[0], clamp(round(drag_orig_prim.size[1] + d), 1, 32), drag_orig_prim.size[2]]
"z":
prim.size = [drag_orig_prim.size[0], drag_orig_prim.size[1], clamp(round(drag_orig_prim.size[2] + d), 1, 32)]
"sphere":
prim.radius = clamp(round_to(drag_orig_prim.radius + d, 2), 0.5, 16)
"cylinder":
match evt.axis:
"z":
prim.height = clamp(round_to(drag_orig_prim.height + d, 2), 0.5, 32)
else:
prim.radius = clamp(round_to(drag_orig_prim.radius + d, 2), 0.5, 16)
status_message = "Resized " + prim.name + " (" + evt.axis + " " + (d >= 0 ? "+" : "") + d + ")"
"end":
if drag_snapshot != null and to_number(evt.delta, 0) != 0:
history.push(drag_snapshot, 40)
drag_snapshot = null
drag_orig_prim = null
@Logic/model_studio
func sanitize_hex(raw, fallback):
local cleaned = raw.trim().toLowerCase()
if regex_match(cleaned, "^#[0-9a-f]{6}$") != null:
return cleaned
if regex_match(cleaned, "^[0-9a-f]{6}$") != null:
return "#" + cleaned
return fallback
func slugify_id(raw, fallback):
local lowered = raw.trim().toLowerCase()
local body = regex_replace(lowered, "[^a-z0-9/_-]+", "_")
local trimmed = regex_replace(body, "^[_/-]+|[_/-]+$", "")
if trimmed == "":
return fallback
return trimmed
func make_prim(id, kind, name, color, from, size, center, radius, height):
local fx = clamp(to_number(from[0], -2), -32, 32)
local fy = clamp(to_number(from[1], -2), -32, 32)
local fz = clamp(to_number(from[2], 0), -32, 32)
local sx = clamp(to_number(size[0], 4), 0.1, 32)
local sy = clamp(to_number(size[1], 4), 0.1, 32)
local sz = clamp(to_number(size[2], 4), 0.1, 32)
match kind:
"box":
fx = round(fx)
fy = round(fy)
fz = round(fz)
sx = round(clamp(sx, 1, 32))
sy = round(clamp(sy, 1, 32))
sz = round(clamp(sz, 1, 32))
else:
fx = round_to(fx, 3)
fy = round_to(fy, 3)
fz = round_to(fz, 3)
sx = round_to(sx, 3)
sy = round_to(sy, 3)
sz = round_to(sz, 3)
local cx = round_to(clamp(to_number(center[0], 0), -32, 32), 3)
local cy = round_to(clamp(to_number(center[1], 0), -32, 32), 3)
local cz = round_to(clamp(to_number(center[2], 2), -32, 32), 3)
local r = round_to(clamp(to_number(radius, 2.5), 0.1, 32), 3)
local h = round_to(clamp(to_number(height, 5), 0.1, 32), 3)
local prim = {"id": id, "kind": kind, "name": name, "color": color, "from": [fx, fy, fz], "size": [sx, sy, sz], "center": [cx, cy, cz], "radius": r, "height": h, "order": 0}
return prim
func box_prim(id, name, color, from, size):
return make_prim(id, "box", name, color, from, size, [0, 0, 2], 2, 4)
func sphere_prim(id, name, color, center, radius):
return make_prim(id, "sphere", name, color, [-2, -2, 0], [4, 4, 4], center, radius, radius * 2)
func cyl_prim(id, name, color, center, radius, height):
return make_prim(id, "cylinder", name, color, [-2, -2, 0], [4, 4, 4], center, radius, height)
func ramp_prim(id, name, color, from, size):
return make_prim(id, "ramp", name, color, from, size, [0, 0, 2], 2, 4)
func make_frame(id, label, primitives, x, y, z, angle, pitch, scale, dissolve):
local frame = {"id": id, "label": label, "primitives": primitives, "x": round_to(clamp(to_number(x, 0), -16, 16), 3), "y": round_to(clamp(to_number(y, 0), -16, 16), 3), "z": round_to(clamp(to_number(z, 0), -16, 16), 3), "angle": round_to(clamp(to_number(angle, 0), -360, 360), 1), "pitch": round_to(clamp(to_number(pitch, 0), -90, 90), 1), "scale": round_to(clamp(to_number(scale, 1), 0.1, 4), 2), "dissolve": round_to(clamp(to_number(dissolve, 0), 0, 1), 2)}
return frame
func make_clip(id, name, rate_fps, mode, interp, frms):
local clean_id = slugify_id(id, "idle")
local clean_mode = (mode == "once" or mode == "pingpong") ? mode : "loop"
local clean_name = name != "" ? name : "Idle"
local clean_fps = clamp(round(to_number(rate_fps, 6)), 1, 24)
local clean_interp = interp != false
local clip = {"id": clean_id, "name": clean_name, "fps": clean_fps, "mode": clean_mode, "interpolate": clean_interp, "frames": frms}
return clip
func knight_pose(left_leg_x, right_leg_x, sword_z, sword_len, shield_y):
local p1 = box_prim(1, "Left Boot", "d", [left_leg_x, -3, 0], [3, 2, 4])
local p2 = box_prim(2, "Right Boot", "d", [right_leg_x, 1, 0], [3, 2, 4])
local p3 = box_prim(3, "Torso Armor", "b", [-2, -4, 4], [4, 8, 7])
local p4 = box_prim(4, "Chest Plate", "s", [1, -3, 5], [2, 6, 5])
local p5 = box_prim(5, "Belt Buckle", "g", [1, -1, 4], [2, 2, 1])
local p6 = box_prim(6, "Helmet", "s", [-2, -3, 11], [5, 6, 5])
local p7 = box_prim(7, "Visor Slit", "p", [2, -2, 13], [1, 4, 1])
local p8 = ramp_prim(8, "Helmet Crest", "g", [-2, -1, 16], [5, 2, 3])
local p9 = box_prim(9, "Shield", "s", [1, shield_y, 5], [2, 2, 6])
local p10 = box_prim(10, "Shield Emblem", "g", [2, shield_y, 7], [1, 1, 2])
local p11 = box_prim(11, "Sword Hilt", "g", [2, 4, sword_z], [3, 1, 2])
local p12 = box_prim(12, "Rune Blade", "c", [4, 4, sword_z + 1], [sword_len, 1, 2])
return [p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12]
func drone_pose(wing_z, core_r):
local p1 = sphere_prim(1, "Core Sphere", "d", [0, 0, 5], 3.4)
local p2 = cyl_prim(2, "Halo Ring", "p", [0, 0, 5], 4.6, 1.0)
local p3 = sphere_prim(3, "Optic Eye", "c", [3.0, 0, 5], core_r)
local p4 = ramp_prim(4, "Left Wing", "s", [-3, -7, wing_z], [6, 3, 2])
local p5 = ramp_prim(5, "Right Wing", "s", [-3, 4, wing_z], [6, 3, 2])
local p6 = cyl_prim(6, "Thruster", "c", [0, 0, 1.4], 1.5, 1.2)
return [p1, p2, p3, p4, p5, p6]
func clown_pose(tail_y, fin_y, bubble_z):
local p1 = sphere_prim(1, "Front Body", "o", [1.5, 0, 4], 3.4)
local p2 = sphere_prim(2, "Back Body", "o", [-2.0, 0, 4], 2.9)
local p3 = box_prim(3, "Front Stripe", "w", [1, -3, 1], [1, 6, 6])
local p4 = box_prim(4, "Mid Stripe", "w", [-2, -3, 2], [1, 6, 5])
local p5 = box_prim(5, "Tail Fin", "o", [-7, tail_y, 2], [3, 2, 5])
local p6 = box_prim(6, "Dorsal Fin", "o", [-2, -1, 7], [4, 2, 2])
local p7 = box_prim(7, "Side Fin", "w", [0, fin_y, 3], [2, 2, 2])
local p8 = box_prim(8, "Left Eye", "k", [3, -3, 5], [1, 1, 1])
local p9 = box_prim(9, "Right Eye", "k", [3, 2, 5], [1, 1, 1])
local p10 = sphere_prim(10, "Bubble", "c", [6, 0, bubble_z], 0.9)
return [p1, p2, p3, p4, p5, p6, p7, p8, p9, p10]
func pup_pose(front_x, back_x, tail_y, tail_z):
local p1 = box_prim(1, "Front Left Leg", "w", [front_x, -3, 0], [2, 2, 5])
local p2 = box_prim(2, "Front Right Leg", "d", [front_x - 1, 1, 0], [2, 2, 5])
local p3 = box_prim(3, "Back Left Leg", "d", [back_x, -3, 0], [2, 2, 5])
local p4 = box_prim(4, "Back Right Leg", "w", [back_x + 1, 1, 0], [2, 2, 5])
local p5 = box_prim(5, "Body", "d", [-6, -3, 4], [12, 6, 5])
local p6 = box_prim(6, "Collar", "s", [4, -3, 5], [2, 6, 2])
local p7 = box_prim(7, "Head", "w", [5, -3, 7], [6, 6, 5])
local p8 = box_prim(8, "Snout", "w", [10, -2, 7], [3, 4, 3])
local p9 = box_prim(9, "Nose", "k", [12, -1, 9], [1, 2, 1])
local p10 = box_prim(10, "Left Ear", "p", [5, -4, 8], [3, 1, 4])
local p11 = box_prim(11, "Right Ear", "p", [5, 3, 8], [3, 1, 4])
local p12 = box_prim(12, "Left Eye", "k", [10, -3, 10], [1, 1, 1])
local p13 = box_prim(13, "Right Eye", "k", [10, 2, 10], [1, 1, 1])
local p14 = box_prim(14, "Tail", "d", [-9, tail_y, tail_z], [4, 2, 2])
return [p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14]
func sentry_pose(eye_color, fin_z):
local p1 = cyl_prim(1, "Base Pedestal", "i", [0, 0, 1.5], 4.2, 3)
local p2 = cyl_prim(2, "Turret Column", "m", [0, 0, 5.5], 2.8, 5)
local p3 = sphere_prim(3, "Sensor Dome", eye_color, [0, 0, 9.2], 2.4)
local p4 = ramp_prim(4, "East Fin", "m", [2, -1, fin_z], [4, 2, 3])
local p5 = ramp_prim(5, "West Fin", "m", [-6, -1, fin_z], [4, 2, 3])
return [p1, p2, p3, p4, p5]
func build_preset(key):
match key:
"neon_drone":
local pal = [{"symbol": "d", "hex": "#1e2b45", "name": "Chassis", "emissive": false}, {"symbol": "s", "hex": "#486085", "name": "Alloy", "emissive": false}, {"symbol": "c", "hex": "#00e5ff", "name": "Cyan Core", "emissive": true}, {"symbol": "p", "hex": "#ff2a85", "name": "Plasma Ring", "emissive": true}, {"symbol": "w", "hex": "#e8f4ff", "name": "Lens", "emissive": false}]
local h1 = make_frame(1, "Hover Low", drone_pose(4, 1.3), 0, 0, 0.1, -8, 3, 1, 0)
local h2 = make_frame(2, "Hover High", drone_pose(5, 1.6), 0, 0, 0.4, 8, -4, 1, 0)
local c_hover = make_clip("hover", "Hover", 6, "pingpong", true, [h1, h2])
local s1 = make_frame(1, "Sweep Left", drone_pose(4.5, 1.5), 0, 0, 0.25, -35, 0, 1, 0)
local s2 = make_frame(2, "Scan Pulse", drone_pose(4.5, 2.0), 0, 0, 0.28, 0, 0, 1.06, 0.08)
local s3 = make_frame(3, "Sweep Right", drone_pose(4.5, 1.5), 0, 0, 0.25, 35, 0, 1, 0)
local c_scan = make_clip("scan", "Scan", 8, "loop", true, [s1, s2, s3])
local b1 = make_frame(1, "Charge", drone_pose(4, 1.3), -0.08, 0, 0.18, 0, 8, 0.96, 0)
local b2 = make_frame(2, "Surge", drone_pose(5.5, 2.1), 0.22, 0, 0.36, 0, -14, 1.06, 0)
local b3 = make_frame(3, "Settle", drone_pose(4, 1.3), 0, 0, 0.14, 0, 0, 1, 0)
local c_boost = make_clip("boost", "Boost", 10, "once", true, [b1, b2, b3])
local preset = {"model_id": "neon_drone", "model_title": "Neon Hover Drone", "palette_name": "drone", "unit": 0.125, "contact_shadow": 0.75, "palette": pal, "clips": [c_hover, c_scan, c_boost], "active_clip_index": 0, "active_frame_index": 0, "selected_primitive_id": 3, "active_color": "c"}
return preset
"lagoon_clownfish":
local pal = [{"symbol": "o", "hex": "#ff8a3d", "name": "Coral Orange", "emissive": false}, {"symbol": "w", "hex": "#f4fff7", "name": "Pearl White", "emissive": false}, {"symbol": "k", "hex": "#102039", "name": "Deep Ink", "emissive": false}, {"symbol": "c", "hex": "#39e9ee", "name": "Glow Bubble", "emissive": true}]
local sw1 = make_frame(1, "Swim Mid", clown_pose(-1, -4, 6.2), 0, 0, 0.25, 0, 0, 1, 0)
local sw2 = make_frame(2, "Tail Left", clown_pose(-2, -4, 7.6), 0, 0.06, 0.34, 10, -4, 1, 0)
local sw3 = make_frame(3, "Tail Right", clown_pose(0, -3, 9.0), 0, -0.06, 0.2, -10, 4, 1, 0)
local c_swim = make_clip("swim", "Swim", 8, "loop", true, [sw1, sw2, sw3])
local d1 = make_frame(1, "Coil", clown_pose(-2, -4, 6.2), -0.1, 0, 0.22, -14, 4, 0.96, 0)
local d2 = make_frame(2, "Dash", clown_pose(0, -3, 8.2), 0.26, 0, 0.32, 6, -6, 1.05, 0)
local d3 = make_frame(3, "Glide", clown_pose(-1, -4, 9.2), 0, 0, 0.25, 0, 0, 1, 0)
local c_dart = make_clip("dart", "Dart", 12, "once", true, [d1, d2, d3])
local preset = {"model_id": "clownfish", "model_title": "Lagoon Clownfish", "palette_name": "aqua", "unit": 0.125, "contact_shadow": 0.5, "palette": pal, "clips": [c_swim, c_dart], "active_clip_index": 0, "active_frame_index": 0, "selected_primitive_id": 1, "active_color": "o"}
return preset
"neighborhood_pup":
local pal = [{"symbol": "d", "hex": "#e2c799", "name": "Golden Coat", "emissive": false}, {"symbol": "w", "hex": "#f6f8f0", "name": "Cream Fur", "emissive": false}, {"symbol": "p", "hex": "#9b6b43", "name": "Floppy Ears", "emissive": false}, {"symbol": "s", "hex": "#ff4f79", "name": "Collar", "emissive": false}, {"symbol": "k", "hex": "#141e30", "name": "Nose & Eyes", "emissive": false}]
local i1 = make_frame(1, "Stand", pup_pose(3, -5, -1, 8), 0, 0, 0, 0, 0, 1, 0)
local i2 = make_frame(2, "Wag Left", pup_pose(3, -5, -2, 9), 0, 0, 0.02, 3, 0, 1, 0)
local i3 = make_frame(3, "Wag Right", pup_pose(3, -5, 0, 9), 0, 0, 0.02, -3, 0, 1, 0)
local c_idle = make_clip("idle", "Idle", 5, "pingpong", true, [i1, i2, i3])
local t1 = make_frame(1, "Trot A", pup_pose(5, -6, -2, 9), 0, 0, 0.08, 4, -4, 1, 0)
local t2 = make_frame(2, "Trot B", pup_pose(2, -3, 0, 9), 0, 0, 0.04, -4, 3, 1, 0)
local c_trot = make_clip("trot", "Trot", 8, "loop", true, [t1, t2])
local p1 = make_frame(1, "Stand", pup_pose(3, -5, -1, 8), 0, 0, 0, 0, 4, 0.96, 0)
local p2 = make_frame(2, "Happy Hop", pup_pose(4, -5, -1, 10), 0.1, 0, 0.3, 0, -9, 1.04, 0)
local p3 = make_frame(3, "Land", pup_pose(3, -5, -1, 8), 0, 0, 0, 0, 0, 1, 0)
local c_hop = make_clip("hop", "Hop", 10, "once", true, [p1, p2, p3])
local preset = {"model_id": "pup", "model_title": "Neighborhood Pup", "palette_name": "walk", "unit": 0.1, "contact_shadow": 0.7, "palette": pal, "clips": [c_idle, c_trot, c_hop], "active_clip_index": 0, "active_frame_index": 0, "selected_primitive_id": 7, "active_color": "d"}
return preset
"marble_sentry":
local pal = [{"symbol": "m", "hex": "#d59968", "name": "Copper", "emissive": false}, {"symbol": "i", "hex": "#39465c", "name": "Slate", "emissive": false}, {"symbol": "c", "hex": "#68e1e8", "name": "Beacon Cyan", "emissive": true}, {"symbol": "r", "hex": "#ff5268", "name": "Alert Red", "emissive": true}]
local pa1 = make_frame(1, "Patrol 0°", sentry_pose("c", 3), 0, 0, 0, 0, 0, 1, 0)
local pa2 = make_frame(2, "Sweep 90°", sentry_pose("c", 4), 0, 0, 0.08, 90, 0, 1, 0)
local pa3 = make_frame(3, "Patrol 180°", sentry_pose("c", 3), 0, 0, 0, 180, 0, 1, 0)
local pa4 = make_frame(4, "Reset 270°", sentry_pose("c", 4), 0, 0, 0.08, 270, 0, 1, 0)
local c_patrol = make_clip("patrol", "Patrol", 6, "loop", true, [pa1, pa2, pa3, pa4])
local al1 = make_frame(1, "Lock On", sentry_pose("r", 4), 0, 0, 0.1, 0, 0, 1.02, 0)
local al2 = make_frame(2, "Red Pulse", sentry_pose("r", 5), 0, 0, 0.2, 0, 0, 1.08, 0)
local c_alert = make_clip("alert", "Alert", 10, "pingpong", true, [al1, al2])
local preset = {"model_id": "sentry", "model_title": "Marble Sentry", "palette_name": "foundry", "unit": 0.125, "contact_shadow": 0.8, "palette": pal, "clips": [c_patrol, c_alert], "active_clip_index": 0, "active_frame_index": 0, "selected_primitive_id": 3, "active_color": "m"}
return preset
else:
local pal = [{"symbol": "s", "hex": "#7f93ad", "name": "Steel", "emissive": false}, {"symbol": "d", "hex": "#3d4c63", "name": "Dark Iron", "emissive": false}, {"symbol": "b", "hex": "#2878c8", "name": "Tunic Blue", "emissive": false}, {"symbol": "g", "hex": "#f5c542", "name": "Gold Trim", "emissive": false}, {"symbol": "c", "hex": "#39e9ee", "name": "Rune Blade", "emissive": true}, {"symbol": "p", "hex": "#e8c19e", "name": "Visor Skin", "emissive": false}]
local ki1 = make_frame(1, "Ready", knight_pose(-1, -1, 6, 7, -6), 0, 0, 0, 0, 0, 1, 0)
local ki2 = make_frame(2, "Breathe", knight_pose(-1, -1, 6, 7, -6), 0, 0, 0.04, 0, 0, 1.02, 0)
local c_idle = make_clip("idle", "Idle", 4, "pingpong", true, [ki1, ki2])
local kw1 = make_frame(1, "Stride L", knight_pose(1, -3, 7, 7, -6), 0, 0, 0.06, 6, 0, 1, 0)
local kw2 = make_frame(2, "Pass", knight_pose(-1, -1, 6, 7, -6), 0, 0, 0, 0, 0, 1, 0)
local kw3 = make_frame(3, "Stride R", knight_pose(-3, 1, 5, 7, -6), 0, 0, 0.06, -6, 0, 1, 0)
local c_walk = make_clip("walk", "Walk", 8, "loop", true, [kw1, kw2, kw3])
local ks1 = make_frame(1, "Windup", knight_pose(-2, 1, 10, 6, -5), 0, 0, 0.04, -18, -4, 1, 0)
local ks2 = make_frame(2, "Strike", knight_pose(2, -2, 5, 10, -6), 0.14, 0, 0.02, 24, 6, 1.04, 0)
local ks3 = make_frame(3, "Recover", knight_pose(-1, -1, 6, 7, -6), 0, 0, 0, 0, 0, 1, 0)
local c_slash = make_clip("slash", "Slash", 10, "once", true, [ks1, ks2, ks3])
local preset = {"model_id": "knight", "model_title": "Dungeon Knight", "palette_name": "knight", "unit": 0.1, "contact_shadow": 0.65, "palette": pal, "clips": [c_idle, c_walk, c_slash], "active_clip_index": 0, "active_frame_index": 0, "selected_primitive_id": 12, "active_color": "c"}
return preset
@Logic/model_studio
state:
selected_preset = "dungeon_knight"
model_id = "knight"
model_title = "Dungeon Knight"
palette_name = "knight"
unit = 0.1
contact_shadow = 0.65
saved_models = []
fps = 6
playback_mode = "loop"
interpolate_transforms = true
is_playing = false
play_start_ms = 0
spin_start_ms = 0
is_fullscreen = false
camera_yaw = -135
camera_pitch = -24
camera_zoom = 4.2
turntable = false
show_grid = true
show_axes = true
show_glow = true
show_onion_skin = false
viewport_resolution = "1280x800"
tool_mode = "select"
place_kind = "box"
hud_hint = "Click part to select · Drag to orbit · Wheel zoom · Keys 1–6 switch tools"
drag_snapshot = null
drag_orig_prim = null
active_color = "c"
new_color_hex = "#ff5db5"
active_frame_index = 0
selected_primitive_id = 12
palette = []
clips = []
active_clip_index = 0
frames = []
copied_pose = null
active_lower_tab = "export"
export_include_animations = true
import_code = ""
status_message = "Drag the 3D viewport to orbit · Click any part to select · Play to preview animation."
computed:
can_undo = history.can_undo
can_redo = history.can_redo
clip_count = clips.length
active_clip = clips.length > 0 ? clips[clamp(floor(active_clip_index), 0, clips.length - 1)] : null
active_clip_id = active_clip != null ? active_clip.id : "idle"
active_clip_name = active_clip != null ? active_clip.name : "Idle"
has_copied_pose = copied_pose != null
frame_count = frames.length
frame_number = frames.length > 0 ? active_frame_index + 1 : 0
active_frame = frames.length > 0 ? frames[clamp(floor(active_frame_index), 0, frames.length - 1)] : null
primitive_count = active_frame != null ? active_frame.primitives.length : 0
active_swatch = palette.find(c => c.symbol == active_color)
active_color_hex = active_swatch != null ? active_swatch.hex : "#68e1e8"
selected_prim = active_frame != null ? active_frame.primitives.find(p => p.id == selected_primitive_id) : null
has_selection = selected_prim != null
sel_kind = selected_prim != null ? selected_prim.kind : "box"
sel_name = selected_prim != null ? selected_prim.name : ""
sel_color = selected_prim != null ? selected_prim.color : "c"
sel_from_x = selected_prim != null ? selected_prim.from[0] : 0
sel_from_y = selected_prim != null ? selected_prim.from[1] : 0
sel_from_z = selected_prim != null ? selected_prim.from[2] : 0
sel_size_x = selected_prim != null ? selected_prim.size[0] : 1
sel_size_y = selected_prim != null ? selected_prim.size[1] : 1
sel_size_z = selected_prim != null ? selected_prim.size[2] : 1
sel_center_x = selected_prim != null ? selected_prim.center[0] : 0
sel_center_y = selected_prim != null ? selected_prim.center[1] : 0
sel_center_z = selected_prim != null ? selected_prim.center[2] : 0
sel_radius = selected_prim != null ? selected_prim.radius : 1
sel_height = selected_prim != null ? selected_prim.height : 2
sel_order = selected_prim != null ? (selected_prim.order ?? 0) : 0
frame_label = active_frame != null ? active_frame.label : "Idle"
frame_x = active_frame != null ? active_frame.x : 0
frame_y = active_frame != null ? active_frame.y : 0
frame_z = active_frame != null ? active_frame.z : 0
frame_angle = active_frame != null ? active_frame.angle : 0
frame_pitch = active_frame != null ? active_frame.pitch : 0
frame_scale = active_frame != null ? active_frame.scale : 1
frame_dissolve = active_frame != null ? active_frame.dissolve : 0
active_primitives = build_prim_rows(active_frame, palette, selected_primitive_id)
clip_items = build_clip_rows(clips, active_clip_index)
frame_items = build_frame_rows(frames, active_frame_index)
exported_rune = clips.length > 0 ? format_rune_code(model_id, model_title, palette_name, unit, contact_shadow, palette, clips, export_include_animations) : ""
watch clips, active_clip_index, frames, palette, active_frame_index, selected_primitive_id, is_playing, tool_mode, place_kind, unit, contact_shadow, show_grid, show_axes, show_glow, show_onion_skin, camera_yaw, camera_pitch, camera_zoom, viewport_resolution:
call renderViewport
keys:
Digit1 -> setToolMode("select")
Digit2 -> setToolMode("move")
Digit3 -> setToolMode("resize")
Digit4 -> setToolMode("place")
Digit5 -> setToolMode("paint")
Digit6 -> setToolMode("erase")
@Logic/model_studio
action loadModelLibrary:
saved_models = storage.get("rune_model_studio_library")
if saved_models == null:
saved_models = []
action renameModel(title):
model_title = title
call syncStudio
action setModelId(id):
model_id = id
call syncStudio
action setLowerTab(tab):
active_lower_tab = tab
action toggleExportAnimations:
export_include_animations = !export_include_animations
call syncStudio
action setImportCode(text):
import_code = text
action importRuneCode:
local parsed = parse_rune_code(import_code)
if (parsed.error ?? "") != "":
status_message = parsed.error
stop
is_playing = false
call syncPlaybackTimer
call pushUndo
call applySnapshot parsed.snapshot
active_lower_tab = "export"
status_message = "Imported " + model_title + " (" + clips.length + " clip" + (clips.length == 1 ? "" : "s") + ", " + frames.length + " frame" + (frames.length == 1 ? "" : "s") + " active)"
call syncStudio
action newModel:
is_playing = false
call syncPlaybackTimer
call pushUndo
local number = storage.get("rune_model_studio_counter")
number = (number ?? 0) + 1
storage.set("rune_model_studio_counter", number)
local mid = "model_" + number
local pal = [{"symbol": "c", "hex": "#00e5ff", "name": "Cyan", "emissive": false}, {"symbol": "s", "hex": "#486085", "name": "Steel", "emissive": false}, {"symbol": "g", "hex": "#ffaa00", "name": "Amber", "emissive": true}, {"symbol": "w", "hex": "#f0f7ff", "name": "White", "emissive": false}]
local base_box = box_prim(1, "Base Block", "s", [-2, -2, 0], [4, 4, 4])
local f1 = make_frame(1, "Pose 1", [base_box], 0, 0, 0, 0, 0, 1, 0)
local c1 = make_clip("idle", "Idle", 6, "loop", true, [f1])
local snap = {"model_id": mid, "model_title": "Untitled Model " + number, "palette_name": mid, "unit": 0.125, "contact_shadow": 0.6, "palette": pal, "clips": [c1], "active_clip_index": 0, "active_frame_index": 0, "selected_primitive_id": 1, "active_color": "c"}
call applySnapshot snap
status_message = "Created new model: " + model_title
call syncStudio
action selectPreset(key):
is_playing = false
call syncPlaybackTimer
call pushUndo
local preset = build_preset(key)
selected_preset = key
call applySnapshot preset
status_message = "Loaded preset: " + model_title + " (" + clips.length + " clips)"
call syncStudio
action openModel(key):
match key:
"reload_saved":
call loadFromStorage
"dungeon_knight", "neon_drone", "lagoon_clownfish", "neighborhood_pup", "marble_sentry":
call selectPreset key
else:
for entry in saved_models:
if entry.key == key:
model_id = entry.id
call loadFromStorage
action saveToStorage:
if model_title == "":
model_title = "Untitled Model"
if model_id == "":
model_id = "custom_model"
local snapshot = capture_snapshot(model_id, model_title, palette_name, unit, contact_shadow, palette, clips, active_clip_index, active_frame_index, selected_primitive_id, active_color)
storage.set("rune_model_studio_last", model_id)
storage.set("rune_model_studio_item_" + model_id, snapshot)
call loadModelLibrary
saved_models = saved_models.filter it.id != model_id
saved_models.push({"key": "saved:" + model_id, "id": model_id, "title": model_title})
storage.set("rune_model_studio_library", saved_models)
status_message = "Saved " + model_title + " in this browser. Export .rune keeps a file copy."
action loadFromStorage:
local target = model_id
local saved = storage.get("rune_model_studio_item_" + target)
if saved == null:
local last_id = storage.get("rune_model_studio_last")
if last_id != null:
saved = storage.get("rune_model_studio_item_" + last_id)
if saved == null:
status_message = "No saved model found for \"" + target + "\""
stop
is_playing = false
call syncPlaybackTimer
call pushUndo
call applySnapshot saved
status_message = "Restored saved model: " + model_title
call syncStudio
action exportRune:
call syncStudio
download(model_id + ".rune", exported_rune)
status_message = "Exported " + model_id + ".rune"
action copyRuneCode:
call syncStudio
clipboard.copy(exported_rune)
status_message = "Copied Pixel-3D .rune code to clipboard"
@Logic/model_studio
func sample_animation(frms, elapsed_sec, rate_fps, mode, interp):
local count = frms.length
if count == 0:
local empty_pose = {"frame_index": 0, "x": 0, "y": 0, "z": 0, "angle": 0, "pitch": 0, "scale": 1, "dissolve": 0}
return empty_pose
if count == 1:
local f = frms[0]
local single_pose = {"frame_index": 0, "x": f.x, "y": f.y, "z": f.z, "angle": f.angle, "pitch": f.pitch, "scale": f.scale, "dissolve": f.dissolve}
return single_pose
local rate = clamp(to_number(rate_fps, 6), 1, 30)
local raw = max(0, elapsed_sec) * rate
local idx_a = 0
local idx_b = 0
local t = 0
match mode:
"once":
local clamped = min(raw, count - 1)
idx_a = floor(clamped)
idx_b = min(count - 1, idx_a + 1)
t = clamped - idx_a
"pingpong":
local span = (count - 1) * 2
local pos = raw % span
local folded = pos <= count - 1 ? pos : span - pos
local lo = floor(folded)
if pos <= count - 1:
idx_a = lo
idx_b = min(count - 1, lo + 1)
t = folded - lo
if pos > count - 1:
local hi = min(count - 1, ceil(folded))
t = hi - folded
idx_a = hi
idx_b = max(0, hi - 1)
else:
local wrapped = raw % count
idx_a = floor(wrapped)
idx_b = (idx_a + 1) % count
t = wrapped - idx_a
local a = frms[idx_a]
local b = frms[idx_b]
local mix = interp ? t : 0
local pose = {"frame_index": idx_a, "x": a.x + (b.x - a.x) * mix, "y": a.y + (b.y - a.y) * mix, "z": a.z + (b.z - a.z) * mix, "angle": a.angle + (b.angle - a.angle) * mix, "pitch": a.pitch + (b.pitch - a.pitch) * mix, "scale": max(0.05, a.scale + (b.scale - a.scale) * mix), "dissolve": clamp(a.dissolve + (b.dissolve - a.dissolve) * mix, 0, 1)}
return pose
func build_model_spec(frame, pal, m_unit, m_shadow, sel_id, pickable, pose):
local fallback_hex = pal.length > 0 ? pal[0].hex : "#68e1e8"
local out_prims = []
for p in frame.primitives:
local swatch = pal.find(c => c.symbol == p.color)
local hx = swatch != null ? swatch.hex : fallback_hex
local glow = swatch != null ? swatch.emissive : false
local item = {"id": p.id, "kind": p.kind, "from": p.from, "size": p.size, "center": p.center, "radius": p.radius, "height": p.height, "color": hx, "emissive": glow, "order": p.order ?? 0}
out_prims = out_prims.concat([item])
local result = {"unit": m_unit, "x": pose.x, "y": pose.y, "z": pose.z, "angle": pose.angle, "pitch": pose.pitch, "scale": pose.scale, "dissolve": pose.dissolve, "contact_shadow": m_shadow, "pickable": pickable, "selected_id": sel_id, "primitives": out_prims}
return result
func build_gizmo_spec(frame, sel_id, m_unit, mode):
if mode != "move" and mode != "resize":
return null
local sel = frame.primitives.find(p => p.id == sel_id)
if sel == null:
return null
local lx = 0
local ly = 0
local lz = 0
local step = 1
match sel.kind:
"box", "ramp":
lx = (sel.from[0] + sel.size[0] * 0.5) * m_unit
ly = (sel.from[1] + sel.size[1] * 0.5) * m_unit
lz = (sel.from[2] + sel.size[2] * 0.5) * m_unit
step = 1
else:
lx = sel.center[0] * m_unit
ly = sel.center[1] * m_unit
lz = sel.center[2] * m_unit
step = 0.5
local sc = clamp(frame.scale, 0.05, 8)
local sx = lx * sc
local sy = ly * sc
local sz = lz * sc
local tc = cos(frame.pitch)
local ts = sin(frame.pitch)
local rx = sx * tc + sz * ts
local rz = -sx * ts + sz * tc
local c = cos(frame.angle)
local s = sin(frame.angle)
local wx = frame.x + rx * c - sy * s
local wy = frame.y + rx * s + sy * c
local wz = frame.z + rz
local spec = {"mode": mode, "origin": [wx, wy, wz], "unit": m_unit, "step": step, "angle": frame.angle, "pitch": frame.pitch, "scale": sc, "size": 0.72}
return spec
func viewport_size(res):
local parts = res.split("x")
local w = clamp(to_number(parts[0], 1280), 120, 1920)
local h = clamp(to_number(parts[1], 800), 80, 1200)
local dims = {"w": w, "h": h}
return dims
action renderViewport:
if frames.length == 0:
stop
local sz = viewport_size(viewport_resolution)
local active_f = frames[active_frame_index]
local pose = {"x": active_f.x, "y": active_f.y, "z": active_f.z, "angle": active_f.angle, "pitch": active_f.pitch, "scale": active_f.scale, "dissolve": active_f.dissolve}
local models = []
if show_onion_skin and !is_playing and frames.length > 1:
local prev_idx = (active_frame_index - 1 + frames.length) % frames.length
local prev_f = frames[prev_idx]
local ghost_pose = {"x": prev_f.x, "y": prev_f.y, "z": prev_f.z, "angle": prev_f.angle, "pitch": prev_f.pitch, "scale": prev_f.scale, "dissolve": 0.72}
local ghost_model = build_model_spec(prev_f, palette, unit, 0, -1, false, ghost_pose)
models = models.concat([ghost_model])
local main_model = build_model_spec(active_f, palette, unit, contact_shadow, selected_primitive_id, true, pose)
models = models.concat([main_model])
local gizmo = is_playing ? null : build_gizmo_spec(active_f, selected_primitive_id, unit, tool_mode)
local place_prev = null
if !is_playing and tool_mode == "place":
place_prev = {"kind": place_kind, "size": [2, 2, 2], "radius": 1.5, "height": 3, "unit": unit, "model_x": active_f.x, "model_y": active_f.y, "model_z": active_f.z, "model_angle": active_f.angle, "model_pitch": active_f.pitch, "model_scale": active_f.scale}
local clip_tag = active_clip_name != "" ? (" · " + active_clip_name) : ""
local hud_text = "Yaw " + round(camera_yaw) + "° · Pitch " + round(camera_pitch) + "° · Zoom " + round_to(camera_zoom, 1) + clip_tag + " · Frame " + (active_frame_index + 1) + "/" + frames.length
local scene = {"width": sz.w, "height": sz.h, "camera": {"yaw": camera_yaw, "pitch": camera_pitch, "zoom": camera_zoom, "target_z": 0.85}, "grid": show_grid, "axes": show_axes, "glow": show_glow, "hud": hud_text, "gizmo": gizmo, "place_preview": place_prev, "models": models}
pixel3d.draw("main", scene)
action tickPlayback:
if frames.length == 0:
stop
if !is_playing and !turntable:
stop
local sz = viewport_size(viewport_resolution)
local cur_yaw = camera_yaw
if turntable:
local spin_sec = (now() - spin_start_ms) / 1000
cur_yaw = ((camera_yaw + spin_sec * 36 + 540) % 360) - 180
local frame_idx = active_frame_index
local active_f = frames[active_frame_index]
local pose = {"x": active_f.x, "y": active_f.y, "z": active_f.z, "angle": active_f.angle, "pitch": active_f.pitch, "scale": active_f.scale, "dissolve": active_f.dissolve}
if is_playing:
local elapsed = (now() - play_start_ms) / 1000
local sampled = sample_animation(frames, elapsed, fps, playback_mode, interpolate_transforms)
frame_idx = sampled.frame_index
active_f = frames[frame_idx]
pose = sampled
local sel_id = is_playing ? -1 : selected_primitive_id
local main_model = build_model_spec(active_f, palette, unit, contact_shadow, sel_id, true, pose)
local clip_tag = active_clip_name != "" ? (" · " + active_clip_name) : ""
local hud_text = "Yaw " + round(cur_yaw) + "° · Pitch " + round(camera_pitch) + "° · Zoom " + round_to(camera_zoom, 1) + clip_tag + " · Frame " + (frame_idx + 1) + "/" + frames.length
local scene = {"width": sz.w, "height": sz.h, "camera": {"yaw": cur_yaw, "pitch": camera_pitch, "zoom": camera_zoom, "target_z": 0.85}, "grid": show_grid, "axes": show_axes, "glow": show_glow, "hud": hud_text, "models": [main_model]}
pixel3d.draw("main", scene)
action syncPlaybackTimer:
if is_playing or turntable:
start-timer tickPlayback 33ms
if !is_playing and !turntable:
stop-timer
@Style/model_studio
tokens:
neon_cyan = #00e5ff
neon_lime = #39ff14
neon_pink = #ff2a85
neon_amber = #ffaa00
chassis_bg = #080b16
rack_bg = #0d1224
card_bg = #121830
elevated_bg = #182140
grid_border = #202b48
text_main = #ecf4ff
text_muted = #9aaac0
rules:
*:
box-sizing = border-box
body:
margin = 0
padding = 8px
background = {chassis_bg}
color = {text_main}
font-family = system-ui, -apple-system, sans-serif
.model-studio-cabinet:
background = {chassis_bg}
color = {text_main}
padding = clamp(0.5rem, 1.3vw, 1.1rem)
border-radius = 12px
border = 1px solid {grid_border}
max-width = 1520px
margin = 0 auto
width = 100%
display = grid
gap = 0.65rem
.ms-header:
display = flex
justify-content = space-between
align-items = center
flex-wrap = wrap
gap = 0.7rem
.ms-brand:
display = flex
align-items = center
gap = 0.5rem
.ms-title:
color = #e7f3ff
font-size = 1.02rem
font-weight = 800
letter-spacing = 2px
margin = 0
.ms-badge:
font-size = 0.65rem
font-weight = 800
letter-spacing = 1.4px
padding = 0.18rem 0.45rem
border-radius = 999px
background = #0d2a3d
border = 1px solid {neon_cyan}
color = {neon_cyan}
.ms-status:
flex = 1
min-width = 200px
margin = 0
font-size = 0.78rem
color = {text_muted}
.ms-header-actions:
display = flex
align-items = center
gap = 0.4rem
.ms-btn-ghost, .ms-btn-fullscreen, .ms-btn-storage, .ms-btn-sm, .ms-btn-xs, .ms-pill, .ms-nudge, .ms-btn-icon, .ms-btn-play, .ms-btn-pause:
font-family = inherit
border-radius = 6px
cursor = pointer
transition = all 0.14s ease
touch-action = manipulation
.ms-btn-ghost:
padding = 0.36rem 0.65rem
font-size = 0.74rem
font-weight = 600
background = {card_bg}
border = 1px solid {grid_border}
color = {text_main}
.ms-btn-ghost:hover:not(:disabled):
border-color = {neon_cyan}
color = {neon_cyan}
.ms-btn-ghost:disabled:
opacity = 0.4
cursor = default
.ms-btn-fullscreen:
padding = 0.36rem 0.8rem
font-size = 0.74rem
font-weight = 700
letter-spacing = 0.8px
background = {card_bg}
border = 1px solid {neon_cyan}
color = {neon_cyan}
.ms-btn-fullscreen:hover:
background = {neon_cyan}
color = #03101a
box-shadow = 0 0 12px {neon_cyan}
.ms-project-bar:
display = flex
justify-content = space-between
align-items = center
flex-wrap = wrap
gap = 0.6rem
padding = 0.55rem 0.75rem
background = {rack_bg}
border = 1px solid {grid_border}
border-radius = 9px
.ms-project-fields:
display = flex
align-items = center
flex-wrap = wrap
gap = 0.65rem
.ms-field-inline:
display = flex
align-items = center
gap = 0.4rem
.ms-label:
font-size = 0.68rem
font-weight = 700
text-transform = uppercase
letter-spacing = 0.8px
color = {text_muted}
.ms-input-text, .ms-input-id, .ms-input-sm, .ms-select, .ms-select-sm:
background = {chassis_bg}
color = {text_main}
border = 1px solid {grid_border}
border-radius = 6px
font-family = inherit
font-size = 0.8rem
padding = 0.34rem 0.55rem
.ms-input-text:
width = 180px
.ms-input-id:
width = 125px
font-family = ui-monospace, SFMono-Regular, monospace
color = {neon_cyan}
.ms-input-sm:
width = 100%
padding = 0.28rem 0.45rem
font-size = 0.76rem
.ms-select-sm:
padding = 0.24rem 0.4rem
font-size = 0.74rem
.ms-project-actions:
display = flex
align-items = center
flex-wrap = wrap
gap = 0.4rem
.ms-btn-storage:
padding = 0.38rem 0.72rem
font-size = 0.76rem
font-weight = 700
background = {card_bg}
border = 1px solid #30416b
color = {text_main}
.ms-btn-storage:hover:
border-color = {neon_cyan}
background = {elevated_bg}
.ms-btn-accent:
border-color = {neon_cyan}
color = {neon_cyan}
.ms-btn-export:
border-color = {neon_lime}
color = {neon_lime}
.ms-btn-export:hover:
background = {neon_lime}
color = #051408
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, canvas:focus-visible:
outline = 2px solid {neon_amber}
outline-offset = 2px
@Style/model_studio
rules:
.ms-timeline-panel:
background = {rack_bg}
border = 1px solid {grid_border}
border-radius = 9px
padding = 0.65rem
display = grid
gap = 0.55rem
.ms-clips-bar:
display = flex
align-items = center
justify-content = space-between
flex-wrap = wrap
gap = 0.45rem
padding = 0.4rem 0.5rem
border-radius = 7px
background = {chassis_bg}
border = 1px solid {grid_border}
.ms-clips-list, .ms-clip-controls:
display = flex
align-items = center
flex-wrap = wrap
gap = 0.32rem
.ms-clip-tab:
display = inline-flex
align-items = center
gap = 0.35rem
padding = 0.28rem 0.62rem
border-radius = 6px
background = {card_bg}
border = 1px solid {grid_border}
color = {text_main}
font-family = inherit
font-size = 0.74rem
font-weight = 700
cursor = pointer
.ms-clip-tab:hover:
border-color = #4c6aa8
.ms-clip-tab.active:
border-color = {neon_cyan}
background = #102542
color = {neon_cyan}
box-shadow = 0 0 10px #00e5ff22
.ms-clip-meta:
font-family = ui-monospace, SFMono-Regular, monospace
font-size = 0.65rem
color = {text_muted}
.ms-clip-tab.active .ms-clip-meta:
color = #9eefff
.ms-input-sm.ms-clip-input:
width = 132px
flex = 0 0 132px
.ms-clip-path:
font-family = ui-monospace, SFMono-Regular, monospace
font-size = 0.68rem
color = {text_muted}
padding = 0.2rem 0.45rem
border-radius = 5px
background = {rack_bg}
border = 1px solid {grid_border}
.ms-timeline-top:
display = flex
align-items = center
justify-content = space-between
flex-wrap = wrap
gap = 0.5rem
.ms-transport, .ms-fps-group, .ms-mode-group, .ms-frame-ops:
display = flex
align-items = center
flex-wrap = wrap
gap = 0.3rem
.ms-btn-play:
padding = 0.36rem 0.85rem
font-size = 0.78rem
font-weight = 800
background = #0c2e1c
border = 1px solid {neon_lime}
color = {neon_lime}
.ms-btn-play:hover:
background = {neon_lime}
color = #04140a
.ms-btn-pause:
padding = 0.36rem 0.85rem
font-size = 0.78rem
font-weight = 800
background = #33220a
border = 1px solid {neon_amber}
color = {neon_amber}
.ms-btn-icon:
width = 30px
height = 30px
background = {card_bg}
border = 1px solid {grid_border}
color = {text_main}
font-size = 0.9rem
font-weight = 700
.ms-btn-icon:hover:
border-color = {neon_cyan}
color = {neon_cyan}
.ms-fps-val:
min-width = 24px
text-align = center
font-family = ui-monospace, SFMono-Regular, monospace
font-size = 0.8rem
font-weight = 800
color = {neon_cyan}
.ms-frames-strip:
display = flex
align-items = stretch
gap = 0.4rem
overflow-x = auto
padding = 0.15rem 0
.ms-frame-card:
min-width = 112px
display = grid
gap = 0.15rem
text-align = left
padding = 0.45rem 0.6rem
border-radius = 7px
background = {card_bg}
border = 1px solid {grid_border}
color = {text_main}
font-family = inherit
cursor = pointer
.ms-frame-card:hover:
border-color = #4c6aa8
.ms-frame-card.active:
border-color = {neon_cyan}
background = #102542
box-shadow = 0 0 12px #00e5ff22
.ms-frame-num:
font-family = ui-monospace, SFMono-Regular, monospace
font-size = 0.68rem
font-weight = 800
color = {neon_cyan}
.ms-frame-name:
font-size = 0.78rem
font-weight = 700
white-space = nowrap
overflow = hidden
text-overflow = ellipsis
.ms-frame-meta:
font-size = 0.66rem
color = {text_muted}
.ms-transform-bar:
display = flex
align-items = center
flex-wrap = wrap
gap = 0.4rem
padding = 0.45rem 0.55rem
border-radius = 7px
background = {chassis_bg}
border = 1px solid {grid_border}
.ms-tf-label-cell:
display = flex
align-items = center
gap = 0.35rem
min-width = 145px
.ms-tf-pill:
display = flex
align-items = center
gap = 0.24rem
padding = 0.16rem 0.34rem
border-radius = 6px
background = {rack_bg}
border = 1px solid {grid_border}
.ms-tf-key:
font-size = 0.66rem
font-weight = 800
text-transform = uppercase
color = {text_muted}
padding-right = 0.15rem
.ms-tf-val:
min-width = 36px
text-align = center
font-family = ui-monospace, SFMono-Regular, monospace
font-size = 0.74rem
font-weight = 700
color = {text_main}
.ms-code-cabinet:
background = {rack_bg}
border = 1px solid {grid_border}
border-radius = 9px
overflow = hidden
.ms-tab-bar:
display = flex
border-bottom = 1px solid {grid_border}
background = {chassis_bg}
.ms-tab-btn:
padding = 0.52rem 0.95rem
font-family = inherit
font-size = 0.76rem
font-weight = 700
background = transparent
border = none
border-bottom = 2px solid transparent
color = {text_muted}
cursor = pointer
.ms-tab-btn.active:
color = {neon_cyan}
border-bottom-color = {neon_cyan}
background = {rack_bg}
.ms-tab-body:
padding = 0.65rem
display = grid
gap = 0.5rem
.ms-code-toolbar:
display = flex
justify-content = space-between
align-items = center
flex-wrap = wrap
gap = 0.5rem
.ms-check-inline:
display = flex
align-items = center
gap = 0.4rem
font-size = 0.76rem
color = {text_muted}
cursor = pointer
.ms-code-actions:
display = flex
gap = 0.38rem
.ms-code-preview:
margin = 0
padding = 0.75rem
border-radius = 7px
background = #050812
border = 1px solid {grid_border}
color = #b5f2ff
font-family = ui-monospace, SFMono-Regular, Menlo, monospace
font-size = 0.74rem
line-height = 1.48
max-height = 290px
overflow = auto
white-space = pre
.ms-import-box:
display = grid
gap = 0.5rem
.ms-import-hint:
margin = 0
font-size = 0.76rem
color = {text_muted}
.ms-import-textarea:
width = 100%
padding = 0.65rem
border-radius = 7px
background = #050812
border = 1px solid {grid_border}
color = {text_main}
font-family = ui-monospace, SFMono-Regular, Menlo, monospace
font-size = 0.76rem
line-height = 1.45
resize = vertical
.ms-import-actions:
display = flex
justify-content = flex-end
@Style/model_studio
rules:
.model-workspace:
display = grid
grid-template-columns = 230px minmax(300px, 1fr) 265px
gap = 0.65rem
align-items = start
.ms-panel:
background = {rack_bg}
border = 1px solid {grid_border}
border-radius = 9px
padding = 0.65rem
display = grid
gap = 0.7rem
min-width = 0
.ms-section:
display = grid
gap = 0.45rem
min-width = 0
.ms-section-head:
display = flex
justify-content = space-between
align-items = center
gap = 0.4rem
.ms-panel-title:
margin = 0
font-size = 0.72rem
font-weight = 800
letter-spacing = 1.1px
text-transform = uppercase
color = #b8cbe6
.ms-count:
font-size = 0.7rem
font-weight = 700
color = {neon_cyan}
font-variant-numeric = tabular-nums
.ms-prim-grid:
display = grid
grid-template-columns = repeat(2, 1fr)
gap = 0.38rem
.ms-prim-btn:
display = flex
align-items = center
justify-content = center
gap = 0.35rem
padding = 0.45rem 0.5rem
border-radius = 7px
border = 1px solid #2b3a60
background = {card_bg}
color = {text_main}
font-family = inherit
font-size = 0.76rem
font-weight = 700
cursor = pointer
.ms-prim-btn:hover:
border-color = {neon_cyan}
background = {elevated_bg}
color = {neon_cyan}
.ms-prim-icon:
color = {neon_cyan}
font-size = 0.9rem
.ms-setting-row:
display = flex
justify-content = space-between
align-items = center
gap = 0.45rem
.ms-setting-label:
font-size = 0.74rem
color = {text_muted}
.ms-palette-list:
display = grid
grid-template-columns = minmax(0, 1fr)
gap = 0.3rem
max-height = 240px
overflow-y = auto
overflow-x = hidden
min-width = 0
.ms-swatch-row:
display = grid
grid-template-columns = 1fr 28px 26px 24px
align-items = center
gap = 0.26rem
padding = 0.22rem
border-radius = 6px
background = {card_bg}
border = 1px solid transparent
.ms-swatch-row.active:
border-color = {neon_cyan}
background = {elevated_bg}
.ms-swatch-pick:
display = flex
align-items = center
gap = 0.36rem
background = transparent
border = none
color = {text_main}
padding = 0.14rem 0.2rem
text-align = left
cursor = pointer
font-family = inherit
font-size = 0.74rem
min-width = 0
.ms-swatch-dot:
width = 14px
height = 14px
border-radius = 4px
border = 1px solid #ffffff33
flex-shrink = 0
.ms-swatch-sym:
font-family = ui-monospace, SFMono-Regular, monospace
font-weight = 800
color = {neon_amber}
.ms-swatch-hex:
font-family = ui-monospace, SFMono-Regular, monospace
font-size = 0.68rem
color = {text_muted}
overflow = hidden
text-overflow = ellipsis
.ms-color-input:
width = 26px
height = 24px
padding = 0
border = 1px solid {grid_border}
border-radius = 4px
background = transparent
cursor = pointer
.ms-glow-btn, .ms-del-btn, .ms-mini-btn:
height = 24px
border-radius = 4px
border = 1px solid {grid_border}
background = {chassis_bg}
color = {text_muted}
font-size = 0.72rem
cursor = pointer
padding = 0 0.25rem
.ms-glow-btn.on:
border-color = {neon_amber}
color = {neon_amber}
background = #2a210c
box-shadow = 0 0 8px #ffaa0055
.ms-del-btn:hover, .ms-mini-btn.danger:hover:
border-color = {neon_pink}
color = {neon_pink}
.ms-add-color-row:
display = flex
align-items = center
gap = 0.4rem
margin-top = 0.2rem
.ms-btn-add-color:
flex = 1
.ms-viewport-panel:
background = {rack_bg}
border = 1px solid {grid_border}
border-radius = 9px
padding = 0.55rem
display = grid
gap = 0.45rem
min-width = 0
.ms-toolbox-bar:
display = flex
justify-content = space-between
align-items = center
flex-wrap = wrap
gap = 0.45rem
padding = 0.34rem 0.42rem
border-radius = 7px
background = #0a0f1e
border = 1px solid {grid_border}
.ms-toolbox-modes, .ms-toolbox-context:
display = flex
align-items = center
flex-wrap = wrap
gap = 0.28rem
.ms-tool-btn:
display = inline-flex
align-items = center
gap = 0.3rem
padding = 0.28rem 0.56rem
border-radius = 6px
border = 1px solid #243154
background = {card_bg}
color = {text_muted}
font-family = inherit
font-size = 0.74rem
font-weight = 700
cursor = pointer
.ms-tool-btn:hover:
border-color = {neon_cyan}
color = {text_main}
background = {elevated_bg}
.ms-tool-btn.active:
background = #0c2b40
border-color = {neon_cyan}
color = {neon_cyan}
box-shadow = 0 0 10px #00e5ff33
.ms-tool-btn.danger.active:
background = #361024
border-color = {neon_pink}
color = {neon_pink}
box-shadow = 0 0 10px #ff2a8533
.ms-tool-icon:
font-size = 0.88rem
line-height = 1
.ms-tool-lbl:
letter-spacing = 0.3px
.ms-gizmo-legend, .ms-paint-chip:
display = inline-flex
align-items = center
gap = 0.32rem
padding = 0.18rem 0.46rem
border-radius = 5px
background = {card_bg}
border = 1px solid {grid_border}
font-size = 0.7rem
font-weight = 700
color = {text_muted}
.ms-gizmo-tip:
margin-left = 0.12rem
color = {text_muted}
font-weight = 600
.ms-viewport-toolbar:
display = flex
justify-content = space-between
align-items = center
flex-wrap = wrap
gap = 0.4rem
.ms-cam-presets, .ms-view-toggles:
display = flex
align-items = center
flex-wrap = wrap
gap = 0.28rem
.ms-pill:
padding = 0.24rem 0.5rem
font-size = 0.72rem
font-weight = 700
background = {card_bg}
border = 1px solid {grid_border}
color = {text_muted}
.ms-pill:hover:
border-color = {neon_cyan}
color = {text_main}
.ms-pill.active:
background = #0c273b
border-color = {neon_cyan}
color = {neon_cyan}
.ms-canvas-stage:
position = relative
border-radius = 8px
overflow = hidden
border = 1px solid #28375a
background = #090d16
.ms-viewport-canvas:
display = block
width = 100%
height = auto
aspect-ratio = 16 / 10
image-rendering = pixelated
cursor = grab
touch-action = none
.ms-viewport-canvas:active:
cursor = grabbing
.ms-viewport-hud:
display = flex
justify-content = space-between
align-items = center
flex-wrap = wrap
gap = 0.4rem
padding = 0.36rem 0.6rem
background = #0a0f1e
border-top = 1px solid {grid_border}
font-size = 0.7rem
.ms-hud-readout:
font-family = ui-monospace, SFMono-Regular, monospace
color = {neon_cyan}
.ms-hud-hint:
color = {text_muted}
.ms-parts-list:
display = grid
grid-template-columns = minmax(0, 1fr)
gap = 0.24rem
max-height = 175px
overflow-y = auto
overflow-x = hidden
min-width = 0
.ms-part-item:
display = flex
align-items = center
justify-content = space-between
gap = 0.25rem
padding = 0.18rem 0.25rem
border-radius = 6px
background = {card_bg}
border = 1px solid transparent
min-width = 0
max-width = 100%
overflow = hidden
.ms-part-item.selected:
border-color = {neon_amber}
background = {elevated_bg}
.ms-part-select:
flex = 1
display = flex
align-items = center
gap = 0.38rem
background = transparent
border = none
color = {text_main}
font-family = inherit
font-size = 0.74rem
text-align = left
cursor = pointer
min-width = 0
overflow = hidden
.ms-part-dot:
width = 10px
height = 10px
border-radius = 3px
flex-shrink = 0
.ms-part-name:
flex = 1
min-width = 0
overflow = hidden
text-overflow = ellipsis
white-space = nowrap
.ms-part-meta:
font-size = 0.64rem
text-transform = uppercase
color = {text_muted}
flex-shrink = 0
.ms-part-quick:
display = flex
gap = 0.2rem
flex-shrink = 0
.ms-prop-section:
border-top = 1px solid {grid_border}
padding-top = 0.55rem
.ms-prop-actions:
display = flex
gap = 0.25rem
.ms-btn-sm:
padding = 0.3rem 0.55rem
font-size = 0.72rem
font-weight = 700
background = {card_bg}
border = 1px solid #2f4068
color = {text_main}
.ms-btn-sm:hover:
border-color = {neon_cyan}
.ms-btn-sm.danger:hover:
border-color = {neon_pink}
color = {neon_pink}
.ms-btn-xs:
padding = 0.18rem 0.42rem
font-size = 0.68rem
font-weight = 700
background = {card_bg}
border = 1px solid {grid_border}
color = {text_main}
.ms-btn-xs:hover:
border-color = {neon_cyan}
color = {neon_cyan}
.ms-kind-row:
display = grid
grid-template-columns = repeat(4, 1fr)
gap = 0.24rem
.ms-prop-name-row:
display = grid
grid-template-columns = 44px 1fr
align-items = center
gap = 0.35rem
.ms-prop-lbl:
font-size = 0.7rem
color = {text_muted}
.ms-vec-group:
display = grid
gap = 0.26rem
padding = 0.4rem
border-radius = 7px
background = {chassis_bg}
border = 1px solid {grid_border}
.ms-vec-title:
font-size = 0.66rem
font-weight = 700
text-transform = uppercase
letter-spacing = 0.7px
color = {text_muted}
.ms-axis-row:
display = grid
grid-template-columns = 24px 28px 1fr 28px
align-items = center
gap = 0.25rem
.ms-axis-tag:
font-size = 0.68rem
font-weight = 800
text-align = center
color = {neon_amber}
.ms-axis-tag.ax-x, .ms-gizmo-legend .ax-x:
color = #ff6b7a
.ms-axis-tag.ax-y, .ms-gizmo-legend .ax-y:
color = #4be681
.ms-axis-tag.ax-z, .ms-gizmo-legend .ax-z:
color = #42ccff
.ms-axis-val:
text-align = center
font-family = ui-monospace, SFMono-Regular, monospace
font-size = 0.78rem
font-weight = 700
font-variant-numeric = tabular-nums
.ms-nudge:
height = 24px
background = {card_bg}
border = 1px solid #2e3e66
color = {text_main}
font-size = 0.82rem
font-weight = 700
padding = 0
.ms-nudge:hover:
border-color = {neon_cyan}
color = {neon_cyan}
@media (max-width: 1020px):
.model-workspace:
grid-template-columns = 1fr
Usa la barra 3D (Select, Move, Resize, Place, Paint, Erase) para esculpir piezas, cambia entre clips (Idle, Walk, Slash) en la barra Clips y pulsa Play.
Renderiza los modelos con el trazador analítico Pixel 3D de Vectrune, con sombreado curvo, brillo emisivo, sombras de contacto, papel cebolla y gizmos 3D para mover o redimensionar.
Combina bloques enteros con esferas, cilindros y rampas, edita colores @Palette en vivo, activa el brillo emisivo y duplica piezas en espejo.
Crea múltiples clips @Animation/<modelo>/<clip> por modelo (idle, walk, slash) con transformaciones por fotograma, interpolación y modos Loop, Ping-Pong u Once.
Guarda proyectos en este navegador (compartidos con la pestaña independiente), pega código @Palette, @Model y @Animation y exporta archivos .rune formateados con geometría deduplicada.
Elige un preajuste o pulsa New Model. Cambia de herramienta con las teclas 1–6, arrastra los ejes 3D para mover o escalar piezas y activa ✦ en una muestra para darle brillo emisivo.
Usa la barra Clips para cambiar o crear clips @Animation, copia y pega poses entre clips, ajusta Z, ángulo, inclinación, escala o disolución y descarga tu archivo .rune.
Para ejecutar el ejemplo completo, instala Vectrune y Git. Clona el repositorio una vez y conserva la carpeta parts junto al archivo principal.
Inicio rápidogit clone https://github.com/davethomas11/vectrune.git
cd vectruneEjecuta estos comandos desde la raíz del repositorio. Si ya tienes una copia, abre una terminal en su raíz y omite la clonación.
vectrune examples/rune-web/model_studio/model_studio.rune
vectrune examples/rune-web/model_studio/model_studio.rune -o html > model_studio.html