Skip to content

Instantly share code, notes, and snippets.

View yelouafi's full-sized avatar

Yassine Elouafi yelouafi

View GitHub Profile
@yelouafi
yelouafi / InstancedBatchedSkinnedMesh.js
Created September 27, 2024 09:23
InstancedBatchedSkinnedMesh
// from https://x.com/Cody_J_Bennett/status/1818025947565584873
// demo https://jsfiddle.net/cbenn/Las0poyu
import * as THREE from "three";
import Stats from "three/addons/libs/stats.module.js";
import { OrbitControls } from "three/addons/controls/OrbitControls.js";
import { GLTFLoader } from "three/addons/loaders/GLTFLoader.js";
import { mergeVertices } from "three/addons/utils/BufferGeometryUtils.js";
THREE.ShaderChunk.skinning_pars_vertex =
var $jscomp = $jscomp || {};
$jscomp.scope = {};
$jscomp.arrayIteratorImpl = function (h) {
var n = 0;
return function () {
return n < h.length ? { done: false, value: h[n++] } : { done: true };
};
};
$jscomp.arrayIterator = function (h) {
return { next: $jscomp.arrayIteratorImpl(h) };
@yelouafi
yelouafi / gist:e25b8ebc7b0b52dd4268f0d7b53040e6
Last active June 8, 2022 19:04 — forked from blackslate/gist:695cf7e76348c4948db7
Demo of using project() and unproject() to drag an object parallel to the camera plane
<!DOCTYPE html>
<html>
<head>
<title>THREE.JS WORLD</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r73/three.js"></script>
<style>
body {
/* set margin to 0 and overflow to hidden, to
use the complete page */
{-# Language TypeSynonymInstances, FlexibleInstances #-}
module Algj where
import Debug.Trace
import Data.Maybe
import qualified Data.Map as M
import qualified Data.Set as S
import Control.Monad.Trans.State
{-# Language TypeSynonymInstances, FlexibleInstances #-}
module Algw where
import Data.Maybe
import qualified Data.Map as M
import qualified Data.Set as S
import Control.Monad.Trans.State
@yelouafi
yelouafi / algebraic-effects-series-4.md
Last active March 1, 2024 15:31
Implementing Algebraic Effects and Handlers

Algebraic Effects in JavaScript part 4 - Implementing Algebraic Effects and Handlers

This is the final part of a series about Algebraic Effects and Handlers.

So we've come to the core topic. The reality is that we've already covered most of it in the previous parts. Especially, in the third part, where we saw delimited continuations at work.

@yelouafi
yelouafi / algebraic-effects-series-3.md
Last active April 19, 2023 06:07
Delimited Continuations
@yelouafi
yelouafi / algebraic-effects-series-2.md
Last active April 19, 2023 08:20
Capturing continuations with Generators

Algebraic Effects in JavaScript part 2 - Capturing continuations with Generators

This is the second part of a series about Algebraic Effects and Handlers.

Note: initially I planned a 3-part series, but since the current post on undelimited continuations ended up taking

@yelouafi
yelouafi / multishot-callcc.js
Created September 21, 2018 17:05
multi shot continuations
function isGenerator(x) {
return x != null && typeof x.next === "function"
}
function isFrame(x) {
return x != null && x._type_ === 'call_frame'
}
function call(genFunc, ...args) {
@yelouafi
yelouafi / algebraic-effects-series-1.md
Last active November 12, 2024 15:47
Operational Introduction to Algebraic Effects and Continuations

Algebraic Effects in JavaScript part 1 - continuations and control transfer

This is the first post of a series about Algebraic Effects and Handlers.

There are 2 ways to approach this topic:

  • Denotational: explain Algebraic Effects in terms of their meaning in mathematics/Category theory
  • Operational: explain the mechanic of Algebraic Effects by showing how they operate under a chosen runtime environment

Both approaches are valuables and give different insights on the topic. However, not everyone (including me), has the prerequisites to grasp the concepts of Category theory and Abstract Algebra. On the other hand, the operational approach is accessible to a much wider audience of programmers even if it doesn't provide the full picture.