forked from CesiumGS/cesium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
render.js
57 lines (48 loc) · 1.87 KB
/
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
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
import { defined } from '../Source/Cesium.js';
import { Intersect } from '../Source/Cesium.js';
import { Pass } from '../Source/Cesium.js';
import { SceneMode } from '../Source/Cesium.js';
function executeCommands(frameState, commands) {
var commandsExecuted = 0;
var cullingVolume = frameState.cullingVolume;
var occluder;
if (frameState.mode === SceneMode.SCENE3D) {
occluder = frameState.occluder;
}
var length = commands.length;
for (var i = 0; i < length; ++i) {
var command = commands[i];
var boundingVolume = command.boundingVolume;
if (defined(boundingVolume)) {
if (cullingVolume.computeVisibility(boundingVolume) === Intersect.OUTSIDE ||
(defined(occluder) && !occluder.isBoundingSphereVisible(boundingVolume))) {
continue;
}
}
command.execute(frameState.context);
commandsExecuted++;
}
return commandsExecuted;
}
function render(frameState, primitive) {
frameState.commandList.length = 0;
primitive.update(frameState);
var i;
var renderCommands = new Array(Pass.NUMBER_OF_PASSES);
for (i = 0; i < Pass.NUMBER_OF_PASSES; ++i) {
renderCommands[i] = [];
}
var commands = frameState.commandList;
var length = commands.length;
for (i = 0; i < length; i++) {
var command = commands[i];
var pass = defined(command.pass) ? command.pass : Pass.OPAQUE;
renderCommands[pass].push(command);
}
var commandsExecuted = 0;
for (i = 0; i < Pass.NUMBER_OF_PASSES; ++i) {
commandsExecuted += executeCommands(frameState, renderCommands[i]);
}
return commandsExecuted;
}
export default render;