Default clipping planes
This commit is contained in:
30
js/scene.js
30
js/scene.js
@@ -36,7 +36,7 @@ Scene.UI.toggleClipper = function(triggerSelector, targetSelector) {
|
||||
console.log('Clipping target:', event.target);
|
||||
if (event.target.id === 'clipX') {
|
||||
// Clip along X...
|
||||
Scene.addClippingPlane('x', 1);
|
||||
Scene.addClippingPlane('x', -1);
|
||||
}
|
||||
else if (event.target.id === 'clipY') {
|
||||
// Clip along Y...
|
||||
@@ -47,7 +47,6 @@ Scene.UI.toggleClipper = function(triggerSelector, targetSelector) {
|
||||
Scene.addClippingPlane('z', 1);
|
||||
}
|
||||
});
|
||||
//Scene.activateClipper()
|
||||
} else {
|
||||
AppState.clipping.enabled = false;
|
||||
ATON.disableClipPlanes();
|
||||
@@ -87,15 +86,23 @@ Scene.showEdges = function(object) {
|
||||
*/
|
||||
Scene.addClippingPlane = function(axis, orientation = -1) {
|
||||
axis = axis.toLowerCase();
|
||||
// TODO: move to dedicated function!!
|
||||
const defaultPoint = new THREE.Vector3(
|
||||
...config.scene.clipping.defaultPoint
|
||||
);
|
||||
const vector = [
|
||||
axis === 'x' ? orientation : 0,
|
||||
axis === 'y' ? orientation : 0,
|
||||
axis === 'z' ? orientation : 0,
|
||||
];
|
||||
|
||||
// First, add a default clipping plane
|
||||
// at a predefined point (bad?)
|
||||
Scene.activateClipper(vector, defaultPoint);
|
||||
console.log(vector, defaultPoint);
|
||||
|
||||
window.addEventListener('mousedown', event => {
|
||||
// Activate clipping when left-clicking on the scene
|
||||
if (AppState.clipping.enabled && event.buttons === 1) {
|
||||
const vector = [
|
||||
axis === 'x' ? orientation : 0,
|
||||
axis === 'y' ? orientation : 0,
|
||||
axis === 'z' ? orientation : 0,
|
||||
]
|
||||
Scene.activateClipper(vector);
|
||||
}
|
||||
});
|
||||
@@ -106,9 +113,12 @@ Scene.addClippingPlane = function(axis, orientation = -1) {
|
||||
* Activate clipping plane
|
||||
* @param {Number[]} vector - The vector array to direct the plane
|
||||
*/
|
||||
Scene.activateClipper = function(vector) {
|
||||
const point = ATON.getSceneQueriedPoint();
|
||||
Scene.activateClipper = function(vector, point = null) {
|
||||
point ??= ATON.getSceneQueriedPoint();
|
||||
|
||||
if (point) {
|
||||
console.log('Queried point:', point);
|
||||
|
||||
// First remove any existing clipping planes
|
||||
ATON.disableClipPlanes();
|
||||
// Normal of the clipping plane along the Y axis facing down
|
||||
|
||||
Reference in New Issue
Block a user