matrix-engine-wgpu 1.0.6 → 1.1.0

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 (69) 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 +1127 -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/main.js +442 -48
  12. package/non-project-files/dev.txt +21 -0
  13. package/non-project-files/image1.png +0 -0
  14. package/non-project-files/image6.png +0 -0
  15. package/package.json +28 -13
  16. package/public/app.js +11405 -9375
  17. package/public/css/style.css +371 -110
  18. package/public/empty.html +1 -1
  19. package/public/empty.js +9887 -9264
  20. package/public/examples.html +10 -8
  21. package/public/examples.js +553 -193
  22. package/public/index.html +3 -5
  23. package/public/manifest copy.web +35 -0
  24. package/public/res/audios/block.mp3 +0 -0
  25. package/public/res/audios/dice1.mp3 +0 -0
  26. package/public/res/audios/dice2.mp3 +0 -0
  27. package/public/res/audios/start.mp3 +0 -0
  28. package/public/res/meshes/jamb/bg.blend +0 -0
  29. package/public/res/meshes/jamb/bg.blend1 +0 -0
  30. package/public/res/meshes/jamb/bg.mtl +12 -0
  31. package/public/res/meshes/jamb/bg.obj +17 -0
  32. package/public/res/meshes/jamb/bg.png +0 -0
  33. package/public/res/meshes/jamb/dice-default.png +0 -0
  34. package/public/res/meshes/jamb/dice-mark.png +0 -0
  35. package/public/res/meshes/jamb/dice.mtl +12 -0
  36. package/public/res/meshes/jamb/dice.obj +40 -0
  37. package/public/res/meshes/jamb/dice.png +0 -0
  38. package/public/res/meshes/jamb/jamb-title.mtl +12 -0
  39. package/public/res/meshes/jamb/jamb-title.obj +26008 -0
  40. package/public/res/meshes/jamb/jamb.blend +0 -0
  41. package/public/res/meshes/jamb/jamb.blend1 +0 -0
  42. package/public/res/meshes/jamb/logo.png +0 -0
  43. package/public/res/meshes/jamb/nidzaDice.blend +0 -0
  44. package/public/res/meshes/jamb/nidzaDice.blend1 +0 -0
  45. package/public/res/meshes/jamb/pile.blend +0 -0
  46. package/public/res/meshes/jamb/simpleCube.blend +0 -0
  47. package/public/res/meshes/jamb/simpleCube.blend1 +0 -0
  48. package/public/res/meshes/jamb/sounds/roll1.wav +0 -0
  49. package/public/res/meshes/jamb/text.png +0 -0
  50. package/public/res/multilang/en.json +27 -0
  51. package/public/res/multilang/sr.json +27 -0
  52. package/public/test.html +636 -0
  53. package/public/three-test.js +165 -0
  54. package/public/worker.html +1 -1
  55. package/readme.md +189 -115
  56. package/src/engine/cube.js +10 -1
  57. package/src/engine/engine.js +1 -5
  58. package/src/engine/loader-obj.js +9 -6
  59. package/src/engine/matrix-class.js +237 -204
  60. package/src/engine/mesh-obj.js +605 -515
  61. package/src/engine/raycast-test.js +93 -0
  62. package/src/engine/utils.js +69 -3
  63. package/src/multilang/lang.js +35 -0
  64. package/src/physics/matrix-ammo.js +168 -15
  65. package/src/shaders/fragment.wgsl.js +4 -2
  66. package/src/shaders/shaders.js +1 -1
  67. package/src/shaders/vertexShadow.wgsl.js +1 -1
  68. package/src/sounds/sounds.js +47 -0
  69. package/src/world.js +311 -248
package/main.js CHANGED
@@ -1,57 +1,451 @@
1
1
  import MatrixEngineWGPU from "./src/world.js";
2
2
  import {downloadMeshes} from './src/engine/loader-obj.js';
3
- import {LOG_FUNNY, LOG_INFO, LOG_MATRIX} from "./src/engine/utils.js";
3
+ import {LOG_FUNNY, LOG_INFO, LOG_MATRIX, randomFloatFromTo, randomIntFromTo} from "./src/engine/utils.js";
4
+ import {dices, myDom} from "./examples/games/jamb/jamb.js";
5
+ import {MatrixSounds} from "./src/sounds/sounds.js";
6
+ import {addRaycastListener, touchCoordinate,rayIntersectsSphere, getRayFromMouse} from "./src/engine/raycast-test.js";
4
7
 
