forked from CesiumGS/cesium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateScene.js
71 lines (58 loc) · 1.97 KB
/
createScene.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
/*global define*/
define([
'Core/Cartesian2',
'Core/clone',
'Core/defaultValue',
'Core/defined',
'Core/queryToObject',
'Scene/Scene',
'Specs/createCanvas',
'Specs/destroyCanvas'
], function(
Cartesian2,
clone,
defaultValue,
defined,
queryToObject,
Scene,
createCanvas,
destroyCanvas) {
'use strict';
function createScene(options) {
options = defaultValue(options, {});
// save the canvas so we don't try to clone an HTMLCanvasElement
var canvas = defined(options.canvas) ? options.canvas : createCanvas();
options.canvas = undefined;
options = clone(options, true);
options.canvas = canvas;
options.contextOptions = defaultValue(options.contextOptions, {});
var contextOptions = options.contextOptions;
contextOptions.webgl = defaultValue(contextOptions.webgl, {});
contextOptions.webgl.antialias = defaultValue(contextOptions.webgl.antialias, false);
var scene = new Scene(options);
if (window.webglValidation) {
var context = scene.context;
context.validateShaderProgram = true;
context.validateFramebuffer = true;
context.logShaderCompilation = true;
context.throwOnWebGLError = true;
}
// Add functions for test
scene.destroyForSpecs = function() {
var canvas = scene.canvas;
scene.destroy();
destroyCanvas(canvas);
};
scene.renderForSpecs = function(time) {
scene.initializeFrame();
scene.render(time);
return scene.context.readPixels();
};
scene.pickForSpecs = function() {
return scene.pick(new Cartesian2(0, 0));
};
scene.rethrowRenderErrors = defaultValue(options.rethrowRenderErrors, true);
return scene;
}
return createScene;
});