matrix-engine-wgpu 1.0.6 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/.codesandbox/tasks.json +46 -0
  2. package/.devcontainer/devcontainer.json +22 -0
  3. package/.github/dependabot.yml +12 -0
  4. package/REFERENCE.md +3 -5
  5. package/dev.md +460 -0
  6. package/empty.js +7 -6
  7. package/examples/games/jamb/jamb.js +1133 -0
  8. package/examples/load-obj-file.js +65 -28
  9. package/examples/unlit-textures.js +26 -23
  10. package/examples.js +35 -3
  11. package/index.js +8 -2
  12. package/main.js +454 -48
  13. package/non-project-files/dev.txt +21 -0
  14. package/non-project-files/image1.png +0 -0
  15. package/non-project-files/image6.png +0 -0
  16. package/package.json +31 -13
  17. package/public/app.js +2234 -114
  18. package/public/css/style.css +371 -110
  19. package/public/empty.html +1 -1
  20. package/public/empty.js +9887 -9264
  21. package/public/examples.html +10 -8
  22. package/public/examples.js +2035 -247
  23. package/public/index.html +3 -5
  24. package/public/manifest copy.web +35 -0
  25. package/public/res/audios/block.mp3 +0 -0
  26. package/public/res/audios/dice1.mp3 +0 -0
  27. package/public/res/audios/dice2.mp3 +0 -0
  28. package/public/res/audios/start.mp3 +0 -0
  29. package/public/res/meshes/jamb/bg.blend +0 -0
  30. package/public/res/meshes/jamb/bg.blend1 +0 -0
  31. package/public/res/meshes/jamb/bg.mtl +12 -0
  32. package/public/res/meshes/jamb/bg.obj +17 -0
  33. package/public/res/meshes/jamb/bg.png +0 -0
  34. package/public/res/meshes/jamb/dice-default.png +0 -0
  35. package/public/res/meshes/jamb/dice-mark.png +0 -0
  36. package/public/res/meshes/jamb/dice.mtl +12 -0
  37. package/public/res/meshes/jamb/dice.obj +40 -0
  38. package/public/res/meshes/jamb/dice.png +0 -0
  39. package/public/res/meshes/jamb/jamb-title.mtl +12 -0
  40. package/public/res/meshes/jamb/jamb-title.obj +26008 -0
  41. package/public/res/meshes/jamb/jamb.blend +0 -0
  42. package/public/res/meshes/jamb/jamb.blend1 +0 -0
  43. package/public/res/meshes/jamb/logo.png +0 -0
  44. package/public/res/meshes/jamb/nidzaDice.blend +0 -0
  45. package/public/res/meshes/jamb/nidzaDice.blend1 +0 -0
  46. package/public/res/meshes/jamb/pile.blend +0 -0
  47. package/public/res/meshes/jamb/simpleCube.blend +0 -0
  48. package/public/res/meshes/jamb/simpleCube.blend1 +0 -0
  49. package/public/res/meshes/jamb/sounds/roll1.wav +0 -0
  50. package/public/res/meshes/jamb/text.png +0 -0
  51. package/public/res/multilang/en.json +27 -0
  52. package/public/res/multilang/sr.json +27 -0
  53. package/public/test.html +636 -0
  54. package/public/three-test.js +165 -0
  55. package/public/worker.html +1 -1
  56. package/readme.md +193 -115
  57. package/src/engine/ball.js +477 -468
  58. package/src/engine/cube.js +486 -468
  59. package/src/engine/engine.js +4 -6
  60. package/src/engine/loader-obj.js +9 -6
  61. package/src/engine/matrix-class.js +237 -204
  62. package/src/engine/mesh-obj.js +603 -515
  63. package/src/engine/raycast.js +101 -0
  64. package/src/engine/utils.js +69 -3
  65. package/src/multilang/lang.js +35 -0
  66. package/src/physics/matrix-ammo.js +168 -15
  67. package/src/shaders/fragment.wgsl.js +4 -2
  68. package/src/shaders/shaders.js +1 -1
  69. package/src/shaders/vertexShadow.wgsl.js +1 -1
  70. package/src/sounds/sounds.js +47 -0
  71. package/src/world.js +311 -248
package/public/app.js CHANGED
@@ -1,6 +1,1045 @@
1
1
  (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2
2
  "use strict";
3
3
 
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.myDom = exports.dices = void 0;
8
+ var _world = _interopRequireDefault(require("../../../src/world.js"));
9
+ var _loaderObj = require("../../../src/engine/loader-obj.js");
10
+ var _utils = require("../../../src/engine/utils.js");
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ let dices = exports.dices = {
13
+ C: 0,
14
+ STATUS: 'FREE_TO_PLAY',
15
+ STATUS_H2: 'WAIT',
16
+ STATUS_H3: 'WAIT',
17
+ R: {},
18
+ SAVED_DICES: {},
19
+ pickDice: dice => {
20
+ (void 0).SAVED_DICES[dice] = (void 0).R[dice];
21
+ },
22
+ checkAll: function () {
23
+ this.C++;
24
+ if (typeof this.R.CubePhysics1 != 'undefined' && typeof this.R.CubePhysics2 != 'undefined' && typeof this.R.CubePhysics3 != 'undefined' && typeof this.R.CubePhysics4 != 'undefined' && typeof this.R.CubePhysics5 != 'undefined' && typeof this.R.CubePhysics6 != 'undefined' && this.C > 1200) {
25
+ dispatchEvent(new CustomEvent('all-done', {
26
+ detail: {}
27
+ }));
28
+ this.C = 0;
29
+ }
30
+ },
31
+ validatePass: function () {
32
+ if (dices.STATUS == "IN_PLAY" || dices.STATUS == "FREE_TO_PLAY") {
33
+ // console.log('%cBLOCK', LOG_FUNNY)
34
+ if (dices.STATUS == "IN_PLAY") _utils.mb.error(`STATUS IS ${dices.STATUS}, please wait for results...`);
35
+ if (dices.STATUS == "FREE_TO_PLAY") _utils.mb.error(`STATUS IS ${dices.STATUS}, you need to roll dice first.`);
36
+ app.matrixSounds.play('block');
37
+ return false;
38
+ } else {
39
+ return true;
40
+ }
41
+ }
42
+ };
43
+ let myDom = exports.myDom = {
44
+ state: {
45
+ rowDown: []
46
+ },
47
+ memoNumberRow: [],
48
+ hideSettings: function () {
49
+ (0, _utils.byId)('blocker').style.display = 'none';
50
+ (0, _utils.byId)('messageBox').style.display = 'none';
51
+ },
52
+ createMenu: function () {
53
+ var root = document.createElement('div');
54
+ root.id = 'hud';
55
+ root.style.position = 'absolute';
56
+ root.style.right = '10%';
57
+ root.style.top = '10%';
58
+ var help = document.createElement('div');
59
+ help.id = 'HELP';
60
+ help.classList.add('btn2');
61
+ help.innerHTML = `<span data-label="help"></span>`;
62
+ var settings = document.createElement('div');
63
+ settings.id = 'settings';
64
+ settings.classList.add('btn2');
65
+ settings.innerHTML = `<span data-label="settings"></span>`;
66
+ settings.addEventListener('click', () => {
67
+ (0, _utils.byId)('messageBox').innerHTML = `
68
+ <div>
69
+ <span data-label="settings"></span>
70
+ <div>
71
+
72
+ <div>
73
+ <span data-label="sounds"></span>
74
+
75
+ <label class="switch">
76
+ <input type="checkbox">
77
+ <span class="sliderSwitch round"></span>
78
+ </label>
79
+
80
+ </div>
81
+
82
+ <div>
83
+ <button class="btn2" onclick="app.myDom.hideSettings()">
84
+ <span data-label="hide"></span>
85
+ </button>
86
+ </div>
87
+
88
+ </div>
89
+ </div>
90
+ `;
91
+ (0, _utils.byId)('blocker').style.display = 'flex';
92
+ (0, _utils.byId)('messageBox').style.display = 'flex';
93
+ dispatchEvent(new CustomEvent('updateLang', {}));
94
+ });
95
+ var roll = document.createElement('div');
96
+ roll.id = 'hud-roll';
97
+ roll.classList.add('btn');
98
+ roll.innerHTML = `<span data-label="roll"></span>`;
99
+ roll.addEventListener('click', () => {
100
+ app.ROLL();
101
+ });
102
+ var separator = document.createElement('div');
103
+ separator.innerHTML = `=======`;
104
+ root.append(settings);
105
+ root.append(help);
106
+ root.append(separator);
107
+ root.append(roll);
108
+ document.body.appendChild(root);
109
+
110
+ // global access
111
+ // app.label.update()
112
+ dispatchEvent(new CustomEvent('updateLang', {}));
113
+ },
114
+ createBlocker: function () {
115
+ var root = document.createElement('div');
116
+ root.id = 'blocker';
117
+ var messageBox = document.createElement('div');
118
+ messageBox.id = 'messageBox';
119
+
120
+ // console.log('TEST', app.label.get)
121
+ messageBox.innerHTML = `
122
+ <span data-label="welcomeMsg"></span>
123
+ <a href="https://github.com/zlatnaspirala/matrix-engine-wgpu">zlatnaspirala/matrix-engine-wgpu</a><br><br>
124
+ <button class="btn" ><span style="font-size:30px;margin:15px;padding:10px" data-label="startGame"></span></button> <br>
125
+ <div><span data-label="changeLang"></span></div>
126
+ <button class="btn" onclick="
127
+ app.label.loadMultilang('en').then(r => {
128
+ app.label.get = r;
129
+ app.label.update()
130
+ });
131
+ " ><span data-label="english"></span></button>
132
+ <button class="btn" onclick="app.label.loadMultilang('sr').then(r => {
133
+ app.label.get = r
134
+ app.label.update() })" ><span data-label="serbian"></span></button>
135
+ `;
136
+ let initialMsgBoxEvent = function () {
137
+ console.log('click on msgbox');
138
+ (0, _utils.byId)('messageBox').innerHTML = ``;
139
+ (0, _utils.byId)('blocker').style.display = 'none';
140
+ myDom.createMenu();
141
+ messageBox.removeEventListener('click', initialMsgBoxEvent);
142
+ };
143
+ messageBox.addEventListener('click', initialMsgBoxEvent);
144
+ root.append(messageBox);
145
+ document.body.appendChild(root);
146
+ app.label.update();
147
+ },
148
+ createJamb: function () {
149
+ var root = document.createElement('div');
150
+ root.id = 'jambTable';
151
+ root.style.position = 'absolute';
152
+ root.style.display = 'flex';
153
+ root.style.top = '10px';
154
+ root.style.left = '10px';
155
+ root.style.width = '200px';
156
+ root.style.background = '#7d7d7d8c';
157
+ var rowHeader = document.createElement('div');
158
+ rowHeader.id = 'rowHeader';
159
+ rowHeader.style.top = '10px';
160
+ rowHeader.style.left = '10px';
161
+ rowHeader.style.width = '200px';
162
+ rowHeader.innerHTML = '<span data-label="cornerText"></span><span id="user-points">0</span>';
163
+ root.appendChild(rowHeader);
164
+ rowHeader.classList.add('myTheme1');
165
+ var rowDown = document.createElement('div');
166
+ rowDown.id = 'rowDown';
167
+ rowDown.style.top = '10px';
168
+ rowDown.style.left = '10px';
169
+ rowDown.style.width = '200px';
170
+ rowDown.innerHTML = '↓';
171
+ rowDown.classList.add('myTheme1');
172
+ root.appendChild(rowDown);
173
+ var rowFree = document.createElement('div');
174
+ rowFree.id = 'rowFree';
175
+ rowFree.style.top = '10px';
176
+ rowFree.style.left = '10px';
177
+ rowFree.style.width = '200px';
178
+ rowFree.innerHTML = '↕';
179
+ rowFree.classList.add('myTheme1');
180
+ root.appendChild(rowFree);
181
+ var rowUp = document.createElement('div');
182
+ rowUp.id = 'rowUp';
183
+ rowUp.style.top = '10px';
184
+ rowUp.style.left = '10px';
185
+ rowUp.style.width = '200px';
186
+ rowUp.innerHTML = '↑';
187
+ rowUp.classList.add('myTheme1');
188
+ root.appendChild(rowUp);
189
+ var rowHand = document.createElement('div');
190
+ rowHand.id = 'rowHand';
191
+ rowHand.style.top = '10px';
192
+ rowHand.style.left = '10px';
193
+ rowHand.style.width = '200px';
194
+ rowHand.innerHTML = '<span data-label="hand"></span>';
195
+ rowHand.classList.add('myTheme1');
196
+ root.appendChild(rowHand);
197
+
198
+ // INJECT TABLE HEADER ROW
199
+ this.createLeftHeaderRow(rowHeader);
200
+ this.createRowDown(rowDown);
201
+ this.createRowFree(rowFree);
202
+ this.createRow(rowUp);
203
+ this.createRow(rowHand);
204
+ document.body.appendChild(root);
205
+ // console.log('JambTable added.')
206
+ },
207
+ createLeftHeaderRow: function (myRoot) {
208
+ for (var x = 1; x < 7; x++) {
209
+ var rowNumber = document.createElement('div');
210
+ rowNumber.id = 'rowNumber' + x;
211
+ rowNumber.style.top = '10px';
212
+ rowNumber.style.left = '10px';
213
+ rowNumber.style.width = 'auto';
214
+ rowNumber.style.background = '#7d7d7d8c';
215
+ rowNumber.innerHTML = `<span>${x}</span>`;
216
+ myRoot.appendChild(rowNumber);
217
+ }
218
+ var rowNumberSum = document.createElement('div');
219
+ rowNumberSum.id = 'H_rowNumberSum';
220
+ rowNumberSum.style.width = 'auto';
221
+ rowNumberSum.style.background = '#7d7d7d8c';
222
+ rowNumberSum.innerHTML = `Σ`;
223
+ myRoot.appendChild(rowNumberSum);
224
+ var rowMax = document.createElement('div');
225
+ rowMax.id = 'H_rowMax';
226
+ rowMax.style.width = 'auto';
227
+ rowMax.style.background = '#7d7d7d8c';
228
+ rowMax.innerHTML = `<span data-label="MAX"></span>`;
229
+ myRoot.appendChild(rowMax);
230
+ var rowMin = document.createElement('div');
231
+ rowMin.id = 'H_rowMax';
232
+ rowMin.style.width = 'auto';
233
+ rowMin.style.background = '#7d7d7d8c';
234
+ rowMin.innerHTML = `<span data-label="MIN"></span>`;
235
+ myRoot.appendChild(rowMin);
236
+ var rowMaxMinSum = document.createElement('div');
237
+ rowMaxMinSum.id = 'H_rowMaxMinSum';
238
+ rowMaxMinSum.style.width = 'auto';
239
+ rowMaxMinSum.style.background = '#7d7d7d8c';
240
+ rowMaxMinSum.innerHTML = `Σ`;
241
+ myRoot.appendChild(rowMaxMinSum);
242
+ var largeStraight = document.createElement('div');
243
+ largeStraight.id = 'H_largeStraight';
244
+ largeStraight.style.width = 'auto';
245
+ largeStraight.style.background = '#7d7d7d8c';
246
+ largeStraight.innerHTML = `<span data-label="straight"></span>`;
247
+ myRoot.appendChild(largeStraight);
248
+ var threeOfAKind = document.createElement('div');
249
+ threeOfAKind.id = 'H_threeOfAKind';
250
+ threeOfAKind.style.width = 'auto';
251
+ threeOfAKind.style.background = '#7d7d7d8c';
252
+ threeOfAKind.innerHTML = `<span data-label="threeOf"></span>`;
253
+ myRoot.appendChild(threeOfAKind);
254
+ var fullHouse = document.createElement('div');
255
+ fullHouse.id = 'H_fullHouse';
256
+ fullHouse.style.width = 'auto';
257
+ fullHouse.style.background = '#7d7d7d8c';
258
+ fullHouse.innerHTML = `<span data-label="fullhouse"></span>`;
259
+ myRoot.appendChild(fullHouse);
260
+ var poker = document.createElement('div');
261
+ poker.id = 'H_poker';
262
+ poker.style.width = 'auto';
263
+ poker.style.background = '#7d7d7d8c';
264
+ poker.innerHTML = `<span data-label="poker"></span>`;
265
+ myRoot.appendChild(poker);
266
+ var jamb = document.createElement('div');
267
+ jamb.id = 'H_jamb';
268
+ jamb.style.width = 'auto';
269
+ jamb.style.background = '#7d7d7d8c';
270
+ jamb.innerHTML = `<span data-label="jamb"></span>`;
271
+ myRoot.appendChild(jamb);
272
+ var rowSum = document.createElement('div');
273
+ rowSum.id = 'H_rowSum';
274
+ rowSum.style.width = 'auto';
275
+ rowSum.style.background = '#7d7d7d8c';
276
+ rowSum.innerHTML = `Σ`;
277
+ myRoot.appendChild(rowSum);
278
+ var rowSumFINAL = document.createElement('div');
279
+ rowSumFINAL.id = 'H_rowSumFINAL';
280
+ rowSumFINAL.style.width = 'auto';
281
+ rowSumFINAL.style.background = '#7d7d7d8c';
282
+ rowSumFINAL.innerHTML = `<spam data-label="final"></span>`;
283
+ myRoot.appendChild(rowSumFINAL);
284
+ },
285
+ createRow: function (myRoot) {
286
+ for (var x = 1; x < 7; x++) {
287
+ var rowNumber = document.createElement('div');
288
+ rowNumber.id = 'rowNumber' + x;
289
+ rowNumber.style.top = '10px';
290
+ rowNumber.style.left = '10px';
291
+ rowNumber.style.width = 'auto';
292
+ rowNumber.style.background = '#7d7d7d8c';
293
+ rowNumber.innerHTML = `-`;
294
+ rowNumber.addEventListener('click', () => {
295
+ console.log('LOG THIS ', this);
296
+ // works
297
+ // rowDown
298
+ if (this.state.rowDown.length == 0) {
299
+ console.log('it is no play yet in this row ', this);
300
+ }
301
+ });
302
+ myRoot.appendChild(rowNumber);
303
+ }
304
+ var rowNumberSum = document.createElement('div');
305
+ rowNumberSum.id = 'rowNumberSum';
306
+ rowNumberSum.style.width = 'auto';
307
+ rowNumberSum.style.background = '#7d7d7d8c';
308
+ rowNumberSum.innerHTML = `-`;
309
+ myRoot.appendChild(rowNumberSum);
310
+ var rowMax = document.createElement('div');
311
+ rowMax.id = 'rowMax';
312
+ rowMax.style.width = 'auto';
313
+ rowMax.style.background = '#7d7d7d8c';
314
+ rowMax.innerHTML = `-`;
315
+ myRoot.appendChild(rowMax);
316
+ var rowMin = document.createElement('div');
317
+ rowMin.id = 'rowMax';
318
+ rowMin.style.width = 'auto';
319
+ rowMin.style.background = '#7d7d7d8c';
320
+ rowMin.innerHTML = `-`;
321
+ myRoot.appendChild(rowMin);
322
+ var rowMaxMinSum = document.createElement('div');
323
+ rowMaxMinSum.id = 'rowMaxMinSum';
324
+ rowMaxMinSum.style.width = 'auto';
325
+ rowMaxMinSum.style.background = '#7d7d7d8c';
326
+ rowMaxMinSum.innerHTML = `-`;
327
+ myRoot.appendChild(rowMaxMinSum);
328
+ var largeStraight = document.createElement('div');
329
+ largeStraight.id = 'largeStraight';
330
+ largeStraight.style.width = 'auto';
331
+ largeStraight.style.background = '#7d7d7d8c';
332
+ largeStraight.innerHTML = `-`;
333
+ myRoot.appendChild(largeStraight);
334
+ var threeOfAKind = document.createElement('div');
335
+ threeOfAKind.id = 'down_threeOfAKind';
336
+ threeOfAKind.style.width = 'auto';
337
+ threeOfAKind.style.background = '#7d7d7d8c';
338
+ threeOfAKind.innerHTML = `-`;
339
+ myRoot.appendChild(threeOfAKind);
340
+ var fullHouse = document.createElement('div');
341
+ fullHouse.id = 'fullHouse';
342
+ fullHouse.style.width = 'auto';
343
+ fullHouse.style.background = '#7d7d7d8c';
344
+ fullHouse.innerHTML = `-`;
345
+ myRoot.appendChild(fullHouse);
346
+ var poker = document.createElement('div');
347
+ poker.id = 'poker';
348
+ poker.style.width = 'auto';
349
+ poker.style.background = '#7d7d7d8c';
350
+ poker.innerHTML = `-`;
351
+ myRoot.appendChild(poker);
352
+ var jamb = document.createElement('div');
353
+ jamb.id = 'jamb';
354
+ jamb.style.width = 'auto';
355
+ jamb.style.background = '#7d7d7d8c';
356
+ jamb.innerHTML = `-`;
357
+ myRoot.appendChild(jamb);
358
+ var rowSum = document.createElement('div');
359
+ rowSum.id = 'rowSum';
360
+ rowSum.style.width = 'auto';
361
+ rowSum.style.background = '#7d7d7d8c';
362
+ rowSum.innerHTML = `-`;
363
+ myRoot.appendChild(rowSum);
364
+ },
365
+ createRowFree: function (myRoot) {
366
+ for (var x = 1; x < 7; x++) {
367
+ var rowNumber = document.createElement('div');
368
+ rowNumber.id = 'free-rowNumber' + x;
369
+ rowNumber.style.top = '10px';
370
+ rowNumber.style.left = '10px';
371
+ rowNumber.style.width = 'auto';
372
+ rowNumber.style.background = '#7d7d7d8c';
373
+ rowNumber.innerHTML = `-`;
374
+ rowNumber.addEventListener('click', e => {
375
+ if (dices.validatePass() == false) return;
376
+ var getName = e.target.id;
377
+ getName = getName.replace('free-rowNumber', '');
378
+ var count23456 = 0;
379
+ for (let key in dices.R) {
380
+ if (parseInt(dices.R[key]) == parseInt(getName)) {
381
+ count23456++;
382
+ }
383
+ }
384
+ this.state.rowDown.push(count23456 * parseInt(getName));
385
+ e.target.innerHTML = count23456 * parseInt(getName);
386
+ if (parseInt(getName) == 6) {
387
+ myDom.calcFreeNumbers();
388
+ }
389
+ dices.STATUS = "FREE_TO_PLAY";
390
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
391
+ });
392
+ myRoot.appendChild(rowNumber);
393
+ }
394
+ var rowNumberSum = document.createElement('div');
395
+ rowNumberSum.id = 'free-rowNumberSum';
396
+ rowNumberSum.style.width = 'auto';
397
+ rowNumberSum.style.background = '#7d7d7d8c';
398
+ rowNumberSum.innerHTML = `-`;
399
+ myRoot.appendChild(rowNumberSum);
400
+ var rowMax = document.createElement('div');
401
+ rowMax.id = 'free-rowMax';
402
+ rowMax.style.width = 'auto';
403
+ rowMax.style.background = '#7d7d7d8c';
404
+ rowMax.innerHTML = `-`;
405
+ rowMax.addEventListener("click", this.calcFreeRowMax);
406
+ myRoot.appendChild(rowMax);
407
+ var rowMin = document.createElement('div');
408
+ rowMin.id = 'free-rowMin';
409
+ rowMin.style.width = 'auto';
410
+ rowMin.style.background = '#7d7d7d8c';
411
+ rowMin.innerHTML = `-`;
412
+ rowMin.addEventListener('click', this.calcFreeRowMin);
413
+ myRoot.appendChild(rowMin);
414
+ var rowMaxMinSum = document.createElement('div');
415
+ rowMaxMinSum.id = 'free-rowMaxMinSum';
416
+ rowMaxMinSum.style.width = 'auto';
417
+ rowMaxMinSum.style.background = '#7d7d7d8c';
418
+ rowMaxMinSum.innerHTML = `-`;
419
+ myRoot.appendChild(rowMaxMinSum);
420
+ var largeStraight = document.createElement('div');
421
+ largeStraight.id = 'free-largeStraight';
422
+ largeStraight.style.width = 'auto';
423
+ largeStraight.style.background = '#7d7d7d8c';
424
+ largeStraight.innerHTML = `-`;
425
+ largeStraight.addEventListener('click', this.attachFreeKenta);
426
+ myRoot.appendChild(largeStraight);
427
+ var threeOfAKind = document.createElement('div');
428
+ threeOfAKind.id = 'free-threeOfAKind';
429
+ threeOfAKind.style.width = 'auto';
430
+ threeOfAKind.style.background = '#7d7d7d8c';
431
+ threeOfAKind.innerHTML = `-`;
432
+ threeOfAKind.addEventListener('click', this.attachFreeTrilling);
433
+ myRoot.appendChild(threeOfAKind);
434
+ var fullHouse = document.createElement('div');
435
+ fullHouse.id = 'free-fullHouse';
436
+ fullHouse.style.width = 'auto';
437
+ fullHouse.style.background = '#7d7d7d8c';
438
+ fullHouse.innerHTML = `-`;
439
+ fullHouse.addEventListener('click', this.attachFreeFullHouse);
440
+ myRoot.appendChild(fullHouse);
441
+ var poker = document.createElement('div');
442
+ poker.id = 'free-poker';
443
+ poker.style.width = 'auto';
444
+ poker.style.background = '#7d7d7d8c';
445
+ poker.innerHTML = `-`;
446
+ poker.addEventListener('click', this.attachFreePoker);
447
+ myRoot.appendChild(poker);
448
+ var jamb = document.createElement('div');
449
+ jamb.id = 'free-jamb';
450
+ jamb.style.width = 'auto';
451
+ jamb.style.background = '#7d7d7d8c';
452
+ jamb.innerHTML = `-`;
453
+ jamb.addEventListener('click', this.attachFreeJamb);
454
+ myRoot.appendChild(jamb);
455
+ var rowSum = document.createElement('div');
456
+ rowSum.id = 'free-rowSum';
457
+ rowSum.style.width = 'auto';
458
+ rowSum.style.background = '#7d7d7d8c';
459
+ rowSum.innerHTML = `-`;
460
+ myRoot.appendChild(rowSum);
461
+ },
462
+ createRowDown: function (myRoot) {
463
+ for (var x = 1; x < 7; x++) {
464
+ var rowNumber = document.createElement('div');
465
+ rowNumber.id = 'down-rowNumber' + x;
466
+ rowNumber.style.top = '10px';
467
+ rowNumber.style.left = '10px';
468
+ rowNumber.style.width = 'auto';
469
+ rowNumber.style.background = '#7d7d7d8c';
470
+ rowNumber.innerHTML = `-`;
471
+ this.memoNumberRow.push(rowNumber);
472
+ // initial
473
+ if (x == 1) {
474
+ rowNumber.classList.add('canPlay');
475
+ }
476
+ rowNumber.addEventListener('click', e => {
477
+ if (dices.validatePass() == false) return;
478
+ var getName = e.target.id;
479
+ getName = getName.replace('down-rowNumber', '');
480
+ if (this.state.rowDown.length == 0) {
481
+ console.log('LOG ', getName);
482
+ if (parseInt(getName) == 1) {
483
+ var count1 = 0;
484
+ for (let key in dices.R) {
485
+ if (parseInt(dices.R[key]) == 1) {
486
+ console.log('yeap', dices.R);
487
+ count1++;
488
+ }
489
+ }
490
+ this.state.rowDown.push(count1);
491
+ e.target.innerHTML = count1;
492
+ e.target.classList.remove('canPlay');
493
+ this.memoNumberRow[1].classList.add('canPlay');
494
+ dices.STATUS = "FREE_TO_PLAY";
495
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
496
+ } else {
497
+ console.log('BLOCK');
498
+ }
499
+ } else {
500
+ if (this.state.rowDown.length > 0) {
501
+ if (parseInt(getName) == this.state.rowDown.length + 1) {
502
+ console.log('moze za ', parseInt(getName));
503
+ var count23456 = 0;
504
+ for (let key in dices.R) {
505
+ if (parseInt(dices.R[key]) == parseInt(getName)) {
506
+ console.log('yeap', dices.R);
507
+ count23456++;
508
+ }
509
+ }
510
+ this.state.rowDown.push(count23456 * parseInt(getName));
511
+ //
512
+ e.target.innerHTML = count23456 * parseInt(getName);
513
+ if (parseInt(getName) == 6) {
514
+ // calc sum
515
+ console.log('calc sum for numb ~ ');
516
+ // this.state.rowDown.length + 1
517
+ myDom.calcDownNumbers();
518
+ e.target.classList.remove('canPlay');
519
+ this.rowMax.classList.add('canPlay');
520
+ } else {
521
+ e.target.classList.remove('canPlay');
522
+ this.memoNumberRow[parseInt(getName)].classList.add('canPlay');
523
+ }
524
+ dices.STATUS = "FREE_TO_PLAY";
525
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
526
+ } else {
527
+ console.log('BLOCK');
528
+ }
529
+ }
530
+ }
531
+ });
532
+ myRoot.appendChild(rowNumber);
533
+ }
534
+ var rowNumberSum = document.createElement('div');
535
+ rowNumberSum.id = 'down-rowNumberSum';
536
+ rowNumberSum.style.width = 'auto';
537
+ rowNumberSum.style.background = '#7d7d7d8c';
538
+ rowNumberSum.innerHTML = `-`;
539
+ myRoot.appendChild(rowNumberSum);
540
+ var rowMax = document.createElement('div');
541
+ rowMax.id = 'down-rowMax';
542
+ rowMax.style.width = 'auto';
543
+ rowMax.style.background = '#7d7d7d8c';
544
+ rowMax.innerHTML = `-`;
545
+ myRoot.appendChild(rowMax);
546
+ this.rowMax = rowMax;
547
+ // this.rowMax.addEventListener("click", (e) => {
548
+ // e.target.classList.remove('canPlay')
549
+ // this.rowMin.classList.add('canPlay')
550
+ // })
551
+
552
+ var rowMin = document.createElement('div');
553
+ rowMin.id = 'down-rowMin';
554
+ rowMin.style.width = 'auto';
555
+ rowMin.style.background = '#7d7d7d8c';
556
+ rowMin.innerHTML = `-`;
557
+ this.rowMin = rowMin;
558
+ myRoot.appendChild(rowMin);
559
+ this.rowMin = rowMin;
560
+ var rowMaxMinSum = document.createElement('div');
561
+ rowMaxMinSum.id = 'down-rowMaxMinSum';
562
+ rowMaxMinSum.style.width = 'auto';
563
+ rowMaxMinSum.style.background = '#7d7d7d8c';
564
+ rowMaxMinSum.innerHTML = `-`;
565
+ myRoot.appendChild(rowMaxMinSum);
566
+ var largeStraight = document.createElement('div');
567
+ largeStraight.id = 'down-largeStraight';
568
+ largeStraight.style.width = 'auto';
569
+ largeStraight.style.background = '#7d7d7d8c';
570
+ largeStraight.innerHTML = `-`;
571
+ myRoot.appendChild(largeStraight);
572
+ var threeOfAKind = document.createElement('div');
573
+ threeOfAKind.id = 'down-threeOfAKind';
574
+ threeOfAKind.style.width = 'auto';
575
+ threeOfAKind.style.background = '#7d7d7d8c';
576
+ threeOfAKind.innerHTML = `-`;
577
+ myRoot.appendChild(threeOfAKind);
578
+ var fullHouse = document.createElement('div');
579
+ fullHouse.id = 'down-fullHouse';
580
+ fullHouse.style.width = 'auto';
581
+ fullHouse.style.background = '#7d7d7d8c';
582
+ fullHouse.innerHTML = `-`;
583
+ myRoot.appendChild(fullHouse);
584
+ var poker = document.createElement('div');
585
+ poker.id = 'down-poker';
586
+ poker.style.width = 'auto';
587
+ poker.style.background = '#7d7d7d8c';
588
+ poker.innerHTML = `-`;
589
+ myRoot.appendChild(poker);
590
+ var jamb = document.createElement('div');
591
+ jamb.id = 'down-jamb';
592
+ jamb.style.width = 'auto';
593
+ jamb.style.background = '#7d7d7d8c';
594
+ jamb.innerHTML = `-`;
595
+ myRoot.appendChild(jamb);
596
+ var rowSum = document.createElement('div');
597
+ rowSum.id = 'down-rowSum';
598
+ rowSum.style.width = 'auto';
599
+ rowSum.style.background = '#7d7d7d8c';
600
+ rowSum.innerHTML = `-`;
601
+ myRoot.appendChild(rowSum);
602
+ },
603
+ calcDownNumbers: function () {
604
+ var s = 0;
605
+ this.state.rowDown.forEach(i => {
606
+ console.log(parseFloat(i));
607
+ s += parseFloat(i);
608
+ });
609
+ (0, _utils.byId)('down-rowNumberSum').style.background = 'rgb(113 0 0 / 55%)';
610
+ (0, _utils.byId)('down-rowNumberSum').innerHTML = s;
611
+ // console.log('this.rowMax also set free to plat status', this.rowMax)
612
+ dices.STATUS = "FREE_TO_PLAY";
613
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
614
+ this.rowMax.addEventListener("click", this.calcDownRowMax);
615
+ },
616
+ // free row start
617
+
618
+ calcFreeNumbers: function () {
619
+ var s = 0;
620
+ this.state.rowDown.forEach(i => {
621
+ console.log(parseFloat(i));
622
+ s += parseFloat(i);
623
+ });
624
+ (0, _utils.byId)('free-rowNumberSum').style.background = 'rgb(113 0 0 / 55%)';
625
+ (0, _utils.byId)('free-rowNumberSum').innerHTML = s;
626
+ // console.log('this.rowMax also set free to plat status', this.rowMax)
627
+ dices.STATUS = "FREE_TO_PLAY";
628
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
629
+ (0, _utils.byId)('free-rowMax').addEventListener("click", this.calc);
630
+ },
631
+ calcFreeRowMax: e => {
632
+ if (dices.validatePass() == false) return;
633
+ var test = 0;
634
+ let keyLessNum = Object.keys(dices.R).reduce((key, v) => dices.R[v] < dices.R[key] ? v : key);
635
+ for (var key in dices.R) {
636
+ if (key != keyLessNum) {
637
+ test += parseFloat(dices.R[key]);
638
+ }
639
+ }
640
+ e.target.innerHTML = test;
641
+ // now attach next event.
642
+ dices.STATUS = "FREE_TO_PLAY";
643
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
644
+ (0, _utils.byId)('free-rowMax').removeEventListener("click", (void 0).calcFreeRowMax);
645
+ },
646
+ calcFreeRowMin: () => {
647
+ if (dices.validatePass() == false) return;
648
+ var maxTestKey = Object.keys(dices.R).reduce(function (a, b) {
649
+ return dices.R[a] > dices.R[b] ? a : b;
650
+ });
651
+ var test = 0;
652
+ for (var key in dices.R) {
653
+ if (key != maxTestKey) {
654
+ test += parseFloat(dices.R[key]);
655
+ } else {
656
+ console.log('not calc dice ', dices.R[key]);
657
+ }
658
+ }
659
+ (0, _utils.byId)('free-rowMin').innerHTML = test;
660
+ (0, _utils.byId)('free-rowMin').removeEventListener('click', (void 0).calcFreeRowMin);
661
+ // calc max min dont forget rules for bonus +30
662
+ var SUMMINMAX = parseFloat((0, _utils.byId)('free-rowMax').innerHTML) - parseFloat((0, _utils.byId)('free-rowMin').innerHTML);
663
+ (0, _utils.byId)('free-rowMaxMinSum').innerHTML = SUMMINMAX;
664
+ myDom.incrasePoints(SUMMINMAX);
665
+ dices.STATUS = "FREE_TO_PLAY";
666
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
667
+ },
668
+ attachFreeKenta: function () {
669
+ if (dices.validatePass() == false) return;
670
+ console.log('Test free kenta :', dices.R);
671
+ var result = app.myDom.checkForDuplicate()[0];
672
+ var testArray = app.myDom.checkForDuplicate()[1];
673
+ console.log('TEST duplik: ' + result);
674
+ if (result.length == 2) {
675
+ console.log('TEST duplik less 3 : ' + result);
676
+ var locPrevent = false;
677
+ testArray.forEach((item, index, array) => {
678
+ if (result[0].value == item.value && locPrevent == false) {
679
+ console.log('detect by value item.value', item.value);
680
+ locPrevent = true;
681
+ array.splice(index, 1);
682
+ }
683
+ });
684
+ // if we catch 1 and 6 in same stack then it is not possible for kenta...
685
+ var test1 = false,
686
+ test6 = false;
687
+ testArray.forEach((item, index, array) => {
688
+ if (item.value == 1) {
689
+ test1 = true;
690
+ } else if (item.value == 6) {
691
+ test6 = true;
692
+ }
693
+ });
694
+ if (test1 == true && test6 == true) {
695
+ (0, _utils.byId)('free-largeStraight').innerHTML = `0`;
696
+ } else if (test1 == true) {
697
+ (0, _utils.byId)('free-largeStraight').innerHTML = 15 + 50;
698
+ myDom.incrasePoints(15 + 50);
699
+ } else if (test6 == true) {
700
+ (0, _utils.byId)('free-largeStraight').innerHTML = 20 + 50;
701
+ myDom.incrasePoints(20 + 50);
702
+ }
703
+ } else if (result < 2) {
704
+ (0, _utils.byId)('free-largeStraight').innerHTML = 66;
705
+ myDom.incrasePoints(66);
706
+ } else {
707
+ // zero value
708
+ (0, _utils.byId)('free-largeStraight').innerHTML = `0`;
709
+ }
710
+ (0, _utils.byId)('free-largeStraight').removeEventListener('click', this.attachFreeKenta);
711
+ dices.STATUS = "FREE_TO_PLAY";
712
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
713
+ },
714
+ attachFreeTrilling: function () {
715
+ if (dices.validatePass() == false) return;
716
+ var result = app.myDom.checkForDuplicate()[0];
717
+ // var testArray = app.myDom.checkForDuplicate()[1];
718
+ // console.log('DUPLICATE FOR TRILING ', result);
719
+ if (result.length > 2) {
720
+ var testWin = 0;
721
+ var TEST = app.myDom.checkForAllDuplicate();
722
+ console.log('DUPLICATE FOR TRILING TEST ', TEST);
723
+ for (var key in TEST) {
724
+ if (TEST[key] > 2) {
725
+ // win
726
+ var getDiceID = parseInt(key.replace('value__', ''));
727
+ testWin = getDiceID * 3;
728
+ }
729
+ }
730
+ console.log('DUPLICATE FOR TRILING 30 + TEST ', testWin);
731
+ if (testWin > 0) {
732
+ (0, _utils.byId)('free-threeOfAKind').innerHTML = 20 + testWin;
733
+ myDom.incrasePoints(20 + testWin);
734
+ }
735
+ } else {
736
+ (0, _utils.byId)('free-threeOfAKind').innerHTML = 0;
737
+ }
738
+ (0, _utils.byId)('free-threeOfAKind').removeEventListener('click', this.attachFreeTrilling);
739
+ dices.STATUS = "FREE_TO_PLAY";
740
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
741
+ },
742
+ attachFreeFullHouse: function () {
743
+ if (dices.validatePass() == false) return;
744
+ var TEST = app.myDom.checkForAllDuplicate();
745
+ // console.log('DUPLICATE FOR FULL HOUSE 30 + TEST ');
746
+ var win = 0;
747
+ var testPair = false;
748
+ var testTrilling = false;
749
+ var testWinPair = 0;
750
+ var testWinTrilling = 0;
751
+ for (var key in TEST) {
752
+ if (TEST[key] == 2) {
753
+ // win
754
+ var getDiceID = parseInt(key.replace('value__', ''));
755
+ testWinPair = getDiceID * 2;
756
+ testPair = true;
757
+ } else if (TEST[key] == 3) {
758
+ var getDiceID = parseInt(key.replace('value__', ''));
759
+ testWinTrilling = getDiceID * 3;
760
+ testTrilling = true;
761
+ }
762
+ }
763
+ if (testPair == true && testTrilling == true) {
764
+ win = testWinPair + testWinTrilling;
765
+ (0, _utils.byId)('free-fullHouse').innerHTML = win + 30;
766
+ myDom.incrasePoints(win + 30);
767
+ } else {
768
+ (0, _utils.byId)('free-fullHouse').innerHTML = 0;
769
+ }
770
+ (0, _utils.byId)('free-fullHouse').removeEventListener('click', this.attachFreeFullHouse);
771
+ dices.STATUS = "FREE_TO_PLAY";
772
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
773
+ },
774
+ attachFreePoker: function () {
775
+ if (dices.validatePass() == false) return;
776
+ var TEST = app.myDom.checkForAllDuplicate();
777
+ // console.log('DUPLICATE FOR poker 40 + TEST ');
778
+ for (var key in TEST) {
779
+ if (TEST[key] == 4 || TEST[key] > 4) {
780
+ var getDiceID = parseInt(key.replace('value__', ''));
781
+ var win = getDiceID * 4;
782
+ (0, _utils.byId)('free-poker').innerHTML = win + 40;
783
+ myDom.incrasePoints(win + 40);
784
+ }
785
+ }
786
+ (0, _utils.byId)('free-poker').removeEventListener('click', this.attachFreePoker);
787
+ dices.STATUS = "FREE_TO_PLAY";
788
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
789
+ },
790
+ attachFreeJamb: function () {
791
+ if (dices.validatePass() == false) return;
792
+ // console.log('<GAMEPLAY><FREE ROW IS FEELED>')
793
+ var TEST = app.myDom.checkForAllDuplicate();
794
+ for (var key in TEST) {
795
+ if (TEST[key] == 5 || TEST[key] > 5) {
796
+ // win
797
+ var getDiceID = parseInt(key.replace('value__', ''));
798
+ var win = getDiceID * 5;
799
+ (0, _utils.byId)('free-poker').innerHTML = win + 50;
800
+ myDom.incrasePoints(win + 50);
801
+ }
802
+ }
803
+ (0, _utils.byId)('free-jamb').removeEventListener('click', this.attachFreeJamb);
804
+ dices.STATUS = "FREE_TO_PLAY";
805
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
806
+ },
807
+ // end of free row
808
+
809
+ calcDownRowMax: e => {
810
+ if (dices.validatePass() == false) return;
811
+ e.target.classList.remove('canPlay');
812
+ (void 0).rowMin.classList.add('canPlay');
813
+ var test = 0;
814
+ let keyLessNum = Object.keys(dices.R).reduce((key, v) => dices.R[v] < dices.R[key] ? v : key);
815
+ // console.log('FIND MIN DICE TO REMOVE FROM SUM ', keyLessNum);
816
+ for (var key in dices.R) {
817
+ if (key != keyLessNum) {
818
+ test += parseFloat(dices.R[key]);
819
+ }
820
+ }
821
+ e.target.innerHTML = test;
822
+ // now attach next event.
823
+ dices.STATUS = "FREE_TO_PLAY";
824
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
825
+ (void 0).rowMax.removeEventListener("click", (void 0).calcDownRowMax);
826
+ (0, _utils.byId)('down-rowMin').addEventListener('click', (void 0).calcDownRowMin);
827
+ },
828
+ incrasePoints: function (arg) {
829
+ (0, _utils.byId)('user-points').innerHTML = parseInt((0, _utils.byId)('user-points').innerHTML) + parseInt(arg);
830
+ },
831
+ calcDownRowMin: () => {
832
+ if (dices.validatePass() == false) return;
833
+ (void 0).rowMin.classList.remove('canPlay');
834
+ console.log('MIN ENABLED');
835
+ var maxTestKey = Object.keys(dices.R).reduce(function (a, b) {
836
+ return dices.R[a] > dices.R[b] ? a : b;
837
+ });
838
+ var test = 0;
839
+ for (var key in dices.R) {
840
+ if (key != maxTestKey) {
841
+ test += parseFloat(dices.R[key]);
842
+ } else {
843
+ console.log('not calc dice ', dices.R[key]);
844
+ }
845
+ }
846
+ (void 0).rowMin.innerHTML = test;
847
+ (0, _utils.byId)('down-rowMin').removeEventListener('click', (void 0).calcDownRowMin);
848
+ // calc max min dont forget rules for bonus +30
849
+ var SUMMINMAX = parseFloat((void 0).rowMax.innerHTML) - parseFloat((void 0).rowMin.innerHTML);
850
+ (0, _utils.byId)('down-rowMaxMinSum').innerHTML = SUMMINMAX;
851
+ myDom.incrasePoints(SUMMINMAX);
852
+ dices.STATUS = "FREE_TO_PLAY";
853
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
854
+ (0, _utils.byId)('down-largeStraight').classList.add('canPlay');
855
+ (0, _utils.byId)('down-largeStraight').addEventListener('click', (void 0).attachKenta);
856
+ },
857
+ checkForDuplicate: function () {
858
+ var testArray = [];
859
+ for (var key in dices.R) {
860
+ var gen = {
861
+ myId: key,
862
+ value: dices.R[key]
863
+ };
864
+ testArray.push(gen);
865
+ }
866
+ var result = Object.values(testArray.reduce((c, v) => {
867
+ let k = v.value;
868
+ c[k] = c[k] || [];
869
+ c[k].push(v);
870
+ return c;
871
+ }, {})).reduce((c, v) => v.length > 1 ? c.concat(v) : c, []);
872
+ return [result, testArray];
873
+ },
874
+ checkForAllDuplicate: function () {
875
+ var testArray = [];
876
+ for (var key in dices.R) {
877
+ var gen = {
878
+ myId: key,
879
+ value: dices.R[key]
880
+ };
881
+ testArray.push(gen);
882
+ }
883
+ // console.log('testArray ', testArray)
884
+ var result = Object.values(testArray.reduce((c, v) => {
885
+ let k = v.value;
886
+ c[k] = c[k] || [];
887
+ c[k].push(v);
888
+ return c;
889
+ }, {})).reduce((c, v) => v.length > 1 ? c.concat(v) : c, []);
890
+ var discret = {};
891
+ result.forEach((item, index, array) => {
892
+ if (typeof discret['value__' + item.value] === 'undefined') {
893
+ discret['value__' + item.value] = 1;
894
+ } else {
895
+ discret['value__' + item.value] += 1;
896
+ }
897
+ });
898
+ return discret;
899
+ },
900
+ attachKenta: function () {
901
+ console.log('Test kenta ', dices.R);
902
+ (0, _utils.byId)('down-largeStraight').classList.remove('canPlay');
903
+ var result = app.myDom.checkForDuplicate()[0];
904
+ var testArray = app.myDom.checkForDuplicate()[1];
905
+ // console.log('TEST duplik: ' + result);
906
+ if (result.length == 2) {
907
+ console.log('TEST duplik less 3 : ' + result);
908
+ var locPrevent = false;
909
+ testArray.forEach((item, index, array) => {
910
+ if (result[0].value == item.value && locPrevent == false) {
911
+ console.log('detect by value item.value', item.value);
912
+ locPrevent = true;
913
+ array.splice(index, 1);
914
+ }
915
+ });
916
+ // if we catch 1 and 6 in same stack then it is not possible for kenta...
917
+ var test1 = false,
918
+ test6 = false;
919
+ testArray.forEach((item, index, array) => {
920
+ if (item.value == 1) {
921
+ test1 = true;
922
+ } else if (item.value == 6) {
923
+ test6 = true;
924
+ }
925
+ });
926
+ if (test1 == true && test6 == true) {
927
+ (0, _utils.byId)('down-largeStraight').innerHTML = `0`;
928
+ } else if (test1 == true) {
929
+ (0, _utils.byId)('down-largeStraight').innerHTML = 15 + 50;
930
+ myDom.incrasePoints(15 + 50);
931
+ } else if (test6 == true) {
932
+ (0, _utils.byId)('down-largeStraight').innerHTML = 20 + 50;
933
+ myDom.incrasePoints(20 + 50);
934
+ }
935
+ } else if (result < 2) {
936
+ (0, _utils.byId)('down-largeStraight').innerHTML = 66;
937
+ myDom.incrasePoints(66);
938
+ } else {
939
+ // zero value
940
+ (0, _utils.byId)('down-largeStraight').innerHTML = `0`;
941
+ }
942
+ (0, _utils.byId)('down-threeOfAKind').addEventListener('click', this.attachDownTrilling);
943
+ (0, _utils.byId)('down-largeStraight').removeEventListener('click', this.attachKenta);
944
+ dices.STATUS = "FREE_TO_PLAY";
945
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
946
+ },
947
+ attachDownTrilling: function () {
948
+ var result = app.myDom.checkForDuplicate()[0];
949
+ // var testArray = app.myDom.checkForDuplicate()[1];
950
+ // console.log('DUPLICATE FOR TRILING ', result);
951
+ if (result.length > 2) {
952
+ var testWin = 0;
953
+ var TEST = app.myDom.checkForAllDuplicate();
954
+ console.log('DUPLICATE FOR TRILING TEST ', TEST);
955
+ for (var key in TEST) {
956
+ if (TEST[key] > 2) {
957
+ // win
958
+ var getDiceID = parseInt(key.replace('value__', ''));
959
+ testWin = getDiceID * 3;
960
+ }
961
+ }
962
+ console.log('DUPLICATE FOR TRILING 30 + TEST ', testWin);
963
+ (0, _utils.byId)('down-threeOfAKind').innerHTML = 20 + testWin;
964
+ myDom.incrasePoints(20 + testWin);
965
+ } else {
966
+ (0, _utils.byId)('down-threeOfAKind').innerHTML = 0;
967
+ }
968
+ (0, _utils.byId)('down-threeOfAKind').removeEventListener('click', this.attachDownTrilling);
969
+ (0, _utils.byId)('down-fullHouse').addEventListener('click', this.attachDownFullHouse);
970
+ dices.STATUS = "FREE_TO_PLAY";
971
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
972
+ },
973
+ attachDownFullHouse: function () {
974
+ var TEST = app.myDom.checkForAllDuplicate();
975
+ // console.log('DUPLICATE FOR FULL HOUSE 30 + TEST ');
976
+ var win = 0;
977
+ var testPair = false;
978
+ var testTrilling = false;
979
+ var testWinPair = 0;
980
+ var testWinTrilling = 0;
981
+ for (var key in TEST) {
982
+ if (TEST[key] == 2) {
983
+ // win
984
+ var getDiceID = parseInt(key.replace('value__', ''));
985
+ testWinPair = getDiceID * 2;
986
+ testPair = true;
987
+ } else if (TEST[key] == 3) {
988
+ var getDiceID = parseInt(key.replace('value__', ''));
989
+ testWinTrilling = getDiceID * 3;
990
+ testTrilling = true;
991
+ }
992
+ }
993
+ if (testPair == true && testTrilling == true) {
994
+ win = testWinPair + testWinTrilling;
995
+ (0, _utils.byId)('down-fullHouse').innerHTML = win + 30;
996
+ myDom.incrasePoints(win + 30);
997
+ } else {
998
+ (0, _utils.byId)('down-fullHouse').innerHTML = 0;
999
+ }
1000
+ (0, _utils.byId)('down-poker').addEventListener('click', this.attachDownPoker);
1001
+ (0, _utils.byId)('down-fullHouse').removeEventListener('click', this.attachDownFullHouse);
1002
+ dices.STATUS = "FREE_TO_PLAY";
1003
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
1004
+ },
1005
+ attachDownPoker: function () {
1006
+ var TEST = app.myDom.checkForAllDuplicate();
1007
+ // console.log('DUPLICATE FOR poker 40 + TEST ');
1008
+ for (var key in TEST) {
1009
+ if (TEST[key] == 4 || TEST[key] > 4) {
1010
+ // win
1011
+ var getDiceID = parseInt(key.replace('value__', ''));
1012
+ var win = getDiceID * 4;
1013
+ (0, _utils.byId)('down-poker').innerHTML = win + 40;
1014
+ myDom.incrasePoints(win + 40);
1015
+ }
1016
+ }
1017
+ (0, _utils.byId)('down-poker').removeEventListener('click', this.attachDownPoker);
1018
+ (0, _utils.byId)('down-jamb').addEventListener('click', this.attachDownJamb);
1019
+ dices.STATUS = "FREE_TO_PLAY";
1020
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
1021
+ },
1022
+ attachDownJamb: function () {
1023
+ (0, _utils.byId)('down-jamb').removeEventListener('click', this.attachDownJamb);
1024
+ console.log('<GAMEPLAY><DOWN ROW IS FEELED>');
1025
+ var TEST = app.myDom.checkForAllDuplicate();
1026
+ for (var key in TEST) {
1027
+ if (TEST[key] == 5 || TEST[key] > 5) {
1028
+ // win
1029
+ var getDiceID = parseInt(key.replace('value__', ''));
1030
+ var win = getDiceID * 5;
1031
+ (0, _utils.byId)('down-poker').innerHTML = win + 50;
1032
+ myDom.incrasePoints(win + 50);
1033
+ }
1034
+ }
1035
+ dices.STATUS = "FREE_TO_PLAY";
1036
+ dispatchEvent(new CustomEvent('FREE_TO_PLAY', {}));
1037
+ }
1038
+ };
1039
+
1040
+ },{"../../../src/engine/loader-obj.js":7,"../../../src/engine/utils.js":12,"../../../src/world.js":20}],2:[function(require,module,exports){
1041
+ "use strict";
1042
+
4
1043
  Object.defineProperty(exports, "__esModule", {
5
1044
  value: true
6
1045
  });
@@ -8,6 +1047,9 @@ exports.application = void 0;
8
1047
  var _world = _interopRequireDefault(require("./src/world.js"));
9
1048
  var _loaderObj = require("./src/engine/loader-obj.js");
10
1049
  var _utils = require("./src/engine/utils.js");
1050
+ var _jamb = require("./examples/games/jamb/jamb.js");
1051
+ var _sounds = require("./src/sounds/sounds.js");
1052
+ var _raycast = require("./src/engine/raycast.js");
11
1053
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
1054
  let application = exports.application = new _world.default({
13
1055
  useSingleRenderPass: true,
@@ -17,23 +1059,366 @@ let application = exports.application = new _world.default({
17
1059
  responseCoef: 1000
18
1060
  }
19
1061
  }, () => {
1062
+ // Dom operations
1063
+ application.myDom = _jamb.myDom;
1064
+ _jamb.myDom.createJamb();
1065
+ _jamb.myDom.createBlocker();
1066
+ application.dices = _jamb.dices;
1067
+
1068
+ // this code must be on top
1069
+ application.matrixAmmo.detectCollision = function () {
1070
+ this.lastRoll = '';
1071
+ this.presentScore = '';
1072
+ let dispatcher = this.dynamicsWorld.getDispatcher();
1073
+ let numManifolds = dispatcher.getNumManifolds();
1074
+ for (let i = 0; i < numManifolds; i++) {
1075
+ let contactManifold = dispatcher.getManifoldByIndexInternal(i);
1076
+ // let numContacts = contactManifold.getNumContacts();
1077
+ if (this.ground.kB == contactManifold.getBody0().kB || this.ground.kB == contactManifold.getBody1().kB) {
1078
+ // console.log(this.ground ,'GROUND IS IN CONTACT WHO IS BODY1 ', contactManifold.getBody1())
1079
+ // CHECK ROTATION BEST WAY - VISAL PART IS NOT INTEREST NOW
1080
+ if (this.ground.kB == contactManifold.getBody0().kB) {
1081
+ var MY_DICE_NAME = this.getNameByBody(contactManifold.getBody1());
1082
+ var testR = contactManifold.getBody1().getWorldTransform().getRotation();
1083
+ }
1084
+ if (this.ground.kB == contactManifold.getBody1().kB) {
1085
+ var MY_DICE_NAME = this.getNameByBody(contactManifold.getBody0());
1086
+ var testR = contactManifold.getBody0().getWorldTransform().getRotation();
1087
+ }
1088
+ var passed = false;
1089
+ if (Math.abs(testR.y()) < 0.00001) {
1090
+ this.lastRoll = "3";
1091
+ this.presentScore += 4;
1092
+ passed = true;
1093
+ }
1094
+ if (Math.abs(testR.x()) < 0.00001) {
1095
+ this.lastRoll = "5";
1096
+ this.presentScore += 3;
1097
+ passed = true;
1098
+ }
1099
+ if (testR.x().toString().substring(0, 5) == testR.y().toString().substring(1, 6)) {
1100
+ this.lastRoll = "6";
1101
+ this.presentScore += 2;
1102
+ passed = true;
1103
+ }
1104
+ if (testR.x().toString().substring(0, 5) == testR.y().toString().substring(0, 5)) {
1105
+ this.lastRoll = "2";
1106
+ this.presentScore += 1;
1107
+ passed = true;
1108
+ }
1109
+ if (testR.z().toString().substring(0, 5) == testR.y().toString().substring(1, 6)) {
1110
+ this.lastRoll = "4";
1111
+ this.presentScore += 6;
1112
+ passed = true;
1113
+ }
1114
+ if (testR.z().toString().substring(0, 5) == testR.y().toString().substring(0, 5)) {
1115
+ this.lastRoll = "1";
1116
+ this.presentScore += 5;
1117
+ passed = true;
1118
+ }
1119
+ if (passed == true) dispatchEvent(new CustomEvent(`dice-${this.lastRoll}`, {
1120
+ detail: {
1121
+ result: `dice-${this.lastRoll}`,
1122
+ cubeId: MY_DICE_NAME
1123
+ }
1124
+ }));
1125
+ }
1126
+ }
1127
+ };
1128
+ (0, _raycast.addRaycastListener)();
1129
+ addEventListener("ray.hit.event", e => {
1130
+ console.log("hit cube ", e.detail.hitObject.name);
1131
+ if (application.dices.STATUS == "FREE_TO_PLAY") {
1132
+ console.log("hit cube status free to play prevent pick. ", e.detail.hitObject.name);
1133
+ } else if (application.dices.STATUS == "SELECT_DICES_1") {
1134
+ console.log("hit cube status SELECT1 pick.", e.detail.hitObject.name);
1135
+ application.dices.pickDice(e.detail.hitObject.name);
1136
+ }
1137
+ });
1138
+ // OR add manual see readme
1139
+
1140
+ addEventListener('mousemove', e => {
1141
+ // console.log('only on click')
1142
+ _raycast.touchCoordinate.enabled = true;
1143
+ });
1144
+
1145
+ // Sounds
1146
+ application.matrixSounds.createAudio('start', 'res/audios/start.mp3', 1);
1147
+ application.matrixSounds.createAudio('block', 'res/audios/block.mp3', 6);
1148
+ application.matrixSounds.createAudio('dice1', 'res/audios/dice1.mp3', 6);
1149
+ application.matrixSounds.createAudio('dice2', 'res/audios/dice2.mp3', 6);
20
1150
  addEventListener('AmmoReady', () => {
21
1151
  (0, _loaderObj.downloadMeshes)({
22
- welcomeText: "./res/meshes/blender/piramyd.obj",
23
- armor: "./res/meshes/obj/armor.obj",
24
- sphere: "./res/meshes/blender/sphere.obj",
25
- cube: "./res/meshes/blender/cube.obj"
26
- }, onLoadObj);
1152
+ cube: "./res/meshes/jamb/dice.obj"
1153
+ }, onLoadObj, {
1154
+ scale: [1, 1, 1],
1155
+ swap: [null]
1156
+ });
1157
+ (0, _loaderObj.downloadMeshes)({
1158
+ bg: "./res/meshes/jamb/bg.obj"
1159
+ }, onLoadObjFloor, {
1160
+ scale: [3, 1, 3],
1161
+ swap: [null]
1162
+ });
1163
+ (0, _loaderObj.downloadMeshes)({
1164
+ mainTitle: "./res/meshes/jamb/jamb-title.obj"
1165
+ }, onLoadObjOther, {
1166
+ scale: [3, 2, 3],
1167
+ swap: [null]
1168
+ });
1169
+ (0, _loaderObj.downloadMeshes)({
1170
+ cube: "./res/meshes/jamb/dice.obj"
1171
+ }, onLoadObjWallCenter, {
1172
+ scale: [50, 10, 10],
1173
+ swap: [null]
1174
+ });
1175
+ (0, _loaderObj.downloadMeshes)({
1176
+ cube: "./res/meshes/jamb/dice.obj"
1177
+ }, m => {
1178
+ for (var key in m) {
1179
+ // console.log(`%c Loaded objs -> : ${key} `, LOG_MATRIX);
1180
+ }
1181
+ // right
1182
+ application.addMeshObj({
1183
+ position: {
1184
+ x: 25,
1185
+ y: 5.5,
1186
+ z: -25
1187
+ },
1188
+ rotation: {
1189
+ x: 0,
1190
+ y: -22,
1191
+ z: 0
1192
+ },
1193
+ scale: [25, 10, 4],
1194
+ texturesPaths: ['./res/meshes/jamb/text.png'],
1195
+ name: 'wallRight',
1196
+ mesh: m.cube,
1197
+ physics: {
1198
+ mass: 0,
1199
+ enabled: true,
1200
+ geometry: "Cube"
1201
+ }
1202
+ });
1203
+ application.addMeshObj({
1204
+ position: {
1205
+ x: -25,
1206
+ y: 5.5,
1207
+ z: -25
1208
+ },
1209
+ rotation: {
1210
+ x: 0,
1211
+ y: 22,
1212
+ z: 0
1213
+ },
1214
+ scale: [25, 10, 4],
1215
+ texturesPaths: ['./res/meshes/jamb/text.png'],
1216
+ name: 'wallLeft',
1217
+ mesh: m.cube,
1218
+ physics: {
1219
+ mass: 0,
1220
+ enabled: true,
1221
+ geometry: "Cube"
1222
+ }
1223
+ });
1224
+ }, {
1225
+ scale: [25, 10, 4],
1226
+ swap: [null]
1227
+ });
27
1228
  });
1229
+ function onLoadObjWallCenter(m) {
1230
+ application.myLoadedMeshesWalls = m;
1231
+ for (var key in m) {
1232
+ // console.log(`%c Loaded objs -> : ${key} `, LOG_MATRIX);
1233
+ }
1234
+
1235
+ // WALLS Center
1236
+ application.addMeshObj({
1237
+ position: {
1238
+ x: 0,
1239
+ y: 5,
1240
+ z: -45
1241
+ },
1242
+ rotation: {
1243
+ x: 0,
1244
+ y: 0,
1245
+ z: 0
1246
+ },
1247
+ scale: [50, 10, 10],
1248
+ texturesPaths: ['./res/meshes/jamb/text.png'],
1249
+ name: 'wallCenter',
1250
+ mesh: m.cube,
1251
+ physics: {
1252
+ mass: 0,
1253
+ enabled: true,
1254
+ geometry: "Cube"
1255
+ }
1256
+ });
1257
+ }
1258
+ function onLoadObjOther(m) {
1259
+ application.myLoadedMeshes = m;
1260
+ for (var key in m) {
1261
+ // console.log(`%c Loaded objs -> : ${key} `, LOG_MATRIX);
1262
+ }
1263
+ // Add logo text top
1264
+ application.addMeshObj({
1265
+ position: {
1266
+ x: 0,
1267
+ y: 6,
1268
+ z: -15
1269
+ },
1270
+ rotation: {
1271
+ x: 0,
1272
+ y: 0,
1273
+ z: 0
1274
+ },
1275
+ texturesPaths: ['./res/meshes/jamb/text.png'],
1276
+ name: 'mainTitle',
1277
+ mesh: m.mainTitle,
1278
+ physics: {
1279
+ mass: 0,
1280
+ enabled: true,
1281
+ geometry: "Cube"
1282
+ }
1283
+ });
1284
+ // console.log('camera set')
1285
+ // application.cameras.WASD.pitch = 0.2
1286
+ setTimeout(() => {
1287
+ app.cameras.WASD.velocity[1] = 18;
1288
+ // BODY , x, y, z, rotX, rotY, RotZ
1289
+ app.matrixAmmo.setKinematicTransform(app.matrixAmmo.getBodyByName('mainTitle'), 0, 0, 0, 1);
1290
+ app.matrixAmmo.setKinematicTransform(app.matrixAmmo.getBodyByName('bg'), 0, -10, 0, 0, 0, 0);
1291
+ // Better access getBodyByName
1292
+ console.log(' app.matrixAmmo. ', app.matrixAmmo.getBodyByName('CubePhysics1'));
1293
+ }, 1225);
1294
+ }
1295
+ function onLoadObjFloor(m) {
1296
+ application.myLoadedMeshes = m;
1297
+ for (var key in m) {
1298
+ // console.log(`%c Loaded objs -> : ${key} `, LOG_MATRIX);
1299
+ }
1300
+ application.addMeshObj({
1301
+ scale: [10, 0.1, 0.1],
1302
+ position: {
1303
+ x: 0,
1304
+ y: 6,
1305
+ z: -10
1306
+ },
1307
+ rotation: {
1308
+ x: 0,
1309
+ y: 0,
1310
+ z: 0
1311
+ },
1312
+ // rotationSpeed: {x: 0, y: 0, z: 0},
1313
+ texturesPaths: ['./res/meshes/jamb/bg.png'],
1314
+ name: 'bg',
1315
+ mesh: m.bg,
1316
+ physics: {
1317
+ collide: false,
1318
+ mass: 0,
1319
+ enabled: true,
1320
+ geometry: "Cube"
1321
+ }
1322
+ });
1323
+ }
28
1324
  function onLoadObj(m) {
29
1325
  application.myLoadedMeshes = m;
30
1326
  for (var key in m) {
31
- console.log(`%c Loaded objs: ${key} `, _utils.LOG_MATRIX);
1327
+ // console.log(`%c Loaded objs -> : ${key} `, LOG_MATRIX);
32
1328
  }
1329
+
1330
+ // Add dices
1331
+ application.addMeshObj({
1332
+ position: {
1333
+ x: 0,
1334
+ y: 6,
1335
+ z: -10
1336
+ },
1337
+ rotation: {
1338
+ x: 0,
1339
+ y: 0,
1340
+ z: 0
1341
+ },
1342
+ rotationSpeed: {
1343
+ x: 0,
1344
+ y: 0,
1345
+ z: 0
1346
+ },
1347
+ texturesPaths: ['./res/meshes/jamb/dice.png'],
1348
+ useUVShema4x2: true,
1349
+ name: 'CubePhysics1',
1350
+ mesh: m.cube,
1351
+ raycast: {
1352
+ enabled: true,
1353
+ radius: 2
1354
+ },
1355
+ physics: {
1356
+ enabled: true,
1357
+ geometry: "Cube"
1358
+ }
1359
+ });
1360
+ application.addMeshObj({
1361
+ position: {
1362
+ x: -5,
1363
+ y: 4,
1364
+ z: -14
1365
+ },
1366
+ rotation: {
1367
+ x: 0,
1368
+ y: 0,
1369
+ z: 0
1370
+ },
1371
+ rotationSpeed: {
1372
+ x: 0,
1373
+ y: 0,
1374
+ z: 0
1375
+ },
1376
+ texturesPaths: ['./res/meshes/jamb/dice.png'],
1377
+ useUVShema4x2: true,
1378
+ name: 'CubePhysics2',
1379
+ mesh: m.cube,
1380
+ raycast: {
1381
+ enabled: true,
1382
+ radius: 2
1383
+ },
1384
+ physics: {
1385
+ enabled: true,
1386
+ geometry: "Cube"
1387
+ }
1388
+ });
33
1389
  application.addMeshObj({
34
1390
  position: {
1391
+ x: 4,
1392
+ y: 8,
1393
+ z: -10
1394
+ },
1395
+ rotation: {
1396
+ x: 0,
1397
+ y: 0,
1398
+ z: 0
1399
+ },
1400
+ rotationSpeed: {
35
1401
  x: 0,
36
- y: 2,
1402
+ y: 0,
1403
+ z: 0
1404
+ },
1405
+ texturesPaths: ['./res/meshes/jamb/dice.png'],
1406
+ useUVShema4x2: true,
1407
+ name: 'CubePhysics3',
1408
+ mesh: m.cube,
1409
+ raycast: {
1410
+ enabled: true,
1411
+ radius: 2
1412
+ },
1413
+ physics: {
1414
+ enabled: true,
1415
+ geometry: "Cube"
1416
+ }
1417
+ });
1418
+ application.addMeshObj({
1419
+ position: {
1420
+ x: 3,
1421
+ y: 4,
37
1422
  z: -10
38
1423
  },
39
1424
  rotation: {
@@ -46,9 +1431,14 @@ let application = exports.application = new _world.default({
46
1431
  y: 0,
47
1432
  z: 0
48
1433
  },
49
- texturesPaths: ['./res/meshes/blender/cube.png'],
50
- name: 'CubePhysics',
1434
+ texturesPaths: ['./res/meshes/jamb/dice.png'],
1435
+ useUVShema4x2: true,
1436
+ name: 'CubePhysics4',
51
1437
  mesh: m.cube,
1438
+ raycast: {
1439
+ enabled: true,
1440
+ radius: 2
1441
+ },
52
1442
  physics: {
53
1443
  enabled: true,
54
1444
  geometry: "Cube"
@@ -56,9 +1446,38 @@ let application = exports.application = new _world.default({
56
1446
  });
57
1447
  application.addMeshObj({
58
1448
  position: {
1449
+ x: -2,
1450
+ y: 4,
1451
+ z: -13
1452
+ },
1453
+ rotation: {
59
1454
  x: 0,
60
- y: 2,
61
- z: -10
1455
+ y: 0,
1456
+ z: 0
1457
+ },
1458
+ rotationSpeed: {
1459
+ x: 0,
1460
+ y: 0,
1461
+ z: 0
1462
+ },
1463
+ texturesPaths: ['./res/meshes/jamb/dice.png'],
1464
+ useUVShema4x2: true,
1465
+ name: 'CubePhysics5',
1466
+ mesh: m.cube,
1467
+ raycast: {
1468
+ enabled: true,
1469
+ radius: 2
1470
+ },
1471
+ physics: {
1472
+ enabled: true,
1473
+ geometry: "Cube"
1474
+ }
1475
+ });
1476
+ application.addMeshObj({
1477
+ position: {
1478
+ x: -4,
1479
+ y: 6,
1480
+ z: -9
62
1481
  },
63
1482
  rotation: {
64
1483
  x: 0,
@@ -70,19 +1489,127 @@ let application = exports.application = new _world.default({
70
1489
  y: 0,
71
1490
  z: 0
72
1491
  },
73
- texturesPaths: ['./res/meshes/blender/cube.png'],
74
- name: 'SpherePhysics',
75
- mesh: m.sphere,
1492
+ texturesPaths: ['./res/meshes/jamb/dice.png'],
1493
+ useUVShema4x2: true,
1494
+ name: 'CubePhysics6',
1495
+ mesh: m.cube,
1496
+ raycast: {
1497
+ enabled: true,
1498
+ radius: 2
1499
+ },
76
1500
  physics: {
77
1501
  enabled: true,
78
- geometry: "Sphere"
1502
+ geometry: "Cube"
1503
+ }
1504
+ });
1505
+ application.TOLERANCE = 0;
1506
+ let allDiceDoneProcedure = () => {
1507
+ console.log("ALL DONE");
1508
+ application.TOLERANCE++;
1509
+ if (application.TOLERANCE >= 1) {
1510
+ removeEventListener('dice-1', dice1Click);
1511
+ removeEventListener('dice-2', dice2Click);
1512
+ removeEventListener('dice-3', dice3Click);
1513
+ removeEventListener('dice-4', dice4Click);
1514
+ removeEventListener('dice-5', dice5Click);
1515
+ removeEventListener('dice-6', dice6Click);
1516
+ console.log('FINAL >>>> ', _jamb.dices.R);
1517
+ application.TOLERANCE = 0;
1518
+ app.cameras.WASD.yaw = 0.01;
1519
+ app.cameras.WASD.pitch = -1.26;
1520
+ app.cameras.WASD.position[2] = -18;
1521
+ app.cameras.WASD.position[1] = 19;
1522
+
1523
+ // dices.STATUS = "PLACE_RESULT";
1524
+ _jamb.dices.STATUS = "SELECT_DICES_1";
1525
+ // application.dices.STATUS = "FREE_TO_PLAY";
79
1526
  }
1527
+ };
1528
+ addEventListener('all-done', allDiceDoneProcedure);
1529
+ addEventListener('FREE_TO_PLAY', () => {
1530
+ // setup againt 3d space loc
1531
+ console.info(' setup againt 3d space loc make some logic for pos ...');
1532
+ app.matrixAmmo.getBodyByName('CubePhysics1').setLinearVelocity(new Ammo.btVector3(2, 2, 12));
1533
+ app.matrixAmmo.getBodyByName('CubePhysics2').setLinearVelocity(new Ammo.btVector3(2, 2, 12));
1534
+ app.matrixAmmo.getBodyByName('CubePhysics3').setLinearVelocity(new Ammo.btVector3(2, 2, 12));
1535
+ app.matrixAmmo.getBodyByName('CubePhysics4').setLinearVelocity(new Ammo.btVector3(2, 2, 12));
1536
+ app.matrixAmmo.getBodyByName('CubePhysics5').setLinearVelocity(new Ammo.btVector3(2, 2, 12));
1537
+ app.matrixAmmo.getBodyByName('CubePhysics6').setLinearVelocity(new Ammo.btVector3(2, 2, 12));
80
1538
  });
1539
+
1540
+ // ACTIONS
1541
+ let dice1Click = e => {
1542
+ // console.info('DICE 1', e.detail)
1543
+ _jamb.dices.R[e.detail.cubeId] = '1';
1544
+ _jamb.dices.checkAll();
1545
+ };
1546
+ // addEventListener('dice-1', dice1Click)
1547
+
1548
+ let dice2Click = e => {
1549
+ // console.info('DICE 2', e.detail)
1550
+ _jamb.dices.R[e.detail.cubeId] = '2';
1551
+ _jamb.dices.checkAll();
1552
+ };
1553
+ // addEventListener('dice-2', dice2Click)
1554
+
1555
+ let dice3Click = e => {
1556
+ // console.info('DICE 3', e.detail)
1557
+ _jamb.dices.R[e.detail.cubeId] = '3';
1558
+ _jamb.dices.checkAll();
1559
+ };
1560
+ // addEventListener('dice-3', dice3Click)
1561
+
1562
+ let dice4Click = e => {
1563
+ // console.info('DICE 4', e.detail)
1564
+ _jamb.dices.R[e.detail.cubeId] = '4';
1565
+ _jamb.dices.checkAll();
1566
+ };
1567
+ // addEventListener('dice-4', dice4Click)
1568
+
1569
+ let dice5Click = e => {
1570
+ // console.info('DICE 5', e.detail)
1571
+ _jamb.dices.R[e.detail.cubeId] = '5';
1572
+ _jamb.dices.checkAll();
1573
+ };
1574
+ // addEventListener('dice-5', dice5Click)
1575
+
1576
+ let dice6Click = e => {
1577
+ // console.info('DICE 6', e.detail)
1578
+ _jamb.dices.R[e.detail.cubeId] = '6';
1579
+ _jamb.dices.checkAll();
1580
+ };
1581
+ // addEventListener('dice-6', dice6Click)
1582
+
1583
+ let rollProcedure = () => {
1584
+ if (_jamb.dices.STATUS == "FREE_TO_PLAY") {
1585
+ app.matrixSounds.play('start');
1586
+ _jamb.dices.STATUS = "IN_PLAY";
1587
+ addEventListener('dice-1', dice1Click);
1588
+ addEventListener('dice-2', dice2Click);
1589
+ addEventListener('dice-3', dice3Click);
1590
+ addEventListener('dice-4', dice4Click);
1591
+ addEventListener('dice-5', dice5Click);
1592
+ addEventListener('dice-6', dice6Click);
1593
+ function shootDice(x) {
1594
+ setTimeout(() => {
1595
+ app.matrixAmmo.getBodyByName(`CubePhysics${x}`).setAngularVelocity(new Ammo.btVector3((0, _utils.randomFloatFromTo)(3, 12), 9, 9));
1596
+ app.matrixAmmo.getBodyByName(`CubePhysics${x}`).setLinearVelocity(new Ammo.btVector3((0, _utils.randomFloatFromTo)(-5, 5), 15, -20));
1597
+ }, 200 * x);
1598
+ }
1599
+ for (var x = 1; x < 7; x++) {
1600
+ shootDice(x);
1601
+ }
1602
+ }
1603
+ };
1604
+ addEventListener('DICE.ROLL', rollProcedure);
1605
+ app.ROLL = () => {
1606
+ dispatchEvent(new CustomEvent('DICE.ROLL', {}));
1607
+ };
81
1608
  }
82
1609
  });
83
1610
  window.app = application;
84
1611
 
85
- },{"./src/engine/loader-obj.js":6,"./src/engine/utils.js":10,"./src/world.js":16}],2:[function(require,module,exports){
1612
+ },{"./examples/games/jamb/jamb.js":1,"./src/engine/loader-obj.js":7,"./src/engine/raycast.js":11,"./src/engine/utils.js":12,"./src/sounds/sounds.js":19,"./src/world.js":20}],3:[function(require,module,exports){
86
1613
  "use strict";
87
1614
 
88
1615
  Object.defineProperty(exports, "__esModule", {
@@ -5429,7 +6956,7 @@ function setDefaultType(ctor) {
5429
6956
  setDefaultType$1(ctor);
5430
6957
  }
5431
6958
 
5432
- },{}],3:[function(require,module,exports){
6959
+ },{}],4:[function(require,module,exports){
5433
6960
  "use strict";
5434
6961
 
5435
6962
  Object.defineProperty(exports, "__esModule", {
@@ -5463,6 +6990,14 @@ class MEBall {
5463
6990
  normalOffset: 3 * 4,
5464
6991
  uvOffset: 6 * 4
5465
6992
  };
6993
+ if (typeof o.raycast === 'undefined') {
6994
+ this.raycast = {
6995
+ enabled: false,
6996
+ radius: 2
6997
+ };
6998
+ } else {
6999
+ this.raycast = o.raycast;
7000
+ }
5466
7001
  this.texturesPaths = [];
5467
7002
  o.texturesPaths.forEach(t => {
5468
7003
  this.texturesPaths.push(t);
@@ -5542,7 +7077,7 @@ class MEBall {
5542
7077
  asteroidCount: 15
5543
7078
  };
5544
7079
  this.loadTex0(this.texturesPaths, device).then(() => {
5545
- this.loadTex1(device).then(() => {
7080
+ this.loadTex1(this.texturesPaths, device).then(() => {
5546
7081
  this.sampler = device.createSampler({
5547
7082
  magFilter: 'linear',
5548
7083
  minFilter: 'linear'
@@ -5697,9 +7232,9 @@ class MEBall {
5697
7232
  _wgpuMatrix.mat4.multiply(this.projectionMatrix, viewMatrix, this.modelViewProjectionMatrix);
5698
7233
  return this.modelViewProjectionMatrix;
5699
7234
  }
5700
- async loadTex1(device) {
7235
+ async loadTex1(texPaths, device) {
5701
7236
  return new Promise(async resolve => {
5702
- const response = await fetch('./res/textures/tex1.jpg');
7237
+ const response = await fetch(texPaths[0]);
5703
7238
  const imageBitmap = await createImageBitmap(await response.blob());
5704
7239
  this.moonTexture = device.createTexture({
5705
7240
  size: [imageBitmap.width, imageBitmap.height, 1],
@@ -5836,7 +7371,7 @@ class MEBall {
5836
7371
  }
5837
7372
  exports.default = MEBall;
5838
7373
 
5839
- },{"../shaders/shaders":13,"./engine":5,"./matrix-class":7,"wgpu-matrix":2}],4:[function(require,module,exports){
7374
+ },{"../shaders/shaders":16,"./engine":6,"./matrix-class":8,"wgpu-matrix":3}],5:[function(require,module,exports){
5840
7375
  "use strict";
5841
7376
 
5842
7377
  Object.defineProperty(exports, "__esModule", {
@@ -5871,6 +7406,17 @@ class MECube {
5871
7406
  code: _shaders.UNLIT_SHADER
5872
7407
  });
5873
7408
  this.texturesPaths = [];
7409
+ if (typeof o.raycast === 'undefined') {
7410
+ this.raycast = {
7411
+ enabled: false,
7412
+ radius: 2
7413
+ };
7414
+ } else {
7415
+ this.raycast = o.raycast;
7416
+ }
7417
+
7418
+ // useUVShema4x2 pass this from top !
7419
+
5874
7420
  o.texturesPaths.forEach(t => {
5875
7421
  this.texturesPaths.push(t);
5876
7422
  });
@@ -5951,15 +7497,13 @@ class MECube {
5951
7497
  asteroidCount: 15
5952
7498
  };
5953
7499
  this.loadTex0(this.texturesPaths, device).then(() => {
5954
- this.loadTex1(device).then(() => {
7500
+ this.loadTex1(this.texturesPaths, device).then(() => {
5955
7501
  this.sampler = device.createSampler({
5956
7502
  magFilter: 'linear',
5957
7503
  minFilter: 'linear'
5958
7504
  });
5959
7505
  this.transform = _wgpuMatrix.mat4.create();
5960
7506
  _wgpuMatrix.mat4.identity(this.transform);
5961
-
5962
- // Create one large central planet surrounded by a large ring of asteroids
5963
7507
  this.planet = this.createGeometry({
5964
7508
  scale: this.scale,
5965
7509
  useUVShema4x2: false
@@ -6096,6 +7640,13 @@ class MECube {
6096
7640
  });
6097
7641
  return bindGroup;
6098
7642
  }
7643
+
7644
+ // TEST
7645
+ getViewMatrix() {
7646
+ const camera = this.cameras[this.mainCameraParams.type];
7647
+ const viewMatrix = camera.update(deltaTime, this.inputHandler());
7648
+ return viewMatrix;
7649
+ }
6099
7650
  getTransformationMatrix(pos) {
6100
7651
  const now = Date.now();
6101
7652
  const deltaTime = (now - this.lastFrameMS) / this.mainCameraParams.responseCoef;
@@ -6111,9 +7662,9 @@ class MECube {
6111
7662
  _wgpuMatrix.mat4.multiply(this.projectionMatrix, viewMatrix, this.modelViewProjectionMatrix);
6112
7663
  return this.modelViewProjectionMatrix;
6113
7664
  }
6114
- async loadTex1(device) {
7665
+ async loadTex1(textPath, device) {
6115
7666
  return new Promise(async resolve => {
6116
- const response = await fetch('./res/textures/tex1.jpg');
7667
+ const response = await fetch(textPath[0]);
6117
7668
  const imageBitmap = await createImageBitmap(await response.blob());
6118
7669
  this.moonTexture = device.createTexture({
6119
7670
  size: [imageBitmap.width, imageBitmap.height, 1],
@@ -6245,7 +7796,7 @@ class MECube {
6245
7796
  }
6246
7797
  exports.default = MECube;
6247
7798
 
6248
- },{"../shaders/shaders":13,"./engine":5,"./matrix-class":7,"wgpu-matrix":2}],5:[function(require,module,exports){
7799
+ },{"../shaders/shaders":16,"./engine":6,"./matrix-class":8,"wgpu-matrix":3}],6:[function(require,module,exports){
6249
7800
  "use strict";
6250
7801
 
6251
7802
  Object.defineProperty(exports, "__esModule", {
@@ -6416,6 +7967,8 @@ class WASDCamera extends CameraBase {
6416
7967
 
6417
7968
  // Reconstruct the camera's rotation, and store into the camera matrix.
6418
7969
  super.matrix = _wgpuMatrix.mat4.rotateX(_wgpuMatrix.mat4.rotationY(this.yaw), this.pitch);
7970
+ // super.matrix = mat4.rotateX(mat4.rotationY(this.yaw), -this.pitch);
7971
+ // super.matrix = mat4.rotateY(mat4.rotateX(this.pitch), this.yaw);
6419
7972
 
6420
7973
  // Calculate the new target velocity
6421
7974
  const digital = input.digital;
@@ -6583,9 +8136,7 @@ function lerp(a, b, s) {
6583
8136
  return _wgpuMatrix.vec3.addScaled(a, _wgpuMatrix.vec3.sub(b, a), s);
6584
8137
  }
6585
8138
 
6586
- // IMPUT
6587
-
6588
- // // Input holds as snapshot of input state
8139
+ // Input holds as snapshot of input state
6589
8140
  // export default interface Input {
6590
8141
  // // Digital input (e.g keyboard state)
6591
8142
  // readonly digital: {
@@ -6604,10 +8155,8 @@ function lerp(a, b, s) {
6604
8155
  // readonly touching: boolean;
6605
8156
  // };
6606
8157
  // }
6607
-
6608
8158
  // InputHandler is a function that when called, returns the current Input state.
6609
8159
  // export type InputHandler = () => Input;
6610
-
6611
8160
  // createInputHandler returns an InputHandler by attaching event handlers to the window and canvas.
6612
8161
  function createInputHandler(window, canvas) {
6613
8162
  let digital = {
@@ -6707,7 +8256,7 @@ function createInputHandler(window, canvas) {
6707
8256
  };
6708
8257
  }
6709
8258
 
6710
- },{"./utils":10,"wgpu-matrix":2}],6:[function(require,module,exports){
8259
+ },{"./utils":12,"wgpu-matrix":3}],7:[function(require,module,exports){
6711
8260
  "use strict";
6712
8261
 
6713
8262
  Object.defineProperty(exports, "__esModule", {
@@ -6721,6 +8270,9 @@ exports.play = play;
6721
8270
  * information can then be used later on when creating your VBOs. See
6722
8271
  * OBJ.initMeshBuffers for an example of how to use the newly created Mesh
6723
8272
  *
8273
+ * Nidza Note:
8274
+ * There is difference from me source obj loader and me-wgpu obj loader
8275
+ * Here we need scele in comp x,y,z because we use also primitive [cube, sphere etc...]
6724
8276
  * @class Mesh
6725
8277
  * @constructor
6726
8278
  *
@@ -6737,7 +8289,7 @@ class constructMesh {
6737
8289
  this.create(this.objectData, this.inputArg);
6738
8290
  };
6739
8291
  this.updateBuffers = () => {
6740
- this.inputArg.scale = 1;
8292
+ this.inputArg.scale = [0.1, 0.1, 0.1];
6741
8293
  this.create(this.objectData, this.inputArg);
6742
8294
  };
6743
8295
  }
@@ -6894,9 +8446,9 @@ class constructMesh {
6894
8446
  This same process is repeated for verts and textures.
6895
8447
  */
6896
8448
  // vertex position
6897
- unpacked.verts.push(+verts[(vertex[0] - 1) * 3 + initOrientation[0]] * inputArg.scale);
6898
- unpacked.verts.push(+verts[(vertex[0] - 1) * 3 + initOrientation[1]] * inputArg.scale);
6899
- unpacked.verts.push(+verts[(vertex[0] - 1) * 3 + initOrientation[2]] * inputArg.scale);
8449
+ unpacked.verts.push(+verts[(vertex[0] - 1) * 3 + initOrientation[0]] * inputArg.scale[0]);
8450
+ unpacked.verts.push(+verts[(vertex[0] - 1) * 3 + initOrientation[1]] * inputArg.scale[1]);
8451
+ unpacked.verts.push(+verts[(vertex[0] - 1) * 3 + initOrientation[2]] * inputArg.scale[2]);
6900
8452
 
6901
8453
  // vertex textures
6902
8454
  if (textures.length) {
@@ -6971,11 +8523,11 @@ var downloadMeshes = function (nameAndURLs, completionCallback, inputArg) {
6971
8523
  // a new object is created. this will be passed into the completionCallback
6972
8524
  if (typeof inputArg === 'undefined') {
6973
8525
  var inputArg = {
6974
- scale: 1,
8526
+ scale: [0.1, 0.1, 0.1],
6975
8527
  swap: [null]
6976
8528
  };
6977
8529
  }
6978
- if (typeof inputArg.scale === 'undefined') inputArg.scale = 0.1;
8530
+ if (typeof inputArg.scale === 'undefined') inputArg.scale = [0.1, 0.1, 0.1];
6979
8531
  if (typeof inputArg.swap === 'undefined') inputArg.swap = [null];
6980
8532
  var meshes = {};
6981
8533
 
@@ -7171,7 +8723,7 @@ function play(nameAni) {
7171
8723
  this.animation.currentAni = this.animation.anims[this.animation.anims.active].from;
7172
8724
  }
7173
8725
 
7174
- },{}],7:[function(require,module,exports){
8726
+ },{}],8:[function(require,module,exports){
7175
8727
  "use strict";
7176
8728
 
7177
8729
  Object.defineProperty(exports, "__esModule", {
@@ -7188,21 +8740,22 @@ var _utils = require("./utils");
7188
8740
 
7189
8741
  class Position {
7190
8742
  constructor(x, y, z) {
8743
+ // console.log('TEST TYTPOF ', x)
7191
8744
  // Not in use for nwo this is from matrix-engine project [nameUniq]
7192
8745
  this.nameUniq = null;
7193
8746
  if (typeof x == 'undefined') x = 0;
7194
8747
  if (typeof y == 'undefined') y = 0;
7195
8748
  if (typeof z == 'undefined') z = 0;
7196
- this.x = x;
7197
- this.y = y;
7198
- this.z = z;
8749
+ this.x = parseFloat(x);
8750
+ this.y = parseFloat(y);
8751
+ this.z = parseFloat(z);
7199
8752
  this.velY = 0;
7200
8753
  this.velX = 0;
7201
8754
  this.velZ = 0;
7202
8755
  this.inMove = false;
7203
- this.targetX = x;
7204
- this.targetY = y;
7205
- this.targetZ = z;
8756
+ this.targetX = parseFloat(x);
8757
+ this.targetY = parseFloat(y);
8758
+ this.targetZ = parseFloat(z);
7206
8759
  this.thrust = 0.01;
7207
8760
  return this;
7208
8761
  }
@@ -7215,36 +8768,36 @@ class Position {
7215
8768
  }
7216
8769
  translateByX(x) {
7217
8770
  this.inMove = true;
7218
- this.targetX = x;
8771
+ this.targetX = parseFloat(x);
7219
8772
  }
7220
8773
  translateByY(y) {
7221
8774
  this.inMove = true;
7222
- this.targetY = y;
8775
+ this.targetY = parseFloat(y);
7223
8776
  }
7224
8777
  translateByZ(z) {
7225
8778
  this.inMove = true;
7226
- this.targetZ = z;
8779
+ this.targetZ = parseFloat(z);
7227
8780
  }
7228
8781
  translateByXY(x, y) {
7229
8782
  this.inMove = true;
7230
- this.targetX = x;
7231
- this.targetY = y;
8783
+ this.targetX = parseFloat(x);
8784
+ this.targetY = parseFloat(y);
7232
8785
  }
7233
8786
  translateByXZ(x, z) {
7234
8787
  this.inMove = true;
7235
- this.targetX = x;
7236
- this.targetZ = z;
8788
+ this.targetX = parseFloat(x);
8789
+ this.targetZ = parseFloat(z);
7237
8790
  }
7238
8791
  translateByYZ(y, z) {
7239
8792
  this.inMove = true;
7240
- this.targetY = y;
7241
- this.targetZ = z;
8793
+ this.targetY = parseFloat(y);
8794
+ this.targetZ = parseFloat(z);
7242
8795
  }
7243
8796
  onTargetPositionReach() {}
7244
8797
  update() {
7245
- var tx = this.targetX - this.x,
7246
- ty = this.targetY - this.y,
7247
- tz = this.targetZ - this.z,
8798
+ var tx = parseFloat(this.targetX) - parseFloat(this.x),
8799
+ ty = parseFloat(this.targetY) - parseFloat(this.y),
8800
+ tz = parseFloat(this.targetZ) - parseFloat(this.z),
7248
8801
  dist = Math.sqrt(tx * tx + ty * ty + tz * tz);
7249
8802
  this.velX = tx / dist * this.thrust;
7250
8803
  this.velY = ty / dist * this.thrust;
@@ -7276,7 +8829,7 @@ class Position {
7276
8829
  }
7277
8830
  }
7278
8831
  get worldLocation() {
7279
- return [this.x, this.y, this.z];
8832
+ return [parseFloat(this.x), parseFloat(this.y), parseFloat(this.z)];
7280
8833
  }
7281
8834
  SetX(newx, em) {
7282
8835
  this.x = newx;
@@ -7311,6 +8864,15 @@ class Position {
7311
8864
  // netObjId: this.nameUniq,
7312
8865
  // });
7313
8866
  }
8867
+ get X() {
8868
+ return parseFloat(this.x);
8869
+ }
8870
+ get Y() {
8871
+ return parseFloat(this.y);
8872
+ }
8873
+ get Z() {
8874
+ return parseFloat(this.z);
8875
+ }
7314
8876
  setPosition(newx, newy, newz) {
7315
8877
  this.x = newx;
7316
8878
  this.y = newy;
@@ -7353,6 +8915,23 @@ class Rotation {
7353
8915
  // not in use good for exstend logic
7354
8916
  this.matrixRotation = null;
7355
8917
  }
8918
+ toDegree() {
8919
+ /*
8920
+ heading = atan2(y * sin(angle)- x * z * (1 - cos(angle)) , 1 - (y2 + z2 ) * (1 - cos(angle)))
8921
+ attitude = asin(x * y * (1 - cos(angle)) + z * sin(angle))
8922
+ bank = atan2(x * sin(angle)-y * z * (1 - cos(angle)) , 1 - (x2 + z2) * (1 - cos(angle)))
8923
+ */
8924
+ return [(0, _utils.radToDeg)(this.axis.x), (0, _utils.radToDeg)(this.axis.y), (0, _utils.radToDeg)(this.axis.z)];
8925
+ }
8926
+ toDegreeX() {
8927
+ return Math.cos((0, _utils.radToDeg)(this.axis.x) / 2);
8928
+ }
8929
+ toDegreeY() {
8930
+ return Math.cos((0, _utils.radToDeg)(this.axis.z) / 2);
8931
+ }
8932
+ toDegreeZ() {
8933
+ return Math.cos((0, _utils.radToDeg)(this.axis.y) / 2);
8934
+ }
7356
8935
  getRotX() {
7357
8936
  if (this.rotationSpeed.x == 0) {
7358
8937
  return (0, _utils.degToRad)(this.x);
@@ -7380,7 +8959,7 @@ class Rotation {
7380
8959
  }
7381
8960
  exports.Rotation = Rotation;
7382
8961
 
7383
- },{"./utils":10}],8:[function(require,module,exports){
8962
+ },{"./utils":12}],9:[function(require,module,exports){
7384
8963
  "use strict";
7385
8964
 
7386
8965
  Object.defineProperty(exports, "__esModule", {
@@ -7394,8 +8973,19 @@ var _vertexShadow = require("../shaders/vertexShadow.wgsl");
7394
8973
  var _fragment = require("../shaders/fragment.wgsl");
7395
8974
  var _vertex = require("../shaders/vertex.wgsl");
7396
8975
  var _utils = require("./utils");
8976
+ var _raycast = require("./raycast");
7397
8977
  class MEMeshObj {
7398
8978
  constructor(canvas, device, context, o) {
8979
+ if (typeof o.name === 'undefined') o.name = (0, _utils.genName)(9);
8980
+ if (typeof o.raycast === 'undefined') {
8981
+ this.raycast = {
8982
+ enabled: false,
8983
+ radius: 2
8984
+ };
8985
+ } else {
8986
+ this.raycast = o.raycast;
8987
+ }
8988
+ this.name = o.name;
7399
8989
  this.done = false;
7400
8990
  this.device = device;
7401
8991
  this.context = context;
@@ -7404,13 +8994,16 @@ class MEMeshObj {
7404
8994
  // Mesh stuff
7405
8995
  this.mesh = o.mesh;
7406
8996
  this.mesh.uvs = this.mesh.textures;
7407
- console.log(`%c Mesh loaded: ${o.name}`, _utils.LOG_INFO);
8997
+ console.log(`%c Mesh loaded: ${o.name}`, _utils.LOG_FUNNY_SMALL);
7408
8998
  this.inputHandler = (0, _engine.createInputHandler)(window, canvas);
7409
8999
  this.cameras = o.cameras;
7410
9000
  this.mainCameraParams = {
7411
9001
  type: o.mainCameraParams.type,
7412
9002
  responseCoef: o.mainCameraParams.responseCoef
7413
9003
  };
9004
+
9005
+ // touchCoordinate.enabled = true;
9006
+
7414
9007
  this.lastFrameMS = 0;
7415
9008
  this.texturesPaths = [];
7416
9009
  o.texturesPaths.forEach(t => {
@@ -7722,35 +9315,37 @@ class MEMeshObj {
7722
9315
  this.viewMatrix = camera.update(deltaTime, this.inputHandler());
7723
9316
  _wgpuMatrix.mat4.translate(this.viewMatrix, _wgpuMatrix.vec3.fromValues(pos.x, pos.y, pos.z), this.viewMatrix);
7724
9317
  _wgpuMatrix.mat4.rotate(this.viewMatrix, _wgpuMatrix.vec3.fromValues(this.rotation.axis.x, this.rotation.axis.y, this.rotation.axis.z), (0, _utils.degToRad)(this.rotation.angle), this.viewMatrix);
7725
- // mat4.rotateX(this.viewMatrix, this.rotation.getRotX(), this.viewMatrix);
7726
- // mat4.rotateY(this.viewMatrix, this.rotation.getRotY(), this.viewMatrix);
7727
- // mat4.rotateZ(this.viewMatrix, this.rotation.getRotZ(), this.viewMatrix);
9318
+
9319
+ // console.info('angle: ', this.rotation.angle, ' axis ' , this.rotation.axis.x, ' , ', this.rotation.axis.y, ' , ', this.rotation.axis.z)
7728
9320
  _wgpuMatrix.mat4.multiply(this.projectionMatrix, this.viewMatrix, this.modelViewProjectionMatrix);
7729
9321
  return this.modelViewProjectionMatrix;
7730
9322
  };
7731
9323
  this.upVector = _wgpuMatrix.vec3.fromValues(0, 1, 0);
7732
9324
  this.origin = _wgpuMatrix.vec3.fromValues(0, 0, 0);
7733
- const lightPosition = _wgpuMatrix.vec3.fromValues(50, 100, -100);
7734
- const lightViewMatrix = _wgpuMatrix.mat4.lookAt(lightPosition, this.origin, this.upVector);
9325
+ this.lightPosition = _wgpuMatrix.vec3.fromValues(0, 0, 0);
9326
+ this.lightViewMatrix = _wgpuMatrix.mat4.lookAt(this.lightPosition, this.origin, this.upVector);
7735
9327
  const lightProjectionMatrix = _wgpuMatrix.mat4.create();
9328
+ var myLMargin = 100;
7736
9329
  {
7737
- const left = -80;
7738
- const right = 80;
7739
- const bottom = -80;
7740
- const top = 80;
9330
+ const left = -myLMargin;
9331
+ const right = myLMargin;
9332
+ const bottom = -myLMargin;
9333
+ const top = myLMargin;
7741
9334
  const near = -200;
7742
9335
  const far = 300;
7743
9336
  _wgpuMatrix.mat4.ortho(left, right, bottom, top, near, far, lightProjectionMatrix);
9337
+ // test
9338
+ // mat4.ortho(right, left, top, bottom, near, far, lightProjectionMatrix);
7744
9339
  }
7745
- const lightViewProjMatrix = _wgpuMatrix.mat4.multiply(lightProjectionMatrix, lightViewMatrix);
9340
+ this.lightViewProjMatrix = _wgpuMatrix.mat4.multiply(lightProjectionMatrix, this.lightViewMatrix);
7746
9341
 
7747
9342
  // looks like affect on transformations for now const 0
7748
9343
  const modelMatrix = _wgpuMatrix.mat4.translation([0, 0, 0]);
7749
9344
  // The camera/light aren't moving, so write them into buffers now.
7750
9345
  {
7751
- const lightMatrixData = lightViewProjMatrix; // as Float32Array;
9346
+ const lightMatrixData = this.lightViewProjMatrix; // as Float32Array;
7752
9347
  this.device.queue.writeBuffer(this.sceneUniformBuffer, 0, lightMatrixData.buffer, lightMatrixData.byteOffset, lightMatrixData.byteLength);
7753
- const lightData = lightPosition;
9348
+ const lightData = this.lightPosition;
7754
9349
  this.device.queue.writeBuffer(this.sceneUniformBuffer, 128, lightData.buffer, lightData.byteOffset, lightData.byteLength);
7755
9350
  const modelData = modelMatrix;
7756
9351
  this.device.queue.writeBuffer(this.modelUniformBuffer, 0, modelData.buffer, modelData.byteOffset, modelData.byteLength);
@@ -7767,6 +9362,48 @@ class MEMeshObj {
7767
9362
  this.done = true;
7768
9363
  });
7769
9364
  }
9365
+ updateLightsTest = position => {
9366
+ console.log('Update light position.', position);
9367
+ this.lightPosition = _wgpuMatrix.vec3.fromValues(position[0], position[1], position[2]);
9368
+ this.lightViewMatrix = _wgpuMatrix.mat4.lookAt(this.lightPosition, this.origin, this.upVector);
9369
+ const lightProjectionMatrix = _wgpuMatrix.mat4.create();
9370
+ {
9371
+ const left = -80;
9372
+ const right = 80;
9373
+ const bottom = -80;
9374
+ const top = 80;
9375
+ const near = -200;
9376
+ const far = 300;
9377
+ _wgpuMatrix.mat4.ortho(left, right, bottom, top, near, far, lightProjectionMatrix);
9378
+ }
9379
+ this.lightViewProjMatrix = _wgpuMatrix.mat4.multiply(lightProjectionMatrix, this.lightViewMatrix);
9380
+
9381
+ // looks like affect on transformations for now const 0
9382
+ const modelMatrix = _wgpuMatrix.mat4.translation([0, 0, 0]);
9383
+ // The camera/light aren't moving, so write them into buffers now.
9384
+ {
9385
+ const lightMatrixData = this.lightViewProjMatrix; // as Float32Array;
9386
+ this.device.queue.writeBuffer(this.sceneUniformBuffer, 0,
9387
+ // 0 ori
9388
+ lightMatrixData.buffer, lightMatrixData.byteOffset, lightMatrixData.byteLength);
9389
+ const lightData = this.lightPosition;
9390
+ this.device.queue.writeBuffer(this.sceneUniformBuffer, 256, lightData.buffer, lightData.byteOffset, lightData.byteLength);
9391
+ const modelData = modelMatrix;
9392
+ this.device.queue.writeBuffer(this.modelUniformBuffer, 0, modelData.buffer, modelData.byteOffset, modelData.byteLength);
9393
+ }
9394
+ this.shadowPassDescriptor = {
9395
+ colorAttachments: [],
9396
+ depthStencilAttachment: {
9397
+ view: this.shadowDepthTextureView,
9398
+ depthClearValue: 1.0,
9399
+ // ori 1.0
9400
+ depthLoadOp: 'clear',
9401
+ depthStoreOp: 'store'
9402
+ }
9403
+ };
9404
+
9405
+ ///////////////////////
9406
+ };
7770
9407
  async loadTex0(texturesPaths, device) {
7771
9408
  this.sampler = device.createSampler({
7772
9409
  magFilter: 'linear',
@@ -7802,6 +9439,12 @@ class MEMeshObj {
7802
9439
  renderPass.setVertexBuffer(2, this.vertexTexCoordsBuffer);
7803
9440
  renderPass.setIndexBuffer(this.indexBuffer, 'uint16');
7804
9441
  renderPass.drawIndexed(this.indexCount);
9442
+
9443
+ // test ray
9444
+
9445
+ // try{ OLD
9446
+ // if(this.raycast.enabled == true) checkingRay(this)
9447
+ // } catch(e) {}
7805
9448
  };
7806
9449
  drawShadows = shadowPass => {
7807
9450
  shadowPass.setBindGroup(0, this.sceneBindGroupForShadow);
@@ -7815,7 +9458,7 @@ class MEMeshObj {
7815
9458
  }
7816
9459
  exports.default = MEMeshObj;
7817
9460
 
7818
- },{"../shaders/fragment.wgsl":12,"../shaders/vertex.wgsl":14,"../shaders/vertexShadow.wgsl":15,"./engine":5,"./matrix-class":7,"./utils":10,"wgpu-matrix":2}],9:[function(require,module,exports){
9461
+ },{"../shaders/fragment.wgsl":15,"../shaders/vertex.wgsl":17,"../shaders/vertexShadow.wgsl":18,"./engine":6,"./matrix-class":8,"./raycast":11,"./utils":12,"wgpu-matrix":3}],10:[function(require,module,exports){
7819
9462
  "use strict";
7820
9463
 
7821
9464
  Object.defineProperty(exports, "__esModule", {
@@ -8213,30 +9856,134 @@ class MEMesh {
8213
9856
  }
8214
9857
  exports.default = MEMesh;
8215
9858
 
8216
- },{"../shaders/fragment.wgsl":12,"../shaders/vertex.wgsl":14,"../shaders/vertexShadow.wgsl":15,"./engine":5,"./loader-obj":6,"./matrix-class":7,"wgpu-matrix":2}],10:[function(require,module,exports){
9859
+ },{"../shaders/fragment.wgsl":15,"../shaders/vertex.wgsl":17,"../shaders/vertexShadow.wgsl":18,"./engine":6,"./loader-obj":7,"./matrix-class":8,"wgpu-matrix":3}],11:[function(require,module,exports){
8217
9860
  "use strict";
8218
9861
 
8219
9862
  Object.defineProperty(exports, "__esModule", {
8220
9863
  value: true
8221
9864
  });
8222
- exports.LOG_WARN = exports.LOG_MATRIX = exports.LOG_INFO = exports.LOG_FUNNY = void 0;
9865
+ exports.addRaycastListener = addRaycastListener;
9866
+ exports.getRayFromMouse = getRayFromMouse;
9867
+ exports.rayIntersectsSphere = rayIntersectsSphere;
9868
+ exports.touchCoordinate = void 0;
9869
+ var _wgpuMatrix = require("wgpu-matrix");
9870
+ /**
9871
+ * @author Nikola Lukic
9872
+ * @email zlatnaspirala@gmail.com
9873
+ * @site https://maximumroulette.com
9874
+ * @Licence GPL v3
9875
+ * @credits chatgpt used for this script adaptation.
9876
+ * @Note matrix-engine-wgpu adaptation test
9877
+ * default for now:
9878
+ * app.cameras['WASD']
9879
+ * Only tested for WASD type of camera.
9880
+ * app is global - will be fixed in future
9881
+ */
9882
+
9883
+ let rayHitEvent;
9884
+ let touchCoordinate = exports.touchCoordinate = {
9885
+ enabled: false,
9886
+ x: 0,
9887
+ y: 0,
9888
+ stopOnFirstDetectedHit: false
9889
+ };
9890
+ function multiplyMatrixVector(matrix, vector) {
9891
+ return _wgpuMatrix.vec4.transformMat4(vector, matrix);
9892
+ }
9893
+ function getRayFromMouse(event, canvas, camera) {
9894
+ const rect = canvas.getBoundingClientRect();
9895
+ let x = (event.clientX - rect.left) / rect.width * 2 - 1;
9896
+ let y = (event.clientY - rect.top) / rect.height * 2 - 1;
9897
+ // simple invert
9898
+ x = -x;
9899
+ y = -y;
9900
+ const fov = Math.PI / 4;
9901
+ const aspect = canvas.width / canvas.height;
9902
+ const near = 0.1;
9903
+ const far = 1000;
9904
+ camera.projectionMatrix = _wgpuMatrix.mat4.perspective(2 * Math.PI / 5, aspect, 1, 1000.0);
9905
+ const invProjection = _wgpuMatrix.mat4.inverse(camera.projectionMatrix);
9906
+
9907
+ // const correctedView = mat4.clone(camera.view_);
9908
+ // correctedView[2] *= -1;
9909
+ // correctedView[6] *= -1;
9910
+ // correctedView[10] *= -1;
9911
+ // const invView = mat4.inverse(correctedView);
9912
+
9913
+ const invView = _wgpuMatrix.mat4.inverse(camera.view);
9914
+ const ndc = [x, y, 1, 1];
9915
+ let worldPos = multiplyMatrixVector(invProjection, ndc);
9916
+ worldPos = multiplyMatrixVector(invView, worldPos);
9917
+ let world;
9918
+ if (worldPos[3] !== 0) {
9919
+ world = [worldPos[0] / worldPos[3], worldPos[2] / worldPos[3], worldPos[1] / worldPos[3]];
9920
+ } else {
9921
+ console.log("[raycaster]special case 0.");
9922
+ world = [worldPos[0], worldPos[1], worldPos[2]];
9923
+ }
9924
+ const rayOrigin = [camera.position[0], camera.position[1], camera.position[2]];
9925
+ const rayDirection = _wgpuMatrix.vec3.normalize(_wgpuMatrix.vec3.subtract(world, rayOrigin));
9926
+ rayDirection[2] = -rayDirection[2];
9927
+ return {
9928
+ rayOrigin,
9929
+ rayDirection
9930
+ };
9931
+ }
9932
+ function rayIntersectsSphere(rayOrigin, rayDirection, sphereCenter, sphereRadius) {
9933
+ const pos = [sphereCenter.x, sphereCenter.y, sphereCenter.z];
9934
+ const oc = _wgpuMatrix.vec3.subtract(rayOrigin, pos);
9935
+ const a = _wgpuMatrix.vec3.dot(rayDirection, rayDirection);
9936
+ const b = 2.0 * _wgpuMatrix.vec3.dot(oc, rayDirection);
9937
+ const c = _wgpuMatrix.vec3.dot(oc, oc) - sphereRadius * sphereRadius;
9938
+ const discriminant = b * b - 4 * a * c;
9939
+ return discriminant > 0;
9940
+ }
9941
+ function addRaycastListener() {
9942
+ window.addEventListener('click', event => {
9943
+ let canvas = document.getElementsByTagName('canvas')[0];
9944
+ let camera = app.cameras.WASD;
9945
+ const {
9946
+ rayOrigin,
9947
+ rayDirection
9948
+ } = getRayFromMouse(event, canvas, camera);
9949
+ for (const object of app.mainRenderBundle) {
9950
+ if (rayIntersectsSphere(rayOrigin, rayDirection, object.position, object.raycast.radius)) {
9951
+ // console.log('Object clicked:', object.name);
9952
+ // Just like in matrix-engine webGL version "ray.hit.event"
9953
+ dispatchEvent(new CustomEvent('ray.hit.event', {
9954
+ detail: {
9955
+ hitObject: object
9956
+ }
9957
+ }));
9958
+ }
9959
+ }
9960
+ });
9961
+ }
9962
+
9963
+ },{"wgpu-matrix":3}],12:[function(require,module,exports){
9964
+ "use strict";
9965
+
9966
+ Object.defineProperty(exports, "__esModule", {
9967
+ value: true
9968
+ });
9969
+ exports.LOG_WARN = exports.LOG_MATRIX = exports.LOG_INFO = exports.LOG_FUNNY_SMALL = exports.LOG_FUNNY = void 0;
8223
9970
  exports.ORBIT = ORBIT;
8224
9971
  exports.ORBIT_FROM_ARRAY = ORBIT_FROM_ARRAY;
8225
9972
  exports.OSCILLATOR = OSCILLATOR;
8226
- exports.QueryString = void 0;
8227
9973
  exports.SWITCHER = SWITCHER;
8228
9974
  exports.byId = void 0;
8229
9975
  exports.createAppEvent = createAppEvent;
8230
9976
  exports.degToRad = degToRad;
9977
+ exports.genName = genName;
8231
9978
  exports.getAxisRot = getAxisRot;
8232
9979
  exports.getAxisRot2 = getAxisRot2;
8233
9980
  exports.getAxisRot3 = getAxisRot3;
8234
- exports.mat4 = void 0;
9981
+ exports.mb = exports.mat4 = void 0;
8235
9982
  exports.quaternion_rotation_matrix = quaternion_rotation_matrix;
8236
9983
  exports.radToDeg = radToDeg;
8237
9984
  exports.randomFloatFromTo = randomFloatFromTo;
8238
9985
  exports.randomIntFromTo = randomIntFromTo;
8239
- exports.vec3 = exports.scriptManager = void 0;
9986
+ exports.vec3 = exports.urlQuery = exports.scriptManager = void 0;
8240
9987
  const vec3 = exports.vec3 = {
8241
9988
  cross(a, b, dst) {
8242
9989
  dst = dst || new Float32Array(3);
@@ -8768,7 +10515,7 @@ function randomIntFromTo(min, max) {
8768
10515
  return Math.floor(Math.random() * (max - min + 1) + min);
8769
10516
  }
8770
10517
  }
8771
- var QueryString = exports.QueryString = function () {
10518
+ var urlQuery = exports.urlQuery = function () {
8772
10519
  var query_string = {};
8773
10520
  var query = window.location.search.substring(1);
8774
10521
  var vars = query.split('&');
@@ -8885,10 +10632,115 @@ function quaternion_rotation_matrix(Q) {
8885
10632
  // copnsole log graphics
8886
10633
  const LOG_WARN = exports.LOG_WARN = 'background: gray; color: yellow; font-size:10px';
8887
10634
  const LOG_INFO = exports.LOG_INFO = 'background: green; color: white; font-size:11px';
8888
- const LOG_MATRIX = exports.LOG_MATRIX = "font-family: verdana;color: #lime; font-size:11px;text-shadow: 2px 2px 4px orangered;background: black;";
10635
+ const LOG_MATRIX = exports.LOG_MATRIX = "font-family: stormfaze;color: #lime; font-size:11px;text-shadow: 2px 2px 4px orangered;background: black;";
8889
10636
  const LOG_FUNNY = exports.LOG_FUNNY = "font-family: stormfaze;color: #f1f033; font-size:14px;text-shadow: 2px 2px 4px #f335f4, 4px 4px 4px #d64444, 2px 2px 4px #c160a6, 6px 2px 0px #123de3;background: black;";
10637
+ const LOG_FUNNY_SMALL = exports.LOG_FUNNY_SMALL = "font-family: stormfaze;color: #f1f033; font-size:10px;text-shadow: 2px 2px 4px #f335f4, 4px 4px 4px #d64444, 1px 1px 2px #c160a6, 3px 1px 0px #123de3;background: black;";
10638
+ function genName(length) {
10639
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
10640
+ let result = "";
10641
+ for (let i = 0; i < length; i++) {
10642
+ result += chars.charAt(Math.floor(Math.random() * chars.length));
10643
+ }
10644
+ return result;
10645
+ }
10646
+ let mb = exports.mb = {
10647
+ root: () => byId('msgBox'),
10648
+ pContent: () => byId('not-content'),
10649
+ copy: function () {
10650
+ navigator.clipboard.writeText(mb.root().children[0].innerText);
10651
+ },
10652
+ c: 0,
10653
+ ic: 0,
10654
+ t: {},
10655
+ setContent: function (content, t) {
10656
+ var iMsg = document.createElement('div');
10657
+ iMsg.innerHTML = content;
10658
+ iMsg.id = `msgbox-loc-${mb.c}`;
10659
+ mb.root().appendChild(iMsg);
10660
+ iMsg.classList.add('animate1');
10661
+ if (t == 'ok') {
10662
+ iMsg.style = 'font-family: stormfaze;color:white;padding:7px;margin:2px';
10663
+ } else {
10664
+ iMsg.style = 'font-family: stormfaze;color:white;padding:7px;margin:2px';
10665
+ }
10666
+ },
10667
+ kill: function () {
10668
+ mb.root().remove();
10669
+ },
10670
+ show: function (content, t) {
10671
+ mb.setContent(content, t);
10672
+ mb.root().style.display = "block";
10673
+ var loc2 = mb.c;
10674
+ setTimeout(function () {
10675
+ byId(`msgbox-loc-${loc2}`).classList.remove("fadeInDown");
10676
+ byId(`msgbox-loc-${loc2}`).classList.add("fadeOut");
10677
+ setTimeout(function () {
10678
+ byId(`msgbox-loc-${loc2}`).style.display = "none";
10679
+ byId(`msgbox-loc-${loc2}`).classList.remove("fadeOut");
10680
+ byId(`msgbox-loc-${loc2}`).remove();
10681
+ mb.ic++;
10682
+ if (mb.c == mb.ic) {
10683
+ mb.root().style.display = 'none';
10684
+ }
10685
+ }, 1000);
10686
+ }, 3000);
10687
+ mb.c++;
10688
+ },
10689
+ error: function (content) {
10690
+ mb.root().classList.remove("success");
10691
+ mb.root().classList.add("error");
10692
+ mb.root().classList.add("fadeInDown");
10693
+ mb.show(content, 'err');
10694
+ },
10695
+ success: function (content) {
10696
+ mb.root().classList.remove("error");
10697
+ mb.root().classList.add("success");
10698
+ mb.root().classList.add("fadeInDown");
10699
+ mb.show(content, 'ok');
10700
+ }
10701
+ };
10702
+
10703
+ },{}],13:[function(require,module,exports){
10704
+ "use strict";
8890
10705
 
8891
- },{}],11:[function(require,module,exports){
10706
+ Object.defineProperty(exports, "__esModule", {
10707
+ value: true
10708
+ });
10709
+ exports.MultiLang = void 0;
10710
+ var _utils = require("../engine/utils");
10711
+ class MultiLang {
10712
+ constructor() {
10713
+ addEventListener('updateLang', () => {
10714
+ console.log('Multilang updated.');
10715
+ this.update();
10716
+ });
10717
+ }
10718
+ update = function () {
10719
+ var allTranDoms = document.querySelectorAll('[data-label]');
10720
+ allTranDoms.forEach(i => {
10721
+ i.innerHTML = this.get[i.getAttribute('data-label')];
10722
+ });
10723
+ };
10724
+ loadMultilang = async function (lang = 'en') {
10725
+ lang = 'res/multilang/' + lang + '.json';
10726
+ console.info(`%cMultilang: ${lang}`, _utils.LOG_MATRIX);
10727
+ try {
10728
+ const r = await fetch(lang, {
10729
+ headers: {
10730
+ 'Accept': 'application/json',
10731
+ 'Content-Type': 'application/json'
10732
+ }
10733
+ });
10734
+ return await r.json();
10735
+ } catch (err) {
10736
+ console.warn('Not possible to access multilang json asset! Err => ', err);
10737
+ return {};
10738
+ }
10739
+ };
10740
+ }
10741
+ exports.MultiLang = MultiLang;
10742
+
10743
+ },{"../engine/utils":12}],14:[function(require,module,exports){
8892
10744
  "use strict";
8893
10745
 
8894
10746
  Object.defineProperty(exports, "__esModule", {
@@ -8896,12 +10748,17 @@ Object.defineProperty(exports, "__esModule", {
8896
10748
  });
8897
10749
  exports.default = void 0;
8898
10750
  var _utils = require("../engine/utils");
10751
+ // import {vec3} from "wgpu-matrix";
10752
+
8899
10753
  class MatrixAmmo {
8900
10754
  constructor() {
8901
10755
  // THIS PATH IS PATH FROM PUBLIC FINAL FOLDER
8902
10756
  _utils.scriptManager.LOAD("./ammojs/ammo.js", "ammojs", undefined, undefined, this.init);
10757
+ this.lastRoll = '';
10758
+ this.presentScore = '';
8903
10759
  }
8904
10760
  init = () => {
10761
+ // console.log('pre ammo')
8905
10762
  Ammo().then(Ammo => {
8906
10763
  // Physics variables
8907
10764
  this.dynamicsWorld = null;
@@ -8910,12 +10767,12 @@ class MatrixAmmo {
8910
10767
  this.lastUpdate = 0;
8911
10768
  console.log("%c Ammo core loaded.", _utils.LOG_FUNNY);
8912
10769
  this.initPhysics();
8913
- dispatchEvent(new CustomEvent('AmmoReady', {}));
10770
+ // simulate async
10771
+ setTimeout(() => dispatchEvent(new CustomEvent('AmmoReady', {})), 100);
8914
10772
  });
8915
10773
  };
8916
10774
  initPhysics() {
8917
10775
  let Ammo = this.Ammo;
8918
-
8919
10776
  // Physics configuration
8920
10777
  var collisionConfiguration = new Ammo.btDefaultCollisionConfiguration(),
8921
10778
  dispatcher = new Ammo.btCollisionDispatcher(collisionConfiguration),
@@ -8923,10 +10780,10 @@ class MatrixAmmo {
8923
10780
  solver = new Ammo.btSequentialImpulseConstraintSolver();
8924
10781
  this.dynamicsWorld = new Ammo.btDiscreteDynamicsWorld(dispatcher, overlappingPairCache, solver, collisionConfiguration);
8925
10782
  this.dynamicsWorld.setGravity(new Ammo.btVector3(0, -10, 0));
8926
- var groundShape = new Ammo.btBoxShape(new Ammo.btVector3(50, 2, 50)),
10783
+ var groundShape = new Ammo.btBoxShape(new Ammo.btVector3(70, 1, 70)),
8927
10784
  groundTransform = new Ammo.btTransform();
8928
10785
  groundTransform.setIdentity();
8929
- groundTransform.setOrigin(new Ammo.btVector3(0, -1, 0));
10786
+ groundTransform.setOrigin(new Ammo.btVector3(0, -4.45, 0));
8930
10787
  var mass = 0,
8931
10788
  isDynamic = mass !== 0,
8932
10789
  localInertia = new Ammo.btVector3(0, 0, 0);
@@ -8934,8 +10791,12 @@ class MatrixAmmo {
8934
10791
  var myMotionState = new Ammo.btDefaultMotionState(groundTransform),
8935
10792
  rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, groundShape, localInertia),
8936
10793
  body = new Ammo.btRigidBody(rbInfo);
10794
+ body.name = 'ground';
10795
+ this.ground = body;
8937
10796
  this.dynamicsWorld.addRigidBody(body);
8938
10797
  // this.rigidBodies.push(body);
10798
+ // add collide event
10799
+ this.detectCollision();
8939
10800
  }
8940
10801
  addPhysics(MEObject, pOptions) {
8941
10802
  if (pOptions.geometry == "Sphere") {
@@ -8962,18 +10823,45 @@ class MatrixAmmo {
8962
10823
  return body;
8963
10824
  }
8964
10825
  addPhysicsBox(MEObject, pOptions) {
10826
+ const FLAGS = {
10827
+ TEST_NIDZA: 3,
10828
+ CF_KINEMATIC_OBJECT: 2
10829
+ };
8965
10830
  let Ammo = this.Ammo;
8966
- var colShape = new Ammo.btBoxShape(new Ammo.btVector3(1, 1, 1)),
10831
+ // improve this - scale by comp
10832
+ var colShape = new Ammo.btBoxShape(new Ammo.btVector3(pOptions.scale[0], pOptions.scale[1], pOptions.scale[2])),
8967
10833
  startTransform = new Ammo.btTransform();
8968
10834
  startTransform.setIdentity();
8969
- var mass = 1;
10835
+ var mass = pOptions.mass;
8970
10836
  var localInertia = new Ammo.btVector3(0, 0, 0);
8971
10837
  colShape.calculateLocalInertia(mass, localInertia);
8972
10838
  startTransform.setOrigin(new Ammo.btVector3(pOptions.position.x, pOptions.position.y, pOptions.position.z));
10839
+ //rotation
10840
+ // console.log('startTransform.setRotation', startTransform.setRotation)
10841
+ var t = startTransform.getRotation();
10842
+ t.setX((0, _utils.degToRad)(pOptions.rotation.x));
10843
+ t.setY((0, _utils.degToRad)(pOptions.rotation.y));
10844
+ t.setZ((0, _utils.degToRad)(pOptions.rotation.z));
10845
+ startTransform.setRotation(t);
10846
+
10847
+ // startTransform.setRotation(pOptions.rotation.x, pOptions.rotation.y, pOptions.rotation.z);
10848
+
8973
10849
  var myMotionState = new Ammo.btDefaultMotionState(startTransform),
8974
10850
  rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia),
8975
10851
  body = new Ammo.btRigidBody(rbInfo);
8976
- body.setActivationState(4);
10852
+ if (pOptions.mass == 0 && typeof pOptions.state == 'undefined' && typeof pOptions.collide == 'undefined') {
10853
+ body.setActivationState(2);
10854
+ body.setCollisionFlags(FLAGS.CF_KINEMATIC_OBJECT);
10855
+ // console.log('what is pOptions.mass and state is 2 ....', pOptions.mass)
10856
+ } else if (typeof pOptions.collide != 'undefined' && pOptions.collide == false) {
10857
+ // idea not work for now - eliminate collide effect
10858
+ body.setActivationState(4);
10859
+ body.setCollisionFlags(FLAGS.TEST_NIDZA);
10860
+ } else {
10861
+ body.setActivationState(4);
10862
+ }
10863
+ // console.log('what is name.', pOptions.name)
10864
+ body.name = pOptions.name;
8977
10865
  body.MEObject = MEObject;
8978
10866
  this.dynamicsWorld.addRigidBody(body);
8979
10867
  this.rigidBodies.push(body);
@@ -8984,6 +10872,118 @@ class MatrixAmmo {
8984
10872
  tbv30.setValue(x, y, z);
8985
10873
  body.setLinearVelocity(tbv30);
8986
10874
  }
10875
+ setKinematicTransform(body, x, y, z, rx, ry, rz) {
10876
+ if (typeof rx == 'undefined') {
10877
+ var rx = 0;
10878
+ }
10879
+ if (typeof ry == 'undefined') {
10880
+ var ry = 0;
10881
+ }
10882
+ if (typeof rz == 'undefined') {
10883
+ var rz = 0;
10884
+ }
10885
+ let pos = new Ammo.btVector3();
10886
+ // let quat = new Ammo.btQuaternion();
10887
+ pos = body.getWorldTransform().getOrigin();
10888
+ let localRot = body.getWorldTransform().getRotation();
10889
+ // console.log('pre pos x:', pos.x(), " y : ", pos.y(), " z:", pos.z())
10890
+ pos.setX(pos.x() + x);
10891
+ pos.setY(pos.y() + y);
10892
+ pos.setZ(pos.z() + z);
10893
+ // console.log('position kinematic move : ', pos)
10894
+ // console.log('position localRot : ', localRot)
10895
+ localRot.setX(rx);
10896
+ localRot.setY(ry);
10897
+ localRot.setZ(rz);
10898
+ let physicsBody = body;
10899
+ let ms = physicsBody.getMotionState();
10900
+ if (ms) {
10901
+ var tmpTrans = new Ammo.btTransform();
10902
+
10903
+ // quat.setValue(quat.x(), quat.y(), quat.z(), quat.w());
10904
+ tmpTrans.setIdentity();
10905
+ tmpTrans.setOrigin(pos);
10906
+ tmpTrans.setRotation(localRot);
10907
+ ms.setWorldTransform(tmpTrans);
10908
+ }
10909
+ // console.log('body, ', body)
10910
+ }
10911
+ getBodyByName(name) {
10912
+ var b = null;
10913
+ this.rigidBodies.forEach((item, index, array) => {
10914
+ if (item.name == name) {
10915
+ b = array[index];
10916
+ }
10917
+ });
10918
+ return b;
10919
+ }
10920
+ getNameByBody(body) {
10921
+ var b = null;
10922
+ this.rigidBodies.forEach((item, index, array) => {
10923
+ if (item.kB == body.kB) {
10924
+ b = array[index].name;
10925
+ }
10926
+ });
10927
+ return b;
10928
+ }
10929
+ detectCollision() {
10930
+ console.log('override this');
10931
+ return;
10932
+ this.lastRoll = '';
10933
+ this.presentScore = '';
10934
+ let dispatcher = this.dynamicsWorld.getDispatcher();
10935
+ let numManifolds = dispatcher.getNumManifolds();
10936
+ for (let i = 0; i < numManifolds; i++) {
10937
+ let contactManifold = dispatcher.getManifoldByIndexInternal(i);
10938
+ // let numContacts = contactManifold.getNumContacts();
10939
+ // this.rigidBodies.forEach((item) => {
10940
+ // if(item.kB == contactManifold.getBody0().kB) {
10941
+ // // console.log('Detected body0 =', item.name)
10942
+ // }
10943
+ // if(item.kB == contactManifold.getBody1().kB) {
10944
+ // // console.log('Detected body1 =', item.name)
10945
+ // }
10946
+ // })
10947
+
10948
+ if (this.ground.kB == contactManifold.getBody0().kB && this.getNameByBody(contactManifold.getBody1()) == 'CubePhysics1') {
10949
+ // console.log(this.ground ,'GROUND IS IN CONTACT WHO IS BODY1 ', contactManifold.getBody1())
10950
+ // console.log('GROUND IS IN CONTACT WHO IS BODY1 getNameByBody ', this.getNameByBody(contactManifold.getBody1()))
10951
+ // CHECK ROTATION
10952
+ var testR = contactManifold.getBody1().getWorldTransform().getRotation();
10953
+ if (Math.abs(testR.y()) < 0.00001) {
10954
+ this.lastRoll += " 4 +";
10955
+ this.presentScore += 4;
10956
+ dispatchEvent(new CustomEvent('dice-1', {}));
10957
+ }
10958
+ if (Math.abs(testR.x()) < 0.00001) {
10959
+ this.lastRoll += " 3 +";
10960
+ this.presentScore += 3;
10961
+ dispatchEvent(new CustomEvent('dice-4', {}));
10962
+ }
10963
+ if (testR.x().toString().substring(0, 5) == testR.y().toString().substring(1, 6)) {
10964
+ this.lastRoll += " 2 +";
10965
+ this.presentScore += 2;
10966
+ dispatchEvent(new CustomEvent('dice-6', {}));
10967
+ }
10968
+ if (testR.x().toString().substring(0, 5) == testR.y().toString().substring(0, 5)) {
10969
+ this.lastRoll += " 1 +";
10970
+ this.presentScore += 1;
10971
+ dispatchEvent(new CustomEvent('dice-2', {}));
10972
+ }
10973
+ if (testR.z().toString().substring(0, 5) == testR.y().toString().substring(1, 6)) {
10974
+ this.lastRoll += " 6 +";
10975
+ this.presentScore += 6;
10976
+ dispatchEvent(new CustomEvent('dice-5', {}));
10977
+ }
10978
+ if (testR.z().toString().substring(0, 5) == testR.y().toString().substring(0, 5)) {
10979
+ this.lastRoll += " 5 +";
10980
+ this.presentScore += 5;
10981
+ dispatchEvent(new CustomEvent('dice-3', {}));
10982
+ }
10983
+ console.log('this.lastRoll = ', this.lastRoll, ' presentScore = ', this.presentScore);
10984
+ }
10985
+ }
10986
+ }
8987
10987
  updatePhysics() {
8988
10988
  // Step world
8989
10989
  this.dynamicsWorld.stepSimulation(1 / 60, 10);
@@ -9002,18 +11002,17 @@ class MatrixAmmo {
9002
11002
  body.MEObject.rotation.axis.x = testAxis.x();
9003
11003
  body.MEObject.rotation.axis.y = testAxis.y();
9004
11004
  body.MEObject.rotation.axis.z = testAxis.z();
9005
- // var tx = radToDeg(parseFloat(test.getAngle().toFixed(2)) * testAxis.x().toFixed(2))
9006
- // var ty = radToDeg(parseFloat(test.getAngle().toFixed(2)) * testAxis.y().toFixed(2))
9007
- // var tz = radToDeg(parseFloat(test.getAngle().toFixed(2)) * testAxis.z().toFixed(2))
9008
11005
  body.MEObject.rotation.matrixRotation = (0, _utils.quaternion_rotation_matrix)(test);
9009
11006
  body.MEObject.rotation.angle = (0, _utils.radToDeg)(parseFloat(test.getAngle().toFixed(2)));
9010
11007
  }
9011
11008
  });
11009
+ // collision detect
11010
+ this.detectCollision();
9012
11011
  }
9013
11012
  }
9014
11013
  exports.default = MatrixAmmo;
9015
11014
 
9016
- },{"../engine/utils":10}],12:[function(require,module,exports){
11015
+ },{"../engine/utils":12}],15:[function(require,module,exports){
9017
11016
  "use strict";
9018
11017
 
9019
11018
  Object.defineProperty(exports, "__esModule", {
@@ -9042,7 +11041,7 @@ struct FragmentInput {
9042
11041
  }
9043
11042
 
9044
11043
  const albedo = vec3f(0.9);
9045
- const ambientFactor = 0.2;
11044
+ const ambientFactor = 0.7;
9046
11045
 
9047
11046
  @fragment
9048
11047
  fn main(input : FragmentInput) -> @location(0) vec4f {
@@ -9061,15 +11060,17 @@ fn main(input : FragmentInput) -> @location(0) vec4f {
9061
11060
  }
9062
11061
  }
9063
11062
  visibility /= 9.0;
9064
-
9065
11063
  let lambertFactor = max(dot(normalize(scene.lightPos - input.fragPos), normalize(input.fragNorm)), 0.0);
9066
11064
  let lightingFactor = min(ambientFactor + visibility * lambertFactor, 1.0);
9067
11065
  let textureColor = textureSample(meshTexture, meshSampler, input.uv);
9068
11066
 
9069
11067
  return vec4(textureColor.rgb * lightingFactor * albedo, 1.0);
11068
+ // return vec4f(input.fragNorm * 0.5 + 0.5, 1)
11069
+ // return vec4f(input.uv, 0, 1)
11070
+ // return vec4(textureColor.rgb , 0.5);
9070
11071
  }`;
9071
11072
 
9072
- },{}],13:[function(require,module,exports){
11073
+ },{}],16:[function(require,module,exports){
9073
11074
  "use strict";
9074
11075
 
9075
11076
  Object.defineProperty(exports, "__esModule", {
@@ -9113,7 +11114,7 @@ fn vertexMain(input: VertexInput) -> VertexOutput {
9113
11114
  @group(1) @binding(2) var meshTexture: texture_2d<f32>;
9114
11115
 
9115
11116
  // Static directional lighting
9116
- const lightDir = vec3f(1, 1, 1);
11117
+ const lightDir = vec3f(0, 1, 0);
9117
11118
  const dirColor = vec3(1);
9118
11119
  const ambientColor = vec3f(0.05);
9119
11120
 
@@ -9127,7 +11128,7 @@ fn fragmentMain(input: VertexOutput) -> @location(0) vec4f {
9127
11128
  return vec4f(textureColor.rgb * lightColor, textureColor.a);
9128
11129
  }`;
9129
11130
 
9130
- },{}],14:[function(require,module,exports){
11131
+ },{}],17:[function(require,module,exports){
9131
11132
  "use strict";
9132
11133
 
9133
11134
  Object.defineProperty(exports, "__esModule", {
@@ -9184,7 +11185,7 @@ fn main(
9184
11185
  }
9185
11186
  `;
9186
11187
 
9187
- },{}],15:[function(require,module,exports){
11188
+ },{}],18:[function(require,module,exports){
9188
11189
  "use strict";
9189
11190
 
9190
11191
  Object.defineProperty(exports, "__esModule", {
@@ -9208,11 +11209,61 @@ struct Model {
9208
11209
  fn main(
9209
11210
  @location(0) position: vec3f
9210
11211
  ) -> @builtin(position) vec4f {
9211
- return scene.lightViewProjMatrix * model.modelMatrix * vec4(position, 1.0);
11212
+ return scene.lightViewProjMatrix * model.modelMatrix * vec4(position, 1);
9212
11213
  }
9213
11214
  `;
9214
11215
 
9215
- },{}],16:[function(require,module,exports){
11216
+ },{}],19:[function(require,module,exports){
11217
+ "use strict";
11218
+
11219
+ Object.defineProperty(exports, "__esModule", {
11220
+ value: true
11221
+ });
11222
+ exports.MatrixSounds = void 0;
11223
+ class MatrixSounds {
11224
+ constructor() {
11225
+ this.volume = 0.5;
11226
+ this.audios = {};
11227
+ }
11228
+ createClones(c, name, path) {
11229
+ for (var x = 1; x < c; x++) {
11230
+ let a = new Audio(path);
11231
+ a.id = name + x;
11232
+ a.volume = this.volume;
11233
+ this.audios[name + x] = a;
11234
+ document.body.append(a);
11235
+ }
11236
+ }
11237
+ createAudio(name, path, useClones) {
11238
+ let a = new Audio(path);
11239
+ a.id = name;
11240
+ a.volume = this.volume;
11241
+ this.audios[name] = a;
11242
+ document.body.append(a);
11243
+ if (typeof useClones !== 'undefined') {
11244
+ this.createClones(useClones, name, path);
11245
+ }
11246
+ }
11247
+ play(name) {
11248
+ if (this.audios[name].paused == true) {
11249
+ this.audios[name].play();
11250
+ } else {
11251
+ this.tryClone(name);
11252
+ }
11253
+ }
11254
+ tryClone(name) {
11255
+ var cc = 1;
11256
+ try {
11257
+ while (this.audios[name + cc].paused == false) {
11258
+ cc++;
11259
+ }
11260
+ if (this.audios[name + cc]) this.audios[name + cc].play();
11261
+ } catch (err) {}
11262
+ }
11263
+ }
11264
+ exports.MatrixSounds = MatrixSounds;
11265
+
11266
+ },{}],20:[function(require,module,exports){
9216
11267
  "use strict";
9217
11268
 
9218
11269
  Object.defineProperty(exports, "__esModule", {
@@ -9227,6 +11278,8 @@ var _mesh = _interopRequireDefault(require("./engine/mesh.js"));
9227
11278
  var _meshObj = _interopRequireDefault(require("./engine/mesh-obj.js"));
9228
11279
  var _matrixAmmo = _interopRequireDefault(require("./physics/matrix-ammo.js"));
9229
11280
  var _utils = require("./engine/utils.js");
11281
+ var _lang = require("./multilang/lang.js");
11282
+ var _sounds = require("./sounds/sounds.js");
9230
11283
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9231
11284
  class MatrixEngineWGPU {
9232
11285
  mainRenderBundle = [];
@@ -9240,6 +11293,7 @@ class MatrixEngineWGPU {
9240
11293
  depthStoreOp: 'store'
9241
11294
  };
9242
11295
  matrixAmmo = new _matrixAmmo.default();
11296
+ matrixSounds = new _sounds.MatrixSounds();
9243
11297
 
9244
11298
  // The input handler
9245
11299
  constructor(options, callback) {
@@ -9288,6 +11342,18 @@ class MatrixEngineWGPU {
9288
11342
  position: initialCameraPosition
9289
11343
  })
9290
11344
  };
11345
+
11346
+ //
11347
+ this.label = new _lang.MultiLang();
11348
+ if (_utils.urlQuery.lang != null) {
11349
+ this.label.loadMultilang(_utils.urlQuery.lang).then(r => {
11350
+ this.label.get = r;
11351
+ });
11352
+ } else {
11353
+ this.label.loadMultilang().then(r => {
11354
+ this.label.get = r;
11355
+ });
11356
+ }
9291
11357
  this.init({
9292
11358
  canvas,
9293
11359
  callback
@@ -9299,7 +11365,17 @@ class MatrixEngineWGPU {
9299
11365
  }) => {
9300
11366
  this.canvas = canvas;
9301
11367
  this.adapter = await navigator.gpu.requestAdapter();
9302
- this.device = await this.adapter.requestDevice();
11368
+ this.device = await this.adapter.requestDevice({
11369
+ extensions: ["ray_tracing"]
11370
+ });
11371
+
11372
+ // Maybe works in ssl with webworkers...
11373
+ // const adapterInfo = await this.adapter.requestAdapterInfo();
11374
+ // var test = this.adapter.features()
11375
+ // console.log(adapterInfo.vendor);
11376
+ // console.log('test' + test);
11377
+ // console.log("FEATURES : " + this.adapter.features)
11378
+
9303
11379
  this.context = canvas.getContext('webgpu');
9304
11380
  const devicePixelRatio = window.devicePixelRatio;
9305
11381
  canvas.width = canvas.clientWidth * devicePixelRatio;
@@ -9490,6 +11566,9 @@ class MatrixEngineWGPU {
9490
11566
  this.mainRenderBundle.push(myMesh1);
9491
11567
  };
9492
11568
  addMeshObj = o => {
11569
+ if (typeof o.name === 'undefined') {
11570
+ o.name = (0, _utils.genName)(9);
11571
+ }
9493
11572
  if (typeof o.position === 'undefined') {
9494
11573
  o.position = {
9495
11574
  x: 0,
@@ -9518,26 +11597,33 @@ class MatrixEngineWGPU {
9518
11597
  o.mainCameraParams = this.mainCameraParams;
9519
11598
  }
9520
11599
  if (typeof o.scale === 'undefined') {
9521
- o.scale = 1;
11600
+ o.scale = [1, 1, 1];
11601
+ }
11602
+ if (typeof o.raycast === 'undefined') {
11603
+ o.raycast = {
11604
+ enabled: false
11605
+ };
9522
11606
  }
9523
11607
  o.entityArgPass = this.entityArgPass;
9524
11608
  o.cameras = this.cameras;
9525
- if (typeof o.name === 'undefined') {
9526
- o.name = 'random' + Math.random();
9527
- }
11609
+ // if(typeof o.name === 'undefined') {o.name = 'random' + Math.random();}
9528
11610
  if (typeof o.mesh === 'undefined') {
11611
+ _utils.mb.error('arg mesh is empty for ', o.name);
9529
11612
  throw console.error('arg mesh is empty...');
9530
11613
  return;
9531
11614
  }
9532
11615
  if (typeof o.physics === 'undefined') {
9533
11616
  o.physics = {
9534
- enabled: false,
11617
+ scale: [1, 1, 1],
11618
+ enabled: true,
9535
11619
  geometry: "Sphere",
9536
- radius: o.scale
11620
+ radius: o.scale,
11621
+ name: o.name,
11622
+ rotation: o.rotation
9537
11623
  };
9538
11624
  }
9539
11625
  if (typeof o.physics.enabled === 'undefined') {
9540
- o.physics.enabled = false;
11626
+ o.physics.enabled = true;
9541
11627
  }
9542
11628
  if (typeof o.physics.geometry === 'undefined') {
9543
11629
  o.physics.geometry = "Sphere";
@@ -9545,11 +11631,22 @@ class MatrixEngineWGPU {
9545
11631
  if (typeof o.physics.radius === 'undefined') {
9546
11632
  o.physics.radius = o.scale;
9547
11633
  }
11634
+ if (typeof o.physics.mass === 'undefined') {
11635
+ o.physics.mass = 1;
11636
+ }
11637
+ if (typeof o.physics.name === 'undefined') {
11638
+ o.physics.name = o.name;
11639
+ }
11640
+ if (typeof o.physics.scale === 'undefined') {
11641
+ o.physics.scale = o.scale;
11642
+ }
11643
+ if (typeof o.physics.rotation === 'undefined') {
11644
+ o.physics.rotation = o.rotation;
11645
+ }
9548
11646
 
9549
11647
  // send same pos
9550
11648
  o.physics.position = o.position;
9551
-
9552
- // console.log('Mesh procedure', o)
11649
+ // console.log('Mesh procedure', o)
9553
11650
  let myMesh1 = new _meshObj.default(this.canvas, this.device, this.context, o);
9554
11651
  if (o.physics.enabled == true) {
9555
11652
  this.matrixAmmo.addPhysics(myMesh1, o.physics);
@@ -9561,9 +11658,13 @@ class MatrixEngineWGPU {
9561
11658
  requestAnimationFrame(this.frame);
9562
11659
  }, 500);
9563
11660
  setTimeout(() => {
9564
- callback();
11661
+ callback(this);
9565
11662
  }, 20);
9566
11663
  }
11664
+ destroyProgram = () => {
11665
+ this.mainRenderBundle = undefined;
11666
+ this.canvas.remove();
11667
+ };
9567
11668
  frameSinglePass = () => {
9568
11669
  if (typeof this.mainRenderBundle == 'undefined') return;
9569
11670
  try {
@@ -9590,7 +11691,7 @@ class MatrixEngineWGPU {
9590
11691
  this.mainRenderBundle.forEach((meItem, index) => {
9591
11692
  meItem.drawElements(renderPass);
9592
11693
  });
9593
- renderPass.end();
11694
+ if (renderPass) renderPass.end();
9594
11695
  this.device.queue.submit([commandEncoder.finish()]);
9595
11696
  requestAnimationFrame(this.frame);
9596
11697
  } catch (err) {
@@ -9598,7 +11699,26 @@ class MatrixEngineWGPU {
9598
11699
  requestAnimationFrame(this.frame);
9599
11700
  }
9600
11701
  };
11702
+ framePassPerObject = () => {
11703
+ // console.log('framePassPerObject')
11704
+ let commandEncoder = this.device.createCommandEncoder();
11705
+ this.rbContainer = [];
11706
+ let passEncoder;
11707
+ this.mainRenderBundle.forEach((meItem, index) => {
11708
+ meItem.draw(commandEncoder);
11709
+ if (meItem.renderBundle) {
11710
+ this.rbContainer.push(meItem.renderBundle);
11711
+ passEncoder = commandEncoder.beginRenderPass(meItem.renderPassDescriptor);
11712
+ passEncoder.executeBundles(this.rbContainer);
11713
+ passEncoder.end();
11714
+ } else {
11715
+ meItem.draw(commandEncoder);
11716
+ }
11717
+ });
11718
+ this.device.queue.submit([commandEncoder.finish()]);
11719
+ requestAnimationFrame(this.frame);
11720
+ };
9601
11721
  }
9602
11722
  exports.default = MatrixEngineWGPU;
9603
11723
 
9604
- },{"./engine/ball.js":3,"./engine/cube.js":4,"./engine/engine.js":5,"./engine/mesh-obj.js":8,"./engine/mesh.js":9,"./engine/utils.js":10,"./physics/matrix-ammo.js":11,"wgpu-matrix":2}]},{},[1]);
11724
+ },{"./engine/ball.js":4,"./engine/cube.js":5,"./engine/engine.js":6,"./engine/mesh-obj.js":9,"./engine/mesh.js":10,"./engine/utils.js":12,"./multilang/lang.js":13,"./physics/matrix-ammo.js":14,"./sounds/sounds.js":19,"wgpu-matrix":3}]},{},[2]);