import P from "parsernostrum" import Grammar from "../serialization/Grammar.js" import IEntity from "./IEntity.js" import NumberEntity from "./NumberEntity.js" export default class VectorEntity extends IEntity { static attributes = { ...super.attributes, X: NumberEntity.withDefault(), Y: NumberEntity.withDefault(), Z: NumberEntity.withDefault(), } /** @type {P} */ static grammar = Grammar.createEntityGrammar(this, Grammar.commaSeparation, true).label("VectorEntity") constructor(values) { super(values) /** @type {InstanceType} */ this.X /** @type {InstanceType} */ this.Y /** @type {InstanceType} */ this.Z } /** @returns {[Number, Number, Number]} */ toArray() { return [this.X.valueOf(), this.Y.valueOf(), this.Z.valueOf()] } }