@pixi/core
Version:
Core PixiJS
99 lines (98 loc) • 3.02 kB
JavaScript
"use strict";
var constants = require("@pixi/constants");
const BLEND = 0, OFFSET = 1, CULLING = 2, DEPTH_TEST = 3, WINDING = 4, DEPTH_MASK = 5;
class State {
constructor() {
this.data = 0, this.blendMode = constants.BLEND_MODES.NORMAL, this.polygonOffset = 0, this.blend = !0, this.depthMask = !0;
}
/**
* Activates blending of the computed fragment color values.
* @default true
*/
get blend() {
return !!(this.data & 1 << BLEND);
}
set blend(value) {
!!(this.data & 1 << BLEND) !== value && (this.data ^= 1 << BLEND);
}
/**
* Activates adding an offset to depth values of polygon's fragments
* @default false
*/
get offsets() {
return !!(this.data & 1 << OFFSET);
}
set offsets(value) {
!!(this.data & 1 << OFFSET) !== value && (this.data ^= 1 << OFFSET);
}
/**
* Activates culling of polygons.
* @default false
*/
get culling() {
return !!(this.data & 1 << CULLING);
}
set culling(value) {
!!(this.data & 1 << CULLING) !== value && (this.data ^= 1 << CULLING);
}
/**
* Activates depth comparisons and updates to the depth buffer.
* @default false
*/
get depthTest() {
return !!(this.data & 1 << DEPTH_TEST);
}
set depthTest(value) {
!!(this.data & 1 << DEPTH_TEST) !== value && (this.data ^= 1 << DEPTH_TEST);
}
/**
* Enables or disables writing to the depth buffer.
* @default true
*/
get depthMask() {
return !!(this.data & 1 << DEPTH_MASK);
}
set depthMask(value) {
!!(this.data & 1 << DEPTH_MASK) !== value && (this.data ^= 1 << DEPTH_MASK);
}
/**
* Specifies whether or not front or back-facing polygons can be culled.
* @default false
*/
get clockwiseFrontFace() {
return !!(this.data & 1 << WINDING);
}
set clockwiseFrontFace(value) {
!!(this.data & 1 << WINDING) !== value && (this.data ^= 1 << WINDING);
}
/**
* The blend mode to be applied when this state is set. Apply a value of `PIXI.BLEND_MODES.NORMAL` to reset the blend mode.
* Setting this mode to anything other than NO_BLEND will automatically switch blending on.
* @default PIXI.BLEND_MODES.NORMAL
*/
get blendMode() {
return this._blendMode;
}
set blendMode(value) {
this.blend = value !== constants.BLEND_MODES.NONE, this._blendMode = value;
}
/**
* The polygon offset. Setting this property to anything other than 0 will automatically enable polygon offset fill.
* @default 0
*/
get polygonOffset() {
return this._polygonOffset;
}
set polygonOffset(value) {
this.offsets = !!value, this._polygonOffset = value;
}
static for2d() {
const state = new State();
return state.depthTest = !1, state.blend = !0, state;
}
}
State.prototype.toString = function() {
return `[ /core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`;
};
exports.State = State;
//# sourceMappingURL=State.js.map