Skip to content

Instantly share code, notes, and snippets.

View EvanBacon's full-sized avatar
🥓
Markdown developer

Evan Bacon EvanBacon

🥓
Markdown developer
View GitHub Profile
@EvanBacon
EvanBacon / App.js
Created February 6, 2018 08:36 — forked from giautm/App.js
Sketch App
import Expo from 'expo';
import * as ExpoPixi from 'expo-pixi';
import React, { Component } from 'react';
import { Image, StyleSheet, View } from 'react-native';
export default class App extends Component {
state = {
strokeColor: Math.random() * 0xffffff,
strokeWidth: Math.random() * 30 + 10,
};
@EvanBacon
EvanBacon / scaleLongestSideToSize.js
Last active October 18, 2017 18:31
Three.js helper function for scaling the longest side of a mesh to a certain size. This is a debug method for AR development.
const scaleLongestSideToSize = (mesh, size) => {
const { x: width, y: height, z: depth } = new THREE.Box3().setFromObject(mesh).getSize();
const longest = Math.max(width, Math.max(height, depth));
const scale = size / longest;
mesh.scale.set(scale, scale, scale);
}
export default scaleLongestSideToSize;
@EvanBacon
EvanBacon / alignMesh.js
Last active October 18, 2017 18:31
Three.js helper function for aligning a mesh.
const alignMesh = (mesh, axis = { x: 0.5, y: 0.5, z: 0.5 }) => {
axis = axis || {};
const box = new THREE.Box3().setFromObject(mesh);
const size = box.getSize();
const { max } = box;
const min = { x: -box.min.x, y: -box.min.y, z: -box.min.z };
Object.keys(axis).map(key => {
const scale = axis[key];