5
8
  export let application = new MatrixEngineWGPU({
6
- useSingleRenderPass: true,
7
- canvasSize: 'fullscreen',
8
- mainCameraParams: {
9
- type: 'WASD',
10
- responseCoef: 1000
11
- }
9
+ useSingleRenderPass: true,
10
+ canvasSize: 'fullscreen',
11
+ mainCameraParams: {
12
+ type: 'WASD',
13
+ responseCoef: 1000
14
+ }
12
15
  }, () => {
16
+ // Dom operations
17
+ application.myDom = myDom;
18
+ myDom.createJamb();
19
+ myDom.createBlocker();
13
20
 
14
- addEventListener('AmmoReady', () => {
15
- downloadMeshes({
16
- welcomeText: "./res/meshes/blender/piramyd.obj",
17
- armor: "./res/meshes/obj/armor.obj",
18
- sphere: "./res/meshes/blender/sphere.obj",
19
- cube: "./res/meshes/blender/cube.obj",
20
- }, onLoadObj)
21
- })
22
-
23
- function onLoadObj(m) {
24
- application.myLoadedMeshes = m;
25
- for(var key in m) {
26
- console.log(`%c Loaded objs: ${key} `, LOG_MATRIX);
27
- }
28
-
29
- application.addMeshObj({
30
- position: {x: 0, y: 2, z: -10},
31
- rotation: {x: 0, y: 0, z: 0},
32
- rotationSpeed: {x: 0, y: 0, z: 0},
33
- texturesPaths: ['./res/meshes/blender/cube.png'],
34
- name: 'CubePhysics',
35
- mesh: m.cube,
36
- physics: {
37
- enabled: true,
38
- geometry: "Cube"
39
- }
40
- })
41
-
42
- application.addMeshObj({
43
- position: {x: 0, y: 2, z: -10},
44
- rotation: {x: 0, y: 0, z: 0},
45
- rotationSpeed: {x: 0, y: 0, z: 0},
46
- texturesPaths: ['./res/meshes/blender/cube.png'],
47
- name: 'SpherePhysics',
48
- mesh: m.sphere,
49
- physics: {
50
- enabled: true,
51
- geometry: "Sphere"
52
- }
53
- })
54
- }
21
+ application.dices = dices;
22
+
23
+ // this code must be on top
24
+ application.matrixAmmo.detectCollision = function() {
25
+ this.lastRoll = '';
26
+ this.presentScore = '';
27
+ let dispatcher = this.dynamicsWorld.getDispatcher();
28
+ let numManifolds = dispatcher.getNumManifolds();
29
+ for(let i = 0;i < numManifolds;i++) {
30
+ let contactManifold = dispatcher.getManifoldByIndexInternal(i);
31
+ // let numContacts = contactManifold.getNumContacts();
32
+ if(this.ground.kB == contactManifold.getBody0().kB ||
33
+ this.ground.kB == contactManifold.getBody1().kB) {
34
+ // console.log(this.ground ,'GROUND IS IN CONTACT WHO IS BODY1 ', contactManifold.getBody1())
35
+ // CHECK ROTATION BEST WAY - VISAL PART IS NOT INTEREST NOW
36
+ if(this.ground.kB == contactManifold.getBody0().kB) {
37
+ var MY_DICE_NAME = this.getNameByBody(contactManifold.getBody1());
38
+ var testR = contactManifold.getBody1().getWorldTransform().getRotation();
39
+ }
40
+ if(this.ground.kB == contactManifold.getBody1().kB) {
41
+ var MY_DICE_NAME = this.getNameByBody(contactManifold.getBody0());
42
+ var testR = contactManifold.getBody0().getWorldTransform().getRotation();
43
+ }
44
+ var passed = false;
45
+ if(Math.abs(testR.y()) < 0.00001) {
46
+ this.lastRoll = "3";
47
+ this.presentScore += 4;
48
+ passed = true;
49
+ }
50
+ if(Math.abs(testR.x()) < 0.00001) {
51
+ this.lastRoll = "5";
52
+ this.presentScore += 3;
53
+ passed = true;
54
+ }
55
+ if(testR.x().toString().substring(0, 5) == testR.y().toString().substring(1, 6)) {
56
+ this.lastRoll = "6";
57
+ this.presentScore += 2;
58
+ passed = true;
59
+ }
60
+ if(testR.x().toString().substring(0, 5) == testR.y().toString().substring(0, 5)) {
61
+ this.lastRoll = "2";
62
+ this.presentScore += 1;
63
+ passed = true;
64
+ }
65
+ if(testR.z().toString().substring(0, 5) == testR.y().toString().substring(1, 6)) {
66
+ this.lastRoll = "4";
67
+ this.presentScore += 6;
68
+ passed = true;
69
+ }
70
+ if(testR.z().toString().substring(0, 5) == testR.y().toString().substring(0, 5)) {
71
+ this.lastRoll = "1";
72
+ this.presentScore += 5;
73
+ passed = true;
74
+ }
75
+ if(passed == true) dispatchEvent(new CustomEvent(`dice-${this.lastRoll}`, {
76
+ detail: {
77
+ result: `dice-${this.lastRoll}`,
78
+ cubeId: MY_DICE_NAME
79
+ }
80
+ }))
81
+ }
82
+ }
83
+ }
84
+
85
+ addRaycastListener();
86
+ // OR add manual see readme
87
+
88
+
89
+ addEventListener('mousemove', (e) => {
90
+ // console.log('only on click')
91
+ touchCoordinate.enabled = true;
92
+ })
93
+
94
+ // Sounds
95
+ application.matrixSounds.createAudio('start', 'res/audios/start.mp3', 1)
96
+ application.matrixSounds.createAudio('block', 'res/audios/block.mp3', 6)
97
+ application.matrixSounds.createAudio('dice1', 'res/audios/dice1.mp3', 6)
98
+ application.matrixSounds.createAudio('dice2', 'res/audios/dice2.mp3', 6)
99
+
100
+ addEventListener('AmmoReady', () => {
101
+ downloadMeshes({
102
+ cube: "./res/meshes/jamb/dice.obj",
103
+ }, onLoadObj, {scale: [1, 1, 1], swap: [null]})
104
+
105
+ downloadMeshes({
106
+ bg: "./res/meshes/jamb/bg.obj",
107
+ }, onLoadObjFloor, {scale: [3, 1, 3], swap: [null]})
108
+
109
+ downloadMeshes({
110
+ mainTitle: "./res/meshes/jamb/jamb-title.obj",
111
+ }, onLoadObjOther, {scale: [3, 2, 3], swap: [null]})
112
+
113
+ downloadMeshes({
114
+ cube: "./res/meshes/jamb/dice.obj",
115
+ }, onLoadObjWallCenter, {scale: [50, 10, 10], swap: [null]})
116
+
117
+ downloadMeshes({
118
+ cube: "./res/meshes/jamb/dice.obj",
119
+ }, (m) => {
120
+ for(var key in m) {
121
+ // console.log(`%c Loaded objs -> : ${key} `, LOG_MATRIX);
122
+ }
123
+ // right
124
+ application.addMeshObj({
125
+ position: {x: 25, y: 5.5, z: -25},
126
+ rotation: {x: 0, y: -22, z: 0},
127
+ scale: [25, 10, 4],
128
+ texturesPaths: ['./res/meshes/jamb/text.png'],
129
+ name: 'wallRight',
130
+ mesh: m.cube,
131
+ physics: {
132
+ mass: 0,
133
+ enabled: true,
134
+ geometry: "Cube"
135
+ }
136
+ })
137
+
138
+ application.addMeshObj({
139
+ position: {x: -25, y: 5.5, z: -25},
140
+ rotation: {x: 0, y: 22, z: 0},
141
+ scale: [25, 10, 4],
142
+ texturesPaths: ['./res/meshes/jamb/text.png'],
143
+ name: 'wallLeft',
144
+ mesh: m.cube,
145
+ physics: {
146
+ mass: 0,
147
+ enabled: true,
148
+ geometry: "Cube"
149
+ }
150
+ })
151
+ }, {scale: [25, 10, 4], swap: [null]})
152
+
153
+ })
154
+
155
+ function onLoadObjWallCenter(m) {
156
+ application.myLoadedMeshesWalls = m;
157
+ for(var key in m) {
158
+ // console.log(`%c Loaded objs -> : ${key} `, LOG_MATRIX);
159
+ }
160
+
161
+ // WALLS Center
162
+ application.addMeshObj({
163
+ position: {x: 0, y: 5, z: -45},
164
+ rotation: {x: 0, y: 0, z: 0},
165
+ scale: [50, 10, 10],
166
+ texturesPaths: ['./res/meshes/jamb/text.png'],
167
+ name: 'wallCenter',
168
+ mesh: m.cube,
169
+ physics: {
170
+ mass: 0,
171
+ enabled: true,
172
+ geometry: "Cube"
173
+ }
174
+ })
175
+ }
176
+
177
+ function onLoadObjOther(m) {
178
+ application.myLoadedMeshes = m;
179
+ for(var key in m) {
180
+ // console.log(`%c Loaded objs -> : ${key} `, LOG_MATRIX);
181
+ }
182
+ // Add logo text top
183
+ application.addMeshObj({
184
+ position: {x: 0, y: 6, z: -15},
185
+ rotation: {x: 0, y: 0, z: 0},
186
+ texturesPaths: ['./res/meshes/jamb/text.png'],
187
+ name: 'mainTitle',
188
+ mesh: m.mainTitle,
189
+ physics: {
190
+ mass: 0,
191
+ enabled: true,
192
+ geometry: "Cube"
193
+ }
194
+ })
195
+ // console.log('camera set')
196
+ // application.cameras.WASD.pitch = 0.2
197
+ setTimeout(() => {
198
+ app.cameras.WASD.velocity[1] = 18
199
+ // BODY , x, y, z, rotX, rotY, RotZ
200
+ app.matrixAmmo.setKinematicTransform(
201
+ app.matrixAmmo.getBodyByName('mainTitle'), 0, 0, 0, 1)
202
+ app.matrixAmmo.setKinematicTransform(
203
+ app.matrixAmmo.getBodyByName('bg'), 0, -10, 0, 0, 0, 0)
204
+ // Better access getBodyByName
205
+ console.log(' app.matrixAmmo. ', app.matrixAmmo.getBodyByName('CubePhysics1'))
206
+ }, 1225)
207
+ }
208
+
209
+ function onLoadObjFloor(m) {
210
+ application.myLoadedMeshes = m;
211
+ for(var key in m) {
212
+ // console.log(`%c Loaded objs -> : ${key} `, LOG_MATRIX);
213
+ }
214
+
215
+ application.addMeshObj({
216
+ scale: [10, 0.1, 0.1],
217
+ position: {x: 0, y: 6, z: -10},
218
+ rotation: {x: 0, y: 0, z: 0},
219
+ // rotationSpeed: {x: 0, y: 0, z: 0},
220
+ texturesPaths: ['./res/meshes/jamb/bg.png'],
221
+ name: 'bg',
222
+ mesh: m.bg,
223
+ physics: {
224
+ collide: false,
225
+ mass: 0,
226
+ enabled: true,
227
+ geometry: "Cube"
228
+ }
229
+ })
230
+ }
231
+
232
+ function onLoadObj(m) {
233
+ application.myLoadedMeshes = m;
234
+ for(var key in m) {
235
+ // console.log(`%c Loaded objs -> : ${key} `, LOG_MATRIX);
236
+ }
237
+
238
+ // Add dices
239
+ application.addMeshObj({
240
+ position: {x: 0, y: 6, z: -10},
241
+ rotation: {x: 0, y: 0, z: 0},
242
+ rotationSpeed: {x: 0, y: 0, z: 0},
243
+ texturesPaths: ['./res/meshes/jamb/dice.png'],
244
+ useUVShema4x2: true,
245
+ name: 'CubePhysics1',
246
+ mesh: m.cube,
247
+ raycast: {enabled: true},
248
+ physics: {
249
+ enabled: true,
250
+ geometry: "Cube"
251
+ }
252
+ })
253
+
254
+ application.addMeshObj({
255
+ position: {x: -5, y: 4, z: -14},
256
+ rotation: {x: 0, y: 0, z: 0},
257
+ rotationSpeed: {x: 0, y: 0, z: 0},
258
+ texturesPaths: ['./res/meshes/jamb/dice.png'],
259
+ useUVShema4x2: true,
260
+ name: 'CubePhysics2',
261
+ mesh: m.cube,
262
+ raycast: {enabled: true},
263
+ physics: {
264
+ enabled: true,
265
+ geometry: "Cube"
266
+ }
267
+ })
268
+
269
+ // application.addMeshObj({
270
+ // position: {x: 4, y: 8, z: -10},
271
+ // rotation: {x: 0, y: 0, z: 0},
272
+ // rotationSpeed: {x: 0, y: 0, z: 0},
273
+ // texturesPaths: ['./res/meshes/jamb/dice.png'],
274
+ // useUVShema4x2: true,
275
+ // name: 'CubePhysics3',
276
+ // mesh: m.cube,
277
+ // raycast: { enabled: true },
278
+ // physics: {
279
+ // enabled: true,
280
+ // geometry: "Cube"
281
+ // }
282
+ // })
283
+
284
+ // application.addMeshObj({
285
+ // position: {x: 3, y: 4, z: -10},
286
+ // rotation: {x: 0, y: 0, z: 0},
287
+ // rotationSpeed: {x: 0, y: 0, z: 0},
288
+ // texturesPaths: ['./res/meshes/jamb/dice.png'],
289
+ // useUVShema4x2: true,
290
+ // name: 'CubePhysics4',
291
+ // mesh: m.cube,
292
+ // raycast: { enabled: true },
293
+ // physics: {
294
+ // enabled: true,
295
+ // geometry: "Cube"
296
+ // }
297
+ // })
298
+
299
+ // application.addMeshObj({
300
+ // position: {x: -2, y: 4, z: -13},
301
+ // rotation: {x: 0, y: 0, z: 0},
302
+ // rotationSpeed: {x: 0, y: 0, z: 0},
303
+ // texturesPaths: ['./res/meshes/jamb/dice.png'],
304
+ // useUVShema4x2: true,
305
+ // name: 'CubePhysics5',
306
+ // mesh: m.cube,
307
+ // raycast: { enabled: true },
308
+ // physics: {
309
+ // enabled: true,
310
+ // geometry: "Cube"
311
+ // }
312
+ // })
313
+
314
+ // application.addMeshObj({
315
+ // position: {x: -4, y: 6, z: -9},
316
+ // rotation: {x: 0, y: 0, z: 0},
317
+ // rotationSpeed: {x: 0, y: 0, z: 0},
318
+ // texturesPaths: ['./res/meshes/jamb/dice.png'],
319
+ // useUVShema4x2: true,
320
+ // name: 'CubePhysics6',
321
+ // mesh: m.cube,
322
+ // raycast: { enabled: true },
323
+ // physics: {
324
+ // enabled: true,
325
+ // geometry: "Cube"
326
+ // }
327
+ // })
328
+
329
+
330
+ application.TOLERANCE = 0;
331
+ let allDiceDoneProcedure = () => {
332
+ console.log("ALL DONE")
333
+ application.TOLERANCE++;
334
+ if(application.TOLERANCE >= 1) {
335
+ removeEventListener('dice-1', dice1Click)
336
+ removeEventListener('dice-2', dice2Click)
337
+ removeEventListener('dice-3', dice3Click)
338
+ removeEventListener('dice-4', dice4Click)
339
+ removeEventListener('dice-5', dice5Click)
340
+ removeEventListener('dice-6', dice6Click)
341
+ console.log('FINAL >>>> ', dices.R)
342
+ application.TOLERANCE = 0;
343
+
344
+ app.cameras.WASD.yaw = 0.01;
345
+ app.cameras.WASD.pitch = -1.26;
346
+ app.cameras.WASD.position[2] = -18;
347
+ app.cameras.WASD.position[1] = 19;
348
+
349
+ // dices.STATUS = "PLACE_RESULT";
350
+ dices.STATUS = "SELECT_DICES_1";
351
+ // application.dices.STATUS = "FREE_TO_PLAY";
352
+ }
353
+ };
354
+
355
+ addEventListener('all-done', allDiceDoneProcedure)
356
+
357
+ addEventListener('FREE_TO_PLAY', () => {
358
+ // setup againt 3d space loc
359
+ console.info(' setup againt 3d space loc make some logic for pos ...')
360
+ app.matrixAmmo.getBodyByName('CubePhysics1').setLinearVelocity(new Ammo.btVector3(2, 2, 12))
361
+ app.matrixAmmo.getBodyByName('CubePhysics2').setLinearVelocity(new Ammo.btVector3(2, 2, 12))
362
+ app.matrixAmmo.getBodyByName('CubePhysics3').setLinearVelocity(new Ammo.btVector3(2, 2, 12))
363
+ app.matrixAmmo.getBodyByName('CubePhysics4').setLinearVelocity(new Ammo.btVector3(2, 2, 12))
364
+ app.matrixAmmo.getBodyByName('CubePhysics5').setLinearVelocity(new Ammo.btVector3(2, 2, 12))
365
+ app.matrixAmmo.getBodyByName('CubePhysics6').setLinearVelocity(new Ammo.btVector3(2, 2, 12))
366
+ })
367
+
368
+ // ACTIONS
369
+ let dice1Click = (e) => {
370
+ // console.info('DICE 1', e.detail)
371
+ dices.R[e.detail.cubeId] = '1';
372
+ dices.checkAll()
373
+ };
374
+ // addEventListener('dice-1', dice1Click)
375
+
376
+ let dice2Click = (e) => {
377
+ // console.info('DICE 2', e.detail)
378
+ dices.R[e.detail.cubeId] = '2';
379
+ dices.checkAll()
380
+ };
381
+ // addEventListener('dice-2', dice2Click)
382
+
383
+ let dice3Click = (e) => {
384
+ // console.info('DICE 3', e.detail)
385
+ dices.R[e.detail.cubeId] = '3';
386
+ dices.checkAll()
387
+ };
388
+ // addEventListener('dice-3', dice3Click)
389
+
390
+ let dice4Click = (e) => {
391
+ // console.info('DICE 4', e.detail)
392
+ dices.R[e.detail.cubeId] = '4';
393
+ dices.checkAll()
394
+ }
395
+ // addEventListener('dice-4', dice4Click)
396
+
397
+ let dice5Click = (e) => {
398
+ // console.info('DICE 5', e.detail)
399
+ dices.R[e.detail.cubeId] = '5';
400
+ dices.checkAll()
401
+ }
402
+ // addEventListener('dice-5', dice5Click)
403
+
404
+ let dice6Click = (e) => {
405
+ // console.info('DICE 6', e.detail)
406
+ dices.R[e.detail.cubeId] = '6';
407
+ dices.checkAll()
408
+ }
409
+ // addEventListener('dice-6', dice6Click)
410
+
411
+ let rollProcedure = () => {
412
+ if(dices.STATUS == "FREE_TO_PLAY") {
413
+
414
+ app.matrixSounds.play('start')
415
+
416
+ dices.STATUS = "IN_PLAY";
417
+ addEventListener('dice-1', dice1Click)
418
+ addEventListener('dice-2', dice2Click)
419
+ addEventListener('dice-3', dice3Click)
420
+ addEventListener('dice-4', dice4Click)
421
+ addEventListener('dice-5', dice5Click)
422
+ addEventListener('dice-6', dice6Click)
423
+
424
+ function shootDice(x) {
425
+ setTimeout(() => {
426
+ app.matrixAmmo.getBodyByName(`CubePhysics${x}`).setAngularVelocity(new Ammo.btVector3(
427
+ randomFloatFromTo(3, 12), 9, 9
428
+ ))
429
+ app.matrixAmmo.getBodyByName(`CubePhysics${x}`).setLinearVelocity(new Ammo.btVector3(
430
+ randomFloatFromTo(-5, 5), 15, -20
431
+ ))
432
+ }, 200 * x)
433
+ }
434
+ for(var x = 1;x < 7;x++) {
435
+ shootDice(x)
436
+ }
437
+
438
+
439
+ }
440
+ }
441
+
442
+ addEventListener('DICE.ROLL', rollProcedure)
443
+
444
+ app.ROLL = () => {
445
+ dispatchEvent(new CustomEvent('DICE.ROLL', {}))
446
+ }
447
+
448
+ }
55
449
  })
56
450
 
57
451
  window.app = application
@@ -0,0 +1,21 @@
1
+
2
+ app.matrixAmmo.rigidBodies[0].setAngularVelocity(new Ammo.btVector3(5,6,0))
3
+ app.matrixAmmo.rigidBodies[0].setLinearVelocity(new Ammo.btVector3(-0,16,1))
4
+
5
+
6
+ dice shema for now
7
+ ====================
8
+ FOR 4 gives 1
9
+ 2 6
10
+ 6 5
11
+ 1 2
12
+ 3 4
13
+ 5 3
14
+
15
+
16
+
17
+ https://phaser.discourse.group/t/disable-all-collision-impacts-matter-js/13715/2
18
+
19
+
20
+ https://stackoverflow.com/questions/17755848/is-it-possible-to-disable-x-z-rotation-in-ammo-js
21
+
Binary file
Binary file
package/package.json CHANGED
@@ -1,25 +1,39 @@
1
1
  {
2
2
  "name": "matrix-engine-wgpu",
3
- "version": "1.0.6",
4
- "description": "webGPU powered pwa application. Crazy fast rendering with AmmoJS physics support.",
3
+ "version": "1.1.0",
4
+ "description": "webGPU powered pwa application. Crazy fast rendering with AmmoJS physics support. Simple raycaster hit object added.",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "main-worker": "watchify app-worker.js -p [esmify --noImplicitAny] -o public/app-worker.js",
8
8
  "examples": "watchify examples.js -p [esmify --noImplicitAny] -o public/examples.js",
9
9
  "main": "watchify main.js -p [esmify --noImplicitAny] -o public/app.js",
10
- "build-empty": "watchify empty.js -p [esmify --noImplicitAny] -o public/empty.js",
11
- "build-all": "npm run main-worker | npm run examples | npm run main | npm run build-empty"
10
+ "empty": "watchify empty.js -p [esmify --noImplicitAny] -o public/empty.js",
11
+ "build-all": "npm run main-worker | npm run examples | npm run main | npm run empty",
12
+ "hosts": "http-server ./public/ -p 3000",
13
+ "build.demo1": "browserify main.js -p esmify > public/app.js"
12
14
  },
