Skip to content

Commit

Permalink
feat(map): add map-aligned position and rotation to doodad defs
Browse files Browse the repository at this point in the history
  • Loading branch information
fallenoak committed Jan 2, 2024
1 parent 05856f2 commit ec7e690
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/lib/map/MapDoodadDef.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
import { MAP_CORNER_X, MAP_CORNER_Y } from './const.js';

class MapDoodadDef {
#name: string;
#id: number;
#position: Float32Array;
#mapPosition: Float32Array;
#rotation: Float32Array;
#mapRotation: Float32Array;
#scale: number;

constructor(name, id, position, rotation, scale) {
constructor(
name: string,
id: number,
position: Float32Array,
rotation: Float32Array,
scale: number,
) {
this.#name = name;
this.#id = id;
this.#position = position;
this.#rotation = rotation;
this.#scale = scale;

// Doodad defs (map placements) are stored in a Y-up right-handed coordinate system

this.#mapPosition = new Float32Array(3);
this.#mapPosition[0] = MAP_CORNER_X - position[2];
this.#mapPosition[1] = MAP_CORNER_Y - position[0];
this.#mapPosition[2] = position[1];

this.#mapRotation = new Float32Array(3);
this.#mapRotation[0] = rotation[2];
this.#mapRotation[1] = rotation[0];
this.#mapRotation[2] = rotation[1];
}

get name() {
Expand All @@ -25,10 +47,18 @@ class MapDoodadDef {
return this.#position;
}

get mapPosition() {
return this.#mapPosition;
}

get rotation() {
return this.#rotation;
}

get mapRotation() {
return this.#mapRotation;
}

get scale() {
return this.#scale;
}
Expand Down

0 comments on commit ec7e690

Please sign in to comment.