refactoring meshUtils, added sceneScale, #74
This commit is contained in:
+10
-3
@@ -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]})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user