matrix-engine-wgpu 1.4.7 → 1.5.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.
@@ -0,0 +1,74 @@
1
+ import MatrixEngineWGPU from "../src/world.js";
2
+ import {downloadMeshes} from '../src/engine/loader-obj.js';
3
+ import {LOG_FUNNY, LOG_INFO, LOG_MATRIX} from "../src/engine/utils.js";
4
+ import {loadBVH} from "../src/engine/loaders/bvh.js";
5
+ import {uploadGLBModel} from "../src/engine/loaders/webgpu-gltf.js";
6
+
7
+ let TEST_ANIM = new MatrixEngineWGPU({
8
+ useSingleRenderPass: true,
9
+ canvasSize: 'fullscreen',
10
+ mainCameraParams: {
11
+ type: 'WASD',
12
+ responseCoef: 1000
13
+ },
14
+ clearColor: {r: 0, b: 0.122, g: 0.122, a: 1}
15
+ }, () => {
16
+
17
+ addEventListener('AmmoReady', async () => {
18
+ setTimeout(() => {
19
+ app.cameras.WASD.yaw = -0.03;
20
+ app.cameras.WASD.pitch = -0.49;
21
+ app.cameras.WASD.position[2] = 0;
22
+ app.cameras.WASD.position[1] = 3.76;
23
+ }, 500)
24
+
25
+ downloadMeshes({cube: "./res/meshes/blender/cube.obj"}, onGround, {scale: [20, 1, 20]})
26
+ // const path = 'https://raw.githubusercontent.com/zlatnaspirala/Matrix-Engine-BVH-test/main/javascript-bvh/example.bvh';
27
+ const path = 'res/meshes/glb/glb-test1.bvh';
28
+
29
+ var glbFile = await fetch(
30
+ "res/meshes/glb/test.glb")
31
+ .then(res => res.arrayBuffer().then(buf => uploadGLBModel(buf, TEST_ANIM.device)));
32
+ TEST_ANIM.addGlbObj({
33
+ // scale: [1,1,1],
34
+ position: {x:0,y:-4,z:-20},
35
+ scale: [10, 10, 10],
36
+ name: 'firstGlb',
37
+ texturesPaths: ['./res/meshes/glb/textures/mutant.png'],
38
+ }, null, glbFile);
39
+
40
+
41
+ // loadBVH(path).then(async (BVHANIM) => {
42
+ // var glbFile = await fetch(
43
+ // "res/meshes/glb/test.glb")
44
+ // .then(res => res.arrayBuffer().then(buf => uploadGLBModel(buf, TEST_ANIM.device)));
45
+ // TEST_ANIM.addGlbObj({
46
+ // // scale: [1,1,1],
47
+ // scale: [10, 10, 10],
48
+ // name: 'firstGlb',
49
+ // texturesPaths: ['./res/textures/rust.jpg'],
50
+ // }, BVHANIM, glbFile);
51
+ // });
52
+ })
53
+
54
+ function onGround(m) {
55
+ TEST_ANIM.addLight();
56
+ TEST_ANIM.globalAmbient[1] = 1.5;
57
+
58
+ TEST_ANIM.addMeshObj({
59
+ position: {x: 0, y: -5, z: -10},
60
+ rotation: {x: 0, y: 0, z: 0},
61
+ rotationSpeed: {x: 0, y: 0, z: 0},
62
+ texturesPaths: ['./res/meshes/blender/cube.png'],
63
+ name: 'ground',
64
+ mesh: m.cube,
65
+ physics: {
66
+ enabled: false,
67
+ mass: 0,
68
+ geometry: "Cube"
69
+ },
70
+ })
71
+ }
72
+ })
73
+ // just for dev
74
+ window.app = TEST_ANIM;
@@ -24,11 +24,18 @@ export var loadObjFile = function() {
24
24
  }, onGround,
25
25
  {scale: [20, 1, 20]})
26
26
 
27
- // loadObjFile.addLight();
27
+ // loadObjFile.addLight();
28
28
  })
29
29
 
