Skip to content

Instantly share code, notes, and snippets.

View funwithtriangles's full-sized avatar

Alex Kempton funwithtriangles

View GitHub Profile
@funwithtriangles
funwithtriangles / index.js
Created March 26, 2020 13:21
Centering a fullscreen three.js video texture
import * as THREE from 'three'
const video = document.createElement('video')
export const vidTexture = new THREE.VideoTexture(video)
vidTexture.center.set(0.5, 0.5)
const resize = () => {
const wWidth = document.body.offsetWidth
const wHeight = document.body.offsetHeight
const vWidth = video.videoWidth
@funwithtriangles
funwithtriangles / index.js
Created March 9, 2020 02:39
random fibonacci sequence
const viswanath = 1.1319882487943
const numTurns = 5000
const posNeg = () => Math.random() > 0.5 ? 1 : -1
let prev = 1
let curr = 1
let temp
for (let i = 0; i < numTurns; i++) {
@funwithtriangles
funwithtriangles / index.js
Last active March 4, 2020 02:05
Raspberry Pi Node JS wifi and connection checker
const fs = require('fs')
const Wifi = require('rpi-wifi-connection')
const internetAvailable = require('internet-available')
const logIntervalMs = 1000 // 1000 * 60 * 10
const errIntervalMs = 5000
let lastLog = Date.now()
const wifi = new Wifi()
@funwithtriangles
funwithtriangles / index.html
Last active September 25, 2019 12:38
Reduced Test Case for 8th Wall Screenshot
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no, maximum-scale=1, user-scalable=no"/>
<title>Screenshot Test</title>
<style>
html, body {
height: 100%;
width: 100%;
@funwithtriangles
funwithtriangles / threePostProcessingPipelineModule.js
Created September 12, 2019 14:53
8th Wall custom postprocessing pipeline module
import { BloomEffect, EffectComposer, EffectPass, RenderPass } from 'postprocessing'
// Custom three pipeline module to try and implement postprocessing
// Can get scene rendering with camera feed background, but adding any other effect passes causes a white background
export const threePipelineModule = () => {
let scene3
return {
name: 'customthreemodule',
onStart: ({ canvas, canvasWidth, canvasHeight, GLctx }) => {
@funwithtriangles
funwithtriangles / threePipelineModule.js
Last active March 27, 2024 09:04
Custom 8th wall three pipeline module, which fixes a problem with the camera's projectionMatrixInverse. See line 33 for the fix.
// Custom three pipeline module because 8th wall's doesn't allow for custom renderer config
// also it has problems with raycasting when using three >= r103 because of this PR:
// https://github.com/mrdoob/three.js/pull/15996
const threePipelineModule = () => {
let scene3
return {
name: 'customthreemodule',
onStart: ({ canvas, canvasWidth, canvasHeight, GLctx }) => {
const scene = new window.THREE.Scene()