Better clipping plane activation logic...
This commit is contained in:
parent
54373cfe96
commit
7b53e09524
23
js/scene.js
23
js/scene.js
@ -32,7 +32,8 @@ Scene.showEdges = function(object) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @todo WIP!
|
||||||
|
* Activate clipping plane
|
||||||
*/
|
*/
|
||||||
Scene.activateClipper = function() {
|
Scene.activateClipper = function() {
|
||||||
const geometry = new THREE.PlaneGeometry( 24, 24 );
|
const geometry = new THREE.PlaneGeometry( 24, 24 );
|
||||||
@ -42,9 +43,11 @@ Scene.activateClipper = function() {
|
|||||||
transparent: true,
|
transparent: true,
|
||||||
});
|
});
|
||||||
const plane = new THREE.Mesh( geometry, material );
|
const plane = new THREE.Mesh( geometry, material );
|
||||||
const root = ATON.getRootScene();
|
const root = AppState.root;
|
||||||
console.log(root, plane);
|
console.log(root, plane);
|
||||||
root.add(plane);
|
root.add(plane);
|
||||||
|
AppState.clipping.enabled = true;
|
||||||
|
AppState.clipping.plane = plane;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -155,10 +158,17 @@ Scene.toggleSettingsPanel = function(id) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Scene.UI.showClipper = function(triggerSelector) {
|
Scene.UI.toggleClipper = function(triggerSelector) {
|
||||||
document.querySelector(triggerSelector).addEventListener(
|
document.querySelector(triggerSelector).addEventListener(
|
||||||
'click',
|
'click',
|
||||||
() => Scene.activateClipper()
|
() => {
|
||||||
|
if (!AppState.clipping.enabled) {
|
||||||
|
Scene.activateClipper()
|
||||||
|
} else {
|
||||||
|
AppState.root.remove(AppState.clipping.plane);
|
||||||
|
AppState.clipping.enabled = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,9 +233,10 @@ Scene.openScene = function(marker) {
|
|||||||
ATON.setAutoLP(true);
|
ATON.setAutoLP(true);
|
||||||
Scene.toggleAmbientOcclusion(true);
|
Scene.toggleAmbientOcclusion(true);
|
||||||
|
|
||||||
Scene.UI.showClipper('#clipper');
|
Scene.UI.toggleClipper('#clipper');
|
||||||
|
|
||||||
|
AppState.root = ATON.getRootScene();
|
||||||
}
|
}
|
||||||
//const rootUI = ATON.getRootUI();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Scene;
|
export default Scene;
|
||||||
@ -1,4 +1,6 @@
|
|||||||
export const AppState = {
|
export const AppState = {
|
||||||
|
// The root scene object
|
||||||
|
root: null,
|
||||||
scenes : [
|
scenes : [
|
||||||
{
|
{
|
||||||
id : "salvador",
|
id : "salvador",
|
||||||
@ -8,6 +10,10 @@ export const AppState = {
|
|||||||
ambientOcclusion : true,
|
ambientOcclusion : true,
|
||||||
shadows : true,
|
shadows : true,
|
||||||
map : null,
|
map : null,
|
||||||
|
clipping : {
|
||||||
|
enabled: false,
|
||||||
|
plane : null,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user