提交 0566ee81 编写于 作者: D Don McCurdy

BufferGeometryUtils: More tests.

上级 5c825e3e
......@@ -31,12 +31,12 @@ export default QUnit.module( 'BufferGeometryUtils', () => {
var array2 = new Float32Array( [ 5, 6, 7, 8 ] );
var attr2 = new THREE.BufferAttribute( array2, 4, false );
assert.equal( THREE.BufferGeometryUtils.mergeBufferAttributes( [ attr1, attr2 ] ), null );
assert.notOk( THREE.BufferGeometryUtils.mergeBufferAttributes( [ attr1, attr2 ] ) );
attr2.itemSize = 2;
attr2.normalized = true;
assert.equal( THREE.BufferGeometryUtils.mergeBufferAttributes( [ attr1, attr2 ] ), null );
assert.notOk( THREE.BufferGeometryUtils.mergeBufferAttributes( [ attr1, attr2 ] ) );
attr2.normalized = false;
......@@ -79,15 +79,50 @@ export default QUnit.module( 'BufferGeometryUtils', () => {
} );
QUnit.todo( 'mergeBufferGeometries - morph targets', ( assert ) => {
QUnit.test( 'mergeBufferGeometries - morph targets', ( assert ) => {
var geometry1 = new THREE.BufferGeometry();
geometry1.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( [ 1, 2, 3 ] ), 1, false ) );
geometry1.morphAttributes.position = [
new THREE.BufferAttribute( new Float32Array( [ 10, 20, 30 ] ), 1, false ),
new THREE.BufferAttribute( new Float32Array( [ 100, 200, 300 ] ), 1, false )
];
var geometry2 = new THREE.BufferGeometry();
geometry2.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( [ 4, 5, 6 ] ), 1, false ) );
geometry2.morphAttributes.position = [
new THREE.BufferAttribute( new Float32Array( [ 40, 50, 60 ] ), 1, false ),
new THREE.BufferAttribute( new Float32Array( [ 400, 500, 600 ] ), 1, false )
];
var mergedGeometry = THREE.BufferGeometryUtils.mergeBufferGeometries( [ geometry1, geometry2 ] );
assert.ok( mergedGeometry, 'merge succeeds' );
assert.smartEqual( Array.from( mergedGeometry.attributes.position.array ), [ 1, 2, 3, 4, 5, 6 ], 'merges elements' );
assert.smartEqual( Array.from( mergedGeometry.morphAttributes.position[ 0 ].array ), [ 10, 20, 30, 40, 50, 60 ], 'merges morph targets' );
assert.smartEqual( Array.from( mergedGeometry.morphAttributes.position[ 1 ].array ), [ 100, 200, 300, 400, 500, 600 ], 'merges morph targets' );
assert.equal( mergedGeometry.attributes.position.itemSize, 1, 'retains .itemSize' );
} );
QUnit.todo( 'mergeBufferGeometries - invalid', ( assert ) => {
QUnit.test( 'mergeBufferGeometries - invalid', ( assert ) => {
var geometry1 = new THREE.BufferGeometry();
geometry1.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( [ 1, 2, 3 ] ), 1, false ) );
geometry1.setIndex( new THREE.BufferAttribute( new Uint16Array( [ 0, 1, 2 ] ), 1, false ) );
var geometry2 = new THREE.BufferGeometry();
geometry2.addAttribute( 'position', new THREE.BufferAttribute( new Float32Array( [ 4, 5, 6 ] ), 1, false ) );
assert.notOk( THREE.BufferGeometryUtils.mergeBufferGeometries( [ geometry1, geometry2 ] ) );
geometry2.setIndex( new THREE.BufferAttribute( new Uint16Array( [ 0, 1, 2 ] ), 1, false ) );
assert.ok( THREE.BufferGeometryUtils.mergeBufferGeometries( [ geometry1, geometry2 ] ) );
geometry2.addAttribute( 'foo', new THREE.BufferAttribute( new Float32Array( [ 1, 2, 3 ] ), 1, false ) );
assert.notOk( THREE.BufferGeometryUtils.mergeBufferGeometries( [ geometry1, geometry2 ] ) );
} );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册