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 {
|
} else {
|
||||||
AppState.clipping.enabled = false;
|
AppState.clipping.enabled = false;
|
||||||
ATON.disableClipPlanes();
|
ATON.disableClipPlanes();
|
||||||
|
AppState.root.remove(AppState.clipping.helper);
|
||||||
|
AppState.clipping.helper = null;
|
||||||
// Refactor!!
|
// Refactor!!
|
||||||
document.querySelector(triggerSelector).classList.remove('border-info');
|
document.querySelector(triggerSelector).classList.remove('border-info');
|
||||||
document.querySelector(triggerSelector).classList.remove('border-2');
|
document.querySelector(triggerSelector).classList.remove('border-2');
|
||||||
@ -218,13 +220,20 @@ 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 => {
|
window.addEventListener('mousedown', event => {
|
||||||
// Activate clipping when clicking on the scene
|
// Activate clipping when 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) {
|
||||||
// Normal of the clipping plane along the Y axis facing down
|
// 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!");
|
console.log("I'm clipping, baby!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ export const AppState = {
|
|||||||
map : null,
|
map : null,
|
||||||
clipping : {
|
clipping : {
|
||||||
enabled: false,
|
enabled: false,
|
||||||
plane : null,
|
helper : null,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user