fix basic cloning

real-world-meshing
Fabien Benetou 4 months ago
parent b5556ff071
commit 3987da1f28
  1. 13
      index.html

@ -68,12 +68,21 @@ recognizer.onresult = (event) => {
if (cmd_words[0] == speechactions[2])
deleteTarget( addedContent.at(-1) )
let latest = addedContent.at(-1)
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
let el = latest.cloneNode(true) // does not work properly, losing some attributes, in particular scale can be problematic
//["scale", "position", "rotation", "wireframe", "target", "material"].map( prop => el.setAttribute(prop, latest.getAttribute(prop) ) )
//["scale", "position", "rotation", "target" ].map( prop => el.setAttribute(prop, latest.getAttribute(prop) ) )
el.setAttribute("scale", latest.getAttribute("scale") )
el.setAttribute("position", latest.getAttribute("position") )
el.setAttribute("rotation", latest.getAttribute("rotation") )
el.setAttribute("target", latest.getAttribute("target") )
// untested
if (cmd_words[1]) console.log('could clone',cmd_words[1],'n times instead')
// could optionally add a number of times
addedContent.push(el)
el.object3D.translateX(1)
AFRAME.scenes[0].appendChild( el )
el.object3D.translateX(1)
}
}

Loading…
Cancel
Save