matrix-engine-wgpu 1.0.4 → 1.0.6

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 (42) hide show
  1. package/REFERENCE.md +8 -0
  2. package/examples/load-obj-file.js +1 -8
  3. package/main.js +39 -20
  4. package/package.json +35 -41
  5. package/public/ammojs/ammo.js +957 -0
  6. package/public/ammojs/ammo.wasm.js +921 -0
  7. package/public/ammojs/ammo.wasm.wasm +0 -0
  8. package/public/app.js +607 -154
  9. package/public/css/style.css +6 -3
  10. package/public/empty.js +466 -84
  11. package/public/examples.js +466 -84
  12. package/public/index.html +4 -4
  13. package/public/res/fonts/Accuratist.ttf +0 -0
  14. package/public/res/fonts/Closeness.ttf +0 -0
  15. package/public/res/fonts/WARGAMES.TTF +0 -0
  16. package/public/res/fonts/readme.txt +5 -0
  17. package/public/res/fonts/stormfaze.ttf +0 -0
  18. package/public/res/meshes/blender/cube.blend +0 -0
  19. package/public/res/meshes/blender/cube.blend1 +0 -0
  20. package/public/res/meshes/blender/cube.mtl +12 -0
  21. package/public/res/meshes/blender/cube.obj +46 -0
  22. package/public/res/meshes/blender/cube.png +0 -0
  23. package/public/res/meshes/blender/cubeSmartUV.blend +0 -0
  24. package/public/res/meshes/blender/cubeSmartUV.mtl +12 -0
  25. package/public/res/meshes/blender/cubeSmartUV.obj +46 -0
  26. package/public/res/meshes/blender/lopta.mtl +10 -0
  27. package/public/res/meshes/blender/lopta.obj +3402 -0
  28. package/public/res/meshes/blender/sphepe.blend +0 -0
  29. package/public/res/meshes/blender/sphepe.blend1 +0 -0
  30. package/public/res/meshes/blender/sphere.mtl +10 -0
  31. package/public/res/meshes/blender/sphere.obj +3402 -0
  32. package/readme.md +161 -45
  33. package/src/engine/ball.js +3 -3
  34. package/src/engine/cube.js +3 -3
  35. package/src/engine/engine.js +2 -4
  36. package/src/engine/matrix-class.js +11 -6
  37. package/src/engine/mesh-obj.js +33 -35
  38. package/src/engine/mesh.js +4 -5
  39. package/src/engine/utils.js +347 -46
  40. package/src/physics/matrix-ammo.js +140 -0
  41. package/src/world.js +80 -84
  42. package/src/engine/matrix-mesh.js +0 -49
package/REFERENCE.md CHANGED
@@ -51,3 +51,11 @@ Most examples that have one render pass set loadOp: 'clear' but in the example a
51
51
  YEs this is happening " would erase the results from render pass 1 "
52
52
 
53
53
 
54
+
55
+ # https://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm
56
+
57
+
58
+
59
+ LOOK HERE
60
+
61
+ https://glm.g-truc.net/0.9.0/api/a00184.html
@@ -22,17 +22,11 @@ export let application = new MatrixEngineWGPU({
22
22
  texturesPaths: ['./res/textures/rust.jpg']
23
23
  };
24
24
 
25
- // let mesh = adaptJSON1(stanfordDragonData)
26
- // application.addBall(o)
27
- // application.addCube(c)
28
25
  application.addCube(o)
29
26
 
30
27
  function onLoadObj(m) {
31
28
  console.log('Loaded obj:', m.armor);
32
- // console.log('APP2 ', jsonPiramyd);
33
- // jsonPiramyd.vertexNormals = jsonPiramyd.normals;
34
- // jsonPiramyd.indices = jsonPiramyd.faces;
35
- // jsonPiramyd.textures = jsonPiramyd.uvs;
29
+
36
30
  application.addMeshObj({
37
31
  position: {x: 0, y: 0, z: -5},
38
32
  texturesPaths: ['./res/meshes/obj/armor.png'],
@@ -41,7 +35,6 @@ export let application = new MatrixEngineWGPU({
41
35
  })
42
36
  }
43
37
 
44
- // downloadMeshes({armor: "./res/meshes/obj/armor.obj"}, onLoadObj)
45
38
  downloadMeshes({armor: "./res/meshes/blender/piramyd.obj"}, onLoadObj)
46
39
  })
47
40
 
package/main.js CHANGED
@@ -1,38 +1,57 @@
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
4
 
4
5
  export let application = new MatrixEngineWGPU({
5
- useSingleRenderPass: false,
6
- canvasSize: 'fullscreen'
6
+ useSingleRenderPass: true,
7
+ canvasSize: 'fullscreen',
8
+ mainCameraParams: {
9
+ type: 'WASD',
10
+ responseCoef: 1000
11
+ }
7
12
  }, () => {
8
- function onLoadObj(m) {
9
13
 
10
- console.log('Loaded objs:', m);
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
+ }
11
28
 
12
29
  application.addMeshObj({
13
- position: {x: -3, y: 0, z: -5},
30
+ position: {x: 0, y: 2, z: -10},
14
31
  rotation: {x: 0, y: 0, z: 0},
15
- rotationSpeed: {x: 0, y: 10, z: 0},
16
- texturesPaths: ['./res/meshes/obj/armor.png'],
17
- name: 'Armor',
18
- mesh: m.armor
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
+ }
19
40
  })
20
41
 
21
42
  application.addMeshObj({
22
- position: {x: 3, y: 0, z: -5},
23
- rotation: {x: -90, y: 0, z: 0},
43
+ position: {x: 0, y: 2, z: -10},
44
+ rotation: {x: 0, y: 0, z: 0},
24
45
  rotationSpeed: {x: 0, y: 0, z: 0},
25
- texturesPaths: ['./res/meshes/obj/armor.png'],
26
- name: 'MyText',
27
- mesh: m.welcomeText
46
+ texturesPaths: ['./res/meshes/blender/cube.png'],
47
+ name: 'SpherePhysics',
48
+ mesh: m.sphere,
49
+ physics: {
50
+ enabled: true,
51
+ geometry: "Sphere"
52
+ }
28
53
  })
29
54
  }
30
-
31
- downloadMeshes({
32
- welcomeText: "./res/meshes/blender/piramyd.obj",
33
- armor: "./res/meshes/obj/armor.obj"
34
- }, onLoadObj)
35
-
36
55
  })
37
56
 
38
57
  window.app = application
package/package.json CHANGED
@@ -1,41 +1,35 @@
1
- {
2
- "name": "matrix-engine-wgpu",
3
- "version": "1.0.4",
4
- "description": "webGPU powered pwa application.Crazy fast rendering.",
5
- "main": "index.js",
6
- "scripts": {
7
- "main-worker": "watchify app-worker.js -p [esmify --noImplicitAny] -o public/app-worker.js",
8
- "examples": "watchify examples.js -p [esmify --noImplicitAny] -o public/examples.js",
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"
12
- },
13
- "keywords": [
14
- "webGPU",
15
- "webGPU-scene",
16
- "webGPU-engine",
17
- "matrix",
18
- "matrix-engine",
19
- "matrix-engine-webGPU",
20
- "matrix-calculation",
21
- "modelView",
22
- "modelViewProjectionMatrix",
23
- "ProjectionMatrix",
24
- "render",
25
- "wgpu",
26
- "zlatnaspirala",
27
- "maximumroulette.com",
28
- "GLSL"
29
- ],
30
- "author": "Nikola Lukic",
31
- "license": "MIT",
32
- "devDependencies": {
33
- "browser-resolve": "^2.0.0",
34
- "browserify": "^17.0.0",
35
- "esmify": "^2.1.1",
36
- "watchify": "^4.0.0"
37
- },
38
- "dependencies": {
39
- "wgpu-matrix": "^2.5.1"
40
- }
41
- }
1
+ {
2
+ "name": "matrix-engine-wgpu",
3
+ "version": "1.0.6",
4
+ "description": "webGPU powered pwa application. Crazy fast rendering with AmmoJS physics support.",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "main-worker": "watchify app-worker.js -p [esmify --noImplicitAny] -o public/app-worker.js",
8
+ "examples": "watchify examples.js -p [esmify --noImplicitAny] -o public/examples.js",
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"
12
+ },
13
+ "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"
23
+ ],
24
+ "author": "Nikola Lukic",
25
+ "license": "MIT",
26
+ "devDependencies": {
27
+ "browser-resolve": "^2.0.0",
28
+ "browserify": "^17.0.0",
29
+ "esmify": "^2.1.1",
30
+ "watchify": "^4.0.0"
31
+ },
32
+ "dependencies": {
33
+ "wgpu-matrix": "^2.5.1"
34
+ }
35
+ }