A small little demo that uses REGL to display point cloud data.
npm install
npm start
<html> | |
<head> | |
<title>Hooks implementation</title> | |
</head> | |
<body> | |
<script> | |
const React = createApplication() | |
React.render(function MyComponent () { | |
const [greeting, setGreeting] = React.useState('hello') |
const path = require('path') | |
const fetch = require('node-fetch') | |
const ProtoBuf = require('protobufjs') | |
const API_KEY = require('./api-key') | |
const API_URL = 'https://api-endpoint.mta.info/Dataservice/mtagtfsfeeds/nyct%2F' | |
const FEED_IDS = [ | |
'gtfs-ace', |
/* | |
Binary Data format: | |
// buildingID int32 | |
// Vertex Offset vec3<int32> | |
// Vertex ByteSize uint8 (1 or 2 - representing the number of bytes used for the vertex X, Y, & Z) | |
// Vertex Count uint16 | |
// vertex1 X uint8 or uint16 depending on Vertex ByteSize | |
// vertex1 Y | |
// vertex1 Z | |
// vertex2 X |
/* | |
Here are some ideas for how you might get file sizes and load times down when working | |
with large datasets in the browser. | |
*/ | |
// 1. Create the TypedArrays you pass to THREE's BufferGeometry on the server and write the binary output to a file: | |
// in Node | |
const vertices = new Float32Array([ 0, 0, 0, 1, 1, 1, 1, 0 ]) | |
process.stdout.write(Buffer.from(vertices.buffer)) |
const vec3 = require('gl-vec3') | |
const convexHull = require('convex-hull') | |
const earcut = require('earcut') | |
const normal = require('get-plane-normal') | |
function clipMeshWithPlane (triangles, planeNormal, pointOnPlane) { | |
const mesh1 = [] | |
const mesh2 = [] | |
const newPoints = [] | |
for (const points of triangles) { |
// <www.shadertoy.com/view/XsX3zB> | |
// by Nikita Miropolskiy | |
/* discontinuous pseudorandom uniformly distributed in [-0.5, +0.5]^3 */ | |
vec3 random3(vec3 c) { | |
float j = 4096.0*sin(dot(c,vec3(17.0, 59.4, 15.0))); | |
vec3 r; | |
r.z = fract(512.0*j); | |
j *= .125; | |
r.x = fract(512.0*j); |
const { Deck } = require('@deck.gl/core') | |
const fit = require('canvas-fit') | |
const mapboxgl = require('mapbox-gl') | |
module.exports = function setupDeck (mapboxToken, center, zoom, bearing, pitch, mapStyle = 'dark', container = window) { | |
mapboxgl.accessToken = mapboxToken | |
const parentElement = container === window ? document.body : container | |
const mapContainer = parentElement.appendChild(document.createElement('div')) | |
mapContainer.style.width = '100vw' |
/* | |
Usage: | |
const regl = createRegl() | |
const data = [{position: [2, 5]}, {position: [3, 6]}, {position: [4, 1]}] | |
const {tick, getStateTexture, getStateIndexes} = createStateTransitioner(regl, data) | |
// call tick({isBrushing, brushRadius, brushPosition}) on every frame to update the animating values | |
// call getStateTexture() to retrieve the latest animating values, stored in a texture | |
// call getStateIndexes() to get a list of vec2 indexes into the animating values texture |
I hereby claim:
To claim this, I am signing this object: