melonjs 10.2.3 → 10.5.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/README.md +6 -6
- package/dist/melonjs.js +3620 -3582
- package/dist/melonjs.min.js +5 -5
- package/dist/melonjs.module.d.ts +3646 -4545
- package/dist/melonjs.module.js +3912 -3521
- package/package.json +21 -20
- package/src/audio/audio.js +30 -31
- package/src/camera/camera2d.js +47 -58
- package/src/entity/entity.js +32 -38
- package/src/game.js +21 -22
- package/src/{shapes → geometries}/ellipse.js +40 -47
- package/src/{shapes → geometries}/line.js +9 -12
- package/src/{shapes → geometries}/poly.js +100 -53
- package/src/{shapes → geometries}/rectangle.js +42 -45
- package/src/index.js +14 -32
- package/src/input/gamepad.js +11 -10
- package/src/input/input.js +2 -3
- package/src/input/keyboard.js +113 -113
- package/src/input/pointer.js +61 -29
- package/src/input/pointerevent.js +92 -29
- package/src/lang/deprecated.js +83 -13
- package/src/level/level.js +23 -24
- package/src/level/tiled/TMXGroup.js +7 -9
- package/src/level/tiled/TMXLayer.js +30 -33
- package/src/level/tiled/TMXObject.js +59 -53
- package/src/level/tiled/TMXTile.js +18 -19
- package/src/level/tiled/TMXTileMap.js +40 -46
- package/src/level/tiled/TMXTileset.js +12 -16
- package/src/level/tiled/TMXTilesetGroup.js +9 -10
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -9
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -9
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -6
- package/src/level/tiled/renderer/TMXRenderer.js +24 -26
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -5
- package/src/loader/loader.js +17 -16
- package/src/loader/loadingscreen.js +2 -5
- package/src/math/color.js +47 -67
- package/src/math/math.js +15 -16
- package/src/math/matrix2.js +53 -59
- package/src/math/matrix3.js +56 -63
- package/src/math/observable_vector2.js +87 -77
- package/src/math/observable_vector3.js +97 -80
- package/src/math/vector2.js +107 -97
- package/src/math/vector3.js +116 -100
- package/src/particles/emitter.js +66 -76
- package/src/particles/particle.js +4 -6
- package/src/particles/particlecontainer.js +2 -4
- package/src/physics/body.js +49 -147
- package/src/physics/bounds.js +48 -50
- package/src/physics/collision.js +13 -14
- package/src/physics/detector.js +18 -17
- package/src/physics/quadtree.js +17 -20
- package/src/physics/sat.js +30 -30
- package/src/physics/world.js +24 -29
- package/src/plugin/plugin.js +11 -15
- package/src/renderable/GUI.js +41 -47
- package/src/renderable/collectable.js +5 -10
- package/src/renderable/colorlayer.js +10 -15
- package/src/renderable/container.js +87 -73
- package/src/renderable/dragndrop.js +224 -0
- package/src/renderable/imagelayer.js +25 -32
- package/src/renderable/nineslicesprite.js +41 -42
- package/src/renderable/renderable.js +113 -124
- package/src/renderable/sprite.js +62 -69
- package/src/renderable/trigger.js +26 -32
- package/src/state/stage.js +13 -18
- package/src/state/state.js +26 -27
- package/src/system/device.js +76 -133
- package/src/system/event.js +81 -70
- package/src/system/pooling.js +11 -12
- package/src/system/save.js +3 -4
- package/src/system/timer.js +19 -20
- package/src/text/bitmaptext.js +57 -55
- package/src/text/bitmaptextdata.js +10 -11
- package/src/text/glyph.js +3 -0
- package/src/text/text.js +49 -55
- package/src/tweens/easing.js +1 -1
- package/src/tweens/interpolation.js +1 -1
- package/src/tweens/tween.js +44 -46
- package/src/utils/agent.js +3 -4
- package/src/utils/array.js +4 -5
- package/src/utils/file.js +3 -4
- package/src/utils/function.js +4 -5
- package/src/utils/string.js +7 -9
- package/src/utils/utils.js +4 -5
- package/src/video/canvas/canvas_renderer.js +60 -62
- package/src/video/renderer.js +53 -58
- package/src/video/texture.js +98 -112
- package/src/video/texture_cache.js +26 -10
- package/src/video/video.js +15 -16
- package/src/video/webgl/buffer/vertex.js +2 -2
- package/src/video/webgl/glshader.js +37 -39
- package/src/video/webgl/webgl_compositor.js +128 -101
- package/src/video/webgl/webgl_renderer.js +126 -106
- package/src/entity/draggable.js +0 -139
- package/src/entity/droptarget.js +0 -109
|
@@ -4,7 +4,7 @@ import Matrix2d from "./../../math/matrix2.js";
|
|
|
4
4
|
import WebGLCompositor from "./webgl_compositor.js";
|
|
5
5
|
import Renderer from "./../renderer.js";
|
|
6
6
|
import TextureCache from "./../texture_cache.js";
|
|
7
|
-
import {
|
|
7
|
+
import { TextureAtlas, createAtlas } from "./../texture.js";
|
|
8
8
|
import { createCanvas, renderer } from "./../video.js";
|
|
9
9
|
import * as event from "./../../system/event.js";
|
|
10
10
|
import pool from "./../../system/pooling.js";
|
|
@@ -14,27 +14,25 @@ import { isPowerOfTwo, nextPowerOfTwo, TAU } from "./../../math/math.js";
|
|
|
14
14
|
/**
|
|
15
15
|
* @classdesc
|
|
16
16
|
* a WebGL renderer object
|
|
17
|
-
* @
|
|
18
|
-
* @extends me.Renderer
|
|
19
|
-
* @memberOf me
|
|
20
|
-
* @constructor
|
|
21
|
-
* @param {object} options The renderer parameters
|
|
22
|
-
* @param {number} options.width The width of the canvas without scaling
|
|
23
|
-
* @param {number} options.height The height of the canvas without scaling
|
|
24
|
-
* @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
|
|
25
|
-
* @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering
|
|
26
|
-
* @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing
|
|
27
|
-
* @param {boolean} [options.failIfMajorPerformanceCaveat=true] If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
|
|
28
|
-
* @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
|
|
29
|
-
* @param {boolean} [options.subPixel=false] Whether to enable subpixel renderering (performance hit when enabled)
|
|
30
|
-
* @param {boolean} [options.preferWebGL1=false] if true the renderer will only use WebGL 1
|
|
31
|
-
* @param {string} [options.powerPreference="default"] a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context ("default", "high-performance", "low-power"). To be noted that Safari and Chrome (since version 80) both default to "low-power" to save battery life and improve the user experience on these dual-GPU machines.
|
|
32
|
-
* @param {number} [options.zoomX=width] The actual width of the canvas with scaling applied
|
|
33
|
-
* @param {number} [options.zoomY=height] The actual height of the canvas with scaling applied
|
|
34
|
-
* @param {me.WebGLCompositor} [options.compositor] A class that implements the compositor API
|
|
17
|
+
* @augments Renderer
|
|
35
18
|
*/
|
|
36
19
|
class WebGLRenderer extends Renderer {
|
|
37
|
-
|
|
20
|
+
/**
|
|
21
|
+
* @param {object} options The renderer parameters
|
|
22
|
+
* @param {number} options.width The width of the canvas without scaling
|
|
23
|
+
* @param {number} options.height The height of the canvas without scaling
|
|
24
|
+
* @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
|
|
25
|
+
* @param {boolean} [options.doubleBuffering=false] Whether to enable double buffering
|
|
26
|
+
* @param {boolean} [options.antiAlias=false] Whether to enable anti-aliasing
|
|
27
|
+
* @param {boolean} [options.failIfMajorPerformanceCaveat=true] If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
|
|
28
|
+
* @param {boolean} [options.transparent=false] Whether to enable transparency on the canvas (performance hit when enabled)
|
|
29
|
+
* @param {boolean} [options.subPixel=false] Whether to enable subpixel renderering (performance hit when enabled)
|
|
30
|
+
* @param {boolean} [options.preferWebGL1=false] if true the renderer will only use WebGL 1
|
|
31
|
+
* @param {string} [options.powerPreference="default"] a hint to the user agent indicating what configuration of GPU is suitable for the WebGL context ("default", "high-performance", "low-power"). To be noted that Safari and Chrome (since version 80) both default to "low-power" to save battery life and improve the user experience on these dual-GPU machines.
|
|
32
|
+
* @param {number} [options.zoomX=width] The actual width of the canvas with scaling applied
|
|
33
|
+
* @param {number} [options.zoomY=height] The actual height of the canvas with scaling applied
|
|
34
|
+
* @param {WebGLCompositor} [options.compositor] A class that implements the compositor API
|
|
35
|
+
*/
|
|
38
36
|
constructor(options) {
|
|
39
37
|
|
|
40
38
|
// parent contructor
|
|
@@ -43,7 +41,7 @@ class WebGLRenderer extends Renderer {
|
|
|
43
41
|
/**
|
|
44
42
|
* The WebGL version used by this renderer (1 or 2)
|
|
45
43
|
* @name WebGLVersion
|
|
46
|
-
* @
|
|
44
|
+
* @memberof WebGLRenderer
|
|
47
45
|
* @type {number}
|
|
48
46
|
* @default 1
|
|
49
47
|
* @readonly
|
|
@@ -53,7 +51,7 @@ class WebGLRenderer extends Renderer {
|
|
|
53
51
|
/**
|
|
54
52
|
* The vendor string of the underlying graphics driver.
|
|
55
53
|
* @name GPUVendor
|
|
56
|
-
* @
|
|
54
|
+
* @memberof WebGLRenderer
|
|
57
55
|
* @type {string}
|
|
58
56
|
* @default null
|
|
59
57
|
* @readonly
|
|
@@ -63,7 +61,7 @@ class WebGLRenderer extends Renderer {
|
|
|
63
61
|
/**
|
|
64
62
|
* The renderer string of the underlying graphics driver.
|
|
65
63
|
* @name GPURenderer
|
|
66
|
-
* @
|
|
64
|
+
* @memberof WebGLRenderer
|
|
67
65
|
* @type {string}
|
|
68
66
|
* @default null
|
|
69
67
|
* @readonly
|
|
@@ -73,7 +71,7 @@ class WebGLRenderer extends Renderer {
|
|
|
73
71
|
/**
|
|
74
72
|
* The WebGL context
|
|
75
73
|
* @name gl
|
|
76
|
-
* @
|
|
74
|
+
* @memberof WebGLRenderer
|
|
77
75
|
* type {WebGLRenderingContext}
|
|
78
76
|
*/
|
|
79
77
|
this.context = this.gl = this.getContextGL(this.getScreenCanvas(), options.transparent);
|
|
@@ -81,7 +79,7 @@ class WebGLRenderer extends Renderer {
|
|
|
81
79
|
/**
|
|
82
80
|
* Maximum number of texture unit supported under the current context
|
|
83
81
|
* @name maxTextures
|
|
84
|
-
* @
|
|
82
|
+
* @memberof WebGLRenderer
|
|
85
83
|
* @type {number}
|
|
86
84
|
* @readonly
|
|
87
85
|
*/
|
|
@@ -115,22 +113,31 @@ class WebGLRenderer extends Renderer {
|
|
|
115
113
|
/**
|
|
116
114
|
* The current transformation matrix used for transformations on the overall scene
|
|
117
115
|
* @name currentTransform
|
|
118
|
-
* @type {
|
|
119
|
-
* @
|
|
116
|
+
* @type {Matrix2d}
|
|
117
|
+
* @memberof WebGLRenderer#
|
|
120
118
|
*/
|
|
121
119
|
this.currentTransform = new Matrix2d();
|
|
122
120
|
|
|
123
121
|
/**
|
|
124
122
|
* The current compositor used by the renderer
|
|
125
123
|
* @name currentCompositor
|
|
126
|
-
* @type {
|
|
127
|
-
* @
|
|
124
|
+
* @type {WebGLCompositor}
|
|
125
|
+
* @memberof WebGLRenderer#
|
|
128
126
|
*/
|
|
129
127
|
this.currentCompositor = null;
|
|
130
128
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
/**
|
|
130
|
+
* The list of active compositors
|
|
131
|
+
* @name compositors
|
|
132
|
+
* @type {Map}
|
|
133
|
+
* @memberof WebGLRenderer#
|
|
134
|
+
*/
|
|
135
|
+
this.compositors = new Map();
|
|
136
|
+
|
|
137
|
+
// Create a default compositor
|
|
138
|
+
var compositor = new (this.settings.compositor || WebGLCompositor)(this);
|
|
139
|
+
this.compositors.set("default", compositor);
|
|
140
|
+
this.setCompositor(compositor);
|
|
134
141
|
|
|
135
142
|
|
|
136
143
|
// default WebGL state(s)
|
|
@@ -172,17 +179,21 @@ class WebGLRenderer extends Renderer {
|
|
|
172
179
|
/**
|
|
173
180
|
* Reset context state
|
|
174
181
|
* @name reset
|
|
175
|
-
* @
|
|
182
|
+
* @memberof WebGLRenderer.prototype
|
|
176
183
|
* @function
|
|
177
184
|
*/
|
|
178
185
|
reset() {
|
|
179
186
|
super.reset();
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
this.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
187
|
+
|
|
188
|
+
this.compositors.forEach((compositor) => {
|
|
189
|
+
if (this.isContextValid === false) {
|
|
190
|
+
// on context lost/restore
|
|
191
|
+
compositor.init(this);
|
|
192
|
+
} else {
|
|
193
|
+
compositor.reset();
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
186
197
|
this.gl.disable(this.gl.SCISSOR_TEST);
|
|
187
198
|
if (typeof this.fontContext2D !== "undefined" ) {
|
|
188
199
|
this.createFontTexture(this.cache);
|
|
@@ -191,25 +202,37 @@ class WebGLRenderer extends Renderer {
|
|
|
191
202
|
}
|
|
192
203
|
|
|
193
204
|
/**
|
|
194
|
-
*
|
|
205
|
+
* set the active compositor for this renderer
|
|
195
206
|
* @name setCompositor
|
|
196
207
|
* @function
|
|
197
|
-
* @param {WebGLCompositor} compositor a compositor instance
|
|
198
|
-
* @
|
|
208
|
+
* @param {WebGLCompositor|string} compositor a compositor name or instance
|
|
209
|
+
* @memberof WebGLRenderer.prototype
|
|
199
210
|
* @function
|
|
200
211
|
*/
|
|
201
|
-
setCompositor(compositor) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
this.
|
|
212
|
+
setCompositor(compositor = "default") {
|
|
213
|
+
|
|
214
|
+
if (typeof compositor === "string") {
|
|
215
|
+
compositor = this.compositors.get(compositor);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (typeof compositor === "undefined") {
|
|
219
|
+
throw new Error("Invalid WebGL Compositor");
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
if (this.currentCompositor !== compositor) {
|
|
223
|
+
if (this.currentCompositor !== null) {
|
|
224
|
+
// flush the current compositor
|
|
225
|
+
this.currentCompositor.flush();
|
|
226
|
+
}
|
|
227
|
+
// set given one as current
|
|
228
|
+
this.currentCompositor = compositor;
|
|
205
229
|
}
|
|
206
|
-
this.currentCompositor = compositor;
|
|
207
230
|
}
|
|
208
231
|
|
|
209
232
|
/**
|
|
210
233
|
* Reset the gl transform to identity
|
|
211
234
|
* @name resetTransform
|
|
212
|
-
* @
|
|
235
|
+
* @memberof WebGLRenderer.prototype
|
|
213
236
|
* @function
|
|
214
237
|
*/
|
|
215
238
|
resetTransform() {
|
|
@@ -244,7 +267,7 @@ class WebGLRenderer extends Renderer {
|
|
|
244
267
|
/**
|
|
245
268
|
* @ignore
|
|
246
269
|
*/
|
|
247
|
-
this.fontTexture = new
|
|
270
|
+
this.fontTexture = new TextureAtlas(createAtlas(canvas.width, canvas.height, "fontTexture"), image, cache);
|
|
248
271
|
this.currentCompositor.uploadTexture(this.fontTexture, 0, 0, 0);
|
|
249
272
|
|
|
250
273
|
} else {
|
|
@@ -256,12 +279,12 @@ class WebGLRenderer extends Renderer {
|
|
|
256
279
|
/**
|
|
257
280
|
* Create a pattern with the specified repetition
|
|
258
281
|
* @name createPattern
|
|
259
|
-
* @
|
|
282
|
+
* @memberof WebGLRenderer.prototype
|
|
260
283
|
* @function
|
|
261
284
|
* @param {Image} image Source image
|
|
262
285
|
* @param {string} repeat Define how the pattern should be repeated
|
|
263
|
-
* @returns {
|
|
264
|
-
* @see
|
|
286
|
+
* @returns {TextureAtlas}
|
|
287
|
+
* @see ImageLayer#repeat
|
|
265
288
|
* @example
|
|
266
289
|
* var tileable = renderer.createPattern(image, "repeat");
|
|
267
290
|
* var horizontal = renderer.createPattern(image, "repeat-x");
|
|
@@ -278,7 +301,7 @@ class WebGLRenderer extends Renderer {
|
|
|
278
301
|
);
|
|
279
302
|
}
|
|
280
303
|
|
|
281
|
-
var texture = new
|
|
304
|
+
var texture = new TextureAtlas(createAtlas(image.width, image.height, "pattern", repeat), image);
|
|
282
305
|
|
|
283
306
|
// FIXME: Remove old cache entry and texture when changing the repeat mode
|
|
284
307
|
this.currentCompositor.uploadTexture(texture);
|
|
@@ -289,7 +312,7 @@ class WebGLRenderer extends Renderer {
|
|
|
289
312
|
/**
|
|
290
313
|
* Flush the compositor to the frame buffer
|
|
291
314
|
* @name flush
|
|
292
|
-
* @
|
|
315
|
+
* @memberof WebGLRenderer.prototype
|
|
293
316
|
* @function
|
|
294
317
|
*/
|
|
295
318
|
flush() {
|
|
@@ -299,23 +322,22 @@ class WebGLRenderer extends Renderer {
|
|
|
299
322
|
/**
|
|
300
323
|
* Clears the gl context with the given color.
|
|
301
324
|
* @name clearColor
|
|
302
|
-
* @
|
|
325
|
+
* @memberof WebGLRenderer.prototype
|
|
303
326
|
* @function
|
|
304
|
-
* @param {
|
|
327
|
+
* @param {Color|string} [color="#000000"] CSS color.
|
|
305
328
|
* @param {boolean} [opaque=false] Allow transparency [default] or clear the surface completely [true]
|
|
306
329
|
*/
|
|
307
|
-
clearColor(color, opaque) {
|
|
330
|
+
clearColor(color = "#000000", opaque = false) {
|
|
308
331
|
var glArray;
|
|
309
332
|
|
|
310
|
-
this.save();
|
|
311
|
-
|
|
312
333
|
if (color instanceof Color) {
|
|
313
334
|
glArray = color.toArray();
|
|
314
335
|
} else {
|
|
336
|
+
var _color = pool.pull("me.Color");
|
|
315
337
|
// reuse temporary the renderer default color object
|
|
316
|
-
glArray =
|
|
338
|
+
glArray = _color.parseCSS(color).toArray();
|
|
339
|
+
pool.push(_color);
|
|
317
340
|
}
|
|
318
|
-
|
|
319
341
|
// clear gl context with the specified color
|
|
320
342
|
this.currentCompositor.clearColor(glArray[0], glArray[1], glArray[2], (opaque === true) ? 1.0 : glArray[3]);
|
|
321
343
|
this.currentCompositor.clear();
|
|
@@ -323,13 +345,12 @@ class WebGLRenderer extends Renderer {
|
|
|
323
345
|
// restore default clear Color black
|
|
324
346
|
this.currentCompositor.clearColor(0.0, 0.0, 0.0, 0.0);
|
|
325
347
|
|
|
326
|
-
this.restore();
|
|
327
348
|
}
|
|
328
349
|
|
|
329
350
|
/**
|
|
330
351
|
* Erase the pixels in the given rectangular area by setting them to transparent black (rgba(0,0,0,0)).
|
|
331
352
|
* @name clearRect
|
|
332
|
-
* @
|
|
353
|
+
* @memberof WebGLRenderer.prototype
|
|
333
354
|
* @function
|
|
334
355
|
* @param {number} x x axis of the coordinate for the rectangle starting point.
|
|
335
356
|
* @param {number} y y axis of the coordinate for the rectangle starting point.
|
|
@@ -337,11 +358,10 @@ class WebGLRenderer extends Renderer {
|
|
|
337
358
|
* @param {number} height The rectangle's height.
|
|
338
359
|
*/
|
|
339
360
|
clearRect(x, y, width, height) {
|
|
340
|
-
|
|
341
|
-
this.
|
|
342
|
-
this.
|
|
343
|
-
this.
|
|
344
|
-
pool.push(color);
|
|
361
|
+
this.save();
|
|
362
|
+
this.clipRect(x, y, width, height);
|
|
363
|
+
this.clearColor();
|
|
364
|
+
this.restore();
|
|
345
365
|
}
|
|
346
366
|
|
|
347
367
|
/**
|
|
@@ -380,7 +400,7 @@ class WebGLRenderer extends Renderer {
|
|
|
380
400
|
/**
|
|
381
401
|
* Draw an image to the gl context
|
|
382
402
|
* @name drawImage
|
|
383
|
-
* @
|
|
403
|
+
* @memberof WebGLRenderer.prototype
|
|
384
404
|
* @function
|
|
385
405
|
* @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.
|
|
386
406
|
* @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.
|
|
@@ -433,14 +453,14 @@ class WebGLRenderer extends Renderer {
|
|
|
433
453
|
/**
|
|
434
454
|
* Draw a pattern within the given rectangle.
|
|
435
455
|
* @name drawPattern
|
|
436
|
-
* @
|
|
456
|
+
* @memberof WebGLRenderer.prototype
|
|
437
457
|
* @function
|
|
438
|
-
* @param {
|
|
458
|
+
* @param {TextureAtlas} pattern Pattern object
|
|
439
459
|
* @param {number} x
|
|
440
460
|
* @param {number} y
|
|
441
461
|
* @param {number} width
|
|
442
462
|
* @param {number} height
|
|
443
|
-
* @see
|
|
463
|
+
* @see WebGLRenderer#createPattern
|
|
444
464
|
*/
|
|
445
465
|
drawPattern(pattern, x, y, width, height) {
|
|
446
466
|
var uvs = pattern.getUVs("0,0," + width + "," + height);
|
|
@@ -451,7 +471,7 @@ class WebGLRenderer extends Renderer {
|
|
|
451
471
|
/**
|
|
452
472
|
* return a reference to the screen canvas corresponding WebGL Context
|
|
453
473
|
* @name getScreenContext
|
|
454
|
-
* @
|
|
474
|
+
* @memberof WebGLRenderer.prototype
|
|
455
475
|
* @function
|
|
456
476
|
* @returns {WebGLRenderingContext}
|
|
457
477
|
*/
|
|
@@ -462,7 +482,7 @@ class WebGLRenderer extends Renderer {
|
|
|
462
482
|
/**
|
|
463
483
|
* Returns the WebGL Context object of the given Canvas
|
|
464
484
|
* @name getContextGL
|
|
465
|
-
* @
|
|
485
|
+
* @memberof WebGLRenderer.prototype
|
|
466
486
|
* @function
|
|
467
487
|
* @param {HTMLCanvasElement} canvas
|
|
468
488
|
* @param {boolean} [transparent=true] use false to disable transparency
|
|
@@ -520,7 +540,7 @@ class WebGLRenderer extends Renderer {
|
|
|
520
540
|
* Returns the WebGLContext instance for the renderer
|
|
521
541
|
* return a reference to the system 2d Context
|
|
522
542
|
* @name getContext
|
|
523
|
-
* @
|
|
543
|
+
* @memberof WebGLRenderer.prototype
|
|
524
544
|
* @function
|
|
525
545
|
* @returns {WebGLRenderingContext}
|
|
526
546
|
*/
|
|
@@ -531,7 +551,7 @@ class WebGLRenderer extends Renderer {
|
|
|
531
551
|
/**
|
|
532
552
|
* set a blend mode for the given context
|
|
533
553
|
* @name setBlendMode
|
|
534
|
-
* @
|
|
554
|
+
* @memberof WebGLRenderer.prototype
|
|
535
555
|
* @function
|
|
536
556
|
* @param {string} [mode="normal"] blend mode : "normal", "multiply"
|
|
537
557
|
* @param {WebGLRenderingContext} [gl]
|
|
@@ -571,7 +591,7 @@ class WebGLRenderer extends Renderer {
|
|
|
571
591
|
/**
|
|
572
592
|
* restores the canvas context
|
|
573
593
|
* @name restore
|
|
574
|
-
* @
|
|
594
|
+
* @memberof WebGLRenderer.prototype
|
|
575
595
|
* @function
|
|
576
596
|
*/
|
|
577
597
|
restore() {
|
|
@@ -605,7 +625,7 @@ class WebGLRenderer extends Renderer {
|
|
|
605
625
|
/**
|
|
606
626
|
* saves the canvas context
|
|
607
627
|
* @name save
|
|
608
|
-
* @
|
|
628
|
+
* @memberof WebGLRenderer.prototype
|
|
609
629
|
* @function
|
|
610
630
|
*/
|
|
611
631
|
save() {
|
|
@@ -621,7 +641,7 @@ class WebGLRenderer extends Renderer {
|
|
|
621
641
|
/**
|
|
622
642
|
* rotates the uniform matrix
|
|
623
643
|
* @name rotate
|
|
624
|
-
* @
|
|
644
|
+
* @memberof WebGLRenderer.prototype
|
|
625
645
|
* @function
|
|
626
646
|
* @param {number} angle in radians
|
|
627
647
|
*/
|
|
@@ -632,7 +652,7 @@ class WebGLRenderer extends Renderer {
|
|
|
632
652
|
/**
|
|
633
653
|
* scales the uniform matrix
|
|
634
654
|
* @name scale
|
|
635
|
-
* @
|
|
655
|
+
* @memberof WebGLRenderer.prototype
|
|
636
656
|
* @function
|
|
637
657
|
* @param {number} x
|
|
638
658
|
* @param {number} y
|
|
@@ -653,7 +673,7 @@ class WebGLRenderer extends Renderer {
|
|
|
653
673
|
/**
|
|
654
674
|
* Set the global alpha
|
|
655
675
|
* @name setGlobalAlpha
|
|
656
|
-
* @
|
|
676
|
+
* @memberof WebGLRenderer.prototype
|
|
657
677
|
* @function
|
|
658
678
|
* @param {number} alpha 0.0 to 1.0 values accepted.
|
|
659
679
|
*/
|
|
@@ -665,9 +685,9 @@ class WebGLRenderer extends Renderer {
|
|
|
665
685
|
* Set the current fill & stroke style color.
|
|
666
686
|
* By default, or upon reset, the value is set to #000000.
|
|
667
687
|
* @name setColor
|
|
668
|
-
* @
|
|
688
|
+
* @memberof WebGLRenderer.prototype
|
|
669
689
|
* @function
|
|
670
|
-
* @param {
|
|
690
|
+
* @param {Color|string} color css color string.
|
|
671
691
|
*/
|
|
672
692
|
setColor(color) {
|
|
673
693
|
var alpha = this.currentColor.alpha;
|
|
@@ -678,7 +698,7 @@ class WebGLRenderer extends Renderer {
|
|
|
678
698
|
/**
|
|
679
699
|
* Set the line width
|
|
680
700
|
* @name setLineWidth
|
|
681
|
-
* @
|
|
701
|
+
* @memberof WebGLRenderer.prototype
|
|
682
702
|
* @function
|
|
683
703
|
* @param {number} width Line width
|
|
684
704
|
*/
|
|
@@ -689,7 +709,7 @@ class WebGLRenderer extends Renderer {
|
|
|
689
709
|
/**
|
|
690
710
|
* Stroke an arc at the specified coordinates with given radius, start and end points
|
|
691
711
|
* @name strokeArc
|
|
692
|
-
* @
|
|
712
|
+
* @memberof WebGLRenderer.prototype
|
|
693
713
|
* @function
|
|
694
714
|
* @param {number} x arc center point x-axis
|
|
695
715
|
* @param {number} y arc center point y-axis
|
|
@@ -733,7 +753,7 @@ class WebGLRenderer extends Renderer {
|
|
|
733
753
|
/**
|
|
734
754
|
* Fill an arc at the specified coordinates with given radius, start and end points
|
|
735
755
|
* @name fillArc
|
|
736
|
-
* @
|
|
756
|
+
* @memberof WebGLRenderer.prototype
|
|
737
757
|
* @function
|
|
738
758
|
* @param {number} x arc center point x-axis
|
|
739
759
|
* @param {number} y arc center point y-axis
|
|
@@ -776,7 +796,7 @@ class WebGLRenderer extends Renderer {
|
|
|
776
796
|
/**
|
|
777
797
|
* Stroke an ellipse at the specified coordinates with given radius
|
|
778
798
|
* @name strokeEllipse
|
|
779
|
-
* @
|
|
799
|
+
* @memberof WebGLRenderer.prototype
|
|
780
800
|
* @function
|
|
781
801
|
* @param {number} x ellipse center point x-axis
|
|
782
802
|
* @param {number} y ellipse center point y-axis
|
|
@@ -813,7 +833,7 @@ class WebGLRenderer extends Renderer {
|
|
|
813
833
|
/**
|
|
814
834
|
* Fill an ellipse at the specified coordinates with given radius
|
|
815
835
|
* @name fillEllipse
|
|
816
|
-
* @
|
|
836
|
+
* @memberof WebGLRenderer.prototype
|
|
817
837
|
* @function
|
|
818
838
|
* @param {number} x ellipse center point x-axis
|
|
819
839
|
* @param {number} y ellipse center point y-axis
|
|
@@ -848,7 +868,7 @@ class WebGLRenderer extends Renderer {
|
|
|
848
868
|
/**
|
|
849
869
|
* Stroke a line of the given two points
|
|
850
870
|
* @name strokeLine
|
|
851
|
-
* @
|
|
871
|
+
* @memberof WebGLRenderer.prototype
|
|
852
872
|
* @function
|
|
853
873
|
* @param {number} startX the start x coordinate
|
|
854
874
|
* @param {number} startY the start y coordinate
|
|
@@ -868,7 +888,7 @@ class WebGLRenderer extends Renderer {
|
|
|
868
888
|
/**
|
|
869
889
|
* Fill a line of the given two points
|
|
870
890
|
* @name fillLine
|
|
871
|
-
* @
|
|
891
|
+
* @memberof WebGLRenderer.prototype
|
|
872
892
|
* @function
|
|
873
893
|
* @param {number} startX the start x coordinate
|
|
874
894
|
* @param {number} startY the start y coordinate
|
|
@@ -882,9 +902,9 @@ class WebGLRenderer extends Renderer {
|
|
|
882
902
|
/**
|
|
883
903
|
* Stroke a me.Polygon on the screen with a specified color
|
|
884
904
|
* @name strokePolygon
|
|
885
|
-
* @
|
|
905
|
+
* @memberof WebGLRenderer.prototype
|
|
886
906
|
* @function
|
|
887
|
-
* @param {
|
|
907
|
+
* @param {Polygon} poly the shape to draw
|
|
888
908
|
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
889
909
|
*/
|
|
890
910
|
strokePolygon(poly, fill = false) {
|
|
@@ -912,9 +932,9 @@ class WebGLRenderer extends Renderer {
|
|
|
912
932
|
/**
|
|
913
933
|
* Fill a me.Polygon on the screen
|
|
914
934
|
* @name fillPolygon
|
|
915
|
-
* @
|
|
935
|
+
* @memberof WebGLRenderer.prototype
|
|
916
936
|
* @function
|
|
917
|
-
* @param {
|
|
937
|
+
* @param {Polygon} poly the shape to draw
|
|
918
938
|
*/
|
|
919
939
|
fillPolygon(poly) {
|
|
920
940
|
var points = poly.points;
|
|
@@ -940,7 +960,7 @@ class WebGLRenderer extends Renderer {
|
|
|
940
960
|
/**
|
|
941
961
|
* Draw a stroke rectangle at the specified coordinates
|
|
942
962
|
* @name strokeRect
|
|
943
|
-
* @
|
|
963
|
+
* @memberof WebGLRenderer.prototype
|
|
944
964
|
* @function
|
|
945
965
|
* @param {number} x
|
|
946
966
|
* @param {number} y
|
|
@@ -968,7 +988,7 @@ class WebGLRenderer extends Renderer {
|
|
|
968
988
|
/**
|
|
969
989
|
* Draw a filled rectangle at the specified coordinates
|
|
970
990
|
* @name fillRect
|
|
971
|
-
* @
|
|
991
|
+
* @memberof WebGLRenderer.prototype
|
|
972
992
|
* @function
|
|
973
993
|
* @param {number} x
|
|
974
994
|
* @param {number} y
|
|
@@ -992,9 +1012,9 @@ class WebGLRenderer extends Renderer {
|
|
|
992
1012
|
* Reset (overrides) the renderer transformation matrix to the
|
|
993
1013
|
* identity one, and then apply the given transformation matrix.
|
|
994
1014
|
* @name setTransform
|
|
995
|
-
* @
|
|
1015
|
+
* @memberof WebGLRenderer.prototype
|
|
996
1016
|
* @function
|
|
997
|
-
* @param {
|
|
1017
|
+
* @param {Matrix2d} mat2d Matrix to transform by
|
|
998
1018
|
*/
|
|
999
1019
|
setTransform(mat2d) {
|
|
1000
1020
|
this.resetTransform();
|
|
@@ -1004,9 +1024,9 @@ class WebGLRenderer extends Renderer {
|
|
|
1004
1024
|
/**
|
|
1005
1025
|
* Multiply given matrix into the renderer tranformation matrix
|
|
1006
1026
|
* @name transform
|
|
1007
|
-
* @
|
|
1027
|
+
* @memberof WebGLRenderer.prototype
|
|
1008
1028
|
* @function
|
|
1009
|
-
* @param {
|
|
1029
|
+
* @param {Matrix2d} mat2d Matrix to transform by
|
|
1010
1030
|
*/
|
|
1011
1031
|
transform(mat2d) {
|
|
1012
1032
|
var currentTransform = this.currentTransform;
|
|
@@ -1022,7 +1042,7 @@ class WebGLRenderer extends Renderer {
|
|
|
1022
1042
|
/**
|
|
1023
1043
|
* Translates the uniform matrix by the given coordinates
|
|
1024
1044
|
* @name translate
|
|
1025
|
-
* @
|
|
1045
|
+
* @memberof WebGLRenderer.prototype
|
|
1026
1046
|
* @function
|
|
1027
1047
|
* @param {number} x
|
|
1028
1048
|
* @param {number} y
|
|
@@ -1045,7 +1065,7 @@ class WebGLRenderer extends Renderer {
|
|
|
1045
1065
|
* and restore it (with the restore() method) any time in the future.
|
|
1046
1066
|
* (<u>this is an experimental feature !</u>)
|
|
1047
1067
|
* @name clipRect
|
|
1048
|
-
* @
|
|
1068
|
+
* @memberof WebGLRenderer.prototype
|
|
1049
1069
|
* @function
|
|
1050
1070
|
* @param {number} x
|
|
1051
1071
|
* @param {number} y
|
|
@@ -1093,9 +1113,9 @@ class WebGLRenderer extends Renderer {
|
|
|
1093
1113
|
* So, if the renderable is larger than the mask, only the intersecting part of the renderable will be visible.
|
|
1094
1114
|
* Mask are not preserved through renderer context save and restore.
|
|
1095
1115
|
* @name setMask
|
|
1096
|
-
* @
|
|
1116
|
+
* @memberof WebGLRenderer.prototype
|
|
1097
1117
|
* @function
|
|
1098
|
-
* @param {
|
|
1118
|
+
* @param {Rect|Polygon|Line|Ellipse} [mask] the shape defining the mask to be applied
|
|
1099
1119
|
*/
|
|
1100
1120
|
setMask(mask) {
|
|
1101
1121
|
var gl = this.gl;
|
|
@@ -1124,8 +1144,8 @@ class WebGLRenderer extends Renderer {
|
|
|
1124
1144
|
/**
|
|
1125
1145
|
* disable (remove) the rendering mask set through setMask.
|
|
1126
1146
|
* @name clearMask
|
|
1127
|
-
* @see
|
|
1128
|
-
* @
|
|
1147
|
+
* @see WebGLRenderer#setMask
|
|
1148
|
+
* @memberof WebGLRenderer.prototype
|
|
1129
1149
|
* @function
|
|
1130
1150
|
*/
|
|
1131
1151
|
clearMask() {
|