melonjs 15.0.0 → 15.1.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 +4 -4
- package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
- package/dist/melonjs.mjs/_virtual/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
- package/dist/melonjs.mjs/_virtual/howler.js +1 -1
- package/dist/melonjs.mjs/_virtual/index.js +7 -3
- package/dist/melonjs.mjs/_virtual/index2.js +1 -1
- package/dist/melonjs.mjs/_virtual/multimap.js +1 -1
- package/dist/melonjs.mjs/_virtual/setmultimap.js +1 -1
- package/dist/melonjs.mjs/application/application.js +27 -17
- package/dist/melonjs.mjs/application/header.js +6 -5
- package/dist/melonjs.mjs/application/resize.js +20 -20
- package/dist/melonjs.mjs/application/settings.js +1 -1
- package/dist/melonjs.mjs/audio/audio.js +17 -17
- package/dist/melonjs.mjs/camera/camera2d.js +10 -10
- package/dist/melonjs.mjs/const.js +1 -1
- package/dist/melonjs.mjs/entity/entity.js +4 -4
- package/dist/melonjs.mjs/geometries/ellipse.js +6 -6
- package/dist/melonjs.mjs/geometries/line.js +9 -9
- package/dist/melonjs.mjs/geometries/path2d.js +53 -53
- package/dist/melonjs.mjs/geometries/point.js +2 -2
- package/dist/melonjs.mjs/geometries/poly.js +29 -29
- package/dist/melonjs.mjs/geometries/rectangle.js +8 -8
- package/dist/melonjs.mjs/geometries/roundrect.js +6 -6
- package/dist/melonjs.mjs/index.js +5 -5
- package/dist/melonjs.mjs/input/gamepad.js +30 -30
- package/dist/melonjs.mjs/input/input.js +2 -2
- package/dist/melonjs.mjs/input/keyboard.js +15 -15
- package/dist/melonjs.mjs/input/pointer.js +2 -2
- package/dist/melonjs.mjs/input/pointerevent.js +58 -58
- package/dist/melonjs.mjs/lang/console.js +3 -3
- package/dist/melonjs.mjs/lang/deprecated.js +2 -2
- package/dist/melonjs.mjs/level/level.js +9 -9
- package/dist/melonjs.mjs/level/tiled/TMXGroup.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXLayer.js +31 -31
- package/dist/melonjs.mjs/level/tiled/TMXObject.js +8 -8
- package/dist/melonjs.mjs/level/tiled/TMXTile.js +8 -8
- package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +19 -19
- package/dist/melonjs.mjs/level/tiled/TMXTileset.js +15 -15
- package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +3 -3
- package/dist/melonjs.mjs/level/tiled/TMXUtils.js +46 -41
- package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
- package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +30 -30
- package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +21 -21
- package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +10 -10
- package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +2 -2
- package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +6 -6
- package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
- package/dist/melonjs.mjs/loader/cache.js +1 -1
- package/dist/melonjs.mjs/loader/loader.js +7 -7
- package/dist/melonjs.mjs/loader/loadingscreen.js +2 -2
- package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
- package/dist/melonjs.mjs/loader/parser.js +13 -13
- package/dist/melonjs.mjs/loader/settings.js +3 -3
- package/dist/melonjs.mjs/math/color.js +21 -21
- package/dist/melonjs.mjs/math/math.js +2 -2
- package/dist/melonjs.mjs/math/matrix2.js +22 -22
- package/dist/melonjs.mjs/math/matrix3.js +52 -52
- package/dist/melonjs.mjs/math/observable_vector2.js +12 -12
- package/dist/melonjs.mjs/math/observable_vector3.js +22 -22
- package/dist/melonjs.mjs/math/vector2.js +11 -11
- package/dist/melonjs.mjs/math/vector3.js +21 -21
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/arraymultimap.js +45 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/esm/multimap.js +130 -0
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +1 -1
- package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
- package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +2 -2
- package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
- package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
- package/dist/melonjs.mjs/particles/emitter.js +5 -5
- package/dist/melonjs.mjs/particles/particle.js +8 -8
- package/dist/melonjs.mjs/particles/settings.js +3 -3
- package/dist/melonjs.mjs/physics/body.js +17 -17
- package/dist/melonjs.mjs/physics/bounds.js +12 -12
- package/dist/melonjs.mjs/physics/collision.js +3 -3
- package/dist/melonjs.mjs/physics/detector.js +14 -14
- package/dist/melonjs.mjs/physics/quadtree.js +19 -19
- package/dist/melonjs.mjs/physics/response.js +1 -1
- package/dist/melonjs.mjs/physics/sat.js +60 -60
- package/dist/melonjs.mjs/physics/world.js +4 -4
- package/dist/melonjs.mjs/plugin/plugin.js +11 -11
- package/dist/melonjs.mjs/renderable/collectable.js +2 -2
- package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
- package/dist/melonjs.mjs/renderable/container.js +77 -59
- package/dist/melonjs.mjs/renderable/dragndrop.js +5 -5
- package/dist/melonjs.mjs/renderable/imagelayer.js +7 -6
- package/dist/melonjs.mjs/renderable/light2d.js +6 -6
- package/dist/melonjs.mjs/renderable/nineslicesprite.js +12 -12
- package/dist/melonjs.mjs/renderable/renderable.js +11 -11
- package/dist/melonjs.mjs/renderable/sprite.js +25 -25
- package/dist/melonjs.mjs/renderable/trigger.js +11 -9
- package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +97 -27
- package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +25 -25
- package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +83 -63
- package/dist/melonjs.mjs/state/stage.js +7 -7
- package/dist/melonjs.mjs/state/state.js +15 -15
- package/dist/melonjs.mjs/system/device.js +2 -2
- package/dist/melonjs.mjs/system/dom.js +1 -1
- package/dist/melonjs.mjs/system/event.js +2 -2
- package/dist/melonjs.mjs/system/platform.js +1 -1
- package/dist/melonjs.mjs/system/pooling.js +9 -9
- package/dist/melonjs.mjs/system/save.js +6 -6
- package/dist/melonjs.mjs/system/timer.js +16 -12
- package/dist/melonjs.mjs/text/bitmaptext.js +20 -20
- package/dist/melonjs.mjs/text/bitmaptextdata.js +22 -22
- package/dist/melonjs.mjs/text/glyph.js +3 -3
- package/dist/melonjs.mjs/text/text.js +10 -9
- package/dist/melonjs.mjs/text/textmetrics.js +15 -15
- package/dist/melonjs.mjs/text/textstyle.js +1 -1
- package/dist/melonjs.mjs/tweens/easing.js +4 -4
- package/dist/melonjs.mjs/tweens/interpolation.js +8 -8
- package/dist/melonjs.mjs/tweens/tween.js +11 -11
- package/dist/melonjs.mjs/utils/agent.js +6 -6
- package/dist/melonjs.mjs/utils/array.js +4 -4
- package/dist/melonjs.mjs/utils/file.js +1 -1
- package/dist/melonjs.mjs/utils/function.js +5 -5
- package/dist/melonjs.mjs/utils/string.js +3 -3
- package/dist/melonjs.mjs/utils/utils.js +16 -16
- package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +35 -109
- package/dist/melonjs.mjs/video/renderer.js +74 -7
- package/dist/melonjs.mjs/video/texture/atlas.js +37 -37
- package/dist/melonjs.mjs/video/texture/cache.js +9 -10
- package/dist/melonjs.mjs/video/texture/canvas_texture.js +63 -3
- package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
- package/dist/melonjs.mjs/video/video.js +2 -2
- package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +3 -3
- package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +5 -5
- package/dist/melonjs.mjs/video/webgl/compositors/primitive_compositor.js +5 -5
- package/dist/melonjs.mjs/video/webgl/compositors/quad_compositor.js +18 -15
- package/dist/melonjs.mjs/video/webgl/glshader.js +7 -7
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
- package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/attributes.js +2 -2
- package/dist/melonjs.mjs/video/webgl/utils/precision.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/program.js +7 -7
- package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
- package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +4 -4
- package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +55 -38
- package/dist/melonjs.module.js +1747 -1809
- package/dist/types/application/application.d.ts +11 -8
- package/dist/types/audio/audio.d.ts +3 -3
- package/dist/types/index.d.ts +4 -3
- package/dist/types/input/input.d.ts +1 -1
- package/dist/types/input/keyboard.d.ts +1 -1
- package/dist/types/input/pointerevent.d.ts +6 -6
- package/dist/types/level/level.d.ts +2 -2
- package/dist/types/level/tiled/TMXLayer.d.ts +4 -4
- package/dist/types/level/tiled/TMXTileMap.d.ts +2 -2
- package/dist/types/level/tiled/TMXUtils.d.ts +5 -4
- package/dist/types/loader/loader.d.ts +2 -2
- package/dist/types/loader/settings.d.ts +2 -2
- package/dist/types/particles/emitter.d.ts +1 -1
- package/dist/types/physics/collision.d.ts +1 -1
- package/dist/types/physics/detector.d.ts +1 -1
- package/dist/types/plugin/plugin.d.ts +2 -2
- package/dist/types/renderable/container.d.ts +21 -17
- package/dist/types/renderable/sprite.d.ts +11 -11
- package/dist/types/renderable/trigger.d.ts +1 -1
- package/dist/types/renderable/ui/uibaseelement.d.ts +28 -6
- package/dist/types/renderable/ui/uispriteelement.d.ts +12 -14
- package/dist/types/renderable/ui/uitextbutton.d.ts +52 -11
- package/dist/types/state/stage.d.ts +1 -1
- package/dist/types/system/device.d.ts +1 -1
- package/dist/types/system/pooling.d.ts +3 -3
- package/dist/types/system/timer.d.ts +5 -5
- package/dist/types/text/bitmaptext.d.ts +1 -1
- package/dist/types/text/text.d.ts +1 -1
- package/dist/types/utils/array.d.ts +2 -2
- package/dist/types/video/canvas/canvas_renderer.d.ts +8 -76
- package/dist/types/video/renderer.d.ts +48 -0
- package/dist/types/video/texture/atlas.d.ts +3 -3
- package/dist/types/video/texture/canvas_texture.d.ts +40 -0
- package/dist/types/video/webgl/glshader.d.ts +1 -1
- package/dist/types/video/webgl/webgl_renderer.d.ts +13 -9
- package/package.json +14 -14
- package/src/application/application.js +26 -16
- package/src/application/header.js +5 -4
- package/src/application/resize.js +19 -19
- package/src/audio/audio.js +16 -16
- package/src/camera/camera2d.js +9 -9
- package/src/entity/entity.js +3 -3
- package/src/geometries/ellipse.js +5 -5
- package/src/geometries/line.js +8 -8
- package/src/geometries/path2d.js +52 -52
- package/src/geometries/point.js +1 -1
- package/src/geometries/poly.js +28 -28
- package/src/geometries/rectangle.js +7 -7
- package/src/geometries/roundrect.js +5 -5
- package/src/index.js +3 -2
- package/src/input/gamepad.js +29 -29
- package/src/input/input.js +1 -1
- package/src/input/keyboard.js +14 -14
- package/src/input/pointer.js +1 -1
- package/src/input/pointerevent.js +52 -52
- package/src/lang/console.js +2 -2
- package/src/lang/deprecated.js +1 -1
- package/src/level/level.js +8 -8
- package/src/level/tiled/TMXGroup.js +2 -2
- package/src/level/tiled/TMXLayer.js +30 -30
- package/src/level/tiled/TMXObject.js +7 -7
- package/src/level/tiled/TMXTile.js +7 -7
- package/src/level/tiled/TMXTileMap.js +18 -18
- package/src/level/tiled/TMXTileset.js +14 -14
- package/src/level/tiled/TMXTilesetGroup.js +2 -2
- package/src/level/tiled/TMXUtils.js +45 -40
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +29 -29
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +20 -20
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +9 -9
- package/src/level/tiled/renderer/TMXRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +5 -5
- package/src/loader/loader.js +6 -6
- package/src/loader/loadingscreen.js +1 -1
- package/src/loader/parser.js +12 -12
- package/src/loader/settings.js +2 -2
- package/src/math/color.js +20 -20
- package/src/math/math.js +1 -1
- package/src/math/matrix2.js +21 -21
- package/src/math/matrix3.js +51 -51
- package/src/math/observable_vector2.js +11 -11
- package/src/math/observable_vector3.js +21 -21
- package/src/math/vector2.js +10 -10
- package/src/math/vector3.js +20 -20
- package/src/particles/emitter.js +4 -4
- package/src/particles/particle.js +7 -7
- package/src/particles/settings.js +2 -2
- package/src/physics/body.js +16 -16
- package/src/physics/bounds.js +11 -11
- package/src/physics/collision.js +2 -2
- package/src/physics/detector.js +13 -13
- package/src/physics/quadtree.js +18 -18
- package/src/physics/sat.js +59 -59
- package/src/physics/world.js +3 -3
- package/src/plugin/plugin.js +8 -8
- package/src/renderable/collectable.js +1 -1
- package/src/renderable/container.js +76 -58
- package/src/renderable/dragndrop.js +4 -4
- package/src/renderable/imagelayer.js +6 -5
- package/src/renderable/light2d.js +5 -5
- package/src/renderable/nineslicesprite.js +11 -11
- package/src/renderable/renderable.js +10 -10
- package/src/renderable/sprite.js +24 -24
- package/src/renderable/trigger.js +10 -8
- package/src/renderable/ui/uibaseelement.js +96 -26
- package/src/renderable/ui/uispriteelement.js +24 -24
- package/src/renderable/ui/uitextbutton.js +85 -65
- package/src/state/stage.js +6 -6
- package/src/state/state.js +14 -14
- package/src/system/device.js +1 -1
- package/src/system/event.js +1 -1
- package/src/system/pooling.js +8 -8
- package/src/system/save.js +5 -5
- package/src/system/timer.js +15 -11
- package/src/text/bitmaptext.js +19 -19
- package/src/text/bitmaptextdata.js +21 -21
- package/src/text/glyph.js +2 -2
- package/src/text/text.js +9 -8
- package/src/text/textmetrics.js +14 -14
- package/src/tweens/easing.js +3 -3
- package/src/tweens/interpolation.js +7 -7
- package/src/tweens/tween.js +10 -10
- package/src/utils/agent.js +5 -5
- package/src/utils/array.js +3 -3
- package/src/utils/function.js +4 -4
- package/src/utils/string.js +2 -2
- package/src/utils/utils.js +15 -15
- package/src/video/canvas/canvas_renderer.js +34 -108
- package/src/video/renderer.js +72 -5
- package/src/video/texture/atlas.js +36 -36
- package/src/video/texture/cache.js +6 -6
- package/src/video/texture/canvas_texture.js +62 -2
- package/src/video/video.js +1 -1
- package/src/video/webgl/buffer/vertex.js +2 -2
- package/src/video/webgl/compositors/compositor.js +4 -4
- package/src/video/webgl/compositors/primitive_compositor.js +4 -4
- package/src/video/webgl/compositors/quad_compositor.js +17 -14
- package/src/video/webgl/glshader.js +6 -6
- package/src/video/webgl/utils/attributes.js +1 -1
- package/src/video/webgl/utils/program.js +6 -6
- package/src/video/webgl/utils/uniforms.js +3 -3
- package/src/video/webgl/webgl_renderer.js +54 -37
|
@@ -86,8 +86,8 @@ export class TextureAtlas {
|
|
|
86
86
|
if (typeof (atlases) !== "undefined") {
|
|
87
87
|
// normalize to array to keep the following code generic
|
|
88
88
|
atlases = Array.isArray(atlases) ? atlases : [atlases];
|
|
89
|
-
for (
|
|
90
|
-
|
|
89
|
+
for (let i in atlases) {
|
|
90
|
+
let atlas = atlases[i];
|
|
91
91
|
|
|
92
92
|
if (typeof(atlas.meta) !== "undefined") {
|
|
93
93
|
// Texture Packer or Free Texture Packer
|
|
@@ -96,7 +96,7 @@ export class TextureAtlas {
|
|
|
96
96
|
// set the texture
|
|
97
97
|
if (typeof(src) === "undefined") {
|
|
98
98
|
// get the texture name from the atlas meta data
|
|
99
|
-
|
|
99
|
+
let image = getImage(atlas.meta.image);
|
|
100
100
|
if (!image) {
|
|
101
101
|
throw new Error(
|
|
102
102
|
"Atlas texture '" + image + "' not found"
|
|
@@ -167,17 +167,17 @@ export class TextureAtlas {
|
|
|
167
167
|
* @ignore
|
|
168
168
|
*/
|
|
169
169
|
parse(data) {
|
|
170
|
-
|
|
170
|
+
let atlas = {};
|
|
171
171
|
|
|
172
172
|
data.frames.forEach((frame) => {
|
|
173
173
|
// fix wrongly formatted JSON (e.g. last dummy object in ShoeBox)
|
|
174
174
|
if (frame.hasOwnProperty("filename")) {
|
|
175
175
|
// Source coordinates
|
|
176
|
-
|
|
176
|
+
let s = frame.frame;
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
let originX, originY;
|
|
179
179
|
// Pixel-based offset origin from the top-left of the source frame
|
|
180
|
-
|
|
180
|
+
let hasTextureAnchorPoint = (frame.spriteSourceSize && frame.sourceSize && frame.pivot);
|
|
181
181
|
if (hasTextureAnchorPoint) {
|
|
182
182
|
originX = (frame.sourceSize.w * frame.pivot.x) - ((frame.trimmed) ? frame.spriteSourceSize.x : 0);
|
|
183
183
|
originY = (frame.sourceSize.h * frame.pivot.y) - ((frame.trimmed) ? frame.spriteSourceSize.y : 0);
|
|
@@ -204,16 +204,16 @@ export class TextureAtlas {
|
|
|
204
204
|
* @ignore
|
|
205
205
|
*/
|
|
206
206
|
parseFromSpriteSheet(data) {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
let atlas = {};
|
|
208
|
+
let image = data.image;
|
|
209
|
+
let spacing = data.spacing || 0;
|
|
210
|
+
let margin = data.margin || 0;
|
|
211
211
|
|
|
212
|
-
|
|
213
|
-
|
|
212
|
+
let width = image.width;
|
|
213
|
+
let height = image.height;
|
|
214
214
|
|
|
215
215
|
// calculate the sprite count (line, col)
|
|
216
|
-
|
|
216
|
+
let spritecount = pool.pull("Vector2d",
|
|
217
217
|
~~((width - margin + spacing) / (data.framewidth + spacing)),
|
|
218
218
|
~~((height - margin + spacing) / (data.frameheight + spacing))
|
|
219
219
|
);
|
|
@@ -221,8 +221,8 @@ export class TextureAtlas {
|
|
|
221
221
|
// verifying the texture size
|
|
222
222
|
if ((width % (data.framewidth + spacing)) !== 0 ||
|
|
223
223
|
(height % (data.frameheight + spacing)) !== 0) {
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
let computed_width = spritecount.x * (data.framewidth + spacing);
|
|
225
|
+
let computed_height = spritecount.y * (data.frameheight + spacing);
|
|
226
226
|
if (computed_width - width !== spacing && computed_height - height !== spacing) {
|
|
227
227
|
// "truncate size" if delta is different from the spacing size
|
|
228
228
|
width = computed_width;
|
|
@@ -238,8 +238,8 @@ export class TextureAtlas {
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
// build the local atlas
|
|
241
|
-
for (
|
|
242
|
-
|
|
241
|
+
for (let frame = 0, count = spritecount.x * spritecount.y; frame < count; frame++) {
|
|
242
|
+
let name = "" + frame;
|
|
243
243
|
atlas[name] = {
|
|
244
244
|
name : name,
|
|
245
245
|
texture : "default", // the source texture
|
|
@@ -310,10 +310,10 @@ export class TextureAtlas {
|
|
|
310
310
|
console.warn("Adding texture region", name, "for texture", this);
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
313
|
+
let source = this.getTexture();
|
|
314
|
+
let atlas = this.getAtlas();
|
|
315
|
+
let dw = source.width;
|
|
316
|
+
let dh = source.height;
|
|
317
317
|
|
|
318
318
|
atlas[name] = {
|
|
319
319
|
name : name,
|
|
@@ -335,7 +335,7 @@ export class TextureAtlas {
|
|
|
335
335
|
* @returns {object}
|
|
336
336
|
*/
|
|
337
337
|
getRegion(name, atlas) {
|
|
338
|
-
|
|
338
|
+
let region;
|
|
339
339
|
if (typeof atlas === "string") {
|
|
340
340
|
region = this.getAtlas(atlas)[name];
|
|
341
341
|
} else {
|
|
@@ -358,11 +358,11 @@ export class TextureAtlas {
|
|
|
358
358
|
*/
|
|
359
359
|
getUVs(name) {
|
|
360
360
|
// Get the source texture region
|
|
361
|
-
|
|
361
|
+
let region = this.getRegion(name);
|
|
362
362
|
|
|
363
363
|
if (typeof(region) === "undefined") {
|
|
364
364
|
// TODO: Require proper atlas regions instead of caching arbitrary region keys
|
|
365
|
-
|
|
365
|
+
let keys = name.split(","),
|
|
366
366
|
sx = +keys[0],
|
|
367
367
|
sy = +keys[1],
|
|
368
368
|
sw = +keys[2],
|
|
@@ -384,9 +384,9 @@ export class TextureAtlas {
|
|
|
384
384
|
// ignore if using the Canvas Renderer
|
|
385
385
|
if (typeof renderer.gl !== "undefined") {
|
|
386
386
|
// Source coordinates
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
387
|
+
let s = atlas[name].offset;
|
|
388
|
+
let sw = atlas[name].width;
|
|
389
|
+
let sh = atlas[name].height;
|
|
390
390
|
|
|
391
391
|
atlas[name].uvs = new Float32Array([
|
|
392
392
|
s.x / w, // u0 (left)
|
|
@@ -396,7 +396,7 @@ export class TextureAtlas {
|
|
|
396
396
|
]);
|
|
397
397
|
// Cache source coordinates
|
|
398
398
|
// TODO: Remove this when the Batcher only accepts a region name
|
|
399
|
-
|
|
399
|
+
let key = s.x + "," + s.y + "," + w + "," + h;
|
|
400
400
|
atlas[key] = atlas[name];
|
|
401
401
|
}
|
|
402
402
|
return atlas[name].uvs;
|
|
@@ -417,13 +417,13 @@ export class TextureAtlas {
|
|
|
417
417
|
* ...
|
|
418
418
|
* ...
|
|
419
419
|
* // create a new "coin" sprite
|
|
420
|
-
*
|
|
420
|
+
* let sprite = game.texture.createSpriteFromName("coin.png");
|
|
421
421
|
* // set the renderable position to bottom center
|
|
422
422
|
* sprite.anchorPoint.set(0.5, 1.0);
|
|
423
423
|
* ...
|
|
424
424
|
* ...
|
|
425
425
|
* // create a 9-slice sprite
|
|
426
|
-
*
|
|
426
|
+
* let dialogPanel = game.texture.createSpriteFromName(
|
|
427
427
|
* "rpg_dialo.png",
|
|
428
428
|
* // width & height are mandatory for 9-slice sprites
|
|
429
429
|
* { width: this.width, height: this.height },
|
|
@@ -456,7 +456,7 @@ export class TextureAtlas {
|
|
|
456
456
|
* );
|
|
457
457
|
*
|
|
458
458
|
* // create a new Animated Sprite
|
|
459
|
-
*
|
|
459
|
+
* let sprite = game.texture.createAnimationFromName([
|
|
460
460
|
* "walk0001.png", "walk0002.png", "walk0003.png",
|
|
461
461
|
* "walk0004.png", "walk0005.png", "walk0006.png",
|
|
462
462
|
* "walk0007.png", "walk0008.png", "walk0009.png",
|
|
@@ -473,12 +473,12 @@ export class TextureAtlas {
|
|
|
473
473
|
* sprite.anchorPoint.set(0.5, 1.0);
|
|
474
474
|
*/
|
|
475
475
|
createAnimationFromName(names, settings) {
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
476
|
+
let tpAtlas = [], indices = {};
|
|
477
|
+
let width = 0, height = 0;
|
|
478
|
+
let region;
|
|
479
479
|
// iterate through the given names
|
|
480
480
|
// and create a "normalized" atlas
|
|
481
|
-
for (
|
|
481
|
+
for (let i = 0; i < names.length; ++i) {
|
|
482
482
|
region = this.getRegion(names[i]);
|
|
483
483
|
if (region == null) {
|
|
484
484
|
// throw an error
|
|
@@ -49,14 +49,14 @@ class TextureCache {
|
|
|
49
49
|
* @ignore
|
|
50
50
|
*/
|
|
51
51
|
get(image, atlas) {
|
|
52
|
-
|
|
52
|
+
let entry;
|
|
53
53
|
|
|
54
54
|
if (typeof atlas === "undefined") {
|
|
55
55
|
entry = this.cache.get(image)[0];
|
|
56
56
|
} else {
|
|
57
57
|
// manage cases where a specific atlas is specified
|
|
58
58
|
this.cache.forEach((value, key) => {
|
|
59
|
-
|
|
59
|
+
let _atlas = value.getAtlas()[0];
|
|
60
60
|
if (key === image && _atlas.width === atlas.framewidth && _atlas.height === atlas.frameheight) {
|
|
61
61
|
entry = value;
|
|
62
62
|
}
|
|
@@ -88,7 +88,7 @@ class TextureCache {
|
|
|
88
88
|
*/
|
|
89
89
|
tint(src, color) {
|
|
90
90
|
// make sure the src is in the cache
|
|
91
|
-
|
|
91
|
+
let image_cache = this.tinted.get(src);
|
|
92
92
|
|
|
93
93
|
if (image_cache === undefined) {
|
|
94
94
|
image_cache = this.tinted.set(src, new Map());
|
|
@@ -105,12 +105,12 @@ class TextureCache {
|
|
|
105
105
|
* @ignore
|
|
106
106
|
*/
|
|
107
107
|
set(image, texture) {
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
let width = image.width;
|
|
109
|
+
let height = image.height;
|
|
110
110
|
|
|
111
111
|
// warn if a non POT texture is added to the cache when using WebGL1
|
|
112
112
|
if (renderer.WebGLVersion === 1 && (!isPowerOfTwo(width) || !isPowerOfTwo(height))) {
|
|
113
|
-
|
|
113
|
+
let src = typeof image.src !== "undefined" ? image.src : image;
|
|
114
114
|
console.warn(
|
|
115
115
|
"[Texture] " + src + " is not a POT texture " +
|
|
116
116
|
"(" + width + "x" + height + ")"
|
|
@@ -3,7 +3,7 @@ import { setPrefixed } from "./../../utils/agent.js";
|
|
|
3
3
|
import { clamp } from "../../math/math.js";
|
|
4
4
|
|
|
5
5
|
// default canvas settings
|
|
6
|
-
|
|
6
|
+
let defaultAttributes = {
|
|
7
7
|
offscreenCanvas : false,
|
|
8
8
|
willReadFrequently : false,
|
|
9
9
|
antiAlias : false,
|
|
@@ -65,7 +65,7 @@ class CanvasTexture {
|
|
|
65
65
|
* @param {boolean} [enable=false]
|
|
66
66
|
*/
|
|
67
67
|
setAntiAlias(enable = false) {
|
|
68
|
-
|
|
68
|
+
let canvas = this.canvas;
|
|
69
69
|
|
|
70
70
|
// enable/disable antialias on the given Context2d object
|
|
71
71
|
setPrefixed("imageSmoothingEnabled", enable, this.context);
|
|
@@ -117,6 +117,66 @@ class CanvasTexture {
|
|
|
117
117
|
return this.context.getImageData(x, y, width, height);
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
/**
|
|
121
|
+
* creates a Blob object representing the image contained in this canvas texture
|
|
122
|
+
* @param {Object} [options] - An object with the following properties:
|
|
123
|
+
* @param {String} [options.type="image/png"] - A string indicating the image format
|
|
124
|
+
* @param {Number} [options.quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
|
|
125
|
+
* @return {Promise} A Promise returning a Blob object representing the image contained in this canvas texture
|
|
126
|
+
* @example
|
|
127
|
+
* canvasTexture.convertToBlob().then((blob) => console.log(blob));
|
|
128
|
+
*/
|
|
129
|
+
toBlob(options) {
|
|
130
|
+
if (typeof this.canvas.convertToBlob === "function") {
|
|
131
|
+
return this.canvas.convertToBlob(options);
|
|
132
|
+
} else {
|
|
133
|
+
return new Promise(function(resolve) {
|
|
134
|
+
this.canvas.toBlob((blob) => {
|
|
135
|
+
resolve(blob);
|
|
136
|
+
}, options ? options.type : undefined, options ? options.quality : undefined);
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* creates an ImageBitmap object from the most recently rendered image of this canvas texture
|
|
143
|
+
* @param {Object} [options] - An object with the following properties:
|
|
144
|
+
* @param {String} [options.type="image/png"] - A string indicating the image format
|
|
145
|
+
* @param {Number} [options.quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
|
|
146
|
+
* @return {Promise} A Promise returning an ImageBitmap.
|
|
147
|
+
* @example
|
|
148
|
+
* canvasTexture.transferToImageBitmap().then((bitmap) => console.log(bitmap));
|
|
149
|
+
*/
|
|
150
|
+
toImageBitmap(options) {
|
|
151
|
+
return new Promise((resolve) => {
|
|
152
|
+
if (typeof this.canvas.transferToImageBitmap === "function") {
|
|
153
|
+
resolve(this.canvas.transferToImageBitmap());
|
|
154
|
+
} else {
|
|
155
|
+
let image = new Image();
|
|
156
|
+
image.src = this.canvas.toDataURL(options);
|
|
157
|
+
image.onload = () => {
|
|
158
|
+
createImageBitmap(image).then((bitmap) => resolve(bitmap));
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* returns a data URL containing a representation of the most recently rendered image of this canvas texture
|
|
166
|
+
* (not supported by OffscreenCanvas)
|
|
167
|
+
* @param {Object} [options] - An object with the following properties:
|
|
168
|
+
* @param {String} [options.type="image/png"] - A string indicating the image format
|
|
169
|
+
* @param {Number} [options.quality] - A Number between 0 and 1 indicating the image quality to be used when creating images using file formats that support lossy compression (such as image/jpeg or image/webp). A user agent will use its default quality value if this option is not specified, or if the number is outside the allowed range.
|
|
170
|
+
* @return {Promise} A Promise returning a string containing the requested data URL.
|
|
171
|
+
* @example
|
|
172
|
+
* renderer.toDataURL().then((dataURL) => console.log(dataURL));
|
|
173
|
+
*/
|
|
174
|
+
toDataURL(options) {
|
|
175
|
+
return new Promise((resolve) => {
|
|
176
|
+
resolve(this.canvas.toDataURL(options));
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
|
|
120
180
|
/**
|
|
121
181
|
* @ignore
|
|
122
182
|
*/
|
package/src/video/video.js
CHANGED
|
@@ -149,7 +149,7 @@ export function init(width, height, options) {
|
|
|
149
149
|
* @returns {HTMLCanvasElement|OffscreenCanvas}
|
|
150
150
|
*/
|
|
151
151
|
export function createCanvas(width, height, returnOffscreenCanvas = false) {
|
|
152
|
-
|
|
152
|
+
let _canvas;
|
|
153
153
|
|
|
154
154
|
if (width === 0 || height === 0) {
|
|
155
155
|
throw new Error("width or height was zero, Canvas could not be initialized !");
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
// save a reference to the previous data
|
|
56
|
-
|
|
56
|
+
let data = this.bufferF32;
|
|
57
57
|
|
|
58
58
|
// recreate ArrayBuffer and views
|
|
59
59
|
this.buffer = new ArrayBuffer(this.maxVertex * this.vertexSize * this.objSize);
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
* @ignore
|
|
72
72
|
*/
|
|
73
73
|
push(x, y, u, v, tint) {
|
|
74
|
-
|
|
74
|
+
let offset = this.vertexCount * this.vertexSize;
|
|
75
75
|
|
|
76
76
|
if (this.vertexCount >= this.maxVertex) {
|
|
77
77
|
this.resize(this.vertexCount);
|
|
@@ -203,12 +203,12 @@ import GLShader from "../glshader.js";
|
|
|
203
203
|
* @param {number} [mode=gl.TRIANGLES] - the GL drawing mode
|
|
204
204
|
*/
|
|
205
205
|
flush(mode = this.mode) {
|
|
206
|
-
|
|
207
|
-
|
|
206
|
+
let vertex = this.vertexData;
|
|
207
|
+
let vertexCount = vertex.vertexCount;
|
|
208
208
|
|
|
209
209
|
if (vertexCount > 0) {
|
|
210
|
-
|
|
211
|
-
|
|
210
|
+
let gl = this.gl;
|
|
211
|
+
let vertexSize = vertex.vertexSize;
|
|
212
212
|
|
|
213
213
|
// Copy data into stream buffer
|
|
214
214
|
if (this.renderer.WebGLVersion > 1) {
|
|
@@ -33,10 +33,10 @@ import Compositor from "./compositor.js";
|
|
|
33
33
|
* @param {number} [vertexCount=verts.length] - amount of points defined in the points array
|
|
34
34
|
*/
|
|
35
35
|
drawVertices(mode, verts, vertexCount = verts.length) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
36
|
+
let viewMatrix = this.viewMatrix;
|
|
37
|
+
let vertexData = this.vertexData;
|
|
38
|
+
let color = this.renderer.currentColor;
|
|
39
|
+
let alpha = this.renderer.getGlobalAlpha();
|
|
40
40
|
|
|
41
41
|
if (vertexData.isFull(vertexCount)) {
|
|
42
42
|
// is the vertex buffer full if we add more vertices
|
|
@@ -5,7 +5,7 @@ import quadFragment from "./../shaders/quad.frag";
|
|
|
5
5
|
import Compositor from "./compositor.js";
|
|
6
6
|
|
|
7
7
|
// a pool of resuable vectors
|
|
8
|
-
|
|
8
|
+
let V_ARRAY = [
|
|
9
9
|
new Vector2d(),
|
|
10
10
|
new Vector2d(),
|
|
11
11
|
new Vector2d(),
|
|
@@ -49,8 +49,8 @@ var V_ARRAY = [
|
|
|
49
49
|
super.reset();
|
|
50
50
|
|
|
51
51
|
// delete all related bound texture
|
|
52
|
-
for (
|
|
53
|
-
|
|
52
|
+
for (let i = 0; i < this.renderer.maxTextures; i++) {
|
|
53
|
+
let texture2D = this.getTexture2D(i);
|
|
54
54
|
if (typeof texture2D !== "undefined") {
|
|
55
55
|
this.deleteTexture2D(texture2D);
|
|
56
56
|
}
|
|
@@ -71,12 +71,12 @@ var V_ARRAY = [
|
|
|
71
71
|
* @returns {WebGLTexture} a WebGL texture
|
|
72
72
|
*/
|
|
73
73
|
createTexture2D(unit, pixels = null, filter, repeat = "no-repeat", w = pixels.width, h = pixels.height, premultipliedAlpha = true, mipmap = true) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
let gl = this.gl;
|
|
75
|
+
let isPOT = isPowerOfTwo(w) && isPowerOfTwo(h);
|
|
76
|
+
let rs = (repeat.search(/^repeat(-x)?$/) === 0) && (isPOT || this.renderer.WebGLVersion > 1) ? gl.REPEAT : gl.CLAMP_TO_EDGE;
|
|
77
|
+
let rt = (repeat.search(/^repeat(-y)?$/) === 0) && (isPOT || this.renderer.WebGLVersion > 1) ? gl.REPEAT : gl.CLAMP_TO_EDGE;
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
let texture = gl.createTexture();
|
|
80
80
|
|
|
81
81
|
this.bindTexture2D(texture, unit);
|
|
82
82
|
|
|
@@ -90,6 +90,9 @@ var V_ARRAY = [
|
|
|
90
90
|
if (pixels === null || typeof pixels.byteLength !== "undefined") {
|
|
91
91
|
// if pixels is undefined, or if it's Uint8Array/Float32Array TypedArray
|
|
92
92
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, w, h, 0, gl.RGBA, gl.UNSIGNED_BYTE, pixels, 0);
|
|
93
|
+
} else if (pixels instanceof OffscreenCanvas) {
|
|
94
|
+
// convert to ImageBitmap first (else Safari 16.4 and higher will throw an TypeError exception)
|
|
95
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, pixels.transferToImageBitmap());
|
|
93
96
|
} else {
|
|
94
97
|
gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, pixels);
|
|
95
98
|
}
|
|
@@ -127,7 +130,7 @@ var V_ARRAY = [
|
|
|
127
130
|
* @param {number} unit - Texture unit to which the given texture is bound
|
|
128
131
|
*/
|
|
129
132
|
bindTexture2D(texture, unit) {
|
|
130
|
-
|
|
133
|
+
let gl = this.gl;
|
|
131
134
|
|
|
132
135
|
if (texture !== this.boundTextures[unit]) {
|
|
133
136
|
this.flush();
|
|
@@ -169,8 +172,8 @@ var V_ARRAY = [
|
|
|
169
172
|
* @ignore
|
|
170
173
|
*/
|
|
171
174
|
uploadTexture(texture, w, h, force = false) {
|
|
172
|
-
|
|
173
|
-
|
|
175
|
+
let unit = this.renderer.cache.getUnit(texture);
|
|
176
|
+
let texture2D = this.boundTextures[unit];
|
|
174
177
|
|
|
175
178
|
if (typeof texture2D === "undefined" || force) {
|
|
176
179
|
this.createTexture2D(
|
|
@@ -203,7 +206,7 @@ var V_ARRAY = [
|
|
|
203
206
|
* @param {number} tint - tint color to be applied to the texture in UINT32 (argb) format
|
|
204
207
|
*/
|
|
205
208
|
addQuad(texture, x, y, w, h, u0, v0, u1, v1, tint) {
|
|
206
|
-
|
|
209
|
+
let vertexData = this.vertexData;
|
|
207
210
|
|
|
208
211
|
if (vertexData.isFull(6)) {
|
|
209
212
|
// is the vertex buffer full if we add 6 more vertices
|
|
@@ -211,13 +214,13 @@ var V_ARRAY = [
|
|
|
211
214
|
}
|
|
212
215
|
|
|
213
216
|
// upload and activate the texture if necessary
|
|
214
|
-
|
|
217
|
+
let unit = this.uploadTexture(texture);
|
|
215
218
|
|
|
216
219
|
// set fragment sampler accordingly
|
|
217
220
|
this.currentShader.setUniform("uSampler", unit);
|
|
218
221
|
|
|
219
222
|
// Transform vertices
|
|
220
|
-
|
|
223
|
+
let m = this.viewMatrix,
|
|
221
224
|
vec0 = V_ARRAY[0].set(x, y),
|
|
222
225
|
vec1 = V_ARRAY[1].set(x + w, y),
|
|
223
226
|
vec2 = V_ARRAY[2].set(x, y + h),
|
|
@@ -18,7 +18,7 @@ import { minify } from "./utils/string.js";
|
|
|
18
18
|
* @see https://developer.mozilla.org/en-US/docs/Games/Techniques/3D_on_the_web/GLSL_Shaders
|
|
19
19
|
* @example
|
|
20
20
|
* // create a basic shader
|
|
21
|
-
*
|
|
21
|
+
* let myShader = new me.GLShader(
|
|
22
22
|
* // WebGL rendering context
|
|
23
23
|
* gl,
|
|
24
24
|
* // vertex shader
|
|
@@ -93,7 +93,7 @@ import { minify } from "./utils/string.js";
|
|
|
93
93
|
* @returns {GLint} number indicating the location of the variable name if found. Returns -1 otherwise
|
|
94
94
|
*/
|
|
95
95
|
getAttribLocation(name) {
|
|
96
|
-
|
|
96
|
+
let attr = this.attributes[name];
|
|
97
97
|
if (typeof attr !== "undefined") {
|
|
98
98
|
return attr;
|
|
99
99
|
} else {
|
|
@@ -109,7 +109,7 @@ import { minify } from "./utils/string.js";
|
|
|
109
109
|
* myShader.setUniform("uProjectionMatrix", this.projectionMatrix);
|
|
110
110
|
*/
|
|
111
111
|
setUniform(name, value) {
|
|
112
|
-
|
|
112
|
+
let uniforms = this.uniforms;
|
|
113
113
|
if (typeof uniforms[name] !== "undefined") {
|
|
114
114
|
if (typeof value === "object" && typeof value.toArray === "function") {
|
|
115
115
|
uniforms[name] = value.toArray();
|
|
@@ -129,9 +129,9 @@ import { minify } from "./utils/string.js";
|
|
|
129
129
|
*/
|
|
130
130
|
setVertexAttributes(gl, attributes, vertexByteSize) {
|
|
131
131
|
// set the vertex attributes
|
|
132
|
-
for (
|
|
133
|
-
|
|
134
|
-
|
|
132
|
+
for (let index = 0; index < attributes.length; ++index) {
|
|
133
|
+
let element = attributes[index];
|
|
134
|
+
let location = this.getAttribLocation(element.name);
|
|
135
135
|
|
|
136
136
|
if (location !== -1) {
|
|
137
137
|
gl.enableVertexAttribArray(location);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @ignore
|
|
3
3
|
*/
|
|
4
4
|
function compileShader(gl, type, source) {
|
|
5
|
-
|
|
5
|
+
let shader = gl.createShader(type);
|
|
6
6
|
gl.shaderSource(shader, source);
|
|
7
7
|
gl.compileShader(shader);
|
|
8
8
|
|
|
@@ -18,10 +18,10 @@ function compileShader(gl, type, source) {
|
|
|
18
18
|
* @ignore
|
|
19
19
|
*/
|
|
20
20
|
export function compileProgram(gl, vertex, fragment, attributes) {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
let vertShader = compileShader(gl, gl.VERTEX_SHADER, vertex);
|
|
22
|
+
let fragShader = compileShader(gl, gl.FRAGMENT_SHADER, fragment);
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
let program = gl.createProgram();
|
|
25
25
|
|
|
26
26
|
gl.attachShader(program, vertShader);
|
|
27
27
|
gl.attachShader(program, fragShader);
|
|
@@ -29,14 +29,14 @@ export function compileProgram(gl, vertex, fragment, attributes) {
|
|
|
29
29
|
|
|
30
30
|
// force vertex attributes to use location 0 as starting location to prevent
|
|
31
31
|
// browser to do complicated emulation when running on desktop OpenGL (e.g. on macOS)
|
|
32
|
-
for (
|
|
32
|
+
for (let location in attributes) {
|
|
33
33
|
gl.bindAttribLocation(program, attributes[location], location);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
gl.linkProgram(program);
|
|
37
37
|
|
|
38
38
|
if (!gl.getProgramParameter(program, gl.LINK_STATUS)) {
|
|
39
|
-
|
|
39
|
+
let error_msg =
|
|
40
40
|
"Error initializing Shader " + this + "\n" +
|
|
41
41
|
"gl.VALIDATE_STATUS: " + gl.getProgramParameter(program, gl.VALIDATE_STATUS) + "\n" +
|
|
42
42
|
"gl.getError()" + gl.getError() + "\n" +
|
|
@@ -26,7 +26,7 @@ const fnHash = {
|
|
|
26
26
|
* @ignore
|
|
27
27
|
*/
|
|
28
28
|
export function extractUniforms(gl, shader) {
|
|
29
|
-
|
|
29
|
+
let uniforms = {},
|
|
30
30
|
uniRx = /uniform\s+(\w+)\s+(\w+)/g,
|
|
31
31
|
uniformsData = {},
|
|
32
32
|
descriptor = {},
|
|
@@ -42,7 +42,7 @@ export function extractUniforms(gl, shader) {
|
|
|
42
42
|
|
|
43
43
|
// Get uniform references
|
|
44
44
|
Object.keys(uniformsData).forEach((name) => {
|
|
45
|
-
|
|
45
|
+
let type = uniformsData[name];
|
|
46
46
|
locations[name] = gl.getUniformLocation(shader.program, name);
|
|
47
47
|
|
|
48
48
|
descriptor[name] = {
|
|
@@ -68,7 +68,7 @@ export function extractUniforms(gl, shader) {
|
|
|
68
68
|
* A generic setter for uniform vectors
|
|
69
69
|
*/
|
|
70
70
|
return function (val) {
|
|
71
|
-
|
|
71
|
+
let fnv = fn;
|
|
72
72
|
if (val.length && fn.slice(-1) !== "v") {
|
|
73
73
|
fnv += "v";
|
|
74
74
|
}
|