Fix handling of light direction (hopefully)
This commit is contained in:
@@ -42,6 +42,7 @@ function init () {
|
|||||||
AppState.camera = ATON.Nav._camera;
|
AppState.camera = ATON.Nav._camera;
|
||||||
AppState.renderer = ATON._renderer;
|
AppState.renderer = ATON._renderer;
|
||||||
AppState.shadows = config.scene.shadows;
|
AppState.shadows = config.scene.shadows;
|
||||||
|
AppState.lightDirection = ATON.getMainLightDirection();
|
||||||
|
|
||||||
ATON.Nav.setUserControl(true);
|
ATON.Nav.setUserControl(true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ let AppState = {
|
|||||||
// {id: String, active: Boolean}
|
// {id: String, active: Boolean}
|
||||||
nodes: [],
|
nodes: [],
|
||||||
/**
|
/**
|
||||||
* @property {NormalizedSceneNode[]} normalizedNodes
|
* @type {NormalizedSceneNode[]} normalizedNodes
|
||||||
*/
|
*/
|
||||||
normalizedNodes: [],
|
normalizedNodes: [],
|
||||||
mainNodeId: null,
|
mainNodeId: null,
|
||||||
@@ -28,6 +28,7 @@ let AppState = {
|
|||||||
sceneHasAudio: false,
|
sceneHasAudio: false,
|
||||||
layersMenuBuilt: false,
|
layersMenuBuilt: false,
|
||||||
initialRotation: null,
|
initialRotation: null,
|
||||||
|
lightDirection: [],
|
||||||
camera: null,
|
camera: null,
|
||||||
renderer: null,
|
renderer: null,
|
||||||
ambientOcclusion : true,
|
ambientOcclusion : true,
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
// Global ATON and THREE
|
// Global ATON and THREE
|
||||||
|
|
||||||
|
import AppState from "../state.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @module Environment
|
* @module Environment
|
||||||
*/
|
*/
|
||||||
@@ -28,16 +30,21 @@ export function toggleAmbientOcclusion(isEnabled) {
|
|||||||
* @param {Number} step - The slider's step
|
* @param {Number} step - The slider's step
|
||||||
*/
|
*/
|
||||||
export function createLightSlider(direction, label, range, step) {
|
export function createLightSlider(direction, label, range, step) {
|
||||||
const currentVal = ATON.getMainLightDirection()[direction];
|
const currentVal = AppState.lightDirection[direction];
|
||||||
|
|
||||||
|
console.debug(currentVal);
|
||||||
|
|
||||||
const lightSlider = ATON.UI.createSlider({
|
const lightSlider = ATON.UI.createSlider({
|
||||||
range,
|
range,
|
||||||
label,
|
label,
|
||||||
value: Number.parseFloat(currentVal).toPrecision(1),
|
value: Number.parseFloat(currentVal).toPrecision(2),
|
||||||
oninput: val => {
|
oninput: val => {
|
||||||
const lightDir = ATON.getMainLightDirection();
|
const lightDir = AppState.lightDirection;
|
||||||
|
|
||||||
// Keep existing direction values for the other axes
|
// Keep existing direction values for the other axes
|
||||||
lightDir[direction] = Number.parseFloat(val);
|
lightDir[direction] = Number.parseFloat(val);
|
||||||
changeLightDirection(lightDir);
|
changeLightDirection(lightDir);
|
||||||
|
AppState.lightDirection = lightDir;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user