|
|
|
@ -3388,11 +3388,46 @@ function ontouch(){ |
|
|
|
|
}, 20) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
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 |
|
|
|
|
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... |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function setNearbyEditor(el){ |
|
|
|
|
let pos = el.getAttribute('position') |
|
|
|
|
fetch(el.getAttribute('value')).then( res => res.text() ).then( content => { |
|
|
|
|
console.log( content ) |
|
|
|
|
// assumes plain text |
|
|
|
|
editors.map( ed => { |
|
|
|
|
console.log(ed) |
|
|
|
|
if ( pos.distanceTo( ed.element.getAttribute('position') ) < 1 ) |
|
|
|
|
updateCodeEditorWithContent(ed, content) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// used for testing |
|
|
|
|
AFRAME.registerComponent('startfunctions', { |
|
|
|
|
init: function () { |
|
|
|
|
|
|
|
|
|
ontouch() |
|
|
|
|
addCodeMultipleEditors(1, 'hello world', '', name='editortodropon') |
|
|
|
|
setOnDropFromAttribute() |
|
|
|
|
//ontouch() |
|
|
|
|
//tensionVisualized() |
|
|
|
|
//startExperience() |
|
|
|
|
//doublePinchToScale() |
|
|
|
@ -3472,6 +3507,10 @@ AFRAME.registerComponent('startfunctions', { |
|
|
|
|
|
|
|
|
|
<a-box target position="0 1.65 -0.5" scale="0.01 0.01 0.01"></a-box> |
|
|
|
|
|
|
|
|
|
<a-troika-text anchor=left target ondrop="setNearbyEditor(el)" |
|
|
|
|
value="https://webdav.benetou.fr/fot-demo-day/mobydick-extract.txt" |
|
|
|
|
position=" -0.3 1.65 -.4" rotation="0 90 0" scale="0.1 0.1 0.1"></a-troika-text> |
|
|
|
|
|
|
|
|
|
</a-scene> |
|
|
|
|
</body> |
|
|
|
|
</script> |
|
|
|
|