1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, '__esModule', { value: true });
|
4 |
|
5 | var constants = require('@pixi/constants');
|
6 |
|
7 | const BLEND = 0;
|
8 | const OFFSET = 1;
|
9 | const CULLING = 2;
|
10 | const DEPTH_TEST = 3;
|
11 | const WINDING = 4;
|
12 | const DEPTH_MASK = 5;
|
13 | class State {
|
14 | constructor() {
|
15 | this.data = 0;
|
16 | this.blendMode = constants.BLEND_MODES.NORMAL;
|
17 | this.polygonOffset = 0;
|
18 | this.blend = true;
|
19 | this.depthMask = true;
|
20 | }
|
21 | get blend() {
|
22 | return !!(this.data & 1 << BLEND);
|
23 | }
|
24 | set blend(value) {
|
25 | if (!!(this.data & 1 << BLEND) !== value) {
|
26 | this.data ^= 1 << BLEND;
|
27 | }
|
28 | }
|
29 | get offsets() {
|
30 | return !!(this.data & 1 << OFFSET);
|
31 | }
|
32 | set offsets(value) {
|
33 | if (!!(this.data & 1 << OFFSET) !== value) {
|
34 | this.data ^= 1 << OFFSET;
|
35 | }
|
36 | }
|
37 | get culling() {
|
38 | return !!(this.data & 1 << CULLING);
|
39 | }
|
40 | set culling(value) {
|
41 | if (!!(this.data & 1 << CULLING) !== value) {
|
42 | this.data ^= 1 << CULLING;
|
43 | }
|
44 | }
|
45 | get depthTest() {
|
46 | return !!(this.data & 1 << DEPTH_TEST);
|
47 | }
|
48 | set depthTest(value) {
|
49 | if (!!(this.data & 1 << DEPTH_TEST) !== value) {
|
50 | this.data ^= 1 << DEPTH_TEST;
|
51 | }
|
52 | }
|
53 | get depthMask() {
|
54 | return !!(this.data & 1 << DEPTH_MASK);
|
55 | }
|
56 | set depthMask(value) {
|
57 | if (!!(this.data & 1 << DEPTH_MASK) !== value) {
|
58 | this.data ^= 1 << DEPTH_MASK;
|
59 | }
|
60 | }
|
61 | get clockwiseFrontFace() {
|
62 | return !!(this.data & 1 << WINDING);
|
63 | }
|
64 | set clockwiseFrontFace(value) {
|
65 | if (!!(this.data & 1 << WINDING) !== value) {
|
66 | this.data ^= 1 << WINDING;
|
67 | }
|
68 | }
|
69 | get blendMode() {
|
70 | return this._blendMode;
|
71 | }
|
72 | set blendMode(value) {
|
73 | this.blend = value !== constants.BLEND_MODES.NONE;
|
74 | this._blendMode = value;
|
75 | }
|
76 | get polygonOffset() {
|
77 | return this._polygonOffset;
|
78 | }
|
79 | set polygonOffset(value) {
|
80 | this.offsets = !!value;
|
81 | this._polygonOffset = value;
|
82 | }
|
83 | toString() {
|
84 | return `[@pixi/core:State blendMode=${this.blendMode} clockwiseFrontFace=${this.clockwiseFrontFace} culling=${this.culling} depthMask=${this.depthMask} polygonOffset=${this.polygonOffset}]`;
|
85 | }
|
86 | static for2d() {
|
87 | const state = new State();
|
88 | state.depthTest = false;
|
89 | state.blend = true;
|
90 | return state;
|
91 | }
|
92 | }
|
93 |
|
94 | exports.State = State;
|
95 |
|