threejs-procedural-motion-systems

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Procedural Motion Systems

程序化运动系统

Semantic state is the source of truth; transforms are its presentation. Keep one writer for each position, orientation, velocity, phase, and event channel.
语义状态是事实来源;变换是其呈现形式。为每个位置、方向、速度、相位和事件通道保留一个写入器。

Process

流程

1. Declare state and its writer

1. 声明状态及其写入器

Name the observable motion, SI units, coordinate frame, stable actor identity, initial state, phase/event state, and duration contract: finite with a terminal pose plus velocity/hand-off rule, periodic with a wrap rule, or open-ended with a stop/reset policy. Assign one writer to every animated channel; clips, procedural roots, instance storage, camera rigs, and external solvers may own different channels only through an explicit layering order.
When another simulation supplies or reacts to motion, declare:
  • exchanged quantities, units, frame/origin, state owner, producer, consumers, version, and publication order;
  • timestamp or half-open interval, cadence, sample phase, interpolation or extrapolation, and discontinuity behavior;
  • support/filter, validity, staleness, error bound, and missing-value behavior;
  • rate versus interval-integrated semantics and one-way or two-way reaction ownership and order;
  • GPU producer/consumer passes, resource generation, queue order, and actual completion evidence;
  • immutable previous/current committed samples, stable identity, and reset, reuse, retirement, and disposal rules.
Keep frame-critical state on its owning device; schedule diagnostic readback asynchronously outside state advance and presentation.
Complete when: every animated channel has exactly one writer, one frame and unit convention, one stable identity, and a defined initial state plus finite, periodic, or open-ended duration contract; every cross-system boundary closes every applicable declaration above.
为可观测运动命名,明确国际单位制(SI)单位、坐标系、稳定角色标识、初始状态、相位/事件状态,以及时长约定:包含终端姿态加速度/交接规则的有限时长、包含循环规则的周期性时长,或包含停止/重置策略的开放式时长。为每个动画通道分配一个写入器;片段、程序化根节点、实例存储、相机控制 rig 和外部求解器仅可通过显式分层顺序拥有不同通道。
当另一个仿真提供或响应运动时,需声明:
  • 交换量、单位、框架/原点、状态所有者、生产者、消费者、版本和发布顺序;
  • 时间戳或半开区间、节奏、采样相位、插值或外推,以及不连续行为;
  • 支持/过滤、有效性、过期性、误差范围,以及缺失值处理方式;
  • 速率与区间积分语义,以及单向或双向响应的所有权与顺序;
  • GPU 生产者/消费者传递、资源生成、队列顺序,以及实际完成证据;
  • 不可变的前/当前提交样本、稳定标识,以及重置、重用、停用和处置规则。
将帧关键状态保留在其所属设备上;在状态推进和呈现之外异步安排诊断回读。
完成标志: 每个动画通道都有且仅有一个写入器、一套框架和单位约定、一个稳定标识,以及定义好的初始状态加有限、周期性或开放式时长约定;每个跨系统边界都完成上述所有适用声明。

2. Choose the time model and representation

2. 选择时间模型与表示方式

Choose by state dependence first, then actor count:
MotionTime modelRepresentation
Seekable authored transformclosed form at authoritative seconds
Object3D
for a few actors; vertex TSL for many
Phased authored sequenceclosed form plus discrete event statephase-local time and a replayable event log
Spring, constraint, collision, or other recurrent statefixed step with previous/current stateCPU arrays or GPU storage selected by measured crossover
Perceptual follow
dt
-correct exponential response
render-time state, explicitly non-physical
Use
InstancedMesh
for repeated identical topology. Use
BatchedMesh
for varied topology with compatible material state. Use storage and compute only when the measured CPU traversal/upload crossover is passed.
The canonical path initializes
WebGPURenderer
from
three/webgpu
with
await renderer.init()
and verifies
renderer.backend.isWebGPUBackend === true
.
Complete when: each motion branch has one time model and one representation, and each GPU route states the measured workload threshold that justifies it.
优先根据状态依赖选择,再根据角色数量选择:
运动类型时间模型表示方式
可跳转的预设变换基于权威时间秒数的闭合形式少量角色使用
Object3D
;大量角色使用顶点TSL
分阶段预设序列闭合形式加离散事件状态阶段本地时间与可重放事件日志
弹簧、约束、碰撞或其他循环状态包含前/当前状态的固定步长根据实测交叉点选择CPU数组或GPU存储
感知式跟随修正
dt
的指数响应
渲染时状态,明确为非物理效果
重复相同拓扑结构时使用
InstancedMesh
。拓扑结构多样但材质状态兼容时使用
BatchedMesh
。仅当实测CPU遍历/上传交叉点被突破时,才使用存储与计算。
标准流程是从
three/webgpu
初始化
WebGPURenderer
,执行
await renderer.init()
并验证
renderer.backend.isWebGPUBackend === true
。
完成标志: 每个运动分支都有一个时间模型和一种表示方式,且每条GPU路线都说明证明其合理性的实测工作负载阈值。

3. Make time deterministic

3. 实现时间确定性

