Skip to content

Instantly share code, notes, and snippets.

@wrr
wrr / body-end.html
Created Nov 7, 2019
Add custom Shapespark menu button
View body-end.html
<script>
var viewer = WALK.getViewer();
var button = viewer.addMenuButton(
'https://cdnjs.cloudflare.com/ajax/libs/webicons/2.0.0/webicons/webicon-facebook.png');
button.addEventListener('click', function() {
viewer.openUrl(
'https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fdemo.shapespark.com%2Fsofa-facebook-share', true)
});
</script>
@wrr
wrr / body-end.html
Created Oct 30, 2019
Disable VR mode in Shapespark
View body-end.html
<script>
navigator.getVRDisplays = undefined;
</script>
@wrr
wrr / body-end.html
Created Sep 20, 2019
Change Shapespark teleport to view to be slower
View body-end.html
<script>
(function() {
// This is in meters / seconds^2 (default is 4)
WALK.TELEPORT_TO_VIEW_ACCELERATION = 1;
// This is in seconds (default is 3)
WALK.TELEPORT_TO_VIEW_MAX_TIME = 100;
}());
</script>
@wrr
wrr / body-end.html
Created Aug 28, 2019
Increase Shapespark camera near to help with z-fighting
View body-end.html
<script>
(function() {
WALK.CAMERA_WALK_NEAR = 0.03;
}());
</script>
@wrr
wrr / body-end.html
Created Jul 4, 2019
Detect which material was selected by the user and show the material name.
View body-end.html
<style>
#banner {
position: absolute;
top: 30px;
text-align: center;
font-size: 3em;
width: 100%;
z-index: 10;
visibility: hidden
}
@wrr
wrr / body-end.html
Created Jun 7, 2019
Detect which material was selected by the material picker
View body-end.html
<script>
var viewer = WALK.getViewer();
viewer.onSceneReadyToDisplay(function() {
var setMaterialForNodeOriginal = viewer.setMaterialForNode;
viewer.setMaterialForNode = function(material, node) {
console.log('Material selected ' + material.name);
setMaterialForNodeOriginal.apply(this, [material, node]);
}
});
</script>
@wrr
wrr / body-end.html
Created Jan 3, 2019
Change Shapespark play button
View body-end.html
<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 Dec 7, 2018
IIS server configuration file for self-hosting of Shapespark bundles.
View web.config
<?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 Jul 3, 2018
Decompresses all compressed files in a Shapespark bundle
View gunzip-files-in-bundle.sh
#!/bin/sh
if [ $# != 1 ]; then
echo "usage: $0 path-to-bundle-dir";
exit;
fi
bundle_dir=${1}
echo "Uncompressing files in ${bundle_dir}"
View headlight
vec3 lightW = normalize(cameraPosition - vPositionW.xyz);
gl_FragColor.rgb = color * max(dot(normalize(vNormalW), lightW), 0.0);
You can’t perform that action at this time.