itowns icon indicating copy to clipboard operation
itowns copied to clipboard

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

Open Pourfex opened this issue 1 year ago • 1 comments

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

  • Version used: 2.40.0
  • Browser Name and version: Chrome 115 (tested on firefox aswell)
  • Operating System and version (desktop or mobile): mac / windows 11

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.

Pourfex avatar Aug 17 '23 13:08 Pourfex

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

AnthonyGlt avatar Dec 11 '23 14:12 AnthonyGlt