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.
Files changed (273) hide show
  1. package/.codesandbox/tasks.json +46 -0
  2. package/.devcontainer/devcontainer.json +22 -0
  3. package/.github/dependabot.yml +12 -0
  4. package/REFERENCE.md +59 -0
  5. package/app-worker.js +45 -0
  6. package/dev.md +541 -0
  7. package/empty.js +17 -0
  8. package/examples/camera-texture.js +60 -0
  9. package/examples/games/jamb/html-content.js +128 -0
  10. package/examples/games/jamb/jamb.js +1341 -0
  11. package/examples/games/jamb/readme.md +3 -0
  12. package/examples/load-jamb.js +6 -0
  13. package/examples/load-obj-file.js +95 -0
  14. package/examples/load-objs-sequence.js +68 -0
  15. package/examples/unlit-textures.js +31 -0
  16. package/examples/video-texture.js +61 -0
  17. package/examples.js +73 -0
  18. package/main.js +635 -0
  19. package/non-project-files/cubebuffer-example.js +51 -0
  20. package/non-project-files/dev.txt +21 -0
  21. package/non-project-files/image1.png +0 -0
  22. package/non-project-files/image6.png +0 -0
  23. package/package.json +2 -5
  24. package/public/ammojs/ammo.js +957 -0
  25. package/public/ammojs/ammo.wasm.js +921 -0
  26. package/public/ammojs/ammo.wasm.wasm +0 -0
  27. package/public/app-worker.js +47 -0
  28. package/public/app.js +12744 -0
  29. package/public/css/style.css +711 -0
  30. package/public/empty.html +25 -0
  31. package/public/empty.js +10453 -0
  32. package/public/examples.html +30 -0
  33. package/public/examples.js +11217 -0
  34. package/public/index.html +20 -0
  35. package/public/manifest copy.web +35 -0
  36. package/public/manifest.web +25 -0
  37. package/public/res/audios/block.mp3 +0 -0
  38. package/public/res/audios/dice-roll.mp3 +0 -0
  39. package/public/res/audios/dice1.mp3 +0 -0
  40. package/public/res/audios/dice2.mp3 +0 -0
  41. package/public/res/audios/kenney/Kenney.url +2 -0
  42. package/public/res/audios/kenney/License.txt +22 -0
  43. package/public/res/audios/kenney/Patreon.url +2 -0
  44. package/public/res/audios/kenney/audios/back_001.ogg +0 -0
  45. package/public/res/audios/kenney/audios/back_002.ogg +0 -0
  46. package/public/res/audios/kenney/audios/back_003.ogg +0 -0
  47. package/public/res/audios/kenney/audios/back_004.ogg +0 -0
  48. package/public/res/audios/kenney/audios/bong_001.ogg +0 -0
  49. package/public/res/audios/kenney/audios/click_001.ogg +0 -0
  50. package/public/res/audios/kenney/audios/click_002.ogg +0 -0
  51. package/public/res/audios/kenney/audios/click_003.ogg +0 -0
  52. package/public/res/audios/kenney/audios/click_004.ogg +0 -0
  53. package/public/res/audios/kenney/audios/click_005.ogg +0 -0
  54. package/public/res/audios/kenney/audios/close_001.ogg +0 -0
  55. package/public/res/audios/kenney/audios/close_002.ogg +0 -0
  56. package/public/res/audios/kenney/audios/close_003.ogg +0 -0
  57. package/public/res/audios/kenney/audios/close_004.ogg +0 -0
  58. package/public/res/audios/kenney/audios/confirmation_001.ogg +0 -0
  59. package/public/res/audios/kenney/audios/confirmation_002.ogg +0 -0
  60. package/public/res/audios/kenney/audios/confirmation_003.ogg +0 -0
  61. package/public/res/audios/kenney/audios/confirmation_004.ogg +0 -0
  62. package/public/res/audios/kenney/audios/drop_001.ogg +0 -0
  63. package/public/res/audios/kenney/audios/drop_002.ogg +0 -0
  64. package/public/res/audios/kenney/audios/drop_003.ogg +0 -0
  65. package/public/res/audios/kenney/audios/drop_004.ogg +0 -0
  66. package/public/res/audios/kenney/audios/error_001.ogg +0 -0
  67. package/public/res/audios/kenney/audios/error_002.ogg +0 -0
  68. package/public/res/audios/kenney/audios/error_003.ogg +0 -0
  69. package/public/res/audios/kenney/audios/error_004.ogg +0 -0
  70. package/public/res/audios/kenney/audios/error_005.ogg +0 -0
  71. package/public/res/audios/kenney/audios/error_006.ogg +0 -0
  72. package/public/res/audios/kenney/audios/error_007.ogg +0 -0
  73. package/public/res/audios/kenney/audios/error_008.ogg +0 -0
  74. package/public/res/audios/kenney/audios/glass_001.ogg +0 -0
  75. package/public/res/audios/kenney/audios/glass_002.ogg +0 -0
  76. package/public/res/audios/kenney/audios/glass_003.ogg +0 -0
  77. package/public/res/audios/kenney/audios/glass_004.ogg +0 -0
  78. package/public/res/audios/kenney/audios/glass_005.ogg +0 -0
  79. package/public/res/audios/kenney/audios/glass_006.ogg +0 -0
  80. package/public/res/audios/kenney/audios/glitch_001.ogg +0 -0
  81. package/public/res/audios/kenney/audios/glitch_002.ogg +0 -0
  82. package/public/res/audios/kenney/audios/glitch_003.ogg +0 -0
  83. package/public/res/audios/kenney/audios/glitch_004.ogg +0 -0
  84. package/public/res/audios/kenney/audios/maximize_001.ogg +0 -0
  85. package/public/res/audios/kenney/audios/maximize_002.ogg +0 -0
  86. package/public/res/audios/kenney/audios/maximize_003.ogg +0 -0
  87. package/public/res/audios/kenney/audios/maximize_004.ogg +0 -0
  88. package/public/res/audios/kenney/audios/maximize_005.ogg +0 -0
  89. package/public/res/audios/kenney/audios/maximize_006.ogg +0 -0
  90. package/public/res/audios/kenney/audios/maximize_007.ogg +0 -0
  91. package/public/res/audios/kenney/audios/maximize_008.ogg +0 -0
  92. package/public/res/audios/kenney/audios/maximize_009.ogg +0 -0
  93. package/public/res/audios/kenney/audios/minimize_001.ogg +0 -0
  94. package/public/res/audios/kenney/audios/minimize_002.ogg +0 -0
  95. package/public/res/audios/kenney/audios/minimize_003.ogg +0 -0
  96. package/public/res/audios/kenney/audios/minimize_004.ogg +0 -0
  97. package/public/res/audios/kenney/audios/minimize_005.ogg +0 -0
  98. package/public/res/audios/kenney/audios/minimize_006.ogg +0 -0
  99. package/public/res/audios/kenney/audios/minimize_007.ogg +0 -0
  100. package/public/res/audios/kenney/audios/minimize_008.ogg +0 -0
  101. package/public/res/audios/kenney/audios/minimize_009.ogg +0 -0
  102. package/public/res/audios/kenney/audios/open_001.ogg +0 -0
  103. package/public/res/audios/kenney/audios/open_002.ogg +0 -0
  104. package/public/res/audios/kenney/audios/open_003.ogg +0 -0
  105. package/public/res/audios/kenney/audios/open_004.ogg +0 -0
  106. package/public/res/audios/kenney/audios/pluck_001.ogg +0 -0
  107. package/public/res/audios/kenney/audios/pluck_002.ogg +0 -0
  108. package/public/res/audios/kenney/audios/question_001.ogg +0 -0
  109. package/public/res/audios/kenney/audios/question_002.ogg +0 -0
  110. package/public/res/audios/kenney/audios/question_003.ogg +0 -0
  111. package/public/res/audios/kenney/audios/question_004.ogg +0 -0
  112. package/public/res/audios/kenney/audios/scratch_001.ogg +0 -0
  113. package/public/res/audios/kenney/audios/scratch_002.ogg +0 -0
  114. package/public/res/audios/kenney/audios/scratch_003.ogg +0 -0
  115. package/public/res/audios/kenney/audios/scratch_004.ogg +0 -0
  116. package/public/res/audios/kenney/audios/scratch_005.ogg +0 -0
  117. package/public/res/audios/kenney/audios/scroll_001.ogg +0 -0
  118. package/public/res/audios/kenney/audios/scroll_002.ogg +0 -0
  119. package/public/res/audios/kenney/audios/scroll_003.ogg +0 -0
  120. package/public/res/audios/kenney/audios/scroll_004.ogg +0 -0
  121. package/public/res/audios/kenney/audios/scroll_005.ogg +0 -0
  122. package/public/res/audios/kenney/audios/select_001.ogg +0 -0
  123. package/public/res/audios/kenney/audios/select_002.ogg +0 -0
  124. package/public/res/audios/kenney/audios/select_003.ogg +0 -0
  125. package/public/res/audios/kenney/audios/select_004.ogg +0 -0
  126. package/public/res/audios/kenney/audios/select_005.ogg +0 -0
  127. package/public/res/audios/kenney/audios/select_006.ogg +0 -0
  128. package/public/res/audios/kenney/audios/select_007.ogg +0 -0
  129. package/public/res/audios/kenney/audios/select_008.ogg +0 -0
  130. package/public/res/audios/kenney/audios/switch_001.ogg +0 -0
  131. package/public/res/audios/kenney/audios/switch_002.ogg +0 -0
  132. package/public/res/audios/kenney/audios/switch_003.ogg +0 -0
  133. package/public/res/audios/kenney/audios/switch_004.ogg +0 -0
  134. package/public/res/audios/kenney/audios/switch_005.ogg +0 -0
  135. package/public/res/audios/kenney/audios/switch_006.ogg +0 -0
  136. package/public/res/audios/kenney/audios/switch_007.ogg +0 -0
  137. package/public/res/audios/kenney/audios/tick_001.ogg +0 -0
  138. package/public/res/audios/kenney/audios/tick_002.ogg +0 -0
  139. package/public/res/audios/kenney/audios/tick_004.ogg +0 -0
  140. package/public/res/audios/kenney/audios/toggle_001.ogg +0 -0
  141. package/public/res/audios/kenney/audios/toggle_002.ogg +0 -0
  142. package/public/res/audios/kenney/audios/toggle_003.ogg +0 -0
  143. package/public/res/audios/kenney/audios/toggle_004.ogg +0 -0
  144. package/public/res/audios/start.mp3 +0 -0
  145. package/public/res/audios/toggle_002.mp3 +0 -0
  146. package/public/res/fonts/Accuratist.ttf +0 -0
  147. package/public/res/fonts/Closeness.ttf +0 -0
  148. package/public/res/fonts/WARGAMES.TTF +0 -0
  149. package/public/res/fonts/readme.txt +5 -0
  150. package/public/res/fonts/stormfaze.ttf +0 -0
  151. package/public/res/icons/512.png +0 -0
  152. package/public/res/icons/webgpu-horizontal.svg +45 -0
  153. package/public/res/meshes/blender/cube.blend +0 -0
  154. package/public/res/meshes/blender/cube.blend1 +0 -0
  155. package/public/res/meshes/blender/cube.mtl +12 -0
  156. package/public/res/meshes/blender/cube.obj +46 -0
  157. package/public/res/meshes/blender/cube.png +0 -0
  158. package/public/res/meshes/blender/cubeSmartUV.blend +0 -0
  159. package/public/res/meshes/blender/cubeSmartUV.mtl +12 -0
  160. package/public/res/meshes/blender/cubeSmartUV.obj +46 -0
  161. package/public/res/meshes/blender/lopta.mtl +10 -0
  162. package/public/res/meshes/blender/lopta.obj +3402 -0
  163. package/public/res/meshes/blender/piramyd.blend +0 -0
  164. package/public/res/meshes/blender/piramyd.blend1 +0 -0
  165. package/public/res/meshes/blender/piramyd.js +42 -0
  166. package/public/res/meshes/blender/piramyd.mtl +10 -0
  167. package/public/res/meshes/blender/piramyd.obj +18696 -0
  168. package/public/res/meshes/blender/piramyd1.js +42 -0
  169. package/public/res/meshes/blender/sphepe.blend +0 -0
  170. package/public/res/meshes/blender/sphepe.blend1 +0 -0
  171. package/public/res/meshes/blender/sphere.mtl +10 -0
  172. package/public/res/meshes/blender/sphere.obj +3402 -0
  173. package/public/res/meshes/blender/welcomeTextblend.blend +0 -0
  174. package/public/res/meshes/dragon/stanfordDragonData.js +5 -0
  175. package/public/res/meshes/jamb/bg.blend +0 -0
  176. package/public/res/meshes/jamb/bg.blend1 +0 -0
  177. package/public/res/meshes/jamb/bg.mtl +12 -0
  178. package/public/res/meshes/jamb/bg.obj +17 -0
  179. package/public/res/meshes/jamb/bg.png +0 -0
  180. package/public/res/meshes/jamb/dice-default.png +0 -0
  181. package/public/res/meshes/jamb/dice-mark.png +0 -0
  182. package/public/res/meshes/jamb/dice.mtl +12 -0
  183. package/public/res/meshes/jamb/dice.obj +40 -0
  184. package/public/res/meshes/jamb/dice.png +0 -0
  185. package/public/res/meshes/jamb/jamb-title.mtl +12 -0
  186. package/public/res/meshes/jamb/jamb-title.obj +26008 -0
  187. package/public/res/meshes/jamb/jamb.blend +0 -0
  188. package/public/res/meshes/jamb/jamb.blend1 +0 -0
  189. package/public/res/meshes/jamb/logo.png +0 -0
  190. package/public/res/meshes/jamb/nidzaDice.blend +0 -0
  191. package/public/res/meshes/jamb/nidzaDice.blend1 +0 -0
  192. package/public/res/meshes/jamb/pile.blend +0 -0
  193. package/public/res/meshes/jamb/simpleCube.blend +0 -0
  194. package/public/res/meshes/jamb/simpleCube.blend1 +0 -0
  195. package/public/res/meshes/jamb/sounds/roll1.wav +0 -0
  196. package/public/res/meshes/jamb/text.png +0 -0
  197. package/public/res/meshes/obj/armor.obj +319 -0
  198. package/public/res/meshes/obj/armor.png +0 -0
  199. package/public/res/meshes/objs-sequence/swat-walk-pistol_000001.mtl +22 -0
  200. package/public/res/meshes/objs-sequence/swat-walk-pistol_000001.obj +23264 -0
  201. package/public/res/meshes/objs-sequence/swat-walk-pistol_000002.mtl +22 -0
  202. package/public/res/meshes/objs-sequence/swat-walk-pistol_000002.obj +23261 -0
  203. package/public/res/meshes/objs-sequence/swat-walk-pistol_000003.mtl +22 -0
  204. package/public/res/meshes/objs-sequence/swat-walk-pistol_000003.obj +23264 -0
  205. package/public/res/meshes/objs-sequence/swat-walk-pistol_000004.mtl +22 -0
  206. package/public/res/meshes/objs-sequence/swat-walk-pistol_000004.obj +23261 -0
  207. package/public/res/meshes/objs-sequence/swat-walk-pistol_000005.mtl +22 -0
  208. package/public/res/meshes/objs-sequence/swat-walk-pistol_000005.obj +23261 -0
  209. package/public/res/meshes/objs-sequence/swat-walk-pistol_000006.mtl +22 -0
  210. package/public/res/meshes/objs-sequence/swat-walk-pistol_000006.obj +23261 -0
  211. package/public/res/meshes/objs-sequence/swat-walk-pistol_000007.mtl +22 -0
  212. package/public/res/meshes/objs-sequence/swat-walk-pistol_000007.obj +23264 -0
  213. package/public/res/meshes/objs-sequence/swat-walk-pistol_000008.mtl +22 -0
  214. package/public/res/meshes/objs-sequence/swat-walk-pistol_000008.obj +23263 -0
  215. package/public/res/meshes/objs-sequence/swat-walk-pistol_000009.mtl +22 -0
  216. package/public/res/meshes/objs-sequence/swat-walk-pistol_000009.obj +23264 -0
  217. package/public/res/meshes/objs-sequence/swat-walk-pistol_000010.mtl +22 -0
  218. package/public/res/meshes/objs-sequence/swat-walk-pistol_000010.obj +23260 -0
  219. package/public/res/meshes/objs-sequence/swat-walk-pistol_000011.mtl +22 -0
  220. package/public/res/meshes/objs-sequence/swat-walk-pistol_000011.obj +23262 -0
  221. package/public/res/meshes/objs-sequence/swat-walk-pistol_000012.mtl +22 -0
  222. package/public/res/meshes/objs-sequence/swat-walk-pistol_000012.obj +23262 -0
  223. package/public/res/meshes/objs-sequence/swat-walk-pistol_000013.mtl +22 -0
  224. package/public/res/meshes/objs-sequence/swat-walk-pistol_000013.obj +23263 -0
  225. package/public/res/meshes/objs-sequence/swat-walk-pistol_000014.mtl +22 -0
  226. package/public/res/meshes/objs-sequence/swat-walk-pistol_000014.obj +23262 -0
  227. package/public/res/meshes/objs-sequence/swat-walk-pistol_000015.mtl +22 -0
  228. package/public/res/meshes/objs-sequence/swat-walk-pistol_000015.obj +23263 -0
  229. package/public/res/meshes/objs-sequence/swat-walk-pistol_000016.mtl +22 -0
  230. package/public/res/meshes/objs-sequence/swat-walk-pistol_000016.obj +23264 -0
  231. package/public/res/meshes/objs-sequence/swat-walk-pistol_000017.mtl +22 -0
  232. package/public/res/meshes/objs-sequence/swat-walk-pistol_000017.obj +23263 -0
  233. package/public/res/meshes/objs-sequence/swat-walk-pistol_000018.mtl +22 -0
  234. package/public/res/meshes/objs-sequence/swat-walk-pistol_000018.obj +23261 -0
  235. package/public/res/meshes/objs-sequence/swat-walk-pistol_000019.mtl +22 -0
  236. package/public/res/meshes/objs-sequence/swat-walk-pistol_000019.obj +23263 -0
  237. package/public/res/meshes/objs-sequence/swat-walk-pistol_000020.mtl +22 -0
  238. package/public/res/meshes/objs-sequence/swat-walk-pistol_000020.obj +23261 -0
  239. package/public/res/meshes/shapes/star1.obj +60 -0
  240. package/public/res/multilang/en.json +39 -0
  241. package/public/res/multilang/sr.json +39 -0
  242. package/public/res/textures/default.png +0 -0
  243. package/public/res/textures/rust.jpg +0 -0
  244. package/public/res/textures/tex1.jpg +0 -0
  245. package/public/res/videos/readme.txt +2 -0
  246. package/public/res/videos/tunel.mp4 +0 -0
  247. package/public/test.html +636 -0
  248. package/public/three-test.js +165 -0
  249. package/public/worker.html +25 -0
  250. package/src/engine/ball.js +482 -0
  251. package/src/engine/cube.js +496 -0
  252. package/src/engine/engine.js +404 -0
  253. package/src/engine/final/adaptJSON1.js +53 -0
  254. package/src/engine/final/utils2.js +63 -0
  255. package/src/engine/lights.js +153 -0
  256. package/src/engine/loader-obj.js +473 -0
  257. package/src/engine/materials.js +295 -0
  258. package/src/engine/matrix-class.js +252 -0
  259. package/src/engine/mesh-obj.js +574 -0
  260. package/src/engine/raycast.js +218 -0
  261. package/src/engine/utils.js +881 -0
  262. package/src/libs/mat.js +0 -0
  263. package/src/multilang/lang.js +35 -0
  264. package/src/physics/matrix-ammo.js +363 -0
  265. package/src/shaders/fragment.video.wgsl.js +83 -0
  266. package/src/shaders/fragment.wgsl.js +75 -0
  267. package/src/shaders/shaders.js +51 -0
  268. package/src/shaders/standard-matrix-engine-shaders/standard-matrix-engine-fs.glsl +56 -0
  269. package/src/shaders/standard-matrix-engine-shaders/standard-matrix-engine-vs.glsl +75 -0
  270. package/src/shaders/vertex.wgsl.js +54 -0
  271. package/src/shaders/vertexShadow.wgsl.js +20 -0
  272. package/src/sounds/sounds.js +69 -0
  273. 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,6 @@
1
+ import {loadJambApp} from "../main.js";
2
+
3
+ export var loadJamb = function() {
4
+ console.log('Just loader for example page')
5
+ window.app = loadJambApp();
6
+ }
@@ -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
+ })