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
import { Cartesian3 } from "../../Source/Cesium.js";
import { PlaneGeometry } from "../../Source/Cesium.js";
import { VertexFormat } from "../../Source/Cesium.js";
import createPackableSpecs from "../createPackableSpecs.js";
 
describe("Core/PlaneGeometry", function () {
  it("constructor creates optimized number of positions for VertexFormat.POSITIONS_ONLY", function () {
    var m = PlaneGeometry.createGeometry(
      new PlaneGeometry({
        vertexFormat: VertexFormat.POSITION_ONLY,
      })
    );
 
    expect(m.attributes.position.values.length).toEqual(4 * 3); // 4 corners
    expect(m.indices.length).toEqual(2 * 3); // 2 triangles
  });
 
  it("constructor computes all vertex attributes", function () {
    var m = PlaneGeometry.createGeometry(
      new PlaneGeometry({
        vertexFormat: VertexFormat.ALL,
      })
    );
 
    var numVertices = 4;
    var numTriangles = 2;
    expect(m.attributes.position.values.length).toEqual(numVertices * 3);
    expect(m.attributes.normal.values.length).toEqual(numVertices * 3);
    expect(m.attributes.tangent.values.length).toEqual(numVertices * 3);
    expect(m.attributes.bitangent.values.length).toEqual(numVertices * 3);
    expect(m.attributes.st.values.length).toEqual(numVertices * 2);
 
    expect(m.indices.length).toEqual(numTriangles * 3);
 
    expect(m.boundingSphere.center).toEqual(Cartesian3.ZERO);
    expect(m.boundingSphere.radius).toEqual(Math.sqrt(2.0));
  });
 
  createPackableSpecs(
    PlaneGeometry,
    new PlaneGeometry({
      vertexFormat: VertexFormat.POSITION_AND_NORMAL,
    }),
    [1.0, 1.0, 0.0, 0.0, 0.0, 0.0]
  );
});