From b1e46be9eb4626e752e7671a5c9a8e84ae39fccc Mon Sep 17 00:00:00 2001 From: Val Erastov Date: Wed, 23 Nov 2016 19:23:25 -0800 Subject: [PATCH] approach to lookAt solid functionality --- web/app/3d/viewer.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/web/app/3d/viewer.js b/web/app/3d/viewer.js index ce250f59..77b79d72 100644 --- a/web/app/3d/viewer.js +++ b/web/app/3d/viewer.js @@ -154,6 +154,23 @@ function Viewer(bus, container) { this.animate(); } +Viewer.prototype.lookAt = function(obj) { + var box = new THREE.Box3(); + box.setFromObject(obj); + let size = box.size(); + //this.camera.position.set(0,0,0); + box.center(this.camera.position); + const maxSize = Math.max(size.x, size.z); + const dist = maxSize / 2 / Math.tan(Math.PI * this.camera.fov / 360); + this.camera.position.addScaledVector(this.camera.position.normalize(), 5000); + + //this.camera.position.sub(new THREE.Vector3(0, 0, dist)); + this.camera.up = new THREE.Vector3(0,1,0); + + + this.render(); +}; + Viewer.prototype.handleSolidPick = function(e) { this.raycastFaces(event, this, function(sketchFace) { this.selectionMgr.clear();