UNPKG

@woosh/meep-engine

Version:

Pure JavaScript game engine. Fully featured and production ready.

58 lines (45 loc) 1.13 kB
import {Transform} from "../transform/Transform.js"; import {assert} from "../../../core/assert.js"; export class Attachment { /** * Parent entity to which attachment is made * @type {number} */ parent = -1; /** * Socket on the parent entity to which attachment is made * @type {String} */ socket = null; /** * * @type {Transform} */ transform = new Transform(); /** * * @type {boolean} */ immediate = false; fromJSON({parent, socket, transform, immediate = false}) { assert.isNonNegativeInteger(parent, 'parent'); this.parent = parent; this.socket = socket; if (transform !== undefined) { this.transform.fromJSON(transform); } this.immediate = immediate; } /** * * @param j * @returns {Attachment} */ static fromJSON(j) { const r = new Attachment(); r.fromJSON(j); return r; } } Attachment.typeName = "Attachment"; Attachment.serializable = false;