This commit is contained in:
33333-33333 2026-06-27 19:22:38 +09:00
commit 129c07183a
51 changed files with 5711 additions and 1122 deletions

View file

@ -131,6 +131,17 @@
return false;
}
function syncGrabbedPhysicsItem(target, reason = "pinch-move") {
if (!target || target.dead) return false;
const pb = (typeof window !== "undefined" ? window : globalThis).TarinaiPhysicsBodySystem;
if (!pb?.isBodyType?.(target.type)) return false;
pb.syncPoseFromItem?.(target);
pb.setScalar?.(target, "awakeUntil", Math.max(Number(pb.scalar?.(target, "awakeUntil", 0) || 0), (world.time || 0) + 0.65), reason);
pb.markBodyChanged?.(target, reason);
(typeof window !== "undefined" ? window : globalThis).TarinaiMechanicalSystem?.invalidateGeometry?.(target);
return true;
}
function prepareGrabTarget(target) {
if (uiCache.grabKind === "tarinai") {
const lodged = target.currentLodgedPin?.() || (world.items || []).find(it => it && isPinType(it.type) && it.pinState === "lodged" && it.pinTargetId === target.id);
@ -168,6 +179,7 @@
target.playerHeld = true;
target._heldByPlayer = true;
target._playerGrabStartedAt = world.time || 0;
if (uiCache.grabKind === "item") syncGrabbedPhysicsItem(target, "pinch-start");
if (target.type === "duplicator") {
target.duplicatorLoadSuppressedUntil = Math.max(target.duplicatorLoadSuppressedUntil || 0, (world.time || 0) + 1.0);
target._duplicatorCandidateKey = "";
@ -206,11 +218,13 @@
const movedX = (Number(target.x || 0) || 0) - beforeX;
const movedY = (Number(target.y || 0) || 0) - beforeY;
if (uiCache.grabKind === "item" && target.type === "reciprocator") {
target.reciprocatorAnchorX = (Number(target.reciprocatorAnchorX || beforeX) || beforeX) + movedX;
target.reciprocatorAnchorY = (Number(target.reciprocatorAnchorY || beforeY) || beforeY) + movedY;
const pb = (typeof window !== "undefined" ? window : globalThis).TarinaiPhysicsBodySystem;
pb?.setScalar?.(target, "railAnchorX", (Number(pb?.scalar?.(target, "railAnchorX", beforeX)) || beforeX) + movedX, "grab-move");
pb?.setScalar?.(target, "railAnchorY", (Number(pb?.scalar?.(target, "railAnchorY", beforeY)) || beforeY) + movedY, "grab-move");
target.prevX = target.x;
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);
if (uiCache.grabKind === "tarinai") {
@ -245,6 +259,7 @@
target.prevX = target.x;
target.prevY = target.y;
}
if (uiCache.grabKind === "item") syncGrabbedPhysicsItem(target, "pinch-release");
target.playerHeld = false;
target._heldByPlayer = false;
target._lastPlayerReleasedAt = world.time || 0;