Skip to content

Commit

Permalink
pickPosition uses globeDepth
Browse files Browse the repository at this point in the history
  • Loading branch information
ggetz committed May 14, 2024
1 parent fd2c9fd commit e9dfea5
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 29 deletions.
7 changes: 1 addition & 6 deletions Apps/Sandcastle/gallery/Picking.html
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,7 @@

const scene = viewer.scene;
if (scene.mode !== Cesium.SceneMode.MORPHING) {
const pickedObject = scene.pick(movement.endPosition);
if (
scene.pickPositionSupported &&
Cesium.defined(pickedObject) &&
pickedObject.id === modelEntity
) {
if (scene.pickPositionSupported) {
const cartesian = viewer.scene.pickPosition(
movement.endPosition
);
Expand Down
5 changes: 3 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
# Change Log

### 1.118
### 1.118 - 2024-06-01

#### @cesium/engine

##### Fixes :wrench:

- Fixed a bug where `scene.pickPosition` returned incorrect results against the globe when `depthTestAgainstTerrain` is `false`. [#4368](https://github.com/CesiumGS/cesium/issues/4368)
- Fixed a bug where `TaskProcessor` worker loading would check the worker module ID rather than the absolute URL when determining if it is cross-origin. [#11833](https://github.com/CesiumGS/cesium/pull/11833)
- Fixed a bug where cross-origin workers would error when loaded with the CommonJS `importScripts` shim instead of an ESM `import`. [#11833](https://github.com/CesiumGS/cesium/pull/11833)

### 1.117
### 1.117 - 2024-05-01

#### @cesium/engine

Expand Down
42 changes: 23 additions & 19 deletions packages/engine/Source/Scene/PickDepth.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import defined from "../Core/defined.js";
import destroyObject from "../Core/destroyObject.js";
import FramebufferManager from "../Renderer/FramebufferManager.js";
import RenderState from "../Renderer/RenderState.js";
import PassThrough from "../Shaders/PostProcessStages/PassThrough.js";
import PassThroughDepth from "../Shaders/PostProcessStages/PassThroughDepth.js";

/**
* @private
Expand Down Expand Up @@ -32,24 +30,30 @@ function updateFramebuffers(pickDepth, context, depthTexture) {

function updateCopyCommands(pickDepth, context, depthTexture) {
if (!defined(pickDepth._copyDepthCommand)) {
// pickDepth._copyDepthCommand = context.createViewportQuadCommand(PassThroughDepth, {
// renderState: RenderState.fromCache(),
// uniformMap: {
// u_depthTexture: function () {
// return pickDepth._textureToCopy;
// },
// },
// owner: pickDepth,
// });
pickDepth._copyDepthCommand = context.createViewportQuadCommand(PassThrough, {
renderState: RenderState.fromCache(),
uniformMap: {
colorTexture: function () {
return pickDepth._textureToCopy;
pickDepth._copyDepthCommand = context.createViewportQuadCommand(
`uniform highp sampler2D colorTexture;
in vec2 v_textureCoordinates;
void main()
{
vec4 globeDepthPacked = texture(czm_globeDepthTexture, v_textureCoordinates);
float globeDepth = czm_unpackDepth(globeDepthPacked);
float depth = texture(colorTexture, v_textureCoordinates).r;
out_FragColor = czm_branchFreeTernary(globeDepth <= 0.0 || globeDepth >= 1.0 || depth < globeDepth && depth > 0.0 && depth < 1.0,
czm_packDepth(depth), globeDepthPacked);
}
`,
{
renderState: RenderState.fromCache(),
uniformMap: {
colorTexture: function () {
return pickDepth._textureToCopy;
},
},
},
owner: pickDepth,
});
owner: pickDepth,
}
);
}

pickDepth._textureToCopy = depthTexture;
Expand Down
3 changes: 1 addition & 2 deletions packages/engine/Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -2688,8 +2688,7 @@ function executeCommands(scene, passState) {
renderTranslucentDepthForPick)
) {
// PERFORMANCE_IDEA: Use MRT to avoid the extra copy.
//const depthStencilTexture = globeDepth.depthStencilTexture;
const depthStencilTexture = globeDepth._copyDepthFramebuffer.getColorTexture();
const depthStencilTexture = globeDepth.depthStencilTexture;
const pickDepth = scene._picking.getPickDepth(scene, index);
pickDepth.update(context, depthStencilTexture);
pickDepth.executeCopyDepth(context, passState);
Expand Down

0 comments on commit e9dfea5

Please sign in to comment.