Skip to content

Commit

Permalink
16.0.0 dist files
Browse files Browse the repository at this point in the history
  • Loading branch information
obiot committed Feb 3, 2024
1 parent ba232ad commit 846b928
Show file tree
Hide file tree
Showing 534 changed files with 5,460 additions and 2,279 deletions.
4 changes: 2 additions & 2 deletions dist/melonjs.mjs/_virtual/_commonjsHelpers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*!
* melonJS Game Engine - v15.15.0
* melonJS Game Engine - v16.0.0
* http://www.melonjs.org
* melonjs is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
* @copyright (C) 2011 - 2024 Olivier Biot (AltByte Pte Ltd)
*/
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

Expand Down
4 changes: 2 additions & 2 deletions dist/melonjs.mjs/_virtual/earcut.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*!
* melonJS Game Engine - v15.15.0
* melonJS Game Engine - v16.0.0
* http://www.melonjs.org
* melonjs is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
* @copyright (C) 2011 - 2024 Olivier Biot (AltByte Pte Ltd)
*/
var earcut = {exports: {}};

Expand Down
4 changes: 2 additions & 2 deletions dist/melonjs.mjs/_virtual/howler.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*!
* melonJS Game Engine - v15.15.0
* melonJS Game Engine - v16.0.0
* http://www.melonjs.org
* melonjs is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
* @copyright (C) 2011 - 2024 Olivier Biot (AltByte Pte Ltd)
*/
var howler = {};

Expand Down
4 changes: 2 additions & 2 deletions dist/melonjs.mjs/_virtual/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*!
* melonJS Game Engine - v15.15.0
* melonJS Game Engine - v16.0.0
* http://www.melonjs.org
* melonjs is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
* @copyright (C) 2011 - 2024 Olivier Biot (AltByte Pte Ltd)
*/
var eventemitter3 = {exports: {}};

Expand Down
4 changes: 2 additions & 2 deletions dist/melonjs.mjs/application/application.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*!
* melonJS Game Engine - v15.15.0
* melonJS Game Engine - v16.0.0
* http://www.melonjs.org
* melonjs is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
* @copyright (C) 2011 - 2024 Olivier Biot (AltByte Pte Ltd)
*/
import { autoDetectRenderer } from '../video/utils/autodetect.js';
import CanvasRenderer from '../video/canvas/canvas_renderer.js';
Expand Down
4 changes: 2 additions & 2 deletions dist/melonjs.mjs/application/header.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*!
* melonJS Game Engine - v15.15.0
* melonJS Game Engine - v16.0.0
* http://www.melonjs.org
* melonjs is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
* @copyright (C) 2011 - 2024 Olivier Biot (AltByte Pte Ltd)
*/
import { devicePixelRatio, platform, getScreenOrientation, language, hasWebAudio } from '../system/device.js';

Expand Down
4 changes: 2 additions & 2 deletions dist/melonjs.mjs/application/resize.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*!
* melonJS Game Engine - v15.15.0
* melonJS Game Engine - v16.0.0
* http://www.melonjs.org
* melonjs is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
* @copyright (C) 2011 - 2024 Olivier Biot (AltByte Pte Ltd)
*/
import { getElementBounds, getParentBounds, devicePixelRatio } from '../system/device.js';

