|
|
|
@ -35,7 +35,7 @@ recognizer.continuous = true; |
|
|
|
|
recognizer.lang = 'en-US'; |
|
|
|
|
|
|
|
|
|
const aframeprimitives = getAllPrimitives() |
|
|
|
|
const speechactions = [ "add", "apply" ] |
|
|
|
|
const speechactions = [ "add", "apply", "delete", "clone" ] |
|
|
|
|
const speechcustomcomponents = [ "target", "teleporter" ] |
|
|
|
|
|
|
|
|
|
recognizer.onresult = (event) => { |
|
|
|
@ -46,6 +46,8 @@ recognizer.onresult = (event) => { |
|
|
|
|
// should instead look if starting with speechContent following by aframeprimitives, optionally speechcustomcomponents |
|
|
|
|
// then apply accordingly |
|
|
|
|
let speechContent = result[0].transcript |
|
|
|
|
// let newPostIt = addNewNoteAsPostItNote(speechContent, "0 1.2 -.5") |
|
|
|
|
// could become jxr code proper later, also allowing to re-execute a command again |
|
|
|
|
let cmd_words = speechContent.split(" ").map( i => i.toLowerCase() ) |
|
|
|
|
if (cmd_words[0] == speechactions[0]){ // limited to add command for now |
|
|
|
|
console.log("recognized proper command") |
|
|
|
@ -63,21 +65,17 @@ recognizer.onresult = (event) => { |
|
|
|
|
addedContent.at(-1).setAttribute( cmd_words[1], cmd_words[2]) // assuming fixed order for now |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ( result[0].transcript == "Add red cube"){ |
|
|
|
|
console.log("recognized command") |
|
|
|
|
let newPostIt = addNewNoteAsPostItNote(speechContent, "0 1.2 -.5") |
|
|
|
|
// could become jxr code proper later, also allowing to re-execute a command again |
|
|
|
|
let el = document.createElement("a-box") |
|
|
|
|
el.setAttribute("color", "red") |
|
|
|
|
el.setAttribute("target", "") |
|
|
|
|
el.setAttribute("scale", ".1 .1 .1") |
|
|
|
|
el.setAttribute("position", "0 1.5 -0.4") |
|
|
|
|
AFRAME.scenes[0].appendChild( el ) |
|
|
|
|
if (cmd_words[0] == speechactions[2]) |
|
|
|
|
deleteTarget( addedContent.at(-1) ) |
|
|
|
|
|
|
|
|
|
// among ACTION could also have a selection area, e.g a bounding box wireframe to apply the action to all elements within in |
|
|
|
|
if (cmd_words[0] == speechactions[3]){ |
|
|
|
|
let el = addedContent.at(-1).cloneNode(true) // does not work properly, losing some attributes, in particular scale can be problematic |
|
|
|
|
// could optionally add a number of times |
|
|
|
|
addedContent.push(el) |
|
|
|
|
|
|
|
|
|
el.object3D.translateX(1) |
|
|
|
|
AFRAME.scenes[0].appendChild( el ) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
recognizer.start(); |
|
|
|
|