Files
discord-decomp/_bundle/eulerToQuaternion.js
T
2026-11-01 12:12:55 +02:00

164 lines
7.6 KiB
JavaScript

// Metro module 1762 (f1763).
import { useEffect, useMemo, useRef } from "react";
import * as _Module1631 from "./Module1631";
import { IOSReferenceFrame } from "./Module1631";
import { initializeSensor, registerSensor, unregisterSensor } from "./Module1650";
import * as _runWorkletOnJS from "./runWorkletOnJS";
let eulerToQuaternion, adjustRotationToInterfaceOrientation, adjustVectorToInterfaceOrientation, __initData;
const eulerToQuaternion2 = function eulerToQuaternion(a0, a1, a2) {
const r8 = Math.cos(a0 / 2);
const r6 = Math.sin(a0 / 2);
const r17 = Math.cos(a1 / 2);
const r21 = Math.sin(a1 / 2);
const r25 = Math.cos(a2 / 2);
const r29 = Math.sin(a2 / 2);
return [r6 * r17 * r25 - r8 * r21 * r29, r8 * r21 * r25 + r6 * r17 * r29, r8 * r17 * r29 + r6 * r21 * r25, r8 * r17 * r25 - r6 * r21 * r29];
};
eulerToQuaternion2.__closure = {};
eulerToQuaternion2.__workletHash = 14525486759705;
eulerToQuaternion2.__initData = {
code: "function eulerToQuaternion_Pnpm_useAnimatedSensorTs1(pitch,roll,yaw){const c1=Math.cos(pitch/2);const s1=Math.sin(pitch/2);const c2=Math.cos(roll/2);const s2=Math.sin(roll/2);const c3=Math.cos(yaw/2);const s3=Math.sin(yaw/2);return[s1*c2*c3-c1*s2*s3,c1*s2*c3+s1*c2*s3,c1*c2*s3+s1*s2*c3,c1*c2*c3-s1*s2*s3];}"
};
eulerToQuaternion = eulerToQuaternion2;
const adjustRotationToInterfaceOrientation2 = function adjustRotationToInterfaceOrientation(a0) {
const { interfaceOrientation, pitch, roll, yaw } = a0;
if (interfaceOrientation === _Module1631.InterfaceOrientation.ROTATION_90) {
a0.pitch = roll;
a0.roll = -pitch;
a0.yaw = yaw - Math.PI / 2;
} else if (interfaceOrientation === _Module1631.InterfaceOrientation.ROTATION_270) {
a0.pitch = -roll;
a0.roll = pitch;
a0.yaw = yaw + Math.PI / 2;
} else if (interfaceOrientation === _Module1631.InterfaceOrientation.ROTATION_180) {
a0.pitch = a0.pitch * -1;
a0.roll = a0.roll * -1;
a0.yaw = a0.yaw * -1;
}
const { pitch: pitch2, roll: roll2, yaw: yaw2 } = a0;
const r54 = Math.cos(pitch2 / 2);
const r58 = Math.sin(pitch2 / 2);
const r62 = Math.cos(roll2 / 2);
const r66 = Math.sin(roll2 / 2);
const r70 = Math.cos(yaw2 / 2);
const r74 = Math.sin(yaw2 / 2);
const r80 = [r58 * r62 * r70 - r54 * r66 * r74, r54 * r66 * r70 + r58 * r62 * r74, r54 * r62 * r74 + r58 * r66 * r70, r54 * r62 * r70 - r58 * r66 * r74];
a0.qx = r80[0];
a0.qy = r80[1];
a0.qz = r80[2];
a0.qw = r80[3];
return a0;
};
adjustRotationToInterfaceOrientation2.__closure = {
InterfaceOrientation: _Module1631.InterfaceOrientation,
eulerToQuaternion
};
adjustRotationToInterfaceOrientation2.__workletHash = 16635654688360;
adjustRotationToInterfaceOrientation2.__initData = {
code: "function adjustRotationToInterfaceOrientation_Pnpm_useAnimatedSensorTs2(data){const{InterfaceOrientation,eulerToQuaternion}=this.__closure;const{interfaceOrientation:interfaceOrientation,pitch:pitch,roll:roll,yaw:yaw}=data;if(interfaceOrientation===InterfaceOrientation.ROTATION_90){data.pitch=roll;data.roll=-pitch;data.yaw=yaw-Math.PI/2;}else if(interfaceOrientation===InterfaceOrientation.ROTATION_270){data.pitch=-roll;data.roll=pitch;data.yaw=yaw+Math.PI/2;}else if(interfaceOrientation===InterfaceOrientation.ROTATION_180){data.pitch*=-1;data.roll*=-1;data.yaw*=-1;}const q=eulerToQuaternion(data.pitch,data.roll,data.yaw);data.qx=q[0];data.qy=q[1];data.qz=q[2];data.qw=q[3];return data;}"
};
adjustRotationToInterfaceOrientation = adjustRotationToInterfaceOrientation2;
const adjustVectorToInterfaceOrientation2 = function adjustVectorToInterfaceOrientation(a0) {
const { interfaceOrientation, x: r4, y: r5 } = a0;
if (interfaceOrientation === _Module1631.InterfaceOrientation.ROTATION_90) {
a0.x = -r5;
a0.y = r4;
} else if (interfaceOrientation === _Module1631.InterfaceOrientation.ROTATION_270) {
a0.x = r5;
a0.y = -r4;
} else if (interfaceOrientation === _Module1631.InterfaceOrientation.ROTATION_180) {
a0.x = a0.x * -1;
a0.y = a0.y * -1;
}
return a0;
};
adjustVectorToInterfaceOrientation2.__closure = {
InterfaceOrientation: _Module1631.InterfaceOrientation
};
adjustVectorToInterfaceOrientation2.__workletHash = 5352466445526;
adjustVectorToInterfaceOrientation2.__initData = {
code: "function adjustVectorToInterfaceOrientation_Pnpm_useAnimatedSensorTs3(data){const{InterfaceOrientation}=this.__closure;const{interfaceOrientation:interfaceOrientation,x:x,y:y}=data;if(interfaceOrientation===InterfaceOrientation.ROTATION_90){data.x=-y;data.y=x;}else if(interfaceOrientation===InterfaceOrientation.ROTATION_270){data.x=y;data.y=-x;}else if(interfaceOrientation===InterfaceOrientation.ROTATION_180){data.x*=-1;data.y*=-1;}return data;}"
};
adjustVectorToInterfaceOrientation = adjustVectorToInterfaceOrientation2;
__initData = {
code: "function pnpm_useAnimatedSensorTs4(data){const{adjustToInterfaceOrientation,sensorType,SensorType,adjustRotationToInterfaceOrientation,adjustVectorToInterfaceOrientation,sensorData,callMicrotasks}=this.__closure;if(adjustToInterfaceOrientation){if(sensorType===SensorType.ROTATION){data=adjustRotationToInterfaceOrientation(data);}else{data=adjustVectorToInterfaceOrientation(data);}}sensorData.value=data;callMicrotasks();}"
};
export function useAnimatedSensor(a0, a1) {
let ref2;
const sensorType = a0;
const ref = useRef(a1);
if (ref.current?.adjustToInterfaceOrientation !== a1?.adjustToInterfaceOrientation || ref.current?.interval !== a1?.interval || ref.current?.iosReferenceFrame !== a1?.iosReferenceFrame) {
ref.current = {
...a1
};
}
const memo = useMemo(() => ({
interval: "auto",
adjustToInterfaceOrientation: true,
iosReferenceFrame: IOSReferenceFrame.Auto,
...ref.current
}), [ref.current]);
ref2 = useRef({
sensor: initializeSensor(a0, memo),
unregister: () => {},
isAvailable: false,
config: memo
});
useEffect(() => {
let sensor, adjustToInterfaceOrientation, c24666_2;
ref2.current = {
sensor: initializeSensor(sensorType, memo),
unregister: () => {},
isAvailable: false,
config: memo
};
sensor = ref2.current.sensor;
adjustToInterfaceOrientation = ref2.current.config.adjustToInterfaceOrientation;
const n = function n(a0) {
if (adjustToInterfaceOrientation) {
if (sensorType === _Module1631.SensorType.ROTATION) {
adjustRotationToInterfaceOrientation(a0);
} else {
const { interfaceOrientation, x: r20, y: r21 } = a0;
if (interfaceOrientation === _Module1631.InterfaceOrientation.ROTATION_90) {
a0.x = -r21;
a0.y = r20;
} else if (interfaceOrientation === _Module1631.InterfaceOrientation.ROTATION_270) {
a0.x = r21;
a0.y = -r20;
} else if (interfaceOrientation === _Module1631.InterfaceOrientation.ROTATION_180) {
a0.x = a0.x * -1;
a0.y = a0.y * -1;
}
}
}
sensor.value = a0;
_runWorkletOnJS.callMicrotasks();
};
n.__closure = {
adjustToInterfaceOrientation,
sensorType,
SensorType: _Module1631.SensorType,
adjustRotationToInterfaceOrientation,
adjustVectorToInterfaceOrientation,
sensorData: sensor,
callMicrotasks: _runWorkletOnJS.callMicrotasks
};
n.__workletHash = 6807952122364;
n.__initData = __initData;
const r35 = registerSensor(sensorType, memo, n);
c24666_2 = r35;
if (r35 !== -1) {
ref2.current.unregister = () => unregisterSensor(c24666_2);
ref2.current.isAvailable = true;
} else {
ref2.current.unregister = () => {};
ref2.current.isAvailable = false;
}
return () => {
ref2.current.unregister();
};
}, [a0, memo]);
return ref2.current;
}