Primitive clipping (WIP)
This commit is contained in:
parent
224763bbdf
commit
c1622799d1
25
js/scene.js
25
js/scene.js
@ -179,15 +179,25 @@ Scene.toggleSettingsPanel = function(triggerId) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo Get clipping button from state? Review logic!!
|
||||||
|
* @param {String} triggerSelector
|
||||||
|
*/
|
||||||
Scene.UI.toggleClipper = function(triggerSelector) {
|
Scene.UI.toggleClipper = function(triggerSelector) {
|
||||||
document.querySelector(triggerSelector).addEventListener(
|
document.querySelector(triggerSelector).addEventListener(
|
||||||
'click',
|
'click',
|
||||||
() => {
|
() => {
|
||||||
if (!AppState.clipping.enabled) {
|
if (!AppState.clipping.enabled) {
|
||||||
Scene.activateClipper()
|
AppState.clipping.enabled = true;
|
||||||
|
document.querySelector(triggerSelector).className += ' border border-2 border-info';
|
||||||
|
//Scene.activateClipper()
|
||||||
} else {
|
} else {
|
||||||
AppState.root.remove(AppState.clipping.plane);
|
|
||||||
AppState.clipping.enabled = false;
|
AppState.clipping.enabled = false;
|
||||||
|
ATON.disableClipPlanes();
|
||||||
|
// Refactor!!
|
||||||
|
document.querySelector(triggerSelector).classList.remove('border-info');
|
||||||
|
document.querySelector(triggerSelector).classList.remove('border-2');
|
||||||
|
document.querySelector(triggerSelector).classList.remove('border');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@ -208,6 +218,17 @@ Scene.init = function() {
|
|||||||
// Open settings side panel when clicking on settings btn
|
// Open settings side panel when clicking on settings btn
|
||||||
Scene.toggleSettingsPanel('settings');
|
Scene.toggleSettingsPanel('settings');
|
||||||
Scene.toggleContentMenu('menu');
|
Scene.toggleContentMenu('menu');
|
||||||
|
window.addEventListener('mousedown', event => {
|
||||||
|
// Activate clipping when clicking on the scene
|
||||||
|
if (AppState.clipping.enabled && event.buttons === 1) {
|
||||||
|
const point = ATON.getSceneQueriedPoint();
|
||||||
|
if (point) {
|
||||||
|
// Normal of the clipping plane along the Y axis facing down
|
||||||
|
ATON.addClipPlane(new THREE.Vector3(0, -1, 0), point);
|
||||||
|
console.log("I'm clipping, baby!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @param {String} id - The back-to-map button id
|
* @param {String} id - The back-to-map button id
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user