Rotate object and fit to screen

Viewed 33

I have raw obj and mtl files from photogrammetry. They have different sizes and orientation. The goal is to change the size and orientation for it to fill the screen. Orientation is to be calculated assuming that the flattest area is defined as ground and anomalies from there, ie bumps, which are likely the desired objects, are to be aligned with the Y-axis point up. The first approach was to use a bounding box

var el = document.querySelector('#aentity');
var object = el.getObject3D('tree-obj');

// compute bounding box
var bbox = new THREE.Box3().setFromObject(object);
console.log(bbox.min, bbox.max)

to get the size and scale it accordingly.

This already fails with

three.js:3819 
        
       Uncaught TypeError: Cannot read properties of undefined (reading 'updateWorldMatrix')
    at Box3.expandByObject (three.js:3819:1)
    at Box3.setFromObject (three.js:3766:1)
    at file.html:25:29

line 25:

var bbox = new THREE.Box3().setFromObject(object);
0 Answers
Related