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

@pixi/filter-simple-lightmap

Package Overview
Dependencies
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pixi/filter-simple-lightmap - npm Package Compare versions

Comparing version 2.7.0 to 3.0.0

dist/filter-simple-lightmap.js

116

lib/filter-simple-lightmap.esm.js
/*!
* @pixi/filter-simple-lightmap - v2.7.0
* Compiled Sun, 13 Jan 2019 22:51:52 UTC
* Compiled Fri, 10 May 2019 22:56:42 UTC
*

@@ -8,3 +8,115 @@ * @pixi/filter-simple-lightmap is licensed under the MIT License.

*/
import{utils as o,Filter as r}from"pixi.js";var t="attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}",e="varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform sampler2D uLightmap;\nuniform vec4 filterArea;\nuniform vec2 dimensions;\nuniform vec4 ambientColor;\nvoid main() {\n vec4 diffuseColor = texture2D(uSampler, vTextureCoord);\n vec2 lightCoord = (vTextureCoord * filterArea.xy) / dimensions;\n vec4 light = texture2D(uLightmap, lightCoord);\n vec3 ambient = ambientColor.rgb * ambientColor.a;\n vec3 intensity = ambient + light.rgb;\n vec3 finalColor = diffuseColor.rgb * intensity;\n gl_FragColor = vec4(finalColor, diffuseColor.a);\n}\n",i=function(r){function i(o,i,n){void 0===i&&(i=0),void 0===n&&(n=1),r.call(this,t,e),this.uniforms.dimensions=new Float32Array(2),this.uniforms.ambientColor=new Float32Array([0,0,0,n]),this.texture=o,this.color=i}r&&(i.__proto__=r),i.prototype=Object.create(r&&r.prototype),i.prototype.constructor=i;var n={texture:{configurable:!0},color:{configurable:!0},alpha:{configurable:!0}};return i.prototype.apply=function(o,r,t,e){this.uniforms.dimensions[0]=r.sourceFrame.width,this.uniforms.dimensions[1]=r.sourceFrame.height,o.applyFilter(this,r,t,e)},n.texture.get=function(){return this.uniforms.uLightmap},n.texture.set=function(o){this.uniforms.uLightmap=o},n.color.set=function(r){var t=this.uniforms.ambientColor;"number"==typeof r?(o.hex2rgb(r,t),this._color=r):(t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],this._color=o.rgb2hex(t))},n.color.get=function(){return this._color},n.alpha.get=function(){return this.uniforms.ambientColor[3]},n.alpha.set=function(o){this.uniforms.ambientColor[3]=o},Object.defineProperties(i.prototype,n),i}(r);export{i as SimpleLightmapFilter};
import { Filter } from '@pixi/core';
import { hex2rgb, rgb2hex } from '@pixi/utils';
var vertex = "attribute vec2 aVertexPosition;\nattribute vec2 aTextureCoord;\n\nuniform mat3 projectionMatrix;\n\nvarying vec2 vTextureCoord;\n\nvoid main(void)\n{\n gl_Position = vec4((projectionMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);\n vTextureCoord = aTextureCoord;\n}";
var fragment = "varying vec2 vTextureCoord;\nuniform sampler2D uSampler;\nuniform sampler2D uLightmap;\nuniform vec4 filterArea;\nuniform vec2 dimensions;\nuniform vec4 ambientColor;\nvoid main() {\n vec4 diffuseColor = texture2D(uSampler, vTextureCoord);\n vec2 lightCoord = (vTextureCoord * filterArea.xy) / dimensions;\n vec4 light = texture2D(uLightmap, lightCoord);\n vec3 ambient = ambientColor.rgb * ambientColor.a;\n vec3 intensity = ambient + light.rgb;\n vec3 finalColor = diffuseColor.rgb * intensity;\n gl_FragColor = vec4(finalColor, diffuseColor.a);\n}\n";
/**
* SimpleLightmap, originally by Oza94
* http://www.html5gamedevs.com/topic/20027-pixijs-simple-lightmapping/
* http://codepen.io/Oza94/pen/EPoRxj
*
* You have to specify filterArea, or suffer consequences.
* You may have to use it with `filter.dontFit = true`,
* until we rewrite this using same approach as for DisplacementFilter.
*
* ![original](../tools/screenshots/dist/original.png)![filter](../tools/screenshots/dist/simple-lightmap.png)
* @class
* @extends PIXI.Filter
* @memberof PIXI.filters
* @see {@link https://www.npmjs.com/package/@pixi/filter-simple-lightmap|@pixi/filter-simple-lightmap}
* @see {@link https://www.npmjs.com/package/pixi-filters|pixi-filters}
* @param {PIXI.Texture} texture a texture where your lightmap is rendered
* @param {Array<number>|number} [color=0x000000] An RGBA array of the ambient color
* @param {number} [alpha=1] Default alpha set independent of color (if it's a number, not array).
*
* @example
* displayObject.filters = [new SimpleLightmapFilter(texture, 0x666666)];
*/
var SimpleLightmapFilter = /*@__PURE__*/(function (Filter) {
function SimpleLightmapFilter(texture, color, alpha) {
if ( color === void 0 ) color = 0x000000;
if ( alpha === void 0 ) alpha = 1;
Filter.call(this, vertex, fragment);
this.uniforms.dimensions = new Float32Array(2);
this.uniforms.ambientColor = new Float32Array([0, 0, 0, alpha]);
this.texture = texture;
this.color = color;
}
if ( Filter ) SimpleLightmapFilter.__proto__ = Filter;
SimpleLightmapFilter.prototype = Object.create( Filter && Filter.prototype );
SimpleLightmapFilter.prototype.constructor = SimpleLightmapFilter;
var prototypeAccessors = { texture: { configurable: true },color: { configurable: true },alpha: { configurable: true } };
/**
* Applies the filter.
* @private
* @param {PIXI.FilterManager} filterManager - The manager.
* @param {PIXI.RenderTarget} input - The input target.
* @param {PIXI.RenderTarget} output - The output target.
*/
SimpleLightmapFilter.prototype.apply = function apply (filterManager, input, output, clear) {
this.uniforms.dimensions[0] = input.filterFrame.width;
this.uniforms.dimensions[1] = input.filterFrame.height;
// draw the filter...
filterManager.applyFilter(this, input, output, clear);
};
/**
* a texture where your lightmap is rendered
* @member {PIXI.Texture}
*/
prototypeAccessors.texture.get = function () {
return this.uniforms.uLightmap;
};
prototypeAccessors.texture.set = function (value) {
this.uniforms.uLightmap = value;
};
/**
* An RGBA array of the ambient color or a hex color without alpha
* @member {Array<number>|number}
*/
prototypeAccessors.color.set = function (value) {
var arr = this.uniforms.ambientColor;
if (typeof value === 'number') {
hex2rgb(value, arr);
this._color = value;
}
else {
arr[0] = value[0];
arr[1] = value[1];
arr[2] = value[2];
arr[3] = value[3];
this._color = rgb2hex(arr);
}
};
prototypeAccessors.color.get = function () {
return this._color;
};
/**
* When setting `color` as hex, this can be used to set alpha independently.
* @member {number}
*/
prototypeAccessors.alpha.get = function () {
return this.uniforms.ambientColor[3];
};
prototypeAccessors.alpha.set = function (value) {
this.uniforms.ambientColor[3] = value;
};
Object.defineProperties( SimpleLightmapFilter.prototype, prototypeAccessors );
return SimpleLightmapFilter;
}(Filter));
export { SimpleLightmapFilter };
//# sourceMappingURL=filter-simple-lightmap.esm.js.map

