Skip to content

Instantly share code, notes, and snippets.

@aadebdeb
aadebdeb / arjs-threejs.html
Created July 19, 2020 04:30
Basic Template for AR.js And Thee.js
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
<title>Marker Based AR with AR.js and Three.js</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/110/three.js"></script>
<script src="https://raw.githack.com/AR-js-org/AR.js/3.1.0/three.js/build/ar.js"></script>
</head>
<body style='margin: 0px; overflow: hidden;'>
<script>
@aadebdeb
aadebdeb / CornelBoxGenerator.cs
Created May 24, 2020 03:14
Script to Generate Cornell Box for Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CornelBoxGenerator : MonoBehaviour
{
static readonly string LeftWallName = "Left Wall";
static readonly string RightWallName = "Right Wall";
static readonly string BottomWallName = "Bottom Wall";
@aadebdeb
aadebdeb / randomInSphere.js
Created February 2, 2020 13:57
random in sphere with p5.js
// Please run on p5.js Web Editor or OpenProcessing.
// https://editor.p5js.org/
// https://www.openprocessing.org/
function randomInSphere() {
const cosTheta = -2.0 * Math.random() + 1.0;
const sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
const phi = 2.0 * Math.PI * Math.random();
const radius = Math.pow(Math.random(), 1.0 / 3.0);
return [
@aadebdeb
aadebdeb / randomOnSphere.js
Created February 2, 2020 13:56
random on sphere with p5.js
// Please run on p5.js Web Editor or OpenProcessing.
// https://editor.p5js.org/
// https://www.openprocessing.org/
function randomOnSphere() {
const cosTheta = -2.0 * Math.random() + 1.0;
const sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
const phi = 2.0 * Math.PI * Math.random();
return [
sinTheta * Math.cos(phi),
@aadebdeb
aadebdeb / randomInCircle.js
Last active February 2, 2020 13:53
random in circle with p5.js
// Please run on p5.js Web Editor or OpenProcessing.
// https://editor.p5js.org/
// https://www.openprocessing.org/
function randomInCircle() {
const theta = 2.0 * Math.PI * Math.random();
const radius = Math.sqrt(Math.random());
return [radius * Math.cos(theta), radius * Math.sin(theta)];
}
@aadebdeb
aadebdeb / randomOnCircle.js
Last active February 2, 2020 13:53
random on circle with p5.js
// Please run on p5.js Web Editor or OpenProcessing.
// https://editor.p5js.org/
// https://www.openprocessing.org/
function randomOnCircle() {
const theta = 2.0 * Math.PI * Math.random();
return [Math.cos(theta), Math.sin(theta)];
}
function setup() {
@aadebdeb
aadebdeb / weblgl-helloworld.ts
Created June 5, 2019 13:16
Hello World of WebGL in TypeScript
function createShader(gl: WebGL2RenderingContext, source: string, type: GLint): WebGLShader {
const shader = gl.createShader(type);
gl.shaderSource(shader, source);
gl.compileShader(shader);
if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
throw new Error(gl.getShaderInfoLog(shader) + source);
}
return shader;
}
@aadebdeb
aadebdeb / webgl-arraybufferview-as-texture.html
Created May 2, 2019 12:53
Sample of Using ArrayBufferView as Texture
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utt-8">
<title>Using ArrayBufferView as Texture in WebGL</title>
</head>
<body>
<canvas id="canvas" width="512" height="512"></canvas>
<script defer>
@aadebdeb
aadebdeb / webgl-int-buffer.html
Created May 2, 2019 01:40
Sample of Using Integer Buffer in WebGL
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Sample of Using Integer Buffer in WebGL</title>
</head>
<body>
<canvas id="canvas" width="512" height="512"></canvas>
<script defer>
@aadebdeb
aadebdeb / binarysearch.js
Created March 29, 2019 15:22
binary search to find index range from array with duplicated values in JavaScript
function binarysearchMinIndex(array, target, from, to) {
while (from !== to) {
const middle = from + Math.floor((to - from) / 2);
if (array[middle] < target) {
from = middle + 1;
} else {
to = middle;
}
}