Skip to content

Instantly share code, notes, and snippets.

@mrdoob
mrdoob / gist:9d7d348131fa875e729451282822033f
Created January 18, 2023 05:55
chrome://gpu MacBook Air M1
Graphics Feature Status
Canvas: Hardware accelerated
Canvas out-of-process rasterization: Disabled
Direct Rendering Display Compositor: Disabled
Compositing: Hardware accelerated
Multiple Raster Threads: Enabled
OpenGL: Enabled
Rasterization: Hardware accelerated
Raw Draw: Disabled
Video Decode: Hardware accelerated
@mrdoob
mrdoob / WebAudio.js
Last active February 14, 2024 05:02
HTMLAudioElement polyfill using the WebAudio API with seamless loop support in Safari.
/**
* @author mrdoob / http://mrdoob.com/
*/
function WebAudio( context ) {
if ( context === undefined ) {
context = WebAudio.context;
@mrdoob
mrdoob / index.html
Created April 23, 2021 15:15
11 years of Three.js
<html>
<head>
<style>
body {
margin: 0;
padding: 10px;
color: #ffffff;
background: #222222;
font-family: sans-serif;
font-size: 7px;
@mrdoob
mrdoob / treeshaking.sh
Created February 17, 2021 19:29
Test module treeshaking
echo "import { Matrix4 } from './src/math/Matrix4.js'" | npx rollup -f es
@mrdoob
mrdoob / README.md
Created December 23, 2020 10:23
Three.js Converters (Node.js)

Utilities for converting model files to the Three.js JSON format. It's necessary to install the esm npm package before you can use the converters.

obj2three.js

Usage:

node -r esm obj2three.js model.obj
@mrdoob
mrdoob / gist:00e94d2934246c1fa32a52d39fa63776
Created November 11, 2020 22:34
Raindrops in Emergency Light by Citavia
data:text/html,<canvas id=R style=width:99%;background:navy><script>setInterval("s=Math.sin;q= Math.sqrt;d=(N,M,O,a)=>1/q((N-x+50-a/2)**2+(M-y+50-a%2)**2+(O-z+o)**2);f=a=>d(i,j,k,a)+d(j,-i,i,a)+d(k,i,-j,a)-.1-A;O=R.getContext('2d');i=s(n/2)* o;j=s(n+=.1)*o;k=s(n/3)*o;for(y=h;y--;)for(x=h;x--;){B=m=z=-o;for(r=9;m++;z+=r)A=0,A=f(0),A*B<0&&(r/=-2),B=A;z++;Z=f(0);z--;C=f(2)/Z;D=f(1)/Z;O.fillStyle='rgb('+s(n)*o/q(C*C+D*D)+',0,'+(C*h+n^D*h+n)+')';O.fillRect(x+h,y+o,1,1)}",n=o=25,h=99)</script>
@mrdoob
mrdoob / responsive_imagemap.js
Last active February 14, 2024 05:02
Responsive image map coords
// @mrdoob: Can't believe image maps aren't responsive
window.onload = function () {
var image = document.getElementById( 'image' );
var delta = image.clientWidth / 1024;
var map = document.getElementById( 'map' );
var areas = map.getElementsByTagName( 'area' );
@mrdoob
mrdoob / convert.bash
Last active June 7, 2020 02:49
Batch convert draco/basis
for i in *.obj; do ../../draco/draco_encoder -i "$i"; done
for i in *.jpg; do sips -Z 2048 -s format png "$i" --out "$i".png; done
for i in *.png; do ../../basis/basisu -file "$i"; done
@mrdoob
mrdoob / stack.js
Created June 4, 2020 23:28
Log the stack trace of a function
try { throw new Error; }
catch(e) {
console.log(e.stack);
}
@mrdoob
mrdoob / html2canvas.js
Created March 9, 2020 23:36
Paints a HTML node into a <canvas> (Very basic CSS support)
/**
* @author mrdoob / http://mrdoob.com/
*/
function html2canvas( element ) {
var range = document.createRange();
function Clipper( context ) {