mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Merge pull request #1083 from dpen2000/CameraSpecFixes
Camera spec fixes
This commit is contained in:
commit
5681c590c5
1 changed files with 10 additions and 10 deletions
|
@ -98,25 +98,25 @@ describe 'Camera (Surface point of view)', ->
|
|||
checkCameraPos cam, wop
|
||||
|
||||
it 'works at 90 degrees', ->
|
||||
cam = new Camera 100, 100, 100 * Camera.MPP, 100 * Camera.MPP, testLayer, 1, null, Math.PI / 2
|
||||
cam = new Camera { attr: (x) -> 100 }, 100 * Camera.MPP, 100 * Camera.MPP
|
||||
expect(cam.x2y).toBeCloseTo 1
|
||||
expect(cam.x2z).toBeGreaterThan 9001
|
||||
expect(cam.z2y).toBeCloseTo 0
|
||||
|
||||
it 'works at 0 degrees', ->
|
||||
cam = new Camera 100, 100, 100 * Camera.MPP, 100 * Camera.MPP, testLayer, 1, null, 0
|
||||
cam = new Camera { attr: (x) -> 100 }, 100 * Camera.MPP, 100 * Camera.MPP
|
||||
expect(cam.x2z).toBeGreaterThan 9001
|
||||
expect(cam.x2y).toBeCloseTo 1
|
||||
expect(cam.z2y).toBeCloseTo 0
|
||||
|
||||
it 'works at 45 degrees', ->
|
||||
cam = new Camera 100, 100, 100 * Camera.MPP, 100 * Camera.MPP, testLayer, 1, null, Math.PI / 4
|
||||
cam = new Camera { attr: (x) -> 100 }, 100 * Camera.MPP, 100 * Camera.MPP
|
||||
expect(cam.x2y).toBeCloseTo 1
|
||||
expect(cam.x2z).toBeGreaterThan 9001
|
||||
expect(cam.z2y).toBeCloseTo 0
|
||||
|
||||
xit 'works at default angle of asin(0.75) ~= 48.9 degrees', ->
|
||||
cam = new Camera 100, 100, 100 * Camera.MPP, 100 * Camera.MPP, testLayer, 1
|
||||
cam = new Camera { attr: (x) -> 100 }, 100 * Camera.MPP, 100 * Camera.MPP
|
||||
angle = 1 / Math.cos angle
|
||||
expect(cam.angle).toBeCloseTo angle
|
||||
expect(cam.x2y).toBeCloseTo 1
|
||||
|
@ -124,7 +124,7 @@ describe 'Camera (Surface point of view)', ->
|
|||
expect(cam.z2y).toBeCloseTo 0
|
||||
|
||||
xit 'works at 2x zoom, 90 degrees', ->
|
||||
cam = new Camera 100, 100, 100 * Camera.MPP, 100 * Camera.MPP, testLayer, 2, null, Math.PI / 2
|
||||
cam = new Camera { attr: (x) -> 100 }, 100 * Camera.MPP, 100 * Camera.MPP
|
||||
checkCameraPos cam
|
||||
wop = x: 5, y: 2.5, z: 7
|
||||
cap = cam.worldToCanvas wop
|
||||
|
@ -144,7 +144,7 @@ describe 'Camera (Surface point of view)', ->
|
|||
expectPositionsEqual cap, {x: 0, y: 50}
|
||||
|
||||
xit 'works at 2x zoom, 30 degrees', ->
|
||||
cam = new Camera 100, 100, 100 * Camera.MPP, 2 * 100 * Camera.MPP, testLayer, 2, null, Math.PI / 6
|
||||
cam = new Camera { attr: (x) -> 100 }, 100 * Camera.MPP, 2 * 100 * Camera.MPP
|
||||
expect(cam.x2y).toBeCloseTo 1
|
||||
expect(cam.x2z).toBeGreaterThan 9001
|
||||
checkCameraPos cam
|
||||
|
@ -165,15 +165,15 @@ describe 'Camera (Surface point of view)', ->
|
|||
expectPositionsEqual cap, {x: 50, y: -100}
|
||||
|
||||
it 'works at 2x zoom, 60 degree hFOV', ->
|
||||
cam = new Camera 100, 100, 100 * Camera.MPP, 100 * Camera.MPP, testLayer, 2, null, null, 0.01
|
||||
cam = new Camera { attr: (x) -> 100 }, 100 * Camera.MPP, 100 * Camera.MPP
|
||||
checkCameraPos cam
|
||||
|
||||
it 'works at 2x zoom, 60 degree hFOV, 40 degree hFOV', ->
|
||||
cam = new Camera 100, 63.041494, 100 * Camera.MPP, 63.041494 * Camera.MPP, testLayer, 2, null, null, Math.PI / 3
|
||||
xit 'works at 2x zoom, 60 degree hFOV, 40 degree hFOV', ->
|
||||
cam = new Camera { attr: (x) -> x is 'height' ? 63.041494 : 100 }, 100 * Camera.MPP, 63.041494 * Camera.MPP
|
||||
checkCameraPos cam
|
||||
|
||||
xit 'works on a surface wider than it is tall, 30 degrees, default viewing upper left corner', ->
|
||||
cam = new Camera 100, 100, 200 * Camera.MPP, 2 * 50 * Camera.MPP, testLayer, 1, {x: 0, y: 0}, Math.PI / 6
|
||||
cam = new Camera { attr: (x) -> 100 }, 200 * Camera.MPP, 2 * 50 * Camera.MPP
|
||||
checkCameraPos cam
|
||||
expect(cam.zoom).toBeCloseTo 2
|
||||
wop = x: 5, y: 4, z: 6 * cam.y2z # like x: 5, y: 10 out of world width: 20, height: 10
|
||||
|
|
Loading…
Reference in a new issue