makepad/libs/model/SELECTION_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

52 lines
3 KiB
Markdown

# Named selections and geometric queries
Use these objects inside `model.apply.operations`, with the normal exact expected
head and request ID. Every operation supplies `object` and `name`. No viewport
state is used. At most128 named groups persist in a document; source/history
preserve them. IDs are canonical decimal strings. Queries inspect the editable
base mesh: make an instance unique or bake its modifiers before querying derived
geometry. Query positions explicitly choose local or world space.
`selection`: `vertices:[ID...]`, `faces:[ID...]` sets a group; both arrays required,
empty allowed. Every ID must exist; duplicates are normalized and sorted.
`select`: `element:"vertices"|"faces"`, `min:integer`, `max:integer`, `query:{...}`.
The selected element count must lie in the inclusive requested range. The result
and saved group include both vertex and face selections. Supported queries:
- `{kind:"all"}`: all base vertices and faces.
- `{kind:"material",material:integer}`: faces with that material and their vertices.
- `{kind:"bounds",min:XYZ,max:XYZ,space:"local"|"world"}`: vertices within the box;
a face is included when every corner lies inside.
- `{kind:"connected",face:ID,stop_seams:boolean}`: edge-connected face component;
optional UV-seam barriers. Includes those faces' vertices.
- `{kind:"loop"|"ring",edge:[vertexID,vertexID]}`: a quad ring crosses opposite
face edges; a loop crosses valence-four vertices through nonadjacent edges and
stops at poles/boundaries. Returns visited edge vertices and incident faces.
- `{kind:"ray",origin:XYZ,direction:XYZ,space:"local"|"world"}`: closest positive
triangle hit, deterministic face-ID tie break. No hit is empty. Use min=1,max=1
to require a hit. Direction must be nonzero; both face orientations are pickable.
`use_selection`: `element:"vertices"|"faces"|"face"`, `operation:{op,...}` fills the
selected field and object into one ordinary mesh operation. The template must
omit object and that selected field. `face` requires exactly one face; array
selections must be nonempty. Recursive selection/control/global operations are
refused. The entire surrounding transaction remains atomic and cancellable.
Example (plus document/request_id/expected envelope):
```json
{"operations":[
{"op":"select","object":"body","name":"roof","element":"vertices","min":4,"max":64,
"query":{"kind":"bounds","min":[-2,0.5,-2],"max":[2,3,2],"space":"local"}},
{"op":"use_selection","object":"body","name":"roof","element":"vertices",
"operation":{"op":"transform","matrix":[[1,0,0,0],[0,1,0,0.2],[0,0,1,0],[0,0,0,1]]}}
]}
```
Groups retain identity-based membership when positions/materials change. Losing
any selected element marks the group **stale**; subsequent use refuses it until
explicitly replaced or queried again. Deleting its object removes its groups.
`delete_selection` removes one named group. Inspect `selections`,
`selection_vertices`, and `selection_faces` with optional object and the normal
bounded offset/limit cursor. Operation outputs return the stable selections too.