melonjs 14.0.2 → 14.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +10 -0
- package/dist/melonjs.mjs/_virtual/arraymultimap.js +10 -0
- package/dist/melonjs.mjs/_virtual/earcut.js +10 -0
- package/dist/melonjs.mjs/_virtual/howler.js +10 -0
- package/dist/melonjs.mjs/_virtual/index.js +10 -0
- package/dist/melonjs.mjs/_virtual/index2.js +10 -0
- package/dist/melonjs.mjs/_virtual/multimap.js +10 -0
- package/dist/melonjs.mjs/_virtual/setmultimap.js +10 -0
- package/dist/melonjs.mjs/application/application.js +238 -0
- package/dist/melonjs.mjs/audio/audio.js +536 -0
- package/dist/melonjs.mjs/camera/camera2d.js +731 -0
- package/dist/melonjs.mjs/entity/entity.js +247 -0
- package/dist/melonjs.mjs/game.js +29 -0
- package/dist/melonjs.mjs/geometries/ellipse.js +274 -0
- package/dist/melonjs.mjs/geometries/line.js +115 -0
- package/dist/melonjs.mjs/geometries/path2d.js +318 -0
- package/dist/melonjs.mjs/geometries/point.js +88 -0
- package/dist/melonjs.mjs/geometries/poly.js +498 -0
- package/dist/melonjs.mjs/geometries/rectangle.js +374 -0
- package/dist/melonjs.mjs/geometries/roundrect.js +167 -0
- package/dist/melonjs.mjs/index.js +248 -0
- package/dist/melonjs.mjs/input/gamepad.js +501 -0
- package/dist/melonjs.mjs/input/input.js +26 -0
- package/dist/melonjs.mjs/input/keyboard.js +470 -0
- package/dist/melonjs.mjs/input/pointer.js +393 -0
- package/dist/melonjs.mjs/input/pointerevent.js +818 -0
- package/dist/melonjs.mjs/lang/deprecated.js +157 -0
- package/dist/melonjs.mjs/level/level.js +297 -0
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +141 -0
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +446 -0
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +355 -0
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +193 -0
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +636 -0
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +309 -0
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +81 -0
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +367 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +504 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +218 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +155 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +124 -0
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +107 -0
- package/dist/melonjs.mjs/loader/loader.js +801 -0
- package/dist/melonjs.mjs/loader/loadingscreen.js +120 -0
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +11 -0
- package/dist/melonjs.mjs/math/color.js +616 -0
- package/dist/melonjs.mjs/math/math.js +218 -0
- package/dist/melonjs.mjs/math/matrix2.js +501 -0
- package/dist/melonjs.mjs/math/matrix3.js +679 -0
- package/dist/melonjs.mjs/math/observable_vector2.js +469 -0
- package/dist/melonjs.mjs/math/observable_vector3.js +559 -0
- package/dist/melonjs.mjs/math/vector2.js +526 -0
- package/dist/melonjs.mjs/math/vector3.js +567 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +73 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +21 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +324 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +69 -0
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +691 -0
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +350 -0
- package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +3241 -0
- package/dist/melonjs.mjs/particles/emitter.js +265 -0
- package/dist/melonjs.mjs/particles/particle.js +186 -0
- package/dist/melonjs.mjs/particles/settings.js +319 -0
- package/dist/melonjs.mjs/physics/body.js +702 -0
- package/dist/melonjs.mjs/physics/bounds.js +459 -0
- package/dist/melonjs.mjs/physics/collision.js +132 -0
- package/dist/melonjs.mjs/physics/detector.js +194 -0
- package/dist/melonjs.mjs/physics/quadtree.js +394 -0
- package/dist/melonjs.mjs/physics/response.js +57 -0
- package/dist/melonjs.mjs/physics/sat.js +483 -0
- package/dist/melonjs.mjs/physics/world.js +219 -0
- package/dist/melonjs.mjs/plugin/plugin.js +141 -0
- package/dist/melonjs.mjs/renderable/collectable.js +60 -0
- package/dist/melonjs.mjs/renderable/colorlayer.js +78 -0
- package/dist/melonjs.mjs/renderable/container.js +1016 -0
- package/dist/melonjs.mjs/renderable/dragndrop.js +224 -0
- package/dist/melonjs.mjs/renderable/imagelayer.js +305 -0
- package/dist/melonjs.mjs/renderable/light2d.js +155 -0
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +246 -0
- package/dist/melonjs.mjs/renderable/renderable.js +781 -0
- package/dist/melonjs.mjs/renderable/sprite.js +653 -0
- package/dist/melonjs.mjs/renderable/trigger.js +156 -0
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +212 -0
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +225 -0
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +127 -0
- package/dist/melonjs.mjs/state/stage.js +236 -0
- package/dist/melonjs.mjs/state/state.js +596 -0
- package/dist/melonjs.mjs/system/device.js +909 -0
- package/dist/melonjs.mjs/system/dom.js +78 -0
- package/dist/melonjs.mjs/system/event.js +537 -0
- package/dist/melonjs.mjs/system/platform.js +41 -0
- package/dist/melonjs.mjs/system/pooling.js +209 -0
- package/dist/melonjs.mjs/system/save.js +157 -0
- package/dist/melonjs.mjs/system/timer.js +286 -0
- package/dist/melonjs.mjs/text/bitmaptext.js +363 -0
- package/dist/melonjs.mjs/text/bitmaptextdata.js +198 -0
- package/dist/melonjs.mjs/text/glyph.js +65 -0
- package/dist/melonjs.mjs/text/text.js +452 -0
- package/dist/melonjs.mjs/text/textmetrics.js +175 -0
- package/dist/melonjs.mjs/text/textstyle.js +23 -0
- package/dist/melonjs.mjs/tweens/easing.js +336 -0
- package/dist/melonjs.mjs/tweens/interpolation.js +112 -0
- package/dist/melonjs.mjs/tweens/tween.js +479 -0
- package/dist/melonjs.mjs/utils/agent.js +76 -0
- package/dist/melonjs.mjs/utils/array.js +63 -0
- package/dist/melonjs.mjs/utils/file.js +42 -0
- package/dist/melonjs.mjs/utils/function.js +70 -0
- package/dist/melonjs.mjs/utils/string.js +82 -0
- package/dist/melonjs.mjs/utils/utils.js +173 -0
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +806 -0
- package/dist/melonjs.mjs/video/renderer.js +410 -0
- package/dist/melonjs.mjs/video/texture/atlas.js +519 -0
- package/dist/melonjs.mjs/video/texture/cache.js +143 -0
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +144 -0
- package/dist/melonjs.mjs/video/video.js +462 -0
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +142 -0
- package/dist/melonjs.mjs/video/webgl/glshader.js +167 -0
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +10 -0
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +10 -0
- package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +10 -0
- package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +10 -0
- package/dist/melonjs.mjs/video/webgl/utils/attributes.js +25 -0
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +20 -0
- package/dist/melonjs.mjs/video/webgl/utils/program.js +67 -0
- package/dist/melonjs.mjs/video/webgl/utils/string.js +25 -0
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +92 -0
- package/dist/melonjs.mjs/video/webgl/webgl_compositor.js +494 -0
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +1035 -0
- package/dist/melonjs.module.d.ts +1298 -1359
- package/dist/melonjs.module.js +2072 -3520
- package/package.json +21 -16
- package/src/application/application.js +4 -5
- package/src/audio/audio.js +32 -32
- package/src/camera/camera2d.js +32 -33
- package/src/entity/entity.js +18 -19
- package/src/geometries/ellipse.js +17 -18
- package/src/geometries/line.js +6 -7
- package/src/geometries/path2d.js +33 -34
- package/src/geometries/point.js +1 -2
- package/src/geometries/poly.js +16 -18
- package/src/geometries/rectangle.js +19 -20
- package/src/geometries/roundrect.js +9 -10
- package/src/input/gamepad.js +15 -15
- package/src/input/keyboard.js +12 -12
- package/src/input/pointer.js +6 -6
- package/src/input/pointerevent.js +12 -12
- package/src/lang/deprecated.js +12 -12
- package/src/level/level.js +25 -25
- package/src/level/tiled/TMXLayer.js +23 -24
- package/src/level/tiled/TMXTile.js +6 -7
- package/src/level/tiled/TMXTileMap.js +8 -10
- package/src/level/tiled/TMXTileset.js +3 -4
- package/src/level/tiled/TMXTilesetGroup.js +1 -2
- package/src/level/tiled/TMXUtils.js +5 -5
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXRenderer.js +20 -21
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -2
- package/src/loader/loader.js +20 -20
- package/src/math/color.js +21 -22
- package/src/math/math.js +16 -16
- package/src/math/matrix2.js +17 -18
- package/src/math/matrix3.js +26 -27
- package/src/math/observable_vector2.js +15 -16
- package/src/math/observable_vector3.js +17 -18
- package/src/math/vector2.js +10 -11
- package/src/math/vector3.js +11 -12
- package/src/particles/emitter.js +7 -8
- package/src/particles/particle.js +3 -4
- package/src/physics/body.js +29 -30
- package/src/physics/bounds.js +10 -10
- package/src/physics/collision.js +2 -2
- package/src/physics/detector.js +6 -6
- package/src/physics/quadtree.js +18 -23
- package/src/physics/sat.js +31 -31
- package/src/physics/world.js +6 -7
- package/src/plugin/plugin.js +5 -5
- package/src/renderable/collectable.js +4 -6
- package/src/renderable/colorlayer.js +6 -8
- package/src/renderable/container.js +25 -27
- package/src/renderable/dragndrop.js +14 -14
- package/src/renderable/imagelayer.js +14 -15
- package/src/renderable/light2d.js +4 -5
- package/src/renderable/nineslicesprite.js +17 -18
- package/src/renderable/renderable.js +26 -28
- package/src/renderable/sprite.js +29 -30
- package/src/renderable/trigger.js +16 -17
- package/src/renderable/ui/uibaseelement.js +8 -9
- package/src/renderable/ui/uispriteelement.js +8 -8
- package/src/renderable/ui/uitextbutton.js +15 -15
- package/src/state/stage.js +8 -9
- package/src/state/state.js +17 -17
- package/src/system/device.js +11 -11
- package/src/system/event.js +10 -10
- package/src/system/pooling.js +9 -9
- package/src/system/save.js +2 -2
- package/src/system/timer.js +10 -10
- package/src/text/bitmaptext.js +19 -20
- package/src/text/bitmaptextdata.js +3 -4
- package/src/text/glyph.js +1 -2
- package/src/text/text.js +24 -25
- package/src/text/textmetrics.js +9 -10
- package/src/tweens/tween.js +20 -21
- package/src/utils/agent.js +5 -5
- package/src/utils/array.js +4 -4
- package/src/utils/file.js +2 -2
- package/src/utils/function.js +6 -6
- package/src/utils/string.js +5 -5
- package/src/utils/utils.js +4 -4
- package/src/video/canvas/canvas_renderer.js +72 -73
- package/src/video/renderer.js +27 -28
- package/src/video/texture/atlas.js +22 -22
- package/src/video/texture/canvas_texture.js +9 -9
- package/src/video/video.js +17 -17
- package/src/video/webgl/buffer/vertex.js +1 -2
- package/src/video/webgl/glshader.js +12 -12
- package/src/video/webgl/webgl_compositor.js +42 -43
- package/src/video/webgl/webgl_renderer.js +76 -77
|
@@ -14,22 +14,22 @@ import { isPowerOfTwo, nextPowerOfTwo } from "./../../math/math.js";
|
|
|
14
14
|
* a WebGL renderer object
|
|
15
15
|
* @augments Renderer
|
|
16
16
|
*/
|
|
17
|
-
class WebGLRenderer extends Renderer {
|
|
17
|
+
export default class WebGLRenderer extends Renderer {
|
|
18
18
|
/**
|
|
19
|
-
* @param {object} options The renderer parameters
|
|
20
|
-
* @param {number} options.width The width of the canvas without scaling
|
|
21
|
-
* @param {number} options.height The height of the canvas without scaling
|
|
22
|
-
* @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
|
|
23
|
-
* @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing
|
|
24
|
-
* @param {boolean} [options.failIfMajorPerformanceCaveat=true] If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
|
|
25
|
-
* @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas
|
|
26
|
-
* @param {boolean} [options.premultipliedAlpha=true] in WebGL, whether the renderer will assume that colors have premultiplied alpha when canvas transparency is enabled
|
|
27
|
-
* @param {boolean} [options.subPixel=false] Whether to enable subpixel renderering (performance hit when enabled)
|
|
28
|
-
* @param {boolean} [options.preferWebGL1=false] if true the renderer will only use WebGL 1
|
|
29
|
-
* @param {string} [options.powerPreference="default"] a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context ("default", "high-performance", "low-power"). To be noted that Safari and Chrome (since version 80) both default to "low-power" to save battery life and improve the user experience on these dual-GPU machines.
|
|
30
|
-
* @param {number} [options.zoomX=width] The actual width of the canvas with scaling applied
|
|
31
|
-
* @param {number} [options.zoomY=height] The actual height of the canvas with scaling applied
|
|
32
|
-
* @param {WebGLCompositor} [options.compositor] A class that implements the compositor API
|
|
19
|
+
* @param {object} options - The renderer parameters
|
|
20
|
+
* @param {number} options.width - The width of the canvas without scaling
|
|
21
|
+
* @param {number} options.height - The height of the canvas without scaling
|
|
22
|
+
* @param {HTMLCanvasElement} [options.canvas] - The html canvas to draw to on screen
|
|
23
|
+
* @param {boolean} [options.antiAlias=false] - Whether to enable anti-aliasing
|
|
24
|
+
* @param {boolean} [options.failIfMajorPerformanceCaveat=true] - If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
|
|
25
|
+
* @param {boolean} [options.transparent=false] - Whether to enable transparency on the canvas
|
|
26
|
+
* @param {boolean} [options.premultipliedAlpha=true] - in WebGL, whether the renderer will assume that colors have premultiplied alpha when canvas transparency is enabled
|
|
27
|
+
* @param {boolean} [options.subPixel=false] - Whether to enable subpixel renderering (performance hit when enabled)
|
|
28
|
+
* @param {boolean} [options.preferWebGL1=false] - if true the renderer will only use WebGL 1
|
|
29
|
+
* @param {string} [options.powerPreference="default"] - a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context ("default", "high-performance", "low-power"). To be noted that Safari and Chrome (since version 80) both default to "low-power" to save battery life and improve the user experience on these dual-GPU machines.
|
|
30
|
+
* @param {number} [options.zoomX=width] - The actual width of the canvas with scaling applied
|
|
31
|
+
* @param {number} [options.zoomY=height] - The actual height of the canvas with scaling applied
|
|
32
|
+
* @param {WebGLCompositor} [options.compositor] - A class that implements the compositor API
|
|
33
33
|
*/
|
|
34
34
|
constructor(options) {
|
|
35
35
|
|
|
@@ -176,7 +176,7 @@ class WebGLRenderer extends Renderer {
|
|
|
176
176
|
|
|
177
177
|
/**
|
|
178
178
|
* set the active compositor for this renderer
|
|
179
|
-
* @param {WebGLCompositor|string} compositor a compositor name or instance
|
|
179
|
+
* @param {WebGLCompositor|string} compositor - a compositor name or instance
|
|
180
180
|
*/
|
|
181
181
|
setCompositor(compositor = "default") {
|
|
182
182
|
|
|
@@ -244,8 +244,8 @@ class WebGLRenderer extends Renderer {
|
|
|
244
244
|
|
|
245
245
|
/**
|
|
246
246
|
* Create a pattern with the specified repetition
|
|
247
|
-
* @param {Image} image Source image
|
|
248
|
-
* @param {string} repeat Define how the pattern should be repeated
|
|
247
|
+
* @param {Image} image - Source image
|
|
248
|
+
* @param {string} repeat - Define how the pattern should be repeated
|
|
249
249
|
* @returns {TextureAtlas}
|
|
250
250
|
* @see ImageLayer#repeat
|
|
251
251
|
* @example
|
|
@@ -297,8 +297,8 @@ class WebGLRenderer extends Renderer {
|
|
|
297
297
|
|
|
298
298
|
/**
|
|
299
299
|
* Clears the gl context with the given color.
|
|
300
|
-
* @param {Color|string} [color="#000000"] CSS color.
|
|
301
|
-
* @param {boolean} [opaque=false] Allow transparency [default] or clear the surface completely [true]
|
|
300
|
+
* @param {Color|string} [color="#000000"] - CSS color.
|
|
301
|
+
* @param {boolean} [opaque=false] - Allow transparency [default] or clear the surface completely [true]
|
|
302
302
|
*/
|
|
303
303
|
clearColor(color = "#000000", opaque = false) {
|
|
304
304
|
var glArray;
|
|
@@ -317,10 +317,10 @@ class WebGLRenderer extends Renderer {
|
|
|
317
317
|
|
|
318
318
|
/**
|
|
319
319
|
* Erase the pixels in the given rectangular area by setting them to transparent black (rgba(0,0,0,0)).
|
|
320
|
-
* @param {number} x x axis of the coordinate for the rectangle starting point.
|
|
321
|
-
* @param {number} y y axis of the coordinate for the rectangle starting point.
|
|
322
|
-
* @param {number} width The rectangle's width.
|
|
323
|
-
* @param {number} height The rectangle's height.
|
|
320
|
+
* @param {number} x - x axis of the coordinate for the rectangle starting point.
|
|
321
|
+
* @param {number} y - y axis of the coordinate for the rectangle starting point.
|
|
322
|
+
* @param {number} width - The rectangle's width.
|
|
323
|
+
* @param {number} height - The rectangle's height.
|
|
324
324
|
*/
|
|
325
325
|
clearRect(x, y, width, height) {
|
|
326
326
|
this.save();
|
|
@@ -364,15 +364,15 @@ class WebGLRenderer extends Renderer {
|
|
|
364
364
|
|
|
365
365
|
/**
|
|
366
366
|
* Draw an image to the gl context
|
|
367
|
-
* @param {Image} image An element to draw into the context. The specification permits any canvas image source (CanvasImageSource), specifically, a CSSImageValue, an HTMLImageElement, an SVGImageElement, an HTMLVideoElement, an HTMLCanvasElement, an ImageBitmap, or an OffscreenCanvas.
|
|
368
|
-
* @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.
|
|
369
|
-
* @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.
|
|
370
|
-
* @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.
|
|
371
|
-
* @param {number} sh The height of the sub-rectangle of the source image to draw into the destination context.
|
|
372
|
-
* @param {number} dx The X coordinate in the destination canvas at which to place the top-left corner of the source image.
|
|
373
|
-
* @param {number} dy The Y coordinate in the destination canvas at which to place the top-left corner of the source image.
|
|
374
|
-
* @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.
|
|
375
|
-
* @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.
|
|
367
|
+
* @param {Image} image - An element to draw into the context. The specification permits any canvas image source (CanvasImageSource), specifically, a CSSImageValue, an HTMLImageElement, an SVGImageElement, an HTMLVideoElement, an HTMLCanvasElement, an ImageBitmap, or an OffscreenCanvas.
|
|
368
|
+
* @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.
|
|
369
|
+
* @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.
|
|
370
|
+
* @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.
|
|
371
|
+
* @param {number} sh - The height of the sub-rectangle of the source image to draw into the destination context.
|
|
372
|
+
* @param {number} dx - The X coordinate in the destination canvas at which to place the top-left corner of the source image.
|
|
373
|
+
* @param {number} dy - The Y coordinate in the destination canvas at which to place the top-left corner of the source image.
|
|
374
|
+
* @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.
|
|
375
|
+
* @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.
|
|
376
376
|
* @example
|
|
377
377
|
* // Position the image on the canvas:
|
|
378
378
|
* renderer.drawImage(image, dx, dy);
|
|
@@ -414,7 +414,7 @@ class WebGLRenderer extends Renderer {
|
|
|
414
414
|
|
|
415
415
|
/**
|
|
416
416
|
* Draw a pattern within the given rectangle.
|
|
417
|
-
* @param {TextureAtlas} pattern Pattern object
|
|
417
|
+
* @param {TextureAtlas} pattern - Pattern object
|
|
418
418
|
* @param {number} x
|
|
419
419
|
* @param {number} y
|
|
420
420
|
* @param {number} width
|
|
@@ -429,7 +429,7 @@ class WebGLRenderer extends Renderer {
|
|
|
429
429
|
/**
|
|
430
430
|
* Returns the WebGL Context object of the given canvas element
|
|
431
431
|
* @param {HTMLCanvasElement} canvas
|
|
432
|
-
* @param {boolean} [transparent=false] use true to enable transparency
|
|
432
|
+
* @param {boolean} [transparent=false] - use true to enable transparency
|
|
433
433
|
* @returns {WebGLRenderingContext}
|
|
434
434
|
*/
|
|
435
435
|
getContextGL(canvas, transparent = false) {
|
|
@@ -497,7 +497,7 @@ class WebGLRenderer extends Renderer {
|
|
|
497
497
|
* - "screen" : The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply) <br>
|
|
498
498
|
* <img src="images/screen-blendmode.png" width="510"/> <br>
|
|
499
499
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
|
|
500
|
-
* @param {string} [mode="normal"] blend mode : "normal", "multiply", "lighter", "additive", "screen"
|
|
500
|
+
* @param {string} [mode="normal"] - blend mode : "normal", "multiply", "lighter", "additive", "screen"
|
|
501
501
|
* @param {WebGLRenderingContext} [gl]
|
|
502
502
|
*/
|
|
503
503
|
setBlendMode(mode = "normal", gl = this.gl) {
|
|
@@ -593,7 +593,7 @@ class WebGLRenderer extends Renderer {
|
|
|
593
593
|
|
|
594
594
|
/**
|
|
595
595
|
* rotates the uniform matrix
|
|
596
|
-
* @param {number} angle in radians
|
|
596
|
+
* @param {number} angle - in radians
|
|
597
597
|
*/
|
|
598
598
|
rotate(angle) {
|
|
599
599
|
this.currentTransform.rotate(angle);
|
|
@@ -619,7 +619,7 @@ class WebGLRenderer extends Renderer {
|
|
|
619
619
|
|
|
620
620
|
/**
|
|
621
621
|
* Set the global alpha
|
|
622
|
-
* @param {number} alpha 0.0 to 1.0 values accepted.
|
|
622
|
+
* @param {number} alpha - 0.0 to 1.0 values accepted.
|
|
623
623
|
*/
|
|
624
624
|
setGlobalAlpha(alpha) {
|
|
625
625
|
this.currentColor.alpha = alpha;
|
|
@@ -636,7 +636,7 @@ class WebGLRenderer extends Renderer {
|
|
|
636
636
|
/**
|
|
637
637
|
* Set the current fill & stroke style color.
|
|
638
638
|
* By default, or upon reset, the value is set to #000000.
|
|
639
|
-
* @param {Color|string} color css color string.
|
|
639
|
+
* @param {Color|string} color - css color string.
|
|
640
640
|
*/
|
|
641
641
|
setColor(color) {
|
|
642
642
|
var alpha = this.currentColor.alpha;
|
|
@@ -646,7 +646,7 @@ class WebGLRenderer extends Renderer {
|
|
|
646
646
|
|
|
647
647
|
/**
|
|
648
648
|
* Set the line width
|
|
649
|
-
* @param {number} width Line width
|
|
649
|
+
* @param {number} width - Line width
|
|
650
650
|
*/
|
|
651
651
|
setLineWidth(width) {
|
|
652
652
|
this.getContext().lineWidth(width);
|
|
@@ -654,12 +654,12 @@ class WebGLRenderer extends Renderer {
|
|
|
654
654
|
|
|
655
655
|
/**
|
|
656
656
|
* Stroke an arc at the specified coordinates with given radius, start and end points
|
|
657
|
-
* @param {number} x arc center point x-axis
|
|
658
|
-
* @param {number} y arc center point y-axis
|
|
657
|
+
* @param {number} x - arc center point x-axis
|
|
658
|
+
* @param {number} y - arc center point y-axis
|
|
659
659
|
* @param {number} radius
|
|
660
|
-
* @param {number} start start angle in radians
|
|
661
|
-
* @param {number} end end angle in radians
|
|
662
|
-
* @param {boolean} [antiClockwise=false] draw arc anti-clockwise
|
|
660
|
+
* @param {number} start - start angle in radians
|
|
661
|
+
* @param {number} end - end angle in radians
|
|
662
|
+
* @param {boolean} [antiClockwise=false] - draw arc anti-clockwise
|
|
663
663
|
* @param {boolean} [fill=false]
|
|
664
664
|
*/
|
|
665
665
|
strokeArc(x, y, radius, start, end, antiClockwise = false, fill = false) {
|
|
@@ -679,12 +679,12 @@ class WebGLRenderer extends Renderer {
|
|
|
679
679
|
|
|
680
680
|
/**
|
|
681
681
|
* Fill an arc at the specified coordinates with given radius, start and end points
|
|
682
|
-
* @param {number} x arc center point x-axis
|
|
683
|
-
* @param {number} y arc center point y-axis
|
|
682
|
+
* @param {number} x - arc center point x-axis
|
|
683
|
+
* @param {number} y - arc center point y-axis
|
|
684
684
|
* @param {number} radius
|
|
685
|
-
* @param {number} start start angle in radians
|
|
686
|
-
* @param {number} end end angle in radians
|
|
687
|
-
* @param {boolean} [antiClockwise=false] draw arc anti-clockwise
|
|
685
|
+
* @param {number} start - start angle in radians
|
|
686
|
+
* @param {number} end - end angle in radians
|
|
687
|
+
* @param {boolean} [antiClockwise=false] - draw arc anti-clockwise
|
|
688
688
|
*/
|
|
689
689
|
fillArc(x, y, radius, start, end, antiClockwise = false) {
|
|
690
690
|
this.strokeArc(x, y, radius, start, end, antiClockwise, true);
|
|
@@ -692,11 +692,11 @@ class WebGLRenderer extends Renderer {
|
|
|
692
692
|
|
|
693
693
|
/**
|
|
694
694
|
* Stroke an ellipse at the specified coordinates with given radius
|
|
695
|
-
* @param {number} x ellipse center point x-axis
|
|
696
|
-
* @param {number} y ellipse center point y-axis
|
|
697
|
-
* @param {number} w horizontal radius of the ellipse
|
|
698
|
-
* @param {number} h vertical radius of the ellipse
|
|
699
|
-
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
695
|
+
* @param {number} x - ellipse center point x-axis
|
|
696
|
+
* @param {number} y - ellipse center point y-axis
|
|
697
|
+
* @param {number} w - horizontal radius of the ellipse
|
|
698
|
+
* @param {number} h - vertical radius of the ellipse
|
|
699
|
+
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
700
700
|
*/
|
|
701
701
|
strokeEllipse(x, y, w, h, fill = false) {
|
|
702
702
|
if (this.getGlobalAlpha() < 1 / 255) {
|
|
@@ -715,10 +715,10 @@ class WebGLRenderer extends Renderer {
|
|
|
715
715
|
|
|
716
716
|
/**
|
|
717
717
|
* Fill an ellipse at the specified coordinates with given radius
|
|
718
|
-
* @param {number} x ellipse center point x-axis
|
|
719
|
-
* @param {number} y ellipse center point y-axis
|
|
720
|
-
* @param {number} w horizontal radius of the ellipse
|
|
721
|
-
* @param {number} h vertical radius of the ellipse
|
|
718
|
+
* @param {number} x - ellipse center point x-axis
|
|
719
|
+
* @param {number} y - ellipse center point y-axis
|
|
720
|
+
* @param {number} w - horizontal radius of the ellipse
|
|
721
|
+
* @param {number} h - vertical radius of the ellipse
|
|
722
722
|
*/
|
|
723
723
|
fillEllipse(x, y, w, h) {
|
|
724
724
|
this.strokeEllipse(x, y, w, h, false);
|
|
@@ -726,10 +726,10 @@ class WebGLRenderer extends Renderer {
|
|
|
726
726
|
|
|
727
727
|
/**
|
|
728
728
|
* Stroke a line of the given two points
|
|
729
|
-
* @param {number} startX the start x coordinate
|
|
730
|
-
* @param {number} startY the start y coordinate
|
|
731
|
-
* @param {number} endX the end x coordinate
|
|
732
|
-
* @param {number} endY the end y coordinate
|
|
729
|
+
* @param {number} startX - the start x coordinate
|
|
730
|
+
* @param {number} startY - the start y coordinate
|
|
731
|
+
* @param {number} endX - the end x coordinate
|
|
732
|
+
* @param {number} endY - the end y coordinate
|
|
733
733
|
*/
|
|
734
734
|
strokeLine(startX, startY, endX, endY) {
|
|
735
735
|
if (this.getGlobalAlpha() < 1 / 255) {
|
|
@@ -745,10 +745,10 @@ class WebGLRenderer extends Renderer {
|
|
|
745
745
|
|
|
746
746
|
/**
|
|
747
747
|
* Fill a line of the given two points
|
|
748
|
-
* @param {number} startX the start x coordinate
|
|
749
|
-
* @param {number} startY the start y coordinate
|
|
750
|
-
* @param {number} endX the end x coordinate
|
|
751
|
-
* @param {number} endY the end y coordinate
|
|
748
|
+
* @param {number} startX - the start x coordinate
|
|
749
|
+
* @param {number} startY - the start y coordinate
|
|
750
|
+
* @param {number} endX - the end x coordinate
|
|
751
|
+
* @param {number} endY - the end y coordinate
|
|
752
752
|
*/
|
|
753
753
|
fillLine(startX, startY, endX, endY) {
|
|
754
754
|
this.strokeLine(startX, startY, endX, endY);
|
|
@@ -756,8 +756,8 @@ class WebGLRenderer extends Renderer {
|
|
|
756
756
|
|
|
757
757
|
/**
|
|
758
758
|
* Stroke a me.Polygon on the screen with a specified color
|
|
759
|
-
* @param {Polygon} poly the shape to draw
|
|
760
|
-
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
759
|
+
* @param {Polygon} poly - the shape to draw
|
|
760
|
+
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
761
761
|
*/
|
|
762
762
|
strokePolygon(poly, fill = false) {
|
|
763
763
|
if (this.getGlobalAlpha() < 1 / 255) {
|
|
@@ -785,7 +785,7 @@ class WebGLRenderer extends Renderer {
|
|
|
785
785
|
|
|
786
786
|
/**
|
|
787
787
|
* Fill a me.Polygon on the screen
|
|
788
|
-
* @param {Polygon} poly the shape to draw
|
|
788
|
+
* @param {Polygon} poly - the shape to draw
|
|
789
789
|
*/
|
|
790
790
|
fillPolygon(poly) {
|
|
791
791
|
this.strokePolygon(poly, true);
|
|
@@ -797,7 +797,7 @@ class WebGLRenderer extends Renderer {
|
|
|
797
797
|
* @param {number} y
|
|
798
798
|
* @param {number} width
|
|
799
799
|
* @param {number} height
|
|
800
|
-
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
800
|
+
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
801
801
|
*/
|
|
802
802
|
strokeRect(x, y, width, height, fill = false) {
|
|
803
803
|
if (this.getGlobalAlpha() < 1 / 255) {
|
|
@@ -831,7 +831,7 @@ class WebGLRenderer extends Renderer {
|
|
|
831
831
|
* @param {number} width
|
|
832
832
|
* @param {number} height
|
|
833
833
|
* @param {number} radius
|
|
834
|
-
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
834
|
+
* @param {boolean} [fill=false] - also fill the shape with the current color if true
|
|
835
835
|
*/
|
|
836
836
|
strokeRoundRect(x, y, width, height, radius, fill = false) {
|
|
837
837
|
if (this.getGlobalAlpha() < 1 / 255) {
|
|
@@ -883,7 +883,7 @@ class WebGLRenderer extends Renderer {
|
|
|
883
883
|
/**
|
|
884
884
|
* Reset (overrides) the renderer transformation matrix to the
|
|
885
885
|
* identity one, and then apply the given transformation matrix.
|
|
886
|
-
* @param {Matrix2d} mat2d Matrix to transform by
|
|
886
|
+
* @param {Matrix2d} mat2d - Matrix to transform by
|
|
887
887
|
*/
|
|
888
888
|
setTransform(mat2d) {
|
|
889
889
|
this.resetTransform();
|
|
@@ -892,7 +892,7 @@ class WebGLRenderer extends Renderer {
|
|
|
892
892
|
|
|
893
893
|
/**
|
|
894
894
|
* Multiply given matrix into the renderer tranformation matrix
|
|
895
|
-
* @param {Matrix2d} mat2d Matrix to transform by
|
|
895
|
+
* @param {Matrix2d} mat2d - Matrix to transform by
|
|
896
896
|
*/
|
|
897
897
|
transform(mat2d) {
|
|
898
898
|
var currentTransform = this.currentTransform;
|
|
@@ -972,8 +972,8 @@ class WebGLRenderer extends Renderer {
|
|
|
972
972
|
* A mask limits rendering elements to the shape and position of the given mask object.
|
|
973
973
|
* So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
|
|
974
974
|
* Mask are not preserved through renderer context save and restore.
|
|
975
|
-
* @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] a shape defining the mask to be applied
|
|
976
|
-
* @param {boolean} [invert=false] either the given shape should define what is visible (default) or the opposite
|
|
975
|
+
* @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] - a shape defining the mask to be applied
|
|
976
|
+
* @param {boolean} [invert=false] - either the given shape should define what is visible (default) or the opposite
|
|
977
977
|
*/
|
|
978
978
|
setMask(mask, invert = false) {
|
|
979
979
|
var gl = this.gl;
|
|
@@ -1024,4 +1024,3 @@ class WebGLRenderer extends Renderer {
|
|
|
1024
1024
|
}
|
|
1025
1025
|
}
|
|
1026
1026
|
}
|
|
1027
|
-
export default WebGLRenderer;
|