Better clipping and AO logic
This commit is contained in:
parent
aa6bae2a24
commit
bd20af3ec0
10
js/scene.js
10
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');
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user