InterleavedBufferAttribute.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * @author simonThiele / https://github.com/simonThiele
  3. */
  4. module( "InterleavedBufferAttribute" );
  5. test( "length and count", function() {
  6. var buffer = new THREE.InterleavedBuffer( new Float32Array( [1, 2, 3, 7, 8 ,9] ), 3 );
  7. var instance = new THREE.InterleavedBufferAttribute( buffer, 2, 0 );
  8. ok( instance.count === 2, "count is calculated via array length / stride" );
  9. });
  10. test( "setX", function() {
  11. var buffer = new THREE.InterleavedBuffer( new Float32Array( [1, 2, 3, 7, 8 ,9] ), 3 );
  12. var instance = new THREE.InterleavedBufferAttribute( buffer, 2, 0 );
  13. instance.setX( 0, 123 );
  14. instance.setX( 1, 321 );
  15. ok( instance.data.array[0] === 123 &&
  16. instance.data.array[3] === 321, "x was calculated correct based on index and default offset" );
  17. buffer = new THREE.InterleavedBuffer( new Float32Array( [1, 2, 3, 7, 8 ,9] ), 3 );
  18. instance = new THREE.InterleavedBufferAttribute( buffer, 2, 1 );
  19. instance.setX( 0, 123 );
  20. instance.setX( 1, 321 );
  21. // the offset was defined as 1, so go one step futher in the array
  22. ok( instance.data.array[1] === 123 &&
  23. instance.data.array[4] === 321, "x was calculated correct based on index and default offset" );
  24. });
  25. // setY, setZ and setW are calculated in the same way so not testing this