InterleavedBuffer.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /**
  2. * @author simonThiele / https://github.com/simonThiele
  3. */
  4. QUnit.module( "InterleavedBuffer" );
  5. function checkInstanceAgainstCopy( instance, copiedInstance, assert ) {
  6. assert.ok( copiedInstance instanceof THREE.InterleavedBuffer, "the clone has the correct type" );
  7. for ( var i = 0; i < instance.array.length; i++ ) {
  8. assert.ok( copiedInstance.array[i] === instance.array[i], "array was copied" );
  9. }
  10. assert.ok( copiedInstance.stride === instance.stride, "stride was copied" );
  11. assert.ok( copiedInstance.dynamic === true, "dynamic was copied" );
  12. }
  13. QUnit.test( "count", function( assert ) {
  14. var instance = new THREE.InterleavedBuffer( new Float32Array( [1, 2, 3, 7, 8 ,9] ), 3 );
  15. assert.equal( instance.count, 2, "count is calculated via array length / stride" );
  16. });
  17. QUnit.test( "copy" , function( assert ) {
  18. var array = new Float32Array( [1, 2, 3, 7, 8 ,9] );
  19. var instance = new THREE.InterleavedBuffer( array, 3 );
  20. instance.setDynamic( true );
  21. checkInstanceAgainstCopy(instance, instance.copy( instance ), assert );
  22. });
  23. QUnit.test( "clone" , function( assert ) {
  24. var array = new Float32Array( [1, 2, 3, 7, 8 ,9] );
  25. var instance = new THREE.InterleavedBuffer( array, 3 );
  26. instance.setDynamic( true );
  27. checkInstanceAgainstCopy( instance, instance.clone(), assert );
  28. });
  29. QUnit.test( "set" , function( assert ) {
  30. var instance = new THREE.InterleavedBuffer( new Float32Array( [1, 2, 3, 7, 8 ,9] ), 3 );
  31. instance.set( [0, -1] );
  32. assert.ok( instance.array[0] === 0 && instance.array[1] === -1, "replace at first by default" );
  33. });
粤ICP备19079148号