Skip to content

Instantly share code, notes, and snippets.

View CodyJasonBennett's full-sized avatar

Cody Bennett CodyJasonBennett

View GitHub Profile
@CodyJasonBennett
CodyJasonBennett / rollup.config.js
Last active October 16, 2021 19:17
Rollup - Advanced Vercel API
// rollup.config.js (builds src/api => api -- use `rollup -c` to build)
import { join } from 'path';
import { mkdirSync, copyFileSync, statSync, readdirSync } from 'fs';
import babel from '@rollup/plugin-babel';
import resolve from '@rollup/plugin-node-resolve';
const API_DIR = join(process.cwd(), 'src/api');
const BUILD_DIR = join(process.cwd(), 'api');
// Copy package.json to build dir
@CodyJasonBennett
CodyJasonBennett / index.js
Created September 2, 2021 04:52
3D de Casteljau algorithm
import { Vector3 } from 'https://cdn.skypack.dev/three';
const tempVector = new Vector3();
function deCasteljauAlgorithm(vectors, t) {
if (t === 1) return vectors[vectors.length - 1];
if (t === 0 || vectors.length === 1) return vectors[0];
const calculatedVectors = [];
@CodyJasonBennett
CodyJasonBennett / index.js
Last active September 2, 2021 02:46
2D de Casteljau algorithm
function deCasteljauAlgorithm(points, t) {
if (t === 1) return points[points.length - 1];
if (t === 0 || points.length === 1) return points[0];
const calculatedPoints = [];
for (let i = 1; i < points.length; i++) {
const [p1X, p1Y] = points[i - 1];
const [p2X, p2Y] = points[i];
@CodyJasonBennett
CodyJasonBennett / index.html
Last active September 19, 2021 20:26
THREE SSR Discord.js
<!DOCTYPE >
<html>
<head>
<meta charset="UTF-8" />
<style>
body {
margin: 0;
}
canvas {
@CodyJasonBennett
CodyJasonBennett / index.css
Created January 15, 2021 12:02
Chromakey Video three.js
body {
margin: 0;
}
canvas {
display: block;
}
video {
display: none;