-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPerspectiveCamera.js
More file actions
44 lines (33 loc) · 997 Bytes
/
PerspectiveCamera.js
File metadata and controls
44 lines (33 loc) · 997 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
Copyright 2017 Marcel Greter
https://www.github.com/mgreter
*/
// private scope
(function (THREE, THREEAPP)
{
"use strict";
var PerspectiveCamera = THREEAPP.Class.create('PerspectiveCamera', null, ['Plugin'])
.proto('provides', 'camera')
.ctor(function (app)
{
// http://threejs.org/docs/#Reference/Cameras/PerspectiveCamera
app.camera = new THREE.PerspectiveCamera(
this.options.fov || 65,
( app.width / app.height ),
this.options.near || 1e-6,
this.options.far || 1e20
);
// add delta offset to avoid some bugs
app.camera.position.x = 0.00000000001;
// update whenever app is resized
app.listen('resized', function () {
// update camera aspect ratio and projection
app.camera.aspect = app.width / app.height;
app.camera.updateProjectionMatrix();
});
})
;
// assign class to global namespace
THREEAPP('Plugin.PerspectiveCamera', PerspectiveCamera);
// EO private scope
})(THREE, THREEAPP);