heremaps / harp.gl

3D web map rendering engine written in TypeScript using three.js
Apache License 2.0
1.29k stars 197 forks source link

MapView scene's up direction appears to be parallel to the map (tiles) #1373

Closed harrycollin closed 4 years ago

harrycollin commented 4 years ago

I've noticed that the MapView.scene is rotated perpendicular relative to the map (tiles). In a test, I positioned two cubes two units apart on the Z axis (these cubes exist in the MapView.scene). I believe the expected result here is to see two cubes parallel to the map (tiles) 2 units apart. In fact the result shows two cubes positioned two units apart going up, perpendicular to the map (tiles) .

Here I've added a grid helper & axis helper to the MapView scene 81de421bfff8d7c864c7da6bd484e0bf

Is this normal behaviour?

nzjony commented 4 years ago

hi @HHammerite thanks again for your issue and engagement in our project! You can see how we translate geocoordinates to world positions in the function: projectPoint. For example if you look at the MercatorProjection implementation, then the longitude is put in the x coordinate, the latitude in the y, and the altitude in the z component. If you look at the surfaceNormal you will also see that for the MercatorProjection you get the vector 0,0,1. So, if you add to the z component of an object I would expect it to have some altitude as you see in your example. Did I understand your problem correctly?

harrycollin commented 4 years ago

Hi @nzjony, thanks again for your fast response. I believe you've understood it :) I must admit I don't fully understand your comment. Was it by design that the coordinates lat, long are on the X & Y axis?

nzjony commented 4 years ago

@HHammerite , no worries, we also have a slack space if you want a quicker response: https://heredev.slack.com/messages/harpgl/. TBH I don't know exactly, I think it is because most planar projections project latitude / longitude to x / y, and to support 3D we just add the z component. It would be possible to swap, y and z, but then we would need to have different code for projection, so this is the easiest way to support both use cases.

harrycollin commented 4 years ago

@nzjony Thank you for the slack invitation, however I can't join and get prompted to contact an admin. As for the X/Y projection it makes sense if the majority of projections use that system.

I've managed to work around it for the moment. I found this issue whilst I was trying to set the MapView.pointOfView camera's (orbit camera) up to (0, 0, 1), allowing me to orbit a MapAnchor in a natural way. It was only until I added the camera to the MapView.mapAnchors node that this worked and I was able to use orbit controls normally.

^^ That part was a little un-related but someone else might find it useful.

Could I get an invitation to the slack workspace?

nzjony commented 4 years ago

@HHammerite , opps, I used the wrong link, try: http://t.her.is/slack.

Maybe this is an issue with the pointOfView, because when you set it, it should update automatically. My guess is that by adding it to the mapAnchors node, internally the matrices are updated, see: https://threejs.org/docs/#manual/en/introduction/How-to-update-things .

I will create an issue: #1377

harrycollin commented 4 years ago

@nzjony Thanks for the invitation! As for the camera controls, it was behaving really strange, I do recall updating the matrices on it with no luck. However, I will try again with the instructions on the link you sent.

harrycollin commented 4 years ago

@nzjony It turns out the adding the camera to mapAnchors wasn't related to the issue at hand. I hope I didn't create a witchhunt for something that might not exist :/ I'm not entirely sure what was happening if I have to be honest.

harrycollin commented 4 years ago

Feel free to close this issue if there is nothing else to be added here :)

nzjony commented 4 years ago

@HHammerite , all good, I was also recently using the MapView.pointOfView in #1224 and had some issues, so I think it is still worth investigating how we can make the interface easier to use, it is definitely a cool debug feature.

thanks again for your interest in harp.gl and I will close this issue.