13
15
  "keywords": [
14
- "3dScene", "webGPU",
15
- "webGPU-scene", "webGPU-engine",
16
- "matrix", "matrix-engine",
17
- "matrix-engine-webGPU", "matrix-calculation",
18
- "modelView", "modelViewProjectionMatrix",
19
- "ProjectionMatrix", "render",
20
- "wgpu", "zlatnaspirala",
21
- "maximumroulette.com", "GLSL",
22
- "webgpu-obj-loader"
16
+ "3dScene",
17
+ "webGPU",
18
+ "webGPU-hit-detect",
19
+ "webGPU-raycaster",
20
+ "webGPU-click-on-object",
21
+ "webGPU-scene",
22
+ "webGPU-engine",
23
+ "matrix",
24
+ "matrix-engine",
25
+ "matrix-engine-webGPU",
26
+ "matrix-calculation",
27
+ "modelView",
28
+ "modelViewProjectionMatrix",
29
+ "ProjectionMatrix",
30
+ "render",
31
+ "wgpu",
32
+ "zlatnaspirala",
33
+ "maximumroulette.com",
34
+ "GLSL",
35
+ "webgpu-obj-loader",
36
+ "webgpu-fps"
23
37
  ],
24
38
  "author": "Nikola Lukic",
25
39
  "license": "MIT",
@@ -30,6 +44,7 @@
30
44
  "watchify": "^4.0.0"
31
45
  },
32
46
  "dependencies": {
47
+ "http-server": "^14.1.1",
33
48
  "wgpu-matrix": "^2.5.1"
34
49
  }
35
50
  }