This file contains 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
class FirstInterpolator: Interpolator { | |
override fun getInterpolation(input: Float): Float { | |
return input | |
} | |
} |
This file contains 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
componentDidUpdate() { | |
var now = Date.now(); | |
var diff = now - lastRendered; | |
lastRendered = now; | |
var timeout = diff >= 16 ? 0 : 16 - diff; | |
setTimeout(() => { | |
this.forceUpdate(); | |
}, timeout); | |
} |
This file contains 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 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'; |
This file contains 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
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); | |
} | |
}); |
This file contains 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
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 |
This file contains 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 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; |
This file contains 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 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; |
This file contains 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
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 () { |
This file contains 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
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) { |
This file contains 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 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]; |