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

Keep camera position during a morph when duration is 0.0 #3521

Merged
merged 29 commits into from
Mar 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
67953aa
Keep same position/orientation when morphing from 3D to Columbus view.
bagnell Jan 29, 2016
e497bdb
Update 3D to 2D that mostly works.
bagnell Jan 29, 2016
78453f1
Merge branch 'master' into morph
bagnell Feb 1, 2016
8362f2a
Merge branch 'master' into morph
bagnell Feb 1, 2016
0521a81
Update CV to 2D and fix 3D to 2D.
bagnell Feb 1, 2016
bc767d2
Update CV to 3D. WIP.
bagnell Feb 3, 2016
e269e94
Mirror morph from perspective to orthographic projections when doing …
bagnell Feb 3, 2016
22d1f62
Fix end position when morphing from 2D to CV.
bagnell Feb 3, 2016
06dd00c
Remove unnecessary code to set the frustum.
bagnell Feb 3, 2016
62d3f44
Update 2D to 3D.
bagnell Feb 3, 2016
9e56b1b
Remove precomputed camera position and orientation for each scene mode.
bagnell Feb 3, 2016
77d51cf
Fix CV to 3D.
bagnell Feb 3, 2016
6b17b77
Fix 2D to 3D.
bagnell Feb 3, 2016
ae6cde6
Better fix for 2D to 3D (Remove duplicate code).
bagnell Feb 3, 2016
9d63107
Fix picking and billboard collection tests.
bagnell Feb 3, 2016
549b60f
Fix LabelCollection, PointPrimitiveCollection, and SceneTransforms te…
bagnell Feb 4, 2016
988c32e
Fix issue where morphing from 2D to 3D could not be cancelled. Fixes …
bagnell Feb 4, 2016
4ead888
Merge branch 'master' into morph
bagnell Feb 4, 2016
a6c761b
Reduce amount of garbage generated from morphs.
bagnell Feb 4, 2016
532b601
Fix height of camera when using orthographic projection that was caus…
bagnell Feb 4, 2016
0df28c7
Update quadtree primitive to not update tiles during a morph and rend…
bagnell Feb 4, 2016
023df2f
Fix position change when morphing from 2D.
bagnell Feb 5, 2016
3786d18
Have the camera rotate to lokk down at the point intersecting the cam…
bagnell Feb 5, 2016
09c0374
Add rotate camera to top down view to morph from 3D to 2D.
bagnell Feb 5, 2016
cb61b27
Reduce garbage generated during morph.
bagnell Feb 5, 2016
472d512
Merge branch 'master' into morph
bagnell Feb 10, 2016
58d57e5
Revert to morph to fly out but add option to jump straight to the end…
bagnell Feb 10, 2016
0c2833e
Fix error when transitioning from CV to 3D.
bagnell Feb 12, 2016
b0e3a13
Merge branch 'master' into morph
bagnell Feb 17, 2016
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
804 changes: 468 additions & 336 deletions Source/Scene/SceneTransitioner.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Source/Shaders/GlobeVS.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ vec4 getPositionMorphingMode(vec3 position, float height, vec2 textureCoordinate
// This is unlikely to be noticeable, though.
vec3 position3DWC = position + u_center3D;
float yPositionFraction = get2DYPositionFraction(textureCoordinates);
vec4 position2DWC = vec4(0.0, mix(u_tileRectangle.st, u_tileRectangle.pq, vec2(textureCoordinates.x, yPositionFraction)), 1.0);
vec4 position2DWC = vec4(height, mix(u_tileRectangle.st, u_tileRectangle.pq, vec2(textureCoordinates.x, yPositionFraction)), 1.0);
vec4 morphPosition = czm_columbusViewMorph(position2DWC, vec4(position3DWC, 1.0), czm_morphTime);
return czm_modelViewProjection * morphPosition;
}
Expand Down
6 changes: 6 additions & 0 deletions Specs/Scene/BillboardCollectionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ defineSuite([
'Core/loadImage',
'Core/Math',
'Core/NearFarScalar',
'Core/Rectangle',
'Renderer/ContextLimits',
'Scene/HeightReference',
'Scene/HorizontalOrigin',
Expand All @@ -32,6 +33,7 @@ defineSuite([
loadImage,
CesiumMath,
NearFarScalar,
Rectangle,
ContextLimits,
HeightReference,
HorizontalOrigin,
Expand Down Expand Up @@ -1196,6 +1198,10 @@ defineSuite([
orthoFrustum.near = 0.01 * maxRadii;
orthoFrustum.far = 60.0 * maxRadii;

camera.setView({
destination : Rectangle.fromDegrees(-60.0, -60.0, -40.0, 60.0)
});

// Update scene state
scene.morphTo2D(0);
scene.renderForSpecs();
Expand Down
16 changes: 5 additions & 11 deletions Specs/Scene/LabelCollectionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ defineSuite([
'Core/Ellipsoid',
'Core/Math',
'Core/NearFarScalar',
'Core/Rectangle',
'Renderer/ContextLimits',
'Scene/HeightReference',
'Scene/HorizontalOrigin',
Expand All @@ -26,6 +27,7 @@ defineSuite([
Ellipsoid,
CesiumMath,
NearFarScalar,
Rectangle,
ContextLimits,
HeightReference,
HorizontalOrigin,
Expand Down Expand Up @@ -1447,21 +1449,13 @@ defineSuite([
text : 'two'
});

var maxRadii = ellipsoid.maximumRadius;
var orthoFrustum = new OrthographicFrustum();
orthoFrustum.right = maxRadii * Math.PI;
orthoFrustum.left = -orthoFrustum.right;
orthoFrustum.top = orthoFrustum.right;
orthoFrustum.bottom = -orthoFrustum.top;
orthoFrustum.near = 0.01 * maxRadii;
orthoFrustum.far = 60.0 * maxRadii;
camera.setView({
destination : Rectangle.fromDegrees(-60.0, -60.0, -40.0, 60.0)
});

// Update scene state
scene.morphTo2D(0);
scene.renderForSpecs();

camera.frustum = orthoFrustum;

scene.renderForSpecs();
var actual = scene.frameState.commandList[0].boundingVolume;

Expand Down
55 changes: 12 additions & 43 deletions Specs/Scene/PickSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ defineSuite([
var scene;
var primitives;
var camera;
var primitiveRectangle = Rectangle.fromDegrees(-50.0, -50.0, 50.0, 50.0);

beforeAll(function() {
scene = createScene();
Expand Down Expand Up @@ -76,7 +77,7 @@ defineSuite([
var e = new Primitive({
geometryInstances: new GeometryInstance({
geometry: new RectangleGeometry({
rectangle: Rectangle.fromDegrees(-50.0, -50.0, 50.0, 50.0),
rectangle: primitiveRectangle,
vertexFormat: EllipsoidSurfaceAppearance.VERTEX_FORMAT,
ellipsoid: ellipsoid,
granularity: CesiumMath.toRadians(20.0)
Expand Down Expand Up @@ -320,58 +321,26 @@ defineSuite([
});

it('picks in 2D', function() {
var ellipsoid = scene.mapProjection.ellipsoid;
var maxRadii = ellipsoid.maximumRadius;

camera.position = new Cartesian3(0.0, 0.0, 2.0 * maxRadii);
Cartesian3.clone(Cartesian3.UNIT_Z, camera.direction);
Cartesian3.negate(camera.direction, camera.direction);
Cartesian3.negate(Cartesian3.UNIT_X, camera.up);
Cartesian3.clone(Cartesian3.UNIT_Y, camera.right);

var frustum = new OrthographicFrustum();
frustum.right = maxRadii * Math.PI;
frustum.left = -frustum.right;
frustum.top = frustum.right * (scene.drawingBufferHeight / scene.drawingBufferWidth);
frustum.bottom = -frustum.top;
frustum.near = 0.01 * maxRadii;
frustum.far = 60.0 * maxRadii;
camera.frustum = frustum;

scene.mode = SceneMode.SCENE2D;
scene.morphTime = SceneMode.getMorphTime(scene.mode);

camera.setView({
destination : primitiveRectangle
});
scene.morphTo2D(0.0);
var rectangle = createRectangle();
scene.initializeFrame();
var pickedObject = scene.pick(new Cartesian2(0, 0));
expect(pickedObject.primitive).toEqual(rectangle);
scene.morphTo3D(0.0);
});

it('picks in 2D when rotated', function() {
var ellipsoid = scene.mapProjection.ellipsoid;
var maxRadii = ellipsoid.maximumRadius;

camera.position = new Cartesian3(0.0, 0.0, 2.0 * maxRadii);
Cartesian3.clone(Cartesian3.UNIT_Z, camera.direction);
Cartesian3.negate(camera.direction, camera.direction);
Cartesian3.negate(Cartesian3.UNIT_X, camera.up);
Cartesian3.clone(Cartesian3.UNIT_Y, camera.right);

var frustum = new OrthographicFrustum();
frustum.right = maxRadii * Math.PI;
frustum.left = -frustum.right;
frustum.top = frustum.right * (scene.drawingBufferHeight / scene.drawingBufferWidth);
frustum.bottom = -frustum.top;
frustum.near = 0.01 * maxRadii;
frustum.far = 60.0 * maxRadii;
camera.frustum = frustum;

scene.mode = SceneMode.SCENE2D;
scene.morphTime = SceneMode.getMorphTime(scene.mode);

camera.setView({
destination : primitiveRectangle
});
scene.morphTo2D(0.0);
var rectangle = createRectangle();
scene.initializeFrame();
var pickedObject = scene.pick(new Cartesian2(0.0, 0.0));
expect(pickedObject.primitive).toEqual(rectangle);
scene.morphTo3D(0.0);
});
}, 'WebGL');
16 changes: 5 additions & 11 deletions Specs/Scene/PointPrimitiveCollectionSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defineSuite([
'Core/Color',
'Core/Math',
'Core/NearFarScalar',
'Core/Rectangle',
'Scene/OrthographicFrustum',
'Specs/createScene'
], function(
Expand All @@ -17,6 +18,7 @@ defineSuite([
Color,
CesiumMath,
NearFarScalar,
Rectangle,
OrthographicFrustum,
createScene) {
'use strict';
Expand Down Expand Up @@ -781,21 +783,13 @@ defineSuite([
position : Cartesian3.fromDegrees(-50.0, 50.0)
});

var maxRadii = ellipsoid.maximumRadius;
var orthoFrustum = new OrthographicFrustum();
orthoFrustum.right = maxRadii * Math.PI;
orthoFrustum.left = -orthoFrustum.right;
orthoFrustum.top = orthoFrustum.right;
orthoFrustum.bottom = -orthoFrustum.top;
orthoFrustum.near = 0.01 * maxRadii;
orthoFrustum.far = 60.0 * maxRadii;
camera.setView({
destination : Rectangle.fromDegrees(-60.0, -60.0, -40.0, 60.0)
});

// Update scene state
scene.morphTo2D(0);
scene.renderForSpecs();

camera.frustum = orthoFrustum;

scene.renderForSpecs();
var actual = scene.frameState.commandList[0].boundingVolume;

Expand Down
6 changes: 6 additions & 0 deletions Specs/Scene/SceneTransformsSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defineSuite([
'Core/Cartesian3',
'Core/Ellipsoid',
'Core/Math',
'Core/Rectangle',
'Scene/Camera',
'Specs/createScene'
], function(
Expand All @@ -13,6 +14,7 @@ defineSuite([
Cartesian3,
Ellipsoid,
CesiumMath,
Rectangle,
Camera,
createScene) {
'use strict';
Expand Down Expand Up @@ -158,6 +160,10 @@ defineSuite([
});

it('returns correct window position in 2D', function() {
scene.camera.setView({
destination : Rectangle.fromDegrees(-0.000001, -0.000001, 0.000001, 0.000001)
});

// Update scene state
scene.morphTo2D(0);
scene.initializeFrame();
Expand Down