Skip to content

Instantly share code, notes, and snippets.

View TimvanScherpenzeel's full-sized avatar

Tim van Scherpenzeel TimvanScherpenzeel

View GitHub Profile
@TimvanScherpenzeel
TimvanScherpenzeel / Thread.ts
Last active October 14, 2020 12:07
A re-usable thread implementation
// Implementation based on https://github.com/developit/greenlet and https://github.com/developit/task-worklet
class Thread {
private taskId = 0;
private promises: any = {};
private worker: Worker | null = new Worker(
URL.createObjectURL(
new Blob(
[
`(${() => {
@TimvanScherpenzeel
TimvanScherpenzeel / donations.md
Last active October 29, 2020 10:30
Donation addresses

ETH

BTC

@zeux
zeux / vertexcodec-comparison.txt
Last active May 23, 2019 16:45
Comparison of vertexcodec/indexcodec from meshoptimizer with Google Draco
Using fixed-point encoding for position (14 bits per component) and texture coordinates (12 bits per component), with 32-bit index buffer
and this vertex format:
// 12 bytes
struct PackedVertexOct
{
unsigned short px, py, pz;
unsigned char nu, nv; // octahedron encoded normal, aliases .pw
unsigned short tx, ty;
};
@butuzov
butuzov / Installing Google Test on Mac.md
Last active April 4, 2024 10:08
Bash Script to install Google Test and Google Mock on Mac

Installing Google Test on Mac

One bash script to install google test (and mock) on your Mac. I assume you already had install cmake (if not, use brew - brew install cmake).

It use brew directories to store gmock and gtest.

gtest_installer.sh

#!/usr/bin/env bash
#![feature(lang_items)]
#![no_std]
#[no_mangle]
pub fn add_one(x: i32) -> i32 {
x + 1
}
// needed for no_std
@mattdesl
mattdesl / about.md
Last active July 17, 2023 09:20
optimizing & de-duplicating geometry in GLTF files

optimize GLTF file

This optimizes a GLTF file that was exported by blender (or similar) by de-duplicating buffer views (i.e. chunks of bytes) that are equal and removing redundant accessors.

For example, 100 cubes of different scales/materials/rotations/etc should all end up using a single BufferGeometry in ThreeJS, which isn't the case with current GLTF exporters in Blender and parsers for ThreeJS.

In scenes with a lot of instancing, it can dramatically reduce total file size as well as render performance. In one test scene:

Before: 4.8MB file size, 832 THREE.Geometry instances across 832 THREE.Mesh objects
After: 661KB file size, 13 THREE.Geometry instances across 832 THREE.Mesh objects

@cdata
cdata / three-clone-gltf.js
Created November 8, 2017 23:26
A quick hack to clone a Three.js GLTF scene without re-loading or re-parsing the source.
const cloneGltf = (gltf) => {
const clone = {
animations: gltf.animations,
scene: gltf.scene.clone(true)
};
const skinnedMeshes = {};
gltf.scene.traverse(node => {
if (node.isSkinnedMesh) {
@zcaceres
zcaceres / How-to-build-a-VR-CommLink-with-Google-Daydream-Part-1.md
Created June 13, 2017 04:39
Part 1: Making NASA style Radio Transmissions with the Tuna.js and WebAudio API
@mattdesl
mattdesl / IceMaterial.js
Last active December 12, 2022 00:58
fast subsurface scattering in ThreeJS PBR material — see "TRANSLUCENCY" in the frag shader
const glslify = require('glslify');
const path = require('path');
const assign = require('object-assign');
const defined = require('defined');
// This is the original source, we will copy + paste it for our own GLSL
// const vertexShader = THREE.ShaderChunk.meshphysical_vert;
// const fragmentShader = THREE.ShaderChunk.meshphysical_frag;
// Our custom shaders
@kripken
kripken / hello_world.c
Last active January 17, 2024 12:15
Standalone WebAssembly Example
int doubler(int x) {
return 2 * x;
}