Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x 913x | import SceneMode from "./SceneMode.js";
/**
* State information about the current frame. An instance of this class
* is provided to update functions.
*
* @param {Context} context The rendering context
* @param {CreditDisplay} creditDisplay Handles adding and removing credits from an HTML element
* @param {JobScheduler} jobScheduler The job scheduler
*
* @alias FrameState
* @constructor
*
* @private
*/
function FrameState(context, creditDisplay, jobScheduler) {
/**
* The rendering context.
*
* @type {Context}
*/
this.context = context;
/**
* An array of rendering commands.
*
* @type {DrawCommand[]}
*/
this.commandList = [];
/**
* An array of shadow maps.
* @type {ShadowMap[]}
*/
this.shadowMaps = [];
/**
* The BRDF look up texture generator used for image-based lighting for PBR models
* @type {BrdfLutGenerator}
*/
this.brdfLutGenerator = undefined;
/**
* The environment map used for image-based lighting for PBR models
* @type {CubeMap}
*/
this.environmentMap = undefined;
/**
* The spherical harmonic coefficients used for image-based lighting for PBR models.
* @type {Cartesian3[]}
*/
this.sphericalHarmonicCoefficients = undefined;
/**
* The specular environment atlas used for image-based lighting for PBR models.
* @type {Texture}
*/
this.specularEnvironmentMaps = undefined;
/**
* The maximum level-of-detail of the specular environment atlas used for image-based lighting for PBR models.
* @type {number}
*/
this.specularEnvironmentMapsMaximumLOD = undefined;
/**
* The current mode of the scene.
*
* @type {SceneMode}
* @default {@link SceneMode.SCENE3D}
*/
this.mode = SceneMode.SCENE3D;
/**
* 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}
*/
this.morphTime = SceneMode.getMorphTime(SceneMode.SCENE3D);
/**
* The current frame number.
*
* @type {number}
* @default 0
*/
this.frameNumber = 0;
/**
* <code>true</code> if a new frame has been issued and the frame number has been updated.
*
* @type {boolean}
* @default false
*/
this.newFrame = false;
/**
* The scene's current time.
*
* @type {JulianDate}
* @default undefined
*/
this.time = undefined;
/**
* The job scheduler.
*
* @type {JobScheduler}
*/
this.jobScheduler = jobScheduler;
/**
* The map projection to use in 2D and Columbus View modes.
*
* @type {MapProjection}
* @default undefined
*/
this.mapProjection = undefined;
/**
* The current camera.
*
* @type {Camera}
* @default undefined
*/
this.camera = undefined;
/**
* Whether the camera is underground.
*
* @type {boolean}
* @default false
*/
this.cameraUnderground = false;
/**
* The {@link GlobeTranslucencyState} object used by the scene.
*
* @type {GlobeTranslucencyState}
* @default undefined
*/
this.globeTranslucencyState = undefined;
/**
* The culling volume.
*
* @type {CullingVolume}
* @default undefined
*/
this.cullingVolume = undefined;
/**
* The current occluder.
*
* @type {Occluder}
* @default undefined
*/
this.occluder = undefined;
/**
* The maximum screen-space error used to drive level-of-detail refinement. Higher
* values will provide better performance but lower visual quality.
*
* @type {number}
* @default 2
*/
this.maximumScreenSpaceError = undefined;
/**
* Ratio between a pixel and a density-independent pixel. Provides a standard unit of
* measure for real pixel measurements appropriate to a particular device.
*
* @type {number}
* @default 1.0
*/
this.pixelRatio = 1.0;
/**
* @typedef FrameState.Passes
* @type {object}
* @property {boolean} render <code>true</code> if the primitive should update for a render pass, <code>false</code> otherwise.
* @property {boolean} pick <code>true</code> if the primitive should update for a picking pass, <code>false</code> otherwise.
* @property {boolean} pickVoxel <code>true</code> if the primitive should update for a voxel picking pass, <code>false</code> otherwise.
* @property {boolean} depth <code>true</code> if the primitive should update for a depth only pass, <code>false</code> otherwise.
* @property {boolean} postProcess <code>true</code> if the primitive should update for a per-feature post-process pass, <code>false</code> otherwise.
* @property {boolean} offscreen <code>true</code> if the primitive should update for an offscreen pass, <code>false</code> otherwise.
*/
/**
* @type {FrameState.Passes}
*/
this.passes = {
/**
* @default false
*/
render: false,
/**
* @default false
*/
pick: false,
/**
* @default false
*/
pickVoxel: false,
/**
* @default false
*/
depth: false,
/**
* @default false
*/
postProcess: false,
/**
* @default false
*/
offscreen: false,
};
/**
* The credit display.
*
* @type {CreditDisplay}
*/
this.creditDisplay = creditDisplay;
/**
* An array of functions to be called at the end of the frame. This array
* will be cleared after each frame.
* <p>
* This allows queueing up events in <code>update</code> functions and
* firing them at a time when the subscribers are free to change the
* scene state, e.g., manipulate the camera, instead of firing events
* directly in <code>update</code> functions.
* </p>
* <p>
* If any function in the array returns <code>true</code>, in request render mode
* another frame will be rendered.
* </p>
*
* @type {FrameState.AfterRenderCallback[]}
*
* @example
* frameState.afterRender.push(function() {
* // take some action, raise an event, etc.
* });
*/
this.afterRender = [];
/**
* Gets whether or not to optimize for 3D only.
*
* @type {boolean}
* @default false
*/
this.scene3DOnly = false;
/**
* @typedef FrameState.Fog
* @type {object}
* @property {boolean} enabled <code>true</code> if fog is enabled, <code>false</code> otherwise. This affects both fog culling and rendering.
* @property {boolean} renderable <code>true</code> if fog should be rendered, <code>false</code> if not. This flag should be checked in combination with fog.enabled.
* @property {number | undefined} density A positive number used to mix the color and fog color based on camera distance.
* @property {number | undefined} visualDensityScalar A positive number to modify how impactful the fog is based off the density
* @property {number | undefined} sse A scalar used to modify the screen space error of geometry partially in fog.
* @property {number | undefined} minimumBrightness The minimum brightness of terrain with fog applied.
*/
/**
* @type {FrameState.Fog}
*/
this.fog = {
/**
* @default false
*/
enabled: false,
renderable: false,
density: undefined,
visualDensityScalar: undefined,
sse: undefined,
minimumBrightness: undefined,
};
/**
* The current Atmosphere
* @type {Atmosphere}
*/
this.atmosphere = undefined;
/**
* A scalar used to vertically exaggerate the scene
* @type {number}
* @default 1.0
*/
this.verticalExaggeration = 1.0;
/**
* The height relative to which the scene is vertically exaggerated.
* @type {number}
* @default 0.0
*/
this.verticalExaggerationRelativeHeight = 0.0;
/**
* @typedef FrameState.ShadowState
* @type {object}
* @property {boolean} shadowsEnabled Whether there are any active shadow maps this frame.
* @property {boolean} lightShadowsEnabled Whether there are any active shadow maps that originate from light sources. Does not include shadow maps that are used for analytical purposes.
* @property {ShadowMap[]} shadowMaps All shadow maps that are enabled this frame.
* @property {ShadowMap[]} lightShadowMaps Shadow maps that originate from light sources. Does not include shadow maps that are used for analytical purposes. Only these shadow maps will be used to generate receive shadows shaders.
* @property {number} nearPlane The near plane of the scene's frustum commands. Used for fitting cascaded shadow maps.
* @property {number} farPlane The far plane of the scene's frustum commands. Used for fitting cascaded shadow maps.
* @property {number} closestObjectSize The size of the bounding volume that is closest to the camera. This is used to place more shadow detail near the object.
* @property {number} lastDirtyTime The time when a shadow map was last dirty
* @property {boolean} outOfView Whether the shadows maps are out of view this frame
*/
/**
* @type {FrameState.ShadowState}
*/
this.shadowState = {
/**
* @default true
*/
shadowsEnabled: true,
shadowMaps: [],
lightShadowMaps: [],
/**
* @default 1.0
*/
nearPlane: 1.0,
/**
* @default 5000.0
*/
farPlane: 5000.0,
/**
* @default 1000.0
*/
closestObjectSize: 1000.0,
/**
* @default 0
*/
lastDirtyTime: 0,
/**
* @default true
*/
outOfView: true,
};
/**
* The position of the splitter to use when rendering different things on either side of a splitter.
* This value should be between 0.0 and 1.0 with 0 being the far left of the viewport and 1 being the far right of the viewport.
* @type {number}
* @default 0.0
*/
this.splitPosition = 0.0;
/**
* Distances to the near and far planes of the camera frustums
* @type {number[]}
* @default []
*/
this.frustumSplits = [];
/**
* The current scene background color
*
* @type {Color}
*/
this.backgroundColor = undefined;
/**
* The light used to shade the scene.
*
* @type {Light}
*/
this.light = undefined;
/**
* The distance from the camera at which to disable the depth test of billboards, labels and points
* to, for example, prevent clipping against terrain. When set to zero, the depth test should always
* be applied. When less than zero, the depth test should never be applied.
* @type {number}
*/
this.minimumDisableDepthTestDistance = undefined;
/**
* 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 with {@link FrameState#invertClassificationColor}.
* @type {boolean}
* @default false
*/
this.invertClassification = false;
/**
* The highlight color of unclassified 3D Tile geometry when {@link FrameState#invertClassification} is <code>true</code>.
* @type {Color}
*/
this.invertClassificationColor = undefined;
/**
* Whether or not the scene uses a logarithmic depth buffer.
*
* @type {boolean}
* @default false
*/
this.useLogDepth = false;
/**
* Additional state used to update 3D Tilesets.
*
* @type {Cesium3DTilePassState}
*/
this.tilesetPassState = undefined;
/**
* The minimum terrain height out of all rendered terrain tiles. Used to improve culling for objects underneath the ellipsoid but above terrain.
*
* @type {number}
* @default 0.0
*/
this.minimumTerrainHeight = 0.0;
/**
* Whether metadata picking is currently in progress.
*
* This is set to `true` in the `Picking.pickMetadata` function,
* immediately before updating and executing the draw commands,
* and set back to `false` immediately afterwards. It will be
* used to determine whether the metadata picking draw commands
* should be executed, in the `Scene.executeCommand` function.
*
* @type {boolean}
* @default false
*/
this.pickingMetadata = false;
/**
* Metadata picking information.
*
* This describes the metadata property that is supposed to be picked
* in a `Picking.pickMetadata` call.
*
* This is stored in the frame state and in the metadata picking draw
* commands. In the `Scene.updateDerivedCommands` call, it will be
* checked whether the instance that is stored in the frame state
* is different from the one in the draw command, and if necessary,
* the derived commands for metadata picking will be updated based
* on this information.
*
* @type {PickedMetadataInfo|undefined}
*/
this.pickedMetadataInfo = undefined;
/**
* Internal toggle indicating that at least one primitive for this frame requested
* edge visibility rendering (EXT_mesh_primitive_edge_visibility). This allows
* lazy allocation/activation of the edge MRT without storing a Scene reference
* on the frame state (avoids passing entire Scene through internal APIs).
* Set by model pipeline stages when they encounter edge visibility data.
* Consumed by Scene to flip its _enableEdgeVisibility flag.
* @type {boolean}
* @private
*/
this.edgeVisibilityRequested = false;
}
/**
* A function that will be called at the end of the frame.
*
* @callback FrameState.AfterRenderCallback
* @returns {boolean} true if another render should be requested in request render mode
*/
export default FrameState;
|