Skip to content

Instantly share code, notes, and snippets.

View mahulst's full-sized avatar

Michel van der Hulst mahulst

  • Amsterdam
  • 22:02 (UTC +02:00)
View GitHub Profile
@mahulst
mahulst / cgltf.odin
Created April 4, 2025 18:23
loading a model using cgltf in odin
Vertex2 :: struct {
pos: Vec3,
color: Vec4,
uv: Vec2,
normal: Vec3,
}
data, result := cgltf.parse_file({}, "./assets/barrel.glb")
b := cgltf.load_buffers({}, data, "./assets/barrel.glb")
vertices: [dynamic]Vertex2 = make([dynamic]Vertex2)
module Main exposing (main)
import AnimationFrame
import Color exposing (Color)
import Html exposing (Html)
import Html.Attributes exposing (width, height, style)
import Math.Matrix4 as Mat4 exposing (Mat4)
import Math.Vector3 as Vec3 exposing (vec3, Vec3)
import Math.Vector4 as Vec4 exposing (vec4, Vec4)
import Time exposing (Time)
@mahulst
mahulst / vertexShader.glsl
Last active February 26, 2018 20:27
low poly vertex shader
void main () {
float y = calculateSurface(position.x, position.y);
vec3 p1 = vec3(vert1.x, calculateSurface(vert1.x, vert1.y), vert1.y);
vec3 p2 = vec3(vert2.x, calculateSurface(vert2.x, vert2.y), vert2.y);
vec3 p3 = vec3(vert3.x, calculateSurface(vert3.x, vert3.y), vert3.y);
vec3 normal = normalize(cross(p2 - p3, p1 - p2));
gl_Position = perspective * camera * vec4(vec3(position.x, y, position.y), 1.0);
vcolor = normal;
@mahulst
mahulst / GLSL-Noise.md
Created February 25, 2018 15:45 — forked from patriciogonzalezvivo/GLSL-Noise.md
GLSL Noise Algorithms

Generic 1,2,3 Noise

float rand(float n){return fract(sin(n) * 43758.5453123);}

float noise(float p){
	float fl = floor(p);
  float fc = fract(p);
	return mix(rand(fl), rand(fl + 1.0), fc);
}
@mahulst
mahulst / Haskell-Style-Guide.md
Created September 26, 2017 13:47 — forked from evancz/Haskell-Style-Guide.md
A style guide for Elm tools

Haskell Style Guide for Elm

Goal: a consistent style throughout all Elm projects that is easy to read and produces clean diffs to make debugging easier. This means valuing regularity and simplicity over cleverness.

Line Length

Keep it under 80 characters. Going over is not the end of the world, but consider refactoring before you decide a line really must be longer.

Variables

@mahulst
mahulst / RayTriangleIntersect.elm
Created September 16, 2017 10:02
rayTriangleIntersect
rayTriangleIntersect : Vec3 -> Vec3 -> ( Vec3, Vec3, Vec3 ) -> Maybe Vec3
rayTriangleIntersect rayOrigin rayDirection ( triangle0, triangle1, triangle2 ) =
let
epsilon =
0.000001
edge1 =
Vec3.sub triangle1 triangle0
edge2 =
@mahulst
mahulst / RayTriangleIntersect.elm
Last active September 16, 2017 10:02
rayTriangleIntersect
rayTriangleIntersect : Vec3 -> Vec3 -> ( Vec3, Vec3, Vec3 ) -> Maybe Vec3
rayTriangleIntersect rayOrigin rayDirection ( triangle0, triangle1, triangle2 ) =
let
epsilon =
0.000001
edge1 =
Vec3.sub triangle1 triangle0
edge2 =
@mahulst
mahulst / GetClickPosition.elm
Created September 16, 2017 10:02
getClickPosition
getClickPosition : Model -> Mouse.Position -> Vec3
getClickPosition model pos =
let
x =
toFloat pos.x
y =
toFloat pos.y
@mahulst
mahulst / LoginMsg.elm
Created June 7, 2017 08:26 — forked from ryan-senn/LoginMsg.elm
Update nesting
module Modules.Auth.Login.Msg exposing (..)
import Http exposing (Error)
import Types exposing (User)
type LoginMsg
= LoginUpdateEmail String
| LoginUpdatePassword String
import { DeviceTypeService, AnalyticsService } from './device-type.service';
import { Observable } from 'rxjs';
import { fakeAsync, tick } from '@angular/core/testing';
describe('DeviceTypeService', () => {
let stub: any = {}, service: DeviceTypeService;
beforeEach(() => {
// Create a stub for the analytics service
stub.AnalyticsService = jasmine.createSpyObj('AnalyticsService', [ 'trackDevices' ]);