| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- /* global QUnit */
- import { InterleavedBuffer } from '../../../../src/core/InterleavedBuffer.js';
- import { DynamicDrawUsage } from '../../../../src/constants.js';
- export default QUnit.module( 'Core', () => {
- QUnit.module( 'InterleavedBuffer', () => {
- function checkInstanceAgainstCopy( instance, copiedInstance, assert ) {
- assert.ok( copiedInstance instanceof InterleavedBuffer, 'the clone has the correct type' );
- for ( let i = 0; i < instance.array.length; i ++ ) {
- assert.ok( copiedInstance.array[ i ] === instance.array[ i ], 'array was copied' );
- }
- assert.ok( copiedInstance.stride === instance.stride, 'stride was copied' );
- assert.ok( copiedInstance.usage === DynamicDrawUsage, 'usage was copied' );
- }
- // INSTANCING
- QUnit.test( 'Instancing', ( assert ) => {
- const object = new InterleavedBuffer();
- assert.ok( object, 'Can instantiate an InterleavedBuffer.' );
- } );
- // PROPERTIES
- QUnit.todo( 'array', ( assert ) => {
- assert.ok( false, 'everything\'s gonna be alright' );
- } );
- QUnit.todo( 'stride', ( assert ) => {
- assert.ok( false, 'everything\'s gonna be alright' );
- } );
- QUnit.todo( 'count', ( assert ) => {
- assert.ok( false, 'everything\'s gonna be alright' );
- } );
- QUnit.todo( 'usage', ( assert ) => {
- assert.ok( false, 'everything\'s gonna be alright' );
- } );
- QUnit.todo( 'updateRange', ( assert ) => {
- assert.ok( false, 'everything\'s gonna be alright' );
- } );
- QUnit.todo( 'version', ( assert ) => {
- assert.ok( false, 'everything\'s gonna be alright' );
- } );
- QUnit.todo( 'uuid', ( assert ) => {
- assert.ok( false, 'everything\'s gonna be alright' );
- } );
- QUnit.todo( 'onUploadCallback', ( assert ) => {
- // onUploadCallback() {} declared but used as property, refactor req
- assert.ok( false, 'everything\'s gonna be alright' );
- } );
- QUnit.test( 'needsUpdate', ( assert ) => {
- const a = new InterleavedBuffer( new Float32Array( [ 1, 2, 3, 4 ] ), 2 );
- a.needsUpdate = true;
- assert.strictEqual( a.version, 1, 'Check version increased' );
- } );
- // PUBLIC
- QUnit.test( 'isInterleavedBuffer', ( assert ) => {
- const object = new InterleavedBuffer();
- assert.ok(
- object.isInterleavedBuffer,
- 'InterleavedBuffer.isInterleavedBuffer should be true'
- );
- } );
- QUnit.test( 'setUsage', ( assert ) => {
- const instance = new InterleavedBuffer();
- instance.setUsage( DynamicDrawUsage );
- assert.strictEqual( instance.usage, DynamicDrawUsage, 'Usage was set' );
- } );
- QUnit.test( 'copy', ( assert ) => {
- const array = new Float32Array( [ 1, 2, 3, 7, 8, 9 ] );
- const instance = new InterleavedBuffer( array, 3 );
- instance.setUsage( DynamicDrawUsage );
- checkInstanceAgainstCopy( instance, instance.copy( instance ), assert );
- } );
- QUnit.test( 'copyAt', ( assert ) => {
- const a = new InterleavedBuffer( new Float32Array( [ 1, 2, 3, 4, 5, 6, 7, 8, 9 ] ), 3 );
- const b = new InterleavedBuffer( new Float32Array( 9 ), 3 );
- const expected = new Float32Array( [ 4, 5, 6, 7, 8, 9, 1, 2, 3 ] );
- b.copyAt( 1, a, 2 );
- b.copyAt( 0, a, 1 );
- b.copyAt( 2, a, 0 );
- assert.deepEqual( b.array, expected, 'Check the right values were replaced' );
- } );
- QUnit.test( 'set', ( assert ) => {
- const instance = new InterleavedBuffer( new Float32Array( [ 1, 2, 3, 7, 8, 9 ] ), 3 );
- instance.set( [ 0, - 1 ] );
- assert.ok( instance.array[ 0 ] === 0 && instance.array[ 1 ] === - 1, 'replace at first by default' );
- } );
- QUnit.todo( 'clone', ( assert ) => {
- assert.ok( false, 'everything\'s gonna be alright' );
- } );
- QUnit.test( 'onUpload', ( assert ) => {
- const a = new InterleavedBuffer();
- const func = function () { };
- a.onUpload( func );
- assert.strictEqual( a.onUploadCallback, func, 'Check callback was set properly' );
- } );
- QUnit.todo( 'toJSON', ( assert ) => {
- assert.ok( false, 'everything\'s gonna be alright' );
- } );
- // OTHERS
- QUnit.test( 'count', ( assert ) => {
- const instance = new InterleavedBuffer( new Float32Array( [ 1, 2, 3, 7, 8, 9 ] ), 3 );
- assert.equal( instance.count, 2, 'count is calculated via array length / stride' );
- } );
- } );
- } );
|