materialStencilState.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. import { __decorate } from "../tslib.es6.js";
  2. import { SerializationHelper } from "../Misc/decorators.serialization.js";
  3. import { serialize } from "../Misc/decorators.js";
  4. /**
  5. * Class that holds the different stencil states of a material
  6. * Usage example: https://playground.babylonjs.com/#CW5PRI#10
  7. */
  8. export class MaterialStencilState {
  9. /**
  10. * Creates a material stencil state instance
  11. */
  12. constructor() {
  13. this.reset();
  14. }
  15. /**
  16. * Resets all the stencil states to default values
  17. */
  18. reset() {
  19. this.enabled = false;
  20. this.mask = 0xff;
  21. this.func = 519;
  22. this.funcRef = 1;
  23. this.funcMask = 0xff;
  24. this.opStencilFail = 7680;
  25. this.opDepthFail = 7680;
  26. this.opStencilDepthPass = 7681;
  27. }
  28. /**
  29. * Gets or sets the stencil function
  30. */
  31. get func() {
  32. return this._func;
  33. }
  34. set func(value) {
  35. this._func = value;
  36. }
  37. /**
  38. * Gets or sets the stencil function reference
  39. */
  40. get funcRef() {
  41. return this._funcRef;
  42. }
  43. set funcRef(value) {
  44. this._funcRef = value;
  45. }
  46. /**
  47. * Gets or sets the stencil function mask
  48. */
  49. get funcMask() {
  50. return this._funcMask;
  51. }
  52. set funcMask(value) {
  53. this._funcMask = value;
  54. }
  55. /**
  56. * Gets or sets the operation when the stencil test fails
  57. */
  58. get opStencilFail() {
  59. return this._opStencilFail;
  60. }
  61. set opStencilFail(value) {
  62. this._opStencilFail = value;
  63. }
  64. /**
  65. * Gets or sets the operation when the depth test fails
  66. */
  67. get opDepthFail() {
  68. return this._opDepthFail;
  69. }
  70. set opDepthFail(value) {
  71. this._opDepthFail = value;
  72. }
  73. /**
  74. * Gets or sets the operation when the stencil+depth test succeeds
  75. */
  76. get opStencilDepthPass() {
  77. return this._opStencilDepthPass;
  78. }
  79. set opStencilDepthPass(value) {
  80. this._opStencilDepthPass = value;
  81. }
  82. /**
  83. * Gets or sets the stencil mask
  84. */
  85. get mask() {
  86. return this._mask;
  87. }
  88. set mask(value) {
  89. this._mask = value;
  90. }
  91. /**
  92. * Enables or disables the stencil test
  93. */
  94. get enabled() {
  95. return this._enabled;
  96. }
  97. set enabled(value) {
  98. this._enabled = value;
  99. }
  100. /**
  101. * Get the current class name, useful for serialization or dynamic coding.
  102. * @returns "MaterialStencilState"
  103. */
  104. getClassName() {
  105. return "MaterialStencilState";
  106. }
  107. /**
  108. * Makes a duplicate of the current configuration into another one.
  109. * @param stencilState defines stencil state where to copy the info
  110. */
  111. copyTo(stencilState) {
  112. SerializationHelper.Clone(() => stencilState, this);
  113. }
  114. /**
  115. * Serializes this stencil configuration.
  116. * @returns - An object with the serialized config.
  117. */
  118. serialize() {
  119. return SerializationHelper.Serialize(this);
  120. }
  121. /**
  122. * Parses a stencil state configuration from a serialized object.
  123. * @param source - Serialized object.
  124. * @param scene Defines the scene we are parsing for
  125. * @param rootUrl Defines the rootUrl to load from
  126. */
  127. parse(source, scene, rootUrl) {
  128. SerializationHelper.Parse(() => this, source, scene, rootUrl);
  129. }
  130. }
  131. __decorate([
  132. serialize()
  133. ], MaterialStencilState.prototype, "func", null);
  134. __decorate([
  135. serialize()
  136. ], MaterialStencilState.prototype, "funcRef", null);
  137. __decorate([
  138. serialize()
  139. ], MaterialStencilState.prototype, "funcMask", null);
  140. __decorate([
  141. serialize()
  142. ], MaterialStencilState.prototype, "opStencilFail", null);
  143. __decorate([
  144. serialize()
  145. ], MaterialStencilState.prototype, "opDepthFail", null);
  146. __decorate([
  147. serialize()
  148. ], MaterialStencilState.prototype, "opStencilDepthPass", null);
  149. __decorate([
  150. serialize()
  151. ], MaterialStencilState.prototype, "mask", null);
  152. __decorate([
  153. serialize()
  154. ], MaterialStencilState.prototype, "enabled", null);
  155. //# sourceMappingURL=materialStencilState.js.map