This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let gl = renderer.getContext(); | |
let debugInfo = gl.getExtension("WEBGL_debug_renderer_info"); | |
let vendor='unk'; | |
let gpu = 'unk'; | |
try { | |
vendor = gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL); | |
gpu = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL); | |
} catch (err) { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uniform sampler2D uTexture; | |
uniform float uAspect; //Aspect ratio of the screen | |
uniform float uProgress; | |
... | |
at the end of the vertex shader: | |
vec4 worldPosition = projectionMatrix * modelViewMatrix * vec4(pos, 1.); | |
vec4 screenPosition = vec4((uv-.5)*2.,0.,1.); | |
ivec2 texDim = textureSize(uTexture,0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as SkeletonUtils from 'threeModules/utils/SkeletonUtils.js'; | |
import * as BufferGeometryUtils from 'threeModules/utils/BufferGeometryUtils.js'; | |
function CrushAnimatedObject(root){ | |
//Make a clone of the root.. to work with.. | |
let ud = root.userData; | |
root.userData={} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let binsert = (items,item)=>{ | |
let low = 0; | |
let high = items.length; | |
while (low < high) { | |
const mid = (low + high) >> 1; | |
((item.cost - items[mid].cost) > 0) ? (high = mid) : (low = mid + 1); | |
} | |
items.splice(low, 0, item); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uint32 EncodeMorton2(uint32 x, uint32 y) | |
{ | |
return (Part1By1(y) << 1) + Part1By1(x); | |
} | |
uint32 EncodeMorton3(uint32 x, uint32 y, uint32 z) | |
{ | |
return (Part1By2(z) << 2) + (Part1By2(y) << 1) + Part1By2(x); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let b2h = [] | |
for(let i=0;i<256;i++)b2h[i]=i.toString(16).padStart(2,"0") | |
let arrayToHex=(a)=>{ | |
let hex = new Array(a.length) | |
for(let i=0,l=a.length;i<l;i++)hex[i]=b2h[a[i]] | |
return hex.join('') | |
} | |
let h2b = {} | |
for(let i=0;i<256;i++)h2b[i.toString(16).padStart(2,"0")]=i; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const DEG2RAD = Math.PI / 180; | |
let updateProjectionMatrixHorizontalFOV = (camera)=>{ | |
const near = camera.near; | |
/* | |
let top = near * Math.tan( DEG2RAD * 0.5 * camera.fov ) / camera.zoom; | |
let height = 2 * top; | |
let width = camera.aspect * height; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let takeScreenShot=()=>{ | |
let d=document; | |
let e = d.createElement("a"); | |
e.setAttribute("href", renderer.domElement.toDataURL("image/jpeg")); | |
e.setAttribute("download", "Screenshot.jpeg"); | |
e.style.display = "none"; | |
d.body.appendChild(e); | |
d.click(); | |
d.body.removeChild(e); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as THREE from 'https:/threejs.org/build/three.module.js' | |
import {GLTFExporter} from 'https:/threejs.org/examples/jsm/exporters/GLTFExporter.js' | |
fetch('./map.json').then(data=>data.json().then((js)=>{ | |
console.log(js) | |
let g = new THREE.PlaneGeometry(1,1) | |
g.attributes.normal.array=new Float32Array(js.normal.length) | |
g.attributes.normal.array.set(js.normal) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// **** This is for testing each number in the 32 bit uint random state individually. **** | |
//#define BIT_BY_BIT_DEBUG | |
#define saturate(a) clamp(a, 0.0, 1.0) | |
// ---- Random functions use one 32 bit state var to change things up ---- | |
// This is the single state variable for the random number generator. | |
uint randomState = 4056649889u; | |
// 0xffffff is biggest 2^n-1 that 32 bit float does exactly. | |
// Check with Math.fround(0xffffff) in javascript. |
NewerOlder