From 0c60b00b5bb26fc6dbada4ea56809015c6e8ac67 Mon Sep 17 00:00:00 2001 From: Fabien Benetou Date: Sat, 1 Oct 2022 23:18:39 +0200 Subject: [PATCH] extending keyboard --- index.html | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 6e14efe..4197df7 100644 --- a/index.html +++ b/index.html @@ -104,11 +104,11 @@ const startingText = "[]" var drawingMode = false var added = [] const maxItemsFromSources = 20 -let alphabet = 'abcdefghijklmnopqrstuvwxyz>'; +let alphabet = ['abcdefghijklmnopqrstuvwxyz', '0123456789', '<>']; var commandhistory = [] const savedProperties = [ "src", "position", "rotation", "scale", "value", ] // add newer properties e.g visibility and generator as class var groupSelection = [] -var cabin +var cabin //storage for load/save. Should use a better name as this is a reminder of a past version rather than something semantically useful. const url = "https://fabien.benetou.fr/PIMVRdata/CabinData?action=" var generators = "line-link-entities link screenstack dynamic-view selectionboxonpinches keyboard " + "commands-from-external-json glossary timeline issues web-url background-via-url observableui hidableenvironmentfot fot" @@ -550,9 +550,10 @@ AFRAME.registerComponent('line-link-entities', { init: function () { let generatorName = this.attrName setTimeout( _ => { // stupid... but works. + if (!this.data.source || !this.data.target) return var sourcePos = this.data.source.object3D.position var targetPos = this.data.target.object3D.position - if (!sourcePos || !targetPos) return + if (!sourcePos || !targetPos) return // might not be needed anymore // adding a gltf inside an element prevents the parent from having coordinates (fast enough?) var step = 0 var points = cut ([sourcePos, targetPos], 0, ++step) @@ -886,6 +887,7 @@ AFRAME.registerComponent('pinchprimary', { // currently only 1 hand, the right o // testing on desktop function switchToWireframe(){ visible = !visible + /* targets.map( e => { scale = 50// should be a variable instead e.setAttribute("scale", visible ? ".05 .05 .05" : ".1 .1 .1" ) @@ -894,7 +896,8 @@ function switchToWireframe(){ e.setAttribute("position", AFRAME.utils.coordinates.stringify(pos)) // should actually be just for src, not for text notes... even though could be interesting }) - var model = document.querySelector("#cabin").object3D + */ + var model = document.querySelector("#environment").object3D model.traverse( o => { if (o.material) { o.material.wireframe = visible; o.material.opacity = visible ? 0.05 : 1; @@ -1165,9 +1168,10 @@ function parseJXR( code ){ function interpretJXR( code ){ if (code.length == 1) { // special case of being a single character, thus keyboard if (code == ">") { // Enter equivalent - //addNewNote( hudTextEl.getAttribute("value").slice(0,-1) addNewNote( hudTextEl.getAttribute("value") ) hudTextEl.setAttribute("value", "") + } else if (code == "<") { // Backspace equivalent + hudTextEl.setAttribute("value", hudTextEl.getAttribute("value").slice(0,-1)) } else { appendToHUD( code ) } @@ -1240,10 +1244,12 @@ AFRAME.registerComponent('keyboard', { let generatorName = this.attrName const horizontaloffset = .5 const horizontalratio = 1/30 - for (var i = 0; i < alphabet.length; i++) { + alphabet.map( (line,ln) => { + for (var i = 0; i < line.length; i++) { var pos = i * horizontalratio - horizontaloffset - addNewNote( alphabet[i], pos+" 1.6 -.4", ".1 .1 .1", null, generatorName) + addNewNote( line[i], pos+" "+(1.6-ln*.03)+" -.4", ".1 .1 .1", null, generatorName) } + }) } }) @@ -1498,7 +1504,7 @@ function remoteSave(){ - +