-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
PolygonPipeline TextureAtlas Camera2DController CameraColumbusViewController CameraControllerCollection CameraEventHandler CameraFreeLookController Camera Polyline
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
defineSuite([ | ||
'Scene/Camera2DController', | ||
'Scene/Camera', | ||
'Scene/OrthographicFrustum', | ||
'Core/Cartographic2', | ||
'Core/Cartesian3', | ||
'Core/Ellipsoid', | ||
'Core/Math', | ||
'Core/Transforms' | ||
], function( | ||
Camera2DController, | ||
Camera, | ||
OrthographicFrustum, | ||
Cartographic2, | ||
Cartesian3, | ||
Ellipsoid, | ||
CesiumMath, | ||
Transforms) { | ||
"use strict"; | ||
/*global document,describe,it,expect,beforeEach,afterEach*/ | ||
|
||
var position; | ||
var up; | ||
var dir; | ||
var right; | ||
var camera; | ||
var frustum; | ||
var moverate; | ||
var zoomrate; | ||
var controller; | ||
var ellipsoid; | ||
|
||
beforeEach(function() { | ||
ellipsoid = Ellipsoid.getWgs84(); | ||
camera = new Camera(document); | ||
|
||
moverate = 3.0; | ||
zoomrate = 1.0; | ||
position = new Cartesian3(); | ||
up = Cartesian3.getUnitY(); | ||
dir = Cartesian3.getUnitZ().negate(); | ||
right = dir.cross(up); | ||
|
||
frustum = new OrthographicFrustum(); | ||
frustum.near = 1; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
frustum.far = 2; | ||
frustum.left = -2; | ||
frustum.right = 2; | ||
frustum.top = 1; | ||
frustum.bottom = -1; | ||
|
||
camera = new Camera(document); | ||
camera.position = position; | ||
camera.up = up; | ||
camera.direction = dir; | ||
camera.right = right; | ||
camera.frustum = frustum; | ||
|
||
controller = new Camera2DController(document, camera, ellipsoid); | ||
}); | ||
|
||
afterEach(function() { | ||
try { | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
kristiancalhoun
Author
Contributor
|
||
controller = controller && controller.destroy(); | ||
} catch(e) {} | ||
}); | ||
|
||
it("setReferenceFrame", function() { | ||
var transform = Transforms.eastNorthUpToFixedFrame(ellipsoid.cartographicDegreesToCartesian(new Cartographic2(-75.0, 40.0))); | ||
controller.setReferenceFrame(transform, ellipsoid); | ||
expect(controller.getEllipsoid()).toBe(ellipsoid); | ||
expect(controller._camera.transform).toBe(transform); | ||
}); | ||
|
||
it("setEllipsoid", function() { | ||
controller.setEllipsoid(Ellipsoid.getUnitSphere()); | ||
expect(controller.getEllipsoid().equals(Ellipsoid.getUnitSphere())).toEqual(true); | ||
}); | ||
|
||
it("moveUp", function() { | ||
controller.moveUp(moverate); | ||
expect(camera.position.equalsEpsilon(new Cartesian3(0, moverate, 0), CesiumMath.EPSILON10)).toEqual(true); | ||
}); | ||
|
||
it("moveDown", function() { | ||
controller.moveDown(moverate); | ||
expect(camera.position.equalsEpsilon(new Cartesian3(0, -moverate, 0), CesiumMath.EPSILON10)).toEqual(true); | ||
}); | ||
|
||
it("moveRight", function() { | ||
controller.moveRight(moverate); | ||
expect(camera.position.equalsEpsilon(new Cartesian3(moverate, 0, 0), CesiumMath.EPSILON10)).toEqual(true); | ||
}); | ||
|
||
it("moveLeft", function() { | ||
controller.moveLeft(moverate); | ||
expect(camera.position.equalsEpsilon(new Cartesian3(-moverate, 0, 0), CesiumMath.EPSILON10)).toEqual(true); | ||
}); | ||
|
||
it("zoomOut", function() { | ||
controller.zoomOut(zoomrate); | ||
expect(frustum.right).toEqualEpsilon(3, CesiumMath.EPSILON10); | ||
expect(frustum.left).toEqual(-3, CesiumMath.EPSILON10); | ||
expect(frustum.top).toEqual(1.5, CesiumMath.EPSILON10); | ||
expect(frustum.bottom).toEqual(-1.5, CesiumMath.EPSILON10); | ||
}); | ||
|
||
it("zoomIn", function() { | ||
controller.zoomIn(zoomrate); | ||
expect(frustum.right).toEqualEpsilon(1, CesiumMath.EPSILON10); | ||
expect(frustum.left).toEqual(-1, CesiumMath.EPSILON10); | ||
expect(frustum.top).toEqual(0.5, CesiumMath.EPSILON10); | ||
expect(frustum.bottom).toEqual(-0.5, CesiumMath.EPSILON10); | ||
}); | ||
|
||
it("zoomIn throws with null OrthogrphicFrustum properties", function() { | ||
var camera = new Camera(document); | ||
var frustum = new OrthographicFrustum(); | ||
This comment has been minimized.
Sorry, something went wrong.
pjcozzi
Contributor
|
||
camera.frustum = frustum; | ||
var c2dc = new Camera2DController(document, camera, ellipsoid); | ||
expect(function () { | ||
c2dc.zoomIn(moverate); | ||
}).toThrow(); | ||
}); | ||
|
||
it("isDestroyed", function() { | ||
expect(controller.isDestroyed()).toEqual(false); | ||
controller.destroy(); | ||
expect(controller.isDestroyed()).toEqual(true); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
defineSuite([ | ||
'Scene/CameraColumbusViewController', | ||
'Scene/Camera' | ||
], function( | ||
CameraColumbusViewController, | ||
Camera) { | ||
"use strict"; | ||
/*global document,describe,it,expect,beforeEach,afterEach*/ | ||
|
||
var controller; | ||
var camera; | ||
|
||
beforeEach(function() { | ||
camera = new Camera(document); | ||
controller = new CameraColumbusViewController(document, camera); | ||
}); | ||
|
||
afterEach(function() { | ||
try { | ||
controller = controller && controller.destroy(); | ||
} catch(e) {} | ||
}); | ||
|
||
it("isDestroyed", function() { | ||
expect(controller.isDestroyed()).toEqual(false); | ||
controller.destroy(); | ||
expect(controller.isDestroyed()).toEqual(true); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
defineSuite([ | ||
'Scene/CameraControllerCollection', | ||
'Scene/Camera', | ||
'Scene/Camera2DController', | ||
'Scene/CameraFreeLookController', | ||
'Scene/CameraSpindleController', | ||
'Core/Cartographic3', | ||
'Core/Ellipsoid' | ||
], function( | ||
CameraControllerCollection, | ||
Camera, | ||
Camera2DController, | ||
CameraFreeLookController, | ||
CameraSpindleController, | ||
Cartographic3, | ||
Ellipsoid) { | ||
"use strict"; | ||
/*global document,describe,it,expect,beforeEach,afterEach*/ | ||
|
||
var camera; | ||
var collection; | ||
|
||
beforeEach(function() { | ||
camera = new Camera(document); | ||
collection = camera.getControllers(); | ||
}); | ||
|
||
afterEach(function() { | ||
try { | ||
collection = collection && collection.destroy(); | ||
} catch(e) {} | ||
}); | ||
|
||
it("add2D", function() { | ||
expect(function() { | ||
collection.add2D(); | ||
}).not.toThrow(); | ||
expect(collection.getLength()).toEqual(1); | ||
}); | ||
|
||
it("addSpindle", function() { | ||
expect(function() { | ||
collection.addSpindle(); | ||
}).not.toThrow(); | ||
expect(collection.getLength()).toEqual(1); | ||
}); | ||
|
||
it("addFreeLook", function() { | ||
expect(function() { | ||
collection.addFreeLook(); | ||
}).not.toThrow(); | ||
expect(collection.getLength()).toEqual(1); | ||
}); | ||
|
||
it("addColumbusView", function() { | ||
expect(function() { | ||
collection.addColumbusView(); | ||
}).not.toThrow(); | ||
expect(collection.getLength()).toEqual(1); | ||
}); | ||
|
||
it("addFlight", function() { | ||
expect(function() { | ||
collection.addFlight({ | ||
destination : Ellipsoid.getWgs84().cartographicDegreesToCartesian(new Cartographic3(-118.26, 34.19, 100000.0)), // Los Angeles | ||
duration : 4.0 | ||
}); | ||
}).not.toThrow(); | ||
expect(collection.getLength()).toEqual(1); | ||
}); | ||
|
||
it("get throws without index", function() { | ||
expect(function() { | ||
collection.get(); | ||
}).toThrow(); | ||
}); | ||
|
||
it("get", function() { | ||
expect(collection.addSpindle()).toBe(collection.get(0)); | ||
}); | ||
|
||
it("contains", function() { | ||
var spindle = collection.addSpindle(); | ||
expect(collection.contains(spindle)).toEqual(true); | ||
collection.remove(spindle); | ||
expect(collection.contains(spindle)).toEqual(false); | ||
}); | ||
|
||
it("does not contain", function() { | ||
expect(collection.contains(new CameraFreeLookController(document, camera))).toEqual(false); | ||
expect(collection.contains()).toEqual(false); | ||
}); | ||
|
||
it("update", function() { | ||
collection.add2D(); | ||
collection.addColumbusView(); | ||
expect(function() { | ||
collection.update(); | ||
}).not.toThrow(); | ||
expect(collection.getLength()).toEqual(2); | ||
}); | ||
|
||
it("update removes expired controllers", function() { | ||
var flight = collection.addFlight({ | ||
destination : Ellipsoid.getWgs84().cartographicDegreesToCartesian(new Cartographic3(-118.26, 34.19, 100000.0)), // Los Angeles | ||
duration : 4.0 | ||
}); | ||
flight._canceled = true; | ||
expect(collection.getLength()).toEqual(1); | ||
collection.update(); | ||
expect(collection.getLength()).toEqual(0); | ||
}); | ||
|
||
it("remove", function() { | ||
expect(collection.remove(collection.addSpindle())).toEqual(true); | ||
}); | ||
|
||
it("remove returns false without controller", function() { | ||
expect(collection.remove()).toEqual(false); | ||
}); | ||
|
||
it("removeAll", function() { | ||
collection.addSpindle(); | ||
collection.addFreeLook(); | ||
expect(collection.getLength()).toEqual(2); | ||
collection.removeAll(); | ||
expect(collection.getLength()).toEqual(0); | ||
}); | ||
|
||
it("isDestroyed", function() { | ||
expect(collection.isDestroyed()).toEqual(false); | ||
collection.destroy(); | ||
expect(collection.isDestroyed()).toEqual(true); | ||
}); | ||
}); |
This file is inconsistent with numeric values. If a whole number is intended to be floating-point, append a .0 for human readers. Otherwise, leave it alone if a human reader should think of it as an integer.