Skip to content

Commit

Permalink
fix issue with clipped models still getting picked
Browse files Browse the repository at this point in the history
  • Loading branch information
likangning93 committed Feb 14, 2018
1 parent cf1b6da commit f7d078e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@

Cesium.knockout.getObservable(viewModel, 'cylinderRadius').subscribe(
function(newValue) {
cylinderRadius = Number.parseFloat(viewModel.cylinderRadius);
cylinderRadius = parseFloat(viewModel.cylinderRadius);
updatePlanes();
}
);
Expand Down
9 changes: 6 additions & 3 deletions Source/Scene/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -1922,6 +1922,10 @@ define([
pickFS = ShaderSource.createPickFragmentShaderSource(fs, 'uniform');
}

if (ClippingPlaneCollection.isSupported()) {
pickFS = modifyShaderForClippingPlanes(pickFS);
}

model._rendererResources.pickPrograms[id] = ShaderProgram.fromCache({
context : context,
vertexShaderSource : pickVS,
Expand Down Expand Up @@ -3728,7 +3732,6 @@ define([
function modifyShaderForClippingPlanes(shader) {
shader = ShaderSource.replaceMain(shader, 'gltf_clip_main');
shader +=
'#define CLIPPING_PLANES_TEXTURE_WIDTH ' + ClippingPlaneCollection.TEXTURE_WIDTH + '\n' +
'uniform vec4 gltf_clippingPlanesLengthRangeUnion; \n' +
'uniform sampler2D gltf_clippingPlanes; \n' +
'uniform vec4 gltf_clippingPlanesEdgeStyle; \n' +
Expand All @@ -3744,11 +3747,11 @@ define([
' float clipDistance; \n' +
' if (clippingPlanesUnionRegions) \n' +
' { \n' +
' clipDistance = czm_discardIfClippedWithUnion(gltf_clippingPlanes, clippingPlanesLength, clippingPlanesRange, CLIPPING_PLANES_TEXTURE_WIDTH, gltf_clippingPlanesMatrix); \n' +
' clipDistance = czm_discardIfClippedWithUnion(gltf_clippingPlanes, clippingPlanesLength, clippingPlanesRange, ' + ClippingPlaneCollection.TEXTURE_WIDTH + ', gltf_clippingPlanesMatrix); \n' +
' } \n' +
' else \n' +
' { \n' +
' clipDistance = czm_discardIfClippedWithIntersect(gltf_clippingPlanes, clippingPlanesLength, clippingPlanesRange, CLIPPING_PLANES_TEXTURE_WIDTH, gltf_clippingPlanesMatrix); \n' +
' clipDistance = czm_discardIfClippedWithIntersect(gltf_clippingPlanes, clippingPlanesLength, clippingPlanesRange, ' + ClippingPlaneCollection.TEXTURE_WIDTH + ', gltf_clippingPlanesMatrix); \n' +
' } \n' +
' \n' +
' vec4 clippingPlanesEdgeColor = vec4(1.0); \n' +
Expand Down

0 comments on commit f7d078e

Please sign in to comment.