15832144755
2022-01-06 7b4c8991dca9cf2a809a95e239d144697d3afb56
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
92
93
94
95
96
97
98
99
100
101
102
import Color from "../Core/Color.js";
import defaultValue from "../Core/defaultValue.js";
 
/**
 * Represents a command to the renderer for clearing a framebuffer.
 *
 * @private
 * @constructor
 */
function ClearCommand(options) {
  options = defaultValue(options, defaultValue.EMPTY_OBJECT);
 
  /**
   * The value to clear the color buffer to.  When <code>undefined</code>, the color buffer is not cleared.
   *
   * @type {Color}
   *
   * @default undefined
   */
  this.color = options.color;
 
  /**
   * The value to clear the depth buffer to.  When <code>undefined</code>, the depth buffer is not cleared.
   *
   * @type {Number}
   *
   * @default undefined
   */
  this.depth = options.depth;
 
  /**
   * The value to clear the stencil buffer to.  When <code>undefined</code>, the stencil buffer is not cleared.
   *
   * @type {Number}
   *
   * @default undefined
   */
  this.stencil = options.stencil;
 
  /**
   * The render state to apply when executing the clear command.  The following states affect clearing:
   * scissor test, color mask, depth mask, and stencil mask.  When the render state is
   * <code>undefined</code>, the default render state is used.
   *
   * @type {RenderState}
   *
   * @default undefined
   */
  this.renderState = options.renderState;
 
  /**
   * The framebuffer to clear.
   *
   * @type {Framebuffer}
   *
   * @default undefined
   */
  this.framebuffer = options.framebuffer;
 
  /**
   * The object who created this command.  This is useful for debugging command
   * execution; it allows you to see who created a command when you only have a
   * reference to the command, and can be used to selectively execute commands
   * with {@link Scene#debugCommandFilter}.
   *
   * @type {Object}
   *
   * @default undefined
   *
   * @see Scene#debugCommandFilter
   */
  this.owner = options.owner;
 
  /**
   * The pass in which to run this command.
   *
   * @type {Pass}
   *
   * @default undefined
   */
  this.pass = options.pass;
}
 
/**
 * Clears color to (0.0, 0.0, 0.0, 0.0); depth to 1.0; and stencil to 0.
 *
 * @type {ClearCommand}
 *
 * @constant
 */
ClearCommand.ALL = Object.freeze(
  new ClearCommand({
    color: new Color(0.0, 0.0, 0.0, 0.0),
    depth: 1.0,
    stencil: 0.0,
  })
);
 
ClearCommand.prototype.execute = function (context, passState) {
  context.clear(this, passState);
};
export default ClearCommand;