f3d-app / f3d

Fast and minimalist 3D viewer.
https://f3d.app
BSD 3-Clause "New" or "Revised" License
2.91k stars 211 forks source link

API to read scene data #1628

Open Nokse22 opened 2 months ago

Nokse22 commented 2 months ago

Description

A method to read scene data from code, it should output a json with the available data about the loaded scene

Now when loading a scene with debug enabled it is already possible to read information

Example

Copied from the terminal

Found a reader for "/run/user/1000/doc/bf697a76/planet_reducer_animation.glb" : "GLTF"
Loading 3D scene: /run/user/1000/doc/bf697a76/planet_reducer_animation.glb

Animation(s) available in this file are:
0: Take 001

Animation(s) time range is: [0, 19.7333].
No camera available in this file

Object004__0 Primitive Geometry:
 Number of points: 624
 Number of polygons: 636
 Number of lines: 0
 Number of vertices: 0
 2 point data array(s):
   NORMAL : float : [-1, 1] [-1, 1] [-1, 1] 
   TEXCOORD_0 : float : [0.00139806, 0.283058] [0.493429, 0.950484] 
 0 cell data array(s):
 0 field data array(s):
Cylinder051__0 Primitive Geometry:
 Number of points: 810
 Number of polygons: 828
 Number of lines: 0
 Number of vertices: 0
 2 point data array(s):
   NORMAL : float : [-1, 1] [-1, 1] [-1, 1] 
   TEXCOORD_0 : float : [0.00139806, 0.283058] [0.493429, 0.950484] 
 0 cell data array(s):
 0 field data array(s):

Scene bounding box: 205.729,331.206,-97.0925,99.6823,-150.93,43.1112

Camera position: 268.468,1.29489,626.074
Camera focal point: 268.468,1.29489,-53.9092
Camera view up: 0,1,0
Camera view angle: 30

Using grid unit square size = 10
Grid origin set to [268.468, -97.1023, -53.9092]
mwestphal commented 2 months ago

This requires quite a bit of work but the will be possible in the middle term future.