t2-mapper/src/components/TSStatic.tsx

26 lines
893 B
TypeScript
Raw Normal View History

import { useMemo } from "react";
import type { TorqueObject } from "../torqueScript";
import { getPosition, getProperty, getRotation, getScale } from "../mission";
import { ShapeRenderer } from "./GenericShape";
import { ShapeInfoProvider } from "./ShapeInfoProvider";
2025-11-15 03:05:24 +00:00
export function TSStatic({ object }: { object: TorqueObject }) {
const shapeName = getProperty(object, "shapeName");
2025-11-15 03:05:24 +00:00
const position = useMemo(() => getPosition(object), [object]);
const q = useMemo(() => getRotation(object), [object]);
const scale = useMemo(() => getScale(object), [object]);
2025-11-15 03:05:24 +00:00
if (!shapeName) {
console.error("<TSStatic> missing shapeName for object", object);
}
2025-11-15 03:05:24 +00:00
return (
2025-12-14 19:06:57 +00:00
<ShapeInfoProvider type="TSStatic" object={object} shapeName={shapeName}>
<group position={position} quaternion={q} scale={scale}>
2025-12-14 19:06:57 +00:00
<ShapeRenderer />
</group>
</ShapeInfoProvider>
2025-11-15 03:05:24 +00:00
);
}