iTowns / itowns

A Three.js-based framework written in Javascript/WebGL for visualizing 3D geospatial data
http://www.itowns-project.org
Other
1.06k stars 290 forks source link

iTowns npm usage : CameraUtils.js -> THREE.Object3D.DEFAULT_UP.set(0, 0, 1) set the axis for all ThreeJS usages #2169

Open Pourfex opened 10 months ago

Pourfex commented 10 months ago

In src/CameraUtils.js, there is a few const written and the line THREE.Object3D.DEFAULT_UP.set(0, 0, 1) Using itowns as an npm package set the THREE up axis for all three js usages. Let's say I'm making an app with threejs and itowns. I setup itwons to use the threejs of my app. This line of code change the up axis for the app threejs library.

This is a major problem as I don't want my threejs scenes (without iTowns) to have their axis change if I use iTowns in another scene.

Your Environment

Steps to Reproduce (for bugs)

Use itowns in any threejs project and link itowns threejs to the app threejs (no duplicate threejs)

Expected Behavior

iTowns should not change the axis of threejs of other scene on import. This kind of code should be on constructors.

Actual Behavior

iTowns change the axis of threejs of other scene on import.

Possible Cause/Fix/Solution

Don't use this line in camera utils but let iTowns scene to handle axis changes. Furthermore having const(s) at top of script will keep memory even if iTowns is not used in other ThreeJS scenes.

AnthonyGlt commented 6 months ago

By doing a quick testing, it's obvious that in planarview, there are issues with the camera. The rotation was wrong and unusable. Concerning the globeview, I don't remember seeing any impact... It could be interesting to understand why it was implemented like this and what are impacted. Maybe we could give the user the choice of the DEFAULT_UP