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

Method bind

scripts/utils/framebuffer.js:385–475  ·  view source on GitHub ↗

* Bind. * @param {PIXI.renderer} renderer - The renderer. * @param {number[]} [attachments] - The subset of attachments to render to.

(renderer, attachments)

Source from the content-addressed store, hash-verified

383 * @param {number[]} [attachments] - The subset of attachments to render to.
384 */
385 bind(renderer, attachments) {
386 if (attachments?.length === 0) {
387 return;
388 }
389
390 renderer.batch.flush();
391
392 const gl = renderer.gl;
393 let framebuffer;
394
395 const key = attachments?.join(",") ?? this.#defaultFramebufferKey;
396
397 if (!this.framebuffers.hasOwnProperty(key)) {
398 const { realWidth, realHeight } = this.textures[0].baseTexture;
399
400 framebuffer = new PIXI.Framebuffer(realWidth, realHeight);
401 framebuffer.multisample = this.framebufferOptions.multisample;
402 framebuffer.depth = !!this.framebufferOptions.depth;
403 framebuffer.stencil = !!this.framebufferOptions.stencil;
404 framebuffer.clearDepth = this.framebufferOptions.clearDepth ?? undefined;
405 framebuffer.clearStencil = this.framebufferOptions.clearStencil ?? undefined;
406 framebuffer.cleared = false;
407
408 for (let i = 0; i < (attachments?.length ?? this.textures.length); i++) {
409 framebuffer.addColorTexture(i, this.textures[attachments?.[i] ?? i].baseTexture);
410 }
411
412 framebuffer.renderTexture = new PIXI.RenderTexture(new Proxy(this.textures[attachments?.[0] ?? 0].baseTexture, {
413 get(target, prop) {
414 return prop === "framebuffer" ? framebuffer : Reflect.get(...arguments);
415 },
416 set(target, prop, value) {
417 if (prop === "framebuffer") {
418 framebuffer = value;
419 } else {
420 return Reflect.set(...arguments);
421 }
422 }
423 }));
424
425 this.framebuffers[key] = framebuffer;
426 } else {
427 framebuffer = this.framebuffers[key];
428 }
429
430 if (Object.values(this.framebuffers).indexOf(renderer.framebuffer.current) >= 0) {
431 for (const baseTexture of renderer.framebuffer.current.colorTextures) {
432 if (framebuffer.colorTextures.indexOf(baseTexture) < 0) {
433 baseTexture.update();
434 }
435 }
436 }
437
438 renderer.renderTexture.bind(framebuffer.renderTexture);
439
440 const drawBuffers = [];
441
442 for (let i = 0, n = framebuffer.colorTextures.length; i < n; i++) {

Callers 15

renderMethod · 0.95
FogManagerClass · 0.80
#applyPassMethod · 0.80
#extractMethod · 0.80
constructorMethod · 0.80
_renderDefaultMethod · 0.80
_renderMethod · 0.80
quadRenderFunction · 0.80
_updateMethod · 0.80
lighting.jsFile · 0.80
updateMethod · 0.80
activateListenersMethod · 0.80

Calls 1

updateMethod · 0.45

Tested by

no test coverage detected