Files
P42_UI/app/views/visualisers/SpaceView.js
T
2026-06-21 21:09:21 +00:00

70 lines
2.4 KiB
JavaScript

/**
* _ ___ Another
* / |/ (_)______ __ _____
* / / / __(_-</ // (_-<
* /_/|_/_/\__/___/\_, /___/
* /___/
* production !
*
* Licensed under the MIT License:
* This code is free to use and modify,
* as long as the copyright notice and license are kept.
*/
class SpaceView extends WindozDomContent {
constructor() {
super()
Object.assign(this, app.helpers.activeAttributes)
//this.tileMarkup = app.Assets.Store.html['/app/assets/html/mailing/tile.html']
}
DOMContentFocused() {
if(this.wasBlured && this.viewMode === '3D' && this.ttb && this.renderingEngine) {
this.ttb.watchCameraFrustum(this.renderingEngine)
}
this.wasBlured = false
}
DOMContentBlured() {
this.wasBlured = true
if(this.viewMode === '3D' && this.ttb) this.ttb.stopWatchingCameraFrustum()
}
DOMContentLoaded(options) {
this.viewMode = options.mode
this.windowPrefsId = `live.spaceview.${options.mode}`
for(let model in options.models) this[model] = options.models[model]
this.ttb = options.ttb
const components = ui.eicfy(this.el)
this.setupTriggers(components)
this.setupRefs(components)
this.renderingEngine = this.ttb.startRendering(this.outputs.ttbCanvas, options.mode)
if(options.mode === '3D') {
this.ttb.watchCameraFrustum(this.renderingEngine)
}
this.output('settingsMenu',app.Assets.Store.html.spaceViewSetting)
this.outputs.settingsMenu.querySelectorAll('input[type="toggler"]').forEach(el => {
const tog = new InputToggler(el)
if(this.ttb[tog._el.name].layers){
tog.value = this.renderingEngine.camera.layers.test(this.ttb[tog._el.name].layers) ? 'yes' : 'no'
}
tog.onToggle = this.settingsToggle.bind(this)
})
}
settingsToggle(value, object){
if(['grid','axes'].includes(object._el.name)){
const layerId = {'grid':1,'axes':2}[object._el.name]
if(value=='yes'){
this.renderingEngine.camera.layers.enable(layerId)
} else {
this.renderingEngine.camera.layers.disable(layerId)
}
}
//TODO save & restore in prefs
}
}
app.registerClass('SpaceView', SpaceView)