matrix-engine-wgpu 1.3.16 → 1.3.18
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/.codesandbox/tasks.json +46 -0
- package/.devcontainer/devcontainer.json +22 -0
- package/.github/dependabot.yml +12 -0
- package/REFERENCE.md +59 -0
- package/app-worker.js +45 -0
- package/dev.md +541 -0
- package/empty.js +17 -0
- package/examples/camera-texture.js +60 -0
- package/examples/games/jamb/html-content.js +128 -0
- package/examples/games/jamb/jamb.js +1341 -0
- package/examples/games/jamb/readme.md +3 -0
- package/examples/load-jamb.js +6 -0
- package/examples/load-obj-file.js +95 -0
- package/examples/load-objs-sequence.js +68 -0
- package/examples/unlit-textures.js +31 -0
- package/examples/video-texture.js +61 -0
- package/examples.js +73 -0
- package/main.js +635 -0
- package/non-project-files/cubebuffer-example.js +51 -0
- package/non-project-files/dev.txt +21 -0
- package/non-project-files/image1.png +0 -0
- package/non-project-files/image6.png +0 -0
- package/package.json +2 -5
- package/public/ammojs/ammo.js +957 -0
- package/public/ammojs/ammo.wasm.js +921 -0
- package/public/ammojs/ammo.wasm.wasm +0 -0
- package/public/app-worker.js +47 -0
- package/public/app.js +12744 -0
- package/public/css/style.css +711 -0
- package/public/empty.html +25 -0
- package/public/empty.js +10453 -0
- package/public/examples.html +30 -0
- package/public/examples.js +11217 -0
- package/public/index.html +20 -0
- package/public/manifest copy.web +35 -0
- package/public/manifest.web +25 -0
- package/public/res/audios/block.mp3 +0 -0
- package/public/res/audios/dice-roll.mp3 +0 -0
- package/public/res/audios/dice1.mp3 +0 -0
- package/public/res/audios/dice2.mp3 +0 -0
- package/public/res/audios/kenney/Kenney.url +2 -0
- package/public/res/audios/kenney/License.txt +22 -0
- package/public/res/audios/kenney/Patreon.url +2 -0
- package/public/res/audios/kenney/audios/back_001.ogg +0 -0
- package/public/res/audios/kenney/audios/back_002.ogg +0 -0
- package/public/res/audios/kenney/audios/back_003.ogg +0 -0
- package/public/res/audios/kenney/audios/back_004.ogg +0 -0
- package/public/res/audios/kenney/audios/bong_001.ogg +0 -0
- package/public/res/audios/kenney/audios/click_001.ogg +0 -0
- package/public/res/audios/kenney/audios/click_002.ogg +0 -0
- package/public/res/audios/kenney/audios/click_003.ogg +0 -0
- package/public/res/audios/kenney/audios/click_004.ogg +0 -0
- package/public/res/audios/kenney/audios/click_005.ogg +0 -0
- package/public/res/audios/kenney/audios/close_001.ogg +0 -0
- package/public/res/audios/kenney/audios/close_002.ogg +0 -0
- package/public/res/audios/kenney/audios/close_003.ogg +0 -0
- package/public/res/audios/kenney/audios/close_004.ogg +0 -0
- package/public/res/audios/kenney/audios/confirmation_001.ogg +0 -0
- package/public/res/audios/kenney/audios/confirmation_002.ogg +0 -0
- package/public/res/audios/kenney/audios/confirmation_003.ogg +0 -0
- package/public/res/audios/kenney/audios/confirmation_004.ogg +0 -0
- package/public/res/audios/kenney/audios/drop_001.ogg +0 -0
- package/public/res/audios/kenney/audios/drop_002.ogg +0 -0
- package/public/res/audios/kenney/audios/drop_003.ogg +0 -0
- package/public/res/audios/kenney/audios/drop_004.ogg +0 -0
- package/public/res/audios/kenney/audios/error_001.ogg +0 -0
- package/public/res/audios/kenney/audios/error_002.ogg +0 -0
- package/public/res/audios/kenney/audios/error_003.ogg +0 -0
- package/public/res/audios/kenney/audios/error_004.ogg +0 -0
- package/public/res/audios/kenney/audios/error_005.ogg +0 -0
- package/public/res/audios/kenney/audios/error_006.ogg +0 -0
- package/public/res/audios/kenney/audios/error_007.ogg +0 -0
- package/public/res/audios/kenney/audios/error_008.ogg +0 -0
- package/public/res/audios/kenney/audios/glass_001.ogg +0 -0
- package/public/res/audios/kenney/audios/glass_002.ogg +0 -0
- package/public/res/audios/kenney/audios/glass_003.ogg +0 -0
- package/public/res/audios/kenney/audios/glass_004.ogg +0 -0
- package/public/res/audios/kenney/audios/glass_005.ogg +0 -0
- package/public/res/audios/kenney/audios/glass_006.ogg +0 -0
- package/public/res/audios/kenney/audios/glitch_001.ogg +0 -0
- package/public/res/audios/kenney/audios/glitch_002.ogg +0 -0
- package/public/res/audios/kenney/audios/glitch_003.ogg +0 -0
- package/public/res/audios/kenney/audios/glitch_004.ogg +0 -0
- package/public/res/audios/kenney/audios/maximize_001.ogg +0 -0
- package/public/res/audios/kenney/audios/maximize_002.ogg +0 -0
- package/public/res/audios/kenney/audios/maximize_003.ogg +0 -0
- package/public/res/audios/kenney/audios/maximize_004.ogg +0 -0
- package/public/res/audios/kenney/audios/maximize_005.ogg +0 -0
- package/public/res/audios/kenney/audios/maximize_006.ogg +0 -0
- package/public/res/audios/kenney/audios/maximize_007.ogg +0 -0
- package/public/res/audios/kenney/audios/maximize_008.ogg +0 -0
- package/public/res/audios/kenney/audios/maximize_009.ogg +0 -0
- package/public/res/audios/kenney/audios/minimize_001.ogg +0 -0
- package/public/res/audios/kenney/audios/minimize_002.ogg +0 -0
- package/public/res/audios/kenney/audios/minimize_003.ogg +0 -0
- package/public/res/audios/kenney/audios/minimize_004.ogg +0 -0
- package/public/res/audios/kenney/audios/minimize_005.ogg +0 -0
- package/public/res/audios/kenney/audios/minimize_006.ogg +0 -0
- package/public/res/audios/kenney/audios/minimize_007.ogg +0 -0
- package/public/res/audios/kenney/audios/minimize_008.ogg +0 -0
- package/public/res/audios/kenney/audios/minimize_009.ogg +0 -0
- package/public/res/audios/kenney/audios/open_001.ogg +0 -0
- package/public/res/audios/kenney/audios/open_002.ogg +0 -0
- package/public/res/audios/kenney/audios/open_003.ogg +0 -0
- package/public/res/audios/kenney/audios/open_004.ogg +0 -0
- package/public/res/audios/kenney/audios/pluck_001.ogg +0 -0
- package/public/res/audios/kenney/audios/pluck_002.ogg +0 -0
- package/public/res/audios/kenney/audios/question_001.ogg +0 -0
- package/public/res/audios/kenney/audios/question_002.ogg +0 -0
- package/public/res/audios/kenney/audios/question_003.ogg +0 -0
- package/public/res/audios/kenney/audios/question_004.ogg +0 -0
- package/public/res/audios/kenney/audios/scratch_001.ogg +0 -0
- package/public/res/audios/kenney/audios/scratch_002.ogg +0 -0
- package/public/res/audios/kenney/audios/scratch_003.ogg +0 -0
- package/public/res/audios/kenney/audios/scratch_004.ogg +0 -0
- package/public/res/audios/kenney/audios/scratch_005.ogg +0 -0
- package/public/res/audios/kenney/audios/scroll_001.ogg +0 -0
- package/public/res/audios/kenney/audios/scroll_002.ogg +0 -0
- package/public/res/audios/kenney/audios/scroll_003.ogg +0 -0
- package/public/res/audios/kenney/audios/scroll_004.ogg +0 -0
- package/public/res/audios/kenney/audios/scroll_005.ogg +0 -0
- package/public/res/audios/kenney/audios/select_001.ogg +0 -0
- package/public/res/audios/kenney/audios/select_002.ogg +0 -0
- package/public/res/audios/kenney/audios/select_003.ogg +0 -0
- package/public/res/audios/kenney/audios/select_004.ogg +0 -0
- package/public/res/audios/kenney/audios/select_005.ogg +0 -0
- package/public/res/audios/kenney/audios/select_006.ogg +0 -0
- package/public/res/audios/kenney/audios/select_007.ogg +0 -0
- package/public/res/audios/kenney/audios/select_008.ogg +0 -0
- package/public/res/audios/kenney/audios/switch_001.ogg +0 -0
- package/public/res/audios/kenney/audios/switch_002.ogg +0 -0
- package/public/res/audios/kenney/audios/switch_003.ogg +0 -0
- package/public/res/audios/kenney/audios/switch_004.ogg +0 -0
- package/public/res/audios/kenney/audios/switch_005.ogg +0 -0
- package/public/res/audios/kenney/audios/switch_006.ogg +0 -0
- package/public/res/audios/kenney/audios/switch_007.ogg +0 -0
- package/public/res/audios/kenney/audios/tick_001.ogg +0 -0
- package/public/res/audios/kenney/audios/tick_002.ogg +0 -0
- package/public/res/audios/kenney/audios/tick_004.ogg +0 -0
- package/public/res/audios/kenney/audios/toggle_001.ogg +0 -0
- package/public/res/audios/kenney/audios/toggle_002.ogg +0 -0
- package/public/res/audios/kenney/audios/toggle_003.ogg +0 -0
- package/public/res/audios/kenney/audios/toggle_004.ogg +0 -0
- package/public/res/audios/start.mp3 +0 -0
- package/public/res/audios/toggle_002.mp3 +0 -0
- package/public/res/fonts/Accuratist.ttf +0 -0
- package/public/res/fonts/Closeness.ttf +0 -0
- package/public/res/fonts/WARGAMES.TTF +0 -0
- package/public/res/fonts/readme.txt +5 -0
- package/public/res/fonts/stormfaze.ttf +0 -0
- package/public/res/icons/512.png +0 -0
- package/public/res/icons/webgpu-horizontal.svg +45 -0
- package/public/res/meshes/blender/cube.blend +0 -0
- package/public/res/meshes/blender/cube.blend1 +0 -0
- package/public/res/meshes/blender/cube.mtl +12 -0
- package/public/res/meshes/blender/cube.obj +46 -0
- package/public/res/meshes/blender/cube.png +0 -0
- package/public/res/meshes/blender/cubeSmartUV.blend +0 -0
- package/public/res/meshes/blender/cubeSmartUV.mtl +12 -0
- package/public/res/meshes/blender/cubeSmartUV.obj +46 -0
- package/public/res/meshes/blender/lopta.mtl +10 -0
- package/public/res/meshes/blender/lopta.obj +3402 -0
- package/public/res/meshes/blender/piramyd.blend +0 -0
- package/public/res/meshes/blender/piramyd.blend1 +0 -0
- package/public/res/meshes/blender/piramyd.js +42 -0
- package/public/res/meshes/blender/piramyd.mtl +10 -0
- package/public/res/meshes/blender/piramyd.obj +18696 -0
- package/public/res/meshes/blender/piramyd1.js +42 -0
- package/public/res/meshes/blender/sphepe.blend +0 -0
- package/public/res/meshes/blender/sphepe.blend1 +0 -0
- package/public/res/meshes/blender/sphere.mtl +10 -0
- package/public/res/meshes/blender/sphere.obj +3402 -0
- package/public/res/meshes/blender/welcomeTextblend.blend +0 -0
- package/public/res/meshes/dragon/stanfordDragonData.js +5 -0
- package/public/res/meshes/jamb/bg.blend +0 -0
- package/public/res/meshes/jamb/bg.blend1 +0 -0
- package/public/res/meshes/jamb/bg.mtl +12 -0
- package/public/res/meshes/jamb/bg.obj +17 -0
- package/public/res/meshes/jamb/bg.png +0 -0
- package/public/res/meshes/jamb/dice-default.png +0 -0
- package/public/res/meshes/jamb/dice-mark.png +0 -0
- package/public/res/meshes/jamb/dice.mtl +12 -0
- package/public/res/meshes/jamb/dice.obj +40 -0
- package/public/res/meshes/jamb/dice.png +0 -0
- package/public/res/meshes/jamb/jamb-title.mtl +12 -0
- package/public/res/meshes/jamb/jamb-title.obj +26008 -0
- package/public/res/meshes/jamb/jamb.blend +0 -0
- package/public/res/meshes/jamb/jamb.blend1 +0 -0
- package/public/res/meshes/jamb/logo.png +0 -0
- package/public/res/meshes/jamb/nidzaDice.blend +0 -0
- package/public/res/meshes/jamb/nidzaDice.blend1 +0 -0
- package/public/res/meshes/jamb/pile.blend +0 -0
- package/public/res/meshes/jamb/simpleCube.blend +0 -0
- package/public/res/meshes/jamb/simpleCube.blend1 +0 -0
- package/public/res/meshes/jamb/sounds/roll1.wav +0 -0
- package/public/res/meshes/jamb/text.png +0 -0
- package/public/res/meshes/obj/armor.obj +319 -0
- package/public/res/meshes/obj/armor.png +0 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000001.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000001.obj +23264 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000002.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000002.obj +23261 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000003.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000003.obj +23264 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000004.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000004.obj +23261 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000005.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000005.obj +23261 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000006.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000006.obj +23261 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000007.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000007.obj +23264 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000008.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000008.obj +23263 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000009.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000009.obj +23264 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000010.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000010.obj +23260 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000011.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000011.obj +23262 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000012.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000012.obj +23262 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000013.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000013.obj +23263 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000014.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000014.obj +23262 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000015.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000015.obj +23263 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000016.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000016.obj +23264 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000017.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000017.obj +23263 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000018.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000018.obj +23261 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000019.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000019.obj +23263 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000020.mtl +22 -0
- package/public/res/meshes/objs-sequence/swat-walk-pistol_000020.obj +23261 -0
- package/public/res/meshes/shapes/star1.obj +60 -0
- package/public/res/multilang/en.json +39 -0
- package/public/res/multilang/sr.json +39 -0
- package/public/res/textures/default.png +0 -0
- package/public/res/textures/rust.jpg +0 -0
- package/public/res/textures/tex1.jpg +0 -0
- package/public/res/videos/readme.txt +2 -0
- package/public/res/videos/tunel.mp4 +0 -0
- package/public/test.html +636 -0
- package/public/three-test.js +165 -0
- package/public/worker.html +25 -0
- package/src/engine/ball.js +482 -0
- package/src/engine/cube.js +496 -0
- package/src/engine/engine.js +404 -0
- package/src/engine/final/adaptJSON1.js +53 -0
- package/src/engine/final/utils2.js +63 -0
- package/src/engine/lights.js +153 -0
- package/src/engine/loader-obj.js +473 -0
- package/src/engine/materials.js +295 -0
- package/src/engine/matrix-class.js +252 -0
- package/src/engine/mesh-obj.js +574 -0
- package/src/engine/raycast.js +218 -0
- package/src/engine/utils.js +881 -0
- package/src/libs/mat.js +0 -0
- package/src/multilang/lang.js +35 -0
- package/src/physics/matrix-ammo.js +363 -0
- package/src/shaders/fragment.video.wgsl.js +83 -0
- package/src/shaders/fragment.wgsl.js +75 -0
- package/src/shaders/shaders.js +51 -0
- package/src/shaders/standard-matrix-engine-shaders/standard-matrix-engine-fs.glsl +56 -0
- package/src/shaders/standard-matrix-engine-shaders/standard-matrix-engine-vs.glsl +75 -0
- package/src/shaders/vertex.wgsl.js +54 -0
- package/src/shaders/vertexShadow.wgsl.js +20 -0
- package/src/sounds/sounds.js +69 -0
- package/src/world.js +474 -0
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
Sound Effect by <a href="https://pixabay.com/users/u_qpfzpydtro-29496424/?utm_source=link-attribution&utm_medium=referral&utm_campaign=music&utm_content=142528">u_qpfzpydtro</a> from <a href="https://pixabay.com//?utm_source=link-attribution&utm_medium=referral&utm_campaign=music&utm_content=142528">Pixabay</a>
|
|
@@ -0,0 +1,95 @@
|
|
|
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 {addRaycastsAABBListener} from "../src/engine/raycast.js";
|
|
5
|
+
|
|
6
|
+
export var loadObjFile = function() {
|
|
7
|
+
|
|
8
|
+
let loadObjFile = new MatrixEngineWGPU({
|
|
9
|
+
useSingleRenderPass: true,
|
|
10
|
+
canvasSize: 'fullscreen',
|
|
11
|
+
mainCameraParams: {
|
|
12
|
+
type: 'WASD',
|
|
13
|
+
responseCoef: 1000
|
|
14
|
+
},
|
|
15
|
+
clearColor: {r: 0, b: 0.122, g: 0.122, a: 1}
|
|
16
|
+
}, () => {
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
// loadObjFile.addLight()
|
|
20
|
+
|
|
21
|
+
addEventListener('AmmoReady', () => {
|
|
22
|
+
downloadMeshes({
|
|
23
|
+
ball: "./res/meshes/blender/sphere.obj",
|
|
24
|
+
cube: "./res/meshes/blender/cube.obj",
|
|
25
|
+
}, onLoadObj,
|
|
26
|
+
{scale: [1, 1, 1]})
|
|
27
|
+
downloadMeshes({
|
|
28
|
+
cube: "./res/meshes/blender/cube.obj",
|
|
29
|
+
}, onGround,
|
|
30
|
+
{scale: [25, 0.1, 25]})
|
|
31
|
+
|
|
32
|
+
// loadObjFile.addLight();
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
function onGround(m) {
|
|
36
|
+
|
|
37
|
+
loadObjFile.addMeshObj({
|
|
38
|
+
position: {x: 0, y: -5, z: -10},
|
|
39
|
+
rotation: {x: 0, y: 0, z: 0},
|
|
40
|
+
rotationSpeed: {x: 0, y: 0, z: 0},
|
|
41
|
+
texturesPaths: ['./res/meshes/blender/cube.png'],
|
|
42
|
+
name: 'ground',
|
|
43
|
+
mesh: m.cube,
|
|
44
|
+
physics: {
|
|
45
|
+
enabled: false,
|
|
46
|
+
mass: 0,
|
|
47
|
+
geometry: "Cube"
|
|
48
|
+
},
|
|
49
|
+
// raycast: { enabled: true , radius: 2 }
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function onLoadObj(m) {
|
|
55
|
+
loadObjFile.myLoadedMeshes = m;
|
|
56
|
+
for(var key in m) {
|
|
57
|
+
console.log(`%c Loaded objs: ${key} `, LOG_MATRIX);
|
|
58
|
+
}
|
|
59
|
+
loadObjFile.addMeshObj({
|
|
60
|
+
position: {x: 0, y: 2, z: -10},
|
|
61
|
+
rotation: {x: 0, y: 0, z: 0},
|
|
62
|
+
rotationSpeed: {x: 0, y: 0, z: 0},
|
|
63
|
+
texturesPaths: ['./res/meshes/blender/cube.png'],
|
|
64
|
+
name: 'cube1',
|
|
65
|
+
mesh: m.cube,
|
|
66
|
+
physics: {
|
|
67
|
+
enabled: true,
|
|
68
|
+
geometry: "Cube",
|
|
69
|
+
},
|
|
70
|
+
// raycast: { enabled: true , radius: 2 }
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
loadObjFile.addMeshObj({
|
|
74
|
+
position: {x: 3, y: 2, z: -15},
|
|
75
|
+
rotation: {x: 0, y: 0, z: 0},
|
|
76
|
+
rotationSpeed: {x: 0, y: 111, z: 0},
|
|
77
|
+
texturesPaths: ['./res/meshes/blender/cube.png'],
|
|
78
|
+
name: 'ball1',
|
|
79
|
+
mesh: m.ball,
|
|
80
|
+
physics: {
|
|
81
|
+
enabled: true,
|
|
82
|
+
geometry: "Sphere"
|
|
83
|
+
},
|
|
84
|
+
// raycast: { enabled: true , radius: 2 }
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
var TEST = loadObjFile.getSceneObjectByName('cube2');
|
|
88
|
+
console.log(`%c Test access scene ${TEST} object.`, LOG_MATRIX);
|
|
89
|
+
|
|
90
|
+
loadObjFile.addLight();
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
// just for dev
|
|
94
|
+
window.app = loadObjFile;
|
|
95
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import MatrixEngineWGPU from "../src/world.js";
|
|
2
|
+
import {downloadMeshes, makeObjSeqArg} from '../src/engine/loader-obj.js';
|
|
3
|
+
import {LOG_MATRIX} from "../src/engine/utils.js";
|
|
4
|
+
|
|
5
|
+
export var loadObjsSequence = function() {
|
|
6
|
+
|
|
7
|
+
let loadObjFile = new MatrixEngineWGPU({
|
|
8
|
+
useSingleRenderPass: true,
|
|
9
|
+
canvasSize: 'fullscreen',
|
|
10
|
+
mainCameraParams: {
|
|
11
|
+
type: 'WASD',
|
|
12
|
+
responseCoef: 1000
|
|
13
|
+
}
|
|
14
|
+
}, () => {
|
|
15
|
+
|
|
16
|
+
addEventListener('AmmoReady', () => {
|
|
17
|
+
downloadMeshes(
|
|
18
|
+
makeObjSeqArg({
|
|
19
|
+
id: "swat-walk-pistol",
|
|
20
|
+
path: "res/meshes/objs-sequence/swat-walk-pistol",
|
|
21
|
+
from: 1,
|
|
22
|
+
to: 20
|
|
23
|
+
}),
|
|
24
|
+
onLoadObj,
|
|
25
|
+
{scale: [10,10,10]}
|
|
26
|
+
);
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
function onLoadObj(m) {
|
|
30
|
+
console.log(`%c Loaded objs: ${m} `, LOG_MATRIX);
|
|
31
|
+
var objAnim = {
|
|
32
|
+
id: "swat-walk-pistol",
|
|
33
|
+
meshList: m,
|
|
34
|
+
currentAni: 1,
|
|
35
|
+
animations: {
|
|
36
|
+
active: 'walk',
|
|
37
|
+
walk: {
|
|
38
|
+
from: 1,
|
|
39
|
+
to: 20,
|
|
40
|
+
speed: 3
|
|
41
|
+
},
|
|
42
|
+
walkPistol: {
|
|
43
|
+
from: 36,
|
|
44
|
+
to: 60,
|
|
45
|
+
speed: 3
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
loadObjFile.addMeshObj({
|
|
50
|
+
position: {x: 0, y: 2, z: -10},
|
|
51
|
+
rotation: {x: 0, y: 0, z: 0},
|
|
52
|
+
rotationSpeed: {x: 0, y: 0, z: 0},
|
|
53
|
+
scale: [100,100,100],
|
|
54
|
+
texturesPaths: ['./res/meshes/blender/cube.png'],
|
|
55
|
+
name: 'swat',
|
|
56
|
+
mesh: m['swat-walk-pistol'],
|
|
57
|
+
physics: {
|
|
58
|
+
enabled: false,
|
|
59
|
+
geometry: "Cube"
|
|
60
|
+
},
|
|
61
|
+
objAnim: objAnim
|
|
62
|
+
})
|
|
63
|
+
app.mainRenderBundle[0].objAnim.play('walk');
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
// Just for dev - easy console access
|
|
67
|
+
window.app = loadObjFile;
|
|
68
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import MatrixEngineWGPU from "../src/world.js";
|
|
2
|
+
|
|
3
|
+
export var unlitTextures = function() {
|
|
4
|
+
let unlitTextures = new MatrixEngineWGPU({
|
|
5
|
+
useSingleRenderPass: false,
|
|
6
|
+
canvasSize: 'fullscreen'
|
|
7
|
+
}, () => {
|
|
8
|
+
addEventListener('AmmoReady', () => {
|
|
9
|
+
let c = {
|
|
10
|
+
scale: 2,
|
|
11
|
+
position: {x: -3, y: 0, z: -10},
|
|
12
|
+
rotation: {x: 0, y: 0, z: 0},
|
|
13
|
+
rotationSpeed: {x: 10, y: 0, z: 0},
|
|
14
|
+
texturesPaths: ['./res/textures/rust.jpg']
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
let o = {
|
|
18
|
+
scale: 2,
|
|
19
|
+
position: {x: 3, y: 0, z: -10},
|
|
20
|
+
rotation: {x: 0, y: 0, z: 0},
|
|
21
|
+
rotationSpeed: {x: 10, y: 0, z: 0},
|
|
22
|
+
texturesPaths: ['./res/textures/default.png']
|
|
23
|
+
};
|
|
24
|
+
unlitTextures.addCube(o)
|
|
25
|
+
unlitTextures.addBall(c)
|
|
26
|
+
});
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
window.app = unlitTextures;
|
|
30
|
+
|
|
31
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
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 {addRaycastsAABBListener} from "../src/engine/raycast.js";
|
|
5
|
+
|
|
6
|
+
export var loadVideoTexture = function() {
|
|
7
|
+
|
|
8
|
+
let videoTexture = new MatrixEngineWGPU({
|
|
9
|
+
useSingleRenderPass: true,
|
|
10
|
+
canvasSize: 'fullscreen',
|
|
11
|
+
mainCameraParams: {
|
|
12
|
+
type: 'WASD',
|
|
13
|
+
responseCoef: 1000
|
|
14
|
+
},
|
|
15
|
+
clearColor: {r: 0, b: 0.122, g: 0.122, a: 1}
|
|
16
|
+
}, () => {
|
|
17
|
+
|
|
18
|
+
addEventListener('AmmoReady', () => {
|
|
19
|
+
downloadMeshes({
|
|
20
|
+
welcomeText: "./res/meshes/blender/piramyd.obj",
|
|
21
|
+
armor: "./res/meshes/obj/armor.obj",
|
|
22
|
+
sphere: "./res/meshes/blender/sphere.obj",
|
|
23
|
+
cube: "./res/meshes/blender/cube.obj",
|
|
24
|
+
}, onLoadObj,
|
|
25
|
+
{scale: [1, 1, 1]})
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
function onLoadObj(m) {
|
|
29
|
+
videoTexture.myLoadedMeshes = m;
|
|
30
|
+
for(var key in m) {
|
|
31
|
+
console.log(`%c Loaded objs: ${key} `, LOG_MATRIX);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
videoTexture.addMeshObj({
|
|
35
|
+
position: {x: 0, y: 2, z: -10},
|
|
36
|
+
rotation: {x: 0, y: 0, z: 0},
|
|
37
|
+
rotationSpeed: {x: 0, y: 0, z: 0},
|
|
38
|
+
texturesPaths: ['./res/meshes/blender/cube.png'],
|
|
39
|
+
name: 'MyVideoTex',
|
|
40
|
+
mesh: m.cube,
|
|
41
|
+
physics: {
|
|
42
|
+
enabled: true,
|
|
43
|
+
geometry: "Cube"
|
|
44
|
+
},
|
|
45
|
+
// raycast: { enabled: true , radius: 2 }
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
var TEST = videoTexture.getSceneObjectByName('MyVideoTex');
|
|
49
|
+
setTimeout(() => {
|
|
50
|
+
console.log(`%c Test video-texture...`, LOG_MATRIX);
|
|
51
|
+
TEST.loadVideoTexture({
|
|
52
|
+
type: 'video',
|
|
53
|
+
src: 'res/videos/tunel.mp4'
|
|
54
|
+
});
|
|
55
|
+
}, 4000);
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
window.app = videoTexture;
|
|
60
|
+
|
|
61
|
+
}
|
package/examples.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @examples
|
|
3
|
+
* MATRIX_ENGINE_WGPU EXAMPLE WORKSPACE
|
|
4
|
+
* Nikola Lukic 2024
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// import {loadJamb} from "./examples/load-jamb.js";
|
|
8
|
+
import {loadCameraTexture} from "./examples/camera-texture.js";
|
|
9
|
+
import {loadObjFile} from "./examples/load-obj-file.js";
|
|
10
|
+
import {loadObjsSequence} from "./examples/load-objs-sequence.js";
|
|
11
|
+
import {unlitTextures} from "./examples/unlit-textures.js";
|
|
12
|
+
import {loadVideoTexture} from "./examples/video-texture.js";
|
|
13
|
+
import {byId} from "./src/engine/utils.js";
|
|
14
|
+
|
|
15
|
+
// For future
|
|
16
|
+
var examples = {
|
|
17
|
+
// loadJamb,
|
|
18
|
+
loadObjFile,
|
|
19
|
+
unlitTextures,
|
|
20
|
+
loadVideoTexture
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function destroyJambDoms() {
|
|
24
|
+
if(byId('hud')) byId('hud').remove();
|
|
25
|
+
if(byId('jambTable')) byId('jambTable').remove();
|
|
26
|
+
if(byId('topTitleDOM')) byId('topTitleDOM').remove();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
byId('loadObjFile').addEventListener("click", () => {
|
|
30
|
+
// byId('loadObjFile').setAttribute('disabled', true)
|
|
31
|
+
// byId('unlitTextures').removeAttribute('disabled')
|
|
32
|
+
if(typeof app !== "undefined") app.destroyProgram()
|
|
33
|
+
destroyJambDoms();
|
|
34
|
+
loadObjFile();
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
byId('unlitTextures').addEventListener("click", () => {
|
|
38
|
+
// byId('unlitTextures').setAttribute('disabled', true)
|
|
39
|
+
// byId('loadObjFile').removeAttribute('disabled')
|
|
40
|
+
if(typeof app !== "undefined") app.destroyProgram()
|
|
41
|
+
destroyJambDoms();
|
|
42
|
+
unlitTextures();
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
byId('camera-texture').addEventListener("click", () => {
|
|
46
|
+
if(typeof app !== "undefined") app.destroyProgram()
|
|
47
|
+
destroyJambDoms();
|
|
48
|
+
loadCameraTexture();
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
byId('video-texture').addEventListener("click", () => {
|
|
52
|
+
if(typeof app !== "undefined") app.destroyProgram()
|
|
53
|
+
destroyJambDoms();
|
|
54
|
+
loadVideoTexture();
|
|
55
|
+
})
|
|
56
|
+
|
|
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()
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
byId('objs-anim').addEventListener("click", () => {
|
|
67
|
+
// byId('unlitTextures').setAttribute('disabled', true)
|
|
68
|
+
// byId('loadObjFile').setAttribute('disabled', true)
|
|
69
|
+
// byId('jamb').removeAttribute('disabled')
|
|
70
|
+
if(typeof app !== "undefined") app.destroyProgram()
|
|
71
|
+
destroyJambDoms();
|
|
72
|
+
loadObjsSequence()
|
|
73
|
+
})
|