Procházet zdrojové kódy

Add type definitions for stencil, stencil materials

Peter Boyer před 6 roky
rodič
revize
9178f188aa
2 změnil soubory, kde provedl 66 přidání a 0 odebrání
  1. 22 0
      src/constants.d.ts
  2. 44 0
      src/materials/Material.d.ts

+ 22 - 0
src/constants.d.ts

@@ -238,3 +238,25 @@ export const RGBADepthPacking: DepthPackingStrategies;
 export enum NormalMapTypes {}
 export const TangentSpaceNormalMap: NormalMapTypes;
 export const ObjectSpaceNormalMap: NormalMapTypes;
+
+// Stencil Op types
+export enum StencilOp {}
+export const ZeroStencilOp: StencilOp;
+export const KeepStencilOp: StencilOp;
+export const ReplaceStencilOp: StencilOp;
+export const IncrementStencilOp: StencilOp;
+export const DecrementStencilOp: StencilOp;
+export const IncrementWrapStencilOp: StencilOp;
+export const DecrementWrapStencilOp: StencilOp;
+export const InvertStencilOp: StencilOp;
+
+// Stencil Func types
+export enum StencilFunc {}
+export const NeverStencilFunc: number;
+export const LessStencilFunc: number;
+export const EqualStencilFunc: number;
+export const LessEqualStencilFunc: number;
+export const GreaterStencilFunc: number;
+export const NotEqualStencilFunc: number;
+export const GreaterEqualStencilFunc: number;
+export const AlwaysStencilFunc: number;

+ 44 - 0
src/materials/Material.d.ts

@@ -10,6 +10,8 @@ import {
   DepthModes,
   Side,
   Colors,
+  StencilFunc,
+  StencilOp
 } from '../constants';
 
 // Materials //////////////////////////////////////////////////////////////////////////////////
@@ -49,6 +51,13 @@ export interface MaterialParameters {
   vertexColors?: Colors;
   vertexTangents?: boolean;
   visible?: boolean;
+  stencilWrite?: boolean;
+  stencilFunc?: StencilFunc;
+  stencilRef?: number;
+  stencilMask?: number;
+  stencilFail?: StencilOp;
+  stencilZFail?: StencilOp;
+  stencilZPass?: StencilOp;
 }
 
 /**
@@ -143,6 +152,41 @@ export class Material extends EventDispatcher {
    */
   id: number;
 
+  /**
+   * Whether rendering this material has any effect on the stencil buffer. Default is *false*.
+   */
+  stencilWrite: boolean;
+
+  /**
+   * The stencil comparison function to use. Default is {@link AlwaysStencilFunc}. See stencil operation constants for all possible values.
+   */
+  stencilFunc: StencilFunc;
+
+  /**
+   * The value to use when performing stencil comparisons or stencil operations. Default is *0*.
+   */
+  stencilRef: number;
+
+  /**
+   * The bit mask to use when comparing against or writing to the stencil buffer. Default is *0xFF*.
+   */
+  stencilMask: number;
+
+  /**
+   * Which stencil operation to perform when the comparison function returns false. Default is {@link KeepStencilOp}. See the stencil operation constants for all possible values.
+   */
+  stencilFail: StencilOp;
+
+  /**
+   * Which stencil operation to perform when the comparison function returns true but the depth test fails. Default is {@link KeepStencilOp}. See the stencil operation constants for all possible values.
+   */
+  stencilZFail: StencilOp;
+
+  /**
+   * Which stencil operation to perform when the comparison function returns true and the depth test passes. Default is {@link KeepStencilOp}. See the stencil operation constants for all possible values.
+   */
+  stencilZPass: StencilOp;
+
   /**
    * Used to check whether this or derived classes are materials. Default is true.
    * You should not change this, as it used internally for optimisation.