├── bin ├── unpack.json ├── res │ └── atlas │ │ ├── comp.png │ │ ├── .rec │ │ └── comp.atlas ├── index.html └── libs │ ├── min │ ├── laya.d3Plugin.min.js │ ├── laya.filter.min.js │ ├── laya.html.min.js │ ├── laya.device.min.js │ ├── laya.wxmini.min.js │ ├── laya.pathfinding.min.js │ ├── laya.particle.min.js │ └── laya.tiledmap.min.js │ ├── laya.d3Plugin.js │ ├── matter-RenderLaya.js │ ├── laya.filter.js │ ├── LayaRender.js │ └── worker.js ├── typings └── index.d.ts ├── config ├── prod.env.js ├── dev.env.js └── index.js ├── laya-webpack-typescript.laya ├── laya ├── assets │ └── comp │ │ ├── bg.png │ │ ├── html.png │ │ ├── tab.png │ │ ├── blank.png │ │ ├── button.png │ │ ├── hscroll.png │ │ ├── hslider.png │ │ ├── image.png │ │ ├── label.png │ │ ├── radio.png │ │ ├── vscroll.png │ │ ├── vslider.png │ │ ├── btn_close.png │ │ ├── checkbox.png │ │ ├── clip_num.png │ │ ├── combobox.png │ │ ├── progress.png │ │ ├── textarea.png │ │ ├── textinput.png │ │ ├── hscroll$bar.png │ │ ├── hscroll$down.png │ │ ├── hscroll$up.png │ │ ├── hslider$bar.png │ │ ├── linkbutton.png │ │ ├── progress$bar.png │ │ ├── radiogroup.png │ │ ├── vscroll$bar.png │ │ ├── vscroll$down.png │ │ ├── vscroll$up.png │ │ ├── vslider$bar.png │ │ ├── clip_selectBox.png │ │ ├── clip_tree_arrow.png │ │ └── clip_tree_folder.png ├── pages │ └── DemoPage.ui └── .laya ├── .editorconfig ├── .gitignore ├── README.md ├── .babelrc ├── tsconfig.json ├── src ├── main.ts └── ui │ └── layaUI.max.all.ts └── package.json /bin/unpack.json: -------------------------------------------------------------------------------- 1 | [] -------------------------------------------------------------------------------- /typings/index.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /config/prod.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | module.exports = { 3 | NODE_ENV: '"production"' 4 | } 5 | -------------------------------------------------------------------------------- /laya-webpack-typescript.laya: -------------------------------------------------------------------------------- 1 | {"proName":"laya-webpack-typescript","engineType":0,"proType":1,"layaProType":1} -------------------------------------------------------------------------------- /bin/res/atlas/comp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/bin/res/atlas/comp.png -------------------------------------------------------------------------------- /laya/assets/comp/bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/bg.png -------------------------------------------------------------------------------- /laya/assets/comp/html.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/html.png -------------------------------------------------------------------------------- /laya/assets/comp/tab.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/tab.png -------------------------------------------------------------------------------- /laya/assets/comp/blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/blank.png -------------------------------------------------------------------------------- /laya/assets/comp/button.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/button.png -------------------------------------------------------------------------------- /laya/assets/comp/hscroll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/hscroll.png -------------------------------------------------------------------------------- /laya/assets/comp/hslider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/hslider.png -------------------------------------------------------------------------------- /laya/assets/comp/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/image.png -------------------------------------------------------------------------------- /laya/assets/comp/label.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/label.png -------------------------------------------------------------------------------- /laya/assets/comp/radio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/radio.png -------------------------------------------------------------------------------- /laya/assets/comp/vscroll.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/vscroll.png -------------------------------------------------------------------------------- /laya/assets/comp/vslider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/vslider.png -------------------------------------------------------------------------------- /laya/assets/comp/btn_close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/btn_close.png -------------------------------------------------------------------------------- /laya/assets/comp/checkbox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/checkbox.png -------------------------------------------------------------------------------- /laya/assets/comp/clip_num.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/clip_num.png -------------------------------------------------------------------------------- /laya/assets/comp/combobox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/combobox.png -------------------------------------------------------------------------------- /laya/assets/comp/progress.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/progress.png -------------------------------------------------------------------------------- /laya/assets/comp/textarea.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/textarea.png -------------------------------------------------------------------------------- /laya/assets/comp/textinput.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/textinput.png -------------------------------------------------------------------------------- /laya/assets/comp/hscroll$bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/hscroll$bar.png -------------------------------------------------------------------------------- /laya/assets/comp/hscroll$down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/hscroll$down.png -------------------------------------------------------------------------------- /laya/assets/comp/hscroll$up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/hscroll$up.png -------------------------------------------------------------------------------- /laya/assets/comp/hslider$bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/hslider$bar.png -------------------------------------------------------------------------------- /laya/assets/comp/linkbutton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/linkbutton.png -------------------------------------------------------------------------------- /laya/assets/comp/progress$bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/progress$bar.png -------------------------------------------------------------------------------- /laya/assets/comp/radiogroup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/radiogroup.png -------------------------------------------------------------------------------- /laya/assets/comp/vscroll$bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/vscroll$bar.png -------------------------------------------------------------------------------- /laya/assets/comp/vscroll$down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/vscroll$down.png -------------------------------------------------------------------------------- /laya/assets/comp/vscroll$up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/vscroll$up.png -------------------------------------------------------------------------------- /laya/assets/comp/vslider$bar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/vslider$bar.png -------------------------------------------------------------------------------- /laya/assets/comp/clip_selectBox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/clip_selectBox.png -------------------------------------------------------------------------------- /laya/assets/comp/clip_tree_arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/clip_tree_arrow.png -------------------------------------------------------------------------------- /laya/assets/comp/clip_tree_folder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kokoroX/laya-webpack-typescript/HEAD/laya/assets/comp/clip_tree_folder.png -------------------------------------------------------------------------------- /config/dev.env.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | const merge = require('webpack-merge') 3 | const prodEnv = require('./prod.env') 4 | 5 | module.exports = merge(prodEnv, { 6 | NODE_ENV: '"development"' 7 | }) 8 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | /dist/ 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | 8 | # Editor directories and files 9 | .idea 10 | .vscode 11 | *.suo 12 | *.ntvs* 13 | *.njsproj 14 | *.sln 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > Layaair Webpack scaffold 2 | 3 | ## 介绍 4 | Layaair Webpack Typescript版本脚手架 5 | 基于 Vue 脚手架 6 | 可以配合官方编辑器使用 7 | 省去手动点击编译的时间 8 | 可以打包所有自定义js文件 9 | 支持热更新 10 | 11 | ## 注意事项 12 | 打包之前需要先跑一次开发 src/ui/layaUI.max.all.ts 的自动添加 export 只配了 dev 环境 13 | 14 | // todo 优化 layaUI 自动添加 export 15 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | [ 4 | "env", 5 | { 6 | "modules": false, 7 | "targets": { 8 | "browsers": [ 9 | "> 1%", 10 | "last 2 versions", 11 | "not ie <= 8" 12 | ] 13 | } 14 | } 15 | ], 16 | "stage-2" 17 | ], 18 | "plugins": [ 19 | "transform-runtime" 20 | ] 21 | } 22 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "include": [ 3 | "src/**/*", 4 | "typings/**/*" 5 | ], 6 | "exclude": [ 7 | "node_modules" 8 | ], 9 | "compilerOptions": { 10 | "allowSyntheticDefaultImports": true, 11 | "allowJs": true, 12 | "module": "commonjs", 13 | "target": "es5", 14 | "noImplicitAny": false, 15 | "moduleResolution": "node", 16 | "lib": [ 17 | "dom", 18 | "es5", 19 | "es2015" 20 | ], 21 | "sourceMap": true, 22 | "pretty": true 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | const { Handler, Sprite } = Laya 2 | import ui from './ui/layaUI.max.all'; 3 | 4 | // 程序入口 5 | class GameMain{ 6 | 7 | constructor () { 8 | Laya.init(750,1334); 9 | Laya.stage.screenMode = 'vertical'; 10 | Laya.loader.load('res/atlas/comp.atlas', Laya.Handler.create(null, this.init), null, Laya.Loader.ATLAS) 11 | } 12 | 13 | init () { 14 | const demoPage = new ui.DemoPageUI() 15 | Laya.stage.addChild(demoPage) 16 | const sprite = new Laya.Sprite() 17 | sprite.loadImage('comp/bg.png') 18 | demoPage.addChild(sprite) 19 | } 20 | } 21 | new GameMain(); 22 | -------------------------------------------------------------------------------- /src/ui/layaUI.max.all.ts: -------------------------------------------------------------------------------- 1 | 2 | import View=laya.ui.View; 3 | import Dialog=laya.ui.Dialog; 4 | module ui { 5 | export class DemoPageUI extends View { 6 | 7 | public static uiView:any ={"type":"View","props":{"width":750,"height":1334},"child":[{"type":"Rect","props":{"y":426,"x":226,"width":300,"rotation":30,"pivotY":1,"pivotX":1,"lineWidth":1,"height":300,"fillColor":"#ff0000"}}]}; 8 | constructor(){ super()} 9 | createChildren():void { 10 | 11 | super.createChildren(); 12 | this.createView(ui.DemoPageUI.uiView); 13 | 14 | } 15 | 16 | } 17 | } 18 | 19 | export default ui -------------------------------------------------------------------------------- /bin/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /bin/res/atlas/.rec: -------------------------------------------------------------------------------- 1 | D . 2 | D comp 3 | P D12221A9 bg.png 4 | P 9401CC40 blank.png 5 | P B03390E5 btn_close.png 6 | P 1F3929EA button.png 7 | P 6CC6DF97 checkbox.png 8 | P FB94CCF2 clip_num.png 9 | P F7B6B7D7 clip_selectBox.png 10 | P 755271AE clip_tree_arrow.png 11 | P 859FD34C clip_tree_folder.png 12 | P A0E3B8F9 combobox.png 13 | P 9EDA959E hscroll$bar.png 14 | P 1AB768D4 hscroll$down.png 15 | P 685261D3 hscroll$up.png 16 | P 274B8076 hscroll.png 17 | P E466EB1C hslider$bar.png 18 | P C4BECA54 hslider.png 19 | P 5EDC128C html.png 20 | P ACFFCCCF image.png 21 | P 5EDC128C label.png 22 | P 5EDC128C linkbutton.png 23 | P 9E4DD730 progress$bar.png 24 | P 3FD78E12 progress.png 25 | P BF898D6A radio.png 26 | P BF898D6A radiogroup.png 27 | P 8CFD9D35 tab.png 28 | P BDA71F88 textarea.png 29 | P BDA71F88 textinput.png 30 | P 52107B89 vscroll$bar.png 31 | P E26B933E vscroll$down.png 32 | P B9680947 vscroll$up.png 33 | P 7E990267 vscroll.png 34 | P E466EB1C vslider$bar.png 35 | P 2BFF7046 vslider.png 36 | -------------------------------------------------------------------------------- /laya/pages/DemoPage.ui: -------------------------------------------------------------------------------- 1 | { 2 | "x":0, 3 | "type":"View", 4 | "selectedBox":1, 5 | "selecteID":3, 6 | "props":{"width":750,"sceneColor":"#000000","height":1334}, 7 | "nodeParent":-1, 8 | "label":"View", 9 | "isOpen":true, 10 | "isDirectory":true, 11 | "isAniNode":true, 12 | "hasChild":true, 13 | "compId":1, 14 | "child":[ 15 | { 16 | "x":15, 17 | "type":"Rect", 18 | "props":{"y":426,"x":226,"width":300,"rotation":30,"pivotY":1,"pivotX":1,"lineWidth":1,"height":300,"fillColor":"#ff0000"}, 19 | "nodeParent":1, 20 | "label":"Rect", 21 | "isDirectory":false, 22 | "isAniNode":true, 23 | "hasChild":false, 24 | "compId":3, 25 | "child":[ 26 | ] 27 | }], 28 | "animations":[ 29 | { 30 | "nodes":[ 31 | ], 32 | "name":"ani1", 33 | "id":1, 34 | "frameRate":24, 35 | "action":0 36 | }] 37 | } -------------------------------------------------------------------------------- /laya/.laya: -------------------------------------------------------------------------------- 1 | 2 | img,temp,sound 3 | embed 4 | png,jpg 5 | bin/res/atlas 6 | bin 7 | src/ui 8 | 9 | 11 | 0 12 | bin/ui.json 13 | Box,List,Tab,RadioGroup,ViewStack,Panel,HBox,VBox,Tree,Sprite 14 | View,Dialog 15 | 16 | 1 17 | 18 | 80 19 | 20 | 21 | 23 | 2048 24 | 2048 25 | 512 26 | 512 27 | false 28 | false 29 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "laya-webpack-typescript", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js", 8 | "start": "npm run dev", 9 | "build": "node build/build.js" 10 | }, 11 | "keywords": [], 12 | "author": "", 13 | "license": "ISC", 14 | "dependencies": {}, 15 | "devDependencies": { 16 | "babel-core": "^6.26.0", 17 | "babel-loader": "^7.1.4", 18 | "babel-plugin-transform-runtime": "^6.23.0", 19 | "babel-preset-env": "^1.6.1", 20 | "babel-preset-stage-2": "^6.24.1", 21 | "chalk": "^2.3.2", 22 | "clean-webpack-plugin": "^0.1.19", 23 | "copy-webpack-plugin": "^4.5.1", 24 | "friendly-errors-webpack-plugin": "^1.7.0", 25 | "html-webpack-plugin": "^3.2.0", 26 | "node-notifier": "^5.2.1", 27 | "portfinder": "^1.0.13", 28 | "ts-loader": "^3.5.0", 29 | "tslint": "^5.9.1", 30 | "tslint-config-standard": "^7.0.0", 31 | "tslint-loader": "^3.6.0", 32 | "typescript": "^2.8.1", 33 | "webpack": "^3.6.0", 34 | "webpack-dev-server": "^2.9.1", 35 | "webpack-merge": "^4.1.2" 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /bin/libs/min/laya.d3Plugin.min.js: -------------------------------------------------------------------------------- 1 | !function(t,i,e){e.un,e.uns,e.static;var r=e.class,n=e.getset,a=(e.__newvec,laya.d3.component.Component3D);laya.d3.core.MeshTerrainSprite3D,laya.d3.core.Sprite3D,function(t){function i(){this._meshTerrainSprite3D=null,this._finder=null,this._setting=null,this.grid=null,i.__super.call(this)}r(i,"laya.d3.component.PathFind",t);var e=i.prototype;e._load=function(i){if(!(i instanceof laya.d3.core.MeshTerrainSprite3D))throw new Error("PathFinding: The owner must MeshTerrainSprite3D!");t.prototype._load.call(this,i),this._meshTerrainSprite3D=i},e.findPath=function(t,i,e,r){var n=this._meshTerrainSprite3D.minX,a=this._meshTerrainSprite3D.minZ,h=this._meshTerrainSprite3D.width/this.grid.width,s=this._meshTerrainSprite3D.depth/this.grid.height,o=h/2,d=s/2,l=Math.floor((t-n)/h),f=Math.floor((i-a)/s),c=Math.floor((e-n)/h),u=Math.floor((r-a)/s),p=this.grid.width-1,_=this.grid.height-1;l>p&&(l=p),f>_&&(f=_),l<0&&(l=0),f<0&&(f=0),c>p&&(c=p),u>_&&(u=_),c<0&&(c=0),u<0&&(u=0);var g=this._finder.findPath(l,f,c,u,this.grid);this.grid.reset();for(var m=1;m1&&(g[0][0]=t,g[0][1]=i,g[g.length-1][0]=e,g[g.length-1][1]=r),g},n(0,e,"setting",function(){return this._setting},function(t){t&&(this._finder=new PathFinding.finders.AStarFinder(t)),this._setting=t})}(a)}(window,document,Laya),"function"==typeof define&&define.amd&&define("laya.core",["require","exports"],function(t,i){"use strict";Object.defineProperty(i,"__esModule",{value:!0});for(var e in Laya){var r=Laya[e];r&&r.__isclass&&(i[e]=r)}}); -------------------------------------------------------------------------------- /config/index.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | // Template version: 1.3.1 3 | // see http://vuejs-templates.github.io/webpack for documentation. 4 | 5 | const path = require('path') 6 | 7 | module.exports = { 8 | dev: { 9 | 10 | // Paths 11 | assetsSubDirectory: 'static', 12 | assetsPublicPath: '/', 13 | proxyTable: {}, 14 | 15 | // Various Dev Server settings 16 | host: 'localhost', // can be overwritten by process.env.HOST 17 | port: 8090, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined 18 | autoOpenBrowser: true, 19 | errorOverlay: true, 20 | notifyOnErrors: true, 21 | poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions- 22 | 23 | 24 | /** 25 | * Source Maps 26 | */ 27 | 28 | // https://webpack.js.org/configuration/devtool/#development 29 | devtool: 'cheap-module-eval-source-map', 30 | 31 | // If you have problems debugging vue-files in devtools, 32 | // set this to false - it *may* help 33 | // https://vue-loader.vuejs.org/en/options.html#cachebusting 34 | cacheBusting: true, 35 | 36 | cssSourceMap: true 37 | }, 38 | 39 | build: { 40 | // Template for index.html 41 | index: path.resolve(__dirname, '../dist/index.html'), 42 | 43 | // Paths 44 | assetsRoot: path.resolve(__dirname, '../dist'), 45 | assetsSubDirectory: 'static', 46 | assetsPublicPath: '/', 47 | 48 | /** 49 | * Source Maps 50 | */ 51 | 52 | productionSourceMap: true, 53 | // https://webpack.js.org/configuration/devtool/#production 54 | devtool: '#source-map', 55 | 56 | // Gzip off by default as many popular static hosts such as 57 | // Surge or Netlify already gzip all static assets for you. 58 | // Before setting to `true`, make sure to: 59 | // npm install --save-dev compression-webpack-plugin 60 | productionGzip: false, 61 | productionGzipExtensions: ['js', 'css'], 62 | 63 | // Run the build command with an extra argument to 64 | // View the bundle analyzer report after build finishes: 65 | // `npm run build --report` 66 | // Set to `true` or `false` to always turn it on or off 67 | bundleAnalyzerReport: process.env.npm_config_report 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /bin/libs/laya.d3Plugin.js: -------------------------------------------------------------------------------- 1 | 2 | (function(window,document,Laya){ 3 | var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec; 4 | 5 | var Component3D=laya.d3.component.Component3D,MeshTerrainSprite3D=laya.d3.core.MeshTerrainSprite3D; 6 | var Sprite3D=laya.d3.core.Sprite3D; 7 | /** 8 | *PathFinding 类用于创建寻路。 9 | */ 10 | //class laya.d3.component.PathFind extends laya.d3.component.Component3D 11 | var PathFind=(function(_super){ 12 | function PathFind(){ 13 | /**@private */ 14 | this._meshTerrainSprite3D=null; 15 | /**@private */ 16 | this._finder=null; 17 | /**@private */ 18 | this._setting=null; 19 | /**寻路网格。*/ 20 | this.grid=null; 21 | PathFind.__super.call(this); 22 | } 23 | 24 | __class(PathFind,'laya.d3.component.PathFind',_super); 25 | var __proto=PathFind.prototype; 26 | /** 27 | *@private 28 | *初始化载入蒙皮动画组件。 29 | *@param owner 所属精灵对象。 30 | */ 31 | __proto._load=function(owner){ 32 | if (! (owner instanceof laya.d3.core.MeshTerrainSprite3D )) 33 | throw new Error("PathFinding: The owner must MeshTerrainSprite3D!"); 34 | _super.prototype._load.call(this,owner); 35 | this._meshTerrainSprite3D=owner; 36 | } 37 | 38 | /** 39 | *寻找路径。 40 | *@param startX 开始X。 41 | *@param startZ 开始Z。 42 | *@param endX 结束X。 43 | *@param endZ 结束Z。 44 | *@return 路径。 45 | */ 46 | __proto.findPath=function(startX,startZ,endX,endZ){ 47 | var minX=this._meshTerrainSprite3D.minX; 48 | var minZ=this._meshTerrainSprite3D.minZ; 49 | var cellX=this._meshTerrainSprite3D.width / this.grid.width; 50 | var cellZ=this._meshTerrainSprite3D.depth / this.grid.height; 51 | var halfCellX=cellX / 2; 52 | var halfCellZ=cellZ / 2; 53 | var gridStartX=Math.floor((startX-minX)/ cellX); 54 | var gridStartZ=Math.floor((startZ-minZ)/ cellZ); 55 | var gridEndX=Math.floor((endX-minX)/ cellX); 56 | var gridEndZ=Math.floor((endZ-minZ)/ cellZ); 57 | var boundWidth=this.grid.width-1; 58 | var boundHeight=this.grid.height-1; 59 | (gridStartX > boundWidth)&& (gridStartX=boundWidth); 60 | (gridStartZ > boundHeight)&& (gridStartZ=boundHeight); 61 | (gridStartX < 0)&& (gridStartX=0); 62 | (gridStartZ < 0)&& (gridStartZ=0); 63 | (gridEndX > boundWidth)&& (gridEndX=boundWidth); 64 | (gridEndZ > boundHeight)&& (gridEndZ=boundHeight); 65 | (gridEndX < 0)&& (gridEndX=0); 66 | (gridEndZ < 0)&& (gridEndZ=0); 67 | var path=this._finder.findPath(gridStartX,gridStartZ,gridEndX,gridEndZ,this.grid); 68 | this.grid.reset(); 69 | for (var i=1;i < path.length-1;i++){ 70 | var gridPos=path[i]; 71 | gridPos[0]=gridPos[0] *cellX+halfCellX+minX; 72 | gridPos[1]=gridPos[1] *cellZ+halfCellZ+minZ; 73 | } 74 | if (path.length==1){ 75 | path[0][0]=endX; 76 | path[0][1]=endX; 77 | }else if (path.length > 1){ 78 | path[0][0]=startX; 79 | path[0][1]=startZ; 80 | path[path.length-1][0]=endX; 81 | path[path.length-1][1]=endZ; 82 | } 83 | return path; 84 | } 85 | 86 | /** 87 | *设置寻路设置。 88 | *@param value 寻路设置。 89 | */ 90 | /** 91 | *获取寻路设置。 92 | *@return 寻路设置。 93 | */ 94 | __getset(0,__proto,'setting',function(){ 95 | return this._setting; 96 | },function(value){ 97 | (value)&& (this._finder=new PathFinding.finders.AStarFinder(value)); 98 | this._setting=value; 99 | }); 100 | 101 | return PathFind; 102 | })(Component3D) 103 | 104 | 105 | 106 | })(window,document,Laya); 107 | 108 | if (typeof define === 'function' && define.amd){ 109 | define('laya.core', ['require', "exports"], function(require, exports) { 110 | 'use strict'; 111 | Object.defineProperty(exports, '__esModule', { value: true }); 112 | for (var i in Laya) { 113 | var o = Laya[i]; 114 | o && o.__isclass && (exports[i] = o); 115 | } 116 | }); 117 | } -------------------------------------------------------------------------------- /bin/res/atlas/comp.atlas: -------------------------------------------------------------------------------- 1 | {"frames":{"bg.png":{"frame":{"h":79,"idx":0,"w":100,"x":151,"y":0},"sourceSize":{"h":79,"w":100},"spriteSourceSize":{"x":0,"y":0}},"blank.png":{"frame":{"h":10,"idx":0,"w":10,"x":344,"y":138},"sourceSize":{"h":10,"w":10},"spriteSourceSize":{"x":0,"y":0}},"btn_close.png":{"frame":{"h":60,"idx":0,"w":28,"x":328,"y":0},"sourceSize":{"h":60,"w":28},"spriteSourceSize":{"x":0,"y":0}},"button.png":{"frame":{"h":69,"idx":0,"w":75,"x":252,"y":0},"sourceSize":{"h":69,"w":75},"spriteSourceSize":{"x":0,"y":0}},"checkbox.png":{"frame":{"h":42,"idx":0,"w":14,"x":364,"y":138},"sourceSize":{"h":42,"w":14},"spriteSourceSize":{"x":0,"y":0}},"clip_num.png":{"frame":{"h":27,"idx":0,"w":240,"x":151,"y":80},"sourceSize":{"h":27,"w":240},"spriteSourceSize":{"x":0,"y":0}},"clip_selectBox.png":{"frame":{"h":40,"idx":0,"w":100,"x":243,"y":108},"sourceSize":{"h":40,"w":100},"spriteSourceSize":{"x":0,"y":0}},"clip_tree_arrow.png":{"frame":{"h":28,"idx":0,"w":14,"x":379,"y":224},"sourceSize":{"h":28,"w":14},"spriteSourceSize":{"x":0,"y":0}},"clip_tree_folder.png":{"frame":{"h":48,"idx":0,"w":16,"x":314,"y":206},"sourceSize":{"h":48,"w":16},"spriteSourceSize":{"x":0,"y":0}},"combobox.png":{"frame":{"h":69,"idx":0,"w":91,"x":151,"y":108},"sourceSize":{"h":69,"w":91},"spriteSourceSize":{"x":0,"y":0}},"hscroll$bar.png":{"frame":{"h":51,"idx":0,"w":21,"x":375,"y":0},"sourceSize":{"h":51,"w":21},"spriteSourceSize":{"x":0,"y":0}},"hscroll$down.png":{"frame":{"h":51,"idx":0,"w":17,"x":343,"y":187},"sourceSize":{"h":51,"w":17},"spriteSourceSize":{"x":0,"y":0}},"hscroll$up.png":{"frame":{"h":51,"idx":0,"w":17,"x":392,"y":52},"sourceSize":{"h":51,"w":17},"spriteSourceSize":{"x":0,"y":0}},"hscroll.png":{"frame":{"h":17,"idx":0,"w":33,"x":331,"y":239},"sourceSize":{"h":17,"w":33},"spriteSourceSize":{"x":0,"y":0}},"hslider$bar.png":{"frame":{"h":42,"idx":0,"w":14,"x":395,"y":104},"sourceSize":{"h":42,"w":14},"spriteSourceSize":{"x":0,"y":0}},"hslider.png":{"frame":{"h":6,"idx":0,"w":100,"x":252,"y":70},"sourceSize":{"h":6,"w":100},"spriteSourceSize":{"x":0,"y":0}},"html.png":{"frame":{"h":18,"idx":0,"w":120,"x":243,"y":149},"sourceSize":{"h":18,"w":120},"spriteSourceSize":{"x":0,"y":0}},"image.png":{"frame":{"h":250,"idx":0,"w":150,"x":0,"y":0},"sourceSize":{"h":250,"w":150},"spriteSourceSize":{"x":0,"y":0}},"label.png":{"frame":{"h":18,"idx":0,"w":120,"x":222,"y":187},"sourceSize":{"h":18,"w":120},"spriteSourceSize":{"x":0,"y":0}},"linkbutton.png":{"frame":{"h":18,"idx":0,"w":120,"x":243,"y":168},"sourceSize":{"h":18,"w":120},"spriteSourceSize":{"x":0,"y":0}},"progress$bar.png":{"frame":{"h":14,"idx":0,"w":50,"x":344,"y":108},"sourceSize":{"h":14,"w":50},"spriteSourceSize":{"x":0,"y":0}},"progress.png":{"frame":{"h":14,"idx":0,"w":50,"x":344,"y":123},"sourceSize":{"h":14,"w":50},"spriteSourceSize":{"x":0,"y":0}},"radio.png":{"frame":{"h":42,"idx":0,"w":14,"x":379,"y":181},"sourceSize":{"h":42,"w":14},"spriteSourceSize":{"x":0,"y":0}},"radiogroup.png":{"frame":{"h":42,"idx":0,"w":14,"x":379,"y":138},"sourceSize":{"h":42,"w":14},"spriteSourceSize":{"x":0,"y":0}},"tab.png":{"frame":{"h":78,"idx":0,"w":70,"x":151,"y":178},"sourceSize":{"h":78,"w":70},"spriteSourceSize":{"x":0,"y":0}},"textarea.png":{"frame":{"h":23,"idx":0,"w":91,"x":222,"y":206},"sourceSize":{"h":23,"w":91},"spriteSourceSize":{"x":0,"y":0}},"textinput.png":{"frame":{"h":23,"idx":0,"w":91,"x":222,"y":230},"sourceSize":{"h":23,"w":91},"spriteSourceSize":{"x":0,"y":0}},"vscroll$bar.png":{"frame":{"h":63,"idx":0,"w":17,"x":357,"y":0},"sourceSize":{"h":63,"w":17},"spriteSourceSize":{"x":0,"y":0}},"vscroll$down.png":{"frame":{"h":51,"idx":0,"w":17,"x":397,"y":0},"sourceSize":{"h":51,"w":17},"spriteSourceSize":{"x":0,"y":0}},"vscroll$up.png":{"frame":{"h":51,"idx":0,"w":17,"x":361,"y":187},"sourceSize":{"h":51,"w":17},"spriteSourceSize":{"x":0,"y":0}},"vscroll.png":{"frame":{"h":33,"idx":0,"w":17,"x":394,"y":190},"sourceSize":{"h":33,"w":17},"spriteSourceSize":{"x":0,"y":0}},"vslider$bar.png":{"frame":{"h":42,"idx":0,"w":14,"x":394,"y":147},"sourceSize":{"h":42,"w":14},"spriteSourceSize":{"x":0,"y":0}},"vslider.png":{"frame":{"h":100,"idx":0,"w":6,"x":410,"y":52},"sourceSize":{"h":100,"w":6},"spriteSourceSize":{"x":0,"y":0}}},"meta":{"image":"comp.png","prefix":"comp/"}} -------------------------------------------------------------------------------- /bin/libs/min/laya.filter.min.js: -------------------------------------------------------------------------------- 1 | !function(t,e,i){i.un,i.uns,i.static;var a=i.class,r=i.getset,n=(i.__newvec,laya.utils.Browser,laya.utils.Color),s=laya.filters.ColorFilterAction,l=laya.filters.webgl.ColorFilterActionGL,o=laya.filters.Filter,u=laya.filters.webgl.FilterActionGL,c=laya.maths.Matrix,h=(laya.maths.Rectangle,laya.renders.Render),f=(laya.renders.RenderContext,laya.webgl.resource.RenderTarget2D),_=laya.utils.RunDriver,d=(laya.webgl.shader.d2.ShaderDefines2D,laya.display.Sprite,laya.resource.Texture,laya.webgl.shader.d2.value.Value2D),g=function(){function t(){this.data=null}a(t,"laya.filters.FilterAction");var e=t.prototype;return i.imps(e,{"laya.filters.IFilterAction":!0}),e.apply=function(t){return null},t}(),y=function(){function t(){}return a(t,"laya.filters.WebGLFilter"),t.enable=function(){t.isInit||(t.isInit=!0,h.isWebGL&&(_.createFilterAction=function(t){var e;switch(t){case 32:e=new l;break;case 16:e=new p;break;case 8:e=new w}return e}))},t.isInit=!1,t.__init$=function(){_.createFilterAction=function(t){var e;switch(t){case 16:case 8:e=new g;break;case 32:e=new s}return e}},t}(),p=(function(t){function e(t){this.strength=NaN,this.strength_sig2_2sig2_gauss1=[],e.__super.call(this),void 0===t&&(t=4),h.isWebGL&&y.enable(),this.strength=t,this._action=_.createFilterAction(16),this._action.data=this}a(e,"laya.filters.BlurFilter",o);var i=e.prototype;i.callNative=function(t){t.conchModel&&t.conchModel.blurFilter&&t.conchModel.blurFilter(this.strength)},r(0,i,"action",function(){return this._action}),r(0,i,"type",function(){return 16})}(),function(t){function e(t,i,a,r){this._color=null,e.__super.call(this),this._elements=new Float32Array(9),void 0===i&&(i=4),void 0===a&&(a=6),void 0===r&&(r=6),h.isWebGL&&y.enable(),this._color=new n(t),this.blur=Math.min(i,20),this.offX=a,this.offY=r,this._action=_.createFilterAction(8),this._action.data=this}a(e,"laya.filters.GlowFilter",o);var i=e.prototype;i.getColor=function(){return this._color._color},i.callNative=function(t){t.conchModel&&t.conchModel.glowFilter&&t.conchModel.glowFilter(this._color.strColor,this._elements[4],this._elements[5],this._elements[6])},r(0,i,"type",function(){return 8}),r(0,i,"action",function(){return this._action}),r(0,i,"offY",function(){return this._elements[6]},function(t){this._elements[6]=t}),r(0,i,"offX",function(){return this._elements[5]},function(t){this._elements[5]=t}),r(0,i,"blur",function(){return this._elements[4]},function(t){this._elements[4]=t})}(),function(t){function e(){this.data=null,e.__super.call(this)}a(e,"laya.filters.webgl.BlurFilterActionGL",u);var i=e.prototype;return i.setValueMix=function(t){t.defines.add(this.data.type)},i.apply3d=function(t,e,i,a,r){var n=t.getValue("bounds"),s=d.create(1,0);s.setFilters([this.data]);c.EMPTY.identity(),i.ctx.drawTarget(t,0,0,n.width,n.height,c.EMPTY,"src",s),s.setFilters(null)},i.setValue=function(t){t.strength=this.data.strength;var e=this.data.strength/3,i=e*e;this.data.strength_sig2_2sig2_gauss1[0]=this.data.strength,this.data.strength_sig2_2sig2_gauss1[1]=i,this.data.strength_sig2_2sig2_gauss1[2]=2*i,this.data.strength_sig2_2sig2_gauss1[3]=1/(2*Math.PI*i),t.strength_sig2_2sig2_gauss1=this.data.strength_sig2_2sig2_gauss1},r(0,i,"typeMix",function(){return 16}),e}()),w=function(t){function e(){this.data=null,this._initKey=!1,this._textureWidth=0,this._textureHeight=0,e.__super.call(this)}a(e,"laya.filters.webgl.GlowFilterActionGL",u);var n=e.prototype;return i.imps(n,{"laya.filters.IFilterActionGL":!0}),n.setValueMix=function(t){},n.apply3d=function(t,e,i,a,r){var n=t.getValue("bounds");t.addValue("color",this.data.getColor());var s=n.width,l=n.height;this._textureWidth=s,this._textureHeight=l;var o,u=c.TEMP;return u.identity(),(o=d.create(1,0)).setFilters([this.data]),i.ctx.drawTarget(t,0,0,this._textureWidth,this._textureHeight,u,"src",o,null),o=d.create(1,0),i.ctx.drawTarget(t,0,0,this._textureWidth,this._textureHeight,u,"src",o),null},n.setSpriteWH=function(t){this._textureWidth=t.width,this._textureHeight=t.height},n.setValue=function(t){t.u_offsetX=this.data.offX,t.u_offsetY=-this.data.offY,t.u_strength=1,t.u_blurX=this.data.blur,t.u_blurY=this.data.blur,t.u_textW=this._textureWidth,t.u_textH=this._textureHeight,t.u_color=this.data.getColor()},r(0,n,"typeMix",function(){return 8}),e.tmpTarget=function(t,e,i,a,r){var n=t.getValue("bounds");t.getValue("out").end();var s=f.create(n.width,n.height);s.start();var l=t.getValue("color");l&&s.clear(l[0],l[1],l[2],0),t.addValue("tmpTarget",s)},e.startOut=function(t,e,i,a,r){t.getValue("tmpTarget").end();var n=t.getValue("out");n.start();var s=t.getValue("color");s&&n.clear(s[0],s[1],s[2],0)},e.recycleTarget=function(t,e,i,a,r){t.getValue("src");t.getValue("tmpTarget").recycle()},e}();i.__init([y])}(window,document,Laya),"function"==typeof define&&define.amd&&define("laya.core",["require","exports"],function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});for(var i in Laya){var a=Laya[i];a&&a.__isclass&&(e[i]=a)}}); -------------------------------------------------------------------------------- /bin/libs/matter-RenderLaya.js: -------------------------------------------------------------------------------- 1 | var Browser = laya.utils.Browser; 2 | 3 | var Composite = Matter.Composite; 4 | var Events = Matter.Events; 5 | var Bounds = Matter.Bounds; 6 | var Common = Matter.Common; 7 | var Vertices = Matter.Vertices; 8 | var Vector = Matter.Vector; 9 | var Sleeping = Matter.Sleeping; 10 | var Axes = Matter.Axes; 11 | var Body = Matter.Body; 12 | var SAT = Matter.SAT; 13 | var Contact = Matter.Contact; 14 | var Pair = Matter.Pair; 15 | var Detector = Matter.Detector; 16 | var Grid = Matter.Grid; 17 | 18 | var LayaRender = {}; 19 | 20 | (function() 21 | { 22 | var graphics, 23 | spriteCon, 24 | graphicsCon; 25 | 26 | LayaRender.create = function(options) 27 | { 28 | var defaults = { 29 | controller: LayaRender, 30 | element: null, 31 | canvas: null, 32 | mouse: null, 33 | options: 34 | { 35 | width: 800, 36 | height: 600, 37 | pixelRatio: 1, 38 | background: '#fafafa', 39 | wireframeBackground: '#222', 40 | hasBounds: !!options.bounds, 41 | enabled: true, 42 | wireframes: true, 43 | showSleeping: true, 44 | showDebug: false, 45 | showBroadphase: false, 46 | showBounds: false, 47 | showVelocity: false, 48 | showCollisions: false, 49 | showSeparations: false, 50 | showAxes: false, 51 | showPositions: false, 52 | showAngleIndicator: false, 53 | showIds: false, 54 | showShadows: false, 55 | showVertexNumbers: false, 56 | showConvexHulls: false, 57 | showInternalEdges: false, 58 | showMousePosition: false 59 | } 60 | }; 61 | 62 | var render = Common.extend(defaults, options); 63 | 64 | render.canvas = laya.renders.Render.canvas; 65 | render.context = laya.renders.Render.context.ctx; 66 | 67 | render.textures = {}; 68 | 69 | render.bounds = render.bounds || 70 | { 71 | min: 72 | { 73 | x: 0, 74 | y: 0 75 | }, 76 | max: 77 | { 78 | x: Laya.stage.width, 79 | y: Laya.stage.height 80 | } 81 | }; 82 | 83 | createContainer(render); 84 | setBackground(render); 85 | setPixelRatio(); 86 | 87 | return render; 88 | }; 89 | 90 | function createContainer(render) 91 | { 92 | var con = render.container; 93 | 94 | spriteCon = new Laya.Sprite(); 95 | graphicsCon = new Laya.Sprite(); 96 | 97 | render.spriteContainer = spriteCon; 98 | render.graphicsContainer = graphicsCon; 99 | 100 | con.addChild(spriteCon); 101 | con.addChild(graphicsCon); 102 | 103 | graphics = graphicsCon.graphics; 104 | } 105 | 106 | // 设置背景 107 | function setBackground(render) 108 | { 109 | var bg = render.options.background; 110 | // 纯色背景 111 | if (bg.length == 7 && bg[0] == '#') 112 | { 113 | spriteCon.graphics.drawRect( 114 | 0, 0, 115 | render.options.width, render.options.height, 116 | bg); 117 | } 118 | // 图片背景 119 | else 120 | { 121 | spriteCon.loadImage(bg); 122 | } 123 | } 124 | 125 | function setPixelRatio() 126 | { 127 | var pixelRatio; 128 | pixelRatio = 1; 129 | Laya.Render.canvas.setAttribute('data-pixel-ratio', pixelRatio); 130 | } 131 | 132 | /** 133 | * Renders the given `engine`'s `Matter.World` object. 134 | * This is the entry point for all rendering and should be called every time the scene changes. 135 | * @method world 136 | * @param {engine} engine 137 | */ 138 | LayaRender.world = function(engine) 139 | { 140 | var render = engine.render, 141 | world = engine.world, 142 | options = render.options, 143 | allConstraints = Composite.allConstraints(world), 144 | bodies = Composite.allBodies(world), 145 | constraints = [], 146 | i; 147 | 148 | // handle bounds 149 | if (options.hasBounds) 150 | { 151 | var boundsWidth = render.bounds.max.x - render.bounds.min.x, 152 | boundsHeight = render.bounds.max.y - render.bounds.min.y, 153 | boundsScaleX = boundsWidth / options.width, 154 | boundsScaleY = boundsHeight / options.height; 155 | 156 | // filter out bodies that are not in view 157 | for (i = 0; i < bodies.length; i++) 158 | { 159 | var body = bodies[i]; 160 | body.render.sprite.visible = Bounds.overlaps(body.bounds, render.bounds); 161 | } 162 | 163 | // filter out constraints that are not in view 164 | for (i = 0; i < allConstraints.length; i++) 165 | { 166 | var constraint = allConstraints[i], 167 | bodyA = constraint.bodyA, 168 | bodyB = constraint.bodyB, 169 | pointAWorld = constraint.pointA, 170 | pointBWorld = constraint.pointB; 171 | 172 | if (bodyA) pointAWorld = Vector.add(bodyA.position, constraint.pointA); 173 | if (bodyB) pointBWorld = Vector.add(bodyB.position, constraint.pointB); 174 | 175 | if (!pointAWorld || !pointBWorld) 176 | continue; 177 | 178 | if (Bounds.contains(render.bounds, pointAWorld) || Bounds.contains(render.bounds, pointBWorld)) 179 | constraints.push(constraint); 180 | } 181 | 182 | // transform the view 183 | // context.scale(1 / boundsScaleX, 1 / boundsScaleY); 184 | // context.translate(-render.bounds.min.x, -render.bounds.min.y); 185 | } 186 | else 187 | { 188 | constraints = allConstraints; 189 | } 190 | 191 | graphics.clear(); 192 | for (i = 0; i < bodies.length; i++) 193 | LayaRender.body(engine, bodies[i]); 194 | 195 | for (i = 0; i < constraints.length; i++) 196 | LayaRender.constraint(engine, constraints[i]); 197 | }; 198 | LayaRender.body = function(engine, body) 199 | { 200 | var render = engine.render, 201 | bodyRender = body.render; 202 | 203 | if (!bodyRender.visible) 204 | { 205 | return; 206 | } 207 | 208 | var spInfo = bodyRender.sprite; 209 | var sp = body.sprite; 210 | if (bodyRender.sprite && bodyRender.sprite.texture) 211 | { 212 | // initialize body sprite if not existing 213 | if (!sp) 214 | { 215 | sp = body.sprite = createBodySprite(spInfo.xOffset, spInfo.yOffset); 216 | sp.loadImage(spInfo.texture); 217 | } 218 | 219 | sp.scale(spInfo.xScale, spInfo.yScale); 220 | sp.pos(body.position.x, body.position.y); 221 | sp.rotation = body.angle * 180 / Math.PI; 222 | } 223 | else 224 | { 225 | var options = render.options; 226 | // handle compound parts 227 | for (k = body.parts.length > 1 ? 1 : 0; k < body.parts.length; k++) 228 | { 229 | part = body.parts[k]; 230 | 231 | if (!part.render.visible) 232 | continue; 233 | 234 | var fillStyle = options.wireframes ? null : part.render.fillStyle; 235 | var lineWidth = part.render.lineWidth; 236 | var strokeStyle = part.render.strokeStyle; 237 | // part polygon 238 | if (part.circleRadius) 239 | { 240 | graphics.drawCircle(part.position.x, part.position.y, part.circleRadius, fillStyle, strokeStyle, lineWidth); 241 | } 242 | else 243 | { 244 | var path = []; 245 | path.push(part.vertices[0].x, part.vertices[0].y); 246 | 247 | for (var j = 1; j < part.vertices.length; j++) 248 | { 249 | if (!part.vertices[j - 1].isInternal || showInternalEdges) 250 | { 251 | path.push(part.vertices[j].x, part.vertices[j].y); 252 | } 253 | else 254 | { 255 | path.push(part.vertices[j].x, part.vertices[j].y); 256 | } 257 | 258 | if (part.vertices[j].isInternal && !showInternalEdges) 259 | { 260 | path.push(part.vertices[(j + 1) % part.vertices.length].x, part.vertices[(j + 1) % part.vertices.length].y); 261 | } 262 | } 263 | 264 | graphics.drawPoly(0, 0, path, fillStyle, strokeStyle, lineWidth); 265 | } 266 | } 267 | } 268 | }; 269 | 270 | LayaRender.constraint = function(engine, constraint) 271 | { 272 | var sx, sy, ex, ey; 273 | if (!constraint.render.visible || !constraint.pointA || !constraint.pointB) 274 | { 275 | return; 276 | } 277 | 278 | var bodyA = constraint.bodyA, 279 | bodyB = constraint.bodyB; 280 | 281 | if (bodyA) 282 | { 283 | sx = bodyA.position.x + constraint.pointA.x; 284 | sy = bodyA.position.y + constraint.pointA.y; 285 | } 286 | else 287 | { 288 | sx = constraint.pointA.x; 289 | sy = constraint.pointA.y; 290 | } 291 | 292 | if (bodyB) 293 | { 294 | ex = bodyB.position.x + constraint.pointB.x; 295 | ey = bodyB.position.y + constraint.pointB.y; 296 | } 297 | else 298 | { 299 | ex = constraint.pointB.x; 300 | ey = constraint.pointB.y; 301 | } 302 | 303 | graphics.drawLine( 304 | sx, sy, ex, ey, 305 | constraint.render.strokeStyle, 306 | constraint.render.lineWidth); 307 | }; 308 | 309 | function createBodySprite(xOffset, yOffset) 310 | { 311 | var sp = new Laya.Sprite(); 312 | 313 | sp.pivot(xOffset, yOffset); 314 | sp.pos(-9999, -9999); 315 | spriteCon.addChild(sp); 316 | 317 | return sp; 318 | } 319 | })(); -------------------------------------------------------------------------------- /bin/libs/laya.filter.js: -------------------------------------------------------------------------------- 1 | 2 | (function(window,document,Laya){ 3 | var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec; 4 | 5 | var Browser=laya.utils.Browser,Color=laya.utils.Color,ColorFilterAction=laya.filters.ColorFilterAction; 6 | var ColorFilterActionGL=laya.filters.webgl.ColorFilterActionGL,Filter=laya.filters.Filter,FilterActionGL=laya.filters.webgl.FilterActionGL; 7 | var Matrix=laya.maths.Matrix,Rectangle=laya.maths.Rectangle,Render=laya.renders.Render,RenderContext=laya.renders.RenderContext; 8 | var RenderTarget2D=laya.webgl.resource.RenderTarget2D,RunDriver=laya.utils.RunDriver,ShaderDefines2D=laya.webgl.shader.d2.ShaderDefines2D; 9 | var Sprite=laya.display.Sprite,Texture=laya.resource.Texture,Value2D=laya.webgl.shader.d2.value.Value2D; 10 | /** 11 | *默认的FILTER,什么都不做 12 | *@private 13 | */ 14 | //class laya.filters.FilterAction 15 | var FilterAction=(function(){ 16 | function FilterAction(){ 17 | this.data=null; 18 | } 19 | 20 | __class(FilterAction,'laya.filters.FilterAction'); 21 | var __proto=FilterAction.prototype; 22 | Laya.imps(__proto,{"laya.filters.IFilterAction":true}) 23 | __proto.apply=function(data){ 24 | return null; 25 | } 26 | 27 | return FilterAction; 28 | })() 29 | 30 | 31 | /** 32 | *@private 33 | */ 34 | //class laya.filters.WebGLFilter 35 | var WebGLFilter=(function(){ 36 | function WebGLFilter(){} 37 | __class(WebGLFilter,'laya.filters.WebGLFilter'); 38 | WebGLFilter.enable=function(){ 39 | if (WebGLFilter.isInit)return; 40 | WebGLFilter.isInit=true; 41 | if (!Render.isWebGL)return; 42 | RunDriver.createFilterAction=function (type){ 43 | var action; 44 | switch (type){ 45 | case /*laya.filters.Filter.COLOR*/0x20: 46 | action=new ColorFilterActionGL(); 47 | break ; 48 | case /*laya.filters.Filter.BLUR*/0x10: 49 | action=new BlurFilterActionGL(); 50 | break ; 51 | case /*laya.filters.Filter.GLOW*/0x08: 52 | action=new GlowFilterActionGL(); 53 | break ; 54 | } 55 | return action; 56 | } 57 | } 58 | 59 | WebGLFilter.isInit=false; 60 | WebGLFilter.__init$=function(){ 61 | BlurFilterActionGL; 62 | ColorFilterActionGL; 63 | GlowFilterActionGL; 64 | Render; 65 | RunDriver;{ 66 | RunDriver.createFilterAction=function (type){ 67 | var action; 68 | switch (type){ 69 | case /*laya.filters.Filter.BLUR*/0x10: 70 | action=new FilterAction(); 71 | break ; 72 | case /*laya.filters.Filter.GLOW*/0x08: 73 | action=new FilterAction(); 74 | break ; 75 | case /*laya.filters.Filter.COLOR*/0x20: 76 | action=new ColorFilterAction(); 77 | break ; 78 | } 79 | return action; 80 | } 81 | } 82 | } 83 | 84 | return WebGLFilter; 85 | })() 86 | 87 | 88 | /** 89 | *模糊滤镜 90 | */ 91 | //class laya.filters.BlurFilter extends laya.filters.Filter 92 | var BlurFilter=(function(_super){ 93 | function BlurFilter(strength){ 94 | /**模糊滤镜的强度(值越大,越不清晰 */ 95 | this.strength=NaN; 96 | this.strength_sig2_2sig2_gauss1=[]; 97 | BlurFilter.__super.call(this); 98 | (strength===void 0)&& (strength=4); 99 | if (Render.isWebGL)WebGLFilter.enable(); 100 | this.strength=strength; 101 | this._action=RunDriver.createFilterAction(0x10); 102 | this._action.data=this; 103 | } 104 | 105 | __class(BlurFilter,'laya.filters.BlurFilter',_super); 106 | var __proto=BlurFilter.prototype; 107 | /** 108 | *@private 通知微端 109 | */ 110 | __proto.callNative=function(sp){ 111 | sp.conchModel &&sp.conchModel.blurFilter&&sp.conchModel.blurFilter(this.strength); 112 | } 113 | 114 | /** 115 | *@private 116 | *当前滤镜对应的操作器 117 | */ 118 | __getset(0,__proto,'action',function(){ 119 | return this._action; 120 | }); 121 | 122 | /** 123 | *@private 124 | *当前滤镜的类型 125 | */ 126 | __getset(0,__proto,'type',function(){ 127 | return 0x10; 128 | }); 129 | 130 | return BlurFilter; 131 | })(Filter) 132 | 133 | 134 | /** 135 | *发光滤镜(也可以当成阴影滤使用) 136 | */ 137 | //class laya.filters.GlowFilter extends laya.filters.Filter 138 | var GlowFilter=(function(_super){ 139 | function GlowFilter(color,blur,offX,offY){ 140 | /**滤镜的颜色*/ 141 | this._color=null; 142 | GlowFilter.__super.call(this); 143 | this._elements=new Float32Array(9); 144 | (blur===void 0)&& (blur=4); 145 | (offX===void 0)&& (offX=6); 146 | (offY===void 0)&& (offY=6); 147 | if (Render.isWebGL){ 148 | WebGLFilter.enable(); 149 | } 150 | this._color=new Color(color); 151 | this.blur=Math.min(blur,20); 152 | this.offX=offX; 153 | this.offY=offY; 154 | this._action=RunDriver.createFilterAction(0x08); 155 | this._action.data=this; 156 | } 157 | 158 | __class(GlowFilter,'laya.filters.GlowFilter',_super); 159 | var __proto=GlowFilter.prototype; 160 | /**@private */ 161 | __proto.getColor=function(){ 162 | return this._color._color; 163 | } 164 | 165 | /** 166 | *@private 通知微端 167 | */ 168 | __proto.callNative=function(sp){ 169 | sp.conchModel &&sp.conchModel.glowFilter&&sp.conchModel.glowFilter(this._color.strColor,this._elements[4],this._elements[5],this._elements[6]); 170 | } 171 | 172 | /** 173 | *@private 174 | *滤镜类型 175 | */ 176 | __getset(0,__proto,'type',function(){ 177 | return 0x08; 178 | }); 179 | 180 | /**@private */ 181 | __getset(0,__proto,'action',function(){ 182 | return this._action; 183 | }); 184 | 185 | /**@private */ 186 | /**@private */ 187 | __getset(0,__proto,'offY',function(){ 188 | return this._elements[6]; 189 | },function(value){ 190 | this._elements[6]=value; 191 | }); 192 | 193 | /**@private */ 194 | /**@private */ 195 | __getset(0,__proto,'offX',function(){ 196 | return this._elements[5]; 197 | },function(value){ 198 | this._elements[5]=value; 199 | }); 200 | 201 | /**@private */ 202 | /**@private */ 203 | __getset(0,__proto,'blur',function(){ 204 | return this._elements[4]; 205 | },function(value){ 206 | this._elements[4]=value; 207 | }); 208 | 209 | return GlowFilter; 210 | })(Filter) 211 | 212 | 213 | /** 214 | *@private 215 | */ 216 | //class laya.filters.webgl.BlurFilterActionGL extends laya.filters.webgl.FilterActionGL 217 | var BlurFilterActionGL=(function(_super){ 218 | function BlurFilterActionGL(){ 219 | this.data=null; 220 | BlurFilterActionGL.__super.call(this); 221 | } 222 | 223 | __class(BlurFilterActionGL,'laya.filters.webgl.BlurFilterActionGL',_super); 224 | var __proto=BlurFilterActionGL.prototype; 225 | __proto.setValueMix=function(shader){ 226 | shader.defines.add(this.data.type); 227 | var o=shader; 228 | } 229 | 230 | __proto.apply3d=function(scope,sprite,context,x,y){ 231 | var b=scope.getValue("bounds"); 232 | var shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0); 233 | shaderValue.setFilters([this.data]); 234 | var tMatrix=Matrix.EMPTY; 235 | tMatrix.identity(); 236 | context.ctx.drawTarget(scope,0,0,b.width,b.height,Matrix.EMPTY,"src",shaderValue); 237 | shaderValue.setFilters(null); 238 | } 239 | 240 | __proto.setValue=function(shader){ 241 | shader.strength=this.data.strength; 242 | var sigma=this.data.strength/3.0; 243 | var sigma2=sigma*sigma; 244 | this.data.strength_sig2_2sig2_gauss1[0]=this.data.strength; 245 | this.data.strength_sig2_2sig2_gauss1[1]=sigma2; 246 | this.data.strength_sig2_2sig2_gauss1[2]=2.0*sigma2; 247 | this.data.strength_sig2_2sig2_gauss1[3]=1.0/(2.0*Math.PI*sigma2); 248 | shader.strength_sig2_2sig2_gauss1=this.data.strength_sig2_2sig2_gauss1; 249 | } 250 | 251 | __getset(0,__proto,'typeMix',function(){return /*laya.filters.Filter.BLUR*/0x10;}); 252 | return BlurFilterActionGL; 253 | })(FilterActionGL) 254 | 255 | 256 | /** 257 | *@private 258 | */ 259 | //class laya.filters.webgl.GlowFilterActionGL extends laya.filters.webgl.FilterActionGL 260 | var GlowFilterActionGL=(function(_super){ 261 | function GlowFilterActionGL(){ 262 | this.data=null; 263 | this._initKey=false; 264 | this._textureWidth=0; 265 | this._textureHeight=0; 266 | GlowFilterActionGL.__super.call(this); 267 | } 268 | 269 | __class(GlowFilterActionGL,'laya.filters.webgl.GlowFilterActionGL',_super); 270 | var __proto=GlowFilterActionGL.prototype; 271 | Laya.imps(__proto,{"laya.filters.IFilterActionGL":true}) 272 | __proto.setValueMix=function(shader){} 273 | __proto.apply3d=function(scope,sprite,context,x,y){ 274 | var b=scope.getValue("bounds"); 275 | scope.addValue("color",this.data.getColor()); 276 | var w=b.width,h=b.height; 277 | this._textureWidth=w; 278 | this._textureHeight=h; 279 | var shaderValue; 280 | var mat=Matrix.TEMP; 281 | mat.identity(); 282 | shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0); 283 | shaderValue.setFilters([this.data]); 284 | context.ctx.drawTarget(scope,0,0,this._textureWidth,this._textureHeight,mat,"src",shaderValue,null); 285 | shaderValue=Value2D.create(/*laya.webgl.shader.d2.ShaderDefines2D.TEXTURE2D*/0x01,0); 286 | context.ctx.drawTarget(scope,0,0,this._textureWidth,this._textureHeight,mat,"src",shaderValue); 287 | return null; 288 | } 289 | 290 | __proto.setSpriteWH=function(sprite){ 291 | this._textureWidth=sprite.width; 292 | this._textureHeight=sprite.height; 293 | } 294 | 295 | __proto.setValue=function(shader){ 296 | shader.u_offsetX=this.data.offX; 297 | shader.u_offsetY=-this.data.offY; 298 | shader.u_strength=1.0; 299 | shader.u_blurX=this.data.blur; 300 | shader.u_blurY=this.data.blur; 301 | shader.u_textW=this._textureWidth; 302 | shader.u_textH=this._textureHeight; 303 | shader.u_color=this.data.getColor(); 304 | } 305 | 306 | __getset(0,__proto,'typeMix',function(){return /*laya.filters.Filter.GLOW*/0x08;}); 307 | GlowFilterActionGL.tmpTarget=function(scope,sprite,context,x,y){ 308 | var b=scope.getValue("bounds"); 309 | var out=scope.getValue("out"); 310 | out.end(); 311 | var tmpTarget=RenderTarget2D.create(b.width,b.height); 312 | tmpTarget.start(); 313 | var color=scope.getValue("color"); 314 | if (color){ 315 | tmpTarget.clear(color[0],color[1],color[2],0); 316 | } 317 | scope.addValue("tmpTarget",tmpTarget); 318 | } 319 | 320 | GlowFilterActionGL.startOut=function(scope,sprite,context,x,y){ 321 | var tmpTarget=scope.getValue("tmpTarget"); 322 | tmpTarget.end(); 323 | var out=scope.getValue("out"); 324 | out.start(); 325 | var color=scope.getValue("color"); 326 | if (color){ 327 | out.clear(color[0],color[1],color[2],0); 328 | } 329 | } 330 | 331 | GlowFilterActionGL.recycleTarget=function(scope,sprite,context,x,y){ 332 | var src=scope.getValue("src"); 333 | var tmpTarget=scope.getValue("tmpTarget"); 334 | tmpTarget.recycle(); 335 | } 336 | 337 | return GlowFilterActionGL; 338 | })(FilterActionGL) 339 | 340 | 341 | Laya.__init([WebGLFilter]); 342 | })(window,document,Laya); 343 | 344 | if (typeof define === 'function' && define.amd){ 345 | define('laya.core', ['require', "exports"], function(require, exports) { 346 | 'use strict'; 347 | Object.defineProperty(exports, '__esModule', { value: true }); 348 | for (var i in Laya) { 349 | var o = Laya[i]; 350 | o && o.__isclass && (exports[i] = o); 351 | } 352 | }); 353 | } -------------------------------------------------------------------------------- /bin/libs/LayaRender.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Matter.js 渲染器在 LayaAir 的实现。 3 | */ 4 | (function() 5 | { 6 | var LayaRender = {}; 7 | 8 | var Common = Matter.Common; 9 | var Composite = Matter.Composite; 10 | var Bounds = Matter.Bounds; 11 | var Events = Matter.Events; 12 | var Grid = Matter.Grid; 13 | var Vector = Matter.Vector; 14 | 15 | /** 16 | * 创建新的渲染器。 17 | * @param {object} options 所有属性都有默认值,options中的属性会覆盖默认属性。 18 | * @return {render} 返回创建的旋绕器 19 | */ 20 | LayaRender.create = function(options) 21 | { 22 | var defaults = { 23 | controller: LayaRender, 24 | engine: null, 25 | element: null, 26 | canvas: null, 27 | mouse: null, 28 | frameRequestId: null, 29 | options: 30 | { 31 | width: 800, 32 | height: 600, 33 | pixelRatio: 1, 34 | background: '#fafafa', 35 | wireframeBackground: '#222222', 36 | hasBounds: !!options.bounds, 37 | enabled: true, 38 | wireframes: true, 39 | showSleeping: true, 40 | showDebug: false, 41 | showBroadphase: false, 42 | showBounds: false, 43 | showVelocity: false, 44 | showCollisions: false, 45 | showSeparations: false, 46 | showAxes: false, 47 | showPositions: false, 48 | showAngleIndicator: false, 49 | showIds: false, 50 | showShadows: false, 51 | showVertexNumbers: false, 52 | showConvexHulls: false, 53 | showInternalEdges: false, 54 | showMousePosition: false 55 | } 56 | }; 57 | var render = Common.extend(defaults, options); 58 | render.mouse = options.mouse; 59 | render.engine = options.engine; 60 | // 如果用户没有指定contaienr,默认使用stage 61 | render.container = render.container || Laya.stage; 62 | render.bounds = render.bounds || 63 | { 64 | min: 65 | { 66 | x: 0, 67 | y: 0 68 | }, 69 | max: 70 | { 71 | x: render.width, 72 | y: render.height 73 | } 74 | }; 75 | 76 | return render; 77 | } 78 | 79 | /** 80 | * 运行渲染器。 81 | * @param {render} render 渲染的目标是LayaRender.create()返回的对象 82 | * @return {void} 83 | */ 84 | LayaRender.run = function(render) 85 | { 86 | Laya.timer.frameLoop(1, this, LayaRender.world, [render]); 87 | Events.on(render.engine.world, 'afterRemove', LayaRender.onRemoveSprite); 88 | }; 89 | 90 | /** 91 | * 停止渲染器。 92 | * @param {render} LayaRender.create()返回的对象 93 | * @return {void} 94 | */ 95 | LayaRender.stop = function(render) 96 | { 97 | Laya.timer.clear(this, LayaRender.world); 98 | Events.off(render.engine.world, 'afterRemove', LayaRender.onRemoveSprite); 99 | } 100 | 101 | LayaRender.onRemoveSprite = function(args) 102 | { 103 | var sprite = args.object.layaSprite; 104 | if (sprite && sprite.parent) 105 | sprite.parent.removeChild(sprite); 106 | } 107 | 108 | /** 109 | * 渲染给定的 engine 的 Matter.World 对象。 110 | * 这是渲染的入口,每次场景改变时都应该被调用。 111 | * @param {render} render 112 | * @return {void} 113 | */ 114 | LayaRender.world = function(render) 115 | { 116 | var engine = render.engine, 117 | world = engine.world, 118 | renderer = render.renderer, 119 | container = render.container, 120 | options = render.options, 121 | bodies = Composite.allBodies(world), 122 | allConstraints = Composite.allConstraints(world), 123 | constraints = [], 124 | i; 125 | 126 | if (options.wireframes) 127 | { 128 | LayaRender.setBackground(render, options.wireframeBackground); 129 | } 130 | else 131 | { 132 | LayaRender.setBackground(render, options.background); 133 | } 134 | 135 | // 处理 bounds 136 | var boundsWidth = render.bounds.max.x - render.bounds.min.x, 137 | boundsHeight = render.bounds.max.y - render.bounds.min.y, 138 | boundsScaleX = boundsWidth / render.options.width, 139 | boundsScaleY = boundsHeight / render.options.height; 140 | 141 | if (options.hasBounds) 142 | { 143 | // 隐藏不在视口内的bodies 144 | for (i = 0; i < bodies.length; i++) 145 | { 146 | var body = bodies[i]; 147 | body.render.sprite.visible = Bounds.overlaps(body.bounds, render.bounds); 148 | } 149 | 150 | // 过滤掉不在视口内的 constraints 151 | for (i = 0; i < allConstraints.length; i++) 152 | { 153 | var constraint = allConstraints[i], 154 | bodyA = constraint.bodyA, 155 | bodyB = constraint.bodyB, 156 | pointAWorld = constraint.pointA, 157 | pointBWorld = constraint.pointB; 158 | 159 | if (bodyA) pointAWorld = Vector.add(bodyA.position, constraint.pointA); 160 | if (bodyB) pointBWorld = Vector.add(bodyB.position, constraint.pointB); 161 | 162 | if (!pointAWorld || !pointBWorld) 163 | continue; 164 | 165 | if (Bounds.contains(render.bounds, pointAWorld) || Bounds.contains(render.bounds, pointBWorld)) 166 | constraints.push(constraint); 167 | } 168 | 169 | // 改变视口 170 | container.scale(1 / boundsScaleX, 1 / boundsScaleY); 171 | container.pos(-render.bounds.min.x * (1 / boundsScaleX), -render.bounds.min.y * (1 / boundsScaleY)); 172 | } 173 | else 174 | { 175 | constraints = allConstraints; 176 | } 177 | 178 | for (i = 0; i < bodies.length; i++) 179 | LayaRender.body(render, bodies[i]); 180 | 181 | for (i = 0; i < constraints.length; i++) 182 | LayaRender.constraint(render, constraints[i]); 183 | }; 184 | 185 | /** 186 | * 设置背景色或者背景图片。 187 | * @param {render} render 188 | * @param {string} background 16进制颜色字符串或者图片路径 189 | */ 190 | LayaRender.setBackground = function(render, background) 191 | { 192 | if (render.currentBackground !== background) 193 | { 194 | var isColor = background.indexOf && background.indexOf('#') !== -1; 195 | 196 | render.container.graphics.clear(); 197 | 198 | if (isColor) 199 | { 200 | // 使用纯色背景 201 | render.container.bgColor = background; 202 | } 203 | else 204 | { 205 | render.container.loadImage(background); 206 | // 使用背景图片时把背景色设置为白色 207 | render.container.bgColor = "#FFFFFF"; 208 | } 209 | 210 | render.currentBackground = background; 211 | } 212 | } 213 | 214 | /** 215 | * 渲染 body 216 | * @param {render} render 217 | * @param {body} body 218 | * @return {void} 219 | */ 220 | LayaRender.body = function(render, body) 221 | { 222 | var engine = render.engine, 223 | bodyRender = body.render; 224 | 225 | if (!bodyRender.visible) 226 | return; 227 | 228 | // 有纹理的body 229 | if (bodyRender.sprite && bodyRender.sprite.texture) 230 | { 231 | var spriteId = 'b-' + body.id, 232 | sprite = body.layaSprite, 233 | container = render.container; 234 | 235 | // 如果sprite不存在,则初始化一个 236 | if (!sprite) 237 | sprite = body.layaSprite = _createBodySprite(render, body); 238 | 239 | // 如果sprite未在显示列表,则添加至显示列表 240 | if (!container.contains(sprite)) 241 | container.addChild(sprite); 242 | 243 | // 更新sprite位置 244 | sprite.x = body.position.x; 245 | sprite.y = body.position.y; 246 | sprite.rotation = body.angle * 180 / Math.PI; 247 | sprite.scaleX = bodyRender.sprite.xScale || 1; 248 | sprite.scaleY = bodyRender.sprite.yScale || 1; 249 | } 250 | else // 没有纹理的body 251 | { 252 | var primitiveId = 'b-' + body.id, 253 | sprite = body.layaSprite, 254 | container = render.container; 255 | 256 | // 如果sprite不存在,则初始化一个 257 | if (!sprite) 258 | { 259 | sprite = body.layaSprite = _createBodyPrimitive(render, body); 260 | sprite.initialAngle = body.angle; 261 | } 262 | 263 | // 如果sprite未在显示列表,则添加至显示列表 264 | if (!container.contains(sprite)) 265 | container.addChild(sprite); 266 | // 更新sprite位置 267 | sprite.x = body.position.x; 268 | sprite.y = body.position.y; 269 | sprite.rotation = (body.angle - sprite.initialAngle) * 180 / Math.PI; 270 | } 271 | }; 272 | 273 | /** 274 | * 创建使用纹理的Sprite对象。 275 | * @param {render} render 276 | * @param {body} body 277 | * @return {void} 278 | */ 279 | var _createBodySprite = function(render, body) 280 | { 281 | var bodyRender = body.render, 282 | texturePath = bodyRender.sprite.texture, 283 | sprite = new Laya.Sprite(); 284 | 285 | sprite.loadImage(texturePath); 286 | sprite.pivotX = body.render.sprite.xOffset; 287 | sprite.pivotY = body.render.sprite.yOffset; 288 | 289 | return sprite; 290 | }; 291 | 292 | /** 293 | * 创建使用矢量绘图的Sprite对象。 294 | * @param {render} render 295 | * @param {body} body 296 | * @return {void} 297 | */ 298 | var _createBodyPrimitive = function(render, body) 299 | { 300 | var bodyRender = body.render, 301 | options = render.options, 302 | sprite = new Laya.Sprite(), 303 | fillStyle, strokeStyle, lineWidth, 304 | part, points = []; 305 | 306 | var primitive = sprite.graphics; 307 | primitive.clear(); 308 | 309 | // 处理 compound parts 310 | for (var k = body.parts.length > 1 ? 1 : 0; k < body.parts.length; k++) 311 | { 312 | part = body.parts[k]; 313 | 314 | if (!options.wireframes) 315 | { 316 | fillStyle = bodyRender.fillStyle; 317 | strokeStyle = bodyRender.strokeStyle; 318 | lineWidth = bodyRender.lineWidth; 319 | } 320 | else 321 | { 322 | fillStyle = null; 323 | strokeStyle = '#bbbbbb'; 324 | lineWidth = 1; 325 | } 326 | 327 | points.push(part.vertices[0].x - body.position.x, part.vertices[0].y - body.position.y); 328 | 329 | for (var j = 1; j < part.vertices.length; j++) 330 | { 331 | points.push(part.vertices[j].x - body.position.x, part.vertices[j].y - body.position.y); 332 | } 333 | 334 | points.push(part.vertices[0].x - body.position.x, part.vertices[0].y - body.position.y); 335 | 336 | primitive.drawPoly(0, 0, points, fillStyle, strokeStyle, lineWidth); 337 | 338 | // 角度指示器 339 | if (options.showAngleIndicator || options.showAxes) 340 | { 341 | lineWidth = 1; 342 | if (options.wireframes) 343 | { 344 | strokeStyle = '#CD5C5C'; 345 | } 346 | else 347 | { 348 | strokeStyle = bodyRender.strokeStyle; 349 | } 350 | 351 | primitive.drawLine(part.position.x - body.position.x, part.position.y - body.position.y, 352 | ((part.vertices[0].x + part.vertices[part.vertices.length - 1].x) / 2 - body.position.x), 353 | ((part.vertices[0].y + part.vertices[part.vertices.length - 1].y) / 2 - body.position.y)); 354 | } 355 | } 356 | 357 | return sprite; 358 | }; 359 | 360 | /** 361 | * 绘制 constraint。 362 | * @param {render} render 363 | * @param {constraint} constraint 364 | * @return {void} 365 | */ 366 | LayaRender.constraint = function(render, constraint) 367 | { 368 | var engine = render.engine, 369 | bodyA = constraint.bodyA, 370 | bodyB = constraint.bodyB, 371 | pointA = constraint.pointA, 372 | pointB = constraint.pointB, 373 | container = render.container, 374 | constraintRender = constraint.render, 375 | primitiveId = 'c-' + constraint.id, 376 | sprite = constraint.layaSprite; 377 | 378 | // 如果sprite不存在,则初始化一个 379 | if (!sprite) 380 | sprite = constraint.layaSprite = new Laya.Sprite(); 381 | 382 | var primitive = sprite.graphics; 383 | 384 | // constraint 没有两个终点时不渲染 385 | if (!constraintRender.visible || !constraint.pointA || !constraint.pointB) 386 | { 387 | primitive.clear(); 388 | return; 389 | } 390 | 391 | // 如果sprite未在显示列表,则添加至显示列表 392 | if (!container.contains(sprite)) 393 | container.addChild(sprite); 394 | 395 | // 渲染 constraint 396 | primitive.clear(); 397 | 398 | var fromX, fromY, toX, toY; 399 | if (bodyA) 400 | { 401 | fromX = bodyA.position.x + pointA.x; 402 | fromY = bodyA.position.y + pointA.y; 403 | } 404 | else 405 | { 406 | fromX = pointA.x; 407 | fromY = pointA.y; 408 | } 409 | 410 | if (bodyB) 411 | { 412 | toX = bodyB.position.x + pointB.x; 413 | toY = bodyB.position.y + pointB.y; 414 | } 415 | else 416 | { 417 | toX = pointB.x; 418 | toY = pointB.y; 419 | } 420 | 421 | primitive.drawLine(fromX, fromY, toX, toY, constraintRender.strokeStyle, constraintRender.lineWidth); 422 | }; 423 | 424 | window.LayaRender = LayaRender; 425 | })(); -------------------------------------------------------------------------------- /bin/libs/min/laya.html.min.js: -------------------------------------------------------------------------------- 1 | !function(window,document,Laya){var __un=Laya.un,__uns=Laya.uns,__static=Laya.static,__class=Laya.class,__getset=Laya.getset,__newvec=Laya.__newvec,Browser=laya.utils.Browser,CSSStyle=laya.display.css.CSSStyle,ClassUtils=laya.utils.ClassUtils,Event=laya.events.Event,HTMLChar=laya.utils.HTMLChar,Loader=laya.net.Loader,Node=laya.display.Node,Rectangle=laya.maths.Rectangle,Render=laya.renders.Render,RenderContext=laya.renders.RenderContext,RenderSprite=laya.renders.RenderSprite,Sprite=laya.display.Sprite,Stat=laya.utils.Stat,Text=laya.display.Text,Texture=laya.resource.Texture,URL=laya.net.URL,Utils=laya.utils.Utils,HTMLParse=function(){function t(){}return __class(t,"laya.html.utils.HTMLParse"),t.parse=function(e,i,n){i=(i=""+(i=i.replace(/
/g,"
"))+"
").replace(t.spacePattern,t.char255);var s=Utils.parseXMLFromString(i);t._parseXML(e,s.childNodes[0].childNodes,n)},t._parseXML=function(e,i,n,s){var l=0,r=0;if(i.join||i.item)for(l=0,r=i.length;l0&&(a=ClassUtils.getInstance(h))&&(e.addChild(a),a.innerTEXT=o.replace(t.char255AndOneSpacePattern," "))):(o=i.textContent.replace(/^\s+|\s+$/g,"")).length>0&&(e.innerTEXT=o.replace(t.char255AndOneSpacePattern," ")))}if("#comment"==(h=i.nodeName.toLowerCase()))return;if(a=ClassUtils.getInstance(h)){(a=e.addChild(a)).URI=n,a.href=s;var _=i.attributes;if(_&&_.length>0)for(l=0,r=_.length;l0&&v+S>g&&E.wordStartIndex>0){var N=0;N=E.elements.length-E.wordStartIndex+1,E.elements.length=E.wordStartIndex,o-=N,i();continue}C=!1,I+=a.width}S=a.width+u,M=a.height,R=!1,(C=C||v+S>g)&&i(),E.minTextHeight=Math.min(E.minTextHeight,s.height)}else h=s,r=(l=s._getCSSStyle()).padding,0===l._getCssFloat()||(x=!0),C=R||l.lineElement,S=h.width*h._style._tf.scaleX+r[1]+r[3]+u,M=h.height*h._style._tf.scaleY+r[0]+r[2],R=l.lineElement,(C=C||v+S>g&&l.wordWrap)&&i();E.elements.push(s),E.h=Math.max(E.h,M),s.x=v,s.y=T,v+=S,E.w=v-u,E.y=T,p=Math.max(v+m,p)}else A||(v+=t.DIV_ELEMENT_PADDING),E.wordStartIndex=E.elements.length;if(T=E.y+E.h,x){var U=0,W=g;for(y&&e.width>0&&(W=e.width),o=0,_=H.length;o<_;o++)H[o].updatePos(0,W,o,U,L,w,f),U+=Math.max(f,H[o].h+c);T=U}return y&&(e.width=p),T>e.height&&(e.height=T),[p,T]},t._multiLineLayout2=function(e){function i(){E.y=T,T+=E.h+c,0==E.h&&(T+=f),E.mWidth=I,I=0,E=new LayoutLine,H.push(E),E.h=0,v=0,A=!0,C=!1}var n=new Array;e._addChildsToLayout(n);var s,l,r,a,h,o=0,_=n.length,d=e._getCSSStyle(),u=d.letterSpacing,c=d.leading,f=d.lineHeight,y=d._widthAuto()||!d.wordWrap,g=y?999999:e.width,p=(e.height,0),m=d.italic?d.fontSize/3:0,L=2-d._getAlign(),w=d._getValign(),x=0!==w||0!==L||0!=f,v=0,T=0,S=0,M=0,H=new Array,E=H[0]=new LayoutLine,C=!1,R=!1;E.h=0,d.italic&&(g-=d.fontSize/3);var I=0,A=!0;for(o=0;o<_;o++)if(null!=(s=n[o]))if(A=!1,s instanceof laya.html.dom.HTMLBrElement)i(),E.y=T;else{if(s._isChar()){if((a=s).isWord)C=R||"\n"===a.char,E.wordStartIndex=E.elements.length;else{if(H.length>0&&v+S>g&&E.wordStartIndex>0){var N=0;N=E.elements.length-E.wordStartIndex+1,E.elements.length=E.wordStartIndex,o-=N,i();continue}C=!1,I+=a.width}S=a.width+u,M=a.height,R=!1,(C=C||v+S>g)&&i(),E.minTextHeight=Math.min(E.minTextHeight,s.height)}else h=s,r=(l=s._getCSSStyle()).padding,0===l._getCssFloat()||(x=!0),C=R||l.lineElement,S=h.width*h._style._tf.scaleX+r[1]+r[3]+u,M=h.height*h._style._tf.scaleY+r[0]+r[2],R=l.lineElement,(C=C||v+S>g&&l.wordWrap)&&i();E.elements.push(s),E.h=Math.max(E.h,M),s.x=v,s.y=T,v+=S,E.w=v-u,E.y=T,p=Math.max(v+m,p)}else A||(v+=t.DIV_ELEMENT_PADDING),E.wordStartIndex=E.elements.length;if(T=E.y+E.h,x){var U=0,W=g;for(o=0,_=H.length;o<_;o++)H[o].updatePos(0,W,o,U,L,w,f),U+=Math.max(f,H[o].h+c);T=U}for(y&&(e.width=p),T>e.height&&(e.height=T),o=0,_=H.length;o<_;o++)H[o].revertOrder(g);return[p,T]},t._will=null,t.DIV_ELEMENT_PADDING=0,t}(),LayoutLine=function(){function t(){this.x=0,this.y=0,this.w=0,this.h=0,this.wordStartIndex=0,this.minTextHeight=99999,this.mWidth=0,this.elements=new Array}__class(t,"laya.html.utils.LayoutLine");var e=t.prototype;return e.updatePos=function(t,e,i,n,s,l,r){var a,h=0;this.elements.length>0&&(h=(a=this.elements[this.elements.length-1]).x+a.width-this.elements[0].x);var o=0,_=NaN;1===s&&(o=(e-h)/2),2===s&&(o=e-h),0===r||0!=l||(l=1);for(var d=0,u=this.elements.length;d0){var i=0,n=0;for(n=this.elements.length,i=0;i0)for(var e=0;e=0&&i.push(e[s]),this._text.drawWords=i}var l=this._text.words;if(l&&l.length===i.length)return l;null===l&&(this._text.words=l=[]),l.length=i.length;var r,a=this.style,h=a.font;for(n=0,s=i.length;n1&&(o.charNum=o.char),this.href){var _=new Sprite;this.addChild(_),o.setSprite(_)}}return l},__proto._getWords=function(){if(!Text.CharacterCache)return this._getWords2();var t=this._text.text;if(!t||0===t.length)return null;var e=this._text.words;if(e&&e.length===t.length)return e;null===e&&(this._text.words=e=[]),e.length=t.length;for(var i,n=this.style,s=n.font,l=0,r=t.length;l0||null!=this._getWords())&&t.block?(Layout.later(this),t._type|=512):this.parent&&this.parent._layoutLater())},__proto._setAttributes=function(t,e){switch(t){case"style":return void this.style.cssText(e);case"class":return void(this.className=e)}_super.prototype._setAttributes.call(this,t,e)},__proto.updateHref=function(){if(null!=this._href){var t=this._getWords();if(t)for(var e,i,n=0;n0)for(var e=0;et)return e;for(var i=512;t>i;)i<<=1;for(var r=new Uint8Array(i),s=0;a>s;++s)r[s]=e[s];return this.buffer=r},getByte:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return this.buffer[this.pos++]},getBytes:function(t){var e=this.pos;if(t){this.ensureBuffer(e+t);for(var a=e+t;!this.eof&&this.bufferLengthi&&(a=i)}else{for(;!this.eof;)this.readBlock();var a=this.bufferLength}return this.pos=a,this.buffer.subarray(e,a)},lookChar:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos])},getChar:function(){for(var t=this.pos;this.bufferLength<=t;){if(this.eof)return null;this.readBlock()}return String.fromCharCode(this.buffer[this.pos++])},makeSubStream:function(t,e,a){for(var i=t+e;this.bufferLength<=i&&!this.eof;)this.readBlock();return new Stream(this.buffer,t,e,a)},skip:function(t){t||(t=1),this.pos+=t},reset:function(){this.pos=0}},t}(),FlateStream=function(){function t(t){throw new Error(t)}function e(e){var a=0,i=e[a++],r=e[a++];-1!=i&&-1!=r||t("Invalid header in flate stream"),8!=(15&i)&&t("Unknown compression method in flate stream"),((i<<8)+r)%31!=0&&t("Bad FCHECK in flate stream"),32&r&&t("FDICT bit set in flate stream"),this.bytes=e,this.bytesPos=a,this.codeSize=0,this.codeBuf=0,DecodeStream.call(this)}var a=new Uint32Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),i=new Uint32Array([3,4,5,6,7,8,9,10,65547,65549,65551,65553,131091,131095,131099,131103,196643,196651,196659,196667,262211,262227,262243,262259,327811,327843,327875,327907,258,258,258]),r=new Uint32Array([1,2,3,4,65541,65543,131081,131085,196625,196633,262177,262193,327745,327777,393345,393409,459009,459137,524801,525057,590849,591361,657409,658433,724993,727041,794625,798721,868353,876545]),s=[new Uint32Array([459008,524368,524304,524568,459024,524400,524336,590016,459016,524384,524320,589984,524288,524416,524352,590048,459012,524376,524312,589968,459028,524408,524344,590032,459020,524392,524328,59e4,524296,524424,524360,590064,459010,524372,524308,524572,459026,524404,524340,590024,459018,524388,524324,589992,524292,524420,524356,590056,459014,524380,524316,589976,459030,524412,524348,590040,459022,524396,524332,590008,524300,524428,524364,590072,459009,524370,524306,524570,459025,524402,524338,590020,459017,524386,524322,589988,524290,524418,524354,590052,459013,524378,524314,589972,459029,524410,524346,590036,459021,524394,524330,590004,524298,524426,524362,590068,459011,524374,524310,524574,459027,524406,524342,590028,459019,524390,524326,589996,524294,524422,524358,590060,459015,524382,524318,589980,459031,524414,524350,590044,459023,524398,524334,590012,524302,524430,524366,590076,459008,524369,524305,524569,459024,524401,524337,590018,459016,524385,524321,589986,524289,524417,524353,590050,459012,524377,524313,589970,459028,524409,524345,590034,459020,524393,524329,590002,524297,524425,524361,590066,459010,524373,524309,524573,459026,524405,524341,590026,459018,524389,524325,589994,524293,524421,524357,590058,459014,524381,524317,589978,459030,524413,524349,590042,459022,524397,524333,590010,524301,524429,524365,590074,459009,524371,524307,524571,459025,524403,524339,590022,459017,524387,524323,589990,524291,524419,524355,590054,459013,524379,524315,589974,459029,524411,524347,590038,459021,524395,524331,590006,524299,524427,524363,590070,459011,524375,524311,524575,459027,524407,524343,590030,459019,524391,524327,589998,524295,524423,524359,590062,459015,524383,524319,589982,459031,524415,524351,590046,459023,524399,524335,590014,524303,524431,524367,590078,459008,524368,524304,524568,459024,524400,524336,590017,459016,524384,524320,589985,524288,524416,524352,590049,459012,524376,524312,589969,459028,524408,524344,590033,459020,524392,524328,590001,524296,524424,524360,590065,459010,524372,524308,524572,459026,524404,524340,590025,459018,524388,524324,589993,524292,524420,524356,590057,459014,524380,524316,589977,459030,524412,524348,590041,459022,524396,524332,590009,524300,524428,524364,590073,459009,524370,524306,524570,459025,524402,524338,590021,459017,524386,524322,589989,524290,524418,524354,590053,459013,524378,524314,589973,459029,524410,524346,590037,459021,524394,524330,590005,524298,524426,524362,590069,459011,524374,524310,524574,459027,524406,524342,590029,459019,524390,524326,589997,524294,524422,524358,590061,459015,524382,524318,589981,459031,524414,524350,590045,459023,524398,524334,590013,524302,524430,524366,590077,459008,524369,524305,524569,459024,524401,524337,590019,459016,524385,524321,589987,524289,524417,524353,590051,459012,524377,524313,589971,459028,524409,524345,590035,459020,524393,524329,590003,524297,524425,524361,590067,459010,524373,524309,524573,459026,524405,524341,590027,459018,524389,524325,589995,524293,524421,524357,590059,459014,524381,524317,589979,459030,524413,524349,590043,459022,524397,524333,590011,524301,524429,524365,590075,459009,524371,524307,524571,459025,524403,524339,590023,459017,524387,524323,589991,524291,524419,524355,590055,459013,524379,524315,589975,459029,524411,524347,590039,459021,524395,524331,590007,524299,524427,524363,590071,459011,524375,524311,524575,459027,524407,524343,590031,459019,524391,524327,589999,524295,524423,524359,590063,459015,524383,524319,589983,459031,524415,524351,590047,459023,524399,524335,590015,524303,524431,524367,590079]),9],n=[new Uint32Array([327680,327696,327688,327704,327684,327700,327692,327708,327682,327698,327690,327706,327686,327702,327694,0,327681,327697,327689,327705,327685,327701,327693,327709,327683,327699,327691,327707,327687,327703,327695,0]),5];return e.prototype=Object.create(DecodeStream.prototype),e.prototype.getBits=function(e){for(var a,i=this.codeSize,r=this.codeBuf,s=this.bytes,n=this.bytesPos;e>i;)"undefined"==typeof(a=s[n++])&&t("Bad encoding in flate stream"),r|=a<>e,this.codeSize=i-=e,this.bytesPos=n,a},e.prototype.getCode=function(e){for(var a=e[0],i=e[1],r=this.codeSize,s=this.codeBuf,n=this.bytes,o=this.bytesPos;i>r;){var h;"undefined"==typeof(h=n[o++])&&t("Bad encoding in flate stream"),s|=h<>16,c=65535&f;return(0==r||d>r||0==d)&&t("Bad encoding in flate stream"),this.codeBuf=s>>d,this.codeSize=r-d,this.bytesPos=o,c},e.prototype.generateHuffmanTable=function(t){for(var e=t.length,a=0,i=0;e>i;++i)t[i]>a&&(a=t[i]);for(var r=1<=n;++n,o<<=1,h<<=1)for(var f=0;e>f;++f)if(t[f]==n){for(var d=0,c=o,i=0;n>i;++i)d=d<<1|1&c,c>>=1;for(var i=d;r>i;i+=h)s[i]=n<<16|f;++o}return[s,a]},e.prototype.readBlock=function(){function e(t,e,a,i,r){for(var s=t.getBits(a)+i;s-- >0;)e[I++]=r}var o=this.getBits(3);if(1&o&&(this.eof=!0),o>>=1,0==o){var h,f=this.bytes,d=this.bytesPos;"undefined"==typeof(h=f[d++])&&t("Bad block header in flate stream");var c=h;"undefined"==typeof(h=f[d++])&&t("Bad block header in flate stream"),c|=h<<8,"undefined"==typeof(h=f[d++])&&t("Bad block header in flate stream");var l=h;"undefined"==typeof(h=f[d++])&&t("Bad block header in flate stream"),l|=h<<8,l!=(65535&~c)&&t("Bad uncompressed block length in flate stream"),this.codeBuf=0,this.codeSize=0;var u=this.bufferLength,p=this.ensureBuffer(u+c),g=u+c;this.bufferLength=g;for(var m=u;g>m;++m){if("undefined"==typeof(h=f[d++])){this.eof=!0;break}p[m]=h}return void(this.bytesPos=d)}var y,v;if(1==o)y=s,v=n;else if(2==o){for(var b=this.getBits(5)+257,w=this.getBits(5)+1,B=this.getBits(4)+4,T=Array(a.length),I=0;B>I;)T[a[I++]]=this.getBits(3);for(var U=this.generateHuffmanTable(T),D=0,I=0,k=b+w,A=new Array(k);k>I;){var C=this.getCode(U);16==C?e(this,A,2,3,D):17==C?e(this,A,3,3,D=0):18==C?e(this,A,7,11,D=0):A[I++]=D=C}y=this.generateHuffmanTable(A.slice(0,b)),v=this.generateHuffmanTable(A.slice(b,k))}else t("Unknown block type in flate stream");for(var p=this.buffer,S=p?p.length:0,P=this.bufferLength;;){var M=this.getCode(y);if(256>M)P+1>=S&&(p=this.ensureBuffer(P+1),S=p.length),p[P++]=M;else{if(256==M)return void(this.bufferLength=P);M-=257,M=i[M];var L=M>>16;L>0&&(L=this.getBits(L));var D=(65535&M)+L;M=this.getCode(v),M=r[M],L=M>>16,L>0&&(L=this.getBits(L));var x=(65535&M)+L;P+D>=S&&(p=this.ensureBuffer(P+D),S=p.length);for(var N=0;D>N;++N,++P)p[P]=p[P-x]}}},e}();(function(){var t;t=function(){function t(t){var e,a,i,r,s,n,o,h,f,d,c,l,u,p;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},s=null;;){switch(e=this.readUInt32(),f=function(){var t,e;for(e=[],n=t=0;4>t;n=++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join("")){case"IHDR":if(this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++],0!=this.interlaceMethod)throw new Error("Invalid interlaceMethod: "+this.interlaceMethod);break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(e);break;case"fcTL":s&&this.animation.frames.push(s),this.pos+=4,s={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},r=this.readUInt16(),i=this.readUInt16()||100,s.delay=1e3*r/i,s.disposeOp=this.data[this.pos++],s.blendOp=this.data[this.pos++],s.data=[];break;case"IDAT":case"fdAT":for("fdAT"===f&&(this.pos+=4,e-=4),t=(null!=s?s.data:void 0)||this.imgData,n=l=0;e>=0?e>l:l>e;n=e>=0?++l:--l)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(e),d=255-this.transparency.indexed.length,d>0)for(n=u=0;d>=0?d>u:u>d;n=d>=0?++u:--u)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":c=this.read(e),o=c.indexOf(0),h=String.fromCharCode.apply(String,c.slice(0,o)),this.text[h]=String.fromCharCode.apply(String,c.slice(o+1));break;case"IEND":return s&&this.animation.frames.push(s),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(p=this.colorType)||6===p,a=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*a,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}var e,a,i,r,s,n;return t.load=function(e,a){var i;return"function"==typeof canvas&&(a=canvas),i=new XMLHttpRequest,i.open("GET",e,!0),i.responseType="arraybuffer",i.onload=function(){var r,s;return r=new Uint8Array(i.response||i.mozResponseArrayBuffer),s=new t(r),s.url=e,"function"==typeof a?a(s):void 0},i.send(null)},r=0,i=1,s=2,a=0,e=1,t.prototype.read=function(t){var e,a,i;for(i=[],e=a=0;t>=0?t>a:a>t;e=t>=0?++a:--a)i.push(this.data[this.pos++]);return i},t.prototype.readUInt32=function(){var t,e,a,i;return t=this.data[this.pos++]<<24,e=this.data[this.pos++]<<16,a=this.data[this.pos++]<<8,i=this.data[this.pos++],t|e|a|i},t.prototype.readUInt16=function(){var t,e;return t=this.data[this.pos++]<<8,e=this.data[this.pos++],t|e},t.prototype.decodePixels=function(t){var e,a,i,r,s,n,o,h,f,d,c,l,u,p,g,m,y,v,b,w,B,T,I;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=new FlateStream(t),t=t.getBytes(),l=this.pixelBitlength/8,m=l*this.width,u=new Uint8Array(m*this.height),n=t.length,g=0,p=0,a=0;n>p;){switch(t[p++]){case 0:for(r=b=0;m>b;r=b+=1)u[a++]=t[p++];break;case 1:for(r=w=0;m>w;r=w+=1)e=t[p++],s=l>r?0:u[a-l],u[a++]=(e+s)%256;break;case 2:for(r=B=0;m>B;r=B+=1)e=t[p++],i=(r-r%l)/l,y=g&&u[(g-1)*m+i*l+r%l],u[a++]=(y+e)%256;break;case 3:for(r=T=0;m>T;r=T+=1)e=t[p++],i=(r-r%l)/l,s=l>r?0:u[a-l],y=g&&u[(g-1)*m+i*l+r%l],u[a++]=(e+Math.floor((s+y)/2))%256;break;case 4:for(r=I=0;m>I;r=I+=1)e=t[p++],i=(r-r%l)/l,s=l>r?0:u[a-l],0===g?y=v=0:(y=u[(g-1)*m+i*l+r%l],v=i&&u[(g-1)*m+(i-1)*l+r%l]),o=s+y-v,h=Math.abs(o-s),d=Math.abs(o-y),c=Math.abs(o-v),f=d>=h&&c>=h?s:c>=d?y:v,u[a++]=(e+f)%256;break;default:throw new Error("Invalid filter algorithm: "+t[p-1])}g++}return u},t.prototype.decodePalette=function(){var t,e,a,i,r,s,n,o,h,f;i=this.palette,n=this.transparency.indexed||[];var d;for(d=4*i.length/3,s=new Uint8Array(d),r=0,a=i.length,t=0,e=o=0,h=i.length;h>o;e=o+=3)s[r++]=i[e],s[r++]=i[e+1],s[r++]=i[e+2],s[r++]=null!=(f=n[t++])?f:255;return s},t.prototype.getImageData=function(){var t=new self.ImageData(this.width,this.height);return this.copyToImageData(t,this.decodePixels()),t},t.prototype.getImageDataBuffer=function(){var t;return t=self.Uint8ClampedArray?new self.Uint8ClampedArray(this.width*this.height*4):new self.Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t},t.prototype.copyToImageData=function(t,e){var a,i,r,s,n,o,h,f,d,c,l;if(i=this.colors,d=null,a=this.hasAlphaChannel,this.palette.length&&(d=null!=(l=this._decodedPalette)?l:this._decodedPalette=this.decodePalette(),i=4,a=!0),r=t.data||t,f=r.length,n=d||e,s=o=0,1===i)for(;f>s;)h=d?4*e[s/4]:o,c=n[h++],r[s++]=c,r[s++]=c,r[s++]=c,r[s++]=a?n[h++]:255,o=h;else for(;f>s;)h=d?4*e[s/4]:o,r[s++]=n[h++],r[s++]=n[h++],r[s++]=n[h++],r[s++]=a?n[h++]:255,o=h},t.prototype.decode=function(){var t;return t=new Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t},t.prototype.decodeFrames=function(t){var e,a,i,r,s,o,h,f;if(this.animation){for(h=this.animation.frames,f=[],a=s=0,o=h.length;o>s;a=++s)e=h[a],i=t.createImageData(e.width,e.height),r=this.decodePixels(new Uint8Array(e.data)),this.copyToImageData(i,r),e.imageData=i,f.push(e.image=n(i));return f}},t}(),this.PNG=t}).call(this),onmessage=function(t){var e=t.data;switch(e.type){case"load":loadImage2(e)}};var canUseImageData=!1;testCanImageData(); -------------------------------------------------------------------------------- /bin/libs/min/laya.device.min.js: -------------------------------------------------------------------------------- 1 | !function(e,t,n){n.un,n.uns;var i=n.static,a=n.class,o=n.getset,r=(n.__newvec,laya.resource.Bitmap),s=laya.utils.Browser,c=(laya.events.Event,laya.events.EventDispatcher),l=(laya.utils.Handler,laya.maths.Rectangle,laya.renders.Render),d=laya.display.Sprite,h=(laya.display.Stage,laya.resource.Texture),u=laya.utils.Utils,v=laya.webgl.WebGL,m=laya.webgl.WebGLContext,g=(function(){function e(){}a(e,"laya.device.geolocation.Geolocation"),e.getCurrentPosition=function(t,n){e.navigator.geolocation.getCurrentPosition(function(n){e.position.setPosition(n),t.runWith(e.position)},function(e){n.runWith(e)},{enableHighAccuracy:laya.device.geolocation.Geolocation.enableHighAccuracy,timeout:laya.device.geolocation.Geolocation.timeout,maximumAge:laya.device.geolocation.Geolocation.maximumAge})},e.watchPosition=function(t,n){return e.navigator.geolocation.watchPosition(function(n){e.position.setPosition(n),t.runWith(e.position)},function(e){n.runWith(e)},{enableHighAccuracy:e.enableHighAccuracy,timeout:e.timeout,maximumAge:e.maximumAge})},e.clearWatch=function(t){e.navigator.geolocation.clearWatch(t)},e.PERMISSION_DENIED=1,e.POSITION_UNAVAILABLE=2,e.TIMEOUT=3,e.enableHighAccuracy=!1,e.maximumAge=0,i(e,["navigator",function(){return this.navigator=s.window.navigator},"position",function(){return this.position=new g},"supported",function(){return this.supported=!!e.navigator.geolocation},"timeout",function(){return this.timeout=1e10}])}(),function(){function e(){this.pos=null,this.coords=null}a(e,"laya.device.geolocation.GeolocationInfo");var t=e.prototype;return t.setPosition=function(e){this.pos=e,this.coords=e.coords},o(0,t,"heading",function(){return this.coords.heading}),o(0,t,"latitude",function(){return this.coords.latitude}),o(0,t,"altitudeAccuracy",function(){return this.coords.altitudeAccuracy}),o(0,t,"longitude",function(){return this.coords.longitude}),o(0,t,"altitude",function(){return this.coords.altitude}),o(0,t,"accuracy",function(){return this.coords.accuracy}),o(0,t,"speed",function(){return this.coords.speed}),o(0,t,"timestamp",function(){return this.pos.timestamp}),e}()),f=function(){function e(){}return a(e,"laya.device.media.Media"),e.supported=function(){return!!s.window.navigator.getUserMedia},e.getMedia=function(e,t,n){s.window.navigator.getUserMedia&&s.window.navigator.getUserMedia(e,function(e){t.runWith(s.window.URL.createObjectURL(e))},function(e){n.runWith(e)})},e.__init$=function(){navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia},e}(),p=function(){function e(){this.x=NaN,this.y=NaN,this.z=NaN}return a(e,"laya.device.motion.AccelerationInfo"),e}(),y=function(){function e(){this.absolute=!1,this.alpha=NaN,this.beta=NaN,this.gamma=NaN,this.compassAccuracy=NaN}return a(e,"laya.device.motion.RotationInfo"),e}(),E=function(e){function t(e){t.__super.call(this),this.onDeviceOrientationChange=this.onDeviceOrientationChange.bind(this)}a(t,"laya.device.motion.Accelerator",e);var r=t.prototype;return r.on=function(t,n,i,a){return e.prototype.on.call(this,t,n,i,a),s.window.addEventListener("devicemotion",this.onDeviceOrientationChange),this},r.off=function(t,n,i,a){return void 0===a&&(a=!1),this.hasListener(t)||s.window.removeEventListener("devicemotion",this.onDeviceOrientationChange),e.prototype.off.call(this,t,n,i,a)},r.onDeviceOrientationChange=function(e){var n=e.interval;t.acceleration.x=e.acceleration.x,t.acceleration.y=e.acceleration.y,t.acceleration.z=e.acceleration.z,t.accelerationIncludingGravity.x=e.accelerationIncludingGravity.x,t.accelerationIncludingGravity.y=e.accelerationIncludingGravity.y,t.accelerationIncludingGravity.z=e.accelerationIncludingGravity.z,t.rotationRate.alpha=-1*e.rotationRate.gamma,t.rotationRate.beta=-1*e.rotationRate.alpha,t.rotationRate.gamma=e.rotationRate.beta,s.onAndriod?(t.onChrome&&(t.rotationRate.alpha*=180/Math.PI,t.rotationRate.beta*=180/Math.PI,t.rotationRate.gamma*=180/Math.PI),t.acceleration.x*=-1,t.accelerationIncludingGravity.x*=-1):s.onIOS&&(t.acceleration.y*=-1,t.acceleration.z*=-1,t.accelerationIncludingGravity.y*=-1,t.accelerationIncludingGravity.z*=-1,n*=1e3),this.event("change",[t.acceleration,t.accelerationIncludingGravity,t.rotationRate,n])},o(1,t,"instance",function(){return t._instance=t._instance||new t(0)},laya.events.EventDispatcher._$SET_instance),t.getTransformedAcceleration=function(e){(t.transformedAcceleration=t.transformedAcceleration||new p).z=e.z,90==s.window.orientation?(t.transformedAcceleration.x=e.y,t.transformedAcceleration.y=-e.x):-90==s.window.orientation?(t.transformedAcceleration.x=-e.y,t.transformedAcceleration.y=e.x):s.window.orientation?180==s.window.orientation&&(t.transformedAcceleration.x=-e.x,t.transformedAcceleration.y=-e.y):(t.transformedAcceleration.x=e.x,t.transformedAcceleration.y=e.y);var i=NaN;return-90==n.stage.canvasDegree?(i=t.transformedAcceleration.x,t.transformedAcceleration.x=-t.transformedAcceleration.y,t.transformedAcceleration.y=i):90==n.stage.canvasDegree&&(i=t.transformedAcceleration.x,t.transformedAcceleration.x=t.transformedAcceleration.y,t.transformedAcceleration.y=-i),t.transformedAcceleration},t._instance=null,t.transformedAcceleration=null,i(t,["acceleration",function(){return this.acceleration=new p},"accelerationIncludingGravity",function(){return this.accelerationIncludingGravity=new p},"rotationRate",function(){return this.rotationRate=new y},"onChrome",function(){return this.onChrome=s.userAgent.indexOf("Chrome")>-1}]),t}(c),L=(function(e){function t(e){t.__super.call(this),this.onDeviceOrientationChange=this.onDeviceOrientationChange.bind(this)}a(t,"laya.device.motion.Gyroscope",e);var n=t.prototype;n.on=function(t,n,i,a){return e.prototype.on.call(this,t,n,i,a),s.window.addEventListener("deviceorientation",this.onDeviceOrientationChange),this},n.off=function(t,n,i,a){return void 0===a&&(a=!1),this.hasListener(t)||s.window.removeEventListener("deviceorientation",this.onDeviceOrientationChange),e.prototype.off.call(this,t,n,i,a)},n.onDeviceOrientationChange=function(e){t.info.alpha=e.alpha,t.info.beta=e.beta,t.info.gamma=e.gamma,e.webkitCompassHeading&&(t.info.alpha=-1*e.webkitCompassHeading,t.info.compassAccuracy=e.webkitCompassAccuracy),this.event("change",[e.absolute,t.info])},o(1,t,"instance",function(){return t._instance=t._instance||new t(0)},laya.events.EventDispatcher._$SET_instance),t._instance=null,i(t,["info",function(){return this.info=new y}])}(c),function(e){function t(){this.throushold=0,this.shakeInterval=0,this.callback=null,this.lastX=NaN,this.lastY=NaN,this.lastZ=NaN,this.lastMillSecond=NaN,t.__super.call(this)}a(t,"laya.device.Shake",c);var n=t.prototype;n.start=function(e,t){this.throushold=e,this.shakeInterval=t,this.lastX=this.lastY=this.lastZ=NaN,E.instance.on("change",this,this.onShake)},n.stop=function(){E.instance.off("change",this,this.onShake)},n.onShake=function(e,t,n,i){if(isNaN(this.lastX))return this.lastX=t.x,this.lastY=t.y,this.lastZ=t.z,void(this.lastMillSecond=s.now());var a=Math.abs(this.lastX-t.x),o=Math.abs(this.lastY-t.y),r=Math.abs(this.lastZ-t.z);if(this.isShaked(a,o,r)){s.now()-this.lastMillSecond>this.shakeInterval&&(this.event("change"),this.lastMillSecond=s.now())}this.lastX=t.x,this.lastY=t.y,this.lastZ=t.z},n.isShaked=function(e,t,n){return e>this.throushold&&t>this.throushold||e>this.throushold&&n>this.throushold||t>this.throushold&&n>this.throushold},o(1,t,"instance",function(){return t._instance=t._instance||new t},laya.events.EventDispatcher._$SET_instance),t._instance=null}(),function(e){function t(e,n){this.htmlVideo=null,this.videoElement=null,this.internalTexture=null,void 0===e&&(e=320),void 0===n&&(n=240),t.__super.call(this),l.isWebGL?this.htmlVideo=new x:this.htmlVideo=new w,this.videoElement=this.htmlVideo.getVideo(),this.videoElement.layaTarget=this,this.internalTexture=new h(this.htmlVideo),this.videoElement.addEventListener("abort",t.onAbort),this.videoElement.addEventListener("canplay",t.onCanplay),this.videoElement.addEventListener("canplaythrough",t.onCanplaythrough),this.videoElement.addEventListener("durationchange",t.onDurationchange),this.videoElement.addEventListener("emptied",t.onEmptied),this.videoElement.addEventListener("error",t.onError),this.videoElement.addEventListener("loadeddata",t.onLoadeddata),this.videoElement.addEventListener("loadedmetadata",t.onLoadedmetadata),this.videoElement.addEventListener("loadstart",t.onLoadstart),this.videoElement.addEventListener("pause",t.onPause),this.videoElement.addEventListener("play",t.onPlay),this.videoElement.addEventListener("playing",t.onPlaying),this.videoElement.addEventListener("progress",t.onProgress),this.videoElement.addEventListener("ratechange",t.onRatechange),this.videoElement.addEventListener("seeked",t.onSeeked),this.videoElement.addEventListener("seeking",t.onSeeking),this.videoElement.addEventListener("stalled",t.onStalled),this.videoElement.addEventListener("suspend",t.onSuspend),this.videoElement.addEventListener("timeupdate",t.onTimeupdate),this.videoElement.addEventListener("volumechange",t.onVolumechange),this.videoElement.addEventListener("waiting",t.onWaiting),this.videoElement.addEventListener("ended",this.onPlayComplete.bind(this)),this.size(e,n),s.onMobile&&(this.onDocumentClick=this.onDocumentClick.bind(this),s.document.addEventListener("touchend",this.onDocumentClick))}a(t,"laya.device.media.Video",e);var i=t.prototype;return i.onPlayComplete=function(e){n.timer.clear(this,this.renderCanvas),this.event("ended")},i.load=function(e){0==e.indexOf("blob:")?this.videoElement.src=e:this.htmlVideo.setSource(e,laya.device.media.Video.MP4)},i.play=function(){this.videoElement.play(),n.timer.frameLoop(1,this,this.renderCanvas)},i.pause=function(){this.videoElement.pause(),n.timer.clear(this,this.renderCanvas)},i.reload=function(){this.videoElement.load()},i.canPlayType=function(e){var t;switch(e){case laya.device.media.Video.MP4:t="video/mp4";break;case laya.device.media.Video.OGG:t="video/ogg";break;case laya.device.media.Video.WEBM:t="video/webm"}return this.videoElement.canPlayType(t)},i.renderCanvas=function(){0!==this.readyState&&(l.isWebGL&&this.htmlVideo.updateTexture(),this.graphics.clear(),this.graphics.drawTexture(this.internalTexture,0,0,this.width,this.height))},i.onDocumentClick=function(){this.videoElement.play(),this.videoElement.pause(),s.document.removeEventListener("touchend",this.onDocumentClick)},i.size=function(t,n){return e.prototype.size.call(this,t,n),this.videoElement.width=t/s.pixelRatio,this.paused&&this.renderCanvas(),this},i.destroy=function(n){void 0===n&&(n=!0),e.prototype.destroy.call(this,n),this.videoElement.removeEventListener("abort",t.onAbort),this.videoElement.removeEventListener("canplay",t.onCanplay),this.videoElement.removeEventListener("canplaythrough",t.onCanplaythrough),this.videoElement.removeEventListener("durationchange",t.onDurationchange),this.videoElement.removeEventListener("emptied",t.onEmptied),this.videoElement.removeEventListener("error",t.onError),this.videoElement.removeEventListener("loadeddata",t.onLoadeddata),this.videoElement.removeEventListener("loadedmetadata",t.onLoadedmetadata),this.videoElement.removeEventListener("loadstart",t.onLoadstart),this.videoElement.removeEventListener("pause",t.onPause),this.videoElement.removeEventListener("play",t.onPlay),this.videoElement.removeEventListener("playing",t.onPlaying),this.videoElement.removeEventListener("progress",t.onProgress),this.videoElement.removeEventListener("ratechange",t.onRatechange),this.videoElement.removeEventListener("seeked",t.onSeeked),this.videoElement.removeEventListener("seeking",t.onSeeking),this.videoElement.removeEventListener("stalled",t.onStalled),this.videoElement.removeEventListener("suspend",t.onSuspend),this.videoElement.removeEventListener("timeupdate",t.onTimeupdate),this.videoElement.removeEventListener("volumechange",t.onVolumechange),this.videoElement.removeEventListener("waiting",t.onWaiting),this.videoElement.removeEventListener("ended",this.onPlayComplete),this.pause(),this.videoElement=null},i.syncVideoPosition=function(){var e,t=n.stage;e=u.getGlobalPosAndScale(this);var i=t._canvasTransform.a,a=t._canvasTransform.d,o=e.x*t.clientScaleX*i+t.offset.x,r=e.y*t.clientScaleY*a+t.offset.y;this.videoElement.style.left=o+"px",this.videoElement.style.top=r+"px",this.videoElement.width=this.width/s.pixelRatio,this.videoElement.height=this.height/s.pixelRatio},o(0,i,"buffered",function(){return this.videoElement.buffered}),o(0,i,"videoWidth",function(){return this.videoElement.videoWidth}),o(0,i,"currentSrc",function(){return this.videoElement.currentSrc}),o(0,i,"currentTime",function(){return this.videoElement.currentTime},function(e){this.videoElement.currentTime=e,this.renderCanvas()}),o(0,i,"ended",function(){return this.videoElement.ended}),o(0,i,"volume",function(){return this.videoElement.volume},function(e){this.videoElement.volume=e}),o(0,i,"videoHeight",function(){return this.videoElement.videoHeight}),o(0,i,"readyState",function(){return this.videoElement.readyState}),o(0,i,"duration",function(){return this.videoElement.duration}),o(0,i,"error",function(){return this.videoElement.error}),o(0,i,"loop",function(){return this.videoElement.loop},function(e){this.videoElement.loop=e}),o(0,i,"playbackRate",function(){return this.videoElement.playbackRate},function(e){this.videoElement.playbackRate=e}),o(0,i,"muted",function(){return this.videoElement.muted},function(e){this.videoElement.muted=e}),o(0,i,"paused",function(){return this.videoElement.paused}),o(0,i,"preload",function(){return this.videoElement.preload},function(e){this.videoElement.preload=e}),o(0,i,"seekable",function(){return this.videoElement.seekable}),o(0,i,"seeking",function(){return this.videoElement.seeking}),o(0,i,"height",e.prototype._$get_height,function(e){n.superSet(d,this,"height",e),this.paused&&this.renderCanvas()}),o(0,i,"width",e.prototype._$get_width,function(e){this.videoElement.width=this.width/s.pixelRatio,n.superSet(d,this,"width",e),this.paused&&this.renderCanvas()}),t.onAbort=function(e){e.target.layaTarget.event("abort")},t.onCanplay=function(e){e.target.layaTarget.event("canplay")},t.onCanplaythrough=function(e){e.target.layaTarget.event("canplaythrough")},t.onDurationchange=function(e){e.target.layaTarget.event("durationchange")},t.onEmptied=function(e){e.target.layaTarget.event("emptied")},t.onError=function(e){e.target.layaTarget.event("error")},t.onLoadeddata=function(e){e.target.layaTarget.event("loadeddata")},t.onLoadedmetadata=function(e){e.target.layaTarget.event("loadedmetadata")},t.onLoadstart=function(e){e.target.layaTarget.event("loadstart")},t.onPause=function(e){e.target.layaTarget.event("pause")},t.onPlay=function(e){e.target.layaTarget.event("play")},t.onPlaying=function(e){e.target.layaTarget.event("playing")},t.onProgress=function(e){e.target.layaTarget.event("progress")},t.onRatechange=function(e){e.target.layaTarget.event("ratechange")},t.onSeeked=function(e){e.target.layaTarget.event("seeked")},t.onSeeking=function(e){e.target.layaTarget.event("seeking")},t.onStalled=function(e){e.target.layaTarget.event("stalled")},t.onSuspend=function(e){e.target.layaTarget.event("suspend")},t.onTimeupdate=function(e){e.target.layaTarget.event("timeupdate")},t.onVolumechange=function(e){e.target.layaTarget.event("volumechange")},t.onWaiting=function(e){e.target.layaTarget.event("waiting")},t.MP4=1,t.OGG=2,t.CAMERA=4,t.WEBM=8,t.SUPPORT_PROBABLY="probably",t.SUPPORT_MAYBY="maybe",t.SUPPORT_NO="",t}(d)),w=function(e){function t(){this.video=null,t.__super.call(this),this._w=1,this._h=1,this.createDomElement()}a(t,"laya.device.media.HtmlVideo",r);var n=t.prototype;return n.createDomElement=function(){var e=this;this._source=this.video=s.createElement("video");var t=this.video.style;t.position="absolute",t.top="0px",t.left="0px",this.video.addEventListener("loadedmetadata",function(){this._w=e.video.videoWidth,this._h=e.video.videoHeight}.bind(this))},n.setSource=function(e,t){for(;this.video.childElementCount;)this.video.firstChild.remove();t&L.MP4&&this.appendSource(e,"video/mp4"),t&L.OGG&&this.appendSource(e+".ogg","video/ogg")},n.appendSource=function(e,t){var n=s.createElement("source");n.src=e,n.type=t,this.video.appendChild(n)},n.getVideo=function(){return this.video},t.create=function(){return new t},t}(),x=function(e){function t(){this.gl=null,this.preTarget=null,this.preTexture=null,t.__super.call(this),s.onIPhone||(this.gl=v.mainContext,this._source=this.gl.createTexture(),this.preTarget=m.curBindTexTarget,this.preTexture=m.curBindTexValue,m.bindTexture(this.gl,3553,this._source),this.gl.texParameteri(3553,10242,33071),this.gl.texParameteri(3553,10243,33071),this.gl.texParameteri(3553,10240,9729),this.gl.texParameteri(3553,10241,9729),this.preTarget&&this.preTexture&&m.bindTexture(this.gl,this.preTarget,this.preTexture))}a(t,"laya.device.media.WebGLVideo",w);return t.prototype.updateTexture=function(){s.onIPhone||(m.bindTexture(this.gl,3553,this._source),this.gl.texImage2D(3553,0,6407,6407,5121,this.video))},t}();n.__init([f])}(window,document,Laya),"function"==typeof define&&define.amd&&define("laya.core",["require","exports"],function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});for(var n in Laya){var i=Laya[n];i&&i.__isclass&&(t[n]=i)}}); -------------------------------------------------------------------------------- /bin/libs/min/laya.wxmini.min.js: -------------------------------------------------------------------------------- 1 | !function(i,e,n){n.un,n.uns;var t=n.static,o=n.class,a=n.getset,r=(n.__newvec,laya.utils.Browser),l=(laya.events.Event,laya.events.EventDispatcher),s=laya.resource.HTMLImage,u=laya.utils.Handler,c=laya.display.Input,d=laya.net.Loader,f=laya.net.LocalStorage,h=(laya.maths.Matrix,laya.renders.Render),p=laya.utils.RunDriver,v=laya.media.SoundChannel,m=laya.media.SoundManager,g=laya.net.URL,_=laya.utils.Utils,y=function(){function e(){}return o(e,"laya.wx.mini.MiniAdpter"),e.getJson=function(i){return JSON.parse(i)},e.init=function(t,o){void 0===t&&(t=!1),void 0===o&&(o=!1),e._inited||(e._inited=!0,(e.window=i).navigator.userAgent.indexOf("MiniGame")<0||(e.isZiYu=o,e.isPosMsgYu=t,e.EnvConfig={},e.isZiYu||(w.setNativeFileDir("/layaairGame"),w.existDir(w.fileNativeDir,u.create(e,e.onMkdirCallBack))),e.systemInfo=wx.getSystemInfoSync(),e.window.focus=function(){},n.getUrlPath=function(){},e.window.logtime=function(i){},e.window.alertTimeLog=function(i){},e.window.resetShareInfo=function(){},e.window.CanvasRenderingContext2D=function(){},e.window.CanvasRenderingContext2D.prototype=e.window.wx.createCanvas().getContext("2d").__proto__,e.window.document.body.appendChild=function(){},e.EnvConfig.pixelRatioInt=0,p.getPixelRatio=e.pixelRatio,e._preCreateElement=r.createElement,r.createElement=e.createElement,p.createShaderCondition=e.createShaderCondition,_.parseXMLFromString=e.parseXMLFromString,c._createInputElement=x._createInputElement,e.EnvConfig.load=d.prototype.load,d.prototype.load=L.prototype.load,d.prototype._loadImage=C.prototype._loadImage,F.__init__(),f._baseClass=F))},e.getUrlEncode=function(i,e){return-1!=i.indexOf(".fnt")?"utf8":"arraybuffer"==e?"":"ascii"},e.downLoadFile=function(i,e,n,t){void 0===e&&(e=""),void 0===t&&(t="ascii");w.getFileInfo(i)?null!=n&&n.runWith([0]):w.downLoadFile(i,e,n,t)},e.remove=function(i,e){w.deleteFile("",i,e,"",0)},e.removeAll=function(){w.deleteAll()},e.hasNativeFile=function(i){return w.isLocalNativeFile(i)},e.getFileInfo=function(i){return w.getFileInfo(i)},e.getFileList=function(){return w.filesListObj},e.exitMiniProgram=function(){e.window.wx.exitMiniProgram()},e.onMkdirCallBack=function(i,e){i||(w.filesListObj=JSON.parse(e.data))},e.pixelRatio=function(){if(!e.EnvConfig.pixelRatioInt)try{return e.EnvConfig.pixelRatioInt=e.systemInfo.pixelRatio,e.systemInfo.pixelRatio}catch(i){}return e.EnvConfig.pixelRatioInt},e.createElement=function(n){if("canvas"==n){var t;return 1==e.idx?e.isZiYu?(t=sharedCanvas).style={}:t=i.canvas:t=i.wx.createCanvas(),e.idx++,t}if("textarea"==n||"input"==n)return e.onCreateInput(n);if("div"==n){var o=e._preCreateElement(n);return o.contains=function(i){return null},o.removeChild=function(i){},o}return e._preCreateElement(n)},e.onCreateInput=function(i){var n=e._preCreateElement(i);return n.focus=x.wxinputFocus,n.blur=x.wxinputblur,n.style={},n.value=0,n.parentElement={},n.placeholder={},n.type={},n.setColor=function(i){},n.setType=function(i){},n.setFontFace=function(i){},n.addEventListener=function(i){},n.contains=function(i){return null},n.removeChild=function(i){},n},e.createShaderCondition=function(i){var e=this;return function(){return e[i.replace("this.","")]}},e.EnvConfig=null,e.window=null,e._preCreateElement=null,e._inited=!1,e.systemInfo=null,e.isZiYu=!1,e.isPosMsgYu=!1,e.autoCacheFile=!0,e.minClearSize=5242880,e.parseXMLFromString=function(e){var n;e=e.replace(/>\s+<");try{n=(new i.Parser.DOMParser).parseFromString(e,"text/xml")}catch(i){throw"需要引入xml解析库文件"}return n},e.idx=1,t(e,["nativefiles",function(){return this.nativefiles=["layaNativeDir","wxlocal"]}]),e}(),w=function(){function i(){}return o(i,"laya.wx.mini.MiniFileMgr"),i.isLocalNativeFile=function(i){for(var e=0,n=y.nativefiles.length;e=52428800&&(e.size>y.minClearSize&&(y.minClearSize=e.size),i.onClearCacheRes()),i.deleteFile(r,n,t,o,e.size)},fail:function(i){null!=t&&t.runWith([1,i])}}):null!=t&&t.runWith([0]):i.fs.getFileInfo({filePath:e,success:function(a){u+4194304+a.size>=52428800&&(a.size>y.minClearSize&&(y.minClearSize=a.size),i.onClearCacheRes()),i.fs.copyFile({srcPath:e,destPath:s,success:function(e){i.onSaveFile(n,r,!0,o,t,a.size)},fail:function(i){null!=t&&t.runWith([1,i])}})},fail:function(i){null!=t&&t.runWith([1,i])}})},i.onClearCacheRes=function(){var e=y.minClearSize,n=[];for(var t in i.filesListObj)n.push(i.filesListObj[t]);i.sortOn(n,"time",16);for(var o=0,a=1,r=n.length;a=e)break;o+=l.size,i.deleteFile("",l.readyUrl)}},i.sortOn=function(i,e,n){return void 0===n&&(n=0),16==n?i.sort(function(i,n){return i[e]-n[e]}):18==n?i.sort(function(i,n){return n[e]-i[e]}):i.sort(function(i,n){return i[e]-n[e]})},i.getFileNativePath=function(i){return laya.wx.mini.MiniFileMgr.fileNativeDir+"/"+i},i.deleteFile=function(e,n,t,o,a){void 0===n&&(n=""),void 0===o&&(o=""),void 0===a&&(a=0);var r=i.getFileInfo(n),l=i.getFileNativePath(r.md5);i.fs.unlink({filePath:l,success:function(r){var l=""!=e;if(""!=e){var s=i.getFileNativePath(e);i.fs.copyFile({srcPath:e,destPath:s,success:function(a){i.onSaveFile(n,e,l,o,t,a.size)},fail:function(i){null!=t&&t.runWith([1,i])}})}else i.onSaveFile(n,e,l,o,t,a)},fail:function(i){}})},i.deleteAll=function(){var e=[];for(var n in i.filesListObj)e.push(i.filesListObj[n]);for(var t=1,o=e.length;t0&&this.loops--,this.startTime=0,this.play()},t.play=function(){this.isStopped=!1,m.addChannel(this),this._audio.play()},t.stop=function(){this.isStopped=!0,m.removeChannel(this),this.completeHandler=null,this._audio&&(this._audio.pause(),this._audio.offEnded(null),this._audio=null,this._miniSound=null,this._onEnd=null)},t.pause=function(){this.isStopped=!0,this._audio.pause()},t.resume=function(){this._audio&&(this.isStopped=!1,m.addChannel(this),this._audio.play())},a(0,t,"autoplay",function(){return this._audio.autoplay},function(i){this._audio.autoplay=i}),a(0,t,"position",function(){return this._audio?this._audio.currentTime:0}),a(0,t,"duration",function(){return this._audio?this._audio.duration:0}),a(0,t,"loop",function(){return this._audio.loop},function(i){this._audio.loop=i}),a(0,t,"volume",function(){return this._audio?this._audio.volume:1},function(i){this._audio&&(this._audio.volume=i)}),e.bindToThis=function(i,e){return i.bind(e)},e}()}(window,document,Laya),"function"==typeof define&&define.amd&&define("laya.core",["require","exports"],function(i,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});for(var n in Laya){var t=Laya[n];t&&t.__isclass&&(e[n]=t)}}); -------------------------------------------------------------------------------- /bin/libs/min/laya.pathfinding.min.js: -------------------------------------------------------------------------------- 1 | !function(t,e,i){var n=(i.un,i.uns,i.static,i.class),s=(i.getset,i.__newvec,function(){function t(){}return n(t,"PathFinding.core.DiagonalMovement"),t.Always=1,t.Never=2,t.IfAtMostOneObstacle=3,t.OnlyWhenNoObstacles=4,t}()),a=function(){function t(t,e,i){this.width=0,this.height=0,this.nodes=null;var n=0;"number"==typeof t?n=t:(e=t.length,n=t[0].length,i=t),this.width=n,this.height=e,this.nodes=this._buildNodes(n,e,i)}n(t,"PathFinding.core.Grid");var e=t.prototype;return e._buildNodes=function(t,e,i){var n=0,s=0,a=[];for(n=0;n=0&&t=0&&e-l&&(u-=l,t+=o),d0&&(new Date).getTime()-h>1e3*o.timeLimit)return 1/0;var f=e+l(t,c)*o.weight;if(f>i)return f;if(t==c)return n[a]=[t.x,t.y],t;var p,g=0,b=0,m=0,v=s.getNeighbors(t,o.diagonalMovement);for(m=0,g=1/0;p=v[m];++m){if(o.trackRecursion&&(p.retainCount=p.retainCount+1||1,1!=p.tested&&(p.tested=!0)),(b=d(p,e+u(t,p),i,n,a+1))instanceof PathFinding.core.Node)return n[a]=[t.x,t.y],b;o.trackRecursion&&0==--p.retainCount&&(p.tested=!1),be?1:0}}n(t,"PathFinding.libs.HeapFunction");var e=t.prototype;return e.insort=function(t,e,i,n,s){var a=NaN;if(null==i&&(i=0),null==s&&(s=this.defaultCmp),i<0)throw new Error("lo must be non-negative");for(null==n&&(n=t.length);ii;0<=i?h++:h--)a.push(h);return a}.apply(this).reverse(),s=[],r=0,l=n.length;rh;0<=h?++d:--d)l.push(this.heappop(t,i));return l},e._siftdown=function(t,e,i,n){var s,a,o=0;for(null==n&&(n=this.defaultCmp),s=t[i];i>e&&(o=i-1>>1,a=t[o],n(s,a)<0);)t[i]=a,i=o;return t[i]=s},e._siftup=function(t,e,i){var n,s=0,a=0,o=0,r=0;for(null==i&&(i=this.defaultCmp),a=t.length,r=e,n=t[e],s=2*e+1;sthis.minEmissionTime;)this._frameTime-=this.minEmissionTime,this.emit()},n(0,e,"particleTemplate",null,function(t){this._particleTemplate=t}),n(0,e,"emissionRate",function(){return this._emissionRate},function(t){t<=0||(this._emissionRate=t,t>0&&(this.minEmissionTime=1/t))}),t}()),g=function(){function t(){this.position=null,this.velocity=null,this.startColor=null,this.endColor=null,this.sizeRotation=null,this.radius=null,this.radian=null,this.durationAddScale=NaN,this.time=NaN}return r(t,"laya.particle.ParticleData"),t.Create=function(e,i,a,r){var n=new t;n.position=i,c.scaleVector3(a,e.emitterVelocitySensitivity,t._tempVelocity);var s=c.lerp(e.minHorizontalVelocity,e.maxHorizontalVelocity,Math.random()),o=Math.random()*Math.PI*2;t._tempVelocity[0]+=s*Math.cos(o),t._tempVelocity[2]+=s*Math.sin(o),t._tempVelocity[1]+=c.lerp(e.minVerticalVelocity,e.maxVerticalVelocity,Math.random()),n.velocity=t._tempVelocity,n.startColor=t._tempStartColor,n.endColor=t._tempEndColor;var l=0;if(e.disableColor)for(l=0;l<4;l++)n.startColor[l]=1,n.endColor[l]=1;else if(e.colorComponentInter)for(l=0;l<4;l++)n.startColor[l]=c.lerp(e.minStartColor[l],e.maxStartColor[l],Math.random()),n.endColor[l]=c.lerp(e.minEndColor[l],e.maxEndColor[l],Math.random());else c.lerpVector4(e.minStartColor,e.maxStartColor,Math.random(),n.startColor),c.lerpVector4(e.minEndColor,e.maxEndColor,Math.random(),n.endColor);n.sizeRotation=t._tempSizeRotation;var h=Math.random();n.sizeRotation[0]=c.lerp(e.minStartSize,e.maxStartSize,h),n.sizeRotation[1]=c.lerp(e.minEndSize,e.maxEndSize,h),n.sizeRotation[2]=c.lerp(e.minRotateSpeed,e.maxRotateSpeed,Math.random()),n.radius=t._tempRadius;var u=Math.random();n.radius[0]=c.lerp(e.minStartRadius,e.maxStartRadius,u),n.radius[1]=c.lerp(e.minEndRadius,e.maxEndRadius,u),n.radian=t._tempRadian,n.radian[0]=c.lerp(e.minHorizontalStartRadian,e.maxHorizontalStartRadian,Math.random()),n.radian[1]=c.lerp(e.minVerticalStartRadian,e.maxVerticalStartRadian,Math.random());var d=e.useEndRadian;return n.radian[2]=d?c.lerp(e.minHorizontalEndRadian,e.maxHorizontalEndRadian,Math.random()):n.radian[0],n.radian[3]=d?c.lerp(e.minVerticalEndRadian,e.maxVerticalEndRadian,Math.random()):n.radian[1],n.durationAddScale=e.ageAddScale*Math.random(),n.time=r,n},a(t,["_tempVelocity",function(){return this._tempVelocity=new Float32Array(3)},"_tempStartColor",function(){return this._tempStartColor=new Float32Array(4)},"_tempEndColor",function(){return this._tempEndColor=new Float32Array(4)},"_tempSizeRotation",function(){return this._tempSizeRotation=new Float32Array(3)},"_tempRadius",function(){return this._tempRadius=new Float32Array(2)},"_tempRadian",function(){return this._tempRadian=new Float32Array(4)}]),t}(),R=(function(){function t(t,e,i){this._templet=null,this._timeBetweenParticles=NaN,this._previousPosition=null,this._timeLeftOver=0,this._tempVelocity=new Float32Array([0,0,0]),this._tempPosition=new Float32Array([0,0,0]),this._templet=t,this._timeBetweenParticles=1/e,this._previousPosition=i}r(t,"laya.particle.ParticleEmitter");t.prototype.update=function(t,e){if((t/=1e3)>0){c.subtractVector3(e,this._previousPosition,this._tempVelocity),c.scaleVector3(this._tempVelocity,1/t,this._tempVelocity);for(var i=this._timeLeftOver+t,a=-this._timeLeftOver;i>this._timeBetweenParticles;)a+=this._timeBetweenParticles,i-=this._timeBetweenParticles,c.lerpVector3(this._previousPosition,e,a/t,this._tempPosition),this._templet.addParticleArray(this._tempPosition,this._tempVelocity);this._timeLeftOver=i}this._previousPosition[0]=e[0],this._previousPosition[1]=e[1],this._previousPosition[2]=e[2]}}(),function(){function t(){this.textureName=null,this.textureCount=1,this.maxPartices=100,this.duration=1,this.ageAddScale=0,this.emitterVelocitySensitivity=1,this.minStartSize=100,this.maxStartSize=100,this.minEndSize=100,this.maxEndSize=100,this.minHorizontalVelocity=0,this.maxHorizontalVelocity=0,this.minVerticalVelocity=0,this.maxVerticalVelocity=0,this.endVelocity=1,this.minRotateSpeed=0,this.maxRotateSpeed=0,this.minStartRadius=0,this.maxStartRadius=0,this.minEndRadius=0,this.maxEndRadius=0,this.minHorizontalStartRadian=0,this.maxHorizontalStartRadian=0,this.minVerticalStartRadian=0,this.maxVerticalStartRadian=0,this.useEndRadian=!0,this.minHorizontalEndRadian=0,this.maxHorizontalEndRadian=0,this.minVerticalEndRadian=0,this.maxVerticalEndRadian=0,this.colorComponentInter=!1,this.disableColor=!1,this.blendState=0,this.emitterType="null",this.emissionRate=0,this.sphereEmitterRadius=1,this.sphereEmitterVelocity=0,this.sphereEmitterVelocityAddVariance=0,this.ringEmitterRadius=30,this.ringEmitterVelocity=0,this.ringEmitterVelocityAddVariance=0,this.ringEmitterUp=2,this.gravity=new Float32Array([0,0,0]),this.minStartColor=new Float32Array([1,1,1,1]),this.maxStartColor=new Float32Array([1,1,1,1]),this.minEndColor=new Float32Array([1,1,1,1]),this.maxEndColor=new Float32Array([1,1,1,1]),this.pointEmitterPosition=new Float32Array([0,0,0]),this.pointEmitterPositionVariance=new Float32Array([0,0,0]),this.pointEmitterVelocity=new Float32Array([0,0,0]),this.pointEmitterVelocityAddVariance=new Float32Array([0,0,0]),this.boxEmitterCenterPosition=new Float32Array([0,0,0]),this.boxEmitterSize=new Float32Array([0,0,0]),this.boxEmitterVelocity=new Float32Array([0,0,0]),this.boxEmitterVelocityAddVariance=new Float32Array([0,0,0]),this.sphereEmitterCenterPosition=new Float32Array([0,0,0]),this.ringEmitterCenterPosition=new Float32Array([0,0,0]),this.positionVariance=new Float32Array([0,0,0])}return r(t,"laya.particle.ParticleSetting"),t.checkSetting=function(e){var i;for(i in t._defaultSetting)e.hasOwnProperty(i)||(e[i]=t._defaultSetting[i])},a(t,["_defaultSetting",function(){return this._defaultSetting=new t}]),t}()),S=function(){function t(){this.settings=null,this.texture=null}r(t,"laya.particle.ParticleTemplateBase");return t.prototype.addParticleArray=function(t,e){},t}(),E=function(){function t(){this.u_Duration=NaN,this.u_EndVelocity=NaN,this.u_Gravity=null,this.a_Position=null,this.a_Velocity=null,this.a_StartColor=null,this.a_EndColor=null,this.a_SizeRotation=null,this.a_Radius=null,this.a_Radian=null,this.a_AgeAddScale=NaN,this.gl_Position=null,this.v_Color=null,this.oSize=NaN,this._color=new Float32Array(4),this._position=new Float32Array(3)}r(t,"laya.particle.particleUtils.CanvasShader");var e=t.prototype;return e.getLen=function(t){return Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2])},e.ComputeParticlePosition=function(t,e,i,a){this._position[0]=t[0],this._position[1]=t[1],this._position[2]=t[2];var r=this.getLen(e),n=r*a+(r*this.u_EndVelocity-r)*a*a/2,s=NaN;s=this.getLen(e);var o=0;for(3,o=0;o<3;o++)this._position[o]=this._position[o]+e[o]/s*n*this.u_Duration,this._position[o]+=this.u_Gravity[o]*i*a;var l=c.lerp(this.a_Radius[0],this.a_Radius[1],a),h=c.lerp(this.a_Radian[0],this.a_Radian[2],a),u=c.lerp(this.a_Radian[1],this.a_Radian[3],a),d=Math.cos(u)*l;return this._position[1]+=Math.sin(u)*l,this._position[0]+=Math.cos(h)*d,this._position[2]+=Math.sin(h)*d,new Float32Array([this._position[0],this._position[1],0,1])},e.ComputeParticleSize=function(t,e,i){return c.lerp(t,e,i)},e.ComputeParticleRotation=function(t,e){return t*e},e.ComputeParticleColor=function(t,e,i){var a=this._color;return c.lerpVector4(t,e,i,a),a[3]=a[3]*i*(1-i)*(1-i)*6.7,a},e.clamp=function(t,e,i){return ti?i:t},e.getData=function(t){t*=1+this.a_AgeAddScale;var e=this.clamp(t/this.u_Duration,0,1);this.gl_Position=this.ComputeParticlePosition(this.a_Position,this.a_Velocity,t,e);var i=this.ComputeParticleSize(this.a_SizeRotation[0],this.a_SizeRotation[1],e),a=this.ComputeParticleRotation(this.a_SizeRotation[2],t);this.v_Color=this.ComputeParticleColor(this.a_StartColor,this.a_EndColor,e);var r=new u,n=NaN;n=i/this.oSize*2,r.scale(n,n),r.rotate(a),r.setTranslate(this.gl_Position[0],-this.gl_Position[1]);var s=NaN;return s=this.v_Color[3],[this.v_Color,s,r,this.v_Color[0]*s,this.v_Color[1]*s,this.v_Color[2]*s]},t}(),V=function(){function t(){this.maxIndex=0,this.cmds=null,this.id=0}r(t,"laya.particle.particleUtils.CMDParticle");return t.prototype.setCmds=function(t){this.cmds=t,this.maxIndex=t.length-1},t}(),A=function(){function t(){}return r(t,"laya.particle.particleUtils.PicTool"),t.getCanvasPic=function(t,e){t=t.bitmap;var i=new o("2D"),a=i.getContext("2d");i.size(t.width,t.height);var r=e>>16&255,n=e>>8&255,s=255&e;if(d.isConchApp&&a.setFilter(r/255,n/255,s/255,0),a.drawImage(t.source,0,0),!d.isConchApp){for(var l=a.getImageData(0,0,i.width,i.height),h=l.data,c=0,u=h.length;c=this.settings.maxPartices&&(this._firstActiveElement=0)}},i.freeRetiredParticles=function(){for(;this._firstRetiredElement!=this._firstActiveElement;){if(this._drawCounter-this._vertices[this._firstRetiredElement*this._floatCountPerVertex*4+28]<3)break;this._firstRetiredElement++,this._firstRetiredElement>=this.settings.maxPartices&&(this._firstRetiredElement=0)}},i.addNewParticlesToVertexBuffer=function(){},i.addParticleArray=function(t,e){var i=this._firstFreeElement+1;if(i>=this.settings.maxPartices&&(i=0),i!==this._firstRetiredElement){for(var a=g.Create(this.settings,t,e,this._currentTime),r=this._firstFreeElement*this._floatCountPerVertex*4,n=0;n<4;n++){var s=0,o=0;for(s=0,o=4;s<3;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.position[s];for(s=0,o=7;s<3;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.velocity[s];for(s=0,o=10;s<4;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.startColor[s];for(s=0,o=14;s<4;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.endColor[s];for(s=0,o=18;s<3;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.sizeRotation[s];for(s=0,o=21;s<2;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.radius[s];for(s=0,o=23;s<4;s++)this._vertices[r+n*this._floatCountPerVertex+o+s]=a.radian[s];this._vertices[r+n*this._floatCountPerVertex+27]=a.durationAddScale,this._vertices[r+n*this._floatCountPerVertex+28]=a.time}this._firstFreeElement=i}},e}(),z=function(t){function e(t){this._ready=!1,this.textureList=[],this.particleList=[],this.pX=0,this.pY=0,this.activeParticles=[],this.deadParticles=[],this.iList=[],this._maxNumParticles=0,this.textureWidth=NaN,this.dTextureWidth=NaN,this.colorChange=!0,this.step=1/60,this.canvasShader=new E,e.__super.call(this),this.settings=t,this._maxNumParticles=t.maxPartices,this.texture=new p,this.texture.on("loaded",this,this._textureLoaded),this.texture.load(t.textureName)}r(e,"laya.particle.ParticleTemplateCanvas",S);var i=e.prototype;return i._textureLoaded=function(t){this.setTexture(this.texture),this._ready=!0},i.clear=function(t){void 0===t&&(t=!0),this.deadParticles.length=0,this.activeParticles.length=0,this.textureList.length=0},i.setTexture=function(t){this.texture=t,this.textureWidth=t.width,this.dTextureWidth=1/this.textureWidth,this.pX=.5*-t.width,this.pY=.5*-t.height,this.textureList=e.changeTexture(t,this.textureList),this.particleList.length=0,this.deadParticles.length=0,this.activeParticles.length=0},i._createAParticleData=function(t,e){this.canvasShader.u_EndVelocity=this.settings.endVelocity,this.canvasShader.u_Gravity=this.settings.gravity,this.canvasShader.u_Duration=this.settings.duration;var i;i=g.Create(this.settings,t,e,0),this.canvasShader.a_Position=i.position,this.canvasShader.a_Velocity=i.velocity,this.canvasShader.a_StartColor=i.startColor,this.canvasShader.a_EndColor=i.endColor,this.canvasShader.a_SizeRotation=i.sizeRotation,this.canvasShader.a_Radius=i.radius,this.canvasShader.a_Radian=i.radian,this.canvasShader.a_AgeAddScale=i.durationAddScale,this.canvasShader.oSize=this.textureWidth;var a=new V,r=0,n=this.settings.duration/(1+i.durationAddScale),s=[];for(r=0;r0&&(i=this.deadParticles.pop(),this.iList[i.id]=0,this.activeParticles.push(i))}},i.advanceTime=function(t){if(void 0===t&&(t=1),this._ready){var e,i=this.activeParticles,a=this.deadParticles,r=0,n=i.length,s=0,o=this.iList;for(r=n-1;r>-1;r--)(s=o[(e=i[r]).id])>=e.maxIndex?(s=0,i.splice(r,1),a.push(e)):s+=1,o[e.id]=s}},i.render=function(t,e,i){this._ready&&(this.activeParticles.length<1||this.textureList.length<2||(this.settings.disableColor?this.noColorRender(t,e,i):this.canvasRender(t,e,i)))},i.noColorRender=function(t,e,i){var a,r,n=this.activeParticles,s=0,o=n.length,l=NaN,h=this.pX,c=this.pY,u=2*-h,d=2*-c,m=0,_=(this.textureList,this.iList),f=NaN;for(t.translate(e,i),f=t.ctx.globalAlpha,s=0;s.01&&(t.setAlpha(p*r[3]),t.drawTexture(_[0],h,c,u,d)),r[4]>.01&&(t.setAlpha(p*r[4]),t.drawTexture(_[1],h,c,u,d)),r[5]>.01&&(t.setAlpha(p*r[5]),t.drawTexture(_[2],h,c,u,d)),t.restore()));t.setAlpha(p),t.translate(-e,-i),t.blendMode(n)},e.changeTexture=function(t,e,i){return e||(e=[]),e.length=0,i&&i.disableColor?e.push(t,t,t):v.copyArray(e,A.getRGBPic(t)),e},e}(),b=function(t){function e(t){this._vertexBuffer2D=null,this._indexBuffer2D=null,this.x=0,this.y=0,this._blendFn=null,this._startTime=0,this.sv=new F,e.__super.call(this,t);var a=this;i.loader.load(this.settings.textureName,l.create(null,function(t){t.bitmap.enableMerageInAtlas=!1,a.texture=t})),this.sv.u_Duration=this.settings.duration,this.sv.u_Gravity=this.settings.gravity,this.sv.u_EndVelocity=this.settings.endVelocity,this._blendFn=s.fns[t.blendState],this.initialize(),this._vertexBuffer=this._vertexBuffer2D=y.create(-1,35048),this._indexBuffer=this._indexBuffer2D=h.create(35044),this.loadContent()}r(e,"laya.particle.ParticleTemplate2D",t);var a=e.prototype;return i.imps(a,{"laya.webgl.submit.ISubmit":!0}),a.getRenderType=function(){return-111},a.releaseRender=function(){},a.addParticleArray=function(e,i){e[0]+=this.x,e[1]+=this.y,t.prototype.addParticleArray.call(this,e,i)},a.loadContent=function(){for(var t=new Uint16Array(6*this.settings.maxPartices),e=0;e0&&(this._vertexBuffer2D.setNeedUpload(),this._vertexBuffer2D.subUpload(0,0,4*this._firstFreeElement*this._floatCountPerVertex*4))),this._firstNewElement=this._firstFreeElement},a.renderSubmit=function(){if(this.texture&&this.texture.loaded){if(this.update(i.timer.delta),this.sv.u_CurrentTime=this._currentTime,this._firstNewElement!=this._firstFreeElement&&this.addNewParticlesToVertexBuffer(),this.blend(),this._firstActiveElement!=this._firstFreeElement){C.mainContext;this._vertexBuffer2D.bind(this._indexBuffer2D),this.sv.u_texture=this.texture.source,this.sv.upload(),this._firstActiveElement0&&C.mainContext.drawElements(4,6*this._firstFreeElement,5123,0)),f.drawCall++}this._drawCounter++}return 1},a.blend=function(){if(s.activeBlendFunction!==this._blendFn){var t=C.mainContext;t.enable(3042),this._blendFn(t),s.activeBlendFunction=this._blendFn}},a.dispose=function(){this._vertexBuffer2D.dispose(),this._indexBuffer2D.dispose()},e.activeBlendType=-1,e}(w),F=function(t){function e(){this.a_CornerTextureCoordinate=[4,5126,!1,116,0],this.a_Position=[3,5126,!1,116,16],this.a_Velocity=[3,5126,!1,116,28],this.a_StartColor=[4,5126,!1,116,40],this.a_EndColor=[4,5126,!1,116,56],this.a_SizeRotation=[3,5126,!1,116,72],this.a_Radius=[2,5126,!1,116,84],this.a_Radian=[4,5126,!1,116,92],this.a_AgeAddScale=[1,5126,!1,116,108],this.a_Time=[1,5126,!1,116,112],this.u_CurrentTime=NaN,this.u_Duration=NaN,this.u_Gravity=null,this.u_EndVelocity=NaN,this.u_texture=null,e.__super.call(this,0,0)}r(e,"laya.particle.shader.value.ParticleShaderValue",x);return e.prototype.upload=function(){this.refresh(),e.pShader.upload(this)},a(e,["pShader",function(){return this.pShader=new N}]),e}(),N=(function(e){function a(t){this._matrix4=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],this._particleTemplate=null,this._canvasTemplate=null,this._emitter=null,this.autoPlay=!0,a.__super.call(this),t&&this.setParticleSetting(t)}r(a,"laya.particle.Particle2D",e);var s=a.prototype;s.load=function(t){i.loader.load(t,l.create(this,this.setParticleSetting),null,"json")},s.setParticleSetting=function(e){var a=this;if(!e)return this.stop();if(R.checkSetting(e),t.ConchParticleTemplate2D&&!d.isWebGL||(this.customRenderEnable=!0),d.isWebGL)this._particleTemplate=new b(e),this.graphics._saveToCmd(d.context._drawParticle,[this._particleTemplate]);else{if(d.isConchApp&&t.ConchParticleTemplate2D){this._particleTemplate=new ConchParticleTemplate2D;var r=this;return i.loader.load(e.textureName,l.create(null,function(t){r._particleTemplate.texture=t,r._particleTemplate.settings=e,d.isConchNode?r.graphics.drawParticle(r._particleTemplate):r.graphics._saveToCmd(d.context._drawParticle,[a._particleTemplate])})),this._emitter={start:function(){}},this.play=this._particleTemplate.play.bind(this._particleTemplate),this.stop=this._particleTemplate.stop.bind(this._particleTemplate),void(this.autoPlay&&this.play())}this._particleTemplate=this._canvasTemplate=new z(e)}this._emitter?this._emitter.template=this._particleTemplate:this._emitter=new T(this._particleTemplate),this.autoPlay&&(this.emitter.start(),this.play())},s.play=function(){this.timer.frameLoop(1,this,this._loop)},s.stop=function(){this.timer.clear(this,this._loop)},s._loop=function(){this.advanceTime(1/60)},s.advanceTime=function(t){void 0===t&&(t=1),this._canvasTemplate&&this._canvasTemplate.advanceTime(t),this._emitter&&this._emitter.advanceTime(t)},s.customRender=function(t,e,i){if(d.isWebGL){this._matrix4[0]=t.ctx._curMat.a,this._matrix4[1]=t.ctx._curMat.b,this._matrix4[4]=t.ctx._curMat.c,this._matrix4[5]=t.ctx._curMat.d,this._matrix4[12]=t.ctx._curMat.tx,this._matrix4[13]=t.ctx._curMat.ty;this._particleTemplate.sv.u_mmat=this._matrix4}this._canvasTemplate&&this._canvasTemplate.render(t,e,i)},s.destroy=function(t){void 0===t&&(t=!0),this._particleTemplate instanceof laya.particle.ParticleTemplate2D&&this._particleTemplate.dispose(),e.prototype.destroy.call(this,t)},n(0,s,"url",null,function(t){this.load(t)}),n(0,s,"emitter",function(){return this._emitter})}(_),function(t){function e(){e.__super.call(this,e.vs,e.ps,"ParticleShader")}return r(e,"laya.particle.shader.ParticleShader",m),a(e,["vs",function(){return this.vs="attribute vec4 a_CornerTextureCoordinate;\nattribute vec3 a_Position;\nattribute vec3 a_Velocity;\nattribute vec4 a_StartColor;\nattribute vec4 a_EndColor;\nattribute vec3 a_SizeRotation;\nattribute vec2 a_Radius;\nattribute vec4 a_Radian;\nattribute float a_AgeAddScale;\nattribute float a_Time;\n\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\n\nuniform float u_CurrentTime;\nuniform float u_Duration;\nuniform float u_EndVelocity;\nuniform vec3 u_Gravity;\n\n#ifdef PARTICLE3D\n uniform mat4 u_WorldMat;\n uniform mat4 u_View;\n uniform mat4 u_Projection;\n uniform vec2 u_ViewportScale;\n#else\n uniform vec2 size;\n uniform mat4 mmat;\n uniform mat4 u_mmat;\n#endif\n\nvec4 ComputeParticlePosition(in vec3 position, in vec3 velocity,in float age,in float normalizedAge)\n{\n\n float startVelocity = length(velocity);//起始标量速度\n float endVelocity = startVelocity * u_EndVelocity;//结束标量速度\n\n float velocityIntegral = startVelocity * normalizedAge +(endVelocity - startVelocity) * normalizedAge *normalizedAge/2.0;//计算当前速度的标量(单位空间),vt=v0*t+(1/2)*a*(t^2)\n \n vec3 addPosition = normalize(velocity) * velocityIntegral * u_Duration;//计算受自身速度影响的位置,转换标量到矢量 \n addPosition += u_Gravity * age * normalizedAge;//计算受重力影响的位置\n \n float radius=mix(a_Radius.x, a_Radius.y, normalizedAge); //计算粒子受半径和角度影响(无需计算角度和半径时,可用宏定义优化屏蔽此计算)\n float radianHorizontal =mix(a_Radian.x,a_Radian.z,normalizedAge);\n float radianVertical =mix(a_Radian.y,a_Radian.w,normalizedAge);\n \n float r =cos(radianVertical)* radius;\n addPosition.y += sin(radianVertical) * radius;\n\t\n addPosition.x += cos(radianHorizontal) *r;\n addPosition.z += sin(radianHorizontal) *r;\n \n #ifdef PARTICLE3D\n position+=addPosition;\n return u_Projection*u_View*u_WorldMat*(vec4(position, 1.0));\n #else\n addPosition.y=-addPosition.y;//2D粒子位置更新需要取负,2D粒子坐标系Y轴正向朝上\n position+=addPosition;\n return vec4(position,1.0);\n #endif\n}\n\nfloat ComputeParticleSize(in float startSize,in float endSize, in float normalizedAge)\n{ \n float size = mix(startSize, endSize, normalizedAge);\n \n\t#ifdef PARTICLE3D\n //Project the size into screen coordinates.\n return size * u_Projection[1][1];\n\t#else\n\t return size;\n\t#endif\n}\n\nmat2 ComputeParticleRotation(in float rot,in float age)\n{ \n float rotation =rot * age;\n //计算2x2旋转矩阵.\n float c = cos(rotation);\n float s = sin(rotation);\n return mat2(c, -s, s, c);\n}\n\nvec4 ComputeParticleColor(in vec4 startColor,in vec4 endColor,in float normalizedAge)\n{\n\tvec4 color=mix(startColor,endColor,normalizedAge);\n //硬编码设置,使粒子淡入很快,淡出很慢,6.7的缩放因子把置归一在0到1之间,可以谷歌x*(1-x)*(1-x)*6.7的制图表\n color.a *= normalizedAge * (1.0-normalizedAge) * (1.0-normalizedAge) * 6.7;\n \n return color;\n}\n\nvoid main()\n{\n float age = u_CurrentTime - a_Time;\n age *= 1.0 + a_AgeAddScale;\n float normalizedAge = clamp(age / u_Duration,0.0,1.0);\n gl_Position = ComputeParticlePosition(a_Position, a_Velocity, age, normalizedAge);//计算粒子位置\n float pSize = ComputeParticleSize(a_SizeRotation.x,a_SizeRotation.y, normalizedAge);\n mat2 rotation = ComputeParticleRotation(a_SizeRotation.z, age);\n\t\n #ifdef PARTICLE3D\n\tgl_Position.xy += (rotation*a_CornerTextureCoordinate.xy) * pSize * u_ViewportScale;\n #else\n mat4 mat=u_mmat*mmat;\n gl_Position=vec4((mat*gl_Position).xy,0.0,1.0);\n\tgl_Position.xy += (rotation*a_CornerTextureCoordinate.xy) * pSize*vec2(mat[0][0],mat[1][1]);\n gl_Position=vec4((gl_Position.x/size.x-0.5)*2.0,(0.5-gl_Position.y/size.y)*2.0,0.0,1.0);\n #endif\n \n v_Color = ComputeParticleColor(a_StartColor,a_EndColor, normalizedAge);\n v_TextureCoordinate =a_CornerTextureCoordinate.zw;\n}\n\n"},"ps",function(){return this.ps="#ifdef FSHIGHPRECISION\nprecision highp float;\n#else\nprecision mediump float;\n#endif\n\nvarying vec4 v_Color;\nvarying vec2 v_TextureCoordinate;\nuniform sampler2D u_texture;\n\nvoid main()\n{\t\n\tgl_FragColor=texture2D(u_texture,v_TextureCoordinate)*v_Color;\n\tgl_FragColor.xyz *= v_Color.w;\n}"}]),e}())}(window,document,Laya),"function"==typeof define&&define.amd&&define("laya.core",["require","exports"],function(t,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0});for(var i in Laya){var a=Laya[i];a&&a.__isclass&&(e[i]=a)}}); -------------------------------------------------------------------------------- /bin/libs/min/laya.tiledmap.min.js: -------------------------------------------------------------------------------- 1 | !function(t,i,e){e.un,e.uns,e.static;var r=e.class,h=e.getset,s=(e.__newvec,laya.utils.Browser),a=laya.resource.HTMLCanvas,o=(laya.utils.Handler,laya.net.Loader),n=laya.maths.Point,l=laya.maths.Rectangle,_=laya.renders.Render,p=laya.renders.RenderContext,c=laya.display.Sprite,m=laya.resource.Texture,d=function(){function t(){this._jsonData=null,this._tileTexSetArr=[],this._texArray=[],this._x=0,this._y=0,this._width=0,this._height=0,this._mapW=0,this._mapH=0,this._mapTileW=0,this._mapTileH=0,this._mapSprite=null,this._layerArray=[],this._renderLayerArray=[],this._gridArray=[],this._showGridKey=!1,this._totalGridNum=0,this._gridW=0,this._gridH=0,this._gridWidth=450,this._gridHeight=450,this._jsonLoader=null,this._loader=null,this._tileSetArray=[],this._currTileSet=null,this._completeHandler=null,this._index=0,this._animationDic={},this._properties=null,this._tileProperties={},this._tileProperties2={},this._orientation="orthogonal",this._renderOrder="right-down",this._colorArray=["FF","00","33","66"],this._scale=1,this._pivotScaleX=.5,this._pivotScaleY=.5,this._centerX=0,this._centerY=0,this._viewPortX=0,this._viewPortY=0,this._viewPortWidth=0,this._viewPortHeight=0,this._enableLinear=!0,this._resPath=null,this._pathArray=null,this._limitRange=!1,this._fastDirty=!0,this.autoCache=!0,this.autoCacheType="normal",this.enableMergeLayer=!1,this.removeCoveredTile=!1,this.showGridTextureCount=!1,this.antiCrack=!0,this.cacheAllAfterInit=!1,this._texutreStartDic={},this._rect=new l,this._paddingRect=new l,this._mapRect=new i,this._mapLogicRect=new i,this._mapLastRect=new i,this._mapSprite=new c}var i,s,n;r(t,"laya.map.TiledMap");var d=t.prototype;return d.createMap=function(t,i,e,r,h,s,a){void 0===s&&(s=!0),void 0===a&&(a=!1),this._enableLinear=s,this._limitRange=a,this._rect.x=i.x,this._rect.y=i.y,this._rect.width=i.width,this._rect.height=i.height,this._viewPortWidth=i.width/this._scale,this._viewPortHeight=i.height/this._scale,this._completeHandler=e,r?this._paddingRect.copyFrom(r):this._paddingRect.setTo(0,0,0,0),h&&(this._gridWidth=h.x,this._gridHeight=h.y);var n=t.lastIndexOf("/");n>-1?(this._resPath=t.substr(0,n),this._pathArray=this._resPath.split("/")):(this._resPath="",this._pathArray=[]),this._jsonLoader=new o,this._jsonLoader.once("complete",this,this.onJsonComplete),this._jsonLoader.load(t,"json",!1)},d.onJsonComplete=function(t){var i=this._jsonData=t;this._properties=i.properties,this._orientation=i.orientation,this._renderOrder=i.renderorder,this._mapW=i.width,this._mapH=i.height,this._mapTileW=i.tilewidth,this._mapTileH=i.tileheight,this._width=this._mapTileW*this._mapW,this._height=this._mapTileH*this._mapH,"staggered"==this._orientation&&(this._height=(.5+.5*this._mapH)*this._mapTileH),this._mapLastRect.top=this._mapLastRect.bottom=this._mapLastRect.left=this._mapLastRect.right=-1;var e,r,h=i.tilesets,a=0;for(a=0;a0){r=this._currTileSet=this._tileSetArray.shift(),this._loader=new o,this._loader.once("complete",this,this.onTextureComplete);var u=this.mergePath(this._resPath,r.image);this._loader.load(u,"image",!1)}},d.mergePath=function(t,i){var e="",r=i.split("/"),h=0,s=0;for(s=r.length-1;s>=0;s--)".."==r[s]&&h++;if(0==h)return e=this._pathArray.length>0?t+"/"+i:i;var a=this._pathArray.length-h;for(a<0&&console.log("[error]path does not exist",this._pathArray,r,t,i),s=0;s0){e=this._currTileSet=this._tileSetArray.shift(),this._loader.once("complete",this,this.onTextureComplete);var d=this.mergePath(this._resPath,e.image);this._loader.load(d,"image",!1)}else this._currTileSet=null,this.initMap()},d.adptTexture=function(t){if(t){var i=t.uv[0],e=t.uv[2],r=t.uv[1],h=t.uv[7],s=1/t.bitmap.width,a=1/t.bitmap.height;t.uv[0]=t.uv[6]=i+s,t.uv[2]=t.uv[4]=e-s,t.uv[1]=t.uv[3]=r+a,t.uv[5]=t.uv[7]=h-a}},d.initMap=function(){var t=0,i=0;for(var r in this._animationDic){var h=this._animationDic[r],s=0;s=this._texutreStartDic[h.image];var a=this.getTexture(parseInt(r)+s);if(h.mAniIdArray.length>0){for(a.textureArray=[],a.durationTimeArray=h.mDurationTimeArray,a.isAnimation=!0,a.animationTotalTime=0,t=0,i=a.durationTimeArray.length;t=0;i--)(t=this._layerArray[i]._mapData)&&(this.removeCoverd(t,e),this.collectCovers(t,e,i))},d.removeCoverd=function(t,i){var e=0,r=0;for(r=t.length,e=0;e0&&this.getTileUserData(s-1,"type",0)>0&&(i[r]=s)},d.getTexture=function(t){return t0&&(t.updateAloneObject(),t.pos(-this._viewPortX,-this._viewPortY))},d.updateViewPort=function(){this._fastDirty=!1;var t=this._rect.width*this._pivotScaleX,i=this._rect.height*this._pivotScaleY;this._centerX=this._rect.x+t,this._centerY=this._rect.y+i;var e=!1,r=this._viewPortX;if(this._viewPortX=this._centerX-t/this._scale,r!=this._viewPortX?e=!0:r=this._viewPortY,this._viewPortY=this._centerY-i/this._scale,e||r==this._viewPortY||(e=!0),this._limitRange){this._viewPortX+this._viewPortWidth>this._width&&(this._viewPortX=this._width-this._viewPortWidth);this._viewPortY+this._viewPortHeight>this._height&&(this._viewPortY=this._height-this._viewPortHeight),this._viewPortX<0&&(this._viewPortX=0),this._viewPortY<0&&(this._viewPortY=0)}var h=this._paddingRect;this._mapLogicRect.top=(this._viewPortY-h.y)/this._gridHeight,this._mapLogicRect.bottom=(this._viewPortY+this._viewPortHeight+h.height+h.y)/this._gridHeight,this._mapLogicRect.left=(this._viewPortX-h.x)/this._gridWidth,this._mapLogicRect.right=(this._viewPortX+this._viewPortWidth+h.width+h.x)/this._gridWidth,this._mapRect.top=0|this._mapLogicRect.top,this._mapRect.bottom=0|this._mapLogicRect.bottom,this._mapRect.left=0|this._mapLogicRect.left,this._mapRect.right=0|this._mapLogicRect.right,this._mapRect.top==this._mapLastRect.top&&this._mapRect.bottom==this._mapLastRect.bottom&&this._mapRect.left==this._mapLastRect.left&&this._mapRect.right==this._mapLastRect.right||(this.clipViewPort(),this._mapLastRect.top=this._mapRect.top,this._mapLastRect.bottom=this._mapRect.bottom,this._mapLastRect.left=this._mapRect.left,this._mapLastRect.right=this._mapRect.right,e=!0),e&&this.updateMapLayersPos()},d.clipViewPort=function(){var t=0,i=0,e=0,r=0;if(this._mapRect.left>this._mapLastRect.left){if((t=this._mapRect.left-this._mapLastRect.left)>0)for(r=this._mapLastRect.left;r0)for(r=this._mapRect.left;rthis._mapLastRect.right){if((i=this._mapRect.right-this._mapLastRect.right)>0)for(r=Math.max(this._mapLastRect.right+1,this._mapRect.left);r<=this._mapLastRect.right+i;r++)for(e=this._mapRect.top;e<=this._mapRect.bottom;e++)this.showGrid(r,e)}else if((t=this._mapLastRect.right-this._mapRect.right)>0)for(r=this._mapRect.right+1;r<=this._mapRect.right+t;r++)for(e=this._mapLastRect.top;e<=this._mapLastRect.bottom;e++)this.hideGrid(r,e);if(this._mapRect.top>this._mapLastRect.top){if((t=this._mapRect.top-this._mapLastRect.top)>0)for(e=this._mapLastRect.top;e0)for(e=this._mapRect.top;ethis._mapLastRect.bottom){if((i=this._mapRect.bottom-this._mapLastRect.bottom)>0)for(e=Math.max(this._mapLastRect.bottom+1,this._mapRect.top);e<=this._mapLastRect.bottom+i;e++)for(r=this._mapRect.left;r<=this._mapRect.right;r++)this.showGrid(r,e)}else if((t=this._mapLastRect.bottom-this._mapRect.bottom)>0)for(e=this._mapRect.bottom+1;e<=this._mapRect.bottom+t;e++)for(r=this._mapLastRect.left;r<=this._mapLastRect.right;r++)this.hideGrid(r,e)},d.showGrid=function(t,i){if(!(t<0||t>=this._gridW||i<0||i>=this._gridH)){var e,r=0,h=this._gridArray[i][t];if(null==h)h=this.getGridArray(t,i);else for(r=0;r0&&e.show()}}},d.cacheAllGrid=function(){var t,i=0,e=0;for(i=0;i=P&&(d=P-1),u<0&&(l=0),u>=P&&(u=P-1),e.zOrder=this._totalGridNum*w+i*this._gridW+t,r=d;rc&&S<=m&&v.drawTileTexture(e,H,L)&&e.drawImageNum++}break;case"staggered":for(e.zOrder=w*this._totalGridNum+i*this._gridW+t,r=n;r=n;r--)for(h=a;h=a;h--)v.drawTileTexture(e,h,r)&&e.drawImageNum++;break;case"left-up":for(e.zOrder=w*this._totalGridNum+(this._gridH-1-i)*this._gridW+(this._gridW-1-t),r=l-1;r>=n;r--)for(h=o-1;h>=a;h--)v.drawTileTexture(e,h,r)&&e.drawImageNum++}}e.isHaveAnimation||(e.autoSize=!0,this.autoCache&&(e.cacheAs=this.autoCacheType),e.autoSize=!1),this.enableMergeLayer?f&&f.drawImageNum>0&&y&&(y.addChild(f),f.visible=!1,f.show()):(e.drawImageNum>0&&(v.addChild(e),e.visible=!1,e.show()),this._showGridKey&&e.graphics.drawRect(0,0,_,p,null,A))}this.enableMergeLayer&&this.showGridTextureCount&&f&&f.graphics.fillText(f.drawImageNum+"",20,20,null,"#ff0000","left")}return s},d.hideGrid=function(t,i){if(!(t<0||t>=this._gridW||i<0||i>=this._gridH)){var e=this._gridArray[i][t];if(e)for(var r,h=0;h0&&null!=r&&r.hide()}},d.getLayerObject=function(t,i){for(var e=null,r=0;r0&&this.durationTimeArray&&this.durationTimeArray.length>0){var t=s.now();this._interval=t-this._preFrameTime,this._preFrameTime=t,this._interval>this.animationTotalTime&&(this._interval=this._interval%this.animationTotalTime),this._time+=this._interval;for(var i=this.durationTimeArray[this._frameIndex];this._time>i;){this._time-=i,this._frameIndex++,(this._frameIndex>=this.durationTimeArray.length||this._frameIndex>=this.textureArray.length)&&(this._frameIndex=0);var e,r=this.textureArray[this._frameIndex];for(var h in this._aniDic)e=this._aniDic[h],this.drawTexture(e,r);i=this.durationTimeArray[this._frameIndex]}}},i.drawTexture=function(t,i){t.graphics.clear(),t.graphics.drawTexture(i.texture,i.offX,i.offY)},i.removeAniSprite=function(t){this._aniDic&&this._aniDic[t]&&(delete this._aniDic[t],this._spriteNum--,0==this._spriteNum&&e.timer.clear(this,this.animate))},i.showDebugInfo=function(){var t=null;return this._spriteNum>0&&(t="TileTextureSet::gid:"+this.gid.toString()+" 动画数:"+this._spriteNum.toString()),t},i.clearAll=function(){this.gid=-1,this.texture&&(this.texture.destroy(),this.texture=null),this.offX=0,this.offY=0,this.textureArray=null,this.durationTimeArray=null,this.isAnimation=!1,this._spriteNum=0,this._aniDic=null,this._frameIndex=0,this._preFrameTime=0,this._time=0,this._interval=0},t}(),g=function(t){function i(){this.relativeX=0,this.relativeY=0,this.isAloneObject=!1,this.isHaveAnimation=!1,this.aniSpriteArray=null,this.drawImageNum=0,this._map=null,i.__super.call(this)}r(i,"laya.map.GridSprite",t);var e=i.prototype;return e.initData=function(t,i){void 0===i&&(i=!1),this._map=t,this.isAloneObject=i},e._setDisplay=function(i){if(!i){var e=this._$P.cacheCanvas;e&&e.ctx&&(e.ctx.canvas.destroy(),e.ctx=null);var r=this._$P._filterCache;r&&(r.destroy(),r.recycle(),this._set$P("_filterCache",null)),this._$P._isHaveGlowFilter&&this._set$P("_isHaveGlowFilter",!1)}t.prototype._setDisplay.call(this,i)},e.addAniSprite=function(t){null==this.aniSpriteArray&&(this.aniSpriteArray=[]),this.aniSpriteArray.push(t)},e.show=function(){if(!this.visible){if(this.visible=!0,!this.isAloneObject){var t;(t=this.parent)&&t.showGridSprite(this)}if(!_.isWebGL&&this._map.autoCache&&(this.cacheAs=this._map.autoCacheType),null==this.aniSpriteArray)return;for(var i=0;ithis._map.viewPortWidth||this.y<0||this.y>this._map.viewPortHeight?this.hide():this.show()):this._map&&(this.x=this.relativeX,this.y=this.relativeY)},e.clearAll=function(){if(this._map&&(this._map=null),this.visible=!1,null!=this.aniSpriteArray){for(var t=0;t0&&(this._objDic={},this._dataDic={});for(var s,a=NaN,o=NaN,l=0;l=0&&i=0&&t=0?i[s]=t:i.push(t)},e.hideGridSprite=function(t){t.visible=!1},e.updateGridPos=function(){var t,i,e=0;e=(i=this._showGridList).length;for(var r=0;r0&&t.updatePos()},e.updateAloneObject=function(){var t,i,e=0;e=(i=this._aloneObjs).length;for(var r=0;r0&&t.updatePos()},e.render=function(i,e,r){var h=this._childs;this._childs=this._showGridList,t.prototype.render.call(this,i,e,r),this._childs=h},e.drawTileTexture=function(t,i,e){if(e>=0&&e=0&&i