-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathindex.html
130 lines (117 loc) · 3.88 KB
/
index.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Egret3D Examples</title>
<meta name="viewport" content="width=device-width,initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="full-screen" content="true" />
<meta name="screen-orientation" content="portrait" />
<meta name="x5-fullscreen" content="true" />
<meta name="360-fullscreen" content="true" />
<style>
html,
body {
overflow: hidden;
background: #000000;
padding: 0;
border: 0;
margin: 0;
height: 100%;
touch-action: none;
}
</style>
<script type="text/javascript" src="https://res.wx.qq.com/mmbizwap/zh_CN/htmledition/js/vconsole/3.0.0/vconsole.min.js"></script>
</head>
<body onContextMenu="return false">
<div
style="margin: auto;width: 100%;height: 100%;overflow: hidden;"
class="egret-player"
data-entry="main"
data-scene=""
data-tick-rate="auto"
data-frame-rate="auto"
data-content-width="1136"
data-content-height="640"
data-antialias="true"
data-alpha="false"
data-orientation="auto"
data-scale-mode="showAll"
data-multi-fingered="2"
data-show-stats="true"
data-show-inspector="auto"
>
</div>
<script>
var loadScript = function (list, callback) {
var loaded = 0;
var loadNext = function () {
loadSingleScript(list[loaded], function () {
loaded++;
if (loaded >= list.length) {
callback();
}
else {
loadNext();
}
})
};
loadNext();
};
var loadSingleScript = function (src, callback) {
var s = document.createElement('script');
s.async = false;
s.src = src;
s.addEventListener('load', function () {
s.parentNode.removeChild(s);
s.removeEventListener('load', arguments.callee, false);
callback();
}, false);
document.body.appendChild(s);
};
var xhr = new XMLHttpRequest();
xhr.open('GET', './manifest.json?v=' + Math.random(), true);
xhr.addEventListener("load", function () {
var manifest = JSON.parse(xhr.response);
var list = manifest.initial.concat(manifest.game);
loadScript(list, function () {
egret3d.runEgret();
/**
* `paper.Application.pause(); // 如果是编辑器模式, egret3d.runEgret() 之后即可暂停主循环`
*/
});
});
xhr.send(null);
/**
* 运行时设置帧频和暂停/恢复
*
```js
var paused = true;
var tps = 10;
var fps = 15;
var firstResume = true;
window.ondblclick = () => {
paused = !paused;
if (!paused && !firstResume) {
// 运行时修改逻辑帧频
paper.clock.tickInterval = 1.0 / tps;
tps += 10;
if (tps > 70) { tps = 10; }
// 运行时修改渲染帧频
paper.clock.frameInterval = 1.0 / fps;
fps *= 2;
if (fps > 60) { fps = 15; }
}
// 运行时切换主动(主循环运行)和被动刷新(主循环暂停)
if (paused) {
paper.Application.pause();
} else {
paper.Application.resume();
firstResume = false;
}
}
```
*/
</script>
</body>
</html>