Skip to content

Instantly share code, notes, and snippets.

View macrozone's full-sized avatar

Marco Wettstein macrozone

View GitHub Profile
@macrozone
macrozone / flow-router-ssr.js
Created October 14, 2018 17:09
flow router ssr example with radium, helmet and fastrender
import { FlowRouter } from 'meteor/ostrio:flow-router-extra';
import { FastRender } from 'meteor/staringatlights:fast-render';
import { InjectData } from 'meteor/staringatlights:inject-data';
import { Random } from 'meteor/random';
import { renderToString } from 'react-dom/server';
import React from 'react';
import Radium from 'radium';
import { Helmet } from 'react-helmet';
import Loadable from 'react-loadable';
import { compose } from 'recompose'
import { connect } from 'react-redux'
import { withNavigationFocus } from 'react-navigation'
import { graphql } from 'react-apollo'
import { isFunction } from 'lodash'
import type { State } from '../../../redux/rootReducer'
export const defaultOptions = polling => ({
pollInterval: polling ? DEFAULT_POLL_INTERVAL : 0,
// @flow
// TODO: use proper vector library
import type { Plane, Ray, Vector3 } from '../../types'
export const UP = {
x: 0,
y: 1,
z: 0,
}
@macrozone
macrozone / ARLine
Created December 19, 2017 14:44
drawing a line in react-native-arkit
// @flow
import { ARKit } from 'react-native-arkit'
import React, { Component } from 'react'
import type { Vector3 } from '../../../types'
import { center, diff, distance, add } from '../../../libs/math/vectorUtils'
type Props = {
from: Vector3,
to: Vector3,
@macrozone
macrozone / ARLineSegment.js
Created October 17, 2017 19:23
react-native-arkit Cylinder from a to b
import { ARKit } from 'react-native-arkit'
import React from 'react'
import type { Point3D } from '../../../types'
import { length, center, diff, distance } from '../libs/vectorUtils'
const PI_2 = Math.PI / 2
@macrozone
macrozone / ModelWithDownload.js
Last active March 29, 2018 15:42
Example how to download a 3dmodel from the internet using react-native-arkit
// @flow
import { ARKit } from '@panter/react-native-arkit'
import { branch, compose, lifecycle, renderComponent } from 'recompose'
import { unzip } from 'react-native-zip-archive'
import RNFetchBlob from 'react-native-fetch-blob'
import React from 'react'
const getModelPath = modelId => (
`${RNFetchBlob.fs.dirs.CacheDir}/models/${modelId}/`
// @flow
import { css } from 'styled-components'
export default {
colors: {
greyDark: '#515151',
greySemiDark: '#7D7D7D',
grey: '#A4A4A4',
greySemiLight: '#C6C6C6',
tabSize: 2
storybook: true
generateComponentTests: false
generateContainerTests: false
modulesPath: src/modules
snakeCaseFileNames: false
templates:
- name: 'storybook'
text: |
// @flow
import React from 'react';
import withTheme from '/lib/withTheme';
import { withUploader } from '@panter/manul-files';
import { useDeps, composeAll } from 'mantra-core';
import BoxedImage from '/client/modules/core/components/boxed_image';
import { connectField } from 'uniforms';
import DropZone from 'react-dropzone';
import { Styles } from './TextField';
import formCol from './FormCol';
import _ from 'lodash';
@macrozone
macrozone / scene-extended.js
Created January 8, 2017 14:58
react-three extended scene
import { Scene } from 'react-three';
import THREE from 'three';
import _ from 'lodash';
/**
we extend the react-three-scene with support for more properties:
- onOrbit: will be called when orbitcontrols are changed. It will pass the current camera
- onClickRay: will be called on a click on the scene with arguments:
event, the current ray from the camera to the mousePosition and the mousePosition
- onMouseMoveRay: same as above, but on every mousemove
**/