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
// install prot globally https://github.com/mattdesl/prot | |
import React, { Component } from 'react' | |
import ReactDOM from 'react-dom' | |
import { scaleTime } from 'd3-scale' | |
import format from 'd3-time-format' | |
function VerticalLine({ x, height, stroke="#888" }) { | |
return <line | |
x1={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
export function wrapTextCanvas(context, text, x, y, maxWidth, lineHeight, drawFlag = true) { | |
const cars = text.split('\n') | |
for (let ii = 0; ii < cars.length; ii++) { | |
let line = '' | |
const words = cars[ii].split(' ') | |
for (let n = 0; n < words.length; n++) { | |
const testLine = line + words[n] + ' ' | |
const metrics = context.measureText(testLine) |
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 defined from 'defined' | |
const TO_PX = 35.43307 | |
const DEFAULT_SVG_LINE_WIDTH = 0.03 | |
export function shapesToSVG(shapes, opt = {}) { | |
const dimensions = opt.dimensions | |
if (!dimensions) throw new TypeError('must specify dimensions currently') | |
const decimalPlaces = 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
import { projectionMatrix, viewMatrix } from './turntable-camera' | |
import mouseChange from 'mouse-change' | |
import mouseWheel from 'mouse-wheel' | |
import identity from 'gl-mat4/identity' | |
import key from 'key-pressed' | |
// const isBrowser = typeof window !== 'undefined' | |
const getStartingState = (initialStatePlusOptions) => ({ | |
view: identity(new Float32Array(16)), |
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
precision mediump float; | |
uniform sampler2D satellite0; | |
uniform sampler2D satellite1; | |
uniform sampler2D satellite2; | |
uniform sampler2D satellite3; | |
uniform sampler2D elevation; | |
varying vec2 vUv; |
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 emptyTextureDimension = { | |
width: 512, | |
height: 512, | |
channels: 3, | |
} | |
function loadImageIntoTexture(url, texture) { | |
const image = new Image() | |
image.crossOrigin = 'anonymous' | |
image.src = url |
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
// ES6 port of famous mbostock's word wrap https://bl.ocks.org/mbostock/7555321 | |
export function wrap(_text, width, lineHeightEm = 1.1) { | |
_text.each(function () { | |
const text = select(this) | |
const words = text.text().split(/\s+/).reverse() | |
const y = text.attr('y') | |
const dy = parseFloat(text.attr('dy')) || 0 | |
let tspan = text.text(null).append('tspan').attr('x', 0).attr('y', y).attr('dy', dy + 'em') | |
let line = [] |
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 createRegl from 'regl' | |
import createCamera from 'regl-camera' | |
import bunny from 'bunny' | |
import normals from 'angle-normals' | |
const regl = createRegl() | |
const camera = createCamera(regl, { | |
minDistance: 0.01, | |
distance: 20, | |
maxDistance: 30, |
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
// quaternion code from https://github.com/stackgl/gl-quat | |
// rotation from https://twistedpairdevelopment.wordpress.com/2013/02/11/rotating-a-vector-by-a-quaternion-in-glsl/ | |
precision mediump float; | |
uniform mat4 projection, view; | |
uniform vec3 translate; | |
uniform vec3 scale; | |
attribute vec3 normal; |
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
// inspired by toxiclibs | |
// https://bitbucket.org/postspectacular/toxiclibs/src/44d9932dbc9f9c69a170643e2d459f449562b750/src.core/toxi/geom/mesh/TriangleMesh.java?at=default&fileviewer=file-view-default#TriangleMesh.java-703 | |
const vec3 = require('gl-vec3') | |
const mat3 = require('gl-mat3') | |
const mat4 = require('gl-mat4') | |
const quat = require('gl-quat') | |
function transform(matrix, v) { | |
const temp = mat3.create() |