Skip to content

Instantly share code, notes, and snippets.

View luruke's full-sized avatar

Luigi De Rosa luruke

View GitHub Profile
// Buffer
this.buffer = new FBO({
geometry: this.geometry,
width: SIZE_BUFFER,
height: SIZE_BUFFER,
name: 'buffer particles',
shader: `
precision highp float;
uniform sampler2D texture;
uniform sampler2D uImage;
import { component } from 'bidello';
import { visibility } from '../bidello';
import FBO from './fbo';
import { pointer } from '../bidello/index';
import {
Vector2,
LinearFilter,
} from 'three';
vec2 offsetr = vec2(trail.r * 0.003);
vec2 offsetg = vec2(trail.r * 0.005);
vec2 offsetb = vec2(trail.r * 0.007);
float r = texture2D(uScene, uv.xy + offsetr).x;
float g = texture2D(uScene, uv.xy + offsetg).y;
float b = texture2D(uScene, uv.xy + offsetb).z;
vec3 color = vec3(r, g, b);
<a href="#" data-component="trackable" data-type="button">Yo, button</a>
import { Component } from 'kapla';
import dom from 'gl/dom';
export default class extends Component {
init() {
dom.register(this.$el);
}
destroy() {
dom.unregister(this.$el);
import Button from './button/button';
import Person from './person/person';
import Footer from './footer/footer';
const elements = {
button: Button,
person: Person,
footer: Footer,
// ...
};
@luruke
luruke / button.js
Last active October 25, 2019 12:23
import {
Mesh,
PlaneBufferGeometry,
RawShaderMaterial,
} from 'three';
import dom3D from '../dom3D';
import scene from '../scene';
import textures from 'gl/utils/textures';
import { Object3D } from 'three';
import { component } from 'bidello';
import { viewport, scroll } from './bidello';
import camera from './camera';
export default class extends component(Object3D) {
init() {
this.element = this._args[0];
}
precision highp float;
uniform float uTime;
uniform sampler2D texture;
uniform sampler2D uWind;
uniform sampler2D uTrail;
void main() {
float pixelHeight = 1.0 / RESOLUTION.y;
float pixelWidth = 1.0 / RESOLUTION.x;
vec2 uv = gl_FragCoord.xy / RESOLUTION.xy;
/**
* Try to fix iOS lock on audio.
*
* By default, audio on iOS is locked until a sound is played within a user interaction,
* and then it plays normally the rest of the page session.
*/
// Inspired from https://github.com/goldfire/howler.js/blob/2.0/src/howler.core.js#L212
export default class IosUnlock {