-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__loading__.js
146 lines (134 loc) · 5.3 KB
/
__loading__.js
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
pc.script.createLoadingScreen(function (app) {
var showSplash = function () {
// splash wrapper
var wrapper = document.createElement('div');
wrapper.id = 'application-splash-wrapper';
document.body.appendChild(wrapper);
// splash
var splash = document.createElement('div');
splash.id = 'application-splash';
wrapper.appendChild(splash);
splash.style.display = 'none';
// logo
var logo = document.createElement('img');
logo.src = 'https://playcanvas.com/api/assets/207164480/file/61e08459-d639-46ae-9867-71ab5432685a-removebg-preview.png'; // Custom logo URL
splash.appendChild(logo);
logo.onload = function () {
splash.style.display = 'block';
};
// progress bar container
var container = document.createElement('div');
container.id = 'progress-bar-container';
splash.appendChild(container);
// progress bar
var bar = document.createElement('div');
bar.id = 'progress-bar';
container.appendChild(bar);
// Create sparks
for (var i = 0; i < 50; i++) { // Reduced number of sparks for visibility
var spark = document.createElement('div');
spark.className = 'spark';
splash.appendChild(spark);
}
};
var hideSplash = function () {
var splash = document.getElementById('application-splash-wrapper');
splash.parentElement.removeChild(splash);
};
var setProgress = function (value) {
var bar = document.getElementById('progress-bar');
if (bar) {
value = Math.min(1, Math.max(0, value));
bar.style.width = value * 100 + '%';
}
};
var createCss = function () {
var css = [
'body {',
' background-color: black;', // Black background for the screen
' margin: 0;',
' padding: 0;',
' overflow: hidden;',
'}',
'',
'#application-splash-wrapper {',
' position: absolute;',
' top: 0;',
' left: 0;',
' height: 100%;',
' width: 100%;',
' background-color: black;', // Black background
' display: flex;',
' justify-content: center;',
' align-items: center;',
' animation: gradient-flow 10s infinite linear;', // Animated gradient effect
'}',
'',
'#application-splash {',
' position: relative;',
' text-align: center;',
'}',
'',
'#application-splash img {',
' width: 100%;', // Maximizes logo size
' height: 100%;',
' object-fit: contain;', // Ensures the logo keeps its aspect ratio
' image-rendering: crisp-edges;', // Prevents blurriness
' image-rendering: -moz-crisp-edges;',
' image-rendering: pixelated;',
'}',
'',
'#progress-bar-container {',
' margin-top: 20px;',
' height: 8px;', // Thicker loading bar
' width: 80%;', // Adjusts the width of the progress bar
' background-color: #1d292c;', // Dark background for the bar
' border-radius: 4px;',
'}',
'',
'#progress-bar {',
' width: 0%;',
' height: 100%;',
' background-color: #007bff;', // Blue loading bar
' border-radius: 4px;',
'}',
'',
'@keyframes gradient-flow {',
' 0% { background: linear-gradient(90deg, #000000, #282828, #000000); }', // Dark gradient
' 50% { background: linear-gradient(90deg, #282828, #000000, #282828); }',
' 100% { background: linear-gradient(90deg, #000000, #282828, #000000); }',
'}',
'',
/* CSS for Sparks */
'.spark {',
' position: absolute;',
' width: 20px;', // Increased width for bigger sparks
' height: 20px;', // Increased height for bigger sparks
' background-color: #007bff;', // Blue spark
' border-radius: 50%;',
' opacity: 0;',
' animation: spark-animation 1.5s infinite;',
'}',
'@keyframes spark-animation {',
' 0% { opacity: 1; transform: translate(0, 0) scale(1); }',
' 50% { opacity: 0.5; transform: translate(40px, -40px) scale(1.5); }', // Increased movement range
' 100% { opacity: 0; transform: translate(80px, -80px) scale(2); }', // Further increased movement range
'}'
].join('\n');
var style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
document.head.appendChild(style);
};
createCss();
showSplash();
app.on('preload:end', function () {
app.off('preload:progress');
});
app.on('preload:progress', setProgress);
app.on('start', hideSplash);
});