Move UI logic to Stimulus: toolbar only
This commit is contained in:
28
js/controllers/settings_controller.js
Normal file
28
js/controllers/settings_controller.js
Normal file
@@ -0,0 +1,28 @@
|
||||
import { Controller } from "@hotwired/stimulus"
|
||||
import AppState from "../state.js";
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ['ao', 'shadows'];
|
||||
|
||||
connect() {
|
||||
console.log('#settings controller connected');
|
||||
this.aoTarget.checked = AppState.ambientOcclusion;
|
||||
this.shadowsTarget.checked = AppState.shadows;
|
||||
}
|
||||
/**
|
||||
* Toggle Ambient Occlusion
|
||||
* @param {Event} event
|
||||
*/
|
||||
toggleAO(event) {
|
||||
ATON.FX.togglePass(ATON.FX.PASS_AO, event.target.checked);
|
||||
AppState.ambientOcclusion = event.target.checked;
|
||||
}
|
||||
/**
|
||||
* Toggle shadows
|
||||
* @param {Event} event
|
||||
*/
|
||||
toggleShadows(event) {
|
||||
ATON.toggleShadows(event.target.checked);
|
||||
AppState.shadows = event.target.checked;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user