-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
DebugModelMatrixPrimitiveSpec.js
92 lines (80 loc) · 2.51 KB
/
DebugModelMatrixPrimitiveSpec.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import { Cartesian3 } from "../../Source/Cesium.js";
import { Matrix4 } from "../../Source/Cesium.js";
import { DebugModelMatrixPrimitive } from "../../Source/Cesium.js";
import createScene from "../createScene.js";
describe(
"Scene/DebugModelMatrixPrimitive",
function () {
let scene;
beforeAll(function () {
scene = createScene();
const camera = scene.camera;
camera.position = new Cartesian3(1.02, 0.0, 0.0);
camera.direction = Cartesian3.negate(Cartesian3.UNIT_X, new Cartesian3());
camera.up = Cartesian3.clone(Cartesian3.UNIT_Z);
});
afterAll(function () {
scene.destroyForSpecs();
});
afterEach(function () {
scene.primitives.removeAll();
});
it("gets the default properties", function () {
const p = new DebugModelMatrixPrimitive();
expect(p.length).toEqual(10000000.0);
expect(p.width).toEqual(2.0);
expect(p.modelMatrix).toEqual(Matrix4.IDENTITY);
expect(p.show).toEqual(true);
expect(p.id).not.toBeDefined();
p.destroy();
});
it("Constructs with options", function () {
const p = new DebugModelMatrixPrimitive({
length: 10.0,
width: 1.0,
modelMatrix: Matrix4.fromUniformScale(2.0),
show: false,
id: "id",
});
expect(p.length).toEqual(10.0);
expect(p.width).toEqual(1.0);
expect(p.modelMatrix).toEqual(Matrix4.fromUniformScale(2.0));
expect(p.show).toEqual(false);
expect(p.id).toEqual("id");
p.destroy();
});
it("renders", function () {
const p = scene.primitives.add(new DebugModelMatrixPrimitive());
expect(scene).notToRender([0, 0, 0, 255]);
// Update and render again
p.length = 100.0;
expect(scene).notToRender([0, 0, 0, 255]);
});
it("does not render when show is false", function () {
scene.primitives.add(
new DebugModelMatrixPrimitive({
show: false,
})
);
expect(scene).toRender([0, 0, 0, 255]);
});
it("is picked", function () {
const p = scene.primitives.add(
new DebugModelMatrixPrimitive({
id: "id",
})
);
expect(scene).toPickAndCall(function (result) {
expect(result.primitive).toBe(p);
expect(result.id).toBe("id");
});
});
it("isDestroyed", function () {
const p = new DebugModelMatrixPrimitive();
expect(p.isDestroyed()).toEqual(false);
p.destroy();
expect(p.isDestroyed()).toEqual(true);
});
},
"WebGL"
);