mirror of
				https://github.com/godotengine/godot.git
				synced 2025-10-31 21:51:22 +00:00 
			
		
		
		
	[HTML5] Preloader fetch, streaming instantiation.
This commit is contained in:
		
							parent
							
								
									8a020a6573
								
							
						
					
					
						commit
						f64ec5f1ad
					
				
					 4 changed files with 103 additions and 70 deletions
				
			
		|  | @ -227,10 +227,10 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused- | |||
| 	/** | ||||
| 	 * @ignore | ||||
| 	 * @param {string} loadPath | ||||
| 	 * @param {Promise} loadPromise | ||||
| 	 * @param {Response} response | ||||
| 	 */ | ||||
| 	Config.prototype.getModuleConfig = function (loadPath, loadPromise) { | ||||
| 		let loader = loadPromise; | ||||
| 	Config.prototype.getModuleConfig = function (loadPath, response) { | ||||
| 		let r = response; | ||||
| 		return { | ||||
| 			'print': this.onPrint, | ||||
| 			'printErr': this.onPrintError, | ||||
|  | @ -238,12 +238,17 @@ const InternalConfig = function (initConfig) { // eslint-disable-line no-unused- | |||
| 			'noExitRuntime': true, | ||||
| 			'dynamicLibraries': [`${loadPath}.side.wasm`], | ||||
| 			'instantiateWasm': function (imports, onSuccess) { | ||||
| 				loader.then(function (xhr) { | ||||
| 					WebAssembly.instantiate(xhr.response, imports).then(function (result) { | ||||
| 						onSuccess(result['instance'], result['module']); | ||||
| 				function done(result) { | ||||
| 					onSuccess(result['instance'], result['module']); | ||||
| 				} | ||||
| 				if (typeof (WebAssembly.instantiateStreaming) !== 'undefined') { | ||||
| 					WebAssembly.instantiateStreaming(Promise.resolve(r), imports).then(done); | ||||
| 				} else { | ||||
| 					r.arrayBuffer().then(function (buffer) { | ||||
| 						WebAssembly.instantiate(buffer, imports).then(done); | ||||
| 					}); | ||||
| 				}); | ||||
| 				loader = null; | ||||
| 				} | ||||
| 				r = null; | ||||
| 				return {}; | ||||
| 			}, | ||||
| 			'locateFile': function (path) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Fabio Alessandrelli
						Fabio Alessandrelli