Calculate camera position for 3d model which shows full model

Copper Contributor



I try to calculate camera position for GLB model so that complete model is visible in my slide.

My understanding is, this can be achieved by setting 'z' attribute of 'camera' node of slide.xml file.


Pasted below camera node for reference.


<am3d:pos x="0" y="0" z="11713743"/>

<am3d:up dx="0" dy="36000000" dz="0"/>

<am3d:lookAt x="0" y="0" z="0"/>

<am3d:perspective fov="2700000"/>



I calculate z position from bounding sphere of model using below logic,

glb_scene = trimesh.load(glb_path)
radius = math.sqrt(glb_scene.bounding_sphere.area/(4 * math.pi))
z_distance = (radius)/math.tan(math.radians(45/2))

But, in the output presentation file created by my script, 3d model is not completely visible. 


To analyze further, I created 3 GLB file containing sphere of various radius. I created empty presentation (not using my script, created using powerpoint application directly) and placed these GLB file in different slide. So, my understanding is, bounding sphere should increase and inturn, camera position in z axis also should increase.


But, when i check slide1.xml, slide2.xml and slide3.xml 'z' position value is same. Is there any other parameters in slide.xml impacts camera position ?



0 Replies