Sample analytic motion directly from authoritative elapsed seconds. Advance recurrent state by a fixed step, retain immutable previous/current states, and move every complete unprocessed step into separate debt state so
0 <= accumulator < fixedStep
before presenting with
alpha = accumulator / fixedStep
. Define raw-delta clamping, maximum substeps, debt handling, pause/resume, and replay behavior once for the whole motion owner. A debt drop or scheduled catch-up and a discontinuity reset are separate decisions. Coupled state advances on its simulation owner's cadence, not the render callback's cadence.
For perceptual follow, declare the target as a continuous function integrated over the interval, a timestamped zero-order hold, or timestamped interpolated samples. Apply changes at their timestamps; presentation cadence never changes the underlying target signal.
Use stored seeds, counters, and one-shot event flags. A direct seek reconstructs the same phase and event state as replay to that time.
AnimationMixer
either updates at the fixed step or uses
setTime()
for seeking; it does not sample an independent clock.
Complete when: analytic and recurrent clocks cannot diverge after a stall, the interpolation pair brackets presentation time with a bounded accumulator, debt and reset decisions are independently observable, and identical initial state plus every applicable seed, fixed step, event schedule, and target signal reproduce the same matched-time state at every tested presentation cadence.
直接从权威流逝时间采样解析运动。以固定步长推进循环状态,保留不可变的前/当前状态,并将所有未处理的完整步长转移到单独的延迟状态,以便在呈现前确保
0 <= accumulator < fixedStep
,并使用
alpha = accumulator / fixedStep
。为整个运动所有者一次性定义原始增量钳制、最大子步数、延迟处理、暂停/恢复和重放行为。延迟消除或计划追赶与不连续重置是独立决策。耦合状态按其仿真所有者的节奏推进,而非渲染回调的节奏。
对于感知式跟随,将目标声明为区间上积分的连续函数、带时间戳的零阶保持,或带时间戳的插值样本。在其时间戳处应用更改;呈现节奏永远不会改变底层目标信号。
使用存储的种子、计数器和一次性事件标志。直接跳转应重建与重放到该时间点相同的相位和事件状态。
AnimationMixer
要么以固定步长更新,要么使用
setTime()
进行跳转;它不会采样独立时钟。
完成标志: 解析和循环时钟在停滞之后不会偏离,插值对以有界累加器包围呈现时间,延迟和重置决策可独立观测,且相同的初始状态加上所有适用的种子、固定步长、事件计划和目标信号,在每个测试的呈现节奏下都能重现相同的匹配时间状态。

4. Implement frame-safe transforms

4. 实现帧安全变换

Name source and destination frames for every position, direction, velocity, and quaternion. Normalize axes, handle parallel and antiparallel vector alignment, canonicalize quaternion signs before interpolation, state multiplication order, and normalize accumulated rotations.
Preserve world pose during reparenting with
M_local_new = inverse(M_world_newParent) * M_world_old
. Decompose to TRS only when the residual passes; retain an affine matrix or wrapper when non-uniform ancestry creates shear. Released children inherit moving-frame velocity, including
omega cross r
for a rotating parent. Docking error is decomposed in the current docking frame, not a stale world frame.
Complete when: every transform has a declared frame chain and quaternion order, reparenting preserves the world matrix within tolerance, zero/antiparallel inputs stay finite, and moving-frame release includes all transport terms.
为每个位置、方向、速度和四元数命名源框架和目标框架。归一化轴,处理平行和反平行向量对齐,在插值前规范化四元数符号,声明乘法顺序,并归一化累积旋转。
重父化期间使用
M_local_new = inverse(M_world_newParent) * M_world_old
保留世界姿态。仅当残差通过时才分解为TRS;当非均匀祖先产生切变时,保留仿射矩阵或包装器。释放的子对象继承运动框架的速度,包括旋转父对象的
omega cross r
。对接误差在当前对接框架中分解,而非过时的世界框架。
完成标志: 每个变换都有声明的框架链和四元数顺序,重父化在容差范围内保留世界矩阵,零/反平行输入保持有限,运动框架释放包含所有传输项。

5. Publish, reset, and dispose

5. 发布、重置与处置

Publish immutable previous/current pose generations with stable actor identity; derive render pose, motion vectors, bounds, shadows, and temporal consumers from that same pair. A cut, teleport, spawn/despawn, reparent, topology or deformation change, LOD/quality change, storage-slot reuse, or identity change starts a new validity epoch and resets the affected history instead of deriving an extreme velocity.
Reset phase timestamps, accumulator and debt records, seed counters, event flags, finite terminal locks, and previous/current buffers together only for a semantic motion reset. A camera cut or other temporal-only reset clears the affected presentation history without restarting semantic motion. Disposal releases storage, compute resources, readback staging, listeners, timers, and the renderer loop owned by the system.
Complete when: every discontinuity selects preserve, migrate, or reset for each history consumer; temporal-only resets preserve semantic state; semantic resets restore the declared initial state atomically; no old identity can observe a reused slot; disposal leaves no live owner, listener, buffer, or animation loop.
发布带有稳定角色标识的不可变前/当前姿态版本;从同一对姿态派生渲染姿态、运动向量、边界、阴影和时间消费者。剪切、瞬移、生成/销毁、重父化、拓扑或变形更改、LOD/质量更改、存储槽重用或标识更改会启动新的有效性周期,并重置受影响的历史记录,而非推导极端速度。
仅在语义运动重置时,才一起重置相位时间戳、累加器和延迟记录、种子计数器、事件标志、有限终端锁,以及前/当前缓冲区。相机剪切或其他仅时间重置会清除受影响的呈现历史,但不会重启语义运动。处置会释放系统拥有的存储、计算资源、回读暂存区、监听器、计时器和渲染循环。
完成标志: 每个不连续点都会为每个历史消费者选择保留、迁移或重置;仅时间重置保留语义状态;语义重置原子性地恢复声明的初始状态;旧标识无法观测到重用的插槽;处置后没有剩余的活动所有者、监听器、缓冲区或动画循环。

