mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1a2d4aaa9c | ||
|
|
d7914bb2fb | ||
|
|
8cb15d488d | ||
|
|
5c3ab2e10d | ||
|
|
28c30f210e | ||
|
|
5c92f9f7ee | ||
|
|
249b185836 |
No files matched your search
+101
-101
@@ -220,190 +220,190 @@
|
|||||||
"clear": "Clear",
|
"clear": "Clear",
|
||||||
"tier": "Tier {tier}",
|
"tier": "Tier {tier}",
|
||||||
"passive": "{name} (Passive)",
|
"passive": "{name} (Passive)",
|
||||||
"active": "{name} (Aktywne)",
|
"active": "{name} (Active)",
|
||||||
"no_tanks_found": {
|
"no_tanks_found": {
|
||||||
"body": "Nie znaleziono czołgu.",
|
"body": "No tanks found.",
|
||||||
"search_again": "",
|
"search_again": "",
|
||||||
"clear_filters": "Try clearing filters."
|
"clear_filters": "Try clearing filters."
|
||||||
},
|
},
|
||||||
"sort": {
|
"sort": {
|
||||||
"meta.none": "brak",
|
"meta.none": "none",
|
||||||
"survivability.health": "punkty.życia",
|
"survivability.health": "health",
|
||||||
"survivability.viewRange": "zasięg widzenia",
|
"survivability.viewRange": "view range",
|
||||||
"survivability.camouflageStill": "kamuflaż w bezruchu",
|
"survivability.camouflageStill": "camouflage still",
|
||||||
"survivability.camouflageMoving": "kamuflaż w trakcie ruchu",
|
"survivability.camouflageMoving": "camouflage moving",
|
||||||
"survivability.camouflageShooting": "kamuflaż podczas strzału",
|
"survivability.camouflageShooting": "camouflage shooting",
|
||||||
"survivability.volume": "wartość",
|
"survivability.volume": "volume",
|
||||||
"survivability.length": "długość",
|
"survivability.length": "length",
|
||||||
"fire.dpm": "DPM pocisków podstawowych",
|
"fire.dpm": "standard DPM",
|
||||||
"fire.dpmPremium": "DPM pocisków premium",
|
"fire.dpmPremium": "premium DPM",
|
||||||
"fire.reload": "przeładowanie",
|
"fire.reload": "reload",
|
||||||
"fire.caliber": "kaliber",
|
"fire.caliber": "caliber",
|
||||||
"fire.standardPenetration": "Penetracja pocisków standardowych",
|
"fire.standardPenetration": "standard penetration",
|
||||||
"fire.premiumPenetration": "Penetracja pocisków premium",
|
"fire.premiumPenetration": "premium penetration",
|
||||||
"fire.tertiaryPenetration": "tertiary penetration",
|
"fire.tertiaryPenetration": "tertiary penetration",
|
||||||
"fire.damage": "uszkodzenia",
|
"fire.damage": "damage",
|
||||||
"fire.moduleDamage": "Uszkodzenia modułów",
|
"fire.moduleDamage": "module damage",
|
||||||
"fire.shellVelocity": "Prędkość pocisku",
|
"fire.shellVelocity": "shell velocity",
|
||||||
"fire.shellRange": "Zasięg pocisku",
|
"fire.shellRange": "shell range",
|
||||||
"fire.shellCapacity": "Maksymalna ilość pocisków",
|
"fire.shellCapacity": "shell capacity",
|
||||||
"fire.aimTime": "Czas celowania",
|
"fire.aimTime": "aim time",
|
||||||
"fire.dispersionStill": "dispersion still",
|
"fire.dispersionStill": "dispersion still",
|
||||||
"fire.dispersionMoving": "dispersion moving",
|
"fire.dispersionMoving": "dispersion moving",
|
||||||
"fire.gunDepression": "Depresja działa",
|
"fire.gunDepression": "gun depression",
|
||||||
"fire.gunElevation": "Elewacja działa",
|
"fire.gunElevation": "gun elevation",
|
||||||
"maneuverability.forwardsSpeed": "Maksymalna prędkość do przodu",
|
"maneuverability.forwardsSpeed": "forwards speed",
|
||||||
"maneuverability.backwardsSpeed": "Maksymalna prędkość do tyłu",
|
"maneuverability.backwardsSpeed": "backwards speed",
|
||||||
"maneuverability.power": "Moc silnika",
|
"maneuverability.power": "power",
|
||||||
"maneuverability.powerToWeight": "Proporcja mocy do masy",
|
"maneuverability.powerToWeight": "power to weight",
|
||||||
"maneuverability.weight": "Masa czołgu",
|
"maneuverability.weight": "weight",
|
||||||
"maneuverability.traverseSpeed": "traverse speed"
|
"maneuverability.traverseSpeed": "traverse speed"
|
||||||
},
|
},
|
||||||
"sort_dropdown": {
|
"sort_dropdown": {
|
||||||
"label": "Filtruj",
|
"label": "Sort",
|
||||||
"groups": {
|
"groups": {
|
||||||
"sort": {
|
"sort": {
|
||||||
"no_sort": "Brak filtrów",
|
"no_sort": "No sort",
|
||||||
"label": "Filtruj według",
|
"label": "Sort by",
|
||||||
"fire": "Siła ognia",
|
"fire": "Fire",
|
||||||
"maneuverability": "Mobilność ",
|
"maneuverability": "Maneuverability",
|
||||||
"survivability": "Przetrwanie"
|
"survivability": "Survivability"
|
||||||
},
|
},
|
||||||
"direction": {
|
"direction": {
|
||||||
"label": "Direction",
|
"label": "Direction",
|
||||||
"ascending": "Rosnąco",
|
"ascending": "Ascending",
|
||||||
"descending": "Malejąco"
|
"descending": "Descending"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"warnings": {
|
"warnings": {
|
||||||
"test": "Wartości statystyk czołgów w fazie testowej mogą ulec zmianie."
|
"test": "Tanks in testing are subject to change and may not represent the final product."
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"discord": {
|
"discord": {
|
||||||
"join_short": "Dołącz do elity!",
|
"join_short": "Join cool people!",
|
||||||
"join_long": "Dołącz do topowej elity!",
|
"join_long": "Join super duper cool people!",
|
||||||
"action": "Discord"
|
"action": "Discord"
|
||||||
},
|
},
|
||||||
"hero": {
|
"hero": {
|
||||||
"credit": "Według {name} ♥️"
|
"credit": "By {name} ❤️"
|
||||||
},
|
},
|
||||||
"hot_tanks": {
|
"hot_tanks": {
|
||||||
"title": "Popularne czołgi",
|
"title": "Popular tanks",
|
||||||
"subtitle": "Ostatnie {days} dni"
|
"subtitle": "Last {days} days"
|
||||||
},
|
},
|
||||||
"other_projects": {
|
"other_projects": {
|
||||||
"title": "Inne epickie projekty"
|
"title": "Other cool projects"
|
||||||
},
|
},
|
||||||
"help_translate": "Proszę pomóż przetłumaczyć {name} na {language}!",
|
"help_translate": "Please help translate {name} to {language}!",
|
||||||
"seo_description": "Narzędzia do wszystkiego World of Tanks Blitz"
|
"seo_description": "Tools for everything World of Tanks Blitz"
|
||||||
},
|
},
|
||||||
"docs": {
|
"docs": {
|
||||||
"patches": {
|
"patches": {
|
||||||
"name": "Zapisy zmian BlitzKit",
|
"name": "BlitzKit Changelogs",
|
||||||
"seo_description": "Zapisy zmian BlitzKit: Discord bot i strona internetowa"
|
"seo_description": "Changelogs for BlitzKit Discord bot and website"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"tools": {
|
"tools": {
|
||||||
"playlist": {
|
"playlist": {
|
||||||
"reset": "Resetuj",
|
"reset": "Reset",
|
||||||
"shuffle": "Wymieszaj",
|
"shuffle": "Shuffle",
|
||||||
"remove": "Usuń czołgi, którymi grałem",
|
"remove": "Remove played",
|
||||||
"tracking": "BlitzKit zapisuje twoje bitwy",
|
"tracking": "BlitzKit is tracking your battles",
|
||||||
"sort": {
|
"sort": {
|
||||||
"button": "Filtruj według",
|
"button": "Sort by",
|
||||||
"last_played": "Ostatnio używane czołgi",
|
"last_played": "Last played",
|
||||||
"least_played": "Najmniej używane czołgi"
|
"least_played": "Least played"
|
||||||
},
|
},
|
||||||
"table": {
|
"table": {
|
||||||
"index": "#",
|
"index": "#",
|
||||||
"never": "Nigdy",
|
"never": "Never",
|
||||||
"tank": "Czołg",
|
"tank": "Tank",
|
||||||
"last_played": "Ostatnio używane czołgi",
|
"last_played": "Last played",
|
||||||
"battles": "Wszystkie bitwy na koncie",
|
"battles": "Career battles",
|
||||||
"unrecorded": "--",
|
"unrecorded": "--",
|
||||||
"wins": "Zwycięstwa"
|
"wins": "Zwycięstwa"
|
||||||
},
|
},
|
||||||
"large_warning": {
|
"large_warning": {
|
||||||
"title": "To jest mnóstwo czołgów!",
|
"title": "That's a lot of tanks!",
|
||||||
"description": "Czy na pewno chcesz stworzyć playlistę złożoną z {count} czołgów? To {time} godzin gry przy 50% zwycięstw!",
|
"description": "Are you sure you want to create a playlist of {count} tanks? That's {time} hours of gameplay at 50% winrate!",
|
||||||
"cancel": "Anuluj",
|
"cancel": "Cancel",
|
||||||
"proceed": "Zatwierdź"
|
"proceed": "Proceed"
|
||||||
},
|
},
|
||||||
"generate": "Wygeneruj playlistę",
|
"generate": "Generate playlist",
|
||||||
"name": "Playlista",
|
"name": "Playlist",
|
||||||
"description": "Generator playlisty czołgów",
|
"description": "Tank playlist generator",
|
||||||
"seo_description": "Nie wiesz, którym czołgiem grać w World of Tanks Blitz? Użyj funkcji playlisty BlitzKit, i ułóż własną listę czołgów do gry!",
|
"seo_description": "Don't know what to play in World of Tanks Blitz? Use BlitzKit Playlist to get suggestions!",
|
||||||
"button": "Wygeneruj",
|
"button": "Generate",
|
||||||
"pool_size": "{count} możliwe czołgi"
|
"pool_size": "{count} possible tanks"
|
||||||
},
|
},
|
||||||
"mixer": {
|
"mixer": {
|
||||||
"name": "Mikser",
|
"name": "Mixer",
|
||||||
"button": "Mix and match",
|
"button": "Mix and match",
|
||||||
"description": "Mix tank modules",
|
"description": "Mix tank modules",
|
||||||
"seo_description": "Mix and match hulls, turrets, and guns of tanks in World of Tanks Blitz",
|
"seo_description": "Mix and match hulls, turrets, and guns of tanks in World of Tanks Blitz",
|
||||||
"screenshot": "Zrzut ekranu",
|
"screenshot": "Screenshot",
|
||||||
"randomize": "Wymieszaj"
|
"randomize": "Randomize"
|
||||||
},
|
},
|
||||||
"guess": {
|
"guess": {
|
||||||
"name": "Zgadnij",
|
"name": "Guess",
|
||||||
"button": "What could it be?",
|
"button": "What could it be?",
|
||||||
"description": "Silhouette mini-game",
|
"description": "Silhouette mini-game",
|
||||||
"seo_description": "Play a tank guessing game with a silhouette in World of Tanks Blitz",
|
"seo_description": "Play a tank guessing game with a silhouette in World of Tanks Blitz",
|
||||||
"search": {
|
"search": {
|
||||||
"placeholder": "Wpisz odpowiedź",
|
"placeholder": "Type to guess...",
|
||||||
"skip": "Pomiń",
|
"skip": "Skip",
|
||||||
"guess": "Zgaduję",
|
"guess": "Guess",
|
||||||
"next": "Następny",
|
"next": "Next",
|
||||||
"no_results": "Brak wyników"
|
"no_results": "Brak wyników"
|
||||||
},
|
},
|
||||||
"stats": "{correct} / {total} correct, {streak} streak",
|
"stats": "{correct} / {total} correct, {streak} streak",
|
||||||
"help": {
|
"help": {
|
||||||
"title": "Odsłonić część czołgu?",
|
"title": "Partially reveal tank?",
|
||||||
"description": "Reveals the tank without showing the name. This round will be considered incorrect and break your streak!",
|
"description": "Reveals the tank without showing the name. This round will be considered incorrect and break your streak!",
|
||||||
"cancel": "Anuluj",
|
"cancel": "Cancel",
|
||||||
"reveal": "Pokaż"
|
"reveal": "Reveal"
|
||||||
},
|
},
|
||||||
"clear": "Wyczyść",
|
"clear": "Clear",
|
||||||
"select_all": "Zaznacz wszystko ",
|
"select_all": "Select all",
|
||||||
"tier": "Poziom czołgu {tier}"
|
"tier": "Tier {tier}"
|
||||||
},
|
},
|
||||||
"tankopedia": {
|
"tankopedia": {
|
||||||
"search": "Wyszukaj statystykę...",
|
"search": "Search a stat...",
|
||||||
"name": "Tankopedia",
|
"name": "Tankopedia",
|
||||||
"button": "Znajdź czołg",
|
"button": "Find tanks",
|
||||||
"description": "Encyklopedia czołgów w WoTb",
|
"description": "Blitz tank encyclopedia",
|
||||||
"seo_description": "Statistics, armor, and more for all tanks in World of Tanks Blitz",
|
"seo_description": "Statistics, armor, and more for all tanks in World of Tanks Blitz",
|
||||||
"tank_seo_title": "{name} - Tier {tier} {nationality} {class} | {website} Tankopedia | World of Tanks Blitz (WoTB)",
|
"tank_seo_title": "{name} - Tier {tier} {nationality} {class} | {website} Tankopedia | World of Tanks Blitz (WoTB)",
|
||||||
"tank_seo_description": "{name} armor, statistics, equipment, provisions, and more. {dpm} DPM, {alpha}hp alpha, {penetration}mm penetration, {speed}kph top speed, {health}hp health.",
|
"tank_seo_description": "{name} armor, statistics, equipment, provisions, and more. {dpm} DPM, {alpha}hp alpha, {penetration}mm penetration, {speed}kph top speed, {health}hp health.",
|
||||||
"visualizers": {
|
"visualizers": {
|
||||||
"reload": {
|
"reload": {
|
||||||
"skip": "Pomiń"
|
"skip": "Skip"
|
||||||
},
|
},
|
||||||
"assault": {
|
"assault": {
|
||||||
"title": "Assault shells"
|
"title": "Assault shells"
|
||||||
},
|
},
|
||||||
"rotator": {
|
"rotator": {
|
||||||
"hull": "Kadłub",
|
"hull": "Hull",
|
||||||
"turret": "Wieża",
|
"turret": "Turret",
|
||||||
"hard": "Utwardzony",
|
"hard": "Hard",
|
||||||
"medium": "Średni",
|
"medium": "Średni",
|
||||||
"soft": "Miękki",
|
"soft": "Soft",
|
||||||
"effective": "Rzeczywisty"
|
"effective": "Effective"
|
||||||
},
|
},
|
||||||
"ricochet": {
|
"ricochet": {
|
||||||
"angle": "Kąt",
|
"angle": "Angle",
|
||||||
"normalization": "Normalization",
|
"normalization": "Normalization",
|
||||||
"effective_angle": "Rzeczywisty kąt nachylenia pancerza",
|
"effective_angle": "Effective angle",
|
||||||
"armor": "Pancerz",
|
"armor": "Armor",
|
||||||
"no_ricochet": "Pociski odłamkowe nie rykoszetują."
|
"no_ricochet": "Explosive shells don't ricochet"
|
||||||
},
|
},
|
||||||
"view_range": {
|
"view_range": {
|
||||||
"camo": "Kamuflaż",
|
"camo": "Camo",
|
||||||
"ghost_factory": "Fabryka duchów",
|
"ghost_factory": "Ghost Factory",
|
||||||
"dead_rail": "Martwy tor"
|
"dead_rail": "Dead Rail"
|
||||||
},
|
},
|
||||||
"flexibility": {
|
"flexibility": {
|
||||||
"yaw": "Yaw",
|
"yaw": "Yaw",
|
||||||
@@ -656,10 +656,10 @@
|
|||||||
"loader": "Loader"
|
"loader": "Loader"
|
||||||
},
|
},
|
||||||
"maneuverability": {
|
"maneuverability": {
|
||||||
"title": "Mobilność "
|
"title": "Maneuverability"
|
||||||
},
|
},
|
||||||
"survivability": {
|
"survivability": {
|
||||||
"title": "Przetrwanie"
|
"title": "Survivability"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"compare": {
|
"compare": {
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
"development": "Development",
|
"development": "Development",
|
||||||
"opentest": "TesteAberto",
|
"opentest": "TesteAberto",
|
||||||
"preview": "Preview",
|
"preview": "Preview",
|
||||||
"production": "Produção"
|
"production": "Production"
|
||||||
},
|
},
|
||||||
"locales": {
|
"locales": {
|
||||||
"en": "Inglês",
|
"en": "Inglês",
|
||||||
@@ -187,11 +187,11 @@
|
|||||||
},
|
},
|
||||||
"website": {
|
"website": {
|
||||||
"redirect": {
|
"redirect": {
|
||||||
"title": "301: movido permanentemente",
|
"title": "301: moved permanently",
|
||||||
"body": "This page has moved. Redirecting..."
|
"body": "This page has moved. Redirecting..."
|
||||||
},
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"title": "Configurações",
|
"title": "Settings",
|
||||||
"description": "Change BlitzKit settings",
|
"description": "Change BlitzKit settings",
|
||||||
"dev_mode": "Modo de desenvolvimento",
|
"dev_mode": "Modo de desenvolvimento",
|
||||||
"auto_load_models": "Auto-load models",
|
"auto_load_models": "Auto-load models",
|
||||||
@@ -207,9 +207,9 @@
|
|||||||
"copied": "Copiado!"
|
"copied": "Copiado!"
|
||||||
},
|
},
|
||||||
"tank_search": {
|
"tank_search": {
|
||||||
"select_dialog_title": "Procura por tanque",
|
"select_dialog_title": "Search for tanks",
|
||||||
"swap_dialog_title": "Swap tank",
|
"swap_dialog_title": "Swap tank",
|
||||||
"clear_filters": "Limpar filtros",
|
"clear_filters": "Clear filters",
|
||||||
"login": "Login to use this",
|
"login": "Login to use this",
|
||||||
"search_bar_hint": "Procurar tanques...",
|
"search_bar_hint": "Procurar tanques...",
|
||||||
"recent": "Visto recentemente",
|
"recent": "Visto recentemente",
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { useModel } from "../hooks/useModel";
|
import { useModel } from "../hooks/useModel";
|
||||||
import { Guess, GuessState } from "../stores/guess";
|
import { Guess, GuessState } from "../stores/guess";
|
||||||
import { SmartCanvas } from "./SmartCanvas";
|
import { SmartCanvas } from "./SmartCanvas";
|
||||||
|
import { TankModel } from "./TankModel";
|
||||||
import { Controls } from "./Tankopedia/HeroSection/components/TankSandbox/components/Control";
|
import { Controls } from "./Tankopedia/HeroSection/components/TankSandbox/components/Control";
|
||||||
import { Lighting } from "./Tankopedia/HeroSection/components/TankSandbox/components/Lighting";
|
import { Lighting } from "./Tankopedia/HeroSection/components/TankSandbox/components/Lighting";
|
||||||
import { TankModel } from "./Tankopedia/HeroSection/components/TankSandbox/components/TankModel";
|
|
||||||
|
|
||||||
const BRIGHTNESS = 2 ** -5.5;
|
const BRIGHTNESS = 2 ** -5.5;
|
||||||
const CONTRAST = 2 ** 2;
|
const CONTRAST = 2 ** 2;
|
||||||
|
|||||||
@@ -0,0 +1,297 @@
|
|||||||
|
import {
|
||||||
|
invalidate,
|
||||||
|
useThree,
|
||||||
|
type ObjectMap,
|
||||||
|
type ThreeEvent,
|
||||||
|
} from "@react-three/fiber";
|
||||||
|
import { useRef } from "react";
|
||||||
|
import type { Texture } from "three";
|
||||||
|
import { Group, Mesh, MeshStandardMaterial, Vector2 } from "three";
|
||||||
|
import { applyPitchYawLimits } from "../core/blitz/applyPitchYawLimits";
|
||||||
|
import { hasEquipment } from "../core/blitzkit/hasEquipment";
|
||||||
|
import { modelTransformEvent } from "../core/blitzkit/modelTransform";
|
||||||
|
import { controlsEnabledEvent } from "../core/controlsEnabled";
|
||||||
|
import { useBatched } from "../hooks/useBatched";
|
||||||
|
import { useModel } from "../hooks/useModel";
|
||||||
|
import { useTankModelDefinition } from "../hooks/useTankModelDefinition";
|
||||||
|
import { useTankTransform } from "../hooks/useTankTransform";
|
||||||
|
import { Duel } from "../stores/duel";
|
||||||
|
import { Tankopedia } from "../stores/tankopedia";
|
||||||
|
import { TankopediaDisplay } from "../stores/tankopediaPersistent/constants";
|
||||||
|
import { ModelTankWrapper } from "./Armor/components/ModelTankWrapper";
|
||||||
|
|
||||||
|
interface SectionProps {
|
||||||
|
map: ObjectMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
function Tracks({ map }: SectionProps) {
|
||||||
|
const Batched = useBatched(map, true);
|
||||||
|
|
||||||
|
const position = useRef(new Vector2());
|
||||||
|
const delta = useRef(new Vector2());
|
||||||
|
|
||||||
|
const textures = useRef(new Set<Texture | null>());
|
||||||
|
|
||||||
|
function handlePointerMove(event: PointerEvent) {
|
||||||
|
delta.current.set(event.clientX, event.clientY).sub(position.current);
|
||||||
|
position.current.set(event.clientX, event.clientY);
|
||||||
|
|
||||||
|
const deltaX = delta.current.x / window.innerWidth;
|
||||||
|
const deltaY = delta.current.y / window.innerHeight;
|
||||||
|
|
||||||
|
const offset = deltaX + deltaY;
|
||||||
|
|
||||||
|
for (const texture of textures.current) {
|
||||||
|
if (!texture) continue;
|
||||||
|
texture.offset.y += offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
invalidate();
|
||||||
|
}
|
||||||
|
function handlePointerUp() {
|
||||||
|
controlsEnabledEvent.dispatch(true);
|
||||||
|
|
||||||
|
window.removeEventListener("pointermove", handlePointerMove);
|
||||||
|
window.removeEventListener("pointerup", handlePointerUp);
|
||||||
|
}
|
||||||
|
function handlePointerDown(event: ThreeEvent<PointerEvent>) {
|
||||||
|
if (Tankopedia.state.display !== TankopediaDisplay.Model) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const material = (event.object as Mesh).material as MeshStandardMaterial;
|
||||||
|
|
||||||
|
textures.current = new Set([
|
||||||
|
material.map,
|
||||||
|
material.aoMap,
|
||||||
|
material.normalMap,
|
||||||
|
material.roughnessMap,
|
||||||
|
material.metalnessMap,
|
||||||
|
]);
|
||||||
|
|
||||||
|
position.current.set(event.clientX, event.clientY);
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
controlsEnabledEvent.dispatch(false);
|
||||||
|
|
||||||
|
window.addEventListener("pointermove", handlePointerMove);
|
||||||
|
window.addEventListener("pointerup", handlePointerUp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Batched
|
||||||
|
onPointerDown={handlePointerDown}
|
||||||
|
slicer={(node) => {
|
||||||
|
return node.name.startsWith("chassis_track_");
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Hull({ map }: SectionProps) {
|
||||||
|
const Batched = useBatched(map, true);
|
||||||
|
|
||||||
|
function handlePointerDown(event: ThreeEvent<PointerEvent>) {
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Batched
|
||||||
|
onPointerDown={handlePointerDown}
|
||||||
|
slicer={(node) => {
|
||||||
|
const isHull = node.name === "hull";
|
||||||
|
const isWheel = node.name.startsWith("chassis_wheel_");
|
||||||
|
|
||||||
|
return isHull || isWheel;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Turret({ map }: SectionProps) {
|
||||||
|
const turret = Duel.use((state) => state.protagonist.turret);
|
||||||
|
const gun = Duel.use((state) => state.protagonist.gun);
|
||||||
|
|
||||||
|
const tankModelDefinition = useTankModelDefinition();
|
||||||
|
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
|
||||||
|
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
||||||
|
|
||||||
|
const Batched = useBatched(map, true);
|
||||||
|
|
||||||
|
const position = useRef(new Vector2());
|
||||||
|
const delta = useRef(new Vector2());
|
||||||
|
|
||||||
|
const canvas = useThree((state) => state.gl.domElement);
|
||||||
|
|
||||||
|
function onPointerDown(event: ThreeEvent<PointerEvent>) {
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
position.current.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 hasImprovedVerticalStabilizer = hasEquipment(
|
||||||
|
122,
|
||||||
|
Duel.state.protagonist.tank.equipment_preset,
|
||||||
|
Duel.state.protagonist.equipmentMatrix,
|
||||||
|
);
|
||||||
|
const hasDownImprovedVerticalStabilizer = hasEquipment(
|
||||||
|
124,
|
||||||
|
Duel.state.protagonist.tank.equipment_preset,
|
||||||
|
Duel.state.protagonist.equipmentMatrix,
|
||||||
|
);
|
||||||
|
const boundingRect = canvas.getBoundingClientRect();
|
||||||
|
|
||||||
|
delta.current.set(event.clientX, event.clientY).sub(position.current);
|
||||||
|
position.current.set(event.clientX, event.clientY);
|
||||||
|
|
||||||
|
const [pitch, yaw] = applyPitchYawLimits(
|
||||||
|
modelTransformEvent.last!.pitch,
|
||||||
|
modelTransformEvent.last!.yaw +
|
||||||
|
delta.current.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 (
|
||||||
|
<Batched
|
||||||
|
onPointerDown={onPointerDown}
|
||||||
|
slicer={(node) => {
|
||||||
|
const isCurrentTurret =
|
||||||
|
node.name ===
|
||||||
|
`turret_${turretModelDefinition.model_id
|
||||||
|
.toString()
|
||||||
|
.padStart(2, "0")}`;
|
||||||
|
|
||||||
|
return isCurrentTurret;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Gun({ map }: SectionProps) {
|
||||||
|
const Batched = useBatched(map, true);
|
||||||
|
|
||||||
|
const turret = Duel.use((state) => state.protagonist.turret);
|
||||||
|
const gun = Duel.use((state) => state.protagonist.gun);
|
||||||
|
|
||||||
|
const tankModelDefinition = useTankModelDefinition();
|
||||||
|
const turretModelDefinition = tankModelDefinition.turrets[turret.id];
|
||||||
|
const gunModelDefinition = turretModelDefinition.guns[gun.id];
|
||||||
|
|
||||||
|
const position = useRef(new Vector2());
|
||||||
|
const delta = useRef(new Vector2());
|
||||||
|
const pitch = useRef(0);
|
||||||
|
const yaw = useRef(0);
|
||||||
|
|
||||||
|
const canvas = useThree((state) => state.gl.domElement);
|
||||||
|
|
||||||
|
function handlePointerMove(event: PointerEvent) {
|
||||||
|
const hasImprovedVerticalStabilizer = hasEquipment(
|
||||||
|
122,
|
||||||
|
Duel.state.protagonist.tank.equipment_preset,
|
||||||
|
Duel.state.protagonist.equipmentMatrix,
|
||||||
|
);
|
||||||
|
const hasDownImprovedVerticalStabilizer = hasEquipment(
|
||||||
|
124,
|
||||||
|
Duel.state.protagonist.tank.equipment_preset,
|
||||||
|
Duel.state.protagonist.equipmentMatrix,
|
||||||
|
);
|
||||||
|
const boundingRect = canvas.getBoundingClientRect();
|
||||||
|
delta.current.set(event.clientX, event.clientY).sub(position.current);
|
||||||
|
position.current.set(event.clientX, event.clientY);
|
||||||
|
|
||||||
|
[pitch.current, yaw.current] = applyPitchYawLimits(
|
||||||
|
pitch.current - delta.current.y * (Math.PI / boundingRect.height),
|
||||||
|
yaw.current + delta.current.x * (Math.PI / boundingRect.width),
|
||||||
|
gunModelDefinition.pitch!,
|
||||||
|
turretModelDefinition.yaw,
|
||||||
|
hasImprovedVerticalStabilizer,
|
||||||
|
hasDownImprovedVerticalStabilizer,
|
||||||
|
);
|
||||||
|
modelTransformEvent.dispatch({ pitch: pitch.current, yaw: yaw.current });
|
||||||
|
}
|
||||||
|
function handlePointerUp() {
|
||||||
|
controlsEnabledEvent.dispatch(true);
|
||||||
|
window.removeEventListener("pointermove", handlePointerMove);
|
||||||
|
window.removeEventListener("pointerup", handlePointerUp);
|
||||||
|
}
|
||||||
|
function onPointerDown(event: ThreeEvent<PointerEvent>) {
|
||||||
|
event.stopPropagation();
|
||||||
|
|
||||||
|
controlsEnabledEvent.dispatch(false);
|
||||||
|
Tankopedia.mutate((draft) => {
|
||||||
|
draft.shot = undefined;
|
||||||
|
draft.highlightArmor = undefined;
|
||||||
|
});
|
||||||
|
|
||||||
|
position.current.set(event.clientX, event.clientY);
|
||||||
|
pitch.current = modelTransformEvent.last!.pitch;
|
||||||
|
yaw.current = modelTransformEvent.last!.yaw;
|
||||||
|
|
||||||
|
window.addEventListener("pointermove", handlePointerMove);
|
||||||
|
window.addEventListener("pointerup", handlePointerUp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Batched
|
||||||
|
onPointerDown={onPointerDown}
|
||||||
|
slicer={(node) => {
|
||||||
|
const isCurrentMantlet =
|
||||||
|
node.name ===
|
||||||
|
`gun_${gunModelDefinition.model_id.toString().padStart(2, "0")}_mask`;
|
||||||
|
const isCurrentGun =
|
||||||
|
node.name ===
|
||||||
|
`gun_${gunModelDefinition.model_id.toString().padStart(2, "0")}`;
|
||||||
|
|
||||||
|
return isCurrentGun || isCurrentMantlet;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function TankModel() {
|
||||||
|
const protagonist = Duel.use((draft) => draft.protagonist);
|
||||||
|
|
||||||
|
const track = Duel.use((state) => state.protagonist.track);
|
||||||
|
const turret = Duel.use((state) => state.protagonist.turret);
|
||||||
|
|
||||||
|
const hullContainer = useRef<Group>(null);
|
||||||
|
const turretContainer = useRef<Group>(null!);
|
||||||
|
const gunContainer = useRef<Group>(null!);
|
||||||
|
|
||||||
|
const { gltf } = useModel(protagonist.tank.id);
|
||||||
|
|
||||||
|
useTankTransform(track, turret, turretContainer, gunContainer);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ModelTankWrapper ref={hullContainer}>
|
||||||
|
<Tracks map={gltf} />
|
||||||
|
<Hull map={gltf} />
|
||||||
|
|
||||||
|
<group ref={turretContainer}>
|
||||||
|
<Turret map={gltf} />
|
||||||
|
|
||||||
|
<group ref={gunContainer}>
|
||||||
|
<Gun map={gltf} />
|
||||||
|
</group>
|
||||||
|
</group>
|
||||||
|
</ModelTankWrapper>
|
||||||
|
);
|
||||||
|
}
|
||||||
+1
-1
@@ -125,7 +125,7 @@ export function Lighting({ hasPbr }: Props) {
|
|||||||
position={position}
|
position={position}
|
||||||
intensity={intensity}
|
intensity={intensity}
|
||||||
penumbra={1}
|
penumbra={1}
|
||||||
castShadow={highGraphics}
|
castShadow={highGraphics && index === 0}
|
||||||
decay={1}
|
decay={1}
|
||||||
color="#ffffff"
|
color="#ffffff"
|
||||||
angle={0}
|
angle={0}
|
||||||
|
|||||||
-271
@@ -1,271 +0,0 @@
|
|||||||
import { invalidate, useThree, type ThreeEvent } from "@react-three/fiber";
|
|
||||||
import { useRef } from "react";
|
|
||||||
import { Group, Mesh, MeshStandardMaterial, Vector2 } from "three";
|
|
||||||
import { applyPitchYawLimits } from "../../../../../../core/blitz/applyPitchYawLimits";
|
|
||||||
import { hasEquipment } from "../../../../../../core/blitzkit/hasEquipment";
|
|
||||||
import { jsxTree } from "../../../../../../core/blitzkit/jsxTree";
|
|
||||||
import { modelTransformEvent } from "../../../../../../core/blitzkit/modelTransform";
|
|
||||||
import { controlsEnabledEvent } from "../../../../../../core/controlsEnabled";
|
|
||||||
import { useModel } from "../../../../../../hooks/useModel";
|
|
||||||
import { useTankModelDefinition } from "../../../../../../hooks/useTankModelDefinition";
|
|
||||||
import { useTankTransform } from "../../../../../../hooks/useTankTransform";
|
|
||||||
import { Duel } from "../../../../../../stores/duel";
|
|
||||||
import { Tankopedia } from "../../../../../../stores/tankopedia";
|
|
||||||
import { TankopediaDisplay } from "../../../../../../stores/tankopediaPersistent/constants";
|
|
||||||
import { ModelTankWrapper } from "../../../../../Armor/components/ModelTankWrapper";
|
|
||||||
|
|
||||||
export function TankModel() {
|
|
||||||
const protagonist = Duel.use((draft) => draft.protagonist);
|
|
||||||
const track = Duel.use((state) => state.protagonist.track);
|
|
||||||
const turret = Duel.use((state) => state.protagonist.turret);
|
|
||||||
const canvas = useThree((state) => state.gl.domElement);
|
|
||||||
const hullContainer = useRef<Group>(null);
|
|
||||||
const turretContainer = useRef<Group>(null!);
|
|
||||||
const gunContainer = useRef<Group>(null!);
|
|
||||||
const tankModelDefinition = useTankModelDefinition();
|
|
||||||
const turretModelDefinition =
|
|
||||||
tankModelDefinition.turrets[protagonist.turret.id];
|
|
||||||
const gunModelDefinition = turretModelDefinition.guns[protagonist.gun.id];
|
|
||||||
const { gltf } = useModel(protagonist.tank.id);
|
|
||||||
const nodes = Object.values(gltf.nodes);
|
|
||||||
|
|
||||||
useTankTransform(track, turret, turretContainer, gunContainer);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<ModelTankWrapper ref={hullContainer}>
|
|
||||||
{nodes.map((node) => {
|
|
||||||
const isHull = node.name === "hull";
|
|
||||||
const isWheel = node.name.startsWith("chassis_wheel_");
|
|
||||||
const isTrack = node.name.startsWith("chassis_track_");
|
|
||||||
const isVisible = isHull || isWheel || isTrack;
|
|
||||||
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.display === 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 jsxTree(node, {
|
|
||||||
mesh(_, props, key) {
|
|
||||||
return (
|
|
||||||
<mesh
|
|
||||||
{...props}
|
|
||||||
key={key}
|
|
||||||
onPointerDown={onPointerDown}
|
|
||||||
castShadow
|
|
||||||
receiveShadow
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
})}
|
|
||||||
|
|
||||||
<group ref={turretContainer}>
|
|
||||||
{nodes.map((node) => {
|
|
||||||
const isTurret = node.name.startsWith("turret_");
|
|
||||||
const isCurrentTurret =
|
|
||||||
node.name ===
|
|
||||||
`turret_${turretModelDefinition.model_id
|
|
||||||
.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 hasImprovedVerticalStabilizer = hasEquipment(
|
|
||||||
122,
|
|
||||||
Duel.state.protagonist.tank.equipment_preset,
|
|
||||||
Duel.state.protagonist.equipmentMatrix,
|
|
||||||
);
|
|
||||||
const hasDownImprovedVerticalStabilizer = hasEquipment(
|
|
||||||
124,
|
|
||||||
Duel.state.protagonist.tank.equipment_preset,
|
|
||||||
Duel.state.protagonist.equipmentMatrix,
|
|
||||||
);
|
|
||||||
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 jsxTree(node, {
|
|
||||||
mesh(_, props, key) {
|
|
||||||
return (
|
|
||||||
<mesh
|
|
||||||
{...props}
|
|
||||||
key={key}
|
|
||||||
onPointerDown={onPointerDown}
|
|
||||||
castShadow
|
|
||||||
receiveShadow
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
})}
|
|
||||||
|
|
||||||
<group ref={gunContainer}>
|
|
||||||
{nodes.map((node) => {
|
|
||||||
const isCurrentMantlet =
|
|
||||||
node.name ===
|
|
||||||
`gun_${gunModelDefinition.model_id
|
|
||||||
.toString()
|
|
||||||
.padStart(2, "0")}_mask`;
|
|
||||||
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 hasImprovedVerticalStabilizer = hasEquipment(
|
|
||||||
122,
|
|
||||||
Duel.state.protagonist.tank.equipment_preset,
|
|
||||||
Duel.state.protagonist.equipmentMatrix,
|
|
||||||
);
|
|
||||||
const hasDownImprovedVerticalStabilizer = hasEquipment(
|
|
||||||
124,
|
|
||||||
Duel.state.protagonist.tank.equipment_preset,
|
|
||||||
Duel.state.protagonist.equipmentMatrix,
|
|
||||||
);
|
|
||||||
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 jsxTree(node, {
|
|
||||||
mesh(_, props, key) {
|
|
||||||
return (
|
|
||||||
<mesh
|
|
||||||
{...props}
|
|
||||||
key={key}
|
|
||||||
onPointerDown={onPointerDown}
|
|
||||||
castShadow
|
|
||||||
receiveShadow
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
})}
|
|
||||||
</group>
|
|
||||||
</group>
|
|
||||||
</ModelTankWrapper>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
+1
-1
@@ -23,12 +23,12 @@ import {
|
|||||||
type ThicknessRange,
|
type ThicknessRange,
|
||||||
} from "../../../../Armor/components/StaticArmor";
|
} from "../../../../Armor/components/StaticArmor";
|
||||||
import { SmartCanvas } from "../../../../SmartCanvas";
|
import { SmartCanvas } from "../../../../SmartCanvas";
|
||||||
|
import { TankModel } from "../../../../TankModel";
|
||||||
import { AutoClear } from "./components/AutoClear";
|
import { AutoClear } from "./components/AutoClear";
|
||||||
import { Controls } from "./components/Control";
|
import { Controls } from "./components/Control";
|
||||||
import { InitialAligner } from "./components/InitialAligner";
|
import { InitialAligner } from "./components/InitialAligner";
|
||||||
import { Lighting } from "./components/Lighting";
|
import { Lighting } from "./components/Lighting";
|
||||||
import { SceneProps } from "./components/SceneProps";
|
import { SceneProps } from "./components/SceneProps";
|
||||||
import { TankModel } from "./components/TankModel";
|
|
||||||
|
|
||||||
interface TankSandboxProps {
|
interface TankSandboxProps {
|
||||||
thicknessRange: ThicknessRange;
|
thicknessRange: ThicknessRange;
|
||||||
|
|||||||
@@ -0,0 +1,89 @@
|
|||||||
|
import type { ObjectMap } from "@react-three/fiber";
|
||||||
|
import type { ComponentProps } from "react";
|
||||||
|
import {
|
||||||
|
BatchedMesh,
|
||||||
|
Group,
|
||||||
|
Mesh,
|
||||||
|
MeshStandardMaterial,
|
||||||
|
type Object3D,
|
||||||
|
} from "three";
|
||||||
|
|
||||||
|
interface BatchedProps extends ComponentProps<"group"> {
|
||||||
|
slicer: (node: Object3D) => boolean;
|
||||||
|
mutator?: (mesh: Mesh) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function useBatched(map: ObjectMap, shadows = false) {
|
||||||
|
return function Batched({ slicer, mutator, ...props }: BatchedProps) {
|
||||||
|
const groups = new Map<
|
||||||
|
MeshStandardMaterial,
|
||||||
|
{ clonedMaterial: MeshStandardMaterial; meshes: Mesh[] }
|
||||||
|
>();
|
||||||
|
|
||||||
|
for (const node of Object.values(map.nodes)) {
|
||||||
|
if (!slicer(node)) continue;
|
||||||
|
|
||||||
|
node.traverse((object) => {
|
||||||
|
if (!(object instanceof Mesh)) return;
|
||||||
|
|
||||||
|
const originalMaterial = object.material;
|
||||||
|
|
||||||
|
if (!(originalMaterial instanceof MeshStandardMaterial)) return;
|
||||||
|
|
||||||
|
let group = groups.get(originalMaterial);
|
||||||
|
|
||||||
|
if (!group) {
|
||||||
|
group = {
|
||||||
|
clonedMaterial: originalMaterial.clone(),
|
||||||
|
meshes: [],
|
||||||
|
};
|
||||||
|
groups.set(originalMaterial, group);
|
||||||
|
}
|
||||||
|
|
||||||
|
group.meshes.push(object);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const wrapper = new Group();
|
||||||
|
|
||||||
|
for (const { clonedMaterial: material, meshes } of groups.values()) {
|
||||||
|
let vertices = 0;
|
||||||
|
let indices = 0;
|
||||||
|
|
||||||
|
for (const mesh of meshes) {
|
||||||
|
vertices += mesh.geometry.attributes.position.count;
|
||||||
|
indices += mesh.geometry.index!.count;
|
||||||
|
}
|
||||||
|
|
||||||
|
const batched = new BatchedMesh(
|
||||||
|
meshes.length,
|
||||||
|
vertices,
|
||||||
|
indices,
|
||||||
|
material,
|
||||||
|
);
|
||||||
|
|
||||||
|
for (const mesh of meshes) {
|
||||||
|
const geometryId = batched.addGeometry(mesh.geometry);
|
||||||
|
const instanceId = batched.addInstance(geometryId);
|
||||||
|
|
||||||
|
mesh.updateWorldMatrix(true, false);
|
||||||
|
batched.setMatrixAt(instanceId, mesh.matrixWorld);
|
||||||
|
|
||||||
|
if (shadows) {
|
||||||
|
batched.castShadow = true;
|
||||||
|
batched.receiveShadow = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
mutator?.(mesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
wrapper.add(batched);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<group {...props}>
|
||||||
|
<primitive object={wrapper} />
|
||||||
|
</group>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in new issue
Block a user