15832144755
2022-01-06 7b4c8991dca9cf2a809a95e239d144697d3afb56
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
import { ShaderFunction } from "../../Source/Cesium.js";
 
describe("Renderer/ShaderFunction", function () {
  var signature = "vec3 testFunction(vec3 position)";
  it("constructs", function () {
    var func = new ShaderFunction(signature);
    expect(func.signature).toEqual(signature);
    expect(func.body).toEqual([]);
  });
 
  it("addLines adds lines to the function body", function () {
    var func = new ShaderFunction("TestStruct");
    func.addLines(["v_color = a_color;", "return vec3(0.0, 0.0, 1.0);"]);
    expect(func.body).toEqual([
      "    v_color = a_color;",
      "    return vec3(0.0, 0.0, 1.0);",
    ]);
  });
 
  it("generateGlslLines generates a function", function () {
    var func = new ShaderFunction(signature);
    func.addLines(["v_color = a_color;", "return vec3(0.0, 0.0, 1.0);"]);
    expect(func.generateGlslLines()).toEqual([
      signature,
      "{",
      "    v_color = a_color;",
      "    return vec3(0.0, 0.0, 1.0);",
      "}",
    ]);
  });
});