mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
fix: armor mesh rotation dysync
This commit is contained in:
1 parent
e33ae0f81b
commit
bc211822aa
7 files changed
+17
-24
No files matched your search
@@ -617,6 +617,7 @@ export function Characteristics() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<InfoWithDelta
|
<InfoWithDelta
|
||||||
|
key={`${member.type}-root`}
|
||||||
name={`${CREW_MEMBER_NAMES[member.type]}${count > 1 ? ` x ${count}` : ''}`}
|
name={`${CREW_MEMBER_NAMES[member.type]}${count > 1 ? ` x ${count}` : ''}`}
|
||||||
unit="%"
|
unit="%"
|
||||||
decimals={0}
|
decimals={0}
|
||||||
@@ -627,6 +628,7 @@ export function Characteristics() {
|
|||||||
</InfoWithDelta>
|
</InfoWithDelta>
|
||||||
{member.substitute && (
|
{member.substitute && (
|
||||||
<Info
|
<Info
|
||||||
|
key={`${member.type}-substitute`}
|
||||||
indent
|
indent
|
||||||
name={
|
name={
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ export function Controls() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
camera.position.set(-4, 4, -16);
|
camera.position.set(-4, 4, -16);
|
||||||
orbitControls.current?.target.set(0, antagonistGunHeight / 2, 0);
|
orbitControls.current?.target.set(0, 1.25, 0);
|
||||||
|
|
||||||
const unsubscribeTankopedia = useTankopediaPersistent.subscribe(
|
const unsubscribeTankopedia = useTankopediaPersistent.subscribe(
|
||||||
(state) => state.model.visual.controlsEnabled,
|
(state) => state.model.visual.controlsEnabled,
|
||||||
@@ -135,7 +135,7 @@ export function Controls() {
|
|||||||
|
|
||||||
case Pose.Default: {
|
case Pose.Default: {
|
||||||
camera.position.set(-4, 4, -16);
|
camera.position.set(-4, 4, -16);
|
||||||
orbitControls.current?.target.set(0, antagonistGunHeight / 2, 0);
|
orbitControls.current?.target.set(0, 1.25, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -87,14 +87,14 @@ export function ArmorHighlighting() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
handleModelTransform(useDuel.getState().protagonist!);
|
handleModelTransform(protagonist);
|
||||||
modelTransformEvent.on(handleModelTransform);
|
modelTransformEvent.on(handleModelTransform);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
modelTransformEvent.off(handleModelTransform);
|
modelTransformEvent.off(handleModelTransform);
|
||||||
unsubscribe();
|
unsubscribe();
|
||||||
};
|
};
|
||||||
}, []);
|
});
|
||||||
|
|
||||||
const armorGltf = useArmor(protagonist.tank.id);
|
const armorGltf = useArmor(protagonist.tank.id);
|
||||||
const armorNodes = Object.values(armorGltf.nodes);
|
const armorNodes = Object.values(armorGltf.nodes);
|
||||||
|
|||||||
+1
-1
@@ -102,7 +102,7 @@ export const ExternalModuleMask = memo<ExternalModuleMaskProps>(
|
|||||||
turretContainer.current?.rotation.copy(turretRotation);
|
turretContainer.current?.rotation.copy(turretRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleModelTransform(useDuel.getState().protagonist!);
|
handleModelTransform(protagonist);
|
||||||
modelTransformEvent.on(handleModelTransform);
|
modelTransformEvent.on(handleModelTransform);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
+1
-1
@@ -108,7 +108,7 @@ export const SpacedArmorDepth = memo<SpacedArmorDepthProps>(
|
|||||||
turretContainer.current?.rotation.copy(turretRotation);
|
turretContainer.current?.rotation.copy(turretRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleModelTransform(useDuel.getState().protagonist!);
|
handleModelTransform(protagonist);
|
||||||
modelTransformEvent.on(handleModelTransform);
|
modelTransformEvent.on(handleModelTransform);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
@@ -1,19 +1,17 @@
|
|||||||
import { ThreeEvent, useThree } from '@react-three/fiber';
|
import { ThreeEvent, useThree } from '@react-three/fiber';
|
||||||
import { memo, useEffect, useRef, useState } from 'react';
|
import { memo, useEffect, useRef } from 'react';
|
||||||
import { Euler, Group, Vector3 } from 'three';
|
import { Euler, Group, Vector3 } from 'three';
|
||||||
import { degToRad } from 'three/src/math/MathUtils';
|
import { degToRad } from 'three/src/math/MathUtils';
|
||||||
import { I_HAT, J_HAT, K_HAT } from '../../../../../../../constants/axis';
|
import { I_HAT, J_HAT, K_HAT } from '../../../../../../../constants/axis';
|
||||||
import { applyPitchYawLimits } from '../../../../../../../core/blitz/applyPitchYawLimits';
|
import { applyPitchYawLimits } from '../../../../../../../core/blitz/applyPitchYawLimits';
|
||||||
import { jsxTree } from '../../../../../../../core/blitzkrieg/jsxTree';
|
import { jsxTree } from '../../../../../../../core/blitzkrieg/jsxTree';
|
||||||
import {
|
import { modelDefinitions } from '../../../../../../../core/blitzkrieg/modelDefinitions';
|
||||||
ModelDefinitions,
|
|
||||||
modelDefinitions,
|
|
||||||
} from '../../../../../../../core/blitzkrieg/modelDefinitions';
|
|
||||||
import {
|
import {
|
||||||
ModelTransformEventData,
|
ModelTransformEventData,
|
||||||
modelTransformEvent,
|
modelTransformEvent,
|
||||||
} from '../../../../../../../core/blitzkrieg/modelTransform';
|
} from '../../../../../../../core/blitzkrieg/modelTransform';
|
||||||
import { normalizeAnglePI } from '../../../../../../../core/math/normalizeAngle180';
|
import { normalizeAnglePI } from '../../../../../../../core/math/normalizeAngle180';
|
||||||
|
import { useAwait } from '../../../../../../../hooks/useAwait';
|
||||||
import { useModel } from '../../../../../../../hooks/useModel';
|
import { useModel } from '../../../../../../../hooks/useModel';
|
||||||
import { mutateDuel, useDuel } from '../../../../../../../stores/duel';
|
import { mutateDuel, useDuel } from '../../../../../../../stores/duel';
|
||||||
import mutateTankopediaPersistent, {
|
import mutateTankopediaPersistent, {
|
||||||
@@ -21,9 +19,7 @@ import mutateTankopediaPersistent, {
|
|||||||
} from '../../../../../../../stores/tankopedia';
|
} from '../../../../../../../stores/tankopedia';
|
||||||
|
|
||||||
export const TankModel = memo(() => {
|
export const TankModel = memo(() => {
|
||||||
const [awaitedModelDefinitions, setAwaitedModelDefinitions] = useState<
|
const awaitedModelDefinitions = useAwait(modelDefinitions);
|
||||||
ModelDefinitions | undefined
|
|
||||||
>(undefined);
|
|
||||||
const protagonist = useDuel((draft) => draft.protagonist!);
|
const protagonist = useDuel((draft) => draft.protagonist!);
|
||||||
const canvas = useThree((state) => state.gl.domElement);
|
const canvas = useThree((state) => state.gl.domElement);
|
||||||
const hullContainer = useRef<Group>(null);
|
const hullContainer = useRef<Group>(null);
|
||||||
@@ -31,14 +27,6 @@ export const TankModel = memo(() => {
|
|||||||
const gunContainer = useRef<Group>(null);
|
const gunContainer = useRef<Group>(null);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
|
||||||
setAwaitedModelDefinitions(await modelDefinitions);
|
|
||||||
})();
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (!awaitedModelDefinitions) return;
|
|
||||||
|
|
||||||
const hullOrigin = new Vector3(
|
const hullOrigin = new Vector3(
|
||||||
trackModelDefinition.origin[0],
|
trackModelDefinition.origin[0],
|
||||||
trackModelDefinition.origin[1],
|
trackModelDefinition.origin[1],
|
||||||
@@ -103,6 +91,7 @@ export const TankModel = memo(() => {
|
|||||||
turretContainer.current?.rotation.copy(turretRotation);
|
turretContainer.current?.rotation.copy(turretRotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleModelTransform(protagonist);
|
||||||
modelTransformEvent.on(handleModelTransform);
|
modelTransformEvent.on(handleModelTransform);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { MeshProps } from '@react-three/fiber';
|
import { MeshProps } from '@react-three/fiber';
|
||||||
import { Mesh, Object3D } from 'three';
|
import { Mesh, Object3D } from 'three';
|
||||||
|
|
||||||
export function jsxTree(node: Object3D, mesh?: MeshProps) {
|
export function jsxTree(node: Object3D, mesh?: MeshProps, key?: string) {
|
||||||
if (node instanceof Mesh) {
|
if (node instanceof Mesh) {
|
||||||
return (
|
return (
|
||||||
<mesh
|
<mesh
|
||||||
|
key={key}
|
||||||
geometry={node.geometry}
|
geometry={node.geometry}
|
||||||
material={node.material}
|
material={node.material}
|
||||||
position={node.position}
|
position={node.position}
|
||||||
@@ -16,11 +17,12 @@ export function jsxTree(node: Object3D, mesh?: MeshProps) {
|
|||||||
} else if (node instanceof Object3D) {
|
} else if (node instanceof Object3D) {
|
||||||
return (
|
return (
|
||||||
<group
|
<group
|
||||||
|
key={key}
|
||||||
position={node.position}
|
position={node.position}
|
||||||
rotation={node.rotation}
|
rotation={node.rotation}
|
||||||
scale={node.scale}
|
scale={node.scale}
|
||||||
>
|
>
|
||||||
{node.children.map((child) => jsxTree(child, mesh))}
|
{node.children.map((child) => jsxTree(child, mesh, child.uuid))}
|
||||||
</group>
|
</group>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user