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
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
import { Cartesian2 } from "../Source/Cesium.js";
import { clone } from "../Source/Cesium.js";
import { defaultValue } from "../Source/Cesium.js";
import { defined } from "../Source/Cesium.js";
import { Scene } from "../Source/Cesium.js";
import createCanvas from "./createCanvas.js";
import getWebGLStub from "./getWebGLStub.js";
 
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
  );
  contextOptions.webgl.stencil = defaultValue(
    contextOptions.webgl.stencil,
    true
  );
  if (!!window.webglStub) {
    contextOptions.getWebGLStub = getWebGLStub;
  }
 
  var scene = new Scene(options);
  scene.highDynamicRange = false;
 
  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 = this.canvas;
    this.destroy();
    document.body.removeChild(canvas);
  };
 
  scene.renderForSpecs = function (time) {
    this.initializeFrame();
    this.render(time);
  };
 
  scene.pickForSpecs = function () {
    this.pick(new Cartesian2(0, 0));
  };
 
  scene.rethrowRenderErrors = defaultValue(options.rethrowRenderErrors, true);
 
  return scene;
}
export default createScene;