30
30
  function onGround(m) {
31
31
 
32
+ setTimeout(() => {
33
+ app.cameras.WASD.yaw = -0.03;
34
+ app.cameras.WASD.pitch = -0.49;
35
+ app.cameras.WASD.position[2] = 0;
36
+ app.cameras.WASD.position[1] = 3.76;
37
+ }, 500)
38
+
32
39
  loadObjFile.addMeshObj({
33
40
  position: {x: 0, y: -5, z: -10},
34
41
  rotation: {x: 0, y: 0, z: 0},
@@ -83,7 +90,7 @@ export var loadObjFile = function() {
83
90
  console.log(`%c Test access scene ${TEST} object.`, LOG_MATRIX);
84
91
 
85
92
  loadObjFile.addLight();
86
- loadObjFile.lightContainer[0].behavior.setOsc0(-1,1,0.1)
93
+ loadObjFile.lightContainer[0].behavior.setOsc0(-1, 1, 0.1)
87
94
  loadObjFile.lightContainer[0].behavior.value_ = -1;
88
95
  loadObjFile.lightContainer[0].updater.push((light) => {
89
96
  light.position[0] = light.behavior.setPath0()
@@ -30,7 +30,7 @@ export var loadObjsSequence = function() {
30
30
  to: 20
31
31
  }),
32
32
  onLoadObj,
33
- {scale: [10,10,10]}
33
+ {scale: [0.1,0.1,0.1]}
34
34
  );
35
35
  })
36
36
 
@@ -69,6 +69,13 @@ export var loadObjsSequence = function() {
69
69
  objAnim: objAnim
70
70
  })
71
71
  app.mainRenderBundle[0].objAnim.play('walk');
72
+
73
+ setTimeout(()=> {
74
+ app.cameras.WASD.pitch = -0.2605728267949113;
75
+ app.cameras.WASD.yaw = -0.0580;
76
+ app.cameras.WASD.position[1] = 15
77
+ app.cameras.WASD.position[2] = 11
78
+ }, 200)
72
79
  }
73
80
  })
74
81
  // Just for dev - easy console access
@@ -23,6 +23,9 @@ export var unlitTextures = function() {
23
23
  };
24
24
  unlitTextures.addCube(o)
25
25
  unlitTextures.addBall(c)
26
+
27
+ // just to fix warns
28
+ unlitTextures.addLight()
26
29
  });
27
30
  })
28
31
 
package/examples.js CHANGED
@@ -55,12 +55,8 @@ byId('video-texture').addEventListener("click", () => {
55
55
  })
56
56
 
57
57
  byId('jamb').addEventListener("click", () => {
58
- // byId('unlitTextures').setAttribute('disabled', true)
59
- // byId('loadObjFile').setAttribute('disabled', true)
60
- // byId('jamb').removeAttribute('disabled')
61
- if(typeof app !== "undefined") app.destroyProgram()
62
- destroyJambDoms();
63
- // loadJamb()
58
+
59
+ open("https://maximumroulette.com/apps/webgpu/");
64
60
  })
65
61
 
66
62
  byId('objs-anim').addEventListener("click", () => {
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matrix-engine-wgpu",
3
- "version": "1.4.7",
3
+ "version": "1.5.0",
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": {
@@ -10,7 +10,25 @@
10
10
  "empty": "watchify empty.js -p [esmify --noImplicitAny] -o public/empty.js",
11
11
  "build-all": "npm run main-worker | npm run examples | npm run main | npm run empty",
12
12
  "hosts": "http-server ./public/ -p 3000",
13
- "build.demo1": "browserify main.js -p esmify > public/app.js"
13
+ "build.test": "browserify main.js -p esmify > public/app.js",
14
+ "glb-loader": "watchify ./examples/glb-loader.js -p [esmify --noImplicitAny] -o public/app.js"
15
+ },
16
+ "author": "Nikola Lukic",
17
+ "license": "MIT",
18
+ "devDependencies": {
19
+ "browser-resolve": "^2.0.0",
20
+ "browserify": "^17.0.0",
21
+ "esmify": "^2.1.1",
22
+ "watchify": "^4.0.0",
23
+ "wgpu-matrix": "^2.0.0",
24
+ "http-server": "^14.1.1"
25
+ },
26
+ "dependencies": {
27
+ "bvh-loader": "1.0.10",
28
+ "gl-matrix": "^3.4.4"
29
+ },
30
+ "peerDependencies": {
31
+ "wgpu-matrix": "^2.0.0"
14
32
  },
15
33
  "keywords": [
16
34
  "3dScene",
@@ -35,26 +53,12 @@
35
53
  "maximumroulette.com",
36
54
  "GLSL",
37
55
  "Lights",
56
+ "shadows-cast",
38
57
  "multi-spot-lights",
39
58
  "raycast",
40
59
  "hit-3d-object",
41
60
  "hit-object",
42
61
  "webgpu-obj-loader",
43
62
  "webgpu-fps"
44
- ],
45
- "author": "Nikola Lukic",
46
- "license": "MIT",
47
- "devDependencies": {
48
- "browser-resolve": "^2.0.0",
49
- "browserify": "^17.0.0",
50
- "esmify": "^2.1.1",
51
- "watchify": "^4.0.0",
52
- "wgpu-matrix": "^2.0.0"
53
- },
54
- "dependencies": {
55
- "http-server": "^14.1.1"
56
- },
57
- "peerDependencies": {
58
- "wgpu-matrix": "^2.0.0"
59
- }
60
- }
63
+ ]
64
+ }