MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / Viewport

Class Viewport

src/main/java/fieldbox/boxes/plugins/Viewport.java:28–470  ·  view source on GitHub ↗

A box that has a 3d drawing canvas inside it.

Source from the content-addressed store, hash-verified

26public class Viewport extends Box implements IO.Loaded, ProvidesGraphicsContext {
27
28 static public final Dict.Prop<Scene> scene = new Dict.Prop<Scene>("scene").type()
29 .toCanon()
30 .doc("The Scene that's inside this viewport");
31
32 static public final Dict.Prop<Camera> camera = new Dict.Prop<Camera>("camera").type()
33 .toCanon()
34 .doc("A Camera object for this viewport");
35
36 static public final Dict.Prop<IdempotencyMap<Supplier<FLine>>> lines3 = new Dict.Prop<>("lines3").type()
37 .toCanon()
38 .doc("3D Geometry to be drawn along with this box")
39 .autoConstructs(() -> new IdempotencyMap<>(Supplier.class));
40
41 static public final Dict.Prop<IdempotencyMap<Supplier<FLine>>> pointSelection = new Dict.Prop<>("pointSelection").type()
42 .toCanon()
43 .doc("adding lines to this property will additionally make their control points selectable")
44 .autoConstructs(() -> new IdempotencyMap<>(Supplier.class));
45
46 static public final Dict.Prop<IdempotencyMap<Supplier<Collection<Supplier<FLine>>>>> bulkLines3 = new Dict.Prop<>("bulkLines3").type()
47 .toCanon()
48 .doc("3D Geometry to be drawn along with this box")
49 .autoConstructs(() -> new IdempotencyMap<>(Supplier.class));
50
51 static public final Dict.Prop<Boolean> clips = new Dict.Prop<>("clips").type()
52 .toCanon()
53 .doc("set to `true` to have this viewport clip its contents to its frame").set(IO.persistent, true);
54
55 private Drawing drawing;
56
57
58 /**
59 * shaders for standard drawing of points lines and planes (with 3d camera transform)
60 */
61 public class Standard {
62 private final Camera camera;
63
64 BaseMesh triangles = BaseMesh.triangleList(0, 0);
65 MeshBuilder triangles_builder = new MeshBuilder(triangles);
66 BaseMesh lines = BaseMesh.lineList(0, 0);
67
68 MeshBuilder lines_builder = new MeshBuilder(lines);
69 BaseMesh points = BaseMesh.pointList(0);
70 MeshBuilder points_builder = new MeshBuilder(points);
71
72 Shader trianglesAndLinesShader = new Shader();
73
74 Shader pointShader = new Shader();
75
76 public Standard(Camera camera) {
77 this.camera = camera;
78 trianglesAndLinesShader.addSource(Shader.Type.vertex, "#version 410\n" +
79 "layout(location=0) in vec3 position;\n" +
80 "layout(location=1) in vec4 color;\n" +
81 "out vec4 vcolor;\n" +
82 "uniform mat4 _p;\n" +
83 "uniform mat4 _mv;\n" +
84 "void main()\n" +
85 "{\n" +

Callers

nothing calls this directly

Calls 7

docMethod · 0.80
toCanonMethod · 0.80
typeMethod · 0.80
autoConstructsMethod · 0.80
setMethod · 0.65
allocateMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected