|
|
@ -61,9 +61,11 @@ recognizer.continuous = true; |
|
|
|
recognizer.lang = 'en-US'; |
|
|
|
recognizer.lang = 'en-US'; |
|
|
|
|
|
|
|
|
|
|
|
const aframeprimitives = getAllPrimitives() |
|
|
|
const aframeprimitives = getAllPrimitives() |
|
|
|
const speechactions = [ "add", "apply", "delete", "clone", "model" ] |
|
|
|
const speechactions = [ "add", "apply", "delete", "clone", "model", "undo" ] |
|
|
|
const speechcustomcomponents = [ "target", "teleporter" ] |
|
|
|
const speechcustomcomponents = [ "target", "teleporter" ] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let speechCommands = [] |
|
|
|
|
|
|
|
|
|
|
|
recognizer.onresult = (event) => { |
|
|
|
recognizer.onresult = (event) => { |
|
|
|
let result = event.results[event.resultIndex] |
|
|
|
let result = event.results[event.resultIndex] |
|
|
|
if (result.isFinal) { |
|
|
|
if (result.isFinal) { |
|
|
@ -84,13 +86,16 @@ recognizer.onresult = (event) => { |
|
|
|
el.setAttribute("position", "0 1.5 -0.4") |
|
|
|
el.setAttribute("position", "0 1.5 -0.4") |
|
|
|
addedContent.push(el) |
|
|
|
addedContent.push(el) |
|
|
|
AFRAME.scenes[0].appendChild( el ) |
|
|
|
AFRAME.scenes[0].appendChild( el ) |
|
|
|
|
|
|
|
speechCommands.push( speechContent ) |
|
|
|
break; |
|
|
|
break; |
|
|
|
case speechactions[1] : |
|
|
|
case speechactions[1] : |
|
|
|
console.log("recognized apply command") |
|
|
|
console.log("recognized apply command") |
|
|
|
latest.setAttribute( cmd_words[1], cmd_words[2]) // assuming fixed order for now |
|
|
|
latest.setAttribute( cmd_words[1], cmd_words[2]) // assuming fixed order for now |
|
|
|
|
|
|
|
speechCommands.push( speechContent ) |
|
|
|
break; |
|
|
|
break; |
|
|
|
case speechactions[2] : |
|
|
|
case speechactions[2] : |
|
|
|
deleteTarget( latest ) |
|
|
|
deleteTarget( latest ) |
|
|
|
|
|
|
|
speechCommands.push( speechContent ) |
|
|
|
break; |
|
|
|
break; |
|
|
|
case speechactions[3] : |
|
|
|
case speechactions[3] : |
|
|
|
el = latest.cloneNode(true) // does not work properly, losing some attributes, in particular scale can be problematic |
|
|
|
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) |
|
|
|
addedContent.push(el) |
|
|
|
AFRAME.scenes[0].appendChild( el ) |
|
|
|
AFRAME.scenes[0].appendChild( el ) |
|
|
|
el.object3D.translateX(10) // due to scaling |
|
|
|
el.object3D.translateX(10) // due to scaling |
|
|
|
|
|
|
|
speechCommands.push( speechContent ) |
|
|
|
break; |
|
|
|
break; |
|
|
|
case speechactions[4] : |
|
|
|
case speechactions[4] : |
|
|
|
getModelFromKeyword( cmd_words[1] ) // requires the backend (proxy, LAN only for now, waiting for API clarification on 403) |
|
|
|
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; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
addedContent.push( addNewNoteAsPostItNote(speechContent, "0 1.2 -.5") ) |
|
|
|
addedContent.push( addNewNoteAsPostItNote(speechContent, "0 1.2 -.5") ) |
|
|
|