Camera "zoom to all" target center of pysical model upon IFC import
See original GitHub issueHi
I am looking for a way that would move the camera to “zoom to all” (target the volumetric center of imported elements) and use that as a Orbitcontrol center upon import of IFC. This would make life a lot easier when it comes to viewing our IFC models that have a coordinate system that starts on a particular elevation. It should be noted that our exported model units are by default in millimeters. I’ve tried to follow a couple of examples I found online, but I am definitively doing this wrong.
I tried to modify example “00” by simply adding the following snippet of code to the “pick()” method in the “scene-picker.js” file in order to find a way to move the camera to the object I am clicking on. Note that I have little experience with threejs, so I might be violating some basic rules 😃
...
pickedObject.material = pickedObjectMaterial;
console.log(pickedObject._Data);
// Code for setting camera target to picked object
var target = pickedObject.geometry.boundingSphere.center;
console.log(target);
//camera.position.set(target);
camera.position.set(target+new THREE.Vector3(10,10,10));
camera.lookAt(new THREE.Vector3(target));
//camera.updateProjectionMatrix();
When I click on a beam (floating in the middle of nowhere as shown below) I end up apparently lost in space 😃

All I see is the grey background and I am unable to see my beam and I’ve lost sight of the grid making it difficult to figure out where I am 😦

The updated camera does however seem to be corrupt or broken in some (as shown in the console logging of the "camera"displaying NA values in the x,y,z coordinates)

I might be way off here, so it is much appreciated if anyone have any suggestions on where I ought to be looking or guidance on how I should debug or any related tips 😃 And any tips for where I should look to implement the same functionality as a final event after IFC import would also be much appreciated.
Great project btw 😃
Best Regards Kristoffer
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:9

Top Related StackOverflow Question
This was already solved by @Voffknur.
Hello! Sorry, I haven’t had time to look more into this:( If you have a plan of how to implement this I think you will have a solution up and running much faster than what I can deliver 😃