-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec8534b
commit 6c26f5c
Showing
14 changed files
with
113 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Room DOM | ||
|
||
Because Aframe uses direct DOM elements as a source of truth and the Room page uses Aframe for its 3D environment, we must manage direct DOM interactions in our React code. | ||
|
||
> We tried [Aframe-React](https://github.com/supermedium/aframe-react) but ran into severe issues ([#5](https://github.com/karaokenite/karaokenite-react/issues/5); [#7](https://github.com/karaokenite/karaokenite-react/issues/7); [networked-aframe#226](https://github.com/networked-aframe/networked-aframe/issues/226)). | ||
## Static HTML | ||
|
||
We use a [Next.js custom `Document`](https://nextjs.org/docs/advanced-features/custom-document) to include: | ||
|
||
- Static Aframe library scripts: | ||
|
||
- When on the `/room` page, these are executed synchronously in a proper order. | ||
- When on any other page, they are loaded as `async` as a prefetching technique. | ||
|
||
- Raw Aframe elements on the page: | ||
|
||
- Placing then in the raw HTML ensures they already exist on the page by the time our scripts need them. | ||
- Our Aframe DOM template is stored in a [`template.html`](/src/pages/room/RoomBody/template.html) and loaded via Webpack's [`html-loader`](https://webpack.js.org/loaders/html-loader). | ||
|
||
## DOM Interactions | ||
|
||
Room DOM interactions are initialized by [`RoomEvents`](/src/pages/room/RoomEvents.ts), a `null`-returning component that sets React effect hooks to initialize DOM event listeners. | ||
Those listeners generally use [`react-use`'s `useEvent`](https://github.com/streamich/react-use/blob/master/docs/useEvent.md) to be automatically disposed when needed. | ||
|
||
> See [Client Room Context](./Client%20Room%20Context.md) for how those listeners interact with room state. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import { Entity } from "aframe"; | ||
import { mapValues } from "lodash"; | ||
|
||
import { controlIds, sceneSelector, videoElementId } from "./constants"; | ||
import * as constants from "./constants"; | ||
import { getElementById, querySelector } from "./queries"; | ||
import { Entity } from "aframe"; | ||
|
||
export const sceneElement = querySelector<Entity>(sceneSelector); | ||
export const environmentElement = querySelector<Entity>( | ||
constants.environmentSelector | ||
); | ||
|
||
export const sceneElement = querySelector<Entity>(constants.sceneSelector); | ||
|
||
export const videoElement = getElementById<Entity & HTMLVideoElement>( | ||
videoElementId | ||
constants.videoElementId | ||
); | ||
|
||
export const controls = mapValues(controlIds, getElementById); | ||
export const controls = mapValues(constants.controlIds, getElementById); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 5 additions & 1 deletion
6
src/pages/room/RoomEvents/useVideoControls/useTimeSynchronization.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters