New A-Frame location based components #405
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What kind of change does this PR introduce?
New. hopefully improved A-Frame components for location-based, plus enhancement of the three.js location-based code.
Can it be referenced to an Issue? If so what is the issue # ?
How can we test it?
I have added two test applications in the
examples
directory, one for A-Frame and one for three.js; these are in thenew-location-based
directory in each case.Summary
The existing location-based components are quite complex code-wise and (IMO) rather difficult to debug. There have been some long standing problems on some devices with location-based such as #275 which have been hard to fix. By simplifying the A-Frame location based components it is hoped that these problems can be resolved more readily.
So two new A-Frame components,
gps-new-camera
andgps-new-entity-place
, have been created, in thenew-location-based
directory. To avoid duplication of code, these actually wrap the three.js location-based code, which takes care of such things as projecting lat/lon into Spherical Mercator and converting to world coordinates. So to use these components, the three.js location-based code must be included in your project.Many of the existing properties of
gps-camera
have been inherited, includingsimulateLatitude
,simulateLongitude
,simulateAltitude
,gpsMinDistance
andpositionMInAccuracy
. However,minDistance
andmaxDIstance
have been removed as this functionality can be implemented using thenear
andfar
properties of the A-Frame camera.simulateLatitude
andsimulateLongitude
offer improved behaviour compared to the originals, as they did not appear to trigger agps-camera-update-position
event previously. Now they do, which makes it easier to implement code which works with real and simulated GPS.A new component
arjs-device-orientation-controls
has also been added. This is a lightweight wrapper around theDeviceOrientationControls
class within three.js location-based (which was in turn taken from three.js itself and modified). However note that this does not detect mouse movements so rotation will only work on a mobile device. The reason for this is to separate out orientation sensor movements and mouse movements; in tests I found that code in the A-Framelook-controls
component was interfering with the device orientation code, and figured that (for now) it was best to separate them out.Does this PR introduce a breaking change?
No as the new components have different names for now,
gps-new-camera
andgps-new-entity-place
. However my proposal is, that once they have been tested on a wide range of devices, to replacegps-projected-camera
andgps-projected-entity-place
with these new components.So if this happens, a few things will not work:
minDistance
andmaxDistance
deprecated; usenear
andfar
as detailed above.gps-camera-update-position
event is now emitted by the camera entity that thegps-new-camera
is attached to, rather than the window. So any code handling that event will need to be updated to take that into account.Please TEST your PR before proposing it. Specify here what device you have used for tests, version of OS and version of Browser
Linux desktop: Firefox and Chrome latest.
Mobile: Pixel 3, Android 12, running latest Chrome. Confirmed to display objects in the correct position in-the-field, and objects move as expected when you move round the real world.
Other information
n/a