MCPcopy Create free account
hub / github.com/dev7355608/perfect-vision / reset

Method reset

scripts/utils/framebuffer.js:72–197  ·  view source on GitHub ↗

* Reset. * @param {object} [texturesOptions] - The textures options. * @param {object} [framebufferOptions] - The framebuffer options.

(texturesOptions = [], framebufferOptions = {})

Source from the content-addressed store, hash-verified

70 * @param {object} [framebufferOptions] - The framebuffer options.
71 */
72 reset(texturesOptions = [], framebufferOptions = {}) {
73 this.framebufferOptions = framebufferOptions = Object.assign(this.framebufferOptions ?? {
74 multisample: PIXI.MSAA_QUALITY.NONE,
75 depth: false,
76 stencil: false,
77 clearDepth: 1,
78 clearStencil: 0
79 }, framebufferOptions);
80
81 this.texturesOptions = this.texturesOptions ?? [];
82
83 for (let i = 0, n = texturesOptions.length; i < n; i++) {
84 this.texturesOptions[i] = Object.assign(this.texturesOptions[i] ?? {
85 wrapMode: PIXI.WRAP_MODES.CLAMP,
86 scaleMode: PIXI.SCALE_MODES.NEAREST,
87 format: PIXI.FORMATS.RED,
88 type: PIXI.TYPES.UNSIGNED_BYTE,
89 target: PIXI.TARGETS.TEXTURE_2D,
90 alphaMode: PIXI.ALPHA_MODES.PMA,
91 multisample: framebufferOptions.multisample,
92 clearColor: [0, 0, 0, 0],
93 }, texturesOptions[i] ?? {});
94
95 const options = this.texturesOptions[i];
96
97 options.mipmap = PIXI.MIPMAP_MODES.OFF;
98 options.anisotropicLevel = 0;
99
100 const clearColor = options.clearColor;
101
102 if (clearColor) {
103 options.clearColor = new Float32Array(4);
104
105 if (clearColor) {
106 for (let j = 0; j < Math.min(clearColor.length, 4); j++) {
107 options.clearColor[j] = clearColor[j];
108 }
109 }
110 }
111 }
112
113 texturesOptions = this.texturesOptions;
114
115 if (!this.textures) {
116 this.textures = [];
117 this.sprites = [];
118
119 for (let i = 0; i < texturesOptions.length; i++) {
120 const options = {
121 ...texturesOptions[i],
122 width: 1,
123 height: 1,
124 resolution: 1,
125 multisample: framebufferOptions.multisample
126 };
127
128 const texture = PIXI.RenderTexture.create(options);
129 const baseTexture = texture.baseTexture;

Callers 3

constructorMethod · 0.95
disposeMethod · 0.95
renderMethod · 0.45

Calls 5

assignMethod · 0.80
fillMethod · 0.80
createMethod · 0.45
setMethod · 0.45
disposeMethod · 0.45

Tested by

no test coverage detected