Skip to content

Commit

Permalink
Remove WorldWindow dependency from Camera. Move transformations betwe…
Browse files Browse the repository at this point in the history
…en Camera and LookAt to WorldWindow.
  • Loading branch information
ComBatVision committed Sep 11, 2022
1 parent 834910e commit c47deb1
Show file tree
Hide file tree
Showing 21 changed files with 313 additions and 370 deletions.
2 changes: 1 addition & 1 deletion apps/Explorer/Explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ define(['../../src/WorldWind',
var lookAt = new WorldWind.LookAt();
lookAt.position.latitude = 30;
lookAt.position.longitude = -(180 / 12) * ((new Date()).getTimezoneOffset() / 60);
this.wwd.camera.setFromLookAt(lookAt);
this.wwd.cameraFromLookAt(lookAt);

this.goToBox = new GoToBox(this.wwd);
this.layersPanel = new LayersPanel(this.wwd);
Expand Down
2 changes: 1 addition & 1 deletion apps/NEO/NEO.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ define(['../../src/WorldWind',
var lookAt = new WorldWind.LookAt();
lookAt.position.latitude = 30;
lookAt.position.longitude = -(180 / 12) * ((new Date()).getTimezoneOffset() / 60);
this.wwd.camera.setFromLookAt(lookAt);
this.wwd.cameraFromLookAt(lookAt);

this.timeSeriesPlayer = new TimeSeriesPlayer(this.wwd);
this.projectionMenu = new ProjectionMenu(this.wwd);
Expand Down
2 changes: 1 addition & 1 deletion apps/SentinelWMTS/SentinelWMTS.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ define(['../../src/WorldWind',
lookAt.position.latitude = 48.86;
lookAt.position.longitude = 2.37;
lookAt.range = 5e4;
this.wwd.camera.setFromLookAt(lookAt);
this.wwd.cameraFromLookAt(lookAt);

// Create controllers for the user interface elements.
new GoToBox(wwd);
Expand Down
2 changes: 1 addition & 1 deletion apps/SubSurface/SubSurface.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ define(['../../src/WorldWind',
var lookAt = new WorldWind.LookAt();
lookAt.position.latitude = 30;
lookAt.position.longitude = -(180 / 12) * ((new Date()).getTimezoneOffset() / 60);
this.wwd.camera.setFromLookAt(lookAt);
this.wwd.cameraFromLookAt(lookAt);

this.goToBox = new GoToBox(this.wwd);
this.layersPanel = new LayersPanel(this.wwd);
Expand Down
2 changes: 1 addition & 1 deletion apps/USGSSlabs/USGSSlabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ define(['../../src/WorldWind',
var lookAt = new WorldWind.LookAt();
lookAt.position.latitude = 30;
lookAt.position.longitude = -(180 / 12) * ((new Date()).getTimezoneOffset() / 60);
this.wwd.camera.setFromLookAt(lookAt);
this.wwd.cameraFromLookAt(lookAt);

// Establish the shapes and the controllers to handle picking.
this.setupPicking();
Expand Down
2 changes: 1 addition & 1 deletion apps/USGSWells/USGSWells.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ define(['../../src/WorldWind',
lookAt.range = 1400;
lookAt.heading = 90;
lookAt.tilt = 60;
this.wwd.camera.setFromLookAt(lookAt);
this.wwd.cameraFromLookAt(lookAt);

// Establish the shapes and the controllers to handle picking.
this.setupPicking();
Expand Down
2 changes: 1 addition & 1 deletion examples/Canyon.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ requirejs(['./WorldWindShim'],
var wwd = new WorldWind.WorldWindow("canvasOne");
var camera = wwd.camera;
var lookAt = new WorldWind.LookAt();
camera.getAsLookAt(lookAt);
wwd.cameraAsLookAt(lookAt);
var layers = [
{layer: new WorldWind.BMNGLayer(), enabled: true},
{layer: new WorldWind.BingAerialWithLabelsLayer(null), enabled: true},
Expand Down
10 changes: 5 additions & 5 deletions examples/Views.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ requirejs(['./WorldWindShim',
var wwd = new WorldWind.WorldWindow("canvasOne");
var camera = wwd.camera;
var lookAt = new WorldWind.LookAt();
camera.getAsLookAt(lookAt);
wwd.cameraAsLookAt(lookAt);
var layers = [
{layer: new WorldWind.BMNGLayer(), enabled: true},
{layer: new WorldWind.BingAerialWithLabelsLayer(null), enabled: true},
Expand Down Expand Up @@ -127,7 +127,7 @@ requirejs(['./WorldWindShim',
rangeSlider.slider("disable");
altitudeSlider.slider("enable");
} else {
camera.getAsLookAt(lookAt);
wwd.cameraAsLookAt(lookAt);
pos = lookAt.position;
view = lookAt;
rangeSlider.slider("enable");
Expand All @@ -138,7 +138,7 @@ requirejs(['./WorldWindShim',
pos = camera.position;
view = camera;
} else {
camera.getAsLookAt(lookAt);
wwd.cameraAsLookAt(lookAt);
pos = lookAt.position;
view = lookAt;
}
Expand All @@ -150,7 +150,7 @@ requirejs(['./WorldWindShim',
view.roll = rollSlider.slider("value");
if (selectedViewType === "LookAt") {
lookAt.range = rangeSlider.slider("value");
camera.setFromLookAt(lookAt);
wwd.cameraFromLookAt(lookAt);
}
}
updateControls(pos, view);
Expand All @@ -159,7 +159,7 @@ requirejs(['./WorldWindShim',

window.setInterval(function () {
var pos, view;
camera.getAsLookAt(lookAt);
wwd.cameraAsLookAt(lookAt);
if (currentViewType === "Camera") {
pos = camera.position;
view = camera;
Expand Down
2 changes: 1 addition & 1 deletion performance/DeepPickingPerformance.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ requirejs(['../src/WorldWind',
var lookAt = new WorldWind.LookAt();
lookAt.position = new WorldWind.Position(44.2, -94.12, 0);
lookAt.range = 625000;
wwd.camera.setFromLookAt(lookAt);
wwd.cameraFromLookAt(lookAt);

// Satellite image footprints
var footprints = [];
Expand Down
24 changes: 12 additions & 12 deletions src/BasicWorldWindowController.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ define([
lookAt.position.longitude += forwardDegrees * sinHeading + sideDegrees * cosHeading;
this.lastPoint.set(tx, ty);
this.applyLookAtLimits(lookAt);
this.wwd.camera.setFromLookAt(lookAt);
this.wwd.cameraFromLookAt(lookAt);
this.wwd.redraw();
}
};
Expand Down Expand Up @@ -295,7 +295,7 @@ define([

// Transform the original view's modelview matrix to account for the gesture's change.
var modelview = Matrix.fromIdentity();
lookAt.computeViewingTransform(globe, modelview);
this.wwd.lookAtToViewingTransform(lookAt, modelview);
modelview.multiplyByTranslation(point2[0] - point1[0], point2[1] - point1[1], point2[2] - point1[2]);

// Compute the globe point at the screen center from the perspective of the transformed view.
Expand All @@ -314,7 +314,7 @@ define([
lookAt.tilt = params.tilt;
lookAt.roll = params.roll;
this.applyLookAtLimits(lookAt);
this.wwd.camera.setFromLookAt(lookAt);
this.wwd.cameraFromLookAt(lookAt);
this.wwd.redraw();
}
};
Expand All @@ -338,7 +338,7 @@ define([
lookAt.heading = this.beginLookAt.heading + headingDegrees;
lookAt.tilt = this.beginLookAt.tilt + tiltDegrees;
this.applyLookAtLimits(lookAt);
this.wwd.camera.setFromLookAt(lookAt);
this.wwd.cameraFromLookAt(lookAt);
this.wwd.redraw();
}
};
Expand All @@ -357,7 +357,7 @@ define([
var lookAt = this.lookAt;
lookAt.range = this.beginLookAt.range / scale;
this.applyLookAtLimits(lookAt);
this.wwd.camera.setFromLookAt(lookAt);
this.wwd.cameraFromLookAt(lookAt);
this.wwd.redraw();
}
}
Expand All @@ -379,7 +379,7 @@ define([
lookAt.heading -= rotation - this.lastRotation;
this.lastRotation = rotation;
this.applyLookAtLimits(lookAt);
this.wwd.camera.setFromLookAt(lookAt);
this.wwd.cameraFromLookAt(lookAt);
this.wwd.redraw();
}
};
Expand All @@ -399,14 +399,14 @@ define([
var lookAt = this.lookAt;
lookAt.tilt = this.beginTilt + tiltDegrees;
this.applyLookAtLimits(lookAt);
this.wwd.camera.setFromLookAt(lookAt);
this.wwd.cameraFromLookAt(lookAt);
this.wwd.redraw();
}
};

// Intentionally not documented.
BasicWorldWindowController.prototype.handleWheelEvent = function (event) {
var lookAt = this.wwd.camera.getAsLookAt(this.lookAt);
var lookAt = this.wwd.cameraAsLookAt(this.lookAt);
// Normalize the wheel delta based on the wheel delta mode. This produces a roughly consistent delta across
// browsers and input devices.
var normalizedDelta;
Expand All @@ -426,7 +426,7 @@ define([
// Apply the scale to this view's properties.
lookAt.range *= scale;
this.applyLookAtLimits(lookAt);
this.wwd.camera.setFromLookAt(lookAt);
this.wwd.cameraFromLookAt(lookAt);
this.wwd.redraw();
};

Expand Down Expand Up @@ -470,9 +470,9 @@ define([
* @ignore
*/
BasicWorldWindowController.prototype.applyLimits = function () {
var lookAt = this.wwd.camera.getAsLookAt(this.lookAt);
var lookAt = this.wwd.cameraAsLookAt(this.lookAt);
this.applyLookAtLimits(lookAt);
this.wwd.camera.setFromLookAt(lookAt);
this.wwd.cameraFromLookAt(lookAt);
};

/**
Expand All @@ -481,7 +481,7 @@ define([
* @ignore
*/
BasicWorldWindowController.prototype.gestureDidBegin = function () {
this.wwd.camera.getAsLookAt(this.beginLookAt);
this.wwd.cameraAsLookAt(this.beginLookAt);
this.lookAt.copy(this.beginLookAt);
};

Expand Down
Loading

0 comments on commit c47deb1

Please sign in to comment.