Lukey
August 17, 2018, 4:59am
1
1. A concise explanation of the problem you’re experiencing.
How to only render the entities in camera view?
I know cesium does this automatically with a 3D tileset.json, is there a quick way to do this with entities?
Only show the entities when camera is in view of them?
I’ve been looking at the cesium occluder but it’s a bit confusing as I don’t know what an occluder is or looks like, google hasn’t helped.
2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
Optimisation purposes
4. The Cesium version you’re using, your operating system and browser.
1.48
omar
August 20, 2018, 1:21pm
2
The Cesium engine already does something like this, see here:
var hasDerivedCommands = defined(derivedCommands.originalCommand);
var needsLogDepthDerivedCommands = useLogDepth && !hasLogDepthDerivedCommands;
var needsHdrCommands = useHdr && !hasHdrCommands;
var needsDerivedCommands = (!useLogDepth || !useHdr) && !hasDerivedCommands;
command.dirty = command.dirty || needsLogDepthDerivedCommands || needsHdrCommands || needsDerivedCommands;
if (command.dirty) {
command.dirty = false;
var shadowMaps = frameState.shadowState.shadowMaps;
var shadowsEnabled = frameState.shadowState.shadowsEnabled;
if (shadowsEnabled && command.castShadows) {
derivedCommands.shadows = ShadowMap.createCastDerivedCommand(shadowMaps, command, shadowsDirty, context, derivedCommands.shadows);
}
if (hasLogDepthDerivedCommands || needsLogDepthDerivedCommands) {
derivedCommands.logDepth = DerivedCommand.createLogDepthCommand(command, context, derivedCommands.logDepth);
updateDerivedCommands(this, derivedCommands.logDepth.command, shadowsDirty);
}
if (hasDerivedCommands || needsDerivedCommands) {
updateDerivedCommands(this, command, shadowsDirty);
Note that it’s not as straightforward as it sounds because:
There isn’t a 1 to 1 correspondence between entities and primitives, since the Entity API is optimized in various ways, sometimes 1 primitive renders multiple entities to reduce draw calls.
Cesium uses a multi-frustum system
Notice how the engine uses the bounding volume to check whether something is visible:
https://github.com/AnalyticalGraphicsInc/cesium/blob/master/Source/Scene/Scene.js#L1695