This file contains 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
//from https://math.stackexchange.com/questions/296794/finding-the-transform-matrix-from-4-projected-points-with-javascript/339033#339033 | |
// and http://jsfiddle.net/dFrHS/1/ | |
function adj(m) { // Compute the adjugate of m | |
return [ | |
m[4]*m[8]-m[5]*m[7], m[2]*m[7]-m[1]*m[8], m[1]*m[5]-m[2]*m[4], | |
m[5]*m[6]-m[3]*m[8], m[0]*m[8]-m[2]*m[6], m[2]*m[3]-m[0]*m[5], | |
m[3]*m[7]-m[4]*m[6], m[1]*m[6]-m[0]*m[7], m[0]*m[4]-m[1]*m[3] | |
]; | |
} |
This file contains 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
<style> | |
html, body{ | |
width:100%; | |
height:100%; | |
overflow: hidden; | |
top:0; | |
left:0; | |
margin:0; | |
padding:0; | |
} |
This file contains 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
/** | |
* creates a noise on the specified 2d context's canvas | |
* @ctx a 2d context | |
* @rgba color code specifies which channels are affected (default = 0 ) | |
* @min noise lower bound ( >= 0 ) | |
* @max noise upper bound ( <= 0xFF ) | |
* */ | |
function noise( ctx, rgba, min, max ) | |
{ |
This file contains 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
#target illustrator | |
var document = app.activeDocument; | |
var maxLength = prompt ("maximum length of a path", 10, "destroy them with lasers!"); | |
for (i=0 ; i< document.pathItems.length; i++) | |
{ | |
var ipath = document.pathItems[i] | |
if( ipath.hidden == true )continue; | |
var l = 0; | |
for( var j = 0; j < ipath.pathPoints.length - 1; j++ ){ | |
var p0 = ipath.pathPoints[j].anchor; |
This file contains 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
var str = "# object mesh \n"; | |
g.toIndexed(); | |
var vs = g.getAttribute("position").array; | |
var ind = g.getIndex().array; | |
var precision = 6; | |
for( var i = 0 ; i < vs.length; i+=3 ){ |
This file contains 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
float hash( float n ) | |
{ | |
return fract(sin(n)*43758.5453); | |
} | |
float noise( vec3 x ) | |
{ | |
// The noise function returns a value in the range -1.0f -> 1.0f | |
vec3 p = floor(x); |
This file contains 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
/* | |
from : http://en.wikipedia.org/wiki/Mersenne_twister | |
*/ | |
let MT | |
let index | |
class PRNG { | |
static setSeed(seed) { | |
// Create a length 624 array to store the state of the generator | |
MT = new Uint32Array(624) | |
index = 0 |
This file contains 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
/** | |
original code https://gist.github.com/Dan-Piker/f7d790b3967d41bff8b0291f4cf7bd9e | |
need to declare the following: | |
uniform vec3 origin; | |
uniform float p; | |
uniform float q; | |
uniform float t; | |
*/ |
This file contains 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
var MercatorPlane = function() | |
{ | |
// create the material | |
var vs = "varying vec2 vUv;\nvoid main() {\n vUv = uv;\ngl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}"; | |
var fs = "uniform sampler2D map;\nvarying vec2 vUv;\n void main() {\nvec4 color = texture2D( map, vUv );\ngl_FragColor = color;\n}"; | |
var material = new THREE.ShaderMaterial({ | |
uniforms: { | |
map: { type: "t", value: null } |
This file contains 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 { | |
BufferAttribute, | |
Group, | |
InstancedBufferAttribute, | |
InstancedBufferGeometry, | |
Mesh, | |
MeshStandardMaterial, | |
Vector3, | |
} from "three"; | |
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader.js"; |