@spearwolf/twopoint5d
Version:
Create 2.5D realtime graphics and pixelart with WebGL and three.js
35 lines • 1.18 kB
JavaScript
import { Color } from 'three/webgpu';
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