mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-07-16 00:44:59 +00:00
add more shapes
This commit is contained in:
parent
3a99e77e96
commit
1c6d7effac
6 changed files with 93 additions and 5 deletions
|
|
@ -14,6 +14,7 @@ export function useStaticShape(shapeName: string) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function ShapeTexture({ materialName }: { materialName: string }) {
|
export function ShapeTexture({ materialName }: { materialName: string }) {
|
||||||
|
// console.log({ materialName });
|
||||||
const url = shapeTextureToUrl(materialName, FALLBACK_URL);
|
const url = shapeTextureToUrl(materialName, FALLBACK_URL);
|
||||||
const texture = useTexture(url, (texture) => setupColor(texture));
|
const texture = useTexture(url, (texture) => setupColor(texture));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,17 @@ import {
|
||||||
import { ShapeModel, ShapePlaceholder } from "./GenericShape";
|
import { ShapeModel, ShapePlaceholder } from "./GenericShape";
|
||||||
|
|
||||||
const dataBlockToShapeName = {
|
const dataBlockToShapeName = {
|
||||||
RepairPack: "pack_upgrade_repair.dts",
|
|
||||||
Flag: "flag.dts",
|
Flag: "flag.dts",
|
||||||
|
InventoryDeployable: "pack_deploy_inventory.dts",
|
||||||
|
RepairKit: "repair_kit.dts",
|
||||||
|
RepairPack: "pack_upgrade_repair.dts",
|
||||||
|
RepairPatch: "repair_patch.dts",
|
||||||
|
CloakingPack: "pack_upgrade_cloaking.dts",
|
||||||
|
ShieldPack: "pack_upgrade_shield.dts",
|
||||||
|
EnergyPack: "pack_upgrade_energy.dts",
|
||||||
|
SniperRifle: "weapon_sniper.dts",
|
||||||
|
PlasmaAmmo: "ammo_plasma.dts",
|
||||||
|
Plasma: "weapon_plasma.dts",
|
||||||
};
|
};
|
||||||
|
|
||||||
let _caseInsensitiveLookup: Record<string, string>;
|
let _caseInsensitiveLookup: Record<string, string>;
|
||||||
|
|
@ -36,6 +45,10 @@ export function Item({ object }: { object: ConsoleObject }) {
|
||||||
|
|
||||||
const shapeName = getDataBlockShape(dataBlock);
|
const shapeName = getDataBlockShape(dataBlock);
|
||||||
|
|
||||||
|
if (!shapeName) {
|
||||||
|
console.error(`<Item> missing shape for dataBlock: ${dataBlock}`);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<group
|
<group
|
||||||
quaternion={q}
|
quaternion={q}
|
||||||
|
|
@ -44,7 +57,7 @@ export function Item({ object }: { object: ConsoleObject }) {
|
||||||
>
|
>
|
||||||
{shapeName ? (
|
{shapeName ? (
|
||||||
<ErrorBoundary fallback={<ShapePlaceholder color="red" />}>
|
<ErrorBoundary fallback={<ShapePlaceholder color="red" />}>
|
||||||
<Suspense fallback={<ShapePlaceholder color="yellow" />}>
|
<Suspense fallback={<ShapePlaceholder color="pink" />}>
|
||||||
<ShapeModel shapeName={shapeName} />
|
<ShapeModel shapeName={shapeName} />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,18 @@ import {
|
||||||
import { ShapeModel, ShapePlaceholder } from "./GenericShape";
|
import { ShapeModel, ShapePlaceholder } from "./GenericShape";
|
||||||
|
|
||||||
const dataBlockToShapeName = {
|
const dataBlockToShapeName = {
|
||||||
StationInventory: "station_inv_human.dts",
|
Banner_Honor: "banner_honor.dts",
|
||||||
SensorLargePulse: "sensor_pulse_large.dts",
|
Banner_Strength: "banner_strength.dts",
|
||||||
|
Banner_Unity: "banner_unity.dts",
|
||||||
|
ExteriorFlagStand: "ext_flagstand.dts",
|
||||||
GeneratorLarge: "station_generator_large.dts",
|
GeneratorLarge: "station_generator_large.dts",
|
||||||
|
LogoProjector: "teamlogo_projector.dts",
|
||||||
|
SensorLargePulse: "sensor_pulse_large.dts",
|
||||||
|
SensorMediumPulse: "sensor_pulse_medium.dts",
|
||||||
SolarPanel: "solarpanel.dts",
|
SolarPanel: "solarpanel.dts",
|
||||||
|
StationInventory: "station_inv_human.dts",
|
||||||
|
StationVehicle: "vehicle_pad_station.dts",
|
||||||
|
StationVehiclePad: "vehicle_pad.dts",
|
||||||
};
|
};
|
||||||
|
|
||||||
let _caseInsensitiveLookup: Record<string, string>;
|
let _caseInsensitiveLookup: Record<string, string>;
|
||||||
|
|
@ -38,6 +46,10 @@ export function StaticShape({ object }: { object: ConsoleObject }) {
|
||||||
|
|
||||||
const shapeName = getDataBlockShape(dataBlock);
|
const shapeName = getDataBlockShape(dataBlock);
|
||||||
|
|
||||||
|
if (!shapeName) {
|
||||||
|
console.error(`<StaticShape> missing shape for dataBlock: ${dataBlock}`);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<group
|
<group
|
||||||
quaternion={q}
|
quaternion={q}
|
||||||
|
|
|
||||||
60
src/components/Turret.tsx
Normal file
60
src/components/Turret.tsx
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
import { Suspense, useMemo } from "react";
|
||||||
|
import { ErrorBoundary } from "react-error-boundary";
|
||||||
|
import {
|
||||||
|
ConsoleObject,
|
||||||
|
getPosition,
|
||||||
|
getProperty,
|
||||||
|
getRotation,
|
||||||
|
getScale,
|
||||||
|
} from "../mission";
|
||||||
|
import { ShapeModel, ShapePlaceholder } from "./GenericShape";
|
||||||
|
|
||||||
|
const dataBlockToShapeName = {
|
||||||
|
SentryTurret: "turret_sentry.dts",
|
||||||
|
TurretBaseLarge: "turret_base_large.dts",
|
||||||
|
};
|
||||||
|
|
||||||
|
let _caseInsensitiveLookup: Record<string, string>;
|
||||||
|
|
||||||
|
function getDataBlockShape(dataBlock: string) {
|
||||||
|
if (!_caseInsensitiveLookup) {
|
||||||
|
_caseInsensitiveLookup = Object.fromEntries(
|
||||||
|
Object.entries(dataBlockToShapeName).map(([key, value]) => {
|
||||||
|
return [key.toLowerCase(), value];
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return _caseInsensitiveLookup[dataBlock.toLowerCase()];
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Turret({ object }: { object: ConsoleObject }) {
|
||||||
|
const dataBlock = getProperty(object, "dataBlock").value;
|
||||||
|
|
||||||
|
const [z, y, x] = useMemo(() => getPosition(object), [object]);
|
||||||
|
const [scaleX, scaleY, scaleZ] = useMemo(() => getScale(object), [object]);
|
||||||
|
const q = useMemo(() => getRotation(object, true), [object]);
|
||||||
|
|
||||||
|
const shapeName = getDataBlockShape(dataBlock);
|
||||||
|
|
||||||
|
if (!shapeName) {
|
||||||
|
console.error(`<Turret> missing shape for dataBlock: ${dataBlock}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<group
|
||||||
|
quaternion={q}
|
||||||
|
position={[x - 1024, y, z - 1024]}
|
||||||
|
scale={[-scaleX, scaleY, scaleZ]}
|
||||||
|
>
|
||||||
|
{shapeName ? (
|
||||||
|
<ErrorBoundary fallback={<ShapePlaceholder color="red" />}>
|
||||||
|
<Suspense fallback={<ShapePlaceholder color="yellow" />}>
|
||||||
|
<ShapeModel shapeName={shapeName} />
|
||||||
|
</Suspense>
|
||||||
|
</ErrorBoundary>
|
||||||
|
) : (
|
||||||
|
<ShapePlaceholder color="orange" />
|
||||||
|
)}
|
||||||
|
</group>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
@ -8,6 +8,7 @@ import { Sun } from "./Sun";
|
||||||
import { TSStatic } from "./TSStatic";
|
import { TSStatic } from "./TSStatic";
|
||||||
import { StaticShape } from "./StaticShape";
|
import { StaticShape } from "./StaticShape";
|
||||||
import { Item } from "./Item";
|
import { Item } from "./Item";
|
||||||
|
import { Turret } from "./Turret";
|
||||||
|
|
||||||
const componentMap = {
|
const componentMap = {
|
||||||
InteriorInstance,
|
InteriorInstance,
|
||||||
|
|
@ -18,6 +19,7 @@ const componentMap = {
|
||||||
Sun,
|
Sun,
|
||||||
TerrainBlock,
|
TerrainBlock,
|
||||||
TSStatic,
|
TSStatic,
|
||||||
|
Turret,
|
||||||
WaterBlock,
|
WaterBlock,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ export function getUrlForPath(resourcePath: string, fallbackUrl?: string) {
|
||||||
sourcePath = getSource(resourcePath);
|
sourcePath = getSource(resourcePath);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (fallbackUrl) {
|
if (fallbackUrl) {
|
||||||
console.error(err);
|
// console.error(err);
|
||||||
return fallbackUrl;
|
return fallbackUrl;
|
||||||
} else {
|
} else {
|
||||||
throw err;
|
throw err;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue