selection bugfix

This commit is contained in:
Leon van Kammen 2023-06-22 11:35:30 +02:00
parent bc38f58329
commit 94472dbc00
4 changed files with 24 additions and 16 deletions

View file

@ -1171,12 +1171,14 @@ const updatePredefinedView = (opts) => {
const selectionOfInterest = (frag,scene,mesh) => { const selectionOfInterest = (frag,scene,mesh) => {
let id = frag.string let id = frag.string
let oldSelection
if(!id) return id // important: ignore empty strings 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 // Selection of Interest if predefined_view matches object name
if( mesh.visible && (id == mesh.name || id.substr(1) == mesh.userData.class) ){ if( mesh.visible && (id == mesh.name || id.substr(1) == mesh.userData.class) ){
xrf.emit('selection',{...opts,frag}) xrf.emit('selection',{...opts,frag})
.then( () => { .then( () => {
console.log("selection event")
const margin = 1.2 const margin = 1.2
mesh.scale.multiplyScalar( margin ) mesh.scale.multiplyScalar( margin )
mesh.selection = new xrf.THREE.BoxHelper(mesh,0xff00ff) mesh.selection = new xrf.THREE.BoxHelper(mesh,0xff00ff)
@ -1187,6 +1189,7 @@ const updatePredefinedView = (opts) => {
scene.add(mesh.selection) scene.add(mesh.selection)
}) })
} }
return oldSelection
} }
const predefinedView = (frag,scene,mesh) => { const predefinedView = (frag,scene,mesh) => {
@ -1211,9 +1214,8 @@ const updatePredefinedView = (opts) => {
remove.push( selectionOfInterest( v, scene, mesh ) ) remove.push( selectionOfInterest( v, scene, mesh ) )
predefinedView( v , scene, mesh ) predefinedView( v , scene, mesh )
}) })
remove.filter( (e) => e ).map( (mesh) => { remove.filter( (e) => e ).map( (selection) => {
scene.remove(mesh.selection) scene.remove(selection)
delete mesh.selection
}) })
} }

View file

@ -1171,12 +1171,14 @@ const updatePredefinedView = (opts) => {
const selectionOfInterest = (frag,scene,mesh) => { const selectionOfInterest = (frag,scene,mesh) => {
let id = frag.string let id = frag.string
let oldSelection
if(!id) return id // important: ignore empty strings 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 // Selection of Interest if predefined_view matches object name
if( mesh.visible && (id == mesh.name || id.substr(1) == mesh.userData.class) ){ if( mesh.visible && (id == mesh.name || id.substr(1) == mesh.userData.class) ){
xrf.emit('selection',{...opts,frag}) xrf.emit('selection',{...opts,frag})
.then( () => { .then( () => {
console.log("selection event")
const margin = 1.2 const margin = 1.2
mesh.scale.multiplyScalar( margin ) mesh.scale.multiplyScalar( margin )
mesh.selection = new xrf.THREE.BoxHelper(mesh,0xff00ff) mesh.selection = new xrf.THREE.BoxHelper(mesh,0xff00ff)
@ -1187,6 +1189,7 @@ const updatePredefinedView = (opts) => {
scene.add(mesh.selection) scene.add(mesh.selection)
}) })
} }
return oldSelection
} }
const predefinedView = (frag,scene,mesh) => { const predefinedView = (frag,scene,mesh) => {
@ -1211,9 +1214,8 @@ const updatePredefinedView = (opts) => {
remove.push( selectionOfInterest( v, scene, mesh ) ) remove.push( selectionOfInterest( v, scene, mesh ) )
predefinedView( v , scene, mesh ) predefinedView( v , scene, mesh )
}) })
remove.filter( (e) => e ).map( (mesh) => { remove.filter( (e) => e ).map( (selection) => {
scene.remove(mesh.selection) scene.remove(selection)
delete mesh.selection
}) })
} }

View file

@ -1171,12 +1171,14 @@ const updatePredefinedView = (opts) => {
const selectionOfInterest = (frag,scene,mesh) => { const selectionOfInterest = (frag,scene,mesh) => {
let id = frag.string let id = frag.string
let oldSelection
if(!id) return id // important: ignore empty strings 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 // Selection of Interest if predefined_view matches object name
if( mesh.visible && (id == mesh.name || id.substr(1) == mesh.userData.class) ){ if( mesh.visible && (id == mesh.name || id.substr(1) == mesh.userData.class) ){
xrf.emit('selection',{...opts,frag}) xrf.emit('selection',{...opts,frag})
.then( () => { .then( () => {
console.log("selection event")
const margin = 1.2 const margin = 1.2
mesh.scale.multiplyScalar( margin ) mesh.scale.multiplyScalar( margin )
mesh.selection = new xrf.THREE.BoxHelper(mesh,0xff00ff) mesh.selection = new xrf.THREE.BoxHelper(mesh,0xff00ff)
@ -1187,6 +1189,7 @@ const updatePredefinedView = (opts) => {
scene.add(mesh.selection) scene.add(mesh.selection)
}) })
} }
return oldSelection
} }
const predefinedView = (frag,scene,mesh) => { const predefinedView = (frag,scene,mesh) => {
@ -1211,9 +1214,8 @@ const updatePredefinedView = (opts) => {
remove.push( selectionOfInterest( v, scene, mesh ) ) remove.push( selectionOfInterest( v, scene, mesh ) )
predefinedView( v , scene, mesh ) predefinedView( v , scene, mesh )
}) })
remove.filter( (e) => e ).map( (mesh) => { remove.filter( (e) => e ).map( (selection) => {
scene.remove(mesh.selection) scene.remove(selection)
delete mesh.selection
}) })
} }

View file

@ -3,12 +3,14 @@ const updatePredefinedView = (opts) => {
const selectionOfInterest = (frag,scene,mesh) => { const selectionOfInterest = (frag,scene,mesh) => {
let id = frag.string let id = frag.string
let oldSelection
if(!id) return id // important: ignore empty strings 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 // Selection of Interest if predefined_view matches object name
if( mesh.visible && (id == mesh.name || id.substr(1) == mesh.userData.class) ){ if( mesh.visible && (id == mesh.name || id.substr(1) == mesh.userData.class) ){
xrf.emit('selection',{...opts,frag}) xrf.emit('selection',{...opts,frag})
.then( () => { .then( () => {
console.log("selection event")
const margin = 1.2 const margin = 1.2
mesh.scale.multiplyScalar( margin ) mesh.scale.multiplyScalar( margin )
mesh.selection = new xrf.THREE.BoxHelper(mesh,0xff00ff) mesh.selection = new xrf.THREE.BoxHelper(mesh,0xff00ff)
@ -19,6 +21,7 @@ const updatePredefinedView = (opts) => {
scene.add(mesh.selection) scene.add(mesh.selection)
}) })
} }
return oldSelection
} }
const predefinedView = (frag,scene,mesh) => { const predefinedView = (frag,scene,mesh) => {
@ -43,9 +46,8 @@ const updatePredefinedView = (opts) => {
remove.push( selectionOfInterest( v, scene, mesh ) ) remove.push( selectionOfInterest( v, scene, mesh ) )
predefinedView( v , scene, mesh ) predefinedView( v , scene, mesh )
}) })
remove.filter( (e) => e ).map( (mesh) => { remove.filter( (e) => e ).map( (selection) => {
scene.remove(mesh.selection) scene.remove(selection)
delete mesh.selection
}) })
} }