makepad/libs/model/SCENE_API.md
Admin d2130e6550 libs: model, mesh_edit, csg, scene, sim, render, xr
Squash of 25 work commits (Sep 1–12):
  237da90  render: the sprite lane hands the screen draw back the way it found it
  895b9a7  particles: an emitter can ride a body's own frame
  914471f  ai-hub: a feed session whose last socket left ends on its idle timeout; skin: parent, skinned centroid and a nodes-only rig for retargets
  3fcccf3  sim: the whole world is implicitly editable, and one seam says where the ground is
  5692fab  sim: the landform world proves itself — walker through the tunnel included
  f4af6df  sim: terrain knows who changed it — a plan layer over player history
  adbb078  render: a water volume can be physics without a picture
  c17480f  render: a non-rigid body may carry its own orientation
  acad401  sim: an agent with no route holds and retries instead of walking into the wall
  22b2bf9  sim + chat: the composed world surface takes a map floor; the chat gets plan tools
  faf8112  web path: the tessellator's lap timer, the trace span and the fusion cycle timer have no clock on the web
  d3472eb  tsdf: the clock-taking XR helpers are native-only — the browser has no depth camera and no Instant
  4946c9e  sim + render: a repaint is not a world edit — colour and glow restyles never rebake the lightmap
  4317f58  sim + render + chat: walk decks as a surface, the filmed body is no obstruction, the brief never asks
  9791279  render: support rigged models and custom materials across viewers
  3ce2792  sim: use deck geometry for collision and sensing
  c8b79ff  Add portable PBR, rig and soft-body authoring support
  108d423  Add transactional polygon modeling and editable asset documents
  38f4d3b  Refine editable modeling and firm yarn character behavior
  08a2637  sim: add entity-owned lights and vehicle headlights
  00d96a7  render: add clustered lights, local shadows and incremental GI
  cf916af  render: import glTF asset extensions and wire clustered GI
  c6d2cca  model: cut transaction memory and raise capacity limits
  41af47a  raytrace: add a CPU probe-ray BVH budget example
  c963d0a  libs: the game sim splits into makepad-scene and makepad-soft-body; render, model, fab and the asset importer retarget

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-15 13:40:31 +02:00

82 lines
5.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Object scene and ordered modifiers
All operations are transactional and require the expected document head.
Scene transforms use local TRS; attachments may target root, an object, or a joint.
`object_node` replaces the entire node; omitted parent/link fields become null
and omitted TRS components become zero translation, identity rotation and unit
scale. `dimensions` sets that node's scale from evaluated local mesh extents; it
does not resize source vertices. Place/rotate with `object_node` BEFORE calling
`dimensions`, or preserve the existing complete TRS when repositioning a sized
part. `model.inspect` domain `scene_nodes` exposes the current node transforms.
| op | Additional fields |
|---|---|
| object_node | object, node: {parent?, linked_to?, transform?} |
| instance | object, source, transform? |
| duplicate | object, source |
| make_unique | object; bakes evaluated linked geometry and clears applied modifiers |
| join | object: new name, sources: distinct object names |
| separate | object: source, name: new name, faces: ID strings |
| pivot | object, position: local XYZ; relocate origin while preserving geometry, child transforms, sockets and lights in world space |
| snap | object, grid: positive metres |
| dimensions | object, size: positive local XYZ extents |
| light | name, attachment, transform?, kind: point/spot, color: linear RGB, intensity: candela, range: metres; spot adds inner/outer cone radians |
| delete_light | name |
| socket | name, attachment, transform |
| delete_socket | name |
| vehicle_wheel | object, connection, pivot: local XYZ, radius, width; see VEHICLE_API.md |
| delete_vehicle_wheel | object |
| lods | object, levels: [{target_faces,max_error,distance}]; 1–4 levels, face counts decrease and distances increase |
| collider | object, kind: box/sphere/mesh; mesh adds source object |
A transform is {translation:XYZ, rotation:normalized XYZW, scale:nonzero XYZ}; omitted transform is identity. An attachment is null (root), {object:name}, or {joint:ordinal}. Point/spot lights are distinct emitters, not emissive materials. Counts are bounded to 32 emitters and 128 sockets. Spotlights shine along local -Z; rotate 180 degrees around Y for a +Z-facing headlight. Range is metres and intensity is candela. Parent/link/modifier cycles are refused.
`modifier` sets or replaces a named ordered entry:
```json
{"op":"modifier","object":"body","name":"copies","enabled":true,
"operation":{"op":"array","count":3,"offset":[2,0,0]}}
```
`enabled` defaults to true. Inner `object` may be omitted; if supplied it must
match the outer object. Each object allows 16 entries and a document allows 128.
Supported entries are subdivision, mirror, array, solidify, decimate, normals,
and deform/lattice/shrinkwrap with `vertices: []`. For a modifier, that empty
selection resolves all current evaluated vertices; an ordinary edit still
treats an empty selection as empty. Fixed element selections cannot be stored
in a stack because earlier modifiers may change topology.
Use `modifier_order {object,names:[...]}` with an exact permutation to reorder,
`remove_modifier {object,name}` to remove, and `apply_modifiers {object}` to bake
the evaluated result and clear the stack/link. A linked instance starts from its
source's evaluated mesh, then applies its own entries. Parent/link/enabled
modifier dependencies form one acyclic graph. Shared references use one immutable
cache per evaluation, and source cage meshes remain unchanged until baked.
Shrinkwrap references are evaluated once, then transformed by
`inverse(owner_world) * reference_world` into the owner's local coordinates.
Its offset and distance limit use that owner-local space.
`join` copies evaluated objects through their world transforms and preserves
UVs, weights, material IDs, split normals, seam/crease markers, and pins.
`separate` preserves those attributes and the selected element IDs in the new
object scope. Linked geometry and stacks must be made unique/baked before a
face selection is separated.
Exported LODs use hidden `MSFT_lod` geometry nodes and
`extras.MAKEPAD_lod_distances`. Sandbox prepares all variants on a worker and
selects one per instance by camera distance from the instance origin in world
metres. The runtime admits up to eight distinct thresholds across an asset;
all variants share one combined upload budget. Lower variants retain node IDs,
animation targets, material layers, and the skeleton. Collision and shadow
geometry use the highest-detail mesh; changing LOD does not change physics.
Hidden targets must be leaf geometry with the owner's skin, local transform,
and node weights. Shape keys must be baked/removed on objects whose LOD geometry
is generated, since decimation changes their vertex correspondence.
Pivot edits require unique geometry with its modifiers applied; shared sources
must first have their linked instances made unique. Morph deltas and vertex IDs
survive a pivot edit. LOD distances must be at most 1,000,000 metres; unreachable
reduction targets fail compilation with an explicit protected-topology error.
Box colliders require positive volume. Worker-cooked box, sphere and mesh
proxies provide collision independent of visual LOD.