mx / src /video /state.ts
Ethscriptions's picture
Step 3-4: 3D 解剖模型与分镜时间轴
213d393 verified
Raw History Blame Contribute Delete
721 Bytes
import { POSE, type SceneState } from './model'
import type { V3 } from './math'
export function baseState(over: Partial<SceneState> = {}): SceneState {
return {
cam: { pos: [0, 0.2, 5], target: [0, 0.2, 0], fov: 35 },
arm: { pos: [0, 0, 0], rot: [0, 0.6, 0] },
pose: [...POSE.rest],
skin: 1, xray: 0, bone: 0, tendon: 0, sheath: 0, thick: 0, friction: 0, pain: 0,
props: {},
time: 0,
...over,
}
}
/** camera orbiting helper: spherical around target */
export function orbit(target: V3, dist: number, yaw: number, pitch: number): V3 {
return [target[0] + dist * Math.sin(yaw) * Math.cos(pitch), target[1] + dist * Math.sin(pitch), target[2] + dist * Math.cos(yaw) * Math.cos(pitch)]
}