MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / applyDrag

Method applyDrag

src/main/java/fieldbox/boxes/plugins/Handles.java:321–349  ·  view source on GitHub ↗
(Draggable x, Vec2 mouseWas, Vec2 mouseNow, Vec3 initialPosition)

Source from the content-addressed store, hash-verified

319 if (x.source != null && x.source.attributes.has(inside)) {
320 System.out.println(" this is 3d");
321 Viewport v = x.source.attributes.get(inside);
322
323 Vec2 ds = v.viewportToDrawingSpace(initialPosition);
324
325 System.out.println(" old drawing space " + ds);
326
327 ds.x += mouseNow.x - mouseWas.x;
328 ds.y += mouseNow.y - mouseWas.y;
329
330 System.out.println(" new drawing space " + ds);
331
332 Vec3 v1 = v.drawingSpaceToViewport(ds, 0.1f);
333 Vec3 v2 = v.drawingSpaceToViewport(ds, 0.9f);
334
335 Vec3 n = new Vec3(v2).sub(v1).normalize();
336
337 double ll = new Vec3(initialPosition).sub(v1).dot(n);
338
339 Vec3 ret = n.scale(ll).add(v1);
340
341 System.out.println(" closest point to point " + initialPosition + " is " + ret + " (" + ll + " away)");
342
343 return ret;
344 }
345 return new Vec3(mouseNow.x - mouseWas.x + initialPosition.x, mouseNow.y - mouseWas.y + initialPosition.y, initialPosition.z);
346 }
347
348
349 private void commit() {
350 all().forEach(x -> x.commit());
351 }
352

Callers 1

draggerForSelectionMethod · 0.95

Calls 10

scaleMethod · 0.95
getMethod · 0.65
hasMethod · 0.45
printlnMethod · 0.45
normalizeMethod · 0.45
subMethod · 0.45
dotMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected