From b31e9251563bec8a66b1edfcda186b7602b5259e Mon Sep 17 00:00:00 2001 From: Fabien Benetou Date: Mon, 23 Jan 2023 09:57:38 +0100 Subject: [PATCH] apply modifier to class --- index.html | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/index.html b/index.html index 3e82855..7dd739f 100644 --- a/index.html +++ b/index.html @@ -2153,12 +2153,53 @@ function getIdFromPick(){ return id } +function getClassFromPick(){ // should be classes, for now assuming one + let classFound = null + let pp = selectedElements.filter( e => e.primary ) + if (pp && pp[pp.length-1] && pp[pp.length-1].element ){ + //if (!pp[pp.length-1].element.className) pp[pp.length-1].element.className= "missingclass" + // arguable + classFound = pp[pp.length-1].element.className + setFeedbackHUD(classFound) + } + return classFound +} + +function changeColorLastClass(){ + let classFound = getClassFromPick() // applies on primary only + if (classFound) + [...document.querySelectorAll("."+classFound)].map( el => el.setAttribute("color", "red") ) +} + function changeColorLastId(){ let id = getIdFromPick() // applies on primary only - console.log("id?",id) if (id) document.querySelector("#"+id).setAttribute("color", "red") } +/* + +generalize selector to pick last Nth rather than very last + adapt getIdFromPick() with .slice() after filter then map on length-N instead of length-1 + +selector pickers : pickClass and pickId + display result in 3D HUD with rotating objects and selector value + ideally themselves also selectable/usable, e.g clone from HUD to bring back "out" + requires extra work as becoming a child will not work, own positionning + should fix that + could compare to world coordinates instead of "just" position attribute + add a clear selector function to avoid making the HUD unusable + +could also pick via volume, e.g wireframe box + start with https://threejs.org/docs/#api/en/math/Box3.containsPoint + can iterate with https://threejs.org/docs/#api/en/math/Box3.containsBox + consider also https://threejs.org/docs/#api/en/math/Box3.intersectsBox + +consider pick then apply, i.e changeColorLastId() but for next Id + should be cancealable + +*/ + +
@@ -2212,6 +2253,9 @@ function changeColorLastId(){ + + +