StackGenVis: Alignment of Data, Algorithms, and Models for Stacking Ensemble Learning Using Performance Metrics https://doi.org/10.1109/TVCG.2020.3030352
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
StackGenVis/frontend/node_modules/3d-view/view.js

122 lines
3.2 KiB

'use strict'
module.exports = createViewController
var createTurntable = require('turntable-camera-controller')
var createOrbit = require('orbit-camera-controller')
var createMatrix = require('matrix-camera-controller')
function ViewController(controllers, mode) {
this._controllerNames = Object.keys(controllers)
this._controllerList = this._controllerNames.map(function(n) {
return controllers[n]
})
this._mode = mode
this._active = controllers[mode]
if(!this._active) {
this._mode = 'turntable'
this._active = controllers.turntable
}
this.modes = this._controllerNames
this.computedMatrix = this._active.computedMatrix
this.computedEye = this._active.computedEye
this.computedUp = this._active.computedUp
this.computedCenter = this._active.computedCenter
this.computedRadius = this._active.computedRadius
}
var proto = ViewController.prototype
var COMMON_METHODS = [
['flush', 1],
['idle', 1],
['lookAt', 4],
['rotate', 4],
['pan', 4],
['translate', 4],
['setMatrix', 2],
['setDistanceLimits', 2],
['setDistance', 2]
]
COMMON_METHODS.forEach(function(method) {
var name = method[0]
var argNames = []
for(var i=0; i<method[1]; ++i) {
argNames.push('a'+i)
}
var code = 'var cc=this._controllerList;for(var i=0;i<cc.length;++i){cc[i].'+method[0]+'('+argNames.join()+')}'
proto[name] = Function.apply(null, argNames.concat(code))
})
proto.recalcMatrix = function(t) {
this._active.recalcMatrix(t)
}
proto.getDistance = function(t) {
return this._active.getDistance(t)
}
proto.getDistanceLimits = function(out) {
return this._active.getDistanceLimits(out)
}
proto.lastT = function() {
return this._active.lastT()
}
proto.setMode = function(mode) {
if(mode === this._mode) {
return
}
var idx = this._controllerNames.indexOf(mode)
if(idx < 0) {
return
}
var prev = this._active
var next = this._controllerList[idx]
var lastT = Math.max(prev.lastT(), next.lastT())
prev.recalcMatrix(lastT)
next.setMatrix(lastT, prev.computedMatrix)
this._active = next
this._mode = mode
//Update matrix properties
this.computedMatrix = this._active.computedMatrix
this.computedEye = this._active.computedEye
this.computedUp = this._active.computedUp
this.computedCenter = this._active.computedCenter
this.computedRadius = this._active.computedRadius
}
proto.getMode = function() {
return this._mode
}
function createViewController(options) {
options = options || {}
var eye = options.eye || [0,0,1]
var center = options.center || [0,0,0]
var up = options.up || [0,1,0]
var limits = options.distanceLimits || [0, Infinity]
var mode = options.mode || 'turntable'
var turntable = createTurntable()
var orbit = createOrbit()
var matrix = createMatrix()
turntable.setDistanceLimits(limits[0], limits[1])
turntable.lookAt(0, eye, center, up)
orbit.setDistanceLimits(limits[0], limits[1])
orbit.lookAt(0, eye, center, up)
matrix.setDistanceLimits(limits[0], limits[1])
matrix.lookAt(0, eye, center, up)
return new ViewController({
turntable: turntable,
orbit: orbit,
matrix: matrix
}, mode)
}