Skip to content

Instantly share code, notes, and snippets.

View igalata's full-sized avatar
🎯
Focusing

Irina Galata igalata

🎯
Focusing
View GitHub Profile
class FirstInterpolator: Interpolator {
override fun getInterpolation(input: Float): Float {
return input
}
}
componentDidUpdate() {
var now = Date.now();
var diff = now - lastRendered;
lastRendered = now;
var timeout = diff >= 16 ? 0 : 16 - diff;
setTimeout(() => {
this.forceUpdate();
}, timeout);
}
import React, {Component} from "react";
import {View, AppRegistry, PanResponder} from "react-native";
import {Surface} from "gl-react-native";
import GL from "gl-react";
import {resolveAssetSource} from "gl-react-native";
import Dimensions from 'Dimensions';
import BallBody from './ballBody.js';
import Wall from './wall.js';
import Ball from './ball.js';
import Box2D from 'box2dweb';
componentWillMount() {
this._panResponder = PanResponder.create({
onStartShouldSetPanResponder: (evt, gestureState) => true,
onStartShouldSetPanResponderCapture: (evt, gestureState) => true,
onMoveShouldSetPanResponder: (evt, gestureState) => true,
onMoveShouldSetPanResponderCapture: (evt, gestureState) => true,
onPanResponderGrant: (evt, gestureState) => {
this.handleTouch(evt);
}
});
function start() {
var gravity = new b2Vec2(0.0, -2000000.0);
world = new b2World(gravity, true);
ball = new BallBody(someInitialPosition, radius, world);
// vertical walls
new Wall(new b2Vec2(0, 0), new b2Vec2(0, 2.0), world);
new Wall(new b2Vec2(0.5, 0), new b2Vec2(0.5, 2.0), world);
// horizontal walls
const Box2D = require('box2dweb');
const b2World = Box2D.Dynamics.b2World;
const b2Vec2 = Box2D.Common.Math.b2Vec2;
const b2BodyDef = Box2D.Dynamics.b2BodyDef;
const b2Body = Box2D.Dynamics.b2Body;
const b2FixtureDef = Box2D.Dynamics.b2FixtureDef;
const b2CircleShape = Box2D.Collision.Shapes.b2CircleShape;
var body;
const Box2D = require('box2dweb');
const b2World = Box2D.Dynamics.b2World;
const b2Vec2 = Box2D.Common.Math.b2Vec2;
const b2BodyDef = Box2D.Dynamics.b2BodyDef;
const b2Body = Box2D.Dynamics.b2Body;
const b2FixtureDef = Box2D.Dynamics.b2FixtureDef;
const b2CircleShape = Box2D.Collision.Shapes.b2CircleShape;
var body;
module.exports = `
precision highp float;
varying vec2 uv;
uniform float ratio;
uniform float radius;
uniform vec2 location;
uniform float angle;
uniform sampler2D image;
void main () {
module.exports = `
precision highp float;
varying vec2 uv;
const float PI = 3.1415926535897932384626433832795;
bool equal(float a, float b) {
return abs(a - b) < 0.001;
}
float angle(vec2 a, vec2 b) {
...
import CircleBody from './circleBody.js';
import Wall from './wall.js';
const Box2D = require('box2dweb');
const b2World = Box2D.Dynamics.b2World;
const b2Vec2 = Box2D.Common.Math.b2Vec2;
const radius = 0.1;
const someInitialPosition = [0.5, 0.3];