Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@pixi/canvas-mesh

Package Overview
Dependencies
Maintainers
3
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/canvas-mesh - npm Package Compare versions

Comparing version 5.0.0-alpha.3 to 5.0.0-rc

239

lib/canvas-mesh.es.js
/*!
* @pixi/canvas-mesh - v5.0.0-alpha.3
* Compiled Tue, 03 Jul 2018 04:08:21 UTC
* @pixi/canvas-mesh - v5.0.0-rc
* Compiled Fri, 01 Feb 2019 04:50:10 UTC
*

@@ -9,5 +9,5 @@ * @pixi/canvas-mesh is licensed under the MIT License.

import { DRAW_MODES } from '@pixi/constants';
import { settings as settings$1 } from '@pixi/settings';
import { Mesh2d, NineSlicePlane } from '@pixi/mesh-extras';
import { Mesh } from '@pixi/mesh';
import { settings } from '@pixi/settings';
import { MeshMaterial, Mesh } from '@pixi/mesh';
import { NineSlicePlane, SimpleMesh, SimpleRope } from '@pixi/mesh-extras';

@@ -18,3 +18,3 @@ /**

* @class
* @private
* @protected
* @memberof PIXI

@@ -32,3 +32,3 @@ */

*/
CanvasMeshRenderer.prototype.render = function render (mesh$$1)
CanvasMeshRenderer.prototype.render = function render (mesh)
{

@@ -38,6 +38,6 @@ var renderer = this.renderer;

var transform = mesh$$1.worldTransform;
var transform = mesh.worldTransform;
var res = renderer.resolution;
if (renderer.roundPixels)
if (mesh.roundPixels)
{

@@ -65,12 +65,12 @@ context.setTransform(

renderer.context.globalAlpha = mesh$$1.worldAlpha;
renderer.setBlendMode(mesh$$1.blendMode);
renderer.context.globalAlpha = mesh.worldAlpha;
renderer.setBlendMode(mesh.blendMode);
if (mesh$$1.drawMode !== DRAW_MODES.TRIANGLES)
if (mesh.drawMode !== DRAW_MODES.TRIANGLES)
{
this._renderTriangleMesh(mesh$$1);
this._renderTriangleMesh(mesh);
}
else
{
this._renderTriangles(mesh$$1);
this._renderTriangles(mesh);
}

@@ -85,8 +85,6 @@ };

*/
CanvasMeshRenderer.prototype._renderTriangleMesh = function _renderTriangleMesh (mesh$$1)
CanvasMeshRenderer.prototype._renderTriangleMesh = function _renderTriangleMesh (mesh)
{
var this$1 = this;
// draw triangles!!
var length = mesh$$1.geometry.buffers[0].data.length;
var length = mesh.geometry.buffers[0].data.length;

@@ -98,3 +96,3 @@ for (var i = 0; i < length - 2; i++)

this$1._renderDrawTriangle(mesh$$1, index, (index + 2), (index + 4));
this._renderDrawTriangle(mesh, index, (index + 2), (index + 4));
}

@@ -109,8 +107,6 @@ };

*/
CanvasMeshRenderer.prototype._renderTriangles = function _renderTriangles (mesh$$1)
CanvasMeshRenderer.prototype._renderTriangles = function _renderTriangles (mesh)
{
var this$1 = this;
// draw triangles!!
var indices = mesh$$1.geometry.getIndex().data;
var indices = mesh.geometry.getIndex().data;
var length = indices.length;

@@ -125,3 +121,3 @@

this$1._renderDrawTriangle(mesh$$1, index0, index1, index2);
this._renderDrawTriangle(mesh, index0, index1, index2);
}

@@ -139,8 +135,8 @@ };

*/
CanvasMeshRenderer.prototype._renderDrawTriangle = function _renderDrawTriangle (mesh$$1, index0, index1, index2)
CanvasMeshRenderer.prototype._renderDrawTriangle = function _renderDrawTriangle (mesh, index0, index1, index2)
{
var context = this.renderer.context;
var vertices = mesh$$1.geometry.buffers[0].data;
var uvs = mesh$$1.geometry.buffers[1].data;
var texture = mesh$$1._texture;
var vertices = mesh.geometry.buffers[0].data;
var uvs = mesh.uvs;
var texture = mesh.texture;

@@ -157,30 +153,9 @@ if (!texture.valid)

var u0;
var u1;
var u2;
var v0;
var v1;
var v2;
var u0 = uvs[index0] * base.width;
var u1 = uvs[index1] * base.width;
var u2 = uvs[index2] * base.width;
var v0 = uvs[index0 + 1] * base.height;
var v1 = uvs[index1 + 1] * base.height;
var v2 = uvs[index2 + 1] * base.height;
if (mesh$$1.uploadUvTransform)
{
var ut = mesh$$1._uvTransform.mapCoord;
u0 = ((uvs[index0] * ut.a) + (uvs[index0 + 1] * ut.c) + ut.tx) * base.width;
u1 = ((uvs[index1] * ut.a) + (uvs[index1 + 1] * ut.c) + ut.tx) * base.width;
u2 = ((uvs[index2] * ut.a) + (uvs[index2 + 1] * ut.c) + ut.tx) * base.width;
v0 = ((uvs[index0] * ut.b) + (uvs[index0 + 1] * ut.d) + ut.ty) * base.height;
v1 = ((uvs[index1] * ut.b) + (uvs[index1 + 1] * ut.d) + ut.ty) * base.height;
v2 = ((uvs[index2] * ut.b) + (uvs[index2 + 1] * ut.d) + ut.ty) * base.height;
}
else
{
u0 = uvs[index0] * base.width;
u1 = uvs[index1] * base.width;
u2 = uvs[index2] * base.width;
v0 = uvs[index0 + 1] * base.height;
v1 = uvs[index1 + 1] * base.height;
v2 = uvs[index2 + 1] * base.height;
}
var x0 = vertices[index0];

@@ -193,8 +168,8 @@ var x1 = vertices[index1];

var canvasPadding = mesh$$1.canvasPadding / this.renderer.resolution;
var canvasPadding = mesh.canvasPadding / this.renderer.resolution;
if (canvasPadding > 0)
{
var paddingX = canvasPadding / Math.abs(mesh$$1.worldTransform.a);
var paddingY = canvasPadding / Math.abs(mesh$$1.worldTransform.d);
var paddingX = canvasPadding / Math.abs(mesh.worldTransform.a);
var paddingY = canvasPadding / Math.abs(mesh.worldTransform.d);
var centerX = (x0 + x1 + x2) / 3;

@@ -279,6 +254,6 @@ var centerY = (y0 + y1 + y2) / 3;

*/
CanvasMeshRenderer.prototype.renderMeshFlat = function renderMeshFlat (mesh$$1)
CanvasMeshRenderer.prototype.renderMeshFlat = function renderMeshFlat (mesh)
{
var context = this.renderer.context;
var vertices = mesh$$1.geometry.getAttribute('aVertexPosition').data;
var vertices = mesh.geometry.getAttribute('aVertexPosition').data;
var length = vertices.length / 2;

@@ -328,44 +303,24 @@

* @static
* @constant
* @name MESH_CANVAS_PADDING
* @memberof PIXI.settings
* @member {number} MESH_CANVAS_PADDING
* @type {number}
* @default 0
*/
settings$1.MESH_CANVAS_PADDING = 0;
settings.MESH_CANVAS_PADDING = 0;
// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created
// this was merely created to completely decouple canvas from the base Mesh class and we are
// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4.
/**
* Internal variable for `canvasPadding`.
* Renders the mesh using the Canvas renderer
*
* @private
* @memberof PIXI.Mesh2d
* @member {number}
* @default null
* @protected
* @method render
* @memberof PIXI.MeshMaterial#
* @param {PIXI.CanvasRenderer} renderer - The canvas renderer.
* @param {PIXI.Mesh} mesh - Mesh to render.
*/
Mesh2d.prototype._canvasPadding = null;
MeshMaterial.prototype._renderCanvas = function _renderCanvas(renderer, mesh)
{
renderer.plugins.mesh.render(mesh);
};
/**
* Triangles in canvas mode are automatically antialiased, use this value to force triangles
* to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING}
*
* @see PIXI.settings.MESH_CANVAS_PADDING
* @member {number} canvasPadding
* @memberof PIXI.Mesh2d#
* @default 0
*/
Object.defineProperty(Mesh2d.prototype, 'canvasPadding', {
get: function get()
{
return this._canvasPadding !== null ? this._canvasPadding : settings$1.MESH_CANVAS_PADDING;
},
set: function set(value)
{
this._canvasPadding = value;
},
});
/**
* Renders the object using the Canvas renderer

@@ -388,3 +343,3 @@ *

if (renderer.roundPixels)
if (this.roundPixels)
{

@@ -436,3 +391,3 @@ context.setTransform(

* @param {CanvasRenderingContext2D} context - The context to draw with.
* @param {CanvasImageSource} textureSource - The source to draw.
* @param {ICanvasImageSource} textureSource - The source to draw.
* @param {number} w - width of the texture

@@ -492,6 +447,98 @@ * @param {number} h - height of the texture

{
renderer.plugins[this.pluginName].render(this);
if (this.shader.uvMatrix)
{
this.shader.uvMatrix.update();
this.calculateUvs();
}
this.material._renderCanvas(renderer, this);
};
// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created
// this was merely created to completely decouple canvas from the base Mesh class and we are
// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4.
/**
* Internal variable for `canvasPadding`.
*
* @private
* @memberof PIXI.Mesh
* @member {number}
* @default null
*/
Mesh.prototype._canvasPadding = null;
/**
* Triangles in canvas mode are automatically antialiased, use this value to force triangles
* to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING}
*
* @see PIXI.settings.MESH_CANVAS_PADDING
* @member {number} canvasPadding
* @memberof PIXI.SimpleMesh#
* @default 0
*/
Object.defineProperty(Mesh.prototype, 'canvasPadding', {
get: function get()
{
return this._canvasPadding !== null ? this._canvasPadding : settings.MESH_CANVAS_PADDING;
},
set: function set(value)
{
this._canvasPadding = value;
},
});
/**
* Renders the object using the Canvas renderer
*
* @private
* @method _renderCanvas
* @memberof PIXI.Mesh#
* @param {PIXI.CanvasRenderer} renderer - The canvas renderer.
*/
SimpleMesh.prototype._renderCanvas = function _renderCanvas(renderer)
{
if (this.autoUpdate)
{
this.geometry.getAttribute('aVertexPosition').update();
}
if (this.shader.update)
{
this.shader.update();
}
this.calculateUvs();
this.material._renderCanvas(renderer, this);
};
/**
* Renders the object using the Canvas renderer
*
* @protected
* @method _renderCanvas
* @memberof PIXI.Mesh#
* @param {PIXI.CanvasRenderer} renderer - The canvas renderer.
*/
SimpleRope.prototype._renderCanvas = function _renderCanvas(renderer)
{
if (this.autoUpdate
|| this.geometry.width !== this.shader.texture.height)
{
this.geometry.width = this.shader.texture.height;
this.geometry.update();
}
if (this.shader.update)
{
this.shader.update();
}
this.calculateUvs();
this.material._renderCanvas(renderer, this);
};
export { CanvasMeshRenderer };
//# sourceMappingURL=canvas-mesh.es.js.map
/*!
* @pixi/canvas-mesh - v5.0.0-alpha.3
* Compiled Tue, 03 Jul 2018 04:08:21 UTC
* @pixi/canvas-mesh - v5.0.0-rc
* Compiled Fri, 01 Feb 2019 04:50:10 UTC
*

@@ -14,4 +14,4 @@ * @pixi/canvas-mesh is licensed under the MIT License.

var settings = require('@pixi/settings');
var mesh = require('@pixi/mesh');
var meshExtras = require('@pixi/mesh-extras');
var mesh = require('@pixi/mesh');

@@ -22,3 +22,3 @@ /**

* @class
* @private
* @protected
* @memberof PIXI

@@ -44,3 +44,3 @@ */

if (renderer.roundPixels)
if (mesh$$1.roundPixels)
{

@@ -89,4 +89,2 @@ context.setTransform(

{
var this$1 = this;
// draw triangles!!

@@ -100,3 +98,3 @@ var length = mesh$$1.geometry.buffers[0].data.length;

this$1._renderDrawTriangle(mesh$$1, index, (index + 2), (index + 4));
this._renderDrawTriangle(mesh$$1, index, (index + 2), (index + 4));
}

@@ -113,4 +111,2 @@ };

{
var this$1 = this;
// draw triangles!!

@@ -127,3 +123,3 @@ var indices = mesh$$1.geometry.getIndex().data;

this$1._renderDrawTriangle(mesh$$1, index0, index1, index2);
this._renderDrawTriangle(mesh$$1, index0, index1, index2);
}

@@ -145,4 +141,4 @@ };

var vertices = mesh$$1.geometry.buffers[0].data;
var uvs = mesh$$1.geometry.buffers[1].data;
var texture = mesh$$1._texture;
var uvs = mesh$$1.uvs;
var texture = mesh$$1.texture;

@@ -159,30 +155,9 @@ if (!texture.valid)

var u0;
var u1;
var u2;
var v0;
var v1;
var v2;
var u0 = uvs[index0] * base.width;
var u1 = uvs[index1] * base.width;
var u2 = uvs[index2] * base.width;
var v0 = uvs[index0 + 1] * base.height;
var v1 = uvs[index1 + 1] * base.height;
var v2 = uvs[index2 + 1] * base.height;
if (mesh$$1.uploadUvTransform)
{
var ut = mesh$$1._uvTransform.mapCoord;
u0 = ((uvs[index0] * ut.a) + (uvs[index0 + 1] * ut.c) + ut.tx) * base.width;
u1 = ((uvs[index1] * ut.a) + (uvs[index1 + 1] * ut.c) + ut.tx) * base.width;
u2 = ((uvs[index2] * ut.a) + (uvs[index2 + 1] * ut.c) + ut.tx) * base.width;
v0 = ((uvs[index0] * ut.b) + (uvs[index0 + 1] * ut.d) + ut.ty) * base.height;
v1 = ((uvs[index1] * ut.b) + (uvs[index1 + 1] * ut.d) + ut.ty) * base.height;
v2 = ((uvs[index2] * ut.b) + (uvs[index2 + 1] * ut.d) + ut.ty) * base.height;
}
else
{
u0 = uvs[index0] * base.width;
u1 = uvs[index1] * base.width;
u2 = uvs[index2] * base.width;
v0 = uvs[index0 + 1] * base.height;
v1 = uvs[index1 + 1] * base.height;
v2 = uvs[index2 + 1] * base.height;
}
var x0 = vertices[index0];

@@ -328,5 +303,5 @@ var x1 = vertices[index1];

* @static
* @constant
* @name MESH_CANVAS_PADDING
* @memberof PIXI.settings
* @member {number} MESH_CANVAS_PADDING
* @type {number}
* @default 0

@@ -336,37 +311,17 @@ */

// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created
// this was merely created to completely decouple canvas from the base Mesh class and we are
// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4.
/**
* Internal variable for `canvasPadding`.
* Renders the mesh using the Canvas renderer
*
* @private
* @memberof PIXI.Mesh2d
* @member {number}
* @default null
* @protected
* @method render
* @memberof PIXI.MeshMaterial#
* @param {PIXI.CanvasRenderer} renderer - The canvas renderer.
* @param {PIXI.Mesh} mesh - Mesh to render.
*/
meshExtras.Mesh2d.prototype._canvasPadding = null;
mesh.MeshMaterial.prototype._renderCanvas = function _renderCanvas(renderer, mesh$$1)
{
renderer.plugins.mesh.render(mesh$$1);
};
/**
* Triangles in canvas mode are automatically antialiased, use this value to force triangles
* to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING}
*
* @see PIXI.settings.MESH_CANVAS_PADDING
* @member {number} canvasPadding
* @memberof PIXI.Mesh2d#
* @default 0
*/
Object.defineProperty(meshExtras.Mesh2d.prototype, 'canvasPadding', {
get: function get()
{
return this._canvasPadding !== null ? this._canvasPadding : settings.settings.MESH_CANVAS_PADDING;
},
set: function set(value)
{
this._canvasPadding = value;
},
});
/**
* Renders the object using the Canvas renderer

@@ -389,3 +344,3 @@ *

if (renderer.roundPixels)
if (this.roundPixels)
{

@@ -437,3 +392,3 @@ context.setTransform(

* @param {CanvasRenderingContext2D} context - The context to draw with.
* @param {CanvasImageSource} textureSource - The source to draw.
* @param {ICanvasImageSource} textureSource - The source to draw.
* @param {number} w - width of the texture

@@ -493,6 +448,98 @@ * @param {number} h - height of the texture

{
renderer.plugins[this.pluginName].render(this);
if (this.shader.uvMatrix)
{
this.shader.uvMatrix.update();
this.calculateUvs();
}
this.material._renderCanvas(renderer, this);
};
// IMPORTANT: Please do NOT use this as a precedent to use `settings` after the object is created
// this was merely created to completely decouple canvas from the base Mesh class and we are
// unable to add `canvasPadding` in the constructor anymore, as the case was for PixiJS v4.
/**
* Internal variable for `canvasPadding`.
*
* @private
* @memberof PIXI.Mesh
* @member {number}
* @default null
*/
mesh.Mesh.prototype._canvasPadding = null;
/**
* Triangles in canvas mode are automatically antialiased, use this value to force triangles
* to overlap a bit with each other. To set the global default, set {@link PIXI.settings.MESH_CANVAS_PADDING}
*
* @see PIXI.settings.MESH_CANVAS_PADDING
* @member {number} canvasPadding
* @memberof PIXI.SimpleMesh#
* @default 0
*/
Object.defineProperty(mesh.Mesh.prototype, 'canvasPadding', {
get: function get()
{
return this._canvasPadding !== null ? this._canvasPadding : settings.settings.MESH_CANVAS_PADDING;
},
set: function set(value)
{
this._canvasPadding = value;
},
});
/**
* Renders the object using the Canvas renderer
*
* @private
* @method _renderCanvas
* @memberof PIXI.Mesh#
* @param {PIXI.CanvasRenderer} renderer - The canvas renderer.
*/
meshExtras.SimpleMesh.prototype._renderCanvas = function _renderCanvas(renderer)
{
if (this.autoUpdate)
{
this.geometry.getAttribute('aVertexPosition').update();
}
if (this.shader.update)
{
this.shader.update();
}
this.calculateUvs();
this.material._renderCanvas(renderer, this);
};
/**
* Renders the object using the Canvas renderer
*
* @protected
* @method _renderCanvas
* @memberof PIXI.Mesh#
* @param {PIXI.CanvasRenderer} renderer - The canvas renderer.
*/
meshExtras.SimpleRope.prototype._renderCanvas = function _renderCanvas(renderer)
{
if (this.autoUpdate
|| this.geometry.width !== this.shader.texture.height)
{
this.geometry.width = this.shader.texture.height;
this.geometry.update();
}
if (this.shader.update)
{
this.shader.update();
}
this.calculateUvs();
this.material._renderCanvas(renderer, this);
};
exports.CanvasMeshRenderer = CanvasMeshRenderer;
//# sourceMappingURL=canvas-mesh.js.map
{
"name": "@pixi/canvas-mesh",
"version": "5.0.0-alpha.3",
"version": "5.0.0-rc",
"main": "lib/canvas-mesh.js",
"module": "lib/canvas-mesh.es.js",
"description": "PixiJS Application",
"description": "Canvas mixin for the mesh package",
"author": "Mat Groves",

@@ -25,10 +25,11 @@ "contributors": [

"dependencies": {
"@pixi/constants": "^5.0.0-alpha.3",
"@pixi/mesh": "^5.0.0-alpha.3",
"@pixi/mesh-extras": "^5.0.0-alpha.3",
"@pixi/settings": "^5.0.0-alpha.3"
"@pixi/constants": "^5.0.0-rc",
"@pixi/mesh": "^5.0.0-rc",
"@pixi/mesh-extras": "^5.0.0-rc",
"@pixi/settings": "^5.0.0-rc"
},
"devDependencies": {
"floss": "^2.1.3"
}
"floss": "^2.1.5"
},
"gitHead": "9026a1bbca9a9d86b7a3b6d5eb4fa2c3145c2b85"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc