melonjs 17.4.0 → 18.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (702) hide show
  1. package/{dist/types → build}/application/application.d.ts +9 -10
  2. package/build/application/application.d.ts.map +1 -0
  3. package/build/application/defaultApplicationSettings.d.ts +18 -0
  4. package/build/application/defaultApplicationSettings.d.ts.map +1 -0
  5. package/{dist/types → build}/application/header.d.ts +1 -0
  6. package/build/application/header.d.ts.map +1 -0
  7. package/{dist/types → build}/application/resize.d.ts +1 -0
  8. package/build/application/resize.d.ts.map +1 -0
  9. package/build/application/scaleMethods.d.ts +44 -0
  10. package/build/application/scaleMethods.d.ts.map +1 -0
  11. package/build/application/settings.d.ts +85 -0
  12. package/build/application/settings.d.ts.map +1 -0
  13. package/{dist/types → build}/audio/audio.d.ts +35 -58
  14. package/build/audio/audio.d.ts.map +1 -0
  15. package/{dist/types → build}/camera/camera2d.d.ts +38 -76
  16. package/build/camera/camera2d.d.ts.map +1 -0
  17. package/build/const.d.ts +14 -0
  18. package/build/const.d.ts.map +1 -0
  19. package/build/geometries/earcut.d.ts +3 -0
  20. package/build/geometries/earcut.d.ts.map +1 -0
  21. package/build/geometries/ellipse.d.ts +117 -0
  22. package/build/geometries/ellipse.d.ts.map +1 -0
  23. package/build/geometries/line.d.ts +39 -0
  24. package/build/geometries/line.d.ts.map +1 -0
  25. package/build/geometries/observablePoint.d.ts +75 -0
  26. package/build/geometries/observablePoint.d.ts.map +1 -0
  27. package/{dist/types → build}/geometries/path2d.d.ts +8 -7
  28. package/build/geometries/path2d.d.ts.map +1 -0
  29. package/build/geometries/point.d.ts +44 -0
  30. package/build/geometries/point.d.ts.map +1 -0
  31. package/build/geometries/polygon.d.ts +182 -0
  32. package/build/geometries/polygon.d.ts.map +1 -0
  33. package/build/geometries/rectangle.d.ts +135 -0
  34. package/build/geometries/rectangle.d.ts.map +1 -0
  35. package/build/geometries/roundrect.d.ts +67 -0
  36. package/build/geometries/roundrect.d.ts.map +1 -0
  37. package/build/geometries/toarccanvas.d.ts +28 -0
  38. package/build/geometries/toarccanvas.d.ts.map +1 -0
  39. package/{dist/types → build}/index.d.ts +41 -45
  40. package/build/index.d.ts.map +1 -0
  41. package/build/index.js +28318 -0
  42. package/build/index.js.map +7 -0
  43. package/{dist/types → build}/input/gamepad.d.ts +3 -11
  44. package/build/input/gamepad.d.ts.map +1 -0
  45. package/{dist/types → build}/input/input.d.ts +4 -2
  46. package/build/input/input.d.ts.map +1 -0
  47. package/build/input/key.d.ts +105 -0
  48. package/build/input/key.d.ts.map +1 -0
  49. package/build/input/keyboard.d.ts +72 -0
  50. package/build/input/keyboard.d.ts.map +1 -0
  51. package/build/input/pointer.d.ts +180 -0
  52. package/build/input/pointer.d.ts.map +1 -0
  53. package/{dist/types → build}/input/pointerevent.d.ts +17 -16
  54. package/build/input/pointerevent.d.ts.map +1 -0
  55. package/{dist/types → build}/lang/console.d.ts +1 -0
  56. package/build/lang/console.d.ts.map +1 -0
  57. package/build/lang/deprecated.d.ts +24 -0
  58. package/build/lang/deprecated.d.ts.map +1 -0
  59. package/{dist/types → build}/level/level.d.ts +7 -7
  60. package/build/level/level.d.ts.map +1 -0
  61. package/{dist/types → build}/level/tiled/TMXGroup.d.ts +2 -2
  62. package/build/level/tiled/TMXGroup.d.ts.map +1 -0
  63. package/{dist/types → build}/level/tiled/TMXLayer.d.ts +4 -4
  64. package/build/level/tiled/TMXLayer.d.ts.map +1 -0
  65. package/{dist/types → build}/level/tiled/TMXObject.d.ts +3 -3
  66. package/build/level/tiled/TMXObject.d.ts.map +1 -0
  67. package/{dist/types → build}/level/tiled/TMXTile.d.ts +4 -5
  68. package/build/level/tiled/TMXTile.d.ts.map +1 -0
  69. package/{dist/types → build}/level/tiled/TMXTileMap.d.ts +4 -4
  70. package/build/level/tiled/TMXTileMap.d.ts.map +1 -0
  71. package/{dist/types → build}/level/tiled/TMXTileset.d.ts +2 -2
  72. package/build/level/tiled/TMXTileset.d.ts.map +1 -0
  73. package/{dist/types → build}/level/tiled/TMXTilesetGroup.d.ts +1 -1
  74. package/build/level/tiled/TMXTilesetGroup.d.ts.map +1 -0
  75. package/{dist/types → build}/level/tiled/TMXUtils.d.ts +2 -1
  76. package/build/level/tiled/TMXUtils.d.ts.map +1 -0
  77. package/{dist/types → build}/level/tiled/constants.d.ts +1 -0
  78. package/build/level/tiled/constants.d.ts.map +1 -0
  79. package/{dist/types → build}/level/tiled/renderer/TMXHexagonalRenderer.d.ts +3 -4
  80. package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts.map +1 -0
  81. package/{dist/types → build}/level/tiled/renderer/TMXIsometricRenderer.d.ts +2 -3
  82. package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts.map +1 -0
  83. package/{dist/types → build}/level/tiled/renderer/TMXOrthogonalRenderer.d.ts +1 -2
  84. package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts.map +1 -0
  85. package/{dist/types → build}/level/tiled/renderer/TMXRenderer.d.ts +7 -7
  86. package/build/level/tiled/renderer/TMXRenderer.d.ts.map +1 -0
  87. package/{dist/types → build}/level/tiled/renderer/TMXStaggeredRenderer.d.ts +1 -2
  88. package/build/level/tiled/renderer/TMXStaggeredRenderer.d.ts.map +1 -0
  89. package/{dist/types → build}/level/tiled/renderer/autodetect.d.ts +4 -3
  90. package/build/level/tiled/renderer/autodetect.d.ts.map +1 -0
  91. package/build/loader/cache.d.ts +10 -0
  92. package/build/loader/cache.d.ts.map +1 -0
  93. package/{dist/types → build}/loader/loader.d.ts +19 -13
  94. package/build/loader/loader.d.ts.map +1 -0
  95. package/{dist/types → build}/loader/loadingscreen.d.ts +1 -0
  96. package/build/loader/loadingscreen.d.ts.map +1 -0
  97. package/{dist/types → build}/loader/parsers/binary.d.ts +2 -1
  98. package/build/loader/parsers/binary.d.ts.map +1 -0
  99. package/{dist/types → build}/loader/parsers/compressed_textures/compressed_image.d.ts +1 -0
  100. package/build/loader/parsers/compressed_textures/compressed_image.d.ts.map +1 -0
  101. package/build/loader/parsers/compressed_textures/parseDDS.d.ts +2 -0
  102. package/build/loader/parsers/compressed_textures/parseDDS.d.ts.map +1 -0
  103. package/build/loader/parsers/compressed_textures/parseKTX.d.ts +2 -0
  104. package/build/loader/parsers/compressed_textures/parseKTX.d.ts.map +1 -0
  105. package/build/loader/parsers/compressed_textures/parseKTX2.d.ts +2 -0
  106. package/build/loader/parsers/compressed_textures/parseKTX2.d.ts.map +1 -0
  107. package/build/loader/parsers/compressed_textures/parsePKM.d.ts +2 -0
  108. package/build/loader/parsers/compressed_textures/parsePKM.d.ts.map +1 -0
  109. package/build/loader/parsers/compressed_textures/parsePVR.d.ts +2 -0
  110. package/build/loader/parsers/compressed_textures/parsePVR.d.ts.map +1 -0
  111. package/{dist/types → build}/loader/parsers/fetchdata.d.ts +2 -1
  112. package/build/loader/parsers/fetchdata.d.ts.map +1 -0
  113. package/{dist/types → build}/loader/parsers/fontface.d.ts +2 -1
  114. package/build/loader/parsers/fontface.d.ts.map +1 -0
  115. package/{dist/types → build}/loader/parsers/image.d.ts +2 -1
  116. package/build/loader/parsers/image.d.ts.map +1 -0
  117. package/{dist/types → build}/loader/parsers/json.d.ts +2 -1
  118. package/build/loader/parsers/json.d.ts.map +1 -0
  119. package/{dist/types → build}/loader/parsers/script.d.ts +2 -1
  120. package/build/loader/parsers/script.d.ts.map +1 -0
  121. package/{dist/types → build}/loader/parsers/tmx.d.ts +2 -1
  122. package/build/loader/parsers/tmx.d.ts.map +1 -0
  123. package/{dist/types → build}/loader/parsers/video.d.ts +2 -1
  124. package/build/loader/parsers/video.d.ts.map +1 -0
  125. package/build/math/color.d.ts +192 -0
  126. package/build/math/color.d.ts.map +1 -0
  127. package/build/math/math.d.ts +128 -0
  128. package/build/math/math.d.ts.map +1 -0
  129. package/build/math/matrix2d.d.ts +163 -0
  130. package/build/math/matrix2d.d.ts.map +1 -0
  131. package/build/math/matrix3d.d.ts +188 -0
  132. package/build/math/matrix3d.d.ts.map +1 -0
  133. package/build/math/observableVector2d.d.ts +286 -0
  134. package/build/math/observableVector2d.d.ts.map +1 -0
  135. package/build/math/observableVector2d_old.d.ts +76 -0
  136. package/build/math/observableVector2d_old.d.ts.map +1 -0
  137. package/build/math/observableVector3d.d.ts +283 -0
  138. package/build/math/observableVector3d.d.ts.map +1 -0
  139. package/build/math/observableVector3d_old.d.ts +81 -0
  140. package/build/math/observableVector3d_old.d.ts.map +1 -0
  141. package/build/math/vector2d.d.ts +253 -0
  142. package/build/math/vector2d.d.ts.map +1 -0
  143. package/build/math/vector3d.d.ts +242 -0
  144. package/build/math/vector3d.d.ts.map +1 -0
  145. package/{dist/types → build}/particles/emitter.d.ts +7 -10
  146. package/build/particles/emitter.d.ts.map +1 -0
  147. package/build/particles/particle.d.ts +47 -0
  148. package/build/particles/particle.d.ts.map +1 -0
  149. package/{dist/types → build}/particles/settings.d.ts +1 -0
  150. package/build/particles/settings.d.ts.map +1 -0
  151. package/{dist/types → build}/physics/body.d.ts +27 -27
  152. package/build/physics/body.d.ts.map +1 -0
  153. package/build/physics/bounds.d.ts +192 -0
  154. package/build/physics/bounds.d.ts.map +1 -0
  155. package/{dist/types → build}/physics/collision.d.ts +5 -5
  156. package/build/physics/collision.d.ts.map +1 -0
  157. package/{dist/types → build}/physics/detector.d.ts +8 -6
  158. package/build/physics/detector.d.ts.map +1 -0
  159. package/{dist/types → build}/physics/quadtree.d.ts +5 -19
  160. package/build/physics/quadtree.d.ts.map +1 -0
  161. package/{dist/types → build}/physics/response.d.ts +46 -5
  162. package/build/physics/response.d.ts.map +1 -0
  163. package/{dist/types → build}/physics/sat.d.ts +3 -2
  164. package/build/physics/sat.d.ts.map +1 -0
  165. package/{dist/types → build}/physics/world.d.ts +5 -4
  166. package/build/physics/world.d.ts.map +1 -0
  167. package/{dist/types → build}/plugin/plugin.d.ts +8 -19
  168. package/build/plugin/plugin.d.ts.map +1 -0
  169. package/build/polyfill/console.d.ts +2 -0
  170. package/build/polyfill/console.d.ts.map +1 -0
  171. package/build/polyfill/index.d.ts +6 -0
  172. package/build/polyfill/index.d.ts.map +1 -0
  173. package/build/polyfill/roundrect.d.ts +2 -0
  174. package/build/polyfill/roundrect.d.ts.map +1 -0
  175. package/build/pool.d.ts +39 -0
  176. package/build/pool.d.ts.map +1 -0
  177. package/{dist/types → build}/renderable/collectable.d.ts +2 -2
  178. package/build/renderable/collectable.d.ts.map +1 -0
  179. package/{dist/types → build}/renderable/colorlayer.d.ts +6 -10
  180. package/build/renderable/colorlayer.d.ts.map +1 -0
  181. package/{dist/types → build}/renderable/container.d.ts +14 -15
  182. package/build/renderable/container.d.ts.map +1 -0
  183. package/{dist/types → build}/renderable/draggable.d.ts +5 -13
  184. package/build/renderable/draggable.d.ts.map +1 -0
  185. package/{dist/types → build}/renderable/dragndrop.d.ts +7 -21
  186. package/build/renderable/dragndrop.d.ts.map +1 -0
  187. package/{dist/types → build}/renderable/entity/entity.d.ts +12 -13
  188. package/build/renderable/entity/entity.d.ts.map +1 -0
  189. package/{dist/types → build}/renderable/imagelayer.d.ts +17 -9
  190. package/build/renderable/imagelayer.d.ts.map +1 -0
  191. package/build/renderable/light2d.d.ts +73 -0
  192. package/build/renderable/light2d.d.ts.map +1 -0
  193. package/{dist/types → build}/renderable/nineslicesprite.d.ts +3 -4
  194. package/build/renderable/nineslicesprite.d.ts.map +1 -0
  195. package/{dist/types → build}/renderable/renderable.d.ts +57 -60
  196. package/build/renderable/renderable.d.ts.map +1 -0
  197. package/{dist/types → build}/renderable/sprite.d.ts +28 -14
  198. package/build/renderable/sprite.d.ts.map +1 -0
  199. package/{dist/types → build}/renderable/text/bitmaptext.d.ts +6 -7
  200. package/build/renderable/text/bitmaptext.d.ts.map +1 -0
  201. package/build/renderable/text/bitmaptextdata.d.ts +17 -0
  202. package/build/renderable/text/bitmaptextdata.d.ts.map +1 -0
  203. package/{dist/types → build}/renderable/text/glyph.d.ts +15 -3
  204. package/build/renderable/text/glyph.d.ts.map +1 -0
  205. package/{dist/types → build}/renderable/text/text.d.ts +7 -16
  206. package/build/renderable/text/text.d.ts.map +1 -0
  207. package/{dist/types → build}/renderable/text/textmetrics.d.ts +8 -9
  208. package/build/renderable/text/textmetrics.d.ts.map +1 -0
  209. package/{dist/types → build}/renderable/text/textstyle.d.ts +1 -0
  210. package/build/renderable/text/textstyle.d.ts.map +1 -0
  211. package/{dist/types → build}/renderable/trigger.d.ts +18 -7
  212. package/build/renderable/trigger.d.ts.map +1 -0
  213. package/{dist/types → build}/renderable/ui/uibaseelement.d.ts +7 -7
  214. package/build/renderable/ui/uibaseelement.d.ts.map +1 -0
  215. package/{dist/types → build}/renderable/ui/uispriteelement.d.ts +4 -6
  216. package/build/renderable/ui/uispriteelement.d.ts.map +1 -0
  217. package/{dist/types → build}/renderable/ui/uitextbutton.d.ts +17 -4
  218. package/build/renderable/ui/uitextbutton.d.ts.map +1 -0
  219. package/{dist/types → build}/state/stage.d.ts +3 -3
  220. package/build/state/stage.d.ts.map +1 -0
  221. package/{dist/types → build}/state/state.d.ts +10 -9
  222. package/build/state/state.d.ts.map +1 -0
  223. package/{dist/types → build}/system/device.d.ts +49 -80
  224. package/build/system/device.d.ts.map +1 -0
  225. package/build/system/dom.d.ts +2 -0
  226. package/build/system/dom.d.ts.map +1 -0
  227. package/{dist/types → build}/system/event.d.ts +124 -291
  228. package/build/system/event.d.ts.map +1 -0
  229. package/build/system/eventEmitter.d.ts +19 -0
  230. package/build/system/eventEmitter.d.ts.map +1 -0
  231. package/build/system/eventEmitter.spec.d.ts +2 -0
  232. package/build/system/eventEmitter.spec.d.ts.map +1 -0
  233. package/{dist/types/system/pooling.d.ts → build/system/legacy_pool.d.ts} +22 -7
  234. package/build/system/legacy_pool.d.ts.map +1 -0
  235. package/build/system/platform.d.ts +34 -0
  236. package/build/system/platform.d.ts.map +1 -0
  237. package/build/system/pool.d.ts +26 -0
  238. package/build/system/pool.d.ts.map +1 -0
  239. package/build/system/save.d.ts +3 -0
  240. package/build/system/save.d.ts.map +1 -0
  241. package/build/system/timer.d.ts +118 -0
  242. package/build/system/timer.d.ts.map +1 -0
  243. package/build/tweens/easing.d.ts +93 -0
  244. package/build/tweens/easing.d.ts.map +1 -0
  245. package/build/tweens/interpolation.d.ts +7 -0
  246. package/build/tweens/interpolation.d.ts.map +1 -0
  247. package/build/tweens/tween.d.ts +234 -0
  248. package/build/tweens/tween.d.ts.map +1 -0
  249. package/build/utils/agent.d.ts +16 -0
  250. package/build/utils/agent.d.ts.map +1 -0
  251. package/build/utils/array-multimap.d.ts +14 -0
  252. package/build/utils/array-multimap.d.ts.map +1 -0
  253. package/build/utils/array.d.ts +30 -0
  254. package/build/utils/array.d.ts.map +1 -0
  255. package/build/utils/file.d.ts +16 -0
  256. package/build/utils/file.d.ts.map +1 -0
  257. package/build/utils/function.d.ts +24 -0
  258. package/build/utils/function.d.ts.map +1 -0
  259. package/build/utils/semver.d.ts +2 -0
  260. package/build/utils/semver.d.ts.map +1 -0
  261. package/build/utils/string.d.ts +35 -0
  262. package/build/utils/string.d.ts.map +1 -0
  263. package/build/utils/types.d.ts +5 -0
  264. package/build/utils/types.d.ts.map +1 -0
  265. package/build/utils/utils.d.ts +49 -0
  266. package/build/utils/utils.d.ts.map +1 -0
  267. package/build/version.d.ts +5 -0
  268. package/build/version.d.ts.map +1 -0
  269. package/{dist/types → build}/video/canvas/canvas_renderer.d.ts +40 -32
  270. package/build/video/canvas/canvas_renderer.d.ts.map +1 -0
  271. package/{dist/types → build}/video/renderer.d.ts +36 -29
  272. package/build/video/renderer.d.ts.map +1 -0
  273. package/{dist/types → build}/video/rendertarget/canvasrendertarget.d.ts +8 -26
  274. package/build/video/rendertarget/canvasrendertarget.d.ts.map +1 -0
  275. package/{dist/types → build}/video/texture/atlas.d.ts +8 -8
  276. package/build/video/texture/atlas.d.ts.map +1 -0
  277. package/{dist/types → build}/video/texture/cache.d.ts +4 -3
  278. package/build/video/texture/cache.d.ts.map +1 -0
  279. package/{dist/types → build}/video/texture/parser/aseprite.d.ts +1 -0
  280. package/build/video/texture/parser/aseprite.d.ts.map +1 -0
  281. package/{dist/types → build}/video/texture/parser/spritesheet.d.ts +1 -0
  282. package/build/video/texture/parser/spritesheet.d.ts.map +1 -0
  283. package/{dist/types → build}/video/texture/parser/texturepacker.d.ts +1 -0
  284. package/build/video/texture/parser/texturepacker.d.ts.map +1 -0
  285. package/build/video/utils/autodetect.d.ts +8 -0
  286. package/build/video/utils/autodetect.d.ts.map +1 -0
  287. package/{dist/types → build}/video/video.d.ts +4 -3
  288. package/build/video/video.d.ts.map +1 -0
  289. package/{dist/types → build}/video/webgl/buffer/vertex.d.ts +5 -6
  290. package/build/video/webgl/buffer/vertex.d.ts.map +1 -0
  291. package/{dist/types → build}/video/webgl/compositors/compositor.d.ts +4 -4
  292. package/build/video/webgl/compositors/compositor.d.ts.map +1 -0
  293. package/{dist/types → build}/video/webgl/compositors/primitive_compositor.d.ts +4 -5
  294. package/build/video/webgl/compositors/primitive_compositor.d.ts.map +1 -0
  295. package/{dist/types → build}/video/webgl/compositors/quad_compositor.d.ts +4 -5
  296. package/build/video/webgl/compositors/quad_compositor.d.ts.map +1 -0
  297. package/{dist/types → build}/video/webgl/glshader.d.ts +2 -2
  298. package/build/video/webgl/glshader.d.ts.map +1 -0
  299. package/{dist/types → build}/video/webgl/utils/attributes.d.ts +1 -0
  300. package/build/video/webgl/utils/attributes.d.ts.map +1 -0
  301. package/{dist/types → build}/video/webgl/utils/precision.d.ts +1 -0
  302. package/build/video/webgl/utils/precision.d.ts.map +1 -0
  303. package/{dist/types → build}/video/webgl/utils/program.d.ts +1 -0
  304. package/build/video/webgl/utils/program.d.ts.map +1 -0
  305. package/{dist/types → build}/video/webgl/utils/string.d.ts +1 -0
  306. package/build/video/webgl/utils/string.d.ts.map +1 -0
  307. package/{dist/types → build}/video/webgl/utils/uniforms.d.ts +1 -0
  308. package/build/video/webgl/utils/uniforms.d.ts.map +1 -0
  309. package/{dist/types → build}/video/webgl/webgl_renderer.d.ts +37 -29
  310. package/build/video/webgl/webgl_renderer.d.ts.map +1 -0
  311. package/package.json +83 -104
  312. package/LICENSE.md +0 -21
  313. package/README.md +0 -223
  314. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +0 -14
  315. package/dist/melonjs.mjs/_virtual/earcut.js +0 -10
  316. package/dist/melonjs.mjs/_virtual/howler.js +0 -10
  317. package/dist/melonjs.mjs/_virtual/index.js +0 -10
  318. package/dist/melonjs.mjs/_virtual/re.js +0 -10
  319. package/dist/melonjs.mjs/application/application.js +0 -443
  320. package/dist/melonjs.mjs/application/header.js +0 -40
  321. package/dist/melonjs.mjs/application/resize.js +0 -128
  322. package/dist/melonjs.mjs/application/settings.js +0 -70
  323. package/dist/melonjs.mjs/audio/audio.js +0 -623
  324. package/dist/melonjs.mjs/camera/camera2d.js +0 -737
  325. package/dist/melonjs.mjs/const.js +0 -32
  326. package/dist/melonjs.mjs/geometries/ellipse.js +0 -253
  327. package/dist/melonjs.mjs/geometries/line.js +0 -113
  328. package/dist/melonjs.mjs/geometries/path2d.js +0 -479
  329. package/dist/melonjs.mjs/geometries/point.js +0 -85
  330. package/dist/melonjs.mjs/geometries/poly.js +0 -441
  331. package/dist/melonjs.mjs/geometries/rectangle.js +0 -335
  332. package/dist/melonjs.mjs/geometries/roundrect.js +0 -165
  333. package/dist/melonjs.mjs/geometries/toarccanvas.js +0 -103
  334. package/dist/melonjs.mjs/index.js +0 -239
  335. package/dist/melonjs.mjs/input/gamepad.js +0 -495
  336. package/dist/melonjs.mjs/input/input.js +0 -26
  337. package/dist/melonjs.mjs/input/keyboard.js +0 -470
  338. package/dist/melonjs.mjs/input/pointer.js +0 -393
  339. package/dist/melonjs.mjs/input/pointerevent.js +0 -807
  340. package/dist/melonjs.mjs/lang/console.js +0 -44
  341. package/dist/melonjs.mjs/lang/deprecated.js +0 -200
  342. package/dist/melonjs.mjs/level/level.js +0 -298
  343. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +0 -120
  344. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +0 -432
  345. package/dist/melonjs.mjs/level/tiled/TMXObject.js +0 -295
  346. package/dist/melonjs.mjs/level/tiled/TMXTile.js +0 -177
  347. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +0 -574
  348. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +0 -292
  349. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +0 -74
  350. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +0 -417
  351. package/dist/melonjs.mjs/level/tiled/constants.js +0 -17
  352. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +0 -503
  353. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +0 -215
  354. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +0 -155
  355. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +0 -113
  356. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +0 -107
  357. package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +0 -38
  358. package/dist/melonjs.mjs/loader/cache.js +0 -30
  359. package/dist/melonjs.mjs/loader/loader.js +0 -729
  360. package/dist/melonjs.mjs/loader/loadingscreen.js +0 -118
  361. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +0 -10
  362. package/dist/melonjs.mjs/loader/parsers/binary.js +0 -42
  363. package/dist/melonjs.mjs/loader/parsers/compressed_textures/compressed_image.js +0 -58
  364. package/dist/melonjs.mjs/loader/parsers/compressed_textures/parseDDS.js +0 -13
  365. package/dist/melonjs.mjs/loader/parsers/compressed_textures/parseKTX.js +0 -13
  366. package/dist/melonjs.mjs/loader/parsers/compressed_textures/parseKTX2.js +0 -13
  367. package/dist/melonjs.mjs/loader/parsers/compressed_textures/parsePKM.js +0 -13
  368. package/dist/melonjs.mjs/loader/parsers/compressed_textures/parsePVR.js +0 -136
  369. package/dist/melonjs.mjs/loader/parsers/fetchdata.js +0 -62
  370. package/dist/melonjs.mjs/loader/parsers/fontface.js +0 -62
  371. package/dist/melonjs.mjs/loader/parsers/image.js +0 -129
  372. package/dist/melonjs.mjs/loader/parsers/json.js +0 -43
  373. package/dist/melonjs.mjs/loader/parsers/script.js +0 -46
  374. package/dist/melonjs.mjs/loader/parsers/tmx.js +0 -103
  375. package/dist/melonjs.mjs/loader/parsers/video.js +0 -99
  376. package/dist/melonjs.mjs/math/color.js +0 -635
  377. package/dist/melonjs.mjs/math/math.js +0 -221
  378. package/dist/melonjs.mjs/math/matrix2.js +0 -495
  379. package/dist/melonjs.mjs/math/matrix3.js +0 -628
  380. package/dist/melonjs.mjs/math/observable_vector2.js +0 -468
  381. package/dist/melonjs.mjs/math/observable_vector3.js +0 -564
  382. package/dist/melonjs.mjs/math/vector2.js +0 -431
  383. package/dist/melonjs.mjs/math/vector3.js +0 -473
  384. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +0 -45
  385. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +0 -130
  386. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +0 -694
  387. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +0 -352
  388. package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +0 -12
  389. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +0 -3246
  390. package/dist/melonjs.mjs/node_modules/semver/classes/comparator.js +0 -165
  391. package/dist/melonjs.mjs/node_modules/semver/classes/range.js +0 -565
  392. package/dist/melonjs.mjs/node_modules/semver/classes/semver.js +0 -317
  393. package/dist/melonjs.mjs/node_modules/semver/functions/clean.js +0 -17
  394. package/dist/melonjs.mjs/node_modules/semver/functions/cmp.js +0 -68
  395. package/dist/melonjs.mjs/node_modules/semver/functions/coerce.js +0 -73
  396. package/dist/melonjs.mjs/node_modules/semver/functions/compare-build.js +0 -18
  397. package/dist/melonjs.mjs/node_modules/semver/functions/compare-loose.js +0 -14
  398. package/dist/melonjs.mjs/node_modules/semver/functions/compare.js +0 -16
  399. package/dist/melonjs.mjs/node_modules/semver/functions/diff.js +0 -76
  400. package/dist/melonjs.mjs/node_modules/semver/functions/eq.js +0 -14
  401. package/dist/melonjs.mjs/node_modules/semver/functions/gt.js +0 -14
  402. package/dist/melonjs.mjs/node_modules/semver/functions/gte.js +0 -14
  403. package/dist/melonjs.mjs/node_modules/semver/functions/inc.js +0 -30
  404. package/dist/melonjs.mjs/node_modules/semver/functions/lt.js +0 -14
  405. package/dist/melonjs.mjs/node_modules/semver/functions/lte.js +0 -14
  406. package/dist/melonjs.mjs/node_modules/semver/functions/major.js +0 -14
  407. package/dist/melonjs.mjs/node_modules/semver/functions/minor.js +0 -14
  408. package/dist/melonjs.mjs/node_modules/semver/functions/neq.js +0 -14
  409. package/dist/melonjs.mjs/node_modules/semver/functions/parse.js +0 -27
  410. package/dist/melonjs.mjs/node_modules/semver/functions/patch.js +0 -14
  411. package/dist/melonjs.mjs/node_modules/semver/functions/prerelease.js +0 -17
  412. package/dist/melonjs.mjs/node_modules/semver/functions/rcompare.js +0 -14
  413. package/dist/melonjs.mjs/node_modules/semver/functions/rsort.js +0 -14
  414. package/dist/melonjs.mjs/node_modules/semver/functions/satisfies.js +0 -21
  415. package/dist/melonjs.mjs/node_modules/semver/functions/sort.js +0 -14
  416. package/dist/melonjs.mjs/node_modules/semver/functions/valid.js +0 -17
  417. package/dist/melonjs.mjs/node_modules/semver/index.js +0 -140
  418. package/dist/melonjs.mjs/node_modules/semver/internal/constants.js +0 -44
  419. package/dist/melonjs.mjs/node_modules/semver/internal/debug.js +0 -18
  420. package/dist/melonjs.mjs/node_modules/semver/internal/identifiers.js +0 -32
  421. package/dist/melonjs.mjs/node_modules/semver/internal/lrucache.js +0 -49
  422. package/dist/melonjs.mjs/node_modules/semver/internal/parse-options.js +0 -24
  423. package/dist/melonjs.mjs/node_modules/semver/internal/re.js +0 -234
  424. package/dist/melonjs.mjs/node_modules/semver/ranges/gtr.js +0 -15
  425. package/dist/melonjs.mjs/node_modules/semver/ranges/intersects.js +0 -18
  426. package/dist/melonjs.mjs/node_modules/semver/ranges/ltr.js +0 -15
  427. package/dist/melonjs.mjs/node_modules/semver/ranges/max-satisfying.js +0 -37
  428. package/dist/melonjs.mjs/node_modules/semver/ranges/min-satisfying.js +0 -36
  429. package/dist/melonjs.mjs/node_modules/semver/ranges/min-version.js +0 -74
  430. package/dist/melonjs.mjs/node_modules/semver/ranges/outside.js +0 -98
  431. package/dist/melonjs.mjs/node_modules/semver/ranges/simplify.js +0 -59
  432. package/dist/melonjs.mjs/node_modules/semver/ranges/subset.js +0 -261
  433. package/dist/melonjs.mjs/node_modules/semver/ranges/to-comparators.js +0 -19
  434. package/dist/melonjs.mjs/node_modules/semver/ranges/valid.js +0 -22
  435. package/dist/melonjs.mjs/particles/emitter.js +0 -265
  436. package/dist/melonjs.mjs/particles/particle.js +0 -190
  437. package/dist/melonjs.mjs/particles/settings.js +0 -317
  438. package/dist/melonjs.mjs/physics/body.js +0 -717
  439. package/dist/melonjs.mjs/physics/bounds.js +0 -415
  440. package/dist/melonjs.mjs/physics/collision.js +0 -135
  441. package/dist/melonjs.mjs/physics/detector.js +0 -227
  442. package/dist/melonjs.mjs/physics/quadtree.js +0 -402
  443. package/dist/melonjs.mjs/physics/response.js +0 -57
  444. package/dist/melonjs.mjs/physics/sat.js +0 -492
  445. package/dist/melonjs.mjs/physics/world.js +0 -228
  446. package/dist/melonjs.mjs/plugin/plugin.js +0 -172
  447. package/dist/melonjs.mjs/renderable/collectable.js +0 -60
  448. package/dist/melonjs.mjs/renderable/colorlayer.js +0 -83
  449. package/dist/melonjs.mjs/renderable/container.js +0 -1016
  450. package/dist/melonjs.mjs/renderable/draggable.js +0 -121
  451. package/dist/melonjs.mjs/renderable/dragndrop.js +0 -119
  452. package/dist/melonjs.mjs/renderable/entity/entity.js +0 -263
  453. package/dist/melonjs.mjs/renderable/imagelayer.js +0 -293
  454. package/dist/melonjs.mjs/renderable/light2d.js +0 -172
  455. package/dist/melonjs.mjs/renderable/nineslicesprite.js +0 -248
  456. package/dist/melonjs.mjs/renderable/renderable.js +0 -878
  457. package/dist/melonjs.mjs/renderable/sprite.js +0 -700
  458. package/dist/melonjs.mjs/renderable/text/bitmaptext.js +0 -421
  459. package/dist/melonjs.mjs/renderable/text/bitmaptextdata.js +0 -195
  460. package/dist/melonjs.mjs/renderable/text/glyph.js +0 -65
  461. package/dist/melonjs.mjs/renderable/text/text.js +0 -424
  462. package/dist/melonjs.mjs/renderable/text/textmetrics.js +0 -176
  463. package/dist/melonjs.mjs/renderable/text/textstyle.js +0 -21
  464. package/dist/melonjs.mjs/renderable/trigger.js +0 -163
  465. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +0 -285
  466. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +0 -231
  467. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +0 -146
  468. package/dist/melonjs.mjs/state/stage.js +0 -235
  469. package/dist/melonjs.mjs/state/state.js +0 -548
  470. package/dist/melonjs.mjs/system/device.js +0 -872
  471. package/dist/melonjs.mjs/system/dom.js +0 -79
  472. package/dist/melonjs.mjs/system/event.js +0 -606
  473. package/dist/melonjs.mjs/system/platform.js +0 -43
  474. package/dist/melonjs.mjs/system/pooling.js +0 -182
  475. package/dist/melonjs.mjs/system/save.js +0 -157
  476. package/dist/melonjs.mjs/system/timer.js +0 -274
  477. package/dist/melonjs.mjs/tweens/easing.js +0 -334
  478. package/dist/melonjs.mjs/tweens/interpolation.js +0 -112
  479. package/dist/melonjs.mjs/tweens/tween.js +0 -479
  480. package/dist/melonjs.mjs/utils/agent.js +0 -77
  481. package/dist/melonjs.mjs/utils/array.js +0 -63
  482. package/dist/melonjs.mjs/utils/file.js +0 -54
  483. package/dist/melonjs.mjs/utils/function.js +0 -69
  484. package/dist/melonjs.mjs/utils/string.js +0 -82
  485. package/dist/melonjs.mjs/utils/utils.js +0 -139
  486. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +0 -914
  487. package/dist/melonjs.mjs/video/renderer.js +0 -402
  488. package/dist/melonjs.mjs/video/rendertarget/canvasrendertarget.js +0 -316
  489. package/dist/melonjs.mjs/video/texture/atlas.js +0 -465
  490. package/dist/melonjs.mjs/video/texture/cache.js +0 -186
  491. package/dist/melonjs.mjs/video/texture/parser/aseprite.js +0 -78
  492. package/dist/melonjs.mjs/video/texture/parser/spritesheet.js +0 -77
  493. package/dist/melonjs.mjs/video/texture/parser/texturepacker.js +0 -64
  494. package/dist/melonjs.mjs/video/utils/autodetect.js +0 -27
  495. package/dist/melonjs.mjs/video/video.js +0 -142
  496. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +0 -146
  497. package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +0 -240
  498. package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +0 -82
  499. package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +0 -259
  500. package/dist/melonjs.mjs/video/webgl/glshader.js +0 -166
  501. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +0 -10
  502. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +0 -10
  503. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +0 -10
  504. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +0 -10
  505. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +0 -25
  506. package/dist/melonjs.mjs/video/webgl/utils/precision.js +0 -38
  507. package/dist/melonjs.mjs/video/webgl/utils/program.js +0 -67
  508. package/dist/melonjs.mjs/video/webgl/utils/string.js +0 -25
  509. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +0 -92
  510. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +0 -1246
  511. package/dist/melonjs.module.js +0 -43200
  512. package/dist/types/application/settings.d.ts +0 -106
  513. package/dist/types/const.d.ts +0 -21
  514. package/dist/types/geometries/ellipse.d.ts +0 -138
  515. package/dist/types/geometries/line.d.ts +0 -15
  516. package/dist/types/geometries/point.d.ts +0 -50
  517. package/dist/types/geometries/poly.d.ts +0 -186
  518. package/dist/types/geometries/rectangle.d.ts +0 -135
  519. package/dist/types/geometries/roundrect.d.ts +0 -43
  520. package/dist/types/geometries/toarccanvas.d.ts +0 -10
  521. package/dist/types/input/keyboard.d.ts +0 -205
  522. package/dist/types/input/pointer.d.ts +0 -261
  523. package/dist/types/lang/deprecated.d.ts +0 -68
  524. package/dist/types/loader/cache.d.ts +0 -9
  525. package/dist/types/loader/parsers/compressed_textures/parseDDS.d.ts +0 -1
  526. package/dist/types/loader/parsers/compressed_textures/parseKTX.d.ts +0 -1
  527. package/dist/types/loader/parsers/compressed_textures/parseKTX2.d.ts +0 -1
  528. package/dist/types/loader/parsers/compressed_textures/parsePKM.d.ts +0 -1
  529. package/dist/types/loader/parsers/compressed_textures/parsePVR.d.ts +0 -1
  530. package/dist/types/math/color.d.ts +0 -179
  531. package/dist/types/math/math.d.ts +0 -149
  532. package/dist/types/math/matrix2.d.ts +0 -174
  533. package/dist/types/math/matrix3.d.ts +0 -186
  534. package/dist/types/math/observable_vector2.d.ts +0 -278
  535. package/dist/types/math/observable_vector3.d.ts +0 -300
  536. package/dist/types/math/vector2.d.ts +0 -255
  537. package/dist/types/math/vector3.d.ts +0 -271
  538. package/dist/types/particles/particle.d.ts +0 -36
  539. package/dist/types/physics/bounds.d.ts +0 -203
  540. package/dist/types/polyfill/console.d.ts +0 -1
  541. package/dist/types/polyfill/index.d.ts +0 -1
  542. package/dist/types/polyfill/roundrect.d.ts +0 -1
  543. package/dist/types/renderable/light2d.d.ts +0 -60
  544. package/dist/types/renderable/text/bitmaptextdata.d.ts +0 -35
  545. package/dist/types/system/dom.d.ts +0 -1
  546. package/dist/types/system/platform.d.ts +0 -33
  547. package/dist/types/system/save.d.ts +0 -25
  548. package/dist/types/system/timer.d.ts +0 -126
  549. package/dist/types/tweens/easing.d.ts +0 -46
  550. package/dist/types/tweens/interpolation.d.ts +0 -18
  551. package/dist/types/tweens/tween.d.ts +0 -195
  552. package/dist/types/utils/agent.d.ts +0 -21
  553. package/dist/types/utils/array.d.ts +0 -39
  554. package/dist/types/utils/file.d.ts +0 -27
  555. package/dist/types/utils/function.d.ts +0 -31
  556. package/dist/types/utils/string.d.ts +0 -50
  557. package/dist/types/utils/utils.d.ts +0 -54
  558. package/dist/types/video/utils/autodetect.d.ts +0 -5
  559. package/src/application/application.js +0 -435
  560. package/src/application/header.js +0 -31
  561. package/src/application/resize.js +0 -119
  562. package/src/application/settings.js +0 -61
  563. package/src/audio/audio.js +0 -622
  564. package/src/camera/camera2d.js +0 -731
  565. package/src/const.js +0 -23
  566. package/src/geometries/ellipse.js +0 -244
  567. package/src/geometries/line.js +0 -104
  568. package/src/geometries/path2d.js +0 -470
  569. package/src/geometries/point.js +0 -76
  570. package/src/geometries/poly.js +0 -432
  571. package/src/geometries/rectangle.js +0 -326
  572. package/src/geometries/roundrect.js +0 -156
  573. package/src/geometries/toarccanvas.js +0 -94
  574. package/src/index.js +0 -315
  575. package/src/input/gamepad.js +0 -487
  576. package/src/input/input.js +0 -17
  577. package/src/input/keyboard.js +0 -461
  578. package/src/input/pointer.js +0 -386
  579. package/src/input/pointerevent.js +0 -798
  580. package/src/lang/console.js +0 -36
  581. package/src/lang/deprecated.js +0 -192
  582. package/src/level/level.js +0 -290
  583. package/src/level/tiled/TMXGroup.js +0 -111
  584. package/src/level/tiled/TMXLayer.js +0 -424
  585. package/src/level/tiled/TMXObject.js +0 -286
  586. package/src/level/tiled/TMXTile.js +0 -168
  587. package/src/level/tiled/TMXTileMap.js +0 -569
  588. package/src/level/tiled/TMXTileset.js +0 -284
  589. package/src/level/tiled/TMXTilesetGroup.js +0 -66
  590. package/src/level/tiled/TMXUtils.js +0 -408
  591. package/src/level/tiled/constants.js +0 -8
  592. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +0 -497
  593. package/src/level/tiled/renderer/TMXIsometricRenderer.js +0 -208
  594. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +0 -149
  595. package/src/level/tiled/renderer/TMXRenderer.js +0 -103
  596. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +0 -100
  597. package/src/level/tiled/renderer/autodetect.js +0 -29
  598. package/src/loader/cache.js +0 -22
  599. package/src/loader/loader.js +0 -728
  600. package/src/loader/loadingscreen.js +0 -112
  601. package/src/loader/melonjs_logo.png +0 -0
  602. package/src/loader/parsers/binary.js +0 -33
  603. package/src/loader/parsers/compressed_textures/compressed_image.js +0 -49
  604. package/src/loader/parsers/compressed_textures/parseDDS.js +0 -5
  605. package/src/loader/parsers/compressed_textures/parseKTX.js +0 -5
  606. package/src/loader/parsers/compressed_textures/parseKTX2.js +0 -5
  607. package/src/loader/parsers/compressed_textures/parsePKM.js +0 -5
  608. package/src/loader/parsers/compressed_textures/parsePVR.js +0 -127
  609. package/src/loader/parsers/fetchdata.js +0 -53
  610. package/src/loader/parsers/fontface.js +0 -54
  611. package/src/loader/parsers/image.js +0 -120
  612. package/src/loader/parsers/json.js +0 -35
  613. package/src/loader/parsers/script.js +0 -37
  614. package/src/loader/parsers/tmx.js +0 -95
  615. package/src/loader/parsers/video.js +0 -90
  616. package/src/math/color.js +0 -627
  617. package/src/math/math.js +0 -212
  618. package/src/math/matrix2.js +0 -487
  619. package/src/math/matrix3.js +0 -620
  620. package/src/math/observable_vector2.js +0 -460
  621. package/src/math/observable_vector3.js +0 -556
  622. package/src/math/vector2.js +0 -423
  623. package/src/math/vector3.js +0 -465
  624. package/src/particles/emitter.js +0 -258
  625. package/src/particles/particle.js +0 -182
  626. package/src/particles/settings.js +0 -310
  627. package/src/physics/body.js +0 -709
  628. package/src/physics/bounds.js +0 -407
  629. package/src/physics/collision.js +0 -128
  630. package/src/physics/detector.js +0 -218
  631. package/src/physics/quadtree.js +0 -393
  632. package/src/physics/response.js +0 -48
  633. package/src/physics/sat.js +0 -483
  634. package/src/physics/world.js +0 -220
  635. package/src/plugin/plugin.js +0 -163
  636. package/src/polyfill/console.js +0 -11
  637. package/src/polyfill/index.js +0 -13
  638. package/src/polyfill/roundrect.js +0 -237
  639. package/src/renderable/collectable.js +0 -51
  640. package/src/renderable/colorlayer.js +0 -74
  641. package/src/renderable/container.js +0 -1008
  642. package/src/renderable/draggable.js +0 -114
  643. package/src/renderable/dragndrop.js +0 -110
  644. package/src/renderable/entity/entity.js +0 -254
  645. package/src/renderable/imagelayer.js +0 -284
  646. package/src/renderable/light2d.js +0 -163
  647. package/src/renderable/nineslicesprite.js +0 -239
  648. package/src/renderable/renderable.js +0 -869
  649. package/src/renderable/sprite.js +0 -691
  650. package/src/renderable/text/bitmaptext.js +0 -418
  651. package/src/renderable/text/bitmaptextdata.js +0 -186
  652. package/src/renderable/text/glyph.js +0 -57
  653. package/src/renderable/text/text.js +0 -415
  654. package/src/renderable/text/textmetrics.js +0 -167
  655. package/src/renderable/text/textstyle.js +0 -12
  656. package/src/renderable/trigger.js +0 -154
  657. package/src/renderable/ui/uibaseelement.js +0 -276
  658. package/src/renderable/ui/uispriteelement.js +0 -223
  659. package/src/renderable/ui/uitextbutton.js +0 -140
  660. package/src/state/stage.js +0 -226
  661. package/src/state/state.js +0 -541
  662. package/src/system/device.js +0 -863
  663. package/src/system/dom.js +0 -70
  664. package/src/system/event.js +0 -597
  665. package/src/system/platform.js +0 -34
  666. package/src/system/pooling.js +0 -190
  667. package/src/system/save.js +0 -148
  668. package/src/system/timer.js +0 -281
  669. package/src/tweens/easing.js +0 -325
  670. package/src/tweens/interpolation.js +0 -103
  671. package/src/tweens/tween.js +0 -470
  672. package/src/utils/agent.js +0 -68
  673. package/src/utils/array.js +0 -54
  674. package/src/utils/file.js +0 -46
  675. package/src/utils/function.js +0 -60
  676. package/src/utils/string.js +0 -73
  677. package/src/utils/utils.js +0 -127
  678. package/src/video/canvas/canvas_renderer.js +0 -905
  679. package/src/video/renderer.js +0 -393
  680. package/src/video/rendertarget/canvasrendertarget.js +0 -309
  681. package/src/video/texture/atlas.js +0 -456
  682. package/src/video/texture/cache.js +0 -178
  683. package/src/video/texture/parser/aseprite.js +0 -69
  684. package/src/video/texture/parser/spritesheet.js +0 -68
  685. package/src/video/texture/parser/texturepacker.js +0 -55
  686. package/src/video/utils/autodetect.js +0 -18
  687. package/src/video/video.js +0 -160
  688. package/src/video/webgl/buffer/vertex.js +0 -137
  689. package/src/video/webgl/compositors/compositor.js +0 -231
  690. package/src/video/webgl/compositors/primitive_compositor.js +0 -73
  691. package/src/video/webgl/compositors/quad_compositor.js +0 -250
  692. package/src/video/webgl/glshader.js +0 -158
  693. package/src/video/webgl/shaders/primitive.frag +0 -5
  694. package/src/video/webgl/shaders/primitive.vert +0 -15
  695. package/src/video/webgl/shaders/quad.frag +0 -7
  696. package/src/video/webgl/shaders/quad.vert +0 -18
  697. package/src/video/webgl/utils/attributes.js +0 -16
  698. package/src/video/webgl/utils/precision.js +0 -29
  699. package/src/video/webgl/utils/program.js +0 -58
  700. package/src/video/webgl/utils/string.js +0 -16
  701. package/src/video/webgl/utils/uniforms.js +0 -84
  702. package/src/video/webgl/webgl_renderer.js +0 -1237
@@ -1,1237 +0,0 @@
1
- import Color from "./../../math/color.js";
2
- import Matrix2d from "./../../math/matrix2.js";
3
- import QuadCompositor from "./compositors/quad_compositor";
4
- import PrimitiveCompositor from "./compositors/primitive_compositor";
5
- import Renderer from "./../renderer.js";
6
- import TextureCache from "./../texture/cache.js";
7
- import { TextureAtlas, createAtlas } from "./../texture/atlas.js";
8
- import { renderer } from "./../video.js";
9
- import * as event from "./../../system/event.js";
10
- import pool from "./../../system/pooling.js";
11
- import { isPowerOfTwo } from "./../../math/math.js";
12
-
13
- /**
14
- * additional import for TypeScript
15
- * @import Rect from "./../../geometries/rectangle.js";
16
- * @import RoundRect from "./../../geometries/roundrect.js";
17
- * @import Polygon from "./../../geometries/poly.js";
18
- * @import Line from "./../../geometries/line.js";
19
- * @import Ellipse from "./../../geometries/ellipse.js";
20
- * @import Matrix3d from "./../../math/matrix3.js";
21
- * @import Compositor from "./compositors/compositor.js";
22
- */
23
-
24
- // list of supported compressed texture formats
25
- let supportedCompressedTextureFormats;
26
-
27
- /**
28
- * @classdesc
29
- * a WebGL renderer object
30
- * @augments Renderer
31
- */
32
- export default class WebGLRenderer extends Renderer {
33
- /**
34
- * @param {ApplicationSettings} [options] - optional parameters for the renderer
35
- */
36
- constructor(options) {
37
- // parent contructor
38
- super(Object.assign(options, { context: "webgl" }));
39
-
40
- /**
41
- * The vendor string of the underlying graphics driver.
42
- * @type {string}
43
- * @default undefined
44
- * @readonly
45
- */
46
- this.GPUVendor = undefined;
47
-
48
- /**
49
- * The renderer string of the underlying graphics driver.
50
- * @type {string}
51
- * @default undefined
52
- * @readonly
53
- */
54
- this.GPURenderer = undefined;
55
-
56
- /**
57
- * The WebGL context
58
- * @name gl
59
- * @type {WebGLRenderingContext}
60
- */
61
- this.gl = this.renderTarget.context;
62
-
63
- /**
64
- * sets or returns the thickness of lines for shape drawing (limited to strokeLine, strokePolygon and strokeRect)
65
- * @type {number}
66
- * @default 1
67
- * @see WebGLRenderer#strokeLine
68
- * @see WebGLRenderer#strokePolygon
69
- * @see WebGLRenderer#strokeRect
70
- */
71
- this.lineWidth = 1;
72
-
73
- /**
74
- * sets or returns the shape used to join two line segments where they meet.
75
- * Out of the three possible values for this property: "round", "bevel", and "miter", only "round" is supported for now in WebGL
76
- * @type {string}
77
- * @default "round"
78
- */
79
- this.lineJoin = "round";
80
-
81
- /**
82
- * the vertex buffer used by this WebGL Renderer
83
- * @type {WebGLBuffer}
84
- */
85
- this.vertexBuffer = this.gl.createBuffer();
86
-
87
- /**
88
- * Maximum number of texture unit supported under the current context
89
- * @type {number}
90
- * @readonly
91
- */
92
- this.maxTextures = this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS);
93
-
94
- /**
95
- * @ignore
96
- */
97
- this._colorStack = [];
98
-
99
- /**
100
- * @ignore
101
- */
102
- this._matrixStack = [];
103
-
104
- /**
105
- * @ignore
106
- */
107
- this._scissorStack = [];
108
-
109
- /**
110
- * @ignore
111
- */
112
- this._blendStack = [];
113
-
114
- /**
115
- * The current transformation matrix used for transformations on the overall scene
116
- * @type {Matrix2d}
117
- */
118
- this.currentTransform = new Matrix2d();
119
-
120
- /**
121
- * The current compositor used by the renderer
122
- * @type {Compositor}
123
- */
124
- this.currentCompositor = undefined;
125
-
126
- /**
127
- * a reference to the current shader program used by the renderer
128
- * @type {WebGLProgram}
129
- */
130
- this.currentProgram = undefined;
131
-
132
- /**
133
- * The list of active compositors
134
- * @type {Map<Compositor>}
135
- */
136
- this.compositors = new Map();
137
-
138
- // bind the vertex buffer
139
- this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.vertexBuffer);
140
-
141
- // Create both quad and primitive compositor
142
- this.addCompositor(new (this.settings.compositor || QuadCompositor)(this), "quad", true);
143
- this.addCompositor(new (this.settings.compositor || PrimitiveCompositor)(this), "primitive");
144
-
145
- // depth Test settings
146
- this.depthTest = options.depthTest;
147
-
148
- // default WebGL state(s)
149
- if (this.depthTest === "z-buffer") {
150
- this.gl.enable(this.gl.DEPTH_TEST);
151
- // https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/depthFunc
152
- this.gl.depthFunc(this.gl.LEQUAL);
153
- this.gl.depthMask(true);
154
- } else {
155
- this.gl.disable(this.gl.DEPTH_TEST);
156
- this.gl.depthMask(false);
157
- }
158
-
159
- this.gl.disable(this.gl.SCISSOR_TEST);
160
- this.gl.enable(this.gl.BLEND);
161
-
162
- // set default mode
163
- this.setBlendMode(this.settings.blendMode);
164
-
165
- // get GPU vendor and renderer
166
- let debugInfo = this.gl.getExtension("WEBGL_debug_renderer_info");
167
- if (debugInfo !== null) {
168
- this.GPUVendor = this.gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL);
169
- this.GPURenderer = this.gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
170
- }
171
-
172
- // a private property that when set will make `setCompositor`
173
- // to use this specific shader instead of the default one
174
- this.customShader = undefined;
175
-
176
- // Create a texture cache
177
- this.cache = new TextureCache(this.maxTextures);
178
-
179
- // set the renderer type
180
- this.type = "WebGL" + this.WebGLVersion;
181
-
182
- // to simulate context lost and restore in WebGL:
183
- // let ctx = me.video.renderer.context.getExtension('WEBGL_lose_context');
184
- // ctx.loseContext()
185
- this.getCanvas().addEventListener("webglcontextlost", (e) => {
186
- e.preventDefault();
187
- this.isContextValid = false;
188
- event.emit(event.ONCONTEXT_LOST, this);
189
- }, false);
190
- // ctx.restoreContext()
191
- this.getCanvas().addEventListener("webglcontextrestored", () => {
192
- this.reset();
193
- this.isContextValid = true;
194
- event.emit(event.ONCONTEXT_RESTORED, this);
195
- }, false);
196
-
197
- // reset the renderer on game reset
198
- event.on(event.GAME_RESET, () => {
199
- this.reset();
200
- });
201
-
202
- // register to the CANVAS resize channel
203
- event.on(event.CANVAS_ONRESIZE, (width, height) => {
204
- this.flush();
205
- this.setViewport(0, 0, width, height);
206
- });
207
- }
208
-
209
- /**
210
- * The WebGL version used by this renderer (1 or 2)
211
- * @type {number}
212
- * @default 1
213
- */
214
- get WebGLVersion() {
215
- return this.renderTarget.WebGLVersion;
216
- }
217
-
218
- /**
219
- * return the list of supported compressed texture formats
220
- * @return {Object}
221
- */
222
- getSupportedCompressedTextureFormats() {
223
- if (typeof supportedCompressedTextureFormats === "undefined") {
224
- const gl = this.gl;
225
- supportedCompressedTextureFormats = {
226
- astc: gl.getExtension("WEBGL_compressed_texture_astc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),
227
- bptc: gl.getExtension("EXT_texture_compression_bptc") || this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"),
228
- s3tc: gl.getExtension("WEBGL_compressed_texture_s3tc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),
229
- s3tc_srgb: gl.getExtension("WEBGL_compressed_texture_s3tc_srgb") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc_srgb"),
230
- pvrtc: gl.getExtension("WEBGL_compressed_texture_pvrtc") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),
231
- etc1: gl.getExtension("WEBGL_compressed_texture_etc1") || this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),
232
- etc2: gl.getExtension("WEBGL_compressed_texture_etc") || gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc") || gl.getExtension("WEBGL_compressed_texture_es3_0")
233
- };
234
- }
235
- return supportedCompressedTextureFormats;
236
- }
237
-
238
- /**
239
- * return true if the given compressed texture format is supported
240
- * @param {Number} format
241
- * @returns
242
- */
243
- hasSupportedCompressedFormats(format) {
244
- const supportedFormats = this.getSupportedCompressedTextureFormats();
245
- for (var supportedFormat in supportedFormats) {
246
- for (var extension in supportedFormats[supportedFormat]) {
247
- if (format === supportedFormats[supportedFormat][extension]) {
248
- return true;
249
- }
250
- }
251
- }
252
- return false;
253
- }
254
-
255
- /**
256
- * Reset context state
257
- */
258
- reset() {
259
- super.reset();
260
-
261
- // clear all stacks
262
- this._colorStack.forEach((color) => {
263
- pool.push(color);
264
- });
265
- this._matrixStack.forEach((matrix) => {
266
- pool.push(matrix);
267
- });
268
- this._colorStack.length = 0;
269
- this._matrixStack.length = 0;
270
- this._blendStack.length = 0;
271
-
272
- // clear gl context
273
- this.clear();
274
-
275
- // initial viewport size
276
- this.setViewport();
277
-
278
- // rebind the vertex buffer if required (e.g in case of context loss)
279
- if (this.gl.getParameter(this.gl.ARRAY_BUFFER_BINDING) !== this.vertexBuffer) {
280
- this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.vertexBuffer);
281
- }
282
-
283
- this.currentCompositor = undefined;
284
- this.currentProgram = undefined;
285
- this.customShader = undefined;
286
-
287
- this.compositors.forEach((compositor) => {
288
- if (this.isContextValid === false) {
289
- // on context lost/restore
290
- compositor.init(this);
291
- } else {
292
- compositor.reset();
293
- }
294
- });
295
-
296
- this.setCompositor("quad");
297
-
298
- this.gl.disable(this.gl.SCISSOR_TEST);
299
- }
300
-
301
- /**
302
- * add a new compositor to this renderer
303
- * @param {Compositor} compositor - a compositor instance
304
- * @param {string} name - a name uniquely identifying this compositor
305
- * @param {boolean} [activate=false] - true if the given compositor should be set as the active one
306
- */
307
- addCompositor(compositor, name = "default", activate = false) {
308
- // make sure there is no existing compositor with the same name
309
- if (typeof this.compositors.get(name) !== "undefined") {
310
- throw new Error("Invalid Compositor name");
311
- }
312
-
313
- // add the new compositor
314
- this.compositors.set(name, compositor);
315
-
316
- if (activate === true) {
317
- // set as active one
318
- this.setCompositor(name);
319
- }
320
- }
321
-
322
- /**
323
- * set the active compositor for this renderer
324
- * @param {string} name - a compositor name
325
- * @param {GLShader} [shader] - an optional shader program to be used, instead of the default one, when activating the compositor
326
- * @returns {Compositor} an instance to the current active compositor
327
- */
328
- setCompositor(name = "default", shader = this.customShader) {
329
- let compositor = this.compositors.get(name);
330
-
331
- if (typeof compositor === "undefined") {
332
- throw new Error("Invalid Compositor");
333
- }
334
-
335
- if (this.currentCompositor !== compositor) {
336
- if (this.currentCompositor !== undefined) {
337
- // flush the current compositor
338
- this.currentCompositor.flush();
339
- }
340
- // set as the active one
341
- this.currentCompositor = compositor;
342
- }
343
-
344
- if (name === "quad" && typeof shader === "object") {
345
- this.currentCompositor.useShader(shader);
346
- } else {
347
- // (re)bind the compositor with the default shader (program & attributes)
348
- this.currentCompositor.bind();
349
- }
350
-
351
- return this.currentCompositor;
352
- }
353
-
354
- /**
355
- * Reset the gl transform to identity
356
- */
357
- resetTransform() {
358
- this.currentTransform.identity();
359
- }
360
-
361
- /**
362
- * Create a pattern with the specified repetition
363
- * @param {HTMLImageElement|SVGImageElement|HTMLVideoElement|HTMLCanvasElement|ImageBitmap|OffscreenCanvas|VideoFrame} image - Source image to be used as the pattern's image
364
- * @param {string} repeat - Define how the pattern should be repeated
365
- * @returns {TextureAtlas} the patterned texture created
366
- * @see ImageLayer#repeat
367
- * @example
368
- * let tileable = renderer.createPattern(image, "repeat");
369
- * let horizontal = renderer.createPattern(image, "repeat-x");
370
- * let vertical = renderer.createPattern(image, "repeat-y");
371
- * let basic = renderer.createPattern(image, "no-repeat");
372
- */
373
- createPattern(image, repeat) {
374
-
375
- this.setCompositor("quad");
376
-
377
- if (renderer.WebGLVersion === 1 && (!isPowerOfTwo(image.width) || !isPowerOfTwo(image.height))) {
378
- let src = typeof image.src !== "undefined" ? image.src : image;
379
- throw new Error(
380
- "[WebGL Renderer] " + src + " is not a POT texture " +
381
- "(" + image.width + "x" + image.height + ")"
382
- );
383
- }
384
-
385
- let texture = new TextureAtlas(createAtlas(image.width, image.height, "pattern", repeat), image);
386
-
387
- // FIXME: Remove old cache entry and texture when changing the repeat mode
388
- this.currentCompositor.uploadTexture(texture);
389
-
390
- return texture;
391
- }
392
-
393
- /**
394
- * Flush the compositor to the frame buffer
395
- */
396
- flush() {
397
- this.currentCompositor.flush();
398
- }
399
-
400
- /**
401
- * set/change the current projection matrix (WebGL only)
402
- * @param {Matrix3d} matrix - the new projection matrix
403
- */
404
- setProjection(matrix) {
405
- super.setProjection(matrix);
406
- this.currentCompositor.setProjection(matrix);
407
- }
408
-
409
- /**
410
- * Sets the WebGL viewport, which specifies the affine transformation of x and y from normalized device coordinates to window coordinates
411
- * @param {number} [x = 0] - x the horizontal coordinate for the lower left corner of the viewport origin
412
- * @param {number} [y = 0] - y the vertical coordinate for the lower left corner of the viewport origin
413
- * @param {number} [w = width of the canvas] - the width of viewport
414
- * @param {number} [h = height of the canvas] - the height of viewport
415
- */
416
- setViewport(x = 0, y = 0, w = this.getCanvas().width, h = this.getCanvas().height) {
417
- this.gl.viewport(x, y, w, h);
418
- }
419
-
420
- /**
421
- * Clear the frame buffer
422
- */
423
- clear() {
424
- let gl = this.gl;
425
- gl.clearColor(0, 0, 0, this.settings.transparent ? 0.0 : 1.0);
426
- this.lineWidth = 1;
427
- if (this.depthTest === "z-buffer") {
428
- gl.clear(gl.DEPTH_BUFFER_BIT | gl.COLOR_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
429
- } else {
430
- gl.clear(gl.COLOR_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
431
- }
432
- }
433
-
434
- /**
435
- * Clears the gl context with the given color.
436
- * @param {Color|string} [color="#000000"] - CSS color.
437
- * @param {boolean} [opaque=false] - Allow transparency [default] or clear the surface completely [true]
438
- */
439
- clearColor(color = "#000000", opaque = false) {
440
- let glArray;
441
- let gl = this.gl;
442
-
443
- if (color instanceof Color) {
444
- glArray = color.toArray();
445
- } else {
446
- let _color = pool.pull("me.Color");
447
- // reuse temporary the renderer default color object
448
- glArray = _color.parseCSS(color).toArray();
449
- pool.push(_color);
450
- }
451
-
452
- // clear gl context with the specified color
453
- gl.clearColor(glArray[0], glArray[1], glArray[2], (opaque === true) ? 1.0 : glArray[3]);
454
- gl.clear(gl.COLOR_BUFFER_BIT);
455
- }
456
-
457
- /**
458
- * Erase the pixels in the given rectangular area by setting them to transparent black (rgba(0,0,0,0)).
459
- * @param {number} x - x axis of the coordinate for the rectangle starting point.
460
- * @param {number} y - y axis of the coordinate for the rectangle starting point.
461
- * @param {number} width - The rectangle's width.
462
- * @param {number} height - The rectangle's height.
463
- */
464
- clearRect(x, y, width, height) {
465
- this.save();
466
- this.clipRect(x, y, width, height);
467
- this.clearColor();
468
- this.restore();
469
- }
470
-
471
- /**
472
- * Draw an image to the gl context
473
- * @param {HTMLImageElement|SVGImageElement|HTMLVideoElement|HTMLCanvasElement|ImageBitmap|OffscreenCanvas|VideoFrame} image - An element to draw into the context.
474
- * @param {number} sx - The X coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.
475
- * @param {number} sy - The Y coordinate of the top left corner of the sub-rectangle of the source image to draw into the destination context.
476
- * @param {number} sw - The width of the sub-rectangle of the source image to draw into the destination context. If not specified, the entire rectangle from the coordinates specified by sx and sy to the bottom-right corner of the image is used.
477
- * @param {number} sh - The height of the sub-rectangle of the source image to draw into the destination context.
478
- * @param {number} dx - The X coordinate in the destination canvas at which to place the top-left corner of the source image.
479
- * @param {number} dy - The Y coordinate in the destination canvas at which to place the top-left corner of the source image.
480
- * @param {number} dw - The width to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in width when drawn.
481
- * @param {number} dh - The height to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in height when drawn.
482
- * @example
483
- * // Position the image on the canvas:
484
- * renderer.drawImage(image, dx, dy);
485
- * // Position the image on the canvas, and specify width and height of the image:
486
- * renderer.drawImage(image, dx, dy, dWidth, dHeight);
487
- * // Clip the image and position the clipped part on the canvas:
488
- * renderer.drawImage(image, sx, sy, sWidth, sHeight, dx, dy, dWidth, dHeight);
489
- */
490
- drawImage(image, sx, sy, sw, sh, dx, dy, dw, dh) {
491
- if (typeof sw === "undefined") {
492
- sw = dw = image.width;
493
- sh = dh = image.height;
494
- dx = sx;
495
- dy = sy;
496
- sx = 0;
497
- sy = 0;
498
- }
499
- else if (typeof dx === "undefined") {
500
- dx = sx;
501
- dy = sy;
502
- dw = sw;
503
- dh = sh;
504
- sw = image.width;
505
- sh = image.height;
506
- sx = 0;
507
- sy = 0;
508
- }
509
-
510
- if (this.settings.subPixel === false) {
511
- // clamp to pixel grid
512
- dx |= 0;
513
- dy |= 0;
514
- }
515
-
516
- this.setCompositor("quad");
517
- // force reuploading if the given image is a HTMLVideoElement
518
- let reupload = typeof image.videoWidth !== "undefined";
519
- let texture = this.cache.get(image);
520
- let uvs = texture.getUVs(sx + "," + sy + "," + sw + "," + sh);
521
- this.currentCompositor.addQuad(texture, dx, dy, dw, dh, uvs[0], uvs[1], uvs[2], uvs[3], this.currentTint.toUint32(this.getGlobalAlpha()), reupload);
522
- }
523
-
524
- /**
525
- * Draw a pattern within the given rectangle.
526
- * @param {TextureAtlas} pattern - Pattern object
527
- * @param {number} x - x position where to draw the pattern
528
- * @param {number} y - y position where to draw the pattern
529
- * @param {number} width - width of the pattern
530
- * @param {number} height - height of the pattern
531
- * @see WebGLRenderer#createPattern
532
- */
533
- drawPattern(pattern, x, y, width, height) {
534
- let uvs = pattern.getUVs("0,0," + width + "," + height);
535
- this.setCompositor("quad");
536
- this.currentCompositor.addQuad(pattern, x, y, width, height, uvs[0], uvs[1], uvs[2], uvs[3], this.currentTint.toUint32(this.getGlobalAlpha()));
537
- }
538
-
539
-
540
- /**
541
- * starts a new path by emptying the list of sub-paths. Call this method when you want to create a new path
542
- * @example
543
- * // First path
544
- * renderer.beginPath();
545
- * renderer.setColor("blue");
546
- * renderer.moveTo(20, 20);
547
- * renderer.lineTo(200, 20);
548
- * renderer.stroke();
549
- * // Second path
550
- * renderer.beginPath();
551
- * renderer.setColor("green");
552
- * renderer.moveTo(20, 20);
553
- * renderer.lineTo(120, 120);
554
- * renderer.stroke();
555
- */
556
- beginPath() {
557
- this.path2D.beginPath();
558
- }
559
-
560
- /**
561
- * begins a new sub-path at the point specified by the given (x, y) coordinates.
562
- * @param {number} x - The x axis of the point.
563
- * @param {number} y - The y axis of the point.
564
- */
565
- moveTo(x, y) {
566
- this.path2D.moveTo(x, y);
567
- }
568
-
569
- /**
570
- * adds a straight line to the current sub-path by connecting the sub-path's last point to the specified (x, y) coordinates.
571
- */
572
- lineTo(x, y) {
573
- this.path2D.lineTo(x, y);
574
- }
575
-
576
- /**
577
- * creates a rectangular path whose starting point is at (x, y) and whose size is specified by width and height.
578
- * @param {number} x - The x axis of the coordinate for the rectangle starting point.
579
- * @param {number} y - The y axis of the coordinate for the rectangle starting point.
580
- * @param {number} width - The rectangle's width.
581
- * @param {number} height - The rectangle's height.
582
- */
583
- rect(x, y, width, height) {
584
- this.path2D.rect(x, y, width, height);
585
- }
586
-
587
- /**
588
- * adds a rounded rectangle to the current path.
589
- * @param {number} x - The x axis of the coordinate for the rectangle starting point.
590
- * @param {number} y - The y axis of the coordinate for the rectangle starting point.
591
- * @param {number} width - The rectangle's width.
592
- * @param {number} height - The rectangle's height.
593
- * @param {number} radius - The corner radius.
594
- */
595
- roundRect(x, y, width, height, radii) {
596
- this.path2D.roundRect(x, y, width, height, radii);
597
- }
598
-
599
- /**
600
- * stroke the given shape or the current defined path
601
- * @param {Rect|RoundRect|Polygon|Line|Ellipse} [shape] - a shape object to stroke
602
- * @param {boolean} [fill=false] - fill the shape with the current color if true
603
- */
604
- stroke(shape, fill) {
605
- this.setCompositor("primitive");
606
- if (typeof shape === "undefined") {
607
- if (fill === true) {
608
- // draw all triangles
609
- this.currentCompositor.drawVertices(this.gl.TRIANGLES, this.path2D.triangulatePath());
610
- } else {
611
- this.currentCompositor.drawVertices(this.gl.LINES, this.path2D.points);
612
- }
613
- } else {
614
- super.stroke(shape, fill);
615
- }
616
- }
617
-
618
- /**
619
- * fill the given shape or the current defined path
620
- * @param {Rect|RoundRect|Polygon|Line|Ellipse} [shape] - a shape object to fill
621
- */
622
- fill(shape) {
623
- this.stroke(shape, true);
624
- }
625
-
626
- /**
627
- * add a straight line from the current point to the start of the current sub-path. If the shape has already been closed or has only one point, this function does nothing
628
- */
629
- closePath() {
630
- this.path2D.closePath();
631
- }
632
-
633
- /**
634
- * Returns the WebGLContext instance for the renderer
635
- * return a reference to the system 2d Context
636
- * @returns {WebGLRenderingContext} the current WebGL context
637
- */
638
- getContext() {
639
- return this.gl;
640
- }
641
-
642
- /**
643
- * set a blend mode for the given context. <br>
644
- * Supported blend mode between Canvas and WebGL remderer : <br>
645
- * - "normal" : this is the default mode and draws new content on top of the existing content <br>
646
- * <img src="images/normal-blendmode.png" width="510"/> <br>
647
- * - "multiply" : the pixels of the top layer are multiplied with the corresponding pixel of the bottom layer. A darker picture is the result. <br>
648
- * <img src="images/multiply-blendmode.png" width="510"/> <br>
649
- * - "additive or lighter" : where both content overlap the color is determined by adding color values. <br>
650
- * <img src="images/lighter-blendmode.png" width="510"/> <br>
651
- * - "screen" : The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply) <br>
652
- * <img src="images/screen-blendmode.png" width="510"/> <br>
653
- * @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
654
- * @param {string} [mode="normal"] - blend mode : "normal", "multiply", "lighter", "additive", "screen"
655
- * @param {WebGLRenderingContext} [gl] - a WebGL context
656
- */
657
- setBlendMode(mode = "normal", gl = this.gl) {
658
-
659
- if (this.currentBlendMode !== mode) {
660
- this.flush();
661
- gl.enable(gl.BLEND);
662
- this.currentBlendMode = mode;
663
-
664
- switch (mode) {
665
- case "screen" :
666
- gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_COLOR);
667
- break;
668
-
669
- case "lighter" :
670
- case "additive" :
671
- gl.blendFunc(gl.ONE, gl.ONE);
672
- break;
673
-
674
- case "multiply" :
675
- gl.blendFunc(gl.DST_COLOR, gl.ONE_MINUS_SRC_ALPHA);
676
- break;
677
-
678
- default :
679
- gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
680
- this.currentBlendMode = "normal";
681
- break;
682
- }
683
- }
684
- }
685
-
686
- /**
687
- * restores the most recently saved renderer state by popping the top entry in the drawing state stack
688
- * @example
689
- * // Save the current state
690
- * renderer.save();
691
- *
692
- * // apply a transform and draw a rect
693
- * renderer.tranform(matrix);
694
- * renderer.fillRect(10, 10, 100, 100);
695
- *
696
- * // Restore to the state saved by the most recent call to save()
697
- * renderer.restore();
698
- */
699
- restore() {
700
- // do nothing if there is no saved states
701
- if (this._matrixStack.length !== 0) {
702
- let color = this._colorStack.pop();
703
- let matrix = this._matrixStack.pop();
704
-
705
- // restore the previous context
706
- this.currentColor.copy(color);
707
- this.currentTransform.copy(matrix);
708
-
709
- this.setBlendMode(this._blendStack.pop());
710
-
711
- // recycle objects
712
- pool.push(color);
713
- pool.push(matrix);
714
- }
715
-
716
- if (this._scissorStack.length !== 0) {
717
- // FIXME : prevent `scissor` object realloc and GC
718
- this.currentScissor.set(this._scissorStack.pop());
719
- } else {
720
- const canvas = this.getCanvas();
721
- // turn off scissor test
722
- this.gl.disable(this.gl.SCISSOR_TEST);
723
- this.currentScissor[0] = 0;
724
- this.currentScissor[1] = 0;
725
- this.currentScissor[2] = canvas.width;
726
- this.currentScissor[3] = canvas.height;
727
- }
728
- }
729
-
730
- /**
731
- * saves the entire state of the renderer by pushing the current state onto a stack.
732
- * @example
733
- * // Save the current state
734
- * renderer.save();
735
- *
736
- * // apply a transform and draw a rect
737
- * renderer.tranform(matrix);
738
- * renderer.fillRect(10, 10, 100, 100);
739
- *
740
- * // Restore to the state saved by the most recent call to save()
741
- * renderer.restore();
742
- */
743
- save() {
744
- this._colorStack.push(this.currentColor.clone());
745
- this._matrixStack.push(this.currentTransform.clone());
746
-
747
- if (this.gl.isEnabled(this.gl.SCISSOR_TEST)) {
748
- // FIXME avoid slice and object realloc
749
- this._scissorStack.push(this.currentScissor.slice());
750
- }
751
-
752
- this._blendStack.push(this.getBlendMode());
753
- }
754
-
755
- /**
756
- * adds a rotation to the transformation matrix.
757
- * @param {number} angle - the rotation angle, clockwise in radians
758
- * @example
759
- * // Rotated rectangle
760
- * renderer.rotate((45 * Math.PI) / 180);
761
- * renderer.setColor("red");
762
- * renderer.fillRect(10, 10, 100, 100);
763
- *
764
- * // Reset transformation matrix to the identity matrix
765
- * renderer.setTransform(1, 0, 0, 1, 0, 0);
766
- */
767
- rotate(angle) {
768
- this.currentTransform.rotate(angle);
769
- }
770
-
771
- /**
772
- * adds a scaling transformation to the renderer units horizontally and/or vertically
773
- * @param {number} x - Scaling factor in the horizontal direction. A negative value flips pixels across the vertical axis. A value of 1 results in no horizontal scaling.
774
- * @param {number} y - Scaling factor in the vertical direction. A negative value flips pixels across the horizontal axis. A value of 1 results in no vertical scaling
775
- */
776
- scale(x, y) {
777
- this.currentTransform.scale(x, y);
778
- }
779
-
780
- /**
781
- * not used by this renderer?
782
- * @param {boolean} [enable=false]
783
- * @ignore
784
- */
785
- setAntiAlias(enable = false) {
786
- super.setAntiAlias(enable);
787
- // TODO: perhaps handle GLNEAREST or other options with texture binding
788
- }
789
-
790
- /**
791
- * Set the global alpha
792
- * @param {number} alpha - 0.0 to 1.0 values accepted.
793
- */
794
- setGlobalAlpha(alpha) {
795
- this.currentColor.alpha = alpha;
796
- }
797
-
798
- /**
799
- * Return the global alpha
800
- * @returns {number} global alpha value
801
- */
802
- getGlobalAlpha() {
803
- return this.currentColor.alpha;
804
- }
805
-
806
- /**
807
- * Set the current fill & stroke style color.
808
- * By default, or upon reset, the value is set to #000000.
809
- * @param {Color|string} color - css color string.
810
- */
811
- setColor(color) {
812
- let alpha = this.currentColor.alpha;
813
- this.currentColor.copy(color);
814
- this.currentColor.alpha *= alpha;
815
- }
816
-
817
- /**
818
- * Stroke an arc at the specified coordinates with given radius, start and end points
819
- * @param {number} x - arc center point x-axis
820
- * @param {number} y - arc center point y-axis
821
- * @param {number} radius - arc radius
822
- * @param {number} start - start angle in radians
823
- * @param {number} end - end angle in radians
824
- * @param {boolean} [antiClockwise=false] - draw arc anti-clockwise
825
- * @param {boolean} [fill=false] - also fill the shape with the current color if true
826
- */
827
- strokeArc(x, y, radius, start, end, antiClockwise = false, fill = false) {
828
- this.setCompositor("primitive");
829
- this.path2D.beginPath();
830
- this.path2D.arc(x, y, radius, start, end, antiClockwise);
831
- if (fill === false) {
832
- this.currentCompositor.drawVertices(this.gl.LINES, this.path2D.points);
833
- } else {
834
- this.currentCompositor.drawVertices(this.gl.TRIANGLES, this.path2D.triangulatePath());
835
- }
836
- }
837
-
838
- /**
839
- * Fill an arc at the specified coordinates with given radius, start and end points
840
- * @param {number} x - arc center point x-axis
841
- * @param {number} y - arc center point y-axis
842
- * @param {number} radius - arc radius
843
- * @param {number} start - start angle in radians
844
- * @param {number} end - end angle in radians
845
- * @param {boolean} [antiClockwise=false] - draw arc anti-clockwise
846
- */
847
- fillArc(x, y, radius, start, end, antiClockwise = false) {
848
- this.strokeArc(x, y, radius, start, end, antiClockwise, true);
849
- }
850
-
851
- /**
852
- * Stroke an ellipse at the specified coordinates with given radius
853
- * @param {number} x - ellipse center point x-axis
854
- * @param {number} y - ellipse center point y-axis
855
- * @param {number} w - horizontal radius of the ellipse
856
- * @param {number} h - vertical radius of the ellipse
857
- * @param {boolean} [fill=false] - also fill the shape with the current color if true
858
- */
859
- strokeEllipse(x, y, w, h, fill = false) {
860
- this.setCompositor("primitive");
861
- this.path2D.beginPath();
862
- this.path2D.ellipse(x, y, w, h, 0, 0, 360);
863
- if (fill === false) {
864
- this.currentCompositor.drawVertices(this.gl.LINES, this.path2D.points);
865
- } else {
866
- this.currentCompositor.drawVertices(this.gl.TRIANGLES, this.path2D.triangulatePath());
867
- }
868
- }
869
-
870
- /**
871
- * Fill an ellipse at the specified coordinates with given radius
872
- * @param {number} x - ellipse center point x-axis
873
- * @param {number} y - ellipse center point y-axis
874
- * @param {number} w - horizontal radius of the ellipse
875
- * @param {number} h - vertical radius of the ellipse
876
- */
877
- fillEllipse(x, y, w, h) {
878
- this.strokeEllipse(x, y, w, h, true);
879
- }
880
-
881
- /**
882
- * Stroke a line of the given two points
883
- * @param {number} startX - the start x coordinate
884
- * @param {number} startY - the start y coordinate
885
- * @param {number} endX - the end x coordinate
886
- * @param {number} endY - the end y coordinate
887
- */
888
- strokeLine(startX, startY, endX, endY) {
889
- this.setCompositor("primitive");
890
- if (this.lineWidth === 1) {
891
- this.path2D.beginPath();
892
- this.path2D.moveTo(startX, startY);
893
- this.path2D.lineTo(endX, endY);
894
- this.currentCompositor.drawVertices(this.gl.LINES, this.path2D.points);
895
- } else if (this.lineWidth > 1) {
896
- const halfWidth = this.lineWidth / 2;
897
- const angle = Math.atan2(endY - startY, endX - startX);
898
- const dx = Math.sin(angle) * halfWidth;
899
- const dy = Math.cos(angle) * halfWidth;
900
- const x1 = startX - dx;
901
- const y1 = startY + dy;
902
- const x2 = startX + dx;
903
- const y2 = startY - dy;
904
- const x3 = endX + dx;
905
- const y3 = endY - dy;
906
- const x4 = endX - dx;
907
- const y4 = endY + dy;
908
-
909
- this.path2D.beginPath();
910
- this.path2D.moveTo(x1, y1);
911
- this.path2D.lineTo(x2, y2);
912
- this.path2D.lineTo(x3, y3);
913
- this.path2D.lineTo(x4, y4);
914
- this.path2D.closePath();
915
- // draw all triangles
916
- this.currentCompositor.drawVertices(this.gl.TRIANGLES, this.path2D.triangulatePath());
917
- }
918
- }
919
-
920
-
921
- /**
922
- * Fill a line of the given two points
923
- * @param {number} startX - the start x coordinate
924
- * @param {number} startY - the start y coordinate
925
- * @param {number} endX - the end x coordinate
926
- * @param {number} endY - the end y coordinate
927
- */
928
- fillLine(startX, startY, endX, endY) {
929
- this.strokeLine(startX, startY, endX, endY);
930
- }
931
-
932
- /**
933
- * Stroke a Polygon on the screen with a specified color
934
- * @param {Polygon} poly - the shape to draw
935
- * @param {boolean} [fill=false] - also fill the shape with the current color if true
936
- */
937
- strokePolygon(poly, fill = false) {
938
- const points = poly.points;
939
- const len = points.length;
940
-
941
- this.translate(poly.pos.x, poly.pos.y);
942
-
943
- if (fill === false && this.lineWidth > 1) {
944
- const radius = this.lineWidth / 2;
945
- for (let i = 0; i < len - 1; i++) {
946
- const curPoint = points[i];
947
- const nextPoint = points[i + 1];
948
- this.fillEllipse(nextPoint.x, nextPoint.y, radius, radius);
949
- this.strokeLine(curPoint.x, curPoint.y, nextPoint.x, nextPoint.y);
950
- }
951
- const lastPoint = points[len - 1];
952
- const firstPoint = points[0];
953
- if (!lastPoint.equals(firstPoint)) {
954
- this.fillEllipse(firstPoint.x, firstPoint.y, radius, radius);
955
- this.strokeLine(lastPoint.x, lastPoint.y, firstPoint.x, firstPoint.y);
956
- }
957
- } else {
958
- this.setCompositor("primitive");
959
- this.path2D.beginPath();
960
- for (let i = 0; i < len - 1; i++) {
961
- const curPoint = points[i];
962
- const nextPoint = points[i + 1];
963
- this.path2D.moveTo(curPoint.x, curPoint.y);
964
- this.path2D.lineTo(nextPoint.x, nextPoint.y);
965
- }
966
- this.path2D.closePath();
967
- if (fill === false) {
968
- this.currentCompositor.drawVertices(this.gl.LINES, this.path2D.points);
969
- } else {
970
- // draw all triangles
971
- this.currentCompositor.drawVertices(this.gl.TRIANGLES, this.path2D.triangulatePath());
972
- }
973
- }
974
-
975
- this.translate(-poly.pos.x, -poly.pos.y);
976
- }
977
-
978
- /**
979
- * Fill a me.Polygon on the screen
980
- * @param {Polygon} poly - the shape to draw
981
- */
982
- fillPolygon(poly) {
983
- this.strokePolygon(poly, true);
984
- }
985
-
986
- /**
987
- * Draw a stroke rectangle at the specified coordinates
988
- * @param {number} x - x axis of the coordinate for the rectangle starting point.
989
- * @param {number} y - y axis of the coordinate for the rectangle starting point.
990
- * @param {number} width - The rectangle's width.
991
- * @param {number} height - The rectangle's height.
992
- * @param {boolean} [fill=false] - also fill the shape with the current color if true
993
- */
994
- strokeRect(x, y, width, height, fill = false) {
995
- if (fill === false && this.lineWidth > 1) {
996
- const radius = this.lineWidth / 2;
997
- this.strokeLine(x, y, x + width, y);
998
- this.strokeLine(x + width, y, x + width, y + height);
999
- this.strokeLine(x + width, y + height, x, y + height);
1000
- this.strokeLine(x, y + height, x, y);
1001
- this.fillEllipse(x, y, radius, radius);
1002
- this.fillEllipse(x + width, y, radius, radius);
1003
- this.fillEllipse(x + width, y + height, radius, radius);
1004
- this.fillEllipse(x, y + height, radius, radius);
1005
- } else {
1006
- this.setCompositor("primitive");
1007
- this.path2D.beginPath();
1008
- this.path2D.rect(x, y, width, height);
1009
- if (fill === false) {
1010
- this.currentCompositor.drawVertices(this.gl.LINES, this.path2D.points);
1011
- } else {
1012
- this.currentCompositor.drawVertices(this.gl.TRIANGLES, this.path2D.triangulatePath());
1013
- }
1014
- }
1015
- }
1016
-
1017
- /**
1018
- * Draw a filled rectangle at the specified coordinates
1019
- * @param {number} x - x axis of the coordinate for the rectangle starting point.
1020
- * @param {number} y - y axis of the coordinate for the rectangle starting point.
1021
- * @param {number} width - The rectangle's width.
1022
- * @param {number} height - The rectangle's height.
1023
- */
1024
- fillRect(x, y, width, height) {
1025
- this.strokeRect(x, y, width, height, true);
1026
- }
1027
-
1028
- /**
1029
- * Stroke a rounded rectangle at the specified coordinates
1030
- * @param {number} x - x axis of the coordinate for the rounded rectangle starting point.
1031
- * @param {number} y - y axis of the coordinate for the rounded rectangle starting point.
1032
- * @param {number} width - The rounded rectangle's width.
1033
- * @param {number} height - The rounded rectangle's height.
1034
- * @param {number} radius - The rounded corner's radius.
1035
- * @param {boolean} [fill=false] - also fill the shape with the current color if true
1036
- */
1037
- strokeRoundRect(x, y, width, height, radius, fill = false) {
1038
- this.setCompositor("primitive");
1039
- this.path2D.beginPath();
1040
- this.path2D.roundRect(x, y, width, height, radius);
1041
- if (fill === false) {
1042
- this.currentCompositor.drawVertices(this.gl.LINES, this.path2D.points);
1043
- } else {
1044
- this.currentCompositor.drawVertices(this.gl.TRIANGLES, this.path2D.triangulatePath());
1045
- }
1046
- }
1047
-
1048
- /**
1049
- * Draw a rounded filled rectangle at the specified coordinates
1050
- * @param {number} x - x axis of the coordinate for the rounded rectangle starting point.
1051
- * @param {number} y - y axis of the coordinate for the rounded rectangle starting point.
1052
- * @param {number} width - The rounded rectangle's width.
1053
- * @param {number} height - The rounded rectangle's height.
1054
- * @param {number} radius - The rounded corner's radius.
1055
- */
1056
- fillRoundRect(x, y, width, height, radius) {
1057
- this.strokeRoundRect(x, y, width, height, radius, true);
1058
- }
1059
-
1060
- /**
1061
- * Stroke a Point at the specified coordinates
1062
- * @param {number} x - x axis of the coordinate for the point.
1063
- * @param {number} y - y axis of the coordinate for the point.
1064
- */
1065
- strokePoint(x, y) {
1066
- this.strokeLine(x, y, x + 1, y + 1);
1067
- }
1068
-
1069
- /**
1070
- * Draw a a point at the specified coordinates
1071
- * @param {number} x - x axis of the coordinate for the point.
1072
- * @param {number} y - y axis of the coordinate for the point.
1073
- */
1074
- fillPoint(x, y) {
1075
- this.strokePoint(x, y);
1076
- }
1077
-
1078
- /**
1079
- * Reset (overrides) the renderer transformation matrix to the
1080
- * identity one, and then apply the given transformation matrix.
1081
- * @param {Matrix2d|number} a - a matrix2d to transform by, or a the a component to multiply the current matrix by
1082
- * @param {number} b - the b component to multiply the current matrix by
1083
- * @param {number} c - the c component to multiply the current matrix by
1084
- * @param {number} d - the d component to multiply the current matrix by
1085
- * @param {number} e - the e component to multiply the current matrix by
1086
- * @param {number} f - the f component to multiply the current matrix by
1087
- */
1088
- setTransform(a, b, c, d, e, f) {
1089
- this.resetTransform();
1090
- this.transform(a, b, c, d, e, f);
1091
- }
1092
-
1093
- /**
1094
- * Multiply given matrix into the renderer tranformation matrix
1095
- * @see {@link WebGLRenderer.setTransform} which will reset the current transform matrix prior to performing the new transformation
1096
- * @param {Matrix2d|number} a - a matrix2d to transform by, or a the a component to multiply the current matrix by
1097
- * @param {number} b - the b component to multiply the current matrix by
1098
- * @param {number} c - the c component to multiply the current matrix by
1099
- * @param {number} d - the d component to multiply the current matrix by
1100
- * @param {number} e - the e component to multiply the current matrix by
1101
- * @param {number} f - the f component to multiply the current matrix by
1102
- */
1103
- transform(a, b, c, d, e, f) {
1104
- if (typeof a === "object") {
1105
- this.currentTransform.multiply(a);
1106
- } else {
1107
- // indivudual component
1108
- this.currentTransform.transform(a, b, c, d, e, f);
1109
- }
1110
- if (this.settings.subPixel === false) {
1111
- // snap position values to pixel grid
1112
- let a = this.currentTransform.toArray();
1113
- a[6] |= 0;
1114
- a[7] |= 0;
1115
- }
1116
- }
1117
-
1118
- /**
1119
- * adds a translation transformation to the current matrix.
1120
- * @param {number} x - Distance to move in the horizontal direction. Positive values are to the right, and negative to the left.
1121
- * @param {number} y - Distance to move in the vertical direction. Positive values are down, and negative are up.
1122
- */
1123
- translate(x, y) {
1124
- let currentTransform = this.currentTransform;
1125
- currentTransform.translate(x, y);
1126
- if (this.settings.subPixel === false) {
1127
- // snap position values to pixel grid
1128
- let a = currentTransform.toArray();
1129
- a[6] |= 0;
1130
- a[7] |= 0;
1131
- }
1132
- }
1133
-
1134
- /**
1135
- * clip the given region from the original canvas. Once a region is clipped,
1136
- * all future drawing will be limited to the clipped region.
1137
- * You can however save the current region using the save(),
1138
- * and restore it (with the restore() method) any time in the future.
1139
- * (<u>this is an experimental feature !</u>)
1140
- * @param {number} x - x axis of the coordinate for the upper-left corner of the rectangle to start clipping from.
1141
- * @param {number} y - y axis of the coordinate for the upper-left corner of the rectangle to start clipping from.
1142
- * @param {number} width - the width of the rectangle to start clipping from.
1143
- * @param {number} height - the height of the rectangle to start clipping from.
1144
- */
1145
- clipRect(x, y, width, height) {
1146
- let canvas = this.getCanvas();
1147
- let gl = this.gl;
1148
- // if requested box is different from the current canvas size
1149
- if (x !== 0 || y !== 0 || width !== canvas.width || height !== canvas.height) {
1150
- let currentScissor = this.currentScissor;
1151
- if (gl.isEnabled(gl.SCISSOR_TEST)) {
1152
- // if same as the current scissor box do nothing
1153
- if (currentScissor[0] === x && currentScissor[1] === y &&
1154
- currentScissor[2] === width && currentScissor[3] === height) {
1155
- return;
1156
- }
1157
- }
1158
- // flush the compositor
1159
- this.flush();
1160
- // turn on scissor test
1161
- gl.enable(this.gl.SCISSOR_TEST);
1162
- // set the scissor rectangle (note : coordinates are left/bottom)
1163
- gl.scissor(
1164
- // scissor does not account for currentTransform, so manually adjust
1165
- x + this.currentTransform.tx,
1166
- canvas.height - height - y - this.currentTransform.ty,
1167
- width,
1168
- height
1169
- );
1170
- // save the new currentScissor box
1171
- currentScissor[0] = x;
1172
- currentScissor[1] = y;
1173
- currentScissor[2] = width;
1174
- currentScissor[3] = height;
1175
- } else {
1176
- // turn off scissor test
1177
- gl.disable(gl.SCISSOR_TEST);
1178
- }
1179
- }
1180
-
1181
- /**
1182
- * A mask limits rendering elements to the shape and position of the given mask object.
1183
- * If the drawing or rendering area is larger than the mask, only the intersecting part of the renderable will be visible.
1184
- * (Note Mask are not preserved through renderer context save and restore and need so be manually cleared)
1185
- * @see CanvasRenderer#clearMask
1186
- * @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] - a shape defining the mask to be applied
1187
- * @param {boolean} [invert=false] - either the given shape should define what is visible (default) or the opposite
1188
- */
1189
- setMask(mask, invert = false) {
1190
- let gl = this.gl;
1191
-
1192
- // flush the compositor
1193
- this.flush();
1194
-
1195
- if (this.maskLevel === 0) {
1196
- // Enable and setup GL state to write to stencil buffer
1197
- gl.enable(gl.STENCIL_TEST);
1198
- gl.clear(gl.STENCIL_BUFFER_BIT);
1199
- }
1200
-
1201
- this.maskLevel++;
1202
-
1203
- gl.colorMask(false, false, false, false);
1204
- gl.stencilFunc(gl.EQUAL, this.maskLevel, 1);
1205
- gl.stencilOp(gl.REPLACE, gl.REPLACE, gl.REPLACE);
1206
-
1207
-
1208
- // fill the given mask shape
1209
- this.fill(mask);
1210
-
1211
- // flush the compositor
1212
- this.flush();
1213
-
1214
- gl.colorMask(true, true, true, true);
1215
-
1216
- // Use stencil buffer to affect next rendering object
1217
- if (invert === true) {
1218
- gl.stencilFunc(gl.EQUAL, this.maskLevel + 1, 1);
1219
- } else {
1220
- gl.stencilFunc(gl.NOTEQUAL, this.maskLevel + 1, 1);
1221
- }
1222
- gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);
1223
- }
1224
-
1225
- /**
1226
- * disable (remove) the rendering mask set through setMask.
1227
- * @see WebGLRenderer#setMask
1228
- */
1229
- clearMask() {
1230
- if (this.maskLevel > 0) {
1231
- // flush the compositor
1232
- this.flush();
1233
- this.maskLevel = 0;
1234
- this.gl.disable(this.gl.STENCIL_TEST);
1235
- }
1236
- }
1237
- }