6. Verify the invariants

6. 验证不变量

For each selected branch, run only its applicable checks. Analytic motion compares direct seek with replay at 30, 60, 120, and 240 Hz presentation. Recurrent motion holds one fixed-step schedule across those presentation rates and passes step-halving. Perceptual follow consumes one timestamped or analytically integrated target signal and compares shared wall-time checkpoints. Finite motion reaches its exact terminal pose and declared velocity or hand-off; only a terminal lock requires zero residual velocity. Periodic and open-ended motion verify their declared wrap or stop/reset transition.
Where selected, also check quaternion norm and sign continuity, world-matrix equality across reparenting, stable instance identity, and reset behavior for every discontinuity. GPU motion records dispatches, hot bytes, p50/p95 time, and zero frame-critical readbacks. Node post proves one presentation/output owner.
Complete when: every selected branch passes its cadence, ownership, frame, reset, lifecycle, and visible-failure checks, with thresholds and target hardware recorded where performance claims are made.
对于每个选定分支,仅运行其适用的检查。解析运动比较直接跳转与30、60、120和240 Hz呈现下的重放结果。循环运动在这些呈现速率下保持一个固定步长计划,并通过步长减半测试。感知式跟随使用一个带时间戳或解析积分的目标信号,并比较共享的 wall-time 检查点。有限运动到达其精确的终端姿态和声明的速度或交接状态;仅终端锁要求零残余速度。周期性和开放式运动验证其声明的循环或停止/重置过渡。
若选定,还需检查四元数范数和符号连续性、重父化后的世界矩阵一致性、稳定实例标识,以及每个不连续点的重置行为。GPU运动记录调度、热字节、p50/p95时间,以及零帧关键回读。节点后置验证存在一个呈现/输出所有者。
完成标志: 每个选定分支都通过其节奏、所有权、框架、重置、生命周期和可见故障检查,若有性能声明则记录阈值和目标硬件。

Conditional references

条件参考

  • For analytic interpolation, phase events, launch paths, detachment, or debris, read Analytic phases, launch, and stage release.
  • For recurrent timing, springs, replay,
    AnimationMixer
    , or terminal locks, read Time and state models.
  • For
    InstancedMesh
    ,
    BatchedMesh
    , storage attributes, TSL compute, or GPU completion, read r185 representation and GPU residency.
  • For docking frames, quaternion order, reparenting, or rotating-parent release, read Moving frames, docking, and quaternions.
  • For water-, terrain-, weather-, contact-, or solver-driven actors, read Environment-driven actors and apply the handoff requirements in step 1.
  • For temporal publication, reset scope, output ownership, disposal, or failure diagnosis, read Presentation, resets, output, and lifecycle and Failure signatures and verification.
  • 如需了解解析插值、相位事件、发射路径、分离或碎片,请阅读解析相位、发射和阶段释放。
  • 如需了解循环计时、弹簧、重放、
    AnimationMixer
    或终端锁,请阅读时间与状态模型。
  • 如需了解
    InstancedMesh
    、
    BatchedMesh
    、存储属性、TSL计算或GPU驻留,请阅读r185表示与GPU驻留。
  • 如需了解对接框架、四元数顺序、重父化或旋转父对象释放,请阅读运动框架、对接与四元数。
  • 如需了解水、地形、天气、接触或求解器驱动的角色,请阅读环境驱动角色并应用步骤1中的交接要求。
  • 如需了解时间发布、重置范围、输出所有权、处置或故障诊断,请阅读呈现、重置、输出与生命周期和故障特征与验证。

Routing boundary

路由边界

Use
$threejs-camera-controls-and-rigs
for camera motion and handoffs,
$threejs-particles-trails-and-effects
when pooled effects are the deliverable, and the relevant water or terrain skill for environment state. Use
$threejs-choose-skills
when the request spans motion plus rendering, geometry, materials, shadows, post, or another simulation.
相机运动与交接使用
$threejs-camera-controls-and-rigs
,池化效果作为交付物时使用
$threejs-particles-trails-and-effects
,环境状态使用相关的水或地形skill。当请求涵盖运动加渲染、几何、材质、阴影、后期处理或其他仿真时,使用
$threejs-choose-skills
。