From 94472dbc00ee64e0b50c6aa043d12fa9772f99da Mon Sep 17 00:00:00 2001 From: Leon van Kammen Date: Thu, 22 Jun 2023 11:35:30 +0200 Subject: [PATCH] selection bugfix --- dist/xrfragment.aframe.js | 10 ++++++---- dist/xrfragment.three.js | 10 ++++++---- dist/xrfragment.three.module.js | 10 ++++++---- src/3rd/js/three/xrf/predefinedView.js | 10 ++++++---- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/dist/xrfragment.aframe.js b/dist/xrfragment.aframe.js index 950b3c3..0951691 100644 --- a/dist/xrfragment.aframe.js +++ b/dist/xrfragment.aframe.js @@ -1171,12 +1171,14 @@ const updatePredefinedView = (opts) => { const selectionOfInterest = (frag,scene,mesh) => { let id = frag.string + let oldSelection if(!id) return id // important: ignore empty strings - if( mesh.selection ) return mesh + if( mesh.selection ) oldSelection = mesh.selection // Selection of Interest if predefined_view matches object name if( mesh.visible && (id == mesh.name || id.substr(1) == mesh.userData.class) ){ xrf.emit('selection',{...opts,frag}) .then( () => { + console.log("selection event") const margin = 1.2 mesh.scale.multiplyScalar( margin ) mesh.selection = new xrf.THREE.BoxHelper(mesh,0xff00ff) @@ -1187,6 +1189,7 @@ const updatePredefinedView = (opts) => { scene.add(mesh.selection) }) } + return oldSelection } const predefinedView = (frag,scene,mesh) => { @@ -1211,9 +1214,8 @@ const updatePredefinedView = (opts) => { remove.push( selectionOfInterest( v, scene, mesh ) ) predefinedView( v , scene, mesh ) }) - remove.filter( (e) => e ).map( (mesh) => { - scene.remove(mesh.selection) - delete mesh.selection + remove.filter( (e) => e ).map( (selection) => { + scene.remove(selection) }) } diff --git a/dist/xrfragment.three.js b/dist/xrfragment.three.js index 951255f..e18d6f7 100644 --- a/dist/xrfragment.three.js +++ b/dist/xrfragment.three.js @@ -1171,12 +1171,14 @@ const updatePredefinedView = (opts) => { const selectionOfInterest = (frag,scene,mesh) => { let id = frag.string + let oldSelection if(!id) return id // important: ignore empty strings - if( mesh.selection ) return mesh + if( mesh.selection ) oldSelection = mesh.selection // Selection of Interest if predefined_view matches object name if( mesh.visible && (id == mesh.name || id.substr(1) == mesh.userData.class) ){ xrf.emit('selection',{...opts,frag}) .then( () => { + console.log("selection event") const margin = 1.2 mesh.scale.multiplyScalar( margin ) mesh.selection = new xrf.THREE.BoxHelper(mesh,0xff00ff) @@ -1187,6 +1189,7 @@ const updatePredefinedView = (opts) => { scene.add(mesh.selection) }) } + return oldSelection } const predefinedView = (frag,scene,mesh) => { @@ -1211,9 +1214,8 @@ const updatePredefinedView = (opts) => { remove.push( selectionOfInterest( v, scene, mesh ) ) predefinedView( v , scene, mesh ) }) - remove.filter( (e) => e ).map( (mesh) => { - scene.remove(mesh.selection) - delete mesh.selection + remove.filter( (e) => e ).map( (selection) => { + scene.remove(selection) }) } diff --git a/dist/xrfragment.three.module.js b/dist/xrfragment.three.module.js index e98dcb6..16938ad 100644 --- a/dist/xrfragment.three.module.js +++ b/dist/xrfragment.three.module.js @@ -1171,12 +1171,14 @@ const updatePredefinedView = (opts) => { const selectionOfInterest = (frag,scene,mesh) => { let id = frag.string + let oldSelection if(!id) return id // important: ignore empty strings - if( mesh.selection ) return mesh + if( mesh.selection ) oldSelection = mesh.selection // Selection of Interest if predefined_view matches object name if( mesh.visible && (id == mesh.name || id.substr(1) == mesh.userData.class) ){ xrf.emit('selection',{...opts,frag}) .then( () => { + console.log("selection event") const margin = 1.2 mesh.scale.multiplyScalar( margin ) mesh.selection = new xrf.THREE.BoxHelper(mesh,0xff00ff) @@ -1187,6 +1189,7 @@ const updatePredefinedView = (opts) => { scene.add(mesh.selection) }) } + return oldSelection } const predefinedView = (frag,scene,mesh) => { @@ -1211,9 +1214,8 @@ const updatePredefinedView = (opts) => { remove.push( selectionOfInterest( v, scene, mesh ) ) predefinedView( v , scene, mesh ) }) - remove.filter( (e) => e ).map( (mesh) => { - scene.remove(mesh.selection) - delete mesh.selection + remove.filter( (e) => e ).map( (selection) => { + scene.remove(selection) }) } diff --git a/src/3rd/js/three/xrf/predefinedView.js b/src/3rd/js/three/xrf/predefinedView.js index 8b4afb7..bc033f2 100644 --- a/src/3rd/js/three/xrf/predefinedView.js +++ b/src/3rd/js/three/xrf/predefinedView.js @@ -3,12 +3,14 @@ const updatePredefinedView = (opts) => { const selectionOfInterest = (frag,scene,mesh) => { let id = frag.string + let oldSelection if(!id) return id // important: ignore empty strings - if( mesh.selection ) return mesh + if( mesh.selection ) oldSelection = mesh.selection // Selection of Interest if predefined_view matches object name if( mesh.visible && (id == mesh.name || id.substr(1) == mesh.userData.class) ){ xrf.emit('selection',{...opts,frag}) .then( () => { + console.log("selection event") const margin = 1.2 mesh.scale.multiplyScalar( margin ) mesh.selection = new xrf.THREE.BoxHelper(mesh,0xff00ff) @@ -19,6 +21,7 @@ const updatePredefinedView = (opts) => { scene.add(mesh.selection) }) } + return oldSelection } const predefinedView = (frag,scene,mesh) => { @@ -43,9 +46,8 @@ const updatePredefinedView = (opts) => { remove.push( selectionOfInterest( v, scene, mesh ) ) predefinedView( v , scene, mesh ) }) - remove.filter( (e) => e ).map( (mesh) => { - scene.remove(mesh.selection) - delete mesh.selection + remove.filter( (e) => e ).map( (selection) => { + scene.remove(selection) }) }