Lame helper plane for clipping
TODO: the visible plane should have its center at the axes origin
This commit is contained in:
parent
c1622799d1
commit
7b556a676c
11
js/scene.js
11
js/scene.js
@ -194,6 +194,8 @@ Scene.UI.toggleClipper = function(triggerSelector) {
|
||||
} else {
|
||||
AppState.clipping.enabled = false;
|
||||
ATON.disableClipPlanes();
|
||||
AppState.root.remove(AppState.clipping.helper);
|
||||
AppState.clipping.helper = null;
|
||||
// Refactor!!
|
||||
document.querySelector(triggerSelector).classList.remove('border-info');
|
||||
document.querySelector(triggerSelector).classList.remove('border-2');
|
||||
@ -218,13 +220,20 @@ Scene.init = function() {
|
||||
// Open settings side panel when clicking on settings btn
|
||||
Scene.toggleSettingsPanel('settings');
|
||||
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);
|
||||
const plane = ATON.addClipPlane(new THREE.Vector3(0, -1, 0), point);
|
||||
// Add a visible plane helper for the clipping plane
|
||||
const helper = new THREE.PlaneHelper(plane, 24, 0xffff00);
|
||||
// Remove any already visbile helper plane
|
||||
if (AppState.clipping.helper !== null) AppState.root.remove(AppState.clipping.helper);
|
||||
AppState.root.add(helper);
|
||||
AppState.clipping.helper = helper;
|
||||
console.log("I'm clipping, baby!");
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ export const AppState = {
|
||||
map : null,
|
||||
clipping : {
|
||||
enabled: false,
|
||||
plane : null,
|
||||
helper : null,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user