mirror of
https://github.com/bakustarver/rpgmakermlinux-cicpoffs.git
synced 2025-03-28 14:56:21 +01:00
Add files via upload
This commit is contained in:
parent
05e550b74e
commit
c819b00971
25 changed files with 166151 additions and 0 deletions
21
nwjs/packagefiles/rpgmaker-mv-pixi5/LICENSE
Normal file
21
nwjs/packagefiles/rpgmaker-mv-pixi5/LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 Scott Atkins
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
40
nwjs/packagefiles/rpgmaker-mv-pixi5/README.md
Normal file
40
nwjs/packagefiles/rpgmaker-mv-pixi5/README.md
Normal file
|
@ -0,0 +1,40 @@
|
|||
# RPGMaker MV Game Engine 1.6.2.1
|
||||
|
||||
This is a set of updates based on RPGMaker MV 1.6.2 to use [PixiJS 5.3.3](https://github.com/pixijs/pixi.js/releases/tag/v5.3.3)
|
||||
|
||||
## Features
|
||||
|
||||
- Faster rendering
|
||||
- Case insensitive file loading to better support Linux/Android without having to change your scripts
|
||||
- With [NW.js v0.45.6](https://dl.nwjs.io/v0.45.6/) plays webm (VP8/VP9) files properly
|
||||
- Filter change for Pixi-Picture to get it to run properly (Issue submitted waiting for a real fix)
|
||||
- Added more keys in the keymap for easier use in scripts
|
||||
- Fixes to documentation, spelling, and javascript syntax
|
||||
- Added jshint information
|
||||
|
||||
## Known Issues
|
||||
|
||||
- ShaderTilemap is not working properly falling back on Tilemap
|
||||
- Doesn't seem to be affecting performance
|
||||
- Plugins the load files directly or override the functions which load from disk may fail in case sensitive environments
|
||||
- Wrap the file path with `CS_URL.MapURL()` to ensure it resolves to the correct case sensitive name
|
||||
- Overrides or calls to `refereshVehicles` will fail
|
||||
- Use `refreshVehicles` instead
|
||||
- Overrides or calls to `updateButtonsVisiblity` will fail
|
||||
- Use `updateButtonsVisibility` instead
|
||||
|
||||
## Further Work
|
||||
|
||||
- Cleanup of Javascript (using let/const)
|
||||
- Add updates to plugins
|
||||
- Investigate if garbage collection needs to run (possibly do this during scene changes)
|
||||
- Check for any memory leaks
|
||||
- Submit issue against Pixi-Tilemap for the rendering issue
|
||||
- Submit issue against NW.js for performance issues starting with v0.46
|
||||
- Bring in proper filter fix for Pixi-Picture when it is released
|
||||
|
||||
## License
|
||||
|
||||
- PixiJS is covered by the [MIT License](https://github.com/pixijs/pixi.js/blob/dev/LICENSE)
|
||||
- Typescript and other libraries, see the file headers
|
||||
- My Modifications: MIT License
|
14
nwjs/packagefiles/rpgmaker-mv-pixi5/js/jsconfig.json
Normal file
14
nwjs/packagefiles/rpgmaker-mv-pixi5/js/jsconfig.json
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"target":"es6"
|
||||
},
|
||||
"files": [
|
||||
"./rmmv.d.ts",
|
||||
"./rmmv-pixi.d.ts"
|
||||
],
|
||||
"include": [
|
||||
"./*",
|
||||
"./plugins_dev/*.js",
|
||||
"./plugins/*.js"
|
||||
]
|
||||
}
|
15
nwjs/packagefiles/rpgmaker-mv-pixi5/js/libs/fpsmeter.js
Normal file
15
nwjs/packagefiles/rpgmaker-mv-pixi5/js/libs/fpsmeter.js
Normal file
|
@ -0,0 +1,15 @@
|
|||
/*! FPSMeter 0.3.1 - 9th May 2013 | https://github.com/Darsain/fpsmeter */
|
||||
(function(m,j){function s(a,e){for(var g in e)try{a.style[g]=e[g]}catch(j){}return a}function H(a){return null==a?String(a):"object"===typeof a||"function"===typeof a?Object.prototype.toString.call(a).match(/\s([a-z]+)/i)[1].toLowerCase()||"object":typeof a}function R(a,e){if("array"!==H(e))return-1;if(e.indexOf)return e.indexOf(a);for(var g=0,j=e.length;g<j;g++)if(e[g]===a)return g;return-1}function I(){var a=arguments,e;for(e in a[1])if(a[1].hasOwnProperty(e))switch(H(a[1][e])){case "object":a[0][e]=
|
||||
I({},a[0][e],a[1][e]);break;case "array":a[0][e]=a[1][e].slice(0);break;default:a[0][e]=a[1][e]}return 2<a.length?I.apply(null,[a[0]].concat(Array.prototype.slice.call(a,2))):a[0]}function N(a){a=Math.round(255*a).toString(16);return 1===a.length?"0"+a:a}function S(a,e,g,j){if(a.addEventListener)a[j?"removeEventListener":"addEventListener"](e,g,!1);else if(a.attachEvent)a[j?"detachEvent":"attachEvent"]("on"+e,g)}function D(a,e){function g(a,b,d,c){return y[0|a][Math.round(Math.min((b-d)/(c-d)*J,J))]}
|
||||
function r(){f.legend.fps!==q&&(f.legend.fps=q,f.legend[T]=q?"FPS":"ms");K=q?b.fps:b.duration;f.count[T]=999<K?"999+":K.toFixed(99<K?0:d.decimals)}function m(){z=A();L<z-d.threshold&&(b.fps-=b.fps/Math.max(1,60*d.smoothing/d.interval),b.duration=1E3/b.fps);for(c=d.history;c--;)E[c]=0===c?b.fps:E[c-1],F[c]=0===c?b.duration:F[c-1];r();if(d.heat){if(w.length)for(c=w.length;c--;)w[c].el.style[h[w[c].name].heatOn]=q?g(h[w[c].name].heatmap,b.fps,0,d.maxFps):g(h[w[c].name].heatmap,b.duration,d.threshold,
|
||||
0);if(f.graph&&h.column.heatOn)for(c=u.length;c--;)u[c].style[h.column.heatOn]=q?g(h.column.heatmap,E[c],0,d.maxFps):g(h.column.heatmap,F[c],d.threshold,0)}if(f.graph)for(p=0;p<d.history;p++)u[p].style.height=(q?E[p]?Math.round(O/d.maxFps*Math.min(E[p],d.maxFps)):0:F[p]?Math.round(O/d.threshold*Math.min(F[p],d.threshold)):0)+"px"}function k(){20>d.interval?(x=M(k),m()):(x=setTimeout(k,d.interval),P=M(m))}function G(a){a=a||window.event;a.preventDefault?(a.preventDefault(),a.stopPropagation()):(a.returnValue=
|
||||
!1,a.cancelBubble=!0);b.toggle()}function U(){d.toggleOn&&S(f.container,d.toggleOn,G,1);a.removeChild(f.container)}function V(){f.container&&U();h=D.theme[d.theme];y=h.compiledHeatmaps||[];if(!y.length&&h.heatmaps.length){for(p=0;p<h.heatmaps.length;p++){y[p]=[];for(c=0;c<=J;c++){var b=y[p],e=c,g;g=0.33/J*c;var j=h.heatmaps[p].saturation,m=h.heatmaps[p].lightness,n=void 0,k=void 0,l=void 0,t=l=void 0,v=n=k=void 0,v=void 0,l=0.5>=m?m*(1+j):m+j-m*j;0===l?g="#000":(t=2*m-l,k=(l-t)/l,g*=6,n=Math.floor(g),
|
||||
v=g-n,v*=l*k,0===n||6===n?(n=l,k=t+v,l=t):1===n?(n=l-v,k=l,l=t):2===n?(n=t,k=l,l=t+v):3===n?(n=t,k=l-v):4===n?(n=t+v,k=t):(n=l,k=t,l-=v),g="#"+N(n)+N(k)+N(l));b[e]=g}}h.compiledHeatmaps=y}f.container=s(document.createElement("div"),h.container);f.count=f.container.appendChild(s(document.createElement("div"),h.count));f.legend=f.container.appendChild(s(document.createElement("div"),h.legend));f.graph=d.graph?f.container.appendChild(s(document.createElement("div"),h.graph)):0;w.length=0;for(var q in f)f[q]&&
|
||||
h[q].heatOn&&w.push({name:q,el:f[q]});u.length=0;if(f.graph){f.graph.style.width=d.history*h.column.width+(d.history-1)*h.column.spacing+"px";for(c=0;c<d.history;c++)u[c]=f.graph.appendChild(s(document.createElement("div"),h.column)),u[c].style.position="absolute",u[c].style.bottom=0,u[c].style.right=c*h.column.width+c*h.column.spacing+"px",u[c].style.width=h.column.width+"px",u[c].style.height="0px"}s(f.container,d);r();a.appendChild(f.container);f.graph&&(O=f.graph.clientHeight);d.toggleOn&&("click"===
|
||||
d.toggleOn&&(f.container.style.cursor="pointer"),S(f.container,d.toggleOn,G))}"object"===H(a)&&a.nodeType===j&&(e=a,a=document.body);a||(a=document.body);var b=this,d=I({},D.defaults,e||{}),f={},u=[],h,y,J=100,w=[],W=0,B=d.threshold,Q=0,L=A()-B,z,E=[],F=[],x,P,q="fps"===d.show,O,K,c,p;b.options=d;b.fps=0;b.duration=0;b.isPaused=0;b.tickStart=function(){Q=A()};b.tick=function(){z=A();W=z-L;B+=(W-B)/d.smoothing;b.fps=1E3/B;b.duration=Q<L?B:z-Q;L=z};b.pause=function(){x&&(b.isPaused=1,clearTimeout(x),
|
||||
C(x),C(P),x=P=0);return b};b.resume=function(){x||(b.isPaused=0,k());return b};b.set=function(a,c){d[a]=c;q="fps"===d.show;-1!==R(a,X)&&V();-1!==R(a,Y)&&s(f.container,d);return b};b.showDuration=function(){b.set("show","ms");return b};b.showFps=function(){b.set("show","fps");return b};b.toggle=function(){b.set("show",q?"ms":"fps");return b};b.hide=function(){b.pause();f.container.style.display="none";return b};b.show=function(){b.resume();f.container.style.display="block";return b};b.destroy=function(){b.pause();
|
||||
U();b.tick=b.tickStart=function(){}};V();k()}var A,r=m.performance;A=r&&(r.now||r.webkitNow)?r[r.now?"now":"webkitNow"].bind(r):function(){return+new Date};for(var C=m.cancelAnimationFrame||m.cancelRequestAnimationFrame,M=m.requestAnimationFrame,r=["moz","webkit","o"],G=0,k=0,Z=r.length;k<Z&&!C;++k)M=(C=m[r[k]+"CancelAnimationFrame"]||m[r[k]+"CancelRequestAnimationFrame"])&&m[r[k]+"RequestAnimationFrame"];C||(M=function(a){var e=A(),g=Math.max(0,16-(e-G));G=e+g;return m.setTimeout(function(){a(e+
|
||||
g)},g)},C=function(a){clearTimeout(a)});var T="string"===H(document.createElement("div").textContent)?"textContent":"innerText";D.extend=I;window.FPSMeter=D;D.defaults={interval:100,smoothing:10,show:"fps",toggleOn:"click",decimals:1,maxFps:60,threshold:100,position:"absolute",zIndex:10,left:"5px",top:"5px",right:"auto",bottom:"auto",margin:"0 0 0 0",theme:"dark",heat:0,graph:0,history:20};var X=["toggleOn","theme","heat","graph","history"],Y="position zIndex left top right bottom margin".split(" ")})(window);(function(m,j){j.theme={};var s=j.theme.base={heatmaps:[],container:{heatOn:null,heatmap:null,padding:"5px",minWidth:"95px",height:"30px",lineHeight:"30px",textAlign:"right",textShadow:"none"},count:{heatOn:null,heatmap:null,position:"absolute",top:0,right:0,padding:"5px 10px",height:"30px",fontSize:"24px",fontFamily:"Consolas, Andale Mono, monospace",zIndex:2},legend:{heatOn:null,heatmap:null,position:"absolute",top:0,left:0,padding:"5px 10px",height:"30px",fontSize:"12px",lineHeight:"32px",fontFamily:"sans-serif",
|
||||
textAlign:"left",zIndex:2},graph:{heatOn:null,heatmap:null,position:"relative",boxSizing:"padding-box",MozBoxSizing:"padding-box",height:"100%",zIndex:1},column:{width:4,spacing:1,heatOn:null,heatmap:null}};j.theme.dark=j.extend({},s,{heatmaps:[{saturation:0.8,lightness:0.8}],container:{background:"#222",color:"#fff",border:"1px solid #1a1a1a",textShadow:"1px 1px 0 #222"},count:{heatOn:"color"},column:{background:"#3f3f3f"}});j.theme.light=j.extend({},s,{heatmaps:[{saturation:0.5,lightness:0.5}],
|
||||
container:{color:"#666",background:"#fff",textShadow:"1px 1px 0 rgba(255,255,255,.5), -1px -1px 0 rgba(255,255,255,.5)",boxShadow:"0 0 0 1px rgba(0,0,0,.1)"},count:{heatOn:"color"},column:{background:"#eaeaea"}});j.theme.colorful=j.extend({},s,{heatmaps:[{saturation:0.5,lightness:0.6}],container:{heatOn:"backgroundColor",background:"#888",color:"#fff",textShadow:"1px 1px 0 rgba(0,0,0,.2)",boxShadow:"0 0 0 1px rgba(0,0,0,.1)"},column:{background:"#777",backgroundColor:"rgba(0,0,0,.2)"}});j.theme.transparent=
|
||||
j.extend({},s,{heatmaps:[{saturation:0.8,lightness:0.5}],container:{padding:0,color:"#fff",textShadow:"1px 1px 0 rgba(0,0,0,.5)"},count:{padding:"0 5px",height:"40px",lineHeight:"40px"},legend:{padding:"0 5px",height:"40px",lineHeight:"42px"},graph:{height:"40px"},column:{width:5,background:"#999",heatOn:"backgroundColor",opacity:0.5}})})(window,FPSMeter);
|
|
@ -0,0 +1,3 @@
|
|||
/*! npm.im/iphone-inline-video */
|
||||
var makeVideoPlayableInline=function(){"use strict";/*! npm.im/intervalometer */
|
||||
function e(e,n,r,i){function t(r){d=n(t,i),e(r-(a||r)),a=r}var d,a;return{start:function(){d||t(0)},stop:function(){r(d),d=null,a=0}}}function n(n){return e(n,requestAnimationFrame,cancelAnimationFrame)}function r(e,n,r,i){function t(n){Boolean(e[r])===Boolean(i)&&n.stopImmediatePropagation(),delete e[r]}return e.addEventListener(n,t,!1),t}function i(e,n,r,i){function t(){return r[n]}function d(e){r[n]=e}i&&d(e[n]),Object.defineProperty(e,n,{get:t,set:d})}function t(e,n,r){r.addEventListener(n,function(){return e.dispatchEvent(new Event(n))})}function d(e,n){Promise.resolve().then(function(){e.dispatchEvent(new Event(n))})}function a(e){var n=new Audio;return t(e,"play",n),t(e,"playing",n),t(e,"pause",n),n.crossOrigin=e.crossOrigin,n.src=e.src||e.currentSrc||"data:",n}function o(e,n,r){(m||0)+200<Date.now()&&(e[g]=!0,m=Date.now()),r||(e.currentTime=n),A[++k%3]=100*n|0}function u(e){return e.driver.currentTime>=e.video.duration}function s(e){var n=this;n.video.readyState>=n.video.HAVE_FUTURE_DATA?(n.hasAudio||(n.driver.currentTime=n.video.currentTime+e*n.video.playbackRate/1e3,n.video.loop&&u(n)&&(n.driver.currentTime=0)),o(n.video,n.driver.currentTime)):n.video.networkState!==n.video.NETWORK_IDLE||n.video.buffered.length||n.video.load(),n.video.ended&&(delete n.video[g],n.video.pause(!0))}function c(){var e=this,n=e[b];return e.webkitDisplayingFullscreen?void e[E]():("data:"!==n.driver.src&&n.driver.src!==e.src&&(o(e,0,!0),n.driver.src=e.src),void(e.paused&&(n.paused=!1,e.buffered.length||e.load(),n.driver.play(),n.updater.start(),n.hasAudio||(d(e,"play"),n.video.readyState>=n.video.HAVE_ENOUGH_DATA&&d(e,"playing")))))}function v(e){var n=this,r=n[b];r.driver.pause(),r.updater.stop(),n.webkitDisplayingFullscreen&&n[T](),r.paused&&!e||(r.paused=!0,r.hasAudio||d(n,"pause"),n.ended&&(n[g]=!0,d(n,"ended")))}function p(e,r){var i=e[b]={};i.paused=!0,i.hasAudio=r,i.video=e,i.updater=n(s.bind(i)),r?i.driver=a(e):(e.addEventListener("canplay",function(){e.paused||d(e,"playing")}),i.driver={src:e.src||e.currentSrc||"data:",muted:!0,paused:!0,pause:function(){i.driver.paused=!0},play:function(){i.driver.paused=!1,u(i)&&o(e,0)},get ended(){return u(i)}}),e.addEventListener("emptied",function(){var n=!i.driver.src||"data:"===i.driver.src;i.driver.src&&i.driver.src!==e.src&&(o(e,0,!0),i.driver.src=e.src,n?i.driver.play():i.updater.stop())},!1),e.addEventListener("webkitbeginfullscreen",function(){e.paused?r&&!i.driver.buffered.length&&i.driver.load():(e.pause(),e[E]())}),r&&(e.addEventListener("webkitendfullscreen",function(){i.driver.currentTime=e.currentTime}),e.addEventListener("seeking",function(){A.indexOf(100*e.currentTime|0)<0&&(i.driver.currentTime=e.currentTime)}))}function l(e){var n=e[b];e[E]=e.play,e[T]=e.pause,e.play=c,e.pause=v,i(e,"paused",n.driver),i(e,"muted",n.driver,!0),i(e,"playbackRate",n.driver,!0),i(e,"ended",n.driver),i(e,"loop",n.driver,!0),r(e,"seeking"),r(e,"seeked"),r(e,"timeupdate",g,!1),r(e,"ended",g,!1)}function f(e,n,r){void 0===n&&(n=!0),void 0===r&&(r=!0),r&&!h||e[b]||(p(e,n),l(e),e.classList.add("IIV"),!n&&e.autoplay&&e.play(),/iPhone|iPod|iPad/.test(navigator.platform)||console.warn("iphone-inline-video is not guaranteed to work in emulated environments"))}var m,y="undefined"==typeof Symbol?function(e){return"@"+(e||"@")+Math.random()}:Symbol,h="object-fit"in document.head.style&&/iPhone|iPod/i.test(navigator.userAgent)&&!matchMedia("(-webkit-video-playable-inline)").matches,b=y(),g=y(),E=y("nativeplay"),T=y("nativepause"),A=[],k=0;return f.isWhitelisted=h,f}();
|
1
nwjs/packagefiles/rpgmaker-mv-pixi5/js/libs/lz-string.js
Normal file
1
nwjs/packagefiles/rpgmaker-mv-pixi5/js/libs/lz-string.js
Normal file
File diff suppressed because one or more lines are too long
44078
nwjs/packagefiles/rpgmaker-mv-pixi5/js/libs/pixi-legacy.js
Normal file
44078
nwjs/packagefiles/rpgmaker-mv-pixi5/js/libs/pixi-legacy.js
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
9
nwjs/packagefiles/rpgmaker-mv-pixi5/js/libs/pixi-legacy.min.js
vendored
Normal file
9
nwjs/packagefiles/rpgmaker-mv-pixi5/js/libs/pixi-legacy.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
404
nwjs/packagefiles/rpgmaker-mv-pixi5/js/libs/pixi-picture.js
Normal file
404
nwjs/packagefiles/rpgmaker-mv-pixi5/js/libs/pixi-picture.js
Normal file
|
@ -0,0 +1,404 @@
|
|||
var __extends = (this && this.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
||||
return extendStatics(d, b);
|
||||
};
|
||||
return function (d, b) {
|
||||
extendStatics(d, b);
|
||||
function __() { this.constructor = d; }
|
||||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
||||
};
|
||||
})();
|
||||
var pixi_picture;
|
||||
(function (pixi_picture) {
|
||||
var BackdropFilter = (function (_super) {
|
||||
__extends(BackdropFilter, _super);
|
||||
function BackdropFilter() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.backdropUniformName = null;
|
||||
_this._backdropActive = false;
|
||||
_this.clearColor = null;
|
||||
return _this;
|
||||
}
|
||||
return BackdropFilter;
|
||||
}(PIXI.Filter));
|
||||
pixi_picture.BackdropFilter = BackdropFilter;
|
||||
var filterFrag = "\nvarying vec2 vTextureCoord;\n\nuniform sampler2D uSampler;\nuniform sampler2D uBackdrop;\n\n%UNIFORM_CODE%\n\nvoid main(void)\n{\n vec4 b_src = texture2D(uSampler, vTextureCoord);\n vec4 b_dest = texture2D(uBackdrop, vTextureCoord);\n vec4 b_res = b_dest;\n \n %BLEND_CODE%\n\n gl_FragColor = b_res;\n}";
|
||||
var BlendFilter = (function (_super) {
|
||||
__extends(BlendFilter, _super);
|
||||
function BlendFilter(shaderParts) {
|
||||
var _this = this;
|
||||
var fragCode = filterFrag;
|
||||
fragCode = fragCode.replace('%UNIFORM_CODE%', shaderParts.uniformCode || "");
|
||||
fragCode = fragCode.replace('%BLEND_CODE%', shaderParts.blendCode || "");
|
||||
_this = _super.call(this, undefined, fragCode, shaderParts.uniforms) || this;
|
||||
_this.backdropUniformName = 'uBackdrop';
|
||||
return _this;
|
||||
}
|
||||
return BlendFilter;
|
||||
}(BackdropFilter));
|
||||
pixi_picture.BlendFilter = BlendFilter;
|
||||
})(pixi_picture || (pixi_picture = {}));
|
||||
var pixi_picture;
|
||||
(function (pixi_picture) {
|
||||
function containsRect(rectOut, rectIn) {
|
||||
var r1 = rectIn.x + rectIn.width;
|
||||
var b1 = rectIn.y + rectIn.height;
|
||||
var r2 = rectOut.x + rectOut.width;
|
||||
var b2 = rectOut.y + rectOut.height;
|
||||
return (rectIn.x >= rectOut.x) &&
|
||||
(rectIn.x <= r2) &&
|
||||
(rectIn.y >= rectOut.y) &&
|
||||
(rectIn.y <= b2) &&
|
||||
(r1 >= rectOut.x) &&
|
||||
(r1 <= r2) &&
|
||||
(b1 >= rectOut.y) &&
|
||||
(b1 <= b2);
|
||||
}
|
||||
PIXI.systems.TextureSystem.prototype.bindForceLocation = function (texture, location) {
|
||||
if (location === void 0) { location = 0; }
|
||||
var gl = this.gl;
|
||||
if (this.currentLocation !== location) {
|
||||
this.currentLocation = location;
|
||||
gl.activeTexture(gl.TEXTURE0 + location);
|
||||
}
|
||||
this.bind(texture, location);
|
||||
};
|
||||
function pushWithCheck(target, filters, checkEmptyBounds) {
|
||||
if (checkEmptyBounds === void 0) { checkEmptyBounds = true; }
|
||||
var renderer = this.renderer;
|
||||
var filterStack = this.defaultFilterStack;
|
||||
var state = this.statePool.pop() || new PIXI.FilterState();
|
||||
var resolution = filters[0].resolution;
|
||||
var padding = filters[0].padding;
|
||||
var autoFit = filters[0].autoFit;
|
||||
var legacy = filters[0].legacy;
|
||||
for (var i = 1; i < filters.length; i++) {
|
||||
var filter = filters[i];
|
||||
resolution = Math.min(resolution, filter.resolution);
|
||||
padding = this.useMaxPadding
|
||||
? Math.max(padding, filter.padding)
|
||||
: padding + filter.padding;
|
||||
autoFit = autoFit || filter.autoFit;
|
||||
legacy = legacy || filter.legacy;
|
||||
}
|
||||
if (filterStack.length === 1) {
|
||||
this.defaultFilterStack[0].renderTexture = renderer.renderTexture.current;
|
||||
}
|
||||
filterStack.push(state);
|
||||
state.resolution = resolution;
|
||||
state.legacy = legacy;
|
||||
state.target = target;
|
||||
state.sourceFrame.copyFrom(target.filterArea || target.getBounds(true));
|
||||
var canUseBackdrop = true;
|
||||
state.sourceFrame.pad(padding);
|
||||
if (autoFit) {
|
||||
state.sourceFrame.fit(this.renderer.renderTexture.sourceFrame);
|
||||
}
|
||||
else {
|
||||
canUseBackdrop = containsRect(this.renderer.renderTexture.sourceFrame, state.sourceFrame);
|
||||
}
|
||||
if (checkEmptyBounds && state.sourceFrame.width <= 1 && state.sourceFrame.height <= 1) {
|
||||
filterStack.pop();
|
||||
state.clear();
|
||||
this.statePool.push(state);
|
||||
return false;
|
||||
}
|
||||
state.sourceFrame.ceil(resolution);
|
||||
if (canUseBackdrop) {
|
||||
var backdrop = null;
|
||||
for (var i = 0; i < filters.length; i++) {
|
||||
var bName = filters[i].backdropUniformName;
|
||||
if (bName) {
|
||||
if (backdrop === null) {
|
||||
backdrop = this.prepareBackdrop(state.sourceFrame);
|
||||
}
|
||||
filters[i].uniforms[bName] = backdrop;
|
||||
if (backdrop) {
|
||||
filters[i]._backdropActive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
state.renderTexture = this.getOptimalFilterTexture(state.sourceFrame.width, state.sourceFrame.height, resolution);
|
||||
state.filters = filters;
|
||||
state.destinationFrame.width = state.renderTexture.width;
|
||||
state.destinationFrame.height = state.renderTexture.height;
|
||||
var destinationFrame = this.tempRect;
|
||||
destinationFrame.width = state.sourceFrame.width;
|
||||
destinationFrame.height = state.sourceFrame.height;
|
||||
state.renderTexture.filterFrame = state.sourceFrame;
|
||||
renderer.renderTexture.bind(state.renderTexture, state.sourceFrame, destinationFrame);
|
||||
renderer.renderTexture.clear(filters[filters.length - 1].clearColor);
|
||||
return true;
|
||||
}
|
||||
function push(target, filters) {
|
||||
return this.pushWithCheck(target, filters, false);
|
||||
}
|
||||
function pop() {
|
||||
var filterStack = this.defaultFilterStack;
|
||||
var state = filterStack.pop();
|
||||
var filters = state.filters;
|
||||
this.activeState = state;
|
||||
var globalUniforms = this.globalUniforms.uniforms;
|
||||
globalUniforms.outputFrame = state.sourceFrame;
|
||||
globalUniforms.resolution = state.resolution;
|
||||
var inputSize = globalUniforms.inputSize;
|
||||
var inputPixel = globalUniforms.inputPixel;
|
||||
var inputClamp = globalUniforms.inputClamp;
|
||||
inputSize[0] = state.destinationFrame.width;
|
||||
inputSize[1] = state.destinationFrame.height;
|
||||
inputSize[2] = 1.0 / inputSize[0];
|
||||
inputSize[3] = 1.0 / inputSize[1];
|
||||
inputPixel[0] = inputSize[0] * state.resolution;
|
||||
inputPixel[1] = inputSize[1] * state.resolution;
|
||||
inputPixel[2] = 1.0 / inputPixel[0];
|
||||
inputPixel[3] = 1.0 / inputPixel[1];
|
||||
inputClamp[0] = 0.5 * inputPixel[2];
|
||||
inputClamp[1] = 0.5 * inputPixel[3];
|
||||
inputClamp[2] = (state.sourceFrame.width * inputSize[2]) - (0.5 * inputPixel[2]);
|
||||
inputClamp[3] = (state.sourceFrame.height * inputSize[3]) - (0.5 * inputPixel[3]);
|
||||
if (state.legacy) {
|
||||
var filterArea = globalUniforms.filterArea;
|
||||
filterArea[0] = state.destinationFrame.width;
|
||||
filterArea[1] = state.destinationFrame.height;
|
||||
filterArea[2] = state.sourceFrame.x;
|
||||
filterArea[3] = state.sourceFrame.y;
|
||||
globalUniforms.filterClamp = globalUniforms.inputClamp;
|
||||
}
|
||||
this.globalUniforms.update();
|
||||
var lastState = filterStack[filterStack.length - 1];
|
||||
if (state.renderTexture.framebuffer.multisample > 1) {
|
||||
this.renderer.framebuffer.blit();
|
||||
}
|
||||
if (filters.length === 1) {
|
||||
filters[0].apply(this, state.renderTexture, lastState.renderTexture, PIXI.CLEAR_MODES.BLEND, state);
|
||||
this.returnFilterTexture(state.renderTexture);
|
||||
}
|
||||
else {
|
||||
var flip = state.renderTexture;
|
||||
var flop = this.getOptimalFilterTexture(flip.width, flip.height, state.resolution);
|
||||
flop.filterFrame = flip.filterFrame;
|
||||
var i = 0;
|
||||
for (i = 0; i < filters.length - 1; ++i) {
|
||||
filters[i].apply(this, flip, flop, PIXI.CLEAR_MODES.CLEAR, state);
|
||||
var t = flip;
|
||||
flip = flop;
|
||||
flop = t;
|
||||
}
|
||||
filters[i].apply(this, flip, lastState.renderTexture, PIXI.CLEAR_MODES.BLEND, state);
|
||||
this.returnFilterTexture(flip);
|
||||
this.returnFilterTexture(flop);
|
||||
}
|
||||
var backdropFree = false;
|
||||
for (var i = 0; i < filters.length; i++) {
|
||||
if (filters[i]._backdropActive) {
|
||||
var bName = filters[i].backdropUniformName;
|
||||
if (!backdropFree) {
|
||||
this.returnFilterTexture(filters[i].uniforms[bName]);
|
||||
backdropFree = true;
|
||||
}
|
||||
filters[i].uniforms[bName] = null;
|
||||
filters[i]._backdropActive = false;
|
||||
}
|
||||
}
|
||||
state.clear();
|
||||
this.statePool.push(state);
|
||||
}
|
||||
var hadBackbufferError = false;
|
||||
function prepareBackdrop(bounds) {
|
||||
var renderer = this.renderer;
|
||||
var renderTarget = renderer.renderTexture.current;
|
||||
var fr = this.renderer.renderTexture.sourceFrame;
|
||||
if (!renderTarget) {
|
||||
if (!hadBackbufferError) {
|
||||
hadBackbufferError = true;
|
||||
console.warn('pixi-picture: you are trying to use Blend Filter on main framebuffer! That wont work.');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
var resolution = renderTarget.baseTexture.resolution;
|
||||
var x = (bounds.x - fr.x) * resolution;
|
||||
var y = (bounds.y - fr.y) * resolution;
|
||||
var w = (bounds.width) * resolution;
|
||||
var h = (bounds.height) * resolution;
|
||||
var gl = renderer.gl;
|
||||
var rt = this.getOptimalFilterTexture(w, h, 1);
|
||||
rt.filterFrame = fr;
|
||||
renderer.texture.bindForceLocation(rt.baseTexture, 0);
|
||||
gl.copyTexSubImage2D(gl.TEXTURE_2D, 0, 0, 0, x, y, w, h);
|
||||
return rt;
|
||||
}
|
||||
PIXI.systems.FilterSystem.prototype.push = push;
|
||||
PIXI.systems.FilterSystem.prototype.pushWithCheck = pushWithCheck;
|
||||
PIXI.systems.FilterSystem.prototype.pop = pop;
|
||||
PIXI.systems.FilterSystem.prototype.prepareBackdrop = prepareBackdrop;
|
||||
})(pixi_picture || (pixi_picture = {}));
|
||||
var pixi_picture;
|
||||
(function (pixi_picture) {
|
||||
var MASK_CHANNEL;
|
||||
(function (MASK_CHANNEL) {
|
||||
MASK_CHANNEL[MASK_CHANNEL["RED"] = 0] = "RED";
|
||||
MASK_CHANNEL[MASK_CHANNEL["GREEN"] = 1] = "GREEN";
|
||||
MASK_CHANNEL[MASK_CHANNEL["BLUE"] = 2] = "BLUE";
|
||||
MASK_CHANNEL[MASK_CHANNEL["ALPHA"] = 3] = "ALPHA";
|
||||
})(MASK_CHANNEL = pixi_picture.MASK_CHANNEL || (pixi_picture.MASK_CHANNEL = {}));
|
||||
var MaskConfig = (function () {
|
||||
function MaskConfig(maskBefore, channel) {
|
||||
if (maskBefore === void 0) { maskBefore = false; }
|
||||
if (channel === void 0) { channel = MASK_CHANNEL.ALPHA; }
|
||||
this.maskBefore = maskBefore;
|
||||
this.uniformCode = 'uniform vec4 uChannel;';
|
||||
this.uniforms = {
|
||||
uChannel: new Float32Array([0, 0, 0, 0]),
|
||||
};
|
||||
this.blendCode = "b_res = dot(b_src, uChannel) * b_dest;";
|
||||
this.uniforms.uChannel[channel] = 1.0;
|
||||
}
|
||||
return MaskConfig;
|
||||
}());
|
||||
pixi_picture.MaskConfig = MaskConfig;
|
||||
var MaskFilter = (function (_super) {
|
||||
__extends(MaskFilter, _super);
|
||||
function MaskFilter(baseFilter, config) {
|
||||
if (config === void 0) { config = new MaskConfig(); }
|
||||
var _this = _super.call(this, config) || this;
|
||||
_this.baseFilter = baseFilter;
|
||||
_this.config = config;
|
||||
_this.padding = baseFilter.padding;
|
||||
return _this;
|
||||
}
|
||||
MaskFilter.prototype.apply = function (filterManager, input, output, clearMode) {
|
||||
var target = filterManager.getFilterTexture(input);
|
||||
if (this.config.maskBefore) {
|
||||
var blendMode = this.state.blendMode;
|
||||
this.state.blendMode = PIXI.BLEND_MODES.NONE;
|
||||
filterManager.applyFilter(this, input, target, PIXI.CLEAR_MODES.YES);
|
||||
this.baseFilter.blendMode = blendMode;
|
||||
this.baseFilter.apply(filterManager, target, output, clearMode);
|
||||
this.state.blendMode = blendMode;
|
||||
}
|
||||
else {
|
||||
var uBackdrop = this.uniforms.uBackdrop;
|
||||
this.baseFilter.apply(filterManager, uBackdrop, target, PIXI.CLEAR_MODES.YES);
|
||||
this.uniforms.uBackdrop = target;
|
||||
filterManager.applyFilter(this, input, output, clearMode);
|
||||
this.uniforms.uBackdrop = uBackdrop;
|
||||
}
|
||||
filterManager.returnFilterTexture(target);
|
||||
};
|
||||
return MaskFilter;
|
||||
}(pixi_picture.BlendFilter));
|
||||
pixi_picture.MaskFilter = MaskFilter;
|
||||
})(pixi_picture || (pixi_picture = {}));
|
||||
var pixi_picture;
|
||||
(function (pixi_picture) {
|
||||
var blends;
|
||||
(function (blends) {
|
||||
blends.NPM_BLEND = "if (b_src.a == 0.0) {\n gl_FragColor = vec4(0, 0, 0, 0);\n return;\n}\nvec3 Cb = b_src.rgb / b_src.a, Cs;\nif (b_dest.a > 0.0) {\n Cs = b_dest.rgb / b_dest.a;\n}\n%NPM_BLEND%\nb_res.a = b_src.a + b_dest.a * (1.0-b_src.a);\nb_res.rgb = (1.0 - b_src.a) * Cs + b_src.a * B;\nb_res.rgb *= b_res.a;\n";
|
||||
blends.OVERLAY_PART = "vec3 multiply = Cb * Cs * 2.0;\nvec3 Cb2 = Cb * 2.0 - 1.0;\nvec3 screen = Cb2 + Cs - Cb2 * Cs;\nvec3 B;\nif (Cs.r <= 0.5) {\n B.r = multiply.r;\n} else {\n B.r = screen.r;\n}\nif (Cs.g <= 0.5) {\n B.g = multiply.g;\n} else {\n B.g = screen.g;\n}\nif (Cs.b <= 0.5) {\n B.b = multiply.b;\n} else {\n B.b = screen.b;\n}\n";
|
||||
blends.HARDLIGHT_PART = "vec3 multiply = Cb * Cs * 2.0;\nvec3 Cs2 = Cs * 2.0 - 1.0;\nvec3 screen = Cb + Cs2 - Cb * Cs2;\nvec3 B;\nif (Cb.r <= 0.5) {\n B.r = multiply.r;\n} else {\n B.r = screen.r;\n}\nif (Cb.g <= 0.5) {\n B.g = multiply.g;\n} else {\n B.g = screen.g;\n}\nif (Cb.b <= 0.5) {\n B.b = multiply.b;\n} else {\n B.b = screen.b;\n}\n";
|
||||
blends.SOFTLIGHT_PART = "vec3 first = Cb - (1.0 - 2.0 * Cs) * Cb * (1.0 - Cb);\nvec3 B;\nvec3 D;\nif (Cs.r <= 0.5)\n{\n B.r = first.r;\n}\nelse\n{\n if (Cb.r <= 0.25)\n {\n D.r = ((16.0 * Cb.r - 12.0) * Cb.r + 4.0) * Cb.r; \n }\n else\n {\n D.r = sqrt(Cb.r);\n }\n B.r = Cb.r + (2.0 * Cs.r - 1.0) * (D.r - Cb.r);\n}\nif (Cs.g <= 0.5)\n{\n B.g = first.g;\n}\nelse\n{\n if (Cb.g <= 0.25)\n {\n D.g = ((16.0 * Cb.g - 12.0) * Cb.g + 4.0) * Cb.g; \n }\n else\n {\n D.g = sqrt(Cb.g);\n }\n B.g = Cb.g + (2.0 * Cs.g - 1.0) * (D.g - Cb.g);\n}\nif (Cs.b <= 0.5)\n{\n B.b = first.b;\n}\nelse\n{\n if (Cb.b <= 0.25)\n {\n D.b = ((16.0 * Cb.b - 12.0) * Cb.b + 4.0) * Cb.b; \n }\n else\n {\n D.b = sqrt(Cb.b);\n }\n B.b = Cb.b + (2.0 * Cs.b - 1.0) * (D.b - Cb.b);\n}\n";
|
||||
blends.MULTIPLY_FULL = "if (b_dest.a > 0.0) {\n vec4 mult;\nmult.a = min(b_src.a + b_dest.a - b_src.a * b_dest.a, 1.0);\n mult.rgb = (b_dest.rgb / b_dest.a) * ((1.0 - b_src.a) + b_src.rgb);\n b_res.rgb = (b_dest.rgb / b_dest.a) * ((1.0 - b_src.a) + b_src.rgb);\n b_res.a = min(b_src.a + b_dest.a - b_src.a * b_dest.a, 1.0);\n b_res.rgb *= mult.a;\n}\n";
|
||||
blends.OVERLAY_FULL = blends.NPM_BLEND.replace("%NPM_BLEND%", blends.OVERLAY_PART);
|
||||
blends.HARDLIGHT_FULL = blends.NPM_BLEND.replace("%NPM_BLEND%", blends.HARDLIGHT_PART);
|
||||
blends.SOFTLIGHT_FULL = blends.NPM_BLEND.replace("%NPM_BLEND%", blends.SOFTLIGHT_PART);
|
||||
blends.blendFullArray = [];
|
||||
blends.blendFullArray[PIXI.BLEND_MODES.MULTIPLY] = blends.MULTIPLY_FULL;
|
||||
blends.blendFullArray[PIXI.BLEND_MODES.OVERLAY] = blends.OVERLAY_FULL;
|
||||
blends.blendFullArray[PIXI.BLEND_MODES.HARD_LIGHT] = blends.HARDLIGHT_FULL;
|
||||
blends.blendFullArray[PIXI.BLEND_MODES.SOFT_LIGHT] = blends.SOFTLIGHT_FULL;
|
||||
})(blends = pixi_picture.blends || (pixi_picture.blends = {}));
|
||||
var filterCache = [];
|
||||
var filterCacheArray = [];
|
||||
function getBlendFilter(blendMode) {
|
||||
if (!blends.blendFullArray[blendMode]) {
|
||||
return null;
|
||||
}
|
||||
if (!filterCache[blendMode]) {
|
||||
filterCache[blendMode] = new pixi_picture.BlendFilter({ blendCode: blends.blendFullArray[blendMode] });
|
||||
}
|
||||
return filterCache[blendMode];
|
||||
}
|
||||
pixi_picture.getBlendFilter = getBlendFilter;
|
||||
function getBlendFilterArray(blendMode) {
|
||||
if (!blends.blendFullArray[blendMode]) {
|
||||
return null;
|
||||
}
|
||||
if (!filterCacheArray[blendMode]) {
|
||||
filterCacheArray[blendMode] = [this.getBlendFilter(blendMode)];
|
||||
}
|
||||
return filterCacheArray[blendMode];
|
||||
}
|
||||
pixi_picture.getBlendFilterArray = getBlendFilterArray;
|
||||
})(pixi_picture || (pixi_picture = {}));
|
||||
var pixi_picture;
|
||||
(function (pixi_picture) {
|
||||
var Sprite = (function (_super) {
|
||||
__extends(Sprite, _super);
|
||||
function Sprite() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
Sprite.prototype._render = function (renderer) {
|
||||
var texture = this._texture;
|
||||
if (!texture || !texture.valid) {
|
||||
return;
|
||||
}
|
||||
var blendFilterArray = pixi_picture.getBlendFilterArray(this.blendMode);
|
||||
if (blendFilterArray) {
|
||||
renderer.batch.flush();
|
||||
if (!renderer.filter.pushWithCheck(this, blendFilterArray)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.calculateVertices();
|
||||
renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]);
|
||||
renderer.plugins[this.pluginName].render(this);
|
||||
if (blendFilterArray) {
|
||||
renderer.batch.flush();
|
||||
renderer.filter.pop();
|
||||
}
|
||||
};
|
||||
return Sprite;
|
||||
}(PIXI.Sprite));
|
||||
pixi_picture.Sprite = Sprite;
|
||||
})(pixi_picture || (pixi_picture = {}));
|
||||
var pixi_picture;
|
||||
(function (pixi_picture) {
|
||||
var TilingSprite = (function (_super) {
|
||||
__extends(TilingSprite, _super);
|
||||
function TilingSprite() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
TilingSprite.prototype._render = function (renderer) {
|
||||
var texture = this._texture;
|
||||
if (!texture || !texture.valid) {
|
||||
return;
|
||||
}
|
||||
var blendFilterArray = pixi_picture.getBlendFilterArray(this.blendMode);
|
||||
if (blendFilterArray) {
|
||||
renderer.batch.flush();
|
||||
if (!renderer.filter.pushWithCheck(this, blendFilterArray)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.tileTransform.updateLocalTransform();
|
||||
this.uvMatrix.update();
|
||||
renderer.batch.setObjectRenderer(renderer.plugins[this.pluginName]);
|
||||
renderer.plugins[this.pluginName].render(this);
|
||||
if (blendFilterArray) {
|
||||
renderer.batch.flush();
|
||||
renderer.filter.pop();
|
||||
}
|
||||
};
|
||||
return TilingSprite;
|
||||
}(PIXI.TilingSprite));
|
||||
pixi_picture.TilingSprite = TilingSprite;
|
||||
})(pixi_picture || (pixi_picture = {}));
|
||||
var pixi_picture;
|
||||
(function (pixi_picture) {
|
||||
PIXI.picture = pixi_picture;
|
||||
})(pixi_picture || (pixi_picture = {}));
|
||||
//# sourceMappingURL=pixi-picture.js.map
|
973
nwjs/packagefiles/rpgmaker-mv-pixi5/js/libs/pixi-tilemap.js
Normal file
973
nwjs/packagefiles/rpgmaker-mv-pixi5/js/libs/pixi-tilemap.js
Normal file
|
@ -0,0 +1,973 @@
|
|||
/* eslint-disable */
|
||||
|
||||
/*!
|
||||
* pixi-tilemap - v2.1.3
|
||||
* Compiled Sun, 18 Oct 2020 17:08:58 UTC
|
||||
*
|
||||
* pixi-tilemap is licensed under the MIT License.
|
||||
* http://www.opensource.org/licenses/mit-license
|
||||
*
|
||||
* Copyright 2019-2020, Ivan Popelyshev, All Rights Reserved
|
||||
*/
|
||||
this.PIXI = this.PIXI || {};
|
||||
this.PIXI.tilemap = this.PIXI.tilemap || {};
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@pixi/display'), require('@pixi/core'), require('@pixi/constants'), require('@pixi/math'), require('@pixi/graphics'), require('@pixi/sprite')) :
|
||||
typeof define === 'function' && define.amd ? define(['exports', '@pixi/display', '@pixi/core', '@pixi/constants', '@pixi/math', '@pixi/graphics', '@pixi/sprite'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.pixi_tilemap = {}, global.PIXI, global.PIXI, global.PIXI, global.PIXI, global.PIXI, global.PIXI));
|
||||
}(this, (function (exports, display, core, constants, math, graphics, sprite) {
|
||||
'use strict';
|
||||
|
||||
class CanvasTileRenderer {
|
||||
constructor(renderer) {
|
||||
this.tileAnim = [0, 0];
|
||||
this.dontUseTransform = false;
|
||||
this.renderer = renderer;
|
||||
this.tileAnim = [0, 0];
|
||||
}
|
||||
}
|
||||
const cr = PIXI.CanvasRenderer;
|
||||
if (cr) {
|
||||
cr.registerPlugin('tilemap', CanvasTileRenderer);
|
||||
}
|
||||
|
||||
const Constant = {
|
||||
maxTextures: 16,
|
||||
bufferSize: 2048,
|
||||
boundSize: 1024,
|
||||
boundCountPerBuffer: 1,
|
||||
use32bitIndex: false,
|
||||
SCALE_MODE: constants.SCALE_MODES.LINEAR,
|
||||
DO_CLEAR: true
|
||||
};
|
||||
|
||||
const POINT_STRUCT_SIZE = 12;
|
||||
class RectTileLayer extends display.Container {
|
||||
constructor(zIndex, texture) {
|
||||
super();
|
||||
this.zIndex = 0;
|
||||
this.modificationMarker = 0;
|
||||
this._$_localBounds = new display.Bounds();
|
||||
this.shadowColor = new Float32Array([0.0, 0.0, 0.0, 0.5]);
|
||||
this._globalMat = null;
|
||||
this.pointsBuf = [];
|
||||
this.hasAnim = false;
|
||||
this.offsetX = 0;
|
||||
this.offsetY = 0;
|
||||
this.compositeParent = false;
|
||||
this.tileAnim = null;
|
||||
this.vbId = 0;
|
||||
this.vb = null;
|
||||
this.vbBuffer = null;
|
||||
this.vbArray = null;
|
||||
this.vbInts = null;
|
||||
this.initialize(zIndex, texture);
|
||||
}
|
||||
initialize(zIndex, textures) {
|
||||
if (!textures) {
|
||||
textures = [];
|
||||
}
|
||||
else if (!(textures instanceof Array) && textures.baseTexture) {
|
||||
textures = [textures];
|
||||
}
|
||||
this.textures = textures;
|
||||
this.zIndex = zIndex;
|
||||
}
|
||||
clear() {
|
||||
this.pointsBuf.length = 0;
|
||||
this.modificationMarker = 0;
|
||||
this._$_localBounds.clear();
|
||||
this.hasAnim = false;
|
||||
}
|
||||
addFrame(texture_, x, y, animX, animY) {
|
||||
let texture;
|
||||
let textureIndex = 0;
|
||||
if (typeof texture_ === "number") {
|
||||
textureIndex = texture_;
|
||||
texture = this.textures[textureIndex];
|
||||
}
|
||||
else {
|
||||
if (typeof texture_ === "string") {
|
||||
texture = core.Texture.from(texture_);
|
||||
}
|
||||
else {
|
||||
texture = texture_;
|
||||
}
|
||||
let found = false;
|
||||
let textureList = this.textures;
|
||||
for (let i = 0; i < textureList.length; i++) {
|
||||
if (textureList[i].baseTexture === texture.baseTexture) {
|
||||
textureIndex = i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
this.addRect(textureIndex, texture.frame.x, texture.frame.y, x, y, texture.orig.width, texture.orig.height, animX, animY, texture.rotate);
|
||||
return true;
|
||||
}
|
||||
addRect(textureIndex, u, v, x, y, tileWidth, tileHeight, animX = 0, animY = 0, rotate = 0, animCountX = 1024, animCountY = 1024) {
|
||||
let pb = this.pointsBuf;
|
||||
this.hasAnim = this.hasAnim || animX > 0 || animY > 0;
|
||||
pb.push(u);
|
||||
pb.push(v);
|
||||
pb.push(x);
|
||||
pb.push(y);
|
||||
pb.push(tileWidth);
|
||||
pb.push(tileHeight);
|
||||
pb.push(rotate);
|
||||
pb.push(animX | 0);
|
||||
pb.push(animY | 0);
|
||||
pb.push(textureIndex);
|
||||
pb.push(animCountX);
|
||||
pb.push(animCountY);
|
||||
this._$_localBounds.addFramePad(x, y, x + tileWidth, y + tileHeight, 0, 0);
|
||||
return this;
|
||||
}
|
||||
tileRotate(rotate) {
|
||||
const pb = this.pointsBuf;
|
||||
pb[pb.length - 3] = rotate;
|
||||
}
|
||||
tileAnimX(offset, count) {
|
||||
const pb = this.pointsBuf;
|
||||
pb[pb.length - 5] = offset;
|
||||
pb[pb.length - 2] = count;
|
||||
}
|
||||
tileAnimY(offset, count) {
|
||||
const pb = this.pointsBuf;
|
||||
pb[pb.length - 4] = offset;
|
||||
pb[pb.length - 1] = count;
|
||||
}
|
||||
renderCanvas(renderer) {
|
||||
let plugin = renderer.plugins.tilemap;
|
||||
if (!plugin.dontUseTransform) {
|
||||
let wt = this.worldTransform;
|
||||
renderer.context.setTransform(wt.a, wt.b, wt.c, wt.d, wt.tx * renderer.resolution, wt.ty * renderer.resolution);
|
||||
}
|
||||
this.renderCanvasCore(renderer);
|
||||
}
|
||||
renderCanvasCore(renderer) {
|
||||
if (this.textures.length === 0)
|
||||
return;
|
||||
let points = this.pointsBuf;
|
||||
const tileAnim = this.tileAnim || renderer.plugins.tilemap.tileAnim;
|
||||
renderer.context.fillStyle = '#000000';
|
||||
for (let i = 0, n = points.length; i < n; i += POINT_STRUCT_SIZE) {
|
||||
let x1 = points[i], y1 = points[i + 1];
|
||||
let x2 = points[i + 2], y2 = points[i + 3];
|
||||
let w = points[i + 4];
|
||||
let h = points[i + 5];
|
||||
var rotate = points[i + 6];
|
||||
x1 += points[i + 7] * tileAnim[0];
|
||||
y1 += points[i + 8] * tileAnim[1];
|
||||
let textureIndex = points[i + 9];
|
||||
if (textureIndex >= 0) {
|
||||
renderer.context.drawImage(this.textures[textureIndex].baseTexture.getDrawableSource(), x1, y1, w, h, x2, y2, w, h);
|
||||
}
|
||||
else {
|
||||
renderer.context.globalAlpha = 0.5;
|
||||
renderer.context.fillRect(x2, y2, w, h);
|
||||
renderer.context.globalAlpha = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
destroyVb() {
|
||||
if (this.vb) {
|
||||
this.vb.destroy();
|
||||
this.vb = null;
|
||||
}
|
||||
}
|
||||
render(renderer) {
|
||||
let plugin = renderer.plugins['tilemap'];
|
||||
let shader = plugin.getShader();
|
||||
renderer.batch.setObjectRenderer(plugin);
|
||||
this._globalMat = shader.uniforms.projTransMatrix;
|
||||
renderer.globalUniforms.uniforms.projectionMatrix.copyTo(this._globalMat).append(this.worldTransform);
|
||||
shader.uniforms.shadowColor = this.shadowColor;
|
||||
shader.uniforms.animationFrame = this.tileAnim || plugin.tileAnim;
|
||||
this.renderWebGLCore(renderer, plugin);
|
||||
}
|
||||
renderWebGLCore(renderer, plugin) {
|
||||
let points = this.pointsBuf;
|
||||
if (points.length === 0)
|
||||
return;
|
||||
let rectsCount = points.length / POINT_STRUCT_SIZE;
|
||||
let shader = plugin.getShader();
|
||||
let textures = this.textures;
|
||||
if (textures.length === 0)
|
||||
return;
|
||||
plugin.bindTextures(renderer, shader, textures);
|
||||
renderer.shader.bind(shader, false);
|
||||
let vb = this.vb;
|
||||
if (!vb) {
|
||||
vb = plugin.createVb();
|
||||
this.vb = vb;
|
||||
this.vbId = vb.id;
|
||||
this.vbBuffer = null;
|
||||
this.modificationMarker = 0;
|
||||
}
|
||||
plugin.checkIndexBuffer(rectsCount, vb);
|
||||
const boundCountPerBuffer = Constant.boundCountPerBuffer;
|
||||
let vertexBuf = vb.getBuffer('aVertexPosition');
|
||||
let vertices = rectsCount * vb.vertPerQuad;
|
||||
if (vertices === 0)
|
||||
return;
|
||||
if (this.modificationMarker !== vertices) {
|
||||
this.modificationMarker = vertices;
|
||||
let vs = vb.stride * vertices;
|
||||
if (!this.vbBuffer || this.vbBuffer.byteLength < vs) {
|
||||
let bk = vb.stride;
|
||||
while (bk < vs) {
|
||||
bk *= 2;
|
||||
}
|
||||
this.vbBuffer = new ArrayBuffer(bk);
|
||||
this.vbArray = new Float32Array(this.vbBuffer);
|
||||
this.vbInts = new Uint32Array(this.vbBuffer);
|
||||
vertexBuf.update(this.vbBuffer);
|
||||
}
|
||||
let arr = this.vbArray, ints = this.vbInts;
|
||||
let sz = 0;
|
||||
let textureId = 0;
|
||||
let shiftU = this.offsetX;
|
||||
let shiftV = this.offsetY;
|
||||
let tint = -1;
|
||||
for (let i = 0; i < points.length; i += POINT_STRUCT_SIZE) {
|
||||
let eps = 0.5;
|
||||
if (this.compositeParent) {
|
||||
if (boundCountPerBuffer > 1) {
|
||||
textureId = (points[i + 9] >> 2);
|
||||
shiftU = this.offsetX * (points[i + 9] & 1);
|
||||
shiftV = this.offsetY * ((points[i + 9] >> 1) & 1);
|
||||
}
|
||||
else {
|
||||
textureId = points[i + 9];
|
||||
shiftU = 0;
|
||||
shiftV = 0;
|
||||
}
|
||||
}
|
||||
let x = points[i + 2], y = points[i + 3];
|
||||
let w = points[i + 4], h = points[i + 5];
|
||||
let u = points[i] + shiftU, v = points[i + 1] + shiftV;
|
||||
let rotate = points[i + 6];
|
||||
const animX = points[i + 7], animY = points[i + 8];
|
||||
const animWidth = points[i + 10] || 1024, animHeight = points[i + 11] || 1024;
|
||||
const animXEncoded = animX + (animWidth * 2048);
|
||||
const animYEncoded = animY + (animHeight * 2048);
|
||||
let u0, v0, u1, v1, u2, v2, u3, v3;
|
||||
if (rotate === 0) {
|
||||
u0 = u;
|
||||
v0 = v;
|
||||
u1 = u + w;
|
||||
v1 = v;
|
||||
u2 = u + w;
|
||||
v2 = v + h;
|
||||
u3 = u;
|
||||
v3 = v + h;
|
||||
}
|
||||
else {
|
||||
let w2 = w / 2;
|
||||
let h2 = h / 2;
|
||||
if (rotate % 4 !== 0) {
|
||||
w2 = h / 2;
|
||||
h2 = w / 2;
|
||||
}
|
||||
const cX = u + w2;
|
||||
const cY = v + h2;
|
||||
rotate = math.groupD8.add(rotate, math.groupD8.NW);
|
||||
u0 = cX + (w2 * math.groupD8.uX(rotate));
|
||||
v0 = cY + (h2 * math.groupD8.uY(rotate));
|
||||
rotate = math.groupD8.add(rotate, 2);
|
||||
u1 = cX + (w2 * math.groupD8.uX(rotate));
|
||||
v1 = cY + (h2 * math.groupD8.uY(rotate));
|
||||
rotate = math.groupD8.add(rotate, 2);
|
||||
u2 = cX + (w2 * math.groupD8.uX(rotate));
|
||||
v2 = cY + (h2 * math.groupD8.uY(rotate));
|
||||
rotate = math.groupD8.add(rotate, 2);
|
||||
u3 = cX + (w2 * math.groupD8.uX(rotate));
|
||||
v3 = cY + (h2 * math.groupD8.uY(rotate));
|
||||
}
|
||||
arr[sz++] = x;
|
||||
arr[sz++] = y;
|
||||
arr[sz++] = u0;
|
||||
arr[sz++] = v0;
|
||||
arr[sz++] = u + eps;
|
||||
arr[sz++] = v + eps;
|
||||
arr[sz++] = u + w - eps;
|
||||
arr[sz++] = v + h - eps;
|
||||
arr[sz++] = animXEncoded;
|
||||
arr[sz++] = animYEncoded;
|
||||
arr[sz++] = textureId;
|
||||
arr[sz++] = x + w;
|
||||
arr[sz++] = y;
|
||||
arr[sz++] = u1;
|
||||
arr[sz++] = v1;
|
||||
arr[sz++] = u + eps;
|
||||
arr[sz++] = v + eps;
|
||||
arr[sz++] = u + w - eps;
|
||||
arr[sz++] = v + h - eps;
|
||||
arr[sz++] = animXEncoded;
|
||||
arr[sz++] = animYEncoded;
|
||||
arr[sz++] = textureId;
|
||||
arr[sz++] = x + w;
|
||||
arr[sz++] = y + h;
|
||||
arr[sz++] = u2;
|
||||
arr[sz++] = v2;
|
||||
arr[sz++] = u + eps;
|
||||
arr[sz++] = v + eps;
|
||||
arr[sz++] = u + w - eps;
|
||||
arr[sz++] = v + h - eps;
|
||||
arr[sz++] = animXEncoded;
|
||||
arr[sz++] = animYEncoded;
|
||||
arr[sz++] = textureId;
|
||||
arr[sz++] = x;
|
||||
arr[sz++] = y + h;
|
||||
arr[sz++] = u3;
|
||||
arr[sz++] = v3;
|
||||
arr[sz++] = u + eps;
|
||||
arr[sz++] = v + eps;
|
||||
arr[sz++] = u + w - eps;
|
||||
arr[sz++] = v + h - eps;
|
||||
arr[sz++] = animXEncoded;
|
||||
arr[sz++] = animYEncoded;
|
||||
arr[sz++] = textureId;
|
||||
}
|
||||
vertexBuf.update(arr);
|
||||
}
|
||||
renderer.geometry.bind(vb, shader);
|
||||
renderer.geometry.draw(constants.DRAW_MODES.TRIANGLES, rectsCount * 6, 0);
|
||||
}
|
||||
isModified(anim) {
|
||||
if (this.modificationMarker !== this.pointsBuf.length ||
|
||||
anim && this.hasAnim) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
clearModify() {
|
||||
this.modificationMarker = this.pointsBuf.length;
|
||||
}
|
||||
_calculateBounds() {
|
||||
const { minX, minY, maxX, maxY } = this._$_localBounds;
|
||||
this._bounds.addFrame(this.transform, minX, minY, maxX, maxY);
|
||||
}
|
||||
getLocalBounds(rect) {
|
||||
if (this.children.length === 0) {
|
||||
return this._$_localBounds.getRectangle(rect);
|
||||
}
|
||||
return super.getLocalBounds.call(this, rect);
|
||||
}
|
||||
destroy(options) {
|
||||
super.destroy(options);
|
||||
this.destroyVb();
|
||||
}
|
||||
}
|
||||
|
||||
class CompositeRectTileLayer extends display.Container {
|
||||
constructor(zIndex, bitmaps, texPerChild) {
|
||||
super();
|
||||
this.modificationMarker = 0;
|
||||
this.shadowColor = new Float32Array([0.0, 0.0, 0.0, 0.5]);
|
||||
this._globalMat = null;
|
||||
this._lastLayer = null;
|
||||
this.tileAnim = null;
|
||||
this.initialize.apply(this, arguments);
|
||||
}
|
||||
initialize(zIndex, bitmaps, texPerChild) {
|
||||
if (texPerChild === true) {
|
||||
texPerChild = 0;
|
||||
}
|
||||
this.z = this.zIndex = zIndex;
|
||||
this.texPerChild = texPerChild || Constant.boundCountPerBuffer * Constant.maxTextures;
|
||||
if (bitmaps) {
|
||||
this.setBitmaps(bitmaps);
|
||||
}
|
||||
}
|
||||
setBitmaps(bitmaps) {
|
||||
for (let i = 0; i < bitmaps.length; i++) {
|
||||
if (bitmaps[i] && !bitmaps[i].baseTexture) {
|
||||
throw new Error(`pixi-tilemap cannot use destroyed textures. ` +
|
||||
`Probably, you passed resources['myAtlas'].texture in pixi > 5.2.1, it does not exist there.`);
|
||||
}
|
||||
}
|
||||
let texPerChild = this.texPerChild;
|
||||
let len1 = this.children.length;
|
||||
let len2 = Math.ceil(bitmaps.length / texPerChild);
|
||||
let i;
|
||||
for (i = 0; i < len1; i++) {
|
||||
this.children[i].textures = bitmaps.slice(i * texPerChild, (i + 1) * texPerChild);
|
||||
}
|
||||
for (i = len1; i < len2; i++) {
|
||||
let layer = new RectTileLayer(this.zIndex, bitmaps.slice(i * texPerChild, (i + 1) * texPerChild));
|
||||
layer.compositeParent = true;
|
||||
layer.offsetX = Constant.boundSize;
|
||||
layer.offsetY = Constant.boundSize;
|
||||
this.addChild(layer);
|
||||
}
|
||||
}
|
||||
clear() {
|
||||
for (let i = 0; i < this.children.length; i++) {
|
||||
this.children[i].clear();
|
||||
}
|
||||
this.modificationMarker = 0;
|
||||
}
|
||||
addRect(textureIndex, u, v, x, y, tileWidth, tileHeight, animX, animY, rotate, animWidth, animHeight) {
|
||||
const childIndex = textureIndex / this.texPerChild >> 0;
|
||||
const textureId = textureIndex % this.texPerChild;
|
||||
if (this.children[childIndex] && this.children[childIndex].textures) {
|
||||
this._lastLayer = this.children[childIndex];
|
||||
this._lastLayer.addRect(textureId, u, v, x, y, tileWidth, tileHeight, animX, animY, rotate, animWidth, animHeight);
|
||||
}
|
||||
else {
|
||||
this._lastLayer = null;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
tileRotate(rotate) {
|
||||
if (this._lastLayer) {
|
||||
this._lastLayer.tileRotate(rotate);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
tileAnimX(offset, count) {
|
||||
if (this._lastLayer) {
|
||||
this._lastLayer.tileAnimX(offset, count);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
tileAnimY(offset, count) {
|
||||
if (this._lastLayer) {
|
||||
this._lastLayer.tileAnimY(offset, count);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
addFrame(texture_, x, y, animX, animY, animWidth, animHeight) {
|
||||
let texture;
|
||||
let layer = null;
|
||||
let ind = 0;
|
||||
let children = this.children;
|
||||
this._lastLayer = null;
|
||||
if (typeof texture_ === "number") {
|
||||
let childIndex = texture_ / this.texPerChild >> 0;
|
||||
layer = children[childIndex];
|
||||
if (!layer) {
|
||||
layer = children[0];
|
||||
if (!layer) {
|
||||
return this;
|
||||
}
|
||||
ind = 0;
|
||||
}
|
||||
else {
|
||||
ind = texture_ % this.texPerChild;
|
||||
}
|
||||
texture = layer.textures[ind];
|
||||
}
|
||||
else {
|
||||
if (typeof texture_ === "string") {
|
||||
texture = core.Texture.from(texture_);
|
||||
}
|
||||
else {
|
||||
texture = texture_;
|
||||
}
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
let child = children[i];
|
||||
let tex = child.textures;
|
||||
for (let j = 0; j < tex.length; j++) {
|
||||
if (tex[j].baseTexture === texture.baseTexture) {
|
||||
layer = child;
|
||||
ind = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (layer) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!layer) {
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
let child = children[i];
|
||||
if (child.textures.length < this.texPerChild) {
|
||||
layer = child;
|
||||
ind = child.textures.length;
|
||||
child.textures.push(texture);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!layer) {
|
||||
layer = new RectTileLayer(this.zIndex, texture);
|
||||
layer.compositeParent = true;
|
||||
layer.offsetX = Constant.boundSize;
|
||||
layer.offsetY = Constant.boundSize;
|
||||
this.addChild(layer);
|
||||
ind = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._lastLayer = layer;
|
||||
layer.addRect(ind, texture.frame.x, texture.frame.y, x, y, texture.orig.width, texture.orig.height, animX, animY, texture.rotate, animWidth, animHeight);
|
||||
return this;
|
||||
}
|
||||
renderCanvas(renderer) {
|
||||
if (!this.visible || this.worldAlpha <= 0 || !this.renderable) {
|
||||
return;
|
||||
}
|
||||
let plugin = renderer.plugins.tilemap;
|
||||
if (!plugin.dontUseTransform) {
|
||||
let wt = this.worldTransform;
|
||||
renderer.context.setTransform(wt.a, wt.b, wt.c, wt.d, wt.tx * renderer.resolution, wt.ty * renderer.resolution);
|
||||
}
|
||||
let layers = this.children;
|
||||
for (let i = 0; i < layers.length; i++) {
|
||||
const layer = layers[i];
|
||||
layer.tileAnim = this.tileAnim;
|
||||
layer.renderCanvasCore(renderer);
|
||||
}
|
||||
}
|
||||
render(renderer) {
|
||||
if (!this.visible || this.worldAlpha <= 0 || !this.renderable) {
|
||||
return;
|
||||
}
|
||||
let plugin = renderer.plugins['tilemap'];
|
||||
let shader = plugin.getShader();
|
||||
renderer.batch.setObjectRenderer(plugin);
|
||||
this._globalMat = shader.uniforms.projTransMatrix;
|
||||
renderer.globalUniforms.uniforms.projectionMatrix.copyTo(this._globalMat).append(this.worldTransform);
|
||||
shader.uniforms.shadowColor = this.shadowColor;
|
||||
shader.uniforms.animationFrame = this.tileAnim || plugin.tileAnim;
|
||||
renderer.shader.bind(shader, false);
|
||||
let layers = this.children;
|
||||
for (let i = 0; i < layers.length; i++) {
|
||||
const layer = layers[i];
|
||||
layer.renderWebGLCore(renderer, plugin);
|
||||
}
|
||||
}
|
||||
isModified(anim) {
|
||||
let layers = this.children;
|
||||
if (this.modificationMarker !== layers.length) {
|
||||
return true;
|
||||
}
|
||||
for (let i = 0; i < layers.length; i++) {
|
||||
if (layers[i].isModified(anim)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
clearModify() {
|
||||
let layers = this.children;
|
||||
this.modificationMarker = layers.length;
|
||||
for (let i = 0; i < layers.length; i++) {
|
||||
layers[i].clearModify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class GraphicsLayer extends graphics.Graphics {
|
||||
constructor(zIndex) {
|
||||
super();
|
||||
this.zIndex = zIndex;
|
||||
}
|
||||
renderCanvas(renderer) {
|
||||
let wt = null;
|
||||
if (renderer.plugins.tilemap.dontUseTransform) {
|
||||
wt = this.transform.worldTransform;
|
||||
this.transform.worldTransform = math.Matrix.IDENTITY;
|
||||
}
|
||||
renderer.plugins.graphics.render(this);
|
||||
if (renderer.plugins.tilemap.dontUseTransform) {
|
||||
this.transform.worldTransform = wt;
|
||||
}
|
||||
renderer.context.globalAlpha = 1.0;
|
||||
}
|
||||
isModified(anim) {
|
||||
return false;
|
||||
}
|
||||
clearModify() {
|
||||
}
|
||||
}
|
||||
|
||||
class MultiTextureResource extends core.resources.Resource {
|
||||
constructor(options) {
|
||||
super(options.bufferSize, options.bufferSize);
|
||||
this.DO_CLEAR = false;
|
||||
this.boundSize = 0;
|
||||
this._clearBuffer = null;
|
||||
this.baseTex = null;
|
||||
this.boundSprites = [];
|
||||
this.dirties = [];
|
||||
const bounds = this.boundSprites;
|
||||
const dirties = this.dirties;
|
||||
this.boundSize = options.boundSize;
|
||||
for (let j = 0; j < options.boundCountPerBuffer; j++) {
|
||||
const spr = new sprite.Sprite();
|
||||
spr.position.x = options.boundSize * (j & 1);
|
||||
spr.position.y = options.boundSize * (j >> 1);
|
||||
bounds.push(spr);
|
||||
dirties.push(0);
|
||||
}
|
||||
this.DO_CLEAR = !!options.DO_CLEAR;
|
||||
}
|
||||
bind(baseTexture) {
|
||||
if (this.baseTex) {
|
||||
throw new Error('Only one baseTexture is allowed for this resource!');
|
||||
}
|
||||
this.baseTex = baseTexture;
|
||||
super.bind(baseTexture);
|
||||
}
|
||||
setTexture(ind, texture) {
|
||||
const spr = this.boundSprites[ind];
|
||||
if (spr.texture.baseTexture === texture.baseTexture) {
|
||||
return;
|
||||
}
|
||||
spr.texture = texture;
|
||||
this.baseTex.update();
|
||||
this.dirties[ind] = this.baseTex.dirtyId;
|
||||
}
|
||||
upload(renderer, texture, glTexture) {
|
||||
const { gl } = renderer;
|
||||
const { width, height } = this;
|
||||
gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.alphaMode === undefined ||
|
||||
texture.alphaMode === constants.ALPHA_MODES.UNPACK);
|
||||
if (glTexture.dirtyId < 0) {
|
||||
glTexture.width = width;
|
||||
glTexture.height = height;
|
||||
gl.texImage2D(texture.target, 0, texture.format, width, height, 0, texture.format, texture.type, null);
|
||||
}
|
||||
const doClear = this.DO_CLEAR;
|
||||
if (doClear && !this._clearBuffer) {
|
||||
this._clearBuffer = new Uint8Array(Constant.boundSize * Constant.boundSize * 4);
|
||||
}
|
||||
const bounds = this.boundSprites;
|
||||
for (let i = 0; i < bounds.length; i++) {
|
||||
const spr = bounds[i];
|
||||
const tex = spr.texture.baseTexture;
|
||||
if (glTexture.dirtyId >= this.dirties[i]) {
|
||||
continue;
|
||||
}
|
||||
const res = tex.resource;
|
||||
if (!tex.valid || !res || !res.source) {
|
||||
continue;
|
||||
}
|
||||
if (doClear && (tex.width < this.boundSize || tex.height < this.boundSize)) {
|
||||
gl.texSubImage2D(texture.target, 0, spr.position.x, spr.position.y, this.boundSize, this.boundSize, texture.format, texture.type, this._clearBuffer);
|
||||
}
|
||||
gl.texSubImage2D(texture.target, 0, spr.position.x, spr.position.y, texture.format, texture.type, res.source);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function fillSamplers(shader, maxTextures) {
|
||||
let sampleValues = [];
|
||||
for (let i = 0; i < maxTextures; i++) {
|
||||
sampleValues[i] = i;
|
||||
}
|
||||
shader.uniforms.uSamplers = sampleValues;
|
||||
let samplerSize = [];
|
||||
for (let i = 0; i < maxTextures; i++) {
|
||||
samplerSize.push(1.0 / Constant.bufferSize);
|
||||
samplerSize.push(1.0 / Constant.bufferSize);
|
||||
}
|
||||
shader.uniforms.uSamplerSize = samplerSize;
|
||||
}
|
||||
function generateFragmentSrc(maxTextures, fragmentSrc) {
|
||||
return fragmentSrc.replace(/%count%/gi, maxTextures + "")
|
||||
.replace(/%forloop%/gi, generateSampleSrc(maxTextures));
|
||||
}
|
||||
function generateSampleSrc(maxTextures) {
|
||||
let src = '';
|
||||
src += '\n';
|
||||
src += '\n';
|
||||
src += 'if(vTextureId <= -1.0) {';
|
||||
src += '\n\tcolor = shadowColor;';
|
||||
src += '\n}';
|
||||
for (let i = 0; i < maxTextures; i++) {
|
||||
src += '\nelse ';
|
||||
if (i < maxTextures - 1) {
|
||||
src += 'if(textureId == ' + i + '.0)';
|
||||
}
|
||||
src += '\n{';
|
||||
src += '\n\tcolor = texture2D(uSamplers[' + i + '], textureCoord * uSamplerSize[' + i + ']);';
|
||||
src += '\n}';
|
||||
}
|
||||
src += '\n';
|
||||
src += '\n';
|
||||
return src;
|
||||
}
|
||||
|
||||
let rectShaderFrag = `
|
||||
varying vec2 vTextureCoord;
|
||||
varying vec4 vFrame;
|
||||
varying float vTextureId;
|
||||
uniform vec4 shadowColor;
|
||||
uniform sampler2D uSamplers[%count%];
|
||||
uniform vec2 uSamplerSize[%count%];
|
||||
|
||||
void main(void){
|
||||
vec2 textureCoord = clamp(vTextureCoord, vFrame.xy, vFrame.zw);
|
||||
float textureId = floor(vTextureId + 0.5);
|
||||
|
||||
vec4 color;
|
||||
%forloop%
|
||||
gl_FragColor = color;
|
||||
}
|
||||
`;
|
||||
let rectShaderVert = `
|
||||
attribute vec2 aVertexPosition;
|
||||
attribute vec2 aTextureCoord;
|
||||
attribute vec4 aFrame;
|
||||
attribute vec2 aAnim;
|
||||
attribute float aTextureId;
|
||||
|
||||
uniform mat3 projTransMatrix;
|
||||
uniform vec2 animationFrame;
|
||||
|
||||
varying vec2 vTextureCoord;
|
||||
varying float vTextureId;
|
||||
varying vec4 vFrame;
|
||||
|
||||
void main(void){
|
||||
gl_Position = vec4((projTransMatrix * vec3(aVertexPosition, 1.0)).xy, 0.0, 1.0);
|
||||
vec2 animCount = floor((aAnim + 0.5) / 2048.0);
|
||||
vec2 animFrameOffset = aAnim - animCount * 2048.0;
|
||||
vec2 animOffset = animFrameOffset * floor(mod(animationFrame + 0.5, animCount));
|
||||
|
||||
vTextureCoord = aTextureCoord + animOffset;
|
||||
vFrame = aFrame + vec4(animOffset, animOffset);
|
||||
vTextureId = aTextureId;
|
||||
}
|
||||
`;
|
||||
class TilemapShader extends core.Shader {
|
||||
constructor(maxTextures, shaderVert, shaderFrag) {
|
||||
super(new core.Program(shaderVert, shaderFrag), {
|
||||
animationFrame: new Float32Array(2),
|
||||
uSamplers: [],
|
||||
uSamplerSize: [],
|
||||
projTransMatrix: new math.Matrix()
|
||||
});
|
||||
this.maxTextures = 0;
|
||||
this.maxTextures = maxTextures;
|
||||
fillSamplers(this, this.maxTextures);
|
||||
}
|
||||
}
|
||||
class RectTileShader extends TilemapShader {
|
||||
constructor(maxTextures) {
|
||||
super(maxTextures, rectShaderVert, generateFragmentSrc(maxTextures, rectShaderFrag));
|
||||
fillSamplers(this, this.maxTextures);
|
||||
}
|
||||
}
|
||||
class RectTileGeom extends core.Geometry {
|
||||
constructor() {
|
||||
super();
|
||||
this.vertSize = 11;
|
||||
this.vertPerQuad = 4;
|
||||
this.stride = this.vertSize * 4;
|
||||
this.lastTimeAccess = 0;
|
||||
const buf = this.buf = new core.Buffer(new Float32Array(2), true, false);
|
||||
this.addAttribute('aVertexPosition', buf, 0, false, 0, this.stride, 0)
|
||||
.addAttribute('aTextureCoord', buf, 0, false, 0, this.stride, 2 * 4)
|
||||
.addAttribute('aFrame', buf, 0, false, 0, this.stride, 4 * 4)
|
||||
.addAttribute('aAnim', buf, 0, false, 0, this.stride, 8 * 4)
|
||||
.addAttribute('aTextureId', buf, 0, false, 0, this.stride, 10 * 4);
|
||||
}
|
||||
}
|
||||
|
||||
class TileRenderer extends core.ObjectRenderer {
|
||||
constructor(renderer) {
|
||||
super(renderer);
|
||||
this.sn = -1;
|
||||
this.indexBuffer = null;
|
||||
this.ibLen = 0;
|
||||
this.tileAnim = [0, 0];
|
||||
this.texLoc = [];
|
||||
this.texResources = [];
|
||||
this.rectShader = new RectTileShader(Constant.maxTextures);
|
||||
this.indexBuffer = new core.Buffer(undefined, true, true);
|
||||
this.checkIndexBuffer(2000);
|
||||
this.initBounds();
|
||||
}
|
||||
initBounds() {
|
||||
if (Constant.boundCountPerBuffer <= 1) {
|
||||
return;
|
||||
}
|
||||
const maxTextures = Constant.maxTextures;
|
||||
for (let i = 0; i < maxTextures; i++) {
|
||||
const resource = new MultiTextureResource(Constant);
|
||||
const baseTex = new core.BaseTexture(resource);
|
||||
baseTex.scaleMode = Constant.SCALE_MODE;
|
||||
baseTex.wrapMode = constants.WRAP_MODES.CLAMP;
|
||||
this.texResources.push(resource);
|
||||
}
|
||||
}
|
||||
bindTexturesWithoutRT(renderer, shader, textures) {
|
||||
let samplerSize = shader.uniforms.uSamplerSize;
|
||||
this.texLoc.length = 0;
|
||||
for (let i = 0; i < textures.length; i++) {
|
||||
const texture = textures[i];
|
||||
if (!texture || !texture.valid) {
|
||||
return;
|
||||
}
|
||||
renderer.texture.bind(textures[i], i);
|
||||
samplerSize[i * 2] = 1.0 / textures[i].baseTexture.width;
|
||||
samplerSize[i * 2 + 1] = 1.0 / textures[i].baseTexture.height;
|
||||
}
|
||||
shader.uniforms.uSamplerSize = samplerSize;
|
||||
}
|
||||
bindTextures(renderer, shader, textures) {
|
||||
const len = textures.length;
|
||||
const maxTextures = Constant.maxTextures;
|
||||
if (len > Constant.boundCountPerBuffer * maxTextures) {
|
||||
return;
|
||||
}
|
||||
if (Constant.boundCountPerBuffer <= 1) {
|
||||
this.bindTexturesWithoutRT(renderer, shader, textures);
|
||||
return;
|
||||
}
|
||||
let i = 0;
|
||||
for (; i < len; i++) {
|
||||
const texture = textures[i];
|
||||
if (!texture || !texture.valid)
|
||||
continue;
|
||||
const multi = this.texResources[i >> 2];
|
||||
multi.setTexture(i & 3, texture);
|
||||
}
|
||||
let gltsUsed = (i + 3) >> 2;
|
||||
for (i = 0; i < gltsUsed; i++) {
|
||||
renderer.texture.bind(this.texResources[i].baseTex, i);
|
||||
}
|
||||
}
|
||||
start() {
|
||||
}
|
||||
createVb() {
|
||||
const geom = new RectTileGeom();
|
||||
geom.addIndex(this.indexBuffer);
|
||||
geom.lastTimeAccess = Date.now();
|
||||
return geom;
|
||||
}
|
||||
checkIndexBuffer(size, vb = null) {
|
||||
const totalIndices = size * 6;
|
||||
if (totalIndices <= this.ibLen) {
|
||||
return;
|
||||
}
|
||||
let len = totalIndices;
|
||||
while (len < totalIndices) {
|
||||
len <<= 1;
|
||||
}
|
||||
this.ibLen = totalIndices;
|
||||
this.indexBuffer.update(PIXI.utils.createIndicesForQuads(size, Constant.use32bitIndex ? new Uint32Array(size * 6) : undefined));
|
||||
}
|
||||
getShader() {
|
||||
return this.rectShader;
|
||||
}
|
||||
destroy() {
|
||||
super.destroy();
|
||||
this.rectShader = null;
|
||||
}
|
||||
}
|
||||
core.Renderer.registerPlugin('tilemap', TileRenderer);
|
||||
|
||||
class ZLayer extends display.Container {
|
||||
constructor(tilemap, zIndex) {
|
||||
super();
|
||||
this._lastAnimationFrame = -1;
|
||||
this.tilemap = tilemap;
|
||||
this.z = zIndex;
|
||||
}
|
||||
clear() {
|
||||
let layers = this.children;
|
||||
for (let i = 0; i < layers.length; i++)
|
||||
layers[i].clear();
|
||||
this._previousLayers = 0;
|
||||
}
|
||||
cacheIfDirty() {
|
||||
let tilemap = this.tilemap;
|
||||
let layers = this.children;
|
||||
let modified = this._previousLayers !== layers.length;
|
||||
this._previousLayers = layers.length;
|
||||
let buf = this.canvasBuffer;
|
||||
let tempRender = this._tempRender;
|
||||
if (!buf) {
|
||||
buf = this.canvasBuffer = document.createElement('canvas');
|
||||
tempRender = this._tempRender = new PIXI.CanvasRenderer({ width: 100, height: 100, view: buf });
|
||||
tempRender.context = tempRender.rootContext;
|
||||
tempRender.plugins.tilemap.dontUseTransform = true;
|
||||
}
|
||||
if (buf.width !== tilemap._layerWidth ||
|
||||
buf.height !== tilemap._layerHeight) {
|
||||
buf.width = tilemap._layerWidth;
|
||||
buf.height = tilemap._layerHeight;
|
||||
modified = true;
|
||||
}
|
||||
let i;
|
||||
if (!modified) {
|
||||
for (i = 0; i < layers.length; i++) {
|
||||
if (layers[i].isModified(this._lastAnimationFrame !== tilemap.animationFrame)) {
|
||||
modified = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
this._lastAnimationFrame = tilemap.animationFrame;
|
||||
if (modified) {
|
||||
if (tilemap._hackRenderer) {
|
||||
tilemap._hackRenderer(tempRender);
|
||||
}
|
||||
tempRender.context.clearRect(0, 0, buf.width, buf.height);
|
||||
for (i = 0; i < layers.length; i++) {
|
||||
layers[i].clearModify();
|
||||
layers[i].renderCanvas(tempRender);
|
||||
}
|
||||
}
|
||||
this.layerTransform = this.worldTransform;
|
||||
for (i = 0; i < layers.length; i++) {
|
||||
this.layerTransform = layers[i].worldTransform;
|
||||
break;
|
||||
}
|
||||
}
|
||||
renderCanvas(renderer) {
|
||||
this.cacheIfDirty();
|
||||
let wt = this.layerTransform;
|
||||
renderer.context.setTransform(wt.a, wt.b, wt.c, wt.d, wt.tx * renderer.resolution, wt.ty * renderer.resolution);
|
||||
let tilemap = this.tilemap;
|
||||
renderer.context.drawImage(this.canvasBuffer, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
const pixi_tilemap = {
|
||||
CanvasTileRenderer,
|
||||
CompositeRectTileLayer,
|
||||
Constant,
|
||||
GraphicsLayer,
|
||||
MultiTextureResource,
|
||||
RectTileLayer,
|
||||
TilemapShader,
|
||||
RectTileShader,
|
||||
RectTileGeom,
|
||||
TileRenderer,
|
||||
ZLayer,
|
||||
};
|
||||
|
||||
exports.CanvasTileRenderer = CanvasTileRenderer;
|
||||
exports.CompositeRectTileLayer = CompositeRectTileLayer;
|
||||
exports.Constant = Constant;
|
||||
exports.GraphicsLayer = GraphicsLayer;
|
||||
exports.MultiTextureResource = MultiTextureResource;
|
||||
exports.POINT_STRUCT_SIZE = POINT_STRUCT_SIZE;
|
||||
exports.RectTileGeom = RectTileGeom;
|
||||
exports.RectTileLayer = RectTileLayer;
|
||||
exports.RectTileShader = RectTileShader;
|
||||
exports.TileRenderer = TileRenderer;
|
||||
exports.TilemapShader = TilemapShader;
|
||||
exports.ZLayer = ZLayer;
|
||||
exports.fillSamplers = fillSamplers;
|
||||
exports.generateFragmentSrc = generateFragmentSrc;
|
||||
exports.generateSampleSrc = generateSampleSrc;
|
||||
exports.pixi_tilemap = pixi_tilemap;
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
})));
|
||||
if (typeof pixi_tilemap !== 'undefined') { Object.assign(this.PIXI.tilemap, pixi_tilemap); }
|
||||
//# sourceMappingURL=pixi-tilemap.umd.js.map
|
41981
nwjs/packagefiles/rpgmaker-mv-pixi5/js/libs/pixi.js
Normal file
41981
nwjs/packagefiles/rpgmaker-mv-pixi5/js/libs/pixi.js
Normal file
File diff suppressed because it is too large
Load diff
1
nwjs/packagefiles/rpgmaker-mv-pixi5/js/libs/pixi.js.map
Normal file
1
nwjs/packagefiles/rpgmaker-mv-pixi5/js/libs/pixi.js.map
Normal file
File diff suppressed because one or more lines are too long
9
nwjs/packagefiles/rpgmaker-mv-pixi5/js/libs/pixi.min.js
vendored
Normal file
9
nwjs/packagefiles/rpgmaker-mv-pixi5/js/libs/pixi.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
9
nwjs/packagefiles/rpgmaker-mv-pixi5/js/main.js
Normal file
9
nwjs/packagefiles/rpgmaker-mv-pixi5/js/main.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
//=============================================================================
|
||||
// main.js
|
||||
//=============================================================================
|
||||
|
||||
PluginManager.setup($plugins);
|
||||
|
||||
window.onload = function() {
|
||||
SceneManager.run(Scene_Boot);
|
||||
};
|
23783
nwjs/packagefiles/rpgmaker-mv-pixi5/js/rmmv-pixi.d.ts
vendored
Normal file
23783
nwjs/packagefiles/rpgmaker-mv-pixi5/js/rmmv-pixi.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load diff
20462
nwjs/packagefiles/rpgmaker-mv-pixi5/js/rmmv.d.ts
vendored
Normal file
20462
nwjs/packagefiles/rpgmaker-mv-pixi5/js/rmmv.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load diff
9432
nwjs/packagefiles/rpgmaker-mv-pixi5/js/rpg_core.js
Normal file
9432
nwjs/packagefiles/rpgmaker-mv-pixi5/js/rpg_core.js
Normal file
File diff suppressed because it is too large
Load diff
2849
nwjs/packagefiles/rpgmaker-mv-pixi5/js/rpg_managers.js
Normal file
2849
nwjs/packagefiles/rpgmaker-mv-pixi5/js/rpg_managers.js
Normal file
File diff suppressed because it is too large
Load diff
10642
nwjs/packagefiles/rpgmaker-mv-pixi5/js/rpg_objects.js
Normal file
10642
nwjs/packagefiles/rpgmaker-mv-pixi5/js/rpg_objects.js
Normal file
File diff suppressed because it is too large
Load diff
2690
nwjs/packagefiles/rpgmaker-mv-pixi5/js/rpg_scenes.js
Normal file
2690
nwjs/packagefiles/rpgmaker-mv-pixi5/js/rpg_scenes.js
Normal file
File diff suppressed because it is too large
Load diff
2703
nwjs/packagefiles/rpgmaker-mv-pixi5/js/rpg_sprites.js
Normal file
2703
nwjs/packagefiles/rpgmaker-mv-pixi5/js/rpg_sprites.js
Normal file
File diff suppressed because it is too large
Load diff
6029
nwjs/packagefiles/rpgmaker-mv-pixi5/js/rpg_windows.js
Normal file
6029
nwjs/packagefiles/rpgmaker-mv-pixi5/js/rpg_windows.js
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue