Skip to content

Instantly share code, notes, and snippets.

View fcor's full-sized avatar
🚀
Making science fiction a reality

Fabio Cortés fcor

🚀
Making science fiction a reality
View GitHub Profile
#version 150
uniform float time;
uniform vec2 resolution;
uniform vec2 mouse;
uniform vec3 spectrum;
uniform sampler2D midi;
in VertexData
// i copied and pasted these functions from the sticker sheet
// to read more about turbo: https://ai.googleblog.com/2019/08/turbo-improved-rainbow-colormap-for.html
// in short, its good for colorblindness, getting more deatil (based on human perception), high contrast
// but still smooth interpretation of the in-value
vec3 turboPalette(float x){ // t can be any floating point number that changes, like time or pos.x;
float m = 1.0; // it repeats every 1 unit, because thats the turbo function's range
float t = m - abs(mod(x*20. , (2.*m)) - m);
// this line turns an increasing value into a triangle wave, linear interpolation of length 1 up
// linear interpolation of length 1 down. like this: /\/\/\/\/\/\/\/\/\/\/\/\/\/
@fcor
fcor / scene.html
Created June 2, 2020 23:30
AR.js NFT gestures
<a-scene
arjs="trackingMethod: best; sourceType: webcam; debugUIEnabled: false;"
embedded
renderer="logarithmicDepthBuffer: true;"
vr-mode-ui="enabled: false"
gesture-detector
id="scene"
>
<a-nft
type="nft"
handleScale(event) {
if (isMarkerVisible) {
this.scaleFactor *=
1 + event.detail.spreadChange / event.detail.startSpread;
this.scaleFactor = Math.min(
Math.max(this.scaleFactor, this.data.minScale),
this.data.maxScale
);
@fcor
fcor / rotation.js
Created June 2, 2020 23:27
Handle Rotation using gestures on AR.js
handleRotation(event) {
if (isMarkerVisible) {
el.object3D.rotation.y +=
event.detail.positionChange.x * rotationFactor;
el.object3D.rotation.x +=
event.detail.positionChange.y * rotationFactor;
}
}
@fcor
fcor / marker-events.js
Created June 2, 2020 23:25
Marker Events - AR.js
sceneEl.addEventListener("markerFound", (e) => {
isMarkerVisible = true;
});
sceneEl.addEventListener("markerLost", (e) => {
isMarkerVisible = false;
});
@fcor
fcor / scene.html
Created June 2, 2020 23:21
AR.js Gestures - Scene
<a-scene
arjs
embedded
renderer="logarithmicDepthBuffer: true;"
vr-mode-ui="enabled: false"
gesture-detector
id="scene"
>
// Scene stuff
// http://www.iquilezles.org/www/articles/palettes/palettes.htm
// As t runs from 0 to 1 (our normalized palette index or domain),
//the cosine oscilates c times with a phase of d.
//The result is scaled and biased by a and b to meet the desired constrast and brightness.
vec3 cosPalette( float t, vec3 a, vec3 b, vec3 c, vec3 d )
{
return a + b*cos( 6.28318*(c*t+d) );
}
float sphere(vec3 pos, float rad){
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>GeoAR.js demo</title>
<script src="https://cdn.jsdelivr.net/gh/aframevr/aframe@1c2407b26c61958baa93967b5412487cd94b290b/dist/aframe-master.min.js"></script>
<script src="https://unpkg.com/aframe-look-at-component@0.8.0/dist/aframe-look-at-component.min.js"></script>
<script src='https://raw.githack.com/jeromeetienne/AR.js/2.1.4/aframe/build/aframe-ar.js'></script>
<script>