Skip to content

Commit 8e1a3ac

Browse files
committed
Tests: Add BufferLoader unit test to check if serialized BufferAttribute can be deserialized
1 parent e5e0227 commit 8e1a3ac

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/unit/src/loaders/BufferGeometryLoader.tests.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/* global QUnit */
22

3+
import { BufferAttribute } from '../../../../src/core/BufferAttribute';
4+
import { BufferGeometry } from '../../../../src/core/BufferGeometry';
35
import { BufferGeometryLoader } from '../../../../src/loaders/BufferGeometryLoader';
6+
import { DynamicDrawUsage } from '../../../../src/constants';
47

58
export default QUnit.module( 'Loaders', () => {
69

@@ -26,6 +29,31 @@ export default QUnit.module( 'Loaders', () => {
2629

2730
} );
2831

32+
QUnit.test( "parser - attributes - circlable", ( assert ) => {
33+
34+
const loader = new BufferGeometryLoader();
35+
const geometry = new BufferGeometry();
36+
const attr = new BufferAttribute( new Float32Array( [ 7, 8, 9, 10, 11, 12 ] ), 2, true );
37+
attr.name = 'attribute';
38+
attr.setUsage( DynamicDrawUsage );
39+
attr.updateRange.offset = 1;
40+
attr.updateRange.count = 2;
41+
42+
geometry.setAttribute( 'attr', attr );
43+
44+
const geometry2 = loader.parse( geometry.toJSON() );
45+
46+
assert.ok( geometry2.getAttribute( 'attr' ),
47+
'Serialized attribute can be deserialized under the same attribute key.' );
48+
49+
assert.deepEqual(
50+
geometry.getAttribute( 'attr' ),
51+
geometry2.getAttribute( 'attr' ),
52+
'Serialized attribute can be deserialized correctly.'
53+
);
54+
55+
} );
56+
2957
} );
3058

3159
} );

0 commit comments

Comments
 (0)