Skip to content

Instantly share code, notes, and snippets.

@pimpelsang
Last active October 31, 2021 06:40
Show Gist options
  • Select an option

  • Save pimpelsang/1598eeab14ba3881f00e4f9ab6a9d913 to your computer and use it in GitHub Desktop.

Select an option

Save pimpelsang/1598eeab14ba3881f00e4f9ab6a9d913 to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Välgu tee 3D päikese vari</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gl-matrix/2.6.1/gl-matrix-min.js" integrity="sha512-5gjtrbkSzY8jdrVyMSiXO+0AERPMGYpUueFLkBMITgfPL+2qAfZnQyW2YWJkXS4ELmFJLhDZu1WbK8UKFjmC/A==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://code.jquery.com/jquery-3.6.0.slim.min.js" integrity="sha256-u7e5khyithlIdTpu22PHhENmPcRdFiHRjhAuHcs05RI=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://static.sketchfab.com/api/sketchfab-viewer-1.10.1.js"></script>
<style type="text/css">
body {
margin: 0;
}
iframe {
display: block;
background: #000;
border: none;
height: 100vh;
width: 100vw;
}
#controls {
position: fixed;
width: 200px;
top: 30px;
right: 10px;
}
button {
height: 30px;
font-size: 20px;
}
</style>
</head>
<body>
<iframe src="" width="100%" height="100%" id="api-frame" allow="autoplay; fullscreen; xr-spatial-tracking" xr-spatial-tracking execution-while-out-of-viewport execution-while-not-rendered web-share allowfullscreen mozallowfullscreen="true" webkitallowfullscreen="true"></iframe>
<div id="controls">
<button value="2021-01-01">talv</button>
<button value="2021-04-01">kevad</button>
<button value="2021-07-01">suvi</button>
<input type="date" id="date" value="2021-01-01" />
<br />
Kell:
<input id="time" type="time" value="12:00">
<input id="slider" type="range" min="0" max="23" value="12"/>
</div>
<script type="text/javascript">
var client = new Sketchfab( document.getElementById('api-frame') );
client.init( 'a2dd37cdb0664d37bae8a1c1f25ee731', {
success: function onSuccess( api ){
api.start();
api.addEventListener( 'viewerready', function() {
$('#controls > button').click((e)=> {
$('#date').val($(e.target).val());
});
$('#slider').on("input change", (e)=> {
$('#time').val($("#slider").val().padStart(2,"0")+":00");
});
function update() {
api.getLight(0, (err, sun) => {
mat4.rotateX(sun.matrix, sun.matrix, 10/180*Math.PI)
api.setLight(0, {matrix: sun.matrix})
})
}
} );
},
error: console.log
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment