matrix-engine-wgpu 1.1.0 → 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.
@@ -8,6 +8,12 @@ export let dices = {
8
8
  STATUS_H2: 'WAIT',
9
9
  STATUS_H3: 'WAIT',
10
10
  R: {},
11
+
12
+ SAVED_DICES: {},
13
+
14
+ pickDice: (dice) => {
15
+ this.SAVED_DICES[dice] = this.R[dice]
16
+ },
11
17
  checkAll: function() {
12
18
  this.C++;
13
19
  if(typeof this.R.CubePhysics1 != 'undefined' &&
@@ -17,9 +17,9 @@ export var unlitTextures = function() {
17
17
  let o = {
18
18
  scale: 2,
19
19
  position: {x: 3, y: 0, z: -10},
20
- rotation: {x: 0, y: 45, z: 0},
21
- rotationSpeed: {x: 0, y: 10, z: 0},
22
- texturesPaths: ['./res/textures/rust.jpg']
20
+ rotation: {x: 0, y: 0, z: 0},
21
+ rotationSpeed: {x: 10, y: 0, z: 0},
22
+ texturesPaths: ['./res/textures/default.png']
23
23
  };
24
24
  unlitTextures.addBall(c)
25
25
  unlitTextures.addCube(o)
package/index.js CHANGED
@@ -6,19 +6,25 @@
6
6
  import {degToRad} from "wgpu-matrix/dist/2.x/utils.js";
7
7
  import {downloadMeshes} from "./src/engine/loader-obj.js";
8
8
  import MatrixEngineWGPU from "./src/meWGPU.js";
9
+ import {getRayFromMouse, rayIntersectsSphere} from "./src/engine/raycast.js";
9
10
 
10
11
  var about = () => {
11
12
  console.log("Hi npm. matrix-engine for webgpu is ready...")
12
13
  console.log("--------------------------------------------")
13
- console.log("List of features : ")
14
+ console.log("List of features: ")
14
15
  console.log(" - Loading obj files with uvs")
15
- console.log(" - Scene oriented draws")
16
+ console.log(" - Scene camera use -z front")
16
17
  console.log(" - position, rotation - same like matrix-engine")
18
+ console.log(" - Physics used Ammo.js build")
19
+ console.log(" - Raycaster HIT/CLICK on object scene")
17
20
  }
18
21
 
19
22
  export {
20
23
  MatrixEngineWGPU,
21
24
  downloadMeshes,
25
+ rayIntersectsSphere,
26
+ getRayFromMouse,
27
+ addRaycastListener,
22
28
  degToRad,
23
29
  about
24
30
  }
package/main.js CHANGED
@@ -3,7 +3,7 @@ import {downloadMeshes} from './src/engine/loader-obj.js';
3
3
  import {LOG_FUNNY, LOG_INFO, LOG_MATRIX, randomFloatFromTo, randomIntFromTo} from "./src/engine/utils.js";
4
4
  import {dices, myDom} from "./examples/games/jamb/jamb.js";
5
5
  import {MatrixSounds} from "./src/sounds/sounds.js";
6
- import {addRaycastListener, touchCoordinate,rayIntersectsSphere, getRayFromMouse} from "./src/engine/raycast-test.js";
6
+ import {addRaycastListener, touchCoordinate, rayIntersectsSphere, getRayFromMouse} from "./src/engine/raycast.js";
7
7
 
8
8
  export let application = new MatrixEngineWGPU({
9
9
  useSingleRenderPass: true,
@@ -83,6 +83,18 @@ export let application = new MatrixEngineWGPU({
83
83
  }
84
84
 
85
85
  addRaycastListener();
86
+
87
+ addEventListener("ray.hit.event", (e) => {
88
+
89
+ console.log("hit cube ", e.detail.hitObject.name)
90
+
91
+ if(application.dices.STATUS == "FREE_TO_PLAY") {
92
+ console.log("hit cube status free to play prevent pick. ", e.detail.hitObject.name)
93
+ } else if(application.dices.STATUS == "SELECT_DICES_1") {
94
+ console.log("hit cube status SELECT1 pick.", e.detail.hitObject.name)
95
+ application.dices.pickDice(e.detail.hitObject.name)
96
+ }
97
+ });
86
98
  // OR add manual see readme
87
99
 
88
100
 
@@ -244,7 +256,7 @@ export let application = new MatrixEngineWGPU({
244
256
  useUVShema4x2: true,
245
257
  name: 'CubePhysics1',
246
258
  mesh: m.cube,
247
- raycast: {enabled: true},
259
+ raycast: {enabled: true, radius: 2},
248
260
  physics: {
249
261
  enabled: true,
250
262
  geometry: "Cube"
@@ -259,72 +271,72 @@ export let application = new MatrixEngineWGPU({
259
271
  useUVShema4x2: true,
260
272
  name: 'CubePhysics2',
261
273
  mesh: m.cube,
262
- raycast: {enabled: true},
274
+ raycast: {enabled: true, radius: 2},
275
+ physics: {
276
+ enabled: true,
277
+ geometry: "Cube"
278
+ }
279
+ })
280
+
281
+ application.addMeshObj({
282
+ position: {x: 4, y: 8, z: -10},
283
+ rotation: {x: 0, y: 0, z: 0},
284
+ rotationSpeed: {x: 0, y: 0, z: 0},
285
+ texturesPaths: ['./res/meshes/jamb/dice.png'],
286
+ useUVShema4x2: true,
287
+ name: 'CubePhysics3',
288
+ mesh: m.cube,
289
+ raycast: {enabled: true, radius: 2},
263
290
  physics: {
264
291
  enabled: true,
265
292
  geometry: "Cube"
266
293
  }
267
294
  })
268
295
 
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
- // })
296
+ application.addMeshObj({
297
+ position: {x: 3, y: 4, z: -10},
298
+ rotation: {x: 0, y: 0, z: 0},
299
+ rotationSpeed: {x: 0, y: 0, z: 0},
300
+ texturesPaths: ['./res/meshes/jamb/dice.png'],
301
+ useUVShema4x2: true,
302
+ name: 'CubePhysics4',
303
+ mesh: m.cube,
304
+ raycast: {enabled: true, radius: 2},
305
+ physics: {
306
+ enabled: true,
307
+ geometry: "Cube"
308
+ }
309
+ })
310
+
311
+ application.addMeshObj({
312
+ position: {x: -2, y: 4, z: -13},
313
+ rotation: {x: 0, y: 0, z: 0},
314
+ rotationSpeed: {x: 0, y: 0, z: 0},
315
+ texturesPaths: ['./res/meshes/jamb/dice.png'],
316
+ useUVShema4x2: true,
317
+ name: 'CubePhysics5',
318
+ mesh: m.cube,
319
+ raycast: {enabled: true,radius: 2},
320
+ physics: {
321
+ enabled: true,
322
+ geometry: "Cube"
323
+ }
324
+ })
325
+
326
+ application.addMeshObj({
327
+ position: {x: -4, y: 6, z: -9},
328
+ rotation: {x: 0, y: 0, z: 0},
329
+ rotationSpeed: {x: 0, y: 0, z: 0},
330
+ texturesPaths: ['./res/meshes/jamb/dice.png'],
331
+ useUVShema4x2: true,
332
+ name: 'CubePhysics6',
333
+ mesh: m.cube,
334
+ raycast: {enabled: true, radius: 2},
335
+ physics: {
336
+ enabled: true,
337
+ geometry: "Cube"
338
+ }
339
+ })
328
340
 
329
341
 
330
342
  application.TOLERANCE = 0;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "matrix-engine-wgpu",
3
- "version": "1.1.0",
4
- "description": "webGPU powered pwa application. Crazy fast rendering with AmmoJS physics support. Simple raycaster hit object added.",
3
+ "version": "1.1.1",
4
+ "description": "+HOTFIX raycast, 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",
@@ -32,6 +32,9 @@
32
32
  "zlatnaspirala",
33
33
  "maximumroulette.com",
34
34
  "GLSL",
35
+ "raycast",
36
+ "hit-3d-object",
37
+ "hit-object",
35
38
  "webgpu-obj-loader",
36
39
  "webgpu-fps"
37
40
  ],