MCPcopy Index your code
hub / github.com/plotly/plotly.js / calcCameraParams

Function calcCameraParams

stackgl_modules/index.js:19194–19249  ·  view source on GitHub ↗
(scene, isOrtho)

Source from the content-addressed store, hash-verified

19192}
19193
19194function calcCameraParams(scene, isOrtho) {
19195 var bounds = scene.bounds
19196 var cameraParams = scene.cameraParams
19197 var projection = cameraParams.projection
19198 var model = cameraParams.model
19199
19200 var width = scene.gl.drawingBufferWidth
19201 var height = scene.gl.drawingBufferHeight
19202 var zNear = scene.zNear
19203 var zFar = scene.zFar
19204 var fovy = scene.fovy
19205
19206 var r = width / height
19207
19208 if(isOrtho) {
19209 ortho(projection,
19210 -r,
19211 r,
19212 -1,
19213 1,
19214 zNear,
19215 zFar
19216 )
19217 cameraParams._ortho = true
19218 } else {
19219 perspective(projection,
19220 fovy,
19221 r,
19222 zNear,
19223 zFar
19224 )
19225 cameraParams._ortho = false
19226 }
19227
19228 //Compute model matrix
19229 for(var i=0; i<16; ++i) {
19230 model[i] = 0
19231 }
19232 model[15] = 1
19233
19234 var maxS = 0
19235 for(var i=0; i<3; ++i) {
19236 maxS = Math.max(maxS, bounds[1][i] - bounds[0][i])
19237 }
19238
19239 for(var i=0; i<3; ++i) {
19240 if(scene.autoScale) {
19241 model[5*i] = scene.aspect[i] / (bounds[1][i] - bounds[0][i])
19242 } else {
19243 model[5*i] = 1 / maxS
19244 }
19245 if(scene.autoCenter) {
19246 model[12+i] = -model[5*i] * 0.5 * (bounds[0][i] + bounds[1][i])
19247 }
19248 }
19249}
19250
19251

Callers 1

redrawFunction · 0.85

Calls 2

orthoFunction · 0.85
perspectiveFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…