diff --git a/index.html b/index.html index f6c8f59..fab15cd 100644 --- a/index.html +++ b/index.html @@ -29,7 +29,7 @@ - + + + + - + + --> + + + diff --git a/jxr.js b/jxr.js index eba384b..00f40ca 100644 --- a/jxr.js +++ b/jxr.js @@ -1334,6 +1334,9 @@ function parseJXR( code ){ newcode = newcode.replace(/ sa ([^\s]+) (.*)/,`.setAttribute('$1','$2')`) // problematic for position as they include spaces + newcode = newcode.replace(/ ga ([^\s]+)/,`.getAttribute('$1')`) + // also problematic to compount but can work e.g interpretJXR('jxr qs #penguin ga position .x++') + newcode = newcode.replace(/obsv ([^\s]+)/ ,`newNoteFromObservableCell('$1')`) // TODO @@ -3422,18 +3425,24 @@ function thumbToIndexAngle(){ AFRAME.registerComponent('annotation', { // consider also multiple annotation but being mindful that it might clutter significantly schema: { - content : {type: 'string'} + content : {type: 'string', default:''}, + back : {type: 'string', default:''} }, init: function () { addAnnotation(this.el, this.data.content) + let back = addAnnotation(this.el, this.data.back) + back.setAttribute('position', '0 0 -.2') + back.setAttribute('rotation', '180 0 0') + back.setAttribute('material', 'side:front') + back.classList.add( 'back' ) }, update: function () { + this.el.querySelector('.annotation').setAttribute('value', this.data.content ) this.el.querySelector('.annotation').setAttribute('value', this.data.content ) // assuming single annotation }, remove: function () { - this.el.querySelector('.annotation').removeFromParent() - //Array.from( this.el.querySelectorAll('.annotation') ).map( a => a.removeFromParent() ) + Array.from( this.el.querySelectorAll('.annotation') ).map( a => a.removeFromParent() ) } }) @@ -3441,6 +3450,7 @@ function addAnnotation(el, content){ // could also appear only when in close proximity or while pinching let annotation = document.createElement( 'a-troika-text' ) annotation.classList.add( 'annotation' ) + annotation.classList.add( 'content' ) annotation.setAttribute('value', content) annotation.setAttribute('position', '0 .1 -.1') annotation.setAttribute('rotation', '-90 0 0') @@ -3448,7 +3458,7 @@ function addAnnotation(el, content){ annotation.setAttribute("outline-width", "5%" ) annotation.setAttribute("outline-color", "black" ) el.appendChild(annotation) - return el + return annotation } // 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 @@ -3464,7 +3474,6 @@ consider also see https://git.benetou.fr/utopiah/text-code-xr-engine/issues/52 for more shorthands -*/ const movePenguin = "jxr qs #penguin sa position 1 0 -2" const rotatePenguin = "jxr qs #penguin sa rotation 0 -20 0" @@ -3494,25 +3503,29 @@ see https://git.benetou.fr/utopiah/text-code-xr-engine/issues/52 for more shorth el.setAttribute('scale', '.1 .1 .1') AFRAME.scenes[0].appendChild(el) +*/ + let h = [ [1,1,1,1,1,1,1,1,1,1], - [1,0,0,0,1,0,0,0,0,1], - [1,0,0,0,0,1,0,0,0,1], - [1,0,0,0,1,0,0,0,0,1], - [1,0,0,0,0,1,0,0,0,1], - [1,0,0,0,1,0,0,0,0,1], - [1,0,0,0,0,1,0,0,0,1], - [1,0,0,0,1,0,0,0,0,1], + [1,0,0,0,1,0,0,3,0,1], [1,0,0,0,0,1,0,0,0,1], + [1,0,2,0,0,0,0,0,0,1], + [1,0,0,0,0,0,0,0,0,1], + [1,0,0,0,0,0,0,0,0,1], + [1,0,0,0,0,0,0,0,0,1], + [1,0,0,0,0,0,0,0,0,1], + [1,0,0,2,0,1,0,0,0,1], [1,1,1,1,1,1,1,1,1,1], ] for (let z=0;z<10;z++) for (let x=0;x<10;x++){ el = document.createElement("a-entity") el.setAttribute('position', (x-5) + ' 0 ' + (z-5) ) + el.classList.add( 'maptile' ) el.setAttribute('geometry', "primitive: cylinder; segmentsRadial: 8; segmentsHeight: 1; radius: 0.5; height: "+(h[x][z]+.1)+";" ) el.setAttribute('material', 'color', 'lightblue') - AFRAME.scenes[0].appendChild(el) + //AFRAME.scenes[0].appendChild(el) + document.getElementById('tablescaled').appendChild(el) } // consider instanciateFromPrimitive() also in order to clone a set of blocks