basis for undo (non functional)

real-world-meshing
Fabien Benetou 3 months ago
parent 3af9600f8e
commit 92a093df65
  1. 13
      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") )

Loading…
Cancel
Save