17

package.json
{
"name": "@pixi/filter-simple-lightmap",
"version": "2.7.0",
"main": "lib/filter-simple-lightmap.js",
"description": "PixiJS v4 filter to create a light-map from a texture",
"version": "3.0.0",
"main": "lib/filter-simple-lightmap.cjs.js",
"bundle": "dist/filter-simple-lightmap.js",
"description": "PixiJS filter to create a light-map from a texture",
"author": "Mat Groves",

@@ -24,11 +25,13 @@ "contributors": [

"lib",
"dist",
"types.d.ts"
],
"peerDependencies": {
"pixi.js": ">=4.0.0"
"dependencies": {
"@pixi/core": "^5.0.0-X",
"@pixi/utils": "^5.0.0-X"
},
"devDependencies": {
"@tools/fragments": "^2.0.0"
"@tools/fragments": "^3.0.0"
},
"gitHead": "a1329fadd2910c48842c92f254be77d971a823ca"
"gitHead": "0902eca3fe476dd7dacc9330f504d8e2ade6c9bd"
}
# SimpleLightmapFilter
PixiJS v4 filter to create a light-map from a texture.
PixiJS filter to create a light-map from a texture.

@@ -5,0 +5,0 @@ ## Installation

/// <reference types="pixi.js" />
declare namespace PIXI.filters {
class SimpleLightmapFilter extends PIXI.Filter<{}> {
declare module "@pixi/filter-simple-lightmap" {
export class SimpleLightmapFilter extends PIXI.Filter {
constructor(texture:PIXI.Texture, color?:number[]|number);

@@ -10,5 +10,1 @@ alpha:number;

}
declare module "@pixi/filter-simple-lightmap" {
export = PIXI.filters;
}

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