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
File without changes
@@ -0,0 +1,35 @@
1
+ import {LOG_MATRIX} from "../engine/utils";
2
+
3
+ export class MultiLang {
4
+
5
+ constructor() {
6
+ addEventListener('updateLang', () => {
7
+ console.log('Multilang updated.')
8
+ this.update();
9
+ })
10
+ }
11
+
12
+ update = function() {
13
+ var allTranDoms = document.querySelectorAll('[data-label]');
14
+ allTranDoms.forEach((i) => {
15
+ i.innerHTML = this.get[i.getAttribute('data-label')]
16
+ })
17
+ }
18
+
19
+ loadMultilang = async function(lang = 'en') {
20
+ lang = 'res/multilang/' + lang + '.json';
21
+ console.info(`%cMultilang: ${lang}` , LOG_MATRIX);
22
+ try {
23
+ const r = await fetch(lang, {
24
+ headers: {
25
+ 'Accept': 'application/json',
26
+ 'Content-Type': 'application/json'
27
+ }
28
+ });
29
+ return await r.json()
30
+ } catch(err) {
31
+ console.warn('Not possible to access multilang json asset! Err => ', err);
32
+ return {}
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,363 @@
1
+ import {LOG_FUNNY, degToRad, quaternion_rotation_matrix, radToDeg, scriptManager} from "../engine/utils";
2
+
3
+ export default class MatrixAmmo {
4
+ constructor() {
5
+ // THIS PATH IS PATH FROM PUBLIC FINAL FOLDER
6
+ scriptManager.LOAD(
7
+ "https://maximumroulette.com/apps/megpu/ammo.js",
8
+ "ammojs",
9
+ undefined,
10
+ undefined,
11
+ this.init,
12
+ );
13
+ this.lastRoll = '';
14
+ this.presentScore = '';
15
+ this.speedUpSimulation = 1;
16
+ }
17
+
18
+ init = () => {
19
+ Ammo().then(Ammo => {
20
+ // Physics variables
21
+ this.dynamicsWorld = null;
22
+ this.rigidBodies = [];
23
+ this.Ammo = Ammo;
24
+ this.lastUpdate = 0
25
+ console.log("%c Ammo core loaded.", LOG_FUNNY);
26
+ this.initPhysics();
27
+ // simulate async
28
+ setTimeout(() => {
29
+ dispatchEvent(new CustomEvent('AmmoReady', {}))
30
+ } , 200)
31
+ });
32
+ };
33
+
34
+ initPhysics() {
35
+ let Ammo = this.Ammo;
36
+ // Physics configuration
37
+ var collisionConfiguration = new Ammo.btDefaultCollisionConfiguration(),
38
+ dispatcher = new Ammo.btCollisionDispatcher(collisionConfiguration),
39
+ overlappingPairCache = new Ammo.btDbvtBroadphase(),
40
+ solver = new Ammo.btSequentialImpulseConstraintSolver();
41
+
42
+ this.dynamicsWorld = new Ammo.btDiscreteDynamicsWorld(dispatcher, overlappingPairCache, solver, collisionConfiguration);
43
+ this.dynamicsWorld.setGravity(new Ammo.btVector3(0, -10, 0));
44
+
45
+ var groundShape = new Ammo.btBoxShape(new Ammo.btVector3(70, 1, 70)),
46
+ groundTransform = new Ammo.btTransform();
47
+ groundTransform.setIdentity();
48
+ groundTransform.setOrigin(new Ammo.btVector3(0, -4.45, 0));
49
+ var mass = 0,
50
+ isDynamic = (mass !== 0),
51
+ localInertia = new Ammo.btVector3(0, 0, 0);
52
+
53
+ if(isDynamic) groundShape.calculateLocalInertia(mass, localInertia);
54
+
55
+ var myMotionState = new Ammo.btDefaultMotionState(groundTransform),
56
+ rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, groundShape, localInertia),
57
+ body = new Ammo.btRigidBody(rbInfo);
58
+ body.name = 'ground';
59
+ this.ground = body;
60
+ this.dynamicsWorld.addRigidBody(body);
61
+ this.detectCollision()
62
+ }
63
+
64
+ addPhysics(MEObject, pOptions) {
65
+ if(pOptions.geometry == "Sphere") {
66
+ this.addPhysicsSphere(MEObject, pOptions)
67
+ } else if(pOptions.geometry == "Cube") {
68
+ this.addPhysicsBox(MEObject, pOptions)
69
+ }
70
+ }
71
+
72
+ addPhysicsSphere(MEObject, pOptions) {
73
+ const FLAGS = {
74
+ TEST_NIDZA: 3,
75
+ CF_KINEMATIC_OBJECT: 2
76
+ }
77
+
78
+ let Ammo = this.Ammo;
79
+ console.log(pOptions.radius + "<<pOptions.radius")
80
+ var colShape = new Ammo.btSphereShape(Array.isArray(pOptions.radius) ? pOptions.radius[0] : pOptions.radius),
81
+ startTransform = new Ammo.btTransform();
82
+ startTransform.setIdentity();
83
+ var mass = 1;
84
+ var localInertia = new Ammo.btVector3(0, 0, 0);
85
+ colShape.calculateLocalInertia(mass, localInertia);
86
+ startTransform.setOrigin(new Ammo.btVector3(pOptions.position.x, pOptions.position.y, pOptions.position.z));
87
+
88
+ var myMotionState = new Ammo.btDefaultMotionState(startTransform),
89
+ rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia),
90
+ body = new Ammo.btRigidBody(rbInfo);
91
+
92
+ if(pOptions.mass == 0 && typeof pOptions.state == 'undefined' && typeof pOptions.collide == 'undefined') {
93
+ body.setActivationState(2)
94
+ body.setCollisionFlags(FLAGS.CF_KINEMATIC_OBJECT);
95
+ // console.log('what is pOptions.mass and state is 2 ....', pOptions.mass)
96
+ } else if(typeof pOptions.collide != 'undefined' && pOptions.collide == false) {
97
+ // idea not work for now - eliminate collide effect
98
+ body.setActivationState(4)
99
+ body.setCollisionFlags(FLAGS.TEST_NIDZA);
100
+ } else {
101
+ body.setActivationState(4)
102
+ }
103
+
104
+ body.name = pOptions.name;
105
+ MEObject.itIsPhysicsBody = true;
106
+ body.MEObject = MEObject;
107
+ this.dynamicsWorld.addRigidBody(body);
108
+ this.rigidBodies.push(body);
109
+ return body;
110
+ }
111
+
112
+ addPhysicsBox(MEObject, pOptions) {
113
+ const FLAGS = {
114
+ TEST_NIDZA: 3,
115
+ CF_KINEMATIC_OBJECT: 2
116
+ }
117
+
118
+ let Ammo = this.Ammo;
119
+ // improve this - scale by comp
120
+ var colShape = new Ammo.btBoxShape(new Ammo.btVector3(pOptions.scale[0], pOptions.scale[1], pOptions.scale[2])),
121
+ startTransform = new Ammo.btTransform();
122
+ startTransform.setIdentity();
123
+ var mass = pOptions.mass;
124
+ var localInertia = new Ammo.btVector3(0, 0, 0);
125
+ colShape.calculateLocalInertia(mass, localInertia);
126
+ startTransform.setOrigin(new Ammo.btVector3(pOptions.position.x, pOptions.position.y, pOptions.position.z));
127
+ // console.log('startTransform.setRotation', startTransform.setRotation)
128
+ var t = startTransform.getRotation()
129
+ t.setX(degToRad(pOptions.rotation.x))
130
+ t.setY(degToRad(pOptions.rotation.y))
131
+ t.setZ(degToRad(pOptions.rotation.z))
132
+ startTransform.setRotation(t)
133
+
134
+ var myMotionState = new Ammo.btDefaultMotionState(startTransform),
135
+ rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia),
136
+ body = new Ammo.btRigidBody(rbInfo);
137
+
138
+ if(pOptions.mass == 0 && typeof pOptions.state == 'undefined' && typeof pOptions.collide == 'undefined') {
139
+ body.setActivationState(2)
140
+ body.setCollisionFlags(FLAGS.CF_KINEMATIC_OBJECT);
141
+ // console.log('what is pOptions.mass and state is 2 ....', pOptions.mass)
142
+ } else if(typeof pOptions.collide != 'undefined' && pOptions.collide == false) {
143
+ // idea not work for now - eliminate collide effect
144
+ body.setActivationState(4)
145
+ body.setCollisionFlags(FLAGS.TEST_NIDZA);
146
+ } else {
147
+ body.setActivationState(4)
148
+ }
149
+ body.name = pOptions.name;
150
+ MEObject.itIsPhysicsBody = true;
151
+ body.MEObject = MEObject;
152
+ this.dynamicsWorld.addRigidBody(body);
153
+ this.rigidBodies.push(body);
154
+ return body;
155
+ }
156
+
157
+ setBodyVelocity(body, x, y, z) {
158
+ var tbv30 = new Ammo.btVector3();
159
+ tbv30.setValue(x, y, z);
160
+ body.setLinearVelocity(tbv30);
161
+ }
162
+
163
+ setKinematicTransform(body, x, y, z, rx, ry, rz) {
164
+ if(typeof rx == 'undefined') {var rx = 0;}
165
+ if(typeof ry == 'undefined') {var ry = 0;}
166
+ if(typeof rz == 'undefined') {var rz = 0;}
167
+ let pos = new Ammo.btVector3();
168
+ // let quat = new Ammo.btQuaternion();
169
+ pos = body.getWorldTransform().getOrigin();
170
+ let localRot = body.getWorldTransform().getRotation();
171
+ // console.log('pre pos x:', pos.x(), " y : ", pos.y(), " z:", pos.z())
172
+ pos.setX(pos.x() + x)
173
+ pos.setY(pos.y() + y)
174
+ pos.setZ(pos.z() + z)
175
+ localRot.setX(rx)
176
+ localRot.setY(ry)
177
+ localRot.setZ(rz)
178
+ let physicsBody = body;
179
+ let ms = physicsBody.getMotionState();
180
+ if(ms) {
181
+ var tmpTrans = new Ammo.btTransform();
182
+ tmpTrans.setIdentity();
183
+ tmpTrans.setOrigin(pos);
184
+ tmpTrans.setRotation(localRot);
185
+ ms.setWorldTransform(tmpTrans);
186
+ }
187
+ }
188
+
189
+ getBodyByName(name) {
190
+ var b = null;
191
+ this.rigidBodies.forEach((item, index, array) => {
192
+ if(item.name == name) {
193
+ b = array[index];
194
+ }
195
+ });
196
+ return b;
197
+ }
198
+
199
+ getNameByBody(body) {
200
+ var b = null;
201
+ this.rigidBodies.forEach((item, index, array) => {
202
+ if(item.kB == body.kB) {
203
+ b = array[index].name;
204
+ }
205
+ });
206
+ return b;
207
+ }
208
+
209
+ deactivatePhysics(body) {
210
+ const CF_KINEMATIC_OBJECT = 2;
211
+ const DISABLE_DEACTIVATION = 4;
212
+ // 1. Remove from world
213
+ this.dynamicsWorld.removeRigidBody(body);
214
+ // 2. Set body to kinematic
215
+ const flags = body.getCollisionFlags();
216
+ body.setCollisionFlags(flags | CF_KINEMATIC_OBJECT);
217
+ body.setActivationState(DISABLE_DEACTIVATION); // no auto-wakeup
218
+ // 3. Clear motion
219
+ const zero = new Ammo.btVector3(0, 0, 0);
220
+ body.setLinearVelocity(zero);
221
+ body.setAngularVelocity(zero);
222
+ // 4. Reset transform to current position (optional — preserves pose)
223
+ const currentTransform = body.getWorldTransform();
224
+ body.setWorldTransform(currentTransform);
225
+ body.getMotionState().setWorldTransform(currentTransform);
226
+ // 5. Add back to physics world
227
+ this.matrixAmmo.dynamicsWorld.addRigidBody(body);
228
+ // 6. Mark it manually (logic flag)
229
+ body.isKinematic = true;
230
+ }
231
+
232
+ detectCollision() {
233
+ // console.log('override this')
234
+ return;
235
+ this.lastRoll = '';
236
+ this.presentScore = '';
237
+
238
+ let dispatcher = this.dynamicsWorld.getDispatcher();
239
+ let numManifolds = dispatcher.getNumManifolds();
240
+
241
+ for(let i = 0;i < numManifolds;i++) {
242
+ let contactManifold = dispatcher.getManifoldByIndexInternal(i);
243
+ // let numContacts = contactManifold.getNumContacts();
244
+ // this.rigidBodies.forEach((item) => {
245
+ // if(item.kB == contactManifold.getBody0().kB) {
246
+ // // console.log('Detected body0 =', item.name)
247
+ // }
248
+ // if(item.kB == contactManifold.getBody1().kB) {
249
+ // // console.log('Detected body1 =', item.name)
250
+ // }
251
+ // })
252
+
253
+ if(this.ground.kB == contactManifold.getBody0().kB &&
254
+ this.getNameByBody(contactManifold.getBody1()) == 'CubePhysics1') {
255
+ // console.log(this.ground ,'GROUND IS IN CONTACT WHO IS BODY1 ', contactManifold.getBody1())
256
+ // console.log('GROUND IS IN CONTACT WHO IS BODY1 getNameByBody ', this.getNameByBody(contactManifold.getBody1()))
257
+ // CHECK ROTATION
258
+ var testR = contactManifold.getBody1().getWorldTransform().getRotation();
259
+ if(Math.abs(testR.y()) < 0.00001) {
260
+ this.lastRoll += " 4 +";
261
+ this.presentScore += 4;
262
+ dispatchEvent(new CustomEvent('dice-1', {}));
263
+ }
264
+ if(Math.abs(testR.x()) < 0.00001) {
265
+ this.lastRoll += " 3 +";
266
+ this.presentScore += 3;
267
+ dispatchEvent(new CustomEvent('dice-4', {}));
268
+ }
269
+ if(testR.x().toString().substring(0, 5) == testR.y().toString().substring(1, 6)) {
270
+ this.lastRoll += " 2 +";
271
+ this.presentScore += 2;
272
+ dispatchEvent(new CustomEvent('dice-6', {}));
273
+ }
274
+
275
+ if(testR.x().toString().substring(0, 5) == testR.y().toString().substring(0, 5)) {
276
+ this.lastRoll += " 1 +";
277
+ this.presentScore += 1;
278
+ dispatchEvent(new CustomEvent('dice-2', {}));
279
+ }
280
+
281
+ if(testR.z().toString().substring(0, 5) == testR.y().toString().substring(1, 6)) {
282
+ this.lastRoll += " 6 +";
283
+ this.presentScore += 6;
284
+ dispatchEvent(new CustomEvent('dice-5', {}));
285
+ }
286
+
287
+ if(testR.z().toString().substring(0, 5) == testR.y().toString().substring(0, 5)) {
288
+ this.lastRoll += " 5 +";
289
+ this.presentScore += 5;
290
+ dispatchEvent(new CustomEvent('dice-3', {}));
291
+ }
292
+
293
+ console.log('this.lastRoll = ', this.lastRoll, ' presentScore = ', this.presentScore)
294
+ }
295
+ }
296
+ }
297
+
298
+ updatePhysics() {
299
+ if(typeof Ammo === 'undefined') return;
300
+ const trans = new Ammo.btTransform();
301
+ const transform = new Ammo.btTransform();
302
+
303
+ this.rigidBodies.forEach(function(body) {
304
+ if(body.isKinematic) {
305
+ transform.setIdentity();
306
+ transform.setOrigin(new Ammo.btVector3(
307
+ body.MEObject.position.x,
308
+ body.MEObject.position.y,
309
+ body.MEObject.position.z
310
+ ));
311
+ const quat = new Ammo.btQuaternion();
312
+ quat.setRotation(
313
+ new Ammo.btVector3(
314
+ body.MEObject.rotation.axis.x,
315
+ body.MEObject.rotation.axis.y,
316
+ body.MEObject.rotation.axis.z
317
+ ),
318
+ degToRad(body.MEObject.rotation.angle)
319
+ );
320
+ transform.setRotation(quat);
321
+
322
+ body.setWorldTransform(transform);
323
+ const ms = body.getMotionState();
324
+ if(ms) ms.setWorldTransform(transform);
325
+ }
326
+ });
327
+
328
+ Ammo.destroy(transform);
329
+
330
+ // Step simulation AFTER setting kinematic transforms
331
+ const timeStep = 1 / 60;
332
+ const maxSubSteps = 10;
333
+
334
+ for(let i = 0;i < this.speedUpSimulation;i++) {
335
+ this.dynamicsWorld.stepSimulation(timeStep, maxSubSteps);
336
+ }
337
+
338
+ this.rigidBodies.forEach(function(body) {
339
+ if(!body.isKinematic && body.getMotionState()) {
340
+ body.getMotionState().getWorldTransform(trans);
341
+
342
+ const _x = +trans.getOrigin().x().toFixed(2);
343
+ const _y = +trans.getOrigin().y().toFixed(2);
344
+ const _z = +trans.getOrigin().z().toFixed(2);
345
+
346
+ body.MEObject.position.setPosition(_x, _y, _z);
347
+
348
+ const rot = trans.getRotation();
349
+ const rotAxis = rot.getAxis();
350
+ rot.normalize();
351
+
352
+ body.MEObject.rotation.axis.x = rotAxis.x();
353
+ body.MEObject.rotation.axis.y = rotAxis.y();
354
+ body.MEObject.rotation.axis.z = rotAxis.z();
355
+ body.MEObject.rotation.matrixRotation = quaternion_rotation_matrix(rot);
356
+ body.MEObject.rotation.angle = radToDeg(parseFloat(rot.getAngle().toFixed(2)));
357
+ }
358
+ });
359
+
360
+ Ammo.destroy(trans);
361
+ this.detectCollision();
362
+ }
363
+ }
@@ -0,0 +1,83 @@
1
+ export let fragmentVideoWGSL = `override shadowDepthTextureSize: f32 = 1024.0;
2
+
3
+ struct Scene {
4
+ lightViewProjMatrix : mat4x4f,
5
+ cameraViewProjMatrix : mat4x4f,
6
+ lightPos : vec3f,
7
+ }
8
+
9
+ @group(0) @binding(0) var<uniform> scene : Scene;
10
+ @group(0) @binding(1) var shadowMap: texture_depth_2d;
11
+ @group(0) @binding(2) var shadowSampler: sampler_comparison;
12
+ @group(0) @binding(3) var meshTexture: texture_external;
13
+ @group(0) @binding(4) var meshSampler: sampler;
14
+
15
+ @group(0) @binding(5) var<uniform> postFXMode: u32;
16
+
17
+ // ❌ No binding(4) here!
18
+
19
+ struct FragmentInput {
20
+ @location(0) shadowPos : vec3f,
21
+ @location(1) fragPos : vec3f,
22
+ @location(2) fragNorm : vec3f,
23
+ @location(3) uv : vec2f,
24
+ }
25
+
26
+ const albedo = vec3f(0.9);
27
+ const ambientFactor = 0.7;
28
+
29
+ @fragment
30
+ fn main(input : FragmentInput) -> @location(0) vec4f {
31
+ // Shadow filtering
32
+ var visibility = 0.0;
33
+ let oneOverShadowDepthTextureSize = 1.0 / shadowDepthTextureSize;
34
+ for (var y = -1; y <= 1; y++) {
35
+ for (var x = -1; x <= 1; x++) {
36
+ let offset = vec2f(vec2(x, y)) * oneOverShadowDepthTextureSize;
37
+ visibility += textureSampleCompare(
38
+ shadowMap, shadowSampler,
39
+ input.shadowPos.xy + offset, input.shadowPos.z - 0.007
40
+ );
41
+ }
42
+ }
43
+ visibility /= 9.0;
44
+
45
+ let lambertFactor = max(dot(normalize(scene.lightPos - input.fragPos), normalize(input.fragNorm)), 0.0);
46
+ let lightingFactor = min(ambientFactor + visibility * lambertFactor, 1.0);
47
+
48
+ // ✅ Correct way to sample video texture
49
+ let textureColor = textureSampleBaseClampToEdge(meshTexture, meshSampler, input.uv);
50
+ let color: vec4f = vec4(textureColor.rgb * lightingFactor * albedo, 1.0);
51
+
52
+ switch (postFXMode) {
53
+ case 0: {
54
+ // Default
55
+ return color;
56
+ }
57
+ case 1: {
58
+ // Invert
59
+ return vec4f(1.0 - color.rgb, color.a);
60
+ }
61
+ case 2: {
62
+ // Grayscale
63
+ let gray = dot(color.rgb, vec3f(0.299, 0.587, 0.114));
64
+ return vec4f(vec3f(gray), color.a);
65
+ }
66
+ case 3: {
67
+ // Chroma Key
68
+ let keyColor = vec3f(0.0, 1.0, 0.0);
69
+ let threshold = 0.3;
70
+ let diff = distance(color.rgb, keyColor);
71
+ if (diff < threshold) {
72
+ return vec4f(0.0, 0.0, 0.0, 0.0);
73
+ }
74
+ return color;
75
+ }
76
+ default: {
77
+ return color;
78
+ }
79
+ }
80
+
81
+ // return color;
82
+ }
83
+ `;
@@ -0,0 +1,75 @@
1
+ export let fragmentWGSL = `override shadowDepthTextureSize: f32 = 1024.0;
2
+
3
+ struct Scene {
4
+ lightViewProjMatrix : mat4x4f,
5
+ cameraViewProjMatrix : mat4x4f,
6
+ lightPos : vec3f,
7
+ padding : f32, // Required for alignment
8
+ }
9
+
10
+ struct SpotLight {
11
+ position: vec3f,
12
+ _pad1: f32,
13
+ direction: vec3f,
14
+ _pad2: f32,
15
+ innerCutoff: f32,
16
+ outerCutoff: f32,
17
+ _pad3: vec2f,
18
+ }
19
+
20
+ @group(0) @binding(0) var<uniform> scene : Scene;
21
+ @group(0) @binding(1) var shadowMap: texture_depth_2d;
22
+ @group(0) @binding(2) var shadowSampler: sampler_comparison;
23
+ @group(0) @binding(3) var meshTexture: texture_2d<f32>;
24
+ @group(0) @binding(4) var meshSampler: sampler;
25
+ @group(0) @binding(5) var<uniform> spotlight: SpotLight;
26
+
27
+ struct FragmentInput {
28
+ @location(0) shadowPos : vec3f,
29
+ @location(1) fragPos : vec3f,
30
+ @location(2) fragNorm : vec3f,
31
+ @location(3) uv : vec2f,
32
+ }
33
+
34
+ const albedo = vec3f(0.9);
35
+ const ambientFactor = 0.7;
36
+
37
+ fn calculateSpotlightFactor(light: SpotLight, fragPos: vec3f) -> f32 {
38
+ let L = normalize(light.position - fragPos);
39
+ let theta = dot(L, normalize(-light.direction));
40
+ let epsilon = light.innerCutoff - light.outerCutoff;
41
+ let intensity = clamp((theta - light.outerCutoff) / epsilon, 0.0, 1.0);
42
+ return intensity;
43
+ }
44
+
45
+ @fragment
46
+ fn main(input : FragmentInput) -> @location(0) vec4f {
47
+ // Shadow PFC
48
+ var visibility = 0.0;
49
+ let oneOverSize = 1.0 / shadowDepthTextureSize;
50
+ for (var y = -1; y <= 1; y++) {
51
+ for (var x = -1; x <= 1; x++) {
52
+ let offset = vec2f(vec2(x, y)) * oneOverSize;
53
+ visibility += textureSampleCompare(
54
+ shadowMap, shadowSampler,
55
+ input.shadowPos.xy + offset, input.shadowPos.z - 0.007
56
+ );
57
+ }
58
+ }
59
+ visibility /= 9.0;
60
+
61
+ // Lambert
62
+ let norm = normalize(input.fragNorm);
63
+ let lightDir = normalize(scene.lightPos - input.fragPos);
64
+ let lambert = max(dot(norm, lightDir), 0.0);
65
+
66
+ // Spotlight effect
67
+ let spotlightFactor = calculateSpotlightFactor(spotlight, input.fragPos);
68
+
69
+ // Combine
70
+ let lightIntensity = ambientFactor + lambert * visibility * spotlightFactor;
71
+ let texColor = textureSample(meshTexture, meshSampler, input.uv);
72
+
73
+ return vec4f(texColor.rgb * lightIntensity * albedo, 1.0);
74
+ }
75
+ `
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @description
3
+ * UNIT Texures -
4
+ * Good for performance
5
+ */
6
+ export const UNLIT_SHADER = `struct Uniforms {
7
+ viewProjectionMatrix : mat4x4f
8
+ }
9
+ @group(0) @binding(0) var<uniform> uniforms : Uniforms;
10
+
11
+ @group(1) @binding(0) var<uniform> modelMatrix : mat4x4f;
12
+
13
+ struct VertexInput {
14
+ @location(0) position : vec4f,
15
+ @location(1) normal : vec3f,
16
+ @location(2) uv : vec2f
17
+ }
18
+
19
+ struct VertexOutput {
20
+ @builtin(position) position : vec4f,
21
+ @location(0) normal: vec3f,
22
+ @location(1) uv : vec2f,
23
+ }
24
+
25
+ @vertex
26
+ fn vertexMain(input: VertexInput) -> VertexOutput {
27
+ var output : VertexOutput;
28
+ output.position = uniforms.viewProjectionMatrix * modelMatrix * input.position;
29
+ output.normal = normalize((modelMatrix * vec4(input.normal, 0)).xyz);
30
+ output.uv = input.uv;
31
+ return output;
32
+ }
33
+
34
+ @group(1) @binding(1) var meshSampler: sampler;
35
+ @group(1) @binding(2) var meshTexture: texture_2d<f32>;
36
+
37
+ // Static directional lighting
38
+ const lightDir = vec3f(0, 1, 0);
39
+ const dirColor = vec3(1);
40
+ const ambientColor = vec3f(0.05);
41
+
42
+ @fragment
43
+ fn fragmentMain(input: VertexOutput) -> @location(0) vec4f {
44
+ let textureColor = textureSample(meshTexture, meshSampler, input.uv);
45
+
46
+ // Very simplified lighting algorithm.
47
+ let lightColor = saturate(ambientColor + max(dot(input.normal, lightDir), 0.0) * dirColor);
48
+
49
+ return vec4f(textureColor.rgb * lightColor, textureColor.a);
50
+ }`;
51
+
@@ -0,0 +1,56 @@
1
+ #version 300 es
2
+ precision mediump float;
3
+ in vec2 vTextureCoord;
4
+ in vec3 vLightWeighting;
5
+ uniform sampler2D uSampler;
6
+ uniform sampler2D uSampler1;
7
+ uniform sampler2D uSampler2;
8
+ uniform sampler2D uSampler3;
9
+ uniform sampler2D uSampler4;
10
+ uniform sampler2D uSampler5;
11
+ // The CubeMap texture.
12
+ uniform samplerCube u_texture;
13
+ // cube map
14
+ // in vec3 v_normal_cubemap;
15
+ uniform float numberOfsamplers;
16
+
17
+ // Spot
18
+ // Passed in from the vertex shader.
19
+ in vec3 v_normal;
20
+ in vec3 v_surfaceToLight;
21
+ in vec3 v_surfaceToView;
22
+ uniform vec4 u_color;
23
+ uniform float u_shininess;
24
+ uniform vec3 u_lightDirection;
25
+ uniform float u_innerLimit;
26
+ uniform float u_outerLimit;
27
+
28
+ out vec4 outColor;
29
+
30
+ void main(void) {
31
+ // because v_normal is a varying it's interpolated
32
+ // so it will not be a unit vector. Normalizing it
33
+ // will make it a unit vector again
34
+ vec3 normal = normalize(v_normal);
35
+
36
+ vec3 surfaceToLightDirection = normalize(v_surfaceToLight);
37
+ vec3 surfaceToViewDirection = normalize(v_surfaceToView);
38
+ vec3 halfVector = normalize(surfaceToLightDirection + surfaceToViewDirection);
39
+
40
+ float dotFromDirection = dot(surfaceToLightDirection, -u_lightDirection);
41
+ float limitRange = u_innerLimit - u_outerLimit;
42
+ float inLight = clamp((dotFromDirection - u_outerLimit) / limitRange, 0.0f, 1.0f);
43
+ float light = inLight * dot(normal, surfaceToLightDirection);
44
+ float specular = inLight * pow(dot(normal, halfVector), u_shininess);
45
+
46
+ // Directioin vs uAmbientColor
47
+ vec4 textureColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));
48
+ vec4 textureColor1 = texture2D(uSampler1, vec2(vTextureCoord.s, vTextureCoord.t));
49
+ vec4 textureColor2 = texture2D(uSampler2, vec2(vTextureCoord.s, vTextureCoord.t));
50
+ vec4 testUnused = texture2D(u_texture, vec2(vTextureCoord.s, vTextureCoord.t));
51
+
52
+ outColor = vec4(textureColor.rgb * vLightWeighting, textureColor.a);
53
+ // Lets multiply just the color portion (not the alpha)
54
+ outColor.rgb *= light;
55
+ outColor.rgb += specular;
56
+ }