Skip to content

Commit ad1b547

Browse files
committed
- feat: handle multiple locations
- fix: constants import - docs: updated Package doc
1 parent 137faeb commit ad1b547

File tree

8 files changed

+54
-43
lines changed

8 files changed

+54
-43
lines changed

docs/package.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ new Package({
1818
height: 1.0,
1919
depth: 1.0
2020
},
21-
latitude: 12.345678, // required for location based AR
22-
longitude: 12.345678 // required for location based AR
21+
locations: [
22+
{
23+
latitude: 12.345678, // required for location based AR
24+
longitude: 12.345678 // required for location based AR
25+
}
26+
]
2327
},
2428
markerPatt: '...', // the content of the generated .patt file, as a string (required for pattern/location based AR)
2529
matrixType: '...', // see exported MATRIX_* constants (required for barcode based AR)

src/modules/location/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
ASSET_IMAGE,
44
ASSET_AUDIO,
55
ASSET_VIDEO,
6-
} from '../../index';
6+
} from '../package/Package';
77

88
import location3dTemplate from './templates/location.3d.handlebars';
99
import locationImageTemplate from './templates/location.image.handlebars';

src/modules/location/templates/location.3d.handlebars

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@
2323
></a-asset-item>
2424
</a-assets>
2525

26-
<a-entity
27-
look-at="[gps-camera]"
28-
animation-mixer="loop: repeat"
29-
gltf-model="#animated-asset"
30-
scale="{{assetParam.scale}} {{assetParam.scale}} {{assetParam.scale}}"
31-
gps-entity-place="latitude: {{assetParam.latitude}}; longitude: {{assetParam.longitude}};"
32-
></a-entity>
26+
{{#each assetParam.locations}}
27+
<a-entity
28+
look-at="[gps-camera]"
29+
animation-mixer="loop: repeat"
30+
gltf-model="#animated-asset"
31+
scale="{{../assetParam.scale}} {{../assetParam.scale}} {{../assetParam.scale}}"
32+
gps-entity-place="latitude: {{this.latitude}}; longitude: {{this.longitude}};"
33+
></a-entity>
34+
{{/each}}
3335

3436
<a-camera gps-camera rotation-reader></a-camera>
3537
</a-scene>

src/modules/location/templates/location.audio.handlebars

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@
2121
response-type="arraybuffer"
2222
></a-asset-item>
2323
</a-assets>
24-
25-
<a-entity
26-
look-at="[gps-camera]"
27-
id="sound-entity"
28-
sound="src: #sound"
29-
emitsevent
30-
autoplay="false"
31-
gps-entity-place="latitude: {{assetParam.latitude}}; longitude: {{assetParam.longitude}};"
32-
></a-entity>
24+
25+
{{#each assetParam.locations}}
26+
<a-entity
27+
look-at="[gps-camera]"
28+
id="sound-entity"
29+
sound="src: #sound"
30+
emitsevent
31+
autoplay="false"
32+
gps-entity-place="latitude: {{this.latitude}}; longitude: {{this.longitude}};"
33+
></a-entity>
34+
{{/each}}
3335

3436
<a-camera gps-camera rotation-reader></a-camera>
3537
</a-scene>

src/modules/location/templates/location.image.handlebars

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
loading-screen="enabled: false;"
1515
arjs="sourceType: webcam; debugUIEnabled: false;"
1616
>
17-
<a-image
18-
src="{{assetPath}}"
19-
look-at="[gps-camera]"
20-
scale="{{assetParam.scale}} {{assetParam.scale}} {{assetParam.scale}}"
21-
gps-entity-place="latitude: {{assetParam.latitude}}; longitude: {{assetParam.longitude}};"
22-
></a-image>
17+
{{#each assetParam.locations}}
18+
<a-image
19+
src="{{assetPath}}"
20+
look-at="[gps-camera]"
21+
scale="{{../assetParam.scale}} {{../assetParam.scale}} {{../assetParam.scale}}"
22+
gps-entity-place="latitude: {{this.latitude}}; longitude: {{this.longitude}};"
23+
></a-image>
24+
{{/each}}
2325

2426
<a-camera gps-camera rotation-reader></a-camera>
2527
</a-scene>

src/modules/location/templates/location.video.handlebars

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,22 @@
2929
></video>
3030
</a-assets>
3131

32-
<a-video
33-
src="#vid"
34-
position='0 0.1 0'
35-
rotation="-90 0 0"
36-
look-at="[gps-camera]"
37-
videohandler
38-
smooth="true"
39-
smoothCount="10"
40-
smoothTolerance="0.01"
41-
smoothThreshold="5"
42-
autoplay="false"
43-
scale="{{assetParam.scale}} {{assetParam.scale}} {{assetParam.scale}}"
44-
gps-entity-place="latitude: {{assetParam.latitude}}; longitude: {{assetParam.longitude}};"
45-
></a-video>
32+
{{#each assetParam.locations}}
33+
<a-video
34+
src="#vid"
35+
position='0 0.1 0'
36+
rotation="-90 0 0"
37+
look-at="[gps-camera]"
38+
videohandler
39+
smooth="true"
40+
smoothCount="10"
41+
smoothTolerance="0.01"
42+
smoothThreshold="5"
43+
autoplay="false"
44+
scale="{{../assetParam.scale}} {{../assetParam.scale}} {{../assetParam.scale}}"
45+
gps-entity-place="latitude: {{this.latitude}}; longitude: {{this.longitude}};"
46+
></a-video>
47+
{{/each}}
4648

4749
<a-camera gps-camera rotation-reader></a-camera>
4850
</a-scene>

src/modules/marker/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
ASSET_IMAGE,
44
ASSET_AUDIO,
55
ASSET_VIDEO,
6-
} from '../../index';
6+
} from '../package/Package';
77

88
import { BarcodeMarkerGenerator } from './tools/barcode-marker-generator';
99
import { PatternMarkerGenerator } from './tools/pattern-marker-generator';

src/modules/package/Package.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ export const PACKAGE_GITHUB = 'github';
2626
* @property {boolean} isValid
2727
* @property {Number} scale
2828
* @property {{width: Number, height: Number, depth: Number}} size
29-
* @property {Number} [latitude] - only for location-based
30-
* @property {Number} [longitude] - only for location-based
29+
* @property {Array<{latitude: Number, longitude: Number}>} locations - an array of latitude/longitude locations, for location based AR
3130
*/
3231
const defaultAssetParam = {
3332
isValid: true,
@@ -46,7 +45,7 @@ export class Package {
4645
* @param {string} config.assetType - one of 3d, image, audio or video (see exported constants)
4746
* @param {string|Blob} config.assetFile - the file to be show in AR
4847
* @param {string} config.assetName - the file name, to be included in HTML template
49-
* @param {AssetParam} [config.assetParam] - scale and position of AR asset
48+
* @param {AssetParam} [config.assetParam] - parameters of AR asset
5049
* @param {string} [config.markerPatt] - the marker image patt file (required for pattern and location AR type)
5150
* @param {string} [config.matrixType] - the barcode matrix type (see {@link BarcodeMarkerGenerator} exported constants, required for barcode AR type)
5251
* @param {number} [config.markerValue] - the barcode value of the marker (required for barcode AR type)

0 commit comments

Comments
 (0)