diff --git a/client/src/units/unit.ts b/client/src/units/unit.ts index 88f10943..fd092a2e 100644 --- a/client/src/units/unit.ts +++ b/client/src/units/unit.ts @@ -363,10 +363,12 @@ export class Unit extends Marker { getMap().removeLayer(this); } else { + this.setLatLng(new LatLng(this.getFlightData().latitude, this.getFlightData().longitude)); var element = this.getElement(); if (element != null) { - element.querySelector(".unit-vvi")?.setAttribute("style", `height: ${15 + this.getFlightData().speed / 5}px; transform:rotate(${rad2deg(this.getFlightData().heading)}deg);`); + + element.querySelector(".unit-vvi")?.setAttribute("style", `height: ${15 + this.getFlightData().speed / 5}px;`); element.querySelector(".unit")?.setAttribute("data-pilot", this.getMissionData().flags.human? "human": "ai"); element.querySelector(".unit-fuel-level")?.setAttribute("style", `width: ${this.getMissionData().fuel}%`); @@ -379,8 +381,18 @@ export class Unit extends Marker { unitHeadingDiv.innerHTML = String(Math.floor(rad2deg(this.getFlightData().heading))); var unitAltitudeDiv = element.querySelector(".unit-altitude"); - if (unitAltitudeDiv != null) + if (unitAltitudeDiv != null) { unitAltitudeDiv.innerHTML = String(Math.floor(this.getFlightData().altitude / 0.3048 / 1000)); + } + + const headingDeg = rad2deg( this.getFlightData().heading ); + + element.querySelectorAll( "[data-rotate-to-heading]" ).forEach( el => { + let currentStyle = el.getAttribute( "style" ) || ""; + el.setAttribute( "style", currentStyle + `transform:rotate(${headingDeg}deg);` ); + }); + + } var pos = getMap().latLngToLayerPoint(this.getLatLng()).round(); this.setZIndexOffset(1000 + Math.floor(this.getFlightData().altitude) - pos.y); @@ -470,7 +482,7 @@ export class Aircraft extends AirUnit {
-
+
@@ -551,7 +563,7 @@ export class Missile extends Weapon { super(ID, data, `
-
+
`);