yzt
2023-05-26 de4278af2fd46705a40bac58ec01122db6b7f3d7
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
67
68
69
70
71
import { BoundingSphere } from "../../Source/Cesium.js";
import { BoxGeometry } from "../../Source/Cesium.js";
import { Cartesian3 } from "../../Source/Cesium.js";
import { ComponentDatatype } from "../../Source/Cesium.js";
import { Geometry } from "../../Source/Cesium.js";
import { GeometryAttribute } from "../../Source/Cesium.js";
import { GeometryAttributes } from "../../Source/Cesium.js";
import { PrimitiveType } from "../../Source/Cesium.js";
import { PrimitivePipeline } from "../../Source/Cesium.js";
 
describe(
  "Scene/PrimitivePipeline",
  function () {
    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"
);