瀏覽代碼

Merge pull request #5 from higharc/add-material-stencil-types

Add type definitions for stencil constants, stencil material properties
Garrett Johnson 6 年之前
父節點
當前提交
61edddf6ed
共有 2 個文件被更改,包括 66 次插入0 次删除
  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: StencilFunc;
+export const LessStencilFunc: StencilFunc;
+export const EqualStencilFunc: StencilFunc;
+export const LessEqualStencilFunc: StencilFunc;
+export const GreaterStencilFunc: StencilFunc;
+export const NotEqualStencilFunc: StencilFunc;
+export const GreaterEqualStencilFunc: StencilFunc;
+export const AlwaysStencilFunc: StencilFunc;

+ 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.