MCPcopy
hub / github.com/regl-project/regl / updateCamera

Function updateCamera

example/util/camera.js:62–94  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60 }
61
62 function updateCamera () {
63 var center = cameraState.center
64 var eye = cameraState.eye
65 var up = cameraState.up
66
67 cameraState.theta += dtheta
68 cameraState.phi = clamp(
69 cameraState.phi + dphi,
70 -Math.PI / 2.0,
71 Math.PI / 2.0)
72 cameraState.distance = clamp(
73 cameraState.distance + ddistance,
74 minDistance,
75 maxDistance)
76
77 dtheta = damp(dtheta)
78 dphi = damp(dphi)
79 ddistance = damp(ddistance)
80
81 var theta = cameraState.theta
82 var phi = cameraState.phi
83 var r = Math.exp(cameraState.distance)
84
85 var vf = r * Math.sin(theta) * Math.cos(phi)
86 var vr = r * Math.cos(theta) * Math.cos(phi)
87 var vu = r * Math.sin(phi)
88
89 for (var i = 0; i < 3; ++i) {
90 eye[i] = center[i] + vf * front[i] + vr * right[i] + vu * up[i]
91 }
92
93 lookAt(cameraState.view, eye, center, up)
94 }
95
96 var injectContext = regl({
97 context: Object.assign({}, cameraState, {

Callers 1

setupCameraFunction · 0.85

Calls 3

dampFunction · 0.85
lookAtFunction · 0.85
clampFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…