1+ /*
2+ * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
3+ * This devtool is neither made for production nor for readable output files.
4+ * It uses "eval()" calls to create a separate source file in the browser devtools.
5+ * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
6+ * or disable the default devtool with "devtool: false".
7+ * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
8+ */
9+ /******/ ( ( ) => { // webpackBootstrap
10+ /******/ var __webpack_modules__ = ( {
11+
12+ /***/ "./index.js" :
13+ /*!******************!*\
14+ !*** ./index.js ***!
15+ \******************/
16+ /***/ ( ( __unused_webpack_module , __unused_webpack_exports , __webpack_require__ ) => {
17+
18+ eval ( "__webpack_require__.e(/*! import() */ \"pkg_index_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./pkg */ \"./pkg/index.js\"))\n .then(wasm => {\n const canvas = document.getElementById('canvas');\n const ctx = canvas.getContext('2d');\n\n let world;\n let wolrd_preset_actual;\n\n // Set world to the collision preset\n function worldCollision() {\n world = wasm.World.new();\n world.add_object(0., -380., 40., -100., 20., 20., 0.8, false);\n world.add_object(-80., 0., 100., -400., 30., 30., 0.8, false);\n world.add_object(200., 300., 0., 0., 30., 30., 0.8, true);\n }\n \n // Set world to the universal gravitation preset\n function worldUniversal() {\n world = wasm.World.new();\n world.add_object(0., 0., 0., 0., 50., 100000000000000000., 0.5, false);\n world.add_object(0., -300., 600., 0., 20., 10000000., 0.5, false);\n world.add_object(0., 200., -700., 0., 15., 5000000., 0.5, false);\n world.set_gravity_y(0.);\n world.set_meter_size(0.001);\n }\n\n function worldMultiCollision() {\n world = wasm.World.new();\n world.add_object(0., -380., 40., -100., 20., 20., 0.8, false);\n world.add_object(-200., 20., 0., 0., 30., 30., 0.8, false);\n }\n\n let world_dictionary = {\n \"collision\": worldCollision,\n \"universal\": worldUniversal,\n\n }\n\n wolrd_preset_actual = document.getElementById(\"world_preset\").value;\n world_dictionary[wolrd_preset_actual]();\n\n let view = wasm.WorldView.new(800, 800);\n\n document.getElementById(\"restart_button\").onclick = function (){\n world_dictionary[wolrd_preset_actual]();\n view.set_view_center(0., 0.);\n };\n\n let t = performance.now();\n\n function loop() {\n // Get the duration of the previous iteration.\n let elapsed_ms = performance.now() - t;\n t = performance.now();\n\n // Get values from the html file\n var world_preset = document.getElementById(\"world_preset\").value;\n var paused = document.getElementById(\"pause\").checked;\n var follow_enabled = document.getElementById(\"follow\").checked;\n var vector_enabled = document.getElementById(\"vectors\").checked;\n\n // Change the preset world if the selection changed\n if (world_preset !== wolrd_preset_actual) {\n wolrd_preset_actual = world_preset;\n world_dictionary[wolrd_preset_actual]();\n view.set_view_center(0., 0.);\n }\n\n // Apply physics.\n if (!paused) {\n world.apply_physic(elapsed_ms);\n }\n\n // Change the position of the view's center\n if (follow_enabled) {\n view.set_view_center(world.get_world().objects[0].pos_x, world.get_world().objects[0].pos_y);\n }\n\n // Draw the wolrd in the canvas\n view.draw(world, ctx);\n \n // Draw vectors\n if (vector_enabled) {\n view.draw_vectors(world, ctx, 1., document.getElementById(\"vectors_values\").checked);\n }\n\n requestAnimationFrame(loop);\n }\n\n // Start the simulation loop\n loop();\n\n })\n .catch(console.error);\n\n\n//# sourceURL=webpack:///./index.js?" ) ;
19+
20+ /***/ } )
21+
22+ /******/ } ) ;
23+ /************************************************************************/
24+ /******/ // The module cache
25+ /******/ var __webpack_module_cache__ = { } ;
26+ /******/
27+ /******/ // The require function
28+ /******/ function __webpack_require__ ( moduleId ) {
29+ /******/ // Check if module is in cache
30+ /******/ var cachedModule = __webpack_module_cache__ [ moduleId ] ;
31+ /******/ if ( cachedModule !== undefined ) {
32+ /******/ return cachedModule . exports ;
33+ /******/ }
34+ /******/ // Create a new module (and put it into the cache)
35+ /******/ var module = __webpack_module_cache__ [ moduleId ] = {
36+ /******/ id : moduleId ,
37+ /******/ // no module.loaded needed
38+ /******/ exports : { }
39+ /******/ } ;
40+ /******/
41+ /******/ // Execute the module function
42+ /******/ __webpack_modules__ [ moduleId ] ( module , module . exports , __webpack_require__ ) ;
43+ /******/
44+ /******/ // Return the exports of the module
45+ /******/ return module . exports ;
46+ /******/ }
47+ /******/
48+ /******/ // expose the modules object (__webpack_modules__)
49+ /******/ __webpack_require__ . m = __webpack_modules__ ;
50+ /******/
51+ /************************************************************************/
52+ /******/ /* webpack/runtime/async module */
53+ /******/ ( ( ) => {
54+ /******/ var webpackQueues = typeof Symbol === "function" ? Symbol ( "webpack queues" ) : "__webpack_queues__" ;
55+ /******/ var webpackExports = typeof Symbol === "function" ? Symbol ( "webpack exports" ) : "__webpack_exports__" ;
56+ /******/ var webpackError = typeof Symbol === "function" ? Symbol ( "webpack error" ) : "__webpack_error__" ;
57+ /******/ var resolveQueue = ( queue ) => {
58+ /******/ if ( queue && queue . d < 1 ) {
59+ /******/ queue . d = 1 ;
60+ /******/ queue . forEach ( ( fn ) => ( fn . r -- ) ) ;
61+ /******/ queue . forEach ( ( fn ) => ( fn . r -- ? fn . r ++ : fn ( ) ) ) ;
62+ /******/ }
63+ /******/ }
64+ /******/ var wrapDeps = ( deps ) => ( deps . map ( ( dep ) => {
65+ /******/ if ( dep !== null && typeof dep === "object" ) {
66+ /******/ if ( dep [ webpackQueues ] ) return dep ;
67+ /******/ if ( dep . then ) {
68+ /******/ var queue = [ ] ;
69+ /******/ queue . d = 0 ;
70+ /******/ dep . then ( ( r ) => {
71+ /******/ obj [ webpackExports ] = r ;
72+ /******/ resolveQueue ( queue ) ;
73+ /******/ } , ( e ) => {
74+ /******/ obj [ webpackError ] = e ;
75+ /******/ resolveQueue ( queue ) ;
76+ /******/ } ) ;
77+ /******/ var obj = { } ;
78+ /******/ obj [ webpackQueues ] = ( fn ) => ( fn ( queue ) ) ;
79+ /******/ return obj ;
80+ /******/ }
81+ /******/ }
82+ /******/ var ret = { } ;
83+ /******/ ret [ webpackQueues ] = x => { } ;
84+ /******/ ret [ webpackExports ] = dep ;
85+ /******/ return ret ;
86+ /******/ } ) ) ;
87+ /******/ __webpack_require__ . a = ( module , body , hasAwait ) => {
88+ /******/ var queue ;
89+ /******/ hasAwait && ( ( queue = [ ] ) . d = - 1 ) ;
90+ /******/ var depQueues = new Set ( ) ;
91+ /******/ var exports = module . exports ;
92+ /******/ var currentDeps ;
93+ /******/ var outerResolve ;
94+ /******/ var reject ;
95+ /******/ var promise = new Promise ( ( resolve , rej ) => {
96+ /******/ reject = rej ;
97+ /******/ outerResolve = resolve ;
98+ /******/ } ) ;
99+ /******/ promise [ webpackExports ] = exports ;
100+ /******/ promise [ webpackQueues ] = ( fn ) => ( queue && fn ( queue ) , depQueues . forEach ( fn ) , promise [ "catch" ] ( x => { } ) ) ;
101+ /******/ module . exports = promise ;
102+ /******/ body ( ( deps ) => {
103+ /******/ currentDeps = wrapDeps ( deps ) ;
104+ /******/ var fn ;
105+ /******/ var getResult = ( ) => ( currentDeps . map ( ( d ) => {
106+ /******/ if ( d [ webpackError ] ) throw d [ webpackError ] ;
107+ /******/ return d [ webpackExports ] ;
108+ /******/ } ) )
109+ /******/ var promise = new Promise ( ( resolve ) => {
110+ /******/ fn = ( ) => ( resolve ( getResult ) ) ;
111+ /******/ fn . r = 0 ;
112+ /******/ var fnQueue = ( q ) => ( q !== queue && ! depQueues . has ( q ) && ( depQueues . add ( q ) , q && ! q . d && ( fn . r ++ , q . push ( fn ) ) ) ) ;
113+ /******/ currentDeps . map ( ( dep ) => ( dep [ webpackQueues ] ( fnQueue ) ) ) ;
114+ /******/ } ) ;
115+ /******/ return fn . r ? promise : getResult ( ) ;
116+ /******/ } , ( err ) => ( ( err ? reject ( promise [ webpackError ] = err ) : outerResolve ( exports ) ) , resolveQueue ( queue ) ) ) ;
117+ /******/ queue && queue . d < 0 && ( queue . d = 0 ) ;
118+ /******/ } ;
119+ /******/ } ) ( ) ;
120+ /******/
121+ /******/ /* webpack/runtime/define property getters */
122+ /******/ ( ( ) => {
123+ /******/ // define getter functions for harmony exports
124+ /******/ __webpack_require__ . d = ( exports , definition ) => {
125+ /******/ for ( var key in definition ) {
126+ /******/ if ( __webpack_require__ . o ( definition , key ) && ! __webpack_require__ . o ( exports , key ) ) {
127+ /******/ Object . defineProperty ( exports , key , { enumerable : true , get : definition [ key ] } ) ;
128+ /******/ }
129+ /******/ }
130+ /******/ } ;
131+ /******/ } ) ( ) ;
132+ /******/
133+ /******/ /* webpack/runtime/ensure chunk */
134+ /******/ ( ( ) => {
135+ /******/ __webpack_require__ . f = { } ;
136+ /******/ // This file contains only the entry chunk.
137+ /******/ // The chunk loading function for additional chunks
138+ /******/ __webpack_require__ . e = ( chunkId ) => {
139+ /******/ return Promise . all ( Object . keys ( __webpack_require__ . f ) . reduce ( ( promises , key ) => {
140+ /******/ __webpack_require__ . f [ key ] ( chunkId , promises ) ;
141+ /******/ return promises ;
142+ /******/ } , [ ] ) ) ;
143+ /******/ } ;
144+ /******/ } ) ( ) ;
145+ /******/
146+ /******/ /* webpack/runtime/get javascript chunk filename */
147+ /******/ ( ( ) => {
148+ /******/ // This function allow to reference async chunks
149+ /******/ __webpack_require__ . u = ( chunkId ) => {
150+ /******/ // return url for filenames based on template
151+ /******/ return "" + chunkId + ".bundle.js" ;
152+ /******/ } ;
153+ /******/ } ) ( ) ;
154+ /******/
155+ /******/ /* webpack/runtime/global */
156+ /******/ ( ( ) => {
157+ /******/ __webpack_require__ . g = ( function ( ) {
158+ /******/ if ( typeof globalThis === 'object' ) return globalThis ;
159+ /******/ try {
160+ /******/ return this || new Function ( 'return this' ) ( ) ;
161+ /******/ } catch ( e ) {
162+ /******/ if ( typeof window === 'object' ) return window ;
163+ /******/ }
164+ /******/ } ) ( ) ;
165+ /******/ } ) ( ) ;
166+ /******/
167+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
168+ /******/ ( ( ) => {
169+ /******/ __webpack_require__ . o = ( obj , prop ) => ( Object . prototype . hasOwnProperty . call ( obj , prop ) )
170+ /******/ } ) ( ) ;
171+ /******/
172+ /******/ /* webpack/runtime/load script */
173+ /******/ ( ( ) => {
174+ /******/ var inProgress = { } ;
175+ /******/ // data-webpack is not used as build has no uniqueName
176+ /******/ // loadScript function to load a script via script tag
177+ /******/ __webpack_require__ . l = ( url , done , key , chunkId ) => {
178+ /******/ if ( inProgress [ url ] ) { inProgress [ url ] . push ( done ) ; return ; }
179+ /******/ var script , needAttach ;
180+ /******/ if ( key !== undefined ) {
181+ /******/ var scripts = document . getElementsByTagName ( "script" ) ;
182+ /******/ for ( var i = 0 ; i < scripts . length ; i ++ ) {
183+ /******/ var s = scripts [ i ] ;
184+ /******/ if ( s . getAttribute ( "src" ) == url ) { script = s ; break ; }
185+ /******/ }
186+ /******/ }
187+ /******/ if ( ! script ) {
188+ /******/ needAttach = true ;
189+ /******/ script = document . createElement ( 'script' ) ;
190+ /******/
191+ /******/ script . charset = 'utf-8' ;
192+ /******/ script . timeout = 120 ;
193+ /******/ if ( __webpack_require__ . nc ) {
194+ /******/ script . setAttribute ( "nonce" , __webpack_require__ . nc ) ;
195+ /******/ }
196+ /******/
197+ /******/
198+ /******/ script . src = url ;
199+ /******/ }
200+ /******/ inProgress [ url ] = [ done ] ;
201+ /******/ var onScriptComplete = ( prev , event ) => {
202+ /******/ // avoid mem leaks in IE.
203+ /******/ script . onerror = script . onload = null ;
204+ /******/ clearTimeout ( timeout ) ;
205+ /******/ var doneFns = inProgress [ url ] ;
206+ /******/ delete inProgress [ url ] ;
207+ /******/ script . parentNode && script . parentNode . removeChild ( script ) ;
208+ /******/ doneFns && doneFns . forEach ( ( fn ) => ( fn ( event ) ) ) ;
209+ /******/ if ( prev ) return prev ( event ) ;
210+ /******/ }
211+ /******/ var timeout = setTimeout ( onScriptComplete . bind ( null , undefined , { type : 'timeout' , target : script } ) , 120000 ) ;
212+ /******/ script . onerror = onScriptComplete . bind ( null , script . onerror ) ;
213+ /******/ script . onload = onScriptComplete . bind ( null , script . onload ) ;
214+ /******/ needAttach && document . head . appendChild ( script ) ;
215+ /******/ } ;
216+ /******/ } ) ( ) ;
217+ /******/
218+ /******/ /* webpack/runtime/make namespace object */
219+ /******/ ( ( ) => {
220+ /******/ // define __esModule on exports
221+ /******/ __webpack_require__ . r = ( exports ) => {
222+ /******/ if ( typeof Symbol !== 'undefined' && Symbol . toStringTag ) {
223+ /******/ Object . defineProperty ( exports , Symbol . toStringTag , { value : 'Module' } ) ;
224+ /******/ }
225+ /******/ Object . defineProperty ( exports , '__esModule' , { value : true } ) ;
226+ /******/ } ;
227+ /******/ } ) ( ) ;
228+ /******/
229+ /******/ /* webpack/runtime/wasm loading */
230+ /******/ ( ( ) => {
231+ /******/ __webpack_require__ . v = ( exports , wasmModuleId , wasmModuleHash , importsObj ) => {
232+ /******/
233+ /******/ var req = fetch ( __webpack_require__ . p + "" + wasmModuleHash + ".module.wasm" ) ;
234+ /******/ var fallback = ( ) => ( req
235+ /******/ . then ( ( x ) => ( x . arrayBuffer ( ) ) )
236+ /******/ . then ( ( bytes ) => ( WebAssembly . instantiate ( bytes , importsObj ) ) )
237+ /******/ . then ( ( res ) => ( Object . assign ( exports , res . instance . exports ) ) ) ) ;
238+ /******/ return req . then ( ( res ) => {
239+ /******/ if ( typeof WebAssembly . instantiateStreaming === "function" ) {
240+ /******/
241+ /******/ return WebAssembly . instantiateStreaming ( res , importsObj )
242+ /******/ . then (
243+ /******/ ( res ) => ( Object . assign ( exports , res . instance . exports ) ) ,
244+ /******/ ( e ) => {
245+ /******/ if ( res . headers . get ( "Content-Type" ) !== "application/wasm" ) {
246+ /******/ console . warn ( "`WebAssembly.instantiateStreaming` failed because your server does not serve wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n" , e ) ;
247+ /******/ return fallback ( ) ;
248+ /******/ }
249+ /******/ throw e ;
250+ /******/ }
251+ /******/ ) ;
252+ /******/ }
253+ /******/ return fallback ( ) ;
254+ /******/ } ) ;
255+ /******/ } ;
256+ /******/ } ) ( ) ;
257+ /******/
258+ /******/ /* webpack/runtime/publicPath */
259+ /******/ ( ( ) => {
260+ /******/ var scriptUrl ;
261+ /******/ if ( __webpack_require__ . g . importScripts ) scriptUrl = __webpack_require__ . g . location + "" ;
262+ /******/ var document = __webpack_require__ . g . document ;
263+ /******/ if ( ! scriptUrl && document ) {
264+ /******/ if ( document . currentScript && document . currentScript . tagName . toUpperCase ( ) === 'SCRIPT' )
265+ /******/ scriptUrl = document . currentScript . src ;
266+ /******/ if ( ! scriptUrl ) {
267+ /******/ var scripts = document . getElementsByTagName ( "script" ) ;
268+ /******/ if ( scripts . length ) {
269+ /******/ var i = scripts . length - 1 ;
270+ /******/ while ( i > - 1 && ( ! scriptUrl || ! / ^ h t t p ( s ? ) : / . test ( scriptUrl ) ) ) scriptUrl = scripts [ i -- ] . src ;
271+ /******/ }
272+ /******/ }
273+ /******/ }
274+ /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
275+ /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
276+ /******/ if ( ! scriptUrl ) throw new Error ( "Automatic publicPath is not supported in this browser" ) ;
277+ /******/ scriptUrl = scriptUrl . replace ( / ^ b l o b : / , "" ) . replace ( / # .* $ / , "" ) . replace ( / \? .* $ / , "" ) . replace ( / \/ [ ^ \/ ] + $ / , "/" ) ;
278+ /******/ __webpack_require__ . p = scriptUrl ;
279+ /******/ } ) ( ) ;
280+ /******/
281+ /******/ /* webpack/runtime/jsonp chunk loading */
282+ /******/ ( ( ) => {
283+ /******/ // no baseURI
284+ /******/
285+ /******/ // object to store loaded and loading chunks
286+ /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
287+ /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
288+ /******/ var installedChunks = {
289+ /******/ "main" : 0
290+ /******/ } ;
291+ /******/
292+ /******/ __webpack_require__ . f . j = ( chunkId , promises ) => {
293+ /******/ // JSONP chunk loading for javascript
294+ /******/ var installedChunkData = __webpack_require__ . o ( installedChunks , chunkId ) ? installedChunks [ chunkId ] : undefined ;
295+ /******/ if ( installedChunkData !== 0 ) { // 0 means "already installed".
296+ /******/
297+ /******/ // a Promise means "currently loading".
298+ /******/ if ( installedChunkData ) {
299+ /******/ promises . push ( installedChunkData [ 2 ] ) ;
300+ /******/ } else {
301+ /******/ if ( true ) { // all chunks have JS
302+ /******/ // setup Promise in chunk cache
303+ /******/ var promise = new Promise ( ( resolve , reject ) => ( installedChunkData = installedChunks [ chunkId ] = [ resolve , reject ] ) ) ;
304+ /******/ promises . push ( installedChunkData [ 2 ] = promise ) ;
305+ /******/
306+ /******/ // start chunk loading
307+ /******/ var url = __webpack_require__ . p + __webpack_require__ . u ( chunkId ) ;
308+ /******/ // create error before stack unwound to get useful stacktrace later
309+ /******/ var error = new Error ( ) ;
310+ /******/ var loadingEnded = ( event ) => {
311+ /******/ if ( __webpack_require__ . o ( installedChunks , chunkId ) ) {
312+ /******/ installedChunkData = installedChunks [ chunkId ] ;
313+ /******/ if ( installedChunkData !== 0 ) installedChunks [ chunkId ] = undefined ;
314+ /******/ if ( installedChunkData ) {
315+ /******/ var errorType = event && ( event . type === 'load' ? 'missing' : event . type ) ;
316+ /******/ var realSrc = event && event . target && event . target . src ;
317+ /******/ error . message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')' ;
318+ /******/ error . name = 'ChunkLoadError' ;
319+ /******/ error . type = errorType ;
320+ /******/ error . request = realSrc ;
321+ /******/ installedChunkData [ 1 ] ( error ) ;
322+ /******/ }
323+ /******/ }
324+ /******/ } ;
325+ /******/ __webpack_require__ . l ( url , loadingEnded , "chunk-" + chunkId , chunkId ) ;
326+ /******/ }
327+ /******/ }
328+ /******/ }
329+ /******/ } ;
330+ /******/
331+ /******/ // no prefetching
332+ /******/
333+ /******/ // no preloaded
334+ /******/
335+ /******/ // no HMR
336+ /******/
337+ /******/ // no HMR manifest
338+ /******/
339+ /******/ // no on chunks loaded
340+ /******/
341+ /******/ // install a JSONP callback for chunk loading
342+ /******/ var webpackJsonpCallback = ( parentChunkLoadingFunction , data ) => {
343+ /******/ var [ chunkIds , moreModules , runtime ] = data ;
344+ /******/ // add "moreModules" to the modules object,
345+ /******/ // then flag all "chunkIds" as loaded and fire callback
346+ /******/ var moduleId , chunkId , i = 0 ;
347+ /******/ if ( chunkIds . some ( ( id ) => ( installedChunks [ id ] !== 0 ) ) ) {
348+ /******/ for ( moduleId in moreModules ) {
349+ /******/ if ( __webpack_require__ . o ( moreModules , moduleId ) ) {
350+ /******/ __webpack_require__ . m [ moduleId ] = moreModules [ moduleId ] ;
351+ /******/ }
352+ /******/ }
353+ /******/ if ( runtime ) var result = runtime ( __webpack_require__ ) ;
354+ /******/ }
355+ /******/ if ( parentChunkLoadingFunction ) parentChunkLoadingFunction ( data ) ;
356+ /******/ for ( ; i < chunkIds . length ; i ++ ) {
357+ /******/ chunkId = chunkIds [ i ] ;
358+ /******/ if ( __webpack_require__ . o ( installedChunks , chunkId ) && installedChunks [ chunkId ] ) {
359+ /******/ installedChunks [ chunkId ] [ 0 ] ( ) ;
360+ /******/ }
361+ /******/ installedChunks [ chunkId ] = 0 ;
362+ /******/ }
363+ /******/
364+ /******/ }
365+ /******/
366+ /******/ var chunkLoadingGlobal = self [ "webpackChunk" ] = self [ "webpackChunk" ] || [ ] ;
367+ /******/ chunkLoadingGlobal . forEach ( webpackJsonpCallback . bind ( null , 0 ) ) ;
368+ /******/ chunkLoadingGlobal . push = webpackJsonpCallback . bind ( null , chunkLoadingGlobal . push . bind ( chunkLoadingGlobal ) ) ;
369+ /******/ } ) ( ) ;
370+ /******/
371+ /************************************************************************/
372+ /******/
373+ /******/ // startup
374+ /******/ // Load entry module and return exports
375+ /******/ // This entry module can't be inlined because the eval devtool is used.
376+ /******/ var __webpack_exports__ = __webpack_require__ ( "./index.js" ) ;
377+ /******/
378+ /******/ } ) ( )
379+ ;
0 commit comments