mirror of
https://github.com/exogen/t2-mapper.git
synced 2026-01-19 20:25:01 +00:00
add more shapes
This commit is contained in:
parent
3a99e77e96
commit
1c6d7effac
|
|
@ -14,6 +14,7 @@ export function useStaticShape(shapeName: string) {
|
|||
}
|
||||
|
||||
export function ShapeTexture({ materialName }: { materialName: string }) {
|
||||
// console.log({ materialName });
|
||||
const url = shapeTextureToUrl(materialName, FALLBACK_URL);
|
||||
const texture = useTexture(url, (texture) => setupColor(texture));
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,17 @@ import {
|
|||
import { ShapeModel, ShapePlaceholder } from "./GenericShape";
|
||||
|
||||
const dataBlockToShapeName = {
|
||||
RepairPack: "pack_upgrade_repair.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>;
|
||||
|
|
@ -36,6 +45,10 @@ export function Item({ object }: { object: ConsoleObject }) {
|
|||
|
||||
const shapeName = getDataBlockShape(dataBlock);
|
||||
|
||||
if (!shapeName) {
|
||||
console.error(`<Item> missing shape for dataBlock: ${dataBlock}`);
|
||||
}
|
||||
|
||||
return (
|
||||
<group
|
||||
quaternion={q}
|
||||
|
|
@ -44,7 +57,7 @@ export function Item({ object }: { object: ConsoleObject }) {
|
|||
>
|
||||
{shapeName ? (
|
||||
<ErrorBoundary fallback={<ShapePlaceholder color="red" />}>
|
||||
<Suspense fallback={<ShapePlaceholder color="yellow" />}>
|
||||
<Suspense fallback={<ShapePlaceholder color="pink" />}>
|
||||
<ShapeModel shapeName={shapeName} />
|
||||
</Suspense>
|
||||
</ErrorBoundary>
|
||||
|
|
|
|||
|
|
@ -10,10 +10,18 @@ import {
|
|||
import { ShapeModel, ShapePlaceholder } from "./GenericShape";
|
||||
|
||||
const dataBlockToShapeName = {
|
||||
StationInventory: "station_inv_human.dts",
|
||||
SensorLargePulse: "sensor_pulse_large.dts",
|
||||
Banner_Honor: "banner_honor.dts",
|
||||
Banner_Strength: "banner_strength.dts",
|
||||
Banner_Unity: "banner_unity.dts",
|
||||
ExteriorFlagStand: "ext_flagstand.dts",
|
||||
GeneratorLarge: "station_generator_large.dts",
|
||||
LogoProjector: "teamlogo_projector.dts",
|
||||
SensorLargePulse: "sensor_pulse_large.dts",
|
||||
SensorMediumPulse: "sensor_pulse_medium.dts",
|
||||
SolarPanel: "solarpanel.dts",
|
||||
StationInventory: "station_inv_human.dts",
|
||||
StationVehicle: "vehicle_pad_station.dts",
|
||||
StationVehiclePad: "vehicle_pad.dts",
|
||||
};
|
||||
|
||||
let _caseInsensitiveLookup: Record<string, string>;
|
||||
|
|
@ -38,6 +46,10 @@ export function StaticShape({ object }: { object: ConsoleObject }) {
|
|||
|
||||
const shapeName = getDataBlockShape(dataBlock);
|
||||
|
||||
if (!shapeName) {
|
||||
console.error(`<StaticShape> missing shape for dataBlock: ${dataBlock}`);
|
||||
}
|
||||
|
||||
return (
|
||||
<group
|
||||
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 { StaticShape } from "./StaticShape";
|
||||
import { Item } from "./Item";
|
||||
import { Turret } from "./Turret";
|
||||
|
||||
const componentMap = {
|
||||
InteriorInstance,
|
||||
|
|
@ -18,6 +19,7 @@ const componentMap = {
|
|||
Sun,
|
||||
TerrainBlock,
|
||||
TSStatic,
|
||||
Turret,
|
||||
WaterBlock,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ export function getUrlForPath(resourcePath: string, fallbackUrl?: string) {
|
|||
sourcePath = getSource(resourcePath);
|
||||
} catch (err) {
|
||||
if (fallbackUrl) {
|
||||
console.error(err);
|
||||
// console.error(err);
|
||||
return fallbackUrl;
|
||||
} else {
|
||||
throw err;
|
||||
|
|
|
|||
Loading…
Reference in a new issue