Skip to content

Instantly share code, notes, and snippets.

@wrr
wrr / body-end.html
Last active October 10, 2020 08:54
Detect which material was selected by the material picker
<script>
var viewer = WALK.getViewer();
viewer.onSceneReadyToDisplay(function() {
var setMaterialForMeshOriginal = viewer.setMaterialForMesh;
viewer.setMaterialForMesh = function(material, mesh) {
console.log('Material selected ' + material.name);
setMaterialForMeshOriginal.apply(this, [material, mesh]);
}
});
</script>
@wrr
wrr / body-end.html
Created January 3, 2019 11:07
Change Shapespark play button
<script>
(function() {
document.getElementById('play-button').src = "https://cdnjs.cloudflare.com/ajax/libs/foundicons/3.0.0/svgs/fi-play-video.svg";
}());
</script>
@wrr
wrr / web.config
Created December 7, 2018 12:37
IIS server configuration file for self-hosting of Shapespark bundles.
<?xml version="1.0" encoding="UTF-8"?>
<!--
IIS site configuration file for Shapespark self-hosting bundles.
Requires URL rewrite extension: https://www.iis.net/downloads/microsoft/url-rewrite
Extract the Shapespark bundle together with this config file to a
folder that is configured as a IIS site (<sites> section of
the applicationhost.config).
-->
@wrr
wrr / gunzip-files-in-bundle.sh
Created July 3, 2018 10:58
Decompresses all compressed files in a Shapespark bundle
#!/bin/sh
if [ $# != 1 ]; then
echo "usage: $0 path-to-bundle-dir";
exit;
fi
bundle_dir=${1}
echo "Uncompressing files in ${bundle_dir}"
@wrr
wrr / headlight
Created September 11, 2017 18:29
vec3 lightW = normalize(cameraPosition - vPositionW.xyz);
gl_FragColor.rgb = color * max(dot(normalize(vNormalW), lightW), 0.0);
struct Row {
float& operator[](int column) {
return coeffs[column];
}
typedef std::tr1::unordered_map<int, float> RowData;
RowData coeffs;
};
@wrr
wrr / pipe.py
Created June 13, 2013 17:53
Experiments with Elixir inspired pipe API for python
import unittest
class Pipe:
OUT = object()
def __init__(self, val):
self._val = val
def __call__(self, *args):
if not (args):
@wrr
wrr / index.html
Last active May 14, 2019 00:27
Random walk illustrated with D3.
<!DOCTYPE html>
<!-- By Jan Wrobel. See it working at:
http://mixedbit.org/blog/2013/02/10/random_walk_illustrated_with_d3.html
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>Random walk</title>