Skip to content

Instantly share code, notes, and snippets.

View Ctrlmonster's full-sized avatar

Brian Breiholz Ctrlmonster

View GitHub Profile
@Ctrlmonster
Ctrlmonster / Lod-fade-material.ts
Created May 14, 2025 07:18
Lod dither fade for mesh and batched mesh
// for regular meshes
import {ShaderMaterial, Vector2, Color, Texture} from "three";
export class LodFadeMaterial extends ShaderMaterial {
constructor(map: Texture, ditherOffset: number, ditherThreshold: number, invertMask: boolean, resolution: Vector2, color: Color) {
super({
uniforms: {
map: {value: map},
resolution: {value: resolution},
ditherOffset: {value: ditherOffset},
@Ctrlmonster
Ctrlmonster / compare-timeouts.js
Last active September 9, 2025 05:27
higher frequency setTimeout
// Copy paste these into your console to compare:
// ============================================================================
// setTimeout
// ============================================================================
// Measures time between back-to-back setTimeout(..., 0) callbacks
(function setTimeoutDiffTest(iterations = 200) {
let last = performance.now();
let i = 0;