From 92a093df65894846bff13e38648c92352135cb24 Mon Sep 17 00:00:00 2001 From: Fabien Benetou Date: Mon, 10 Jun 2024 21:48:47 +0200 Subject: [PATCH] basis for undo (non functional) --- index.html | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index c10e827..c04eb8d 100644 --- a/index.html +++ b/index.html @@ -61,9 +61,11 @@ recognizer.continuous = true; recognizer.lang = 'en-US'; const aframeprimitives = getAllPrimitives() -const speechactions = [ "add", "apply", "delete", "clone", "model" ] +const speechactions = [ "add", "apply", "delete", "clone", "model", "undo" ] const speechcustomcomponents = [ "target", "teleporter" ] +let speechCommands = [] + recognizer.onresult = (event) => { let result = event.results[event.resultIndex] if (result.isFinal) { @@ -84,13 +86,16 @@ recognizer.onresult = (event) => { el.setAttribute("position", "0 1.5 -0.4") addedContent.push(el) AFRAME.scenes[0].appendChild( el ) + speechCommands.push( speechContent ) break; case speechactions[1] : console.log("recognized apply command") latest.setAttribute( cmd_words[1], cmd_words[2]) // assuming fixed order for now + speechCommands.push( speechContent ) break; case speechactions[2] : deleteTarget( latest ) + speechCommands.push( speechContent ) break; case speechactions[3] : el = latest.cloneNode(true) // does not work properly, losing some attributes, in particular scale can be problematic @@ -106,9 +111,15 @@ recognizer.onresult = (event) => { addedContent.push(el) AFRAME.scenes[0].appendChild( el ) el.object3D.translateX(10) // due to scaling + speechCommands.push( speechContent ) break; case speechactions[4] : getModelFromKeyword( cmd_words[1] ) // requires the backend (proxy, LAN only for now, waiting for API clarification on 403) + speechCommands.push( speechContent ) + break; + case speechactions[5] : + console.log( "should undo", speechCommands.at(-1) ) + // note that not all commands might be undo-able break; default: addedContent.push( addNewNoteAsPostItNote(speechContent, "0 1.2 -.5") )