-
Notifications
You must be signed in to change notification settings - Fork 3
/
simpleSpinner.html
72 lines (55 loc) · 2.22 KB
/
simpleSpinner.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<html>
<head>
<title>Simple Spinner</title>
<link rel='stylesheet' href='css/main.css'/>
</head>
<body>
<div id="header">
<a href="https://github.com/Pixpipe/quickvoxelcore"><img src='../assets/images/qv_logo_horizontal.png'/></a>
<div class="description">
Quickvoxel Core provides some events such as <code>startAddingVolume</code> and <code>volumeReady</code>, giving the possibility to show and hide a spinner based on the loading and processing stage or the data
•
<a id="sourcelink" href="">source</a>
</div>
</div>
<!-- This one is not related to Quickvoxel, just to auto update the link to the Github source -->
<script src="js/addsourcelink.js"></script>
<!-- Loading Quickvoxel Core -->
<script src="../dist/quickvoxelcore.es6.js"></script>
<img id="spinner" src="images/lego_spinner.gif"/>
<canvas id="renderCanvas"></canvas>
<script>
// test compatibility with WebGL2
if (!quickvoxelcore.webGL2()){
alert( 'Quickvoxel Core cannot run here because this web browser is not compatible with WebGL2.' )
} else {
main()
}
function main () {
let canvas = document.getElementById("renderCanvas")
let spinner = document.getElementById('spinner')
// the QuickvoxelCore instance is the entry point
let qvc = new quickvoxelcore.QuickvoxelCore( canvas );
// for future access to the volume collection
let volumeCollection = qvc.getVolumeCollection();
// for future access the render engine
let renderEngine = qvc.getRenderEngine();
// events must be declared before adding a volume!
volumeCollection.on("startAddingVolume", function(volume){
// showing the loading spinner
spinner.style.display = 'initial'
})
// mount the volume when it's ready!
volumeCollection.on("volumeReady", function(volume){
// hiding the loading spinner
spinner.style.display = 'none'
let couldMount = renderEngine.mountVolumeOnFirstEmptySlot( volume )
if( !couldMount ){
console.log("All volume slots are taken on the render engine, make some space before rendering this volume.");
}
})
volumeCollection.addVolumeFromUrl( "../data/structural.nii.gz" );
}
</script>
</body>
</html>