diff --git a/index.html b/index.html index 8f9e004..04fa979 100644 --- a/index.html +++ b/index.html @@ -30,8 +30,7 @@ - - + - - - - - - - - - - - - - + + + - - - - - + - - - - - - - - - - - - @@ -343,6 +195,8 @@ AFRAME.registerComponent('warmup', { + + + diff --git a/jxr.js b/jxr.js index 1737496..d656763 100644 --- a/jxr.js +++ b/jxr.js @@ -1202,7 +1202,7 @@ function addNewNote( text, position=`-0.2 1.1 -0.1`, scale= "0.1 0.1 0.1", id=nu if (id) newnote.id = id else - newnote.id = "note_" + Date.now() // not particularly descriptive but content might change later on + newnote.id = "note_" + crypto.randomUUID() // not particularly descriptive but content might change later on if (classes) newnote.className += classes newnote.setAttribute("side", "double" ) @@ -3413,7 +3413,7 @@ function thumbToIndexAngle(){ console.log( 'r' ) p.emit('thumb2indexpush') // could insert (with max threshold) a targe entity between tip and thumb - // this entity could then ondrop add a new post it note or jxr element + // this entity could then ondrop (now onreleased) add a new post it note or jxr element } // could also check angle against head to insure it's facing the user }, 590) @@ -3709,33 +3709,25 @@ AFRAME.registerComponent('gltf-jxr', { */ }); -function setOnDropFromAttribute(){ - // add to file descriptor from offtopus - // could also be prototyped with a URL instead, doesn't need offtopus even cached version - // could also prototype by doing so via https://webdav.benetou.fr/fot-demo-day/mobydick-extract.txt - console.log('setOnDropFromAttribute') - targets.map( el => { - if ( el.getAttribute('ondrop')?.length > 0 ) - el.addEventListener('released', e => { - let code = el.getAttribute('ondrop') - console.log('do', code) - try { - eval( code ) - } catch (error) { - console.error(`Evaluation failed with ${error}`); - } - }) - } ) - // if dropped close enough to an editor, load file content in editor - // could try a jxr command... -} +// avoiding setOnDropFromAttribute() as it is not idiosyncratic and creates timing issues +AFRAME.registerComponent('onreleased', { // changed from ondrop to be coherent with event name + events: { + released: function (e) { + let code = this.el.getAttribute('onreleased') + try { + eval( code ) + } catch (error) { + console.error(`Evaluation failed with ${error}`); + } + } + } +}) // used for testing, now that jxr.js is outside of index.html, could consider putting this back in index.html instead to keep behavior one would expect from a library // does indeed create problems, namely other pages relying on it do get this testing behavior AFRAME.registerComponent('startfunctions', { init: function () { console.log('startfunctions') - setOnDropFromAttribute() /* class clonableasset : Crystal.glb Fish.glb Mountains.glb Penguin.glb Pinetree.glb consider also backend needed for caching