melonjs 10.2.0 → 10.3.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 +1 -1
- package/dist/melonjs.js +4435 -4283
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +3348 -3833
- package/dist/melonjs.module.js +4025 -3920
- package/package.json +13 -14
- package/src/audio/audio.js +45 -45
- package/src/camera/camera2d.js +78 -101
- package/src/entity/draggable.js +21 -29
- package/src/entity/droptarget.js +24 -31
- package/src/entity/entity.js +34 -38
- package/src/game.js +8 -8
- package/src/{shapes → geometries}/ellipse.js +46 -46
- package/src/{shapes → geometries}/line.js +14 -14
- package/src/{shapes → geometries}/poly.js +103 -54
- package/src/{shapes → geometries}/rectangle.js +73 -120
- package/src/index.js +18 -19
- package/src/input/gamepad.js +20 -20
- package/src/input/input.js +3 -3
- package/src/input/keyboard.js +122 -124
- package/src/input/pointer.js +102 -62
- package/src/input/pointerevent.js +97 -42
- package/src/lang/deprecated.js +29 -18
- package/src/level/level.js +34 -26
- package/src/level/tiled/TMXGroup.js +12 -13
- package/src/level/tiled/TMXLayer.js +41 -42
- package/src/level/tiled/TMXObject.js +76 -70
- package/src/level/tiled/TMXTile.js +13 -15
- package/src/level/tiled/TMXTileMap.js +26 -25
- package/src/level/tiled/TMXTileset.js +14 -15
- package/src/level/tiled/TMXTilesetGroup.js +5 -6
- package/src/level/tiled/TMXUtils.js +13 -11
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXRenderer.js +18 -19
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +2 -3
- package/src/loader/loader.js +46 -40
- package/src/loader/loadingscreen.js +7 -7
- package/src/math/color.js +68 -88
- package/src/math/math.js +33 -33
- package/src/math/matrix2.js +70 -71
- package/src/math/matrix3.js +90 -91
- package/src/math/observable_vector2.js +91 -92
- package/src/math/observable_vector3.js +110 -106
- package/src/math/vector2.js +116 -104
- package/src/math/vector3.js +129 -110
- package/src/particles/emitter.js +116 -126
- package/src/particles/particle.js +4 -5
- package/src/particles/particlecontainer.js +2 -3
- package/src/physics/body.js +82 -83
- package/src/physics/bounds.js +64 -66
- package/src/physics/collision.js +21 -22
- package/src/physics/detector.js +13 -13
- package/src/physics/quadtree.js +26 -25
- package/src/physics/sat.js +21 -21
- package/src/physics/world.js +23 -22
- package/src/plugin/plugin.js +12 -13
- package/src/renderable/GUI.js +20 -26
- package/src/renderable/collectable.js +6 -7
- package/src/renderable/colorlayer.js +11 -12
- package/src/renderable/container.js +98 -81
- package/src/renderable/imagelayer.js +33 -35
- package/src/renderable/nineslicesprite.js +15 -16
- package/src/renderable/renderable.js +112 -111
- package/src/renderable/sprite.js +71 -58
- package/src/renderable/trigger.js +17 -19
- package/src/state/stage.js +14 -15
- package/src/state/state.js +78 -78
- package/src/system/device.js +137 -180
- package/src/system/event.js +116 -104
- package/src/system/pooling.js +15 -15
- package/src/system/save.js +9 -6
- package/src/system/timer.js +33 -33
- package/src/text/bitmaptext.js +39 -46
- package/src/text/bitmaptextdata.js +14 -15
- package/src/text/text.js +55 -58
- package/src/tweens/easing.js +5 -5
- package/src/tweens/interpolation.js +5 -5
- package/src/tweens/tween.js +49 -40
- package/src/utils/agent.js +12 -11
- package/src/utils/array.js +8 -8
- package/src/utils/file.js +7 -7
- package/src/utils/function.js +8 -8
- package/src/utils/string.js +19 -19
- package/src/utils/utils.js +23 -23
- package/src/video/canvas/canvas_renderer.js +127 -128
- package/src/video/renderer.js +69 -69
- package/src/video/texture.js +80 -82
- package/src/video/texture_cache.js +2 -4
- package/src/video/video.js +38 -38
- package/src/video/webgl/buffer/vertex.js +11 -3
- package/src/video/webgl/glshader.js +31 -32
- package/src/video/webgl/webgl_compositor.js +145 -127
- package/src/video/webgl/webgl_renderer.js +196 -175
package/src/video/video.js
CHANGED
|
@@ -10,7 +10,7 @@ import { initialized, version } from "./../index.js";
|
|
|
10
10
|
/**
|
|
11
11
|
* video functions
|
|
12
12
|
* @namespace me.video
|
|
13
|
-
* @
|
|
13
|
+
* @memberof me
|
|
14
14
|
*/
|
|
15
15
|
|
|
16
16
|
var designRatio = 1;
|
|
@@ -126,7 +126,7 @@ function onresize() {
|
|
|
126
126
|
/**
|
|
127
127
|
* Select the HTML5 Canvas renderer
|
|
128
128
|
* @name CANVAS
|
|
129
|
-
* @
|
|
129
|
+
* @memberof me.video
|
|
130
130
|
* @constant
|
|
131
131
|
*/
|
|
132
132
|
export const CANVAS = 0;
|
|
@@ -134,7 +134,7 @@ export const CANVAS = 0;
|
|
|
134
134
|
/**
|
|
135
135
|
* Select the WebGL renderer
|
|
136
136
|
* @name WEBGL
|
|
137
|
-
* @
|
|
137
|
+
* @memberof me.video
|
|
138
138
|
* @constant
|
|
139
139
|
*/
|
|
140
140
|
export const WEBGL = 1;
|
|
@@ -142,7 +142,7 @@ export const WEBGL = 1;
|
|
|
142
142
|
/**
|
|
143
143
|
* Auto-select the renderer (Attempt WebGL first, with fallback to Canvas)
|
|
144
144
|
* @name AUTO
|
|
145
|
-
* @
|
|
145
|
+
* @memberof me.video
|
|
146
146
|
* @constant
|
|
147
147
|
*/
|
|
148
148
|
export const AUTO = 2;
|
|
@@ -153,7 +153,7 @@ export const AUTO = 2;
|
|
|
153
153
|
* @type {HTMLElement}
|
|
154
154
|
* @readonly
|
|
155
155
|
* @name parent
|
|
156
|
-
* @
|
|
156
|
+
* @memberof me.video
|
|
157
157
|
*/
|
|
158
158
|
export let parent = null;
|
|
159
159
|
|
|
@@ -162,7 +162,7 @@ export let parent = null;
|
|
|
162
162
|
* @name scaleRatio
|
|
163
163
|
* @type {me.Vector2d}
|
|
164
164
|
* @default <1,1>
|
|
165
|
-
* @
|
|
165
|
+
* @memberof me.video
|
|
166
166
|
*/
|
|
167
167
|
export let scaleRatio = new Vector2d(1, 1);
|
|
168
168
|
|
|
@@ -170,7 +170,7 @@ export let scaleRatio = new Vector2d(1, 1);
|
|
|
170
170
|
* A reference to the active Canvas or WebGL active renderer renderer
|
|
171
171
|
* @name renderer
|
|
172
172
|
* @type {me.CanvasRenderer|me.WebGLRenderer}
|
|
173
|
-
* @
|
|
173
|
+
* @memberof me.video
|
|
174
174
|
*/
|
|
175
175
|
export let renderer = null;
|
|
176
176
|
|
|
@@ -192,20 +192,20 @@ export let renderer = null;
|
|
|
192
192
|
* - <i><b>`stretch`</b></i> : Canvas is resized to fit; content is scaled to screen aspect ratio
|
|
193
193
|
* <center><img src="images/scale-stretch.png"/></center><br>
|
|
194
194
|
* @function me.video.init
|
|
195
|
-
* @param {
|
|
196
|
-
* @param {
|
|
197
|
-
* @param {
|
|
198
|
-
* @param {
|
|
199
|
-
* @param {
|
|
200
|
-
* @param {
|
|
201
|
-
* @param {
|
|
202
|
-
* @param {
|
|
203
|
-
* @param {
|
|
204
|
-
* @param {
|
|
205
|
-
* @param {
|
|
206
|
-
* @param {
|
|
207
|
-
* @param {
|
|
208
|
-
* @
|
|
195
|
+
* @param {number} width The width of the canvas viewport
|
|
196
|
+
* @param {number} height The height of the canvas viewport
|
|
197
|
+
* @param {object} [options] The optional video/renderer parameters.<br> (see Renderer(s) documentation for further specific options)
|
|
198
|
+
* @param {string|HTMLElement} [options.parent=document.body] the DOM parent element to hold the canvas in the HTML file
|
|
199
|
+
* @param {number} [options.renderer=me.video.AUTO] renderer to use (me.video.CANVAS, me.video.WEBGL, me.video.AUTO)
|
|
200
|
+
* @param {boolean} [options.doubleBuffering=false] enable/disable double buffering
|
|
201
|
+
* @param {number|string} [options.scale=1.0] enable scaling of the canvas ('auto' for automatic scaling)
|
|
202
|
+
* @param {string} [options.scaleMethod="fit"] screen scaling modes ('fit','fill-min','fill-max','flex','flex-width','flex-height','stretch')
|
|
203
|
+
* @param {boolean} [options.preferWebGL1=false] if true the renderer will only use WebGL 1
|
|
204
|
+
* @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.
|
|
205
|
+
* @param {boolean} [options.transparent=false] whether to allow transparent pixels in the front buffer (screen).
|
|
206
|
+
* @param {boolean} [options.antiAlias=false] whether to enable or not video scaling interpolation
|
|
207
|
+
* @param {boolean} [options.consoleHeader=true] whether to display melonJS version and basic device information in the console
|
|
208
|
+
* @returns {boolean} false if initialization failed (canvas not supported)
|
|
209
209
|
* @example
|
|
210
210
|
* // init the video with a 640x480 canvas
|
|
211
211
|
* me.video.init(640, 480, {
|
|
@@ -216,7 +216,7 @@ export let renderer = null;
|
|
|
216
216
|
* doubleBuffering : true
|
|
217
217
|
* });
|
|
218
218
|
*/
|
|
219
|
-
export function init(
|
|
219
|
+
export function init(width, height, options) {
|
|
220
220
|
|
|
221
221
|
// ensure melonjs has been properly initialized
|
|
222
222
|
if (!initialized) {
|
|
@@ -227,8 +227,8 @@ export function init(game_width, game_height, options) {
|
|
|
227
227
|
settings = Object.assign(settings, options || {});
|
|
228
228
|
|
|
229
229
|
// sanitize potential given parameters
|
|
230
|
-
settings.width =
|
|
231
|
-
settings.height =
|
|
230
|
+
settings.width = width;
|
|
231
|
+
settings.height = height;
|
|
232
232
|
settings.doubleBuffering = !!(settings.doubleBuffering);
|
|
233
233
|
settings.transparent = !!(settings.transparent);
|
|
234
234
|
settings.antiAlias = !!(settings.antiAlias);
|
|
@@ -268,13 +268,13 @@ export function init(game_width, game_height, options) {
|
|
|
268
268
|
}
|
|
269
269
|
|
|
270
270
|
// hold the requested video size ratio
|
|
271
|
-
designRatio =
|
|
272
|
-
designWidth =
|
|
273
|
-
designHeight =
|
|
271
|
+
designRatio = width / height;
|
|
272
|
+
designWidth = width;
|
|
273
|
+
designHeight = height;
|
|
274
274
|
|
|
275
275
|
// default scaled size value
|
|
276
|
-
settings.zoomX =
|
|
277
|
-
settings.zoomY =
|
|
276
|
+
settings.zoomX = width * scaleRatio.x;
|
|
277
|
+
settings.zoomY = width * scaleRatio.y;
|
|
278
278
|
|
|
279
279
|
//add a channel for the onresize/onorientationchange event
|
|
280
280
|
window.addEventListener(
|
|
@@ -367,7 +367,7 @@ export function init(game_width, game_height, options) {
|
|
|
367
367
|
device.getScreenOrientation() + " | " +
|
|
368
368
|
device.language
|
|
369
369
|
);
|
|
370
|
-
console.log( "resolution: " + "requested " +
|
|
370
|
+
console.log( "resolution: " + "requested " + width + "x" + height +
|
|
371
371
|
", got " + renderer.getWidth() + "x" + renderer.getHeight()
|
|
372
372
|
);
|
|
373
373
|
}
|
|
@@ -381,12 +381,12 @@ export function init(game_width, game_height, options) {
|
|
|
381
381
|
/**
|
|
382
382
|
* Create and return a new Canvas element
|
|
383
383
|
* @function me.video.createCanvas
|
|
384
|
-
* @param {
|
|
385
|
-
* @param {
|
|
386
|
-
* @param {
|
|
387
|
-
* @
|
|
384
|
+
* @param {number} width width
|
|
385
|
+
* @param {number} height height
|
|
386
|
+
* @param {boolean} [offscreen=false] will returns an OffscreenCanvas if supported
|
|
387
|
+
* @returns {HTMLCanvasElement|OffscreenCanvas}
|
|
388
388
|
*/
|
|
389
|
-
export function createCanvas(width, height, offscreen) {
|
|
389
|
+
export function createCanvas(width, height, offscreen = false) {
|
|
390
390
|
var _canvas;
|
|
391
391
|
|
|
392
392
|
if (width === 0 || height === 0) {
|
|
@@ -413,7 +413,7 @@ export function createCanvas(width, height, offscreen) {
|
|
|
413
413
|
/**
|
|
414
414
|
* return a reference to the parent DOM element holding the main canvas
|
|
415
415
|
* @function me.video.getParent
|
|
416
|
-
* @
|
|
416
|
+
* @returns {HTMLElement}
|
|
417
417
|
*/
|
|
418
418
|
export function getParent() {
|
|
419
419
|
return parent;
|
|
@@ -425,8 +425,8 @@ export function getParent() {
|
|
|
425
425
|
* Only use this if you are not using the automatic scaling feature.
|
|
426
426
|
* @function me.video.scale
|
|
427
427
|
* @see me.video.init
|
|
428
|
-
* @param {
|
|
429
|
-
* @param {
|
|
428
|
+
* @param {number} x x scaling multiplier
|
|
429
|
+
* @param {number} y y scaling multiplier
|
|
430
430
|
*/
|
|
431
431
|
export function scale(x, y) {
|
|
432
432
|
var canvas = renderer.getScreenCanvas();
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* @classdesc
|
|
3
3
|
* a Vertex Buffer object
|
|
4
4
|
* @class VertexArrayBuffer
|
|
5
|
-
* @
|
|
5
|
+
* @ignore
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
class VertexArrayBuffer {
|
|
9
9
|
|
|
10
10
|
constructor(vertex_size, vertex_per_quad) {
|
|
11
|
-
// the size of one vertex
|
|
11
|
+
// the size of one vertex in float
|
|
12
12
|
this.vertexSize = vertex_size;
|
|
13
13
|
// size of a quad in vertex
|
|
14
14
|
this.quadSize = vertex_per_quad;
|
|
@@ -29,6 +29,7 @@ class VertexArrayBuffer {
|
|
|
29
29
|
|
|
30
30
|
/**
|
|
31
31
|
* clear the vertex array buffer
|
|
32
|
+
* @ignore
|
|
32
33
|
*/
|
|
33
34
|
clear() {
|
|
34
35
|
this.vertexCount = 0;
|
|
@@ -37,13 +38,15 @@ class VertexArrayBuffer {
|
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* return true if full
|
|
41
|
+
* @ignore
|
|
40
42
|
*/
|
|
41
|
-
isFull(vertex =
|
|
43
|
+
isFull(vertex = this.quadSize) {
|
|
42
44
|
return (this.vertexCount + vertex >= this.maxVertex);
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
/**
|
|
46
48
|
* resize the vertex buffer, retaining its original contents
|
|
49
|
+
* @ignore
|
|
47
50
|
*/
|
|
48
51
|
resize() {
|
|
49
52
|
// double the vertex size
|
|
@@ -64,6 +67,7 @@ class VertexArrayBuffer {
|
|
|
64
67
|
|
|
65
68
|
/**
|
|
66
69
|
* push a new vertex to the buffer
|
|
70
|
+
* @ignore
|
|
67
71
|
*/
|
|
68
72
|
push(x, y, u, v, tint) {
|
|
69
73
|
var offset = this.vertexCount * this.vertexSize;
|
|
@@ -91,6 +95,7 @@ class VertexArrayBuffer {
|
|
|
91
95
|
|
|
92
96
|
/**
|
|
93
97
|
* return a reference to the data in Float32 format
|
|
98
|
+
* @ignore
|
|
94
99
|
*/
|
|
95
100
|
toFloat32(begin, end) {
|
|
96
101
|
if (typeof end !== "undefined") {
|
|
@@ -102,6 +107,7 @@ class VertexArrayBuffer {
|
|
|
102
107
|
|
|
103
108
|
/**
|
|
104
109
|
* return a reference to the data in Uint32 format
|
|
110
|
+
* @ignore
|
|
105
111
|
*/
|
|
106
112
|
toUint32(begin, end) {
|
|
107
113
|
if (typeof end !== "undefined") {
|
|
@@ -113,6 +119,7 @@ class VertexArrayBuffer {
|
|
|
113
119
|
|
|
114
120
|
/**
|
|
115
121
|
* return the size of the vertex in vertex
|
|
122
|
+
* @ignore
|
|
116
123
|
*/
|
|
117
124
|
length() {
|
|
118
125
|
return this.vertexCount;
|
|
@@ -120,6 +127,7 @@ class VertexArrayBuffer {
|
|
|
120
127
|
|
|
121
128
|
/**
|
|
122
129
|
* return true if empty
|
|
130
|
+
* @ignore
|
|
123
131
|
*/
|
|
124
132
|
isEmpty() {
|
|
125
133
|
return this.vertexCount === 0;
|
|
@@ -2,7 +2,7 @@ import * as event from "./../../system/event.js";
|
|
|
2
2
|
import device from "./../../system/device.js";
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @
|
|
5
|
+
* @ignore
|
|
6
6
|
*/
|
|
7
7
|
function extractUniforms(gl, shader) {
|
|
8
8
|
var uniforms = {},
|
|
@@ -46,9 +46,9 @@ function extractUniforms(gl, shader) {
|
|
|
46
46
|
}
|
|
47
47
|
else {
|
|
48
48
|
/**
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
* A generic setter for uniform vectors
|
|
50
|
+
* @ignore
|
|
51
|
+
*/
|
|
52
52
|
return function (val) {
|
|
53
53
|
var fnv = fn;
|
|
54
54
|
if (val.length && fn.substr(-1) !== "v") {
|
|
@@ -66,7 +66,7 @@ function extractUniforms(gl, shader) {
|
|
|
66
66
|
};
|
|
67
67
|
|
|
68
68
|
/**
|
|
69
|
-
* @
|
|
69
|
+
* @ignore
|
|
70
70
|
*/
|
|
71
71
|
function extractAttributes(gl, shader) {
|
|
72
72
|
var attributes = {},
|
|
@@ -83,7 +83,7 @@ function extractAttributes(gl, shader) {
|
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
/**
|
|
86
|
-
* @
|
|
86
|
+
* @ignore
|
|
87
87
|
*/
|
|
88
88
|
function compileShader(gl, type, source) {
|
|
89
89
|
var shader = gl.createShader(type);
|
|
@@ -99,7 +99,7 @@ function compileShader(gl, type, source) {
|
|
|
99
99
|
|
|
100
100
|
/**
|
|
101
101
|
* Compile GLSL into a shader object
|
|
102
|
-
* @
|
|
102
|
+
* @ignore
|
|
103
103
|
*/
|
|
104
104
|
function compileProgram(gl, vertex, fragment, attributes) {
|
|
105
105
|
var vertShader = compileShader(gl, gl.VERTEX_SHADER, vertex);
|
|
@@ -144,7 +144,7 @@ function compileProgram(gl, vertex, fragment, attributes) {
|
|
|
144
144
|
|
|
145
145
|
/**
|
|
146
146
|
* Hash map of GLSL data types to WebGL Uniform methods
|
|
147
|
-
* @
|
|
147
|
+
* @ignore
|
|
148
148
|
*/
|
|
149
149
|
var fnHash = {
|
|
150
150
|
"bool" : "1i",
|
|
@@ -168,7 +168,7 @@ var fnHash = {
|
|
|
168
168
|
/**
|
|
169
169
|
* set precision for the fiven shader source
|
|
170
170
|
* won't do anything if the precision is already specified
|
|
171
|
-
* @
|
|
171
|
+
* @ignore
|
|
172
172
|
*/
|
|
173
173
|
function setPrecision(src, precision) {
|
|
174
174
|
if (src.substring(0, 9) !== "precision") {
|
|
@@ -179,7 +179,7 @@ function setPrecision(src, precision) {
|
|
|
179
179
|
|
|
180
180
|
/**
|
|
181
181
|
* clean the given source from space, comments, etc...
|
|
182
|
-
* @
|
|
182
|
+
* @ignore
|
|
183
183
|
*/
|
|
184
184
|
function minify(src) {
|
|
185
185
|
// remove comments
|
|
@@ -198,12 +198,11 @@ function minify(src) {
|
|
|
198
198
|
* @classdesc
|
|
199
199
|
* a base GL Shader object
|
|
200
200
|
* @class GLShader
|
|
201
|
-
* @
|
|
201
|
+
* @memberof me
|
|
202
202
|
* @param {WebGLRenderingContext} gl the current WebGL rendering context
|
|
203
|
-
* @param {
|
|
204
|
-
* @param {
|
|
205
|
-
* @param {
|
|
206
|
-
* @constructor
|
|
203
|
+
* @param {string} vertex a string containing the GLSL source code to set
|
|
204
|
+
* @param {string} fragment a string containing the GLSL source code to set
|
|
205
|
+
* @param {string} [precision=auto detected] float precision ('lowp', 'mediump' or 'highp').
|
|
207
206
|
* @see https://developer.mozilla.org/en-US/docs/Games/Techniques/3D_on_the_web/GLSL_Shaders
|
|
208
207
|
* @example
|
|
209
208
|
* // create a basic shader
|
|
@@ -235,25 +234,25 @@ class GLShader {
|
|
|
235
234
|
* @public
|
|
236
235
|
* @type {WebGLRenderingContext}
|
|
237
236
|
* @name gl
|
|
238
|
-
* @
|
|
237
|
+
* @memberof me.GLShader
|
|
239
238
|
*/
|
|
240
239
|
this.gl = gl;
|
|
241
240
|
|
|
242
241
|
/**
|
|
243
242
|
* the vertex shader source code
|
|
244
243
|
* @public
|
|
245
|
-
* @type {
|
|
244
|
+
* @type {string}
|
|
246
245
|
* @name vertex
|
|
247
|
-
* @
|
|
246
|
+
* @memberof me.GLShader
|
|
248
247
|
*/
|
|
249
248
|
this.vertex = setPrecision(minify(vertex), precision || device.getMaxShaderPrecision(this.gl));
|
|
250
249
|
|
|
251
250
|
/**
|
|
252
251
|
* the fragment shader source code
|
|
253
252
|
* @public
|
|
254
|
-
* @type {
|
|
253
|
+
* @type {string}
|
|
255
254
|
* @name vertex
|
|
256
|
-
* @
|
|
255
|
+
* @memberof me.GLShader
|
|
257
256
|
*/
|
|
258
257
|
this.fragment = setPrecision(minify(fragment), precision || device.getMaxShaderPrecision(this.gl));
|
|
259
258
|
|
|
@@ -262,7 +261,7 @@ class GLShader {
|
|
|
262
261
|
* @public
|
|
263
262
|
* @type {GLint[]}
|
|
264
263
|
* @name attributes
|
|
265
|
-
* @
|
|
264
|
+
* @memberof me.GLShader
|
|
266
265
|
*/
|
|
267
266
|
this.attributes = extractAttributes(this.gl, this);
|
|
268
267
|
|
|
@@ -272,16 +271,16 @@ class GLShader {
|
|
|
272
271
|
* @public
|
|
273
272
|
* @type {WebGLProgram}
|
|
274
273
|
* @name program
|
|
275
|
-
* @
|
|
274
|
+
* @memberof me.GLShader
|
|
276
275
|
*/
|
|
277
276
|
this.program = compileProgram(this.gl, this.vertex, this.fragment, this.attributes);
|
|
278
277
|
|
|
279
278
|
/**
|
|
280
279
|
* the uniforms of the shader
|
|
281
280
|
* @public
|
|
282
|
-
* @type {
|
|
281
|
+
* @type {object}
|
|
283
282
|
* @name uniforms
|
|
284
|
-
* @
|
|
283
|
+
* @memberof me.GLShader
|
|
285
284
|
*/
|
|
286
285
|
this.uniforms = extractUniforms(this.gl, this);
|
|
287
286
|
|
|
@@ -294,7 +293,7 @@ class GLShader {
|
|
|
294
293
|
/**
|
|
295
294
|
* Installs this shader program as part of current rendering state
|
|
296
295
|
* @name bind
|
|
297
|
-
* @
|
|
296
|
+
* @memberof me.GLShader
|
|
298
297
|
* @function
|
|
299
298
|
*/
|
|
300
299
|
bind() {
|
|
@@ -304,10 +303,10 @@ class GLShader {
|
|
|
304
303
|
/**
|
|
305
304
|
* returns the location of an attribute variable in this shader program
|
|
306
305
|
* @name getAttribLocation
|
|
307
|
-
* @
|
|
306
|
+
* @memberof me.GLShader
|
|
308
307
|
* @function
|
|
309
|
-
* @param {
|
|
310
|
-
* @
|
|
308
|
+
* @param {string} name the name of the attribute variable whose location to get.
|
|
309
|
+
* @returns {GLint} number indicating the location of the variable name if found. Returns -1 otherwise
|
|
311
310
|
*/
|
|
312
311
|
getAttribLocation(name) {
|
|
313
312
|
var attr = this.attributes[name];
|
|
@@ -321,10 +320,10 @@ class GLShader {
|
|
|
321
320
|
/**
|
|
322
321
|
* Set the uniform to the given value
|
|
323
322
|
* @name setUniform
|
|
324
|
-
* @
|
|
323
|
+
* @memberof me.GLShader
|
|
325
324
|
* @function
|
|
326
|
-
* @param {
|
|
327
|
-
* @param {
|
|
325
|
+
* @param {string} name the uniform name
|
|
326
|
+
* @param {object|Float32Array} value the value to assign to that uniform
|
|
328
327
|
* @example
|
|
329
328
|
* myShader.setUniform("uProjectionMatrix", this.projectionMatrix);
|
|
330
329
|
*/
|
|
@@ -344,7 +343,7 @@ class GLShader {
|
|
|
344
343
|
/**
|
|
345
344
|
* destroy this shader objects resources (program, attributes, uniforms)
|
|
346
345
|
* @name destroy
|
|
347
|
-
* @
|
|
346
|
+
* @memberof me.GLShader
|
|
348
347
|
* @function
|
|
349
348
|
*/
|
|
350
349
|
destroy() {
|