Skip to content
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

Made imagerySplitPosition use absolute coordinates #5124

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Apps/Sandcastle/gallery/Imagery Layers Split.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@

// Sync the position of the slider with the split position
var slider = document.getElementById('slider');
viewer.scene.imagerySplitPosition = (slider.offsetLeft) / slider.parentElement.offsetWidth;
viewer.scene.imagerySplitPosition = slider.offsetLeft;

var dragStartX = 0;

Expand All @@ -87,9 +87,15 @@
var slider = document.getElementById('slider');
var splitPosition = (e.clientX - dragStartX) / slider.parentElement.offsetWidth;
slider.style.left = 100.0 * splitPosition + "%";
viewer.scene.imagerySplitPosition = splitPosition;
viewer.scene.imagerySplitPosition = slider.offsetLeft;
}

// Update the slider position each frame to account for window resizing.
viewer.scene.preRender.addEventListener(function(scene, time) {
var slider = document.getElementById('slider');
viewer.scene.imagerySplitPosition = slider.offsetLeft;
});


//Sandcastle_End
Sandcastle.finishedLoading();
Expand Down
2 changes: 1 addition & 1 deletion Source/Renderer/AutomaticUniforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,7 @@ define([

/**
* An automatic GLSL uniform representing the splitter position to use when rendering imagery layers with a splitter.
* This will be in the range 0.0 to 1.0 with 0.0 being the far left of the viewport and 1.0 being the far right of the viewport.
* This will be in pixel coordinates relative to the canvas.
*
* @alias czm_imagerySplitPosition
* @glslUniform
Expand Down
2 changes: 1 addition & 1 deletion Source/Shaders/GlobeFS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ vec4 sampleAndBlend(
float alpha = value.a;

#ifdef APPLY_SPLIT
float splitPosition = czm_imagerySplitPosition * czm_viewport.z;
float splitPosition = czm_imagerySplitPosition;
// Split to the left
if (split < 0.0 && gl_FragCoord.x > splitPosition) {
alpha = 0.0;
Expand Down