@pixi/core
Version:
Core PixiJS
92 lines (89 loc) • 2.15 kB
JavaScript
import { BLEND_MODES } from '@pixi/constants';
const BLEND = 0;
const OFFSET = 1;
const CULLING = 2;
const DEPTH_TEST = 3;
const WINDING = 4;
const DEPTH_MASK = 5;
class State {
constructor() {
this.data = 0;
this.blendMode = BLEND_MODES.NORMAL;
this.polygonOffset = 0;
this.blend = true;
this.depthMask = true;
}
get blend() {
return !!(this.data & 1 << BLEND);
}
set blend(value) {
if (!!(this.data & 1 << BLEND) !== value) {
this.data ^= 1 << BLEND;
}
}
get offsets() {
return !!(this.data & 1 << OFFSET);
}
set offsets(value) {
if (!!(this.data & 1 << OFFSET) !== value) {
this.data ^= 1 << OFFSET;
}
}
get culling() {
return !!(this.data & 1 << CULLING);
}
set culling(value) {
if (!!(this.data & 1 << CULLING) !== value) {
this.data ^= 1 << CULLING;
}
}
get depthTest() {
return !!(this.data & 1 << DEPTH_TEST);
}
set depthTest(value) {
if (!!(this.data & 1 << DEPTH_TEST) !== value) {
this.data ^= 1 << DEPTH_TEST;
}
}
get depthMask() {
return !!(this.data & 1 << DEPTH_MASK);
}
set depthMask(value) {
if (!!(this.data & 1 << DEPTH_MASK) !== value) {
this.data ^= 1 << DEPTH_MASK;
}
}
get clockwiseFrontFace() {
return !!(this.data & 1 << WINDING);
}
set clockwiseFrontFace(value) {
if (!!(this.data & 1 << WINDING) !== value) {
this.data ^= 1 << WINDING;
}
}
get blendMode() {
return this._blendMode;
}
set blendMode(value) {
this.blend = value !== BLEND_MODES.NONE;
this._blendMode = value;
}
get polygonOffset() {
return this._polygonOffset;
}
set polygonOffset(value) {
this.offsets = !!value;
this._polygonOffset = value;
}
toString() {
return `[ /core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`;
}
static for2d() {
const state = new State();
state.depthTest = false;
state.blend = true;
return state;
}
}
export { State };
//# sourceMappingURL=State.mjs.map