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
package/dist/melonjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* melonJS Game Engine - v13.
|
|
2
|
+
* melonJS Game Engine - v13.2.0
|
|
3
3
|
* http://www.melonjs.org
|
|
4
4
|
* melonjs is licensed under the MIT License.
|
|
5
5
|
* http://www.opensource.org/licenses/mit-license
|
|
@@ -315,10 +315,10 @@
|
|
|
315
315
|
(shared$3.exports = function (key, value) {
|
|
316
316
|
return store$2[key] || (store$2[key] = value !== undefined ? value : {});
|
|
317
317
|
})('versions', []).push({
|
|
318
|
-
version: '3.
|
|
318
|
+
version: '3.24.1',
|
|
319
319
|
mode: 'global',
|
|
320
320
|
copyright: '© 2014-2022 Denis Pushkarev (zloirock.ru)',
|
|
321
|
-
license: 'https://github.com/zloirock/core-js/blob/v3.
|
|
321
|
+
license: 'https://github.com/zloirock/core-js/blob/v3.24.1/LICENSE',
|
|
322
322
|
source: 'https://github.com/zloirock/core-js'
|
|
323
323
|
});
|
|
324
324
|
|
|
@@ -2366,6 +2366,29 @@
|
|
|
2366
2366
|
return this;
|
|
2367
2367
|
};
|
|
2368
2368
|
|
|
2369
|
+
/**
|
|
2370
|
+
* interpolate the position of this vector towards the given one by the given maximum step.
|
|
2371
|
+
* @name moveTowards
|
|
2372
|
+
* @memberof Vector2d
|
|
2373
|
+
* @param {Vector2d} target
|
|
2374
|
+
* @param {number} step the maximum step per iteration (Negative values will push the vector away from the target)
|
|
2375
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
2376
|
+
*/
|
|
2377
|
+
Vector2d.prototype.moveTowards = function moveTowards (target, step) {
|
|
2378
|
+
var angle = Math.atan2(target.y - this.y, target.x - this.x);
|
|
2379
|
+
|
|
2380
|
+
var distance = this.distance(target);
|
|
2381
|
+
|
|
2382
|
+
if (distance === 0 || (step >= 0 && distance <= step * step)) {
|
|
2383
|
+
return target;
|
|
2384
|
+
}
|
|
2385
|
+
|
|
2386
|
+
this.x += Math.cos(angle) * step;
|
|
2387
|
+
this.y += Math.sin(angle) * step;
|
|
2388
|
+
|
|
2389
|
+
return this;
|
|
2390
|
+
};
|
|
2391
|
+
|
|
2369
2392
|
/**
|
|
2370
2393
|
* return the distance between this vector and the passed one
|
|
2371
2394
|
* @name distance
|
|
@@ -2433,9 +2456,17 @@
|
|
|
2433
2456
|
};
|
|
2434
2457
|
|
|
2435
2458
|
// convert a give color component to it hexadecimal value
|
|
2436
|
-
|
|
2459
|
+
function toHex(component) {
|
|
2437
2460
|
return "0123456789ABCDEF".charAt((component - (component % 16)) >> 4) + "0123456789ABCDEF".charAt(component % 16);
|
|
2438
|
-
}
|
|
2461
|
+
}
|
|
2462
|
+
function hue2rgb(p, q, t) {
|
|
2463
|
+
if (t < 0) { t += 1; }
|
|
2464
|
+
if (t > 1) { t -= 1; }
|
|
2465
|
+
if (t < 1/6) { return p + (q - p) * 6 * t; }
|
|
2466
|
+
if (t < 1/2) { return q; }
|
|
2467
|
+
if (t < 2/3) { return p + (q - p) * (2/3 - t) * 6; }
|
|
2468
|
+
return p;
|
|
2469
|
+
}
|
|
2439
2470
|
|
|
2440
2471
|
var rgbaRx = /^rgba?\((\d+), ?(\d+), ?(\d+)(, ?([\d\.]+))?\)$/;
|
|
2441
2472
|
var hex3Rx = /^#([\da-fA-F])([\da-fA-F])([\da-fA-F])$/;
|
|
@@ -2635,7 +2666,6 @@
|
|
|
2635
2666
|
/**
|
|
2636
2667
|
* Color Red Component [0 .. 255]
|
|
2637
2668
|
* @type {number}
|
|
2638
|
-
* @memberof Color
|
|
2639
2669
|
*/
|
|
2640
2670
|
prototypeAccessors$4.r.get = function () {
|
|
2641
2671
|
return ~~(this.glArray[0] * 255);
|
|
@@ -2649,7 +2679,6 @@
|
|
|
2649
2679
|
/**
|
|
2650
2680
|
* Color Green Component [0 .. 255]
|
|
2651
2681
|
* @type {number}
|
|
2652
|
-
* @memberof Color
|
|
2653
2682
|
*/
|
|
2654
2683
|
prototypeAccessors$4.g.get = function () {
|
|
2655
2684
|
return ~~(this.glArray[1] * 255);
|
|
@@ -2663,7 +2692,6 @@
|
|
|
2663
2692
|
/**
|
|
2664
2693
|
* Color Blue Component [0 .. 255]
|
|
2665
2694
|
* @type {number}
|
|
2666
|
-
* @memberof Color
|
|
2667
2695
|
*/
|
|
2668
2696
|
prototypeAccessors$4.b.get = function () {
|
|
2669
2697
|
return ~~(this.glArray[2] * 255);
|
|
@@ -2675,7 +2703,6 @@
|
|
|
2675
2703
|
/**
|
|
2676
2704
|
* Color Alpha Component [0.0 .. 1.0]
|
|
2677
2705
|
* @type {number}
|
|
2678
|
-
* @memberof Color
|
|
2679
2706
|
*/
|
|
2680
2707
|
prototypeAccessors$4.alpha.get = function () {
|
|
2681
2708
|
return this.glArray[3];
|
|
@@ -2688,8 +2715,6 @@
|
|
|
2688
2715
|
|
|
2689
2716
|
/**
|
|
2690
2717
|
* Set this color to the specified value.
|
|
2691
|
-
* @name setColor
|
|
2692
|
-
* @memberof Color
|
|
2693
2718
|
* @param {number} r red component [0 .. 255]
|
|
2694
2719
|
* @param {number} g green component [0 .. 255]
|
|
2695
2720
|
* @param {number} b blue component [0 .. 255]
|
|
@@ -2706,10 +2731,59 @@
|
|
|
2706
2731
|
return this;
|
|
2707
2732
|
};
|
|
2708
2733
|
|
|
2734
|
+
/**
|
|
2735
|
+
* set this color to the specified HSV value
|
|
2736
|
+
* @param {number} h hue (a value from 0 to 1)
|
|
2737
|
+
* @param {number} s saturation (a value from 0 to 1)
|
|
2738
|
+
* @param {number} v value (a value from 0 to 1)
|
|
2739
|
+
* @returns {Color} Reference to this object for method chaining
|
|
2740
|
+
*/
|
|
2741
|
+
Color.prototype.setHSV = function setHSV (h, s, v) {
|
|
2742
|
+
var r, g, b;
|
|
2743
|
+
|
|
2744
|
+
var i = Math.floor(h * 6);
|
|
2745
|
+
var f = h * 6 - i;
|
|
2746
|
+
var p = v * (1 - s);
|
|
2747
|
+
var q = v * (1 - f * s);
|
|
2748
|
+
var t = v * (1 - (1 - f) * s);
|
|
2749
|
+
|
|
2750
|
+
switch (i % 6) {
|
|
2751
|
+
case 0: r = v, g = t, b = p; break;
|
|
2752
|
+
case 1: r = q, g = v, b = p; break;
|
|
2753
|
+
case 2: r = p, g = v, b = t; break;
|
|
2754
|
+
case 3: r = p, g = q, b = v; break;
|
|
2755
|
+
case 4: r = t, g = p, b = v; break;
|
|
2756
|
+
case 5: r = v, g = p, b = q; break;
|
|
2757
|
+
}
|
|
2758
|
+
return this.setColor(r * 255, g * 255, b * 255);
|
|
2759
|
+
};
|
|
2760
|
+
|
|
2761
|
+
/**
|
|
2762
|
+
* set this color to the specified HSL value
|
|
2763
|
+
* @param {number} h hue (a value from 0 to 1)
|
|
2764
|
+
* @param {number} s saturation (a value from 0 to 1)
|
|
2765
|
+
* @param {number} l lightness (a value from 0 to 1)
|
|
2766
|
+
* @returns {Color} Reference to this object for method chaining
|
|
2767
|
+
*/
|
|
2768
|
+
Color.prototype.setHSL = function setHSL (h, s, l) {
|
|
2769
|
+
var r, g, b;
|
|
2770
|
+
|
|
2771
|
+
if (s === 0) {
|
|
2772
|
+
r = g = b = l; // achromatic
|
|
2773
|
+
} else {
|
|
2774
|
+
var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
|
|
2775
|
+
var p = 2 * l - q;
|
|
2776
|
+
|
|
2777
|
+
r = hue2rgb(p, q, h + 1/3);
|
|
2778
|
+
g = hue2rgb(p, q, h);
|
|
2779
|
+
b = hue2rgb(p, q, h - 1/3);
|
|
2780
|
+
}
|
|
2781
|
+
|
|
2782
|
+
return this.setColor(r * 255, g * 255, b * 255);
|
|
2783
|
+
};
|
|
2784
|
+
|
|
2709
2785
|
/**
|
|
2710
2786
|
* Create a new copy of this color object.
|
|
2711
|
-
* @name clone
|
|
2712
|
-
* @memberof Color
|
|
2713
2787
|
* @returns {Color} Reference to the newly cloned object
|
|
2714
2788
|
*/
|
|
2715
2789
|
Color.prototype.clone = function clone () {
|
|
@@ -2718,8 +2792,6 @@
|
|
|
2718
2792
|
|
|
2719
2793
|
/**
|
|
2720
2794
|
* Copy a color object or CSS color into this one.
|
|
2721
|
-
* @name copy
|
|
2722
|
-
* @memberof Color
|
|
2723
2795
|
* @param {Color|string} color
|
|
2724
2796
|
* @returns {Color} Reference to this object for method chaining
|
|
2725
2797
|
*/
|
|
@@ -2734,8 +2806,6 @@
|
|
|
2734
2806
|
|
|
2735
2807
|
/**
|
|
2736
2808
|
* Blend this color with the given one using addition.
|
|
2737
|
-
* @name add
|
|
2738
|
-
* @memberof Color
|
|
2739
2809
|
* @param {Color} color
|
|
2740
2810
|
* @returns {Color} Reference to this object for method chaining
|
|
2741
2811
|
*/
|
|
@@ -2750,8 +2820,6 @@
|
|
|
2750
2820
|
|
|
2751
2821
|
/**
|
|
2752
2822
|
* Darken this color value by 0..1
|
|
2753
|
-
* @name darken
|
|
2754
|
-
* @memberof Color
|
|
2755
2823
|
* @param {number} scale
|
|
2756
2824
|
* @returns {Color} Reference to this object for method chaining
|
|
2757
2825
|
*/
|
|
@@ -2766,8 +2834,6 @@
|
|
|
2766
2834
|
|
|
2767
2835
|
/**
|
|
2768
2836
|
* Linearly interpolate between this color and the given one.
|
|
2769
|
-
* @name lerp
|
|
2770
|
-
* @memberof Color
|
|
2771
2837
|
* @param {Color} color
|
|
2772
2838
|
* @param {number} alpha with alpha = 0 being this color, and alpha = 1 being the given one.
|
|
2773
2839
|
* @returns {Color} Reference to this object for method chaining
|
|
@@ -2783,8 +2849,6 @@
|
|
|
2783
2849
|
|
|
2784
2850
|
/**
|
|
2785
2851
|
* Lighten this color value by 0..1
|
|
2786
|
-
* @name lighten
|
|
2787
|
-
* @memberof Color
|
|
2788
2852
|
* @param {number} scale
|
|
2789
2853
|
* @returns {Color} Reference to this object for method chaining
|
|
2790
2854
|
*/
|
|
@@ -2799,8 +2863,6 @@
|
|
|
2799
2863
|
|
|
2800
2864
|
/**
|
|
2801
2865
|
* Generate random r,g,b values for this color object
|
|
2802
|
-
* @name random
|
|
2803
|
-
* @memberof Color
|
|
2804
2866
|
* @param {number} [min=0] minimum value for the random range
|
|
2805
2867
|
* @param {number} [max=255] maxmium value for the random range
|
|
2806
2868
|
* @returns {Color} Reference to this object for method chaining
|
|
@@ -2827,8 +2889,6 @@
|
|
|
2827
2889
|
/**
|
|
2828
2890
|
* Return true if the r,g,b,a values of this color are equal with the
|
|
2829
2891
|
* given one.
|
|
2830
|
-
* @name equals
|
|
2831
|
-
* @memberof Color
|
|
2832
2892
|
* @param {Color} color
|
|
2833
2893
|
* @returns {boolean}
|
|
2834
2894
|
*/
|
|
@@ -2844,8 +2904,6 @@
|
|
|
2844
2904
|
/**
|
|
2845
2905
|
* Parse a CSS color string and set this color to the corresponding
|
|
2846
2906
|
* r,g,b values
|
|
2847
|
-
* @name parseCSS
|
|
2848
|
-
* @memberof Color
|
|
2849
2907
|
* @param {string} cssColor
|
|
2850
2908
|
* @returns {Color} Reference to this object for method chaining
|
|
2851
2909
|
*/
|
|
@@ -2861,8 +2919,6 @@
|
|
|
2861
2919
|
|
|
2862
2920
|
/**
|
|
2863
2921
|
* Parse an RGB or RGBA CSS color string
|
|
2864
|
-
* @name parseRGB
|
|
2865
|
-
* @memberof Color
|
|
2866
2922
|
* @param {string} rgbColor
|
|
2867
2923
|
* @returns {Color} Reference to this object for method chaining
|
|
2868
2924
|
*/
|
|
@@ -2880,8 +2936,6 @@
|
|
|
2880
2936
|
/**
|
|
2881
2937
|
* Parse a Hex color ("#RGB", "#RGBA" or "#RRGGBB", "#RRGGBBAA" format) and set this color to
|
|
2882
2938
|
* the corresponding r,g,b,a values
|
|
2883
|
-
* @name parseHex
|
|
2884
|
-
* @memberof Color
|
|
2885
2939
|
* @param {string} hexColor
|
|
2886
2940
|
* @param {boolean} [argb = false] true if format is #ARGB, or #AARRGGBB (as opposed to #RGBA or #RGGBBAA)
|
|
2887
2941
|
* @returns {Color} Reference to this object for method chaining
|
|
@@ -2941,13 +2995,11 @@
|
|
|
2941
2995
|
|
|
2942
2996
|
/**
|
|
2943
2997
|
* Pack this color into a Uint32 ARGB representation
|
|
2944
|
-
* @name toUint32
|
|
2945
|
-
* @memberof Color
|
|
2946
2998
|
* @param {number} [alpha=1.0] alpha value [0.0 .. 1.0]
|
|
2947
2999
|
* @returns {number}
|
|
2948
3000
|
*/
|
|
2949
3001
|
Color.prototype.toUint32 = function toUint32 (alpha) {
|
|
2950
|
-
if ( alpha === void 0 ) alpha =
|
|
3002
|
+
if ( alpha === void 0 ) alpha = 1.0;
|
|
2951
3003
|
|
|
2952
3004
|
var ur = this.r & 0xff;
|
|
2953
3005
|
var ug = this.g & 0xff;
|
|
@@ -2959,8 +3011,6 @@
|
|
|
2959
3011
|
|
|
2960
3012
|
/**
|
|
2961
3013
|
* return an array representation of this object
|
|
2962
|
-
* @name toArray
|
|
2963
|
-
* @memberof Color
|
|
2964
3014
|
* @returns {Float32Array}
|
|
2965
3015
|
*/
|
|
2966
3016
|
Color.prototype.toArray = function toArray () {
|
|
@@ -2969,9 +3019,7 @@
|
|
|
2969
3019
|
|
|
2970
3020
|
|
|
2971
3021
|
/**
|
|
2972
|
-
*
|
|
2973
|
-
* @name toHex
|
|
2974
|
-
* @memberof Color
|
|
3022
|
+
* return the color in "#RRGGBB" format
|
|
2975
3023
|
* @returns {string}
|
|
2976
3024
|
*/
|
|
2977
3025
|
Color.prototype.toHex = function toHex$1 () {
|
|
@@ -2983,8 +3031,6 @@
|
|
|
2983
3031
|
|
|
2984
3032
|
/**
|
|
2985
3033
|
* Get the color in "#RRGGBBAA" format
|
|
2986
|
-
* @name toHex8
|
|
2987
|
-
* @memberof Color
|
|
2988
3034
|
* @returns {string}
|
|
2989
3035
|
*/
|
|
2990
3036
|
Color.prototype.toHex8 = function toHex8 (alpha) {
|
|
@@ -2998,8 +3044,6 @@
|
|
|
2998
3044
|
|
|
2999
3045
|
/**
|
|
3000
3046
|
* Get the color in "rgb(R,G,B)" format
|
|
3001
|
-
* @name toRGB
|
|
3002
|
-
* @memberof Color
|
|
3003
3047
|
* @returns {string}
|
|
3004
3048
|
*/
|
|
3005
3049
|
Color.prototype.toRGB = function toRGB () {
|
|
@@ -3015,8 +3059,6 @@
|
|
|
3015
3059
|
|
|
3016
3060
|
/**
|
|
3017
3061
|
* Get the color in "rgba(R,G,B,A)" format
|
|
3018
|
-
* @name toRGBA
|
|
3019
|
-
* @memberof Color
|
|
3020
3062
|
* @param {number} [alpha=1.0] alpha value [0.0 .. 1.0]
|
|
3021
3063
|
* @returns {string}
|
|
3022
3064
|
*/
|
|
@@ -6501,56 +6543,38 @@
|
|
|
6501
6543
|
|
|
6502
6544
|
/**
|
|
6503
6545
|
* the active gl rendering context
|
|
6504
|
-
* @public
|
|
6505
6546
|
* @type {WebGLRenderingContext}
|
|
6506
|
-
* @name gl
|
|
6507
|
-
* @memberof GLShader
|
|
6508
6547
|
*/
|
|
6509
6548
|
this.gl = gl;
|
|
6510
6549
|
|
|
6511
6550
|
/**
|
|
6512
6551
|
* the vertex shader source code
|
|
6513
|
-
* @public
|
|
6514
6552
|
* @type {string}
|
|
6515
|
-
* @name vertex
|
|
6516
|
-
* @memberof GLShader
|
|
6517
6553
|
*/
|
|
6518
6554
|
this.vertex = setPrecision(minify(vertex), precision || getMaxShaderPrecision(this.gl));
|
|
6519
6555
|
|
|
6520
6556
|
/**
|
|
6521
6557
|
* the fragment shader source code
|
|
6522
|
-
* @public
|
|
6523
6558
|
* @type {string}
|
|
6524
|
-
* @name vertex
|
|
6525
|
-
* @memberof GLShader
|
|
6526
6559
|
*/
|
|
6527
6560
|
this.fragment = setPrecision(minify(fragment), precision || getMaxShaderPrecision(this.gl));
|
|
6528
6561
|
|
|
6529
6562
|
/**
|
|
6530
6563
|
* the location attributes of the shader
|
|
6531
|
-
* @public
|
|
6532
6564
|
* @type {GLint[]}
|
|
6533
|
-
* @name attributes
|
|
6534
|
-
* @memberof GLShader
|
|
6535
6565
|
*/
|
|
6536
6566
|
this.attributes = extractAttributes(this.gl, this);
|
|
6537
6567
|
|
|
6538
6568
|
|
|
6539
6569
|
/**
|
|
6540
6570
|
* a reference to the shader program (once compiled)
|
|
6541
|
-
* @public
|
|
6542
6571
|
* @type {WebGLProgram}
|
|
6543
|
-
* @name program
|
|
6544
|
-
* @memberof GLShader
|
|
6545
6572
|
*/
|
|
6546
6573
|
this.program = compileProgram(this.gl, this.vertex, this.fragment, this.attributes);
|
|
6547
6574
|
|
|
6548
6575
|
/**
|
|
6549
6576
|
* the uniforms of the shader
|
|
6550
|
-
* @public
|
|
6551
6577
|
* @type {object}
|
|
6552
|
-
* @name uniforms
|
|
6553
|
-
* @memberof GLShader
|
|
6554
6578
|
*/
|
|
6555
6579
|
this.uniforms = extractUniforms(this.gl, this);
|
|
6556
6580
|
|
|
@@ -6560,8 +6584,6 @@
|
|
|
6560
6584
|
|
|
6561
6585
|
/**
|
|
6562
6586
|
* Installs this shader program as part of current rendering state
|
|
6563
|
-
* @name bind
|
|
6564
|
-
* @memberof GLShader
|
|
6565
6587
|
*/
|
|
6566
6588
|
GLShader.prototype.bind = function bind () {
|
|
6567
6589
|
this.gl.useProgram(this.program);
|
|
@@ -6569,8 +6591,6 @@
|
|
|
6569
6591
|
|
|
6570
6592
|
/**
|
|
6571
6593
|
* returns the location of an attribute variable in this shader program
|
|
6572
|
-
* @name getAttribLocation
|
|
6573
|
-
* @memberof GLShader
|
|
6574
6594
|
* @param {string} name the name of the attribute variable whose location to get.
|
|
6575
6595
|
* @returns {GLint} number indicating the location of the variable name if found. Returns -1 otherwise
|
|
6576
6596
|
*/
|
|
@@ -6585,8 +6605,6 @@
|
|
|
6585
6605
|
|
|
6586
6606
|
/**
|
|
6587
6607
|
* Set the uniform to the given value
|
|
6588
|
-
* @name setUniform
|
|
6589
|
-
* @memberof GLShader
|
|
6590
6608
|
* @param {string} name the uniform name
|
|
6591
6609
|
* @param {object|Float32Array} value the value to assign to that uniform
|
|
6592
6610
|
* @example
|
|
@@ -6607,8 +6625,6 @@
|
|
|
6607
6625
|
|
|
6608
6626
|
/**
|
|
6609
6627
|
* activate the given vertex attribute for this shader
|
|
6610
|
-
* @name setVertexAttributes
|
|
6611
|
-
* @memberof GLShader
|
|
6612
6628
|
* @param {WebGLRenderingContext} gl the current WebGL rendering context
|
|
6613
6629
|
* @param {object[]} attributes an array of vertex attributes
|
|
6614
6630
|
* @param {number} vertexByteSize the size of a single vertex in bytes
|
|
@@ -6630,8 +6646,6 @@
|
|
|
6630
6646
|
|
|
6631
6647
|
/**
|
|
6632
6648
|
* destroy this shader objects resources (program, attributes, uniforms)
|
|
6633
|
-
* @name destroy
|
|
6634
|
-
* @memberof GLShader
|
|
6635
6649
|
*/
|
|
6636
6650
|
GLShader.prototype.destroy = function destroy () {
|
|
6637
6651
|
this.uniforms = null;
|
|
@@ -6828,44 +6842,37 @@
|
|
|
6828
6842
|
|
|
6829
6843
|
/**
|
|
6830
6844
|
* a reference to the active WebGL shader
|
|
6831
|
-
* @name activeShader
|
|
6832
|
-
* @memberof WebGLCompositor
|
|
6833
6845
|
* @type {GLShader}
|
|
6834
6846
|
*/
|
|
6835
6847
|
this.activeShader = null;
|
|
6836
6848
|
|
|
6837
6849
|
/**
|
|
6838
6850
|
* primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)
|
|
6839
|
-
* @
|
|
6840
|
-
* @see WebGLCompositor
|
|
6841
|
-
* @memberof WebGLCompositor
|
|
6851
|
+
* @type {number}
|
|
6842
6852
|
* @default gl.TRIANGLES
|
|
6843
6853
|
*/
|
|
6844
6854
|
this.mode = gl.TRIANGLES;
|
|
6845
6855
|
|
|
6846
6856
|
/**
|
|
6847
6857
|
* an array of vertex attribute properties
|
|
6848
|
-
* @name attributes
|
|
6849
6858
|
* @see WebGLCompositor.addAttribute
|
|
6850
|
-
* @
|
|
6859
|
+
* @type {Array}
|
|
6851
6860
|
*/
|
|
6852
6861
|
this.attributes = [];
|
|
6853
6862
|
|
|
6854
6863
|
/**
|
|
6855
6864
|
* the size of a single vertex in bytes
|
|
6856
6865
|
* (will automatically be calculated as attributes definitions are added)
|
|
6857
|
-
* @name vertexByteSize
|
|
6858
6866
|
* @see WebGLCompositor.addAttribute
|
|
6859
|
-
* @
|
|
6867
|
+
* @type {number}
|
|
6860
6868
|
*/
|
|
6861
6869
|
this.vertexByteSize = 0;
|
|
6862
6870
|
|
|
6863
6871
|
/**
|
|
6864
6872
|
* the size of a single vertex in floats
|
|
6865
6873
|
* (will automatically be calculated as attributes definitions are added)
|
|
6866
|
-
* @name vertexSize
|
|
6867
6874
|
* @see WebGLCompositor.addAttribute
|
|
6868
|
-
* @
|
|
6875
|
+
* @type {number}
|
|
6869
6876
|
*/
|
|
6870
6877
|
this.vertexSize = 0;
|
|
6871
6878
|
|
|
@@ -6904,8 +6911,8 @@
|
|
|
6904
6911
|
// initial viewport size
|
|
6905
6912
|
this.setViewport(
|
|
6906
6913
|
0, 0,
|
|
6907
|
-
this.renderer.
|
|
6908
|
-
this.renderer.
|
|
6914
|
+
this.renderer.getCanvas().width,
|
|
6915
|
+
this.renderer.getCanvas().height
|
|
6909
6916
|
);
|
|
6910
6917
|
|
|
6911
6918
|
// Initialize clear color
|
|
@@ -6926,8 +6933,6 @@
|
|
|
6926
6933
|
|
|
6927
6934
|
/**
|
|
6928
6935
|
* add vertex attribute property definition to the compositor
|
|
6929
|
-
* @name addAttribute
|
|
6930
|
-
* @memberof WebGLCompositor
|
|
6931
6936
|
* @param {string} name name of the attribute in the vertex shader
|
|
6932
6937
|
* @param {number} size number of components per vertex attribute. Must be 1, 2, 3, or 4.
|
|
6933
6938
|
* @param {GLenum} type data type of each component in the array
|
|
@@ -6973,8 +6978,6 @@
|
|
|
6973
6978
|
|
|
6974
6979
|
/**
|
|
6975
6980
|
* Sets the viewport
|
|
6976
|
-
* @name setViewport
|
|
6977
|
-
* @memberof WebGLCompositor
|
|
6978
6981
|
* @param {number} x x position of viewport
|
|
6979
6982
|
* @param {number} y y position of viewport
|
|
6980
6983
|
* @param {number} w width of viewport
|
|
@@ -6986,8 +6989,6 @@
|
|
|
6986
6989
|
|
|
6987
6990
|
/**
|
|
6988
6991
|
* Create a WebGL texture from an image
|
|
6989
|
-
* @name createTexture2D
|
|
6990
|
-
* @memberof WebGLCompositor
|
|
6991
6992
|
* @param {number} unit Destination texture unit
|
|
6992
6993
|
* @param {Image|HTMLCanvasElement|ImageData|Uint8Array[]|Float32Array[]} image Source image
|
|
6993
6994
|
* @param {number} filter gl.LINEAR or gl.NEAREST
|
|
@@ -7034,8 +7035,6 @@
|
|
|
7034
7035
|
|
|
7035
7036
|
/**
|
|
7036
7037
|
* delete the given WebGL texture
|
|
7037
|
-
* @name bindTexture2D
|
|
7038
|
-
* @memberof WebGLCompositor
|
|
7039
7038
|
* @param {WebGLTexture} [texture] a WebGL texture to delete
|
|
7040
7039
|
* @param {number} [unit] Texture unit to delete
|
|
7041
7040
|
*/
|
|
@@ -7046,8 +7045,6 @@
|
|
|
7046
7045
|
|
|
7047
7046
|
/**
|
|
7048
7047
|
* returns the WebGL texture associated to the given texture unit
|
|
7049
|
-
* @name bindTexture2D
|
|
7050
|
-
* @memberof WebGLCompositor
|
|
7051
7048
|
* @param {number} unit Texture unit to which a texture is bound
|
|
7052
7049
|
* @returns {WebGLTexture} texture a WebGL texture
|
|
7053
7050
|
*/
|
|
@@ -7057,8 +7054,6 @@
|
|
|
7057
7054
|
|
|
7058
7055
|
/**
|
|
7059
7056
|
* assign the given WebGL texture to the current batch
|
|
7060
|
-
* @name bindTexture2D
|
|
7061
|
-
* @memberof WebGLCompositor
|
|
7062
7057
|
* @param {WebGLTexture} texture a WebGL texture
|
|
7063
7058
|
* @param {number} unit Texture unit to which the given texture is bound
|
|
7064
7059
|
*/
|
|
@@ -7084,8 +7079,6 @@
|
|
|
7084
7079
|
|
|
7085
7080
|
/**
|
|
7086
7081
|
* unbind the given WebGL texture, forcing it to be reuploaded
|
|
7087
|
-
* @name unbindTexture2D
|
|
7088
|
-
* @memberof WebGLCompositor
|
|
7089
7082
|
* @param {WebGLTexture} [texture] a WebGL texture
|
|
7090
7083
|
* @param {number} [unit] a WebGL texture
|
|
7091
7084
|
* @returns {number} unit the unit number that was associated with the given texture
|
|
@@ -7132,8 +7125,6 @@
|
|
|
7132
7125
|
|
|
7133
7126
|
/**
|
|
7134
7127
|
* set/change the current projection matrix
|
|
7135
|
-
* @name setProjection
|
|
7136
|
-
* @memberof WebGLCompositor
|
|
7137
7128
|
* @param {Matrix3d} matrix
|
|
7138
7129
|
*/
|
|
7139
7130
|
WebGLCompositor.prototype.setProjection = function setProjection (matrix) {
|
|
@@ -7142,9 +7133,7 @@
|
|
|
7142
7133
|
|
|
7143
7134
|
/**
|
|
7144
7135
|
* Select the shader to use for compositing
|
|
7145
|
-
* @name useShader
|
|
7146
7136
|
* @see GLShader
|
|
7147
|
-
* @memberof WebGLCompositor
|
|
7148
7137
|
* @param {GLShader} shader a reference to a GLShader instance
|
|
7149
7138
|
*/
|
|
7150
7139
|
WebGLCompositor.prototype.useShader = function useShader (shader) {
|
|
@@ -7159,8 +7148,6 @@
|
|
|
7159
7148
|
|
|
7160
7149
|
/**
|
|
7161
7150
|
* Add a textured quad
|
|
7162
|
-
* @name addQuad
|
|
7163
|
-
* @memberof WebGLCompositor
|
|
7164
7151
|
* @param {TextureAtlas} texture Source texture atlas
|
|
7165
7152
|
* @param {number} x Destination x-coordinate
|
|
7166
7153
|
* @param {number} y Destination y-coordinate
|
|
@@ -7216,7 +7203,6 @@
|
|
|
7216
7203
|
/**
|
|
7217
7204
|
* Flush batched texture operations to the GPU
|
|
7218
7205
|
* @param {number} [mode=gl.TRIANGLES] the GL drawing mode
|
|
7219
|
-
* @memberof WebGLCompositor
|
|
7220
7206
|
*/
|
|
7221
7207
|
WebGLCompositor.prototype.flush = function flush (mode) {
|
|
7222
7208
|
if ( mode === void 0 ) mode = this.mode;
|
|
@@ -7244,8 +7230,6 @@
|
|
|
7244
7230
|
|
|
7245
7231
|
/**
|
|
7246
7232
|
* Draw an array of vertices
|
|
7247
|
-
* @name drawVertices
|
|
7248
|
-
* @memberof WebGLCompositor
|
|
7249
7233
|
* @param {GLenum} mode primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)
|
|
7250
7234
|
* @param {Vector2d[]} verts vertices
|
|
7251
7235
|
* @param {number} [vertexCount=verts.length] amount of points defined in the points array
|
|
@@ -7274,25 +7258,33 @@
|
|
|
7274
7258
|
};
|
|
7275
7259
|
|
|
7276
7260
|
/**
|
|
7277
|
-
*
|
|
7278
|
-
* @
|
|
7279
|
-
* @memberof WebGLCompositor
|
|
7280
|
-
* @param {number} [r=0] - the red color value used when the color buffers are cleared
|
|
7281
|
-
* @param {number} [g=0] - the green color value used when the color buffers are cleared
|
|
7282
|
-
* @param {number} [b=0] - the blue color value used when the color buffers are cleared
|
|
7283
|
-
* @param {number} [a=0] - the alpha color value used when the color buffers are cleared
|
|
7261
|
+
* Clear the frame buffer
|
|
7262
|
+
* @param {number} [alpha = 0.0] - the alpha value used when clearing the framebuffer
|
|
7284
7263
|
*/
|
|
7285
|
-
WebGLCompositor.prototype.
|
|
7286
|
-
|
|
7264
|
+
WebGLCompositor.prototype.clear = function clear (alpha) {
|
|
7265
|
+
if ( alpha === void 0 ) alpha = 0;
|
|
7266
|
+
|
|
7267
|
+
var gl = this.gl;
|
|
7268
|
+
gl.clearColor(0, 0, 0, alpha);
|
|
7269
|
+
gl.clear(gl.COLOR_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
|
|
7287
7270
|
};
|
|
7288
7271
|
|
|
7289
7272
|
/**
|
|
7290
|
-
*
|
|
7291
|
-
* @
|
|
7292
|
-
* @
|
|
7273
|
+
* Specify the color values used when clearing color buffers. The values are clamped between 0 and 1.
|
|
7274
|
+
* @param {number} [r = 0] - the red color value used when the color buffers are cleared
|
|
7275
|
+
* @param {number} [g = 0] - the green color value used when the color buffers are cleared
|
|
7276
|
+
* @param {number} [b = 0] - the blue color value used when the color buffers are cleared
|
|
7277
|
+
* @param {number} [a = 0] - the alpha color value used when the color buffers are cleared
|
|
7293
7278
|
*/
|
|
7294
|
-
WebGLCompositor.prototype.
|
|
7295
|
-
|
|
7279
|
+
WebGLCompositor.prototype.clearColor = function clearColor (r, g, b, a) {
|
|
7280
|
+
if ( r === void 0 ) r = 0;
|
|
7281
|
+
if ( g === void 0 ) g = 0;
|
|
7282
|
+
if ( b === void 0 ) b = 0;
|
|
7283
|
+
if ( a === void 0 ) a = 0;
|
|
7284
|
+
|
|
7285
|
+
var gl = this.gl;
|
|
7286
|
+
gl.clearColor(r, g, b, a);
|
|
7287
|
+
gl.clear(gl.COLOR_BUFFER_BIT);
|
|
7296
7288
|
};
|
|
7297
7289
|
|
|
7298
7290
|
var earcut$1 = {exports: {}};
|
|
@@ -9590,17 +9582,18 @@
|
|
|
9590
9582
|
* add the given point to the bounds definition.
|
|
9591
9583
|
* @name addPoint
|
|
9592
9584
|
* @memberof Bounds
|
|
9593
|
-
* @param {Vector2d}
|
|
9594
|
-
* @param {Matrix2d} [m] an optional transform to apply to the given point
|
|
9585
|
+
* @param {Vector2d|Point} point the point to be added to the bounds
|
|
9586
|
+
* @param {Matrix2d} [m] an optional transform to apply to the given point (only if the given point is a vector)
|
|
9595
9587
|
*/
|
|
9596
|
-
Bounds.prototype.addPoint = function addPoint (
|
|
9597
|
-
if (typeof m !== "undefined") {
|
|
9598
|
-
|
|
9588
|
+
Bounds.prototype.addPoint = function addPoint (point, m) {
|
|
9589
|
+
if ((typeof m !== "undefined") && (typeof point.rotate === "function")) {
|
|
9590
|
+
// only Vectors object have a rotate function
|
|
9591
|
+
point = m.apply(point);
|
|
9599
9592
|
}
|
|
9600
|
-
this.min.x = Math.min(this.min.x,
|
|
9601
|
-
this.max.x = Math.max(this.max.x,
|
|
9602
|
-
this.min.y = Math.min(this.min.y,
|
|
9603
|
-
this.max.y = Math.max(this.max.y,
|
|
9593
|
+
this.min.x = Math.min(this.min.x, point.x);
|
|
9594
|
+
this.max.x = Math.max(this.max.x, point.x);
|
|
9595
|
+
this.min.y = Math.min(this.min.y, point.y);
|
|
9596
|
+
this.max.y = Math.max(this.max.y, point.y);
|
|
9604
9597
|
};
|
|
9605
9598
|
|
|
9606
9599
|
/**
|
|
@@ -10091,6 +10084,93 @@
|
|
|
10091
10084
|
this.arcTo(x, y, x + radius, y, radius);
|
|
10092
10085
|
};
|
|
10093
10086
|
|
|
10087
|
+
/**
|
|
10088
|
+
* @classdesc
|
|
10089
|
+
* represents a point in a 2d space
|
|
10090
|
+
*/
|
|
10091
|
+
var Point = function Point(x, y) {
|
|
10092
|
+
if ( x === void 0 ) x = 0;
|
|
10093
|
+
if ( y === void 0 ) y = 0;
|
|
10094
|
+
|
|
10095
|
+
/**
|
|
10096
|
+
* the position of the point on the horizontal axis
|
|
10097
|
+
* @public
|
|
10098
|
+
* @type {Number}
|
|
10099
|
+
* @default 0
|
|
10100
|
+
*/
|
|
10101
|
+
this.x = x;
|
|
10102
|
+
|
|
10103
|
+
/**
|
|
10104
|
+
* the position of the point on the vertical axis
|
|
10105
|
+
* @public
|
|
10106
|
+
* @type {Number}
|
|
10107
|
+
* @default 0
|
|
10108
|
+
*/
|
|
10109
|
+
this.y = y;
|
|
10110
|
+
};
|
|
10111
|
+
|
|
10112
|
+
/** @ignore */
|
|
10113
|
+
Point.prototype.onResetEvent = function onResetEvent (x, y) {
|
|
10114
|
+
if ( x === void 0 ) x = 0;
|
|
10115
|
+
if ( y === void 0 ) y = 0;
|
|
10116
|
+
|
|
10117
|
+
this.set(x, y);
|
|
10118
|
+
};
|
|
10119
|
+
|
|
10120
|
+
/**
|
|
10121
|
+
* set the Point x and y properties to the given values
|
|
10122
|
+
* @param {number} x
|
|
10123
|
+
* @param {number} y
|
|
10124
|
+
* @returns {Point} Reference to this object for method chaining
|
|
10125
|
+
*/
|
|
10126
|
+
Point.prototype.set = function set (x, y) {
|
|
10127
|
+
if ( x === void 0 ) x = 0;
|
|
10128
|
+
if ( y === void 0 ) y = 0;
|
|
10129
|
+
|
|
10130
|
+
this.x = x;
|
|
10131
|
+
this.y = y;
|
|
10132
|
+
return this;
|
|
10133
|
+
};
|
|
10134
|
+
|
|
10135
|
+
/**
|
|
10136
|
+
* return true if the two points are the same
|
|
10137
|
+
* @name equals
|
|
10138
|
+
* @memberof Point
|
|
10139
|
+
* @method
|
|
10140
|
+
* @param {Point} point
|
|
10141
|
+
* @returns {boolean}
|
|
10142
|
+
*/
|
|
10143
|
+
/**
|
|
10144
|
+
* return true if this point is equal to the given values
|
|
10145
|
+
* @name equals
|
|
10146
|
+
* @memberof Point
|
|
10147
|
+
* @param {number} x
|
|
10148
|
+
* @param {number} y
|
|
10149
|
+
* @returns {boolean}
|
|
10150
|
+
*/
|
|
10151
|
+
Point.prototype.equals = function equals () {
|
|
10152
|
+
var _x, _y;
|
|
10153
|
+
if (arguments.length === 2) {
|
|
10154
|
+
// x, y
|
|
10155
|
+
_x = arguments[0];
|
|
10156
|
+
_y = arguments[1];
|
|
10157
|
+
} else {
|
|
10158
|
+
// point
|
|
10159
|
+
_x = arguments[0].x;
|
|
10160
|
+
_y = arguments[0].y;
|
|
10161
|
+
}
|
|
10162
|
+
return ((this.x === _x) && (this.y === _y));
|
|
10163
|
+
};
|
|
10164
|
+
|
|
10165
|
+
/**
|
|
10166
|
+
* clone this Point
|
|
10167
|
+
* @name clone
|
|
10168
|
+
* @returns {Point} new Point
|
|
10169
|
+
*/
|
|
10170
|
+
Point.prototype.clone = function clone () {
|
|
10171
|
+
return new Point(this.x, this.y);
|
|
10172
|
+
};
|
|
10173
|
+
|
|
10094
10174
|
/**
|
|
10095
10175
|
* @classdesc
|
|
10096
10176
|
* a base renderer object
|
|
@@ -10099,26 +10179,20 @@
|
|
|
10099
10179
|
/**
|
|
10100
10180
|
* The given constructor options
|
|
10101
10181
|
* @public
|
|
10102
|
-
* @name settings
|
|
10103
|
-
* @memberof Renderer#
|
|
10104
10182
|
* @type {object}
|
|
10105
10183
|
*/
|
|
10106
10184
|
this.settings = options;
|
|
10107
10185
|
|
|
10108
10186
|
/**
|
|
10109
10187
|
* true if the current rendering context is valid
|
|
10110
|
-
* @name isContextValid
|
|
10111
|
-
* @memberof Renderer#
|
|
10112
10188
|
* @default true
|
|
10113
|
-
* type {boolean}
|
|
10189
|
+
* @type {boolean}
|
|
10114
10190
|
*/
|
|
10115
10191
|
this.isContextValid = true;
|
|
10116
10192
|
|
|
10117
10193
|
/**
|
|
10118
10194
|
* The Path2D instance used by the renderer to draw primitives
|
|
10119
|
-
* @name path2D
|
|
10120
10195
|
* @type {Path2D}
|
|
10121
|
-
* @memberof Renderer#
|
|
10122
10196
|
*/
|
|
10123
10197
|
this.path2D = new Path2D();
|
|
10124
10198
|
|
|
@@ -10147,13 +10221,9 @@
|
|
|
10147
10221
|
} else if (typeof this.settings.canvas !== "undefined") {
|
|
10148
10222
|
this.canvas = this.settings.canvas;
|
|
10149
10223
|
} else {
|
|
10150
|
-
this.canvas = createCanvas(this.settings.
|
|
10224
|
+
this.canvas = createCanvas(this.settings.width, this.settings.height);
|
|
10151
10225
|
}
|
|
10152
10226
|
|
|
10153
|
-
// canvas object and context
|
|
10154
|
-
this.backBufferCanvas = this.canvas;
|
|
10155
|
-
this.context = null;
|
|
10156
|
-
|
|
10157
10227
|
// global color
|
|
10158
10228
|
this.currentColor = new Color(0, 0, 0, 1.0);
|
|
10159
10229
|
|
|
@@ -10174,15 +10244,16 @@
|
|
|
10174
10244
|
|
|
10175
10245
|
/**
|
|
10176
10246
|
* prepare the framebuffer for drawing a new frame
|
|
10177
|
-
* @name clear
|
|
10178
|
-
* @memberof Renderer
|
|
10179
10247
|
*/
|
|
10180
10248
|
Renderer.prototype.clear = function clear () {};
|
|
10181
10249
|
|
|
10250
|
+
/**
|
|
10251
|
+
* render the main framebuffer on screen
|
|
10252
|
+
*/
|
|
10253
|
+
Renderer.prototype.flush = function flush () {};
|
|
10254
|
+
|
|
10182
10255
|
/**
|
|
10183
10256
|
* Reset context state
|
|
10184
|
-
* @name reset
|
|
10185
|
-
* @memberof Renderer
|
|
10186
10257
|
*/
|
|
10187
10258
|
Renderer.prototype.reset = function reset () {
|
|
10188
10259
|
this.resetTransform();
|
|
@@ -10192,46 +10263,30 @@
|
|
|
10192
10263
|
this.cache.clear();
|
|
10193
10264
|
this.currentScissor[0] = 0;
|
|
10194
10265
|
this.currentScissor[1] = 0;
|
|
10195
|
-
this.currentScissor[2] = this.
|
|
10196
|
-
this.currentScissor[3] = this.
|
|
10266
|
+
this.currentScissor[2] = this.getCanvas().width;
|
|
10267
|
+
this.currentScissor[3] = this.getCanvas().height;
|
|
10197
10268
|
this.clearMask();
|
|
10198
10269
|
};
|
|
10199
10270
|
|
|
10200
10271
|
/**
|
|
10201
|
-
* return a reference to the
|
|
10202
|
-
* @name getCanvas
|
|
10203
|
-
* @memberof Renderer
|
|
10272
|
+
* return a reference to the canvas which this renderer draws to
|
|
10204
10273
|
* @returns {HTMLCanvasElement}
|
|
10205
10274
|
*/
|
|
10206
10275
|
Renderer.prototype.getCanvas = function getCanvas () {
|
|
10207
|
-
return this.backBufferCanvas;
|
|
10208
|
-
};
|
|
10209
|
-
|
|
10210
|
-
/**
|
|
10211
|
-
* return a reference to the screen canvas
|
|
10212
|
-
* @name getScreenCanvas
|
|
10213
|
-
* @memberof Renderer
|
|
10214
|
-
* @returns {HTMLCanvasElement}
|
|
10215
|
-
*/
|
|
10216
|
-
Renderer.prototype.getScreenCanvas = function getScreenCanvas () {
|
|
10217
10276
|
return this.canvas;
|
|
10218
10277
|
};
|
|
10219
10278
|
|
|
10279
|
+
|
|
10220
10280
|
/**
|
|
10221
|
-
* return a reference to
|
|
10222
|
-
*
|
|
10223
|
-
* @name getScreenContext
|
|
10224
|
-
* @memberof Renderer
|
|
10225
|
-
* @returns {CanvasRenderingContext2D}
|
|
10281
|
+
* return a reference to this renderer canvas corresponding Context
|
|
10282
|
+
* @returns {CanvasRenderingContext2D|WebGLRenderingContext}
|
|
10226
10283
|
*/
|
|
10227
|
-
Renderer.prototype.
|
|
10284
|
+
Renderer.prototype.getContext = function getContext () {
|
|
10228
10285
|
return this.context;
|
|
10229
10286
|
};
|
|
10230
10287
|
|
|
10231
10288
|
/**
|
|
10232
10289
|
* returns the current blend mode for this renderer
|
|
10233
|
-
* @name getBlendMode
|
|
10234
|
-
* @memberof Renderer
|
|
10235
10290
|
* @returns {string} blend mode
|
|
10236
10291
|
*/
|
|
10237
10292
|
Renderer.prototype.getBlendMode = function getBlendMode () {
|
|
@@ -10241,8 +10296,6 @@
|
|
|
10241
10296
|
/**
|
|
10242
10297
|
* Returns the 2D Context object of the given Canvas<br>
|
|
10243
10298
|
* Also configures anti-aliasing and blend modes based on constructor options.
|
|
10244
|
-
* @name getContext2d
|
|
10245
|
-
* @memberof Renderer
|
|
10246
10299
|
* @param {HTMLCanvasElement} canvas
|
|
10247
10300
|
* @param {boolean} [transparent=true] use false to disable transparency
|
|
10248
10301
|
* @returns {CanvasRenderingContext2D}
|
|
@@ -10278,28 +10331,22 @@
|
|
|
10278
10331
|
|
|
10279
10332
|
/**
|
|
10280
10333
|
* return the width of the system Canvas
|
|
10281
|
-
* @name getWidth
|
|
10282
|
-
* @memberof Renderer
|
|
10283
10334
|
* @returns {number}
|
|
10284
10335
|
*/
|
|
10285
10336
|
Renderer.prototype.getWidth = function getWidth () {
|
|
10286
|
-
return this.
|
|
10337
|
+
return this.getCanvas().width;
|
|
10287
10338
|
};
|
|
10288
10339
|
|
|
10289
10340
|
/**
|
|
10290
10341
|
* return the height of the system Canvas
|
|
10291
|
-
* @name getHeight
|
|
10292
|
-
* @memberof Renderer
|
|
10293
10342
|
* @returns {number} height of the system Canvas
|
|
10294
10343
|
*/
|
|
10295
10344
|
Renderer.prototype.getHeight = function getHeight () {
|
|
10296
|
-
return this.
|
|
10345
|
+
return this.getCanvas().height;
|
|
10297
10346
|
};
|
|
10298
10347
|
|
|
10299
10348
|
/**
|
|
10300
10349
|
* get the current fill & stroke style color.
|
|
10301
|
-
* @name getColor
|
|
10302
|
-
* @memberof Renderer
|
|
10303
10350
|
* @returns {Color} current global color
|
|
10304
10351
|
*/
|
|
10305
10352
|
Renderer.prototype.getColor = function getColor () {
|
|
@@ -10308,8 +10355,6 @@
|
|
|
10308
10355
|
|
|
10309
10356
|
/**
|
|
10310
10357
|
* return the current global alpha
|
|
10311
|
-
* @name globalAlpha
|
|
10312
|
-
* @memberof Renderer
|
|
10313
10358
|
* @returns {number}
|
|
10314
10359
|
*/
|
|
10315
10360
|
Renderer.prototype.globalAlpha = function globalAlpha () {
|
|
@@ -10318,8 +10363,6 @@
|
|
|
10318
10363
|
|
|
10319
10364
|
/**
|
|
10320
10365
|
* check if the given rect or bounds overlaps with the renderer screen coordinates
|
|
10321
|
-
* @name overlaps
|
|
10322
|
-
* @memberof Renderer
|
|
10323
10366
|
* @param {Rect|Bounds} bounds
|
|
10324
10367
|
* @returns {boolean} true if overlaps
|
|
10325
10368
|
*/
|
|
@@ -10333,15 +10376,14 @@
|
|
|
10333
10376
|
|
|
10334
10377
|
/**
|
|
10335
10378
|
* resizes the system canvas
|
|
10336
|
-
* @name resize
|
|
10337
|
-
* @memberof Renderer
|
|
10338
10379
|
* @param {number} width new width of the canvas
|
|
10339
10380
|
* @param {number} height new height of the canvas
|
|
10340
10381
|
*/
|
|
10341
10382
|
Renderer.prototype.resize = function resize (width, height) {
|
|
10342
|
-
|
|
10343
|
-
|
|
10344
|
-
|
|
10383
|
+
var canvas = this.getCanvas();
|
|
10384
|
+
if (width !== canvas.width || height !== canvas.height) {
|
|
10385
|
+
canvas.width = width;
|
|
10386
|
+
canvas.height = height;
|
|
10345
10387
|
this.currentScissor[0] = 0;
|
|
10346
10388
|
this.currentScissor[1] = 0;
|
|
10347
10389
|
this.currentScissor[2] = width;
|
|
@@ -10353,8 +10395,6 @@
|
|
|
10353
10395
|
|
|
10354
10396
|
/**
|
|
10355
10397
|
* enable/disable image smoothing (scaling interpolation) for the given context
|
|
10356
|
-
* @name setAntiAlias
|
|
10357
|
-
* @memberof Renderer
|
|
10358
10398
|
* @param {CanvasRenderingContext2D} context
|
|
10359
10399
|
* @param {boolean} [enable=false]
|
|
10360
10400
|
*/
|
|
@@ -10382,8 +10422,6 @@
|
|
|
10382
10422
|
|
|
10383
10423
|
/**
|
|
10384
10424
|
* set/change the current projection matrix (WebGL only)
|
|
10385
|
-
* @name setProjection
|
|
10386
|
-
* @memberof Renderer
|
|
10387
10425
|
* @param {Matrix3d} matrix
|
|
10388
10426
|
*/
|
|
10389
10427
|
Renderer.prototype.setProjection = function setProjection (matrix) {
|
|
@@ -10392,8 +10430,6 @@
|
|
|
10392
10430
|
|
|
10393
10431
|
/**
|
|
10394
10432
|
* stroke the given shape
|
|
10395
|
-
* @name stroke
|
|
10396
|
-
* @memberof Renderer
|
|
10397
10433
|
* @param {Rect|RoundRect|Polygon|Line|Ellipse} shape a shape object to stroke
|
|
10398
10434
|
* @param {boolean} [fill=false] fill the shape with the current color if true
|
|
10399
10435
|
*/
|
|
@@ -10420,6 +10456,10 @@
|
|
|
10420
10456
|
);
|
|
10421
10457
|
return;
|
|
10422
10458
|
}
|
|
10459
|
+
if (shape instanceof Point) {
|
|
10460
|
+
this.strokePoint(shape.x, shape.y);
|
|
10461
|
+
return;
|
|
10462
|
+
}
|
|
10423
10463
|
throw new Error("Invalid geometry for fill/stroke");
|
|
10424
10464
|
};
|
|
10425
10465
|
|
|
@@ -10435,8 +10475,6 @@
|
|
|
10435
10475
|
|
|
10436
10476
|
/**
|
|
10437
10477
|
* tint the given image or canvas using the given color
|
|
10438
|
-
* @name tint
|
|
10439
|
-
* @memberof Renderer
|
|
10440
10478
|
* @param {HTMLImageElement|HTMLCanvasElement|OffscreenCanvas} src the source image to be tinted
|
|
10441
10479
|
* @param {Color|string} color the color that will be used to tint the image
|
|
10442
10480
|
* @param {string} [mode="multiply"] the composition mode used to tint the image
|
|
@@ -10465,8 +10503,6 @@
|
|
|
10465
10503
|
* A mask limits rendering elements to the shape and position of the given mask object.
|
|
10466
10504
|
* So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
|
|
10467
10505
|
* Mask are not preserved through renderer context save and restore.
|
|
10468
|
-
* @name setMask
|
|
10469
|
-
* @memberof Renderer
|
|
10470
10506
|
* @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
|
|
10471
10507
|
* @param {boolean} [invert=false] either the given shape should define what is visible (default) or the opposite
|
|
10472
10508
|
*/
|
|
@@ -10475,16 +10511,12 @@
|
|
|
10475
10511
|
|
|
10476
10512
|
/**
|
|
10477
10513
|
* disable (remove) the rendering mask set through setMask.
|
|
10478
|
-
* @name clearMask
|
|
10479
10514
|
* @see Renderer#setMask
|
|
10480
|
-
* @memberof Renderer
|
|
10481
10515
|
*/
|
|
10482
10516
|
Renderer.prototype.clearMask = function clearMask () {};
|
|
10483
10517
|
|
|
10484
10518
|
/**
|
|
10485
10519
|
* set a coloring tint for sprite based renderables
|
|
10486
|
-
* @name setTint
|
|
10487
|
-
* @memberof Renderer
|
|
10488
10520
|
* @param {Color} tint the tint color
|
|
10489
10521
|
* @param {number} [alpha] an alpha value to be applied to the tint
|
|
10490
10522
|
*/
|
|
@@ -10498,9 +10530,7 @@
|
|
|
10498
10530
|
|
|
10499
10531
|
/**
|
|
10500
10532
|
* clear the rendering tint set through setTint.
|
|
10501
|
-
* @name clearTint
|
|
10502
10533
|
* @see Renderer#setTint
|
|
10503
|
-
* @memberof Renderer
|
|
10504
10534
|
*/
|
|
10505
10535
|
Renderer.prototype.clearTint = function clearTint () {
|
|
10506
10536
|
// reset to default
|
|
@@ -14678,8 +14708,32 @@
|
|
|
14678
14708
|
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
14679
14709
|
*/
|
|
14680
14710
|
ObservableVector2d.prototype.lerp = function lerp (v, alpha) {
|
|
14681
|
-
this.
|
|
14682
|
-
|
|
14711
|
+
return this._set(
|
|
14712
|
+
this._x + ( v.x - this._x ) * alpha,
|
|
14713
|
+
this._y + ( v.y - this._y ) * alpha
|
|
14714
|
+
);
|
|
14715
|
+
};
|
|
14716
|
+
|
|
14717
|
+
/**
|
|
14718
|
+
* interpolate the position of this vector towards the given one while nsure that the distance never exceeds the given step.
|
|
14719
|
+
* @name moveTowards
|
|
14720
|
+
* @memberof ObservableVector2d
|
|
14721
|
+
* @param {Vector2d|ObservableVector2d} target
|
|
14722
|
+
* @param {number} step the maximum step per iteration (Negative values will push the vector away from the target)
|
|
14723
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
14724
|
+
*/
|
|
14725
|
+
ObservableVector2d.prototype.moveTowards = function moveTowards (target, step) {
|
|
14726
|
+
var angle = Math.atan2(target.y - this._y, target.x - this._x);
|
|
14727
|
+
|
|
14728
|
+
var distance = this.distance(target);
|
|
14729
|
+
|
|
14730
|
+
if (distance === 0 || (step >= 0 && distance <= step * step)) {
|
|
14731
|
+
return target;
|
|
14732
|
+
}
|
|
14733
|
+
|
|
14734
|
+
this._x += Math.cos(angle) * step;
|
|
14735
|
+
this._y += Math.sin(angle) * step;
|
|
14736
|
+
|
|
14683
14737
|
return this;
|
|
14684
14738
|
};
|
|
14685
14739
|
|
|
@@ -15192,6 +15246,32 @@
|
|
|
15192
15246
|
return this;
|
|
15193
15247
|
};
|
|
15194
15248
|
|
|
15249
|
+
/**
|
|
15250
|
+
* interpolate the position of this vector on the x and y axis towards the given one by the given maximum step.
|
|
15251
|
+
* @name moveTowards
|
|
15252
|
+
* @memberof Vector3d
|
|
15253
|
+
* @param {Vector2d|Vector3d} target
|
|
15254
|
+
* @param {number} step the maximum step per iteration (Negative values will push the vector away from the target)
|
|
15255
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
15256
|
+
*/
|
|
15257
|
+
Vector3d.prototype.moveTowards = function moveTowards (target, step) {
|
|
15258
|
+
var angle = Math.atan2(target.y - this.y, target.x - this.x);
|
|
15259
|
+
|
|
15260
|
+
var dx = this.x - target.x;
|
|
15261
|
+
var dy = this.y - target.y;
|
|
15262
|
+
|
|
15263
|
+
var distance = Math.sqrt(dx * dx + dy * dy);
|
|
15264
|
+
|
|
15265
|
+
if (distance === 0 || (step >= 0 && distance <= step * step)) {
|
|
15266
|
+
return target;
|
|
15267
|
+
}
|
|
15268
|
+
|
|
15269
|
+
this.x += Math.cos(angle) * step;
|
|
15270
|
+
this.y += Math.sin(angle) * step;
|
|
15271
|
+
|
|
15272
|
+
return this;
|
|
15273
|
+
};
|
|
15274
|
+
|
|
15195
15275
|
/**
|
|
15196
15276
|
* return the distance between this vector and the passed one
|
|
15197
15277
|
* @name distance
|
|
@@ -15733,10 +15813,38 @@
|
|
|
15733
15813
|
* @returns {ObservableVector3d} Reference to this object for method chaining
|
|
15734
15814
|
*/
|
|
15735
15815
|
ObservableVector3d.prototype.lerp = function lerp (v, alpha) {
|
|
15736
|
-
this.
|
|
15737
|
-
|
|
15738
|
-
|
|
15739
|
-
|
|
15816
|
+
return this._set(
|
|
15817
|
+
this._x + ( v.x - this._x ) * alpha,
|
|
15818
|
+
this._y + ( v.y - this._y ) * alpha,
|
|
15819
|
+
this._z + ( v.z - this._z ) * alpha
|
|
15820
|
+
);
|
|
15821
|
+
};
|
|
15822
|
+
|
|
15823
|
+
/**
|
|
15824
|
+
* interpolate the position of this vector on the x and y axis towards the given one while ensure that the distance never exceeds the given step.
|
|
15825
|
+
* @name moveTowards
|
|
15826
|
+
* @memberof ObservableVector3d
|
|
15827
|
+
* @param {Vector2d|ObservableVector2d|Vector3d|ObservableVector3d} target
|
|
15828
|
+
* @param {number} step the maximum step per iteration (Negative values will push the vector away from the target)
|
|
15829
|
+
* @returns {ObservableVector3d} Reference to this object for method chaining
|
|
15830
|
+
*/
|
|
15831
|
+
ObservableVector3d.prototype.moveTowards = function moveTowards (target, step) {
|
|
15832
|
+
var angle = Math.atan2(target.y - this._y, target.x - this._x);
|
|
15833
|
+
|
|
15834
|
+
var dx = this._x - target.x;
|
|
15835
|
+
var dy = this._y - target.y;
|
|
15836
|
+
|
|
15837
|
+
var distance = Math.sqrt(dx * dx + dy * dy);
|
|
15838
|
+
|
|
15839
|
+
if (distance === 0 || (step >= 0 && distance <= step * step)) {
|
|
15840
|
+
return target;
|
|
15841
|
+
}
|
|
15842
|
+
|
|
15843
|
+
return this._set(
|
|
15844
|
+
this._x + Math.cos(angle) * step,
|
|
15845
|
+
this._y + Math.sin(angle) * step,
|
|
15846
|
+
this._z
|
|
15847
|
+
);
|
|
15740
15848
|
};
|
|
15741
15849
|
|
|
15742
15850
|
/**
|
|
@@ -16750,7 +16858,7 @@
|
|
|
16750
16858
|
|
|
16751
16859
|
if (pointerEventTarget === null) {
|
|
16752
16860
|
// default pointer event target
|
|
16753
|
-
pointerEventTarget = renderer.
|
|
16861
|
+
pointerEventTarget = renderer.getCanvas();
|
|
16754
16862
|
}
|
|
16755
16863
|
|
|
16756
16864
|
if (pointerEvent) {
|
|
@@ -17181,7 +17289,7 @@
|
|
|
17181
17289
|
*/
|
|
17182
17290
|
function globalToLocal(x, y, v) {
|
|
17183
17291
|
v = v || pool.pull("Vector2d");
|
|
17184
|
-
var rect = getElementBounds(renderer.
|
|
17292
|
+
var rect = getElementBounds(renderer.getCanvas());
|
|
17185
17293
|
var pixelRatio = globalThis.devicePixelRatio || 1;
|
|
17186
17294
|
x -= rect.left + (globalThis.pageXOffset || 0);
|
|
17187
17295
|
y -= rect.top + (globalThis.pageYOffset || 0);
|
|
@@ -17978,21 +18086,14 @@
|
|
|
17978
18086
|
|
|
17979
18087
|
/**
|
|
17980
18088
|
* If true then physic collision and input events will not impact this renderable
|
|
17981
|
-
* @public
|
|
17982
18089
|
* @type {boolean}
|
|
17983
18090
|
* @default true
|
|
17984
|
-
* @name isKinematic
|
|
17985
|
-
* @memberof Renderable
|
|
17986
18091
|
*/
|
|
17987
18092
|
this.isKinematic = true;
|
|
17988
18093
|
|
|
17989
18094
|
/**
|
|
17990
18095
|
* the renderable physic body
|
|
17991
|
-
* @public
|
|
17992
18096
|
* @type {Body}
|
|
17993
|
-
* @see Body
|
|
17994
|
-
* @name body
|
|
17995
|
-
* @memberof Renderable#
|
|
17996
18097
|
* @example
|
|
17997
18098
|
* // define a new Player Class
|
|
17998
18099
|
* class PlayerEntity extends me.Sprite {
|
|
@@ -18030,10 +18131,7 @@
|
|
|
18030
18131
|
if (typeof this.currentTransform === "undefined") {
|
|
18031
18132
|
/**
|
|
18032
18133
|
* the renderable default transformation matrix
|
|
18033
|
-
* @public
|
|
18034
18134
|
* @type {Matrix2d}
|
|
18035
|
-
* @name currentTransform
|
|
18036
|
-
* @memberof Renderable#
|
|
18037
18135
|
*/
|
|
18038
18136
|
this.currentTransform = pool.pull("Matrix2d");
|
|
18039
18137
|
}
|
|
@@ -18043,20 +18141,14 @@
|
|
|
18043
18141
|
* (G)ame (U)nique (Id)entifier" <br>
|
|
18044
18142
|
* a GUID will be allocated for any renderable object added <br>
|
|
18045
18143
|
* to an object container (including the `me.game.world` container)
|
|
18046
|
-
* @public
|
|
18047
18144
|
* @type {string}
|
|
18048
|
-
* @name GUID
|
|
18049
|
-
* @memberof Renderable
|
|
18050
18145
|
*/
|
|
18051
18146
|
this.GUID = undefined;
|
|
18052
18147
|
|
|
18053
18148
|
/**
|
|
18054
18149
|
* an event handler that is called when the renderable leave or enter a camera viewport
|
|
18055
|
-
* @public
|
|
18056
18150
|
* @type {Function}
|
|
18057
18151
|
* @default undefined
|
|
18058
|
-
* @name onVisibilityChange
|
|
18059
|
-
* @memberof Renderable#
|
|
18060
18152
|
* @example
|
|
18061
18153
|
* this.onVisibilityChange = function(inViewport) {
|
|
18062
18154
|
* if (inViewport === true) {
|
|
@@ -18068,42 +18160,30 @@
|
|
|
18068
18160
|
|
|
18069
18161
|
/**
|
|
18070
18162
|
* Whether the renderable object will always update, even when outside of the viewport<br>
|
|
18071
|
-
* @public
|
|
18072
18163
|
* @type {boolean}
|
|
18073
18164
|
* @default false
|
|
18074
|
-
* @name alwaysUpdate
|
|
18075
|
-
* @memberof Renderable
|
|
18076
18165
|
*/
|
|
18077
18166
|
this.alwaysUpdate = false;
|
|
18078
18167
|
|
|
18079
18168
|
/**
|
|
18080
18169
|
* Whether to update this object when the game is paused.
|
|
18081
|
-
* @public
|
|
18082
18170
|
* @type {boolean}
|
|
18083
18171
|
* @default false
|
|
18084
|
-
* @name updateWhenPaused
|
|
18085
|
-
* @memberof Renderable
|
|
18086
18172
|
*/
|
|
18087
18173
|
this.updateWhenPaused = false;
|
|
18088
18174
|
|
|
18089
18175
|
/**
|
|
18090
18176
|
* make the renderable object persistent over level changes<br>
|
|
18091
|
-
* @public
|
|
18092
18177
|
* @type {boolean}
|
|
18093
18178
|
* @default false
|
|
18094
|
-
* @name isPersistent
|
|
18095
|
-
* @memberof Renderable
|
|
18096
18179
|
*/
|
|
18097
18180
|
this.isPersistent = false;
|
|
18098
18181
|
|
|
18099
18182
|
/**
|
|
18100
18183
|
* If true, this renderable will be rendered using screen coordinates,
|
|
18101
18184
|
* as opposed to world coordinates. Use this, for example, to define UI elements.
|
|
18102
|
-
* @public
|
|
18103
18185
|
* @type {boolean}
|
|
18104
18186
|
* @default false
|
|
18105
|
-
* @name floating
|
|
18106
|
-
* @memberof Renderable
|
|
18107
18187
|
*/
|
|
18108
18188
|
this.floating = false;
|
|
18109
18189
|
|
|
@@ -18118,11 +18198,8 @@
|
|
|
18118
18198
|
* <br>
|
|
18119
18199
|
* <i><b>Note:</b> Object created through Tiled will have their anchorPoint set to (0, 0) to match Tiled Level editor implementation.
|
|
18120
18200
|
* To specify a value through Tiled, use a json expression like `json:{"x":0.5,"y":0.5}`. </i>
|
|
18121
|
-
* @public
|
|
18122
18201
|
* @type {ObservableVector2d}
|
|
18123
18202
|
* @default <0.5,0.5>
|
|
18124
|
-
* @name anchorPoint
|
|
18125
|
-
* @memberof Renderable#
|
|
18126
18203
|
*/
|
|
18127
18204
|
this.anchorPoint = pool.pull("ObservableVector2d", 0.5, 0.5, { onUpdate: this.onAnchorUpdate, scope: this });
|
|
18128
18205
|
}
|
|
@@ -18130,11 +18207,8 @@
|
|
|
18130
18207
|
/**
|
|
18131
18208
|
* When enabled, an object container will automatically apply
|
|
18132
18209
|
* any defined transformation before calling the child draw method.
|
|
18133
|
-
* @public
|
|
18134
18210
|
* @type {boolean}
|
|
18135
18211
|
* @default true
|
|
18136
|
-
* @name autoTransform
|
|
18137
|
-
* @memberof Renderable
|
|
18138
18212
|
* @example
|
|
18139
18213
|
* // enable "automatic" transformation when the object is activated
|
|
18140
18214
|
* onActivateEvent: function () {
|
|
@@ -18154,30 +18228,23 @@
|
|
|
18154
18228
|
* Set to zero if you do not wish an object to be drawn
|
|
18155
18229
|
* @see Renderable#setOpacity
|
|
18156
18230
|
* @see Renderable#getOpacity
|
|
18157
|
-
* @public
|
|
18158
18231
|
* @type {number}
|
|
18159
18232
|
* @default 1.0
|
|
18160
|
-
* @name Renderable#alpha
|
|
18161
18233
|
*/
|
|
18162
18234
|
this.alpha = 1.0;
|
|
18163
18235
|
|
|
18164
18236
|
/**
|
|
18165
18237
|
* a reference to the parent object that contains this renderable
|
|
18166
|
-
* @public
|
|
18167
18238
|
* @type {Container|Entity}
|
|
18168
18239
|
* @default undefined
|
|
18169
|
-
* @name Renderable#ancestor
|
|
18170
18240
|
*/
|
|
18171
18241
|
this.ancestor = undefined;
|
|
18172
18242
|
|
|
18173
18243
|
/**
|
|
18174
18244
|
* A mask limits rendering elements to the shape and position of the given mask object.
|
|
18175
18245
|
* So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
|
|
18176
|
-
* @public
|
|
18177
18246
|
* @type {Rect|RoundRect|Polygon|Line|Ellipse}
|
|
18178
|
-
* @name mask
|
|
18179
18247
|
* @default undefined
|
|
18180
|
-
* @memberof Renderable#
|
|
18181
18248
|
* @example
|
|
18182
18249
|
* // apply a mask in the shape of a Star
|
|
18183
18250
|
* myNPCSprite.mask = new me.Polygon(myNPCSprite.width / 2, 0, [
|
|
@@ -18196,40 +18263,19 @@
|
|
|
18196
18263
|
*/
|
|
18197
18264
|
this.mask = undefined;
|
|
18198
18265
|
|
|
18199
|
-
/**
|
|
18200
|
-
* define a tint for this renderable. a (255, 255, 255) r, g, b value will remove the tint effect.
|
|
18201
|
-
* @public
|
|
18202
|
-
* @type {Color}
|
|
18203
|
-
* @name tint
|
|
18204
|
-
* @default (255, 255, 255)
|
|
18205
|
-
* @memberof Renderable#
|
|
18206
|
-
* @example
|
|
18207
|
-
* // add a red tint to this renderable
|
|
18208
|
-
* this.tint.setColor(255, 128, 128);
|
|
18209
|
-
* // remove the tint
|
|
18210
|
-
* this.tint.setColor(255, 255, 255);
|
|
18211
|
-
*/
|
|
18212
|
-
this.tint = pool.pull("Color", 255, 255, 255, 1.0);
|
|
18213
|
-
|
|
18214
18266
|
/**
|
|
18215
18267
|
* the blend mode to be applied to this renderable (see renderer setBlendMode for available blend mode)
|
|
18216
|
-
* @public
|
|
18217
18268
|
* @type {string}
|
|
18218
|
-
* @name blendMode
|
|
18219
18269
|
* @default "normal"
|
|
18220
18270
|
* @see CanvasRenderer#setBlendMode
|
|
18221
18271
|
* @see WebGLRenderer#setBlendMode
|
|
18222
|
-
* @memberof Renderable#
|
|
18223
18272
|
*/
|
|
18224
18273
|
this.blendMode = "normal";
|
|
18225
18274
|
|
|
18226
18275
|
/**
|
|
18227
18276
|
* The name of the renderable
|
|
18228
|
-
* @public
|
|
18229
18277
|
* @type {string}
|
|
18230
|
-
* @name name
|
|
18231
18278
|
* @default ""
|
|
18232
|
-
* @memberof Renderable
|
|
18233
18279
|
*/
|
|
18234
18280
|
this.name = "";
|
|
18235
18281
|
|
|
@@ -18240,8 +18286,6 @@
|
|
|
18240
18286
|
* Position of the Renderable relative to its parent container
|
|
18241
18287
|
* @public
|
|
18242
18288
|
* @type {ObservableVector3d}
|
|
18243
|
-
* @name pos
|
|
18244
|
-
* @memberof Renderable#
|
|
18245
18289
|
*/
|
|
18246
18290
|
this.pos = pool.pull("ObservableVector3d", x, y, 0, { onUpdate: this.updateBoundsPos, scope: this});
|
|
18247
18291
|
}
|
|
@@ -18249,9 +18293,7 @@
|
|
|
18249
18293
|
/**
|
|
18250
18294
|
* when true the renderable will be redrawn during the next update cycle
|
|
18251
18295
|
* @type {boolean}
|
|
18252
|
-
* @name isDirty
|
|
18253
18296
|
* @default false
|
|
18254
|
-
* @memberof Renderable#
|
|
18255
18297
|
*/
|
|
18256
18298
|
this.isDirty = false;
|
|
18257
18299
|
|
|
@@ -18272,27 +18314,49 @@
|
|
|
18272
18314
|
Renderable.prototype = Object.create( Rect && Rect.prototype );
|
|
18273
18315
|
Renderable.prototype.constructor = Renderable;
|
|
18274
18316
|
|
|
18275
|
-
var prototypeAccessors = { isFloating: { configurable: true },inViewport: { configurable: true },isFlippedX: { configurable: true },isFlippedY: { configurable: true } };
|
|
18317
|
+
var prototypeAccessors = { isFloating: { configurable: true },tint: { configurable: true },inViewport: { configurable: true },isFlippedX: { configurable: true },isFlippedY: { configurable: true } };
|
|
18276
18318
|
|
|
18277
18319
|
/**
|
|
18278
18320
|
* Whether the renderable object is floating, or contained in a floating container
|
|
18279
|
-
* @public
|
|
18280
18321
|
* @see Renderable#floating
|
|
18281
18322
|
* @type {boolean}
|
|
18282
|
-
* @name isFloating
|
|
18283
|
-
* @memberof Renderable
|
|
18284
18323
|
*/
|
|
18285
18324
|
prototypeAccessors.isFloating.get = function () {
|
|
18286
18325
|
return this.floating === true || (typeof this.ancestor !== "undefined" && this.ancestor.floating === true);
|
|
18287
18326
|
};
|
|
18288
18327
|
|
|
18328
|
+
/**
|
|
18329
|
+
* define a tint for this renderable. a (255, 255, 255) r, g, b value will remove the tint effect.
|
|
18330
|
+
* @type {Color}
|
|
18331
|
+
* @default (255, 255, 255)
|
|
18332
|
+
* @example
|
|
18333
|
+
* // add a red tint to this renderable
|
|
18334
|
+
* this.tint.setColor(255, 128, 128);
|
|
18335
|
+
* // remove the tint
|
|
18336
|
+
* this.tint.setColor(255, 255, 255);
|
|
18337
|
+
*/
|
|
18338
|
+
prototypeAccessors.tint.get = function () {
|
|
18339
|
+
if (typeof this._tint === "undefined") {
|
|
18340
|
+
this._tint = pool.pull("Color", 255, 255, 255, 1.0);
|
|
18341
|
+
}
|
|
18342
|
+
return this._tint;
|
|
18343
|
+
};
|
|
18344
|
+
prototypeAccessors.tint.set = function (value) {
|
|
18345
|
+
if (typeof this._tint === "undefined") {
|
|
18346
|
+
this._tint = pool.pull("Color", 255, 255, 255, 1.0);
|
|
18347
|
+
}
|
|
18348
|
+
if (value instanceof Color) {
|
|
18349
|
+
this._tint.copy(value);
|
|
18350
|
+
} else {
|
|
18351
|
+
// string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
|
|
18352
|
+
this._tint.parseCSS(value);
|
|
18353
|
+
}
|
|
18354
|
+
};
|
|
18355
|
+
|
|
18289
18356
|
/**
|
|
18290
18357
|
* Whether the renderable object is visible and within the viewport
|
|
18291
|
-
* @public
|
|
18292
18358
|
* @type {boolean}
|
|
18293
18359
|
* @default false
|
|
18294
|
-
* @name inViewport
|
|
18295
|
-
* @memberof Renderable
|
|
18296
18360
|
*/
|
|
18297
18361
|
prototypeAccessors.inViewport.get = function () {
|
|
18298
18362
|
return this._inViewport;
|
|
@@ -18311,8 +18375,6 @@
|
|
|
18311
18375
|
* @public
|
|
18312
18376
|
* @see Renderable#flipX
|
|
18313
18377
|
* @type {boolean}
|
|
18314
|
-
* @name isFlippedX
|
|
18315
|
-
* @memberof Renderable
|
|
18316
18378
|
*/
|
|
18317
18379
|
prototypeAccessors.isFlippedX.get = function () {
|
|
18318
18380
|
return this._flip.x === true;
|
|
@@ -18323,8 +18385,6 @@
|
|
|
18323
18385
|
* @public
|
|
18324
18386
|
* @see Renderable#flipY
|
|
18325
18387
|
* @type {boolean}
|
|
18326
|
-
* @name isFlippedY
|
|
18327
|
-
* @memberof Renderable
|
|
18328
18388
|
*/
|
|
18329
18389
|
prototypeAccessors.isFlippedY.get = function () {
|
|
18330
18390
|
return this._flip.y === true;
|
|
@@ -18332,8 +18392,6 @@
|
|
|
18332
18392
|
|
|
18333
18393
|
/**
|
|
18334
18394
|
* returns the bounding box for this renderable
|
|
18335
|
-
* @name getBounds
|
|
18336
|
-
* @memberof Renderable
|
|
18337
18395
|
* @returns {Bounds} bounding box Rectangle object
|
|
18338
18396
|
*/
|
|
18339
18397
|
Renderable.prototype.getBounds = function getBounds () {
|
|
@@ -18352,8 +18410,6 @@
|
|
|
18352
18410
|
|
|
18353
18411
|
/**
|
|
18354
18412
|
* get the renderable alpha channel value<br>
|
|
18355
|
-
* @name getOpacity
|
|
18356
|
-
* @memberof Renderable
|
|
18357
18413
|
* @returns {number} current opacity value between 0 and 1
|
|
18358
18414
|
*/
|
|
18359
18415
|
Renderable.prototype.getOpacity = function getOpacity () {
|
|
@@ -18362,8 +18418,6 @@
|
|
|
18362
18418
|
|
|
18363
18419
|
/**
|
|
18364
18420
|
* set the renderable alpha channel value<br>
|
|
18365
|
-
* @name setOpacity
|
|
18366
|
-
* @memberof Renderable
|
|
18367
18421
|
* @param {number} alpha opacity value between 0.0 and 1.0
|
|
18368
18422
|
*/
|
|
18369
18423
|
Renderable.prototype.setOpacity = function setOpacity (alpha) {
|
|
@@ -18380,8 +18434,6 @@
|
|
|
18380
18434
|
/**
|
|
18381
18435
|
* flip the renderable on the horizontal axis (around the center of the renderable)
|
|
18382
18436
|
* @see Matrix2d#scaleX
|
|
18383
|
-
* @name flipX
|
|
18384
|
-
* @memberof Renderable
|
|
18385
18437
|
* @param {boolean} [flip=true] `true` to flip this renderable.
|
|
18386
18438
|
* @returns {Renderable} Reference to this object for method chaining
|
|
18387
18439
|
*/
|
|
@@ -18396,8 +18448,6 @@
|
|
|
18396
18448
|
/**
|
|
18397
18449
|
* flip the renderable on the vertical axis (around the center of the renderable)
|
|
18398
18450
|
* @see Matrix2d#scaleY
|
|
18399
|
-
* @name flipY
|
|
18400
|
-
* @memberof Renderable
|
|
18401
18451
|
* @param {boolean} [flip=true] `true` to flip this renderable.
|
|
18402
18452
|
* @returns {Renderable} Reference to this object for method chaining
|
|
18403
18453
|
*/
|
|
@@ -18411,8 +18461,6 @@
|
|
|
18411
18461
|
|
|
18412
18462
|
/**
|
|
18413
18463
|
* multiply the renderable currentTransform with the given matrix
|
|
18414
|
-
* @name transform
|
|
18415
|
-
* @memberof Renderable
|
|
18416
18464
|
* @see Renderable#currentTransform
|
|
18417
18465
|
* @param {Matrix2d} m the transformation matrix
|
|
18418
18466
|
* @returns {Renderable} Reference to this object for method chaining
|
|
@@ -18427,8 +18475,6 @@
|
|
|
18427
18475
|
|
|
18428
18476
|
/**
|
|
18429
18477
|
* return the angle to the specified target
|
|
18430
|
-
* @name angleTo
|
|
18431
|
-
* @memberof Renderable
|
|
18432
18478
|
* @param {Renderable|Vector2d|Vector3d} target
|
|
18433
18479
|
* @returns {number} angle in radians
|
|
18434
18480
|
*/
|
|
@@ -18450,8 +18496,6 @@
|
|
|
18450
18496
|
|
|
18451
18497
|
/**
|
|
18452
18498
|
* return the distance to the specified target
|
|
18453
|
-
* @name distanceTo
|
|
18454
|
-
* @memberof Renderable
|
|
18455
18499
|
* @param {Renderable|Vector2d|Vector3d} target
|
|
18456
18500
|
* @returns {number} distance
|
|
18457
18501
|
*/
|
|
@@ -18473,8 +18517,6 @@
|
|
|
18473
18517
|
|
|
18474
18518
|
/**
|
|
18475
18519
|
* Rotate this renderable towards the given target.
|
|
18476
|
-
* @name lookAt
|
|
18477
|
-
* @memberof Renderable
|
|
18478
18520
|
* @param {Renderable|Vector2d|Vector3d} target the renderable or position to look at
|
|
18479
18521
|
* @returns {Renderable} Reference to this object for method chaining
|
|
18480
18522
|
*/
|
|
@@ -18496,8 +18538,6 @@
|
|
|
18496
18538
|
|
|
18497
18539
|
/**
|
|
18498
18540
|
* Rotate this renderable by the specified angle (in radians).
|
|
18499
|
-
* @name rotate
|
|
18500
|
-
* @memberof Renderable
|
|
18501
18541
|
* @param {number} angle The angle to rotate (in radians)
|
|
18502
18542
|
* @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around
|
|
18503
18543
|
* @returns {Renderable} Reference to this object for method chaining
|
|
@@ -18517,8 +18557,6 @@
|
|
|
18517
18557
|
* when rendering. It does not scale the object itself. For example if the renderable
|
|
18518
18558
|
* is an image, the image.width and image.height properties are unaltered but the currentTransform
|
|
18519
18559
|
* member will be changed.
|
|
18520
|
-
* @name scale
|
|
18521
|
-
* @memberof Renderable
|
|
18522
18560
|
* @param {number} x a number representing the abscissa of the scaling vector.
|
|
18523
18561
|
* @param {number} [y=x] a number representing the ordinate of the scaling vector.
|
|
18524
18562
|
* @returns {Renderable} Reference to this object for method chaining
|
|
@@ -18532,8 +18570,6 @@
|
|
|
18532
18570
|
|
|
18533
18571
|
/**
|
|
18534
18572
|
* scale the renderable around his anchor point
|
|
18535
|
-
* @name scaleV
|
|
18536
|
-
* @memberof Renderable
|
|
18537
18573
|
* @param {Vector2d} v scaling vector
|
|
18538
18574
|
* @returns {Renderable} Reference to this object for method chaining
|
|
18539
18575
|
*/
|
|
@@ -18543,11 +18579,7 @@
|
|
|
18543
18579
|
};
|
|
18544
18580
|
|
|
18545
18581
|
/**
|
|
18546
|
-
* update function.
|
|
18547
|
-
* automatically called by the game manager {@link game}
|
|
18548
|
-
* @name update
|
|
18549
|
-
* @memberof Renderable
|
|
18550
|
-
* @protected
|
|
18582
|
+
* update function (automatically called by melonJS).
|
|
18551
18583
|
* @param {number} dt time since the last update in milliseconds.
|
|
18552
18584
|
* @returns {boolean} true if the renderable is dirty
|
|
18553
18585
|
*/
|
|
@@ -18558,8 +18590,6 @@
|
|
|
18558
18590
|
/**
|
|
18559
18591
|
* update the bounding box for this shape.
|
|
18560
18592
|
* @ignore
|
|
18561
|
-
* @name updateBounds
|
|
18562
|
-
* @memberof Renderable
|
|
18563
18593
|
* @returns {Bounds} this shape bounding box Rectangle object
|
|
18564
18594
|
*/
|
|
18565
18595
|
Renderable.prototype.updateBounds = function updateBounds () {
|
|
@@ -18571,8 +18601,6 @@
|
|
|
18571
18601
|
/**
|
|
18572
18602
|
* update the renderable's bounding rect (private)
|
|
18573
18603
|
* @ignore
|
|
18574
|
-
* @name updateBoundsPos
|
|
18575
|
-
* @memberof Renderable
|
|
18576
18604
|
*/
|
|
18577
18605
|
Renderable.prototype.updateBoundsPos = function updateBoundsPos (newX, newY) {
|
|
18578
18606
|
var bounds = this.getBounds();
|
|
@@ -18603,8 +18631,6 @@
|
|
|
18603
18631
|
|
|
18604
18632
|
/**
|
|
18605
18633
|
* return the renderable absolute position in the game world
|
|
18606
|
-
* @name getAbsolutePosition
|
|
18607
|
-
* @memberof Renderable
|
|
18608
18634
|
* @returns {Vector2d}
|
|
18609
18635
|
*/
|
|
18610
18636
|
Renderable.prototype.getAbsolutePosition = function getAbsolutePosition () {
|
|
@@ -18622,8 +18648,6 @@
|
|
|
18622
18648
|
/**
|
|
18623
18649
|
* called when the anchor point value is changed
|
|
18624
18650
|
* @private
|
|
18625
|
-
* @name onAnchorUpdate
|
|
18626
|
-
* @memberof Renderable
|
|
18627
18651
|
* @param {number} x the new X value to be set for the anchor
|
|
18628
18652
|
* @param {number} y the new Y value to be set for the anchor
|
|
18629
18653
|
*/
|
|
@@ -18636,12 +18660,10 @@
|
|
|
18636
18660
|
};
|
|
18637
18661
|
|
|
18638
18662
|
/**
|
|
18639
|
-
*
|
|
18640
|
-
*
|
|
18641
|
-
*
|
|
18642
|
-
* @
|
|
18643
|
-
* @memberof Renderable
|
|
18644
|
-
* @protected
|
|
18663
|
+
* Prepare the rendering context before drawing (automatically called by melonJS).
|
|
18664
|
+
* This will apply any defined transforms, anchor point, tint or blend mode and translate the context accordingly to this renderable position.
|
|
18665
|
+
* @see Renderable#draw
|
|
18666
|
+
* @see Renderable#postDraw
|
|
18645
18667
|
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
|
|
18646
18668
|
*/
|
|
18647
18669
|
Renderable.prototype.preDraw = function preDraw (renderer) {
|
|
@@ -18692,10 +18714,15 @@
|
|
|
18692
18714
|
};
|
|
18693
18715
|
|
|
18694
18716
|
/**
|
|
18695
|
-
*
|
|
18696
|
-
*
|
|
18697
|
-
*
|
|
18698
|
-
*
|
|
18717
|
+
* Draw this renderable (automatically called by melonJS).
|
|
18718
|
+
* All draw operations for renderable are made respectively
|
|
18719
|
+
* to the position or transforms set or applied by the preDraw method.
|
|
18720
|
+
* The main draw loop will first call preDraw() to prepare the context for drawing the renderable,
|
|
18721
|
+
* then draw() to draw the renderable, and finally postDraw() to clear the context.
|
|
18722
|
+
* If you override this method, be mindful about the drawing logic; for example if you draw a shape
|
|
18723
|
+
* from the draw method, you should make sure that your draw it at the 0, 0 coordinates.
|
|
18724
|
+
* @see Renderable#preDraw
|
|
18725
|
+
* @see Renderable#postDraw
|
|
18699
18726
|
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer instance
|
|
18700
18727
|
* @param {Camera2d} [viewport] the viewport to (re)draw
|
|
18701
18728
|
*/
|
|
@@ -18704,11 +18731,9 @@
|
|
|
18704
18731
|
};
|
|
18705
18732
|
|
|
18706
18733
|
/**
|
|
18707
|
-
* restore the rendering context after drawing.
|
|
18708
|
-
*
|
|
18709
|
-
* @
|
|
18710
|
-
* @memberof Renderable
|
|
18711
|
-
* @protected
|
|
18734
|
+
* restore the rendering context after drawing (automatically called by melonJS).
|
|
18735
|
+
* @see Renderable#preDraw
|
|
18736
|
+
* @see Renderable#draw
|
|
18712
18737
|
* @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
|
|
18713
18738
|
*/
|
|
18714
18739
|
Renderable.prototype.postDraw = function postDraw (renderer) {
|
|
@@ -18730,8 +18755,6 @@
|
|
|
18730
18755
|
/**
|
|
18731
18756
|
* onCollision callback, triggered in case of collision,
|
|
18732
18757
|
* when this renderable body is colliding with another one
|
|
18733
|
-
* @name onCollision
|
|
18734
|
-
* @memberof Renderable
|
|
18735
18758
|
* @param {ResponseObject} response the collision response object
|
|
18736
18759
|
* @param {Renderable} other the other renderable touching this one (a reference to response.a or response.b)
|
|
18737
18760
|
* @returns {boolean} true if the object should respond to the collision (its position and velocity will be corrected)
|
|
@@ -18783,9 +18806,9 @@
|
|
|
18783
18806
|
this.mask = undefined;
|
|
18784
18807
|
}
|
|
18785
18808
|
|
|
18786
|
-
if (typeof this.
|
|
18787
|
-
pool.push(this.
|
|
18788
|
-
this.
|
|
18809
|
+
if (typeof this._tint !== "undefined") {
|
|
18810
|
+
pool.push(this._tint);
|
|
18811
|
+
this._tint = undefined;
|
|
18789
18812
|
}
|
|
18790
18813
|
|
|
18791
18814
|
this.ancestor = undefined;
|
|
@@ -18806,8 +18829,6 @@
|
|
|
18806
18829
|
/**
|
|
18807
18830
|
* OnDestroy Notification function<br>
|
|
18808
18831
|
* Called by engine before deleting the object
|
|
18809
|
-
* @name onDestroyEvent
|
|
18810
|
-
* @memberof Renderable
|
|
18811
18832
|
*/
|
|
18812
18833
|
Renderable.prototype.onDestroyEvent = function onDestroyEvent () {
|
|
18813
18834
|
// to be extended !
|
|
@@ -19676,7 +19697,7 @@
|
|
|
19676
19697
|
/**
|
|
19677
19698
|
* The collision shapes of the body
|
|
19678
19699
|
* @ignore
|
|
19679
|
-
* @type {Polygon[]|Line[]|Ellipse[]}
|
|
19700
|
+
* @type {Polygon[]|Line[]|Ellipse[]|Point|Point[]}
|
|
19680
19701
|
*/
|
|
19681
19702
|
this.shapes = [];
|
|
19682
19703
|
}
|
|
@@ -19870,7 +19891,7 @@
|
|
|
19870
19891
|
/**
|
|
19871
19892
|
* add a collision shape to this body <br>
|
|
19872
19893
|
* (note: me.Rect objects will be converted to me.Polygon before being added)
|
|
19873
|
-
* @param {Rect|Polygon|Line|Ellipse|Bounds|object} shape a shape or JSON object
|
|
19894
|
+
* @param {Rect|Polygon|Line|Ellipse|Point|Point[]|Bounds|object} shape a shape or JSON object
|
|
19874
19895
|
* @returns {number} the shape array length
|
|
19875
19896
|
* @example
|
|
19876
19897
|
* // add a rectangle shape
|
|
@@ -19905,6 +19926,12 @@
|
|
|
19905
19926
|
// update the body bounds
|
|
19906
19927
|
this.bounds.add(shape.points);
|
|
19907
19928
|
this.bounds.translate(shape.pos);
|
|
19929
|
+
} else if (shape instanceof Point) {
|
|
19930
|
+
if (!this.shapes.includes(shape)) {
|
|
19931
|
+
// see removeShape
|
|
19932
|
+
this.shapes.push(shape);
|
|
19933
|
+
}
|
|
19934
|
+
this.bounds.addPoint(shape);
|
|
19908
19935
|
} else {
|
|
19909
19936
|
// JSON object
|
|
19910
19937
|
this.fromJSON(shape);
|
|
@@ -24334,17 +24361,7 @@
|
|
|
24334
24361
|
Renderer.call(this, options);
|
|
24335
24362
|
|
|
24336
24363
|
// defined the 2d context
|
|
24337
|
-
this.context = this.getContext2d(this.
|
|
24338
|
-
|
|
24339
|
-
// create the back buffer if we use double buffering
|
|
24340
|
-
if (this.settings.doubleBuffering) {
|
|
24341
|
-
this.backBufferCanvas = createCanvas(this.settings.width, this.settings.height, true);
|
|
24342
|
-
this.backBufferContext2D = this.getContext2d(this.backBufferCanvas);
|
|
24343
|
-
}
|
|
24344
|
-
else {
|
|
24345
|
-
this.backBufferCanvas = this.getScreenCanvas();
|
|
24346
|
-
this.backBufferContext2D = this.context;
|
|
24347
|
-
}
|
|
24364
|
+
this.context = this.getContext2d(this.getCanvas(), this.settings.transparent);
|
|
24348
24365
|
|
|
24349
24366
|
this.setBlendMode(this.settings.blendMode);
|
|
24350
24367
|
|
|
@@ -24360,13 +24377,13 @@
|
|
|
24360
24377
|
}
|
|
24361
24378
|
|
|
24362
24379
|
// context lost & restore event for canvas
|
|
24363
|
-
this.
|
|
24380
|
+
this.getCanvas().addEventListener("contextlost", function (e) {
|
|
24364
24381
|
e.preventDefault();
|
|
24365
24382
|
this$1$1.isContextValid = false;
|
|
24366
24383
|
emit(ONCONTEXT_LOST, this$1$1);
|
|
24367
24384
|
}, false );
|
|
24368
24385
|
// ctx.restoreContext()
|
|
24369
|
-
this.
|
|
24386
|
+
this.getCanvas().addEventListener("contextrestored", function () {
|
|
24370
24387
|
this$1$1.isContextValid = true;
|
|
24371
24388
|
emit(ONCONTEXT_RESTORED, this$1$1);
|
|
24372
24389
|
}, false );
|
|
@@ -24392,7 +24409,7 @@
|
|
|
24392
24409
|
* @memberof CanvasRenderer
|
|
24393
24410
|
*/
|
|
24394
24411
|
CanvasRenderer.prototype.resetTransform = function resetTransform () {
|
|
24395
|
-
this.
|
|
24412
|
+
this.getContext().setTransform(1, 0, 0, 1, 0, 0);
|
|
24396
24413
|
};
|
|
24397
24414
|
|
|
24398
24415
|
/**
|
|
@@ -24436,12 +24453,6 @@
|
|
|
24436
24453
|
this.currentBlendMode = "normal";
|
|
24437
24454
|
break;
|
|
24438
24455
|
}
|
|
24439
|
-
|
|
24440
|
-
// transparent setting will override the given blendmode for this.context
|
|
24441
|
-
if (this.settings.doubleBuffering && this.settings.transparent) {
|
|
24442
|
-
// Clears the front buffer for each frame blit
|
|
24443
|
-
this.context.globalCompositeOperation = "copy";
|
|
24444
|
-
}
|
|
24445
24456
|
};
|
|
24446
24457
|
|
|
24447
24458
|
/**
|
|
@@ -24450,19 +24461,10 @@
|
|
|
24450
24461
|
* @memberof CanvasRenderer
|
|
24451
24462
|
*/
|
|
24452
24463
|
CanvasRenderer.prototype.clear = function clear () {
|
|
24453
|
-
if (this.settings.transparent) {
|
|
24454
|
-
this.
|
|
24455
|
-
|
|
24456
|
-
|
|
24457
|
-
|
|
24458
|
-
/**
|
|
24459
|
-
* render the main framebuffer on screen
|
|
24460
|
-
* @name flush
|
|
24461
|
-
* @memberof CanvasRenderer
|
|
24462
|
-
*/
|
|
24463
|
-
CanvasRenderer.prototype.flush = function flush () {
|
|
24464
|
-
if (this.settings.doubleBuffering) {
|
|
24465
|
-
this.context.drawImage(this.backBufferCanvas, 0, 0);
|
|
24464
|
+
if (this.settings.transparent === false) {
|
|
24465
|
+
var canvas = this.getCanvas();
|
|
24466
|
+
var context = this.getContext();
|
|
24467
|
+
context.clearRect(0, 0, canvas.width, canvas.height);
|
|
24466
24468
|
}
|
|
24467
24469
|
};
|
|
24468
24470
|
|
|
@@ -24475,12 +24477,17 @@
|
|
|
24475
24477
|
*/
|
|
24476
24478
|
CanvasRenderer.prototype.clearColor = function clearColor (color, opaque) {
|
|
24477
24479
|
if ( color === void 0 ) color = "#000000";
|
|
24480
|
+
if ( opaque === void 0 ) opaque = false;
|
|
24481
|
+
|
|
24482
|
+
var canvas = this.getCanvas();
|
|
24483
|
+
var context = this.getContext();
|
|
24478
24484
|
|
|
24479
24485
|
this.save();
|
|
24480
24486
|
this.resetTransform();
|
|
24481
|
-
|
|
24482
|
-
|
|
24483
|
-
|
|
24487
|
+
context.globalAlpha = 1;
|
|
24488
|
+
context.globalCompositeOperation = opaque === true ? "copy" : "source-over";
|
|
24489
|
+
context.fillStyle = (color instanceof Color) ? color.toRGBA() : color;
|
|
24490
|
+
this.fillRect(0, 0, canvas.width, canvas.height);
|
|
24484
24491
|
this.restore();
|
|
24485
24492
|
};
|
|
24486
24493
|
|
|
@@ -24850,15 +24857,28 @@
|
|
|
24850
24857
|
this.strokeRoundRect(x, y, width, height, radius, true);
|
|
24851
24858
|
};
|
|
24852
24859
|
|
|
24860
|
+
/**
|
|
24861
|
+
* Stroke a Point at the specified coordinates
|
|
24862
|
+
* @name strokePoint
|
|
24863
|
+
* @memberof CanvasRenderer
|
|
24864
|
+
* @param {number} x
|
|
24865
|
+
* @param {number} y
|
|
24866
|
+
*/
|
|
24867
|
+
CanvasRenderer.prototype.strokePoint = function strokePoint (x, y) {
|
|
24868
|
+
this.strokeLine(x, y, x + 1, y + 1);
|
|
24869
|
+
};
|
|
24853
24870
|
|
|
24854
24871
|
/**
|
|
24855
|
-
*
|
|
24856
|
-
* @name
|
|
24872
|
+
* Draw a a point at the specified coordinates
|
|
24873
|
+
* @name fillPoint
|
|
24857
24874
|
* @memberof CanvasRenderer
|
|
24858
|
-
* @
|
|
24875
|
+
* @param {number} x
|
|
24876
|
+
* @param {number} y
|
|
24877
|
+
* @param {number} width
|
|
24878
|
+
* @param {number} height
|
|
24859
24879
|
*/
|
|
24860
|
-
CanvasRenderer.prototype.
|
|
24861
|
-
|
|
24880
|
+
CanvasRenderer.prototype.fillPoint = function fillPoint (x, y) {
|
|
24881
|
+
this.strokePoint(x, y);
|
|
24862
24882
|
};
|
|
24863
24883
|
|
|
24864
24884
|
/**
|
|
@@ -24876,7 +24896,7 @@
|
|
|
24876
24896
|
* @memberof CanvasRenderer
|
|
24877
24897
|
*/
|
|
24878
24898
|
CanvasRenderer.prototype.save = function save () {
|
|
24879
|
-
this.
|
|
24899
|
+
this.getContext().save();
|
|
24880
24900
|
};
|
|
24881
24901
|
|
|
24882
24902
|
/**
|
|
@@ -24885,12 +24905,12 @@
|
|
|
24885
24905
|
* @memberof CanvasRenderer
|
|
24886
24906
|
*/
|
|
24887
24907
|
CanvasRenderer.prototype.restore = function restore () {
|
|
24888
|
-
this.
|
|
24908
|
+
this.getContext().restore();
|
|
24889
24909
|
this.currentColor.glArray[3] = this.getGlobalAlpha();
|
|
24890
24910
|
this.currentScissor[0] = 0;
|
|
24891
24911
|
this.currentScissor[1] = 0;
|
|
24892
|
-
this.currentScissor[2] = this.
|
|
24893
|
-
this.currentScissor[3] = this.
|
|
24912
|
+
this.currentScissor[2] = this.getCanvas().width;
|
|
24913
|
+
this.currentScissor[3] = this.getCanvas().height;
|
|
24894
24914
|
};
|
|
24895
24915
|
|
|
24896
24916
|
/**
|
|
@@ -24900,7 +24920,7 @@
|
|
|
24900
24920
|
* @param {number} angle in radians
|
|
24901
24921
|
*/
|
|
24902
24922
|
CanvasRenderer.prototype.rotate = function rotate (angle) {
|
|
24903
|
-
this.
|
|
24923
|
+
this.getContext().rotate(angle);
|
|
24904
24924
|
};
|
|
24905
24925
|
|
|
24906
24926
|
/**
|
|
@@ -24911,7 +24931,7 @@
|
|
|
24911
24931
|
* @param {number} y
|
|
24912
24932
|
*/
|
|
24913
24933
|
CanvasRenderer.prototype.scale = function scale (x, y) {
|
|
24914
|
-
this.
|
|
24934
|
+
this.getContext().scale(x, y);
|
|
24915
24935
|
};
|
|
24916
24936
|
|
|
24917
24937
|
/**
|
|
@@ -24922,8 +24942,9 @@
|
|
|
24922
24942
|
* @param {Color|string} color css color value
|
|
24923
24943
|
*/
|
|
24924
24944
|
CanvasRenderer.prototype.setColor = function setColor (color) {
|
|
24925
|
-
this.
|
|
24926
|
-
|
|
24945
|
+
var context = this.getContext();
|
|
24946
|
+
context.strokeStyle =
|
|
24947
|
+
context.fillStyle = (
|
|
24927
24948
|
color instanceof Color ?
|
|
24928
24949
|
color.toRGBA() :
|
|
24929
24950
|
color
|
|
@@ -24937,7 +24958,7 @@
|
|
|
24937
24958
|
* @param {number} alpha 0.0 to 1.0 values accepted.
|
|
24938
24959
|
*/
|
|
24939
24960
|
CanvasRenderer.prototype.setGlobalAlpha = function setGlobalAlpha (alpha) {
|
|
24940
|
-
this.
|
|
24961
|
+
this.getContext().globalAlpha = this.currentColor.glArray[3] = alpha;
|
|
24941
24962
|
};
|
|
24942
24963
|
|
|
24943
24964
|
/**
|
|
@@ -24947,7 +24968,7 @@
|
|
|
24947
24968
|
* @returns {number} global alpha value
|
|
24948
24969
|
*/
|
|
24949
24970
|
CanvasRenderer.prototype.getGlobalAlpha = function getGlobalAlpha () {
|
|
24950
|
-
return this.
|
|
24971
|
+
return this.getContext().globalAlpha;
|
|
24951
24972
|
};
|
|
24952
24973
|
|
|
24953
24974
|
/**
|
|
@@ -24957,7 +24978,7 @@
|
|
|
24957
24978
|
* @param {number} width Line width
|
|
24958
24979
|
*/
|
|
24959
24980
|
CanvasRenderer.prototype.setLineWidth = function setLineWidth (width) {
|
|
24960
|
-
this.
|
|
24981
|
+
this.getContext().lineWidth = width;
|
|
24961
24982
|
};
|
|
24962
24983
|
|
|
24963
24984
|
/**
|
|
@@ -24992,7 +25013,7 @@
|
|
|
24992
25013
|
f |= 0;
|
|
24993
25014
|
}
|
|
24994
25015
|
|
|
24995
|
-
this.
|
|
25016
|
+
this.getContext().transform(a, b, c, d, e, f);
|
|
24996
25017
|
};
|
|
24997
25018
|
|
|
24998
25019
|
/**
|
|
@@ -25004,9 +25025,9 @@
|
|
|
25004
25025
|
*/
|
|
25005
25026
|
CanvasRenderer.prototype.translate = function translate (x, y) {
|
|
25006
25027
|
if (this.settings.subPixel === false) {
|
|
25007
|
-
this.
|
|
25028
|
+
this.getContext().translate(~~x, ~~y);
|
|
25008
25029
|
} else {
|
|
25009
|
-
this.
|
|
25030
|
+
this.getContext().translate(x, y);
|
|
25010
25031
|
}
|
|
25011
25032
|
};
|
|
25012
25033
|
|
|
@@ -25024,14 +25045,14 @@
|
|
|
25024
25045
|
* @param {number} height
|
|
25025
25046
|
*/
|
|
25026
25047
|
CanvasRenderer.prototype.clipRect = function clipRect (x, y, width, height) {
|
|
25027
|
-
var canvas = this.
|
|
25048
|
+
var canvas = this.getCanvas();
|
|
25028
25049
|
// if requested box is different from the current canvas size;
|
|
25029
25050
|
if (x !== 0 || y !== 0 || width !== canvas.width || height !== canvas.height) {
|
|
25030
25051
|
var currentScissor = this.currentScissor;
|
|
25031
25052
|
// if different from the current scissor box
|
|
25032
25053
|
if (currentScissor[0] !== x || currentScissor[1] !== y ||
|
|
25033
25054
|
currentScissor[2] !== width || currentScissor[3] !== height) {
|
|
25034
|
-
var context = this.
|
|
25055
|
+
var context = this.getContext();
|
|
25035
25056
|
context.beginPath();
|
|
25036
25057
|
context.rect(x, y, width, height);
|
|
25037
25058
|
context.clip();
|
|
@@ -25252,6 +25273,15 @@
|
|
|
25252
25273
|
*/
|
|
25253
25274
|
this.renderorder = data.renderorder || "right-down";
|
|
25254
25275
|
|
|
25276
|
+
/**
|
|
25277
|
+
* the layer class
|
|
25278
|
+
* @public
|
|
25279
|
+
* @type {string}
|
|
25280
|
+
* @name class
|
|
25281
|
+
* @name TMXLayer#class
|
|
25282
|
+
*/
|
|
25283
|
+
this.class = data.class;
|
|
25284
|
+
|
|
25255
25285
|
// for displaying order
|
|
25256
25286
|
this.pos.z = z;
|
|
25257
25287
|
|
|
@@ -26649,6 +26679,14 @@
|
|
|
26649
26679
|
*/
|
|
26650
26680
|
this.isCollection = false;
|
|
26651
26681
|
|
|
26682
|
+
/**
|
|
26683
|
+
* the tileset class
|
|
26684
|
+
* @public
|
|
26685
|
+
* @type {boolean}
|
|
26686
|
+
* @name TMXTileset#class
|
|
26687
|
+
*/
|
|
26688
|
+
this.class = tileset.class;
|
|
26689
|
+
|
|
26652
26690
|
/**
|
|
26653
26691
|
* Tileset animations
|
|
26654
26692
|
* @private
|
|
@@ -27041,20 +27079,31 @@
|
|
|
27041
27079
|
* object type
|
|
27042
27080
|
* @public
|
|
27043
27081
|
* @type {string}
|
|
27082
|
+
* @deprecated since Tiled 1.9
|
|
27083
|
+
* @see https://docs.mapeditor.org/en/stable/reference/tmx-changelog/#tiled-1-9
|
|
27044
27084
|
* @name type
|
|
27045
27085
|
* @memberof TMXObject
|
|
27046
27086
|
*/
|
|
27047
27087
|
this.type = settings.type;
|
|
27048
27088
|
|
|
27089
|
+
/**
|
|
27090
|
+
* the object class
|
|
27091
|
+
* @public
|
|
27092
|
+
* @type {string}
|
|
27093
|
+
* @name class
|
|
27094
|
+
* @memberof TMXObject
|
|
27095
|
+
*/
|
|
27096
|
+
this.class = typeof settings.class !== "undefined" ? settings.class : settings.type;
|
|
27097
|
+
|
|
27049
27098
|
/**
|
|
27050
27099
|
* object text
|
|
27051
27100
|
* @public
|
|
27052
27101
|
* @type {object}
|
|
27053
27102
|
* @see http://docs.mapeditor.org/en/stable/reference/tmx-map-format/#text
|
|
27054
|
-
* @name
|
|
27103
|
+
* @name text
|
|
27055
27104
|
* @memberof TMXObject
|
|
27056
27105
|
*/
|
|
27057
|
-
this.
|
|
27106
|
+
this.text = undefined;
|
|
27058
27107
|
|
|
27059
27108
|
/**
|
|
27060
27109
|
* The rotation of the object in radians clockwise (defaults to 0)
|
|
@@ -27101,6 +27150,15 @@
|
|
|
27101
27150
|
*/
|
|
27102
27151
|
this.isEllipse = false;
|
|
27103
27152
|
|
|
27153
|
+
/**
|
|
27154
|
+
* if true, the object is a Point
|
|
27155
|
+
* @public
|
|
27156
|
+
* @type {boolean}
|
|
27157
|
+
* @name isPoint
|
|
27158
|
+
* @memberof TMXObject
|
|
27159
|
+
*/
|
|
27160
|
+
this.isPoint = false;
|
|
27161
|
+
|
|
27104
27162
|
/**
|
|
27105
27163
|
* if true, the object is a Polygon
|
|
27106
27164
|
* @public
|
|
@@ -27124,12 +27182,14 @@
|
|
|
27124
27182
|
this.setTile(map.tilesets);
|
|
27125
27183
|
}
|
|
27126
27184
|
else {
|
|
27127
|
-
if (typeof
|
|
27185
|
+
if (typeof settings.ellipse !== "undefined") {
|
|
27128
27186
|
this.isEllipse = true;
|
|
27129
|
-
} else if (typeof
|
|
27187
|
+
} else if (typeof settings.point !== "undefined") {
|
|
27188
|
+
this.isPoint = true;
|
|
27189
|
+
} else if (typeof settings.polygon !== "undefined") {
|
|
27130
27190
|
this.points = settings.polygon;
|
|
27131
27191
|
this.isPolygon = true;
|
|
27132
|
-
} else if (typeof
|
|
27192
|
+
} else if (typeof settings.polyline !== "undefined") {
|
|
27133
27193
|
this.points = settings.polyline;
|
|
27134
27194
|
this.isPolyLine = true;
|
|
27135
27195
|
}
|
|
@@ -27203,8 +27263,9 @@
|
|
|
27203
27263
|
this.width,
|
|
27204
27264
|
this.height
|
|
27205
27265
|
)).rotate(this.rotation));
|
|
27266
|
+
} else if (this.isPoint === true) {
|
|
27267
|
+
shapes.push(pool.pull("Point", this.x, this.y));
|
|
27206
27268
|
} else {
|
|
27207
|
-
|
|
27208
27269
|
// add a polygon
|
|
27209
27270
|
if (this.isPolygon === true) {
|
|
27210
27271
|
var _polygon = pool.pull("Polygon", 0, 0, this.points);
|
|
@@ -27213,10 +27274,8 @@
|
|
|
27213
27274
|
throw new Error("collision polygones in Tiled should be defined as Convex");
|
|
27214
27275
|
}
|
|
27215
27276
|
shapes.push(_polygon.rotate(this.rotation));
|
|
27216
|
-
}
|
|
27217
27277
|
|
|
27218
|
-
|
|
27219
|
-
else if (this.isPolyLine === true) {
|
|
27278
|
+
} else if (this.isPolyLine === true) {
|
|
27220
27279
|
var p = this.points;
|
|
27221
27280
|
var p1, p2;
|
|
27222
27281
|
var segments = p.length - 1;
|
|
@@ -27248,7 +27307,9 @@
|
|
|
27248
27307
|
// Apply isometric projection
|
|
27249
27308
|
if (this.orientation === "isometric") {
|
|
27250
27309
|
for (i = 0; i < shapes.length; i++) {
|
|
27251
|
-
shapes[i].toIso
|
|
27310
|
+
if (typeof shapes[i].toIso === "function") {
|
|
27311
|
+
shapes[i].toIso();
|
|
27312
|
+
}
|
|
27252
27313
|
}
|
|
27253
27314
|
}
|
|
27254
27315
|
|
|
@@ -27309,6 +27370,16 @@
|
|
|
27309
27370
|
*/
|
|
27310
27371
|
this.tintcolor = data.tintcolor;
|
|
27311
27372
|
|
|
27373
|
+
|
|
27374
|
+
/**
|
|
27375
|
+
* the group class
|
|
27376
|
+
* @public
|
|
27377
|
+
* @type {string}
|
|
27378
|
+
* @name class
|
|
27379
|
+
* @memberof TMXGroup
|
|
27380
|
+
*/
|
|
27381
|
+
this.class = data.class;
|
|
27382
|
+
|
|
27312
27383
|
/**
|
|
27313
27384
|
* group z order
|
|
27314
27385
|
* @public
|
|
@@ -27559,6 +27630,16 @@
|
|
|
27559
27630
|
*/
|
|
27560
27631
|
this.tiledversion = data.tiledversion;
|
|
27561
27632
|
|
|
27633
|
+
|
|
27634
|
+
/**
|
|
27635
|
+
* The map class.
|
|
27636
|
+
* @public
|
|
27637
|
+
* @type {string}
|
|
27638
|
+
* @name TMXTileMap#class
|
|
27639
|
+
*/
|
|
27640
|
+
this.class = data.class;
|
|
27641
|
+
|
|
27642
|
+
|
|
27562
27643
|
// tilesets for this map
|
|
27563
27644
|
this.tilesets = null;
|
|
27564
27645
|
|
|
@@ -27898,6 +27979,8 @@
|
|
|
27898
27979
|
obj.anchorPoint.set(0, 0);
|
|
27899
27980
|
obj.name = settings.name;
|
|
27900
27981
|
obj.type = settings.type;
|
|
27982
|
+
// for backward compatibility
|
|
27983
|
+
obj.class = settings.class || settings.type;
|
|
27901
27984
|
obj.id = settings.id;
|
|
27902
27985
|
obj.body = new Body(obj, shape);
|
|
27903
27986
|
obj.body.setStatic(true);
|
|
@@ -29172,7 +29255,12 @@
|
|
|
29172
29255
|
}
|
|
29173
29256
|
|
|
29174
29257
|
if (typeof (settings.tint) !== "undefined") {
|
|
29175
|
-
|
|
29258
|
+
if (settings.tint instanceof Color) {
|
|
29259
|
+
this.tint.copy(settings.tint);
|
|
29260
|
+
} else {
|
|
29261
|
+
// string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
|
|
29262
|
+
this.tint.parseCSS(settings.tint);
|
|
29263
|
+
}
|
|
29176
29264
|
}
|
|
29177
29265
|
|
|
29178
29266
|
// set the sprite name if specified
|
|
@@ -30699,8 +30787,6 @@
|
|
|
30699
30787
|
|
|
30700
30788
|
/**
|
|
30701
30789
|
* The WebGL version used by this renderer (1 or 2)
|
|
30702
|
-
* @name WebGLVersion
|
|
30703
|
-
* @memberof WebGLRenderer#
|
|
30704
30790
|
* @type {number}
|
|
30705
30791
|
* @default 1
|
|
30706
30792
|
* @readonly
|
|
@@ -30709,8 +30795,6 @@
|
|
|
30709
30795
|
|
|
30710
30796
|
/**
|
|
30711
30797
|
* The vendor string of the underlying graphics driver.
|
|
30712
|
-
* @name GPUVendor
|
|
30713
|
-
* @memberof WebGLRenderer#
|
|
30714
30798
|
* @type {string}
|
|
30715
30799
|
* @default null
|
|
30716
30800
|
* @readonly
|
|
@@ -30719,8 +30803,6 @@
|
|
|
30719
30803
|
|
|
30720
30804
|
/**
|
|
30721
30805
|
* The renderer string of the underlying graphics driver.
|
|
30722
|
-
* @name GPURenderer
|
|
30723
|
-
* @memberof WebGLRenderer#
|
|
30724
30806
|
* @type {string}
|
|
30725
30807
|
* @default null
|
|
30726
30808
|
* @readonly
|
|
@@ -30730,15 +30812,12 @@
|
|
|
30730
30812
|
/**
|
|
30731
30813
|
* The WebGL context
|
|
30732
30814
|
* @name gl
|
|
30733
|
-
* @memberof WebGLRenderer
|
|
30734
30815
|
* @type {WebGLRenderingContext}
|
|
30735
30816
|
*/
|
|
30736
|
-
this.context = this.gl = this.getContextGL(this.
|
|
30817
|
+
this.context = this.gl = this.getContextGL(this.getCanvas(), options.transparent);
|
|
30737
30818
|
|
|
30738
30819
|
/**
|
|
30739
30820
|
* Maximum number of texture unit supported under the current context
|
|
30740
|
-
* @name maxTextures
|
|
30741
|
-
* @memberof WebGLRenderer#
|
|
30742
30821
|
* @type {number}
|
|
30743
30822
|
* @readonly
|
|
30744
30823
|
*/
|
|
@@ -30766,25 +30845,19 @@
|
|
|
30766
30845
|
|
|
30767
30846
|
/**
|
|
30768
30847
|
* The current transformation matrix used for transformations on the overall scene
|
|
30769
|
-
* @name currentTransform
|
|
30770
30848
|
* @type {Matrix2d}
|
|
30771
|
-
* @memberof WebGLRenderer#
|
|
30772
30849
|
*/
|
|
30773
30850
|
this.currentTransform = new Matrix2d();
|
|
30774
30851
|
|
|
30775
30852
|
/**
|
|
30776
30853
|
* The current compositor used by the renderer
|
|
30777
|
-
* @name currentCompositor
|
|
30778
30854
|
* @type {WebGLCompositor}
|
|
30779
|
-
* @memberof WebGLRenderer#
|
|
30780
30855
|
*/
|
|
30781
30856
|
this.currentCompositor = null;
|
|
30782
30857
|
|
|
30783
30858
|
/**
|
|
30784
30859
|
* The list of active compositors
|
|
30785
|
-
* @name compositors
|
|
30786
30860
|
* @type {Map<WebGLCompositor>}
|
|
30787
|
-
* @memberof WebGLRenderer#
|
|
30788
30861
|
*/
|
|
30789
30862
|
this.compositors = new Map();
|
|
30790
30863
|
|
|
@@ -30815,13 +30888,13 @@
|
|
|
30815
30888
|
// to simulate context lost and restore in WebGL:
|
|
30816
30889
|
// var ctx = me.video.renderer.context.getExtension('WEBGL_lose_context');
|
|
30817
30890
|
// ctx.loseContext()
|
|
30818
|
-
this.
|
|
30891
|
+
this.getCanvas().addEventListener("webglcontextlost", function (e) {
|
|
30819
30892
|
e.preventDefault();
|
|
30820
30893
|
this$1$1.isContextValid = false;
|
|
30821
30894
|
emit(ONCONTEXT_LOST, this$1$1);
|
|
30822
30895
|
}, false );
|
|
30823
30896
|
// ctx.restoreContext()
|
|
30824
|
-
this.
|
|
30897
|
+
this.getCanvas().addEventListener("webglcontextrestored", function () {
|
|
30825
30898
|
this$1$1.reset();
|
|
30826
30899
|
this$1$1.isContextValid = true;
|
|
30827
30900
|
emit(ONCONTEXT_RESTORED, this$1$1);
|
|
@@ -30834,8 +30907,6 @@
|
|
|
30834
30907
|
|
|
30835
30908
|
/**
|
|
30836
30909
|
* Reset context state
|
|
30837
|
-
* @name reset
|
|
30838
|
-
* @memberof WebGLRenderer
|
|
30839
30910
|
*/
|
|
30840
30911
|
WebGLRenderer.prototype.reset = function reset () {
|
|
30841
30912
|
var this$1$1 = this;
|
|
@@ -30860,9 +30931,7 @@
|
|
|
30860
30931
|
|
|
30861
30932
|
/**
|
|
30862
30933
|
* set the active compositor for this renderer
|
|
30863
|
-
* @name setCompositor
|
|
30864
30934
|
* @param {WebGLCompositor|string} compositor a compositor name or instance
|
|
30865
|
-
* @memberof WebGLRenderer
|
|
30866
30935
|
*/
|
|
30867
30936
|
WebGLRenderer.prototype.setCompositor = function setCompositor (compositor) {
|
|
30868
30937
|
if ( compositor === void 0 ) compositor = "default";
|
|
@@ -30888,8 +30957,6 @@
|
|
|
30888
30957
|
|
|
30889
30958
|
/**
|
|
30890
30959
|
* Reset the gl transform to identity
|
|
30891
|
-
* @name resetTransform
|
|
30892
|
-
* @memberof WebGLRenderer
|
|
30893
30960
|
*/
|
|
30894
30961
|
WebGLRenderer.prototype.resetTransform = function resetTransform () {
|
|
30895
30962
|
this.currentTransform.identity();
|
|
@@ -30900,7 +30967,7 @@
|
|
|
30900
30967
|
*/
|
|
30901
30968
|
WebGLRenderer.prototype.createFontTexture = function createFontTexture (cache) {
|
|
30902
30969
|
if (typeof this.fontTexture === "undefined") {
|
|
30903
|
-
var canvas = this.
|
|
30970
|
+
var canvas = this.getCanvas();
|
|
30904
30971
|
var width = canvas.width;
|
|
30905
30972
|
var height = canvas.height;
|
|
30906
30973
|
|
|
@@ -30934,8 +31001,6 @@
|
|
|
30934
31001
|
|
|
30935
31002
|
/**
|
|
30936
31003
|
* Create a pattern with the specified repetition
|
|
30937
|
-
* @name createPattern
|
|
30938
|
-
* @memberof WebGLRenderer
|
|
30939
31004
|
* @param {Image} image Source image
|
|
30940
31005
|
* @param {string} repeat Define how the pattern should be repeated
|
|
30941
31006
|
* @returns {TextureAtlas}
|
|
@@ -30966,8 +31031,6 @@
|
|
|
30966
31031
|
|
|
30967
31032
|
/**
|
|
30968
31033
|
* Flush the compositor to the frame buffer
|
|
30969
|
-
* @name flush
|
|
30970
|
-
* @memberof WebGLRenderer
|
|
30971
31034
|
*/
|
|
30972
31035
|
WebGLRenderer.prototype.flush = function flush () {
|
|
30973
31036
|
this.currentCompositor.flush();
|
|
@@ -30975,8 +31038,6 @@
|
|
|
30975
31038
|
|
|
30976
31039
|
/**
|
|
30977
31040
|
* set/change the current projection matrix (WebGL only)
|
|
30978
|
-
* @name setProjection
|
|
30979
|
-
* @memberof WebGLRenderer
|
|
30980
31041
|
* @param {Matrix3d} matrix
|
|
30981
31042
|
*/
|
|
30982
31043
|
WebGLRenderer.prototype.setProjection = function setProjection (matrix) {
|
|
@@ -30984,10 +31045,15 @@
|
|
|
30984
31045
|
this.currentCompositor.setProjection(matrix);
|
|
30985
31046
|
};
|
|
30986
31047
|
|
|
31048
|
+
/**
|
|
31049
|
+
* prepare the framebuffer for drawing a new frame
|
|
31050
|
+
*/
|
|
31051
|
+
WebGLRenderer.prototype.clear = function clear () {
|
|
31052
|
+
this.currentCompositor.clear(this.settings.transparent ? 0.0 : 1.0);
|
|
31053
|
+
};
|
|
31054
|
+
|
|
30987
31055
|
/**
|
|
30988
31056
|
* Clears the gl context with the given color.
|
|
30989
|
-
* @name clearColor
|
|
30990
|
-
* @memberof WebGLRenderer
|
|
30991
31057
|
* @param {Color|string} [color="#000000"] CSS color.
|
|
30992
31058
|
* @param {boolean} [opaque=false] Allow transparency [default] or clear the surface completely [true]
|
|
30993
31059
|
*/
|
|
@@ -31007,17 +31073,10 @@
|
|
|
31007
31073
|
}
|
|
31008
31074
|
// clear gl context with the specified color
|
|
31009
31075
|
this.currentCompositor.clearColor(glArray[0], glArray[1], glArray[2], (opaque === true) ? 1.0 : glArray[3]);
|
|
31010
|
-
this.currentCompositor.clear();
|
|
31011
|
-
|
|
31012
|
-
// restore default clear Color black
|
|
31013
|
-
this.currentCompositor.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
31014
|
-
|
|
31015
31076
|
};
|
|
31016
31077
|
|
|
31017
31078
|
/**
|
|
31018
31079
|
* Erase the pixels in the given rectangular area by setting them to transparent black (rgba(0,0,0,0)).
|
|
31019
|
-
* @name clearRect
|
|
31020
|
-
* @memberof WebGLRenderer
|
|
31021
31080
|
* @param {number} x x axis of the coordinate for the rectangle starting point.
|
|
31022
31081
|
* @param {number} y y axis of the coordinate for the rectangle starting point.
|
|
31023
31082
|
* @param {number} width The rectangle's width.
|
|
@@ -31051,7 +31110,7 @@
|
|
|
31051
31110
|
uvs[1],
|
|
31052
31111
|
uvs[2],
|
|
31053
31112
|
uvs[3],
|
|
31054
|
-
this.currentTint.toUint32()
|
|
31113
|
+
this.currentTint.toUint32(this.getGlobalAlpha())
|
|
31055
31114
|
);
|
|
31056
31115
|
|
|
31057
31116
|
// Clear font context2D
|
|
@@ -31065,8 +31124,6 @@
|
|
|
31065
31124
|
|
|
31066
31125
|
/**
|
|
31067
31126
|
* Draw an image to the gl context
|
|
31068
|
-
* @name drawImage
|
|
31069
|
-
* @memberof WebGLRenderer
|
|
31070
31127
|
* @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.
|
|
31071
31128
|
* @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.
|
|
31072
31129
|
* @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.
|
|
@@ -31112,13 +31169,11 @@
|
|
|
31112
31169
|
|
|
31113
31170
|
var texture = this.cache.get(image);
|
|
31114
31171
|
var uvs = texture.getUVs(sx + "," + sy + "," + sw + "," + sh);
|
|
31115
|
-
this.currentCompositor.addQuad(texture, dx, dy, dw, dh, uvs[0], uvs[1], uvs[2], uvs[3], this.currentTint.toUint32());
|
|
31172
|
+
this.currentCompositor.addQuad(texture, dx, dy, dw, dh, uvs[0], uvs[1], uvs[2], uvs[3], this.currentTint.toUint32(this.getGlobalAlpha()));
|
|
31116
31173
|
};
|
|
31117
31174
|
|
|
31118
31175
|
/**
|
|
31119
31176
|
* Draw a pattern within the given rectangle.
|
|
31120
|
-
* @name drawPattern
|
|
31121
|
-
* @memberof WebGLRenderer
|
|
31122
31177
|
* @param {TextureAtlas} pattern Pattern object
|
|
31123
31178
|
* @param {number} x
|
|
31124
31179
|
* @param {number} y
|
|
@@ -31128,29 +31183,18 @@
|
|
|
31128
31183
|
*/
|
|
31129
31184
|
WebGLRenderer.prototype.drawPattern = function drawPattern (pattern, x, y, width, height) {
|
|
31130
31185
|
var uvs = pattern.getUVs("0,0," + width + "," + height);
|
|
31131
|
-
this.currentCompositor.addQuad(pattern, x, y, width, height, uvs[0], uvs[1], uvs[2], uvs[3], this.currentTint.toUint32());
|
|
31186
|
+
this.currentCompositor.addQuad(pattern, x, y, width, height, uvs[0], uvs[1], uvs[2], uvs[3], this.currentTint.toUint32(this.getGlobalAlpha()));
|
|
31132
31187
|
};
|
|
31133
31188
|
|
|
31134
|
-
|
|
31135
31189
|
/**
|
|
31136
|
-
*
|
|
31137
|
-
* @name getScreenContext
|
|
31138
|
-
* @memberof WebGLRenderer
|
|
31139
|
-
* @returns {WebGLRenderingContext}
|
|
31140
|
-
*/
|
|
31141
|
-
WebGLRenderer.prototype.getScreenContext = function getScreenContext () {
|
|
31142
|
-
return this.gl;
|
|
31143
|
-
};
|
|
31144
|
-
|
|
31145
|
-
/**
|
|
31146
|
-
* Returns the WebGL Context object of the given Canvas
|
|
31147
|
-
* @name getContextGL
|
|
31148
|
-
* @memberof WebGLRenderer
|
|
31190
|
+
* Returns the WebGL Context object of the given canvas element
|
|
31149
31191
|
* @param {HTMLCanvasElement} canvas
|
|
31150
|
-
* @param {boolean} [transparent=
|
|
31192
|
+
* @param {boolean} [transparent=false] use true to enable transparency
|
|
31151
31193
|
* @returns {WebGLRenderingContext}
|
|
31152
31194
|
*/
|
|
31153
31195
|
WebGLRenderer.prototype.getContextGL = function getContextGL (canvas, transparent) {
|
|
31196
|
+
if ( transparent === void 0 ) transparent = false;
|
|
31197
|
+
|
|
31154
31198
|
if (typeof canvas === "undefined" || canvas === null) {
|
|
31155
31199
|
throw new Error(
|
|
31156
31200
|
"You must pass a canvas element in order to create " +
|
|
@@ -31158,17 +31202,13 @@
|
|
|
31158
31202
|
);
|
|
31159
31203
|
}
|
|
31160
31204
|
|
|
31161
|
-
if (typeof transparent !== "boolean") {
|
|
31162
|
-
transparent = true;
|
|
31163
|
-
}
|
|
31164
|
-
|
|
31165
31205
|
var attr = {
|
|
31166
31206
|
alpha : transparent,
|
|
31167
31207
|
antialias : this.settings.antiAlias,
|
|
31168
31208
|
depth : false,
|
|
31169
31209
|
stencil: true,
|
|
31170
31210
|
preserveDrawingBuffer : false,
|
|
31171
|
-
premultipliedAlpha: transparent,
|
|
31211
|
+
premultipliedAlpha: transparent ? this.settings.premultipliedAlpha : false,
|
|
31172
31212
|
powerPreference: this.settings.powerPreference,
|
|
31173
31213
|
failIfMajorPerformanceCaveat : this.settings.failIfMajorPerformanceCaveat
|
|
31174
31214
|
};
|
|
@@ -31201,8 +31241,6 @@
|
|
|
31201
31241
|
/**
|
|
31202
31242
|
* Returns the WebGLContext instance for the renderer
|
|
31203
31243
|
* return a reference to the system 2d Context
|
|
31204
|
-
* @name getContext
|
|
31205
|
-
* @memberof WebGLRenderer
|
|
31206
31244
|
* @returns {WebGLRenderingContext}
|
|
31207
31245
|
*/
|
|
31208
31246
|
WebGLRenderer.prototype.getContext = function getContext () {
|
|
@@ -31220,9 +31258,7 @@
|
|
|
31220
31258
|
* <img src="images/lighter-blendmode.png" width="510"/> <br>
|
|
31221
31259
|
* - "screen" : The pixels are inverted, multiplied, and inverted again. A lighter picture is the result (opposite of multiply) <br>
|
|
31222
31260
|
* <img src="images/screen-blendmode.png" width="510"/> <br>
|
|
31223
|
-
* @name setBlendMode
|
|
31224
31261
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
|
|
31225
|
-
* @memberof WebGLRenderer
|
|
31226
31262
|
* @param {string} [mode="normal"] blend mode : "normal", "multiply", "lighter", "additive", "screen"
|
|
31227
31263
|
* @param {WebGLRenderingContext} [gl]
|
|
31228
31264
|
*/
|
|
@@ -31274,8 +31310,6 @@
|
|
|
31274
31310
|
|
|
31275
31311
|
/**
|
|
31276
31312
|
* restores the canvas context
|
|
31277
|
-
* @name restore
|
|
31278
|
-
* @memberof WebGLRenderer
|
|
31279
31313
|
*/
|
|
31280
31314
|
WebGLRenderer.prototype.restore = function restore () {
|
|
31281
31315
|
// do nothing if there is no saved states
|
|
@@ -31302,15 +31336,13 @@
|
|
|
31302
31336
|
this.gl.disable(this.gl.SCISSOR_TEST);
|
|
31303
31337
|
this.currentScissor[0] = 0;
|
|
31304
31338
|
this.currentScissor[1] = 0;
|
|
31305
|
-
this.currentScissor[2] = this.
|
|
31306
|
-
this.currentScissor[3] = this.
|
|
31339
|
+
this.currentScissor[2] = this.getCanvas().width;
|
|
31340
|
+
this.currentScissor[3] = this.getCanvas().height;
|
|
31307
31341
|
}
|
|
31308
31342
|
};
|
|
31309
31343
|
|
|
31310
31344
|
/**
|
|
31311
31345
|
* saves the canvas context
|
|
31312
|
-
* @name save
|
|
31313
|
-
* @memberof WebGLRenderer
|
|
31314
31346
|
*/
|
|
31315
31347
|
WebGLRenderer.prototype.save = function save () {
|
|
31316
31348
|
this._colorStack.push(this.currentColor.clone());
|
|
@@ -31326,8 +31358,6 @@
|
|
|
31326
31358
|
|
|
31327
31359
|
/**
|
|
31328
31360
|
* rotates the uniform matrix
|
|
31329
|
-
* @name rotate
|
|
31330
|
-
* @memberof WebGLRenderer
|
|
31331
31361
|
* @param {number} angle in radians
|
|
31332
31362
|
*/
|
|
31333
31363
|
WebGLRenderer.prototype.rotate = function rotate (angle) {
|
|
@@ -31336,8 +31366,6 @@
|
|
|
31336
31366
|
|
|
31337
31367
|
/**
|
|
31338
31368
|
* scales the uniform matrix
|
|
31339
|
-
* @name scale
|
|
31340
|
-
* @memberof WebGLRenderer
|
|
31341
31369
|
* @param {number} x
|
|
31342
31370
|
* @param {number} y
|
|
31343
31371
|
*/
|
|
@@ -31356,8 +31384,6 @@
|
|
|
31356
31384
|
|
|
31357
31385
|
/**
|
|
31358
31386
|
* Set the global alpha
|
|
31359
|
-
* @name setGlobalAlpha
|
|
31360
|
-
* @memberof WebGLRenderer
|
|
31361
31387
|
* @param {number} alpha 0.0 to 1.0 values accepted.
|
|
31362
31388
|
*/
|
|
31363
31389
|
WebGLRenderer.prototype.setGlobalAlpha = function setGlobalAlpha (alpha) {
|
|
@@ -31366,8 +31392,6 @@
|
|
|
31366
31392
|
|
|
31367
31393
|
/**
|
|
31368
31394
|
* Return the global alpha
|
|
31369
|
-
* @name getGlobalAlpha
|
|
31370
|
-
* @memberof WebGLRenderer
|
|
31371
31395
|
* @returns {number} global alpha value
|
|
31372
31396
|
*/
|
|
31373
31397
|
WebGLRenderer.prototype.getGlobalAlpha = function getGlobalAlpha () {
|
|
@@ -31377,8 +31401,6 @@
|
|
|
31377
31401
|
/**
|
|
31378
31402
|
* Set the current fill & stroke style color.
|
|
31379
31403
|
* By default, or upon reset, the value is set to #000000.
|
|
31380
|
-
* @name setColor
|
|
31381
|
-
* @memberof WebGLRenderer
|
|
31382
31404
|
* @param {Color|string} color css color string.
|
|
31383
31405
|
*/
|
|
31384
31406
|
WebGLRenderer.prototype.setColor = function setColor (color) {
|
|
@@ -31389,18 +31411,14 @@
|
|
|
31389
31411
|
|
|
31390
31412
|
/**
|
|
31391
31413
|
* Set the line width
|
|
31392
|
-
* @name setLineWidth
|
|
31393
|
-
* @memberof WebGLRenderer
|
|
31394
31414
|
* @param {number} width Line width
|
|
31395
31415
|
*/
|
|
31396
31416
|
WebGLRenderer.prototype.setLineWidth = function setLineWidth (width) {
|
|
31397
|
-
this.
|
|
31417
|
+
this.getContext().lineWidth(width);
|
|
31398
31418
|
};
|
|
31399
31419
|
|
|
31400
31420
|
/**
|
|
31401
31421
|
* Stroke an arc at the specified coordinates with given radius, start and end points
|
|
31402
|
-
* @name strokeArc
|
|
31403
|
-
* @memberof WebGLRenderer
|
|
31404
31422
|
* @param {number} x arc center point x-axis
|
|
31405
31423
|
* @param {number} y arc center point y-axis
|
|
31406
31424
|
* @param {number} radius
|
|
@@ -31429,8 +31447,6 @@
|
|
|
31429
31447
|
|
|
31430
31448
|
/**
|
|
31431
31449
|
* Fill an arc at the specified coordinates with given radius, start and end points
|
|
31432
|
-
* @name fillArc
|
|
31433
|
-
* @memberof WebGLRenderer
|
|
31434
31450
|
* @param {number} x arc center point x-axis
|
|
31435
31451
|
* @param {number} y arc center point y-axis
|
|
31436
31452
|
* @param {number} radius
|
|
@@ -31446,8 +31462,6 @@
|
|
|
31446
31462
|
|
|
31447
31463
|
/**
|
|
31448
31464
|
* Stroke an ellipse at the specified coordinates with given radius
|
|
31449
|
-
* @name strokeEllipse
|
|
31450
|
-
* @memberof WebGLRenderer
|
|
31451
31465
|
* @param {number} x ellipse center point x-axis
|
|
31452
31466
|
* @param {number} y ellipse center point y-axis
|
|
31453
31467
|
* @param {number} w horizontal radius of the ellipse
|
|
@@ -31473,8 +31487,6 @@
|
|
|
31473
31487
|
|
|
31474
31488
|
/**
|
|
31475
31489
|
* Fill an ellipse at the specified coordinates with given radius
|
|
31476
|
-
* @name fillEllipse
|
|
31477
|
-
* @memberof WebGLRenderer
|
|
31478
31490
|
* @param {number} x ellipse center point x-axis
|
|
31479
31491
|
* @param {number} y ellipse center point y-axis
|
|
31480
31492
|
* @param {number} w horizontal radius of the ellipse
|
|
@@ -31486,8 +31498,6 @@
|
|
|
31486
31498
|
|
|
31487
31499
|
/**
|
|
31488
31500
|
* Stroke a line of the given two points
|
|
31489
|
-
* @name strokeLine
|
|
31490
|
-
* @memberof WebGLRenderer
|
|
31491
31501
|
* @param {number} startX the start x coordinate
|
|
31492
31502
|
* @param {number} startY the start y coordinate
|
|
31493
31503
|
* @param {number} endX the end x coordinate
|
|
@@ -31507,8 +31517,6 @@
|
|
|
31507
31517
|
|
|
31508
31518
|
/**
|
|
31509
31519
|
* Fill a line of the given two points
|
|
31510
|
-
* @name fillLine
|
|
31511
|
-
* @memberof WebGLRenderer
|
|
31512
31520
|
* @param {number} startX the start x coordinate
|
|
31513
31521
|
* @param {number} startY the start y coordinate
|
|
31514
31522
|
* @param {number} endX the end x coordinate
|
|
@@ -31520,8 +31528,6 @@
|
|
|
31520
31528
|
|
|
31521
31529
|
/**
|
|
31522
31530
|
* Stroke a me.Polygon on the screen with a specified color
|
|
31523
|
-
* @name strokePolygon
|
|
31524
|
-
* @memberof WebGLRenderer
|
|
31525
31531
|
* @param {Polygon} poly the shape to draw
|
|
31526
31532
|
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
31527
31533
|
*/
|
|
@@ -31553,8 +31559,6 @@
|
|
|
31553
31559
|
|
|
31554
31560
|
/**
|
|
31555
31561
|
* Fill a me.Polygon on the screen
|
|
31556
|
-
* @name fillPolygon
|
|
31557
|
-
* @memberof WebGLRenderer
|
|
31558
31562
|
* @param {Polygon} poly the shape to draw
|
|
31559
31563
|
*/
|
|
31560
31564
|
WebGLRenderer.prototype.fillPolygon = function fillPolygon (poly) {
|
|
@@ -31563,8 +31567,6 @@
|
|
|
31563
31567
|
|
|
31564
31568
|
/**
|
|
31565
31569
|
* Draw a stroke rectangle at the specified coordinates
|
|
31566
|
-
* @name strokeRect
|
|
31567
|
-
* @memberof WebGLRenderer
|
|
31568
31570
|
* @param {number} x
|
|
31569
31571
|
* @param {number} y
|
|
31570
31572
|
* @param {number} width
|
|
@@ -31589,8 +31591,6 @@
|
|
|
31589
31591
|
|
|
31590
31592
|
/**
|
|
31591
31593
|
* Draw a filled rectangle at the specified coordinates
|
|
31592
|
-
* @name fillRect
|
|
31593
|
-
* @memberof WebGLRenderer
|
|
31594
31594
|
* @param {number} x
|
|
31595
31595
|
* @param {number} y
|
|
31596
31596
|
* @param {number} width
|
|
@@ -31602,8 +31602,6 @@
|
|
|
31602
31602
|
|
|
31603
31603
|
/**
|
|
31604
31604
|
* Stroke a rounded rectangle at the specified coordinates
|
|
31605
|
-
* @name strokeRoundRect
|
|
31606
|
-
* @memberof WebGLRenderer
|
|
31607
31605
|
* @param {number} x
|
|
31608
31606
|
* @param {number} y
|
|
31609
31607
|
* @param {number} width
|
|
@@ -31630,8 +31628,6 @@
|
|
|
31630
31628
|
|
|
31631
31629
|
/**
|
|
31632
31630
|
* Draw a rounded filled rectangle at the specified coordinates
|
|
31633
|
-
* @name fillRoundRect
|
|
31634
|
-
* @memberof WebGLRenderer
|
|
31635
31631
|
* @param {number} x
|
|
31636
31632
|
* @param {number} y
|
|
31637
31633
|
* @param {number} width
|
|
@@ -31642,11 +31638,29 @@
|
|
|
31642
31638
|
this.strokeRoundRect(x, y, width, height, radius, true);
|
|
31643
31639
|
};
|
|
31644
31640
|
|
|
31641
|
+
/**
|
|
31642
|
+
* Stroke a Point at the specified coordinates
|
|
31643
|
+
* @param {number} x
|
|
31644
|
+
* @param {number} y
|
|
31645
|
+
*/
|
|
31646
|
+
WebGLRenderer.prototype.strokePoint = function strokePoint (x, y) {
|
|
31647
|
+
this.strokeLine(x, y, x + 1, y + 1);
|
|
31648
|
+
};
|
|
31649
|
+
|
|
31650
|
+
/**
|
|
31651
|
+
* Draw a a point at the specified coordinates
|
|
31652
|
+
* @param {number} x
|
|
31653
|
+
* @param {number} y
|
|
31654
|
+
* @param {number} width
|
|
31655
|
+
* @param {number} height
|
|
31656
|
+
*/
|
|
31657
|
+
WebGLRenderer.prototype.fillPoint = function fillPoint (x, y) {
|
|
31658
|
+
this.strokePoint(x, y);
|
|
31659
|
+
};
|
|
31660
|
+
|
|
31645
31661
|
/**
|
|
31646
31662
|
* Reset (overrides) the renderer transformation matrix to the
|
|
31647
31663
|
* identity one, and then apply the given transformation matrix.
|
|
31648
|
-
* @name setTransform
|
|
31649
|
-
* @memberof WebGLRenderer
|
|
31650
31664
|
* @param {Matrix2d} mat2d Matrix to transform by
|
|
31651
31665
|
*/
|
|
31652
31666
|
WebGLRenderer.prototype.setTransform = function setTransform (mat2d) {
|
|
@@ -31656,8 +31670,6 @@
|
|
|
31656
31670
|
|
|
31657
31671
|
/**
|
|
31658
31672
|
* Multiply given matrix into the renderer tranformation matrix
|
|
31659
|
-
* @name transform
|
|
31660
|
-
* @memberof WebGLRenderer
|
|
31661
31673
|
* @param {Matrix2d} mat2d Matrix to transform by
|
|
31662
31674
|
*/
|
|
31663
31675
|
WebGLRenderer.prototype.transform = function transform (mat2d) {
|
|
@@ -31673,8 +31685,6 @@
|
|
|
31673
31685
|
|
|
31674
31686
|
/**
|
|
31675
31687
|
* Translates the uniform matrix by the given coordinates
|
|
31676
|
-
* @name translate
|
|
31677
|
-
* @memberof WebGLRenderer
|
|
31678
31688
|
* @param {number} x
|
|
31679
31689
|
* @param {number} y
|
|
31680
31690
|
*/
|
|
@@ -31695,15 +31705,13 @@
|
|
|
31695
31705
|
* You can however save the current region using the save(),
|
|
31696
31706
|
* and restore it (with the restore() method) any time in the future.
|
|
31697
31707
|
* (<u>this is an experimental feature !</u>)
|
|
31698
|
-
* @name clipRect
|
|
31699
|
-
* @memberof WebGLRenderer
|
|
31700
31708
|
* @param {number} x
|
|
31701
31709
|
* @param {number} y
|
|
31702
31710
|
* @param {number} width
|
|
31703
31711
|
* @param {number} height
|
|
31704
31712
|
*/
|
|
31705
31713
|
WebGLRenderer.prototype.clipRect = function clipRect (x, y, width, height) {
|
|
31706
|
-
var canvas = this.
|
|
31714
|
+
var canvas = this.getCanvas();
|
|
31707
31715
|
var gl = this.gl;
|
|
31708
31716
|
// if requested box is different from the current canvas size
|
|
31709
31717
|
if (x !== 0 || y !== 0 || width !== canvas.width || height !== canvas.height) {
|
|
@@ -31742,8 +31750,6 @@
|
|
|
31742
31750
|
* A mask limits rendering elements to the shape and position of the given mask object.
|
|
31743
31751
|
* So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
|
|
31744
31752
|
* Mask are not preserved through renderer context save and restore.
|
|
31745
|
-
* @name setMask
|
|
31746
|
-
* @memberof WebGLRenderer
|
|
31747
31753
|
* @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] a shape defining the mask to be applied
|
|
31748
31754
|
* @param {boolean} [invert=false] either the given shape should define what is visible (default) or the opposite
|
|
31749
31755
|
*/
|
|
@@ -31759,8 +31765,6 @@
|
|
|
31759
31765
|
// Enable and setup GL state to write to stencil buffer
|
|
31760
31766
|
gl.enable(gl.STENCIL_TEST);
|
|
31761
31767
|
gl.clear(gl.STENCIL_BUFFER_BIT);
|
|
31762
|
-
|
|
31763
|
-
|
|
31764
31768
|
}
|
|
31765
31769
|
|
|
31766
31770
|
this.maskLevel++;
|
|
@@ -31789,9 +31793,7 @@
|
|
|
31789
31793
|
|
|
31790
31794
|
/**
|
|
31791
31795
|
* disable (remove) the rendering mask set through setMask.
|
|
31792
|
-
* @name clearMask
|
|
31793
31796
|
* @see WebGLRenderer#setMask
|
|
31794
|
-
* @memberof WebGLRenderer
|
|
31795
31797
|
*/
|
|
31796
31798
|
WebGLRenderer.prototype.clearMask = function clearMask () {
|
|
31797
31799
|
if (this.maskLevel > 0) {
|
|
@@ -31818,11 +31820,11 @@
|
|
|
31818
31820
|
var settings = {
|
|
31819
31821
|
parent : undefined,
|
|
31820
31822
|
renderer : 2, // AUTO
|
|
31821
|
-
doubleBuffering : false,
|
|
31822
31823
|
autoScale : false,
|
|
31823
31824
|
scale : 1.0,
|
|
31824
|
-
scaleMethod : "
|
|
31825
|
+
scaleMethod : "manual",
|
|
31825
31826
|
transparent : false,
|
|
31827
|
+
premultipliedAlpha: true,
|
|
31826
31828
|
blendMode : "normal",
|
|
31827
31829
|
antiAlias : false,
|
|
31828
31830
|
failIfMajorPerformanceCaveat : true,
|
|
@@ -31862,7 +31864,7 @@
|
|
|
31862
31864
|
var canvasMaxHeight = Infinity;
|
|
31863
31865
|
|
|
31864
31866
|
if (globalThis.getComputedStyle) {
|
|
31865
|
-
var style = globalThis.getComputedStyle(renderer.
|
|
31867
|
+
var style = globalThis.getComputedStyle(renderer.getCanvas(), null);
|
|
31866
31868
|
canvasMaxWidth = parseInt(style.maxWidth, 10) || Infinity;
|
|
31867
31869
|
canvasMaxHeight = parseInt(style.maxHeight, 10) || Infinity;
|
|
31868
31870
|
}
|
|
@@ -31916,6 +31918,9 @@
|
|
|
31916
31918
|
|
|
31917
31919
|
// adjust scaling ratio based on the new scaling ratio
|
|
31918
31920
|
scale(scaleX, scaleY);
|
|
31921
|
+
} else {
|
|
31922
|
+
// adjust scaling ratio based on the given settings
|
|
31923
|
+
scale(settings.scale, settings.scale);
|
|
31919
31924
|
}
|
|
31920
31925
|
}
|
|
31921
31926
|
/**
|
|
@@ -31992,7 +31997,6 @@
|
|
|
31992
31997
|
* @param {object} [options] The optional video/renderer parameters.<br> (see Renderer(s) documentation for further specific options)
|
|
31993
31998
|
* @param {string|HTMLElement} [options.parent=document.body] the DOM parent element to hold the canvas in the HTML file
|
|
31994
31999
|
* @param {number} [options.renderer=video.AUTO] renderer to use (me.video.CANVAS, me.video.WEBGL, me.video.AUTO)
|
|
31995
|
-
* @param {boolean} [options.doubleBuffering=false] enable/disable double buffering
|
|
31996
32000
|
* @param {number|string} [options.scale=1.0] enable scaling of the canvas ('auto' for automatic scaling)
|
|
31997
32001
|
* @param {string} [options.scaleMethod="fit"] screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
|
|
31998
32002
|
* @param {boolean} [options.preferWebGL1=false] if true the renderer will only use WebGL 1
|
|
@@ -32007,8 +32011,7 @@
|
|
|
32007
32011
|
* parent : "screen",
|
|
32008
32012
|
* renderer : me.video.AUTO,
|
|
32009
32013
|
* scale : "auto",
|
|
32010
|
-
* scaleMethod : "fit"
|
|
32011
|
-
* doubleBuffering : true
|
|
32014
|
+
* scaleMethod : "fit"
|
|
32012
32015
|
* });
|
|
32013
32016
|
*/
|
|
32014
32017
|
function init(width, height, options) {
|
|
@@ -32024,7 +32027,6 @@
|
|
|
32024
32027
|
// sanitize potential given parameters
|
|
32025
32028
|
settings.width = width;
|
|
32026
32029
|
settings.height = height;
|
|
32027
|
-
settings.doubleBuffering = !!(settings.doubleBuffering);
|
|
32028
32030
|
settings.transparent = !!(settings.transparent);
|
|
32029
32031
|
settings.antiAlias = !!(settings.antiAlias);
|
|
32030
32032
|
settings.failIfMajorPerformanceCaveat = !!(settings.failIfMajorPerformanceCaveat);
|
|
@@ -32044,24 +32046,21 @@
|
|
|
32044
32046
|
console.log("melonJS 2 (v" + version + ") | http://melonjs.org" );
|
|
32045
32047
|
}
|
|
32046
32048
|
|
|
32047
|
-
// override renderer settings if &webgl is defined in the URL
|
|
32049
|
+
// override renderer settings if &webgl or &canvas is defined in the URL
|
|
32048
32050
|
var uriFragment = utils.getUriFragment();
|
|
32049
32051
|
if (uriFragment.webgl === true || uriFragment.webgl1 === true || uriFragment.webgl2 === true) {
|
|
32050
32052
|
settings.renderer = WEBGL;
|
|
32051
32053
|
if (uriFragment.webgl1 === true) {
|
|
32052
32054
|
settings.preferWebGL1 = true;
|
|
32053
32055
|
}
|
|
32056
|
+
} else if (uriFragment.canvas === true) {
|
|
32057
|
+
settings.renderer = CANVAS;
|
|
32054
32058
|
}
|
|
32055
32059
|
|
|
32056
32060
|
// normalize scale
|
|
32057
32061
|
settings.scale = (settings.autoScale) ? 1.0 : (+settings.scale || 1.0);
|
|
32058
32062
|
scaleRatio.set(settings.scale, settings.scale);
|
|
32059
32063
|
|
|
32060
|
-
// force double buffering if scaling is required
|
|
32061
|
-
if (settings.autoScale || (settings.scale !== 1.0)) {
|
|
32062
|
-
settings.doubleBuffering = true;
|
|
32063
|
-
}
|
|
32064
|
-
|
|
32065
32064
|
// hold the requested video size ratio
|
|
32066
32065
|
designRatio = width / height;
|
|
32067
32066
|
designWidth = width;
|
|
@@ -32133,7 +32132,7 @@
|
|
|
32133
32132
|
|
|
32134
32133
|
// add our canvas (default to document.body if settings.parent is undefined)
|
|
32135
32134
|
parent = getElement(typeof settings.parent !== "undefined" ? settings.parent : document.body);
|
|
32136
|
-
parent.appendChild(renderer.
|
|
32135
|
+
parent.appendChild(renderer.getCanvas());
|
|
32137
32136
|
|
|
32138
32137
|
// Mobile browser hacks
|
|
32139
32138
|
if (platform.isMobile) {
|
|
@@ -32229,8 +32228,8 @@
|
|
|
32229
32228
|
* @param {number} y y scaling multiplier
|
|
32230
32229
|
*/
|
|
32231
32230
|
function scale(x, y) {
|
|
32232
|
-
var canvas = renderer.
|
|
32233
|
-
var context = renderer.
|
|
32231
|
+
var canvas = renderer.getCanvas();
|
|
32232
|
+
var context = renderer.getContext();
|
|
32234
32233
|
var settings = renderer.settings;
|
|
32235
32234
|
var pixelRatio = devicePixelRatio;
|
|
32236
32235
|
|
|
@@ -32990,10 +32989,10 @@
|
|
|
32990
32989
|
* this can be overridden by the plugin
|
|
32991
32990
|
* @public
|
|
32992
32991
|
* @type {string}
|
|
32993
|
-
* @default "13.
|
|
32992
|
+
* @default "13.2.0"
|
|
32994
32993
|
* @name plugin.Base#version
|
|
32995
32994
|
*/
|
|
32996
|
-
this.version = "13.
|
|
32995
|
+
this.version = "13.2.0";
|
|
32997
32996
|
};
|
|
32998
32997
|
|
|
32999
32998
|
/**
|
|
@@ -33993,7 +33992,8 @@
|
|
|
33993
33992
|
var defaultAttributes = {
|
|
33994
33993
|
offscreenCanvas : false,
|
|
33995
33994
|
willReadFrequently : false,
|
|
33996
|
-
antiAlias : false
|
|
33995
|
+
antiAlias : false,
|
|
33996
|
+
context: "2d"
|
|
33997
33997
|
};
|
|
33998
33998
|
|
|
33999
33999
|
/**
|
|
@@ -34222,7 +34222,7 @@
|
|
|
34222
34222
|
this.width = this.height = 0;
|
|
34223
34223
|
|
|
34224
34224
|
for (var i = 0; i < strings.length; i++) {
|
|
34225
|
-
this.width = Math.max(this.lineWidth(strings[i].
|
|
34225
|
+
this.width = Math.max(this.lineWidth(strings[i].trimEnd(), context), this.width);
|
|
34226
34226
|
this.height += this.lineHeight();
|
|
34227
34227
|
}
|
|
34228
34228
|
this.width = Math.ceil(this.width);
|
|
@@ -34696,7 +34696,7 @@
|
|
|
34696
34696
|
setContextStyle(context, this, stroke);
|
|
34697
34697
|
|
|
34698
34698
|
for (var i = 0; i < text.length; i++) {
|
|
34699
|
-
var string = text[i].
|
|
34699
|
+
var string = text[i].trimEnd();
|
|
34700
34700
|
// draw the string
|
|
34701
34701
|
context[stroke ? "strokeText" : "fillText"](string, x, y);
|
|
34702
34702
|
// add leading space
|
|
@@ -34814,12 +34814,7 @@
|
|
|
34814
34814
|
|
|
34815
34815
|
// apply given fillstyle
|
|
34816
34816
|
if (typeof settings.fillStyle !== "undefined") {
|
|
34817
|
-
|
|
34818
|
-
this.fillStyle.setColor(settings.fillStyle);
|
|
34819
|
-
} else {
|
|
34820
|
-
// string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
|
|
34821
|
-
this.fillStyle.parseCSS(settings.fillStyle);
|
|
34822
|
-
}
|
|
34817
|
+
this.fillStyle = settings.fillStyle;
|
|
34823
34818
|
}
|
|
34824
34819
|
|
|
34825
34820
|
// update anchorPoint if provided
|
|
@@ -34900,7 +34895,12 @@
|
|
|
34900
34895
|
return this.tint;
|
|
34901
34896
|
};
|
|
34902
34897
|
prototypeAccessors.fillStyle.set = function (value) {
|
|
34903
|
-
|
|
34898
|
+
if (value instanceof Color) {
|
|
34899
|
+
this.tint.copy(value);
|
|
34900
|
+
} else {
|
|
34901
|
+
// string (#RGB, #ARGB, #RRGGBB, #AARRGGBB)
|
|
34902
|
+
this.tint.parseCSS(value);
|
|
34903
|
+
}
|
|
34904
34904
|
};
|
|
34905
34905
|
|
|
34906
34906
|
/**
|
|
@@ -34959,7 +34959,7 @@
|
|
|
34959
34959
|
|
|
34960
34960
|
for (var i = 0; i < this._text.length; i++) {
|
|
34961
34961
|
x = lX;
|
|
34962
|
-
var string = this._text[i].
|
|
34962
|
+
var string = this._text[i].trimEnd();
|
|
34963
34963
|
// adjust x pos based on alignment value
|
|
34964
34964
|
var stringWidth = this.metrics.lineWidth(string);
|
|
34965
34965
|
switch (this.textAlign) {
|
|
@@ -35663,7 +35663,7 @@
|
|
|
35663
35663
|
this.width = Math.floor(settings.width);
|
|
35664
35664
|
this.height = Math.floor(settings.height);
|
|
35665
35665
|
|
|
35666
|
-
// nine slice sprite specific
|
|
35666
|
+
// nine slice sprite specific internal variables
|
|
35667
35667
|
this.nss_width = this.width;
|
|
35668
35668
|
this.nss_height = this.height;
|
|
35669
35669
|
|
|
@@ -35675,6 +35675,34 @@
|
|
|
35675
35675
|
NineSliceSprite.prototype = Object.create( Sprite && Sprite.prototype );
|
|
35676
35676
|
NineSliceSprite.prototype.constructor = NineSliceSprite;
|
|
35677
35677
|
|
|
35678
|
+
var prototypeAccessors = { width: { configurable: true },height: { configurable: true } };
|
|
35679
|
+
|
|
35680
|
+
/**
|
|
35681
|
+
* width of the NineSliceSprite
|
|
35682
|
+
* @public
|
|
35683
|
+
* @type {number}
|
|
35684
|
+
* @name width
|
|
35685
|
+
*/
|
|
35686
|
+
prototypeAccessors.width.get = function () {
|
|
35687
|
+
return Sprite.prototype.width;
|
|
35688
|
+
};
|
|
35689
|
+
prototypeAccessors.width.set = function (value) {
|
|
35690
|
+
Sprite.prototype.width = this.nss_width = value;
|
|
35691
|
+
};
|
|
35692
|
+
|
|
35693
|
+
/**
|
|
35694
|
+
* height of the NineSliceSprite
|
|
35695
|
+
* @public
|
|
35696
|
+
* @type {number}
|
|
35697
|
+
* @name height
|
|
35698
|
+
*/
|
|
35699
|
+
prototypeAccessors.height.get = function () {
|
|
35700
|
+
return Sprite.prototype.height;
|
|
35701
|
+
};
|
|
35702
|
+
prototypeAccessors.height.set = function (value) {
|
|
35703
|
+
Sprite.prototype.height = this.nss_height = value;
|
|
35704
|
+
};
|
|
35705
|
+
|
|
35678
35706
|
/**
|
|
35679
35707
|
* @ignore
|
|
35680
35708
|
*/
|
|
@@ -35829,6 +35857,8 @@
|
|
|
35829
35857
|
);
|
|
35830
35858
|
};
|
|
35831
35859
|
|
|
35860
|
+
Object.defineProperties( NineSliceSprite.prototype, prototypeAccessors );
|
|
35861
|
+
|
|
35832
35862
|
return NineSliceSprite;
|
|
35833
35863
|
}(Sprite));
|
|
35834
35864
|
|
|
@@ -37579,7 +37609,6 @@
|
|
|
37579
37609
|
}
|
|
37580
37610
|
});
|
|
37581
37611
|
|
|
37582
|
-
|
|
37583
37612
|
/**
|
|
37584
37613
|
* @classdesc
|
|
37585
37614
|
* Used to make a game entity draggable
|
|
@@ -37620,6 +37649,33 @@
|
|
|
37620
37649
|
return DroptargetEntity;
|
|
37621
37650
|
}(DropTarget));
|
|
37622
37651
|
|
|
37652
|
+
/**
|
|
37653
|
+
* return a reference to the screen canvas
|
|
37654
|
+
* @name getScreenCanvas
|
|
37655
|
+
* @memberof Renderer
|
|
37656
|
+
* @returns {HTMLCanvasElement}
|
|
37657
|
+
* @deprecated since 13.1.0
|
|
37658
|
+
* @see getCanvas();
|
|
37659
|
+
*/
|
|
37660
|
+
Renderer.prototype.getScreenCanvas = function() {
|
|
37661
|
+
warning("getScreenCanvas", "getCanvas", "13.1.0");
|
|
37662
|
+
return this.getCanvas();
|
|
37663
|
+
};
|
|
37664
|
+
|
|
37665
|
+
/**
|
|
37666
|
+
* return a reference to the screen canvas corresponding 2d Context<br>
|
|
37667
|
+
* (will return buffered context if double buffering is enabled, or a reference to the Screen Context)
|
|
37668
|
+
* @name getScreenContext
|
|
37669
|
+
* @memberof Renderer
|
|
37670
|
+
* @returns {CanvasRenderingContext2D}
|
|
37671
|
+
* @deprecated since 13.1.0
|
|
37672
|
+
* @see getContext();
|
|
37673
|
+
*/
|
|
37674
|
+
Renderer.prototype.getScreenContext = function() {
|
|
37675
|
+
warning("getScreenContext", "getContext", "13.1.0");
|
|
37676
|
+
return this.getContext();
|
|
37677
|
+
};
|
|
37678
|
+
|
|
37623
37679
|
// ES5/ES6 polyfills
|
|
37624
37680
|
|
|
37625
37681
|
|
|
@@ -37630,7 +37686,7 @@
|
|
|
37630
37686
|
* @name version
|
|
37631
37687
|
* @type {string}
|
|
37632
37688
|
*/
|
|
37633
|
-
var version = "13.
|
|
37689
|
+
var version = "13.2.0";
|
|
37634
37690
|
|
|
37635
37691
|
|
|
37636
37692
|
/**
|
|
@@ -37689,6 +37745,7 @@
|
|
|
37689
37745
|
pool.register("me.RoundRect", RoundRect, true);
|
|
37690
37746
|
pool.register("me.Polygon", Polygon, true);
|
|
37691
37747
|
pool.register("me.Line", Line, true);
|
|
37748
|
+
pool.register("me.Point", Point, true);
|
|
37692
37749
|
pool.register("me.Ellipse", Ellipse, true);
|
|
37693
37750
|
pool.register("me.Bounds", Bounds, true);
|
|
37694
37751
|
|
|
@@ -37718,6 +37775,7 @@
|
|
|
37718
37775
|
pool.register("RoundRect", RoundRect, true);
|
|
37719
37776
|
pool.register("Polygon", Polygon, true);
|
|
37720
37777
|
pool.register("Line", Line, true);
|
|
37778
|
+
pool.register("Point", Point, true);
|
|
37721
37779
|
pool.register("Ellipse", Ellipse, true);
|
|
37722
37780
|
pool.register("Bounds", Bounds, true);
|
|
37723
37781
|
pool.register("CanvasTexture", CanvasTexture, true);
|
|
@@ -37771,6 +37829,7 @@
|
|
|
37771
37829
|
exports.Particle = Particle;
|
|
37772
37830
|
exports.ParticleEmitter = ParticleEmitter;
|
|
37773
37831
|
exports.ParticleEmitterSettings = ParticleEmitterSettings;
|
|
37832
|
+
exports.Point = Point;
|
|
37774
37833
|
exports.Pointer = Pointer;
|
|
37775
37834
|
exports.Polygon = Polygon;
|
|
37776
37835
|
exports.QuadTree = QuadTree;
|