matrix-engine-wgpu 1.4.4 → 1.4.5

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.
@@ -21,6 +21,11 @@ export var loadVideoTexture = function() {
21
21
  // videoTexture is app main instance
22
22
  videoTexture.addLight();
23
23
 
24
+ addRaycastsAABBListener();
25
+ videoTexture.canvas.addEventListener("ray.hit.event", (e) => {
26
+ console.log('test ray after shadows merge')
27
+ })
28
+
24
29
  addEventListener('AmmoReady', () => {
25
30
  downloadMeshes({
26
31
  welcomeText: "./res/meshes/blender/piramyd.obj",
@@ -48,7 +53,7 @@ export var loadVideoTexture = function() {
48
53
  enabled: true,
49
54
  geometry: "Cube"
50
55
  },
51
- // raycast: { enabled: true , radius: 2 }
56
+ raycast: {enabled: true, radius: 12}
52
57
  })
53
58
 
54
59
  var TEST = videoTexture.getSceneObjectByName('MyVideoTex');
package/main.js CHANGED
@@ -2,7 +2,7 @@ import MatrixEngineWGPU from "./src/world.js";
2
2
  import {downloadMeshes} from './src/engine/loader-obj.js';
3
3
  import {byId, LOG_FUNNY, LOG_INFO, LOG_MATRIX, mb, randomFloatFromTo, randomIntFromTo} from "./src/engine/utils.js";
4
4
  import {dices, myDom} from "./examples/games/jamb/jamb.js";
5
- import {addRaycastListener, touchCoordinate, rayIntersectsSphere, getRayFromMouse} from "./src/engine/raycast.js";
5
+ import {addRaycastsAABBListener, addRaycastListener, touchCoordinate, rayIntersectsSphere, getRayFromMouse} from "./src/engine/raycast.js";
6
6
 
7
7
  export let application = new MatrixEngineWGPU({
8
8
  useSingleRenderPass: true,
@@ -12,6 +12,20 @@ export let application = new MatrixEngineWGPU({
12
12
  responseCoef: 1000
13
13
  }
14
14
  }, () => {
15
+
16
+ application.addLight();
17
+ console.log('light added.')
18
+ application.lightContainer[0].outerCutoff = 0.5;
19
+ application.lightContainer[0].position[2] = -27;
20
+ application.lightContainer[0].intensity = 4;
21
+ application.lightContainer[0].target[2] = -25;
22
+ application.lightContainer[0].position[1] = 9;
23
+ application.globalAmbient[0] = 0.7;
24
+ application.globalAmbient[1] = 0.7;
25
+ application.globalAmbient[2] = 0.7;
26
+
27
+ const diceTexturePath = './res/meshes/jamb/dice.png';
28
+
15
29
  // Dom operations
16
30
  application.userState = {
17
31
  name: 'Guest',
@@ -23,7 +37,6 @@ export let application = new MatrixEngineWGPU({
23
37
  myDom.createBlocker();
24
38
  application.dices = dices;
25
39
 
26
-
27
40
  application.activateDiceClickListener = null;
28
41
 
29
42
  // -------------------------
@@ -140,7 +153,11 @@ export let application = new MatrixEngineWGPU({
140
153
  }
141
154
 
142
155
  addRaycastListener();
143
- addEventListener("ray.hit.event", (e) => {
156
+ // addRaycastsAABBListener();
157
+
158
+ application.canvas.addEventListener("ray.hit.event", (e) => {
159
+ console.log('ray.hit.event @@@@@@@@@@@@ detected');
160
+
144
161
  if(byId('topTitleDOM') && byId('topTitleDOM').getAttribute('data-gamestatus') != 'FREE' &&
145
162
  byId('topTitleDOM').getAttribute('data-gamestatus') != 'status-select') {
146
163
  console.log('no hit in middle of game ...');
@@ -164,7 +181,7 @@ export let application = new MatrixEngineWGPU({
164
181
 
165
182
  addEventListener('mousemove', (e) => {
166
183
  // console.log('only on click')
167
-
184
+
168
185
  })
169
186
 
170
187
  // Sounds
@@ -183,34 +200,18 @@ export let application = new MatrixEngineWGPU({
183
200
  cube: "./res/meshes/jamb/dice.obj",
184
201
  }, onLoadObj, {scale: [1, 1, 1], swap: [null]})
185
202
 
186
- downloadMeshes({
187
- star1: "./res/meshes/shapes/star1.obj",
188
- }, (m) => {
203
+ // downloadMeshes({
204
+ // star1: "./res/meshes/shapes/star1.obj",
205
+ // }, (m) => {
189
206
 
190
- let o = {
191
- scale: 2,
192
- position: {x: 3, y: 0, z: -10},
193
- rotation: {x: 0, y: 0, z: 0},
194
- rotationSpeed: {x: 10, y: 0, z: 0},
195
- texturesPaths: ['./res/textures/default.png']
196
- };
197
- // application.addCube(o)
198
-
199
- // application.addMeshObj({
200
- // position: {x: 0, y: 6, z: -5},
201
- // rotation: {x: 0, y: 0, z: 0},
202
- // rotationSpeed: {x: 0, y: 0, z: 0},
203
- // texturesPaths: ['./res/meshes/jamb/dice.png'],
204
- // useUVShema4x2: true,
205
- // name: 'star1',
206
- // mesh: m.star1,
207
- // raycast: {enabled: true, radius: 2},
208
- // physics: {
209
- // enabled: true,
210
- // geometry: "Cube"
211
- // }
212
- // })
213
- }, {scale: [11, 11, 11], swap: [null]})
207
+ // let o = {
208
+ // scale: 2,
209
+ // position: {x: 3, y: 0, z: -10},
210
+ // rotation: {x: 0, y: 0, z: 0},
211
+ // rotationSpeed: {x: 10, y: 0, z: 0},
212
+ // texturesPaths: ['./res/textures/default.png']
213
+ // };
214
+ // }, {scale: [11, 11, 11], swap: [null]})
214
215
 
215
216
  downloadMeshes({
216
217
  bg: "./res/meshes/jamb/bg.obj",
@@ -242,7 +243,8 @@ export let application = new MatrixEngineWGPU({
242
243
  mass: 0,
243
244
  enabled: true,
244
245
  geometry: "Cube"
245
- }
246
+ },
247
+ raycast: {enabled: false, radius: 2},
246
248
  })
247
249
 
248
250
  application.addMeshObj({
@@ -256,7 +258,8 @@ export let application = new MatrixEngineWGPU({
256
258
  mass: 0,
257
259
  enabled: true,
258
260
  geometry: "Cube"
259
- }
261
+ },
262
+ raycast: {enabled: false, radius: 2},
260
263
  })
261
264
  }, {scale: [25, 10, 4], swap: [null]})
262
265
 
@@ -280,7 +283,8 @@ export let application = new MatrixEngineWGPU({
280
283
  mass: 0,
281
284
  enabled: true,
282
285
  geometry: "Cube"
283
- }
286
+ },
287
+ raycast: {enabled: false, radius: 2},
284
288
  })
285
289
  }
286
290
 
@@ -297,11 +301,17 @@ export let application = new MatrixEngineWGPU({
297
301
  mass: 0,
298
302
  enabled: true,
299
303
  geometry: "Cube"
300
- }
304
+ },
305
+ raycast: {enabled: false, radius: 2},
301
306
  })
302
307
  // application.cameras.WASD.pitch = 0.2
303
308
  setTimeout(() => {
304
- app.cameras.WASD.velocity[1] = 18
309
+ // app.cameras.WASD.velocity[1] = 18
310
+ console.log('set camera position with timeout...')
311
+ app.cameras.WASD.yaw = -6.21;
312
+ app.cameras.WASD.pitch = -0.32;
313
+ app.cameras.WASD.position[2] = 0;
314
+ app.cameras.WASD.position[1] = 3.76;
305
315
  // BODY , x, y, z, rotX, rotY, RotZ
306
316
  app.matrixAmmo.setKinematicTransform(
307
317
  app.matrixAmmo.getBodyByName('mainTitle'), 0, 0, 0, 1)
@@ -326,7 +336,8 @@ export let application = new MatrixEngineWGPU({
326
336
  mass: 0,
327
337
  enabled: true,
328
338
  geometry: "Cube"
329
- }
339
+ },
340
+ raycast: {enabled: false, radius: 2},
330
341
  })
331
342
  }
332
343
 
@@ -337,7 +348,7 @@ export let application = new MatrixEngineWGPU({
337
348
  position: {x: 0, y: 6, z: -10},
338
349
  rotation: {x: 0, y: 0, z: 0},
339
350
  rotationSpeed: {x: 0, y: 0, z: 0},
340
- texturesPaths: ['./res/meshes/jamb/dice.png'],
351
+ texturesPaths: [diceTexturePath],
341
352
  useUVShema4x2: true,
342
353
  name: 'CubePhysics1',
343
354
  mesh: m.cube,
@@ -352,7 +363,7 @@ export let application = new MatrixEngineWGPU({
352
363
  position: {x: -5, y: 4, z: -14},
353
364
  rotation: {x: 0, y: 0, z: 0},
354
365
  rotationSpeed: {x: 0, y: 0, z: 0},
355
- texturesPaths: ['./res/meshes/jamb/dice.png'],
366
+ texturesPaths: [diceTexturePath],
356
367
  useUVShema4x2: true,
357
368
  name: 'CubePhysics2',
358
369
  mesh: m.cube,
@@ -367,7 +378,7 @@ export let application = new MatrixEngineWGPU({
367
378
  position: {x: 4, y: 8, z: -10},
368
379
  rotation: {x: 0, y: 0, z: 0},
369
380
  rotationSpeed: {x: 0, y: 0, z: 0},
370
- texturesPaths: ['./res/meshes/jamb/dice.png'],
381
+ texturesPaths: [diceTexturePath],
371
382
  useUVShema4x2: true,
372
383
  name: 'CubePhysics3',
373
384
  mesh: m.cube,
@@ -382,7 +393,7 @@ export let application = new MatrixEngineWGPU({
382
393
  position: {x: 3, y: 4, z: -10},
383
394
  rotation: {x: 0, y: 0, z: 0},
384
395
  rotationSpeed: {x: 0, y: 0, z: 0},
385
- texturesPaths: ['./res/meshes/jamb/dice.png'],
396
+ texturesPaths: [diceTexturePath],
386
397
  useUVShema4x2: true,
387
398
  name: 'CubePhysics4',
388
399
  mesh: m.cube,
@@ -397,7 +408,7 @@ export let application = new MatrixEngineWGPU({
397
408
  position: {x: -2, y: 4, z: -13},
398
409
  rotation: {x: 0, y: 0, z: 0},
399
410
  rotationSpeed: {x: 0, y: 0, z: 0},
400
- texturesPaths: ['./res/meshes/jamb/dice.png'],
411
+ texturesPaths: [diceTexturePath],
401
412
  useUVShema4x2: true,
402
413
  name: 'CubePhysics5',
403
414
  mesh: m.cube,
@@ -412,7 +423,7 @@ export let application = new MatrixEngineWGPU({
412
423
  position: {x: -4, y: 6, z: -9},
413
424
  rotation: {x: 0, y: 0, z: 0},
414
425
  rotationSpeed: {x: 0, y: 0, z: 0},
415
- texturesPaths: ['./res/meshes/jamb/dice.png'],
426
+ texturesPaths: [diceTexturePath],
416
427
  useUVShema4x2: true,
417
428
  name: 'CubePhysics6',
418
429
  mesh: m.cube,
@@ -436,6 +447,7 @@ export let application = new MatrixEngineWGPU({
436
447
  removeEventListener('dice-6', dice6Click)
437
448
  console.log(`%cFINAL<preliminar> ${dices.R}`, LOG_FUNNY)
438
449
  application.TOLERANCE = 0;
450
+ console.log('se camera position 2')
439
451
  app.cameras.WASD.yaw = 0.01;
440
452
  app.cameras.WASD.pitch = -1.26;
441
453
  app.cameras.WASD.position[2] = -18;
@@ -489,6 +501,8 @@ export let application = new MatrixEngineWGPU({
489
501
  setTimeout(() => {
490
502
  app.dices.activateAllDicesPhysics();
491
503
  }, 1000);
504
+
505
+ console.log('se camera position 3')
492
506
  app.cameras.WASD.yaw = 0;
493
507
  app.cameras.WASD.pitch = 0;
494
508
  app.cameras.WASD.position[2] = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matrix-engine-wgpu",
3
- "version": "1.4.4",
3
+ "version": "1.4.5",
4
4
  "description": "Fixed shadows casting vs camera/video texture, webGPU powered pwa application. Crazy fast rendering with AmmoJS physics support. Simple raycaster hit object added.",
5
5
  "main": "index.js",
6
6
  "scripts": {