Skip to content

Instantly share code, notes, and snippets.

View davepape's full-sized avatar

Dave Pape davepape

View GitHub Profile
@davepape
davepape / plotaqi.js
Created November 16, 2015 15:52
Plot AQI data from AirNow, similar to the plotquakes.js example
#pragma strict
// Script to visualize AQI data in JSON format from airnowapi.org
// Requires the SimpleJSON plugin from http://wiki.unity3d.com/index.php/SimpleJSON
// The script should be attached to a model of the Earth such as a sphere
// scaled by a factor of 20 and positioned at (0,0,0). A prefab to use for marking
// the readings should be assigned to the variable "prefab" in the Unity editor.
import SimpleJSON;
@davepape
davepape / airnow-linegraph.js
Last active November 11, 2015 15:53
Plot some AirNow data as a line graph
#pragma strict
// Script to take AirNow AQI data and turn it into a line graph
// Data is assumed to be a time sequence for a single station, from the "Observations by Monitoring Site" query tool
// The data file should be in JSON format, and placed in a folder called "data" within the Assets folder
// This must be attached to a GameObject that has a Mesh Renderer and an empty Mesh Filter
// Using a Mesh Renderer, rather than a Line Renderer, allows us to set per-vertex colors.
import SimpleJSON;
@davepape
davepape / barchart3.js
Created November 4, 2015 15:40
read earthquake data live, using Unity's WWW class, and turn that into a simple bar of a bar chart
#pragma strict
import SimpleJSON;
public var min = 0;
public var max = 2;
public var url = "http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/4.5_month.geojson";
private var dataurl : WWW;
private var done = 0;
@davepape
davepape / barchart.js
Last active November 2, 2015 18:10
example from class, making a single bar for a bar chart of earthquake magnitudes
#pragma strict
import SimpleJSON;
public var min = 0;
public var max = 2;
function Start ()
{
var datastring = System.IO.File.ReadAllText("q.json");
@davepape
davepape / plotquakes.js
Last active November 2, 2015 18:20
Visualize earthquake data from USGS
#pragma strict
// Script to visualize earthquake data in GeoJSON format from USGS
// (http://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php)
// Requires the SimpleJSON plugin from http://wiki.unity3d.com/index.php/SimpleJSON
// The script should be attached to a model of the Earth such as a sphere
// with a 20 unit diameter. A prefab to use for marking the quakes should
// be assigned to the variable "prefab" in the Unity editor.
import SimpleJSON;
#pragma strict
public var rows = 30;
public var cols = 30;
private var myVertices = Array();
private var myUVs = Array();
private var myTriangles = Array();
function Start ()
#pragma strict
public var rows = 30;
public var cols = 30;
private var myVertices = Array();
private var myColors = Array();
private var myTriangles = Array();
function Start ()
#pragma strict
public var rows = 30;
public var cols = 30;
private var myVertices = Array();
private var myColors = Array();
private var myTriangles = Array();
function Start ()
@davepape
davepape / makeTriangles3.js
Last active October 5, 2015 14:49
create a Unity mesh with UV texture coordinates
#pragma strict
// Script to create a mesh with 2 triangles with texture coordinates (UV).
// This expects to be attached to a GameObject that already has a mesh
// and material (such as a sphere), so that you can assign the texture
// through the Unity editor, instead of here in the code
// It uses the mesh's Clear() function to erase the old geometry before
// creating the triangles.
function Start ()
@davepape
davepape / vertexColor.shader
Last active September 29, 2015 04:52
minimal Unity shader, to use vertex colors without lighting or texture
// taken from http://answers.unity3d.com/questions/391561/create-a-mesh-and-color-cubes.html
Shader "Custom/Vertex Colored"
{
Properties
{
}
SubShader
{
Pass
{