Skip to content

Commit

Permalink
Convert beacon.js to TypeScript
Browse files Browse the repository at this point in the history
  • Loading branch information
steinbro committed Nov 20, 2024
1 parent ce7fc2d commit edc5f90
Show file tree
Hide file tree
Showing 10 changed files with 245 additions and 177 deletions.
6 changes: 3 additions & 3 deletions src/components/BeaconController.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<p v-if="beacon.name">
<p v-if="beacon.location">
<button
id="toggleBeacon"
class="beacon-button"
Expand All @@ -8,7 +8,7 @@
>
{{ beacon.enabled ? '⏸' : '▶' }}
</button>
<span id="currentBeacon">{{ beacon.name }}</span>
<span id="currentBeacon">{{ beacon.location.name }}</span>
<button
class="beacon-button"
id="clearBeacon"
Expand All @@ -21,7 +21,7 @@
</template>

<script setup>
import { beacon } from '../state/beacon.js';
import { beacon } from '../state/beacon';
const toggleBeacon = () => {
if (beacon.enabled) {
Expand Down
12 changes: 6 additions & 6 deletions src/components/CalloutList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,18 @@

<script setup>
import BeaconController from './BeaconController.vue'
import { beacon } from '../state/beacon.js';
import { beacon } from '../state/beacon';
const props = defineProps({
callouts: Array,
})
const startBeacon = (e) => {
beacon.set(
e.target.getAttribute("data-name"),
e.target.getAttribute('data-latitude'),
e.target.getAttribute('data-longitude')
);
beacon.set({
name: e.target.getAttribute("data-name"),
latitude: e.target.getAttribute('data-latitude'),
longitude: e.target.getAttribute('data-longitude')
});
beacon.start();
};
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/components/WelcomeScreen.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</template>

<script setup>
import { beacon } from '../state/beacon.js';
import { beacon } from '../state/beacon';
import { useDeviceOrientation } from "../composables/compass.js";
import { myLocation } from '../state/location';
import { initializeAudioQueue, playSpatialSpeech } from '../state/audio';
Expand Down
5 changes: 3 additions & 2 deletions src/state/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,10 @@ export function createSpatialPlayer(): SpatialPlayer {
// Create a WebAudio panner with the settings that will be used by both
// beacons and callouts.
// https://developer.mozilla.org/en-US/docs/Web/API/PannerNode
export function createPanner(audioContext: AudioContext): PannerNode & {
export type PannerNodeWithCoordinates = PannerNode & {
setCoordinates: (x: number, y: number) => void;
} {
}
export function createPanner(audioContext: AudioContext): PannerNodeWithCoordinates {
const panner = audioContext.createPanner();
panner.panningModel = "HRTF";
// Keep a constant volume regardless of distance from source.
Expand Down
162 changes: 0 additions & 162 deletions src/state/beacon.js

This file was deleted.

Loading

0 comments on commit edc5f90

Please sign in to comment.