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