*Improved Platform (MiscGroups) transforms. Positions are now 100% accurate, rotations ~90% *Platforms won't be rendered if their tilt is too big *Misc objects now use yawData.yaw as their "y rotation" in rendering *Renamed Platforms layer
38 lines
1.3 KiB
JavaScript
38 lines
1.3 KiB
JavaScript
import { ReactSVG } from 'react-svg';
|
|
import AlwaysUpText from '../text/AlwaysUpText';
|
|
|
|
export default function SignalBoxRenderer(props) {
|
|
const { object } = props;
|
|
const [x, y] = object.pos.toSVGCoords();
|
|
const text = object.getPrintableSignalBoxName();
|
|
|
|
const yaw = object.yawData?.yaw || object.rot.y;
|
|
const rotDiff = object.def.undef ? Math.round(yaw / 90) * (-90) : object.def.rot * 90;
|
|
const rot = yaw + rotDiff;
|
|
|
|
return (
|
|
<g className="signalbox" transform={`translate(${x}, ${y}) rotate(${rot})`}>
|
|
<g className="signalbox-icon" transform={`translate(-4.725, -4.725)`}>
|
|
<ReactSVG
|
|
src={`${process.env.PUBLIC_URL}/assets/signalboxes/${object.def.icon}`}
|
|
wrapper='svg'
|
|
|
|
beforeInjection={(svg) => {
|
|
svg.setAttribute('width', '2.5mm');
|
|
svg.setAttribute('height', '2.5mm');
|
|
}}
|
|
/>
|
|
</g>
|
|
<AlwaysUpText
|
|
baseRot={rot - 90}
|
|
additionalRot={180}
|
|
offsetY={6}
|
|
textProps={{
|
|
textAnchor: 'middle'
|
|
}}
|
|
text={text}
|
|
/>
|
|
</g>
|
|
);
|
|
}
|
|
|