-
Notifications
You must be signed in to change notification settings - Fork 2
/
ModelView_WallpaperEngine_template.html
78 lines (69 loc) · 2.61 KB
/
ModelView_WallpaperEngine_template.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
73
74
75
76
77
78
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>
<%= htmlWebpackPlugin.options.title %>
</title>
<!-- lib-->
<script desc="lib-js">
<%= htmlWebpackPlugin.options.templateParameters.myscript %>
</script>
<!-- data,image,model-->
<script desc="model-data">
<%= htmlWebpackPlugin.options.templateParameters.model_base64_data %>
</script>
<!-- <script desc="img-data">-->
<!-- <%= htmlWebpackPlugin.options.templateParameters.images_base64_data %>-->
<!-- </script>-->
<script desc="mp3-data">
<%= htmlWebpackPlugin.options.templateParameters.mp3_base64_data %>
</script>
<script>
function b64toBlob(b64Data, contentType = "", sliceSize = 512) {
const byteCharacters = atob(b64Data);
const byteArrays = [];
for (var offset = 0; offset < byteCharacters.length; offset += sliceSize) {
const slice = byteCharacters.slice(offset, offset + sliceSize);
const byteNumbers = new Array(slice.length);
for (var i = 0; i < slice.length; i++) {
byteNumbers[i] = slice.charCodeAt(i);
}
const byteArray = new Uint8Array(byteNumbers);
byteArrays.push(byteArray);
}
const blob = new Blob(byteArrays, {
type: contentType,
});
return blob;
}
const contentType = "application/octet-stream";
function getModelURL(model) {return URL.createObjectURL(b64toBlob(model, contentType));}
const blobUrl = getModelURL(scene_model);
marmoset.noUserInterface = true; //please be considerate
var myviewer = null;
setTimeout(function() {
myviewer = new marmoset.WebViewer(window.innerWidth, window.innerHeight, blobUrl);
document.getElementById("view").appendChild(myviewer.domRoot);
myviewer.domRoot.style.position = "absolute", myviewer.domRoot.style.left = myviewer.domRoot.style.top = 0;
myviewer.loadScene();
}, 300);
var timer = null;
timer = setInterval(function () {
if (myviewer && myviewer.scene && myviewer.scene.complete()) {
document.getElementById("marmosetUI").outerHTML = document.getElementById("marmosetUI");
clearInterval(timer);
}
}, 100);
</script>
</head>
<body>
<div id="view"></div>
<audio autoplay loop style="display: none">
<source id="mp3" type="audio/mpeg">
</audio>
</body>
<script>
document.getElementById("mp3").src = `data:audio/mpeg;base64,${LaSoLa_mp3 }`;
</script>
</html>