This file contains hidden or 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
import React from 'react' | |
import * as Animation from 'utils/Animation' | |
import * as MathUtils from 'math/utils' | |
import { Observable } from 'utils/Observable' | |
import { useComplexEffects } from 'utils/react' | |
import './Switch.css' | |
export const SimpleSwitch: React.FC<{ | |
index?: number | |
paths?: React.ElementType[] |
This file contains hidden or 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
const map = new Map() | |
export const addToBench = (msg, cb) => { | |
if (typeof msg === 'function') { | |
msg = msg.name | |
} | |
const index = map.size | |
map.set(msg, { | |
index, | |
msg, |
This file contains hidden or 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
export const clamp01 = x => x < 0 ? 0 : x > 1 ? 1 : x | |
export const clamp = (x, min = 0, max = 1) => x < min ? min : x > max ? max : x | |
export const lerp = (a, b, x) => a + (b - a) * clamp01(x) | |
export const inverseLerp = (x, min, max) => clamp01((x - min) / (max - min)) | |
export const map = (x, inMin, inMax, outMin, outMax) => lerp(outMin, outMax, inverseLerp(x, inMin, inMax)) |
This file contains hidden or 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
/** | |
* TO BE DISCUSSED. | |
* This is a little wrapper that allows to animate any "abstract" variable. | |
* Callback may be provided to react on any value change. | |
* "old" allows to know the "old" (previous) value. | |
*/ | |
type Callback = (variable: Variable) => void | |
export default class Variable { |
This file contains hidden or 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
import { WebGLRenderer, PerspectiveCamera, Scene } from 'https://threejs.org/build/three.module.js' | |
import { OrbitControls } from 'https://threejs.org/examples/jsm/controls/OrbitControls.js' | |
const renderer = new WebGLRenderer({ antialias: true }) | |
renderer.setPixelRatio(window.devicePixelRatio) | |
renderer.setSize(window.innerWidth, window.innerHeight) | |
document.body.append(renderer.domElement) | |
const camera = new PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 100) | |
camera.position.z = 5 |
This file contains hidden or 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
/** | |
* returns [1, 4, 12] from [4, 3, 2] | |
* @param {number[]} array | |
*/ | |
function getArrayScale (array) { | |
let scale = 1 | |
return array.map(dim => { | |
const x = scale | |
scale *= dim | |
return x |
This file contains hidden or 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
import fetch from 'node-fetch' | |
import fs from 'fs-extra' | |
const safeName = str => str.replace(/\W/g, '-') | |
const parseFontFace = fontFace => { | |
const [, url] = fontFace.match(/url\((.*?)\)/) | |
const [, family] = fontFace.match(/font-family: '(.*?)';/) | |
const [, style] = fontFace.match(/font-style: (.*?);/) | |
const [, weight] = fontFace.match(/font-weight: (.*?);/) |
This file contains hidden or 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
const removeHeadingWhitespaces = str => { | |
const lines = str.split('\n') | |
while (lines.length > 0 && /^\s*$/.test(lines[0])) { | |
lines.shift() | |
} | |
while (lines.length > 0 && /^\s*$/.test(lines[lines.length - 1])) { | |
lines.pop() |
This file contains hidden or 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
// https://gist.github.com/jniac/1f1b8e57dbb320138af00680c090f94e | |
const parser = new DOMParser() | |
const html = (strings, ...inserts) => { | |
if (typeof strings === 'string') { | |
// html is used as a regular function, eg: | |
// html(`<div>${foo}</div>`) |
This file contains hidden or 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
let VertigoCamera | |
const init = THREE => { | |
const { | |
Camera, | |
PerspectiveCamera, | |
OrthographicCamera, |
NewerOlder