UNPKG

@spearwolf/twopoint5d

Version:

a library to create 2.5d realtime graphics and pixelart with three.js

35 lines 1.17 kB
import { Color } from 'three'; import { voInitialize } from '../../index.js'; export class TexturedSprite { [voInitialize]() { this.setColorValues([1, 1, 1, 1]); } setSize(width, height) { this.setQuadSize([width, height]); } setPosition(x, y, z = 0) { this.setInstancePosition([x, y, z]); } setFrame(frame) { const { coords } = frame; this.setTexCoords([coords.s, coords.t, coords.u, coords.v]); } setColor(color, a = 1) { this.setColorValues([color.r, color.g, color.b, a]); } getColor(target = new Color()) { return target.set(this.r, this.g, this.b); } } export const TexturedSpriteDescriptor = { meshCount: 1, attributes: { quadSize: { components: ['width', 'height'] }, texCoords: { components: ['s', 't', 'u', 'v'] }, instancePosition: { components: ['x', 'y', 'z'], usage: 'dynamic' }, rotation: { size: 1, usage: 'dynamic' }, color: { components: ['r', 'g', 'b', 'a'], setter: 'setColorValues', getter: false }, }, basePrototype: TexturedSprite.prototype, }; //# sourceMappingURL=TexturedSprite.js.map