forked from CesiumGS/cesium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPrimitivePipelineSpec.js
66 lines (57 loc) · 2.26 KB
/
PrimitivePipelineSpec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*global defineSuite*/
defineSuite([
'Scene/PrimitivePipeline',
'Core/BoundingSphere',
'Core/BoxGeometry',
'Core/Cartesian3',
'Core/ComponentDatatype',
'Core/Geometry',
'Core/GeometryAttribute',
'Core/GeometryAttributes',
'Core/PrimitiveType'
], function(
PrimitivePipeline,
BoundingSphere,
BoxGeometry,
Cartesian3,
ComponentDatatype,
Geometry,
GeometryAttribute,
GeometryAttributes,
PrimitiveType) {
'use strict';
it('can pack and unpack geometry', function() {
var boxGeometry = BoxGeometry.createGeometry(BoxGeometry.fromDimensions({
dimensions : new Cartesian3(1, 2, 3)
}));
var boxGeometry2 = BoxGeometry.createGeometry(BoxGeometry.fromDimensions({
dimensions : new Cartesian3(3, 4, 7)
}));
var geometryToPack = [boxGeometry, boxGeometry2];
var transferableObjects = [];
var results = PrimitivePipeline.packCreateGeometryResults(geometryToPack, transferableObjects);
var unpackedGeometry = PrimitivePipeline.unpackCreateGeometryResults(results);
expect(transferableObjects.length).toBe(1);
expect(geometryToPack).toEqual(unpackedGeometry);
});
it('can pack and unpack geometry without indices', function() {
var attributes = new GeometryAttributes();
attributes.position = new GeometryAttribute({
componentDatatype : ComponentDatatype.FLOAT,
componentsPerAttribute : 3,
values : new Float32Array([1, 2, 3, 4, 5, 6])
});
var geometry = new Geometry({
attributes : attributes,
indices : undefined,
primitiveType : PrimitiveType.POINTS,
boundingSphere : BoundingSphere.fromVertices(attributes.position.values)
});
var geometryToPack = [geometry];
var transferableObjects = [];
var results = PrimitivePipeline.packCreateGeometryResults(geometryToPack, transferableObjects);
var unpackedGeometry = PrimitivePipeline.unpackCreateGeometryResults(results);
expect(transferableObjects.length).toBe(1);
expect(geometryToPack).toEqual(unpackedGeometry);
});
}, 'WebGL');