mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
center correction
This commit is contained in:
1 parent
d424679257
commit
a7d5bd6c75
3 files changed
+12
No files matched your search
@@ -0,0 +1,3 @@
|
||||
export function copySign(a: number, b: number) {
|
||||
return b >= 0 ? Math.abs(a) : -Math.abs(a);
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { invalidate, useFrame, useThree } from "@react-three/fiber";
|
||||
import { useCallback, useEffect, useRef, type RefObject } from "react";
|
||||
import { Quaternion, Vector2, Vector3 } from "three";
|
||||
import {
|
||||
cameraCenterCorrectionAmplitude,
|
||||
cameraSwingHorizontalAmplitude,
|
||||
cameraSwingHorizontalFrequency,
|
||||
cameraSwingVerticalAmplitude,
|
||||
@@ -32,6 +33,12 @@ export function TankopediaControls() {
|
||||
const disturbed = Tankopedia.use((state) => state.disturbed);
|
||||
|
||||
const updateCameraPosition = useCallback(() => {
|
||||
// https://www.desmos.com/calculator/wen5z8qdc1
|
||||
cameraCenter.x =
|
||||
cameraCenterCorrectionAmplitude *
|
||||
Math.sin(2 * theta.current) *
|
||||
Math.sign(Math.cos(theta.current));
|
||||
|
||||
workingVector3
|
||||
.set(
|
||||
Math.sin(phi.current) * Math.sin(theta.current),
|
||||
|
||||
@@ -10,3 +10,5 @@ export const cameraSwingVerticalAmplitude = degToRad(5);
|
||||
export const cameraSwingVerticalFrequency = Math.E ** -6;
|
||||
export const cameraSwingHorizontalAmplitude = degToRad(30);
|
||||
export const cameraSwingHorizontalFrequency = Math.E ** -5;
|
||||
|
||||
export const cameraCenterCorrectionAmplitude = 0.8;
|
||||
Reference in new issue
Block a user