From 3987da1f28236a780b4c815a520a655062dd5433 Mon Sep 17 00:00:00 2001 From: Fabien Benetou Date: Wed, 5 Jun 2024 22:12:29 +0200 Subject: [PATCH] fix basic cloning --- index.html | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index 6edbcef..09aa287 100644 --- a/index.html +++ b/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) } }