feat(v0.1.1): 周期表五大分区 / 分区与单格改色 / 全屏视线跟随 / 窗口图标 / 跨平台打包
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
const fs = require('fs')
|
||||
const base = 'E:/SodiumPet/WorkPlace/v0.1.1/src/'
|
||||
function rep(file, from, to, label) {
|
||||
const p = base + file
|
||||
let c = fs.readFileSync(p, 'utf8')
|
||||
if (!c.includes(from)) {
|
||||
console.log('MISS:', label)
|
||||
return
|
||||
}
|
||||
c = c.replace(from, to)
|
||||
fs.writeFileSync(p, c, 'utf8')
|
||||
console.log('ok:', label)
|
||||
}
|
||||
|
||||
// 1) 适配器:全屏方向映射(远距离保持方向,近距离更灵敏)
|
||||
rep(
|
||||
'renderer/src/pet/adapters/live2d.ts',
|
||||
` // 以脸的位置为中心,把目标限制在一个锥形范围内,鼠标很远时也不会锁死
|
||||
const s = this.model.scale.x || 1
|
||||
const cx = this.model.x + (this.baseSize.w / 2) * s
|
||||
const cy = this.model.y + (this.baseSize.h * 0.45) * s
|
||||
let dx = x - cx
|
||||
let dy = y - cy
|
||||
const dist = Math.hypot(dx, dy)
|
||||
const R = 260
|
||||
if (dist > R) {
|
||||
dx = (dx / dist) * R
|
||||
dy = (dy / dist) * R
|
||||
}
|
||||
this.model?.focus(cx + dx, cy + dy)`,
|
||||
` // 以脸的位置为中心:方向永远跟随光标,距离只影响偏转幅度
|
||||
// 这样光标跑到屏幕另一头也能转,不会在窗口边缘就"锁死"
|
||||
const s = this.model.scale.x || 1
|
||||
const cx = this.model.x + (this.baseSize.w / 2) * s
|
||||
const cy = this.model.y + (this.baseSize.h * 0.45) * s
|
||||
const dx = x - cx
|
||||
const dy = y - cy
|
||||
const dist = Math.hypot(dx, dy)
|
||||
if (dist < 0.5) {
|
||||
this.model?.focus(cx, cy)
|
||||
return
|
||||
}
|
||||
// 620 约等于"一个窗口外两三屏"的距离;超出后只保留最大偏转
|
||||
const eased = Math.min(1, Math.pow(dist / 620, 0.6))
|
||||
const R = 80 + 340 * eased
|
||||
this.model?.focus(cx + (dx / dist) * R, cy + (dy / dist) * R)`,
|
||||
'adapter lookAt range'
|
||||
)
|
||||
|
||||
// 2) 渲染层:去掉局部 pointermove 覆盖,统一交给主进程全局轮询
|
||||
rep(
|
||||
'renderer/src/App.tsx',
|
||||
` if (cfg.eyeFollow) {
|
||||
adapterRef.current?.lookAt?.(e.clientX + cfg.cropLeft, e.clientY + cfg.cropTop)
|
||||
}
|
||||
`,
|
||||
'',
|
||||
'remove local pointer eye-follow'
|
||||
)
|
||||
|
||||
// 3) preload / api 类型补 inside
|
||||
rep(
|
||||
'preload/index.ts',
|
||||
' onLook: (cb: (p: { x: number; y: number }) => void) => () => void',
|
||||
' onLook: (cb: (p: { x: number; y: number; inside?: boolean }) => void) => () => void',
|
||||
'preload onLook type'
|
||||
)
|
||||
rep(
|
||||
'renderer/src/api.ts',
|
||||
' onLook: (cb: (p: { x: number; y: number }) => void) => () => void',
|
||||
' onLook: (cb: (p: { x: number; y: number; inside?: boolean }) => void) => () => void',
|
||||
'api onLook type'
|
||||
)
|
||||
Reference in New Issue
Block a user