melonjs 13.0.0 → 13.2.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.
- package/dist/melonjs.js +642 -583
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.d.ts +286 -476
- package/dist/melonjs.module.js +629 -592
- package/package.json +7 -7
- package/src/geometries/point.js +80 -0
- package/src/index.js +4 -0
- package/src/input/pointerevent.js +2 -2
- package/src/lang/deprecated.js +27 -1
- package/src/level/tiled/TMXGroup.js +10 -0
- package/src/level/tiled/TMXLayer.js +9 -0
- package/src/level/tiled/TMXObject.js +33 -10
- package/src/level/tiled/TMXTileMap.js +12 -0
- package/src/level/tiled/TMXTileset.js +8 -0
- package/src/math/color.js +63 -43
- package/src/math/observable_vector2.js +26 -2
- package/src/math/observable_vector3.js +32 -4
- package/src/math/vector2.js +23 -0
- package/src/math/vector3.js +26 -0
- package/src/physics/body.js +10 -3
- package/src/physics/bounds.js +10 -9
- package/src/polyfill/index.js +2 -2
- package/src/renderable/nineslicesprite.js +27 -1
- package/src/renderable/renderable.js +49 -135
- package/src/renderable/sprite.js +7 -1
- package/src/text/bitmaptext.js +8 -8
- package/src/text/text.js +1 -1
- package/src/text/textmetrics.js +1 -1
- package/src/video/canvas/canvas_renderer.js +51 -60
- package/src/video/renderer.js +27 -76
- package/src/video/texture/canvas_texture.js +4 -2
- package/src/video/video.js +13 -16
- package/src/video/webgl/glshader.js +0 -28
- package/src/video/webgl/webgl_compositor.js +21 -50
- package/src/video/webgl/webgl_renderer.js +44 -132
|
@@ -20,10 +20,10 @@ class WebGLRenderer extends Renderer {
|
|
|
20
20
|
* @param {number} options.width The width of the canvas without scaling
|
|
21
21
|
* @param {number} options.height The height of the canvas without scaling
|
|
22
22
|
* @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
|
|
23
|
-
* @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering (not applicable when using the WebGL Renderer)
|
|
24
23
|
* @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing
|
|
25
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.
|
|
26
|
-
* @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas
|
|
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
27
|
* @param {boolean} [options.subPixel=false] Whether to enable subpixel renderering (performance hit when enabled)
|
|
28
28
|
* @param {boolean} [options.preferWebGL1=false] if true the renderer will only use WebGL 1
|
|
29
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.
|
|
@@ -38,8 +38,6 @@ class WebGLRenderer extends Renderer {
|
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* The WebGL version used by this renderer (1 or 2)
|
|
41
|
-
* @name WebGLVersion
|
|
42
|
-
* @memberof WebGLRenderer#
|
|
43
41
|
* @type {number}
|
|
44
42
|
* @default 1
|
|
45
43
|
* @readonly
|
|
@@ -48,8 +46,6 @@ class WebGLRenderer extends Renderer {
|
|
|
48
46
|
|
|
49
47
|
/**
|
|
50
48
|
* The vendor string of the underlying graphics driver.
|
|
51
|
-
* @name GPUVendor
|
|
52
|
-
* @memberof WebGLRenderer#
|
|
53
49
|
* @type {string}
|
|
54
50
|
* @default null
|
|
55
51
|
* @readonly
|
|
@@ -58,8 +54,6 @@ class WebGLRenderer extends Renderer {
|
|
|
58
54
|
|
|
59
55
|
/**
|
|
60
56
|
* The renderer string of the underlying graphics driver.
|
|
61
|
-
* @name GPURenderer
|
|
62
|
-
* @memberof WebGLRenderer#
|
|
63
57
|
* @type {string}
|
|
64
58
|
* @default null
|
|
65
59
|
* @readonly
|
|
@@ -69,15 +63,12 @@ class WebGLRenderer extends Renderer {
|
|
|
69
63
|
/**
|
|
70
64
|
* The WebGL context
|
|
71
65
|
* @name gl
|
|
72
|
-
* @memberof WebGLRenderer
|
|
73
66
|
* @type {WebGLRenderingContext}
|
|
74
67
|
*/
|
|
75
|
-
this.context = this.gl = this.getContextGL(this.
|
|
68
|
+
this.context = this.gl = this.getContextGL(this.getCanvas(), options.transparent);
|
|
76
69
|
|
|
77
70
|
/**
|
|
78
71
|
* Maximum number of texture unit supported under the current context
|
|
79
|
-
* @name maxTextures
|
|
80
|
-
* @memberof WebGLRenderer#
|
|
81
72
|
* @type {number}
|
|
82
73
|
* @readonly
|
|
83
74
|
*/
|
|
@@ -105,25 +96,19 @@ class WebGLRenderer extends Renderer {
|
|
|
105
96
|
|
|
106
97
|
/**
|
|
107
98
|
* The current transformation matrix used for transformations on the overall scene
|
|
108
|
-
* @name currentTransform
|
|
109
99
|
* @type {Matrix2d}
|
|
110
|
-
* @memberof WebGLRenderer#
|
|
111
100
|
*/
|
|
112
101
|
this.currentTransform = new Matrix2d();
|
|
113
102
|
|
|
114
103
|
/**
|
|
115
104
|
* The current compositor used by the renderer
|
|
116
|
-
* @name currentCompositor
|
|
117
105
|
* @type {WebGLCompositor}
|
|
118
|
-
* @memberof WebGLRenderer#
|
|
119
106
|
*/
|
|
120
107
|
this.currentCompositor = null;
|
|
121
108
|
|
|
122
109
|
/**
|
|
123
110
|
* The list of active compositors
|
|
124
|
-
* @name compositors
|
|
125
111
|
* @type {Map<WebGLCompositor>}
|
|
126
|
-
* @memberof WebGLRenderer#
|
|
127
112
|
*/
|
|
128
113
|
this.compositors = new Map();
|
|
129
114
|
|
|
@@ -154,13 +139,13 @@ class WebGLRenderer extends Renderer {
|
|
|
154
139
|
// to simulate context lost and restore in WebGL:
|
|
155
140
|
// var ctx = me.video.renderer.context.getExtension('WEBGL_lose_context');
|
|
156
141
|
// ctx.loseContext()
|
|
157
|
-
this.
|
|
142
|
+
this.getCanvas().addEventListener("webglcontextlost", (e) => {
|
|
158
143
|
e.preventDefault();
|
|
159
144
|
this.isContextValid = false;
|
|
160
145
|
event.emit(event.ONCONTEXT_LOST, this);
|
|
161
146
|
}, false );
|
|
162
147
|
// ctx.restoreContext()
|
|
163
|
-
this.
|
|
148
|
+
this.getCanvas().addEventListener("webglcontextrestored", () => {
|
|
164
149
|
this.reset();
|
|
165
150
|
this.isContextValid = true;
|
|
166
151
|
event.emit(event.ONCONTEXT_RESTORED, this);
|
|
@@ -169,8 +154,6 @@ class WebGLRenderer extends Renderer {
|
|
|
169
154
|
|
|
170
155
|
/**
|
|
171
156
|
* Reset context state
|
|
172
|
-
* @name reset
|
|
173
|
-
* @memberof WebGLRenderer
|
|
174
157
|
*/
|
|
175
158
|
reset() {
|
|
176
159
|
super.reset();
|
|
@@ -193,9 +176,7 @@ class WebGLRenderer extends Renderer {
|
|
|
193
176
|
|
|
194
177
|
/**
|
|
195
178
|
* set the active compositor for this renderer
|
|
196
|
-
* @name setCompositor
|
|
197
179
|
* @param {WebGLCompositor|string} compositor a compositor name or instance
|
|
198
|
-
* @memberof WebGLRenderer
|
|
199
180
|
*/
|
|
200
181
|
setCompositor(compositor = "default") {
|
|
201
182
|
|
|
@@ -219,8 +200,6 @@ class WebGLRenderer extends Renderer {
|
|
|
219
200
|
|
|
220
201
|
/**
|
|
221
202
|
* Reset the gl transform to identity
|
|
222
|
-
* @name resetTransform
|
|
223
|
-
* @memberof WebGLRenderer
|
|
224
203
|
*/
|
|
225
204
|
resetTransform() {
|
|
226
205
|
this.currentTransform.identity();
|
|
@@ -231,7 +210,7 @@ class WebGLRenderer extends Renderer {
|
|
|
231
210
|
*/
|
|
232
211
|
createFontTexture(cache) {
|
|
233
212
|
if (typeof this.fontTexture === "undefined") {
|
|
234
|
-
var canvas = this.
|
|
213
|
+
var canvas = this.getCanvas();
|
|
235
214
|
var width = canvas.width;
|
|
236
215
|
var height = canvas.height;
|
|
237
216
|
|
|
@@ -265,8 +244,6 @@ class WebGLRenderer extends Renderer {
|
|
|
265
244
|
|
|
266
245
|
/**
|
|
267
246
|
* Create a pattern with the specified repetition
|
|
268
|
-
* @name createPattern
|
|
269
|
-
* @memberof WebGLRenderer
|
|
270
247
|
* @param {Image} image Source image
|
|
271
248
|
* @param {string} repeat Define how the pattern should be repeated
|
|
272
249
|
* @returns {TextureAtlas}
|
|
@@ -297,8 +274,6 @@ class WebGLRenderer extends Renderer {
|
|
|
297
274
|
|
|
298
275
|
/**
|
|
299
276
|
* Flush the compositor to the frame buffer
|
|
300
|
-
* @name flush
|
|
301
|
-
* @memberof WebGLRenderer
|
|
302
277
|
*/
|
|
303
278
|
flush() {
|
|
304
279
|
this.currentCompositor.flush();
|
|
@@ -306,8 +281,6 @@ class WebGLRenderer extends Renderer {
|
|
|
306
281
|
|
|
307
282
|
/**
|
|
308
283
|
* set/change the current projection matrix (WebGL only)
|
|
309
|
-
* @name setProjection
|
|
310
|
-
* @memberof WebGLRenderer
|
|
311
284
|
* @param {Matrix3d} matrix
|
|
312
285
|
*/
|
|
313
286
|
setProjection(matrix) {
|
|
@@ -315,10 +288,15 @@ class WebGLRenderer extends Renderer {
|
|
|
315
288
|
this.currentCompositor.setProjection(matrix);
|
|
316
289
|
}
|
|
317
290
|
|
|
291
|
+
/**
|
|
292
|
+
* prepare the framebuffer for drawing a new frame
|
|
293
|
+
*/
|
|
294
|
+
clear() {
|
|
295
|
+
this.currentCompositor.clear(this.settings.transparent ? 0.0 : 1.0);
|
|
296
|
+
}
|
|
297
|
+
|
|
318
298
|
/**
|
|
319
299
|
* Clears the gl context with the given color.
|
|
320
|
-
* @name clearColor
|
|
321
|
-
* @memberof WebGLRenderer
|
|
322
300
|
* @param {Color|string} [color="#000000"] CSS color.
|
|
323
301
|
* @param {boolean} [opaque=false] Allow transparency [default] or clear the surface completely [true]
|
|
324
302
|
*/
|
|
@@ -335,17 +313,10 @@ class WebGLRenderer extends Renderer {
|
|
|
335
313
|
}
|
|
336
314
|
// clear gl context with the specified color
|
|
337
315
|
this.currentCompositor.clearColor(glArray[0], glArray[1], glArray[2], (opaque === true) ? 1.0 : glArray[3]);
|
|
338
|
-
this.currentCompositor.clear();
|
|
339
|
-
|
|
340
|
-
// restore default clear Color black
|
|
341
|
-
this.currentCompositor.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
342
|
-
|
|
343
316
|
}
|
|
344
317
|
|
|
345
318
|
/**
|
|
346
319
|
* Erase the pixels in the given rectangular area by setting them to transparent black (rgba(0,0,0,0)).
|
|
347
|
-
* @name clearRect
|
|
348
|
-
* @memberof WebGLRenderer
|
|
349
320
|
* @param {number} x x axis of the coordinate for the rectangle starting point.
|
|
350
321
|
* @param {number} y y axis of the coordinate for the rectangle starting point.
|
|
351
322
|
* @param {number} width The rectangle's width.
|
|
@@ -379,7 +350,7 @@ class WebGLRenderer extends Renderer {
|
|
|
379
350
|
uvs[1],
|
|
380
351
|
uvs[2],
|
|
381
352
|
uvs[3],
|
|
382
|
-
this.currentTint.toUint32()
|
|
353
|
+
this.currentTint.toUint32(this.getGlobalAlpha())
|
|
383
354
|
);
|
|
384
355
|
|
|
385
356
|
// Clear font context2D
|
|
@@ -393,8 +364,6 @@ class WebGLRenderer extends Renderer {
|
|
|
393
364
|
|
|
394
365
|
/**
|
|
395
366
|
* Draw an image to the gl context
|
|
396
|
-
* @name drawImage
|
|
397
|
-
* @memberof WebGLRenderer
|
|
398
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.
|
|
399
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.
|
|
400
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.
|
|
@@ -440,13 +409,11 @@ class WebGLRenderer extends Renderer {
|
|
|
440
409
|
|
|
441
410
|
var texture = this.cache.get(image);
|
|
442
411
|
var uvs = texture.getUVs(sx + "," + sy + "," + sw + "," + sh);
|
|
443
|
-
this.currentCompositor.addQuad(texture, dx, dy, dw, dh, uvs[0], uvs[1], uvs[2], uvs[3], this.currentTint.toUint32());
|
|
412
|
+
this.currentCompositor.addQuad(texture, dx, dy, dw, dh, uvs[0], uvs[1], uvs[2], uvs[3], this.currentTint.toUint32(this.getGlobalAlpha()));
|
|
444
413
|
}
|
|
445
414
|
|
|
446
415
|
/**
|
|
447
416
|
* Draw a pattern within the given rectangle.
|
|
448
|
-
* @name drawPattern
|
|
449
|
-
* @memberof WebGLRenderer
|
|
450
417
|
* @param {TextureAtlas} pattern Pattern object
|
|
451
418
|
* @param {number} x
|
|
452
419
|
* @param {number} y
|
|
@@ -456,29 +423,16 @@ class WebGLRenderer extends Renderer {
|
|
|
456
423
|
*/
|
|
457
424
|
drawPattern(pattern, x, y, width, height) {
|
|
458
425
|
var uvs = pattern.getUVs("0,0," + width + "," + height);
|
|
459
|
-
this.currentCompositor.addQuad(pattern, x, y, width, height, uvs[0], uvs[1], uvs[2], uvs[3], this.currentTint.toUint32());
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
/**
|
|
464
|
-
* return a reference to the screen canvas corresponding WebGL Context
|
|
465
|
-
* @name getScreenContext
|
|
466
|
-
* @memberof WebGLRenderer
|
|
467
|
-
* @returns {WebGLRenderingContext}
|
|
468
|
-
*/
|
|
469
|
-
getScreenContext() {
|
|
470
|
-
return this.gl;
|
|
426
|
+
this.currentCompositor.addQuad(pattern, x, y, width, height, uvs[0], uvs[1], uvs[2], uvs[3], this.currentTint.toUint32(this.getGlobalAlpha()));
|
|
471
427
|
}
|
|
472
428
|
|
|
473
429
|
/**
|
|
474
|
-
* Returns the WebGL Context object of the given
|
|
475
|
-
* @name getContextGL
|
|
476
|
-
* @memberof WebGLRenderer
|
|
430
|
+
* Returns the WebGL Context object of the given canvas element
|
|
477
431
|
* @param {HTMLCanvasElement} canvas
|
|
478
|
-
* @param {boolean} [transparent=
|
|
432
|
+
* @param {boolean} [transparent=false] use true to enable transparency
|
|
479
433
|
* @returns {WebGLRenderingContext}
|
|
480
434
|
*/
|
|
481
|
-
getContextGL(canvas, transparent) {
|
|
435
|
+
getContextGL(canvas, transparent = false) {
|
|
482
436
|
if (typeof canvas === "undefined" || canvas === null) {
|
|
483
437
|
throw new Error(
|
|
484
438
|
"You must pass a canvas element in order to create " +
|
|
@@ -486,17 +440,13 @@ class WebGLRenderer extends Renderer {
|
|
|
486
440
|
);
|
|
487
441
|
}
|
|
488
442
|
|
|
489
|
-
if (typeof transparent !== "boolean") {
|
|
490
|
-
transparent = true;
|
|
491
|
-
}
|
|
492
|
-
|
|
493
443
|
var attr = {
|
|
494
444
|
alpha : transparent,
|
|
495
445
|
antialias : this.settings.antiAlias,
|
|
496
446
|
depth : false,
|
|
497
447
|
stencil: true,
|
|
498
448
|
preserveDrawingBuffer : false,
|
|
499
|
-
premultipliedAlpha: transparent,
|
|
449
|
+
premultipliedAlpha: transparent ? this.settings.premultipliedAlpha : false,
|
|
500
450
|
powerPreference: this.settings.powerPreference,
|
|
501
451
|
failIfMajorPerformanceCaveat : this.settings.failIfMajorPerformanceCaveat
|
|
502
452
|
};
|
|
@@ -529,8 +479,6 @@ class WebGLRenderer extends Renderer {
|
|
|
529
479
|
/**
|
|
530
480
|
* Returns the WebGLContext instance for the renderer
|
|
531
481
|
* return a reference to the system 2d Context
|
|
532
|
-
* @name getContext
|
|
533
|
-
* @memberof WebGLRenderer
|
|
534
482
|
* @returns {WebGLRenderingContext}
|
|
535
483
|
*/
|
|
536
484
|
getContext() {
|
|
@@ -548,9 +496,7 @@ class WebGLRenderer extends Renderer {
|
|
|
548
496
|
* <img src="images/lighter-blendmode.png" width="510"/> <br>
|
|
549
497
|
* - "screen" : The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply) <br>
|
|
550
498
|
* <img src="images/screen-blendmode.png" width="510"/> <br>
|
|
551
|
-
* @name setBlendMode
|
|
552
499
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
|
|
553
|
-
* @memberof WebGLRenderer
|
|
554
500
|
* @param {string} [mode="normal"] blend mode : "normal", "multiply", "lighter", "additive", "screen"
|
|
555
501
|
* @param {WebGLRenderingContext} [gl]
|
|
556
502
|
*/
|
|
@@ -599,8 +545,6 @@ class WebGLRenderer extends Renderer {
|
|
|
599
545
|
|
|
600
546
|
/**
|
|
601
547
|
* restores the canvas context
|
|
602
|
-
* @name restore
|
|
603
|
-
* @memberof WebGLRenderer
|
|
604
548
|
*/
|
|
605
549
|
restore() {
|
|
606
550
|
// do nothing if there is no saved states
|
|
@@ -627,15 +571,13 @@ class WebGLRenderer extends Renderer {
|
|
|
627
571
|
this.gl.disable(this.gl.SCISSOR_TEST);
|
|
628
572
|
this.currentScissor[0] = 0;
|
|
629
573
|
this.currentScissor[1] = 0;
|
|
630
|
-
this.currentScissor[2] = this.
|
|
631
|
-
this.currentScissor[3] = this.
|
|
574
|
+
this.currentScissor[2] = this.getCanvas().width;
|
|
575
|
+
this.currentScissor[3] = this.getCanvas().height;
|
|
632
576
|
}
|
|
633
577
|
}
|
|
634
578
|
|
|
635
579
|
/**
|
|
636
580
|
* saves the canvas context
|
|
637
|
-
* @name save
|
|
638
|
-
* @memberof WebGLRenderer
|
|
639
581
|
*/
|
|
640
582
|
save() {
|
|
641
583
|
this._colorStack.push(this.currentColor.clone());
|
|
@@ -651,8 +593,6 @@ class WebGLRenderer extends Renderer {
|
|
|
651
593
|
|
|
652
594
|
/**
|
|
653
595
|
* rotates the uniform matrix
|
|
654
|
-
* @name rotate
|
|
655
|
-
* @memberof WebGLRenderer
|
|
656
596
|
* @param {number} angle in radians
|
|
657
597
|
*/
|
|
658
598
|
rotate(angle) {
|
|
@@ -661,8 +601,6 @@ class WebGLRenderer extends Renderer {
|
|
|
661
601
|
|
|
662
602
|
/**
|
|
663
603
|
* scales the uniform matrix
|
|
664
|
-
* @name scale
|
|
665
|
-
* @memberof WebGLRenderer
|
|
666
604
|
* @param {number} x
|
|
667
605
|
* @param {number} y
|
|
668
606
|
*/
|
|
@@ -681,8 +619,6 @@ class WebGLRenderer extends Renderer {
|
|
|
681
619
|
|
|
682
620
|
/**
|
|
683
621
|
* Set the global alpha
|
|
684
|
-
* @name setGlobalAlpha
|
|
685
|
-
* @memberof WebGLRenderer
|
|
686
622
|
* @param {number} alpha 0.0 to 1.0 values accepted.
|
|
687
623
|
*/
|
|
688
624
|
setGlobalAlpha(alpha) {
|
|
@@ -691,8 +627,6 @@ class WebGLRenderer extends Renderer {
|
|
|
691
627
|
|
|
692
628
|
/**
|
|
693
629
|
* Return the global alpha
|
|
694
|
-
* @name getGlobalAlpha
|
|
695
|
-
* @memberof WebGLRenderer
|
|
696
630
|
* @returns {number} global alpha value
|
|
697
631
|
*/
|
|
698
632
|
getGlobalAlpha() {
|
|
@@ -702,8 +636,6 @@ class WebGLRenderer extends Renderer {
|
|
|
702
636
|
/**
|
|
703
637
|
* Set the current fill & stroke style color.
|
|
704
638
|
* By default, or upon reset, the value is set to #000000.
|
|
705
|
-
* @name setColor
|
|
706
|
-
* @memberof WebGLRenderer
|
|
707
639
|
* @param {Color|string} color css color string.
|
|
708
640
|
*/
|
|
709
641
|
setColor(color) {
|
|
@@ -714,18 +646,14 @@ class WebGLRenderer extends Renderer {
|
|
|
714
646
|
|
|
715
647
|
/**
|
|
716
648
|
* Set the line width
|
|
717
|
-
* @name setLineWidth
|
|
718
|
-
* @memberof WebGLRenderer
|
|
719
649
|
* @param {number} width Line width
|
|
720
650
|
*/
|
|
721
651
|
setLineWidth(width) {
|
|
722
|
-
this.
|
|
652
|
+
this.getContext().lineWidth(width);
|
|
723
653
|
}
|
|
724
654
|
|
|
725
655
|
/**
|
|
726
656
|
* Stroke an arc at the specified coordinates with given radius, start and end points
|
|
727
|
-
* @name strokeArc
|
|
728
|
-
* @memberof WebGLRenderer
|
|
729
657
|
* @param {number} x arc center point x-axis
|
|
730
658
|
* @param {number} y arc center point y-axis
|
|
731
659
|
* @param {number} radius
|
|
@@ -751,8 +679,6 @@ class WebGLRenderer extends Renderer {
|
|
|
751
679
|
|
|
752
680
|
/**
|
|
753
681
|
* Fill an arc at the specified coordinates with given radius, start and end points
|
|
754
|
-
* @name fillArc
|
|
755
|
-
* @memberof WebGLRenderer
|
|
756
682
|
* @param {number} x arc center point x-axis
|
|
757
683
|
* @param {number} y arc center point y-axis
|
|
758
684
|
* @param {number} radius
|
|
@@ -766,8 +692,6 @@ class WebGLRenderer extends Renderer {
|
|
|
766
692
|
|
|
767
693
|
/**
|
|
768
694
|
* Stroke an ellipse at the specified coordinates with given radius
|
|
769
|
-
* @name strokeEllipse
|
|
770
|
-
* @memberof WebGLRenderer
|
|
771
695
|
* @param {number} x ellipse center point x-axis
|
|
772
696
|
* @param {number} y ellipse center point y-axis
|
|
773
697
|
* @param {number} w horizontal radius of the ellipse
|
|
@@ -791,8 +715,6 @@ class WebGLRenderer extends Renderer {
|
|
|
791
715
|
|
|
792
716
|
/**
|
|
793
717
|
* Fill an ellipse at the specified coordinates with given radius
|
|
794
|
-
* @name fillEllipse
|
|
795
|
-
* @memberof WebGLRenderer
|
|
796
718
|
* @param {number} x ellipse center point x-axis
|
|
797
719
|
* @param {number} y ellipse center point y-axis
|
|
798
720
|
* @param {number} w horizontal radius of the ellipse
|
|
@@ -804,8 +726,6 @@ class WebGLRenderer extends Renderer {
|
|
|
804
726
|
|
|
805
727
|
/**
|
|
806
728
|
* Stroke a line of the given two points
|
|
807
|
-
* @name strokeLine
|
|
808
|
-
* @memberof WebGLRenderer
|
|
809
729
|
* @param {number} startX the start x coordinate
|
|
810
730
|
* @param {number} startY the start y coordinate
|
|
811
731
|
* @param {number} endX the end x coordinate
|
|
@@ -825,8 +745,6 @@ class WebGLRenderer extends Renderer {
|
|
|
825
745
|
|
|
826
746
|
/**
|
|
827
747
|
* Fill a line of the given two points
|
|
828
|
-
* @name fillLine
|
|
829
|
-
* @memberof WebGLRenderer
|
|
830
748
|
* @param {number} startX the start x coordinate
|
|
831
749
|
* @param {number} startY the start y coordinate
|
|
832
750
|
* @param {number} endX the end x coordinate
|
|
@@ -838,8 +756,6 @@ class WebGLRenderer extends Renderer {
|
|
|
838
756
|
|
|
839
757
|
/**
|
|
840
758
|
* Stroke a me.Polygon on the screen with a specified color
|
|
841
|
-
* @name strokePolygon
|
|
842
|
-
* @memberof WebGLRenderer
|
|
843
759
|
* @param {Polygon} poly the shape to draw
|
|
844
760
|
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
845
761
|
*/
|
|
@@ -869,8 +785,6 @@ class WebGLRenderer extends Renderer {
|
|
|
869
785
|
|
|
870
786
|
/**
|
|
871
787
|
* Fill a me.Polygon on the screen
|
|
872
|
-
* @name fillPolygon
|
|
873
|
-
* @memberof WebGLRenderer
|
|
874
788
|
* @param {Polygon} poly the shape to draw
|
|
875
789
|
*/
|
|
876
790
|
fillPolygon(poly) {
|
|
@@ -879,8 +793,6 @@ class WebGLRenderer extends Renderer {
|
|
|
879
793
|
|
|
880
794
|
/**
|
|
881
795
|
* Draw a stroke rectangle at the specified coordinates
|
|
882
|
-
* @name strokeRect
|
|
883
|
-
* @memberof WebGLRenderer
|
|
884
796
|
* @param {number} x
|
|
885
797
|
* @param {number} y
|
|
886
798
|
* @param {number} width
|
|
@@ -903,8 +815,6 @@ class WebGLRenderer extends Renderer {
|
|
|
903
815
|
|
|
904
816
|
/**
|
|
905
817
|
* Draw a filled rectangle at the specified coordinates
|
|
906
|
-
* @name fillRect
|
|
907
|
-
* @memberof WebGLRenderer
|
|
908
818
|
* @param {number} x
|
|
909
819
|
* @param {number} y
|
|
910
820
|
* @param {number} width
|
|
@@ -916,8 +826,6 @@ class WebGLRenderer extends Renderer {
|
|
|
916
826
|
|
|
917
827
|
/**
|
|
918
828
|
* Stroke a rounded rectangle at the specified coordinates
|
|
919
|
-
* @name strokeRoundRect
|
|
920
|
-
* @memberof WebGLRenderer
|
|
921
829
|
* @param {number} x
|
|
922
830
|
* @param {number} y
|
|
923
831
|
* @param {number} width
|
|
@@ -942,8 +850,6 @@ class WebGLRenderer extends Renderer {
|
|
|
942
850
|
|
|
943
851
|
/**
|
|
944
852
|
* Draw a rounded filled rectangle at the specified coordinates
|
|
945
|
-
* @name fillRoundRect
|
|
946
|
-
* @memberof WebGLRenderer
|
|
947
853
|
* @param {number} x
|
|
948
854
|
* @param {number} y
|
|
949
855
|
* @param {number} width
|
|
@@ -954,11 +860,29 @@ class WebGLRenderer extends Renderer {
|
|
|
954
860
|
this.strokeRoundRect(x, y, width, height, radius, true);
|
|
955
861
|
}
|
|
956
862
|
|
|
863
|
+
/**
|
|
864
|
+
* Stroke a Point at the specified coordinates
|
|
865
|
+
* @param {number} x
|
|
866
|
+
* @param {number} y
|
|
867
|
+
*/
|
|
868
|
+
strokePoint(x, y) {
|
|
869
|
+
this.strokeLine(x, y, x + 1, y + 1);
|
|
870
|
+
}
|
|
871
|
+
|
|
872
|
+
/**
|
|
873
|
+
* Draw a a point at the specified coordinates
|
|
874
|
+
* @param {number} x
|
|
875
|
+
* @param {number} y
|
|
876
|
+
* @param {number} width
|
|
877
|
+
* @param {number} height
|
|
878
|
+
*/
|
|
879
|
+
fillPoint(x, y) {
|
|
880
|
+
this.strokePoint(x, y);
|
|
881
|
+
}
|
|
882
|
+
|
|
957
883
|
/**
|
|
958
884
|
* Reset (overrides) the renderer transformation matrix to the
|
|
959
885
|
* identity one, and then apply the given transformation matrix.
|
|
960
|
-
* @name setTransform
|
|
961
|
-
* @memberof WebGLRenderer
|
|
962
886
|
* @param {Matrix2d} mat2d Matrix to transform by
|
|
963
887
|
*/
|
|
964
888
|
setTransform(mat2d) {
|
|
@@ -968,8 +892,6 @@ class WebGLRenderer extends Renderer {
|
|
|
968
892
|
|
|
969
893
|
/**
|
|
970
894
|
* Multiply given matrix into the renderer tranformation matrix
|
|
971
|
-
* @name transform
|
|
972
|
-
* @memberof WebGLRenderer
|
|
973
895
|
* @param {Matrix2d} mat2d Matrix to transform by
|
|
974
896
|
*/
|
|
975
897
|
transform(mat2d) {
|
|
@@ -985,8 +907,6 @@ class WebGLRenderer extends Renderer {
|
|
|
985
907
|
|
|
986
908
|
/**
|
|
987
909
|
* Translates the uniform matrix by the given coordinates
|
|
988
|
-
* @name translate
|
|
989
|
-
* @memberof WebGLRenderer
|
|
990
910
|
* @param {number} x
|
|
991
911
|
* @param {number} y
|
|
992
912
|
*/
|
|
@@ -1007,15 +927,13 @@ class WebGLRenderer extends Renderer {
|
|
|
1007
927
|
* You can however save the current region using the save(),
|
|
1008
928
|
* and restore it (with the restore() method) any time in the future.
|
|
1009
929
|
* (<u>this is an experimental feature !</u>)
|
|
1010
|
-
* @name clipRect
|
|
1011
|
-
* @memberof WebGLRenderer
|
|
1012
930
|
* @param {number} x
|
|
1013
931
|
* @param {number} y
|
|
1014
932
|
* @param {number} width
|
|
1015
933
|
* @param {number} height
|
|
1016
934
|
*/
|
|
1017
935
|
clipRect(x, y, width, height) {
|
|
1018
|
-
var canvas = this.
|
|
936
|
+
var canvas = this.getCanvas();
|
|
1019
937
|
var gl = this.gl;
|
|
1020
938
|
// if requested box is different from the current canvas size
|
|
1021
939
|
if (x !== 0 || y !== 0 || width !== canvas.width || height !== canvas.height) {
|
|
@@ -1054,8 +972,6 @@ class WebGLRenderer extends Renderer {
|
|
|
1054
972
|
* A mask limits rendering elements to the shape and position of the given mask object.
|
|
1055
973
|
* So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
|
|
1056
974
|
* Mask are not preserved through renderer context save and restore.
|
|
1057
|
-
* @name setMask
|
|
1058
|
-
* @memberof WebGLRenderer
|
|
1059
975
|
* @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] a shape defining the mask to be applied
|
|
1060
976
|
* @param {boolean} [invert=false] either the given shape should define what is visible (default) or the opposite
|
|
1061
977
|
*/
|
|
@@ -1069,8 +985,6 @@ class WebGLRenderer extends Renderer {
|
|
|
1069
985
|
// Enable and setup GL state to write to stencil buffer
|
|
1070
986
|
gl.enable(gl.STENCIL_TEST);
|
|
1071
987
|
gl.clear(gl.STENCIL_BUFFER_BIT);
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
988
|
}
|
|
1075
989
|
|
|
1076
990
|
this.maskLevel++;
|
|
@@ -1099,9 +1013,7 @@ class WebGLRenderer extends Renderer {
|
|
|
1099
1013
|
|
|
1100
1014
|
/**
|
|
1101
1015
|
* disable (remove) the rendering mask set through setMask.
|
|
1102
|
-
* @name clearMask
|
|
1103
1016
|
* @see WebGLRenderer#setMask
|
|
1104
|
-
* @memberof WebGLRenderer
|
|
1105
1017
|
*/
|
|
1106
1018
|
clearMask() {
|
|
1107
1019
|
if (this.maskLevel > 0) {
|