UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

68 lines (57 loc) 1.31 kB
import Vector2 from "../../../core/geom/Vector2.js"; export class TerrainPreview { /** * * @type {String} */ url = ""; /** * * @type {Vector2} */ offset = new Vector2(0, 0); /** * * @type {Vector2} */ scale = new Vector2(1, 1); /** * * @param {TerrainPreview} other */ copy(other) { this.url = other.url; this.scale.copy(other.scale); this.offset.copy(other.offset); } toJSON() { return { url: this.url, offset: this.offset.toJSON(), scale: this.scale.toJSON() }; } fromJSON(obj) { this.url = obj.url; this.offset.fromJSON(obj.offset); this.scale.fromJSON(obj.scale); } /** * * @param {BinaryBuffer} buffer */ toBinaryBuffer(buffer) { buffer.writeUTF8String(this.url); this.offset.toBinaryBuffer(buffer); this.scale.toBinaryBuffer(buffer); } /** * * @param {BinaryBuffer} buffer */ fromBinaryBuffer(buffer) { this.url = buffer.readUTF8String(); this.offset.fromBinaryBuffer(buffer); this.scale.fromBinaryBuffer(buffer); } }