comparison Platforms/Wasm/wasm-application-runner.ts @ 562:37e396ae08a3

Merged dev into default
author Alain Mazy <am@osimis.io>
date Thu, 18 Apr 2019 07:30:56 +0000
parents e1ba16436d59
children 70992b38aa8a 636eb0e4c9dd
comparison
equal deleted inserted replaced
560:aaeec7be8fb7 562:37e396ae08a3
1 import Stone = require('./stone-framework-loader'); 1 import Stone = require('./stone-framework-loader');
2 import StoneViewport = require('./wasm-viewport'); 2 import StoneViewport = require('./wasm-viewport');
3 import * as Logger from './logger'
3 4
4 if (!('WebAssembly' in window)) { 5 if (!('WebAssembly' in window)) {
5 alert('Sorry, your browser does not support WebAssembly :('); 6 alert('Sorry, your browser does not support WebAssembly :(');
6 } 7 }
7 8
17 var SetStartupParameter: Function = null; 18 var SetStartupParameter: Function = null;
18 var CreateWasmApplication: Function = null; 19 var CreateWasmApplication: Function = null;
19 export var CreateCppViewport: Function = null; 20 export var CreateCppViewport: Function = null;
20 var ReleaseCppViewport: Function = null; 21 var ReleaseCppViewport: Function = null;
21 var StartWasmApplication: Function = null; 22 var StartWasmApplication: Function = null;
22 export var SendMessageToStoneApplication: Function = null; 23 export var SendSerializedMessageToStoneApplication: Function = null;
23 24
24 function DoAnimationThread() { 25 function DoAnimationThread() {
25 if (WasmDoAnimation != null) { 26 if (WasmDoAnimation != null) {
26 WasmDoAnimation(); 27 WasmDoAnimation();
27 } 28 }
82 83
83 // Wait for the Orthanc Framework to be initialized (this initializes 84 // Wait for the Orthanc Framework to be initialized (this initializes
84 // the WebAssembly environment) and then, create and initialize the Wasm application 85 // the WebAssembly environment) and then, create and initialize the Wasm application
85 Stone.Framework.Initialize(true, function () { 86 Stone.Framework.Initialize(true, function () {
86 87
87 console.log("Connecting C++ methods to JS methods"); 88 Logger.defaultLogger.debug("Connecting C++ methods to JS methods");
88 89
89 SetStartupParameter = (<any> window).StoneFrameworkModule.cwrap('SetStartupParameter', null, ['string', 'string']); 90 SetStartupParameter = (<any> window).StoneFrameworkModule.cwrap('SetStartupParameter', null, ['string', 'string']);
90 CreateWasmApplication = (<any> window).StoneFrameworkModule.cwrap('CreateWasmApplication', null, ['number']); 91 CreateWasmApplication = (<any> window).StoneFrameworkModule.cwrap('CreateWasmApplication', null, ['number']);
91 CreateCppViewport = (<any> window).StoneFrameworkModule.cwrap('CreateCppViewport', 'number', []); 92 CreateCppViewport = (<any> window).StoneFrameworkModule.cwrap('CreateCppViewport', 'number', []);
92 ReleaseCppViewport = (<any> window).StoneFrameworkModule.cwrap('ReleaseCppViewport', null, ['number']); 93 ReleaseCppViewport = (<any> window).StoneFrameworkModule.cwrap('ReleaseCppViewport', null, ['number']);
97 (<any> window).WasmWebService_NotifyError = (<any> window).StoneFrameworkModule.cwrap('WasmWebService_NotifyError', null, ['number', 'string', 'number']); 98 (<any> window).WasmWebService_NotifyError = (<any> window).StoneFrameworkModule.cwrap('WasmWebService_NotifyError', null, ['number', 'string', 'number']);
98 (<any> window).WasmDelayedCallExecutor_ExecuteCallback = (<any> window).StoneFrameworkModule.cwrap('WasmDelayedCallExecutor_ExecuteCallback', null, ['number']); 99 (<any> window).WasmDelayedCallExecutor_ExecuteCallback = (<any> window).StoneFrameworkModule.cwrap('WasmDelayedCallExecutor_ExecuteCallback', null, ['number']);
99 // no need to put this into the globals for it's only used in this very module 100 // no need to put this into the globals for it's only used in this very module
100 WasmDoAnimation = (<any> window).StoneFrameworkModule.cwrap('WasmDoAnimation', null, []); 101 WasmDoAnimation = (<any> window).StoneFrameworkModule.cwrap('WasmDoAnimation', null, []);
101 102
102 SendMessageToStoneApplication = (<any> window).StoneFrameworkModule.cwrap('SendMessageToStoneApplication', 'string', ['string']); 103 SendSerializedMessageToStoneApplication = (<any> window).StoneFrameworkModule.cwrap('SendSerializedMessageToStoneApplication', 'string', ['string']);
103 104
104 console.log("Connecting C++ methods to JS methods - done"); 105 Logger.defaultLogger.debug("Connecting C++ methods to JS methods - done");
105 106
106 // Prevent scrolling 107 // Prevent scrolling
107 document.body.addEventListener('touchmove', function (event) { 108 document.body.addEventListener('touchmove', function (event) {
108 event.preventDefault(); 109 event.preventDefault();
109 }, false); 110 }, { passive: false}); // must not be passive if calling event.preventDefault, ie to cancel scroll or zoom of the whole interface
110 111
111 _InitializeWasmApplication(orthancBaseUrl); 112 _InitializeWasmApplication(orthancBaseUrl);
112 }); 113 });
113 } 114 }
114 115