import Component from '@/ecs/component.js'; export default class Sprite extends Component { instanceFromSchema() { return class SpriteInstance extends super.instanceFromSchema() { get anchor() { return {x: this.anchorX, y: this.anchorY}; } get scale() { return {x: this.scaleX, y: this.scaleY}; } }; } async load(instance) { instance.$$sourceJson = await this.ecs.readJson(instance.source); } static properties = { anchorX: {defaultValue: 0.5, type: 'float32'}, anchorY: {defaultValue: 0.5, type: 'float32'}, animation: {type: 'string'}, elapsed: {type: 'float32'}, frame: {type: 'uint16'}, frames: {type: 'uint16'}, scaleX: {defaultValue: 1, type: 'float32'}, scaleY: {defaultValue: 1, type: 'float32'}, source: {type: 'string'}, speed: {type: 'float32'}, }; }