Skip to content

Instantly share code, notes, and snippets.

@simonghales
simonghales / revised.ts
Last active March 23, 2024 23:26
Running a game loop on a web worker
export const createNewPhysicsLoopWebWorker = (stepRate: number) => {
return new Worker('data:application/javascript,' +
encodeURIComponent(`
var start = performance.now();
var updateRate = ${stepRate};
function getNow() {
return start + performance.now();
}
@simonghales
simonghales / README.md
Created January 22, 2021 02:49
addExternalBabelPlugin not working for customize-cra (react app rewired) alternative solution

this wasn't working:

const { override, addExternalBabelPlugin } = require('customize-cra');

module.exports = override(addExternalBabelPlugin('babel-plugin-react-engine'))

this instead worked:

@simonghales
simonghales / README.md
Last active January 20, 2021 09:35
threejs positional audio with stream via web sockets

Just chucking up a random gist to document that if you're trying to create a positional audio in threejs via a stream that's passed in remotely (i.e. not initiated within the current browser) then you will need to create a new Audio (not threejs Audio, the native browser Audio) object and set the srcObject to the stream.

I suspect this activates the stream. Whereas a locally initiated stream is already active, hence why some of the examples I found demo'ing setMediaStreamSource worked, because the stream was local.

So here's my code to demonstrate this.