|
| 1 | +/* global QUnit */ |
| 2 | + |
| 3 | +import { NearestFilter } from '../../../../src/constants.js'; |
| 4 | +import { RenderTarget } from '../../../../src/core/RenderTarget.js'; |
| 5 | + |
| 6 | +export default QUnit.module( 'Core', () => { |
| 7 | + |
| 8 | + QUnit.module( 'RenderTarget', () => { |
| 9 | + |
| 10 | + // Constructor options |
| 11 | + QUnit.test( 'Constructor', ( assert ) => { |
| 12 | + |
| 13 | + const empty = new RenderTarget(); |
| 14 | + assert.ok( empty.width != null && empty.height != null && empty.textures.length === 1, 'Can instantiate a RenderTarget with no arguments.' ); |
| 15 | + |
| 16 | + const sized = new RenderTarget( 1, 1 ); |
| 17 | + assert.ok( sized.width === 1 && sized.height === 1 && sized.textures.length === 1, 'Can instantiate a RenderTarget with custom size.' ); |
| 18 | + |
| 19 | + const mrt = new RenderTarget( 1, 1, { count: 2 } ); |
| 20 | + assert.ok( mrt.width === 1 && mrt.height === 1 && mrt.textures.length === 2, 'Can instantiate a RenderTarget with custom count (MRT).' ); |
| 21 | + |
| 22 | + const options = new RenderTarget( 1, 1, { magFilter: NearestFilter } ); |
| 23 | + assert.ok( options.width === 1 && options.height === 1 && options.texture.magFilter === NearestFilter, 'Can instantiate a RenderTarget with texture options.' ); |
| 24 | + |
| 25 | + } ); |
| 26 | + |
| 27 | + // PROPERTIES |
| 28 | + QUnit.todo( 'texture', ( assert ) => { |
| 29 | + |
| 30 | + assert.ok( false, 'everything\'s gonna be alright' ); |
| 31 | + |
| 32 | + } ); |
| 33 | + |
| 34 | + QUnit.todo( 'depthTexture', ( assert ) => { |
| 35 | + |
| 36 | + assert.ok( false, 'everything\'s gonna be alright' ); |
| 37 | + |
| 38 | + } ); |
| 39 | + |
| 40 | + // PUBLIC |
| 41 | + QUnit.test( 'setSize', ( assert ) => { |
| 42 | + |
| 43 | + const renderTarget = new RenderTarget(); |
| 44 | + renderTarget.setSize( 128, 128 ); |
| 45 | + assert.ok( renderTarget.width === 128 && renderTarget.height === 128, 'Sets a size with width and height' ); |
| 46 | + assert.ok( renderTarget.texture.image.width === 128 && renderTarget.texture.image.height === 128, 'Texture image is updated on resize' ); |
| 47 | + assert.ok( renderTarget.viewport.width === 128 && renderTarget.viewport.height === 128, 'Viewport is updated on resize' ); |
| 48 | + assert.ok( renderTarget.scissor.width === 128 && renderTarget.scissor.height === 128, 'Scissor is updated on resize' ); |
| 49 | + |
| 50 | + const mrt = new RenderTarget( 0, 0, { count: 2 } ); |
| 51 | + mrt.setSize( 128, 128 ); |
| 52 | + assert.ok( mrt.width === 128 && mrt.height === 128, 'Sets a size with width and height' ); |
| 53 | + assert.ok( mrt.textures[ 0 ].image.width === 128 && mrt.textures[ 0 ].image.height === 128 && mrt.textures[ 1 ].image.width === 128 && mrt.textures[ 1 ].image.height === 128, 'Texture images are updated on resize' ); |
| 54 | + assert.ok( mrt.viewport.width === 128 && mrt.viewport.height === 128, 'Viewport is updated on resize' ); |
| 55 | + assert.ok( mrt.scissor.width === 128 && mrt.scissor.height === 128, 'Scissor is updated on resize' ); |
| 56 | + |
| 57 | + const renderTarget3D = new RenderTarget(); |
| 58 | + renderTarget3D.setSize( 128, 128, 16 ); |
| 59 | + assert.ok( renderTarget3D.width === 128 && renderTarget3D.height === 128 && renderTarget3D.depth === 16, 'Sets a size with width, height, and depth' ); |
| 60 | + assert.ok( renderTarget3D.texture.image.width === 128 && renderTarget3D.texture.image.height === 128 && renderTarget3D.texture.image.depth === 16, 'Texture image is updated on resize' ); |
| 61 | + assert.ok( renderTarget3D.viewport.width === 128 && renderTarget3D.viewport.height === 128, 'Viewport is updated on resize' ); |
| 62 | + assert.ok( renderTarget3D.scissor.width === 128 && renderTarget3D.scissor.height === 128, 'Scissor is updated on resize' ); |
| 63 | + |
| 64 | + } ); |
| 65 | + |
| 66 | + } ); |
| 67 | + |
| 68 | +} ); |
0 commit comments