Skip to content

Instantly share code, notes, and snippets.

@nicoptere
nicoptere / float triplets sorting method
Last active August 29, 2015 14:08
sorting triplets of floats in a buffer (vertices, indices, normals etc. ) using the QuickSort method.
/*
the quick sort method is described here :
http://antjanus.com/blog/web-development-tutorials/understanding-quicksort-js-native-implementation/
*/
function tripletSort( arr )
{
@nicoptere
nicoptere / bitmasking
Created October 14, 2014 16:00
bit masking, basic operations
/**
* checks if a value has a given bit set to 1
* @value the int / uint to test
* @mask the bits to check
**/
function bit_isset( value, mask )
{
return ( value & mask ) != 0;
}
@nicoptere
nicoptere / THREE.js lon_lat_to_cartesian
Last active January 16, 2023 09:56
methods to convert longitude / latitude to XYZ and back + utility polygon contains point for THREE.js
/**
* converts a XYZ vector3 to longitude latitude (Direct Polar)
* @param lng longitude
* @param lat latitude
* @param vector3 optional output vector3
* @returns a unit vector of the 3d position
*/
function lonLatToVector3( lng, lat, out )
{
out = out || new THREE.Vector3();
@nicoptere
nicoptere / imageProxy.php
Last active December 27, 2023 17:30
basic PHP image proxy (that works ... )
<?php
$url = "";
if( isset( $_GET['url'] ) )
{
$url = $_GET[ 'url' ];
}
else
{
@nicoptere
nicoptere / PRNG
Last active February 6, 2020 08:32
Mersenne Twister: a good Pseudo Random Number Generator ( PRNG )
/*
from : http://en.wikipedia.org/wiki/Mersenne_twister
*/
let MT
let index
class PRNG {
static setSeed(seed) {
// Create a length 624 array to store the state of the generator
MT = new Uint32Array(624)
index = 0
@nicoptere
nicoptere / lol()
Last active August 29, 2015 14:05
lol() : improving the console.log through dynamic LULZ injection
/**
* lol()
* improving the console.log through dynamic LULZ injection
*
* history
* - v0.0 RC - 2014-08-08 - 13h01 : initial release
* - v0.1 RC - 2014-08-08 - 13h29 : DogeScript support
*
* Licensed under WTFPL
*