arx-level-generator
Version:
A tool for creating Arx Fatalis maps
45 lines • 1.28 kB
JavaScript
import { Vector2 } from 'three';
import { Color } from './Color.js';
import { Vector3 } from './Vector3.js';
export class Vertex extends Vector3 {
uv;
color;
constructor(x, y, z, u = 0, v = 0, color = Color.transparent) {
super(x, y, z);
this.uv = new Vector2(u, v);
this.color = color;
}
clone() {
const copy = new Vertex(this.x, this.y, this.z, this.uv.x, this.uv.y, this.color);
return copy;
}
static fromArxVertex({ x, y, z, u, v, color }) {
if (typeof color === 'undefined') {
return new Vertex(x, y, z, u, v);
}
return new Vertex(x, y, z, u, v, Color.fromArxColor(color));
}
toArxVertex() {
return {
...this.toArxVector3(),
u: this.uv.x,
v: this.uv.y,
};
}
equals(v, epsilon = 0) {
if (epsilon === 0) {
return this.x === v.x && this.y === v.y && this.z === v.z;
}
if (Math.abs(this.x - v.x) > epsilon) {
return false;
}
if (Math.abs(this.y - v.y) > epsilon) {
return false;
}
if (Math.abs(this.z - v.z) > epsilon) {
return false;
}
return true;
}
}
//# sourceMappingURL=Vertex.js.map