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.
- package/examples/glb-loader.js +74 -0
- package/examples/load-obj-file.js +9 -2
- package/examples/load-objs-sequence.js +8 -1
- package/examples/unlit-textures.js +3 -0
- package/examples.js +2 -6
- package/non-project-files/3d-jamb.png +0 -0
- package/package.json +23 -19
- package/public/app.js +24462 -12821
- package/public/examples.js +14125 -166
- package/public/index.html +1 -0
- package/public/res/meshes/glb/Capoeira-.fbx +0 -0
- package/public/res/meshes/glb/glb-test1.bvh +284 -0
- package/public/res/meshes/glb/model2.blend +0 -0
- package/public/res/meshes/glb/model2.blend1 +0 -0
- package/public/res/meshes/glb/test.glb +0 -0
- package/public/res/meshes/glb/textures/mutant.png +0 -0
- package/public/res/meshes/jamb/jamb-title.mtl +14 -4
- package/public/res/meshes/jamb/jamb-title.obj +57626 -26002
- package/public/res/meshes/jamb/jamb.blend +0 -0
- package/public/res/meshes/jamb/jamb.blend1 +0 -0
- package/public/res/multilang/en.json +2 -2
- package/public/res/multilang/sr.json +1 -1
- package/readme.md +15 -7
- package/src/engine/engine.js +35 -29
- package/src/engine/lights.js +35 -4
- package/src/engine/loaders/bvh.js +486 -0
- package/src/engine/loaders/webgpu-gltf.js +618 -0
- package/src/engine/materials.js +27 -84
- package/src/engine/mesh-obj.js +267 -55
- package/src/shaders/fragment.video.wgsl.js +0 -2
- package/src/shaders/vertex.wgsl.js +60 -8
- package/src/shaders/vertexShadow.wgsl.js +1 -1
- package/src/world.js +99 -27
|
@@ -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
|
-
|
|
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: [
|
|
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
|
package/examples.js
CHANGED
|
@@ -55,12 +55,8 @@ byId('video-texture').addEventListener("click", () => {
|
|
|
55
55
|
})
|
|
56
56
|
|
|
57
57
|
byId('jamb').addEventListener("click", () => {
|
|
58
|
-
|
|
59
|
-
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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
|
+
}
|