Skip to content

Commit 31f1440

Browse files
committed
Pass search uri args
`?fps=#`, `?scale=#.#`, and `?showfps=1` search parms pass through the 404.html and set values on pxlNav on load
1 parent 194825c commit 31f1440

File tree

4 files changed

+63
-6
lines changed

4 files changed

+63
-6
lines changed

docs/404.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,13 @@
2424
let basePath = window.location.pathname;
2525
basePath = basePath.split('/');
2626
basePath = basePath.pop();
27-
let redirectUrl = '/index.htm?redirect=' + basePath;
27+
let getData = "";
28+
if(window.location.search) {
29+
getData = window.location.search;
30+
getData = getData.replace("?", "&");
31+
}
2832

33+
let redirectUrl = '/index.htm?redirect=' + basePath + getData;
2934
window.location.replace( redirectUrl );
3035

3136
// -- -- --

docs/index.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
<link type="text/css" rel="stylesheet" href="style/ProcStackStyle.css">
5454
<link type="text/css" rel="stylesheet" href="style/pxlNavStyle.min.css">
5555

56-
<script src="https://www.youtube.com/iframe_api"></script>
56+
<script src="https://www.youtube.com/iframe_api" async></script>
5757

5858
<!-- -- -- -- -->
5959

docs/js/ProckStackGitio.js

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ userSettings['gravity']['max'] = 15.5; // Max gravity rate
7878
// Default is - PC = 30 -&- Movile = 30
7979
const targetFPS = {
8080
'pc' : 45,
81-
'mobile' : 30
81+
'mobile' : 45
8282
};
8383

8484
// Render Resolution Scale
@@ -120,6 +120,33 @@ const collisionScale = {
120120
};
121121

122122

123+
// -- -- -- -- --
124+
125+
// Find search parameters in the URL for procstack.github.io
126+
// Not needed for pxlNav
127+
// Note : procPages clears the search parameters on the page
128+
// So search is lost on page change,
129+
// Running before procPages.init() is needed
130+
let uriSearch = window.location.search;
131+
132+
// Check hash for fps and renderScale
133+
let searchParams = new URLSearchParams(uriSearch);
134+
let showFPS = searchParams.has('showfps') ? !!parseInt(searchParams.get('showfps')) : false;
135+
if( searchParams.has('fps') ){
136+
let fps = parseInt(searchParams.get('fps'));
137+
if( fps > 0 ){
138+
targetFPS.pc = fps;
139+
targetFPS.mobile = fps;
140+
}
141+
}
142+
if( searchParams.has('scale') ){
143+
let scale = parseFloat(searchParams.get('scale'));
144+
if( scale > 0 ){
145+
renderScale.pc = scale;
146+
renderScale.mobile = scale;
147+
}
148+
}
149+
123150
// -- -- -- -- --
124151

125152
// Create the main page manager
@@ -170,8 +197,6 @@ pxlNavOptions.loaderPhrases = loaderPhrases;
170197
const pxlNavEnv = new pxlNav( pxlNavOptions, projectTitle, procPages.curRoom, bootRoomList );
171198

172199

173-
174-
175200
// -- -- -- -- --
176201

177202

@@ -183,6 +208,7 @@ pageListenEvents.forEach( (e)=>{
183208
});
184209

185210

211+
186212
// -- -- --
187213

188214
// Connect ProcPages' trigger emit function to into `pxlNav`
@@ -191,6 +217,32 @@ procPages.bindTriggerEmits( pxlNavEnv.trigger.bind(pxlNavEnv) );
191217
// -- -- --
192218

193219

220+
// Check hash for fps and renderScale
221+
if( showFPS ){
222+
let verboseConsole = document.getElementById('verbErrorConsole');
223+
let skipper = true;
224+
let prevTime = 0;
225+
if( verboseConsole ){
226+
pxlNavEnv.subscribe( 'render-prep', ( e )=>{
227+
skipper = !skipper;
228+
if( !skipper ){
229+
prevTime = e.value.time;
230+
return;
231+
}
232+
let newDiv = document.createElement('div');
233+
let delta = (1 / ((e.value.time-prevTime))).toFixed(3);
234+
newDiv.innerHTML = delta;
235+
verboseConsole.prepend(newDiv);
236+
if( verboseConsole.childElementCount > 3 ){
237+
verboseConsole.removeChild(verboseConsole.lastChild);
238+
}
239+
});
240+
}
241+
}
242+
243+
// -- -- --
244+
245+
194246
function init(){
195247

196248
// Start the timer and initilize pxlNAv

docs/js/pxlNav.esm.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)