This commit is contained in:
33333-33333 2026-06-28 23:07:40 +09:00
commit 0e432c62ae
87 changed files with 4282 additions and 3066 deletions

View file

@ -21,6 +21,7 @@
document.body.classList.toggle("mobile-mode-auto", mode === "auto");
document.body.classList.toggle("mobile-mode-camera", mode === "camera");
document.body.classList.toggle("mobile-mode-tool", mode === "tool");
global.syncMobileRotateControls?.();
return mode;
}
@ -28,6 +29,7 @@
const enabled = Boolean(inputModeManager?.refresh?.().touchFirst);
document.body.classList.toggle("touch-mobile-ui", enabled);
if (ui.mobileModeControls) ui.mobileModeControls.hidden = !enabled;
global.syncMobileRotateControls?.();
return enabled;
}
@ -187,6 +189,9 @@
rememberGrabOrigin(target);
uiCache.grabLastWorldX = p.x;
uiCache.grabLastWorldY = p.y;
uiCache.grabVelocityX = 0;
uiCache.grabVelocityY = 0;
uiCache.grabLastMoveAt = performance?.now?.() ?? Date.now();
uiCache.grabStartX = clientX || 0;
uiCache.grabStartY = clientY || 0;
target.playerHeld = true;
@ -215,6 +220,11 @@
}
const dx = p.x - (uiCache.grabLastWorldX ?? p.x);
const dy = p.y - (uiCache.grabLastWorldY ?? p.y);
const moveNow = performance?.now?.() ?? Date.now();
const moveDt = Math.max(0.012, Math.min(0.18, (moveNow - (uiCache.grabLastMoveAt || moveNow)) / 1000));
uiCache.grabLastMoveAt = moveNow;
uiCache.grabVelocityX = clamp(dx / moveDt, -820, 820);
uiCache.grabVelocityY = clamp(dy / moveDt, -820, 820);
uiCache.grabLastWorldX = p.x;
uiCache.grabLastWorldY = p.y;
const beforeX = Number(target.x || 0) || 0;
@ -238,8 +248,8 @@
target.prevY = target.y;
}
if (uiCache.grabKind === "item") syncGrabbedPhysicsItem(target, "pinch-move");
target.vx = clamp(dx * 16, -160, 160);
target.vy = clamp(dy * 16, -160, 160);
target.vx = clamp(uiCache.grabVelocityX || dx * 16, -820, 820);
target.vy = clamp(uiCache.grabVelocityY || dy * 16, -820, 820);
if (uiCache.grabKind === "tarinai") {
target.goIdle?.("\u3064\u307e\u307e\u308c\u3066\u3044\u308b");
if (options.touch) target.pinchThoughtTimer = Math.max(target.pinchThoughtTimer || 0, 0.8);
@ -268,9 +278,21 @@
target.targetKey = "";
target.surpriseTimer = Math.max(target.surpriseTimer || 0, 0.15);
finishTarinaiGrab(target, clientX, clientY);
} else if (target.type === "ball") {
target.prevX = target.x;
target.prevY = target.y;
} else if (uiCache.grabKind === "item") {
const releaseVx = clamp(Number(uiCache.grabVelocityX || target.vx || 0) || 0, -900, 900);
const releaseVy = clamp(Number(uiCache.grabVelocityY || target.vy || 0) || 0, -900, 900);
const releaseSpeed = Math.hypot(releaseVx, releaseVy);
if (releaseSpeed > 18) {
target.vx = releaseVx;
target.vy = releaseVy;
const frameDt = Math.max(1 / 90, Math.min(1 / 30, Number(world.dt || 1 / 60) || 1 / 60));
target.prevX = target.x - releaseVx * frameDt;
target.prevY = target.y - releaseVy * frameDt;
if (target.type === "ball") target.spinVelocity = clamp((target.spinVelocity || 0) + releaseVx * 0.018, -42, 42);
} else if (target.type === "ball") {
target.prevX = target.x;
target.prevY = target.y;
}
}
if (uiCache.grabKind === "item") syncGrabbedPhysicsItem(target, "pinch-release");
target.playerHeld = false;
@ -286,6 +308,9 @@
uiCache.grabbing = false;
uiCache.grabTarget = null;
uiCache.grabKind = "";
uiCache.grabVelocityX = 0;
uiCache.grabVelocityY = 0;
uiCache.grabLastMoveAt = 0;
world.rebuildSpatial?.();
uiCache.grabLastSpatialAt = 0;
canvas.style.cursor = cursorForTool(world.tool);
@ -571,6 +596,9 @@
uiCache.grabbing = false;
uiCache.grabTarget = null;
uiCache.grabKind = "";
uiCache.grabVelocityX = 0;
uiCache.grabVelocityY = 0;
uiCache.grabLastMoveAt = 0;
if (world) {
world.hoverGrabTarget = null;
world.hoverDeleteTarget = null;