feat(craft-tilt): 新增 simulateTilt 手动模拟入口
- simulateTilt(dx, dy) 单位度,校验 NaN/Infinity - simulateTiltFromNormalized(x, y) 触摸归一化转度(系数 45) - simulateTiltReset() 滑块复位用 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
958c867309
commit
c6cb55dfc0
@ -12,6 +12,9 @@ import { ref, nextTick } from 'vue'
|
||||
import { useLenticularPreview } from '@/composables/useLenticularPreview.js'
|
||||
import { useLenticularStudioTilt } from '@/composables/useLenticularStudioTilt.js'
|
||||
|
||||
// 手动模拟倾斜:归一化 → 度数 转换系数(spec §3.5)
|
||||
const NORMALIZED_TO_DEG = 45
|
||||
|
||||
const FLOW_PHYSICS = {
|
||||
angleStability: 15, // 显示层跟踪速度(0=最快/最跟手;100=最稳/最惰性)
|
||||
transitionSmoothness: 2, // 输入层跟踪速度(值越小越瞬时;引擎内部: alpha=1-s*0.9)
|
||||
@ -212,6 +215,39 @@ export function useLenticularCraftTiltPreview(layersRef) {
|
||||
stopTilt()
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
// 手动模拟倾斜入口(spec §3.1)
|
||||
// ====================================================================
|
||||
|
||||
/**
|
||||
* 滑块/外部入口:直接传度数(-45..+45)
|
||||
* 内部转给 simulateFromSignedDegrees 走现有离散档位逻辑
|
||||
*/
|
||||
function simulateTilt(dx, dy) {
|
||||
if (!Number.isFinite(dx) || !Number.isFinite(dy)) {
|
||||
console.warn('[CraftTilt] simulateTilt: non-finite input', dx, dy)
|
||||
return
|
||||
}
|
||||
simulateFromSignedDegrees(dx, dy)
|
||||
}
|
||||
|
||||
/**
|
||||
* 触摸入口:-1..+1 归一化转度数(系数 45)
|
||||
* 由 LenticularCard.vue / HolographicCard.vue 的 @simulate 事件触发
|
||||
*/
|
||||
function simulateTiltFromNormalized(x, y) {
|
||||
const dx = x * NORMALIZED_TO_DEG
|
||||
const dy = (y != null ? y : 0) * NORMALIZED_TO_DEG
|
||||
simulateTilt(dx, dy)
|
||||
}
|
||||
|
||||
/**
|
||||
* 滑块点"复位"时调用:归零 + 清空离散档位状态
|
||||
*/
|
||||
function simulateTiltReset() {
|
||||
lockPreviewStill()
|
||||
}
|
||||
|
||||
return {
|
||||
physics,
|
||||
layerTransforms,
|
||||
@ -221,5 +257,9 @@ export function useLenticularCraftTiltPreview(layersRef) {
|
||||
scheduleTiltStart,
|
||||
stopTiltPreview,
|
||||
lockPreviewStill,
|
||||
// 新增:手动模拟入口(spec §3.1)
|
||||
simulateTilt,
|
||||
simulateTiltFromNormalized,
|
||||
simulateTiltReset,
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user