refactoring meshUtils, added sceneScale, #74

This commit is contained in:
2026-03-24 20:25:50 +02:00
parent 0928ef8999
commit 008cc428d4
19 changed files with 199 additions and 189 deletions
+10 -3
View File
@@ -4,7 +4,7 @@ class Draggable{
constructor(engine, defaultDistance){
const objects = [];
const raycaster = new Raycaster();
let v = new Vector3;
let v = new Vector3(), cv = new Vector3();
let dragging = null;
this.add = function(object, dragZone, fn, distance){
objects.push(object);
@@ -29,9 +29,16 @@ class Draggable{
this.handle = function(action){
if (['start', 'selectstart'].includes(action)){
let forExecute = [];
objects.forEach(o=>{
engine.cameraWorld.getWorldPosition(cv);
objects.filter(o=>{
do {
if (o.__active === false || o.visible === false) return false;
o = o.parent;
} while (o);
return true;
}).forEach(o=>{
o.getWorldPosition(v);
if (engine.cameraWorld.position.distanceTo(v) <= o._draggable.distance && o.visible){
if (cv.distanceTo(v) <= o._draggable.distance / engine.scale){
const intersects = raycaster.intersectObject(o);
if (intersects[0]) forExecute.push({o, i:intersects[0]})
}