* Render the display object. * @param {PIXI.Renderer} renderer - The renderer. * @param {PIXI.DisplayObject} displayObject - The display object to be rendered. * @param {object} [options] * @param {boolean|undefined} [options.clear=true] - Clear before rendering? * @param {P
(renderer, displayObject, { clear = true, transform, skipUpdateTransform = false,
attachments, resize = true, width, height, resolution } = {})
| 282 | * @param {number} [options.resolution] - The resolution of the framebuffer. Defaults to the resolution of the renderer. |
| 283 | */ |
| 284 | render(renderer, displayObject, { clear = true, transform, skipUpdateTransform = false, |
| 285 | attachments, resize = true, width, height, resolution } = {}) { |
| 286 | const textures = this.textures; |
| 287 | |
| 288 | if (resize) { |
| 289 | const texture0 = textures[0]; |
| 290 | const screen = renderer.screen; |
| 291 | |
| 292 | height ??= screen.height; |
| 293 | width ??= screen.width; |
| 294 | resolution ??= renderer.resolution; |
| 295 | |
| 296 | if (texture0.width !== width || texture0.height !== height || texture0.resolution !== resolution) { |
| 297 | const realWidth = Math.round(width * resolution); |
| 298 | const realHeight = Math.round(height * resolution); |
| 299 | |
| 300 | for (let i = 0; i < textures.length; i++) { |
| 301 | const texture = textures[i]; |
| 302 | const baseTexture = texture.baseTexture; |
| 303 | |
| 304 | texture.valid = width > 0 && height > 0; |
| 305 | texture._frame.width = texture.orig.width = width; |
| 306 | texture._frame.height = texture.orig.height = height; |
| 307 | baseTexture.setRealSize(realWidth, realHeight, resolution); |
| 308 | texture.updateUvs(); |
| 309 | |
| 310 | const sprite = this.sprites[i]; |
| 311 | |
| 312 | sprite.width = width; |
| 313 | sprite.height = height; |
| 314 | sprite.updateTransform(); |
| 315 | } |
| 316 | |
| 317 | for (const framebuffer of Object.values(this.framebuffers)) { |
| 318 | framebuffer.width = realWidth; |
| 319 | framebuffer.height = realHeight; |
| 320 | |
| 321 | framebuffer.dirtyId++; |
| 322 | framebuffer.dirtySize++; |
| 323 | |
| 324 | if (framebuffer.depthTexture) { |
| 325 | const resolution = framebuffer.depthTexture.resolution; |
| 326 | |
| 327 | framebuffer.depthTexture.setSize(width / resolution, height / resolution); |
| 328 | } |
| 329 | } |
| 330 | } |
| 331 | } |
| 332 | |
| 333 | renderer.renderingToScreen = false; |
| 334 | renderer.runners.prerender.emit(); |
| 335 | renderer.emit("prerender"); |
| 336 | renderer.projection.transform = transform ?? null; |
| 337 | |
| 338 | if (renderer.context.isLost) { |
| 339 | return; |
| 340 | } |
| 341 |
no test coverage detected