Skip to content

Instantly share code, notes, and snippets.

View DennisSmolek's full-sized avatar

Dennis Smolek DennisSmolek

View GitHub Profile
@DennisSmolek
DennisSmolek / RenderTargetToIMG.ts
Last active October 15, 2025 22:14
Threejs render target utils
export function renderTargetToImageData(
renderTarget: THREE.WebGLRenderTarget,
renderer: THREE.WebGLRenderer
): ImageData {
// get the height and width
const height = renderTarget.height;
const width = renderTarget.width;
const buffer = new Uint8Array(width * height * 4);
@DennisSmolek
DennisSmolek / useVariants.ts
Created October 2, 2024 13:40
useVariants() draft
// this hook wraps a gltf and allows the use of the khr variants extension
import { useMemo, useState, useEffect, useCallback } from "react";
import type { GLTF } from "../../types/gltf";
import type { Material, Mesh } from "three";
/* What I want to return is an object like { variants, activeVariant, setVariant, materials}*/
export const useVariants = (model: GLTF, inVariant: string) => {
// states
const [activeVariant, setActiveVariant] = useState<string | null>(null);
@DennisSmolek
DennisSmolek / ExtraSuspense.tsx
Last active September 18, 2024 09:34
Adds event notification for the suspense with a little delay
// This creates a wrapper around suspense to notify when the transition takes place
import {
Suspense as ReactSuspense,
useState,
useEffect,
useCallback,
useMemo,
useRef,
} from "react";
@DennisSmolek
DennisSmolek / CloudsResources.md
Created April 11, 2022 17:14 — forked from pixelsnafu/CloudsResources.md
Useful Resources for Rendering Volumetric Clouds

Volumetric Clouds Resources List

  1. A. Schneider, "Real-Time Volumetric Cloudscapes," in GPU Pro 7: Advanced Rendering Techniques, 2016, pp. 97-127. (Follow up presentations here, and here.)

  2. S. Hillaire, "Physically Based Sky, Atmosphere and Cloud Rendering in Frostbite" in Physically Based Shading in Theory and Practice course, SIGGRAPH 2016. [video] [course notes] [scatter integral shadertoy]

  3. [R. Högfeldt, "Convincing Cloud Rendering – An Implementation of Real-Time Dynamic Volumetric Clouds in Frostbite"](https://odr.chalmers.se/hand

@DennisSmolek
DennisSmolek / README.md
Created June 20, 2021 09:03 — forked from astamicu/Remove videos from Youtube Watch Later playlist.md
Script to remove all videos from Youtube Watch Later playlist

UPDATED 3.12.2020

The old version of youtube with "disable_polymer" is not working anymore, so the script also stopped working.

Thanks to JanTheDeveloper we have a new working script. Big up!

I just changed the '//span[contains(text(),"Watch later")]', to '//span[contains(text(),"Remove from")]', and it should work for any playlist, not just the watch later one. (thanks to hudsonite for the tip)

setInterval(function () {
 document.querySelector('#primary button[aria-label="Action menu"]').click();
@DennisSmolek
DennisSmolek / gist:c1b74f3b7fa6a81cdcc79173ee3de515
Created February 19, 2018 14:06
key$ Observable Operator for Firebase & AngularFire2
// == Custom observable operator to get firebase keys onto a stream with the standard valueChanges()
// Code based on: https://github.com/ReactiveX/rxjs/blob/master/doc/operator-creation.md
export function key$() {
// We *could* do a `var self = this;` here to close over, but see next comment
return Observable.create(subscriber => {
// because we're in an arrow function `this` is from the outer scope.
// var source = this;
// save our inner subscription
var subscription = this.subscribe(value => {
// important: catch errors from user-provided callbacks