diff --git a/js/scene.js b/js/scene.js index ebc7f67..dee2b05 100644 --- a/js/scene.js +++ b/js/scene.js @@ -68,7 +68,6 @@ Scene.changeLightDirection = function(vector) { Scene.toggleAmbientOcclusion = function(isEnabled) { ATON.FX.togglePass(ATON.FX.PASS_AO, isEnabled); console.log('Ambient occlusion', isEnabled ? 'ON' : 'OFF'); - AppState.ambientOcclusion = isEnabled; } /** @@ -166,6 +165,7 @@ Scene.toggleSettingsPanel = function(triggerId) { 'change', event => { this.toggleAmbientOcclusion(event.target.checked); + AppState.ambientOcclusion = event.target.checked; } ); document.querySelector('#shadowsSwitch').addEventListener( @@ -188,9 +188,11 @@ Scene.UI.toggleClipper = function(triggerSelector) { trigger.addEventListener( 'click', () => { + const aoCurrentState = AppState.ambientOcclusion; if (!AppState.clipping.enabled) { AppState.clipping.enabled = true; trigger.className += ' border border-2 border-white'; + Scene.toggleAmbientOcclusion(false); //Scene.activateClipper() } else { AppState.clipping.enabled = false; @@ -199,6 +201,7 @@ Scene.UI.toggleClipper = function(triggerSelector) { AppState.clipping.helper = null; let noBorder = trigger.className.replace(/ border.*$/g, ''); trigger.className = noBorder; + Scene.toggleAmbientOcclusion(aoCurrentState); } } ); @@ -221,10 +224,12 @@ Scene.init = function() { Scene.toggleContentMenu('menu'); window.addEventListener('mousedown', event => { - // Activate clipping when clicking on the scene + // Activate clipping when left-clicking on the scene if (AppState.clipping.enabled && event.buttons === 1) { const point = ATON.getSceneQueriedPoint(); if (point) { + // First remove any existing clipping planes + ATON.disableClipPlanes(); // Normal of the clipping plane along the Y axis facing down const plane = ATON.addClipPlane(new THREE.Vector3(0, -1, 0), point); // Add a visible plane helper for the clipping plane @@ -282,6 +287,7 @@ Scene.openScene = function(marker) { ATON.setAutoLP(true); Scene.toggleAmbientOcclusion(true); + AppState.ambientOcclusion = true; Scene.UI.toggleClipper('#clipper');