// 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( | |
[ | |
`(${() => { |
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; | |
}; |
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.
#!/usr/bin/env bash
#![feature(lang_items)] | |
#![no_std] | |
#[no_mangle] | |
pub fn add_one(x: i32) -> i32 { | |
x + 1 | |
} | |
// needed for no_std |
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
const cloneGltf = (gltf) => { | |
const clone = { | |
animations: gltf.animations, | |
scene: gltf.scene.clone(true) | |
}; | |
const skinnedMeshes = {}; | |
gltf.scene.traverse(node => { | |
if (node.isSkinnedMesh) { |
Recently, I had the chance to design a small audio module for a space-themed WebVR simulation.
Many people don't know that browsers support a remarkable set of tools for creating and transforming audio files.
We wanted our space simulation to be as immersive as possible. The user experience was all about communication. So we needed immersive audio to match our VR.
Let's see how we can create immersive audio for our interstellar radio transmissions, using only the browser!
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 |
int doubler(int x) { | |
return 2 * x; | |
} |