melonjs 10.1.1 → 10.2.3
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 -10
- package/dist/melonjs.js +3114 -2866
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.d.ts +2588 -2498
- package/dist/melonjs.module.js +2694 -2479
- package/package.json +10 -11
- package/src/audio/audio.js +43 -43
- package/src/camera/camera2d.js +52 -74
- package/src/entity/draggable.js +18 -17
- package/src/entity/droptarget.js +19 -18
- package/src/entity/entity.js +22 -26
- package/src/game.js +3 -3
- package/src/index.js +15 -11
- package/src/input/gamepad.js +13 -13
- package/src/input/input.js +1 -1
- package/src/input/keyboard.js +14 -16
- package/src/input/pointer.js +42 -35
- package/src/input/pointerevent.js +25 -33
- package/src/lang/deprecated.js +3 -3
- package/src/level/level.js +24 -16
- package/src/level/tiled/TMXGroup.js +6 -6
- package/src/level/tiled/TMXLayer.js +31 -31
- package/src/level/tiled/TMXObject.js +19 -19
- package/src/level/tiled/TMXTile.js +11 -12
- package/src/level/tiled/TMXTileMap.js +23 -21
- package/src/level/tiled/TMXTileset.js +13 -13
- package/src/level/tiled/TMXTilesetGroup.js +4 -4
- package/src/level/tiled/TMXUtils.js +13 -11
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +17 -17
- package/src/loader/loader.js +31 -27
- package/src/loader/loadingscreen.js +44 -75
- package/src/math/color.js +45 -64
- package/src/math/math.js +17 -17
- package/src/math/matrix2.js +46 -46
- package/src/math/matrix3.js +64 -64
- package/src/math/observable_vector2.js +45 -57
- package/src/math/observable_vector3.js +56 -70
- package/src/math/vector2.js +60 -59
- package/src/math/vector3.js +65 -64
- package/src/particles/emitter.js +53 -55
- package/src/particles/particle.js +1 -1
- package/src/physics/body.js +45 -51
- package/src/physics/bounds.js +36 -36
- package/src/physics/collision.js +15 -16
- package/src/physics/detector.js +10 -11
- package/src/physics/quadtree.js +18 -16
- package/src/physics/sat.js +17 -17
- package/src/physics/world.js +12 -10
- package/src/plugin/plugin.js +6 -6
- package/src/renderable/GUI.js +13 -18
- package/src/renderable/collectable.js +3 -3
- package/src/renderable/colorlayer.js +4 -4
- package/src/renderable/container.js +64 -46
- package/src/renderable/imagelayer.js +30 -31
- package/src/renderable/nineslicesprite.js +158 -69
- package/src/renderable/renderable.js +68 -67
- package/src/renderable/sprite.js +57 -43
- package/src/renderable/trigger.js +14 -15
- package/src/shapes/ellipse.js +27 -26
- package/src/shapes/line.js +8 -7
- package/src/shapes/poly.js +33 -31
- package/src/shapes/rectangle.js +50 -96
- package/src/state/stage.js +8 -8
- package/src/state/state.js +56 -56
- package/src/system/device.js +97 -84
- package/src/system/event.js +72 -72
- package/src/system/pooling.js +14 -14
- package/src/system/save.js +6 -3
- package/src/system/timer.js +20 -20
- package/src/text/bitmaptext.js +27 -33
- package/src/text/bitmaptextdata.js +9 -9
- package/src/text/text.js +118 -59
- package/src/tweens/easing.js +4 -4
- package/src/tweens/interpolation.js +4 -4
- package/src/tweens/tween.js +37 -27
- package/src/utils/agent.js +9 -8
- package/src/utils/array.js +4 -4
- package/src/utils/file.js +4 -4
- package/src/utils/function.js +5 -5
- package/src/utils/string.js +12 -12
- package/src/utils/utils.js +19 -19
- package/src/video/canvas/canvas_renderer.js +90 -90
- package/src/video/renderer.js +40 -39
- package/src/video/texture.js +85 -76
- package/src/video/texture_cache.js +11 -0
- package/src/video/video.js +31 -31
- package/src/video/webgl/buffer/vertex.js +9 -1
- package/src/video/webgl/glshader.js +20 -20
- package/src/video/webgl/webgl_compositor.js +47 -46
- package/src/video/webgl/webgl_renderer.js +104 -104
|
@@ -75,15 +75,6 @@ class WebGLCompositor {
|
|
|
75
75
|
// local reference
|
|
76
76
|
var gl = renderer.gl;
|
|
77
77
|
|
|
78
|
-
/**
|
|
79
|
-
* The number of quads held in the batch
|
|
80
|
-
* @name length
|
|
81
|
-
* @memberOf me.WebGLCompositor
|
|
82
|
-
* @type Number
|
|
83
|
-
* @readonly
|
|
84
|
-
*/
|
|
85
|
-
//this.length = 0;
|
|
86
|
-
|
|
87
78
|
// list of active texture units
|
|
88
79
|
this.currentTextureUnit = -1;
|
|
89
80
|
this.boundTextures = [];
|
|
@@ -181,9 +172,9 @@ class WebGLCompositor {
|
|
|
181
172
|
for (var i = 0; i < this.renderer.maxTextures; i++) {
|
|
182
173
|
var texture = this.boundTextures[i];
|
|
183
174
|
if (texture !== null) {
|
|
175
|
+
this.boundTextures[i] = null;
|
|
184
176
|
this.gl.deleteTexture(texture);
|
|
185
177
|
}
|
|
186
|
-
this.boundTextures[i] = null;
|
|
187
178
|
}
|
|
188
179
|
this.currentTextureUnit = -1;
|
|
189
180
|
|
|
@@ -196,11 +187,11 @@ class WebGLCompositor {
|
|
|
196
187
|
* @name addAttribute
|
|
197
188
|
* @memberOf me.WebGLCompositor
|
|
198
189
|
* @function
|
|
199
|
-
* @param {
|
|
200
|
-
* @param {
|
|
190
|
+
* @param {string} name name of the attribute in the vertex shader
|
|
191
|
+
* @param {number} size number of components per vertex attribute. Must be 1, 2, 3, or 4.
|
|
201
192
|
* @param {GLenum} type data type of each component in the array
|
|
202
|
-
* @param {
|
|
203
|
-
* @param {
|
|
193
|
+
* @param {boolean} normalized whether integer data values should be normalized into a certain range when being cast to a float
|
|
194
|
+
* @param {number} offset offset in bytes of the first component in the vertex attribute array
|
|
204
195
|
*/
|
|
205
196
|
addAttribute(name, size, type, normalized, offset) {
|
|
206
197
|
this.attributes.push({
|
|
@@ -217,10 +208,10 @@ class WebGLCompositor {
|
|
|
217
208
|
* @name setViewport
|
|
218
209
|
* @memberOf me.WebGLCompositor
|
|
219
210
|
* @function
|
|
220
|
-
* @param {
|
|
221
|
-
* @param {
|
|
222
|
-
* @param {
|
|
223
|
-
* @param {
|
|
211
|
+
* @param {number} x x position of viewport
|
|
212
|
+
* @param {number} y y position of viewport
|
|
213
|
+
* @param {number} w width of viewport
|
|
214
|
+
* @param {number} h height of viewport
|
|
224
215
|
*/
|
|
225
216
|
setViewport(x, y, w, h) {
|
|
226
217
|
this.gl.viewport(x, y, w, h);
|
|
@@ -231,17 +222,16 @@ class WebGLCompositor {
|
|
|
231
222
|
* @name createTexture2D
|
|
232
223
|
* @memberOf me.WebGLCompositor
|
|
233
224
|
* @function
|
|
234
|
-
* @param {
|
|
235
|
-
* @param {Image|
|
|
236
|
-
* @param {
|
|
237
|
-
* @param {
|
|
238
|
-
* @param {
|
|
239
|
-
* @param {
|
|
240
|
-
* @param {
|
|
241
|
-
* @param {
|
|
242
|
-
* @param {
|
|
243
|
-
* @
|
|
244
|
-
* @return {WebGLTexture} a WebGL texture
|
|
225
|
+
* @param {number} unit Destination texture unit
|
|
226
|
+
* @param {Image|HTMLCanvasElement|ImageData|Uint8Array[]|Float32Array[]} image Source image
|
|
227
|
+
* @param {number} filter gl.LINEAR or gl.NEAREST
|
|
228
|
+
* @param {string} [repeat="no-repeat"] Image repeat behavior (see {@link me.ImageLayer#repeat})
|
|
229
|
+
* @param {number} [w] Source image width (Only use with UInt8Array[] or Float32Array[] source image)
|
|
230
|
+
* @param {number} [h] Source image height (Only use with UInt8Array[] or Float32Array[] source image)
|
|
231
|
+
* @param {number} [b] Source image border (Only use with UInt8Array[] or Float32Array[] source image)
|
|
232
|
+
* @param {boolean} [premultipliedAlpha=true] Multiplies the alpha channel into the other color channels
|
|
233
|
+
* @param {boolean} [mipmap=true] Whether mipmap levels should be generated for this texture
|
|
234
|
+
* @returns {WebGLTexture} a WebGL texture
|
|
245
235
|
*/
|
|
246
236
|
createTexture2D(unit, image, filter, repeat = "no-repeat", w, h, b, premultipliedAlpha = true, mipmap = true) {
|
|
247
237
|
var gl = this.gl;
|
|
@@ -250,7 +240,7 @@ class WebGLCompositor {
|
|
|
250
240
|
var rs = (repeat.search(/^repeat(-x)?$/) === 0) && (isPOT || this.renderer.WebGLVersion > 1) ? gl.REPEAT : gl.CLAMP_TO_EDGE;
|
|
251
241
|
var rt = (repeat.search(/^repeat(-y)?$/) === 0) && (isPOT || this.renderer.WebGLVersion > 1) ? gl.REPEAT : gl.CLAMP_TO_EDGE;
|
|
252
242
|
|
|
253
|
-
this.
|
|
243
|
+
this.bindTexture2D(texture, unit);
|
|
254
244
|
|
|
255
245
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, rs);
|
|
256
246
|
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, rt);
|
|
@@ -274,13 +264,13 @@ class WebGLCompositor {
|
|
|
274
264
|
|
|
275
265
|
/**
|
|
276
266
|
* assign the given WebGL texture to the current batch
|
|
277
|
-
* @name
|
|
267
|
+
* @name bindTexture2D
|
|
278
268
|
* @memberOf me.WebGLCompositor
|
|
279
269
|
* @function
|
|
280
|
-
* @param {WebGLTexture} a WebGL texture
|
|
281
|
-
* @param {
|
|
270
|
+
* @param {WebGLTexture} texture a WebGL texture
|
|
271
|
+
* @param {number} unit Texture unit to which the given texture is bound
|
|
282
272
|
*/
|
|
283
|
-
|
|
273
|
+
bindTexture2D(texture, unit) {
|
|
284
274
|
var gl = this.gl;
|
|
285
275
|
|
|
286
276
|
if (texture !== this.boundTextures[unit]) {
|
|
@@ -300,6 +290,17 @@ class WebGLCompositor {
|
|
|
300
290
|
}
|
|
301
291
|
}
|
|
302
292
|
|
|
293
|
+
/**
|
|
294
|
+
* unbind the given WebGL texture, forcing it to be reuploaded
|
|
295
|
+
* @name unbindTexture2D
|
|
296
|
+
* @memberOf me.WebGLCompositor
|
|
297
|
+
* @function
|
|
298
|
+
* @param {WebGLTexture} texture a WebGL texture
|
|
299
|
+
*/
|
|
300
|
+
unbindTexture2D(texture) {
|
|
301
|
+
var unit = this.renderer.cache.getUnit(texture);
|
|
302
|
+
this.boundTextures[unit] = null;
|
|
303
|
+
}
|
|
303
304
|
|
|
304
305
|
/**
|
|
305
306
|
* @ignore
|
|
@@ -320,7 +321,7 @@ class WebGLCompositor {
|
|
|
320
321
|
texture.premultipliedAlpha
|
|
321
322
|
);
|
|
322
323
|
} else {
|
|
323
|
-
this.
|
|
324
|
+
this.bindTexture2D(texture2D, unit);
|
|
324
325
|
}
|
|
325
326
|
|
|
326
327
|
return this.currentTextureUnit;
|
|
@@ -363,10 +364,10 @@ class WebGLCompositor {
|
|
|
363
364
|
* @memberOf me.WebGLCompositor
|
|
364
365
|
* @function
|
|
365
366
|
* @param {me.Renderer.Texture} texture Source texture
|
|
366
|
-
* @param {
|
|
367
|
-
* @param {
|
|
368
|
-
* @param {
|
|
369
|
-
* @param {
|
|
367
|
+
* @param {number} x Destination x-coordinate
|
|
368
|
+
* @param {number} y Destination y-coordinate
|
|
369
|
+
* @param {number} w Destination width
|
|
370
|
+
* @param {number} h Destination height
|
|
370
371
|
* @param {number} u0 Texture UV (u0) value.
|
|
371
372
|
* @param {number} v0 Texture UV (v0) value.
|
|
372
373
|
* @param {number} u1 Texture UV (u1) value.
|
|
@@ -414,7 +415,7 @@ class WebGLCompositor {
|
|
|
414
415
|
|
|
415
416
|
/**
|
|
416
417
|
* Flush batched texture operations to the GPU
|
|
417
|
-
* @param
|
|
418
|
+
* @param {number} [mode=gl.TRIANGLES] the GL drawing mode
|
|
418
419
|
* @memberOf me.WebGLCompositor
|
|
419
420
|
* @function
|
|
420
421
|
*/
|
|
@@ -452,9 +453,9 @@ class WebGLCompositor {
|
|
|
452
453
|
* @name drawVertices
|
|
453
454
|
* @memberOf me.WebGLCompositor
|
|
454
455
|
* @function
|
|
455
|
-
* @param {
|
|
456
|
+
* @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)
|
|
456
457
|
* @param {me.Vector2d[]} verts vertices
|
|
457
|
-
* @param {
|
|
458
|
+
* @param {number} [vertexCount=verts.length] amount of points defined in the points array
|
|
458
459
|
*/
|
|
459
460
|
drawVertices(mode, verts, vertexCount = verts.length) {
|
|
460
461
|
// use the primitive shader
|
|
@@ -482,10 +483,10 @@ class WebGLCompositor {
|
|
|
482
483
|
* @name clearColor
|
|
483
484
|
* @memberOf me.WebGLCompositor
|
|
484
485
|
* @function
|
|
485
|
-
* @param {
|
|
486
|
-
* @param {
|
|
487
|
-
* @param {
|
|
488
|
-
* @param {
|
|
486
|
+
* @param {number} r - the red color value used when the color buffers are cleared
|
|
487
|
+
* @param {number} g - the green color value used when the color buffers are cleared
|
|
488
|
+
* @param {number} b - the blue color value used when the color buffers are cleared
|
|
489
|
+
* @param {number} a - the alpha color value used when the color buffers are cleared
|
|
489
490
|
*/
|
|
490
491
|
clearColor(r, g, b, a) {
|
|
491
492
|
this.gl.clearColor(r, g, b, a);
|
|
@@ -18,19 +18,19 @@ import { isPowerOfTwo, nextPowerOfTwo, TAU } from "./../../math/math.js";
|
|
|
18
18
|
* @extends me.Renderer
|
|
19
19
|
* @memberOf me
|
|
20
20
|
* @constructor
|
|
21
|
-
* @param {
|
|
22
|
-
* @param {
|
|
23
|
-
* @param {
|
|
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
24
|
* @param {HTMLCanvasElement} [options.canvas] The html canvas to draw to on screen
|
|
25
|
-
* @param {
|
|
26
|
-
* @param {
|
|
27
|
-
* @param {
|
|
28
|
-
* @param {
|
|
29
|
-
* @param {
|
|
30
|
-
* @param {
|
|
31
|
-
* @param {
|
|
32
|
-
* @param {
|
|
33
|
-
* @param {
|
|
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
34
|
* @param {me.WebGLCompositor} [options.compositor] A class that implements the compositor API
|
|
35
35
|
*/
|
|
36
36
|
class WebGLRenderer extends Renderer {
|
|
@@ -44,7 +44,7 @@ class WebGLRenderer extends Renderer {
|
|
|
44
44
|
* The WebGL version used by this renderer (1 or 2)
|
|
45
45
|
* @name WebGLVersion
|
|
46
46
|
* @memberOf me.WebGLRenderer
|
|
47
|
-
* @type {
|
|
47
|
+
* @type {number}
|
|
48
48
|
* @default 1
|
|
49
49
|
* @readonly
|
|
50
50
|
*/
|
|
@@ -54,7 +54,7 @@ class WebGLRenderer extends Renderer {
|
|
|
54
54
|
* The vendor string of the underlying graphics driver.
|
|
55
55
|
* @name GPUVendor
|
|
56
56
|
* @memberOf me.WebGLRenderer
|
|
57
|
-
* @type {
|
|
57
|
+
* @type {string}
|
|
58
58
|
* @default null
|
|
59
59
|
* @readonly
|
|
60
60
|
*/
|
|
@@ -64,7 +64,7 @@ class WebGLRenderer extends Renderer {
|
|
|
64
64
|
* The renderer string of the underlying graphics driver.
|
|
65
65
|
* @name GPURenderer
|
|
66
66
|
* @memberOf me.WebGLRenderer
|
|
67
|
-
* @type {
|
|
67
|
+
* @type {string}
|
|
68
68
|
* @default null
|
|
69
69
|
* @readonly
|
|
70
70
|
*/
|
|
@@ -82,7 +82,7 @@ class WebGLRenderer extends Renderer {
|
|
|
82
82
|
* Maximum number of texture unit supported under the current context
|
|
83
83
|
* @name maxTextures
|
|
84
84
|
* @memberOf me.WebGLRenderer
|
|
85
|
-
* @type {
|
|
85
|
+
* @type {number}
|
|
86
86
|
* @readonly
|
|
87
87
|
*/
|
|
88
88
|
this.maxTextures = this.gl.getParameter(this.gl.MAX_TEXTURE_IMAGE_UNITS);
|
|
@@ -115,7 +115,7 @@ class WebGLRenderer extends Renderer {
|
|
|
115
115
|
/**
|
|
116
116
|
* The current transformation matrix used for transformations on the overall scene
|
|
117
117
|
* @name currentTransform
|
|
118
|
-
* @type me.Matrix2d
|
|
118
|
+
* @type {me.Matrix2d}
|
|
119
119
|
* @memberOf me.WebGLRenderer#
|
|
120
120
|
*/
|
|
121
121
|
this.currentTransform = new Matrix2d();
|
|
@@ -123,7 +123,7 @@ class WebGLRenderer extends Renderer {
|
|
|
123
123
|
/**
|
|
124
124
|
* The current compositor used by the renderer
|
|
125
125
|
* @name currentCompositor
|
|
126
|
-
* @type me.WebGLCompositor
|
|
126
|
+
* @type {me.WebGLCompositor}
|
|
127
127
|
* @memberOf me.WebGLRenderer#
|
|
128
128
|
*/
|
|
129
129
|
this.currentCompositor = null;
|
|
@@ -258,9 +258,9 @@ class WebGLRenderer extends Renderer {
|
|
|
258
258
|
* @name createPattern
|
|
259
259
|
* @memberOf me.WebGLRenderer.prototype
|
|
260
260
|
* @function
|
|
261
|
-
* @param {
|
|
262
|
-
* @param {
|
|
263
|
-
* @
|
|
261
|
+
* @param {Image} image Source image
|
|
262
|
+
* @param {string} repeat Define how the pattern should be repeated
|
|
263
|
+
* @returns {me.Renderer.Texture}
|
|
264
264
|
* @see me.ImageLayer#repeat
|
|
265
265
|
* @example
|
|
266
266
|
* var tileable = renderer.createPattern(image, "repeat");
|
|
@@ -301,19 +301,19 @@ class WebGLRenderer extends Renderer {
|
|
|
301
301
|
* @name clearColor
|
|
302
302
|
* @memberOf me.WebGLRenderer.prototype
|
|
303
303
|
* @function
|
|
304
|
-
* @param {me.Color|
|
|
305
|
-
* @param {
|
|
304
|
+
* @param {me.Color|string} color CSS color.
|
|
305
|
+
* @param {boolean} [opaque=false] Allow transparency [default] or clear the surface completely [true]
|
|
306
306
|
*/
|
|
307
|
-
clearColor(
|
|
307
|
+
clearColor(color, opaque) {
|
|
308
308
|
var glArray;
|
|
309
309
|
|
|
310
310
|
this.save();
|
|
311
311
|
|
|
312
|
-
if (
|
|
313
|
-
glArray =
|
|
312
|
+
if (color instanceof Color) {
|
|
313
|
+
glArray = color.toArray();
|
|
314
314
|
} else {
|
|
315
315
|
// reuse temporary the renderer default color object
|
|
316
|
-
glArray = this.getColor().parseCSS(
|
|
316
|
+
glArray = this.getColor().parseCSS(color).toArray();
|
|
317
317
|
}
|
|
318
318
|
|
|
319
319
|
// clear gl context with the specified color
|
|
@@ -331,10 +331,10 @@ class WebGLRenderer extends Renderer {
|
|
|
331
331
|
* @name clearRect
|
|
332
332
|
* @memberOf me.WebGLRenderer.prototype
|
|
333
333
|
* @function
|
|
334
|
-
* @param {
|
|
335
|
-
* @param {
|
|
336
|
-
* @param {
|
|
337
|
-
* @param {
|
|
334
|
+
* @param {number} x x axis of the coordinate for the rectangle starting point.
|
|
335
|
+
* @param {number} y y axis of the coordinate for the rectangle starting point.
|
|
336
|
+
* @param {number} width The rectangle's width.
|
|
337
|
+
* @param {number} height The rectangle's height.
|
|
338
338
|
*/
|
|
339
339
|
clearRect(x, y, width, height) {
|
|
340
340
|
var color = this.currentColor.clone();
|
|
@@ -383,14 +383,14 @@ class WebGLRenderer extends Renderer {
|
|
|
383
383
|
* @memberOf me.WebGLRenderer.prototype
|
|
384
384
|
* @function
|
|
385
385
|
* @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
|
-
* @param {
|
|
387
|
-
* @param {
|
|
388
|
-
* @param {
|
|
389
|
-
* @param {
|
|
390
|
-
* @param {
|
|
391
|
-
* @param {
|
|
392
|
-
* @param {
|
|
393
|
-
* @param {
|
|
386
|
+
* @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.
|
|
387
|
+
* @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.
|
|
388
|
+
* @param {number} sw The width of the sub-rectangle of the source image to draw into the destination context. If not specified, the entire rectangle from the coordinates specified by sx and sy to the bottom-right corner of the image is used.
|
|
389
|
+
* @param {number} sh The height of the sub-rectangle of the source image to draw into the destination context.
|
|
390
|
+
* @param {number} dx The X coordinate in the destination canvas at which to place the top-left corner of the source image.
|
|
391
|
+
* @param {number} dy The Y coordinate in the destination canvas at which to place the top-left corner of the source image.
|
|
392
|
+
* @param {number} dw The width to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in width when drawn.
|
|
393
|
+
* @param {number} dh The height to draw the image in the destination canvas. This allows scaling of the drawn image. If not specified, the image is not scaled in height when drawn.
|
|
394
394
|
* @example
|
|
395
395
|
* // Position the image on the canvas:
|
|
396
396
|
* renderer.drawImage(image, dx, dy);
|
|
@@ -436,10 +436,10 @@ class WebGLRenderer extends Renderer {
|
|
|
436
436
|
* @memberOf me.WebGLRenderer.prototype
|
|
437
437
|
* @function
|
|
438
438
|
* @param {me.Renderer.Texture} pattern Pattern object
|
|
439
|
-
* @param {
|
|
440
|
-
* @param {
|
|
441
|
-
* @param {
|
|
442
|
-
* @param {
|
|
439
|
+
* @param {number} x
|
|
440
|
+
* @param {number} y
|
|
441
|
+
* @param {number} width
|
|
442
|
+
* @param {number} height
|
|
443
443
|
* @see me.WebGLRenderer#createPattern
|
|
444
444
|
*/
|
|
445
445
|
drawPattern(pattern, x, y, width, height) {
|
|
@@ -453,7 +453,7 @@ class WebGLRenderer extends Renderer {
|
|
|
453
453
|
* @name getScreenContext
|
|
454
454
|
* @memberOf me.WebGLRenderer.prototype
|
|
455
455
|
* @function
|
|
456
|
-
* @
|
|
456
|
+
* @returns {WebGLRenderingContext}
|
|
457
457
|
*/
|
|
458
458
|
getScreenContext() {
|
|
459
459
|
return this.gl;
|
|
@@ -464,9 +464,9 @@ class WebGLRenderer extends Renderer {
|
|
|
464
464
|
* @name getContextGL
|
|
465
465
|
* @memberOf me.WebGLRenderer.prototype
|
|
466
466
|
* @function
|
|
467
|
-
* @param {
|
|
468
|
-
* @param {
|
|
469
|
-
* @
|
|
467
|
+
* @param {HTMLCanvasElement} canvas
|
|
468
|
+
* @param {boolean} [transparent=true] use false to disable transparency
|
|
469
|
+
* @returns {WebGLRenderingContext}
|
|
470
470
|
*/
|
|
471
471
|
getContextGL(canvas, transparent) {
|
|
472
472
|
if (typeof canvas === "undefined" || canvas === null) {
|
|
@@ -522,7 +522,7 @@ class WebGLRenderer extends Renderer {
|
|
|
522
522
|
* @name getContext
|
|
523
523
|
* @memberOf me.WebGLRenderer.prototype
|
|
524
524
|
* @function
|
|
525
|
-
* @
|
|
525
|
+
* @returns {WebGLRenderingContext}
|
|
526
526
|
*/
|
|
527
527
|
getContext() {
|
|
528
528
|
return this.gl;
|
|
@@ -533,7 +533,7 @@ class WebGLRenderer extends Renderer {
|
|
|
533
533
|
* @name setBlendMode
|
|
534
534
|
* @memberOf me.WebGLRenderer.prototype
|
|
535
535
|
* @function
|
|
536
|
-
* @param {
|
|
536
|
+
* @param {string} [mode="normal"] blend mode : "normal", "multiply"
|
|
537
537
|
* @param {WebGLRenderingContext} [gl]
|
|
538
538
|
*/
|
|
539
539
|
setBlendMode(mode, gl) {
|
|
@@ -623,7 +623,7 @@ class WebGLRenderer extends Renderer {
|
|
|
623
623
|
* @name rotate
|
|
624
624
|
* @memberOf me.WebGLRenderer.prototype
|
|
625
625
|
* @function
|
|
626
|
-
* @param {
|
|
626
|
+
* @param {number} angle in radians
|
|
627
627
|
*/
|
|
628
628
|
rotate(angle) {
|
|
629
629
|
this.currentTransform.rotate(angle);
|
|
@@ -634,8 +634,8 @@ class WebGLRenderer extends Renderer {
|
|
|
634
634
|
* @name scale
|
|
635
635
|
* @memberOf me.WebGLRenderer.prototype
|
|
636
636
|
* @function
|
|
637
|
-
* @param {
|
|
638
|
-
* @param {
|
|
637
|
+
* @param {number} x
|
|
638
|
+
* @param {number} y
|
|
639
639
|
*/
|
|
640
640
|
scale(x, y) {
|
|
641
641
|
this.currentTransform.scale(x, y);
|
|
@@ -655,10 +655,10 @@ class WebGLRenderer extends Renderer {
|
|
|
655
655
|
* @name setGlobalAlpha
|
|
656
656
|
* @memberOf me.WebGLRenderer.prototype
|
|
657
657
|
* @function
|
|
658
|
-
* @param {
|
|
658
|
+
* @param {number} alpha 0.0 to 1.0 values accepted.
|
|
659
659
|
*/
|
|
660
|
-
setGlobalAlpha(
|
|
661
|
-
this.currentColor.alpha =
|
|
660
|
+
setGlobalAlpha(alpha) {
|
|
661
|
+
this.currentColor.alpha = alpha;
|
|
662
662
|
}
|
|
663
663
|
|
|
664
664
|
/**
|
|
@@ -667,7 +667,7 @@ class WebGLRenderer extends Renderer {
|
|
|
667
667
|
* @name setColor
|
|
668
668
|
* @memberOf me.WebGLRenderer.prototype
|
|
669
669
|
* @function
|
|
670
|
-
* @param {me.Color|
|
|
670
|
+
* @param {me.Color|string} color css color string.
|
|
671
671
|
*/
|
|
672
672
|
setColor(color) {
|
|
673
673
|
var alpha = this.currentColor.alpha;
|
|
@@ -680,7 +680,7 @@ class WebGLRenderer extends Renderer {
|
|
|
680
680
|
* @name setLineWidth
|
|
681
681
|
* @memberOf me.WebGLRenderer.prototype
|
|
682
682
|
* @function
|
|
683
|
-
* @param {
|
|
683
|
+
* @param {number} width Line width
|
|
684
684
|
*/
|
|
685
685
|
setLineWidth(width) {
|
|
686
686
|
this.getScreenContext().lineWidth(width);
|
|
@@ -691,13 +691,13 @@ class WebGLRenderer extends Renderer {
|
|
|
691
691
|
* @name strokeArc
|
|
692
692
|
* @memberOf me.WebGLRenderer.prototype
|
|
693
693
|
* @function
|
|
694
|
-
* @param {
|
|
695
|
-
* @param {
|
|
696
|
-
* @param {
|
|
697
|
-
* @param {
|
|
698
|
-
* @param {
|
|
699
|
-
* @param {
|
|
700
|
-
* @param {
|
|
694
|
+
* @param {number} x arc center point x-axis
|
|
695
|
+
* @param {number} y arc center point y-axis
|
|
696
|
+
* @param {number} radius
|
|
697
|
+
* @param {number} start start angle in radians
|
|
698
|
+
* @param {number} end end angle in radians
|
|
699
|
+
* @param {boolean} [antiClockwise=false] draw arc anti-clockwise
|
|
700
|
+
* @param {boolean} [fill=false]
|
|
701
701
|
*/
|
|
702
702
|
strokeArc(x, y, radius, start, end, antiClockwise = false, fill) {
|
|
703
703
|
if (fill === true ) {
|
|
@@ -735,12 +735,12 @@ class WebGLRenderer extends Renderer {
|
|
|
735
735
|
* @name fillArc
|
|
736
736
|
* @memberOf me.WebGLRenderer.prototype
|
|
737
737
|
* @function
|
|
738
|
-
* @param {
|
|
739
|
-
* @param {
|
|
740
|
-
* @param {
|
|
741
|
-
* @param {
|
|
742
|
-
* @param {
|
|
743
|
-
* @param {
|
|
738
|
+
* @param {number} x arc center point x-axis
|
|
739
|
+
* @param {number} y arc center point y-axis
|
|
740
|
+
* @param {number} radius
|
|
741
|
+
* @param {number} start start angle in radians
|
|
742
|
+
* @param {number} end end angle in radians
|
|
743
|
+
* @param {boolean} [antiClockwise=false] draw arc anti-clockwise
|
|
744
744
|
*/
|
|
745
745
|
fillArc(x, y, radius, start, end /*, antiClockwise = false*/) {
|
|
746
746
|
// XXX to be optimzed using a specific shader
|
|
@@ -778,11 +778,11 @@ class WebGLRenderer extends Renderer {
|
|
|
778
778
|
* @name strokeEllipse
|
|
779
779
|
* @memberOf me.WebGLRenderer.prototype
|
|
780
780
|
* @function
|
|
781
|
-
* @param {
|
|
782
|
-
* @param {
|
|
783
|
-
* @param {
|
|
784
|
-
* @param {
|
|
785
|
-
* @param {
|
|
781
|
+
* @param {number} x ellipse center point x-axis
|
|
782
|
+
* @param {number} y ellipse center point y-axis
|
|
783
|
+
* @param {number} w horizontal radius of the ellipse
|
|
784
|
+
* @param {number} h vertical radius of the ellipse
|
|
785
|
+
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
786
786
|
*/
|
|
787
787
|
strokeEllipse(x, y, w, h, fill = false) {
|
|
788
788
|
if (fill === true ) {
|
|
@@ -815,10 +815,10 @@ class WebGLRenderer extends Renderer {
|
|
|
815
815
|
* @name fillEllipse
|
|
816
816
|
* @memberOf me.WebGLRenderer.prototype
|
|
817
817
|
* @function
|
|
818
|
-
* @param {
|
|
819
|
-
* @param {
|
|
820
|
-
* @param {
|
|
821
|
-
* @param {
|
|
818
|
+
* @param {number} x ellipse center point x-axis
|
|
819
|
+
* @param {number} y ellipse center point y-axis
|
|
820
|
+
* @param {number} w horizontal radius of the ellipse
|
|
821
|
+
* @param {number} h vertical radius of the ellipse
|
|
822
822
|
*/
|
|
823
823
|
fillEllipse(x, y, w, h) {
|
|
824
824
|
// XXX to be optimzed using a specific shader
|
|
@@ -850,10 +850,10 @@ class WebGLRenderer extends Renderer {
|
|
|
850
850
|
* @name strokeLine
|
|
851
851
|
* @memberOf me.WebGLRenderer.prototype
|
|
852
852
|
* @function
|
|
853
|
-
* @param {
|
|
854
|
-
* @param {
|
|
855
|
-
* @param {
|
|
856
|
-
* @param {
|
|
853
|
+
* @param {number} startX the start x coordinate
|
|
854
|
+
* @param {number} startY the start y coordinate
|
|
855
|
+
* @param {number} endX the end x coordinate
|
|
856
|
+
* @param {number} endY the end y coordinate
|
|
857
857
|
*/
|
|
858
858
|
strokeLine(startX, startY, endX, endY) {
|
|
859
859
|
var points = this._glPoints;
|
|
@@ -870,10 +870,10 @@ class WebGLRenderer extends Renderer {
|
|
|
870
870
|
* @name fillLine
|
|
871
871
|
* @memberOf me.WebGLRenderer.prototype
|
|
872
872
|
* @function
|
|
873
|
-
* @param {
|
|
874
|
-
* @param {
|
|
875
|
-
* @param {
|
|
876
|
-
* @param {
|
|
873
|
+
* @param {number} startX the start x coordinate
|
|
874
|
+
* @param {number} startY the start y coordinate
|
|
875
|
+
* @param {number} endX the end x coordinate
|
|
876
|
+
* @param {number} endY the end y coordinate
|
|
877
877
|
*/
|
|
878
878
|
fillLine(startX, startY, endX, endY) {
|
|
879
879
|
this.strokeLine(startX, startY, endX, endY);
|
|
@@ -885,7 +885,7 @@ class WebGLRenderer extends Renderer {
|
|
|
885
885
|
* @memberOf me.WebGLRenderer.prototype
|
|
886
886
|
* @function
|
|
887
887
|
* @param {me.Polygon} poly the shape to draw
|
|
888
|
-
* @param {
|
|
888
|
+
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
889
889
|
*/
|
|
890
890
|
strokePolygon(poly, fill = false) {
|
|
891
891
|
if (fill === true ) {
|
|
@@ -915,7 +915,7 @@ class WebGLRenderer extends Renderer {
|
|
|
915
915
|
* @memberOf me.WebGLRenderer.prototype
|
|
916
916
|
* @function
|
|
917
917
|
* @param {me.Polygon} poly the shape to draw
|
|
918
|
-
|
|
918
|
+
*/
|
|
919
919
|
fillPolygon(poly) {
|
|
920
920
|
var points = poly.points;
|
|
921
921
|
var glPoints = this._glPoints;
|
|
@@ -942,11 +942,11 @@ class WebGLRenderer extends Renderer {
|
|
|
942
942
|
* @name strokeRect
|
|
943
943
|
* @memberOf me.WebGLRenderer.prototype
|
|
944
944
|
* @function
|
|
945
|
-
* @param {
|
|
946
|
-
* @param {
|
|
947
|
-
* @param {
|
|
948
|
-
* @param {
|
|
949
|
-
* @param {
|
|
945
|
+
* @param {number} x
|
|
946
|
+
* @param {number} y
|
|
947
|
+
* @param {number} width
|
|
948
|
+
* @param {number} height
|
|
949
|
+
* @param {boolean} [fill=false] also fill the shape with the current color if true
|
|
950
950
|
*/
|
|
951
951
|
strokeRect(x, y, width, height, fill = false) {
|
|
952
952
|
if (fill === true ) {
|
|
@@ -970,10 +970,10 @@ class WebGLRenderer extends Renderer {
|
|
|
970
970
|
* @name fillRect
|
|
971
971
|
* @memberOf me.WebGLRenderer.prototype
|
|
972
972
|
* @function
|
|
973
|
-
* @param {
|
|
974
|
-
* @param {
|
|
975
|
-
* @param {
|
|
976
|
-
* @param {
|
|
973
|
+
* @param {number} x
|
|
974
|
+
* @param {number} y
|
|
975
|
+
* @param {number} width
|
|
976
|
+
* @param {number} height
|
|
977
977
|
*/
|
|
978
978
|
fillRect(x, y, width, height) {
|
|
979
979
|
var glPoints = this._glPoints;
|
|
@@ -1024,8 +1024,8 @@ class WebGLRenderer extends Renderer {
|
|
|
1024
1024
|
* @name translate
|
|
1025
1025
|
* @memberOf me.WebGLRenderer.prototype
|
|
1026
1026
|
* @function
|
|
1027
|
-
* @param {
|
|
1028
|
-
* @param {
|
|
1027
|
+
* @param {number} x
|
|
1028
|
+
* @param {number} y
|
|
1029
1029
|
*/
|
|
1030
1030
|
translate(x, y) {
|
|
1031
1031
|
var currentTransform = this.currentTransform;
|
|
@@ -1047,10 +1047,10 @@ class WebGLRenderer extends Renderer {
|
|
|
1047
1047
|
* @name clipRect
|
|
1048
1048
|
* @memberOf me.WebGLRenderer.prototype
|
|
1049
1049
|
* @function
|
|
1050
|
-
* @param {
|
|
1051
|
-
* @param {
|
|
1052
|
-
* @param {
|
|
1053
|
-
* @param {
|
|
1050
|
+
* @param {number} x
|
|
1051
|
+
* @param {number} y
|
|
1052
|
+
* @param {number} width
|
|
1053
|
+
* @param {number} height
|
|
1054
1054
|
*/
|
|
1055
1055
|
clipRect(x, y, width, height) {
|
|
1056
1056
|
var canvas = this.backBufferCanvas;
|