You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown Nick.Penwarden
#rb none
============================
MAJOR FEATURES & CHANGES
============================
Change 3795481 by Nick.Shin
HTML5 - disable SupportsScreenPercentage() - render the full screen
otherwise, this is causing HTML5 screen to only render a portion of the screen and in black...
- there may be another function is that not getting fired off "to render the screen" properly
- this may be due to IsMobileHDR checks that are not fully accounted for the HTML5 platform
#jira UE-52640 HTML5 only renders a black rectangle in the browser when launched
Change 3807007 by Nick.Shin
HTML5 - remove webgl1 only precompile guards (UE4_HTML5_TARGET_WEBGL2)
toolchain can "fallback" to webgl1 -- webgl2 functions in UE4 code are "if checked"/configured/setup at start up
#jira UE-51267 WebGL1 fails to compile
Change 3822593 by Nick.Shin
#jira UE-27141 Remove all #if PLATFORM_HTML5 from high level code
Change 3823512 by Nick.Shin
#jira UE-27141 Remove all #if PLATFORM_HTML5 from high level code
Change 3824639 by Nick.Shin
HTML5 - OSX - RunMacHTML5LaunchHelper.command
- more helpful warning messages
#jira UE-49861 A copied RunMacHTML5LaunchHelper.command gives unspecific Mono error
Change 3829092 by Josh.Adams
- Updated UnrealRemote to 1.4.1
Change 3832708 by Chris.Babcock
Allow UE4Commandline.txt in APK
#jira
#ue4
#android
Change 3835867 by Nick.Shin
HTML5 - code cleanup
origial work was for: UE-27141 (Remove all #if PLATFORM_HTML5 from high level code)
this exposed an issue that i totally forgot about (.../Engine/Source/Developer/... only does builds tools -- which does not make use of PLATFORM_XXX preprocessor)
tested with HTML5 builds with QAGame project :: TM-ShaderModels map
#jira UE-53524 UE4Editor Static Analysis Win64 (MSVC) - 1 repeat warning
Change 3839967 by Mi.Wang
Override MaxObjectInGame on Android to save ~30M with the ObjectArray size.
#Android
Change 3842022 by Mi.Wang
Fix an AssetRegistry size calculation bug.
Change 3843552 by Sorin.Gradinaru
UE-54139 Possible crash with new virtual keyboard on Android if suggestions not disabled
#4.19
#Android
#jira UE-54139
S8 on 7.0 is not hiding suggestions and disabling predictive input. There are cases with this that can cause a crash.
Fix: On text change, downgrade to simple suggestions all the easy correction spans that are not a spell check span (remove android.text.style.SuggestionSpan.FLAG_EASY_CORRECT flags)
Change 3844210 by Nick.Shin
HTML5 - filter out "windows/super" keys - these are not used in UE4
- but, keycode are not the expected "91 or 92" values, SDL keys are "227 & 231" instead...
#jira UE-54056 HTML5 crashes inside browser upon pressing windows key
Change 3844874 by Nick.Shin
HTML5 - detect "SyntaxError: " and do a forced reload
- an actual syntax error would be caught during compile time
- this is usually error condition is usually seen when browser is running "old/partial" cached data and it's fairly safe to just reload the page
#jira UE-54017 QAGame fails to launch properly on HTML5 Firefox 64 bit
Change 3846695 by Nick.Shin
#jira UE-53524 UE4Editor Static Analysis Win64 (MSVC) - 1 repeat warning
Change 3847309 by Nick.Shin
HTML5 - (not to) show virtual joystick
- virtual joysticks are not shown by default-- and the mouse not captured
- this now behaves like the win64 client version
#jira UE-33854 Virtual Joysticks In HTML5 if Mobile/Tablet Project is chosen
Change 3847310 by Nick.Shin
HTML5 - set controller axis and button max value in code instead of relying on emscripten_get_gamepad_status()
- seems emscripten might be uninitialized by the time controlers are used...
#jira UE-28513 - Using a controller in HTML5 causes error
Change 3850606 by Nick.Shin
HTML5 - more static warning fix ups
#jira UE-53524 UE4Editor Static Analysis Win64 (MSVC) - 1 repeat warning
Change 3850624 by Nick.Shin
HTML5 - tell user/developer to show unsupported WebGL browsers on old hardware -- will need to try another browser
note: using following jira to track progress:
#jira UE-47066 Packaged HTML 5 Map Prompts for Firefox Update in Chrome
Change 3855610 by Sorin.Gradinaru
UE-49173 Progress bar causes black screen on iOS
#iOS
#4.20
#jira UE-49173
The bug occurs on iOS with Metal, when the last Slate element to be draw in the scene is a ScrollBar with progress between 0 and 1.
As a workaround, adding another widget (eg. button, image) in the Blueprint solves the problem.
The bug can be reproduced by adding OutDrawElements.PushClip & OutDrawElements.PopClip in any SWidget::OnPaint.
The solution is to disable the scissor
RHICmdList.SetScissorRect(false, 0, 0, 0, 0);
in FSlateRHIRenderingPolicy::DrawElements after the batch rendering
Change 3855652 by Sorin.Gradinaru
iOS 3D browser
UE-53248 Web Browser on a Widget Component is 2D when launching on to iOS
#jira UE-53248
#iOS
#4.20
Uses the same WebTexture from the WebBrowser plugin as the Android version.
+ Code contributed by Juan.Belon from Alea S.r.l at https://udn.unrealengine.com/questions/390166/3d-world-space-widget-is-being-rendered-in-screen.html
Change 3856174 by Nick.Shin
HTML5 - python forking will still error while trying to terminate already terminated processes
- added same "WindowsError code 5" handler found in subprocess.py
#jira UE-51618 HTML5 fails to build, [Error 5] Access is denied
Change 3863322 by Sorin.Gradinaru
UE-54317 DXT apps fail on first launch when 'For Distribution' enabled, Unsupported Texture Format
#jira UE-54317
#Android
#4.19
Change 3878088 by Nick.Shin
UEMOB-425 superceeds this jira
#jira UE-25257 Mac HTML5 project crashes upon downloading expression HasFoundDataDirectory failed
Change 3884560 by Jack.Porter
Fix logspam in FAVMoviePlayer
#jira UE-54760
Change 3886533 by Mi.Wang
Fix a potential crash that the VirtualKeyboardWidget has been hide while trying to use in gamethread.
Change 3889081 by Sorin.Gradinaru
UE-54490 Android Startup Movie audio still playing when app paused, and after app resumed the movie is blackscreen until engine ticked.
#Android
#4.20
#jira UE-54490
Call ForceCompletion for the intial movie player on onPause.
Call App Restart on Resume.
Programmatically restarting an Android application basically consists in killing the current app, then using the launch intent as parameter for startActivity.
This can be done only in onResume , which means that the movie player still has to be manually paused/stopped in onPause.
I╞ve tried to kill the activity on onPause, tested on several devices, with various problems: the app doesn╞t restart anymore (onResume is not called) or the app is automatically sent to background (seems to be crashing when using the multitasking soft key).
Change 3890320 by Chris.Babcock
Fix initializer ordering
#jira UE-55189
#ue4
Change 3958226 by Nick.Shin
HTML5 disable memory poison tests
and fix a bug during Realloc() // for Linux... and in turn for HTML5
#jria none
Change 3958250 by Nick.Shin
HTML5 - FText::FormatStr - skip if multi-threading not supported
#jira none
Change 3968328 by Nick.Shin
HTML5 CORS fixes
still need datarouter.ol.epicgames.com fixes to completely solve these issues. (API server own estimates no later than mid-April)
note: the following are all related:
+ answerhub 756723 - HTML5 CORS / Access-Control-Allow-Headers
+ answerhub 756942 - HTML5 CORS Issue to my Hosts API / Hosted Server
+ UE-22285 - Session events are not generated for HTML5
+ UE-19330 - HTML5 Analytics cross-origin request blocked header Access-Control-Allow-Origin missing
#jira UE-19330
Change 3971405 by Nick.Shin
HTML5 suppress double printing to console.log
#jira none
Change 3978767 by Nick.Shin
HTML5 CORS fixes
note: the following are all related:
+ answerhub 756723 - HTML5 CORS / Access-Control-Allow-Headers
+ answerhub 756942 - HTML5 CORS Issue to my Hosts API / Hosted Server
+ UE-22285 - Session events are not generated for HTML5
+ UE-19330 - HTML5 Analytics cross-origin request blocked header Access-Control-Allow-Origin missing
tested (against datarouter.ol.epicgames.com fixes) and found to be functional
#jira UE-22285
Change 3981103 by Nick.Shin
HTML5 - num pad keys crashes project
match latest Engine/Source/Runtime/InputCore/Private/Linux/LinuxPlatformInput.cpp to HTML5PlatformInput.cpp
also fix a HUD crash...
#jira UE-54056 HTML5 crashes inside browser upon pressing windows key
Change 3983424 by Sorin.Gradinaru
UE-57107 Attempting to load a streamed media source causes the app to become unresponsive when device is not connected to internet
#jira UE-57107
#Android
#4.20
The ANR is because the android.media.MediaExtractor.setDataSource(UrlPath) calls an underlying api which retries the download (10-30 times).
Additional issue (all platforms): the MediaFrameworkTest/StreamSource_Infiltrator souce seems to have been removed (no longer at https://docs.unrealengine.com/latest/attachments/Engine/MediaFramework/HowTo/StreamMediaSource/Infiltrator%20Demo.mp4). According to the docs (https://docs.unrealengine.com/en-US/Engine/MediaFramework/HowTo/StreamMediaSource) the new location of the Sample Video is at https://dnnrz1gqa.blob.core.windows.net/portals/attachments/Engine/MediaFramework/HowTo/StreamMediaSource/Infiltrator%20Demo.mp4?sr=b&si=DNNFileManagerPolicy&sig=F%2BBpnYueeQTUTSW0nCRSrXEfr35LIawe7C3MQoe2%2FPI%3D
Change 3985248 by Nick.Shin
HTML5 game window size
add project setting drop down box to select canvas scaling mode
#jira UE-46555 HTML5 game window does not scale with browser size
Change 3986190 by Sorin.Gradinaru
UE-56076 Android Launch On "Running..." toast intermittently doesn't appear
#jira UE-56076
#Android
#4.10
When cancelling Launch on Device, always call CancelContinuations for the current task
Change 3986412 by Nick.Shin
CIS error fix
#jira none
Change 3987007 by Nick.Shin
HTML5 fullscreen size fix
- when using FIXED scale mode initially, there's some strange padding margins
- but, setting UE4_fullscreenScaleMode to anything "but FIXED scale mode" will work...
#jira UE-46555 HTML5 game window does not scale with browser size
Change 3988408 by Nick.Shin
HTML5 call EndSession() onbeforeunload()
? should PreExit() be called instead?
#jira UE-57207 Session End event is not generated for HTML5
Change 3991828 by Nick.Shin
HTML5 shipping build crash
some FVector2D needs ContainsNaN() checks
#jira UE-57401 Projects packaged for Shipping HTML5 do not launch the engine in the browser
Change 3992884 by Nick.Shin
HTML5 call EndSession() onbeforeunload() code cleanup
#jira UE-57207 Session End event is not generated for HTML5
Change 3992887 by Nick.Shin
datarouter: Session events code cleanup
#jira UE-22285 - Session events are not generated for HTML5
Change 4002603 by Sorin.Gradinaru
UE-56177 Unplugging a device while launching onto it from a source build will result in the "Running..." toast staying open
#jira UE-56177
#Android
#iOS
#4.10
Using the device discovery to signal when the running device gets disconnected
Change 4007162 by Dmitriy.Dyomin
Merging using Dev-Mobile->FortMain
Added ObjectOrientation material node for decals, returns decal projection direction ( X-axis)
#jira none
Change 4012196 by Sorin.Gradinaru
UE-57120 Lighting needs to be rebuilt error appears on Camera test app on Nexus 9 and Note 4.
#jira UE-57120
#Android
#4.20
Level lightings rebuilt and QA-Media_Camera_BuiltData.uasset added.
The message appeared (rarely and only on certain devices) because the engine tries to load the pre-computed lightmap data on the render thread, then to add it to the scene on the game thread (in FPrecomputedVolumetricLightmap::AddToScene).
Most of the times there is a desync and the data is not yet loaded when the lightmap is validated (in FScene::AddPrecomputedVolumetricLightmap).
Change 4013034 by Sorin.Gradinaru
UE-55427 iOS application crashes when suspending and resuming the startup movie in rapid succession
#jira UE-55427
#iOS
#4.20
Caused by ToggleSuspend waiting for FDefaultGameMoviePlayer::WaitForMovieToFinish()
Renamed InitialMovie to StartupMovie, including the methods related to the Android platform.
Change 4015449 by Sorin.Gradinaru
UE-38306 "Running xxx on yyy" panel Cancel button should terminate app
#jira UE-38306
#Android
#4.10
Run on device: Pressing Cancel on the "Running..." message should stop the application, if running
Cancel Android builds using "adb shell am force-stop <bundle_id> <device_id>"
Note: Using a new AutomationTool command (re-starting the Automation tool after canceling the BuildCookRun task chain) is too slow - takes 3-10 sec depending on the PC configuration.
AutomationTool is used now only to correctly retrieve the bundle id for each Android device. This is done inside the BuildCookRun command when the application is deployed on the device(s). Cannot simply use the current project's properties to retrieve the bundle id, because when using Launch-> Device Launcher, the user can choose to cook&deploy a different project/texture format, also the user can create & use a profile with multiple devices / with different texture formats.
Change 4016057 by Sorin.Gradinaru
UE-57845 GitHub 4666 : Pull request clipboard on android
#jira UE-57845
#4.20
#Android
#4666
https://github.com/EpicGames/UnrealEngine/pull/4666
Implemented Clipboard function on Android.
Change 4020229 by Sorin.Gradinaru
UE-57845 GitHub 4666 : Pull request clipboard on android
#jira UE-57845
#Android
#4.20
GameActivity.java: moving the methods related to clipboard above the native public declarations
Change 4021188 by Sorin.Gradinaru
UE-57876 Location accuracy is ignored by ULocationServicesIOSImpl
#jira UE-57876
#iOS
#4.30
In ULocationServicesIOSImpl::InitLocationServices(ELocationAccuracy Accuracy, float UpdateFrequency, float MinDistance) the first param must be converted to CLLocationAccuracy and used as the first param of LocationDelegateinitLocationServices, rather than using the hardcoded kCLLocationAccuracyHundredMeters.
Also fixed a compilation error (!) when enabling The Location Services plugin on iOS
Change 4024839 by Sorin.Gradinaru
UE-38306 "Running xxx on yyy" panel Cancel button should terminate app
#jira UE-38306
#Android
#4.10
Removed unnecessary #include "AndroidTargetDevice.h", causing circular reference => nightly build errors
Change 4024962 by Cosmin.Sulea
UE-56294 - Packaging step fails when packaging project for distribution
#jira UE-56294
Change 4026122 by Sorin.Gradinaru
UE-57149 Razer Phone: Crash after Switching Camera Format 22-26 times
#jira UE-57149
#Android
#4.20
jobject obj = env->GetObjectArrayElement must be followed by env->DeleteLocalRef(obj)
The bug can probably be reproduced by using a MediaPlayer.
Change 4038185 by Nick.Shin
HTML5 - merge error fix
MallocAnsi.cpp was stomped on
#jira UE-58367 //UE4/Dev-Mobile - Compile UE4Game HTML5 - use of undeclared identifier 'malloc_usable_size'
Change 4039521 by Dmitriy.Dyomin
Export WorldBrowser API so plugin makers can use it
#jira UE-57323
Change 4039523 by Dmitriy.Dyomin
Exposed MobilePatchingLibrary API
#jira UE-55941
Change 4039526 by Dmitriy.Dyomin
Fixed: Hierarchy filtering does not work in world composition
#jira UE-57900
Change 4039529 by Dmitriy.Dyomin
Fixed: 'Apply Fogging' in Material does not work on Mobile (GitHub 4357)
#jira UE-53618
#4357
Change 4039874 by Sorin.Gradinaru
UEMOB-436 Support "All Android" Launch On and Project Launcher options
The main change is in the DeviceProxy class.
A new type ("All devices" proxy) was added, and the proxy now holds a list of physical device IDs for every variant (texture format), instead of a single device ID.
The "All devices" proxy is updated automatically by the device discovery thread.
The change was necessary because the list in the Project Launcher is using the device proxy list.
#jira UEMOB-436
#Android
#UE4
#4.19
Change 4041446 by John.Mauney
Fix that Chris B made locally on my machine
#jira UE-58420
Change 4041791 by Jack.Porter
Fix CIS incremental UE4Editor Win64
#jira 0
[CL 4047603 by Jack Porter in Main branch]
1215 lines
53 KiB
Plaintext
1215 lines
53 KiB
Plaintext
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>%GAME%</title>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<script>
|
|
// THIS IS TEMP -- to be removed when the following has been removed as well
|
|
// .../Engine/Source/Runtime/Engine/Private/ActiveSound.cpp
|
|
// // for velocity-based effects like doppler
|
|
// ParseParams.Velocity = (ParseParams.Transform.GetTranslation() - LastLocation) / DeltaTime;
|
|
window.AudioContext = ( window.AudioContext || window.webkitAudioContext || null );
|
|
if ( AudioContext ) {
|
|
var ue4_hacks = {}; // making this obvious...
|
|
ue4_hacks.ctx = new AudioContext();
|
|
ue4_hacks.panner = ue4_hacks.ctx.createPanner();
|
|
ue4_hacks.panner.__proto__.setVelocity = ( ue4_hacks.panner.__proto__.setVelocity || function(){} );
|
|
}
|
|
</script>
|
|
|
|
<script>
|
|
// Minimum WebGL version that the page needs in order to run. UE4 will attempt to use WebGL 2 if available.
|
|
// Set this to 1 to run with a WebGL 1 fallback if the graphical features required by your UE4 project are
|
|
// low enough that they do not strictly require WebGL 2.
|
|
const requiredWebGLVersion = 1;
|
|
|
|
// Add ?webgl1 GET param to explicitly test the WebGL 1 fallback version even if browser does support WebGL 2.
|
|
const explicitlyUseWebGL1 = (location.search.indexOf('webgl1') != -1);
|
|
|
|
// Deduce which version to load up.
|
|
var supportsWasm = (typeof WebAssembly === 'object' && typeof WebAssembly.Memory === 'function');
|
|
|
|
// By default, Shipping builds serve out compressed assets, and Development builds serve uncompressed assets.
|
|
// Change the following line to customize. When hosting UE4 builds live on a production CDN, compression
|
|
// should always be enabled, since uncompressed files are too huge to be downloaded over the web.
|
|
const serveCompressedAssets = %SERVE_COMPRESSED%;
|
|
|
|
// For the large .data file, there's two ways to manage compression: either UE4 UnrealPak tool can compress it in engine, or
|
|
// it can be gzip compressed on disk like other assets. Compressing via UnrealPak has the advantage of storing a smaller data
|
|
// file to IndexedDB, whereas gzip compressing to disk has the advantage of starting up the page slightly faster.
|
|
// If true, serve out 'UE4Game.data.gz', if false, serve out 'UE4Game.data'.
|
|
// const dataFileIsGzipCompressed = false;
|
|
|
|
var Module = {
|
|
// state management
|
|
infoPrinted: false,
|
|
lastcurrentDownloadedSize: 0,
|
|
totalDependencies: 0,
|
|
dataBytesStoredInIndexedDB: 0, // Track how much data is currently stored in IndexedDB.
|
|
|
|
assetDownloadProgress: {}, // Track how many bytes of each needed asset has been downloaded so far.
|
|
|
|
UE4_indexedDBName: 'UE4_assetDatabase_%GAME%', // TODO Nick: this should be an ascii ID string without special characters that is unique to the project that is being packaged
|
|
UE4_indexedDBVersion: %TIMESTAMP%, // Bump this number to invalidate existing IDB storages in browsers.
|
|
};
|
|
|
|
// Tests if type === 'browser' or type === 'os' is 64-bit or not.
|
|
function heuristicIs64Bit(type) {
|
|
function contains(str, substrList) { for(var i in substrList) if (str.indexOf(substrList[i]) != -1) return true; return false; }
|
|
var ua = (navigator.userAgent + ' ' + navigator.oscpu + ' ' + navigator.platform).toLowerCase();
|
|
if (contains(ua, ['wow64'])) return type === 'os'; // 32bit browser on 64bit OS
|
|
if (contains(ua, ['x86_64', 'amd64', 'ia64', 'win64', 'x64', 'arm64', 'irix64', 'mips64', 'ppc64', 'sparc64'])) return true;
|
|
if (contains(ua, ['i386', 'i486', 'i586', 'i686', 'x86', 'arm7', 'android', 'mobile', 'win32'])) return false;
|
|
if (contains(ua, ['intel mac os'])) return true;
|
|
return false;
|
|
}
|
|
|
|
// For best stability on 32-bit browsers, allocate asm.js/WebAssembly heap up front before proceeding
|
|
// to load any other page content. This mitigates the chances that loading up page assets first would
|
|
// fragment the memory area of the browser process.
|
|
var pageSize = 64 * 1024;
|
|
var heuristic64BitBrowser = heuristicIs64Bit('browser');
|
|
function alignPageUp(size) { return pageSize * Math.ceil(size / pageSize); }
|
|
|
|
// The application should not be able to allocate more than MAX bytes of memory. If the application
|
|
// attempts to allocate any more, it will be forbidden. Use this field to defensively impose a
|
|
// strict limit to an application to keep it from going rogue with its memory usage beyond some
|
|
// undesired limit. The absolute maximum that is possible is one memory page short of 2GB.
|
|
var MAX_MEMORY_64BIT = Infinity;
|
|
var MAX_MEMORY_32BIT = 512*1024*1024;
|
|
var MAX_MEMORY = Math.min(alignPageUp(heuristic64BitBrowser ? MAX_MEMORY_64BIT : MAX_MEMORY_32BIT), 2048 * 1024 * 1024 - pageSize);
|
|
|
|
// The application needs at least this much memory to run. If the browser can't provide this,
|
|
// the page startup should be aborted in an out-of-memory exception.
|
|
var MIN_MEMORY = Math.min(alignPageUp(32 * 1024 * 1024), MAX_MEMORY);
|
|
|
|
// As a hint to the implementation, the application would prefer to reserve this much address
|
|
// space at startup, and the browser will attempt its best to satisfy this. If this is not
|
|
// possible, the browser will attempt to allocate anything as close to this IDEAL amount as
|
|
// possible, but at least MIN bytes.
|
|
var IDEAL_MEMORY_64BIT = %HEAPSIZE%;
|
|
var IDEAL_MEMORY_32BIT = %HEAPSIZE%;
|
|
var IDEAL_MEMORY = Math.min(Math.max(alignPageUp(heuristic64BitBrowser ? IDEAL_MEMORY_64BIT : IDEAL_MEMORY_32BIT), MIN_MEMORY), MAX_MEMORY);
|
|
|
|
// If true, assume the application will have most of its memory allocation pressure inside the
|
|
// application heap, so reserve address space there up front. If false, assume that the memory
|
|
// allocation pressure is outside the heap, so avoid reserving memory up front, until needed.
|
|
var RESERVE_MAX_64BIT = true;
|
|
var RESERVE_MAX_32BIT = false;
|
|
var RESERVE_MAX = heuristic64BitBrowser ? RESERVE_MAX_64BIT : RESERVE_MAX_32BIT;
|
|
|
|
function MB(x) { return (x/1024/1024) + 'MB'; }
|
|
function allocateHeap() {
|
|
// Try to get as much memory close to IDEAL, but at least MIN.
|
|
for(var mem = IDEAL_MEMORY; mem >= MIN_MEMORY; mem -= pageSize) {
|
|
try {
|
|
if (RESERVE_MAX)
|
|
Module['wasmMemory'] = new WebAssembly.Memory({ initial: mem / pageSize, maximum: MAX_MEMORY / pageSize });
|
|
else
|
|
Module['wasmMemory'] = new WebAssembly.Memory({ initial: mem / pageSize });
|
|
Module['buffer'] = Module['wasmMemory'].buffer;
|
|
if (Module['buffer'].byteLength != mem) throw 'Out of memory';
|
|
break;
|
|
} catch(e) { /*nop*/ }
|
|
}
|
|
if (!Module['buffer'] || !(Module['buffer'].byteLength >= MIN_MEMORY)) {
|
|
delete Module['buffer'];
|
|
throw 'Out of memory';
|
|
}
|
|
Module['TOTAL_MEMORY'] = Module['buffer'].byteLength;
|
|
}
|
|
allocateHeap();
|
|
Module['MAX_MEMORY'] = MAX_MEMORY;
|
|
console.log('Initial memory size: ' + MB(Module['TOTAL_MEMORY']) + ' (MIN_MEMORY: ' + MB(MIN_MEMORY) + ', IDEAL_MEMORY: ' + MB(IDEAL_MEMORY) + ', MAX_MEMORY: ' + MB(MAX_MEMORY) + ', RESERVE_MAX: ' + RESERVE_MAX + ', heuristic64BitBrowser: ' + heuristic64BitBrowser + ', heuristic64BitOS: ' + heuristicIs64Bit('os') + ')');
|
|
</script>
|
|
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
|
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
|
|
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
|
|
</head>
|
|
<body>
|
|
|
|
<style type="text/css">
|
|
|
|
html, body, .container {
|
|
height: 100%;
|
|
font-family: "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif;
|
|
}
|
|
|
|
.h4, h4 {
|
|
margin-top: 1pt;
|
|
margin-bottom: 1pt;
|
|
font-size: 10pt;
|
|
}
|
|
|
|
.container {
|
|
display: table;
|
|
vertical-align: middle;
|
|
border: 0px;
|
|
border-spacing: 0px;
|
|
}
|
|
|
|
.glyphicon-spin {
|
|
animation: spin 2000ms infinite linear;
|
|
}
|
|
|
|
@keyframes spin {
|
|
0% {
|
|
transform: rotate(0deg);
|
|
}
|
|
100% {
|
|
transform: rotate(359deg);
|
|
}
|
|
}
|
|
|
|
@-webkit-keyframes spin {
|
|
0% {
|
|
transform: rotate(0deg);
|
|
}
|
|
100% {
|
|
transform: rotate(359deg);
|
|
}
|
|
}
|
|
|
|
.wrapper {
|
|
position: relative;
|
|
margin: 1em auto 10px auto;
|
|
text-align: center;
|
|
min-width: 640px;
|
|
width: 100%;
|
|
height: 480px; /* initial height, will be dynamically adjusted at runtime */
|
|
max-width: 95%;
|
|
display: block;
|
|
align-items: center;
|
|
position: relative;
|
|
text-align: center;
|
|
justify-content: center;
|
|
}
|
|
|
|
.emscripten {
|
|
padding-right: 0;
|
|
margin-left: auto;
|
|
margin-right: auto;
|
|
display: block;
|
|
display: -webkit-box;
|
|
display: -moz-box;
|
|
display: box;
|
|
|
|
-webkit-box-align: center;
|
|
-moz-box-align: center;
|
|
box-align: center;
|
|
|
|
-webkit-box-pack: center;
|
|
-moz-box-pack: center;
|
|
box-pack: center;
|
|
}
|
|
|
|
#canvas:not([fullscreen]) {
|
|
padding-right: 0;
|
|
margin-left: auto;
|
|
margin-right: auto;
|
|
width: 100%;
|
|
}
|
|
|
|
.texthalf {
|
|
height: 37%;
|
|
border: 0px;
|
|
padding: 0px;
|
|
overflow-y: scroll;
|
|
font-size: 2em;
|
|
}
|
|
|
|
.buttonarea {
|
|
min-height: 3%;
|
|
border-top: 0px;
|
|
border-bottom: 0px;
|
|
padding: 0px;
|
|
margin-right: 0px;
|
|
margin-top: 0px;
|
|
margin-bottom: 0px;
|
|
}
|
|
|
|
.btn { padding: 0px; text-align: center; min-width: 150px }
|
|
.progress { background: rgba(245, 245, 245, 1); border: 0px solid rgba(245, 245, 245, 1); border-radius: 0px; height: 4px; }
|
|
.progress-bar-custom { background: rgba(153, 153, 153, 1); }
|
|
.centered-axis-xy {
|
|
position: absolute;
|
|
left: 50%;
|
|
top: 50%;
|
|
transform: translate(-50%,-50%);
|
|
}
|
|
</style>
|
|
|
|
<div class="wrapper" id="mainarea">
|
|
<div class="alert alert-warning centered-axis-xy" style="min-height: 20px; display:none;" role="alert" id="compilingmessage">
|
|
<div id='loadTasks'> </div>
|
|
</div>
|
|
<canvas id="canvas" class="emscripten" oncontextmenu="event.preventDefault()" style="display:none;">
|
|
</div>
|
|
<div class="row buttonarea text-center" id="buttonrow">
|
|
<div class="col-sm-2 text-center"></div>
|
|
<div class="col-sm-2 text-center"><button type="button" class="btn btn-primary" onclick="Module['pauseMainLoop']();">Pause</button></div>
|
|
<div class="col-sm-2 text-center"><button type="button" class="btn btn-primary" onclick="Module['resumeMainLoop']();">Resume</button></div>
|
|
<div class="col-sm-2 text-center"></div>
|
|
<div class="col-sm-2 text-center"><button type="button" class="btn btn-primary" id='clear_indexeddb' onclick="deleteIndexedDBStorage();">Clear IndexedDB</button></div>
|
|
<div class="col-sm-2 text-center"><button type="button" class="btn btn-primary" id="fullscreen_request">FullScreen</button></div>
|
|
<div class="col-sm-2 text-center"></div>
|
|
<div class="col-sm-2 text-center"></div>
|
|
</div>
|
|
<div class="texthalf text-normal jumbotron " id="logwindow" style='display:none'></div>
|
|
|
|
<script type="text/javascript">
|
|
|
|
// combine all parallel downloads into one progress bar.
|
|
var totalDownloadSize = 0;
|
|
var currentDownloadedSize = 0;
|
|
|
|
// helper functions.
|
|
// http://stackoverflow.com/questions/4750015/regular-expression-to-find-urls-within-a-string
|
|
function getHTMLGetParam(name) {
|
|
if (name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
|
|
return decodeURIComponent(name[1]);
|
|
}
|
|
|
|
var UE4 = {
|
|
on_fatal: function() {
|
|
try {
|
|
UE4.on_fatal = Module.cwrap('on_fatal', null, ['string', 'string']);
|
|
} catch(e) {
|
|
UE4.on_fatal = function() {};
|
|
}
|
|
},
|
|
};
|
|
|
|
Module['preinitializedWebGLContext'] = null;
|
|
|
|
function getGpuInfo() {
|
|
var gl = Module['preinitializedWebGLContext'];
|
|
if (!gl) return '(no GL: ' + Module['webGLErrorReason'] + ')';
|
|
|
|
var glInfo = '';
|
|
var debugInfo = gl.getExtension('WEBGL_debug_renderer_info');
|
|
if (debugInfo) glInfo += gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL) + ' ' + gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL) + '/';
|
|
glInfo += gl.getParameter(gl.VENDOR) + ' ' + gl.getParameter(gl.RENDERER);
|
|
glInfo += ' ' + gl.getParameter(gl.VERSION);
|
|
glInfo += ', ' + gl.getParameter(gl.SHADING_LANGUAGE_VERSION);
|
|
if (Module['softwareWebGL']) glInfo += ' (software)';
|
|
return glInfo;
|
|
}
|
|
|
|
function detectWebGL() {
|
|
var canvas = Module['canvas'] || document.createElement("canvas");
|
|
// If you run into problems with WebGL 2, or for quick testing purposes, you can disable UE4
|
|
// from using WebGL 2 and revert back to WebGL 1 by setting the following flag to true.
|
|
var disableWebGL2 = false;
|
|
if (explicitlyUseWebGL1) {
|
|
disableWebGL2 = true;
|
|
console.log('Disabled WebGL 2 as requested by ?webgl1 GET param.');
|
|
}
|
|
var names = ["webgl", "experimental-webgl"];
|
|
if (disableWebGL2) {
|
|
WebGL2RenderingContext = undefined;
|
|
} else {
|
|
names = ["webgl2"].concat(names);
|
|
}
|
|
function testError(e) { Module['webGLErrorReason'] = e.statusMessage; };
|
|
canvas.addEventListener("webglcontextcreationerror", testError, false);
|
|
try {
|
|
for(var failIfMajorPerformanceCaveat = 1; failIfMajorPerformanceCaveat >= 0; --failIfMajorPerformanceCaveat) {
|
|
for(var i in names) {
|
|
try {
|
|
var context = canvas.getContext(names[i], {antialias:false,alpha:false,depth:true,stencil:true,failIfMajorPerformanceCaveat:!!failIfMajorPerformanceCaveat});
|
|
Module['preinitializedWebGLContext'] = context;
|
|
Module['softwareWebGL'] = !failIfMajorPerformanceCaveat;
|
|
if (context && typeof context.getParameter == "function") {
|
|
if (typeof WebGL2RenderingContext !== 'undefined' && context instanceof WebGL2RenderingContext && names[i] == 'webgl2') {
|
|
return 2;
|
|
} else {
|
|
// We were able to precreate only a WebGL 1 context, remove support for WebGL 2 from the rest of the page execution.
|
|
WebGL2RenderingContext = undefined;
|
|
return 1;
|
|
}
|
|
}
|
|
} catch(e) { Module['webGLErrorReason'] = e.toString(); }
|
|
}
|
|
}
|
|
} finally {
|
|
canvas.removeEventListener("webglcontextcreationerror", testError, false);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
Module['canvas'] = document.getElementById('canvas');
|
|
|
|
// Canvas scaling mode should be set to one of: 1=STRETCH, 2=ASPECT, or 3=FIXED.
|
|
// This dictates how the canvas size changes when the browser window is resized
|
|
// by dragging from the corner.
|
|
var canvasWindowedScaleMode = %CANVASSCALEMODE%;
|
|
|
|
// High DPI setting configures whether to match the canvas size 1:1 with
|
|
// the physical pixels on the screen.
|
|
// For background, see https://www.khronos.org/webgl/wiki/HandlingHighDPI
|
|
var canvasWindowedUseHighDpi = true;
|
|
|
|
// Stores the initial size of the canvas in physical pixel units.
|
|
// If canvasWindowedScaleMode == 3 (FIXED), this size defines the fixed resolution
|
|
// that the app will render to.
|
|
// If canvasWindowedScaleMode == 2 (ASPECT), this size defines only the aspect ratio
|
|
// that the canvas will be constrained to.
|
|
// If canvasWindowedScaleMode == 1 (STRETCH), these size values are ignored.
|
|
var canvasAspectRatioWidth = 1366;
|
|
var canvasAspectRatioHeight = 768;
|
|
|
|
// Fullscreen scaling mode behavior (export these to Module object for the engine to read)
|
|
// This value is one of:
|
|
// 0=NONE: The same canvas size is kept when entering fullscreen without change.
|
|
// 1=STRETCH: The canvas is resized to the size of the whole screen, potentially changing aspect ratio.
|
|
// 2=ASPECT: The canvas is resized to the size of the whole screen, but retaining current aspect ratio.
|
|
// 3=FIXED: The canvas is centered on screen with a fixed resolution.
|
|
Module['UE4_fullscreenScaleMode'] = 1;//canvasWindowedScaleMode; // BUG: if using FIXED, fullscreen gets some strange padding on margin...
|
|
|
|
// When entering fullscreen mode, should UE4 engine resize the canvas?
|
|
// 0=No resizing (do it manually in resizeCanvas()), 1=Resize to standard DPI, 2=Resize to highDPI
|
|
Module['UE4_fullscreenCanvasResizeMode'] = canvasWindowedUseHighDpi ? 2/*HIDPI*/ : 1/*Standard DPI*/;
|
|
|
|
// Specifies how canvas is scaled to fullscreen, if not rendering in 1:1 pixel perfect mode.
|
|
// One of 0=Default, 1=Nearest, 2=Bilinear
|
|
Module['UE4_fullscreenFilteringMode'] = 0;
|
|
|
|
document.addEventListener('error', function(){document.getElementById('clear_indexeddb').style.display = 'inline-block';}, false);
|
|
|
|
// Startup task which is run after UE4 engine has launched.
|
|
function postRunEmscripten() {
|
|
taskFinished(TASK_MAIN);
|
|
$("#compilingmessage").remove();
|
|
|
|
// The default Emscripten provided canvas resizing behavior is not needed,
|
|
// since we are controlling the canvas sizes here, so stub those functions out.
|
|
Browser.updateCanvasDimensions = function() {};
|
|
Browser.setCanvasSize = function() {};
|
|
|
|
// If you'd like to configure the initial canvas size to render using the resolution
|
|
// defined in UE4 DefaultEngine.ini [SystemSettings] r.setRes=WidthxHeight,
|
|
// uncomment the following two lines before calling resizeCanvas() below:
|
|
|
|
// canvasAspectRatioWidth = UE_JSlib.UE_GSystemResolution_ResX();
|
|
// canvasAspectRatioHeight = UE_JSlib.UE_GSystemResolution_ResY();
|
|
|
|
// Configure the size of the canvas and display it.
|
|
resizeCanvas();
|
|
Module['canvas'].style.display = 'block';
|
|
|
|
// Whenever the browser window size changes, relayout the canvas size on the page.
|
|
window.addEventListener('resize', resizeCanvas, false);
|
|
window.addEventListener('orientationchange', resizeCanvas, false);
|
|
|
|
// The following is needed if game is within an iframe - main window already has focus...
|
|
window.focus();
|
|
}
|
|
Module.postRun = [postRunEmscripten];
|
|
|
|
// The resizeCanvas() function recomputes the canvas size on the page as the user changes
|
|
// the browser window size.
|
|
function resizeCanvas(aboutToEnterFullscreen) {
|
|
// Configuration variables, feel free to play around with these to tweak.
|
|
var minimumCanvasHeightCssPixels = 480; // the visible size of the canvas should always be at least this high (in CSS pixels)
|
|
var minimumCanvasHeightFractionOfBrowserWindowHeight = 0.65; // and also vertically take up this much % of the total browser client area height.
|
|
|
|
if (aboutToEnterFullscreen && !aboutToEnterFullscreen.type) { // UE4 engine is calling this function right before entering fullscreen?
|
|
// If you want to perform specific resolution setup here, do so by setting Module['canvas'].width x Module['canvas'].height now,
|
|
// and configure Module['UE4_fullscreenXXX'] fields above. Most of the time, the defaults are good, so no need to resize here.
|
|
// Return true here if you want to abort entering fullscreen mode altogether.
|
|
return;
|
|
}
|
|
|
|
// The browser called resizeCanvas() to notify that we just entered fullscreen? In that case, we never react, since the strategy is
|
|
// to always set the canvas size right before entering fullscreen.
|
|
if (document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement) {
|
|
return;
|
|
}
|
|
|
|
var mainArea = document.getElementById('mainarea');
|
|
var canvasRect = mainArea.getBoundingClientRect();
|
|
|
|
// Compute the unconstrained size for the div that encloses the canvas, in CSS pixel units.
|
|
var cssWidth = canvasRect.right - canvasRect.left;
|
|
var cssHeight = Math.max(minimumCanvasHeightCssPixels, canvasRect.bottom - canvasRect.top, window.innerHeight * minimumCanvasHeightFractionOfBrowserWindowHeight);
|
|
|
|
if (canvasWindowedScaleMode == 3/*NONE*/) {
|
|
// In fixed display mode, render to a statically determined WebGL render target size.
|
|
var newRenderTargetWidth = canvasAspectRatioWidth;
|
|
var newRenderTargetHeight = canvasAspectRatioHeight;
|
|
} else {
|
|
// Convert unconstrained render target size from CSS to physical pixel units.
|
|
var newRenderTargetWidth = canvasWindowedUseHighDpi ? (cssWidth * window.devicePixelRatio) : cssWidth;
|
|
var newRenderTargetHeight = canvasWindowedUseHighDpi ? (cssHeight * window.devicePixelRatio) : cssHeight;
|
|
|
|
// Apply aspect ratio constraints, if desired.
|
|
if (canvasWindowedScaleMode == 2/*ASPECT*/) {
|
|
if (cssWidth * canvasAspectRatioHeight > canvasAspectRatioWidth * cssHeight) {
|
|
newRenderTargetWidth = newRenderTargetHeight * canvasAspectRatioWidth / canvasAspectRatioHeight;
|
|
} else {
|
|
newRenderTargetHeight = newRenderTargetWidth * canvasAspectRatioHeight / canvasAspectRatioWidth;
|
|
}
|
|
}
|
|
|
|
// WebGL render target sizes are always full integer pixels in size, so rounding is critical for CSS size computations below.
|
|
newRenderTargetWidth = Math.round(newRenderTargetWidth);
|
|
newRenderTargetHeight = Math.round(newRenderTargetHeight);
|
|
}
|
|
|
|
// Very subtle but important behavior is that the size of a DOM element on a web page in CSS pixel units can be a fraction, e.g. on
|
|
// high DPI scaling displays (CSS pixel units are "virtual" pixels). If the CSS size and physical pixel size of the WebGL canvas do
|
|
// not correspond to each other 1:1 after window.devicePixelRatio scaling has been applied, the result can look blurry. Therefore always
|
|
// first compute the WebGL render target size first in physical pixels, and convert that back to CSS pixels so that the CSS pixel size
|
|
// will perfectly align up and the result look clear without scaling applied.
|
|
cssWidth = canvasWindowedUseHighDpi ? (newRenderTargetWidth / window.devicePixelRatio) : newRenderTargetWidth;
|
|
cssHeight = canvasWindowedUseHighDpi ? (newRenderTargetHeight / window.devicePixelRatio) : newRenderTargetHeight;
|
|
|
|
Module['canvas'].width = newRenderTargetWidth;
|
|
Module['canvas'].height = newRenderTargetHeight;
|
|
|
|
Module['canvas'].style.width = cssWidth + 'px';
|
|
Module['canvas'].style.height = mainArea.style.height = cssHeight + 'px';
|
|
|
|
// Tell the engine that the web page has changed the size of the WebGL render target on the canvas (Module['canvas'].width/height).
|
|
// This will update the GL viewport and propagate the change throughout the engine.
|
|
// If the CSS style size is changed, this function doesn't need to be called.
|
|
if (UE_JSlib.UE_CanvasSizeChanged) UE_JSlib.UE_CanvasSizeChanged();
|
|
}
|
|
Module['UE4_resizeCanvas'] = resizeCanvas;
|
|
|
|
Module.arguments = [%UE4CMDLINE%];
|
|
|
|
// we are serving via a server and it is unreal file server?
|
|
if (location.host != "" && getHTMLGetParam("cookonthefly") == "true") {
|
|
Module.arguments.push("'-filehostIp=" + location.protocol + "//" + location.host + "'");
|
|
}
|
|
|
|
function addLog(info, color) {
|
|
$("#logwindow").append("<h4><small>" + info + " </small></h4>");
|
|
}
|
|
Module.print = addLog;
|
|
|
|
Module.printErr = function(text) {
|
|
console.error(text);
|
|
};
|
|
|
|
// Module.locateFile() routes asset downloads to either gzip compressed or uncompressed assets.
|
|
Module.locateFile = function(name) {
|
|
var serveGzipped = serveCompressedAssets;
|
|
// When serving from file:// URLs, don't read .gz compressed files, because these files can't be transparently uncompressed.
|
|
var isFileProtocol = name.indexOf('file://') != -1 || location.protocol.indexOf('file') != -1;
|
|
if (isFileProtocol) {
|
|
if (!Module['shownFileProtocolWarning']) {
|
|
showWarningRibbon('Attempting to load the page via the "file://" protocol. This only works in Firefox, and even there only when not using compression, so attempting to load uncompressed assets. Please host the page on a web server and visit it via a "http://" URL.');
|
|
Module['shownFileProtocolWarning'] = true;
|
|
}
|
|
serveGzipped = false;
|
|
}
|
|
|
|
// uncompressing very large gzip files may slow down startup times.
|
|
// if (!dataFileIsGzipCompressed && name.split('.').slice(-1)[0] == 'data') serveGzipped = false;
|
|
|
|
return serveGzipped ? (name + 'gz') : name;
|
|
};
|
|
|
|
Module.getPreloadedPackage = function(remotePackageName, remotePackageSize) {
|
|
return Module['preloadedPackages'] ? Module['preloadedPackages'][remotePackageName] : null;
|
|
}
|
|
|
|
// Asynchronously appends the given script code to DOM. This is to ensure that
|
|
// browsers parse and compile the JS code parallel to all other execution.
|
|
function addScriptToDom(scriptCode) {
|
|
return new Promise(function(resolve, reject) {
|
|
var script = document.createElement('script');
|
|
var blob = (scriptCode instanceof Blob) ? scriptCode : new Blob([scriptCode], { type: 'text/javascript' });
|
|
var objectUrl = URL.createObjectURL(blob);
|
|
script.src = objectUrl;
|
|
script.onload = function() {
|
|
script.onload = script.onerror = null; // Remove these onload and onerror handlers, because these capture the inputs to the Promise and the input function, which would leak a lot of memory!
|
|
URL.revokeObjectURL(objectUrl); // Free up the blob. Note that for debugging purposes, this can be useful to comment out to be able to read the sources in debugger.
|
|
resolve();
|
|
}
|
|
script.onerror = function(e) {
|
|
script.onload = script.onerror = null; // Remove these onload and onerror handlers, because these capture the inputs to the Promise and the input function, which would leak a lot of memory!
|
|
URL.revokeObjectURL(objectUrl);
|
|
console.error('script failed to add to dom: ' + e);
|
|
console.error(scriptCode);
|
|
console.error(e);
|
|
// The onerror event sends a DOM Level 3 event error object, which does not seem to have any kind of human readable error reason (https://developer.mozilla.org/en-US/docs/Web/Events/error)
|
|
// There is another error event object at https://developer.mozilla.org/en-US/docs/Web/API/ErrorEvent, which would have an error reason. Perhaps that error event might sometimes be fired,
|
|
// but if not, guess that the error reason was an OOM, since we are dealing with large .js files.
|
|
reject(e.message || "(out of memory?)");
|
|
}
|
|
document.body.appendChild(script);
|
|
});
|
|
}
|
|
|
|
var TASK_DOWNLOADING = 0;
|
|
var TASK_COMPILING = 1;
|
|
var TASK_SHADERS = 2;
|
|
var TASK_MAIN = 3;
|
|
var loadTasks = [ 'Downloading', 'Compiling WebAssembly', 'Building shaders', 'Launching engine'];
|
|
|
|
function taskProgress(taskId, progress) {
|
|
var c = document.getElementById('compilingmessage');
|
|
if (c) c.style.display = 'block';
|
|
else return;
|
|
var l = document.getElementById('load_' + taskId);
|
|
if (!l) {
|
|
var tasks = document.getElementById('loadTasks');
|
|
if (!tasks) return;
|
|
l = document.createElement('div');
|
|
l.innerHTML = '<span id="icon_' + taskId + '" class="glyphicon glyphicon-refresh glyphicon-spin"></span> <span id="load_' + taskId + '"></span>';
|
|
tasks.appendChild(l);
|
|
l = document.getElementById('load_' + taskId);
|
|
}
|
|
if (!l.startTime) l.startTime = performance.now();
|
|
var text = loadTasks[taskId];
|
|
if (progress && progress.total) {
|
|
text += ': ' + (progress.currentShow || progress.current) + '/' + (progress.totalShow || progress.total) + ' (' + (progress.current * 100 / progress.total).toFixed(0) + '%)';
|
|
} else {
|
|
text += '...';
|
|
}
|
|
l.innerHTML = text;
|
|
}
|
|
|
|
function showErrorDialog(errorText) {
|
|
if ( errorText.indexOf('SyntaxError: ') != -1 ) { // this may be due to caching issue -- otherwise, compile time would have caught this
|
|
errorText = "NOTE: attempting to flush cache and force reload...<br>Please standby...";
|
|
setTimeout(function() {
|
|
location.reload(true);
|
|
}, 2000); // 2 seconds
|
|
}
|
|
console.error('error: ' + errorText);
|
|
var existingErrorDialog = document.getElementById('errorDialog');
|
|
if (existingErrorDialog) {
|
|
existingErrorDialog.innerHTML += '<br>' + errorText;
|
|
} else {
|
|
$('#mainarea').empty();
|
|
$('#mainarea').append('<div class="alert alert-danger centered-axis-xy" style ="min-height: 10pt" role="alert" id="errorDialog">' + errorText + '</div></div>');
|
|
}
|
|
}
|
|
|
|
function showWarningRibbon(warningText) {
|
|
var existingWarningDialog = document.getElementById('warningDialog');
|
|
if (existingWarningDialog) {
|
|
existingWarningDialog.innerHTML += '<br>' + warningText;
|
|
} else {
|
|
$('#buttonrow').prepend('<div class="alert alert-warning centered-axis-x" role="warning" id="warningDialog" style="padding-top:5px; padding-bottom: 5px">' + warningText + '</div></div>');
|
|
}
|
|
}
|
|
|
|
function taskFinished(taskId, error) {
|
|
var l = document.getElementById('load_' + taskId);
|
|
var icon = document.getElementById('icon_' + taskId);
|
|
if (l && icon) {
|
|
var totalTime = performance.now() - l.startTime;
|
|
if (!error) {
|
|
l.innerHTML = loadTasks[taskId] + ' (' + (totalTime/1000).toFixed(2) + 's)';
|
|
icon.className = 'glyphicon glyphicon-ok';
|
|
}
|
|
else {
|
|
l.innerHTML = loadTasks[taskId] + ': FAILED! ' + error;
|
|
icon.className = 'glyphicon glyphicon-remove';
|
|
|
|
showErrorDialog(loadTasks[taskId] + ' failed: <br> ' + error);
|
|
}
|
|
}
|
|
}
|
|
|
|
window.onerror = function(e) {
|
|
e = e.toString();
|
|
if (e.toLowerCase().indexOf('memory') != -1) {
|
|
e += '<br>';
|
|
if (!heuristic64BitBrowser) e += ' Try running in a 64-bit browser to resolve.';
|
|
}
|
|
showErrorDialog(e);
|
|
}
|
|
|
|
function formatBytes(bytes) {
|
|
if (bytes >= 1024*1024*1024) return (bytes / (1024*1024*1024)).toFixed(1) + ' GB';
|
|
if (bytes >= 1024*1024) return (bytes / (1024*1024)).toFixed(0) + ' MB';
|
|
if (bytes >= 1024) return (bytes / 1024).toFixed(1) + ' KB';
|
|
return bytes + ' B';
|
|
}
|
|
|
|
function reportDataBytesStoredInIndexedDB(deltaBytes) {
|
|
if (deltaBytes === null) Module['dataBytesStoredInIndexedDB'] = 0; // call with deltaBytes == null to report that DB was cleared.
|
|
else Module['dataBytesStoredInIndexedDB'] += deltaBytes;
|
|
document.getElementById('clear_indexeddb').innerText = 'Clear IndexedDB (' + formatBytes(Module['dataBytesStoredInIndexedDB']) + ')';
|
|
}
|
|
|
|
function reportDownloadProgress(url, downloadedBytes, totalBytes, finished) {
|
|
Module['assetDownloadProgress'][url] = {
|
|
current: downloadedBytes,
|
|
total: totalBytes,
|
|
finished: finished
|
|
};
|
|
var aggregated = {
|
|
current: 0,
|
|
total: 0,
|
|
finished: true
|
|
};
|
|
for(var i in Module['assetDownloadProgress']) {
|
|
aggregated.current += Module['assetDownloadProgress'][i].current;
|
|
aggregated.total += Module['assetDownloadProgress'][i].total;
|
|
aggregated.finished = aggregated.finished && Module['assetDownloadProgress'][i].finished;
|
|
}
|
|
|
|
aggregated.currentShow = formatBytes(aggregated.current);
|
|
aggregated.totalShow = formatBytes(aggregated.total);
|
|
|
|
if (aggregated.finished) taskFinished(TASK_DOWNLOADING);
|
|
else taskProgress(TASK_DOWNLOADING, aggregated);
|
|
}
|
|
|
|
function download(url, responseType) {
|
|
return new Promise(function(resolve, reject) {
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open('GET', url, true);
|
|
xhr.responseType = responseType || 'blob';
|
|
reportDownloadProgress(url, 0, 1);
|
|
xhr.onload = function() {
|
|
if (xhr.status == 0 || (xhr.status >= 200 && xhr.status < 300)) {
|
|
var len = xhr.response.size || xhr.response.byteLength;
|
|
reportDownloadProgress(url, len, len, true);
|
|
resolve(xhr.response);
|
|
} else {
|
|
taskFinished(TASK_DOWNLOADING, 'HTTP error ' + (xhr.status || 404) + ' ' + xhr.statusText + ' on file ' + url);
|
|
reject({
|
|
status: xhr.status,
|
|
statusText: xhr.statusText
|
|
});
|
|
}
|
|
};
|
|
xhr.onprogress = function(p) {
|
|
if (p.lengthComputable) reportDownloadProgress(url, p.loaded, p.total);
|
|
};
|
|
xhr.onerror = function(e) {
|
|
var isFileProtocol = url.indexOf('file://') == 0 || location.protocol.indexOf('file') != -1;
|
|
if (isFileProtocol) taskFinished(TASK_DOWNLOADING, 'HTTP error ' + (xhr.status || 404) + ' ' + xhr.statusText + ' on file ' + url +'<br>Try using a web server to avoid loading via a "file://" URL.'); // Convert the most common source of errors to a more friendly message format.
|
|
else taskFinished(TASK_DOWNLOADING, 'HTTP error ' + (xhr.status || 404) + ' ' + xhr.statusText + ' on file ' + url);
|
|
reject({
|
|
status: xhr.status || 404,
|
|
statusText: xhr.statusText
|
|
});
|
|
};
|
|
xhr.onreadystatechange = function() {
|
|
if (xhr.readyState >= xhr.HEADERS_RECEIVED) {
|
|
if (url.endsWith('gz') && (xhr.status == 0 || xhr.status == 200)) {
|
|
if (xhr.getResponseHeader('Content-Encoding') != 'gzip') {
|
|
// A fallback is to set serveCompressedAssets = false to serve uncompressed assets instead, but that is not really recommended for production use, since gzip compression shrinks
|
|
// download sizes so dramatically that omitting it for production is not a good idea.
|
|
taskFinished(TASK_DOWNLOADING, 'Downloaded a compressed file ' + url + ' without the necessary HTTP response header "Content-Encoding: gzip" specified!<br>Please configure gzip compression on this asset on the web server to serve gzipped assets!');
|
|
xhr.onload = xhr.onprogress = xhr.onerror = xhr.onreadystatechange = null; // Abandon tracking events from this XHR further.
|
|
xhr.abort();
|
|
return reject({
|
|
status: 406,
|
|
statusText: 'Not Acceptable'
|
|
});
|
|
}
|
|
|
|
// After enabling Content-Encoding: gzip, make sure that the appropriate MIME type is being used for the asset, i.e. the MIME
|
|
// type should be that of the uncompressed asset, and not the MIME type of the compression method that was used.
|
|
if (xhr.getResponseHeader('Content-Type').toLowerCase().indexOf('zip') != -1) {
|
|
function expectedMimeType(url) {
|
|
if (url.indexOf('.wasm') != -1) return 'application/wasm';
|
|
if (url.indexOf('.js') != -1) return 'application/javascript';
|
|
return 'application/octet-stream';
|
|
}
|
|
taskFinished(TASK_DOWNLOADING, 'Downloaded a compressed file ' + url + ' with incorrect HTTP response header "Content-Type: ' + xhr.getResponseHeader('Content-Type') + '"!<br>Please set the MIME type of the asset to "' + expectedMimeType(url) + '".');
|
|
xhr.onload = xhr.onprogress = xhr.onerror = xhr.onreadystatechange = null; // Abandon tracking events from this XHR further.
|
|
xhr.abort();
|
|
return reject({
|
|
status: 406,
|
|
statusText: 'Not Acceptable'
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
xhr.send(null);
|
|
});
|
|
}
|
|
|
|
function getIDBRequestErrorString(req) {
|
|
try { return req.error ? ('IndexedDB ' + req.error.name + ': ' + req.error.message) : req.result;
|
|
} catch(ex) { return null; }
|
|
}
|
|
|
|
function deleteIndexedDBStorage(dbName, onsuccess, onerror, onblocked) {
|
|
var idb = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
|
|
if (Module['dbInstance']) Module['dbInstance'].close();
|
|
if (!dbName) dbName = Module['UE4_indexedDBName'];
|
|
var req = idb.deleteDatabase(dbName);
|
|
req.onsuccess = function() { console.log('Deleted IndexedDB storage ' + dbName + '!'); reportDataBytesStoredInIndexedDB(null); if (onsuccess) onsuccess(); }
|
|
req.onerror = function(evt) {
|
|
var errorString = getIDBRequestErrorString(req);
|
|
console.error('Failed to delete IndexedDB storage ' + dbName + ', ' + errorString);
|
|
evt.preventDefault();
|
|
if (onerror) onerror(errorString);
|
|
};
|
|
req.onblocked = function(evt) {
|
|
var errorString = getIDBRequestErrorString(req);
|
|
console.error('Failed to delete IndexedDB storage ' + dbName + ', DB was blocked! ' + errorString);
|
|
evt.preventDefault();
|
|
if (onblocked) onblocked(errorString);
|
|
}
|
|
}
|
|
|
|
var enableReadFromIndexedDB = (location.search.indexOf('noidbread') == -1);
|
|
var enableWriteToIndexedDB = enableReadFromIndexedDB && (location.search.indexOf('noidbwrite') == -1);
|
|
%DISABLE_INDEXEDDB%
|
|
|
|
if (!enableReadFromIndexedDB) showWarningRibbon('Running with IndexedDB access disabled.');
|
|
else if (!enableWriteToIndexedDB) showWarningRibbon('Running in read-only IndexedDB access mode.');
|
|
|
|
function storeToIndexedDB(db, key, value) {
|
|
return new Promise(function(resolve, reject) {
|
|
if (!enableWriteToIndexedDB) return reject('storeToIndexedDB: IndexedDB writes disabled by "?noidbwrite" option');
|
|
function fail(e) {
|
|
console.error('Failed to store file ' + key + ' to IndexedDB storage! error: ' + e);
|
|
if (!Module['idberrorShown']) {
|
|
showWarningRibbon('Failed to store file ' + key + ' to IndexedDB, error: ' + e);
|
|
Module['idberrorShown'] = true;
|
|
}
|
|
return reject(e);
|
|
}
|
|
if (!db) return fail('IndexedDB not available!');
|
|
if (location.protocol.indexOf('file') != -1) return reject('Loading via file://, skipping caching to IndexedDB');
|
|
|
|
try {
|
|
var transaction = db.transaction(['FILES'], 'readwrite');
|
|
var packages = transaction.objectStore('FILES');
|
|
var putRequest = packages.put(value, "file/" + Module.key + '/' + key);
|
|
putRequest.onsuccess = function(evt) {
|
|
if (value.byteLength || value.length) reportDataBytesStoredInIndexedDB(value.size || value.byteLength || value.length);
|
|
resolve(key);
|
|
};
|
|
putRequest.onerror = function(evt) {
|
|
var errorString = getIDBRequestErrorString(putRequest) || ('IndexedDB request error: ' + evt);
|
|
evt.preventDefault();
|
|
fail(errorString);
|
|
};
|
|
} catch(e) {
|
|
fail(e);
|
|
}
|
|
});
|
|
}
|
|
|
|
function fetchFromIndexedDB(db, key) {
|
|
return new Promise(function(resolve, reject) {
|
|
if (!enableReadFromIndexedDB) return reject('fetchFromIndexedDB: IndexedDB reads disabled by "?noidbread" option');
|
|
function fail(e) {
|
|
console.error('Failed to read file ' + key + ' from IndexedDB storage! error:');
|
|
console.error(e);
|
|
if (!Module['idberrorShown']) {
|
|
showWarningRibbon('Failed to read file ' + key + ' from IndexedDB, error: ' + e);
|
|
Module['idberrorShown'] = true;
|
|
}
|
|
return reject(e);
|
|
}
|
|
if (!db) return fail('IndexedDB not available!');
|
|
try {
|
|
var transaction = db.transaction(['FILES'], 'readonly');
|
|
var packages = transaction.objectStore('FILES');
|
|
var getRequest = packages.get("file/" + Module.key + '/' + key);
|
|
getRequest.onsuccess = function(evt) {
|
|
if (evt.target.result) {
|
|
var len = evt.target.result.size || evt.target.result.byteLength || evt.target.result.length;
|
|
if (len) reportDataBytesStoredInIndexedDB(len);
|
|
resolve(evt.target.result);
|
|
} else {
|
|
// Succeeded to load, but the load came back with the value of undefined, treat that as an error since we never store undefined in db.
|
|
reject();
|
|
}
|
|
};
|
|
getRequest.onerror = function(evt) {
|
|
var errorString = getIDBRequestErrorString(getRequest) || ('IndexedDB.get request error: ' + evt);
|
|
evt.preventDefault();
|
|
fail(errorString);
|
|
};
|
|
} catch(e) {
|
|
fail(e);
|
|
}
|
|
});
|
|
}
|
|
|
|
function fetchOrDownloadAndStore(db, url, responseType) {
|
|
return new Promise(function(resolve, reject) {
|
|
fetchFromIndexedDB(db, url)
|
|
.then(function(data) { return resolve(data); })
|
|
.catch(function(error) {
|
|
return download(url, responseType)
|
|
.then(function(data) {
|
|
// Treat IDB store as separate operation that's not part of the Promise chain.
|
|
/*return*/ storeToIndexedDB(db, url, data)
|
|
.then(function() { return resolve(data); })
|
|
.catch(function(error) {
|
|
console.error('Failed to store download to IndexedDB! ' + error);
|
|
return resolve(data); // succeeded download, but failed to store - ignore failure in that case and just proceed to run by calling the success handler.
|
|
})
|
|
})
|
|
.catch(function(error) { return reject(error); })
|
|
});
|
|
});
|
|
}
|
|
|
|
function openIndexedDB(dbName, dbVersion) {
|
|
return new Promise(function(resolve, reject) {
|
|
if (!enableReadFromIndexedDB) return reject('openIndexedDB: IndexedDB disabled by "?noidbread" option');
|
|
try {
|
|
var idb = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
|
|
var openRequest = idb.open(dbName, dbVersion);
|
|
} catch(e) { return reject(e); }
|
|
|
|
openRequest.onupgradeneeded = function(evt) {
|
|
var db = evt.target.result;
|
|
if (db.objectStoreNames.contains('FILES')) db.deleteObjectStore('FILES');
|
|
db.createObjectStore('FILES');
|
|
};
|
|
openRequest.onsuccess = function(evt) {
|
|
resolve(evt.target.result);
|
|
};
|
|
openRequest.onerror = function(evt) {
|
|
var errorString = getIDBRequestErrorString(openRequest) || ('IndexedDB request error: ' + evt);
|
|
evt.preventDefault();
|
|
reject(errorString);
|
|
};
|
|
});
|
|
}
|
|
|
|
Module['instantiateWasm'] = function(info, receiveInstance) {
|
|
Module['wasmDownloadAction'].then(function(downloadResults) {
|
|
taskProgress(TASK_COMPILING);
|
|
var wasmInstantiate = WebAssembly.instantiate(downloadResults.wasmModule || new Uint8Array(downloadResults.wasmBytes), info);
|
|
return wasmInstantiate.then(function(output) {
|
|
var instance = output.instance || output;
|
|
var module = output.module;
|
|
taskFinished(TASK_COMPILING);
|
|
Module['wasmInstantiateActionResolve'](instance);
|
|
receiveInstance(instance);
|
|
|
|
// After a successful instantiation, attempt to save the compiled Wasm Module object to IndexedDB.
|
|
if (!downloadResults.fromIndexedDB) {
|
|
storeToIndexedDB(downloadResults.db, 'wasmModule', module).catch(function() {
|
|
// If the browser did not support storing Wasm Modules to IndexedDB, try to store the Wasm instance instead.
|
|
return storeToIndexedDB(downloadResults.db, 'wasmBytes', downloadResults.wasmBytes);
|
|
});
|
|
}
|
|
});
|
|
}).catch(function(error) {
|
|
$ ('#mainarea').empty();
|
|
$ ('#mainarea').append('<div class="alert alert-danger centered-axis-xy" style ="min-height: 10pt" role="alert">WebAssembly instantiation failed: <br> ' + error + '</div></div>');
|
|
});
|
|
return {};
|
|
}
|
|
|
|
// Given a blob, asynchronously reads the byte contents of that blob to an arraybuffer and returns it as a Promise.
|
|
function readBlobToArrayBuffer(blob) {
|
|
return new Promise(function(resolve, reject) {
|
|
var fileReader = new FileReader();
|
|
fileReader.onload = function() { resolve(this.result); }
|
|
fileReader.onerror = function(e) { reject(e); }
|
|
fileReader.readAsArrayBuffer(blob);
|
|
});
|
|
}
|
|
|
|
function compileShadersFromJson(jsonData) {
|
|
var shaderPrograms = [];
|
|
if (jsonData instanceof ArrayBuffer) jsonData = new TextDecoder('utf-8').decode(new DataView(jsonData));
|
|
var programsDict = JSON.parse(jsonData);
|
|
for(var i in programsDict) {
|
|
shaderPrograms.push(programsDict[i]);
|
|
}
|
|
|
|
var gl = Module['preinitializedWebGLContext'];
|
|
|
|
Module['precompiledShaders'] = [];
|
|
Module['precompiledPrograms'] = [];
|
|
|
|
Module['glIDCounter'] = 1;
|
|
Module['precompiledUniforms'] = [null];
|
|
|
|
var promise = new Promise(function(resolve, reject) {
|
|
var nextProgramToBuild = 0;
|
|
function buildProgram() {
|
|
if (nextProgramToBuild >= shaderPrograms.length) {
|
|
taskFinished(TASK_SHADERS);
|
|
return resolve();
|
|
}
|
|
var p = shaderPrograms[nextProgramToBuild++];
|
|
taskProgress(TASK_SHADERS, {current: nextProgramToBuild, total: shaderPrograms.length });
|
|
var program = gl.createProgram();
|
|
|
|
function lineNumberize(str) {
|
|
str = str.split('\n');
|
|
for(var i = 0; i < str.length; ++i) str[i] = (i<9?' ':'') + (i<99?' ':'') + (i+1) + ': ' + str[i];
|
|
return str.join('\n');
|
|
}
|
|
|
|
var vs = gl.createShader(gl.VERTEX_SHADER);
|
|
gl.shaderSource(vs, p.vs);
|
|
gl.compileShader(vs);
|
|
var success = gl.getShaderParameter(vs, gl.COMPILE_STATUS);
|
|
var compileLog = gl.getShaderInfoLog(vs);
|
|
if (compileLog) compileLog = compileLog.trim();
|
|
if (compileLog) console.error('Compiling vertex shader: ' + lineNumberize(p.vs));
|
|
if (!success) console.error('Vertex shader compilation failed!');
|
|
if (compileLog) console.error('Compilation log: ' + compileLog);
|
|
if (!success) return reject('Vertex shader compilation failed: ' + compileLog);
|
|
gl.attachShader(program, vs);
|
|
|
|
Module['precompiledShaders'].push({
|
|
vs: p.vs,
|
|
shader: vs,
|
|
program: program
|
|
});
|
|
|
|
var fs = gl.createShader(gl.FRAGMENT_SHADER);
|
|
gl.shaderSource(fs, p.fs);
|
|
gl.compileShader(fs);
|
|
var success = gl.getShaderParameter(fs, gl.COMPILE_STATUS);
|
|
var compileLog = gl.getShaderInfoLog(fs);
|
|
if (compileLog) compileLog = compileLog.trim();
|
|
if (compileLog) console.error('Compiling fragment shader: ' + lineNumberize(p.fs));
|
|
if (!success) console.error('Fragment shader compilation failed!');
|
|
if (compileLog) console.error('Compilation log: ' + compileLog);
|
|
if (!success) return reject('Fragment shader compilation failed: ' + compileLog);
|
|
gl.attachShader(program, fs);
|
|
|
|
Module['precompiledShaders'].push({
|
|
fs: p.fs,
|
|
shader: fs,
|
|
program: program
|
|
});
|
|
|
|
for(var name in p.attribs) {
|
|
gl.bindAttribLocation(program, p.attribs[name], name);
|
|
}
|
|
gl.linkProgram(program);
|
|
var success = gl.getProgramParameter(program, gl.LINK_STATUS);
|
|
var linkLog = gl.getProgramInfoLog(program);
|
|
if (linkLog) linkLog = linkLog.trim();
|
|
if (linkLog) console.error('Linking shader program, vs: \n' + lineNumberize(p.vs) + ', \n fs:\n' + lineNumberize(p.fs));
|
|
if (!success) console.error('Shader program linking failed!');
|
|
if (linkLog) console.error('Link log: ' + linkLog);
|
|
if (!success) return reject('Shader linking failed: ' + linkLog);
|
|
|
|
var ptable = {
|
|
uniforms: {},
|
|
maxUniformLength: 0,
|
|
maxAttributeLength: -1,
|
|
maxUniformBlockNameLength: -1
|
|
};
|
|
var GLctx = gl;
|
|
var utable = ptable.uniforms;
|
|
var numUniforms = GLctx.getProgramParameter(program, GLctx.ACTIVE_UNIFORMS);
|
|
for (var i = 0; i < numUniforms; ++i) {
|
|
var u = GLctx.getActiveUniform(program, i);
|
|
var name = u.name;
|
|
ptable.maxUniformLength = Math.max(ptable.maxUniformLength, name.length + 1);
|
|
if (name.indexOf("]", name.length - 1) !== -1) {
|
|
var ls = name.lastIndexOf("[");
|
|
name = name.slice(0, ls);
|
|
}
|
|
var loc = GLctx.getUniformLocation(program, name);
|
|
var id = Module['glIDCounter']++;
|
|
utable[name] = [ u.size, id ];
|
|
Module['precompiledUniforms'].push(loc);
|
|
if (Module['precompiledUniforms'].length != Module['glIDCounter']) throw 'uniforms array not in sync! ' + Module['precompiledUniforms'].length + ', ' + Module['glIDCounter'];
|
|
for (var j = 1; j < u.size; ++j) {
|
|
var n = name + "[" + j + "]";
|
|
loc = GLctx.getUniformLocation(program, n);
|
|
id = Module['glIDCounter']++;
|
|
Module['precompiledUniforms'].push(loc);
|
|
if (Module['precompiledUniforms'].length != Module['glIDCounter']) throw 'uniforms array not in sync! ' + Module['precompiledUniforms'].length + ', ' + Module['glIDCounter'];
|
|
}
|
|
}
|
|
|
|
var e = gl.getError();
|
|
if (e) {
|
|
console.error('Precompiling shaders got GL error: ' + e);
|
|
return reject('Precompiling shaders got GL error: ' + e);
|
|
}
|
|
Module['precompiledPrograms'].push({
|
|
program: program,
|
|
programInfos: ptable,
|
|
vs: p.vs,
|
|
fs: p.fs
|
|
});
|
|
setTimeout(buildProgram, 0);
|
|
}
|
|
setTimeout(buildProgram, 0);
|
|
})
|
|
|
|
return promise;
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
if (!supportsWasm) {
|
|
showErrorDialog('Your browser does not support WebAssembly. Please try updating to latest 64-bit browser that supports WebAssembly.<br>Current user agent: ' + navigator.userAgent);
|
|
return;
|
|
}
|
|
|
|
if (!Module['buffer'] && allocateHeapUpFront) {
|
|
showErrorDialog('Failed to allocate ' + MB(MIN_MEMORY) + ' of linear memory for the ' + 'WebAssembly' + ' heap!');
|
|
return;
|
|
}
|
|
// check for webgl and cache it for later (UE_BrowserWebGLVersion() reads this)
|
|
Module['WEBGL_VERSION'] = detectWebGL();
|
|
console.log(getGpuInfo());
|
|
if (!Module['WEBGL_VERSION'] || Module['WEBGL_VERSION'] < requiredWebGLVersion) {
|
|
showErrorDialog('Your browser does not support WebGL ' + requiredWebGLVersion + '<br>Error reason: ' + (Module['webGLErrorReason'] || 'Unknown') + '. Try updating your browser and/or graphics card drivers.<br>Current renderer: ' + getGpuInfo());
|
|
return;
|
|
}
|
|
|
|
function shouldBrowserSupportWebGL2() {
|
|
var match = window.navigator.userAgent.match(/Firefox\/([0-9]+)\./);
|
|
if (match) return parseInt(match[1]) >= 51;
|
|
}
|
|
|
|
if (Module['WEBGL_VERSION'] < 2 && !explicitlyUseWebGL1) {
|
|
if (shouldBrowserSupportWebGL2()) {
|
|
showWarningRibbon('Your GPU does not support WebGL 2. This affects graphics performance and quality. Please try updating your graphics driver and/or browser to latest version.<br>Error reason: ' + (Module['webGLErrorReason'] || 'Unknown') + '<br>Current renderer: ' + getGpuInfo());
|
|
} else {
|
|
showWarningRibbon('The current browser does not support WebGL 2. This affects graphics performance and quality.<br>Please try updating your browser (and/or video drivers). NOTE: old hardware might have been blacklisted by this browser -- you may need to use a different browser.<br>Error reason: ' + (Module['webGLErrorReason'] || 'Unknown') + '<br>Current renderer: ' + getGpuInfo());
|
|
}
|
|
}
|
|
|
|
if (!heuristicIs64Bit('browser')) {
|
|
if (heuristicIs64Bit('os')) {
|
|
showWarningRibbon('It looks like you are running a 32-bit browser on a 64-bit operating system. This can dramatically affect performance and risk running out of memory on large applications. Try updating to a 64-bit browser for an optimized experience.');
|
|
} else {
|
|
showWarningRibbon('It looks like your computer hardware is 32-bit. This can dramatically affect performance.');
|
|
}
|
|
}
|
|
|
|
// The following WebGL 1.0 extensions are available in core WebGL 2.0 specification, so they are no longer shown in the extensions list.
|
|
var webGLExtensionsInCoreWebGL2 = ['ANGLE_instanced_arrays','EXT_blend_minmax','EXT_color_buffer_half_float','EXT_frag_depth','EXT_sRGB','EXT_shader_texture_lod','OES_element_index_uint','OES_standard_derivatives','OES_texture_float','OES_texture_half_float','OES_texture_half_float_linear','OES_vertex_array_object','WEBGL_color_buffer_float','WEBGL_depth_texture','WEBGL_draw_buffers'];
|
|
|
|
var supportedWebGLExtensions = Module['preinitializedWebGLContext'].getSupportedExtensions();
|
|
if (Module['WEBGL_VERSION'] >= 2) supportedWebGLExtensions = supportedWebGLExtensions.concat(webGLExtensionsInCoreWebGL2);
|
|
|
|
// The following WebGL extensions are required by UE4/this project, and it cannot run without.
|
|
var requiredWebGLExtensions = []; // TODO: List WebGL extensions here that the demo needs and can't run without.
|
|
for(var i in requiredWebGLExtensions) {
|
|
if (supportedWebGLExtensions.indexOf(requiredWebGLExtensions[i]) == -1) {
|
|
showErrorDialog('Your browser does not support WebGL extension ' + requiredWebGLExtensions[i] + ', which is required to run this page!');
|
|
}
|
|
}
|
|
|
|
// The following WebGL extensions would be preferred to exist for best features/performance, but are not strictly needed and UE4 can fall back if not available.
|
|
var preferredToHaveWebGLExtensions = [// The following are core in WebGL 2:
|
|
'ANGLE_instanced_arrays', // UE4 uses instanced rendering where possible, but can fallback to noninstanced.
|
|
'EXT_color_buffer_half_float',
|
|
'EXT_sRGB',
|
|
'EXT_shader_texture_lod', // textureLod() is needed for correct reflections, without this reflection shaders are missing and render out black.
|
|
'OES_standard_derivatives',
|
|
'OES_texture_half_float',
|
|
'OES_texture_half_float_linear',
|
|
'OES_vertex_array_object',
|
|
'WEBGL_color_buffer_float',
|
|
'WEBGL_depth_texture',
|
|
'WEBGL_draw_buffers',
|
|
|
|
// These are still extensions in WebGL 2:
|
|
'OES_texture_float',
|
|
'WEBGL_compressed_texture_s3tc',
|
|
'EXT_texture_filter_anisotropic'
|
|
];
|
|
var unsupportedWebGLExtensions = [];
|
|
for(var i in preferredToHaveWebGLExtensions) {
|
|
if (supportedWebGLExtensions.indexOf(preferredToHaveWebGLExtensions[i]) == -1) {
|
|
unsupportedWebGLExtensions.push(preferredToHaveWebGLExtensions[i]);
|
|
}
|
|
}
|
|
if (unsupportedWebGLExtensions.length > 1) {
|
|
showWarningRibbon('Your browser or graphics card does not support the following WebGL extensions: ' + unsupportedWebGLExtensions.join(', ') + '. This can impact UE4 graphics performance and quality.');
|
|
} else if (unsupportedWebGLExtensions.length == 1) {
|
|
showWarningRibbon('Your browser or graphics card does not support the WebGL extension ' + unsupportedWebGLExtensions[0] + '. This can impact UE4 graphics performance and quality.');
|
|
}
|
|
|
|
function withIndexedDB(db) {
|
|
Module['dbInstance'] = db;
|
|
|
|
var mainCompiledCode = fetchFromIndexedDB(db, 'wasmModule').then(function(wasmModule) {
|
|
return { db: db, wasmModule: wasmModule, fromIndexedDB: true };
|
|
}).catch(function() {
|
|
return fetchFromIndexedDB(db, 'wasmBytes').then(function(wasmBytes) {
|
|
return { db: db, wasmBytes: wasmBytes, fromIndexedDB: true };
|
|
});
|
|
}).catch(function() {
|
|
return download(Module.locateFile('%CONFIG%.wasm'), 'arraybuffer').then(function(wasmBytes) {
|
|
return { db: db, wasmBytes: wasmBytes, fromIndexedDB: false };
|
|
});
|
|
});
|
|
Module['wasmDownloadAction'] = mainCompiledCode;
|
|
var compiledCodeInstantiateAction = new Promise(function(resolve, reject) {
|
|
Module['wasmInstantiateActionResolve'] = resolve;
|
|
Module['wasmInstantiateActionReject'] = reject;
|
|
});
|
|
|
|
var mainJsDownload = fetchOrDownloadAndStore(db, Module.locateFile('%CONFIG%.js')).then(function(data) {
|
|
return addScriptToDom(data).then(function() {
|
|
addRunDependency('wait-for-compiled-code');
|
|
});
|
|
});
|
|
|
|
var dataJsDownload = fetchOrDownloadAndStore(db, Module.locateFile('%GAME%.data.js'));
|
|
var utilityJsDownload = fetchOrDownloadAndStore(db, Module.locateFile('Utility.js')).then(addScriptToDom);
|
|
var dataDownload =
|
|
/* // The following code would download and store the .data file as a Blob, which should be more efficient than loading an ArrayBuffer. However that seems to be buggy, so avoid it for now.
|
|
fetchOrDownloadAndStore(db, Module.locateFile('%GAME%.data')).then(function(dataBlob) {
|
|
return readBlobToArrayBuffer(dataBlob).then(function(dataArrayBuffer) {
|
|
Module['preloadedPackages'] = {};
|
|
Module['preloadedPackages'][Module.locateFile('%GAME%.data')] = dataArrayBuffer;
|
|
return dataJsDownload.then(addScriptToDom);
|
|
})
|
|
});
|
|
*/
|
|
// Instead as a fallback, download as ArrayBuffer. (TODO: Figure out the bugs with the above, and switch to using that one instead)
|
|
fetchOrDownloadAndStore(db, Module.locateFile('%GAME%.data'), 'arraybuffer').then(function(dataArrayBuffer) {
|
|
Module['preloadedPackages'] = {};
|
|
Module['preloadedPackages'][Module.locateFile('%GAME%.data')] = dataArrayBuffer;
|
|
return dataJsDownload.then(addScriptToDom);
|
|
});
|
|
|
|
const precompileShaders = false; // Currently not enabled.
|
|
|
|
if (precompileShaders) {
|
|
var compileShaders = fetchOrDownloadAndStore(db, Module.locateFile('shaders.json'), 'arraybuffer')
|
|
.then(function(json) {
|
|
return compileShadersFromJson(json)
|
|
.catch(function(error) {
|
|
taskFinished(TASK_SHADERS, error + '<br>Current renderer: ' + getGpuInfo());
|
|
throw 'Shader compilation failed';
|
|
});
|
|
});
|
|
} else {
|
|
var compileShaders = true; // Not precompiling shaders, no-op Promise action.
|
|
}
|
|
|
|
Promise.all([mainCompiledCode, mainJsDownload, dataJsDownload, utilityJsDownload, dataDownload, compiledCodeInstantiateAction, compileShaders]).then(function() {
|
|
if (!precompileShaders) {
|
|
Module['precompiledShaders'] = Module['precompiledPrograms'] = Module['preinitializedWebGLContext'] = Module['glIDCounter'] = Module['precompiledUniforms'] = null;
|
|
}
|
|
taskProgress(TASK_MAIN);
|
|
removeRunDependency('wait-for-compiled-code'); // Now we are ready to call main()
|
|
});
|
|
};
|
|
|
|
openIndexedDB(Module['UE4_indexedDBName'], Module['UE4_indexedDBVersion'] || 1).then(withIndexedDB).catch(function(e) {
|
|
console.error('Failed to openIndexedDB, proceeding without reading or storing contents to IndexedDB! Error: ');
|
|
console.error(e);
|
|
withIndexedDB(null);
|
|
});
|
|
});
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|