undo working, limited to undo-ing adding only

speech
Fabien Benetou 3 months ago
parent 92a093df65
commit 81a028b706
  1. 106
      index.html

@ -96,6 +96,7 @@ recognizer.onresult = (event) => {
case speechactions[2] :
deleteTarget( latest )
speechCommands.push( speechContent )
addedContent.pop()
break;
case speechactions[3] :
el = latest.cloneNode(true) // does not work properly, losing some attributes, in particular scale can be problematic
@ -118,8 +119,19 @@ recognizer.onresult = (event) => {
speechCommands.push( speechContent )
break;
case speechactions[5] :
console.log( "should undo", speechCommands.at(-1) )
// note that not all commands might be undo-able
if ( speechCommands.at(-1) ){
let prev_cmd_words = speechCommands.at(-1).split(" ").map( i => i.toLowerCase() )
switch(prev_cmd_words[0]) {
case speechactions[0]:
console.log( "undoing", speechCommands.at(-1) )
deleteTarget( latest )
addedContent.pop()
break;
default:
console.log( "can't undo", speechCommands.at(-1) )
// note that not all commands might be undo-able
}
}
break;
default:
addedContent.push( addNewNoteAsPostItNote(speechContent, "0 1.2 -.5") )
@ -499,96 +511,6 @@ setTimeout( _ => {
<a-box target teleporter height=".1" depth=".1" width=".1" class="teleportable" material="color: red" position="0 1 -.5" ></a-box>
<a-entity position="-1 1 -3.5" scaffolding>
<a-box teleporter height=".01" depth=".4" width="1" class="teleportable" material="color: white" position=".5 0 -.2" ></a-box>
<a-entity position="0 0.5 0" class="scaffolding_front">
<a-cylinder radius=".05"></a-cylinder>
<a-cylinder radius=".05" position=".5 -.5 0" rotation="0 0 90"></a-cylinder>
<a-cylinder radius=".05" height=1.2 position=".5 0 0" rotation="0 0 45"></a-cylinder>
<a-cylinder radius=".05" height=".4" position="0 -.5 -.2" rotation="90 0 0"></a-cylinder>
</a-entity>
<a-entity position="0 0.5 -.4" class="scaffolding_back">
<a-cylinder radius=".05" position="0 0 0"></a-cylinder>
<a-cylinder radius=".05" position=".5 -.5 0" rotation="0 0 90"></a-cylinder>
<a-cylinder radius=".05" height=1.2 position=".5 0 0" rotation="0 0 -45"></a-cylinder>
<a-cylinder radius=".05" height=".4" position="1 -.5 .2" rotation="90 0 0"></a-cylinder>
</a-entity>
</a-entity>
<a-entity position="-1 2 -3.5" scaffolding>
<a-box teleporter height=".01" depth=".4" width="1" class="teleportable" material="color: white" position=".5 0 -.2" ></a-box>
<a-entity position="0 0.5 0" class="scaffolding_front">
<a-cylinder radius=".05"></a-cylinder>
<a-cylinder radius=".05" position=".5 -.5 0" rotation="0 0 90"></a-cylinder>
<a-cylinder radius=".05" height=1.2 position=".5 0 0" rotation="0 0 45"></a-cylinder>
<a-cylinder radius=".05" height=".4" position="0 -.5 -.2" rotation="90 0 0"></a-cylinder>
</a-entity>
<a-entity position="0 0.5 -.4" class="scaffolding_back">
<a-cylinder radius=".05" position="0 0 0"></a-cylinder>
<a-cylinder radius=".05" position=".5 -.5 0" rotation="0 0 90"></a-cylinder>
<a-cylinder radius=".05" height=1.2 position=".5 0 0" rotation="0 0 -45"></a-cylinder>
<a-cylinder radius=".05" height=".4" position="1 -.5 .2" rotation="90 0 0"></a-cylinder>
</a-entity>
</a-entity>
<a-entity position="0 0 -3.5" scaffolding>
<a-box teleporter height=".01" depth=".4" width="1" class="teleportable" material="color: white" position=".5 0 -.2" ></a-box>
<a-entity position="0 0.5 0" class="scaffolding_front">
<a-cylinder radius=".05"></a-cylinder>
<a-cylinder radius=".05" position=".5 -.5 0" rotation="0 0 90"></a-cylinder>
<a-cylinder radius=".05" height=1.2 position=".5 0 0" rotation="0 0 45"></a-cylinder>
<a-cylinder radius=".05" height=".4" position="0 -.5 -.2" rotation="90 0 0"></a-cylinder>
</a-entity>
<a-entity position="0 0.5 -.4" class="scaffolding_back">
<a-cylinder radius=".05" position="0 0 0"></a-cylinder>
<a-cylinder radius=".05" position=".5 -.5 0" rotation="0 0 90"></a-cylinder>
<a-cylinder radius=".05" height=1.2 position=".5 0 0" rotation="0 0 -45"></a-cylinder>
<a-cylinder radius=".05" height=".4" position="1 -.5 .2" rotation="90 0 0"></a-cylinder>
</a-entity>
</a-entity>
<a-entity position="0 1 -3.5" scaffolding>
<a-box teleporter height=".01" depth=".4" width="1" class="teleportable" material="color: white" position=".5 0 -.2" ></a-box>
<a-entity position="0 0.5 0" class="scaffolding_front">
<a-cylinder radius=".05"></a-cylinder>
<a-cylinder radius=".05" position=".5 -.5 0" rotation="0 0 90"></a-cylinder>
<a-cylinder radius=".05" height=1.2 position=".5 0 0" rotation="0 0 45"></a-cylinder>
<a-cylinder radius=".05" height=".4" position="0 -.5 -.2" rotation="90 0 0"></a-cylinder>
</a-entity>
<a-entity position="0 0.5 -.4" class="scaffolding_back">
<a-cylinder radius=".05" position="0 0 0"></a-cylinder>
<a-cylinder radius=".05" position=".5 -.5 0" rotation="0 0 90"></a-cylinder>
<a-cylinder radius=".05" height=1.2 position=".5 0 0" rotation="0 0 -45"></a-cylinder>
<a-cylinder radius=".05" height=".4" position="1 -.5 .2" rotation="90 0 0"></a-cylinder>
</a-entity>
</a-entity>
<a-entity position="1 0 -3.5" scaffolding>
<a-box teleporter height=".01" depth=".4" width="1" class="teleportable" material="color: white" position=".5 0 -.2" ></a-box>
<a-entity position="0 0.5 0" class="scaffolding_front">
<a-cylinder radius=".05"></a-cylinder>
<a-cylinder radius=".05" position=".5 -.5 0" rotation="0 0 90"></a-cylinder>
<a-cylinder radius=".05" height=1.2 position=".5 0 0" rotation="0 0 45"></a-cylinder>
<a-cylinder radius=".05" height=".4" position="0 -.5 -.2" rotation="90 0 0"></a-cylinder>
</a-entity>
<a-entity position="0 0.5 -.4" class="scaffolding_back">
<a-cylinder radius=".05" position="0 0 0"></a-cylinder>
<a-cylinder radius=".05" position=".5 -.5 0" rotation="0 0 90"></a-cylinder>
<a-cylinder radius=".05" height=1.2 position=".5 0 0" rotation="0 0 -45"></a-cylinder>
<a-cylinder radius=".05" height=".4" position="1 -.5 .2" rotation="90 0 0"></a-cylinder>
</a-entity>
</a-entity>
<a-entity position="-1 0 -3.5" scaffolding>
<a-box teleporter height=".01" depth=".4" width="1" class="teleportable" material="color: white" position=".5 0 -.2" ></a-box>
<a-entity position="0 0.5 0" class="scaffolding_front">
<a-cylinder radius=".05"></a-cylinder>
<a-cylinder radius=".05" position=".5 -.5 0" rotation="0 0 90"></a-cylinder>
<a-cylinder radius=".05" height=1.2 position=".5 0 0" rotation="0 0 45"></a-cylinder>
<a-cylinder radius=".05" height=".4" position="0 -.5 -.2" rotation="90 0 0"></a-cylinder>
</a-entity>
<a-entity position="0 0.5 -.4" class="scaffolding_back">
<a-cylinder radius=".05" position="0 0 0"></a-cylinder>
<a-cylinder radius=".05" position=".5 -.5 0" rotation="0 0 90"></a-cylinder>
<a-cylinder radius=".05" height=1.2 position=".5 0 0" rotation="0 0 -45"></a-cylinder>
<a-cylinder radius=".05" height=".4" position="1 -.5 .2" rotation="90 0 0"></a-cylinder>
</a-entity>
</a-entity>
</a-scene>
</body>
</script>

Loading…
Cancel
Save