webgpuDepthCullingState.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import { DepthCullingState } from "../../States/depthCullingState.js";
  2. /**
  3. * @internal
  4. **/
  5. export class WebGPUDepthCullingState extends DepthCullingState {
  6. /**
  7. * Initializes the state.
  8. * @param cache
  9. */
  10. constructor(cache) {
  11. super(false);
  12. this._cache = cache;
  13. this.reset();
  14. }
  15. get zOffset() {
  16. return this._zOffset;
  17. }
  18. set zOffset(value) {
  19. if (this._zOffset === value) {
  20. return;
  21. }
  22. this._zOffset = value;
  23. this._isZOffsetDirty = true;
  24. this._cache.setDepthBiasSlopeScale(value);
  25. }
  26. get zOffsetUnits() {
  27. return this._zOffsetUnits;
  28. }
  29. set zOffsetUnits(value) {
  30. if (this._zOffsetUnits === value) {
  31. return;
  32. }
  33. this._zOffsetUnits = value;
  34. this._isZOffsetDirty = true;
  35. this._cache.setDepthBias(value);
  36. }
  37. get cullFace() {
  38. return this._cullFace;
  39. }
  40. set cullFace(value) {
  41. if (this._cullFace === value) {
  42. return;
  43. }
  44. this._cullFace = value;
  45. this._isCullFaceDirty = true;
  46. this._cache.setCullFace(value ?? 1);
  47. }
  48. get cull() {
  49. return this._cull;
  50. }
  51. set cull(value) {
  52. if (this._cull === value) {
  53. return;
  54. }
  55. this._cull = value;
  56. this._isCullDirty = true;
  57. this._cache.setCullEnabled(!!value);
  58. }
  59. get depthFunc() {
  60. return this._depthFunc;
  61. }
  62. set depthFunc(value) {
  63. if (this._depthFunc === value) {
  64. return;
  65. }
  66. this._depthFunc = value;
  67. this._isDepthFuncDirty = true;
  68. this._cache.setDepthCompare(value);
  69. }
  70. get depthMask() {
  71. return this._depthMask;
  72. }
  73. set depthMask(value) {
  74. if (this._depthMask === value) {
  75. return;
  76. }
  77. this._depthMask = value;
  78. this._isDepthMaskDirty = true;
  79. this._cache.setDepthWriteEnabled(value);
  80. }
  81. get depthTest() {
  82. return this._depthTest;
  83. }
  84. set depthTest(value) {
  85. if (this._depthTest === value) {
  86. return;
  87. }
  88. this._depthTest = value;
  89. this._isDepthTestDirty = true;
  90. this._cache.setDepthTestEnabled(value);
  91. }
  92. get frontFace() {
  93. return this._frontFace;
  94. }
  95. set frontFace(value) {
  96. if (this._frontFace === value) {
  97. return;
  98. }
  99. this._frontFace = value;
  100. this._isFrontFaceDirty = true;
  101. this._cache.setFrontFace(value ?? 2);
  102. }
  103. reset() {
  104. super.reset();
  105. this._cache.resetDepthCullingState();
  106. }
  107. apply() {
  108. // nothing to do
  109. }
  110. }
  111. //# sourceMappingURL=webgpuDepthCullingState.js.map