Appearance
视线追踪主模块
系统概览
视线追踪主模块(ADR-071/162/166)。调度 JS/WASM 两种视线追踪实现,提供统一的视线配置接口。两路径均可用,按运行时类型自动分支(非"按性能切换")。
核心职责
perception-gaze.ts— 视线追踪调度入口_applyGaze/applyGazeWasm,按_isWasmRuntime()自动分支到 JS 或 WASM 路径,并维护共用骨架(targetWorldQ 计算 / clamp / Slerp / cache)。
对外 API(节选)
initGazeTracking(modelId)— 初始化视线追踪。setGazeConfig(config)— 设置视线配置(启用/灵敏度/模式)。getGazeConfig()— 取当前视线配置。_applyGaze(...)— 统一调度入口(perception-observer 每帧调用)。applyGazeWasm(bones, cam, config, dt)— WASM 路径直暴露(当前无外部调用者,仅经 perception.ts re-export 预留;wasm-layers-blender 未实际调用,注释已过时)。
与其他子系统关系
- WASM 生产路径:
./perception-gaze-wasm.ts(直写 frontBuffer +_propagateChildrenWasm)。 - JS 调试路径:
./perception-gaze-js.ts(写linkedBone+_updateBoneChain+skeleton._markAsDirty)。 - 主控:
../perception.ts。 - 共享类型:
./perception-shared.ts。 - Observer 注册:
./perception-observer.ts(每帧调用_applyGaze)。
不变量
- JS 模式和 WASM 模式互斥,由
_isWasmRuntime(bone)检测当前IMmdRuntimeBone所属运行时类型自动分支(非按性能切换)。 - WASM 模式下不调
skeleton._markAsDirty()(直写 frontBuffer 即生效);JS 模式必须调。 - 视线配置与感知层状态同步。
- JS 路径仅用于
VITE_MMD_RUNTIME=js调试模式(无物理),保留作为 gaze 行为对比排查与 WASM 兼容性回退(scene.ts:687 注释明令勿删除)。