Skip to content

Instantly share code, notes, and snippets.

View andreasplesch's full-sized avatar

Andreas Plesch andreasplesch

  • Earthstruct
  • Waltham, MA
View GitHub Profile
@andreasplesch
andreasplesch / README.md
Last active August 29, 2015 14:27
1d pixel texture by D3 color interpolation

Use data binding to generate a defined number of colors interpolated between two colors in Lab, Hcl and rgb color space.

@andreasplesch
andreasplesch / README.md
Last active September 19, 2015 13:20
d3 color scale from ncar ncl color table

I am interested in an easy way to generate a color table with a defined number of colors for use with this:

http://andreasplesch.github.io/x3dom/GeoElevationGrid_texture/terrain_spheresensor.xhtml

Here is a D3 way to use the many color maps NCAR's NCL provides. The original source file is read, so all of the parsing and then color scale (mapping) work takes place in the callback. The original tables directly map to D3 linear scales with a segmented definition. Hcl interpolation looks better for oversampling. The resampling is then simply an application of a new input domain to the piecewise color scale function. Since I use table cells to draw the color tables, there is a somewhat clever function to keep the table at a constant total width by inserting an extra width pixel every so many columns.

@andreasplesch
andreasplesch / README.md
Last active August 29, 2015 14:27
testing d3 v.4 range() method, wait ...

These are some tests to check behavior of the d3 range() method when it is used with fractional step sizes.

https://github.com/d3/d3-arrays has the candidate versions for a new release d3. The range() function below is copied over from there.

@andreasplesch
andreasplesch / x3domEarClippingFixer.user.js
Last active November 11, 2015 18:21
user script to redefine x3dom earclipping
// ==UserScript==
// @name x3domEarClipFixer
// @namespace aplesch
// @description fixes x3dom earclipping
// @version 2.1
// @grant none
// ==/UserScript==
/*
* X3DOM JavaScript Library
// ==UserScript==
// @name x3domEarCut
// @namespace aplesch
// @description uses earcut for x3dom earclipping
// @version 1.8
// @grant none
// ==/UserScript==
/*
* X3DOM JavaScript Library
// ==UserScript==
// @name GeoLOD
// @namespace aplesch
// @description GeoLOD for x3dom (no mm)
// @version 0.21
// @grant none
// ==/UserScript==
/** @namespace x3dom.nodeTypes */
/*
@andreasplesch
andreasplesch / normalDisplacement.user.js
Last active December 14, 2015 21:55
displacement texture along normal for commonsurfaceshader
// ==UserScript==
// @name normalDisplacement
// @namespace aplesch
// @description normal displacement for CommonSurfaceShader
// @version 0.31
// @grant none
// ==/UserScript==
/*
* X3DOM JavaScript Library
// ==UserScript==
// @name VolumeData
// @namespace aplesch
// @description adjust steps for ray casting
// @version 0.13
// @grant none
// ==/UserScript==
/** @namespace x3dom.nodeTypes */
/*
<!DOCTYPE html >
<html >
<head>
<meta http-equiv='Content-Type' content='text/html;charset=utf-8'/>
<script type="text/javascript" src="http://x3dom.org/release/x3dom-full-physics.js"></script>
<link rel='stylesheet' type='text/css' href='http://x3dom.org/release/x3dom.css'/>
<style type="text/css">
* { -webkit-user-select: none; -moz-user-select: none; cursor: default; }
body { font: 13px/18px Arial, sans-serif; background: black; color: white;}
/** @namespace x3dom.nodeTypes */
/*
* X3DOM JavaScript Library
* http://www.x3dom.org
*
* (C)2009 Fraunhofer IGD, Darmstadt, Germany
* Dual licensed under the MIT and GPL
* (C)2016 Leonard Daly
*/