-
Notifications
You must be signed in to change notification settings - Fork 0
/
render.js
29 lines (25 loc) · 847 Bytes
/
render.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
class RenderMesh {
constructor( matrix, mesh ) {
this.matrix = matrix;
this.mesh = mesh;
}
}
class RenderLight {
constructor( location, color, num ) {
this.loc = location;
this.color = color;
this.num = num;
}
}
function generate_render_jobs(parent_matrix, node, jobs, lights) {
let matrix = parent_matrix.mul(node.getMatrix());
if (node.data instanceof Light) {
let color = [node.data.r, node.data.g, node.data.b];
lights.push( new RenderLight(matrix.get_transformed_coordinates(), color, node.data.light_no) );
} else if (node.data instanceof FishMesh || node.data instanceof NormalMesh) {
jobs.push( new RenderMesh(matrix, node.data) );
}
for (let child of node.children) {
generate_render_jobs(matrix, child, jobs, lights);
}
}