matrix-engine-wgpu 1.4.0 → 1.4.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.
- package/examples/camera-texture.js +2 -0
- package/examples/load-obj-file.js +6 -6
- package/examples/load-objs-sequence.js +8 -0
- package/examples/video-texture.js +13 -7
- package/package.json +4 -2
- package/public/examples.js +11117 -10888
- package/readme.md +19 -8
- package/src/engine/engine.js +1 -1
- package/src/engine/lights.js +177 -77
- package/src/engine/materials.js +125 -63
- package/src/engine/mesh-obj.js +91 -151
- package/src/shaders/fragment.video.wgsl.js +3 -2
- package/src/shaders/fragment.wgsl.js +77 -47
- package/src/shaders/shaders.js +0 -1
- package/src/shaders/vertex.wgsl.js +6 -20
- package/src/world.js +180 -70
|
@@ -22,7 +22,7 @@ export var loadObjFile = function() {
|
|
|
22
22
|
downloadMeshes({
|
|
23
23
|
cube: "./res/meshes/blender/cube.obj",
|
|
24
24
|
}, onGround,
|
|
25
|
-
{scale: [
|
|
25
|
+
{scale: [20, 1, 20]})
|
|
26
26
|
|
|
27
27
|
// loadObjFile.addLight();
|
|
28
28
|
})
|
|
@@ -52,28 +52,28 @@ export var loadObjFile = function() {
|
|
|
52
52
|
// console.log(`%c Loaded objs: ${key} `, LOG_MATRIX);
|
|
53
53
|
}
|
|
54
54
|
loadObjFile.addMeshObj({
|
|
55
|
-
position: {x: 0, y: 2, z: -
|
|
55
|
+
position: {x: 0, y: 2, z: -20},
|
|
56
56
|
rotation: {x: 0, y: 0, z: 0},
|
|
57
57
|
rotationSpeed: {x: 0, y: 0, z: 0},
|
|
58
58
|
texturesPaths: ['./res/meshes/blender/cube.png'],
|
|
59
59
|
name: 'cube1',
|
|
60
60
|
mesh: m.cube,
|
|
61
61
|
physics: {
|
|
62
|
-
enabled:
|
|
62
|
+
enabled: false,
|
|
63
63
|
geometry: "Cube",
|
|
64
64
|
},
|
|
65
65
|
// raycast: { enabled: true , radius: 2 }
|
|
66
66
|
})
|
|
67
67
|
|
|
68
68
|
loadObjFile.addMeshObj({
|
|
69
|
-
position: {x:
|
|
69
|
+
position: {x: 0, y: -1, z: -20},
|
|
70
70
|
rotation: {x: 0, y: 0, z: 0},
|
|
71
71
|
rotationSpeed: {x: 0, y: 111, z: 0},
|
|
72
72
|
texturesPaths: ['./res/meshes/blender/cube.png'],
|
|
73
73
|
name: 'ball1',
|
|
74
74
|
mesh: m.ball,
|
|
75
75
|
physics: {
|
|
76
|
-
enabled:
|
|
76
|
+
enabled: false,
|
|
77
77
|
geometry: "Sphere"
|
|
78
78
|
},
|
|
79
79
|
// raycast: { enabled: true , radius: 2 }
|
|
@@ -82,7 +82,7 @@ export var loadObjFile = function() {
|
|
|
82
82
|
var TEST = loadObjFile.getSceneObjectByName('cube2');
|
|
83
83
|
console.log(`%c Test access scene ${TEST} object.`, LOG_MATRIX);
|
|
84
84
|
loadObjFile.addLight();
|
|
85
|
-
loadObjFile.addLight();
|
|
85
|
+
// loadObjFile.addLight();
|
|
86
86
|
|
|
87
87
|
}
|
|
88
88
|
})
|
|
@@ -14,6 +14,14 @@ export var loadObjsSequence = function() {
|
|
|
14
14
|
}, () => {
|
|
15
15
|
|
|
16
16
|
addEventListener('AmmoReady', () => {
|
|
17
|
+
|
|
18
|
+
// requied now
|
|
19
|
+
loadObjFile.addLight();
|
|
20
|
+
|
|
21
|
+
// adapt
|
|
22
|
+
app.lightContainer[0].position[2] = -5;
|
|
23
|
+
app.lightContainer[0].position[1] = 22;
|
|
24
|
+
|
|
17
25
|
downloadMeshes(
|
|
18
26
|
makeObjSeqArg({
|
|
19
27
|
id: "swat-walk-pistol",
|
|
@@ -3,6 +3,7 @@ import {downloadMeshes} from '../src/engine/loader-obj.js';
|
|
|
3
3
|
import {LOG_FUNNY, LOG_INFO, LOG_MATRIX} from "../src/engine/utils.js";
|
|
4
4
|
import {addRaycastsAABBListener} from "../src/engine/raycast.js";
|
|
5
5
|
|
|
6
|
+
// @group(0) @binding(5) var<uniform> postFXMode: u32;
|
|
6
7
|
export var loadVideoTexture = function() {
|
|
7
8
|
|
|
8
9
|
let videoTexture = new MatrixEngineWGPU({
|
|
@@ -15,6 +16,11 @@ export var loadVideoTexture = function() {
|
|
|
15
16
|
clearColor: {r: 0, b: 0.122, g: 0.122, a: 1}
|
|
16
17
|
}, () => {
|
|
17
18
|
|
|
19
|
+
// For now one light perscene must be added.
|
|
20
|
+
// if you dont wanna light just use intesity = 0
|
|
21
|
+
// videoTexture is app main instance
|
|
22
|
+
videoTexture.addLight();
|
|
23
|
+
|
|
18
24
|
addEventListener('AmmoReady', () => {
|
|
19
25
|
downloadMeshes({
|
|
20
26
|
welcomeText: "./res/meshes/blender/piramyd.obj",
|
|
@@ -46,13 +52,13 @@ export var loadVideoTexture = function() {
|
|
|
46
52
|
})
|
|
47
53
|
|
|
48
54
|
var TEST = videoTexture.getSceneObjectByName('MyVideoTex');
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
|
|
56
|
+
console.log(`%c Test video-texture...`, LOG_MATRIX);
|
|
57
|
+
TEST.loadVideoTexture({
|
|
58
|
+
type: 'video',
|
|
59
|
+
src: 'res/videos/tunel.mp4'
|
|
60
|
+
});
|
|
61
|
+
|
|
56
62
|
}
|
|
57
63
|
})
|
|
58
64
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "matrix-engine-wgpu",
|
|
3
|
-
"version": "1.4.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.4.1",
|
|
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": {
|
|
7
7
|
"main-worker": "watchify app-worker.js -p [esmify --noImplicitAny] -o public/app-worker.js",
|
|
@@ -34,6 +34,8 @@
|
|
|
34
34
|
"zlatnaspirala",
|
|
35
35
|
"maximumroulette.com",
|
|
36
36
|
"GLSL",
|
|
37
|
+
"Lights",
|
|
38
|
+
"multi-spot-lights",
|
|
37
39
|
"raycast",
|
|
38
40
|
"hit-3d-object",
|
|
39
41
|
"hit-object",
|