mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
103.09k stars 35.42k forks source link

Examples: OrthographicCamera instantiation #29024

Closed WestLangley closed 2 months ago

WestLangley commented 4 months ago

Description

Below are two example files that instantiate an OrthographicCamera by passing pixel units into the constructor. The units should be scene units.

FBXLoader.js

https://github.com/mrdoob/three.js/blob/ddd1bc654db5fdc3f58a5cbc689065b26864add0/examples/jsm/loaders/FBXLoader.js#L1097

After reading the FBX spec, it is not clear to me how to fix this...

misc_exporter_gltf.html

https://github.com/mrdoob/three.js/blob/ddd1bc654db5fdc3f58a5cbc689065b26864add0/examples/misc_exporter_gltf.html#L371

In addition to the pixel issue, the far plane is too limiting, and the camera position likely needs to be changed.

Related: the glTF spec says the near plane distance must be non-negative.

Reproduction steps

n/a

Code

see above

Live example

n/a

Screenshots

No response

Version

r167

Device

No response

Browser

No response

OS

No response

WestLangley commented 2 months ago

misc_exporter_gltf.html

It appears the exported OrthographicCamera does not render correctly on any online viewer that supports camera selection.

Is anyone interested in having a look at this?

FBXLoader.js

Is anyone interested in maintaining FBXLoader?

Mugen87 commented 2 months ago

I have tried fixing the issue in misc_exporter_gltf but I'm unsure about a proper fix for FBXLoader. Maybe one could use the dimensions of the asset's bounding box to derive a frustum size but even then I don't know if that is what the FBX spec expects from importers.

Mugen87 commented 2 months ago

How about we remove support for orthographic cameras from FBXLoader and print a warning instead?

Right now, I doubt the view frustum is correct so no developer should rely on exporting scenes with orthographic cameras to FBX and importing them via FBXLoader. The code path for perspective cameras looks good, btw.

Besides, if a developer is going to file a bug in the future because of the warning, we at least have a FBX asset with an orthographic camera definition which should make debugging easier.