mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-12-01 13:55:01 +01:00
Merge branch 'main' into data-driven
This commit is contained in:
34 files changed
+927
-933
No files matched your search
@@ -16,9 +16,11 @@ Pages that are not migrated yet are named `_index.astro` so Astro skips them. Mi
|
|||||||
|
|
||||||
- Components live flat at `src/components/Name/index.tsx` with `index.module.css` beside it. No flat `Name.tsx` files and no nested `components/Parent/components/Child` folders: a sub-component becomes its own top-level folder prefixed with its feature, e.g. `MixerScene/components/Model.tsx` becomes `components/MixerModel/index.tsx`.
|
- Components live flat at `src/components/Name/index.tsx` with `index.module.css` beside it. No flat `Name.tsx` files and no nested `components/Parent/components/Child` folders: a sub-component becomes its own top-level folder prefixed with its feature, e.g. `MixerScene/components/Model.tsx` becomes `components/MixerModel/index.tsx`.
|
||||||
- Pages keep their styles in `_index.module.css` next to `_index.tsx`.
|
- Pages keep their styles in `_index.module.css` next to `_index.tsx`.
|
||||||
|
- Hooks live in `src/hooks/useName.ts` (`.tsx` if they render JSX), one hook per file named after it, never inside a component's folder.
|
||||||
|
|
||||||
## TypeScript
|
## TypeScript
|
||||||
|
|
||||||
|
- When an `if`/`else if` chain checks one value against several candidates (`x === "a"`, `x === b`, ...), use a `switch` on that value instead. Inside a loop, end each case with `continue`, and put the checks a `switch` can't express (`startsWith`, ranges, ...) as an `if` after it, not in `default`.
|
||||||
- No return type annotations. Put `satisfies Type` on the returned expression instead.
|
- No return type annotations. Put `satisfies Type` on the returned expression instead.
|
||||||
- Wrap functions defined inside React components in `useCallback`.
|
- Wrap functions defined inside React components in `useCallback`.
|
||||||
- Never inline a complex type (a union of object shapes, etc.) in a signature; name it as an interface or type.
|
- Never inline a complex type (a union of object shapes, etc.) in a signature; name it as an interface or type.
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# BlitzKit 1.33.1
|
||||||
|
|
||||||
|
Thank you to [HitJack](https://github.com/Hitjack007) for your contributions this update.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Legendary camouflages in Tankopedia are now animated and loop their garage animations [HitJack]
|
||||||
|
- Tankopedia's 3D viewer is now much faster as tank models, armor, and legendary camouflages are drawn in batches
|
||||||
|
- Shadows are now only redrawn when something in the scene changes instead of every frame, saving battery and GPU time
|
||||||
|
|
||||||
|
## Fixes
|
||||||
|
|
||||||
|
- Unused parts of legendary camouflages are now hidden, fixing camouflages like the Maus' [HitJack]
|
||||||
|
- Legendary camouflage parts with no LODs are no longer missing, like the Tiger II's cat and the BDT-5A's engine rings [HitJack]
|
||||||
|
- The ground in Tankopedia is no longer transparent, so it fades out cleanly instead of blending with things behind it
|
||||||
|
|
||||||
|
## Technical Changes
|
||||||
|
|
||||||
|
- Tank and legendary camouflage models build much faster thanks to a faster DDS decoder and native CRC32 checksums [HitJack]
|
||||||
|
- The game client is now downloaded from Wargaming Game Center by default
|
||||||
|
- Added a zip-backed virtual file system for reading game files
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "blitzkit",
|
"name": "blitzkit",
|
||||||
"version": "1.33.0",
|
"version": "1.33.1",
|
||||||
"license": "BlitzKit License",
|
"license": "BlitzKit License",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@@ -0,0 +1,68 @@
|
|||||||
|
import { invalidate } from "@react-three/fiber";
|
||||||
|
import { useEffect, useMemo, type ComponentProps } from "react";
|
||||||
|
import { BatchedMesh, Color, type Matrix4, type Mesh } from "three";
|
||||||
|
import { sceneChangeEvent } from "../../core/three/sceneChange";
|
||||||
|
|
||||||
|
export interface BatchItem {
|
||||||
|
mesh: Mesh;
|
||||||
|
matrix: Matrix4;
|
||||||
|
// red channel of the instance color, read in shaders with getBatchingColor
|
||||||
|
thickness?: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
type BatchProps = Omit<ComponentProps<"primitive">, "object"> & {
|
||||||
|
items: BatchItem[];
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One draw call for all items. Only the geometry is memoized, on the identity
|
||||||
|
* of items; material, renderOrder, shadows, events and so on are plain props.
|
||||||
|
*/
|
||||||
|
export function Batch({ items, ...props }: BatchProps) {
|
||||||
|
const batch = useMemo(() => {
|
||||||
|
if (items.length === 0) return null;
|
||||||
|
|
||||||
|
let vertices = 0;
|
||||||
|
let indices = 0;
|
||||||
|
|
||||||
|
for (const { mesh } of items) {
|
||||||
|
vertices += mesh.geometry.attributes.position.count;
|
||||||
|
indices += mesh.geometry.index!.count;
|
||||||
|
}
|
||||||
|
|
||||||
|
const batch = new BatchedMesh(items.length, vertices, indices);
|
||||||
|
const color = new Color();
|
||||||
|
|
||||||
|
// otherwise the draw list is re-culled, re-sorted and re-uploaded every draw
|
||||||
|
batch.perObjectFrustumCulled = false;
|
||||||
|
batch.sortObjects = false;
|
||||||
|
|
||||||
|
for (const { mesh, matrix, thickness } of items) {
|
||||||
|
const instanceId = batch.addInstance(batch.addGeometry(mesh.geometry));
|
||||||
|
|
||||||
|
batch.setMatrixAt(instanceId, matrix);
|
||||||
|
|
||||||
|
if (thickness !== undefined) {
|
||||||
|
batch.setColorAt(instanceId, color.setRGB(thickness, 0, 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return batch;
|
||||||
|
}, [items]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!batch) return;
|
||||||
|
|
||||||
|
invalidate();
|
||||||
|
sceneChangeEvent.dispatch();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
batch.dispose();
|
||||||
|
sceneChangeEvent.dispatch();
|
||||||
|
};
|
||||||
|
}, [batch]);
|
||||||
|
|
||||||
|
if (!batch) return null;
|
||||||
|
|
||||||
|
return <primitive object={batch} {...props} />;
|
||||||
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
import { blueDark, orangeDark } from "@radix-ui/colors";
|
import { blueDark, orangeDark } from "@radix-ui/colors";
|
||||||
import { ContactShadows } from "@react-three/drei";
|
|
||||||
import { invalidate, useFrame } from "@react-three/fiber";
|
import { invalidate, useFrame } from "@react-three/fiber";
|
||||||
import { clamp, times } from "lodash-es";
|
import { clamp, times } from "lodash-es";
|
||||||
import { Quicklime } from "quicklime";
|
import { Quicklime } from "quicklime";
|
||||||
@@ -12,9 +11,12 @@ import {
|
|||||||
} from "react";
|
} from "react";
|
||||||
import { HemisphereLight, SpotLight, type Group } from "three";
|
import { HemisphereLight, SpotLight, type Group } from "three";
|
||||||
import { degToRad, lerp } from "three/src/math/MathUtils.js";
|
import { degToRad, lerp } from "three/src/math/MathUtils.js";
|
||||||
|
import { sceneChangeEvent } from "../core/three/sceneChange";
|
||||||
|
import { useShadowsOnDemand } from "../hooks/useShadowsOnDemand";
|
||||||
import { Tankopedia } from "../stores/tankopedia";
|
import { Tankopedia } from "../stores/tankopedia";
|
||||||
import { TankopediaPersistent } from "../stores/tankopediaPersistent";
|
import { TankopediaPersistent } from "../stores/tankopediaPersistent";
|
||||||
import { TankopediaDisplay } from "../stores/tankopediaPersistent/constants";
|
import { TankopediaDisplay } from "../stores/tankopediaPersistent/constants";
|
||||||
|
import { TankopediaContactShadows } from "./TankopediaContactShadows";
|
||||||
|
|
||||||
const ANGLE = degToRad(15);
|
const ANGLE = degToRad(15);
|
||||||
const REVEAL_ANIMATION_TIME = 3;
|
const REVEAL_ANIMATION_TIME = 3;
|
||||||
@@ -66,6 +68,10 @@ export function Lighting({ hasPbr, hidden = false }: Props) {
|
|||||||
|
|
||||||
const [animate, setAnimate] = useState(true);
|
const [animate, setAnimate] = useState(true);
|
||||||
|
|
||||||
|
useShadowsOnDemand();
|
||||||
|
|
||||||
|
useEffect(() => sceneChangeEvent.dispatch(), [highGraphics]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Tankopedia.mutate((draft) => {
|
Tankopedia.mutate((draft) => {
|
||||||
draft.showControls = true;
|
draft.showControls = true;
|
||||||
@@ -118,17 +124,7 @@ export function Lighting({ hasPbr, hidden = false }: Props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ContactShadows
|
<TankopediaContactShadows />
|
||||||
width={1.5}
|
|
||||||
height={1.5}
|
|
||||||
near={0}
|
|
||||||
far={1}
|
|
||||||
opacity={2 ** 1}
|
|
||||||
blur={2 ** 1}
|
|
||||||
resolution={2 ** 9}
|
|
||||||
depthWrite={false}
|
|
||||||
renderOrder={1}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{animate && (
|
{animate && (
|
||||||
<Animator
|
<Animator
|
||||||
@@ -234,6 +230,8 @@ function Animator({
|
|||||||
}
|
}
|
||||||
|
|
||||||
transitionEvent.dispatch(t);
|
transitionEvent.dispatch(t);
|
||||||
|
// spotlight angles shape their shadows
|
||||||
|
sceneChangeEvent.dispatch();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useFrame(({ invalidate }) => {
|
useFrame(({ invalidate }) => {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
type ModelTransformEventData,
|
type ModelTransformEventData,
|
||||||
} from "../../core/blitzkit/modelTransform";
|
} from "../../core/blitzkit/modelTransform";
|
||||||
import { controlsEnabledEvent } from "../../core/controlsEnabled";
|
import { controlsEnabledEvent } from "../../core/controlsEnabled";
|
||||||
|
import { sceneChangeEvent } from "../../core/three/sceneChange";
|
||||||
import { useModel } from "../../hooks/useModel";
|
import { useModel } from "../../hooks/useModel";
|
||||||
import { Mixer } from "../../stores/mixer";
|
import { Mixer } from "../../stores/mixer";
|
||||||
|
|
||||||
@@ -83,6 +84,8 @@ export function MixerModel() {
|
|||||||
window.removeEventListener("pointerup", handlePointerUp);
|
window.removeEventListener("pointerup", handlePointerUp);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => sceneChangeEvent.dispatch(), [hull, turret, gun]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function handleModelTransform(
|
function handleModelTransform(
|
||||||
event: QuicklimeEvent<ModelTransformEventData>,
|
event: QuicklimeEvent<ModelTransformEventData>,
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import { memo, useRef } from "react";
|
import { memo, useRef } from "react";
|
||||||
import { Group } from "three";
|
import { Group } from "three";
|
||||||
import { nameToArmorId } from "../core/blitzkit/nameToArmorId";
|
import { useArmorPlates } from "../hooks/useArmorPlates";
|
||||||
import { resolveArmor } from "../core/blitzkit/resolveThickness";
|
|
||||||
import { useArmor } from "../hooks/useArmor";
|
|
||||||
import { useConsumable } from "../hooks/useConsumable";
|
import { useConsumable } from "../hooks/useConsumable";
|
||||||
import { useDuelModels } from "../hooks/useDuelModels";
|
import { useDuelModels } from "../hooks/useDuelModels";
|
||||||
import { useDuelModules } from "../hooks/useDuelModules";
|
import { useDuelModules } from "../hooks/useDuelModules";
|
||||||
@@ -14,14 +12,15 @@ export const PrimaryArmorScene = memo(() => {
|
|||||||
const turretContainer = useRef<Group>(null!);
|
const turretContainer = useRef<Group>(null!);
|
||||||
const gunContainer = useRef<Group>(null!);
|
const gunContainer = useRef<Group>(null!);
|
||||||
const protagonist = useDuelModules("protagonist");
|
const protagonist = useDuelModules("protagonist");
|
||||||
const armorGltf = useArmor(protagonist.tank.id).gltf;
|
|
||||||
const armorNodes = Object.values(armorGltf.nodes);
|
|
||||||
const models = useDuelModels("protagonist");
|
const models = useDuelModels("protagonist");
|
||||||
const hullOrigin = toThreeVector(models.track.origin);
|
const hullOrigin = toThreeVector(models.track.origin);
|
||||||
const turretOrigin = toThreeVector(models.tank.turret_origin);
|
const turretOrigin = toThreeVector(models.tank.turret_origin);
|
||||||
const gunOrigin = toThreeVector(models.turret.gun_origin);
|
const gunOrigin = toThreeVector(models.turret.gun_origin);
|
||||||
const isDynamicArmorActive = useConsumable("protagonist", 73);
|
const isDynamicArmorActive = useConsumable("protagonist", 73);
|
||||||
|
|
||||||
|
const hiddenState = isDynamicArmorActive ? "state_01" : "state_00";
|
||||||
|
const plates = useArmorPlates(hiddenState);
|
||||||
|
|
||||||
useTankTransform(
|
useTankTransform(
|
||||||
protagonist.track,
|
protagonist.track,
|
||||||
protagonist.turret,
|
protagonist.turret,
|
||||||
@@ -32,100 +31,22 @@ export const PrimaryArmorScene = memo(() => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<group position={hullOrigin}>
|
<group position={hullOrigin}>
|
||||||
{armorNodes.map((node) => {
|
<PrimaryArmorSceneComponent plates={plates.hull.primary} />
|
||||||
const isHull = node.name.startsWith("hull_");
|
|
||||||
const isVisible = isHull;
|
|
||||||
const armorId = nameToArmorId(node.name);
|
|
||||||
const { spaced, thickness } = resolveArmor(
|
|
||||||
models.tank.armor!,
|
|
||||||
armorId,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (
|
|
||||||
!isVisible ||
|
|
||||||
spaced ||
|
|
||||||
thickness === undefined ||
|
|
||||||
(isDynamicArmorActive && node.name.includes("state_01")) ||
|
|
||||||
(!isDynamicArmorActive && node.name.includes("state_00"))
|
|
||||||
)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<PrimaryArmorSceneComponent
|
|
||||||
key={node.uuid}
|
|
||||||
thickness={thickness}
|
|
||||||
node={node}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
<group ref={turretContainer}>
|
<group ref={turretContainer}>
|
||||||
{armorNodes.map((node) => {
|
<group position={hullOrigin}>
|
||||||
const isCurrentTurret = node.name.startsWith(
|
|
||||||
`turret_${models.turret.model_id.toString().padStart(2, "0")}`,
|
|
||||||
);
|
|
||||||
const isVisible = isCurrentTurret;
|
|
||||||
const armorId = nameToArmorId(node.name);
|
|
||||||
const { spaced, thickness } = resolveArmor(
|
|
||||||
models.turret.armor!,
|
|
||||||
armorId,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (
|
|
||||||
!isVisible ||
|
|
||||||
spaced ||
|
|
||||||
thickness === undefined ||
|
|
||||||
(isDynamicArmorActive && node.name.includes("state_01")) ||
|
|
||||||
(!isDynamicArmorActive && node.name.includes("state_00"))
|
|
||||||
)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<group position={hullOrigin} key={node.uuid}>
|
|
||||||
<group position={turretOrigin}>
|
<group position={turretOrigin}>
|
||||||
<PrimaryArmorSceneComponent
|
<PrimaryArmorSceneComponent plates={plates.turret.primary} />
|
||||||
key={node.uuid}
|
|
||||||
thickness={thickness}
|
|
||||||
node={node}
|
|
||||||
/>
|
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
);
|
|
||||||
})}
|
|
||||||
|
|
||||||
<group ref={gunContainer}>
|
<group ref={gunContainer}>
|
||||||
{armorNodes.map((node) => {
|
<group position={hullOrigin}>
|
||||||
const isCurrentGun = node.name.startsWith(
|
|
||||||
`gun_${models.gun.model_id.toString().padStart(2, "0")}`,
|
|
||||||
);
|
|
||||||
const isVisible = isCurrentGun;
|
|
||||||
const armorId = nameToArmorId(node.name);
|
|
||||||
const { spaced, thickness } = resolveArmor(
|
|
||||||
models.gun.armor!,
|
|
||||||
armorId,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (
|
|
||||||
!isVisible ||
|
|
||||||
spaced ||
|
|
||||||
thickness === undefined ||
|
|
||||||
(isDynamicArmorActive && node.name.includes("state_01")) ||
|
|
||||||
(!isDynamicArmorActive && node.name.includes("state_00"))
|
|
||||||
)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<group position={hullOrigin} key={node.uuid}>
|
|
||||||
<group position={turretOrigin.clone().add(gunOrigin)}>
|
<group position={turretOrigin.clone().add(gunOrigin)}>
|
||||||
<PrimaryArmorSceneComponent
|
<PrimaryArmorSceneComponent plates={plates.gun.primary} />
|
||||||
thickness={thickness}
|
|
||||||
node={node}
|
|
||||||
/>
|
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
);
|
|
||||||
})}
|
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { useEffect, useRef } from "react";
|
|||||||
import {
|
import {
|
||||||
MeshBasicMaterial,
|
MeshBasicMaterial,
|
||||||
NormalBlending,
|
NormalBlending,
|
||||||
Object3D,
|
|
||||||
ShaderMaterial,
|
ShaderMaterial,
|
||||||
SubtractiveBlending,
|
SubtractiveBlending,
|
||||||
UniformsLib,
|
UniformsLib,
|
||||||
@@ -14,19 +13,20 @@ import {
|
|||||||
Vector2,
|
Vector2,
|
||||||
} from "three";
|
} from "three";
|
||||||
import { degToRad } from "three/src/math/MathUtils.js";
|
import { degToRad } from "three/src/math/MathUtils.js";
|
||||||
import { jsxTree } from "../../core/blitzkit/jsxTree";
|
import type { ArmorPlate } from "../../hooks/useArmorPlates";
|
||||||
import { getDuelModules } from "../../hooks/useDuelModules";
|
import { getDuelModules } from "../../hooks/useDuelModules";
|
||||||
import { hasEquipment } from "../../hooks/useEquipment";
|
import { hasEquipment } from "../../hooks/useEquipment";
|
||||||
|
import { usePlateItems } from "../../hooks/usePlateItems";
|
||||||
import { Tankopedia } from "../../stores/tankopedia";
|
import { Tankopedia } from "../../stores/tankopedia";
|
||||||
import { TankopediaPersistent } from "../../stores/tankopediaPersistent";
|
import { TankopediaPersistent } from "../../stores/tankopediaPersistent";
|
||||||
|
import { Batch } from "../Batch";
|
||||||
import { transitionEvent } from "../Lighting";
|
import { transitionEvent } from "../Lighting";
|
||||||
import { spacedArmorRenderTarget } from "../PrimaryArmorRenderTarget";
|
import { spacedArmorRenderTarget } from "../PrimaryArmorRenderTarget";
|
||||||
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";
|
||||||
|
|
||||||
interface PrimaryArmorSceneComponentProps {
|
interface PrimaryArmorSceneComponentProps {
|
||||||
thickness: number;
|
plates: ArmorPlate[];
|
||||||
node: Object3D;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const excludeMaterial = new MeshBasicMaterial({
|
const excludeMaterial = new MeshBasicMaterial({
|
||||||
@@ -37,8 +37,7 @@ const date = new Date();
|
|||||||
const isHalloween = date.getMonth() === 9 && date.getDate() === 31;
|
const isHalloween = date.getMonth() === 9 && date.getDate() === 31;
|
||||||
|
|
||||||
export function PrimaryArmorSceneComponent({
|
export function PrimaryArmorSceneComponent({
|
||||||
node,
|
plates,
|
||||||
thickness,
|
|
||||||
}: PrimaryArmorSceneComponentProps) {
|
}: PrimaryArmorSceneComponentProps) {
|
||||||
const material = useRef(
|
const material = useRef(
|
||||||
new ShaderMaterial({
|
new ShaderMaterial({
|
||||||
@@ -55,7 +54,7 @@ export function PrimaryArmorSceneComponent({
|
|||||||
UniformsLib.fog,
|
UniformsLib.fog,
|
||||||
|
|
||||||
{
|
{
|
||||||
thickness: { value: null },
|
thicknessCoefficient: { value: null },
|
||||||
penetration: { value: null },
|
penetration: { value: null },
|
||||||
caliber: { value: null },
|
caliber: { value: null },
|
||||||
ricochet: { value: null },
|
ricochet: { value: null },
|
||||||
@@ -129,8 +128,8 @@ export function PrimaryArmorSceneComponent({
|
|||||||
? protagonist.equalizer?.armor
|
? protagonist.equalizer?.armor
|
||||||
: undefined) ?? 1;
|
: undefined) ?? 1;
|
||||||
|
|
||||||
material.current.uniforms.thickness.value =
|
material.current.uniforms.thicknessCoefficient.value =
|
||||||
thickness * (hasEnhancedArmor ? 1.04 : 1) * equalizer;
|
(hasEnhancedArmor ? 1.04 : 1) * equalizer;
|
||||||
|
|
||||||
if (!noInvalidate) invalidate();
|
if (!noInvalidate) invalidate();
|
||||||
}
|
}
|
||||||
@@ -223,32 +222,12 @@ export function PrimaryArmorSceneComponent({
|
|||||||
camera.projectionMatrixInverse;
|
camera.projectionMatrixInverse;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const items = usePlateItems(plates);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{jsxTree(node, {
|
<Batch items={items} material={excludeMaterial} renderOrder={0} />
|
||||||
mesh(_, props, key) {
|
<Batch items={items} material={material.current} renderOrder={1} />
|
||||||
return (
|
|
||||||
<mesh
|
|
||||||
{...props}
|
|
||||||
key={`${key}-exclude`}
|
|
||||||
renderOrder={0}
|
|
||||||
material={excludeMaterial}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
})}
|
|
||||||
{jsxTree(node, {
|
|
||||||
mesh(_, props, key) {
|
|
||||||
return (
|
|
||||||
<mesh
|
|
||||||
{...props}
|
|
||||||
key={`${key}-include`}
|
|
||||||
renderOrder={1}
|
|
||||||
material={material.current}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
})}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -4,7 +4,8 @@ varying vec3 vNormal;
|
|||||||
varying vec3 vViewPosition;
|
varying vec3 vViewPosition;
|
||||||
|
|
||||||
uniform float opacity;
|
uniform float opacity;
|
||||||
uniform float thickness;
|
uniform float thicknessCoefficient;
|
||||||
|
varying float vThickness;
|
||||||
uniform float penetration;
|
uniform float penetration;
|
||||||
uniform float caliber;
|
uniform float caliber;
|
||||||
uniform float ricochet;
|
uniform float ricochet;
|
||||||
@@ -43,6 +44,8 @@ vec3 getPenetrationColor(bool isThreeCalibersRule, bool couldHaveRicochet) {
|
|||||||
void main() {
|
void main() {
|
||||||
#include <clipping_planes_fragment>
|
#include <clipping_planes_fragment>
|
||||||
|
|
||||||
|
float thickness = vThickness * thicknessCoefficient;
|
||||||
|
|
||||||
vec2 screenCoord = gl_FragCoord.xy / resolution;
|
vec2 screenCoord = gl_FragCoord.xy / resolution;
|
||||||
vec4 spacedArmorData = texture2D(spacedArmorBuffer, screenCoord);
|
vec4 spacedArmorData = texture2D(spacedArmorBuffer, screenCoord);
|
||||||
bool isUnderSpacedArmor = spacedArmorData.a != 0.0;
|
bool isUnderSpacedArmor = spacedArmorData.a != 0.0;
|
||||||
|
|||||||
@@ -2,12 +2,31 @@ precision mediump float;
|
|||||||
|
|
||||||
varying vec3 vNormal;
|
varying vec3 vNormal;
|
||||||
varying vec3 vViewPosition;
|
varying vec3 vViewPosition;
|
||||||
|
varying float vThickness;
|
||||||
|
|
||||||
|
#include <batching_pars_vertex>
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
|
vec4 localPosition = vec4(position, 1.0);
|
||||||
|
vec3 localNormal = normal;
|
||||||
|
|
||||||
|
#ifdef USE_BATCHING
|
||||||
|
#include <batching_vertex>
|
||||||
|
|
||||||
|
localPosition = batchingMatrix * localPosition;
|
||||||
|
localNormal = normalize(mat3(batchingMatrix) * localNormal);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_BATCHING_COLOR
|
||||||
|
vThickness = getBatchingColor(getIndirectIndex(gl_DrawID)).r;
|
||||||
|
#else
|
||||||
|
vThickness = 0.0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
vec4 mvPosition = modelViewMatrix * localPosition;
|
||||||
|
|
||||||
vViewPosition = mvPosition.xyz;
|
vViewPosition = mvPosition.xyz;
|
||||||
vNormal = normalMatrix * normal;
|
vNormal = normalMatrix * localNormal;
|
||||||
|
|
||||||
gl_Position = projectionMatrix * mvPosition;
|
gl_Position = projectionMatrix * mvPosition;
|
||||||
}
|
}
|
||||||
@@ -54,8 +54,6 @@ export function SceneProps({ color = mauveDark.mauve6 }: SceneProps) {
|
|||||||
"#include <dithering_fragment>",
|
"#include <dithering_fragment>",
|
||||||
|
|
||||||
`
|
`
|
||||||
#include <dithering_fragment>
|
|
||||||
|
|
||||||
vec3 scaled = vWorldPosition / size;
|
vec3 scaled = vWorldPosition / size;
|
||||||
float radius = length(scaled.xz);
|
float radius = length(scaled.xz);
|
||||||
|
|
||||||
@@ -67,6 +65,9 @@ export function SceneProps({ color = mauveDark.mauve6 }: SceneProps) {
|
|||||||
float y = x * x;
|
float y = x * x;
|
||||||
|
|
||||||
gl_FragColor.rgb *= y;
|
gl_FragColor.rgb *= y;
|
||||||
|
|
||||||
|
// after the falloff, so its gradient doesn't band
|
||||||
|
#include <dithering_fragment>
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -85,6 +86,7 @@ export function SceneProps({ color = mauveDark.mauve6 }: SceneProps) {
|
|||||||
<meshStandardMaterial
|
<meshStandardMaterial
|
||||||
color={color}
|
color={color}
|
||||||
roughness={1}
|
roughness={1}
|
||||||
|
dithering
|
||||||
onBeforeCompile={handleBeforeCompile}
|
onBeforeCompile={handleBeforeCompile}
|
||||||
/>
|
/>
|
||||||
</mesh>
|
</mesh>
|
||||||
|
|||||||
@@ -1,15 +1,19 @@
|
|||||||
import { memo, useRef } from "react";
|
import { memo, useMemo, useRef } from "react";
|
||||||
import { Group, Plane, Scene, Vector3 } from "three";
|
import { Group, Plane, Scene, Vector3, type Object3D } from "three";
|
||||||
import { nameToArmorId } from "../core/blitzkit/nameToArmorId";
|
import { type ArmorPlate, useArmorPlates } from "../hooks/useArmorPlates";
|
||||||
import { resolveArmor } from "../core/blitzkit/resolveThickness";
|
|
||||||
import { useArmor } from "../hooks/useArmor";
|
|
||||||
import { useConsumable } from "../hooks/useConsumable";
|
import { useConsumable } from "../hooks/useConsumable";
|
||||||
import { useDuelModels } from "../hooks/useDuelModels";
|
import { useDuelModels } from "../hooks/useDuelModels";
|
||||||
import { useDuelModules } from "../hooks/useDuelModules";
|
import { useDuelModules } from "../hooks/useDuelModules";
|
||||||
import { useModel } from "../hooks/useModel";
|
import { useModelNodes } from "../hooks/useModelNodes";
|
||||||
import { useTankTransform } from "../hooks/useTankTransform";
|
import { useTankTransform } from "../hooks/useTankTransform";
|
||||||
import { toThreeVector } from "../three/toThreeVector";
|
import { toThreeVector } from "../three/toThreeVector";
|
||||||
import { SpacedArmorSceneComponent } from "./SpacedArmorSceneComponent";
|
import {
|
||||||
|
SpacedArmorSceneComponent,
|
||||||
|
type ExternalModuleVariant,
|
||||||
|
} from "./SpacedArmorSceneComponent";
|
||||||
|
import { SpacedArmorSubExternal } from "./SpacedArmorSubExternal";
|
||||||
|
import { SpacedArmorSubPrimary } from "./SpacedArmorSubPrimary";
|
||||||
|
import { SpacedArmorSubSpaced } from "./SpacedArmorSubSpaced";
|
||||||
|
|
||||||
export enum ArmorType {
|
export enum ArmorType {
|
||||||
Primary,
|
Primary,
|
||||||
@@ -21,14 +25,87 @@ interface SpacedArmorSceneProps {
|
|||||||
scene: Scene;
|
scene: Scene;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ArmorSectionProps {
|
||||||
|
primary: ArmorPlate[];
|
||||||
|
spaced: ArmorPlate[];
|
||||||
|
scene: Scene;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ArmorSection({ primary, spaced, scene }: ArmorSectionProps) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<SpacedArmorSubPrimary plates={primary} />
|
||||||
|
<SpacedArmorSubSpaced plates={spaced} />
|
||||||
|
|
||||||
|
{primary.map(({ node, thickness }) => (
|
||||||
|
<SpacedArmorSceneComponent
|
||||||
|
scene={scene}
|
||||||
|
key={node.uuid}
|
||||||
|
type={ArmorType.Primary}
|
||||||
|
thickness={thickness}
|
||||||
|
node={node}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
{spaced.map(({ node, thickness }) => (
|
||||||
|
<SpacedArmorSceneComponent
|
||||||
|
scene={scene}
|
||||||
|
key={node.uuid}
|
||||||
|
type={ArmorType.Spaced}
|
||||||
|
thickness={thickness}
|
||||||
|
node={node}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ExternalSectionProps {
|
||||||
|
nodes: Object3D[];
|
||||||
|
thickness: number;
|
||||||
|
variant: ExternalModuleVariant;
|
||||||
|
clip?: Plane;
|
||||||
|
scene: Scene;
|
||||||
|
}
|
||||||
|
|
||||||
|
function ExternalSection({
|
||||||
|
nodes,
|
||||||
|
thickness,
|
||||||
|
variant,
|
||||||
|
clip,
|
||||||
|
scene,
|
||||||
|
}: ExternalSectionProps) {
|
||||||
|
const plates = useMemo(
|
||||||
|
() => nodes.map((node) => ({ node, thickness })),
|
||||||
|
[nodes, thickness],
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<SpacedArmorSubExternal
|
||||||
|
plates={plates}
|
||||||
|
thickness={thickness}
|
||||||
|
clip={clip}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{nodes.map((node) => (
|
||||||
|
<SpacedArmorSceneComponent
|
||||||
|
scene={scene}
|
||||||
|
key={node.uuid}
|
||||||
|
type={ArmorType.External}
|
||||||
|
thickness={thickness}
|
||||||
|
variant={variant}
|
||||||
|
node={node}
|
||||||
|
clip={clip}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
|
export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
|
||||||
const turretContainer = useRef<Group>(null!);
|
const turretContainer = useRef<Group>(null!);
|
||||||
const gunContainer = useRef<Group>(null!);
|
const gunContainer = useRef<Group>(null!);
|
||||||
const protagonist = useDuelModules("protagonist");
|
const protagonist = useDuelModules("protagonist");
|
||||||
const { gltf: armorGltf } = useArmor(protagonist.tank.id);
|
|
||||||
const { gltf: modelGltf } = useModel(protagonist.tank.id);
|
|
||||||
const armorNodes = Object.values(armorGltf.nodes);
|
|
||||||
const modelNodes = Object.values(modelGltf.nodes);
|
|
||||||
const models = useDuelModels("protagonist");
|
const models = useDuelModels("protagonist");
|
||||||
const hullOrigin = toThreeVector(models.track.origin);
|
const hullOrigin = toThreeVector(models.track.origin);
|
||||||
const turretOrigin = toThreeVector(models.tank.turret_origin);
|
const turretOrigin = toThreeVector(models.tank.turret_origin);
|
||||||
@@ -38,6 +115,26 @@ export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
|
|||||||
? undefined
|
? undefined
|
||||||
: models.gun.mask + hullOrigin.y + turretOrigin.y + gunOrigin.y;
|
: models.gun.mask + hullOrigin.y + turretOrigin.y + gunOrigin.y;
|
||||||
const isDynamicArmorActive = useConsumable("protagonist", 73);
|
const isDynamicArmorActive = useConsumable("protagonist", 73);
|
||||||
|
const clip = useMemo(
|
||||||
|
() =>
|
||||||
|
maskOrigin === undefined
|
||||||
|
? undefined
|
||||||
|
: new Plane(new Vector3(0, 0, -1), -maskOrigin),
|
||||||
|
[maskOrigin],
|
||||||
|
);
|
||||||
|
|
||||||
|
const hiddenState = isDynamicArmorActive ? "state_00" : "state_01";
|
||||||
|
const plates = useArmorPlates(hiddenState);
|
||||||
|
const modelNodes = useModelNodes();
|
||||||
|
const hasMask = Boolean(models.gun.mask);
|
||||||
|
const trackNodes = useMemo(
|
||||||
|
() => [...modelNodes.wheels, ...modelNodes.tracks],
|
||||||
|
[modelNodes],
|
||||||
|
);
|
||||||
|
const gunNodes = useMemo(
|
||||||
|
() => (hasMask ? [...modelNodes.gun, ...modelNodes.mask] : modelNodes.gun),
|
||||||
|
[modelNodes, hasMask],
|
||||||
|
);
|
||||||
|
|
||||||
useTankTransform(
|
useTankTransform(
|
||||||
protagonist.track,
|
protagonist.track,
|
||||||
@@ -49,150 +146,37 @@ export const SpacedArmorScene = memo<SpacedArmorSceneProps>(({ scene }) => {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<group position={hullOrigin}>
|
<group position={hullOrigin}>
|
||||||
{armorNodes.map((node) => {
|
<ArmorSection {...plates.hull} scene={scene} />
|
||||||
const isHull = node.name.startsWith("hull_");
|
|
||||||
const isVisible = isHull;
|
|
||||||
const armorId = nameToArmorId(node.name);
|
|
||||||
const { spaced, thickness } = resolveArmor(
|
|
||||||
models.tank.armor!,
|
|
||||||
armorId,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (
|
|
||||||
!isVisible ||
|
|
||||||
thickness === undefined ||
|
|
||||||
(isDynamicArmorActive && node.name.includes("state_00")) ||
|
|
||||||
(!isDynamicArmorActive && node.name.includes("state_01"))
|
|
||||||
)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<SpacedArmorSceneComponent
|
|
||||||
scene={scene}
|
|
||||||
key={`${node.uuid}-hull`}
|
|
||||||
type={spaced ? ArmorType.Spaced : ArmorType.Primary}
|
|
||||||
thickness={thickness}
|
|
||||||
node={node}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</group>
|
</group>
|
||||||
|
|
||||||
{modelNodes.map((node) => {
|
<ExternalSection
|
||||||
const isWheel = node.name.startsWith("chassis_wheel_");
|
nodes={trackNodes}
|
||||||
const isTrack = node.name.startsWith("chassis_track_");
|
|
||||||
const isVisible = isWheel || isTrack;
|
|
||||||
|
|
||||||
if (!isVisible) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<SpacedArmorSceneComponent
|
|
||||||
scene={scene}
|
|
||||||
key={`${node.uuid}-track`}
|
|
||||||
type={ArmorType.External}
|
|
||||||
thickness={models.track.thickness}
|
thickness={models.track.thickness}
|
||||||
variant="track"
|
variant="track"
|
||||||
node={node}
|
scene={scene}
|
||||||
/>
|
/>
|
||||||
);
|
|
||||||
})}
|
|
||||||
|
|
||||||
<group ref={turretContainer}>
|
<group ref={turretContainer}>
|
||||||
{armorNodes.map((node) => {
|
<group position={hullOrigin}>
|
||||||
const isCurrentTurret = node.name.startsWith(
|
|
||||||
`turret_${models.turret.model_id.toString().padStart(2, "0")}`,
|
|
||||||
);
|
|
||||||
const isVisible = isCurrentTurret;
|
|
||||||
const armorId = nameToArmorId(node.name);
|
|
||||||
const { spaced, thickness } = resolveArmor(
|
|
||||||
models.turret.armor!,
|
|
||||||
armorId,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (
|
|
||||||
!isVisible ||
|
|
||||||
thickness === undefined ||
|
|
||||||
(isDynamicArmorActive && node.name.includes("state_00")) ||
|
|
||||||
(!isDynamicArmorActive && node.name.includes("state_01"))
|
|
||||||
)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<group position={hullOrigin} key={node.uuid}>
|
|
||||||
<group position={turretOrigin}>
|
<group position={turretOrigin}>
|
||||||
<SpacedArmorSceneComponent
|
<ArmorSection {...plates.turret} scene={scene} />
|
||||||
scene={scene}
|
|
||||||
key={`${node.uuid}-turret`}
|
|
||||||
type={spaced ? ArmorType.Spaced : ArmorType.Primary}
|
|
||||||
thickness={thickness}
|
|
||||||
node={node}
|
|
||||||
/>
|
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
);
|
|
||||||
})}
|
|
||||||
|
|
||||||
<group ref={gunContainer}>
|
<group ref={gunContainer}>
|
||||||
{armorNodes.map((node) => {
|
<group position={hullOrigin}>
|
||||||
const isCurrentGun = node.name.startsWith(
|
|
||||||
`gun_${models.gun.model_id.toString().padStart(2, "0")}`,
|
|
||||||
);
|
|
||||||
const isVisible = isCurrentGun;
|
|
||||||
const armorId = nameToArmorId(node.name);
|
|
||||||
const { spaced, thickness } = resolveArmor(
|
|
||||||
models.gun.armor!,
|
|
||||||
armorId,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (
|
|
||||||
!isVisible ||
|
|
||||||
thickness === undefined ||
|
|
||||||
(isDynamicArmorActive && node.name.includes("state_00")) ||
|
|
||||||
(!isDynamicArmorActive && node.name.includes("state_01"))
|
|
||||||
)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<group position={hullOrigin} key={`${node.uuid}-gun-spaced}`}>
|
|
||||||
<group position={turretOrigin.clone().add(gunOrigin)}>
|
<group position={turretOrigin.clone().add(gunOrigin)}>
|
||||||
<SpacedArmorSceneComponent
|
<ArmorSection {...plates.gun} scene={scene} />
|
||||||
scene={scene}
|
|
||||||
type={spaced ? ArmorType.Spaced : ArmorType.Primary}
|
|
||||||
thickness={thickness}
|
|
||||||
node={node}
|
|
||||||
/>
|
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
);
|
|
||||||
})}
|
|
||||||
|
|
||||||
{modelNodes.map((node) => {
|
<ExternalSection
|
||||||
const gunString = `gun_${models.gun.model_id
|
nodes={gunNodes}
|
||||||
.toString()
|
|
||||||
.padStart(2, "0")}`;
|
|
||||||
const isCurrentGun = models.gun.mask
|
|
||||||
? node.name.startsWith(gunString)
|
|
||||||
: node.name === gunString;
|
|
||||||
const isVisible = isCurrentGun;
|
|
||||||
|
|
||||||
if (!isVisible) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<SpacedArmorSceneComponent
|
|
||||||
scene={scene}
|
|
||||||
key={`${node.uuid}-gun-external`}
|
|
||||||
type={ArmorType.External}
|
|
||||||
thickness={models.gun.thickness}
|
thickness={models.gun.thickness}
|
||||||
variant="gun"
|
variant="gun"
|
||||||
node={node}
|
clip={clip}
|
||||||
clip={
|
scene={scene}
|
||||||
maskOrigin === undefined
|
|
||||||
? undefined
|
|
||||||
: new Plane(new Vector3(0, 0, -1), -maskOrigin)
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
);
|
|
||||||
})}
|
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { isExplosive, resolvePenetrationCoefficient } from "@blitzkit/core";
|
import { isExplosive, resolvePenetrationCoefficient } from "@blitzkit/core";
|
||||||
import { ShellType } from "@blitzkit/protos";
|
import { ShellType } from "@blitzkit/protos";
|
||||||
import { useThree } from "@react-three/fiber";
|
import { useThree } from "@react-three/fiber";
|
||||||
import { useCallback } from "react";
|
import { useCallback, useMemo } from "react";
|
||||||
import {
|
import {
|
||||||
type Intersection,
|
type Intersection,
|
||||||
MeshBasicMaterial,
|
MeshBasicMaterial,
|
||||||
@@ -29,8 +29,6 @@ import {
|
|||||||
Tankopedia,
|
Tankopedia,
|
||||||
} from "../stores/tankopedia";
|
} from "../stores/tankopedia";
|
||||||
import { ArmorType } from "./SpacedArmorScene";
|
import { ArmorType } from "./SpacedArmorScene";
|
||||||
import { SpacedArmorSubExternal } from "./SpacedArmorSubExternal";
|
|
||||||
import { SpacedArmorSubSpaced } from "./SpacedArmorSubSpaced";
|
|
||||||
|
|
||||||
type SpacedArmorSceneComponentProps = {
|
type SpacedArmorSceneComponentProps = {
|
||||||
node: Object3D;
|
node: Object3D;
|
||||||
@@ -90,12 +88,14 @@ function resolvePenetrationChance(shoot: (scale: number) => Shot | null) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const omitMaterial = new MeshBasicMaterial({
|
const proxyMaterial = new MeshBasicMaterial({ visible: false });
|
||||||
colorWrite: false,
|
|
||||||
depthWrite: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Plates are drawn in batches by SpacedArmorSubPrimary, SpacedArmorSubSpaced
|
||||||
|
* and SpacedArmorSubExternal; this only renders invisible per plate proxies
|
||||||
|
* so raycasts still resolve each plate's userData. Raycasting ignores
|
||||||
|
* material visibility.
|
||||||
|
*
|
||||||
* Render orders allocations:
|
* Render orders allocations:
|
||||||
* - 0 : core omission
|
* - 0 : core omission
|
||||||
* - 1-2: spaced without depth buffer write but do test to allow additive blending
|
* - 1-2: spaced without depth buffer write but do test to allow additive blending
|
||||||
@@ -431,36 +431,36 @@ export function SpacedArmorSceneComponent({
|
|||||||
[camera],
|
[camera],
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
const clippedProxyMaterial = useMemo(
|
||||||
<>
|
() =>
|
||||||
{props.type === ArmorType.Primary &&
|
clip
|
||||||
jsxTree(node, {
|
? new MeshBasicMaterial({ visible: false, clippingPlanes: [clip] })
|
||||||
mesh(_, props, key) {
|
: proxyMaterial,
|
||||||
|
[clip],
|
||||||
|
);
|
||||||
|
const userData: ArmorUserData =
|
||||||
|
props.type === ArmorType.External
|
||||||
|
? { type: ArmorType.External, thickness, variant: props.variant }
|
||||||
|
: { type: props.type, thickness };
|
||||||
|
|
||||||
|
return jsxTree(node, {
|
||||||
|
mesh(_, meshProps, key) {
|
||||||
return (
|
return (
|
||||||
<mesh
|
<mesh
|
||||||
{...props}
|
{...meshProps}
|
||||||
key={`${key}-spaced-component`}
|
key={`${key}-proxy`}
|
||||||
renderOrder={0}
|
material={clippedProxyMaterial}
|
||||||
material={omitMaterial}
|
userData={userData}
|
||||||
userData={
|
|
||||||
{
|
|
||||||
type: ArmorType.Primary,
|
|
||||||
thickness,
|
|
||||||
} satisfies ArmorUserData
|
|
||||||
}
|
|
||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
|
// other layers only need to be in the intersections
|
||||||
|
if (props.type !== ArmorType.Primary) return;
|
||||||
|
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
|
||||||
const shot = shoot(event.point, event.intersections, true)!;
|
const shot = shoot(event.point, event.intersections, true)!;
|
||||||
|
|
||||||
shot.penetrationChance = resolvePenetrationChance((scale) =>
|
shot.penetrationChance = resolvePenetrationChance((scale) =>
|
||||||
shoot(
|
shoot(event.point, event.intersections, true, undefined, scale),
|
||||||
event.point,
|
|
||||||
event.intersections,
|
|
||||||
true,
|
|
||||||
undefined,
|
|
||||||
scale,
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
Tankopedia.mutate((draft) => {
|
Tankopedia.mutate((draft) => {
|
||||||
@@ -470,20 +470,5 @@ export function SpacedArmorSceneComponent({
|
|||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
})}
|
});
|
||||||
|
|
||||||
{props.type === ArmorType.Spaced && (
|
|
||||||
<SpacedArmorSubSpaced node={node} thickness={thickness} />
|
|
||||||
)}
|
|
||||||
|
|
||||||
{props.type === ArmorType.External && (
|
|
||||||
<SpacedArmorSubExternal
|
|
||||||
node={node}
|
|
||||||
thickness={thickness}
|
|
||||||
variant={props.variant}
|
|
||||||
clip={clip}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
@@ -1,38 +1,44 @@
|
|||||||
import { resolvePenetrationCoefficient } from "@blitzkit/core";
|
import { resolvePenetrationCoefficient } from "@blitzkit/core";
|
||||||
import { useEffect } from "react";
|
import { useEffect, useMemo } from "react";
|
||||||
import {
|
import {
|
||||||
AdditiveBlending,
|
AdditiveBlending,
|
||||||
MeshBasicMaterial,
|
MeshBasicMaterial,
|
||||||
Object3D,
|
|
||||||
Plane,
|
Plane,
|
||||||
ShaderMaterial,
|
ShaderMaterial,
|
||||||
} from "three";
|
} from "three";
|
||||||
import { jsxTree } from "../../core/blitzkit/jsxTree";
|
import type { ArmorPlate } from "../../hooks/useArmorPlates";
|
||||||
import { getDuelModules } from "../../hooks/useDuelModules";
|
import { getDuelModules } from "../../hooks/useDuelModules";
|
||||||
import { hasEquipment } from "../../hooks/useEquipment";
|
import { hasEquipment } from "../../hooks/useEquipment";
|
||||||
|
import { usePlateItems } from "../../hooks/usePlateItems";
|
||||||
import { Tankopedia } from "../../stores/tankopedia";
|
import { Tankopedia } from "../../stores/tankopedia";
|
||||||
import { ArmorType } from "../SpacedArmorScene";
|
import { Batch } from "../Batch";
|
||||||
import type {
|
|
||||||
ArmorUserData,
|
|
||||||
ExternalModuleVariant,
|
|
||||||
} from "../SpacedArmorSceneComponent";
|
|
||||||
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";
|
||||||
|
|
||||||
interface SpacedArmorSubExternalProps {
|
interface SpacedArmorSubExternalProps {
|
||||||
node: Object3D;
|
plates: ArmorPlate[];
|
||||||
thickness: number;
|
thickness: number;
|
||||||
variant: ExternalModuleVariant;
|
|
||||||
clip?: Plane;
|
clip?: Plane;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SpacedArmorSubExternal({
|
export function SpacedArmorSubExternal({
|
||||||
node,
|
plates,
|
||||||
thickness,
|
thickness,
|
||||||
variant,
|
|
||||||
clip,
|
clip,
|
||||||
}: SpacedArmorSubExternalProps) {
|
}: SpacedArmorSubExternalProps) {
|
||||||
const material = new ShaderMaterial({
|
const excludeMaterial = useMemo(
|
||||||
|
() =>
|
||||||
|
new MeshBasicMaterial({
|
||||||
|
colorWrite: false,
|
||||||
|
depthTest: true,
|
||||||
|
depthWrite: true,
|
||||||
|
...(clip ? { clippingPlanes: [clip] } : {}),
|
||||||
|
}),
|
||||||
|
[clip],
|
||||||
|
);
|
||||||
|
const material = useMemo(
|
||||||
|
() =>
|
||||||
|
new ShaderMaterial({
|
||||||
fragmentShader,
|
fragmentShader,
|
||||||
vertexShader,
|
vertexShader,
|
||||||
|
|
||||||
@@ -46,7 +52,9 @@ export function SpacedArmorSubExternal({
|
|||||||
thickness: { value: null },
|
thickness: { value: null },
|
||||||
penetration: { value: null },
|
penetration: { value: null },
|
||||||
},
|
},
|
||||||
});
|
}),
|
||||||
|
[clip],
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function handleShellChange() {
|
function handleShellChange() {
|
||||||
@@ -126,62 +134,15 @@ export function SpacedArmorSubExternal({
|
|||||||
return () => {
|
return () => {
|
||||||
unsubscribes.forEach((unsubscribe) => unsubscribe());
|
unsubscribes.forEach((unsubscribe) => unsubscribe());
|
||||||
};
|
};
|
||||||
});
|
}, [material, thickness]);
|
||||||
|
|
||||||
|
|
||||||
|
const items = usePlateItems(plates);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{jsxTree(node, {
|
<Batch items={items} material={excludeMaterial} renderOrder={3} />
|
||||||
group(_, props, key) {
|
<Batch items={items} material={material} renderOrder={4} />
|
||||||
return (
|
|
||||||
<group {...props} key={`${key}-spaced-sub-external-exclude`} />
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
mesh(_, props, key) {
|
|
||||||
return (
|
|
||||||
<mesh
|
|
||||||
{...props}
|
|
||||||
onClick={() => {}}
|
|
||||||
key={`${key}-spaced-sub-external-exclude`}
|
|
||||||
renderOrder={3}
|
|
||||||
material={
|
|
||||||
new MeshBasicMaterial({
|
|
||||||
colorWrite: false,
|
|
||||||
depthTest: true,
|
|
||||||
depthWrite: true,
|
|
||||||
...(clip ? { clippingPlanes: [clip] } : {}),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
userData={
|
|
||||||
{
|
|
||||||
type: ArmorType.External,
|
|
||||||
thickness,
|
|
||||||
variant,
|
|
||||||
} satisfies ArmorUserData
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
})}
|
|
||||||
|
|
||||||
{jsxTree(node, {
|
|
||||||
group(_, props, key) {
|
|
||||||
return (
|
|
||||||
<group {...props} key={`${key}-spaced-sub-external-include`} />
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
mesh(_, props, key) {
|
|
||||||
return (
|
|
||||||
<mesh
|
|
||||||
{...props}
|
|
||||||
key={`${key}-spaced-sub-external-include`}
|
|
||||||
renderOrder={4}
|
|
||||||
material={material}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
})}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
precision mediump float;
|
precision mediump float;
|
||||||
|
|
||||||
|
#include <batching_pars_vertex>
|
||||||
#include <clipping_planes_pars_vertex>
|
#include <clipping_planes_pars_vertex>
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
#include <batching_vertex>
|
||||||
#include <begin_vertex>
|
#include <begin_vertex>
|
||||||
#include <project_vertex>
|
#include <project_vertex>
|
||||||
#include <clipping_planes_vertex>
|
#include <clipping_planes_vertex>
|
||||||
|
|||||||
@@ -1,24 +1,18 @@
|
|||||||
import { isExplosive, resolvePenetrationCoefficient } from "@blitzkit/core";
|
import { isExplosive, resolvePenetrationCoefficient } from "@blitzkit/core";
|
||||||
import { useEffect } from "react";
|
import { useEffect, useMemo } from "react";
|
||||||
import {
|
import { AdditiveBlending, MeshBasicMaterial, ShaderMaterial } from "three";
|
||||||
AdditiveBlending,
|
|
||||||
MeshBasicMaterial,
|
|
||||||
ShaderMaterial,
|
|
||||||
type Object3D,
|
|
||||||
} from "three";
|
|
||||||
import { degToRad } from "three/src/math/MathUtils.js";
|
import { degToRad } from "three/src/math/MathUtils.js";
|
||||||
import { jsxTree } from "../../core/blitzkit/jsxTree";
|
import type { ArmorPlate } from "../../hooks/useArmorPlates";
|
||||||
import { getDuelModules } from "../../hooks/useDuelModules";
|
import { getDuelModules } from "../../hooks/useDuelModules";
|
||||||
import { hasEquipment } from "../../hooks/useEquipment";
|
import { hasEquipment } from "../../hooks/useEquipment";
|
||||||
|
import { usePlateItems } from "../../hooks/usePlateItems";
|
||||||
import { Tankopedia } from "../../stores/tankopedia";
|
import { Tankopedia } from "../../stores/tankopedia";
|
||||||
import { ArmorType } from "../SpacedArmorScene";
|
import { Batch } from "../Batch";
|
||||||
import type { ArmorUserData } from "../SpacedArmorSceneComponent";
|
|
||||||
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";
|
||||||
|
|
||||||
interface SpacedArmorSubSpacedProps {
|
interface SpacedArmorSubSpacedProps {
|
||||||
node: Object3D;
|
plates: ArmorPlate[];
|
||||||
thickness: number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const depthWriteMaterial = new MeshBasicMaterial({
|
const depthWriteMaterial = new MeshBasicMaterial({
|
||||||
@@ -26,11 +20,10 @@ const depthWriteMaterial = new MeshBasicMaterial({
|
|||||||
colorWrite: false,
|
colorWrite: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
export function SpacedArmorSubSpaced({
|
export function SpacedArmorSubSpaced({ plates }: SpacedArmorSubSpacedProps) {
|
||||||
node,
|
const material = useMemo(
|
||||||
thickness,
|
() =>
|
||||||
}: SpacedArmorSubSpacedProps) {
|
new ShaderMaterial({
|
||||||
const material = new ShaderMaterial({
|
|
||||||
fragmentShader,
|
fragmentShader,
|
||||||
vertexShader,
|
vertexShader,
|
||||||
|
|
||||||
@@ -39,13 +32,15 @@ export function SpacedArmorSubSpaced({
|
|||||||
blending: AdditiveBlending,
|
blending: AdditiveBlending,
|
||||||
|
|
||||||
uniforms: {
|
uniforms: {
|
||||||
thickness: { value: null },
|
thicknessCoefficient: { value: null },
|
||||||
penetration: { value: null },
|
penetration: { value: null },
|
||||||
caliber: { value: null },
|
caliber: { value: null },
|
||||||
ricochet: { value: null },
|
ricochet: { value: null },
|
||||||
normalization: { value: null },
|
normalization: { value: null },
|
||||||
},
|
},
|
||||||
});
|
}),
|
||||||
|
[],
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function handleShellChange() {
|
function handleShellChange() {
|
||||||
@@ -75,8 +70,8 @@ export function SpacedArmorSubSpaced({
|
|||||||
? protagonist.equalizer?.armor
|
? protagonist.equalizer?.armor
|
||||||
: undefined) ?? 1;
|
: undefined) ?? 1;
|
||||||
|
|
||||||
material.uniforms.thickness.value =
|
material.uniforms.thicknessCoefficient.value =
|
||||||
thickness * (hasEnhancedArmor ? 1.04 : 1) * equalizer;
|
(hasEnhancedArmor ? 1.04 : 1) * equalizer;
|
||||||
}
|
}
|
||||||
function handleAntagonistEquipmentChange() {
|
function handleAntagonistEquipmentChange() {
|
||||||
const antagonist = getDuelModules("antagonist").tank;
|
const antagonist = getDuelModules("antagonist").tank;
|
||||||
@@ -133,50 +128,15 @@ export function SpacedArmorSubSpaced({
|
|||||||
return () => {
|
return () => {
|
||||||
unsubscribes.forEach((unsubscribe) => unsubscribe());
|
unsubscribes.forEach((unsubscribe) => unsubscribe());
|
||||||
};
|
};
|
||||||
});
|
}, [material]);
|
||||||
|
|
||||||
|
|
||||||
|
const items = usePlateItems(plates);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{jsxTree(node, {
|
<Batch items={items} material={material} renderOrder={2} />
|
||||||
group(_, props, key) {
|
<Batch items={items} material={depthWriteMaterial} renderOrder={5} />
|
||||||
return <group {...props} key={`${key}-spaced-sub-spaced-exclude`} />;
|
|
||||||
},
|
|
||||||
|
|
||||||
mesh(_, props, key) {
|
|
||||||
return (
|
|
||||||
<mesh
|
|
||||||
{...props}
|
|
||||||
key={`${key}-spaced-sub-spaced-exclude`}
|
|
||||||
renderOrder={2}
|
|
||||||
material={material}
|
|
||||||
onClick={() => {}}
|
|
||||||
userData={
|
|
||||||
{
|
|
||||||
type: ArmorType.Spaced,
|
|
||||||
thickness,
|
|
||||||
} satisfies ArmorUserData
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
})}
|
|
||||||
|
|
||||||
{jsxTree(node, {
|
|
||||||
group(_, props, key) {
|
|
||||||
return <group {...props} key={`${key}-spaced-sub-spaced-include`} />;
|
|
||||||
},
|
|
||||||
|
|
||||||
mesh(_, props, key) {
|
|
||||||
return (
|
|
||||||
<mesh
|
|
||||||
{...props}
|
|
||||||
key={`${key}-spaced-sub-spaced-include`}
|
|
||||||
renderOrder={5}
|
|
||||||
material={depthWriteMaterial}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
})}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -3,13 +3,15 @@ precision mediump float;
|
|||||||
varying vec3 vNormal;
|
varying vec3 vNormal;
|
||||||
varying vec3 vViewPosition;
|
varying vec3 vViewPosition;
|
||||||
|
|
||||||
uniform float thickness;
|
uniform float thicknessCoefficient;
|
||||||
|
varying float vThickness;
|
||||||
uniform float penetration;
|
uniform float penetration;
|
||||||
uniform float caliber;
|
uniform float caliber;
|
||||||
uniform float ricochet;
|
uniform float ricochet;
|
||||||
uniform float normalization;
|
uniform float normalization;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
|
float thickness = vThickness * thicknessCoefficient;
|
||||||
float angle = acos(dot(vNormal, -vViewPosition) / length(vViewPosition));
|
float angle = acos(dot(vNormal, -vViewPosition) / length(vViewPosition));
|
||||||
|
|
||||||
bool threeCalibersRule = caliber > thickness * 3.0;
|
bool threeCalibersRule = caliber > thickness * 3.0;
|
||||||
|
|||||||
@@ -2,12 +2,31 @@ precision mediump float;
|
|||||||
|
|
||||||
varying vec3 vNormal;
|
varying vec3 vNormal;
|
||||||
varying vec3 vViewPosition;
|
varying vec3 vViewPosition;
|
||||||
|
varying float vThickness;
|
||||||
|
|
||||||
|
#include <batching_pars_vertex>
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec4 vViewPosition4 = modelViewMatrix * vec4(position, 1.0);
|
vec4 localPosition = vec4(position, 1.0);
|
||||||
|
vec3 localNormal = normal;
|
||||||
|
|
||||||
|
#ifdef USE_BATCHING
|
||||||
|
#include <batching_vertex>
|
||||||
|
|
||||||
|
localPosition = batchingMatrix * localPosition;
|
||||||
|
localNormal = normalize(mat3(batchingMatrix) * localNormal);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_BATCHING_COLOR
|
||||||
|
vThickness = getBatchingColor(getIndirectIndex(gl_DrawID)).r;
|
||||||
|
#else
|
||||||
|
vThickness = 0.0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
vec4 vViewPosition4 = modelViewMatrix * localPosition;
|
||||||
|
|
||||||
vViewPosition = vViewPosition4.xyz;
|
vViewPosition = vViewPosition4.xyz;
|
||||||
vNormal = normalMatrix * normal;
|
vNormal = normalMatrix * localNormal;
|
||||||
|
|
||||||
gl_Position = projectionMatrix * vViewPosition4;
|
gl_Position = projectionMatrix * vViewPosition4;
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
type ModelTransformEventData,
|
type ModelTransformEventData,
|
||||||
} from "../core/blitzkit/modelTransform";
|
} from "../core/blitzkit/modelTransform";
|
||||||
import { discardClippingPlane } from "../core/three/discardClippingPlane";
|
import { discardClippingPlane } from "../core/three/discardClippingPlane";
|
||||||
|
import { sceneChangeEvent } from "../core/three/sceneChange";
|
||||||
import { useDuelModules } from "../hooks/useDuelModules";
|
import { useDuelModules } from "../hooks/useDuelModules";
|
||||||
import { useEquipment } from "../hooks/useEquipment";
|
import { useEquipment } from "../hooks/useEquipment";
|
||||||
import { Tankopedia } from "../stores/tankopedia";
|
import { Tankopedia } from "../stores/tankopedia";
|
||||||
@@ -155,6 +156,13 @@ export function StaticArmorSceneComponent({
|
|||||||
[hasEnhancedArmor, equalize],
|
[hasEnhancedArmor, equalize],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// these cast shadows
|
||||||
|
useEffect(() => {
|
||||||
|
sceneChangeEvent.dispatch();
|
||||||
|
|
||||||
|
return () => sceneChangeEvent.dispatch();
|
||||||
|
}, [node]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
function handleHighlightArmor(selectedName?: string) {
|
function handleHighlightArmor(selectedName?: string) {
|
||||||
if (selectedName === undefined) {
|
if (selectedName === undefined) {
|
||||||
|
|||||||
@@ -1,20 +1,178 @@
|
|||||||
import { invalidate, useThree, type ThreeEvent } from "@react-three/fiber";
|
import { invalidate, useThree, type ThreeEvent } from "@react-three/fiber";
|
||||||
import { useMemo, useRef } from "react";
|
import { useMemo, useRef } from "react";
|
||||||
|
import type { Object3D, Texture } from "three";
|
||||||
import { Group, Mesh, MeshStandardMaterial, Vector2 } from "three";
|
import { Group, Mesh, MeshStandardMaterial, Vector2 } from "three";
|
||||||
import { applyPitchYawLimits } from "../core/blitz/applyPitchYawLimits";
|
import { applyPitchYawLimits } from "../core/blitz/applyPitchYawLimits";
|
||||||
import { modelTransformEvent } from "../core/blitzkit/modelTransform";
|
import { modelTransformEvent } from "../core/blitzkit/modelTransform";
|
||||||
import { skinTree } from "../core/blitzkit/skinTree";
|
|
||||||
import { controlsEnabledEvent } from "../core/controlsEnabled";
|
import { controlsEnabledEvent } from "../core/controlsEnabled";
|
||||||
|
import { useBatchGroups } from "../hooks/useBatchGroups";
|
||||||
|
import { useDuelModels } from "../hooks/useDuelModels";
|
||||||
import { getDuelModules, useDuelModules } from "../hooks/useDuelModules";
|
import { getDuelModules, useDuelModules } from "../hooks/useDuelModules";
|
||||||
import { useDuelModel } from "../hooks/useDuelModel";
|
|
||||||
import { hasEquipment } from "../hooks/useEquipment";
|
import { hasEquipment } from "../hooks/useEquipment";
|
||||||
import { useModel } from "../hooks/useModel";
|
import { useModelNodes } from "../hooks/useModelNodes";
|
||||||
import { useSilhouette } from "../hooks/useSilhouette";
|
import { useSilhouette } from "../hooks/useSilhouette";
|
||||||
import { useSkin } from "../hooks/useSkin";
|
import { useSkin, type Skin } from "../hooks/useSkin";
|
||||||
import { useSkinAnimation } from "../hooks/useSkinAnimation";
|
import { useSkinAnimation } from "../hooks/useSkinAnimation";
|
||||||
import { useTankTransform } from "../hooks/useTankTransform";
|
import { useTankTransform } from "../hooks/useTankTransform";
|
||||||
import { Tankopedia } from "../stores/tankopedia";
|
import { Tankopedia } from "../stores/tankopedia";
|
||||||
import { TankopediaDisplay } from "../stores/tankopediaPersistent/constants";
|
import { TankopediaDisplay } from "../stores/tankopediaPersistent/constants";
|
||||||
|
import { Batch } from "./Batch";
|
||||||
|
|
||||||
|
interface SectionProps {
|
||||||
|
nodes: Object3D[];
|
||||||
|
skins: Skin[];
|
||||||
|
silhouette: boolean;
|
||||||
|
// dragging scrolls the track textures
|
||||||
|
scrollTracks?: boolean;
|
||||||
|
// dragging turns the turret
|
||||||
|
yaw?: boolean;
|
||||||
|
// dragging raises and lowers the gun
|
||||||
|
pitch?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
function Section({
|
||||||
|
nodes,
|
||||||
|
skins,
|
||||||
|
silhouette,
|
||||||
|
scrollTracks,
|
||||||
|
yaw,
|
||||||
|
pitch,
|
||||||
|
}: SectionProps) {
|
||||||
|
const models = useDuelModels("protagonist");
|
||||||
|
|
||||||
|
const { groups, parts, materials } = useBatchGroups(nodes, skins);
|
||||||
|
|
||||||
|
const position = useRef(new Vector2());
|
||||||
|
const delta = useRef(new Vector2());
|
||||||
|
const pitchAngle = useRef(0);
|
||||||
|
const yawAngle = useRef(0);
|
||||||
|
const textures = useRef(new Set<Texture | null>());
|
||||||
|
|
||||||
|
const canvas = useThree((state) => state.gl.domElement);
|
||||||
|
const rotates = yaw || pitch;
|
||||||
|
|
||||||
|
function handlePointerMove(event: PointerEvent) {
|
||||||
|
delta.current.set(event.clientX, event.clientY).sub(position.current);
|
||||||
|
position.current.set(event.clientX, event.clientY);
|
||||||
|
|
||||||
|
if (scrollTracks) {
|
||||||
|
const offset =
|
||||||
|
delta.current.x / window.innerWidth +
|
||||||
|
delta.current.y / window.innerHeight;
|
||||||
|
|
||||||
|
for (const texture of textures.current) {
|
||||||
|
if (!texture) continue;
|
||||||
|
texture.offset.y += offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rotates) {
|
||||||
|
const protagonist = getDuelModules("protagonist").tank;
|
||||||
|
const hasImprovedVerticalStabilizer = hasEquipment(
|
||||||
|
122,
|
||||||
|
protagonist.equipment_preset,
|
||||||
|
Tankopedia.state.protagonist.equipment,
|
||||||
|
);
|
||||||
|
const hasDownImprovedVerticalStabilizer = hasEquipment(
|
||||||
|
124,
|
||||||
|
protagonist.equipment_preset,
|
||||||
|
Tankopedia.state.protagonist.equipment,
|
||||||
|
);
|
||||||
|
const boundingRect = canvas.getBoundingClientRect();
|
||||||
|
const pitchDelta = pitch
|
||||||
|
? delta.current.y * (Math.PI / boundingRect.height)
|
||||||
|
: 0;
|
||||||
|
const yawDelta = yaw
|
||||||
|
? delta.current.x * (Math.PI / boundingRect.width)
|
||||||
|
: 0;
|
||||||
|
|
||||||
|
[pitchAngle.current, yawAngle.current] = applyPitchYawLimits(
|
||||||
|
pitchAngle.current - pitchDelta,
|
||||||
|
yawAngle.current + yawDelta,
|
||||||
|
models.gun.pitch!,
|
||||||
|
models.turret.yaw,
|
||||||
|
hasImprovedVerticalStabilizer,
|
||||||
|
hasDownImprovedVerticalStabilizer,
|
||||||
|
);
|
||||||
|
modelTransformEvent.dispatch({
|
||||||
|
pitch: pitchAngle.current,
|
||||||
|
yaw: yawAngle.current,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function handlePointerUp() {
|
||||||
|
controlsEnabledEvent.dispatch(true);
|
||||||
|
|
||||||
|
window.removeEventListener("pointermove", handlePointerMove);
|
||||||
|
window.removeEventListener("pointerup", handlePointerUp);
|
||||||
|
}
|
||||||
|
function handlePointerDown(event: ThreeEvent<PointerEvent>) {
|
||||||
|
// tracks only scroll while looking at the model, not the armor
|
||||||
|
if (
|
||||||
|
scrollTracks &&
|
||||||
|
Tankopedia.state.loaders.display.loaded !== TankopediaDisplay.Model
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
if (!scrollTracks && !rotates) return;
|
||||||
|
|
||||||
|
if (scrollTracks) {
|
||||||
|
const material = (event.object as Mesh).material as MeshStandardMaterial;
|
||||||
|
|
||||||
|
textures.current = new Set([
|
||||||
|
material.map,
|
||||||
|
material.aoMap,
|
||||||
|
material.normalMap,
|
||||||
|
material.roughnessMap,
|
||||||
|
material.metalnessMap,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rotates) {
|
||||||
|
Tankopedia.mutate((draft) => {
|
||||||
|
draft.shot = undefined;
|
||||||
|
draft.highlightArmor = undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
pitchAngle.current = modelTransformEvent.last!.pitch;
|
||||||
|
yawAngle.current = modelTransformEvent.last!.yaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
position.current.set(event.clientX, event.clientY);
|
||||||
|
controlsEnabledEvent.dispatch(false);
|
||||||
|
|
||||||
|
window.addEventListener("pointermove", handlePointerMove);
|
||||||
|
window.addEventListener("pointerup", handlePointerUp);
|
||||||
|
}
|
||||||
|
|
||||||
|
// also fades emissive parts with the lights
|
||||||
|
useSilhouette(silhouette, materials);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<group onPointerDown={handlePointerDown}>
|
||||||
|
{groups.map(({ material, items }) => (
|
||||||
|
<Batch
|
||||||
|
key={material.uuid}
|
||||||
|
items={items}
|
||||||
|
material={material}
|
||||||
|
castShadow
|
||||||
|
receiveShadow
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
|
||||||
|
{parts.map(({ part, matrix }) => (
|
||||||
|
<group key={part.uuid} matrix={matrix} matrixAutoUpdate={false}>
|
||||||
|
<primitive object={part} />
|
||||||
|
</group>
|
||||||
|
))}
|
||||||
|
</group>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
interface TankModelProps {
|
interface TankModelProps {
|
||||||
// while the lights are down, draws the tank as a flat light shape
|
// while the lights are down, draws the tank as a flat light shape
|
||||||
@@ -22,24 +180,21 @@ interface TankModelProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function TankModel({ silhouette = false }: TankModelProps) {
|
export function TankModel({ silhouette = false }: TankModelProps) {
|
||||||
const protagonistState = Tankopedia.use((state) => state.protagonist);
|
const protagonistTank = Tankopedia.use((state) => state.protagonist.tank);
|
||||||
const protagonist = useDuelModules("protagonist");
|
const protagonist = useDuelModules("protagonist");
|
||||||
|
|
||||||
const canvas = useThree((state) => state.gl.domElement);
|
|
||||||
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 turretModelDefinition =
|
const nodes = useModelNodes();
|
||||||
tankModelDefinition.turrets[protagonistState.turret];
|
const skinGltf = useSkin(protagonistTank);
|
||||||
const gunModelDefinition = turretModelDefinition.guns[protagonistState.gun];
|
const attachmentGltf = useSkin(protagonistTank, "attachment");
|
||||||
const { gltf } = useModel(protagonistState.tank);
|
|
||||||
const nodes = Object.values(gltf.nodes);
|
|
||||||
const skinGltf = useSkin(protagonistState.tank);
|
|
||||||
const attachmentGltf = useSkin(protagonistState.tank, "attachment");
|
|
||||||
const skins = useMemo(
|
const skins = useMemo(
|
||||||
() => [skinGltf, attachmentGltf].filter((skin) => skin !== undefined),
|
() => [skinGltf, attachmentGltf].filter((skin) => skin !== undefined),
|
||||||
[skinGltf, attachmentGltf],
|
[skinGltf, attachmentGltf],
|
||||||
);
|
);
|
||||||
|
const hullNodes = useMemo(() => [...nodes.hull, ...nodes.wheels], [nodes]);
|
||||||
|
const gunNodes = useMemo(() => [...nodes.gun, ...nodes.mask], [nodes]);
|
||||||
|
|
||||||
useTankTransform(
|
useTankTransform(
|
||||||
protagonist.track,
|
protagonist.track,
|
||||||
@@ -49,298 +204,32 @@ export function TankModel({ silhouette = false }: TankModelProps) {
|
|||||||
);
|
);
|
||||||
useSkinAnimation(skins);
|
useSkinAnimation(skins);
|
||||||
|
|
||||||
const materials = useMemo(() => {
|
|
||||||
const collected = new Set<MeshStandardMaterial>();
|
|
||||||
const roots = [
|
|
||||||
gltf.scene,
|
|
||||||
...skins.flatMap((skin) => [...skin.parts.values()].flat()),
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const root of roots) {
|
|
||||||
root.traverse((object) => {
|
|
||||||
if (!(object instanceof Mesh)) return;
|
|
||||||
|
|
||||||
for (const material of [object.material].flat()) {
|
|
||||||
if (material instanceof MeshStandardMaterial) {
|
|
||||||
collected.add(material);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return [...collected];
|
|
||||||
}, [gltf, skins]);
|
|
||||||
|
|
||||||
// also fades emissive parts with the lights
|
|
||||||
useSilhouette(silhouette, materials);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{nodes.map((node) => {
|
<Section
|
||||||
const isHull = node.name === "hull";
|
nodes={nodes.tracks}
|
||||||
const isWheel = node.name.startsWith("chassis_wheel_");
|
skins={skins}
|
||||||
const isTrack = node.name.startsWith("chassis_track_");
|
silhouette={silhouette}
|
||||||
const isVisible = isHull || isWheel || isTrack;
|
scrollTracks
|
||||||
const position = new Vector2();
|
|
||||||
const delta = new Vector2();
|
|
||||||
|
|
||||||
if (!isVisible) return null;
|
|
||||||
|
|
||||||
function translateTexture(offset: number) {
|
|
||||||
const mesh = node.children[0] as Mesh;
|
|
||||||
const material = mesh?.material as MeshStandardMaterial;
|
|
||||||
|
|
||||||
if (!material) return;
|
|
||||||
|
|
||||||
invalidate();
|
|
||||||
|
|
||||||
const textures = new Set([
|
|
||||||
material.map,
|
|
||||||
material.aoMap,
|
|
||||||
material.normalMap,
|
|
||||||
material.roughnessMap,
|
|
||||||
material.metalnessMap,
|
|
||||||
]);
|
|
||||||
|
|
||||||
for (const texture of textures) {
|
|
||||||
if (texture) texture.offset.y += offset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onPointerDown(event: ThreeEvent<PointerEvent>) {
|
|
||||||
if (
|
|
||||||
isTrack &&
|
|
||||||
Tankopedia.state.loaders.display.loaded === TankopediaDisplay.Model
|
|
||||||
) {
|
|
||||||
position.set(event.clientX, event.clientY);
|
|
||||||
event.stopPropagation();
|
|
||||||
|
|
||||||
controlsEnabledEvent.dispatch(false);
|
|
||||||
|
|
||||||
window.addEventListener("pointermove", handlePointerMove);
|
|
||||||
window.addEventListener("pointerup", handlePointerUp);
|
|
||||||
} else {
|
|
||||||
event.stopPropagation();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function handlePointerMove(event: PointerEvent) {
|
|
||||||
delta.set(event.clientX, event.clientY).sub(position);
|
|
||||||
position.set(event.clientX, event.clientY);
|
|
||||||
const deltaX = delta.x / window.innerWidth;
|
|
||||||
const deltaY = delta.y / window.innerHeight;
|
|
||||||
|
|
||||||
translateTexture(deltaX + deltaY);
|
|
||||||
}
|
|
||||||
function handlePointerUp() {
|
|
||||||
controlsEnabledEvent.dispatch(true);
|
|
||||||
|
|
||||||
window.removeEventListener("pointermove", handlePointerMove);
|
|
||||||
window.removeEventListener("pointerup", handlePointerUp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return skinTree(node, skins, {
|
|
||||||
mesh(_, props, key) {
|
|
||||||
return (
|
|
||||||
<mesh
|
|
||||||
{...props}
|
|
||||||
key={key}
|
|
||||||
onPointerDown={onPointerDown}
|
|
||||||
castShadow
|
|
||||||
receiveShadow
|
|
||||||
/>
|
/>
|
||||||
);
|
<Section nodes={hullNodes} skins={skins} silhouette={silhouette} />
|
||||||
},
|
|
||||||
primitive(object, key) {
|
|
||||||
return (
|
|
||||||
<primitive
|
|
||||||
key={key}
|
|
||||||
object={object}
|
|
||||||
onPointerDown={onPointerDown}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
})}
|
|
||||||
|
|
||||||
<group ref={turretContainer}>
|
<group ref={turretContainer}>
|
||||||
{nodes.map((node) => {
|
<Section
|
||||||
const isTurret = node.name.startsWith("turret_");
|
nodes={nodes.turret}
|
||||||
const isCurrentTurret =
|
skins={skins}
|
||||||
node.name ===
|
silhouette={silhouette}
|
||||||
`turret_${turretModelDefinition.model_id
|
yaw
|
||||||
.toString()
|
|
||||||
.padStart(2, "0")}`;
|
|
||||||
const isVisible = isCurrentTurret;
|
|
||||||
const position = new Vector2();
|
|
||||||
const delta = new Vector2();
|
|
||||||
|
|
||||||
if (!isVisible) return null;
|
|
||||||
|
|
||||||
function onPointerDown(event: ThreeEvent<PointerEvent>) {
|
|
||||||
event.stopPropagation();
|
|
||||||
|
|
||||||
if (!isTurret) return;
|
|
||||||
|
|
||||||
position.set(event.clientX, event.clientY);
|
|
||||||
|
|
||||||
controlsEnabledEvent.dispatch(false);
|
|
||||||
Tankopedia.mutate((draft) => {
|
|
||||||
draft.shot = undefined;
|
|
||||||
draft.highlightArmor = undefined;
|
|
||||||
});
|
|
||||||
window.addEventListener("pointermove", handlePointerMove);
|
|
||||||
window.addEventListener("pointerup", handlePointerUp);
|
|
||||||
}
|
|
||||||
function handlePointerMove(event: PointerEvent) {
|
|
||||||
const protagonist = getDuelModules("protagonist").tank;
|
|
||||||
|
|
||||||
const hasImprovedVerticalStabilizer = hasEquipment(
|
|
||||||
122,
|
|
||||||
protagonist.equipment_preset,
|
|
||||||
Tankopedia.state.protagonist.equipment,
|
|
||||||
);
|
|
||||||
const hasDownImprovedVerticalStabilizer = hasEquipment(
|
|
||||||
124,
|
|
||||||
protagonist.equipment_preset,
|
|
||||||
Tankopedia.state.protagonist.equipment,
|
|
||||||
);
|
|
||||||
const boundingRect = canvas.getBoundingClientRect();
|
|
||||||
|
|
||||||
delta.set(event.clientX, event.clientY).sub(position);
|
|
||||||
position.set(event.clientX, event.clientY);
|
|
||||||
|
|
||||||
const [pitch, yaw] = applyPitchYawLimits(
|
|
||||||
modelTransformEvent.last!.pitch,
|
|
||||||
modelTransformEvent.last!.yaw +
|
|
||||||
delta.x * (Math.PI / boundingRect.width),
|
|
||||||
gunModelDefinition.pitch!,
|
|
||||||
turretModelDefinition.yaw,
|
|
||||||
hasImprovedVerticalStabilizer,
|
|
||||||
hasDownImprovedVerticalStabilizer,
|
|
||||||
);
|
|
||||||
modelTransformEvent.dispatch({ pitch, yaw });
|
|
||||||
}
|
|
||||||
function handlePointerUp() {
|
|
||||||
controlsEnabledEvent.dispatch(true);
|
|
||||||
window.removeEventListener("pointermove", handlePointerMove);
|
|
||||||
window.removeEventListener("pointerup", handlePointerUp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return skinTree(node, skins, {
|
|
||||||
mesh(_, props, key) {
|
|
||||||
return (
|
|
||||||
<mesh
|
|
||||||
{...props}
|
|
||||||
key={key}
|
|
||||||
onPointerDown={onPointerDown}
|
|
||||||
castShadow
|
|
||||||
receiveShadow
|
|
||||||
/>
|
/>
|
||||||
);
|
|
||||||
},
|
|
||||||
primitive(object, key) {
|
|
||||||
return (
|
|
||||||
<primitive
|
|
||||||
key={key}
|
|
||||||
object={object}
|
|
||||||
onPointerDown={onPointerDown}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
})}
|
|
||||||
|
|
||||||
<group ref={gunContainer}>
|
<group ref={gunContainer}>
|
||||||
{nodes.map((node) => {
|
<Section
|
||||||
const isCurrentMantlet =
|
nodes={gunNodes}
|
||||||
node.name ===
|
skins={skins}
|
||||||
`gun_${gunModelDefinition.model_id
|
silhouette={silhouette}
|
||||||
.toString()
|
yaw
|
||||||
.padStart(2, "0")}_mask`;
|
pitch
|
||||||
const isCurrentGun =
|
|
||||||
node.name ===
|
|
||||||
`gun_${gunModelDefinition.model_id.toString().padStart(2, "0")}`;
|
|
||||||
const isVisible = isCurrentGun || isCurrentMantlet;
|
|
||||||
const position = new Vector2();
|
|
||||||
const delta = new Vector2();
|
|
||||||
|
|
||||||
if (!isVisible) return null;
|
|
||||||
|
|
||||||
let pitch = 0;
|
|
||||||
let yaw = 0;
|
|
||||||
|
|
||||||
function onPointerDown(event: ThreeEvent<PointerEvent>) {
|
|
||||||
event.stopPropagation();
|
|
||||||
|
|
||||||
controlsEnabledEvent.dispatch(false);
|
|
||||||
Tankopedia.mutate((draft) => {
|
|
||||||
draft.shot = undefined;
|
|
||||||
draft.highlightArmor = undefined;
|
|
||||||
});
|
|
||||||
|
|
||||||
position.set(event.clientX, event.clientY);
|
|
||||||
pitch = modelTransformEvent.last!.pitch;
|
|
||||||
yaw = modelTransformEvent.last!.yaw;
|
|
||||||
|
|
||||||
window.addEventListener("pointermove", handlePointerMove);
|
|
||||||
window.addEventListener("pointerup", handlePointerUp);
|
|
||||||
}
|
|
||||||
function handlePointerMove(event: PointerEvent) {
|
|
||||||
const protagonist = getDuelModules("protagonist").tank;
|
|
||||||
|
|
||||||
const hasImprovedVerticalStabilizer = hasEquipment(
|
|
||||||
122,
|
|
||||||
protagonist.equipment_preset,
|
|
||||||
Tankopedia.state.protagonist.equipment,
|
|
||||||
);
|
|
||||||
const hasDownImprovedVerticalStabilizer = hasEquipment(
|
|
||||||
124,
|
|
||||||
protagonist.equipment_preset,
|
|
||||||
Tankopedia.state.protagonist.equipment,
|
|
||||||
);
|
|
||||||
const boundingRect = canvas.getBoundingClientRect();
|
|
||||||
delta.set(event.clientX, event.clientY).sub(position);
|
|
||||||
position.set(event.clientX, event.clientY);
|
|
||||||
|
|
||||||
[pitch, yaw] = applyPitchYawLimits(
|
|
||||||
pitch - delta.y * (Math.PI / boundingRect.height),
|
|
||||||
yaw + delta.x * (Math.PI / boundingRect.width),
|
|
||||||
gunModelDefinition.pitch!,
|
|
||||||
turretModelDefinition.yaw,
|
|
||||||
hasImprovedVerticalStabilizer,
|
|
||||||
hasDownImprovedVerticalStabilizer,
|
|
||||||
);
|
|
||||||
modelTransformEvent.dispatch({ pitch, yaw });
|
|
||||||
}
|
|
||||||
function handlePointerUp() {
|
|
||||||
controlsEnabledEvent.dispatch(true);
|
|
||||||
window.removeEventListener("pointermove", handlePointerMove);
|
|
||||||
window.removeEventListener("pointerup", handlePointerUp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return skinTree(node, skins, {
|
|
||||||
mesh(_, props, key) {
|
|
||||||
return (
|
|
||||||
<mesh
|
|
||||||
{...props}
|
|
||||||
key={key}
|
|
||||||
onPointerDown={onPointerDown}
|
|
||||||
castShadow
|
|
||||||
receiveShadow
|
|
||||||
/>
|
/>
|
||||||
);
|
|
||||||
},
|
|
||||||
primitive(object, key) {
|
|
||||||
return (
|
|
||||||
<primitive
|
|
||||||
key={key}
|
|
||||||
object={object}
|
|
||||||
onPointerDown={onPointerDown}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
})}
|
|
||||||
</group>
|
</group>
|
||||||
</group>
|
</group>
|
||||||
</>
|
</>
|
||||||
|
|||||||
-153
@@ -1,153 +0,0 @@
|
|||||||
import { useRef } from "react";
|
|
||||||
import { Group, ShaderMaterial, UniformsLib, UniformsUtils } from "three";
|
|
||||||
import { jsxTree } from "../../../../../../../core/blitzkit/jsxTree";
|
|
||||||
import { useArmor } from "../../../../../../../hooks/useArmor";
|
|
||||||
import { useModel } from "../../../../../../../hooks/useModel";
|
|
||||||
import { useTankModelDefinition } from "../../../../../../../hooks/useTankModelDefinition";
|
|
||||||
import { useTankTransform } from "../../../../../../../hooks/useTankTransform";
|
|
||||||
import { Duel } from "../../../../../../../stores/duel";
|
|
||||||
import { toThreeVector } from "../../../../../../../three/toThreeVector";
|
|
||||||
import { ModelTankWrapper } from "../../../../../../ModelTankWrapper";
|
|
||||||
import fragmentShader from "./shaders/fragment.glsl?raw";
|
|
||||||
import vertexShader from "./shaders/vertex.glsl?raw";
|
|
||||||
|
|
||||||
const skeletonMaterial = new ShaderMaterial({
|
|
||||||
vertexShader,
|
|
||||||
fragmentShader,
|
|
||||||
wireframe: true,
|
|
||||||
fog: true,
|
|
||||||
transparent: true,
|
|
||||||
uniforms: UniformsUtils.merge([UniformsLib.common, UniformsLib.fog]),
|
|
||||||
depthWrite: false,
|
|
||||||
});
|
|
||||||
|
|
||||||
export function TransitionSkeleton() {
|
|
||||||
const tank = Duel.use((state) => state.protagonist.tank);
|
|
||||||
const gun = Duel.use((state) => state.protagonist.gun);
|
|
||||||
const track = Duel.use((state) => state.protagonist.track);
|
|
||||||
const turret = Duel.use((state) => state.protagonist.turret);
|
|
||||||
const turretContainer = useRef<Group>(null!);
|
|
||||||
const gunContainer = useRef<Group>(null!);
|
|
||||||
const { gltf: armorGltf } = useArmor(tank.id);
|
|
||||||
const { gltf: modelGltf } = useModel(tank.id);
|
|
||||||
const modelNodes = Object.values(modelGltf.nodes);
|
|
||||||
const armorNodes = Object.values(armorGltf.nodes);
|
|
||||||
const tankModelDefinition = useTankModelDefinition();
|
|
||||||
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
|
|
||||||
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
|
||||||
const trackModelDefinition = tankModelDefinition.tracks[track.id];
|
|
||||||
const wrapper = useRef<Group>(null);
|
|
||||||
const hullOrigin = toThreeVector(trackModelDefinition.origin);
|
|
||||||
const turretOrigin = toThreeVector(tankModelDefinition.turret_origin);
|
|
||||||
const gunOrigin = toThreeVector(turretModelDefinition.gun_origin);
|
|
||||||
|
|
||||||
useTankTransform(track, turret, turretContainer, gunContainer);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ModelTankWrapper ref={wrapper}>
|
|
||||||
<group position={hullOrigin}>
|
|
||||||
{armorNodes.map((node) => {
|
|
||||||
const isHull = node.name.startsWith("hull_");
|
|
||||||
const isVisible = isHull;
|
|
||||||
|
|
||||||
if (!isVisible) return null;
|
|
||||||
|
|
||||||
return jsxTree(node, {
|
|
||||||
mesh(_, props, key) {
|
|
||||||
return <mesh {...props} key={key} material={skeletonMaterial} />;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
})}
|
|
||||||
</group>
|
|
||||||
|
|
||||||
{modelNodes.map((node) => {
|
|
||||||
const isWheel = node.name.startsWith("chassis_wheel_");
|
|
||||||
const isTrack = node.name.startsWith("chassis_track_");
|
|
||||||
const isVisible = isWheel || isTrack;
|
|
||||||
|
|
||||||
if (!isVisible) return null;
|
|
||||||
|
|
||||||
return jsxTree(node, {
|
|
||||||
mesh(_, props, key) {
|
|
||||||
return <mesh {...props} key={key} material={skeletonMaterial} />;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
})}
|
|
||||||
|
|
||||||
<group ref={turretContainer}>
|
|
||||||
{armorNodes.map((node) => {
|
|
||||||
const isCurrentTurret = node.name.startsWith(
|
|
||||||
`turret_${turretModelDefinition.model_id.toString().padStart(2, "0")}`,
|
|
||||||
);
|
|
||||||
const isVisible = isCurrentTurret;
|
|
||||||
if (!isVisible) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<group key={node.uuid} position={hullOrigin}>
|
|
||||||
<group position={turretOrigin}>
|
|
||||||
{jsxTree(node, {
|
|
||||||
mesh(_, props, key) {
|
|
||||||
return (
|
|
||||||
<mesh {...props} key={key} material={skeletonMaterial} />
|
|
||||||
);
|
|
||||||
},
|
|
||||||
})}
|
|
||||||
</group>
|
|
||||||
</group>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
|
|
||||||
<group ref={gunContainer}>
|
|
||||||
{armorNodes.map((node) => {
|
|
||||||
const isCurrentGun = node.name.startsWith(
|
|
||||||
`gun_${gunModelDefinition.model_id.toString().padStart(2, "0")}`,
|
|
||||||
);
|
|
||||||
const isVisible = isCurrentGun;
|
|
||||||
|
|
||||||
if (!isVisible) return null;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<group key={node.uuid} position={hullOrigin}>
|
|
||||||
<group position={turretOrigin.clone().add(gunOrigin)}>
|
|
||||||
{jsxTree(node, {
|
|
||||||
mesh(_, props, key) {
|
|
||||||
return (
|
|
||||||
<mesh
|
|
||||||
{...props}
|
|
||||||
key={key}
|
|
||||||
material={skeletonMaterial}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
})}
|
|
||||||
</group>
|
|
||||||
</group>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
|
|
||||||
{modelNodes.map((node) => {
|
|
||||||
const gunString = `gun_${gunModelDefinition.model_id
|
|
||||||
.toString()
|
|
||||||
.padStart(2, "0")}`;
|
|
||||||
const isCurrentGun = gunModelDefinition.mask
|
|
||||||
? node.name.startsWith(gunString)
|
|
||||||
: node.name === gunString;
|
|
||||||
const isVisible = isCurrentGun;
|
|
||||||
|
|
||||||
if (!isVisible) return null;
|
|
||||||
|
|
||||||
return jsxTree(node, {
|
|
||||||
mesh(_, props, key) {
|
|
||||||
return (
|
|
||||||
<mesh {...props} key={key} material={skeletonMaterial} />
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
})}
|
|
||||||
</group>
|
|
||||||
</group>
|
|
||||||
</ModelTankWrapper>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
-11
@@ -1,11 +0,0 @@
|
|||||||
precision mediump float;
|
|
||||||
|
|
||||||
#define USE_FOG
|
|
||||||
|
|
||||||
#include <fog_pars_fragment>
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
float fogFactor = smoothstep(fogNear, fogFar, vFogDepth);
|
|
||||||
gl_FragColor = vec4(0.5, 0.5, 0.5, fogFactor);
|
|
||||||
gl_FragColor.rgb = mix(fogColor, gl_FragColor.rgb, fogFactor);
|
|
||||||
}
|
|
||||||
-19
@@ -1,19 +0,0 @@
|
|||||||
precision mediump float;
|
|
||||||
|
|
||||||
#define USE_FOG
|
|
||||||
|
|
||||||
#include <fog_pars_vertex>
|
|
||||||
|
|
||||||
varying vec3 vNormal;
|
|
||||||
varying vec3 vViewPosition;
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);
|
|
||||||
|
|
||||||
vViewPosition = mvPosition.xyz;
|
|
||||||
vNormal = normalMatrix * normal;
|
|
||||||
|
|
||||||
gl_Position = projectionMatrix * mvPosition;
|
|
||||||
|
|
||||||
#include <fog_vertex>
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import { Matrix4, type Object3D } from "three";
|
||||||
|
|
||||||
|
export interface FlatNode {
|
||||||
|
object: Object3D;
|
||||||
|
// relative to the root's parent, like jsxTree renders it
|
||||||
|
matrix: Matrix4;
|
||||||
|
root: Object3D;
|
||||||
|
}
|
||||||
|
|
||||||
|
function allChildren(object: Object3D) {
|
||||||
|
return object.children;
|
||||||
|
}
|
||||||
|
|
||||||
|
// every object under the roots; children picks which ones to descend into
|
||||||
|
export function flattenNodes(roots: Object3D[], children = allChildren) {
|
||||||
|
const flat: FlatNode[] = [];
|
||||||
|
|
||||||
|
function walk(object: Object3D, parent: Matrix4, root: Object3D) {
|
||||||
|
object.updateMatrix();
|
||||||
|
|
||||||
|
const matrix = parent.clone().multiply(object.matrix);
|
||||||
|
|
||||||
|
flat.push({ object, matrix, root });
|
||||||
|
|
||||||
|
for (const child of children(object)) walk(child, matrix, root);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const root of roots) walk(root, new Matrix4(), root);
|
||||||
|
|
||||||
|
return flat;
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import { Quicklime } from "quicklime";
|
||||||
|
|
||||||
|
// something that casts or receives shadows was added, removed or changed
|
||||||
|
export const sceneChangeEvent = new Quicklime();
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
import type { Armor } from "@blitzkit/core";
|
||||||
|
import { useMemo } from "react";
|
||||||
|
import type { Object3D } from "three";
|
||||||
|
import { nameToArmorId } from "../core/blitzkit/nameToArmorId";
|
||||||
|
import { resolveArmor } from "../core/blitzkit/resolveThickness";
|
||||||
|
import { Duel } from "../stores/duel";
|
||||||
|
import { useArmor } from "./useArmor";
|
||||||
|
import { useTankModelDefinition } from "./useTankModelDefinition";
|
||||||
|
|
||||||
|
export interface ArmorPlate {
|
||||||
|
node: Object3D;
|
||||||
|
thickness: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SectionPlates {
|
||||||
|
primary: ArmorPlate[];
|
||||||
|
spaced: ArmorPlate[];
|
||||||
|
}
|
||||||
|
|
||||||
|
// the protagonist's hull, turret and gun plates; nodes whose name contains
|
||||||
|
// hiddenState are dynamic armor in the other state
|
||||||
|
export function useArmorPlates(hiddenState: string) {
|
||||||
|
const tank = Duel.use((state) => state.protagonist.tank);
|
||||||
|
const turret = Duel.use((state) => state.protagonist.turret);
|
||||||
|
const gun = Duel.use((state) => state.protagonist.gun);
|
||||||
|
const { gltf } = useArmor(tank.id);
|
||||||
|
const tankModelDefinition = useTankModelDefinition();
|
||||||
|
|
||||||
|
return useMemo(() => {
|
||||||
|
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
|
||||||
|
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
||||||
|
const nodes = Object.values(gltf.nodes);
|
||||||
|
|
||||||
|
function platesOf(prefix: string, armor: Armor) {
|
||||||
|
const plates: SectionPlates = { primary: [], spaced: [] };
|
||||||
|
|
||||||
|
for (const node of nodes) {
|
||||||
|
if (!node.name.startsWith(prefix) || node.name.includes(hiddenState)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { spaced, thickness } = resolveArmor(
|
||||||
|
armor,
|
||||||
|
nameToArmorId(node.name),
|
||||||
|
);
|
||||||
|
|
||||||
|
plates[spaced ? "spaced" : "primary"].push({ node, thickness });
|
||||||
|
}
|
||||||
|
|
||||||
|
return plates;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hullPlates = platesOf("hull_", tankModelDefinition.armor!);
|
||||||
|
const turretPlates = platesOf(
|
||||||
|
`turret_${turretModelDefinition.model_id.toString().padStart(2, "0")}`,
|
||||||
|
turretModelDefinition.armor!,
|
||||||
|
);
|
||||||
|
const gunPlates = platesOf(
|
||||||
|
`gun_${gunModelDefinition.model_id.toString().padStart(2, "0")}`,
|
||||||
|
gunModelDefinition.armor!,
|
||||||
|
);
|
||||||
|
|
||||||
|
return { hull: hullPlates, turret: turretPlates, gun: gunPlates };
|
||||||
|
}, [gltf, tankModelDefinition, turret.id, gun.id, hiddenState]);
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
import { useEffect, useMemo } from "react";
|
||||||
|
import {
|
||||||
|
Mesh,
|
||||||
|
MeshStandardMaterial,
|
||||||
|
type Material,
|
||||||
|
type Matrix4,
|
||||||
|
type Object3D,
|
||||||
|
} from "three";
|
||||||
|
import type { BatchItem } from "../components/Batch";
|
||||||
|
import { prepareMaterial } from "../core/blitzkit/jsxTree";
|
||||||
|
import { nameOf } from "../core/blitzkit/skinTree";
|
||||||
|
import { flattenNodes } from "../core/three/flattenNodes";
|
||||||
|
import type { Skin } from "./useSkin";
|
||||||
|
|
||||||
|
interface BatchGroup {
|
||||||
|
material: MeshStandardMaterial;
|
||||||
|
items: BatchItem[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SkinPart {
|
||||||
|
part: Object3D;
|
||||||
|
matrix: Matrix4;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Model nodes grouped into one batch per material. Skins are layered in order,
|
||||||
|
* so an attachment's states win over the camouflage's. Their parts aren't
|
||||||
|
* batched so their bones can animate.
|
||||||
|
*/
|
||||||
|
export function useBatchGroups(nodes: Object3D[], skins: Skin[]) {
|
||||||
|
const batchGroups = useMemo(() => {
|
||||||
|
const skinMaterials = new Map<string, Material>();
|
||||||
|
const states: Record<string, string | null> = {};
|
||||||
|
|
||||||
|
for (const skin of skins) {
|
||||||
|
for (const [name, material] of skin.materials) {
|
||||||
|
skinMaterials.set(name, material);
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.assign(states, skin.scene.userData.states);
|
||||||
|
}
|
||||||
|
|
||||||
|
function stateChildren(object: Object3D) {
|
||||||
|
if (object.userData.state === undefined) return object.children;
|
||||||
|
|
||||||
|
const name = nameOf(object);
|
||||||
|
const state = name in states ? states[name] : object.userData.state;
|
||||||
|
|
||||||
|
return object.children.filter((child) => nameOf(child) === state);
|
||||||
|
}
|
||||||
|
|
||||||
|
const groups = new Map<Material, BatchGroup>();
|
||||||
|
const parts: SkinPart[] = [];
|
||||||
|
|
||||||
|
for (const { object, matrix } of flattenNodes(nodes, stateChildren)) {
|
||||||
|
for (const skin of skins) {
|
||||||
|
for (const part of skin.parts.get(object.name) ?? []) {
|
||||||
|
parts.push({ part, matrix });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(object instanceof Mesh)) continue;
|
||||||
|
|
||||||
|
const source =
|
||||||
|
skinMaterials.get((object.material as Material).name) ??
|
||||||
|
object.material;
|
||||||
|
|
||||||
|
if (!(source instanceof MeshStandardMaterial)) continue;
|
||||||
|
|
||||||
|
let group = groups.get(source);
|
||||||
|
|
||||||
|
if (!group) {
|
||||||
|
const material = source.clone();
|
||||||
|
|
||||||
|
prepareMaterial(material);
|
||||||
|
group = { material, items: [] };
|
||||||
|
groups.set(source, group);
|
||||||
|
}
|
||||||
|
|
||||||
|
group.items.push({ mesh: object, matrix });
|
||||||
|
}
|
||||||
|
|
||||||
|
const materials = [...groups.values()].map(({ material }) => material);
|
||||||
|
|
||||||
|
for (const { part } of parts) {
|
||||||
|
part.traverse((object) => {
|
||||||
|
if (
|
||||||
|
object instanceof Mesh &&
|
||||||
|
object.material instanceof MeshStandardMaterial
|
||||||
|
) {
|
||||||
|
materials.push(object.material);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return { groups: [...groups.values()], parts, materials };
|
||||||
|
}, [nodes, skins]);
|
||||||
|
|
||||||
|
useEffect(
|
||||||
|
() => () => {
|
||||||
|
for (const { material } of batchGroups.groups) material.dispose();
|
||||||
|
},
|
||||||
|
[batchGroups],
|
||||||
|
);
|
||||||
|
|
||||||
|
return batchGroups;
|
||||||
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
import { useMemo } from "react";
|
||||||
|
import type { Object3D } from "three";
|
||||||
|
import { Duel } from "../stores/duel";
|
||||||
|
import { useModel } from "./useModel";
|
||||||
|
import { useTankModelDefinition } from "./useTankModelDefinition";
|
||||||
|
|
||||||
|
interface ModelNodes {
|
||||||
|
hull: Object3D[];
|
||||||
|
wheels: Object3D[];
|
||||||
|
tracks: Object3D[];
|
||||||
|
turret: Object3D[];
|
||||||
|
gun: Object3D[];
|
||||||
|
mask: Object3D[];
|
||||||
|
}
|
||||||
|
|
||||||
|
// the protagonist's visual model split into its parts
|
||||||
|
export function useModelNodes() {
|
||||||
|
const tank = Duel.use((state) => state.protagonist.tank);
|
||||||
|
const turret = Duel.use((state) => state.protagonist.turret);
|
||||||
|
const gun = Duel.use((state) => state.protagonist.gun);
|
||||||
|
const { gltf } = useModel(tank.id);
|
||||||
|
const tankModelDefinition = useTankModelDefinition();
|
||||||
|
|
||||||
|
return useMemo(() => {
|
||||||
|
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
|
||||||
|
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
||||||
|
const turretName = `turret_${turretModelDefinition.model_id
|
||||||
|
.toString()
|
||||||
|
.padStart(2, "0")}`;
|
||||||
|
const gunName = `gun_${gunModelDefinition.model_id
|
||||||
|
.toString()
|
||||||
|
.padStart(2, "0")}`;
|
||||||
|
const maskName = `${gunName}_mask`;
|
||||||
|
const nodes: ModelNodes = {
|
||||||
|
hull: [],
|
||||||
|
wheels: [],
|
||||||
|
tracks: [],
|
||||||
|
turret: [],
|
||||||
|
gun: [],
|
||||||
|
mask: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const node of Object.values(gltf.nodes)) {
|
||||||
|
switch (node.name) {
|
||||||
|
case "hull":
|
||||||
|
nodes.hull.push(node);
|
||||||
|
continue;
|
||||||
|
|
||||||
|
case turretName:
|
||||||
|
nodes.turret.push(node);
|
||||||
|
continue;
|
||||||
|
|
||||||
|
case gunName:
|
||||||
|
nodes.gun.push(node);
|
||||||
|
continue;
|
||||||
|
|
||||||
|
case maskName:
|
||||||
|
nodes.mask.push(node);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (node.name.startsWith("chassis_wheel_")) {
|
||||||
|
nodes.wheels.push(node);
|
||||||
|
} else if (node.name.startsWith("chassis_track_")) {
|
||||||
|
nodes.tracks.push(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nodes;
|
||||||
|
}, [gltf, tankModelDefinition, turret.id, gun.id]);
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { useEffect } from "react";
|
||||||
|
import { modelTransformEvent } from "../core/blitzkit/modelTransform";
|
||||||
|
import { sceneChangeEvent } from "../core/three/sceneChange";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calls back on mount and whenever shadows may have changed: the tank moved or
|
||||||
|
* something dispatched sceneChangeEvent.
|
||||||
|
*/
|
||||||
|
export function useOnSceneChange(callback: () => void) {
|
||||||
|
useEffect(() => {
|
||||||
|
callback();
|
||||||
|
|
||||||
|
modelTransformEvent.on(callback);
|
||||||
|
sceneChangeEvent.on(callback);
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
modelTransformEvent.off(callback);
|
||||||
|
sceneChangeEvent.off(callback);
|
||||||
|
};
|
||||||
|
}, [callback]);
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import { useMemo } from "react";
|
||||||
|
import { Mesh } from "three";
|
||||||
|
import type { BatchItem } from "../components/Batch";
|
||||||
|
import { flattenNodes } from "../core/three/flattenNodes";
|
||||||
|
import type { ArmorPlate } from "./useArmorPlates";
|
||||||
|
|
||||||
|
// batch items for armor plates, each carrying its plate's thickness
|
||||||
|
export function usePlateItems(plates: ArmorPlate[]) {
|
||||||
|
return useMemo(() => {
|
||||||
|
const thicknesses = new Map(
|
||||||
|
plates.map(({ node, thickness }) => [node, thickness]),
|
||||||
|
);
|
||||||
|
|
||||||
|
return flattenNodes(plates.map(({ node }) => node)).flatMap(
|
||||||
|
({ object, matrix, root }) =>
|
||||||
|
object instanceof Mesh
|
||||||
|
? [
|
||||||
|
{
|
||||||
|
mesh: object,
|
||||||
|
matrix,
|
||||||
|
thickness: thicknesses.get(root)!,
|
||||||
|
} satisfies BatchItem,
|
||||||
|
]
|
||||||
|
: [],
|
||||||
|
);
|
||||||
|
}, [plates]);
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import { invalidate, useThree } from "@react-three/fiber";
|
||||||
|
import { useEffect } from "react";
|
||||||
|
import { useOnSceneChange } from "./useOnSceneChange";
|
||||||
|
|
||||||
|
// shadow maps only re-render when the scene changes, not every frame
|
||||||
|
export function useShadowsOnDemand() {
|
||||||
|
const gl = useThree((state) => state.gl);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
gl.shadowMap.autoUpdate = false;
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
gl.shadowMap.autoUpdate = true;
|
||||||
|
};
|
||||||
|
}, [gl]);
|
||||||
|
|
||||||
|
useOnSceneChange(() => {
|
||||||
|
gl.shadowMap.needsUpdate = true;
|
||||||
|
invalidate();
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { invalidate, useFrame } from "@react-three/fiber";
|
import { invalidate, useFrame } from "@react-three/fiber";
|
||||||
|
import { sceneChangeEvent } from "../core/three/sceneChange";
|
||||||
import { Tankopedia } from "../stores/tankopedia";
|
import { Tankopedia } from "../stores/tankopedia";
|
||||||
import type { Skin } from "./useSkin";
|
import type { Skin } from "./useSkin";
|
||||||
|
|
||||||
@@ -13,6 +14,7 @@ export function useSkinAnimation(skins: Skin[]) {
|
|||||||
|
|
||||||
mixer.update(delta);
|
mixer.update(delta);
|
||||||
invalidate();
|
invalidate();
|
||||||
|
sceneChangeEvent.dispatch();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -5,6 +5,7 @@ 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 { sceneChangeEvent } from "../core/three/sceneChange";
|
||||||
import {
|
import {
|
||||||
modelTransformEvent,
|
modelTransformEvent,
|
||||||
type ModelTransformEventData,
|
type ModelTransformEventData,
|
||||||
@@ -89,6 +90,7 @@ export function useTankTransform(
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleModelTransformInner();
|
handleModelTransformInner();
|
||||||
|
sceneChangeEvent.dispatch();
|
||||||
|
|
||||||
modelTransformEvent.on(handleModelTransform);
|
modelTransformEvent.on(handleModelTransform);
|
||||||
|
|
||||||
|
|||||||
@@ -31,5 +31,5 @@ export const TankopediaPersistent = new Soapstone<TankopediaPersistent>(
|
|||||||
recentlyViewed: [],
|
recentlyViewed: [],
|
||||||
highGraphics: true,
|
highGraphics: true,
|
||||||
},
|
},
|
||||||
"tankopedia-3",
|
"tankopedia-4",
|
||||||
);
|
);
|
||||||
Reference in new issue
Block a user