UNPKG

@animech-public/playcanvas

Version:
2 lines (1 loc) 1.24 kB
import{BitPacking as t}from"../../core/math/bit-packing.js";import{StringIds as e}from"../../core/string-ids.js";import{FUNC_LESSEQUAL as s,FUNC_ALWAYS as i}from"./constants.js";var h;const a=new e;class p{constructor(t=s,e=!0){this.data=0,this._depthBias=0,this._depthBiasSlope=0,this.key=0,this.func=t,this.write=e}set test(t){this.func=t?s:i,this.updateKey()}get test(){return this.func!==i}set write(e){this.data=t.set(this.data,e?1:0,3),this.updateKey()}get write(){return t.all(this.data,3)}set func(e){this.data=t.set(this.data,e,0,7),this.updateKey()}get func(){return t.get(this.data,0,7)}set depthBias(t){this._depthBias=t,this.updateKey()}get depthBias(){return this._depthBias}set depthBiasSlope(t){this._depthBiasSlope=t,this.updateKey()}get depthBiasSlope(){return this._depthBiasSlope}copy(t){return this.data=t.data,this._depthBias=t._depthBias,this._depthBiasSlope=t._depthBiasSlope,this.key=t.key,this}clone(){return(new this.constructor).copy(this)}updateKey(){const{data:t,_depthBias:e,_depthBiasSlope:s}=this,i=`${t}-${e}-${s}`;this.key=a.get(i)}equals(t){return this.key===t.key}}h=p,p.DEFAULT=Object.freeze(new h),p.NODEPTH=Object.freeze(new h(i,!1)),p.WRITEDEPTH=Object.freeze(new h(i,!0));export{p as DepthState};