Actor animation programs v23
本页目录
本文对应 1.21.10 现代框架。文档中的接口与配置按当前文档快照核对;完整框架仍在开发验收。接口可编译、配置可解析与游戏内效果验证分别记录。
Decision: ADR-035(源码配套资料). Implementation and validation status are recorded only in R4 actorProgramsSlice in delivery-tasks.json(源码配套资料).
Core contract
ModelAnimationProgram is a platform-free immutable value: an exact primary clip, at most 32 queued clips and at most four parallel clips. All referenced clips must exist and have finite positive duration. Each primary segment plays once except the final segment, which follows the command's loop flag. Parallel clips loop for the command lifetime. Layer order is primary, then parallel declaration order; a later authored translation, rotation or scale channel overrides that channel alone.
V1's pinned Gecko runtime traverses a HashMap of controllers. Overlapping channels must therefore be flagged during migration for an explicit mapping and equivalence check; declaration-order behavior cannot be assumed from the old source's registration order.
ModelClipController.playProgram uses the existing controller and pose instance, with the same speed, restart and transition parameters as single-clip playback. Non-restarting updates with the same primary identity preserve total elapsed time. Speed changes integrate the preceding interval at the preceding speed. Stop or one-shot expiry releases the command; subsequent ordinary-state updates restore state playback.
ModelPlayback.layers() reports immutable facts from the last successful sample. ModelClipController.commandLayers(now) projects current command layers without sampling or mutating the controller. Each fact identifies slot, queue segment, clip, elapsed seconds, clip duration and loop mode. commandState retains primary identity and reports total program duration/time; playbackState reports the actually sampled primary segment. Events using a program must use layer facts and command identity together.
External samplers opt into ModelAnimationSampler.sampleLayer. Core provides a fresh bounded writer per layer, validates values and commits the combined pose and transition atomically. Existing single-clip sample behavior is unchanged. The source backend supplies independently acknowledged expression sessions per layer; its owner must reserve memory before growing the layer count and release extra sessions on retirement.
Public command
ActorProgramCommand provides play(binding, ModelAnimationPlayback[, authoredEvents, events]), stop(binding), strict JSON parsing and defensive serialization. Consumers dispatch through ModelService.Owner.actorProgram; the optional ModelSyncSession.Port.actorProgram defaults to an explicit unsupported result on old ports. The separately negotiated capability is model_actor_programs_v23. Wire messages are actor_program and actor_program_receipt, using the existing ordered action stream and actionStatus query. Entity/player binding IDs resolve only within the caller's owner. Missing capability, uncommitted revision, unavailable resources or a full 16-command observer queue reject before allocating a sequence. New observers receive the model document, never historical programs.
Profiles declare the capability and call model:actor_program with the same command object. Data-driven substitutions do not replace the behavior instance. For example:
{
"operation": "play",
"binding": "body",
"playback": {
"clip": "wave", "queue": ["idle"], "parallel": ["sway"],
"loop": true, "speed": 1, "restart": true, "transitionTicks": 4,
"conflicts": []
},
"authoredEvents": true,
"events": { "idle": { "soundEvents": [] } }
}
Playback uses the existing ModelAnimationPlayback limits: speed 0.05–16, transition 0–200 ticks, queue 32, parallel 4, conflict names 32. A non-restarting command conflicting with the active primary (or its declared conflicts) returns conflict without replacing it. A restarting command explicitly replaces it. Stop accepts only operation and binding. v22 remains single-clip and keeps rejecting program fields. ModelPlan schema, canonical bytes and digests are unchanged.
Event policy and lifetime
authoredEvents defaults to false and is supported by BBModel/Bedrock source animation backends. Opting in on GLB is rejected. Each events entry names a clip actually referenced by the program and may override soundEvents and/or particleEvents. An absent channel inherits authored events only when opted in; an explicit empty array silences it. Null and unknown fields are rejected. There are at most 16 events per channel per clip and 512 resolved events in total. Explicit payloads use the existing event DTOs and tick timing; authored fractional-second timing, locators and source context are preserved. Unsupported authored timeline/time-warp shapes remain explicit errors.
All referenced clips, event intervals, particle nodes and native sound/particle resources are validated before playback replacement. Changing an active program's event policy without restart is rejected. Structural queue/layer edits preserve integrated time but do not replay events preceding the new layer positions. Each of at most five active layer cursors reads controller facts. A skipped primary interval traverses at most 33 segments; parallel/final loops retain the existing bounded latest-crossing policy (at most one occurrence per declared event per consume). Parallel events stop at the primary program's one-shot end. Retiring a segment or program releases its event owners, including outstanding tails and pending node emissions.
The adapter reserves candidate event-compilation and extra evaluator memory while retaining the previous program's reservation. Growth is admitted before allocation; failed clip/event/resource/sampling preparation keeps the accepted command, pose and variable state. Ordinary single-clip replacement, stop, one-shot expiry, actor unload, owner close, session clear and resource retirement release added layers/tracks and reservations. Each source layer has independent expression variables; the primary session remains the existing actor session. First-person/body/attachment consumers continue reading the same model instance.
After a successful pose commit and before event dispatch, the native adapter invalidates previously captured anchors, including those captured earlier in the same tick. Node events wait for a fresh capture of the accepted pose within the existing bounded grace interval. Failed candidates retain current anchors; first-command player events receive the confirmed native actor before dispatch.
Verification boundary
The native candidate now wires public transport, profile primitive, entity/player adapters and capability negotiation together. Independent v23 consumer/probe and neutral source resources exercise the real candidate; their result is recorded in the ledger, not inferred from compilation or the previous v22 regression. R4 remains incomplete while other parity tasks are open; migration, human acceptance and release have separate gates.