twoPosToBox() for blinders and clarified onreleased/onreleased event detail scope

in-situ-instructions
Fabien Benetou 8 months ago
parent eada8885bd
commit b8f56191c8
  1. 36
      index.html
  2. 2
      jxr-core.js

@ -20,9 +20,31 @@ AFRAME.registerComponent('startfunctions', {
let newEl = document.createElement('a-entity') let newEl = document.createElement('a-entity')
newEl.setAttribute('instruction-machine', '') newEl.setAttribute('instruction-machine', '')
AFRAME.scenes[0].appendChild(newEl) AFRAME.scenes[0].appendChild(newEl)
let el = document.createElement('a-sphere')
el.setAttribute('radius', '.01')
el.setAttribute('target', '')
el.setAttribute('position', '0 1 -.5')
AFRAME.scenes[0].appendChild(el)
el.setAttribute("onpicked", "window.pfb = selectedElements.at(-1).element.getAttribute('position').clone();")
el.setAttribute("onreleased", "twoPosToBox(window.pfb, selectedElements.at(-1).element.getAttribute('position'));")
// event detail is available within that code as a e.detail e.g e.detail.element
} }
}) })
function twoPosToBox(A, B){
let center = A.clone()
center.add(B)
center.divideScalar(2)
let lengthes = A.clone()
lengthes.sub(B)
let el = document.createElement("a-box")
el.setAttribute("position", center )
el.setAttribute('target', '')
el.setAttribute("scale", lengthes.toArray().map( i => Math.abs(i) ).join(" ") )
AFRAME.scenes[0].appendChild(el)
}
// import from https://fabien.benetou.fr/PIMVRdata/SpaSca3DPrinterInstructions?action=source // import from https://fabien.benetou.fr/PIMVRdata/SpaSca3DPrinterInstructions?action=source
// but as text editable format, not code // but as text editable format, not code
// would be safer to do few examples BEFORE synthesizing to a flexible enough format, just with mini games before // would be safer to do few examples BEFORE synthesizing to a flexible enough format, just with mini games before
@ -43,6 +65,20 @@ AFRAME.registerComponent('instruction-machine', {
// port a text version, i.e no 6DoF or hand tracking, to Monocle/Frame // port a text version, i.e no 6DoF or hand tracking, to Monocle/Frame
// adapt from wiki sequential instructions part, possibly with some images // adapt from wiki sequential instructions part, possibly with some images
// consider https://threejs.org/docs/?q=grid#api/en/helpers/GridHelper too // consider https://threejs.org/docs/?q=grid#api/en/helpers/GridHelper too
// hiding panel, like whiteboards/blackboards in order to focus on solely the task at hand
// optional blinders managed by the user
// overall guiding principle, finding the sweet spot of signal/noise ratio
// starting with a lot of blinders then gradually removing them
// potentially leading to open a set of other instructions next to it
// and find combinatorial opportunities
// wall aligning before starting, this way snap would make sense too
// could be done via GridHelper rather than primitive
// requirement, i.e this instruction needs that other instruction to be completed before
// leading to a graph Sasha Kaurov (IAS) as discussed a while ago with X and experienced via Khan Academy (esp. in math)
// can also list optional requirements
// get model of space https://twitter.com/utopiah/status/1712340651453411808
// can prepare remotely, i.e in VR, to either train virtually in-situ
// to build the instruction sets
schema: {default: schema: {default:

@ -218,6 +218,7 @@ AFRAME.registerComponent('onreleased', { // changed from ondrop to be coherent w
// if multi, should also look for onreleased__ not just onreleased // if multi, should also look for onreleased__ not just onreleased
try { try {
eval( code ) // should be jxr too e.g if (txt.match(prefix)) interpretJXR(txt) eval( code ) // should be jxr too e.g if (txt.match(prefix)) interpretJXR(txt)
// note that event details are avaible within that code as e.detail which might not be very clear
} catch (error) { } catch (error) {
console.error(`Evaluation failed with ${error}`); console.error(`Evaluation failed with ${error}`);
} }
@ -235,6 +236,7 @@ AFRAME.registerComponent('onpicked', {
// if multi, should also look for onreleased__ not just onreleased // if multi, should also look for onreleased__ not just onreleased
try { try {
eval( code ) // should be jxr too e.g if (txt.match(prefix)) interpretJXR(txt) eval( code ) // should be jxr too e.g if (txt.match(prefix)) interpretJXR(txt)
// note that event details are avaible within that code as e.detail which might not be very clear
} catch (error) { } catch (error) {
console.error(`Evaluation failed with ${error}`); console.error(`Evaluation failed with ${error}`);
} }

Loading…
Cancel
Save