Skip to content

Instantly share code, notes, and snippets.

View w8r's full-sized avatar
💭
learning

Alexander Milevski w8r

💭
learning
View GitHub Profile
@birkir
birkir / Cube.tsx
Created September 2, 2019 14:42
react native react-three-fiber
function Cube({ position }: { position?: number[] | THREE.Vector3 }) {
const mesh = useRef<THREE.Mesh>();
const touched = useTouch(mesh);
return (
<mesh ref={mesh} castShadow receiveShadow position={position}>
<boxGeometry attach="geometry" args={[1, 1, 1]} />
<meshStandardMaterial
attach="material"
color={touched ? 0xff0000 : 0xffffff}
//
// CatmullRomLength()
//
//
//*******************************************************************************************
template <typename T>
T CatmullRomLength( const CVector2<T> &p0,
const CVector2<T> &p1,
const CVector2<T> &p2,
const CVector2<T> &p3,
@petrsm
petrsm / gist:d47be1fbd0f240b5051bdc81cb62f79e
Created November 22, 2017 08:28
2D point projection onto cubic (Catmull-Rom) curve
//
// CatmullRomCurveProjectPt()
//
//
//*******************************************************************************************
template <typename T>
T CatmullRomCurveProjectPt( const CVector2<T> &p0,
const CVector2<T> &p1,
const CVector2<T> &p2,
const CVector2<T> &p3,
@grahamboree
grahamboree / Quadtree.cs
Created November 15, 2017 17:25
Generic Loose Quadtree for Unity
using System.Collections.Generic;
using UnityEngine;
public interface QuadtreeItem {
Rect GetBounds();
}
public class QuadtreeNode<T> where T : QuadtreeItem {
const int MAX_DEPTH = 10;
@bberak
bberak / Bunny.js
Created October 18, 2017 12:34
How to use regl in React or React Native
import React, { PureComponent } from "react";
import { StyleSheet } from "react-native";
import ReglView from "./ReglView";
import mat4 from "gl-mat4";
import bunny from "bunny";
export default class Bunny extends PureComponent {
drawCommand = regl => {
return regl({
vert: `
@max-mapper
max-mapper / bibtex.png
Last active March 10, 2024 21:53
How to make a scientific looking PDF from markdown (with bibliography)
bibtex.png
@rpgove
rpgove / .block
Last active January 10, 2023 06:29
Force-directed layout
license: gpl-3.0
height: 600
@armollica
armollica / .DS_Store
Last active July 16, 2018 11:31
World Tour along Flying Arcs
@veltman
veltman / README.md
Last active November 25, 2019 20:16
Smoother polygon transitions

Smooth transitioning US tour in the same vein as this example. Steps:

  1. Compares both shapes and adds evenly-spaced points to whichever polygon has fewer so that both have the same number of points
  2. Picks the winding of the first polygon that minimizes the sum of the squared distances between point pairs

Some possible improvements:

  • Adding additional points to both shapes first such that every segment longer than a certain distance is bisected
  • Tweaking the placement of added points with simulated annealing
  • Using a cost function that factors in self-intersections at the halfway mark in addition to distance traveled
@marcin-chwedczuk
marcin-chwedczuk / btree.js
Created May 30, 2016 15:26
BTree implementation in JavaScript
#!/usr/bin/env node
const NKEYS = 4;
function arrayOfSize(size) {
var a = Array(size);
for (var i = 0; i < size; i += 1)
a[i] = null;