From de5c6a41bd353180f317998f50b2e561276cc8a7 Mon Sep 17 00:00:00 2001 From: Fabien Benetou Date: Sun, 2 Apr 2023 19:14:28 +0200 Subject: [PATCH] rotation fixed, again, somehow (does not seem stable) --- index.html | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/index.html b/index.html index d8910a8..d337955 100644 --- a/index.html +++ b/index.html @@ -4,8 +4,8 @@ - - + + @@ -1053,8 +1053,9 @@ AFRAME.registerComponent('pinchprimary', { // currently only 1 hand, the right o if (selectedElement && !groupingMode) { selectedElement.setAttribute("position", event.detail.position) document.querySelector("#rightHand").object3D.traverse( e => { - if (e.name == "b_"+sides[primarySide][0]+"_wrist") - selectedElement.setAttribute("rotation", e.rotation._x*180/3.14 + " " + e.rotation._y*180/3.14 + " " + e.rotation._z*180/3.14) + if (e.name == "b_"+sides[primarySide][0]+"_wrist"){ + selectedElement.object3D.rotation.copy( e.rotation ) + } }) // rotation isn't ideal with the wrist as tend not have wrist flat as we pinch } @@ -2177,13 +2178,15 @@ function addAllPrimitives(){ .map( (i,j) => addPrimitive( i, ""+ j/7 + " 1.4 -0.5" ) ) } +const eventHighlighterReady = new Event("highlighterready"); var highlighter shiki.setCDN('../content/shiki/') // see https://github.com/shikijs/shiki#specify-a-custom-root-directory -shiki.getHighlighter({ theme: 'monokai', langs: ['javascript' ] }).then(h => highlighter = h ) +shiki.getHighlighter({ theme: 'monokai', langs: ['javascript' ] }).then(h => { highlighter = h; document.body.dispatchEvent(eventHighlighterReady); } ) // see https://github.com/shikijs/shiki/blob/main/docs/languages.md function highlight(code = `console.log("Here is your code."); var x = 5;`, language='javascript'){ - if (!highlighter) return {} // should also warn + if (!highlighter) return null + // check set colorRange if the result is {} which is the case when shiki highlighter isn't ready or available const tokens = highlighter.codeToThemedTokens(code, language) let pos=0 let colorRange={} @@ -2197,14 +2200,16 @@ function highlight(code = `console.log("Here is your code."); var x = 5;`, langu return colorRange } +document.body.addEventListener( "highlighterready", (e) => { + console.log(highlighter) + fetch("colorme.js").then(r=>r.text()).then( page => { addCodeEditor( page ) }) +}, false); function startExperience(){ //addCodeEditor(" \n\nqwe qwe qwe qwe qwe qwe qwe qweqweqwe\n\n\na", "") //addCodeEditor() - fetch("colorme.js").then(r=>r.text()).then( page => { addCodeEditor( page ) }) //fetch("https://fabien.benetou.fr/Tools/Docker?action=source").then(r=>r.text()).then( page => { addCodeEditor( page, "" ) }) - if (AFRAME.utils.device.checkHeadsetConnected()) - AFRAME.scenes[0].enterVR(); + //if (AFRAME.utils.device.checkHeadsetConnected()) AFRAME.scenes[0].enterVR(); //document.querySelector("#snapping-sound").components.sound.playSound(); document.querySelector("#mainbutton").style.display = "none" } @@ -2538,7 +2543,6 @@ function addCodeEditor(page="jxr console.log('hello world')", language="javascri codeEditor.element.setAttribute("troika-text", {value: content}) codeEditor.element.setAttribute("troika-text", {depthOffset: .1}) if (language?.length > 0 && language != "none") codeEditor.element.setAttribute("troika-text", {colorRanges: highlight(content, language)}) - // shouldn't set colorRange if the result is {} which is the case when shiki highlighter isn't ready or available addBackdropToTroikaElement( codeEditor.element ) addGuttersToTroikaElement( codeEditor.element ) @@ -2997,7 +3001,7 @@ AFRAME.registerComponent('startfunctions', {
- + --> - + @@ -3069,9 +3073,5 @@ AFRAME.registerComponent('startfunctions', { -