forked from pmndrs/postprocessing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDepthEffect.js
More file actions
91 lines (60 loc) · 1.51 KB
/
DepthEffect.js
File metadata and controls
91 lines (60 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { BlendFunction, EffectAttribute } from "../enums/index.js";
import { Effect } from "./Effect.js";
import fragmentShader from "./glsl/depth.frag";
/**
* A depth visualization effect.
*
* Useful for debugging.
*/
export class DepthEffect extends Effect {
/**
* Constructs a new depth effect.
*
* @param {Object} [options] - The options.
* @param {BlendFunction} [options.blendFunction=BlendFunction.SRC] - The blend function of this effect.
* @param {Boolean} [options.inverted=false] - Whether the depth should be inverted.
*/
constructor({ blendFunction = BlendFunction.SRC, inverted = false } = {}) {
super("DepthEffect", fragmentShader, {
blendFunction,
attributes: EffectAttribute.DEPTH
});
this.inverted = inverted;
}
/**
* Indicates whether depth should be inverted.
*
* @type {Boolean}
*/
get inverted() {
return this.defines.has("INVERTED");
}
set inverted(value) {
if(this.inverted !== value) {
if(value) {
this.defines.set("INVERTED", "1");
} else {
this.defines.delete("INVERTED");
}
this.setChanged();
}
}
/**
* Indicates whether the rendered depth is inverted.
*
* @deprecated Use inverted instead.
* @return {Boolean} Whether the rendered depth is inverted.
*/
isInverted() {
return this.inverted;
}
/**
* Enables or disables depth inversion.
*
* @deprecated Use inverted instead.
* @param {Boolean} value - Whether depth should be inverted.
*/
setInverted(value) {
this.inverted = value;
}
}