-
Notifications
You must be signed in to change notification settings - Fork 3.5k
/
Scene.js
3563 lines (3068 loc) · 138 KB
/
Scene.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
define([
'../Core/BoundingRectangle',
'../Core/BoundingSphere',
'../Core/BoxGeometry',
'../Core/buildModuleUrl',
'../Core/Cartesian2',
'../Core/Cartesian3',
'../Core/Cartesian4',
'../Core/Cartographic',
'../Core/Color',
'../Core/ColorGeometryInstanceAttribute',
'../Core/createGuid',
'../Core/CullingVolume',
'../Core/defaultValue',
'../Core/defined',
'../Core/defineProperties',
'../Core/destroyObject',
'../Core/DeveloperError',
'../Core/EllipsoidGeometry',
'../Core/Event',
'../Core/GeographicProjection',
'../Core/GeometryInstance',
'../Core/GeometryPipeline',
'../Core/getTimestamp',
'../Core/Intersect',
'../Core/Interval',
'../Core/JulianDate',
'../Core/Math',
'../Core/Matrix4',
'../Core/mergeSort',
'../Core/Occluder',
'../Core/OrthographicFrustum',
'../Core/OrthographicOffCenterFrustum',
'../Core/PerspectiveFrustum',
'../Core/PerspectiveOffCenterFrustum',
'../Core/PixelFormat',
'../Core/RequestScheduler',
'../Core/ShowGeometryInstanceAttribute',
'../Core/Transforms',
'../Renderer/ClearCommand',
'../Renderer/ComputeEngine',
'../Renderer/Context',
'../Renderer/ContextLimits',
'../Renderer/DrawCommand',
'../Renderer/Framebuffer',
'../Renderer/loadCubeMap',
'../Renderer/Pass',
'../Renderer/PassState',
'../Renderer/PixelDatatype',
'../Renderer/RenderState',
'../Renderer/Sampler',
'../Renderer/ShaderProgram',
'../Renderer/ShaderSource',
'../Renderer/Texture',
'./BrdfLutGenerator',
'./Camera',
'./CreditDisplay',
'./DebugCameraPrimitive',
'./DepthPlane',
'./DeviceOrientationCameraController',
'./Fog',
'./FrameState',
'./FrustumCommands',
'./FXAA',
'./GlobeDepth',
'./InvertClassification',
'./JobScheduler',
'./MapMode2D',
'./OIT',
'./PerformanceDisplay',
'./PerInstanceColorAppearance',
'./PickDepth',
'./Primitive',
'./PrimitiveCollection',
'./SceneMode',
'./SceneTransforms',
'./SceneTransitioner',
'./ScreenSpaceCameraController',
'./ShadowMap',
'./SunPostProcess',
'./TweenCollection'
], function(
BoundingRectangle,
BoundingSphere,
BoxGeometry,
buildModuleUrl,
Cartesian2,
Cartesian3,
Cartesian4,
Cartographic,
Color,
ColorGeometryInstanceAttribute,
createGuid,
CullingVolume,
defaultValue,
defined,
defineProperties,
destroyObject,
DeveloperError,
EllipsoidGeometry,
Event,
GeographicProjection,
GeometryInstance,
GeometryPipeline,
getTimestamp,
Intersect,
Interval,
JulianDate,
CesiumMath,
Matrix4,
mergeSort,
Occluder,
OrthographicFrustum,
OrthographicOffCenterFrustum,
PerspectiveFrustum,
PerspectiveOffCenterFrustum,
PixelFormat,
RequestScheduler,
ShowGeometryInstanceAttribute,
Transforms,
ClearCommand,
ComputeEngine,
Context,
ContextLimits,
DrawCommand,
Framebuffer,
loadCubeMap,
Pass,
PassState,
PixelDatatype,
RenderState,
Sampler,
ShaderProgram,
ShaderSource,
Texture,
BrdfLutGenerator,
Camera,
CreditDisplay,
DebugCameraPrimitive,
DepthPlane,
DeviceOrientationCameraController,
Fog,
FrameState,
FrustumCommands,
FXAA,
GlobeDepth,
InvertClassification,
JobScheduler,
MapMode2D,
OIT,
PerformanceDisplay,
PerInstanceColorAppearance,
PickDepth,
Primitive,
PrimitiveCollection,
SceneMode,
SceneTransforms,
SceneTransitioner,
ScreenSpaceCameraController,
ShadowMap,
SunPostProcess,
TweenCollection) {
'use strict';
/**
* The container for all 3D graphical objects and state in a Cesium virtual scene. Generally,
* a scene is not created directly; instead, it is implicitly created by {@link CesiumWidget}.
* <p>
* <em><code>contextOptions</code> parameter details:</em>
* </p>
* <p>
* The default values are:
* <code>
* {
* webgl : {
* alpha : false,
* depth : true,
* stencil : false,
* antialias : true,
* premultipliedAlpha : true,
* preserveDrawingBuffer : false,
* failIfMajorPerformanceCaveat : false
* },
* allowTextureFilterAnisotropic : true
* }
* </code>
* </p>
* <p>
* The <code>webgl</code> property corresponds to the {@link http://www.khronos.org/registry/webgl/specs/latest/#5.2|WebGLContextAttributes}
* object used to create the WebGL context.
* </p>
* <p>
* <code>webgl.alpha</code> defaults to false, which can improve performance compared to the standard WebGL default
* of true. If an application needs to composite Cesium above other HTML elements using alpha-blending, set
* <code>webgl.alpha</code> to true.
* </p>
* <p>
* The other <code>webgl</code> properties match the WebGL defaults for {@link http://www.khronos.org/registry/webgl/specs/latest/#5.2|WebGLContextAttributes}.
* </p>
* <p>
* <code>allowTextureFilterAnisotropic</code> defaults to true, which enables anisotropic texture filtering when the
* WebGL extension is supported. Setting this to false will improve performance, but hurt visual quality, especially for horizon views.
* </p>
*
* @alias Scene
* @constructor
*
* @param {Object} [options] Object with the following properties:
* @param {Canvas} options.canvas The HTML canvas element to create the scene for.
* @param {Object} [options.contextOptions] Context and WebGL creation properties. See details above.
* @param {Element} [options.creditContainer] The HTML element in which the credits will be displayed.
* @param {MapProjection} [options.mapProjection=new GeographicProjection()] The map projection to use in 2D and Columbus View modes.
* @param {Boolean} [options.orderIndependentTranslucency=true] If true and the configuration supports it, use order independent translucency.
* @param {Boolean} [options.scene3DOnly=false] If true, optimizes memory use and performance for 3D mode but disables the ability to use 2D or Columbus View.
* @param {Number} [options.terrainExaggeration=1.0] A scalar used to exaggerate the terrain. Note that terrain exaggeration will not modify any other primitive as they are positioned relative to the ellipsoid.
* @param {Boolean} [options.shadows=false] Determines if shadows are cast by the sun.
* @param {MapMode2D} [options.mapMode2D=MapMode2D.INFINITE_SCROLL] Determines if the 2D map is rotatable or can be scrolled infinitely in the horizontal direction.
*
* @see CesiumWidget
* @see {@link http://www.khronos.org/registry/webgl/specs/latest/#5.2|WebGLContextAttributes}
*
* @exception {DeveloperError} options and options.canvas are required.
*
* @example
* // Create scene without anisotropic texture filtering
* var scene = new Cesium.Scene({
* canvas : canvas,
* contextOptions : {
* allowTextureFilterAnisotropic : false
* }
* });
*/
function Scene(options) {
options = defaultValue(options, defaultValue.EMPTY_OBJECT);
var canvas = options.canvas;
var contextOptions = options.contextOptions;
var creditContainer = options.creditContainer;
//>>includeStart('debug', pragmas.debug);
if (!defined(canvas)) {
throw new DeveloperError('options and options.canvas are required.');
}
//>>includeEnd('debug');
var context = new Context(canvas, contextOptions);
if (!defined(creditContainer)) {
creditContainer = document.createElement('div');
creditContainer.style.position = 'absolute';
creditContainer.style.bottom = '0';
creditContainer.style['text-shadow'] = '0 0 2px #000000';
creditContainer.style.color = '#ffffff';
creditContainer.style['font-size'] = '10px';
creditContainer.style['padding-right'] = '5px';
canvas.parentNode.appendChild(creditContainer);
}
this._id = createGuid();
this._jobScheduler = new JobScheduler();
this._frameState = new FrameState(context, new CreditDisplay(creditContainer), this._jobScheduler);
this._frameState.scene3DOnly = defaultValue(options.scene3DOnly, false);
var ps = new PassState(context);
ps.viewport = new BoundingRectangle();
ps.viewport.x = 0;
ps.viewport.y = 0;
ps.viewport.width = context.drawingBufferWidth;
ps.viewport.height = context.drawingBufferHeight;
this._passState = ps;
this._canvas = canvas;
this._context = context;
this._computeEngine = new ComputeEngine(context);
this._globe = undefined;
this._primitives = new PrimitiveCollection();
this._groundPrimitives = new PrimitiveCollection();
this._tweens = new TweenCollection();
this._shaderFrameCount = 0;
this._sunPostProcess = undefined;
this._computeCommandList = [];
this._frustumCommandsList = [];
this._overlayCommandList = [];
this._pickFramebuffer = undefined;
this._useOIT = defaultValue(options.orderIndependentTranslucency, true);
this._executeOITFunction = undefined;
var globeDepth;
if (context.depthTexture) {
globeDepth = new GlobeDepth();
}
var oit;
if (this._useOIT && defined(globeDepth)) {
oit = new OIT(context);
}
this._globeDepth = globeDepth;
this._depthPlane = new DepthPlane();
this._oit = oit;
this._fxaa = new FXAA();
this._clearColorCommand = new ClearCommand({
color : new Color(),
stencil : 0,
owner : this
});
this._depthClearCommand = new ClearCommand({
depth : 1.0,
owner : this
});
this._stencilClearCommand = new ClearCommand({
stencil : 0
});
this._pickDepths = [];
this._debugGlobeDepths = [];
this._pickDepthPassState = undefined;
this._pickDepthFramebuffer = undefined;
this._pickDepthFramebufferWidth = undefined;
this._pickDepthFramebufferHeight = undefined;
this._depthOnlyRenderStateCache = {};
this._transitioner = new SceneTransitioner(this);
this._renderError = new Event();
this._preRender = new Event();
this._postRender = new Event();
this._cameraStartFired = false;
this._cameraMovedTime = undefined;
this._pickPositionCache = {};
this._pickPositionCacheDirty = false;
this._minimumDisableDepthTestDistance = 0.0;
/**
* Exceptions occurring in <code>render</code> are always caught in order to raise the
* <code>renderError</code> event. If this property is true, the error is rethrown
* after the event is raised. If this property is false, the <code>render</code> function
* returns normally after raising the event.
*
* @type {Boolean}
* @default false
*/
this.rethrowRenderErrors = false;
/**
* Determines whether or not to instantly complete the
* scene transition animation on user input.
*
* @type {Boolean}
* @default true
*/
this.completeMorphOnUserInput = true;
/**
* The event fired at the beginning of a scene transition.
* @type {Event}
* @default Event()
*/
this.morphStart = new Event();
/**
* The event fired at the completion of a scene transition.
* @type {Event}
* @default Event()
*/
this.morphComplete = new Event();
/**
* The {@link SkyBox} used to draw the stars.
*
* @type {SkyBox}
* @default undefined
*
* @see Scene#backgroundColor
*/
this.skyBox = undefined;
/**
* The sky atmosphere drawn around the globe.
*
* @type {SkyAtmosphere}
* @default undefined
*/
this.skyAtmosphere = undefined;
/**
* The {@link Sun}.
*
* @type {Sun}
* @default undefined
*/
this.sun = undefined;
/**
* Uses a bloom filter on the sun when enabled.
*
* @type {Boolean}
* @default true
*/
this.sunBloom = true;
this._sunBloom = undefined;
/**
* The {@link Moon}
*
* @type Moon
* @default undefined
*/
this.moon = undefined;
/**
* The background color, which is only visible if there is no sky box, i.e., {@link Scene#skyBox} is undefined.
*
* @type {Color}
* @default {@link Color.BLACK}
*
* @see Scene#skyBox
*/
this.backgroundColor = Color.clone(Color.BLACK);
this._mode = SceneMode.SCENE3D;
this._mapProjection = defined(options.mapProjection) ? options.mapProjection : new GeographicProjection();
/**
* The current morph transition time between 2D/Columbus View and 3D,
* with 0.0 being 2D or Columbus View and 1.0 being 3D.
*
* @type {Number}
* @default 1.0
*/
this.morphTime = 1.0;
/**
* The far-to-near ratio of the multi-frustum. The default is 1,000.0.
*
* @type {Number}
* @default 1000.0
*/
this.farToNearRatio = 1000.0;
/**
* Determines the uniform depth size in meters of each frustum of the multifrustum in 2D. If a primitive or model close
* to the surface shows z-fighting, decreasing this will eliminate the artifact, but decrease performance. On the
* other hand, increasing this will increase performance but may cause z-fighting among primitives close to thesurface.
* @type {Number}
* @default 1.75e6
*/
this.nearToFarDistance2D = 1.75e6;
/**
* This property is for debugging only; it is not for production use.
* <p>
* A function that determines what commands are executed. As shown in the examples below,
* the function receives the command's <code>owner</code> as an argument, and returns a boolean indicating if the
* command should be executed.
* </p>
* <p>
* The default is <code>undefined</code>, indicating that all commands are executed.
* </p>
*
* @type Function
*
* @default undefined
*
* @example
* // Do not execute any commands.
* scene.debugCommandFilter = function(command) {
* return false;
* };
*
* // Execute only the billboard's commands. That is, only draw the billboard.
* var billboards = new Cesium.BillboardCollection();
* scene.debugCommandFilter = function(command) {
* return command.owner === billboards;
* };
*/
this.debugCommandFilter = undefined;
/**
* This property is for debugging only; it is not for production use.
* <p>
* When <code>true</code>, commands are randomly shaded. This is useful
* for performance analysis to see what parts of a scene or model are
* command-dense and could benefit from batching.
* </p>
*
* @type Boolean
*
* @default false
*/
this.debugShowCommands = false;
/**
* This property is for debugging only; it is not for production use.
* <p>
* When <code>true</code>, commands are shaded based on the frustums they
* overlap. Commands in the closest frustum are tinted red, commands in
* the next closest are green, and commands in the farthest frustum are
* blue. If a command overlaps more than one frustum, the color components
* are combined, e.g., a command overlapping the first two frustums is tinted
* yellow.
* </p>
*
* @type Boolean
*
* @default false
*/
this.debugShowFrustums = false;
this._debugFrustumStatistics = undefined;
/**
* This property is for debugging only; it is not for production use.
* <p>
* Displays frames per second and time between frames.
* </p>
*
* @type Boolean
*
* @default false
*/
this.debugShowFramesPerSecond = false;
/**
* This property is for debugging only; it is not for production use.
* <p>
* Displays depth information for the indicated frustum.
* </p>
*
* @type Boolean
*
* @default false
*/
this.debugShowGlobeDepth = false;
/**
* This property is for debugging only; it is not for production use.
* <p>
* Indicates which frustum will have depth information displayed.
* </p>
*
* @type Number
*
* @default 1
*/
this.debugShowDepthFrustum = 1;
/**
* This property is for debugging only; it is not for production use.
* <p>
* When <code>true</code>, draws outlines to show the boundaries of the camera frustums
* </p>
*
* @type Boolean
*
* @default false
*/
this.debugShowFrustumPlanes = false;
this._debugShowFrustumPlanes = false;
this._debugFrustumPlanes = undefined;
/**
* When <code>true</code>, enables Fast Approximate Anti-aliasing even when order independent translucency
* is unsupported.
*
* @type Boolean
* @default true
*/
this.fxaa = true;
/**
* When <code>true</code>, enables picking using the depth buffer.
*
* @type Boolean
* @default true
*/
this.useDepthPicking = true;
/**
* When <code>true</code>, enables picking translucent geometry using the depth buffer.
* {@link Scene#useDepthPicking} must also be true to enable picking the depth buffer.
* <p>
* There is a decrease in performance when enabled. There are extra draw calls to write depth for
* translucent geometry.
* </p>
* @type {Boolean}
* @default false
*/
this.pickTranslucentDepth = false;
/**
* The time in milliseconds to wait before checking if the camera has not moved and fire the cameraMoveEnd event.
* @type {Number}
* @default 500.0
* @private
*/
this.cameraEventWaitTime = 500.0;
/**
* Set to true to copy the depth texture after rendering the globe. Makes czm_globeDepthTexture valid.
* @type {Boolean}
* @default false
* @private
*/
this.copyGlobeDepth = false;
/**
* Blends the atmosphere to geometry far from the camera for horizon views. Allows for additional
* performance improvements by rendering less geometry and dispatching less terrain requests.
* @type {Fog}
*/
this.fog = new Fog();
this._sunCamera = new Camera(this);
/**
* The shadow map in the scene. When enabled, models, primitives, and the globe may cast and receive shadows.
* By default the light source of the shadow map is the sun.
* @type {ShadowMap}
*/
this.shadowMap = new ShadowMap({
context : context,
lightCamera : this._sunCamera,
enabled : defaultValue(options.shadows, false)
});
/**
* When <code>false</code>, 3D Tiles will render normally. When <code>true</code>, classified 3D Tile geometry will render normally and
* unclassified 3D Tile geometry will render with the color multiplied by {@link Scene#invertClassificationColor}.
* @type {Boolean}
* @default false
*/
this.invertClassification = false;
/**
* The highlight color of unclassified 3D Tile geometry when {@link Scene#invertClassification} is <code>true</code>.
* <p>When the color's alpha is less than 1.0, the unclassified portions of the 3D Tiles will not blend correctly with the classified positions of the 3D Tiles.</p>
* <p>Also, when the color's alpha is less than 1.0, the WEBGL_depth_texture and EXT_frag_depth WebGL extensions must be supported.</p>
* @type {Color}
* @default Color.WHITE
*/
this.invertClassificationColor = Color.clone(Color.WHITE);
this._actualInvertClassificationColor = Color.clone(this._invertClassificationColor);
this._invertClassification = new InvertClassification();
/**
* The focal length for use when with cardboard or WebVR.
* @type {Number}
*/
this.focalLength = undefined;
/**
* The eye separation distance in meters for use with cardboard or WebVR.
* @type {Number}
*/
this.eyeSeparation = undefined;
this._brdfLutGenerator = new BrdfLutGenerator();
this._terrainExaggeration = defaultValue(options.terrainExaggeration, 1.0);
this._performanceDisplay = undefined;
this._debugVolume = undefined;
var camera = new Camera(this);
this._camera = camera;
this._cameraClone = Camera.clone(camera);
this._screenSpaceCameraController = new ScreenSpaceCameraController(this);
this._mapMode2D = defaultValue(options.mapMode2D, MapMode2D.INFINITE_SCROLL);
// Keeps track of the state of a frame. FrameState is the state across
// the primitives of the scene. This state is for internally keeping track
// of celestial and environment effects that need to be updated/rendered in
// a certain order as well as updating/tracking framebuffer usage.
this._environmentState = {
skyBoxCommand : undefined,
skyAtmosphereCommand : undefined,
sunDrawCommand : undefined,
sunComputeCommand : undefined,
moonCommand : undefined,
isSunVisible : false,
isMoonVisible : false,
isReadyForAtmosphere : false,
isSkyAtmosphereVisible : false,
clearGlobeDepth : false,
useDepthPlane : false,
originalFramebuffer : undefined,
useGlobeDepthFramebuffer : false,
useOIT : false,
useFXAA : false,
useInvertClassification : false
};
this._useWebVR = false;
this._cameraVR = undefined;
this._aspectRatioVR = undefined;
// initial guess at frustums.
var near = camera.frustum.near;
var far = camera.frustum.far;
var numFrustums = Math.ceil(Math.log(far / near) / Math.log(this.farToNearRatio));
updateFrustums(near, far, this.farToNearRatio, numFrustums, this._frustumCommandsList, false, undefined);
// give frameState, camera, and screen space camera controller initial state before rendering
updateFrameState(this, 0.0, JulianDate.now());
this.initializeFrame();
}
var OPAQUE_FRUSTUM_NEAR_OFFSET = 0.9999;
defineProperties(Scene.prototype, {
/**
* Gets the canvas element to which this scene is bound.
* @memberof Scene.prototype
*
* @type {Canvas}
* @readonly
*/
canvas : {
get : function() {
return this._canvas;
}
},
/**
* The drawingBufferWidth of the underlying GL context.
* @memberof Scene.prototype
*
* @type {Number}
* @readonly
*
* @see {@link https://www.khronos.org/registry/webgl/specs/1.0/#DOM-WebGLRenderingContext-drawingBufferWidth|drawingBufferWidth}
*/
drawingBufferHeight : {
get : function() {
return this._context.drawingBufferHeight;
}
},
/**
* The drawingBufferHeight of the underlying GL context.
* @memberof Scene.prototype
*
* @type {Number}
* @readonly
*
* @see {@link https://www.khronos.org/registry/webgl/specs/1.0/#DOM-WebGLRenderingContext-drawingBufferHeight|drawingBufferHeight}
*/
drawingBufferWidth : {
get : function() {
return this._context.drawingBufferWidth;
}
},
/**
* The maximum aliased line width, in pixels, supported by this WebGL implementation. It will be at least one.
* @memberof Scene.prototype
*
* @type {Number}
* @readonly
*
* @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with <code>ALIASED_LINE_WIDTH_RANGE</code>.
*/
maximumAliasedLineWidth : {
get : function() {
return ContextLimits.maximumAliasedLineWidth;
}
},
/**
* The maximum length in pixels of one edge of a cube map, supported by this WebGL implementation. It will be at least 16.
* @memberof Scene.prototype
*
* @type {Number}
* @readonly
*
* @see {@link https://www.khronos.org/opengles/sdk/docs/man/xhtml/glGet.xml|glGet} with <code>GL_MAX_CUBE_MAP_TEXTURE_SIZE</code>.
*/
maximumCubeMapSize : {
get : function() {
return ContextLimits.maximumCubeMapSize;
}
},
/**
* Returns true if the pickPosition function is supported.
* @memberof Scene.prototype
*
* @type {Boolean}
* @readonly
*/
pickPositionSupported : {
get : function() {
return this._context.depthTexture;
}
},
/**
* Gets or sets the depth-test ellipsoid.
* @memberof Scene.prototype
*
* @type {Globe}
*/
globe : {
get: function() {
return this._globe;
},
set: function(globe) {
this._globe = this._globe && this._globe.destroy();
this._globe = globe;
}
},
/**
* Gets the collection of primitives.
* @memberof Scene.prototype
*
* @type {PrimitiveCollection}
* @readonly
*/
primitives : {
get : function() {
return this._primitives;
}
},
/**
* Gets the collection of ground primitives.
* @memberof Scene.prototype
*
* @type {PrimitiveCollection}
* @readonly
*/
groundPrimitives : {
get : function() {
return this._groundPrimitives;
}
},
/**
* Gets the camera.
* @memberof Scene.prototype
*
* @type {Camera}
* @readonly
*/
camera : {
get : function() {
return this._camera;
}
},
// TODO: setCamera
/**
* Gets the controller for camera input handling.
* @memberof Scene.prototype
*
* @type {ScreenSpaceCameraController}
* @readonly
*/
screenSpaceCameraController : {
get : function() {
return this._screenSpaceCameraController;
}
},
/**
* Get the map projection to use in 2D and Columbus View modes.
* @memberof Scene.prototype
*
* @type {MapProjection}
* @readonly
*
* @default new GeographicProjection()
*/
mapProjection : {
get: function() {
return this._mapProjection;
}
},
/**
* Gets state information about the current scene. If called outside of a primitive's <code>update</code>
* function, the previous frame's state is returned.
* @memberof Scene.prototype
*
* @type {FrameState}
* @readonly
*
* @private
*/
frameState : {
get: function() {
return this._frameState;
}
},
/**
* Gets the collection of tweens taking place in the scene.
* @memberof Scene.prototype
*
* @type {TweenCollection}
* @readonly
*
* @private
*/
tweens : {
get : function() {
return this._tweens;
}
},
/**
* Gets the collection of image layers that will be rendered on the globe.
* @memberof Scene.prototype
*
* @type {ImageryLayerCollection}
* @readonly
*/
imageryLayers : {
get : function() {
if (!defined(this.globe)) {
return undefined;
}
return this.globe.imageryLayers;
}
},
/**
* The terrain provider providing surface geometry for the globe.
* @memberof Scene.prototype
*
* @type {TerrainProvider}
*/
terrainProvider : {
get : function() {
if (!defined(this.globe)) {
return undefined;
}
return this.globe.terrainProvider;
},
set : function(terrainProvider) {
if (defined(this.globe)) {
this.globe.terrainProvider = terrainProvider;
}
}
},
/**
* Gets an event that's raised when the terrain provider is changed
* @memberof Scene.prototype
*
* @type {Event}
* @readonly
*/
terrainProviderChanged : {
get : function() {
if (!defined(this.globe)) {
return undefined;
}
return this.globe.terrainProviderChanged;
}
},
/**
* Gets the event that will be raised when an error is thrown inside the <code>render</code> function.
* The Scene instance and the thrown error are the only two parameters passed to the event handler.
* By default, errors are not rethrown after this event is raised, but that can be changed by setting
* the <code>rethrowRenderErrors</code> property.
* @memberof Scene.prototype
*
* @type {Event}
* @readonly
*/
renderError : {
get : function() {
return this._renderError;
}
},
/**
* Gets the event that will be raised at the start of each call to <code>render</code>. Subscribers to the event
* receive the Scene instance as the first parameter and the current time as the second parameter.