mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 03:59:50 +02:00
angles
This commit is contained in:
1 parent
f73ffc3c93
commit
1f767af0b5
9 files changed
+47
-41
No files matched your search
@@ -1,7 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
BlitzCrewType,
|
BlitzCrewType,
|
||||||
ChassisDefinitionsList,
|
ChassisDefinitionsList,
|
||||||
EngineDefinitionsList,
|
|
||||||
GunDefinitionsList,
|
GunDefinitionsList,
|
||||||
TankParameters,
|
TankParameters,
|
||||||
toUniqueId,
|
toUniqueId,
|
||||||
@@ -17,7 +16,7 @@ import { ServerBlitzKitAPI2 } from "./2_camouflages";
|
|||||||
|
|
||||||
export abstract class ServerBlitzKitAPI3 extends ServerBlitzKitAPI2 {
|
export abstract class ServerBlitzKitAPI3 extends ServerBlitzKitAPI2 {
|
||||||
private vector3TupleToBlitzkit(tuple: Vector3Tuple) {
|
private vector3TupleToBlitzkit(tuple: Vector3Tuple) {
|
||||||
return { x: tuple[0], y: tuple[1], z: tuple[2] } satisfies Vector3;
|
return { x: tuple[0], y: tuple[1], z: -tuple[2] } satisfies Vector3;
|
||||||
}
|
}
|
||||||
|
|
||||||
private assignArmor(
|
private assignArmor(
|
||||||
@@ -50,9 +49,6 @@ export abstract class ServerBlitzKitAPI3 extends ServerBlitzKitAPI2 {
|
|||||||
const gunList = await this.vfs.xml<{
|
const gunList = await this.vfs.xml<{
|
||||||
root: GunDefinitionsList;
|
root: GunDefinitionsList;
|
||||||
}>(`Data/XML/item_defs/vehicles/${nation}/components/guns.xml`);
|
}>(`Data/XML/item_defs/vehicles/${nation}/components/guns.xml`);
|
||||||
const enginesList = await this.vfs.xml<{
|
|
||||||
root: EngineDefinitionsList;
|
|
||||||
}>(`Data/XML/item_defs/vehicles/${nation}/components/engines.xml`);
|
|
||||||
const chassisList = await this.vfs.xml<{
|
const chassisList = await this.vfs.xml<{
|
||||||
root: ChassisDefinitionsList;
|
root: ChassisDefinitionsList;
|
||||||
}>(`Data/XML/item_defs/vehicles/${nation}/components/chassis.xml`);
|
}>(`Data/XML/item_defs/vehicles/${nation}/components/chassis.xml`);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { memo, useRef } from "react";
|
import { memo, useRef } from "react";
|
||||||
import { Group } from "three";
|
import { Group } from "three";
|
||||||
import { correctZYTuple } from "../core/blitz/correctZYTuple";
|
|
||||||
import { nameToArmorId } from "../core/blitzkit/nameToArmorId";
|
import { nameToArmorId } from "../core/blitzkit/nameToArmorId";
|
||||||
import { resolveArmor } from "../core/blitzkit/resolveThickness";
|
import { resolveArmor } from "../core/blitzkit/resolveThickness";
|
||||||
import { useArmor } from "../hooks/useArmor";
|
import { useArmor } from "../hooks/useArmor";
|
||||||
@@ -8,6 +7,7 @@ import { useConsumable } from "../hooks/useConsumable";
|
|||||||
import { DuelModule, useDuel } from "../hooks/useDuel";
|
import { DuelModule, useDuel } from "../hooks/useDuel";
|
||||||
import { useDuelModel } from "../hooks/useDuelModel";
|
import { useDuelModel } from "../hooks/useDuelModel";
|
||||||
import { useTankTransform } from "../hooks/useTankTransform";
|
import { useTankTransform } from "../hooks/useTankTransform";
|
||||||
|
import { toThreeVector } from "../three/toThreeVector";
|
||||||
import { PrimaryArmorSceneComponent } from "./PrimaryArmorSceneComponent";
|
import { PrimaryArmorSceneComponent } from "./PrimaryArmorSceneComponent";
|
||||||
|
|
||||||
export const PrimaryArmorScene = memo(() => {
|
export const PrimaryArmorScene = memo(() => {
|
||||||
@@ -23,9 +23,9 @@ export const PrimaryArmorScene = memo(() => {
|
|||||||
const trackModelDefinition = tankModelDefinition.tracks[track.id];
|
const trackModelDefinition = tankModelDefinition.tracks[track.id];
|
||||||
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
|
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
|
||||||
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
||||||
const hullOrigin = correctZYTuple(trackModelDefinition.origin!);
|
const hullOrigin = toThreeVector(trackModelDefinition.origin);
|
||||||
const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin!);
|
const turretOrigin = toThreeVector(tankModelDefinition.turret_origin);
|
||||||
const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin!);
|
const gunOrigin = toThreeVector(turretModelDefinition.gun_origin);
|
||||||
const isDynamicArmorActive = useConsumable("protagonist", 73);
|
const isDynamicArmorActive = useConsumable("protagonist", 73);
|
||||||
|
|
||||||
useTankTransform(track, turret, turretContainer, gunContainer);
|
useTankTransform(track, turret, turretContainer, gunContainer);
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { memo, useRef } from "react";
|
import { memo, useRef } from "react";
|
||||||
import { Group, Plane, Scene, Vector3 } from "three";
|
import { Group, Plane, Scene, Vector3 } from "three";
|
||||||
import { correctZYTuple } from "../core/blitz/correctZYTuple";
|
|
||||||
import { nameToArmorId } from "../core/blitzkit/nameToArmorId";
|
import { nameToArmorId } from "../core/blitzkit/nameToArmorId";
|
||||||
import { resolveArmor } from "../core/blitzkit/resolveThickness";
|
import { resolveArmor } from "../core/blitzkit/resolveThickness";
|
||||||
import { useArmor } from "../hooks/useArmor";
|
import { useArmor } from "../hooks/useArmor";
|
||||||
@@ -9,6 +8,7 @@ import { DuelModule, useDuel } from "../hooks/useDuel";
|
|||||||
import { useDuelModel } from "../hooks/useDuelModel";
|
import { useDuelModel } from "../hooks/useDuelModel";
|
||||||
import { useModel } from "../hooks/useModel";
|
import { useModel } from "../hooks/useModel";
|
||||||
import { useTankTransform } from "../hooks/useTankTransform";
|
import { useTankTransform } from "../hooks/useTankTransform";
|
||||||
|
import { toThreeVector } from "../three/toThreeVector";
|
||||||
import { SpacedArmorSceneComponent } from "./SpacedArmorSceneComponent";
|
import { SpacedArmorSceneComponent } from "./SpacedArmorSceneComponent";
|
||||||
|
|
||||||
export enum ArmorType {
|
export enum ArmorType {
|
||||||
@@ -36,9 +36,9 @@ export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
|
|||||||
const trackModelDefinition = tankModelDefinition.tracks[track.id];
|
const trackModelDefinition = tankModelDefinition.tracks[track.id];
|
||||||
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
|
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
|
||||||
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
||||||
const hullOrigin = correctZYTuple(trackModelDefinition.origin!);
|
const hullOrigin = toThreeVector(trackModelDefinition.origin);
|
||||||
const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin!);
|
const turretOrigin = toThreeVector(tankModelDefinition.turret_origin);
|
||||||
const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin!);
|
const gunOrigin = toThreeVector(turretModelDefinition.gun_origin);
|
||||||
const maskOrigin =
|
const maskOrigin =
|
||||||
gunModelDefinition.mask === undefined
|
gunModelDefinition.mask === undefined
|
||||||
? undefined
|
? undefined
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { useThree, type ThreeEvent } from "@react-three/fiber";
|
|||||||
import { memo, useRef } from "react";
|
import { memo, useRef } from "react";
|
||||||
import { Group, Plane, Vector2, Vector3 } from "three";
|
import { Group, Plane, Vector2, Vector3 } from "three";
|
||||||
import { applyPitchYawLimits } from "../core/blitz/applyPitchYawLimits";
|
import { applyPitchYawLimits } from "../core/blitz/applyPitchYawLimits";
|
||||||
import { correctZYTuple } from "../core/blitz/correctZYTuple";
|
|
||||||
import { modelTransformEvent } from "../core/blitzkit/modelTransform";
|
import { modelTransformEvent } from "../core/blitzkit/modelTransform";
|
||||||
import { nameToArmorId } from "../core/blitzkit/nameToArmorId";
|
import { nameToArmorId } from "../core/blitzkit/nameToArmorId";
|
||||||
import { resolveArmor } from "../core/blitzkit/resolveThickness";
|
import { resolveArmor } from "../core/blitzkit/resolveThickness";
|
||||||
@@ -16,6 +15,7 @@ import { useModel } from "../hooks/useModel";
|
|||||||
import { useTankTransform } from "../hooks/useTankTransform";
|
import { useTankTransform } from "../hooks/useTankTransform";
|
||||||
import { Tankopedia } from "../stores/tankopedia";
|
import { Tankopedia } from "../stores/tankopedia";
|
||||||
import { TankopediaPersistent } from "../stores/tankopediaPersistent";
|
import { TankopediaPersistent } from "../stores/tankopediaPersistent";
|
||||||
|
import { toThreeVector } from "../three/toThreeVector";
|
||||||
import { ArmorType } from "./SpacedArmorScene";
|
import { ArmorType } from "./SpacedArmorScene";
|
||||||
import { StaticArmorSceneComponent } from "./StaticArmorSceneComponent";
|
import { StaticArmorSceneComponent } from "./StaticArmorSceneComponent";
|
||||||
|
|
||||||
@@ -44,9 +44,9 @@ export const StaticArmor = memo<ArmorSceneProps>(({ thicknessRange }) => {
|
|||||||
const trackModelDefinition = tankModelDefinition.tracks[track.id];
|
const trackModelDefinition = tankModelDefinition.tracks[track.id];
|
||||||
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
|
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
|
||||||
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
||||||
const hullOrigin = correctZYTuple(trackModelDefinition.origin!);
|
const hullOrigin = toThreeVector(trackModelDefinition.origin);
|
||||||
const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin!);
|
const turretOrigin = toThreeVector(tankModelDefinition.turret_origin);
|
||||||
const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin!);
|
const gunOrigin = toThreeVector(turretModelDefinition.gun_origin);
|
||||||
const canvas = useThree((state) => state.gl.domElement);
|
const canvas = useThree((state) => state.gl.domElement);
|
||||||
|
|
||||||
const maskOrigin =
|
const maskOrigin =
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ export function TankModel() {
|
|||||||
const turretContainer = useRef<Group>(null!);
|
const turretContainer = useRef<Group>(null!);
|
||||||
const gunContainer = useRef<Group>(null!);
|
const gunContainer = useRef<Group>(null!);
|
||||||
const tankModelDefinition = useDuelModel("protagonist");
|
const tankModelDefinition = useDuelModel("protagonist");
|
||||||
|
const trackModelDefinition = tankModelDefinition.tracks[track.id];
|
||||||
const turretModelDefinition = tankModelDefinition.turrets[protagonist.turret];
|
const turretModelDefinition = tankModelDefinition.turrets[protagonist.turret];
|
||||||
const gunModelDefinition = turretModelDefinition.guns[protagonist.gun];
|
const gunModelDefinition = turretModelDefinition.guns[protagonist.gun];
|
||||||
const { gltf } = useModel(protagonist.tank);
|
const { gltf } = useModel(protagonist.tank);
|
||||||
@@ -31,6 +32,18 @@ export function TankModel() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{/* <mesh
|
||||||
|
scale={0.1}
|
||||||
|
position={[
|
||||||
|
trackModelDefinition.origin!.x + tankModelDefinition.turret_origin!.x,
|
||||||
|
trackModelDefinition.origin!.y + tankModelDefinition.turret_origin!.y,
|
||||||
|
trackModelDefinition.origin!.z + tankModelDefinition.turret_origin!.z,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<sphereGeometry />
|
||||||
|
<meshBasicMaterial color="red" depthTest={false} />
|
||||||
|
</mesh> */}
|
||||||
|
|
||||||
{nodes.map((node) => {
|
{nodes.map((node) => {
|
||||||
const isHull = node.name === "hull";
|
const isHull = node.name === "hull";
|
||||||
const isWheel = node.name.startsWith("chassis_wheel_");
|
const isWheel = node.name.startsWith("chassis_wheel_");
|
||||||
@@ -129,7 +142,7 @@ export function TankModel() {
|
|||||||
window.addEventListener("pointerup", handlePointerUp);
|
window.addEventListener("pointerup", handlePointerUp);
|
||||||
}
|
}
|
||||||
function handlePointerMove(event: PointerEvent) {
|
function handlePointerMove(event: PointerEvent) {
|
||||||
const protagonist = useDuel("protagonist", DuelModule.Tank);
|
const protagonist = getDuel("protagonist", DuelModule.Tank);
|
||||||
|
|
||||||
const hasImprovedVerticalStabilizer = hasEquipment(
|
const hasImprovedVerticalStabilizer = hasEquipment(
|
||||||
122,
|
122,
|
||||||
|
|||||||
+4
-4
@@ -1,12 +1,12 @@
|
|||||||
import { useRef } from "react";
|
import { useRef } from "react";
|
||||||
import { Group, ShaderMaterial, UniformsLib, UniformsUtils } from "three";
|
import { Group, ShaderMaterial, UniformsLib, UniformsUtils } from "three";
|
||||||
import { correctZYTuple } from "../../../../../../../core/blitz/correctZYTuple";
|
|
||||||
import { jsxTree } from "../../../../../../../core/blitzkit/jsxTree";
|
import { jsxTree } from "../../../../../../../core/blitzkit/jsxTree";
|
||||||
import { useArmor } from "../../../../../../../hooks/useArmor";
|
import { useArmor } from "../../../../../../../hooks/useArmor";
|
||||||
import { useModel } from "../../../../../../../hooks/useModel";
|
import { useModel } from "../../../../../../../hooks/useModel";
|
||||||
import { useTankModelDefinition } from "../../../../../../../hooks/useTankModelDefinition";
|
import { useTankModelDefinition } from "../../../../../../../hooks/useTankModelDefinition";
|
||||||
import { useTankTransform } from "../../../../../../../hooks/useTankTransform";
|
import { useTankTransform } from "../../../../../../../hooks/useTankTransform";
|
||||||
import { Duel } from "../../../../../../../stores/duel";
|
import { Duel } from "../../../../../../../stores/duel";
|
||||||
|
import { toThreeVector } from "../../../../../../../three/toThreeVector";
|
||||||
import { ModelTankWrapper } from "../../../../../../ModelTankWrapper";
|
import { ModelTankWrapper } from "../../../../../../ModelTankWrapper";
|
||||||
import fragmentShader from "./shaders/fragment.glsl?raw";
|
import fragmentShader from "./shaders/fragment.glsl?raw";
|
||||||
import vertexShader from "./shaders/vertex.glsl?raw";
|
import vertexShader from "./shaders/vertex.glsl?raw";
|
||||||
@@ -37,9 +37,9 @@ export function TransitionSkeleton() {
|
|||||||
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
||||||
const trackModelDefinition = tankModelDefinition.tracks[track.id];
|
const trackModelDefinition = tankModelDefinition.tracks[track.id];
|
||||||
const wrapper = useRef<Group>(null);
|
const wrapper = useRef<Group>(null);
|
||||||
const hullOrigin = correctZYTuple(trackModelDefinition.origin!);
|
const hullOrigin = toThreeVector(trackModelDefinition.origin);
|
||||||
const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin!);
|
const turretOrigin = toThreeVector(tankModelDefinition.turret_origin);
|
||||||
const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin!);
|
const gunOrigin = toThreeVector(turretModelDefinition.gun_origin);
|
||||||
|
|
||||||
useTankTransform(track, turret, turretContainer, gunContainer);
|
useTankTransform(track, turret, turretContainer, gunContainer);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
import type { Vector3 as BlitzkitVector3 } from "@blitzkit/protos";
|
|
||||||
import { Vector3 as THREEVector3 } from "three";
|
|
||||||
import { rotateDavaVector } from "./rotateDavaVector";
|
|
||||||
|
|
||||||
export function correctZYTuple(tuple: BlitzkitVector3) {
|
|
||||||
return rotateDavaVector(new THREEVector3(tuple.x, tuple.y, -tuple.z));
|
|
||||||
}
|
|
||||||
@@ -5,11 +5,11 @@ import type { QuicklimeEvent } from "quicklime";
|
|||||||
import { type RefObject, useEffect } from "react";
|
import { type RefObject, useEffect } from "react";
|
||||||
import { Euler, Group, Vector3 } from "three";
|
import { Euler, Group, Vector3 } from "three";
|
||||||
import { degToRad } from "three/src/math/MathUtils.js";
|
import { degToRad } from "three/src/math/MathUtils.js";
|
||||||
import { correctZYTuple } from "../core/blitz/correctZYTuple";
|
|
||||||
import {
|
import {
|
||||||
modelTransformEvent,
|
modelTransformEvent,
|
||||||
type ModelTransformEventData,
|
type ModelTransformEventData,
|
||||||
} from "../core/blitzkit/modelTransform";
|
} from "../core/blitzkit/modelTransform";
|
||||||
|
import { toThreeVector } from "../three/toThreeVector";
|
||||||
import { useDuelModel } from "./useDuelModel";
|
import { useDuelModel } from "./useDuelModel";
|
||||||
|
|
||||||
export function useTankTransform(
|
export function useTankTransform(
|
||||||
@@ -23,9 +23,9 @@ export function useTankTransform(
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const trackModelDefinition = tankModelDefinition.tracks[track.id];
|
const trackModelDefinition = tankModelDefinition.tracks[track.id];
|
||||||
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
|
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
|
||||||
const hullOrigin = correctZYTuple(trackModelDefinition.origin!);
|
const hullOrigin = toThreeVector(trackModelDefinition.origin);
|
||||||
const turretOrigin = correctZYTuple(tankModelDefinition.turret_origin!);
|
const turretOrigin = toThreeVector(tankModelDefinition.turret_origin);
|
||||||
const gunOrigin = correctZYTuple(turretModelDefinition.gun_origin!);
|
const gunOrigin = toThreeVector(turretModelDefinition.gun_origin);
|
||||||
const turretPosition = new Vector3();
|
const turretPosition = new Vector3();
|
||||||
const turretRotation = new Euler();
|
const turretRotation = new Euler();
|
||||||
const gunPosition = new Vector3();
|
const gunPosition = new Vector3();
|
||||||
@@ -54,14 +54,12 @@ export function useTankTransform(
|
|||||||
gunContainer.current?.position.copy(gunPosition);
|
gunContainer.current?.position.copy(gunPosition);
|
||||||
gunContainer.current?.rotation.copy(gunRotation);
|
gunContainer.current?.rotation.copy(gunRotation);
|
||||||
|
|
||||||
if (yaw === undefined) return;
|
|
||||||
|
|
||||||
turretPosition
|
turretPosition
|
||||||
.set(0, 0, 0)
|
.set(0, 0, 0)
|
||||||
.sub(hullOrigin)
|
.sub(hullOrigin)
|
||||||
.sub(turretOrigin)
|
.sub(turretOrigin)
|
||||||
.applyAxisAngle(new Vector3(0, 0, 1), yaw);
|
.applyAxisAngle(J_HAT, yaw);
|
||||||
turretRotation.set(0, 0, yaw);
|
turretRotation.set(0, yaw, 0);
|
||||||
|
|
||||||
if (tankModelDefinition.initial_turret_rotation) {
|
if (tankModelDefinition.initial_turret_rotation) {
|
||||||
const initialPitch = -degToRad(
|
const initialPitch = -degToRad(
|
||||||
@@ -76,11 +74,11 @@ export function useTankTransform(
|
|||||||
|
|
||||||
turretPosition
|
turretPosition
|
||||||
.applyAxisAngle(I_HAT, initialPitch)
|
.applyAxisAngle(I_HAT, initialPitch)
|
||||||
.applyAxisAngle(J_HAT, initialRoll)
|
.applyAxisAngle(J_HAT, initialYaw)
|
||||||
.applyAxisAngle(K_HAT, initialYaw);
|
.applyAxisAngle(K_HAT, initialRoll);
|
||||||
turretRotation.x += initialPitch;
|
turretRotation.x += initialPitch;
|
||||||
turretRotation.y += initialRoll;
|
turretRotation.y += initialYaw;
|
||||||
turretRotation.z += initialYaw;
|
turretRotation.z += initialRoll;
|
||||||
}
|
}
|
||||||
|
|
||||||
turretPosition.add(turretOrigin).add(hullOrigin);
|
turretPosition.add(turretOrigin).add(hullOrigin);
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import type { Vector3 as BlitzKitVector } from "@blitzkit/protos";
|
||||||
|
import { Vector3 } from "three";
|
||||||
|
|
||||||
|
export function toThreeVector(vector?: BlitzKitVector) {
|
||||||
|
return new Vector3(vector!.x, vector!.y, vector!.z);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user