mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: transition and continous
This commit is contained in:
1 parent
291395718f
commit
897da9479d
2 files changed
+35
-25
No files matched your search
+30
-24
@@ -1,5 +1,6 @@
|
|||||||
import { Card } from '@radix-ui/themes';
|
import { Card } from '@radix-ui/themes';
|
||||||
import { awaitableModelDefinitions } from '../../../../../../../core/awaitables/modelDefinitions';
|
import { awaitableModelDefinitions } from '../../../../../../../core/awaitables/modelDefinitions';
|
||||||
|
import { DEFAULT_PITCH_TRANSITION } from '../../../../../../../core/blitz/applyPitchYawLimits';
|
||||||
import { Duel } from '../../../../../../../stores/duel';
|
import { Duel } from '../../../../../../../stores/duel';
|
||||||
|
|
||||||
const MAX_MAG = 20;
|
const MAX_MAG = 20;
|
||||||
@@ -28,58 +29,55 @@ export function GunFlexibilityVisualizer() {
|
|||||||
const y = turretModel.yaw;
|
const y = turretModel.yaw;
|
||||||
const f = p.front;
|
const f = p.front;
|
||||||
const b = p.back;
|
const b = p.back;
|
||||||
|
const t = gunModel.pitch.transition ?? DEFAULT_PITCH_TRANSITION;
|
||||||
|
|
||||||
let d = '';
|
let d = '';
|
||||||
|
|
||||||
// right
|
// right
|
||||||
d += `M 0 0`;
|
|
||||||
const ms = mag(p.max);
|
const ms = mag(p.max);
|
||||||
if (y) {
|
if (y) {
|
||||||
d += `L ${c(90 - y.max, ms)}`;
|
d += `M ${c(90 - y.max, ms)}`;
|
||||||
} else if (b) {
|
} else if (b) {
|
||||||
d += `L ${c(-90 + b.range / 2, ms)}`;
|
d += `M ${c(-90 + b.range / 2 + t, ms)}`;
|
||||||
} else {
|
} else {
|
||||||
d += `L ${c(-90 / 2, ms)}`;
|
d += `M ${c(-90 / 2, ms)}`;
|
||||||
}
|
}
|
||||||
if (f) {
|
if (f) {
|
||||||
d += `A ${ms} ${ms} 0 0 0 ${c(90 - f.range / 2, ms)}`;
|
d += `A ${ms} ${ms} 0 0 0 ${c(90 - f.range / 2 - t, ms)}`;
|
||||||
} else {
|
} else {
|
||||||
d += `A ${ms} ${ms} 0 0 0 ${c(90 / 2, ms)}`;
|
d += `A ${ms} ${ms} 0 0 0 ${c(90 / 2, ms)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// left
|
// front
|
||||||
d += `M 0 0`;
|
|
||||||
if (f) {
|
if (f) {
|
||||||
d += `L ${c(90 + f.range / 2, ms)}`;
|
const m = mag(f.max);
|
||||||
|
d += `L ${c(90 - f.range / 2, m)}`;
|
||||||
|
d += `A ${m} ${m} 0 0 0 ${c(90 + f.range / 2, m)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// left
|
||||||
|
if (f) {
|
||||||
|
d += `L ${c(90 + f.range / 2 + t, ms)}`;
|
||||||
} else {
|
} else {
|
||||||
d += `L ${c(90 / 2, ms)}`;
|
d += `L ${c(90 / 2, ms)}`;
|
||||||
}
|
}
|
||||||
if (y) {
|
if (y) {
|
||||||
d += `A ${ms} ${ms} 0 0 0 ${c(90 - y.min, ms)}`;
|
d += `A ${ms} ${ms} 0 0 0 ${c(90 - y.min, ms)}`;
|
||||||
} else if (b) {
|
} else if (b) {
|
||||||
d += `A ${ms} ${ms} 0 0 0 ${c(-90 - b.range / 2, ms)}`;
|
d += `A ${ms} ${ms} 0 0 0 ${c(-90 - b.range / 2 - t, ms)}`;
|
||||||
} else {
|
} else {
|
||||||
d += `A ${ms} ${ms} 0 0 0 ${c(-90 / 2, ms)}`;
|
d += `A ${ms} ${ms} 0 0 0 ${c(-90 / 2, ms)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// front
|
|
||||||
if (f) {
|
|
||||||
const m = mag(f.max);
|
|
||||||
d += `M 0 0`;
|
|
||||||
d += `L ${c(90 - f.range / 2, m)}`;
|
|
||||||
d += `A ${m} ${m} 0 0 0 ${c(90 + f.range / 2, m)}`;
|
|
||||||
d += `Z`;
|
|
||||||
}
|
|
||||||
|
|
||||||
// back
|
// back
|
||||||
if (!y && b) {
|
if (!y && b) {
|
||||||
const m = mag(b.max);
|
const m = mag(b.max);
|
||||||
d += `M 0 0`;
|
|
||||||
d += `L ${c(-90 - b.range / 2, m)}`;
|
d += `L ${c(-90 - b.range / 2, m)}`;
|
||||||
d += `A ${m} ${m} 0 0 0 ${c(-90 + b.range / 2, m)}`;
|
d += `A ${m} ${m} 0 0 0 ${c(-90 + b.range / 2, m)}`;
|
||||||
d += `Z`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d += `Z`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card style={{ aspectRatio: '1 / 1' }} variant="classic">
|
<Card style={{ aspectRatio: '1 / 1' }} variant="classic">
|
||||||
<svg
|
<svg
|
||||||
@@ -87,16 +85,24 @@ export function GunFlexibilityVisualizer() {
|
|||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: 0,
|
top: 0,
|
||||||
left: 0,
|
left: 0,
|
||||||
width: '100%',
|
width: 'calc(100%)',
|
||||||
height: '100%',
|
height: 'calc(100%)',
|
||||||
}}
|
}}
|
||||||
viewBox="-1 -1 2 2"
|
viewBox="-1 -1 2 2"
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
fill="var(--gray-1)"
|
stroke="var(--gray-11)"
|
||||||
|
strokeWidth="0.01px"
|
||||||
|
fill="var(--gray-9)"
|
||||||
|
d={d}
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
stroke="var(--gray-2)"
|
||||||
|
fill="transparent"
|
||||||
|
strokeWidth="0.01px"
|
||||||
|
strokeDasharray="0.05 0.01"
|
||||||
d="M 0.5 0 A 0.5 0.5 0 1 1 -0.5 0 A 0.5 0.5 0 1 1 0.5 0 Z"
|
d="M 0.5 0 A 0.5 0.5 0 1 1 -0.5 0 A 0.5 0.5 0 1 1 0.5 0 Z"
|
||||||
/>
|
/>
|
||||||
<path fill="var(--gray-a9)" d={d} />
|
|
||||||
</svg>
|
</svg>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import {
|
|||||||
import { clamp } from 'lodash-es';
|
import { clamp } from 'lodash-es';
|
||||||
import { degToRad } from 'three/src/math/MathUtils.js';
|
import { degToRad } from 'three/src/math/MathUtils.js';
|
||||||
|
|
||||||
|
export const DEFAULT_PITCH_TRANSITION = 15;
|
||||||
|
|
||||||
export function applyPitchYawLimits(
|
export function applyPitchYawLimits(
|
||||||
pitch: number, // rad
|
pitch: number, // rad
|
||||||
yaw: number, // rad
|
yaw: number, // rad
|
||||||
@@ -28,7 +30,9 @@ export function applyPitchYawLimits(
|
|||||||
const elevationBuff = verticalStabilizer ? degToRad(4) : 0;
|
const elevationBuff = verticalStabilizer ? degToRad(4) : 0;
|
||||||
let lowerPitch = -degToRad(pitchLimits.max) - depressionBuff;
|
let lowerPitch = -degToRad(pitchLimits.max) - depressionBuff;
|
||||||
let upperPitch = -degToRad(pitchLimits.min) + elevationBuff;
|
let upperPitch = -degToRad(pitchLimits.min) + elevationBuff;
|
||||||
const transition = degToRad(pitchLimits.transition ?? 15);
|
const transition = degToRad(
|
||||||
|
pitchLimits.transition ?? DEFAULT_PITCH_TRANSITION,
|
||||||
|
);
|
||||||
|
|
||||||
if (pitchLimits.back) {
|
if (pitchLimits.back) {
|
||||||
const range = degToRad(pitchLimits.back.range);
|
const range = degToRad(pitchLimits.back.range);
|
||||||
|
|||||||
Reference in new issue
Block a user