UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

67 lines (54 loc) 1.34 kB
import { computeStringHash } from "../../core/primitives/strings/computeStringHash.js"; import Vector2 from "../../core/geom/Vector2.js"; export class TerrainLayerDescription { /** * URL to diffuse texture * @type {string} */ diffuse = ''; /** * * @type {Vector2} */ size = new Vector2(1, 1); hash() { return computeStringHash(this.diffuse) ^ this.size.hash(); } /** * * @param {TerrainLayerDescription} other * @returns {boolean} */ equals(other) { if (this === other) { return true; } return this.diffuse === other.diffuse && this.size.equals(other.size); } toJSON() { return { diffuse: this.diffuse, size: this.size.toJSON() }; } toString() { return JSON.stringify(this.toJSON()); } static from({ diffuse, size }) { const r = new TerrainLayerDescription(); r.diffuse = diffuse; if (size !== undefined) { r.size.copy(size); } return r; } } /** * * @type {boolean} */ TerrainLayerDescription.prototype.isTerrainLayerDescription = true;