Expand Down
8 changes: 5 additions & 3 deletions dist/melonjs.mjs/application/settings.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*!
* melonJS Game Engine - v15.15.0
* melonJS Game Engine - v16.0.0
* http://www.melonjs.org
* melonjs is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
* @copyright (C) 2011 - 2024 Olivier Biot (AltByte Pte Ltd)
*/
// default settings
const defaultSettings = {
Expand All @@ -24,13 +24,15 @@ const defaultSettings = {
powerPreference : "default",
verbose : false,
consoleHeader : true,
legacy : false
legacy : false,
canvas : undefined
};

/**
* Application & Renderer Settings definition.
* @typedef {object} Settings
* @property {string|HTMLElement} [parent=document.body] - the DOM parent element to hold the canvas in the HTML file
* @property {HTMLCanvasElement} [canvas] - an existing canvas element to use as the renderer target (by default melonJS will create its own canvas based on given parameters)
* @property {number|Renderer} [renderer=AUTO] - renderer to use (CANVAS, WEBGL, AUTO), or a custom renderer class
* @property {number|string} [scale=1.0] - enable scaling of the canvas ('auto' for automatic scaling)
* @property {"fit"|"fill-min"|"fill-max"|"flex"|"flex-width"|"flex-height"|"stretch"} [scaleMethod="fit"] - screen scaling modes : <br>
Expand Down
4 changes: 2 additions & 2 deletions dist/melonjs.mjs/audio/audio.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*!
* melonJS Game Engine - v15.15.0
* melonJS Game Engine - v16.0.0
* http://www.melonjs.org
* melonjs is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
* @copyright (C) 2011 - 2024 Olivier Biot (AltByte Pte Ltd)
*/
import '../node_modules/howler/dist/howler.js';
import { clamp } from '../math/math.js';
Expand Down
4 changes: 2 additions & 2 deletions dist/melonjs.mjs/camera/camera2d.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*!
* melonJS Game Engine - v15.15.0
* melonJS Game Engine - v16.0.0
* http://www.melonjs.org
* melonjs is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
* @copyright (C) 2011 - 2024 Olivier Biot (AltByte Pte Ltd)
*/
import Vector2d from '../math/vector2.js';
import Vector3d from '../math/vector3.js';
Expand Down
4 changes: 2 additions & 2 deletions dist/melonjs.mjs/const.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*!
* melonJS Game Engine - v15.15.0
* melonJS Game Engine - v16.0.0
* http://www.melonjs.org
* melonjs is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
* @copyright (C) 2011 - 2024 Olivier Biot (AltByte Pte Ltd)
*/
/**
* constant to select the HTML5 Canvas renderer
Expand Down
14 changes: 6 additions & 8 deletions dist/melonjs.mjs/geometries/ellipse.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*!
* melonJS Game Engine - v15.15.0
* melonJS Game Engine - v16.0.0
* http://www.melonjs.org
* melonjs is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
* @copyright (C) 2011 - 2024 Olivier Biot (AltByte Pte Ltd)
*/
import pool from '../system/pooling.js';

Expand Down Expand Up @@ -196,17 +196,15 @@ class Ellipse {
* // do something
* }
*/
contains() {
contains(...args) {
let _x, _y;

if (arguments.length === 2) {
if (args.length === 2) {
// x, y
_x = arguments[0];
_y = arguments[1];
[_x, _y] = args;
} else {
// vector
_x = arguments[0].x;
_y = arguments[0].y;
[_x, _y] = [args[0].x, args[0].y];
}

// Make position relative to object center point.
Expand Down
4 changes: 2 additions & 2 deletions dist/melonjs.mjs/geometries/line.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*!
* melonJS Game Engine - v15.15.0
* melonJS Game Engine - v16.0.0
* http://www.melonjs.org
* melonjs is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
* @copyright (C) 2011 - 2024 Olivier Biot (AltByte Pte Ltd)
*/
import pool from '../system/pooling.js';
import Polygon from './poly.js';
Expand Down
136 changes: 131 additions & 5 deletions dist/melonjs.mjs/geometries/path2d.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
/*!
* melonJS Game Engine - v15.15.0
* melonJS Game Engine - v16.0.0
* http://www.melonjs.org
* melonjs is licensed under the MIT License.
* http://www.opensource.org/licenses/mit-license
* @copyright (C) 2011 - 2023 Olivier Biot (AltByte Pte Ltd)
* @copyright (C) 2011 - 2024 Olivier Biot (AltByte Pte Ltd)
*/
import pool from '../system/pooling.js';
import { TAU } from '../math/math.js';
import earcut from '../node_modules/earcut/src/earcut.js';
import { endpointToCenterParameterization } from './toarccanvas.js';

/**
* @classdesc
* a simplified path2d implementation, supporting only one path
*/
class Path2D {
constructor() {
constructor(svgPath) {
/**
* the points defining the current path
* @type {Point[]}
Expand All @@ -36,8 +37,75 @@ class Path2D {

/* @ignore */
this.isDirty = false;

if (typeof svgPath === "string") {
this.parseSVGPath(svgPath);
}
}

/**
* Parses an SVG path string and adds the points to the current path.
* @param {string} svgPath - The SVG path string to parse.
*/
parseSVGPath(svgPath) {
// Split path into commands and coordinates
const pathCommands = svgPath.match(/([a-df-z])[^a-df-z]*/gi);
const points = this.points;
const startPoint = this.startPoint;
let lastPoint = startPoint;

this.beginPath();

// Process each command and corresponding coordinates
for (let i = 0; i < pathCommands.length; i++) {
const pathCommand = pathCommands[i];
const command = pathCommand[0].toUpperCase();
const coordinates = pathCommand.slice(1).trim().split(/[\s,]+/).map(parseFloat);

switch (command) {
case "A": {
// A command takes 5 coordinates
const p = endpointToCenterParameterization(...coordinates);
this.arc(p.x, p.y, p.radiusX, p.radiusY, p.rotation, p.startAngle, p.endAngle, p.applyanticlockwise);
}
break;
case "H":
// H take 1 coordinate
lastPoint = points.length === 0 ? startPoint : points[points.length-1];
this.lineTo(lastPoint.x + coordinates[0], lastPoint.y);
break;
case "V":
// V take 1 coordinate
lastPoint = points.length === 0 ? startPoint : points[points.length-1];
this.lineTo(lastPoint.x, lastPoint.y + coordinates[0]);
break;
case "M":
// M takes 2 coordinates
this.moveTo(...coordinates);
break;
case "L":
// L takes 2 coordinates
this.lineTo(...coordinates);
break;
case "Q":
// Q takes 4 coordinates
this.quadraticCurveTo(...coordinates);
break;
case "C":
// C takes 6 coordinates
this.bezierCurveTo(...coordinates);
break;
case "Z":
this.closePath();
break;
default:
console.warn("Unsupported command:", command);
break;
}
}
}


/**
* begin a new path
*/
Expand Down Expand Up @@ -197,9 +265,11 @@ class Path2D {
*/
arcTo(x1, y1, x2, y2, radius) {
let points = this.points;
// based on from https://github.com/karellodewijk/canvas-webgl/blob/master/canvas-webgl.js
let x0 = points[points.length-1].x, y0 = points[points.length-1].y;
let startPoint = this.startPoint;
let lastPoint = points.length === 0 ? startPoint : points[points.length-1];

// based on from https://github.com/karellodewijk/canvas-webgl/blob/master/canvas-webgl.js
let x0 = lastPoint.x, y0 = lastPoint.y;
//a = -incoming vector, b = outgoing vector to x1, y1
let a0 = x0 - x1, a1 = y0 - y1;
let b0 = x2 - x1, b1 = y2 - y1;
Expand Down Expand Up @@ -293,6 +363,62 @@ class Path2D {
this.isDirty = true;
}

/**
* Adds a quadratic Bézier curve to the path.
* @param {number} cpX - The x-coordinate of the control point.
* @param {number} cpY - The y-coordinate of the control point.
* @param {number} x - The x-coordinate of the end point of the curve.
* @param {number} y - The y-coordinate of the end point of the curve.
*/
quadraticCurveTo(cpX, cpY, x, y) {
const points = this.points;
const startPoint = this.startPoint;
const lastPoint = points.length === 0 ? startPoint : points[points.length-1];
const endPoint = pool.pull("Point").set(x, y);
const controlPoint = pool.pull("Point").set(cpX, cpY);
const resolution = this.arcResolution;

const t = 1 / resolution;
for (let i = 1; i <= resolution; i++) {
this.lineTo(
lastPoint.x * Math.pow(1 - t * i, 2) + controlPoint.x * 2 * (1 - t * i) * t * i + endPoint.x * Math.pow(t * i, 2),
lastPoint.y * Math.pow(1 - t * i, 2) + controlPoint.y * 2 * (1 - t * i) * t * i + endPoint.y * Math.pow(t * i, 2)
);
}
pool.push(endPoint, controlPoint);
this.isDirty = true;
}

/**
* Adds a cubic Bézier curve to the path.
* @param {number} cp1X - The x-coordinate of the first control point.
* @param {number} cp1Y - The y-coordinate of the first control point.
* @param {number} cp2X - The x-coordinate of the second control point.
* @param {number} cp2Y - The y-coordinate of the second control point.
* @param {number} x - The x-coordinate of the end point of the curve.
* @param {number} y - The y-coordinate of the end point of the curve.
*/
bezierCurveTo(cp1X, cp1Y, cp2X, cp2Y, x, y) {
const points = this.points;
const startPoint = this.startPoint;
const lastPoint = points.length === 0 ? startPoint : points[points.length-1];
const endPoint = pool.pull("Point").set(x, y);
const controlPoint1 = pool.pull("Point").set(cp1X, cp1Y);
const controlPoint2 = pool.pull("Point").set(cp2X, cp2Y);
const resolution = this.arcResolution;

const t = 1 / resolution;
for (let i = 1; i <= resolution; i++) {
this.lineTo(
lastPoint.x * Math.pow(1 - t * i, 3) + controlPoint1.x * 3 * Math.pow(1 - t * i, 2) * t * i + controlPoint2.x * 3 * (1 - t * i) * Math.pow(t * i, 2) + endPoint.x * Math.pow(t * i, 3),
lastPoint.y * Math.pow(1 - t * i, 3) + controlPoint1.y * 3 * Math.pow(1 - t * i, 2) * t * i + controlPoint2.y * 3 * (1 - t * i) * Math.pow(t * i, 2) + endPoint.y * Math.pow(t * i, 3)
);
}

pool.push(endPoint, controlPoint1, controlPoint2);
this.isDirty = true;
}

/**
* creates a path for a rectangle at position (x, y) with a size that is determined by width and height.
* @param {number} x - the x-axis coordinate of the rectangle's starting point.
Expand Down
Loading

0 comments on commit 846b928

Please sign in to comment.