Moved cameras to a separate file

This commit is contained in:
Felipe Martín 2013-05-31 12:03:32 +02:00
parent 81d47e9db9
commit 75352e2929
3 changed files with 45 additions and 43 deletions

View File

@ -0,0 +1,40 @@
#
# CAMERAS
#
orthograpicCamera =
_self: null
_left: 0
_right: 0
_top: 0
_bottom: 0
_near: -1000
_far: 1000
init: (width, height) ->
@_left = width / -2
@_right = width / 2
@_top = height / 2
@_bottom = height / -2
@_near = width * -2
@_far = width * 2
camera = new THREE.OrthographicCamera @_left, @_right, @_top, @_bottom, @_near, @_far
@_self = camera
perspectiveCamera =
_fov: 45
_aspectRatio: 0
_near: 1
_far: 1000
init: (width, height) ->
@_aspectRatio = width / height
camera = new THREE.PerspectiveCamera @_fov, @_aspectRatio, @_near, @_far
camera.position.z = 40
@_self = camera
window.StudioCameras =
orthographicCamera: orthograpicCamera
perspectiveCamera: perspectiveCamera

View File

@ -25,9 +25,9 @@ Studio =
# Callbacks
onCameraChange: (cameraType) ->
if "#{cameraType}Camera" of StudioObjects
if "#{cameraType}Camera" of window.StudioCameras
@_cameraType = cameraType
@camera = StudioObjects["#{cameraType}Camera"].init @width, @height
@camera = window.StudioCameras["#{cameraType}Camera"].init @width, @height
if not @animating
@animate()
@ -89,51 +89,12 @@ Studio =
@light.intensity = 1.6
@scene.add @light
@object = new THREE.Mesh new THREE.CubeGeometry(16, 16, 16), new THREE.MeshNormalMaterial()
#@object = new THREE.Mesh new THREE.CubeGeometry(16, 16, 16), new THREE.MeshNormalMaterial()
@scene.add @object
#@scene.add @object
# /test
@animate()
#
# CAMERAS
#
orthograpicCamera =
_self: null
_left: 0
_right: 0
_top: 0
_bottom: 0
_near: -1000
_far: 1000
init: (width, height) ->
@_left = width / -2
@_right = width / 2
@_top = height / 2
@_bottom = height / -2
@_near = width * -2
@_far = width * 2
camera = new THREE.OrthographicCamera @_left, @_right, @_top, @_bottom, @_near, @_far
@_self = camera
perspectiveCamera =
_fov: 45
_aspectRatio: 0
_near: 1
_far: 1000
init: (width, height) ->
@_aspectRatio = width / height
camera = new THREE.PerspectiveCamera @_fov, @_aspectRatio, @_near, @_far
camera.position.z = 40
@_self = camera
window.Studio = Studio
window.StudioObjects =
'orthographicCamera': orthograpicCamera
'perspectiveCamera': perspectiveCamera

View File

@ -21,6 +21,7 @@
<!-- Handlebars -->
<script type="text/javascript" src="/static/lib/handlebars.1.0.rc4.js"></script>
<!-- Studio -->
<script type="text/javascript" src="/static/js/cameras.js"></script>
<script type="text/javascript" src="/static/js/studio.js"></script>
<script type="text/javascript" src="/static/js/modals.js"></script>
<script defer="defer" type="text/javascript" src="/static/js/loader.js"></script>