-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3D Tiles in 2D/CV #4884
Merged
Merged
3D Tiles in 2D/CV #4884
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
aa96644
Initial 3d tiles in 2d. Frustum culling and RTC tiles are broken.
bagnell 343a0e9
Fix RTC in 2D/CV. Frustum culling is still broken.
bagnell dd12045
Compute 2D bounding volumes for each 3D tile and use in frustum culling.
bagnell 32d39db
Remove comment. Dynamic SSE is only for 3D.
bagnell 0964932
Merge branch '3d-tiles' into 3d-tiles-2d
bagnell 3c8b4f0
Fix jsHint.
bagnell 9b6188a
Fix content bounding volume in 2D. Do not pick when morphing.
bagnell b889a8e
Fix distance to bounding sphere.
bagnell a093dc8
Add 2D/CV support for point clouds.
bagnell d3b7707
Fix jsHint error.
bagnell a85a1c6
Fix for RTC center is the origin.
bagnell 1f70717
Add 3D tiles tests for rendering in 2D and CV.
bagnell 7d8efa5
Do not pick while morphing.
bagnell f46ae83
Add one time warning for instanced models in 2D/CV.
bagnell 6b81c81
Merge branch '3d-tiles' into 3d-tiles-2d
bagnell File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -216,7 +216,7 @@ define([ | |
|
||
/** | ||
* Determines whether the tileset casts or receives shadows from each light source. | ||
* | ||
* | ||
* @type {ShadowMode} | ||
* @default ShadowMode.ENABLED | ||
*/ | ||
|
@@ -776,7 +776,7 @@ define([ | |
throw new DeveloperError('The tileset is not loaded. Use Cesium3DTileset.readyPromise or wait for Cesium3DTileset.ready to be true.'); | ||
} | ||
//>>includeEnd('debug'); | ||
|
||
return this._root._boundingVolume; | ||
} | ||
}, | ||
|
@@ -1053,25 +1053,35 @@ define([ | |
} | ||
|
||
function getScreenSpaceError(tileset, geometricError, tile, frameState) { | ||
// TODO: screenSpaceError2D like QuadtreePrimitive.js | ||
if (geometricError === 0.0) { | ||
// Leaf nodes do not have any error so save the computation | ||
return 0.0; | ||
} | ||
|
||
// Avoid divide by zero when viewer is inside the tile | ||
var camera = frameState.camera; | ||
var distance = Math.max(tile.distanceToCamera, CesiumMath.EPSILON7); | ||
var height = frameState.context.drawingBufferHeight; | ||
var sseDenominator = camera.frustum.sseDenominator; | ||
var context = frameState.context; | ||
var height = context.drawingBufferHeight; | ||
|
||
var error = (geometricError * height) / (distance * sseDenominator); | ||
var error; | ||
if (frameState.mode === SceneMode.SCENE2D) { | ||
var frustum = camera.frustum; | ||
var width = context.drawingBufferWidth; | ||
|
||
if (tileset.dynamicScreenSpaceError) { | ||
var density = tileset._dynamicScreenSpaceErrorComputedDensity; | ||
var factor = tileset.dynamicScreenSpaceErrorFactor; | ||
var dynamicError = CesiumMath.fog(distance, density) * factor; | ||
error -= dynamicError; | ||
var pixelSize = Math.max(frustum.top - frustum.bottom, frustum.right - frustum.left) / Math.max(width, height); | ||
error = geometricError / pixelSize; | ||
} else { | ||
// Avoid divide by zero when viewer is inside the tile | ||
var distance = Math.max(tile.distanceToCamera, CesiumMath.EPSILON7); | ||
var sseDenominator = camera.frustum.sseDenominator; | ||
error = (geometricError * height) / (distance * sseDenominator); | ||
|
||
if (tileset.dynamicScreenSpaceError) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we still account for this in CV? What about 2D? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it would make sense in 2D. Maybe CV, but we don't have fog in CV either. |
||
var density = tileset._dynamicScreenSpaceErrorComputedDensity; | ||
var factor = tileset.dynamicScreenSpaceErrorFactor; | ||
var dynamicError = CesiumMath.fog(distance, density) * factor; | ||
error -= dynamicError; | ||
} | ||
} | ||
|
||
return error; | ||
|
@@ -1132,7 +1142,7 @@ define([ | |
function selectTile(tileset, tile, fullyVisible, frameState) { | ||
// There may also be a tight box around just the tile's contents, e.g., for a city, we may be | ||
// zoomed into a neighborhood and can cull the skyscrapers in the root node. | ||
if (tile.contentReady && (fullyVisible || (tile.contentsVisibility(frameState.cullingVolume) !== Intersect.OUTSIDE))) { | ||
if (tile.contentReady && (fullyVisible || (tile.contentsVisibility(frameState) !== Intersect.OUTSIDE))) { | ||
tileset._selectedTiles.push(tile); | ||
tile.selected = true; | ||
|
||
|
@@ -1169,7 +1179,6 @@ define([ | |
} | ||
|
||
var maximumScreenSpaceError = tileset._maximumScreenSpaceError; | ||
var cullingVolume = frameState.cullingVolume; | ||
|
||
tileset._selectedTiles.length = 0; | ||
tileset._selectedTilesToStyle.length = 0; | ||
|
@@ -1196,7 +1205,7 @@ define([ | |
return; | ||
} | ||
|
||
root.visibilityPlaneMask = root.visibility(cullingVolume, CullingVolume.MASK_INDETERMINATE); | ||
root.visibilityPlaneMask = root.visibility(frameState, CullingVolume.MASK_INDETERMINATE); | ||
if (root.visibilityPlaneMask === CullingVolume.MASK_OUTSIDE) { | ||
return; | ||
} | ||
|
@@ -1276,7 +1285,7 @@ define([ | |
if (child.insideViewerRequestVolume(frameState)) { | ||
// Use parent's geometric error with child's box to see if we already meet the SSE | ||
if (getScreenSpaceError(tileset, t.geometricError, child, frameState) > maximumScreenSpaceError) { | ||
child.visibilityPlaneMask = child.visibility(cullingVolume, visibilityPlaneMask); | ||
child.visibilityPlaneMask = child.visibility(frameState, visibilityPlaneMask); | ||
if (isVisible(child.visibilityPlaneMask)) { | ||
if (child.contentUnloaded) { | ||
requestContent(tileset, child, outOfCore); | ||
|
@@ -1344,7 +1353,7 @@ define([ | |
for (k = 0; k < childrenLength; ++k) { | ||
child = children[k]; | ||
if (child.insideViewerRequestVolume(frameState)) { | ||
child.visibilityPlaneMask = child.visibility(frameState.cullingVolume, visibilityPlaneMask); | ||
child.visibilityPlaneMask = child.visibility(frameState, visibilityPlaneMask); | ||
} else { | ||
child.visibilityPlaneMask = CullingVolume.MASK_OUTSIDE; | ||
} | ||
|
@@ -1382,7 +1391,7 @@ define([ | |
child = children[k]; | ||
child.updateTransform(t.computedTransform); | ||
if (child.insideViewerRequestVolume(frameState)) { | ||
child.visibilityPlaneMask = child.visibility(frameState.cullingVolume, visibilityPlaneMask); | ||
child.visibilityPlaneMask = child.visibility(frameState, visibilityPlaneMask); | ||
} else { | ||
child.visibilityPlaneMask = CullingVolume.MASK_OUTSIDE; | ||
} | ||
|
@@ -1736,8 +1745,7 @@ define([ | |
* @exception {DeveloperError} The tileset must be 3D Tiles version 0.0. See https://github.com/AnalyticalGraphicsInc/3d-tiles#spec-status | ||
*/ | ||
Cesium3DTileset.prototype.update = function(frameState) { | ||
// TODO: Support 2D and CV | ||
if (!this.show || !this.ready || (frameState.mode !== SceneMode.SCENE3D)) { | ||
if (!this.show || !this.ready) { | ||
return; | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this from the other 3D Tiles Sandcastle examples.