eraser 4 年之前
當前提交
99440ca775
共有 100 個文件被更改,包括 80152 次插入0 次删除
  1. 73 0
      ShootingSun/.laya/compile.js
  2. 371 0
      ShootingSun/.laya/publish.js
  3. 189 0
      ShootingSun/.laya/publish_bdgame.js
  4. 454 0
      ShootingSun/.laya/publish_oppogame.js
  5. 342 0
      ShootingSun/.laya/publish_qqgame.js
  6. 739 0
      ShootingSun/.laya/publish_vivogame.js
  7. 435 0
      ShootingSun/.laya/publish_wxgame.js
  8. 527 0
      ShootingSun/.laya/publish_xmgame.js
  9. 66 0
      ShootingSun/.laya/web.json
  10. 84 0
      ShootingSun/.laya/wxgame.json
  11. 27 0
      ShootingSun/.vscode/launch.json
  12. 1 0
      ShootingSun/ShootingSun.laya
  13. 0 0
      ShootingSun/bin/Animation/shoot_blood.ani
  14. 0 0
      ShootingSun/bin/MainScene.json
  15. 二進制
      ShootingSun/bin/UI/ad.png
  16. 二進制
      ShootingSun/bin/UI/bg.png
  17. 二進制
      ShootingSun/bin/UI/feedback.png
  18. 二進制
      ShootingSun/bin/UI/mask.png
  19. 二進制
      ShootingSun/bin/UI/shareImg1.jpg
  20. 二進制
      ShootingSun/bin/UI/shareImg2.jpg
  21. 二進制
      ShootingSun/bin/UI/tishikuang.png
  22. 二進制
      ShootingSun/bin/dragonBone/addBlood/add_blood.png
  23. 二進制
      ShootingSun/bin/dragonBone/addBlood/add_blood.sk
  24. 二進制
      ShootingSun/bin/dragonBone/shield/hudun.png
  25. 二進制
      ShootingSun/bin/dragonBone/shield/hudun.sk
  26. 0 0
      ShootingSun/bin/fileconfig.json
  27. 9 0
      ShootingSun/bin/game.js
  28. 11 0
      ShootingSun/bin/game.json
  29. 32 0
      ShootingSun/bin/index.html
  30. 15 0
      ShootingSun/bin/index.js
  31. 2445 0
      ShootingSun/bin/js/bundle.js
  32. 3746 0
      ShootingSun/bin/libs/bytebuffer.js
  33. 2357 0
      ShootingSun/bin/libs/domparserinone.js
  34. 4209 0
      ShootingSun/bin/libs/laya.ani.js
  35. 1700 0
      ShootingSun/bin/libs/laya.bdmini.js
  36. 5184 0
      ShootingSun/bin/libs/laya.core.js
  37. 28836 0
      ShootingSun/bin/libs/laya.d3.js
  38. 4052 0
      ShootingSun/bin/libs/laya.debugtool.js
  39. 655 0
      ShootingSun/bin/libs/laya.device.js
  40. 1543 0
      ShootingSun/bin/libs/laya.html.js
  41. 267 0
      ShootingSun/bin/libs/laya.particle.js
  42. 3201 0
      ShootingSun/bin/libs/laya.physics.js
  43. 0 0
      ShootingSun/bin/libs/laya.physics3D.js
  44. 10 0
      ShootingSun/bin/libs/laya.physics3D.runtime.js
  45. 23 0
      ShootingSun/bin/libs/laya.physics3D.wasm.js
  46. 二進制
      ShootingSun/bin/libs/laya.physics3D.wasm.wasm
  47. 1710 0
      ShootingSun/bin/libs/laya.qqmini.js
  48. 1686 0
      ShootingSun/bin/libs/laya.quickgamemini.js
  49. 1604 0
      ShootingSun/bin/libs/laya.tiledmap.js
  50. 6073 0
      ShootingSun/bin/libs/laya.ui.js
  51. 1691 0
      ShootingSun/bin/libs/laya.vvmini.js
  52. 1709 0
      ShootingSun/bin/libs/laya.wxmini.js
  53. 1693 0
      ShootingSun/bin/libs/laya.xmmini.js
  54. 0 0
      ShootingSun/bin/libs/worker.js
  55. 132 0
      ShootingSun/bin/libs/workerloader.js
  56. 二進制
      ShootingSun/bin/music/bgMusic.mp3
  57. 二進制
      ShootingSun/bin/music/btnClick.mp3
  58. 二進制
      ShootingSun/bin/music/gameFailed.mp3
  59. 二進制
      ShootingSun/bin/music/gameSuccess.mp3
  60. 二進制
      ShootingSun/bin/music/getCoins.mp3
  61. 二進制
      ShootingSun/bin/music/hitObstacle.wav
  62. 二進制
      ShootingSun/bin/music/knifeAttackSun.mp3
  63. 二進制
      ShootingSun/bin/music/planetDie.mp3
  64. 二進制
      ShootingSun/bin/music/useProp.wav
  65. 15 0
      ShootingSun/bin/openData/index.js
  66. 151 0
      ShootingSun/bin/openData/js/bundle.js
  67. 0 0
      ShootingSun/bin/openData/libs/laya.opendata.min.js
  68. 1662 0
      ShootingSun/bin/openData/weapp-adapter.js
  69. 32 0
      ShootingSun/bin/project.config.json
  70. 1 0
      ShootingSun/bin/project.swan.json
  71. 二進制
      ShootingSun/bin/rank/ad.jpg
  72. 二進制
      ShootingSun/bin/rank/bg.png
  73. 二進制
      ShootingSun/bin/rank/btnLeft.png
  74. 二進制
      ShootingSun/bin/rank/btnRight.png
  75. 二進制
      ShootingSun/bin/rank/button.png
  76. 二進制
      ShootingSun/bin/rank/default.png
  77. 二進制
      ShootingSun/bin/rank/rank1.png
  78. 二進制
      ShootingSun/bin/rank/rank2.png
  79. 二進制
      ShootingSun/bin/rank/rank3.png
  80. 二進制
      ShootingSun/bin/rank/rect1.png
  81. 二進制
      ShootingSun/bin/rank/rect2.png
  82. 二進制
      ShootingSun/bin/rank/rect3.png
  83. 二進制
      ShootingSun/bin/rank/rect4.png
  84. 二進制
      ShootingSun/bin/rank/round.png
  85. 二進制
      ShootingSun/bin/rank/titleRank.png
  86. 二進制
      ShootingSun/bin/rank/txtBack.png
  87. 383 0
      ShootingSun/bin/res/atlas/.rec
  88. 1 0
      ShootingSun/bin/res/atlas/texture/BG.atlas
  89. 二進制
      ShootingSun/bin/res/atlas/texture/BG.png
  90. 1 0
      ShootingSun/bin/res/atlas/texture/Dialog_CoinAndStrength.atlas
  91. 二進制
      ShootingSun/bin/res/atlas/texture/Dialog_CoinAndStrength.png
  92. 1 0
      ShootingSun/bin/res/atlas/texture/Dialog_CoinAndStrength/threeTimesFasterProgress.atlas
  93. 二進制
      ShootingSun/bin/res/atlas/texture/Dialog_CoinAndStrength/threeTimesFasterProgress.png
  94. 1 0
      ShootingSun/bin/res/atlas/texture/Dialog_GetProp.atlas
  95. 二進制
      ShootingSun/bin/res/atlas/texture/Dialog_GetProp.png
  96. 1 0
      ShootingSun/bin/res/atlas/texture/Dialog_LevelOver.atlas
  97. 二進制
      ShootingSun/bin/res/atlas/texture/Dialog_LevelOver.png
  98. 1 0
      ShootingSun/bin/res/atlas/texture/Dialog_NewPlanet.atlas
  99. 二進制
      ShootingSun/bin/res/atlas/texture/Dialog_NewPlanet.png
  100. 1 0
      ShootingSun/bin/res/atlas/texture/Effect/Crit.atlas

+ 73 - 0
ShootingSun/.laya/compile.js

@@ -0,0 +1,73 @@
+// v1.2.1
+//是否使用IDE自带的node环境和插件,设置false后,则使用自己环境(使用命令行方式执行)
+const useIDENode = process.argv[0].indexOf("LayaAir") > -1 ? true : false;
+const useCMDNode = process.argv[1].indexOf("layaair2-cmd") > -1 ? true : false;
+
+function useOtherNode(){
+	return useIDENode||useCMDNode;
+}
+//获取Node插件和工作路径
+let ideModuleDir = useOtherNode() ? process.argv[1].replace("gulp\\bin\\gulp.js", "").replace("gulp/bin/gulp.js", "") : "";
+let workSpaceDir = useOtherNode() ? process.argv[2].replace("--gulpfile=", "").replace("\\.laya\\compile.js", "").replace("/.laya/compile.js", "") : "./../";
+
+const gulp = require(ideModuleDir + "gulp");
+const rollup = require(ideModuleDir + "rollup");
+const typescript = require(ideModuleDir + 'rollup-plugin-typescript2');//typescript2 plugin
+const glsl = require(ideModuleDir + 'rollup-plugin-glsl');
+
+// 如果是发布时调用编译功能,增加prevTasks
+let prevTasks = "";
+if (global.publish) {
+	prevTasks = ["loadConfig"];
+}
+
+gulp.task("compile", prevTasks, function () {
+	// 发布时调用编译功能,判断是否点击了编译选项
+	if (global.publish && !global.config.compile) {
+		return;
+	} else if (global.publish && global.config.compile) {
+		// 发布时调用编译,workSpaceDir使用publish.js里的变量
+		workSpaceDir = global.workSpaceDir;
+	}
+
+	return rollup.rollup({
+		input: workSpaceDir + '/src/Main.ts',
+		onwarn:(waring,warn)=>{
+			if(waring.code == "CIRCULAR_DEPENDENCY"){
+				console.log("warnning Circular dependency:");
+				console.log(waring);
+			}
+		},
+		treeshake: false, //建议忽略
+		plugins: [
+			typescript({
+				tsconfig:workSpaceDir + "/tsconfig.json",
+				check: true, //Set to false to avoid doing any diagnostic checks on the code
+				tsconfigOverride:{compilerOptions:{removeComments: true}},
+				include:/.*.ts/,
+			}),
+			glsl({
+				// By default, everything gets included
+				include: /.*(.glsl|.vs|.fs)$/,
+				sourceMap: false,
+				compress:false
+			}),
+			/*terser({
+				output: {
+				},
+				numWorkers:1,//Amount of workers to spawn. Defaults to the number of CPUs minus 1
+				sourcemap: false
+			})*/        
+		]
+	}).then(bundle => {
+		return bundle.write({
+			file: workSpaceDir + '/bin/js/bundle.js',
+			format: 'iife',
+			name: 'laya',
+			sourcemap: false
+		});
+	}).catch(err=>{
+			console.log(err);
+		
+	})
+});

+ 371 - 0
ShootingSun/.laya/publish.js

@@ -0,0 +1,371 @@
+// v1.6.1
+//是否使用IDE自带的node环境和插件,设置false后,则使用自己环境(使用命令行方式执行)
+const useIDENode = process.argv[0].indexOf("LayaAir") > -1 ? true : false;
+const useCMDNode = process.argv[1].indexOf("layaair2-cmd") > -1 ? true : false;
+
+function useOtherNode(){
+	return useIDENode||useCMDNode;
+}
+//获取Node插件和工作路径
+let ideModuleDir = useOtherNode() ? process.argv[1].replace("gulp\\bin\\gulp.js", "").replace("gulp/bin/gulp.js", "") : "";
+let workSpaceDir = useOtherNode() ? process.argv[2].replace("--gulpfile=", "").replace("\\.laya\\publish.js", "").replace("/.laya/publish.js", "") + "/" : "./../";
+
+//引用插件模块
+const gulp = require(ideModuleDir + "gulp");
+const fs = require("fs");
+const path = require("path");
+const uglify = require(ideModuleDir + 'gulp-uglify-es').default;
+const jsonminify = require(ideModuleDir + "gulp-jsonminify");
+const image = require(ideModuleDir + "gulp-image");
+const rev = require(ideModuleDir + "gulp-rev");
+const revdel = require(ideModuleDir + "gulp-rev-delete-original");
+const revCollector = require(ideModuleDir + 'gulp-rev-collector');
+const del = require(ideModuleDir + "del");
+const requireDir = require(ideModuleDir + 'require-dir');
+const babel = require(ideModuleDir + 'gulp-babel');
+
+global.ideModuleDir = ideModuleDir;
+global.workSpaceDir = workSpaceDir;
+
+// 结合compile.js使用
+global.publish = true;
+const fileList = ["compile.js", "publish_xmgame.js", "publish_oppogame.js", "publish_vivogame.js", "publish_wxgame.js", "publish_bdgame.js", "publish_qqgame.js"];
+requireDir('./', {
+	filter: function (fullPath) {
+		// 只用到了compile.js和publish.js
+		if (fileList.includes(path.basename(fullPath))) {
+			return true;
+		} else {
+			return false;
+		}
+	}
+});
+
+const QUICKGAMELIST = ["xmgame", "oppogame", "vivogame"];
+
+// 清理临时文件夹,加载配置
+let config,
+	releaseDir,
+	binPath,
+	platform = "web",
+	isOpendataProj = false,
+	platformCopyTask = [],// 平台脚本拷贝任务
+	platformTask = []; // 平台需要执行的任务
+//任务对照列表
+const copyTasks = {
+	"biligame": "copyPlatformFile_Bili",
+	"Alipaygame": "copyPlatformFile_Alipay",
+	"vivogame": "copyPlatformFile_VIVO",
+	"oppogame": "preCreate_OPPO",
+	"xmgame": "copyPlatformFile_XM",
+	"bdgame": "copyPlatformFile_BD",
+	"qqgame": "copyPlatformFile_QQ",
+	"wxgame": "copyPlatformFile_WX",
+	"web": "copyLibsJsFile"
+}
+const tasks = {
+	"biligame": "buildBiliProj",
+	"Alipaygame": "buildAlipayProj",
+	"vivogame": "buildVivoProj",
+	"oppogame": "buildOPPOProj",
+	"xmgame": "buildXiaomiProj",
+	"bdgame": "buildBDProj",
+	"qqgame": "buildQQProj",
+	"wxgame": "buildWXProj",
+	"web": "packfile"
+}
+
+if (!useOtherNode() && process.argv.length > 5 && process.argv[4] == "--config") {
+	platform = process.argv[5].replace(".json", "");
+}
+if (useOtherNode() && process.argv.length >= 4 && process.argv[3].startsWith("--config") && process.argv[3].endsWith(".json")) {
+	platform = process.argv[3].match(/(\w+).json/)[1];
+	platformCopyTask.push(copyTasks[platform]);
+	platformTask.push(tasks[platform]);
+}
+
+gulp.task("loadConfig", function () {
+	let _path;
+	if (!useOtherNode()) {
+		_path = platform + ".json";
+		releaseDir = "../release/" + platform;
+		binPath = "../bin/";
+	}
+	if (useOtherNode()) {
+		_path = path.join(workSpaceDir, ".laya", `${platform}.json`);
+		releaseDir = path.join(workSpaceDir, "release", platform).replace(/\\/g, "/");
+		binPath = path.join(workSpaceDir, "bin").replace(/\\/g, "/");
+	}
+	global.platform = platform;
+	let file = fs.readFileSync(_path, "utf-8");
+	if (file) {
+		if (QUICKGAMELIST.includes(platform)) {
+			file = file.replace(/\$basePath/g, releaseDir + "/temprelease");
+		} else {
+			file = file.replace(/\$basePath/g, releaseDir);
+		}
+		config = JSON.parse(file);
+		global.config = config;
+	}
+	// 是否是开放域项目
+	let projInfoPath = path.join(workSpaceDir, path.basename(workSpaceDir) + ".laya");
+	let isExist = fs.existsSync(projInfoPath);
+	if (isExist) {
+		try {
+			let projInfo = fs.readFileSync(projInfoPath, "utf8");
+			projInfo = projInfo && JSON.parse(projInfo);
+			isOpendataProj = projInfo.layaProType === 12;
+		} catch (e) {}
+	}
+});
+
+// 清理release文件夹
+gulp.task("clearReleaseDir", ["compile"], function (cb) {
+	if (config.clearReleaseDir) {
+		let delList = [`${releaseDir}/**`, releaseDir + "_pack", config.packfileTargetValue];
+		// 小米快游戏,使用即存的项目,删掉Laya工程文件,保留小米环境项目文件
+		if (platform === "xmgame") {
+			let xmProjSrc = path.join(releaseDir, config.xmInfo.projName);
+			// 不要删掉manifest.json/main.js文件
+			// 这里不是node-glob语法,详见: https://github.com/sindresorhus/del
+			delList = [`${xmProjSrc}/**`, `!${xmProjSrc}`, `!${xmProjSrc}/node_modules/**`, `!${xmProjSrc}/sign/**`, `!${xmProjSrc}/{babel.config.js,main.js,manifest.json,package.json,package-lock.json}`];
+		} else if (platform === "oppogame") {
+			let oppoProjSrc = path.join(releaseDir, config.oppoInfo.projName);
+			delList = [`${oppoProjSrc}/**`, `!${oppoProjSrc}`, `!${oppoProjSrc}/dist/**`, `!${oppoProjSrc}/{manifest.json}`];
+		} else if (platform === "vivogame") {
+			let vvProj = path.join(releaseDir, config.vivoInfo.projName);
+			let vvProjSrc = path.join(vvProj, "src");
+			// 不要删掉manifest.json/main.js文件
+			// 这里不是node-glob语法,详见: https://github.com/sindresorhus/del
+			delList = [`${vvProjSrc}/**`, `!${vvProjSrc}`, `!${vvProjSrc}/sign/**`, `!${vvProjSrc}/{game.js,manifest.json}`];
+			delList = delList.concat(`${vvProj}/engine/**`, `${vvProj}/config/**`);
+		}
+		// 保留平台配置文件
+		if (config.keepPlatformFile) {
+			if (platform === "wxgame" || platform === "qqgame") {
+				delList = delList.concat(`!${releaseDir}`, `!${releaseDir}/{game.js,game.json,project.config.json,weapp-adapter.js}`);
+			} else if (platform === "bdgame") {
+				delList = delList.concat(`!${releaseDir}`, `!${releaseDir}/{game.js,game.json,project.swan.json,swan-game-adapter.js}`);
+			} else if (platform === "Alipaygame") {
+				delList = delList.concat(`!${releaseDir}`, `!${releaseDir}/{game.js,game.json,my-adapter.js}`);
+			}
+		}
+		del(delList, { force: true }).then(paths => {
+			cb();
+		});
+	} else cb();
+});
+
+// copy bin文件到release文件夹
+gulp.task("copyFile", ["clearReleaseDir"], function () {
+	let baseCopyFilter = [`${workSpaceDir}/bin/**/*.*`, `!${workSpaceDir}/bin/indexmodule.html`, `!${workSpaceDir}/bin/import/*.*`];
+	// 只拷贝index.js中引用的类库
+	if (config.onlyIndexJS) {
+		baseCopyFilter = baseCopyFilter.concat(`!${workSpaceDir}/bin/libs/*.*`);
+	}
+	if (platform === "wxgame" && isOpendataProj) { // 开放域项目微信发布,仅拷贝用到的文件
+		config.copyFilesFilter = [`${workSpaceDir}/bin/js/bundle.js`, `${workSpaceDir}/bin/index.js`, `${workSpaceDir}/bin/game.js`];
+		if (config.projectType !== "as") { // 开放域精简类库
+			config.copyFilesFilter.push(`${workSpaceDir}/bin/libs/laya.opendata.js`);
+		}
+	} else if (platform === "wxgame") { // 微信项目,不拷贝index.html,不拷贝百度bin目录中的文件
+		config.copyFilesFilter = baseCopyFilter.concat([`!${workSpaceDir}/bin/index.html`, `!${workSpaceDir}/bin/{project.swan.json,swan-game-adapter.js}`]);
+	} else if (platform === "bdgame") { // 百度项目,不拷贝index.html,不拷贝微信bin目录中的文件
+		config.copyFilesFilter = baseCopyFilter.concat([`!${workSpaceDir}/bin/index.html`, `!${workSpaceDir}/bin/{project.config.json,weapp-adapter.js}`]);
+	} else { // web|QQ项目|bili|快游戏,不拷贝微信、百度在bin目录中的文件
+		config.copyFilesFilter = baseCopyFilter.concat([`!${workSpaceDir}/bin/{game.js,game.json,project.config.json,weapp-adapter.js,project.swan.json,swan-game-adapter.js}`]);
+	}
+	// bili/alipay/qq,不拷贝index.html
+	if (["biligame", "Alipaygame", "qqgame"].includes(platform)) {
+		config.copyFilesFilter = config.copyFilesFilter.concat([`!${workSpaceDir}/bin/index.html`]);
+	}
+	// 快游戏,需要新建一个快游戏项目,拷贝的只是项目的一部分,将文件先拷贝到文件夹的临时目录中去
+	if (QUICKGAMELIST.includes(platform)) {
+		config.copyFilesFilter = config.copyFilesFilter.concat([`!${workSpaceDir}/bin/index.html`]);
+		releaseDir = global.tempReleaseDir = path.join(releaseDir, "temprelease");
+	}
+	if (config.exclude) { // 排除文件
+		config.excludeFilter.forEach(function(item, index, list) {
+			releaseDir = releaseDir.replace(/\\/g, "/");
+			config.excludeFilter[index] = item.replace(releaseDir, binPath);
+		});
+		config.copyFilesFilter = config.copyFilesFilter.concat(config.excludeFilter);
+	}
+	global.releaseDir = releaseDir;
+	var stream = gulp.src(config.copyFilesFilter, { base: `${workSpaceDir}/bin` });
+	return stream.pipe(gulp.dest(releaseDir));
+});
+
+// copy libs中的js文件到release文件夹
+gulp.task("copyLibsJsFile", ["copyFile"], function () {
+	if (!config.onlyIndexJS) {
+		return;
+	}
+	if (platform === "wxgame" && isOpendataProj) { // 开放域项目微信发布,拷贝文件时已经拷贝类库文件了
+		return;
+	}
+	// 开放域项目,as语言,没有libs目录,mac系统报错
+	let libs = path.join(workSpaceDir, "bin", "libs");
+	if (!fs.existsSync(libs)) {
+		return;
+	}
+	// 分析index.js
+	let indexJSPath = path.join(workSpaceDir, "bin", "index.js");
+	let indexJsContent = fs.readFileSync(indexJSPath, "utf8");
+	let libsList = indexJsContent.match(/loadLib\(['"]libs\/[\w-./]+\.(js|wasm)['"]\)/g);
+	if (!libsList) {
+		libsList = [];
+	}
+	let 
+		item,
+		libsName = "",
+		libsStr = "";
+	for (let i = 0, len = libsList.length; i < len; i++) {
+		item = libsList[i];
+		libsName = item.match(/loadLib\(['"]libs\/([\w-./]+\.(js|wasm))['"]\)/);
+		libsStr += libsStr ? `,${libsName[1]}` : libsName[1];
+	}
+	// 发布web项目,如果使用了physics3D,默认拷贝runtime
+	if (platform === "web" && libsStr.includes("laya.physics3D")) {
+		libsStr += ',laya.physics3D.runtime.js';
+	}
+	let copyLibsList = [`${workSpaceDir}/bin/libs/{${libsStr}}`];
+	if (!libsStr.includes(",")) {
+		copyLibsList = [`${workSpaceDir}/bin/libs/${libsStr}`];
+	}
+	var stream = gulp.src(copyLibsList, { base: `${workSpaceDir}/bin` });
+	return stream.pipe(gulp.dest(releaseDir));
+});
+
+// es6toes5
+gulp.task("es6toes5", platformCopyTask, function() {
+	if (config.es6toes5) {
+		return gulp.src(`${releaseDir}/**/*.js`, { base: releaseDir })
+		.pipe(babel({
+			presets: ['@babel/env'],
+			compact: true
+		})) 
+		.pipe(gulp.dest(releaseDir));
+	}
+})
+
+// 压缩json
+gulp.task("compressJson", ["es6toes5"], function () {
+	if (config.compressJson) {
+		return gulp.src(config.compressJsonFilter, { base: releaseDir })
+			.pipe(jsonminify())
+			.pipe(gulp.dest(releaseDir));
+	}
+});
+
+// 压缩js
+gulp.task("compressJs", ["compressJson"], function () {
+	if (config.compressJs) {
+		return gulp.src(config.compressJsFilter, { base: releaseDir })
+			.pipe(uglify({
+				mangle: {
+					keep_fnames:true
+				}
+			}))
+			.on('error', function (err) {
+				console.warn(err.toString());
+			})
+			.pipe(gulp.dest(releaseDir));
+	}
+});
+
+// 压缩png,jpg
+gulp.task("compressImage", ["compressJs"], function () {
+	if (config.compressImage) {
+		return gulp.src(config.compressImageFilter, { base: releaseDir })
+			.pipe(image({
+				pngquant: true,			//PNG优化工具
+				optipng: false,			//PNG优化工具
+				zopflipng: true,		//PNG优化工具
+				jpegRecompress: false,	//jpg优化工具
+				mozjpeg: true,			//jpg优化工具
+				guetzli: false,			//jpg优化工具
+				gifsicle: false,		//gif优化工具
+				svgo: false,			//SVG优化工具
+				concurrent: 10,			//并发线程数
+				quiet: true 			//是否是静默方式
+				// optipng: ['-i 1', '-strip all', '-fix', '-o7', '-force'],
+				// pngquant: ['--speed=1', '--force', 256],
+				// zopflipng: ['-y', '--lossy_8bit', '--lossy_transparent'],
+				// jpegRecompress: ['--strip', '--quality', 'medium', '--min', 40, '--max', 80],
+				// mozjpeg: ['-optimize', '-progressive'],
+				// guetzli: ['--quality', 85]
+			}))
+			.pipe(gulp.dest(releaseDir));
+	}
+});
+
+// 生成版本管理信息
+gulp.task("version1", ["compressImage"], function () {
+	if (config.version) {
+		return gulp.src(config.versionFilter, { base: releaseDir })
+			.pipe(rev())
+			.pipe(gulp.dest(releaseDir))
+			.pipe(revdel())
+			.pipe(rev.manifest("version.json"))
+			.pipe(gulp.dest(releaseDir));
+	}
+});
+
+// 替换index.js里面的变化的文件名
+gulp.task("version2", ["version1"], function () {
+	if (config.version) {
+		//替换index.html和index.js里面的文件名称
+
+		let htmlPath = releaseDir + "/index.html";
+		let versionPath = releaseDir + "/version.json";
+		let gameJSPath = releaseDir + "/game.js";
+		let mainJSPath = releaseDir + "/main.js";
+		let indexJSPath;
+		let versionCon = fs.readFileSync(versionPath, "utf8");
+		versionCon = JSON.parse(versionCon);
+		let indexJsStr = (versionCon && versionCon["index.js"]) ? versionCon["index.js"] :  "index.js";
+		indexJSPath = releaseDir + "/" + indexJsStr;
+		// 替换config.packfileFullValue中的路径
+		let packfileStr = JSON.stringify(config.packfileFullValue).replace(/\\\\/g, "/");
+		let tempPackfile = `${workSpaceDir}/.laya/configTemp.json`;
+		fs.writeFileSync(tempPackfile, packfileStr, "utf8");
+
+		let srcList = [versionPath, indexJSPath, tempPackfile];
+		if (fs.existsSync(htmlPath)) {
+			srcList.push(htmlPath);
+		}
+		if (fs.existsSync(gameJSPath)) {
+			srcList.push(gameJSPath);
+		}
+		if (fs.existsSync(mainJSPath)) {
+			srcList.push(mainJSPath);
+		}
+		return gulp.src(srcList)
+			.pipe(revCollector())
+			.pipe(gulp.dest(releaseDir));
+	}
+});
+
+// 筛选4M包
+gulp.task("packfile", ["version2"], function() {
+	if (config.version) {
+		// 从release目录取得带有版本号的目录
+		let tempPackfile = `${workSpaceDir}/.laya/configTemp.json`;
+		let releasePackfile = `${releaseDir}/configTemp.json`;
+		let packfileStr = fs.readFileSync(releasePackfile, "utf8");
+		config.packfileFullValue = JSON.parse(packfileStr);
+		// 删掉临时目录
+		fs.unlinkSync(tempPackfile);
+		fs.unlinkSync(releasePackfile);
+	}
+	if (config.packfile) { // 提取本地包(文件列表形式)
+		return gulp.src(config.packfileFullValue, { base: releaseDir })
+			.pipe(gulp.dest(config.packfileTargetValue || releaseDir + "_pack"));
+	}
+});
+
+// 起始任务
+gulp.task("publish", platformTask , function () {
+	console.log("All tasks completed!");
+});

+ 189 - 0
ShootingSun/.laya/publish_bdgame.js

@@ -0,0 +1,189 @@
+// v1.3.0
+// publish 2.x 也是用这个文件,需要做兼容
+let isPublish2 = process.argv[2].includes("publish_bdgame.js") && process.argv[3].includes("--evn=publish2");
+// 获取Node插件和工作路径
+let ideModuleDir, workSpaceDir;
+if (isPublish2) {
+	//是否使用IDE自带的node环境和插件,设置false后,则使用自己环境(使用命令行方式执行)
+	const useIDENode = process.argv[0].indexOf("LayaAir") > -1 ? true : false;
+	ideModuleDir = useIDENode ? process.argv[1].replace("gulp\\bin\\gulp.js", "").replace("gulp/bin/gulp.js", "") : "";
+	workSpaceDir = useIDENode ? process.argv[2].replace("--gulpfile=", "").replace("\\.laya\\publish_bdgame.js", "").replace("/.laya/publish_bdgame.js", "") + "/" : "./../";
+} else {
+	ideModuleDir = global.ideModuleDir;
+	workSpaceDir = global.workSpaceDir;
+}
+
+//引用插件模块
+const gulp = require(ideModuleDir + "gulp");
+const fs = require("fs");
+const path = require("path");
+const crypto = require("crypto");
+const childProcess = require("child_process");
+const del = require(ideModuleDir + "del");
+const revCollector = require(ideModuleDir + 'gulp-rev-collector');
+let commandSuffix = ".cmd";
+
+let copyLibsTask = ["copyLibsJsFile"];
+let packfiletask = ["packfile"];
+if (isPublish2) {
+	copyLibsTask = "";
+	packfiletask = ["copyPlatformFile_BD"];
+}
+
+let 
+    config,
+	platform,
+    releaseDir;
+let isGlobalCli = true;
+let versionCon; // 版本管理version.json
+// 应该在publish中的,但是为了方便发布2.0及IDE 1.x,放在这里修改
+gulp.task("preCreate_BD", copyLibsTask, function() {
+	if (isPublish2) {
+		let pubsetPath = path.join(workSpaceDir, ".laya", "pubset.json");
+		let content = fs.readFileSync(pubsetPath, "utf8");
+		let pubsetJson = JSON.parse(content);
+		platform = "bdgame";
+		releaseDir = path.join(workSpaceDir, "release", platform).replace(/\\/g, "/");
+		config = pubsetJson[3];
+	} else {
+		platform = global.platform;
+		releaseDir = global.releaseDir;
+		config = global.config;
+	}
+	// 如果不是百度小游戏
+	if (platform !== "bdgame") {
+		return;
+	}
+	if (process.platform === "darwin") {
+		commandSuffix = "";
+	}
+	let copyLibsList = [`${workSpaceDir}/bin/libs/laya.bdmini.js`];
+	var stream = gulp.src(copyLibsList, { base: `${workSpaceDir}/bin` });
+	return stream.pipe(gulp.dest(releaseDir));
+});
+
+gulp.task("copyPlatformFile_BD", ["preCreate_BD"], function() {
+	// 如果不是百度小游戏
+	if (platform !== "bdgame") {
+		return;
+	}
+	let adapterPath = path.join(ideModuleDir, "../", "out", "layarepublic", "LayaAirProjectPack", "lib", "data", "bdfiles");
+	// 如果新建项目时已经点击了"微信/百度小游戏bin目录快速调试",不再拷贝
+	let isHadBdFiles =
+		fs.existsSync(path.join(workSpaceDir, "bin", "game.js")) &&
+		fs.existsSync(path.join(workSpaceDir, "bin", "game.json")) &&
+		fs.existsSync(path.join(workSpaceDir, "bin", "project.swan.json")) &&
+		fs.existsSync(path.join(workSpaceDir, "bin", "swan-game-adapter.js"));
+	if (isHadBdFiles) {
+		return;
+	}
+	let isHasPublish = 
+		fs.existsSync(path.join(releaseDir, "game.js")) &&
+		fs.existsSync(path.join(releaseDir, "game.json")) &&
+		fs.existsSync(path.join(releaseDir, "project.swan.json")) &&
+		fs.existsSync(path.join(releaseDir, "swan-game-adapter.js"));
+	if (isHasPublish) {
+		return;
+	}
+	let stream = gulp.src(adapterPath + "/*.*");
+	return stream.pipe(gulp.dest(releaseDir));
+});
+
+gulp.task("modifyFile_BD", packfiletask, function() {
+	// 如果不是百度小游戏
+	if (platform !== "bdgame") {
+		return;
+	}
+	if (config.version) {
+		let versionPath = releaseDir + "/version.json";
+		versionCon = fs.readFileSync(versionPath, "utf8");
+		versionCon = JSON.parse(versionCon);
+	}
+	let indexJsStr = (versionCon && versionCon["index.js"]) ? versionCon["index.js"] :  "index.js";
+	// 百度小游戏项目,修改index.js
+	let filePath = path.join(releaseDir, indexJsStr);
+	if (!fs.existsSync(filePath)) {
+		return;
+	}
+	let fileContent = fs.readFileSync(filePath, "utf8");
+	fileContent = fileContent.replace(/loadLib(\(['"])/gm, "require$1./");
+	fs.writeFileSync(filePath, fileContent, "utf8");
+});
+
+// 开放域的情况下,合并game.js和index.js,并删除game.js
+gulp.task("openData_BD", ["modifyFile_BD"], function (cb) {
+	// 如果不是百度小游戏
+	if (platform !== "bdgame") {
+		return cb();
+	}
+	if (config.openDataZone) {
+		let versionCon;
+		if (config.version) {
+			let versionPath = releaseDir + "/version.json";
+			versionCon = fs.readFileSync(versionPath, "utf8");
+			versionCon = JSON.parse(versionCon);
+		}
+		let indexJsStr = (versionCon && versionCon["index.js"]) ? versionCon["index.js"] :  "index.js";
+		let indexPath = path.join(releaseDir, indexJsStr);
+		let indexjs = readFile(indexPath);
+		let gamejs = readFile(releaseDir + "/game.js");
+		if (gamejs && indexjs) {
+			gamejs = gamejs.replace(`require("index.js")`, indexjs);
+			fs.writeFileSync(indexPath, gamejs, 'utf-8');
+		}
+		return cb();
+	}
+	cb();
+});
+
+function readFile(path) {
+	if (fs.existsSync(path)) {
+		return fs.readFileSync(path, "utf-8");
+	}
+	return null;
+}
+
+gulp.task("version_BD", ["openData_BD"], function() {
+	// 如果不是百度小游戏
+	if (platform !== "bdgame") {
+		return;
+	}
+	if (config.version) {
+		let versionPath = releaseDir + "/version.json";
+		let gameJSPath = releaseDir + "/game.js";
+		let srcList = [versionPath, gameJSPath];
+		return gulp.src(srcList)
+			.pipe(revCollector())
+			.pipe(gulp.dest(releaseDir));
+	}
+});
+
+gulp.task("optimizeOpen_BD", ["version_BD"], function(cb) {
+	// 如果不是百度小游戏
+	if (platform !== "bdgame") {
+		return cb();
+	}
+	let bdOptimize = config.bdOptimize;
+	if (!bdOptimize || !bdOptimize.useOptimizeOpen) {
+		return cb();
+	}
+	// 首屏加载优化(秒开),修改game.json
+	let filePath = path.join(releaseDir, "game.json");
+	if (!fs.existsSync(filePath)) {
+		return cb();
+	}
+	let fileContent = fs.readFileSync(filePath, "utf8");
+	let fileConObj = JSON.parse(fileContent);
+	if (bdOptimize.preloadRes) {
+		fileConObj.preloadResources = bdOptimize.preloadResList;
+	} else {
+		delete fileConObj.preloadResources;
+	}
+
+	fs.writeFileSync(filePath, JSON.stringify(fileConObj, null, 4), "utf8");
+	return cb();
+});
+
+gulp.task("buildBDProj", ["optimizeOpen_BD"], function() {
+	console.log("all tasks completed");
+});

+ 454 - 0
ShootingSun/.laya/publish_oppogame.js

@@ -0,0 +1,454 @@
+// v1.3.0
+// publish 2.x 也是用这个文件,需要做兼容
+let isPublish2 = process.argv[2].includes("publish_oppogame.js") && process.argv[3].includes("--evn=publish2");
+// 获取Node插件和工作路径
+let ideModuleDir, workSpaceDir;
+if (isPublish2) {
+	//是否使用IDE自带的node环境和插件,设置false后,则使用自己环境(使用命令行方式执行)
+	const useIDENode = process.argv[0].indexOf("LayaAir") > -1 ? true : false;
+	ideModuleDir = useIDENode ? process.argv[1].replace("gulp\\bin\\gulp.js", "").replace("gulp/bin/gulp.js", "") : "";
+	workSpaceDir = useIDENode ? process.argv[2].replace("--gulpfile=", "").replace("\\.laya\\publish_oppogame.js", "").replace("/.laya/publish_oppogame.js", "") + "/" : "./../";
+} else {
+	ideModuleDir = global.ideModuleDir;
+	workSpaceDir = global.workSpaceDir;
+}
+
+//引用插件模块
+const gulp = require(ideModuleDir + "gulp");
+const fs = require("fs");
+const path = require("path");
+const childProcess = require("child_process");
+const del = require(ideModuleDir + "del");
+const revCollector = require(ideModuleDir + 'gulp-rev-collector');
+let commandSuffix = ".cmd";
+
+let copyLibsTask = ["copyLibsJsFile"];
+let packfiletask = ["packfile"];
+if (isPublish2) {
+	copyLibsTask = "";
+	packfiletask = ["preCreate_OPPO"];
+}
+
+let 
+    config,
+	platform,
+	releaseDir,
+    toolkitPath,
+    tempReleaseDir, // OPPO临时拷贝目录
+	projDir; // OPPO快游戏工程目录
+let versionCon; // 版本管理version.json
+// 创建OPPO项目前,拷贝OPPO引擎库、修改index.js
+// 应该在publish中的,但是为了方便发布2.0及IDE 1.x,放在这里修改
+gulp.task("preCreate_OPPO", copyLibsTask, function() {
+	if (isPublish2) {
+		let pubsetPath = path.join(workSpaceDir, ".laya", "pubset.json");
+		let content = fs.readFileSync(pubsetPath, "utf8");
+		let pubsetJson = JSON.parse(content);
+		platform = "oppogame";
+		releaseDir = path.join(workSpaceDir, "release", platform).replace(/\\/g, "/");
+		releaseDir = tempReleaseDir = path.join(releaseDir, "temprelease");
+		config = pubsetJson[5]; // 只用到了 config.oppoInfo|config.oppoSign
+	} else {
+		platform = global.platform;
+		releaseDir = global.releaseDir;
+		tempReleaseDir = global.tempReleaseDir;
+		config = global.config;
+	}
+    toolkitPath = path.join(ideModuleDir, "../", "out", "layarepublic", "oppo", "quickgame-toolkit");
+	// 如果不是OPPO快游戏
+	if (platform !== "oppogame") {
+		return;
+	}
+	if (process.platform === "darwin") {
+		commandSuffix = "";
+	}
+	let copyLibsList = [`${workSpaceDir}/bin/libs/laya.quickgamemini.js`];
+	var stream = gulp.src(copyLibsList, { base: `${workSpaceDir}/bin` });
+	return stream.pipe(gulp.dest(tempReleaseDir));
+});
+
+// 新建OPPO项目-OPPO项目与其他项目不同,需要安装OPPO quickgame node_modules,并打包成.rpk文件
+gulp.task("installModules_OPPO", packfiletask, function() {
+	// 如果不是OPPO快游戏
+	if (platform !== "oppogame") {
+		return;
+	}
+	releaseDir = path.dirname(releaseDir);
+	projDir = path.join(releaseDir, config.oppoInfo.projName);
+    // 如果IDE里对应OPPO包已经install node_modules了,忽略这一步
+    if (fs.existsSync(path.join(toolkitPath, "node_modules"))) {
+        return;
+    }
+	// 安装OPPO quickgame node_modules
+	return new Promise((resolve, reject) => {
+		console.log("开始安装OPPO quickgame node_modules,请耐心等待...");
+		let cmd = `npm${commandSuffix}`;
+		let args = ["install"];
+        let opts = {
+			cwd: toolkitPath,
+			shell: true
+		};
+        let cp = childProcess.spawn(cmd, args, opts);
+        
+		cp.stdout.on('data', (data) => {
+			console.log(`stdout: ${data}`);
+		});
+		
+		cp.stderr.on('data', (data) => {
+			console.log(`stderr: ${data}`);
+			// reject();
+		});
+		
+		cp.on('close', (code) => {
+			console.log(`子进程退出码:${code}`);
+			resolve();
+		});
+	});
+});
+
+// 拷贝文件到OPPO快游戏
+gulp.task("copyFileToProj_OPPO", ["installModules_OPPO"], function() {
+	// 如果不是OPPO快游戏
+	if (platform !== "oppogame") {
+		return;
+	}
+	// 将临时文件夹中的文件,拷贝到项目中去
+	let originalDir = `${tempReleaseDir}/**/*.*`;
+	let stream = gulp.src(originalDir);
+	return stream.pipe(gulp.dest(path.join(projDir)));
+});
+
+// 拷贝icon到OPPO快游戏
+gulp.task("copyIconToProj_OPPO", ["copyFileToProj_OPPO"], function() {
+	// 如果不是OPPO快游戏
+	if (platform !== "oppogame") {
+		return;
+	}
+	let originalDir = config.oppoInfo.icon;
+	let stream = gulp.src(originalDir);
+	return stream.pipe(gulp.dest(path.join(projDir)));
+});
+
+// 清除OPPO快游戏临时目录
+gulp.task("clearTempDir_OPPO", ["copyIconToProj_OPPO"], function() {
+	// 如果不是OPPO快游戏
+	if (platform !== "oppogame") {
+		return;
+	}
+	// 删掉临时目录
+	return del([tempReleaseDir], { force: true });
+});
+
+// 生成release签名(私钥文件 private.pem 和证书文件 certificate.pem )
+gulp.task("generateSign_OPPO", ["clearTempDir_OPPO"], function() {
+	// 如果不是OPPO快游戏
+	if (platform !== "oppogame") {
+		return;
+    }
+    if (!config.oppoSign.generateSign) {
+        return;
+    }
+	// https://doc.quickapp.cn/tools/compiling-tools.html
+	return new Promise((resolve, reject) => {
+		let cmd = "openssl";
+		let args = ["req", "-newkey", "rsa:2048", "-nodes", "-keyout", "private.pem", 
+					"-x509", "-days", "3650", "-out", "certificate.pem"];
+		let opts = {
+			cwd: projDir,
+			shell: true
+		};
+		let cp = childProcess.spawn(cmd, args, opts);
+		cp.stdout.on('data', (data) => {
+			console.log(`stdout: ${data}`);
+		});
+
+		cp.stderr.on('data', (data) => {
+			console.log(`stderr: ${data}`);
+			data += "";
+			if (data.includes("Country Name")) {
+				cp.stdin.write(`${config.oppoSign.countryName}\n`);
+				console.log(`Country Name: ${config.oppoSign.countryName}`);
+			} else if (data.includes("Province Name")) {
+				cp.stdin.write(`${config.oppoSign.provinceName}\n`);
+				console.log(`Province Name: ${config.oppoSign.provinceName}`);
+			} else if (data.includes("Locality Name")) {
+				cp.stdin.write(`${config.oppoSign.localityName}\n`);
+				console.log(`Locality Name: ${config.oppoSign.localityName}`);
+			} else if (data.includes("Organization Name")) {
+				cp.stdin.write(`${config.oppoSign.orgName}\n`);
+				console.log(`Organization Name: ${config.oppoSign.orgName}`);
+			} else if (data.includes("Organizational Unit Name")) {
+				cp.stdin.write(`${config.oppoSign.orgUnitName}\n`);
+				console.log(`Organizational Unit Name: ${config.oppoSign.orgUnitName}`);
+			} else if (data.includes("Common Name")) {
+				cp.stdin.write(`${config.oppoSign.commonName}\n`);
+				console.log(`Common Name: ${config.oppoSign.commonName}`);
+			} else if (data.includes("Email Address")) {
+				cp.stdin.write(`${config.oppoSign.emailAddr}\n`);
+				console.log(`Email Address: ${config.oppoSign.emailAddr}`);
+				// cp.stdin.end();
+			}
+			// reject();
+		});
+
+		cp.on('close', (code) => {
+			console.log(`子进程退出码:${code}`);
+			resolve();
+		});
+	});
+});
+
+// 拷贝sign文件到指定位置
+gulp.task("copySignFile_OPPO", ["generateSign_OPPO"], function() {
+	// 如果不是OPPO快游戏
+	if (platform !== "oppogame") {
+		return;
+    }
+    if (config.oppoSign.generateSign) { // 新生成的签名
+        // 移动签名文件到项目中(Laya & OPPO快游戏项目中)
+        let 
+            privatePem = path.join(projDir, "private.pem"),
+            certificatePem = path.join(projDir, "certificate.pem");
+        let isSignExits = fs.existsSync(privatePem) && fs.existsSync(certificatePem);
+        if (!isSignExits) {
+            return;
+        }
+        let 
+            xiaomiDest = `${projDir}/sign/release`,
+            layaDest = `${workSpaceDir}/sign/release`;
+        let stream = gulp.src([privatePem, certificatePem]);
+        return stream.pipe(gulp.dest(xiaomiDest))
+                    .pipe(gulp.dest(layaDest));
+    } else if (config.oppoInfo.useReleaseSign && !config.oppoSign.generateSign) { // 使用release签名,并且没有重新生成
+        // 从项目中将签名拷贝到OPPO快游戏项目中
+        let 
+            privatePem = path.join(workSpaceDir, "sign", "release", "private.pem"),
+            certificatePem = path.join(workSpaceDir, "sign", "release", "certificate.pem");
+        let isSignExits = fs.existsSync(privatePem) && fs.existsSync(certificatePem);
+        if (!isSignExits) {
+            return;
+        }
+        let 
+            xiaomiDest = `${projDir}/sign/release`;
+        let stream = gulp.src([privatePem, certificatePem]);
+        return stream.pipe(gulp.dest(xiaomiDest));
+    }
+});
+
+gulp.task("deleteSignFile_OPPO", ["copySignFile_OPPO"], function() {
+	// 如果不是OPPO快游戏
+	if (platform !== "oppogame") {
+		return;
+	}
+	if (config.oppoSign.generateSign) { // 新生成的签名
+		let 
+            privatePem = path.join(projDir, "private.pem"),
+            certificatePem = path.join(projDir, "certificate.pem");
+		return del([privatePem, certificatePem], { force: true });
+	}
+});
+
+gulp.task("modifyFile_OPPO", ["deleteSignFile_OPPO"], function() {
+	// 如果不是OPPO快游戏
+	if (platform !== "oppogame") {
+		return;
+	}
+	// 修改manifest.json文件
+	let manifestPath = path.join(projDir, "manifest.json");
+	let IDEManifestPath = path.join(toolkitPath, "tpl", "manifest.json");
+	if (!fs.existsSync(IDEManifestPath)) {
+		return;
+	}
+	let manifestContent = fs.readFileSync(IDEManifestPath, "utf8");
+	let manifestJson = JSON.parse(manifestContent);
+	manifestJson.package = config.oppoInfo.package;
+	manifestJson.name = config.oppoInfo.name;
+	manifestJson.orientation = config.oppoInfo.orientation;
+	manifestJson.config.logLevel = config.oppoInfo.logLevel || "off";
+	manifestJson.versionName = config.oppoInfo.versionName;
+	manifestJson.versionCode = config.oppoInfo.versionCode;
+	manifestJson.minPlatformVersion = config.oppoInfo.minPlatformVersion;
+	manifestJson.icon = `./${path.basename(config.oppoInfo.icon)}`;
+	if (config.oppoInfo.subpack) {
+		manifestJson.subpackages = config.oppoSubpack;
+	}
+	fs.writeFileSync(manifestPath, JSON.stringify(manifestJson, null, 4), "utf8");
+
+	if (config.version) {
+		let versionPath = projDir + "/version.json";
+		versionCon = fs.readFileSync(versionPath, "utf8");
+		versionCon = JSON.parse(versionCon);
+	}
+	let indexJsStr = (versionCon && versionCon["index.js"]) ? versionCon["index.js"] :  "index.js";
+	// OPPO项目,修改main.js
+	let filePath = path.join(projDir, "main.js");
+	// 这个地方,1.x IDE和2.x IDE 不一致
+	let fileContent = `window.navigator.userAgent = 'Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LYZ28E) AppleWebKit/603.1.30 (KHTML, like Gecko) Mobile/14E8301 OPPO MiniGame NetType/WIFI Language/zh_CN';
+require("./libs/laya.quickgamemini.js");\nrequire("index.js");`;
+	fs.writeFileSync(filePath, fileContent, "utf8");
+
+	// OPPO项目,修改index.js
+	let indexFilePath = path.join(projDir, indexJsStr);
+	if (!fs.existsSync(indexFilePath)) {
+		return;
+	}
+	let indexFileContent = fs.readFileSync(indexFilePath, "utf8");
+	indexFileContent = indexFileContent.replace(/loadLib(\(['"])/gm, "require$1./");
+	fs.writeFileSync(indexFilePath, indexFileContent, "utf8");
+});
+
+gulp.task("version_OPPO", ["modifyFile_OPPO"], function () {
+	// 如果不是OPPO快游戏
+	if (platform !== "oppogame") {
+		return;
+	}
+	if (config.version) {
+		let versionPath = projDir + "/version.json";
+		let mainJSPath = projDir + "/main.js";
+		let srcList = [versionPath, mainJSPath];
+		return gulp.src(srcList)
+			.pipe(revCollector())
+			.pipe(gulp.dest(projDir));
+	}
+});
+
+// 打包rpk
+gulp.task("buildRPK_OPPO", ["version_OPPO"], function() {
+	// 如果不是OPPO快游戏
+	if (platform !== "oppogame") {
+		return;
+	}
+	// 在OPPO轻游戏项目目录中执行:
+    // quickgame pack || quickgame pack release
+    // quickgame subpack --no-build-js || quickgame subpack release --no-build-js
+	let cmdStr = "";
+	let packStr = "pack";
+	let nobuildjs = "";
+	if (config.oppoInfo.subpack) {
+		packStr = "subpack";
+		nobuildjs = "--no-build-js";
+	}
+    if (config.oppoInfo.useReleaseSign) {
+        cmdStr = "release";
+    }
+	return new Promise((resolve, reject) => {
+		let cmd = path.join(toolkitPath, "lib", "bin", `quickgame${commandSuffix}`);
+		let args = [packStr, cmdStr, nobuildjs];
+		let opts = {
+			cwd: projDir,
+			shell: true
+		};
+		let cp = childProcess.spawn(cmd, args, opts);
+		// let cp = childProcess.spawn('npx.cmd', ['-v']);
+		cp.stdout.on('data', (data) => {
+			console.log(`stdout: ${data}`);
+		});
+
+		cp.stderr.on('data', (data) => {
+			console.log(`stderr: ${data}`);
+			// reject();
+		});
+
+		cp.on('close', (code) => {
+			console.log(`子进程退出码:${code}`);
+			resolve();
+		});
+	});
+});
+
+gulp.task("pushRPK_OPPO", ["buildRPK_OPPO"], function() {
+	// 如果不是OPPO快游戏
+	if (platform !== "oppogame") {
+		return;
+	}
+	if (!config.oppoInfo.oppoDebug) {
+        return;
+    }
+	// 在OPPO轻游戏项目目录中执行:
+    // adb push dist/game.rpk sdcard/games
+	// adb push idePath/resources/app/out/layarepublic/oppo/instant_app_settings.properties
+	// adb shell am start -n com.nearme.instant.platform/com.oppo.autotest.main.InstantAppActivity
+	return new Promise((resolve, reject) => {
+		let cmd = "adb";
+		let sdGamesPath = config.oppoInfo.subpack ? "sdcard/subPkg" : "sdcard/games";
+		let args = ["push", `dist/${config.oppoInfo.package}${config.oppoInfo.useReleaseSign ? ".signed" : ""}.rpk`, sdGamesPath];
+		let opts = {
+			cwd: projDir,
+			shell: true
+		};
+		let cp = childProcess.spawn(cmd, args, opts);
+		// let cp = childProcess.spawn('npx.cmd', ['-v']);
+		cp.stdout.on('data', (data) => {
+			console.log(`stdout: ${data}`);
+		});
+
+		cp.stderr.on('data', (data) => {
+			console.log(`stderr: ${data}`);
+			// reject();
+		});
+
+		cp.on('close', (code) => {
+			console.log(`1) push_RPK 子进程退出码:${code}`);
+			resolve();
+		});
+	}).then(() => {
+		return new Promise((resolve, reject) => {
+			// 如果是分包,需要修改里面的内容
+			let oppoPropPath = path.join(ideModuleDir, "../", `/out/layarepublic/oppo/instant_app_settings.properties`);
+			if (config.oppoInfo.subpack) {
+				fs.writeFileSync(oppoPropPath, "default_tab_index=4", "utf8");
+			} else {
+				fs.writeFileSync(oppoPropPath, "default_tab_index=2", "utf8");
+			}
+			let cmd = "adb";
+			let args = ["push", oppoPropPath, "sdcard/"];
+			let opts = {
+				cwd: projDir,
+				shell: true
+			};
+			let cp = childProcess.spawn(cmd, args, opts);
+			// let cp = childProcess.spawn('npx.cmd', ['-v']);
+			cp.stdout.on('data', (data) => {
+				console.log(`stdout: ${data}`);
+			});
+	
+			cp.stderr.on('data', (data) => {
+				console.log(`stderr: ${data}`);
+				// reject();
+			});
+	
+			cp.on('close', (code) => {
+				console.log(`2) push_RPK 子进程退出码:${code}`);
+				resolve();
+			});
+		});
+	}).then(() => {
+		return new Promise((resolve, reject) => {
+			let cmd = "adb";
+			let args = ["shell", "am", "start", "-n", "com.nearme.instant.platform/com.oppo.autotest.main.InstantAppActivity"];
+			let opts = {
+				cwd: projDir,
+				shell: true
+			};
+			let cp = childProcess.spawn(cmd, args, opts);
+			// let cp = childProcess.spawn('npx.cmd', ['-v']);
+			cp.stdout.on('data', (data) => {
+				console.log(`stdout: ${data}`);
+			});
+	
+			cp.stderr.on('data', (data) => {
+				console.log(`stderr: ${data}`);
+				// reject();
+			});
+	
+			cp.on('close', (code) => {
+				console.log(`3) push_RPK 子进程退出码:${code}`);
+				resolve();
+			});
+		});
+	});
+});
+
+gulp.task("buildOPPOProj", ["pushRPK_OPPO"], function() {
+	console.log("all tasks completed");
+});

+ 342 - 0
ShootingSun/.laya/publish_qqgame.js

@@ -0,0 +1,342 @@
+// v1.3.0
+// publish 2.x 也是用这个文件,需要做兼容
+let isPublish2 = process.argv[2].includes("publish_qqgame.js") && process.argv[3].includes("--evn=publish2");
+// 获取Node插件和工作路径
+let ideModuleDir, workSpaceDir;
+if (isPublish2) {
+	//是否使用IDE自带的node环境和插件,设置false后,则使用自己环境(使用命令行方式执行)
+	const useIDENode = process.argv[0].indexOf("LayaAir") > -1 ? true : false;
+	ideModuleDir = useIDENode ? process.argv[1].replace("gulp\\bin\\gulp.js", "").replace("gulp/bin/gulp.js", "") : "";
+	workSpaceDir = useIDENode ? process.argv[2].replace("--gulpfile=", "").replace("\\.laya\\publish_qqgame.js", "").replace("/.laya/publish_qqgame.js", "") + "/" : "./../";
+} else {
+	ideModuleDir = global.ideModuleDir;
+	workSpaceDir = global.workSpaceDir;
+}
+
+//引用插件模块
+const gulp = require(ideModuleDir + "gulp");
+const fs = require("fs");
+const path = require("path");
+const crypto = require("crypto");
+const childProcess = require("child_process");
+const del = require(ideModuleDir + "del");
+const revCollector = require(ideModuleDir + 'gulp-rev-collector');
+let commandSuffix = ".cmd";
+const provider = "1109625052";
+const fullRemoteEngineList = ["laya.core.js", "laya.webgl.js", "laya.filter.js", "laya.ani.js", "laya.d3.js", "laya.html.js", "laya.particle.js", "laya.ui.js", "bytebuffer.js"];
+
+let copyLibsTask = ["copyLibsJsFile"];
+let packfiletask = ["packfile"];
+if (isPublish2) {
+	copyLibsTask = "";
+	packfiletask = ["copyPlatformFile_QQ"];
+}
+
+let 
+    config,
+	platform,
+    releaseDir;
+let isGlobalCli = true;
+let versionCon; // 版本管理version.json
+// 应该在publish中的,但是为了方便发布2.0及IDE 1.x,放在这里修改
+gulp.task("preCreate_QQ", copyLibsTask, function() {
+	if (isPublish2) {
+		let pubsetPath = path.join(workSpaceDir, ".laya", "pubset.json");
+		let content = fs.readFileSync(pubsetPath, "utf8");
+		let pubsetJson = JSON.parse(content);
+		platform = "qqgame";
+		releaseDir = path.join(workSpaceDir, "release", platform).replace(/\\/g, "/");
+		config = pubsetJson[2];
+	} else {
+		platform = global.platform;
+		releaseDir = global.releaseDir;
+		config = global.config;
+	}
+	// 如果不是QQ小游戏
+	if (platform !== "qqgame") {
+		return;
+	}
+	if (process.platform === "darwin") {
+		commandSuffix = "";
+	}
+	let copyLibsList = [`${workSpaceDir}/bin/libs/laya.qqmini.js`];
+	var stream = gulp.src(copyLibsList, { base: `${workSpaceDir}/bin` });
+	return stream.pipe(gulp.dest(releaseDir));
+});
+
+gulp.task("copyPlatformFile_QQ", ["preCreate_QQ"], function() {
+	// 如果不是QQ小游戏
+	if (platform !== "qqgame") {
+		return;
+	}
+	let isHasPublish = 
+		fs.existsSync(path.join(releaseDir, "game.js")) &&
+		fs.existsSync(path.join(releaseDir, "game.json")) &&
+		fs.existsSync(path.join(releaseDir, "project.config.json")) &&
+		fs.existsSync(path.join(releaseDir, "weapp-adapter.js"));
+	if (isHasPublish) {
+		return;
+	}
+	let adapterPath = path.join(ideModuleDir, "../", "out", "layarepublic", "LayaAirProjectPack", "lib", "data", "qqfiles");
+	let stream = gulp.src(adapterPath + "/*.*");
+	return stream.pipe(gulp.dest(releaseDir));
+});
+
+gulp.task("version_QQ", packfiletask, function() {
+	// 如果不是QQ小游戏
+	if (platform !== "qqgame") {
+		return;
+	}
+	if (config.version) {
+		let versionPath = releaseDir + "/version.json";
+		let gameJSPath = releaseDir + "/game.js";
+		let srcList = [versionPath, gameJSPath];
+		return gulp.src(srcList)
+			.pipe(revCollector())
+			.pipe(gulp.dest(releaseDir));
+	}
+});
+
+gulp.task("pluginEngin_QQ", ["version_QQ"], function(cb) {
+	// 如果不是微信小游戏
+	if (platform !== "qqgame") {
+		return cb();
+	}
+	if (!config.uesEnginePlugin) { // 没有使用微信引擎插件,还是像以前一样发布
+		return cb();
+	}
+	if (config.version) {
+		let versionPath = releaseDir + "/version.json";
+		versionCon = fs.readFileSync(versionPath, "utf8");
+		versionCon = JSON.parse(versionCon);
+	}
+	let indexJsStr = (versionCon && versionCon["index.js"]) ? versionCon["index.js"] :  "index.js";
+	
+	// 获取version等信息
+	let coreLibPath = path.join(workSpaceDir, "bin", "libs", "laya.core.js");
+	let isHasCoreLib = fs.existsSync(coreLibPath);
+	let isOldAsProj = fs.existsSync(`${workSpaceDir}/asconfig.json`) && !isHasCoreLib;
+	let isNewTsProj = fs.existsSync(`${workSpaceDir}/src/tsconfig.json`) && !isHasCoreLib;
+	let EngineVersion = getEngineVersion();
+	if (!EngineVersion) {
+		throw new Error(`读取引擎版本号失败,请于服务提供商联系!`);
+	}
+	if (!EngineVersion || EngineVersion.includes("beta") || !canUsePluginEngine(EngineVersion)) {
+		throw new Error(`该版本引擎无法使用引擎插件功能(engineVersion: ${EngineVersion})`);
+	}
+	console.log(`通过版本号检查:  ${EngineVersion}`);
+	// 使用引擎插件
+	let localUseEngineList = [];
+	let copyEnginePathList;
+	new Promise(function(resolve, reject) {
+		console.log(`修改game.js和game.json`);
+		// 1) 修改game.js和game.json
+		// 修改game.js
+		let gameJsPath = path.join(releaseDir, "game.js");
+		let gameJscontent = `require("weapp-adapter.js");\nrequire("./libs/laya.qqmini.js");\nrequirePlugin('layaPlugin');\nwindow.loadLib = require;\nrequire("./${indexJsStr}");`;
+		fs.writeFileSync(gameJsPath, gameJscontent, "utf8");
+		// 修改game.json,使其支持引擎插件
+		let gameJsonPath = path.join(releaseDir, "game.json");
+		let gameJsonContent = fs.readFileSync(gameJsonPath, "utf8");
+		let conJson = JSON.parse(gameJsonContent);
+		conJson.plugins = {
+			"layaPlugin": {
+				"version": EngineVersion,
+				"provider": provider,
+				"path": "laya-libs"
+			}
+		}
+		gameJsonContent = JSON.stringify(conJson, null, 4);
+		fs.writeFileSync(gameJsonPath, gameJsonContent, "utf8");
+		// 修改project.config.json
+		let projConfigPath = path.join(releaseDir, "project.config.json");
+		let projConfigcontent = fs.readFileSync(projConfigPath, "utf8");
+		let projConfigConJson = JSON.parse(projConfigcontent);
+		projConfigConJson.compileType = "gamePlugin";
+		projConfigConJson.pluginRoot = "laya-libs";
+		projConfigcontent = JSON.stringify(projConfigConJson, null, 4);
+		fs.writeFileSync(projConfigPath, projConfigcontent, "utf8");
+		resolve();
+	}).then(function() {
+		return new Promise(function(resolve, reject) {
+			console.log(`确定用到的插件引擎`);
+			// 2) 确定用到了那些插件引擎,并将插件引擎从index.js的引用中去掉
+			let indexJsPath = path.join(releaseDir, indexJsStr);
+			let indexJsCon = fs.readFileSync(indexJsPath, "utf8");
+			let item, fullRequireItem;
+			for (let i = 0, len = fullRemoteEngineList.length; i < len; i++) {
+				item = fullRemoteEngineList[i];
+				fullRequireItem = `loadLib("libs/${item}")`;
+				if (indexJsCon.includes(fullRequireItem)) {
+					localUseEngineList.push(item);
+					indexJsCon = indexJsCon.replace(fullRequireItem, "");
+				}
+			}
+			if (isOldAsProj || isNewTsProj) { // 如果as||ts_new语言,开发者将laya.js也写入index.js中了,将其删掉
+				fullRequireItem = `loadLib("laya.js")`;
+				if (indexJsCon.includes(fullRequireItem)) {
+					indexJsCon = indexJsCon.replace(fullRequireItem, "");
+				}
+			}
+			fs.writeFileSync(indexJsPath, indexJsCon, "utf8");
+			// ts/js再次修改game.js,仅引用使用到的类库
+			// as||ts_new因为本地只有laya.js,无法仅引用使用到的类库
+			if (!isOldAsProj && !isNewTsProj) {
+				let pluginCon = "";
+				localUseEngineList.forEach(function(item) {
+					pluginCon += `requirePlugin("layaPlugin/${item}");\n`;
+				});
+				let gameJsPath = path.join(releaseDir, "game.js");
+				let gameJsCon = fs.readFileSync(gameJsPath, "utf8");
+				gameJsCon = gameJsCon.replace(`requirePlugin('layaPlugin');`, pluginCon);
+				fs.writeFileSync(gameJsPath, gameJsCon, "utf8");
+			}
+			resolve();
+		});
+	}).then(function() {
+		return new Promise(function(resolve, reject) {
+			console.log(`将本地的引擎插件移动到laya-libs中`);
+			// 3) 将本地的引擎插件移动到laya-libs中
+			copyEnginePathList = [`${releaseDir}/libs/{${localUseEngineList.join(",")}}`];
+			if (isOldAsProj || isNewTsProj) { // 单独拷贝laya.js
+				copyEnginePathList = [`${releaseDir}/laya.js`];
+			}
+			gulp.src(copyEnginePathList).pipe(gulp.dest(`${releaseDir}/laya-libs`));
+			setTimeout(resolve, 500);
+		});
+	}).then(function() {
+		return new Promise(function(resolve, reject) {
+			console.log(`将libs中的本地引擎插件删掉`);
+			// 4) 将libs中的本地引擎插件删掉
+			del(copyEnginePathList, { force: true }).then(resolve);
+		});
+	}).then(function() {
+		return new Promise(async function(resolve, reject) {
+			console.log(`完善引擎插件目录`);
+			// 5) 引擎插件目录laya-libs中还需要新建几个文件,使该目录能够使用
+			if (isOldAsProj || isNewTsProj) { // 单独拷贝laya.js
+				localUseEngineList.push("laya.js");
+			}
+			let 
+				layalibsPath = path.join(releaseDir, "laya-libs"),
+				engineIndex = path.join(layalibsPath, "index.js"),
+				engineplugin = path.join(layalibsPath, "plugin.json"),
+				enginesignature = path.join(layalibsPath, "signature.json");
+			// index.js
+			if (!fs.existsSync(layalibsPath)) {
+				throw new Error("引擎插件目录创建失败,请与服务提供商联系!");
+			}
+			let indexCon = "";
+			localUseEngineList.forEach(function(item) {
+				indexCon += `require("./${item}");\n`;
+			});
+			fs.writeFileSync(engineIndex, indexCon, "utf8");
+			// plugin.json
+			let pluginCon = {"main": "index.js"};
+			fs.writeFileSync(engineplugin, JSON.stringify(pluginCon, null, 4), "utf8");
+			// signature.json
+			let signatureCon = {
+				"provider": provider,
+				"signature": []
+			};
+			localUseEngineList.unshift("index.js");
+			let fileName, md5Str;
+			for (let i = 0, len = localUseEngineList.length; i < len; i++) {
+				fileName = localUseEngineList[i];
+				let md5Str = await getFileMd5(path.join(releaseDir, "laya-libs", fileName));
+				signatureCon.signature.push({
+					"path": fileName,
+					"md5": md5Str
+				});
+			}
+			fs.writeFileSync(enginesignature, JSON.stringify(signatureCon, null, 4), "utf8");
+			resolve();
+		});
+	})
+	.then(function() {
+		cb();
+	}).catch(function(e) {
+		throw e;
+	})
+});
+
+function getEngineVersion() {
+	let coreLibPath = path.join(workSpaceDir, "bin", "libs", "laya.core.js");
+	let isHasCoreLib = fs.existsSync(coreLibPath);
+	let isOldAsProj = fs.existsSync(`${workSpaceDir}/asconfig.json`) && !isHasCoreLib;
+	let isNewTsProj = fs.existsSync(`${workSpaceDir}/src/tsconfig.json`) && !isHasCoreLib;
+	let EngineVersion;
+	if (isHasCoreLib) {
+		let con = fs.readFileSync(coreLibPath, "utf8");
+		let matchList = con.match(/Laya\.version\s*=\s*['"]([0-9\.]+(beta)?.*)['"]/);
+		if (!Array.isArray(matchList)) {
+			return null;
+		}
+		EngineVersion = matchList[1];
+	} else { // newts项目和旧版本as项目
+		if (isOldAsProj) {
+			let coreLibFilePath = path.join(workSpaceDir, "libs", "laya", "src", "Laya.as");
+			if (!fs.existsSync(coreLibFilePath)) {
+				return null;
+			}
+			let con = fs.readFileSync(coreLibFilePath, "utf8");
+			let matchList = con.match(/version:String\s*=\s*['"]([0-9\.]+(beta)?.*)['"]/);
+			if (!Array.isArray(matchList)) {
+				return null;
+			}
+			EngineVersion = matchList[1];
+		} else if (isNewTsProj) {
+			let coreLibFilePath = path.join(workSpaceDir, "libs", "Laya.ts");
+			if (!fs.existsSync(coreLibFilePath)) {
+				return null;
+			}
+			let con = fs.readFileSync(coreLibFilePath, "utf8");
+			let matchList = con.match(/static\s*version:\s*string\s*=\s*['"]([0-9\.]+(beta)?.*)['"]/);
+			if (!Array.isArray(matchList)) {
+				return null;
+			}
+			EngineVersion = matchList[1];
+		}
+	}
+	// 特殊处理,因为历史原因,我们有一些4位的正式版本,调整为3位
+	if (EngineVersion && /[\d\.]+/.test(EngineVersion) && EngineVersion.split(".").length > 3) {
+		let verList = EngineVersion.split(".");
+		verList.length = 3;
+		EngineVersion = verList.join(".");
+	}
+	return EngineVersion;
+}
+
+function getFileMd5(filePath) {
+	return new Promise(function(resolve, reject) {
+		let md5 = crypto.createHash('md5');
+		let stream = fs.createReadStream(filePath);
+		stream.on("data", function(data) {
+			md5.update(data);
+		});
+		stream.on("end", function() {
+			let md5Str = md5.digest('hex');
+			return resolve(md5Str);
+		});
+	});
+}
+
+function canUsePluginEngine(version) {
+	const minVersionNum = "2.1.1";
+	let compileMacthList = minVersionNum.match(/^(\d+)\.(\d+)\.(\d+)/);
+	let matchList = version.match(/^(\d+)\.(\d+)\.(\d+)/);
+    if (matchList[1] > compileMacthList[1]) {
+        return true;
+	}
+    if (matchList[1] === compileMacthList[1] && matchList[2] > compileMacthList[2]) {
+        return true;
+    }
+    if (matchList[1] === compileMacthList[1] && matchList[2] === compileMacthList[2] && matchList[3] >= compileMacthList[3]) {
+        return true;
+    }
+    return false;
+}
+
+gulp.task("buildQQProj", ["pluginEngin_QQ"], function() {
+	console.log("all tasks completed");
+});

+ 739 - 0
ShootingSun/.laya/publish_vivogame.js

@@ -0,0 +1,739 @@
+// v1.3.0
+// publish 2.x 也是用这个文件,需要做兼容
+let isPublish2 = process.argv[2].includes("publish_vivogame.js") && process.argv[3].includes("--evn=publish2");
+// 获取Node插件和工作路径
+let ideModuleDir, workSpaceDir;
+if (isPublish2) {
+	//是否使用IDE自带的node环境和插件,设置false后,则使用自己环境(使用命令行方式执行)
+	const useIDENode = process.argv[0].indexOf("LayaAir") > -1 ? true : false;
+	ideModuleDir = useIDENode ? process.argv[1].replace("gulp\\bin\\gulp.js", "").replace("gulp/bin/gulp.js", "") : "";
+	workSpaceDir = useIDENode ? process.argv[2].replace("--gulpfile=", "").replace("\\.laya\\publish_vivogame.js", "").replace("/.laya/publish_vivogame.js", "") + "/" : "./../";
+} else {
+	ideModuleDir = global.ideModuleDir;
+	workSpaceDir = global.workSpaceDir;
+}
+
+//引用插件模块
+const gulp = require(ideModuleDir + "gulp");
+const fs = require("fs");
+const path = require("path");
+const childProcess = require("child_process");
+const del = require(ideModuleDir + "del");
+const iconv =  require(ideModuleDir + "iconv-lite");
+const revCollector = require(ideModuleDir + 'gulp-rev-collector');
+let commandSuffix = ".cmd";
+
+let copyLibsTask = ["copyLibsJsFile"];
+let packfiletask = ["packfile"];
+if (isPublish2) {
+	copyLibsTask = "";
+	packfiletask = ["copyPlatformFile_VIVO"];
+}
+
+let 
+    config,
+	platform,
+	releaseDir,
+    tempReleaseDir, // vivo临时拷贝目录
+	projDir, // vivo快游戏工程目录
+	isDealNoCompile = true,
+	physicsLibsPathList = [],
+	isExistEngineFolder = false; // bin目录下是否存在engine文件夹
+let projSrc;
+let versionCon; // 版本管理version.json
+// 创建vivo项目前,拷贝vivo引擎库、修改index.js
+// 应该在publish中的,但是为了方便发布2.0及IDE 1.x,放在这里修改
+gulp.task("preCreate_VIVO", copyLibsTask, function() {
+	if (isPublish2) {
+		let pubsetPath = path.join(workSpaceDir, ".laya", "pubset.json");
+		let content = fs.readFileSync(pubsetPath, "utf8");
+		let pubsetJson = JSON.parse(content);
+		platform = "vivogame";
+		releaseDir = path.join(workSpaceDir, "release", platform).replace(/\\/g, "/");
+		releaseDir = tempReleaseDir = path.join(releaseDir, "temprelease");
+		config = pubsetJson[6]; // 只用到了 config.vivoInfo|config.vivoSign
+	} else {
+		platform = global.platform;
+		releaseDir = global.releaseDir;
+		tempReleaseDir = global.tempReleaseDir;
+		config = global.config;
+	}
+	// 如果不是vivo快游戏
+	if (platform !== "vivogame") {
+		return;
+	}
+	if (process.platform === "darwin") {
+		commandSuffix = "";
+	}
+	let copyLibsList = [`${workSpaceDir}/bin/libs/laya.vvmini.js`];
+	var stream = gulp.src(copyLibsList, { base: `${workSpaceDir}/bin` });
+	return stream.pipe(gulp.dest(tempReleaseDir));
+});
+
+gulp.task("copyPlatformFile_VIVO", ["preCreate_VIVO"], function() {
+	// 如果不是vivo快游戏
+	if (platform !== "vivogame") {
+		return;
+	}
+	let vivoAdapterPath = path.join(ideModuleDir, "../", "out", "layarepublic", "LayaAirProjectPack", "lib", "data", "vivofiles");
+	let copyLibsList = [`${vivoAdapterPath}/**/*.*`];
+	var stream = gulp.src(copyLibsList);
+	return stream.pipe(gulp.dest(tempReleaseDir));
+});
+
+// 检查是否全局安装了qgame
+gulp.task("createGlobalQGame_VIVO", packfiletask, function() {
+	// 如果不是vivo快游戏
+	if (platform !== "vivogame") {
+		return;
+	}
+	releaseDir = path.dirname(releaseDir);
+	projDir = path.join(releaseDir, config.vivoInfo.projName);
+	projSrc = path.join(projDir, "src");
+	// npm view @vivo-minigame/cli version
+	// npm install -g @vivo-minigame/cli
+	let remoteVersion, localVersion;
+	let isGetRemote, isGetLocal;
+	let isUpdateGlobalQGame = true;
+	return new Promise((resolve, reject) => { // 远程版本号
+		childProcess.exec("npm view  @vivo-minigame/cli version", function(error, stdout, stderr) {
+			if (!stdout) { // 获取 @vivo-minigame/cli 远程版本号失败
+				console.log("Failed to get the remote version number");
+				resolve();
+				return;
+			}
+			remoteVersion = stdout;
+			isGetRemote = true;
+			if (isGetRemote && isGetLocal) {
+				isUpdateGlobalQGame = remoteVersion != localVersion;
+				console.log(`remoteVersion: ${remoteVersion}, localVersion: ${localVersion}`);
+				resolve();
+			}
+		});
+		childProcess.exec("mg -v", { cwd: `${projDir}/node_modules` }, function(error, stdout, stderr) {
+			if (!stdout) { // 获取  @vivo-minigame/cli 本地版本号失败
+				console.log("Failed to get the local version number");
+				resolve();
+				return;
+			}
+			localVersion = stdout;
+			isGetLocal = true;
+			if (isGetRemote && isGetLocal) {
+				isUpdateGlobalQGame = remoteVersion != localVersion;
+				console.log(`remoteVersion: ${remoteVersion}, localVersion: ${localVersion}`);
+				resolve();
+			}
+		});
+		setTimeout(() => {
+			if (!isGetLocal || !isGetRemote) {
+				console.log("Failed to get the local or remote version number");
+				resolve();
+				return;
+			}
+		}, 10000);
+	}).then(() => {
+		return new Promise((resolve, reject) => {
+			if (!isUpdateGlobalQGame) {
+				resolve();
+				return;
+			}
+			console.log("全局安装@vivo-minigame/cli");
+			// npm install -g @vivo-minigame/cli
+			let cmd = `npm${commandSuffix}`;
+			let args = ["install", "@vivo-minigame/cli", "-g"];
+			let opts = {
+				shell: true
+			};
+			let cp = childProcess.spawn(cmd, args, opts);
+			
+			cp.stdout.on('data', (data) => {
+				console.log(`stdout: ${data}`);
+			});
+	
+			cp.stderr.on('data', (data) => {
+				console.log(`stderr: ${data}`);
+				// reject();
+			});
+	
+			cp.on('close', (code) => {
+				console.log(`2 end) npm install -g @vivo-minigame/cli:${code}`);
+				resolve();
+			});
+		});
+	}).catch((e) => {
+		console.log("catch e", e);
+	});
+});
+
+gulp.task("createProj_VIVO", ["createGlobalQGame_VIVO"], function() {
+	// 如果不是vivo快游戏
+	if (platform !== "vivogame") {
+		return;
+	}
+	// 如果有即存项目,不再新建
+	let isProjExist = fs.existsSync(projDir + "/node_modules") && 
+					  fs.existsSync(projDir + "/sign");
+	if (isProjExist) {
+		// 检测是否需要升级
+		let packageCon = fs.readFileSync(`${projDir}/package.json`, "utf8");
+		let minigamePath = path.join(projDir, "minigame.config.js");
+		if (packageCon.includes("@vivo-minigame/cli-service") && fs.existsSync(minigamePath)) {
+			return;
+		}
+	}
+	// 如果有即存项目,但是是旧的项目,删掉后重新创建
+	return new Promise((resolve, reject) => {
+		if (!fs.existsSync(projDir)) {
+			return resolve();
+		}
+		let delList = [projDir];
+		del(delList, { force: true }).then(paths => {
+			resolve();
+		});
+	}).then(function() {
+		// 在项目中创建vivo项目
+		return new Promise((resolve, reject) => {
+			console.log("(proj)开始创建vivo快游戏项目");
+			// mg init <project-name>
+			let cmd = `mg${commandSuffix}`;
+			let args = ["init", config.vivoInfo.projName];
+			let opts = {
+				cwd: releaseDir,
+				shell: true
+			};
+
+			let cp = childProcess.spawn(cmd, args, opts);
+			
+			cp.stdout.on('data', (data) => {
+				console.log(`stdout: ${data}`);
+			});
+			
+			cp.stderr.on('data', (data) => {
+				console.log(`stderr: ${data}`);
+				// reject();
+			});
+			
+			cp.on('close', (code) => {
+				cp = null;
+				console.log(`子进程退出码:${code}`);
+				resolve();
+			});
+		});
+	});
+});
+
+// 拷贝文件到vivo快游戏
+gulp.task("copyFileToProj_VIVO", ["createProj_VIVO"], function() {
+	// 如果不是vivo快游戏
+	if (platform !== "vivogame") {
+		return;
+	}
+	// 如果有js/main.js,将其删除
+	let vivoMainPath = path.join(projDir, "src", "js", "main.js");
+	if (fs.existsSync(vivoMainPath)) {
+		fs.unlinkSync(vivoMainPath);
+	}
+	// 将临时文件夹中的文件,拷贝到项目中去
+	let originalDir = `${tempReleaseDir}/**/*.*`;
+	let stream = gulp.src(originalDir);
+	return stream.pipe(gulp.dest(path.join(projSrc)));
+});
+
+// 拷贝icon到vivo快游戏
+gulp.task("copyIconToProj_VIVO", ["copyFileToProj_VIVO"], function() {
+	// 如果不是vivo快游戏
+	if (platform !== "vivogame") {
+		return;
+	}
+	let originalDir = config.vivoInfo.icon;
+	let stream = gulp.src(originalDir);
+	return stream.pipe(gulp.dest(projSrc));
+});
+
+// 清除vivo快游戏临时目录
+gulp.task("clearTempDir_VIVO", ["copyIconToProj_VIVO"], function() {
+	// 如果不是vivo快游戏
+	if (platform !== "vivogame") {
+		return;
+	}
+	// 删掉临时目录
+	return del([tempReleaseDir], { force: true });
+});
+
+// 生成release签名(私钥文件 private.pem 和证书文件 certificate.pem )
+gulp.task("generateSign_VIVO", ["clearTempDir_VIVO"], function() {
+	// 如果不是vivo快游戏
+	if (platform !== "vivogame") {
+		return;
+    }
+    if (!config.vivoSign.generateSign) {
+        return;
+    }
+	// https://doc.quickapp.cn/tools/compiling-tools.html
+	return new Promise((resolve, reject) => {
+		let cmd = "openssl";
+		let args = ["req", "-newkey", "rsa:2048", "-nodes", "-keyout", "private.pem", 
+					"-x509", "-days", "3650", "-out", "certificate.pem"];
+		let opts = {
+			cwd: projDir,
+			shell: true
+		};
+		let cp = childProcess.spawn(cmd, args, opts);
+		cp.stdout.on('data', (data) => {
+			console.log(`stdout: ${data}`);
+		});
+
+		cp.stderr.on('data', (data) => {
+			console.log(`stderr: ${data}`);
+			data += "";
+			if (data.includes("Country Name")) {
+				cp.stdin.write(`${config.vivoSign.countryName}\n`);
+				console.log(`Country Name: ${config.vivoSign.countryName}`);
+			} else if (data.includes("Province Name")) {
+				cp.stdin.write(`${config.vivoSign.provinceName}\n`);
+				console.log(`Province Name: ${config.vivoSign.provinceName}`);
+			} else if (data.includes("Locality Name")) {
+				cp.stdin.write(`${config.vivoSign.localityName}\n`);
+				console.log(`Locality Name: ${config.vivoSign.localityName}`);
+			} else if (data.includes("Organization Name")) {
+				cp.stdin.write(`${config.vivoSign.orgName}\n`);
+				console.log(`Organization Name: ${config.vivoSign.orgName}`);
+			} else if (data.includes("Organizational Unit Name")) {
+				cp.stdin.write(`${config.vivoSign.orgUnitName}\n`);
+				console.log(`Organizational Unit Name: ${config.vivoSign.orgUnitName}`);
+			} else if (data.includes("Common Name")) {
+				cp.stdin.write(`${config.vivoSign.commonName}\n`);
+				console.log(`Common Name: ${config.vivoSign.commonName}`);
+			} else if (data.includes("Email Address")) {
+				cp.stdin.write(`${config.vivoSign.emailAddr}\n`);
+				console.log(`Email Address: ${config.vivoSign.emailAddr}`);
+				// cp.stdin.end();
+			}
+			// reject();
+		});
+
+		cp.on('close', (code) => {
+			console.log(`子进程退出码:${code}`);
+			resolve();
+		});
+	});
+});
+
+// 拷贝sign文件到指定位置
+gulp.task("copySignFile_VIVO", ["generateSign_VIVO"], function() {
+	// 如果不是vivo快游戏
+	if (platform !== "vivogame") {
+		return;
+    }
+    if (config.vivoSign.generateSign) { // 新生成的签名
+        // 移动签名文件到项目中(Laya & vivo快游戏项目中)
+        let 
+            privatePem = path.join(projDir, "private.pem"),
+            certificatePem = path.join(projDir, "certificate.pem");
+        let isSignExits = fs.existsSync(privatePem) && fs.existsSync(certificatePem);
+        if (!isSignExits) {
+            return;
+        }
+        let 
+            xiaomiDest = `${projDir}/sign/release`,
+            layaDest = `${workSpaceDir}/sign/release`;
+        let stream = gulp.src([privatePem, certificatePem]);
+        return stream.pipe(gulp.dest(xiaomiDest))
+                    .pipe(gulp.dest(layaDest));
+    } else if (config.vivoInfo.useReleaseSign && !config.vivoSign.generateSign) { // 使用release签名,并且没有重新生成
+        // 从项目中将签名拷贝到vivo快游戏项目中
+        let 
+            privatePem = path.join(workSpaceDir, "sign", "release", "private.pem"),
+            certificatePem = path.join(workSpaceDir, "sign", "release", "certificate.pem");
+        let isSignExits = fs.existsSync(privatePem) && fs.existsSync(certificatePem);
+        if (!isSignExits) {
+            return;
+        }
+        let 
+            xiaomiDest = `${projDir}/sign/release`;
+        let stream = gulp.src([privatePem, certificatePem]);
+        return stream.pipe(gulp.dest(xiaomiDest));
+    }
+});
+
+gulp.task("deleteSignFile_VIVO", ["copySignFile_VIVO"], function() {
+	// 如果不是vivo快游戏
+	if (platform !== "vivogame") {
+		return;
+	}
+	if (config.vivoSign.generateSign) { // 新生成的签名
+		let 
+            privatePem = path.join(projDir, "private.pem"),
+            certificatePem = path.join(projDir, "certificate.pem");
+		return del([privatePem, certificatePem], { force: true });
+	}
+});
+
+gulp.task("modifyFile_VIVO", ["deleteSignFile_VIVO"], function() {
+	// 如果不是vivo快游戏
+	if (platform !== "vivogame") {
+		return;
+	}
+	// 修改manifest.json文件
+	let manifestPath = path.join(projSrc, "manifest.json");
+	if (!fs.existsSync(manifestPath)) {
+		return;
+	}
+	let manifestContent = fs.readFileSync(manifestPath, "utf8");
+	let manifestJson = JSON.parse(manifestContent);
+	manifestJson.package = config.vivoInfo.package;
+	manifestJson.name = config.vivoInfo.name;
+	manifestJson.orientation = config.vivoInfo.orientation;
+	manifestJson.config.logLevel = config.vivoInfo.logLevel || "off";
+	manifestJson.deviceOrientation = config.vivoInfo.orientation;
+	manifestJson.versionName = config.vivoInfo.versionName;
+	manifestJson.versionCode = config.vivoInfo.versionCode;
+	manifestJson.minPlatformVersion = config.vivoInfo.minPlatformVersion;
+	manifestJson.icon = `/${path.basename(config.vivoInfo.icon)}`;
+	if (config.vivoInfo.subpack) { // 分包
+		manifestJson.subpackages = config.vivoSubpack;
+	} else {
+		delete manifestJson.subpackages;
+	}
+	// 增加thirdEngine字段
+	let EngineVersion = getEngineVersion();
+	if (EngineVersion) {
+		manifestJson.thirdEngine = {
+			"laya": EngineVersion
+		};
+	}
+	fs.writeFileSync(manifestPath, JSON.stringify(manifestJson, null, 4), "utf8");
+	
+	if (config.version) {
+		let versionPath = projSrc + "/version.json";
+		versionCon = fs.readFileSync(versionPath, "utf8");
+		versionCon = JSON.parse(versionCon);
+	}
+	let indexJsStr = (versionCon && versionCon["index.js"]) ? versionCon["index.js"] :  "index.js";
+	// 修改game.js文件
+	let content = `require("./qgame-adapter.js");\nif(!window.navigator)\n\twindow.navigator = {};\nwindow.navigator.userAgent = 'Mozilla/5.0 (Linux; Android 5.1.1; Nexus 6 Build/LYZ28E) AppleWebKit/603.1.30 (KHTML, like Gecko) Mobile/14E8301 VVGame NetType/WIFI Language/zh_CN';
+require("./libs/laya.vvmini.js");\nrequire("./index.js");`;
+	let gameJsPath = path.join(projSrc, "game.js");
+	fs.writeFileSync(gameJsPath, content, "utf8");
+
+	// vivo项目,修改index.js
+	let filePath = path.join(projSrc, indexJsStr);
+	if (!fs.existsSync(filePath)) {
+		return;
+	}
+	let fileContent = fs.readFileSync(filePath, "utf8");
+	fileContent = fileContent.replace(/loadLib(\(['"])/gm, "require$1./");
+	fs.writeFileSync(filePath, fileContent, "utf8");
+})
+
+function getEngineVersion() {
+	let coreLibPath = path.join(workSpaceDir, "bin", "libs", "laya.core.js");
+	let isHasCoreLib = fs.existsSync(coreLibPath);
+	let isOldAsProj = fs.existsSync(`${workSpaceDir}/asconfig.json`) && !isHasCoreLib;
+	let isNewTsProj = fs.existsSync(`${workSpaceDir}/src/tsconfig.json`) && !isHasCoreLib;
+	let EngineVersion;
+	if (isHasCoreLib) {
+		let con = fs.readFileSync(coreLibPath, "utf8");
+		let matchList = con.match(/Laya\.version\s*=\s*['"]([0-9\.]+(beta)?.*)['"]/);
+		if (!Array.isArray(matchList)) {
+			return null;
+		}
+		EngineVersion = matchList[1];
+	} else { // newts项目和旧版本as项目
+		if (isOldAsProj) {
+			let coreLibFilePath = path.join(workSpaceDir, "libs", "laya", "src", "Laya.as");
+			if (!fs.existsSync(coreLibFilePath)) {
+				return null;
+			}
+			let con = fs.readFileSync(coreLibFilePath, "utf8");
+			let matchList = con.match(/version:String\s*=\s*['"]([0-9\.]+(beta)?.*)['"]/);
+			if (!Array.isArray(matchList)) {
+				return null;
+			}
+			EngineVersion = matchList[1];
+		} else if (isNewTsProj) {
+			let coreLibFilePath = path.join(workSpaceDir, "libs", "Laya.ts");
+			if (!fs.existsSync(coreLibFilePath)) {
+				return null;
+			}
+			let con = fs.readFileSync(coreLibFilePath, "utf8");
+			let matchList = con.match(/static\s*version:\s*string\s*=\s*['"]([0-9\.]+(beta)?.*)['"]/);
+			if (!Array.isArray(matchList)) {
+				return null;
+			}
+			EngineVersion = matchList[1];
+		}
+	}
+	return EngineVersion;
+}
+
+gulp.task("version_VIVO", ["modifyFile_VIVO"], function () {
+	// 如果不是vivo快游戏
+	if (platform !== "vivogame") {
+		return;
+	}
+	if (config.version) {
+		let versionPath = projSrc + "/version.json";
+		let mainJSPath = projSrc + "/game.js";
+		let srcList = [versionPath, mainJSPath];
+		return gulp.src(srcList)
+			.pipe(revCollector())
+			.pipe(gulp.dest(projSrc));
+	}
+});
+
+// 处理engine文件夹
+gulp.task("dealEngineFolder1_VIVO", ["version_VIVO"], function() {
+	// 如果项目中有engine文件夹,我们默认该开发者是熟悉VIVO发布流程的,已经处理好所有的逻辑
+	// 值得注意的:
+	// 1) 如果有engine文件夹而未处理2D物理库(box2d.js/physics.js),项目将无法运行
+	// 2) 如果未处理3D物理库(physics3D.js),打包时间将会很长
+
+	// 如果不是vivo快游戏
+	if (platform !== "vivogame") {
+		return;
+	}
+	let engineFolder = path.join(projDir, "src", "engine");
+	isExistEngineFolder = fs.existsSync(engineFolder);
+	if (!isExistEngineFolder) {
+		return;
+	}
+
+	let adapterOriginalPath = path.join(projDir, "src", "qgame-adapter.js");
+
+	// 不想写一堆task任务,500ms默认拷贝完成吧
+	// 未来有了更好的解决方案再修改
+	return new Promise(function(resolve, reject) {
+		// 将engine文件夹拷贝到projRoot下
+		setTimeout(resolve, 500);
+		var stream = gulp.src([`${engineFolder}/**/*.*`], {base: `${projDir}/src`});
+		return stream.pipe(gulp.dest(projDir));
+	}).then(function() {
+		return new Promise(function(resolve, reject) {
+			// 将adapter.js拷贝到engine文件夹中
+			setTimeout(resolve, 500);
+			var stream = gulp.src([adapterOriginalPath]);
+			return stream.pipe(gulp.dest(`${projDir}/engine`));
+		});
+	}).then(function() {
+		return new Promise(function(resolve, reject) {
+			// 删掉src下的engine和adapter
+			setTimeout(resolve, 500);
+			return del([engineFolder, adapterOriginalPath], { force: true });
+		});
+	}).catch(function(err) {
+		console.log(err);
+	});
+});
+
+gulp.task("dealEngineFolder2_VIVO", ["dealEngineFolder1_VIVO"], function() {
+	// 如果不是vivo快游戏
+	if (platform !== "vivogame") {
+		return;
+	}
+	if (!isExistEngineFolder) {
+		return;
+	}
+	
+	let engineFolder = path.join(projDir, "engine");
+	let engineFileList = fs.readdirSync(engineFolder);
+	// 修改配置文件
+	configVivoConfigFile(engineFileList);
+});
+
+// 如果项目中用到了 box2d.js|laya.physics.js/laya.physics3D.js ,需要特殊处理
+// 之前处理的是有项目中已经存在engine文件夹的情况,现在开始处理没有文件夹的情况
+gulp.task("dealNoCompile1_VIVO", ["dealEngineFolder2_VIVO"], function() {
+	// 如果不是vivo快游戏
+	if (platform !== "vivogame") {
+		return;
+	}
+	if (!isDealNoCompile) {
+		return;
+	}
+
+	// let indexJsStr = (versionCon && versionCon["index.js"]) ? versionCon["index.js"] :  "index.js";
+	// let bundleJsStr = (versionCon && versionCon["js/bundle.js"]) ? versionCon["js/bundle.js"] :  "js/bundle.js";
+	// let box2dJsStr = (versionCon && versionCon["libs/box2d.js"]) ? versionCon["libs/box2d.js"] :  "libs/box2d.js";
+	// let physicsJsStr = (versionCon && versionCon["libs/laya.physics.js"]) ? versionCon["libs/laya.physics.js"] :  "libs/laya.physics.js";
+	// let physics3DJsStr = (versionCon && versionCon["libs/laya.physics3D.js"]) ? versionCon["libs/laya.physics3D.js"] :  "libs/laya.physics3D.js";
+
+	// // 修改index.js,去掉物理库前面的libs
+	// let filePath = path.join(projSrc, indexJsStr);
+	// let fileContent = fs.readFileSync(filePath, "utf8");
+	// let physicsNameList = [];
+
+	// if (fileContent.includes(bundleJsStr)) {
+	// 	let adapterJsPath = path.join(projSrc, bundleJsStr);
+	// 	physicsNameList.push(bundleJsStr);
+	// 	physicsLibsPathList.push(adapterJsPath);
+	// }
+	// if (fileContent.includes(box2dJsStr)) {
+	// 	let libPath = path.join(projSrc, box2dJsStr);
+	// 	physicsNameList.push(box2dJsStr);
+	// 	physicsLibsPathList.push(libPath);
+	// }
+	// if (fileContent.includes(physicsJsStr)) {
+	// 	let libPath = path.join(projSrc, physicsJsStr);
+	// 	physicsNameList.push(physicsJsStr);
+	// 	physicsLibsPathList.push(libPath);
+	// }
+	// if (fileContent.includes(physics3DJsStr)) {
+	// 	let libPath = path.join(projSrc, physics3DJsStr);
+	// 	physicsNameList.push(physics3DJsStr);
+	// 	physicsLibsPathList.push(libPath);
+	// }
+	// if (physicsLibsPathList.length > 0) {
+	// 	let adapterJsPath = path.join(projSrc, "qgame-adapter.js");
+	// 	physicsNameList.push("qgame-adapter.js");
+	// 	physicsLibsPathList.push(adapterJsPath);
+	// }
+
+
+	// 将js/bundle.js | libs/*.* qgame-adapter.js 全放到engine文件夹中
+	let indexJsStr = (versionCon && versionCon["index.js"]) ? versionCon["index.js"] :  "index.js";
+	let bundleJsStr = (versionCon && versionCon["js/bundle.js"]) ? versionCon["js/bundle.js"] :  "js/bundle.js";
+
+	// 修改index.js,去掉物理库前面的libs
+	let filePath = path.join(projSrc, indexJsStr);
+	let fileContent = fs.readFileSync(filePath, "utf8");
+	let physicsNameList = [];
+
+	if (fileContent.includes(bundleJsStr)) {
+		let adapterJsPath = path.join(projSrc, bundleJsStr);
+		physicsNameList.push(bundleJsStr);
+		physicsLibsPathList.push(adapterJsPath);
+	}
+	let libsList = fs.readdirSync(path.join(projSrc, "libs"));
+	let libsFileName, libsFilePath;
+	for (let i = 0, len = libsList.length; i < len; i++) {
+		libsFileName = libsList[i];
+		libsFilePath = path.join(projSrc, "libs", libsFileName);
+		physicsNameList.push(`libs/${libsFileName}`);
+		physicsLibsPathList.push(libsFilePath);
+	}
+	if (physicsLibsPathList.length > 0) {
+		let adapterJsPath = path.join(projSrc, "qgame-adapter.js");
+		physicsNameList.push("qgame-adapter.js");
+		physicsLibsPathList.push(adapterJsPath);
+	}
+
+	// 修改配置文件
+	configVivoConfigFile(physicsNameList);
+
+	// 将物理库、qgame-adapter.js拷贝到engine中
+	var stream = gulp.src(physicsLibsPathList, {base: projSrc});
+	return stream.pipe(gulp.dest(path.join(projDir, "engine")));
+});
+
+function configVivoConfigFile(engineFileList) {
+	let vvConfigPath = path.join(projDir, "minigame.config.js");
+	let content = fs.readFileSync(vvConfigPath, "utf8");
+	let externalsStr = 'const externals = [\n';
+	let libName;
+	for (let i = 0, len = engineFileList.length; i < len; i++) {
+		libName = engineFileList[i];
+		if (i !== 0) {
+			externalsStr += ',\n';
+		}
+		// 不要改这里的缩进,否则最终的结果不好看
+		externalsStr += `{
+		module_name:'./${libName}',
+		module_path:'./${libName}',
+		module_from:'engine/${libName}'
+	}`;
+	}
+	externalsStr += '\t]';
+	content = content.replace(/const externals = \[([^*].|\n|\r)*\]/gm, externalsStr);
+	fs.writeFileSync(vvConfigPath, content, "utf8");
+}
+
+gulp.task("dealNoCompile2_VIVO", ["dealNoCompile1_VIVO"], function() {
+	// 如果不是vivo快游戏
+	if (platform !== "vivogame") {
+		return;
+	}
+	if (!isDealNoCompile || physicsLibsPathList.length === 0) {
+		return;
+	}
+	return del(physicsLibsPathList, { force: true });
+});
+
+// 打包rpk
+gulp.task("buildRPK_VIVO", ["dealNoCompile2_VIVO"], function() {
+	// 如果不是vivo快游戏
+	if (platform !== "vivogame") {
+		return;
+	}
+	// 在vivo轻游戏项目目录中执行:
+    // npm run build || npm run release
+    let cmdStr = "build";
+    if (config.vivoInfo.useReleaseSign) {
+        cmdStr = "release";
+    }
+	return new Promise((resolve, reject) => {
+		let cmd = `npm${commandSuffix}`;
+		let args = ["run", cmdStr];
+		let opts = {
+			cwd: projDir,
+			shell: true
+		};
+		let cp = childProcess.spawn(cmd, args, opts);
+		// let cp = childProcess.spawn(`npx${commandSuffix}`, ['-v']);
+		cp.stdout.on('data', (data) => {
+			console.log(`stdout: ${data}`);
+		});
+
+		cp.stderr.on('data', (data) => {
+			console.log(`stderr: ${data}`);
+			console.log(`stderr(iconv): ${iconv.decode(data, 'gbk')}`);
+			
+			// reject();
+		});
+
+		cp.on('close', (code) => {
+			console.log(`子进程退出码:${code}`);
+			resolve();
+		});
+	});
+});
+
+gulp.task("showQRCode_VIVO", ["buildRPK_VIVO"], function() {
+	// 如果不是vivo快游戏
+	if (platform !== "vivogame") {
+		return;
+	}
+	// 在vivo轻游戏项目目录中执行:
+	// npm run server
+	return new Promise((resolve, reject) => {
+		let cmd = `npm${commandSuffix}`;
+		let args = ["run", "server"];
+		let opts = {
+			cwd: projDir,
+			shell: true
+		};
+		let cp = childProcess.spawn(cmd, args, opts);
+		// let cp = childProcess.spawn(`npx${commandSuffix}`, ['-v']);
+		cp.stdout.on('data', (data) => {
+			console.log(`${data}`);
+			// 输出pid,macos要用: macos无法kill进程树,也无法执行命令获取3000端口pid(没有查询权限),导致无法kill这个进程
+			console.log('vv_qrcode_pid:' + cp.pid);
+		});
+
+		cp.stderr.on('data', (data) => {
+			console.log(`stderr: ${data}`);
+			console.log(`stderr(iconv): ${iconv.decode(data, 'gbk')}`);
+			// reject();
+		});
+
+		cp.on('close', (code) => {
+			console.log(`子进程退出码:${code}`);
+			resolve();
+		});
+	});
+});
+
+
+gulp.task("buildVivoProj", ["showQRCode_VIVO"], function() {
+	console.log("all tasks completed");
+});

+ 435 - 0
ShootingSun/.laya/publish_wxgame.js

@@ -0,0 +1,435 @@
+// v1.3.1
+// publish 2.x 也是用这个文件,需要做兼容
+let isPublish2 = process.argv[2].includes("publish_wxgame.js") && process.argv[3].includes("--evn=publish2");
+// 获取Node插件和工作路径
+let ideModuleDir, workSpaceDir;
+if (isPublish2) {
+	//是否使用IDE自带的node环境和插件,设置false后,则使用自己环境(使用命令行方式执行)
+	const useIDENode = process.argv[0].indexOf("LayaAir") > -1 ? true : false;
+	ideModuleDir = useIDENode ? process.argv[1].replace("gulp\\bin\\gulp.js", "").replace("gulp/bin/gulp.js", "") : "";
+	workSpaceDir = useIDENode ? process.argv[2].replace("--gulpfile=", "").replace("\\.laya\\publish_wxgame.js", "").replace("/.laya/publish_wxgame.js", "") + "/" : "./../";
+} else {
+	ideModuleDir = global.ideModuleDir;
+	workSpaceDir = global.workSpaceDir;
+}
+
+//引用插件模块
+const gulp = require(ideModuleDir + "gulp");
+const fs = require("fs");
+const path = require("path");
+const crypto = require("crypto");
+const childProcess = require("child_process");
+const del = require(ideModuleDir + "del");
+const revCollector = require(ideModuleDir + 'gulp-rev-collector');
+let commandSuffix = ".cmd";
+const provider = "wx70d8aa25ec591f7a";
+const fullRemoteEngineList = ["laya.core.js", "laya.webgl.js", "laya.filter.js", "laya.ani.js", "laya.d3.js", "laya.html.js", "laya.particle.js", "laya.ui.js", "laya.d3Plugin.js"];
+
+let copyLibsTask = ["copyLibsJsFile"];
+let packfiletask = ["packfile"];
+if (isPublish2) {
+	copyLibsTask = "";
+	packfiletask = ["copyPlatformFile_WX"];
+}
+
+let 
+    config,
+	platform,
+    releaseDir;
+let isGlobalCli = true;
+let isOpendataProj;
+let versionCon; // 版本管理version.json
+// 应该在publish中的,但是为了方便发布2.0及IDE 1.x,放在这里修改
+gulp.task("preCreate_WX", copyLibsTask, function() {
+	if (isPublish2) {
+		let pubsetPath = path.join(workSpaceDir, ".laya", "pubset.json");
+		let content = fs.readFileSync(pubsetPath, "utf8");
+		let pubsetJson = JSON.parse(content);
+		platform = "wxgame";
+		releaseDir = path.join(workSpaceDir, "release", platform).replace(/\\/g, "/");
+		config = pubsetJson[1];
+	} else {
+		platform = global.platform;
+		releaseDir = global.releaseDir;
+		config = global.config;
+	}
+	// 如果不是微信小游戏
+	if (platform !== "wxgame") {
+		return;
+	}
+	if (process.platform === "darwin") {
+		commandSuffix = "";
+	}
+	// 是否是开放域项目
+	let projInfoPath = path.join(workSpaceDir, path.basename(workSpaceDir) + ".laya");
+	let isExist = fs.existsSync(projInfoPath);
+	if (isExist) {
+		try {
+			let projInfo = fs.readFileSync(projInfoPath, "utf8");
+			projInfo = projInfo && JSON.parse(projInfo);
+			isOpendataProj = projInfo.layaProType === 12;
+		} catch (e) {}
+	}
+	if (isOpendataProj) {
+		return;
+	}
+	let copyLibsList = [`${workSpaceDir}/bin/libs/laya.wxmini.js`];
+	var stream = gulp.src(copyLibsList, { base: `${workSpaceDir}/bin` });
+	return stream.pipe(gulp.dest(releaseDir));
+});
+
+gulp.task("copyPlatformFile_WX", ["preCreate_WX"], function() {
+	// 如果不是微信小游戏
+	if (platform !== "wxgame") {
+		return;
+	}
+	let adapterPath = path.join(ideModuleDir, "../", "out", "layarepublic", "LayaAirProjectPack", "lib", "data", "wxfiles");
+	// 开放域项目
+	if (isOpendataProj) {
+		let platformDir = path.join(adapterPath, "weapp-adapter.js");
+		let stream = gulp.src(platformDir);
+		return stream.pipe(gulp.dest(releaseDir));
+	}
+	// 如果新建项目时已经点击了"微信/百度小游戏bin目录快速调试",不再拷贝
+	let isHadWXFiles =
+		fs.existsSync(path.join(workSpaceDir, "bin", "game.js")) &&
+		fs.existsSync(path.join(workSpaceDir, "bin", "game.json")) &&
+		fs.existsSync(path.join(workSpaceDir, "bin", "project.config.json")) &&
+		fs.existsSync(path.join(workSpaceDir, "bin", "weapp-adapter.js"));
+	if (isHadWXFiles) {
+		return;
+	}
+	let isHasPublish = 
+		fs.existsSync(path.join(releaseDir, "game.js")) &&
+		fs.existsSync(path.join(releaseDir, "game.json")) &&
+		fs.existsSync(path.join(releaseDir, "project.config.json")) &&
+		fs.existsSync(path.join(releaseDir, "weapp-adapter.js"));
+	if (isHasPublish) {
+		return;
+	}
+	let copyLibsList = [`${adapterPath}/*.*`];
+	var stream = gulp.src(copyLibsList);
+	return stream.pipe(gulp.dest(releaseDir));
+});
+
+// 开放域的情况下,合并game.js和index.js,并删除game.js
+gulp.task("openData_WX", packfiletask, function (cb) {
+	// 如果不是微信小游戏
+	if (platform !== "wxgame") {
+		return cb();
+	}
+	if (config.openDataZone) {
+		let versionCon;
+		if (config.version) {
+			let versionPath = releaseDir + "/version.json";
+			versionCon = fs.readFileSync(versionPath, "utf8");
+			versionCon = JSON.parse(versionCon);
+		}
+		let indexJsStr = (versionCon && versionCon["index.js"]) ? versionCon["index.js"] :  "index.js";
+		let indexPath = path.join(releaseDir, indexJsStr);
+		let indexjs = readFile(indexPath);
+		let gamejs = readFile(releaseDir + "/game.js");
+		if (gamejs && indexjs) {
+			gamejs = gamejs.replace(`require("index.js")`, indexjs);
+			fs.writeFileSync(indexPath, gamejs, 'utf-8');
+		}
+		if (isOpendataProj) {
+			// 开放域项目,将game.js删掉,发布最小包
+			del(`${releaseDir}/game.js`, { force: true }).then(paths => {
+				cb();
+			});
+		} else {
+			cb();
+		}
+	} else {
+		cb();
+	}
+});
+
+function readFile(path) {
+	if (fs.existsSync(path)) {
+		return fs.readFileSync(path, "utf-8");
+	}
+	return null;
+}
+
+gulp.task("version_WX", ["openData_WX"], function() {
+	// 如果不是微信小游戏
+	if (platform !== "wxgame") {
+		return;
+	}
+	if (config.version) {
+		let versionPath = releaseDir + "/version.json";
+		let gameJSPath = releaseDir + "/game.js";
+		let srcList = [versionPath, gameJSPath];
+		return gulp.src(srcList)
+			.pipe(revCollector())
+			.pipe(gulp.dest(releaseDir));
+	}
+});
+
+gulp.task("optimizeOpen_WX", ["version_WX"], function(cb) {
+	// 如果不是微信小游戏
+	if (platform !== "wxgame") {
+		return cb();
+	}
+	let wxOptimize = config.wxOptimize;
+	if (!wxOptimize || !wxOptimize.useOptimizeOpen) { // 没有使用微信引擎插件,还是像以前一样发布
+		return cb();
+	}
+	// 首屏加载优化(秒开),修改game.json
+	let filePath = path.join(releaseDir, "game.json");
+	if (!fs.existsSync(filePath)) {
+		return cb();
+	}
+	let fileContent = fs.readFileSync(filePath, "utf8");
+	let fileConObj = JSON.parse(fileContent);
+	if (wxOptimize.preloadRes) {
+		fileConObj.preloadResources = wxOptimize.preloadResList;
+	} else {
+		delete fileConObj.preloadResources;
+	}
+	if (wxOptimize.preloadSubpack) {
+		fileConObj.preloadSubpackages = wxOptimize.preloadSubpackList;
+	} else {
+		delete fileConObj.preloadSubpackages;
+	}
+	fs.writeFileSync(filePath, JSON.stringify(fileConObj, null, 4), "utf8");
+	return cb();
+});
+
+gulp.task("pluginEngin_WX", ["optimizeOpen_WX"], function(cb) {
+	// 如果不是微信小游戏
+	if (platform !== "wxgame") {
+		return cb();
+	}
+	if (!config.uesEnginePlugin) { // 没有使用微信引擎插件,还是像以前一样发布
+		return cb();
+	}
+	if (config.version) {
+		let versionPath = releaseDir + "/version.json";
+		versionCon = fs.readFileSync(versionPath, "utf8");
+		versionCon = JSON.parse(versionCon);
+	}
+	let indexJsStr = (versionCon && versionCon["index.js"]) ? versionCon["index.js"] :  "index.js";
+	
+	// 获取version等信息
+	let coreLibPath = path.join(workSpaceDir, "bin", "libs", "laya.core.js");
+	let isHasCoreLib = fs.existsSync(coreLibPath);
+	let isOldAsProj = fs.existsSync(`${workSpaceDir}/asconfig.json`) && !isHasCoreLib;
+	let isNewTsProj = fs.existsSync(`${workSpaceDir}/src/tsconfig.json`) && !isHasCoreLib;
+	let EngineVersion = getEngineVersion();
+	if (!EngineVersion) {
+		throw new Error(`读取引擎版本号失败,请于服务提供商联系!`);
+	}
+	if (!EngineVersion || EngineVersion.includes("beta") || !canUsePluginEngine(EngineVersion)) {
+		throw new Error(`该版本引擎无法使用引擎插件功能(engineVersion: ${EngineVersion})`);
+	}
+	console.log(`通过版本号检查:  ${EngineVersion}`);
+	// 使用引擎插件
+	let localUseEngineList = [];
+	let copyEnginePathList;
+	new Promise(function(resolve, reject) {
+		console.log(`修改game.js和game.json`);
+		// 1) 修改game.js和game.json
+		// 修改game.js
+		let gameJsPath = path.join(releaseDir, "game.js");
+		let gameJscontent = `require("weapp-adapter.js");\nrequire("./libs/laya.wxmini.js");\nrequirePlugin('layaPlugin');\nwindow.loadLib = require;\nrequire("./${indexJsStr}");`;
+		fs.writeFileSync(gameJsPath, gameJscontent, "utf8");
+		// 修改game.json,使其支持引擎插件
+		let gameJsonPath = path.join(releaseDir, "game.json");
+		let gameJsonContent = fs.readFileSync(gameJsonPath, "utf8");
+		let conJson = JSON.parse(gameJsonContent);
+		conJson.plugins = {
+			"layaPlugin": {
+				"version": EngineVersion,
+				"provider": provider,
+				"path": "laya-libs"
+			}
+		}
+		gameJsonContent = JSON.stringify(conJson, null, 4);
+		fs.writeFileSync(gameJsonPath, gameJsonContent, "utf8");
+		resolve();
+	}).then(function() {
+		return new Promise(function(resolve, reject) {
+			console.log(`确定用到的插件引擎`);
+			// 2) 确定用到了那些插件引擎,并将插件引擎从index.js的引用中去掉
+			let indexJsPath = path.join(releaseDir, indexJsStr);
+			let indexJsCon = fs.readFileSync(indexJsPath, "utf8");
+			let item, fullRequireItem;
+			for (let i = 0, len = fullRemoteEngineList.length; i < len; i++) {
+				item = fullRemoteEngineList[i];
+				fullRequireItem = `loadLib("libs/${item}")`;
+				if (indexJsCon.includes(fullRequireItem)) {
+					localUseEngineList.push(item);
+					indexJsCon = indexJsCon.replace(fullRequireItem, "");
+				}
+			}
+			if (isOldAsProj || isNewTsProj) { // 如果as||ts_new语言,开发者将laya.js也写入index.js中了,将其删掉
+				fullRequireItem = `loadLib("laya.js")`;
+				if (indexJsCon.includes(fullRequireItem)) {
+					indexJsCon = indexJsCon.replace(fullRequireItem, "");
+				}
+			}
+			fs.writeFileSync(indexJsPath, indexJsCon, "utf8");
+			// ts/js再次修改game.js,仅引用使用到的类库
+			// as||ts_new因为本地只有laya.js,无法仅引用使用到的类库
+			if (!isOldAsProj && !isNewTsProj) {
+				let pluginCon = "";
+				localUseEngineList.forEach(function(item) {
+					pluginCon += `requirePlugin("layaPlugin/${item}");\n`;
+				});
+				let gameJsPath = path.join(releaseDir, "game.js");
+				let gameJsCon = fs.readFileSync(gameJsPath, "utf8");
+				gameJsCon = gameJsCon.replace(`requirePlugin('layaPlugin');`, pluginCon);
+				fs.writeFileSync(gameJsPath, gameJsCon, "utf8");
+			}
+			resolve();
+		});
+	}).then(function() {
+		return new Promise(function(resolve, reject) {
+			console.log(`将本地的引擎插件移动到laya-libs中`);
+			// 3) 将本地的引擎插件移动到laya-libs中
+			copyEnginePathList = [`${releaseDir}/libs/{${localUseEngineList.join(",")}}`];
+			if (isOldAsProj || isNewTsProj) { // 单独拷贝laya.js
+				copyEnginePathList = [`${releaseDir}/laya.js`];
+			}
+			gulp.src(copyEnginePathList).pipe(gulp.dest(`${releaseDir}/laya-libs`));
+			setTimeout(resolve, 500);
+		});
+	}).then(function() {
+		return new Promise(function(resolve, reject) {
+			console.log(`将libs中的本地引擎插件删掉`);
+			// 4) 将libs中的本地引擎插件删掉
+			del(copyEnginePathList, { force: true }).then(resolve);
+		});
+	}).then(function() {
+		return new Promise(async function(resolve, reject) {
+			console.log(`完善引擎插件目录`);
+			// 5) 引擎插件目录laya-libs中还需要新建几个文件,使该目录能够使用
+			if (isOldAsProj || isNewTsProj) { // 单独拷贝laya.js
+				localUseEngineList.push("laya.js");
+			}
+			let 
+				layalibsPath = path.join(releaseDir, "laya-libs"),
+				engineIndex = path.join(layalibsPath, "index.js"),
+				engineplugin = path.join(layalibsPath, "plugin.json"),
+				enginesignature = path.join(layalibsPath, "signature.json");
+			// index.js
+			if (!fs.existsSync(layalibsPath)) {
+				throw new Error("引擎插件目录创建失败,请与服务提供商联系!");
+			}
+			let indexCon = "";
+			localUseEngineList.forEach(function(item) {
+				indexCon += `require("./${item}");\n`;
+			});
+			fs.writeFileSync(engineIndex, indexCon, "utf8");
+			// plugin.json
+			let pluginCon = {"main": "index.js"};
+			fs.writeFileSync(engineplugin, JSON.stringify(pluginCon, null, 4), "utf8");
+			// signature.json
+			let signatureCon = {
+				"provider": provider,
+				"signature": []
+			};
+			localUseEngineList.unshift("index.js");
+			let fileName, md5Str;
+			for (let i = 0, len = localUseEngineList.length; i < len; i++) {
+				fileName = localUseEngineList[i];
+				let md5Str = await getFileMd5(path.join(releaseDir, "laya-libs", fileName));
+				signatureCon.signature.push({
+					"path": fileName,
+					"md5": md5Str
+				});
+			}
+			fs.writeFileSync(enginesignature, JSON.stringify(signatureCon, null, 4), "utf8");
+			resolve();
+		});
+	})
+	.then(function() {
+		cb();
+	}).catch(function(e) {
+		throw e;
+	})
+});
+
+function getEngineVersion() {
+	let coreLibPath = path.join(workSpaceDir, "bin", "libs", "laya.core.js");
+	let isHasCoreLib = fs.existsSync(coreLibPath);
+	let isOldAsProj = fs.existsSync(`${workSpaceDir}/asconfig.json`) && !isHasCoreLib;
+	let isNewTsProj = fs.existsSync(`${workSpaceDir}/src/tsconfig.json`) && !isHasCoreLib;
+	let EngineVersion;
+	if (isHasCoreLib) {
+		let con = fs.readFileSync(coreLibPath, "utf8");
+		let matchList = con.match(/Laya\.version\s*=\s*['"]([0-9\.]+(beta)?.*)['"]/);
+		if (!Array.isArray(matchList)) {
+			return null;
+		}
+		EngineVersion = matchList[1];
+	} else { // newts项目和旧版本as项目
+		if (isOldAsProj) {
+			let coreLibFilePath = path.join(workSpaceDir, "libs", "laya", "src", "Laya.as");
+			if (!fs.existsSync(coreLibFilePath)) {
+				return null;
+			}
+			let con = fs.readFileSync(coreLibFilePath, "utf8");
+			let matchList = con.match(/version:String\s*=\s*['"]([0-9\.]+(beta)?.*)['"]/);
+			if (!Array.isArray(matchList)) {
+				return null;
+			}
+			EngineVersion = matchList[1];
+		} else if (isNewTsProj) {
+			let coreLibFilePath = path.join(workSpaceDir, "libs", "Laya.ts");
+			if (!fs.existsSync(coreLibFilePath)) {
+				return null;
+			}
+			let con = fs.readFileSync(coreLibFilePath, "utf8");
+			let matchList = con.match(/static\s*version:\s*string\s*=\s*['"]([0-9\.]+(beta)?.*)['"]/);
+			if (!Array.isArray(matchList)) {
+				return null;
+			}
+			EngineVersion = matchList[1];
+		}
+	}
+	// 特殊处理,因为历史原因,我们有一些4位的正式版本,调整为3位
+	if (EngineVersion && /[\d\.]+/.test(EngineVersion) && EngineVersion.split(".").length > 3) {
+		let verList = EngineVersion.split(".");
+		verList.length = 3;
+		EngineVersion = verList.join(".");
+	}
+	return EngineVersion;
+}
+
+function getFileMd5(filePath) {
+	return new Promise(function(resolve, reject) {
+		let md5 = crypto.createHash('md5');
+		let stream = fs.createReadStream(filePath);
+		stream.on("data", function(data) {
+			md5.update(data);
+		});
+		stream.on("end", function() {
+			let md5Str = md5.digest('hex');
+			return resolve(md5Str);
+		});
+	});
+}
+
+function canUsePluginEngine(version) {
+	const minVersionNum = "2.0.1";
+	let compileMacthList = minVersionNum.match(/^(\d+)\.(\d+)\.(\d+)/);
+	let matchList = version.match(/^(\d+)\.(\d+)\.(\d+)/);
+    if (matchList[1] > compileMacthList[1]) {
+        return true;
+	}
+    if (matchList[1] === compileMacthList[1] && matchList[2] > compileMacthList[2]) {
+        return true;
+    }
+    if (matchList[1] === compileMacthList[1] && matchList[2] === compileMacthList[2] && matchList[3] >= compileMacthList[3]) {
+        return true;
+    }
+    return false;
+}
+
+gulp.task("buildWXProj", ["pluginEngin_WX"], function() {
+	console.log("all tasks completed");
+});

+ 527 - 0
ShootingSun/.laya/publish_xmgame.js

@@ -0,0 +1,527 @@
+// v1.3.0
+// publish 2.x 也是用这个文件,需要做兼容
+let isPublish2 = process.argv[2].includes("publish_xmgame.js") && process.argv[3].includes("--evn=publish2");
+// 获取Node插件和工作路径
+let ideModuleDir, workSpaceDir;
+if (isPublish2) {
+	//是否使用IDE自带的node环境和插件,设置false后,则使用自己环境(使用命令行方式执行)
+	const useIDENode = process.argv[0].indexOf("LayaAir") > -1 ? true : false;
+	ideModuleDir = useIDENode ? process.argv[1].replace("gulp\\bin\\gulp.js", "").replace("gulp/bin/gulp.js", "") : "";
+	workSpaceDir = useIDENode ? process.argv[2].replace("--gulpfile=", "").replace("\\.laya\\publish_xmgame.js", "").replace("/.laya/publish_xmgame.js", "") + "/" : "./../";
+} else {
+	ideModuleDir = global.ideModuleDir;
+	workSpaceDir = global.workSpaceDir;
+}
+
+//引用插件模块
+const gulp = require(ideModuleDir + "gulp");
+const fs = require("fs");
+const path = require("path");
+const childProcess = require("child_process");
+const del = require(ideModuleDir + "del");
+const revCollector = require(ideModuleDir + 'gulp-rev-collector');
+let commandSuffix = ".cmd";
+
+let copyLibsTask = ["copyLibsJsFile"];
+let packfiletask = ["packfile"];
+if (isPublish2) {
+	copyLibsTask = "";
+	packfiletask = ["copyPlatformFile_XM"];
+}
+
+let 
+    config,
+	platform,
+	releaseDir,
+    tempReleaseDir, // 小米临时拷贝目录
+	projDir; // 小米快游戏工程目录
+let IDEXMProjPath,
+	isUpdateIDEXMProj = false;
+let versionCon; // 版本管理version.json
+// 创建小米项目前,拷贝小米引擎库、修改index.js
+// 应该在publish中的,但是为了方便发布2.0及IDE 1.x,放在这里修改
+gulp.task("preCreate_XM", copyLibsTask, function() {
+	if (isPublish2) {
+		let pubsetPath = path.join(workSpaceDir, ".laya", "pubset.json");
+		let content = fs.readFileSync(pubsetPath, "utf8");
+		let pubsetJson = JSON.parse(content);
+		platform = "xmgame";
+		releaseDir = path.join(workSpaceDir, "release", platform).replace(/\\/g, "/");
+		releaseDir = tempReleaseDir = path.join(releaseDir, "temprelease");
+		config = pubsetJson[4]; // 只用到了 config.xmInfo|config.xmSign
+	} else {
+		platform = global.platform;
+		releaseDir = global.releaseDir;
+		tempReleaseDir = global.tempReleaseDir;
+		config = global.config;
+	}
+	// 如果不是小米快游戏
+	if (platform !== "xmgame") {
+		return;
+	}
+	if (process.platform === "darwin") {
+		commandSuffix = "";
+	}
+	let copyLibsList = [`${workSpaceDir}/bin/libs/laya.xmmini.js`];
+	var stream = gulp.src(copyLibsList, { base: `${workSpaceDir}/bin` });
+	return stream.pipe(gulp.dest(tempReleaseDir));
+});
+
+gulp.task("copyPlatformFile_XM", ["preCreate_XM"], function() {
+	// 如果不是小米快游戏
+	if (platform !== "xmgame") {
+		return;
+	}
+	let xmAdapterPath = path.join(ideModuleDir, "../", "out", "layarepublic", "LayaAirProjectPack", "lib", "data", "xmfiles");
+	let copyLibsList = [`${xmAdapterPath}/**/*.*`];
+	var stream = gulp.src(copyLibsList);
+	return stream.pipe(gulp.dest(tempReleaseDir));
+});
+
+// 新建小米项目-小米项目与其他项目不同,需要新建小米快游戏项目,并打包成.rpk文件
+gulp.task("checkIDEProj_XM", packfiletask, function() {
+	// 如果不是小米快游戏
+	if (platform !== "xmgame") {
+		return;
+	}
+	if (!ideModuleDir) {
+		return;
+	}
+	IDEXMProjPath = path.join(ideModuleDir, "../", "out", "layarepublic", "xm");
+	if (process.platform === "darwin") {
+		return;
+	}
+	let ideLastXMProjPath = path.join(IDEXMProjPath, config.xmInfo.projName);
+	// 如果IDE中没有小米项目,跳过这一步
+	let isProjExist = fs.existsSync(ideLastXMProjPath + "/node_modules") && 
+					  fs.existsSync(ideLastXMProjPath + "/sign");
+	if (!isProjExist) {
+		console.log("IDE中没有小米项目,跳过检查小米项目版本号这一步");
+		return;
+	}
+	// 如果IDE中项目已经存在了,检查版本号
+	// npm view quickgame-cli version
+	// npm ls quickgame-cli
+	let remoteVersion, localVersion;
+	let isGetRemote, isGetLocal;
+	return new Promise((resolve, reject) => { // 远程版本号
+		childProcess.exec("npm view quickgame-cli version", function(error, stdout, stderr) {
+			if (!stdout) { // 获取 quickgame-cli 远程版本号失败
+				reject();
+				return;
+			}
+			remoteVersion = stdout;
+			isGetRemote = true;
+			if (isGetRemote && isGetLocal) {
+				resolve();
+			}
+		});
+		childProcess.exec("npm ls quickgame-cli", { cwd: ideLastXMProjPath }, function(error, stdout, stderr) {
+			if (!stdout) { // 获取 quickgame-cli 本地版本号失败
+				reject();
+				return;
+			}
+			localVersion = stdout.match(/quickgame-cli@(.+)/);
+			localVersion = localVersion && localVersion[1];
+			isGetLocal = true;
+			if (isGetRemote && isGetLocal) {
+				resolve();
+			}
+		});
+		setTimeout(() => {
+			if (!isGetLocal || !isGetRemote) {
+				console.log("获取远程版本号或本地版本号失败");
+				reject();
+				return;
+			}
+		}, 10000);
+	}).then(() => { // 比较两个版本号
+		if (!remoteVersion || !localVersion) {
+			console.log("获取远程版本号或本地版本号失败!");
+		}
+		console.log("quickgame-cli -> ", localVersion, "|", remoteVersion);
+		if (remoteVersion.trim() !== localVersion.trim()) { // 仅当两个版本号都获取到并且不相等,置为需要更新(true)
+			isUpdateIDEXMProj = true;
+		}
+	}).catch((e) => {
+		console.log("获取远程版本号或本地版本号失败 -> ", remoteVersion, "|", localVersion);
+		console.log(e);
+	});
+});
+
+gulp.task("createIDEProj_XM", ["checkIDEProj_XM"], function() {
+	// 如果不是小米快游戏
+	if (platform !== "xmgame") {
+		return;
+	}
+	if (!ideModuleDir) {
+		return;
+	}
+	if (process.platform === "darwin") {
+		return;
+	}
+	let ideLastXMProjPath = path.join(IDEXMProjPath, config.xmInfo.projName);
+	// 如果有即存项目,不再新建
+	let isProjExist = fs.existsSync(ideLastXMProjPath + "/node_modules") && 
+					  fs.existsSync(ideLastXMProjPath + "/sign");
+	if (isProjExist && !isUpdateIDEXMProj) { // 项目存在并且不需要更新IDE中的小米项目
+		return;
+	}
+	return new Promise((resolve, reject) => {
+		console.log("(IDE)开始创建小米快游戏项目,请耐心等待(预计需要10分钟)...");
+		let cmd = `npx${commandSuffix}`;
+		let args = ["create-quickgame", config.xmInfo.projName, `path=${IDEXMProjPath}`,
+					`package=${config.xmInfo.package}`, `versionName=${config.xmInfo.versionName}`,
+					`versionCode=${config.xmInfo.versionCode}`, `minPlatformVersion=${config.xmInfo.minPlatformVersion}`,
+                    `icon=/layaicon/${path.basename(config.xmInfo.icon)}`, `name=${config.xmInfo.name}`, `rebuild=true`];
+        console.log(JSON.stringify(args));
+		let opts = {
+			shell: true
+		};
+        let cp = childProcess.spawn(cmd, args, opts);
+        
+		cp.stdout.on('data', (data) => {
+			console.log(`stdout: ${data}`);
+		});
+		
+		cp.stderr.on('data', (data) => {
+			console.log(`stderr: ${data}`);
+			// reject();
+		});
+		
+		cp.on('close', (code) => {
+			console.log(`子进程退出码:${code}`);
+			resolve();
+		});
+	});
+});
+
+gulp.task("createProj_XM", ["createIDEProj_XM"], function() {
+	// 如果不是小米快游戏
+	if (platform !== "xmgame") {
+		return;
+	}
+	releaseDir = path.dirname(releaseDir);
+	projDir = path.join(releaseDir, config.xmInfo.projName);
+	// 如果有即存项目,不再新建
+	let isProjExist = fs.existsSync(projDir + "/node_modules") && 
+					  fs.existsSync(projDir + "/sign");
+	if (isProjExist) {
+		return;
+	}
+	// 如果IDE中有即存项目,不再新建,从IDE中拷贝
+	let ideLastXMProjPath = path.join(IDEXMProjPath, config.xmInfo.projName);
+	let isIDEXMProjExist = fs.existsSync(ideLastXMProjPath + "/node_modules") && 
+						fs.existsSync(ideLastXMProjPath + "/sign");
+	if (isIDEXMProjExist) { // 如果用的IDE并且有IDEXM目录
+		console.log("使用IDE中的小米游戏项目,拷贝...");
+		// node-glob语法中,* 无法匹配 .开头的文件(夹),必须手动匹配
+		let IDEXMProjPathStr = [`${IDEXMProjPath}/**/*.*`, `${ideLastXMProjPath}/node_modules/.bin/*.*`];
+		var stream = gulp.src(IDEXMProjPathStr, { base: IDEXMProjPath});
+		return stream.pipe(gulp.dest(releaseDir));
+	}
+	// 在项目中创建小米项目
+	return new Promise((resolve, reject) => {
+		console.log("(proj)开始创建小米快游戏项目,请耐心等待(预计需要10分钟)...");
+		let cmd = `npx${commandSuffix}`;
+		let args = ["create-quickgame", config.xmInfo.projName, `path=${releaseDir}`,
+					`package=${config.xmInfo.package}`, `versionName=${config.xmInfo.versionName}`,
+					`versionCode=${config.xmInfo.versionCode}`, `minPlatformVersion=${config.xmInfo.minPlatformVersion}`,
+                    `icon=/layaicon/${path.basename(config.xmInfo.icon)}`, `name=${config.xmInfo.name}`, `rebuild=true`];
+        console.log(JSON.stringify(args));
+        let opts = {
+			shell: true
+		};
+        let cp = childProcess.spawn(cmd, args, opts);
+        
+		cp.stdout.on('data', (data) => {
+			console.log(`stdout: ${data}`);
+		});
+		
+		cp.stderr.on('data', (data) => {
+			console.log(`stderr: ${data}`);
+			// reject();
+		});
+		
+		cp.on('close', (code) => {
+			console.log(`子进程退出码:${code}`);
+			resolve();
+		});
+	});
+});
+
+// 拷贝文件到小米快游戏
+gulp.task("copyFileToProj_XM", ["createProj_XM"], function() {
+	// 如果不是小米快游戏
+	if (platform !== "xmgame") {
+		return;
+	}
+	// 将临时文件夹中的文件,拷贝到项目中去
+	let originalDir = `${tempReleaseDir}/**/*.*`;
+	let stream = gulp.src(originalDir);
+	return stream.pipe(gulp.dest(path.join(projDir)));
+});
+
+// 拷贝icon到小米快游戏
+gulp.task("copyIconToProj_XM", ["copyFileToProj_XM"], function() {
+	// 如果不是小米快游戏
+	if (platform !== "xmgame") {
+		return;
+	}
+	let originalDir = config.xmInfo.icon;
+	let stream = gulp.src(originalDir);
+	return stream.pipe(gulp.dest(path.join(projDir, "layaicon")));
+});
+
+// 清除小米快游戏临时目录
+gulp.task("clearTempDir_XM", ["copyIconToProj_XM"], function() {
+	// 如果不是小米快游戏
+	if (platform !== "xmgame") {
+		return;
+	}
+	// 删掉临时目录
+	return del([tempReleaseDir], { force: true });
+});
+
+// 生成release签名(私钥文件 private.pem 和证书文件 certificate.pem )
+gulp.task("generateSign_XM", ["clearTempDir_XM"], function() {
+	// 如果不是小米快游戏
+	if (platform !== "xmgame") {
+		return;
+    }
+    if (!config.xmSign.generateSign) {
+        return;
+    }
+	// https://doc.quickapp.cn/tools/compiling-tools.html
+	return new Promise((resolve, reject) => {
+		let cmd = "openssl";
+		let args = ["req", "-newkey", "rsa:2048", "-nodes", "-keyout", "private.pem", 
+					"-x509", "-days", "3650", "-out", "certificate.pem"];
+		let opts = {
+			cwd: projDir,
+			shell: true
+		};
+		let cp = childProcess.spawn(cmd, args, opts);
+		cp.stdout.on('data', (data) => {
+			console.log(`stdout: ${data}`);
+		});
+
+		cp.stderr.on('data', (data) => {
+			console.log(`stderr: ${data}`);
+			data += "";
+			if (data.includes("Country Name")) {
+				cp.stdin.write(`${config.xmSign.countryName}\n`);
+				console.log(`Country Name: ${config.xmSign.countryName}`);
+			} else if (data.includes("Province Name")) {
+				cp.stdin.write(`${config.xmSign.provinceName}\n`);
+				console.log(`Province Name: ${config.xmSign.provinceName}`);
+			} else if (data.includes("Locality Name")) {
+				cp.stdin.write(`${config.xmSign.localityName}\n`);
+				console.log(`Locality Name: ${config.xmSign.localityName}`);
+			} else if (data.includes("Organization Name")) {
+				cp.stdin.write(`${config.xmSign.orgName}\n`);
+				console.log(`Organization Name: ${config.xmSign.orgName}`);
+			} else if (data.includes("Organizational Unit Name")) {
+				cp.stdin.write(`${config.xmSign.orgUnitName}\n`);
+				console.log(`Organizational Unit Name: ${config.xmSign.orgUnitName}`);
+			} else if (data.includes("Common Name")) {
+				cp.stdin.write(`${config.xmSign.commonName}\n`);
+				console.log(`Common Name: ${config.xmSign.commonName}`);
+			} else if (data.includes("Email Address")) {
+				cp.stdin.write(`${config.xmSign.emailAddr}\n`);
+				console.log(`Email Address: ${config.xmSign.emailAddr}`);
+				// cp.stdin.end();
+			}
+			// reject();
+		});
+
+		cp.on('close', (code) => {
+			console.log(`子进程退出码:${code}`);
+			resolve();
+		});
+	});
+});
+
+// 拷贝sign文件到指定位置
+gulp.task("copySignFile_XM", ["generateSign_XM"], function() {
+	// 如果不是小米快游戏
+	if (platform !== "xmgame") {
+		return;
+    }
+    if (config.xmSign.generateSign) { // 新生成的签名
+        // 移动签名文件到项目中(Laya & 小米快游戏项目中)
+        let 
+            privatePem = path.join(projDir, "private.pem"),
+            certificatePem = path.join(projDir, "certificate.pem");
+        let isSignExits = fs.existsSync(privatePem) && fs.existsSync(certificatePem);
+        if (!isSignExits) {
+            return;
+        }
+        let 
+            xiaomiDest = `${projDir}/sign/release`,
+            layaDest = `${workSpaceDir}/sign/release`;
+        let stream = gulp.src([privatePem, certificatePem]);
+        return stream.pipe(gulp.dest(xiaomiDest))
+                    .pipe(gulp.dest(layaDest));
+    } else if (config.xmInfo.useReleaseSign && !config.xmSign.generateSign) { // 使用release签名,并且没有重新生成
+        // 从项目中将签名拷贝到小米快游戏项目中
+        let 
+            privatePem = path.join(workSpaceDir, "sign", "release", "private.pem"),
+            certificatePem = path.join(workSpaceDir, "sign", "release", "certificate.pem");
+        let isSignExits = fs.existsSync(privatePem) && fs.existsSync(certificatePem);
+        if (!isSignExits) {
+            return;
+        }
+        let 
+            xiaomiDest = `${projDir}/sign/release`;
+        let stream = gulp.src([privatePem, certificatePem]);
+        return stream.pipe(gulp.dest(xiaomiDest));
+    }
+});
+
+gulp.task("deleteSignFile_XM", ["copySignFile_XM"], function() {
+	// 如果不是小米快游戏
+	if (platform !== "xmgame") {
+		return;
+	}
+	if (config.xmSign.generateSign) { // 新生成的签名
+		let 
+            privatePem = path.join(projDir, "private.pem"),
+            certificatePem = path.join(projDir, "certificate.pem");
+		return del([privatePem, certificatePem], { force: true });
+	}
+});
+
+gulp.task("modifyFile_XM", ["deleteSignFile_XM"], function() {
+	// 如果不是小米快游戏
+	if (platform !== "xmgame") {
+		return;
+	}
+	// 修改manifest.json文件
+	let manifestPath = path.join(projDir, "manifest.json");
+	if (!fs.existsSync(manifestPath)) {
+		return;
+	}
+	let manifestContent = fs.readFileSync(manifestPath, "utf8");
+	let manifestJson = JSON.parse(manifestContent);
+	manifestJson.package = config.xmInfo.package;
+	manifestJson.name = config.xmInfo.name;
+	manifestJson.orientation = config.xmInfo.orientation;
+	manifestJson.config.logLevel = config.xmInfo.logLevel || "off";
+	manifestJson.versionName = config.xmInfo.versionName;
+	manifestJson.versionCode = config.xmInfo.versionCode;
+	manifestJson.minPlatformVersion = config.xmInfo.minPlatformVersion;
+	manifestJson.icon = `/layaicon/${path.basename(config.xmInfo.icon)}`;
+	fs.writeFileSync(manifestPath, JSON.stringify(manifestJson, null, 4), "utf8");
+
+	if (config.version) {
+		let versionPath = projDir + "/version.json";
+		versionCon = fs.readFileSync(versionPath, "utf8");
+		versionCon = JSON.parse(versionCon);
+	}
+	let indexJsStr = (versionCon && versionCon["index.js"]) ? versionCon["index.js"] :  "index.js";
+	// 修改main.js文件
+	let content = 'require("./qg-adapter.js");\nrequire("./libs/laya.xmmini.js");\nrequire("./index.js");';
+	let mainJsPath = path.join(projDir, "main.js");
+	fs.writeFileSync(mainJsPath, content, "utf8");
+
+	// 小米项目,修改index.js
+	let filePath = path.join(projDir, indexJsStr);
+	if (!fs.existsSync(filePath)) {
+		return;
+	}
+	let fileContent = fs.readFileSync(filePath, "utf8");
+	fileContent = fileContent.replace(/loadLib(\(['"])/gm, "require$1./");
+	fs.writeFileSync(filePath, fileContent, "utf8");
+})
+
+gulp.task("version_XM", ["modifyFile_XM"], function () {
+	// 如果不是小米快游戏
+	if (platform !== "xmgame") {
+		return;
+	}
+	if (config.version) {
+		let versionPath = projDir + "/version.json";
+		let mainJSPath = projDir + "/main.js";
+		let srcList = [versionPath, mainJSPath];
+		return gulp.src(srcList)
+			.pipe(revCollector())
+			.pipe(gulp.dest(projDir));
+	}
+});
+
+// 打包rpk
+gulp.task("buildRPK_XM", ["version_XM"], function() {
+	// 如果不是小米快游戏
+	if (platform !== "xmgame") {
+		return;
+	}
+	// 在小米轻游戏项目目录中执行:
+    // npm run build || npm run release
+    let cmdStr = "build";
+    if (config.xmInfo.useReleaseSign) {
+        cmdStr = "release";
+    }
+	return new Promise((resolve, reject) => {
+		let cmd = `npm${commandSuffix}`;
+		let args = ["run", cmdStr];
+		let opts = {
+			cwd: projDir,
+			shell: true
+		};
+		let cp = childProcess.spawn(cmd, args, opts);
+		// let cp = childProcess.spawn(`npx${commandSuffix}`, ['-v']);
+		cp.stdout.on('data', (data) => {
+			console.log(`stdout: ${data}`);
+		});
+
+		cp.stderr.on('data', (data) => {
+			console.log(`stderr: ${data}`);
+			// reject();
+		});
+
+		cp.on('close', (code) => {
+			console.log(`子进程退出码:${code}`);
+			resolve();
+		});
+	});
+});
+
+gulp.task("showQRCode_XM", ["buildRPK_XM"], function() {
+	// 如果不是小米快游戏
+	if (platform !== "xmgame") {
+		return;
+	}
+	// 在小米轻游戏项目目录中执行:
+	// npm run server
+	return new Promise((resolve, reject) => {
+		let cmd = `npm${commandSuffix}`;
+		let args = ["run", "server"];
+		let opts = {
+			cwd: projDir,
+			shell: true
+		};
+		let cp = childProcess.spawn(cmd, args, opts);
+		// let cp = childProcess.spawn(`npx${commandSuffix}`, ['-v']);
+		cp.stdout.on('data', (data) => {
+			console.log(`${data}`);
+			// 输出pid,macos要用: macos无法kill进程树,也无法执行命令获取3000端口pid(没有查询权限),导致无法kill这个进程
+			console.log('xm_qrcode_pid:' + cp.pid);
+		});
+
+		cp.stderr.on('data', (data) => {
+			console.log(`stderr: ${data}`);
+			// reject();
+		});
+
+		cp.on('close', (code) => {
+			console.log(`子进程退出码:${code}`);
+			resolve();
+		});
+	});
+});
+
+
+gulp.task("buildXiaomiProj", ["showQRCode_XM"], function() {
+	console.log("all tasks completed");
+});

+ 66 - 0
ShootingSun/.laya/web.json

@@ -0,0 +1,66 @@
+{
+    "copyFilesFilter": [
+        "../bin/**/*.*"
+    ],
+    "openDataZone": false,
+    "compressJson": true,
+    "compressJsonFilter": [
+        "$basePath/**/*.{json,atlas}"
+    ],
+    "compressJsonNoteList": [
+        ""
+    ],
+    "compressImage": true,
+    "compressImageFilter": [
+        "$basePath/**/*.{png,jpg}"
+    ],
+    "compressImageNoteList": [
+        ""
+    ],
+    "compressJs": true,
+    "compressJsFilter": [
+        "$basePath/**/*.js"
+    ],
+    "compressJsNoteList": [
+        ""
+    ],
+    "version": false,
+    "versionFilter": [
+        "$basePath/**/*.*",
+        "!$basePath/*.html",
+        "!$basePath/{version.json,game.js,game.json,project.config.json,weapp-adapter.js,project.swan.json,swan-game-adapter.js,main.js,gameConfig.json,my-adapter.js}",
+        "!$basePath/layaforqq/**/*.*"
+    ],
+    "versionNoteList": [
+        "",
+        "",
+        "",
+        ""
+    ],
+    "exclude": false,
+    "excludeFilter": [
+        "!$basePath/res/**/*.*"
+    ],
+    "vexcludeNoteList": [
+        ""
+    ],
+    "packfile": false,
+    "keepPlatformFile": false,
+    "packfileFilter": [
+        ""
+    ],
+    "packfileFullValue": [
+        "$basePath/**/*.*"
+    ],
+    "packfileTargetValue": "",
+    "packfileNoteList": [
+        ""
+    ],
+    "clearReleaseDir": true,
+    "compile": false,
+    "forceCompile": false,
+    "onlyIndexJS": true,
+    "es6toes5": false,
+    "projectType": "ts",
+    "pubTime": 1610543859106
+}

+ 84 - 0
ShootingSun/.laya/wxgame.json

@@ -0,0 +1,84 @@
+{
+    "copyFilesFilter": [
+        "../bin/**/*.*"
+    ],
+    "openDataZone": false,
+    "compressJson": true,
+    "compressJsonFilter": [
+        "$basePath/**/*.{json,atlas}"
+    ],
+    "compressJsonNoteList": [
+        ""
+    ],
+    "compressImage": true,
+    "compressImageFilter": [
+        "$basePath/**/*.{png,jpg}"
+    ],
+    "compressImageNoteList": [
+        ""
+    ],
+    "compressJs": true,
+    "compressJsFilter": [
+        "$basePath/**/*.js"
+    ],
+    "compressJsNoteList": [
+        ""
+    ],
+    "version": false,
+    "versionFilter": [
+        "$basePath/**/*.*",
+        "!$basePath/*.html",
+        "!$basePath/{version.json,game.js,game.json,project.config.json,weapp-adapter.js,project.swan.json,swan-game-adapter.js,main.js,gameConfig.json,my-adapter.js}",
+        "!$basePath/layaforqq/**/*.*"
+    ],
+    "versionNoteList": [
+        "",
+        "",
+        "",
+        ""
+    ],
+    "exclude": false,
+    "excludeFilter": [
+        "!$basePath/res/**/*.*"
+    ],
+    "vexcludeNoteList": [
+        ""
+    ],
+    "packfile": false,
+    "keepPlatformFile": false,
+    "packfileFilter": [
+        ""
+    ],
+    "packfileFullValue": [
+        "$basePath/**/*.*",
+        "$basePath/game.js",
+        "$basePath/game.json",
+        "$basePath/project.config.json",
+        "$basePath/weapp-adapter.js"
+    ],
+    "packfileTargetValue": "",
+    "packfileNoteList": [
+        ""
+    ],
+    "clearReleaseDir": true,
+    "compile": false,
+    "forceCompile": false,
+    "onlyIndexJS": true,
+    "es6toes5": false,
+    "projectType": "ts",
+    "pubTime": 1592649757904,
+    "uesEnginePlugin": false,
+    "wxOptimize": {
+        "useOptimizeOpen": false,
+        "preloadRes": false,
+        "preloadResRootDomain": "",
+        "preloadResList": [
+            {
+                "path": "wxfile://usr/",
+                "url": ""
+            }
+        ],
+        "preloadSubpack": false,
+        "preloadSubpackList": []
+    }
+}

+ 27 - 0
ShootingSun/.vscode/launch.json

@@ -0,0 +1,27 @@
+{
+	"version": "0.2.0",
+	"configurations": [ 
+		{
+			"name": "chrome调试",
+			"type": "chrome",
+			"request": "launch",
+			"file": "${workspaceRoot}/bin/index.html",
+			// "换成自己的谷歌安装路径,": 比如
+			//window 默认安装路径为: "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe"
+			//mac 系统上的默认安装路径为 "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome";
+			// "runtimeExecutable": "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe",
+			"runtimeArgs": [
+				"--allow-file-access-from-files",
+				"--allow-file-access-frome-files",
+				" --disable-web-security"
+			],
+			"sourceMaps": true,
+			"webRoot": "${workspaceRoot}",
+			//假如谷歌调试报userDataDir不可用,请把谷歌安装路径取得管理员权限,或者更换${tmpdir}为其他可以读写的文件夹,也可以删除。
+			"userDataDir": "${workspaceRoot}/.laya/chrome",
+			"sourceMapPathOverrides": {
+				"src/*": "${workspaceRoot}/src/*"
+			}		
+		}
+	]
+}

+ 1 - 0
ShootingSun/ShootingSun.laya

@@ -0,0 +1 @@
+{"proName":"ShootingSun","engineType":0,"proType":1,"layaProType":0,"version":"2.1.0"}

文件差異過大導致無法顯示
+ 0 - 0
ShootingSun/bin/Animation/shoot_blood.ani


文件差異過大導致無法顯示
+ 0 - 0
ShootingSun/bin/MainScene.json


二進制
ShootingSun/bin/UI/ad.png


二進制
ShootingSun/bin/UI/bg.png


二進制
ShootingSun/bin/UI/feedback.png


二進制
ShootingSun/bin/UI/mask.png


二進制
ShootingSun/bin/UI/shareImg1.jpg


二進制
ShootingSun/bin/UI/shareImg2.jpg


二進制
ShootingSun/bin/UI/tishikuang.png


二進制
ShootingSun/bin/dragonBone/addBlood/add_blood.png


二進制
ShootingSun/bin/dragonBone/addBlood/add_blood.sk


二進制
ShootingSun/bin/dragonBone/shield/hudun.png


二進制
ShootingSun/bin/dragonBone/shield/hudun.sk


文件差異過大導致無法顯示
+ 0 - 0
ShootingSun/bin/fileconfig.json


+ 9 - 0
ShootingSun/bin/game.js

@@ -0,0 +1,9 @@
+if ((typeof swan !== 'undefined') && (typeof swanGlobal !== 'undefined')) {
+	require("swan-game-adapter.js");
+	require("libs/laya.bdmini.js");
+} else if (typeof wx!=="undefined") {
+	require("weapp-adapter.js");
+	require("libs/laya.wxmini.js");
+}
+window.loadLib = require;
+require("index.js");

+ 11 - 0
ShootingSun/bin/game.json

@@ -0,0 +1,11 @@
+{
+  "deviceOrientation": "portrait",
+  "showStatusBar": false,
+  "openDataContext":"openData",
+  "networkTimeout": {
+    "request": 10000,
+    "connectSocket": 10000,
+    "uploadFile": 10000,
+    "downloadFile": 10000
+  }
+}

+ 32 - 0
ShootingSun/bin/index.html

@@ -0,0 +1,32 @@
+<html>
+
+<head>
+    <title>www.layabox.com</title>
+    <meta charset='utf-8' />
+    <meta name='renderer' content='webkit' />
+    <meta name='viewport' content='width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no'
+    />
+    <meta name='apple-mobile-web-app-capable' content='yes' />
+    <meta name='full-screen' content='true' />
+    <meta name='x5-fullscreen' content='true' />
+    <meta name='360-fullscreen' content='true' />
+    <meta name='laya' screenorientation='landscape' />
+    <meta http-equiv='expires' content='0' />
+    <meta http-equiv='X-UA-Compatible' content='IE=edge,chrome=1' />
+    <meta http-equiv='expires' content='0' />
+    <meta http-equiv='Cache-Control' content='no-siteapp' />
+</head>
+
+<body>
+    <script type="text/javascript">
+        function loadLib(url) {
+            var script = document.createElement("script");
+            script.async = false;
+            script.src = url;
+            document.body.appendChild(script);
+        }
+    </script>
+    <script type="text/javascript" src="index.js"></script>
+</body>
+
+</html>

+ 15 - 0
ShootingSun/bin/index.js

@@ -0,0 +1,15 @@
+/**
+ * 设置LayaNative屏幕方向,可设置以下值
+ * landscape           横屏
+ * portrait            竖屏
+ * sensor_landscape    横屏(双方向)
+ * sensor_portrait     竖屏(双方向)
+ */
+window.screenOrientation = "sensor_landscape";
+
+//-----libs-begin-----
+loadLib("libs/laya.core.js")
+loadLib("libs/laya.ani.js")
+loadLib("libs/laya.ui.js")
+//-----libs-end-------
+loadLib("js/bundle.js");

文件差異過大導致無法顯示
+ 2445 - 0
ShootingSun/bin/js/bundle.js


+ 3746 - 0
ShootingSun/bin/libs/bytebuffer.js

@@ -0,0 +1,3746 @@
+/*
+ Copyright 2013-2014 Daniel Wirtz <dcode@dcode.io>
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ */
+
+/**
+ * @license bytebuffer.js (c) 2015 Daniel Wirtz <dcode@dcode.io>
+ * Backing buffer: ArrayBuffer, Accessor: Uint8Array
+ * Released under the Apache License, Version 2.0
+ * see: https://github.com/dcodeIO/bytebuffer.js for details
+ */
+(function(global, factory) {
+
+    /* AMD */ if (typeof define === 'function' && define["amd"])
+        define(["long"], factory);
+    /* CommonJS */ else if (typeof require === 'function' && typeof module === "object" && module && module["exports"])
+        module['exports'] = (function() {
+            var Long; try { Long = require("long"); } catch (e) {}
+            return factory(Long);
+        })();
+    /* Global */ else
+        (global["dcodeIO"] = global["dcodeIO"] || {})["ByteBuffer"] = factory(global["dcodeIO"]["Long"]);
+
+})(this, function(Long) {
+    "use strict";
+
+    /**
+     * Constructs a new ByteBuffer.
+     * @class The swiss army knife for binary data in JavaScript.
+     * @exports ByteBuffer
+     * @constructor
+     * @param {number=} capacity Initial capacity. Defaults to {@link ByteBuffer.DEFAULT_CAPACITY}.
+     * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to
+     *  {@link ByteBuffer.DEFAULT_ENDIAN}.
+     * @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to
+     *  {@link ByteBuffer.DEFAULT_NOASSERT}.
+     * @expose
+     */
+    var ByteBuffer = function(capacity, littleEndian, noAssert) {
+        if (typeof capacity === 'undefined')
+            capacity = ByteBuffer.DEFAULT_CAPACITY;
+        if (typeof littleEndian === 'undefined')
+            littleEndian = ByteBuffer.DEFAULT_ENDIAN;
+        if (typeof noAssert === 'undefined')
+            noAssert = ByteBuffer.DEFAULT_NOASSERT;
+        if (!noAssert) {
+            capacity = capacity | 0;
+            if (capacity < 0)
+                throw RangeError("Illegal capacity");
+            littleEndian = !!littleEndian;
+            noAssert = !!noAssert;
+        }
+
+        /**
+         * Backing ArrayBuffer.
+         * @type {!ArrayBuffer}
+         * @expose
+         */
+        this.buffer = capacity === 0 ? EMPTY_BUFFER : new ArrayBuffer(capacity);
+
+        /**
+         * Uint8Array utilized to manipulate the backing buffer. Becomes `null` if the backing buffer has a capacity of `0`.
+         * @type {?Uint8Array}
+         * @expose
+         */
+        this.view = capacity === 0 ? null : new Uint8Array(this.buffer);
+
+        /**
+         * Absolute read/write offset.
+         * @type {number}
+         * @expose
+         * @see ByteBuffer#flip
+         * @see ByteBuffer#clear
+         */
+        this.offset = 0;
+
+        /**
+         * Marked offset.
+         * @type {number}
+         * @expose
+         * @see ByteBuffer#mark
+         * @see ByteBuffer#reset
+         */
+        this.markedOffset = -1;
+
+        /**
+         * Absolute limit of the contained data. Set to the backing buffer's capacity upon allocation.
+         * @type {number}
+         * @expose
+         * @see ByteBuffer#flip
+         * @see ByteBuffer#clear
+         */
+        this.limit = capacity;
+
+        /**
+         * Whether to use little endian byte order, defaults to `false` for big endian.
+         * @type {boolean}
+         * @expose
+         */
+        this.littleEndian = littleEndian;
+
+        /**
+         * Whether to skip assertions of offsets and values, defaults to `false`.
+         * @type {boolean}
+         * @expose
+         */
+        this.noAssert = noAssert;
+    };
+
+    /**
+     * ByteBuffer version.
+     * @type {string}
+     * @const
+     * @expose
+     */
+    ByteBuffer.VERSION = "5.0.1";
+
+    /**
+     * Little endian constant that can be used instead of its boolean value. Evaluates to `true`.
+     * @type {boolean}
+     * @const
+     * @expose
+     */
+    ByteBuffer.LITTLE_ENDIAN = true;
+
+    /**
+     * Big endian constant that can be used instead of its boolean value. Evaluates to `false`.
+     * @type {boolean}
+     * @const
+     * @expose
+     */
+    ByteBuffer.BIG_ENDIAN = false;
+
+    /**
+     * Default initial capacity of `16`.
+     * @type {number}
+     * @expose
+     */
+    ByteBuffer.DEFAULT_CAPACITY = 16;
+
+    /**
+     * Default endianess of `false` for big endian.
+     * @type {boolean}
+     * @expose
+     */
+    ByteBuffer.DEFAULT_ENDIAN = ByteBuffer.BIG_ENDIAN;
+
+    /**
+     * Default no assertions flag of `false`.
+     * @type {boolean}
+     * @expose
+     */
+    ByteBuffer.DEFAULT_NOASSERT = false;
+
+    /**
+     * A `Long` class for representing a 64-bit two's-complement integer value. May be `null` if Long.js has not been loaded
+     *  and int64 support is not available.
+     * @type {?Long}
+     * @const
+     * @see https://github.com/dcodeIO/long.js
+     * @expose
+     */
+    ByteBuffer.Long = Long || null;
+
+    /**
+     * @alias ByteBuffer.prototype
+     * @inner
+     */
+    var ByteBufferPrototype = ByteBuffer.prototype;
+
+    /**
+     * An indicator used to reliably determine if an object is a ByteBuffer or not.
+     * @type {boolean}
+     * @const
+     * @expose
+     * @private
+     */
+    ByteBufferPrototype.__isByteBuffer__;
+
+    Object.defineProperty(ByteBufferPrototype, "__isByteBuffer__", {
+        value: true,
+        enumerable: false,
+        configurable: false
+    });
+
+    // helpers
+
+    /**
+     * @type {!ArrayBuffer}
+     * @inner
+     */
+    var EMPTY_BUFFER = new ArrayBuffer(0);
+
+    /**
+     * String.fromCharCode reference for compile-time renaming.
+     * @type {function(...number):string}
+     * @inner
+     */
+    var stringFromCharCode = String.fromCharCode;
+
+    /**
+     * Creates a source function for a string.
+     * @param {string} s String to read from
+     * @returns {function():number|null} Source function returning the next char code respectively `null` if there are
+     *  no more characters left.
+     * @throws {TypeError} If the argument is invalid
+     * @inner
+     */
+    function stringSource(s) {
+        var i=0; return function() {
+            return i < s.length ? s.charCodeAt(i++) : null;
+        };
+    }
+
+    /**
+     * Creates a destination function for a string.
+     * @returns {function(number=):undefined|string} Destination function successively called with the next char code.
+     *  Returns the final string when called without arguments.
+     * @inner
+     */
+    function stringDestination() {
+        var cs = [], ps = []; return function() {
+            if (arguments.length === 0)
+                return ps.join('')+stringFromCharCode.apply(String, cs);
+            if (cs.length + arguments.length > 1024)
+                ps.push(stringFromCharCode.apply(String, cs)),
+                    cs.length = 0;
+            Array.prototype.push.apply(cs, arguments);
+        };
+    }
+
+    /**
+     * Gets the accessor type.
+     * @returns {Function} `Buffer` under node.js, `Uint8Array` respectively `DataView` in the browser (classes)
+     * @expose
+     */
+    ByteBuffer.accessor = function() {
+        return Uint8Array;
+    };
+    /**
+     * Allocates a new ByteBuffer backed by a buffer of the specified capacity.
+     * @param {number=} capacity Initial capacity. Defaults to {@link ByteBuffer.DEFAULT_CAPACITY}.
+     * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to
+     *  {@link ByteBuffer.DEFAULT_ENDIAN}.
+     * @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to
+     *  {@link ByteBuffer.DEFAULT_NOASSERT}.
+     * @returns {!ByteBuffer}
+     * @expose
+     */
+    ByteBuffer.allocate = function(capacity, littleEndian, noAssert) {
+        return new ByteBuffer(capacity, littleEndian, noAssert);
+    };
+
+    /**
+     * Concatenates multiple ByteBuffers into one.
+     * @param {!Array.<!ByteBuffer|!ArrayBuffer|!Uint8Array|string>} buffers Buffers to concatenate
+     * @param {(string|boolean)=} encoding String encoding if `buffers` contains a string ("base64", "hex", "binary",
+     *  defaults to "utf8")
+     * @param {boolean=} littleEndian Whether to use little or big endian byte order for the resulting ByteBuffer. Defaults
+     *  to {@link ByteBuffer.DEFAULT_ENDIAN}.
+     * @param {boolean=} noAssert Whether to skip assertions of offsets and values for the resulting ByteBuffer. Defaults to
+     *  {@link ByteBuffer.DEFAULT_NOASSERT}.
+     * @returns {!ByteBuffer} Concatenated ByteBuffer
+     * @expose
+     */
+    ByteBuffer.concat = function(buffers, encoding, littleEndian, noAssert) {
+        if (typeof encoding === 'boolean' || typeof encoding !== 'string') {
+            noAssert = littleEndian;
+            littleEndian = encoding;
+            encoding = undefined;
+        }
+        var capacity = 0;
+        for (var i=0, k=buffers.length, length; i<k; ++i) {
+            if (!ByteBuffer.isByteBuffer(buffers[i]))
+                buffers[i] = ByteBuffer.wrap(buffers[i], encoding);
+            length = buffers[i].limit - buffers[i].offset;
+            if (length > 0) capacity += length;
+        }
+        if (capacity === 0)
+            return new ByteBuffer(0, littleEndian, noAssert);
+        var bb = new ByteBuffer(capacity, littleEndian, noAssert),
+            bi;
+        i=0; while (i<k) {
+            bi = buffers[i++];
+            length = bi.limit - bi.offset;
+            if (length <= 0) continue;
+            bb.view.set(bi.view.subarray(bi.offset, bi.limit), bb.offset);
+            bb.offset += length;
+        }
+        bb.limit = bb.offset;
+        bb.offset = 0;
+        return bb;
+    };
+
+    /**
+     * Tests if the specified type is a ByteBuffer.
+     * @param {*} bb ByteBuffer to test
+     * @returns {boolean} `true` if it is a ByteBuffer, otherwise `false`
+     * @expose
+     */
+    ByteBuffer.isByteBuffer = function(bb) {
+        return (bb && bb["__isByteBuffer__"]) === true;
+    };
+    /**
+     * Gets the backing buffer type.
+     * @returns {Function} `Buffer` under node.js, `ArrayBuffer` in the browser (classes)
+     * @expose
+     */
+    ByteBuffer.type = function() {
+        return ArrayBuffer;
+    };
+    /**
+     * Wraps a buffer or a string. Sets the allocated ByteBuffer's {@link ByteBuffer#offset} to `0` and its
+     *  {@link ByteBuffer#limit} to the length of the wrapped data.
+     * @param {!ByteBuffer|!ArrayBuffer|!Uint8Array|string|!Array.<number>} buffer Anything that can be wrapped
+     * @param {(string|boolean)=} encoding String encoding if `buffer` is a string ("base64", "hex", "binary", defaults to
+     *  "utf8")
+     * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to
+     *  {@link ByteBuffer.DEFAULT_ENDIAN}.
+     * @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to
+     *  {@link ByteBuffer.DEFAULT_NOASSERT}.
+     * @returns {!ByteBuffer} A ByteBuffer wrapping `buffer`
+     * @expose
+     */
+    ByteBuffer.wrap = function(buffer, encoding, littleEndian, noAssert) {
+        if (typeof encoding !== 'string') {
+            noAssert = littleEndian;
+            littleEndian = encoding;
+            encoding = undefined;
+        }
+        if (typeof buffer === 'string') {
+            if (typeof encoding === 'undefined')
+                encoding = "utf8";
+            switch (encoding) {
+                case "base64":
+                    return ByteBuffer.fromBase64(buffer, littleEndian);
+                case "hex":
+                    return ByteBuffer.fromHex(buffer, littleEndian);
+                case "binary":
+                    return ByteBuffer.fromBinary(buffer, littleEndian);
+                case "utf8":
+                    return ByteBuffer.fromUTF8(buffer, littleEndian);
+                case "debug":
+                    return ByteBuffer.fromDebug(buffer, littleEndian);
+                default:
+                    throw Error("Unsupported encoding: "+encoding);
+            }
+        }
+        if (buffer === null || typeof buffer !== 'object')
+            throw TypeError("Illegal buffer");
+        var bb;
+        if (ByteBuffer.isByteBuffer(buffer)) {
+            bb = ByteBufferPrototype.clone.call(buffer);
+            bb.markedOffset = -1;
+            return bb;
+        }
+        if (buffer instanceof Uint8Array) { // Extract ArrayBuffer from Uint8Array
+            bb = new ByteBuffer(0, littleEndian, noAssert);
+            if (buffer.length > 0) { // Avoid references to more than one EMPTY_BUFFER
+                bb.buffer = buffer.buffer;
+                bb.offset = buffer.byteOffset;
+                bb.limit = buffer.byteOffset + buffer.byteLength;
+                bb.view = new Uint8Array(buffer.buffer);
+            }
+        } else if (buffer instanceof ArrayBuffer) { // Reuse ArrayBuffer
+            bb = new ByteBuffer(0, littleEndian, noAssert);
+            if (buffer.byteLength > 0) {
+                bb.buffer = buffer;
+                bb.offset = 0;
+                bb.limit = buffer.byteLength;
+                bb.view = buffer.byteLength > 0 ? new Uint8Array(buffer) : null;
+            }
+        } else if (Object.prototype.toString.call(buffer) === "[object Array]") { // Create from octets
+            bb = new ByteBuffer(buffer.length, littleEndian, noAssert);
+            bb.limit = buffer.length;
+            for (var i=0; i<buffer.length; ++i)
+                bb.view[i] = buffer[i];
+        } else
+            throw TypeError("Illegal buffer"); // Otherwise fail
+        return bb;
+    };
+
+    /**
+     * Writes the array as a bitset.
+     * @param {Array<boolean>} value Array of booleans to write
+     * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `length` if omitted.
+     * @returns {!ByteBuffer}
+     * @expose
+     */
+    ByteBufferPrototype.writeBitSet = function(value, offset) {
+      var relative = typeof offset === 'undefined';
+      if (relative) offset = this.offset;
+      if (!this.noAssert) {
+        if (!(value instanceof Array))
+          throw TypeError("Illegal BitSet: Not an array");
+        if (typeof offset !== 'number' || offset % 1 !== 0)
+            throw TypeError("Illegal offset: "+offset+" (not an integer)");
+        offset >>>= 0;
+        if (offset < 0 || offset + 0 > this.buffer.byteLength)
+            throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+      }
+
+      var start = offset,
+          bits = value.length,
+          bytes = (bits >> 3),
+          bit = 0,
+          k;
+
+      offset += this.writeVarint32(bits,offset);
+
+      while(bytes--) {
+        k = (!!value[bit++] & 1) |
+            ((!!value[bit++] & 1) << 1) |
+            ((!!value[bit++] & 1) << 2) |
+            ((!!value[bit++] & 1) << 3) |
+            ((!!value[bit++] & 1) << 4) |
+            ((!!value[bit++] & 1) << 5) |
+            ((!!value[bit++] & 1) << 6) |
+            ((!!value[bit++] & 1) << 7);
+        this.writeByte(k,offset++);
+      }
+
+      if(bit < bits) {
+        var m = 0; k = 0;
+        while(bit < bits) k = k | ((!!value[bit++] & 1) << (m++));
+        this.writeByte(k,offset++);
+      }
+
+      if (relative) {
+        this.offset = offset;
+        return this;
+      }
+      return offset - start;
+    }
+
+    /**
+     * Reads a BitSet as an array of booleans.
+     * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `length` if omitted.
+     * @returns {Array<boolean>
+     * @expose
+     */
+    ByteBufferPrototype.readBitSet = function(offset) {
+      var relative = typeof offset === 'undefined';
+      if (relative) offset = this.offset;
+
+      var ret = this.readVarint32(offset),
+          bits = ret.value,
+          bytes = (bits >> 3),
+          bit = 0,
+          value = [],
+          k;
+
+      offset += ret.length;
+
+      while(bytes--) {
+        k = this.readByte(offset++);
+        value[bit++] = !!(k & 0x01);
+        value[bit++] = !!(k & 0x02);
+        value[bit++] = !!(k & 0x04);
+        value[bit++] = !!(k & 0x08);
+        value[bit++] = !!(k & 0x10);
+        value[bit++] = !!(k & 0x20);
+        value[bit++] = !!(k & 0x40);
+        value[bit++] = !!(k & 0x80);
+      }
+
+      if(bit < bits) {
+        var m = 0;
+        k = this.readByte(offset++);
+        while(bit < bits) value[bit++] = !!((k >> (m++)) & 1);
+      }
+
+      if (relative) {
+        this.offset = offset;
+      }
+      return value;
+    }
+    /**
+     * Reads the specified number of bytes.
+     * @param {number} length Number of bytes to read
+     * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `length` if omitted.
+     * @returns {!ByteBuffer}
+     * @expose
+     */
+    ByteBufferPrototype.readBytes = function(length, offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + length > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+length+") <= "+this.buffer.byteLength);
+        }
+        var slice = this.slice(offset, offset + length);
+        if (relative) this.offset += length;
+        return slice;
+    };
+
+    /**
+     * Writes a payload of bytes. This is an alias of {@link ByteBuffer#append}.
+     * @function
+     * @param {!ByteBuffer|!ArrayBuffer|!Uint8Array|string} source Data to write. If `source` is a ByteBuffer, its offsets
+     *  will be modified according to the performed read operation.
+     * @param {(string|number)=} encoding Encoding if `data` is a string ("base64", "hex", "binary", defaults to "utf8")
+     * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+     *  written if omitted.
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.writeBytes = ByteBufferPrototype.append;
+
+    // types/ints/int8
+
+    /**
+     * Writes an 8bit signed integer.
+     * @param {number} value Value to write
+     * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.writeInt8 = function(value, offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof value !== 'number' || value % 1 !== 0)
+                throw TypeError("Illegal value: "+value+" (not an integer)");
+            value |= 0;
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+        }
+        offset += 1;
+        var capacity0 = this.buffer.byteLength;
+        if (offset > capacity0)
+            this.resize((capacity0 *= 2) > offset ? capacity0 : offset);
+        offset -= 1;
+        this.view[offset] = value;
+        if (relative) this.offset += 1;
+        return this;
+    };
+
+    /**
+     * Writes an 8bit signed integer. This is an alias of {@link ByteBuffer#writeInt8}.
+     * @function
+     * @param {number} value Value to write
+     * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.writeByte = ByteBufferPrototype.writeInt8;
+
+    /**
+     * Reads an 8bit signed integer.
+     * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.
+     * @returns {number} Value read
+     * @expose
+     */
+    ByteBufferPrototype.readInt8 = function(offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 1 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+1+") <= "+this.buffer.byteLength);
+        }
+        var value = this.view[offset];
+        if ((value & 0x80) === 0x80) value = -(0xFF - value + 1); // Cast to signed
+        if (relative) this.offset += 1;
+        return value;
+    };
+
+    /**
+     * Reads an 8bit signed integer. This is an alias of {@link ByteBuffer#readInt8}.
+     * @function
+     * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.
+     * @returns {number} Value read
+     * @expose
+     */
+    ByteBufferPrototype.readByte = ByteBufferPrototype.readInt8;
+
+    /**
+     * Writes an 8bit unsigned integer.
+     * @param {number} value Value to write
+     * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.writeUint8 = function(value, offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof value !== 'number' || value % 1 !== 0)
+                throw TypeError("Illegal value: "+value+" (not an integer)");
+            value >>>= 0;
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+        }
+        offset += 1;
+        var capacity1 = this.buffer.byteLength;
+        if (offset > capacity1)
+            this.resize((capacity1 *= 2) > offset ? capacity1 : offset);
+        offset -= 1;
+        this.view[offset] = value;
+        if (relative) this.offset += 1;
+        return this;
+    };
+
+    /**
+     * Writes an 8bit unsigned integer. This is an alias of {@link ByteBuffer#writeUint8}.
+     * @function
+     * @param {number} value Value to write
+     * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.writeUInt8 = ByteBufferPrototype.writeUint8;
+
+    /**
+     * Reads an 8bit unsigned integer.
+     * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.
+     * @returns {number} Value read
+     * @expose
+     */
+    ByteBufferPrototype.readUint8 = function(offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 1 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+1+") <= "+this.buffer.byteLength);
+        }
+        var value = this.view[offset];
+        if (relative) this.offset += 1;
+        return value;
+    };
+
+    /**
+     * Reads an 8bit unsigned integer. This is an alias of {@link ByteBuffer#readUint8}.
+     * @function
+     * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `1` if omitted.
+     * @returns {number} Value read
+     * @expose
+     */
+    ByteBufferPrototype.readUInt8 = ByteBufferPrototype.readUint8;
+
+    // types/ints/int16
+
+    /**
+     * Writes a 16bit signed integer.
+     * @param {number} value Value to write
+     * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.
+     * @throws {TypeError} If `offset` or `value` is not a valid number
+     * @throws {RangeError} If `offset` is out of bounds
+     * @expose
+     */
+    ByteBufferPrototype.writeInt16 = function(value, offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof value !== 'number' || value % 1 !== 0)
+                throw TypeError("Illegal value: "+value+" (not an integer)");
+            value |= 0;
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+        }
+        offset += 2;
+        var capacity2 = this.buffer.byteLength;
+        if (offset > capacity2)
+            this.resize((capacity2 *= 2) > offset ? capacity2 : offset);
+        offset -= 2;
+        if (this.littleEndian) {
+            this.view[offset+1] = (value & 0xFF00) >>> 8;
+            this.view[offset  ] =  value & 0x00FF;
+        } else {
+            this.view[offset]   = (value & 0xFF00) >>> 8;
+            this.view[offset+1] =  value & 0x00FF;
+        }
+        if (relative) this.offset += 2;
+        return this;
+    };
+
+    /**
+     * Writes a 16bit signed integer. This is an alias of {@link ByteBuffer#writeInt16}.
+     * @function
+     * @param {number} value Value to write
+     * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.
+     * @throws {TypeError} If `offset` or `value` is not a valid number
+     * @throws {RangeError} If `offset` is out of bounds
+     * @expose
+     */
+    ByteBufferPrototype.writeShort = ByteBufferPrototype.writeInt16;
+
+    /**
+     * Reads a 16bit signed integer.
+     * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.
+     * @returns {number} Value read
+     * @throws {TypeError} If `offset` is not a valid number
+     * @throws {RangeError} If `offset` is out of bounds
+     * @expose
+     */
+    ByteBufferPrototype.readInt16 = function(offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 2 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+2+") <= "+this.buffer.byteLength);
+        }
+        var value = 0;
+        if (this.littleEndian) {
+            value  = this.view[offset  ];
+            value |= this.view[offset+1] << 8;
+        } else {
+            value  = this.view[offset  ] << 8;
+            value |= this.view[offset+1];
+        }
+        if ((value & 0x8000) === 0x8000) value = -(0xFFFF - value + 1); // Cast to signed
+        if (relative) this.offset += 2;
+        return value;
+    };
+
+    /**
+     * Reads a 16bit signed integer. This is an alias of {@link ByteBuffer#readInt16}.
+     * @function
+     * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.
+     * @returns {number} Value read
+     * @throws {TypeError} If `offset` is not a valid number
+     * @throws {RangeError} If `offset` is out of bounds
+     * @expose
+     */
+    ByteBufferPrototype.readShort = ByteBufferPrototype.readInt16;
+
+    /**
+     * Writes a 16bit unsigned integer.
+     * @param {number} value Value to write
+     * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.
+     * @throws {TypeError} If `offset` or `value` is not a valid number
+     * @throws {RangeError} If `offset` is out of bounds
+     * @expose
+     */
+    ByteBufferPrototype.writeUint16 = function(value, offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof value !== 'number' || value % 1 !== 0)
+                throw TypeError("Illegal value: "+value+" (not an integer)");
+            value >>>= 0;
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+        }
+        offset += 2;
+        var capacity3 = this.buffer.byteLength;
+        if (offset > capacity3)
+            this.resize((capacity3 *= 2) > offset ? capacity3 : offset);
+        offset -= 2;
+        if (this.littleEndian) {
+            this.view[offset+1] = (value & 0xFF00) >>> 8;
+            this.view[offset  ] =  value & 0x00FF;
+        } else {
+            this.view[offset]   = (value & 0xFF00) >>> 8;
+            this.view[offset+1] =  value & 0x00FF;
+        }
+        if (relative) this.offset += 2;
+        return this;
+    };
+
+    /**
+     * Writes a 16bit unsigned integer. This is an alias of {@link ByteBuffer#writeUint16}.
+     * @function
+     * @param {number} value Value to write
+     * @param {number=} offset Offset to write to. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.
+     * @throws {TypeError} If `offset` or `value` is not a valid number
+     * @throws {RangeError} If `offset` is out of bounds
+     * @expose
+     */
+    ByteBufferPrototype.writeUInt16 = ByteBufferPrototype.writeUint16;
+
+    /**
+     * Reads a 16bit unsigned integer.
+     * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.
+     * @returns {number} Value read
+     * @throws {TypeError} If `offset` is not a valid number
+     * @throws {RangeError} If `offset` is out of bounds
+     * @expose
+     */
+    ByteBufferPrototype.readUint16 = function(offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 2 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+2+") <= "+this.buffer.byteLength);
+        }
+        var value = 0;
+        if (this.littleEndian) {
+            value  = this.view[offset  ];
+            value |= this.view[offset+1] << 8;
+        } else {
+            value  = this.view[offset  ] << 8;
+            value |= this.view[offset+1];
+        }
+        if (relative) this.offset += 2;
+        return value;
+    };
+
+    /**
+     * Reads a 16bit unsigned integer. This is an alias of {@link ByteBuffer#readUint16}.
+     * @function
+     * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `2` if omitted.
+     * @returns {number} Value read
+     * @throws {TypeError} If `offset` is not a valid number
+     * @throws {RangeError} If `offset` is out of bounds
+     * @expose
+     */
+    ByteBufferPrototype.readUInt16 = ByteBufferPrototype.readUint16;
+
+    // types/ints/int32
+
+    /**
+     * Writes a 32bit signed integer.
+     * @param {number} value Value to write
+     * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
+     * @expose
+     */
+    ByteBufferPrototype.writeInt32 = function(value, offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof value !== 'number' || value % 1 !== 0)
+                throw TypeError("Illegal value: "+value+" (not an integer)");
+            value |= 0;
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+        }
+        offset += 4;
+        var capacity4 = this.buffer.byteLength;
+        if (offset > capacity4)
+            this.resize((capacity4 *= 2) > offset ? capacity4 : offset);
+        offset -= 4;
+        if (this.littleEndian) {
+            this.view[offset+3] = (value >>> 24) & 0xFF;
+            this.view[offset+2] = (value >>> 16) & 0xFF;
+            this.view[offset+1] = (value >>>  8) & 0xFF;
+            this.view[offset  ] =  value         & 0xFF;
+        } else {
+            this.view[offset  ] = (value >>> 24) & 0xFF;
+            this.view[offset+1] = (value >>> 16) & 0xFF;
+            this.view[offset+2] = (value >>>  8) & 0xFF;
+            this.view[offset+3] =  value         & 0xFF;
+        }
+        if (relative) this.offset += 4;
+        return this;
+    };
+
+    /**
+     * Writes a 32bit signed integer. This is an alias of {@link ByteBuffer#writeInt32}.
+     * @param {number} value Value to write
+     * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
+     * @expose
+     */
+    ByteBufferPrototype.writeInt = ByteBufferPrototype.writeInt32;
+
+    /**
+     * Reads a 32bit signed integer.
+     * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
+     * @returns {number} Value read
+     * @expose
+     */
+    ByteBufferPrototype.readInt32 = function(offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 4 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+4+") <= "+this.buffer.byteLength);
+        }
+        var value = 0;
+        if (this.littleEndian) {
+            value  = this.view[offset+2] << 16;
+            value |= this.view[offset+1] <<  8;
+            value |= this.view[offset  ];
+            value += this.view[offset+3] << 24 >>> 0;
+        } else {
+            value  = this.view[offset+1] << 16;
+            value |= this.view[offset+2] <<  8;
+            value |= this.view[offset+3];
+            value += this.view[offset  ] << 24 >>> 0;
+        }
+        value |= 0; // Cast to signed
+        if (relative) this.offset += 4;
+        return value;
+    };
+
+    /**
+     * Reads a 32bit signed integer. This is an alias of {@link ByteBuffer#readInt32}.
+     * @param {number=} offset Offset to read from. Will use and advance {@link ByteBuffer#offset} by `4` if omitted.
+     * @returns {number} Value read
+     * @expose
+     */
+    ByteBufferPrototype.readInt = ByteBufferPrototype.readInt32;
+
+    /**
+     * Writes a 32bit unsigned integer.
+     * @param {number} value Value to write
+     * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
+     * @expose
+     */
+    ByteBufferPrototype.writeUint32 = function(value, offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof value !== 'number' || value % 1 !== 0)
+                throw TypeError("Illegal value: "+value+" (not an integer)");
+            value >>>= 0;
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+        }
+        offset += 4;
+        var capacity5 = this.buffer.byteLength;
+        if (offset > capacity5)
+            this.resize((capacity5 *= 2) > offset ? capacity5 : offset);
+        offset -= 4;
+        if (this.littleEndian) {
+            this.view[offset+3] = (value >>> 24) & 0xFF;
+            this.view[offset+2] = (value >>> 16) & 0xFF;
+            this.view[offset+1] = (value >>>  8) & 0xFF;
+            this.view[offset  ] =  value         & 0xFF;
+        } else {
+            this.view[offset  ] = (value >>> 24) & 0xFF;
+            this.view[offset+1] = (value >>> 16) & 0xFF;
+            this.view[offset+2] = (value >>>  8) & 0xFF;
+            this.view[offset+3] =  value         & 0xFF;
+        }
+        if (relative) this.offset += 4;
+        return this;
+    };
+
+    /**
+     * Writes a 32bit unsigned integer. This is an alias of {@link ByteBuffer#writeUint32}.
+     * @function
+     * @param {number} value Value to write
+     * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
+     * @expose
+     */
+    ByteBufferPrototype.writeUInt32 = ByteBufferPrototype.writeUint32;
+
+    /**
+     * Reads a 32bit unsigned integer.
+     * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
+     * @returns {number} Value read
+     * @expose
+     */
+    ByteBufferPrototype.readUint32 = function(offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 4 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+4+") <= "+this.buffer.byteLength);
+        }
+        var value = 0;
+        if (this.littleEndian) {
+            value  = this.view[offset+2] << 16;
+            value |= this.view[offset+1] <<  8;
+            value |= this.view[offset  ];
+            value += this.view[offset+3] << 24 >>> 0;
+        } else {
+            value  = this.view[offset+1] << 16;
+            value |= this.view[offset+2] <<  8;
+            value |= this.view[offset+3];
+            value += this.view[offset  ] << 24 >>> 0;
+        }
+        if (relative) this.offset += 4;
+        return value;
+    };
+
+    /**
+     * Reads a 32bit unsigned integer. This is an alias of {@link ByteBuffer#readUint32}.
+     * @function
+     * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
+     * @returns {number} Value read
+     * @expose
+     */
+    ByteBufferPrototype.readUInt32 = ByteBufferPrototype.readUint32;
+
+    // types/ints/int64
+
+    if (Long) {
+
+        /**
+         * Writes a 64bit signed integer.
+         * @param {number|!Long} value Value to write
+         * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
+         * @returns {!ByteBuffer} this
+         * @expose
+         */
+        ByteBufferPrototype.writeInt64 = function(value, offset) {
+            var relative = typeof offset === 'undefined';
+            if (relative) offset = this.offset;
+            if (!this.noAssert) {
+                if (typeof value === 'number')
+                    value = Long.fromNumber(value);
+                else if (typeof value === 'string')
+                    value = Long.fromString(value);
+                else if (!(value && value instanceof Long))
+                    throw TypeError("Illegal value: "+value+" (not an integer or Long)");
+                if (typeof offset !== 'number' || offset % 1 !== 0)
+                    throw TypeError("Illegal offset: "+offset+" (not an integer)");
+                offset >>>= 0;
+                if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                    throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+            }
+            if (typeof value === 'number')
+                value = Long.fromNumber(value);
+            else if (typeof value === 'string')
+                value = Long.fromString(value);
+            offset += 8;
+            var capacity6 = this.buffer.byteLength;
+            if (offset > capacity6)
+                this.resize((capacity6 *= 2) > offset ? capacity6 : offset);
+            offset -= 8;
+            var lo = value.low,
+                hi = value.high;
+            if (this.littleEndian) {
+                this.view[offset+3] = (lo >>> 24) & 0xFF;
+                this.view[offset+2] = (lo >>> 16) & 0xFF;
+                this.view[offset+1] = (lo >>>  8) & 0xFF;
+                this.view[offset  ] =  lo         & 0xFF;
+                offset += 4;
+                this.view[offset+3] = (hi >>> 24) & 0xFF;
+                this.view[offset+2] = (hi >>> 16) & 0xFF;
+                this.view[offset+1] = (hi >>>  8) & 0xFF;
+                this.view[offset  ] =  hi         & 0xFF;
+            } else {
+                this.view[offset  ] = (hi >>> 24) & 0xFF;
+                this.view[offset+1] = (hi >>> 16) & 0xFF;
+                this.view[offset+2] = (hi >>>  8) & 0xFF;
+                this.view[offset+3] =  hi         & 0xFF;
+                offset += 4;
+                this.view[offset  ] = (lo >>> 24) & 0xFF;
+                this.view[offset+1] = (lo >>> 16) & 0xFF;
+                this.view[offset+2] = (lo >>>  8) & 0xFF;
+                this.view[offset+3] =  lo         & 0xFF;
+            }
+            if (relative) this.offset += 8;
+            return this;
+        };
+
+        /**
+         * Writes a 64bit signed integer. This is an alias of {@link ByteBuffer#writeInt64}.
+         * @param {number|!Long} value Value to write
+         * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
+         * @returns {!ByteBuffer} this
+         * @expose
+         */
+        ByteBufferPrototype.writeLong = ByteBufferPrototype.writeInt64;
+
+        /**
+         * Reads a 64bit signed integer.
+         * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
+         * @returns {!Long}
+         * @expose
+         */
+        ByteBufferPrototype.readInt64 = function(offset) {
+            var relative = typeof offset === 'undefined';
+            if (relative) offset = this.offset;
+            if (!this.noAssert) {
+                if (typeof offset !== 'number' || offset % 1 !== 0)
+                    throw TypeError("Illegal offset: "+offset+" (not an integer)");
+                offset >>>= 0;
+                if (offset < 0 || offset + 8 > this.buffer.byteLength)
+                    throw RangeError("Illegal offset: 0 <= "+offset+" (+"+8+") <= "+this.buffer.byteLength);
+            }
+            var lo = 0,
+                hi = 0;
+            if (this.littleEndian) {
+                lo  = this.view[offset+2] << 16;
+                lo |= this.view[offset+1] <<  8;
+                lo |= this.view[offset  ];
+                lo += this.view[offset+3] << 24 >>> 0;
+                offset += 4;
+                hi  = this.view[offset+2] << 16;
+                hi |= this.view[offset+1] <<  8;
+                hi |= this.view[offset  ];
+                hi += this.view[offset+3] << 24 >>> 0;
+            } else {
+                hi  = this.view[offset+1] << 16;
+                hi |= this.view[offset+2] <<  8;
+                hi |= this.view[offset+3];
+                hi += this.view[offset  ] << 24 >>> 0;
+                offset += 4;
+                lo  = this.view[offset+1] << 16;
+                lo |= this.view[offset+2] <<  8;
+                lo |= this.view[offset+3];
+                lo += this.view[offset  ] << 24 >>> 0;
+            }
+            var value = new Long(lo, hi, false);
+            if (relative) this.offset += 8;
+            return value;
+        };
+
+        /**
+         * Reads a 64bit signed integer. This is an alias of {@link ByteBuffer#readInt64}.
+         * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
+         * @returns {!Long}
+         * @expose
+         */
+        ByteBufferPrototype.readLong = ByteBufferPrototype.readInt64;
+
+        /**
+         * Writes a 64bit unsigned integer.
+         * @param {number|!Long} value Value to write
+         * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
+         * @returns {!ByteBuffer} this
+         * @expose
+         */
+        ByteBufferPrototype.writeUint64 = function(value, offset) {
+            var relative = typeof offset === 'undefined';
+            if (relative) offset = this.offset;
+            if (!this.noAssert) {
+                if (typeof value === 'number')
+                    value = Long.fromNumber(value);
+                else if (typeof value === 'string')
+                    value = Long.fromString(value);
+                else if (!(value && value instanceof Long))
+                    throw TypeError("Illegal value: "+value+" (not an integer or Long)");
+                if (typeof offset !== 'number' || offset % 1 !== 0)
+                    throw TypeError("Illegal offset: "+offset+" (not an integer)");
+                offset >>>= 0;
+                if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                    throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+            }
+            if (typeof value === 'number')
+                value = Long.fromNumber(value);
+            else if (typeof value === 'string')
+                value = Long.fromString(value);
+            offset += 8;
+            var capacity7 = this.buffer.byteLength;
+            if (offset > capacity7)
+                this.resize((capacity7 *= 2) > offset ? capacity7 : offset);
+            offset -= 8;
+            var lo = value.low,
+                hi = value.high;
+            if (this.littleEndian) {
+                this.view[offset+3] = (lo >>> 24) & 0xFF;
+                this.view[offset+2] = (lo >>> 16) & 0xFF;
+                this.view[offset+1] = (lo >>>  8) & 0xFF;
+                this.view[offset  ] =  lo         & 0xFF;
+                offset += 4;
+                this.view[offset+3] = (hi >>> 24) & 0xFF;
+                this.view[offset+2] = (hi >>> 16) & 0xFF;
+                this.view[offset+1] = (hi >>>  8) & 0xFF;
+                this.view[offset  ] =  hi         & 0xFF;
+            } else {
+                this.view[offset  ] = (hi >>> 24) & 0xFF;
+                this.view[offset+1] = (hi >>> 16) & 0xFF;
+                this.view[offset+2] = (hi >>>  8) & 0xFF;
+                this.view[offset+3] =  hi         & 0xFF;
+                offset += 4;
+                this.view[offset  ] = (lo >>> 24) & 0xFF;
+                this.view[offset+1] = (lo >>> 16) & 0xFF;
+                this.view[offset+2] = (lo >>>  8) & 0xFF;
+                this.view[offset+3] =  lo         & 0xFF;
+            }
+            if (relative) this.offset += 8;
+            return this;
+        };
+
+        /**
+         * Writes a 64bit unsigned integer. This is an alias of {@link ByteBuffer#writeUint64}.
+         * @function
+         * @param {number|!Long} value Value to write
+         * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
+         * @returns {!ByteBuffer} this
+         * @expose
+         */
+        ByteBufferPrototype.writeUInt64 = ByteBufferPrototype.writeUint64;
+
+        /**
+         * Reads a 64bit unsigned integer.
+         * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
+         * @returns {!Long}
+         * @expose
+         */
+        ByteBufferPrototype.readUint64 = function(offset) {
+            var relative = typeof offset === 'undefined';
+            if (relative) offset = this.offset;
+            if (!this.noAssert) {
+                if (typeof offset !== 'number' || offset % 1 !== 0)
+                    throw TypeError("Illegal offset: "+offset+" (not an integer)");
+                offset >>>= 0;
+                if (offset < 0 || offset + 8 > this.buffer.byteLength)
+                    throw RangeError("Illegal offset: 0 <= "+offset+" (+"+8+") <= "+this.buffer.byteLength);
+            }
+            var lo = 0,
+                hi = 0;
+            if (this.littleEndian) {
+                lo  = this.view[offset+2] << 16;
+                lo |= this.view[offset+1] <<  8;
+                lo |= this.view[offset  ];
+                lo += this.view[offset+3] << 24 >>> 0;
+                offset += 4;
+                hi  = this.view[offset+2] << 16;
+                hi |= this.view[offset+1] <<  8;
+                hi |= this.view[offset  ];
+                hi += this.view[offset+3] << 24 >>> 0;
+            } else {
+                hi  = this.view[offset+1] << 16;
+                hi |= this.view[offset+2] <<  8;
+                hi |= this.view[offset+3];
+                hi += this.view[offset  ] << 24 >>> 0;
+                offset += 4;
+                lo  = this.view[offset+1] << 16;
+                lo |= this.view[offset+2] <<  8;
+                lo |= this.view[offset+3];
+                lo += this.view[offset  ] << 24 >>> 0;
+            }
+            var value = new Long(lo, hi, true);
+            if (relative) this.offset += 8;
+            return value;
+        };
+
+        /**
+         * Reads a 64bit unsigned integer. This is an alias of {@link ByteBuffer#readUint64}.
+         * @function
+         * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
+         * @returns {!Long}
+         * @expose
+         */
+        ByteBufferPrototype.readUInt64 = ByteBufferPrototype.readUint64;
+
+    } // Long
+
+
+    // types/floats/float32
+
+    /*
+     ieee754 - https://github.com/feross/ieee754
+
+     The MIT License (MIT)
+
+     Copyright (c) Feross Aboukhadijeh
+
+     Permission is hereby granted, free of charge, to any person obtaining a copy
+     of this software and associated documentation files (the "Software"), to deal
+     in the Software without restriction, including without limitation the rights
+     to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+     copies of the Software, and to permit persons to whom the Software is
+     furnished to do so, subject to the following conditions:
+
+     The above copyright notice and this permission notice shall be included in
+     all copies or substantial portions of the Software.
+
+     THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+     IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+     FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+     AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+     LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+     OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+     THE SOFTWARE.
+    */
+
+    /**
+     * Reads an IEEE754 float from a byte array.
+     * @param {!Array} buffer
+     * @param {number} offset
+     * @param {boolean} isLE
+     * @param {number} mLen
+     * @param {number} nBytes
+     * @returns {number}
+     * @inner
+     */
+    function ieee754_read(buffer, offset, isLE, mLen, nBytes) {
+        var e, m,
+            eLen = nBytes * 8 - mLen - 1,
+            eMax = (1 << eLen) - 1,
+            eBias = eMax >> 1,
+            nBits = -7,
+            i = isLE ? (nBytes - 1) : 0,
+            d = isLE ? -1 : 1,
+            s = buffer[offset + i];
+
+        i += d;
+
+        e = s & ((1 << (-nBits)) - 1);
+        s >>= (-nBits);
+        nBits += eLen;
+        for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
+
+        m = e & ((1 << (-nBits)) - 1);
+        e >>= (-nBits);
+        nBits += mLen;
+        for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
+
+        if (e === 0) {
+            e = 1 - eBias;
+        } else if (e === eMax) {
+            return m ? NaN : ((s ? -1 : 1) * Infinity);
+        } else {
+            m = m + Math.pow(2, mLen);
+            e = e - eBias;
+        }
+        return (s ? -1 : 1) * m * Math.pow(2, e - mLen);
+    }
+
+    /**
+     * Writes an IEEE754 float to a byte array.
+     * @param {!Array} buffer
+     * @param {number} value
+     * @param {number} offset
+     * @param {boolean} isLE
+     * @param {number} mLen
+     * @param {number} nBytes
+     * @inner
+     */
+    function ieee754_write(buffer, value, offset, isLE, mLen, nBytes) {
+        var e, m, c,
+            eLen = nBytes * 8 - mLen - 1,
+            eMax = (1 << eLen) - 1,
+            eBias = eMax >> 1,
+            rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0),
+            i = isLE ? 0 : (nBytes - 1),
+            d = isLE ? 1 : -1,
+            s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0;
+
+        value = Math.abs(value);
+
+        if (isNaN(value) || value === Infinity) {
+            m = isNaN(value) ? 1 : 0;
+            e = eMax;
+        } else {
+            e = Math.floor(Math.log(value) / Math.LN2);
+            if (value * (c = Math.pow(2, -e)) < 1) {
+                e--;
+                c *= 2;
+            }
+            if (e + eBias >= 1) {
+                value += rt / c;
+            } else {
+                value += rt * Math.pow(2, 1 - eBias);
+            }
+            if (value * c >= 2) {
+                e++;
+                c /= 2;
+            }
+
+            if (e + eBias >= eMax) {
+                m = 0;
+                e = eMax;
+            } else if (e + eBias >= 1) {
+                m = (value * c - 1) * Math.pow(2, mLen);
+                e = e + eBias;
+            } else {
+                m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
+                e = 0;
+            }
+        }
+
+        for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
+
+        e = (e << mLen) | m;
+        eLen += mLen;
+        for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
+
+        buffer[offset + i - d] |= s * 128;
+    }
+
+    /**
+     * Writes a 32bit float.
+     * @param {number} value Value to write
+     * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.writeFloat32 = function(value, offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof value !== 'number')
+                throw TypeError("Illegal value: "+value+" (not a number)");
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+        }
+        offset += 4;
+        var capacity8 = this.buffer.byteLength;
+        if (offset > capacity8)
+            this.resize((capacity8 *= 2) > offset ? capacity8 : offset);
+        offset -= 4;
+        ieee754_write(this.view, value, offset, this.littleEndian, 23, 4);
+        if (relative) this.offset += 4;
+        return this;
+    };
+
+    /**
+     * Writes a 32bit float. This is an alias of {@link ByteBuffer#writeFloat32}.
+     * @function
+     * @param {number} value Value to write
+     * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.writeFloat = ByteBufferPrototype.writeFloat32;
+
+    /**
+     * Reads a 32bit float.
+     * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
+     * @returns {number}
+     * @expose
+     */
+    ByteBufferPrototype.readFloat32 = function(offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 4 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+4+") <= "+this.buffer.byteLength);
+        }
+        var value = ieee754_read(this.view, offset, this.littleEndian, 23, 4);
+        if (relative) this.offset += 4;
+        return value;
+    };
+
+    /**
+     * Reads a 32bit float. This is an alias of {@link ByteBuffer#readFloat32}.
+     * @function
+     * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `4` if omitted.
+     * @returns {number}
+     * @expose
+     */
+    ByteBufferPrototype.readFloat = ByteBufferPrototype.readFloat32;
+
+    // types/floats/float64
+
+    /**
+     * Writes a 64bit float.
+     * @param {number} value Value to write
+     * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.writeFloat64 = function(value, offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof value !== 'number')
+                throw TypeError("Illegal value: "+value+" (not a number)");
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+        }
+        offset += 8;
+        var capacity9 = this.buffer.byteLength;
+        if (offset > capacity9)
+            this.resize((capacity9 *= 2) > offset ? capacity9 : offset);
+        offset -= 8;
+        ieee754_write(this.view, value, offset, this.littleEndian, 52, 8);
+        if (relative) this.offset += 8;
+        return this;
+    };
+
+    /**
+     * Writes a 64bit float. This is an alias of {@link ByteBuffer#writeFloat64}.
+     * @function
+     * @param {number} value Value to write
+     * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.writeDouble = ByteBufferPrototype.writeFloat64;
+
+    /**
+     * Reads a 64bit float.
+     * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
+     * @returns {number}
+     * @expose
+     */
+    ByteBufferPrototype.readFloat64 = function(offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 8 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+8+") <= "+this.buffer.byteLength);
+        }
+        var value = ieee754_read(this.view, offset, this.littleEndian, 52, 8);
+        if (relative) this.offset += 8;
+        return value;
+    };
+
+    /**
+     * Reads a 64bit float. This is an alias of {@link ByteBuffer#readFloat64}.
+     * @function
+     * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by `8` if omitted.
+     * @returns {number}
+     * @expose
+     */
+    ByteBufferPrototype.readDouble = ByteBufferPrototype.readFloat64;
+
+
+    // types/varints/varint32
+
+    /**
+     * Maximum number of bytes required to store a 32bit base 128 variable-length integer.
+     * @type {number}
+     * @const
+     * @expose
+     */
+    ByteBuffer.MAX_VARINT32_BYTES = 5;
+
+    /**
+     * Calculates the actual number of bytes required to store a 32bit base 128 variable-length integer.
+     * @param {number} value Value to encode
+     * @returns {number} Number of bytes required. Capped to {@link ByteBuffer.MAX_VARINT32_BYTES}
+     * @expose
+     */
+    ByteBuffer.calculateVarint32 = function(value) {
+        // ref: src/google/protobuf/io/coded_stream.cc
+        value = value >>> 0;
+             if (value < 1 << 7 ) return 1;
+        else if (value < 1 << 14) return 2;
+        else if (value < 1 << 21) return 3;
+        else if (value < 1 << 28) return 4;
+        else                      return 5;
+    };
+
+    /**
+     * Zigzag encodes a signed 32bit integer so that it can be effectively used with varint encoding.
+     * @param {number} n Signed 32bit integer
+     * @returns {number} Unsigned zigzag encoded 32bit integer
+     * @expose
+     */
+    ByteBuffer.zigZagEncode32 = function(n) {
+        return (((n |= 0) << 1) ^ (n >> 31)) >>> 0; // ref: src/google/protobuf/wire_format_lite.h
+    };
+
+    /**
+     * Decodes a zigzag encoded signed 32bit integer.
+     * @param {number} n Unsigned zigzag encoded 32bit integer
+     * @returns {number} Signed 32bit integer
+     * @expose
+     */
+    ByteBuffer.zigZagDecode32 = function(n) {
+        return ((n >>> 1) ^ -(n & 1)) | 0; // // ref: src/google/protobuf/wire_format_lite.h
+    };
+
+    /**
+     * Writes a 32bit base 128 variable-length integer.
+     * @param {number} value Value to write
+     * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+     *  written if omitted.
+     * @returns {!ByteBuffer|number} this if `offset` is omitted, else the actual number of bytes written
+     * @expose
+     */
+    ByteBufferPrototype.writeVarint32 = function(value, offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof value !== 'number' || value % 1 !== 0)
+                throw TypeError("Illegal value: "+value+" (not an integer)");
+            value |= 0;
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+        }
+        var size = ByteBuffer.calculateVarint32(value),
+            b;
+        offset += size;
+        var capacity10 = this.buffer.byteLength;
+        if (offset > capacity10)
+            this.resize((capacity10 *= 2) > offset ? capacity10 : offset);
+        offset -= size;
+        value >>>= 0;
+        while (value >= 0x80) {
+            b = (value & 0x7f) | 0x80;
+            this.view[offset++] = b;
+            value >>>= 7;
+        }
+        this.view[offset++] = value;
+        if (relative) {
+            this.offset = offset;
+            return this;
+        }
+        return size;
+    };
+
+    /**
+     * Writes a zig-zag encoded (signed) 32bit base 128 variable-length integer.
+     * @param {number} value Value to write
+     * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+     *  written if omitted.
+     * @returns {!ByteBuffer|number} this if `offset` is omitted, else the actual number of bytes written
+     * @expose
+     */
+    ByteBufferPrototype.writeVarint32ZigZag = function(value, offset) {
+        return this.writeVarint32(ByteBuffer.zigZagEncode32(value), offset);
+    };
+
+    /**
+     * Reads a 32bit base 128 variable-length integer.
+     * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+     *  written if omitted.
+     * @returns {number|!{value: number, length: number}} The value read if offset is omitted, else the value read
+     *  and the actual number of bytes read.
+     * @throws {Error} If it's not a valid varint. Has a property `truncated = true` if there is not enough data available
+     *  to fully decode the varint.
+     * @expose
+     */
+    ByteBufferPrototype.readVarint32 = function(offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 1 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+1+") <= "+this.buffer.byteLength);
+        }
+        var c = 0,
+            value = 0 >>> 0,
+            b;
+        do {
+            if (!this.noAssert && offset > this.limit) {
+                var err = Error("Truncated");
+                err['truncated'] = true;
+                throw err;
+            }
+            b = this.view[offset++];
+            if (c < 5)
+                value |= (b & 0x7f) << (7*c);
+            ++c;
+        } while ((b & 0x80) !== 0);
+        value |= 0;
+        if (relative) {
+            this.offset = offset;
+            return value;
+        }
+        return {
+            "value": value,
+            "length": c
+        };
+    };
+
+    /**
+     * Reads a zig-zag encoded (signed) 32bit base 128 variable-length integer.
+     * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+     *  written if omitted.
+     * @returns {number|!{value: number, length: number}} The value read if offset is omitted, else the value read
+     *  and the actual number of bytes read.
+     * @throws {Error} If it's not a valid varint
+     * @expose
+     */
+    ByteBufferPrototype.readVarint32ZigZag = function(offset) {
+        var val = this.readVarint32(offset);
+        if (typeof val === 'object')
+            val["value"] = ByteBuffer.zigZagDecode32(val["value"]);
+        else
+            val = ByteBuffer.zigZagDecode32(val);
+        return val;
+    };
+
+    // types/varints/varint64
+
+    if (Long) {
+
+        /**
+         * Maximum number of bytes required to store a 64bit base 128 variable-length integer.
+         * @type {number}
+         * @const
+         * @expose
+         */
+        ByteBuffer.MAX_VARINT64_BYTES = 10;
+
+        /**
+         * Calculates the actual number of bytes required to store a 64bit base 128 variable-length integer.
+         * @param {number|!Long} value Value to encode
+         * @returns {number} Number of bytes required. Capped to {@link ByteBuffer.MAX_VARINT64_BYTES}
+         * @expose
+         */
+        ByteBuffer.calculateVarint64 = function(value) {
+            if (typeof value === 'number')
+                value = Long.fromNumber(value);
+            else if (typeof value === 'string')
+                value = Long.fromString(value);
+            // ref: src/google/protobuf/io/coded_stream.cc
+            var part0 = value.toInt() >>> 0,
+                part1 = value.shiftRightUnsigned(28).toInt() >>> 0,
+                part2 = value.shiftRightUnsigned(56).toInt() >>> 0;
+            if (part2 == 0) {
+                if (part1 == 0) {
+                    if (part0 < 1 << 14)
+                        return part0 < 1 << 7 ? 1 : 2;
+                    else
+                        return part0 < 1 << 21 ? 3 : 4;
+                } else {
+                    if (part1 < 1 << 14)
+                        return part1 < 1 << 7 ? 5 : 6;
+                    else
+                        return part1 < 1 << 21 ? 7 : 8;
+                }
+            } else
+                return part2 < 1 << 7 ? 9 : 10;
+        };
+
+        /**
+         * Zigzag encodes a signed 64bit integer so that it can be effectively used with varint encoding.
+         * @param {number|!Long} value Signed long
+         * @returns {!Long} Unsigned zigzag encoded long
+         * @expose
+         */
+        ByteBuffer.zigZagEncode64 = function(value) {
+            if (typeof value === 'number')
+                value = Long.fromNumber(value, false);
+            else if (typeof value === 'string')
+                value = Long.fromString(value, false);
+            else if (value.unsigned !== false) value = value.toSigned();
+            // ref: src/google/protobuf/wire_format_lite.h
+            return value.shiftLeft(1).xor(value.shiftRight(63)).toUnsigned();
+        };
+
+        /**
+         * Decodes a zigzag encoded signed 64bit integer.
+         * @param {!Long|number} value Unsigned zigzag encoded long or JavaScript number
+         * @returns {!Long} Signed long
+         * @expose
+         */
+        ByteBuffer.zigZagDecode64 = function(value) {
+            if (typeof value === 'number')
+                value = Long.fromNumber(value, false);
+            else if (typeof value === 'string')
+                value = Long.fromString(value, false);
+            else if (value.unsigned !== false) value = value.toSigned();
+            // ref: src/google/protobuf/wire_format_lite.h
+            return value.shiftRightUnsigned(1).xor(value.and(Long.ONE).toSigned().negate()).toSigned();
+        };
+
+        /**
+         * Writes a 64bit base 128 variable-length integer.
+         * @param {number|Long} value Value to write
+         * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+         *  written if omitted.
+         * @returns {!ByteBuffer|number} `this` if offset is omitted, else the actual number of bytes written.
+         * @expose
+         */
+        ByteBufferPrototype.writeVarint64 = function(value, offset) {
+            var relative = typeof offset === 'undefined';
+            if (relative) offset = this.offset;
+            if (!this.noAssert) {
+                if (typeof value === 'number')
+                    value = Long.fromNumber(value);
+                else if (typeof value === 'string')
+                    value = Long.fromString(value);
+                else if (!(value && value instanceof Long))
+                    throw TypeError("Illegal value: "+value+" (not an integer or Long)");
+                if (typeof offset !== 'number' || offset % 1 !== 0)
+                    throw TypeError("Illegal offset: "+offset+" (not an integer)");
+                offset >>>= 0;
+                if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                    throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+            }
+            if (typeof value === 'number')
+                value = Long.fromNumber(value, false);
+            else if (typeof value === 'string')
+                value = Long.fromString(value, false);
+            else if (value.unsigned !== false) value = value.toSigned();
+            var size = ByteBuffer.calculateVarint64(value),
+                part0 = value.toInt() >>> 0,
+                part1 = value.shiftRightUnsigned(28).toInt() >>> 0,
+                part2 = value.shiftRightUnsigned(56).toInt() >>> 0;
+            offset += size;
+            var capacity11 = this.buffer.byteLength;
+            if (offset > capacity11)
+                this.resize((capacity11 *= 2) > offset ? capacity11 : offset);
+            offset -= size;
+            switch (size) {
+                case 10: this.view[offset+9] = (part2 >>>  7) & 0x01;
+                case 9 : this.view[offset+8] = size !== 9 ? (part2       ) | 0x80 : (part2       ) & 0x7F;
+                case 8 : this.view[offset+7] = size !== 8 ? (part1 >>> 21) | 0x80 : (part1 >>> 21) & 0x7F;
+                case 7 : this.view[offset+6] = size !== 7 ? (part1 >>> 14) | 0x80 : (part1 >>> 14) & 0x7F;
+                case 6 : this.view[offset+5] = size !== 6 ? (part1 >>>  7) | 0x80 : (part1 >>>  7) & 0x7F;
+                case 5 : this.view[offset+4] = size !== 5 ? (part1       ) | 0x80 : (part1       ) & 0x7F;
+                case 4 : this.view[offset+3] = size !== 4 ? (part0 >>> 21) | 0x80 : (part0 >>> 21) & 0x7F;
+                case 3 : this.view[offset+2] = size !== 3 ? (part0 >>> 14) | 0x80 : (part0 >>> 14) & 0x7F;
+                case 2 : this.view[offset+1] = size !== 2 ? (part0 >>>  7) | 0x80 : (part0 >>>  7) & 0x7F;
+                case 1 : this.view[offset  ] = size !== 1 ? (part0       ) | 0x80 : (part0       ) & 0x7F;
+            }
+            if (relative) {
+                this.offset += size;
+                return this;
+            } else {
+                return size;
+            }
+        };
+
+        /**
+         * Writes a zig-zag encoded 64bit base 128 variable-length integer.
+         * @param {number|Long} value Value to write
+         * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+         *  written if omitted.
+         * @returns {!ByteBuffer|number} `this` if offset is omitted, else the actual number of bytes written.
+         * @expose
+         */
+        ByteBufferPrototype.writeVarint64ZigZag = function(value, offset) {
+            return this.writeVarint64(ByteBuffer.zigZagEncode64(value), offset);
+        };
+
+        /**
+         * Reads a 64bit base 128 variable-length integer. Requires Long.js.
+         * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+         *  read if omitted.
+         * @returns {!Long|!{value: Long, length: number}} The value read if offset is omitted, else the value read and
+         *  the actual number of bytes read.
+         * @throws {Error} If it's not a valid varint
+         * @expose
+         */
+        ByteBufferPrototype.readVarint64 = function(offset) {
+            var relative = typeof offset === 'undefined';
+            if (relative) offset = this.offset;
+            if (!this.noAssert) {
+                if (typeof offset !== 'number' || offset % 1 !== 0)
+                    throw TypeError("Illegal offset: "+offset+" (not an integer)");
+                offset >>>= 0;
+                if (offset < 0 || offset + 1 > this.buffer.byteLength)
+                    throw RangeError("Illegal offset: 0 <= "+offset+" (+"+1+") <= "+this.buffer.byteLength);
+            }
+            // ref: src/google/protobuf/io/coded_stream.cc
+            var start = offset,
+                part0 = 0,
+                part1 = 0,
+                part2 = 0,
+                b  = 0;
+            b = this.view[offset++]; part0  = (b & 0x7F)      ; if ( b & 0x80                                                   ) {
+            b = this.view[offset++]; part0 |= (b & 0x7F) <<  7; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) {
+            b = this.view[offset++]; part0 |= (b & 0x7F) << 14; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) {
+            b = this.view[offset++]; part0 |= (b & 0x7F) << 21; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) {
+            b = this.view[offset++]; part1  = (b & 0x7F)      ; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) {
+            b = this.view[offset++]; part1 |= (b & 0x7F) <<  7; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) {
+            b = this.view[offset++]; part1 |= (b & 0x7F) << 14; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) {
+            b = this.view[offset++]; part1 |= (b & 0x7F) << 21; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) {
+            b = this.view[offset++]; part2  = (b & 0x7F)      ; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) {
+            b = this.view[offset++]; part2 |= (b & 0x7F) <<  7; if ((b & 0x80) || (this.noAssert && typeof b === 'undefined')) {
+            throw Error("Buffer overrun"); }}}}}}}}}}
+            var value = Long.fromBits(part0 | (part1 << 28), (part1 >>> 4) | (part2) << 24, false);
+            if (relative) {
+                this.offset = offset;
+                return value;
+            } else {
+                return {
+                    'value': value,
+                    'length': offset-start
+                };
+            }
+        };
+
+        /**
+         * Reads a zig-zag encoded 64bit base 128 variable-length integer. Requires Long.js.
+         * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+         *  read if omitted.
+         * @returns {!Long|!{value: Long, length: number}} The value read if offset is omitted, else the value read and
+         *  the actual number of bytes read.
+         * @throws {Error} If it's not a valid varint
+         * @expose
+         */
+        ByteBufferPrototype.readVarint64ZigZag = function(offset) {
+            var val = this.readVarint64(offset);
+            if (val && val['value'] instanceof Long)
+                val["value"] = ByteBuffer.zigZagDecode64(val["value"]);
+            else
+                val = ByteBuffer.zigZagDecode64(val);
+            return val;
+        };
+
+    } // Long
+
+
+    // types/strings/cstring
+
+    /**
+     * Writes a NULL-terminated UTF8 encoded string. For this to work the specified string must not contain any NULL
+     *  characters itself.
+     * @param {string} str String to write
+     * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+     *  contained in `str` + 1 if omitted.
+     * @returns {!ByteBuffer|number} this if offset is omitted, else the actual number of bytes written
+     * @expose
+     */
+    ByteBufferPrototype.writeCString = function(str, offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        var i,
+            k = str.length;
+        if (!this.noAssert) {
+            if (typeof str !== 'string')
+                throw TypeError("Illegal str: Not a string");
+            for (i=0; i<k; ++i) {
+                if (str.charCodeAt(i) === 0)
+                    throw RangeError("Illegal str: Contains NULL-characters");
+            }
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+        }
+        // UTF8 strings do not contain zero bytes in between except for the zero character, so:
+        k = utfx.calculateUTF16asUTF8(stringSource(str))[1];
+        offset += k+1;
+        var capacity12 = this.buffer.byteLength;
+        if (offset > capacity12)
+            this.resize((capacity12 *= 2) > offset ? capacity12 : offset);
+        offset -= k+1;
+        utfx.encodeUTF16toUTF8(stringSource(str), function(b) {
+            this.view[offset++] = b;
+        }.bind(this));
+        this.view[offset++] = 0;
+        if (relative) {
+            this.offset = offset;
+            return this;
+        }
+        return k;
+    };
+
+    /**
+     * Reads a NULL-terminated UTF8 encoded string. For this to work the string read must not contain any NULL characters
+     *  itself.
+     * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+     *  read if omitted.
+     * @returns {string|!{string: string, length: number}} The string read if offset is omitted, else the string
+     *  read and the actual number of bytes read.
+     * @expose
+     */
+    ByteBufferPrototype.readCString = function(offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 1 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+1+") <= "+this.buffer.byteLength);
+        }
+        var start = offset,
+            temp;
+        // UTF8 strings do not contain zero bytes in between except for the zero character itself, so:
+        var sd, b = -1;
+        utfx.decodeUTF8toUTF16(function() {
+            if (b === 0) return null;
+            if (offset >= this.limit)
+                throw RangeError("Illegal range: Truncated data, "+offset+" < "+this.limit);
+            b = this.view[offset++];
+            return b === 0 ? null : b;
+        }.bind(this), sd = stringDestination(), true);
+        if (relative) {
+            this.offset = offset;
+            return sd();
+        } else {
+            return {
+                "string": sd(),
+                "length": offset - start
+            };
+        }
+    };
+
+    // types/strings/istring
+
+    /**
+     * Writes a length as uint32 prefixed UTF8 encoded string.
+     * @param {string} str String to write
+     * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+     *  written if omitted.
+     * @returns {!ByteBuffer|number} `this` if `offset` is omitted, else the actual number of bytes written
+     * @expose
+     * @see ByteBuffer#writeVarint32
+     */
+    ByteBufferPrototype.writeIString = function(str, offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof str !== 'string')
+                throw TypeError("Illegal str: Not a string");
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+        }
+        var start = offset,
+            k;
+        k = utfx.calculateUTF16asUTF8(stringSource(str), this.noAssert)[1];
+        offset += 4+k;
+        var capacity13 = this.buffer.byteLength;
+        if (offset > capacity13)
+            this.resize((capacity13 *= 2) > offset ? capacity13 : offset);
+        offset -= 4+k;
+        if (this.littleEndian) {
+            this.view[offset+3] = (k >>> 24) & 0xFF;
+            this.view[offset+2] = (k >>> 16) & 0xFF;
+            this.view[offset+1] = (k >>>  8) & 0xFF;
+            this.view[offset  ] =  k         & 0xFF;
+        } else {
+            this.view[offset  ] = (k >>> 24) & 0xFF;
+            this.view[offset+1] = (k >>> 16) & 0xFF;
+            this.view[offset+2] = (k >>>  8) & 0xFF;
+            this.view[offset+3] =  k         & 0xFF;
+        }
+        offset += 4;
+        utfx.encodeUTF16toUTF8(stringSource(str), function(b) {
+            this.view[offset++] = b;
+        }.bind(this));
+        if (offset !== start + 4 + k)
+            throw RangeError("Illegal range: Truncated data, "+offset+" == "+(offset+4+k));
+        if (relative) {
+            this.offset = offset;
+            return this;
+        }
+        return offset - start;
+    };
+
+    /**
+     * Reads a length as uint32 prefixed UTF8 encoded string.
+     * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+     *  read if omitted.
+     * @returns {string|!{string: string, length: number}} The string read if offset is omitted, else the string
+     *  read and the actual number of bytes read.
+     * @expose
+     * @see ByteBuffer#readVarint32
+     */
+    ByteBufferPrototype.readIString = function(offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 4 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+4+") <= "+this.buffer.byteLength);
+        }
+        var start = offset;
+        var len = this.readUint32(offset);
+        var str = this.readUTF8String(len, ByteBuffer.METRICS_BYTES, offset += 4);
+        offset += str['length'];
+        if (relative) {
+            this.offset = offset;
+            return str['string'];
+        } else {
+            return {
+                'string': str['string'],
+                'length': offset - start
+            };
+        }
+    };
+
+    // types/strings/utf8string
+
+    /**
+     * Metrics representing number of UTF8 characters. Evaluates to `c`.
+     * @type {string}
+     * @const
+     * @expose
+     */
+    ByteBuffer.METRICS_CHARS = 'c';
+
+    /**
+     * Metrics representing number of bytes. Evaluates to `b`.
+     * @type {string}
+     * @const
+     * @expose
+     */
+    ByteBuffer.METRICS_BYTES = 'b';
+
+    /**
+     * Writes an UTF8 encoded string.
+     * @param {string} str String to write
+     * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} if omitted.
+     * @returns {!ByteBuffer|number} this if offset is omitted, else the actual number of bytes written.
+     * @expose
+     */
+    ByteBufferPrototype.writeUTF8String = function(str, offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+        }
+        var k;
+        var start = offset;
+        k = utfx.calculateUTF16asUTF8(stringSource(str))[1];
+        offset += k;
+        var capacity14 = this.buffer.byteLength;
+        if (offset > capacity14)
+            this.resize((capacity14 *= 2) > offset ? capacity14 : offset);
+        offset -= k;
+        utfx.encodeUTF16toUTF8(stringSource(str), function(b) {
+            this.view[offset++] = b;
+        }.bind(this));
+        if (relative) {
+            this.offset = offset;
+            return this;
+        }
+        return offset - start;
+    };
+
+    /**
+     * Writes an UTF8 encoded string. This is an alias of {@link ByteBuffer#writeUTF8String}.
+     * @function
+     * @param {string} str String to write
+     * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} if omitted.
+     * @returns {!ByteBuffer|number} this if offset is omitted, else the actual number of bytes written.
+     * @expose
+     */
+    ByteBufferPrototype.writeString = ByteBufferPrototype.writeUTF8String;
+
+    /**
+     * Calculates the number of UTF8 characters of a string. JavaScript itself uses UTF-16, so that a string's
+     *  `length` property does not reflect its actual UTF8 size if it contains code points larger than 0xFFFF.
+     * @param {string} str String to calculate
+     * @returns {number} Number of UTF8 characters
+     * @expose
+     */
+    ByteBuffer.calculateUTF8Chars = function(str) {
+        return utfx.calculateUTF16asUTF8(stringSource(str))[0];
+    };
+
+    /**
+     * Calculates the number of UTF8 bytes of a string.
+     * @param {string} str String to calculate
+     * @returns {number} Number of UTF8 bytes
+     * @expose
+     */
+    ByteBuffer.calculateUTF8Bytes = function(str) {
+        return utfx.calculateUTF16asUTF8(stringSource(str))[1];
+    };
+
+    /**
+     * Calculates the number of UTF8 bytes of a string. This is an alias of {@link ByteBuffer.calculateUTF8Bytes}.
+     * @function
+     * @param {string} str String to calculate
+     * @returns {number} Number of UTF8 bytes
+     * @expose
+     */
+    ByteBuffer.calculateString = ByteBuffer.calculateUTF8Bytes;
+
+    /**
+     * Reads an UTF8 encoded string.
+     * @param {number} length Number of characters or bytes to read.
+     * @param {string=} metrics Metrics specifying what `length` is meant to count. Defaults to
+     *  {@link ByteBuffer.METRICS_CHARS}.
+     * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+     *  read if omitted.
+     * @returns {string|!{string: string, length: number}} The string read if offset is omitted, else the string
+     *  read and the actual number of bytes read.
+     * @expose
+     */
+    ByteBufferPrototype.readUTF8String = function(length, metrics, offset) {
+        if (typeof metrics === 'number') {
+            offset = metrics;
+            metrics = undefined;
+        }
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (typeof metrics === 'undefined') metrics = ByteBuffer.METRICS_CHARS;
+        if (!this.noAssert) {
+            if (typeof length !== 'number' || length % 1 !== 0)
+                throw TypeError("Illegal length: "+length+" (not an integer)");
+            length |= 0;
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+        }
+        var i = 0,
+            start = offset,
+            sd;
+        if (metrics === ByteBuffer.METRICS_CHARS) { // The same for node and the browser
+            sd = stringDestination();
+            utfx.decodeUTF8(function() {
+                return i < length && offset < this.limit ? this.view[offset++] : null;
+            }.bind(this), function(cp) {
+                ++i; utfx.UTF8toUTF16(cp, sd);
+            });
+            if (i !== length)
+                throw RangeError("Illegal range: Truncated data, "+i+" == "+length);
+            if (relative) {
+                this.offset = offset;
+                return sd();
+            } else {
+                return {
+                    "string": sd(),
+                    "length": offset - start
+                };
+            }
+        } else if (metrics === ByteBuffer.METRICS_BYTES) {
+            if (!this.noAssert) {
+                if (typeof offset !== 'number' || offset % 1 !== 0)
+                    throw TypeError("Illegal offset: "+offset+" (not an integer)");
+                offset >>>= 0;
+                if (offset < 0 || offset + length > this.buffer.byteLength)
+                    throw RangeError("Illegal offset: 0 <= "+offset+" (+"+length+") <= "+this.buffer.byteLength);
+            }
+            var k = offset + length;
+            utfx.decodeUTF8toUTF16(function() {
+                return offset < k ? this.view[offset++] : null;
+            }.bind(this), sd = stringDestination(), this.noAssert);
+            if (offset !== k)
+                throw RangeError("Illegal range: Truncated data, "+offset+" == "+k);
+            if (relative) {
+                this.offset = offset;
+                return sd();
+            } else {
+                return {
+                    'string': sd(),
+                    'length': offset - start
+                };
+            }
+        } else
+            throw TypeError("Unsupported metrics: "+metrics);
+    };
+
+    /**
+     * Reads an UTF8 encoded string. This is an alias of {@link ByteBuffer#readUTF8String}.
+     * @function
+     * @param {number} length Number of characters or bytes to read
+     * @param {number=} metrics Metrics specifying what `n` is meant to count. Defaults to
+     *  {@link ByteBuffer.METRICS_CHARS}.
+     * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+     *  read if omitted.
+     * @returns {string|!{string: string, length: number}} The string read if offset is omitted, else the string
+     *  read and the actual number of bytes read.
+     * @expose
+     */
+    ByteBufferPrototype.readString = ByteBufferPrototype.readUTF8String;
+
+    // types/strings/vstring
+
+    /**
+     * Writes a length as varint32 prefixed UTF8 encoded string.
+     * @param {string} str String to write
+     * @param {number=} offset Offset to write to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+     *  written if omitted.
+     * @returns {!ByteBuffer|number} `this` if `offset` is omitted, else the actual number of bytes written
+     * @expose
+     * @see ByteBuffer#writeVarint32
+     */
+    ByteBufferPrototype.writeVString = function(str, offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof str !== 'string')
+                throw TypeError("Illegal str: Not a string");
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+        }
+        var start = offset,
+            k, l;
+        k = utfx.calculateUTF16asUTF8(stringSource(str), this.noAssert)[1];
+        l = ByteBuffer.calculateVarint32(k);
+        offset += l+k;
+        var capacity15 = this.buffer.byteLength;
+        if (offset > capacity15)
+            this.resize((capacity15 *= 2) > offset ? capacity15 : offset);
+        offset -= l+k;
+        offset += this.writeVarint32(k, offset);
+        utfx.encodeUTF16toUTF8(stringSource(str), function(b) {
+            this.view[offset++] = b;
+        }.bind(this));
+        if (offset !== start+k+l)
+            throw RangeError("Illegal range: Truncated data, "+offset+" == "+(offset+k+l));
+        if (relative) {
+            this.offset = offset;
+            return this;
+        }
+        return offset - start;
+    };
+
+    /**
+     * Reads a length as varint32 prefixed UTF8 encoded string.
+     * @param {number=} offset Offset to read from. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+     *  read if omitted.
+     * @returns {string|!{string: string, length: number}} The string read if offset is omitted, else the string
+     *  read and the actual number of bytes read.
+     * @expose
+     * @see ByteBuffer#readVarint32
+     */
+    ByteBufferPrototype.readVString = function(offset) {
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 1 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+1+") <= "+this.buffer.byteLength);
+        }
+        var start = offset;
+        var len = this.readVarint32(offset);
+        var str = this.readUTF8String(len['value'], ByteBuffer.METRICS_BYTES, offset += len['length']);
+        offset += str['length'];
+        if (relative) {
+            this.offset = offset;
+            return str['string'];
+        } else {
+            return {
+                'string': str['string'],
+                'length': offset - start
+            };
+        }
+    };
+
+
+    /**
+     * Appends some data to this ByteBuffer. This will overwrite any contents behind the specified offset up to the appended
+     *  data's length.
+     * @param {!ByteBuffer|!ArrayBuffer|!Uint8Array|string} source Data to append. If `source` is a ByteBuffer, its offsets
+     *  will be modified according to the performed read operation.
+     * @param {(string|number)=} encoding Encoding if `data` is a string ("base64", "hex", "binary", defaults to "utf8")
+     * @param {number=} offset Offset to append at. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+     *  written if omitted.
+     * @returns {!ByteBuffer} this
+     * @expose
+     * @example A relative `<01 02>03.append(<04 05>)` will result in `<01 02 04 05>, 04 05|`
+     * @example An absolute `<01 02>03.append(04 05>, 1)` will result in `<01 04>05, 04 05|`
+     */
+    ByteBufferPrototype.append = function(source, encoding, offset) {
+        if (typeof encoding === 'number' || typeof encoding !== 'string') {
+            offset = encoding;
+            encoding = undefined;
+        }
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+        }
+        if (!(source instanceof ByteBuffer))
+            source = ByteBuffer.wrap(source, encoding);
+        var length = source.limit - source.offset;
+        if (length <= 0) return this; // Nothing to append
+        offset += length;
+        var capacity16 = this.buffer.byteLength;
+        if (offset > capacity16)
+            this.resize((capacity16 *= 2) > offset ? capacity16 : offset);
+        offset -= length;
+        this.view.set(source.view.subarray(source.offset, source.limit), offset);
+        source.offset += length;
+        if (relative) this.offset += length;
+        return this;
+    };
+
+    /**
+     * Appends this ByteBuffer's contents to another ByteBuffer. This will overwrite any contents at and after the
+        specified offset up to the length of this ByteBuffer's data.
+     * @param {!ByteBuffer} target Target ByteBuffer
+     * @param {number=} offset Offset to append to. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+     *  read if omitted.
+     * @returns {!ByteBuffer} this
+     * @expose
+     * @see ByteBuffer#append
+     */
+    ByteBufferPrototype.appendTo = function(target, offset) {
+        target.append(this, offset);
+        return this;
+    };
+
+    /**
+     * Enables or disables assertions of argument types and offsets. Assertions are enabled by default but you can opt to
+     *  disable them if your code already makes sure that everything is valid.
+     * @param {boolean} assert `true` to enable assertions, otherwise `false`
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.assert = function(assert) {
+        this.noAssert = !assert;
+        return this;
+    };
+
+    /**
+     * Gets the capacity of this ByteBuffer's backing buffer.
+     * @returns {number} Capacity of the backing buffer
+     * @expose
+     */
+    ByteBufferPrototype.capacity = function() {
+        return this.buffer.byteLength;
+    };
+    /**
+     * Clears this ByteBuffer's offsets by setting {@link ByteBuffer#offset} to `0` and {@link ByteBuffer#limit} to the
+     *  backing buffer's capacity. Discards {@link ByteBuffer#markedOffset}.
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.clear = function() {
+        this.offset = 0;
+        this.limit = this.buffer.byteLength;
+        this.markedOffset = -1;
+        return this;
+    };
+
+    /**
+     * Creates a cloned instance of this ByteBuffer, preset with this ByteBuffer's values for {@link ByteBuffer#offset},
+     *  {@link ByteBuffer#markedOffset} and {@link ByteBuffer#limit}.
+     * @param {boolean=} copy Whether to copy the backing buffer or to return another view on the same, defaults to `false`
+     * @returns {!ByteBuffer} Cloned instance
+     * @expose
+     */
+    ByteBufferPrototype.clone = function(copy) {
+        var bb = new ByteBuffer(0, this.littleEndian, this.noAssert);
+        if (copy) {
+            bb.buffer = new ArrayBuffer(this.buffer.byteLength);
+            bb.view = new Uint8Array(bb.buffer);
+        } else {
+            bb.buffer = this.buffer;
+            bb.view = this.view;
+        }
+        bb.offset = this.offset;
+        bb.markedOffset = this.markedOffset;
+        bb.limit = this.limit;
+        return bb;
+    };
+
+    /**
+     * Compacts this ByteBuffer to be backed by a {@link ByteBuffer#buffer} of its contents' length. Contents are the bytes
+     *  between {@link ByteBuffer#offset} and {@link ByteBuffer#limit}. Will set `offset = 0` and `limit = capacity` and
+     *  adapt {@link ByteBuffer#markedOffset} to the same relative position if set.
+     * @param {number=} begin Offset to start at, defaults to {@link ByteBuffer#offset}
+     * @param {number=} end Offset to end at, defaults to {@link ByteBuffer#limit}
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.compact = function(begin, end) {
+        if (typeof begin === 'undefined') begin = this.offset;
+        if (typeof end === 'undefined') end = this.limit;
+        if (!this.noAssert) {
+            if (typeof begin !== 'number' || begin % 1 !== 0)
+                throw TypeError("Illegal begin: Not an integer");
+            begin >>>= 0;
+            if (typeof end !== 'number' || end % 1 !== 0)
+                throw TypeError("Illegal end: Not an integer");
+            end >>>= 0;
+            if (begin < 0 || begin > end || end > this.buffer.byteLength)
+                throw RangeError("Illegal range: 0 <= "+begin+" <= "+end+" <= "+this.buffer.byteLength);
+        }
+        if (begin === 0 && end === this.buffer.byteLength)
+            return this; // Already compacted
+        var len = end - begin;
+        if (len === 0) {
+            this.buffer = EMPTY_BUFFER;
+            this.view = null;
+            if (this.markedOffset >= 0) this.markedOffset -= begin;
+            this.offset = 0;
+            this.limit = 0;
+            return this;
+        }
+        var buffer = new ArrayBuffer(len);
+        var view = new Uint8Array(buffer);
+        view.set(this.view.subarray(begin, end));
+        this.buffer = buffer;
+        this.view = view;
+        if (this.markedOffset >= 0) this.markedOffset -= begin;
+        this.offset = 0;
+        this.limit = len;
+        return this;
+    };
+
+    /**
+     * Creates a copy of this ByteBuffer's contents. Contents are the bytes between {@link ByteBuffer#offset} and
+     *  {@link ByteBuffer#limit}.
+     * @param {number=} begin Begin offset, defaults to {@link ByteBuffer#offset}.
+     * @param {number=} end End offset, defaults to {@link ByteBuffer#limit}.
+     * @returns {!ByteBuffer} Copy
+     * @expose
+     */
+    ByteBufferPrototype.copy = function(begin, end) {
+        if (typeof begin === 'undefined') begin = this.offset;
+        if (typeof end === 'undefined') end = this.limit;
+        if (!this.noAssert) {
+            if (typeof begin !== 'number' || begin % 1 !== 0)
+                throw TypeError("Illegal begin: Not an integer");
+            begin >>>= 0;
+            if (typeof end !== 'number' || end % 1 !== 0)
+                throw TypeError("Illegal end: Not an integer");
+            end >>>= 0;
+            if (begin < 0 || begin > end || end > this.buffer.byteLength)
+                throw RangeError("Illegal range: 0 <= "+begin+" <= "+end+" <= "+this.buffer.byteLength);
+        }
+        if (begin === end)
+            return new ByteBuffer(0, this.littleEndian, this.noAssert);
+        var capacity = end - begin,
+            bb = new ByteBuffer(capacity, this.littleEndian, this.noAssert);
+        bb.offset = 0;
+        bb.limit = capacity;
+        if (bb.markedOffset >= 0) bb.markedOffset -= begin;
+        this.copyTo(bb, 0, begin, end);
+        return bb;
+    };
+
+    /**
+     * Copies this ByteBuffer's contents to another ByteBuffer. Contents are the bytes between {@link ByteBuffer#offset} and
+     *  {@link ByteBuffer#limit}.
+     * @param {!ByteBuffer} target Target ByteBuffer
+     * @param {number=} targetOffset Offset to copy to. Will use and increase the target's {@link ByteBuffer#offset}
+     *  by the number of bytes copied if omitted.
+     * @param {number=} sourceOffset Offset to start copying from. Will use and increase {@link ByteBuffer#offset} by the
+     *  number of bytes copied if omitted.
+     * @param {number=} sourceLimit Offset to end copying from, defaults to {@link ByteBuffer#limit}
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.copyTo = function(target, targetOffset, sourceOffset, sourceLimit) {
+        var relative,
+            targetRelative;
+        if (!this.noAssert) {
+            if (!ByteBuffer.isByteBuffer(target))
+                throw TypeError("Illegal target: Not a ByteBuffer");
+        }
+        targetOffset = (targetRelative = typeof targetOffset === 'undefined') ? target.offset : targetOffset | 0;
+        sourceOffset = (relative = typeof sourceOffset === 'undefined') ? this.offset : sourceOffset | 0;
+        sourceLimit = typeof sourceLimit === 'undefined' ? this.limit : sourceLimit | 0;
+
+        if (targetOffset < 0 || targetOffset > target.buffer.byteLength)
+            throw RangeError("Illegal target range: 0 <= "+targetOffset+" <= "+target.buffer.byteLength);
+        if (sourceOffset < 0 || sourceLimit > this.buffer.byteLength)
+            throw RangeError("Illegal source range: 0 <= "+sourceOffset+" <= "+this.buffer.byteLength);
+
+        var len = sourceLimit - sourceOffset;
+        if (len === 0)
+            return target; // Nothing to copy
+
+        target.ensureCapacity(targetOffset + len);
+
+        target.view.set(this.view.subarray(sourceOffset, sourceLimit), targetOffset);
+
+        if (relative) this.offset += len;
+        if (targetRelative) target.offset += len;
+
+        return this;
+    };
+
+    /**
+     * Makes sure that this ByteBuffer is backed by a {@link ByteBuffer#buffer} of at least the specified capacity. If the
+     *  current capacity is exceeded, it will be doubled. If double the current capacity is less than the required capacity,
+     *  the required capacity will be used instead.
+     * @param {number} capacity Required capacity
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.ensureCapacity = function(capacity) {
+        var current = this.buffer.byteLength;
+        if (current < capacity)
+            return this.resize((current *= 2) > capacity ? current : capacity);
+        return this;
+    };
+
+    /**
+     * Overwrites this ByteBuffer's contents with the specified value. Contents are the bytes between
+     *  {@link ByteBuffer#offset} and {@link ByteBuffer#limit}.
+     * @param {number|string} value Byte value to fill with. If given as a string, the first character is used.
+     * @param {number=} begin Begin offset. Will use and increase {@link ByteBuffer#offset} by the number of bytes
+     *  written if omitted. defaults to {@link ByteBuffer#offset}.
+     * @param {number=} end End offset, defaults to {@link ByteBuffer#limit}.
+     * @returns {!ByteBuffer} this
+     * @expose
+     * @example `someByteBuffer.clear().fill(0)` fills the entire backing buffer with zeroes
+     */
+    ByteBufferPrototype.fill = function(value, begin, end) {
+        var relative = typeof begin === 'undefined';
+        if (relative) begin = this.offset;
+        if (typeof value === 'string' && value.length > 0)
+            value = value.charCodeAt(0);
+        if (typeof begin === 'undefined') begin = this.offset;
+        if (typeof end === 'undefined') end = this.limit;
+        if (!this.noAssert) {
+            if (typeof value !== 'number' || value % 1 !== 0)
+                throw TypeError("Illegal value: "+value+" (not an integer)");
+            value |= 0;
+            if (typeof begin !== 'number' || begin % 1 !== 0)
+                throw TypeError("Illegal begin: Not an integer");
+            begin >>>= 0;
+            if (typeof end !== 'number' || end % 1 !== 0)
+                throw TypeError("Illegal end: Not an integer");
+            end >>>= 0;
+            if (begin < 0 || begin > end || end > this.buffer.byteLength)
+                throw RangeError("Illegal range: 0 <= "+begin+" <= "+end+" <= "+this.buffer.byteLength);
+        }
+        if (begin >= end)
+            return this; // Nothing to fill
+        while (begin < end) this.view[begin++] = value;
+        if (relative) this.offset = begin;
+        return this;
+    };
+
+    /**
+     * Makes this ByteBuffer ready for a new sequence of write or relative read operations. Sets `limit = offset` and
+     *  `offset = 0`. Make sure always to flip a ByteBuffer when all relative read or write operations are complete.
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.flip = function() {
+        this.limit = this.offset;
+        this.offset = 0;
+        return this;
+    };
+    /**
+     * Marks an offset on this ByteBuffer to be used later.
+     * @param {number=} offset Offset to mark. Defaults to {@link ByteBuffer#offset}.
+     * @returns {!ByteBuffer} this
+     * @throws {TypeError} If `offset` is not a valid number
+     * @throws {RangeError} If `offset` is out of bounds
+     * @see ByteBuffer#reset
+     * @expose
+     */
+    ByteBufferPrototype.mark = function(offset) {
+        offset = typeof offset === 'undefined' ? this.offset : offset;
+        if (!this.noAssert) {
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+        }
+        this.markedOffset = offset;
+        return this;
+    };
+    /**
+     * Sets the byte order.
+     * @param {boolean} littleEndian `true` for little endian byte order, `false` for big endian
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.order = function(littleEndian) {
+        if (!this.noAssert) {
+            if (typeof littleEndian !== 'boolean')
+                throw TypeError("Illegal littleEndian: Not a boolean");
+        }
+        this.littleEndian = !!littleEndian;
+        return this;
+    };
+
+    /**
+     * Switches (to) little endian byte order.
+     * @param {boolean=} littleEndian Defaults to `true`, otherwise uses big endian
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.LE = function(littleEndian) {
+        this.littleEndian = typeof littleEndian !== 'undefined' ? !!littleEndian : true;
+        return this;
+    };
+
+    /**
+     * Switches (to) big endian byte order.
+     * @param {boolean=} bigEndian Defaults to `true`, otherwise uses little endian
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.BE = function(bigEndian) {
+        this.littleEndian = typeof bigEndian !== 'undefined' ? !bigEndian : false;
+        return this;
+    };
+    /**
+     * Prepends some data to this ByteBuffer. This will overwrite any contents before the specified offset up to the
+     *  prepended data's length. If there is not enough space available before the specified `offset`, the backing buffer
+     *  will be resized and its contents moved accordingly.
+     * @param {!ByteBuffer|string|!ArrayBuffer} source Data to prepend. If `source` is a ByteBuffer, its offset will be
+     *  modified according to the performed read operation.
+     * @param {(string|number)=} encoding Encoding if `data` is a string ("base64", "hex", "binary", defaults to "utf8")
+     * @param {number=} offset Offset to prepend at. Will use and decrease {@link ByteBuffer#offset} by the number of bytes
+     *  prepended if omitted.
+     * @returns {!ByteBuffer} this
+     * @expose
+     * @example A relative `00<01 02 03>.prepend(<04 05>)` results in `<04 05 01 02 03>, 04 05|`
+     * @example An absolute `00<01 02 03>.prepend(<04 05>, 2)` results in `04<05 02 03>, 04 05|`
+     */
+    ByteBufferPrototype.prepend = function(source, encoding, offset) {
+        if (typeof encoding === 'number' || typeof encoding !== 'string') {
+            offset = encoding;
+            encoding = undefined;
+        }
+        var relative = typeof offset === 'undefined';
+        if (relative) offset = this.offset;
+        if (!this.noAssert) {
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: "+offset+" (not an integer)");
+            offset >>>= 0;
+            if (offset < 0 || offset + 0 > this.buffer.byteLength)
+                throw RangeError("Illegal offset: 0 <= "+offset+" (+"+0+") <= "+this.buffer.byteLength);
+        }
+        if (!(source instanceof ByteBuffer))
+            source = ByteBuffer.wrap(source, encoding);
+        var len = source.limit - source.offset;
+        if (len <= 0) return this; // Nothing to prepend
+        var diff = len - offset;
+        if (diff > 0) { // Not enough space before offset, so resize + move
+            var buffer = new ArrayBuffer(this.buffer.byteLength + diff);
+            var view = new Uint8Array(buffer);
+            view.set(this.view.subarray(offset, this.buffer.byteLength), len);
+            this.buffer = buffer;
+            this.view = view;
+            this.offset += diff;
+            if (this.markedOffset >= 0) this.markedOffset += diff;
+            this.limit += diff;
+            offset += diff;
+        } else {
+            var arrayView = new Uint8Array(this.buffer);
+        }
+        this.view.set(source.view.subarray(source.offset, source.limit), offset - len);
+
+        source.offset = source.limit;
+        if (relative)
+            this.offset -= len;
+        return this;
+    };
+
+    /**
+     * Prepends this ByteBuffer to another ByteBuffer. This will overwrite any contents before the specified offset up to the
+     *  prepended data's length. If there is not enough space available before the specified `offset`, the backing buffer
+     *  will be resized and its contents moved accordingly.
+     * @param {!ByteBuffer} target Target ByteBuffer
+     * @param {number=} offset Offset to prepend at. Will use and decrease {@link ByteBuffer#offset} by the number of bytes
+     *  prepended if omitted.
+     * @returns {!ByteBuffer} this
+     * @expose
+     * @see ByteBuffer#prepend
+     */
+    ByteBufferPrototype.prependTo = function(target, offset) {
+        target.prepend(this, offset);
+        return this;
+    };
+    /**
+     * Prints debug information about this ByteBuffer's contents.
+     * @param {function(string)=} out Output function to call, defaults to console.log
+     * @expose
+     */
+    ByteBufferPrototype.printDebug = function(out) {
+        if (typeof out !== 'function') out = console.log.bind(console);
+        out(
+            this.toString()+"\n"+
+            "-------------------------------------------------------------------\n"+
+            this.toDebug(/* columns */ true)
+        );
+    };
+
+    /**
+     * Gets the number of remaining readable bytes. Contents are the bytes between {@link ByteBuffer#offset} and
+     *  {@link ByteBuffer#limit}, so this returns `limit - offset`.
+     * @returns {number} Remaining readable bytes. May be negative if `offset > limit`.
+     * @expose
+     */
+    ByteBufferPrototype.remaining = function() {
+        return this.limit - this.offset;
+    };
+    /**
+     * Resets this ByteBuffer's {@link ByteBuffer#offset}. If an offset has been marked through {@link ByteBuffer#mark}
+     *  before, `offset` will be set to {@link ByteBuffer#markedOffset}, which will then be discarded. If no offset has been
+     *  marked, sets `offset = 0`.
+     * @returns {!ByteBuffer} this
+     * @see ByteBuffer#mark
+     * @expose
+     */
+    ByteBufferPrototype.reset = function() {
+        if (this.markedOffset >= 0) {
+            this.offset = this.markedOffset;
+            this.markedOffset = -1;
+        } else {
+            this.offset = 0;
+        }
+        return this;
+    };
+    /**
+     * Resizes this ByteBuffer to be backed by a buffer of at least the given capacity. Will do nothing if already that
+     *  large or larger.
+     * @param {number} capacity Capacity required
+     * @returns {!ByteBuffer} this
+     * @throws {TypeError} If `capacity` is not a number
+     * @throws {RangeError} If `capacity < 0`
+     * @expose
+     */
+    ByteBufferPrototype.resize = function(capacity) {
+        if (!this.noAssert) {
+            if (typeof capacity !== 'number' || capacity % 1 !== 0)
+                throw TypeError("Illegal capacity: "+capacity+" (not an integer)");
+            capacity |= 0;
+            if (capacity < 0)
+                throw RangeError("Illegal capacity: 0 <= "+capacity);
+        }
+        if (this.buffer.byteLength < capacity) {
+            var buffer = new ArrayBuffer(capacity);
+            var view = new Uint8Array(buffer);
+            view.set(this.view);
+            this.buffer = buffer;
+            this.view = view;
+        }
+        return this;
+    };
+    /**
+     * Reverses this ByteBuffer's contents.
+     * @param {number=} begin Offset to start at, defaults to {@link ByteBuffer#offset}
+     * @param {number=} end Offset to end at, defaults to {@link ByteBuffer#limit}
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.reverse = function(begin, end) {
+        if (typeof begin === 'undefined') begin = this.offset;
+        if (typeof end === 'undefined') end = this.limit;
+        if (!this.noAssert) {
+            if (typeof begin !== 'number' || begin % 1 !== 0)
+                throw TypeError("Illegal begin: Not an integer");
+            begin >>>= 0;
+            if (typeof end !== 'number' || end % 1 !== 0)
+                throw TypeError("Illegal end: Not an integer");
+            end >>>= 0;
+            if (begin < 0 || begin > end || end > this.buffer.byteLength)
+                throw RangeError("Illegal range: 0 <= "+begin+" <= "+end+" <= "+this.buffer.byteLength);
+        }
+        if (begin === end)
+            return this; // Nothing to reverse
+        Array.prototype.reverse.call(this.view.subarray(begin, end));
+        return this;
+    };
+    /**
+     * Skips the next `length` bytes. This will just advance
+     * @param {number} length Number of bytes to skip. May also be negative to move the offset back.
+     * @returns {!ByteBuffer} this
+     * @expose
+     */
+    ByteBufferPrototype.skip = function(length) {
+        if (!this.noAssert) {
+            if (typeof length !== 'number' || length % 1 !== 0)
+                throw TypeError("Illegal length: "+length+" (not an integer)");
+            length |= 0;
+        }
+        var offset = this.offset + length;
+        if (!this.noAssert) {
+            if (offset < 0 || offset > this.buffer.byteLength)
+                throw RangeError("Illegal length: 0 <= "+this.offset+" + "+length+" <= "+this.buffer.byteLength);
+        }
+        this.offset = offset;
+        return this;
+    };
+
+    /**
+     * Slices this ByteBuffer by creating a cloned instance with `offset = begin` and `limit = end`.
+     * @param {number=} begin Begin offset, defaults to {@link ByteBuffer#offset}.
+     * @param {number=} end End offset, defaults to {@link ByteBuffer#limit}.
+     * @returns {!ByteBuffer} Clone of this ByteBuffer with slicing applied, backed by the same {@link ByteBuffer#buffer}
+     * @expose
+     */
+    ByteBufferPrototype.slice = function(begin, end) {
+        if (typeof begin === 'undefined') begin = this.offset;
+        if (typeof end === 'undefined') end = this.limit;
+        if (!this.noAssert) {
+            if (typeof begin !== 'number' || begin % 1 !== 0)
+                throw TypeError("Illegal begin: Not an integer");
+            begin >>>= 0;
+            if (typeof end !== 'number' || end % 1 !== 0)
+                throw TypeError("Illegal end: Not an integer");
+            end >>>= 0;
+            if (begin < 0 || begin > end || end > this.buffer.byteLength)
+                throw RangeError("Illegal range: 0 <= "+begin+" <= "+end+" <= "+this.buffer.byteLength);
+        }
+        var bb = this.clone();
+        bb.offset = begin;
+        bb.limit = end;
+        return bb;
+    };
+    /**
+     * Returns a copy of the backing buffer that contains this ByteBuffer's contents. Contents are the bytes between
+     *  {@link ByteBuffer#offset} and {@link ByteBuffer#limit}.
+     * @param {boolean=} forceCopy If `true` returns a copy, otherwise returns a view referencing the same memory if
+     *  possible. Defaults to `false`
+     * @returns {!ArrayBuffer} Contents as an ArrayBuffer
+     * @expose
+     */
+    ByteBufferPrototype.toBuffer = function(forceCopy) {
+        var offset = this.offset,
+            limit = this.limit;
+        if (!this.noAssert) {
+            if (typeof offset !== 'number' || offset % 1 !== 0)
+                throw TypeError("Illegal offset: Not an integer");
+            offset >>>= 0;
+            if (typeof limit !== 'number' || limit % 1 !== 0)
+                throw TypeError("Illegal limit: Not an integer");
+            limit >>>= 0;
+            if (offset < 0 || offset > limit || limit > this.buffer.byteLength)
+                throw RangeError("Illegal range: 0 <= "+offset+" <= "+limit+" <= "+this.buffer.byteLength);
+        }
+        // NOTE: It's not possible to have another ArrayBuffer reference the same memory as the backing buffer. This is
+        // possible with Uint8Array#subarray only, but we have to return an ArrayBuffer by contract. So:
+        if (!forceCopy && offset === 0 && limit === this.buffer.byteLength)
+            return this.buffer;
+        if (offset === limit)
+            return EMPTY_BUFFER;
+        var buffer = new ArrayBuffer(limit - offset);
+        new Uint8Array(buffer).set(new Uint8Array(this.buffer).subarray(offset, limit), 0);
+        return buffer;
+    };
+
+    /**
+     * Returns a raw buffer compacted to contain this ByteBuffer's contents. Contents are the bytes between
+     *  {@link ByteBuffer#offset} and {@link ByteBuffer#limit}. This is an alias of {@link ByteBuffer#toBuffer}.
+     * @function
+     * @param {boolean=} forceCopy If `true` returns a copy, otherwise returns a view referencing the same memory.
+     *  Defaults to `false`
+     * @returns {!ArrayBuffer} Contents as an ArrayBuffer
+     * @expose
+     */
+    ByteBufferPrototype.toArrayBuffer = ByteBufferPrototype.toBuffer;
+
+    /**
+     * Converts the ByteBuffer's contents to a string.
+     * @param {string=} encoding Output encoding. Returns an informative string representation if omitted but also allows
+     *  direct conversion to "utf8", "hex", "base64" and "binary" encoding. "debug" returns a hex representation with
+     *  highlighted offsets.
+     * @param {number=} begin Offset to begin at, defaults to {@link ByteBuffer#offset}
+     * @param {number=} end Offset to end at, defaults to {@link ByteBuffer#limit}
+     * @returns {string} String representation
+     * @throws {Error} If `encoding` is invalid
+     * @expose
+     */
+    ByteBufferPrototype.toString = function(encoding, begin, end) {
+        if (typeof encoding === 'undefined')
+            return "ByteBufferAB(offset="+this.offset+",markedOffset="+this.markedOffset+",limit="+this.limit+",capacity="+this.capacity()+")";
+        if (typeof encoding === 'number')
+            encoding = "utf8",
+            begin = encoding,
+            end = begin;
+        switch (encoding) {
+            case "utf8":
+                return this.toUTF8(begin, end);
+            case "base64":
+                return this.toBase64(begin, end);
+            case "hex":
+                return this.toHex(begin, end);
+            case "binary":
+                return this.toBinary(begin, end);
+            case "debug":
+                return this.toDebug();
+            case "columns":
+                return this.toColumns();
+            default:
+                throw Error("Unsupported encoding: "+encoding);
+        }
+    };
+
+    // lxiv-embeddable
+
+    /**
+     * lxiv-embeddable (c) 2014 Daniel Wirtz <dcode@dcode.io>
+     * Released under the Apache License, Version 2.0
+     * see: https://github.com/dcodeIO/lxiv for details
+     */
+    var lxiv = function() {
+        "use strict";
+
+        /**
+         * lxiv namespace.
+         * @type {!Object.<string,*>}
+         * @exports lxiv
+         */
+        var lxiv = {};
+
+        /**
+         * Character codes for output.
+         * @type {!Array.<number>}
+         * @inner
+         */
+        var aout = [
+            65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
+            81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 97, 98, 99, 100, 101, 102,
+            103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118,
+            119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 47
+        ];
+
+        /**
+         * Character codes for input.
+         * @type {!Array.<number>}
+         * @inner
+         */
+        var ain = [];
+        for (var i=0, k=aout.length; i<k; ++i)
+            ain[aout[i]] = i;
+
+        /**
+         * Encodes bytes to base64 char codes.
+         * @param {!function():number|null} src Bytes source as a function returning the next byte respectively `null` if
+         *  there are no more bytes left.
+         * @param {!function(number)} dst Characters destination as a function successively called with each encoded char
+         *  code.
+         */
+        lxiv.encode = function(src, dst) {
+            var b, t;
+            while ((b = src()) !== null) {
+                dst(aout[(b>>2)&0x3f]);
+                t = (b&0x3)<<4;
+                if ((b = src()) !== null) {
+                    t |= (b>>4)&0xf;
+                    dst(aout[(t|((b>>4)&0xf))&0x3f]);
+                    t = (b&0xf)<<2;
+                    if ((b = src()) !== null)
+                        dst(aout[(t|((b>>6)&0x3))&0x3f]),
+                        dst(aout[b&0x3f]);
+                    else
+                        dst(aout[t&0x3f]),
+                        dst(61);
+                } else
+                    dst(aout[t&0x3f]),
+                    dst(61),
+                    dst(61);
+            }
+        };
+
+        /**
+         * Decodes base64 char codes to bytes.
+         * @param {!function():number|null} src Characters source as a function returning the next char code respectively
+         *  `null` if there are no more characters left.
+         * @param {!function(number)} dst Bytes destination as a function successively called with the next byte.
+         * @throws {Error} If a character code is invalid
+         */
+        lxiv.decode = function(src, dst) {
+            var c, t1, t2;
+            function fail(c) {
+                throw Error("Illegal character code: "+c);
+            }
+            while ((c = src()) !== null) {
+                t1 = ain[c];
+                if (typeof t1 === 'undefined') fail(c);
+                if ((c = src()) !== null) {
+                    t2 = ain[c];
+                    if (typeof t2 === 'undefined') fail(c);
+                    dst((t1<<2)>>>0|(t2&0x30)>>4);
+                    if ((c = src()) !== null) {
+                        t1 = ain[c];
+                        if (typeof t1 === 'undefined')
+                            if (c === 61) break; else fail(c);
+                        dst(((t2&0xf)<<4)>>>0|(t1&0x3c)>>2);
+                        if ((c = src()) !== null) {
+                            t2 = ain[c];
+                            if (typeof t2 === 'undefined')
+                                if (c === 61) break; else fail(c);
+                            dst(((t1&0x3)<<6)>>>0|t2);
+                        }
+                    }
+                }
+            }
+        };
+
+        /**
+         * Tests if a string is valid base64.
+         * @param {string} str String to test
+         * @returns {boolean} `true` if valid, otherwise `false`
+         */
+        lxiv.test = function(str) {
+            return /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(str);
+        };
+
+        return lxiv;
+    }();
+
+    // encodings/base64
+
+    /**
+     * Encodes this ByteBuffer's contents to a base64 encoded string.
+     * @param {number=} begin Offset to begin at, defaults to {@link ByteBuffer#offset}.
+     * @param {number=} end Offset to end at, defaults to {@link ByteBuffer#limit}.
+     * @returns {string} Base64 encoded string
+     * @throws {RangeError} If `begin` or `end` is out of bounds
+     * @expose
+     */
+    ByteBufferPrototype.toBase64 = function(begin, end) {
+        if (typeof begin === 'undefined')
+            begin = this.offset;
+        if (typeof end === 'undefined')
+            end = this.limit;
+        begin = begin | 0; end = end | 0;
+        if (begin < 0 || end > this.capacity || begin > end)
+            throw RangeError("begin, end");
+        var sd; lxiv.encode(function() {
+            return begin < end ? this.view[begin++] : null;
+        }.bind(this), sd = stringDestination());
+        return sd();
+    };
+
+    /**
+     * Decodes a base64 encoded string to a ByteBuffer.
+     * @param {string} str String to decode
+     * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to
+     *  {@link ByteBuffer.DEFAULT_ENDIAN}.
+     * @returns {!ByteBuffer} ByteBuffer
+     * @expose
+     */
+    ByteBuffer.fromBase64 = function(str, littleEndian) {
+        if (typeof str !== 'string')
+            throw TypeError("str");
+        var bb = new ByteBuffer(str.length/4*3, littleEndian),
+            i = 0;
+        lxiv.decode(stringSource(str), function(b) {
+            bb.view[i++] = b;
+        });
+        bb.limit = i;
+        return bb;
+    };
+
+    /**
+     * Encodes a binary string to base64 like `window.btoa` does.
+     * @param {string} str Binary string
+     * @returns {string} Base64 encoded string
+     * @see https://developer.mozilla.org/en-US/docs/Web/API/Window.btoa
+     * @expose
+     */
+    ByteBuffer.btoa = function(str) {
+        return ByteBuffer.fromBinary(str).toBase64();
+    };
+
+    /**
+     * Decodes a base64 encoded string to binary like `window.atob` does.
+     * @param {string} b64 Base64 encoded string
+     * @returns {string} Binary string
+     * @see https://developer.mozilla.org/en-US/docs/Web/API/Window.atob
+     * @expose
+     */
+    ByteBuffer.atob = function(b64) {
+        return ByteBuffer.fromBase64(b64).toBinary();
+    };
+
+    // encodings/binary
+
+    /**
+     * Encodes this ByteBuffer to a binary encoded string, that is using only characters 0x00-0xFF as bytes.
+     * @param {number=} begin Offset to begin at. Defaults to {@link ByteBuffer#offset}.
+     * @param {number=} end Offset to end at. Defaults to {@link ByteBuffer#limit}.
+     * @returns {string} Binary encoded string
+     * @throws {RangeError} If `offset > limit`
+     * @expose
+     */
+    ByteBufferPrototype.toBinary = function(begin, end) {
+        if (typeof begin === 'undefined')
+            begin = this.offset;
+        if (typeof end === 'undefined')
+            end = this.limit;
+        begin |= 0; end |= 0;
+        if (begin < 0 || end > this.capacity() || begin > end)
+            throw RangeError("begin, end");
+        if (begin === end)
+            return "";
+        var chars = [],
+            parts = [];
+        while (begin < end) {
+            chars.push(this.view[begin++]);
+            if (chars.length >= 1024)
+                parts.push(String.fromCharCode.apply(String, chars)),
+                chars = [];
+        }
+        return parts.join('') + String.fromCharCode.apply(String, chars);
+    };
+
+    /**
+     * Decodes a binary encoded string, that is using only characters 0x00-0xFF as bytes, to a ByteBuffer.
+     * @param {string} str String to decode
+     * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to
+     *  {@link ByteBuffer.DEFAULT_ENDIAN}.
+     * @returns {!ByteBuffer} ByteBuffer
+     * @expose
+     */
+    ByteBuffer.fromBinary = function(str, littleEndian) {
+        if (typeof str !== 'string')
+            throw TypeError("str");
+        var i = 0,
+            k = str.length,
+            charCode,
+            bb = new ByteBuffer(k, littleEndian);
+        while (i<k) {
+            charCode = str.charCodeAt(i);
+            if (charCode > 0xff)
+                throw RangeError("illegal char code: "+charCode);
+            bb.view[i++] = charCode;
+        }
+        bb.limit = k;
+        return bb;
+    };
+
+    // encodings/debug
+
+    /**
+     * Encodes this ByteBuffer to a hex encoded string with marked offsets. Offset symbols are:
+     * * `<` : offset,
+     * * `'` : markedOffset,
+     * * `>` : limit,
+     * * `|` : offset and limit,
+     * * `[` : offset and markedOffset,
+     * * `]` : markedOffset and limit,
+     * * `!` : offset, markedOffset and limit
+     * @param {boolean=} columns If `true` returns two columns hex + ascii, defaults to `false`
+     * @returns {string|!Array.<string>} Debug string or array of lines if `asArray = true`
+     * @expose
+     * @example `>00'01 02<03` contains four bytes with `limit=0, markedOffset=1, offset=3`
+     * @example `00[01 02 03>` contains four bytes with `offset=markedOffset=1, limit=4`
+     * @example `00|01 02 03` contains four bytes with `offset=limit=1, markedOffset=-1`
+     * @example `|` contains zero bytes with `offset=limit=0, markedOffset=-1`
+     */
+    ByteBufferPrototype.toDebug = function(columns) {
+        var i = -1,
+            k = this.buffer.byteLength,
+            b,
+            hex = "",
+            asc = "",
+            out = "";
+        while (i<k) {
+            if (i !== -1) {
+                b = this.view[i];
+                if (b < 0x10) hex += "0"+b.toString(16).toUpperCase();
+                else hex += b.toString(16).toUpperCase();
+                if (columns)
+                    asc += b > 32 && b < 127 ? String.fromCharCode(b) : '.';
+            }
+            ++i;
+            if (columns) {
+                if (i > 0 && i % 16 === 0 && i !== k) {
+                    while (hex.length < 3*16+3) hex += " ";
+                    out += hex+asc+"\n";
+                    hex = asc = "";
+                }
+            }
+            if (i === this.offset && i === this.limit)
+                hex += i === this.markedOffset ? "!" : "|";
+            else if (i === this.offset)
+                hex += i === this.markedOffset ? "[" : "<";
+            else if (i === this.limit)
+                hex += i === this.markedOffset ? "]" : ">";
+            else
+                hex += i === this.markedOffset ? "'" : (columns || (i !== 0 && i !== k) ? " " : "");
+        }
+        if (columns && hex !== " ") {
+            while (hex.length < 3*16+3)
+                hex += " ";
+            out += hex + asc + "\n";
+        }
+        return columns ? out : hex;
+    };
+
+    /**
+     * Decodes a hex encoded string with marked offsets to a ByteBuffer.
+     * @param {string} str Debug string to decode (not be generated with `columns = true`)
+     * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to
+     *  {@link ByteBuffer.DEFAULT_ENDIAN}.
+     * @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to
+     *  {@link ByteBuffer.DEFAULT_NOASSERT}.
+     * @returns {!ByteBuffer} ByteBuffer
+     * @expose
+     * @see ByteBuffer#toDebug
+     */
+    ByteBuffer.fromDebug = function(str, littleEndian, noAssert) {
+        var k = str.length,
+            bb = new ByteBuffer(((k+1)/3)|0, littleEndian, noAssert);
+        var i = 0, j = 0, ch, b,
+            rs = false, // Require symbol next
+            ho = false, hm = false, hl = false, // Already has offset (ho), markedOffset (hm), limit (hl)?
+            fail = false;
+        while (i<k) {
+            switch (ch = str.charAt(i++)) {
+                case '!':
+                    if (!noAssert) {
+                        if (ho || hm || hl) {
+                            fail = true;
+                            break;
+                        }
+                        ho = hm = hl = true;
+                    }
+                    bb.offset = bb.markedOffset = bb.limit = j;
+                    rs = false;
+                    break;
+                case '|':
+                    if (!noAssert) {
+                        if (ho || hl) {
+                            fail = true;
+                            break;
+                        }
+                        ho = hl = true;
+                    }
+                    bb.offset = bb.limit = j;
+                    rs = false;
+                    break;
+                case '[':
+                    if (!noAssert) {
+                        if (ho || hm) {
+                            fail = true;
+                            break;
+                        }
+                        ho = hm = true;
+                    }
+                    bb.offset = bb.markedOffset = j;
+                    rs = false;
+                    break;
+                case '<':
+                    if (!noAssert) {
+                        if (ho) {
+                            fail = true;
+                            break;
+                        }
+                        ho = true;
+                    }
+                    bb.offset = j;
+                    rs = false;
+                    break;
+                case ']':
+                    if (!noAssert) {
+                        if (hl || hm) {
+                            fail = true;
+                            break;
+                        }
+                        hl = hm = true;
+                    }
+                    bb.limit = bb.markedOffset = j;
+                    rs = false;
+                    break;
+                case '>':
+                    if (!noAssert) {
+                        if (hl) {
+                            fail = true;
+                            break;
+                        }
+                        hl = true;
+                    }
+                    bb.limit = j;
+                    rs = false;
+                    break;
+                case "'":
+                    if (!noAssert) {
+                        if (hm) {
+                            fail = true;
+                            break;
+                        }
+                        hm = true;
+                    }
+                    bb.markedOffset = j;
+                    rs = false;
+                    break;
+                case ' ':
+                    rs = false;
+                    break;
+                default:
+                    if (!noAssert) {
+                        if (rs) {
+                            fail = true;
+                            break;
+                        }
+                    }
+                    b = parseInt(ch+str.charAt(i++), 16);
+                    if (!noAssert) {
+                        if (isNaN(b) || b < 0 || b > 255)
+                            throw TypeError("Illegal str: Not a debug encoded string");
+                    }
+                    bb.view[j++] = b;
+                    rs = true;
+            }
+            if (fail)
+                throw TypeError("Illegal str: Invalid symbol at "+i);
+        }
+        if (!noAssert) {
+            if (!ho || !hl)
+                throw TypeError("Illegal str: Missing offset or limit");
+            if (j<bb.buffer.byteLength)
+                throw TypeError("Illegal str: Not a debug encoded string (is it hex?) "+j+" < "+k);
+        }
+        return bb;
+    };
+
+    // encodings/hex
+
+    /**
+     * Encodes this ByteBuffer's contents to a hex encoded string.
+     * @param {number=} begin Offset to begin at. Defaults to {@link ByteBuffer#offset}.
+     * @param {number=} end Offset to end at. Defaults to {@link ByteBuffer#limit}.
+     * @returns {string} Hex encoded string
+     * @expose
+     */
+    ByteBufferPrototype.toHex = function(begin, end) {
+        begin = typeof begin === 'undefined' ? this.offset : begin;
+        end = typeof end === 'undefined' ? this.limit : end;
+        if (!this.noAssert) {
+            if (typeof begin !== 'number' || begin % 1 !== 0)
+                throw TypeError("Illegal begin: Not an integer");
+            begin >>>= 0;
+            if (typeof end !== 'number' || end % 1 !== 0)
+                throw TypeError("Illegal end: Not an integer");
+            end >>>= 0;
+            if (begin < 0 || begin > end || end > this.buffer.byteLength)
+                throw RangeError("Illegal range: 0 <= "+begin+" <= "+end+" <= "+this.buffer.byteLength);
+        }
+        var out = new Array(end - begin),
+            b;
+        while (begin < end) {
+            b = this.view[begin++];
+            if (b < 0x10)
+                out.push("0", b.toString(16));
+            else out.push(b.toString(16));
+        }
+        return out.join('');
+    };
+
+    /**
+     * Decodes a hex encoded string to a ByteBuffer.
+     * @param {string} str String to decode
+     * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to
+     *  {@link ByteBuffer.DEFAULT_ENDIAN}.
+     * @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to
+     *  {@link ByteBuffer.DEFAULT_NOASSERT}.
+     * @returns {!ByteBuffer} ByteBuffer
+     * @expose
+     */
+    ByteBuffer.fromHex = function(str, littleEndian, noAssert) {
+        if (!noAssert) {
+            if (typeof str !== 'string')
+                throw TypeError("Illegal str: Not a string");
+            if (str.length % 2 !== 0)
+                throw TypeError("Illegal str: Length not a multiple of 2");
+        }
+        var k = str.length,
+            bb = new ByteBuffer((k / 2) | 0, littleEndian),
+            b;
+        for (var i=0, j=0; i<k; i+=2) {
+            b = parseInt(str.substring(i, i+2), 16);
+            if (!noAssert)
+                if (!isFinite(b) || b < 0 || b > 255)
+                    throw TypeError("Illegal str: Contains non-hex characters");
+            bb.view[j++] = b;
+        }
+        bb.limit = j;
+        return bb;
+    };
+
+    // utfx-embeddable
+
+    /**
+     * utfx-embeddable (c) 2014 Daniel Wirtz <dcode@dcode.io>
+     * Released under the Apache License, Version 2.0
+     * see: https://github.com/dcodeIO/utfx for details
+     */
+    var utfx = function() {
+        "use strict";
+
+        /**
+         * utfx namespace.
+         * @inner
+         * @type {!Object.<string,*>}
+         */
+        var utfx = {};
+
+        /**
+         * Maximum valid code point.
+         * @type {number}
+         * @const
+         */
+        utfx.MAX_CODEPOINT = 0x10FFFF;
+
+        /**
+         * Encodes UTF8 code points to UTF8 bytes.
+         * @param {(!function():number|null) | number} src Code points source, either as a function returning the next code point
+         *  respectively `null` if there are no more code points left or a single numeric code point.
+         * @param {!function(number)} dst Bytes destination as a function successively called with the next byte
+         */
+        utfx.encodeUTF8 = function(src, dst) {
+            var cp = null;
+            if (typeof src === 'number')
+                cp = src,
+                src = function() { return null; };
+            while (cp !== null || (cp = src()) !== null) {
+                if (cp < 0x80)
+                    dst(cp&0x7F);
+                else if (cp < 0x800)
+                    dst(((cp>>6)&0x1F)|0xC0),
+                    dst((cp&0x3F)|0x80);
+                else if (cp < 0x10000)
+                    dst(((cp>>12)&0x0F)|0xE0),
+                    dst(((cp>>6)&0x3F)|0x80),
+                    dst((cp&0x3F)|0x80);
+                else
+                    dst(((cp>>18)&0x07)|0xF0),
+                    dst(((cp>>12)&0x3F)|0x80),
+                    dst(((cp>>6)&0x3F)|0x80),
+                    dst((cp&0x3F)|0x80);
+                cp = null;
+            }
+        };
+
+        /**
+         * Decodes UTF8 bytes to UTF8 code points.
+         * @param {!function():number|null} src Bytes source as a function returning the next byte respectively `null` if there
+         *  are no more bytes left.
+         * @param {!function(number)} dst Code points destination as a function successively called with each decoded code point.
+         * @throws {RangeError} If a starting byte is invalid in UTF8
+         * @throws {Error} If the last sequence is truncated. Has an array property `bytes` holding the
+         *  remaining bytes.
+         */
+        utfx.decodeUTF8 = function(src, dst) {
+            var a, b, c, d, fail = function(b) {
+                b = b.slice(0, b.indexOf(null));
+                var err = Error(b.toString());
+                err.name = "TruncatedError";
+                err['bytes'] = b;
+                throw err;
+            };
+            while ((a = src()) !== null) {
+                if ((a&0x80) === 0)
+                    dst(a);
+                else if ((a&0xE0) === 0xC0)
+                    ((b = src()) === null) && fail([a, b]),
+                    dst(((a&0x1F)<<6) | (b&0x3F));
+                else if ((a&0xF0) === 0xE0)
+                    ((b=src()) === null || (c=src()) === null) && fail([a, b, c]),
+                    dst(((a&0x0F)<<12) | ((b&0x3F)<<6) | (c&0x3F));
+                else if ((a&0xF8) === 0xF0)
+                    ((b=src()) === null || (c=src()) === null || (d=src()) === null) && fail([a, b, c ,d]),
+                    dst(((a&0x07)<<18) | ((b&0x3F)<<12) | ((c&0x3F)<<6) | (d&0x3F));
+                else throw RangeError("Illegal starting byte: "+a);
+            }
+        };
+
+        /**
+         * Converts UTF16 characters to UTF8 code points.
+         * @param {!function():number|null} src Characters source as a function returning the next char code respectively
+         *  `null` if there are no more characters left.
+         * @param {!function(number)} dst Code points destination as a function successively called with each converted code
+         *  point.
+         */
+        utfx.UTF16toUTF8 = function(src, dst) {
+            var c1, c2 = null;
+            while (true) {
+                if ((c1 = c2 !== null ? c2 : src()) === null)
+                    break;
+                if (c1 >= 0xD800 && c1 <= 0xDFFF) {
+                    if ((c2 = src()) !== null) {
+                        if (c2 >= 0xDC00 && c2 <= 0xDFFF) {
+                            dst((c1-0xD800)*0x400+c2-0xDC00+0x10000);
+                            c2 = null; continue;
+                        }
+                    }
+                }
+                dst(c1);
+            }
+            if (c2 !== null) dst(c2);
+        };
+
+        /**
+         * Converts UTF8 code points to UTF16 characters.
+         * @param {(!function():number|null) | number} src Code points source, either as a function returning the next code point
+         *  respectively `null` if there are no more code points left or a single numeric code point.
+         * @param {!function(number)} dst Characters destination as a function successively called with each converted char code.
+         * @throws {RangeError} If a code point is out of range
+         */
+        utfx.UTF8toUTF16 = function(src, dst) {
+            var cp = null;
+            if (typeof src === 'number')
+                cp = src, src = function() { return null; };
+            while (cp !== null || (cp = src()) !== null) {
+                if (cp <= 0xFFFF)
+                    dst(cp);
+                else
+                    cp -= 0x10000,
+                    dst((cp>>10)+0xD800),
+                    dst((cp%0x400)+0xDC00);
+                cp = null;
+            }
+        };
+
+        /**
+         * Converts and encodes UTF16 characters to UTF8 bytes.
+         * @param {!function():number|null} src Characters source as a function returning the next char code respectively `null`
+         *  if there are no more characters left.
+         * @param {!function(number)} dst Bytes destination as a function successively called with the next byte.
+         */
+        utfx.encodeUTF16toUTF8 = function(src, dst) {
+            utfx.UTF16toUTF8(src, function(cp) {
+                utfx.encodeUTF8(cp, dst);
+            });
+        };
+
+        /**
+         * Decodes and converts UTF8 bytes to UTF16 characters.
+         * @param {!function():number|null} src Bytes source as a function returning the next byte respectively `null` if there
+         *  are no more bytes left.
+         * @param {!function(number)} dst Characters destination as a function successively called with each converted char code.
+         * @throws {RangeError} If a starting byte is invalid in UTF8
+         * @throws {Error} If the last sequence is truncated. Has an array property `bytes` holding the remaining bytes.
+         */
+        utfx.decodeUTF8toUTF16 = function(src, dst) {
+            utfx.decodeUTF8(src, function(cp) {
+                utfx.UTF8toUTF16(cp, dst);
+            });
+        };
+
+        /**
+         * Calculates the byte length of an UTF8 code point.
+         * @param {number} cp UTF8 code point
+         * @returns {number} Byte length
+         */
+        utfx.calculateCodePoint = function(cp) {
+            return (cp < 0x80) ? 1 : (cp < 0x800) ? 2 : (cp < 0x10000) ? 3 : 4;
+        };
+
+        /**
+         * Calculates the number of UTF8 bytes required to store UTF8 code points.
+         * @param {(!function():number|null)} src Code points source as a function returning the next code point respectively
+         *  `null` if there are no more code points left.
+         * @returns {number} The number of UTF8 bytes required
+         */
+        utfx.calculateUTF8 = function(src) {
+            var cp, l=0;
+            while ((cp = src()) !== null)
+                l += (cp < 0x80) ? 1 : (cp < 0x800) ? 2 : (cp < 0x10000) ? 3 : 4;
+            return l;
+        };
+
+        /**
+         * Calculates the number of UTF8 code points respectively UTF8 bytes required to store UTF16 char codes.
+         * @param {(!function():number|null)} src Characters source as a function returning the next char code respectively
+         *  `null` if there are no more characters left.
+         * @returns {!Array.<number>} The number of UTF8 code points at index 0 and the number of UTF8 bytes required at index 1.
+         */
+        utfx.calculateUTF16asUTF8 = function(src) {
+            var n=0, l=0;
+            utfx.UTF16toUTF8(src, function(cp) {
+                ++n; l += (cp < 0x80) ? 1 : (cp < 0x800) ? 2 : (cp < 0x10000) ? 3 : 4;
+            });
+            return [n,l];
+        };
+
+        return utfx;
+    }();
+
+    // encodings/utf8
+
+    /**
+     * Encodes this ByteBuffer's contents between {@link ByteBuffer#offset} and {@link ByteBuffer#limit} to an UTF8 encoded
+     *  string.
+     * @returns {string} Hex encoded string
+     * @throws {RangeError} If `offset > limit`
+     * @expose
+     */
+    ByteBufferPrototype.toUTF8 = function(begin, end) {
+        if (typeof begin === 'undefined') begin = this.offset;
+        if (typeof end === 'undefined') end = this.limit;
+        if (!this.noAssert) {
+            if (typeof begin !== 'number' || begin % 1 !== 0)
+                throw TypeError("Illegal begin: Not an integer");
+            begin >>>= 0;
+            if (typeof end !== 'number' || end % 1 !== 0)
+                throw TypeError("Illegal end: Not an integer");
+            end >>>= 0;
+            if (begin < 0 || begin > end || end > this.buffer.byteLength)
+                throw RangeError("Illegal range: 0 <= "+begin+" <= "+end+" <= "+this.buffer.byteLength);
+        }
+        var sd; try {
+            utfx.decodeUTF8toUTF16(function() {
+                return begin < end ? this.view[begin++] : null;
+            }.bind(this), sd = stringDestination());
+        } catch (e) {
+            if (begin !== end)
+                throw RangeError("Illegal range: Truncated data, "+begin+" != "+end);
+        }
+        return sd();
+    };
+
+    /**
+     * Decodes an UTF8 encoded string to a ByteBuffer.
+     * @param {string} str String to decode
+     * @param {boolean=} littleEndian Whether to use little or big endian byte order. Defaults to
+     *  {@link ByteBuffer.DEFAULT_ENDIAN}.
+     * @param {boolean=} noAssert Whether to skip assertions of offsets and values. Defaults to
+     *  {@link ByteBuffer.DEFAULT_NOASSERT}.
+     * @returns {!ByteBuffer} ByteBuffer
+     * @expose
+     */
+    ByteBuffer.fromUTF8 = function(str, littleEndian, noAssert) {
+        if (!noAssert)
+            if (typeof str !== 'string')
+                throw TypeError("Illegal str: Not a string");
+        var bb = new ByteBuffer(utfx.calculateUTF16asUTF8(stringSource(str), true)[1], littleEndian, noAssert),
+            i = 0;
+        utfx.encodeUTF16toUTF8(stringSource(str), function(b) {
+            bb.view[i++] = b;
+        });
+        bb.limit = i;
+        return bb;
+    };
+
+    return ByteBuffer;
+});

+ 2357 - 0
ShootingSun/bin/libs/domparserinone.js

@@ -0,0 +1,2357 @@
+var entityMap = {
+       lt: '<',
+       gt: '>',
+       amp: '&',
+       quot: '"',
+       apos: "'",
+       Agrave: "À",
+       Aacute: "Á",
+       Acirc: "Â",
+       Atilde: "Ã",
+       Auml: "Ä",
+       Aring: "Å",
+       AElig: "Æ",
+       Ccedil: "Ç",
+       Egrave: "È",
+       Eacute: "É",
+       Ecirc: "Ê",
+       Euml: "Ë",
+       Igrave: "Ì",
+       Iacute: "Í",
+       Icirc: "Î",
+       Iuml: "Ï",
+       ETH: "Ð",
+       Ntilde: "Ñ",
+       Ograve: "Ò",
+       Oacute: "Ó",
+       Ocirc: "Ô",
+       Otilde: "Õ",
+       Ouml: "Ö",
+       Oslash: "Ø",
+       Ugrave: "Ù",
+       Uacute: "Ú",
+       Ucirc: "Û",
+       Uuml: "Ü",
+       Yacute: "Ý",
+       THORN: "Þ",
+       szlig: "ß",
+       agrave: "à",
+       aacute: "á",
+       acirc: "â",
+       atilde: "ã",
+       auml: "ä",
+       aring: "å",
+       aelig: "æ",
+       ccedil: "ç",
+       egrave: "è",
+       eacute: "é",
+       ecirc: "ê",
+       euml: "ë",
+       igrave: "ì",
+       iacute: "í",
+       icirc: "î",
+       iuml: "ï",
+       eth: "ð",
+       ntilde: "ñ",
+       ograve: "ò",
+       oacute: "ó",
+       ocirc: "ô",
+       otilde: "õ",
+       ouml: "ö",
+       oslash: "ø",
+       ugrave: "ù",
+       uacute: "ú",
+       ucirc: "û",
+       uuml: "ü",
+       yacute: "ý",
+       thorn: "þ",
+       yuml: "ÿ",
+       nbsp: " ",
+       iexcl: "¡",
+       cent: "¢",
+       pound: "£",
+       curren: "¤",
+       yen: "¥",
+       brvbar: "¦",
+       sect: "§",
+       uml: "¨",
+       copy: "©",
+       ordf: "ª",
+       laquo: "«",
+       not: "¬",
+       shy: "­­",
+       reg: "®",
+       macr: "¯",
+       deg: "°",
+       plusmn: "±",
+       sup2: "²",
+       sup3: "³",
+       acute: "´",
+       micro: "µ",
+       para: "¶",
+       middot: "·",
+       cedil: "¸",
+       sup1: "¹",
+       ordm: "º",
+       raquo: "»",
+       frac14: "¼",
+       frac12: "½",
+       frac34: "¾",
+       iquest: "¿",
+       times: "×",
+       divide: "÷",
+       forall: "∀",
+       part: "∂",
+       exist: "∃",
+       empty: "∅",
+       nabla: "∇",
+       isin: "∈",
+       notin: "∉",
+       ni: "∋",
+       prod: "∏",
+       sum: "∑",
+       minus: "−",
+       lowast: "∗",
+       radic: "√",
+       prop: "∝",
+       infin: "∞",
+       ang: "∠",
+       and: "∧",
+       or: "∨",
+       cap: "∩",
+       cup: "∪",
+       'int': "∫",
+       there4: "∴",
+       sim: "∼",
+       cong: "≅",
+       asymp: "≈",
+       ne: "≠",
+       equiv: "≡",
+       le: "≤",
+       ge: "≥",
+       sub: "⊂",
+       sup: "⊃",
+       nsub: "⊄",
+       sube: "⊆",
+       supe: "⊇",
+       oplus: "⊕",
+       otimes: "⊗",
+       perp: "⊥",
+       sdot: "⋅",
+       Alpha: "Α",
+       Beta: "Β",
+       Gamma: "Γ",
+       Delta: "Δ",
+       Epsilon: "Ε",
+       Zeta: "Ζ",
+       Eta: "Η",
+       Theta: "Θ",
+       Iota: "Ι",
+       Kappa: "Κ",
+       Lambda: "Λ",
+       Mu: "Μ",
+       Nu: "Ν",
+       Xi: "Ξ",
+       Omicron: "Ο",
+       Pi: "Π",
+       Rho: "Ρ",
+       Sigma: "Σ",
+       Tau: "Τ",
+       Upsilon: "Υ",
+       Phi: "Φ",
+       Chi: "Χ",
+       Psi: "Ψ",
+       Omega: "Ω",
+       alpha: "α",
+       beta: "β",
+       gamma: "γ",
+       delta: "δ",
+       epsilon: "ε",
+       zeta: "ζ",
+       eta: "η",
+       theta: "θ",
+       iota: "ι",
+       kappa: "κ",
+       lambda: "λ",
+       mu: "μ",
+       nu: "ν",
+       xi: "ξ",
+       omicron: "ο",
+       pi: "π",
+       rho: "ρ",
+       sigmaf: "ς",
+       sigma: "σ",
+       tau: "τ",
+       upsilon: "υ",
+       phi: "φ",
+       chi: "χ",
+       psi: "ψ",
+       omega: "ω",
+       thetasym: "ϑ",
+       upsih: "ϒ",
+       piv: "ϖ",
+       OElig: "Œ",
+       oelig: "œ",
+       Scaron: "Š",
+       scaron: "š",
+       Yuml: "Ÿ",
+       fnof: "ƒ",
+       circ: "ˆ",
+       tilde: "˜",
+       ensp: " ",
+       emsp: " ",
+       thinsp: " ",
+       zwnj: "‌",
+       zwj: "‍",
+       lrm: "‎",
+       rlm: "‏",
+       ndash: "–",
+       mdash: "—",
+       lsquo: "‘",
+       rsquo: "’",
+       sbquo: "‚",
+       ldquo: "“",
+       rdquo: "”",
+       bdquo: "„",
+       dagger: "†",
+       Dagger: "‡",
+       bull: "•",
+       hellip: "…",
+       permil: "‰",
+       prime: "′",
+       Prime: "″",
+       lsaquo: "‹",
+       rsaquo: "›",
+       oline: "‾",
+       euro: "€",
+       trade: "™",
+       larr: "←",
+       uarr: "↑",
+       rarr: "→",
+       darr: "↓",
+       harr: "↔",
+       crarr: "↵",
+       lceil: "⌈",
+       rceil: "⌉",
+       lfloor: "⌊",
+       rfloor: "⌋",
+       loz: "◊",
+       spades: "♠",
+       clubs: "♣",
+       hearts: "♥",
+       diams: "♦"
+};
+//for(var  n in exports.entityMap){console.log(exports.entityMap[n].charCodeAt())}
+
+//[4]   	NameStartChar	   ::=   	":" | [A-Z] | "_" | [a-z] | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x2FF] | [#x370-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF]
+//[4a]   	NameChar	   ::=   	NameStartChar | "-" | "." | [0-9] | #xB7 | [#x0300-#x036F] | [#x203F-#x2040]
+//[5]   	Name	   ::=   	NameStartChar (NameChar)*
+var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]///\u10000-\uEFFFF
+var nameChar = new RegExp("[\\-\\.0-9"+nameStartChar.source.slice(1,-1)+"\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
+var tagNamePattern = new RegExp('^'+nameStartChar.source+nameChar.source+'*(?:\:'+nameStartChar.source+nameChar.source+'*)?$');
+//var tagNamePattern = /^[a-zA-Z_][\w\-\.]*(?:\:[a-zA-Z_][\w\-\.]*)?$/
+//var handlers = 'resolveEntity,getExternalSubset,characters,endDocument,endElement,endPrefixMapping,ignorableWhitespace,processingInstruction,setDocumentLocator,skippedEntity,startDocument,startElement,startPrefixMapping,notationDecl,unparsedEntityDecl,error,fatalError,warning,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,comment,endCDATA,endDTD,endEntity,startCDATA,startDTD,startEntity'.split(',')
+
+//S_TAG,	S_ATTR,	S_EQ,	S_ATTR_NOQUOT_VALUE
+//S_ATTR_SPACE,	S_ATTR_END,	S_TAG_SPACE, S_TAG_CLOSE
+var S_TAG = 0;//tag name offerring
+var S_ATTR = 1;//attr name offerring 
+var S_ATTR_SPACE=2;//attr name end and space offer
+var S_EQ = 3;//=space?
+var S_ATTR_NOQUOT_VALUE = 4;//attr value(no quot value only)
+var S_ATTR_END = 5;//attr value end and no space(quot end)
+var S_TAG_SPACE = 6;//(attr value end || tag end ) && (space offer)
+var S_TAG_CLOSE = 7;//closed el<el />
+
+SaxO={};
+function XMLReader(){
+	
+}
+
+XMLReader.prototype = {
+	parse:function(source,defaultNSMap,entityMap){
+		var domBuilder = this.domBuilder;
+		domBuilder.startDocument();
+		_copy(defaultNSMap ,defaultNSMap = {})
+		parse(source,defaultNSMap,entityMap,
+				domBuilder,this.errorHandler);
+		domBuilder.endDocument();
+	}
+}
+function parse(source,defaultNSMapCopy,entityMap,domBuilder,errorHandler){
+	function fixedFromCharCode(code) {
+		// String.prototype.fromCharCode does not supports
+		// > 2 bytes unicode chars directly
+		if (code > 0xffff) {
+			code -= 0x10000;
+			var surrogate1 = 0xd800 + (code >> 10)
+				, surrogate2 = 0xdc00 + (code & 0x3ff);
+
+			return String.fromCharCode(surrogate1, surrogate2);
+		} else {
+			return String.fromCharCode(code);
+		}
+	}
+	function entityReplacer(a){
+		var k = a.slice(1,-1);
+		if(k in entityMap){
+			return entityMap[k]; 
+		}else if(k.charAt(0) === '#'){
+			return fixedFromCharCode(parseInt(k.substr(1).replace('x','0x')))
+		}else{
+			errorHandler.error('entity not found:'+a);
+			return a;
+		}
+	}
+	function appendText(end){//has some bugs
+		if(end>start){
+			var xt = source.substring(start,end).replace(/&#?\w+;/g,entityReplacer);
+			locator&&position(start);
+			domBuilder.characters(xt,0,end-start);
+			start = end
+		}
+	}
+	function position(p,m){
+		while(p>=lineEnd && (m = linePattern.exec(source))){
+			lineStart = m.index;
+			lineEnd = lineStart + m[0].length;
+			locator.lineNumber++;
+			//console.log('line++:',locator,startPos,endPos)
+		}
+		locator.columnNumber = p-lineStart+1;
+	}
+	var lineStart = 0;
+	var lineEnd = 0;
+	var linePattern = /.*(?:\r\n?|\n)|.*$/g
+	var locator = domBuilder.locator;
+	
+	var parseStack = [{currentNSMap:defaultNSMapCopy}]
+	var closeMap = {};
+	var start = 0;
+	while(true){
+		try{
+			var tagStart = source.indexOf('<',start);
+			if(tagStart<0){
+				if(!source.substr(start).match(/^\s*$/)){
+					var doc = domBuilder.doc;
+	    			var text = doc.createTextNode(source.substr(start));
+	    			doc.appendChild(text);
+	    			domBuilder.currentElement = text;
+				}
+				return;
+			}
+			if(tagStart>start){
+				appendText(tagStart);
+			}
+			switch(source.charAt(tagStart+1)){
+			case '/':
+				var end = source.indexOf('>',tagStart+3);
+				var tagName = source.substring(tagStart+2,end);
+				var config = parseStack.pop();
+				if(end<0){
+					
+	        		tagName = source.substring(tagStart+2).replace(/[\s<].*/,'');
+	        		//console.error('#@@@@@@'+tagName)
+	        		errorHandler.error("end tag name: "+tagName+' is not complete:'+config.tagName);
+	        		end = tagStart+1+tagName.length;
+	        	}else if(tagName.match(/\s</)){
+	        		tagName = tagName.replace(/[\s<].*/,'');
+	        		errorHandler.error("end tag name: "+tagName+' maybe not complete');
+	        		end = tagStart+1+tagName.length;
+				}
+				//console.error(parseStack.length,parseStack)
+				//console.error(config);
+				var localNSMap = config.localNSMap;
+				var endMatch = config.tagName == tagName;
+				var endIgnoreCaseMach = endMatch || config.tagName&&config.tagName.toLowerCase() == tagName.toLowerCase()
+		        if(endIgnoreCaseMach){
+		        	domBuilder.endElement(config.uri,config.localName,tagName);
+					if(localNSMap){
+						for(var prefix in localNSMap){
+							domBuilder.endPrefixMapping(prefix) ;
+						}
+					}
+					if(!endMatch){
+		            	errorHandler.fatalError("end tag name: "+tagName+' is not match the current start tagName:'+config.tagName );
+					}
+		        }else{
+		        	parseStack.push(config)
+		        }
+				
+				end++;
+				break;
+				// end elment
+			case '?':// <?...?>
+				locator&&position(tagStart);
+				end = parseInstruction(source,tagStart,domBuilder);
+				break;
+			case '!':// <!doctype,<![CDATA,<!--
+				locator&&position(tagStart);
+				end = parseDCC(source,tagStart,domBuilder,errorHandler);
+				break;
+			default:
+				locator&&position(tagStart);
+				var el = new ElementAttributes();
+				var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
+				//elStartEnd
+				var end = parseElementStartPart(source,tagStart,el,currentNSMap,entityReplacer,errorHandler);
+				var len = el.length;
+				
+				
+				if(!el.closed && fixSelfClosed(source,end,el.tagName,closeMap)){
+					el.closed = true;
+					if(!entityMap.nbsp){
+						errorHandler.warning('unclosed xml attribute');
+					}
+				}
+				if(locator && len){
+					var locator2 = copyLocator(locator,{});
+					//try{//attribute position fixed
+					for(var i = 0;i<len;i++){
+						var a = el[i];
+						position(a.offset);
+						a.locator = copyLocator(locator,{});
+					}
+					//}catch(e){console.error('@@@@@'+e)}
+					domBuilder.locator = locator2
+					if(SaxO.appendElement(el,domBuilder,currentNSMap)){
+						parseStack.push(el)
+					}
+					domBuilder.locator = locator;
+				}else{
+					if(SaxO.appendElement(el,domBuilder,currentNSMap)){
+						parseStack.push(el)
+					}
+				}
+				
+				
+				
+				if(el.uri === 'http://www.w3.org/1999/xhtml' && !el.closed){
+					end = parseHtmlSpecialContent(source,end,el.tagName,entityReplacer,domBuilder)
+				}else{
+					end++;
+				}
+			}
+		}catch(e){
+			errorHandler.error('element parse error: '+e)
+			//errorHandler.error('element parse error: '+e);
+			end = -1;
+			//throw e;
+		}
+		if(end>start){
+			start = end;
+		}else{
+			//TODO: 这里有可能sax回退,有位置错误风险
+			appendText(Math.max(tagStart,start)+1);
+		}
+	}
+}
+function copyLocator(f,t){
+	t.lineNumber = f.lineNumber;
+	t.columnNumber = f.columnNumber;
+	return t;
+}
+
+/**
+ * @see #appendElement(source,elStartEnd,el,selfClosed,entityReplacer,domBuilder,parseStack);
+ * @return end of the elementStartPart(end of elementEndPart for selfClosed el)
+ */
+function parseElementStartPart(source,start,el,currentNSMap,entityReplacer,errorHandler){
+	var attrName;
+	var value;
+	var p = ++start;
+	var s = S_TAG;//status
+	while(true){
+		var c = source.charAt(p);
+		switch(c){
+		case '=':
+			if(s === S_ATTR){//attrName
+				attrName = source.slice(start,p);
+				s = S_EQ;
+			}else if(s === S_ATTR_SPACE){
+				s = S_EQ;
+			}else{
+				//fatalError: equal must after attrName or space after attrName
+				throw new Error('attribute equal must after attrName');
+			}
+			break;
+		case '\'':
+		case '"':
+			if(s === S_EQ || s === S_ATTR //|| s == S_ATTR_SPACE
+				){//equal
+				if(s === S_ATTR){
+					errorHandler.warning('attribute value must after "="')
+					attrName = source.slice(start,p)
+				}
+				start = p+1;
+				p = source.indexOf(c,start)
+				if(p>0){
+					value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
+					el.add(attrName,value,start-1);
+					s = S_ATTR_END;
+				}else{
+					//fatalError: no end quot match
+					throw new Error('attribute value no end \''+c+'\' match');
+				}
+			}else if(s == S_ATTR_NOQUOT_VALUE){
+				value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
+				//console.log(attrName,value,start,p)
+				el.add(attrName,value,start);
+				//console.dir(el)
+				errorHandler.warning('attribute "'+attrName+'" missed start quot('+c+')!!');
+				start = p+1;
+				s = S_ATTR_END
+			}else{
+				//fatalError: no equal before
+				throw new Error('attribute value must after "="');
+			}
+			break;
+		case '/':
+			switch(s){
+			case S_TAG:
+				el.setTagName(source.slice(start,p));
+			case S_ATTR_END:
+			case S_TAG_SPACE:
+			case S_TAG_CLOSE:
+				s =S_TAG_CLOSE;
+				el.closed = true;
+			case S_ATTR_NOQUOT_VALUE:
+			case S_ATTR:
+			case S_ATTR_SPACE:
+				break;
+			//case S_EQ:
+			default:
+				throw new Error("attribute invalid close char('/')")
+			}
+			break;
+		case ''://end document
+			//throw new Error('unexpected end of input')
+			errorHandler.error('unexpected end of input');
+			if(s == S_TAG){
+				el.setTagName(source.slice(start,p));
+			}
+			return p;
+		case '>':
+			switch(s){
+			case S_TAG:
+				el.setTagName(source.slice(start,p));
+			case S_ATTR_END:
+			case S_TAG_SPACE:
+			case S_TAG_CLOSE:
+				break;//normal
+			case S_ATTR_NOQUOT_VALUE://Compatible state
+			case S_ATTR:
+				value = source.slice(start,p);
+				if(value.slice(-1) === '/'){
+					el.closed  = true;
+					value = value.slice(0,-1)
+				}
+			case S_ATTR_SPACE:
+				if(s === S_ATTR_SPACE){
+					value = attrName;
+				}
+				if(s == S_ATTR_NOQUOT_VALUE){
+					errorHandler.warning('attribute "'+value+'" missed quot(")!!');
+					el.add(attrName,value.replace(/&#?\w+;/g,entityReplacer),start)
+				}else{
+					if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !value.match(/^(?:disabled|checked|selected)$/i)){
+						errorHandler.warning('attribute "'+value+'" missed value!! "'+value+'" instead!!')
+					}
+					el.add(value,value,start)
+				}
+				break;
+			case S_EQ:
+				throw new Error('attribute value missed!!');
+			}
+//			console.log(tagName,tagNamePattern,tagNamePattern.test(tagName))
+			return p;
+		/*xml space '\x20' | #x9 | #xD | #xA; */
+		case '\u0080':
+			c = ' ';
+		default:
+			if(c<= ' '){//space
+				switch(s){
+				case S_TAG:
+					el.setTagName(source.slice(start,p));//tagName
+					s = S_TAG_SPACE;
+					break;
+				case S_ATTR:
+					attrName = source.slice(start,p)
+					s = S_ATTR_SPACE;
+					break;
+				case S_ATTR_NOQUOT_VALUE:
+					var value = source.slice(start,p).replace(/&#?\w+;/g,entityReplacer);
+					errorHandler.warning('attribute "'+value+'" missed quot(")!!');
+					el.add(attrName,value,start)
+				case S_ATTR_END:
+					s = S_TAG_SPACE;
+					break;
+				//case S_TAG_SPACE:
+				//case S_EQ:
+				//case S_ATTR_SPACE:
+				//	void();break;
+				//case S_TAG_CLOSE:
+					//ignore warning
+				}
+			}else{//not space
+//S_TAG,	S_ATTR,	S_EQ,	S_ATTR_NOQUOT_VALUE
+//S_ATTR_SPACE,	S_ATTR_END,	S_TAG_SPACE, S_TAG_CLOSE
+				switch(s){
+				//case S_TAG:void();break;
+				//case S_ATTR:void();break;
+				//case S_ATTR_NOQUOT_VALUE:void();break;
+				case S_ATTR_SPACE:
+					var tagName =  el.tagName;
+					if(currentNSMap[''] !== 'http://www.w3.org/1999/xhtml' || !attrName.match(/^(?:disabled|checked|selected)$/i)){
+						errorHandler.warning('attribute "'+attrName+'" missed value!! "'+attrName+'" instead2!!')
+					}
+					el.add(attrName,attrName,start);
+					start = p;
+					s = S_ATTR;
+					break;
+				case S_ATTR_END:
+					errorHandler.warning('attribute space is required"'+attrName+'"!!')
+				case S_TAG_SPACE:
+					s = S_ATTR;
+					start = p;
+					break;
+				case S_EQ:
+					s = S_ATTR_NOQUOT_VALUE;
+					start = p;
+					break;
+				case S_TAG_CLOSE:
+					throw new Error("elements closed character '/' and '>' must be connected to");
+				}
+			}
+		}//end outer switch
+		//console.log('p++',p)
+		p++;
+	}
+}
+/**
+ * @return true if has new namespace define
+ */
+SaxO.appendElement=function appendElement(el,domBuilder,currentNSMap){
+	var tagName = el.tagName;
+	var localNSMap = null;
+	//var currentNSMap = parseStack[parseStack.length-1].currentNSMap;
+	var i = el.length;
+	while(i--){
+		var a = el[i];
+		var qName = a.qName;
+		var value = a.value;
+		var nsp = qName.indexOf(':');
+		if(nsp>0){
+			var prefix = a.prefix = qName.slice(0,nsp);
+			var localName = qName.slice(nsp+1);
+			var nsPrefix = prefix === 'xmlns' && localName
+		}else{
+			localName = qName;
+			prefix = null
+			nsPrefix = qName === 'xmlns' && ''
+		}
+		//can not set prefix,because prefix !== ''
+		a.localName = localName ;
+		//prefix == null for no ns prefix attribute 
+		if(nsPrefix !== false){//hack!!
+			if(localNSMap == null){
+				localNSMap = {}
+				//console.log(currentNSMap,0)
+				_copy(currentNSMap,currentNSMap={})
+				//console.log(currentNSMap,1)
+			}
+			currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
+			a.uri = 'http://www.w3.org/2000/xmlns/'
+			domBuilder.startPrefixMapping(nsPrefix, value) 
+		}
+	}
+	var i = el.length;
+	while(i--){
+		a = el[i];
+		var prefix = a.prefix;
+		if(prefix){//no prefix attribute has no namespace
+			if(prefix === 'xml'){
+				a.uri = 'http://www.w3.org/XML/1998/namespace';
+			}if(prefix !== 'xmlns'){
+				a.uri = currentNSMap[prefix || '']
+				
+				//{console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}
+			}
+		}
+	}
+	var nsp = tagName.indexOf(':');
+	if(nsp>0){
+		prefix = el.prefix = tagName.slice(0,nsp);
+		localName = el.localName = tagName.slice(nsp+1);
+	}else{
+		prefix = null;//important!!
+		localName = el.localName = tagName;
+	}
+	//no prefix element has default namespace
+	var ns = el.uri = currentNSMap[prefix || ''];
+	domBuilder.startElement(ns,localName,tagName,el);
+	//endPrefixMapping and startPrefixMapping have not any help for dom builder
+	//localNSMap = null
+	if(el.closed){
+		domBuilder.endElement(ns,localName,tagName);
+		if(localNSMap){
+			for(prefix in localNSMap){
+				domBuilder.endPrefixMapping(prefix) 
+			}
+		}
+	}else{
+		el.currentNSMap = currentNSMap;
+		el.localNSMap = localNSMap;
+		//parseStack.push(el);
+		return true;
+	}
+}
+function parseHtmlSpecialContent(source,elStartEnd,tagName,entityReplacer,domBuilder){
+	if(/^(?:script|textarea)$/i.test(tagName)){
+		var elEndStart =  source.indexOf('</'+tagName+'>',elStartEnd);
+		var text = source.substring(elStartEnd+1,elEndStart);
+		if(/[&<]/.test(text)){
+			if(/^script$/i.test(tagName)){
+				//if(!/\]\]>/.test(text)){
+					//lexHandler.startCDATA();
+					domBuilder.characters(text,0,text.length);
+					//lexHandler.endCDATA();
+					return elEndStart;
+				//}
+			}//}else{//text area
+				text = text.replace(/&#?\w+;/g,entityReplacer);
+				domBuilder.characters(text,0,text.length);
+				return elEndStart;
+			//}
+			
+		}
+	}
+	return elStartEnd+1;
+}
+function fixSelfClosed(source,elStartEnd,tagName,closeMap){
+	//if(tagName in closeMap){
+	var pos = closeMap[tagName];
+	if(pos == null){
+		//console.log(tagName)
+		pos =  source.lastIndexOf('</'+tagName+'>')
+		if(pos<elStartEnd){//忘记闭合
+			pos = source.lastIndexOf('</'+tagName)
+		}
+		closeMap[tagName] =pos
+	}
+	return pos<elStartEnd;
+	//} 
+}
+function _copy(source,target){
+	for(var n in source){target[n] = source[n]}
+}
+function parseDCC(source,start,domBuilder,errorHandler){//sure start with '<!'
+	var next= source.charAt(start+2)
+	switch(next){
+	case '-':
+		if(source.charAt(start + 3) === '-'){
+			var end = source.indexOf('-->',start+4);
+			//append comment source.substring(4,end)//<!--
+			if(end>start){
+				domBuilder.comment(source,start+4,end-start-4);
+				return end+3;
+			}else{
+				errorHandler.error("Unclosed comment");
+				return -1;
+			}
+		}else{
+			//error
+			return -1;
+		}
+	default:
+		if(source.substr(start+3,6) == 'CDATA['){
+			var end = source.indexOf(']]>',start+9);
+			domBuilder.startCDATA();
+			domBuilder.characters(source,start+9,end-start-9);
+			domBuilder.endCDATA() 
+			return end+3;
+		}
+		//<!DOCTYPE
+		//startDTD(java.lang.String name, java.lang.String publicId, java.lang.String systemId) 
+		var matchs = split(source,start);
+		var len = matchs.length;
+		if(len>1 && /!doctype/i.test(matchs[0][0])){
+			var name = matchs[1][0];
+			var pubid = len>3 && /^public$/i.test(matchs[2][0]) && matchs[3][0]
+			var sysid = len>4 && matchs[4][0];
+			var lastMatch = matchs[len-1]
+			domBuilder.startDTD(name,pubid && pubid.replace(/^(['"])(.*?)\1$/,'$2'),
+					sysid && sysid.replace(/^(['"])(.*?)\1$/,'$2'));
+			domBuilder.endDTD();
+			
+			return lastMatch.index+lastMatch[0].length
+		}
+	}
+	return -1;
+}
+
+
+
+function parseInstruction(source,start,domBuilder){
+	var end = source.indexOf('?>',start);
+	if(end){
+		var match = source.substring(start,end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
+		if(match){
+			var len = match[0].length;
+			domBuilder.processingInstruction(match[1], match[2]) ;
+			return end+2;
+		}else{//error
+			return -1;
+		}
+	}
+	return -1;
+}
+
+/**
+ * @param source
+ */
+function ElementAttributes(source){
+	
+}
+ElementAttributes.prototype = {
+	setTagName:function(tagName){
+		if(!tagNamePattern.test(tagName)){
+			throw new Error('invalid tagName:'+tagName)
+		}
+		this.tagName = tagName
+	},
+	add:function(qName,value,offset){
+		if(!tagNamePattern.test(qName)){
+			throw new Error('invalid attribute:'+qName)
+		}
+		this[this.length++] = {qName:qName,value:value,offset:offset}
+	},
+	length:0,
+	getLocalName:function(i){return this[i].localName},
+	getLocator:function(i){return this[i].locator},
+	getQName:function(i){return this[i].qName},
+	getURI:function(i){return this[i].uri},
+	getValue:function(i){return this[i].value}
+//	,getIndex:function(uri, localName)){
+//		if(localName){
+//			
+//		}else{
+//			var qName = uri
+//		}
+//	},
+//	getValue:function(){return this.getValue(this.getIndex.apply(this,arguments))},
+//	getType:function(uri,localName){}
+//	getType:function(i){},
+}
+
+
+
+function split(source,start){
+	var match;
+	var buf = [];
+	var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
+	reg.lastIndex = start;
+	reg.exec(source);//skip <
+	while(match = reg.exec(source)){
+		buf.push(match);
+		if(match[1])return buf;
+	}
+}
+if(typeof require == 'function')
+{
+	exports.XMLReader = XMLReader;
+}
+
+/*
+ * DOM Level 2
+ * Object DOMException
+ * @see http://www.w3.org/TR/REC-DOM-Level-1/ecma-script-language-binding.html
+ * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/ecma-script-binding.html
+ */
+
+function copy(src,dest){
+	for(var p in src){
+		dest[p] = src[p];
+	}
+}
+/**
+^\w+\.prototype\.([_\w]+)\s*=\s*((?:.*\{\s*?[\r\n][\s\S]*?^})|\S.*?(?=[;\r\n]));?
+^\w+\.prototype\.([_\w]+)\s*=\s*(\S.*?(?=[;\r\n]));?
+ */
+function _extends(Class,Super){
+	var pt = Class.prototype;
+	if(!(pt instanceof Super)){
+		function t(){};
+		t.prototype = Super.prototype;
+		t = new t();
+		copy(pt,t);
+		Class.prototype = pt = t;
+	}
+	if(pt.constructor != Class){
+		if(typeof Class != 'function'){
+			console.error("unknow Class:"+Class)
+		}
+		pt.constructor = Class
+	}
+}
+var htmlns = 'http://www.w3.org/1999/xhtml' ;
+// Node Types
+var NodeType = {}
+var ELEMENT_NODE                = NodeType.ELEMENT_NODE                = 1;
+var ATTRIBUTE_NODE              = NodeType.ATTRIBUTE_NODE              = 2;
+var TEXT_NODE                   = NodeType.TEXT_NODE                   = 3;
+var CDATA_SECTION_NODE          = NodeType.CDATA_SECTION_NODE          = 4;
+var ENTITY_REFERENCE_NODE       = NodeType.ENTITY_REFERENCE_NODE       = 5;
+var ENTITY_NODE                 = NodeType.ENTITY_NODE                 = 6;
+var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
+var COMMENT_NODE                = NodeType.COMMENT_NODE                = 8;
+var DOCUMENT_NODE               = NodeType.DOCUMENT_NODE               = 9;
+var DOCUMENT_TYPE_NODE          = NodeType.DOCUMENT_TYPE_NODE          = 10;
+var DOCUMENT_FRAGMENT_NODE      = NodeType.DOCUMENT_FRAGMENT_NODE      = 11;
+var NOTATION_NODE               = NodeType.NOTATION_NODE               = 12;
+
+// ExceptionCode
+var ExceptionCode = {}
+var ExceptionMessage = {};
+var INDEX_SIZE_ERR              = ExceptionCode.INDEX_SIZE_ERR              = ((ExceptionMessage[1]="Index size error"),1);
+var DOMSTRING_SIZE_ERR          = ExceptionCode.DOMSTRING_SIZE_ERR          = ((ExceptionMessage[2]="DOMString size error"),2);
+var HIERARCHY_REQUEST_ERR       = ExceptionCode.HIERARCHY_REQUEST_ERR       = ((ExceptionMessage[3]="Hierarchy request error"),3);
+var WRONG_DOCUMENT_ERR          = ExceptionCode.WRONG_DOCUMENT_ERR          = ((ExceptionMessage[4]="Wrong document"),4);
+var INVALID_CHARACTER_ERR       = ExceptionCode.INVALID_CHARACTER_ERR       = ((ExceptionMessage[5]="Invalid character"),5);
+var NO_DATA_ALLOWED_ERR         = ExceptionCode.NO_DATA_ALLOWED_ERR         = ((ExceptionMessage[6]="No data allowed"),6);
+var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = ((ExceptionMessage[7]="No modification allowed"),7);
+var NOT_FOUND_ERR               = ExceptionCode.NOT_FOUND_ERR               = ((ExceptionMessage[8]="Not found"),8);
+var NOT_SUPPORTED_ERR           = ExceptionCode.NOT_SUPPORTED_ERR           = ((ExceptionMessage[9]="Not supported"),9);
+var INUSE_ATTRIBUTE_ERR         = ExceptionCode.INUSE_ATTRIBUTE_ERR         = ((ExceptionMessage[10]="Attribute in use"),10);
+//level2
+var INVALID_STATE_ERR        	= ExceptionCode.INVALID_STATE_ERR        	= ((ExceptionMessage[11]="Invalid state"),11);
+var SYNTAX_ERR               	= ExceptionCode.SYNTAX_ERR               	= ((ExceptionMessage[12]="Syntax error"),12);
+var INVALID_MODIFICATION_ERR 	= ExceptionCode.INVALID_MODIFICATION_ERR 	= ((ExceptionMessage[13]="Invalid modification"),13);
+var NAMESPACE_ERR            	= ExceptionCode.NAMESPACE_ERR           	= ((ExceptionMessage[14]="Invalid namespace"),14);
+var INVALID_ACCESS_ERR       	= ExceptionCode.INVALID_ACCESS_ERR      	= ((ExceptionMessage[15]="Invalid access"),15);
+
+
+function DOMException(code, message) {
+	if(message instanceof Error){
+		var error = message;
+	}else{
+		error = this;
+		Error.call(this, ExceptionMessage[code]);
+		this.message = ExceptionMessage[code];
+		if(Error.captureStackTrace) Error.captureStackTrace(this, DOMException);
+	}
+	error.code = code;
+	if(message) this.message = this.message + ": " + message;
+	return error;
+};
+DOMException.prototype = Error.prototype;
+copy(ExceptionCode,DOMException)
+/**
+ * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-536297177
+ * The NodeList interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented. NodeList objects in the DOM are live.
+ * The items in the NodeList are accessible via an integral index, starting from 0.
+ */
+function NodeList() {
+};
+NodeList.prototype = {
+	/**
+	 * The number of nodes in the list. The range of valid child node indices is 0 to length-1 inclusive.
+	 * @standard level1
+	 */
+	length:0, 
+	/**
+	 * Returns the indexth item in the collection. If index is greater than or equal to the number of nodes in the list, this returns null.
+	 * @standard level1
+	 * @param index  unsigned long 
+	 *   Index into the collection.
+	 * @return Node
+	 * 	The node at the indexth position in the NodeList, or null if that is not a valid index. 
+	 */
+	item: function(index) {
+		return this[index] || null;
+	},
+	toString:function(isHTML,nodeFilter){
+		for(var buf = [], i = 0;i<this.length;i++){
+			serializeToString(this[i],buf,isHTML,nodeFilter);
+		}
+		return buf.join('');
+	}
+};
+function LiveNodeList(node,refresh){
+	this._node = node;
+	this._refresh = refresh
+	_updateLiveList(this);
+}
+function _updateLiveList(list){
+	var inc = list._node._inc || list._node.ownerDocument._inc;
+	if(list._inc != inc){
+		var ls = list._refresh(list._node);
+		//console.log(ls.length)
+		__set__(list,'length',ls.length);
+		copy(ls,list);
+		list._inc = inc;
+	}
+}
+LiveNodeList.prototype.item = function(i){
+	_updateLiveList(this);
+	return this[i];
+}
+
+_extends(LiveNodeList,NodeList);
+/**
+ * 
+ * Objects implementing the NamedNodeMap interface are used to represent collections of nodes that can be accessed by name. Note that NamedNodeMap does not inherit from NodeList; NamedNodeMaps are not maintained in any particular order. Objects contained in an object implementing NamedNodeMap may also be accessed by an ordinal index, but this is simply to allow convenient enumeration of the contents of a NamedNodeMap, and does not imply that the DOM specifies an order to these Nodes.
+ * NamedNodeMap objects in the DOM are live.
+ * used for attributes or DocumentType entities 
+ */
+function NamedNodeMap() {
+};
+
+function _findNodeIndex(list,node){
+	var i = list.length;
+	while(i--){
+		if(list[i] === node){return i}
+	}
+}
+
+function _addNamedNode(el,list,newAttr,oldAttr){
+	if(oldAttr){
+		list[_findNodeIndex(list,oldAttr)] = newAttr;
+	}else{
+		list[list.length++] = newAttr;
+	}
+	if(el){
+		newAttr.ownerElement = el;
+		var doc = el.ownerDocument;
+		if(doc){
+			oldAttr && _onRemoveAttribute(doc,el,oldAttr);
+			_onAddAttribute(doc,el,newAttr);
+		}
+	}
+}
+function _removeNamedNode(el,list,attr){
+	//console.log('remove attr:'+attr)
+	var i = _findNodeIndex(list,attr);
+	if(i>=0){
+		var lastIndex = list.length-1
+		while(i<lastIndex){
+			list[i] = list[++i]
+		}
+		list.length = lastIndex;
+		if(el){
+			var doc = el.ownerDocument;
+			if(doc){
+				_onRemoveAttribute(doc,el,attr);
+				attr.ownerElement = null;
+			}
+		}
+	}else{
+		throw DOMException(NOT_FOUND_ERR,new Error(el.tagName+'@'+attr))
+	}
+}
+NamedNodeMap.prototype = {
+	length:0,
+	item:NodeList.prototype.item,
+	getNamedItem: function(key) {
+//		if(key.indexOf(':')>0 || key == 'xmlns'){
+//			return null;
+//		}
+		//console.log()
+		var i = this.length;
+		while(i--){
+			var attr = this[i];
+			//console.log(attr.nodeName,key)
+			if(attr.nodeName == key){
+				return attr;
+			}
+		}
+	},
+	setNamedItem: function(attr) {
+		var el = attr.ownerElement;
+		if(el && el!=this._ownerElement){
+			throw new DOMException(INUSE_ATTRIBUTE_ERR);
+		}
+		var oldAttr = this.getNamedItem(attr.nodeName);
+		_addNamedNode(this._ownerElement,this,attr,oldAttr);
+		return oldAttr;
+	},
+	/* returns Node */
+	setNamedItemNS: function(attr) {// raises: WRONG_DOCUMENT_ERR,NO_MODIFICATION_ALLOWED_ERR,INUSE_ATTRIBUTE_ERR
+		var el = attr.ownerElement, oldAttr;
+		if(el && el!=this._ownerElement){
+			throw new DOMException(INUSE_ATTRIBUTE_ERR);
+		}
+		oldAttr = this.getNamedItemNS(attr.namespaceURI,attr.localName);
+		_addNamedNode(this._ownerElement,this,attr,oldAttr);
+		return oldAttr;
+	},
+
+	/* returns Node */
+	removeNamedItem: function(key) {
+		var attr = this.getNamedItem(key);
+		_removeNamedNode(this._ownerElement,this,attr);
+		return attr;
+		
+		
+	},// raises: NOT_FOUND_ERR,NO_MODIFICATION_ALLOWED_ERR
+	
+	//for level2
+	removeNamedItemNS:function(namespaceURI,localName){
+		var attr = this.getNamedItemNS(namespaceURI,localName);
+		_removeNamedNode(this._ownerElement,this,attr);
+		return attr;
+	},
+	getNamedItemNS: function(namespaceURI, localName) {
+		var i = this.length;
+		while(i--){
+			var node = this[i];
+			if(node.localName == localName && node.namespaceURI == namespaceURI){
+				return node;
+			}
+		}
+		return null;
+	}
+};
+/**
+ * @see http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-102161490
+ */
+function DOMImplementation(/* Object */ features) {
+	this._features = {};
+	if (features) {
+		for (var feature in features) {
+			 this._features = features[feature];
+		}
+	}
+};
+
+DOMImplementation.prototype = {
+	hasFeature: function(/* string */ feature, /* string */ version) {
+		var versions = this._features[feature.toLowerCase()];
+		if (versions && (!version || version in versions)) {
+			return true;
+		} else {
+			return false;
+		}
+	},
+	// Introduced in DOM Level 2:
+	createDocument:function(namespaceURI,  qualifiedName, doctype){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR,WRONG_DOCUMENT_ERR
+		var doc = new Document();
+		doc.implementation = this;
+		doc.childNodes = new NodeList();
+		doc.doctype = doctype;
+		if(doctype){
+			doc.appendChild(doctype);
+		}
+		if(qualifiedName){
+			var root = doc.createElementNS(namespaceURI,qualifiedName);
+			doc.appendChild(root);
+		}
+		return doc;
+	},
+	// Introduced in DOM Level 2:
+	createDocumentType:function(qualifiedName, publicId, systemId){// raises:INVALID_CHARACTER_ERR,NAMESPACE_ERR
+		var node = new DocumentType();
+		node.name = qualifiedName;
+		node.nodeName = qualifiedName;
+		node.publicId = publicId;
+		node.systemId = systemId;
+		// Introduced in DOM Level 2:
+		//readonly attribute DOMString        internalSubset;
+		
+		//TODO:..
+		//  readonly attribute NamedNodeMap     entities;
+		//  readonly attribute NamedNodeMap     notations;
+		return node;
+	}
+};
+
+
+/**
+ * @see http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-1950641247
+ */
+
+function Node() {
+};
+
+Node.prototype = {
+	firstChild : null,
+	lastChild : null,
+	previousSibling : null,
+	nextSibling : null,
+	attributes : null,
+	parentNode : null,
+	childNodes : null,
+	ownerDocument : null,
+	nodeValue : null,
+	namespaceURI : null,
+	prefix : null,
+	localName : null,
+	// Modified in DOM Level 2:
+	insertBefore:function(newChild, refChild){//raises 
+		return _insertBefore(this,newChild,refChild);
+	},
+	replaceChild:function(newChild, oldChild){//raises 
+		this.insertBefore(newChild,oldChild);
+		if(oldChild){
+			this.removeChild(oldChild);
+		}
+	},
+	removeChild:function(oldChild){
+		return _removeChild(this,oldChild);
+	},
+	appendChild:function(newChild){
+		return this.insertBefore(newChild,null);
+	},
+	hasChildNodes:function(){
+		return this.firstChild != null;
+	},
+	cloneNode:function(deep){
+		return cloneNode(this.ownerDocument||this,this,deep);
+	},
+	// Modified in DOM Level 2:
+	normalize:function(){
+		var child = this.firstChild;
+		while(child){
+			var next = child.nextSibling;
+			if(next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE){
+				this.removeChild(next);
+				child.appendData(next.data);
+			}else{
+				child.normalize();
+				child = next;
+			}
+		}
+	},
+  	// Introduced in DOM Level 2:
+	isSupported:function(feature, version){
+		return this.ownerDocument.implementation.hasFeature(feature,version);
+	},
+    // Introduced in DOM Level 2:
+    hasAttributes:function(){
+    	return this.attributes.length>0;
+    },
+    lookupPrefix:function(namespaceURI){
+    	var el = this;
+    	while(el){
+    		var map = el._nsMap;
+    		//console.dir(map)
+    		if(map){
+    			for(var n in map){
+    				if(map[n] == namespaceURI){
+    					return n;
+    				}
+    			}
+    		}
+    		el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
+    	}
+    	return null;
+    },
+    // Introduced in DOM Level 3:
+    lookupNamespaceURI:function(prefix){
+    	var el = this;
+    	while(el){
+    		var map = el._nsMap;
+    		//console.dir(map)
+    		if(map){
+    			if(prefix in map){
+    				return map[prefix] ;
+    			}
+    		}
+    		el = el.nodeType == ATTRIBUTE_NODE?el.ownerDocument : el.parentNode;
+    	}
+    	return null;
+    },
+    // Introduced in DOM Level 3:
+    isDefaultNamespace:function(namespaceURI){
+    	var prefix = this.lookupPrefix(namespaceURI);
+    	return prefix == null;
+    }
+};
+
+
+function _xmlEncoder(c){
+	return c == '<' && '&lt;' ||
+         c == '>' && '&gt;' ||
+         c == '&' && '&amp;' ||
+         c == '"' && '&quot;' ||
+         '&#'+c.charCodeAt()+';'
+}
+
+
+copy(NodeType,Node);
+copy(NodeType,Node.prototype);
+
+/**
+ * @param callback return true for continue,false for break
+ * @return boolean true: break visit;
+ */
+function _visitNode(node,callback){
+	if(callback(node)){
+		return true;
+	}
+	if(node = node.firstChild){
+		do{
+			if(_visitNode(node,callback)){return true}
+        }while(node=node.nextSibling)
+    }
+}
+
+
+
+function Document(){
+}
+function _onAddAttribute(doc,el,newAttr){
+	doc && doc._inc++;
+	var ns = newAttr.namespaceURI ;
+	if(ns == 'http://www.w3.org/2000/xmlns/'){
+		//update namespace
+		el._nsMap[newAttr.prefix?newAttr.localName:''] = newAttr.value
+	}
+}
+function _onRemoveAttribute(doc,el,newAttr,remove){
+	doc && doc._inc++;
+	var ns = newAttr.namespaceURI ;
+	if(ns == 'http://www.w3.org/2000/xmlns/'){
+		//update namespace
+		delete el._nsMap[newAttr.prefix?newAttr.localName:'']
+	}
+}
+function _onUpdateChild(doc,el,newChild){
+	if(doc && doc._inc){
+		doc._inc++;
+		//update childNodes
+		var cs = el.childNodes;
+		if(newChild){
+			cs[cs.length++] = newChild;
+		}else{
+			//console.log(1)
+			var child = el.firstChild;
+			var i = 0;
+			while(child){
+				cs[i++] = child;
+				child =child.nextSibling;
+			}
+			cs.length = i;
+		}
+	}
+}
+
+/**
+ * attributes;
+ * children;
+ * 
+ * writeable properties:
+ * nodeValue,Attr:value,CharacterData:data
+ * prefix
+ */
+function _removeChild(parentNode,child){
+	var previous = child.previousSibling;
+	var next = child.nextSibling;
+	if(previous){
+		previous.nextSibling = next;
+	}else{
+		parentNode.firstChild = next
+	}
+	if(next){
+		next.previousSibling = previous;
+	}else{
+		parentNode.lastChild = previous;
+	}
+	_onUpdateChild(parentNode.ownerDocument,parentNode);
+	return child;
+}
+/**
+ * preformance key(refChild == null)
+ */
+function _insertBefore(parentNode,newChild,nextChild){
+	var cp = newChild.parentNode;
+	if(cp){
+		cp.removeChild(newChild);//remove and update
+	}
+	if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
+		var newFirst = newChild.firstChild;
+		if (newFirst == null) {
+			return newChild;
+		}
+		var newLast = newChild.lastChild;
+	}else{
+		newFirst = newLast = newChild;
+	}
+	var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild;
+
+	newFirst.previousSibling = pre;
+	newLast.nextSibling = nextChild;
+	
+	
+	if(pre){
+		pre.nextSibling = newFirst;
+	}else{
+		parentNode.firstChild = newFirst;
+	}
+	if(nextChild == null){
+		parentNode.lastChild = newLast;
+	}else{
+		nextChild.previousSibling = newLast;
+	}
+	do{
+		newFirst.parentNode = parentNode;
+	}while(newFirst !== newLast && (newFirst= newFirst.nextSibling))
+	_onUpdateChild(parentNode.ownerDocument||parentNode,parentNode);
+	//console.log(parentNode.lastChild.nextSibling == null)
+	if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
+		newChild.firstChild = newChild.lastChild = null;
+	}
+	return newChild;
+}
+function _appendSingleChild(parentNode,newChild){
+	var cp = newChild.parentNode;
+	if(cp){
+		var pre = parentNode.lastChild;
+		cp.removeChild(newChild);//remove and update
+		var pre = parentNode.lastChild;
+	}
+	var pre = parentNode.lastChild;
+	newChild.parentNode = parentNode;
+	newChild.previousSibling = pre;
+	newChild.nextSibling = null;
+	if(pre){
+		pre.nextSibling = newChild;
+	}else{
+		parentNode.firstChild = newChild;
+	}
+	parentNode.lastChild = newChild;
+	_onUpdateChild(parentNode.ownerDocument,parentNode,newChild);
+	return newChild;
+	//console.log("__aa",parentNode.lastChild.nextSibling == null)
+}
+Document.prototype = {
+	//implementation : null,
+	nodeName :  '#document',
+	nodeType :  DOCUMENT_NODE,
+	doctype :  null,
+	documentElement :  null,
+	_inc : 1,
+	
+	insertBefore :  function(newChild, refChild){//raises 
+		if(newChild.nodeType == DOCUMENT_FRAGMENT_NODE){
+			var child = newChild.firstChild;
+			while(child){
+				var next = child.nextSibling;
+				this.insertBefore(child,refChild);
+				child = next;
+			}
+			return newChild;
+		}
+		if(this.documentElement == null && newChild.nodeType == ELEMENT_NODE){
+			this.documentElement = newChild;
+		}
+		
+		return _insertBefore(this,newChild,refChild),(newChild.ownerDocument = this),newChild;
+	},
+	removeChild :  function(oldChild){
+		if(this.documentElement == oldChild){
+			this.documentElement = null;
+		}
+		return _removeChild(this,oldChild);
+	},
+	// Introduced in DOM Level 2:
+	importNode : function(importedNode,deep){
+		return importNode(this,importedNode,deep);
+	},
+	// Introduced in DOM Level 2:
+	getElementById :	function(id){
+		var rtv = null;
+		_visitNode(this.documentElement,function(node){
+			if(node.nodeType == ELEMENT_NODE){
+				if(node.getAttribute('id') == id){
+					rtv = node;
+					return true;
+				}
+			}
+		})
+		return rtv;
+	},
+	
+	//document factory method:
+	createElement :	function(tagName){
+		var node = new Element();
+		node.ownerDocument = this;
+		node.nodeName = tagName;
+		node.tagName = tagName;
+		node.childNodes = new NodeList();
+		var attrs	= node.attributes = new NamedNodeMap();
+		attrs._ownerElement = node;
+		return node;
+	},
+	createDocumentFragment :	function(){
+		var node = new DocumentFragment();
+		node.ownerDocument = this;
+		node.childNodes = new NodeList();
+		return node;
+	},
+	createTextNode :	function(data){
+		var node = new Text();
+		node.ownerDocument = this;
+		node.appendData(data)
+		return node;
+	},
+	createComment :	function(data){
+		var node = new Comment();
+		node.ownerDocument = this;
+		node.appendData(data)
+		return node;
+	},
+	createCDATASection :	function(data){
+		var node = new CDATASection();
+		node.ownerDocument = this;
+		node.appendData(data)
+		return node;
+	},
+	createProcessingInstruction :	function(target,data){
+		var node = new ProcessingInstruction();
+		node.ownerDocument = this;
+		node.tagName = node.target = target;
+		node.nodeValue= node.data = data;
+		return node;
+	},
+	createAttribute :	function(name){
+		var node = new Attr();
+		node.ownerDocument	= this;
+		node.name = name;
+		node.nodeName	= name;
+		node.localName = name;
+		node.specified = true;
+		return node;
+	},
+	createEntityReference :	function(name){
+		var node = new EntityReference();
+		node.ownerDocument	= this;
+		node.nodeName	= name;
+		return node;
+	},
+	// Introduced in DOM Level 2:
+	createElementNS :	function(namespaceURI,qualifiedName){
+		var node = new Element();
+		var pl = qualifiedName.split(':');
+		var attrs	= node.attributes = new NamedNodeMap();
+		node.childNodes = new NodeList();
+		node.ownerDocument = this;
+		node.nodeName = qualifiedName;
+		node.tagName = qualifiedName;
+		node.namespaceURI = namespaceURI;
+		if(pl.length == 2){
+			node.prefix = pl[0];
+			node.localName = pl[1];
+		}else{
+			//el.prefix = null;
+			node.localName = qualifiedName;
+		}
+		attrs._ownerElement = node;
+		return node;
+	},
+	// Introduced in DOM Level 2:
+	createAttributeNS :	function(namespaceURI,qualifiedName){
+		var node = new Attr();
+		var pl = qualifiedName.split(':');
+		node.ownerDocument = this;
+		node.nodeName = qualifiedName;
+		node.name = qualifiedName;
+		node.namespaceURI = namespaceURI;
+		node.specified = true;
+		if(pl.length == 2){
+			node.prefix = pl[0];
+			node.localName = pl[1];
+		}else{
+			//el.prefix = null;
+			node.localName = qualifiedName;
+		}
+		return node;
+	}
+};
+_extends(Document,Node);
+
+
+function Element() {
+	this._nsMap = {};
+};
+Element.prototype = {
+	nodeType : ELEMENT_NODE,
+	hasAttribute : function(name){
+		return this.getAttributeNode(name)!=null;
+	},
+	getAttribute : function(name){
+		var attr = this.getAttributeNode(name);
+		return attr && attr.value || '';
+	},
+	getAttributeNode : function(name){
+		return this.attributes.getNamedItem(name);
+	},
+	setAttribute : function(name, value){
+		var attr = this.ownerDocument.createAttribute(name);
+		attr.value = attr.nodeValue = "" + value;
+		this.setAttributeNode(attr)
+	},
+	removeAttribute : function(name){
+		var attr = this.getAttributeNode(name)
+		attr && this.removeAttributeNode(attr);
+	},
+	
+	//four real opeartion method
+	appendChild:function(newChild){
+		if(newChild.nodeType === DOCUMENT_FRAGMENT_NODE){
+			return this.insertBefore(newChild,null);
+		}else{
+			return _appendSingleChild(this,newChild);
+		}
+	},
+	setAttributeNode : function(newAttr){
+		return this.attributes.setNamedItem(newAttr);
+	},
+	setAttributeNodeNS : function(newAttr){
+		return this.attributes.setNamedItemNS(newAttr);
+	},
+	removeAttributeNode : function(oldAttr){
+		//console.log(this == oldAttr.ownerElement)
+		return this.attributes.removeNamedItem(oldAttr.nodeName);
+	},
+	//get real attribute name,and remove it by removeAttributeNode
+	removeAttributeNS : function(namespaceURI, localName){
+		var old = this.getAttributeNodeNS(namespaceURI, localName);
+		old && this.removeAttributeNode(old);
+	},
+	
+	hasAttributeNS : function(namespaceURI, localName){
+		return this.getAttributeNodeNS(namespaceURI, localName)!=null;
+	},
+	getAttributeNS : function(namespaceURI, localName){
+		var attr = this.getAttributeNodeNS(namespaceURI, localName);
+		return attr && attr.value || '';
+	},
+	setAttributeNS : function(namespaceURI, qualifiedName, value){
+		var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
+		attr.value = attr.nodeValue = "" + value;
+		this.setAttributeNode(attr)
+	},
+	getAttributeNodeNS : function(namespaceURI, localName){
+		return this.attributes.getNamedItemNS(namespaceURI, localName);
+	},
+	
+	getElementsByTagName : function(tagName){
+		return new LiveNodeList(this,function(base){
+			var ls = [];
+			_visitNode(base,function(node){
+				if(node !== base && node.nodeType == ELEMENT_NODE && (tagName === '*' || node.tagName == tagName)){
+					ls.push(node);
+				}
+			});
+			return ls;
+		});
+	},
+	getElementsByTagNameNS : function(namespaceURI, localName){
+		return new LiveNodeList(this,function(base){
+			var ls = [];
+			_visitNode(base,function(node){
+				if(node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === '*' || node.namespaceURI === namespaceURI) && (localName === '*' || node.localName == localName)){
+					ls.push(node);
+				}
+			});
+			return ls;
+			
+		});
+	}
+};
+Document.prototype.getElementsByTagName = Element.prototype.getElementsByTagName;
+Document.prototype.getElementsByTagNameNS = Element.prototype.getElementsByTagNameNS;
+
+
+_extends(Element,Node);
+function Attr() {
+};
+Attr.prototype.nodeType = ATTRIBUTE_NODE;
+_extends(Attr,Node);
+
+
+function CharacterData() {
+};
+CharacterData.prototype = {
+	data : '',
+	substringData : function(offset, count) {
+		return this.data.substring(offset, offset+count);
+	},
+	appendData: function(text) {
+		text = this.data+text;
+		this.nodeValue = this.data = text;
+		this.length = text.length;
+	},
+	insertData: function(offset,text) {
+		this.replaceData(offset,0,text);
+	
+	},
+	appendChild:function(newChild){
+		throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR])
+	},
+	deleteData: function(offset, count) {
+		this.replaceData(offset,count,"");
+	},
+	replaceData: function(offset, count, text) {
+		var start = this.data.substring(0,offset);
+		var end = this.data.substring(offset+count);
+		text = start + text + end;
+		this.nodeValue = this.data = text;
+		this.length = text.length;
+	}
+}
+_extends(CharacterData,Node);
+function Text() {
+};
+Text.prototype = {
+	nodeName : "#text",
+	nodeType : TEXT_NODE,
+	splitText : function(offset) {
+		var text = this.data;
+		var newText = text.substring(offset);
+		text = text.substring(0, offset);
+		this.data = this.nodeValue = text;
+		this.length = text.length;
+		var newNode = this.ownerDocument.createTextNode(newText);
+		if(this.parentNode){
+			this.parentNode.insertBefore(newNode, this.nextSibling);
+		}
+		return newNode;
+	}
+}
+_extends(Text,CharacterData);
+function Comment() {
+};
+Comment.prototype = {
+	nodeName : "#comment",
+	nodeType : COMMENT_NODE
+}
+_extends(Comment,CharacterData);
+
+function CDATASection() {
+};
+CDATASection.prototype = {
+	nodeName : "#cdata-section",
+	nodeType : CDATA_SECTION_NODE
+}
+_extends(CDATASection,CharacterData);
+
+
+function DocumentType() {
+};
+DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
+_extends(DocumentType,Node);
+
+function Notation() {
+};
+Notation.prototype.nodeType = NOTATION_NODE;
+_extends(Notation,Node);
+
+function Entity() {
+};
+Entity.prototype.nodeType = ENTITY_NODE;
+_extends(Entity,Node);
+
+function EntityReference() {
+};
+EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
+_extends(EntityReference,Node);
+
+function DocumentFragment() {
+};
+DocumentFragment.prototype.nodeName =	"#document-fragment";
+DocumentFragment.prototype.nodeType =	DOCUMENT_FRAGMENT_NODE;
+_extends(DocumentFragment,Node);
+
+
+function ProcessingInstruction() {
+}
+ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
+_extends(ProcessingInstruction,Node);
+function XMLSerializer(){}
+XMLSerializer.prototype.serializeToString = function(node,isHtml,nodeFilter){
+	return nodeSerializeToString.call(node,isHtml,nodeFilter);
+}
+Node.prototype.toString = nodeSerializeToString;
+function nodeSerializeToString(isHtml,nodeFilter){
+	var buf = [];
+	var refNode = this.nodeType == 9 && this.documentElement || this;
+	var prefix = refNode.prefix;
+	var uri = refNode.namespaceURI;
+	
+	if(uri && prefix == null){
+		//console.log(prefix)
+		var prefix = refNode.lookupPrefix(uri);
+		if(prefix == null){
+			//isHTML = true;
+			var visibleNamespaces=[
+			{namespace:uri,prefix:null}
+			//{namespace:uri,prefix:''}
+			]
+		}
+	}
+	serializeToString(this,buf,isHtml,nodeFilter,visibleNamespaces);
+	//console.log('###',this.nodeType,uri,prefix,buf.join(''))
+	return buf.join('');
+}
+function needNamespaceDefine(node,isHTML, visibleNamespaces) {
+	var prefix = node.prefix||'';
+	var uri = node.namespaceURI;
+	if (!prefix && !uri){
+		return false;
+	}
+	if (prefix === "xml" && uri === "http://www.w3.org/XML/1998/namespace" 
+		|| uri == 'http://www.w3.org/2000/xmlns/'){
+		return false;
+	}
+	
+	var i = visibleNamespaces.length 
+	//console.log('@@@@',node.tagName,prefix,uri,visibleNamespaces)
+	while (i--) {
+		var ns = visibleNamespaces[i];
+		// get namespace prefix
+		//console.log(node.nodeType,node.tagName,ns.prefix,prefix)
+		if (ns.prefix == prefix){
+			return ns.namespace != uri;
+		}
+	}
+	//console.log(isHTML,uri,prefix=='')
+	//if(isHTML && prefix ==null && uri == 'http://www.w3.org/1999/xhtml'){
+	//	return false;
+	//}
+	//node.flag = '11111'
+	//console.error(3,true,node.flag,node.prefix,node.namespaceURI)
+	return true;
+}
+function serializeToString(node,buf,isHTML,nodeFilter,visibleNamespaces){
+	if(nodeFilter){
+		node = nodeFilter(node);
+		if(node){
+			if(typeof node == 'string'){
+				buf.push(node);
+				return;
+			}
+		}else{
+			return;
+		}
+		//buf.sort.apply(attrs, attributeSorter);
+	}
+	switch(node.nodeType){
+	case ELEMENT_NODE:
+		if (!visibleNamespaces) visibleNamespaces = [];
+		var startVisibleNamespaces = visibleNamespaces.length;
+		var attrs = node.attributes;
+		var len = attrs.length;
+		var child = node.firstChild;
+		var nodeName = node.tagName;
+		
+		isHTML =  (htmlns === node.namespaceURI) ||isHTML 
+		buf.push('<',nodeName);
+		
+		
+		
+		for(var i=0;i<len;i++){
+			// add namespaces for attributes
+			var attr = attrs.item(i);
+			if (attr.prefix == 'xmlns') {
+				visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
+			}else if(attr.nodeName == 'xmlns'){
+				visibleNamespaces.push({ prefix: '', namespace: attr.value });
+			}
+		}
+		for(var i=0;i<len;i++){
+			var attr = attrs.item(i);
+			if (needNamespaceDefine(attr,isHTML, visibleNamespaces)) {
+				var prefix = attr.prefix||'';
+				var uri = attr.namespaceURI;
+				var ns = prefix ? ' xmlns:' + prefix : " xmlns";
+				buf.push(ns, '="' , uri , '"');
+				visibleNamespaces.push({ prefix: prefix, namespace:uri });
+			}
+			serializeToString(attr,buf,isHTML,nodeFilter,visibleNamespaces);
+		}
+		// add namespace for current node		
+		if (needNamespaceDefine(node,isHTML, visibleNamespaces)) {
+			var prefix = node.prefix||'';
+			var uri = node.namespaceURI;
+			var ns = prefix ? ' xmlns:' + prefix : " xmlns";
+			buf.push(ns, '="' , uri , '"');
+			visibleNamespaces.push({ prefix: prefix, namespace:uri });
+		}
+		
+		if(child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)){
+			buf.push('>');
+			//if is cdata child node
+			if(isHTML && /^script$/i.test(nodeName)){
+				while(child){
+					if(child.data){
+						buf.push(child.data);
+					}else{
+						serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
+					}
+					child = child.nextSibling;
+				}
+			}else
+			{
+				while(child){
+					serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
+					child = child.nextSibling;
+				}
+			}
+			buf.push('</',nodeName,'>');
+		}else{
+			buf.push('/>');
+		}
+		// remove added visible namespaces
+		//visibleNamespaces.length = startVisibleNamespaces;
+		return;
+	case DOCUMENT_NODE:
+	case DOCUMENT_FRAGMENT_NODE:
+		var child = node.firstChild;
+		while(child){
+			serializeToString(child,buf,isHTML,nodeFilter,visibleNamespaces);
+			child = child.nextSibling;
+		}
+		return;
+	case ATTRIBUTE_NODE:
+		return buf.push(' ',node.name,'="',node.value.replace(/[<&"]/g,_xmlEncoder),'"');
+	case TEXT_NODE:
+		return buf.push(node.data.replace(/[<&]/g,_xmlEncoder));
+	case CDATA_SECTION_NODE:
+		return buf.push( '<![CDATA[',node.data,']]>');
+	case COMMENT_NODE:
+		return buf.push( "<!--",node.data,"-->");
+	case DOCUMENT_TYPE_NODE:
+		var pubid = node.publicId;
+		var sysid = node.systemId;
+		buf.push('<!DOCTYPE ',node.name);
+		if(pubid){
+			buf.push(' PUBLIC "',pubid);
+			if (sysid && sysid!='.') {
+				buf.push( '" "',sysid);
+			}
+			buf.push('">');
+		}else if(sysid && sysid!='.'){
+			buf.push(' SYSTEM "',sysid,'">');
+		}else{
+			var sub = node.internalSubset;
+			if(sub){
+				buf.push(" [",sub,"]");
+			}
+			buf.push(">");
+		}
+		return;
+	case PROCESSING_INSTRUCTION_NODE:
+		return buf.push( "<?",node.target," ",node.data,"?>");
+	case ENTITY_REFERENCE_NODE:
+		return buf.push( '&',node.nodeName,';');
+	//case ENTITY_NODE:
+	//case NOTATION_NODE:
+	default:
+		buf.push('??',node.nodeName);
+	}
+}
+function importNode(doc,node,deep){
+	var node2;
+	switch (node.nodeType) {
+	case ELEMENT_NODE:
+		node2 = node.cloneNode(false);
+		node2.ownerDocument = doc;
+		//var attrs = node2.attributes;
+		//var len = attrs.length;
+		//for(var i=0;i<len;i++){
+			//node2.setAttributeNodeNS(importNode(doc,attrs.item(i),deep));
+		//}
+	case DOCUMENT_FRAGMENT_NODE:
+		break;
+	case ATTRIBUTE_NODE:
+		deep = true;
+		break;
+	//case ENTITY_REFERENCE_NODE:
+	//case PROCESSING_INSTRUCTION_NODE:
+	////case TEXT_NODE:
+	//case CDATA_SECTION_NODE:
+	//case COMMENT_NODE:
+	//	deep = false;
+	//	break;
+	//case DOCUMENT_NODE:
+	//case DOCUMENT_TYPE_NODE:
+	//cannot be imported.
+	//case ENTITY_NODE:
+	//case NOTATION_NODE:
+	//can not hit in level3
+	//default:throw e;
+	}
+	if(!node2){
+		node2 = node.cloneNode(false);//false
+	}
+	node2.ownerDocument = doc;
+	node2.parentNode = null;
+	if(deep){
+		var child = node.firstChild;
+		while(child){
+			node2.appendChild(importNode(doc,child,deep));
+			child = child.nextSibling;
+		}
+	}
+	return node2;
+}
+//
+//var _relationMap = {firstChild:1,lastChild:1,previousSibling:1,nextSibling:1,
+//					attributes:1,childNodes:1,parentNode:1,documentElement:1,doctype,};
+function cloneNode(doc,node,deep){
+	var node2 = new node.constructor();
+	for(var n in node){
+		var v = node[n];
+		if(typeof v != 'object' ){
+			if(v != node2[n]){
+				node2[n] = v;
+			}
+		}
+	}
+	if(node.childNodes){
+		node2.childNodes = new NodeList();
+	}
+	node2.ownerDocument = doc;
+	switch (node2.nodeType) {
+	case ELEMENT_NODE:
+		var attrs	= node.attributes;
+		var attrs2	= node2.attributes = new NamedNodeMap();
+		var len = attrs.length
+		attrs2._ownerElement = node2;
+		for(var i=0;i<len;i++){
+			node2.setAttributeNode(cloneNode(doc,attrs.item(i),true));
+		}
+		break;;
+	case ATTRIBUTE_NODE:
+		deep = true;
+	}
+	if(deep){
+		var child = node.firstChild;
+		while(child){
+			node2.appendChild(cloneNode(doc,child,deep));
+			child = child.nextSibling;
+		}
+	}
+	return node2;
+}
+
+function __set__(object,key,value){
+	object[key] = value
+}
+//do dynamic
+try{
+	if(Object.defineProperty){
+		Object.defineProperty(LiveNodeList.prototype,'length',{
+			get:function(){
+				_updateLiveList(this);
+				return this.$$length;
+			}
+		});
+		Object.defineProperty(Node.prototype,'textContent',{
+			get:function(){
+				return getTextContent(this);
+			},
+			set:function(data){
+				switch(this.nodeType){
+				case ELEMENT_NODE:
+				case DOCUMENT_FRAGMENT_NODE:
+					while(this.firstChild){
+						this.removeChild(this.firstChild);
+					}
+					if(data || String(data)){
+						this.appendChild(this.ownerDocument.createTextNode(data));
+					}
+					break;
+				default:
+					//TODO:
+					this.data = data;
+					this.value = data;
+					this.nodeValue = data;
+				}
+			}
+		})
+		
+		function getTextContent(node){
+			switch(node.nodeType){
+			case ELEMENT_NODE:
+			case DOCUMENT_FRAGMENT_NODE:
+				var buf = [];
+				node = node.firstChild;
+				while(node){
+					if(node.nodeType!==7 && node.nodeType !==8){
+						buf.push(getTextContent(node));
+					}
+					node = node.nextSibling;
+				}
+				return buf.join('');
+			default:
+				return node.nodeValue;
+			}
+		}
+		__set__ = function(object,key,value){
+			//console.log(value)
+			object['$$'+key] = value
+		}
+	}
+}catch(e){//ie8
+}
+
+if(typeof require == 'function'){
+	exports.DOMImplementation = DOMImplementation;
+	exports.XMLSerializer = XMLSerializer;
+}
+
+function DOMParser(options){
+	this.options = options ||{locator:{}};
+	
+}
+
+DOMParser.prototype.parseFromString = function(source,mimeType){
+	var options = this.options;
+	var sax =  new XMLReader();
+	var domBuilder = options.domBuilder || new DOMHandler();//contentHandler and LexicalHandler
+	var errorHandler = options.errorHandler;
+	var locator = options.locator;
+	var defaultNSMap = options.xmlns||{};
+	var isHTML = /\/x?html?$/.test(mimeType);//mimeType.toLowerCase().indexOf('html') > -1;
+  	var entityMap = isHTML?htmlEntity.entityMap:{'lt':'<','gt':'>','amp':'&','quot':'"','apos':"'"};
+	if(locator){
+		domBuilder.setDocumentLocator(locator)
+	}
+	
+	sax.errorHandler = buildErrorHandler(errorHandler,domBuilder,locator);
+	sax.domBuilder = options.domBuilder || domBuilder;
+	if(isHTML){
+		defaultNSMap['']= 'http://www.w3.org/1999/xhtml';
+	}
+	defaultNSMap.xml = defaultNSMap.xml || 'http://www.w3.org/XML/1998/namespace';
+	if(source){
+		sax.parse(source,defaultNSMap,entityMap);
+	}else{
+		sax.errorHandler.error("invalid doc source");
+	}
+	return domBuilder.doc;
+}
+function buildErrorHandler(errorImpl,domBuilder,locator){
+	if(!errorImpl){
+		if(domBuilder instanceof DOMHandler){
+			return domBuilder;
+		}
+		errorImpl = domBuilder ;
+	}
+	var errorHandler = {}
+	var isCallback = errorImpl instanceof Function;
+	locator = locator||{}
+	function build(key){
+		var fn = errorImpl[key];
+		if(!fn && isCallback){
+			fn = errorImpl.length == 2?function(msg){errorImpl(key,msg)}:errorImpl;
+		}
+		errorHandler[key] = fn && function(msg){
+			fn('[xmldom '+key+']\t'+msg+_locator(locator));
+		}||function(){};
+	}
+	build('warning');
+	build('error');
+	build('fatalError');
+	return errorHandler;
+}
+
+//console.log('#\n\n\n\n\n\n\n####')
+/**
+ * +ContentHandler+ErrorHandler
+ * +LexicalHandler+EntityResolver2
+ * -DeclHandler-DTDHandler 
+ * 
+ * DefaultHandler:EntityResolver, DTDHandler, ContentHandler, ErrorHandler
+ * DefaultHandler2:DefaultHandler,LexicalHandler, DeclHandler, EntityResolver2
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/helpers/DefaultHandler.html
+ */
+function DOMHandler() {
+    this.cdata = false;
+}
+function position(locator,node){
+	node.lineNumber = locator.lineNumber;
+	node.columnNumber = locator.columnNumber;
+}
+/**
+ * @see org.xml.sax.ContentHandler#startDocument
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html
+ */ 
+DOMHandler.prototype = {
+	startDocument : function() {
+    	this.doc = new DOMImplementation().createDocument(null, null, null);
+    	if (this.locator) {
+        	this.doc.documentURI = this.locator.systemId;
+    	}
+	},
+	startElement:function(namespaceURI, localName, qName, attrs) {
+		var doc = this.doc;
+	    var el = doc.createElementNS(namespaceURI, qName||localName);
+	    var len = attrs.length;
+	    appendElement(this, el);
+	    this.currentElement = el;
+	    
+		this.locator && position(this.locator,el)
+	    for (var i = 0 ; i < len; i++) {
+	        var namespaceURI = attrs.getURI(i);
+	        var value = attrs.getValue(i);
+	        var qName = attrs.getQName(i);
+			var attr = doc.createAttributeNS(namespaceURI, qName);
+			this.locator &&position(attrs.getLocator(i),attr);
+			attr.value = attr.nodeValue = value;
+			el.setAttributeNode(attr)
+	    }
+	},
+	endElement:function(namespaceURI, localName, qName) {
+		var current = this.currentElement
+		var tagName = current.tagName;
+		this.currentElement = current.parentNode;
+	},
+	startPrefixMapping:function(prefix, uri) {
+	},
+	endPrefixMapping:function(prefix) {
+	},
+	processingInstruction:function(target, data) {
+	    var ins = this.doc.createProcessingInstruction(target, data);
+	    this.locator && position(this.locator,ins)
+	    appendElement(this, ins);
+	},
+	ignorableWhitespace:function(ch, start, length) {
+	},
+	characters:function(chars, start, length) {
+		chars = _toString.apply(this,arguments)
+		//console.log(chars)
+		if(chars){
+			if (this.cdata) {
+				var charNode = this.doc.createCDATASection(chars);
+			} else {
+				var charNode = this.doc.createTextNode(chars);
+			}
+			if(this.currentElement){
+				this.currentElement.appendChild(charNode);
+			}else if(/^\s*$/.test(chars)){
+				this.doc.appendChild(charNode);
+				//process xml
+			}
+			this.locator && position(this.locator,charNode)
+		}
+	},
+	skippedEntity:function(name) {
+	},
+	endDocument:function() {
+		this.doc.normalize();
+	},
+	setDocumentLocator:function (locator) {
+	    if(this.locator = locator){// && !('lineNumber' in locator)){
+	    	locator.lineNumber = 0;
+	    }
+	},
+	//LexicalHandler
+	comment:function(chars, start, length) {
+		chars = _toString.apply(this,arguments)
+	    var comm = this.doc.createComment(chars);
+	    this.locator && position(this.locator,comm)
+	    appendElement(this, comm);
+	},
+	
+	startCDATA:function() {
+	    //used in characters() methods
+	    this.cdata = true;
+	},
+	endCDATA:function() {
+	    this.cdata = false;
+	},
+	
+	startDTD:function(name, publicId, systemId) {
+		var impl = this.doc.implementation;
+	    if (impl && impl.createDocumentType) {
+	        var dt = impl.createDocumentType(name, publicId, systemId);
+	        this.locator && position(this.locator,dt)
+	        appendElement(this, dt);
+	    }
+	},
+	/**
+	 * @see org.xml.sax.ErrorHandler
+	 * @link http://www.saxproject.org/apidoc/org/xml/sax/ErrorHandler.html
+	 */
+	warning:function(error) {
+		console.warn('[xmldom warning]\t'+error,_locator(this.locator));
+	},
+	error:function(error) {
+		console.error('[xmldom error]\t'+error,_locator(this.locator));
+	},
+	fatalError:function(error) {
+		console.error('[xmldom fatalError]\t'+error,_locator(this.locator));
+	    throw error;
+	}
+}
+function _locator(l){
+	if(l){
+		return '\n@'+(l.systemId ||'')+'#[line:'+l.lineNumber+',col:'+l.columnNumber+']'
+	}
+}
+function _toString(chars,start,length){
+	if(typeof chars == 'string'){
+		return chars.substr(start,length)
+	}else{//java sax connect width xmldom on rhino(what about: "? && !(chars instanceof String)")
+		if(chars.length >= start+length || start){
+			return new java.lang.String(chars,start,length)+'';
+		}
+		return chars;
+	}
+}
+
+/*
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/LexicalHandler.html
+ * used method of org.xml.sax.ext.LexicalHandler:
+ *  #comment(chars, start, length)
+ *  #startCDATA()
+ *  #endCDATA()
+ *  #startDTD(name, publicId, systemId)
+ *
+ *
+ * IGNORED method of org.xml.sax.ext.LexicalHandler:
+ *  #endDTD()
+ *  #startEntity(name)
+ *  #endEntity(name)
+ *
+ *
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/DeclHandler.html
+ * IGNORED method of org.xml.sax.ext.DeclHandler
+ * 	#attributeDecl(eName, aName, type, mode, value)
+ *  #elementDecl(name, model)
+ *  #externalEntityDecl(name, publicId, systemId)
+ *  #internalEntityDecl(name, value)
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/ext/EntityResolver2.html
+ * IGNORED method of org.xml.sax.EntityResolver2
+ *  #resolveEntity(String name,String publicId,String baseURI,String systemId)
+ *  #resolveEntity(publicId, systemId)
+ *  #getExternalSubset(name, baseURI)
+ * @link http://www.saxproject.org/apidoc/org/xml/sax/DTDHandler.html
+ * IGNORED method of org.xml.sax.DTDHandler
+ *  #notationDecl(name, publicId, systemId) {};
+ *  #unparsedEntityDecl(name, publicId, systemId, notationName) {};
+ */
+"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g,function(key){
+	DOMHandler.prototype[key] = function(){return null}
+})
+
+/* Private static helpers treated below as private instance methods, so don't need to add these to the public API; we might use a Relator to also get rid of non-standard public properties */
+function appendElement (hander,node) {
+    if (!hander.currentElement) {
+        hander.doc.appendChild(node);
+    } else {
+        hander.currentElement.appendChild(node);
+    }
+}//appendChild and setAttributeNS are preformance key
+
+
+	htmlEntity={};
+	htmlEntity.entityMap=entityMap;
+
+
+
+window.Parser = { DOMParser :DOMParser};

+ 4209 - 0
ShootingSun/bin/libs/laya.ani.js

@@ -0,0 +1,4209 @@
+(function (exports, Laya) {
+    'use strict';
+
+    class IAniLib {
+    }
+    IAniLib.Skeleton = null;
+    IAniLib.AnimationTemplet = null;
+    IAniLib.Templet = null;
+
+    class AnimationContent {
+    }
+
+    class AnimationNodeContent {
+    }
+
+    class KeyFramesContent {
+    }
+
+    class AnimationParser01 {
+        static parse(templet, reader) {
+            var data = reader.__getBuffer();
+            var i, j, k, n, l, m, o;
+            var aniClassName = reader.readUTFString();
+            templet._aniClassName = aniClassName;
+            var strList = reader.readUTFString().split("\n");
+            var aniCount = reader.getUint8();
+            var publicDataPos = reader.getUint32();
+            var publicExtDataPos = reader.getUint32();
+            var publicData;
+            if (publicDataPos > 0)
+                publicData = data.slice(publicDataPos, publicExtDataPos);
+            var publicRead = new Laya.Byte(publicData);
+            if (publicExtDataPos > 0)
+                templet._publicExtData = data.slice(publicExtDataPos, data.byteLength);
+            templet._useParent = !!reader.getUint8();
+            templet._anis.length = aniCount;
+            for (i = 0; i < aniCount; i++) {
+                var ani = templet._anis[i] = new AnimationContent();
+                ani.nodes = [];
+                var name = ani.name = strList[reader.getUint16()];
+                templet._aniMap[name] = i;
+                ani.bone3DMap = {};
+                ani.playTime = reader.getFloat32();
+                var boneCount = ani.nodes.length = reader.getUint8();
+                ani.totalKeyframeDatasLength = 0;
+                for (j = 0; j < boneCount; j++) {
+                    var node = ani.nodes[j] = new AnimationNodeContent();
+                    node.childs = [];
+                    var nameIndex = reader.getInt16();
+                    if (nameIndex >= 0) {
+                        node.name = strList[nameIndex];
+                        ani.bone3DMap[node.name] = j;
+                    }
+                    node.keyFrame = [];
+                    node.parentIndex = reader.getInt16();
+                    node.parentIndex == -1 ? node.parent = null : node.parent = ani.nodes[node.parentIndex];
+                    node.lerpType = reader.getUint8();
+                    var keyframeParamsOffset = reader.getUint32();
+                    publicRead.pos = keyframeParamsOffset;
+                    var keyframeDataCount = node.keyframeWidth = publicRead.getUint16();
+                    ani.totalKeyframeDatasLength += keyframeDataCount;
+                    if (node.lerpType === 0 || node.lerpType === 1) {
+                        node.interpolationMethod = [];
+                        node.interpolationMethod.length = keyframeDataCount;
+                        for (k = 0; k < keyframeDataCount; k++)
+                            node.interpolationMethod[k] = IAniLib.AnimationTemplet.interpolation[publicRead.getUint8()];
+                    }
+                    if (node.parent != null)
+                        node.parent.childs.push(node);
+                    var privateDataLen = reader.getUint16();
+                    if (privateDataLen > 0) {
+                        node.extenData = data.slice(reader.pos, reader.pos + privateDataLen);
+                        reader.pos += privateDataLen;
+                    }
+                    var keyframeCount = reader.getUint16();
+                    node.keyFrame.length = keyframeCount;
+                    var startTime = 0;
+                    var keyFrame;
+                    for (k = 0, n = keyframeCount; k < n; k++) {
+                        keyFrame = node.keyFrame[k] = new KeyFramesContent();
+                        keyFrame.duration = reader.getFloat32();
+                        keyFrame.startTime = startTime;
+                        if (node.lerpType === 2) {
+                            keyFrame.interpolationData = [];
+                            var interDataLength = reader.getUint8();
+                            var lerpType;
+                            lerpType = reader.getFloat32();
+                            switch (lerpType) {
+                                case 254:
+                                    keyFrame.interpolationData.length = keyframeDataCount;
+                                    for (o = 0; o < keyframeDataCount; o++)
+                                        keyFrame.interpolationData[o] = 0;
+                                    break;
+                                case 255:
+                                    keyFrame.interpolationData.length = keyframeDataCount;
+                                    for (o = 0; o < keyframeDataCount; o++)
+                                        keyFrame.interpolationData[o] = 5;
+                                    break;
+                                default:
+                                    keyFrame.interpolationData.push(lerpType);
+                                    for (m = 1; m < interDataLength; m++) {
+                                        keyFrame.interpolationData.push(reader.getFloat32());
+                                    }
+                            }
+                        }
+                        keyFrame.data = new Float32Array(keyframeDataCount);
+                        keyFrame.dData = new Float32Array(keyframeDataCount);
+                        keyFrame.nextData = new Float32Array(keyframeDataCount);
+                        for (l = 0; l < keyframeDataCount; l++) {
+                            keyFrame.data[l] = reader.getFloat32();
+                            if (keyFrame.data[l] > -0.00000001 && keyFrame.data[l] < 0.00000001)
+                                keyFrame.data[l] = 0;
+                        }
+                        startTime += keyFrame.duration;
+                    }
+                    keyFrame.startTime = ani.playTime;
+                    node.playTime = ani.playTime;
+                    templet._calculateKeyFrame(node, keyframeCount, keyframeDataCount);
+                }
+            }
+        }
+    }
+
+    class AnimationParser02 {
+        static READ_DATA() {
+            AnimationParser02._DATA.offset = AnimationParser02._reader.getUint32();
+            AnimationParser02._DATA.size = AnimationParser02._reader.getUint32();
+        }
+        static READ_BLOCK() {
+            var count = AnimationParser02._BLOCK.count = AnimationParser02._reader.getUint16();
+            var blockStarts = AnimationParser02._BLOCK.blockStarts = [];
+            var blockLengths = AnimationParser02._BLOCK.blockLengths = [];
+            for (var i = 0; i < count; i++) {
+                blockStarts.push(AnimationParser02._reader.getUint32());
+                blockLengths.push(AnimationParser02._reader.getUint32());
+            }
+        }
+        static READ_STRINGS() {
+            var offset = AnimationParser02._reader.getUint32();
+            var count = AnimationParser02._reader.getUint16();
+            var prePos = AnimationParser02._reader.pos;
+            AnimationParser02._reader.pos = offset + AnimationParser02._DATA.offset;
+            for (var i = 0; i < count; i++)
+                AnimationParser02._strings[i] = AnimationParser02._reader.readUTFString();
+            AnimationParser02._reader.pos = prePos;
+        }
+        static parse(templet, reader) {
+            AnimationParser02._templet = templet;
+            AnimationParser02._reader = reader;
+            var arrayBuffer = reader.__getBuffer();
+            AnimationParser02.READ_DATA();
+            AnimationParser02.READ_BLOCK();
+            AnimationParser02.READ_STRINGS();
+            for (var i = 0, n = AnimationParser02._BLOCK.count; i < n; i++) {
+                var index = reader.getUint16();
+                var blockName = AnimationParser02._strings[index];
+                var fn = AnimationParser02["READ_" + blockName];
+                if (fn == null)
+                    throw new Error("model file err,no this function:" + index + " " + blockName);
+                else
+                    fn.call(null);
+            }
+        }
+        static READ_ANIMATIONS() {
+            var reader = AnimationParser02._reader;
+            var arrayBuffer = reader.__getBuffer();
+            var i, j, k, n;
+            var keyframeWidth = reader.getUint16();
+            var interpolationMethod = [];
+            interpolationMethod.length = keyframeWidth;
+            for (i = 0; i < keyframeWidth; i++)
+                interpolationMethod[i] = IAniLib.AnimationTemplet.interpolation[reader.getByte()];
+            var aniCount = reader.getUint8();
+            AnimationParser02._templet._anis.length = aniCount;
+            for (i = 0; i < aniCount; i++) {
+                var ani = AnimationParser02._templet._anis[i] = new AnimationContent();
+                ani.nodes = [];
+                var aniName = ani.name = AnimationParser02._strings[reader.getUint16()];
+                AnimationParser02._templet._aniMap[aniName] = i;
+                ani.bone3DMap = {};
+                ani.playTime = reader.getFloat32();
+                var boneCount = ani.nodes.length = reader.getInt16();
+                ani.totalKeyframeDatasLength = 0;
+                for (j = 0; j < boneCount; j++) {
+                    var node = ani.nodes[j] = new AnimationNodeContent();
+                    node.keyframeWidth = keyframeWidth;
+                    node.childs = [];
+                    var nameIndex = reader.getUint16();
+                    if (nameIndex >= 0) {
+                        node.name = AnimationParser02._strings[nameIndex];
+                        ani.bone3DMap[node.name] = j;
+                    }
+                    node.keyFrame = [];
+                    node.parentIndex = reader.getInt16();
+                    node.parentIndex == -1 ? node.parent = null : node.parent = ani.nodes[node.parentIndex];
+                    ani.totalKeyframeDatasLength += keyframeWidth;
+                    node.interpolationMethod = interpolationMethod;
+                    if (node.parent != null)
+                        node.parent.childs.push(node);
+                    var keyframeCount = reader.getUint16();
+                    node.keyFrame.length = keyframeCount;
+                    var keyFrame = null, lastKeyFrame = null;
+                    for (k = 0, n = keyframeCount; k < n; k++) {
+                        keyFrame = node.keyFrame[k] = new KeyFramesContent();
+                        keyFrame.startTime = reader.getFloat32();
+                        (lastKeyFrame) && (lastKeyFrame.duration = keyFrame.startTime - lastKeyFrame.startTime);
+                        keyFrame.dData = new Float32Array(keyframeWidth);
+                        keyFrame.nextData = new Float32Array(keyframeWidth);
+                        var offset = AnimationParser02._DATA.offset;
+                        var keyframeDataOffset = reader.getUint32();
+                        var keyframeDataLength = keyframeWidth * 4;
+                        var keyframeArrayBuffer = arrayBuffer.slice(offset + keyframeDataOffset, offset + keyframeDataOffset + keyframeDataLength);
+                        keyFrame.data = new Float32Array(keyframeArrayBuffer);
+                        lastKeyFrame = keyFrame;
+                    }
+                    keyFrame.duration = 0;
+                    node.playTime = ani.playTime;
+                    AnimationParser02._templet._calculateKeyFrame(node, keyframeCount, keyframeWidth);
+                }
+            }
+        }
+    }
+    AnimationParser02._strings = [];
+    AnimationParser02._BLOCK = { count: 0 };
+    AnimationParser02._DATA = { offset: 0, size: 0 };
+
+    class AnimationState {
+        constructor() {
+        }
+    }
+    AnimationState.stopped = 0;
+    AnimationState.paused = 1;
+    AnimationState.playing = 2;
+
+    class AnimationPlayer extends Laya.EventDispatcher {
+        constructor() {
+            super();
+            this.isCache = true;
+            this.playbackRate = 1.0;
+            this._destroyed = false;
+            this._currentAnimationClipIndex = -1;
+            this._currentKeyframeIndex = -1;
+            this._currentTime = 0.0;
+            this._overallDuration = Number.MAX_VALUE;
+            this._stopWhenCircleFinish = false;
+            this._elapsedPlaybackTime = 0;
+            this._startUpdateLoopCount = -1;
+            this._cachePlayRate = 1.0;
+            this.cacheFrameRate = 60;
+            this.returnToZeroStopped = false;
+        }
+        get templet() {
+            return this._templet;
+        }
+        set templet(value) {
+            if (!(this.state === AnimationState.stopped))
+                this.stop(true);
+            if (this._templet !== value) {
+                this._templet = value;
+                this._computeFullKeyframeIndices();
+            }
+        }
+        get playStart() {
+            return this._playStart;
+        }
+        get playEnd() {
+            return this._playEnd;
+        }
+        get playDuration() {
+            return this._playDuration;
+        }
+        get overallDuration() {
+            return this._overallDuration;
+        }
+        get currentAnimationClipIndex() {
+            return this._currentAnimationClipIndex;
+        }
+        get currentKeyframeIndex() {
+            return this._currentKeyframeIndex;
+        }
+        get currentPlayTime() {
+            return this._currentTime + this._playStart;
+        }
+        get currentFrameTime() {
+            return this._currentFrameTime;
+        }
+        get cachePlayRate() {
+            return this._cachePlayRate;
+        }
+        set cachePlayRate(value) {
+            if (this._cachePlayRate !== value) {
+                this._cachePlayRate = value;
+                if (this._templet)
+                    this._computeFullKeyframeIndices();
+            }
+        }
+        get cacheFrameRate() {
+            return this._cacheFrameRate;
+        }
+        set cacheFrameRate(value) {
+            if (this._cacheFrameRate !== value) {
+                this._cacheFrameRate = value;
+                this._cacheFrameRateInterval = 1000.0 / this._cacheFrameRate;
+                if (this._templet)
+                    this._computeFullKeyframeIndices();
+            }
+        }
+        set currentTime(value) {
+            if (this._currentAnimationClipIndex === -1 || !this._templet)
+                return;
+            if (value < this._playStart || value > this._playEnd)
+                throw new Error("AnimationPlayer:value must large than playStartTime,small than playEndTime.");
+            this._startUpdateLoopCount = Laya.Stat.loopCount;
+            var cacheFrameInterval = this._cacheFrameRateInterval * this._cachePlayRate;
+            this._currentTime = value;
+            this._currentKeyframeIndex = Math.floor(this.currentPlayTime / cacheFrameInterval);
+            this._currentFrameTime = this._currentKeyframeIndex * cacheFrameInterval;
+        }
+        get paused() {
+            return this._paused;
+        }
+        set paused(value) {
+            this._paused = value;
+            value && this.event(Laya.Event.PAUSED);
+        }
+        get cacheFrameRateInterval() {
+            return this._cacheFrameRateInterval;
+        }
+        get state() {
+            if (this._currentAnimationClipIndex === -1)
+                return AnimationState.stopped;
+            if (this._paused)
+                return AnimationState.paused;
+            return AnimationState.playing;
+        }
+        get destroyed() {
+            return this._destroyed;
+        }
+        _onTempletLoadedComputeFullKeyframeIndices(cachePlayRate, cacheFrameRate, templet) {
+            if (this._templet === templet && this._cachePlayRate === cachePlayRate && this._cacheFrameRate === cacheFrameRate)
+                this._computeFullKeyframeIndices();
+        }
+        _computeFullKeyframeIndices() {
+            return;
+            var templet = this._templet;
+            if (templet._fullFrames)
+                return;
+            var anifullFrames = this._templet._fullFrames = [];
+            var cacheFrameInterval = this._cacheFrameRateInterval * this._cachePlayRate;
+            for (var i = 0, iNum = templet.getAnimationCount(); i < iNum; i++) {
+                var aniFullFrame = [];
+                if (!templet.getAnimation(i).nodes) {
+                    anifullFrames.push(aniFullFrame);
+                    continue;
+                }
+                for (var j = 0, jNum = templet.getAnimation(i).nodes.length; j < jNum; j++) {
+                    var node = templet.getAnimation(i).nodes[j];
+                    var frameCount = Math.round(node.playTime / cacheFrameInterval);
+                    var nodeFullFrames = new Uint16Array(frameCount + 1);
+                    var stidx = -1;
+                    var nodeframes = node.keyFrame;
+                    for (var n = 0, nNum = nodeframes.length; n < nNum; n++) {
+                        var keyFrame = nodeframes[n];
+                        var pos = Math.round(keyFrame.startTime / cacheFrameInterval);
+                        if (stidx < 0 && pos > 0) {
+                            stidx = pos;
+                        }
+                        if (pos <= frameCount) {
+                            nodeFullFrames[pos] = n;
+                        }
+                    }
+                    var cf = 0;
+                    for (n = stidx; n < frameCount; n++) {
+                        if (nodeFullFrames[n] == 0) {
+                            nodeFullFrames[n] = cf;
+                        }
+                        else {
+                            cf = nodeFullFrames[n];
+                        }
+                    }
+                    aniFullFrame.push(nodeFullFrames);
+                }
+                anifullFrames.push(aniFullFrame);
+            }
+        }
+        _onAnimationTempletLoaded() {
+            (this.destroyed) || (this._calculatePlayDuration());
+        }
+        _calculatePlayDuration() {
+            if (this.state !== AnimationState.stopped) {
+                var oriDuration = this._templet.getAniDuration(this._currentAnimationClipIndex);
+                (this._playEnd === 0) && (this._playEnd = oriDuration);
+                if (this._playEnd > oriDuration)
+                    this._playEnd = oriDuration;
+                this._playDuration = this._playEnd - this._playStart;
+            }
+        }
+        _setPlayParams(time, cacheFrameInterval) {
+            this._currentTime = time;
+            this._currentKeyframeIndex = Math.floor((this.currentPlayTime) / cacheFrameInterval + 0.01);
+            this._currentFrameTime = this._currentKeyframeIndex * cacheFrameInterval;
+        }
+        _setPlayParamsWhenStop(currentAniClipPlayDuration, cacheFrameInterval, playEnd = -1) {
+            this._currentTime = currentAniClipPlayDuration;
+            var endTime = playEnd > 0 ? playEnd : currentAniClipPlayDuration;
+            this._currentKeyframeIndex = Math.floor(endTime / cacheFrameInterval + 0.01);
+            this._currentKeyframeIndex = Math.floor(currentAniClipPlayDuration / cacheFrameInterval + 0.01);
+            this._currentFrameTime = this._currentKeyframeIndex * cacheFrameInterval;
+            this._currentAnimationClipIndex = -1;
+        }
+        _update(elapsedTime) {
+            if (this._currentAnimationClipIndex === -1 || this._paused || !this._templet)
+                return;
+            var cacheFrameInterval = this._cacheFrameRateInterval * this._cachePlayRate;
+            var time = 0;
+            (this._startUpdateLoopCount !== Laya.Stat.loopCount) && (time = elapsedTime * this.playbackRate, this._elapsedPlaybackTime += time);
+            var currentAniClipPlayDuration = this.playDuration;
+            time += this._currentTime;
+            if ((this._overallDuration !== 0 && this._elapsedPlaybackTime >= this._overallDuration) || (this._overallDuration === 0 && this._elapsedPlaybackTime >= currentAniClipPlayDuration
+                || (this._overallDuration === 0 && time >= this.playEnd))) {
+                this._setPlayParamsWhenStop(currentAniClipPlayDuration, cacheFrameInterval, this.playEnd);
+                this.event(Laya.Event.STOPPED);
+                return;
+            }
+            if (currentAniClipPlayDuration > 0) {
+                if (time >= currentAniClipPlayDuration) {
+                    if (this._stopWhenCircleFinish) {
+                        this._setPlayParamsWhenStop(currentAniClipPlayDuration, cacheFrameInterval);
+                        this._stopWhenCircleFinish = false;
+                        this.event(Laya.Event.STOPPED);
+                        return;
+                    }
+                    else {
+                        time = time % currentAniClipPlayDuration;
+                        this._setPlayParams(time, cacheFrameInterval);
+                        this.event(Laya.Event.COMPLETE);
+                        return;
+                    }
+                }
+                else {
+                    this._setPlayParams(time, cacheFrameInterval);
+                }
+            }
+            else {
+                if (this._stopWhenCircleFinish) {
+                    this._setPlayParamsWhenStop(currentAniClipPlayDuration, cacheFrameInterval);
+                    this._stopWhenCircleFinish = false;
+                    this.event(Laya.Event.STOPPED);
+                    return;
+                }
+                this._currentTime = this._currentFrameTime = this._currentKeyframeIndex = 0;
+                this.event(Laya.Event.COMPLETE);
+            }
+        }
+        _destroy() {
+            this.offAll();
+            this._templet = null;
+            this._destroyed = true;
+        }
+        play(index = 0, playbackRate = 1.0, overallDuration = 2147483647, playStart = 0, playEnd = 0) {
+            if (!this._templet)
+                throw new Error("AnimationPlayer:templet must not be null,maybe you need to set url.");
+            if (overallDuration < 0 || playStart < 0 || playEnd < 0)
+                throw new Error("AnimationPlayer:overallDuration,playStart and playEnd must large than zero.");
+            if ((playEnd !== 0) && (playStart > playEnd))
+                throw new Error("AnimationPlayer:start must less than end.");
+            this._currentTime = 0;
+            this._currentFrameTime = 0;
+            this._elapsedPlaybackTime = 0;
+            this.playbackRate = playbackRate;
+            this._overallDuration = overallDuration;
+            this._playStart = playStart;
+            this._playEnd = playEnd;
+            this._paused = false;
+            this._currentAnimationClipIndex = index;
+            this._currentKeyframeIndex = 0;
+            this._startUpdateLoopCount = Laya.Stat.loopCount;
+            this.event(Laya.Event.PLAYED);
+            this._calculatePlayDuration();
+            this._update(0);
+        }
+        playByFrame(index = 0, playbackRate = 1.0, overallDuration = 2147483647, playStartFrame = 0, playEndFrame = 0, fpsIn3DBuilder = 30) {
+            var interval = 1000.0 / fpsIn3DBuilder;
+            this.play(index, playbackRate, overallDuration, playStartFrame * interval, playEndFrame * interval);
+        }
+        stop(immediate = true) {
+            if (immediate) {
+                this._currentTime = this._currentFrameTime = this._currentKeyframeIndex = 0;
+                this._currentAnimationClipIndex = -1;
+                this.event(Laya.Event.STOPPED);
+            }
+            else {
+                this._stopWhenCircleFinish = true;
+            }
+        }
+        destroy() {
+        }
+    }
+
+    class BezierLerp {
+        constructor() {
+        }
+        static getBezierRate(t, px0, py0, px1, py1) {
+            var key = BezierLerp._getBezierParamKey(px0, py0, px1, py1);
+            var vKey = key * 100 + t;
+            if (BezierLerp._bezierResultCache[vKey])
+                return BezierLerp._bezierResultCache[vKey];
+            var points = BezierLerp._getBezierPoints(px0, py0, px1, py1, key);
+            var i, len;
+            len = points.length;
+            for (i = 0; i < len; i += 2) {
+                if (t <= points[i]) {
+                    BezierLerp._bezierResultCache[vKey] = points[i + 1];
+                    return points[i + 1];
+                }
+            }
+            BezierLerp._bezierResultCache[vKey] = 1;
+            return 1;
+        }
+        static _getBezierParamKey(px0, py0, px1, py1) {
+            return (((px0 * 100 + py0) * 100 + px1) * 100 + py1) * 100;
+        }
+        static _getBezierPoints(px0, py0, px1, py1, key) {
+            if (BezierLerp._bezierPointsCache[key])
+                return BezierLerp._bezierPointsCache[key];
+            var controlPoints;
+            controlPoints = [0, 0, px0, py0, px1, py1, 1, 1];
+            var bz;
+            bz = new Laya.Bezier();
+            var points;
+            points = bz.getBezierPoints(controlPoints, 100, 3);
+            BezierLerp._bezierPointsCache[key] = points;
+            return points;
+        }
+    }
+    BezierLerp._bezierResultCache = {};
+    BezierLerp._bezierPointsCache = {};
+
+    class AnimationTemplet extends Laya.Resource {
+        constructor() {
+            super();
+            this._anis = [];
+            this._aniMap = {};
+            this.unfixedLastAniIndex = -1;
+            this._fullFrames = null;
+            this._boneCurKeyFrm = [];
+        }
+        static _LinearInterpolation_0(bone, index, out, outOfs, data, dt, dData, duration, nextData, interData = null) {
+            out[outOfs] = data[index] + dt * dData[index];
+            return 1;
+        }
+        static _QuaternionInterpolation_1(bone, index, out, outOfs, data, dt, dData, duration, nextData, interData = null) {
+            var amount = duration === 0 ? 0 : dt / duration;
+            Laya.MathUtil.slerpQuaternionArray(data, index, nextData, index, amount, out, outOfs);
+            return 4;
+        }
+        static _AngleInterpolation_2(bone, index, out, outOfs, data, dt, dData, duration, nextData, interData = null) {
+            return 0;
+        }
+        static _RadiansInterpolation_3(bone, index, out, outOfs, data, dt, dData, duration, nextData, interData = null) {
+            return 0;
+        }
+        static _Matrix4x4Interpolation_4(bone, index, out, outOfs, data, dt, dData, duration, nextData, interData = null) {
+            for (var i = 0; i < 16; i++, index++)
+                out[outOfs + i] = data[index] + dt * dData[index];
+            return 16;
+        }
+        static _NoInterpolation_5(bone, index, out, outOfs, data, dt, dData, duration, nextData, interData = null) {
+            out[outOfs] = data[index];
+            return 1;
+        }
+        static _BezierInterpolation_6(bone, index, out, outOfs, data, dt, dData, duration, nextData, interData = null, offset = 0) {
+            out[outOfs] = data[index] + (nextData[index] - data[index]) * BezierLerp.getBezierRate(dt / duration, interData[offset], interData[offset + 1], interData[offset + 2], interData[offset + 3]);
+            return 5;
+        }
+        static _BezierInterpolation_7(bone, index, out, outOfs, data, dt, dData, duration, nextData, interData = null, offset = 0) {
+            out[outOfs] = interData[offset + 4] + interData[offset + 5] * BezierLerp.getBezierRate((dt * 0.001 + interData[offset + 6]) / interData[offset + 7], interData[offset], interData[offset + 1], interData[offset + 2], interData[offset + 3]);
+            return 9;
+        }
+        parse(data) {
+            var reader = new Laya.Byte(data);
+            this._aniVersion = reader.readUTFString();
+            AnimationParser01.parse(this, reader);
+        }
+        _calculateKeyFrame(node, keyframeCount, keyframeDataCount) {
+            var keyFrames = node.keyFrame;
+            keyFrames[keyframeCount] = keyFrames[0];
+            for (var i = 0; i < keyframeCount; i++) {
+                var keyFrame = keyFrames[i];
+                for (var j = 0; j < keyframeDataCount; j++) {
+                    keyFrame.dData[j] = (keyFrame.duration === 0) ? 0 : (keyFrames[i + 1].data[j] - keyFrame.data[j]) / keyFrame.duration;
+                    keyFrame.nextData[j] = keyFrames[i + 1].data[j];
+                }
+            }
+            keyFrames.length--;
+        }
+        _onAsynLoaded(data, propertyParams = null) {
+            var reader = new Laya.Byte(data);
+            this._aniVersion = reader.readUTFString();
+            switch (this._aniVersion) {
+                case "LAYAANIMATION:02":
+                    AnimationParser02.parse(this, reader);
+                    break;
+                default:
+                    AnimationParser01.parse(this, reader);
+            }
+        }
+        getAnimationCount() {
+            return this._anis.length;
+        }
+        getAnimation(aniIndex) {
+            return this._anis[aniIndex];
+        }
+        getAniDuration(aniIndex) {
+            return this._anis[aniIndex].playTime;
+        }
+        getNodes(aniIndex) {
+            return this._anis[aniIndex].nodes;
+        }
+        getNodeIndexWithName(aniIndex, name) {
+            return this._anis[aniIndex].bone3DMap[name];
+        }
+        getNodeCount(aniIndex) {
+            return this._anis[aniIndex].nodes.length;
+        }
+        getTotalkeyframesLength(aniIndex) {
+            return this._anis[aniIndex].totalKeyframeDatasLength;
+        }
+        getPublicExtData() {
+            return this._publicExtData;
+        }
+        getAnimationDataWithCache(key, cacheDatas, aniIndex, frameIndex) {
+            var aniDatas = cacheDatas[aniIndex];
+            if (!aniDatas) {
+                return null;
+            }
+            else {
+                var keyDatas = aniDatas[key];
+                if (!keyDatas)
+                    return null;
+                else {
+                    return keyDatas[frameIndex];
+                }
+            }
+        }
+        setAnimationDataWithCache(key, cacheDatas, aniIndex, frameIndex, data) {
+            var aniDatas = (cacheDatas[aniIndex]) || (cacheDatas[aniIndex] = {});
+            var aniDatasCache = (aniDatas[key]) || (aniDatas[key] = []);
+            aniDatasCache[frameIndex] = data;
+        }
+        getNodeKeyFrame(nodeframes, nodeid, tm) {
+            var cid = this._boneCurKeyFrm[nodeid];
+            var frmNum = nodeframes.length;
+            if (cid == void 0 || cid >= frmNum) {
+                cid = this._boneCurKeyFrm[nodeid] = 0;
+            }
+            var kinfo = nodeframes[cid];
+            var curFrmTm = kinfo.startTime;
+            var dt = tm - curFrmTm;
+            if (dt == 0 || (dt > 0 && kinfo.duration > dt)) {
+                return cid;
+            }
+            var i = 0;
+            if (dt > 0) {
+                tm = tm + 0.01;
+                for (i = cid + 1; i < frmNum; i++) {
+                    kinfo = nodeframes[i];
+                    if (kinfo.startTime <= tm && kinfo.startTime + kinfo.duration > tm) {
+                        this._boneCurKeyFrm[nodeid] = i;
+                        return i;
+                    }
+                }
+                return frmNum - 1;
+            }
+            else {
+                for (i = 0; i < cid; i++) {
+                    kinfo = nodeframes[i];
+                    if (kinfo.startTime <= tm && kinfo.startTime + kinfo.duration > tm) {
+                        this._boneCurKeyFrm[nodeid] = i;
+                        return i;
+                    }
+                }
+                return cid;
+            }
+            return 0;
+        }
+        getOriginalData(aniIndex, originalData, nodesFrameIndices, frameIndex, playCurTime) {
+            var oneAni = this._anis[aniIndex];
+            var nodes = oneAni.nodes;
+            var curKFrm = this._boneCurKeyFrm;
+            if (curKFrm.length < nodes.length) {
+                curKFrm.length = nodes.length;
+            }
+            var j = 0;
+            for (var i = 0, n = nodes.length, outOfs = 0; i < n; i++) {
+                var node = nodes[i];
+                var key;
+                var kfrm = node.keyFrame;
+                key = kfrm[this.getNodeKeyFrame(kfrm, i, playCurTime)];
+                node.dataOffset = outOfs;
+                var dt = playCurTime - key.startTime;
+                var lerpType = node.lerpType;
+                if (lerpType) {
+                    switch (lerpType) {
+                        case 0:
+                        case 1:
+                            for (j = 0; j < node.keyframeWidth;)
+                                j += node.interpolationMethod[j](node, j, originalData, outOfs + j, key.data, dt, key.dData, key.duration, key.nextData);
+                            break;
+                        case 2:
+                            var interpolationData = key.interpolationData;
+                            var interDataLen = interpolationData.length;
+                            var dataIndex = 0;
+                            for (j = 0; j < interDataLen;) {
+                                var type = interpolationData[j];
+                                switch (type) {
+                                    case 6:
+                                        j += AnimationTemplet.interpolation[type](node, dataIndex, originalData, outOfs + dataIndex, key.data, dt, key.dData, key.duration, key.nextData, interpolationData, j + 1);
+                                        break;
+                                    case 7:
+                                        j += AnimationTemplet.interpolation[type](node, dataIndex, originalData, outOfs + dataIndex, key.data, dt, key.dData, key.duration, key.nextData, interpolationData, j + 1);
+                                        break;
+                                    default:
+                                        j += AnimationTemplet.interpolation[type](node, dataIndex, originalData, outOfs + dataIndex, key.data, dt, key.dData, key.duration, key.nextData);
+                                }
+                                dataIndex++;
+                            }
+                            break;
+                    }
+                }
+                else {
+                    for (j = 0; j < node.keyframeWidth;)
+                        j += node.interpolationMethod[j](node, j, originalData, outOfs + j, key.data, dt, key.dData, key.duration, key.nextData);
+                }
+                outOfs += node.keyframeWidth;
+            }
+        }
+        getNodesCurrentFrameIndex(aniIndex, playCurTime) {
+            var ani = this._anis[aniIndex];
+            var nodes = ani.nodes;
+            if (aniIndex !== this.unfixedLastAniIndex) {
+                this.unfixedCurrentFrameIndexes = new Uint32Array(nodes.length);
+                this.unfixedCurrentTimes = new Float32Array(nodes.length);
+                this.unfixedLastAniIndex = aniIndex;
+            }
+            for (var i = 0, n = nodes.length; i < n; i++) {
+                var node = nodes[i];
+                if (playCurTime < this.unfixedCurrentTimes[i])
+                    this.unfixedCurrentFrameIndexes[i] = 0;
+                this.unfixedCurrentTimes[i] = playCurTime;
+                while ((this.unfixedCurrentFrameIndexes[i] < node.keyFrame.length)) {
+                    if (node.keyFrame[this.unfixedCurrentFrameIndexes[i]].startTime > this.unfixedCurrentTimes[i])
+                        break;
+                    this.unfixedCurrentFrameIndexes[i]++;
+                }
+                this.unfixedCurrentFrameIndexes[i]--;
+            }
+            return this.unfixedCurrentFrameIndexes;
+        }
+        getOriginalDataUnfixedRate(aniIndex, originalData, playCurTime) {
+            var oneAni = this._anis[aniIndex];
+            var nodes = oneAni.nodes;
+            if (aniIndex !== this.unfixedLastAniIndex) {
+                this.unfixedCurrentFrameIndexes = new Uint32Array(nodes.length);
+                this.unfixedCurrentTimes = new Float32Array(nodes.length);
+                this.unfixedKeyframes = [];
+                this.unfixedLastAniIndex = aniIndex;
+            }
+            var j = 0;
+            for (var i = 0, n = nodes.length, outOfs = 0; i < n; i++) {
+                var node = nodes[i];
+                if (playCurTime < this.unfixedCurrentTimes[i])
+                    this.unfixedCurrentFrameIndexes[i] = 0;
+                this.unfixedCurrentTimes[i] = playCurTime;
+                while (this.unfixedCurrentFrameIndexes[i] < node.keyFrame.length) {
+                    if (node.keyFrame[this.unfixedCurrentFrameIndexes[i]].startTime > this.unfixedCurrentTimes[i])
+                        break;
+                    this.unfixedKeyframes[i] = node.keyFrame[this.unfixedCurrentFrameIndexes[i]];
+                    this.unfixedCurrentFrameIndexes[i]++;
+                }
+                var key = this.unfixedKeyframes[i];
+                node.dataOffset = outOfs;
+                var dt = playCurTime - key.startTime;
+                var lerpType = node.lerpType;
+                if (lerpType) {
+                    switch (node.lerpType) {
+                        case 0:
+                        case 1:
+                            for (j = 0; j < node.keyframeWidth;)
+                                j += node.interpolationMethod[j](node, j, originalData, outOfs + j, key.data, dt, key.dData, key.duration, key.nextData);
+                            break;
+                        case 2:
+                            var interpolationData = key.interpolationData;
+                            var interDataLen = interpolationData.length;
+                            var dataIndex = 0;
+                            for (j = 0; j < interDataLen;) {
+                                var type = interpolationData[j];
+                                switch (type) {
+                                    case 6:
+                                        j += AnimationTemplet.interpolation[type](node, dataIndex, originalData, outOfs + dataIndex, key.data, dt, key.dData, key.duration, key.nextData, interpolationData, j + 1);
+                                        break;
+                                    case 7:
+                                        j += AnimationTemplet.interpolation[type](node, dataIndex, originalData, outOfs + dataIndex, key.data, dt, key.dData, key.duration, key.nextData, interpolationData, j + 1);
+                                        break;
+                                    default:
+                                        j += AnimationTemplet.interpolation[type](node, dataIndex, originalData, outOfs + dataIndex, key.data, dt, key.dData, key.duration, key.nextData);
+                                }
+                                dataIndex++;
+                            }
+                            break;
+                    }
+                }
+                else {
+                    for (j = 0; j < node.keyframeWidth;)
+                        j += node.interpolationMethod[j](node, j, originalData, outOfs + j, key.data, dt, key.dData, key.duration, key.nextData);
+                }
+                outOfs += node.keyframeWidth;
+            }
+        }
+    }
+    AnimationTemplet.interpolation = [AnimationTemplet._LinearInterpolation_0, AnimationTemplet._QuaternionInterpolation_1, AnimationTemplet._AngleInterpolation_2, AnimationTemplet._RadiansInterpolation_3, AnimationTemplet._Matrix4x4Interpolation_4, AnimationTemplet._NoInterpolation_5, AnimationTemplet._BezierInterpolation_6, AnimationTemplet._BezierInterpolation_7];
+    IAniLib.AnimationTemplet = AnimationTemplet;
+
+    class GraphicsAni extends Laya.Graphics {
+        drawSkin(skinA, alpha) {
+            this.drawTriangles(skinA.texture, 0, 0, skinA.vertices, skinA.uvs, skinA.indexes, skinA.transform || Laya.Matrix.EMPTY, alpha);
+        }
+        static create() {
+            var rs = GraphicsAni._caches.pop();
+            return rs || new GraphicsAni();
+        }
+        static recycle(graphics) {
+            graphics.clear();
+            GraphicsAni._caches.push(graphics);
+        }
+    }
+    GraphicsAni._caches = [];
+
+    class Transform {
+        constructor() {
+            this.skX = 0;
+            this.skY = 0;
+            this.scX = 1;
+            this.scY = 1;
+            this.x = 0;
+            this.y = 0;
+            this.skewX = 0;
+            this.skewY = 0;
+        }
+        initData(data) {
+            if (data.x != undefined) {
+                this.x = data.x;
+            }
+            if (data.y != undefined) {
+                this.y = data.y;
+            }
+            if (data.skX != undefined) {
+                this.skX = data.skX;
+            }
+            if (data.skY != undefined) {
+                this.skY = data.skY;
+            }
+            if (data.scX != undefined) {
+                this.scX = data.scX;
+            }
+            if (data.scY != undefined) {
+                this.scY = data.scY;
+            }
+        }
+        getMatrix() {
+            var tMatrix;
+            if (this.mMatrix) {
+                tMatrix = this.mMatrix;
+            }
+            else {
+                tMatrix = this.mMatrix = new Laya.Matrix();
+            }
+            tMatrix.identity();
+            tMatrix.scale(this.scX, this.scY);
+            if (this.skewX || this.skewY) {
+                this.skew(tMatrix, this.skewX * Math.PI / 180, this.skewY * Math.PI / 180);
+            }
+            tMatrix.rotate(this.skX * Math.PI / 180);
+            tMatrix.translate(this.x, this.y);
+            return tMatrix;
+        }
+        skew(m, x, y) {
+            var sinX = Math.sin(y);
+            var cosX = Math.cos(y);
+            var sinY = Math.sin(x);
+            var cosY = Math.cos(x);
+            m.setTo(m.a * cosY - m.b * sinX, m.a * sinY + m.b * cosX, m.c * cosY - m.d * sinX, m.c * sinY + m.d * cosX, m.tx * cosY - m.ty * sinX, m.tx * sinY + m.ty * cosX);
+            return m;
+        }
+    }
+
+    class Bone {
+        constructor() {
+            this.length = 10;
+            this.resultTransform = new Transform();
+            this.resultMatrix = new Laya.Matrix();
+            this.inheritScale = true;
+            this.inheritRotation = true;
+            this.d = -1;
+            this._children = [];
+        }
+        setTempMatrix(matrix) {
+            this._tempMatrix = matrix;
+            var i = 0, n = 0;
+            var tBone;
+            for (i = 0, n = this._children.length; i < n; i++) {
+                tBone = this._children[i];
+                tBone.setTempMatrix(this._tempMatrix);
+            }
+        }
+        update(pMatrix = null) {
+            this.rotation = this.transform.skX;
+            var tResultMatrix;
+            if (pMatrix) {
+                tResultMatrix = this.resultTransform.getMatrix();
+                Laya.Matrix.mul(tResultMatrix, pMatrix, this.resultMatrix);
+                this.resultRotation = this.rotation;
+            }
+            else {
+                this.resultRotation = this.rotation + this.parentBone.resultRotation;
+                if (this.parentBone) {
+                    if (this.inheritRotation && this.inheritScale) {
+                        tResultMatrix = this.resultTransform.getMatrix();
+                        Laya.Matrix.mul(tResultMatrix, this.parentBone.resultMatrix, this.resultMatrix);
+                    }
+                    else {
+                        var parent = this.parentBone;
+                        var tAngle;
+                        var cos;
+                        var sin;
+                        var tParentMatrix = this.parentBone.resultMatrix;
+                        tResultMatrix = this.resultTransform.getMatrix();
+                        var worldX = tParentMatrix.a * tResultMatrix.tx + tParentMatrix.c * tResultMatrix.ty + tParentMatrix.tx;
+                        var worldY = tParentMatrix.b * tResultMatrix.tx + tParentMatrix.d * tResultMatrix.ty + tParentMatrix.ty;
+                        var tTestMatrix = new Laya.Matrix();
+                        if (this.inheritRotation) {
+                            tAngle = Math.atan2(parent.resultMatrix.b, parent.resultMatrix.a);
+                            cos = Math.cos(tAngle), sin = Math.sin(tAngle);
+                            tTestMatrix.setTo(cos, sin, -sin, cos, 0, 0);
+                            Laya.Matrix.mul(this._tempMatrix, tTestMatrix, Laya.Matrix.TEMP);
+                            Laya.Matrix.TEMP.copyTo(tTestMatrix);
+                            tResultMatrix = this.resultTransform.getMatrix();
+                            Laya.Matrix.mul(tResultMatrix, tTestMatrix, this.resultMatrix);
+                            if (this.resultTransform.scX * this.resultTransform.scY < 0) {
+                                this.resultMatrix.rotate(Math.PI * 0.5);
+                            }
+                            this.resultMatrix.tx = worldX;
+                            this.resultMatrix.ty = worldY;
+                        }
+                        else if (this.inheritScale) {
+                            tResultMatrix = this.resultTransform.getMatrix();
+                            Laya.Matrix.TEMP.identity();
+                            Laya.Matrix.TEMP.d = this.d;
+                            Laya.Matrix.mul(tResultMatrix, Laya.Matrix.TEMP, this.resultMatrix);
+                            this.resultMatrix.tx = worldX;
+                            this.resultMatrix.ty = worldY;
+                        }
+                        else {
+                            tResultMatrix = this.resultTransform.getMatrix();
+                            Laya.Matrix.TEMP.identity();
+                            Laya.Matrix.TEMP.d = this.d;
+                            Laya.Matrix.mul(tResultMatrix, Laya.Matrix.TEMP, this.resultMatrix);
+                            this.resultMatrix.tx = worldX;
+                            this.resultMatrix.ty = worldY;
+                        }
+                    }
+                }
+                else {
+                    tResultMatrix = this.resultTransform.getMatrix();
+                    tResultMatrix.copyTo(this.resultMatrix);
+                }
+            }
+            var i = 0, n = 0;
+            var tBone;
+            for (i = 0, n = this._children.length; i < n; i++) {
+                tBone = this._children[i];
+                tBone.update();
+            }
+        }
+        updateChild() {
+            var i = 0, n = 0;
+            var tBone;
+            for (i = 0, n = this._children.length; i < n; i++) {
+                tBone = this._children[i];
+                tBone.update();
+            }
+        }
+        setRotation(rd) {
+            if (this._sprite) {
+                this._sprite.rotation = rd * 180 / Math.PI;
+            }
+        }
+        updateDraw(x, y) {
+            if (!Bone.ShowBones || Bone.ShowBones[this.name]) {
+                if (this._sprite) {
+                    this._sprite.x = x + this.resultMatrix.tx;
+                    this._sprite.y = y + this.resultMatrix.ty;
+                }
+                else {
+                    this._sprite = new Laya.Sprite();
+                    this._sprite.graphics.drawCircle(0, 0, 5, "#ff0000");
+                    this._sprite.graphics.drawLine(0, 0, this.length, 0, "#00ff00");
+                    this._sprite.graphics.fillText(this.name, 0, 0, "20px Arial", "#00ff00", "center");
+                    Laya.ILaya.stage.addChild(this._sprite);
+                    this._sprite.x = x + this.resultMatrix.tx;
+                    this._sprite.y = y + this.resultMatrix.ty;
+                }
+            }
+            var i = 0, n = 0;
+            var tBone;
+            for (i = 0, n = this._children.length; i < n; i++) {
+                tBone = this._children[i];
+                tBone.updateDraw(x, y);
+            }
+        }
+        addChild(bone) {
+            this._children.push(bone);
+            bone.parentBone = this;
+        }
+        findBone(boneName) {
+            if (this.name == boneName) {
+                return this;
+            }
+            else {
+                var i, n;
+                var tBone;
+                var tResult;
+                for (i = 0, n = this._children.length; i < n; i++) {
+                    tBone = this._children[i];
+                    tResult = tBone.findBone(boneName);
+                    if (tResult) {
+                        return tResult;
+                    }
+                }
+            }
+            return null;
+        }
+        localToWorld(local) {
+            var localX = local[0];
+            var localY = local[1];
+            local[0] = localX * this.resultMatrix.a + localY * this.resultMatrix.c + this.resultMatrix.tx;
+            local[1] = localX * this.resultMatrix.b + localY * this.resultMatrix.d + this.resultMatrix.ty;
+        }
+    }
+    Bone.ShowBones = {};
+
+    class UVTools {
+        constructor() {
+        }
+        static getRelativeUV(bigUV, smallUV, rst = null) {
+            var startX = bigUV[0];
+            var width = bigUV[2] - bigUV[0];
+            var startY = bigUV[1];
+            var height = bigUV[5] - bigUV[1];
+            if (!rst)
+                rst = [];
+            rst.length = smallUV.length;
+            var i, len;
+            len = rst.length;
+            var dWidth = 1 / width;
+            var dHeight = 1 / height;
+            for (i = 0; i < len; i += 2) {
+                rst[i] = (smallUV[i] - startX) * dWidth;
+                rst[i + 1] = (smallUV[i + 1] - startY) * dHeight;
+            }
+            return rst;
+        }
+        static getAbsoluteUV(bigUV, smallUV, rst = null) {
+            if (bigUV[0] == 0 && bigUV[1] == 0 && bigUV[4] == 1 && bigUV[5] == 1) {
+                if (rst) {
+                    Laya.Utils.copyArray(rst, smallUV);
+                    return rst;
+                }
+                else {
+                    return smallUV;
+                }
+            }
+            var startX = bigUV[0];
+            var width = bigUV[2] - bigUV[0];
+            var startY = bigUV[1];
+            var height = bigUV[5] - bigUV[1];
+            if (!rst)
+                rst = [];
+            rst.length = smallUV.length;
+            var i, len;
+            len = rst.length;
+            for (i = 0; i < len; i += 2) {
+                rst[i] = smallUV[i] * width + startX;
+                rst[i + 1] = smallUV[i + 1] * height + startY;
+            }
+            return rst;
+        }
+    }
+
+    class MeshData {
+        constructor() {
+            this.uvs = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
+            this.vertices = new Float32Array([0, 0, 100, 0, 100, 100, 0, 100]);
+            this.indexes = new Uint16Array([0, 1, 3, 3, 1, 2]);
+            this.useUvTransform = false;
+            this.canvasPadding = 1;
+        }
+        getBounds() {
+            return Laya.Rectangle._getWrapRec(this.vertices);
+        }
+    }
+
+    class SkinMeshForGraphic extends MeshData {
+        constructor() {
+            super();
+        }
+        init2(texture, ps, verticles, uvs) {
+            if (this.transform) {
+                this.transform = null;
+            }
+            var _ps = ps || [0, 1, 3, 3, 1, 2];
+            this.texture = texture;
+            this.indexes = new Uint16Array(_ps);
+            this.vertices = new Float32Array(verticles);
+            this.uvs = new Float32Array(uvs);
+        }
+    }
+
+    class BoneSlot {
+        constructor() {
+            this.srcDisplayIndex = -1;
+            this.type = "src";
+            this.displayIndex = -1;
+            this.originalIndex = -1;
+            this._replaceDic = {};
+        }
+        showSlotData(slotData, freshIndex = true) {
+            this.currSlotData = slotData;
+            if (freshIndex)
+                this.displayIndex = this.srcDisplayIndex;
+            this.currDisplayData = null;
+            this.currTexture = null;
+        }
+        showDisplayByName(name) {
+            if (this.currSlotData) {
+                this.showDisplayByIndex(this.currSlotData.getDisplayByName(name));
+            }
+        }
+        replaceDisplayByName(tarName, newName) {
+            if (!this.currSlotData)
+                return;
+            var preIndex;
+            preIndex = this.currSlotData.getDisplayByName(tarName);
+            var newIndex;
+            newIndex = this.currSlotData.getDisplayByName(newName);
+            this.replaceDisplayByIndex(preIndex, newIndex);
+        }
+        replaceDisplayByIndex(tarIndex, newIndex) {
+            if (!this.currSlotData)
+                return;
+            this._replaceDic[tarIndex] = newIndex;
+            if (this.originalIndex == tarIndex) {
+                this.showDisplayByIndex(tarIndex);
+            }
+        }
+        showDisplayByIndex(index) {
+            this.originalIndex = index;
+            if (this._replaceDic[index] != null)
+                index = this._replaceDic[index];
+            if (this.currSlotData && index > -1 && index < this.currSlotData.displayArr.length) {
+                this.displayIndex = index;
+                this.currDisplayData = this.currSlotData.displayArr[index];
+                if (this.currDisplayData) {
+                    var tName = this.currDisplayData.name;
+                    this.currTexture = this.templet.getTexture(tName);
+                    if (this.currTexture && this.currDisplayData.type == 0 && this.currDisplayData.uvs) {
+                        this.currTexture = this.currDisplayData.createTexture(this.currTexture);
+                    }
+                }
+            }
+            else {
+                this.displayIndex = -1;
+                this.currDisplayData = null;
+                this.currTexture = null;
+            }
+        }
+        replaceSkin(_texture) {
+            this._diyTexture = _texture;
+            if (this._curDiyUV)
+                this._curDiyUV.length = 0;
+            if (this.currDisplayData && this._diyTexture == this.currDisplayData.texture) {
+                this._diyTexture = null;
+            }
+        }
+        setParentMatrix(parentMatrix) {
+            this._parentMatrix = parentMatrix;
+        }
+        static createSkinMesh() {
+            return new SkinMeshForGraphic();
+        }
+        static isSameArr(arrA, arrB) {
+            if (arrA.length != arrB.length)
+                return false;
+            var i, len;
+            len = arrA.length;
+            for (i = 0; i < len; i++) {
+                if (arrA[i] != arrB[i])
+                    return false;
+            }
+            return true;
+        }
+        getSaveVerticle(tArr) {
+            if (BoneSlot.useSameMatrixAndVerticle && this._preGraphicVerticle && BoneSlot.isSameArr(tArr, this._preGraphicVerticle)) {
+                tArr = this._preGraphicVerticle;
+            }
+            else {
+                tArr = Laya.ILaya.Utils.copyArray([], tArr);
+                this._preGraphicVerticle = tArr;
+            }
+            return tArr;
+        }
+        static isSameMatrix(mtA, mtB) {
+            return mtA.a == mtB.a && mtA.b == mtB.b && mtA.c == mtB.c && mtA.d == mtB.d && Math.abs(mtA.tx - mtB.tx) < 0.00001 && Math.abs(mtA.ty - mtB.ty) < 0.00001;
+        }
+        getSaveMatrix(tResultMatrix) {
+            if (BoneSlot.useSameMatrixAndVerticle && this._preGraphicMatrix && BoneSlot.isSameMatrix(tResultMatrix, this._preGraphicMatrix)) {
+                tResultMatrix = this._preGraphicMatrix;
+            }
+            else {
+                var newMatrix = tResultMatrix.clone();
+                tResultMatrix = newMatrix;
+                this._preGraphicMatrix = tResultMatrix;
+            }
+            return tResultMatrix;
+        }
+        draw(graphics, boneMatrixArray, noUseSave = false, alpha = 1) {
+            if ((this._diyTexture == null && this.currTexture == null) || this.currDisplayData == null) {
+                if (!(this.currDisplayData && this.currDisplayData.type == 3)) {
+                    return;
+                }
+            }
+            var tTexture = this.currTexture;
+            if (this._diyTexture)
+                tTexture = this._diyTexture;
+            var tSkinSprite;
+            switch (this.currDisplayData.type) {
+                case 0:
+                    if (graphics) {
+                        var tCurrentMatrix = this.getDisplayMatrix();
+                        if (this._parentMatrix) {
+                            var tRotateKey = false;
+                            if (tCurrentMatrix) {
+                                Laya.Matrix.mul(tCurrentMatrix, this._parentMatrix, Laya.Matrix.TEMP);
+                                var tResultMatrix;
+                                if (noUseSave) {
+                                    if (this._resultMatrix == null)
+                                        this._resultMatrix = new Laya.Matrix();
+                                    tResultMatrix = this._resultMatrix;
+                                }
+                                else {
+                                    tResultMatrix = BoneSlot._tempResultMatrix;
+                                }
+                                if (this._diyTexture && this.currDisplayData.uvs) {
+                                    var tTestMatrix = BoneSlot._tempMatrix;
+                                    tTestMatrix.identity();
+                                    if (this.currDisplayData.uvs[1] > this.currDisplayData.uvs[5]) {
+                                        tTestMatrix.d = -1;
+                                    }
+                                    if (this.currDisplayData.uvs[0] > this.currDisplayData.uvs[4]
+                                        && this.currDisplayData.uvs[1] > this.currDisplayData.uvs[5]) {
+                                        tRotateKey = true;
+                                        tTestMatrix.rotate(-Math.PI / 2);
+                                    }
+                                    Laya.Matrix.mul(tTestMatrix, Laya.Matrix.TEMP, tResultMatrix);
+                                }
+                                else {
+                                    Laya.Matrix.TEMP.copyTo(tResultMatrix);
+                                }
+                                if (!noUseSave) {
+                                    tResultMatrix = this.getSaveMatrix(tResultMatrix);
+                                }
+                                tResultMatrix._checkTransform();
+                                if (tRotateKey) {
+                                    graphics.drawTexture(tTexture, -this.currDisplayData.height / 2, -this.currDisplayData.width / 2, this.currDisplayData.height, this.currDisplayData.width, tResultMatrix, alpha);
+                                }
+                                else {
+                                    graphics.drawTexture(tTexture, -this.currDisplayData.width / 2, -this.currDisplayData.height / 2, this.currDisplayData.width, this.currDisplayData.height, tResultMatrix, alpha);
+                                }
+                            }
+                        }
+                    }
+                    break;
+                case 1:
+                    if (noUseSave) {
+                        if (this._skinSprite == null) {
+                            this._skinSprite = BoneSlot.createSkinMesh();
+                        }
+                        tSkinSprite = this._skinSprite;
+                    }
+                    else {
+                        tSkinSprite = BoneSlot.createSkinMesh();
+                    }
+                    if (tSkinSprite == null) {
+                        return;
+                    }
+                    var tIBArray;
+                    if (this.currDisplayData.bones == null) {
+                        var tVertices = this.currDisplayData.weights;
+                        if (this.deformData) {
+                            tVertices = this.deformData;
+                        }
+                        var tUVs;
+                        if (this._diyTexture) {
+                            if (!this._curDiyUV) {
+                                this._curDiyUV = [];
+                            }
+                            if (this._curDiyUV.length == 0) {
+                                this._curDiyUV = UVTools.getRelativeUV(this.currTexture.uv, this.currDisplayData.uvs, this._curDiyUV);
+                                this._curDiyUV = UVTools.getAbsoluteUV(this._diyTexture.uv, this._curDiyUV, this._curDiyUV);
+                            }
+                            tUVs = this._curDiyUV;
+                        }
+                        else {
+                            tUVs = this.currDisplayData.uvs;
+                        }
+                        this._mVerticleArr = tVertices;
+                        var tTriangleNum = this.currDisplayData.triangles.length / 3;
+                        tIBArray = this.currDisplayData.triangles;
+                        if (this.deformData) {
+                            if (!noUseSave) {
+                                this._mVerticleArr = this.getSaveVerticle(this._mVerticleArr);
+                            }
+                        }
+                        tSkinSprite.init2(tTexture, tIBArray, this._mVerticleArr, tUVs);
+                        var tCurrentMatrix2 = this.getDisplayMatrix();
+                        if (this._parentMatrix) {
+                            if (tCurrentMatrix2) {
+                                Laya.Matrix.mul(tCurrentMatrix2, this._parentMatrix, Laya.Matrix.TEMP);
+                                var tResultMatrix2;
+                                if (noUseSave) {
+                                    if (this._resultMatrix == null)
+                                        this._resultMatrix = new Laya.Matrix();
+                                    tResultMatrix2 = this._resultMatrix;
+                                }
+                                else {
+                                    tResultMatrix2 = BoneSlot._tempResultMatrix;
+                                }
+                                Laya.Matrix.TEMP.copyTo(tResultMatrix2);
+                                if (!noUseSave) {
+                                    tResultMatrix2 = this.getSaveMatrix(tResultMatrix2);
+                                }
+                                tSkinSprite.transform = tResultMatrix2;
+                            }
+                        }
+                    }
+                    else {
+                        this.skinMesh(boneMatrixArray, tSkinSprite);
+                    }
+                    graphics.drawSkin(tSkinSprite, alpha);
+                    break;
+                case 2:
+                    if (noUseSave) {
+                        if (this._skinSprite == null) {
+                            this._skinSprite = BoneSlot.createSkinMesh();
+                        }
+                        tSkinSprite = this._skinSprite;
+                    }
+                    else {
+                        tSkinSprite = BoneSlot.createSkinMesh();
+                    }
+                    if (tSkinSprite == null) {
+                        return;
+                    }
+                    this.skinMesh(boneMatrixArray, tSkinSprite);
+                    graphics.drawSkin(tSkinSprite, alpha);
+                    break;
+                case 3:
+                    break;
+            }
+        }
+        skinMesh(boneMatrixArray, skinSprite) {
+            var tTexture = this.currTexture;
+            var tBones = this.currDisplayData.bones;
+            var tUvs;
+            if (this._diyTexture) {
+                tTexture = this._diyTexture;
+                if (!this._curDiyUV) {
+                    this._curDiyUV = [];
+                }
+                if (this._curDiyUV.length == 0) {
+                    this._curDiyUV = UVTools.getRelativeUV(this.currTexture.uv, this.currDisplayData.uvs, this._curDiyUV);
+                    this._curDiyUV = UVTools.getAbsoluteUV(this._diyTexture.uv, this._curDiyUV, this._curDiyUV);
+                }
+                tUvs = this._curDiyUV;
+            }
+            else {
+                tUvs = this.currDisplayData.uvs;
+            }
+            var tWeights = this.currDisplayData.weights;
+            var tTriangles = this.currDisplayData.triangles;
+            var tIBArray;
+            var tRx = 0;
+            var tRy = 0;
+            var nn = 0;
+            var tMatrix;
+            var tX;
+            var tY;
+            var tB = 0;
+            var tWeight = 0;
+            var tVertices;
+            var i = 0, n = 0;
+            BoneSlot._tempVerticleArr.length = 0;
+            tVertices = BoneSlot._tempVerticleArr;
+            if (this.deformData && this.deformData.length > 0) {
+                var f = 0;
+                for (i = 0, n = tBones.length; i < n;) {
+                    nn = tBones[i++] + i;
+                    tRx = 0, tRy = 0;
+                    for (; i < nn; i++) {
+                        tMatrix = boneMatrixArray[tBones[i]];
+                        tX = tWeights[tB] + this.deformData[f++];
+                        tY = tWeights[tB + 1] + this.deformData[f++];
+                        tWeight = tWeights[tB + 2];
+                        tRx += (tX * tMatrix.a + tY * tMatrix.c + tMatrix.tx) * tWeight;
+                        tRy += (tX * tMatrix.b + tY * tMatrix.d + tMatrix.ty) * tWeight;
+                        tB += 3;
+                    }
+                    tVertices.push(tRx, tRy);
+                }
+            }
+            else {
+                for (i = 0, n = tBones.length; i < n;) {
+                    nn = tBones[i++] + i;
+                    tRx = 0, tRy = 0;
+                    for (; i < nn; i++) {
+                        tMatrix = boneMatrixArray[tBones[i]];
+                        tX = tWeights[tB];
+                        tY = tWeights[tB + 1];
+                        tWeight = tWeights[tB + 2];
+                        tRx += (tX * tMatrix.a + tY * tMatrix.c + tMatrix.tx) * tWeight;
+                        tRy += (tX * tMatrix.b + tY * tMatrix.d + tMatrix.ty) * tWeight;
+                        tB += 3;
+                    }
+                    tVertices.push(tRx, tRy);
+                }
+            }
+            this._mVerticleArr = tVertices;
+            tIBArray = tTriangles;
+            this._mVerticleArr = this.getSaveVerticle(this._mVerticleArr);
+            skinSprite.init2(tTexture, tIBArray, this._mVerticleArr, tUvs);
+        }
+        drawBonePoint(graphics) {
+            if (graphics && this._parentMatrix) {
+                graphics.drawCircle(this._parentMatrix.tx, this._parentMatrix.ty, 5, "#ff0000");
+            }
+        }
+        getDisplayMatrix() {
+            if (this.currDisplayData) {
+                return this.currDisplayData.transform.getMatrix();
+            }
+            return null;
+        }
+        getMatrix() {
+            return this._resultMatrix;
+        }
+        copy() {
+            var tBoneSlot = new BoneSlot();
+            tBoneSlot.type = "copy";
+            tBoneSlot.name = this.name;
+            tBoneSlot.attachmentName = this.attachmentName;
+            tBoneSlot.srcDisplayIndex = this.srcDisplayIndex;
+            tBoneSlot.parent = this.parent;
+            tBoneSlot.displayIndex = this.displayIndex;
+            tBoneSlot.templet = this.templet;
+            tBoneSlot.currSlotData = this.currSlotData;
+            tBoneSlot.currTexture = this.currTexture;
+            tBoneSlot.currDisplayData = this.currDisplayData;
+            return tBoneSlot;
+        }
+    }
+    BoneSlot._tempMatrix = new Laya.Matrix();
+    BoneSlot._tempResultMatrix = new Laya.Matrix();
+    BoneSlot.useSameMatrixAndVerticle = true;
+    BoneSlot._tempVerticleArr = [];
+
+    class DeformAniData {
+        constructor() {
+            this.deformSlotDataList = [];
+        }
+    }
+
+    class DeformSlotData {
+        constructor() {
+            this.deformSlotDisplayList = [];
+        }
+    }
+
+    class DeformSlotDisplayData {
+        constructor() {
+            this.slotIndex = -1;
+            this.timeList = [];
+            this.vectices = [];
+            this.tweenKeyList = [];
+            this.frameIndex = 0;
+        }
+        binarySearch1(values, target) {
+            var low = 0;
+            var high = values.length - 2;
+            if (high == 0)
+                return 1;
+            var current = high >>> 1;
+            while (true) {
+                if (values[Math.floor(current + 1)] <= target)
+                    low = current + 1;
+                else
+                    high = current;
+                if (low == high)
+                    return low + 1;
+                current = (low + high) >>> 1;
+            }
+            return 0;
+        }
+        apply(time, boneSlot, alpha = 1) {
+            time += 0.05;
+            if (this.timeList.length <= 0) {
+                return;
+            }
+            var i = 0;
+            var tTime = this.timeList[0];
+            if (time < tTime) {
+                return;
+            }
+            var tVertexCount = this.vectices[0].length;
+            var tVertices = [];
+            var tFrameIndex = this.binarySearch1(this.timeList, time);
+            this.frameIndex = tFrameIndex;
+            if (time >= this.timeList[this.timeList.length - 1]) {
+                var lastVertices = this.vectices[this.vectices.length - 1];
+                if (alpha < 1) {
+                    for (i = 0; i < tVertexCount; i++) {
+                        tVertices[i] += (lastVertices[i] - tVertices[i]) * alpha;
+                    }
+                }
+                else {
+                    for (i = 0; i < tVertexCount; i++) {
+                        tVertices[i] = lastVertices[i];
+                    }
+                }
+                this.deformData = tVertices;
+                return;
+            }
+            var tPrevVertices = this.vectices[this.frameIndex - 1];
+            var tNextVertices = this.vectices[this.frameIndex];
+            var tPreFrameTime = this.timeList[this.frameIndex - 1];
+            var tFrameTime = this.timeList[this.frameIndex];
+            if (this.tweenKeyList[tFrameIndex - 1]) {
+                alpha = (time - tPreFrameTime) / (tFrameTime - tPreFrameTime);
+            }
+            else {
+                alpha = 0;
+            }
+            var tPrev;
+            for (i = 0; i < tVertexCount; i++) {
+                tPrev = tPrevVertices[i];
+                tVertices[i] = tPrev + (tNextVertices[i] - tPrev) * alpha;
+            }
+            this.deformData = tVertices;
+        }
+    }
+
+    class DrawOrderData {
+        constructor() {
+            this.drawOrder = [];
+        }
+    }
+
+    class EventData {
+        constructor() {
+        }
+    }
+
+    class IkConstraint {
+        constructor(data, bones) {
+            this.isSpine = true;
+            this.isDebug = false;
+            this._targetBone = bones[data.targetBoneIndex];
+            this.isSpine = data.isSpine;
+            if (this._bones == null)
+                this._bones = [];
+            this._bones.length = 0;
+            for (var i = 0, n = data.boneIndexs.length; i < n; i++) {
+                this._bones.push(bones[data.boneIndexs[i]]);
+            }
+            this.name = data.name;
+            this.mix = data.mix;
+            this.bendDirection = data.bendDirection;
+        }
+        apply() {
+            switch (this._bones.length) {
+                case 1:
+                    this._applyIk1(this._bones[0], this._targetBone.resultMatrix.tx, this._targetBone.resultMatrix.ty, this.mix);
+                    break;
+                case 2:
+                    if (this.isSpine) {
+                        this._applyIk2(this._bones[0], this._bones[1], this._targetBone.resultMatrix.tx, this._targetBone.resultMatrix.ty, this.bendDirection, this.mix);
+                    }
+                    else {
+                        this._applyIk3(this._bones[0], this._bones[1], this._targetBone.resultMatrix.tx, this._targetBone.resultMatrix.ty, this.bendDirection, this.mix);
+                    }
+                    break;
+            }
+        }
+        _applyIk1(bone, targetX, targetY, alpha) {
+            var pp = bone.parentBone;
+            var id = 1 / (pp.resultMatrix.a * pp.resultMatrix.d - pp.resultMatrix.b * pp.resultMatrix.c);
+            var x = targetX - pp.resultMatrix.tx;
+            var y = targetY - pp.resultMatrix.ty;
+            var tx = (x * pp.resultMatrix.d - y * pp.resultMatrix.c) * id - bone.transform.x;
+            var ty = (y * pp.resultMatrix.a - x * pp.resultMatrix.b) * id - bone.transform.y;
+            var rotationIK = Math.atan2(ty, tx) * IkConstraint.radDeg - 0 - bone.transform.skX;
+            if (bone.transform.scX < 0)
+                rotationIK += 180;
+            if (rotationIK > 180)
+                rotationIK -= 360;
+            else if (rotationIK < -180)
+                rotationIK += 360;
+            bone.transform.skX = bone.transform.skY = bone.transform.skX + rotationIK * alpha;
+            bone.update();
+        }
+        updatePos(x, y) {
+            if (this._sp) {
+                this._sp.pos(x, y);
+            }
+        }
+        _applyIk2(parent, child, targetX, targetY, bendDir, alpha) {
+            if (alpha == 0) {
+                return;
+            }
+            var px = parent.resultTransform.x, py = parent.resultTransform.y;
+            var psx = parent.transform.scX, psy = parent.transform.scY;
+            var csx = child.transform.scX;
+            var os1, os2, s2;
+            if (psx < 0) {
+                psx = -psx;
+                os1 = 180;
+                s2 = -1;
+            }
+            else {
+                os1 = 0;
+                s2 = 1;
+            }
+            if (psy < 0) {
+                psy = -psy;
+                s2 = -s2;
+            }
+            if (csx < 0) {
+                csx = -csx;
+                os2 = 180;
+            }
+            else {
+                os2 = 0;
+            }
+            var cx = child.resultTransform.x, cy, cwx, cwy;
+            var a = parent.resultMatrix.a, b = parent.resultMatrix.c;
+            var c = parent.resultMatrix.b, d = parent.resultMatrix.d;
+            var u = Math.abs(psx - psy) <= 0.0001;
+            if (!u) {
+                cy = 0;
+                cwx = a * cx + parent.resultMatrix.tx;
+                cwy = c * cx + parent.resultMatrix.ty;
+            }
+            else {
+                cy = child.resultTransform.y;
+                cwx = a * cx + b * cy + parent.resultMatrix.tx;
+                cwy = c * cx + d * cy + parent.resultMatrix.ty;
+            }
+            if (this.isDebug) {
+                if (!this._sp) {
+                    this._sp = new Laya.Sprite();
+                    Laya.ILaya.stage.addChild(this._sp);
+                }
+                this._sp.graphics.clear();
+                this._sp.graphics.drawCircle(targetX, targetY, 15, "#ffff00");
+                this._sp.graphics.drawCircle(cwx, cwy, 15, "#ff00ff");
+            }
+            parent.setRotation(Math.atan2(cwy - parent.resultMatrix.ty, cwx - parent.resultMatrix.tx));
+            var pp = parent.parentBone;
+            a = pp.resultMatrix.a;
+            b = pp.resultMatrix.c;
+            c = pp.resultMatrix.b;
+            d = pp.resultMatrix.d;
+            var id = 1 / (a * d - b * c);
+            var x = targetX - pp.resultMatrix.tx, y = targetY - pp.resultMatrix.ty;
+            var tx = (x * d - y * b) * id - px;
+            var ty = (y * a - x * c) * id - py;
+            x = cwx - pp.resultMatrix.tx;
+            y = cwy - pp.resultMatrix.ty;
+            var dx = (x * d - y * b) * id - px;
+            var dy = (y * a - x * c) * id - py;
+            var l1 = Math.sqrt(dx * dx + dy * dy);
+            var l2 = child.length * csx;
+            var a1, a2;
+            if (u) {
+                l2 *= psx;
+                var cos = (tx * tx + ty * ty - l1 * l1 - l2 * l2) / (2 * l1 * l2);
+                if (cos < -1)
+                    cos = -1;
+                else if (cos > 1)
+                    cos = 1;
+                a2 = Math.acos(cos) * bendDir;
+                a = l1 + l2 * cos;
+                b = l2 * Math.sin(a2);
+                a1 = Math.atan2(ty * a - tx * b, tx * a + ty * b);
+            }
+            else {
+                a = psx * l2;
+                b = psy * l2;
+                var aa = a * a, bb = b * b, dd = tx * tx + ty * ty, ta = Math.atan2(ty, tx);
+                c = bb * l1 * l1 + aa * dd - aa * bb;
+                var c1 = -2 * bb * l1, c2 = bb - aa;
+                d = c1 * c1 - 4 * c2 * c;
+                if (d > 0) {
+                    var q = Math.sqrt(d);
+                    if (c1 < 0)
+                        q = -q;
+                    q = -(c1 + q) / 2;
+                    var r0 = q / c2, r1 = c / q;
+                    var r = Math.abs(r0) < Math.abs(r1) ? r0 : r1;
+                    if (r * r <= dd) {
+                        y = Math.sqrt(dd - r * r) * bendDir;
+                        a1 = ta - Math.atan2(y, r);
+                        a2 = Math.atan2(y / psy, (r - l1) / psx);
+                    }
+                }
+                var minAngle = 0, minDist = Number.MAX_VALUE, minX = 0, minY = 0;
+                var maxAngle = 0, maxDist = 0, maxX = 0, maxY = 0;
+                x = l1 + a;
+                d = x * x;
+                if (d > maxDist) {
+                    maxAngle = 0;
+                    maxDist = d;
+                    maxX = x;
+                }
+                x = l1 - a;
+                d = x * x;
+                if (d < minDist) {
+                    minAngle = Math.PI;
+                    minDist = d;
+                    minX = x;
+                }
+                var angle = Math.acos(-a * l1 / (aa - bb));
+                x = a * Math.cos(angle) + l1;
+                y = b * Math.sin(angle);
+                d = x * x + y * y;
+                if (d < minDist) {
+                    minAngle = angle;
+                    minDist = d;
+                    minX = x;
+                    minY = y;
+                }
+                if (d > maxDist) {
+                    maxAngle = angle;
+                    maxDist = d;
+                    maxX = x;
+                    maxY = y;
+                }
+                if (dd <= (minDist + maxDist) / 2) {
+                    a1 = ta - Math.atan2(minY * bendDir, minX);
+                    a2 = minAngle * bendDir;
+                }
+                else {
+                    a1 = ta - Math.atan2(maxY * bendDir, maxX);
+                    a2 = maxAngle * bendDir;
+                }
+            }
+            var os = Math.atan2(cy, cx) * s2;
+            var rotation = parent.resultTransform.skX;
+            a1 = (a1 - os) * IkConstraint.radDeg + os1 - rotation;
+            if (a1 > 180)
+                a1 -= 360;
+            else if (a1 < -180)
+                a1 += 360;
+            parent.resultTransform.x = px;
+            parent.resultTransform.y = py;
+            parent.resultTransform.skX = parent.resultTransform.skY = rotation + a1 * alpha;
+            rotation = child.resultTransform.skX;
+            rotation = rotation % 360;
+            a2 = ((a2 + os) * IkConstraint.radDeg - 0) * s2 + os2 - rotation;
+            if (a2 > 180)
+                a2 -= 360;
+            else if (a2 < -180)
+                a2 += 360;
+            child.resultTransform.x = cx;
+            child.resultTransform.y = cy;
+            child.resultTransform.skX = child.resultTransform.skY = child.resultTransform.skY + a2 * alpha;
+            parent.update();
+        }
+        _applyIk3(parent, child, targetX, targetY, bendDir, alpha) {
+            if (alpha == 0) {
+                return;
+            }
+            var cwx, cwy;
+            const x = child.resultMatrix.a * child.length;
+            const y = child.resultMatrix.b * child.length;
+            const lLL = x * x + y * y;
+            const lL = Math.sqrt(lLL);
+            var parentX = parent.resultMatrix.tx;
+            var parentY = parent.resultMatrix.ty;
+            var childX = child.resultMatrix.tx;
+            var childY = child.resultMatrix.ty;
+            var dX = childX - parentX;
+            var dY = childY - parentY;
+            const lPP = dX * dX + dY * dY;
+            const lP = Math.sqrt(lPP);
+            dX = targetX - parent.resultMatrix.tx;
+            dY = targetY - parent.resultMatrix.ty;
+            const lTT = dX * dX + dY * dY;
+            const lT = Math.sqrt(lTT);
+            if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) {
+                var rate;
+                if (lL + lP <= lT) {
+                    rate = 1;
+                }
+                else {
+                    rate = -1;
+                }
+                childX = parentX + rate * (targetX - parentX) * lP / lT;
+                childY = parentY + rate * (targetY - parentY) * lP / lT;
+            }
+            else {
+                const h = (lPP - lLL + lTT) / (2 * lTT);
+                const r = Math.sqrt(lPP - h * h * lTT) / lT;
+                const hX = parentX + (dX * h);
+                const hY = parentY + (dY * h);
+                const rX = -dY * r;
+                const rY = dX * r;
+                if (bendDir > 0) {
+                    childX = hX - rX;
+                    childY = hY - rY;
+                }
+                else {
+                    childX = hX + rX;
+                    childY = hY + rY;
+                }
+            }
+            cwx = childX;
+            cwy = childY;
+            if (this.isDebug) {
+                if (!this._sp) {
+                    this._sp = new Laya.Sprite();
+                    Laya.ILaya.stage.addChild(this._sp);
+                }
+                this._sp.graphics.clear();
+                this._sp.graphics.drawCircle(parentX, parentY, 15, "#ff00ff");
+                this._sp.graphics.drawCircle(targetX, targetY, 15, "#ffff00");
+                this._sp.graphics.drawCircle(cwx, cwy, 15, "#ff00ff");
+            }
+            var pRotation;
+            pRotation = Math.atan2(cwy - parent.resultMatrix.ty, cwx - parent.resultMatrix.tx);
+            parent.setRotation(pRotation);
+            var pTarMatrix;
+            pTarMatrix = IkConstraint._tempMatrix;
+            pTarMatrix.identity();
+            pTarMatrix.rotate(pRotation);
+            pTarMatrix.scale(parent.resultMatrix.getScaleX(), parent.resultMatrix.getScaleY());
+            pTarMatrix.translate(parent.resultMatrix.tx, parent.resultMatrix.ty);
+            pTarMatrix.copyTo(parent.resultMatrix);
+            parent.updateChild();
+            var childRotation;
+            childRotation = Math.atan2(targetY - cwy, targetX - cwx);
+            child.setRotation(childRotation);
+            var childTarMatrix;
+            childTarMatrix = IkConstraint._tempMatrix;
+            childTarMatrix.identity();
+            childTarMatrix.rotate(childRotation);
+            childTarMatrix.scale(child.resultMatrix.getScaleX(), child.resultMatrix.getScaleY());
+            childTarMatrix.translate(cwx, cwy);
+            pTarMatrix.copyTo(child.resultMatrix);
+            child.updateChild();
+        }
+    }
+    IkConstraint.radDeg = 180 / Math.PI;
+    IkConstraint.degRad = Math.PI / 180;
+    IkConstraint._tempMatrix = new Laya.Matrix();
+
+    class IkConstraintData {
+        constructor() {
+            this.boneNames = [];
+            this.bendDirection = 1;
+            this.mix = 1;
+            this.isSpine = true;
+            this.targetBoneIndex = -1;
+            this.boneIndexs = [];
+        }
+    }
+
+    class PathConstraint {
+        constructor(data, bones) {
+            this._debugKey = false;
+            this._segments = [];
+            this._curves = [];
+            this.data = data;
+            this.position = data.position;
+            this.spacing = data.spacing;
+            this.rotateMix = data.rotateMix;
+            this.translateMix = data.translateMix;
+            this.bones = [];
+            var tBoneIds = this.data.bones;
+            for (var i = 0, n = tBoneIds.length; i < n; i++) {
+                this.bones.push(bones[tBoneIds[i]]);
+            }
+        }
+        apply(boneList, graphics) {
+            if (!this.target)
+                return;
+            var tTranslateMix = this.translateMix;
+            var tRotateMix = this.translateMix;
+            var tRotate = tRotateMix > 0;
+            var tSpacingMode = this.data.spacingMode;
+            var tLengthSpacing = tSpacingMode == "length";
+            var tRotateMode = this.data.rotateMode;
+            var tTangents = tRotateMode == "tangent";
+            var tScale = tRotateMode == "chainScale";
+            var lengths = [];
+            var boneCount = this.bones.length;
+            var spacesCount = tTangents ? boneCount : boneCount + 1;
+            var spaces = [];
+            this._spaces = spaces;
+            spaces[0] = this.position;
+            var spacing = this.spacing;
+            if (tScale || tLengthSpacing) {
+                for (var i = 0, n = spacesCount - 1; i < n;) {
+                    var bone = this.bones[i];
+                    var length = bone.length;
+                    var x = length * bone.resultMatrix.a;
+                    var y = length * bone.resultMatrix.b;
+                    length = Math.sqrt(x * x + y * y);
+                    if (tScale)
+                        lengths[i] = length;
+                    spaces[++i] = tLengthSpacing ? Math.max(0, length + spacing) : spacing;
+                }
+            }
+            else {
+                for (i = 1; i < spacesCount; i++) {
+                    spaces[i] = spacing;
+                }
+            }
+            var positions = this.computeWorldPositions(this.target, boneList, graphics, spacesCount, tTangents, this.data.positionMode == "percent", tSpacingMode == "percent");
+            if (this._debugKey) {
+                for (i = 0; i < positions.length; i++) {
+                    graphics.drawCircle(positions[i++], positions[i++], 5, "#00ff00");
+                }
+                var tLinePos = [];
+                for (i = 0; i < positions.length; i++) {
+                    tLinePos.push(positions[i++], positions[i++]);
+                }
+                graphics.drawLines(0, 0, tLinePos, "#ff0000");
+            }
+            var boneX = positions[0];
+            var boneY = positions[1];
+            var offsetRotation = this.data.offsetRotation;
+            var tip = tRotateMode == "chain" && offsetRotation == 0;
+            var p;
+            for (i = 0, p = 3; i < boneCount; i++, p += 3) {
+                bone = this.bones[i];
+                bone.resultMatrix.tx += (boneX - bone.resultMatrix.tx) * tTranslateMix;
+                bone.resultMatrix.ty += (boneY - bone.resultMatrix.ty) * tTranslateMix;
+                x = positions[p];
+                y = positions[p + 1];
+                var dx = x - boneX, dy = y - boneY;
+                if (tScale) {
+                    length = lengths[i];
+                    if (length != 0) {
+                        var s = (Math.sqrt(dx * dx + dy * dy) / length - 1) * tRotateMix + 1;
+                        bone.resultMatrix.a *= s;
+                        bone.resultMatrix.c *= s;
+                    }
+                }
+                boneX = x;
+                boneY = y;
+                if (tRotate) {
+                    var a = bone.resultMatrix.a;
+                    var b = bone.resultMatrix.c;
+                    var c = bone.resultMatrix.b;
+                    var d = bone.resultMatrix.d;
+                    var r;
+                    var cos;
+                    var sin;
+                    if (tTangents) {
+                        r = positions[p - 1];
+                    }
+                    else if (spaces[i + 1] == 0) {
+                        r = positions[p + 2];
+                    }
+                    else {
+                        r = Math.atan2(dy, dx);
+                    }
+                    r -= Math.atan2(c, a) - offsetRotation / 180 * Math.PI;
+                    if (tip) {
+                        cos = Math.cos(r);
+                        sin = Math.sin(r);
+                        length = bone.length;
+                        boneX += (length * (cos * a - sin * c) - dx) * tRotateMix;
+                        boneY += (length * (sin * a + cos * c) - dy) * tRotateMix;
+                    }
+                    if (r > Math.PI) {
+                        r -= (Math.PI * 2);
+                    }
+                    else if (r < -Math.PI) {
+                        r += (Math.PI * 2);
+                    }
+                    r *= tRotateMix;
+                    cos = Math.cos(r);
+                    sin = Math.sin(r);
+                    bone.resultMatrix.a = cos * a - sin * c;
+                    bone.resultMatrix.c = cos * b - sin * d;
+                    bone.resultMatrix.b = sin * a + cos * c;
+                    bone.resultMatrix.d = sin * b + cos * d;
+                }
+            }
+        }
+        computeWorldVertices2(boneSlot, boneList, start, count, worldVertices, offset) {
+            var tBones = boneSlot.currDisplayData.bones;
+            var tWeights = boneSlot.currDisplayData.weights;
+            var tTriangles = boneSlot.currDisplayData.triangles;
+            var tMatrix;
+            var i = 0;
+            var v = 0;
+            var skip = 0;
+            var n = 0;
+            var w = 0;
+            var b = 0;
+            var wx = 0;
+            var wy = 0;
+            var vx = 0;
+            var vy = 0;
+            var bone;
+            var len;
+            if (tBones == null) {
+                if (!tTriangles)
+                    tTriangles = tWeights;
+                if (boneSlot.deformData)
+                    tTriangles = boneSlot.deformData;
+                var parentName;
+                parentName = boneSlot.parent;
+                if (boneList) {
+                    len = boneList.length;
+                    for (i = 0; i < len; i++) {
+                        if (boneList[i].name == parentName) {
+                            bone = boneList[i];
+                            break;
+                        }
+                    }
+                }
+                var tBoneMt;
+                if (bone) {
+                    tBoneMt = bone.resultMatrix;
+                }
+                if (!tBoneMt)
+                    tBoneMt = PathConstraint._tempMt;
+                var x = tBoneMt.tx;
+                var y = tBoneMt.ty;
+                var a = tBoneMt.a, bb = tBoneMt.b, c = tBoneMt.c, d = tBoneMt.d;
+                if (bone)
+                    d *= bone.d;
+                for (v = start, w = offset; w < count; v += 2, w += 2) {
+                    vx = tTriangles[v], vy = tTriangles[v + 1];
+                    worldVertices[w] = vx * a + vy * bb + x;
+                    worldVertices[w + 1] = -(vx * c + vy * d + y);
+                }
+                return;
+            }
+            for (i = 0; i < start; i += 2) {
+                n = tBones[v];
+                v += n + 1;
+                skip += n;
+            }
+            var skeletonBones = boneList;
+            for (w = offset, b = skip * 3; w < count; w += 2) {
+                wx = 0, wy = 0;
+                n = tBones[v++];
+                n += v;
+                for (; v < n; v++, b += 3) {
+                    tMatrix = skeletonBones[tBones[v]].resultMatrix;
+                    vx = tWeights[b];
+                    vy = tWeights[b + 1];
+                    var weight = tWeights[b + 2];
+                    wx += (vx * tMatrix.a + vy * tMatrix.c + tMatrix.tx) * weight;
+                    wy += (vx * tMatrix.b + vy * tMatrix.d + tMatrix.ty) * weight;
+                }
+                worldVertices[w] = wx;
+                worldVertices[w + 1] = wy;
+            }
+        }
+        computeWorldPositions(boneSlot, boneList, graphics, spacesCount, tangents, percentPosition, percentSpacing) {
+            var tBones = boneSlot.currDisplayData.bones;
+            var tWeights = boneSlot.currDisplayData.weights;
+            var tTriangles = boneSlot.currDisplayData.triangles;
+            var tVertices = [];
+            var i = 0;
+            var verticesLength = boneSlot.currDisplayData.verLen;
+            var position = this.position;
+            var spaces = this._spaces;
+            var world = [];
+            var out = [];
+            var curveCount = verticesLength / 6;
+            var prevCurve = -1;
+            var pathLength;
+            var o, curve;
+            var p;
+            var space;
+            var prev;
+            var length;
+            {
+                curveCount--;
+                verticesLength -= 4;
+                this.computeWorldVertices2(boneSlot, boneList, 2, verticesLength, tVertices, 0);
+                if (this._debugKey) {
+                    for (i = 0; i < tVertices.length;) {
+                        graphics.drawCircle(tVertices[i++], tVertices[i++], 10, "#ff0000");
+                    }
+                }
+                world = tVertices;
+            }
+            this._curves.length = curveCount;
+            var curves = this._curves;
+            pathLength = 0;
+            var x1 = world[0], y1 = world[1], cx1 = 0, cy1 = 0, cx2 = 0, cy2 = 0, x2 = 0, y2 = 0;
+            var tmpx, tmpy, dddfx, dddfy, ddfx, ddfy, dfx, dfy;
+            var w;
+            for (i = 0, w = 2; i < curveCount; i++, w += 6) {
+                cx1 = world[w];
+                cy1 = world[w + 1];
+                cx2 = world[w + 2];
+                cy2 = world[w + 3];
+                x2 = world[w + 4];
+                y2 = world[w + 5];
+                tmpx = (x1 - cx1 * 2 + cx2) * 0.1875;
+                tmpy = (y1 - cy1 * 2 + cy2) * 0.1875;
+                dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.09375;
+                dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.09375;
+                ddfx = tmpx * 2 + dddfx;
+                ddfy = tmpy * 2 + dddfy;
+                dfx = (cx1 - x1) * 0.75 + tmpx + dddfx * 0.16666667;
+                dfy = (cy1 - y1) * 0.75 + tmpy + dddfy * 0.16666667;
+                pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
+                dfx += ddfx;
+                dfy += ddfy;
+                ddfx += dddfx;
+                ddfy += dddfy;
+                pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
+                dfx += ddfx;
+                dfy += ddfy;
+                pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
+                dfx += ddfx + dddfx;
+                dfy += ddfy + dddfy;
+                pathLength += Math.sqrt(dfx * dfx + dfy * dfy);
+                curves[i] = pathLength;
+                x1 = x2;
+                y1 = y2;
+            }
+            if (percentPosition)
+                position *= pathLength;
+            if (percentSpacing) {
+                for (i = 0; i < spacesCount; i++)
+                    spaces[i] *= pathLength;
+            }
+            var segments = this._segments;
+            var curveLength = 0;
+            var segment;
+            for (i = 0, o = 0, curve = 0, segment = 0; i < spacesCount; i++, o += 3) {
+                space = spaces[i];
+                position += space;
+                p = position;
+                if (p < 0) {
+                    this.addBeforePosition(p, world, 0, out, o);
+                    continue;
+                }
+                else if (p > pathLength) {
+                    this.addAfterPosition(p - pathLength, world, verticesLength - 4, out, o);
+                    continue;
+                }
+                for (;; curve++) {
+                    length = curves[curve];
+                    if (p > length)
+                        continue;
+                    if (curve == 0)
+                        p /= length;
+                    else {
+                        prev = curves[curve - 1];
+                        p = (p - prev) / (length - prev);
+                    }
+                    break;
+                }
+                if (curve != prevCurve) {
+                    prevCurve = curve;
+                    var ii = curve * 6;
+                    x1 = world[ii];
+                    y1 = world[ii + 1];
+                    cx1 = world[ii + 2];
+                    cy1 = world[ii + 3];
+                    cx2 = world[ii + 4];
+                    cy2 = world[ii + 5];
+                    x2 = world[ii + 6];
+                    y2 = world[ii + 7];
+                    tmpx = (x1 - cx1 * 2 + cx2) * 0.03;
+                    tmpy = (y1 - cy1 * 2 + cy2) * 0.03;
+                    dddfx = ((cx1 - cx2) * 3 - x1 + x2) * 0.006;
+                    dddfy = ((cy1 - cy2) * 3 - y1 + y2) * 0.006;
+                    ddfx = tmpx * 2 + dddfx;
+                    ddfy = tmpy * 2 + dddfy;
+                    dfx = (cx1 - x1) * 0.3 + tmpx + dddfx * 0.16666667;
+                    dfy = (cy1 - y1) * 0.3 + tmpy + dddfy * 0.16666667;
+                    curveLength = Math.sqrt(dfx * dfx + dfy * dfy);
+                    segments[0] = curveLength;
+                    for (ii = 1; ii < 8; ii++) {
+                        dfx += ddfx;
+                        dfy += ddfy;
+                        ddfx += dddfx;
+                        ddfy += dddfy;
+                        curveLength += Math.sqrt(dfx * dfx + dfy * dfy);
+                        segments[ii] = curveLength;
+                    }
+                    dfx += ddfx;
+                    dfy += ddfy;
+                    curveLength += Math.sqrt(dfx * dfx + dfy * dfy);
+                    segments[8] = curveLength;
+                    dfx += ddfx + dddfx;
+                    dfy += ddfy + dddfy;
+                    curveLength += Math.sqrt(dfx * dfx + dfy * dfy);
+                    segments[9] = curveLength;
+                    segment = 0;
+                }
+                p *= curveLength;
+                for (;; segment++) {
+                    length = segments[segment];
+                    if (p > length)
+                        continue;
+                    if (segment == 0)
+                        p /= length;
+                    else {
+                        prev = segments[segment - 1];
+                        p = segment + (p - prev) / (length - prev);
+                    }
+                    break;
+                }
+                this.addCurvePosition(p * 0.1, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents || (i > 0 && space == 0));
+            }
+            return out;
+        }
+        addBeforePosition(p, temp, i, out, o) {
+            var x1 = temp[i], y1 = temp[i + 1], dx = temp[i + 2] - x1, dy = temp[i + 3] - y1, r = Math.atan2(dy, dx);
+            out[o] = x1 + p * Math.cos(r);
+            out[o + 1] = y1 + p * Math.sin(r);
+            out[o + 2] = r;
+        }
+        addAfterPosition(p, temp, i, out, o) {
+            var x1 = temp[i + 2], y1 = temp[i + 3], dx = x1 - temp[i], dy = y1 - temp[i + 1], r = Math.atan2(dy, dx);
+            out[o] = x1 + p * Math.cos(r);
+            out[o + 1] = y1 + p * Math.sin(r);
+            out[o + 2] = r;
+        }
+        addCurvePosition(p, x1, y1, cx1, cy1, cx2, cy2, x2, y2, out, o, tangents) {
+            if (p == 0)
+                p = 0.0001;
+            var tt = p * p, ttt = tt * p, u = 1 - p, uu = u * u, uuu = uu * u;
+            var ut = u * p, ut3 = ut * 3, uut3 = u * ut3, utt3 = ut3 * p;
+            var x = x1 * uuu + cx1 * uut3 + cx2 * utt3 + x2 * ttt, y = y1 * uuu + cy1 * uut3 + cy2 * utt3 + y2 * ttt;
+            out[o] = x;
+            out[o + 1] = y;
+            if (tangents) {
+                out[o + 2] = Math.atan2(y - (y1 * uu + cy1 * ut * 2 + cy2 * tt), x - (x1 * uu + cx1 * ut * 2 + cx2 * tt));
+            }
+            else {
+                out[o + 2] = 0;
+            }
+        }
+    }
+    PathConstraint.BEFORE = -2;
+    PathConstraint.AFTER = -3;
+    PathConstraint._tempMt = new Laya.Matrix();
+
+    class PathConstraintData {
+        constructor() {
+            this.bones = [];
+        }
+    }
+
+    class TfConstraint {
+        constructor(data, bones) {
+            this._temp = [];
+            this._data = data;
+            if (this._bones == null) {
+                this._bones = [];
+            }
+            this.target = bones[data.targetIndex];
+            var j, n;
+            for (j = 0, n = data.boneIndexs.length; j < n; j++) {
+                this._bones.push(bones[data.boneIndexs[j]]);
+            }
+            this.rotateMix = data.rotateMix;
+            this.translateMix = data.translateMix;
+            this.scaleMix = data.scaleMix;
+            this.shearMix = data.shearMix;
+        }
+        apply() {
+            var tTfBone;
+            var ta = this.target.resultMatrix.a, tb = this.target.resultMatrix.b, tc = this.target.resultMatrix.c, td = this.target.resultMatrix.d;
+            for (var j = 0, n = this._bones.length; j < n; j++) {
+                tTfBone = this._bones[j];
+                if (this.rotateMix > 0) {
+                    var a = tTfBone.resultMatrix.a, b = tTfBone.resultMatrix.b, c = tTfBone.resultMatrix.c, d = tTfBone.resultMatrix.d;
+                    var r = Math.atan2(tc, ta) - Math.atan2(c, a) + this._data.offsetRotation * Math.PI / 180;
+                    if (r > Math.PI)
+                        r -= Math.PI * 2;
+                    else if (r < -Math.PI)
+                        r += Math.PI * 2;
+                    r *= this.rotateMix;
+                    var cos = Math.cos(r), sin = Math.sin(r);
+                    tTfBone.resultMatrix.a = cos * a - sin * c;
+                    tTfBone.resultMatrix.b = cos * b - sin * d;
+                    tTfBone.resultMatrix.c = sin * a + cos * c;
+                    tTfBone.resultMatrix.d = sin * b + cos * d;
+                }
+                if (this.translateMix) {
+                    this._temp[0] = this._data.offsetX;
+                    this._temp[1] = this._data.offsetY;
+                    this.target.localToWorld(this._temp);
+                    tTfBone.resultMatrix.tx += (this._temp[0] - tTfBone.resultMatrix.tx) * this.translateMix;
+                    tTfBone.resultMatrix.ty += (this._temp[1] - tTfBone.resultMatrix.ty) * this.translateMix;
+                    tTfBone.updateChild();
+                }
+                if (this.scaleMix > 0) {
+                    var bs = Math.sqrt(tTfBone.resultMatrix.a * tTfBone.resultMatrix.a + tTfBone.resultMatrix.c * tTfBone.resultMatrix.c);
+                    var ts = Math.sqrt(ta * ta + tc * tc);
+                    var s = bs > 0.00001 ? (bs + (ts - bs + this._data.offsetScaleX) * this.scaleMix) / bs : 0;
+                    tTfBone.resultMatrix.a *= s;
+                    tTfBone.resultMatrix.c *= s;
+                    bs = Math.sqrt(tTfBone.resultMatrix.b * tTfBone.resultMatrix.b + tTfBone.resultMatrix.d * tTfBone.resultMatrix.d);
+                    ts = Math.sqrt(tb * tb + td * td);
+                    s = bs > 0.00001 ? (bs + (ts - bs + this._data.offsetScaleY) * this.scaleMix) / bs : 0;
+                    tTfBone.resultMatrix.b *= s;
+                    tTfBone.resultMatrix.d *= s;
+                }
+                if (this.shearMix > 0) {
+                    b = tTfBone.resultMatrix.b, d = tTfBone.resultMatrix.d;
+                    var by = Math.atan2(d, b);
+                    r = Math.atan2(td, tb) - Math.atan2(tc, ta) - (by - Math.atan2(tTfBone.resultMatrix.c, tTfBone.resultMatrix.a));
+                    if (r > Math.PI)
+                        r -= Math.PI * 2;
+                    else if (r < -Math.PI)
+                        r += Math.PI * 2;
+                    r = by + (r + this._data.offsetShearY * Math.PI / 180) * this.shearMix;
+                    s = Math.sqrt(b * b + d * d);
+                    tTfBone.resultMatrix.b = Math.cos(r) * s;
+                    tTfBone.resultMatrix.d = Math.sin(r) * s;
+                }
+            }
+        }
+    }
+
+    class Skeleton extends Laya.Sprite {
+        constructor(templet = null, aniMode = 0) {
+            super();
+            this._boneMatrixArray = [];
+            this._lastTime = 0;
+            this._currAniIndex = -1;
+            this._pause = true;
+            this._aniClipIndex = -1;
+            this._clipIndex = -1;
+            this._skinIndex = 0;
+            this._skinName = "default";
+            this._aniMode = 0;
+            this._index = -1;
+            this._total = -1;
+            this._indexControl = false;
+            this._eventIndex = 0;
+            this._drawOrderIndex = 0;
+            this._drawOrder = null;
+            this._lastAniClipIndex = -1;
+            this._lastUpdateAniClipIndex = -1;
+            this._playAudio = true;
+            this._soundChannelArr = [];
+            if (templet)
+                this.init(templet, aniMode);
+        }
+        init(templet, aniMode = 0) {
+            var i = 0, n;
+            if (aniMode == 1) {
+                this._graphicsCache = [];
+                for (i = 0, n = templet.getAnimationCount(); i < n; i++) {
+                    this._graphicsCache.push([]);
+                }
+            }
+            this._yReverseMatrix = templet.yReverseMatrix;
+            this._aniMode = aniMode;
+            this._templet = templet;
+            this._templet._addReference(1);
+            this._player = new AnimationPlayer();
+            this._player.cacheFrameRate = templet.rate;
+            this._player.templet = templet;
+            this._player.play();
+            this._parseSrcBoneMatrix();
+            this._boneList = templet.mBoneArr;
+            this._rootBone = templet.mRootBone;
+            this._aniSectionDic = templet.aniSectionDic;
+            if (templet.ikArr.length > 0) {
+                this._ikArr = [];
+                for (i = 0, n = templet.ikArr.length; i < n; i++) {
+                    this._ikArr.push(new IkConstraint(templet.ikArr[i], this._boneList));
+                }
+            }
+            if (templet.pathArr.length > 0) {
+                var tPathData;
+                var tPathConstraint;
+                if (this._pathDic == null)
+                    this._pathDic = {};
+                var tBoneSlot;
+                for (i = 0, n = templet.pathArr.length; i < n; i++) {
+                    tPathData = templet.pathArr[i];
+                    tPathConstraint = new PathConstraint(tPathData, this._boneList);
+                    tBoneSlot = this._boneSlotDic[tPathData.name];
+                    if (tBoneSlot) {
+                        tPathConstraint = new PathConstraint(tPathData, this._boneList);
+                        tPathConstraint.target = tBoneSlot;
+                    }
+                    this._pathDic[tPathData.name] = tPathConstraint;
+                }
+            }
+            if (templet.tfArr.length > 0) {
+                this._tfArr = [];
+                for (i = 0, n = templet.tfArr.length; i < n; i++) {
+                    this._tfArr.push(new TfConstraint(templet.tfArr[i], this._boneList));
+                }
+            }
+            if (templet.skinDataArray.length > 0) {
+                var tSkinData = this._templet.skinDataArray[this._skinIndex];
+                this._skinName = tSkinData.name;
+            }
+            this._player.on(Laya.Event.PLAYED, this, this._onPlay);
+            this._player.on(Laya.Event.STOPPED, this, this._onStop);
+            this._player.on(Laya.Event.PAUSED, this, this._onPause);
+        }
+        get url() {
+            return this._aniPath;
+        }
+        set url(path) {
+            this.load(path);
+        }
+        load(path, complete = null, aniMode = 0) {
+            this._aniPath = path;
+            this._complete = complete;
+            this._loadAniMode = aniMode;
+            Laya.ILaya.loader.load([{ url: path, type: Laya.ILaya.Loader.BUFFER }], Laya.Handler.create(this, this._onLoaded));
+        }
+        _onLoaded() {
+            var arraybuffer = Laya.ILaya.Loader.getRes(this._aniPath);
+            if (arraybuffer == null)
+                return;
+            if (IAniLib.Templet.TEMPLET_DICTIONARY == null) {
+                IAniLib.Templet.TEMPLET_DICTIONARY = {};
+            }
+            var tFactory;
+            tFactory = IAniLib.Templet.TEMPLET_DICTIONARY[this._aniPath];
+            if (tFactory) {
+                if (tFactory.isParseFail) {
+                    this._parseFail();
+                }
+                else {
+                    if (tFactory.isParserComplete) {
+                        this._parseComplete();
+                    }
+                    else {
+                        tFactory.on(Laya.Event.COMPLETE, this, this._parseComplete);
+                        tFactory.on(Laya.Event.ERROR, this, this._parseFail);
+                    }
+                }
+            }
+            else {
+                tFactory = new IAniLib.Templet();
+                tFactory._setCreateURL(this._aniPath);
+                IAniLib.Templet.TEMPLET_DICTIONARY[this._aniPath] = tFactory;
+                tFactory.on(Laya.Event.COMPLETE, this, this._parseComplete);
+                tFactory.on(Laya.Event.ERROR, this, this._parseFail);
+                tFactory.isParserComplete = false;
+                tFactory.parseData(null, arraybuffer);
+            }
+        }
+        _parseComplete() {
+            var tTemple = IAniLib.Templet.TEMPLET_DICTIONARY[this._aniPath];
+            if (tTemple) {
+                this.init(tTemple, this._loadAniMode);
+                this.play(0, true);
+            }
+            this._complete && this._complete.runWith(this);
+        }
+        _parseFail() {
+            console.log("[Error]:" + this._aniPath + "解析失败");
+        }
+        _onPlay() {
+            this.event(Laya.Event.PLAYED);
+        }
+        _onStop() {
+            var tEventData;
+            var tEventAniArr = this._templet.eventAniArr;
+            var tEventArr = tEventAniArr[this._aniClipIndex];
+            if (tEventArr && this._eventIndex < tEventArr.length) {
+                for (; this._eventIndex < tEventArr.length; this._eventIndex++) {
+                    tEventData = tEventArr[this._eventIndex];
+                    if (tEventData.time >= this._player.playStart && tEventData.time <= this._player.playEnd) {
+                        this.event(Laya.Event.LABEL, tEventData);
+                    }
+                }
+            }
+            this._drawOrder = null;
+            this.event(Laya.Event.STOPPED);
+        }
+        _onPause() {
+            this.event(Laya.Event.PAUSED);
+        }
+        _parseSrcBoneMatrix() {
+            var i = 0, n = 0;
+            n = this._templet.srcBoneMatrixArr.length;
+            for (i = 0; i < n; i++) {
+                this._boneMatrixArray.push(new Laya.Matrix());
+            }
+            if (this._aniMode == 0) {
+                this._boneSlotDic = this._templet.boneSlotDic;
+                this._bindBoneBoneSlotDic = this._templet.bindBoneBoneSlotDic;
+                this._boneSlotArray = this._templet.boneSlotArray;
+            }
+            else {
+                if (this._boneSlotDic == null)
+                    this._boneSlotDic = {};
+                if (this._bindBoneBoneSlotDic == null)
+                    this._bindBoneBoneSlotDic = {};
+                if (this._boneSlotArray == null)
+                    this._boneSlotArray = [];
+                var tArr = this._templet.boneSlotArray;
+                var tBS;
+                var tBSArr;
+                for (i = 0, n = tArr.length; i < n; i++) {
+                    tBS = tArr[i];
+                    tBSArr = this._bindBoneBoneSlotDic[tBS.parent];
+                    if (tBSArr == null) {
+                        this._bindBoneBoneSlotDic[tBS.parent] = tBSArr = [];
+                    }
+                    this._boneSlotDic[tBS.name] = tBS = tBS.copy();
+                    tBSArr.push(tBS);
+                    this._boneSlotArray.push(tBS);
+                }
+            }
+        }
+        _emitMissedEvents(startTime, endTime, startIndex = 0) {
+            var tEventAniArr = this._templet.eventAniArr;
+            var tEventArr = tEventAniArr[this._player.currentAnimationClipIndex];
+            if (tEventArr) {
+                var i = 0, len;
+                var tEventData;
+                len = tEventArr.length;
+                for (i = startIndex; i < len; i++) {
+                    tEventData = tEventArr[i];
+                    if (tEventData.time >= this._player.playStart && tEventData.time <= this._player.playEnd) {
+                        this.event(Laya.Event.LABEL, tEventData);
+                    }
+                }
+            }
+        }
+        _update(autoKey = true) {
+            if (this._pause)
+                return;
+            if (autoKey && this._indexControl) {
+                return;
+            }
+            var tCurrTime = this.timer.currTimer;
+            var preIndex = this._player.currentKeyframeIndex;
+            var dTime = tCurrTime - this._lastTime;
+            if (autoKey) {
+                this._player._update(dTime);
+            }
+            else {
+                preIndex = -1;
+            }
+            this._lastTime = tCurrTime;
+            if (!this._player)
+                return;
+            this._index = this._clipIndex = this._player.currentKeyframeIndex;
+            if (this._index < 0)
+                return;
+            if (dTime > 0 && this._clipIndex == preIndex && this._lastUpdateAniClipIndex == this._aniClipIndex) {
+                return;
+            }
+            this._lastUpdateAniClipIndex = this._aniClipIndex;
+            if (preIndex > this._clipIndex && this._eventIndex != 0) {
+                this._emitMissedEvents(this._player.playStart, this._player.playEnd, this._eventIndex);
+                this._eventIndex = 0;
+            }
+            var tEventArr = this._templet.eventAniArr[this._aniClipIndex];
+            var _soundChannel;
+            if (tEventArr && this._eventIndex < tEventArr.length) {
+                var tEventData = tEventArr[this._eventIndex];
+                if (tEventData.time >= this._player.playStart && tEventData.time <= this._player.playEnd) {
+                    if (this._player.currentPlayTime >= tEventData.time) {
+                        this.event(Laya.Event.LABEL, tEventData);
+                        this._eventIndex++;
+                        if (this._playAudio && tEventData.audioValue && tEventData.audioValue !== "null" && tEventData.audioValue !== "undefined") {
+                            _soundChannel = Laya.SoundManager.playSound(this._player.templet._path + tEventData.audioValue, 1, Laya.Handler.create(this, this._onAniSoundStoped));
+                            Laya.SoundManager.playbackRate = this._player.playbackRate;
+                            _soundChannel && this._soundChannelArr.push(_soundChannel);
+                        }
+                    }
+                }
+                else if (tEventData.time < this._player.playStart && this._playAudio && tEventData.audioValue && tEventData.audioValue !== "null" && tEventData.audioValue !== "undefined") {
+                    this._eventIndex++;
+                    _soundChannel = Laya.SoundManager.playSound(this._player.templet._path + tEventData.audioValue, 1, Laya.Handler.create(this, this._onAniSoundStoped), null, (this._player.currentPlayTime - tEventData.time) / 1000);
+                    Laya.SoundManager.playbackRate = this._player.playbackRate;
+                    _soundChannel && this._soundChannelArr.push(_soundChannel);
+                }
+                else {
+                    this._eventIndex++;
+                }
+            }
+            var tGraphics;
+            if (this._aniMode == 0) {
+                tGraphics = this._templet.getGrahicsDataWithCache(this._aniClipIndex, this._clipIndex) || this._createGraphics();
+                if (tGraphics && this.graphics != tGraphics) {
+                    this.graphics = tGraphics;
+                }
+            }
+            else if (this._aniMode == 1) {
+                tGraphics = this._getGrahicsDataWithCache(this._aniClipIndex, this._clipIndex) || this._createGraphics();
+                if (tGraphics && this.graphics != tGraphics) {
+                    this.graphics = tGraphics;
+                }
+            }
+            else {
+                this._createGraphics();
+            }
+        }
+        _onAniSoundStoped(force) {
+            var _channel;
+            for (var len = this._soundChannelArr.length, i = 0; i < len; i++) {
+                _channel = this._soundChannelArr[i];
+                if (_channel.isStopped || force) {
+                    !_channel.isStopped && _channel.stop();
+                    this._soundChannelArr.splice(i, 1);
+                    len--;
+                    i--;
+                }
+            }
+        }
+        _createGraphics(_clipIndex = -1) {
+            if (_clipIndex == -1)
+                _clipIndex = this._clipIndex;
+            var curTime = _clipIndex * this._player.cacheFrameRateInterval;
+            var tDrawOrderData;
+            var tDrawOrderAniArr = this._templet.drawOrderAniArr;
+            var tDrawOrderArr = tDrawOrderAniArr[this._aniClipIndex];
+            if (tDrawOrderArr && tDrawOrderArr.length > 0) {
+                this._drawOrderIndex = 0;
+                tDrawOrderData = tDrawOrderArr[this._drawOrderIndex];
+                while (curTime >= tDrawOrderData.time) {
+                    this._drawOrder = tDrawOrderData.drawOrder;
+                    this._drawOrderIndex++;
+                    if (this._drawOrderIndex >= tDrawOrderArr.length) {
+                        break;
+                    }
+                    tDrawOrderData = tDrawOrderArr[this._drawOrderIndex];
+                }
+            }
+            if (this._aniMode == 0 || this._aniMode == 1) {
+                this.graphics = GraphicsAni.create();
+            }
+            else {
+                if (this.graphics instanceof GraphicsAni) {
+                    this.graphics.clear();
+                }
+                else {
+                    this.graphics = GraphicsAni.create();
+                }
+            }
+            var tGraphics = this.graphics;
+            var bones = this._templet.getNodes(this._aniClipIndex);
+            var stopped = this._player.state == 0;
+            this._templet.getOriginalData(this._aniClipIndex, this._curOriginalData, null, _clipIndex, stopped ? (curTime + this._player.cacheFrameRateInterval) : curTime);
+            var tSectionArr = this._aniSectionDic[this._aniClipIndex];
+            var tStartIndex = 0;
+            var i = 0, j = 0, k = 0, n = 0;
+            var tDBBoneSlot;
+            var tDBBoneSlotArr;
+            var tParentTransform;
+            var tSrcBone;
+            var boneCount = this._templet.srcBoneMatrixArr.length;
+            var origDt = this._curOriginalData;
+            for (i = 0, n = tSectionArr[0]; i < boneCount; i++) {
+                tSrcBone = this._boneList[i];
+                var resultTrans = tSrcBone.resultTransform;
+                tParentTransform = this._templet.srcBoneMatrixArr[i];
+                resultTrans.scX = tParentTransform.scX * origDt[tStartIndex++];
+                resultTrans.skX = tParentTransform.skX + origDt[tStartIndex++];
+                resultTrans.skY = tParentTransform.skY + origDt[tStartIndex++];
+                resultTrans.scY = tParentTransform.scY * origDt[tStartIndex++];
+                resultTrans.x = tParentTransform.x + origDt[tStartIndex++];
+                resultTrans.y = tParentTransform.y + origDt[tStartIndex++];
+                if (this._templet.tMatrixDataLen === 8) {
+                    resultTrans.skewX = tParentTransform.skewX + origDt[tStartIndex++];
+                    resultTrans.skewY = tParentTransform.skewY + origDt[tStartIndex++];
+                }
+            }
+            var tSlotDic = {};
+            var tSlotAlphaDic = {};
+            var tBoneData;
+            for (n += tSectionArr[1]; i < n; i++) {
+                tBoneData = bones[i];
+                tSlotDic[tBoneData.name] = origDt[tStartIndex++];
+                tSlotAlphaDic[tBoneData.name] = origDt[tStartIndex++];
+                tStartIndex += 4;
+            }
+            var tBendDirectionDic = {};
+            var tMixDic = {};
+            for (n += tSectionArr[2]; i < n; i++) {
+                tBoneData = bones[i];
+                tBendDirectionDic[tBoneData.name] = origDt[tStartIndex++];
+                tMixDic[tBoneData.name] = origDt[tStartIndex++];
+                tStartIndex += 4;
+            }
+            if (this._pathDic) {
+                var tPathConstraint;
+                for (n += tSectionArr[3]; i < n; i++) {
+                    tBoneData = bones[i];
+                    tPathConstraint = this._pathDic[tBoneData.name];
+                    if (tPathConstraint) {
+                        var tByte = new Laya.Byte(tBoneData.extenData);
+                        switch (tByte.getByte()) {
+                            case 1:
+                                tPathConstraint.position = origDt[tStartIndex++];
+                                break;
+                            case 2:
+                                tPathConstraint.spacing = origDt[tStartIndex++];
+                                break;
+                            case 3:
+                                tPathConstraint.rotateMix = origDt[tStartIndex++];
+                                tPathConstraint.translateMix = origDt[tStartIndex++];
+                                break;
+                        }
+                    }
+                }
+            }
+            this._rootBone.update(this._yReverseMatrix || Laya.Matrix.TEMP.identity());
+            if (this._ikArr) {
+                var tIkConstraint;
+                for (i = 0, n = this._ikArr.length; i < n; i++) {
+                    tIkConstraint = this._ikArr[i];
+                    if (tIkConstraint.name in tBendDirectionDic) {
+                        tIkConstraint.bendDirection = tBendDirectionDic[tIkConstraint.name];
+                    }
+                    if (tIkConstraint.name in tMixDic) {
+                        tIkConstraint.mix = tMixDic[tIkConstraint.name];
+                    }
+                    tIkConstraint.apply();
+                }
+            }
+            if (this._pathDic) {
+                for (var tPathStr in this._pathDic) {
+                    tPathConstraint = this._pathDic[tPathStr];
+                    tPathConstraint.apply(this._boneList, tGraphics);
+                }
+            }
+            if (this._tfArr) {
+                var tTfConstraint;
+                for (i = 0, k = this._tfArr.length; i < k; i++) {
+                    tTfConstraint = this._tfArr[i];
+                    tTfConstraint.apply();
+                }
+            }
+            for (i = 0, k = this._boneList.length; i < k; i++) {
+                tSrcBone = this._boneList[i];
+                tDBBoneSlotArr = this._bindBoneBoneSlotDic[tSrcBone.name];
+                tSrcBone.resultMatrix.copyTo(this._boneMatrixArray[i]);
+                if (tDBBoneSlotArr) {
+                    for (j = 0, n = tDBBoneSlotArr.length; j < n; j++) {
+                        tDBBoneSlot = tDBBoneSlotArr[j];
+                        if (tDBBoneSlot) {
+                            tDBBoneSlot.setParentMatrix(tSrcBone.resultMatrix);
+                        }
+                    }
+                }
+            }
+            var tDeformDic = {};
+            var tDeformAniArr = this._templet.deformAniArr;
+            var tDeformAniData;
+            if (tDeformAniArr && tDeformAniArr.length > 0) {
+                if (this._lastAniClipIndex != this._aniClipIndex) {
+                    this._lastAniClipIndex = this._aniClipIndex;
+                    for (i = 0, n = this._boneSlotArray.length; i < n; i++) {
+                        tDBBoneSlot = this._boneSlotArray[i];
+                        tDBBoneSlot.deformData = null;
+                    }
+                }
+                var tSkinDeformAni = tDeformAniArr[this._aniClipIndex];
+                tDeformAniData = (tSkinDeformAni["default"]);
+                this._setDeform(tDeformAniData, tDeformDic, this._boneSlotArray, curTime);
+                var tSkin;
+                for (tSkin in tSkinDeformAni) {
+                    if (tSkin != "default" && tSkin != this._skinName) {
+                        tDeformAniData = tSkinDeformAni[tSkin];
+                        this._setDeform(tDeformAniData, tDeformDic, this._boneSlotArray, curTime);
+                    }
+                }
+                tDeformAniData = (tSkinDeformAni[this._skinName]);
+                this._setDeform(tDeformAniData, tDeformDic, this._boneSlotArray, curTime);
+            }
+            var tSlotData2;
+            var tSlotData3;
+            var tObject;
+            if (this._drawOrder) {
+                for (i = 0, n = this._drawOrder.length; i < n; i++) {
+                    tDBBoneSlot = this._boneSlotArray[this._drawOrder[i]];
+                    tSlotData2 = tSlotDic[tDBBoneSlot.name];
+                    tSlotData3 = tSlotAlphaDic[tDBBoneSlot.name];
+                    if (!isNaN(tSlotData2) && tSlotData2 != -2) {
+                        if (this._templet.attachmentNames) {
+                            tDBBoneSlot.showDisplayByName(this._templet.attachmentNames[tSlotData2]);
+                        }
+                        else {
+                            tDBBoneSlot.showDisplayByIndex(tSlotData2);
+                        }
+                    }
+                    if (tDeformDic[this._drawOrder[i]]) {
+                        tObject = tDeformDic[this._drawOrder[i]];
+                        if (tDBBoneSlot.currDisplayData && tObject[tDBBoneSlot.currDisplayData.attachmentName]) {
+                            tDBBoneSlot.deformData = tObject[tDBBoneSlot.currDisplayData.attachmentName];
+                        }
+                        else {
+                            tDBBoneSlot.deformData = null;
+                        }
+                    }
+                    else {
+                        tDBBoneSlot.deformData = null;
+                    }
+                    if (!isNaN(tSlotData3)) {
+                        tDBBoneSlot.draw(tGraphics, this._boneMatrixArray, this._aniMode == 2, tSlotData3);
+                    }
+                    else {
+                        tDBBoneSlot.draw(tGraphics, this._boneMatrixArray, this._aniMode == 2);
+                    }
+                }
+            }
+            else {
+                for (i = 0, n = this._boneSlotArray.length; i < n; i++) {
+                    tDBBoneSlot = this._boneSlotArray[i];
+                    tSlotData2 = tSlotDic[tDBBoneSlot.name];
+                    tSlotData3 = tSlotAlphaDic[tDBBoneSlot.name];
+                    if (!isNaN(tSlotData2) && tSlotData2 != -2) {
+                        if (this._templet.attachmentNames) {
+                            tDBBoneSlot.showDisplayByName(this._templet.attachmentNames[tSlotData2]);
+                        }
+                        else {
+                            tDBBoneSlot.showDisplayByIndex(tSlotData2);
+                        }
+                    }
+                    if (tDeformDic[i]) {
+                        tObject = tDeformDic[i];
+                        if (tDBBoneSlot.currDisplayData && tObject[tDBBoneSlot.currDisplayData.attachmentName]) {
+                            tDBBoneSlot.deformData = tObject[tDBBoneSlot.currDisplayData.attachmentName];
+                        }
+                        else {
+                            tDBBoneSlot.deformData = null;
+                        }
+                    }
+                    else {
+                        tDBBoneSlot.deformData = null;
+                    }
+                    if (!isNaN(tSlotData3)) {
+                        tDBBoneSlot.draw(tGraphics, this._boneMatrixArray, this._aniMode == 2, tSlotData3);
+                    }
+                    else {
+                        tDBBoneSlot.draw(tGraphics, this._boneMatrixArray, this._aniMode == 2);
+                    }
+                }
+            }
+            if (this._aniMode == 0) {
+                this._templet.setGrahicsDataWithCache(this._aniClipIndex, _clipIndex, tGraphics);
+                this._checkIsAllParsed(this._aniClipIndex);
+            }
+            else if (this._aniMode == 1) {
+                this._setGrahicsDataWithCache(this._aniClipIndex, _clipIndex, tGraphics);
+            }
+            return tGraphics;
+        }
+        _checkIsAllParsed(_aniClipIndex) {
+            var i, len;
+            len = Math.floor(0.01 + this._templet.getAniDuration(_aniClipIndex) / 1000 * this._player.cacheFrameRate);
+            for (i = 0; i < len; i++) {
+                if (!this._templet.getGrahicsDataWithCache(_aniClipIndex, i))
+                    return;
+            }
+            if (!this._templet.getGrahicsDataWithCache(_aniClipIndex, len)) {
+                this._createGraphics(len);
+                return;
+            }
+            this._templet.deleteAniData(_aniClipIndex);
+        }
+        _setDeform(tDeformAniData, tDeformDic, _boneSlotArray, curTime) {
+            if (!tDeformAniData)
+                return;
+            var tDeformSlotData;
+            var tDeformSlotDisplayData;
+            var tDBBoneSlot;
+            var i, n, j;
+            if (tDeformAniData) {
+                for (i = 0, n = tDeformAniData.deformSlotDataList.length; i < n; i++) {
+                    tDeformSlotData = tDeformAniData.deformSlotDataList[i];
+                    for (j = 0; j < tDeformSlotData.deformSlotDisplayList.length; j++) {
+                        tDeformSlotDisplayData = tDeformSlotData.deformSlotDisplayList[j];
+                        tDBBoneSlot = _boneSlotArray[tDeformSlotDisplayData.slotIndex];
+                        tDeformSlotDisplayData.apply(curTime, tDBBoneSlot);
+                        if (!tDeformDic[tDeformSlotDisplayData.slotIndex]) {
+                            tDeformDic[tDeformSlotDisplayData.slotIndex] = {};
+                        }
+                        tDeformDic[tDeformSlotDisplayData.slotIndex][tDeformSlotDisplayData.attachment] = tDeformSlotDisplayData.deformData;
+                    }
+                }
+            }
+        }
+        getAnimNum() {
+            return this._templet.getAnimationCount();
+        }
+        getAniNameByIndex(index) {
+            return this._templet.getAniNameByIndex(index);
+        }
+        getSlotByName(name) {
+            return this._boneSlotDic[name];
+        }
+        showSkinByName(name, freshSlotIndex = true) {
+            this.showSkinByIndex(this._templet.getSkinIndexByName(name), freshSlotIndex);
+        }
+        showSkinByIndex(skinIndex, freshSlotIndex = true) {
+            for (var i = 0; i < this._boneSlotArray.length; i++) {
+                this._boneSlotArray[i].showSlotData(null, freshSlotIndex);
+            }
+            if (this._templet.showSkinByIndex(this._boneSlotDic, skinIndex, freshSlotIndex)) {
+                var tSkinData = this._templet.skinDataArray[skinIndex];
+                this._skinIndex = skinIndex;
+                this._skinName = tSkinData.name;
+            }
+            this._clearCache();
+        }
+        showSlotSkinByIndex(slotName, index) {
+            if (this._aniMode == 0)
+                return;
+            var tBoneSlot = this.getSlotByName(slotName);
+            if (tBoneSlot) {
+                tBoneSlot.showDisplayByIndex(index);
+            }
+            this._clearCache();
+        }
+        showSlotSkinByName(slotName, name) {
+            if (this._aniMode == 0)
+                return;
+            var tBoneSlot = this.getSlotByName(slotName);
+            if (tBoneSlot) {
+                tBoneSlot.showDisplayByName(name);
+            }
+            this._clearCache();
+        }
+        replaceSlotSkinName(slotName, oldName, newName) {
+            if (this._aniMode == 0)
+                return;
+            var tBoneSlot = this.getSlotByName(slotName);
+            if (tBoneSlot) {
+                tBoneSlot.replaceDisplayByName(oldName, newName);
+            }
+            this._clearCache();
+        }
+        replaceSlotSkinByIndex(slotName, oldIndex, newIndex) {
+            if (this._aniMode == 0)
+                return;
+            var tBoneSlot = this.getSlotByName(slotName);
+            if (tBoneSlot) {
+                tBoneSlot.replaceDisplayByIndex(oldIndex, newIndex);
+            }
+            this._clearCache();
+        }
+        setSlotSkin(slotName, texture) {
+            if (this._aniMode == 0)
+                return;
+            var tBoneSlot = this.getSlotByName(slotName);
+            if (tBoneSlot) {
+                tBoneSlot.replaceSkin(texture);
+            }
+            this._clearCache();
+        }
+        _clearCache() {
+            if (this._aniMode == 1) {
+                for (var i = 0, n = this._graphicsCache.length; i < n; i++) {
+                    for (var j = 0, len = this._graphicsCache[i].length; j < len; j++) {
+                        var gp = this._graphicsCache[i][j];
+                        if (gp && gp != this.graphics) {
+                            GraphicsAni.recycle(gp);
+                        }
+                    }
+                    this._graphicsCache[i].length = 0;
+                }
+            }
+        }
+        play(nameOrIndex, loop, force = true, start = 0, end = 0, freshSkin = true, playAudio = true) {
+            this._playAudio = playAudio;
+            this._indexControl = false;
+            var index = -1;
+            var duration;
+            if (loop) {
+                duration = 2147483647;
+            }
+            else {
+                duration = 0;
+            }
+            if (typeof (nameOrIndex) == 'string') {
+                for (var i = 0, n = this._templet.getAnimationCount(); i < n; i++) {
+                    var animation = this._templet.getAnimation(i);
+                    if (animation && nameOrIndex == animation.name) {
+                        index = i;
+                        break;
+                    }
+                }
+            }
+            else {
+                index = nameOrIndex;
+            }
+            if (index > -1 && index < this.getAnimNum()) {
+                this._aniClipIndex = index;
+                if (force || this._pause || this._currAniIndex != index) {
+                    this._currAniIndex = index;
+                    this._curOriginalData = new Float32Array(this._templet.getTotalkeyframesLength(index));
+                    this._drawOrder = null;
+                    this._eventIndex = 0;
+                    this._player.play(index, this._player.playbackRate, duration, start, end);
+                    if (freshSkin)
+                        this._templet.showSkinByIndex(this._boneSlotDic, this._skinIndex);
+                    if (this._pause) {
+                        this._pause = false;
+                        this._lastTime = Laya.ILaya.Browser.now();
+                        this.timer.frameLoop(1, this, this._update, null, true);
+                    }
+                    this._update();
+                }
+            }
+        }
+        stop() {
+            if (!this._pause) {
+                this._pause = true;
+                if (this._player) {
+                    this._player.stop(true);
+                }
+                if (this._soundChannelArr.length > 0) {
+                    this._onAniSoundStoped(true);
+                }
+                this.timer.clear(this, this._update);
+            }
+        }
+        playbackRate(value) {
+            if (this._player) {
+                this._player.playbackRate = value;
+            }
+        }
+        paused() {
+            if (!this._pause) {
+                this._pause = true;
+                if (this._player) {
+                    this._player.paused = true;
+                }
+                if (this._soundChannelArr.length > 0) {
+                    var _soundChannel;
+                    for (var len = this._soundChannelArr.length, i = 0; i < len; i++) {
+                        _soundChannel = this._soundChannelArr[i];
+                        if (!_soundChannel.isStopped) {
+                            _soundChannel.pause();
+                        }
+                    }
+                }
+                this.timer.clear(this, this._update);
+            }
+        }
+        resume() {
+            this._indexControl = false;
+            if (this._pause) {
+                this._pause = false;
+                if (this._player) {
+                    this._player.paused = false;
+                }
+                if (this._soundChannelArr.length > 0) {
+                    var _soundChannel;
+                    for (var len = this._soundChannelArr.length, i = 0; i < len; i++) {
+                        _soundChannel = this._soundChannelArr[i];
+                        if (_soundChannel.audioBuffer) {
+                            _soundChannel.resume();
+                        }
+                    }
+                }
+                this._lastTime = Laya.ILaya.Browser.now();
+                this.timer.frameLoop(1, this, this._update, null, true);
+            }
+        }
+        _getGrahicsDataWithCache(aniIndex, frameIndex) {
+            return this._graphicsCache[aniIndex][frameIndex];
+        }
+        _setGrahicsDataWithCache(aniIndex, frameIndex, graphics) {
+            this._graphicsCache[aniIndex][frameIndex] = graphics;
+        }
+        destroy(destroyChild = true) {
+            super.destroy(destroyChild);
+            this._templet._removeReference(1);
+            this._templet = null;
+            if (this._player)
+                this._player.offAll();
+            this._player = null;
+            this._curOriginalData = null;
+            this._boneMatrixArray.length = 0;
+            this._lastTime = 0;
+            this.timer.clear(this, this._update);
+            if (this._soundChannelArr.length > 0) {
+                this._onAniSoundStoped(true);
+            }
+        }
+        get index() {
+            return this._index;
+        }
+        set index(value) {
+            if (this.player) {
+                this._index = value;
+                this._player.currentTime = this._index * 1000 / this._player.cacheFrameRate;
+                this._indexControl = true;
+                this._update(false);
+            }
+        }
+        get total() {
+            if (this._templet && this._player) {
+                this._total = Math.floor(this._templet.getAniDuration(this._player.currentAnimationClipIndex) / 1000 * this._player.cacheFrameRate);
+            }
+            else {
+                this._total = -1;
+            }
+            return this._total;
+        }
+        get player() {
+            return this._player;
+        }
+        get templet() {
+            return this._templet;
+        }
+    }
+    Skeleton.useSimpleMeshInCanvas = false;
+    IAniLib.Skeleton = Skeleton;
+    Laya.ILaya.regClass(Skeleton);
+    Laya.ClassUtils.regClass("laya.ani.bone.Skeleton", Skeleton);
+    Laya.ClassUtils.regClass("Laya.Skeleton", Skeleton);
+
+    class SkinData {
+        constructor() {
+            this.slotArr = [];
+        }
+    }
+
+    class SkinSlotDisplayData {
+        createTexture(currTexture) {
+            if (this.texture)
+                return this.texture;
+            this.texture = new Laya.Texture(currTexture.bitmap, this.uvs);
+            if (this.uvs[0] > this.uvs[4]
+                && this.uvs[1] > this.uvs[5]) {
+                this.texture.width = currTexture.height;
+                this.texture.height = currTexture.width;
+                this.texture.offsetX = -currTexture.offsetX;
+                this.texture.offsetY = -currTexture.offsetY;
+                this.texture.sourceWidth = currTexture.sourceHeight;
+                this.texture.sourceHeight = currTexture.sourceWidth;
+            }
+            else {
+                this.texture.width = currTexture.width;
+                this.texture.height = currTexture.height;
+                this.texture.offsetX = -currTexture.offsetX;
+                this.texture.offsetY = -currTexture.offsetY;
+                this.texture.sourceWidth = currTexture.sourceWidth;
+                this.texture.sourceHeight = currTexture.sourceHeight;
+            }
+            return this.texture;
+        }
+        destory() {
+            if (this.texture)
+                this.texture.destroy();
+        }
+    }
+
+    class SlotData {
+        constructor() {
+            this.displayArr = [];
+        }
+        getDisplayByName(name) {
+            var tDisplay;
+            for (var i = 0, n = this.displayArr.length; i < n; i++) {
+                tDisplay = this.displayArr[i];
+                if (tDisplay.attachmentName == name) {
+                    return i;
+                }
+            }
+            return -1;
+        }
+    }
+
+    class TfConstraintData {
+        constructor() {
+            this.boneIndexs = [];
+        }
+    }
+
+    class Templet extends AnimationTemplet {
+        constructor() {
+            super(...arguments);
+            this._graphicsCache = [];
+            this.srcBoneMatrixArr = [];
+            this.ikArr = [];
+            this.tfArr = [];
+            this.pathArr = [];
+            this.boneSlotDic = {};
+            this.bindBoneBoneSlotDic = {};
+            this.boneSlotArray = [];
+            this.skinDataArray = [];
+            this.skinDic = {};
+            this.subTextureDic = {};
+            this.isParseFail = false;
+            this.drawOrderAniArr = [];
+            this.eventAniArr = [];
+            this.attachmentNames = null;
+            this.deformAniArr = [];
+            this.skinSlotDisplayDataArr = [];
+            this._isParseAudio = false;
+            this._isDestroyed = false;
+            this._rate = 30;
+            this.isParserComplete = false;
+            this.aniSectionDic = {};
+            this._textureDic = {};
+            this.mBoneArr = [];
+        }
+        loadAni(url) {
+            this._skBufferUrl = url;
+            Laya.ILaya.loader.load(url, Laya.Handler.create(this, this.onComplete), null, Laya.ILaya.Loader.BUFFER);
+        }
+        onComplete(content = null) {
+            if (this._isDestroyed) {
+                this.destroy();
+                return;
+            }
+            var tSkBuffer = Laya.ILaya.Loader.getRes(this._skBufferUrl);
+            if (!tSkBuffer) {
+                this.event(Laya.Event.ERROR, "load failed:" + this._skBufferUrl);
+                return;
+            }
+            this._path = this._skBufferUrl.slice(0, this._skBufferUrl.lastIndexOf("/")) + "/";
+            this.parseData(null, tSkBuffer);
+        }
+        parseData(texture, skeletonData, playbackRate = 30) {
+            if (!this._path) {
+                var s1 = (this._relativeUrl || this.url);
+                if (s1) {
+                    var p1 = s1.lastIndexOf('/');
+                    if (p1 > 0) {
+                        this._path = s1.slice(0, p1) + "/";
+                    }
+                    else {
+                        this._path = '';
+                    }
+                }
+            }
+            this._mainTexture = texture;
+            this._rate = playbackRate;
+            this.parse(skeletonData);
+        }
+        buildArmature(aniMode = 0) {
+            return new Skeleton(this, aniMode);
+        }
+        parse(data) {
+            super.parse(data);
+            this.event(Laya.Event.LOADED, this);
+            if (this._aniVersion === Templet.LAYA_ANIMATION_VISION) {
+                this._isParseAudio = true;
+            }
+            else if (this._aniVersion != Templet.LAYA_ANIMATION_160_VISION) {
+                console.log("[Error] 版本不一致,请使用IDE版本配套的重新导出" + this._aniVersion + "->" + Templet.LAYA_ANIMATION_VISION);
+            }
+            if (this._mainTexture) {
+                this._parsePublicExtData();
+            }
+            else {
+                this._parseTexturePath();
+            }
+        }
+        _parseTexturePath() {
+            if (this._isDestroyed) {
+                this.destroy();
+                return;
+            }
+            var i = 0;
+            this._loadList = [];
+            var tByte = new Laya.Byte(this.getPublicExtData());
+            var tX = 0, tY = 0, tWidth = 0, tHeight = 0;
+            var tTempleData = 0;
+            var tTextureLen = tByte.getInt32();
+            var tTextureName = tByte.readUTFString();
+            var tTextureNameArr = tTextureName.split("\n");
+            var tSrcTexturePath;
+            for (i = 0; i < tTextureLen; i++) {
+                tSrcTexturePath = this._path + tTextureNameArr[i * 2];
+                tTextureName = tTextureNameArr[i * 2 + 1];
+                tX = tByte.getFloat32();
+                tY = tByte.getFloat32();
+                tWidth = tByte.getFloat32();
+                tHeight = tByte.getFloat32();
+                tTempleData = tByte.getFloat32();
+                tTempleData = tByte.getFloat32();
+                tTempleData = tByte.getFloat32();
+                tTempleData = tByte.getFloat32();
+                if (this._loadList.indexOf(tSrcTexturePath) == -1) {
+                    this._loadList.push(tSrcTexturePath);
+                }
+            }
+            Laya.ILaya.loader.load(this._loadList, Laya.Handler.create(this, this._textureComplete));
+        }
+        _textureComplete() {
+            var tTexture;
+            var tTextureName;
+            for (var i = 0, n = this._loadList.length; i < n; i++) {
+                tTextureName = this._loadList[i];
+                tTexture = this._textureDic[tTextureName] = Laya.ILaya.Loader.getRes(tTextureName);
+            }
+            this._parsePublicExtData();
+        }
+        _parsePublicExtData() {
+            var i = 0, j = 0, k = 0, l = 0, n = 0;
+            for (i = 0, n = this.getAnimationCount(); i < n; i++) {
+                this._graphicsCache.push([]);
+            }
+            var isSpine;
+            isSpine = this._aniClassName != "Dragon";
+            var tByte = new Laya.Byte(this.getPublicExtData());
+            var tX = 0, tY = 0, tWidth = 0, tHeight = 0;
+            var tFrameX = 0, tFrameY = 0, tFrameWidth = 0, tFrameHeight = 0;
+            var tTempleData = 0;
+            var tTextureLen = tByte.getInt32();
+            var tTextureName = tByte.readUTFString();
+            var tTextureNameArr = tTextureName.split("\n");
+            var tTexture;
+            var tSrcTexturePath;
+            for (i = 0; i < tTextureLen; i++) {
+                tTexture = this._mainTexture;
+                tSrcTexturePath = this._path + tTextureNameArr[i * 2];
+                tTextureName = tTextureNameArr[i * 2 + 1];
+                if (this._mainTexture == null) {
+                    tTexture = this._textureDic[tSrcTexturePath];
+                }
+                if (!tTexture) {
+                    this.event(Laya.Event.ERROR, this);
+                    this.isParseFail = true;
+                    return;
+                }
+                tX = tByte.getFloat32();
+                tY = tByte.getFloat32();
+                tWidth = tByte.getFloat32();
+                tHeight = tByte.getFloat32();
+                tTempleData = tByte.getFloat32();
+                tFrameX = isNaN(tTempleData) ? 0 : tTempleData;
+                tTempleData = tByte.getFloat32();
+                tFrameY = isNaN(tTempleData) ? 0 : tTempleData;
+                tTempleData = tByte.getFloat32();
+                tFrameWidth = isNaN(tTempleData) ? tWidth : tTempleData;
+                tTempleData = tByte.getFloat32();
+                tFrameHeight = isNaN(tTempleData) ? tHeight : tTempleData;
+                this.subTextureDic[tTextureName] = Laya.Texture.create(tTexture, tX, tY, tWidth, tHeight, -tFrameX, -tFrameY, tFrameWidth, tFrameHeight);
+            }
+            this._mainTexture = tTexture;
+            var tAniCount = tByte.getUint16();
+            var tSectionArr;
+            for (i = 0; i < tAniCount; i++) {
+                tSectionArr = [];
+                tSectionArr.push(tByte.getUint16());
+                tSectionArr.push(tByte.getUint16());
+                tSectionArr.push(tByte.getUint16());
+                tSectionArr.push(tByte.getUint16());
+                this.aniSectionDic[i] = tSectionArr;
+            }
+            var tBone;
+            var tParentBone;
+            var tName;
+            var tParentName;
+            var tBoneLen = tByte.getInt16();
+            var tBoneDic = {};
+            var tRootBone;
+            for (i = 0; i < tBoneLen; i++) {
+                tBone = new Bone();
+                if (i == 0) {
+                    tRootBone = tBone;
+                }
+                else {
+                    tBone.root = tRootBone;
+                }
+                tBone.d = isSpine ? -1 : 1;
+                tName = tByte.readUTFString();
+                tParentName = tByte.readUTFString();
+                tBone.length = tByte.getFloat32();
+                if (tByte.getByte() == 1) {
+                    tBone.inheritRotation = false;
+                }
+                if (tByte.getByte() == 1) {
+                    tBone.inheritScale = false;
+                }
+                tBone.name = tName;
+                if (tParentName) {
+                    tParentBone = tBoneDic[tParentName];
+                    if (tParentBone) {
+                        tParentBone.addChild(tBone);
+                    }
+                    else {
+                        this.mRootBone = tBone;
+                    }
+                }
+                tBoneDic[tName] = tBone;
+                this.mBoneArr.push(tBone);
+            }
+            this.tMatrixDataLen = tByte.getUint16();
+            var tLen = tByte.getUint16();
+            var boneLength = Math.floor(tLen / this.tMatrixDataLen);
+            var tResultTransform;
+            var tMatrixArray = this.srcBoneMatrixArr;
+            for (i = 0; i < boneLength; i++) {
+                tResultTransform = new Transform();
+                tResultTransform.scX = tByte.getFloat32();
+                tResultTransform.skX = tByte.getFloat32();
+                tResultTransform.skY = tByte.getFloat32();
+                tResultTransform.scY = tByte.getFloat32();
+                tResultTransform.x = tByte.getFloat32();
+                tResultTransform.y = tByte.getFloat32();
+                if (this.tMatrixDataLen === 8) {
+                    tResultTransform.skewX = tByte.getFloat32();
+                    tResultTransform.skewY = tByte.getFloat32();
+                }
+                tMatrixArray.push(tResultTransform);
+                tBone = this.mBoneArr[i];
+                tBone.transform = tResultTransform;
+            }
+            var tIkConstraintData;
+            var tIkLen = tByte.getUint16();
+            var tIkBoneLen;
+            for (i = 0; i < tIkLen; i++) {
+                tIkConstraintData = new IkConstraintData();
+                tIkBoneLen = tByte.getUint16();
+                for (j = 0; j < tIkBoneLen; j++) {
+                    tIkConstraintData.boneNames.push(tByte.readUTFString());
+                    tIkConstraintData.boneIndexs.push(tByte.getInt16());
+                }
+                tIkConstraintData.name = tByte.readUTFString();
+                tIkConstraintData.targetBoneName = tByte.readUTFString();
+                tIkConstraintData.targetBoneIndex = tByte.getInt16();
+                tIkConstraintData.bendDirection = tByte.getFloat32();
+                tIkConstraintData.mix = tByte.getFloat32();
+                tIkConstraintData.isSpine = isSpine;
+                this.ikArr.push(tIkConstraintData);
+            }
+            var tTfConstraintData;
+            var tTfLen = tByte.getUint16();
+            var tTfBoneLen;
+            for (i = 0; i < tTfLen; i++) {
+                tTfConstraintData = new TfConstraintData();
+                tTfBoneLen = tByte.getUint16();
+                for (j = 0; j < tTfBoneLen; j++) {
+                    tTfConstraintData.boneIndexs.push(tByte.getInt16());
+                }
+                tTfConstraintData.name = tByte.getUTFString();
+                tTfConstraintData.targetIndex = tByte.getInt16();
+                tTfConstraintData.rotateMix = tByte.getFloat32();
+                tTfConstraintData.translateMix = tByte.getFloat32();
+                tTfConstraintData.scaleMix = tByte.getFloat32();
+                tTfConstraintData.shearMix = tByte.getFloat32();
+                tTfConstraintData.offsetRotation = tByte.getFloat32();
+                tTfConstraintData.offsetX = tByte.getFloat32();
+                tTfConstraintData.offsetY = tByte.getFloat32();
+                tTfConstraintData.offsetScaleX = tByte.getFloat32();
+                tTfConstraintData.offsetScaleY = tByte.getFloat32();
+                tTfConstraintData.offsetShearY = tByte.getFloat32();
+                this.tfArr.push(tTfConstraintData);
+            }
+            var tPathConstraintData;
+            var tPathLen = tByte.getUint16();
+            var tPathBoneLen;
+            for (i = 0; i < tPathLen; i++) {
+                tPathConstraintData = new PathConstraintData();
+                tPathConstraintData.name = tByte.readUTFString();
+                tPathBoneLen = tByte.getUint16();
+                for (j = 0; j < tPathBoneLen; j++) {
+                    tPathConstraintData.bones.push(tByte.getInt16());
+                }
+                tPathConstraintData.target = tByte.readUTFString();
+                tPathConstraintData.positionMode = tByte.readUTFString();
+                tPathConstraintData.spacingMode = tByte.readUTFString();
+                tPathConstraintData.rotateMode = tByte.readUTFString();
+                tPathConstraintData.offsetRotation = tByte.getFloat32();
+                tPathConstraintData.position = tByte.getFloat32();
+                tPathConstraintData.spacing = tByte.getFloat32();
+                tPathConstraintData.rotateMix = tByte.getFloat32();
+                tPathConstraintData.translateMix = tByte.getFloat32();
+                this.pathArr.push(tPathConstraintData);
+            }
+            var tDeformSlotLen;
+            var tDeformSlotDisplayLen;
+            var tDSlotIndex;
+            var tDAttachment;
+            var tDeformTimeLen;
+            var tDTime;
+            var tDeformVecticesLen;
+            var tDeformAniData;
+            var tDeformSlotData;
+            var tDeformSlotDisplayData;
+            var tDeformVectices;
+            var tDeformAniLen = tByte.getInt16();
+            for (i = 0; i < tDeformAniLen; i++) {
+                var tDeformSkinLen = tByte.getUint8();
+                var tSkinDic = {};
+                this.deformAniArr.push(tSkinDic);
+                for (var f = 0; f < tDeformSkinLen; f++) {
+                    tDeformAniData = new DeformAniData();
+                    tDeformAniData.skinName = tByte.getUTFString();
+                    tSkinDic[tDeformAniData.skinName] = tDeformAniData;
+                    tDeformSlotLen = tByte.getInt16();
+                    for (j = 0; j < tDeformSlotLen; j++) {
+                        tDeformSlotData = new DeformSlotData();
+                        tDeformAniData.deformSlotDataList.push(tDeformSlotData);
+                        tDeformSlotDisplayLen = tByte.getInt16();
+                        for (k = 0; k < tDeformSlotDisplayLen; k++) {
+                            tDeformSlotDisplayData = new DeformSlotDisplayData();
+                            tDeformSlotData.deformSlotDisplayList.push(tDeformSlotDisplayData);
+                            tDeformSlotDisplayData.slotIndex = tDSlotIndex = tByte.getInt16();
+                            tDeformSlotDisplayData.attachment = tDAttachment = tByte.getUTFString();
+                            tDeformTimeLen = tByte.getInt16();
+                            for (l = 0; l < tDeformTimeLen; l++) {
+                                if (tByte.getByte() == 1) {
+                                    tDeformSlotDisplayData.tweenKeyList.push(true);
+                                }
+                                else {
+                                    tDeformSlotDisplayData.tweenKeyList.push(false);
+                                }
+                                tDTime = tByte.getFloat32();
+                                tDeformSlotDisplayData.timeList.push(tDTime);
+                                tDeformVectices = [];
+                                tDeformSlotDisplayData.vectices.push(tDeformVectices);
+                                tDeformVecticesLen = tByte.getInt16();
+                                for (n = 0; n < tDeformVecticesLen; n++) {
+                                    tDeformVectices.push(tByte.getFloat32());
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            var tDrawOrderArr;
+            var tDrawOrderAniLen = tByte.getInt16();
+            var tDrawOrderLen;
+            var tDrawOrderData;
+            var tDoLen;
+            for (i = 0; i < tDrawOrderAniLen; i++) {
+                tDrawOrderLen = tByte.getInt16();
+                tDrawOrderArr = [];
+                for (j = 0; j < tDrawOrderLen; j++) {
+                    tDrawOrderData = new DrawOrderData();
+                    tDrawOrderData.time = tByte.getFloat32();
+                    tDoLen = tByte.getInt16();
+                    for (k = 0; k < tDoLen; k++) {
+                        tDrawOrderData.drawOrder.push(tByte.getInt16());
+                    }
+                    tDrawOrderArr.push(tDrawOrderData);
+                }
+                this.drawOrderAniArr.push(tDrawOrderArr);
+            }
+            var tEventArr;
+            var tEventAniLen = tByte.getInt16();
+            var tEventLen;
+            var tEventData;
+            for (i = 0; i < tEventAniLen; i++) {
+                tEventLen = tByte.getInt16();
+                tEventArr = [];
+                for (j = 0; j < tEventLen; j++) {
+                    tEventData = new EventData();
+                    tEventData.name = tByte.getUTFString();
+                    if (this._isParseAudio)
+                        tEventData.audioValue = tByte.getUTFString();
+                    tEventData.intValue = tByte.getInt32();
+                    tEventData.floatValue = tByte.getFloat32();
+                    tEventData.stringValue = tByte.getUTFString();
+                    tEventData.time = tByte.getFloat32();
+                    tEventArr.push(tEventData);
+                }
+                this.eventAniArr.push(tEventArr);
+            }
+            var tAttachmentLen = tByte.getInt16();
+            if (tAttachmentLen > 0) {
+                this.attachmentNames = [];
+                for (i = 0; i < tAttachmentLen; i++) {
+                    this.attachmentNames.push(tByte.getUTFString());
+                }
+            }
+            var tBoneSlotLen = tByte.getInt16();
+            var tDBBoneSlot;
+            var tDBBoneSlotArr;
+            for (i = 0; i < tBoneSlotLen; i++) {
+                tDBBoneSlot = new BoneSlot();
+                tDBBoneSlot.name = tByte.readUTFString();
+                tDBBoneSlot.parent = tByte.readUTFString();
+                tDBBoneSlot.attachmentName = tByte.readUTFString();
+                tDBBoneSlot.srcDisplayIndex = tDBBoneSlot.displayIndex = tByte.getInt16();
+                tDBBoneSlot.templet = this;
+                this.boneSlotDic[tDBBoneSlot.name] = tDBBoneSlot;
+                tDBBoneSlotArr = this.bindBoneBoneSlotDic[tDBBoneSlot.parent];
+                if (tDBBoneSlotArr == null) {
+                    this.bindBoneBoneSlotDic[tDBBoneSlot.parent] = tDBBoneSlotArr = [];
+                }
+                tDBBoneSlotArr.push(tDBBoneSlot);
+                this.boneSlotArray.push(tDBBoneSlot);
+            }
+            var tNameString = tByte.readUTFString();
+            var tNameArray = tNameString.split("\n");
+            var tNameStartIndex = 0;
+            var tSkinDataLen = tByte.getUint8();
+            var tSkinData, tSlotData, tDisplayData;
+            var tSlotDataLen, tDisplayDataLen;
+            var tUvLen, tWeightLen, tTriangleLen, tVerticeLen, tLengthLen;
+            for (i = 0; i < tSkinDataLen; i++) {
+                tSkinData = new SkinData();
+                tSkinData.name = tNameArray[tNameStartIndex++];
+                tSlotDataLen = tByte.getUint8();
+                for (j = 0; j < tSlotDataLen; j++) {
+                    tSlotData = new SlotData();
+                    tSlotData.name = tNameArray[tNameStartIndex++];
+                    tDBBoneSlot = this.boneSlotDic[tSlotData.name];
+                    tDisplayDataLen = tByte.getUint8();
+                    for (k = 0; k < tDisplayDataLen; k++) {
+                        tDisplayData = new SkinSlotDisplayData();
+                        this.skinSlotDisplayDataArr.push(tDisplayData);
+                        tDisplayData.name = tNameArray[tNameStartIndex++];
+                        tDisplayData.attachmentName = tNameArray[tNameStartIndex++];
+                        tDisplayData.transform = new Transform();
+                        tDisplayData.transform.scX = tByte.getFloat32();
+                        tDisplayData.transform.skX = tByte.getFloat32();
+                        tDisplayData.transform.skY = tByte.getFloat32();
+                        tDisplayData.transform.scY = tByte.getFloat32();
+                        tDisplayData.transform.x = tByte.getFloat32();
+                        tDisplayData.transform.y = tByte.getFloat32();
+                        tSlotData.displayArr.push(tDisplayData);
+                        tDisplayData.width = tByte.getFloat32();
+                        tDisplayData.height = tByte.getFloat32();
+                        tDisplayData.type = tByte.getUint8();
+                        tDisplayData.verLen = tByte.getUint16();
+                        tBoneLen = tByte.getUint16();
+                        if (tBoneLen > 0) {
+                            tDisplayData.bones = [];
+                            for (l = 0; l < tBoneLen; l++) {
+                                var tBoneId = tByte.getUint16();
+                                tDisplayData.bones.push(tBoneId);
+                            }
+                        }
+                        tUvLen = tByte.getUint16();
+                        if (tUvLen > 0) {
+                            tDisplayData.uvs = [];
+                            for (l = 0; l < tUvLen; l++) {
+                                tDisplayData.uvs.push(tByte.getFloat32());
+                            }
+                        }
+                        tWeightLen = tByte.getUint16();
+                        if (tWeightLen > 0) {
+                            tDisplayData.weights = [];
+                            for (l = 0; l < tWeightLen; l++) {
+                                tDisplayData.weights.push(tByte.getFloat32());
+                            }
+                        }
+                        tTriangleLen = tByte.getUint16();
+                        if (tTriangleLen > 0) {
+                            tDisplayData.triangles = [];
+                            for (l = 0; l < tTriangleLen; l++) {
+                                tDisplayData.triangles.push(tByte.getUint16());
+                            }
+                        }
+                        tVerticeLen = tByte.getUint16();
+                        if (tVerticeLen > 0) {
+                            tDisplayData.vertices = [];
+                            for (l = 0; l < tVerticeLen; l++) {
+                                tDisplayData.vertices.push(tByte.getFloat32());
+                            }
+                        }
+                        tLengthLen = tByte.getUint16();
+                        if (tLengthLen > 0) {
+                            tDisplayData.lengths = [];
+                            for (l = 0; l < tLengthLen; l++) {
+                                tDisplayData.lengths.push(tByte.getFloat32());
+                            }
+                        }
+                    }
+                    tSkinData.slotArr.push(tSlotData);
+                }
+                this.skinDic[tSkinData.name] = tSkinData;
+                this.skinDataArray.push(tSkinData);
+            }
+            var tReverse = tByte.getUint8();
+            if (tReverse == 1) {
+                this.yReverseMatrix = new Laya.Matrix(1, 0, 0, -1, 0, 0);
+                if (tRootBone) {
+                    tRootBone.setTempMatrix(this.yReverseMatrix);
+                }
+            }
+            else {
+                if (tRootBone) {
+                    tRootBone.setTempMatrix(new Laya.Matrix());
+                }
+            }
+            this.showSkinByIndex(this.boneSlotDic, 0);
+            this.isParserComplete = true;
+            this.event(Laya.Event.COMPLETE, this);
+        }
+        getTexture(name) {
+            var tTexture = this.subTextureDic[name];
+            if (!tTexture) {
+                tTexture = this.subTextureDic[name.substr(0, name.length - 1)];
+            }
+            if (tTexture == null) {
+                return this._mainTexture;
+            }
+            return tTexture;
+        }
+        showSkinByIndex(boneSlotDic, skinIndex, freshDisplayIndex = true) {
+            if (skinIndex < 0 && skinIndex >= this.skinDataArray.length)
+                return false;
+            var i, n;
+            var tBoneSlot;
+            var tSlotData;
+            var tSkinData = this.skinDataArray[skinIndex];
+            if (tSkinData) {
+                for (i = 0, n = tSkinData.slotArr.length; i < n; i++) {
+                    tSlotData = tSkinData.slotArr[i];
+                    if (tSlotData) {
+                        tBoneSlot = boneSlotDic[tSlotData.name];
+                        if (tBoneSlot) {
+                            tBoneSlot.showSlotData(tSlotData, freshDisplayIndex);
+                            if (freshDisplayIndex && tBoneSlot.attachmentName != "undefined" && tBoneSlot.attachmentName != "null") {
+                                tBoneSlot.showDisplayByName(tBoneSlot.attachmentName);
+                            }
+                            else {
+                                tBoneSlot.showDisplayByIndex(tBoneSlot.displayIndex);
+                            }
+                        }
+                    }
+                }
+                return true;
+            }
+            return false;
+        }
+        getSkinIndexByName(skinName) {
+            var tSkinData;
+            for (var i = 0, n = this.skinDataArray.length; i < n; i++) {
+                tSkinData = this.skinDataArray[i];
+                if (tSkinData.name == skinName) {
+                    return i;
+                }
+            }
+            return -1;
+        }
+        getGrahicsDataWithCache(aniIndex, frameIndex) {
+            if (this._graphicsCache[aniIndex] && this._graphicsCache[aniIndex][frameIndex]) {
+                return this._graphicsCache[aniIndex][frameIndex];
+            }
+            return null;
+        }
+        _setCreateURL(url) {
+            this._skBufferUrl = this._relativeUrl = url;
+            super._setCreateURL(url);
+        }
+        setGrahicsDataWithCache(aniIndex, frameIndex, graphics) {
+            this._graphicsCache[aniIndex][frameIndex] = graphics;
+        }
+        deleteAniData(aniIndex) {
+            if (this._anis[aniIndex]) {
+                var tAniDataO = this._anis[aniIndex];
+                tAniDataO.bone3DMap = null;
+                tAniDataO.nodes = null;
+            }
+        }
+        destroy() {
+            this._isDestroyed = true;
+            var tTexture;
+            for (tTexture in this.subTextureDic) {
+                if (tTexture) {
+                    this.subTextureDic[tTexture].destroy();
+                }
+            }
+            for (tTexture in this._textureDic) {
+                if (tTexture) {
+                    this._textureDic[tTexture].destroy();
+                }
+            }
+            var tSkinSlotDisplayData;
+            for (var i = 0, n = this.skinSlotDisplayDataArr.length; i < n; i++) {
+                tSkinSlotDisplayData = this.skinSlotDisplayDataArr[i];
+                tSkinSlotDisplayData.destory();
+            }
+            this.skinSlotDisplayDataArr.length = 0;
+            if (this._relativeUrl) {
+                delete Templet.TEMPLET_DICTIONARY[this._relativeUrl];
+            }
+            super.destroy();
+            Laya.ILaya.loader.clearRes(this._skBufferUrl);
+        }
+        getAniNameByIndex(index) {
+            var tAni = this.getAnimation(index);
+            if (tAni)
+                return tAni.name;
+            return null;
+        }
+        get rate() {
+            return this._rate;
+        }
+        set rate(v) {
+            this._rate = v;
+        }
+    }
+    Templet.LAYA_ANIMATION_160_VISION = "LAYAANIMATION:1.6.0";
+    Templet.LAYA_ANIMATION_VISION = "LAYAANIMATION:1.7.0";
+    IAniLib.Templet = Templet;
+
+    class MovieClip extends Laya.Sprite {
+        constructor(parentMovieClip = null) {
+            super();
+            this._start = 0;
+            this._Pos = 0;
+            this._ended = true;
+            this._loadedImage = {};
+            this._endFrame = -1;
+            this.interval = 30;
+            this._ids = {};
+            this._idOfSprite = [];
+            this._reset();
+            this._playing = false;
+            this._parentMovieClip = parentMovieClip;
+            if (!parentMovieClip) {
+                this._movieClipList = [this];
+                this._isRoot = true;
+                this._setBitUp(Laya.Const.DISPLAY);
+            }
+            else {
+                this._isRoot = false;
+                this._movieClipList = parentMovieClip._movieClipList;
+                this._movieClipList.push(this);
+            }
+        }
+        destroy(destroyChild = true) {
+            this._clear();
+            super.destroy(destroyChild);
+        }
+        _setDisplay(value) {
+            super._setDisplay(value);
+            if (this._isRoot) {
+                this._onDisplay(value);
+            }
+        }
+        _onDisplay(value) {
+            if (value)
+                this.timer.loop(this.interval, this, this.updates, null, true);
+            else
+                this.timer.clear(this, this.updates);
+        }
+        updates() {
+            if (this._parentMovieClip)
+                return;
+            var i, len;
+            len = this._movieClipList.length;
+            for (i = 0; i < len; i++) {
+                this._movieClipList[i] && this._movieClipList[i]._update();
+            }
+        }
+        get index() {
+            return this._playIndex;
+        }
+        set index(value) {
+            this._playIndex = value;
+            if (this._data)
+                this._displayFrame(this._playIndex);
+            if (this._labels && this._labels[value])
+                this.event(Laya.Event.LABEL, this._labels[value]);
+        }
+        addLabel(label, index) {
+            if (!this._labels)
+                this._labels = {};
+            this._labels[index] = label;
+        }
+        removeLabel(label) {
+            if (!label)
+                this._labels = null;
+            else if (!this._labels) {
+                for (var name in this._labels) {
+                    if (this._labels[name] === label) {
+                        delete this._labels[name];
+                        break;
+                    }
+                }
+            }
+        }
+        get count() {
+            return this._count;
+        }
+        get playing() {
+            return this._playing;
+        }
+        _update() {
+            if (!this._data)
+                return;
+            if (!this._playing)
+                return;
+            this._playIndex++;
+            if (this._playIndex >= this._count) {
+                if (!this.loop) {
+                    this._playIndex--;
+                    this.stop();
+                    return;
+                }
+                this._playIndex = 0;
+            }
+            this._parseFrame(this._playIndex);
+            if (this._labels && this._labels[this._playIndex])
+                this.event(Laya.Event.LABEL, this._labels[this._playIndex]);
+            if (this._endFrame != -1 && this._endFrame == this._playIndex) {
+                this._endFrame = -1;
+                if (this._completeHandler != null) {
+                    var handler = this._completeHandler;
+                    this._completeHandler = null;
+                    handler.run();
+                }
+                this.stop();
+            }
+        }
+        stop() {
+            this._playing = false;
+        }
+        gotoAndStop(index) {
+            this.index = index;
+            this.stop();
+        }
+        _clear() {
+            this.stop();
+            this._idOfSprite.length = 0;
+            if (!this._parentMovieClip) {
+                this.timer.clear(this, this.updates);
+                var i, len;
+                len = this._movieClipList.length;
+                for (i = 0; i < len; i++) {
+                    if (this._movieClipList[i] != this)
+                        this._movieClipList[i]._clear();
+                }
+                this._movieClipList.length = 0;
+            }
+            if (this._atlasPath) {
+                Laya.ILaya.Loader.clearRes(this._atlasPath);
+            }
+            var key;
+            for (key in this._loadedImage) {
+                if (this._loadedImage[key]) {
+                    Laya.ILaya.Loader.clearRes(key);
+                    this._loadedImage[key] = false;
+                }
+            }
+            this.removeChildren();
+            this.graphics = null;
+            this._parentMovieClip = null;
+        }
+        play(index = 0, loop = true) {
+            this.loop = loop;
+            this._playing = true;
+            if (this._data)
+                this._displayFrame(index);
+        }
+        _displayFrame(frameIndex = -1) {
+            if (frameIndex != -1) {
+                if (this._curIndex > frameIndex)
+                    this._reset();
+                this._parseFrame(frameIndex);
+            }
+        }
+        _reset(rm = true) {
+            if (rm && this._curIndex != 1)
+                this.removeChildren();
+            this._preIndex = this._curIndex = -1;
+            this._Pos = this._start;
+        }
+        _parseFrame(frameIndex) {
+            var mc, sp, key, type, tPos, ttype, ifAdd = false;
+            var _idOfSprite = this._idOfSprite, _data = this._data, eStr;
+            if (this._ended)
+                this._reset();
+            _data.pos = this._Pos;
+            this._ended = false;
+            this._playIndex = frameIndex;
+            if (this._curIndex > frameIndex && frameIndex < this._preIndex) {
+                this._reset(true);
+                _data.pos = this._Pos;
+            }
+            while ((this._curIndex <= frameIndex) && (!this._ended)) {
+                type = _data.getUint16();
+                switch (type) {
+                    case 12:
+                        key = _data.getUint16();
+                        tPos = this._ids[_data.getUint16()];
+                        this._Pos = _data.pos;
+                        _data.pos = tPos;
+                        if ((ttype = _data.getUint8()) == 0) {
+                            var pid = _data.getUint16();
+                            sp = _idOfSprite[key];
+                            if (!sp) {
+                                sp = _idOfSprite[key] = new Laya.Sprite();
+                                var spp = new Laya.Sprite();
+                                spp.loadImage(this.basePath + pid + ".png");
+                                this._loadedImage[this.basePath + pid + ".png"] = true;
+                                sp.addChild(spp);
+                                spp.size(_data.getFloat32(), _data.getFloat32());
+                                var mat = _data._getMatrix();
+                                spp.transform = mat;
+                            }
+                            sp.alpha = 1;
+                        }
+                        else if (ttype == 1) {
+                            mc = _idOfSprite[key];
+                            if (!mc) {
+                                _idOfSprite[key] = mc = new MovieClip(this);
+                                mc.interval = this.interval;
+                                mc._ids = this._ids;
+                                mc.basePath = this.basePath;
+                                mc._setData(_data, tPos);
+                                mc._initState();
+                                mc.play(0);
+                            }
+                            mc.alpha = 1;
+                        }
+                        _data.pos = this._Pos;
+                        break;
+                    case 3:
+                        var node = _idOfSprite[_data.getUint16()];
+                        if (node) {
+                            this.addChild(node);
+                            node.zOrder = _data.getUint16();
+                            ifAdd = true;
+                        }
+                        break;
+                    case 4:
+                        node = _idOfSprite[_data.getUint16()];
+                        node && node.removeSelf();
+                        break;
+                    case 5:
+                        _idOfSprite[_data.getUint16()][MovieClip._ValueList[_data.getUint16()]] = (_data.getFloat32());
+                        break;
+                    case 6:
+                        _idOfSprite[_data.getUint16()].visible = (_data.getUint8() > 0);
+                        break;
+                    case 7:
+                        sp = _idOfSprite[_data.getUint16()];
+                        var mt = sp.transform || Laya.Matrix.create();
+                        mt.setTo(_data.getFloat32(), _data.getFloat32(), _data.getFloat32(), _data.getFloat32(), _data.getFloat32(), _data.getFloat32());
+                        sp.transform = mt;
+                        break;
+                    case 8:
+                        _idOfSprite[_data.getUint16()].setPos(_data.getFloat32(), _data.getFloat32());
+                        break;
+                    case 9:
+                        _idOfSprite[_data.getUint16()].setSize(_data.getFloat32(), _data.getFloat32());
+                        break;
+                    case 10:
+                        _idOfSprite[_data.getUint16()].alpha = _data.getFloat32();
+                        break;
+                    case 11:
+                        _idOfSprite[_data.getUint16()].setScale(_data.getFloat32(), _data.getFloat32());
+                        break;
+                    case 98:
+                        eStr = _data.getString();
+                        this.event(eStr);
+                        if (eStr == "stop")
+                            this.stop();
+                        break;
+                    case 99:
+                        this._curIndex = _data.getUint16();
+                        ifAdd && this.updateZOrder();
+                        break;
+                    case 100:
+                        this._count = this._curIndex + 1;
+                        this._ended = true;
+                        if (this._playing) {
+                            this.event(Laya.Event.FRAME);
+                            this.event(Laya.Event.END);
+                            this.event(Laya.Event.COMPLETE);
+                        }
+                        this._reset(false);
+                        break;
+                }
+            }
+            if (this._playing && !this._ended)
+                this.event(Laya.Event.FRAME);
+            this._Pos = _data.pos;
+        }
+        _setData(data, start) {
+            this._data = data;
+            this._start = start + 3;
+        }
+        set url(path) {
+            this.load(path);
+        }
+        load(url, atlas = false, atlasPath = null) {
+            this._url = url;
+            if (atlas)
+                this._atlasPath = atlasPath ? atlasPath : url.split(".swf")[0] + ".json";
+            this.stop();
+            this._clear();
+            this._movieClipList = [this];
+            var urls;
+            urls = [{ url: url, type: Laya.ILaya.Loader.BUFFER }];
+            if (this._atlasPath) {
+                urls.push({ url: this._atlasPath, type: Laya.ILaya.Loader.ATLAS });
+            }
+            Laya.ILaya.loader.load(urls, Laya.Handler.create(this, this._onLoaded));
+        }
+        _onLoaded() {
+            var data;
+            data = Laya.ILaya.Loader.getRes(this._url);
+            if (!data) {
+                this.event(Laya.Event.ERROR, "file not find");
+                return;
+            }
+            if (this._atlasPath && !Laya.ILaya.Loader.getAtlas(this._atlasPath)) {
+                this.event(Laya.Event.ERROR, "Atlas not find");
+                return;
+            }
+            this.basePath = this._atlasPath ? Laya.ILaya.Loader.getAtlas(this._atlasPath).dir : this._url.split(".swf")[0] + "/image/";
+            this._initData(data);
+        }
+        _initState() {
+            this._reset();
+            this._ended = false;
+            var preState = this._playing;
+            this._playing = false;
+            this._curIndex = 0;
+            while (!this._ended)
+                this._parseFrame(++this._curIndex);
+            this._playing = preState;
+        }
+        _initData(data) {
+            this._data = new Laya.Byte(data);
+            var i, len = this._data.getUint16();
+            for (i = 0; i < len; i++)
+                this._ids[this._data.getInt16()] = this._data.getInt32();
+            this.interval = 1000 / this._data.getUint16();
+            this._setData(this._data, this._ids[32767]);
+            this._initState();
+            this.play(0);
+            this.event(Laya.Event.LOADED);
+            if (!this._parentMovieClip)
+                this.timer.loop(this.interval, this, this.updates, null, true);
+        }
+        playTo(start, end, complete = null) {
+            this._completeHandler = complete;
+            this._endFrame = end;
+            this.play(start, false);
+        }
+    }
+    MovieClip._ValueList = ["x", "y", "width", "height", "scaleX", "scaleY", "rotation", "alpha"];
+
+    exports.AnimationContent = AnimationContent;
+    exports.AnimationNodeContent = AnimationNodeContent;
+    exports.AnimationParser01 = AnimationParser01;
+    exports.AnimationParser02 = AnimationParser02;
+    exports.AnimationPlayer = AnimationPlayer;
+    exports.AnimationState = AnimationState;
+    exports.AnimationTemplet = AnimationTemplet;
+    exports.BezierLerp = BezierLerp;
+    exports.Bone = Bone;
+    exports.BoneSlot = BoneSlot;
+    exports.DeformAniData = DeformAniData;
+    exports.DeformSlotData = DeformSlotData;
+    exports.DeformSlotDisplayData = DeformSlotDisplayData;
+    exports.DrawOrderData = DrawOrderData;
+    exports.EventData = EventData;
+    exports.GraphicsAni = GraphicsAni;
+    exports.IAniLib = IAniLib;
+    exports.IkConstraint = IkConstraint;
+    exports.IkConstraintData = IkConstraintData;
+    exports.KeyFramesContent = KeyFramesContent;
+    exports.MeshData = MeshData;
+    exports.MovieClip = MovieClip;
+    exports.PathConstraint = PathConstraint;
+    exports.PathConstraintData = PathConstraintData;
+    exports.Skeleton = Skeleton;
+    exports.SkinData = SkinData;
+    exports.SkinMeshForGraphic = SkinMeshForGraphic;
+    exports.SkinSlotDisplayData = SkinSlotDisplayData;
+    exports.SlotData = SlotData;
+    exports.Templet = Templet;
+    exports.TfConstraint = TfConstraint;
+    exports.TfConstraintData = TfConstraintData;
+    exports.Transform = Transform;
+    exports.UVTools = UVTools;
+
+}(window.Laya = window.Laya || {}, Laya));

+ 1700 - 0
ShootingSun/bin/libs/laya.bdmini.js

@@ -0,0 +1,1700 @@
+window.bdMiniGame = function (exports, Laya) {
+	'use strict';
+
+	class MiniFileMgr {
+	    static isLocalNativeFile(url) {
+	        for (var i = 0, sz = BMiniAdapter.nativefiles.length; i < sz; i++) {
+	            if (url.indexOf(BMiniAdapter.nativefiles[i]) != -1)
+	                return true;
+	        }
+	        return false;
+	    }
+	    static getFileInfo(fileUrl) {
+	        var fileNativePath = fileUrl;
+	        var fileObj = MiniFileMgr.fakeObj[fileNativePath];
+	        if (fileObj == null)
+	            return null;
+	        else
+	            return fileObj;
+	        return null;
+	    }
+	    static read(filePath, encoding = "utf8", callBack = null, readyUrl = "", isSaveFile = false, fileType = "") {
+	        var fileUrl;
+	        if (readyUrl != "" && (readyUrl.indexOf("http://") != -1 || readyUrl.indexOf("https://") != -1)) {
+	            fileUrl = MiniFileMgr.getFileNativePath(filePath);
+	        }
+	        else {
+	            fileUrl = filePath;
+	        }
+	        fileUrl = Laya.URL.getAdptedFilePath(fileUrl);
+	        MiniFileMgr.fs.readFile({ filePath: fileUrl, encoding: encoding, success: function (data) {
+	                callBack != null && callBack.runWith([0, data]);
+	            }, fail: function (data) {
+	                if (data && readyUrl != "")
+	                    MiniFileMgr.downFiles(readyUrl, encoding, callBack, readyUrl, isSaveFile, fileType);
+	                else
+	                    callBack != null && callBack.runWith([1]);
+	            } });
+	    }
+	    static downFiles(fileUrl, encoding = "utf8", callBack = null, readyUrl = "", isSaveFile = false, fileType = "", isAutoClear = true) {
+	        var downloadTask = MiniFileMgr.wxdown({ url: fileUrl, success: function (data) {
+	                if (data.statusCode === 200)
+	                    MiniFileMgr.readFile(data.tempFilePath, encoding, callBack, readyUrl, isSaveFile, fileType, isAutoClear);
+	                else if (data.statusCode === 403) {
+	                    callBack != null && callBack.runWith([0, fileUrl]);
+	                }
+	                else {
+	                    callBack != null && callBack.runWith([1, data]);
+	                }
+	            }, fail: function (data) {
+	                callBack != null && callBack.runWith([1, data]);
+	            } });
+	        downloadTask.onProgressUpdate(function (data) {
+	            callBack != null && callBack.runWith([2, data.progress]);
+	        });
+	    }
+	    static readFile(filePath, encoding = "utf8", callBack = null, readyUrl = "", isSaveFile = false, fileType = "", isAutoClear = true) {
+	        filePath = Laya.URL.getAdptedFilePath(filePath);
+	        MiniFileMgr.fs.readFile({ filePath: filePath, encoding: encoding, success: function (data) {
+	                if (filePath.indexOf(BMiniAdapter.window.swan.env.USER_DATA_PATH) == -1 && (filePath.indexOf("http://") != -1 || filePath.indexOf("https://") != -1)) {
+	                    if (BMiniAdapter.autoCacheFile || isSaveFile) {
+	                        callBack != null && callBack.runWith([0, data]);
+	                        MiniFileMgr.copyFile(filePath, readyUrl, null, encoding, isAutoClear);
+	                    }
+	                    else
+	                        callBack != null && callBack.runWith([0, data]);
+	                }
+	                else
+	                    callBack != null && callBack.runWith([0, data]);
+	            }, fail: function (data) {
+	                if (data)
+	                    callBack != null && callBack.runWith([1, data]);
+	            } });
+	    }
+	    static downOtherFiles(fileUrl, callBack = null, readyUrl = "", isSaveFile = false, isAutoClear = true) {
+	        MiniFileMgr.wxdown({ url: fileUrl, success: function (data) {
+	                if (data.statusCode === 200) {
+	                    if ((BMiniAdapter.autoCacheFile || isSaveFile) && readyUrl.indexOf("qlogo.cn") == -1 && readyUrl.indexOf(".php") == -1) {
+	                        callBack != null && callBack.runWith([0, data.tempFilePath]);
+	                        MiniFileMgr.copyFile(data.tempFilePath, readyUrl, null, "", isAutoClear);
+	                    }
+	                    else
+	                        callBack != null && callBack.runWith([0, data.tempFilePath]);
+	                }
+	                else {
+	                    callBack != null && callBack.runWith([1, data]);
+	                }
+	            }, fail: function (data) {
+	                callBack != null && callBack.runWith([1, data]);
+	            } });
+	    }
+	    static downLoadFile(fileUrl, fileType = "", callBack = null, encoding = "utf8") {
+	        if (window.navigator.userAgent.indexOf('SwanGame') < 0) {
+	            Laya.Laya.loader.load(fileUrl, callBack);
+	        }
+	        else {
+	            if (fileType == Laya.Loader.IMAGE || fileType == Laya.Loader.SOUND)
+	                MiniFileMgr.downOtherFiles(fileUrl, callBack, fileUrl, true, false);
+	            else
+	                MiniFileMgr.downFiles(fileUrl, encoding, callBack, fileUrl, true, fileType, false);
+	        }
+	    }
+	    static copyFile(tempFilePath, readyUrl, callBack, encoding = "", isAutoClear = true) {
+	        var temp = tempFilePath.split("/");
+	        var tempFileName = temp[temp.length - 1];
+	        var fileurlkey = readyUrl;
+	        var fileObj = MiniFileMgr.getFileInfo(readyUrl);
+	        var saveFilePath = MiniFileMgr.getFileNativePath(tempFileName);
+	        MiniFileMgr.fakeObj[fileurlkey] = { md5: tempFileName, readyUrl: readyUrl, size: 0, times: Laya.Browser.now(), encoding: encoding };
+	        var totalSize = 50 * 1024 * 1024;
+	        var chaSize = 4 * 1024 * 1024;
+	        var fileUseSize = MiniFileMgr.getCacheUseSize();
+	        if (fileObj) {
+	            if (fileObj.readyUrl != readyUrl) {
+	                MiniFileMgr.fs.getFileInfo({
+	                    filePath: tempFilePath,
+	                    success: function (data) {
+	                        if ((isAutoClear && (fileUseSize + chaSize + data.size) >= totalSize)) {
+	                            if (data.size > BMiniAdapter.minClearSize)
+	                                BMiniAdapter.minClearSize = data.size;
+	                            MiniFileMgr.onClearCacheRes();
+	                        }
+	                        MiniFileMgr.deleteFile(tempFilePath, readyUrl, callBack, encoding, data.size);
+	                    },
+	                    fail: function (data) {
+	                        callBack != null && callBack.runWith([1, data]);
+	                    }
+	                });
+	            }
+	            else
+	                callBack != null && callBack.runWith([0]);
+	        }
+	        else {
+	            MiniFileMgr.fs.getFileInfo({
+	                filePath: tempFilePath,
+	                success: function (data) {
+	                    if ((isAutoClear && (fileUseSize + chaSize + data.size) >= totalSize)) {
+	                        if (data.size > BMiniAdapter.minClearSize)
+	                            BMiniAdapter.minClearSize = data.size;
+	                        MiniFileMgr.onClearCacheRes();
+	                    }
+	                    MiniFileMgr.fs.copyFile({ srcPath: tempFilePath, destPath: saveFilePath, success: function (data2) {
+	                            MiniFileMgr.onSaveFile(readyUrl, tempFileName, true, encoding, callBack, data.size);
+	                        }, fail: function (data) {
+	                            callBack != null && callBack.runWith([1, data]);
+	                        } });
+	                },
+	                fail: function (data) {
+	                    callBack != null && callBack.runWith([1, data]);
+	                }
+	            });
+	        }
+	    }
+	    static onClearCacheRes() {
+	        var memSize = BMiniAdapter.minClearSize;
+	        var tempFileListArr = [];
+	        for (var key in MiniFileMgr.filesListObj) {
+	            if (key != "fileUsedSize")
+	                tempFileListArr.push(MiniFileMgr.filesListObj[key]);
+	        }
+	        MiniFileMgr.sortOn(tempFileListArr, "times", MiniFileMgr.NUMERIC);
+	        var clearSize = 0;
+	        for (var i = 1, sz = tempFileListArr.length; i < sz; i++) {
+	            var fileObj = tempFileListArr[i];
+	            if (clearSize >= memSize)
+	                break;
+	            clearSize += fileObj.size;
+	            MiniFileMgr.deleteFile("", fileObj.readyUrl);
+	        }
+	    }
+	    static sortOn(array, name, options = 0) {
+	        if (options == MiniFileMgr.NUMERIC)
+	            return array.sort(function (a, b) { return a[name] - b[name]; });
+	        if (options == (MiniFileMgr.NUMERIC | MiniFileMgr.DESCENDING))
+	            return array.sort(function (a, b) { return b[name] - a[name]; });
+	        return array.sort(function (a, b) { return a[name] - b[name]; });
+	    }
+	    static getFileNativePath(fileName) {
+	        return MiniFileMgr.fileNativeDir + "/" + fileName;
+	    }
+	    static deleteFile(tempFileName, readyUrl = "", callBack = null, encoding = "", fileSize = 0) {
+	        var fileObj = MiniFileMgr.getFileInfo(readyUrl);
+	        var deleteFileUrl = MiniFileMgr.getFileNativePath(fileObj.md5);
+	        var isAdd = tempFileName != "" ? true : false;
+	        MiniFileMgr.onSaveFile(readyUrl, tempFileName, isAdd, encoding, callBack, fileSize);
+	        MiniFileMgr.fs.unlink({ filePath: deleteFileUrl, success: function (data) {
+	                if (tempFileName != "") {
+	                    var saveFilePath = MiniFileMgr.getFileNativePath(tempFileName);
+	                    MiniFileMgr.fs.copyFile({ srcPath: tempFileName, destPath: saveFilePath, success: function (data) {
+	                        }, fail: function (data) {
+	                            callBack != null && callBack.runWith([1, data]);
+	                        } });
+	                }
+	            }, fail: function (data) {
+	            } });
+	    }
+	    static deleteAll() {
+	        var tempFileListArr = [];
+	        for (var key in MiniFileMgr.filesListObj) {
+	            if (key != "fileUsedSize")
+	                tempFileListArr.push(MiniFileMgr.filesListObj[key]);
+	        }
+	        for (var i = 1, sz = tempFileListArr.length; i < sz; i++) {
+	            var fileObj = tempFileListArr[i];
+	            MiniFileMgr.deleteFile("", fileObj.readyUrl);
+	        }
+	        if (MiniFileMgr.filesListObj && MiniFileMgr.filesListObj.fileUsedSize) {
+	            MiniFileMgr.filesListObj.fileUsedSize = 0;
+	        }
+	        MiniFileMgr.writeFilesList("", JSON.stringify({}), false);
+	    }
+	    static onSaveFile(readyUrl, md5Name, isAdd = true, encoding = "", callBack = null, fileSize = 0) {
+	        var fileurlkey = readyUrl;
+	        if (MiniFileMgr.filesListObj['fileUsedSize'] == null)
+	            MiniFileMgr.filesListObj['fileUsedSize'] = 0;
+	        if (isAdd) {
+	            var fileNativeName = MiniFileMgr.getFileNativePath(md5Name);
+	            MiniFileMgr.filesListObj[fileurlkey] = { md5: md5Name, readyUrl: readyUrl, size: fileSize, times: Laya.Browser.now(), encoding: encoding };
+	            MiniFileMgr.filesListObj['fileUsedSize'] = parseInt(MiniFileMgr.filesListObj['fileUsedSize']) + fileSize;
+	            MiniFileMgr.writeFilesList(fileurlkey, JSON.stringify(MiniFileMgr.filesListObj), true);
+	            callBack != null && callBack.runWith([0]);
+	        }
+	        else {
+	            if (MiniFileMgr.filesListObj[fileurlkey]) {
+	                var deletefileSize = parseInt(MiniFileMgr.filesListObj[fileurlkey].size);
+	                MiniFileMgr.filesListObj['fileUsedSize'] = parseInt(MiniFileMgr.filesListObj['fileUsedSize']) - deletefileSize;
+	                delete MiniFileMgr.filesListObj[fileurlkey];
+	                MiniFileMgr.writeFilesList(fileurlkey, JSON.stringify(MiniFileMgr.filesListObj), false);
+	                callBack != null && callBack.runWith([0]);
+	            }
+	        }
+	    }
+	    static writeFilesList(fileurlkey, filesListStr, isAdd) {
+	        var listFilesPath = MiniFileMgr.fileNativeDir + "/" + MiniFileMgr.fileListName;
+	        MiniFileMgr.fs.writeFile({ filePath: listFilesPath, encoding: 'utf8', data: filesListStr, success: function (data) {
+	            }, fail: function (data) {
+	            } });
+	        if (!BMiniAdapter.isZiYu && BMiniAdapter.isPosMsgYu) {
+	            BMiniAdapter.window.swan.postMessage({ url: fileurlkey, data: MiniFileMgr.filesListObj[fileurlkey], isLoad: "filenative", isAdd: isAdd });
+	        }
+	    }
+	    static getCacheUseSize() {
+	        if (MiniFileMgr.filesListObj && MiniFileMgr.filesListObj['fileUsedSize'])
+	            return MiniFileMgr.filesListObj['fileUsedSize'];
+	        return 0;
+	    }
+	    static existDir(dirPath, callBack) {
+	        MiniFileMgr.fs.mkdir({ dirPath: dirPath, success: function (data) {
+	                callBack != null && callBack.runWith([0, { data: JSON.stringify({}) }]);
+	            }, fail: function (data) {
+	                if (data.errMsg.indexOf("file already exists") != -1)
+	                    MiniFileMgr.readSync(MiniFileMgr.fileListName, "utf8", callBack);
+	                else
+	                    callBack != null && callBack.runWith([1, data]);
+	            } });
+	    }
+	    static readSync(filePath, encoding = "utf8", callBack = null, readyUrl = "") {
+	        var fileUrl = MiniFileMgr.getFileNativePath(filePath);
+	        var filesListStr;
+	        try {
+	            filesListStr = MiniFileMgr.fs.readFileSync(fileUrl, encoding);
+	            callBack != null && callBack.runWith([0, { data: filesListStr }]);
+	        }
+	        catch (error) {
+	            callBack != null && callBack.runWith([1]);
+	        }
+	    }
+	    static setNativeFileDir(value) {
+	        MiniFileMgr.fileNativeDir = BMiniAdapter.window.swan.env.USER_DATA_PATH + value;
+	    }
+	}
+	MiniFileMgr.fs = window.swan.getFileSystemManager();
+	MiniFileMgr.wxdown = window.swan.downloadFile;
+	MiniFileMgr.filesListObj = {};
+	MiniFileMgr.fakeObj = {};
+	MiniFileMgr.fileListName = "layaairfiles.txt";
+	MiniFileMgr.ziyuFileData = {};
+	MiniFileMgr.ziyuFileTextureData = {};
+	MiniFileMgr.loadPath = "";
+	MiniFileMgr.DESCENDING = 2;
+	MiniFileMgr.NUMERIC = 16;
+
+	class MiniSoundChannel extends Laya.SoundChannel {
+	    constructor(audio, miniSound) {
+	        super();
+	        this._audio = audio;
+	        this._miniSound = miniSound;
+	        this._onEnd = MiniSoundChannel.bindToThis(this.__onEnd, this);
+	        audio.onEnded(this._onEnd);
+	    }
+	    static bindToThis(fun, scope) {
+	        var rst = fun;
+	        rst = fun.bind(scope);
+	        return rst;
+	    }
+	    __onEnd() {
+	        if (this.loops == 1) {
+	            if (this.completeHandler) {
+	                Laya.Laya.systemTimer.once(10, this, this.__runComplete, [this.completeHandler], false);
+	                this.completeHandler = null;
+	            }
+	            this.stop();
+	            this.event(Laya.Event.COMPLETE);
+	            return;
+	        }
+	        if (this.loops > 0) {
+	            this.loops--;
+	        }
+	        this.startTime = 0;
+	        this.play();
+	    }
+	    play() {
+	        this.isStopped = false;
+	        Laya.SoundManager.addChannel(this);
+	        this._audio.play();
+	    }
+	    set startTime(time) {
+	        if (this._audio) {
+	            this._audio.startTime = time;
+	        }
+	    }
+	    set autoplay(value) {
+	        this._audio.autoplay = value;
+	    }
+	    get autoplay() {
+	        return this._audio.autoplay;
+	    }
+	    get position() {
+	        if (!this._audio)
+	            return 0;
+	        return this._audio.currentTime;
+	    }
+	    get duration() {
+	        if (!this._audio)
+	            return 0;
+	        return this._audio.duration;
+	    }
+	    stop() {
+	        this.isStopped = true;
+	        Laya.SoundManager.removeChannel(this);
+	        this.completeHandler = null;
+	        if (!this._audio)
+	            return;
+	        this._audio.stop();
+	        if (!this.loop) {
+	            this._audio.offEnded(null);
+	            this._miniSound.dispose();
+	            this._audio = null;
+	            this._miniSound = null;
+	            this._onEnd = null;
+	        }
+	    }
+	    pause() {
+	        this.isStopped = true;
+	        this._audio.pause();
+	    }
+	    get loop() {
+	        return this._audio.loop;
+	    }
+	    set loop(value) {
+	        this._audio.loop = value;
+	    }
+	    resume() {
+	        if (!this._audio)
+	            return;
+	        this.isStopped = false;
+	        Laya.SoundManager.addChannel(this);
+	        this._audio.play();
+	    }
+	    set volume(v) {
+	        if (!this._audio)
+	            return;
+	        this._audio.volume = v;
+	    }
+	    get volume() {
+	        if (!this._audio)
+	            return 1;
+	        return this._audio.volume;
+	    }
+	}
+
+	class MiniSound extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	        this.loaded = false;
+	    }
+	    static _createSound() {
+	        MiniSound._id++;
+	        return BMiniAdapter.window.swan.createInnerAudioContext();
+	    }
+	    load(url) {
+	        if (!MiniSound._musicAudio)
+	            MiniSound._musicAudio = MiniSound._createSound();
+	        if (!MiniFileMgr.isLocalNativeFile(url)) {
+	            url = Laya.URL.formatURL(url);
+	        }
+	        else {
+	            if (url.indexOf("http://") != -1 || url.indexOf("https://") != -1) {
+	                if (MiniFileMgr.loadPath != "") {
+	                    url = url.split(MiniFileMgr.loadPath)[1];
+	                }
+	                else {
+	                    var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    if (tempStr != "")
+	                        url = url.split(tempStr)[1];
+	                }
+	            }
+	        }
+	        this.url = url;
+	        this.readyUrl = url;
+	        if (MiniSound._audioCache[this.readyUrl]) {
+	            this.event(Laya.Event.COMPLETE);
+	            return;
+	        }
+	        if (BMiniAdapter.autoCacheFile && MiniFileMgr.getFileInfo(url)) {
+	            this.onDownLoadCallBack(url, 0);
+	        }
+	        else {
+	            if (!BMiniAdapter.autoCacheFile) {
+	                this.onDownLoadCallBack(url, 0);
+	            }
+	            else {
+	                if (MiniFileMgr.isLocalNativeFile(url)) {
+	                    tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    var tempUrl = url;
+	                    if (tempStr != "")
+	                        url = url.split(tempStr)[1];
+	                    if (!url) {
+	                        url = tempUrl;
+	                    }
+	                    if (BMiniAdapter.subNativeFiles && BMiniAdapter.subNativeheads.length == 0) {
+	                        for (var key in BMiniAdapter.subNativeFiles) {
+	                            var tempArr = BMiniAdapter.subNativeFiles[key];
+	                            BMiniAdapter.subNativeheads = BMiniAdapter.subNativeheads.concat(tempArr);
+	                            for (var aa = 0; aa < tempArr.length; aa++) {
+	                                BMiniAdapter.subMaps[tempArr[aa]] = key + "/" + tempArr[aa];
+	                            }
+	                        }
+	                    }
+	                    if (BMiniAdapter.subNativeFiles && url.indexOf("/") != -1) {
+	                        var curfileHead = url.split("/")[0] + "/";
+	                        if (curfileHead && BMiniAdapter.subNativeheads.indexOf(curfileHead) != -1) {
+	                            var newfileHead = BMiniAdapter.subMaps[curfileHead];
+	                            url = url.replace(curfileHead, newfileHead);
+	                        }
+	                    }
+	                    this.onDownLoadCallBack(url, 0);
+	                }
+	                else {
+	                    if (!MiniFileMgr.isLocalNativeFile(url) && (url.indexOf("http://") == -1 && url.indexOf("https://") == -1) || (url.indexOf(BMiniAdapter.window.swan.env.USER_DATA_PATH) != -1)) {
+	                        this.onDownLoadCallBack(url, 0);
+	                    }
+	                    else {
+	                        MiniFileMgr.downOtherFiles(encodeURI(url), Laya.Handler.create(this, this.onDownLoadCallBack, [url]), url);
+	                    }
+	                }
+	            }
+	        }
+	    }
+	    onDownLoadCallBack(sourceUrl, errorCode) {
+	        if (!errorCode) {
+	            var fileNativeUrl;
+	            if (BMiniAdapter.autoCacheFile) {
+	                if (MiniFileMgr.isLocalNativeFile(sourceUrl)) {
+	                    var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    var tempUrl = sourceUrl;
+	                    if (tempStr != "" && (sourceUrl.indexOf("http://") != -1 || sourceUrl.indexOf("https://") != -1))
+	                        fileNativeUrl = sourceUrl.split(tempStr)[1];
+	                    if (!fileNativeUrl) {
+	                        fileNativeUrl = tempUrl;
+	                    }
+	                }
+	                else {
+	                    var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                    if (fileObj && fileObj.md5) {
+	                        var fileMd5Name = fileObj.md5;
+	                        fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                    }
+	                    else {
+	                        fileNativeUrl = sourceUrl;
+	                    }
+	                }
+	                if (this.url != Laya.SoundManager._bgMusic) {
+	                    this._sound = MiniSound._createSound();
+	                    this._sound.src = this.url = fileNativeUrl;
+	                }
+	                else {
+	                    this._sound = MiniSound._musicAudio;
+	                    this._sound.src = this.url = fileNativeUrl;
+	                }
+	            }
+	            else {
+	                if (this.url != Laya.SoundManager._bgMusic) {
+	                    this._sound = MiniSound._createSound();
+	                    this._sound.src = sourceUrl;
+	                }
+	                else {
+	                    this._sound = MiniSound._musicAudio;
+	                    this._sound.src = sourceUrl;
+	                }
+	            }
+	            this._sound.onCanplay(MiniSound.bindToThis(this.onCanPlay, this));
+	            this._sound.onError(MiniSound.bindToThis(this.onError, this));
+	        }
+	        else {
+	            this.event(Laya.Event.ERROR);
+	        }
+	    }
+	    onError(error) {
+	        try {
+	            console.log("-----1---------------minisound-----id:" + MiniSound._id);
+	            console.log(error);
+	        }
+	        catch (error) {
+	            console.log("-----2---------------minisound-----id:" + MiniSound._id);
+	            console.log(error);
+	        }
+	        this.event(Laya.Event.ERROR);
+	        this._sound.offError(null);
+	    }
+	    onCanPlay() {
+	        this.loaded = true;
+	        this.event(Laya.Event.COMPLETE);
+	        this._sound.offCanplay(null);
+	    }
+	    static bindToThis(fun, scope) {
+	        var rst = fun;
+	        rst = fun.bind(scope);
+	        return rst;
+	    }
+	    play(startTime = 0, loops = 0) {
+	        var tSound;
+	        if (this.url == Laya.SoundManager._bgMusic) {
+	            if (!MiniSound._musicAudio)
+	                MiniSound._musicAudio = MiniSound._createSound();
+	            tSound = MiniSound._musicAudio;
+	        }
+	        else {
+	            if (MiniSound._audioCache[this.readyUrl]) {
+	                tSound = MiniSound._audioCache[this.readyUrl]._sound;
+	            }
+	            else {
+	                tSound = MiniSound._createSound();
+	            }
+	        }
+	        if (!tSound)
+	            return null;
+	        if (BMiniAdapter.autoCacheFile && MiniFileMgr.getFileInfo(this.url)) {
+	            var fileObj = MiniFileMgr.getFileInfo(this.url);
+	            var fileMd5Name = fileObj.md5;
+	            tSound.src = this.url = MiniFileMgr.getFileNativePath(fileMd5Name);
+	        }
+	        else {
+	            tSound.src = encodeURI(this.url);
+	        }
+	        var channel = new MiniSoundChannel(tSound, this);
+	        channel.url = this.url;
+	        channel.loops = loops;
+	        channel.loop = (loops === 0 ? true : false);
+	        channel.startTime = startTime;
+	        channel.play();
+	        Laya.SoundManager.addChannel(channel);
+	        return channel;
+	    }
+	    get duration() {
+	        return this._sound.duration;
+	    }
+	    dispose() {
+	        var ad = MiniSound._audioCache[this.readyUrl];
+	        if (ad) {
+	            ad.src = "";
+	            if (ad._sound) {
+	                ad._sound.destroy();
+	                ad._sound = null;
+	                ad = null;
+	            }
+	            delete MiniSound._audioCache[this.readyUrl];
+	        }
+	        if (this._sound) {
+	            this._sound.destroy();
+	            this._sound = null;
+	            this.readyUrl = this.url = null;
+	        }
+	    }
+	}
+	MiniSound._id = 0;
+	MiniSound._audioCache = {};
+
+	class MiniInput {
+	    constructor() {
+	    }
+	    static _createInputElement() {
+	        Laya.Input['_initInput'](Laya.Input['area'] = Laya.Browser.createElement("textarea"));
+	        Laya.Input['_initInput'](Laya.Input['input'] = Laya.Browser.createElement("input"));
+	        Laya.Input['inputContainer'] = Laya.Browser.createElement("div");
+	        Laya.Input['inputContainer'].style.position = "absolute";
+	        Laya.Input['inputContainer'].style.zIndex = 1E5;
+	        Laya.Browser.container.appendChild(Laya.Input['inputContainer']);
+	        Laya.Laya.stage.on("resize", null, MiniInput._onStageResize);
+	        BMiniAdapter.window.swan.onWindowResize && BMiniAdapter.window.swan.onWindowResize(function (res) {
+	        });
+	        Laya.SoundManager._soundClass = MiniSound;
+	        Laya.SoundManager._musicClass = MiniSound;
+	        var model = BMiniAdapter.systemInfo.model;
+	        var system = BMiniAdapter.systemInfo.system;
+	        if (model.indexOf("iPhone") != -1) {
+	            Laya.Browser.onIPhone = true;
+	            Laya.Browser.onIOS = true;
+	            Laya.Browser.onIPad = true;
+	            Laya.Browser.onAndroid = false;
+	        }
+	        if (system.indexOf("Android") != -1 || system.indexOf("Adr") != -1) {
+	            Laya.Browser.onAndroid = true;
+	            Laya.Browser.onIPhone = false;
+	            Laya.Browser.onIOS = false;
+	            Laya.Browser.onIPad = false;
+	        }
+	    }
+	    static _onStageResize() {
+	        var ts = Laya.Laya.stage._canvasTransform.identity();
+	        ts.scale((Laya.Browser.width / Laya.Render.canvas.width / Laya.Browser.pixelRatio), Laya.Browser.height / Laya.Render.canvas.height / Laya.Browser.pixelRatio);
+	    }
+	    static wxinputFocus(e) {
+	        var _inputTarget = Laya.Input['inputElement'].target;
+	        if (_inputTarget && !_inputTarget.editable) {
+	            return;
+	        }
+	        BMiniAdapter.window.swan.offKeyboardConfirm();
+	        BMiniAdapter.window.swan.offKeyboardInput();
+	        BMiniAdapter.window.swan.showKeyboard({ defaultValue: _inputTarget.text, maxLength: _inputTarget.maxChars, multiple: _inputTarget.multiline, confirmHold: true, confirmType: _inputTarget["confirmType"] || 'done', success: function (res) {
+	            }, fail: function (res) {
+	            } });
+	        BMiniAdapter.window.swan.onKeyboardConfirm(function (res) {
+	            var str = res ? res.value : "";
+	            if (_inputTarget._restrictPattern) {
+	                str = str.replace(/\u2006|\x27/g, "");
+	                if (_inputTarget._restrictPattern.test(str)) {
+	                    str = str.replace(_inputTarget._restrictPattern, "");
+	                }
+	            }
+	            _inputTarget.text = str;
+	            _inputTarget.event(Laya.Event.INPUT);
+	            MiniInput.inputEnter();
+	            _inputTarget.event("confirm");
+	        });
+	        BMiniAdapter.window.swan.onKeyboardInput(function (res) {
+	            var str = res ? res.value : "";
+	            if (!_inputTarget.multiline) {
+	                if (str.indexOf("\n") != -1) {
+	                    MiniInput.inputEnter();
+	                    return;
+	                }
+	            }
+	            if (_inputTarget._restrictPattern) {
+	                str = str.replace(/\u2006|\x27/g, "");
+	                if (_inputTarget._restrictPattern.test(str)) {
+	                    str = str.replace(_inputTarget._restrictPattern, "");
+	                }
+	            }
+	            _inputTarget.text = str;
+	            _inputTarget.event(Laya.Event.INPUT);
+	        });
+	    }
+	    static inputEnter() {
+	        Laya.Input['inputElement'].target.focus = false;
+	    }
+	    static wxinputblur() {
+	        MiniInput.hideKeyboard();
+	    }
+	    static hideKeyboard() {
+	        BMiniAdapter.window.swan.offKeyboardConfirm();
+	        BMiniAdapter.window.swan.offKeyboardInput();
+	        BMiniAdapter.window.swan.hideKeyboard({ success: function (res) {
+	                console.log('隐藏键盘');
+	            }, fail: function (res) {
+	                console.log("隐藏键盘出错:" + (res ? res.errMsg : ""));
+	            } });
+	    }
+	}
+
+	class MiniLoader extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	    }
+	    _loadResourceFilter(type, url) {
+	        var thisLoader = this;
+	        if (url.indexOf(BMiniAdapter.window.swan.env.USER_DATA_PATH) == -1 && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1)) {
+	            if (MiniFileMgr.loadPath != "") {
+	                url = url.split(MiniFileMgr.loadPath)[1];
+	            }
+	            else {
+	                var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                var tempUrl = url;
+	                if (tempStr != "")
+	                    url = url.split(tempStr)[1];
+	                if (!url) {
+	                    url = tempUrl;
+	                }
+	            }
+	        }
+	        if (BMiniAdapter.subNativeFiles && BMiniAdapter.subNativeheads.length == 0) {
+	            for (var key in BMiniAdapter.subNativeFiles) {
+	                var tempArr = BMiniAdapter.subNativeFiles[key];
+	                BMiniAdapter.subNativeheads = BMiniAdapter.subNativeheads.concat(tempArr);
+	                for (var aa = 0; aa < tempArr.length; aa++) {
+	                    BMiniAdapter.subMaps[tempArr[aa]] = key + "/" + tempArr[aa];
+	                }
+	            }
+	        }
+	        if (BMiniAdapter.subNativeFiles && url.indexOf("/") != -1) {
+	            var curfileHead = url.split("/")[0] + "/";
+	            if (curfileHead && BMiniAdapter.subNativeheads.indexOf(curfileHead) != -1) {
+	                var newfileHead = BMiniAdapter.subMaps[curfileHead];
+	                url = url.replace(curfileHead, newfileHead);
+	            }
+	        }
+	        switch (type) {
+	            case Laya.Loader.IMAGE:
+	            case "htmlimage":
+	            case "nativeimage":
+	                MiniLoader._transformImgUrl(url, type, thisLoader);
+	                break;
+	            case Laya.Loader.SOUND:
+	                thisLoader._loadSound(url);
+	                break;
+	            default:
+	                thisLoader._loadResource(type, url);
+	        }
+	    }
+	    _loadSound(url) {
+	        var thisLoader = this;
+	        var fileNativeUrl;
+	        if (MiniFileMgr.isLocalNativeFile(url)) {
+	            var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	            var tempUrl = url;
+	            if (tempStr != "" && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1))
+	                fileNativeUrl = url.split(tempStr)[1];
+	            if (!fileNativeUrl) {
+	                fileNativeUrl = tempUrl;
+	            }
+	            MiniLoader.onDownLoadCallBack(url, thisLoader, 0);
+	        }
+	        else {
+	            var tempurl = Laya.URL.formatURL(url);
+	            if (!MiniFileMgr.isLocalNativeFile(url) && (tempurl.indexOf("http://") == -1 && tempurl.indexOf("https://") == -1) || (tempurl.indexOf("http://usr/") != -1)) {
+	                MiniLoader.onDownLoadCallBack(url, thisLoader, 0);
+	            }
+	            else {
+	                MiniFileMgr.downOtherFiles(encodeURI(tempurl), Laya.Handler.create(MiniLoader, MiniLoader.onDownLoadCallBack, [tempurl, thisLoader]), tempurl);
+	            }
+	        }
+	    }
+	    static onDownLoadCallBack(sourceUrl, thisLoader, errorCode, tempFilePath = null) {
+	        if (!errorCode) {
+	            var fileNativeUrl;
+	            if (BMiniAdapter.autoCacheFile) {
+	                if (!tempFilePath) {
+	                    if (MiniFileMgr.isLocalNativeFile(sourceUrl)) {
+	                        var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                        var tempUrl = sourceUrl;
+	                        if (tempStr != "" && (sourceUrl.indexOf("http://") != -1 || sourceUrl.indexOf("https://") != -1))
+	                            fileNativeUrl = sourceUrl.split(tempStr)[1];
+	                        if (!fileNativeUrl) {
+	                            fileNativeUrl = tempUrl;
+	                        }
+	                    }
+	                    else {
+	                        var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                        if (fileObj && fileObj.md5) {
+	                            var fileMd5Name = fileObj.md5;
+	                            fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                        }
+	                        else {
+	                            fileNativeUrl = sourceUrl;
+	                        }
+	                    }
+	                }
+	                else {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	            }
+	            sourceUrl = fileNativeUrl;
+	            var sound = (new Laya.SoundManager._soundClass());
+	            sound.load(sourceUrl);
+	            thisLoader.onLoaded(sound);
+	        }
+	        else {
+	            thisLoader.event(Laya.Event.ERROR, "Load sound failed");
+	        }
+	    }
+	    static bindToThis(fun, scope) {
+	        var rst = fun;
+	        rst = fun.bind(scope);
+	        return rst;
+	    }
+	    _loadHttpRequestWhat(url, contentType) {
+	        var thisLoader = this;
+	        var encoding = BMiniAdapter.getUrlEncode(url, contentType);
+	        if (Laya.Loader.preLoadedMap[url])
+	            thisLoader.onLoaded(Laya.Loader.preLoadedMap[url]);
+	        else {
+	            var tempurl = Laya.URL.formatURL(url);
+	            if (!MiniFileMgr.isLocalNativeFile(url) && !MiniFileMgr.getFileInfo(tempurl) && url.indexOf(BMiniAdapter.window.swan.env.USER_DATA_PATH) == -1 && (tempurl.indexOf("http://") != -1 || tempurl.indexOf("https://") != -1) && !BMiniAdapter.AutoCacheDownFile) {
+	                thisLoader._loadHttpRequest(tempurl, contentType, thisLoader, thisLoader.onLoaded, thisLoader, thisLoader.onProgress, thisLoader, thisLoader.onError);
+	            }
+	            else {
+	                var fileObj = MiniFileMgr.getFileInfo(Laya.URL.formatURL(url));
+	                if (fileObj) {
+	                    fileObj.encoding = fileObj.encoding == null ? "utf8" : fileObj.encoding;
+	                    MiniFileMgr.readFile(MiniFileMgr.getFileNativePath(fileObj.md5), encoding, new Laya.Handler(MiniLoader, MiniLoader.onReadNativeCallBack, [url, contentType, thisLoader]), url);
+	                }
+	                else if (thisLoader.type == "image" || thisLoader.type == "htmlimage") {
+	                    thisLoader._transformUrl(url, contentType);
+	                }
+	                else {
+	                    if (contentType != Laya.Loader.IMAGE && ((tempurl.indexOf("http://") == -1 && tempurl.indexOf("https://") == -1) || MiniFileMgr.isLocalNativeFile(url))) {
+	                        MiniFileMgr.readFile(url, encoding, new Laya.Handler(MiniLoader, MiniLoader.onReadNativeCallBack, [url, contentType, thisLoader]), url);
+	                    }
+	                    else {
+	                        MiniFileMgr.downFiles(tempurl, encoding, new Laya.Handler(MiniLoader, MiniLoader.onReadNativeCallBack, [url, contentType, thisLoader]), tempurl, true);
+	                    }
+	                }
+	            }
+	        }
+	    }
+	    static onReadNativeCallBack(url, type = null, thisLoader = null, errorCode = 0, data = null) {
+	        if (!errorCode) {
+	            var tempData;
+	            if (type == Laya.Loader.JSON || type == Laya.Loader.ATLAS || type == Laya.Loader.PREFAB || type == Laya.Loader.PLF) {
+	                tempData = BMiniAdapter.getJson(data.data);
+	            }
+	            else if (type == Laya.Loader.XML) {
+	                tempData = Laya.Utils.parseXMLFromString(data.data);
+	            }
+	            else {
+	                tempData = data.data;
+	            }
+	            if (!BMiniAdapter.isZiYu && BMiniAdapter.isPosMsgYu && type != Laya.Loader.BUFFER && BMiniAdapter.window.swan) {
+	                BMiniAdapter.window.swan.postMessage({ url: url, data: tempData, isLoad: "filedata" });
+	            }
+	            thisLoader.onLoaded(tempData);
+	        }
+	        else if (errorCode == 1) {
+	            thisLoader._loadHttpRequest(url, type, thisLoader, thisLoader.onLoaded, thisLoader, thisLoader.onProgress, thisLoader, thisLoader.onError);
+	        }
+	    }
+	    static _transformImgUrl(url, type, thisLoader) {
+	        if (BMiniAdapter.isZiYu) {
+	            thisLoader._loadImage(url, false);
+	            return;
+	        }
+	        if (MiniFileMgr.isLocalNativeFile(url)) {
+	            thisLoader._loadImage(url, false);
+	            return;
+	        }
+	        if (!MiniFileMgr.isLocalNativeFile(url) && !MiniFileMgr.getFileInfo(Laya.URL.formatURL(url))) {
+	            var tempUrl = Laya.URL.formatURL(url);
+	            if (url.indexOf(BMiniAdapter.window.swan.env.USER_DATA_PATH) == -1 && (tempUrl.indexOf("http://") != -1 || tempUrl.indexOf("https://") != -1)) {
+	                if (BMiniAdapter.isZiYu) {
+	                    thisLoader._loadImage(url, false);
+	                }
+	                else {
+	                    MiniFileMgr.downOtherFiles(tempUrl, new Laya.Handler(MiniLoader, MiniLoader.onDownImgCallBack, [url, thisLoader]), tempUrl);
+	                }
+	            }
+	            else
+	                thisLoader._loadImage(url, false);
+	        }
+	        else {
+	            MiniLoader.onCreateImage(url, thisLoader);
+	        }
+	    }
+	    static onDownImgCallBack(sourceUrl, thisLoader, errorCode, tempFilePath = "") {
+	        if (!errorCode)
+	            MiniLoader.onCreateImage(sourceUrl, thisLoader, false, tempFilePath);
+	        else {
+	            thisLoader.onError(null);
+	        }
+	    }
+	    static onCreateImage(sourceUrl, thisLoader, isLocal = false, tempFilePath = "") {
+	        var fileNativeUrl;
+	        if (BMiniAdapter.autoCacheFile) {
+	            if (!isLocal) {
+	                if (tempFilePath != "") {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	                else {
+	                    var fileObj = MiniFileMgr.getFileInfo(Laya.URL.formatURL(sourceUrl));
+	                    var fileMd5Name = fileObj.md5;
+	                    fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                }
+	            }
+	            else if (BMiniAdapter.isZiYu) {
+	                var tempUrl = Laya.URL.formatURL(sourceUrl);
+	                if (MiniFileMgr.ziyuFileTextureData[tempUrl]) {
+	                    fileNativeUrl = MiniFileMgr.ziyuFileTextureData[tempUrl];
+	                }
+	                else
+	                    fileNativeUrl = sourceUrl;
+	            }
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        else {
+	            if (!isLocal)
+	                fileNativeUrl = tempFilePath;
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        thisLoader._loadImage(fileNativeUrl, false);
+	    }
+	}
+
+	class MiniLocalStorage {
+	    constructor() {
+	    }
+	    static __init__() {
+	        MiniLocalStorage.items = MiniLocalStorage;
+	    }
+	    static setItem(key, value) {
+	        try {
+	            BMiniAdapter.window.swan.setStorageSync(key, value);
+	        }
+	        catch (error) {
+	            BMiniAdapter.window.swan.setStorage({
+	                key: key,
+	                data: value
+	            });
+	        }
+	    }
+	    static getItem(key) {
+	        return BMiniAdapter.window.swan.getStorageSync(key);
+	    }
+	    static setJSON(key, value) {
+	        MiniLocalStorage.setItem(key, value);
+	    }
+	    static getJSON(key) {
+	        return MiniLocalStorage.getItem(key);
+	    }
+	    static removeItem(key) {
+	        BMiniAdapter.window.swan.removeStorageSync(key);
+	    }
+	    static clear() {
+	        BMiniAdapter.window.swan.clearStorageSync();
+	    }
+	    static getStorageInfoSync() {
+	        try {
+	            var res = BMiniAdapter.window.swan.getStorageInfoSync();
+	            console.log(res.keys);
+	            console.log(res.currentSize);
+	            console.log(res.limitSize);
+	            return res;
+	        }
+	        catch (e) {
+	        }
+	        return null;
+	    }
+	}
+	MiniLocalStorage.support = true;
+
+	class BMiniAdapter {
+	    static getJson(data) {
+	        return JSON.parse(data);
+	    }
+	    static enable() {
+	        BMiniAdapter.init(Laya.Laya.isWXPosMsg, Laya.Laya.isWXOpenDataContext);
+	    }
+	    static init(isPosMsg = false, isSon = false) {
+	        if (BMiniAdapter._inited)
+	            return;
+	        BMiniAdapter._inited = true;
+	        BMiniAdapter.window = window;
+	        if (!BMiniAdapter.window.hasOwnProperty("swan"))
+	            return;
+	        if (BMiniAdapter.window.navigator.userAgent.indexOf('SwanGame') < 0)
+	            return;
+	        BMiniAdapter.isZiYu = isSon;
+	        BMiniAdapter.isPosMsgYu = isPosMsg;
+	        BMiniAdapter.EnvConfig = {};
+	        if (!BMiniAdapter.isZiYu) {
+	            MiniFileMgr.setNativeFileDir("/layaairGame");
+	            MiniFileMgr.existDir(MiniFileMgr.fileNativeDir, Laya.Handler.create(BMiniAdapter, BMiniAdapter.onMkdirCallBack));
+	        }
+	        BMiniAdapter.systemInfo = BMiniAdapter.window.swan.getSystemInfoSync();
+	        BMiniAdapter.window.focus = function () {
+	        };
+	        Laya.Laya['_getUrlPath'] = function () {
+	            return "";
+	        };
+	        BMiniAdapter.window.logtime = function (str) {
+	        };
+	        BMiniAdapter.window.alertTimeLog = function (str) {
+	        };
+	        BMiniAdapter.window.resetShareInfo = function () {
+	        };
+	        BMiniAdapter.window.CanvasRenderingContext2D = function () {
+	        };
+	        BMiniAdapter.window.CanvasRenderingContext2D.prototype = BMiniAdapter.window.swan.createCanvas().getContext('2d').__proto__;
+	        BMiniAdapter.window.document.body.appendChild = function () {
+	        };
+	        BMiniAdapter.EnvConfig.pixelRatioInt = 0;
+	        Laya.Browser["_pixelRatio"] = BMiniAdapter.pixelRatio();
+	        BMiniAdapter._preCreateElement = Laya.Browser.createElement;
+	        Laya.Browser["createElement"] = BMiniAdapter.createElement;
+	        Laya.RunDriver.createShaderCondition = BMiniAdapter.createShaderCondition;
+	        Laya.Utils['parseXMLFromString'] = BMiniAdapter.parseXMLFromString;
+	        Laya.Input['_createInputElement'] = MiniInput['_createInputElement'];
+	        Laya.Loader.prototype._loadResourceFilter = MiniLoader.prototype._loadResourceFilter;
+	        Laya.Loader.prototype._loadSound = MiniLoader.prototype._loadSound;
+	        Laya.Loader.prototype._loadHttpRequestWhat = MiniLoader.prototype._loadHttpRequestWhat;
+	        Laya.LocalStorage._baseClass = MiniLocalStorage;
+	        MiniLocalStorage.__init__();
+	        BMiniAdapter.window.swan.onMessage && BMiniAdapter.window.swan.onMessage(BMiniAdapter._onMessage);
+	    }
+	    static _onMessage(data) {
+	        switch (data.type) {
+	            case "changeMatrix":
+	                Laya.Laya.stage.transform.identity();
+	                Laya.Laya.stage._width = data.w;
+	                Laya.Laya.stage._height = data.h;
+	                Laya.Laya.stage._canvasTransform = new Laya.Matrix(data.a, data.b, data.c, data.d, data.tx, data.ty);
+	                break;
+	            case "display":
+	                Laya.Laya.stage.frameRate = data.rate || Laya.Stage.FRAME_FAST;
+	                break;
+	            case "undisplay":
+	                Laya.Laya.stage.frameRate = Laya.Stage.FRAME_SLEEP;
+	                break;
+	        }
+	        if (data['isLoad'] == "opendatacontext") {
+	            if (data.url) {
+	                MiniFileMgr.ziyuFileData[data.url] = data.atlasdata;
+	                MiniFileMgr.ziyuFileTextureData[data.imgReadyUrl] = data.imgNativeUrl;
+	            }
+	        }
+	        else if (data['isLoad'] == "openJsondatacontext") {
+	            if (data.url) {
+	                MiniFileMgr.ziyuFileData[data.url] = data.atlasdata;
+	            }
+	        }
+	        else if (data['isLoad'] == "openJsondatacontextPic") {
+	            MiniFileMgr.ziyuFileTextureData[data.imgReadyUrl] = data.imgNativeUrl;
+	        }
+	    }
+	    static getUrlEncode(url, type) {
+	        if (type == "arraybuffer")
+	            return "";
+	        return "utf8";
+	    }
+	    static downLoadFile(fileUrl, fileType = "", callBack = null, encoding = "utf8") {
+	        var fileObj = MiniFileMgr.getFileInfo(fileUrl);
+	        if (!fileObj)
+	            MiniFileMgr.downLoadFile(fileUrl, fileType, callBack, encoding);
+	        else {
+	            callBack != null && callBack.runWith([0]);
+	        }
+	    }
+	    static remove(fileUrl, callBack = null) {
+	        MiniFileMgr.deleteFile("", fileUrl, callBack, "", 0);
+	    }
+	    static removeAll() {
+	        MiniFileMgr.deleteAll();
+	    }
+	    static hasNativeFile(fileUrl) {
+	        return MiniFileMgr.isLocalNativeFile(fileUrl);
+	    }
+	    static getFileInfo(fileUrl) {
+	        return MiniFileMgr.getFileInfo(fileUrl);
+	    }
+	    static getFileList() {
+	        return MiniFileMgr.filesListObj;
+	    }
+	    static onMkdirCallBack(errorCode, data) {
+	        if (!errorCode)
+	            MiniFileMgr.filesListObj = JSON.parse(data.data);
+	        MiniFileMgr.fakeObj = MiniFileMgr.filesListObj;
+	    }
+	    static pixelRatio() {
+	        if (!BMiniAdapter.EnvConfig.pixelRatioInt) {
+	            try {
+	                BMiniAdapter.EnvConfig.pixelRatioInt = BMiniAdapter.systemInfo.pixelRatio;
+	                return BMiniAdapter.systemInfo.pixelRatio;
+	            }
+	            catch (error) {
+	            }
+	        }
+	        return BMiniAdapter.EnvConfig.pixelRatioInt;
+	    }
+	    static createElement(type) {
+	        if (type == "canvas") {
+	            var _source;
+	            if (BMiniAdapter.idx == 1) {
+	                if (BMiniAdapter.isZiYu) {
+	                    _source = BMiniAdapter.window.sharedCanvas;
+	                }
+	                else {
+	                    _source = BMiniAdapter.window.canvas;
+	                }
+	            }
+	            else {
+	                _source = BMiniAdapter.window.swan.createCanvas();
+	            }
+	            _source.style = {};
+	            BMiniAdapter.idx++;
+	            return _source;
+	        }
+	        else if (type == "textarea" || type == "input") {
+	            return BMiniAdapter.onCreateInput(type);
+	        }
+	        else if (type == "div") {
+	            var node = BMiniAdapter._preCreateElement(type);
+	            node.contains = function (value) {
+	                return null;
+	            };
+	            node.removeChild = function (value) {
+	            };
+	            return node;
+	        }
+	        else {
+	            return BMiniAdapter._preCreateElement(type);
+	        }
+	    }
+	    static onCreateInput(type) {
+	        var node = BMiniAdapter._preCreateElement(type);
+	        node.focus = MiniInput.wxinputFocus;
+	        node.blur = MiniInput.wxinputblur;
+	        node.style = {};
+	        node.value = 0;
+	        if (!node.parentElement)
+	            node.parentElement = {};
+	        node.placeholder = {};
+	        node.type = {};
+	        node.setColor = function (value) {
+	        };
+	        node.setType = function (value) {
+	        };
+	        node.setFontFace = function (value) {
+	        };
+	        node.addEventListener = function (value) {
+	        };
+	        node.contains = function (value) {
+	            return null;
+	        };
+	        node.removeChild = function (value) {
+	        };
+	        return node;
+	    }
+	    static createShaderCondition(conditionScript) {
+	        var func = function () {
+	            return this[conditionScript.replace("this.", "")];
+	        };
+	        return func;
+	    }
+	    static sendAtlasToOpenDataContext(url) {
+	        if (!BMiniAdapter.isZiYu) {
+	            var atlasJson = Laya.Loader.getRes(Laya.URL.formatURL(url));
+	            if (atlasJson) {
+	                var textureArr = atlasJson.meta.image.split(",");
+	                if (atlasJson.meta && atlasJson.meta.image) {
+	                    var toloadPics = atlasJson.meta.image.split(",");
+	                    var split = url.indexOf("/") >= 0 ? "/" : "\\";
+	                    var idx = url.lastIndexOf(split);
+	                    var folderPath = idx >= 0 ? url.substr(0, idx + 1) : "";
+	                    for (var i = 0, len = toloadPics.length; i < len; i++) {
+	                        toloadPics[i] = folderPath + toloadPics[i];
+	                    }
+	                }
+	                else {
+	                    toloadPics = [url.replace(".json", ".png")];
+	                }
+	                for (i = 0; i < toloadPics.length; i++) {
+	                    var tempAtlasPngUrl = toloadPics[i];
+	                    BMiniAdapter.postInfoToContext(url, tempAtlasPngUrl, atlasJson);
+	                }
+	            }
+	            else {
+	                throw "传递的url没有获取到对应的图集数据信息,请确保图集已经过!";
+	            }
+	        }
+	    }
+	    static postInfoToContext(url, atlaspngUrl, atlasJson) {
+	        var postData = { "frames": atlasJson.frames, "meta": atlasJson.meta };
+	        var textureUrl = atlaspngUrl;
+	        var fileObj = MiniFileMgr.getFileInfo(Laya.URL.formatURL(atlaspngUrl));
+	        if (fileObj) {
+	            var fileMd5Name = fileObj.md5;
+	            var fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	        }
+	        else {
+	            fileNativeUrl = textureUrl;
+	        }
+	        if (fileNativeUrl) {
+	            BMiniAdapter.window.swan.postMessage({ url: url, atlasdata: postData, imgNativeUrl: fileNativeUrl, imgReadyUrl: textureUrl, isLoad: "opendatacontext" });
+	        }
+	        else {
+	            throw "获取图集的磁盘url路径不存在!";
+	        }
+	    }
+	    static sendSinglePicToOpenDataContext(url) {
+	        var tempTextureUrl = Laya.URL.formatURL(url);
+	        var fileObj = MiniFileMgr.getFileInfo(tempTextureUrl);
+	        if (fileObj) {
+	            var fileMd5Name = fileObj.md5;
+	            var fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	            url = tempTextureUrl;
+	        }
+	        else {
+	            fileNativeUrl = url;
+	        }
+	        if (fileNativeUrl) {
+	            BMiniAdapter.window.swan.postMessage({ url: url, imgNativeUrl: fileNativeUrl, imgReadyUrl: url, isLoad: "openJsondatacontextPic" });
+	        }
+	        else {
+	            throw "获取图集的磁盘url路径不存在!";
+	        }
+	    }
+	    static sendJsonDataToDataContext(url) {
+	        if (!BMiniAdapter.isZiYu) {
+	            var atlasJson = Laya.Loader.getRes(url);
+	            if (atlasJson) {
+	                BMiniAdapter.window.swan.postMessage({ url: url, atlasdata: atlasJson, isLoad: "openJsondatacontext" });
+	            }
+	            else {
+	                throw "传递的url没有获取到对应的图集数据信息,请确保图集已经过!";
+	            }
+	        }
+	    }
+	}
+	BMiniAdapter._inited = false;
+	BMiniAdapter.autoCacheFile = true;
+	BMiniAdapter.minClearSize = (5 * 1024 * 1024);
+	BMiniAdapter.nativefiles = ["layaNativeDir", "wxlocal"];
+	BMiniAdapter.subNativeFiles = [];
+	BMiniAdapter.subNativeheads = [];
+	BMiniAdapter.subMaps = [];
+	BMiniAdapter.AutoCacheDownFile = false;
+	BMiniAdapter.parseXMLFromString = function (value) {
+	    var rst;
+	    value = value.replace(/>\s+</g, '><');
+	    try {
+	        rst = (new BMiniAdapter.window.Parser.DOMParser()).parseFromString(value, 'text/xml');
+	    }
+	    catch (error) {
+	        throw "需要引入xml解析库文件";
+	    }
+	    return rst;
+	};
+	BMiniAdapter.idx = 1;
+
+	class MiniAccelerator extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	    }
+	    static __init__() {
+	        try {
+	            var Acc;
+	            Acc = Laya.Accelerator;
+	            if (!Acc)
+	                return;
+	            Acc["prototype"]["on"] = MiniAccelerator["prototype"]["on"];
+	            Acc["prototype"]["off"] = MiniAccelerator["prototype"]["off"];
+	        }
+	        catch (e) {
+	        }
+	    }
+	    static startListen(callBack) {
+	        MiniAccelerator._callBack = callBack;
+	        if (MiniAccelerator._isListening)
+	            return;
+	        MiniAccelerator._isListening = true;
+	        try {
+	            BMiniAdapter.window.swan.onAccelerometerChange(MiniAccelerator.onAccelerometerChange);
+	        }
+	        catch (e) { }
+	    }
+	    static stopListen() {
+	        MiniAccelerator._isListening = false;
+	        try {
+	            BMiniAdapter.window.swan.stopAccelerometer({});
+	        }
+	        catch (e) { }
+	    }
+	    static onAccelerometerChange(res) {
+	        var e;
+	        e = {};
+	        e.acceleration = res;
+	        e.accelerationIncludingGravity = res;
+	        e.rotationRate = {};
+	        if (MiniAccelerator._callBack != null) {
+	            MiniAccelerator._callBack(e);
+	        }
+	    }
+	    on(type, caller, listener, args = null) {
+	        super.on(type, caller, listener, args);
+	        MiniAccelerator.startListen(this["onDeviceOrientationChange"]);
+	        return this;
+	    }
+	    off(type, caller, listener, onceOnly = false) {
+	        if (!this.hasListener(type))
+	            MiniAccelerator.stopListen();
+	        return super.off(type, caller, listener, onceOnly);
+	    }
+	}
+	MiniAccelerator._isListening = false;
+
+	class MiniImage {
+	    _loadImage(url) {
+	        var thisLoader = this;
+	        if (BMiniAdapter.isZiYu) {
+	            MiniImage.onCreateImage(url, thisLoader, true);
+	            return;
+	        }
+	        var isTransformUrl;
+	        if (!MiniFileMgr.isLocalNativeFile(url)) {
+	            isTransformUrl = true;
+	            url = Laya.URL.formatURL(url);
+	        }
+	        else {
+	            if (url.indexOf("http://usr/") == -1 && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1)) {
+	                if (MiniFileMgr.loadPath != "") {
+	                    url = url.split(MiniFileMgr.loadPath)[1];
+	                }
+	                else {
+	                    var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    var tempUrl = url;
+	                    if (tempStr != "")
+	                        url = url.split(tempStr)[1];
+	                    if (!url) {
+	                        url = tempUrl;
+	                    }
+	                }
+	            }
+	            if (BMiniAdapter.subNativeFiles && BMiniAdapter.subNativeheads.length == 0) {
+	                for (var key in BMiniAdapter.subNativeFiles) {
+	                    var tempArr = BMiniAdapter.subNativeFiles[key];
+	                    BMiniAdapter.subNativeheads = BMiniAdapter.subNativeheads.concat(tempArr);
+	                    for (var aa = 0; aa < tempArr.length; aa++) {
+	                        BMiniAdapter.subMaps[tempArr[aa]] = key + "/" + tempArr[aa];
+	                    }
+	                }
+	            }
+	            if (BMiniAdapter.subNativeFiles && url.indexOf("/") != -1) {
+	                var curfileHead = url.split("/")[0] + "/";
+	                if (curfileHead && BMiniAdapter.subNativeheads.indexOf(curfileHead) != -1) {
+	                    var newfileHead = BMiniAdapter.subMaps[curfileHead];
+	                    url = url.replace(curfileHead, newfileHead);
+	                }
+	            }
+	        }
+	        if (!MiniFileMgr.getFileInfo(url)) {
+	            if (url.indexOf('http://usr/') == -1 && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1)) {
+	                if (BMiniAdapter.isZiYu) {
+	                    MiniImage.onCreateImage(url, thisLoader, true);
+	                }
+	                else {
+	                    MiniFileMgr.downOtherFiles(url, new Laya.Handler(MiniImage, MiniImage.onDownImgCallBack, [url, thisLoader]), url);
+	                }
+	            }
+	            else
+	                MiniImage.onCreateImage(url, thisLoader, true);
+	        }
+	        else {
+	            MiniImage.onCreateImage(url, thisLoader, !isTransformUrl);
+	        }
+	    }
+	    static onDownImgCallBack(sourceUrl, thisLoader, errorCode, tempFilePath = "") {
+	        if (!errorCode)
+	            MiniImage.onCreateImage(sourceUrl, thisLoader, false, tempFilePath);
+	        else {
+	            thisLoader.onError(null);
+	        }
+	    }
+	    static onCreateImage(sourceUrl, thisLoader, isLocal = false, tempFilePath = "") {
+	        var fileNativeUrl;
+	        if (BMiniAdapter.autoCacheFile) {
+	            if (!isLocal) {
+	                if (tempFilePath != "") {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	                else {
+	                    var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                    var fileMd5Name = fileObj.md5;
+	                    fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                }
+	            }
+	            else if (BMiniAdapter.isZiYu) {
+	                var tempUrl = Laya.URL.formatURL(sourceUrl);
+	                if (MiniFileMgr.ziyuFileTextureData[tempUrl]) {
+	                    fileNativeUrl = MiniFileMgr.ziyuFileTextureData[tempUrl];
+	                }
+	                else
+	                    fileNativeUrl = sourceUrl;
+	            }
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        else {
+	            if (!isLocal)
+	                fileNativeUrl = tempFilePath;
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        if (thisLoader._imgCache == null)
+	            thisLoader._imgCache = {};
+	        var image;
+	        function clear() {
+	            var img = thisLoader._imgCache[fileNativeUrl];
+	            if (img) {
+	                img.onload = null;
+	                img.onerror = null;
+	                delete thisLoader._imgCache[fileNativeUrl];
+	            }
+	        }
+	        var onerror = function () {
+	            clear();
+	            delete MiniFileMgr.fakeObj[sourceUrl];
+	            delete MiniFileMgr.filesListObj[sourceUrl];
+	            thisLoader.event(Laya.Event.ERROR, "Load image failed");
+	        };
+	        if (thisLoader._type == "nativeimage") {
+	            var onload = function () {
+	                clear();
+	                thisLoader.onLoaded(image);
+	            };
+	            image = new Laya.Browser.window.Image();
+	            image.crossOrigin = "";
+	            image.onload = onload;
+	            image.onerror = onerror;
+	            image.src = fileNativeUrl;
+	            thisLoader._imgCache[fileNativeUrl] = image;
+	        }
+	        else {
+	            var imageSource = new Laya.Browser.window.Image();
+	            onload = function () {
+	                image = Laya.HTMLImage.create(imageSource.width, imageSource.height);
+	                image.loadImageSource(imageSource, true);
+	                image._setCreateURL(fileNativeUrl);
+	                clear();
+	                thisLoader.onLoaded(image);
+	            };
+	            imageSource.crossOrigin = "";
+	            imageSource.onload = onload;
+	            imageSource.onerror = onerror;
+	            imageSource.src = fileNativeUrl;
+	            thisLoader._imgCache[fileNativeUrl] = imageSource;
+	        }
+	    }
+	}
+
+	class MiniLocation {
+	    constructor() {
+	    }
+	    static __init__() {
+	        BMiniAdapter.window.navigator.geolocation.getCurrentPosition = MiniLocation.getCurrentPosition;
+	        BMiniAdapter.window.navigator.geolocation.watchPosition = MiniLocation.watchPosition;
+	        BMiniAdapter.window.navigator.geolocation.clearWatch = MiniLocation.clearWatch;
+	    }
+	    static getCurrentPosition(success = null, error = null, options = null) {
+	        var paramO;
+	        paramO = {};
+	        paramO.success = getSuccess;
+	        paramO.fail = error;
+	        BMiniAdapter.window.swan.getLocation(paramO);
+	        function getSuccess(res) {
+	            if (success != null) {
+	                success(res);
+	            }
+	        }
+	    }
+	    static watchPosition(success = null, error = null, options = null) {
+	        MiniLocation._curID++;
+	        var curWatchO;
+	        curWatchO = {};
+	        curWatchO.success = success;
+	        curWatchO.error = error;
+	        MiniLocation._watchDic[MiniLocation._curID] = curWatchO;
+	        Laya.Laya.systemTimer.loop(1000, null, MiniLocation._myLoop);
+	        return MiniLocation._curID;
+	    }
+	    static clearWatch(id) {
+	        delete MiniLocation._watchDic[id];
+	        if (!MiniLocation._hasWatch()) {
+	            Laya.Laya.systemTimer.clear(null, MiniLocation._myLoop);
+	        }
+	    }
+	    static _hasWatch() {
+	        var key;
+	        for (key in MiniLocation._watchDic) {
+	            if (MiniLocation._watchDic[key])
+	                return true;
+	        }
+	        return false;
+	    }
+	    static _myLoop() {
+	        MiniLocation.getCurrentPosition(MiniLocation._mySuccess, MiniLocation._myError);
+	    }
+	    static _mySuccess(res) {
+	        var rst = {};
+	        rst.coords = res;
+	        rst.timestamp = Laya.Browser.now();
+	        var key;
+	        for (key in MiniLocation._watchDic) {
+	            if (MiniLocation._watchDic[key].success) {
+	                MiniLocation._watchDic[key].success(rst);
+	            }
+	        }
+	    }
+	    static _myError(res) {
+	        var key;
+	        for (key in MiniLocation._watchDic) {
+	            if (MiniLocation._watchDic[key].error) {
+	                MiniLocation._watchDic[key].error(res);
+	            }
+	        }
+	    }
+	}
+	MiniLocation._watchDic = {};
+	MiniLocation._curID = 0;
+
+	class MiniVideo {
+	    constructor(width = 320, height = 240) {
+	        this.videoend = false;
+	        this.videourl = "";
+	        this.videoElement = BMiniAdapter.window.swan.createVideo({ width: width, height: height, autoplay: true });
+	    }
+	    static __init__() {
+	    }
+	    on(eventType, ths, callBack) {
+	        if (eventType == "loadedmetadata") {
+	            this.onPlayFunc = callBack.bind(ths);
+	            this.videoElement.onPlay = this.onPlayFunction.bind(this);
+	        }
+	        else if (eventType == "ended") {
+	            this.onEndedFunC = callBack.bind(ths);
+	            this.videoElement.onEnded = this.onEndedFunction.bind(this);
+	        }
+	        this.videoElement.onTimeUpdate = this.onTimeUpdateFunc.bind(this);
+	    }
+	    onTimeUpdateFunc(data) {
+	        this.position = data.position;
+	        this._duration = data.duration;
+	    }
+	    get duration() {
+	        return this._duration;
+	    }
+	    onPlayFunction() {
+	        if (this.videoElement)
+	            this.videoElement.readyState = 200;
+	        console.log("=====视频加载完成========");
+	        this.onPlayFunc != null && this.onPlayFunc();
+	    }
+	    onEndedFunction() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoend = true;
+	        console.log("=====视频播放完毕========");
+	        this.onEndedFunC != null && this.onEndedFunC();
+	    }
+	    off(eventType, ths, callBack) {
+	        if (eventType == "loadedmetadata") {
+	            this.onPlayFunc = callBack.bind(ths);
+	            this.videoElement.offPlay = this.onPlayFunction.bind(this);
+	        }
+	        else if (eventType == "ended") {
+	            this.onEndedFunC = callBack.bind(ths);
+	            this.videoElement.offEnded = this.onEndedFunction.bind(this);
+	        }
+	    }
+	    load(url) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.src = url;
+	    }
+	    play() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoend = false;
+	        this.videoElement.play();
+	    }
+	    pause() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoend = true;
+	        this.videoElement.pause();
+	    }
+	    get currentTime() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.initialTime;
+	    }
+	    set currentTime(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.initialTime = value;
+	    }
+	    get videoWidth() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.width;
+	    }
+	    get videoHeight() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.height;
+	    }
+	    get ended() {
+	        return this.videoend;
+	    }
+	    get loop() {
+	        if (!this.videoElement)
+	            return false;
+	        return this.videoElement.loop;
+	    }
+	    set loop(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.loop = value;
+	    }
+	    get playbackRate() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.playbackRate;
+	    }
+	    set playbackRate(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.playbackRate = value;
+	    }
+	    get muted() {
+	        if (!this.videoElement)
+	            return false;
+	        return this.videoElement.muted;
+	    }
+	    set muted(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.muted = value;
+	    }
+	    get paused() {
+	        if (!this.videoElement)
+	            return false;
+	        return this.videoElement.paused;
+	    }
+	    size(width, height) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.width = width;
+	        this.videoElement.height = height;
+	    }
+	    get x() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.x;
+	    }
+	    set x(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.x = value;
+	    }
+	    get y() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.y;
+	    }
+	    set y(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.y = value;
+	    }
+	    get currentSrc() {
+	        return this.videoElement.src;
+	    }
+	    destroy() {
+	        if (this.videoElement)
+	            this.videoElement.destroy();
+	        this.videoElement = null;
+	        this.onEndedFunC = null;
+	        this.onPlayFunc = null;
+	        this.videoend = false;
+	        this.videourl = null;
+	    }
+	    reload() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.src = this.videourl;
+	    }
+	}
+
+	exports.BMiniAdapter = BMiniAdapter;
+	exports.MiniAccelerator = MiniAccelerator;
+	exports.MiniFileMgr = MiniFileMgr;
+	exports.MiniImage = MiniImage;
+	exports.MiniInput = MiniInput;
+	exports.MiniLoader = MiniLoader;
+	exports.MiniLocalStorage = MiniLocalStorage;
+	exports.MiniLocation = MiniLocation;
+	exports.MiniSound = MiniSound;
+	exports.MiniSoundChannel = MiniSoundChannel;
+	exports.MiniVideo = MiniVideo;
+
+} 

文件差異過大導致無法顯示
+ 5184 - 0
ShootingSun/bin/libs/laya.core.js


文件差異過大導致無法顯示
+ 28836 - 0
ShootingSun/bin/libs/laya.d3.js


文件差異過大導致無法顯示
+ 4052 - 0
ShootingSun/bin/libs/laya.debugtool.js


+ 655 - 0
ShootingSun/bin/libs/laya.device.js

@@ -0,0 +1,655 @@
+(function (exports, Laya) {
+	'use strict';
+
+	class AccelerationInfo {
+	    constructor() {
+	    }
+	}
+
+	class RotationInfo {
+	    constructor() {
+	    }
+	}
+
+	class Accelerator extends Laya.EventDispatcher {
+	    constructor(singleton) {
+	        super();
+	        this.onDeviceOrientationChange = this.onDeviceOrientationChange.bind(this);
+	    }
+	    static get instance() {
+	        Accelerator._instance = Accelerator._instance || new Accelerator(0);
+	        return Accelerator._instance;
+	    }
+	    on(type, caller, listener, args = null) {
+	        super.on(type, caller, listener, args);
+	        Laya.ILaya.Browser.window.addEventListener('devicemotion', this.onDeviceOrientationChange);
+	        return this;
+	    }
+	    off(type, caller, listener, onceOnly = false) {
+	        if (!this.hasListener(type))
+	            Laya.ILaya.Browser.window.removeEventListener('devicemotion', this.onDeviceOrientationChange);
+	        return super.off(type, caller, listener, onceOnly);
+	    }
+	    onDeviceOrientationChange(e) {
+	        var interval = e.interval;
+	        Accelerator.acceleration.x = e.acceleration.x;
+	        Accelerator.acceleration.y = e.acceleration.y;
+	        Accelerator.acceleration.z = e.acceleration.z;
+	        Accelerator.accelerationIncludingGravity.x = e.accelerationIncludingGravity.x;
+	        Accelerator.accelerationIncludingGravity.y = e.accelerationIncludingGravity.y;
+	        Accelerator.accelerationIncludingGravity.z = e.accelerationIncludingGravity.z;
+	        Accelerator.rotationRate.alpha = e.rotationRate.gamma * -1;
+	        Accelerator.rotationRate.beta = e.rotationRate.alpha * -1;
+	        Accelerator.rotationRate.gamma = e.rotationRate.beta;
+	        if (Laya.ILaya.Browser.onAndroid) {
+	            if (Laya.ILaya.Browser.userAgent.indexOf("Chrome") > -1) {
+	                Accelerator.rotationRate.alpha *= 180 / Math.PI;
+	                Accelerator.rotationRate.beta *= 180 / Math.PI;
+	                Accelerator.rotationRate.gamma *= 180 / Math.PI;
+	            }
+	            Accelerator.acceleration.x *= -1;
+	            Accelerator.accelerationIncludingGravity.x *= -1;
+	        }
+	        else if (Laya.ILaya.Browser.onIOS) {
+	            Accelerator.acceleration.y *= -1;
+	            Accelerator.acceleration.z *= -1;
+	            Accelerator.accelerationIncludingGravity.y *= -1;
+	            Accelerator.accelerationIncludingGravity.z *= -1;
+	            interval *= 1000;
+	        }
+	        this.event(Laya.Event.CHANGE, [Accelerator.acceleration, Accelerator.accelerationIncludingGravity, Accelerator.rotationRate, interval]);
+	    }
+	    static getTransformedAcceleration(acceleration) {
+	        Accelerator.transformedAcceleration = Accelerator.transformedAcceleration || new AccelerationInfo();
+	        Accelerator.transformedAcceleration.z = acceleration.z;
+	        if (Laya.ILaya.Browser.window.orientation == 90) {
+	            Accelerator.transformedAcceleration.x = acceleration.y;
+	            Accelerator.transformedAcceleration.y = -acceleration.x;
+	        }
+	        else if (Laya.ILaya.Browser.window.orientation == -90) {
+	            Accelerator.transformedAcceleration.x = -acceleration.y;
+	            Accelerator.transformedAcceleration.y = acceleration.x;
+	        }
+	        else if (!Laya.ILaya.Browser.window.orientation) {
+	            Accelerator.transformedAcceleration.x = acceleration.x;
+	            Accelerator.transformedAcceleration.y = acceleration.y;
+	        }
+	        else if (Laya.ILaya.Browser.window.orientation == 180) {
+	            Accelerator.transformedAcceleration.x = -acceleration.x;
+	            Accelerator.transformedAcceleration.y = -acceleration.y;
+	        }
+	        var tx;
+	        if (Laya.ILaya.stage.canvasDegree == -90) {
+	            tx = Accelerator.transformedAcceleration.x;
+	            Accelerator.transformedAcceleration.x = -Accelerator.transformedAcceleration.y;
+	            Accelerator.transformedAcceleration.y = tx;
+	        }
+	        else if (Laya.ILaya.stage.canvasDegree == 90) {
+	            tx = Accelerator.transformedAcceleration.x;
+	            Accelerator.transformedAcceleration.x = Accelerator.transformedAcceleration.y;
+	            Accelerator.transformedAcceleration.y = -tx;
+	        }
+	        return Accelerator.transformedAcceleration;
+	    }
+	}
+	Accelerator.acceleration = new AccelerationInfo();
+	Accelerator.accelerationIncludingGravity = new AccelerationInfo();
+	Accelerator.rotationRate = new RotationInfo();
+
+	class Shake extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	    }
+	    static get instance() {
+	        Shake._instance = Shake._instance || new Shake();
+	        return Shake._instance;
+	    }
+	    start(throushold, interval) {
+	        this.throushold = throushold;
+	        this.shakeInterval = interval;
+	        this.lastX = this.lastY = this.lastZ = NaN;
+	        Accelerator.instance.on(Laya.Event.CHANGE, this, this.onShake);
+	    }
+	    stop() {
+	        Accelerator.instance.off(Laya.Event.CHANGE, this, this.onShake);
+	    }
+	    onShake(acceleration, accelerationIncludingGravity, rotationRate, interval) {
+	        if (isNaN(this.lastX)) {
+	            this.lastX = accelerationIncludingGravity.x;
+	            this.lastY = accelerationIncludingGravity.y;
+	            this.lastZ = accelerationIncludingGravity.z;
+	            this.lastMillSecond = Laya.ILaya.Browser.now();
+	            return;
+	        }
+	        var deltaX = Math.abs(this.lastX - accelerationIncludingGravity.x);
+	        var deltaY = Math.abs(this.lastY - accelerationIncludingGravity.y);
+	        var deltaZ = Math.abs(this.lastZ - accelerationIncludingGravity.z);
+	        if (this.isShaked(deltaX, deltaY, deltaZ)) {
+	            var deltaMillSecond = Laya.ILaya.Browser.now() - this.lastMillSecond;
+	            if (deltaMillSecond > this.shakeInterval) {
+	                this.event(Laya.Event.CHANGE);
+	                this.lastMillSecond = Laya.ILaya.Browser.now();
+	            }
+	        }
+	        this.lastX = accelerationIncludingGravity.x;
+	        this.lastY = accelerationIncludingGravity.y;
+	        this.lastZ = accelerationIncludingGravity.z;
+	    }
+	    isShaked(deltaX, deltaY, deltaZ) {
+	        return (deltaX > this.throushold && deltaY > this.throushold) ||
+	            (deltaX > this.throushold && deltaZ > this.throushold) ||
+	            (deltaY > this.throushold && deltaZ > this.throushold);
+	    }
+	}
+
+	class GeolocationInfo {
+	    setPosition(pos) {
+	        this.pos = pos;
+	        this.coords = pos.coords;
+	    }
+	    get latitude() {
+	        return this.coords.latitude;
+	    }
+	    get longitude() {
+	        return this.coords.longitude;
+	    }
+	    get altitude() {
+	        return this.coords.altitude;
+	    }
+	    get accuracy() {
+	        return this.coords.accuracy;
+	    }
+	    get altitudeAccuracy() {
+	        return this.coords.altitudeAccuracy;
+	    }
+	    get heading() {
+	        return this.coords.heading;
+	    }
+	    get speed() {
+	        return this.coords.speed;
+	    }
+	    get timestamp() {
+	        return this.pos.timestamp;
+	    }
+	}
+
+	class Geolocation {
+	    constructor() {
+	    }
+	    static getCurrentPosition(onSuccess, onError = null) {
+	        Geolocation.navigator.geolocation.getCurrentPosition(function (pos) {
+	            Geolocation.position.setPosition(pos);
+	            onSuccess.runWith(Geolocation.position);
+	        }, function (error) {
+	            onError.runWith(error);
+	        }, {
+	            enableHighAccuracy: Geolocation.enableHighAccuracy,
+	            timeout: Geolocation.timeout,
+	            maximumAge: Geolocation.maximumAge
+	        });
+	    }
+	    static watchPosition(onSuccess, onError) {
+	        return Geolocation.navigator.geolocation.watchPosition(function (pos) {
+	            Geolocation.position.setPosition(pos);
+	            onSuccess.runWith(Geolocation.position);
+	        }, function (error) {
+	            onError.runWith(error);
+	        }, {
+	            enableHighAccuracy: Geolocation.enableHighAccuracy,
+	            timeout: Geolocation.timeout,
+	            maximumAge: Geolocation.maximumAge
+	        });
+	    }
+	    static clearWatch(id) {
+	        Geolocation.navigator.geolocation.clearWatch(id);
+	    }
+	}
+	Geolocation.navigator = Laya.ILaya.Browser.window.navigator;
+	Geolocation.position = new GeolocationInfo();
+	Geolocation.PERMISSION_DENIED = 1;
+	Geolocation.POSITION_UNAVAILABLE = 2;
+	Geolocation.TIMEOUT = 3;
+	Geolocation.supported = !!Geolocation.navigator.geolocation;
+	Geolocation.enableHighAccuracy = false;
+	Geolocation.timeout = 1E10;
+	Geolocation.maximumAge = 0;
+
+	class HtmlVideo extends Laya.Bitmap {
+	    constructor() {
+	        super();
+	        this._w = 0;
+	        this._h = 0;
+	        this._width = 1;
+	        this._height = 1;
+	        this.createDomElement();
+	    }
+	    createDomElement() {
+	        this._source = this.video = Laya.ILaya.Browser.createElement("video");
+	        var style = this.video.style;
+	        style.position = 'absolute';
+	        style.top = '0px';
+	        style.left = '0px';
+	        this.video.addEventListener("loadedmetadata", () => {
+	            this._w = this.video.videoWidth;
+	            this._h = this.video.videoHeight;
+	        });
+	    }
+	    setSource(url, extension) {
+	        while (this.video.childElementCount)
+	            this.video.firstChild.remove();
+	        if (extension & 1)
+	            this.appendSource(url, "video/mp4");
+	        if (extension & 2)
+	            this.appendSource(url + ".ogg", "video/ogg");
+	    }
+	    appendSource(source, type) {
+	        var sourceElement = Laya.ILaya.Browser.createElement("source");
+	        sourceElement.src = source;
+	        sourceElement.type = type;
+	        this.video.appendChild(sourceElement);
+	    }
+	    getVideo() {
+	        return this.video;
+	    }
+	    _getSource() {
+	        return this._source;
+	    }
+	    destroy() {
+	        super.destroy();
+	        var isConchApp = Laya.ILaya.Render.isConchApp;
+	        if (isConchApp) {
+	            this.video._destroy();
+	        }
+	    }
+	}
+	HtmlVideo.create = function () {
+	    return new HtmlVideo();
+	};
+
+	class Media {
+	    constructor() {
+	    }
+	    static supported() {
+	        return !!Laya.ILaya.Browser.window.navigator.getUserMedia;
+	    }
+	    static getMedia(options, onSuccess, onError) {
+	        if (Laya.ILaya.Browser.window.navigator.getUserMedia) {
+	            Laya.ILaya.Browser.window.navigator.getUserMedia(options, function (stream) {
+	                onSuccess.runWith(Laya.ILaya.Browser.window.URL.createObjectURL(stream));
+	            }, function (err) {
+	                onError.runWith(err);
+	            });
+	        }
+	    }
+	}
+
+	class WebGLVideo extends HtmlVideo {
+	    constructor() {
+	        super();
+	        var gl = Laya.LayaGL.instance;
+	        if (!Laya.ILaya.Render.isConchApp && Laya.ILaya.Browser.onIPhone)
+	            return;
+	        this.gl = Laya.ILaya.Render.isConchApp ? window.LayaGLContext.instance : Laya.WebGLContext.mainContext;
+	        this._source = this.gl.createTexture();
+	        Laya.WebGLContext.bindTexture(this.gl, gl.TEXTURE_2D, this._source);
+	        this.gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
+	        this.gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
+	        this.gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
+	        this.gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
+	        Laya.WebGLContext.bindTexture(this.gl, gl.TEXTURE_2D, null);
+	    }
+	    updateTexture() {
+	        if (!Laya.ILaya.Render.isConchApp && Laya.ILaya.Browser.onIPhone)
+	            return;
+	        var gl = Laya.LayaGL.instance;
+	        Laya.WebGLContext.bindTexture(this.gl, gl.TEXTURE_2D, this._source);
+	        this.gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGB, gl.RGB, gl.UNSIGNED_BYTE, this.video);
+	        WebGLVideo.curBindSource = this._source;
+	    }
+	    get _glTexture() {
+	        return this._source;
+	    }
+	    destroy() {
+	        if (this._source) {
+	            this.gl = Laya.ILaya.Render.isConchApp ? window.LayaGLContext.instance : Laya.WebGLContext.mainContext;
+	            if (WebGLVideo.curBindSource == this._source) {
+	                Laya.WebGLContext.bindTexture(this.gl, this.gl.TEXTURE_2D, null);
+	                WebGLVideo.curBindSource = null;
+	            }
+	            this.gl.deleteTexture(this._source);
+	        }
+	        super.destroy();
+	    }
+	}
+
+	class Video extends Laya.Sprite {
+	    constructor(width = 320, height = 240) {
+	        super();
+	        this.htmlVideo = new WebGLVideo();
+	        this.videoElement = this.htmlVideo.getVideo();
+	        this.videoElement.layaTarget = this;
+	        this.internalTexture = new Laya.Texture(this.htmlVideo);
+	        this.videoElement.addEventListener("abort", Video.onAbort);
+	        this.videoElement.addEventListener("canplay", Video.onCanplay);
+	        this.videoElement.addEventListener("canplaythrough", Video.onCanplaythrough);
+	        this.videoElement.addEventListener("durationchange", Video.onDurationchange);
+	        this.videoElement.addEventListener("emptied", Video.onEmptied);
+	        this.videoElement.addEventListener("error", Video.onError);
+	        this.videoElement.addEventListener("loadeddata", Video.onLoadeddata);
+	        this.videoElement.addEventListener("loadedmetadata", Video.onLoadedmetadata);
+	        this.videoElement.addEventListener("loadstart", Video.onLoadstart);
+	        this.videoElement.addEventListener("pause", Video.onPause);
+	        this.videoElement.addEventListener("play", Video.onPlay);
+	        this.videoElement.addEventListener("playing", Video.onPlaying);
+	        this.videoElement.addEventListener("progress", Video.onProgress);
+	        this.videoElement.addEventListener("ratechange", Video.onRatechange);
+	        this.videoElement.addEventListener("seeked", Video.onSeeked);
+	        this.videoElement.addEventListener("seeking", Video.onSeeking);
+	        this.videoElement.addEventListener("stalled", Video.onStalled);
+	        this.videoElement.addEventListener("suspend", Video.onSuspend);
+	        this.videoElement.addEventListener("timeupdate", Video.onTimeupdate);
+	        this.videoElement.addEventListener("volumechange", Video.onVolumechange);
+	        this.videoElement.addEventListener("waiting", Video.onWaiting);
+	        this.videoElement.addEventListener("ended", this.onPlayComplete['bind'](this));
+	        this.size(width, height);
+	        if (Laya.ILaya.Browser.onMobile) {
+	            this.onDocumentClick = this.onDocumentClick.bind(this);
+	            Laya.ILaya.Browser.document.addEventListener("touchend", this.onDocumentClick);
+	        }
+	    }
+	    static onAbort(e) { e.target.layaTarget.event("abort"); }
+	    static onCanplay(e) { e.target.layaTarget.event("canplay"); }
+	    static onCanplaythrough(e) { e.target.layaTarget.event("canplaythrough"); }
+	    static onDurationchange(e) { e.target.layaTarget.event("durationchange"); }
+	    static onEmptied(e) { e.target.layaTarget.event("emptied"); }
+	    static onError(e) { e.target.layaTarget.event("error"); }
+	    static onLoadeddata(e) { e.target.layaTarget.event("loadeddata"); }
+	    static onLoadedmetadata(e) { e.target.layaTarget.event("loadedmetadata"); }
+	    static onLoadstart(e) { e.target.layaTarget.event("loadstart"); }
+	    static onPause(e) { e.target.layaTarget.event("pause"); }
+	    static onPlay(e) { e.target.layaTarget.event("play"); }
+	    static onPlaying(e) { e.target.layaTarget.event("playing"); }
+	    static onProgress(e) { e.target.layaTarget.event("progress"); }
+	    static onRatechange(e) { e.target.layaTarget.event("ratechange"); }
+	    static onSeeked(e) { e.target.layaTarget.event("seeked"); }
+	    static onSeeking(e) { e.target.layaTarget.event("seeking"); }
+	    static onStalled(e) { e.target.layaTarget.event("stalled"); }
+	    static onSuspend(e) { e.target.layaTarget.event("suspend"); }
+	    static onTimeupdate(e) { e.target.layaTarget.event("timeupdate"); }
+	    static onVolumechange(e) { e.target.layaTarget.event("volumechange"); }
+	    static onWaiting(e) { e.target.layaTarget.event("waiting"); }
+	    onPlayComplete(e) {
+	        if (!Laya.ILaya.Render.isConchApp || !this.videoElement || !this.videoElement.loop)
+	            Laya.ILaya.timer.clear(this, this.renderCanvas);
+	        this.event("ended");
+	    }
+	    load(url) {
+	        if (url.indexOf("blob:") == 0)
+	            this.videoElement.src = url;
+	        else
+	            this.htmlVideo.setSource(url, 1);
+	    }
+	    play() {
+	        this.videoElement.play();
+	        Laya.ILaya.timer.frameLoop(1, this, this.renderCanvas);
+	    }
+	    pause() {
+	        this.videoElement.pause();
+	        Laya.ILaya.timer.clear(this, this.renderCanvas);
+	    }
+	    reload() {
+	        this.videoElement.load();
+	    }
+	    canPlayType(type) {
+	        var typeString;
+	        switch (type) {
+	            case 1:
+	                typeString = "video/mp4";
+	                break;
+	            case 2:
+	                typeString = "video/ogg";
+	                break;
+	            case 8:
+	                typeString = "video/webm";
+	                break;
+	        }
+	        return this.videoElement.canPlayType(typeString);
+	    }
+	    renderCanvas() {
+	        if (this.readyState === 0)
+	            return;
+	        this.htmlVideo['updateTexture']();
+	        this.graphics.clear();
+	        this.graphics.drawTexture(this.internalTexture, 0, 0, this.width, this.height);
+	    }
+	    onDocumentClick() {
+	        this.videoElement.play();
+	        this.videoElement.pause();
+	        Laya.ILaya.Browser.document.removeEventListener("touchend", this.onDocumentClick);
+	    }
+	    get buffered() {
+	        return this.videoElement.buffered;
+	    }
+	    get currentSrc() {
+	        return this.videoElement.currentSrc;
+	    }
+	    get currentTime() {
+	        return this.videoElement.currentTime;
+	    }
+	    set currentTime(value) {
+	        this.videoElement.currentTime = value;
+	        this.renderCanvas();
+	    }
+	    set volume(value) {
+	        this.videoElement.volume = value;
+	    }
+	    get volume() {
+	        return this.videoElement.volume;
+	    }
+	    get readyState() {
+	        return this.videoElement.readyState;
+	    }
+	    get videoWidth() {
+	        return this.videoElement.videoWidth;
+	    }
+	    get videoHeight() {
+	        return this.videoElement.videoHeight;
+	    }
+	    get duration() {
+	        return this.videoElement.duration;
+	    }
+	    get ended() {
+	        return this.videoElement.ended;
+	    }
+	    get error() {
+	        return this.videoElement.error;
+	    }
+	    get loop() {
+	        return this.videoElement.loop;
+	    }
+	    set loop(value) {
+	        this.videoElement.loop = value;
+	    }
+	    set x(val) {
+	        super.x = val;
+	        if (Laya.ILaya.Render.isConchApp) {
+	            var transform = Laya.ILaya.Utils.getTransformRelativeToWindow(this, 0, 0);
+	            this.videoElement.style.left = transform.x;
+	        }
+	    }
+	    get x() {
+	        return super.x;
+	    }
+	    set y(val) {
+	        super.y = val;
+	        if (Laya.ILaya.Render.isConchApp) {
+	            var transform = Laya.ILaya.Utils.getTransformRelativeToWindow(this, 0, 0);
+	            this.videoElement.style.top = transform.y;
+	        }
+	    }
+	    get y() {
+	        return super.y;
+	    }
+	    get playbackRate() {
+	        return this.videoElement.playbackRate;
+	    }
+	    set playbackRate(value) {
+	        this.videoElement.playbackRate = value;
+	    }
+	    get muted() {
+	        return this.videoElement.muted;
+	    }
+	    set muted(value) {
+	        this.videoElement.muted = value;
+	    }
+	    get paused() {
+	        return this.videoElement.paused;
+	    }
+	    get preload() {
+	        return this.videoElement.preload;
+	    }
+	    set preload(value) {
+	        this.videoElement.preload = value;
+	    }
+	    get seekable() {
+	        return this.videoElement.seekable;
+	    }
+	    get seeking() {
+	        return this.videoElement.seeking;
+	    }
+	    size(width, height) {
+	        super.size(width, height);
+	        if (Laya.ILaya.Render.isConchApp) {
+	            var transform = Laya.ILaya.Utils.getTransformRelativeToWindow(this, 0, 0);
+	            this.videoElement.width = width * transform.scaleX;
+	        }
+	        else {
+	            this.videoElement.width = width / Laya.ILaya.Browser.pixelRatio;
+	        }
+	        if (this.paused)
+	            this.renderCanvas();
+	        return this;
+	    }
+	    set width(value) {
+	        if (Laya.ILaya.Render.isConchApp) {
+	            var transform = Laya.ILaya.Utils.getTransformRelativeToWindow(this, 0, 0);
+	            this.videoElement.width = value * transform.scaleX;
+	        }
+	        else {
+	            this.videoElement.width = this.width / Laya.ILaya.Browser.pixelRatio;
+	        }
+	        super.width = value;
+	        if (this.paused)
+	            this.renderCanvas();
+	    }
+	    get width() {
+	        return super.width;
+	    }
+	    set height(value) {
+	        if (Laya.ILaya.Render.isConchApp) {
+	            var transform = Laya.ILaya.Utils.getTransformRelativeToWindow(this, 0, 0);
+	            this.videoElement.height = value * transform.scaleY;
+	        }
+	        else {
+	            this.videoElement.height = this.height / Laya.ILaya.Browser.pixelRatio;
+	        }
+	        super.height = value;
+	    }
+	    get height() {
+	        return super.height;
+	    }
+	    destroy(detroyChildren = true) {
+	        super.destroy(detroyChildren);
+	        this.videoElement.removeEventListener("abort", Video.onAbort);
+	        this.videoElement.removeEventListener("canplay", Video.onCanplay);
+	        this.videoElement.removeEventListener("canplaythrough", Video.onCanplaythrough);
+	        this.videoElement.removeEventListener("durationchange", Video.onDurationchange);
+	        this.videoElement.removeEventListener("emptied", Video.onEmptied);
+	        this.videoElement.removeEventListener("error", Video.onError);
+	        this.videoElement.removeEventListener("loadeddata", Video.onLoadeddata);
+	        this.videoElement.removeEventListener("loadedmetadata", Video.onLoadedmetadata);
+	        this.videoElement.removeEventListener("loadstart", Video.onLoadstart);
+	        this.videoElement.removeEventListener("pause", Video.onPause);
+	        this.videoElement.removeEventListener("play", Video.onPlay);
+	        this.videoElement.removeEventListener("playing", Video.onPlaying);
+	        this.videoElement.removeEventListener("progress", Video.onProgress);
+	        this.videoElement.removeEventListener("ratechange", Video.onRatechange);
+	        this.videoElement.removeEventListener("seeked", Video.onSeeked);
+	        this.videoElement.removeEventListener("seeking", Video.onSeeking);
+	        this.videoElement.removeEventListener("stalled", Video.onStalled);
+	        this.videoElement.removeEventListener("suspend", Video.onSuspend);
+	        this.videoElement.removeEventListener("timeupdate", Video.onTimeupdate);
+	        this.videoElement.removeEventListener("volumechange", Video.onVolumechange);
+	        this.videoElement.removeEventListener("waiting", Video.onWaiting);
+	        this.videoElement.removeEventListener("ended", this.onPlayComplete);
+	        this.pause();
+	        this.videoElement.layaTarget = null;
+	        this.videoElement = null;
+	        this.htmlVideo.destroy();
+	    }
+	    syncVideoPosition() {
+	        var stage = Laya.ILaya.stage;
+	        var rec;
+	        rec = Laya.ILaya.Utils.getGlobalPosAndScale(this);
+	        var a = stage._canvasTransform.a, d = stage._canvasTransform.d;
+	        var x = rec.x * stage.clientScaleX * a + stage.offset.x;
+	        var y = rec.y * stage.clientScaleY * d + stage.offset.y;
+	        this.videoElement.style.left = x + 'px';
+	        this.videoElement.style.top = y + 'px';
+	        this.videoElement.width = this.width / Laya.ILaya.Browser.pixelRatio;
+	        this.videoElement.height = this.height / Laya.ILaya.Browser.pixelRatio;
+	    }
+	}
+	Video.MP4 = 1;
+	Video.OGG = 2;
+	Video.CAMERA = 4;
+	Video.WEBM = 8;
+	Video.SUPPORT_PROBABLY = "probably";
+	Video.SUPPORT_MAYBY = "maybe";
+	Video.SUPPORT_NO = "";
+
+	class Gyroscope extends Laya.EventDispatcher {
+	    constructor(singleton) {
+	        super();
+	        this.onDeviceOrientationChange = this.onDeviceOrientationChange.bind(this);
+	    }
+	    static get instance() {
+	        Gyroscope._instance = Gyroscope._instance || new Gyroscope(0);
+	        return Gyroscope._instance;
+	    }
+	    on(type, caller, listener, args = null) {
+	        super.on(type, caller, listener, args);
+	        Laya.ILaya.Browser.window.addEventListener('deviceorientation', this.onDeviceOrientationChange);
+	        return this;
+	    }
+	    off(type, caller, listener, onceOnly = false) {
+	        if (!this.hasListener(type))
+	            Laya.ILaya.Browser.window.removeEventListener('deviceorientation', this.onDeviceOrientationChange);
+	        return super.off(type, caller, listener, onceOnly);
+	    }
+	    onDeviceOrientationChange(e) {
+	        Gyroscope.info.alpha = e.alpha;
+	        Gyroscope.info.beta = e.beta;
+	        Gyroscope.info.gamma = e.gamma;
+	        if (e.webkitCompassHeading) {
+	            Gyroscope.info.alpha = e.webkitCompassHeading * -1;
+	            Gyroscope.info.compassAccuracy = e.webkitCompassAccuracy;
+	        }
+	        this.event(Laya.Event.CHANGE, [e.absolute, Gyroscope.info]);
+	    }
+	}
+	Gyroscope.info = new RotationInfo();
+
+	exports.AccelerationInfo = AccelerationInfo;
+	exports.Accelerator = Accelerator;
+	exports.Geolocation = Geolocation;
+	exports.GeolocationInfo = GeolocationInfo;
+	exports.Gyroscope = Gyroscope;
+	exports.HtmlVideo = HtmlVideo;
+	exports.Media = Media;
+	exports.RotationInfo = RotationInfo;
+	exports.Shake = Shake;
+	exports.Video = Video;
+	exports.WebGLVideo = WebGLVideo;
+
+}(window.Laya = window.Laya || {}, Laya));

+ 1543 - 0
ShootingSun/bin/libs/laya.html.js

@@ -0,0 +1,1543 @@
+(function (exports, Laya) {
+    'use strict';
+
+    class HTMLExtendStyle {
+        constructor() {
+            this.reset();
+        }
+        reset() {
+            this.stroke = 0;
+            this.strokeColor = "#000000";
+            this.leading = 0;
+            this.lineHeight = 0;
+            this.letterSpacing = 0;
+            this.href = null;
+            return this;
+        }
+        recover() {
+            if (this == HTMLExtendStyle.EMPTY)
+                return;
+            Laya.Pool.recover("HTMLExtendStyle", this.reset());
+        }
+        static create() {
+            return Laya.Pool.getItemByClass("HTMLExtendStyle", HTMLExtendStyle);
+        }
+    }
+    HTMLExtendStyle.EMPTY = new HTMLExtendStyle();
+    Laya.ClassUtils.regClass("laya.html.utils.HTMLExtendStyle", HTMLExtendStyle);
+    Laya.ClassUtils.regClass("Laya.HTMLExtendStyle", HTMLExtendStyle);
+
+    class HTMLStyle {
+        constructor() {
+            this.padding = HTMLStyle._PADDING;
+            this.reset();
+        }
+        _getExtendStyle() {
+            if (this._extendStyle === HTMLExtendStyle.EMPTY)
+                this._extendStyle = HTMLExtendStyle.create();
+            return this._extendStyle;
+        }
+        get href() {
+            return this._extendStyle.href;
+        }
+        set href(value) {
+            if (value === this._extendStyle.href)
+                return;
+            this._getExtendStyle().href = value;
+        }
+        get stroke() {
+            return this._extendStyle.stroke;
+        }
+        set stroke(value) {
+            if (this._extendStyle.stroke === value)
+                return;
+            this._getExtendStyle().stroke = value;
+        }
+        get strokeColor() {
+            return this._extendStyle.strokeColor;
+        }
+        set strokeColor(value) {
+            if (this._extendStyle.strokeColor === value)
+                return;
+            this._getExtendStyle().strokeColor = value;
+        }
+        get leading() {
+            return this._extendStyle.leading;
+        }
+        set leading(value) {
+            if (this._extendStyle.leading === value)
+                return;
+            this._getExtendStyle().leading = value;
+        }
+        get lineHeight() {
+            return this._extendStyle.lineHeight;
+        }
+        set lineHeight(value) {
+            if (this._extendStyle.lineHeight === value)
+                return;
+            this._getExtendStyle().lineHeight = value;
+        }
+        set align(v) {
+            if (!(v in HTMLStyle.alignVDic))
+                return;
+            this._type &= (~HTMLStyle._ALIGN);
+            this._type |= HTMLStyle.alignVDic[v];
+        }
+        get align() {
+            var v = this._type & HTMLStyle._ALIGN;
+            return HTMLStyle.align_Value[v];
+        }
+        set valign(v) {
+            if (!(v in HTMLStyle.alignVDic))
+                return;
+            this._type &= (~HTMLStyle._VALIGN);
+            this._type |= HTMLStyle.alignVDic[v];
+        }
+        get valign() {
+            var v = this._type & HTMLStyle._VALIGN;
+            return HTMLStyle.vAlign_Value[v];
+        }
+        set font(value) {
+            var strs = value.split(' ');
+            for (var i = 0, n = strs.length; i < n; i++) {
+                var str = strs[i];
+                switch (str) {
+                    case 'italic':
+                        this.italic = true;
+                        continue;
+                    case 'bold':
+                        this.bold = true;
+                        continue;
+                }
+                if (str.indexOf('px') > 0) {
+                    this.fontSize = parseInt(str);
+                    this.family = strs[i + 1];
+                    i++;
+                    continue;
+                }
+            }
+        }
+        get font() {
+            return (this.italic ? "italic " : "") + (this.bold ? "bold " : "") + this.fontSize + "px " + (Laya.ILaya.Browser.onIPhone ? (Laya.ILaya.Text.fontFamilyMap[this.family] || this.family) : this.family);
+        }
+        set block(value) {
+            value ? (this._type |= HTMLStyle._CSS_BLOCK) : (this._type &= (~HTMLStyle._CSS_BLOCK));
+        }
+        get block() {
+            return (this._type & HTMLStyle._CSS_BLOCK) != 0;
+        }
+        reset() {
+            this.ower = null;
+            this._type = 0;
+            this.wordWrap = true;
+            this.fontSize = Laya.ILaya.Text.defaultFontSize;
+            this.family = Laya.ILaya.Text.defaultFont;
+            this.color = "#000000";
+            this.valign = HTMLStyle.VALIGN_TOP;
+            this.padding = HTMLStyle._PADDING;
+            this.bold = false;
+            this.italic = false;
+            this.align = HTMLStyle.ALIGN_LEFT;
+            this.textDecoration = null;
+            this.bgColor = null;
+            this.borderColor = null;
+            if (this._extendStyle)
+                this._extendStyle.recover();
+            this._extendStyle = HTMLExtendStyle.EMPTY;
+            return this;
+        }
+        recover() {
+            Laya.Pool.recover("HTMLStyle", this.reset());
+        }
+        static create() {
+            return Laya.Pool.getItemByClass("HTMLStyle", HTMLStyle);
+        }
+        inherit(src) {
+            var i, len;
+            var props;
+            props = HTMLStyle._inheritProps;
+            len = props.length;
+            var key;
+            for (i = 0; i < len; i++) {
+                key = props[i];
+                this[key] = src[key];
+            }
+        }
+        get wordWrap() {
+            return (this._type & HTMLStyle._NOWARP) === 0;
+        }
+        set wordWrap(value) {
+            value ? (this._type &= ~HTMLStyle._NOWARP) : (this._type |= HTMLStyle._NOWARP);
+        }
+        get bold() {
+            return (this._type & HTMLStyle._BOLD) != 0;
+        }
+        set bold(value) {
+            value ? (this._type |= HTMLStyle._BOLD) : (this._type &= ~HTMLStyle._BOLD);
+        }
+        get italic() {
+            return (this._type & HTMLStyle._ITALIC) != 0;
+        }
+        set italic(value) {
+            value ? (this._type |= HTMLStyle._ITALIC) : (this._type &= ~HTMLStyle._ITALIC);
+        }
+        _widthAuto() {
+            return (this._type & HTMLStyle._WIDTHAUTO) !== 0;
+        }
+        widthed(sprite) {
+            return (this._type & HTMLStyle._WIDTH_SET) != 0;
+        }
+        set whiteSpace(type) {
+            type === "nowrap" && (this._type |= HTMLStyle._NOWARP);
+            type === "none" && (this._type &= ~HTMLStyle._NOWARP);
+        }
+        get whiteSpace() {
+            return (this._type & HTMLStyle._NOWARP) ? "nowrap" : "";
+        }
+        _calculation(type, value) {
+            return false;
+        }
+        set width(w) {
+            this._type |= HTMLStyle._WIDTH_SET;
+            if (typeof (w) == 'string') {
+                var offset = w.indexOf('auto');
+                if (offset >= 0) {
+                    this._type |= HTMLStyle._WIDTHAUTO;
+                    w = w.substr(0, offset);
+                }
+                if (this._calculation("width", w))
+                    return;
+                w = parseInt(w);
+            }
+            this.size(w, -1);
+        }
+        set height(h) {
+            this._type |= HTMLStyle._HEIGHT_SET;
+            if (typeof (h) == 'string') {
+                if (this._calculation("height", h))
+                    return;
+                h = parseInt(h);
+            }
+            this.size(-1, h);
+        }
+        heighted(sprite) {
+            return (this._type & HTMLStyle._HEIGHT_SET) != 0;
+        }
+        size(w, h) {
+            var ower = this.ower;
+            var resize = false;
+            if (w !== -1 && w != ower.width) {
+                this._type |= HTMLStyle._WIDTH_SET;
+                ower.width = w;
+                resize = true;
+            }
+            if (h !== -1 && h != ower.height) {
+                this._type |= HTMLStyle._HEIGHT_SET;
+                ower.height = h;
+                resize = true;
+            }
+            if (resize) {
+                ower._layoutLater();
+            }
+        }
+        getLineElement() {
+            return (this._type & HTMLStyle._LINE_ELEMENT) != 0;
+        }
+        setLineElement(value) {
+            value ? (this._type |= HTMLStyle._LINE_ELEMENT) : (this._type &= (~HTMLStyle._LINE_ELEMENT));
+        }
+        _enableLayout() {
+            return (this._type & HTMLStyle._DISPLAY_NONE) === 0 && (this._type & HTMLStyle._ABSOLUTE) === 0;
+        }
+        get letterSpacing() {
+            return this._extendStyle.letterSpacing;
+        }
+        set letterSpacing(d) {
+            (typeof (d) == 'string') && (d = parseInt(d + ""));
+            if (d == this._extendStyle.letterSpacing)
+                return;
+            this._getExtendStyle().letterSpacing = d;
+        }
+        cssText(text) {
+            this.attrs(HTMLStyle.parseOneCSS(text, ';'));
+        }
+        attrs(attrs) {
+            if (attrs) {
+                for (var i = 0, n = attrs.length; i < n; i++) {
+                    var attr = attrs[i];
+                    this[attr[0]] = attr[1];
+                }
+            }
+        }
+        set position(value) {
+            value === "absolute" ? (this._type |= HTMLStyle._ABSOLUTE) : (this._type &= ~HTMLStyle._ABSOLUTE);
+        }
+        get position() {
+            return (this._type & HTMLStyle._ABSOLUTE) ? "absolute" : "";
+        }
+        get absolute() {
+            return (this._type & HTMLStyle._ABSOLUTE) !== 0;
+        }
+        get paddingLeft() {
+            return this.padding[3];
+        }
+        get paddingTop() {
+            return this.padding[0];
+        }
+        static parseOneCSS(text, clipWord) {
+            var out = [];
+            var attrs = text.split(clipWord);
+            var valueArray;
+            for (var i = 0, n = attrs.length; i < n; i++) {
+                var attr = attrs[i];
+                var ofs = attr.indexOf(':');
+                var name = attr.substr(0, ofs).replace(/^\s+|\s+$/g, '');
+                if (name.length === 0)
+                    continue;
+                var value = attr.substr(ofs + 1).replace(/^\s+|\s+$/g, '');
+                var one = [name, value];
+                switch (name) {
+                    case 'italic':
+                    case 'bold':
+                        one[1] = value == "true";
+                        break;
+                    case "font-weight":
+                        if (value == "bold") {
+                            one[1] = true;
+                            one[0] = "bold";
+                        }
+                        break;
+                    case 'line-height':
+                        one[0] = 'lineHeight';
+                        one[1] = parseInt(value);
+                        break;
+                    case 'font-size':
+                        one[0] = 'fontSize';
+                        one[1] = parseInt(value);
+                        break;
+                    case 'stroke':
+                        one[0] = 'stroke';
+                        one[1] = parseInt(value);
+                        break;
+                    case 'padding':
+                        valueArray = value.split(' ');
+                        valueArray.length > 1 || (valueArray[1] = valueArray[2] = valueArray[3] = valueArray[0]);
+                        one[1] = [parseInt(valueArray[0]), parseInt(valueArray[1]), parseInt(valueArray[2]), parseInt(valueArray[3])];
+                        break;
+                    default:
+                        (one[0] = HTMLStyle._CSSTOVALUE[name]) || (one[0] = name);
+                }
+                out.push(one);
+            }
+            return out;
+        }
+        static parseCSS(text, uri) {
+            var one;
+            while ((one = HTMLStyle._parseCSSRegExp.exec(text)) != null) {
+                HTMLStyle.styleSheets[one[1]] = HTMLStyle.parseOneCSS(one[2], ';');
+            }
+        }
+    }
+    HTMLStyle._CSSTOVALUE = { 'letter-spacing': 'letterSpacing', 'white-space': 'whiteSpace', 'line-height': 'lineHeight', 'font-family': 'family', 'vertical-align': 'valign', 'text-decoration': 'textDecoration', 'background-color': 'bgColor', 'border-color': 'borderColor' };
+    HTMLStyle._parseCSSRegExp = new RegExp("([\.\#]\\w+)\\s*{([\\s\\S]*?)}", "g");
+    HTMLStyle._inheritProps = ["italic", "align", "valign", "leading", "stroke", "strokeColor", "bold", "fontSize", "lineHeight", "wordWrap", "color"];
+    HTMLStyle.ALIGN_LEFT = "left";
+    HTMLStyle.ALIGN_CENTER = "center";
+    HTMLStyle.ALIGN_RIGHT = "right";
+    HTMLStyle.VALIGN_TOP = "top";
+    HTMLStyle.VALIGN_MIDDLE = "middle";
+    HTMLStyle.VALIGN_BOTTOM = "bottom";
+    HTMLStyle.styleSheets = {};
+    HTMLStyle.ADDLAYOUTED = 0x200;
+    HTMLStyle._PADDING = [0, 0, 0, 0];
+    HTMLStyle._HEIGHT_SET = 0x2000;
+    HTMLStyle._LINE_ELEMENT = 0x10000;
+    HTMLStyle._NOWARP = 0x20000;
+    HTMLStyle._WIDTHAUTO = 0x40000;
+    HTMLStyle._BOLD = 0x400;
+    HTMLStyle._ITALIC = 0x800;
+    HTMLStyle._CSS_BLOCK = 0x1;
+    HTMLStyle._DISPLAY_NONE = 0x2;
+    HTMLStyle._ABSOLUTE = 0x4;
+    HTMLStyle._WIDTH_SET = 0x8;
+    HTMLStyle.alignVDic = { "left": 0, "center": 0x10, "right": 0x20, "top": 0, "middle": 0x40, "bottom": 0x80 };
+    HTMLStyle.align_Value = { 0: "left", 0x10: "center", 0x20: "right" };
+    HTMLStyle.vAlign_Value = { 0: "top", 0x40: "middle", 0x80: "bottom" };
+    HTMLStyle._ALIGN = 0x30;
+    HTMLStyle._VALIGN = 0xc0;
+    Laya.ClassUtils.regClass("laya.html.utils.HTMLStyle", HTMLStyle);
+    Laya.ClassUtils.regClass("Laya.HTMLStyle", HTMLStyle);
+
+    class HTMLDocument {
+        constructor() {
+            this.all = [];
+            this.styleSheets = HTMLStyle.styleSheets;
+        }
+        getElementById(id) {
+            return this.all[id];
+        }
+        setElementById(id, e) {
+            this.all[id] = e;
+        }
+    }
+    HTMLDocument.document = new HTMLDocument();
+    Laya.ClassUtils.regClass("laya.html.dom.HTMLDocument", HTMLDocument);
+    Laya.ClassUtils.regClass("Laya.HTMLDocument", HTMLDocument);
+
+    class HTMLHitRect {
+        constructor() {
+            this.rec = new Laya.Rectangle();
+            this.reset();
+        }
+        reset() {
+            this.rec.reset();
+            this.href = null;
+            return this;
+        }
+        recover() {
+            Laya.Pool.recover("HTMLHitRect", this.reset());
+        }
+        static create() {
+            return Laya.Pool.getItemByClass("HTMLHitRect", HTMLHitRect);
+        }
+    }
+    Laya.ClassUtils.regClass("laya.html.dom.HTMLHitRect", HTMLHitRect);
+    Laya.ClassUtils.regClass("Laya.HTMLHitRect", HTMLHitRect);
+
+    class IHtml {
+    }
+    IHtml.HTMLDivElement = null;
+    IHtml.HTMLImageElement = null;
+    IHtml.HTMLBrElement = null;
+    IHtml.HTMLDivParser = null;
+    IHtml.HTMLParse = null;
+    IHtml.HTMLElementType = null;
+
+    class LayoutLine {
+        constructor() {
+            this.elements = [];
+            this.x = 0;
+            this.y = 0;
+            this.w = 0;
+            this.h = 0;
+            this.wordStartIndex = 0;
+            this.minTextHeight = 99999;
+            this.mWidth = 0;
+        }
+        updatePos(left, width, lineNum, dy, align, valign, lineHeight) {
+            var w = 0;
+            var one;
+            if (this.elements.length > 0) {
+                one = this.elements[this.elements.length - 1];
+                w = one.x + one.width - this.elements[0].x;
+            }
+            lineHeight = lineHeight || this.h;
+            var dx = 0, ddy;
+            if (align === HTMLStyle.ALIGN_CENTER)
+                dx = (width - w) / 2;
+            if (align === HTMLStyle.ALIGN_RIGHT)
+                dx = (width - w);
+            for (var i = 0, n = this.elements.length; i < n; i++) {
+                one = this.elements[i];
+                var tCSSStyle = one._getCSSStyle();
+                dx !== 0 && (one.x += dx);
+                switch (tCSSStyle.valign) {
+                    case "top":
+                        one.y = dy;
+                        break;
+                    case "middle":
+                        var tMinTextHeight = 0;
+                        if (this.minTextHeight != 99999)
+                            tMinTextHeight = this.minTextHeight;
+                        var tBottomLineY = (tMinTextHeight + lineHeight) / 2;
+                        tBottomLineY = Math.max(tBottomLineY, this.h);
+                        if (one.eletype == IHtml.HTMLElementType.IMAGE)
+                            ddy = dy + tBottomLineY - one.height;
+                        else
+                            ddy = dy + tBottomLineY - one.height;
+                        one.y = ddy;
+                        break;
+                    case "bottom":
+                        one.y = dy + (lineHeight - one.height);
+                        break;
+                }
+            }
+        }
+    }
+    Laya.ClassUtils.regClass("laya.html.utils.LayoutLine", LayoutLine);
+    Laya.ClassUtils.regClass("Laya.LayoutLine", LayoutLine);
+
+    class Layout {
+        static later(element) {
+            if (Layout._will == null) {
+                Layout._will = [];
+                Laya.ILaya.stage.frameLoop(1, null, function () {
+                    if (Layout._will.length < 1)
+                        return;
+                    for (var i = 0; i < Layout._will.length; i++) {
+                        Layout.layout(Layout._will[i]);
+                    }
+                    Layout._will.length = 0;
+                });
+            }
+            Layout._will.push(element);
+        }
+        static layout(element) {
+            if (!element || !element._style)
+                return null;
+            var style = element._style;
+            if ((style._type & HTMLStyle.ADDLAYOUTED) === 0)
+                return null;
+            element.style._type &= ~HTMLStyle.ADDLAYOUTED;
+            var arr = Layout._multiLineLayout(element);
+            return arr;
+        }
+        static _multiLineLayout(element) {
+            var elements = [];
+            element._addChildsToLayout(elements);
+            var i, n = elements.length;
+            var style = element._getCSSStyle();
+            var letterSpacing = style.letterSpacing;
+            var leading = style.leading;
+            var lineHeight = style.lineHeight;
+            var widthAuto = style._widthAuto() || !style.wordWrap;
+            var width = widthAuto ? 999999 : element.width;
+            var height = element.height;
+            var maxWidth = 0;
+            var exWidth = style.italic ? style.fontSize / 3 : 0;
+            var align = style.align;
+            var valign = style.valign;
+            var endAdjust = valign !== HTMLStyle.VALIGN_TOP || align !== HTMLStyle.ALIGN_LEFT || lineHeight != 0;
+            var oneLayout;
+            var x = 0;
+            var y = 0;
+            var w = 0;
+            var h = 0;
+            var lines = [];
+            var curStyle;
+            var curPadding;
+            var curLine = lines[0] = new LayoutLine();
+            var newLine, nextNewline = false;
+            var htmlWord;
+            var sprite;
+            curLine.h = 0;
+            if (style.italic)
+                width -= style.fontSize / 3;
+            var tWordWidth = 0;
+            var tLineFirstKey = true;
+            function addLine() {
+                curLine.y = y;
+                y += curLine.h + leading;
+                curLine.mWidth = tWordWidth;
+                tWordWidth = 0;
+                curLine = new LayoutLine();
+                lines.push(curLine);
+                curLine.h = 0;
+                x = 0;
+                tLineFirstKey = true;
+                newLine = false;
+            }
+            for (i = 0; i < n; i++) {
+                oneLayout = elements[i];
+                if (oneLayout == null) {
+                    if (!tLineFirstKey) {
+                        x += Layout.DIV_ELEMENT_PADDING;
+                    }
+                    curLine.wordStartIndex = curLine.elements.length;
+                    continue;
+                }
+                tLineFirstKey = false;
+                if (oneLayout instanceof IHtml.HTMLBrElement) {
+                    addLine();
+                    curLine.y = y;
+                    curLine.h = lineHeight;
+                    continue;
+                }
+                else if (oneLayout._isChar()) {
+                    htmlWord = oneLayout;
+                    if (!htmlWord.isWord) {
+                        if (lines.length > 0 && (x + w) > width && curLine.wordStartIndex > 0) {
+                            var tLineWord = 0;
+                            tLineWord = curLine.elements.length - curLine.wordStartIndex + 1;
+                            curLine.elements.length = curLine.wordStartIndex;
+                            i -= tLineWord;
+                            addLine();
+                            continue;
+                        }
+                        newLine = false;
+                        tWordWidth += htmlWord.width;
+                    }
+                    else {
+                        newLine = nextNewline || (htmlWord.char === '\n');
+                        curLine.wordStartIndex = curLine.elements.length;
+                    }
+                    w = htmlWord.width + htmlWord.style.letterSpacing;
+                    h = htmlWord.height;
+                    nextNewline = false;
+                    newLine = newLine || ((x + w) > width);
+                    newLine && addLine();
+                    curLine.minTextHeight = Math.min(curLine.minTextHeight, oneLayout.height);
+                }
+                else {
+                    curStyle = oneLayout._getCSSStyle();
+                    sprite = oneLayout;
+                    curPadding = curStyle.padding;
+                    newLine = nextNewline || curStyle.getLineElement();
+                    w = sprite.width + curPadding[1] + curPadding[3] + curStyle.letterSpacing;
+                    h = sprite.height + curPadding[0] + curPadding[2];
+                    nextNewline = curStyle.getLineElement();
+                    newLine = newLine || ((x + w) > width && curStyle.wordWrap);
+                    newLine && addLine();
+                }
+                curLine.elements.push(oneLayout);
+                curLine.h = Math.max(curLine.h, h);
+                oneLayout.x = x;
+                oneLayout.y = y;
+                x += w;
+                curLine.w = x - letterSpacing;
+                curLine.y = y;
+                maxWidth = Math.max(x + exWidth, maxWidth);
+            }
+            y = curLine.y + curLine.h;
+            if (endAdjust) {
+                var tY = 0;
+                var tWidth = width;
+                if (widthAuto && element.width > 0) {
+                    tWidth = element.width;
+                }
+                for (i = 0, n = lines.length; i < n; i++) {
+                    lines[i].updatePos(0, tWidth, i, tY, align, valign, lineHeight);
+                    tY += Math.max(lineHeight, lines[i].h + leading);
+                }
+                y = tY;
+            }
+            widthAuto && (element.width = maxWidth);
+            (y > element.height) && (element.height = y);
+            return [maxWidth, y];
+        }
+    }
+    Layout.DIV_ELEMENT_PADDING = 0;
+    Laya.ClassUtils.regClass("laya.html.utils.Layout", Layout);
+    Laya.ClassUtils.regClass("Laya.Layout", Layout);
+
+    (function (HTMLElementType) {
+        HTMLElementType[HTMLElementType["BASE"] = 0] = "BASE";
+        HTMLElementType[HTMLElementType["IMAGE"] = 1] = "IMAGE";
+    })(exports.HTMLElementType || (exports.HTMLElementType = {}));
+    class HTMLElement {
+        constructor() {
+            this.eletype = exports.HTMLElementType.BASE;
+            this._creates();
+            this.reset();
+        }
+        static formatURL1(url, basePath = null) {
+            if (!url)
+                return "null path";
+            if (!basePath)
+                basePath = Laya.URL.basePath;
+            if (url.indexOf(":") > 0)
+                return url;
+            if (Laya.URL.customFormat != null)
+                url = Laya.URL.customFormat(url);
+            if (url.indexOf(":") > 0)
+                return url;
+            var char1 = url.charAt(0);
+            if (char1 === ".") {
+                return Laya.URL._formatRelativePath(basePath + url);
+            }
+            else if (char1 === '~') {
+                return Laya.URL.rootPath + url.substring(1);
+            }
+            else if (char1 === "d") {
+                if (url.indexOf("data:image") === 0)
+                    return url;
+            }
+            else if (char1 === "/") {
+                return url;
+            }
+            return basePath + url;
+        }
+        _creates() {
+            this._style = HTMLStyle.create();
+        }
+        reset() {
+            this.URI = null;
+            this.parent = null;
+            this._style.reset();
+            this._style.ower = this;
+            this._style.valign = "middle";
+            if (this._text && this._text.words) {
+                var words = this._text.words;
+                var i, len;
+                len = words.length;
+                var tChar;
+                for (i = 0; i < len; i++) {
+                    tChar = words[i];
+                    if (tChar)
+                        tChar.recover();
+                }
+            }
+            this._text = HTMLElement._EMPTYTEXT;
+            if (this._children)
+                this._children.length = 0;
+            this._x = this._y = this._width = this._height = 0;
+            return this;
+        }
+        _getCSSStyle() {
+            return this._style;
+        }
+        _addChildsToLayout(out) {
+            var words = this._getWords();
+            if (words == null && (!this._children || this._children.length == 0))
+                return false;
+            if (words) {
+                for (var i = 0, n = words.length; i < n; i++) {
+                    out.push(words[i]);
+                }
+            }
+            if (this._children)
+                this._children.forEach(function (o, index, array) {
+                    var _style = o._style;
+                    _style._enableLayout && _style._enableLayout() && o._addToLayout(out);
+                });
+            return true;
+        }
+        _addToLayout(out) {
+            if (!this._style)
+                return;
+            var style = this._style;
+            if (style.absolute)
+                return;
+            style.block ? out.push(this) : (this._addChildsToLayout(out) && (this.x = this.y = 0));
+        }
+        set id(value) {
+            HTMLDocument.document.setElementById(value, this);
+        }
+        repaint(recreate = false) {
+            this.parentRepaint(recreate);
+        }
+        parentRepaint(recreate = false) {
+            if (this.parent)
+                this.parent.repaint(recreate);
+        }
+        set innerTEXT(value) {
+            if (this._text === HTMLElement._EMPTYTEXT) {
+                this._text = { text: value, words: null };
+            }
+            else {
+                this._text.text = value;
+                this._text.words && (this._text.words.length = 0);
+            }
+            this.repaint();
+        }
+        get innerTEXT() {
+            return this._text.text;
+        }
+        _setParent(value) {
+            if (value instanceof HTMLElement) {
+                var p = value;
+                this.URI || (this.URI = p.URI);
+                if (this.style)
+                    this.style.inherit(p.style);
+            }
+        }
+        appendChild(c) {
+            return this.addChild(c);
+        }
+        addChild(c) {
+            if (c.parent)
+                c.parent.removeChild(c);
+            if (!this._children)
+                this._children = [];
+            this._children.push(c);
+            c.parent = this;
+            c._setParent(this);
+            this.repaint();
+            return c;
+        }
+        removeChild(c) {
+            if (!this._children)
+                return null;
+            var i, len;
+            len = this._children.length;
+            for (i = 0; i < len; i++) {
+                if (this._children[i] == c) {
+                    this._children.splice(i, 1);
+                    return c;
+                }
+            }
+            return null;
+        }
+        static getClassName(tar) {
+            if (tar instanceof Function)
+                return tar.name;
+            return tar["constructor"].name;
+        }
+        destroy() {
+            if (this._children) {
+                this.destroyChildren();
+                this._children.length = 0;
+            }
+            Laya.Pool.recover(HTMLElement.getClassName(this), this.reset());
+        }
+        destroyChildren() {
+            if (this._children) {
+                for (var i = this._children.length - 1; i > -1; i--) {
+                    this._children[i].destroy();
+                }
+                this._children.length = 0;
+            }
+        }
+        get style() {
+            return this._style;
+        }
+        _getWords() {
+            if (!this._text)
+                return null;
+            var txt = this._text.text;
+            if (!txt || txt.length === 0)
+                return null;
+            var words = this._text.words;
+            if (words && words.length === txt.length)
+                return words;
+            words === null && (this._text.words = words = []);
+            words.length = txt.length;
+            var size;
+            var style = this.style;
+            var fontStr = style.font;
+            for (var i = 0, n = txt.length; i < n; i++) {
+                size = Laya.ILaya.Browser.measureText(txt.charAt(i), fontStr);
+                words[i] = Laya.HTMLChar.create().setData(txt.charAt(i), size.width, size.height || style.fontSize, style);
+            }
+            return words;
+        }
+        _isChar() {
+            return false;
+        }
+        _layoutLater() {
+            var style = this.style;
+            if ((style._type & HTMLStyle.ADDLAYOUTED))
+                return;
+            if (style.widthed(this) && ((this._children && this._children.length > 0) || this._getWords() != null) && style.block) {
+                Layout.later(this);
+                style._type |= HTMLStyle.ADDLAYOUTED;
+            }
+            else {
+                this.parent && this.parent._layoutLater();
+            }
+        }
+        set x(v) {
+            if (this._x != v) {
+                this._x = v;
+                this.parentRepaint();
+            }
+        }
+        get x() {
+            return this._x;
+        }
+        set y(v) {
+            if (this._y != v) {
+                this._y = v;
+                this.parentRepaint();
+            }
+        }
+        get y() {
+            return this._y;
+        }
+        get width() {
+            return this._width;
+        }
+        set width(value) {
+            if (this._width !== value) {
+                this._width = value;
+                this.repaint();
+            }
+        }
+        get height() {
+            return this._height;
+        }
+        set height(value) {
+            if (this._height !== value) {
+                this._height = value;
+                this.repaint();
+            }
+        }
+        _setAttributes(name, value) {
+            switch (name) {
+                case 'style':
+                    this.style.cssText(value);
+                    break;
+                case 'class':
+                    this.className = value;
+                    break;
+                case 'x':
+                    this.x = parseFloat(value);
+                    break;
+                case 'y':
+                    this.y = parseFloat(value);
+                    break;
+                case 'width':
+                    this.width = parseFloat(value);
+                    break;
+                case 'height':
+                    this.height = parseFloat(value);
+                    break;
+                default:
+                    this[name] = value;
+            }
+        }
+        set href(url) {
+            if (!this._style)
+                return;
+            if (url != this._style.href) {
+                this._style.href = url;
+                this.repaint();
+            }
+        }
+        get href() {
+            if (!this._style)
+                return null;
+            return this._style.href;
+        }
+        formatURL(url) {
+            if (!this.URI)
+                return url;
+            return HTMLElement.formatURL1(url, this.URI ? this.URI.path : null);
+        }
+        set color(value) {
+            this.style.color = value;
+        }
+        set className(value) {
+            this.style.attrs(HTMLDocument.document.styleSheets['.' + value]);
+        }
+        drawToGraphic(graphic, gX, gY, recList) {
+            gX += this.x;
+            gY += this.y;
+            var cssStyle = this.style;
+            if (cssStyle.paddingLeft) {
+                gX += cssStyle.paddingLeft;
+            }
+            if (cssStyle.paddingTop) {
+                gY += cssStyle.paddingTop;
+            }
+            if (cssStyle.bgColor != null || cssStyle.borderColor) {
+                graphic.drawRect(gX, gY, this.width, this.height, cssStyle.bgColor, cssStyle.borderColor, 1);
+            }
+            this.renderSelfToGraphic(graphic, gX, gY, recList);
+            var i, len;
+            var tChild;
+            if (this._children && this._children.length > 0) {
+                len = this._children.length;
+                for (i = 0; i < len; i++) {
+                    tChild = this._children[i];
+                    if (tChild.drawToGraphic != null)
+                        tChild.drawToGraphic(graphic, gX, gY, recList);
+                }
+            }
+        }
+        renderSelfToGraphic(graphic, gX, gY, recList) {
+            var cssStyle = this.style;
+            var words = this._getWords();
+            var len;
+            if (words) {
+                len = words.length;
+                if (cssStyle) {
+                    var font = cssStyle.font;
+                    var color = cssStyle.color;
+                    if (cssStyle.stroke) {
+                        var stroke = cssStyle.stroke;
+                        stroke = parseInt(stroke);
+                        var strokeColor = cssStyle.strokeColor;
+                        graphic.fillBorderWords(words, gX, gY, font, color, strokeColor, stroke);
+                    }
+                    else {
+                        graphic.fillWords(words, gX, gY, font, color);
+                    }
+                    if (this.href) {
+                        var lastIndex = words.length - 1;
+                        var lastWords = words[lastIndex];
+                        var lineY = lastWords.y + lastWords.height;
+                        if (lastWords.y == words[0].y) {
+                            if (cssStyle.textDecoration != "none")
+                                graphic.drawLine(words[0].x, lineY, lastWords.x + lastWords.width, lineY, color, 1);
+                            var hitRec = HTMLHitRect.create();
+                            hitRec.rec.setTo(words[0].x, lastWords.y, lastWords.x + lastWords.width - words[0].x, lastWords.height);
+                            hitRec.href = this.href;
+                            recList.push(hitRec);
+                        }
+                        else {
+                            this.workLines(words, graphic, recList);
+                        }
+                    }
+                }
+            }
+        }
+        workLines(wordList, g, recList) {
+            var cssStyle = this.style;
+            var hasLine;
+            hasLine = cssStyle.textDecoration != "none";
+            var i, len;
+            len = wordList.length;
+            var tStartWord;
+            tStartWord = wordList[i];
+            var tEndWord;
+            tEndWord = tStartWord;
+            if (!tStartWord)
+                return;
+            var tword;
+            for (i = 1; i < len; i++) {
+                tword = wordList[i];
+                if (tword.y != tStartWord.y) {
+                    this.createOneLine(tStartWord, tEndWord, hasLine, g, recList);
+                    tStartWord = tword;
+                    tEndWord = tword;
+                }
+                else {
+                    tEndWord = tword;
+                }
+            }
+            this.createOneLine(tStartWord, tEndWord, hasLine, g, recList);
+        }
+        createOneLine(startWord, lastWords, hasLine, graphic, recList) {
+            var lineY = lastWords.y + lastWords.height;
+            if (hasLine)
+                graphic.drawLine(startWord.x, lineY, lastWords.x + lastWords.width, lineY, this.style.color, 1);
+            var hitRec = HTMLHitRect.create();
+            hitRec.rec.setTo(startWord.x, lastWords.y, lastWords.x + lastWords.width - startWord.x, lastWords.height);
+            hitRec.href = this.href;
+            recList.push(hitRec);
+        }
+    }
+    HTMLElement._EMPTYTEXT = { text: null, words: null };
+    Laya.ILaya.regClass(HTMLElement);
+    IHtml.HTMLElementType = exports.HTMLElementType;
+    Laya.ClassUtils.regClass("laya.html.dom.HTMLElement", HTMLElement);
+    Laya.ClassUtils.regClass("Laya.HTMLElement", HTMLElement);
+
+    class HTMLBrElement {
+        _addToLayout(out) {
+            out.push(this);
+        }
+        reset() {
+            return this;
+        }
+        destroy() {
+            Laya.Pool.recover(HTMLElement.getClassName(this), this.reset());
+        }
+        _setParent(value) {
+        }
+        set parent(value) {
+        }
+        set URI(value) {
+        }
+        set href(value) {
+        }
+        _getCSSStyle() {
+            if (!HTMLBrElement.brStyle) {
+                HTMLBrElement.brStyle = new HTMLStyle();
+                HTMLBrElement.brStyle.setLineElement(true);
+                HTMLBrElement.brStyle.block = true;
+            }
+            return HTMLBrElement.brStyle;
+        }
+        renderSelfToGraphic(graphic, gX, gY, recList) {
+        }
+    }
+    IHtml.HTMLBrElement = HTMLBrElement;
+    Laya.ILaya.regClass(HTMLBrElement);
+    Laya.ClassUtils.regClass("laya.html.dom.HTMLBrElement", HTMLBrElement);
+    Laya.ClassUtils.regClass("Laya.HTMLBrElement", HTMLBrElement);
+
+    class HTMLStyleElement extends HTMLElement {
+        _creates() {
+        }
+        drawToGraphic(graphic, gX, gY, recList) {
+        }
+        reset() {
+            return this;
+        }
+        set innerTEXT(value) {
+            HTMLStyle.parseCSS(value, null);
+        }
+        get innerTEXT() {
+            return super.innerTEXT;
+        }
+    }
+    Laya.ILaya.regClass(HTMLStyleElement);
+    Laya.ClassUtils.regClass("laya.html.dom.HTMLStyleElement", HTMLStyleElement);
+    Laya.ClassUtils.regClass("Laya.HTMLStyleElement", HTMLStyleElement);
+
+    class HTMLLinkElement extends HTMLElement {
+        _creates() {
+        }
+        drawToGraphic(graphic, gX, gY, recList) {
+        }
+        reset() {
+            if (this._loader)
+                this._loader.off(Laya.Event.COMPLETE, this, this._onload);
+            this._loader = null;
+            return this;
+        }
+        _onload(data) {
+            if (this._loader)
+                this._loader = null;
+            switch (this.type) {
+                case 'text/css':
+                    HTMLStyle.parseCSS(data, this.URI);
+                    break;
+            }
+            this.repaint(true);
+        }
+        set href(url) {
+            if (!url)
+                return;
+            url = this.formatURL(url);
+            this.URI = new Laya.URL(url);
+            if (this._loader)
+                this._loader.off(Laya.Event.COMPLETE, this, this._onload);
+            if (Laya.Loader.getRes(url)) {
+                if (this.type == "text/css") {
+                    HTMLStyle.parseCSS(Laya.Loader.getRes(url), this.URI);
+                }
+                return;
+            }
+            this._loader = new Laya.Loader();
+            this._loader.once(Laya.Event.COMPLETE, this, this._onload);
+            this._loader.load(url, Laya.Loader.TEXT);
+        }
+        get href() {
+            return super.href;
+        }
+    }
+    HTMLLinkElement._cuttingStyle = new RegExp("((@keyframes[\\s\\t]+|)(.+))[\\t\\n\\r\\\s]*{", "g");
+    Laya.ILaya.regClass(HTMLLinkElement);
+    Laya.ClassUtils.regClass("laya.html.dom.HTMLLinkElement", HTMLLinkElement);
+    Laya.ClassUtils.regClass("Laya.HTMLLinkElement", HTMLLinkElement);
+
+    class HTMLDivParser extends HTMLElement {
+        constructor() {
+            super(...arguments);
+            this.repaintHandler = null;
+        }
+        reset() {
+            super.reset();
+            this._style.block = true;
+            this._style.setLineElement(true);
+            this._style.width = 200;
+            this._style.height = 200;
+            this.repaintHandler = null;
+            this.contextHeight = 0;
+            this.contextWidth = 0;
+            return this;
+        }
+        set innerHTML(text) {
+            this.destroyChildren();
+            this.appendHTML(text);
+        }
+        set width(value) {
+            var changed;
+            if (value === 0) {
+                changed = value != this._width;
+            }
+            else {
+                changed = value != this.width;
+            }
+            super.width = value;
+            if (changed)
+                this.layout();
+        }
+        appendHTML(text) {
+            IHtml.HTMLParse.parse(this, text, this.URI);
+            this.layout();
+        }
+        _addChildsToLayout(out) {
+            var words = this._getWords();
+            if (words == null && (!this._children || this._children.length == 0))
+                return false;
+            words && words.forEach(function (o) {
+                out.push(o);
+            });
+            var tFirstKey = true;
+            for (var i = 0, len = this._children.length; i < len; i++) {
+                var o = this._children[i];
+                if (tFirstKey) {
+                    tFirstKey = false;
+                }
+                else {
+                    out.push(null);
+                }
+                o._addToLayout(out);
+            }
+            return true;
+        }
+        _addToLayout(out) {
+            this.layout();
+            !this.style.absolute && out.push(this);
+        }
+        getBounds() {
+            if (!this._htmlBounds)
+                return null;
+            if (!this._boundsRec)
+                this._boundsRec = Laya.Rectangle.create();
+            return this._boundsRec.copyFrom(this._htmlBounds);
+        }
+        parentRepaint(recreate = false) {
+            super.parentRepaint();
+            if (this.repaintHandler)
+                this.repaintHandler.runWith(recreate);
+        }
+        layout() {
+            this.style._type |= HTMLStyle.ADDLAYOUTED;
+            var tArray = Layout.layout(this);
+            if (tArray) {
+                if (!this._htmlBounds)
+                    this._htmlBounds = Laya.Rectangle.create();
+                var tRectangle = this._htmlBounds;
+                tRectangle.x = tRectangle.y = 0;
+                tRectangle.width = this.contextWidth = tArray[0];
+                tRectangle.height = this.contextHeight = tArray[1];
+            }
+        }
+        get height() {
+            if (this._height)
+                return this._height;
+            return this.contextHeight;
+        }
+        set height(value) {
+            super.height = value;
+        }
+        get width() {
+            if (this._width)
+                return this._width;
+            return this.contextWidth;
+        }
+    }
+    IHtml.HTMLDivParser = HTMLDivParser;
+    Laya.ILaya.regClass(HTMLDivParser);
+    Laya.ClassUtils.regClass("laya.html.dom.HTMLDivParser", HTMLDivParser);
+    Laya.ClassUtils.regClass("Laya.HTMLDivParser", HTMLDivParser);
+
+    class HTMLImageElement extends HTMLElement {
+        constructor() {
+            super();
+            this.eletype = exports.HTMLElementType.IMAGE;
+        }
+        reset() {
+            super.reset();
+            if (this._tex) {
+                this._tex.off(Laya.Event.LOADED, this, this.onloaded);
+            }
+            this._tex = null;
+            this._url = null;
+            return this;
+        }
+        set src(url) {
+            url = this.formatURL(url);
+            if (this._url === url)
+                return;
+            this._url = url;
+            var tex = this._tex = Laya.Loader.getRes(url);
+            if (!tex) {
+                this._tex = tex = new Laya.Texture();
+                tex.load(url);
+                Laya.Loader.cacheTexture(url, tex);
+            }
+            tex.getIsReady() ? this.onloaded() : tex.once(Laya.Event.READY, this, this.onloaded);
+        }
+        onloaded() {
+            if (!this._style)
+                return;
+            var style = this._style;
+            var w = style.widthed(this) ? -1 : this._tex.width;
+            var h = style.heighted(this) ? -1 : this._tex.height;
+            if (!style.widthed(this) && this._width != this._tex.width) {
+                this.width = this._tex.width;
+                this.parent && this.parent._layoutLater();
+            }
+            if (!style.heighted(this) && this._height != this._tex.height) {
+                this.height = this._tex.height;
+                this.parent && this.parent._layoutLater();
+            }
+            this.repaint();
+        }
+        _addToLayout(out) {
+            var style = this._style;
+            !style.absolute && out.push(this);
+        }
+        renderSelfToGraphic(graphic, gX, gY, recList) {
+            if (!this._tex)
+                return;
+            graphic.drawImage(this._tex, gX, gY, this.width || this._tex.width, this.height || this._tex.height);
+        }
+    }
+    IHtml.HTMLImageElement = HTMLImageElement;
+    Laya.ILaya.regClass(HTMLImageElement);
+    Laya.ClassUtils.regClass("laya.html.dom.HTMLImageElement", HTMLImageElement);
+    Laya.ClassUtils.regClass("Laya.HTMLImageElement", HTMLImageElement);
+
+    class HTMLParse {
+        static getInstance(type) {
+            var rst = Laya.Pool.getItem(HTMLParse._htmlClassMapShort[type]);
+            if (!rst) {
+                rst = Laya.ClassUtils.getInstance(type);
+            }
+            return rst;
+        }
+        static parse(ower, xmlString, url) {
+            xmlString = xmlString.replace(/<br>/g, "<br/>");
+            xmlString = "<root>" + xmlString + "</root>";
+            xmlString = xmlString.replace(HTMLParse.spacePattern, HTMLParse.char255);
+            var xml = Laya.Utils.parseXMLFromString(xmlString);
+            HTMLParse._parseXML(ower, xml.childNodes[0].childNodes, url);
+        }
+        static _parseXML(parent, xml, url, href = null) {
+            var i, n;
+            if (xml.join || xml.item) {
+                for (i = 0, n = xml.length; i < n; ++i) {
+                    HTMLParse._parseXML(parent, xml[i], url, href);
+                }
+            }
+            else {
+                var node;
+                var nodeName;
+                if (xml.nodeType == 3) {
+                    var txt;
+                    if (parent instanceof IHtml.HTMLDivParser) {
+                        if (xml.nodeName == null) {
+                            xml.nodeName = "#text";
+                        }
+                        nodeName = xml.nodeName.toLowerCase();
+                        txt = xml.textContent.replace(/^\s+|\s+$/g, '');
+                        if (txt.length > 0) {
+                            node = HTMLParse.getInstance(nodeName);
+                            if (node) {
+                                parent.addChild(node);
+                                (node.innerTEXT = txt.replace(HTMLParse.char255AndOneSpacePattern, " "));
+                            }
+                        }
+                    }
+                    else {
+                        txt = xml.textContent.replace(/^\s+|\s+$/g, '');
+                        if (txt.length > 0) {
+                            var containNode = parent;
+                            if (parent instanceof HTMLElement && parent.innerTEXT && parent.innerTEXT.length > 0) {
+                                let cnode = HTMLParse.getInstance('p');
+                                if (cnode) {
+                                    parent.addChild(cnode);
+                                    containNode = cnode;
+                                }
+                            }
+                            containNode.innerTEXT = txt.replace(HTMLParse.char255AndOneSpacePattern, " ");
+                        }
+                    }
+                    return;
+                }
+                else {
+                    nodeName = xml.nodeName.toLowerCase();
+                    if (nodeName == "#comment")
+                        return;
+                    node = HTMLParse.getInstance(nodeName);
+                    if (node) {
+                        if (nodeName == "p") {
+                            parent.addChild(HTMLParse.getInstance("br"));
+                            node = parent.addChild(node);
+                            parent.addChild(HTMLParse.getInstance("br"));
+                        }
+                        else {
+                            node = parent.addChild(node);
+                        }
+                        node.URI = url;
+                        node.href = href;
+                        var attributes = xml.attributes;
+                        if (attributes && attributes.length > 0) {
+                            for (i = 0, n = attributes.length; i < n; ++i) {
+                                var attribute = attributes[i];
+                                var attrName = attribute.nodeName;
+                                var value = attribute.value;
+                                node._setAttributes(attrName, value);
+                            }
+                        }
+                        HTMLParse._parseXML(node, xml.childNodes, url, node.href);
+                    }
+                    else {
+                        HTMLParse._parseXML(parent, xml.childNodes, url, href);
+                    }
+                }
+            }
+        }
+    }
+    HTMLParse.char255 = String.fromCharCode(255);
+    HTMLParse.spacePattern = /&nbsp;|&#160;/g;
+    HTMLParse.char255AndOneSpacePattern = new RegExp(String.fromCharCode(255) + "|(\\s+)", "g");
+    HTMLParse._htmlClassMapShort = {
+        'div': HTMLDivParser,
+        'p': HTMLElement,
+        'img': HTMLImageElement,
+        'span': HTMLElement,
+        'br': HTMLBrElement,
+        'style': HTMLStyleElement,
+        'font': HTMLElement,
+        'a': HTMLElement,
+        '#text': HTMLElement,
+        'link': HTMLLinkElement
+    };
+    IHtml.HTMLParse = HTMLParse;
+    Laya.ClassUtils.regClass('div', HTMLDivParser);
+    Laya.ClassUtils.regClass('p', HTMLElement);
+    Laya.ClassUtils.regClass('img', HTMLImageElement);
+    Laya.ClassUtils.regClass('span', HTMLElement);
+    Laya.ClassUtils.regClass('br', HTMLBrElement);
+    Laya.ClassUtils.regClass('style', HTMLStyleElement);
+    Laya.ClassUtils.regClass('font', HTMLElement);
+    Laya.ClassUtils.regClass('a', HTMLElement);
+    Laya.ClassUtils.regClass('#text', HTMLElement);
+    Laya.ClassUtils.regClass('link', HTMLLinkElement);
+    Laya.ClassUtils.regClass("laya.html.utils.HTMLParse", HTMLParse);
+    Laya.ClassUtils.regClass("Laya.HTMLParse", HTMLParse);
+
+    class HTMLDivElement extends Laya.Sprite {
+        constructor() {
+            super();
+            this._recList = [];
+            this._repaintState = 0;
+            this._element = new HTMLDivParser();
+            this._element.repaintHandler = new Laya.Handler(this, this._htmlDivRepaint);
+            this.mouseEnabled = true;
+            this.on(Laya.Event.CLICK, this, this._onMouseClick);
+        }
+        destroy(destroyChild = true) {
+            if (this._element)
+                this._element.reset();
+            this._element = null;
+            this._doClears();
+            super.destroy(destroyChild);
+        }
+        _htmlDivRepaint(recreate = false) {
+            if (recreate) {
+                if (this._repaintState < 2)
+                    this._repaintState = 2;
+            }
+            else {
+                if (this._repaintState < 1)
+                    this._repaintState = 1;
+            }
+            if (this._repaintState > 0)
+                this._setGraphicDirty();
+        }
+        _updateGraphicWork() {
+            switch (this._repaintState) {
+                case 1:
+                    this._updateGraphic();
+                    break;
+                case 2:
+                    this._refresh();
+                    break;
+            }
+        }
+        _setGraphicDirty() {
+            this.callLater(this._updateGraphicWork);
+        }
+        _doClears() {
+            if (!this._recList)
+                return;
+            var i, len = this._recList.length;
+            var tRec;
+            for (i = 0; i < len; i++) {
+                tRec = this._recList[i];
+                tRec.recover();
+            }
+            this._recList.length = 0;
+        }
+        _updateGraphic() {
+            this._doClears();
+            this.graphics.clear(true);
+            this._repaintState = 0;
+            this._element.drawToGraphic(this.graphics, -this._element.x, -this._element.y, this._recList);
+            var bounds = this._element.getBounds();
+            if (bounds)
+                this.setSelfBounds(bounds);
+            this.size(bounds.width, bounds.height);
+        }
+        get style() {
+            return this._element.style;
+        }
+        set innerHTML(text) {
+            if (this._innerHTML == text)
+                return;
+            this._repaintState = 1;
+            this._innerHTML = text;
+            this._element.innerHTML = text;
+            this._setGraphicDirty();
+        }
+        _refresh() {
+            this._repaintState = 1;
+            if (this._innerHTML)
+                this._element.innerHTML = this._innerHTML;
+            this._setGraphicDirty();
+        }
+        get contextWidth() {
+            return this._element.contextWidth;
+        }
+        get contextHeight() {
+            return this._element.contextHeight;
+        }
+        _onMouseClick() {
+            var tX = this.mouseX;
+            var tY = this.mouseY;
+            var i, len;
+            var tHit;
+            len = this._recList.length;
+            for (i = 0; i < len; i++) {
+                tHit = this._recList[i];
+                if (tHit.rec.contains(tX, tY)) {
+                    this._eventLink(tHit.href);
+                }
+            }
+        }
+        _eventLink(href) {
+            this.event(Laya.Event.LINK, [href]);
+        }
+    }
+    IHtml.HTMLDivElement = HTMLDivElement;
+    IHtml.HTMLParse = HTMLParse;
+    Laya.ClassUtils.regClass("laya.html.dom.HTMLDivElement", HTMLDivElement);
+    Laya.ClassUtils.regClass("Laya.HTMLDivElement", HTMLDivElement);
+
+    class HTMLIframeElement extends HTMLDivElement {
+        constructor() {
+            super();
+            this._element._getCSSStyle().valign = "middle";
+        }
+        set href(url) {
+            url = this._element.formatURL(url);
+            var l = new Laya.Loader();
+            l.once(Laya.Event.COMPLETE, null, (data) => {
+                var pre = this._element.URI;
+                this._element.URI = new Laya.URL(url);
+                this.innerHTML = data;
+                !pre || (this._element.URI = pre);
+            });
+            l.load(url, Laya.Loader.TEXT);
+        }
+    }
+    Laya.ClassUtils.regClass("laya.html.dom.HTMLIframeElement", HTMLIframeElement);
+    Laya.ClassUtils.regClass("Laya.HTMLIframeElement", HTMLIframeElement);
+
+    exports.HTMLBrElement = HTMLBrElement;
+    exports.HTMLDivElement = HTMLDivElement;
+    exports.HTMLDivParser = HTMLDivParser;
+    exports.HTMLDocument = HTMLDocument;
+    exports.HTMLElement = HTMLElement;
+    exports.HTMLExtendStyle = HTMLExtendStyle;
+    exports.HTMLHitRect = HTMLHitRect;
+    exports.HTMLIframeElement = HTMLIframeElement;
+    exports.HTMLImageElement = HTMLImageElement;
+    exports.HTMLLinkElement = HTMLLinkElement;
+    exports.HTMLParse = HTMLParse;
+    exports.HTMLStyle = HTMLStyle;
+    exports.HTMLStyleElement = HTMLStyleElement;
+    exports.IHtml = IHtml;
+    exports.Layout = Layout;
+    exports.LayoutLine = LayoutLine;
+
+}(window.Laya = window.Laya || {}, Laya));

文件差異過大導致無法顯示
+ 267 - 0
ShootingSun/bin/libs/laya.particle.js


+ 3201 - 0
ShootingSun/bin/libs/laya.physics.js

@@ -0,0 +1,3201 @@
+var COMPILED=!0,goog=goog||{};goog.global=window;goog.isDef=function(a){return void 0!==a};goog.exportPath_=function(a,b,c){a=a.split(".");c=c||goog.global;a[0]in c||!c.execScript||c.execScript("var "+a[0]);for(var d;a.length&&(d=a.shift());)!a.length&&goog.isDef(b)?c[d]=b:c=c[d]?c[d]:c[d]={}};
+goog.define=function(a,b){var c=b;COMPILED||(goog.global.CLOSURE_UNCOMPILED_DEFINES&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_UNCOMPILED_DEFINES,a)?c=goog.global.CLOSURE_UNCOMPILED_DEFINES[a]:goog.global.CLOSURE_DEFINES&&Object.prototype.hasOwnProperty.call(goog.global.CLOSURE_DEFINES,a)&&(c=goog.global.CLOSURE_DEFINES[a]));goog.exportPath_(a,c)};goog.DEBUG=!1;goog.LOCALE="en";goog.TRUSTED_SITE=!0;goog.STRICT_MODE_COMPATIBLE=!1;goog.DISALLOW_TEST_ONLY_CODE=COMPILED&&!goog.DEBUG;
+goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING=!1;goog.provide=function(a){if(!COMPILED&&goog.isProvided_(a))throw Error('Namespace "'+a+'" already declared.');goog.constructNamespace_(a)};goog.constructNamespace_=function(a,b){if(!COMPILED){delete goog.implicitNamespaces_[a];for(var c=a;(c=c.substring(0,c.lastIndexOf(".")))&&!goog.getObjectByName(c);)goog.implicitNamespaces_[c]=!0}goog.exportPath_(a,b)};goog.VALID_MODULE_RE_=/^[a-zA-Z_$][a-zA-Z0-9._$]*$/;
+goog.module=function(a){if(!goog.isString(a)||!a||-1==a.search(goog.VALID_MODULE_RE_))throw Error("Invalid module identifier");if(!goog.isInModuleLoader_())throw Error("Module "+a+" has been loaded incorrectly.");if(goog.moduleLoaderState_.moduleName)throw Error("goog.module may only be called once per module.");goog.moduleLoaderState_.moduleName=a;if(!COMPILED){if(goog.isProvided_(a))throw Error('Namespace "'+a+'" already declared.');delete goog.implicitNamespaces_[a]}};goog.module.get=function(a){return goog.module.getInternal_(a)};
+goog.module.getInternal_=function(a){if(!COMPILED)return goog.isProvided_(a)?a in goog.loadedModules_?goog.loadedModules_[a]:goog.getObjectByName(a):null};goog.moduleLoaderState_=null;goog.isInModuleLoader_=function(){return null!=goog.moduleLoaderState_};
+goog.module.declareLegacyNamespace=function(){if(!COMPILED&&!goog.isInModuleLoader_())throw Error("goog.module.declareLegacyNamespace must be called from within a goog.module");if(!COMPILED&&!goog.moduleLoaderState_.moduleName)throw Error("goog.module must be called prior to goog.module.declareLegacyNamespace.");goog.moduleLoaderState_.declareLegacyNamespace=!0};
+goog.setTestOnly=function(a){if(goog.DISALLOW_TEST_ONLY_CODE)throw a=a||"",Error("Importing test-only code into non-debug environment"+(a?": "+a:"."));};goog.forwardDeclare=function(a){};COMPILED||(goog.isProvided_=function(a){return a in goog.loadedModules_||!goog.implicitNamespaces_[a]&&goog.isDefAndNotNull(goog.getObjectByName(a))},goog.implicitNamespaces_={"goog.module":!0});
+goog.getObjectByName=function(a,b){for(var c=a.split("."),d=b||goog.global,e;e=c.shift();)if(goog.isDefAndNotNull(d[e]))d=d[e];else return null;return d};goog.globalize=function(a,b){var c=b||goog.global,d;for(d in a)c[d]=a[d]};goog.addDependency=function(a,b,c,d){if(goog.DEPENDENCIES_ENABLED){var e;a=a.replace(/\\/g,"/");for(var f=goog.dependencies_,g=0;e=b[g];g++)f.nameToPath[e]=a,f.pathIsModule[a]=!!d;for(d=0;b=c[d];d++)a in f.requires||(f.requires[a]={}),f.requires[a][b]=!0}};
+goog.ENABLE_DEBUG_LOADER=!0;goog.logToConsole_=function(a){goog.global.console&&goog.global.console.error(a)};goog.require=function(a){if(!COMPILED){goog.ENABLE_DEBUG_LOADER&&goog.IS_OLD_IE_&&goog.maybeProcessDeferredDep_(a);if(goog.isProvided_(a))return goog.isInModuleLoader_()?goog.module.getInternal_(a):null;if(goog.ENABLE_DEBUG_LOADER){var b=goog.getPathFromDeps_(a);if(b)return goog.writeScripts_(b),null}a="goog.require could not find: "+a;goog.logToConsole_(a);throw Error(a);}};
+goog.basePath="";goog.nullFunction=function(){};goog.abstractMethod=function(){throw Error("unimplemented abstract method");};goog.addSingletonGetter=function(a){a.getInstance=function(){if(a.instance_)return a.instance_;goog.DEBUG&&(goog.instantiatedSingletons_[goog.instantiatedSingletons_.length]=a);return a.instance_=new a}};goog.instantiatedSingletons_=[];goog.LOAD_MODULE_USING_EVAL=!0;goog.SEAL_MODULE_EXPORTS=goog.DEBUG;goog.loadedModules_={};goog.DEPENDENCIES_ENABLED=!COMPILED&&goog.ENABLE_DEBUG_LOADER;
+goog.DEPENDENCIES_ENABLED&&(goog.dependencies_={pathIsModule:{},nameToPath:{},requires:{},visited:{},written:{},deferred:{}},goog.inHtmlDocument_=function(){var a=goog.global.document;return null!=a&&"write"in a},goog.findBasePath_=function(){if(goog.isDef(goog.global.CLOSURE_BASE_PATH))goog.basePath=goog.global.CLOSURE_BASE_PATH;else if(goog.inHtmlDocument_())for(var a=goog.global.document.getElementsByTagName("SCRIPT"),b=a.length-1;0<=b;--b){var c=a[b].src,d=c.lastIndexOf("?"),d=-1==d?c.length:
+d;if("base.js"==c.substr(d-7,7)){goog.basePath=c.substr(0,d-7);break}}},goog.importScript_=function(a,b){(goog.global.CLOSURE_IMPORT_SCRIPT||goog.writeScriptTag_)(a,b)&&(goog.dependencies_.written[a]=!0)},goog.IS_OLD_IE_=!(goog.global.atob||!goog.global.document||!goog.global.document.all),goog.importModule_=function(a){goog.importScript_("",'goog.retrieveAndExecModule_("'+a+'");')&&(goog.dependencies_.written[a]=!0)},goog.queuedModules_=[],goog.wrapModule_=function(a,b){return goog.LOAD_MODULE_USING_EVAL&&
+goog.isDef(goog.global.JSON)?"goog.loadModule("+goog.global.JSON.stringify(b+"\n//# sourceURL="+a+"\n")+");":'goog.loadModule(function(exports) {"use strict";'+b+"\n;return exports});\n//# sourceURL="+a+"\n"},goog.loadQueuedModules_=function(){var a=goog.queuedModules_.length;if(0<a){var b=goog.queuedModules_;goog.queuedModules_=[];for(var c=0;c<a;c++)goog.maybeProcessDeferredPath_(b[c])}},goog.maybeProcessDeferredDep_=function(a){goog.isDeferredModule_(a)&&goog.allDepsAreAvailable_(a)&&(a=goog.getPathFromDeps_(a),
+goog.maybeProcessDeferredPath_(goog.basePath+a))},goog.isDeferredModule_=function(a){return(a=goog.getPathFromDeps_(a))&&goog.dependencies_.pathIsModule[a]?goog.basePath+a in goog.dependencies_.deferred:!1},goog.allDepsAreAvailable_=function(a){if((a=goog.getPathFromDeps_(a))&&a in goog.dependencies_.requires)for(var b in goog.dependencies_.requires[a])if(!goog.isProvided_(b)&&!goog.isDeferredModule_(b))return!1;return!0},goog.maybeProcessDeferredPath_=function(a){if(a in goog.dependencies_.deferred){var b=
+goog.dependencies_.deferred[a];delete goog.dependencies_.deferred[a];goog.globalEval(b)}},goog.loadModuleFromUrl=function(a){goog.retrieveAndExecModule_(a)},goog.loadModule=function(a){var b=goog.moduleLoaderState_;try{goog.moduleLoaderState_={moduleName:void 0,declareLegacyNamespace:!1};var c;if(goog.isFunction(a))c=a.call(goog.global,{});else if(goog.isString(a))c=goog.loadModuleFromSource_.call(goog.global,a);else throw Error("Invalid module definition");var d=goog.moduleLoaderState_.moduleName;
+if(!goog.isString(d)||!d)throw Error('Invalid module name "'+d+'"');goog.moduleLoaderState_.declareLegacyNamespace?goog.constructNamespace_(d,c):goog.SEAL_MODULE_EXPORTS&&Object.seal&&Object.seal(c);goog.loadedModules_[d]=c}finally{goog.moduleLoaderState_=b}},goog.loadModuleFromSource_=function(a){eval(a);return{}},goog.writeScriptSrcNode_=function(a){goog.global.document.write('<script type="text/javascript" src="'+a+'">\x3c/script>')},goog.appendScriptSrcNode_=function(a){var b=goog.global.document,
+c=b.createElement("script");c.type="text/javascript";c.src=a;c.defer=!1;c.async=!1;b.head.appendChild(c)},goog.writeScriptTag_=function(a,b){if(goog.inHtmlDocument_()){var c=goog.global.document;if(!goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING&&"complete"==c.readyState){if(/\bdeps.js$/.test(a))return!1;throw Error('Cannot write "'+a+'" after document load');}var d=goog.IS_OLD_IE_;void 0===b?d?(d=" onreadystatechange='goog.onScriptLoad_(this, "+ ++goog.lastNonModuleScriptIndex_+")' ",c.write('<script type="text/javascript" src="'+
+a+'"'+d+">\x3c/script>")):goog.ENABLE_CHROME_APP_SAFE_SCRIPT_LOADING?goog.appendScriptSrcNode_(a):goog.writeScriptSrcNode_(a):c.write('<script type="text/javascript">'+b+"\x3c/script>");return!0}return!1},goog.lastNonModuleScriptIndex_=0,goog.onScriptLoad_=function(a,b){"complete"==a.readyState&&goog.lastNonModuleScriptIndex_==b&&goog.loadQueuedModules_();return!0},goog.writeScripts_=function(a){function b(a){if(!(a in e.written||a in e.visited)){e.visited[a]=!0;if(a in e.requires)for(var f in e.requires[a])if(!goog.isProvided_(f))if(f in
+e.nameToPath)b(e.nameToPath[f]);else throw Error("Undefined nameToPath for "+f);a in d||(d[a]=!0,c.push(a))}}var c=[],d={},e=goog.dependencies_;b(a);for(a=0;a<c.length;a++){var f=c[a];goog.dependencies_.written[f]=!0}var g=goog.moduleLoaderState_;goog.moduleLoaderState_=null;for(a=0;a<c.length;a++)if(f=c[a])e.pathIsModule[f]?goog.importModule_(goog.basePath+f):goog.importScript_(goog.basePath+f);else throw goog.moduleLoaderState_=g,Error("Undefined script input");goog.moduleLoaderState_=g},goog.getPathFromDeps_=
+function(a){return a in goog.dependencies_.nameToPath?goog.dependencies_.nameToPath[a]:null},goog.findBasePath_(),goog.global.CLOSURE_NO_DEPS||goog.importScript_(goog.basePath+"deps.js"));goog.normalizePath_=function(a){a=a.split("/");for(var b=0;b<a.length;)"."==a[b]?a.splice(b,1):b&&".."==a[b]&&a[b-1]&&".."!=a[b-1]?a.splice(--b,2):b++;return a.join("/")};
+goog.loadFileSync_=function(a){if(goog.global.CLOSURE_LOAD_FILE_SYNC)return goog.global.CLOSURE_LOAD_FILE_SYNC(a);var b=new goog.global.XMLHttpRequest;b.open("get",a,!1);b.send();return b.responseText};
+goog.retrieveAndExecModule_=function(a){if(!COMPILED){var b=a;a=goog.normalizePath_(a);var c=goog.global.CLOSURE_IMPORT_SCRIPT||goog.writeScriptTag_,d=goog.loadFileSync_(a);if(null!=d)d=goog.wrapModule_(a,d),goog.IS_OLD_IE_?(goog.dependencies_.deferred[b]=d,goog.queuedModules_.push(b)):c(a,d);else throw Error("load of "+a+"failed");}};
+goog.typeOf=function(a){var b=typeof a;if("object"==b)if(a){if(a instanceof Array)return"array";if(a instanceof Object)return b;var c=Object.prototype.toString.call(a);if("[object Window]"==c)return"object";if("[object Array]"==c||"number"==typeof a.length&&"undefined"!=typeof a.splice&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("splice"))return"array";if("[object Function]"==c||"undefined"!=typeof a.call&&"undefined"!=typeof a.propertyIsEnumerable&&!a.propertyIsEnumerable("call"))return"function"}else return"null";
+else if("function"==b&&"undefined"==typeof a.call)return"object";return b};goog.isNull=function(a){return null===a};goog.isDefAndNotNull=function(a){return null!=a};goog.isArray=function(a){return"array"==goog.typeOf(a)};goog.isArrayLike=function(a){var b=goog.typeOf(a);return"array"==b||"object"==b&&"number"==typeof a.length};goog.isDateLike=function(a){return goog.isObject(a)&&"function"==typeof a.getFullYear};goog.isString=function(a){return"string"==typeof a};
+goog.isBoolean=function(a){return"boolean"==typeof a};goog.isNumber=function(a){return"number"==typeof a};goog.isFunction=function(a){return"function"==goog.typeOf(a)};goog.isObject=function(a){var b=typeof a;return"object"==b&&null!=a||"function"==b};goog.getUid=function(a){return a[goog.UID_PROPERTY_]||(a[goog.UID_PROPERTY_]=++goog.uidCounter_)};goog.hasUid=function(a){return!!a[goog.UID_PROPERTY_]};
+goog.removeUid=function(a){null!==a&&"removeAttribute"in a&&a.removeAttribute(goog.UID_PROPERTY_);try{delete a[goog.UID_PROPERTY_]}catch(b){}};goog.UID_PROPERTY_="closure_uid_"+(1E9*Math.random()>>>0);goog.uidCounter_=0;goog.getHashCode=goog.getUid;goog.removeHashCode=goog.removeUid;goog.cloneObject=function(a){var b=goog.typeOf(a);if("object"==b||"array"==b){if(a.clone)return a.clone();var b="array"==b?[]:{},c;for(c in a)b[c]=goog.cloneObject(a[c]);return b}return a};
+goog.bindNative_=function(a,b,c){return a.call.apply(a.bind,arguments)};goog.bindJs_=function(a,b,c){if(!a)throw Error();if(2<arguments.length){var d=Array.prototype.slice.call(arguments,2);return function(){var c=Array.prototype.slice.call(arguments);Array.prototype.unshift.apply(c,d);return a.apply(b,c)}}return function(){return a.apply(b,arguments)}};
+goog.bind=function(a,b,c){Function.prototype.bind&&-1!=Function.prototype.bind.toString().indexOf("native code")?goog.bind=goog.bindNative_:goog.bind=goog.bindJs_;return goog.bind.apply(null,arguments)};goog.partial=function(a,b){var c=Array.prototype.slice.call(arguments,1);return function(){var b=c.slice();b.push.apply(b,arguments);return a.apply(this,b)}};goog.mixin=function(a,b){for(var c in b)a[c]=b[c]};goog.now=goog.TRUSTED_SITE&&Date.now||function(){return+new Date};
+goog.globalEval=function(a){if(goog.global.execScript)goog.global.execScript(a,"JavaScript");else if(goog.global.eval){if(null==goog.evalWorksForGlobals_)if(goog.global.eval("var _evalTest_ = 1;"),"undefined"!=typeof goog.global._evalTest_){try{delete goog.global._evalTest_}catch(d){}goog.evalWorksForGlobals_=!0}else goog.evalWorksForGlobals_=!1;if(goog.evalWorksForGlobals_)goog.global.eval(a);else{var b=goog.global.document,c=b.createElement("SCRIPT");c.type="text/javascript";c.defer=!1;c.appendChild(b.createTextNode(a));
+b.body.appendChild(c);b.body.removeChild(c)}}else throw Error("goog.globalEval not available");};goog.evalWorksForGlobals_=null;goog.getCssName=function(a,b){var c=function(a){return goog.cssNameMapping_[a]||a},d=function(a){a=a.split("-");for(var b=[],d=0;d<a.length;d++)b.push(c(a[d]));return b.join("-")},d=goog.cssNameMapping_?"BY_WHOLE"==goog.cssNameMappingStyle_?c:d:function(a){return a};return b?a+"-"+d(b):d(a)};
+goog.setCssNameMapping=function(a,b){goog.cssNameMapping_=a;goog.cssNameMappingStyle_=b};!COMPILED&&goog.global.CLOSURE_CSS_NAME_MAPPING&&(goog.cssNameMapping_=goog.global.CLOSURE_CSS_NAME_MAPPING);goog.getMsg=function(a,b){b&&(a=a.replace(/\{\$([^}]+)}/g,function(a,d){return null!=b&&d in b?b[d]:a}));return a};goog.getMsgWithFallback=function(a,b){return a};goog.exportSymbol=function(a,b,c){goog.exportPath_(a,b,c)};goog.exportProperty=function(a,b,c){a[b]=c};
+goog.inherits=function(a,b){function c(){}c.prototype=b.prototype;a.superClass_=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.base=function(a,c,f){for(var g=Array(arguments.length-2),h=2;h<arguments.length;h++)g[h-2]=arguments[h];return b.prototype[c].apply(a,g)}};
+goog.base=function(a,b,c){var d=arguments.callee.caller;if(goog.STRICT_MODE_COMPATIBLE||goog.DEBUG&&!d)throw Error("arguments.caller not defined.  goog.base() cannot be used with strict mode code. See http://www.ecma-international.org/ecma-262/5.1/#sec-C");if(d.superClass_){for(var e=Array(arguments.length-1),f=1;f<arguments.length;f++)e[f-1]=arguments[f];return d.superClass_.constructor.apply(a,e)}e=Array(arguments.length-2);for(f=2;f<arguments.length;f++)e[f-2]=arguments[f];for(var f=!1,g=a.constructor;g;g=
+g.superClass_&&g.superClass_.constructor)if(g.prototype[b]===d)f=!0;else if(f)return g.prototype[b].apply(a,e);if(a[b]===d)return a.constructor.prototype[b].apply(a,e);throw Error("goog.base called from a method of one name to a method of a different name");};goog.scope=function(a){a.call(goog.global)};COMPILED||(goog.global.COMPILED=COMPILED);
+goog.defineClass=function(a,b){var c=b.constructor,d=b.statics;c&&c!=Object.prototype.constructor||(c=function(){throw Error("cannot instantiate an interface (no constructor defined).");});c=goog.defineClass.createSealingConstructor_(c,a);a&&goog.inherits(c,a);delete b.constructor;delete b.statics;goog.defineClass.applyProperties_(c.prototype,b);null!=d&&(d instanceof Function?d(c):goog.defineClass.applyProperties_(c,d));return c};goog.defineClass.SEAL_CLASS_INSTANCES=goog.DEBUG;
+goog.defineClass.createSealingConstructor_=function(a,b){if(goog.defineClass.SEAL_CLASS_INSTANCES&&Object.seal instanceof Function){if(b&&b.prototype&&b.prototype[goog.UNSEALABLE_CONSTRUCTOR_PROPERTY_])return a;var c=function(){var b=a.apply(this,arguments)||this;b[goog.UID_PROPERTY_]=b[goog.UID_PROPERTY_];this.constructor===c&&Object.seal(b);return b};return c}return a};goog.defineClass.OBJECT_PROTOTYPE_FIELDS_="constructor hasOwnProperty isPrototypeOf propertyIsEnumerable toLocaleString toString valueOf".split(" ");
+goog.defineClass.applyProperties_=function(a,b){for(var c in b)Object.prototype.hasOwnProperty.call(b,c)&&(a[c]=b[c]);for(var d=0;d<goog.defineClass.OBJECT_PROTOTYPE_FIELDS_.length;d++)c=goog.defineClass.OBJECT_PROTOTYPE_FIELDS_[d],Object.prototype.hasOwnProperty.call(b,c)&&(a[c]=b[c])};goog.tagUnsealableClass=function(a){!COMPILED&&goog.defineClass.SEAL_CLASS_INSTANCES&&(a.prototype[goog.UNSEALABLE_CONSTRUCTOR_PROPERTY_]=!0)};goog.UNSEALABLE_CONSTRUCTOR_PROPERTY_="goog_defineClass_legacy_unsealable";var box2d={b2Settings:{}};Object.defineProperty||(Object.defineProperty=function(a,b,c){Object.__defineGetter__&&("get"in c?a.__defineGetter__(b,c.get):"value"in c&&a.__defineGetter__(b,c.value));Object.__defineSetter__&&("set"in c?a.__defineSetter__(b,c.set):"value"in c&&a.__defineSetter__(b,c.value));return a});box2d.DEBUG=!0;goog.exportSymbol("box2d.DEBUG",box2d.DEBUG);box2d.ENABLE_ASSERTS=box2d.DEBUG;goog.exportSymbol("box2d.ENABLE_ASSERTS",box2d.ENABLE_ASSERTS);
+box2d.b2Assert=function(a,b,c){if(box2d.DEBUG&&!a)throw Error();};goog.exportSymbol("box2d.b2Assert",box2d.b2Assert);box2d.b2_maxFloat=1E37;goog.exportSymbol("box2d.b2_maxFloat",box2d.b2_maxFloat);box2d.b2_epsilon=1E-5;goog.exportSymbol("box2d.b2_epsilon",box2d.b2_epsilon);box2d.b2_epsilon_sq=box2d.b2_epsilon*box2d.b2_epsilon;goog.exportSymbol("box2d.b2_epsilon_sq",box2d.b2_epsilon_sq);box2d.b2_pi=Math.PI;goog.exportSymbol("box2d.b2_pi",box2d.b2_pi);box2d.b2_maxManifoldPoints=2;
+goog.exportSymbol("box2d.b2_maxManifoldPoints",box2d.b2_maxManifoldPoints);box2d.b2_maxPolygonVertices=8;goog.exportSymbol("box2d.b2_maxPolygonVertices",box2d.b2_maxPolygonVertices);box2d.b2_aabbExtension=.1;goog.exportSymbol("box2d.b2_aabbExtension",box2d.b2_aabbExtension);box2d.b2_aabbMultiplier=2;goog.exportSymbol("box2d.b2_aabbMultiplier",box2d.b2_aabbMultiplier);box2d.b2_linearSlop=.008;goog.exportSymbol("box2d.b2_linearSlop",box2d.b2_linearSlop);box2d.b2_angularSlop=2/180*box2d.b2_pi;
+goog.exportSymbol("box2d.b2_angularSlop",box2d.b2_angularSlop);box2d.b2_polygonRadius=2*box2d.b2_linearSlop;goog.exportSymbol("box2d.b2_polygonRadius",box2d.b2_polygonRadius);box2d.b2_maxSubSteps=8;goog.exportSymbol("box2d.b2_maxSubSteps",box2d.b2_maxSubSteps);box2d.b2_maxTOIContacts=32;goog.exportSymbol("box2d.b2_maxTOIContacts",box2d.b2_maxTOIContacts);box2d.b2_velocityThreshold=1;goog.exportSymbol("box2d.b2_velocityThreshold",box2d.b2_velocityThreshold);box2d.b2_maxLinearCorrection=.2;
+goog.exportSymbol("box2d.b2_maxLinearCorrection",box2d.b2_maxLinearCorrection);box2d.b2_maxAngularCorrection=8/180*box2d.b2_pi;goog.exportSymbol("box2d.b2_maxAngularCorrection",box2d.b2_maxAngularCorrection);box2d.b2_maxTranslation=2;goog.exportSymbol("box2d.b2_maxTranslation",box2d.b2_maxTranslation);box2d.b2_maxTranslationSquared=box2d.b2_maxTranslation*box2d.b2_maxTranslation;goog.exportSymbol("box2d.b2_maxTranslationSquared",box2d.b2_maxTranslationSquared);box2d.b2_maxRotation=.5*box2d.b2_pi;
+goog.exportSymbol("box2d.b2_maxRotation",box2d.b2_maxRotation);box2d.b2_maxRotationSquared=box2d.b2_maxRotation*box2d.b2_maxRotation;goog.exportSymbol("box2d.b2_maxRotationSquared",box2d.b2_maxRotationSquared);box2d.b2_baumgarte=.2;goog.exportSymbol("box2d.b2_baumgarte",box2d.b2_baumgarte);box2d.b2_toiBaumgarte=.75;goog.exportSymbol("box2d.b2_toiBaumgarte",box2d.b2_toiBaumgarte);box2d.b2_invalidParticleIndex=-1;goog.exportSymbol("box2d.b2_invalidParticleIndex",box2d.b2_invalidParticleIndex);
+box2d.b2_maxParticleIndex=2147483647;goog.exportSymbol("box2d.b2_maxParticleIndex",box2d.b2_maxParticleIndex);box2d.b2_particleStride=.75;goog.exportSymbol("box2d.b2_particleStride",box2d.b2_particleStride);box2d.b2_minParticleWeight=1;goog.exportSymbol("box2d.b2_minParticleWeight",box2d.b2_minParticleWeight);box2d.b2_maxParticlePressure=.25;goog.exportSymbol("box2d.b2_maxParticlePressure",box2d.b2_maxParticlePressure);box2d.b2_maxParticleForce=.5;goog.exportSymbol("box2d.b2_maxParticleForce",box2d.b2_maxParticleForce);
+box2d.b2_maxTriadDistance=2;goog.exportSymbol("box2d.b2_maxTriadDistance",box2d.b2_maxTriadDistance);box2d.b2_maxTriadDistanceSquared=box2d.b2_maxTriadDistance*box2d.b2_maxTriadDistance;goog.exportSymbol("box2d.b2_maxTriadDistanceSquared",box2d.b2_maxTriadDistanceSquared);box2d.b2_minParticleSystemBufferCapacity=256;goog.exportSymbol("box2d.b2_minParticleSystemBufferCapacity",box2d.b2_minParticleSystemBufferCapacity);box2d.b2_barrierCollisionTime=2.5;
+goog.exportSymbol("box2d.b2_barrierCollisionTime",box2d.b2_barrierCollisionTime);box2d.b2_timeToSleep=.5;goog.exportSymbol("box2d.b2_timeToSleep",box2d.b2_timeToSleep);box2d.b2_linearSleepTolerance=.01;goog.exportSymbol("box2d.b2_linearSleepTolerance",box2d.b2_linearSleepTolerance);box2d.b2_angularSleepTolerance=2/180*box2d.b2_pi;goog.exportSymbol("box2d.b2_angularSleepTolerance",box2d.b2_angularSleepTolerance);box2d.b2Alloc=function(a){return null};goog.exportSymbol("box2d.b2Alloc",box2d.b2Alloc);
+box2d.b2Free=function(a){};goog.exportSymbol("box2d.b2Free",box2d.b2Free);box2d.b2Log=function(a){goog.global.console.log.apply(null,arguments)};goog.exportSymbol("box2d.b2Log",box2d.b2Log);box2d.b2Version=function(a,b,c){this.major=a||0;this.minor=b||0;this.revision=c||0};goog.exportSymbol("box2d.b2Version",box2d.b2Version);box2d.b2Version.prototype.major=0;goog.exportProperty(box2d.b2Version.prototype,"major",box2d.b2Version.prototype.major);box2d.b2Version.prototype.minor=0;
+goog.exportProperty(box2d.b2Version.prototype,"minor",box2d.b2Version.prototype.minor);box2d.b2Version.prototype.revision=0;goog.exportProperty(box2d.b2Version.prototype,"revision",box2d.b2Version.prototype.revision);box2d.b2Version.prototype.toString=function(){return this.major+"."+this.minor+"."+this.revision};goog.exportProperty(box2d.b2Version.prototype,"toString",box2d.b2Version.prototype.toString);box2d.b2_version=new box2d.b2Version(2,3,2);goog.exportSymbol("box2d.b2_version",box2d.b2_version);
+box2d.b2_changelist=313;goog.exportSymbol("box2d.b2_changelist",box2d.b2_changelist);box2d.b2ParseInt=function(a){return parseInt(a,10)};goog.exportSymbol("box2d.b2ParseInt",box2d.b2ParseInt);box2d.b2ParseUInt=function(a){return box2d.b2Abs(parseInt(a,10))};goog.exportSymbol("box2d.b2ParseUInt",box2d.b2ParseUInt);box2d.b2MakeArray=function(a,b){a="number"===typeof a?a:0;var c=[];if("function"===typeof b)for(var d=0;d<a;++d)c.push(b(d));else for(d=0;d<a;++d)c.push(null);return c};
+goog.exportSymbol("box2d.b2MakeArray",box2d.b2MakeArray);box2d.b2MakeNumberArray=function(a){return box2d.b2MakeArray(a,function(a){return 0})};goog.exportSymbol("box2d.b2MakeNumberArray",box2d.b2MakeNumberArray);box2d.b2Color=function(a,b,c,d){this.r=a;this.g=b;this.b=c;this.a="number"===typeof d?d:1};goog.exportSymbol("box2d.b2Color",box2d.b2Color);box2d.b2Color.prototype.r=.5;goog.exportProperty(box2d.b2Color.prototype,"r",box2d.b2Color.prototype.r);box2d.b2Color.prototype.g=.5;goog.exportProperty(box2d.b2Color.prototype,"g",box2d.b2Color.prototype.g);box2d.b2Color.prototype.b=.5;goog.exportProperty(box2d.b2Color.prototype,"b",box2d.b2Color.prototype.b);box2d.b2Color.prototype.a=1;
+goog.exportProperty(box2d.b2Color.prototype,"a",box2d.b2Color.prototype.a);box2d.b2Color.prototype.SetRGB=function(a,b,c){this.r=a;this.g=b;this.b=c;return this};goog.exportProperty(box2d.b2Color.prototype,"SetRGB",box2d.b2Color.prototype.SetRGB);
+box2d.b2Color.prototype.MakeStyleString=function(a){return box2d.b2Color.MakeStyleString(Math.round(Math.max(0,Math.min(255,255*this.r))),Math.round(Math.max(0,Math.min(255,255*this.g))),Math.round(Math.max(0,Math.min(255,255*this.b))),"undefined"===typeof a?this.a:Math.max(0,Math.min(1,a)))};goog.exportProperty(box2d.b2Color.prototype,"MakeStyleString",box2d.b2Color.prototype.MakeStyleString);
+box2d.b2Color.MakeStyleString=function(a,b,c,d){return 1>d?"rgba("+a+","+b+","+c+","+d+")":"rgb("+a+","+b+","+c+")"};goog.exportProperty(box2d.b2Color,"MakeStyleString",box2d.b2Color.MakeStyleString);box2d.b2Color.RED=new box2d.b2Color(1,0,0);goog.exportProperty(box2d.b2Color,"RED",box2d.b2Color.RED);box2d.b2Color.GREEN=new box2d.b2Color(0,1,0);goog.exportProperty(box2d.b2Color,"GREEN",box2d.b2Color.GREEN);box2d.b2Color.BLUE=new box2d.b2Color(0,0,1);goog.exportProperty(box2d.b2Color,"BLUE",box2d.b2Color.BLUE);
+box2d.b2DrawFlags={e_none:0,e_shapeBit:1,e_jointBit:2,e_aabbBit:4,e_pairBit:8,e_centerOfMassBit:16,e_controllerBit:32,e_particleBit:64,e_all:65535};goog.exportSymbol("box2d.b2DrawFlags",box2d.b2DrawFlags);goog.exportProperty(box2d.b2DrawFlags,"e_none",box2d.b2DrawFlags.e_none);goog.exportProperty(box2d.b2DrawFlags,"e_shapeBit",box2d.b2DrawFlags.e_shapeBit);goog.exportProperty(box2d.b2DrawFlags,"e_jointBit",box2d.b2DrawFlags.e_jointBit);goog.exportProperty(box2d.b2DrawFlags,"e_aabbBit",box2d.b2DrawFlags.e_aabbBit);
+goog.exportProperty(box2d.b2DrawFlags,"e_pairBit",box2d.b2DrawFlags.e_pairBit);goog.exportProperty(box2d.b2DrawFlags,"e_centerOfMassBit",box2d.b2DrawFlags.e_centerOfMassBit);goog.exportProperty(box2d.b2DrawFlags,"e_controllerBit",box2d.b2DrawFlags.e_controllerBit);goog.exportProperty(box2d.b2DrawFlags,"e_particleBit",box2d.b2DrawFlags.e_particleBit);goog.exportProperty(box2d.b2DrawFlags,"e_all",box2d.b2DrawFlags.e_all);box2d.b2Draw=function(){};goog.exportSymbol("box2d.b2Draw",box2d.b2Draw);
+box2d.b2Draw.prototype.m_drawFlags=box2d.b2DrawFlags.e_none;goog.exportProperty(box2d.b2Draw.prototype,"m_drawFlags",box2d.b2Draw.prototype.m_drawFlags);box2d.b2Draw.prototype.SetFlags=function(a){this.m_drawFlags=a};goog.exportProperty(box2d.b2Draw.prototype,"SetFlags",box2d.b2Draw.prototype.SetFlags);box2d.b2Draw.prototype.GetFlags=function(){return this.m_drawFlags};goog.exportProperty(box2d.b2Draw.prototype,"GetFlags",box2d.b2Draw.prototype.GetFlags);
+box2d.b2Draw.prototype.AppendFlags=function(a){this.m_drawFlags|=a};goog.exportProperty(box2d.b2Draw.prototype,"AppendFlags",box2d.b2Draw.prototype.AppendFlags);box2d.b2Draw.prototype.ClearFlags=function(a){this.m_drawFlags&=~a};goog.exportProperty(box2d.b2Draw.prototype,"ClearFlags",box2d.b2Draw.prototype.ClearFlags);box2d.b2Draw.prototype.PushTransform=function(a){};goog.exportProperty(box2d.b2Draw.prototype,"PushTransform",box2d.b2Draw.prototype.PushTransform);
+box2d.b2Draw.prototype.PopTransform=function(a){};goog.exportProperty(box2d.b2Draw.prototype,"PopTransform",box2d.b2Draw.prototype.PopTransform);box2d.b2Draw.prototype.DrawPolygon=function(a,b,c){};goog.exportProperty(box2d.b2Draw.prototype,"DrawPolygon",box2d.b2Draw.prototype.DrawPolygon);box2d.b2Draw.prototype.DrawSolidPolygon=function(a,b,c){};goog.exportProperty(box2d.b2Draw.prototype,"DrawSolidPolygon",box2d.b2Draw.prototype.DrawSolidPolygon);box2d.b2Draw.prototype.DrawCircle=function(a,b,c){};
+goog.exportProperty(box2d.b2Draw.prototype,"DrawCircle",box2d.b2Draw.prototype.DrawCircle);box2d.b2Draw.prototype.DrawSolidCircle=function(a,b,c,d){};goog.exportProperty(box2d.b2Draw.prototype,"DrawSolidCircle",box2d.b2Draw.prototype.DrawSolidCircle);box2d.b2Draw.prototype.DrawParticles=function(a,b,c,d){};goog.exportProperty(box2d.b2Draw.prototype,"DrawParticles",box2d.b2Draw.prototype.DrawParticles);box2d.b2Draw.prototype.DrawSegment=function(a,b,c){};
+goog.exportProperty(box2d.b2Draw.prototype,"DrawSegment",box2d.b2Draw.prototype.DrawSegment);box2d.b2Draw.prototype.DrawTransform=function(a){};goog.exportProperty(box2d.b2Draw.prototype,"DrawTransform",box2d.b2Draw.prototype.DrawTransform);box2d.b2GrowableStack=function(a){this.m_stack=Array(a)};goog.exportSymbol("box2d.b2GrowableStack",box2d.b2GrowableStack);box2d.b2GrowableStack.prototype.m_stack=null;goog.exportProperty(box2d.b2GrowableStack.prototype,"m_stack",box2d.b2GrowableStack.prototype.m_stack);box2d.b2GrowableStack.prototype.m_count=0;goog.exportProperty(box2d.b2GrowableStack.prototype,"m_count",box2d.b2GrowableStack.prototype.m_count);box2d.b2GrowableStack.prototype.Reset=function(){this.m_count=0;return this};
+goog.exportProperty(box2d.b2GrowableStack.prototype,"Reset",box2d.b2GrowableStack.prototype.Reset);box2d.b2GrowableStack.prototype.Push=function(a){this.m_stack[this.m_count]=a;++this.m_count};goog.exportProperty(box2d.b2GrowableStack.prototype,"Push",box2d.b2GrowableStack.prototype.Push);box2d.b2GrowableStack.prototype.Pop=function(){box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<this.m_count);--this.m_count;var a=this.m_stack[this.m_count];this.m_stack[this.m_count]=null;return a};
+goog.exportProperty(box2d.b2GrowableStack.prototype,"Pop",box2d.b2GrowableStack.prototype.Pop);box2d.b2GrowableStack.prototype.GetCount=function(){return this.m_count};goog.exportProperty(box2d.b2GrowableStack.prototype,"GetCount",box2d.b2GrowableStack.prototype.GetCount);box2d.b2Math={};box2d.b2_pi_over_180=box2d.b2_pi/180;goog.exportSymbol("box2d.b2_pi_over_180",box2d.b2_pi_over_180);box2d.b2_180_over_pi=180/box2d.b2_pi;goog.exportSymbol("box2d.b2_180_over_pi",box2d.b2_180_over_pi);box2d.b2_two_pi=2*box2d.b2_pi;goog.exportSymbol("box2d.b2_two_pi",box2d.b2_two_pi);box2d.b2Abs=Math.abs;goog.exportSymbol("box2d.b2Abs",box2d.b2Abs);box2d.b2Min=Math.min;goog.exportSymbol("box2d.b2Min",box2d.b2Min);box2d.b2Max=Math.max;goog.exportSymbol("box2d.b2Max",box2d.b2Max);
+box2d.b2Clamp=function(a,b,c){return Math.min(Math.max(a,b),c)};goog.exportSymbol("box2d.b2Clamp",box2d.b2Clamp);box2d.b2Wrap=function(a,b,c){return b<c?a<b?c-(b-a)%(c-b):b+(a-b)%(c-b):b===c?b:a};goog.exportSymbol("box2d.b2Wrap",box2d.b2Wrap);box2d.b2WrapAngle=function(a){return 0>a?(a-box2d.b2_pi)%box2d.b2_two_pi+box2d.b2_pi:(a+box2d.b2_pi)%box2d.b2_two_pi-box2d.b2_pi};goog.exportSymbol("box2d.b2WrapAngle",box2d.b2WrapAngle);
+box2d.b2Swap=function(a,b){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1);var c=a[0];a[0]=b[0];b[0]=c};goog.exportSymbol("box2d.b2Swap",box2d.b2Swap);box2d.b2IsValid=function(a){return isFinite(a)};goog.exportSymbol("box2d.b2IsValid",box2d.b2IsValid);box2d.b2Sq=function(a){return a*a};goog.exportSymbol("box2d.b2Sq",box2d.b2Sq);box2d.b2InvSqrt=function(a){return 1/Math.sqrt(a)};goog.exportSymbol("box2d.b2InvSqrt",box2d.b2InvSqrt);box2d.b2Sqrt=function(a){return Math.sqrt(a)};
+goog.exportSymbol("box2d.b2Sqrt",box2d.b2Sqrt);box2d.b2Pow=function(a,b){return Math.pow(a,b)};goog.exportSymbol("box2d.b2Pow",box2d.b2Pow);box2d.b2DegToRad=function(a){return a*box2d.b2_pi_over_180};goog.exportSymbol("box2d.b2DegToRad",box2d.b2DegToRad);box2d.b2RadToDeg=function(a){return a*box2d.b2_180_over_pi};goog.exportSymbol("box2d.b2RadToDeg",box2d.b2RadToDeg);box2d.b2Cos=function(a){return Math.cos(a)};goog.exportSymbol("box2d.b2Cos",box2d.b2Cos);box2d.b2Sin=function(a){return Math.sin(a)};
+goog.exportSymbol("box2d.b2Sin",box2d.b2Sin);box2d.b2Acos=function(a){return Math.acos(a)};goog.exportSymbol("box2d.b2Acos",box2d.b2Acos);box2d.b2Asin=function(a){return Math.asin(a)};goog.exportSymbol("box2d.b2Asin",box2d.b2Asin);box2d.b2Atan2=function(a,b){return Math.atan2(a,b)};goog.exportSymbol("box2d.b2Atan2",box2d.b2Atan2);box2d.b2NextPowerOfTwo=function(a){a|=a>>1&2147483647;a|=a>>2&1073741823;a|=a>>4&268435455;a|=a>>8&16777215;return(a|a>>16&65535)+1};
+goog.exportSymbol("box2d.b2NextPowerOfTwo",box2d.b2NextPowerOfTwo);box2d.b2IsPowerOfTwo=function(a){return 0<a&&0===(a&a-1)};goog.exportSymbol("box2d.b2IsPowerOfTwo",box2d.b2IsPowerOfTwo);box2d.b2Random=function(){return 2*Math.random()-1};goog.exportSymbol("box2d.b2Random",box2d.b2Random);box2d.b2RandomRange=function(a,b){return(b-a)*Math.random()+a};goog.exportSymbol("box2d.b2RandomRange",box2d.b2RandomRange);box2d.b2Vec2=function(a,b){this.x=a||0;this.y=b||0};goog.exportSymbol("box2d.b2Vec2",box2d.b2Vec2);
+box2d.b2Vec2.prototype.x=0;goog.exportProperty(box2d.b2Vec2.prototype,"x",box2d.b2Vec2.prototype.x);box2d.b2Vec2.prototype.y=0;goog.exportProperty(box2d.b2Vec2.prototype,"y",box2d.b2Vec2.prototype.y);box2d.b2Vec2_zero=new box2d.b2Vec2;goog.exportSymbol("box2d.b2Vec2_zero",box2d.b2Vec2_zero);box2d.b2Vec2.ZERO=new box2d.b2Vec2;goog.exportProperty(box2d.b2Vec2,"ZERO",box2d.b2Vec2.ZERO);box2d.b2Vec2.UNITX=new box2d.b2Vec2(1,0);goog.exportProperty(box2d.b2Vec2,"UNITX",box2d.b2Vec2.UNITX);
+box2d.b2Vec2.UNITY=new box2d.b2Vec2(0,1);goog.exportProperty(box2d.b2Vec2,"UNITY",box2d.b2Vec2.UNITY);box2d.b2Vec2.s_t0=new box2d.b2Vec2;goog.exportProperty(box2d.b2Vec2,"s_t0",box2d.b2Vec2.s_t0);box2d.b2Vec2.s_t1=new box2d.b2Vec2;goog.exportProperty(box2d.b2Vec2,"s_t1",box2d.b2Vec2.s_t1);box2d.b2Vec2.s_t2=new box2d.b2Vec2;goog.exportProperty(box2d.b2Vec2,"s_t2",box2d.b2Vec2.s_t2);box2d.b2Vec2.s_t3=new box2d.b2Vec2;goog.exportProperty(box2d.b2Vec2,"s_t3",box2d.b2Vec2.s_t3);
+box2d.b2Vec2.MakeArray=function(a){return box2d.b2MakeArray(a,function(a){return new box2d.b2Vec2})};goog.exportProperty(box2d.b2Vec2,"MakeArray",box2d.b2Vec2.MakeArray);box2d.b2Vec2.prototype.Clone=function(){return new box2d.b2Vec2(this.x,this.y)};goog.exportProperty(box2d.b2Vec2.prototype,"Clone",box2d.b2Vec2.prototype.Clone);box2d.b2Vec2.prototype.SetZero=function(){this.y=this.x=0;return this};goog.exportProperty(box2d.b2Vec2.prototype,"SetZero",box2d.b2Vec2.prototype.SetZero);
+box2d.b2Vec2.prototype.Set=function(a,b){this.x=a;this.y=b;return this};goog.exportProperty(box2d.b2Vec2.prototype,"Set",box2d.b2Vec2.prototype.Set);box2d.b2Vec2.prototype.Copy=function(a){this.x=a.x;this.y=a.y;return this};goog.exportProperty(box2d.b2Vec2.prototype,"Copy",box2d.b2Vec2.prototype.Copy);box2d.b2Vec2.prototype.SelfAdd=function(a){this.x+=a.x;this.y+=a.y;return this};goog.exportProperty(box2d.b2Vec2.prototype,"SelfAdd",box2d.b2Vec2.prototype.SelfAdd);
+box2d.b2Vec2.prototype.SelfAddXY=function(a,b){this.x+=a;this.y+=b;return this};goog.exportProperty(box2d.b2Vec2.prototype,"SelfAddXY",box2d.b2Vec2.prototype.SelfAddXY);box2d.b2Vec2.prototype.SelfSub=function(a){this.x-=a.x;this.y-=a.y;return this};goog.exportProperty(box2d.b2Vec2.prototype,"SelfSub",box2d.b2Vec2.prototype.SelfSub);box2d.b2Vec2.prototype.SelfSubXY=function(a,b){this.x-=a;this.y-=b;return this};goog.exportProperty(box2d.b2Vec2.prototype,"SelfSubXY",box2d.b2Vec2.prototype.SelfSubXY);
+box2d.b2Vec2.prototype.SelfMul=function(a){this.x*=a;this.y*=a;return this};goog.exportProperty(box2d.b2Vec2.prototype,"SelfMul",box2d.b2Vec2.prototype.SelfMul);box2d.b2Vec2.prototype.SelfMulAdd=function(a,b){this.x+=a*b.x;this.y+=a*b.y;return this};goog.exportProperty(box2d.b2Vec2.prototype,"SelfMulAdd",box2d.b2Vec2.prototype.SelfMulAdd);box2d.b2Vec2.prototype.SelfMulSub=function(a,b){this.x-=a*b.x;this.y-=a*b.y;return this};goog.exportProperty(box2d.b2Vec2.prototype,"SelfMulSub",box2d.b2Vec2.prototype.SelfMulSub);
+box2d.b2Vec2.prototype.Dot=function(a){return this.x*a.x+this.y*a.y};goog.exportProperty(box2d.b2Vec2.prototype,"Dot",box2d.b2Vec2.prototype.Dot);box2d.b2Vec2.prototype.Cross=function(a){return this.x*a.y-this.y*a.x};goog.exportProperty(box2d.b2Vec2.prototype,"Cross",box2d.b2Vec2.prototype.Cross);box2d.b2Vec2.prototype.Length=function(){var a=this.x,b=this.y;return Math.sqrt(a*a+b*b)};goog.exportProperty(box2d.b2Vec2.prototype,"Length",box2d.b2Vec2.prototype.Length);
+box2d.b2Vec2.prototype.LengthSquared=function(){var a=this.x,b=this.y;return a*a+b*b};goog.exportProperty(box2d.b2Vec2.prototype,"LengthSquared",box2d.b2Vec2.prototype.LengthSquared);box2d.b2Vec2.prototype.Normalize=function(){var a=this.Length();if(a>=box2d.b2_epsilon){var b=1/a;this.x*=b;this.y*=b}return a};goog.exportProperty(box2d.b2Vec2.prototype,"Normalize",box2d.b2Vec2.prototype.Normalize);box2d.b2Vec2.prototype.SelfNormalize=function(){this.Normalize();return this};
+goog.exportProperty(box2d.b2Vec2.prototype,"SelfNormalize",box2d.b2Vec2.prototype.SelfNormalize);box2d.b2Vec2.prototype.SelfRotate=function(a,b){var c=this.x,d=this.y;this.x=a*c-b*d;this.y=b*c+a*d;return this};goog.exportProperty(box2d.b2Vec2.prototype,"SelfRotate",box2d.b2Vec2.prototype.SelfRotate);box2d.b2Vec2.prototype.SelfRotateAngle=function(a){return this.SelfRotate(Math.cos(a),Math.sin(a))};goog.exportProperty(box2d.b2Vec2.prototype,"SelfRotateAngle",box2d.b2Vec2.prototype.SelfRotateAngle);
+box2d.b2Vec2.prototype.IsValid=function(){return isFinite(this.x)&&isFinite(this.y)};goog.exportProperty(box2d.b2Vec2.prototype,"IsValid",box2d.b2Vec2.prototype.IsValid);box2d.b2Vec2.prototype.SelfMin=function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);return this};goog.exportProperty(box2d.b2Vec2.prototype,"SelfMin",box2d.b2Vec2.prototype.SelfMin);box2d.b2Vec2.prototype.SelfMax=function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);return this};
+goog.exportProperty(box2d.b2Vec2.prototype,"SelfMax",box2d.b2Vec2.prototype.SelfMax);box2d.b2Vec2.prototype.SelfAbs=function(){this.x=Math.abs(this.x);this.y=Math.abs(this.y);return this};goog.exportProperty(box2d.b2Vec2.prototype,"SelfAbs",box2d.b2Vec2.prototype.SelfAbs);box2d.b2Vec2.prototype.SelfNeg=function(){this.x=-this.x;this.y=-this.y;return this};goog.exportProperty(box2d.b2Vec2.prototype,"SelfNeg",box2d.b2Vec2.prototype.SelfNeg);
+box2d.b2Vec2.prototype.SelfSkew=function(){var a=this.x;this.x=-this.y;this.y=a;return this};goog.exportProperty(box2d.b2Vec2.prototype,"SelfSkew",box2d.b2Vec2.prototype.SelfSkew);box2d.b2Abs_V2=function(a,b){b.x=Math.abs(a.x);b.y=Math.abs(a.y);return b};goog.exportSymbol("box2d.b2Abs_V2",box2d.b2Abs_V2);box2d.b2Min_V2_V2=function(a,b,c){c.x=Math.min(a.x,b.x);c.y=Math.min(a.y,b.y);return c};goog.exportSymbol("box2d.b2Min_V2_V2",box2d.b2Min_V2_V2);
+box2d.b2Max_V2_V2=function(a,b,c){c.x=Math.max(a.x,b.x);c.y=Math.max(a.y,b.y);return c};goog.exportSymbol("box2d.b2Max_V2_V2",box2d.b2Max_V2_V2);box2d.b2Clamp_V2_V2_V2=function(a,b,c,d){d.x=Math.min(Math.max(a.x,b.x),c.x);d.y=Math.min(Math.max(a.y,b.y),c.y);return d};goog.exportSymbol("box2d.b2Clamp_V2_V2_V2",box2d.b2Clamp_V2_V2_V2);box2d.b2Dot_V2_V2=function(a,b){return a.x*b.x+a.y*b.y};goog.exportSymbol("box2d.b2Dot_V2_V2",box2d.b2Dot_V2_V2);
+box2d.b2Cross_V2_V2=function(a,b){return a.x*b.y-a.y*b.x};goog.exportSymbol("box2d.b2Cross_V2_V2",box2d.b2Cross_V2_V2);box2d.b2Cross_V2_S=function(a,b,c){var d=a.x;c.x=b*a.y;c.y=-b*d;return c};goog.exportSymbol("box2d.b2Cross_V2_S",box2d.b2Cross_V2_S);box2d.b2Cross_S_V2=function(a,b,c){var d=b.x;c.x=-a*b.y;c.y=a*d;return c};goog.exportSymbol("box2d.b2Cross_S_V2",box2d.b2Cross_S_V2);box2d.b2Add_V2_V2=function(a,b,c){c.x=a.x+b.x;c.y=a.y+b.y;return c};goog.exportSymbol("box2d.b2Add_V2_V2",box2d.b2Add_V2_V2);
+box2d.b2Sub_V2_V2=function(a,b,c){c.x=a.x-b.x;c.y=a.y-b.y;return c};goog.exportSymbol("box2d.b2Sub_V2_V2",box2d.b2Sub_V2_V2);box2d.b2Add_V2_S=function(a,b,c){c.x=a.x+b;c.y=a.y+b;return c};goog.exportSymbol("box2d.b2Add_V2_S",box2d.b2Add_V2_S);box2d.b2Sub_V2_S=function(a,b,c){c.x=a.x-b;c.y=a.y-b;return c};goog.exportSymbol("box2d.b2Sub_V2_S",box2d.b2Sub_V2_S);box2d.b2Mul_S_V2=function(a,b,c){c.x=b.x*a;c.y=b.y*a;return c};goog.exportSymbol("box2d.b2Mul_S_V2",box2d.b2Mul_S_V2);
+box2d.b2Mul_V2_S=function(a,b,c){c.x=a.x*b;c.y=a.y*b;return c};goog.exportSymbol("box2d.b2Mul_V2_S",box2d.b2Mul_V2_S);box2d.b2Div_V2_S=function(a,b,c){c.x=a.x/b;c.y=a.y/b;return c};goog.exportSymbol("box2d.b2Div_V2_S",box2d.b2Div_V2_S);box2d.b2AddMul_V2_S_V2=function(a,b,c,d){d.x=a.x+b*c.x;d.y=a.y+b*c.y;return d};goog.exportSymbol("box2d.b2AddMul_V2_S_V2",box2d.b2AddMul_V2_S_V2);box2d.b2SubMul_V2_S_V2=function(a,b,c,d){d.x=a.x-b*c.x;d.y=a.y-b*c.y;return d};
+goog.exportSymbol("box2d.b2SubMul_V2_S_V2",box2d.b2SubMul_V2_S_V2);box2d.b2AddCross_V2_S_V2=function(a,b,c,d){var e=c.x;d.x=a.x-b*c.y;d.y=a.y+b*e;return d};goog.exportSymbol("box2d.b2AddCross_V2_S_V2",box2d.b2AddCross_V2_S_V2);box2d.b2Mid_V2_V2=function(a,b,c){c.x=.5*(a.x+b.x);c.y=.5*(a.y+b.y);return c};goog.exportSymbol("box2d.b2Mid_V2_V2",box2d.b2Mid_V2_V2);box2d.b2Ext_V2_V2=function(a,b,c){c.x=.5*(b.x-a.x);c.y=.5*(b.y-a.y);return c};goog.exportSymbol("box2d.b2Ext_V2_V2",box2d.b2Ext_V2_V2);
+box2d.b2Distance=function(a,b){var c=a.x-b.x,d=a.y-b.y;return Math.sqrt(c*c+d*d)};goog.exportSymbol("box2d.b2Distance",box2d.b2Distance);box2d.b2DistanceSquared=function(a,b){var c=a.x-b.x,d=a.y-b.y;return c*c+d*d};goog.exportSymbol("box2d.b2DistanceSquared",box2d.b2DistanceSquared);box2d.b2Vec3=function(a,b,c){this.x=a||0;this.y=b||0;this.z=c||0};goog.exportSymbol("box2d.b2Vec3",box2d.b2Vec3);box2d.b2Vec3.prototype.x=0;goog.exportProperty(box2d.b2Vec3.prototype,"x",box2d.b2Vec3.prototype.x);
+box2d.b2Vec3.prototype.y=0;goog.exportProperty(box2d.b2Vec3.prototype,"y",box2d.b2Vec3.prototype.y);box2d.b2Vec3.prototype.z=0;goog.exportProperty(box2d.b2Vec3.prototype,"z",box2d.b2Vec3.prototype.z);box2d.b2Vec3.ZERO=new box2d.b2Vec3;goog.exportProperty(box2d.b2Vec3,"ZERO",box2d.b2Vec3.ZERO);box2d.b2Vec3.s_t0=new box2d.b2Vec3;goog.exportProperty(box2d.b2Vec3,"s_t0",box2d.b2Vec3.s_t0);box2d.b2Vec3.prototype.Clone=function(){return new box2d.b2Vec3(this.x,this.y,this.z)};
+goog.exportProperty(box2d.b2Vec3.prototype,"Clone",box2d.b2Vec3.prototype.Clone);box2d.b2Vec3.prototype.SetZero=function(){this.z=this.y=this.x=0;return this};goog.exportProperty(box2d.b2Vec3.prototype,"SetZero",box2d.b2Vec3.prototype.SetZero);box2d.b2Vec3.prototype.Set=function(a,b,c){this.x=a;this.y=b;this.z=c;return this};goog.exportProperty(box2d.b2Vec3.prototype,"Set",box2d.b2Vec3.prototype.Set);box2d.b2Vec3.prototype.Copy=function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this};
+goog.exportProperty(box2d.b2Vec3.prototype,"Copy",box2d.b2Vec3.prototype.Copy);box2d.b2Vec3.prototype.SelfNeg=function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this};goog.exportProperty(box2d.b2Vec3.prototype,"SelfNeg",box2d.b2Vec3.prototype.SelfNeg);box2d.b2Vec3.prototype.SelfAdd=function(a){this.x+=a.x;this.y+=a.y;this.z+=a.z;return this};goog.exportProperty(box2d.b2Vec3.prototype,"SelfAdd",box2d.b2Vec3.prototype.SelfAdd);
+box2d.b2Vec3.prototype.SelfAddV2=function(a,b){this.x+=a.x;this.y+=a.y;this.z+=b;return this};goog.exportProperty(box2d.b2Vec3.prototype,"SelfAddV2",box2d.b2Vec3.prototype.SelfAddV2);box2d.b2Vec3.prototype.SelfAddXYZ=function(a,b,c){this.x+=a;this.y+=b;this.z+=c;return this};goog.exportProperty(box2d.b2Vec3.prototype,"SelfAddXYZ",box2d.b2Vec3.prototype.SelfAddXYZ);box2d.b2Vec3.prototype.SelfSub=function(a){this.x-=a.x;this.y-=a.y;this.z-=a.z;return this};
+goog.exportProperty(box2d.b2Vec3.prototype,"SelfSub",box2d.b2Vec3.prototype.SelfSub);box2d.b2Vec3.prototype.SelfSubV2=function(a,b){this.x-=a.x;this.y-=a.y;this.z-=b;return this};goog.exportProperty(box2d.b2Vec3.prototype,"SelfSubV2",box2d.b2Vec3.prototype.SelfSubV2);box2d.b2Vec3.prototype.SelfSubXYZ=function(a,b,c){this.x-=a;this.y-=b;this.z-=c;return this};goog.exportProperty(box2d.b2Vec3.prototype,"SelfSubXYZ",box2d.b2Vec3.prototype.SelfSubXYZ);
+box2d.b2Vec3.prototype.SelfMul=function(a){this.x*=a.x;this.y*=a.y;this.z*=a.z;return this};goog.exportProperty(box2d.b2Vec3.prototype,"SelfMul",box2d.b2Vec3.prototype.SelfMul);box2d.b2Vec3.prototype.SelfMulV2=function(a,b){this.x*=a.x;this.y*=a.y;this.z*=b;return this};goog.exportProperty(box2d.b2Vec3.prototype,"SelfMulV2",box2d.b2Vec3.prototype.SelfMulV2);box2d.b2Vec3.prototype.SelfMulXYZ=function(a,b,c){this.x*=a;this.y*=b;this.z*=c;return this};
+goog.exportProperty(box2d.b2Vec3.prototype,"SelfMulXYZ",box2d.b2Vec3.prototype.SelfMulXYZ);box2d.b2Vec3.prototype.SelfMulScalar=function(a){this.x*=a;this.y*=a;this.z*=a;return this};goog.exportProperty(box2d.b2Vec3.prototype,"SelfMulScalar",box2d.b2Vec3.prototype.SelfMulScalar);box2d.b2Vec3.prototype.Length=function(){var a=this.x,b=this.y,c=this.z;return Math.sqrt(a*a+b*b+c*c)};goog.exportProperty(box2d.b2Vec3.prototype,"Length",box2d.b2Vec3.prototype.Length);
+box2d.b2Vec3.prototype.LengthSquared=function(){var a=this.x,b=this.y,c=this.z;return a*a+b*b+c*c};goog.exportProperty(box2d.b2Vec3.prototype,"LengthSquared",box2d.b2Vec3.prototype.LengthSquared);box2d.b2Vec3.prototype.Normalize=function(){var a=this.Length();if(a>=box2d.b2_epsilon){var b=1/a;this.x*=b;this.y*=b;this.z*=b}return a};goog.exportProperty(box2d.b2Vec3.prototype,"Normalize",box2d.b2Vec3.prototype.Normalize);box2d.b2Vec3.prototype.SelfNormalize=function(){this.Normalize();return this};
+goog.exportProperty(box2d.b2Vec3.prototype,"SelfNormalize",box2d.b2Vec3.prototype.SelfNormalize);box2d.b2Add_V3_V3=function(a,b,c){c.x=a.x+b.x;c.y=a.y+b.y;c.z=a.z+b.z;return c};goog.exportSymbol("box2d.b2Add_V3_V3",box2d.b2Add_V3_V3);box2d.b2Sub_V3_V3=function(a,b,c){c.x=a.x+b.x;c.y=a.y+b.y;c.z=a.z+b.z;return c};goog.exportSymbol("box2d.b2Sub_V3_V3",box2d.b2Sub_V3_V3);box2d.b2Dot_V3_V3=function(a,b){return a.x*b.x+a.y*b.y+a.z*b.z};goog.exportSymbol("box2d.b2Dot_V3_V3",box2d.b2Dot_V3_V3);
+box2d.b2Cross_V3_V3=function(a,b,c){var d=a.x,e=a.y;a=a.z;var f=b.x,g=b.y;b=b.z;c.x=e*b-a*g;c.y=a*f-d*b;c.z=d*g-e*f;return c};goog.exportSymbol("box2d.b2Cross_V3_V3",box2d.b2Cross_V3_V3);box2d.b2Vec4=function(a,b,c,d){this.x=a||0;this.y=b||0;this.z=c||0;this.w=d||0};goog.exportSymbol("box2d.b2Vec4",box2d.b2Vec4);box2d.b2Vec4.prototype.x=0;goog.exportProperty(box2d.b2Vec4.prototype,"x",box2d.b2Vec4.prototype.x);box2d.b2Vec4.prototype.y=0;goog.exportProperty(box2d.b2Vec4.prototype,"y",box2d.b2Vec4.prototype.y);
+box2d.b2Vec4.prototype.z=0;goog.exportProperty(box2d.b2Vec4.prototype,"z",box2d.b2Vec4.prototype.z);box2d.b2Vec4.prototype.w=0;goog.exportProperty(box2d.b2Vec4.prototype,"w",box2d.b2Vec4.prototype.w);box2d.b2Vec4.ZERO=new box2d.b2Vec4(0,0,0,0);goog.exportProperty(box2d.b2Vec4,"ZERO",box2d.b2Vec4.ZERO);box2d.b2Vec4.s_t0=new box2d.b2Vec4;goog.exportProperty(box2d.b2Vec4,"s_t0",box2d.b2Vec4.s_t0);box2d.b2Vec4.prototype.Clone=function(){return new box2d.b2Vec4(this.x,this.y,this.z,this.w)};
+goog.exportProperty(box2d.b2Vec4.prototype,"Clone",box2d.b2Vec4.prototype.Clone);box2d.b2Vec4.prototype.SetZero=function(){this.w=this.z=this.y=this.x=0;return this};goog.exportProperty(box2d.b2Vec4.prototype,"SetZero",box2d.b2Vec4.prototype.SetZero);box2d.b2Vec4.prototype.Set=function(a,b,c,d){this.x=a;this.y=b;this.z=c;this.w=d;return this};goog.exportProperty(box2d.b2Vec4.prototype,"Set",box2d.b2Vec4.prototype.Set);
+box2d.b2Vec4.prototype.Copy=function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=a.w;return this};goog.exportProperty(box2d.b2Vec4.prototype,"Copy",box2d.b2Vec4.prototype.Copy);box2d.b2Mat22=function(){this.ex=new box2d.b2Vec2(1,0);this.ey=new box2d.b2Vec2(0,1)};goog.exportSymbol("box2d.b2Mat22",box2d.b2Mat22);box2d.b2Mat22.prototype.ex=null;goog.exportProperty(box2d.b2Mat22.prototype,"ex",box2d.b2Mat22.prototype.ex);box2d.b2Mat22.prototype.ey=null;
+goog.exportProperty(box2d.b2Mat22.prototype,"ey",box2d.b2Mat22.prototype.ey);box2d.b2Mat22.IDENTITY=new box2d.b2Mat22;goog.exportProperty(box2d.b2Mat22,"IDENTITY",box2d.b2Mat22.IDENTITY);box2d.b2Mat22.prototype.Clone=function(){return(new box2d.b2Mat22).Copy(this)};goog.exportProperty(box2d.b2Mat22.prototype,"Clone",box2d.b2Mat22.prototype.Clone);box2d.b2Mat22.prototype.SetAngle=function(a){var b=Math.cos(a);a=Math.sin(a);this.ex.Set(b,a);this.ey.Set(-a,b);return this};
+goog.exportProperty(box2d.b2Mat22.prototype,"SetAngle",box2d.b2Mat22.prototype.SetAngle);box2d.b2Mat22.prototype.Copy=function(a){this.ex.Copy(a.ex);this.ey.Copy(a.ey);return this};goog.exportProperty(box2d.b2Mat22.prototype,"Copy",box2d.b2Mat22.prototype.Copy);box2d.b2Mat22.prototype.SetIdentity=function(){this.ex.Set(1,0);this.ey.Set(0,1);return this};goog.exportProperty(box2d.b2Mat22.prototype,"SetIdentity",box2d.b2Mat22.prototype.SetIdentity);
+box2d.b2Mat22.prototype.SetZero=function(){this.ex.SetZero();this.ey.SetZero();return this};goog.exportProperty(box2d.b2Mat22.prototype,"SetZero",box2d.b2Mat22.prototype.SetZero);box2d.b2Mat22.prototype.GetAngle=function(){return Math.atan2(this.ex.y,this.ex.x)};goog.exportProperty(box2d.b2Mat22.prototype,"GetAngle",box2d.b2Mat22.prototype.GetAngle);
+box2d.b2Mat22.prototype.GetInverse=function(a){var b=this.ex.x,c=this.ey.x,d=this.ex.y,e=this.ey.y,f=b*e-c*d;0!==f&&(f=1/f);a.ex.x=f*e;a.ey.x=-f*c;a.ex.y=-f*d;a.ey.y=f*b;return a};goog.exportProperty(box2d.b2Mat22.prototype,"GetInverse",box2d.b2Mat22.prototype.GetInverse);box2d.b2Mat22.prototype.Solve=function(a,b,c){var d=this.ex.x,e=this.ey.x,f=this.ex.y,g=this.ey.y,h=d*g-e*f;0!==h&&(h=1/h);c.x=h*(g*a-e*b);c.y=h*(d*b-f*a);return c};goog.exportProperty(box2d.b2Mat22.prototype,"Solve",box2d.b2Mat22.prototype.Solve);
+box2d.b2Mat22.prototype.SelfAbs=function(){this.ex.SelfAbs();this.ey.SelfAbs();return this};goog.exportProperty(box2d.b2Mat22.prototype,"SelfAbs",box2d.b2Mat22.prototype.SelfAbs);box2d.b2Mat22.prototype.SelfInv=function(){return this.GetInverse(this)};goog.exportProperty(box2d.b2Mat22.prototype,"SelfInv",box2d.b2Mat22.prototype.SelfInv);box2d.b2Mat22.prototype.SelfAdd=function(a){this.ex.SelfAdd(a.ex);this.ey.SelfAdd(a.ey);return this};goog.exportProperty(box2d.b2Mat22.prototype,"SelfAdd",box2d.b2Mat22.prototype.SelfAdd);
+box2d.b2Mat22.prototype.SelfSub=function(a){this.ex.SelfSub(a.ex);this.ey.SelfSub(a.ey);return this};goog.exportProperty(box2d.b2Mat22.prototype,"SelfSub",box2d.b2Mat22.prototype.SelfSub);box2d.b2Abs_M22=function(a,b){var c=a.ex,d=a.ey;b.ex.x=box2d.b2Abs(c.x);b.ex.y=box2d.b2Abs(c.y);b.ey.x=box2d.b2Abs(d.x);b.ey.y=box2d.b2Abs(d.y);return b};goog.exportSymbol("box2d.b2Abs_M22",box2d.b2Abs_M22);box2d.b2Mul_M22_V2=function(a,b,c){var d=a.ex;a=a.ey;var e=b.x;b=b.y;c.x=d.x*e+a.x*b;c.y=d.y*e+a.y*b;return c};
+goog.exportSymbol("box2d.b2Mul_M22_V2",box2d.b2Mul_M22_V2);box2d.b2MulT_M22_V2=function(a,b,c){var d=a.ex;a=a.ey;var e=b.x;b=b.y;c.x=d.x*e+d.y*b;c.y=a.x*e+a.y*b;return c};goog.exportSymbol("box2d.b2MulT_M22_V2",box2d.b2MulT_M22_V2);box2d.b2Add_M22_M22=function(a,b,c){var d=a.ex;a=a.ey;var e=b.ex;b=b.ey;c.ex.x=d.x+e.x;c.ex.y=d.y+e.y;c.ey.x=a.x+b.x;c.ey.y=a.y+b.y;return c};goog.exportSymbol("box2d.b2Add_M22_M22",box2d.b2Add_M22_M22);
+box2d.b2Mul_M22_M22=function(a,b,c){var d=a.ex.x,e=a.ex.y,f=a.ey.x;a=a.ey.y;var g=b.ex.x,h=b.ex.y,k=b.ey.x;b=b.ey.y;c.ex.x=d*g+f*h;c.ex.y=e*g+a*h;c.ey.x=d*k+f*b;c.ey.y=e*k+a*b;return c};goog.exportSymbol("box2d.b2Mul_M22_M22",box2d.b2Mul_M22_M22);box2d.b2MulT_M22_M22=function(a,b,c){var d=a.ex.x,e=a.ex.y,f=a.ey.x;a=a.ey.y;var g=b.ex.x,h=b.ex.y,k=b.ey.x;b=b.ey.y;c.ex.x=d*g+e*h;c.ex.y=f*g+a*h;c.ey.x=d*k+e*b;c.ey.y=f*k+a*b;return c};goog.exportSymbol("box2d.b2MulT_M22_M22",box2d.b2MulT_M22_M22);
+box2d.b2Mat33=function(){this.ex=new box2d.b2Vec3(1,0,0);this.ey=new box2d.b2Vec3(0,1,0);this.ez=new box2d.b2Vec3(0,0,1)};goog.exportSymbol("box2d.b2Mat33",box2d.b2Mat33);box2d.b2Mat33.prototype.ex=null;goog.exportProperty(box2d.b2Mat33.prototype,"ex",box2d.b2Mat33.prototype.ex);box2d.b2Mat33.prototype.ey=null;goog.exportProperty(box2d.b2Mat33.prototype,"ey",box2d.b2Mat33.prototype.ey);box2d.b2Mat33.prototype.ez=null;goog.exportProperty(box2d.b2Mat33.prototype,"ez",box2d.b2Mat33.prototype.ez);
+box2d.b2Mat33.IDENTITY=new box2d.b2Mat33;goog.exportProperty(box2d.b2Mat33,"IDENTITY",box2d.b2Mat33.IDENTITY);box2d.b2Mat33.prototype.Clone=function(){return(new box2d.b2Mat33).Copy(this)};goog.exportProperty(box2d.b2Mat33.prototype,"Clone",box2d.b2Mat33.prototype.Clone);box2d.b2Mat33.prototype.Copy=function(a){this.ex.Copy(a.ex);this.ey.Copy(a.ey);this.ez.Copy(a.ez);return this};goog.exportProperty(box2d.b2Mat33.prototype,"Copy",box2d.b2Mat33.prototype.Copy);
+box2d.b2Mat33.prototype.SetIdentity=function(){this.ex.Set(1,0,0);this.ey.Set(0,1,0);this.ez.Set(0,0,1);return this};goog.exportProperty(box2d.b2Mat33.prototype,"SetIdentity",box2d.b2Mat33.prototype.SetIdentity);box2d.b2Mat33.prototype.SetZero=function(){this.ex.SetZero();this.ey.SetZero();this.ez.SetZero();return this};goog.exportProperty(box2d.b2Mat33.prototype,"SetZero",box2d.b2Mat33.prototype.SetZero);
+box2d.b2Mat33.prototype.SelfAdd=function(a){this.ex.SelfAdd(a.ex);this.ey.SelfAdd(a.ey);this.ez.SelfAdd(a.ez);return this};goog.exportProperty(box2d.b2Mat33.prototype,"SelfAdd",box2d.b2Mat33.prototype.SelfAdd);
+box2d.b2Mat33.prototype.Solve33=function(a,b,c,d){var e=this.ex.x,f=this.ex.y,g=this.ex.z,h=this.ey.x,k=this.ey.y,l=this.ey.z,m=this.ez.x,n=this.ez.y,p=this.ez.z,q=e*(k*p-l*n)+f*(l*m-h*p)+g*(h*n-k*m);0!==q&&(q=1/q);d.x=q*(a*(k*p-l*n)+b*(l*m-h*p)+c*(h*n-k*m));d.y=q*(e*(b*p-c*n)+f*(c*m-a*p)+g*(a*n-b*m));d.z=q*(e*(k*c-l*b)+f*(l*a-h*c)+g*(h*b-k*a));return d};goog.exportProperty(box2d.b2Mat33.prototype,"Solve33",box2d.b2Mat33.prototype.Solve33);
+box2d.b2Mat33.prototype.Solve22=function(a,b,c){var d=this.ex.x,e=this.ey.x,f=this.ex.y,g=this.ey.y,h=d*g-e*f;0!==h&&(h=1/h);c.x=h*(g*a-e*b);c.y=h*(d*b-f*a);return c};goog.exportProperty(box2d.b2Mat33.prototype,"Solve22",box2d.b2Mat33.prototype.Solve22);box2d.b2Mat33.prototype.GetInverse22=function(a){var b=this.ex.x,c=this.ey.x,d=this.ex.y,e=this.ey.y,f=b*e-c*d;0!==f&&(f=1/f);a.ex.x=f*e;a.ey.x=-f*c;a.ex.z=0;a.ex.y=-f*d;a.ey.y=f*b;a.ey.z=0;a.ez.x=0;a.ez.y=0;a.ez.z=0};
+goog.exportProperty(box2d.b2Mat33.prototype,"GetInverse22",box2d.b2Mat33.prototype.GetInverse22);box2d.b2Mat33.prototype.GetSymInverse33=function(a){var b=box2d.b2Dot_V3_V3(this.ex,box2d.b2Cross_V3_V3(this.ey,this.ez,box2d.b2Vec3.s_t0));0!==b&&(b=1/b);var c=this.ex.x,d=this.ey.x,e=this.ez.x,f=this.ey.y,g=this.ez.y,h=this.ez.z;a.ex.x=b*(f*h-g*g);a.ex.y=b*(e*g-d*h);a.ex.z=b*(d*g-e*f);a.ey.x=a.ex.y;a.ey.y=b*(c*h-e*e);a.ey.z=b*(e*d-c*g);a.ez.x=a.ex.z;a.ez.y=a.ey.z;a.ez.z=b*(c*f-d*d)};
+goog.exportProperty(box2d.b2Mat33.prototype,"GetSymInverse33",box2d.b2Mat33.prototype.GetSymInverse33);box2d.b2Mul_M33_V3=function(a,b,c){var d=b.x,e=b.y;b=b.z;c.x=a.ex.x*d+a.ey.x*e+a.ez.x*b;c.y=a.ex.y*d+a.ey.y*e+a.ez.y*b;c.z=a.ex.z*d+a.ey.z*e+a.ez.z*b;return c};goog.exportSymbol("box2d.b2Mul_M33_V3",box2d.b2Mul_M33_V3);box2d.b2Mul_M33_X_Y_Z=function(a,b,c,d,e){e.x=a.ex.x*b+a.ey.x*c+a.ez.x*d;e.y=a.ex.y*b+a.ey.y*c+a.ez.y*d;e.z=a.ex.z*b+a.ey.z*c+a.ez.z*d;return e};
+goog.exportSymbol("box2d.b2Mul_M33_X_Y_Z",box2d.b2Mul_M33_X_Y_Z);box2d.b2Mul22_M33_V2=function(a,b,c){var d=b.x;b=b.y;c.x=a.ex.x*d+a.ey.x*b;c.y=a.ex.y*d+a.ey.y*b;return c};goog.exportSymbol("box2d.b2Mul22_M33_V2",box2d.b2Mul22_M33_V2);box2d.b2Mul_M33_X_Y=function(a,b,c,d){d.x=a.ex.x*b+a.ey.x*c;d.y=a.ex.y*b+a.ey.y*c;return d};goog.exportSymbol("box2d.b2Mul_M33_X_Y",box2d.b2Mul_M33_X_Y);box2d.b2Rot=function(a){a&&(this.angle=a,this.s=Math.sin(a),this.c=Math.cos(a))};
+goog.exportSymbol("box2d.b2Rot",box2d.b2Rot);box2d.b2Rot.prototype.angle=0;goog.exportProperty(box2d.b2Rot.prototype,"angle",box2d.b2Rot.prototype.angle);box2d.b2Rot.prototype.s=0;goog.exportProperty(box2d.b2Rot.prototype,"s",box2d.b2Rot.prototype.s);box2d.b2Rot.prototype.c=1;goog.exportProperty(box2d.b2Rot.prototype,"c",box2d.b2Rot.prototype.c);box2d.b2Rot.IDENTITY=new box2d.b2Rot;goog.exportProperty(box2d.b2Rot,"IDENTITY",box2d.b2Rot.IDENTITY);box2d.b2Rot.prototype.Clone=function(){return(new box2d.b2Rot).Copy(this)};
+goog.exportProperty(box2d.b2Rot.prototype,"Clone",box2d.b2Rot.prototype.Clone);box2d.b2Rot.prototype.Copy=function(a){this.angle=a.angle;this.s=a.s;this.c=a.c;return this};goog.exportProperty(box2d.b2Rot.prototype,"Copy",box2d.b2Rot.prototype.Copy);box2d.b2Rot.prototype.Set=function(a){Math.abs(this.angle-a)>=box2d.b2_epsilon&&(this.angle=a,this.s=Math.sin(a),this.c=Math.cos(a));return this};goog.exportProperty(box2d.b2Rot.prototype,"Set",box2d.b2Rot.prototype.Set);
+box2d.b2Rot.prototype.SetAngle=box2d.b2Rot.prototype.Set;goog.exportProperty(box2d.b2Rot.prototype,"SetAngle",box2d.b2Rot.prototype.SetAngle);box2d.b2Rot.prototype.SetIdentity=function(){this.s=this.angle=0;this.c=1;return this};goog.exportProperty(box2d.b2Rot.prototype,"SetIdentity",box2d.b2Rot.prototype.SetIdentity);box2d.b2Rot.prototype.GetAngle=function(){return this.angle};goog.exportProperty(box2d.b2Rot.prototype,"GetAngle",box2d.b2Rot.prototype.GetAngle);
+box2d.b2Rot.prototype.GetXAxis=function(a){a.x=this.c;a.y=this.s;return a};goog.exportProperty(box2d.b2Rot.prototype,"GetXAxis",box2d.b2Rot.prototype.GetXAxis);box2d.b2Rot.prototype.GetYAxis=function(a){a.x=-this.s;a.y=this.c;return a};goog.exportProperty(box2d.b2Rot.prototype,"GetYAxis",box2d.b2Rot.prototype.GetYAxis);box2d.b2Mul_R_R=function(a,b,c){var d=a.c,e=a.s,f=b.c,g=b.s;c.s=e*f+d*g;c.c=d*f-e*g;c.angle=box2d.b2WrapAngle(a.angle+b.angle);return c};goog.exportSymbol("box2d.b2Mul_R_R",box2d.b2Mul_R_R);
+box2d.b2MulT_R_R=function(a,b,c){var d=a.c,e=a.s,f=b.c,g=b.s;c.s=d*g-e*f;c.c=d*f+e*g;c.angle=box2d.b2WrapAngle(a.angle-b.angle);return c};goog.exportSymbol("box2d.b2MulT_R_R",box2d.b2MulT_R_R);box2d.b2Mul_R_V2=function(a,b,c){var d=a.c;a=a.s;var e=b.x;b=b.y;c.x=d*e-a*b;c.y=a*e+d*b;return c};goog.exportSymbol("box2d.b2Mul_R_V2",box2d.b2Mul_R_V2);box2d.b2MulT_R_V2=function(a,b,c){var d=a.c;a=a.s;var e=b.x;b=b.y;c.x=d*e+a*b;c.y=-a*e+d*b;return c};goog.exportSymbol("box2d.b2MulT_R_V2",box2d.b2MulT_R_V2);
+box2d.b2Transform=function(){this.p=new box2d.b2Vec2;this.q=new box2d.b2Rot};goog.exportSymbol("box2d.b2Transform",box2d.b2Transform);box2d.b2Transform.prototype.p=null;goog.exportProperty(box2d.b2Transform.prototype,"p",box2d.b2Transform.prototype.p);box2d.b2Transform.prototype.q=null;goog.exportProperty(box2d.b2Transform.prototype,"q",box2d.b2Transform.prototype.q);box2d.b2Transform.IDENTITY=new box2d.b2Transform;goog.exportProperty(box2d.b2Transform,"IDENTITY",box2d.b2Transform.IDENTITY);
+box2d.b2Transform.prototype.Clone=function(){return(new box2d.b2Transform).Copy(this)};goog.exportProperty(box2d.b2Transform.prototype,"Clone",box2d.b2Transform.prototype.Clone);box2d.b2Transform.prototype.Copy=function(a){this.p.Copy(a.p);this.q.Copy(a.q);return this};goog.exportProperty(box2d.b2Transform.prototype,"Copy",box2d.b2Transform.prototype.Copy);box2d.b2Transform.prototype.SetIdentity=function(){this.p.SetZero();this.q.SetIdentity();return this};
+goog.exportProperty(box2d.b2Transform.prototype,"SetIdentity",box2d.b2Transform.prototype.SetIdentity);box2d.b2Transform.prototype.Set=function(a,b){return this.SetPositionRotationAngle(a,b)};box2d.b2Transform.prototype.SetPositionRotation=function(a,b){this.p.Copy(a);this.q.Copy(b);return this};goog.exportProperty(box2d.b2Transform.prototype,"SetPositionRotation",box2d.b2Transform.prototype.SetPositionRotation);
+box2d.b2Transform.prototype.SetPositionRotationAngle=function(a,b){this.p.Copy(a);this.q.SetAngle(b);return this};goog.exportProperty(box2d.b2Transform.prototype,"SetPositionRotationAngle",box2d.b2Transform.prototype.SetPositionRotationAngle);box2d.b2Transform.prototype.SetPosition=function(a){this.p.Copy(a);return this};goog.exportProperty(box2d.b2Transform.prototype,"SetPosition",box2d.b2Transform.prototype.SetPosition);box2d.b2Transform.prototype.SetPositionXY=function(a,b){this.p.Set(a,b);return this};
+goog.exportProperty(box2d.b2Transform.prototype,"SetPositionXY",box2d.b2Transform.prototype.SetPositionXY);box2d.b2Transform.prototype.SetRotation=function(a){this.q.Copy(a);return this};goog.exportProperty(box2d.b2Transform.prototype,"SetRotation",box2d.b2Transform.prototype.SetRotation);box2d.b2Transform.prototype.SetRotationAngle=function(a){this.q.SetAngle(a);return this};goog.exportProperty(box2d.b2Transform.prototype,"SetRotationAngle",box2d.b2Transform.prototype.SetRotationAngle);
+box2d.b2Transform.prototype.GetPosition=function(){return this.p};goog.exportProperty(box2d.b2Transform.prototype,"GetPosition",box2d.b2Transform.prototype.GetPosition);box2d.b2Transform.prototype.GetRotation=function(){return this.q};goog.exportProperty(box2d.b2Transform.prototype,"GetRotation",box2d.b2Transform.prototype.GetRotation);box2d.b2Transform.prototype.GetRotationAngle=function(){return this.q.GetAngle()};goog.exportProperty(box2d.b2Transform.prototype,"GetRotationAngle",box2d.b2Transform.prototype.GetRotationAngle);
+box2d.b2Transform.prototype.GetAngle=function(){return this.q.GetAngle()};goog.exportProperty(box2d.b2Transform.prototype,"GetAngle",box2d.b2Transform.prototype.GetAngle);box2d.b2Mul_X_V2=function(a,b,c){var d=a.q.c,e=a.q.s,f=b.x;b=b.y;c.x=d*f-e*b+a.p.x;c.y=e*f+d*b+a.p.y;return c};goog.exportSymbol("box2d.b2Mul_X_V2",box2d.b2Mul_X_V2);box2d.b2MulT_X_V2=function(a,b,c){var d=a.q.c,e=a.q.s,f=b.x-a.p.x;a=b.y-a.p.y;c.x=d*f+e*a;c.y=-e*f+d*a;return c};goog.exportSymbol("box2d.b2MulT_X_V2",box2d.b2MulT_X_V2);
+box2d.b2Mul_X_X=function(a,b,c){box2d.b2Mul_R_R(a.q,b.q,c.q);box2d.b2Add_V2_V2(box2d.b2Mul_R_V2(a.q,b.p,c.p),a.p,c.p);return c};goog.exportSymbol("box2d.b2Mul_X_X",box2d.b2Mul_X_X);box2d.b2MulT_X_X=function(a,b,c){box2d.b2MulT_R_R(a.q,b.q,c.q);box2d.b2MulT_R_V2(a.q,box2d.b2Sub_V2_V2(b.p,a.p,c.p),c.p);return c};goog.exportSymbol("box2d.b2MulT_X_X",box2d.b2MulT_X_X);box2d.b2Sweep=function(){this.localCenter=new box2d.b2Vec2;this.c0=new box2d.b2Vec2;this.c=new box2d.b2Vec2};
+goog.exportSymbol("box2d.b2Sweep",box2d.b2Sweep);box2d.b2Sweep.prototype.localCenter=null;goog.exportProperty(box2d.b2Sweep.prototype,"localCenter",box2d.b2Sweep.prototype.localCenter);box2d.b2Sweep.prototype.c0=null;goog.exportProperty(box2d.b2Sweep.prototype,"c0",box2d.b2Sweep.prototype.c0);box2d.b2Sweep.prototype.c=null;goog.exportProperty(box2d.b2Sweep.prototype,"c",box2d.b2Sweep.prototype.c);box2d.b2Sweep.prototype.a0=0;goog.exportProperty(box2d.b2Sweep.prototype,"a0",box2d.b2Sweep.prototype.a0);
+box2d.b2Sweep.prototype.a=0;goog.exportProperty(box2d.b2Sweep.prototype,"a",box2d.b2Sweep.prototype.a);box2d.b2Sweep.prototype.alpha0=0;goog.exportProperty(box2d.b2Sweep.prototype,"alpha0",box2d.b2Sweep.prototype.alpha0);box2d.b2Sweep.prototype.Clone=function(){return(new box2d.b2Sweep).Copy(this)};goog.exportProperty(box2d.b2Sweep.prototype,"Clone",box2d.b2Sweep.prototype.Clone);
+box2d.b2Sweep.prototype.Copy=function(a){this.localCenter.Copy(a.localCenter);this.c0.Copy(a.c0);this.c.Copy(a.c);this.a0=a.a0;this.a=a.a;this.alpha0=a.alpha0;return this};goog.exportProperty(box2d.b2Sweep.prototype,"Copy",box2d.b2Sweep.prototype.Copy);box2d.b2Sweep.prototype.GetTransform=function(a,b){var c=1-b;a.p.x=c*this.c0.x+b*this.c.x;a.p.y=c*this.c0.y+b*this.c.y;a.q.SetAngle(c*this.a0+b*this.a);a.p.SelfSub(box2d.b2Mul_R_V2(a.q,this.localCenter,box2d.b2Vec2.s_t0));return a};
+goog.exportProperty(box2d.b2Sweep.prototype,"GetTransform",box2d.b2Sweep.prototype.GetTransform);box2d.b2Sweep.prototype.Advance=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(1>this.alpha0);var b=(a-this.alpha0)/(1-this.alpha0);this.c0.x+=b*(this.c.x-this.c0.x);this.c0.y+=b*(this.c.y-this.c0.y);this.a0+=b*(this.a-this.a0);this.alpha0=a};goog.exportProperty(box2d.b2Sweep.prototype,"Advance",box2d.b2Sweep.prototype.Advance);
+box2d.b2Sweep.prototype.Normalize=function(){this.a0=box2d.b2WrapAngle(this.a0);this.a=box2d.b2WrapAngle(this.a)};goog.exportProperty(box2d.b2Sweep.prototype,"Normalize",box2d.b2Sweep.prototype.Normalize);box2d.b2Dot=function(a,b){if(a instanceof box2d.b2Vec2&&b instanceof box2d.b2Vec2)return box2d.b2Dot_V2_V2(a,b);if(a instanceof box2d.b2Vec3&&b instanceof box2d.b2Vec3)return box2d.b2Dot_V3_V3(a,b);throw Error();};goog.exportSymbol("box2d.b2Dot",box2d.b2Dot);
+box2d.b2Cross=function(a,b,c){if(a instanceof box2d.b2Vec2&&b instanceof box2d.b2Vec2)return box2d.b2Cross_V2_V2(a,b);if(a instanceof box2d.b2Vec2&&"number"===typeof b&&c instanceof box2d.b2Vec2)return box2d.b2Cross_V2_S(a,b,c);if("number"===typeof a&&b instanceof box2d.b2Vec2&&c instanceof box2d.b2Vec2)return box2d.b2Cross_S_V2(a,b,c);if(a instanceof box2d.b2Vec3&&b instanceof box2d.b2Vec3&&c instanceof box2d.b2Vec3)return box2d.b2Cross_V3_V3(a,b,c);throw Error();};
+goog.exportSymbol("box2d.b2Cross",box2d.b2Cross);box2d.b2Add=function(a,b,c){if(a instanceof box2d.b2Vec2&&b instanceof box2d.b2Vec2&&c instanceof box2d.b2Vec2)return box2d.b2Add_V2_V2(a,b,c);if(a instanceof box2d.b2Vec3&&b instanceof box2d.b2Vec3&&c instanceof box2d.b2Vec3)return box2d.b2Add_V3_V3(a,b,c);throw Error();};goog.exportSymbol("box2d.b2Add",box2d.b2Add);
+box2d.b2Sub=function(a,b,c){if(a instanceof box2d.b2Vec2&&b instanceof box2d.b2Vec2&&c instanceof box2d.b2Vec2)return box2d.b2Sub_V2_V2(a,b,c);if(a instanceof box2d.b2Vec3&&b instanceof box2d.b2Vec3&&c instanceof box2d.b2Vec3)return box2d.b2Sub_V3_V3(a,b,c);throw Error();};goog.exportSymbol("box2d.b2Sub",box2d.b2Sub);
+box2d.b2Mul=function(a,b,c){if(a instanceof box2d.b2Mat22&&b instanceof box2d.b2Vec2&&c instanceof box2d.b2Vec2)return box2d.b2Mul_M22_V2(a,b,c);if(a instanceof box2d.b2Mat22&&b instanceof box2d.b2Mat22&&c instanceof box2d.b2Mat22)return box2d.b2Mul_M22_M22(a,b,c);if(a instanceof box2d.b2Mat33&&b instanceof box2d.b2Vec3&&c instanceof box2d.b2Vec3)return box2d.b2Mul_M33_V3(a,b,c);if(a instanceof box2d.b2Rot&&b instanceof box2d.b2Rot&&c instanceof box2d.b2Rot)return box2d.b2Mul_R_R(a,b,c);if(a instanceof
+box2d.b2Rot&&b instanceof box2d.b2Vec2&&c instanceof box2d.b2Vec2)return box2d.b2Mul_R_V2(a,b,c);if(a instanceof box2d.b2Transform&&b instanceof box2d.b2Vec2&&c instanceof box2d.b2Vec2)return box2d.b2Mul_X_V2(a,b,c);if(a instanceof box2d.b2Transform&&b instanceof box2d.b2Transform&&c instanceof box2d.b2Transform)return box2d.b2Mul_X_X(a,b,c);throw Error();};goog.exportSymbol("box2d.b2Mul",box2d.b2Mul);
+box2d.b2Mul22=function(a,b,c){if(a instanceof box2d.b2Mat33&&b instanceof box2d.b2Vec2)return box2d.b2Mul22_M33_V2(a,b,c);throw Error();};goog.exportSymbol("box2d.b2Mul22",box2d.b2Mul22);
+box2d.b2MulT=function(a,b,c){if(a instanceof box2d.b2Mat22&&b instanceof box2d.b2Vec2&&c instanceof box2d.b2Vec2)return box2d.b2MulT_M22_V2(a,b,c);if(a instanceof box2d.b2Mat22&&b instanceof box2d.b2Mat22&&c instanceof box2d.b2Mat22)return box2d.b2MulT_M22_M22(a,b,c);if(a instanceof box2d.b2Rot&&b instanceof box2d.b2Rot&&c instanceof box2d.b2Rot)return box2d.b2MulT_R_R(a,b,c);if(a instanceof box2d.b2Rot&&b instanceof box2d.b2Vec2&&c instanceof box2d.b2Vec2)return box2d.b2MulT_R_V2(a,b,c);if(a instanceof
+box2d.b2Transform&&b instanceof box2d.b2Vec2&&c instanceof box2d.b2Vec2)return box2d.b2MulT_X_V2(a,b,c);if(a instanceof box2d.b2Transform&&b instanceof box2d.b2Transform&&c instanceof box2d.b2Transform)return box2d.b2MulT_X_X(a,b,c);throw Error();};goog.exportSymbol("box2d.b2MulT",box2d.b2MulT);box2d.b2DistanceProxy=function(){this.m_buffer=box2d.b2Vec2.MakeArray(2)};goog.exportSymbol("box2d.b2DistanceProxy",box2d.b2DistanceProxy);box2d.b2DistanceProxy.prototype.m_buffer=null;goog.exportProperty(box2d.b2DistanceProxy.prototype,"m_buffer",box2d.b2DistanceProxy.prototype.m_buffer);box2d.b2DistanceProxy.prototype.m_vertices=null;goog.exportProperty(box2d.b2DistanceProxy.prototype,"m_vertices",box2d.b2DistanceProxy.prototype.m_vertices);box2d.b2DistanceProxy.prototype.m_count=0;
+goog.exportProperty(box2d.b2DistanceProxy.prototype,"m_count",box2d.b2DistanceProxy.prototype.m_count);box2d.b2DistanceProxy.prototype.m_radius=0;goog.exportProperty(box2d.b2DistanceProxy.prototype,"m_radius",box2d.b2DistanceProxy.prototype.m_radius);box2d.b2DistanceProxy.prototype.Reset=function(){this.m_vertices=null;this.m_radius=this.m_count=0;return this};goog.exportProperty(box2d.b2DistanceProxy.prototype,"Reset",box2d.b2DistanceProxy.prototype.Reset);
+box2d.b2DistanceProxy.prototype.SetShape=function(a,b){a.SetupDistanceProxy(this,b)};goog.exportProperty(box2d.b2DistanceProxy.prototype,"SetShape",box2d.b2DistanceProxy.prototype.SetShape);box2d.b2DistanceProxy.prototype.GetSupport=function(a){for(var b=0,c=box2d.b2Dot_V2_V2(this.m_vertices[0],a),d=1;d<this.m_count;++d){var e=box2d.b2Dot_V2_V2(this.m_vertices[d],a);e>c&&(b=d,c=e)}return b};goog.exportProperty(box2d.b2DistanceProxy.prototype,"GetSupport",box2d.b2DistanceProxy.prototype.GetSupport);
+box2d.b2DistanceProxy.prototype.GetSupportVertex=function(a,b){for(var c=0,d=box2d.b2Dot_V2_V2(this.m_vertices[0],a),e=1;e<this.m_count;++e){var f=box2d.b2Dot_V2_V2(this.m_vertices[e],a);f>d&&(c=e,d=f)}return b.Copy(this.m_vertices[c])};goog.exportProperty(box2d.b2DistanceProxy.prototype,"GetSupportVertex",box2d.b2DistanceProxy.prototype.GetSupportVertex);box2d.b2DistanceProxy.prototype.GetVertexCount=function(){return this.m_count};
+goog.exportProperty(box2d.b2DistanceProxy.prototype,"GetVertexCount",box2d.b2DistanceProxy.prototype.GetVertexCount);box2d.b2DistanceProxy.prototype.GetVertex=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<=a&&a<this.m_count);return this.m_vertices[a]};goog.exportProperty(box2d.b2DistanceProxy.prototype,"GetVertex",box2d.b2DistanceProxy.prototype.GetVertex);box2d.b2SimplexCache=function(){this.indexA=box2d.b2MakeNumberArray(3);this.indexB=box2d.b2MakeNumberArray(3)};
+goog.exportSymbol("box2d.b2SimplexCache",box2d.b2SimplexCache);box2d.b2SimplexCache.prototype.metric=0;goog.exportProperty(box2d.b2SimplexCache.prototype,"metric",box2d.b2SimplexCache.prototype.metric);box2d.b2SimplexCache.prototype.count=0;goog.exportProperty(box2d.b2SimplexCache.prototype,"count",box2d.b2SimplexCache.prototype.count);box2d.b2SimplexCache.prototype.indexA=null;goog.exportProperty(box2d.b2SimplexCache.prototype,"indexA",box2d.b2SimplexCache.prototype.indexA);
+box2d.b2SimplexCache.prototype.indexB=null;goog.exportProperty(box2d.b2SimplexCache.prototype,"indexB",box2d.b2SimplexCache.prototype.indexB);box2d.b2SimplexCache.prototype.Reset=function(){this.count=this.metric=0;return this};goog.exportProperty(box2d.b2SimplexCache.prototype,"Reset",box2d.b2SimplexCache.prototype.Reset);box2d.b2DistanceInput=function(){this.proxyA=new box2d.b2DistanceProxy;this.proxyB=new box2d.b2DistanceProxy;this.transformA=new box2d.b2Transform;this.transformB=new box2d.b2Transform};
+goog.exportSymbol("box2d.b2DistanceInput",box2d.b2DistanceInput);box2d.b2DistanceInput.prototype.proxyA=null;goog.exportProperty(box2d.b2DistanceInput.prototype,"proxyA",box2d.b2DistanceInput.prototype.proxyA);box2d.b2DistanceInput.prototype.proxyB=null;goog.exportProperty(box2d.b2DistanceInput.prototype,"proxyB",box2d.b2DistanceInput.prototype.proxyB);box2d.b2DistanceInput.prototype.transformA=null;goog.exportProperty(box2d.b2DistanceInput.prototype,"transformA",box2d.b2DistanceInput.prototype.transformA);
+box2d.b2DistanceInput.prototype.transformB=null;goog.exportProperty(box2d.b2DistanceInput.prototype,"transformB",box2d.b2DistanceInput.prototype.transformB);box2d.b2DistanceInput.prototype.useRadii=!1;goog.exportProperty(box2d.b2DistanceInput.prototype,"useRadii",box2d.b2DistanceInput.prototype.useRadii);box2d.b2DistanceInput.prototype.Reset=function(){this.proxyA.Reset();this.proxyB.Reset();this.transformA.SetIdentity();this.transformB.SetIdentity();this.useRadii=!1;return this};
+goog.exportProperty(box2d.b2DistanceInput.prototype,"Reset",box2d.b2DistanceInput.prototype.Reset);box2d.b2DistanceOutput=function(){this.pointA=new box2d.b2Vec2;this.pointB=new box2d.b2Vec2};goog.exportSymbol("box2d.b2DistanceOutput",box2d.b2DistanceOutput);box2d.b2DistanceOutput.prototype.pointA=null;goog.exportProperty(box2d.b2DistanceOutput.prototype,"pointA",box2d.b2DistanceOutput.prototype.pointA);box2d.b2DistanceOutput.prototype.pointB=null;
+goog.exportProperty(box2d.b2DistanceOutput.prototype,"pointB",box2d.b2DistanceOutput.prototype.pointB);box2d.b2DistanceOutput.prototype.distance=0;goog.exportProperty(box2d.b2DistanceOutput.prototype,"distance",box2d.b2DistanceOutput.prototype.distance);box2d.b2DistanceOutput.prototype.iterations=0;goog.exportProperty(box2d.b2DistanceOutput.prototype,"iterations",box2d.b2DistanceOutput.prototype.iterations);
+box2d.b2DistanceOutput.prototype.Reset=function(){this.pointA.SetZero();this.pointB.SetZero();this.iterations=this.distance=0;return this};goog.exportProperty(box2d.b2DistanceOutput.prototype,"Reset",box2d.b2DistanceOutput.prototype.Reset);box2d.b2_gjkCalls=0;goog.exportSymbol("box2d.b2_gjkCalls",box2d.b2_gjkCalls);box2d.b2_gjkIters=0;goog.exportSymbol("box2d.b2_gjkIters",box2d.b2_gjkIters);box2d.b2_gjkMaxIters=0;goog.exportSymbol("box2d.b2_gjkMaxIters",box2d.b2_gjkMaxIters);
+box2d.b2SimplexVertex=function(){this.wA=new box2d.b2Vec2;this.wB=new box2d.b2Vec2;this.w=new box2d.b2Vec2};goog.exportSymbol("box2d.b2SimplexVertex",box2d.b2SimplexVertex);box2d.b2SimplexVertex.prototype.wA=null;goog.exportProperty(box2d.b2SimplexVertex.prototype,"wA",box2d.b2SimplexVertex.prototype.wA);box2d.b2SimplexVertex.prototype.wB=null;goog.exportProperty(box2d.b2SimplexVertex.prototype,"wB",box2d.b2SimplexVertex.prototype.wB);box2d.b2SimplexVertex.prototype.w=null;
+goog.exportProperty(box2d.b2SimplexVertex.prototype,"w",box2d.b2SimplexVertex.prototype.w);box2d.b2SimplexVertex.prototype.a=0;goog.exportProperty(box2d.b2SimplexVertex.prototype,"a",box2d.b2SimplexVertex.prototype.a);box2d.b2SimplexVertex.prototype.indexA=0;goog.exportProperty(box2d.b2SimplexVertex.prototype,"indexA",box2d.b2SimplexVertex.prototype.indexA);box2d.b2SimplexVertex.prototype.indexB=0;goog.exportProperty(box2d.b2SimplexVertex.prototype,"indexB",box2d.b2SimplexVertex.prototype.indexB);
+box2d.b2SimplexVertex.prototype.Copy=function(a){this.wA.Copy(a.wA);this.wB.Copy(a.wB);this.w.Copy(a.w);this.a=a.a;this.indexA=a.indexA;this.indexB=a.indexB;return this};goog.exportProperty(box2d.b2SimplexVertex.prototype,"Copy",box2d.b2SimplexVertex.prototype.Copy);
+box2d.b2Simplex=function(){this.m_v1=new box2d.b2SimplexVertex;this.m_v2=new box2d.b2SimplexVertex;this.m_v3=new box2d.b2SimplexVertex;this.m_vertices=Array(3);this.m_vertices[0]=this.m_v1;this.m_vertices[1]=this.m_v2;this.m_vertices[2]=this.m_v3};goog.exportSymbol("box2d.b2Simplex",box2d.b2Simplex);box2d.b2Simplex.prototype.m_v1=null;goog.exportProperty(box2d.b2Simplex.prototype,"m_v1",box2d.b2Simplex.prototype.m_v1);box2d.b2Simplex.prototype.m_v2=null;
+goog.exportProperty(box2d.b2Simplex.prototype,"m_v2",box2d.b2Simplex.prototype.m_v2);box2d.b2Simplex.prototype.m_v3=null;goog.exportProperty(box2d.b2Simplex.prototype,"m_v3",box2d.b2Simplex.prototype.m_v3);box2d.b2Simplex.prototype.m_vertices=null;goog.exportProperty(box2d.b2Simplex.prototype,"m_vertices",box2d.b2Simplex.prototype.m_vertices);box2d.b2Simplex.prototype.m_count=0;goog.exportProperty(box2d.b2Simplex.prototype,"m_count",box2d.b2Simplex.prototype.m_count);
+box2d.b2Simplex.prototype.ReadCache=function(a,b,c,d,e){box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<=a.count&&3>=a.count);this.m_count=a.count;for(var f=this.m_vertices,g=0;g<this.m_count;++g){var h=f[g];h.indexA=a.indexA[g];h.indexB=a.indexB[g];var k=b.GetVertex(h.indexA),l=d.GetVertex(h.indexB);box2d.b2Mul_X_V2(c,k,h.wA);box2d.b2Mul_X_V2(e,l,h.wB);box2d.b2Sub_V2_V2(h.wB,h.wA,h.w);h.a=0}1<this.m_count&&(a=a.metric,g=this.GetMetric(),g<.5*a||2*a<g||g<box2d.b2_epsilon)&&(this.m_count=0);0===this.m_count&&
+(h=f[0],h.indexA=0,h.indexB=0,k=b.GetVertex(0),l=d.GetVertex(0),box2d.b2Mul_X_V2(c,k,h.wA),box2d.b2Mul_X_V2(e,l,h.wB),box2d.b2Sub_V2_V2(h.wB,h.wA,h.w),this.m_count=h.a=1)};goog.exportProperty(box2d.b2Simplex.prototype,"ReadCache",box2d.b2Simplex.prototype.ReadCache);box2d.b2Simplex.prototype.WriteCache=function(a){a.metric=this.GetMetric();a.count=this.m_count;for(var b=this.m_vertices,c=0;c<this.m_count;++c)a.indexA[c]=b[c].indexA,a.indexB[c]=b[c].indexB};
+goog.exportProperty(box2d.b2Simplex.prototype,"WriteCache",box2d.b2Simplex.prototype.WriteCache);box2d.b2Simplex.prototype.GetSearchDirection=function(a){switch(this.m_count){case 1:return a.Copy(this.m_v1.w).SelfNeg();case 2:var b=box2d.b2Sub_V2_V2(this.m_v2.w,this.m_v1.w,a);return 0<box2d.b2Cross_V2_V2(b,box2d.b2Vec2.s_t0.Copy(this.m_v1.w).SelfNeg())?box2d.b2Cross_S_V2(1,b,a):box2d.b2Cross_V2_S(b,1,a);default:return box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1),a.SetZero()}};
+goog.exportProperty(box2d.b2Simplex.prototype,"GetSearchDirection",box2d.b2Simplex.prototype.GetSearchDirection);box2d.b2Simplex.prototype.GetClosestPoint=function(a){switch(this.m_count){case 0:return box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1),a.SetZero();case 1:return a.Copy(this.m_v1.w);case 2:return a.Set(this.m_v1.a*this.m_v1.w.x+this.m_v2.a*this.m_v2.w.x,this.m_v1.a*this.m_v1.w.y+this.m_v2.a*this.m_v2.w.y);case 3:return a.SetZero();default:return box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1),a.SetZero()}};
+goog.exportProperty(box2d.b2Simplex.prototype,"GetClosestPoint",box2d.b2Simplex.prototype.GetClosestPoint);
+box2d.b2Simplex.prototype.GetWitnessPoints=function(a,b){switch(this.m_count){case 0:box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1);break;case 1:a.Copy(this.m_v1.wA);b.Copy(this.m_v1.wB);break;case 2:a.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x;a.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y;b.x=this.m_v1.a*this.m_v1.wB.x+this.m_v2.a*this.m_v2.wB.x;b.y=this.m_v1.a*this.m_v1.wB.y+this.m_v2.a*this.m_v2.wB.y;break;case 3:b.x=a.x=this.m_v1.a*this.m_v1.wA.x+this.m_v2.a*this.m_v2.wA.x+
+this.m_v3.a*this.m_v3.wA.x;b.y=a.y=this.m_v1.a*this.m_v1.wA.y+this.m_v2.a*this.m_v2.wA.y+this.m_v3.a*this.m_v3.wA.y;break;default:box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1)}};goog.exportProperty(box2d.b2Simplex.prototype,"GetWitnessPoints",box2d.b2Simplex.prototype.GetWitnessPoints);
+box2d.b2Simplex.prototype.GetMetric=function(){switch(this.m_count){case 0:return box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1),0;case 1:return 0;case 2:return box2d.b2Distance(this.m_v1.w,this.m_v2.w);case 3:return box2d.b2Cross_V2_V2(box2d.b2Sub_V2_V2(this.m_v2.w,this.m_v1.w,box2d.b2Vec2.s_t0),box2d.b2Sub_V2_V2(this.m_v3.w,this.m_v1.w,box2d.b2Vec2.s_t1));default:return box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1),0}};goog.exportProperty(box2d.b2Simplex.prototype,"GetMetric",box2d.b2Simplex.prototype.GetMetric);
+box2d.b2Simplex.prototype.Solve2=function(){var a=this.m_v1.w,b=this.m_v2.w,c=box2d.b2Sub_V2_V2(b,a,box2d.b2Simplex.s_e12),a=-box2d.b2Dot_V2_V2(a,c);0>=a?this.m_count=this.m_v1.a=1:(b=box2d.b2Dot_V2_V2(b,c),0>=b?(this.m_count=this.m_v2.a=1,this.m_v1.Copy(this.m_v2)):(c=1/(b+a),this.m_v1.a=b*c,this.m_v2.a=a*c,this.m_count=2))};goog.exportProperty(box2d.b2Simplex.prototype,"Solve2",box2d.b2Simplex.prototype.Solve2);
+box2d.b2Simplex.prototype.Solve3=function(){var a=this.m_v1.w,b=this.m_v2.w,c=this.m_v3.w,d=box2d.b2Sub_V2_V2(b,a,box2d.b2Simplex.s_e12),e=box2d.b2Dot_V2_V2(a,d),f=box2d.b2Dot_V2_V2(b,d),e=-e,g=box2d.b2Sub_V2_V2(c,a,box2d.b2Simplex.s_e13),h=box2d.b2Dot_V2_V2(a,g),k=box2d.b2Dot_V2_V2(c,g),h=-h,l=box2d.b2Sub_V2_V2(c,b,box2d.b2Simplex.s_e23),m=box2d.b2Dot_V2_V2(b,l),l=box2d.b2Dot_V2_V2(c,l),m=-m,g=box2d.b2Cross_V2_V2(d,g),d=g*box2d.b2Cross_V2_V2(b,c),c=g*box2d.b2Cross_V2_V2(c,a),a=g*box2d.b2Cross_V2_V2(a,
+b);0>=e&&0>=h?this.m_count=this.m_v1.a=1:0<f&&0<e&&0>=a?(k=1/(f+e),this.m_v1.a=f*k,this.m_v2.a=e*k,this.m_count=2):0<k&&0<h&&0>=c?(f=1/(k+h),this.m_v1.a=k*f,this.m_v3.a=h*f,this.m_count=2,this.m_v2.Copy(this.m_v3)):0>=f&&0>=m?(this.m_count=this.m_v2.a=1,this.m_v1.Copy(this.m_v2)):0>=k&&0>=l?(this.m_count=this.m_v3.a=1,this.m_v1.Copy(this.m_v3)):0<l&&0<m&&0>=d?(f=1/(l+m),this.m_v2.a=l*f,this.m_v3.a=m*f,this.m_count=2,this.m_v1.Copy(this.m_v3)):(f=1/(d+c+a),this.m_v1.a=d*f,this.m_v2.a=c*f,this.m_v3.a=
+a*f,this.m_count=3)};goog.exportProperty(box2d.b2Simplex.prototype,"Solve3",box2d.b2Simplex.prototype.Solve3);box2d.b2Simplex.s_e12=new box2d.b2Vec2;box2d.b2Simplex.s_e13=new box2d.b2Vec2;box2d.b2Simplex.s_e23=new box2d.b2Vec2;
+box2d.b2ShapeDistance=function(a,b,c){++box2d.b2_gjkCalls;var d=c.proxyA,e=c.proxyB,f=c.transformA,g=c.transformB,h=box2d.b2Distance.s_simplex;h.ReadCache(b,d,f,e,g);for(var k=h.m_vertices,l=box2d.b2Distance.s_saveA,m=box2d.b2Distance.s_saveB,n=0,p=0;20>p;){for(var n=h.m_count,q=0;q<n;++q)l[q]=k[q].indexA,m[q]=k[q].indexB;switch(h.m_count){case 1:break;case 2:h.Solve2();break;case 3:h.Solve3();break;default:box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1)}if(3===h.m_count)break;var r=h.GetClosestPoint(box2d.b2Distance.s_p);
+r.LengthSquared();q=h.GetSearchDirection(box2d.b2Distance.s_d);if(q.LengthSquared()<box2d.b2_epsilon_sq)break;r=k[h.m_count];r.indexA=d.GetSupport(box2d.b2MulT_R_V2(f.q,box2d.b2Vec2.s_t0.Copy(q).SelfNeg(),box2d.b2Distance.s_supportA));box2d.b2Mul_X_V2(f,d.GetVertex(r.indexA),r.wA);r.indexB=e.GetSupport(box2d.b2MulT_R_V2(g.q,q,box2d.b2Distance.s_supportB));box2d.b2Mul_X_V2(g,e.GetVertex(r.indexB),r.wB);box2d.b2Sub_V2_V2(r.wB,r.wA,r.w);++p;++box2d.b2_gjkIters;for(var u=!1,q=0;q<n;++q)if(r.indexA===
+l[q]&&r.indexB===m[q]){u=!0;break}if(u)break;++h.m_count}box2d.b2_gjkMaxIters=box2d.b2Max(box2d.b2_gjkMaxIters,p);h.GetWitnessPoints(a.pointA,a.pointB);a.distance=box2d.b2Distance(a.pointA,a.pointB);a.iterations=p;h.WriteCache(b);c.useRadii&&(b=d.m_radius,e=e.m_radius,a.distance>b+e&&a.distance>box2d.b2_epsilon?(a.distance-=b+e,c=box2d.b2Sub_V2_V2(a.pointB,a.pointA,box2d.b2Distance.s_normal),c.Normalize(),a.pointA.SelfMulAdd(b,c),a.pointB.SelfMulSub(e,c)):(r=box2d.b2Mid_V2_V2(a.pointA,a.pointB,box2d.b2Distance.s_p),
+a.pointA.Copy(r),a.pointB.Copy(r),a.distance=0))};goog.exportSymbol("box2d.b2ShapeDistance",box2d.b2ShapeDistance);box2d.b2Distance.s_simplex=new box2d.b2Simplex;box2d.b2Distance.s_saveA=box2d.b2MakeNumberArray(3);box2d.b2Distance.s_saveB=box2d.b2MakeNumberArray(3);box2d.b2Distance.s_p=new box2d.b2Vec2;box2d.b2Distance.s_d=new box2d.b2Vec2;box2d.b2Distance.s_normal=new box2d.b2Vec2;box2d.b2Distance.s_supportA=new box2d.b2Vec2;box2d.b2Distance.s_supportB=new box2d.b2Vec2;box2d.b2Collision={};box2d.b2ContactFeatureType={e_vertex:0,e_face:1};goog.exportSymbol("box2d.b2ContactFeatureType",box2d.b2ContactFeatureType);goog.exportProperty(box2d.b2ContactFeatureType,"e_vertex",box2d.b2ContactFeatureType.e_vertex);goog.exportProperty(box2d.b2ContactFeatureType,"e_face",box2d.b2ContactFeatureType.e_face);box2d.b2ContactFeature=function(){};goog.exportSymbol("box2d.b2ContactFeature",box2d.b2ContactFeature);box2d.b2ContactFeature.prototype._key=0;
+goog.exportProperty(box2d.b2ContactFeature.prototype,"_key",box2d.b2ContactFeature.prototype._key);box2d.b2ContactFeature.prototype._key_invalid=!1;goog.exportProperty(box2d.b2ContactFeature.prototype,"_key_invalid",box2d.b2ContactFeature.prototype._key_invalid);box2d.b2ContactFeature.prototype._indexA=0;goog.exportProperty(box2d.b2ContactFeature.prototype,"_indexA",box2d.b2ContactFeature.prototype._indexA);box2d.b2ContactFeature.prototype._indexB=0;
+goog.exportProperty(box2d.b2ContactFeature.prototype,"_indexB",box2d.b2ContactFeature.prototype._indexB);box2d.b2ContactFeature.prototype._typeA=0;goog.exportProperty(box2d.b2ContactFeature.prototype,"_typeA",box2d.b2ContactFeature.prototype._typeA);box2d.b2ContactFeature.prototype._typeB=0;goog.exportProperty(box2d.b2ContactFeature.prototype,"_typeB",box2d.b2ContactFeature.prototype._typeB);
+Object.defineProperty(box2d.b2ContactFeature.prototype,"key",{enumerable:!1,configurable:!0,get:function(){this._key_invalid&&(this._key_invalid=!1,this._key=this._indexA|this._indexB<<8|this._typeA<<16|this._typeB<<24);return this._key},set:function(a){this._key=a;this._indexA=this._key&255;this._indexB=this._key>>8&255;this._typeA=this._key>>16&255;this._typeB=this._key>>24&255}});
+Object.defineProperty(box2d.b2ContactFeature.prototype,"indexA",{enumerable:!1,configurable:!0,get:function(){return this._indexA},set:function(a){this._indexA=a;this._key_invalid=!0}});Object.defineProperty(box2d.b2ContactFeature.prototype,"indexB",{enumerable:!1,configurable:!0,get:function(){return this._indexB},set:function(a){this._indexB=a;this._key_invalid=!0}});
+Object.defineProperty(box2d.b2ContactFeature.prototype,"typeA",{enumerable:!1,configurable:!0,get:function(){return this._typeA},set:function(a){this._typeA=a;this._key_invalid=!0}});Object.defineProperty(box2d.b2ContactFeature.prototype,"typeB",{enumerable:!1,configurable:!0,get:function(){return this._typeB},set:function(a){this._typeB=a;this._key_invalid=!0}});box2d.b2ContactID=function(){this.cf=new box2d.b2ContactFeature};goog.exportSymbol("box2d.b2ContactID",box2d.b2ContactID);
+box2d.b2ContactID.prototype.cf=null;goog.exportProperty(box2d.b2ContactID.prototype,"cf",box2d.b2ContactID.prototype.cf);box2d.b2ContactID.prototype.key=0;goog.exportProperty(box2d.b2ContactID.prototype,"key",box2d.b2ContactID.prototype.key);Object.defineProperty(box2d.b2ContactID.prototype,"key",{enumerable:!1,configurable:!0,get:function(){return this.cf.key},set:function(a){this.cf.key=a}});box2d.b2ContactID.prototype.Copy=function(a){this.key=a.key;return this};
+goog.exportProperty(box2d.b2ContactID.prototype,"Copy",box2d.b2ContactID.prototype.Copy);box2d.b2ContactID.prototype.Clone=function(){return(new box2d.b2ContactID).Copy(this)};goog.exportProperty(box2d.b2ContactID.prototype,"Clone",box2d.b2ContactID.prototype.Clone);box2d.b2ManifoldPoint=function(){this.localPoint=new box2d.b2Vec2;this.id=new box2d.b2ContactID};goog.exportSymbol("box2d.b2ManifoldPoint",box2d.b2ManifoldPoint);box2d.b2ManifoldPoint.prototype.localPoint=null;
+goog.exportProperty(box2d.b2ManifoldPoint.prototype,"localPoint",box2d.b2ManifoldPoint.prototype.localPoint);box2d.b2ManifoldPoint.prototype.normalImpulse=0;goog.exportProperty(box2d.b2ManifoldPoint.prototype,"normalImpulse",box2d.b2ManifoldPoint.prototype.normalImpulse);box2d.b2ManifoldPoint.prototype.tangentImpulse=0;goog.exportProperty(box2d.b2ManifoldPoint.prototype,"tangentImpulse",box2d.b2ManifoldPoint.prototype.tangentImpulse);box2d.b2ManifoldPoint.prototype.id=null;
+goog.exportProperty(box2d.b2ManifoldPoint.prototype,"id",box2d.b2ManifoldPoint.prototype.id);box2d.b2ManifoldPoint.MakeArray=function(a){return box2d.b2MakeArray(a,function(a){return new box2d.b2ManifoldPoint})};goog.exportProperty(box2d.b2ManifoldPoint,"MakeArray",box2d.b2ManifoldPoint.MakeArray);box2d.b2ManifoldPoint.prototype.Reset=function(){this.localPoint.SetZero();this.tangentImpulse=this.normalImpulse=0;this.id.key=0};goog.exportProperty(box2d.b2ManifoldPoint.prototype,"Reset",box2d.b2ManifoldPoint.prototype.Reset);
+box2d.b2ManifoldPoint.prototype.Copy=function(a){this.localPoint.Copy(a.localPoint);this.normalImpulse=a.normalImpulse;this.tangentImpulse=a.tangentImpulse;this.id.Copy(a.id);return this};goog.exportProperty(box2d.b2ManifoldPoint.prototype,"Copy",box2d.b2ManifoldPoint.prototype.Copy);box2d.b2ManifoldType={e_unknown:-1,e_circles:0,e_faceA:1,e_faceB:2};goog.exportSymbol("box2d.b2ManifoldType",box2d.b2ManifoldType);goog.exportProperty(box2d.b2ManifoldType,"e_unknown",box2d.b2ManifoldType.e_unknown);
+goog.exportProperty(box2d.b2ManifoldType,"e_circles",box2d.b2ManifoldType.e_circles);goog.exportProperty(box2d.b2ManifoldType,"e_faceA",box2d.b2ManifoldType.e_faceA);goog.exportProperty(box2d.b2ManifoldType,"e_faceB",box2d.b2ManifoldType.e_faceB);box2d.b2Manifold=function(){this.points=box2d.b2ManifoldPoint.MakeArray(box2d.b2_maxManifoldPoints);this.localNormal=new box2d.b2Vec2;this.localPoint=new box2d.b2Vec2;this.type=box2d.b2ManifoldType.e_unknown;this.pointCount=0};
+goog.exportSymbol("box2d.b2Manifold",box2d.b2Manifold);box2d.b2Manifold.prototype.points=null;goog.exportProperty(box2d.b2Manifold.prototype,"points",box2d.b2Manifold.prototype.points);box2d.b2Manifold.prototype.localNormal=null;goog.exportProperty(box2d.b2Manifold.prototype,"localNormal",box2d.b2Manifold.prototype.localNormal);box2d.b2Manifold.prototype.localPoint=null;goog.exportProperty(box2d.b2Manifold.prototype,"localPoint",box2d.b2Manifold.prototype.localPoint);
+box2d.b2Manifold.prototype.type=box2d.b2ManifoldType.e_unknown;goog.exportProperty(box2d.b2Manifold.prototype,"type",box2d.b2Manifold.prototype.type);box2d.b2Manifold.prototype.pointCount=0;goog.exportProperty(box2d.b2Manifold.prototype,"pointCount",box2d.b2Manifold.prototype.pointCount);
+box2d.b2Manifold.prototype.Reset=function(){for(var a=0,b=box2d.b2_maxManifoldPoints;a<b;++a)this.points[a].Reset();this.localNormal.SetZero();this.localPoint.SetZero();this.type=box2d.b2ManifoldType.e_unknown;this.pointCount=0};goog.exportProperty(box2d.b2Manifold.prototype,"Reset",box2d.b2Manifold.prototype.Reset);
+box2d.b2Manifold.prototype.Copy=function(a){this.pointCount=a.pointCount;for(var b=0,c=box2d.b2_maxManifoldPoints;b<c;++b)this.points[b].Copy(a.points[b]);this.localNormal.Copy(a.localNormal);this.localPoint.Copy(a.localPoint);this.type=a.type;return this};goog.exportProperty(box2d.b2Manifold.prototype,"Copy",box2d.b2Manifold.prototype.Copy);box2d.b2Manifold.prototype.Clone=function(){return(new box2d.b2Manifold).Copy(this)};goog.exportProperty(box2d.b2Manifold.prototype,"Clone",box2d.b2Manifold.prototype.Clone);
+box2d.b2WorldManifold=function(){this.normal=new box2d.b2Vec2;this.points=box2d.b2Vec2.MakeArray(box2d.b2_maxManifoldPoints);this.separations=box2d.b2MakeNumberArray(box2d.b2_maxManifoldPoints)};goog.exportSymbol("box2d.b2WorldManifold",box2d.b2WorldManifold);box2d.b2WorldManifold.prototype.normal=null;goog.exportProperty(box2d.b2WorldManifold.prototype,"normal",box2d.b2WorldManifold.prototype.normal);box2d.b2WorldManifold.prototype.points=null;
+goog.exportProperty(box2d.b2WorldManifold.prototype,"points",box2d.b2WorldManifold.prototype.points);box2d.b2WorldManifold.prototype.separations=null;goog.exportProperty(box2d.b2WorldManifold.prototype,"separations",box2d.b2WorldManifold.prototype.separations);
+box2d.b2WorldManifold.prototype.Initialize=function(a,b,c,d,e){if(0!==a.pointCount)switch(a.type){case box2d.b2ManifoldType.e_circles:this.normal.Set(1,0);b=box2d.b2Mul_X_V2(b,a.localPoint,box2d.b2WorldManifold.prototype.Initialize.s_pointA);a=box2d.b2Mul_X_V2(d,a.points[0].localPoint,box2d.b2WorldManifold.prototype.Initialize.s_pointB);box2d.b2DistanceSquared(b,a)>box2d.b2_epsilon_sq&&box2d.b2Sub_V2_V2(a,b,this.normal).SelfNormalize();var f=box2d.b2AddMul_V2_S_V2(b,c,this.normal,box2d.b2WorldManifold.prototype.Initialize.s_cA),
+g=box2d.b2SubMul_V2_S_V2(a,e,this.normal,box2d.b2WorldManifold.prototype.Initialize.s_cB);box2d.b2Mid_V2_V2(f,g,this.points[0]);this.separations[0]=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(g,f,box2d.b2Vec2.s_t0),this.normal);break;case box2d.b2ManifoldType.e_faceA:box2d.b2Mul_R_V2(b.q,a.localNormal,this.normal);for(var h=box2d.b2Mul_X_V2(b,a.localPoint,box2d.b2WorldManifold.prototype.Initialize.s_planePoint),k=0,l=a.pointCount;k<l;++k){var m=box2d.b2Mul_X_V2(d,a.points[k].localPoint,box2d.b2WorldManifold.prototype.Initialize.s_clipPoint),
+f=c-box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(m,h,box2d.b2Vec2.s_t0),this.normal),f=box2d.b2AddMul_V2_S_V2(m,f,this.normal,box2d.b2WorldManifold.prototype.Initialize.s_cA),g=box2d.b2SubMul_V2_S_V2(m,e,this.normal,box2d.b2WorldManifold.prototype.Initialize.s_cB);box2d.b2Mid_V2_V2(f,g,this.points[k]);this.separations[k]=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(g,f,box2d.b2Vec2.s_t0),this.normal)}break;case box2d.b2ManifoldType.e_faceB:box2d.b2Mul_R_V2(d.q,a.localNormal,this.normal);h=box2d.b2Mul_X_V2(d,a.localPoint,
+box2d.b2WorldManifold.prototype.Initialize.s_planePoint);k=0;for(l=a.pointCount;k<l;++k)m=box2d.b2Mul_X_V2(b,a.points[k].localPoint,box2d.b2WorldManifold.prototype.Initialize.s_clipPoint),f=e-box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(m,h,box2d.b2Vec2.s_t0),this.normal),g=box2d.b2AddMul_V2_S_V2(m,f,this.normal,box2d.b2WorldManifold.prototype.Initialize.s_cB),f=box2d.b2SubMul_V2_S_V2(m,c,this.normal,box2d.b2WorldManifold.prototype.Initialize.s_cA),box2d.b2Mid_V2_V2(f,g,this.points[k]),this.separations[k]=
+box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(f,g,box2d.b2Vec2.s_t0),this.normal);this.normal.SelfNeg()}};goog.exportProperty(box2d.b2WorldManifold.prototype,"Initialize",box2d.b2WorldManifold.prototype.Initialize);box2d.b2WorldManifold.prototype.Initialize.s_pointA=new box2d.b2Vec2;box2d.b2WorldManifold.prototype.Initialize.s_pointB=new box2d.b2Vec2;box2d.b2WorldManifold.prototype.Initialize.s_cA=new box2d.b2Vec2;box2d.b2WorldManifold.prototype.Initialize.s_cB=new box2d.b2Vec2;
+box2d.b2WorldManifold.prototype.Initialize.s_planePoint=new box2d.b2Vec2;box2d.b2WorldManifold.prototype.Initialize.s_clipPoint=new box2d.b2Vec2;box2d.b2PointState={b2_nullState:0,b2_addState:1,b2_persistState:2,b2_removeState:3};goog.exportSymbol("box2d.b2PointState",box2d.b2PointState);goog.exportProperty(box2d.b2PointState,"b2_nullState   ",box2d.b2PointState.b2_nullState);goog.exportProperty(box2d.b2PointState,"b2_addState    ",box2d.b2PointState.b2_addState);
+goog.exportProperty(box2d.b2PointState,"b2_persistState",box2d.b2PointState.b2_persistState);goog.exportProperty(box2d.b2PointState,"b2_removeState ",box2d.b2PointState.b2_removeState);
+box2d.b2GetPointStates=function(a,b,c,d){for(var e=0,f=c.pointCount;e<f;++e){var g=c.points[e].id,g=g.key;a[e]=box2d.b2PointState.b2_removeState;for(var h=0,k=d.pointCount;h<k;++h)if(d.points[h].id.key===g){a[e]=box2d.b2PointState.b2_persistState;break}}for(f=box2d.b2_maxManifoldPoints;e<f;++e)a[e]=box2d.b2PointState.b2_nullState;e=0;for(f=d.pointCount;e<f;++e)for(g=d.points[e].id,g=g.key,b[e]=box2d.b2PointState.b2_addState,h=0,k=c.pointCount;h<k;++h)if(c.points[h].id.key===g){b[e]=box2d.b2PointState.b2_persistState;
+break}for(f=box2d.b2_maxManifoldPoints;e<f;++e)b[e]=box2d.b2PointState.b2_nullState};goog.exportSymbol("box2d.b2GetPointStates",box2d.b2GetPointStates);box2d.b2ClipVertex=function(){this.v=new box2d.b2Vec2;this.id=new box2d.b2ContactID};goog.exportSymbol("box2d.b2ClipVertex",box2d.b2ClipVertex);box2d.b2ClipVertex.prototype.v=null;goog.exportProperty(box2d.b2ClipVertex.prototype,"v",box2d.b2ClipVertex.prototype.v);box2d.b2ClipVertex.prototype.id=null;
+goog.exportProperty(box2d.b2ClipVertex.prototype,"id",box2d.b2ClipVertex.prototype.id);box2d.b2ClipVertex.MakeArray=function(a){return box2d.b2MakeArray(a,function(a){return new box2d.b2ClipVertex})};goog.exportProperty(box2d.b2ClipVertex,"MakeArray",box2d.b2ClipVertex.MakeArray);box2d.b2ClipVertex.prototype.Copy=function(a){this.v.Copy(a.v);this.id.Copy(a.id);return this};goog.exportProperty(box2d.b2ClipVertex.prototype,"Copy",box2d.b2ClipVertex.prototype.Copy);
+box2d.b2RayCastInput=function(){this.p1=new box2d.b2Vec2;this.p2=new box2d.b2Vec2;this.maxFraction=1};goog.exportSymbol("box2d.b2RayCastInput",box2d.b2RayCastInput);box2d.b2RayCastInput.prototype.p1=null;goog.exportProperty(box2d.b2RayCastInput.prototype,"p1",box2d.b2RayCastInput.prototype.p1);box2d.b2RayCastInput.prototype.p2=null;goog.exportProperty(box2d.b2RayCastInput.prototype,"p2",box2d.b2RayCastInput.prototype.p2);box2d.b2RayCastInput.prototype.maxFraction=1;
+goog.exportProperty(box2d.b2RayCastInput.prototype,"maxFraction",box2d.b2RayCastInput.prototype.maxFraction);box2d.b2RayCastInput.prototype.Copy=function(a){this.p1.Copy(a.p1);this.p2.Copy(a.p2);this.maxFraction=a.maxFraction;return this};goog.exportProperty(box2d.b2RayCastInput.prototype,"Copy",box2d.b2RayCastInput.prototype.Copy);box2d.b2RayCastOutput=function(){this.normal=new box2d.b2Vec2;this.fraction=0};goog.exportSymbol("box2d.b2RayCastOutput",box2d.b2RayCastOutput);
+box2d.b2RayCastOutput.prototype.normal=null;goog.exportProperty(box2d.b2RayCastOutput.prototype,"normal",box2d.b2RayCastOutput.prototype.normal);box2d.b2RayCastOutput.prototype.fraction=0;goog.exportProperty(box2d.b2RayCastOutput.prototype,"fraction",box2d.b2RayCastOutput.prototype.fraction);box2d.b2RayCastOutput.prototype.Copy=function(a){this.normal.Copy(a.normal);this.fraction=a.fraction;return this};goog.exportProperty(box2d.b2RayCastOutput.prototype,"Copy",box2d.b2RayCastOutput.prototype.Copy);
+box2d.b2AABB=function(){this.lowerBound=new box2d.b2Vec2;this.upperBound=new box2d.b2Vec2;this.m_out_center=new box2d.b2Vec2;this.m_out_extent=new box2d.b2Vec2};goog.exportSymbol("box2d.b2AABB",box2d.b2AABB);box2d.b2AABB.prototype.lowerBound=null;goog.exportProperty(box2d.b2AABB.prototype,"lowerBound",box2d.b2AABB.prototype.lowerBound);box2d.b2AABB.prototype.upperBound=null;goog.exportProperty(box2d.b2AABB.prototype,"upperBound",box2d.b2AABB.prototype.upperBound);
+box2d.b2AABB.prototype.m_out_center=null;goog.exportProperty(box2d.b2AABB.prototype,"m_out_center",box2d.b2AABB.prototype.m_out_center);box2d.b2AABB.prototype.m_out_extent=null;goog.exportProperty(box2d.b2AABB.prototype,"m_out_extent",box2d.b2AABB.prototype.m_out_extent);box2d.b2AABB.prototype.Clone=function(){return(new box2d.b2AABB).Copy(this)};goog.exportProperty(box2d.b2AABB.prototype,"Clone",box2d.b2AABB.prototype.Clone);
+box2d.b2AABB.prototype.Copy=function(a){this.lowerBound.Copy(a.lowerBound);this.upperBound.Copy(a.upperBound);return this};goog.exportProperty(box2d.b2AABB.prototype,"Copy",box2d.b2AABB.prototype.Copy);box2d.b2AABB.prototype.IsValid=function(){var a=this.upperBound.y-this.lowerBound.y;return a=(a=0<=this.upperBound.x-this.lowerBound.x&&0<=a)&&this.lowerBound.IsValid()&&this.upperBound.IsValid()};goog.exportProperty(box2d.b2AABB.prototype,"IsValid",box2d.b2AABB.prototype.IsValid);
+box2d.b2AABB.prototype.GetCenter=function(){return box2d.b2Mid_V2_V2(this.lowerBound,this.upperBound,this.m_out_center)};goog.exportProperty(box2d.b2AABB.prototype,"GetCenter",box2d.b2AABB.prototype.GetCenter);box2d.b2AABB.prototype.GetExtents=function(){return box2d.b2Ext_V2_V2(this.lowerBound,this.upperBound,this.m_out_extent)};goog.exportProperty(box2d.b2AABB.prototype,"GetExtents",box2d.b2AABB.prototype.GetExtents);
+box2d.b2AABB.prototype.GetPerimeter=function(){return 2*(this.upperBound.x-this.lowerBound.x+(this.upperBound.y-this.lowerBound.y))};goog.exportProperty(box2d.b2AABB.prototype,"GetPerimeter",box2d.b2AABB.prototype.GetPerimeter);box2d.b2AABB.prototype.Combine=function(a,b){switch(arguments.length){case 1:return this.Combine1(a);case 2:return this.Combine2(a,b||new box2d.b2AABB);default:throw Error();}};
+box2d.b2AABB.prototype.Combine1=function(a){this.lowerBound.x=box2d.b2Min(this.lowerBound.x,a.lowerBound.x);this.lowerBound.y=box2d.b2Min(this.lowerBound.y,a.lowerBound.y);this.upperBound.x=box2d.b2Max(this.upperBound.x,a.upperBound.x);this.upperBound.y=box2d.b2Max(this.upperBound.y,a.upperBound.y);return this};goog.exportProperty(box2d.b2AABB.prototype,"Combine1",box2d.b2AABB.prototype.Combine1);
+box2d.b2AABB.prototype.Combine2=function(a,b){this.lowerBound.x=box2d.b2Min(a.lowerBound.x,b.lowerBound.x);this.lowerBound.y=box2d.b2Min(a.lowerBound.y,b.lowerBound.y);this.upperBound.x=box2d.b2Max(a.upperBound.x,b.upperBound.x);this.upperBound.y=box2d.b2Max(a.upperBound.y,b.upperBound.y);return this};goog.exportProperty(box2d.b2AABB.prototype,"Combine2",box2d.b2AABB.prototype.Combine2);box2d.b2AABB.Combine=function(a,b,c){c.Combine2(a,b);return c};goog.exportProperty(box2d.b2AABB,"Combine",box2d.b2AABB.Combine);
+box2d.b2AABB.prototype.Contains=function(a){var b;return b=(b=(b=(b=this.lowerBound.x<=a.lowerBound.x)&&this.lowerBound.y<=a.lowerBound.y)&&a.upperBound.x<=this.upperBound.x)&&a.upperBound.y<=this.upperBound.y};goog.exportProperty(box2d.b2AABB.prototype,"Contains",box2d.b2AABB.prototype.Contains);
+box2d.b2AABB.prototype.RayCast=function(a,b){var c=-box2d.b2_maxFloat,d=box2d.b2_maxFloat,e=b.p1.x,f=b.p1.y,g=b.p2.x-b.p1.x,h=b.p2.y-b.p1.y,k=box2d.b2Abs(g),l=box2d.b2Abs(h),m=a.normal;if(k<box2d.b2_epsilon){if(e<this.lowerBound.x||this.upperBound.x<e)return!1}else if(k=1/g,g=(this.lowerBound.x-e)*k,e=(this.upperBound.x-e)*k,k=-1,g>e&&(k=g,g=e,e=k,k=1),g>c&&(m.x=k,m.y=0,c=g),d=box2d.b2Min(d,e),c>d)return!1;if(l<box2d.b2_epsilon){if(f<this.lowerBound.y||this.upperBound.y<f)return!1}else if(k=1/h,g=
+(this.lowerBound.y-f)*k,e=(this.upperBound.y-f)*k,k=-1,g>e&&(k=g,g=e,e=k,k=1),g>c&&(m.x=0,m.y=k,c=g),d=box2d.b2Min(d,e),c>d)return!1;if(0>c||b.maxFraction<c)return!1;a.fraction=c;return!0};goog.exportProperty(box2d.b2AABB.prototype,"RayCast",box2d.b2AABB.prototype.RayCast);box2d.b2AABB.prototype.TestOverlap=function(a){var b=a.lowerBound.y-this.upperBound.y,c=this.lowerBound.y-a.upperBound.y;return 0<a.lowerBound.x-this.upperBound.x||0<b||0<this.lowerBound.x-a.upperBound.x||0<c?!1:!0};
+goog.exportProperty(box2d.b2AABB.prototype,"TestOverlap",box2d.b2AABB.prototype.TestOverlap);box2d.b2TestOverlap_AABB=function(a,b){var c=b.lowerBound.y-a.upperBound.y,d=a.lowerBound.y-b.upperBound.y;return 0<b.lowerBound.x-a.upperBound.x||0<c||0<a.lowerBound.x-b.upperBound.x||0<d?!1:!0};goog.exportSymbol("box2d.b2TestOverlap_AABB",box2d.b2TestOverlap_AABB);
+box2d.b2ClipSegmentToLine=function(a,b,c,d,e){var f=0,g=b[0];b=b[1];var h=box2d.b2Dot_V2_V2(c,g.v)-d;c=box2d.b2Dot_V2_V2(c,b.v)-d;0>=h&&a[f++].Copy(g);0>=c&&a[f++].Copy(b);0>h*c&&(c=h/(h-c),d=a[f].v,d.x=g.v.x+c*(b.v.x-g.v.x),d.y=g.v.y+c*(b.v.y-g.v.y),a=a[f].id,a.cf.indexA=e,a.cf.indexB=g.id.cf.indexB,a.cf.typeA=box2d.b2ContactFeatureType.e_vertex,a.cf.typeB=box2d.b2ContactFeatureType.e_face,++f);return f};goog.exportSymbol("box2d.b2ClipSegmentToLine",box2d.b2ClipSegmentToLine);
+box2d.b2TestOverlap_Shape=function(a,b,c,d,e,f){var g=box2d.b2TestOverlap_Shape.s_input.Reset();g.proxyA.SetShape(a,b);g.proxyB.SetShape(c,d);g.transformA.Copy(e);g.transformB.Copy(f);g.useRadii=!0;a=box2d.b2TestOverlap_Shape.s_simplexCache.Reset();a.count=0;b=box2d.b2TestOverlap_Shape.s_output.Reset();box2d.b2ShapeDistance(b,a,g);return b.distance<10*box2d.b2_epsilon};goog.exportSymbol("box2d.b2TestOverlap_Shape",box2d.b2TestOverlap_Shape);box2d.b2TestOverlap_Shape.s_input=new box2d.b2DistanceInput;
+box2d.b2TestOverlap_Shape.s_simplexCache=new box2d.b2SimplexCache;box2d.b2TestOverlap_Shape.s_output=new box2d.b2DistanceOutput;box2d.b2TestOverlap=function(a,b,c,d,e,f){if(a instanceof box2d.b2AABB&&b instanceof box2d.b2AABB)return box2d.b2TestOverlap_AABB(a,b);if(a instanceof box2d.b2Shape&&"number"===typeof b&&c instanceof box2d.b2Shape&&"number"===typeof d&&e instanceof box2d.b2Transform&&f instanceof box2d.b2Transform)return box2d.b2TestOverlap_Shape(a,b,c,d,e,f);throw Error();};
+goog.exportSymbol("box2d.b2TestOverlap",box2d.b2TestOverlap);box2d.b2CollideCircle={};box2d.b2CollideCircles=function(a,b,c,d,e){a.pointCount=0;c=box2d.b2Mul_X_V2(c,b.m_p,box2d.b2CollideCircles.s_pA);e=box2d.b2Mul_X_V2(e,d.m_p,box2d.b2CollideCircles.s_pB);e=box2d.b2DistanceSquared(c,e);c=b.m_radius+d.m_radius;e>c*c||(a.type=box2d.b2ManifoldType.e_circles,a.localPoint.Copy(b.m_p),a.localNormal.SetZero(),a.pointCount=1,a.points[0].localPoint.Copy(d.m_p),a.points[0].id.key=0)};goog.exportSymbol("box2d.b2CollideCircles",box2d.b2CollideCircles);
+box2d.b2CollideCircles.s_pA=new box2d.b2Vec2;box2d.b2CollideCircles.s_pB=new box2d.b2Vec2;
+box2d.b2CollidePolygonAndCircle=function(a,b,c,d,e){a.pointCount=0;e=box2d.b2Mul_X_V2(e,d.m_p,box2d.b2CollidePolygonAndCircle.s_c);c=box2d.b2MulT_X_V2(c,e,box2d.b2CollidePolygonAndCircle.s_cLocal);var f=0,g=-box2d.b2_maxFloat;e=b.m_radius+d.m_radius;var h=b.m_count,k=b.m_vertices;b=b.m_normals;for(var l=0;l<h;++l){var m=box2d.b2Dot_V2_V2(b[l],box2d.b2Sub_V2_V2(c,k[l],box2d.b2Vec2.s_t0));if(m>e)return;m>g&&(g=m,f=l)}l=f;m=k[l];h=k[(l+1)%h];g<box2d.b2_epsilon?(a.pointCount=1,a.type=box2d.b2ManifoldType.e_faceA,
+a.localNormal.Copy(b[f]),box2d.b2Mid_V2_V2(m,h,a.localPoint),a.points[0].localPoint.Copy(d.m_p),a.points[0].id.key=0):(g=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(c,m,box2d.b2Vec2.s_t0),box2d.b2Sub_V2_V2(h,m,box2d.b2Vec2.s_t1)),f=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(c,h,box2d.b2Vec2.s_t0),box2d.b2Sub_V2_V2(m,h,box2d.b2Vec2.s_t1)),0>=g?box2d.b2DistanceSquared(c,m)>e*e||(a.pointCount=1,a.type=box2d.b2ManifoldType.e_faceA,box2d.b2Sub_V2_V2(c,m,a.localNormal).SelfNormalize(),a.localPoint.Copy(m),a.points[0].localPoint.Copy(d.m_p),
+a.points[0].id.key=0):0>=f?box2d.b2DistanceSquared(c,h)>e*e||(a.pointCount=1,a.type=box2d.b2ManifoldType.e_faceA,box2d.b2Sub_V2_V2(c,h,a.localNormal).SelfNormalize(),a.localPoint.Copy(h),a.points[0].localPoint.Copy(d.m_p),a.points[0].id.key=0):(f=box2d.b2Mid_V2_V2(m,h,box2d.b2CollidePolygonAndCircle.s_faceCenter),g=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(c,f,box2d.b2Vec2.s_t1),b[l]),g>e||(a.pointCount=1,a.type=box2d.b2ManifoldType.e_faceA,a.localNormal.Copy(b[l]).SelfNormalize(),a.localPoint.Copy(f),
+a.points[0].localPoint.Copy(d.m_p),a.points[0].id.key=0)))};goog.exportSymbol("box2d.b2CollidePolygonAndCircle",box2d.b2CollidePolygonAndCircle);box2d.b2CollidePolygonAndCircle.s_c=new box2d.b2Vec2;box2d.b2CollidePolygonAndCircle.s_cLocal=new box2d.b2Vec2;box2d.b2CollidePolygonAndCircle.s_faceCenter=new box2d.b2Vec2;box2d.b2CollideEdge={};
+box2d.b2CollideEdgeAndCircle=function(a,b,c,d,e){a.pointCount=0;c=box2d.b2MulT_X_V2(c,box2d.b2Mul_X_V2(e,d.m_p,box2d.b2Vec2.s_t0),box2d.b2CollideEdgeAndCircle.s_Q);var f=b.m_vertex1,g=b.m_vertex2,h=box2d.b2Sub_V2_V2(g,f,box2d.b2CollideEdgeAndCircle.s_e),k=box2d.b2Dot_V2_V2(h,box2d.b2Sub_V2_V2(g,c,box2d.b2Vec2.s_t0)),l=box2d.b2Dot_V2_V2(h,box2d.b2Sub_V2_V2(c,f,box2d.b2Vec2.s_t0)),m=b.m_radius+d.m_radius;e=box2d.b2CollideEdgeAndCircle.s_id;e.cf.indexB=0;e.cf.typeB=box2d.b2ContactFeatureType.e_vertex;if(0>=
+l){var n=f,k=box2d.b2Sub_V2_V2(c,n,box2d.b2CollideEdgeAndCircle.s_d),k=box2d.b2Dot_V2_V2(k,k);if(!(k>m*m)){if(b.m_hasVertex0&&(b=box2d.b2Sub_V2_V2(f,b.m_vertex0,box2d.b2CollideEdgeAndCircle.s_e1),0<box2d.b2Dot_V2_V2(b,box2d.b2Sub_V2_V2(f,c,box2d.b2Vec2.s_t0))))return;e.cf.indexA=0;e.cf.typeA=box2d.b2ContactFeatureType.e_vertex;a.pointCount=1;a.type=box2d.b2ManifoldType.e_circles;a.localNormal.SetZero();a.localPoint.Copy(n);a.points[0].id.Copy(e);a.points[0].localPoint.Copy(d.m_p)}}else if(0>=k){if(n=
+g,k=box2d.b2Sub_V2_V2(c,n,box2d.b2CollideEdgeAndCircle.s_d),k=box2d.b2Dot_V2_V2(k,k),!(k>m*m)){if(b.m_hasVertex3&&(f=box2d.b2Sub_V2_V2(b.m_vertex3,g,box2d.b2CollideEdgeAndCircle.s_e2),0<box2d.b2Dot_V2_V2(f,box2d.b2Sub_V2_V2(c,g,box2d.b2Vec2.s_t0))))return;e.cf.indexA=1;e.cf.typeA=box2d.b2ContactFeatureType.e_vertex;a.pointCount=1;a.type=box2d.b2ManifoldType.e_circles;a.localNormal.SetZero();a.localPoint.Copy(n);a.points[0].id.Copy(e);a.points[0].localPoint.Copy(d.m_p)}}else b=box2d.b2Dot_V2_V2(h,
+h),box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<b),n=box2d.b2CollideEdgeAndCircle.s_P,n.x=1/b*(k*f.x+l*g.x),n.y=1/b*(k*f.y+l*g.y),k=box2d.b2Sub_V2_V2(c,n,box2d.b2CollideEdgeAndCircle.s_d),k=box2d.b2Dot_V2_V2(k,k),k>m*m||(n=box2d.b2CollideEdgeAndCircle.s_n.Set(-h.y,h.x),0>box2d.b2Dot_V2_V2(n,box2d.b2Sub_V2_V2(c,f,box2d.b2Vec2.s_t0))&&n.Set(-n.x,-n.y),n.Normalize(),e.cf.indexA=0,e.cf.typeA=box2d.b2ContactFeatureType.e_face,a.pointCount=1,a.type=box2d.b2ManifoldType.e_faceA,a.localNormal.Copy(n),a.localPoint.Copy(f),
+a.points[0].id.Copy(e),a.points[0].localPoint.Copy(d.m_p))};goog.exportSymbol("box2d.b2CollideEdgeAndCircle",box2d.b2CollideEdgeAndCircle);box2d.b2CollideEdgeAndCircle.s_Q=new box2d.b2Vec2;box2d.b2CollideEdgeAndCircle.s_e=new box2d.b2Vec2;box2d.b2CollideEdgeAndCircle.s_d=new box2d.b2Vec2;box2d.b2CollideEdgeAndCircle.s_e1=new box2d.b2Vec2;box2d.b2CollideEdgeAndCircle.s_e2=new box2d.b2Vec2;box2d.b2CollideEdgeAndCircle.s_P=new box2d.b2Vec2;box2d.b2CollideEdgeAndCircle.s_n=new box2d.b2Vec2;
+box2d.b2CollideEdgeAndCircle.s_id=new box2d.b2ContactID;box2d.b2EPAxisType={e_unknown:0,e_edgeA:1,e_edgeB:2};goog.exportSymbol("box2d.b2EPAxisType",box2d.b2EPAxisType);goog.exportProperty(box2d.b2EPAxisType,"e_unknown",box2d.b2EPAxisType.e_unknown);goog.exportProperty(box2d.b2EPAxisType,"e_edgeA",box2d.b2EPAxisType.e_edgeA);goog.exportProperty(box2d.b2EPAxisType,"e_edgeB",box2d.b2EPAxisType.e_edgeB);box2d.b2EPAxis=function(){};goog.exportSymbol("box2d.b2EPAxis",box2d.b2EPAxis);
+box2d.b2EPAxis.prototype.type=box2d.b2EPAxisType.e_unknown;goog.exportProperty(box2d.b2EPAxis.prototype,"type",box2d.b2EPAxis.prototype.type);box2d.b2EPAxis.prototype.index=0;goog.exportProperty(box2d.b2EPAxis.prototype,"index",box2d.b2EPAxis.prototype.index);box2d.b2EPAxis.prototype.separation=0;goog.exportProperty(box2d.b2EPAxis.prototype,"separation",box2d.b2EPAxis.prototype.separation);
+box2d.b2TempPolygon=function(){this.vertices=box2d.b2Vec2.MakeArray(box2d.b2_maxPolygonVertices);this.normals=box2d.b2Vec2.MakeArray(box2d.b2_maxPolygonVertices);this.count=0};goog.exportSymbol("box2d.b2TempPolygon",box2d.b2TempPolygon);box2d.b2TempPolygon.prototype.vertices=null;goog.exportProperty(box2d.b2TempPolygon.prototype,"vertices",box2d.b2TempPolygon.prototype.vertices);box2d.b2TempPolygon.prototype.normals=null;goog.exportProperty(box2d.b2TempPolygon.prototype,"normals",box2d.b2TempPolygon.prototype.normals);
+box2d.b2TempPolygon.prototype.count=0;goog.exportProperty(box2d.b2TempPolygon.prototype,"count",box2d.b2TempPolygon.prototype.count);box2d.b2ReferenceFace=function(){this.i2=this.i1=0;this.v1=new box2d.b2Vec2;this.v2=new box2d.b2Vec2;this.normal=new box2d.b2Vec2;this.sideNormal1=new box2d.b2Vec2;this.sideOffset1=0;this.sideNormal2=new box2d.b2Vec2;this.sideOffset2=0};goog.exportSymbol("box2d.b2ReferenceFace",box2d.b2ReferenceFace);box2d.b2ReferenceFace.prototype.i1=0;
+goog.exportProperty(box2d.b2ReferenceFace.prototype,"i1",box2d.b2ReferenceFace.prototype.i1);box2d.b2ReferenceFace.prototype.i2=0;goog.exportProperty(box2d.b2ReferenceFace.prototype,"i2",box2d.b2ReferenceFace.prototype.i2);box2d.b2ReferenceFace.prototype.v1=null;goog.exportProperty(box2d.b2ReferenceFace.prototype,"v1",box2d.b2ReferenceFace.prototype.v1);box2d.b2ReferenceFace.prototype.v2=null;goog.exportProperty(box2d.b2ReferenceFace.prototype,"v2",box2d.b2ReferenceFace.prototype.v2);
+box2d.b2ReferenceFace.prototype.normal=null;goog.exportProperty(box2d.b2ReferenceFace.prototype,"normal",box2d.b2ReferenceFace.prototype.normal);box2d.b2ReferenceFace.prototype.sideNormal1=null;goog.exportProperty(box2d.b2ReferenceFace.prototype,"sideNormal1",box2d.b2ReferenceFace.prototype.sideNormal1);box2d.b2ReferenceFace.prototype.sideOffset1=0;goog.exportProperty(box2d.b2ReferenceFace.prototype,"sideOffset1",box2d.b2ReferenceFace.prototype.sideOffset1);
+box2d.b2ReferenceFace.prototype.sideNormal2=null;goog.exportProperty(box2d.b2ReferenceFace.prototype,"sideNormal2",box2d.b2ReferenceFace.prototype.sideNormal2);box2d.b2ReferenceFace.prototype.sideOffset2=0;goog.exportProperty(box2d.b2ReferenceFace.prototype,"sideOffset2",box2d.b2ReferenceFace.prototype.sideOffset2);box2d.b2EPColliderVertexType={e_isolated:0,e_concave:1,e_convex:2};goog.exportSymbol("box2d.b2EPColliderVertexType",box2d.b2EPColliderVertexType);
+goog.exportProperty(box2d.b2EPColliderVertexType,"e_isolated",box2d.b2EPColliderVertexType.e_isolated);goog.exportProperty(box2d.b2EPColliderVertexType,"e_concave",box2d.b2EPColliderVertexType.e_concave);goog.exportProperty(box2d.b2EPColliderVertexType,"e_convex",box2d.b2EPColliderVertexType.e_convex);
+box2d.b2EPCollider=function(){this.m_polygonB=new box2d.b2TempPolygon;this.m_xf=new box2d.b2Transform;this.m_centroidB=new box2d.b2Vec2;this.m_v0=new box2d.b2Vec2;this.m_v1=new box2d.b2Vec2;this.m_v2=new box2d.b2Vec2;this.m_v3=new box2d.b2Vec2;this.m_normal0=new box2d.b2Vec2;this.m_normal1=new box2d.b2Vec2;this.m_normal2=new box2d.b2Vec2;this.m_normal=new box2d.b2Vec2;this.m_type2=this.m_type1=box2d.b2EPColliderVertexType.e_isolated;this.m_lowerLimit=new box2d.b2Vec2;this.m_upperLimit=new box2d.b2Vec2;
+this.m_radius=0;this.m_front=!1};goog.exportSymbol("box2d.b2EPCollider",box2d.b2EPCollider);box2d.b2EPCollider.prototype.m_polygonB=null;goog.exportProperty(box2d.b2EPCollider.prototype,"m_polygonB",box2d.b2EPCollider.prototype.m_polygonB);box2d.b2EPCollider.prototype.m_xf=null;goog.exportProperty(box2d.b2EPCollider.prototype,"m_xf",box2d.b2EPCollider.prototype.m_xf);box2d.b2EPCollider.prototype.m_centroidB=null;goog.exportProperty(box2d.b2EPCollider.prototype,"m_centroidB",box2d.b2EPCollider.prototype.m_centroidB);
+box2d.b2EPCollider.prototype.m_v0=null;goog.exportProperty(box2d.b2EPCollider.prototype,"m_v0",box2d.b2EPCollider.prototype.m_v0);box2d.b2EPCollider.prototype.m_v1=null;goog.exportProperty(box2d.b2EPCollider.prototype,"m_v1",box2d.b2EPCollider.prototype.m_v1);box2d.b2EPCollider.prototype.m_v2=null;goog.exportProperty(box2d.b2EPCollider.prototype,"m_v2",box2d.b2EPCollider.prototype.m_v2);box2d.b2EPCollider.prototype.m_v3=null;goog.exportProperty(box2d.b2EPCollider.prototype,"m_v3",box2d.b2EPCollider.prototype.m_v3);
+box2d.b2EPCollider.prototype.m_normal0=null;goog.exportProperty(box2d.b2EPCollider.prototype,"m_normal0",box2d.b2EPCollider.prototype.m_normal0);box2d.b2EPCollider.prototype.m_normal1=null;goog.exportProperty(box2d.b2EPCollider.prototype,"m_normal1",box2d.b2EPCollider.prototype.m_normal1);box2d.b2EPCollider.prototype.m_normal2=null;goog.exportProperty(box2d.b2EPCollider.prototype,"m_normal2",box2d.b2EPCollider.prototype.m_normal2);box2d.b2EPCollider.prototype.m_normal=null;
+goog.exportProperty(box2d.b2EPCollider.prototype,"m_normal",box2d.b2EPCollider.prototype.m_normal);box2d.b2EPCollider.prototype.m_type1=box2d.b2EPColliderVertexType.e_isolated;goog.exportProperty(box2d.b2EPCollider.prototype,"m_type1",box2d.b2EPCollider.prototype.m_type1);box2d.b2EPCollider.prototype.m_type2=box2d.b2EPColliderVertexType.e_isolated;goog.exportProperty(box2d.b2EPCollider.prototype,"m_type2",box2d.b2EPCollider.prototype.m_type2);box2d.b2EPCollider.prototype.m_lowerLimit=null;
+goog.exportProperty(box2d.b2EPCollider.prototype,"m_lowerLimit",box2d.b2EPCollider.prototype.m_lowerLimit);box2d.b2EPCollider.prototype.m_upperLimit=null;goog.exportProperty(box2d.b2EPCollider.prototype,"m_upperLimit",box2d.b2EPCollider.prototype.m_upperLimit);box2d.b2EPCollider.prototype.m_radius=0;goog.exportProperty(box2d.b2EPCollider.prototype,"m_radius",box2d.b2EPCollider.prototype.m_radius);box2d.b2EPCollider.prototype.m_front=!1;goog.exportProperty(box2d.b2EPCollider.prototype,"m_front",box2d.b2EPCollider.prototype.m_front);
+box2d.b2EPCollider.prototype.Collide=function(a,b,c,d,e){box2d.b2MulT_X_X(c,e,this.m_xf);box2d.b2Mul_X_V2(this.m_xf,d.m_centroid,this.m_centroidB);this.m_v0.Copy(b.m_vertex0);this.m_v1.Copy(b.m_vertex1);this.m_v2.Copy(b.m_vertex2);this.m_v3.Copy(b.m_vertex3);c=b.m_hasVertex0;b=b.m_hasVertex3;e=box2d.b2Sub_V2_V2(this.m_v2,this.m_v1,box2d.b2EPCollider.s_edge1);e.Normalize();this.m_normal1.Set(e.y,-e.x);var f=box2d.b2Dot_V2_V2(this.m_normal1,box2d.b2Sub_V2_V2(this.m_centroidB,this.m_v1,box2d.b2Vec2.s_t0)),
+g=0,h=0,k=!1,l=!1;c&&(g=box2d.b2Sub_V2_V2(this.m_v1,this.m_v0,box2d.b2EPCollider.s_edge0),g.Normalize(),this.m_normal0.Set(g.y,-g.x),k=0<=box2d.b2Cross_V2_V2(g,e),g=box2d.b2Dot_V2_V2(this.m_normal0,box2d.b2Sub_V2_V2(this.m_centroidB,this.m_v0,box2d.b2Vec2.s_t0)));b&&(h=box2d.b2Sub_V2_V2(this.m_v3,this.m_v2,box2d.b2EPCollider.s_edge2),h.Normalize(),this.m_normal2.Set(h.y,-h.x),l=0<box2d.b2Cross_V2_V2(e,h),h=box2d.b2Dot_V2_V2(this.m_normal2,box2d.b2Sub_V2_V2(this.m_centroidB,this.m_v2,box2d.b2Vec2.s_t0)));
+c&&b?k&&l?(this.m_front=0<=g||0<=f||0<=h)?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal0),this.m_upperLimit.Copy(this.m_normal2)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):k?(this.m_front=0<=g||0<=f&&0<=h)?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal0),this.m_upperLimit.Copy(this.m_normal1)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(),
+this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):l?(this.m_front=0<=h||0<=g&&0<=f)?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal2)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal0).SelfNeg()):(this.m_front=0<=g&&0<=f&&0<=h)?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),
+this.m_lowerLimit.Copy(this.m_normal2).SelfNeg(),this.m_upperLimit.Copy(this.m_normal0).SelfNeg()):c?k?((this.m_front=0<=g||0<=f)?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal0)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1)),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):(this.m_front=0<=g&&0<=f)?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):(this.m_normal.Copy(this.m_normal1).SelfNeg(),
+this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal0).SelfNeg()):b?l?(this.m_front=0<=f||0<=h)?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal2)):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1)):((this.m_front=0<=f&&0<=h)?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg()):(this.m_normal.Copy(this.m_normal1).SelfNeg(),
+this.m_lowerLimit.Copy(this.m_normal2).SelfNeg()),this.m_upperLimit.Copy(this.m_normal1)):(this.m_front=0<=f)?(this.m_normal.Copy(this.m_normal1),this.m_lowerLimit.Copy(this.m_normal1).SelfNeg(),this.m_upperLimit.Copy(this.m_normal1).SelfNeg()):(this.m_normal.Copy(this.m_normal1).SelfNeg(),this.m_lowerLimit.Copy(this.m_normal1),this.m_upperLimit.Copy(this.m_normal1));this.m_polygonB.count=d.m_count;f=0;for(g=d.m_count;f<g;++f)box2d.b2Mul_X_V2(this.m_xf,d.m_vertices[f],this.m_polygonB.vertices[f]),
+box2d.b2Mul_R_V2(this.m_xf.q,d.m_normals[f],this.m_polygonB.normals[f]);this.m_radius=2*box2d.b2_polygonRadius;a.pointCount=0;c=this.ComputeEdgeSeparation(box2d.b2EPCollider.s_edgeAxis);if(!(c.type===box2d.b2EPAxisType.e_unknown||c.separation>this.m_radius||(b=this.ComputePolygonSeparation(box2d.b2EPCollider.s_polygonAxis),b.type!==box2d.b2EPAxisType.e_unknown&&b.separation>this.m_radius))){c=b.type===box2d.b2EPAxisType.e_unknown?c:b.separation>.98*c.separation+.001?b:c;e=box2d.b2EPCollider.s_ie;
+b=box2d.b2EPCollider.s_rf;if(c.type===box2d.b2EPAxisType.e_edgeA){a.type=box2d.b2ManifoldType.e_faceA;h=0;k=box2d.b2Dot_V2_V2(this.m_normal,this.m_polygonB.normals[0]);f=1;for(g=this.m_polygonB.count;f<g;++f)l=box2d.b2Dot_V2_V2(this.m_normal,this.m_polygonB.normals[f]),l<k&&(k=l,h=f);g=h;f=(g+1)%this.m_polygonB.count;h=e[0];h.v.Copy(this.m_polygonB.vertices[g]);h.id.cf.indexA=0;h.id.cf.indexB=g;h.id.cf.typeA=box2d.b2ContactFeatureType.e_face;h.id.cf.typeB=box2d.b2ContactFeatureType.e_vertex;g=e[1];
+g.v.Copy(this.m_polygonB.vertices[f]);g.id.cf.indexA=0;g.id.cf.indexB=f;g.id.cf.typeA=box2d.b2ContactFeatureType.e_face;g.id.cf.typeB=box2d.b2ContactFeatureType.e_vertex;this.m_front?(b.i1=0,b.i2=1,b.v1.Copy(this.m_v1),b.v2.Copy(this.m_v2),b.normal.Copy(this.m_normal1)):(b.i1=1,b.i2=0,b.v1.Copy(this.m_v2),b.v2.Copy(this.m_v1),b.normal.Copy(this.m_normal1).SelfNeg())}else a.type=box2d.b2ManifoldType.e_faceB,h=e[0],h.v.Copy(this.m_v1),h.id.cf.indexA=0,h.id.cf.indexB=c.index,h.id.cf.typeA=box2d.b2ContactFeatureType.e_vertex,
+h.id.cf.typeB=box2d.b2ContactFeatureType.e_face,g=e[1],g.v.Copy(this.m_v2),g.id.cf.indexA=0,g.id.cf.indexB=c.index,g.id.cf.typeA=box2d.b2ContactFeatureType.e_vertex,g.id.cf.typeB=box2d.b2ContactFeatureType.e_face,b.i1=c.index,b.i2=(b.i1+1)%this.m_polygonB.count,b.v1.Copy(this.m_polygonB.vertices[b.i1]),b.v2.Copy(this.m_polygonB.vertices[b.i2]),b.normal.Copy(this.m_polygonB.normals[b.i1]);b.sideNormal1.Set(b.normal.y,-b.normal.x);b.sideNormal2.Copy(b.sideNormal1).SelfNeg();b.sideOffset1=box2d.b2Dot_V2_V2(b.sideNormal1,
+b.v1);b.sideOffset2=box2d.b2Dot_V2_V2(b.sideNormal2,b.v2);f=box2d.b2EPCollider.s_clipPoints1;h=box2d.b2EPCollider.s_clipPoints2;g=0;g=box2d.b2ClipSegmentToLine(f,e,b.sideNormal1,b.sideOffset1,b.i1);if(!(g<box2d.b2_maxManifoldPoints||(g=box2d.b2ClipSegmentToLine(h,f,b.sideNormal2,b.sideOffset2,b.i2),g<box2d.b2_maxManifoldPoints))){c.type===box2d.b2EPAxisType.e_edgeA?(a.localNormal.Copy(b.normal),a.localPoint.Copy(b.v1)):(a.localNormal.Copy(d.m_normals[b.i1]),a.localPoint.Copy(d.m_vertices[b.i1]));
+f=d=0;for(g=box2d.b2_maxManifoldPoints;f<g;++f)box2d.b2Dot_V2_V2(b.normal,box2d.b2Sub_V2_V2(h[f].v,b.v1,box2d.b2Vec2.s_t0))<=this.m_radius&&(e=a.points[d],c.type===box2d.b2EPAxisType.e_edgeA?(box2d.b2MulT_X_V2(this.m_xf,h[f].v,e.localPoint),e.id=h[f].id):(e.localPoint.Copy(h[f].v),e.id.cf.typeA=h[f].id.cf.typeB,e.id.cf.typeB=h[f].id.cf.typeA,e.id.cf.indexA=h[f].id.cf.indexB,e.id.cf.indexB=h[f].id.cf.indexA),++d);a.pointCount=d}}};goog.exportProperty(box2d.b2EPCollider.prototype,"Collide",box2d.b2EPCollider.prototype.Collide);
+box2d.b2EPCollider.s_edge1=new box2d.b2Vec2;box2d.b2EPCollider.s_edge0=new box2d.b2Vec2;box2d.b2EPCollider.s_edge2=new box2d.b2Vec2;box2d.b2EPCollider.s_ie=box2d.b2ClipVertex.MakeArray(2);box2d.b2EPCollider.s_rf=new box2d.b2ReferenceFace;box2d.b2EPCollider.s_clipPoints1=box2d.b2ClipVertex.MakeArray(2);box2d.b2EPCollider.s_clipPoints2=box2d.b2ClipVertex.MakeArray(2);box2d.b2EPCollider.s_edgeAxis=new box2d.b2EPAxis;box2d.b2EPCollider.s_polygonAxis=new box2d.b2EPAxis;
+box2d.b2EPCollider.prototype.ComputeEdgeSeparation=function(a){a.type=box2d.b2EPAxisType.e_edgeA;a.index=this.m_front?0:1;a.separation=box2d.b2_maxFloat;for(var b=0,c=this.m_polygonB.count;b<c;++b){var d=box2d.b2Dot_V2_V2(this.m_normal,box2d.b2Sub_V2_V2(this.m_polygonB.vertices[b],this.m_v1,box2d.b2Vec2.s_t0));d<a.separation&&(a.separation=d)}return a};goog.exportProperty(box2d.b2EPCollider.prototype,"ComputeEdgeSeparation",box2d.b2EPCollider.prototype.ComputeEdgeSeparation);
+box2d.b2EPCollider.prototype.ComputePolygonSeparation=function(a){a.type=box2d.b2EPAxisType.e_unknown;a.index=-1;a.separation=-box2d.b2_maxFloat;for(var b=box2d.b2EPCollider.s_perp.Set(-this.m_normal.y,this.m_normal.x),c=0,d=this.m_polygonB.count;c<d;++c){var e=box2d.b2EPCollider.s_n.Copy(this.m_polygonB.normals[c]).SelfNeg(),f=box2d.b2Dot_V2_V2(e,box2d.b2Sub_V2_V2(this.m_polygonB.vertices[c],this.m_v1,box2d.b2Vec2.s_t0)),g=box2d.b2Dot_V2_V2(e,box2d.b2Sub_V2_V2(this.m_polygonB.vertices[c],this.m_v2,
+box2d.b2Vec2.s_t0)),f=box2d.b2Min(f,g);if(f>this.m_radius){a.type=box2d.b2EPAxisType.e_edgeB;a.index=c;a.separation=f;break}if(0<=box2d.b2Dot_V2_V2(e,b)){if(box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(e,this.m_upperLimit,box2d.b2Vec2.s_t0),this.m_normal)<-box2d.b2_angularSlop)continue}else if(box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(e,this.m_lowerLimit,box2d.b2Vec2.s_t0),this.m_normal)<-box2d.b2_angularSlop)continue;f>a.separation&&(a.type=box2d.b2EPAxisType.e_edgeB,a.index=c,a.separation=f)}return a};
+goog.exportProperty(box2d.b2EPCollider.prototype,"ComputePolygonSeparation",box2d.b2EPCollider.prototype.ComputePolygonSeparation);box2d.b2EPCollider.s_n=new box2d.b2Vec2;box2d.b2EPCollider.s_perp=new box2d.b2Vec2;box2d.b2CollideEdgeAndPolygon=function(a,b,c,d,e){box2d.b2CollideEdgeAndPolygon.s_collider.Collide(a,b,c,d,e)};goog.exportSymbol("box2d.b2CollideEdgeAndPolygon",box2d.b2CollideEdgeAndPolygon);box2d.b2CollideEdgeAndPolygon.s_collider=new box2d.b2EPCollider;box2d.b2CollidePolygon={};
+box2d.b2FindMaxSeparation=function(a,b,c,d,e){var f=b.m_count,g=d.m_count,h=b.m_normals;b=b.m_vertices;d=d.m_vertices;c=box2d.b2MulT_X_X(e,c,box2d.b2FindMaxSeparation.s_xf);e=0;for(var k=-box2d.b2_maxFloat,l=0;l<f;++l){for(var m=box2d.b2Mul_R_V2(c.q,h[l],box2d.b2FindMaxSeparation.s_n),n=box2d.b2Mul_X_V2(c,b[l],box2d.b2FindMaxSeparation.s_v1),p=box2d.b2_maxFloat,q=0;q<g;++q){var r=box2d.b2Dot_V2_V2(m,box2d.b2Sub_V2_V2(d[q],n,box2d.b2Vec2.s_t0));r<p&&(p=r)}p>k&&(k=p,e=l)}a[0]=e;return k};
+goog.exportSymbol("box2d.b2FindMaxSeparation",box2d.b2FindMaxSeparation);box2d.b2FindMaxSeparation.s_xf=new box2d.b2Transform;box2d.b2FindMaxSeparation.s_n=new box2d.b2Vec2;box2d.b2FindMaxSeparation.s_v1=new box2d.b2Vec2;
+box2d.b2FindIncidentEdge=function(a,b,c,d,e,f){var g=b.m_count,h=b.m_normals,k=e.m_count;b=e.m_vertices;e=e.m_normals;box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<=d&&d<g);c=box2d.b2MulT_R_V2(f.q,box2d.b2Mul_R_V2(c.q,h[d],box2d.b2Vec2.s_t0),box2d.b2FindIncidentEdge.s_normal1);for(var g=0,h=box2d.b2_maxFloat,l=0;l<k;++l){var m=box2d.b2Dot_V2_V2(c,e[l]);m<h&&(h=m,g=l)}e=g;k=(e+1)%k;c=a[0];box2d.b2Mul_X_V2(f,b[e],c.v);c=c.id.cf;c.indexA=d;c.indexB=e;c.typeA=box2d.b2ContactFeatureType.e_face;c.typeB=box2d.b2ContactFeatureType.e_vertex;
+a=a[1];box2d.b2Mul_X_V2(f,b[k],a.v);f=a.id.cf;f.indexA=d;f.indexB=k;f.typeA=box2d.b2ContactFeatureType.e_face;f.typeB=box2d.b2ContactFeatureType.e_vertex};goog.exportSymbol("box2d.b2FindIncidentEdge",box2d.b2FindIncidentEdge);box2d.b2FindIncidentEdge.s_normal1=new box2d.b2Vec2;
+box2d.b2CollidePolygons=function(a,b,c,d,e){a.pointCount=0;var f=b.m_radius+d.m_radius,g=box2d.b2CollidePolygons.s_edgeA;g[0]=0;var h=box2d.b2FindMaxSeparation(g,b,c,d,e);if(!(h>f)){var k=box2d.b2CollidePolygons.s_edgeB;k[0]=0;var l=box2d.b2FindMaxSeparation(k,d,e,b,c);if(!(l>f)){var m=0,n=0;l>.98*h+.001?(h=d,d=b,b=e,m=k[0],a.type=box2d.b2ManifoldType.e_faceB,n=1):(h=b,b=c,c=e,m=g[0],a.type=box2d.b2ManifoldType.e_faceA,n=0);g=box2d.b2CollidePolygons.s_incidentEdge;box2d.b2FindIncidentEdge(g,h,b,m,
+d,c);e=h.m_vertices;var k=m,h=(m+1)%h.m_count,p=e[k],q=e[h],m=box2d.b2Sub_V2_V2(q,p,box2d.b2CollidePolygons.s_localTangent);m.Normalize();e=box2d.b2Cross_V2_S(m,1,box2d.b2CollidePolygons.s_localNormal);d=box2d.b2Mid_V2_V2(p,q,box2d.b2CollidePolygons.s_planePoint);var l=box2d.b2Mul_R_V2(b.q,m,box2d.b2CollidePolygons.s_tangent),m=box2d.b2Cross_V2_S(l,1,box2d.b2CollidePolygons.s_normal),p=box2d.b2Mul_X_V2(b,p,box2d.b2CollidePolygons.s_v11),r=box2d.b2Mul_X_V2(b,q,box2d.b2CollidePolygons.s_v12);b=box2d.b2Dot_V2_V2(m,
+p);var q=-box2d.b2Dot_V2_V2(l,p)+f,r=box2d.b2Dot_V2_V2(l,r)+f,u=box2d.b2CollidePolygons.s_clipPoints1,p=box2d.b2CollidePolygons.s_clipPoints2,t=box2d.b2CollidePolygons.s_ntangent.Copy(l).SelfNeg(),g=box2d.b2ClipSegmentToLine(u,g,t,q,k);if(!(2>g||(g=box2d.b2ClipSegmentToLine(p,u,l,r,h),2>g))){a.localNormal.Copy(e);a.localPoint.Copy(d);for(k=g=0;k<box2d.b2_maxManifoldPoints;++k)e=p[k],box2d.b2Dot_V2_V2(m,e.v)-b<=f&&(h=a.points[g],box2d.b2MulT_X_V2(c,e.v,h.localPoint),h.id.Copy(e.id),n&&(e=h.id.cf,h.id.cf.indexA=
+e.indexB,h.id.cf.indexB=e.indexA,h.id.cf.typeA=e.typeB,h.id.cf.typeB=e.typeA),++g);a.pointCount=g}}}};goog.exportSymbol("box2d.b2CollidePolygons",box2d.b2CollidePolygons);box2d.b2CollidePolygons.s_incidentEdge=box2d.b2ClipVertex.MakeArray(2);box2d.b2CollidePolygons.s_clipPoints1=box2d.b2ClipVertex.MakeArray(2);box2d.b2CollidePolygons.s_clipPoints2=box2d.b2ClipVertex.MakeArray(2);box2d.b2CollidePolygons.s_edgeA=box2d.b2MakeNumberArray(1);box2d.b2CollidePolygons.s_edgeB=box2d.b2MakeNumberArray(1);
+box2d.b2CollidePolygons.s_localTangent=new box2d.b2Vec2;box2d.b2CollidePolygons.s_localNormal=new box2d.b2Vec2;box2d.b2CollidePolygons.s_planePoint=new box2d.b2Vec2;box2d.b2CollidePolygons.s_normal=new box2d.b2Vec2;box2d.b2CollidePolygons.s_tangent=new box2d.b2Vec2;box2d.b2CollidePolygons.s_ntangent=new box2d.b2Vec2;box2d.b2CollidePolygons.s_v11=new box2d.b2Vec2;box2d.b2CollidePolygons.s_v12=new box2d.b2Vec2;box2d.b2TreeNode=function(a){this.m_id=a||0;this.aabb=new box2d.b2AABB};goog.exportSymbol("box2d.b2TreeNode",box2d.b2TreeNode);box2d.b2TreeNode.prototype.m_id=0;goog.exportProperty(box2d.b2TreeNode.prototype,"m_id",box2d.b2TreeNode.prototype.m_id);box2d.b2TreeNode.prototype.aabb=null;goog.exportProperty(box2d.b2TreeNode.prototype,"aabb",box2d.b2TreeNode.prototype.aabb);box2d.b2TreeNode.prototype.userData=null;goog.exportProperty(box2d.b2TreeNode.prototype,"userData",box2d.b2TreeNode.prototype.userData);
+box2d.b2TreeNode.prototype.parent=null;goog.exportProperty(box2d.b2TreeNode.prototype,"parent",box2d.b2TreeNode.prototype.parent);box2d.b2TreeNode.prototype.child1=null;goog.exportProperty(box2d.b2TreeNode.prototype,"child1",box2d.b2TreeNode.prototype.child1);box2d.b2TreeNode.prototype.child2=null;goog.exportProperty(box2d.b2TreeNode.prototype,"child2",box2d.b2TreeNode.prototype.child2);box2d.b2TreeNode.prototype.height=0;goog.exportProperty(box2d.b2TreeNode.prototype,"height",box2d.b2TreeNode.prototype.height);
+box2d.b2TreeNode.prototype.IsLeaf=function(){return null===this.child1};goog.exportProperty(box2d.b2TreeNode.prototype,"IsLeaf",box2d.b2TreeNode.prototype.IsLeaf);box2d.b2DynamicTree=function(){};goog.exportSymbol("box2d.b2DynamicTree",box2d.b2DynamicTree);box2d.b2DynamicTree.prototype.m_root=null;goog.exportProperty(box2d.b2DynamicTree.prototype,"m_root",box2d.b2DynamicTree.prototype.m_root);box2d.b2DynamicTree.prototype.m_freeList=null;
+goog.exportProperty(box2d.b2DynamicTree.prototype,"m_freeList",box2d.b2DynamicTree.prototype.m_freeList);box2d.b2DynamicTree.prototype.m_path=0;goog.exportProperty(box2d.b2DynamicTree.prototype,"m_path",box2d.b2DynamicTree.prototype.m_path);box2d.b2DynamicTree.prototype.m_insertionCount=0;goog.exportProperty(box2d.b2DynamicTree.prototype,"m_insertionCount",box2d.b2DynamicTree.prototype.m_insertionCount);box2d.b2DynamicTree.s_stack=new box2d.b2GrowableStack(256);box2d.b2DynamicTree.s_r=new box2d.b2Vec2;
+box2d.b2DynamicTree.s_v=new box2d.b2Vec2;box2d.b2DynamicTree.s_abs_v=new box2d.b2Vec2;box2d.b2DynamicTree.s_segmentAABB=new box2d.b2AABB;box2d.b2DynamicTree.s_subInput=new box2d.b2RayCastInput;box2d.b2DynamicTree.s_combinedAABB=new box2d.b2AABB;box2d.b2DynamicTree.s_aabb=new box2d.b2AABB;box2d.b2DynamicTree.prototype.GetUserData=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(null!==a);return a.userData};goog.exportProperty(box2d.b2DynamicTree.prototype,"GetUserData",box2d.b2DynamicTree.prototype.GetUserData);
+box2d.b2DynamicTree.prototype.GetFatAABB=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(null!==a);return a.aabb};goog.exportProperty(box2d.b2DynamicTree.prototype,"GetFatAABB",box2d.b2DynamicTree.prototype.GetFatAABB);box2d.b2DynamicTree.prototype.Query=function(a,b){if(null!==this.m_root){var c=box2d.b2DynamicTree.s_stack.Reset();for(c.Push(this.m_root);0<c.GetCount();){var d=c.Pop();if(null!==d&&d.aabb.TestOverlap(b))if(d.IsLeaf()){if(!a(d))break}else c.Push(d.child1),c.Push(d.child2)}}};
+goog.exportProperty(box2d.b2DynamicTree.prototype,"Query",box2d.b2DynamicTree.prototype.Query);
+box2d.b2DynamicTree.prototype.RayCast=function(a,b){if(null!==this.m_root){var c=b.p1,d=b.p2,e=box2d.b2Sub_V2_V2(d,c,box2d.b2DynamicTree.s_r);box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<e.LengthSquared());e.Normalize();var e=box2d.b2Cross_S_V2(1,e,box2d.b2DynamicTree.s_v),f=box2d.b2Abs_V2(e,box2d.b2DynamicTree.s_abs_v),g=b.maxFraction,h=box2d.b2DynamicTree.s_segmentAABB,k=c.x+g*(d.x-c.x),l=c.y+g*(d.y-c.y);h.lowerBound.x=box2d.b2Min(c.x,k);h.lowerBound.y=box2d.b2Min(c.y,l);h.upperBound.x=box2d.b2Max(c.x,
+k);h.upperBound.y=box2d.b2Max(c.y,l);var m=box2d.b2DynamicTree.s_stack.Reset();for(m.Push(this.m_root);0<m.GetCount();)if(k=m.Pop(),null!==k&&box2d.b2TestOverlap_AABB(k.aabb,h)){var l=k.aabb.GetCenter(),n=k.aabb.GetExtents();if(!(0<box2d.b2Abs(box2d.b2Dot_V2_V2(e,box2d.b2Sub_V2_V2(c,l,box2d.b2Vec2.s_t0)))-box2d.b2Dot_V2_V2(f,n)))if(k.IsLeaf()){l=box2d.b2DynamicTree.s_subInput;l.p1.Copy(b.p1);l.p2.Copy(b.p2);l.maxFraction=g;k=a(l,k);if(0===k)break;0<k&&(g=k,k=c.x+g*(d.x-c.x),l=c.y+g*(d.y-c.y),h.lowerBound.x=
+box2d.b2Min(c.x,k),h.lowerBound.y=box2d.b2Min(c.y,l),h.upperBound.x=box2d.b2Max(c.x,k),h.upperBound.y=box2d.b2Max(c.y,l))}else m.Push(k.child1),m.Push(k.child2)}}};goog.exportProperty(box2d.b2DynamicTree.prototype,"RayCast",box2d.b2DynamicTree.prototype.RayCast);box2d.b2DynamicTree.prototype.AllocateNode=function(){if(this.m_freeList){var a=this.m_freeList;this.m_freeList=a.parent;a.parent=null;a.child1=null;a.child2=null;a.height=0;a.userData=null;return a}return new box2d.b2TreeNode(box2d.b2DynamicTree.prototype.s_node_id++)};
+goog.exportProperty(box2d.b2DynamicTree.prototype,"AllocateNode",box2d.b2DynamicTree.prototype.AllocateNode);box2d.b2DynamicTree.prototype.s_node_id=0;box2d.b2DynamicTree.prototype.FreeNode=function(a){a.parent=this.m_freeList;a.height=-1;this.m_freeList=a};goog.exportProperty(box2d.b2DynamicTree.prototype,"FreeNode",box2d.b2DynamicTree.prototype.FreeNode);
+box2d.b2DynamicTree.prototype.CreateProxy=function(a,b){var c=this.AllocateNode(),d=box2d.b2_aabbExtension,e=box2d.b2_aabbExtension;c.aabb.lowerBound.x=a.lowerBound.x-d;c.aabb.lowerBound.y=a.lowerBound.y-e;c.aabb.upperBound.x=a.upperBound.x+d;c.aabb.upperBound.y=a.upperBound.y+e;c.userData=b;c.height=0;this.InsertLeaf(c);return c};goog.exportProperty(box2d.b2DynamicTree.prototype,"CreateProxy",box2d.b2DynamicTree.prototype.CreateProxy);
+box2d.b2DynamicTree.prototype.DestroyProxy=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(a.IsLeaf());this.RemoveLeaf(a);this.FreeNode(a)};goog.exportProperty(box2d.b2DynamicTree.prototype,"DestroyProxy",box2d.b2DynamicTree.prototype.DestroyProxy);
+box2d.b2DynamicTree.prototype.MoveProxy=function(a,b,c){box2d.ENABLE_ASSERTS&&box2d.b2Assert(a.IsLeaf());if(a.aabb.Contains(b))return!1;this.RemoveLeaf(a);var d=box2d.b2_aabbExtension+box2d.b2_aabbMultiplier*(0<c.x?c.x:-c.x);c=box2d.b2_aabbExtension+box2d.b2_aabbMultiplier*(0<c.y?c.y:-c.y);a.aabb.lowerBound.x=b.lowerBound.x-d;a.aabb.lowerBound.y=b.lowerBound.y-c;a.aabb.upperBound.x=b.upperBound.x+d;a.aabb.upperBound.y=b.upperBound.y+c;this.InsertLeaf(a);return!0};
+goog.exportProperty(box2d.b2DynamicTree.prototype,"MoveProxy",box2d.b2DynamicTree.prototype.MoveProxy);
+box2d.b2DynamicTree.prototype.InsertLeaf=function(a){++this.m_insertionCount;if(null===this.m_root)this.m_root=a,this.m_root.parent=null;else{var b=a.aabb;b.GetCenter();for(var c=this.m_root,d,e;!c.IsLeaf();){d=c.child1;e=c.child2;var f=c.aabb.GetPerimeter(),g=box2d.b2DynamicTree.s_combinedAABB;g.Combine2(c.aabb,b);var h=g.GetPerimeter(),g=2*h,h=2*(h-f),k=box2d.b2DynamicTree.s_aabb,l,m;d.IsLeaf()?(k.Combine2(b,d.aabb),f=k.GetPerimeter()+h):(k.Combine2(b,d.aabb),l=d.aabb.GetPerimeter(),m=k.GetPerimeter(),
+f=m-l+h);e.IsLeaf()?(k.Combine2(b,e.aabb),h=k.GetPerimeter()+h):(k.Combine2(b,e.aabb),l=e.aabb.GetPerimeter(),m=k.GetPerimeter(),h=m-l+h);if(g<f&&g<h)break;c=f<h?d:e}d=c.parent;e=this.AllocateNode();e.parent=d;e.userData=null;e.aabb.Combine2(b,c.aabb);e.height=c.height+1;d?(d.child1===c?d.child1=e:d.child2=e,e.child1=c,e.child2=a,c.parent=e,a.parent=e):(e.child1=c,e.child2=a,c.parent=e,this.m_root=a.parent=e);for(c=a.parent;null!==c;)c=this.Balance(c),d=c.child1,e=c.child2,box2d.ENABLE_ASSERTS&&box2d.b2Assert(null!==
+d),box2d.ENABLE_ASSERTS&&box2d.b2Assert(null!==e),c.height=1+box2d.b2Max(d.height,e.height),c.aabb.Combine2(d.aabb,e.aabb),c=c.parent}};goog.exportProperty(box2d.b2DynamicTree.prototype,"InsertLeaf",box2d.b2DynamicTree.prototype.InsertLeaf);
+box2d.b2DynamicTree.prototype.RemoveLeaf=function(a){if(a===this.m_root)this.m_root=null;else{var b=a.parent,c=b.parent;a=b.child1===a?b.child2:b.child1;if(c)for(c.child1===b?c.child1=a:c.child2=a,a.parent=c,this.FreeNode(b),b=c;b;)b=this.Balance(b),c=b.child1,a=b.child2,b.aabb.Combine2(c.aabb,a.aabb),b.height=1+box2d.b2Max(c.height,a.height),b=b.parent;else this.m_root=a,a.parent=null,this.FreeNode(b)}};goog.exportProperty(box2d.b2DynamicTree.prototype,"RemoveLeaf",box2d.b2DynamicTree.prototype.RemoveLeaf);
+box2d.b2DynamicTree.prototype.Balance=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(null!==a);if(a.IsLeaf()||2>a.height)return a;var b=a.child1,c=a.child2,d=c.height-b.height;if(1<d){var d=c.child1,e=c.child2;c.child1=a;c.parent=a.parent;a.parent=c;null!==c.parent?c.parent.child1===a?c.parent.child1=c:(box2d.ENABLE_ASSERTS&&box2d.b2Assert(c.parent.child2===a),c.parent.child2=c):this.m_root=c;d.height>e.height?(c.child2=d,a.child2=e,e.parent=a,a.aabb.Combine2(b.aabb,e.aabb),c.aabb.Combine2(a.aabb,
+d.aabb),a.height=1+box2d.b2Max(b.height,e.height),c.height=1+box2d.b2Max(a.height,d.height)):(c.child2=e,a.child2=d,d.parent=a,a.aabb.Combine2(b.aabb,d.aabb),c.aabb.Combine2(a.aabb,e.aabb),a.height=1+box2d.b2Max(b.height,d.height),c.height=1+box2d.b2Max(a.height,e.height));return c}return-1>d?(d=b.child1,e=b.child2,b.child1=a,b.parent=a.parent,a.parent=b,null!==b.parent?b.parent.child1===a?b.parent.child1=b:(box2d.ENABLE_ASSERTS&&box2d.b2Assert(b.parent.child2===a),b.parent.child2=b):this.m_root=
+b,d.height>e.height?(b.child2=d,a.child1=e,e.parent=a,a.aabb.Combine2(c.aabb,e.aabb),b.aabb.Combine2(a.aabb,d.aabb),a.height=1+box2d.b2Max(c.height,e.height),b.height=1+box2d.b2Max(a.height,d.height)):(b.child2=e,a.child1=d,d.parent=a,a.aabb.Combine2(c.aabb,d.aabb),b.aabb.Combine2(a.aabb,e.aabb),a.height=1+box2d.b2Max(c.height,d.height),b.height=1+box2d.b2Max(a.height,e.height)),b):a};goog.exportProperty(box2d.b2DynamicTree.prototype,"Balance",box2d.b2DynamicTree.prototype.Balance);
+box2d.b2DynamicTree.prototype.GetHeight=function(){return null===this.m_root?0:this.m_root.height};goog.exportProperty(box2d.b2DynamicTree.prototype,"GetHeight",box2d.b2DynamicTree.prototype.GetHeight);box2d.b2DynamicTree.prototype.GetAreaRatio=function(){if(null===this.m_root)return 0;var a=this.m_root.aabb.GetPerimeter(),b=function(a){if(null===a||a.IsLeaf())return 0;var d=a.aabb.GetPerimeter(),d=d+b(a.child1);return d+=b(a.child2)};return b(this.m_root)/a};
+goog.exportProperty(box2d.b2DynamicTree.prototype,"GetAreaRatio",box2d.b2DynamicTree.prototype.GetAreaRatio);box2d.b2DynamicTree.prototype.ComputeHeightNode=function(a){if(a.IsLeaf())return 0;var b=this.ComputeHeightNode(a.child1);a=this.ComputeHeightNode(a.child2);return 1+box2d.b2Max(b,a)};goog.exportProperty(box2d.b2DynamicTree.prototype,"ComputeHeightNode",box2d.b2DynamicTree.prototype.ComputeHeightNode);box2d.b2DynamicTree.prototype.ComputeHeight=function(){return this.ComputeHeightNode(this.m_root)};
+goog.exportProperty(box2d.b2DynamicTree.prototype,"ComputeHeight",box2d.b2DynamicTree.prototype.ComputeHeight);
+box2d.b2DynamicTree.prototype.ValidateStructure=function(a){if(null!==a){a===this.m_root&&box2d.ENABLE_ASSERTS&&box2d.b2Assert(null===a.parent);var b=a.child1,c=a.child2;a.IsLeaf()?(box2d.ENABLE_ASSERTS&&box2d.b2Assert(null===b),box2d.ENABLE_ASSERTS&&box2d.b2Assert(null===c),box2d.ENABLE_ASSERTS&&box2d.b2Assert(0===a.height)):(box2d.ENABLE_ASSERTS&&box2d.b2Assert(b.parent===a),box2d.ENABLE_ASSERTS&&box2d.b2Assert(c.parent===a),this.ValidateStructure(b),this.ValidateStructure(c))}};
+goog.exportProperty(box2d.b2DynamicTree.prototype,"ValidateStructure",box2d.b2DynamicTree.prototype.ValidateStructure);
+box2d.b2DynamicTree.prototype.ValidateMetrics=function(a){if(null!==a){var b=a.child1,c=a.child2;if(a.IsLeaf())box2d.ENABLE_ASSERTS&&box2d.b2Assert(null===b),box2d.ENABLE_ASSERTS&&box2d.b2Assert(null===c),box2d.ENABLE_ASSERTS&&box2d.b2Assert(0===a.height);else{var d;d=1+box2d.b2Max(b.height,c.height);box2d.ENABLE_ASSERTS&&box2d.b2Assert(a.height===d);d=box2d.b2DynamicTree.s_aabb;d.Combine2(b.aabb,c.aabb);box2d.ENABLE_ASSERTS&&box2d.b2Assert(d.lowerBound===a.aabb.lowerBound);box2d.ENABLE_ASSERTS&&
+box2d.b2Assert(d.upperBound===a.aabb.upperBound);this.ValidateMetrics(b);this.ValidateMetrics(c)}}};goog.exportProperty(box2d.b2DynamicTree.prototype,"ValidateMetrics",box2d.b2DynamicTree.prototype.ValidateMetrics);box2d.b2DynamicTree.prototype.Validate=function(){this.ValidateStructure(this.m_root);this.ValidateMetrics(this.m_root);for(var a=0,b=this.m_freeList;null!==b;)b=b.parent,++a;box2d.ENABLE_ASSERTS&&box2d.b2Assert(this.GetHeight()===this.ComputeHeight())};
+goog.exportProperty(box2d.b2DynamicTree.prototype,"Validate",box2d.b2DynamicTree.prototype.Validate);box2d.b2DynamicTree.prototype.GetMaxBalance=function(){var a;a=this.m_root;null===a?a=0:1>=a.height?a=0:(box2d.ENABLE_ASSERTS&&box2d.b2Assert(!a.IsLeaf()),a=box2d.b2Abs(a.child2.height-a.child1.height),a=box2d.b2Max(0,a));return a};goog.exportProperty(box2d.b2DynamicTree.prototype,"GetMaxBalance",box2d.b2DynamicTree.prototype.GetMaxBalance);box2d.b2DynamicTree.prototype.RebuildBottomUp=function(){this.Validate()};
+goog.exportProperty(box2d.b2DynamicTree.prototype,"RebuildBottomUp",box2d.b2DynamicTree.prototype.RebuildBottomUp);box2d.b2DynamicTree.prototype.ShiftOrigin=function(a){var b=function(a,d){if(null!==a&&!(1>=a.height)){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!a.IsLeaf());var e=a.child2;b(a.child1,d);b(e,d);a.aabb.lowerBound.SelfSub(d);a.aabb.upperBound.SelfSub(d)}};b(this.m_root,a)};goog.exportProperty(box2d.b2DynamicTree.prototype,"ShiftOrigin",box2d.b2DynamicTree.prototype.ShiftOrigin);box2d.b2Pair=function(){};goog.exportSymbol("box2d.b2Pair",box2d.b2Pair);box2d.b2Pair.prototype.proxyA=null;goog.exportProperty(box2d.b2Pair.prototype,"proxyA",box2d.b2Pair.prototype.proxyA);box2d.b2Pair.prototype.proxyB=null;goog.exportProperty(box2d.b2Pair.prototype,"proxyB",box2d.b2Pair.prototype.proxyB);box2d.b2BroadPhase=function(){this.m_tree=new box2d.b2DynamicTree;this.m_moveBuffer=[];this.m_pairBuffer=[]};goog.exportSymbol("box2d.b2BroadPhase",box2d.b2BroadPhase);
+box2d.b2BroadPhase.prototype.m_tree=null;goog.exportProperty(box2d.b2BroadPhase.prototype,"m_tree",box2d.b2BroadPhase.prototype.m_tree);box2d.b2BroadPhase.prototype.m_proxyCount=0;goog.exportProperty(box2d.b2BroadPhase.prototype,"m_proxyCount",box2d.b2BroadPhase.prototype.m_proxyCount);box2d.b2BroadPhase.prototype.m_moveCount=0;goog.exportProperty(box2d.b2BroadPhase.prototype,"m_moveCount",box2d.b2BroadPhase.prototype.m_moveCount);box2d.b2BroadPhase.prototype.m_moveBuffer=null;
+goog.exportProperty(box2d.b2BroadPhase.prototype,"m_moveBuffer",box2d.b2BroadPhase.prototype.m_moveBuffer);box2d.b2BroadPhase.prototype.m_pairCount=0;goog.exportProperty(box2d.b2BroadPhase.prototype,"m_pairCount",box2d.b2BroadPhase.prototype.m_pairCount);box2d.b2BroadPhase.prototype.m_pairBuffer=null;goog.exportProperty(box2d.b2BroadPhase.prototype,"m_pairBuffer",box2d.b2BroadPhase.prototype.m_pairBuffer);
+box2d.b2BroadPhase.prototype.CreateProxy=function(a,b){var c=this.m_tree.CreateProxy(a,b);++this.m_proxyCount;this.BufferMove(c);return c};goog.exportProperty(box2d.b2BroadPhase.prototype,"CreateProxy",box2d.b2BroadPhase.prototype.CreateProxy);box2d.b2BroadPhase.prototype.DestroyProxy=function(a){this.UnBufferMove(a);--this.m_proxyCount;this.m_tree.DestroyProxy(a)};goog.exportProperty(box2d.b2BroadPhase.prototype,"DestroyProxy",box2d.b2BroadPhase.prototype.DestroyProxy);
+box2d.b2BroadPhase.prototype.MoveProxy=function(a,b,c){this.m_tree.MoveProxy(a,b,c)&&this.BufferMove(a)};goog.exportProperty(box2d.b2BroadPhase.prototype,"MoveProxy",box2d.b2BroadPhase.prototype.MoveProxy);box2d.b2BroadPhase.prototype.TouchProxy=function(a){this.BufferMove(a)};goog.exportProperty(box2d.b2BroadPhase.prototype,"TouchProxy",box2d.b2BroadPhase.prototype.TouchProxy);box2d.b2BroadPhase.prototype.GetFatAABB=function(a){return this.m_tree.GetFatAABB(a)};
+goog.exportProperty(box2d.b2BroadPhase.prototype,"GetFatAABB",box2d.b2BroadPhase.prototype.GetFatAABB);box2d.b2BroadPhase.prototype.GetUserData=function(a){return this.m_tree.GetUserData(a)};goog.exportProperty(box2d.b2BroadPhase.prototype,"GetUserData",box2d.b2BroadPhase.prototype.GetUserData);box2d.b2BroadPhase.prototype.TestOverlap=function(a,b){var c=this.m_tree.GetFatAABB(a),d=this.m_tree.GetFatAABB(b);return box2d.b2TestOverlap_AABB(c,d)};
+goog.exportProperty(box2d.b2BroadPhase.prototype,"TestOverlap",box2d.b2BroadPhase.prototype.TestOverlap);box2d.b2BroadPhase.prototype.GetProxyCount=function(){return this.m_proxyCount};goog.exportProperty(box2d.b2BroadPhase.prototype,"GetProxyCount",box2d.b2BroadPhase.prototype.GetProxyCount);box2d.b2BroadPhase.prototype.GetTreeHeight=function(){return this.m_tree.GetHeight()};goog.exportProperty(box2d.b2BroadPhase.prototype,"GetTreeHeight",box2d.b2BroadPhase.prototype.GetTreeHeight);
+box2d.b2BroadPhase.prototype.GetTreeBalance=function(){return this.m_tree.GetMaxBalance()};goog.exportProperty(box2d.b2BroadPhase.prototype,"GetTreeBalance",box2d.b2BroadPhase.prototype.GetTreeBalance);box2d.b2BroadPhase.prototype.GetTreeQuality=function(){return this.m_tree.GetAreaRatio()};goog.exportProperty(box2d.b2BroadPhase.prototype,"GetTreeQuality",box2d.b2BroadPhase.prototype.GetTreeQuality);box2d.b2BroadPhase.prototype.ShiftOrigin=function(a){this.m_tree.ShiftOrigin(a)};
+goog.exportProperty(box2d.b2BroadPhase.prototype,"ShiftOrigin",box2d.b2BroadPhase.prototype.ShiftOrigin);
+box2d.b2BroadPhase.prototype.UpdatePairs=function(a){for(var b=this.m_pairCount=0;b<this.m_moveCount;++b){var c=this.m_moveBuffer[b];if(null!==c){var d=this,e=this.m_tree.GetFatAABB(c);this.m_tree.Query(function(a){if(a.m_id===c.m_id)return!0;d.m_pairCount===d.m_pairBuffer.length&&(d.m_pairBuffer[d.m_pairCount]=new box2d.b2Pair);var b=d.m_pairBuffer[d.m_pairCount];a.m_id<c.m_id?(b.proxyA=a,b.proxyB=c):(b.proxyA=c,b.proxyB=a);++d.m_pairCount;return!0},e)}}this.m_moveCount=0;this.m_pairBuffer.length=
+this.m_pairCount;this.m_pairBuffer.sort(box2d.b2PairLessThan);for(b=0;b<this.m_pairCount;){var e=this.m_pairBuffer[b],f=this.m_tree.GetUserData(e.proxyA),g=this.m_tree.GetUserData(e.proxyB);a.AddPair(f,g);for(++b;b<this.m_pairCount;){f=this.m_pairBuffer[b];if(f.proxyA.m_id!==e.proxyA.m_id||f.proxyB.m_id!==e.proxyB.m_id)break;++b}}};goog.exportProperty(box2d.b2BroadPhase.prototype,"UpdatePairs",box2d.b2BroadPhase.prototype.UpdatePairs);
+box2d.b2BroadPhase.prototype.Query=function(a,b){this.m_tree.Query(a,b)};goog.exportProperty(box2d.b2BroadPhase.prototype,"Query",box2d.b2BroadPhase.prototype.Query);box2d.b2BroadPhase.prototype.RayCast=function(a,b){this.m_tree.RayCast(a,b)};goog.exportProperty(box2d.b2BroadPhase.prototype,"RayCast",box2d.b2BroadPhase.prototype.RayCast);box2d.b2BroadPhase.prototype.BufferMove=function(a){this.m_moveBuffer[this.m_moveCount]=a;++this.m_moveCount};
+goog.exportProperty(box2d.b2BroadPhase.prototype,"BufferMove",box2d.b2BroadPhase.prototype.BufferMove);box2d.b2BroadPhase.prototype.UnBufferMove=function(a){a=this.m_moveBuffer.indexOf(a);this.m_moveBuffer[a]=null};goog.exportProperty(box2d.b2BroadPhase.prototype,"UnBufferMove",box2d.b2BroadPhase.prototype.UnBufferMove);box2d.b2PairLessThan=function(a,b){return a.proxyA.m_id===b.proxyA.m_id?a.proxyB.m_id-b.proxyB.m_id:a.proxyA.m_id-b.proxyA.m_id};box2d.b2MassData=function(){this.center=new box2d.b2Vec2(0,0)};goog.exportSymbol("box2d.b2MassData",box2d.b2MassData);box2d.b2MassData.prototype.mass=0;goog.exportProperty(box2d.b2MassData.prototype,"mass",box2d.b2MassData.prototype.mass);box2d.b2MassData.prototype.center=null;goog.exportProperty(box2d.b2MassData.prototype,"center",box2d.b2MassData.prototype.center);box2d.b2MassData.prototype.I=0;goog.exportProperty(box2d.b2MassData.prototype,"I",box2d.b2MassData.prototype.I);
+box2d.b2ShapeType={e_unknown:-1,e_circleShape:0,e_edgeShape:1,e_polygonShape:2,e_chainShape:3,e_shapeTypeCount:4};goog.exportSymbol("box2d.b2ShapeType",box2d.b2ShapeType);goog.exportProperty(box2d.b2ShapeType,"e_unknown",box2d.b2ShapeType.e_unknown);goog.exportProperty(box2d.b2ShapeType,"e_circleShape",box2d.b2ShapeType.e_circleShape);goog.exportProperty(box2d.b2ShapeType,"e_edgeShape",box2d.b2ShapeType.e_edgeShape);goog.exportProperty(box2d.b2ShapeType,"e_polygonShape",box2d.b2ShapeType.e_polygonShape);
+goog.exportProperty(box2d.b2ShapeType,"e_chainShape",box2d.b2ShapeType.e_chainShape);goog.exportProperty(box2d.b2ShapeType,"e_shapeTypeCount",box2d.b2ShapeType.e_shapeTypeCount);box2d.b2Shape=function(a,b){this.m_type=a;this.m_radius=b};goog.exportSymbol("box2d.b2Shape",box2d.b2Shape);box2d.b2Shape.prototype.m_type=box2d.b2ShapeType.e_unknown;goog.exportProperty(box2d.b2Shape.prototype,"m_type",box2d.b2Shape.prototype.m_type);box2d.b2Shape.prototype.m_radius=0;
+goog.exportProperty(box2d.b2Shape.prototype,"m_radius",box2d.b2Shape.prototype.m_radius);box2d.b2Shape.prototype.Clone=function(){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1);return null};goog.exportProperty(box2d.b2Shape.prototype,"Clone",box2d.b2Shape.prototype.Clone);box2d.b2Shape.prototype.Copy=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(this.m_type===a.m_type);this.m_radius=a.m_radius;return this};goog.exportProperty(box2d.b2Shape.prototype,"Copy",box2d.b2Shape.prototype.Copy);
+box2d.b2Shape.prototype.GetType=function(){return this.m_type};goog.exportProperty(box2d.b2Shape.prototype,"GetType",box2d.b2Shape.prototype.GetType);box2d.b2Shape.prototype.GetChildCount=function(){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1,"pure virtual");return 0};goog.exportProperty(box2d.b2Shape.prototype,"GetChildCount",box2d.b2Shape.prototype.GetChildCount);box2d.b2Shape.prototype.TestPoint=function(a,b){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1,"pure virtual");return!1};
+goog.exportProperty(box2d.b2Shape.prototype,"TestPoint",box2d.b2Shape.prototype.TestPoint);box2d.b2Shape.prototype.ComputeDistance=function(a,b,c,d){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1,"pure virtual");return 0};goog.exportProperty(box2d.b2Shape.prototype,"ComputeDistance",box2d.b2Shape.prototype.ComputeDistance);box2d.b2Shape.prototype.RayCast=function(a,b,c,d){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1,"pure virtual");return!1};goog.exportProperty(box2d.b2Shape.prototype,"RayCast",box2d.b2Shape.prototype.RayCast);
+box2d.b2Shape.prototype.ComputeAABB=function(a,b,c){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1,"pure virtual")};goog.exportProperty(box2d.b2Shape.prototype,"ComputeAABB",box2d.b2Shape.prototype.ComputeAABB);box2d.b2Shape.prototype.ComputeMass=function(a,b){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1,"pure virtual")};goog.exportProperty(box2d.b2Shape.prototype,"ComputeMass",box2d.b2Shape.prototype.ComputeMass);
+box2d.b2Shape.prototype.SetupDistanceProxy=function(a,b){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1,"pure virtual")};box2d.b2Shape.prototype.ComputeSubmergedArea=function(a,b,c,d){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1,"pure virtual");return 0};goog.exportProperty(box2d.b2Shape.prototype,"ComputeSubmergedArea",box2d.b2Shape.prototype.ComputeSubmergedArea);box2d.b2Shape.prototype.Dump=function(){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1,"pure virtual")};
+goog.exportProperty(box2d.b2Shape.prototype,"Dump",box2d.b2Shape.prototype.Dump);box2d.b2CircleShape=function(a){box2d.b2Shape.call(this,box2d.b2ShapeType.e_circleShape,a||0);this.m_p=new box2d.b2Vec2};goog.inherits(box2d.b2CircleShape,box2d.b2Shape);goog.exportSymbol("box2d.b2CircleShape",box2d.b2CircleShape);box2d.b2CircleShape.prototype.m_p=null;goog.exportProperty(box2d.b2CircleShape.prototype,"m_p",box2d.b2CircleShape.prototype.m_p);box2d.b2CircleShape.prototype.Clone=function(){return(new box2d.b2CircleShape).Copy(this)};
+goog.exportProperty(box2d.b2CircleShape.prototype,"Clone",box2d.b2CircleShape.prototype.Clone);box2d.b2CircleShape.prototype.Copy=function(a){box2d.b2Shape.prototype.Copy.call(this,a);box2d.ENABLE_ASSERTS&&box2d.b2Assert(a instanceof box2d.b2CircleShape);this.m_p.Copy(a.m_p);return this};goog.exportProperty(box2d.b2CircleShape.prototype,"Copy",box2d.b2CircleShape.prototype.Copy);box2d.b2CircleShape.prototype.GetChildCount=function(){return 1};
+goog.exportProperty(box2d.b2CircleShape.prototype,"GetChildCount",box2d.b2CircleShape.prototype.GetChildCount);box2d.b2CircleShape.prototype.TestPoint=function(a,b){var c=box2d.b2Mul_X_V2(a,this.m_p,box2d.b2CircleShape.prototype.TestPoint.s_center),c=box2d.b2Sub_V2_V2(b,c,box2d.b2CircleShape.prototype.TestPoint.s_d);return box2d.b2Dot_V2_V2(c,c)<=box2d.b2Sq(this.m_radius)};goog.exportProperty(box2d.b2CircleShape.prototype,"TestPoint",box2d.b2CircleShape.prototype.TestPoint);
+box2d.b2CircleShape.prototype.TestPoint.s_center=new box2d.b2Vec2;box2d.b2CircleShape.prototype.TestPoint.s_d=new box2d.b2Vec2;box2d.b2CircleShape.prototype.ComputeDistance=function(a,b,c,d){a=box2d.b2Mul_X_V2(a,this.m_p,box2d.b2CircleShape.prototype.ComputeDistance.s_center);box2d.b2Sub_V2_V2(b,a,c);return c.Normalize()-this.m_radius};goog.exportProperty(box2d.b2CircleShape.prototype,"ComputeDistance",box2d.b2CircleShape.prototype.ComputeDistance);
+box2d.b2CircleShape.prototype.ComputeDistance.s_center=new box2d.b2Vec2;
+box2d.b2CircleShape.prototype.RayCast=function(a,b,c,d){c=box2d.b2Mul_X_V2(c,this.m_p,box2d.b2CircleShape.prototype.RayCast.s_position);c=box2d.b2Sub_V2_V2(b.p1,c,box2d.b2CircleShape.prototype.RayCast.s_s);var e=box2d.b2Dot_V2_V2(c,c)-box2d.b2Sq(this.m_radius);d=box2d.b2Sub_V2_V2(b.p2,b.p1,box2d.b2CircleShape.prototype.RayCast.s_r);var f=box2d.b2Dot_V2_V2(c,d),g=box2d.b2Dot_V2_V2(d,d),e=f*f-g*e;if(0>e||g<box2d.b2_epsilon)return!1;f=-(f+box2d.b2Sqrt(e));return 0<=f&&f<=b.maxFraction*g?(f/=g,a.fraction=
+f,box2d.b2AddMul_V2_S_V2(c,f,d,a.normal).SelfNormalize(),!0):!1};goog.exportProperty(box2d.b2CircleShape.prototype,"RayCast",box2d.b2CircleShape.prototype.RayCast);box2d.b2CircleShape.prototype.RayCast.s_position=new box2d.b2Vec2;box2d.b2CircleShape.prototype.RayCast.s_s=new box2d.b2Vec2;box2d.b2CircleShape.prototype.RayCast.s_r=new box2d.b2Vec2;
+box2d.b2CircleShape.prototype.ComputeAABB=function(a,b,c){b=box2d.b2Mul_X_V2(b,this.m_p,box2d.b2CircleShape.prototype.ComputeAABB.s_p);a.lowerBound.Set(b.x-this.m_radius,b.y-this.m_radius);a.upperBound.Set(b.x+this.m_radius,b.y+this.m_radius)};goog.exportProperty(box2d.b2CircleShape.prototype,"ComputeAABB",box2d.b2CircleShape.prototype.ComputeAABB);box2d.b2CircleShape.prototype.ComputeAABB.s_p=new box2d.b2Vec2;
+box2d.b2CircleShape.prototype.ComputeMass=function(a,b){var c=box2d.b2Sq(this.m_radius);a.mass=b*box2d.b2_pi*c;a.center.Copy(this.m_p);a.I=a.mass*(.5*c+box2d.b2Dot_V2_V2(this.m_p,this.m_p))};goog.exportProperty(box2d.b2CircleShape.prototype,"ComputeMass",box2d.b2CircleShape.prototype.ComputeMass);box2d.b2CircleShape.prototype.SetupDistanceProxy=function(a,b){a.m_vertices=a.m_buffer;a.m_vertices[0].Copy(this.m_p);a.m_count=1;a.m_radius=this.m_radius};
+box2d.b2CircleShape.prototype.ComputeSubmergedArea=function(a,b,c,d){c=box2d.b2Mul_X_V2(c,this.m_p,new box2d.b2Vec2);var e=-(box2d.b2Dot_V2_V2(a,c)-b);if(e<-this.m_radius+box2d.b2_epsilon)return 0;if(e>this.m_radius)return d.Copy(c),box2d.b2_pi*this.m_radius*this.m_radius;b=this.m_radius*this.m_radius;var f=e*e,e=b*(box2d.b2Asin(e/this.m_radius)+box2d.b2_pi/2)+e*box2d.b2Sqrt(b-f);b=-2/3*box2d.b2Pow(b-f,1.5)/e;d.x=c.x+a.x*b;d.y=c.y+a.y*b;return e};
+goog.exportProperty(box2d.b2CircleShape.prototype,"ComputeSubmergedArea",box2d.b2CircleShape.prototype.ComputeSubmergedArea);box2d.b2CircleShape.prototype.Dump=function(){box2d.b2Log("    /*box2d.b2CircleShape*/ var shape = new box2d.b2CircleShape();\n");box2d.b2Log("    shape.m_radius = %.15f;\n",this.m_radius);box2d.b2Log("    shape.m_p.Set(%.15f, %.15f);\n",this.m_p.x,this.m_p.y)};goog.exportProperty(box2d.b2CircleShape.prototype,"Dump",box2d.b2CircleShape.prototype.Dump);box2d.b2EdgeShape=function(){box2d.b2Shape.call(this,box2d.b2ShapeType.e_edgeShape,box2d.b2_polygonRadius);this.m_vertex1=new box2d.b2Vec2;this.m_vertex2=new box2d.b2Vec2;this.m_vertex0=new box2d.b2Vec2;this.m_vertex3=new box2d.b2Vec2};goog.inherits(box2d.b2EdgeShape,box2d.b2Shape);goog.exportSymbol("box2d.b2EdgeShape",box2d.b2EdgeShape);box2d.b2EdgeShape.prototype.m_vertex1=null;goog.exportProperty(box2d.b2EdgeShape.prototype,"m_vertex1",box2d.b2EdgeShape.prototype.m_vertex1);
+box2d.b2EdgeShape.prototype.m_vertex2=null;goog.exportProperty(box2d.b2EdgeShape.prototype,"m_vertex2",box2d.b2EdgeShape.prototype.m_vertex2);box2d.b2EdgeShape.prototype.m_vertex0=null;goog.exportProperty(box2d.b2EdgeShape.prototype,"m_vertex0",box2d.b2EdgeShape.prototype.m_vertex0);box2d.b2EdgeShape.prototype.m_vertex3=null;goog.exportProperty(box2d.b2EdgeShape.prototype,"m_vertex3",box2d.b2EdgeShape.prototype.m_vertex3);box2d.b2EdgeShape.prototype.m_hasVertex0=!1;
+goog.exportProperty(box2d.b2EdgeShape.prototype,"m_hasVertex0",box2d.b2EdgeShape.prototype.m_hasVertex0);box2d.b2EdgeShape.prototype.m_hasVertex3=!1;goog.exportProperty(box2d.b2EdgeShape.prototype,"m_hasVertex3",box2d.b2EdgeShape.prototype.m_hasVertex3);box2d.b2EdgeShape.prototype.Set=function(a,b){this.m_vertex1.Copy(a);this.m_vertex2.Copy(b);this.m_hasVertex3=this.m_hasVertex0=!1;return this};goog.exportProperty(box2d.b2EdgeShape.prototype,"Set",box2d.b2EdgeShape.prototype.Set);
+box2d.b2EdgeShape.prototype.SetAsEdge=box2d.b2EdgeShape.prototype.Set;box2d.b2EdgeShape.prototype.Clone=function(){return(new box2d.b2EdgeShape).Copy(this)};goog.exportProperty(box2d.b2EdgeShape.prototype,"Clone",box2d.b2EdgeShape.prototype.Clone);
+box2d.b2EdgeShape.prototype.Copy=function(a){box2d.b2Shape.prototype.Copy.call(this,a);box2d.ENABLE_ASSERTS&&box2d.b2Assert(a instanceof box2d.b2EdgeShape);this.m_vertex1.Copy(a.m_vertex1);this.m_vertex2.Copy(a.m_vertex2);this.m_vertex0.Copy(a.m_vertex0);this.m_vertex3.Copy(a.m_vertex3);this.m_hasVertex0=a.m_hasVertex0;this.m_hasVertex3=a.m_hasVertex3;return this};goog.exportProperty(box2d.b2EdgeShape.prototype,"Copy",box2d.b2EdgeShape.prototype.Copy);box2d.b2EdgeShape.prototype.GetChildCount=function(){return 1};
+goog.exportProperty(box2d.b2EdgeShape.prototype,"GetChildCount",box2d.b2EdgeShape.prototype.GetChildCount);box2d.b2EdgeShape.prototype.TestPoint=function(a,b){return!1};goog.exportProperty(box2d.b2EdgeShape.prototype,"TestPoint",box2d.b2EdgeShape.prototype.TestPoint);
+box2d.b2EdgeShape.prototype.ComputeDistance=function(a,b,c,d){var e=box2d.b2Mul_X_V2(a,this.m_vertex1,box2d.b2EdgeShape.prototype.ComputeDistance.s_v1);a=box2d.b2Mul_X_V2(a,this.m_vertex2,box2d.b2EdgeShape.prototype.ComputeDistance.s_v2);d=box2d.b2Sub_V2_V2(b,e,box2d.b2EdgeShape.prototype.ComputeDistance.s_d);var e=box2d.b2Sub_V2_V2(a,e,box2d.b2EdgeShape.prototype.ComputeDistance.s_s),f=box2d.b2Dot_V2_V2(d,e);if(0<f){var g=box2d.b2Dot_V2_V2(e,e);f>g?box2d.b2Sub_V2_V2(b,a,d):d.SelfMulSub(f/g,e)}c.Copy(d);
+return c.Normalize()};goog.exportProperty(box2d.b2EdgeShape.prototype,"ComputeDistance",box2d.b2EdgeShape.prototype.ComputeDistance);box2d.b2EdgeShape.prototype.ComputeDistance.s_v1=new box2d.b2Vec2;box2d.b2EdgeShape.prototype.ComputeDistance.s_v2=new box2d.b2Vec2;box2d.b2EdgeShape.prototype.ComputeDistance.s_d=new box2d.b2Vec2;box2d.b2EdgeShape.prototype.ComputeDistance.s_s=new box2d.b2Vec2;
+box2d.b2EdgeShape.prototype.RayCast=function(a,b,c,d){var e=box2d.b2MulT_X_V2(c,b.p1,box2d.b2EdgeShape.prototype.RayCast.s_p1);d=box2d.b2MulT_X_V2(c,b.p2,box2d.b2EdgeShape.prototype.RayCast.s_p2);var f=box2d.b2Sub_V2_V2(d,e,box2d.b2EdgeShape.prototype.RayCast.s_d);d=this.m_vertex1;var g=this.m_vertex2,h=box2d.b2Sub_V2_V2(g,d,box2d.b2EdgeShape.prototype.RayCast.s_e),k=a.normal.Set(h.y,-h.x).SelfNormalize(),h=box2d.b2Dot_V2_V2(k,box2d.b2Sub_V2_V2(d,e,box2d.b2Vec2.s_t0)),k=box2d.b2Dot_V2_V2(k,f);if(0===
+k)return!1;k=h/k;if(0>k||b.maxFraction<k)return!1;b=box2d.b2AddMul_V2_S_V2(e,k,f,box2d.b2EdgeShape.prototype.RayCast.s_q);e=box2d.b2Sub_V2_V2(g,d,box2d.b2EdgeShape.prototype.RayCast.s_r);g=box2d.b2Dot_V2_V2(e,e);if(0===g)return!1;d=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(b,d,box2d.b2Vec2.s_t0),e)/g;if(0>d||1<d)return!1;a.fraction=k;box2d.b2Mul_R_V2(c.q,a.normal,a.normal);0<h&&a.normal.SelfNeg();return!0};goog.exportProperty(box2d.b2EdgeShape.prototype,"RayCast",box2d.b2EdgeShape.prototype.RayCast);
+box2d.b2EdgeShape.prototype.RayCast.s_p1=new box2d.b2Vec2;box2d.b2EdgeShape.prototype.RayCast.s_p2=new box2d.b2Vec2;box2d.b2EdgeShape.prototype.RayCast.s_d=new box2d.b2Vec2;box2d.b2EdgeShape.prototype.RayCast.s_e=new box2d.b2Vec2;box2d.b2EdgeShape.prototype.RayCast.s_q=new box2d.b2Vec2;box2d.b2EdgeShape.prototype.RayCast.s_r=new box2d.b2Vec2;
+box2d.b2EdgeShape.prototype.ComputeAABB=function(a,b,c){c=box2d.b2Mul_X_V2(b,this.m_vertex1,box2d.b2EdgeShape.prototype.ComputeAABB.s_v1);b=box2d.b2Mul_X_V2(b,this.m_vertex2,box2d.b2EdgeShape.prototype.ComputeAABB.s_v2);box2d.b2Min_V2_V2(c,b,a.lowerBound);box2d.b2Max_V2_V2(c,b,a.upperBound);b=this.m_radius;a.lowerBound.SelfSubXY(b,b);a.upperBound.SelfAddXY(b,b)};goog.exportProperty(box2d.b2EdgeShape.prototype,"ComputeAABB",box2d.b2EdgeShape.prototype.ComputeAABB);
+box2d.b2EdgeShape.prototype.ComputeAABB.s_v1=new box2d.b2Vec2;box2d.b2EdgeShape.prototype.ComputeAABB.s_v2=new box2d.b2Vec2;box2d.b2EdgeShape.prototype.ComputeMass=function(a,b){a.mass=0;box2d.b2Mid_V2_V2(this.m_vertex1,this.m_vertex2,a.center);a.I=0};goog.exportProperty(box2d.b2EdgeShape.prototype,"ComputeMass",box2d.b2EdgeShape.prototype.ComputeMass);
+box2d.b2EdgeShape.prototype.SetupDistanceProxy=function(a,b){a.m_vertices=a.m_buffer;a.m_vertices[0].Copy(this.m_vertex1);a.m_vertices[1].Copy(this.m_vertex2);a.m_count=2;a.m_radius=this.m_radius};box2d.b2EdgeShape.prototype.ComputeSubmergedArea=function(a,b,c,d){d.SetZero();return 0};goog.exportProperty(box2d.b2EdgeShape.prototype,"ComputeSubmergedArea",box2d.b2EdgeShape.prototype.ComputeSubmergedArea);
+box2d.b2EdgeShape.prototype.Dump=function(){box2d.b2Log("    /*box2d.b2EdgeShape*/ var shape = new box2d.b2EdgeShape();\n");box2d.b2Log("    shape.m_radius = %.15f;\n",this.m_radius);box2d.b2Log("    shape.m_vertex0.Set(%.15f, %.15f);\n",this.m_vertex0.x,this.m_vertex0.y);box2d.b2Log("    shape.m_vertex1.Set(%.15f, %.15f);\n",this.m_vertex1.x,this.m_vertex1.y);box2d.b2Log("    shape.m_vertex2.Set(%.15f, %.15f);\n",this.m_vertex2.x,this.m_vertex2.y);box2d.b2Log("    shape.m_vertex3.Set(%.15f, %.15f);\n",
+this.m_vertex3.x,this.m_vertex3.y);box2d.b2Log("    shape.m_hasVertex0 = %s;\n",this.m_hasVertex0);box2d.b2Log("    shape.m_hasVertex3 = %s;\n",this.m_hasVertex3)};goog.exportProperty(box2d.b2EdgeShape.prototype,"Dump",box2d.b2EdgeShape.prototype.Dump);box2d.b2ChainShape=function(){box2d.b2Shape.call(this,box2d.b2ShapeType.e_chainShape,box2d.b2_polygonRadius);this.m_prevVertex=new box2d.b2Vec2;this.m_nextVertex=new box2d.b2Vec2};goog.inherits(box2d.b2ChainShape,box2d.b2Shape);goog.exportSymbol("box2d.b2ChainShape",box2d.b2ChainShape);box2d.b2ChainShape.prototype.m_vertices=null;goog.exportProperty(box2d.b2ChainShape.prototype,"m_vertices",box2d.b2ChainShape.prototype.m_vertices);box2d.b2ChainShape.prototype.m_count=0;
+goog.exportProperty(box2d.b2ChainShape.prototype,"m_count",box2d.b2ChainShape.prototype.m_count);box2d.b2ChainShape.prototype.m_prevVertex=null;goog.exportProperty(box2d.b2ChainShape.prototype,"m_prevVertex",box2d.b2ChainShape.prototype.m_prevVertex);box2d.b2ChainShape.prototype.m_nextVertex=null;goog.exportProperty(box2d.b2ChainShape.prototype,"m_nextVertex",box2d.b2ChainShape.prototype.m_nextVertex);box2d.b2ChainShape.prototype.m_hasPrevVertex=!1;
+goog.exportProperty(box2d.b2ChainShape.prototype,"m_hasPrevVertex",box2d.b2ChainShape.prototype.m_hasPrevVertex);box2d.b2ChainShape.prototype.m_hasNextVertex=!1;goog.exportProperty(box2d.b2ChainShape.prototype,"m_hasNextVertex",box2d.b2ChainShape.prototype.m_hasNextVertex);box2d.b2ChainShape.prototype.Clear=function(){this.m_vertices=null;this.m_count=0};goog.exportProperty(box2d.b2ChainShape.prototype,"Clear",box2d.b2ChainShape.prototype.Clear);
+box2d.b2ChainShape.prototype.CreateLoop=function(a,b){b=b||a.length;box2d.ENABLE_ASSERTS&&box2d.b2Assert(null===this.m_vertices&&0===this.m_count);box2d.ENABLE_ASSERTS&&box2d.b2Assert(3<=b);if(box2d.ENABLE_ASSERTS)for(var c=1;c<b;++c)box2d.b2Assert(box2d.b2DistanceSquared(a[c-1],a[c])>box2d.b2_linearSlop*box2d.b2_linearSlop);this.m_count=b+1;this.m_vertices=box2d.b2Vec2.MakeArray(this.m_count);for(c=0;c<b;++c)this.m_vertices[c].Copy(a[c]);this.m_vertices[b].Copy(this.m_vertices[0]);this.m_prevVertex.Copy(this.m_vertices[this.m_count-
+2]);this.m_nextVertex.Copy(this.m_vertices[1]);this.m_hasNextVertex=this.m_hasPrevVertex=!0;return this};goog.exportProperty(box2d.b2ChainShape.prototype,"CreateLoop",box2d.b2ChainShape.prototype.CreateLoop);
+box2d.b2ChainShape.prototype.CreateChain=function(a,b){b=b||a.length;box2d.ENABLE_ASSERTS&&box2d.b2Assert(null===this.m_vertices&&0===this.m_count);box2d.ENABLE_ASSERTS&&box2d.b2Assert(2<=b);if(box2d.ENABLE_ASSERTS)for(var c=1;c<b;++c)box2d.b2Assert(box2d.b2DistanceSquared(a[c-1],a[c])>box2d.b2_linearSlop*box2d.b2_linearSlop);this.m_count=b;this.m_vertices=box2d.b2Vec2.MakeArray(b);for(c=0;c<b;++c)this.m_vertices[c].Copy(a[c]);this.m_hasNextVertex=this.m_hasPrevVertex=!1;this.m_prevVertex.SetZero();
+this.m_nextVertex.SetZero();return this};goog.exportProperty(box2d.b2ChainShape.prototype,"CreateChain",box2d.b2ChainShape.prototype.CreateChain);box2d.b2ChainShape.prototype.SetPrevVertex=function(a){this.m_prevVertex.Copy(a);this.m_hasPrevVertex=!0;return this};goog.exportProperty(box2d.b2ChainShape.prototype,"SetPrevVertex",box2d.b2ChainShape.prototype.SetPrevVertex);box2d.b2ChainShape.prototype.SetNextVertex=function(a){this.m_nextVertex.Copy(a);this.m_hasNextVertex=!0;return this};
+goog.exportProperty(box2d.b2ChainShape.prototype,"SetNextVertex",box2d.b2ChainShape.prototype.SetNextVertex);box2d.b2ChainShape.prototype.Clone=function(){return(new box2d.b2ChainShape).Copy(this)};goog.exportProperty(box2d.b2ChainShape.prototype,"Clone",box2d.b2ChainShape.prototype.Clone);
+box2d.b2ChainShape.prototype.Copy=function(a){box2d.b2Shape.prototype.Copy.call(this,a);box2d.ENABLE_ASSERTS&&box2d.b2Assert(a instanceof box2d.b2ChainShape);this.CreateChain(a.m_vertices,a.m_count);this.m_prevVertex.Copy(a.m_prevVertex);this.m_nextVertex.Copy(a.m_nextVertex);this.m_hasPrevVertex=a.m_hasPrevVertex;this.m_hasNextVertex=a.m_hasNextVertex;return this};goog.exportProperty(box2d.b2ChainShape.prototype,"Copy",box2d.b2ChainShape.prototype.Copy);
+box2d.b2ChainShape.prototype.GetChildCount=function(){return this.m_count-1};goog.exportProperty(box2d.b2ChainShape.prototype,"GetChildCount",box2d.b2ChainShape.prototype.GetChildCount);
+box2d.b2ChainShape.prototype.GetChildEdge=function(a,b){box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<=b&&b<this.m_count-1);a.m_type=box2d.b2ShapeType.e_edgeShape;a.m_radius=this.m_radius;a.m_vertex1.Copy(this.m_vertices[b]);a.m_vertex2.Copy(this.m_vertices[b+1]);0<b?(a.m_vertex0.Copy(this.m_vertices[b-1]),a.m_hasVertex0=!0):(a.m_vertex0.Copy(this.m_prevVertex),a.m_hasVertex0=this.m_hasPrevVertex);b<this.m_count-2?(a.m_vertex3.Copy(this.m_vertices[b+2]),a.m_hasVertex3=!0):(a.m_vertex3.Copy(this.m_nextVertex),
+a.m_hasVertex3=this.m_hasNextVertex)};goog.exportProperty(box2d.b2ChainShape.prototype,"GetChildEdge",box2d.b2ChainShape.prototype.GetChildEdge);box2d.b2ChainShape.prototype.TestPoint=function(a,b){return!1};goog.exportProperty(box2d.b2ChainShape.prototype,"TestPoint",box2d.b2ChainShape.prototype.TestPoint);box2d.b2ChainShape.prototype.ComputeDistance=function(a,b,c,d){var e=box2d.b2ChainShape.prototype.ComputeDistance.s_edgeShape;this.GetChildEdge(e,d);return e.ComputeDistance(a,b,c,0)};
+goog.exportProperty(box2d.b2ChainShape.prototype,"ComputeDistance",box2d.b2ChainShape.prototype.ComputeDistance);box2d.b2ChainShape.prototype.ComputeDistance.s_edgeShape=new box2d.b2EdgeShape;box2d.b2ChainShape.prototype.RayCast=function(a,b,c,d){box2d.ENABLE_ASSERTS&&box2d.b2Assert(d<this.m_count);var e=box2d.b2ChainShape.prototype.RayCast.s_edgeShape;e.m_vertex1.Copy(this.m_vertices[d]);e.m_vertex2.Copy(this.m_vertices[(d+1)%this.m_count]);return e.RayCast(a,b,c,0)};
+goog.exportProperty(box2d.b2ChainShape.prototype,"RayCast",box2d.b2ChainShape.prototype.RayCast);box2d.b2ChainShape.prototype.RayCast.s_edgeShape=new box2d.b2EdgeShape;
+box2d.b2ChainShape.prototype.ComputeAABB=function(a,b,c){box2d.ENABLE_ASSERTS&&box2d.b2Assert(c<this.m_count);var d=this.m_vertices[(c+1)%this.m_count];c=box2d.b2Mul_X_V2(b,this.m_vertices[c],box2d.b2ChainShape.prototype.ComputeAABB.s_v1);b=box2d.b2Mul_X_V2(b,d,box2d.b2ChainShape.prototype.ComputeAABB.s_v2);box2d.b2Min_V2_V2(c,b,a.lowerBound);box2d.b2Max_V2_V2(c,b,a.upperBound)};goog.exportProperty(box2d.b2ChainShape.prototype,"ComputeAABB",box2d.b2ChainShape.prototype.ComputeAABB);
+box2d.b2ChainShape.prototype.ComputeAABB.s_v1=new box2d.b2Vec2;goog.exportProperty(box2d.b2ChainShape.prototype.ComputeAABB,"s_v1",box2d.b2ChainShape.prototype.ComputeAABB.s_v1);box2d.b2ChainShape.prototype.ComputeAABB.s_v2=new box2d.b2Vec2;goog.exportProperty(box2d.b2ChainShape.prototype.ComputeAABB,"s_v2",box2d.b2ChainShape.prototype.ComputeAABB.s_v2);box2d.b2ChainShape.prototype.ComputeMass=function(a,b){a.mass=0;a.center.SetZero();a.I=0};
+goog.exportProperty(box2d.b2ChainShape.prototype,"ComputeMass",box2d.b2ChainShape.prototype.ComputeMass);box2d.b2ChainShape.prototype.SetupDistanceProxy=function(a,b){box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<=b&&b<this.m_count);a.m_buffer[0].Copy(this.m_vertices[b]);b+1<this.m_count?a.m_buffer[1].Copy(this.m_vertices[b+1]):a.m_buffer[1].Copy(this.m_vertices[0]);a.m_vertices=a.m_buffer;a.m_count=2;a.m_radius=this.m_radius};
+box2d.b2ChainShape.prototype.ComputeSubmergedArea=function(a,b,c,d){d.SetZero();return 0};goog.exportProperty(box2d.b2ChainShape.prototype,"ComputeSubmergedArea",box2d.b2ChainShape.prototype.ComputeSubmergedArea);
+box2d.b2ChainShape.prototype.Dump=function(){box2d.b2Log("    /*box2d.b2ChainShape*/ var shape = new box2d.b2ChainShape();\n");box2d.b2Log("    /*box2d.b2Vec2[]*/ var vs = box2d.b2Vec2.MakeArray(%d);\n",box2d.b2_maxPolygonVertices);for(var a=0;a<this.m_count;++a)box2d.b2Log("    vs[%d].Set(%.15f, %.15f);\n",a,this.m_vertices[a].x,this.m_vertices[a].y);box2d.b2Log("    shape.CreateChain(vs, %d);\n",this.m_count);box2d.b2Log("    shape.m_prevVertex.Set(%.15f, %.15f);\n",this.m_prevVertex.x,this.m_prevVertex.y);
+box2d.b2Log("    shape.m_nextVertex.Set(%.15f, %.15f);\n",this.m_nextVertex.x,this.m_nextVertex.y);box2d.b2Log("    shape.m_hasPrevVertex = %s;\n",this.m_hasPrevVertex?"true":"false");box2d.b2Log("    shape.m_hasNextVertex = %s;\n",this.m_hasNextVertex?"true":"false")};goog.exportProperty(box2d.b2ChainShape.prototype,"Dump",box2d.b2ChainShape.prototype.Dump);box2d.b2PolygonShape=function(){box2d.b2Shape.call(this,box2d.b2ShapeType.e_polygonShape,box2d.b2_polygonRadius);this.m_centroid=new box2d.b2Vec2(0,0);this.m_vertices=box2d.b2Vec2.MakeArray(box2d.b2_maxPolygonVertices);this.m_normals=box2d.b2Vec2.MakeArray(box2d.b2_maxPolygonVertices)};goog.inherits(box2d.b2PolygonShape,box2d.b2Shape);goog.exportSymbol("box2d.b2PolygonShape",box2d.b2PolygonShape);box2d.b2PolygonShape.prototype.m_centroid=null;
+goog.exportProperty(box2d.b2PolygonShape.prototype,"m_centroid",box2d.b2PolygonShape.prototype.m_centroid);box2d.b2PolygonShape.prototype.m_vertices=null;goog.exportProperty(box2d.b2PolygonShape.prototype,"m_vertices",box2d.b2PolygonShape.prototype.m_vertices);box2d.b2PolygonShape.prototype.m_normals=null;goog.exportProperty(box2d.b2PolygonShape.prototype,"m_normals",box2d.b2PolygonShape.prototype.m_normals);box2d.b2PolygonShape.prototype.m_count=0;
+goog.exportProperty(box2d.b2PolygonShape.prototype,"m_count",box2d.b2PolygonShape.prototype.m_count);box2d.b2PolygonShape.prototype.Clone=function(){return(new box2d.b2PolygonShape).Copy(this)};goog.exportProperty(box2d.b2PolygonShape.prototype,"Clone",box2d.b2PolygonShape.prototype.Clone);
+box2d.b2PolygonShape.prototype.Copy=function(a){box2d.b2Shape.prototype.Copy.call(this,a);box2d.ENABLE_ASSERTS&&box2d.b2Assert(a instanceof box2d.b2PolygonShape);this.m_centroid.Copy(a.m_centroid);this.m_count=a.m_count;for(var b=0,c=this.m_count;b<c;++b)this.m_vertices[b].Copy(a.m_vertices[b]),this.m_normals[b].Copy(a.m_normals[b]);return this};goog.exportProperty(box2d.b2PolygonShape.prototype,"Copy",box2d.b2PolygonShape.prototype.Copy);
+box2d.b2PolygonShape.prototype.SetAsBox=function(a,b,c,d){this.m_count=4;this.m_vertices[0].Set(-a,-b);this.m_vertices[1].Set(a,-b);this.m_vertices[2].Set(a,b);this.m_vertices[3].Set(-a,b);this.m_normals[0].Set(0,-1);this.m_normals[1].Set(1,0);this.m_normals[2].Set(0,1);this.m_normals[3].Set(-1,0);this.m_centroid.SetZero();if(c instanceof box2d.b2Vec2)for(d="number"===typeof d?d:0,this.m_centroid.Copy(c),a=new box2d.b2Transform,a.SetPosition(c),a.SetRotationAngle(d),c=0,d=this.m_count;c<d;++c)box2d.b2Mul_X_V2(a,
+this.m_vertices[c],this.m_vertices[c]),box2d.b2Mul_R_V2(a.q,this.m_normals[c],this.m_normals[c]);return this};goog.exportProperty(box2d.b2PolygonShape.prototype,"SetAsBox",box2d.b2PolygonShape.prototype.SetAsBox);
+box2d.b2PolygonShape.prototype.Set=function(a,b,c){b="number"===typeof b?b:a.length;c="number"===typeof c?c:0;box2d.ENABLE_ASSERTS&&box2d.b2Assert(3<=b&&b<=box2d.b2_maxPolygonVertices);if(3>b)return this.SetAsBox(1,1);b=box2d.b2Min(b,box2d.b2_maxPolygonVertices);for(var d=box2d.b2PolygonShape.prototype.Set.s_ps,e=0,f=0;f<b;++f){for(var g=a[c+f],h=!0,k=0;k<e;++k)if(box2d.b2DistanceSquared(g,d[k])<.25*box2d.b2_linearSlop*box2d.b2_linearSlop){h=!1;break}h&&d[e++].Copy(g)}b=e;if(3>b)return box2d.ENABLE_ASSERTS&&
+box2d.b2Assert(!1),this.SetAsBox(1,1);a=0;g=d[0].x;for(f=1;f<b;++f)if(k=d[f].x,k>g||k===g&&d[f].y<d[a].y)a=f,g=k;e=box2d.b2PolygonShape.prototype.Set.s_hull;c=0;for(f=a;;){e[c]=f;h=0;for(k=1;k<b;++k)if(h===f)h=k;else{var l=box2d.b2Sub_V2_V2(d[h],d[e[c]],box2d.b2PolygonShape.prototype.Set.s_r),g=box2d.b2Sub_V2_V2(d[k],d[e[c]],box2d.b2PolygonShape.prototype.Set.s_v),m=box2d.b2Cross_V2_V2(l,g);0>m&&(h=k);0===m&&g.LengthSquared()>l.LengthSquared()&&(h=k)}++c;f=h;if(h===a)break}if(3>c)return box2d.ENABLE_ASSERTS&&
+box2d.b2Assert(!1),this.SetAsBox(1,1);this.m_count=c;for(f=0;f<c;++f)this.m_vertices[f].Copy(d[e[f]]);f=0;for(b=c;f<b;++f)d=box2d.b2Sub_V2_V2(this.m_vertices[(f+1)%b],this.m_vertices[f],box2d.b2Vec2.s_t0),box2d.ENABLE_ASSERTS&&box2d.b2Assert(d.LengthSquared()>box2d.b2_epsilon_sq),box2d.b2Cross_V2_S(d,1,this.m_normals[f]).SelfNormalize();box2d.b2PolygonShape.ComputeCentroid(this.m_vertices,c,this.m_centroid);return this};goog.exportProperty(box2d.b2PolygonShape.prototype,"Set",box2d.b2PolygonShape.prototype.Set);
+box2d.b2PolygonShape.prototype.Set.s_ps=box2d.b2Vec2.MakeArray(box2d.b2_maxPolygonVertices);box2d.b2PolygonShape.prototype.Set.s_hull=box2d.b2MakeNumberArray(box2d.b2_maxPolygonVertices);box2d.b2PolygonShape.prototype.Set.s_r=new box2d.b2Vec2;box2d.b2PolygonShape.prototype.Set.s_v=new box2d.b2Vec2;box2d.b2PolygonShape.prototype.GetChildCount=function(){return 1};goog.exportProperty(box2d.b2PolygonShape.prototype,"GetChildCount",box2d.b2PolygonShape.prototype.GetChildCount);
+box2d.b2PolygonShape.prototype.TestPoint=function(a,b){for(var c=box2d.b2MulT_X_V2(a,b,box2d.b2PolygonShape.prototype.TestPoint.s_pLocal),d=0,e=this.m_count;d<e;++d)if(0<box2d.b2Dot_V2_V2(this.m_normals[d],box2d.b2Sub_V2_V2(c,this.m_vertices[d],box2d.b2Vec2.s_t0)))return!1;return!0};goog.exportProperty(box2d.b2PolygonShape.prototype,"TestPoint",box2d.b2PolygonShape.prototype.TestPoint);box2d.b2PolygonShape.prototype.TestPoint.s_pLocal=new box2d.b2Vec2;
+box2d.b2PolygonShape.prototype.ComputeDistance=function(a,b,c,d){b=box2d.b2MulT_X_V2(a,b,box2d.b2PolygonShape.prototype.ComputeDistance.s_pLocal);var e=-box2d.b2_maxFloat,f=box2d.b2PolygonShape.prototype.ComputeDistance.s_normalForMaxDistance.Copy(b);for(d=0;d<this.m_count;++d){var g=box2d.b2Dot_V2_V2(this.m_normals[d],box2d.b2Sub_V2_V2(b,this.m_vertices[d],box2d.b2Vec2.s_t0));g>e&&(e=g,f.Copy(this.m_normals[d]))}if(0<e){f=box2d.b2PolygonShape.prototype.ComputeDistance.s_minDistance.Copy(f);e*=e;
+for(d=0;d<this.m_count;++d){var g=box2d.b2Sub_V2_V2(b,this.m_vertices[d],box2d.b2PolygonShape.prototype.ComputeDistance.s_distance),h=g.LengthSquared();e>h&&(f.Copy(g),e=h)}box2d.b2Mul_R_V2(a.q,f,c);c.Normalize();return Math.sqrt(e)}box2d.b2Mul_R_V2(a.q,f,c);return e};goog.exportProperty(box2d.b2PolygonShape.prototype,"ComputeDistance",box2d.b2PolygonShape.prototype.ComputeDistance);box2d.b2PolygonShape.prototype.ComputeDistance.s_pLocal=new box2d.b2Vec2;
+box2d.b2PolygonShape.prototype.ComputeDistance.s_normalForMaxDistance=new box2d.b2Vec2;box2d.b2PolygonShape.prototype.ComputeDistance.s_minDistance=new box2d.b2Vec2;box2d.b2PolygonShape.prototype.ComputeDistance.s_distance=new box2d.b2Vec2;
+box2d.b2PolygonShape.prototype.RayCast=function(a,b,c,d){d=box2d.b2MulT_X_V2(c,b.p1,box2d.b2PolygonShape.prototype.RayCast.s_p1);for(var e=box2d.b2MulT_X_V2(c,b.p2,box2d.b2PolygonShape.prototype.RayCast.s_p2),e=box2d.b2Sub_V2_V2(e,d,box2d.b2PolygonShape.prototype.RayCast.s_d),f=0,g=b.maxFraction,h=-1,k=0,l=this.m_count;k<l;++k){var m=box2d.b2Dot_V2_V2(this.m_normals[k],box2d.b2Sub_V2_V2(this.m_vertices[k],d,box2d.b2Vec2.s_t0)),n=box2d.b2Dot_V2_V2(this.m_normals[k],e);if(0===n){if(0>m)return!1}else 0>
+n&&m<f*n?(f=m/n,h=k):0<n&&m<g*n&&(g=m/n);if(g<f)return!1}box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<=f&&f<=b.maxFraction);return 0<=h?(a.fraction=f,box2d.b2Mul_R_V2(c.q,this.m_normals[h],a.normal),!0):!1};goog.exportProperty(box2d.b2PolygonShape.prototype,"RayCast",box2d.b2PolygonShape.prototype.RayCast);box2d.b2PolygonShape.prototype.RayCast.s_p1=new box2d.b2Vec2;box2d.b2PolygonShape.prototype.RayCast.s_p2=new box2d.b2Vec2;box2d.b2PolygonShape.prototype.RayCast.s_d=new box2d.b2Vec2;
+box2d.b2PolygonShape.prototype.ComputeAABB=function(a,b,c){c=box2d.b2Mul_X_V2(b,this.m_vertices[0],a.lowerBound);a=a.upperBound.Copy(c);for(var d=0,e=this.m_count;d<e;++d){var f=box2d.b2Mul_X_V2(b,this.m_vertices[d],box2d.b2PolygonShape.prototype.ComputeAABB.s_v);box2d.b2Min_V2_V2(f,c,c);box2d.b2Max_V2_V2(f,a,a)}b=this.m_radius;c.SelfSubXY(b,b);a.SelfAddXY(b,b)};goog.exportProperty(box2d.b2PolygonShape.prototype,"ComputeAABB",box2d.b2PolygonShape.prototype.ComputeAABB);
+box2d.b2PolygonShape.prototype.ComputeAABB.s_v=new box2d.b2Vec2;
+box2d.b2PolygonShape.prototype.ComputeMass=function(a,b){box2d.ENABLE_ASSERTS&&box2d.b2Assert(3<=this.m_count);for(var c=box2d.b2PolygonShape.prototype.ComputeMass.s_center.SetZero(),d=0,e=0,f=box2d.b2PolygonShape.prototype.ComputeMass.s_s.SetZero(),g=0,h=this.m_count;g<h;++g)f.SelfAdd(this.m_vertices[g]);f.SelfMul(1/this.m_count);for(var k=1/3,g=0,h=this.m_count;g<h;++g){var l=box2d.b2Sub_V2_V2(this.m_vertices[g],f,box2d.b2PolygonShape.prototype.ComputeMass.s_e1),m=box2d.b2Sub_V2_V2(this.m_vertices[(g+
+1)%h],f,box2d.b2PolygonShape.prototype.ComputeMass.s_e2),n=box2d.b2Cross_V2_V2(l,m),p=.5*n,d=d+p;c.SelfAdd(box2d.b2Mul_S_V2(p*k,box2d.b2Add_V2_V2(l,m,box2d.b2Vec2.s_t0),box2d.b2Vec2.s_t1));var p=l.x,l=l.y,q=m.x,m=m.y,e=e+.25*k*n*(p*p+q*p+q*q+(l*l+m*l+m*m))}a.mass=b*d;box2d.ENABLE_ASSERTS&&box2d.b2Assert(d>box2d.b2_epsilon);c.SelfMul(1/d);box2d.b2Add_V2_V2(c,f,a.center);a.I=b*e;a.I+=a.mass*(box2d.b2Dot_V2_V2(a.center,a.center)-box2d.b2Dot_V2_V2(c,c))};
+goog.exportProperty(box2d.b2PolygonShape.prototype,"ComputeMass",box2d.b2PolygonShape.prototype.ComputeMass);box2d.b2PolygonShape.prototype.ComputeMass.s_center=new box2d.b2Vec2;box2d.b2PolygonShape.prototype.ComputeMass.s_s=new box2d.b2Vec2;box2d.b2PolygonShape.prototype.ComputeMass.s_e1=new box2d.b2Vec2;box2d.b2PolygonShape.prototype.ComputeMass.s_e2=new box2d.b2Vec2;
+box2d.b2PolygonShape.prototype.Validate=function(){for(var a=0;a<this.m_count;++a)for(var b=a,c=(a+1)%this.m_count,d=this.m_vertices[b],e=box2d.b2Sub_V2_V2(this.m_vertices[c],d,box2d.b2PolygonShape.prototype.Validate.s_e),f=0;f<this.m_count;++f)if(f!==b&&f!==c){var g=box2d.b2Sub_V2_V2(this.m_vertices[f],d,box2d.b2PolygonShape.prototype.Validate.s_v);if(0>box2d.b2Cross_V2_V2(e,g))return!1}return!0};goog.exportProperty(box2d.b2PolygonShape.prototype,"Validate",box2d.b2PolygonShape.prototype.Validate);
+box2d.b2PolygonShape.prototype.Validate.s_e=new box2d.b2Vec2;box2d.b2PolygonShape.prototype.Validate.s_v=new box2d.b2Vec2;box2d.b2PolygonShape.prototype.SetupDistanceProxy=function(a,b){a.m_vertices=this.m_vertices;a.m_count=this.m_count;a.m_radius=this.m_radius};
+box2d.b2PolygonShape.prototype.ComputeSubmergedArea=function(a,b,c,d){var e=box2d.b2MulT_R_V2(c.q,a,box2d.b2PolygonShape.prototype.ComputeSubmergedArea.s_normalL),f=b-box2d.b2Dot_V2_V2(a,c.p),g=box2d.b2PolygonShape.prototype.ComputeSubmergedArea.s_depths,h=0,k=-1;b=-1;var l=!1;a=0;for(var m=this.m_count;a<m;++a){g[a]=box2d.b2Dot_V2_V2(e,this.m_vertices[a])-f;var n=g[a]<-box2d.b2_epsilon;0<a&&(n?l||(k=a-1,h++):l&&(b=a-1,h++));l=n}switch(h){case 0:return l?(a=box2d.b2PolygonShape.prototype.ComputeSubmergedArea.s_md,
+this.ComputeMass(a,1),box2d.b2Mul_X_V2(c,a.center,d),a.mass):0;case 1:-1===k?k=this.m_count-1:b=this.m_count-1}a=(k+1)%this.m_count;e=(b+1)%this.m_count;f=(0-g[k])/(g[a]-g[k]);g=(0-g[b])/(g[e]-g[b]);k=box2d.b2PolygonShape.prototype.ComputeSubmergedArea.s_intoVec.Set(this.m_vertices[k].x*(1-f)+this.m_vertices[a].x*f,this.m_vertices[k].y*(1-f)+this.m_vertices[a].y*f);b=box2d.b2PolygonShape.prototype.ComputeSubmergedArea.s_outoVec.Set(this.m_vertices[b].x*(1-g)+this.m_vertices[e].x*g,this.m_vertices[b].y*
+(1-g)+this.m_vertices[e].y*g);g=0;f=box2d.b2PolygonShape.prototype.ComputeSubmergedArea.s_center.SetZero();h=this.m_vertices[a];for(l=null;a!==e;)a=(a+1)%this.m_count,l=a===e?b:this.m_vertices[a],m=.5*((h.x-k.x)*(l.y-k.y)-(h.y-k.y)*(l.x-k.x)),g+=m,f.x+=m*(k.x+h.x+l.x)/3,f.y+=m*(k.y+h.y+l.y)/3,h=l;f.SelfMul(1/g);box2d.b2Mul_X_V2(c,f,d);return g};goog.exportProperty(box2d.b2PolygonShape.prototype,"ComputeSubmergedArea",box2d.b2PolygonShape.prototype.ComputeSubmergedArea);
+box2d.b2PolygonShape.prototype.ComputeSubmergedArea.s_normalL=new box2d.b2Vec2;box2d.b2PolygonShape.prototype.ComputeSubmergedArea.s_depths=box2d.b2MakeNumberArray(box2d.b2_maxPolygonVertices);box2d.b2PolygonShape.prototype.ComputeSubmergedArea.s_md=new box2d.b2MassData;box2d.b2PolygonShape.prototype.ComputeSubmergedArea.s_intoVec=new box2d.b2Vec2;box2d.b2PolygonShape.prototype.ComputeSubmergedArea.s_outoVec=new box2d.b2Vec2;box2d.b2PolygonShape.prototype.ComputeSubmergedArea.s_center=new box2d.b2Vec2;
+box2d.b2PolygonShape.prototype.Dump=function(){box2d.b2Log("    /*box2d.b2PolygonShape*/ var shape = new box2d.b2PolygonShape();\n");box2d.b2Log("    /*box2d.b2Vec2[]*/ var vs = box2d.b2Vec2.MakeArray(%d);\n",box2d.b2_maxPolygonVertices);for(var a=0;a<this.m_count;++a)box2d.b2Log("    vs[%d].Set(%.15f, %.15f);\n",a,this.m_vertices[a].x,this.m_vertices[a].y);box2d.b2Log("    shape.Set(vs, %d);\n",this.m_count)};goog.exportProperty(box2d.b2PolygonShape.prototype,"Dump",box2d.b2PolygonShape.prototype.Dump);
+box2d.b2PolygonShape.ComputeCentroid=function(a,b,c){box2d.ENABLE_ASSERTS&&box2d.b2Assert(3<=b);c.SetZero();for(var d=0,e=box2d.b2PolygonShape.ComputeCentroid.s_pRef.SetZero(),f=1/3,g=0;g<b;++g){var h=e,k=a[g],l=a[(g+1)%b],m=box2d.b2Sub_V2_V2(k,h,box2d.b2PolygonShape.ComputeCentroid.s_e1),n=box2d.b2Sub_V2_V2(l,h,box2d.b2PolygonShape.ComputeCentroid.s_e2),m=.5*box2d.b2Cross_V2_V2(m,n),d=d+m;c.x+=m*f*(h.x+k.x+l.x);c.y+=m*f*(h.y+k.y+l.y)}box2d.ENABLE_ASSERTS&&box2d.b2Assert(d>box2d.b2_epsilon);c.SelfMul(1/
+d);return c};goog.exportProperty(box2d.b2PolygonShape,"ComputeCentroid",box2d.b2PolygonShape.ComputeCentroid);box2d.b2PolygonShape.ComputeCentroid.s_pRef=new box2d.b2Vec2;box2d.b2PolygonShape.ComputeCentroid.s_e1=new box2d.b2Vec2;box2d.b2PolygonShape.ComputeCentroid.s_e2=new box2d.b2Vec2;box2d.b2Timer=function(){this.m_start=(new Date).getTime()};goog.exportSymbol("box2d.b2Timer",box2d.b2Timer);box2d.b2Timer.prototype.m_start=0;goog.exportProperty(box2d.b2Timer.prototype,"m_start",box2d.b2Timer.prototype.m_start);box2d.b2Timer.prototype.Reset=function(){this.m_start=(new Date).getTime();return this};goog.exportProperty(box2d.b2Timer.prototype,"Reset",box2d.b2Timer.prototype.Reset);box2d.b2Timer.prototype.GetMilliseconds=function(){return(new Date).getTime()-this.m_start};
+goog.exportProperty(box2d.b2Timer.prototype,"GetMilliseconds",box2d.b2Timer.prototype.GetMilliseconds);box2d.b2Counter=function(){};goog.exportSymbol("box2d.b2Counter",box2d.b2Counter);box2d.b2Counter.prototype.m_count=0;goog.exportProperty(box2d.b2Counter.prototype,"m_count",box2d.b2Counter.prototype.m_count);box2d.b2Counter.prototype.m_min_count=0;goog.exportProperty(box2d.b2Counter.prototype,"m_min_count",box2d.b2Counter.prototype.m_min_count);box2d.b2Counter.prototype.m_max_count=0;
+goog.exportProperty(box2d.b2Counter.prototype,"m_max_count",box2d.b2Counter.prototype.m_max_count);box2d.b2Counter.prototype.GetCount=function(){return this.m_count};goog.exportProperty(box2d.b2Counter.prototype,"GetCount",box2d.b2Counter.prototype.GetCount);box2d.b2Counter.prototype.GetMinCount=function(){return this.m_min_count};goog.exportProperty(box2d.b2Counter.prototype,"GetMinCount",box2d.b2Counter.prototype.GetMinCount);box2d.b2Counter.prototype.GetMaxCount=function(){return this.m_max_count};
+goog.exportProperty(box2d.b2Counter.prototype,"GetMaxCount",box2d.b2Counter.prototype.GetMaxCount);box2d.b2Counter.prototype.ResetCount=function(){var a=this.m_count;this.m_count=0;return a};goog.exportProperty(box2d.b2Counter.prototype,"ResetCount",box2d.b2Counter.prototype.ResetCount);box2d.b2Counter.prototype.ResetMinCount=function(){this.m_min_count=0};goog.exportProperty(box2d.b2Counter.prototype,"ResetMinCount",box2d.b2Counter.prototype.ResetMinCount);
+box2d.b2Counter.prototype.ResetMaxCount=function(){this.m_max_count=0};goog.exportProperty(box2d.b2Counter.prototype,"ResetMaxCount",box2d.b2Counter.prototype.ResetMaxCount);box2d.b2Counter.prototype.Increment=function(){this.m_count++;this.m_max_count<this.m_count&&(this.m_max_count=this.m_count)};goog.exportProperty(box2d.b2Counter.prototype,"Increment",box2d.b2Counter.prototype.Increment);
+box2d.b2Counter.prototype.Decrement=function(){this.m_count--;this.m_min_count>this.m_count&&(this.m_min_count=this.m_count)};goog.exportProperty(box2d.b2Counter.prototype,"Decrement",box2d.b2Counter.prototype.Decrement);box2d.b2_toiTime=0;goog.exportSymbol("box2d.b2_toiTime",box2d.b2_toiTime);box2d.b2_toiMaxTime=0;goog.exportSymbol("box2d.b2_toiMaxTime",box2d.b2_toiMaxTime);box2d.b2_toiCalls=0;goog.exportSymbol("box2d.b2_toiCalls",box2d.b2_toiCalls);box2d.b2_toiIters=0;goog.exportSymbol("box2d.b2_toiIters",box2d.b2_toiIters);box2d.b2_toiMaxIters=0;goog.exportSymbol("box2d.b2_toiMaxIters",box2d.b2_toiMaxIters);box2d.b2_toiRootIters=0;goog.exportSymbol("box2d.b2_toiRootIters",box2d.b2_toiRootIters);
+box2d.b2_toiMaxRootIters=0;goog.exportSymbol("box2d.b2_toiMaxRootIters",box2d.b2_toiMaxRootIters);box2d.b2TOIInput=function(){this.proxyA=new box2d.b2DistanceProxy;this.proxyB=new box2d.b2DistanceProxy;this.sweepA=new box2d.b2Sweep;this.sweepB=new box2d.b2Sweep};goog.exportSymbol("box2d.b2TOIInput",box2d.b2TOIInput);box2d.b2TOIInput.prototype.proxyA=null;goog.exportProperty(box2d.b2TOIInput.prototype,"proxyA",box2d.b2TOIInput.prototype.proxyA);box2d.b2TOIInput.prototype.proxyB=null;
+goog.exportProperty(box2d.b2TOIInput.prototype,"proxyB",box2d.b2TOIInput.prototype.proxyB);box2d.b2TOIInput.prototype.sweepA=null;goog.exportProperty(box2d.b2TOIInput.prototype,"sweepA",box2d.b2TOIInput.prototype.sweepA);box2d.b2TOIInput.prototype.sweepB=null;goog.exportProperty(box2d.b2TOIInput.prototype,"sweepB",box2d.b2TOIInput.prototype.sweepB);box2d.b2TOIInput.prototype.tMax=0;goog.exportProperty(box2d.b2TOIInput.prototype,"tMax",box2d.b2TOIInput.prototype.tMax);
+box2d.b2TOIOutputState={e_unknown:0,e_failed:1,e_overlapped:2,e_touching:3,e_separated:4};goog.exportSymbol("box2d.b2TOIOutputState",box2d.b2TOIOutputState);goog.exportProperty(box2d.b2TOIOutputState,"e_unknown",box2d.b2TOIOutputState.e_unknown);goog.exportProperty(box2d.b2TOIOutputState,"e_failed",box2d.b2TOIOutputState.e_failed);goog.exportProperty(box2d.b2TOIOutputState,"e_overlapped",box2d.b2TOIOutputState.e_overlapped);goog.exportProperty(box2d.b2TOIOutputState,"e_touching",box2d.b2TOIOutputState.e_touching);
+goog.exportProperty(box2d.b2TOIOutputState,"e_separated",box2d.b2TOIOutputState.e_separated);box2d.b2TOIOutput=function(){};goog.exportSymbol("box2d.b2TOIOutput",box2d.b2TOIOutput);box2d.b2TOIOutput.prototype.state=box2d.b2TOIOutputState.e_unknown;goog.exportProperty(box2d.b2TOIOutput.prototype,"state",box2d.b2TOIOutput.prototype.state);box2d.b2TOIOutput.prototype.t=0;goog.exportProperty(box2d.b2TOIOutput.prototype,"t",box2d.b2TOIOutput.prototype.t);
+box2d.b2SeparationFunctionType={e_unknown:-1,e_points:0,e_faceA:1,e_faceB:2};goog.exportSymbol("box2d.b2SeparationFunctionType",box2d.b2SeparationFunctionType);goog.exportProperty(box2d.b2SeparationFunctionType,"e_unknown",box2d.b2SeparationFunctionType.e_unknown);goog.exportProperty(box2d.b2SeparationFunctionType,"e_points",box2d.b2SeparationFunctionType.e_points);goog.exportProperty(box2d.b2SeparationFunctionType,"e_faceA",box2d.b2SeparationFunctionType.e_faceA);
+goog.exportProperty(box2d.b2SeparationFunctionType,"e_faceB",box2d.b2SeparationFunctionType.e_faceB);box2d.b2SeparationFunction=function(){this.m_sweepA=new box2d.b2Sweep;this.m_sweepB=new box2d.b2Sweep;this.m_localPoint=new box2d.b2Vec2;this.m_axis=new box2d.b2Vec2};goog.exportSymbol("box2d.b2SeparationFunction",box2d.b2SeparationFunction);box2d.b2SeparationFunction.prototype.m_proxyA=null;goog.exportProperty(box2d.b2SeparationFunction.prototype,"m_proxyA",box2d.b2SeparationFunction.prototype.m_proxyA);
+box2d.b2SeparationFunction.prototype.m_proxyB=null;goog.exportProperty(box2d.b2SeparationFunction.prototype,"m_proxyB",box2d.b2SeparationFunction.prototype.m_proxyB);box2d.b2SeparationFunction.prototype.m_sweepA=null;goog.exportProperty(box2d.b2SeparationFunction.prototype,"m_sweepA",box2d.b2SeparationFunction.prototype.m_sweepA);box2d.b2SeparationFunction.prototype.m_sweepB=null;goog.exportProperty(box2d.b2SeparationFunction.prototype,"m_sweepB",box2d.b2SeparationFunction.prototype.m_sweepB);
+box2d.b2SeparationFunction.prototype.m_type=box2d.b2SeparationFunctionType.e_unknown;goog.exportProperty(box2d.b2SeparationFunction.prototype,"m_type",box2d.b2SeparationFunction.prototype.m_type);box2d.b2SeparationFunction.prototype.m_localPoint=null;goog.exportProperty(box2d.b2SeparationFunction.prototype,"m_localPoint",box2d.b2SeparationFunction.prototype.m_localPoint);box2d.b2SeparationFunction.prototype.m_axis=null;goog.exportProperty(box2d.b2SeparationFunction.prototype,"m_axis",box2d.b2SeparationFunction.prototype.m_axis);
+box2d.b2SeparationFunction.prototype.Initialize=function(a,b,c,d,e,f){this.m_proxyA=b;this.m_proxyB=d;b=a.count;box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<b&&3>b);this.m_sweepA.Copy(c);this.m_sweepB.Copy(e);c=box2d.b2TimeOfImpact.s_xfA;e=box2d.b2TimeOfImpact.s_xfB;this.m_sweepA.GetTransform(c,f);this.m_sweepB.GetTransform(e,f);1===b?(this.m_type=box2d.b2SeparationFunctionType.e_points,b=this.m_proxyA.GetVertex(a.indexA[0]),a=this.m_proxyB.GetVertex(a.indexB[0]),c=box2d.b2Mul_X_V2(c,b,box2d.b2TimeOfImpact.s_pointA),
+e=box2d.b2Mul_X_V2(e,a,box2d.b2TimeOfImpact.s_pointB),box2d.b2Sub_V2_V2(e,c,this.m_axis),a=this.m_axis.Normalize(),this.m_localPoint.SetZero()):(a.indexA[0]===a.indexA[1]?(this.m_type=box2d.b2SeparationFunctionType.e_faceB,b=this.m_proxyB.GetVertex(a.indexB[0]),d=this.m_proxyB.GetVertex(a.indexB[1]),box2d.b2Cross_V2_S(box2d.b2Sub_V2_V2(d,b,box2d.b2Vec2.s_t0),1,this.m_axis).SelfNormalize(),f=box2d.b2Mul_R_V2(e.q,this.m_axis,box2d.b2TimeOfImpact.s_normal),box2d.b2Mid_V2_V2(b,d,this.m_localPoint),e=
+box2d.b2Mul_X_V2(e,this.m_localPoint,box2d.b2TimeOfImpact.s_pointB),b=this.m_proxyA.GetVertex(a.indexA[0]),c=box2d.b2Mul_X_V2(c,b,box2d.b2TimeOfImpact.s_pointA),a=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(c,e,box2d.b2Vec2.s_t0),f)):(this.m_type=box2d.b2SeparationFunctionType.e_faceA,b=this.m_proxyA.GetVertex(a.indexA[0]),d=this.m_proxyA.GetVertex(a.indexA[1]),box2d.b2Cross_V2_S(box2d.b2Sub_V2_V2(d,b,box2d.b2Vec2.s_t0),1,this.m_axis).SelfNormalize(),f=box2d.b2Mul_R_V2(c.q,this.m_axis,box2d.b2TimeOfImpact.s_normal),
+box2d.b2Mid_V2_V2(b,d,this.m_localPoint),c=box2d.b2Mul_X_V2(c,this.m_localPoint,box2d.b2TimeOfImpact.s_pointA),a=this.m_proxyB.GetVertex(a.indexB[0]),e=box2d.b2Mul_X_V2(e,a,box2d.b2TimeOfImpact.s_pointB),a=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(e,c,box2d.b2Vec2.s_t0),f)),0>a&&(this.m_axis.SelfNeg(),a=-a));return a};goog.exportProperty(box2d.b2SeparationFunction.prototype,"Initialize",box2d.b2SeparationFunction.prototype.Initialize);
+box2d.b2SeparationFunction.prototype.FindMinSeparation=function(a,b,c){var d=box2d.b2TimeOfImpact.s_xfA,e=box2d.b2TimeOfImpact.s_xfB;this.m_sweepA.GetTransform(d,c);this.m_sweepB.GetTransform(e,c);switch(this.m_type){case box2d.b2SeparationFunctionType.e_points:var f=box2d.b2MulT_R_V2(d.q,this.m_axis,box2d.b2TimeOfImpact.s_axisA),g=box2d.b2MulT_R_V2(e.q,box2d.b2Vec2.s_t0.Copy(this.m_axis).SelfNeg(),box2d.b2TimeOfImpact.s_axisB);a[0]=this.m_proxyA.GetSupport(f);b[0]=this.m_proxyB.GetSupport(g);a=this.m_proxyA.GetVertex(a[0]);
+b=this.m_proxyB.GetVertex(b[0]);d=box2d.b2Mul_X_V2(d,a,box2d.b2TimeOfImpact.s_pointA);e=box2d.b2Mul_X_V2(e,b,box2d.b2TimeOfImpact.s_pointB);return b=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(e,d,box2d.b2Vec2.s_t0),this.m_axis);case box2d.b2SeparationFunctionType.e_faceA:return c=box2d.b2Mul_R_V2(d.q,this.m_axis,box2d.b2TimeOfImpact.s_normal),d=box2d.b2Mul_X_V2(d,this.m_localPoint,box2d.b2TimeOfImpact.s_pointA),g=box2d.b2MulT_R_V2(e.q,box2d.b2Vec2.s_t0.Copy(c).SelfNeg(),box2d.b2TimeOfImpact.s_axisB),a[0]=
+-1,b[0]=this.m_proxyB.GetSupport(g),b=this.m_proxyB.GetVertex(b[0]),e=box2d.b2Mul_X_V2(e,b,box2d.b2TimeOfImpact.s_pointB),b=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(e,d,box2d.b2Vec2.s_t0),c);case box2d.b2SeparationFunctionType.e_faceB:return c=box2d.b2Mul_R_V2(e.q,this.m_axis,box2d.b2TimeOfImpact.s_normal),e=box2d.b2Mul_X_V2(e,this.m_localPoint,box2d.b2TimeOfImpact.s_pointB),f=box2d.b2MulT_R_V2(d.q,box2d.b2Vec2.s_t0.Copy(c).SelfNeg(),box2d.b2TimeOfImpact.s_axisA),b[0]=-1,a[0]=this.m_proxyA.GetSupport(f),
+a=this.m_proxyA.GetVertex(a[0]),d=box2d.b2Mul_X_V2(d,a,box2d.b2TimeOfImpact.s_pointA),b=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(d,e,box2d.b2Vec2.s_t0),c);default:return box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1),a[0]=-1,b[0]=-1,0}};goog.exportProperty(box2d.b2SeparationFunction.prototype,"FindMinSeparation",box2d.b2SeparationFunction.prototype.FindMinSeparation);
+box2d.b2SeparationFunction.prototype.Evaluate=function(a,b,c){var d=box2d.b2TimeOfImpact.s_xfA,e=box2d.b2TimeOfImpact.s_xfB;this.m_sweepA.GetTransform(d,c);this.m_sweepB.GetTransform(e,c);switch(this.m_type){case box2d.b2SeparationFunctionType.e_points:return a=this.m_proxyA.GetVertex(a),b=this.m_proxyB.GetVertex(b),d=box2d.b2Mul_X_V2(d,a,box2d.b2TimeOfImpact.s_pointA),e=box2d.b2Mul_X_V2(e,b,box2d.b2TimeOfImpact.s_pointB),d=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(e,d,box2d.b2Vec2.s_t0),this.m_axis);case box2d.b2SeparationFunctionType.e_faceA:return c=
+box2d.b2Mul_R_V2(d.q,this.m_axis,box2d.b2TimeOfImpact.s_normal),d=box2d.b2Mul_X_V2(d,this.m_localPoint,box2d.b2TimeOfImpact.s_pointA),b=this.m_proxyB.GetVertex(b),e=box2d.b2Mul_X_V2(e,b,box2d.b2TimeOfImpact.s_pointB),d=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(e,d,box2d.b2Vec2.s_t0),c);case box2d.b2SeparationFunctionType.e_faceB:return c=box2d.b2Mul_R_V2(e.q,this.m_axis,box2d.b2TimeOfImpact.s_normal),e=box2d.b2Mul_X_V2(e,this.m_localPoint,box2d.b2TimeOfImpact.s_pointB),a=this.m_proxyA.GetVertex(a),d=box2d.b2Mul_X_V2(d,
+a,box2d.b2TimeOfImpact.s_pointA),d=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(d,e,box2d.b2Vec2.s_t0),c);default:return box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1),0}};goog.exportProperty(box2d.b2SeparationFunction.prototype,"Evaluate",box2d.b2SeparationFunction.prototype.Evaluate);
+box2d.b2TimeOfImpact=function(a,b){var c=box2d.b2TimeOfImpact.s_timer.Reset();++box2d.b2_toiCalls;a.state=box2d.b2TOIOutputState.e_unknown;a.t=b.tMax;var d=b.proxyA,e=b.proxyB,f=box2d.b2TimeOfImpact.s_sweepA.Copy(b.sweepA),g=box2d.b2TimeOfImpact.s_sweepB.Copy(b.sweepB);f.Normalize();g.Normalize();var h=b.tMax,k=box2d.b2Max(box2d.b2_linearSlop,d.m_radius+e.m_radius-3*box2d.b2_linearSlop),l=.25*box2d.b2_linearSlop;box2d.ENABLE_ASSERTS&&box2d.b2Assert(k>l);var m=0,n=0,p=box2d.b2TimeOfImpact.s_cache;
+p.count=0;var q=box2d.b2TimeOfImpact.s_distanceInput;q.proxyA=b.proxyA;q.proxyB=b.proxyB;for(q.useRadii=!1;;){var r=box2d.b2TimeOfImpact.s_xfA,u=box2d.b2TimeOfImpact.s_xfB;f.GetTransform(r,m);g.GetTransform(u,m);q.transformA.Copy(r);q.transformB.Copy(u);r=box2d.b2TimeOfImpact.s_distanceOutput;box2d.b2ShapeDistance(r,p,q);if(0>=r.distance){a.state=box2d.b2TOIOutputState.e_overlapped;a.t=0;break}if(r.distance<k+l){a.state=box2d.b2TOIOutputState.e_touching;a.t=m;break}r=box2d.b2TimeOfImpact.s_fcn;r.Initialize(p,
+d,f,e,g,m);for(var u=!1,t=h,w=0;;){var x=box2d.b2TimeOfImpact.s_indexA,v=box2d.b2TimeOfImpact.s_indexB,y=r.FindMinSeparation(x,v,t);if(y>k+l){a.state=box2d.b2TOIOutputState.e_separated;a.t=h;u=!0;break}if(y>k-l){m=t;break}var z=r.Evaluate(x[0],v[0],m);if(z<k-l){a.state=box2d.b2TOIOutputState.e_failed;a.t=m;u=!0;break}if(z<=k+l){a.state=box2d.b2TOIOutputState.e_touching;a.t=m;u=!0;break}for(var B=0,E=m,F=t;;){var G=0,G=B&1?E+(k-z)*(F-E)/(y-z):.5*(E+F);++B;++box2d.b2_toiRootIters;var H=r.Evaluate(x[0],
+v[0],G);if(box2d.b2Abs(H-k)<l){t=G;break}H>k?(E=G,z=H):(F=G,y=H);if(50===B)break}box2d.b2_toiMaxRootIters=box2d.b2Max(box2d.b2_toiMaxRootIters,B);++w;if(w===box2d.b2_maxPolygonVertices)break}++n;++box2d.b2_toiIters;if(u)break;if(20===n){a.state=box2d.b2TOIOutputState.e_failed;a.t=m;break}}box2d.b2_toiMaxIters=box2d.b2Max(box2d.b2_toiMaxIters,n);c=c.GetMilliseconds();box2d.b2_toiMaxTime=box2d.b2Max(box2d.b2_toiMaxTime,c);box2d.b2_toiTime+=c};goog.exportSymbol("box2d.b2TimeOfImpact",box2d.b2TimeOfImpact);
+box2d.b2TimeOfImpact.s_timer=new box2d.b2Timer;box2d.b2TimeOfImpact.s_cache=new box2d.b2SimplexCache;box2d.b2TimeOfImpact.s_distanceInput=new box2d.b2DistanceInput;box2d.b2TimeOfImpact.s_distanceOutput=new box2d.b2DistanceOutput;box2d.b2TimeOfImpact.s_xfA=new box2d.b2Transform;box2d.b2TimeOfImpact.s_xfB=new box2d.b2Transform;box2d.b2TimeOfImpact.s_indexA=box2d.b2MakeNumberArray(1);box2d.b2TimeOfImpact.s_indexB=box2d.b2MakeNumberArray(1);box2d.b2TimeOfImpact.s_fcn=new box2d.b2SeparationFunction;
+box2d.b2TimeOfImpact.s_sweepA=new box2d.b2Sweep;box2d.b2TimeOfImpact.s_sweepB=new box2d.b2Sweep;box2d.b2TimeOfImpact.s_pointA=new box2d.b2Vec2;box2d.b2TimeOfImpact.s_pointB=new box2d.b2Vec2;box2d.b2TimeOfImpact.s_normal=new box2d.b2Vec2;box2d.b2TimeOfImpact.s_axisA=new box2d.b2Vec2;box2d.b2TimeOfImpact.s_axisB=new box2d.b2Vec2;box2d.b2Filter=function(){};goog.exportSymbol("box2d.b2Filter",box2d.b2Filter);box2d.b2Filter.prototype.categoryBits=1;goog.exportProperty(box2d.b2Filter.prototype,"categoryBits",box2d.b2Filter.prototype.categoryBits);box2d.b2Filter.prototype.maskBits=65535;goog.exportProperty(box2d.b2Filter.prototype,"maskBits",box2d.b2Filter.prototype.maskBits);box2d.b2Filter.prototype.groupIndex=0;goog.exportProperty(box2d.b2Filter.prototype,"groupIndex",box2d.b2Filter.prototype.groupIndex);
+box2d.b2Filter.prototype.Clone=function(){return(new box2d.b2Filter).Copy(this)};goog.exportProperty(box2d.b2Filter.prototype,"Clone",box2d.b2Filter.prototype.Clone);box2d.b2Filter.prototype.Copy=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(this!==a);this.categoryBits=a.categoryBits;this.maskBits=a.maskBits;this.groupIndex=a.groupIndex;return this};goog.exportProperty(box2d.b2Filter.prototype,"Copy",box2d.b2Filter.prototype.Copy);box2d.b2FixtureDef=function(){this.filter=new box2d.b2Filter};
+goog.exportSymbol("box2d.b2FixtureDef",box2d.b2FixtureDef);box2d.b2FixtureDef.prototype.shape=null;goog.exportProperty(box2d.b2FixtureDef.prototype,"shape",box2d.b2FixtureDef.prototype.shape);box2d.b2FixtureDef.prototype.userData=null;goog.exportProperty(box2d.b2FixtureDef.prototype,"userData",box2d.b2FixtureDef.prototype.userData);box2d.b2FixtureDef.prototype.friction=.2;goog.exportProperty(box2d.b2FixtureDef.prototype,"friction",box2d.b2FixtureDef.prototype.friction);
+box2d.b2FixtureDef.prototype.restitution=0;goog.exportProperty(box2d.b2FixtureDef.prototype,"restitution",box2d.b2FixtureDef.prototype.restitution);box2d.b2FixtureDef.prototype.density=0;goog.exportProperty(box2d.b2FixtureDef.prototype,"density",box2d.b2FixtureDef.prototype.density);box2d.b2FixtureDef.prototype.isSensor=!1;goog.exportProperty(box2d.b2FixtureDef.prototype,"isSensor",box2d.b2FixtureDef.prototype.isSensor);box2d.b2FixtureDef.prototype.filter=null;
+goog.exportProperty(box2d.b2FixtureDef.prototype,"filter",box2d.b2FixtureDef.prototype.filter);box2d.b2FixtureProxy=function(){this.aabb=new box2d.b2AABB};goog.exportSymbol("box2d.b2FixtureProxy",box2d.b2FixtureProxy);box2d.b2FixtureProxy.prototype.aabb=null;goog.exportProperty(box2d.b2FixtureProxy.prototype,"aabb",box2d.b2FixtureProxy.prototype.aabb);box2d.b2FixtureProxy.prototype.fixture=null;goog.exportProperty(box2d.b2FixtureProxy.prototype,"fixture",box2d.b2FixtureProxy.prototype.fixture);
+box2d.b2FixtureProxy.prototype.childIndex=0;goog.exportProperty(box2d.b2FixtureProxy.prototype,"childIndex",box2d.b2FixtureProxy.prototype.childIndex);box2d.b2FixtureProxy.prototype.proxy=null;goog.exportProperty(box2d.b2FixtureProxy.prototype,"proxy",box2d.b2FixtureProxy.prototype.proxy);box2d.b2FixtureProxy.MakeArray=function(a){return box2d.b2MakeArray(a,function(a){return new box2d.b2FixtureProxy})};goog.exportProperty(box2d.b2FixtureProxy,"MakeArray",box2d.b2FixtureProxy.MakeArray);
+box2d.b2Fixture=function(){this.m_proxyCount=0;this.m_filter=new box2d.b2Filter};goog.exportSymbol("box2d.b2Fixture",box2d.b2Fixture);box2d.b2Fixture.prototype.m_density=0;goog.exportProperty(box2d.b2Fixture.prototype,"m_density",box2d.b2Fixture.prototype.m_density);box2d.b2Fixture.prototype.m_next=null;goog.exportProperty(box2d.b2Fixture.prototype,"m_next",box2d.b2Fixture.prototype.m_next);box2d.b2Fixture.prototype.m_body=null;goog.exportProperty(box2d.b2Fixture.prototype,"m_body",box2d.b2Fixture.prototype.m_body);
+box2d.b2Fixture.prototype.m_shape=null;goog.exportProperty(box2d.b2Fixture.prototype,"m_shape",box2d.b2Fixture.prototype.m_shape);box2d.b2Fixture.prototype.m_friction=0;goog.exportProperty(box2d.b2Fixture.prototype,"m_friction",box2d.b2Fixture.prototype.m_friction);box2d.b2Fixture.prototype.m_restitution=0;goog.exportProperty(box2d.b2Fixture.prototype,"m_restitution",box2d.b2Fixture.prototype.m_restitution);box2d.b2Fixture.prototype.m_proxies=null;
+goog.exportProperty(box2d.b2Fixture.prototype,"m_proxies",box2d.b2Fixture.prototype.m_proxies);box2d.b2Fixture.prototype.m_proxyCount=0;goog.exportProperty(box2d.b2Fixture.prototype,"m_proxyCount",box2d.b2Fixture.prototype.m_proxyCount);box2d.b2Fixture.prototype.m_filter=null;goog.exportProperty(box2d.b2Fixture.prototype,"m_filter",box2d.b2Fixture.prototype.m_filter);box2d.b2Fixture.prototype.m_isSensor=!1;goog.exportProperty(box2d.b2Fixture.prototype,"m_isSensor",box2d.b2Fixture.prototype.m_isSensor);
+box2d.b2Fixture.prototype.m_userData=null;goog.exportProperty(box2d.b2Fixture.prototype,"m_userData",box2d.b2Fixture.prototype.m_userData);box2d.b2Fixture.prototype.GetType=function(){return this.m_shape.GetType()};goog.exportProperty(box2d.b2Fixture.prototype,"GetType",box2d.b2Fixture.prototype.GetType);box2d.b2Fixture.prototype.GetShape=function(){return this.m_shape};goog.exportProperty(box2d.b2Fixture.prototype,"GetShape",box2d.b2Fixture.prototype.GetShape);
+box2d.b2Fixture.prototype.IsSensor=function(){return this.m_isSensor};goog.exportProperty(box2d.b2Fixture.prototype,"IsSensor",box2d.b2Fixture.prototype.IsSensor);box2d.b2Fixture.prototype.GetFilterData=function(a){a=a||new box2d.b2Filter;return a.Copy(this.m_filter)};goog.exportProperty(box2d.b2Fixture.prototype,"GetFilterData",box2d.b2Fixture.prototype.GetFilterData);box2d.b2Fixture.prototype.GetUserData=function(){return this.m_userData};
+goog.exportProperty(box2d.b2Fixture.prototype,"GetUserData",box2d.b2Fixture.prototype.GetUserData);box2d.b2Fixture.prototype.SetUserData=function(a){this.m_userData=a};goog.exportProperty(box2d.b2Fixture.prototype,"SetUserData",box2d.b2Fixture.prototype.SetUserData);box2d.b2Fixture.prototype.GetBody=function(){return this.m_body};goog.exportProperty(box2d.b2Fixture.prototype,"GetBody",box2d.b2Fixture.prototype.GetBody);box2d.b2Fixture.prototype.GetNext=function(){return this.m_next};
+goog.exportProperty(box2d.b2Fixture.prototype,"GetNext",box2d.b2Fixture.prototype.GetNext);box2d.b2Fixture.prototype.SetDensity=function(a){this.m_density=a};goog.exportProperty(box2d.b2Fixture.prototype,"SetDensity",box2d.b2Fixture.prototype.SetDensity);box2d.b2Fixture.prototype.GetDensity=function(){return this.m_density};goog.exportProperty(box2d.b2Fixture.prototype,"GetDensity",box2d.b2Fixture.prototype.GetDensity);box2d.b2Fixture.prototype.GetFriction=function(){return this.m_friction};
+goog.exportProperty(box2d.b2Fixture.prototype,"GetFriction",box2d.b2Fixture.prototype.GetFriction);box2d.b2Fixture.prototype.SetFriction=function(a){this.m_friction=a};goog.exportProperty(box2d.b2Fixture.prototype,"SetFriction",box2d.b2Fixture.prototype.SetFriction);box2d.b2Fixture.prototype.GetRestitution=function(){return this.m_restitution};goog.exportProperty(box2d.b2Fixture.prototype,"GetRestitution",box2d.b2Fixture.prototype.GetRestitution);
+box2d.b2Fixture.prototype.SetRestitution=function(a){this.m_restitution=a};goog.exportProperty(box2d.b2Fixture.prototype,"SetRestitution",box2d.b2Fixture.prototype.SetRestitution);box2d.b2Fixture.prototype.TestPoint=function(a){return this.m_shape.TestPoint(this.m_body.GetTransform(),a)};goog.exportProperty(box2d.b2Fixture.prototype,"TestPoint",box2d.b2Fixture.prototype.TestPoint);
+box2d.b2Fixture.prototype.ComputeDistance=function(a,b,c){return this.m_shape.ComputeDistance(this.m_body.GetTransform(),a,b,c)};goog.exportProperty(box2d.b2Fixture.prototype,"ComputeDistance",box2d.b2Fixture.prototype.ComputeDistance);box2d.b2Fixture.prototype.RayCast=function(a,b,c){return this.m_shape.RayCast(a,b,this.m_body.GetTransform(),c)};goog.exportProperty(box2d.b2Fixture.prototype,"RayCast",box2d.b2Fixture.prototype.RayCast);
+box2d.b2Fixture.prototype.GetMassData=function(a){a=a||new box2d.b2MassData;this.m_shape.ComputeMass(a,this.m_density);return a};goog.exportProperty(box2d.b2Fixture.prototype,"GetMassData",box2d.b2Fixture.prototype.GetMassData);box2d.b2Fixture.prototype.GetAABB=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<=a&&a<this.m_proxyCount);return this.m_proxies[a].aabb};goog.exportProperty(box2d.b2Fixture.prototype,"GetAABB",box2d.b2Fixture.prototype.GetAABB);
+box2d.b2Fixture.prototype.Create=function(a,b){this.m_userData=b.userData;this.m_friction=b.friction;this.m_restitution=b.restitution;this.m_body=a;this.m_next=null;this.m_filter.Copy(b.filter);this.m_isSensor=b.isSensor;this.m_shape=b.shape.Clone();this.m_proxies=box2d.b2FixtureProxy.MakeArray(this.m_shape.GetChildCount());this.m_proxyCount=0;this.m_density=b.density};goog.exportProperty(box2d.b2Fixture.prototype,"Create",box2d.b2Fixture.prototype.Create);
+box2d.b2Fixture.prototype.Destroy=function(){box2d.ENABLE_ASSERTS&&box2d.b2Assert(0===this.m_proxyCount);this.m_shape=null};goog.exportProperty(box2d.b2Fixture.prototype,"Destroy",box2d.b2Fixture.prototype.Destroy);
+box2d.b2Fixture.prototype.CreateProxies=function(a,b){box2d.ENABLE_ASSERTS&&box2d.b2Assert(0===this.m_proxyCount);this.m_proxyCount=this.m_shape.GetChildCount();for(var c=0;c<this.m_proxyCount;++c){var d=this.m_proxies[c];this.m_shape.ComputeAABB(d.aabb,b,c);d.proxy=a.CreateProxy(d.aabb,d);d.fixture=this;d.childIndex=c}};goog.exportProperty(box2d.b2Fixture.prototype,"CreateProxies",box2d.b2Fixture.prototype.CreateProxies);
+box2d.b2Fixture.prototype.DestroyProxies=function(a){for(var b=0;b<this.m_proxyCount;++b){var c=this.m_proxies[b];a.DestroyProxy(c.proxy);c.proxy=null}this.m_proxyCount=0};goog.exportProperty(box2d.b2Fixture.prototype,"DestroyProxies",box2d.b2Fixture.prototype.DestroyProxies);
+box2d.b2Fixture.prototype.Synchronize=function(a,b,c){if(0!==this.m_proxyCount)for(var d=0;d<this.m_proxyCount;++d){var e=this.m_proxies[d],f=box2d.b2Fixture.prototype.Synchronize.s_aabb1,g=box2d.b2Fixture.prototype.Synchronize.s_aabb2;this.m_shape.ComputeAABB(f,b,d);this.m_shape.ComputeAABB(g,c,d);e.aabb.Combine2(f,g);f=box2d.b2Sub_V2_V2(c.p,b.p,box2d.b2Fixture.prototype.Synchronize.s_displacement);a.MoveProxy(e.proxy,e.aabb,f)}};goog.exportProperty(box2d.b2Fixture.prototype,"Synchronize",box2d.b2Fixture.prototype.Synchronize);
+box2d.b2Fixture.prototype.Synchronize.s_aabb1=new box2d.b2AABB;box2d.b2Fixture.prototype.Synchronize.s_aabb2=new box2d.b2AABB;box2d.b2Fixture.prototype.Synchronize.s_displacement=new box2d.b2Vec2;box2d.b2Fixture.prototype.SetFilterData=function(a){this.m_filter.Copy(a);this.Refilter()};goog.exportProperty(box2d.b2Fixture.prototype,"SetFilterData",box2d.b2Fixture.prototype.SetFilterData);
+box2d.b2Fixture.prototype.Refilter=function(){if(null!==this.m_body){for(var a=this.m_body.GetContactList();a;){var b=a.contact,c=b.GetFixtureA(),d=b.GetFixtureB();c!==this&&d!==this||b.FlagForFiltering();a=a.next}a=this.m_body.GetWorld();if(null!==a)for(a=a.m_contactManager.m_broadPhase,b=0;b<this.m_proxyCount;++b)a.TouchProxy(this.m_proxies[b].proxy)}};goog.exportProperty(box2d.b2Fixture.prototype,"Refilter",box2d.b2Fixture.prototype.Refilter);
+box2d.b2Fixture.prototype.SetSensor=function(a){a!==this.m_isSensor&&(this.m_body.SetAwake(!0),this.m_isSensor=a)};goog.exportProperty(box2d.b2Fixture.prototype,"SetSensor",box2d.b2Fixture.prototype.SetSensor);
+box2d.b2Fixture.prototype.Dump=function(a){box2d.DEBUG&&(box2d.b2Log("    /*box2d.b2FixtureDef*/ var fd = new box2d.b2FixtureDef();\n"),box2d.b2Log("    fd.friction = %.15f;\n",this.m_friction),box2d.b2Log("    fd.restitution = %.15f;\n",this.m_restitution),box2d.b2Log("    fd.density = %.15f;\n",this.m_density),box2d.b2Log("    fd.isSensor = %s;\n",this.m_isSensor?"true":"false"),box2d.b2Log("    fd.filter.categoryBits = %d;\n",this.m_filter.categoryBits),box2d.b2Log("    fd.filter.maskBits = %d;\n",
+this.m_filter.maskBits),box2d.b2Log("    fd.filter.groupIndex = %d;\n",this.m_filter.groupIndex),this.m_shape.Dump(),box2d.b2Log("\n"),box2d.b2Log("    fd.shape = shape;\n"),box2d.b2Log("\n"),box2d.b2Log("    bodies[%d].CreateFixture(fd);\n",a))};goog.exportProperty(box2d.b2Fixture.prototype,"Dump",box2d.b2Fixture.prototype.Dump);box2d.b2BodyType={b2_unknown:-1,b2_staticBody:0,b2_kinematicBody:1,b2_dynamicBody:2,b2_bulletBody:3};goog.exportSymbol("box2d.b2BodyType",box2d.b2BodyType);goog.exportProperty(box2d.b2BodyType,"b2_unknown",box2d.b2BodyType.b2_unknown);goog.exportProperty(box2d.b2BodyType,"b2_staticBody",box2d.b2BodyType.b2_staticBody);goog.exportProperty(box2d.b2BodyType,"b2_kinematicBody",box2d.b2BodyType.b2_kinematicBody);goog.exportProperty(box2d.b2BodyType,"b2_dynamicBody",box2d.b2BodyType.b2_dynamicBody);
+goog.exportProperty(box2d.b2BodyType,"b2_bulletBody",box2d.b2BodyType.b2_bulletBody);box2d.b2BodyDef=function(){this.position=new box2d.b2Vec2(0,0);this.linearVelocity=new box2d.b2Vec2(0,0)};goog.exportSymbol("box2d.b2BodyDef",box2d.b2BodyDef);box2d.b2BodyDef.prototype.type=box2d.b2BodyType.b2_staticBody;goog.exportProperty(box2d.b2BodyDef.prototype,"type",box2d.b2BodyDef.prototype.type);box2d.b2BodyDef.prototype.position=null;goog.exportProperty(box2d.b2BodyDef.prototype,"position",box2d.b2BodyDef.prototype.position);
+box2d.b2BodyDef.prototype.angle=0;goog.exportProperty(box2d.b2BodyDef.prototype,"angle",box2d.b2BodyDef.prototype.angle);box2d.b2BodyDef.prototype.linearVelocity=null;goog.exportProperty(box2d.b2BodyDef.prototype,"linearVelocity",box2d.b2BodyDef.prototype.linearVelocity);box2d.b2BodyDef.prototype.angularVelocity=0;goog.exportProperty(box2d.b2BodyDef.prototype,"angularVelocity",box2d.b2BodyDef.prototype.angularVelocity);box2d.b2BodyDef.prototype.linearDamping=0;
+goog.exportProperty(box2d.b2BodyDef.prototype,"linearDamping",box2d.b2BodyDef.prototype.linearDamping);box2d.b2BodyDef.prototype.angularDamping=0;goog.exportProperty(box2d.b2BodyDef.prototype,"angularDamping",box2d.b2BodyDef.prototype.angularDamping);box2d.b2BodyDef.prototype.allowSleep=!0;goog.exportProperty(box2d.b2BodyDef.prototype,"allowSleep",box2d.b2BodyDef.prototype.allowSleep);box2d.b2BodyDef.prototype.awake=!0;goog.exportProperty(box2d.b2BodyDef.prototype,"awake",box2d.b2BodyDef.prototype.awake);
+box2d.b2BodyDef.prototype.fixedRotation=!1;goog.exportProperty(box2d.b2BodyDef.prototype,"fixedRotation",box2d.b2BodyDef.prototype.fixedRotation);box2d.b2BodyDef.prototype.bullet=!1;goog.exportProperty(box2d.b2BodyDef.prototype,"bullet",box2d.b2BodyDef.prototype.bullet);box2d.b2BodyDef.prototype.active=!0;goog.exportProperty(box2d.b2BodyDef.prototype,"active",box2d.b2BodyDef.prototype.active);box2d.b2BodyDef.prototype.userData=null;goog.exportProperty(box2d.b2BodyDef.prototype,"userData",box2d.b2BodyDef.prototype.userData);
+box2d.b2BodyDef.prototype.gravityScale=1;goog.exportProperty(box2d.b2BodyDef.prototype,"gravityScale",box2d.b2BodyDef.prototype.gravityScale);
+box2d.b2Body=function(a,b){this.m_xf=new box2d.b2Transform;this.m_out_xf=new box2d.b2Transform;this.m_xf0=new box2d.b2Transform;this.m_sweep=new box2d.b2Sweep;this.m_out_sweep=new box2d.b2Sweep;this.m_linearVelocity=new box2d.b2Vec2;this.m_out_linearVelocity=new box2d.b2Vec2;this.m_force=new box2d.b2Vec2;box2d.ENABLE_ASSERTS&&box2d.b2Assert(a.position.IsValid());box2d.ENABLE_ASSERTS&&box2d.b2Assert(a.linearVelocity.IsValid());box2d.ENABLE_ASSERTS&&box2d.b2Assert(box2d.b2IsValid(a.angle));box2d.ENABLE_ASSERTS&&
+box2d.b2Assert(box2d.b2IsValid(a.angularVelocity));box2d.ENABLE_ASSERTS&&box2d.b2Assert(box2d.b2IsValid(a.gravityScale)&&0<=a.gravityScale);box2d.ENABLE_ASSERTS&&box2d.b2Assert(box2d.b2IsValid(a.angularDamping)&&0<=a.angularDamping);box2d.ENABLE_ASSERTS&&box2d.b2Assert(box2d.b2IsValid(a.linearDamping)&&0<=a.linearDamping);a.bullet&&(this.m_flag_bulletFlag=!0);a.fixedRotation&&(this.m_flag_fixedRotationFlag=!0);a.allowSleep&&(this.m_flag_autoSleepFlag=!0);a.awake&&(this.m_flag_awakeFlag=!0);a.active&&
+(this.m_flag_activeFlag=!0);this.m_world=b;this.m_xf.p.Copy(a.position);this.m_xf.q.SetAngle(a.angle);this.m_xf0.Copy(this.m_xf);this.m_sweep.localCenter.SetZero();this.m_sweep.c0.Copy(this.m_xf.p);this.m_sweep.c.Copy(this.m_xf.p);this.m_sweep.a0=a.angle;this.m_sweep.a=a.angle;this.m_sweep.alpha0=0;this.m_linearVelocity.Copy(a.linearVelocity);this.m_angularVelocity=a.angularVelocity;this.m_linearDamping=a.linearDamping;this.m_angularDamping=a.angularDamping;this.m_gravityScale=a.gravityScale;this.m_force.SetZero();
+this.m_sleepTime=this.m_torque=0;this.m_type=a.type;this.m_invMass=a.type===box2d.b2BodyType.b2_dynamicBody?this.m_mass=1:this.m_mass=0;this.m_invI=this.m_I=0;this.m_userData=a.userData;this.m_fixtureList=null;this.m_fixtureCount=0;this.m_controllerList=null;this.m_controllerCount=0};goog.exportSymbol("box2d.b2Body",box2d.b2Body);box2d.b2Body.prototype.m_flag_islandFlag=!1;goog.exportProperty(box2d.b2Body.prototype,"m_flag_islandFlag",box2d.b2Body.prototype.m_flag_islandFlag);
+box2d.b2Body.prototype.m_flag_awakeFlag=!1;goog.exportProperty(box2d.b2Body.prototype,"m_flag_awakeFlag",box2d.b2Body.prototype.m_flag_awakeFlag);box2d.b2Body.prototype.m_flag_autoSleepFlag=!1;goog.exportProperty(box2d.b2Body.prototype,"m_flag_autoSleepFlag",box2d.b2Body.prototype.m_flag_autoSleepFlag);box2d.b2Body.prototype.m_flag_bulletFlag=!1;goog.exportProperty(box2d.b2Body.prototype,"m_flag_bulletFlag",box2d.b2Body.prototype.m_flag_bulletFlag);
+box2d.b2Body.prototype.m_flag_fixedRotationFlag=!1;goog.exportProperty(box2d.b2Body.prototype,"m_flag_fixedRotationFlag",box2d.b2Body.prototype.m_flag_fixedRotationFlag);box2d.b2Body.prototype.m_flag_activeFlag=!1;goog.exportProperty(box2d.b2Body.prototype,"m_flag_activeFlag",box2d.b2Body.prototype.m_flag_activeFlag);box2d.b2Body.prototype.m_flag_toiFlag=!1;goog.exportProperty(box2d.b2Body.prototype,"m_flag_toiFlag",box2d.b2Body.prototype.m_flag_toiFlag);box2d.b2Body.prototype.m_islandIndex=0;
+goog.exportProperty(box2d.b2Body.prototype,"m_islandIndex",box2d.b2Body.prototype.m_islandIndex);box2d.b2Body.prototype.m_world=null;goog.exportProperty(box2d.b2Body.prototype,"m_world",box2d.b2Body.prototype.m_world);box2d.b2Body.prototype.m_xf=null;goog.exportProperty(box2d.b2Body.prototype,"m_xf",box2d.b2Body.prototype.m_xf);box2d.b2Body.prototype.m_out_xf=null;goog.exportProperty(box2d.b2Body.prototype,"m_out_xf",box2d.b2Body.prototype.m_out_xf);box2d.b2Body.prototype.m_xf0=null;
+goog.exportProperty(box2d.b2Body.prototype,"m_xf0",box2d.b2Body.prototype.m_xf0);box2d.b2Body.prototype.m_sweep=null;goog.exportProperty(box2d.b2Body.prototype,"m_sweep",box2d.b2Body.prototype.m_sweep);box2d.b2Body.prototype.m_out_sweep=null;goog.exportProperty(box2d.b2Body.prototype,"m_out_sweep",box2d.b2Body.prototype.m_out_sweep);box2d.b2Body.prototype.m_jointList=null;goog.exportProperty(box2d.b2Body.prototype,"m_jointList",box2d.b2Body.prototype.m_jointList);
+box2d.b2Body.prototype.m_contactList=null;goog.exportProperty(box2d.b2Body.prototype,"m_contactList",box2d.b2Body.prototype.m_contactList);box2d.b2Body.prototype.m_prev=null;goog.exportProperty(box2d.b2Body.prototype,"m_prev",box2d.b2Body.prototype.m_prev);box2d.b2Body.prototype.m_next=null;goog.exportProperty(box2d.b2Body.prototype,"m_next",box2d.b2Body.prototype.m_next);box2d.b2Body.prototype.m_linearVelocity=null;goog.exportProperty(box2d.b2Body.prototype,"m_linearVelocity",box2d.b2Body.prototype.m_linearVelocity);
+box2d.b2Body.prototype.m_out_linearVelocity=null;goog.exportProperty(box2d.b2Body.prototype,"m_out_linearVelocity",box2d.b2Body.prototype.m_out_linearVelocity);box2d.b2Body.prototype.m_angularVelocity=0;goog.exportProperty(box2d.b2Body.prototype,"m_angularVelocity",box2d.b2Body.prototype.m_angularVelocity);box2d.b2Body.prototype.m_linearDamping=0;goog.exportProperty(box2d.b2Body.prototype,"m_linearDamping",box2d.b2Body.prototype.m_linearDamping);box2d.b2Body.prototype.m_angularDamping=0;
+goog.exportProperty(box2d.b2Body.prototype,"m_angularDamping",box2d.b2Body.prototype.m_angularDamping);box2d.b2Body.prototype.m_gravityScale=1;goog.exportProperty(box2d.b2Body.prototype,"m_gravityScale",box2d.b2Body.prototype.m_gravityScale);box2d.b2Body.prototype.m_force=null;goog.exportProperty(box2d.b2Body.prototype,"m_force",box2d.b2Body.prototype.m_force);box2d.b2Body.prototype.m_torque=0;goog.exportProperty(box2d.b2Body.prototype,"m_torque",box2d.b2Body.prototype.m_torque);
+box2d.b2Body.prototype.m_sleepTime=0;goog.exportProperty(box2d.b2Body.prototype,"m_sleepTime",box2d.b2Body.prototype.m_sleepTime);box2d.b2Body.prototype.m_type=box2d.b2BodyType.b2_staticBody;goog.exportProperty(box2d.b2Body.prototype,"m_type",box2d.b2Body.prototype.m_type);box2d.b2Body.prototype.m_mass=1;goog.exportProperty(box2d.b2Body.prototype,"m_mass",box2d.b2Body.prototype.m_mass);box2d.b2Body.prototype.m_invMass=1;goog.exportProperty(box2d.b2Body.prototype,"m_invMass",box2d.b2Body.prototype.m_invMass);
+box2d.b2Body.prototype.m_I=0;goog.exportProperty(box2d.b2Body.prototype,"m_I",box2d.b2Body.prototype.m_I);box2d.b2Body.prototype.m_invI=0;goog.exportProperty(box2d.b2Body.prototype,"m_invI",box2d.b2Body.prototype.m_invI);box2d.b2Body.prototype.m_userData=null;goog.exportProperty(box2d.b2Body.prototype,"m_userData",box2d.b2Body.prototype.m_userData);box2d.b2Body.prototype.m_fixtureList=null;goog.exportProperty(box2d.b2Body.prototype,"m_fixtureList",box2d.b2Body.prototype.m_fixtureList);
+box2d.b2Body.prototype.m_fixtureCount=0;goog.exportProperty(box2d.b2Body.prototype,"m_fixtureCount",box2d.b2Body.prototype.m_fixtureCount);box2d.b2Body.prototype.m_controllerList=null;goog.exportProperty(box2d.b2Body.prototype,"m_controllerList",box2d.b2Body.prototype.m_controllerList);box2d.b2Body.prototype.m_controllerCount=0;goog.exportProperty(box2d.b2Body.prototype,"m_controllerCount",box2d.b2Body.prototype.m_controllerCount);
+box2d.b2Body.prototype.CreateFixture=function(a,b){if(a instanceof box2d.b2FixtureDef)return this.CreateFixture_Def(a);if(a instanceof box2d.b2Shape&&"number"===typeof b)return this.CreateFixture_Shape_Density(a,b);throw Error();};goog.exportProperty(box2d.b2Body.prototype,"CreateFixture",box2d.b2Body.prototype.CreateFixture);
+box2d.b2Body.prototype.CreateFixture_Def=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!this.m_world.IsLocked());if(this.m_world.IsLocked())return null;var b=new box2d.b2Fixture;b.Create(this,a);this.m_flag_activeFlag&&b.CreateProxies(this.m_world.m_contactManager.m_broadPhase,this.m_xf);b.m_next=this.m_fixtureList;this.m_fixtureList=b;++this.m_fixtureCount;b.m_body=this;0<b.m_density&&this.ResetMassData();this.m_world.m_flag_newFixture=!0;return b};
+goog.exportProperty(box2d.b2Body.prototype,"CreateFixture_Def",box2d.b2Body.prototype.CreateFixture_Def);box2d.b2Body.prototype.CreateFixture_Shape_Density=function(a,b){var c=box2d.b2Body.prototype.CreateFixture_Shape_Density.s_def;c.shape=a;c.density="number"===typeof b?b:0;return this.CreateFixture_Def(c)};goog.exportProperty(box2d.b2Body.prototype,"CreateFixture_Shape_Density",box2d.b2Body.prototype.CreateFixture_Shape_Density);box2d.b2Body.prototype.CreateFixture_Shape_Density.s_def=new box2d.b2FixtureDef;
+box2d.b2Body.prototype.DestroyFixture=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!this.m_world.IsLocked());if(!this.m_world.IsLocked()){box2d.ENABLE_ASSERTS&&box2d.b2Assert(a.m_body===this);box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<this.m_fixtureCount);for(var b=this.m_fixtureList,c=null,d=!1;null!==b;){if(b===a){c?c.m_next=a.m_next:this.m_fixtureList=a.m_next;d=!0;break}c=b;b=b.m_next}box2d.ENABLE_ASSERTS&&box2d.b2Assert(d);for(b=this.m_contactList;b;){var c=b.contact,b=b.next,d=c.GetFixtureA(),
+e=c.GetFixtureB();a!==d&&a!==e||this.m_world.m_contactManager.Destroy(c)}this.m_flag_activeFlag&&a.DestroyProxies(this.m_world.m_contactManager.m_broadPhase);a.Destroy();a.m_body=null;a.m_next=null;--this.m_fixtureCount;this.ResetMassData()}};goog.exportProperty(box2d.b2Body.prototype,"DestroyFixture",box2d.b2Body.prototype.DestroyFixture);
+box2d.b2Body.prototype.SetTransform=function(a,b,c){if(a instanceof box2d.b2Vec2&&"number"===typeof b)this.SetTransform_X_Y_A(a.x,a.y,b);else if(a instanceof box2d.b2Transform)this.SetTransform_X_Y_A(a.p.x,a.p.y,a.GetAngle());else if("number"===typeof a&&"number"===typeof b&&"number"===typeof c)this.SetTransform_X_Y_A(a,b,c);else throw Error();};goog.exportProperty(box2d.b2Body.prototype,"SetTransform",box2d.b2Body.prototype.SetTransform);
+box2d.b2Body.prototype.SetTransform_V2_A=function(a,b){this.SetTransform_X_Y_A(a.x,a.y,b)};goog.exportProperty(box2d.b2Body.prototype,"SetTransform_V2_A",box2d.b2Body.prototype.SetTransform_V2_A);
+box2d.b2Body.prototype.SetTransform_X_Y_A=function(a,b,c){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!this.m_world.IsLocked());if(!this.m_world.IsLocked()&&(this.m_xf.p.x!==a||this.m_xf.p.y!==b||this.m_xf.q.GetAngle()!==c))for(this.m_xf.q.SetAngle(c),this.m_xf.p.Set(a,b),this.m_xf0.Copy(this.m_xf),box2d.b2Mul_X_V2(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c),this.m_sweep.a=c,this.m_sweep.c0.Copy(this.m_sweep.c),this.m_sweep.a0=c,a=this.m_world.m_contactManager.m_broadPhase,b=this.m_fixtureList;b;b=
+b.m_next)b.Synchronize(a,this.m_xf,this.m_xf)};goog.exportProperty(box2d.b2Body.prototype,"SetTransform_X_Y_A",box2d.b2Body.prototype.SetTransform_X_Y_A);box2d.b2Body.prototype.SetTransform_X=function(a){this.SetTransform_X_Y_A(a.p.x,a.p.y,a.GetAngle())};goog.exportProperty(box2d.b2Body.prototype,"SetTransform_X",box2d.b2Body.prototype.SetTransform_X);box2d.b2Body.prototype.GetTransform=function(a){a=a||this.m_out_xf;return a.Copy(this.m_xf)};
+goog.exportProperty(box2d.b2Body.prototype,"GetTransform",box2d.b2Body.prototype.GetTransform);box2d.b2Body.prototype.GetPosition=function(a){a=a||this.m_out_xf.p;return a.Copy(this.m_xf.p)};goog.exportProperty(box2d.b2Body.prototype,"GetPosition",box2d.b2Body.prototype.GetPosition);box2d.b2Body.prototype.SetPosition=function(a){this.SetTransform_V2_A(a,this.GetAngle())};goog.exportProperty(box2d.b2Body.prototype,"SetPosition",box2d.b2Body.prototype.SetPosition);
+box2d.b2Body.prototype.SetPositionXY=function(a,b){this.SetTransform_X_Y_A(a,b,this.GetAngle())};goog.exportProperty(box2d.b2Body.prototype,"SetPositionXY",box2d.b2Body.prototype.SetPositionXY);box2d.b2Body.prototype.GetRotation=function(a){a=a||this.m_out_xf.q;return a.Copy(this.m_xf.q)};goog.exportProperty(box2d.b2Body.prototype,"GetRotation",box2d.b2Body.prototype.GetRotation);box2d.b2Body.prototype.SetRotation=function(a){this.SetTransform_V2_A(this.GetPosition(),a.GetAngle())};
+goog.exportProperty(box2d.b2Body.prototype,"SetRotation",box2d.b2Body.prototype.SetRotation);box2d.b2Body.prototype.GetAngle=function(){return this.m_sweep.a};goog.exportProperty(box2d.b2Body.prototype,"GetAngle",box2d.b2Body.prototype.GetAngle);box2d.b2Body.prototype.SetAngle=function(a){this.SetTransform_V2_A(this.GetPosition(),a)};goog.exportProperty(box2d.b2Body.prototype,"SetAngle",box2d.b2Body.prototype.SetAngle);box2d.b2Body.prototype.GetWorldCenter=function(a){a=a||this.m_out_sweep.c;return a.Copy(this.m_sweep.c)};
+goog.exportProperty(box2d.b2Body.prototype,"GetWorldCenter",box2d.b2Body.prototype.GetWorldCenter);box2d.b2Body.prototype.GetLocalCenter=function(a){a=a||this.m_out_sweep.localCenter;return a.Copy(this.m_sweep.localCenter)};goog.exportProperty(box2d.b2Body.prototype,"GetLocalCenter",box2d.b2Body.prototype.GetLocalCenter);box2d.b2Body.prototype.SetLinearVelocity=function(a){this.m_type!==box2d.b2BodyType.b2_staticBody&&(0<box2d.b2Dot_V2_V2(a,a)&&this.SetAwake(!0),this.m_linearVelocity.Copy(a))};
+goog.exportProperty(box2d.b2Body.prototype,"SetLinearVelocity",box2d.b2Body.prototype.SetLinearVelocity);box2d.b2Body.prototype.GetLinearVelocity=function(a){a=a||this.m_out_linearVelocity;return a.Copy(this.m_linearVelocity)};goog.exportProperty(box2d.b2Body.prototype,"GetLinearVelocity",box2d.b2Body.prototype.GetLinearVelocity);box2d.b2Body.prototype.SetAngularVelocity=function(a){this.m_type!==box2d.b2BodyType.b2_staticBody&&(0<a*a&&this.SetAwake(!0),this.m_angularVelocity=a)};
+goog.exportProperty(box2d.b2Body.prototype,"SetAngularVelocity",box2d.b2Body.prototype.SetAngularVelocity);box2d.b2Body.prototype.GetAngularVelocity=function(){return this.m_angularVelocity};goog.exportProperty(box2d.b2Body.prototype,"GetAngularVelocity",box2d.b2Body.prototype.GetAngularVelocity);
+box2d.b2Body.prototype.GetDefinition=function(a){a.type=this.GetType();a.allowSleep=this.m_flag_autoSleepFlag;a.angle=this.GetAngle();a.angularDamping=this.m_angularDamping;a.gravityScale=this.m_gravityScale;a.angularVelocity=this.m_angularVelocity;a.fixedRotation=this.m_flag_fixedRotationFlag;a.bullet=this.m_flag_bulletFlag;a.awake=this.m_flag_awakeFlag;a.linearDamping=this.m_linearDamping;a.linearVelocity.Copy(this.GetLinearVelocity());a.position.Copy(this.GetPosition());a.userData=this.GetUserData();
+return a};goog.exportProperty(box2d.b2Body.prototype,"GetDefinition",box2d.b2Body.prototype.GetDefinition);box2d.b2Body.prototype.ApplyForce=function(a,b,c){this.m_type===box2d.b2BodyType.b2_dynamicBody&&(!this.m_flag_awakeFlag&&this.SetAwake(!0),this.m_flag_awakeFlag&&(this.m_force.x+=a.x,this.m_force.y+=a.y,this.m_torque+=(b.x-this.m_sweep.c.x)*a.y-(b.y-this.m_sweep.c.y)*a.x))};goog.exportProperty(box2d.b2Body.prototype,"ApplyForce",box2d.b2Body.prototype.ApplyForce);
+box2d.b2Body.prototype.ApplyForceToCenter=function(a,b){this.m_type===box2d.b2BodyType.b2_dynamicBody&&(("boolean"===typeof b?b:1)&&!this.m_flag_awakeFlag&&this.SetAwake(!0),this.m_flag_awakeFlag&&(this.m_force.x+=a.x,this.m_force.y+=a.y))};goog.exportProperty(box2d.b2Body.prototype,"ApplyForceToCenter",box2d.b2Body.prototype.ApplyForceToCenter);
+box2d.b2Body.prototype.ApplyTorque=function(a,b){this.m_type===box2d.b2BodyType.b2_dynamicBody&&(("boolean"===typeof b?b:1)&&!this.m_flag_awakeFlag&&this.SetAwake(!0),this.m_flag_awakeFlag&&(this.m_torque+=a))};goog.exportProperty(box2d.b2Body.prototype,"ApplyTorque",box2d.b2Body.prototype.ApplyTorque);
+box2d.b2Body.prototype.ApplyLinearImpulse=function(a,b,c){this.m_type===box2d.b2BodyType.b2_dynamicBody&&(("boolean"===typeof c?c:1)&&!this.m_flag_awakeFlag&&this.SetAwake(!0),this.m_flag_awakeFlag&&(this.m_linearVelocity.x+=this.m_invMass*a.x,this.m_linearVelocity.y+=this.m_invMass*a.y,this.m_angularVelocity+=this.m_invI*((b.x-this.m_sweep.c.x)*a.y-(b.y-this.m_sweep.c.y)*a.x)))};goog.exportProperty(box2d.b2Body.prototype,"ApplyLinearImpulse",box2d.b2Body.prototype.ApplyLinearImpulse);
+box2d.b2Body.prototype.ApplyLinearImpulseToCenter=function(a,b){this.m_type===box2d.b2BodyType.b2_dynamicBody&&(("boolean"===typeof b?b:1)&&!this.m_flag_awakeFlag&&this.SetAwake(!0),this.m_flag_awakeFlag&&(this.m_linearVelocity.x+=this.m_invMass*a.x,this.m_linearVelocity.y+=this.m_invMass*a.y))};goog.exportProperty(box2d.b2Body.prototype,"ApplyLinearImpulseToCenter",box2d.b2Body.prototype.ApplyLinearImpulseToCenter);
+box2d.b2Body.prototype.ApplyAngularImpulse=function(a,b){this.m_type===box2d.b2BodyType.b2_dynamicBody&&(("boolean"===typeof b?b:1)&&!this.m_flag_awakeFlag&&this.SetAwake(!0),this.m_flag_awakeFlag&&(this.m_angularVelocity+=this.m_invI*a))};goog.exportProperty(box2d.b2Body.prototype,"ApplyAngularImpulse",box2d.b2Body.prototype.ApplyAngularImpulse);box2d.b2Body.prototype.GetMass=function(){return this.m_mass};goog.exportProperty(box2d.b2Body.prototype,"GetMass",box2d.b2Body.prototype.GetMass);
+box2d.b2Body.prototype.GetInertia=function(){return this.m_I+this.m_mass*box2d.b2Dot_V2_V2(this.m_sweep.localCenter,this.m_sweep.localCenter)};goog.exportProperty(box2d.b2Body.prototype,"GetInertia",box2d.b2Body.prototype.GetInertia);box2d.b2Body.prototype.GetMassData=function(a){a.mass=this.m_mass;a.I=this.m_I+this.m_mass*box2d.b2Dot_V2_V2(this.m_sweep.localCenter,this.m_sweep.localCenter);a.center.Copy(this.m_sweep.localCenter);return a};
+goog.exportProperty(box2d.b2Body.prototype,"GetMassData",box2d.b2Body.prototype.GetMassData);
+box2d.b2Body.prototype.SetMassData=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!this.m_world.IsLocked());if(!this.m_world.IsLocked()&&this.m_type===box2d.b2BodyType.b2_dynamicBody){this.m_invI=this.m_I=this.m_invMass=0;this.m_mass=a.mass;0>=this.m_mass&&(this.m_mass=1);this.m_invMass=1/this.m_mass;0<a.I&&!this.m_flag_fixedRotationFlag&&(this.m_I=a.I-this.m_mass*box2d.b2Dot_V2_V2(a.center,a.center),box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<this.m_I),this.m_invI=1/this.m_I);var b=box2d.b2Body.prototype.SetMassData.s_oldCenter.Copy(this.m_sweep.c);
+this.m_sweep.localCenter.Copy(a.center);box2d.b2Mul_X_V2(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c);this.m_sweep.c0.Copy(this.m_sweep.c);box2d.b2AddCross_V2_S_V2(this.m_linearVelocity,this.m_angularVelocity,box2d.b2Sub_V2_V2(this.m_sweep.c,b,box2d.b2Vec2.s_t0),this.m_linearVelocity)}};goog.exportProperty(box2d.b2Body.prototype,"SetMassData",box2d.b2Body.prototype.SetMassData);box2d.b2Body.prototype.SetMassData.s_oldCenter=new box2d.b2Vec2;
+box2d.b2Body.prototype.ResetMassData=function(){this.m_invI=this.m_I=this.m_invMass=this.m_mass=0;this.m_sweep.localCenter.SetZero();if(this.m_type===box2d.b2BodyType.b2_staticBody||this.m_type===box2d.b2BodyType.b2_kinematicBody)this.m_sweep.c0.Copy(this.m_xf.p),this.m_sweep.c.Copy(this.m_xf.p),this.m_sweep.a0=this.m_sweep.a;else{box2d.ENABLE_ASSERTS&&box2d.b2Assert(this.m_type===box2d.b2BodyType.b2_dynamicBody);for(var a=box2d.b2Body.prototype.ResetMassData.s_localCenter.SetZero(),b=this.m_fixtureList;b;b=
+b.m_next)if(0!==b.m_density){var c=b.GetMassData(box2d.b2Body.prototype.ResetMassData.s_massData);this.m_mass+=c.mass;a.x+=c.center.x*c.mass;a.y+=c.center.y*c.mass;this.m_I+=c.I}0<this.m_mass?(this.m_invMass=1/this.m_mass,a.x*=this.m_invMass,a.y*=this.m_invMass):this.m_invMass=this.m_mass=1;0<this.m_I&&!this.m_flag_fixedRotationFlag?(this.m_I-=this.m_mass*box2d.b2Dot_V2_V2(a,a),box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<this.m_I),this.m_invI=1/this.m_I):this.m_invI=this.m_I=0;b=box2d.b2Body.prototype.ResetMassData.s_oldCenter.Copy(this.m_sweep.c);
+this.m_sweep.localCenter.Copy(a);box2d.b2Mul_X_V2(this.m_xf,this.m_sweep.localCenter,this.m_sweep.c);this.m_sweep.c0.Copy(this.m_sweep.c);box2d.b2AddCross_V2_S_V2(this.m_linearVelocity,this.m_angularVelocity,box2d.b2Sub_V2_V2(this.m_sweep.c,b,box2d.b2Vec2.s_t0),this.m_linearVelocity)}};goog.exportProperty(box2d.b2Body.prototype,"ResetMassData",box2d.b2Body.prototype.ResetMassData);box2d.b2Body.prototype.ResetMassData.s_localCenter=new box2d.b2Vec2;
+box2d.b2Body.prototype.ResetMassData.s_oldCenter=new box2d.b2Vec2;box2d.b2Body.prototype.ResetMassData.s_massData=new box2d.b2MassData;box2d.b2Body.prototype.GetWorldPoint=function(a,b){return box2d.b2Mul_X_V2(this.m_xf,a,b)};goog.exportProperty(box2d.b2Body.prototype,"GetWorldPoint",box2d.b2Body.prototype.GetWorldPoint);box2d.b2Body.prototype.GetWorldVector=function(a,b){return box2d.b2Mul_R_V2(this.m_xf.q,a,b)};goog.exportProperty(box2d.b2Body.prototype,"GetWorldVector",box2d.b2Body.prototype.GetWorldVector);
+box2d.b2Body.prototype.GetLocalPoint=function(a,b){return box2d.b2MulT_X_V2(this.m_xf,a,b)};goog.exportProperty(box2d.b2Body.prototype,"GetLocalPoint",box2d.b2Body.prototype.GetLocalPoint);box2d.b2Body.prototype.GetLocalVector=function(a,b){return box2d.b2MulT_R_V2(this.m_xf.q,a,b)};goog.exportProperty(box2d.b2Body.prototype,"GetLocalVector",box2d.b2Body.prototype.GetLocalVector);
+box2d.b2Body.prototype.GetLinearVelocityFromWorldPoint=function(a,b){return box2d.b2AddCross_V2_S_V2(this.m_linearVelocity,this.m_angularVelocity,box2d.b2Sub_V2_V2(a,this.m_sweep.c,box2d.b2Vec2.s_t0),b)};goog.exportProperty(box2d.b2Body.prototype,"GetLinearVelocityFromWorldPoint",box2d.b2Body.prototype.GetLinearVelocityFromWorldPoint);box2d.b2Body.prototype.GetLinearVelocityFromLocalPoint=function(a,b){return this.GetLinearVelocityFromWorldPoint(this.GetWorldPoint(a,b),b)};
+goog.exportProperty(box2d.b2Body.prototype,"GetLinearVelocityFromLocalPoint",box2d.b2Body.prototype.GetLinearVelocityFromLocalPoint);box2d.b2Body.prototype.GetLinearDamping=function(){return this.m_linearDamping};goog.exportProperty(box2d.b2Body.prototype,"GetLinearDamping",box2d.b2Body.prototype.GetLinearDamping);box2d.b2Body.prototype.SetLinearDamping=function(a){this.m_linearDamping=a};goog.exportProperty(box2d.b2Body.prototype,"SetLinearDamping",box2d.b2Body.prototype.SetLinearDamping);
+box2d.b2Body.prototype.GetAngularDamping=function(){return this.m_angularDamping};goog.exportProperty(box2d.b2Body.prototype,"GetAngularDamping",box2d.b2Body.prototype.GetAngularDamping);box2d.b2Body.prototype.SetAngularDamping=function(a){this.m_angularDamping=a};goog.exportProperty(box2d.b2Body.prototype,"SetAngularDamping",box2d.b2Body.prototype.SetAngularDamping);box2d.b2Body.prototype.GetGravityScale=function(){return this.m_gravityScale};
+goog.exportProperty(box2d.b2Body.prototype,"GetGravityScale",box2d.b2Body.prototype.GetGravityScale);box2d.b2Body.prototype.SetGravityScale=function(a){this.m_gravityScale=a};goog.exportProperty(box2d.b2Body.prototype,"SetGravityScale",box2d.b2Body.prototype.SetGravityScale);
+box2d.b2Body.prototype.SetType=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!this.m_world.IsLocked());if(!this.m_world.IsLocked()&&this.m_type!==a){this.m_type=a;this.ResetMassData();this.m_type===box2d.b2BodyType.b2_staticBody&&(this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_sweep.a0=this.m_sweep.a,this.m_sweep.c0.Copy(this.m_sweep.c),this.SynchronizeFixtures());this.SetAwake(!0);this.m_force.SetZero();this.m_torque=0;for(a=this.m_contactList;a;){var b=a;a=a.next;this.m_world.m_contactManager.Destroy(b.contact)}this.m_contactList=
+null;a=this.m_world.m_contactManager.m_broadPhase;for(b=this.m_fixtureList;b;b=b.m_next)for(var c=b.m_proxyCount,d=0;d<c;++d)a.TouchProxy(b.m_proxies[d].proxy)}};goog.exportProperty(box2d.b2Body.prototype,"SetType",box2d.b2Body.prototype.SetType);box2d.b2Body.prototype.GetType=function(){return this.m_type};goog.exportProperty(box2d.b2Body.prototype,"GetType",box2d.b2Body.prototype.GetType);box2d.b2Body.prototype.SetBullet=function(a){this.m_flag_bulletFlag=a};
+goog.exportProperty(box2d.b2Body.prototype,"SetBullet",box2d.b2Body.prototype.SetBullet);box2d.b2Body.prototype.IsBullet=function(){return this.m_flag_bulletFlag};goog.exportProperty(box2d.b2Body.prototype,"IsBullet",box2d.b2Body.prototype.IsBullet);box2d.b2Body.prototype.SetSleepingAllowed=function(a){a?this.m_flag_autoSleepFlag=!0:(this.m_flag_autoSleepFlag=!1,this.SetAwake(!0))};goog.exportProperty(box2d.b2Body.prototype,"SetSleepingAllowed",box2d.b2Body.prototype.SetSleepingAllowed);
+box2d.b2Body.prototype.IsSleepingAllowed=function(){return this.m_flag_autoSleepFlag};goog.exportProperty(box2d.b2Body.prototype,"IsSleepingAllowed",box2d.b2Body.prototype.IsSleepingAllowed);box2d.b2Body.prototype.SetAwake=function(a){a?this.m_flag_awakeFlag||(this.m_flag_awakeFlag=!0,this.m_sleepTime=0):(this.m_flag_awakeFlag=!1,this.m_sleepTime=0,this.m_linearVelocity.SetZero(),this.m_angularVelocity=0,this.m_force.SetZero(),this.m_torque=0)};
+goog.exportProperty(box2d.b2Body.prototype,"SetAwake",box2d.b2Body.prototype.SetAwake);box2d.b2Body.prototype.IsAwake=function(){return this.m_flag_awakeFlag};goog.exportProperty(box2d.b2Body.prototype,"IsAwake",box2d.b2Body.prototype.IsAwake);
+box2d.b2Body.prototype.SetActive=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!this.m_world.IsLocked());if(a!==this.IsActive())if(a){this.m_flag_activeFlag=!0;a=this.m_world.m_contactManager.m_broadPhase;for(var b=this.m_fixtureList;b;b=b.m_next)b.CreateProxies(a,this.m_xf)}else{this.m_flag_activeFlag=!1;a=this.m_world.m_contactManager.m_broadPhase;for(b=this.m_fixtureList;b;b=b.m_next)b.DestroyProxies(a);for(a=this.m_contactList;a;)b=a,a=a.next,this.m_world.m_contactManager.Destroy(b.contact);
+this.m_contactList=null}};goog.exportProperty(box2d.b2Body.prototype,"SetActive",box2d.b2Body.prototype.SetActive);box2d.b2Body.prototype.IsActive=function(){return this.m_flag_activeFlag};goog.exportProperty(box2d.b2Body.prototype,"IsActive",box2d.b2Body.prototype.IsActive);box2d.b2Body.prototype.SetFixedRotation=function(a){this.m_flag_fixedRotationFlag!==a&&(this.m_flag_fixedRotationFlag=a,this.m_angularVelocity=0,this.ResetMassData())};
+goog.exportProperty(box2d.b2Body.prototype,"SetFixedRotation",box2d.b2Body.prototype.SetFixedRotation);box2d.b2Body.prototype.IsFixedRotation=function(){return this.m_flag_fixedRotationFlag};goog.exportProperty(box2d.b2Body.prototype,"IsFixedRotation",box2d.b2Body.prototype.IsFixedRotation);box2d.b2Body.prototype.GetFixtureList=function(){return this.m_fixtureList};goog.exportProperty(box2d.b2Body.prototype,"GetFixtureList",box2d.b2Body.prototype.GetFixtureList);
+box2d.b2Body.prototype.GetJointList=function(){return this.m_jointList};goog.exportProperty(box2d.b2Body.prototype,"GetJointList",box2d.b2Body.prototype.GetJointList);box2d.b2Body.prototype.GetContactList=function(){return this.m_contactList};goog.exportProperty(box2d.b2Body.prototype,"GetContactList",box2d.b2Body.prototype.GetContactList);box2d.b2Body.prototype.GetNext=function(){return this.m_next};goog.exportProperty(box2d.b2Body.prototype,"GetNext",box2d.b2Body.prototype.GetNext);
+box2d.b2Body.prototype.GetUserData=function(){return this.m_userData};goog.exportProperty(box2d.b2Body.prototype,"GetUserData",box2d.b2Body.prototype.GetUserData);box2d.b2Body.prototype.SetUserData=function(a){this.m_userData=a};goog.exportProperty(box2d.b2Body.prototype,"SetUserData",box2d.b2Body.prototype.SetUserData);box2d.b2Body.prototype.GetWorld=function(){return this.m_world};goog.exportProperty(box2d.b2Body.prototype,"GetWorld",box2d.b2Body.prototype.GetWorld);
+box2d.b2Body.prototype.SynchronizeFixtures=function(){var a=box2d.b2Body.prototype.SynchronizeFixtures.s_xf1;a.q.SetAngle(this.m_sweep.a0);box2d.b2Mul_R_V2(a.q,this.m_sweep.localCenter,a.p);box2d.b2Sub_V2_V2(this.m_sweep.c0,a.p,a.p);for(var b=this.m_world.m_contactManager.m_broadPhase,c=this.m_fixtureList;c;c=c.m_next)c.Synchronize(b,a,this.m_xf)};goog.exportProperty(box2d.b2Body.prototype,"SynchronizeFixtures",box2d.b2Body.prototype.SynchronizeFixtures);
+box2d.b2Body.prototype.SynchronizeFixtures.s_xf1=new box2d.b2Transform;box2d.b2Body.prototype.SynchronizeTransform=function(){this.m_xf.q.SetAngle(this.m_sweep.a);box2d.b2Mul_R_V2(this.m_xf.q,this.m_sweep.localCenter,this.m_xf.p);box2d.b2Sub_V2_V2(this.m_sweep.c,this.m_xf.p,this.m_xf.p)};goog.exportProperty(box2d.b2Body.prototype,"SynchronizeTransform",box2d.b2Body.prototype.SynchronizeTransform);
+box2d.b2Body.prototype.ShouldCollide=function(a){return this.m_type===box2d.b2BodyType.b2_staticBody&&a.m_type===box2d.b2BodyType.b2_staticBody?!1:this.ShouldCollideConnected(a)};goog.exportProperty(box2d.b2Body.prototype,"ShouldCollide",box2d.b2Body.prototype.ShouldCollide);box2d.b2Body.prototype.ShouldCollideConnected=function(a){for(var b=this.m_jointList;b;b=b.next)if(b.other===a&&!b.joint.m_collideConnected)return!1;return!0};
+goog.exportProperty(box2d.b2Body.prototype,"ShouldCollideConnected",box2d.b2Body.prototype.ShouldCollideConnected);box2d.b2Body.prototype.Advance=function(a){this.m_sweep.Advance(a);this.m_sweep.c.Copy(this.m_sweep.c0);this.m_sweep.a=this.m_sweep.a0;this.m_xf.q.SetAngle(this.m_sweep.a);box2d.b2Mul_R_V2(this.m_xf.q,this.m_sweep.localCenter,this.m_xf.p);box2d.b2Sub_V2_V2(this.m_sweep.c,this.m_xf.p,this.m_xf.p)};goog.exportProperty(box2d.b2Body.prototype,"Advance",box2d.b2Body.prototype.Advance);
+box2d.b2Body.prototype.Dump=function(){if(box2d.DEBUG){var a=this.m_islandIndex;box2d.b2Log("{\n");box2d.b2Log("  /*box2d.b2BodyDef*/ var bd = new box2d.b2BodyDef();\n");var b="";switch(this.m_type){case box2d.b2BodyType.b2_staticBody:b="box2d.b2BodyType.b2_staticBody";break;case box2d.b2BodyType.b2_kinematicBody:b="box2d.b2BodyType.b2_kinematicBody";break;case box2d.b2BodyType.b2_dynamicBody:b="box2d.b2BodyType.b2_dynamicBody";break;default:box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1)}box2d.b2Log("  bd.type = %s;\n",
+b);box2d.b2Log("  bd.position.Set(%.15f, %.15f);\n",this.m_xf.p.x,this.m_xf.p.y);box2d.b2Log("  bd.angle = %.15f;\n",this.m_sweep.a);box2d.b2Log("  bd.linearVelocity.Set(%.15f, %.15f);\n",this.m_linearVelocity.x,this.m_linearVelocity.y);box2d.b2Log("  bd.angularVelocity = %.15f;\n",this.m_angularVelocity);box2d.b2Log("  bd.linearDamping = %.15f;\n",this.m_linearDamping);box2d.b2Log("  bd.angularDamping = %.15f;\n",this.m_angularDamping);box2d.b2Log("  bd.allowSleep = %s;\n",this.m_flag_autoSleepFlag?
+"true":"false");box2d.b2Log("  bd.awake = %s;\n",this.m_flag_awakeFlag?"true":"false");box2d.b2Log("  bd.fixedRotation = %s;\n",this.m_flag_fixedRotationFlag?"true":"false");box2d.b2Log("  bd.bullet = %s;\n",this.m_flag_bulletFlag?"true":"false");box2d.b2Log("  bd.active = %s;\n",this.m_flag_activeFlag?"true":"false");box2d.b2Log("  bd.gravityScale = %.15f;\n",this.m_gravityScale);box2d.b2Log("\n");box2d.b2Log("  bodies[%d] = this.m_world.CreateBody(bd);\n",this.m_islandIndex);box2d.b2Log("\n");for(b=
+this.m_fixtureList;b;b=b.m_next)box2d.b2Log("  {\n"),b.Dump(a),box2d.b2Log("  }\n");box2d.b2Log("}\n")}};goog.exportProperty(box2d.b2Body.prototype,"Dump",box2d.b2Body.prototype.Dump);box2d.b2Body.prototype.GetControllerList=function(){return this.m_controllerList};goog.exportProperty(box2d.b2Body.prototype,"GetControllerList",box2d.b2Body.prototype.GetControllerList);box2d.b2Body.prototype.GetControllerCount=function(){return this.m_controllerCount};
+goog.exportProperty(box2d.b2Body.prototype,"GetControllerCount",box2d.b2Body.prototype.GetControllerCount);box2d.b2Profile=function(){};goog.exportSymbol("box2d.b2Profile",box2d.b2Profile);box2d.b2Profile.prototype.step=0;goog.exportProperty(box2d.b2Profile.prototype,"step",box2d.b2Profile.prototype.step);box2d.b2Profile.prototype.collide=0;goog.exportProperty(box2d.b2Profile.prototype,"collide",box2d.b2Profile.prototype.collide);box2d.b2Profile.prototype.solve=0;goog.exportProperty(box2d.b2Profile.prototype,"solve",box2d.b2Profile.prototype.solve);box2d.b2Profile.prototype.solveInit=0;
+goog.exportProperty(box2d.b2Profile.prototype,"solveInit",box2d.b2Profile.prototype.solveInit);box2d.b2Profile.prototype.solveVelocity=0;goog.exportProperty(box2d.b2Profile.prototype,"solveVelocity",box2d.b2Profile.prototype.solveVelocity);box2d.b2Profile.prototype.solvePosition=0;goog.exportProperty(box2d.b2Profile.prototype,"solvePosition",box2d.b2Profile.prototype.solvePosition);box2d.b2Profile.prototype.broadphase=0;goog.exportProperty(box2d.b2Profile.prototype,"broadphase",box2d.b2Profile.prototype.broadphase);
+box2d.b2Profile.prototype.solveTOI=0;goog.exportProperty(box2d.b2Profile.prototype,"solveTOI",box2d.b2Profile.prototype.solveTOI);box2d.b2Profile.prototype.Reset=function(){this.solveTOI=this.broadphase=this.solvePosition=this.solveVelocity=this.solveInit=this.solve=this.collide=this.step=0;return this};goog.exportProperty(box2d.b2Profile.prototype,"Reset",box2d.b2Profile.prototype.Reset);box2d.b2TimeStep=function(){};goog.exportSymbol("box2d.b2TimeStep",box2d.b2TimeStep);
+box2d.b2TimeStep.prototype.dt=0;goog.exportProperty(box2d.b2TimeStep.prototype,"dt",box2d.b2TimeStep.prototype.dt);box2d.b2TimeStep.prototype.inv_dt=0;goog.exportProperty(box2d.b2TimeStep.prototype,"inv_dt",box2d.b2TimeStep.prototype.inv_dt);box2d.b2TimeStep.prototype.dtRatio=0;goog.exportProperty(box2d.b2TimeStep.prototype,"dtRatio",box2d.b2TimeStep.prototype.dtRatio);box2d.b2TimeStep.prototype.velocityIterations=0;goog.exportProperty(box2d.b2TimeStep.prototype,"velocityIterations",box2d.b2TimeStep.prototype.velocityIterations);
+box2d.b2TimeStep.prototype.positionIterations=0;goog.exportProperty(box2d.b2TimeStep.prototype,"positionIterations",box2d.b2TimeStep.prototype.positionIterations);box2d.b2TimeStep.prototype.particleIterations=0;goog.exportProperty(box2d.b2TimeStep.prototype,"particleIterations",box2d.b2TimeStep.prototype.particleIterations);box2d.b2TimeStep.prototype.warmStarting=!1;goog.exportProperty(box2d.b2TimeStep.prototype,"warmStarting",box2d.b2TimeStep.prototype.warmStarting);
+box2d.b2TimeStep.prototype.Copy=function(a){this.dt=a.dt;this.inv_dt=a.inv_dt;this.dtRatio=a.dtRatio;this.positionIterations=a.positionIterations;this.velocityIterations=a.velocityIterations;this.particleIterations=a.particleIterations;this.warmStarting=a.warmStarting;return this};goog.exportProperty(box2d.b2TimeStep.prototype,"Copy",box2d.b2TimeStep.prototype.Copy);box2d.b2Position=function(){this.c=new box2d.b2Vec2};goog.exportSymbol("box2d.b2Position",box2d.b2Position);
+box2d.b2Position.prototype.c=null;goog.exportProperty(box2d.b2Position.prototype,"c",box2d.b2Position.prototype.c);box2d.b2Position.prototype.a=0;goog.exportProperty(box2d.b2Position.prototype,"a",box2d.b2Position.prototype.a);box2d.b2Position.MakeArray=function(a){return box2d.b2MakeArray(a,function(a){return new box2d.b2Position})};goog.exportProperty(box2d.b2Position,"MakeArray",box2d.b2Position.MakeArray);box2d.b2Velocity=function(){this.v=new box2d.b2Vec2};
+goog.exportSymbol("box2d.b2Velocity",box2d.b2Velocity);box2d.b2Velocity.prototype.v=null;goog.exportProperty(box2d.b2Velocity.prototype,"v",box2d.b2Velocity.prototype.v);box2d.b2Velocity.prototype.w=0;goog.exportProperty(box2d.b2Velocity.prototype,"w",box2d.b2Velocity.prototype.w);box2d.b2Velocity.MakeArray=function(a){return box2d.b2MakeArray(a,function(a){return new box2d.b2Velocity})};goog.exportProperty(box2d.b2Velocity,"MakeArray",box2d.b2Velocity.MakeArray);
+box2d.b2SolverData=function(){this.step=new box2d.b2TimeStep};goog.exportSymbol("box2d.b2SolverData",box2d.b2SolverData);box2d.b2SolverData.prototype.step=null;goog.exportProperty(box2d.b2SolverData.prototype,"step",box2d.b2SolverData.prototype.step);box2d.b2SolverData.prototype.positions=null;goog.exportProperty(box2d.b2SolverData.prototype,"positions",box2d.b2SolverData.prototype.positions);box2d.b2SolverData.prototype.velocities=null;
+goog.exportProperty(box2d.b2SolverData.prototype,"velocities",box2d.b2SolverData.prototype.velocities);box2d.b2WorldCallbacks={};box2d.b2DestructionListener=function(){};goog.exportSymbol("box2d.b2DestructionListener",box2d.b2DestructionListener);box2d.b2DestructionListener.prototype.SayGoodbyeJoint=function(a){};goog.exportProperty(box2d.b2DestructionListener.prototype,"SayGoodbyeJoint",box2d.b2DestructionListener.prototype.SayGoodbyeJoint);box2d.b2DestructionListener.prototype.SayGoodbyeFixture=function(a){};goog.exportProperty(box2d.b2DestructionListener.prototype,"SayGoodbyeFixture",box2d.b2DestructionListener.prototype.SayGoodbyeFixture);
+box2d.b2DestructionListener.prototype.SayGoodbyeParticleGroup=function(a){};box2d.b2DestructionListener.prototype.SayGoodbyeParticle=function(a,b){};box2d.b2ContactFilter=function(){};goog.exportSymbol("box2d.b2ContactFilter",box2d.b2ContactFilter);
+box2d.b2ContactFilter.prototype.ShouldCollide=function(a,b){var c=a.GetBody(),d=b.GetBody();if(d.GetType()===box2d.b2BodyType.b2_staticBody&&c.GetType()===box2d.b2BodyType.b2_staticBody||!1===d.ShouldCollideConnected(c))return!1;c=a.GetFilterData();d=b.GetFilterData();return c.groupIndex===d.groupIndex&&0!==c.groupIndex?0<c.groupIndex:0!==(c.maskBits&d.categoryBits)&&0!==(c.categoryBits&d.maskBits)};goog.exportProperty(box2d.b2ContactFilter.prototype,"ShouldCollide",box2d.b2ContactFilter.prototype.ShouldCollide);
+box2d.b2ContactFilter.prototype.ShouldCollideFixtureParticle=function(a,b,c){return!0};goog.exportProperty(box2d.b2ContactFilter.prototype,"ShouldCollideFixtureParticle",box2d.b2ContactFilter.prototype.ShouldCollideFixtureParticle);box2d.b2ContactFilter.prototype.ShouldCollideParticleParticle=function(a,b,c){return!0};goog.exportProperty(box2d.b2ContactFilter.prototype,"ShouldCollideParticleParticle",box2d.b2ContactFilter.prototype.ShouldCollideParticleParticle);
+box2d.b2ContactFilter.b2_defaultFilter=new box2d.b2ContactFilter;box2d.b2ContactImpulse=function(){this.normalImpulses=box2d.b2MakeNumberArray(box2d.b2_maxManifoldPoints);this.tangentImpulses=box2d.b2MakeNumberArray(box2d.b2_maxManifoldPoints)};goog.exportSymbol("box2d.b2ContactImpulse",box2d.b2ContactImpulse);box2d.b2ContactImpulse.prototype.normalImpulses=null;goog.exportProperty(box2d.b2ContactImpulse.prototype,"normalImpulses",box2d.b2ContactImpulse.prototype.normalImpulses);
+box2d.b2ContactImpulse.prototype.tangentImpulses=null;goog.exportProperty(box2d.b2ContactImpulse.prototype,"tangentImpulses",box2d.b2ContactImpulse.prototype.tangentImpulses);box2d.b2ContactImpulse.prototype.count=0;goog.exportProperty(box2d.b2ContactImpulse.prototype,"count",box2d.b2ContactImpulse.prototype.count);box2d.b2ContactListener=function(){};goog.exportSymbol("box2d.b2ContactListener",box2d.b2ContactListener);box2d.b2ContactListener.prototype.BeginContact=function(a){};
+goog.exportProperty(box2d.b2ContactListener.prototype,"BeginContact",box2d.b2ContactListener.prototype.BeginContact);box2d.b2ContactListener.prototype.EndContact=function(a){};goog.exportProperty(box2d.b2ContactListener.prototype,"EndContact",box2d.b2ContactListener.prototype.EndContact);box2d.b2ContactListener.prototype.BeginContactFixtureParticle=function(a,b){};goog.exportProperty(box2d.b2ContactListener.prototype,"BeginContactFixtureParticle",box2d.b2ContactListener.prototype.BeginContactFixtureParticle);
+box2d.b2ContactListener.prototype.EndContactFixtureParticle=function(a,b,c){};goog.exportProperty(box2d.b2ContactListener.prototype,"EndContactFixtureParticle",box2d.b2ContactListener.prototype.EndContactFixtureParticle);box2d.b2ContactListener.prototype.BeginContactParticleParticle=function(a,b){};goog.exportProperty(box2d.b2ContactListener.prototype,"BeginContactParticleParticle",box2d.b2ContactListener.prototype.BeginContactParticleParticle);
+box2d.b2ContactListener.prototype.EndContactParticleParticle=function(a,b,c){};goog.exportProperty(box2d.b2ContactListener.prototype,"EndContactParticleParticle",box2d.b2ContactListener.prototype.EndContactParticleParticle);box2d.b2ContactListener.prototype.PreSolve=function(a,b){};goog.exportProperty(box2d.b2ContactListener.prototype,"PreSolve",box2d.b2ContactListener.prototype.PreSolve);box2d.b2ContactListener.prototype.PostSolve=function(a,b){};
+goog.exportProperty(box2d.b2ContactListener.prototype,"PostSolve",box2d.b2ContactListener.prototype.PostSolve);box2d.b2ContactListener.b2_defaultListener=new box2d.b2ContactListener;goog.exportProperty(box2d.b2ContactListener,"b2_defaultListener",box2d.b2ContactListener.b2_defaultListener);box2d.b2QueryCallback=function(){};goog.exportSymbol("box2d.b2QueryCallback",box2d.b2QueryCallback);box2d.b2QueryCallback.prototype.ReportFixture=function(a){return!0};
+goog.exportProperty(box2d.b2QueryCallback.prototype,"ReportFixture",box2d.b2QueryCallback.prototype.ReportFixture);box2d.b2QueryCallback.prototype.ReportParticle=function(a,b){return!1};goog.exportProperty(box2d.b2QueryCallback.prototype,"ReportParticle",box2d.b2QueryCallback.prototype.ReportParticle);box2d.b2QueryCallback.prototype.ShouldQueryParticleSystem=function(a){return!0};goog.exportProperty(box2d.b2QueryCallback.prototype,"ShouldQueryParticleSystem",box2d.b2QueryCallback.prototype.ShouldQueryParticleSystem);
+box2d.b2RayCastCallback=function(){};goog.exportSymbol("box2d.b2RayCastCallback",box2d.b2RayCastCallback);box2d.b2RayCastCallback.prototype.ReportFixture=function(a,b,c,d){return d};goog.exportProperty(box2d.b2RayCastCallback.prototype,"ReportFixture",box2d.b2RayCastCallback.prototype.ReportFixture);box2d.b2RayCastCallback.prototype.ReportParticle=function(a,b,c,d,e){return 0};goog.exportProperty(box2d.b2RayCastCallback.prototype,"ReportParticle",box2d.b2RayCastCallback.prototype.ReportParticle);
+box2d.b2RayCastCallback.prototype.ShouldQueryParticleSystem=function(a){return!0};goog.exportProperty(box2d.b2RayCastCallback.prototype,"ShouldQueryParticleSystem",box2d.b2RayCastCallback.prototype.ShouldQueryParticleSystem);box2d.b2MixFriction=function(a,b){return box2d.b2Sqrt(a*b)};goog.exportSymbol("box2d.b2MixFriction",box2d.b2MixFriction);box2d.b2MixRestitution=function(a,b){return a>b?a:b};goog.exportSymbol("box2d.b2MixRestitution",box2d.b2MixRestitution);box2d.b2ContactEdge=function(){};goog.exportSymbol("box2d.b2ContactEdge",box2d.b2ContactEdge);box2d.b2ContactEdge.prototype.other=null;goog.exportProperty(box2d.b2ContactEdge.prototype,"other",box2d.b2ContactEdge.prototype.other);
+box2d.b2ContactEdge.prototype.contact=null;goog.exportProperty(box2d.b2ContactEdge.prototype,"contact",box2d.b2ContactEdge.prototype.contact);box2d.b2ContactEdge.prototype.prev=null;goog.exportProperty(box2d.b2ContactEdge.prototype,"prev",box2d.b2ContactEdge.prototype.prev);box2d.b2ContactEdge.prototype.next=null;goog.exportProperty(box2d.b2ContactEdge.prototype,"next",box2d.b2ContactEdge.prototype.next);
+box2d.b2Contact=function(){this.m_nodeA=new box2d.b2ContactEdge;this.m_nodeB=new box2d.b2ContactEdge;this.m_manifold=new box2d.b2Manifold;this.m_oldManifold=new box2d.b2Manifold};goog.exportSymbol("box2d.b2Contact",box2d.b2Contact);box2d.b2Contact.prototype.m_flag_islandFlag=!1;goog.exportProperty(box2d.b2Contact.prototype,"m_flag_islandFlag",box2d.b2Contact.prototype.m_flag_islandFlag);box2d.b2Contact.prototype.m_flag_touchingFlag=!1;
+goog.exportProperty(box2d.b2Contact.prototype,"m_flag_touchingFlag",box2d.b2Contact.prototype.m_flag_touchingFlag);box2d.b2Contact.prototype.m_flag_enabledFlag=!1;goog.exportProperty(box2d.b2Contact.prototype,"m_flag_enabledFlag",box2d.b2Contact.prototype.m_flag_enabledFlag);box2d.b2Contact.prototype.m_flag_filterFlag=!1;goog.exportProperty(box2d.b2Contact.prototype,"m_flag_filterFlag",box2d.b2Contact.prototype.m_flag_filterFlag);box2d.b2Contact.prototype.m_flag_bulletHitFlag=!1;
+goog.exportProperty(box2d.b2Contact.prototype,"m_flag_bulletHitFlag",box2d.b2Contact.prototype.m_flag_bulletHitFlag);box2d.b2Contact.prototype.m_flag_toiFlag=!1;goog.exportProperty(box2d.b2Contact.prototype,"m_flag_toiFlag",box2d.b2Contact.prototype.m_flag_toiFlag);box2d.b2Contact.prototype.m_prev=null;goog.exportProperty(box2d.b2Contact.prototype,"m_prev",box2d.b2Contact.prototype.m_prev);box2d.b2Contact.prototype.m_next=null;goog.exportProperty(box2d.b2Contact.prototype,"m_next",box2d.b2Contact.prototype.m_next);
+box2d.b2Contact.prototype.m_nodeA=null;goog.exportProperty(box2d.b2Contact.prototype,"m_nodeA",box2d.b2Contact.prototype.m_nodeA);box2d.b2Contact.prototype.m_nodeB=null;goog.exportProperty(box2d.b2Contact.prototype,"m_nodeB",box2d.b2Contact.prototype.m_nodeB);box2d.b2Contact.prototype.m_fixtureA=null;goog.exportProperty(box2d.b2Contact.prototype,"m_fixtureA",box2d.b2Contact.prototype.m_fixtureA);box2d.b2Contact.prototype.m_fixtureB=null;goog.exportProperty(box2d.b2Contact.prototype,"m_fixtureB",box2d.b2Contact.prototype.m_fixtureB);
+box2d.b2Contact.prototype.m_indexA=0;goog.exportProperty(box2d.b2Contact.prototype,"m_indexA",box2d.b2Contact.prototype.m_indexA);box2d.b2Contact.prototype.m_indexB=0;goog.exportProperty(box2d.b2Contact.prototype,"m_indexB",box2d.b2Contact.prototype.m_indexB);box2d.b2Contact.prototype.m_manifold=null;goog.exportProperty(box2d.b2Contact.prototype,"m_manifold",box2d.b2Contact.prototype.m_manifold);box2d.b2Contact.prototype.m_toiCount=0;goog.exportProperty(box2d.b2Contact.prototype,"m_toiCount",box2d.b2Contact.prototype.m_toiCount);
+box2d.b2Contact.prototype.m_toi=0;goog.exportProperty(box2d.b2Contact.prototype,"m_toi",box2d.b2Contact.prototype.m_toi);box2d.b2Contact.prototype.m_friction=0;goog.exportProperty(box2d.b2Contact.prototype,"m_friction",box2d.b2Contact.prototype.m_friction);box2d.b2Contact.prototype.m_restitution=0;goog.exportProperty(box2d.b2Contact.prototype,"m_restitution",box2d.b2Contact.prototype.m_restitution);box2d.b2Contact.prototype.m_tangentSpeed=0;
+goog.exportProperty(box2d.b2Contact.prototype,"m_tangentSpeed",box2d.b2Contact.prototype.m_tangentSpeed);box2d.b2Contact.prototype.m_oldManifold=null;goog.exportProperty(box2d.b2Contact.prototype,"m_oldManifold",box2d.b2Contact.prototype.m_oldManifold);box2d.b2Contact.prototype.GetManifold=function(){return this.m_manifold};goog.exportProperty(box2d.b2Contact.prototype,"GetManifold",box2d.b2Contact.prototype.GetManifold);
+box2d.b2Contact.prototype.GetWorldManifold=function(a){var b=this.m_fixtureA.GetBody(),c=this.m_fixtureB.GetBody(),d=this.m_fixtureA.GetShape(),e=this.m_fixtureB.GetShape();a.Initialize(this.m_manifold,b.GetTransform(),d.m_radius,c.GetTransform(),e.m_radius)};goog.exportProperty(box2d.b2Contact.prototype,"GetWorldManifold",box2d.b2Contact.prototype.GetWorldManifold);box2d.b2Contact.prototype.IsTouching=function(){return this.m_flag_touchingFlag};
+goog.exportProperty(box2d.b2Contact.prototype,"IsTouching",box2d.b2Contact.prototype.IsTouching);box2d.b2Contact.prototype.SetEnabled=function(a){this.m_flag_enabledFlag=a};goog.exportProperty(box2d.b2Contact.prototype,"SetEnabled",box2d.b2Contact.prototype.SetEnabled);box2d.b2Contact.prototype.IsEnabled=function(){return this.m_flag_enabledFlag};goog.exportProperty(box2d.b2Contact.prototype,"IsEnabled",box2d.b2Contact.prototype.IsEnabled);box2d.b2Contact.prototype.GetNext=function(){return this.m_next};
+goog.exportProperty(box2d.b2Contact.prototype,"GetNext",box2d.b2Contact.prototype.GetNext);box2d.b2Contact.prototype.GetFixtureA=function(){return this.m_fixtureA};goog.exportProperty(box2d.b2Contact.prototype,"GetFixtureA",box2d.b2Contact.prototype.GetFixtureA);box2d.b2Contact.prototype.GetChildIndexA=function(){return this.m_indexA};goog.exportProperty(box2d.b2Contact.prototype,"GetChildIndexA",box2d.b2Contact.prototype.GetChildIndexA);box2d.b2Contact.prototype.GetFixtureB=function(){return this.m_fixtureB};
+goog.exportProperty(box2d.b2Contact.prototype,"GetFixtureB",box2d.b2Contact.prototype.GetFixtureB);box2d.b2Contact.prototype.GetChildIndexB=function(){return this.m_indexB};goog.exportProperty(box2d.b2Contact.prototype,"GetChildIndexB",box2d.b2Contact.prototype.GetChildIndexB);box2d.b2Contact.prototype.Evaluate=function(a,b,c){};goog.exportProperty(box2d.b2Contact.prototype,"Evaluate",box2d.b2Contact.prototype.Evaluate);
+box2d.b2Contact.prototype.FlagForFiltering=function(){this.m_flag_filterFlag=!0};goog.exportProperty(box2d.b2Contact.prototype,"FlagForFiltering",box2d.b2Contact.prototype.FlagForFiltering);box2d.b2Contact.prototype.SetFriction=function(a){this.m_friction=a};goog.exportProperty(box2d.b2Contact.prototype,"SetFriction",box2d.b2Contact.prototype.SetFriction);box2d.b2Contact.prototype.GetFriction=function(){return this.m_friction};goog.exportProperty(box2d.b2Contact.prototype,"GetFriction",box2d.b2Contact.prototype.GetFriction);
+box2d.b2Contact.prototype.ResetFriction=function(){this.m_friction=box2d.b2MixFriction(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction)};goog.exportProperty(box2d.b2Contact.prototype,"ResetFriction",box2d.b2Contact.prototype.ResetFriction);box2d.b2Contact.prototype.SetRestitution=function(a){this.m_restitution=a};goog.exportProperty(box2d.b2Contact.prototype,"SetRestitution",box2d.b2Contact.prototype.SetRestitution);box2d.b2Contact.prototype.GetRestitution=function(){return this.m_restitution};
+goog.exportProperty(box2d.b2Contact.prototype,"GetRestitution",box2d.b2Contact.prototype.GetRestitution);box2d.b2Contact.prototype.ResetRestitution=function(){this.m_restitution=box2d.b2MixRestitution(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)};goog.exportProperty(box2d.b2Contact.prototype,"ResetRestitution",box2d.b2Contact.prototype.ResetRestitution);box2d.b2Contact.prototype.SetTangentSpeed=function(a){this.m_tangentSpeed=a};
+goog.exportProperty(box2d.b2Contact.prototype,"SetTangentSpeed",box2d.b2Contact.prototype.SetTangentSpeed);box2d.b2Contact.prototype.GetTangentSpeed=function(){return this.m_tangentSpeed};goog.exportProperty(box2d.b2Contact.prototype,"GetTangentSpeed",box2d.b2Contact.prototype.GetTangentSpeed);
+box2d.b2Contact.prototype.Reset=function(a,b,c,d){this.m_flag_touchingFlag=this.m_flag_islandFlag=!1;this.m_flag_enabledFlag=!0;this.m_flag_toiFlag=this.m_flag_bulletHitFlag=this.m_flag_filterFlag=!1;this.m_fixtureA=a;this.m_fixtureB=c;this.m_indexA=b;this.m_indexB=d;this.m_manifold.pointCount=0;this.m_next=this.m_prev=null;this.m_nodeA.contact=null;this.m_nodeA.prev=null;this.m_nodeA.next=null;this.m_nodeA.other=null;this.m_nodeB.contact=null;this.m_nodeB.prev=null;this.m_nodeB.next=null;this.m_nodeB.other=
+null;this.m_toiCount=0;this.m_friction=box2d.b2MixFriction(this.m_fixtureA.m_friction,this.m_fixtureB.m_friction);this.m_restitution=box2d.b2MixRestitution(this.m_fixtureA.m_restitution,this.m_fixtureB.m_restitution)};goog.exportProperty(box2d.b2Contact.prototype,"Reset",box2d.b2Contact.prototype.Reset);
+box2d.b2Contact.prototype.Update=function(a){var b=this.m_oldManifold;this.m_oldManifold=this.m_manifold;this.m_manifold=b;this.m_flag_enabledFlag=!0;var c=!1,b=this.m_flag_touchingFlag,d=this.m_fixtureA.IsSensor(),e=this.m_fixtureB.IsSensor(),d=d||e,e=this.m_fixtureA.GetBody(),f=this.m_fixtureB.GetBody(),c=e.GetTransform(),g=f.GetTransform();if(d)e=this.m_fixtureA.GetShape(),f=this.m_fixtureB.GetShape(),c=box2d.b2TestOverlap_Shape(e,this.m_indexA,f,this.m_indexB,c,g),this.m_manifold.pointCount=0;
+else{this.Evaluate(this.m_manifold,c,g);c=0<this.m_manifold.pointCount;for(g=0;g<this.m_manifold.pointCount;++g){var h=this.m_manifold.points[g];h.normalImpulse=0;h.tangentImpulse=0;for(var k=h.id,l=0;l<this.m_oldManifold.pointCount;++l){var m=this.m_oldManifold.points[l];if(m.id.key===k.key){h.normalImpulse=m.normalImpulse;h.tangentImpulse=m.tangentImpulse;break}}}c!==b&&(e.SetAwake(!0),f.SetAwake(!0))}this.m_flag_touchingFlag=c;!b&&c&&a&&a.BeginContact(this);b&&!c&&a&&a.EndContact(this);!d&&c&&
+a&&a.PreSolve(this,this.m_oldManifold)};goog.exportProperty(box2d.b2Contact.prototype,"Update",box2d.b2Contact.prototype.Update);box2d.b2Contact.prototype.ComputeTOI=function(a,b){var c=box2d.b2Contact.prototype.ComputeTOI.s_input;c.proxyA.SetShape(this.m_fixtureA.GetShape(),this.m_indexA);c.proxyB.SetShape(this.m_fixtureB.GetShape(),this.m_indexB);c.sweepA.Copy(a);c.sweepB.Copy(b);c.tMax=box2d.b2_linearSlop;var d=box2d.b2Contact.prototype.ComputeTOI.s_output;box2d.b2TimeOfImpact(d,c);return d.t};
+goog.exportProperty(box2d.b2Contact.prototype,"ComputeTOI",box2d.b2Contact.prototype.ComputeTOI);box2d.b2Contact.prototype.ComputeTOI.s_input=new box2d.b2TOIInput;box2d.b2Contact.prototype.ComputeTOI.s_output=new box2d.b2TOIOutput;box2d.b2ChainAndCircleContact=function(){box2d.b2Contact.call(this)};goog.inherits(box2d.b2ChainAndCircleContact,box2d.b2Contact);goog.exportSymbol("box2d.b2ChainAndCircleContact",box2d.b2ChainAndCircleContact);box2d.b2ChainAndCircleContact.Create=function(a){return new box2d.b2ChainAndCircleContact};goog.exportProperty(box2d.b2ChainAndCircleContact,"Create",box2d.b2ChainAndCircleContact.Create);box2d.b2ChainAndCircleContact.Destroy=function(a,b){};
+goog.exportProperty(box2d.b2ChainAndCircleContact,"Destroy",box2d.b2ChainAndCircleContact.Destroy);
+box2d.b2ChainAndCircleContact.prototype.Evaluate=function(a,b,c){var d=this.m_fixtureA.GetShape(),e=this.m_fixtureB.GetShape();box2d.ENABLE_ASSERTS&&box2d.b2Assert(d instanceof box2d.b2ChainShape);box2d.ENABLE_ASSERTS&&box2d.b2Assert(e instanceof box2d.b2CircleShape);var f=box2d.b2ChainAndCircleContact.prototype.Evaluate.s_edge;(d instanceof box2d.b2ChainShape?d:null).GetChildEdge(f,this.m_indexA);box2d.b2CollideEdgeAndCircle(a,f,b,e instanceof box2d.b2CircleShape?e:null,c)};
+goog.exportProperty(box2d.b2ChainAndCircleContact.prototype,"Evaluate",box2d.b2ChainAndCircleContact.prototype.Evaluate);box2d.b2ChainAndCircleContact.prototype.Evaluate.s_edge=new box2d.b2EdgeShape;box2d.b2ChainAndPolygonContact=function(){box2d.b2Contact.call(this)};goog.inherits(box2d.b2ChainAndPolygonContact,box2d.b2Contact);goog.exportSymbol("box2d.b2ChainAndPolygonContact",box2d.b2ChainAndPolygonContact);box2d.b2ChainAndPolygonContact.Create=function(a){return new box2d.b2ChainAndPolygonContact};goog.exportProperty(box2d.b2ChainAndPolygonContact,"Create",box2d.b2ChainAndPolygonContact.Create);box2d.b2ChainAndPolygonContact.Destroy=function(a,b){};
+goog.exportProperty(box2d.b2ChainAndPolygonContact,"Destroy",box2d.b2ChainAndPolygonContact.Destroy);
+box2d.b2ChainAndPolygonContact.prototype.Evaluate=function(a,b,c){var d=this.m_fixtureA.GetShape(),e=this.m_fixtureB.GetShape();box2d.ENABLE_ASSERTS&&box2d.b2Assert(d instanceof box2d.b2ChainShape);box2d.ENABLE_ASSERTS&&box2d.b2Assert(e instanceof box2d.b2PolygonShape);var f=box2d.b2ChainAndPolygonContact.prototype.Evaluate.s_edge;(d instanceof box2d.b2ChainShape?d:null).GetChildEdge(f,this.m_indexA);box2d.b2CollideEdgeAndPolygon(a,f,b,e instanceof box2d.b2PolygonShape?e:null,c)};
+goog.exportProperty(box2d.b2ChainAndPolygonContact.prototype,"Evaluate",box2d.b2ChainAndPolygonContact.prototype.Evaluate);box2d.b2ChainAndPolygonContact.prototype.Evaluate.s_edge=new box2d.b2EdgeShape;box2d.b2CircleContact=function(){box2d.b2Contact.call(this)};goog.inherits(box2d.b2CircleContact,box2d.b2Contact);goog.exportSymbol("box2d.b2CircleContact",box2d.b2CircleContact);box2d.b2CircleContact.Create=function(a){return new box2d.b2CircleContact};goog.exportProperty(box2d.b2CircleContact,"Create",box2d.b2CircleContact.Create);box2d.b2CircleContact.Destroy=function(a,b){};goog.exportProperty(box2d.b2CircleContact,"Destroy",box2d.b2CircleContact.Destroy);
+box2d.b2CircleContact.prototype.Evaluate=function(a,b,c){var d=this.m_fixtureA.GetShape(),e=this.m_fixtureB.GetShape();box2d.ENABLE_ASSERTS&&box2d.b2Assert(d instanceof box2d.b2CircleShape);box2d.ENABLE_ASSERTS&&box2d.b2Assert(e instanceof box2d.b2CircleShape);box2d.b2CollideCircles(a,d instanceof box2d.b2CircleShape?d:null,b,e instanceof box2d.b2CircleShape?e:null,c)};goog.exportProperty(box2d.b2CircleContact.prototype,"Evaluate",box2d.b2CircleContact.prototype.Evaluate);box2d.b2ContactRegister=function(){};goog.exportSymbol("box2d.b2ContactRegister",box2d.b2ContactRegister);box2d.b2ContactRegister.prototype.createFcn=null;box2d.b2ContactRegister.prototype.destroyFcn=null;box2d.b2ContactRegister.prototype.primary=!1;box2d.b2ContactFactory=function(a){this.m_allocator=a;this.InitializeRegisters()};goog.exportSymbol("box2d.b2ContactFactory",box2d.b2ContactFactory);box2d.b2ContactFactory.prototype.m_allocator=null;
+box2d.b2ContactFactory.prototype.AddType=function(a,b,c,d){var e=box2d.b2MakeArray(256,function(b){return a()});b=function(b){return 0<e.length?e.pop():a(b)};var f=function(a,b){e.push(a)};this.m_registers[c][d].pool=e;this.m_registers[c][d].createFcn=b;this.m_registers[c][d].destroyFcn=f;this.m_registers[c][d].primary=!0;c!==d&&(this.m_registers[d][c].pool=e,this.m_registers[d][c].createFcn=b,this.m_registers[d][c].destroyFcn=f,this.m_registers[d][c].primary=!1)};
+goog.exportProperty(box2d.b2ContactFactory.prototype,"AddType",box2d.b2ContactFactory.prototype.AddType);
+box2d.b2ContactFactory.prototype.InitializeRegisters=function(){this.m_registers=Array(box2d.b2ShapeType.e_shapeTypeCount);for(var a=0;a<box2d.b2ShapeType.e_shapeTypeCount;a++){this.m_registers[a]=Array(box2d.b2ShapeType.e_shapeTypeCount);for(var b=0;b<box2d.b2ShapeType.e_shapeTypeCount;b++)this.m_registers[a][b]=new box2d.b2ContactRegister}this.AddType(box2d.b2CircleContact.Create,box2d.b2CircleContact.Destroy,box2d.b2ShapeType.e_circleShape,box2d.b2ShapeType.e_circleShape);this.AddType(box2d.b2PolygonAndCircleContact.Create,
+box2d.b2PolygonAndCircleContact.Destroy,box2d.b2ShapeType.e_polygonShape,box2d.b2ShapeType.e_circleShape);this.AddType(box2d.b2PolygonContact.Create,box2d.b2PolygonContact.Destroy,box2d.b2ShapeType.e_polygonShape,box2d.b2ShapeType.e_polygonShape);this.AddType(box2d.b2EdgeAndCircleContact.Create,box2d.b2EdgeAndCircleContact.Destroy,box2d.b2ShapeType.e_edgeShape,box2d.b2ShapeType.e_circleShape);this.AddType(box2d.b2EdgeAndPolygonContact.Create,box2d.b2EdgeAndPolygonContact.Destroy,box2d.b2ShapeType.e_edgeShape,
+box2d.b2ShapeType.e_polygonShape);this.AddType(box2d.b2ChainAndCircleContact.Create,box2d.b2ChainAndCircleContact.Destroy,box2d.b2ShapeType.e_chainShape,box2d.b2ShapeType.e_circleShape);this.AddType(box2d.b2ChainAndPolygonContact.Create,box2d.b2ChainAndPolygonContact.Destroy,box2d.b2ShapeType.e_chainShape,box2d.b2ShapeType.e_polygonShape)};goog.exportProperty(box2d.b2ContactFactory.prototype,"InitializeRegisters",box2d.b2ContactFactory.prototype.InitializeRegisters);
+box2d.b2ContactFactory.prototype.Create=function(a,b,c,d){var e=a.GetType(),f=c.GetType();box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<=e&&e<box2d.b2ShapeType.e_shapeTypeCount);box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<=f&&f<box2d.b2ShapeType.e_shapeTypeCount);e=this.m_registers[e][f];f=e.createFcn;return null!==f?(e.primary?(e=f(this.m_allocator),e.Reset(a,b,c,d)):(e=f(this.m_allocator),e.Reset(c,d,a,b)),e):null};goog.exportProperty(box2d.b2ContactFactory.prototype,"Create",box2d.b2ContactFactory.prototype.Create);
+box2d.b2ContactFactory.prototype.Destroy=function(a){var b=a.m_fixtureA,c=a.m_fixtureB;0<a.m_manifold.pointCount&&!b.IsSensor()&&!c.IsSensor()&&(b.GetBody().SetAwake(!0),c.GetBody().SetAwake(!0));b=b.GetType();c=c.GetType();box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<=b&&c<box2d.b2ShapeType.e_shapeTypeCount);box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<=b&&c<box2d.b2ShapeType.e_shapeTypeCount);c=this.m_registers[b][c].destroyFcn;c(a,this.m_allocator)};
+goog.exportProperty(box2d.b2ContactFactory.prototype,"Destroy",box2d.b2ContactFactory.prototype.Destroy);box2d.b2ContactManager=function(){this.m_broadPhase=new box2d.b2BroadPhase;this.m_contactFactory=new box2d.b2ContactFactory(this.m_allocator)};box2d.b2ContactManager.prototype.m_broadPhase=null;goog.exportProperty(box2d.b2ContactManager.prototype,"m_broadPhase",box2d.b2ContactManager.prototype.m_broadPhase);box2d.b2ContactManager.prototype.m_contactList=null;goog.exportProperty(box2d.b2ContactManager.prototype,"m_contactList",box2d.b2ContactManager.prototype.m_contactList);
+box2d.b2ContactManager.prototype.m_contactCount=0;goog.exportProperty(box2d.b2ContactManager.prototype,"m_contactCount",box2d.b2ContactManager.prototype.m_contactCount);box2d.b2ContactManager.prototype.m_contactFilter=box2d.b2ContactFilter.b2_defaultFilter;goog.exportProperty(box2d.b2ContactManager.prototype,"m_contactFilter",box2d.b2ContactManager.prototype.m_contactFilter);box2d.b2ContactManager.prototype.m_contactListener=box2d.b2ContactListener.b2_defaultListener;
+goog.exportProperty(box2d.b2ContactManager.prototype,"m_contactListener",box2d.b2ContactManager.prototype.m_contactListener);box2d.b2ContactManager.prototype.m_allocator=null;goog.exportProperty(box2d.b2ContactManager.prototype,"m_allocator",box2d.b2ContactManager.prototype.m_allocator);box2d.b2ContactManager.prototype.m_contactFactory=null;goog.exportProperty(box2d.b2ContactManager.prototype,"m_contactFactory",box2d.b2ContactManager.prototype.m_contactFactory);
+box2d.b2ContactManager.prototype.Destroy=function(a){var b=a.GetFixtureA(),c=a.GetFixtureB(),b=b.GetBody(),c=c.GetBody();this.m_contactListener&&a.IsTouching()&&this.m_contactListener.EndContact(a);a.m_prev&&(a.m_prev.m_next=a.m_next);a.m_next&&(a.m_next.m_prev=a.m_prev);a===this.m_contactList&&(this.m_contactList=a.m_next);a.m_nodeA.prev&&(a.m_nodeA.prev.next=a.m_nodeA.next);a.m_nodeA.next&&(a.m_nodeA.next.prev=a.m_nodeA.prev);a.m_nodeA===b.m_contactList&&(b.m_contactList=a.m_nodeA.next);a.m_nodeB.prev&&
+(a.m_nodeB.prev.next=a.m_nodeB.next);a.m_nodeB.next&&(a.m_nodeB.next.prev=a.m_nodeB.prev);a.m_nodeB===c.m_contactList&&(c.m_contactList=a.m_nodeB.next);this.m_contactFactory.Destroy(a);--this.m_contactCount};goog.exportProperty(box2d.b2ContactManager.prototype,"Destroy",box2d.b2ContactManager.prototype.Destroy);
+box2d.b2ContactManager.prototype.Collide=function(){for(var a=this.m_contactList;a;){var b=a.GetFixtureA(),c=a.GetFixtureB(),d=a.GetChildIndexA(),e=a.GetChildIndexB(),f=b.GetBody(),g=c.GetBody();if(a.m_flag_filterFlag){if(!g.ShouldCollide(f)){b=a;a=b.m_next;this.Destroy(b);continue}if(this.m_contactFilter&&!this.m_contactFilter.ShouldCollide(b,c)){b=a;a=b.m_next;this.Destroy(b);continue}a.m_flag_filterFlag=!1}f=f.IsAwake()&&f.m_type!==box2d.b2BodyType.b2_staticBody;g=g.IsAwake()&&g.m_type!==box2d.b2BodyType.b2_staticBody;
+f||g?this.m_broadPhase.TestOverlap(b.m_proxies[d].proxy,c.m_proxies[e].proxy)?(a.Update(this.m_contactListener),a=a.m_next):(b=a,a=b.m_next,this.Destroy(b)):a=a.m_next}};goog.exportProperty(box2d.b2ContactManager.prototype,"Collide",box2d.b2ContactManager.prototype.Collide);box2d.b2ContactManager.prototype.FindNewContacts=function(){this.m_broadPhase.UpdatePairs(this)};goog.exportProperty(box2d.b2ContactManager.prototype,"FindNewContacts",box2d.b2ContactManager.prototype.FindNewContacts);
+box2d.b2ContactManager.prototype.AddPair=function(a,b){box2d.ENABLE_ASSERTS&&box2d.b2Assert(a instanceof box2d.b2FixtureProxy);box2d.ENABLE_ASSERTS&&box2d.b2Assert(b instanceof box2d.b2FixtureProxy);var c=a.fixture,d=b.fixture,e=a.childIndex,f=b.childIndex,g=c.GetBody(),h=d.GetBody();if(g!==h){for(var k=h.GetContactList();k;){if(k.other===g){var l=k.contact.GetFixtureA(),m=k.contact.GetFixtureB(),n=k.contact.GetChildIndexA(),p=k.contact.GetChildIndexB();if(l===c&&m===d&&n===e&&p===f||l===d&&m===c&&
+n===f&&p===e)return}k=k.next}!h.ShouldCollide(g)||this.m_contactFilter&&!this.m_contactFilter.ShouldCollide(c,d)||(e=this.m_contactFactory.Create(c,e,d,f),null!==e&&(c=e.GetFixtureA(),d=e.GetFixtureB(),g=c.m_body,h=d.m_body,e.m_prev=null,e.m_next=this.m_contactList,null!==this.m_contactList&&(this.m_contactList.m_prev=e),this.m_contactList=e,e.m_nodeA.contact=e,e.m_nodeA.other=h,e.m_nodeA.prev=null,e.m_nodeA.next=g.m_contactList,null!==g.m_contactList&&(g.m_contactList.prev=e.m_nodeA),g.m_contactList=
+e.m_nodeA,e.m_nodeB.contact=e,e.m_nodeB.other=g,e.m_nodeB.prev=null,e.m_nodeB.next=h.m_contactList,null!==h.m_contactList&&(h.m_contactList.prev=e.m_nodeB),h.m_contactList=e.m_nodeB,c.IsSensor()||d.IsSensor()||(g.SetAwake(!0),h.SetAwake(!0)),++this.m_contactCount))}};goog.exportProperty(box2d.b2ContactManager.prototype,"AddPair",box2d.b2ContactManager.prototype.AddPair);box2d.b2EdgeAndCircleContact=function(){box2d.b2Contact.call(this)};goog.inherits(box2d.b2EdgeAndCircleContact,box2d.b2Contact);goog.exportSymbol("box2d.b2EdgeAndCircleContact",box2d.b2EdgeAndCircleContact);box2d.b2EdgeAndCircleContact.Create=function(a){return new box2d.b2EdgeAndCircleContact};goog.exportProperty(box2d.b2EdgeAndCircleContact,"Create",box2d.b2EdgeAndCircleContact.Create);box2d.b2EdgeAndCircleContact.Destroy=function(a,b){};
+goog.exportProperty(box2d.b2EdgeAndCircleContact,"Destroy",box2d.b2EdgeAndCircleContact.Destroy);box2d.b2EdgeAndCircleContact.prototype.Evaluate=function(a,b,c){var d=this.m_fixtureA.GetShape(),e=this.m_fixtureB.GetShape();box2d.ENABLE_ASSERTS&&box2d.b2Assert(d instanceof box2d.b2EdgeShape);box2d.ENABLE_ASSERTS&&box2d.b2Assert(e instanceof box2d.b2CircleShape);box2d.b2CollideEdgeAndCircle(a,d instanceof box2d.b2EdgeShape?d:null,b,e instanceof box2d.b2CircleShape?e:null,c)};
+goog.exportProperty(box2d.b2EdgeAndCircleContact.prototype,"Evaluate",box2d.b2EdgeAndCircleContact.prototype.Evaluate);box2d.b2EdgeAndPolygonContact=function(){box2d.b2Contact.call(this)};goog.inherits(box2d.b2EdgeAndPolygonContact,box2d.b2Contact);goog.exportSymbol("box2d.b2EdgeAndPolygonContact",box2d.b2EdgeAndPolygonContact);box2d.b2EdgeAndPolygonContact.Create=function(a){return new box2d.b2EdgeAndPolygonContact};goog.exportProperty(box2d.b2EdgeAndPolygonContact,"Create",box2d.b2EdgeAndPolygonContact.Create);box2d.b2EdgeAndPolygonContact.Destroy=function(a,b){};
+goog.exportProperty(box2d.b2EdgeAndPolygonContact,"Destroy",box2d.b2EdgeAndPolygonContact.Destroy);box2d.b2EdgeAndPolygonContact.prototype.Evaluate=function(a,b,c){var d=this.m_fixtureA.GetShape(),e=this.m_fixtureB.GetShape();box2d.ENABLE_ASSERTS&&box2d.b2Assert(d instanceof box2d.b2EdgeShape);box2d.ENABLE_ASSERTS&&box2d.b2Assert(e instanceof box2d.b2PolygonShape);box2d.b2CollideEdgeAndPolygon(a,d instanceof box2d.b2EdgeShape?d:null,b,e instanceof box2d.b2PolygonShape?e:null,c)};
+goog.exportProperty(box2d.b2EdgeAndPolygonContact.prototype,"Evaluate",box2d.b2EdgeAndPolygonContact.prototype.Evaluate);box2d.b2PolygonAndCircleContact=function(){box2d.b2Contact.call(this)};goog.inherits(box2d.b2PolygonAndCircleContact,box2d.b2Contact);goog.exportSymbol("box2d.b2PolygonAndCircleContact",box2d.b2PolygonAndCircleContact);box2d.b2PolygonAndCircleContact.Create=function(a){return new box2d.b2PolygonAndCircleContact};goog.exportProperty(box2d.b2PolygonAndCircleContact,"Create",box2d.b2PolygonAndCircleContact.Create);box2d.b2PolygonAndCircleContact.Destroy=function(a,b){};
+goog.exportProperty(box2d.b2PolygonAndCircleContact,"Destroy",box2d.b2PolygonAndCircleContact.Destroy);box2d.b2PolygonAndCircleContact.prototype.Evaluate=function(a,b,c){var d=this.m_fixtureA.GetShape(),e=this.m_fixtureB.GetShape();box2d.ENABLE_ASSERTS&&box2d.b2Assert(d instanceof box2d.b2PolygonShape);box2d.ENABLE_ASSERTS&&box2d.b2Assert(e instanceof box2d.b2CircleShape);box2d.b2CollidePolygonAndCircle(a,d instanceof box2d.b2PolygonShape?d:null,b,e instanceof box2d.b2CircleShape?e:null,c)};
+goog.exportProperty(box2d.b2PolygonAndCircleContact.prototype,"Evaluate",box2d.b2PolygonAndCircleContact.prototype.Evaluate);box2d.b2PolygonContact=function(){box2d.b2Contact.call(this)};goog.inherits(box2d.b2PolygonContact,box2d.b2Contact);goog.exportSymbol("box2d.b2PolygonContact",box2d.b2PolygonContact);box2d.b2PolygonContact.Create=function(a){return new box2d.b2PolygonContact};goog.exportProperty(box2d.b2PolygonContact,"Create",box2d.b2PolygonContact.Create);box2d.b2PolygonContact.Destroy=function(a,b){};goog.exportProperty(box2d.b2PolygonContact,"Destroy",box2d.b2PolygonContact.Destroy);
+box2d.b2PolygonContact.prototype.Evaluate=function(a,b,c){var d=this.m_fixtureA.GetShape(),e=this.m_fixtureB.GetShape();box2d.ENABLE_ASSERTS&&box2d.b2Assert(d instanceof box2d.b2PolygonShape);box2d.ENABLE_ASSERTS&&box2d.b2Assert(e instanceof box2d.b2PolygonShape);box2d.b2CollidePolygons(a,d instanceof box2d.b2PolygonShape?d:null,b,e instanceof box2d.b2PolygonShape?e:null,c)};goog.exportProperty(box2d.b2PolygonContact.prototype,"Evaluate",box2d.b2PolygonContact.prototype.Evaluate);box2d.g_blockSolve=!0;box2d.b2VelocityConstraintPoint=function(){this.rA=new box2d.b2Vec2;this.rB=new box2d.b2Vec2};goog.exportSymbol("box2d.b2VelocityConstraintPoint",box2d.b2VelocityConstraintPoint);box2d.b2VelocityConstraintPoint.prototype.rA=null;goog.exportProperty(box2d.b2VelocityConstraintPoint.prototype,"rA",box2d.b2VelocityConstraintPoint.prototype.rA);box2d.b2VelocityConstraintPoint.prototype.rB=null;goog.exportProperty(box2d.b2VelocityConstraintPoint.prototype,"rB",box2d.b2VelocityConstraintPoint.prototype.rB);
+box2d.b2VelocityConstraintPoint.prototype.normalImpulse=0;goog.exportProperty(box2d.b2VelocityConstraintPoint.prototype,"normalImpulse",box2d.b2VelocityConstraintPoint.prototype.normalImpulse);box2d.b2VelocityConstraintPoint.prototype.tangentImpulse=0;goog.exportProperty(box2d.b2VelocityConstraintPoint.prototype,"tangentImpulse",box2d.b2VelocityConstraintPoint.prototype.tangentImpulse);box2d.b2VelocityConstraintPoint.prototype.normalMass=0;
+goog.exportProperty(box2d.b2VelocityConstraintPoint.prototype,"normalMass",box2d.b2VelocityConstraintPoint.prototype.normalMass);box2d.b2VelocityConstraintPoint.prototype.tangentMass=0;goog.exportProperty(box2d.b2VelocityConstraintPoint.prototype,"tangentMass",box2d.b2VelocityConstraintPoint.prototype.tangentMass);box2d.b2VelocityConstraintPoint.prototype.velocityBias=0;goog.exportProperty(box2d.b2VelocityConstraintPoint.prototype,"velocityBias",box2d.b2VelocityConstraintPoint.prototype.velocityBias);
+box2d.b2VelocityConstraintPoint.MakeArray=function(a){return box2d.b2MakeArray(a,function(a){return new box2d.b2VelocityConstraintPoint})};goog.exportProperty(box2d.b2VelocityConstraintPoint,"MakeArray",box2d.b2VelocityConstraintPoint.MakeArray);box2d.b2ContactVelocityConstraint=function(){this.points=box2d.b2VelocityConstraintPoint.MakeArray(box2d.b2_maxManifoldPoints);this.normal=new box2d.b2Vec2;this.tangent=new box2d.b2Vec2;this.normalMass=new box2d.b2Mat22;this.K=new box2d.b2Mat22};
+goog.exportSymbol("box2d.b2ContactVelocityConstraint",box2d.b2ContactVelocityConstraint);box2d.b2ContactVelocityConstraint.prototype.points=null;goog.exportProperty(box2d.b2ContactVelocityConstraint.prototype,"points",box2d.b2ContactVelocityConstraint.prototype.points);box2d.b2ContactVelocityConstraint.prototype.normal=null;goog.exportProperty(box2d.b2ContactVelocityConstraint.prototype,"normal",box2d.b2ContactVelocityConstraint.prototype.normal);
+box2d.b2ContactVelocityConstraint.prototype.tangent=null;goog.exportProperty(box2d.b2ContactVelocityConstraint.prototype,"tangent",box2d.b2ContactVelocityConstraint.prototype.tangent);box2d.b2ContactVelocityConstraint.prototype.normalMass=null;goog.exportProperty(box2d.b2ContactVelocityConstraint.prototype,"normalMass",box2d.b2ContactVelocityConstraint.prototype.normalMass);box2d.b2ContactVelocityConstraint.prototype.K=null;goog.exportProperty(box2d.b2ContactVelocityConstraint.prototype,"K",box2d.b2ContactVelocityConstraint.prototype.K);
+box2d.b2ContactVelocityConstraint.prototype.indexA=0;goog.exportProperty(box2d.b2ContactVelocityConstraint.prototype,"indexA",box2d.b2ContactVelocityConstraint.prototype.indexA);box2d.b2ContactVelocityConstraint.prototype.indexB=0;goog.exportProperty(box2d.b2ContactVelocityConstraint.prototype,"indexB",box2d.b2ContactVelocityConstraint.prototype.indexB);box2d.b2ContactVelocityConstraint.prototype.invMassA=0;goog.exportProperty(box2d.b2ContactVelocityConstraint.prototype,"invMassA",box2d.b2ContactVelocityConstraint.prototype.invMassA);
+box2d.b2ContactVelocityConstraint.prototype.invMassB=0;goog.exportProperty(box2d.b2ContactVelocityConstraint.prototype,"invMassB",box2d.b2ContactVelocityConstraint.prototype.invMassB);box2d.b2ContactVelocityConstraint.prototype.invIA=0;goog.exportProperty(box2d.b2ContactVelocityConstraint.prototype,"invIA",box2d.b2ContactVelocityConstraint.prototype.invIA);box2d.b2ContactVelocityConstraint.prototype.invIB=0;goog.exportProperty(box2d.b2ContactVelocityConstraint.prototype,"invIB",box2d.b2ContactVelocityConstraint.prototype.invIB);
+box2d.b2ContactVelocityConstraint.prototype.friction=0;goog.exportProperty(box2d.b2ContactVelocityConstraint.prototype,"friction",box2d.b2ContactVelocityConstraint.prototype.friction);box2d.b2ContactVelocityConstraint.prototype.restitution=0;goog.exportProperty(box2d.b2ContactVelocityConstraint.prototype,"restitution",box2d.b2ContactVelocityConstraint.prototype.restitution);box2d.b2ContactVelocityConstraint.prototype.tangentSpeed=0;
+goog.exportProperty(box2d.b2ContactVelocityConstraint.prototype,"tangentSpeed",box2d.b2ContactVelocityConstraint.prototype.tangentSpeed);box2d.b2ContactVelocityConstraint.prototype.pointCount=0;goog.exportProperty(box2d.b2ContactVelocityConstraint.prototype,"pointCount",box2d.b2ContactVelocityConstraint.prototype.pointCount);box2d.b2ContactVelocityConstraint.prototype.contactIndex=0;goog.exportProperty(box2d.b2ContactVelocityConstraint.prototype,"contactIndex",box2d.b2ContactVelocityConstraint.prototype.contactIndex);
+box2d.b2ContactVelocityConstraint.MakeArray=function(a){return box2d.b2MakeArray(a,function(a){return new box2d.b2ContactVelocityConstraint})};goog.exportProperty(box2d.b2ContactVelocityConstraint,"MakeArray",box2d.b2ContactVelocityConstraint.MakeArray);box2d.b2ContactPositionConstraint=function(){this.localPoints=box2d.b2Vec2.MakeArray(box2d.b2_maxManifoldPoints);this.localNormal=new box2d.b2Vec2;this.localPoint=new box2d.b2Vec2;this.localCenterA=new box2d.b2Vec2;this.localCenterB=new box2d.b2Vec2};
+goog.exportSymbol("box2d.b2ContactPositionConstraint",box2d.b2ContactPositionConstraint);box2d.b2ContactPositionConstraint.prototype.localPoints=null;goog.exportProperty(box2d.b2ContactPositionConstraint.prototype,"localPoints",box2d.b2ContactPositionConstraint.prototype.localPoints);box2d.b2ContactPositionConstraint.prototype.localNormal=null;goog.exportProperty(box2d.b2ContactPositionConstraint.prototype,"localNormal",box2d.b2ContactPositionConstraint.prototype.localNormal);
+box2d.b2ContactPositionConstraint.prototype.localPoint=null;goog.exportProperty(box2d.b2ContactPositionConstraint.prototype,"localPoint",box2d.b2ContactPositionConstraint.prototype.localPoint);box2d.b2ContactPositionConstraint.prototype.indexA=0;goog.exportProperty(box2d.b2ContactPositionConstraint.prototype,"indexA",box2d.b2ContactPositionConstraint.prototype.indexA);box2d.b2ContactPositionConstraint.prototype.indexB=0;goog.exportProperty(box2d.b2ContactPositionConstraint.prototype,"indexB",box2d.b2ContactPositionConstraint.prototype.indexB);
+box2d.b2ContactPositionConstraint.prototype.invMassA=0;goog.exportProperty(box2d.b2ContactPositionConstraint.prototype,"invMassA",box2d.b2ContactPositionConstraint.prototype.invMassA);box2d.b2ContactPositionConstraint.prototype.invMassB=0;goog.exportProperty(box2d.b2ContactPositionConstraint.prototype,"invMassB",box2d.b2ContactPositionConstraint.prototype.invMassB);box2d.b2ContactPositionConstraint.prototype.localCenterA=null;
+goog.exportProperty(box2d.b2ContactPositionConstraint.prototype,"localCenterA",box2d.b2ContactPositionConstraint.prototype.localCenterA);box2d.b2ContactPositionConstraint.prototype.localCenterB=null;goog.exportProperty(box2d.b2ContactPositionConstraint.prototype,"localCenterB",box2d.b2ContactPositionConstraint.prototype.localCenterB);box2d.b2ContactPositionConstraint.prototype.invIA=0;goog.exportProperty(box2d.b2ContactPositionConstraint.prototype,"invIA",box2d.b2ContactPositionConstraint.prototype.invIA);
+box2d.b2ContactPositionConstraint.prototype.invIB=0;goog.exportProperty(box2d.b2ContactPositionConstraint.prototype,"invIB",box2d.b2ContactPositionConstraint.prototype.invIB);box2d.b2ContactPositionConstraint.prototype.type=box2d.b2ManifoldType.e_unknown;goog.exportProperty(box2d.b2ContactPositionConstraint.prototype,"type",box2d.b2ContactPositionConstraint.prototype.type);box2d.b2ContactPositionConstraint.prototype.radiusA=0;
+goog.exportProperty(box2d.b2ContactPositionConstraint.prototype,"radiusA",box2d.b2ContactPositionConstraint.prototype.radiusA);box2d.b2ContactPositionConstraint.prototype.radiusB=0;goog.exportProperty(box2d.b2ContactPositionConstraint.prototype,"radiusB",box2d.b2ContactPositionConstraint.prototype.radiusB);box2d.b2ContactPositionConstraint.prototype.pointCount=0;goog.exportProperty(box2d.b2ContactPositionConstraint.prototype,"pointCount",box2d.b2ContactPositionConstraint.prototype.pointCount);
+box2d.b2ContactPositionConstraint.MakeArray=function(a){return box2d.b2MakeArray(a,function(a){return new box2d.b2ContactPositionConstraint})};goog.exportProperty(box2d.b2ContactPositionConstraint,"MakeArray",box2d.b2ContactPositionConstraint.MakeArray);box2d.b2ContactSolverDef=function(){this.step=new box2d.b2TimeStep};goog.exportSymbol("box2d.b2ContactSolverDef",box2d.b2ContactSolverDef);box2d.b2ContactSolverDef.prototype.step=null;goog.exportProperty(box2d.b2ContactSolverDef.prototype,"step",box2d.b2ContactSolverDef.prototype.step);
+box2d.b2ContactSolverDef.prototype.contacts=null;goog.exportProperty(box2d.b2ContactSolverDef.prototype,"contacts",box2d.b2ContactSolverDef.prototype.contacts);box2d.b2ContactSolverDef.prototype.count=0;goog.exportProperty(box2d.b2ContactSolverDef.prototype,"count",box2d.b2ContactSolverDef.prototype.count);box2d.b2ContactSolverDef.prototype.positions=null;goog.exportProperty(box2d.b2ContactSolverDef.prototype,"positions",box2d.b2ContactSolverDef.prototype.positions);
+box2d.b2ContactSolverDef.prototype.velocities=null;goog.exportProperty(box2d.b2ContactSolverDef.prototype,"velocities",box2d.b2ContactSolverDef.prototype.velocities);box2d.b2ContactSolverDef.prototype.allocator=null;goog.exportProperty(box2d.b2ContactSolverDef.prototype,"allocator",box2d.b2ContactSolverDef.prototype.allocator);box2d.b2ContactSolver=function(){this.m_step=new box2d.b2TimeStep;this.m_positionConstraints=box2d.b2ContactPositionConstraint.MakeArray(1024);this.m_velocityConstraints=box2d.b2ContactVelocityConstraint.MakeArray(1024)};
+goog.exportSymbol("box2d.b2ContactSolver",box2d.b2ContactSolver);box2d.b2ContactSolver.prototype.m_step=null;goog.exportProperty(box2d.b2ContactSolver.prototype,"m_step",box2d.b2ContactSolver.prototype.m_step);box2d.b2ContactSolver.prototype.m_positions=null;goog.exportProperty(box2d.b2ContactSolver.prototype,"m_positions",box2d.b2ContactSolver.prototype.m_positions);box2d.b2ContactSolver.prototype.m_velocities=null;goog.exportProperty(box2d.b2ContactSolver.prototype,"m_velocities",box2d.b2ContactSolver.prototype.m_velocities);
+box2d.b2ContactSolver.prototype.m_allocator=null;goog.exportProperty(box2d.b2ContactSolver.prototype,"m_allocator",box2d.b2ContactSolver.prototype.m_allocator);box2d.b2ContactSolver.prototype.m_positionConstraints=null;goog.exportProperty(box2d.b2ContactSolver.prototype,"m_positionConstraints",box2d.b2ContactSolver.prototype.m_positionConstraints);box2d.b2ContactSolver.prototype.m_velocityConstraints=null;goog.exportProperty(box2d.b2ContactSolver.prototype,"m_velocityConstraints",box2d.b2ContactSolver.prototype.m_velocityConstraints);
+box2d.b2ContactSolver.prototype.m_contacts=null;goog.exportProperty(box2d.b2ContactSolver.prototype,"m_contacts",box2d.b2ContactSolver.prototype.m_contacts);box2d.b2ContactSolver.prototype.m_count=0;goog.exportProperty(box2d.b2ContactSolver.prototype,"m_count",box2d.b2ContactSolver.prototype.m_count);
+box2d.b2ContactSolver.prototype.Initialize=function(a){this.m_step.Copy(a.step);this.m_allocator=a.allocator;this.m_count=a.count;if(this.m_positionConstraints.length<this.m_count){var b=box2d.b2Max(2*this.m_positionConstraints.length,this.m_count);for(box2d.DEBUG&&window.console.log("box2d.b2ContactSolver.m_positionConstraints: "+b);this.m_positionConstraints.length<b;)this.m_positionConstraints[this.m_positionConstraints.length]=new box2d.b2ContactPositionConstraint}if(this.m_velocityConstraints.length<
+this.m_count)for(b=box2d.b2Max(2*this.m_velocityConstraints.length,this.m_count),box2d.DEBUG&&window.console.log("box2d.b2ContactSolver.m_velocityConstraints: "+b);this.m_velocityConstraints.length<b;)this.m_velocityConstraints[this.m_velocityConstraints.length]=new box2d.b2ContactVelocityConstraint;this.m_positions=a.positions;this.m_velocities=a.velocities;this.m_contacts=a.contacts;var c,d,e,f,g,h,k,l;a=0;for(b=this.m_count;a<b;++a)for(e=this.m_contacts[a],f=e.m_fixtureA,g=e.m_fixtureB,c=f.GetShape(),
+d=g.GetShape(),c=c.m_radius,d=d.m_radius,h=f.GetBody(),k=g.GetBody(),g=e.GetManifold(),l=g.pointCount,box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<l),f=this.m_velocityConstraints[a],f.friction=e.m_friction,f.restitution=e.m_restitution,f.tangentSpeed=e.m_tangentSpeed,f.indexA=h.m_islandIndex,f.indexB=k.m_islandIndex,f.invMassA=h.m_invMass,f.invMassB=k.m_invMass,f.invIA=h.m_invI,f.invIB=k.m_invI,f.contactIndex=a,f.pointCount=l,f.K.SetZero(),f.normalMass.SetZero(),e=this.m_positionConstraints[a],e.indexA=
+h.m_islandIndex,e.indexB=k.m_islandIndex,e.invMassA=h.m_invMass,e.invMassB=k.m_invMass,e.localCenterA.Copy(h.m_sweep.localCenter),e.localCenterB.Copy(k.m_sweep.localCenter),e.invIA=h.m_invI,e.invIB=k.m_invI,e.localNormal.Copy(g.localNormal),e.localPoint.Copy(g.localPoint),e.pointCount=l,e.radiusA=c,e.radiusB=d,e.type=g.type,c=0,d=l;c<d;++c)h=g.points[c],l=f.points[c],this.m_step.warmStarting?(l.normalImpulse=this.m_step.dtRatio*h.normalImpulse,l.tangentImpulse=this.m_step.dtRatio*h.tangentImpulse):
+(l.normalImpulse=0,l.tangentImpulse=0),l.rA.SetZero(),l.rB.SetZero(),l.normalMass=0,l.tangentMass=0,l.velocityBias=0,e.localPoints[c].Copy(h.localPoint);return this};goog.exportProperty(box2d.b2ContactSolver.prototype,"Initialize",box2d.b2ContactSolver.prototype.Initialize);
+box2d.b2ContactSolver.prototype.InitializeVelocityConstraints=function(){var a,b,c,d,e,f,g,h,k,l,m,n,p,q,r,u,t,w,x,v,y=box2d.b2ContactSolver.prototype.InitializeVelocityConstraints.s_xfA,z=box2d.b2ContactSolver.prototype.InitializeVelocityConstraints.s_xfB,B=box2d.b2ContactSolver.prototype.InitializeVelocityConstraints.s_worldManifold;a=0;for(b=this.m_count;a<b;++a){e=this.m_velocityConstraints[a];f=this.m_positionConstraints[a];c=f.radiusA;d=f.radiusB;g=this.m_contacts[e.contactIndex].GetManifold();
+h=e.indexA;k=e.indexB;l=e.invMassA;m=e.invMassB;n=e.invIA;p=e.invIB;q=f.localCenterA;r=f.localCenterB;f=this.m_positions[h].c;u=this.m_positions[h].a;t=this.m_velocities[h].v;h=this.m_velocities[h].w;w=this.m_positions[k].c;x=this.m_positions[k].a;v=this.m_velocities[k].v;k=this.m_velocities[k].w;box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<g.pointCount);y.q.SetAngle(u);z.q.SetAngle(x);box2d.b2Sub_V2_V2(f,box2d.b2Mul_R_V2(y.q,q,box2d.b2Vec2.s_t0),y.p);box2d.b2Sub_V2_V2(w,box2d.b2Mul_R_V2(z.q,r,box2d.b2Vec2.s_t0),
+z.p);B.Initialize(g,y,c,z,d);e.normal.Copy(B.normal);box2d.b2Cross_V2_S(e.normal,1,e.tangent);d=e.pointCount;for(c=0;c<d;++c)g=e.points[c],box2d.b2Sub_V2_V2(B.points[c],f,g.rA),box2d.b2Sub_V2_V2(B.points[c],w,g.rB),q=box2d.b2Cross_V2_V2(g.rA,e.normal),r=box2d.b2Cross_V2_V2(g.rB,e.normal),q=l+m+n*q*q+p*r*r,g.normalMass=0<q?1/q:0,r=e.tangent,q=box2d.b2Cross_V2_V2(g.rA,r),r=box2d.b2Cross_V2_V2(g.rB,r),q=l+m+n*q*q+p*r*r,g.tangentMass=0<q?1/q:0,g.velocityBias=0,q=box2d.b2Dot_V2_V2(e.normal,box2d.b2Sub_V2_V2(box2d.b2AddCross_V2_S_V2(v,
+k,g.rB,box2d.b2Vec2.s_t0),box2d.b2AddCross_V2_S_V2(t,h,g.rA,box2d.b2Vec2.s_t1),box2d.b2Vec2.s_t0)),q<-box2d.b2_velocityThreshold&&(g.velocityBias+=-e.restitution*q);2===e.pointCount&&box2d.g_blockSolve&&(t=e.points[0],w=e.points[1],f=box2d.b2Cross_V2_V2(t.rA,e.normal),t=box2d.b2Cross_V2_V2(t.rB,e.normal),h=box2d.b2Cross_V2_V2(w.rA,e.normal),k=box2d.b2Cross_V2_V2(w.rB,e.normal),w=l+m+n*f*f+p*t*t,v=l+m+n*h*h+p*k*k,l=l+m+n*f*h+p*t*k,w*w<1E3*(w*v-l*l)?(e.K.ex.Set(w,l),e.K.ey.Set(l,v),e.K.GetInverse(e.normalMass)):
+e.pointCount=1)}};goog.exportProperty(box2d.b2ContactSolver.prototype,"InitializeVelocityConstraints",box2d.b2ContactSolver.prototype.InitializeVelocityConstraints);box2d.b2ContactSolver.prototype.InitializeVelocityConstraints.s_xfA=new box2d.b2Transform;box2d.b2ContactSolver.prototype.InitializeVelocityConstraints.s_xfB=new box2d.b2Transform;box2d.b2ContactSolver.prototype.InitializeVelocityConstraints.s_worldManifold=new box2d.b2WorldManifold;
+box2d.b2ContactSolver.prototype.WarmStart=function(){var a,b,c,d,e,f,g,h,k,l,m,n,p,q,r,u,t,w,x=box2d.b2ContactSolver.prototype.WarmStart.s_P;a=0;for(b=this.m_count;a<b;++a){e=this.m_velocityConstraints[a];f=e.indexA;g=e.indexB;h=e.invMassA;k=e.invIA;l=e.invMassB;m=e.invIB;d=e.pointCount;n=this.m_velocities[f].v;p=this.m_velocities[f].w;q=this.m_velocities[g].v;r=this.m_velocities[g].w;u=e.normal;t=e.tangent;for(c=0;c<d;++c)w=e.points[c],box2d.b2Add_V2_V2(box2d.b2Mul_S_V2(w.normalImpulse,u,box2d.b2Vec2.s_t0),
+box2d.b2Mul_S_V2(w.tangentImpulse,t,box2d.b2Vec2.s_t1),x),p-=k*box2d.b2Cross_V2_V2(w.rA,x),n.SelfMulSub(h,x),r+=m*box2d.b2Cross_V2_V2(w.rB,x),q.SelfMulAdd(l,x);this.m_velocities[f].w=p;this.m_velocities[g].w=r}};goog.exportProperty(box2d.b2ContactSolver.prototype,"WarmStart",box2d.b2ContactSolver.prototype.WarmStart);box2d.b2ContactSolver.prototype.WarmStart.s_P=new box2d.b2Vec2;
+box2d.b2ContactSolver.prototype.SolveVelocityConstraints=function(){var a,b,c,d,e,f,g,h,k,l,m,n,p,q,r,u,t,w,x,v,y=box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_dv,z=box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_dv1,B=box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_dv2,E,F,G=box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_P,H=box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_a,I=box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_b,C=
+box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_x,A=box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_d,K=box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_P1,J=box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_P2,D=box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_P1P2;a=0;for(b=this.m_count;a<b;++a){e=this.m_velocityConstraints[a];f=e.indexA;g=e.indexB;h=e.invMassA;k=e.invIA;l=e.invMassB;m=e.invIB;n=e.pointCount;p=this.m_velocities[f].v;q=this.m_velocities[f].w;
+r=this.m_velocities[g].v;u=this.m_velocities[g].w;t=e.normal;w=e.tangent;x=e.friction;box2d.ENABLE_ASSERTS&&box2d.b2Assert(1===n||2===n);c=0;for(d=n;c<d;++c)v=e.points[c],box2d.b2Sub_V2_V2(box2d.b2AddCross_V2_S_V2(r,u,v.rB,box2d.b2Vec2.s_t0),box2d.b2AddCross_V2_S_V2(p,q,v.rA,box2d.b2Vec2.s_t1),y),E=box2d.b2Dot_V2_V2(y,w)-e.tangentSpeed,E=v.tangentMass*-E,F=x*v.normalImpulse,F=box2d.b2Clamp(v.tangentImpulse+E,-F,F),E=F-v.tangentImpulse,v.tangentImpulse=F,box2d.b2Mul_S_V2(E,w,G),p.SelfMulSub(h,G),q-=
+k*box2d.b2Cross_V2_V2(v.rA,G),r.SelfMulAdd(l,G),u+=m*box2d.b2Cross_V2_V2(v.rB,G);if(1!==e.pointCount&&box2d.g_blockSolve)for(n=e.points[0],v=e.points[1],H.Set(n.normalImpulse,v.normalImpulse),box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<=H.x&&0<=H.y),box2d.b2Sub_V2_V2(box2d.b2AddCross_V2_S_V2(r,u,n.rB,box2d.b2Vec2.s_t0),box2d.b2AddCross_V2_S_V2(p,q,n.rA,box2d.b2Vec2.s_t1),z),box2d.b2Sub_V2_V2(box2d.b2AddCross_V2_S_V2(r,u,v.rB,box2d.b2Vec2.s_t0),box2d.b2AddCross_V2_S_V2(p,q,v.rA,box2d.b2Vec2.s_t1),B),c=
+box2d.b2Dot_V2_V2(z,t),d=box2d.b2Dot_V2_V2(B,t),I.x=c-n.velocityBias,I.y=d-v.velocityBias,I.SelfSub(box2d.b2Mul_M22_V2(e.K,H,box2d.b2Vec2.s_t0));;){box2d.b2Mul_M22_V2(e.normalMass,I,C).SelfNeg();if(0<=C.x&&0<=C.y){box2d.b2Sub_V2_V2(C,H,A);box2d.b2Mul_S_V2(A.x,t,K);box2d.b2Mul_S_V2(A.y,t,J);box2d.b2Add_V2_V2(K,J,D);p.SelfMulSub(h,D);q-=k*(box2d.b2Cross_V2_V2(n.rA,K)+box2d.b2Cross_V2_V2(v.rA,J));r.SelfMulAdd(l,D);u+=m*(box2d.b2Cross_V2_V2(n.rB,K)+box2d.b2Cross_V2_V2(v.rB,J));n.normalImpulse=C.x;v.normalImpulse=
+C.y;break}C.x=-n.normalMass*I.x;C.y=0;d=e.K.ex.y*C.x+I.y;if(0<=C.x&&0<=d){box2d.b2Sub_V2_V2(C,H,A);box2d.b2Mul_S_V2(A.x,t,K);box2d.b2Mul_S_V2(A.y,t,J);box2d.b2Add_V2_V2(K,J,D);p.SelfMulSub(h,D);q-=k*(box2d.b2Cross_V2_V2(n.rA,K)+box2d.b2Cross_V2_V2(v.rA,J));r.SelfMulAdd(l,D);u+=m*(box2d.b2Cross_V2_V2(n.rB,K)+box2d.b2Cross_V2_V2(v.rB,J));n.normalImpulse=C.x;v.normalImpulse=C.y;break}C.x=0;C.y=-v.normalMass*I.y;c=e.K.ey.x*C.y+I.x;if(0<=C.y&&0<=c){box2d.b2Sub_V2_V2(C,H,A);box2d.b2Mul_S_V2(A.x,t,K);box2d.b2Mul_S_V2(A.y,
+t,J);box2d.b2Add_V2_V2(K,J,D);p.SelfMulSub(h,D);q-=k*(box2d.b2Cross_V2_V2(n.rA,K)+box2d.b2Cross_V2_V2(v.rA,J));r.SelfMulAdd(l,D);u+=m*(box2d.b2Cross_V2_V2(n.rB,K)+box2d.b2Cross_V2_V2(v.rB,J));n.normalImpulse=C.x;v.normalImpulse=C.y;break}C.x=0;C.y=0;c=I.x;d=I.y;if(0<=c&&0<=d){box2d.b2Sub_V2_V2(C,H,A);box2d.b2Mul_S_V2(A.x,t,K);box2d.b2Mul_S_V2(A.y,t,J);box2d.b2Add_V2_V2(K,J,D);p.SelfMulSub(h,D);q-=k*(box2d.b2Cross_V2_V2(n.rA,K)+box2d.b2Cross_V2_V2(v.rA,J));r.SelfMulAdd(l,D);u+=m*(box2d.b2Cross_V2_V2(n.rB,
+K)+box2d.b2Cross_V2_V2(v.rB,J));n.normalImpulse=C.x;v.normalImpulse=C.y;break}break}else for(c=0;c<n;++c)v=e.points[c],box2d.b2Sub_V2_V2(box2d.b2AddCross_V2_S_V2(r,u,v.rB,box2d.b2Vec2.s_t0),box2d.b2AddCross_V2_S_V2(p,q,v.rA,box2d.b2Vec2.s_t1),y),d=box2d.b2Dot_V2_V2(y,t),E=-v.normalMass*(d-v.velocityBias),F=box2d.b2Max(v.normalImpulse+E,0),E=F-v.normalImpulse,v.normalImpulse=F,box2d.b2Mul_S_V2(E,t,G),p.SelfMulSub(h,G),q-=k*box2d.b2Cross_V2_V2(v.rA,G),r.SelfMulAdd(l,G),u+=m*box2d.b2Cross_V2_V2(v.rB,
+G);this.m_velocities[f].w=q;this.m_velocities[g].w=u}};goog.exportProperty(box2d.b2ContactSolver.prototype,"SolveVelocityConstraints",box2d.b2ContactSolver.prototype.SolveVelocityConstraints);box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_dv=new box2d.b2Vec2;box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_dv1=new box2d.b2Vec2;box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_dv2=new box2d.b2Vec2;box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_P=new box2d.b2Vec2;
+box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_a=new box2d.b2Vec2;box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_b=new box2d.b2Vec2;box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_x=new box2d.b2Vec2;box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_d=new box2d.b2Vec2;box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_P1=new box2d.b2Vec2;box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_P2=new box2d.b2Vec2;
+box2d.b2ContactSolver.prototype.SolveVelocityConstraints.s_P1P2=new box2d.b2Vec2;box2d.b2ContactSolver.prototype.StoreImpulses=function(){var a,b,c,d,e,f;a=0;for(b=this.m_count;a<b;++a)for(e=this.m_velocityConstraints[a],f=this.m_contacts[e.contactIndex].GetManifold(),c=0,d=e.pointCount;c<d;++c)f.points[c].normalImpulse=e.points[c].normalImpulse,f.points[c].tangentImpulse=e.points[c].tangentImpulse};goog.exportProperty(box2d.b2ContactSolver.prototype,"StoreImpulses",box2d.b2ContactSolver.prototype.StoreImpulses);
+box2d.b2PositionSolverManifold=function(){this.normal=new box2d.b2Vec2;this.point=new box2d.b2Vec2};goog.exportSymbol("box2d.b2PositionSolverManifold",box2d.b2PositionSolverManifold);box2d.b2PositionSolverManifold.prototype.normal=null;goog.exportProperty(box2d.b2PositionSolverManifold.prototype,"normal",box2d.b2PositionSolverManifold.prototype.normal);box2d.b2PositionSolverManifold.prototype.point=null;goog.exportProperty(box2d.b2PositionSolverManifold.prototype,"point",box2d.b2PositionSolverManifold.prototype.point);
+box2d.b2PositionSolverManifold.prototype.separation=0;goog.exportProperty(box2d.b2PositionSolverManifold.prototype,"separation",box2d.b2PositionSolverManifold.prototype.separation);
+box2d.b2PositionSolverManifold.prototype.Initialize=function(a,b,c,d){var e=box2d.b2PositionSolverManifold.prototype.Initialize.s_pointA,f=box2d.b2PositionSolverManifold.prototype.Initialize.s_pointB,g=box2d.b2PositionSolverManifold.prototype.Initialize.s_planePoint,h=box2d.b2PositionSolverManifold.prototype.Initialize.s_clipPoint;box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<a.pointCount);switch(a.type){case box2d.b2ManifoldType.e_circles:box2d.b2Mul_X_V2(b,a.localPoint,e);box2d.b2Mul_X_V2(c,a.localPoints[0],
+f);box2d.b2Sub_V2_V2(f,e,this.normal).SelfNormalize();box2d.b2Mid_V2_V2(e,f,this.point);this.separation=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(f,e,box2d.b2Vec2.s_t0),this.normal)-a.radiusA-a.radiusB;break;case box2d.b2ManifoldType.e_faceA:box2d.b2Mul_R_V2(b.q,a.localNormal,this.normal);box2d.b2Mul_X_V2(b,a.localPoint,g);box2d.b2Mul_X_V2(c,a.localPoints[d],h);this.separation=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(h,g,box2d.b2Vec2.s_t0),this.normal)-a.radiusA-a.radiusB;this.point.Copy(h);break;case box2d.b2ManifoldType.e_faceB:box2d.b2Mul_R_V2(c.q,
+a.localNormal,this.normal),box2d.b2Mul_X_V2(c,a.localPoint,g),box2d.b2Mul_X_V2(b,a.localPoints[d],h),this.separation=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(h,g,box2d.b2Vec2.s_t0),this.normal)-a.radiusA-a.radiusB,this.point.Copy(h),this.normal.SelfNeg()}};goog.exportProperty(box2d.b2PositionSolverManifold.prototype,"Initialize",box2d.b2PositionSolverManifold.prototype.Initialize);box2d.b2PositionSolverManifold.prototype.Initialize.s_pointA=new box2d.b2Vec2;
+box2d.b2PositionSolverManifold.prototype.Initialize.s_pointB=new box2d.b2Vec2;box2d.b2PositionSolverManifold.prototype.Initialize.s_planePoint=new box2d.b2Vec2;box2d.b2PositionSolverManifold.prototype.Initialize.s_clipPoint=new box2d.b2Vec2;
+box2d.b2ContactSolver.prototype.SolvePositionConstraints=function(){var a,b,c,d,e,f,g,h,k,l,m,n,p,q,r,u,t,w=box2d.b2ContactSolver.prototype.SolvePositionConstraints.s_xfA,x=box2d.b2ContactSolver.prototype.SolvePositionConstraints.s_xfB,v=box2d.b2ContactSolver.prototype.SolvePositionConstraints.s_psm,y,z,B,E=box2d.b2ContactSolver.prototype.SolvePositionConstraints.s_rA,F=box2d.b2ContactSolver.prototype.SolvePositionConstraints.s_rB,G,H=box2d.b2ContactSolver.prototype.SolvePositionConstraints.s_P,I=
+0;a=0;for(b=this.m_count;a<b;++a){e=this.m_positionConstraints[a];f=e.indexA;g=e.indexB;h=e.localCenterA;k=e.invMassA;l=e.invIA;m=e.localCenterB;n=e.invMassB;p=e.invIB;d=e.pointCount;q=this.m_positions[f].c;r=this.m_positions[f].a;u=this.m_positions[g].c;t=this.m_positions[g].a;for(c=0;c<d;++c)w.q.SetAngle(r),x.q.SetAngle(t),box2d.b2Sub_V2_V2(q,box2d.b2Mul_R_V2(w.q,h,box2d.b2Vec2.s_t0),w.p),box2d.b2Sub_V2_V2(u,box2d.b2Mul_R_V2(x.q,m,box2d.b2Vec2.s_t0),x.p),v.Initialize(e,w,x,c),y=v.normal,z=v.point,
+B=v.separation,box2d.b2Sub_V2_V2(z,q,E),box2d.b2Sub_V2_V2(z,u,F),I=box2d.b2Min(I,B),z=box2d.b2Clamp(box2d.b2_baumgarte*(B+box2d.b2_linearSlop),-box2d.b2_maxLinearCorrection,0),B=box2d.b2Cross_V2_V2(E,y),G=box2d.b2Cross_V2_V2(F,y),B=k+n+l*B*B+p*G*G,z=0<B?-z/B:0,box2d.b2Mul_S_V2(z,y,H),q.SelfMulSub(k,H),r-=l*box2d.b2Cross_V2_V2(E,H),u.SelfMulAdd(n,H),t+=p*box2d.b2Cross_V2_V2(F,H);this.m_positions[f].a=r;this.m_positions[g].a=t}return I>-3*box2d.b2_linearSlop};
+goog.exportProperty(box2d.b2ContactSolver.prototype,"SolvePositionConstraints",box2d.b2ContactSolver.prototype.SolvePositionConstraints);box2d.b2ContactSolver.prototype.SolvePositionConstraints.s_xfA=new box2d.b2Transform;box2d.b2ContactSolver.prototype.SolvePositionConstraints.s_xfB=new box2d.b2Transform;box2d.b2ContactSolver.prototype.SolvePositionConstraints.s_psm=new box2d.b2PositionSolverManifold;box2d.b2ContactSolver.prototype.SolvePositionConstraints.s_rA=new box2d.b2Vec2;
+box2d.b2ContactSolver.prototype.SolvePositionConstraints.s_rB=new box2d.b2Vec2;box2d.b2ContactSolver.prototype.SolvePositionConstraints.s_P=new box2d.b2Vec2;
+box2d.b2ContactSolver.prototype.SolveTOIPositionConstraints=function(a,b){var c,d,e,f,g,h,k,l,m,n,p,q,r,u,t,w,x,v=box2d.b2ContactSolver.prototype.SolveTOIPositionConstraints.s_xfA,y=box2d.b2ContactSolver.prototype.SolveTOIPositionConstraints.s_xfB,z=box2d.b2ContactSolver.prototype.SolveTOIPositionConstraints.s_psm,B,E,F,G=box2d.b2ContactSolver.prototype.SolveTOIPositionConstraints.s_rA,H=box2d.b2ContactSolver.prototype.SolveTOIPositionConstraints.s_rB,I,C=box2d.b2ContactSolver.prototype.SolveTOIPositionConstraints.s_P,
+A=0;c=0;for(d=this.m_count;c<d;++c){g=this.m_positionConstraints[c];h=g.indexA;k=g.indexB;l=g.localCenterA;m=g.localCenterB;f=g.pointCount;p=n=0;if(h===a||h===b)n=g.invMassA,p=g.invIA;r=q=0;if(k===a||k===b)q=g.invMassB,r=g.invIB;u=this.m_positions[h].c;t=this.m_positions[h].a;w=this.m_positions[k].c;x=this.m_positions[k].a;for(e=0;e<f;++e)v.q.SetAngle(t),y.q.SetAngle(x),box2d.b2Sub_V2_V2(u,box2d.b2Mul_R_V2(v.q,l,box2d.b2Vec2.s_t0),v.p),box2d.b2Sub_V2_V2(w,box2d.b2Mul_R_V2(y.q,m,box2d.b2Vec2.s_t0),
+y.p),z.Initialize(g,v,y,e),B=z.normal,E=z.point,F=z.separation,box2d.b2Sub_V2_V2(E,u,G),box2d.b2Sub_V2_V2(E,w,H),A=box2d.b2Min(A,F),E=box2d.b2Clamp(box2d.b2_toiBaumgarte*(F+box2d.b2_linearSlop),-box2d.b2_maxLinearCorrection,0),F=box2d.b2Cross_V2_V2(G,B),I=box2d.b2Cross_V2_V2(H,B),F=n+q+p*F*F+r*I*I,E=0<F?-E/F:0,box2d.b2Mul_S_V2(E,B,C),u.SelfMulSub(n,C),t-=p*box2d.b2Cross_V2_V2(G,C),w.SelfMulAdd(q,C),x+=r*box2d.b2Cross_V2_V2(H,C);this.m_positions[h].a=t;this.m_positions[k].a=x}return A>=-1.5*box2d.b2_linearSlop};
+goog.exportProperty(box2d.b2ContactSolver.prototype,"SolveTOIPositionConstraints",box2d.b2ContactSolver.prototype.SolveTOIPositionConstraints);box2d.b2ContactSolver.prototype.SolveTOIPositionConstraints.s_xfA=new box2d.b2Transform;box2d.b2ContactSolver.prototype.SolveTOIPositionConstraints.s_xfB=new box2d.b2Transform;box2d.b2ContactSolver.prototype.SolveTOIPositionConstraints.s_psm=new box2d.b2PositionSolverManifold;box2d.b2ContactSolver.prototype.SolveTOIPositionConstraints.s_rA=new box2d.b2Vec2;
+box2d.b2ContactSolver.prototype.SolveTOIPositionConstraints.s_rB=new box2d.b2Vec2;box2d.b2ContactSolver.prototype.SolveTOIPositionConstraints.s_P=new box2d.b2Vec2;box2d.b2Island=function(){this.m_bodies=Array(1024);this.m_contacts=Array(1024);this.m_joints=Array(1024);this.m_positions=box2d.b2Position.MakeArray(1024);this.m_velocities=box2d.b2Velocity.MakeArray(1024)};goog.exportSymbol("box2d.b2Island",box2d.b2Island);box2d.b2Island.prototype.m_allocator=null;goog.exportProperty(box2d.b2Island.prototype,"m_allocator",box2d.b2Island.prototype.m_allocator);box2d.b2Island.prototype.m_listener=null;goog.exportProperty(box2d.b2Island.prototype,"m_listener",box2d.b2Island.prototype.m_listener);
+box2d.b2Island.prototype.m_bodies=null;goog.exportProperty(box2d.b2Island.prototype,"m_bodies",box2d.b2Island.prototype.m_bodies);box2d.b2Island.prototype.m_contacts=null;goog.exportProperty(box2d.b2Island.prototype,"m_contacts",box2d.b2Island.prototype.m_contacts);box2d.b2Island.prototype.m_joints=null;goog.exportProperty(box2d.b2Island.prototype,"m_joints",box2d.b2Island.prototype.m_joints);box2d.b2Island.prototype.m_positions=null;goog.exportProperty(box2d.b2Island.prototype,"m_positions",box2d.b2Island.prototype.m_positions);
+box2d.b2Island.prototype.m_velocities=null;goog.exportProperty(box2d.b2Island.prototype,"m_velocities",box2d.b2Island.prototype.m_velocities);box2d.b2Island.prototype.m_bodyCount=0;goog.exportProperty(box2d.b2Island.prototype,"m_bodyCount",box2d.b2Island.prototype.m_bodyCount);box2d.b2Island.prototype.m_jointCount=0;goog.exportProperty(box2d.b2Island.prototype,"m_jointCount",box2d.b2Island.prototype.m_jointCount);box2d.b2Island.prototype.m_contactCount=0;
+goog.exportProperty(box2d.b2Island.prototype,"m_contactCount",box2d.b2Island.prototype.m_contactCount);box2d.b2Island.prototype.m_bodyCapacity=0;goog.exportProperty(box2d.b2Island.prototype,"m_bodyCapacity",box2d.b2Island.prototype.m_bodyCapacity);box2d.b2Island.prototype.m_contactCapacity=0;goog.exportProperty(box2d.b2Island.prototype,"m_contactCapacity",box2d.b2Island.prototype.m_contactCapacity);box2d.b2Island.prototype.m_jointCapacity=0;
+goog.exportProperty(box2d.b2Island.prototype,"m_jointCapacity",box2d.b2Island.prototype.m_jointCapacity);
+box2d.b2Island.prototype.Initialize=function(a,b,c,d,e){this.m_bodyCapacity=a;this.m_contactCapacity=b;this.m_jointCapacity=c;this.m_jointCount=this.m_contactCount=this.m_bodyCount=0;this.m_allocator=d;for(this.m_listener=e;this.m_bodies.length<a;)this.m_bodies[this.m_bodies.length]=null;for(;this.m_contacts.length<b;)this.m_contacts[this.m_contacts.length]=null;for(;this.m_joints.length<c;)this.m_joints[this.m_joints.length]=null;if(this.m_positions.length<a)for(b=box2d.b2Max(2*this.m_positions.length,
+a),box2d.DEBUG&&window.console.log("box2d.b2Island.m_positions: "+b);this.m_positions.length<b;)this.m_positions[this.m_positions.length]=new box2d.b2Position;if(this.m_velocities.length<a)for(b=box2d.b2Max(2*this.m_velocities.length,a),box2d.DEBUG&&window.console.log("box2d.b2Island.m_velocities: "+b);this.m_velocities.length<b;)this.m_velocities[this.m_velocities.length]=new box2d.b2Velocity};goog.exportProperty(box2d.b2Island.prototype,"Initialize",box2d.b2Island.prototype.Initialize);
+box2d.b2Island.prototype.Clear=function(){this.m_jointCount=this.m_contactCount=this.m_bodyCount=0};goog.exportProperty(box2d.b2Island.prototype,"Clear",box2d.b2Island.prototype.Clear);box2d.b2Island.prototype.AddBody=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(this.m_bodyCount<this.m_bodyCapacity);a.m_islandIndex=this.m_bodyCount;this.m_bodies[this.m_bodyCount++]=a};goog.exportProperty(box2d.b2Island.prototype,"AddBody",box2d.b2Island.prototype.AddBody);
+box2d.b2Island.prototype.AddContact=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(this.m_contactCount<this.m_contactCapacity);this.m_contacts[this.m_contactCount++]=a};goog.exportProperty(box2d.b2Island.prototype,"AddContact",box2d.b2Island.prototype.AddContact);box2d.b2Island.prototype.AddJoint=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(this.m_jointCount<this.m_jointCapacity);this.m_joints[this.m_jointCount++]=a};goog.exportProperty(box2d.b2Island.prototype,"AddJoint",box2d.b2Island.prototype.AddJoint);
+box2d.b2Island.prototype.Solve=function(a,b,c,d){for(var e=box2d.b2Island.s_timer.Reset(),f=b.dt,g=0;g<this.m_bodyCount;++g){var h=this.m_bodies[g],k=this.m_positions[g].c.Copy(h.m_sweep.c),l=h.m_sweep.a,m=this.m_velocities[g].v.Copy(h.m_linearVelocity),n=h.m_angularVelocity;h.m_sweep.c0.Copy(h.m_sweep.c);h.m_sweep.a0=h.m_sweep.a;h.m_type===box2d.b2BodyType.b2_dynamicBody&&(m.x+=f*(h.m_gravityScale*c.x+h.m_invMass*h.m_force.x),m.y+=f*(h.m_gravityScale*c.y+h.m_invMass*h.m_force.y),n+=f*h.m_invI*h.m_torque,
+m.SelfMul(1/(1+f*h.m_linearDamping)),n*=1/(1+f*h.m_angularDamping));this.m_positions[g].a=l;this.m_velocities[g].w=n}e.Reset();h=box2d.b2Island.s_solverData;h.step.Copy(b);h.positions=this.m_positions;h.velocities=this.m_velocities;g=box2d.b2Island.s_contactSolverDef;g.step.Copy(b);g.contacts=this.m_contacts;g.count=this.m_contactCount;g.positions=this.m_positions;g.velocities=this.m_velocities;g.allocator=this.m_allocator;c=box2d.b2Island.s_contactSolver.Initialize(g);c.InitializeVelocityConstraints();
+b.warmStarting&&c.WarmStart();for(g=0;g<this.m_jointCount;++g)this.m_joints[g].InitVelocityConstraints(h);a.solveInit=e.GetMilliseconds();e.Reset();for(g=0;g<b.velocityIterations;++g){for(l=0;l<this.m_jointCount;++l)this.m_joints[l].SolveVelocityConstraints(h);c.SolveVelocityConstraints()}c.StoreImpulses();a.solveVelocity=e.GetMilliseconds();for(g=0;g<this.m_bodyCount;++g){var k=this.m_positions[g].c,l=this.m_positions[g].a,m=this.m_velocities[g].v,n=this.m_velocities[g].w,p=box2d.b2Mul_S_V2(f,m,
+box2d.b2Island.s_translation);box2d.b2Dot_V2_V2(p,p)>box2d.b2_maxTranslationSquared&&(p=box2d.b2_maxTranslation/p.Length(),m.SelfMul(p));p=f*n;p*p>box2d.b2_maxRotationSquared&&(p=box2d.b2_maxRotation/box2d.b2Abs(p),n*=p);k.x+=f*m.x;k.y+=f*m.y;l+=f*n;this.m_positions[g].a=l;this.m_velocities[g].w=n}e.Reset();k=!1;for(g=0;g<b.positionIterations;++g){m=c.SolvePositionConstraints();n=!0;for(l=0;l<this.m_jointCount;++l)p=this.m_joints[l].SolvePositionConstraints(h),n=n&&p;if(m&&n){k=!0;break}}for(g=0;g<
+this.m_bodyCount;++g)b=this.m_bodies[g],b.m_sweep.c.Copy(this.m_positions[g].c),b.m_sweep.a=this.m_positions[g].a,b.m_linearVelocity.Copy(this.m_velocities[g].v),b.m_angularVelocity=this.m_velocities[g].w,b.SynchronizeTransform();a.solvePosition=e.GetMilliseconds();this.Report(c.m_velocityConstraints);if(d){a=box2d.b2_maxFloat;d=box2d.b2_linearSleepTolerance*box2d.b2_linearSleepTolerance;e=box2d.b2_angularSleepTolerance*box2d.b2_angularSleepTolerance;for(g=0;g<this.m_bodyCount;++g)h=this.m_bodies[g],
+h.GetType()!==box2d.b2BodyType.b2_staticBody&&(!h.m_flag_autoSleepFlag||h.m_angularVelocity*h.m_angularVelocity>e||box2d.b2Dot_V2_V2(h.m_linearVelocity,h.m_linearVelocity)>d?a=h.m_sleepTime=0:(h.m_sleepTime+=f,a=box2d.b2Min(a,h.m_sleepTime)));if(a>=box2d.b2_timeToSleep&&k)for(g=0;g<this.m_bodyCount;++g)h=this.m_bodies[g],h.SetAwake(!1)}};goog.exportProperty(box2d.b2Island.prototype,"Solve",box2d.b2Island.prototype.Solve);
+box2d.b2Island.prototype.SolveTOI=function(a,b,c){box2d.ENABLE_ASSERTS&&box2d.b2Assert(b<this.m_bodyCount);box2d.ENABLE_ASSERTS&&box2d.b2Assert(c<this.m_bodyCount);for(var d=0;d<this.m_bodyCount;++d){var e=this.m_bodies[d];this.m_positions[d].c.Copy(e.m_sweep.c);this.m_positions[d].a=e.m_sweep.a;this.m_velocities[d].v.Copy(e.m_linearVelocity);this.m_velocities[d].w=e.m_angularVelocity}d=box2d.b2Island.s_contactSolverDef;d.contacts=this.m_contacts;d.count=this.m_contactCount;d.allocator=this.m_allocator;
+d.step.Copy(a);d.positions=this.m_positions;d.velocities=this.m_velocities;e=box2d.b2Island.s_contactSolver.Initialize(d);for(d=0;d<a.positionIterations&&!e.SolveTOIPositionConstraints(b,c);++d);this.m_bodies[b].m_sweep.c0.Copy(this.m_positions[b].c);this.m_bodies[b].m_sweep.a0=this.m_positions[b].a;this.m_bodies[c].m_sweep.c0.Copy(this.m_positions[c].c);this.m_bodies[c].m_sweep.a0=this.m_positions[c].a;e.InitializeVelocityConstraints();for(d=0;d<a.velocityIterations;++d)e.SolveVelocityConstraints();
+a=a.dt;for(d=0;d<this.m_bodyCount;++d){b=this.m_positions[d].c;c=this.m_positions[d].a;var f=this.m_velocities[d].v,g=this.m_velocities[d].w,h=box2d.b2Mul_S_V2(a,f,box2d.b2Island.s_translation);box2d.b2Dot_V2_V2(h,h)>box2d.b2_maxTranslationSquared&&(h=box2d.b2_maxTranslation/h.Length(),f.SelfMul(h));h=a*g;h*h>box2d.b2_maxRotationSquared&&(h=box2d.b2_maxRotation/box2d.b2Abs(h),g*=h);b.SelfMulAdd(a,f);c+=a*g;this.m_positions[d].a=c;this.m_velocities[d].w=g;h=this.m_bodies[d];h.m_sweep.c.Copy(b);h.m_sweep.a=
+c;h.m_linearVelocity.Copy(f);h.m_angularVelocity=g;h.SynchronizeTransform()}this.Report(e.m_velocityConstraints)};goog.exportProperty(box2d.b2Island.prototype,"SolveTOI",box2d.b2Island.prototype.SolveTOI);
+box2d.b2Island.prototype.Report=function(a){if(null!==this.m_listener)for(var b=0;b<this.m_contactCount;++b){var c=this.m_contacts[b];if(c){var d=a[b],e=box2d.b2Island.s_impulse;e.count=d.pointCount;for(var f=0;f<d.pointCount;++f)e.normalImpulses[f]=d.points[f].normalImpulse,e.tangentImpulses[f]=d.points[f].tangentImpulse;this.m_listener.PostSolve(c,e)}}};goog.exportProperty(box2d.b2Island.prototype,"Report",box2d.b2Island.prototype.Report);box2d.b2Island.s_timer=new box2d.b2Timer;
+box2d.b2Island.s_solverData=new box2d.b2SolverData;box2d.b2Island.s_contactSolverDef=new box2d.b2ContactSolverDef;box2d.b2Island.s_contactSolver=new box2d.b2ContactSolver;box2d.b2Island.s_translation=new box2d.b2Vec2;box2d.b2Island.s_impulse=new box2d.b2ContactImpulse;box2d.b2JointType={e_unknownJoint:0,e_revoluteJoint:1,e_prismaticJoint:2,e_distanceJoint:3,e_pulleyJoint:4,e_mouseJoint:5,e_gearJoint:6,e_wheelJoint:7,e_weldJoint:8,e_frictionJoint:9,e_ropeJoint:10,e_motorJoint:11,e_areaJoint:12};goog.exportSymbol("box2d.b2JointType",box2d.b2JointType);goog.exportProperty(box2d.b2JointType,"e_unknownJoint",box2d.b2JointType.e_unknownJoint);goog.exportProperty(box2d.b2JointType,"e_revoluteJoint",box2d.b2JointType.e_revoluteJoint);
+goog.exportProperty(box2d.b2JointType,"e_prismaticJoint",box2d.b2JointType.e_prismaticJoint);goog.exportProperty(box2d.b2JointType,"e_distanceJoint",box2d.b2JointType.e_distanceJoint);goog.exportProperty(box2d.b2JointType,"e_pulleyJoint",box2d.b2JointType.e_pulleyJoint);goog.exportProperty(box2d.b2JointType,"e_mouseJoint",box2d.b2JointType.e_mouseJoint);goog.exportProperty(box2d.b2JointType,"e_gearJoint",box2d.b2JointType.e_gearJoint);goog.exportProperty(box2d.b2JointType,"e_wheelJoint",box2d.b2JointType.e_wheelJoint);
+goog.exportProperty(box2d.b2JointType,"e_weldJoint",box2d.b2JointType.e_weldJoint);goog.exportProperty(box2d.b2JointType,"e_frictionJoint",box2d.b2JointType.e_frictionJoint);goog.exportProperty(box2d.b2JointType,"e_ropeJoint",box2d.b2JointType.e_ropeJoint);goog.exportProperty(box2d.b2JointType,"e_motorJoint",box2d.b2JointType.e_motorJoint);goog.exportProperty(box2d.b2JointType,"e_areaJoint",box2d.b2JointType.e_areaJoint);box2d.b2LimitState={e_inactiveLimit:0,e_atLowerLimit:1,e_atUpperLimit:2,e_equalLimits:3};
+goog.exportSymbol("box2d.b2LimitState",box2d.b2LimitState);goog.exportProperty(box2d.b2LimitState,"e_inactiveLimit",box2d.b2LimitState.e_inactiveLimit);goog.exportProperty(box2d.b2LimitState,"e_atLowerLimit",box2d.b2LimitState.e_atLowerLimit);goog.exportProperty(box2d.b2LimitState,"e_atUpperLimit",box2d.b2LimitState.e_atUpperLimit);goog.exportProperty(box2d.b2LimitState,"e_equalLimits",box2d.b2LimitState.e_equalLimits);box2d.b2Jacobian=function(){this.linear=new box2d.b2Vec2};
+goog.exportSymbol("box2d.b2Jacobian",box2d.b2Jacobian);box2d.b2Jacobian.prototype.linear=null;goog.exportProperty(box2d.b2Jacobian.prototype,"linear",box2d.b2Jacobian.prototype.linear);box2d.b2Jacobian.prototype.angularA=0;goog.exportProperty(box2d.b2Jacobian.prototype,"angularA",box2d.b2Jacobian.prototype.angularA);box2d.b2Jacobian.prototype.angularB=0;goog.exportProperty(box2d.b2Jacobian.prototype,"angularB",box2d.b2Jacobian.prototype.angularB);
+box2d.b2Jacobian.prototype.SetZero=function(){this.linear.SetZero();this.angularB=this.angularA=0;return this};goog.exportProperty(box2d.b2Jacobian.prototype,"SetZero",box2d.b2Jacobian.prototype.SetZero);box2d.b2Jacobian.prototype.Set=function(a,b,c){this.linear.Copy(a);this.angularA=b;this.angularB=c;return this};goog.exportProperty(box2d.b2Jacobian.prototype,"Set",box2d.b2Jacobian.prototype.Set);box2d.b2JointEdge=function(){};goog.exportSymbol("box2d.b2JointEdge",box2d.b2JointEdge);
+box2d.b2JointEdge.prototype.other=null;goog.exportProperty(box2d.b2JointEdge.prototype,"other",box2d.b2JointEdge.prototype.other);box2d.b2JointEdge.prototype.joint=null;goog.exportProperty(box2d.b2JointEdge.prototype,"joint",box2d.b2JointEdge.prototype.joint);box2d.b2JointEdge.prototype.prev=null;goog.exportProperty(box2d.b2JointEdge.prototype,"prev",box2d.b2JointEdge.prototype.prev);box2d.b2JointEdge.prototype.next=null;goog.exportProperty(box2d.b2JointEdge.prototype,"next",box2d.b2JointEdge.prototype.next);
+box2d.b2JointDef=function(a){this.type=a};goog.exportSymbol("box2d.b2JointDef",box2d.b2JointDef);box2d.b2JointDef.prototype.type=box2d.b2JointType.e_unknownJoint;goog.exportProperty(box2d.b2JointDef.prototype,"type",box2d.b2JointDef.prototype.type);box2d.b2JointDef.prototype.userData=null;goog.exportProperty(box2d.b2JointDef.prototype,"userData",box2d.b2JointDef.prototype.userData);box2d.b2JointDef.prototype.bodyA=null;goog.exportProperty(box2d.b2JointDef.prototype,"bodyA",box2d.b2JointDef.prototype.bodyA);
+box2d.b2JointDef.prototype.bodyB=null;goog.exportProperty(box2d.b2JointDef.prototype,"bodyB",box2d.b2JointDef.prototype.bodyB);box2d.b2JointDef.prototype.collideConnected=!1;goog.exportProperty(box2d.b2JointDef.prototype,"collideConnected",box2d.b2JointDef.prototype.collideConnected);
+box2d.b2Joint=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(a.bodyA!==a.bodyB);this.m_type=a.type;this.m_edgeA=new box2d.b2JointEdge;this.m_edgeB=new box2d.b2JointEdge;this.m_bodyA=a.bodyA;this.m_bodyB=a.bodyB;this.m_collideConnected=a.collideConnected;this.m_userData=a.userData};goog.exportSymbol("box2d.b2Joint",box2d.b2Joint);box2d.b2Joint.prototype.m_type=box2d.b2JointType.e_unknownJoint;goog.exportProperty(box2d.b2Joint.prototype,"m_type",box2d.b2Joint.prototype.m_type);
+box2d.b2Joint.prototype.m_prev=null;goog.exportProperty(box2d.b2Joint.prototype,"m_prev",box2d.b2Joint.prototype.m_prev);box2d.b2Joint.prototype.m_next=null;goog.exportProperty(box2d.b2Joint.prototype,"m_next",box2d.b2Joint.prototype.m_next);box2d.b2Joint.prototype.m_edgeA=null;goog.exportProperty(box2d.b2Joint.prototype,"m_edgeA",box2d.b2Joint.prototype.m_edgeA);box2d.b2Joint.prototype.m_edgeB=null;goog.exportProperty(box2d.b2Joint.prototype,"m_edgeB",box2d.b2Joint.prototype.m_edgeB);
+box2d.b2Joint.prototype.m_bodyA=null;goog.exportProperty(box2d.b2Joint.prototype,"m_bodyA",box2d.b2Joint.prototype.m_bodyA);box2d.b2Joint.prototype.m_bodyB=null;goog.exportProperty(box2d.b2Joint.prototype,"m_bodyB",box2d.b2Joint.prototype.m_bodyB);box2d.b2Joint.prototype.m_index=0;goog.exportProperty(box2d.b2Joint.prototype,"m_index",box2d.b2Joint.prototype.m_index);box2d.b2Joint.prototype.m_islandFlag=!1;goog.exportProperty(box2d.b2Joint.prototype,"m_islandFlag",box2d.b2Joint.prototype.m_islandFlag);
+box2d.b2Joint.prototype.m_collideConnected=!1;goog.exportProperty(box2d.b2Joint.prototype,"m_collideConnected",box2d.b2Joint.prototype.m_collideConnected);box2d.b2Joint.prototype.m_userData=null;goog.exportProperty(box2d.b2Joint.prototype,"m_userData",box2d.b2Joint.prototype.m_userData);box2d.b2Joint.prototype.GetAnchorA=function(a){return a.SetZero()};goog.exportProperty(box2d.b2Joint.prototype,"GetAnchorA",box2d.b2Joint.prototype.GetAnchorA);box2d.b2Joint.prototype.GetAnchorB=function(a){return a.SetZero()};
+goog.exportProperty(box2d.b2Joint.prototype,"GetAnchorB",box2d.b2Joint.prototype.GetAnchorB);box2d.b2Joint.prototype.GetReactionForce=function(a,b){return b.SetZero()};goog.exportProperty(box2d.b2Joint.prototype,"GetReactionForce",box2d.b2Joint.prototype.GetReactionForce);box2d.b2Joint.prototype.GetReactionTorque=function(a){return 0};goog.exportProperty(box2d.b2Joint.prototype,"GetReactionTorque",box2d.b2Joint.prototype.GetReactionTorque);box2d.b2Joint.prototype.InitVelocityConstraints=function(a){};
+goog.exportProperty(box2d.b2Joint.prototype,"InitVelocityConstraints",box2d.b2Joint.prototype.InitVelocityConstraints);box2d.b2Joint.prototype.SolveVelocityConstraints=function(a){};goog.exportProperty(box2d.b2Joint.prototype,"SolveVelocityConstraints",box2d.b2Joint.prototype.SolveVelocityConstraints);box2d.b2Joint.prototype.SolvePositionConstraints=function(a){return!1};goog.exportProperty(box2d.b2Joint.prototype,"SolvePositionConstraints",box2d.b2Joint.prototype.SolvePositionConstraints);
+box2d.b2Joint.prototype.GetType=function(){return this.m_type};goog.exportProperty(box2d.b2Joint.prototype,"GetType",box2d.b2Joint.prototype.GetType);box2d.b2Joint.prototype.GetBodyA=function(){return this.m_bodyA};goog.exportProperty(box2d.b2Joint.prototype,"GetBodyA",box2d.b2Joint.prototype.GetBodyA);box2d.b2Joint.prototype.GetBodyB=function(){return this.m_bodyB};goog.exportProperty(box2d.b2Joint.prototype,"GetBodyB",box2d.b2Joint.prototype.GetBodyB);box2d.b2Joint.prototype.GetNext=function(){return this.m_next};
+goog.exportProperty(box2d.b2Joint.prototype,"GetNext",box2d.b2Joint.prototype.GetNext);box2d.b2Joint.prototype.GetUserData=function(){return this.m_userData};goog.exportProperty(box2d.b2Joint.prototype,"GetUserData",box2d.b2Joint.prototype.GetUserData);box2d.b2Joint.prototype.SetUserData=function(a){this.m_userData=a};goog.exportProperty(box2d.b2Joint.prototype,"SetUserData",box2d.b2Joint.prototype.SetUserData);box2d.b2Joint.prototype.GetCollideConnected=function(){return this.m_collideConnected};
+goog.exportProperty(box2d.b2Joint.prototype,"GetCollideConnected",box2d.b2Joint.prototype.GetCollideConnected);box2d.b2Joint.prototype.Dump=function(){box2d.DEBUG&&box2d.b2Log("// Dump is not supported for this joint type.\n")};goog.exportProperty(box2d.b2Joint.prototype,"Dump",box2d.b2Joint.prototype.Dump);box2d.b2Joint.prototype.IsActive=function(){return this.m_bodyA.IsActive()&&this.m_bodyB.IsActive()};goog.exportProperty(box2d.b2Joint.prototype,"IsActive",box2d.b2Joint.prototype.IsActive);
+box2d.b2Joint.prototype.ShiftOrigin=function(a){};goog.exportProperty(box2d.b2Joint.prototype,"ShiftOrigin",box2d.b2Joint.prototype.ShiftOrigin);box2d.b2AreaJointDef=function(){box2d.b2JointDef.call(this,box2d.b2JointType.e_areaJoint);this.bodies=[]};goog.inherits(box2d.b2AreaJointDef,box2d.b2JointDef);goog.exportSymbol("box2d.b2AreaJointDef",box2d.b2AreaJointDef);box2d.b2AreaJointDef.prototype.world=null;goog.exportProperty(box2d.b2AreaJointDef.prototype,"world",box2d.b2AreaJointDef.prototype.world);box2d.b2AreaJointDef.prototype.bodies=null;goog.exportProperty(box2d.b2AreaJointDef.prototype,"bodies",box2d.b2AreaJointDef.prototype.bodies);
+box2d.b2AreaJointDef.prototype.frequencyHz=0;goog.exportProperty(box2d.b2AreaJointDef.prototype,"frequencyHz",box2d.b2AreaJointDef.prototype.frequencyHz);box2d.b2AreaJointDef.prototype.dampingRatio=0;goog.exportProperty(box2d.b2AreaJointDef.prototype,"dampingRatio",box2d.b2AreaJointDef.prototype.dampingRatio);box2d.b2AreaJointDef.prototype.AddBody=function(a){this.bodies.push(a);1===this.bodies.length?this.bodyA=a:2===this.bodies.length&&(this.bodyB=a)};
+goog.exportProperty(box2d.b2AreaJointDef.prototype,"AddBody",box2d.b2AreaJointDef.prototype.AddBody);
+box2d.b2AreaJoint=function(a){box2d.b2Joint.call(this,a);box2d.ENABLE_ASSERTS&&box2d.b2Assert(3<=a.bodies.length,"You cannot create an area joint with less than three bodies.");this.m_bodies=a.bodies;this.m_frequencyHz=a.frequencyHz;this.m_dampingRatio=a.dampingRatio;this.m_targetLengths=box2d.b2MakeNumberArray(a.bodies.length);this.m_normals=box2d.b2Vec2.MakeArray(a.bodies.length);this.m_joints=Array(a.bodies.length);this.m_deltas=box2d.b2Vec2.MakeArray(a.bodies.length);this.m_delta=new box2d.b2Vec2;
+var b=new box2d.b2DistanceJointDef;b.frequencyHz=a.frequencyHz;b.dampingRatio=a.dampingRatio;for(var c=this.m_targetArea=0,d=this.m_bodies.length;c<d;++c){var e=this.m_bodies[c],f=this.m_bodies[(c+1)%d],g=e.GetWorldCenter(),h=f.GetWorldCenter();this.m_targetLengths[c]=box2d.b2Distance(g,h);this.m_targetArea+=box2d.b2Cross_V2_V2(g,h);b.Initialize(e,f,g,h);this.m_joints[c]=a.world.CreateJoint(b)}this.m_targetArea*=.5};goog.inherits(box2d.b2AreaJoint,box2d.b2Joint);
+goog.exportSymbol("box2d.b2AreaJoint",box2d.b2AreaJoint);box2d.b2AreaJoint.prototype.m_bodies=null;goog.exportProperty(box2d.b2AreaJoint.prototype,"m_bodies",box2d.b2AreaJoint.prototype.m_bodies);box2d.b2AreaJoint.prototype.m_frequencyHz=0;goog.exportProperty(box2d.b2AreaJoint.prototype,"m_frequencyHz",box2d.b2AreaJoint.prototype.m_frequencyHz);box2d.b2AreaJoint.prototype.m_dampingRatio=0;goog.exportProperty(box2d.b2AreaJoint.prototype,"m_dampingRatio",box2d.b2AreaJoint.prototype.m_dampingRatio);
+box2d.b2AreaJoint.prototype.m_impulse=0;goog.exportProperty(box2d.b2AreaJoint.prototype,"m_impulse",box2d.b2AreaJoint.prototype.m_impulse);box2d.b2AreaJoint.prototype.m_targetLengths=null;box2d.b2AreaJoint.prototype.m_targetArea=0;box2d.b2AreaJoint.prototype.m_normals=null;box2d.b2AreaJoint.prototype.m_joints=null;box2d.b2AreaJoint.prototype.m_deltas=null;box2d.b2AreaJoint.prototype.m_delta=null;box2d.b2AreaJoint.prototype.GetAnchorA=function(a){return a.SetZero()};
+goog.exportProperty(box2d.b2AreaJoint.prototype,"GetAnchorA",box2d.b2AreaJoint.prototype.GetAnchorA);box2d.b2AreaJoint.prototype.GetAnchorB=function(a){return a.SetZero()};goog.exportProperty(box2d.b2AreaJoint.prototype,"GetAnchorB",box2d.b2AreaJoint.prototype.GetAnchorB);box2d.b2AreaJoint.prototype.GetReactionForce=function(a,b){return b.SetZero()};goog.exportProperty(box2d.b2AreaJoint.prototype,"GetReactionForce",box2d.b2AreaJoint.prototype.GetReactionForce);
+box2d.b2AreaJoint.prototype.GetReactionTorque=function(a){return 0};goog.exportProperty(box2d.b2AreaJoint.prototype,"GetReactionTorque",box2d.b2AreaJoint.prototype.GetReactionTorque);box2d.b2AreaJoint.prototype.SetFrequency=function(a){this.m_frequencyHz=a;for(var b=0,c=this.m_joints.length;b<c;++b)this.m_joints[b].SetFrequency(a)};goog.exportProperty(box2d.b2AreaJoint.prototype,"SetFrequency",box2d.b2AreaJoint.prototype.SetFrequency);box2d.b2AreaJoint.prototype.GetFrequency=function(){return this.m_frequencyHz};
+goog.exportProperty(box2d.b2AreaJoint.prototype,"GetFrequency",box2d.b2AreaJoint.prototype.GetFrequency);box2d.b2AreaJoint.prototype.SetDampingRatio=function(a){this.m_dampingRatio=a;for(var b=0,c=this.m_joints.length;b<c;++b)this.m_joints[b].SetDampingRatio(a)};goog.exportProperty(box2d.b2AreaJoint.prototype,"SetDampingRatio",box2d.b2AreaJoint.prototype.SetDampingRatio);box2d.b2AreaJoint.prototype.GetDampingRatio=function(){return this.m_dampingRatio};
+goog.exportProperty(box2d.b2AreaJoint.prototype,"GetDampingRatio",box2d.b2AreaJoint.prototype.GetDampingRatio);box2d.b2AreaJoint.prototype.Dump=function(){box2d.DEBUG&&box2d.b2Log("Area joint dumping is not supported.\n")};goog.exportProperty(box2d.b2AreaJoint.prototype,"Dump",box2d.b2AreaJoint.prototype.Dump);
+box2d.b2AreaJoint.prototype.InitVelocityConstraints=function(a){for(var b=0,c=this.m_bodies.length;b<c;++b){var d=this.m_deltas[b];box2d.b2Sub_V2_V2(a.positions[this.m_bodies[(b+1)%c].m_islandIndex].c,a.positions[this.m_bodies[(b+c-1)%c].m_islandIndex].c,d)}if(a.step.warmStarting)for(this.m_impulse*=a.step.dtRatio,b=0,c=this.m_bodies.length;b<c;++b){var e=this.m_bodies[b],f=a.velocities[e.m_islandIndex].v,d=this.m_deltas[b];f.x+=e.m_invMass*d.y*.5*this.m_impulse;f.y+=e.m_invMass*-d.x*.5*this.m_impulse}else this.m_impulse=
+0};goog.exportProperty(box2d.b2AreaJoint.prototype,"InitVelocityConstraints",box2d.b2AreaJoint.prototype.InitVelocityConstraints);
+box2d.b2AreaJoint.prototype.SolveVelocityConstraints=function(a){for(var b=0,c=0,d=0,e=this.m_bodies.length;d<e;++d)var f=this.m_bodies[d],g=a.velocities[f.m_islandIndex].v,h=this.m_deltas[d],b=b+h.LengthSquared()/f.GetMass(),c=c+box2d.b2Cross_V2_V2(g,h);b=-2*c/b;this.m_impulse+=b;d=0;for(e=this.m_bodies.length;d<e;++d)f=this.m_bodies[d],g=a.velocities[f.m_islandIndex].v,h=this.m_deltas[d],g.x+=f.m_invMass*h.y*.5*b,g.y+=f.m_invMass*-h.x*.5*b};
+goog.exportProperty(box2d.b2AreaJoint.prototype,"SolveVelocityConstraints",box2d.b2AreaJoint.prototype.SolveVelocityConstraints);
+box2d.b2AreaJoint.prototype.SolvePositionConstraints=function(a){for(var b=0,c=0,d=0,e=this.m_bodies.length;d<e;++d){var f=this.m_bodies[d],f=a.positions[f.m_islandIndex].c,g=a.positions[this.m_bodies[(d+1)%e].m_islandIndex].c,h=box2d.b2Sub_V2_V2(g,f,this.m_delta),k=h.Length();k<box2d.b2_epsilon&&(k=1);this.m_normals[d].x=h.y/k;this.m_normals[d].y=-h.x/k;b+=k;c+=box2d.b2Cross_V2_V2(f,g)}b=.5*(this.m_targetArea-.5*c)/b;c=!0;d=0;for(e=this.m_bodies.length;d<e;++d)f=this.m_bodies[d],f=a.positions[f.m_islandIndex].c,
+h=box2d.b2Add_V2_V2(this.m_normals[d],this.m_normals[(d+1)%e],this.m_delta),h.SelfMul(b),g=h.LengthSquared(),g>box2d.b2Sq(box2d.b2_maxLinearCorrection)&&h.SelfMul(box2d.b2_maxLinearCorrection/box2d.b2Sqrt(g)),g>box2d.b2Sq(box2d.b2_linearSlop)&&(c=!1),f.x+=h.x,f.y+=h.y;return c};goog.exportProperty(box2d.b2AreaJoint.prototype,"SolvePositionConstraints",box2d.b2AreaJoint.prototype.SolvePositionConstraints);box2d.b2DistanceJointDef=function(){box2d.b2JointDef.call(this,box2d.b2JointType.e_distanceJoint);this.localAnchorA=new box2d.b2Vec2;this.localAnchorB=new box2d.b2Vec2};goog.inherits(box2d.b2DistanceJointDef,box2d.b2JointDef);goog.exportSymbol("box2d.b2DistanceJointDef",box2d.b2DistanceJointDef);box2d.b2DistanceJointDef.prototype.localAnchorA=null;goog.exportProperty(box2d.b2DistanceJointDef.prototype,"localAnchorA",box2d.b2DistanceJointDef.prototype.localAnchorA);
+box2d.b2DistanceJointDef.prototype.localAnchorB=null;goog.exportProperty(box2d.b2DistanceJointDef.prototype,"localAnchorB",box2d.b2DistanceJointDef.prototype.localAnchorB);box2d.b2DistanceJointDef.prototype.length=1;goog.exportProperty(box2d.b2DistanceJointDef.prototype,"length",box2d.b2DistanceJointDef.prototype.length);box2d.b2DistanceJointDef.prototype.frequencyHz=0;goog.exportProperty(box2d.b2DistanceJointDef.prototype,"frequencyHz",box2d.b2DistanceJointDef.prototype.frequencyHz);
+box2d.b2DistanceJointDef.prototype.dampingRatio=0;goog.exportProperty(box2d.b2DistanceJointDef.prototype,"dampingRatio",box2d.b2DistanceJointDef.prototype.dampingRatio);box2d.b2DistanceJointDef.prototype.Initialize=function(a,b,c,d){this.bodyA=a;this.bodyB=b;this.bodyA.GetLocalPoint(c,this.localAnchorA);this.bodyB.GetLocalPoint(d,this.localAnchorB);this.length=box2d.b2Distance(c,d);this.dampingRatio=this.frequencyHz=0};goog.exportProperty(box2d.b2DistanceJointDef.prototype,"Initialize",box2d.b2DistanceJointDef.prototype.Initialize);
+box2d.b2DistanceJoint=function(a){box2d.b2Joint.call(this,a);this.m_u=new box2d.b2Vec2;this.m_rA=new box2d.b2Vec2;this.m_rB=new box2d.b2Vec2;this.m_localCenterA=new box2d.b2Vec2;this.m_localCenterB=new box2d.b2Vec2;this.m_qA=new box2d.b2Rot;this.m_qB=new box2d.b2Rot;this.m_lalcA=new box2d.b2Vec2;this.m_lalcB=new box2d.b2Vec2;this.m_frequencyHz=a.frequencyHz;this.m_dampingRatio=a.dampingRatio;this.m_localAnchorA=a.localAnchorA.Clone();this.m_localAnchorB=a.localAnchorB.Clone();this.m_length=a.length};
+goog.inherits(box2d.b2DistanceJoint,box2d.b2Joint);goog.exportSymbol("box2d.b2DistanceJoint",box2d.b2DistanceJoint);box2d.b2DistanceJoint.prototype.m_frequencyHz=0;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_frequencyHz",box2d.b2DistanceJoint.prototype.m_frequencyHz);box2d.b2DistanceJoint.prototype.m_dampingRatio=0;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_dampingRatio",box2d.b2DistanceJoint.prototype.m_dampingRatio);box2d.b2DistanceJoint.prototype.m_bias=0;
+goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_bias",box2d.b2DistanceJoint.prototype.m_bias);box2d.b2DistanceJoint.prototype.m_localAnchorA=null;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_localAnchorA",box2d.b2DistanceJoint.prototype.m_localAnchorA);box2d.b2DistanceJoint.prototype.m_localAnchorB=null;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_localAnchorB",box2d.b2DistanceJoint.prototype.m_localAnchorB);box2d.b2DistanceJoint.prototype.m_gamma=0;
+goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_gamma",box2d.b2DistanceJoint.prototype.m_gamma);box2d.b2DistanceJoint.prototype.m_impulse=0;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_impulse",box2d.b2DistanceJoint.prototype.m_impulse);box2d.b2DistanceJoint.prototype.m_length=0;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_length",box2d.b2DistanceJoint.prototype.m_length);box2d.b2DistanceJoint.prototype.m_indexA=0;
+goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_indexA",box2d.b2DistanceJoint.prototype.m_indexA);box2d.b2DistanceJoint.prototype.m_indexB=0;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_indexB",box2d.b2DistanceJoint.prototype.m_indexB);box2d.b2DistanceJoint.prototype.m_u=null;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_u",box2d.b2DistanceJoint.prototype.m_u);box2d.b2DistanceJoint.prototype.m_rA=null;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_rA",box2d.b2DistanceJoint.prototype.m_rA);
+box2d.b2DistanceJoint.prototype.m_rB=null;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_rB",box2d.b2DistanceJoint.prototype.m_rB);box2d.b2DistanceJoint.prototype.m_localCenterA=null;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_localCenterA",box2d.b2DistanceJoint.prototype.m_localCenterA);box2d.b2DistanceJoint.prototype.m_localCenterB=null;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_localCenterB",box2d.b2DistanceJoint.prototype.m_localCenterB);
+box2d.b2DistanceJoint.prototype.m_invMassA=0;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_invMassA",box2d.b2DistanceJoint.prototype.m_invMassA);box2d.b2DistanceJoint.prototype.m_invMassB=0;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_invMassB",box2d.b2DistanceJoint.prototype.m_invMassB);box2d.b2DistanceJoint.prototype.m_invIA=0;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_invIA",box2d.b2DistanceJoint.prototype.m_invIA);box2d.b2DistanceJoint.prototype.m_invIB=0;
+goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_invIB",box2d.b2DistanceJoint.prototype.m_invIB);box2d.b2DistanceJoint.prototype.m_mass=0;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_mass",box2d.b2DistanceJoint.prototype.m_mass);box2d.b2DistanceJoint.prototype.m_qA=null;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_qA",box2d.b2DistanceJoint.prototype.m_qA);box2d.b2DistanceJoint.prototype.m_qB=null;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_qB",box2d.b2DistanceJoint.prototype.m_qB);
+box2d.b2DistanceJoint.prototype.m_lalcA=null;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_lalcA",box2d.b2DistanceJoint.prototype.m_lalcA);box2d.b2DistanceJoint.prototype.m_lalcB=null;goog.exportProperty(box2d.b2DistanceJoint.prototype,"m_lalcB",box2d.b2DistanceJoint.prototype.m_lalcB);box2d.b2DistanceJoint.prototype.GetAnchorA=function(a){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,a)};goog.exportProperty(box2d.b2DistanceJoint.prototype,"GetAnchorA",box2d.b2DistanceJoint.prototype.GetAnchorA);
+box2d.b2DistanceJoint.prototype.GetAnchorB=function(a){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,a)};goog.exportProperty(box2d.b2DistanceJoint.prototype,"GetAnchorB",box2d.b2DistanceJoint.prototype.GetAnchorB);box2d.b2DistanceJoint.prototype.GetReactionForce=function(a,b){return b.Set(a*this.m_impulse*this.m_u.x,a*this.m_impulse*this.m_u.y)};goog.exportProperty(box2d.b2DistanceJoint.prototype,"GetReactionForce",box2d.b2DistanceJoint.prototype.GetReactionForce);
+box2d.b2DistanceJoint.prototype.GetReactionTorque=function(a){return 0};goog.exportProperty(box2d.b2DistanceJoint.prototype,"GetReactionTorque",box2d.b2DistanceJoint.prototype.GetReactionTorque);box2d.b2DistanceJoint.prototype.GetLocalAnchorA=function(a){return a.Copy(this.m_localAnchorA)};goog.exportProperty(box2d.b2DistanceJoint.prototype,"GetLocalAnchorA",box2d.b2DistanceJoint.prototype.GetLocalAnchorA);box2d.b2DistanceJoint.prototype.GetLocalAnchorB=function(a){return a.Copy(this.m_localAnchorB)};
+goog.exportProperty(box2d.b2DistanceJoint.prototype,"GetLocalAnchorB",box2d.b2DistanceJoint.prototype.GetLocalAnchorB);box2d.b2DistanceJoint.prototype.SetLength=function(a){this.m_length=a};goog.exportProperty(box2d.b2DistanceJoint.prototype,"SetLength",box2d.b2DistanceJoint.prototype.SetLength);box2d.b2DistanceJoint.prototype.GetLength=function(){return this.m_length};goog.exportProperty(box2d.b2DistanceJoint.prototype,"GetLength",box2d.b2DistanceJoint.prototype.GetLength);
+box2d.b2DistanceJoint.prototype.SetFrequency=function(a){this.m_frequencyHz=a};goog.exportProperty(box2d.b2DistanceJoint.prototype,"SetFrequency",box2d.b2DistanceJoint.prototype.SetFrequency);box2d.b2DistanceJoint.prototype.GetFrequency=function(){return this.m_frequencyHz};goog.exportProperty(box2d.b2DistanceJoint.prototype,"GetFrequency",box2d.b2DistanceJoint.prototype.GetFrequency);box2d.b2DistanceJoint.prototype.SetDampingRatio=function(a){this.m_dampingRatio=a};
+goog.exportProperty(box2d.b2DistanceJoint.prototype,"SetDampingRatio",box2d.b2DistanceJoint.prototype.SetDampingRatio);box2d.b2DistanceJoint.prototype.GetDampingRatio=function(){return this.m_dampingRatio};goog.exportProperty(box2d.b2DistanceJoint.prototype,"GetDampingRatio",box2d.b2DistanceJoint.prototype.GetDampingRatio);
+box2d.b2DistanceJoint.prototype.Dump=function(){if(box2d.DEBUG){var a=this.m_bodyA.m_islandIndex,b=this.m_bodyB.m_islandIndex;box2d.b2Log("  /*box2d.b2DistanceJointDef*/ var jd = new box2d.b2DistanceJointDef();\n");box2d.b2Log("  jd.bodyA = bodies[%d];\n",a);box2d.b2Log("  jd.bodyB = bodies[%d];\n",b);box2d.b2Log("  jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false");box2d.b2Log("  jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y);box2d.b2Log("  jd.localAnchorB.Set(%.15f, %.15f);\n",
+this.m_localAnchorB.x,this.m_localAnchorB.y);box2d.b2Log("  jd.length = %.15f;\n",this.m_length);box2d.b2Log("  jd.frequencyHz = %.15f;\n",this.m_frequencyHz);box2d.b2Log("  jd.dampingRatio = %.15f;\n",this.m_dampingRatio);box2d.b2Log("  joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}};goog.exportProperty(box2d.b2DistanceJoint.prototype,"Dump",box2d.b2DistanceJoint.prototype.Dump);
+box2d.b2DistanceJoint.prototype.InitVelocityConstraints=function(a){this.m_indexA=this.m_bodyA.m_islandIndex;this.m_indexB=this.m_bodyB.m_islandIndex;this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter);this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter);this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var b=a.positions[this.m_indexA].c,c=a.velocities[this.m_indexA].v,d=a.velocities[this.m_indexA].w,
+e=a.positions[this.m_indexB].c,f=a.positions[this.m_indexB].a,g=a.velocities[this.m_indexB].v,h=a.velocities[this.m_indexB].w,k=this.m_qA.SetAngle(a.positions[this.m_indexA].a),f=this.m_qB.SetAngle(f);box2d.b2Sub_V2_V2(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);box2d.b2Mul_R_V2(k,this.m_lalcA,this.m_rA);box2d.b2Sub_V2_V2(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);box2d.b2Mul_R_V2(f,this.m_lalcB,this.m_rB);this.m_u.x=e.x+this.m_rB.x-b.x-this.m_rA.x;this.m_u.y=e.y+this.m_rB.y-
+b.y-this.m_rA.y;e=this.m_u.Length();e>box2d.b2_linearSlop?this.m_u.SelfMul(1/e):this.m_u.SetZero();b=box2d.b2Cross_V2_V2(this.m_rA,this.m_u);k=box2d.b2Cross_V2_V2(this.m_rB,this.m_u);b=this.m_invMassA+this.m_invIA*b*b+this.m_invMassB+this.m_invIB*k*k;this.m_mass=0!==b?1/b:0;if(0<this.m_frequencyHz){var e=e-this.m_length,k=2*box2d.b2_pi*this.m_frequencyHz,f=this.m_mass*k*k,l=a.step.dt;this.m_gamma=l*(2*this.m_mass*this.m_dampingRatio*k+l*f);this.m_gamma=0!==this.m_gamma?1/this.m_gamma:0;this.m_bias=
+e*l*f*this.m_gamma;b+=this.m_gamma;this.m_mass=0!==b?1/b:0}else this.m_bias=this.m_gamma=0;a.step.warmStarting?(this.m_impulse*=a.step.dtRatio,b=box2d.b2Mul_S_V2(this.m_impulse,this.m_u,box2d.b2DistanceJoint.prototype.InitVelocityConstraints.s_P),c.SelfMulSub(this.m_invMassA,b),d-=this.m_invIA*box2d.b2Cross_V2_V2(this.m_rA,b),g.SelfMulAdd(this.m_invMassB,b),h+=this.m_invIB*box2d.b2Cross_V2_V2(this.m_rB,b)):this.m_impulse=0;a.velocities[this.m_indexA].w=d;a.velocities[this.m_indexB].w=h};
+goog.exportProperty(box2d.b2DistanceJoint.prototype,"InitVelocityConstraints",box2d.b2DistanceJoint.prototype.InitVelocityConstraints);box2d.b2DistanceJoint.prototype.InitVelocityConstraints.s_P=new box2d.b2Vec2;
+box2d.b2DistanceJoint.prototype.SolveVelocityConstraints=function(a){var b=a.velocities[this.m_indexA].v,c=a.velocities[this.m_indexA].w,d=a.velocities[this.m_indexB].v,e=a.velocities[this.m_indexB].w,f=box2d.b2AddCross_V2_S_V2(b,c,this.m_rA,box2d.b2DistanceJoint.prototype.SolveVelocityConstraints.s_vpA),g=box2d.b2AddCross_V2_S_V2(d,e,this.m_rB,box2d.b2DistanceJoint.prototype.SolveVelocityConstraints.s_vpB),f=box2d.b2Dot_V2_V2(this.m_u,box2d.b2Sub_V2_V2(g,f,box2d.b2Vec2.s_t0)),f=-this.m_mass*(f+this.m_bias+
+this.m_gamma*this.m_impulse);this.m_impulse+=f;f=box2d.b2Mul_S_V2(f,this.m_u,box2d.b2DistanceJoint.prototype.SolveVelocityConstraints.s_P);b.SelfMulSub(this.m_invMassA,f);c-=this.m_invIA*box2d.b2Cross_V2_V2(this.m_rA,f);d.SelfMulAdd(this.m_invMassB,f);e+=this.m_invIB*box2d.b2Cross_V2_V2(this.m_rB,f);a.velocities[this.m_indexA].w=c;a.velocities[this.m_indexB].w=e};goog.exportProperty(box2d.b2DistanceJoint.prototype,"SolveVelocityConstraints",box2d.b2DistanceJoint.prototype.SolveVelocityConstraints);
+box2d.b2DistanceJoint.prototype.SolveVelocityConstraints.s_vpA=new box2d.b2Vec2;box2d.b2DistanceJoint.prototype.SolveVelocityConstraints.s_vpB=new box2d.b2Vec2;box2d.b2DistanceJoint.prototype.SolveVelocityConstraints.s_P=new box2d.b2Vec2;
+box2d.b2DistanceJoint.prototype.SolvePositionConstraints=function(a){if(0<this.m_frequencyHz)return!0;var b=a.positions[this.m_indexA].c,c=a.positions[this.m_indexA].a,d=a.positions[this.m_indexB].c,e=a.positions[this.m_indexB].a;this.m_qA.SetAngle(c);this.m_qB.SetAngle(e);var f=box2d.b2Mul_R_V2(this.m_qA,this.m_lalcA,this.m_rA),g=box2d.b2Mul_R_V2(this.m_qB,this.m_lalcB,this.m_rB),h=this.m_u;h.x=d.x+g.x-b.x-f.x;h.y=d.y+g.y-b.y-f.y;var k=this.m_u.Normalize()-this.m_length,k=box2d.b2Clamp(k,-box2d.b2_maxLinearCorrection,
+box2d.b2_maxLinearCorrection),h=box2d.b2Mul_S_V2(-this.m_mass*k,h,box2d.b2DistanceJoint.prototype.SolvePositionConstraints.s_P);b.SelfMulSub(this.m_invMassA,h);c-=this.m_invIA*box2d.b2Cross_V2_V2(f,h);d.SelfMulAdd(this.m_invMassB,h);e+=this.m_invIB*box2d.b2Cross_V2_V2(g,h);a.positions[this.m_indexA].a=c;a.positions[this.m_indexB].a=e;return box2d.b2Abs(k)<box2d.b2_linearSlop};goog.exportProperty(box2d.b2DistanceJoint.prototype,"SolvePositionConstraints",box2d.b2DistanceJoint.prototype.SolvePositionConstraints);
+box2d.b2DistanceJoint.prototype.SolvePositionConstraints.s_P=new box2d.b2Vec2;box2d.b2FrictionJointDef=function(){box2d.b2JointDef.call(this,box2d.b2JointType.e_frictionJoint);this.localAnchorA=new box2d.b2Vec2;this.localAnchorB=new box2d.b2Vec2};goog.inherits(box2d.b2FrictionJointDef,box2d.b2JointDef);goog.exportSymbol("box2d.b2FrictionJointDef",box2d.b2FrictionJointDef);box2d.b2FrictionJointDef.prototype.localAnchorA=null;goog.exportProperty(box2d.b2FrictionJointDef.prototype,"localAnchorA",box2d.b2FrictionJointDef.prototype.localAnchorA);
+box2d.b2FrictionJointDef.prototype.localAnchorB=null;goog.exportProperty(box2d.b2FrictionJointDef.prototype,"localAnchorB",box2d.b2FrictionJointDef.prototype.localAnchorB);box2d.b2FrictionJointDef.prototype.maxForce=0;goog.exportProperty(box2d.b2FrictionJointDef.prototype,"maxForce",box2d.b2FrictionJointDef.prototype.maxForce);box2d.b2FrictionJointDef.prototype.maxTorque=0;goog.exportProperty(box2d.b2FrictionJointDef.prototype,"maxTorque",box2d.b2FrictionJointDef.prototype.maxTorque);
+box2d.b2FrictionJointDef.prototype.Initialize=function(a,b,c){this.bodyA=a;this.bodyB=b;this.bodyA.GetLocalPoint(c,this.localAnchorA);this.bodyB.GetLocalPoint(c,this.localAnchorB)};goog.exportProperty(box2d.b2FrictionJointDef.prototype,"Initialize",box2d.b2FrictionJointDef.prototype.Initialize);
+box2d.b2FrictionJoint=function(a){box2d.b2Joint.call(this,a);this.m_localAnchorA=a.localAnchorA.Clone();this.m_localAnchorB=a.localAnchorB.Clone();this.m_linearImpulse=(new box2d.b2Vec2).SetZero();this.m_maxForce=a.maxForce;this.m_maxTorque=a.maxTorque;this.m_rA=new box2d.b2Vec2;this.m_rB=new box2d.b2Vec2;this.m_localCenterA=new box2d.b2Vec2;this.m_localCenterB=new box2d.b2Vec2;this.m_linearMass=(new box2d.b2Mat22).SetZero();this.m_qA=new box2d.b2Rot;this.m_qB=new box2d.b2Rot;this.m_lalcA=new box2d.b2Vec2;
+this.m_lalcB=new box2d.b2Vec2;this.m_K=new box2d.b2Mat22};goog.inherits(box2d.b2FrictionJoint,box2d.b2Joint);goog.exportSymbol("box2d.b2FrictionJoint",box2d.b2FrictionJoint);box2d.b2FrictionJoint.prototype.m_localAnchorA=null;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_localAnchorA",box2d.b2FrictionJoint.prototype.m_localAnchorA);box2d.b2FrictionJoint.prototype.m_localAnchorB=null;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_localAnchorB",box2d.b2FrictionJoint.prototype.m_localAnchorB);
+box2d.b2FrictionJoint.prototype.m_linearImpulse=null;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_linearImpulse",box2d.b2FrictionJoint.prototype.m_linearImpulse);box2d.b2FrictionJoint.prototype.m_angularImpulse=0;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_angularImpulse",box2d.b2FrictionJoint.prototype.m_angularImpulse);box2d.b2FrictionJoint.prototype.m_maxForce=0;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_maxForce",box2d.b2FrictionJoint.prototype.m_maxForce);
+box2d.b2FrictionJoint.prototype.m_maxTorque=0;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_maxTorque",box2d.b2FrictionJoint.prototype.m_maxTorque);box2d.b2FrictionJoint.prototype.m_indexA=0;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_indexA",box2d.b2FrictionJoint.prototype.m_indexA);box2d.b2FrictionJoint.prototype.m_indexB=0;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_indexB",box2d.b2FrictionJoint.prototype.m_indexB);box2d.b2FrictionJoint.prototype.m_rA=null;
+goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_rA",box2d.b2FrictionJoint.prototype.m_rA);box2d.b2FrictionJoint.prototype.m_rB=null;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_rB",box2d.b2FrictionJoint.prototype.m_rB);box2d.b2FrictionJoint.prototype.m_localCenterA=null;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_localCenterA",box2d.b2FrictionJoint.prototype.m_localCenterA);box2d.b2FrictionJoint.prototype.m_localCenterB=null;
+goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_localCenterB",box2d.b2FrictionJoint.prototype.m_localCenterB);box2d.b2FrictionJoint.prototype.m_invMassA=0;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_invMassA",box2d.b2FrictionJoint.prototype.m_invMassA);box2d.b2FrictionJoint.prototype.m_invMassB=0;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_invMassB",box2d.b2FrictionJoint.prototype.m_invMassB);box2d.b2FrictionJoint.prototype.m_invIA=0;
+goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_invIA",box2d.b2FrictionJoint.prototype.m_invIA);box2d.b2FrictionJoint.prototype.m_invIB=0;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_invIB",box2d.b2FrictionJoint.prototype.m_invIB);box2d.b2FrictionJoint.prototype.m_linearMass=null;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_linearMass",box2d.b2FrictionJoint.prototype.m_linearMass);box2d.b2FrictionJoint.prototype.m_angularMass=0;
+goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_angularMass",box2d.b2FrictionJoint.prototype.m_angularMass);box2d.b2FrictionJoint.prototype.m_qA=null;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_qA",box2d.b2FrictionJoint.prototype.m_qA);box2d.b2FrictionJoint.prototype.m_qB=null;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_qB",box2d.b2FrictionJoint.prototype.m_qB);box2d.b2FrictionJoint.prototype.m_lalcA=null;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_lalcA",box2d.b2FrictionJoint.prototype.m_lalcA);
+box2d.b2FrictionJoint.prototype.m_lalcB=null;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_lalcB",box2d.b2FrictionJoint.prototype.m_lalcB);box2d.b2FrictionJoint.prototype.m_K=null;goog.exportProperty(box2d.b2FrictionJoint.prototype,"m_K",box2d.b2FrictionJoint.prototype.m_K);
+box2d.b2FrictionJoint.prototype.InitVelocityConstraints=function(a){this.m_indexA=this.m_bodyA.m_islandIndex;this.m_indexB=this.m_bodyB.m_islandIndex;this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter);this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter);this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var b=a.velocities[this.m_indexA].v,c=a.velocities[this.m_indexA].w,d=a.positions[this.m_indexB].a,
+e=a.velocities[this.m_indexB].v,f=a.velocities[this.m_indexB].w,g=this.m_qA.SetAngle(a.positions[this.m_indexA].a),d=this.m_qB.SetAngle(d);box2d.b2Sub_V2_V2(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);g=box2d.b2Mul_R_V2(g,this.m_lalcA,this.m_rA);box2d.b2Sub_V2_V2(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var h=box2d.b2Mul_R_V2(d,this.m_lalcB,this.m_rB),d=this.m_invMassA,k=this.m_invMassB,l=this.m_invIA,m=this.m_invIB,n=this.m_K;n.ex.x=d+k+l*g.y*g.y+m*h.y*h.y;n.ex.y=-l*g.x*g.y-
+m*h.x*h.y;n.ey.x=n.ex.y;n.ey.y=d+k+l*g.x*g.x+m*h.x*h.x;n.GetInverse(this.m_linearMass);this.m_angularMass=l+m;0<this.m_angularMass&&(this.m_angularMass=1/this.m_angularMass);a.step.warmStarting?(this.m_linearImpulse.SelfMul(a.step.dtRatio),this.m_angularImpulse*=a.step.dtRatio,g=this.m_linearImpulse,b.SelfMulSub(d,g),c-=l*(box2d.b2Cross_V2_V2(this.m_rA,g)+this.m_angularImpulse),e.SelfMulAdd(k,g),f+=m*(box2d.b2Cross_V2_V2(this.m_rB,g)+this.m_angularImpulse)):(this.m_linearImpulse.SetZero(),this.m_angularImpulse=
+0);a.velocities[this.m_indexA].w=c;a.velocities[this.m_indexB].w=f};goog.exportProperty(box2d.b2FrictionJoint.prototype,"InitVelocityConstraints",box2d.b2FrictionJoint.prototype.InitVelocityConstraints);
+box2d.b2FrictionJoint.prototype.SolveVelocityConstraints=function(a){var b=a.velocities[this.m_indexA].v,c=a.velocities[this.m_indexA].w,d=a.velocities[this.m_indexB].v,e=a.velocities[this.m_indexB].w,f=this.m_invMassA,g=this.m_invMassB,h=this.m_invIA,k=this.m_invIB,l=a.step.dt,m,n=-this.m_angularMass*(e-c),p=this.m_angularImpulse;m=l*this.m_maxTorque;this.m_angularImpulse=box2d.b2Clamp(this.m_angularImpulse+n,-m,m);n=this.m_angularImpulse-p;c-=h*n;e+=k*n;m=box2d.b2Sub_V2_V2(box2d.b2AddCross_V2_S_V2(d,
+e,this.m_rB,box2d.b2Vec2.s_t0),box2d.b2AddCross_V2_S_V2(b,c,this.m_rA,box2d.b2Vec2.s_t1),box2d.b2FrictionJoint.prototype.SolveVelocityConstraints.s_Cdot);n=box2d.b2Mul_M22_V2(this.m_linearMass,m,box2d.b2FrictionJoint.prototype.SolveVelocityConstraints.s_impulseV).SelfNeg();p=box2d.b2FrictionJoint.prototype.SolveVelocityConstraints.s_oldImpulseV.Copy(this.m_linearImpulse);this.m_linearImpulse.SelfAdd(n);m=l*this.m_maxForce;this.m_linearImpulse.LengthSquared()>m*m&&(this.m_linearImpulse.Normalize(),
+this.m_linearImpulse.SelfMul(m));box2d.b2Sub_V2_V2(this.m_linearImpulse,p,n);b.SelfMulSub(f,n);c-=h*box2d.b2Cross_V2_V2(this.m_rA,n);d.SelfMulAdd(g,n);e+=k*box2d.b2Cross_V2_V2(this.m_rB,n);a.velocities[this.m_indexA].w=c;a.velocities[this.m_indexB].w=e};goog.exportProperty(box2d.b2FrictionJoint.prototype,"SolveVelocityConstraints",box2d.b2FrictionJoint.prototype.SolveVelocityConstraints);box2d.b2FrictionJoint.prototype.SolveVelocityConstraints.s_Cdot=new box2d.b2Vec2;
+box2d.b2FrictionJoint.prototype.SolveVelocityConstraints.s_impulseV=new box2d.b2Vec2;box2d.b2FrictionJoint.prototype.SolveVelocityConstraints.s_oldImpulseV=new box2d.b2Vec2;box2d.b2FrictionJoint.prototype.SolvePositionConstraints=function(a){return!0};goog.exportProperty(box2d.b2FrictionJoint.prototype,"SolvePositionConstraints",box2d.b2FrictionJoint.prototype.SolvePositionConstraints);box2d.b2FrictionJoint.prototype.GetAnchorA=function(a){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,a)};
+goog.exportProperty(box2d.b2FrictionJoint.prototype,"GetAnchorA",box2d.b2FrictionJoint.prototype.GetAnchorA);box2d.b2FrictionJoint.prototype.GetAnchorB=function(a){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,a)};goog.exportProperty(box2d.b2FrictionJoint.prototype,"GetAnchorB",box2d.b2FrictionJoint.prototype.GetAnchorB);box2d.b2FrictionJoint.prototype.GetReactionForce=function(a,b){return b.Set(a*this.m_linearImpulse.x,a*this.m_linearImpulse.y)};
+goog.exportProperty(box2d.b2FrictionJoint.prototype,"GetReactionForce",box2d.b2FrictionJoint.prototype.GetReactionForce);box2d.b2FrictionJoint.prototype.GetReactionTorque=function(a){return a*this.m_angularImpulse};goog.exportProperty(box2d.b2FrictionJoint.prototype,"GetReactionTorque",box2d.b2FrictionJoint.prototype.GetReactionTorque);box2d.b2FrictionJoint.prototype.GetLocalAnchorA=function(a){return a.Copy(this.m_localAnchorA)};
+goog.exportProperty(box2d.b2FrictionJoint.prototype,"GetLocalAnchorA",box2d.b2FrictionJoint.prototype.GetLocalAnchorA);box2d.b2FrictionJoint.prototype.GetLocalAnchorB=function(a){return a.Copy(this.m_localAnchorB)};goog.exportProperty(box2d.b2FrictionJoint.prototype,"GetLocalAnchorB",box2d.b2FrictionJoint.prototype.GetLocalAnchorB);box2d.b2FrictionJoint.prototype.SetMaxForce=function(a){this.m_maxForce=a};goog.exportProperty(box2d.b2FrictionJoint.prototype,"SetMaxForce",box2d.b2FrictionJoint.prototype.SetMaxForce);
+box2d.b2FrictionJoint.prototype.GetMaxForce=function(){return this.m_maxForce};goog.exportProperty(box2d.b2FrictionJoint.prototype,"GetMaxForce",box2d.b2FrictionJoint.prototype.GetMaxForce);box2d.b2FrictionJoint.prototype.SetMaxTorque=function(a){this.m_maxTorque=a};goog.exportProperty(box2d.b2FrictionJoint.prototype,"SetMaxTorque",box2d.b2FrictionJoint.prototype.SetMaxTorque);box2d.b2FrictionJoint.prototype.GetMaxTorque=function(){return this.m_maxTorque};
+goog.exportProperty(box2d.b2FrictionJoint.prototype,"GetMaxTorque",box2d.b2FrictionJoint.prototype.GetMaxTorque);
+box2d.b2FrictionJoint.prototype.Dump=function(){if(box2d.DEBUG){var a=this.m_bodyA.m_islandIndex,b=this.m_bodyB.m_islandIndex;box2d.b2Log("  /*box2d.b2FrictionJointDef*/ var jd = new box2d.b2FrictionJointDef();\n");box2d.b2Log("  jd.bodyA = bodies[%d];\n",a);box2d.b2Log("  jd.bodyB = bodies[%d];\n",b);box2d.b2Log("  jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false");box2d.b2Log("  jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y);box2d.b2Log("  jd.localAnchorB.Set(%.15f, %.15f);\n",
+this.m_localAnchorB.x,this.m_localAnchorB.y);box2d.b2Log("  jd.maxForce = %.15f;\n",this.m_maxForce);box2d.b2Log("  jd.maxTorque = %.15f;\n",this.m_maxTorque);box2d.b2Log("  joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}};goog.exportProperty(box2d.b2FrictionJoint.prototype,"Dump",box2d.b2FrictionJoint.prototype.Dump);box2d.b2JointFactory={};
+box2d.b2JointFactory.Create=function(a,b){var c=null;switch(a.type){case box2d.b2JointType.e_distanceJoint:c=new box2d.b2DistanceJoint(a instanceof box2d.b2DistanceJointDef?a:null);break;case box2d.b2JointType.e_mouseJoint:c=new box2d.b2MouseJoint(a instanceof box2d.b2MouseJointDef?a:null);break;case box2d.b2JointType.e_prismaticJoint:c=new box2d.b2PrismaticJoint(a instanceof box2d.b2PrismaticJointDef?a:null);break;case box2d.b2JointType.e_revoluteJoint:c=new box2d.b2RevoluteJoint(a instanceof box2d.b2RevoluteJointDef?
+a:null);break;case box2d.b2JointType.e_pulleyJoint:c=new box2d.b2PulleyJoint(a instanceof box2d.b2PulleyJointDef?a:null);break;case box2d.b2JointType.e_gearJoint:c=new box2d.b2GearJoint(a instanceof box2d.b2GearJointDef?a:null);break;case box2d.b2JointType.e_wheelJoint:c=new box2d.b2WheelJoint(a instanceof box2d.b2WheelJointDef?a:null);break;case box2d.b2JointType.e_weldJoint:c=new box2d.b2WeldJoint(a instanceof box2d.b2WeldJointDef?a:null);break;case box2d.b2JointType.e_frictionJoint:c=new box2d.b2FrictionJoint(a instanceof
+box2d.b2FrictionJointDef?a:null);break;case box2d.b2JointType.e_ropeJoint:c=new box2d.b2RopeJoint(a instanceof box2d.b2RopeJointDef?a:null);break;case box2d.b2JointType.e_motorJoint:c=new box2d.b2MotorJoint(a instanceof box2d.b2MotorJointDef?a:null);break;case box2d.b2JointType.e_areaJoint:c=new box2d.b2AreaJoint(a instanceof box2d.b2AreaJointDef?a:null);break;default:box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1)}return c};goog.exportSymbol("box2d.b2JointFactory.Create",box2d.b2JointFactory.Create);
+box2d.b2JointFactory.Destroy=function(a,b){};goog.exportSymbol("box2d.b2JointFactory.Destroy",box2d.b2JointFactory.Destroy);box2d.b2World=function(a){this.m_flag_clearForces=!0;this.m_contactManager=new box2d.b2ContactManager;this.m_gravity=a.Clone();this.m_out_gravity=new box2d.b2Vec2;this.m_allowSleep=!0;this.m_debugDraw=this.m_destructionListener=null;this.m_continuousPhysics=this.m_warmStarting=!0;this.m_subStepping=!1;this.m_stepComplete=!0;this.m_profile=new box2d.b2Profile;this.m_island=new box2d.b2Island;this.s_stack=[]};goog.exportSymbol("box2d.b2World",box2d.b2World);
+box2d.b2World.prototype.m_flag_newFixture=!1;goog.exportProperty(box2d.b2World.prototype,"m_flag_newFixture",box2d.b2World.prototype.m_flag_newFixture);box2d.b2World.prototype.m_flag_locked=!1;goog.exportProperty(box2d.b2World.prototype,"m_flag_locked",box2d.b2World.prototype.m_flag_locked);box2d.b2World.prototype.m_flag_clearForces=!1;goog.exportProperty(box2d.b2World.prototype,"m_flag_clearForces",box2d.b2World.prototype.m_flag_clearForces);box2d.b2World.prototype.m_contactManager=null;
+goog.exportProperty(box2d.b2World.prototype,"m_contactManager",box2d.b2World.prototype.m_contactManager);box2d.b2World.prototype.m_bodyList=null;goog.exportProperty(box2d.b2World.prototype,"m_bodyList",box2d.b2World.prototype.m_bodyList);box2d.b2World.prototype.m_jointList=null;goog.exportProperty(box2d.b2World.prototype,"m_jointList",box2d.b2World.prototype.m_jointList);box2d.b2World.prototype.m_particleSystemList=null;goog.exportProperty(box2d.b2World.prototype,"m_particleSystemList",box2d.b2World.prototype.m_particleSystemList);
+box2d.b2World.prototype.m_bodyCount=0;goog.exportProperty(box2d.b2World.prototype,"m_bodyCount",box2d.b2World.prototype.m_bodyCount);box2d.b2World.prototype.m_jointCount=0;goog.exportProperty(box2d.b2World.prototype,"m_jointCount",box2d.b2World.prototype.m_jointCount);box2d.b2World.prototype.m_gravity=null;goog.exportProperty(box2d.b2World.prototype,"m_gravity",box2d.b2World.prototype.m_gravity);box2d.b2World.prototype.m_out_gravity=null;
+goog.exportProperty(box2d.b2World.prototype,"m_out_gravity",box2d.b2World.prototype.m_out_gravity);box2d.b2World.prototype.m_allowSleep=!0;goog.exportProperty(box2d.b2World.prototype,"m_allowSleep",box2d.b2World.prototype.m_allowSleep);box2d.b2World.prototype.m_destructionListener=null;goog.exportProperty(box2d.b2World.prototype,"m_destructionListener",box2d.b2World.prototype.m_destructionListener);box2d.b2World.prototype.m_debugDraw=null;
+goog.exportProperty(box2d.b2World.prototype,"m_debugDraw",box2d.b2World.prototype.m_debugDraw);box2d.b2World.prototype.m_inv_dt0=0;goog.exportProperty(box2d.b2World.prototype,"m_inv_dt0",box2d.b2World.prototype.m_inv_dt0);box2d.b2World.prototype.m_warmStarting=!0;goog.exportProperty(box2d.b2World.prototype,"m_warmStarting",box2d.b2World.prototype.m_warmStarting);box2d.b2World.prototype.m_continuousPhysics=!0;goog.exportProperty(box2d.b2World.prototype,"m_continuousPhysics",box2d.b2World.prototype.m_continuousPhysics);
+box2d.b2World.prototype.m_subStepping=!1;goog.exportProperty(box2d.b2World.prototype,"m_subStepping",box2d.b2World.prototype.m_subStepping);box2d.b2World.prototype.m_stepComplete=!0;goog.exportProperty(box2d.b2World.prototype,"m_stepComplete",box2d.b2World.prototype.m_stepComplete);box2d.b2World.prototype.m_profile=null;goog.exportProperty(box2d.b2World.prototype,"m_profile",box2d.b2World.prototype.m_profile);box2d.b2World.prototype.m_island=null;
+goog.exportProperty(box2d.b2World.prototype,"m_island",box2d.b2World.prototype.m_island);box2d.b2World.prototype.s_stack=null;goog.exportProperty(box2d.b2World.prototype,"s_stack",box2d.b2World.prototype.s_stack);box2d.b2World.prototype.m_controllerList=null;goog.exportProperty(box2d.b2World.prototype,"m_controllerList",box2d.b2World.prototype.m_controllerList);box2d.b2World.prototype.m_controllerCount=0;goog.exportProperty(box2d.b2World.prototype,"m_controllerCount",box2d.b2World.prototype.m_controllerCount);
+box2d.b2World.prototype.SetAllowSleeping=function(a){if(a!==this.m_allowSleep&&(this.m_allowSleep=a,!this.m_allowSleep))for(a=this.m_bodyList;a;a=a.m_next)a.SetAwake(!0)};goog.exportProperty(box2d.b2World.prototype,"SetAllowSleeping",box2d.b2World.prototype.SetAllowSleeping);box2d.b2World.prototype.GetAllowSleeping=function(){return this.m_allowSleep};goog.exportProperty(box2d.b2World.prototype,"GetAllowSleeping",box2d.b2World.prototype.GetAllowSleeping);
+box2d.b2World.prototype.SetWarmStarting=function(a){this.m_warmStarting=a};goog.exportProperty(box2d.b2World.prototype,"SetWarmStarting",box2d.b2World.prototype.SetWarmStarting);box2d.b2World.prototype.GetWarmStarting=function(){return this.m_warmStarting};goog.exportProperty(box2d.b2World.prototype,"GetWarmStarting",box2d.b2World.prototype.GetWarmStarting);box2d.b2World.prototype.SetContinuousPhysics=function(a){this.m_continuousPhysics=a};
+goog.exportProperty(box2d.b2World.prototype,"SetContinuousPhysics",box2d.b2World.prototype.SetContinuousPhysics);box2d.b2World.prototype.GetContinuousPhysics=function(){return this.m_continuousPhysics};goog.exportProperty(box2d.b2World.prototype,"GetContinuousPhysics",box2d.b2World.prototype.GetContinuousPhysics);box2d.b2World.prototype.SetSubStepping=function(a){this.m_subStepping=a};goog.exportProperty(box2d.b2World.prototype,"SetSubStepping",box2d.b2World.prototype.SetSubStepping);
+box2d.b2World.prototype.GetSubStepping=function(){return this.m_subStepping};goog.exportProperty(box2d.b2World.prototype,"GetSubStepping",box2d.b2World.prototype.GetSubStepping);box2d.b2World.prototype.GetBodyList=function(){return this.m_bodyList};goog.exportProperty(box2d.b2World.prototype,"GetBodyList",box2d.b2World.prototype.GetBodyList);box2d.b2World.prototype.GetJointList=function(){return this.m_jointList};goog.exportProperty(box2d.b2World.prototype,"GetJointList",box2d.b2World.prototype.GetJointList);
+box2d.b2World.prototype.GetParticleSystemList=function(){return this.m_particleSystemList};goog.exportProperty(box2d.b2World.prototype,"GetParticleSystemList",box2d.b2World.prototype.GetParticleSystemList);box2d.b2World.prototype.GetContactList=function(){return this.m_contactManager.m_contactList};goog.exportProperty(box2d.b2World.prototype,"GetContactList",box2d.b2World.prototype.GetContactList);box2d.b2World.prototype.GetBodyCount=function(){return this.m_bodyCount};
+goog.exportProperty(box2d.b2World.prototype,"GetBodyCount",box2d.b2World.prototype.GetBodyCount);box2d.b2World.prototype.GetJointCount=function(){return this.m_jointCount};goog.exportProperty(box2d.b2World.prototype,"GetJointCount",box2d.b2World.prototype.GetJointCount);box2d.b2World.prototype.GetContactCount=function(){return this.m_contactManager.m_contactCount};goog.exportProperty(box2d.b2World.prototype,"GetContactCount",box2d.b2World.prototype.GetContactCount);
+box2d.b2World.prototype.SetGravity=function(a,b){b=b||!0;if(this.m_gravity.x!==a.x||this.m_gravity.y!==a.y)if(this.m_gravity.Copy(a),b)for(var c=this.m_bodyList;c;c=c.m_next)c.SetAwake(!0)};goog.exportProperty(box2d.b2World.prototype,"SetGravity",box2d.b2World.prototype.SetGravity);box2d.b2World.prototype.GetGravity=function(a){a=a||this.m_out_gravity;return a.Copy(this.m_gravity)};goog.exportProperty(box2d.b2World.prototype,"GetGravity",box2d.b2World.prototype.GetGravity);
+box2d.b2World.prototype.IsLocked=function(){return this.m_flag_locked};goog.exportProperty(box2d.b2World.prototype,"IsLocked",box2d.b2World.prototype.IsLocked);box2d.b2World.prototype.SetAutoClearForces=function(a){this.m_flag_clearForces=a};goog.exportProperty(box2d.b2World.prototype,"SetAutoClearForces",box2d.b2World.prototype.SetAutoClearForces);box2d.b2World.prototype.GetAutoClearForces=function(){return this.m_flag_clearForces};
+goog.exportProperty(box2d.b2World.prototype,"GetAutoClearForces",box2d.b2World.prototype.GetAutoClearForces);box2d.b2World.prototype.GetContactManager=function(){return this.m_contactManager};goog.exportProperty(box2d.b2World.prototype,"GetContactManager",box2d.b2World.prototype.GetContactManager);box2d.b2World.prototype.GetProfile=function(){return this.m_profile};goog.exportProperty(box2d.b2World.prototype,"GetProfile",box2d.b2World.prototype.GetProfile);
+box2d.b2World.prototype.SetDestructionListener=function(a){this.m_destructionListener=a};goog.exportProperty(box2d.b2World.prototype,"SetDestructionListener",box2d.b2World.prototype.SetDestructionListener);box2d.b2World.prototype.SetContactFilter=function(a){this.m_contactManager.m_contactFilter=a};goog.exportProperty(box2d.b2World.prototype,"SetContactFilter",box2d.b2World.prototype.SetContactFilter);box2d.b2World.prototype.SetContactListener=function(a){this.m_contactManager.m_contactListener=a};
+goog.exportProperty(box2d.b2World.prototype,"SetContactListener",box2d.b2World.prototype.SetContactListener);box2d.b2World.prototype.SetDebugDraw=function(a){this.m_debugDraw=a};goog.exportProperty(box2d.b2World.prototype,"SetDebugDraw",box2d.b2World.prototype.SetDebugDraw);
+box2d.b2World.prototype.CreateBody=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!this.IsLocked());if(this.IsLocked())return null;a=new box2d.b2Body(a,this);a.m_prev=null;if(a.m_next=this.m_bodyList)this.m_bodyList.m_prev=a;this.m_bodyList=a;++this.m_bodyCount;return a};goog.exportProperty(box2d.b2World.prototype,"CreateBody",box2d.b2World.prototype.CreateBody);
+box2d.b2World.prototype.DestroyBody=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<this.m_bodyCount);box2d.ENABLE_ASSERTS&&box2d.b2Assert(!this.IsLocked());if(!this.IsLocked()){for(var b=a.m_jointList;b;){var c=b,b=b.next;this.m_destructionListener&&this.m_destructionListener.SayGoodbyeJoint(c.joint);this.DestroyJoint(c.joint);a.m_jointList=b}a.m_jointList=null;for(b=a.m_controllerList;b;)c=b,b=b.nextController,c.controller.RemoveBody(a);for(b=a.m_contactList;b;)c=b,b=b.next,this.m_contactManager.Destroy(c.contact);
+a.m_contactList=null;for(b=a.m_fixtureList;b;)c=b,b=b.m_next,this.m_destructionListener&&this.m_destructionListener.SayGoodbyeFixture(c),c.DestroyProxies(this.m_contactManager.m_broadPhase),c.Destroy(),a.m_fixtureList=b,--a.m_fixtureCount;a.m_fixtureList=null;a.m_fixtureCount=0;a.m_prev&&(a.m_prev.m_next=a.m_next);a.m_next&&(a.m_next.m_prev=a.m_prev);a===this.m_bodyList&&(this.m_bodyList=a.m_next);--this.m_bodyCount}};goog.exportProperty(box2d.b2World.prototype,"DestroyBody",box2d.b2World.prototype.DestroyBody);
+box2d.b2World.prototype.CreateJoint=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!this.IsLocked());if(this.IsLocked())return null;var b=box2d.b2JointFactory.Create(a,null);b.m_prev=null;if(b.m_next=this.m_jointList)this.m_jointList.m_prev=b;this.m_jointList=b;++this.m_jointCount;b.m_edgeA.joint=b;b.m_edgeA.other=b.m_bodyB;b.m_edgeA.prev=null;if(b.m_edgeA.next=b.m_bodyA.m_jointList)b.m_bodyA.m_jointList.prev=b.m_edgeA;b.m_bodyA.m_jointList=b.m_edgeA;b.m_edgeB.joint=b;b.m_edgeB.other=b.m_bodyA;
+b.m_edgeB.prev=null;if(b.m_edgeB.next=b.m_bodyB.m_jointList)b.m_bodyB.m_jointList.prev=b.m_edgeB;b.m_bodyB.m_jointList=b.m_edgeB;var c=a.bodyA,d=a.bodyB;if(!a.collideConnected)for(a=d.GetContactList();a;)a.other===c&&a.contact.FlagForFiltering(),a=a.next;return b};goog.exportProperty(box2d.b2World.prototype,"CreateJoint",box2d.b2World.prototype.CreateJoint);
+box2d.b2World.prototype.DestroyJoint=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!this.IsLocked());if(!this.IsLocked()){var b=a.m_collideConnected;a.m_prev&&(a.m_prev.m_next=a.m_next);a.m_next&&(a.m_next.m_prev=a.m_prev);a===this.m_jointList&&(this.m_jointList=a.m_next);var c=a.m_bodyA,d=a.m_bodyB;c.SetAwake(!0);d.SetAwake(!0);a.m_edgeA.prev&&(a.m_edgeA.prev.next=a.m_edgeA.next);a.m_edgeA.next&&(a.m_edgeA.next.prev=a.m_edgeA.prev);a.m_edgeA===c.m_jointList&&(c.m_jointList=a.m_edgeA.next);a.m_edgeA.prev=
+null;a.m_edgeA.next=null;a.m_edgeB.prev&&(a.m_edgeB.prev.next=a.m_edgeB.next);a.m_edgeB.next&&(a.m_edgeB.next.prev=a.m_edgeB.prev);a.m_edgeB===d.m_jointList&&(d.m_jointList=a.m_edgeB.next);a.m_edgeB.prev=null;a.m_edgeB.next=null;box2d.b2JointFactory.Destroy(a,null);box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<this.m_jointCount);--this.m_jointCount;if(!b)for(a=d.GetContactList();a;)a.other===c&&a.contact.FlagForFiltering(),a=a.next}};goog.exportProperty(box2d.b2World.prototype,"DestroyJoint",box2d.b2World.prototype.DestroyJoint);
+box2d.b2World.prototype.CreateParticleSystem=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!this.IsLocked());if(this.IsLocked())return null;a=new box2d.b2ParticleSystem(a,this);a.m_prev=null;if(a.m_next=this.m_particleSystemList)this.m_particleSystemList.m_prev=a;return this.m_particleSystemList=a};goog.exportProperty(box2d.b2World.prototype,"CreateParticleSystem",box2d.b2World.prototype.CreateParticleSystem);
+box2d.b2World.prototype.DestroyParticleSystem=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!this.IsLocked());this.IsLocked()||(a.m_prev&&(a.m_prev.m_next=a.m_next),a.m_next&&(a.m_next.m_prev=a.m_prev),a===this.m_particleSystemList&&(this.m_particleSystemList=a.m_next))};goog.exportProperty(box2d.b2World.prototype,"DestroyParticleSystem",box2d.b2World.prototype.DestroyParticleSystem);
+box2d.b2World.prototype.Solve=function(a){for(var b=this.m_bodyList;b;b=b.m_next)b.m_xf0.Copy(b.m_xf);for(var c=this.m_controllerList;c;c=c.m_next)c.Step(a);this.m_profile.solveInit=0;this.m_profile.solveVelocity=0;this.m_profile.solvePosition=0;c=this.m_island;c.Initialize(this.m_bodyCount,this.m_contactManager.m_contactCount,this.m_jointCount,null,this.m_contactManager.m_contactListener);for(b=this.m_bodyList;b;b=b.m_next)b.m_flag_islandFlag=!1;for(var d=this.m_contactManager.m_contactList;d;d=
+d.m_next)d.m_flag_islandFlag=!1;for(d=this.m_jointList;d;d=d.m_next)d.m_islandFlag=!1;for(var d=this.m_bodyCount,e=this.s_stack,f=this.m_bodyList;f;f=f.m_next)if(!f.m_flag_islandFlag&&f.IsAwake()&&f.IsActive()&&f.GetType()!==box2d.b2BodyType.b2_staticBody){c.Clear();var g=0;e[g++]=f;for(f.m_flag_islandFlag=!0;0<g;)if(b=e[--g],box2d.ENABLE_ASSERTS&&box2d.b2Assert(b.IsActive()),c.AddBody(b),b.SetAwake(!0),b.GetType()!==box2d.b2BodyType.b2_staticBody){for(var h=b.m_contactList;h;h=h.next){var k=h.contact;
+if(!k.m_flag_islandFlag&&k.IsEnabled()&&k.IsTouching()){var l=k.m_fixtureB.m_isSensor;k.m_fixtureA.m_isSensor||l||(c.AddContact(k),k.m_flag_islandFlag=!0,k=h.other,k.m_flag_islandFlag||(box2d.ENABLE_ASSERTS&&box2d.b2Assert(g<d),e[g++]=k,k.m_flag_islandFlag=!0))}}for(b=b.m_jointList;b;b=b.next)b.joint.m_islandFlag||(k=b.other,k.IsActive()&&(c.AddJoint(b.joint),b.joint.m_islandFlag=!0,k.m_flag_islandFlag||(box2d.ENABLE_ASSERTS&&box2d.b2Assert(g<d),e[g++]=k,k.m_flag_islandFlag=!0)))}b=new box2d.b2Profile;
+c.Solve(b,a,this.m_gravity,this.m_allowSleep);this.m_profile.solveInit+=b.solveInit;this.m_profile.solveVelocity+=b.solveVelocity;this.m_profile.solvePosition+=b.solvePosition;for(g=0;g<c.m_bodyCount;++g)b=c.m_bodies[g],b.GetType()===box2d.b2BodyType.b2_staticBody&&(b.m_flag_islandFlag=!1)}for(g=0;g<e.length&&e[g];++g)e[g]=null;a=new box2d.b2Timer;for(b=this.m_bodyList;b;b=b.m_next)b.m_flag_islandFlag&&b.GetType()!==box2d.b2BodyType.b2_staticBody&&b.SynchronizeFixtures();this.m_contactManager.FindNewContacts();
+this.m_profile.broadphase=a.GetMilliseconds()};goog.exportProperty(box2d.b2World.prototype,"Solve",box2d.b2World.prototype.Solve);
+box2d.b2World.prototype.SolveTOI=function(a){var b=this.m_island;b.Initialize(2*box2d.b2_maxTOIContacts,box2d.b2_maxTOIContacts,0,null,this.m_contactManager.m_contactListener);if(this.m_stepComplete){for(var c=this.m_bodyList;c;c=c.m_next)c.m_flag_islandFlag=!1,c.m_sweep.alpha0=0;for(var d=this.m_contactManager.m_contactList;d;d=d.m_next)d.m_flag_toiFlag=d.m_flag_islandFlag=!1,d.m_toiCount=0,d.m_toi=1}for(;;){for(var e=null,c=1,d=this.m_contactManager.m_contactList;d;d=d.m_next)if(d.IsEnabled()&&
+!(d.m_toiCount>box2d.b2_maxSubSteps)){var f=1;if(d.m_flag_toiFlag)f=d.m_toi;else{var g=d.GetFixtureA(),h=d.GetFixtureB();if(g.IsSensor()||h.IsSensor())continue;var f=g.GetBody(),k=h.GetBody(),l=f.m_type,m=k.m_type;box2d.ENABLE_ASSERTS&&box2d.b2Assert(l!==box2d.b2BodyType.b2_staticBody||m!==box2d.b2BodyType.b2_staticBody);var n=f.IsAwake()&&l!==box2d.b2BodyType.b2_staticBody,p=k.IsAwake()&&m!==box2d.b2BodyType.b2_staticBody;if(!n&&!p)continue;l=f.IsBullet()||l!==box2d.b2BodyType.b2_dynamicBody;m=k.IsBullet()||
+m!==box2d.b2BodyType.b2_dynamicBody;if(!l&&!m)continue;m=f.m_sweep.alpha0;f.m_sweep.alpha0<k.m_sweep.alpha0?(m=k.m_sweep.alpha0,f.m_sweep.Advance(m)):k.m_sweep.alpha0<f.m_sweep.alpha0&&(m=f.m_sweep.alpha0,k.m_sweep.Advance(m));box2d.ENABLE_ASSERTS&&box2d.b2Assert(1>m);n=d.GetChildIndexA();p=d.GetChildIndexB();l=box2d.b2World.prototype.SolveTOI.s_toi_input;l.proxyA.SetShape(g.GetShape(),n);l.proxyB.SetShape(h.GetShape(),p);l.sweepA.Copy(f.m_sweep);l.sweepB.Copy(k.m_sweep);l.tMax=1;f=box2d.b2World.prototype.SolveTOI.s_toi_output;
+box2d.b2TimeOfImpact(f,l);k=f.t;f=f.state===box2d.b2TOIOutputState.e_touching?box2d.b2Min(m+(1-m)*k,1):1;d.m_toi=f;d.m_flag_toiFlag=!0}f<c&&(e=d,c=f)}if(null===e||1-10*box2d.b2_epsilon<c){this.m_stepComplete=!0;break}g=e.GetFixtureA();h=e.GetFixtureB();f=g.GetBody();k=h.GetBody();d=box2d.b2World.prototype.SolveTOI.s_backup1.Copy(f.m_sweep);g=box2d.b2World.prototype.SolveTOI.s_backup2.Copy(k.m_sweep);f.Advance(c);k.Advance(c);e.Update(this.m_contactManager.m_contactListener);e.m_flag_toiFlag=!1;++e.m_toiCount;
+if(e.IsEnabled()&&e.IsTouching()){f.SetAwake(!0);k.SetAwake(!0);b.Clear();b.AddBody(f);b.AddBody(k);b.AddContact(e);f.m_flag_islandFlag=!0;k.m_flag_islandFlag=!0;e.m_flag_islandFlag=!0;for(e=0;2>e;++e)if(d=0===e?f:k,d.m_type===box2d.b2BodyType.b2_dynamicBody)for(g=d.m_contactList;g&&b.m_bodyCount!==b.m_bodyCapacity&&b.m_contactCount!==b.m_contactCapacity;g=g.next)h=g.contact,!h.m_flag_islandFlag&&(m=g.other,m.m_type!==box2d.b2BodyType.b2_dynamicBody||d.IsBullet()||m.IsBullet())&&(l=h.m_fixtureB.m_isSensor,
+h.m_fixtureA.m_isSensor||l||(l=box2d.b2World.prototype.SolveTOI.s_backup.Copy(m.m_sweep),m.m_flag_islandFlag||m.Advance(c),h.Update(this.m_contactManager.m_contactListener),h.IsEnabled()?h.IsTouching()?(h.m_flag_islandFlag=!0,b.AddContact(h),m.m_flag_islandFlag||(m.m_flag_islandFlag=!0,m.m_type!==box2d.b2BodyType.b2_staticBody&&m.SetAwake(!0),b.AddBody(m))):(m.m_sweep.Copy(l),m.SynchronizeTransform()):(m.m_sweep.Copy(l),m.SynchronizeTransform())));e=box2d.b2World.prototype.SolveTOI.s_subStep;e.dt=
+(1-c)*a.dt;e.inv_dt=1/e.dt;e.dtRatio=1;e.positionIterations=20;e.velocityIterations=a.velocityIterations;e.particleIterations=a.particleIterations;e.warmStarting=!1;b.SolveTOI(e,f.m_islandIndex,k.m_islandIndex);for(e=0;e<b.m_bodyCount;++e)if(d=b.m_bodies[e],d.m_flag_islandFlag=!1,d.m_type===box2d.b2BodyType.b2_dynamicBody)for(d.SynchronizeFixtures(),g=d.m_contactList;g;g=g.next)g.contact.m_flag_toiFlag=g.contact.m_flag_islandFlag=!1;this.m_contactManager.FindNewContacts();if(this.m_subStepping){this.m_stepComplete=
+!1;break}}else e.SetEnabled(!1),f.m_sweep.Copy(d),k.m_sweep.Copy(g),f.SynchronizeTransform(),k.SynchronizeTransform()}};goog.exportProperty(box2d.b2World.prototype,"SolveTOI",box2d.b2World.prototype.SolveTOI);box2d.b2World.prototype.SolveTOI.s_subStep=new box2d.b2TimeStep;box2d.b2World.prototype.SolveTOI.s_backup=new box2d.b2Sweep;box2d.b2World.prototype.SolveTOI.s_backup1=new box2d.b2Sweep;box2d.b2World.prototype.SolveTOI.s_backup2=new box2d.b2Sweep;box2d.b2World.prototype.SolveTOI.s_toi_input=new box2d.b2TOIInput;
+box2d.b2World.prototype.SolveTOI.s_toi_output=new box2d.b2TOIOutput;
+box2d.b2World.prototype.Step=function(a,b,c,d){d=d||this.CalculateReasonableParticleIterations(a);var e=new box2d.b2Timer;this.m_flag_newFixture&&(this.m_contactManager.FindNewContacts(),this.m_flag_newFixture=!1);this.m_flag_locked=!0;var f=box2d.b2World.prototype.Step.s_step;f.dt=a;f.velocityIterations=b;f.positionIterations=c;f.particleIterations=d;f.inv_dt=0<a?1/a:0;f.dtRatio=this.m_inv_dt0*a;f.warmStarting=this.m_warmStarting;a=new box2d.b2Timer;this.m_contactManager.Collide();this.m_profile.collide=
+a.GetMilliseconds();if(this.m_stepComplete&&0<f.dt){a=new box2d.b2Timer;for(b=this.m_particleSystemList;b;b=b.m_next)b.Solve(f);this.Solve(f);this.m_profile.solve=a.GetMilliseconds()}this.m_continuousPhysics&&0<f.dt&&(a=new box2d.b2Timer,this.SolveTOI(f),this.m_profile.solveTOI=a.GetMilliseconds());0<f.dt&&(this.m_inv_dt0=f.inv_dt);this.m_flag_clearForces&&this.ClearForces();this.m_flag_locked=!1;this.m_profile.step=e.GetMilliseconds()};goog.exportProperty(box2d.b2World.prototype,"Step",box2d.b2World.prototype.Step);
+box2d.b2World.prototype.Step.s_step=new box2d.b2TimeStep;box2d.b2World.prototype.ClearForces=function(){for(var a=this.m_bodyList;a;a=a.m_next)a.m_force.SetZero(),a.m_torque=0};goog.exportProperty(box2d.b2World.prototype,"ClearForces",box2d.b2World.prototype.ClearForces);
+box2d.b2World.prototype.QueryAABB=function(a,b){var c=this.m_contactManager.m_broadPhase;c.Query(function(b){b=c.GetUserData(b);box2d.ENABLE_ASSERTS&&box2d.b2Assert(b instanceof box2d.b2FixtureProxy);b=b.fixture;return a instanceof box2d.b2QueryCallback?a.ReportFixture(b):a(b)},b);if(a instanceof box2d.b2QueryCallback)for(var d=this.m_particleSystemList;d;d=d.m_next)a.ShouldQueryParticleSystem(d)&&d.QueryAABB(a,b)};goog.exportProperty(box2d.b2World.prototype,"QueryAABB",box2d.b2World.prototype.QueryAABB);
+box2d.b2World.prototype.QueryShape=function(a,b,c,d){var e=this.m_contactManager.m_broadPhase,f=box2d.b2World.prototype.QueryShape.s_aabb;b.ComputeAABB(f,c,d||0);e.Query(function(d){d=e.GetUserData(d);box2d.ENABLE_ASSERTS&&box2d.b2Assert(d instanceof box2d.b2FixtureProxy);d=d.fixture;return box2d.b2TestOverlap_Shape(b,0,d.GetShape(),0,c,d.GetBody().GetTransform())?a instanceof box2d.b2QueryCallback?a.ReportFixture(d):a(d):!0},f);if(a instanceof box2d.b2QueryCallback)for(d=this.m_particleSystemList;d;d=
+d.m_next)a.ShouldQueryParticleSystem(d)&&d.QueryAABB(a,f)};goog.exportProperty(box2d.b2World.prototype,"QueryShape",box2d.b2World.prototype.QueryShape);box2d.b2World.prototype.QueryShape.s_aabb=new box2d.b2AABB;
+box2d.b2World.prototype.QueryPoint=function(a,b,c){var d=this.m_contactManager.m_broadPhase;c="number"===typeof c?c:box2d.b2_linearSlop;var e=box2d.b2World.prototype.QueryPoint.s_aabb;e.lowerBound.Set(b.x-c,b.y-c);e.upperBound.Set(b.x+c,b.y+c);d.Query(function(c){c=d.GetUserData(c);box2d.ENABLE_ASSERTS&&box2d.b2Assert(c instanceof box2d.b2FixtureProxy);c=c.fixture;return c.TestPoint(b)?a instanceof box2d.b2QueryCallback?a.ReportFixture(c):a(c):!0},e);if(a instanceof box2d.b2QueryCallback)for(c=this.m_particleSystemList;c;c=
+c.m_next)a.ShouldQueryParticleSystem(c)&&c.QueryAABB(a,e)};goog.exportProperty(box2d.b2World.prototype,"QueryPoint",box2d.b2World.prototype.QueryPoint);box2d.b2World.prototype.QueryPoint.s_aabb=new box2d.b2AABB;
+box2d.b2World.prototype.RayCast=function(a,b,c){var d=this.m_contactManager.m_broadPhase,e=box2d.b2World.prototype.RayCast.s_input;e.maxFraction=1;e.p1.Copy(b);e.p2.Copy(c);d.RayCast(function(e,g){var h=d.GetUserData(g);box2d.ENABLE_ASSERTS&&box2d.b2Assert(h instanceof box2d.b2FixtureProxy);var k=h.fixture,l=box2d.b2World.prototype.RayCast.s_output;if(k.RayCast(l,e,h.childIndex)){var h=l.fraction,m=box2d.b2World.prototype.RayCast.s_point;m.Set((1-h)*b.x+h*c.x,(1-h)*b.y+h*c.y);return a instanceof box2d.b2RayCastCallback?
+a.ReportFixture(k,m,l.normal,h):a(k,m,l.normal,h)}return e.maxFraction},e);if(a instanceof box2d.b2RayCastCallback)for(e=this.m_particleSystemList;e;e=e.m_next)a.ShouldQueryParticleSystem(e)&&e.RayCast(a,b,c)};goog.exportProperty(box2d.b2World.prototype,"RayCast",box2d.b2World.prototype.RayCast);box2d.b2World.prototype.RayCast.s_input=new box2d.b2RayCastInput;box2d.b2World.prototype.RayCast.s_output=new box2d.b2RayCastOutput;box2d.b2World.prototype.RayCast.s_point=new box2d.b2Vec2;
+box2d.b2World.prototype.RayCastOne=function(a,b){var c=null,d=1;this.RayCast(function(a,b,g,h){h<d&&(d=h,c=a);return d},a,b);return c};goog.exportProperty(box2d.b2World.prototype,"RayCastOne",box2d.b2World.prototype.RayCastOne);box2d.b2World.prototype.RayCastAll=function(a,b,c){c.length=0;this.RayCast(function(a,b,f,g){c.push(a);return 1},a,b);return c};goog.exportProperty(box2d.b2World.prototype,"RayCastAll",box2d.b2World.prototype.RayCastAll);
+box2d.b2World.prototype.DrawShape=function(a,b){var c=a.GetShape();switch(c.m_type){case box2d.b2ShapeType.e_circleShape:c=c instanceof box2d.b2CircleShape?c:null;this.m_debugDraw.DrawSolidCircle(c.m_p,c.m_radius,box2d.b2Vec2.UNITX,b);break;case box2d.b2ShapeType.e_edgeShape:var d=c instanceof box2d.b2EdgeShape?c:null,c=d.m_vertex1,e=d.m_vertex2;this.m_debugDraw.DrawSegment(c,e,b);break;case box2d.b2ShapeType.e_chainShape:var c=c instanceof box2d.b2ChainShape?c:null,d=c.m_count,f=c.m_vertices,c=f[0];
+this.m_debugDraw.DrawCircle(c,.05,b);for(var g=1;g<d;++g)e=f[g],this.m_debugDraw.DrawSegment(c,e,b),this.m_debugDraw.DrawCircle(e,.05,b),c=e;break;case box2d.b2ShapeType.e_polygonShape:d=c instanceof box2d.b2PolygonShape?c:null,c=d.m_count,f=d.m_vertices,this.m_debugDraw.DrawSolidPolygon(f,c,b)}};goog.exportProperty(box2d.b2World.prototype,"DrawShape",box2d.b2World.prototype.DrawShape);
+box2d.b2World.prototype.DrawJoint=function(a){var b=a.GetBodyA(),c=a.GetBodyB(),d=b.m_xf.p,e=c.m_xf.p,c=a.GetAnchorA(box2d.b2World.prototype.DrawJoint.s_p1),b=a.GetAnchorB(box2d.b2World.prototype.DrawJoint.s_p2),f=box2d.b2World.prototype.DrawJoint.s_color.SetRGB(.5,.8,.8);switch(a.m_type){case box2d.b2JointType.e_distanceJoint:this.m_debugDraw.DrawSegment(c,b,f);break;case box2d.b2JointType.e_pulleyJoint:d=a instanceof box2d.b2PulleyJoint?a:null;a=d.GetGroundAnchorA(box2d.b2World.prototype.DrawJoint.s_s1);
+d=d.GetGroundAnchorB(box2d.b2World.prototype.DrawJoint.s_s2);this.m_debugDraw.DrawSegment(a,c,f);this.m_debugDraw.DrawSegment(d,b,f);this.m_debugDraw.DrawSegment(a,d,f);break;case box2d.b2JointType.e_mouseJoint:this.m_debugDraw.DrawSegment(c,b,f);break;default:this.m_debugDraw.DrawSegment(d,c,f),this.m_debugDraw.DrawSegment(c,b,f),this.m_debugDraw.DrawSegment(e,b,f)}};goog.exportProperty(box2d.b2World.prototype,"DrawJoint",box2d.b2World.prototype.DrawJoint);
+box2d.b2World.prototype.DrawJoint.s_p1=new box2d.b2Vec2;box2d.b2World.prototype.DrawJoint.s_p2=new box2d.b2Vec2;box2d.b2World.prototype.DrawJoint.s_color=new box2d.b2Color(.5,.8,.8);box2d.b2World.prototype.DrawJoint.s_s1=new box2d.b2Vec2;box2d.b2World.prototype.DrawJoint.s_s2=new box2d.b2Vec2;
+box2d.b2World.prototype.DrawParticleSystem=function(a){var b=a.GetParticleCount();if(b){var c=a.GetRadius(),d=a.GetPositionBuffer();a.m_colorBuffer.data?(a=a.GetColorBuffer(),this.m_debugDraw.DrawParticles(d,c,a,b)):this.m_debugDraw.DrawParticles(d,c,null,b)}};goog.exportProperty(box2d.b2World.prototype,"DrawParticleSystem",box2d.b2World.prototype.DrawParticleSystem);
+box2d.b2World.prototype.DrawDebugData=function(){if(null!==this.m_debugDraw){var a=this.m_debugDraw.GetFlags(),b=box2d.b2World.prototype.DrawDebugData.s_color.SetRGB(0,0,0);if(a&box2d.b2DrawFlags.e_shapeBit)for(var c=this.m_bodyList;c;c=c.m_next){var d=c.m_xf;this.m_debugDraw.PushTransform(d);for(var e=c.GetFixtureList();e;e=e.m_next)c.IsActive()?c.GetType()===box2d.b2BodyType.b2_staticBody?b.SetRGB(.5,.9,.5):c.GetType()===box2d.b2BodyType.b2_kinematicBody?b.SetRGB(.5,.5,.9):c.IsAwake()?b.SetRGB(.9,
+.7,.7):b.SetRGB(.6,.6,.6):b.SetRGB(.5,.5,.3),this.DrawShape(e,b);this.m_debugDraw.PopTransform(d)}if(a&box2d.b2DrawFlags.e_particleBit)for(c=this.m_particleSystemList;c;c=c.m_next)this.DrawParticleSystem(c);if(a&box2d.b2DrawFlags.e_jointBit)for(c=this.m_jointList;c;c=c.m_next)this.DrawJoint(c);if(a&box2d.b2DrawFlags.e_aabbBit){b.SetRGB(.9,.3,.9);for(var d=this.m_contactManager.m_broadPhase,f=box2d.b2World.prototype.DrawDebugData.s_vs,c=this.m_bodyList;c;c=c.m_next)if(c.IsActive())for(e=c.GetFixtureList();e;e=
+e.m_next)for(var g=0;g<e.m_proxyCount;++g){var h=d.GetFatAABB(e.m_proxies[g].proxy);f[0].Set(h.lowerBound.x,h.lowerBound.y);f[1].Set(h.upperBound.x,h.lowerBound.y);f[2].Set(h.upperBound.x,h.upperBound.y);f[3].Set(h.lowerBound.x,h.upperBound.y);this.m_debugDraw.DrawPolygon(f,4,b)}}if(a&box2d.b2DrawFlags.e_centerOfMassBit)for(c=this.m_bodyList;c;c=c.m_next)d=box2d.b2World.prototype.DrawDebugData.s_xf,d.q.Copy(c.m_xf.q),d.p.Copy(c.GetWorldCenter()),this.m_debugDraw.DrawTransform(d);if(a&box2d.b2DrawFlags.e_controllerBit)for(a=
+this.m_controllerList;a;a=a.m_next)a.Draw(this.m_debugDraw)}};goog.exportProperty(box2d.b2World.prototype,"DrawDebugData",box2d.b2World.prototype.DrawDebugData);box2d.b2World.prototype.DrawDebugData.s_color=new box2d.b2Color(0,0,0);box2d.b2World.prototype.DrawDebugData.s_vs=box2d.b2Vec2.MakeArray(4);box2d.b2World.prototype.DrawDebugData.s_xf=new box2d.b2Transform;
+box2d.b2World.prototype.SetBroadPhase=function(a){var b=this.m_contactManager.m_broadPhase;this.m_contactManager.m_broadPhase=a;for(var c=this.m_bodyList;c;c=c.m_next)for(var d=c.m_fixtureList;d;d=d.m_next)d.m_proxy=a.CreateProxy(b.GetFatAABB(d.m_proxy),d)};goog.exportProperty(box2d.b2World.prototype,"SetBroadPhase",box2d.b2World.prototype.SetBroadPhase);
+box2d.b2World.prototype.CalculateReasonableParticleIterations=function(a){return null===this.m_particleSystemList?1:box2d.b2CalculateParticleIterations(this.m_gravity.Length(),function(a){var c=box2d.b2_maxFloat;for(a=a.GetParticleSystemList();null!==a;a=a.m_next)c=box2d.b2Min(c,a.GetRadius());return c}(this),a)};goog.exportProperty(box2d.b2World.prototype,"CalculateReasonableParticleIterations",box2d.b2World.prototype.CalculateReasonableParticleIterations);box2d.b2World.prototype.GetProxyCount=function(){return this.m_contactManager.m_broadPhase.GetProxyCount()};
+goog.exportProperty(box2d.b2World.prototype,"GetProxyCount",box2d.b2World.prototype.GetProxyCount);box2d.b2World.prototype.GetTreeHeight=function(){return this.m_contactManager.m_broadPhase.GetTreeHeight()};goog.exportProperty(box2d.b2World.prototype,"GetTreeHeight",box2d.b2World.prototype.GetTreeHeight);box2d.b2World.prototype.GetTreeBalance=function(){return this.m_contactManager.m_broadPhase.GetTreeBalance()};goog.exportProperty(box2d.b2World.prototype,"GetTreeBalance",box2d.b2World.prototype.GetTreeBalance);
+box2d.b2World.prototype.GetTreeQuality=function(){return this.m_contactManager.m_broadPhase.GetTreeQuality()};goog.exportProperty(box2d.b2World.prototype,"GetTreeQuality",box2d.b2World.prototype.GetTreeQuality);box2d.b2World.prototype.ShiftOrigin=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!this.IsLocked());if(!this.IsLocked()){for(var b=this.m_bodyList;b;b=b.m_next)b.m_xf.p.SelfSub(a),b.m_sweep.c0.SelfSub(a),b.m_sweep.c.SelfSub(a);for(b=this.m_jointList;b;b=b.m_next)b.ShiftOrigin(a);this.m_contactManager.m_broadPhase.ShiftOrigin(a)}};
+goog.exportProperty(box2d.b2World.prototype,"ShiftOrigin",box2d.b2World.prototype.ShiftOrigin);
+box2d.b2World.prototype.Dump=function(){if(box2d.DEBUG&&!this.m_flag_locked){box2d.b2Log("/** @type {box2d.b2Vec2} */ var g = new box2d.b2Vec2(%.15f, %.15f);\n",this.m_gravity.x,this.m_gravity.y);box2d.b2Log("this.m_world.SetGravity(g);\n");box2d.b2Log("/** @type {Array.<box2d.b2Body>} */ var bodies = new Array(%d);\n",this.m_bodyCount);box2d.b2Log("/** @type {Array.<box2d.b2Joint>} */ var joints = new Array(%d);\n",this.m_jointCount);for(var a=0,b=this.m_bodyList;b;b=b.m_next)b.m_islandIndex=a,b.Dump(),
+++a;a=0;for(b=this.m_jointList;b;b=b.m_next)b.m_index=a,++a;for(b=this.m_jointList;b;b=b.m_next)b.m_type!==box2d.b2JointType.e_gearJoint&&(box2d.b2Log("{\n"),b.Dump(),box2d.b2Log("}\n"));for(b=this.m_jointList;b;b=b.m_next)b.m_type===box2d.b2JointType.e_gearJoint&&(box2d.b2Log("{\n"),b.Dump(),box2d.b2Log("}\n"))}};goog.exportProperty(box2d.b2World.prototype,"Dump",box2d.b2World.prototype.Dump);
+box2d.b2World.prototype.AddController=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(null===a.m_world,"Controller can only be a member of one world");a.m_world=this;a.m_next=this.m_controllerList;a.m_prev=null;this.m_controllerList&&(this.m_controllerList.m_prev=a);this.m_controllerList=a;++this.m_controllerCount;return a};goog.exportProperty(box2d.b2World.prototype,"AddController",box2d.b2World.prototype.AddController);
+box2d.b2World.prototype.RemoveController=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(a.m_world===this,"Controller is not a member of this world");a.m_prev&&(a.m_prev.m_next=a.m_next);a.m_next&&(a.m_next.m_prev=a.m_prev);this.m_controllerList===a&&(this.m_controllerList=a.m_next);--this.m_controllerCount;a.m_prev=null;a.m_next=null;a.m_world=null};goog.exportProperty(box2d.b2World.prototype,"RemoveController",box2d.b2World.prototype.RemoveController);box2d.b2MotorJointDef=function(){box2d.b2JointDef.call(this,box2d.b2JointType.e_motorJoint);this.linearOffset=new box2d.b2Vec2(0,0)};goog.inherits(box2d.b2MotorJointDef,box2d.b2JointDef);goog.exportSymbol("box2d.b2MotorJointDef",box2d.b2MotorJointDef);box2d.b2MotorJointDef.prototype.linearOffset=null;goog.exportProperty(box2d.b2MotorJointDef.prototype,"linearOffset",box2d.b2MotorJointDef.prototype.linearOffset);box2d.b2MotorJointDef.prototype.angularOffset=0;
+goog.exportProperty(box2d.b2MotorJointDef.prototype,"angularOffset",box2d.b2MotorJointDef.prototype.angularOffset);box2d.b2MotorJointDef.prototype.maxForce=1;goog.exportProperty(box2d.b2MotorJointDef.prototype,"maxForce",box2d.b2MotorJointDef.prototype.maxForce);box2d.b2MotorJointDef.prototype.maxTorque=1;goog.exportProperty(box2d.b2MotorJointDef.prototype,"maxTorque",box2d.b2MotorJointDef.prototype.maxTorque);box2d.b2MotorJointDef.prototype.correctionFactor=.3;
+goog.exportProperty(box2d.b2MotorJointDef.prototype,"correctionFactor",box2d.b2MotorJointDef.prototype.correctionFactor);box2d.b2MotorJointDef.prototype.Initialize=function(a,b){this.bodyA=a;this.bodyB=b;this.bodyA.GetLocalPoint(this.bodyB.GetPosition(),this.linearOffset);var c=this.bodyA.GetAngle();this.angularOffset=this.bodyB.GetAngle()-c};goog.exportProperty(box2d.b2MotorJointDef.prototype,"Initialize",box2d.b2MotorJointDef.prototype.Initialize);
+box2d.b2MotorJoint=function(a){box2d.b2Joint.call(this,a);this.m_linearOffset=a.linearOffset.Clone();this.m_linearImpulse=new box2d.b2Vec2(0,0);this.m_maxForce=a.maxForce;this.m_maxTorque=a.maxTorque;this.m_correctionFactor=a.correctionFactor;this.m_rA=new box2d.b2Vec2(0,0);this.m_rB=new box2d.b2Vec2(0,0);this.m_localCenterA=new box2d.b2Vec2(0,0);this.m_localCenterB=new box2d.b2Vec2(0,0);this.m_linearError=new box2d.b2Vec2(0,0);this.m_linearMass=new box2d.b2Mat22;this.m_qA=new box2d.b2Rot;this.m_qB=
+new box2d.b2Rot;this.m_K=new box2d.b2Mat22};goog.inherits(box2d.b2MotorJoint,box2d.b2Joint);goog.exportSymbol("box2d.b2MotorJoint",box2d.b2MotorJoint);box2d.b2MotorJoint.prototype.m_linearOffset=null;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_linearOffset",box2d.b2MotorJoint.prototype.m_linearOffset);box2d.b2MotorJoint.prototype.m_angularOffset=0;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_angularOffset",box2d.b2MotorJoint.prototype.m_angularOffset);
+box2d.b2MotorJoint.prototype.m_linearImpulse=null;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_linearImpulse",box2d.b2MotorJoint.prototype.m_linearImpulse);box2d.b2MotorJoint.prototype.m_angularImpulse=0;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_angularImpulse",box2d.b2MotorJoint.prototype.m_angularImpulse);box2d.b2MotorJoint.prototype.m_maxForce=0;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_maxForce",box2d.b2MotorJoint.prototype.m_maxForce);
+box2d.b2MotorJoint.prototype.m_maxTorque=0;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_maxTorque",box2d.b2MotorJoint.prototype.m_maxTorque);box2d.b2MotorJoint.prototype.m_correctionFactor=.3;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_correctionFactor",box2d.b2MotorJoint.prototype.m_correctionFactor);box2d.b2MotorJoint.prototype.m_indexA=0;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_indexA",box2d.b2MotorJoint.prototype.m_indexA);box2d.b2MotorJoint.prototype.m_indexB=0;
+goog.exportProperty(box2d.b2MotorJoint.prototype,"m_indexB",box2d.b2MotorJoint.prototype.m_indexB);box2d.b2MotorJoint.prototype.m_rA=null;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_rA",box2d.b2MotorJoint.prototype.m_rA);box2d.b2MotorJoint.prototype.m_rB=null;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_rB",box2d.b2MotorJoint.prototype.m_rB);box2d.b2MotorJoint.prototype.m_localCenterA=null;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_localCenterA",box2d.b2MotorJoint.prototype.m_localCenterA);
+box2d.b2MotorJoint.prototype.m_localCenterB=null;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_localCenterB",box2d.b2MotorJoint.prototype.m_localCenterB);box2d.b2MotorJoint.prototype.m_linearError=null;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_linearError",box2d.b2MotorJoint.prototype.m_linearError);box2d.b2MotorJoint.prototype.m_angularError=0;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_angularError",box2d.b2MotorJoint.prototype.m_angularError);
+box2d.b2MotorJoint.prototype.m_invMassA=0;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_invMassA",box2d.b2MotorJoint.prototype.m_invMassA);box2d.b2MotorJoint.prototype.m_invMassB=0;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_invMassB",box2d.b2MotorJoint.prototype.m_invMassB);box2d.b2MotorJoint.prototype.m_invIA=0;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_invIA",box2d.b2MotorJoint.prototype.m_invIA);box2d.b2MotorJoint.prototype.m_invIB=0;
+goog.exportProperty(box2d.b2MotorJoint.prototype,"m_invIB",box2d.b2MotorJoint.prototype.m_invIB);box2d.b2MotorJoint.prototype.m_linearMass=null;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_linearMass",box2d.b2MotorJoint.prototype.m_linearMass);box2d.b2MotorJoint.prototype.m_angularMass=0;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_angularMass",box2d.b2MotorJoint.prototype.m_angularMass);box2d.b2MotorJoint.prototype.m_qA=null;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_qA",box2d.b2MotorJoint.prototype.m_qA);
+box2d.b2MotorJoint.prototype.m_qB=null;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_qB",box2d.b2MotorJoint.prototype.m_qB);box2d.b2MotorJoint.prototype.m_K=null;goog.exportProperty(box2d.b2MotorJoint.prototype,"m_K",box2d.b2MotorJoint.prototype.m_K);box2d.b2MotorJoint.prototype.GetAnchorA=function(a){return this.m_bodyA.GetPosition(a)};goog.exportProperty(box2d.b2MotorJoint.prototype,"GetAnchorA",box2d.b2MotorJoint.prototype.GetAnchorA);box2d.b2MotorJoint.prototype.GetAnchorB=function(a){return this.m_bodyB.GetPosition(a)};
+goog.exportProperty(box2d.b2MotorJoint.prototype,"GetAnchorB",box2d.b2MotorJoint.prototype.GetAnchorB);box2d.b2MotorJoint.prototype.GetReactionForce=function(a,b){return box2d.b2Mul_S_V2(a,this.m_linearImpulse,b)};goog.exportProperty(box2d.b2MotorJoint.prototype,"GetReactionForce",box2d.b2MotorJoint.prototype.GetReactionForce);box2d.b2MotorJoint.prototype.GetReactionTorque=function(a){return a*this.m_angularImpulse};goog.exportProperty(box2d.b2MotorJoint.prototype,"GetReactionTorque",box2d.b2MotorJoint.prototype.GetReactionTorque);
+box2d.b2MotorJoint.prototype.SetCorrectionFactor=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(box2d.b2IsValid(a)&&0<=a&&1>=a);this._correctionFactor=a};box2d.b2MotorJoint.prototype.GetCorrectionFactor=function(){return this.m_correctionFactor};box2d.b2MotorJoint.prototype.SetLinearOffset=function(a){if(a.x!=this.m_linearOffset.x||a.y!=this.m_linearOffset.y)this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_linearOffset.Copy(a)};
+goog.exportProperty(box2d.b2MotorJoint.prototype,"SetLinearOffset",box2d.b2MotorJoint.prototype.SetLinearOffset);box2d.b2MotorJoint.prototype.GetLinearOffset=function(a){return a.Copy(this.m_linearOffset)};goog.exportProperty(box2d.b2MotorJoint.prototype,"GetLinearOffset",box2d.b2MotorJoint.prototype.GetLinearOffset);box2d.b2MotorJoint.prototype.SetAngularOffset=function(a){a!==this.m_angularOffset&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_angularOffset=a)};
+goog.exportProperty(box2d.b2MotorJoint.prototype,"SetAngularOffset",box2d.b2MotorJoint.prototype.SetAngularOffset);box2d.b2MotorJoint.prototype.GetAngularOffset=function(){return this.m_angularOffset};goog.exportProperty(box2d.b2MotorJoint.prototype,"GetAngularOffset",box2d.b2MotorJoint.prototype.GetAngularOffset);box2d.b2MotorJoint.prototype.SetMaxForce=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(box2d.b2IsValid(a)&&0<=a);this.m_maxForce=a};
+goog.exportProperty(box2d.b2MotorJoint.prototype,"SetMaxForce",box2d.b2MotorJoint.prototype.SetMaxForce);box2d.b2MotorJoint.prototype.GetMaxForce=function(){return this.m_maxForce};goog.exportProperty(box2d.b2MotorJoint.prototype,"GetMaxForce",box2d.b2MotorJoint.prototype.GetMaxForce);box2d.b2MotorJoint.prototype.SetMaxTorque=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(box2d.b2IsValid(a)&&0<=a);this.m_maxTorque=a};goog.exportProperty(box2d.b2MotorJoint.prototype,"SetMaxTorque",box2d.b2MotorJoint.prototype.SetMaxTorque);
+box2d.b2MotorJoint.prototype.GetMaxTorque=function(){return this.m_maxTorque};goog.exportProperty(box2d.b2MotorJoint.prototype,"GetMaxTorque",box2d.b2MotorJoint.prototype.GetMaxTorque);
+box2d.b2MotorJoint.prototype.InitVelocityConstraints=function(a){this.m_indexA=this.m_bodyA.m_islandIndex;this.m_indexB=this.m_bodyB.m_islandIndex;this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter);this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter);this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var b=a.positions[this.m_indexA].c,c=a.positions[this.m_indexA].a,d=a.velocities[this.m_indexA].v,
+e=a.velocities[this.m_indexA].w,f=a.positions[this.m_indexB].c,g=a.positions[this.m_indexB].a,h=a.velocities[this.m_indexB].v,k=a.velocities[this.m_indexB].w,l=this.m_qA.SetAngle(c),m=this.m_qB.SetAngle(g),n=box2d.b2Mul_R_V2(l,box2d.b2Vec2.s_t0.Copy(this.m_localCenterA).SelfNeg(),this.m_rA),m=box2d.b2Mul_R_V2(m,box2d.b2Vec2.s_t0.Copy(this.m_localCenterB).SelfNeg(),this.m_rB),p=this.m_invMassA,q=this.m_invMassB,r=this.m_invIA,u=this.m_invIB,t=this.m_K;t.ex.x=p+q+r*n.y*n.y+u*m.y*m.y;t.ex.y=-r*n.x*n.y-
+u*m.x*m.y;t.ey.x=t.ex.y;t.ey.y=p+q+r*n.x*n.x+u*m.x*m.x;t.GetInverse(this.m_linearMass);this.m_angularMass=r+u;0<this.m_angularMass&&(this.m_angularMass=1/this.m_angularMass);box2d.b2Sub_V2_V2(box2d.b2Sub_V2_V2(box2d.b2Add_V2_V2(f,m,box2d.b2Vec2.s_t0),box2d.b2Add_V2_V2(b,n,box2d.b2Vec2.s_t1),box2d.b2Vec2.s_t2),box2d.b2Mul_R_V2(l,this.m_linearOffset,box2d.b2Vec2.s_t3),this.m_linearError);this.m_angularError=g-c-this.m_angularOffset;a.step.warmStarting?(this.m_linearImpulse.SelfMul(a.step.dtRatio),this.m_angularImpulse*=
+a.step.dtRatio,b=this.m_linearImpulse,d.SelfMulSub(p,b),e-=r*(box2d.b2Cross_V2_V2(n,b)+this.m_angularImpulse),h.SelfMulAdd(q,b),k+=u*(box2d.b2Cross_V2_V2(m,b)+this.m_angularImpulse)):(this.m_linearImpulse.SetZero(),this.m_angularImpulse=0);a.velocities[this.m_indexA].w=e;a.velocities[this.m_indexB].w=k};goog.exportProperty(box2d.b2MotorJoint.prototype,"InitVelocityConstraints",box2d.b2MotorJoint.prototype.InitVelocityConstraints);
+box2d.b2MotorJoint.prototype.SolveVelocityConstraints=function(a){var b=a.velocities[this.m_indexA].v,c=a.velocities[this.m_indexA].w,d=a.velocities[this.m_indexB].v,e=a.velocities[this.m_indexB].w,f=this.m_invMassA,g=this.m_invMassB,h=this.m_invIA,k=this.m_invIB,l=a.step.dt,m=a.step.inv_dt,n=e-c+m*this.m_correctionFactor*this.m_angularError,n=-this.m_angularMass*n,p=this.m_angularImpulse,q=l*this.m_maxTorque;this.m_angularImpulse=box2d.b2Clamp(this.m_angularImpulse+n,-q,q);var n=this.m_angularImpulse-
+p,c=c-h*n,e=e+k*n,r=this.m_rA,u=this.m_rB,n=box2d.b2Add_V2_V2(box2d.b2Sub_V2_V2(box2d.b2Add_V2_V2(d,box2d.b2Cross_S_V2(e,u,box2d.b2Vec2.s_t0),box2d.b2Vec2.s_t0),box2d.b2Add_V2_V2(b,box2d.b2Cross_S_V2(c,r,box2d.b2Vec2.s_t1),box2d.b2Vec2.s_t1),box2d.b2Vec2.s_t2),box2d.b2Mul_S_V2(m*this.m_correctionFactor,this.m_linearError,box2d.b2Vec2.s_t3),box2d.b2MotorJoint.prototype.SolveVelocityConstraints.s_Cdot),n=box2d.b2Mul_M22_V2(this.m_linearMass,n,box2d.b2MotorJoint.prototype.SolveVelocityConstraints.s_impulse).SelfNeg(),
+p=box2d.b2MotorJoint.prototype.SolveVelocityConstraints.s_oldImpulse.Copy(this.m_linearImpulse);this.m_linearImpulse.SelfAdd(n);q=l*this.m_maxForce;this.m_linearImpulse.LengthSquared()>q*q&&(this.m_linearImpulse.Normalize(),this.m_linearImpulse.SelfMul(q));box2d.b2Sub_V2_V2(this.m_linearImpulse,p,n);b.SelfMulSub(f,n);c-=h*box2d.b2Cross_V2_V2(r,n);d.SelfMulAdd(g,n);e+=k*box2d.b2Cross_V2_V2(u,n);a.velocities[this.m_indexA].w=c;a.velocities[this.m_indexB].w=e};
+goog.exportProperty(box2d.b2MotorJoint.prototype,"SolveVelocityConstraints",box2d.b2MotorJoint.prototype.SolveVelocityConstraints);box2d.b2MotorJoint.prototype.SolveVelocityConstraints.s_Cdot=new box2d.b2Vec2;box2d.b2MotorJoint.prototype.SolveVelocityConstraints.s_impulse=new box2d.b2Vec2;box2d.b2MotorJoint.prototype.SolveVelocityConstraints.s_oldImpulse=new box2d.b2Vec2;box2d.b2MotorJoint.prototype.SolvePositionConstraints=function(a){return!0};
+goog.exportProperty(box2d.b2MotorJoint.prototype,"SolvePositionConstraints",box2d.b2MotorJoint.prototype.SolvePositionConstraints);
+box2d.b2MotorJoint.prototype.Dump=function(){if(box2d.DEBUG){var a=this.m_bodyA.m_islandIndex,b=this.m_bodyB.m_islandIndex;box2d.b2Log("  /*box2d.b2MotorJointDef*/ var jd = new box2d.b2MotorJointDef();\n");box2d.b2Log("  jd.bodyA = bodies[%d];\n",a);box2d.b2Log("  jd.bodyB = bodies[%d];\n",b);box2d.b2Log("  jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false");box2d.b2Log("  jd.linearOffset.Set(%.15f, %.15f);\n",this.m_linearOffset.x,this.m_linearOffset.y);box2d.b2Log("  jd.angularOffset = %.15f;\n",
+this.m_angularOffset);box2d.b2Log("  jd.maxForce = %.15f;\n",this.m_maxForce);box2d.b2Log("  jd.maxTorque = %.15f;\n",this.m_maxTorque);box2d.b2Log("  jd.correctionFactor = %.15f;\n",this.m_correctionFactor);box2d.b2Log("  joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}};goog.exportProperty(box2d.b2MotorJoint.prototype,"Dump",box2d.b2MotorJoint.prototype.Dump);box2d.b2MouseJointDef=function(){box2d.b2JointDef.call(this,box2d.b2JointType.e_mouseJoint);this.target=new box2d.b2Vec2};goog.inherits(box2d.b2MouseJointDef,box2d.b2JointDef);goog.exportSymbol("box2d.b2MouseJointDef",box2d.b2MouseJointDef);box2d.b2MouseJointDef.prototype.target=null;goog.exportProperty(box2d.b2MouseJointDef.prototype,"target",box2d.b2MouseJointDef.prototype.target);box2d.b2MouseJointDef.prototype.maxForce=0;goog.exportProperty(box2d.b2MouseJointDef.prototype,"maxForce",box2d.b2MouseJointDef.prototype.maxForce);
+box2d.b2MouseJointDef.prototype.frequencyHz=5;goog.exportProperty(box2d.b2MouseJointDef.prototype,"frequencyHz",box2d.b2MouseJointDef.prototype.frequencyHz);box2d.b2MouseJointDef.prototype.dampingRatio=.7;goog.exportProperty(box2d.b2MouseJointDef.prototype,"dampingRatio",box2d.b2MouseJointDef.prototype.dampingRatio);
+box2d.b2MouseJoint=function(a){box2d.b2Joint.call(this,a);this.m_localAnchorB=new box2d.b2Vec2;this.m_targetA=new box2d.b2Vec2;this.m_impulse=new box2d.b2Vec2;this.m_rB=new box2d.b2Vec2;this.m_localCenterB=new box2d.b2Vec2;this.m_mass=new box2d.b2Mat22;this.m_C=new box2d.b2Vec2;this.m_qB=new box2d.b2Rot;this.m_lalcB=new box2d.b2Vec2;this.m_K=new box2d.b2Mat22;box2d.ENABLE_ASSERTS&&box2d.b2Assert(a.target.IsValid());box2d.ENABLE_ASSERTS&&box2d.b2Assert(box2d.b2IsValid(a.maxForce)&&0<=a.maxForce);box2d.ENABLE_ASSERTS&&
+box2d.b2Assert(box2d.b2IsValid(a.frequencyHz)&&0<=a.frequencyHz);box2d.ENABLE_ASSERTS&&box2d.b2Assert(box2d.b2IsValid(a.dampingRatio)&&0<=a.dampingRatio);this.m_targetA.Copy(a.target);box2d.b2MulT_X_V2(this.m_bodyB.GetTransform(),this.m_targetA,this.m_localAnchorB);this.m_maxForce=a.maxForce;this.m_impulse.SetZero();this.m_frequencyHz=a.frequencyHz;this.m_dampingRatio=a.dampingRatio;this.m_gamma=this.m_beta=0};goog.inherits(box2d.b2MouseJoint,box2d.b2Joint);
+goog.exportSymbol("box2d.b2MouseJoint",box2d.b2MouseJoint);box2d.b2MouseJoint.prototype.m_localAnchorB=null;goog.exportProperty(box2d.b2MouseJoint.prototype,"m_localAnchorB",box2d.b2MouseJoint.prototype.m_localAnchorB);box2d.b2MouseJoint.prototype.m_targetA=null;goog.exportProperty(box2d.b2MouseJoint.prototype,"m_targetA",box2d.b2MouseJoint.prototype.m_targetA);box2d.b2MouseJoint.prototype.m_frequencyHz=0;goog.exportProperty(box2d.b2MouseJoint.prototype,"m_frequencyHz",box2d.b2MouseJoint.prototype.m_frequencyHz);
+box2d.b2MouseJoint.prototype.m_dampingRatio=0;goog.exportProperty(box2d.b2MouseJoint.prototype,"m_dampingRatio",box2d.b2MouseJoint.prototype.m_dampingRatio);box2d.b2MouseJoint.prototype.m_beta=0;goog.exportProperty(box2d.b2MouseJoint.prototype,"m_beta",box2d.b2MouseJoint.prototype.m_beta);box2d.b2MouseJoint.prototype.m_impulse=null;goog.exportProperty(box2d.b2MouseJoint.prototype,"m_impulse",box2d.b2MouseJoint.prototype.m_impulse);box2d.b2MouseJoint.prototype.m_maxForce=0;
+goog.exportProperty(box2d.b2MouseJoint.prototype,"m_maxForce",box2d.b2MouseJoint.prototype.m_maxForce);box2d.b2MouseJoint.prototype.m_gamma=0;goog.exportProperty(box2d.b2MouseJoint.prototype,"m_gamma",box2d.b2MouseJoint.prototype.m_gamma);box2d.b2MouseJoint.prototype.m_indexA=0;goog.exportProperty(box2d.b2MouseJoint.prototype,"m_indexA",box2d.b2MouseJoint.prototype.m_indexA);box2d.b2MouseJoint.prototype.m_indexB=0;goog.exportProperty(box2d.b2MouseJoint.prototype,"m_indexB",box2d.b2MouseJoint.prototype.m_indexB);
+box2d.b2MouseJoint.prototype.m_rB=null;goog.exportProperty(box2d.b2MouseJoint.prototype,"m_rB",box2d.b2MouseJoint.prototype.m_rB);box2d.b2MouseJoint.prototype.m_localCenterB=null;goog.exportProperty(box2d.b2MouseJoint.prototype,"m_localCenterB",box2d.b2MouseJoint.prototype.m_localCenterB);box2d.b2MouseJoint.prototype.m_invMassB=0;goog.exportProperty(box2d.b2MouseJoint.prototype,"m_invMassB",box2d.b2MouseJoint.prototype.m_invMassB);box2d.b2MouseJoint.prototype.m_invIB=0;
+goog.exportProperty(box2d.b2MouseJoint.prototype,"m_invIB",box2d.b2MouseJoint.prototype.m_invIB);box2d.b2MouseJoint.prototype.m_mass=null;goog.exportProperty(box2d.b2MouseJoint.prototype,"m_mass",box2d.b2MouseJoint.prototype.m_mass);box2d.b2MouseJoint.prototype.m_C=null;goog.exportProperty(box2d.b2MouseJoint.prototype,"m_C",box2d.b2MouseJoint.prototype.m_C);box2d.b2MouseJoint.prototype.m_qB=null;goog.exportProperty(box2d.b2MouseJoint.prototype,"m_qB",box2d.b2MouseJoint.prototype.m_qB);
+box2d.b2MouseJoint.prototype.m_lalcB=null;goog.exportProperty(box2d.b2MouseJoint.prototype,"m_lalcB",box2d.b2MouseJoint.prototype.m_lalcB);box2d.b2MouseJoint.prototype.m_K=null;goog.exportProperty(box2d.b2MouseJoint.prototype,"m_K",box2d.b2MouseJoint.prototype.m_K);box2d.b2MouseJoint.prototype.SetTarget=function(a){this.m_bodyB.IsAwake()||this.m_bodyB.SetAwake(!0);this.m_targetA.Copy(a)};goog.exportProperty(box2d.b2MouseJoint.prototype,"SetTarget",box2d.b2MouseJoint.prototype.SetTarget);
+box2d.b2MouseJoint.prototype.GetTarget=function(a){return a.Copy(this.m_targetA)};goog.exportProperty(box2d.b2MouseJoint.prototype,"GetTarget",box2d.b2MouseJoint.prototype.GetTarget);box2d.b2MouseJoint.prototype.SetMaxForce=function(a){this.m_maxForce=a};goog.exportProperty(box2d.b2MouseJoint.prototype,"SetMaxForce",box2d.b2MouseJoint.prototype.SetMaxForce);box2d.b2MouseJoint.prototype.GetMaxForce=function(){return this.m_maxForce};goog.exportProperty(box2d.b2MouseJoint.prototype,"GetMaxForce",box2d.b2MouseJoint.prototype.GetMaxForce);
+box2d.b2MouseJoint.prototype.SetFrequency=function(a){this.m_frequencyHz=a};goog.exportProperty(box2d.b2MouseJoint.prototype,"SetFrequency",box2d.b2MouseJoint.prototype.SetFrequency);box2d.b2MouseJoint.prototype.GetFrequency=function(){return this.m_frequencyHz};goog.exportProperty(box2d.b2MouseJoint.prototype,"GetFrequency",box2d.b2MouseJoint.prototype.GetFrequency);box2d.b2MouseJoint.prototype.SetDampingRatio=function(a){this.m_dampingRatio=a};
+goog.exportProperty(box2d.b2MouseJoint.prototype,"SetDampingRatio",box2d.b2MouseJoint.prototype.SetDampingRatio);box2d.b2MouseJoint.prototype.GetDampingRatio=function(){return this.m_dampingRatio};goog.exportProperty(box2d.b2MouseJoint.prototype,"GetDampingRatio",box2d.b2MouseJoint.prototype.GetDampingRatio);
+box2d.b2MouseJoint.prototype.InitVelocityConstraints=function(a){this.m_indexB=this.m_bodyB.m_islandIndex;this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter);this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIB=this.m_bodyB.m_invI;var b=a.positions[this.m_indexB].c,c=a.velocities[this.m_indexB].v,d=a.velocities[this.m_indexB].w,e=this.m_qB.SetAngle(a.positions[this.m_indexB].a),f=this.m_bodyB.GetMass(),g=2*box2d.b2_pi*this.m_frequencyHz,h=2*f*this.m_dampingRatio*g,f=f*g*g,g=a.step.dt;box2d.ENABLE_ASSERTS&&
+box2d.b2Assert(h+g*f>box2d.b2_epsilon);this.m_gamma=g*(h+g*f);0!==this.m_gamma&&(this.m_gamma=1/this.m_gamma);this.m_beta=g*f*this.m_gamma;box2d.b2Sub_V2_V2(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);box2d.b2Mul_R_V2(e,this.m_lalcB,this.m_rB);e=this.m_K;e.ex.x=this.m_invMassB+this.m_invIB*this.m_rB.y*this.m_rB.y+this.m_gamma;e.ex.y=-this.m_invIB*this.m_rB.x*this.m_rB.y;e.ey.x=e.ex.y;e.ey.y=this.m_invMassB+this.m_invIB*this.m_rB.x*this.m_rB.x+this.m_gamma;e.GetInverse(this.m_mass);this.m_C.x=
+b.x+this.m_rB.x-this.m_targetA.x;this.m_C.y=b.y+this.m_rB.y-this.m_targetA.y;this.m_C.SelfMul(this.m_beta);d*=.98;a.step.warmStarting?(this.m_impulse.SelfMul(a.step.dtRatio),c.x+=this.m_invMassB*this.m_impulse.x,c.y+=this.m_invMassB*this.m_impulse.y,d+=this.m_invIB*box2d.b2Cross_V2_V2(this.m_rB,this.m_impulse)):this.m_impulse.SetZero();a.velocities[this.m_indexB].w=d};goog.exportProperty(box2d.b2MouseJoint.prototype,"InitVelocityConstraints",box2d.b2MouseJoint.prototype.InitVelocityConstraints);
+box2d.b2MouseJoint.prototype.SolveVelocityConstraints=function(a){var b=a.velocities[this.m_indexB].v,c=a.velocities[this.m_indexB].w,d=box2d.b2AddCross_V2_S_V2(b,c,this.m_rB,box2d.b2MouseJoint.prototype.SolveVelocityConstraints.s_Cdot),d=box2d.b2Mul_M22_V2(this.m_mass,box2d.b2Add_V2_V2(d,box2d.b2Add_V2_V2(this.m_C,box2d.b2Mul_S_V2(this.m_gamma,this.m_impulse,box2d.b2Vec2.s_t0),box2d.b2Vec2.s_t0),box2d.b2Vec2.s_t0).SelfNeg(),box2d.b2MouseJoint.prototype.SolveVelocityConstraints.s_impulse),e=box2d.b2MouseJoint.prototype.SolveVelocityConstraints.s_oldImpulse.Copy(this.m_impulse);
+this.m_impulse.SelfAdd(d);var f=a.step.dt*this.m_maxForce;this.m_impulse.LengthSquared()>f*f&&this.m_impulse.SelfMul(f/this.m_impulse.Length());box2d.b2Sub_V2_V2(this.m_impulse,e,d);b.SelfMulAdd(this.m_invMassB,d);c+=this.m_invIB*box2d.b2Cross_V2_V2(this.m_rB,d);a.velocities[this.m_indexB].w=c};goog.exportProperty(box2d.b2MouseJoint.prototype,"SolveVelocityConstraints",box2d.b2MouseJoint.prototype.SolveVelocityConstraints);box2d.b2MouseJoint.prototype.SolveVelocityConstraints.s_Cdot=new box2d.b2Vec2;
+box2d.b2MouseJoint.prototype.SolveVelocityConstraints.s_impulse=new box2d.b2Vec2;box2d.b2MouseJoint.prototype.SolveVelocityConstraints.s_oldImpulse=new box2d.b2Vec2;box2d.b2MouseJoint.prototype.SolvePositionConstraints=function(a){return!0};goog.exportProperty(box2d.b2MouseJoint.prototype,"SolvePositionConstraints",box2d.b2MouseJoint.prototype.SolvePositionConstraints);box2d.b2MouseJoint.prototype.GetAnchorA=function(a){return a.Copy(this.m_targetA)};
+goog.exportProperty(box2d.b2MouseJoint.prototype,"GetAnchorA",box2d.b2MouseJoint.prototype.GetAnchorA);box2d.b2MouseJoint.prototype.GetAnchorB=function(a){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,a)};goog.exportProperty(box2d.b2MouseJoint.prototype,"GetAnchorB",box2d.b2MouseJoint.prototype.GetAnchorB);box2d.b2MouseJoint.prototype.GetReactionForce=function(a,b){return box2d.b2Mul_S_V2(a,this.m_impulse,b)};goog.exportProperty(box2d.b2MouseJoint.prototype,"GetReactionForce",box2d.b2MouseJoint.prototype.GetReactionForce);
+box2d.b2MouseJoint.prototype.GetReactionTorque=function(a){return 0};goog.exportProperty(box2d.b2MouseJoint.prototype,"GetReactionTorque",box2d.b2MouseJoint.prototype.GetReactionTorque);box2d.b2MouseJoint.prototype.Dump=function(){box2d.DEBUG&&box2d.b2Log("Mouse joint dumping is not supported.\n")};goog.exportProperty(box2d.b2MouseJoint.prototype,"Dump",box2d.b2MouseJoint.prototype.Dump);box2d.b2MouseJoint.prototype.ShiftOrigin=function(a){this.m_targetA.SelfSub(a)};
+goog.exportProperty(box2d.b2MouseJoint.prototype,"ShiftOrigin",box2d.b2MouseJoint.prototype.ShiftOrigin);box2d.b2PrismaticJointDef=function(){box2d.b2JointDef.call(this,box2d.b2JointType.e_prismaticJoint);this.localAnchorA=new box2d.b2Vec2;this.localAnchorB=new box2d.b2Vec2;this.localAxisA=new box2d.b2Vec2(1,0)};goog.inherits(box2d.b2PrismaticJointDef,box2d.b2JointDef);goog.exportSymbol("box2d.b2PrismaticJointDef",box2d.b2PrismaticJointDef);box2d.b2PrismaticJointDef.prototype.localAnchorA=null;goog.exportProperty(box2d.b2PrismaticJointDef.prototype,"localAnchorA",box2d.b2PrismaticJointDef.prototype.localAnchorA);
+box2d.b2PrismaticJointDef.prototype.localAnchorB=null;goog.exportProperty(box2d.b2PrismaticJointDef.prototype,"localAnchorB",box2d.b2PrismaticJointDef.prototype.localAnchorB);box2d.b2PrismaticJointDef.prototype.localAxisA=null;goog.exportProperty(box2d.b2PrismaticJointDef.prototype,"localAxisA",box2d.b2PrismaticJointDef.prototype.localAxisA);box2d.b2PrismaticJointDef.prototype.referenceAngle=0;goog.exportProperty(box2d.b2PrismaticJointDef.prototype,"referenceAngle",box2d.b2PrismaticJointDef.prototype.referenceAngle);
+box2d.b2PrismaticJointDef.prototype.enableLimit=!1;goog.exportProperty(box2d.b2PrismaticJointDef.prototype,"enableLimit",box2d.b2PrismaticJointDef.prototype.enableLimit);box2d.b2PrismaticJointDef.prototype.lowerTranslation=0;goog.exportProperty(box2d.b2PrismaticJointDef.prototype,"lowerTranslation",box2d.b2PrismaticJointDef.prototype.lowerTranslation);box2d.b2PrismaticJointDef.prototype.upperTranslation=0;goog.exportProperty(box2d.b2PrismaticJointDef.prototype,"upperTranslation",box2d.b2PrismaticJointDef.prototype.upperTranslation);
+box2d.b2PrismaticJointDef.prototype.enableMotor=!1;goog.exportProperty(box2d.b2PrismaticJointDef.prototype,"enableMotor",box2d.b2PrismaticJointDef.prototype.enableMotor);box2d.b2PrismaticJointDef.prototype.maxMotorForce=0;goog.exportProperty(box2d.b2PrismaticJointDef.prototype,"maxMotorForce",box2d.b2PrismaticJointDef.prototype.maxMotorForce);box2d.b2PrismaticJointDef.prototype.motorSpeed=0;goog.exportProperty(box2d.b2PrismaticJointDef.prototype,"motorSpeed",box2d.b2PrismaticJointDef.prototype.motorSpeed);
+box2d.b2PrismaticJointDef.prototype.Initialize=function(a,b,c,d){this.bodyA=a;this.bodyB=b;this.bodyA.GetLocalPoint(c,this.localAnchorA);this.bodyB.GetLocalPoint(c,this.localAnchorB);this.bodyA.GetLocalVector(d,this.localAxisA);this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()};goog.exportProperty(box2d.b2PrismaticJointDef.prototype,"Initialize",box2d.b2PrismaticJointDef.prototype.Initialize);
+box2d.b2PrismaticJoint=function(a){box2d.b2Joint.call(this,a);this.m_localAnchorA=a.localAnchorA.Clone();this.m_localAnchorB=a.localAnchorB.Clone();this.m_localXAxisA=a.localAxisA.Clone().SelfNormalize();this.m_localYAxisA=box2d.b2Cross_S_V2(1,this.m_localXAxisA,new box2d.b2Vec2);this.m_referenceAngle=a.referenceAngle;this.m_impulse=new box2d.b2Vec3(0,0,0);this.m_lowerTranslation=a.lowerTranslation;this.m_upperTranslation=a.upperTranslation;this.m_maxMotorForce=a.maxMotorForce;this.m_motorSpeed=a.motorSpeed;
+this.m_enableLimit=a.enableLimit;this.m_enableMotor=a.enableMotor;this.m_localCenterA=new box2d.b2Vec2;this.m_localCenterB=new box2d.b2Vec2;this.m_axis=new box2d.b2Vec2(0,0);this.m_perp=new box2d.b2Vec2(0,0);this.m_K=new box2d.b2Mat33;this.m_K3=new box2d.b2Mat33;this.m_K2=new box2d.b2Mat22;this.m_qA=new box2d.b2Rot;this.m_qB=new box2d.b2Rot;this.m_lalcA=new box2d.b2Vec2;this.m_lalcB=new box2d.b2Vec2;this.m_rA=new box2d.b2Vec2;this.m_rB=new box2d.b2Vec2};goog.inherits(box2d.b2PrismaticJoint,box2d.b2Joint);
+goog.exportSymbol("box2d.b2PrismaticJoint",box2d.b2PrismaticJoint);box2d.b2PrismaticJoint.prototype.m_localAnchorA=null;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_localAnchorA",box2d.b2PrismaticJoint.prototype.m_localAnchorA);box2d.b2PrismaticJoint.prototype.m_localAnchorB=null;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_localAnchorB",box2d.b2PrismaticJoint.prototype.m_localAnchorB);box2d.b2PrismaticJoint.prototype.m_localXAxisA=null;
+goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_localXAxisA",box2d.b2PrismaticJoint.prototype.m_localXAxisA);box2d.b2PrismaticJoint.prototype.m_localYAxisA=null;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_localYAxisA",box2d.b2PrismaticJoint.prototype.m_localYAxisA);box2d.b2PrismaticJoint.prototype.m_referenceAngle=0;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_referenceAngle",box2d.b2PrismaticJoint.prototype.m_referenceAngle);
+box2d.b2PrismaticJoint.prototype.m_impulse=null;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_impulse",box2d.b2PrismaticJoint.prototype.m_impulse);box2d.b2PrismaticJoint.prototype.m_motorImpulse=0;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_motorImpulse",box2d.b2PrismaticJoint.prototype.m_motorImpulse);box2d.b2PrismaticJoint.prototype.m_lowerTranslation=0;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_lowerTranslation",box2d.b2PrismaticJoint.prototype.m_lowerTranslation);
+box2d.b2PrismaticJoint.prototype.m_upperTranslation=0;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_upperTranslation",box2d.b2PrismaticJoint.prototype.m_upperTranslation);box2d.b2PrismaticJoint.prototype.m_maxMotorForce=0;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_maxMotorForce",box2d.b2PrismaticJoint.prototype.m_maxMotorForce);box2d.b2PrismaticJoint.prototype.m_motorSpeed=0;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_motorSpeed",box2d.b2PrismaticJoint.prototype.m_motorSpeed);
+box2d.b2PrismaticJoint.prototype.m_enableLimit=!1;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_enableLimit",box2d.b2PrismaticJoint.prototype.m_enableLimit);box2d.b2PrismaticJoint.prototype.m_enableMotor=!1;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_enableMotor",box2d.b2PrismaticJoint.prototype.m_enableMotor);box2d.b2PrismaticJoint.prototype.m_limitState=box2d.b2LimitState.e_inactiveLimit;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_limitState",box2d.b2PrismaticJoint.prototype.m_limitState);
+box2d.b2PrismaticJoint.prototype.m_indexA=0;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_indexA",box2d.b2PrismaticJoint.prototype.m_indexA);box2d.b2PrismaticJoint.prototype.m_indexB=0;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_indexB",box2d.b2PrismaticJoint.prototype.m_indexB);box2d.b2PrismaticJoint.prototype.m_localCenterA=null;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_localCenterA",box2d.b2PrismaticJoint.prototype.m_localCenterA);
+box2d.b2PrismaticJoint.prototype.m_localCenterB=null;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_localCenterB",box2d.b2PrismaticJoint.prototype.m_localCenterB);box2d.b2PrismaticJoint.prototype.m_invMassA=0;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_invMassA",box2d.b2PrismaticJoint.prototype.m_invMassA);box2d.b2PrismaticJoint.prototype.m_invMassB=0;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_invMassB",box2d.b2PrismaticJoint.prototype.m_invMassB);
+box2d.b2PrismaticJoint.prototype.m_invIA=0;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_invIA",box2d.b2PrismaticJoint.prototype.m_invIA);box2d.b2PrismaticJoint.prototype.m_invIB=0;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_invIB",box2d.b2PrismaticJoint.prototype.m_invIB);box2d.b2PrismaticJoint.prototype.m_axis=null;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_axis",box2d.b2PrismaticJoint.prototype.m_axis);box2d.b2PrismaticJoint.prototype.m_perp=null;
+goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_perp",box2d.b2PrismaticJoint.prototype.m_perp);box2d.b2PrismaticJoint.prototype.m_s1=0;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_s1",box2d.b2PrismaticJoint.prototype.m_s1);box2d.b2PrismaticJoint.prototype.m_s2=0;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_s2",box2d.b2PrismaticJoint.prototype.m_s2);box2d.b2PrismaticJoint.prototype.m_a1=0;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_a1",box2d.b2PrismaticJoint.prototype.m_a1);
+box2d.b2PrismaticJoint.prototype.m_a2=0;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_a2",box2d.b2PrismaticJoint.prototype.m_a2);box2d.b2PrismaticJoint.prototype.m_K=null;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_K",box2d.b2PrismaticJoint.prototype.m_K);box2d.b2PrismaticJoint.prototype.m_K3=null;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_K3",box2d.b2PrismaticJoint.prototype.m_K3);box2d.b2PrismaticJoint.prototype.m_K2=null;
+goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_K2",box2d.b2PrismaticJoint.prototype.m_K2);box2d.b2PrismaticJoint.prototype.m_motorMass=0;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_motorMass",box2d.b2PrismaticJoint.prototype.m_motorMass);box2d.b2PrismaticJoint.prototype.m_qA=null;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_qA",box2d.b2PrismaticJoint.prototype.m_qA);box2d.b2PrismaticJoint.prototype.m_qB=null;
+goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_qB",box2d.b2PrismaticJoint.prototype.m_qB);box2d.b2PrismaticJoint.prototype.m_lalcA=null;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_lalcA",box2d.b2PrismaticJoint.prototype.m_lalcA);box2d.b2PrismaticJoint.prototype.m_lalcB=null;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_lalcB",box2d.b2PrismaticJoint.prototype.m_lalcB);box2d.b2PrismaticJoint.prototype.m_rA=null;
+goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_rA",box2d.b2PrismaticJoint.prototype.m_rA);box2d.b2PrismaticJoint.prototype.m_rB=null;goog.exportProperty(box2d.b2PrismaticJoint.prototype,"m_rB",box2d.b2PrismaticJoint.prototype.m_rB);
+box2d.b2PrismaticJoint.prototype.InitVelocityConstraints=function(a){this.m_indexA=this.m_bodyA.m_islandIndex;this.m_indexB=this.m_bodyB.m_islandIndex;this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter);this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter);this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var b=a.positions[this.m_indexA].c,c=a.velocities[this.m_indexA].v,d=a.velocities[this.m_indexA].w,
+e=a.positions[this.m_indexB].c,f=a.positions[this.m_indexB].a,g=a.velocities[this.m_indexB].v,h=a.velocities[this.m_indexB].w,k=this.m_qA.SetAngle(a.positions[this.m_indexA].a),f=this.m_qB.SetAngle(f);box2d.b2Sub_V2_V2(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var l=box2d.b2Mul_R_V2(k,this.m_lalcA,this.m_rA);box2d.b2Sub_V2_V2(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var m=box2d.b2Mul_R_V2(f,this.m_lalcB,this.m_rB),n=box2d.b2Add_V2_V2(box2d.b2Sub_V2_V2(e,b,box2d.b2Vec2.s_t0),
+box2d.b2Sub_V2_V2(m,l,box2d.b2Vec2.s_t1),box2d.b2PrismaticJoint.prototype.InitVelocityConstraints.s_d),b=this.m_invMassA,e=this.m_invMassB,f=this.m_invIA,p=this.m_invIB;box2d.b2Mul_R_V2(k,this.m_localXAxisA,this.m_axis);this.m_a1=box2d.b2Cross_V2_V2(box2d.b2Add_V2_V2(n,l,box2d.b2Vec2.s_t0),this.m_axis);this.m_a2=box2d.b2Cross_V2_V2(m,this.m_axis);this.m_motorMass=b+e+f*this.m_a1*this.m_a1+p*this.m_a2*this.m_a2;0<this.m_motorMass&&(this.m_motorMass=1/this.m_motorMass);box2d.b2Mul_R_V2(k,this.m_localYAxisA,
+this.m_perp);this.m_s1=box2d.b2Cross_V2_V2(box2d.b2Add_V2_V2(n,l,box2d.b2Vec2.s_t0),this.m_perp);this.m_s2=box2d.b2Cross_V2_V2(m,this.m_perp);this.m_K.ex.x=b+e+f*this.m_s1*this.m_s1+p*this.m_s2*this.m_s2;this.m_K.ex.y=f*this.m_s1+p*this.m_s2;this.m_K.ex.z=f*this.m_s1*this.m_a1+p*this.m_s2*this.m_a2;this.m_K.ey.x=this.m_K.ex.y;this.m_K.ey.y=f+p;0===this.m_K.ey.y&&(this.m_K.ey.y=1);this.m_K.ey.z=f*this.m_a1+p*this.m_a2;this.m_K.ez.x=this.m_K.ex.z;this.m_K.ez.y=this.m_K.ey.z;this.m_K.ez.z=b+e+f*this.m_a1*
+this.m_a1+p*this.m_a2*this.m_a2;this.m_enableLimit?(k=box2d.b2Dot_V2_V2(this.m_axis,n),box2d.b2Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*box2d.b2_linearSlop?this.m_limitState=box2d.b2LimitState.e_equalLimits:k<=this.m_lowerTranslation?this.m_limitState!==box2d.b2LimitState.e_atLowerLimit&&(this.m_limitState=box2d.b2LimitState.e_atLowerLimit,this.m_impulse.z=0):k>=this.m_upperTranslation?this.m_limitState!==box2d.b2LimitState.e_atUpperLimit&&(this.m_limitState=box2d.b2LimitState.e_atUpperLimit,
+this.m_impulse.z=0):(this.m_limitState=box2d.b2LimitState.e_inactiveLimit,this.m_impulse.z=0)):(this.m_limitState=box2d.b2LimitState.e_inactiveLimit,this.m_impulse.z=0);this.m_enableMotor||(this.m_motorImpulse=0);a.step.warmStarting?(this.m_impulse.SelfMulScalar(a.step.dtRatio),this.m_motorImpulse*=a.step.dtRatio,k=box2d.b2Add_V2_V2(box2d.b2Mul_S_V2(this.m_impulse.x,this.m_perp,box2d.b2Vec2.s_t0),box2d.b2Mul_S_V2(this.m_motorImpulse+this.m_impulse.z,this.m_axis,box2d.b2Vec2.s_t1),box2d.b2PrismaticJoint.prototype.InitVelocityConstraints.s_P),
+l=this.m_impulse.x*this.m_s1+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a1,m=this.m_impulse.x*this.m_s2+this.m_impulse.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_a2,c.SelfMulSub(b,k),d-=f*l,g.SelfMulAdd(e,k),h+=p*m):(this.m_impulse.SetZero(),this.m_motorImpulse=0);a.velocities[this.m_indexA].w=d;a.velocities[this.m_indexB].w=h};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"InitVelocityConstraints",box2d.b2PrismaticJoint.prototype.InitVelocityConstraints);
+box2d.b2PrismaticJoint.prototype.InitVelocityConstraints.s_d=new box2d.b2Vec2;box2d.b2PrismaticJoint.prototype.InitVelocityConstraints.s_P=new box2d.b2Vec2;
+box2d.b2PrismaticJoint.prototype.SolveVelocityConstraints=function(a){var b=a.velocities[this.m_indexA].v,c=a.velocities[this.m_indexA].w,d=a.velocities[this.m_indexB].v,e=a.velocities[this.m_indexB].w,f=this.m_invMassA,g=this.m_invMassB,h=this.m_invIA,k=this.m_invIB;if(this.m_enableMotor&&this.m_limitState!==box2d.b2LimitState.e_equalLimits){var l=box2d.b2Dot_V2_V2(this.m_axis,box2d.b2Sub_V2_V2(d,b,box2d.b2Vec2.s_t0))+this.m_a2*e-this.m_a1*c,l=this.m_motorMass*(this.m_motorSpeed-l),m=this.m_motorImpulse,
+n=a.step.dt*this.m_maxMotorForce;this.m_motorImpulse=box2d.b2Clamp(this.m_motorImpulse+l,-n,n);l=this.m_motorImpulse-m;m=box2d.b2Mul_S_V2(l,this.m_axis,box2d.b2PrismaticJoint.prototype.SolveVelocityConstraints.s_P);n=l*this.m_a1;l*=this.m_a2;b.SelfMulSub(f,m);c-=h*n;d.SelfMulAdd(g,m);e+=k*l}var n=box2d.b2Dot_V2_V2(this.m_perp,box2d.b2Sub_V2_V2(d,b,box2d.b2Vec2.s_t0))+this.m_s2*e-this.m_s1*c,p=e-c;this.m_enableLimit&&this.m_limitState!==box2d.b2LimitState.e_inactiveLimit?(l=box2d.b2Dot_V2_V2(this.m_axis,
+box2d.b2Sub_V2_V2(d,b,box2d.b2Vec2.s_t0))+this.m_a2*e-this.m_a1*c,m=box2d.b2PrismaticJoint.prototype.SolveVelocityConstraints.s_f1.Copy(this.m_impulse),l=this.m_K.Solve33(-n,-p,-l,box2d.b2PrismaticJoint.prototype.SolveVelocityConstraints.s_df3),this.m_impulse.SelfAdd(l),this.m_limitState===box2d.b2LimitState.e_atLowerLimit?this.m_impulse.z=box2d.b2Max(this.m_impulse.z,0):this.m_limitState===box2d.b2LimitState.e_atUpperLimit&&(this.m_impulse.z=box2d.b2Min(this.m_impulse.z,0)),n=this.m_K.Solve22(-n-
+(this.m_impulse.z-m.z)*this.m_K.ez.x,-p-(this.m_impulse.z-m.z)*this.m_K.ez.y,box2d.b2PrismaticJoint.prototype.SolveVelocityConstraints.s_f2r),n.x+=m.x,n.y+=m.y,this.m_impulse.x=n.x,this.m_impulse.y=n.y,l.x=this.m_impulse.x-m.x,l.y=this.m_impulse.y-m.y,l.z=this.m_impulse.z-m.z,m=box2d.b2Add_V2_V2(box2d.b2Mul_S_V2(l.x,this.m_perp,box2d.b2Vec2.s_t0),box2d.b2Mul_S_V2(l.z,this.m_axis,box2d.b2Vec2.s_t1),box2d.b2PrismaticJoint.prototype.SolveVelocityConstraints.s_P),n=l.x*this.m_s1+l.y+l.z*this.m_a1,l=l.x*
+this.m_s2+l.y+l.z*this.m_a2):(l=this.m_K.Solve22(-n,-p,box2d.b2PrismaticJoint.prototype.SolveVelocityConstraints.s_df2),this.m_impulse.x+=l.x,this.m_impulse.y+=l.y,m=box2d.b2Mul_S_V2(l.x,this.m_perp,box2d.b2PrismaticJoint.prototype.SolveVelocityConstraints.s_P),n=l.x*this.m_s1+l.y,l=l.x*this.m_s2+l.y);b.SelfMulSub(f,m);c-=h*n;d.SelfMulAdd(g,m);a.velocities[this.m_indexA].w=c;a.velocities[this.m_indexB].w=e+k*l};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"SolveVelocityConstraints",box2d.b2PrismaticJoint.prototype.SolveVelocityConstraints);
+box2d.b2PrismaticJoint.prototype.SolveVelocityConstraints.s_P=new box2d.b2Vec2;box2d.b2PrismaticJoint.prototype.SolveVelocityConstraints.s_f2r=new box2d.b2Vec2;box2d.b2PrismaticJoint.prototype.SolveVelocityConstraints.s_f1=new box2d.b2Vec3;box2d.b2PrismaticJoint.prototype.SolveVelocityConstraints.s_df3=new box2d.b2Vec3;box2d.b2PrismaticJoint.prototype.SolveVelocityConstraints.s_df2=new box2d.b2Vec2;
+box2d.b2PrismaticJoint.prototype.SolvePositionConstraints=function(a){var b=a.positions[this.m_indexA].c,c=a.positions[this.m_indexA].a,d=a.positions[this.m_indexB].c,e=a.positions[this.m_indexB].a,f=this.m_qA.SetAngle(c),g=this.m_qB.SetAngle(e),h=this.m_invMassA,k=this.m_invMassB,l=this.m_invIA,m=this.m_invIB,n=box2d.b2Mul_R_V2(f,this.m_lalcA,this.m_rA),p=box2d.b2Mul_R_V2(g,this.m_lalcB,this.m_rB),q=box2d.b2Sub_V2_V2(box2d.b2Add_V2_V2(d,p,box2d.b2Vec2.s_t0),box2d.b2Add_V2_V2(b,n,box2d.b2Vec2.s_t1),
+box2d.b2PrismaticJoint.prototype.SolvePositionConstraints.s_d),r=box2d.b2Mul_R_V2(f,this.m_localXAxisA,this.m_axis),u=box2d.b2Cross_V2_V2(box2d.b2Add_V2_V2(q,n,box2d.b2Vec2.s_t0),r),g=box2d.b2Cross_V2_V2(p,r),f=box2d.b2Mul_R_V2(f,this.m_localYAxisA,this.m_perp),t=box2d.b2Cross_V2_V2(box2d.b2Add_V2_V2(q,n,box2d.b2Vec2.s_t0),f),w=box2d.b2Cross_V2_V2(p,f),x=box2d.b2PrismaticJoint.prototype.SolvePositionConstraints.s_impulse,v=box2d.b2Dot_V2_V2(f,q),y=e-c-this.m_referenceAngle,n=box2d.b2Abs(v),p=box2d.b2Abs(y),
+z=!1,B=0;this.m_enableLimit&&(q=box2d.b2Dot_V2_V2(r,q),box2d.b2Abs(this.m_upperTranslation-this.m_lowerTranslation)<2*box2d.b2_linearSlop?(B=box2d.b2Clamp(q,-box2d.b2_maxLinearCorrection,box2d.b2_maxLinearCorrection),n=box2d.b2Max(n,box2d.b2Abs(q)),z=!0):q<=this.m_lowerTranslation?(B=box2d.b2Clamp(q-this.m_lowerTranslation+box2d.b2_linearSlop,-box2d.b2_maxLinearCorrection,0),n=box2d.b2Max(n,this.m_lowerTranslation-q),z=!0):q>=this.m_upperTranslation&&(B=box2d.b2Clamp(q-this.m_upperTranslation-box2d.b2_linearSlop,
+0,box2d.b2_maxLinearCorrection),n=box2d.b2Max(n,q-this.m_upperTranslation),z=!0));if(z){var q=l*t+m*w,E=l*t*u+m*w*g,z=l+m;0===z&&(z=1);var F=l*u+m*g,G=h+k+l*u*u+m*g*g,H=this.m_K3;H.ex.Set(h+k+l*t*t+m*w*w,q,E);H.ey.Set(q,z,F);H.ez.Set(E,F,G);x=H.Solve33(-v,-y,-B,x)}else q=l*t+m*w,z=l+m,0===z&&(z=1),B=this.m_K2,B.ex.Set(h+k+l*t*t+m*w*w,q),B.ey.Set(q,z),v=B.Solve(-v,-y,box2d.b2PrismaticJoint.prototype.SolvePositionConstraints.s_impulse1),x.x=v.x,x.y=v.y,x.z=0;r=box2d.b2Add_V2_V2(box2d.b2Mul_S_V2(x.x,
+f,box2d.b2Vec2.s_t0),box2d.b2Mul_S_V2(x.z,r,box2d.b2Vec2.s_t1),box2d.b2PrismaticJoint.prototype.SolvePositionConstraints.s_P);u=x.x*t+x.y+x.z*u;g=x.x*w+x.y+x.z*g;b.SelfMulSub(h,r);c-=l*u;d.SelfMulAdd(k,r);a.positions[this.m_indexA].a=c;a.positions[this.m_indexB].a=e+m*g;return n<=box2d.b2_linearSlop&&p<=box2d.b2_angularSlop};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"SolvePositionConstraints",box2d.b2PrismaticJoint.prototype.SolvePositionConstraints);
+box2d.b2PrismaticJoint.prototype.SolvePositionConstraints.s_d=new box2d.b2Vec2;box2d.b2PrismaticJoint.prototype.SolvePositionConstraints.s_impulse=new box2d.b2Vec3;box2d.b2PrismaticJoint.prototype.SolvePositionConstraints.s_impulse1=new box2d.b2Vec2;box2d.b2PrismaticJoint.prototype.SolvePositionConstraints.s_P=new box2d.b2Vec2;box2d.b2PrismaticJoint.prototype.GetAnchorA=function(a){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,a)};
+goog.exportProperty(box2d.b2PrismaticJoint.prototype,"GetAnchorA",box2d.b2PrismaticJoint.prototype.GetAnchorA);box2d.b2PrismaticJoint.prototype.GetAnchorB=function(a){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,a)};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"GetAnchorB",box2d.b2PrismaticJoint.prototype.GetAnchorB);
+box2d.b2PrismaticJoint.prototype.GetReactionForce=function(a,b){return b.Set(a*(this.m_impulse.x*this.m_perp.x+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.x),a*(this.m_impulse.x*this.m_perp.y+(this.m_motorImpulse+this.m_impulse.z)*this.m_axis.y))};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"GetReactionForce",box2d.b2PrismaticJoint.prototype.GetReactionForce);box2d.b2PrismaticJoint.prototype.GetReactionTorque=function(a){return a*this.m_impulse.y};
+goog.exportProperty(box2d.b2PrismaticJoint.prototype,"GetReactionTorque",box2d.b2PrismaticJoint.prototype.GetReactionTorque);box2d.b2PrismaticJoint.prototype.GetLocalAnchorA=function(a){return a.Copy(this.m_localAnchorA)};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"GetLocalAnchorA",box2d.b2PrismaticJoint.prototype.GetLocalAnchorA);box2d.b2PrismaticJoint.prototype.GetLocalAnchorB=function(a){return a.Copy(this.m_localAnchorB)};
+goog.exportProperty(box2d.b2PrismaticJoint.prototype,"GetLocalAnchorB",box2d.b2PrismaticJoint.prototype.GetLocalAnchorB);box2d.b2PrismaticJoint.prototype.GetLocalAxisA=function(a){return a.Copy(this.m_localXAxisA)};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"GetLocalAxisA",box2d.b2PrismaticJoint.prototype.GetLocalAxisA);box2d.b2PrismaticJoint.prototype.GetReferenceAngle=function(){return this.m_referenceAngle};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"GetReferenceAngle",box2d.b2PrismaticJoint.prototype.GetReferenceAngle);
+box2d.b2PrismaticJoint.prototype.GetJointTranslation=function(){var a=this.m_bodyA.GetWorldPoint(this.m_localAnchorA,box2d.b2PrismaticJoint.prototype.GetJointTranslation.s_pA),b=this.m_bodyB.GetWorldPoint(this.m_localAnchorB,box2d.b2PrismaticJoint.prototype.GetJointTranslation.s_pB),a=box2d.b2Sub_V2_V2(b,a,box2d.b2PrismaticJoint.prototype.GetJointTranslation.s_d),b=this.m_bodyA.GetWorldVector(this.m_localXAxisA,box2d.b2PrismaticJoint.prototype.GetJointTranslation.s_axis);return box2d.b2Dot_V2_V2(a,
+b)};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"GetJointTranslation",box2d.b2PrismaticJoint.prototype.GetJointTranslation);box2d.b2PrismaticJoint.prototype.GetJointTranslation.s_pA=new box2d.b2Vec2;box2d.b2PrismaticJoint.prototype.GetJointTranslation.s_pB=new box2d.b2Vec2;box2d.b2PrismaticJoint.prototype.GetJointTranslation.s_d=new box2d.b2Vec2;box2d.b2PrismaticJoint.prototype.GetJointTranslation.s_axis=new box2d.b2Vec2;
+box2d.b2PrismaticJoint.prototype.GetJointSpeed=function(){var a=this.m_bodyA,b=this.m_bodyB;box2d.b2Sub_V2_V2(this.m_localAnchorA,a.m_sweep.localCenter,this.m_lalcA);var c=box2d.b2Mul_R_V2(a.m_xf.q,this.m_lalcA,this.m_rA);box2d.b2Sub_V2_V2(this.m_localAnchorB,b.m_sweep.localCenter,this.m_lalcB);var d=box2d.b2Mul_R_V2(b.m_xf.q,this.m_lalcB,this.m_rB),e=box2d.b2Add_V2_V2(a.m_sweep.c,c,box2d.b2Vec2.s_t0),f=box2d.b2Add_V2_V2(b.m_sweep.c,d,box2d.b2Vec2.s_t1),e=box2d.b2Sub_V2_V2(f,e,box2d.b2Vec2.s_t2),
+f=a.GetWorldVector(this.m_localXAxisA,this.m_axis),g=a.m_linearVelocity,h=b.m_linearVelocity,a=a.m_angularVelocity,b=b.m_angularVelocity;return box2d.b2Dot_V2_V2(e,box2d.b2Cross_S_V2(a,f,box2d.b2Vec2.s_t0))+box2d.b2Dot_V2_V2(f,box2d.b2Sub_V2_V2(box2d.b2AddCross_V2_S_V2(h,b,d,box2d.b2Vec2.s_t0),box2d.b2AddCross_V2_S_V2(g,a,c,box2d.b2Vec2.s_t1),box2d.b2Vec2.s_t0))};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"GetJointSpeed",box2d.b2PrismaticJoint.prototype.GetJointSpeed);
+box2d.b2PrismaticJoint.prototype.IsLimitEnabled=function(){return this.m_enableLimit};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"IsLimitEnabled",box2d.b2PrismaticJoint.prototype.IsLimitEnabled);box2d.b2PrismaticJoint.prototype.EnableLimit=function(a){a!==this.m_enableLimit&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableLimit=a,this.m_impulse.z=0)};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"EnableLimit",box2d.b2PrismaticJoint.prototype.EnableLimit);
+box2d.b2PrismaticJoint.prototype.GetLowerLimit=function(){return this.m_lowerTranslation};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"GetLowerLimit",box2d.b2PrismaticJoint.prototype.GetLowerLimit);box2d.b2PrismaticJoint.prototype.GetUpperLimit=function(){return this.m_upperTranslation};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"GetUpperLimit",box2d.b2PrismaticJoint.prototype.GetUpperLimit);
+box2d.b2PrismaticJoint.prototype.SetLimits=function(a,b){if(a!==this.m_lowerTranslation||b!==this.m_upperTranslation)this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_lowerTranslation=a,this.m_upperTranslation=b,this.m_impulse.z=0};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"SetLimits",box2d.b2PrismaticJoint.prototype.SetLimits);box2d.b2PrismaticJoint.prototype.IsMotorEnabled=function(){return this.m_enableMotor};
+goog.exportProperty(box2d.b2PrismaticJoint.prototype,"IsMotorEnabled",box2d.b2PrismaticJoint.prototype.IsMotorEnabled);box2d.b2PrismaticJoint.prototype.EnableMotor=function(a){this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_enableMotor=a};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"EnableMotor",box2d.b2PrismaticJoint.prototype.EnableMotor);box2d.b2PrismaticJoint.prototype.SetMotorSpeed=function(a){this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_motorSpeed=a};
+goog.exportProperty(box2d.b2PrismaticJoint.prototype,"SetMotorSpeed",box2d.b2PrismaticJoint.prototype.SetMotorSpeed);box2d.b2PrismaticJoint.prototype.GetMotorSpeed=function(){return this.m_motorSpeed};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"GetMotorSpeed",box2d.b2PrismaticJoint.prototype.GetMotorSpeed);box2d.b2PrismaticJoint.prototype.SetMaxMotorForce=function(a){this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_maxMotorForce=a};
+goog.exportProperty(box2d.b2PrismaticJoint.prototype,"SetMaxMotorForce",box2d.b2PrismaticJoint.prototype.SetMaxMotorForce);box2d.b2PrismaticJoint.prototype.GetMaxMotorForce=function(){return this.m_maxMotorForce};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"GetMaxMotorForce",box2d.b2PrismaticJoint.prototype.GetMaxMotorForce);box2d.b2PrismaticJoint.prototype.GetMotorForce=function(a){return a*this.m_motorImpulse};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"GetMotorForce",box2d.b2PrismaticJoint.prototype.GetMotorForce);
+box2d.b2PrismaticJoint.prototype.Dump=function(){if(box2d.DEBUG){var a=this.m_bodyA.m_islandIndex,b=this.m_bodyB.m_islandIndex;box2d.b2Log("  /*box2d.b2PrismaticJointDef*/ var jd = new box2d.b2PrismaticJointDef();\n");box2d.b2Log("  jd.bodyA = bodies[%d];\n",a);box2d.b2Log("  jd.bodyB = bodies[%d];\n",b);box2d.b2Log("  jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false");box2d.b2Log("  jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y);box2d.b2Log("  jd.localAnchorB.Set(%.15f, %.15f);\n",
+this.m_localAnchorB.x,this.m_localAnchorB.y);box2d.b2Log("  jd.localAxisA.Set(%.15f, %.15f);\n",this.m_localXAxisA.x,this.m_localXAxisA.y);box2d.b2Log("  jd.referenceAngle = %.15f;\n",this.m_referenceAngle);box2d.b2Log("  jd.enableLimit = %s;\n",this.m_enableLimit?"true":"false");box2d.b2Log("  jd.lowerTranslation = %.15f;\n",this.m_lowerTranslation);box2d.b2Log("  jd.upperTranslation = %.15f;\n",this.m_upperTranslation);box2d.b2Log("  jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false");box2d.b2Log("  jd.motorSpeed = %.15f;\n",
+this.m_motorSpeed);box2d.b2Log("  jd.maxMotorForce = %.15f;\n",this.m_maxMotorForce);box2d.b2Log("  joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}};goog.exportProperty(box2d.b2PrismaticJoint.prototype,"Dump",box2d.b2PrismaticJoint.prototype.Dump);box2d.b2_minPulleyLength=2;goog.exportSymbol("box2d.b2_minPulleyLength",box2d.b2_minPulleyLength);box2d.b2PulleyJointDef=function(){box2d.b2JointDef.call(this,box2d.b2JointType.e_pulleyJoint);this.collideConnected=!0;this.groundAnchorA=new box2d.b2Vec2(-1,1);this.groundAnchorB=new box2d.b2Vec2(1,1);this.localAnchorA=new box2d.b2Vec2(-1,0);this.localAnchorB=new box2d.b2Vec2(1,0)};goog.inherits(box2d.b2PulleyJointDef,box2d.b2JointDef);goog.exportSymbol("box2d.b2PulleyJointDef",box2d.b2PulleyJointDef);
+box2d.b2PulleyJointDef.prototype.groundAnchorA=null;goog.exportProperty(box2d.b2PulleyJointDef.prototype,"groundAnchorA",box2d.b2PulleyJointDef.prototype.groundAnchorA);box2d.b2PulleyJointDef.prototype.groundAnchorB=null;goog.exportProperty(box2d.b2PulleyJointDef.prototype,"groundAnchorB",box2d.b2PulleyJointDef.prototype.groundAnchorB);box2d.b2PulleyJointDef.prototype.localAnchorA=null;goog.exportProperty(box2d.b2PulleyJointDef.prototype,"localAnchorA",box2d.b2PulleyJointDef.prototype.localAnchorA);
+box2d.b2PulleyJointDef.prototype.localAnchorB=null;goog.exportProperty(box2d.b2PulleyJointDef.prototype,"localAnchorB",box2d.b2PulleyJointDef.prototype.localAnchorB);box2d.b2PulleyJointDef.prototype.lengthA=0;goog.exportProperty(box2d.b2PulleyJointDef.prototype,"lengthA",box2d.b2PulleyJointDef.prototype.lengthA);box2d.b2PulleyJointDef.prototype.lengthB=0;goog.exportProperty(box2d.b2PulleyJointDef.prototype,"lengthB",box2d.b2PulleyJointDef.prototype.lengthB);
+box2d.b2PulleyJointDef.prototype.ratio=1;goog.exportProperty(box2d.b2PulleyJointDef.prototype,"ratio",box2d.b2PulleyJointDef.prototype.ratio);
+box2d.b2PulleyJointDef.prototype.Initialize=function(a,b,c,d,e,f,g){this.bodyA=a;this.bodyB=b;this.groundAnchorA.Copy(c);this.groundAnchorB.Copy(d);this.bodyA.GetLocalPoint(e,this.localAnchorA);this.bodyB.GetLocalPoint(f,this.localAnchorB);this.lengthA=box2d.b2Distance(e,c);this.lengthB=box2d.b2Distance(f,d);this.ratio=g;box2d.ENABLE_ASSERTS&&box2d.b2Assert(this.ratio>box2d.b2_epsilon)};goog.exportProperty(box2d.b2PulleyJointDef.prototype,"Initialize",box2d.b2PulleyJointDef.prototype.Initialize);
+box2d.b2PulleyJoint=function(a){box2d.b2Joint.call(this,a);this.m_groundAnchorA=new box2d.b2Vec2;this.m_groundAnchorB=new box2d.b2Vec2;this.m_localAnchorA=new box2d.b2Vec2;this.m_localAnchorB=new box2d.b2Vec2;this.m_uA=new box2d.b2Vec2;this.m_uB=new box2d.b2Vec2;this.m_rA=new box2d.b2Vec2;this.m_rB=new box2d.b2Vec2;this.m_localCenterA=new box2d.b2Vec2;this.m_localCenterB=new box2d.b2Vec2;this.m_qA=new box2d.b2Rot;this.m_qB=new box2d.b2Rot;this.m_lalcA=new box2d.b2Vec2;this.m_lalcB=new box2d.b2Vec2;
+this.m_groundAnchorA.Copy(a.groundAnchorA);this.m_groundAnchorB.Copy(a.groundAnchorB);this.m_localAnchorA.Copy(a.localAnchorA);this.m_localAnchorB.Copy(a.localAnchorB);this.m_lengthA=a.lengthA;this.m_lengthB=a.lengthB;box2d.ENABLE_ASSERTS&&box2d.b2Assert(0!==a.ratio);this.m_ratio=a.ratio;this.m_constant=a.lengthA+this.m_ratio*a.lengthB;this.m_impulse=0};goog.inherits(box2d.b2PulleyJoint,box2d.b2Joint);goog.exportSymbol("box2d.b2PulleyJoint",box2d.b2PulleyJoint);
+box2d.b2PulleyJoint.prototype.m_groundAnchorA=null;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_groundAnchorA",box2d.b2PulleyJoint.prototype.m_groundAnchorA);box2d.b2PulleyJoint.prototype.m_groundAnchorB=null;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_groundAnchorB",box2d.b2PulleyJoint.prototype.m_groundAnchorB);box2d.b2PulleyJoint.prototype.m_lengthA=0;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_lengthA",box2d.b2PulleyJoint.prototype.m_lengthA);
+box2d.b2PulleyJoint.prototype.m_lengthB=0;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_lengthB",box2d.b2PulleyJoint.prototype.m_lengthB);box2d.b2PulleyJoint.prototype.m_localAnchorA=null;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_localAnchorA",box2d.b2PulleyJoint.prototype.m_localAnchorA);box2d.b2PulleyJoint.prototype.m_localAnchorB=null;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_localAnchorB",box2d.b2PulleyJoint.prototype.m_localAnchorB);
+box2d.b2PulleyJoint.prototype.m_constant=0;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_constant",box2d.b2PulleyJoint.prototype.m_constant);box2d.b2PulleyJoint.prototype.m_ratio=0;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_ratio",box2d.b2PulleyJoint.prototype.m_ratio);box2d.b2PulleyJoint.prototype.m_impulse=0;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_impulse",box2d.b2PulleyJoint.prototype.m_impulse);box2d.b2PulleyJoint.prototype.m_indexA=0;
+goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_indexA",box2d.b2PulleyJoint.prototype.m_indexA);box2d.b2PulleyJoint.prototype.m_indexB=0;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_indexB",box2d.b2PulleyJoint.prototype.m_indexB);box2d.b2PulleyJoint.prototype.m_uA=null;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_uA",box2d.b2PulleyJoint.prototype.m_uA);box2d.b2PulleyJoint.prototype.m_uB=null;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_uB",box2d.b2PulleyJoint.prototype.m_uB);
+box2d.b2PulleyJoint.prototype.m_rA=null;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_rA",box2d.b2PulleyJoint.prototype.m_rA);box2d.b2PulleyJoint.prototype.m_rB=null;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_rB",box2d.b2PulleyJoint.prototype.m_rB);box2d.b2PulleyJoint.prototype.m_localCenterA=null;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_localCenterA",box2d.b2PulleyJoint.prototype.m_localCenterA);box2d.b2PulleyJoint.prototype.m_localCenterB=null;
+goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_localCenterB",box2d.b2PulleyJoint.prototype.m_localCenterB);box2d.b2PulleyJoint.prototype.m_invMassA=0;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_invMassA",box2d.b2PulleyJoint.prototype.m_invMassA);box2d.b2PulleyJoint.prototype.m_invMassB=0;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_invMassB",box2d.b2PulleyJoint.prototype.m_invMassB);box2d.b2PulleyJoint.prototype.m_invIA=0;
+goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_invIA",box2d.b2PulleyJoint.prototype.m_invIA);box2d.b2PulleyJoint.prototype.m_invIB=0;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_invIB",box2d.b2PulleyJoint.prototype.m_invIB);box2d.b2PulleyJoint.prototype.m_mass=0;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_mass",box2d.b2PulleyJoint.prototype.m_mass);box2d.b2PulleyJoint.prototype.m_qA=null;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_qA",box2d.b2PulleyJoint.prototype.m_qA);
+box2d.b2PulleyJoint.prototype.m_qB=null;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_qB",box2d.b2PulleyJoint.prototype.m_qB);box2d.b2PulleyJoint.prototype.m_lalcA=null;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_lalcA",box2d.b2PulleyJoint.prototype.m_lalcA);box2d.b2PulleyJoint.prototype.m_lalcB=null;goog.exportProperty(box2d.b2PulleyJoint.prototype,"m_lalcB",box2d.b2PulleyJoint.prototype.m_lalcB);
+box2d.b2PulleyJoint.prototype.InitVelocityConstraints=function(a){this.m_indexA=this.m_bodyA.m_islandIndex;this.m_indexB=this.m_bodyB.m_islandIndex;this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter);this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter);this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var b=a.positions[this.m_indexA].c,c=a.velocities[this.m_indexA].v,d=a.velocities[this.m_indexA].w,
+e=a.positions[this.m_indexB].c,f=a.positions[this.m_indexB].a,g=a.velocities[this.m_indexB].v,h=a.velocities[this.m_indexB].w,k=this.m_qA.SetAngle(a.positions[this.m_indexA].a),f=this.m_qB.SetAngle(f);box2d.b2Sub_V2_V2(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);box2d.b2Mul_R_V2(k,this.m_lalcA,this.m_rA);box2d.b2Sub_V2_V2(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);box2d.b2Mul_R_V2(f,this.m_lalcB,this.m_rB);this.m_uA.Copy(b).SelfAdd(this.m_rA).SelfSub(this.m_groundAnchorA);this.m_uB.Copy(e).SelfAdd(this.m_rB).SelfSub(this.m_groundAnchorB);
+b=this.m_uA.Length();e=this.m_uB.Length();b>10*box2d.b2_linearSlop?this.m_uA.SelfMul(1/b):this.m_uA.SetZero();e>10*box2d.b2_linearSlop?this.m_uB.SelfMul(1/e):this.m_uB.SetZero();b=box2d.b2Cross_V2_V2(this.m_rA,this.m_uA);e=box2d.b2Cross_V2_V2(this.m_rB,this.m_uB);this.m_mass=this.m_invMassA+this.m_invIA*b*b+this.m_ratio*this.m_ratio*(this.m_invMassB+this.m_invIB*e*e);0<this.m_mass&&(this.m_mass=1/this.m_mass);a.step.warmStarting?(this.m_impulse*=a.step.dtRatio,b=box2d.b2Mul_S_V2(-this.m_impulse,this.m_uA,
+box2d.b2PulleyJoint.prototype.InitVelocityConstraints.s_PA),e=box2d.b2Mul_S_V2(-this.m_ratio*this.m_impulse,this.m_uB,box2d.b2PulleyJoint.prototype.InitVelocityConstraints.s_PB),c.SelfMulAdd(this.m_invMassA,b),d+=this.m_invIA*box2d.b2Cross_V2_V2(this.m_rA,b),g.SelfMulAdd(this.m_invMassB,e),h+=this.m_invIB*box2d.b2Cross_V2_V2(this.m_rB,e)):this.m_impulse=0;a.velocities[this.m_indexA].w=d;a.velocities[this.m_indexB].w=h};goog.exportProperty(box2d.b2PulleyJoint.prototype,"InitVelocityConstraints",box2d.b2PulleyJoint.prototype.InitVelocityConstraints);
+box2d.b2PulleyJoint.prototype.InitVelocityConstraints.s_PA=new box2d.b2Vec2;box2d.b2PulleyJoint.prototype.InitVelocityConstraints.s_PB=new box2d.b2Vec2;
+box2d.b2PulleyJoint.prototype.SolveVelocityConstraints=function(a){var b=a.velocities[this.m_indexA].v,c=a.velocities[this.m_indexA].w,d=a.velocities[this.m_indexB].v,e=a.velocities[this.m_indexB].w,f=box2d.b2AddCross_V2_S_V2(b,c,this.m_rA,box2d.b2PulleyJoint.prototype.SolveVelocityConstraints.s_vpA),g=box2d.b2AddCross_V2_S_V2(d,e,this.m_rB,box2d.b2PulleyJoint.prototype.SolveVelocityConstraints.s_vpB),f=-box2d.b2Dot_V2_V2(this.m_uA,f)-this.m_ratio*box2d.b2Dot_V2_V2(this.m_uB,g),g=-this.m_mass*f;this.m_impulse+=
+g;f=box2d.b2Mul_S_V2(-g,this.m_uA,box2d.b2PulleyJoint.prototype.SolveVelocityConstraints.s_PA);g=box2d.b2Mul_S_V2(-this.m_ratio*g,this.m_uB,box2d.b2PulleyJoint.prototype.SolveVelocityConstraints.s_PB);b.SelfMulAdd(this.m_invMassA,f);c+=this.m_invIA*box2d.b2Cross_V2_V2(this.m_rA,f);d.SelfMulAdd(this.m_invMassB,g);e+=this.m_invIB*box2d.b2Cross_V2_V2(this.m_rB,g);a.velocities[this.m_indexA].w=c;a.velocities[this.m_indexB].w=e};
+goog.exportProperty(box2d.b2PulleyJoint.prototype,"SolveVelocityConstraints",box2d.b2PulleyJoint.prototype.SolveVelocityConstraints);box2d.b2PulleyJoint.prototype.SolveVelocityConstraints.s_vpA=new box2d.b2Vec2;box2d.b2PulleyJoint.prototype.SolveVelocityConstraints.s_vpB=new box2d.b2Vec2;box2d.b2PulleyJoint.prototype.SolveVelocityConstraints.s_PA=new box2d.b2Vec2;box2d.b2PulleyJoint.prototype.SolveVelocityConstraints.s_PB=new box2d.b2Vec2;
+box2d.b2PulleyJoint.prototype.SolvePositionConstraints=function(a){var b=a.positions[this.m_indexA].c,c=a.positions[this.m_indexA].a,d=a.positions[this.m_indexB].c,e=a.positions[this.m_indexB].a,f=this.m_qA.SetAngle(c),g=this.m_qB.SetAngle(e);box2d.b2Sub_V2_V2(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);f=box2d.b2Mul_R_V2(f,this.m_lalcA,this.m_rA);box2d.b2Sub_V2_V2(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var g=box2d.b2Mul_R_V2(g,this.m_lalcB,this.m_rB),h=this.m_uA.Copy(b).SelfAdd(f).SelfSub(this.m_groundAnchorA),
+k=this.m_uB.Copy(d).SelfAdd(g).SelfSub(this.m_groundAnchorB),l=h.Length(),m=k.Length();l>10*box2d.b2_linearSlop?h.SelfMul(1/l):h.SetZero();m>10*box2d.b2_linearSlop?k.SelfMul(1/m):k.SetZero();var n=box2d.b2Cross_V2_V2(f,h),p=box2d.b2Cross_V2_V2(g,k),n=this.m_invMassA+this.m_invIA*n*n+this.m_ratio*this.m_ratio*(this.m_invMassB+this.m_invIB*p*p);0<n&&(n=1/n);m=this.m_constant-l-this.m_ratio*m;l=box2d.b2Abs(m);m*=-n;h=box2d.b2Mul_S_V2(-m,h,box2d.b2PulleyJoint.prototype.SolvePositionConstraints.s_PA);
+k=box2d.b2Mul_S_V2(-this.m_ratio*m,k,box2d.b2PulleyJoint.prototype.SolvePositionConstraints.s_PB);b.SelfMulAdd(this.m_invMassA,h);c+=this.m_invIA*box2d.b2Cross_V2_V2(f,h);d.SelfMulAdd(this.m_invMassB,k);e+=this.m_invIB*box2d.b2Cross_V2_V2(g,k);a.positions[this.m_indexA].a=c;a.positions[this.m_indexB].a=e;return l<box2d.b2_linearSlop};goog.exportProperty(box2d.b2PulleyJoint.prototype,"SolvePositionConstraints",box2d.b2PulleyJoint.prototype.SolvePositionConstraints);
+box2d.b2PulleyJoint.prototype.SolvePositionConstraints.s_PA=new box2d.b2Vec2;box2d.b2PulleyJoint.prototype.SolvePositionConstraints.s_PB=new box2d.b2Vec2;box2d.b2PulleyJoint.prototype.GetAnchorA=function(a){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,a)};goog.exportProperty(box2d.b2PulleyJoint.prototype,"GetAnchorA",box2d.b2PulleyJoint.prototype.GetAnchorA);box2d.b2PulleyJoint.prototype.GetAnchorB=function(a){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,a)};
+goog.exportProperty(box2d.b2PulleyJoint.prototype,"GetAnchorB",box2d.b2PulleyJoint.prototype.GetAnchorB);box2d.b2PulleyJoint.prototype.GetReactionForce=function(a,b){return b.Set(a*this.m_impulse*this.m_uB.x,a*this.m_impulse*this.m_uB.y)};goog.exportProperty(box2d.b2PulleyJoint.prototype,"GetReactionForce",box2d.b2PulleyJoint.prototype.GetReactionForce);box2d.b2PulleyJoint.prototype.GetReactionTorque=function(a){return 0};goog.exportProperty(box2d.b2PulleyJoint.prototype,"GetReactionTorque",box2d.b2PulleyJoint.prototype.GetReactionTorque);
+box2d.b2PulleyJoint.prototype.GetGroundAnchorA=function(a){return a.Copy(this.m_groundAnchorA)};goog.exportProperty(box2d.b2PulleyJoint.prototype,"GetGroundAnchorA",box2d.b2PulleyJoint.prototype.GetGroundAnchorA);box2d.b2PulleyJoint.prototype.GetGroundAnchorB=function(a){return a.Copy(this.m_groundAnchorB)};goog.exportProperty(box2d.b2PulleyJoint.prototype,"GetGroundAnchorB",box2d.b2PulleyJoint.prototype.GetGroundAnchorB);box2d.b2PulleyJoint.prototype.GetLengthA=function(){return this.m_lengthA};
+goog.exportProperty(box2d.b2PulleyJoint.prototype,"GetLengthA",box2d.b2PulleyJoint.prototype.GetLengthA);box2d.b2PulleyJoint.prototype.GetLengthB=function(){return this.m_lengthB};goog.exportProperty(box2d.b2PulleyJoint.prototype,"GetLengthB",box2d.b2PulleyJoint.prototype.GetLengthB);box2d.b2PulleyJoint.prototype.GetRatio=function(){return this.m_ratio};goog.exportProperty(box2d.b2PulleyJoint.prototype,"GetRatio",box2d.b2PulleyJoint.prototype.GetRatio);
+box2d.b2PulleyJoint.prototype.GetCurrentLengthA=function(){var a=this.m_bodyA.GetWorldPoint(this.m_localAnchorA,box2d.b2PulleyJoint.prototype.GetCurrentLengthA.s_p);return box2d.b2Distance(a,this.m_groundAnchorA)};goog.exportProperty(box2d.b2PulleyJoint.prototype,"GetCurrentLengthA",box2d.b2PulleyJoint.prototype.GetCurrentLengthA);box2d.b2PulleyJoint.prototype.GetCurrentLengthA.s_p=new box2d.b2Vec2;
+box2d.b2PulleyJoint.prototype.GetCurrentLengthB=function(){var a=this.m_bodyB.GetWorldPoint(this.m_localAnchorB,box2d.b2PulleyJoint.prototype.GetCurrentLengthB.s_p);return box2d.b2Distance(a,this.m_groundAnchorB)};goog.exportProperty(box2d.b2PulleyJoint.prototype,"GetCurrentLengthB",box2d.b2PulleyJoint.prototype.GetCurrentLengthB);box2d.b2PulleyJoint.prototype.GetCurrentLengthB.s_p=new box2d.b2Vec2;
+box2d.b2PulleyJoint.prototype.Dump=function(){if(box2d.DEBUG){var a=this.m_bodyA.m_islandIndex,b=this.m_bodyB.m_islandIndex;box2d.b2Log("  /*box2d.b2PulleyJointDef*/ var jd = new box2d.b2PulleyJointDef();\n");box2d.b2Log("  jd.bodyA = bodies[%d];\n",a);box2d.b2Log("  jd.bodyB = bodies[%d];\n",b);box2d.b2Log("  jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false");box2d.b2Log("  jd.groundAnchorA.Set(%.15f, %.15f);\n",this.m_groundAnchorA.x,this.m_groundAnchorA.y);box2d.b2Log("  jd.groundAnchorB.Set(%.15f, %.15f);\n",
+this.m_groundAnchorB.x,this.m_groundAnchorB.y);box2d.b2Log("  jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y);box2d.b2Log("  jd.localAnchorB.Set(%.15f, %.15f);\n",this.m_localAnchorB.x,this.m_localAnchorB.y);box2d.b2Log("  jd.lengthA = %.15f;\n",this.m_lengthA);box2d.b2Log("  jd.lengthB = %.15f;\n",this.m_lengthB);box2d.b2Log("  jd.ratio = %.15f;\n",this.m_ratio);box2d.b2Log("  joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}};
+goog.exportProperty(box2d.b2PulleyJoint.prototype,"Dump",box2d.b2PulleyJoint.prototype.Dump);box2d.b2PulleyJoint.prototype.ShiftOrigin=function(a){this.m_groundAnchorA.SelfSub(a);this.m_groundAnchorB.SelfSub(a)};goog.exportProperty(box2d.b2PulleyJoint.prototype,"ShiftOrigin",box2d.b2PulleyJoint.prototype.ShiftOrigin);box2d.b2RevoluteJointDef=function(){box2d.b2JointDef.call(this,box2d.b2JointType.e_revoluteJoint);this.localAnchorA=new box2d.b2Vec2(0,0);this.localAnchorB=new box2d.b2Vec2(0,0)};goog.inherits(box2d.b2RevoluteJointDef,box2d.b2JointDef);goog.exportSymbol("box2d.b2RevoluteJointDef",box2d.b2RevoluteJointDef);box2d.b2RevoluteJointDef.prototype.localAnchorA=null;goog.exportProperty(box2d.b2RevoluteJointDef.prototype,"localAnchorA",box2d.b2RevoluteJointDef.prototype.localAnchorA);
+box2d.b2RevoluteJointDef.prototype.localAnchorB=null;goog.exportProperty(box2d.b2RevoluteJointDef.prototype,"localAnchorB",box2d.b2RevoluteJointDef.prototype.localAnchorB);box2d.b2RevoluteJointDef.prototype.referenceAngle=0;goog.exportProperty(box2d.b2RevoluteJointDef.prototype,"referenceAngle",box2d.b2RevoluteJointDef.prototype.referenceAngle);box2d.b2RevoluteJointDef.prototype.enableLimit=!1;goog.exportProperty(box2d.b2RevoluteJointDef.prototype,"enableLimit",box2d.b2RevoluteJointDef.prototype.enableLimit);
+box2d.b2RevoluteJointDef.prototype.lowerAngle=0;goog.exportProperty(box2d.b2RevoluteJointDef.prototype,"lowerAngle",box2d.b2RevoluteJointDef.prototype.lowerAngle);box2d.b2RevoluteJointDef.prototype.upperAngle=0;goog.exportProperty(box2d.b2RevoluteJointDef.prototype,"upperAngle",box2d.b2RevoluteJointDef.prototype.upperAngle);box2d.b2RevoluteJointDef.prototype.enableMotor=!1;goog.exportProperty(box2d.b2RevoluteJointDef.prototype,"enableMotor",box2d.b2RevoluteJointDef.prototype.enableMotor);
+box2d.b2RevoluteJointDef.prototype.motorSpeed=0;goog.exportProperty(box2d.b2RevoluteJointDef.prototype,"motorSpeed",box2d.b2RevoluteJointDef.prototype.motorSpeed);box2d.b2RevoluteJointDef.prototype.maxMotorTorque=0;goog.exportProperty(box2d.b2RevoluteJointDef.prototype,"maxMotorTorque",box2d.b2RevoluteJointDef.prototype.maxMotorTorque);
+box2d.b2RevoluteJointDef.prototype.Initialize=function(a,b,c){this.bodyA=a;this.bodyB=b;this.bodyA.GetLocalPoint(c,this.localAnchorA);this.bodyB.GetLocalPoint(c,this.localAnchorB);this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()};goog.exportProperty(box2d.b2RevoluteJointDef.prototype,"Initialize",box2d.b2RevoluteJointDef.prototype.Initialize);
+box2d.b2RevoluteJoint=function(a){box2d.b2Joint.call(this,a);this.m_localAnchorA=new box2d.b2Vec2;this.m_localAnchorB=new box2d.b2Vec2;this.m_impulse=new box2d.b2Vec3;this.m_rA=new box2d.b2Vec2;this.m_rB=new box2d.b2Vec2;this.m_localCenterA=new box2d.b2Vec2;this.m_localCenterB=new box2d.b2Vec2;this.m_mass=new box2d.b2Mat33;this.m_qA=new box2d.b2Rot;this.m_qB=new box2d.b2Rot;this.m_lalcA=new box2d.b2Vec2;this.m_lalcB=new box2d.b2Vec2;this.m_K=new box2d.b2Mat22;this.m_localAnchorA.Copy(a.localAnchorA);
+this.m_localAnchorB.Copy(a.localAnchorB);this.m_referenceAngle=a.referenceAngle;this.m_impulse.SetZero();this.m_motorImpulse=0;this.m_lowerAngle=a.lowerAngle;this.m_upperAngle=a.upperAngle;this.m_maxMotorTorque=a.maxMotorTorque;this.m_motorSpeed=a.motorSpeed;this.m_enableLimit=a.enableLimit;this.m_enableMotor=a.enableMotor;this.m_limitState=box2d.b2LimitState.e_inactiveLimit};goog.inherits(box2d.b2RevoluteJoint,box2d.b2Joint);goog.exportSymbol("box2d.b2RevoluteJoint",box2d.b2RevoluteJoint);
+box2d.b2RevoluteJoint.prototype.m_localAnchorA=null;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_localAnchorA",box2d.b2RevoluteJoint.prototype.m_localAnchorA);box2d.b2RevoluteJoint.prototype.m_localAnchorB=null;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_localAnchorB",box2d.b2RevoluteJoint.prototype.m_localAnchorB);box2d.b2RevoluteJoint.prototype.m_impulse=null;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_impulse",box2d.b2RevoluteJoint.prototype.m_impulse);
+box2d.b2RevoluteJoint.prototype.m_motorImpulse=0;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_motorImpulse",box2d.b2RevoluteJoint.prototype.m_motorImpulse);box2d.b2RevoluteJoint.prototype.m_enableMotor=!1;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_enableMotor",box2d.b2RevoluteJoint.prototype.m_enableMotor);box2d.b2RevoluteJoint.prototype.m_maxMotorTorque=0;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_maxMotorTorque",box2d.b2RevoluteJoint.prototype.m_maxMotorTorque);
+box2d.b2RevoluteJoint.prototype.m_motorSpeed=0;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_motorSpeed",box2d.b2RevoluteJoint.prototype.m_motorSpeed);box2d.b2RevoluteJoint.prototype.m_enableLimit=!1;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_enableLimit",box2d.b2RevoluteJoint.prototype.m_enableLimit);box2d.b2RevoluteJoint.prototype.m_referenceAngle=0;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_referenceAngle",box2d.b2RevoluteJoint.prototype.m_referenceAngle);
+box2d.b2RevoluteJoint.prototype.m_lowerAngle=0;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_lowerAngle",box2d.b2RevoluteJoint.prototype.m_lowerAngle);box2d.b2RevoluteJoint.prototype.m_upperAngle=0;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_upperAngle",box2d.b2RevoluteJoint.prototype.m_upperAngle);box2d.b2RevoluteJoint.prototype.m_indexA=0;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_indexA",box2d.b2RevoluteJoint.prototype.m_indexA);
+box2d.b2RevoluteJoint.prototype.m_indexB=0;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_indexB",box2d.b2RevoluteJoint.prototype.m_indexB);box2d.b2RevoluteJoint.prototype.m_rA=null;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_rA",box2d.b2RevoluteJoint.prototype.m_rA);box2d.b2RevoluteJoint.prototype.m_rB=null;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_rB",box2d.b2RevoluteJoint.prototype.m_rB);box2d.b2RevoluteJoint.prototype.m_localCenterA=null;
+goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_localCenterA",box2d.b2RevoluteJoint.prototype.m_localCenterA);box2d.b2RevoluteJoint.prototype.m_localCenterB=null;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_localCenterB",box2d.b2RevoluteJoint.prototype.m_localCenterB);box2d.b2RevoluteJoint.prototype.m_invMassA=0;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_invMassA",box2d.b2RevoluteJoint.prototype.m_invMassA);box2d.b2RevoluteJoint.prototype.m_invMassB=0;
+goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_invMassB",box2d.b2RevoluteJoint.prototype.m_invMassB);box2d.b2RevoluteJoint.prototype.m_invIA=0;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_invIA",box2d.b2RevoluteJoint.prototype.m_invIA);box2d.b2RevoluteJoint.prototype.m_invIB=0;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_invIB",box2d.b2RevoluteJoint.prototype.m_invIB);box2d.b2RevoluteJoint.prototype.m_mass=null;
+goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_mass",box2d.b2RevoluteJoint.prototype.m_mass);box2d.b2RevoluteJoint.prototype.m_motorMass=0;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_motorMass",box2d.b2RevoluteJoint.prototype.m_motorMass);box2d.b2RevoluteJoint.prototype.m_limitState=box2d.b2LimitState.e_inactiveLimit;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_limitState",box2d.b2RevoluteJoint.prototype.m_limitState);box2d.b2RevoluteJoint.prototype.m_qA=null;
+goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_qA",box2d.b2RevoluteJoint.prototype.m_qA);box2d.b2RevoluteJoint.prototype.m_qB=null;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_qB",box2d.b2RevoluteJoint.prototype.m_qB);box2d.b2RevoluteJoint.prototype.m_lalcA=null;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_lalcA",box2d.b2RevoluteJoint.prototype.m_lalcA);box2d.b2RevoluteJoint.prototype.m_lalcB=null;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_lalcB",box2d.b2RevoluteJoint.prototype.m_lalcB);
+box2d.b2RevoluteJoint.prototype.m_K=null;goog.exportProperty(box2d.b2RevoluteJoint.prototype,"m_K",box2d.b2RevoluteJoint.prototype.m_K);
+box2d.b2RevoluteJoint.prototype.InitVelocityConstraints=function(a){this.m_indexA=this.m_bodyA.m_islandIndex;this.m_indexB=this.m_bodyB.m_islandIndex;this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter);this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter);this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var b=a.positions[this.m_indexA].a,c=a.velocities[this.m_indexA].v,d=a.velocities[this.m_indexA].w,
+e=a.positions[this.m_indexB].a,f=a.velocities[this.m_indexB].v,g=a.velocities[this.m_indexB].w,h=this.m_qA.SetAngle(b),k=this.m_qB.SetAngle(e);box2d.b2Sub_V2_V2(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);box2d.b2Mul_R_V2(h,this.m_lalcA,this.m_rA);box2d.b2Sub_V2_V2(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);box2d.b2Mul_R_V2(k,this.m_lalcB,this.m_rB);var h=this.m_invMassA,k=this.m_invMassB,l=this.m_invIA,m=this.m_invIB,n=0===l+m;this.m_mass.ex.x=h+k+this.m_rA.y*this.m_rA.y*l+this.m_rB.y*
+this.m_rB.y*m;this.m_mass.ey.x=-this.m_rA.y*this.m_rA.x*l-this.m_rB.y*this.m_rB.x*m;this.m_mass.ez.x=-this.m_rA.y*l-this.m_rB.y*m;this.m_mass.ex.y=this.m_mass.ey.x;this.m_mass.ey.y=h+k+this.m_rA.x*this.m_rA.x*l+this.m_rB.x*this.m_rB.x*m;this.m_mass.ez.y=this.m_rA.x*l+this.m_rB.x*m;this.m_mass.ex.z=this.m_mass.ez.x;this.m_mass.ey.z=this.m_mass.ez.y;this.m_mass.ez.z=l+m;this.m_motorMass=l+m;0<this.m_motorMass&&(this.m_motorMass=1/this.m_motorMass);if(!this.m_enableMotor||n)this.m_motorImpulse=0;this.m_enableLimit&&
+!n?(b=e-b-this.m_referenceAngle,box2d.b2Abs(this.m_upperAngle-this.m_lowerAngle)<2*box2d.b2_angularSlop?this.m_limitState=box2d.b2LimitState.e_equalLimits:b<=this.m_lowerAngle?(this.m_limitState!==box2d.b2LimitState.e_atLowerLimit&&(this.m_impulse.z=0),this.m_limitState=box2d.b2LimitState.e_atLowerLimit):b>=this.m_upperAngle?(this.m_limitState!==box2d.b2LimitState.e_atUpperLimit&&(this.m_impulse.z=0),this.m_limitState=box2d.b2LimitState.e_atUpperLimit):(this.m_limitState=box2d.b2LimitState.e_inactiveLimit,
+this.m_impulse.z=0)):this.m_limitState=box2d.b2LimitState.e_inactiveLimit;a.step.warmStarting?(this.m_impulse.SelfMulScalar(a.step.dtRatio),this.m_motorImpulse*=a.step.dtRatio,b=box2d.b2RevoluteJoint.prototype.InitVelocityConstraints.s_P.Set(this.m_impulse.x,this.m_impulse.y),c.SelfMulSub(h,b),d-=l*(box2d.b2Cross_V2_V2(this.m_rA,b)+this.m_motorImpulse+this.m_impulse.z),f.SelfMulAdd(k,b),g+=m*(box2d.b2Cross_V2_V2(this.m_rB,b)+this.m_motorImpulse+this.m_impulse.z)):(this.m_impulse.SetZero(),this.m_motorImpulse=
+0);a.velocities[this.m_indexA].w=d;a.velocities[this.m_indexB].w=g};goog.exportProperty(box2d.b2RevoluteJoint.prototype,"InitVelocityConstraints",box2d.b2RevoluteJoint.prototype.InitVelocityConstraints);box2d.b2RevoluteJoint.prototype.InitVelocityConstraints.s_P=new box2d.b2Vec2;
+box2d.b2RevoluteJoint.prototype.SolveVelocityConstraints=function(a){var b=a.velocities[this.m_indexA].v,c=a.velocities[this.m_indexA].w,d=a.velocities[this.m_indexB].v,e=a.velocities[this.m_indexB].w,f=this.m_invMassA,g=this.m_invMassB,h=this.m_invIA,k=this.m_invIB,l=0===h+k;if(this.m_enableMotor&&this.m_limitState!==box2d.b2LimitState.e_equalLimits&&!l){var m=e-c-this.m_motorSpeed,m=-this.m_motorMass*m,n=this.m_motorImpulse,p=a.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=box2d.b2Clamp(this.m_motorImpulse+
+m,-p,p);m=this.m_motorImpulse-n;c-=h*m;e+=k*m}this.m_enableLimit&&this.m_limitState!==box2d.b2LimitState.e_inactiveLimit&&!l?(l=box2d.b2Sub_V2_V2(box2d.b2AddCross_V2_S_V2(d,e,this.m_rB,box2d.b2Vec2.s_t0),box2d.b2AddCross_V2_S_V2(b,c,this.m_rA,box2d.b2Vec2.s_t1),box2d.b2RevoluteJoint.prototype.SolveVelocityConstraints.s_Cdot1),m=this.m_mass.Solve33(l.x,l.y,e-c,box2d.b2RevoluteJoint.prototype.SolveVelocityConstraints.s_impulse3).SelfNeg(),this.m_limitState===box2d.b2LimitState.e_equalLimits?this.m_impulse.SelfAdd(m):
+this.m_limitState===box2d.b2LimitState.e_atLowerLimit?(n=this.m_impulse.z+m.z,0>n?(n=-l.x+this.m_impulse.z*this.m_mass.ez.x,l=-l.y+this.m_impulse.z*this.m_mass.ez.y,l=this.m_mass.Solve22(n,l,box2d.b2RevoluteJoint.prototype.SolveVelocityConstraints.s_reduced),m.x=l.x,m.y=l.y,m.z=-this.m_impulse.z,this.m_impulse.x+=l.x,this.m_impulse.y+=l.y,this.m_impulse.z=0):this.m_impulse.SelfAdd(m)):this.m_limitState===box2d.b2LimitState.e_atUpperLimit&&(n=this.m_impulse.z+m.z,0<n?(n=-l.x+this.m_impulse.z*this.m_mass.ez.x,
+l=-l.y+this.m_impulse.z*this.m_mass.ez.y,l=this.m_mass.Solve22(n,l,box2d.b2RevoluteJoint.prototype.SolveVelocityConstraints.s_reduced),m.x=l.x,m.y=l.y,m.z=-this.m_impulse.z,this.m_impulse.x+=l.x,this.m_impulse.y+=l.y,this.m_impulse.z=0):this.m_impulse.SelfAdd(m)),l=box2d.b2RevoluteJoint.prototype.SolveVelocityConstraints.s_P.Set(m.x,m.y),b.SelfMulSub(f,l),c-=h*(box2d.b2Cross_V2_V2(this.m_rA,l)+m.z),d.SelfMulAdd(g,l),e+=k*(box2d.b2Cross_V2_V2(this.m_rB,l)+m.z)):(m=box2d.b2Sub_V2_V2(box2d.b2AddCross_V2_S_V2(d,
+e,this.m_rB,box2d.b2Vec2.s_t0),box2d.b2AddCross_V2_S_V2(b,c,this.m_rA,box2d.b2Vec2.s_t1),box2d.b2RevoluteJoint.prototype.SolveVelocityConstraints.s_Cdot),m=this.m_mass.Solve22(-m.x,-m.y,box2d.b2RevoluteJoint.prototype.SolveVelocityConstraints.s_impulse2),this.m_impulse.x+=m.x,this.m_impulse.y+=m.y,b.SelfMulSub(f,m),c-=h*box2d.b2Cross_V2_V2(this.m_rA,m),d.SelfMulAdd(g,m),e+=k*box2d.b2Cross_V2_V2(this.m_rB,m));a.velocities[this.m_indexA].w=c;a.velocities[this.m_indexB].w=e};
+goog.exportProperty(box2d.b2RevoluteJoint.prototype,"SolveVelocityConstraints",box2d.b2RevoluteJoint.prototype.SolveVelocityConstraints);box2d.b2RevoluteJoint.prototype.SolveVelocityConstraints.s_P=new box2d.b2Vec2;box2d.b2RevoluteJoint.prototype.SolveVelocityConstraints.s_Cdot=new box2d.b2Vec2;box2d.b2RevoluteJoint.prototype.SolveVelocityConstraints.s_Cdot1=new box2d.b2Vec2;box2d.b2RevoluteJoint.prototype.SolveVelocityConstraints.s_impulse3=new box2d.b2Vec3;
+box2d.b2RevoluteJoint.prototype.SolveVelocityConstraints.s_reduced=new box2d.b2Vec2;box2d.b2RevoluteJoint.prototype.SolveVelocityConstraints.s_impulse2=new box2d.b2Vec2;
+box2d.b2RevoluteJoint.prototype.SolvePositionConstraints=function(a){var b=a.positions[this.m_indexA].c,c=a.positions[this.m_indexA].a,d=a.positions[this.m_indexB].c,e=a.positions[this.m_indexB].a,f=this.m_qA.SetAngle(c),g=this.m_qB.SetAngle(e),h=0,k=0,k=0===this.m_invIA+this.m_invIB;if(this.m_enableLimit&&this.m_limitState!==box2d.b2LimitState.e_inactiveLimit&&!k){var l=e-c-this.m_referenceAngle,k=0;this.m_limitState===box2d.b2LimitState.e_equalLimits?(l=box2d.b2Clamp(l-this.m_lowerAngle,-box2d.b2_maxAngularCorrection,
+box2d.b2_maxAngularCorrection),k=-this.m_motorMass*l,h=box2d.b2Abs(l)):this.m_limitState===box2d.b2LimitState.e_atLowerLimit?(l-=this.m_lowerAngle,h=-l,l=box2d.b2Clamp(l+box2d.b2_angularSlop,-box2d.b2_maxAngularCorrection,0),k=-this.m_motorMass*l):this.m_limitState===box2d.b2LimitState.e_atUpperLimit&&(h=l-=this.m_upperAngle,l=box2d.b2Clamp(l-box2d.b2_angularSlop,0,box2d.b2_maxAngularCorrection),k=-this.m_motorMass*l);c-=this.m_invIA*k;e+=this.m_invIB*k}f.SetAngle(c);g.SetAngle(e);box2d.b2Sub_V2_V2(this.m_localAnchorA,
+this.m_localCenterA,this.m_lalcA);f=box2d.b2Mul_R_V2(f,this.m_lalcA,this.m_rA);box2d.b2Sub_V2_V2(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var g=box2d.b2Mul_R_V2(g,this.m_lalcB,this.m_rB),l=box2d.b2Sub_V2_V2(box2d.b2Add_V2_V2(d,g,box2d.b2Vec2.s_t0),box2d.b2Add_V2_V2(b,f,box2d.b2Vec2.s_t1),box2d.b2RevoluteJoint.prototype.SolvePositionConstraints.s_C),k=l.Length(),m=this.m_invMassA,n=this.m_invMassB,p=this.m_invIA,q=this.m_invIB,r=this.m_K;r.ex.x=m+n+p*f.y*f.y+q*g.y*g.y;r.ex.y=-p*f.x*f.y-
+q*g.x*g.y;r.ey.x=r.ex.y;r.ey.y=m+n+p*f.x*f.x+q*g.x*g.x;l=r.Solve(l.x,l.y,box2d.b2RevoluteJoint.prototype.SolvePositionConstraints.s_impulse).SelfNeg();b.SelfMulSub(m,l);c-=p*box2d.b2Cross_V2_V2(f,l);d.SelfMulAdd(n,l);e+=q*box2d.b2Cross_V2_V2(g,l);a.positions[this.m_indexA].a=c;a.positions[this.m_indexB].a=e;return k<=box2d.b2_linearSlop&&h<=box2d.b2_angularSlop};goog.exportProperty(box2d.b2RevoluteJoint.prototype,"SolvePositionConstraints",box2d.b2RevoluteJoint.prototype.SolvePositionConstraints);
+box2d.b2RevoluteJoint.prototype.SolvePositionConstraints.s_C=new box2d.b2Vec2;box2d.b2RevoluteJoint.prototype.SolvePositionConstraints.s_impulse=new box2d.b2Vec2;box2d.b2RevoluteJoint.prototype.GetAnchorA=function(a){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,a)};goog.exportProperty(box2d.b2RevoluteJoint.prototype,"GetAnchorA",box2d.b2RevoluteJoint.prototype.GetAnchorA);box2d.b2RevoluteJoint.prototype.GetAnchorB=function(a){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,a)};
+goog.exportProperty(box2d.b2RevoluteJoint.prototype,"GetAnchorB",box2d.b2RevoluteJoint.prototype.GetAnchorB);box2d.b2RevoluteJoint.prototype.GetReactionForce=function(a,b){return b.Set(a*this.m_impulse.x,a*this.m_impulse.y)};goog.exportProperty(box2d.b2RevoluteJoint.prototype,"GetReactionForce",box2d.b2RevoluteJoint.prototype.GetReactionForce);box2d.b2RevoluteJoint.prototype.GetReactionTorque=function(a){return a*this.m_impulse.z};
+goog.exportProperty(box2d.b2RevoluteJoint.prototype,"GetReactionTorque",box2d.b2RevoluteJoint.prototype.GetReactionTorque);box2d.b2RevoluteJoint.prototype.GetLocalAnchorA=function(a){return a.Copy(this.m_localAnchorA)};goog.exportProperty(box2d.b2RevoluteJoint.prototype,"GetLocalAnchorA",box2d.b2RevoluteJoint.prototype.GetLocalAnchorA);box2d.b2RevoluteJoint.prototype.GetLocalAnchorB=function(a){return a.Copy(this.m_localAnchorB)};
+goog.exportProperty(box2d.b2RevoluteJoint.prototype,"GetLocalAnchorB",box2d.b2RevoluteJoint.prototype.GetLocalAnchorB);box2d.b2RevoluteJoint.prototype.GetReferenceAngle=function(){return this.m_referenceAngle};goog.exportProperty(box2d.b2RevoluteJoint.prototype,"GetReferenceAngle",box2d.b2RevoluteJoint.prototype.GetReferenceAngle);box2d.b2RevoluteJoint.prototype.GetJointAngle=function(){return this.m_bodyB.m_sweep.a-this.m_bodyA.m_sweep.a-this.m_referenceAngle};
+goog.exportProperty(box2d.b2RevoluteJoint.prototype,"GetJointAngle",box2d.b2RevoluteJoint.prototype.GetJointAngle);box2d.b2RevoluteJoint.prototype.GetJointSpeed=function(){return this.m_bodyB.m_angularVelocity-this.m_bodyA.m_angularVelocity};goog.exportProperty(box2d.b2RevoluteJoint.prototype,"GetJointSpeed",box2d.b2RevoluteJoint.prototype.GetJointSpeed);box2d.b2RevoluteJoint.prototype.IsMotorEnabled=function(){return this.m_enableMotor};
+goog.exportProperty(box2d.b2RevoluteJoint.prototype,"IsMotorEnabled",box2d.b2RevoluteJoint.prototype.IsMotorEnabled);box2d.b2RevoluteJoint.prototype.EnableMotor=function(a){this.m_enableMotor!==a&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableMotor=a)};goog.exportProperty(box2d.b2RevoluteJoint.prototype,"EnableMotor",box2d.b2RevoluteJoint.prototype.EnableMotor);box2d.b2RevoluteJoint.prototype.GetMotorTorque=function(a){return a*this.m_motorImpulse};
+goog.exportProperty(box2d.b2RevoluteJoint.prototype,"GetMotorTorque",box2d.b2RevoluteJoint.prototype.GetMotorTorque);box2d.b2RevoluteJoint.prototype.GetMotorSpeed=function(){return this.m_motorSpeed};goog.exportProperty(box2d.b2RevoluteJoint.prototype,"GetMotorSpeed",box2d.b2RevoluteJoint.prototype.GetMotorSpeed);box2d.b2RevoluteJoint.prototype.SetMaxMotorTorque=function(a){this.m_maxMotorTorque=a};goog.exportProperty(box2d.b2RevoluteJoint.prototype,"SetMaxMotorTorque",box2d.b2RevoluteJoint.prototype.SetMaxMotorTorque);
+box2d.b2RevoluteJoint.prototype.GetMaxMotorTorque=function(){return this.m_maxMotorTorque};goog.exportProperty(box2d.b2RevoluteJoint.prototype,"GetMaxMotorTorque",box2d.b2RevoluteJoint.prototype.GetMaxMotorTorque);box2d.b2RevoluteJoint.prototype.IsLimitEnabled=function(){return this.m_enableLimit};goog.exportProperty(box2d.b2RevoluteJoint.prototype,"IsLimitEnabled",box2d.b2RevoluteJoint.prototype.IsLimitEnabled);
+box2d.b2RevoluteJoint.prototype.EnableLimit=function(a){a!==this.m_enableLimit&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_enableLimit=a,this.m_impulse.z=0)};goog.exportProperty(box2d.b2RevoluteJoint.prototype,"EnableLimit",box2d.b2RevoluteJoint.prototype.EnableLimit);box2d.b2RevoluteJoint.prototype.GetLowerLimit=function(){return this.m_lowerAngle};goog.exportProperty(box2d.b2RevoluteJoint.prototype,"GetLowerLimit",box2d.b2RevoluteJoint.prototype.GetLowerLimit);
+box2d.b2RevoluteJoint.prototype.GetUpperLimit=function(){return this.m_upperAngle};goog.exportProperty(box2d.b2RevoluteJoint.prototype,"GetUpperLimit",box2d.b2RevoluteJoint.prototype.GetUpperLimit);box2d.b2RevoluteJoint.prototype.SetLimits=function(a,b){if(a!==this.m_lowerAngle||b!==this.m_upperAngle)this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_impulse.z=0,this.m_lowerAngle=a,this.m_upperAngle=b};goog.exportProperty(box2d.b2RevoluteJoint.prototype,"SetLimits",box2d.b2RevoluteJoint.prototype.SetLimits);
+box2d.b2RevoluteJoint.prototype.SetMotorSpeed=function(a){this.m_motorSpeed!==a&&(this.m_bodyA.SetAwake(!0),this.m_bodyB.SetAwake(!0),this.m_motorSpeed=a)};goog.exportProperty(box2d.b2RevoluteJoint.prototype,"SetMotorSpeed",box2d.b2RevoluteJoint.prototype.SetMotorSpeed);
+box2d.b2RevoluteJoint.prototype.Dump=function(){if(box2d.DEBUG){var a=this.m_bodyA.m_islandIndex,b=this.m_bodyB.m_islandIndex;box2d.b2Log("  /*box2d.b2RevoluteJointDef*/ var jd = new box2d.b2RevoluteJointDef();\n");box2d.b2Log("  jd.bodyA = bodies[%d];\n",a);box2d.b2Log("  jd.bodyB = bodies[%d];\n",b);box2d.b2Log("  jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false");box2d.b2Log("  jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y);box2d.b2Log("  jd.localAnchorB.Set(%.15f, %.15f);\n",
+this.m_localAnchorB.x,this.m_localAnchorB.y);box2d.b2Log("  jd.referenceAngle = %.15f;\n",this.m_referenceAngle);box2d.b2Log("  jd.enableLimit = %s;\n",this.m_enableLimit?"true":"false");box2d.b2Log("  jd.lowerAngle = %.15f;\n",this.m_lowerAngle);box2d.b2Log("  jd.upperAngle = %.15f;\n",this.m_upperAngle);box2d.b2Log("  jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false");box2d.b2Log("  jd.motorSpeed = %.15f;\n",this.m_motorSpeed);box2d.b2Log("  jd.maxMotorTorque = %.15f;\n",this.m_maxMotorTorque);
+box2d.b2Log("  joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}};goog.exportProperty(box2d.b2RevoluteJoint.prototype,"Dump",box2d.b2RevoluteJoint.prototype.Dump);box2d.b2GearJointDef=function(){box2d.b2JointDef.call(this,box2d.b2JointType.e_gearJoint)};goog.inherits(box2d.b2GearJointDef,box2d.b2JointDef);goog.exportSymbol("box2d.b2GearJointDef",box2d.b2GearJointDef);box2d.b2GearJointDef.prototype.joint1=null;goog.exportProperty(box2d.b2GearJointDef.prototype,"joint1",box2d.b2GearJointDef.prototype.joint1);box2d.b2GearJointDef.prototype.joint2=null;goog.exportProperty(box2d.b2GearJointDef.prototype,"joint2",box2d.b2GearJointDef.prototype.joint2);
+box2d.b2GearJointDef.prototype.ratio=1;goog.exportProperty(box2d.b2GearJointDef.prototype,"ratio",box2d.b2GearJointDef.prototype.ratio);
+box2d.b2GearJoint=function(a){box2d.b2Joint.call(this,a);this.m_joint1=a.joint1;this.m_joint2=a.joint2;this.m_localAnchorA=new box2d.b2Vec2;this.m_localAnchorB=new box2d.b2Vec2;this.m_localAnchorC=new box2d.b2Vec2;this.m_localAnchorD=new box2d.b2Vec2;this.m_localAxisC=new box2d.b2Vec2;this.m_localAxisD=new box2d.b2Vec2;this.m_lcA=new box2d.b2Vec2;this.m_lcB=new box2d.b2Vec2;this.m_lcC=new box2d.b2Vec2;this.m_lcD=new box2d.b2Vec2;this.m_JvAC=new box2d.b2Vec2;this.m_JvBD=new box2d.b2Vec2;this.m_qA=
+new box2d.b2Rot;this.m_qB=new box2d.b2Rot;this.m_qC=new box2d.b2Rot;this.m_qD=new box2d.b2Rot;this.m_lalcA=new box2d.b2Vec2;this.m_lalcB=new box2d.b2Vec2;this.m_lalcC=new box2d.b2Vec2;this.m_lalcD=new box2d.b2Vec2;this.m_typeA=this.m_joint1.GetType();this.m_typeB=this.m_joint2.GetType();box2d.ENABLE_ASSERTS&&box2d.b2Assert(this.m_typeA===box2d.b2JointType.e_revoluteJoint||this.m_typeA===box2d.b2JointType.e_prismaticJoint);box2d.ENABLE_ASSERTS&&box2d.b2Assert(this.m_typeB===box2d.b2JointType.e_revoluteJoint||
+this.m_typeB===box2d.b2JointType.e_prismaticJoint);var b,c;this.m_bodyC=this.m_joint1.GetBodyA();this.m_bodyA=this.m_joint1.GetBodyB();b=this.m_bodyA.m_xf;var d=this.m_bodyA.m_sweep.a;c=this.m_bodyC.m_xf;var e=this.m_bodyC.m_sweep.a;this.m_typeA===box2d.b2JointType.e_revoluteJoint?(c=a.joint1,this.m_localAnchorC.Copy(c.m_localAnchorA),this.m_localAnchorA.Copy(c.m_localAnchorB),this.m_referenceAngleA=c.m_referenceAngle,this.m_localAxisC.SetZero(),b=d-e-this.m_referenceAngleA):(e=a.joint1,this.m_localAnchorC.Copy(e.m_localAnchorA),
+this.m_localAnchorA.Copy(e.m_localAnchorB),this.m_referenceAngleA=e.m_referenceAngle,this.m_localAxisC.Copy(e.m_localXAxisA),d=this.m_localAnchorC,b=box2d.b2MulT_R_V2(c.q,box2d.b2Add_V2_V2(box2d.b2Mul_R_V2(b.q,this.m_localAnchorA,box2d.b2Vec2.s_t0),box2d.b2Sub_V2_V2(b.p,c.p,box2d.b2Vec2.s_t1),box2d.b2Vec2.s_t0),box2d.b2Vec2.s_t0),b=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(b,d,box2d.b2Vec2.s_t0),this.m_localAxisC));this.m_bodyD=this.m_joint2.GetBodyA();this.m_bodyB=this.m_joint2.GetBodyB();c=this.m_bodyB.m_xf;
+var e=this.m_bodyB.m_sweep.a,d=this.m_bodyD.m_xf,f=this.m_bodyD.m_sweep.a;this.m_typeB===box2d.b2JointType.e_revoluteJoint?(c=a.joint2,this.m_localAnchorD.Copy(c.m_localAnchorA),this.m_localAnchorB.Copy(c.m_localAnchorB),this.m_referenceAngleB=c.m_referenceAngle,this.m_localAxisD.SetZero(),c=e-f-this.m_referenceAngleB):(e=a.joint2,this.m_localAnchorD.Copy(e.m_localAnchorA),this.m_localAnchorB.Copy(e.m_localAnchorB),this.m_referenceAngleB=e.m_referenceAngle,this.m_localAxisD.Copy(e.m_localXAxisA),
+e=this.m_localAnchorD,c=box2d.b2MulT_R_V2(d.q,box2d.b2Add_V2_V2(box2d.b2Mul_R_V2(c.q,this.m_localAnchorB,box2d.b2Vec2.s_t0),box2d.b2Sub_V2_V2(c.p,d.p,box2d.b2Vec2.s_t1),box2d.b2Vec2.s_t0),box2d.b2Vec2.s_t0),c=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(c,e,box2d.b2Vec2.s_t0),this.m_localAxisD));this.m_ratio=a.ratio;this.m_constant=b+this.m_ratio*c;this.m_impulse=0};goog.inherits(box2d.b2GearJoint,box2d.b2Joint);goog.exportSymbol("box2d.b2GearJoint",box2d.b2GearJoint);
+box2d.b2GearJoint.prototype.m_joint1=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_joint1",box2d.b2GearJoint.prototype.m_joint1);box2d.b2GearJoint.prototype.m_joint2=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_joint2",box2d.b2GearJoint.prototype.m_joint2);box2d.b2GearJoint.prototype.m_typeA=box2d.b2JointType.e_unknownJoint;goog.exportProperty(box2d.b2GearJoint.prototype,"m_typeA",box2d.b2GearJoint.prototype.m_typeA);box2d.b2GearJoint.prototype.m_typeB=box2d.b2JointType.e_unknownJoint;
+goog.exportProperty(box2d.b2GearJoint.prototype,"m_typeB",box2d.b2GearJoint.prototype.m_typeB);box2d.b2GearJoint.prototype.m_bodyC=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_bodyC",box2d.b2GearJoint.prototype.m_bodyC);box2d.b2GearJoint.prototype.m_bodyD=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_bodyD",box2d.b2GearJoint.prototype.m_bodyD);box2d.b2GearJoint.prototype.m_localAnchorA=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_localAnchorA",box2d.b2GearJoint.prototype.m_localAnchorA);
+box2d.b2GearJoint.prototype.m_localAnchorB=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_localAnchorB",box2d.b2GearJoint.prototype.m_localAnchorB);box2d.b2GearJoint.prototype.m_localAnchorC=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_localAnchorC",box2d.b2GearJoint.prototype.m_localAnchorC);box2d.b2GearJoint.prototype.m_localAnchorD=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_localAnchorD",box2d.b2GearJoint.prototype.m_localAnchorD);
+box2d.b2GearJoint.prototype.m_localAxisC=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_localAxisC",box2d.b2GearJoint.prototype.m_localAxisC);box2d.b2GearJoint.prototype.m_localAxisD=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_localAxisD",box2d.b2GearJoint.prototype.m_localAxisD);box2d.b2GearJoint.prototype.m_referenceAngleA=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_referenceAngleA",box2d.b2GearJoint.prototype.m_referenceAngleA);
+box2d.b2GearJoint.prototype.m_referenceAngleB=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_referenceAngleB",box2d.b2GearJoint.prototype.m_referenceAngleB);box2d.b2GearJoint.prototype.m_constant=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_constant",box2d.b2GearJoint.prototype.m_constant);box2d.b2GearJoint.prototype.m_ratio=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_ratio",box2d.b2GearJoint.prototype.m_ratio);box2d.b2GearJoint.prototype.m_impulse=0;
+goog.exportProperty(box2d.b2GearJoint.prototype,"m_impulse",box2d.b2GearJoint.prototype.m_impulse);box2d.b2GearJoint.prototype.m_indexA=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_indexA",box2d.b2GearJoint.prototype.m_indexA);box2d.b2GearJoint.prototype.m_indexB=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_indexB",box2d.b2GearJoint.prototype.m_indexB);box2d.b2GearJoint.prototype.m_indexC=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_indexC",box2d.b2GearJoint.prototype.m_indexC);
+box2d.b2GearJoint.prototype.m_indexD=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_indexD",box2d.b2GearJoint.prototype.m_indexD);box2d.b2GearJoint.prototype.m_lcA=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_lcA",box2d.b2GearJoint.prototype.m_lcA);box2d.b2GearJoint.prototype.m_lcB=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_lcB",box2d.b2GearJoint.prototype.m_lcB);box2d.b2GearJoint.prototype.m_lcC=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_lcC",box2d.b2GearJoint.prototype.m_lcC);
+box2d.b2GearJoint.prototype.m_lcD=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_lcD",box2d.b2GearJoint.prototype.m_lcD);box2d.b2GearJoint.prototype.m_mA=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_mA",box2d.b2GearJoint.prototype.m_mA);box2d.b2GearJoint.prototype.m_mB=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_mB",box2d.b2GearJoint.prototype.m_mB);box2d.b2GearJoint.prototype.m_mC=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_mC",box2d.b2GearJoint.prototype.m_mC);
+box2d.b2GearJoint.prototype.m_mD=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_mD",box2d.b2GearJoint.prototype.m_mD);box2d.b2GearJoint.prototype.m_iA=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_iA",box2d.b2GearJoint.prototype.m_iA);box2d.b2GearJoint.prototype.m_iB=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_iB",box2d.b2GearJoint.prototype.m_iB);box2d.b2GearJoint.prototype.m_iC=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_iC",box2d.b2GearJoint.prototype.m_iC);
+box2d.b2GearJoint.prototype.m_iD=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_iD",box2d.b2GearJoint.prototype.m_iD);box2d.b2GearJoint.prototype.m_JvAC=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_JvAC",box2d.b2GearJoint.prototype.m_JvAC);box2d.b2GearJoint.prototype.m_JvBD=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_JvBD",box2d.b2GearJoint.prototype.m_JvBD);box2d.b2GearJoint.prototype.m_JwA=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_JwA",box2d.b2GearJoint.prototype.m_JwA);
+box2d.b2GearJoint.prototype.m_JwB=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_JwB",box2d.b2GearJoint.prototype.m_JwB);box2d.b2GearJoint.prototype.m_JwC=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_JwC",box2d.b2GearJoint.prototype.m_JwC);box2d.b2GearJoint.prototype.m_JwD=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_JwD",box2d.b2GearJoint.prototype.m_JwD);box2d.b2GearJoint.prototype.m_mass=0;goog.exportProperty(box2d.b2GearJoint.prototype,"m_mass",box2d.b2GearJoint.prototype.m_mass);
+box2d.b2GearJoint.prototype.m_qA=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_qA",box2d.b2GearJoint.prototype.m_qA);box2d.b2GearJoint.prototype.m_qB=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_qB",box2d.b2GearJoint.prototype.m_qB);box2d.b2GearJoint.prototype.m_qC=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_qC",box2d.b2GearJoint.prototype.m_qC);box2d.b2GearJoint.prototype.m_qD=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_qD",box2d.b2GearJoint.prototype.m_qD);
+box2d.b2GearJoint.prototype.m_lalcA=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_lalcA",box2d.b2GearJoint.prototype.m_lalcA);box2d.b2GearJoint.prototype.m_lalcB=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_lalcB",box2d.b2GearJoint.prototype.m_lalcB);box2d.b2GearJoint.prototype.m_lalcC=null;goog.exportProperty(box2d.b2GearJoint.prototype,"m_lalcC",box2d.b2GearJoint.prototype.m_lalcC);box2d.b2GearJoint.prototype.m_lalcD=null;
+goog.exportProperty(box2d.b2GearJoint.prototype,"m_lalcD",box2d.b2GearJoint.prototype.m_lalcD);
+box2d.b2GearJoint.prototype.InitVelocityConstraints=function(a){this.m_indexA=this.m_bodyA.m_islandIndex;this.m_indexB=this.m_bodyB.m_islandIndex;this.m_indexC=this.m_bodyC.m_islandIndex;this.m_indexD=this.m_bodyD.m_islandIndex;this.m_lcA.Copy(this.m_bodyA.m_sweep.localCenter);this.m_lcB.Copy(this.m_bodyB.m_sweep.localCenter);this.m_lcC.Copy(this.m_bodyC.m_sweep.localCenter);this.m_lcD.Copy(this.m_bodyD.m_sweep.localCenter);this.m_mA=this.m_bodyA.m_invMass;this.m_mB=this.m_bodyB.m_invMass;this.m_mC=
+this.m_bodyC.m_invMass;this.m_mD=this.m_bodyD.m_invMass;this.m_iA=this.m_bodyA.m_invI;this.m_iB=this.m_bodyB.m_invI;this.m_iC=this.m_bodyC.m_invI;this.m_iD=this.m_bodyD.m_invI;var b=a.velocities[this.m_indexA].v,c=a.velocities[this.m_indexA].w,d=a.positions[this.m_indexB].a,e=a.velocities[this.m_indexB].v,f=a.velocities[this.m_indexB].w,g=a.positions[this.m_indexC].a,h=a.velocities[this.m_indexC].v,k=a.velocities[this.m_indexC].w,l=a.positions[this.m_indexD].a,m=a.velocities[this.m_indexD].v,n=a.velocities[this.m_indexD].w,
+p=this.m_qA.SetAngle(a.positions[this.m_indexA].a),d=this.m_qB.SetAngle(d),q=this.m_qC.SetAngle(g),g=this.m_qD.SetAngle(l);this.m_mass=0;this.m_typeA===box2d.b2JointType.e_revoluteJoint?(this.m_JvAC.SetZero(),this.m_JwC=this.m_JwA=1,this.m_mass+=this.m_iA+this.m_iC):(l=box2d.b2Mul_R_V2(q,this.m_localAxisC,box2d.b2GearJoint.prototype.InitVelocityConstraints.s_u),box2d.b2Sub_V2_V2(this.m_localAnchorC,this.m_lcC,this.m_lalcC),q=box2d.b2Mul_R_V2(q,this.m_lalcC,box2d.b2GearJoint.prototype.InitVelocityConstraints.s_rC),
+box2d.b2Sub_V2_V2(this.m_localAnchorA,this.m_lcA,this.m_lalcA),p=box2d.b2Mul_R_V2(p,this.m_lalcA,box2d.b2GearJoint.prototype.InitVelocityConstraints.s_rA),this.m_JvAC.Copy(l),this.m_JwC=box2d.b2Cross_V2_V2(q,l),this.m_JwA=box2d.b2Cross_V2_V2(p,l),this.m_mass+=this.m_mC+this.m_mA+this.m_iC*this.m_JwC*this.m_JwC+this.m_iA*this.m_JwA*this.m_JwA);this.m_typeB===box2d.b2JointType.e_revoluteJoint?(this.m_JvBD.SetZero(),this.m_JwD=this.m_JwB=this.m_ratio,this.m_mass+=this.m_ratio*this.m_ratio*(this.m_iB+
+this.m_iD)):(l=box2d.b2Mul_R_V2(g,this.m_localAxisD,box2d.b2GearJoint.prototype.InitVelocityConstraints.s_u),box2d.b2Sub_V2_V2(this.m_localAnchorD,this.m_lcD,this.m_lalcD),p=box2d.b2Mul_R_V2(g,this.m_lalcD,box2d.b2GearJoint.prototype.InitVelocityConstraints.s_rD),box2d.b2Sub_V2_V2(this.m_localAnchorB,this.m_lcB,this.m_lalcB),d=box2d.b2Mul_R_V2(d,this.m_lalcB,box2d.b2GearJoint.prototype.InitVelocityConstraints.s_rB),box2d.b2Mul_S_V2(this.m_ratio,l,this.m_JvBD),this.m_JwD=this.m_ratio*box2d.b2Cross_V2_V2(p,
+l),this.m_JwB=this.m_ratio*box2d.b2Cross_V2_V2(d,l),this.m_mass+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*this.m_JwD*this.m_JwD+this.m_iB*this.m_JwB*this.m_JwB);this.m_mass=0<this.m_mass?1/this.m_mass:0;a.step.warmStarting?(b.SelfMulAdd(this.m_mA*this.m_impulse,this.m_JvAC),c+=this.m_iA*this.m_impulse*this.m_JwA,e.SelfMulAdd(this.m_mB*this.m_impulse,this.m_JvBD),f+=this.m_iB*this.m_impulse*this.m_JwB,h.SelfMulSub(this.m_mC*this.m_impulse,this.m_JvAC),k-=this.m_iC*this.m_impulse*this.m_JwC,
+m.SelfMulSub(this.m_mD*this.m_impulse,this.m_JvBD),n-=this.m_iD*this.m_impulse*this.m_JwD):this.m_impulse=0;a.velocities[this.m_indexA].w=c;a.velocities[this.m_indexB].w=f;a.velocities[this.m_indexC].w=k;a.velocities[this.m_indexD].w=n};box2d.b2GearJoint.prototype.InitVelocityConstraints.s_u=new box2d.b2Vec2;box2d.b2GearJoint.prototype.InitVelocityConstraints.s_rA=new box2d.b2Vec2;box2d.b2GearJoint.prototype.InitVelocityConstraints.s_rB=new box2d.b2Vec2;
+box2d.b2GearJoint.prototype.InitVelocityConstraints.s_rC=new box2d.b2Vec2;box2d.b2GearJoint.prototype.InitVelocityConstraints.s_rD=new box2d.b2Vec2;
+box2d.b2GearJoint.prototype.SolveVelocityConstraints=function(a){var b=a.velocities[this.m_indexA].v,c=a.velocities[this.m_indexA].w,d=a.velocities[this.m_indexB].v,e=a.velocities[this.m_indexB].w,f=a.velocities[this.m_indexC].v,g=a.velocities[this.m_indexC].w,h=a.velocities[this.m_indexD].v,k=a.velocities[this.m_indexD].w,l=box2d.b2Dot_V2_V2(this.m_JvAC,box2d.b2Sub_V2_V2(b,f,box2d.b2Vec2.s_t0))+box2d.b2Dot_V2_V2(this.m_JvBD,box2d.b2Sub_V2_V2(d,h,box2d.b2Vec2.s_t0)),l=l+(this.m_JwA*c-this.m_JwC*g+
+(this.m_JwB*e-this.m_JwD*k)),l=-this.m_mass*l;this.m_impulse+=l;b.SelfMulAdd(this.m_mA*l,this.m_JvAC);c+=this.m_iA*l*this.m_JwA;d.SelfMulAdd(this.m_mB*l,this.m_JvBD);e+=this.m_iB*l*this.m_JwB;f.SelfMulSub(this.m_mC*l,this.m_JvAC);g-=this.m_iC*l*this.m_JwC;h.SelfMulSub(this.m_mD*l,this.m_JvBD);k-=this.m_iD*l*this.m_JwD;a.velocities[this.m_indexA].w=c;a.velocities[this.m_indexB].w=e;a.velocities[this.m_indexC].w=g;a.velocities[this.m_indexD].w=k};
+box2d.b2GearJoint.prototype.SolvePositionConstraints=function(a){var b=a.positions[this.m_indexA].c,c=a.positions[this.m_indexA].a,d=a.positions[this.m_indexB].c,e=a.positions[this.m_indexB].a,f=a.positions[this.m_indexC].c,g=a.positions[this.m_indexC].a,h=a.positions[this.m_indexD].c,k=a.positions[this.m_indexD].a,l=this.m_qA.SetAngle(c),m=this.m_qB.SetAngle(e),n=this.m_qC.SetAngle(g),p=this.m_qD.SetAngle(k),q=this.m_JvAC,r=this.m_JvBD,u,t,w=0;if(this.m_typeA===box2d.b2JointType.e_revoluteJoint)q.SetZero(),
+l=u=1,w+=this.m_iA+this.m_iC,n=c-g-this.m_referenceAngleA;else{t=box2d.b2Mul_R_V2(n,this.m_localAxisC,box2d.b2GearJoint.prototype.SolvePositionConstraints.s_u);u=box2d.b2Mul_R_V2(n,this.m_lalcC,box2d.b2GearJoint.prototype.SolvePositionConstraints.s_rC);var x=box2d.b2Mul_R_V2(l,this.m_lalcA,box2d.b2GearJoint.prototype.SolvePositionConstraints.s_rA);q.Copy(t);l=box2d.b2Cross_V2_V2(u,t);u=box2d.b2Cross_V2_V2(x,t);w+=this.m_mC+this.m_mA+this.m_iC*l*l+this.m_iA*u*u;t=this.m_lalcC;n=box2d.b2MulT_R_V2(n,
+box2d.b2Add_V2_V2(x,box2d.b2Sub_V2_V2(b,f,box2d.b2Vec2.s_t0),box2d.b2Vec2.s_t0),box2d.b2Vec2.s_t0);n=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(n,t,box2d.b2Vec2.s_t0),this.m_localAxisC)}if(this.m_typeB===box2d.b2JointType.e_revoluteJoint)r.SetZero(),m=t=this.m_ratio,w+=this.m_ratio*this.m_ratio*(this.m_iB+this.m_iD),p=e-k-this.m_referenceAngleB;else{t=box2d.b2Mul_R_V2(p,this.m_localAxisD,box2d.b2GearJoint.prototype.SolvePositionConstraints.s_u);var v=box2d.b2Mul_R_V2(p,this.m_lalcD,box2d.b2GearJoint.prototype.SolvePositionConstraints.s_rD),
+x=box2d.b2Mul_R_V2(m,this.m_lalcB,box2d.b2GearJoint.prototype.SolvePositionConstraints.s_rB);box2d.b2Mul_S_V2(this.m_ratio,t,r);m=this.m_ratio*box2d.b2Cross_V2_V2(v,t);t=this.m_ratio*box2d.b2Cross_V2_V2(x,t);w+=this.m_ratio*this.m_ratio*(this.m_mD+this.m_mB)+this.m_iD*m*m+this.m_iB*t*t;v=this.m_lalcD;p=box2d.b2MulT_R_V2(p,box2d.b2Add_V2_V2(x,box2d.b2Sub_V2_V2(d,h,box2d.b2Vec2.s_t0),box2d.b2Vec2.s_t0),box2d.b2Vec2.s_t0);p=box2d.b2Dot_V2_V2(box2d.b2Sub_V2_V2(p,v,box2d.b2Vec2.s_t0),this.m_localAxisD)}p=
+n+this.m_ratio*p-this.m_constant;n=0;0<w&&(n=-p/w);b.SelfMulAdd(this.m_mA*n,q);c+=this.m_iA*n*u;d.SelfMulAdd(this.m_mB*n,r);e+=this.m_iB*n*t;f.SelfMulSub(this.m_mC*n,q);g-=this.m_iC*n*l;h.SelfMulSub(this.m_mD*n,r);k-=this.m_iD*n*m;a.positions[this.m_indexA].a=c;a.positions[this.m_indexB].a=e;a.positions[this.m_indexC].a=g;a.positions[this.m_indexD].a=k;return 0<box2d.b2_linearSlop};goog.exportProperty(box2d.b2GearJoint.prototype,"SolvePositionConstraints",box2d.b2GearJoint.prototype.SolvePositionConstraints);
+box2d.b2GearJoint.prototype.SolvePositionConstraints.s_u=new box2d.b2Vec2;box2d.b2GearJoint.prototype.SolvePositionConstraints.s_rA=new box2d.b2Vec2;box2d.b2GearJoint.prototype.SolvePositionConstraints.s_rB=new box2d.b2Vec2;box2d.b2GearJoint.prototype.SolvePositionConstraints.s_rC=new box2d.b2Vec2;box2d.b2GearJoint.prototype.SolvePositionConstraints.s_rD=new box2d.b2Vec2;box2d.b2GearJoint.prototype.GetAnchorA=function(a){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,a)};
+goog.exportProperty(box2d.b2GearJoint.prototype,"GetAnchorA",box2d.b2GearJoint.prototype.GetAnchorA);box2d.b2GearJoint.prototype.GetAnchorB=function(a){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,a)};goog.exportProperty(box2d.b2GearJoint.prototype,"GetAnchorB",box2d.b2GearJoint.prototype.GetAnchorB);box2d.b2GearJoint.prototype.GetReactionForce=function(a,b){return box2d.b2Mul_S_V2(a*this.m_impulse,this.m_JvAC,b)};goog.exportProperty(box2d.b2GearJoint.prototype,"GetReactionForce",box2d.b2GearJoint.prototype.GetReactionForce);
+box2d.b2GearJoint.prototype.GetReactionTorque=function(a){return a*this.m_impulse*this.m_JwA};goog.exportProperty(box2d.b2GearJoint.prototype,"GetReactionTorque",box2d.b2GearJoint.prototype.GetReactionTorque);box2d.b2GearJoint.prototype.GetJoint1=function(){return this.m_joint1};goog.exportProperty(box2d.b2GearJoint.prototype,"GetJoint1",box2d.b2GearJoint.prototype.GetJoint1);box2d.b2GearJoint.prototype.GetJoint2=function(){return this.m_joint2};
+goog.exportProperty(box2d.b2GearJoint.prototype,"GetJoint2",box2d.b2GearJoint.prototype.GetJoint2);box2d.b2GearJoint.prototype.GetRatio=function(){return this.m_ratio};goog.exportProperty(box2d.b2GearJoint.prototype,"GetRatio",box2d.b2GearJoint.prototype.GetRatio);box2d.b2GearJoint.prototype.SetRatio=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(box2d.b2IsValid(a));this.m_ratio=a};goog.exportProperty(box2d.b2GearJoint.prototype,"SetRatio",box2d.b2GearJoint.prototype.SetRatio);
+box2d.b2GearJoint.prototype.Dump=function(){if(box2d.DEBUG){var a=this.m_bodyA.m_islandIndex,b=this.m_bodyB.m_islandIndex,c=this.m_joint1.m_index,d=this.m_joint2.m_index;box2d.b2Log("  /*box2d.b2GearJointDef*/ var jd = new box2d.b2GearJointDef();\n");box2d.b2Log("  jd.bodyA = bodies[%d];\n",a);box2d.b2Log("  jd.bodyB = bodies[%d];\n",b);box2d.b2Log("  jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false");box2d.b2Log("  jd.joint1 = joints[%d];\n",c);box2d.b2Log("  jd.joint2 = joints[%d];\n",
+d);box2d.b2Log("  jd.ratio = %.15f;\n",this.m_ratio);box2d.b2Log("  joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}};goog.exportProperty(box2d.b2GearJoint.prototype,"Dump",box2d.b2GearJoint.prototype.Dump);box2d.b2RopeJointDef=function(){box2d.b2JointDef.call(this,box2d.b2JointType.e_ropeJoint);this.localAnchorA=new box2d.b2Vec2(-1,0);this.localAnchorB=new box2d.b2Vec2(1,0)};goog.inherits(box2d.b2RopeJointDef,box2d.b2JointDef);goog.exportSymbol("box2d.b2RopeJointDef",box2d.b2RopeJointDef);box2d.b2RopeJointDef.prototype.localAnchorA=null;goog.exportProperty(box2d.b2RopeJointDef.prototype,"localAnchorA",box2d.b2RopeJointDef.prototype.localAnchorA);box2d.b2RopeJointDef.prototype.localAnchorB=null;
+goog.exportProperty(box2d.b2RopeJointDef.prototype,"localAnchorB",box2d.b2RopeJointDef.prototype.localAnchorB);box2d.b2RopeJointDef.prototype.maxLength=0;goog.exportProperty(box2d.b2RopeJointDef.prototype,"maxLength",box2d.b2RopeJointDef.prototype.maxLength);
+box2d.b2RopeJoint=function(a){box2d.b2Joint.call(this,a);this.m_localAnchorA=a.localAnchorA.Clone();this.m_localAnchorB=a.localAnchorB.Clone();this.m_maxLength=a.maxLength;this.m_u=new box2d.b2Vec2;this.m_rA=new box2d.b2Vec2;this.m_rB=new box2d.b2Vec2;this.m_localCenterA=new box2d.b2Vec2;this.m_localCenterB=new box2d.b2Vec2;this.m_qA=new box2d.b2Rot;this.m_qB=new box2d.b2Rot;this.m_lalcA=new box2d.b2Vec2;this.m_lalcB=new box2d.b2Vec2};goog.inherits(box2d.b2RopeJoint,box2d.b2Joint);
+goog.exportSymbol("box2d.b2RopeJoint",box2d.b2RopeJoint);box2d.b2RopeJoint.prototype.m_localAnchorA=null;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_localAnchorA",box2d.b2RopeJoint.prototype.m_localAnchorA);box2d.b2RopeJoint.prototype.m_localAnchorB=null;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_localAnchorB",box2d.b2RopeJoint.prototype.m_localAnchorB);box2d.b2RopeJoint.prototype.m_maxLength=0;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_maxLength",box2d.b2RopeJoint.prototype.m_maxLength);
+box2d.b2RopeJoint.prototype.m_length=0;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_length",box2d.b2RopeJoint.prototype.m_length);box2d.b2RopeJoint.prototype.m_impulse=0;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_impulse",box2d.b2RopeJoint.prototype.m_impulse);box2d.b2RopeJoint.prototype.m_indexA=0;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_indexA",box2d.b2RopeJoint.prototype.m_indexA);box2d.b2RopeJoint.prototype.m_indexB=0;
+goog.exportProperty(box2d.b2RopeJoint.prototype,"m_indexB",box2d.b2RopeJoint.prototype.m_indexB);box2d.b2RopeJoint.prototype.m_u=null;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_u",box2d.b2RopeJoint.prototype.m_u);box2d.b2RopeJoint.prototype.m_rA=null;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_rA",box2d.b2RopeJoint.prototype.m_rA);box2d.b2RopeJoint.prototype.m_rB=null;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_rB",box2d.b2RopeJoint.prototype.m_rB);
+box2d.b2RopeJoint.prototype.m_localCenterA=null;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_localCenterA",box2d.b2RopeJoint.prototype.m_localCenterA);box2d.b2RopeJoint.prototype.m_localCenterB=null;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_localCenterB",box2d.b2RopeJoint.prototype.m_localCenterB);box2d.b2RopeJoint.prototype.m_invMassA=0;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_invMassA",box2d.b2RopeJoint.prototype.m_invMassA);box2d.b2RopeJoint.prototype.m_invMassB=0;
+goog.exportProperty(box2d.b2RopeJoint.prototype,"m_invMassB",box2d.b2RopeJoint.prototype.m_invMassB);box2d.b2RopeJoint.prototype.m_invIA=0;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_invIA",box2d.b2RopeJoint.prototype.m_invIA);box2d.b2RopeJoint.prototype.m_invIB=0;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_invIB",box2d.b2RopeJoint.prototype.m_invIB);box2d.b2RopeJoint.prototype.m_mass=0;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_mass",box2d.b2RopeJoint.prototype.m_mass);
+box2d.b2RopeJoint.prototype.m_state=box2d.b2LimitState.e_inactiveLimit;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_state",box2d.b2RopeJoint.prototype.m_state);box2d.b2RopeJoint.prototype.m_qA=null;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_qA",box2d.b2RopeJoint.prototype.m_qA);box2d.b2RopeJoint.prototype.m_qB=null;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_qB",box2d.b2RopeJoint.prototype.m_qB);box2d.b2RopeJoint.prototype.m_lalcA=null;
+goog.exportProperty(box2d.b2RopeJoint.prototype,"m_lalcA",box2d.b2RopeJoint.prototype.m_lalcA);box2d.b2RopeJoint.prototype.m_lalcB=null;goog.exportProperty(box2d.b2RopeJoint.prototype,"m_lalcB",box2d.b2RopeJoint.prototype.m_lalcB);
+box2d.b2RopeJoint.prototype.InitVelocityConstraints=function(a){this.m_indexA=this.m_bodyA.m_islandIndex;this.m_indexB=this.m_bodyB.m_islandIndex;this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter);this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter);this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var b=a.positions[this.m_indexA].c,c=a.velocities[this.m_indexA].v,d=a.velocities[this.m_indexA].w,
+e=a.positions[this.m_indexB].c,f=a.positions[this.m_indexB].a,g=a.velocities[this.m_indexB].v,h=a.velocities[this.m_indexB].w,k=this.m_qA.SetAngle(a.positions[this.m_indexA].a),f=this.m_qB.SetAngle(f);box2d.b2Sub_V2_V2(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);box2d.b2Mul_R_V2(k,this.m_lalcA,this.m_rA);box2d.b2Sub_V2_V2(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);box2d.b2Mul_R_V2(f,this.m_lalcB,this.m_rB);this.m_u.Copy(e).SelfAdd(this.m_rB).SelfSub(b).SelfSub(this.m_rA);this.m_length=
+this.m_u.Length();this.m_state=0<this.m_length-this.m_maxLength?box2d.b2LimitState.e_atUpperLimit:box2d.b2LimitState.e_inactiveLimit;this.m_length>box2d.b2_linearSlop?(this.m_u.SelfMul(1/this.m_length),b=box2d.b2Cross_V2_V2(this.m_rA,this.m_u),e=box2d.b2Cross_V2_V2(this.m_rB,this.m_u),b=this.m_invMassA+this.m_invIA*b*b+this.m_invMassB+this.m_invIB*e*e,this.m_mass=0!==b?1/b:0,a.step.warmStarting?(this.m_impulse*=a.step.dtRatio,b=box2d.b2Mul_S_V2(this.m_impulse,this.m_u,box2d.b2RopeJoint.prototype.InitVelocityConstraints.s_P),
+c.SelfMulSub(this.m_invMassA,b),d-=this.m_invIA*box2d.b2Cross_V2_V2(this.m_rA,b),g.SelfMulAdd(this.m_invMassB,b),h+=this.m_invIB*box2d.b2Cross_V2_V2(this.m_rB,b)):this.m_impulse=0,a.velocities[this.m_indexA].w=d,a.velocities[this.m_indexB].w=h):(this.m_u.SetZero(),this.m_impulse=this.m_mass=0)};goog.exportProperty(box2d.b2RopeJoint.prototype,"InitVelocityConstraints",box2d.b2RopeJoint.prototype.InitVelocityConstraints);box2d.b2RopeJoint.prototype.InitVelocityConstraints.s_P=new box2d.b2Vec2;
+box2d.b2RopeJoint.prototype.SolveVelocityConstraints=function(a){var b=a.velocities[this.m_indexA].v,c=a.velocities[this.m_indexA].w,d=a.velocities[this.m_indexB].v,e=a.velocities[this.m_indexB].w,f=box2d.b2AddCross_V2_S_V2(b,c,this.m_rA,box2d.b2RopeJoint.prototype.SolveVelocityConstraints.s_vpA),g=box2d.b2AddCross_V2_S_V2(d,e,this.m_rB,box2d.b2RopeJoint.prototype.SolveVelocityConstraints.s_vpB),h=this.m_length-this.m_maxLength,f=box2d.b2Dot_V2_V2(this.m_u,box2d.b2Sub_V2_V2(g,f,box2d.b2Vec2.s_t0));
+0>h&&(f+=a.step.inv_dt*h);h=-this.m_mass*f;f=this.m_impulse;this.m_impulse=box2d.b2Min(0,this.m_impulse+h);h=this.m_impulse-f;h=box2d.b2Mul_S_V2(h,this.m_u,box2d.b2RopeJoint.prototype.SolveVelocityConstraints.s_P);b.SelfMulSub(this.m_invMassA,h);c-=this.m_invIA*box2d.b2Cross_V2_V2(this.m_rA,h);d.SelfMulAdd(this.m_invMassB,h);e+=this.m_invIB*box2d.b2Cross_V2_V2(this.m_rB,h);a.velocities[this.m_indexA].w=c;a.velocities[this.m_indexB].w=e};
+goog.exportProperty(box2d.b2RopeJoint.prototype,"SolveVelocityConstraints",box2d.b2RopeJoint.prototype.SolveVelocityConstraints);box2d.b2RopeJoint.prototype.SolveVelocityConstraints.s_vpA=new box2d.b2Vec2;box2d.b2RopeJoint.prototype.SolveVelocityConstraints.s_vpB=new box2d.b2Vec2;box2d.b2RopeJoint.prototype.SolveVelocityConstraints.s_P=new box2d.b2Vec2;
+box2d.b2RopeJoint.prototype.SolvePositionConstraints=function(a){var b=a.positions[this.m_indexA].c,c=a.positions[this.m_indexA].a,d=a.positions[this.m_indexB].c,e=a.positions[this.m_indexB].a,f=this.m_qA.SetAngle(c),g=this.m_qB.SetAngle(e);box2d.b2Sub_V2_V2(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);f=box2d.b2Mul_R_V2(f,this.m_lalcA,this.m_rA);box2d.b2Sub_V2_V2(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var g=box2d.b2Mul_R_V2(g,this.m_lalcB,this.m_rB),h=this.m_u.Copy(d).SelfAdd(g).SelfSub(b).SelfSub(f),
+k=h.Normalize(),l=k-this.m_maxLength,l=box2d.b2Clamp(l,0,box2d.b2_maxLinearCorrection),h=box2d.b2Mul_S_V2(-this.m_mass*l,h,box2d.b2RopeJoint.prototype.SolvePositionConstraints.s_P);b.SelfMulSub(this.m_invMassA,h);c-=this.m_invIA*box2d.b2Cross_V2_V2(f,h);d.SelfMulAdd(this.m_invMassB,h);e+=this.m_invIB*box2d.b2Cross_V2_V2(g,h);a.positions[this.m_indexA].a=c;a.positions[this.m_indexB].a=e;return k-this.m_maxLength<box2d.b2_linearSlop};
+goog.exportProperty(box2d.b2RopeJoint.prototype,"SolvePositionConstraints",box2d.b2RopeJoint.prototype.SolvePositionConstraints);box2d.b2RopeJoint.prototype.SolvePositionConstraints.s_P=new box2d.b2Vec2;box2d.b2RopeJoint.prototype.GetAnchorA=function(a){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,a)};goog.exportProperty(box2d.b2RopeJoint.prototype,"GetAnchorA",box2d.b2RopeJoint.prototype.GetAnchorA);
+box2d.b2RopeJoint.prototype.GetAnchorB=function(a){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,a)};goog.exportProperty(box2d.b2RopeJoint.prototype,"GetAnchorB",box2d.b2RopeJoint.prototype.GetAnchorB);box2d.b2RopeJoint.prototype.GetReactionForce=function(a,b){return box2d.b2Mul_S_V2(a*this.m_impulse,this.m_u,b)};goog.exportProperty(box2d.b2RopeJoint.prototype,"GetReactionForce",box2d.b2RopeJoint.prototype.GetReactionForce);box2d.b2RopeJoint.prototype.GetReactionTorque=function(a){return 0};
+goog.exportProperty(box2d.b2RopeJoint.prototype,"GetReactionTorque",box2d.b2RopeJoint.prototype.GetReactionTorque);box2d.b2RopeJoint.prototype.GetLocalAnchorA=function(a){return a.Copy(this.m_localAnchorA)};goog.exportProperty(box2d.b2RopeJoint.prototype,"GetLocalAnchorA",box2d.b2RopeJoint.prototype.GetLocalAnchorA);box2d.b2RopeJoint.prototype.GetLocalAnchorB=function(a){return a.Copy(this.m_localAnchorB)};goog.exportProperty(box2d.b2RopeJoint.prototype,"GetLocalAnchorB",box2d.b2RopeJoint.prototype.GetLocalAnchorB);
+box2d.b2RopeJoint.prototype.SetMaxLength=function(a){this.m_maxLength=a};goog.exportProperty(box2d.b2RopeJoint.prototype,"SetMaxLength",box2d.b2RopeJoint.prototype.SetMaxLength);box2d.b2RopeJoint.prototype.GetMaxLength=function(){return this.m_maxLength};goog.exportProperty(box2d.b2RopeJoint.prototype,"GetMaxLength",box2d.b2RopeJoint.prototype.GetMaxLength);box2d.b2RopeJoint.prototype.GetLimitState=function(){return this.m_state};goog.exportProperty(box2d.b2RopeJoint.prototype,"GetLimitState",box2d.b2RopeJoint.prototype.GetLimitState);
+box2d.b2RopeJoint.prototype.Dump=function(){if(box2d.DEBUG){var a=this.m_bodyA.m_islandIndex,b=this.m_bodyB.m_islandIndex;box2d.b2Log("  /*box2d.b2RopeJointDef*/ var jd = new box2d.b2RopeJointDef();\n");box2d.b2Log("  jd.bodyA = bodies[%d];\n",a);box2d.b2Log("  jd.bodyB = bodies[%d];\n",b);box2d.b2Log("  jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false");box2d.b2Log("  jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y);box2d.b2Log("  jd.localAnchorB.Set(%.15f, %.15f);\n",
+this.m_localAnchorB.x,this.m_localAnchorB.y);box2d.b2Log("  jd.maxLength = %.15f;\n",this.m_maxLength);box2d.b2Log("  joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}};goog.exportProperty(box2d.b2RopeJoint.prototype,"Dump",box2d.b2RopeJoint.prototype.Dump);box2d.b2WeldJointDef=function(){box2d.b2JointDef.call(this,box2d.b2JointType.e_weldJoint);this.localAnchorA=new box2d.b2Vec2;this.localAnchorB=new box2d.b2Vec2};goog.inherits(box2d.b2WeldJointDef,box2d.b2JointDef);goog.exportSymbol("box2d.b2WeldJointDef",box2d.b2WeldJointDef);box2d.b2WeldJointDef.prototype.localAnchorA=null;goog.exportProperty(box2d.b2WeldJointDef.prototype,"localAnchorA",box2d.b2WeldJointDef.prototype.localAnchorA);box2d.b2WeldJointDef.prototype.localAnchorB=null;
+goog.exportProperty(box2d.b2WeldJointDef.prototype,"localAnchorB",box2d.b2WeldJointDef.prototype.localAnchorB);box2d.b2WeldJointDef.prototype.referenceAngle=0;goog.exportProperty(box2d.b2WeldJointDef.prototype,"referenceAngle",box2d.b2WeldJointDef.prototype.referenceAngle);box2d.b2WeldJointDef.prototype.frequencyHz=0;goog.exportProperty(box2d.b2WeldJointDef.prototype,"frequencyHz",box2d.b2WeldJointDef.prototype.frequencyHz);box2d.b2WeldJointDef.prototype.dampingRatio=0;
+goog.exportProperty(box2d.b2WeldJointDef.prototype,"dampingRatio",box2d.b2WeldJointDef.prototype.dampingRatio);box2d.b2WeldJointDef.prototype.Initialize=function(a,b,c){this.bodyA=a;this.bodyB=b;this.bodyA.GetLocalPoint(c,this.localAnchorA);this.bodyB.GetLocalPoint(c,this.localAnchorB);this.referenceAngle=this.bodyB.GetAngle()-this.bodyA.GetAngle()};goog.exportProperty(box2d.b2WeldJointDef.prototype,"Initialize",box2d.b2WeldJointDef.prototype.Initialize);
+box2d.b2WeldJoint=function(a){box2d.b2Joint.call(this,a);this.m_frequencyHz=a.frequencyHz;this.m_dampingRatio=a.dampingRatio;this.m_localAnchorA=a.localAnchorA.Clone();this.m_localAnchorB=a.localAnchorB.Clone();this.m_referenceAngle=a.referenceAngle;this.m_impulse=new box2d.b2Vec3(0,0,0);this.m_rA=new box2d.b2Vec2;this.m_rB=new box2d.b2Vec2;this.m_localCenterA=new box2d.b2Vec2;this.m_localCenterB=new box2d.b2Vec2;this.m_mass=new box2d.b2Mat33;this.m_qA=new box2d.b2Rot;this.m_qB=new box2d.b2Rot;this.m_lalcA=
+new box2d.b2Vec2;this.m_lalcB=new box2d.b2Vec2;this.m_K=new box2d.b2Mat33};goog.inherits(box2d.b2WeldJoint,box2d.b2Joint);goog.exportSymbol("box2d.b2WeldJoint",box2d.b2WeldJoint);box2d.b2WeldJoint.prototype.m_frequencyHz=0;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_frequencyHz",box2d.b2WeldJoint.prototype.m_frequencyHz);box2d.b2WeldJoint.prototype.m_dampingRatio=0;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_dampingRatio",box2d.b2WeldJoint.prototype.m_dampingRatio);
+box2d.b2WeldJoint.prototype.m_bias=0;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_bias",box2d.b2WeldJoint.prototype.m_bias);box2d.b2WeldJoint.prototype.m_localAnchorA=null;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_localAnchorA",box2d.b2WeldJoint.prototype.m_localAnchorA);box2d.b2WeldJoint.prototype.m_localAnchorB=null;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_localAnchorB",box2d.b2WeldJoint.prototype.m_localAnchorB);box2d.b2WeldJoint.prototype.m_referenceAngle=0;
+goog.exportProperty(box2d.b2WeldJoint.prototype,"m_referenceAngle",box2d.b2WeldJoint.prototype.m_referenceAngle);box2d.b2WeldJoint.prototype.m_gamma=0;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_gamma",box2d.b2WeldJoint.prototype.m_gamma);box2d.b2WeldJoint.prototype.m_impulse=null;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_impulse",box2d.b2WeldJoint.prototype.m_impulse);box2d.b2WeldJoint.prototype.m_indexA=0;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_indexA",box2d.b2WeldJoint.prototype.m_indexA);
+box2d.b2WeldJoint.prototype.m_indexB=0;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_indexB",box2d.b2WeldJoint.prototype.m_indexB);box2d.b2WeldJoint.prototype.m_rA=null;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_rA",box2d.b2WeldJoint.prototype.m_rA);box2d.b2WeldJoint.prototype.m_rB=null;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_rB",box2d.b2WeldJoint.prototype.m_rB);box2d.b2WeldJoint.prototype.m_localCenterA=null;
+goog.exportProperty(box2d.b2WeldJoint.prototype,"m_localCenterA",box2d.b2WeldJoint.prototype.m_localCenterA);box2d.b2WeldJoint.prototype.m_localCenterB=null;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_localCenterB",box2d.b2WeldJoint.prototype.m_localCenterB);box2d.b2WeldJoint.prototype.m_invMassA=0;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_invMassA",box2d.b2WeldJoint.prototype.m_invMassA);box2d.b2WeldJoint.prototype.m_invMassB=0;
+goog.exportProperty(box2d.b2WeldJoint.prototype,"m_invMassB",box2d.b2WeldJoint.prototype.m_invMassB);box2d.b2WeldJoint.prototype.m_invIA=0;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_invIA",box2d.b2WeldJoint.prototype.m_invIA);box2d.b2WeldJoint.prototype.m_invIB=0;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_invIB",box2d.b2WeldJoint.prototype.m_invIB);box2d.b2WeldJoint.prototype.m_mass=null;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_mass",box2d.b2WeldJoint.prototype.m_mass);
+box2d.b2WeldJoint.prototype.m_qA=null;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_qA",box2d.b2WeldJoint.prototype.m_qA);box2d.b2WeldJoint.prototype.m_qB=null;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_qB",box2d.b2WeldJoint.prototype.m_qB);box2d.b2WeldJoint.prototype.m_lalcA=null;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_lalcA",box2d.b2WeldJoint.prototype.m_lalcA);box2d.b2WeldJoint.prototype.m_lalcB=null;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_lalcB",box2d.b2WeldJoint.prototype.m_lalcB);
+box2d.b2WeldJoint.prototype.m_K=null;goog.exportProperty(box2d.b2WeldJoint.prototype,"m_K",box2d.b2WeldJoint.prototype.m_K);
+box2d.b2WeldJoint.prototype.InitVelocityConstraints=function(a){this.m_indexA=this.m_bodyA.m_islandIndex;this.m_indexB=this.m_bodyB.m_islandIndex;this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter);this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter);this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var b=a.positions[this.m_indexA].a,c=a.velocities[this.m_indexA].v,d=a.velocities[this.m_indexA].w,
+e=a.positions[this.m_indexB].a,f=a.velocities[this.m_indexB].v,g=a.velocities[this.m_indexB].w,h=this.m_qA.SetAngle(b),k=this.m_qB.SetAngle(e);box2d.b2Sub_V2_V2(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);box2d.b2Mul_R_V2(h,this.m_lalcA,this.m_rA);box2d.b2Sub_V2_V2(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);box2d.b2Mul_R_V2(k,this.m_lalcB,this.m_rB);var h=this.m_invMassA,k=this.m_invMassB,l=this.m_invIA,m=this.m_invIB,n=this.m_K;n.ex.x=h+k+this.m_rA.y*this.m_rA.y*l+this.m_rB.y*
+this.m_rB.y*m;n.ey.x=-this.m_rA.y*this.m_rA.x*l-this.m_rB.y*this.m_rB.x*m;n.ez.x=-this.m_rA.y*l-this.m_rB.y*m;n.ex.y=n.ey.x;n.ey.y=h+k+this.m_rA.x*this.m_rA.x*l+this.m_rB.x*this.m_rB.x*m;n.ez.y=this.m_rA.x*l+this.m_rB.x*m;n.ex.z=n.ez.x;n.ey.z=n.ez.y;n.ez.z=l+m;if(0<this.m_frequencyHz){n.GetInverse22(this.m_mass);var n=l+m,p=0<n?1/n:0,b=e-b-this.m_referenceAngle,e=2*box2d.b2_pi*this.m_frequencyHz,q=p*e*e,r=a.step.dt;this.m_gamma=r*(2*p*this.m_dampingRatio*e+r*q);this.m_gamma=0!==this.m_gamma?1/this.m_gamma:
+0;this.m_bias=b*r*q*this.m_gamma;n+=this.m_gamma;this.m_mass.ez.z=0!==n?1/n:0}else 0===n.ez.z?n.GetInverse22(this.m_mass):n.GetSymInverse33(this.m_mass),this.m_bias=this.m_gamma=0;a.step.warmStarting?(this.m_impulse.SelfMulScalar(a.step.dtRatio),n=box2d.b2WeldJoint.prototype.InitVelocityConstraints.s_P.Set(this.m_impulse.x,this.m_impulse.y),c.SelfMulSub(h,n),d-=l*(box2d.b2Cross_V2_V2(this.m_rA,n)+this.m_impulse.z),f.SelfMulAdd(k,n),g+=m*(box2d.b2Cross_V2_V2(this.m_rB,n)+this.m_impulse.z)):this.m_impulse.SetZero();
+a.velocities[this.m_indexA].w=d;a.velocities[this.m_indexB].w=g};box2d.b2WeldJoint.prototype.InitVelocityConstraints.s_P=new box2d.b2Vec2;
+box2d.b2WeldJoint.prototype.SolveVelocityConstraints=function(a){var b=a.velocities[this.m_indexA].v,c=a.velocities[this.m_indexA].w,d=a.velocities[this.m_indexB].v,e=a.velocities[this.m_indexB].w,f=this.m_invMassA,g=this.m_invMassB,h=this.m_invIA,k=this.m_invIB;if(0<this.m_frequencyHz){var l=-this.m_mass.ez.z*(e-c+this.m_bias+this.m_gamma*this.m_impulse.z);this.m_impulse.z+=l;c-=h*l;e+=k*l;l=box2d.b2Sub_V2_V2(box2d.b2AddCross_V2_S_V2(d,e,this.m_rB,box2d.b2Vec2.s_t0),box2d.b2AddCross_V2_S_V2(b,c,
+this.m_rA,box2d.b2Vec2.s_t1),box2d.b2WeldJoint.prototype.SolveVelocityConstraints.s_Cdot1);l=box2d.b2Mul_M33_X_Y(this.m_mass,l.x,l.y,box2d.b2WeldJoint.prototype.SolveVelocityConstraints.s_impulse1).SelfNeg();this.m_impulse.x+=l.x;this.m_impulse.y+=l.y;b.SelfMulSub(f,l);c-=h*box2d.b2Cross_V2_V2(this.m_rA,l);d.SelfMulAdd(g,l);e+=k*box2d.b2Cross_V2_V2(this.m_rB,l)}else{var l=box2d.b2Sub_V2_V2(box2d.b2AddCross_V2_S_V2(d,e,this.m_rB,box2d.b2Vec2.s_t0),box2d.b2AddCross_V2_S_V2(b,c,this.m_rA,box2d.b2Vec2.s_t1),
+box2d.b2WeldJoint.prototype.SolveVelocityConstraints.s_Cdot1),m=box2d.b2Mul_M33_X_Y_Z(this.m_mass,l.x,l.y,e-c,box2d.b2WeldJoint.prototype.SolveVelocityConstraints.s_impulse).SelfNeg();this.m_impulse.SelfAdd(m);l=box2d.b2WeldJoint.prototype.SolveVelocityConstraints.s_P.Set(m.x,m.y);b.SelfMulSub(f,l);c-=h*(box2d.b2Cross_V2_V2(this.m_rA,l)+m.z);d.SelfMulAdd(g,l);e+=k*(box2d.b2Cross_V2_V2(this.m_rB,l)+m.z)}a.velocities[this.m_indexA].w=c;a.velocities[this.m_indexB].w=e};
+goog.exportProperty(box2d.b2WeldJoint.prototype,"SolveVelocityConstraints",box2d.b2WeldJoint.prototype.SolveVelocityConstraints);box2d.b2WeldJoint.prototype.SolveVelocityConstraints.s_Cdot1=new box2d.b2Vec2;box2d.b2WeldJoint.prototype.SolveVelocityConstraints.s_impulse1=new box2d.b2Vec2;box2d.b2WeldJoint.prototype.SolveVelocityConstraints.s_impulse=new box2d.b2Vec3;box2d.b2WeldJoint.prototype.SolveVelocityConstraints.s_P=new box2d.b2Vec2;
+box2d.b2WeldJoint.prototype.SolvePositionConstraints=function(a){var b=a.positions[this.m_indexA].c,c=a.positions[this.m_indexA].a,d=a.positions[this.m_indexB].c,e=a.positions[this.m_indexB].a,f=this.m_qA.SetAngle(c),g=this.m_qB.SetAngle(e),h=this.m_invMassA,k=this.m_invMassB,l=this.m_invIA,m=this.m_invIB;box2d.b2Sub_V2_V2(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var n=box2d.b2Mul_R_V2(f,this.m_lalcA,this.m_rA);box2d.b2Sub_V2_V2(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var p=
+box2d.b2Mul_R_V2(g,this.m_lalcB,this.m_rB),q=this.m_K;q.ex.x=h+k+n.y*n.y*l+p.y*p.y*m;q.ey.x=-n.y*n.x*l-p.y*p.x*m;q.ez.x=-n.y*l-p.y*m;q.ex.y=q.ey.x;q.ey.y=h+k+n.x*n.x*l+p.x*p.x*m;q.ez.y=n.x*l+p.x*m;q.ex.z=q.ez.x;q.ey.z=q.ez.y;q.ez.z=l+m;if(0<this.m_frequencyHz){var r=box2d.b2Sub_V2_V2(box2d.b2Add_V2_V2(d,p,box2d.b2Vec2.s_t0),box2d.b2Add_V2_V2(b,n,box2d.b2Vec2.s_t1),box2d.b2WeldJoint.prototype.SolvePositionConstraints.s_C1),g=r.Length(),f=0,q=q.Solve22(r.x,r.y,box2d.b2WeldJoint.prototype.SolvePositionConstraints.s_P).SelfNeg();
+b.SelfMulSub(h,q);c-=l*box2d.b2Cross_V2_V2(n,q);d.SelfMulAdd(k,q);e+=m*box2d.b2Cross_V2_V2(p,q)}else r=box2d.b2Sub_V2_V2(box2d.b2Add_V2_V2(d,p,box2d.b2Vec2.s_t0),box2d.b2Add_V2_V2(b,n,box2d.b2Vec2.s_t1),box2d.b2WeldJoint.prototype.SolvePositionConstraints.s_C1),p=e-c-this.m_referenceAngle,g=r.Length(),f=box2d.b2Abs(p),n=box2d.b2WeldJoint.prototype.SolvePositionConstraints.s_impulse,0<q.ez.z?q.Solve33(r.x,r.y,p,n).SelfNeg():(q=q.Solve22(r.x,r.y,box2d.b2WeldJoint.prototype.SolvePositionConstraints.s_impulse2).SelfNeg(),
+n.x=q.x,n.y=q.y,n.z=0),q=box2d.b2WeldJoint.prototype.SolvePositionConstraints.s_P.Set(n.x,n.y),b.SelfMulSub(h,q),c-=l*(box2d.b2Cross_V2_V2(this.m_rA,q)+n.z),d.SelfMulAdd(k,q),e+=m*(box2d.b2Cross_V2_V2(this.m_rB,q)+n.z);a.positions[this.m_indexA].a=c;a.positions[this.m_indexB].a=e;return g<=box2d.b2_linearSlop&&f<=box2d.b2_angularSlop};goog.exportProperty(box2d.b2WeldJoint.prototype,"SolvePositionConstraints",box2d.b2WeldJoint.prototype.SolvePositionConstraints);
+box2d.b2WeldJoint.prototype.SolvePositionConstraints.s_C1=new box2d.b2Vec2;box2d.b2WeldJoint.prototype.SolvePositionConstraints.s_P=new box2d.b2Vec2;box2d.b2WeldJoint.prototype.SolvePositionConstraints.s_impulse=new box2d.b2Vec3;box2d.b2WeldJoint.prototype.SolvePositionConstraints.s_impulse2=new box2d.b2Vec2;box2d.b2WeldJoint.prototype.GetAnchorA=function(a){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,a)};goog.exportProperty(box2d.b2WeldJoint.prototype,"GetAnchorA",box2d.b2WeldJoint.prototype.GetAnchorA);
+box2d.b2WeldJoint.prototype.GetAnchorB=function(a){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,a)};goog.exportProperty(box2d.b2WeldJoint.prototype,"GetAnchorB",box2d.b2WeldJoint.prototype.GetAnchorB);box2d.b2WeldJoint.prototype.GetReactionForce=function(a,b){return b.Set(a*this.m_impulse.x,a*this.m_impulse.y)};goog.exportProperty(box2d.b2WeldJoint.prototype,"GetReactionForce",box2d.b2WeldJoint.prototype.GetReactionForce);
+box2d.b2WeldJoint.prototype.GetReactionTorque=function(a){return a*this.m_impulse.z};goog.exportProperty(box2d.b2WeldJoint.prototype,"GetReactionTorque",box2d.b2WeldJoint.prototype.GetReactionTorque);box2d.b2WeldJoint.prototype.GetLocalAnchorA=function(a){return a.Copy(this.m_localAnchorA)};goog.exportProperty(box2d.b2WeldJoint.prototype,"GetLocalAnchorA",box2d.b2WeldJoint.prototype.GetLocalAnchorA);box2d.b2WeldJoint.prototype.GetLocalAnchorB=function(a){return a.Copy(this.m_localAnchorB)};
+goog.exportProperty(box2d.b2WeldJoint.prototype,"GetLocalAnchorB",box2d.b2WeldJoint.prototype.GetLocalAnchorB);box2d.b2WeldJoint.prototype.GetReferenceAngle=function(){return this.m_referenceAngle};goog.exportProperty(box2d.b2WeldJoint.prototype,"GetReferenceAngle",box2d.b2WeldJoint.prototype.GetReferenceAngle);box2d.b2WeldJoint.prototype.SetFrequency=function(a){this.m_frequencyHz=a};box2d.b2WeldJoint.prototype.GetFrequency=function(){return this.m_frequencyHz};
+goog.exportProperty(box2d.b2WeldJoint.prototype,"GetFrequency",box2d.b2WeldJoint.prototype.GetFrequency);box2d.b2WeldJoint.prototype.SetDampingRatio=function(a){this.m_dampingRatio=a};box2d.b2WeldJoint.prototype.GetDampingRatio=function(){return this.m_dampingRatio};goog.exportProperty(box2d.b2WeldJoint.prototype,"GetDampingRatio",box2d.b2WeldJoint.prototype.GetDampingRatio);
+box2d.b2WeldJoint.prototype.Dump=function(){if(box2d.DEBUG){var a=this.m_bodyA.m_islandIndex,b=this.m_bodyB.m_islandIndex;box2d.b2Log("  /*box2d.b2WeldJointDef*/ var jd = new box2d.b2WeldJointDef();\n");box2d.b2Log("  jd.bodyA = bodies[%d];\n",a);box2d.b2Log("  jd.bodyB = bodies[%d];\n",b);box2d.b2Log("  jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false");box2d.b2Log("  jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y);box2d.b2Log("  jd.localAnchorB.Set(%.15f, %.15f);\n",
+this.m_localAnchorB.x,this.m_localAnchorB.y);box2d.b2Log("  jd.referenceAngle = %.15f;\n",this.m_referenceAngle);box2d.b2Log("  jd.frequencyHz = %.15f;\n",this.m_frequencyHz);box2d.b2Log("  jd.dampingRatio = %.15f;\n",this.m_dampingRatio);box2d.b2Log("  joints[%d] = this.m_world.CreateJoint(jd);\n",this.m_index)}};goog.exportProperty(box2d.b2WeldJoint.prototype,"Dump",box2d.b2WeldJoint.prototype.Dump);box2d.b2WheelJointDef=function(){box2d.b2JointDef.call(this,box2d.b2JointType.e_wheelJoint);this.localAnchorA=new box2d.b2Vec2(0,0);this.localAnchorB=new box2d.b2Vec2(0,0);this.localAxisA=new box2d.b2Vec2(1,0)};goog.inherits(box2d.b2WheelJointDef,box2d.b2JointDef);goog.exportSymbol("box2d.b2WheelJointDef",box2d.b2WheelJointDef);box2d.b2WheelJointDef.prototype.localAnchorA=null;goog.exportProperty(box2d.b2WheelJointDef.prototype,"localAnchorA",box2d.b2WheelJointDef.prototype.localAnchorA);
+box2d.b2WheelJointDef.prototype.localAnchorB=null;goog.exportProperty(box2d.b2WheelJointDef.prototype,"localAnchorB",box2d.b2WheelJointDef.prototype.localAnchorB);box2d.b2WheelJointDef.prototype.localAxisA=null;goog.exportProperty(box2d.b2WheelJointDef.prototype,"localAxisA",box2d.b2WheelJointDef.prototype.localAxisA);box2d.b2WheelJointDef.prototype.enableMotor=!1;goog.exportProperty(box2d.b2WheelJointDef.prototype,"enableMotor",box2d.b2WheelJointDef.prototype.enableMotor);
+box2d.b2WheelJointDef.prototype.maxMotorTorque=0;goog.exportProperty(box2d.b2WheelJointDef.prototype,"maxMotorTorque",box2d.b2WheelJointDef.prototype.maxMotorTorque);box2d.b2WheelJointDef.prototype.motorSpeed=0;goog.exportProperty(box2d.b2WheelJointDef.prototype,"motorSpeed",box2d.b2WheelJointDef.prototype.motorSpeed);box2d.b2WheelJointDef.prototype.frequencyHz=2;goog.exportProperty(box2d.b2WheelJointDef.prototype,"frequencyHz",box2d.b2WheelJointDef.prototype.frequencyHz);
+box2d.b2WheelJointDef.prototype.dampingRatio=.7;goog.exportProperty(box2d.b2WheelJointDef.prototype,"dampingRatio",box2d.b2WheelJointDef.prototype.dampingRatio);box2d.b2WheelJointDef.prototype.Initialize=function(a,b,c,d){this.bodyA=a;this.bodyB=b;this.bodyA.GetLocalPoint(c,this.localAnchorA);this.bodyB.GetLocalPoint(c,this.localAnchorB);this.bodyA.GetLocalVector(d,this.localAxisA)};goog.exportProperty(box2d.b2WheelJointDef.prototype,"Initialize",box2d.b2WheelJointDef.prototype.Initialize);
+box2d.b2WheelJoint=function(a){box2d.b2Joint.call(this,a);this.m_frequencyHz=a.frequencyHz;this.m_dampingRatio=a.dampingRatio;this.m_localAnchorA=a.localAnchorA.Clone();this.m_localAnchorB=a.localAnchorB.Clone();this.m_localXAxisA=a.localAxisA.Clone();this.m_localYAxisA=box2d.b2Cross_S_V2(1,this.m_localXAxisA,new box2d.b2Vec2);this.m_maxMotorTorque=a.maxMotorTorque;this.m_motorSpeed=a.motorSpeed;this.m_enableMotor=a.enableMotor;this.m_localCenterA=new box2d.b2Vec2;this.m_localCenterB=new box2d.b2Vec2;
+this.m_ax=new box2d.b2Vec2;this.m_ay=new box2d.b2Vec2;this.m_qA=new box2d.b2Rot;this.m_qB=new box2d.b2Rot;this.m_lalcA=new box2d.b2Vec2;this.m_lalcB=new box2d.b2Vec2;this.m_rA=new box2d.b2Vec2;this.m_rB=new box2d.b2Vec2;this.m_ax.SetZero();this.m_ay.SetZero()};goog.inherits(box2d.b2WheelJoint,box2d.b2Joint);goog.exportSymbol("box2d.b2WheelJoint",box2d.b2WheelJoint);box2d.b2WheelJoint.prototype.m_frequencyHz=0;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_frequencyHz",box2d.b2WheelJoint.prototype.m_frequencyHz);
+box2d.b2WheelJoint.prototype.m_dampingRatio=0;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_dampingRatio",box2d.b2WheelJoint.prototype.m_dampingRatio);box2d.b2WheelJoint.prototype.m_localAnchorA=null;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_localAnchorA",box2d.b2WheelJoint.prototype.m_localAnchorA);box2d.b2WheelJoint.prototype.m_localAnchorB=null;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_localAnchorB",box2d.b2WheelJoint.prototype.m_localAnchorB);
+box2d.b2WheelJoint.prototype.m_localXAxisA=null;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_localXAxisA",box2d.b2WheelJoint.prototype.m_localXAxisA);box2d.b2WheelJoint.prototype.m_localYAxisA=null;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_localYAxisA",box2d.b2WheelJoint.prototype.m_localYAxisA);box2d.b2WheelJoint.prototype.m_impulse=0;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_impulse",box2d.b2WheelJoint.prototype.m_impulse);box2d.b2WheelJoint.prototype.m_motorImpulse=0;
+goog.exportProperty(box2d.b2WheelJoint.prototype,"m_motorImpulse",box2d.b2WheelJoint.prototype.m_motorImpulse);box2d.b2WheelJoint.prototype.m_springImpulse=0;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_springImpulse",box2d.b2WheelJoint.prototype.m_springImpulse);box2d.b2WheelJoint.prototype.m_maxMotorTorque=0;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_maxMotorTorque",box2d.b2WheelJoint.prototype.m_maxMotorTorque);box2d.b2WheelJoint.prototype.m_motorSpeed=0;
+goog.exportProperty(box2d.b2WheelJoint.prototype,"m_motorSpeed",box2d.b2WheelJoint.prototype.m_motorSpeed);box2d.b2WheelJoint.prototype.m_enableMotor=!1;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_enableMotor",box2d.b2WheelJoint.prototype.m_enableMotor);box2d.b2WheelJoint.prototype.m_indexA=0;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_indexA",box2d.b2WheelJoint.prototype.m_indexA);box2d.b2WheelJoint.prototype.m_indexB=0;
+goog.exportProperty(box2d.b2WheelJoint.prototype,"m_indexB",box2d.b2WheelJoint.prototype.m_indexB);box2d.b2WheelJoint.prototype.m_localCenterA=null;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_localCenterA",box2d.b2WheelJoint.prototype.m_localCenterA);box2d.b2WheelJoint.prototype.m_localCenterB=null;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_localCenterB",box2d.b2WheelJoint.prototype.m_localCenterB);box2d.b2WheelJoint.prototype.m_invMassA=0;
+goog.exportProperty(box2d.b2WheelJoint.prototype,"m_invMassA",box2d.b2WheelJoint.prototype.m_invMassA);box2d.b2WheelJoint.prototype.m_invMassB=0;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_invMassB",box2d.b2WheelJoint.prototype.m_invMassB);box2d.b2WheelJoint.prototype.m_invIA=0;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_invIA",box2d.b2WheelJoint.prototype.m_invIA);box2d.b2WheelJoint.prototype.m_invIB=0;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_invIB",box2d.b2WheelJoint.prototype.m_invIB);
+box2d.b2WheelJoint.prototype.m_ax=null;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_ax",box2d.b2WheelJoint.prototype.m_ax);box2d.b2WheelJoint.prototype.m_ay=null;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_ay",box2d.b2WheelJoint.prototype.m_ay);box2d.b2WheelJoint.prototype.m_sAx=0;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_sAx",box2d.b2WheelJoint.prototype.m_sAx);box2d.b2WheelJoint.prototype.m_sBx=0;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_sBx",box2d.b2WheelJoint.prototype.m_sBx);
+box2d.b2WheelJoint.prototype.m_sAy=0;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_sAy",box2d.b2WheelJoint.prototype.m_sAy);box2d.b2WheelJoint.prototype.m_sBy=0;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_sBy",box2d.b2WheelJoint.prototype.m_sBy);box2d.b2WheelJoint.prototype.m_mass=0;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_mass",box2d.b2WheelJoint.prototype.m_mass);box2d.b2WheelJoint.prototype.m_motorMass=0;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_motorMass",box2d.b2WheelJoint.prototype.m_motorMass);
+box2d.b2WheelJoint.prototype.m_springMass=0;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_springMass",box2d.b2WheelJoint.prototype.m_springMass);box2d.b2WheelJoint.prototype.m_bias=0;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_bias",box2d.b2WheelJoint.prototype.m_bias);box2d.b2WheelJoint.prototype.m_gamma=0;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_gamma",box2d.b2WheelJoint.prototype.m_gamma);box2d.b2WheelJoint.prototype.m_qA=null;
+goog.exportProperty(box2d.b2WheelJoint.prototype,"m_qA",box2d.b2WheelJoint.prototype.m_qA);box2d.b2WheelJoint.prototype.m_qB=null;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_qB",box2d.b2WheelJoint.prototype.m_qB);box2d.b2WheelJoint.prototype.m_lalcA=null;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_lalcA",box2d.b2WheelJoint.prototype.m_lalcA);box2d.b2WheelJoint.prototype.m_lalcB=null;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_lalcB",box2d.b2WheelJoint.prototype.m_lalcB);
+box2d.b2WheelJoint.prototype.m_rA=null;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_rA",box2d.b2WheelJoint.prototype.m_rA);box2d.b2WheelJoint.prototype.m_rB=null;goog.exportProperty(box2d.b2WheelJoint.prototype,"m_rB",box2d.b2WheelJoint.prototype.m_rB);box2d.b2WheelJoint.prototype.GetMotorSpeed=function(){return this.m_motorSpeed};goog.exportProperty(box2d.b2WheelJoint.prototype,"GetMotorSpeed",box2d.b2WheelJoint.prototype.GetMotorSpeed);box2d.b2WheelJoint.prototype.GetMaxMotorTorque=function(){return this.m_maxMotorTorque};
+goog.exportProperty(box2d.b2WheelJoint.prototype,"GetMaxMotorTorque",box2d.b2WheelJoint.prototype.GetMaxMotorTorque);box2d.b2WheelJoint.prototype.SetSpringFrequencyHz=function(a){this.m_frequencyHz=a};goog.exportProperty(box2d.b2WheelJoint.prototype,"SetSpringFrequencyHz",box2d.b2WheelJoint.prototype.SetSpringFrequencyHz);box2d.b2WheelJoint.prototype.GetSpringFrequencyHz=function(){return this.m_frequencyHz};goog.exportProperty(box2d.b2WheelJoint.prototype,"GetSpringFrequencyHz",box2d.b2WheelJoint.prototype.GetSpringFrequencyHz);
+box2d.b2WheelJoint.prototype.SetSpringDampingRatio=function(a){this.m_dampingRatio=a};goog.exportProperty(box2d.b2WheelJoint.prototype,"SetSpringDampingRatio",box2d.b2WheelJoint.prototype.SetSpringDampingRatio);box2d.b2WheelJoint.prototype.GetSpringDampingRatio=function(){return this.m_dampingRatio};goog.exportProperty(box2d.b2WheelJoint.prototype,"GetSpringDampingRatio",box2d.b2WheelJoint.prototype.GetSpringDampingRatio);
+box2d.b2WheelJoint.prototype.InitVelocityConstraints=function(a){this.m_indexA=this.m_bodyA.m_islandIndex;this.m_indexB=this.m_bodyB.m_islandIndex;this.m_localCenterA.Copy(this.m_bodyA.m_sweep.localCenter);this.m_localCenterB.Copy(this.m_bodyB.m_sweep.localCenter);this.m_invMassA=this.m_bodyA.m_invMass;this.m_invMassB=this.m_bodyB.m_invMass;this.m_invIA=this.m_bodyA.m_invI;this.m_invIB=this.m_bodyB.m_invI;var b=this.m_invMassA,c=this.m_invMassB,d=this.m_invIA,e=this.m_invIB,f=a.positions[this.m_indexA].c,
+g=a.velocities[this.m_indexA].v,h=a.velocities[this.m_indexA].w,k=a.positions[this.m_indexB].c,l=a.positions[this.m_indexB].a,m=a.velocities[this.m_indexB].v,n=a.velocities[this.m_indexB].w,p=this.m_qA.SetAngle(a.positions[this.m_indexA].a),q=this.m_qB.SetAngle(l);box2d.b2Sub_V2_V2(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);l=box2d.b2Mul_R_V2(p,this.m_lalcA,this.m_rA);box2d.b2Sub_V2_V2(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);q=box2d.b2Mul_R_V2(q,this.m_lalcB,this.m_rB);f=
+box2d.b2Sub_V2_V2(box2d.b2Add_V2_V2(k,q,box2d.b2Vec2.s_t0),box2d.b2Add_V2_V2(f,l,box2d.b2Vec2.s_t1),box2d.b2WheelJoint.prototype.InitVelocityConstraints.s_d);box2d.b2Mul_R_V2(p,this.m_localYAxisA,this.m_ay);this.m_sAy=box2d.b2Cross_V2_V2(box2d.b2Add_V2_V2(f,l,box2d.b2Vec2.s_t0),this.m_ay);this.m_sBy=box2d.b2Cross_V2_V2(q,this.m_ay);this.m_mass=b+c+d*this.m_sAy*this.m_sAy+e*this.m_sBy*this.m_sBy;0<this.m_mass&&(this.m_mass=1/this.m_mass);this.m_gamma=this.m_bias=this.m_springMass=0;0<this.m_frequencyHz?
+(box2d.b2Mul_R_V2(p,this.m_localXAxisA,this.m_ax),this.m_sAx=box2d.b2Cross_V2_V2(box2d.b2Add_V2_V2(f,l,box2d.b2Vec2.s_t0),this.m_ax),this.m_sBx=box2d.b2Cross_V2_V2(q,this.m_ax),b=b+c+d*this.m_sAx*this.m_sAx+e*this.m_sBx*this.m_sBx,0<b&&(this.m_springMass=1/b,c=box2d.b2Dot_V2_V2(f,this.m_ax),p=2*box2d.b2_pi*this.m_frequencyHz,f=this.m_springMass*p*p,k=a.step.dt,this.m_gamma=k*(2*this.m_springMass*this.m_dampingRatio*p+k*f),0<this.m_gamma&&(this.m_gamma=1/this.m_gamma),this.m_bias=c*k*f*this.m_gamma,
+this.m_springMass=b+this.m_gamma,0<this.m_springMass&&(this.m_springMass=1/this.m_springMass))):this.m_springImpulse=0;this.m_enableMotor?(this.m_motorMass=d+e,0<this.m_motorMass&&(this.m_motorMass=1/this.m_motorMass)):this.m_motorImpulse=this.m_motorMass=0;a.step.warmStarting?(this.m_impulse*=a.step.dtRatio,this.m_springImpulse*=a.step.dtRatio,this.m_motorImpulse*=a.step.dtRatio,d=box2d.b2Add_V2_V2(box2d.b2Mul_S_V2(this.m_impulse,this.m_ay,box2d.b2Vec2.s_t0),box2d.b2Mul_S_V2(this.m_springImpulse,
+this.m_ax,box2d.b2Vec2.s_t1),box2d.b2WheelJoint.prototype.InitVelocityConstraints.s_P),e=this.m_impulse*this.m_sAy+this.m_springImpulse*this.m_sAx+this.m_motorImpulse,b=this.m_impulse*this.m_sBy+this.m_springImpulse*this.m_sBx+this.m_motorImpulse,g.SelfMulSub(this.m_invMassA,d),h-=this.m_invIA*e,m.SelfMulAdd(this.m_invMassB,d),n+=this.m_invIB*b):this.m_motorImpulse=this.m_springImpulse=this.m_impulse=0;a.velocities[this.m_indexA].w=h;a.velocities[this.m_indexB].w=n};
+goog.exportProperty(box2d.b2WheelJoint.prototype,"InitVelocityConstraints",box2d.b2WheelJoint.prototype.InitVelocityConstraints);box2d.b2WheelJoint.prototype.InitVelocityConstraints.s_d=new box2d.b2Vec2;box2d.b2WheelJoint.prototype.InitVelocityConstraints.s_P=new box2d.b2Vec2;
+box2d.b2WheelJoint.prototype.SolveVelocityConstraints=function(a){var b=this.m_invMassA,c=this.m_invMassB,d=this.m_invIA,e=this.m_invIB,f=a.velocities[this.m_indexA].v,g=a.velocities[this.m_indexA].w,h=a.velocities[this.m_indexB].v,k=a.velocities[this.m_indexB].w,l=box2d.b2Dot_V2_V2(this.m_ax,box2d.b2Sub_V2_V2(h,f,box2d.b2Vec2.s_t0))+this.m_sBx*k-this.m_sAx*g,l=-this.m_springMass*(l+this.m_bias+this.m_gamma*this.m_springImpulse);this.m_springImpulse+=l;var m=box2d.b2Mul_S_V2(l,this.m_ax,box2d.b2WheelJoint.prototype.SolveVelocityConstraints.s_P),
+n=l*this.m_sAx,l=l*this.m_sBx;f.SelfMulSub(b,m);g-=d*n;h.SelfMulAdd(c,m);k+=e*l;l=k-g-this.m_motorSpeed;l*=-this.m_motorMass;m=this.m_motorImpulse;n=a.step.dt*this.m_maxMotorTorque;this.m_motorImpulse=box2d.b2Clamp(this.m_motorImpulse+l,-n,n);l=this.m_motorImpulse-m;g-=d*l;k+=e*l;l=box2d.b2Dot_V2_V2(this.m_ay,box2d.b2Sub_V2_V2(h,f,box2d.b2Vec2.s_t0))+this.m_sBy*k-this.m_sAy*g;l*=-this.m_mass;this.m_impulse+=l;m=box2d.b2Mul_S_V2(l,this.m_ay,box2d.b2WheelJoint.prototype.SolveVelocityConstraints.s_P);
+n=l*this.m_sAy;l*=this.m_sBy;f.SelfMulSub(b,m);g-=d*n;h.SelfMulAdd(c,m);a.velocities[this.m_indexA].w=g;a.velocities[this.m_indexB].w=k+e*l};goog.exportProperty(box2d.b2WheelJoint.prototype,"SolveVelocityConstraints",box2d.b2WheelJoint.prototype.SolveVelocityConstraints);box2d.b2WheelJoint.prototype.SolveVelocityConstraints.s_P=new box2d.b2Vec2;
+box2d.b2WheelJoint.prototype.SolvePositionConstraints=function(a){var b=a.positions[this.m_indexA].c,c=a.positions[this.m_indexA].a,d=a.positions[this.m_indexB].c,e=a.positions[this.m_indexB].a,f=this.m_qA.SetAngle(c),g=this.m_qB.SetAngle(e);box2d.b2Sub_V2_V2(this.m_localAnchorA,this.m_localCenterA,this.m_lalcA);var h=box2d.b2Mul_R_V2(f,this.m_lalcA,this.m_rA);box2d.b2Sub_V2_V2(this.m_localAnchorB,this.m_localCenterB,this.m_lalcB);var g=box2d.b2Mul_R_V2(g,this.m_lalcB,this.m_rB),k=box2d.b2Add_V2_V2(box2d.b2Sub_V2_V2(d,
+b,box2d.b2Vec2.s_t0),box2d.b2Sub_V2_V2(g,h,box2d.b2Vec2.s_t1),box2d.b2WheelJoint.prototype.SolvePositionConstraints.s_d),f=box2d.b2Mul_R_V2(f,this.m_localYAxisA,this.m_ay),h=box2d.b2Cross_V2_V2(box2d.b2Add_V2_V2(k,h,box2d.b2Vec2.s_t0),f),g=box2d.b2Cross_V2_V2(g,f),k=box2d.b2Dot_V2_V2(k,this.m_ay),l=this.m_invMassA+this.m_invMassB+this.m_invIA*this.m_sAy*this.m_sAy+this.m_invIB*this.m_sBy*this.m_sBy,l=0!==l?-k/l:0,f=box2d.b2Mul_S_V2(l,f,box2d.b2WheelJoint.prototype.SolvePositionConstraints.s_P),h=
+l*h,g=l*g;b.SelfMulSub(this.m_invMassA,f);c-=this.m_invIA*h;d.SelfMulAdd(this.m_invMassB,f);e+=this.m_invIB*g;a.positions[this.m_indexA].a=c;a.positions[this.m_indexB].a=e;return box2d.b2Abs(k)<=box2d.b2_linearSlop};goog.exportProperty(box2d.b2WheelJoint.prototype,"SolvePositionConstraints",box2d.b2WheelJoint.prototype.SolvePositionConstraints);box2d.b2WheelJoint.prototype.SolvePositionConstraints.s_d=new box2d.b2Vec2;box2d.b2WheelJoint.prototype.SolvePositionConstraints.s_P=new box2d.b2Vec2;
+box2d.b2WheelJoint.prototype.GetDefinition=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(!1);return a};goog.exportProperty(box2d.b2WheelJoint.prototype,"GetDefinition",box2d.b2WheelJoint.prototype.GetDefinition);box2d.b2WheelJoint.prototype.GetAnchorA=function(a){return this.m_bodyA.GetWorldPoint(this.m_localAnchorA,a)};goog.exportProperty(box2d.b2WheelJoint.prototype,"GetAnchorA",box2d.b2WheelJoint.prototype.GetAnchorA);
+box2d.b2WheelJoint.prototype.GetAnchorB=function(a){return this.m_bodyB.GetWorldPoint(this.m_localAnchorB,a)};goog.exportProperty(box2d.b2WheelJoint.prototype,"GetAnchorB",box2d.b2WheelJoint.prototype.GetAnchorB);box2d.b2WheelJoint.prototype.GetReactionForce=function(a,b){b.x=a*(this.m_impulse*this.m_ay.x+this.m_springImpulse*this.m_ax.x);b.y=a*(this.m_impulse*this.m_ay.y+this.m_springImpulse*this.m_ax.y);return b};goog.exportProperty(box2d.b2WheelJoint.prototype,"GetReactionForce",box2d.b2WheelJoint.prototype.GetReactionForce);
+box2d.b2WheelJoint.prototype.GetReactionTorque=function(a){return a*this.m_motorImpulse};goog.exportProperty(box2d.b2WheelJoint.prototype,"GetReactionTorque",box2d.b2WheelJoint.prototype.GetReactionTorque);box2d.b2WheelJoint.prototype.GetLocalAnchorA=function(a){return a.Copy(this.m_localAnchorA)};goog.exportProperty(box2d.b2WheelJoint.prototype,"GetLocalAnchorA",box2d.b2WheelJoint.prototype.GetLocalAnchorA);box2d.b2WheelJoint.prototype.GetLocalAnchorB=function(a){return a.Copy(this.m_localAnchorB)};
+goog.exportProperty(box2d.b2WheelJoint.prototype,"GetLocalAnchorB",box2d.b2WheelJoint.prototype.GetLocalAnchorB);box2d.b2WheelJoint.prototype.GetLocalAxisA=function(a){return a.Copy(this.m_localXAxisA)};goog.exportProperty(box2d.b2WheelJoint.prototype,"GetLocalAxisA",box2d.b2WheelJoint.prototype.GetLocalAxisA);box2d.b2WheelJoint.prototype.GetJointTranslation=function(){return this.GetPrismaticJointTranslation()};goog.exportProperty(box2d.b2WheelJoint.prototype,"GetJointTranslation",box2d.b2WheelJoint.prototype.GetJointTranslation);
+box2d.b2WheelJoint.prototype.GetJointSpeed=function(){return this.GetRevoluteJointSpeed()};goog.exportProperty(box2d.b2WheelJoint.prototype,"GetJointSpeed",box2d.b2WheelJoint.prototype.GetJointSpeed);
+box2d.b2WheelJoint.prototype.GetPrismaticJointTranslation=function(){var a=this.m_bodyA,b=this.m_bodyB,c=a.GetWorldPoint(this.m_localAnchorA,new box2d.b2Vec2),b=b.GetWorldPoint(this.m_localAnchorB,new box2d.b2Vec2),c=box2d.b2Sub_V2_V2(b,c,new box2d.b2Vec2),a=a.GetWorldVector(this.m_localXAxisA,new box2d.b2Vec2);return box2d.b2Dot_V2_V2(c,a)};goog.exportProperty(box2d.b2WheelJoint.prototype,"GetPrismaticJointTranslation",box2d.b2WheelJoint.prototype.GetPrismaticJointTranslation);
+box2d.b2WheelJoint.prototype.GetPrismaticJointSpeed=function(){var a=this.m_bodyA,b=this.m_bodyB;box2d.b2Sub_V2_V2(this.m_localAnchorA,a.m_sweep.localCenter,this.m_lalcA);var c=box2d.b2Mul_R_V2(a.m_xf.q,this.m_lalcA,this.m_rA);box2d.b2Sub_V2_V2(this.m_localAnchorB,b.m_sweep.localCenter,this.m_lalcB);var d=box2d.b2Mul_R_V2(b.m_xf.q,this.m_lalcB,this.m_rB),e=box2d.b2Add_V2_V2(a.m_sweep.c,c,box2d.b2Vec2.s_t0),f=box2d.b2Add_V2_V2(b.m_sweep.c,d,box2d.b2Vec2.s_t1),e=box2d.b2Sub_V2_V2(f,e,box2d.b2Vec2.s_t2),
+f=a.GetWorldVector(this.m_localXAxisA,new box2d.b2Vec2),g=a.m_linearVelocity,h=b.m_linearVelocity,a=a.m_angularVelocity,b=b.m_angularVelocity;return box2d.b2Dot_V2_V2(e,box2d.b2Cross_S_V2(a,f,box2d.b2Vec2.s_t0))+box2d.b2Dot_V2_V2(f,box2d.b2Sub_V2_V2(box2d.b2AddCross_V2_S_V2(h,b,d,box2d.b2Vec2.s_t0),box2d.b2AddCross_V2_S_V2(g,a,c,box2d.b2Vec2.s_t1),box2d.b2Vec2.s_t0))};goog.exportProperty(box2d.b2WheelJoint.prototype,"GetPrismaticJointSpeed",box2d.b2WheelJoint.prototype.GetPrismaticJointSpeed);
+box2d.b2WheelJoint.prototype.GetRevoluteJointAngle=function(){return this.m_bodyB.m_sweep.a-this.m_bodyA.m_sweep.a};goog.exportProperty(box2d.b2WheelJoint.prototype,"GetRevoluteJointAngle",box2d.b2WheelJoint.prototype.GetRevoluteJointAngle);box2d.b2WheelJoint.prototype.GetRevoluteJointSpeed=function(){return this.m_bodyB.m_angularVelocity-this.m_bodyA.m_angularVelocity};goog.exportProperty(box2d.b2WheelJoint.prototype,"GetRevoluteJointSpeed",box2d.b2WheelJoint.prototype.GetRevoluteJointSpeed);
+box2d.b2WheelJoint.prototype.IsMotorEnabled=function(){return this.m_enableMotor};goog.exportProperty(box2d.b2WheelJoint.prototype,"IsMotorEnabled",box2d.b2WheelJoint.prototype.IsMotorEnabled);box2d.b2WheelJoint.prototype.EnableMotor=function(a){this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_enableMotor=a};goog.exportProperty(box2d.b2WheelJoint.prototype,"EnableMotor",box2d.b2WheelJoint.prototype.EnableMotor);
+box2d.b2WheelJoint.prototype.SetMotorSpeed=function(a){this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_motorSpeed=a};goog.exportProperty(box2d.b2WheelJoint.prototype,"SetMotorSpeed",box2d.b2WheelJoint.prototype.SetMotorSpeed);box2d.b2WheelJoint.prototype.SetMaxMotorTorque=function(a){this.m_bodyA.SetAwake(!0);this.m_bodyB.SetAwake(!0);this.m_maxMotorTorque=a};goog.exportProperty(box2d.b2WheelJoint.prototype,"SetMaxMotorTorque",box2d.b2WheelJoint.prototype.SetMaxMotorTorque);
+box2d.b2WheelJoint.prototype.GetMotorTorque=function(a){return a*this.m_motorImpulse};goog.exportProperty(box2d.b2WheelJoint.prototype,"GetMotorTorque",box2d.b2WheelJoint.prototype.GetMotorTorque);
+box2d.b2WheelJoint.prototype.Dump=function(){if(box2d.DEBUG){var a=this.m_bodyA.m_islandIndex,b=this.m_bodyB.m_islandIndex;box2d.b2Log("  /*box2d.b2WheelJointDef*/ var jd = new box2d.b2WheelJointDef();\n");box2d.b2Log("  jd.bodyA = bodies[%d];\n",a);box2d.b2Log("  jd.bodyB = bodies[%d];\n",b);box2d.b2Log("  jd.collideConnected = %s;\n",this.m_collideConnected?"true":"false");box2d.b2Log("  jd.localAnchorA.Set(%.15f, %.15f);\n",this.m_localAnchorA.x,this.m_localAnchorA.y);box2d.b2Log("  jd.localAnchorB.Set(%.15f, %.15f);\n",
+this.m_localAnchorB.x,this.m_localAnchorB.y);box2d.b2Log("  jd.localAxisA.Set(%.15f, %.15f);\n",this.m_localXAxisA.x,this.m_localXAxisA.y);box2d.b2Log("  jd.enableMotor = %s;\n",this.m_enableMotor?"true":"false");box2d.b2Log("  jd.motorSpeed = %.15f;\n",this.m_motorSpeed);box2d.b2Log("  jd.maxMotorTorque = %.15f;\n",this.m_maxMotorTorque);box2d.b2Log("  jd.frequencyHz = %.15f;\n",this.m_frequencyHz);box2d.b2Log("  jd.dampingRatio = %.15f;\n",this.m_dampingRatio);box2d.b2Log("  joints[%d] = this.m_world.CreateJoint(jd);\n",
+this.m_index)}};goog.exportProperty(box2d.b2WheelJoint.prototype,"Dump",box2d.b2WheelJoint.prototype.Dump);box2d.b2Particle={};box2d.b2ParticleFlag={b2_waterParticle:0,b2_zombieParticle:2,b2_wallParticle:4,b2_springParticle:8,b2_elasticParticle:16,b2_viscousParticle:32,b2_powderParticle:64,b2_tensileParticle:128,b2_colorMixingParticle:256,b2_destructionListenerParticle:512,b2_barrierParticle:1024,b2_staticPressureParticle:2048,b2_reactiveParticle:4096,b2_repulsiveParticle:8192,b2_fixtureContactListenerParticle:16384,b2_particleContactListenerParticle:32768,b2_fixtureContactFilterParticle:65536,b2_particleContactFilterParticle:131072};
+goog.exportSymbol("box2d.b2ParticleFlag",box2d.b2ParticleFlag);goog.exportProperty(box2d.b2ParticleFlag,"b2_waterParticle",box2d.b2ParticleFlag.b2_waterParticle);goog.exportProperty(box2d.b2ParticleFlag,"b2_zombieParticle",box2d.b2ParticleFlag.b2_zombieParticle);goog.exportProperty(box2d.b2ParticleFlag,"b2_wallParticle",box2d.b2ParticleFlag.b2_wallParticle);goog.exportProperty(box2d.b2ParticleFlag,"b2_springParticle",box2d.b2ParticleFlag.b2_springParticle);
+goog.exportProperty(box2d.b2ParticleFlag,"b2_elasticParticle",box2d.b2ParticleFlag.b2_elasticParticle);goog.exportProperty(box2d.b2ParticleFlag,"b2_viscousParticle",box2d.b2ParticleFlag.b2_viscousParticle);goog.exportProperty(box2d.b2ParticleFlag,"b2_powderParticle",box2d.b2ParticleFlag.b2_powderParticle);goog.exportProperty(box2d.b2ParticleFlag,"b2_tensileParticle",box2d.b2ParticleFlag.b2_tensileParticle);goog.exportProperty(box2d.b2ParticleFlag,"b2_colorMixingParticle",box2d.b2ParticleFlag.b2_colorMixingParticle);
+goog.exportProperty(box2d.b2ParticleFlag,"b2_destructionListenerParticle",box2d.b2ParticleFlag.b2_destructionListenerParticle);goog.exportProperty(box2d.b2ParticleFlag,"b2_barrierParticle",box2d.b2ParticleFlag.b2_barrierParticle);goog.exportProperty(box2d.b2ParticleFlag,"b2_staticPressureParticle",box2d.b2ParticleFlag.b2_staticPressureParticle);goog.exportProperty(box2d.b2ParticleFlag,"b2_reactiveParticle",box2d.b2ParticleFlag.b2_reactiveParticle);
+goog.exportProperty(box2d.b2ParticleFlag,"b2_repulsiveParticle",box2d.b2ParticleFlag.b2_repulsiveParticle);goog.exportProperty(box2d.b2ParticleFlag,"b2_fixtureContactListenerParticle",box2d.b2ParticleFlag.b2_fixtureContactListenerParticle);goog.exportProperty(box2d.b2ParticleFlag,"b2_particleContactListenerParticle",box2d.b2ParticleFlag.b2_particleContactListenerParticle);goog.exportProperty(box2d.b2ParticleFlag,"b2_fixtureContactFilterParticle",box2d.b2ParticleFlag.b2_fixtureContactFilterParticle);
+goog.exportProperty(box2d.b2ParticleFlag,"b2_particleContactFilterParticle",box2d.b2ParticleFlag.b2_particleContactFilterParticle);box2d.b2ParticleColor=function(a,b,c,d){if(0!==arguments.length)if(a instanceof box2d.b2Color)this.r=0|255*a.r,this.g=0|255*a.g,this.b=0|255*a.b,this.a=0|255*a.a;else if(3<=arguments.length)this.r=0|a||0,this.g=0|b||0,this.b=0|c||0,this.a=0|d||0;else throw Error();};goog.exportSymbol("box2d.b2ParticleColor",box2d.b2ParticleColor);box2d.b2ParticleColor.prototype.r=0;
+goog.exportProperty(box2d.b2ParticleColor.prototype,"r",box2d.b2ParticleColor.prototype.r);box2d.b2ParticleColor.prototype.g=0;goog.exportProperty(box2d.b2ParticleColor.prototype,"g",box2d.b2ParticleColor.prototype.g);box2d.b2ParticleColor.prototype.b=0;goog.exportProperty(box2d.b2ParticleColor.prototype,"b",box2d.b2ParticleColor.prototype.b);box2d.b2ParticleColor.prototype.a=0;goog.exportProperty(box2d.b2ParticleColor.prototype,"a",box2d.b2ParticleColor.prototype.a);
+box2d.b2ParticleColor.prototype.IsZero=function(){return 0===this.r&&0===this.g&&0===this.b&&0===this.a};goog.exportProperty(box2d.b2ParticleColor.prototype,"IsZero",box2d.b2ParticleColor.prototype.IsZero);box2d.b2ParticleColor.prototype.GetColor=function(a){a.r=this.r/255;a.g=this.g/255;a.b=this.b/255;a.a=this.a/255;return a};goog.exportProperty(box2d.b2ParticleColor.prototype,"GetColor",box2d.b2ParticleColor.prototype.GetColor);
+box2d.b2ParticleColor.prototype.Set=function(a,b,c,d){if(a instanceof box2d.b2Color)this.SetColor(a);else if(3<=arguments.length)this.SetRGBA(a||0,b||0,c||0,d);else throw Error();};goog.exportProperty(box2d.b2ParticleColor.prototype,"Set",box2d.b2ParticleColor.prototype.Set);box2d.b2ParticleColor.prototype.SetRGBA=function(a,b,c,d){this.r=a;this.g=b;this.b=c;this.a="number"===typeof d?d:255};goog.exportProperty(box2d.b2ParticleColor.prototype,"SetRGBA",box2d.b2ParticleColor.prototype.SetRGBA);
+box2d.b2ParticleColor.prototype.SetColor=function(a){this.r=255*a.r;this.g=255*a.g;this.b=255*a.b;this.a=255*a.a};goog.exportProperty(box2d.b2ParticleColor.prototype,"SetColor",box2d.b2ParticleColor.prototype.SetColor);box2d.b2ParticleColor.prototype.Copy=function(a){this.r=a.r;this.g=a.g;this.b=a.b;this.a=a.a;return this};goog.exportProperty(box2d.b2ParticleColor.prototype,"Copy",box2d.b2ParticleColor.prototype.Copy);
+box2d.b2ParticleColor.prototype.Clone=function(){return new box2d.b2ParticleColor(this.r,this.g,this.b,this.a)};box2d.b2ParticleColor.prototype.SelfMul_0_1=function(a){this.r*=a;this.g*=a;this.b*=a;this.a*=a;return this};goog.exportProperty(box2d.b2ParticleColor.prototype,"SelfMul_0_1",box2d.b2ParticleColor.prototype.SelfMul_0_1);
+box2d.b2ParticleColor.prototype.SelfMul_0_255=function(a){a+=1;this.r=this.r*a>>box2d.b2ParticleColor.k_bitsPerComponent;this.g=this.g*a>>box2d.b2ParticleColor.k_bitsPerComponent;this.b=this.b*a>>box2d.b2ParticleColor.k_bitsPerComponent;this.a=this.a*a>>box2d.b2ParticleColor.k_bitsPerComponent;return this};goog.exportProperty(box2d.b2ParticleColor.prototype,"SelfMul_0_255",box2d.b2ParticleColor.prototype.SelfMul_0_255);box2d.b2ParticleColor.prototype.Mul_0_1=function(a,b){return b.Copy(this).SelfMul_0_1(a)};
+goog.exportProperty(box2d.b2ParticleColor.prototype,"Mul_0_1",box2d.b2ParticleColor.prototype.Mul_0_1);box2d.b2ParticleColor.prototype.Mul_0_255=function(a,b){return b.Copy(this).SelfMul_0_255(a)};goog.exportProperty(box2d.b2ParticleColor.prototype,"Mul_0_255",box2d.b2ParticleColor.prototype.Mul_0_255);box2d.b2ParticleColor.prototype.SelfAdd=function(a){this.r+=a.r;this.g+=a.g;this.b+=a.b;this.a+=a.a;return this};goog.exportProperty(box2d.b2ParticleColor.prototype,"SelfAdd",box2d.b2ParticleColor.prototype.SelfAdd);
+box2d.b2ParticleColor.prototype.Add=function(a,b){b.r=this.r+a.r;b.g=this.g+a.g;b.b=this.b+a.b;b.a=this.a+a.a;return b};goog.exportProperty(box2d.b2ParticleColor.prototype,"Add",box2d.b2ParticleColor.prototype.Add);box2d.b2ParticleColor.prototype.SelfSub=function(a){this.r-=a.r;this.g-=a.g;this.b-=a.b;this.a-=a.a;return this};goog.exportProperty(box2d.b2ParticleColor.prototype,"SelfSub",box2d.b2ParticleColor.prototype.SelfSub);
+box2d.b2ParticleColor.prototype.Sub=function(a,b){b.r=this.r-a.r;b.g=this.g-a.g;b.b=this.b-a.b;b.a=this.a-a.a;return b};goog.exportProperty(box2d.b2ParticleColor.prototype,"Sub",box2d.b2ParticleColor.prototype.Sub);box2d.b2ParticleColor.prototype.IsEqual=function(a){return this.r===a.r&&this.g===a.g&&this.b===a.b&&this.a===a.a};goog.exportProperty(box2d.b2ParticleColor.prototype,"IsEqual",box2d.b2ParticleColor.prototype.IsEqual);
+box2d.b2ParticleColor.prototype.Mix=function(a,b){box2d.b2ParticleColor.MixColors(this,a,b)};goog.exportProperty(box2d.b2ParticleColor.prototype,"Mix",box2d.b2ParticleColor.prototype.Mix);
+box2d.b2ParticleColor.MixColors=function(a,b,c){var d=c*(b.r-a.r)>>box2d.b2ParticleColor.k_bitsPerComponent,e=c*(b.g-a.g)>>box2d.b2ParticleColor.k_bitsPerComponent,f=c*(b.b-a.b)>>box2d.b2ParticleColor.k_bitsPerComponent;c=c*(b.a-a.a)>>box2d.b2ParticleColor.k_bitsPerComponent;a.r+=d;a.g+=e;a.b+=f;a.a+=c;b.r-=d;b.g-=e;b.b-=f;b.a-=c};goog.exportProperty(box2d.b2ParticleColor,"MixColors",box2d.b2ParticleColor.MixColors);box2d.B2PARTICLECOLOR_BITS_PER_COMPONENT=8;
+box2d.B2PARTICLECOLOR_MAX_VALUE=(1<<box2d.B2PARTICLECOLOR_BITS_PER_COMPONENT)-1;box2d.b2ParticleColor.k_maxValue=+box2d.B2PARTICLECOLOR_MAX_VALUE;goog.exportProperty(box2d.b2ParticleColor,"k_maxValue",box2d.b2ParticleColor.k_maxValue);box2d.b2ParticleColor.k_inverseMaxValue=1/+box2d.B2PARTICLECOLOR_MAX_VALUE;goog.exportProperty(box2d.b2ParticleColor,"k_inverseMaxValue",box2d.b2ParticleColor.k_inverseMaxValue);box2d.b2ParticleColor.k_bitsPerComponent=box2d.B2PARTICLECOLOR_BITS_PER_COMPONENT;
+goog.exportProperty(box2d.b2ParticleColor,"k_bitsPerComponent",box2d.b2ParticleColor.k_bitsPerComponent);box2d.b2ParticleColor_zero=new box2d.b2ParticleColor;box2d.b2ParticleDef=function(){this.position=box2d.b2Vec2_zero.Clone();this.velocity=box2d.b2Vec2_zero.Clone();this.color=box2d.b2ParticleColor_zero.Clone()};goog.exportSymbol("box2d.b2ParticleDef",box2d.b2ParticleDef);box2d.b2ParticleDef.prototype.flags=0;goog.exportProperty(box2d.b2ParticleDef.prototype,"flags",box2d.b2ParticleDef.prototype.flags);
+box2d.b2ParticleDef.prototype.position=null;goog.exportProperty(box2d.b2ParticleDef.prototype,"position",box2d.b2ParticleDef.prototype.position);box2d.b2ParticleDef.prototype.velocity=null;goog.exportProperty(box2d.b2ParticleDef.prototype,"velocity",box2d.b2ParticleDef.prototype.velocity);box2d.b2ParticleDef.prototype.color=null;goog.exportProperty(box2d.b2ParticleDef.prototype,"color",box2d.b2ParticleDef.prototype.color);box2d.b2ParticleDef.prototype.lifetime=0;
+goog.exportProperty(box2d.b2ParticleDef.prototype,"lifetime",box2d.b2ParticleDef.prototype.lifetime);box2d.b2ParticleDef.prototype.userData=null;goog.exportProperty(box2d.b2ParticleDef.prototype,"userData",box2d.b2ParticleDef.prototype.userData);box2d.b2ParticleDef.prototype.group=null;goog.exportProperty(box2d.b2ParticleDef.prototype,"group",box2d.b2ParticleDef.prototype.group);box2d.b2CalculateParticleIterations=function(a,b,c){return box2d.b2Clamp(Math.ceil(Math.sqrt(a/(.01*b))*c),1,8)};
+goog.exportSymbol("box2d.b2CalculateParticleIterations",box2d.b2CalculateParticleIterations);box2d.b2ParticleHandle=function(){};goog.exportSymbol("box2d.b2ParticleHandle",box2d.b2ParticleHandle);box2d.b2ParticleHandle.prototype.m_index=box2d.b2_invalidParticleIndex;box2d.b2ParticleHandle.prototype.GetIndex=function(){return this.m_index};goog.exportProperty(box2d.b2ParticleHandle.prototype,"GetIndex",box2d.b2ParticleHandle.prototype.GetIndex);
+box2d.b2ParticleHandle.prototype.SetIndex=function(a){this.m_index=a};box2d.b2ParticleGroupFlag={b2_solidParticleGroup:1,b2_rigidParticleGroup:2,b2_particleGroupCanBeEmpty:4,b2_particleGroupWillBeDestroyed:8,b2_particleGroupNeedsUpdateDepth:16};goog.exportSymbol("box2d.b2ParticleGroupFlag",box2d.b2ParticleGroupFlag);goog.exportProperty(box2d.b2ParticleGroupFlag,"b2_solidParticleGroup",box2d.b2ParticleGroupFlag.b2_solidParticleGroup);goog.exportProperty(box2d.b2ParticleGroupFlag,"b2_rigidParticleGroup",box2d.b2ParticleGroupFlag.b2_rigidParticleGroup);
+goog.exportProperty(box2d.b2ParticleGroupFlag,"b2_particleGroupCanBeEmpty",box2d.b2ParticleGroupFlag.b2_particleGroupCanBeEmpty);goog.exportProperty(box2d.b2ParticleGroupFlag,"b2_particleGroupWillBeDestroyed",box2d.b2ParticleGroupFlag.b2_particleGroupWillBeDestroyed);goog.exportProperty(box2d.b2ParticleGroupFlag,"b2_particleGroupNeedsUpdateDepth",box2d.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth);
+box2d.b2ParticleGroupFlag.b2_particleGroupInternalMask=box2d.b2ParticleGroupFlag.b2_particleGroupWillBeDestroyed|box2d.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth;box2d.b2ParticleGroupDef=function(){this.position=box2d.b2Vec2_zero.Clone();this.linearVelocity=box2d.b2Vec2_zero.Clone();this.color=box2d.b2ParticleColor_zero.Clone()};goog.exportSymbol("box2d.b2ParticleGroupDef",box2d.b2ParticleGroupDef);box2d.b2ParticleGroupDef.prototype.flags=0;
+goog.exportProperty(box2d.b2ParticleGroupDef.prototype,"flags",box2d.b2ParticleGroupDef.prototype.flags);box2d.b2ParticleGroupDef.prototype.groupFlags=0;goog.exportProperty(box2d.b2ParticleGroupDef.prototype,"groupFlags",box2d.b2ParticleGroupDef.prototype.groupFlags);box2d.b2ParticleGroupDef.prototype.position=null;goog.exportProperty(box2d.b2ParticleGroupDef.prototype,"position",box2d.b2ParticleGroupDef.prototype.position);box2d.b2ParticleGroupDef.prototype.angle=0;
+goog.exportProperty(box2d.b2ParticleGroupDef.prototype,"angle",box2d.b2ParticleGroupDef.prototype.angle);box2d.b2ParticleGroupDef.prototype.linearVelocity=null;goog.exportProperty(box2d.b2ParticleGroupDef.prototype,"linearVelocity",box2d.b2ParticleGroupDef.prototype.linearVelocity);box2d.b2ParticleGroupDef.prototype.angularVelocity=0;goog.exportProperty(box2d.b2ParticleGroupDef.prototype,"angularVelocity",box2d.b2ParticleGroupDef.prototype.angularVelocity);
+box2d.b2ParticleGroupDef.prototype.color=null;goog.exportProperty(box2d.b2ParticleGroupDef.prototype,"color",box2d.b2ParticleGroupDef.prototype.color);box2d.b2ParticleGroupDef.prototype.strength=1;goog.exportProperty(box2d.b2ParticleGroupDef.prototype,"strength",box2d.b2ParticleGroupDef.prototype.strength);box2d.b2ParticleGroupDef.prototype.shape=null;goog.exportProperty(box2d.b2ParticleGroupDef.prototype,"shape",box2d.b2ParticleGroupDef.prototype.shape);
+box2d.b2ParticleGroupDef.prototype.shapes=null;goog.exportProperty(box2d.b2ParticleGroupDef.prototype,"shapes",box2d.b2ParticleGroupDef.prototype.shapes);box2d.b2ParticleGroupDef.prototype.shapeCount=0;goog.exportProperty(box2d.b2ParticleGroupDef.prototype,"shapeCount",box2d.b2ParticleGroupDef.prototype.shapeCount);box2d.b2ParticleGroupDef.prototype.stride=0;goog.exportProperty(box2d.b2ParticleGroupDef.prototype,"stride",box2d.b2ParticleGroupDef.prototype.stride);
+box2d.b2ParticleGroupDef.prototype.particleCount=0;goog.exportProperty(box2d.b2ParticleGroupDef.prototype,"particleCount",box2d.b2ParticleGroupDef.prototype.particleCount);box2d.b2ParticleGroupDef.prototype.positionData=null;goog.exportProperty(box2d.b2ParticleGroupDef.prototype,"positionData",box2d.b2ParticleGroupDef.prototype.positionData);box2d.b2ParticleGroupDef.prototype.lifetime=0;goog.exportProperty(box2d.b2ParticleGroupDef.prototype,"lifetime",box2d.b2ParticleGroupDef.prototype.lifetime);
+box2d.b2ParticleGroupDef.prototype.userData=null;goog.exportProperty(box2d.b2ParticleGroupDef.prototype,"userData",box2d.b2ParticleGroupDef.prototype.userData);box2d.b2ParticleGroupDef.prototype.group=null;goog.exportProperty(box2d.b2ParticleGroupDef.prototype,"group",box2d.b2ParticleGroupDef.prototype.group);box2d.b2ParticleGroup=function(){this.m_center=new box2d.b2Vec2;this.m_linearVelocity=new box2d.b2Vec2;this.m_transform=new box2d.b2Transform;this.m_transform.SetIdentity()};
+goog.exportSymbol("box2d.b2ParticleGroup",box2d.b2ParticleGroup);box2d.b2ParticleGroup.prototype.m_system=null;box2d.b2ParticleGroup.prototype.m_firstIndex=0;box2d.b2ParticleGroup.prototype.m_lastIndex=0;box2d.b2ParticleGroup.prototype.m_groupFlags=0;box2d.b2ParticleGroup.prototype.m_strength=1;box2d.b2ParticleGroup.prototype.m_prev=null;box2d.b2ParticleGroup.prototype.m_next=null;box2d.b2ParticleGroup.prototype.m_timestamp=-1;box2d.b2ParticleGroup.prototype.m_mass=0;
+box2d.b2ParticleGroup.prototype.m_inertia=0;box2d.b2ParticleGroup.prototype.m_center=null;box2d.b2ParticleGroup.prototype.m_linearVelocity=null;box2d.b2ParticleGroup.prototype.m_angularVelocity=0;box2d.b2ParticleGroup.prototype.m_transform=null;box2d.b2ParticleGroup.prototype.m_userData=null;box2d.b2ParticleGroup.prototype.GetNext=function(){return this.m_next};goog.exportProperty(box2d.b2ParticleGroup.prototype,"GetNext",box2d.b2ParticleGroup.prototype.GetNext);
+box2d.b2ParticleGroup.prototype.GetParticleSystem=function(){return this.m_system};goog.exportProperty(box2d.b2ParticleGroup.prototype,"GetParticleSystem",box2d.b2ParticleGroup.prototype.GetParticleSystem);box2d.b2ParticleGroup.prototype.GetParticleCount=function(){return this.m_lastIndex-this.m_firstIndex};goog.exportProperty(box2d.b2ParticleGroup.prototype,"GetParticleCount",box2d.b2ParticleGroup.prototype.GetParticleCount);box2d.b2ParticleGroup.prototype.GetBufferIndex=function(){return this.m_firstIndex};
+goog.exportProperty(box2d.b2ParticleGroup.prototype,"GetBufferIndex",box2d.b2ParticleGroup.prototype.GetBufferIndex);box2d.b2ParticleGroup.prototype.ContainsParticle=function(a){return this.m_firstIndex<=a&&a<this.m_lastIndex};box2d.b2ParticleGroup.prototype.GetAllParticleFlags=function(){for(var a=0,b=this.m_firstIndex;b<this.m_lastIndex;b++)a|=this.m_system.m_flagsBuffer.data[b];return a};goog.exportProperty(box2d.b2ParticleGroup.prototype,"GetAllParticleFlags",box2d.b2ParticleGroup.prototype.GetAllParticleFlags);
+box2d.b2ParticleGroup.prototype.GetGroupFlags=function(){return this.m_groupFlags};goog.exportProperty(box2d.b2ParticleGroup.prototype,"GetGroupFlags",box2d.b2ParticleGroup.prototype.GetGroupFlags);box2d.b2ParticleGroup.prototype.SetGroupFlags=function(a){box2d.b2Assert(0===(a&box2d.b2ParticleGroupFlag.b2_particleGroupInternalMask));a|=this.m_groupFlags&box2d.b2ParticleGroupFlag.b2_particleGroupInternalMask;this.m_system.SetGroupFlags(this,a)};
+goog.exportProperty(box2d.b2ParticleGroup.prototype,"SetGroupFlags",box2d.b2ParticleGroup.prototype.SetGroupFlags);box2d.b2ParticleGroup.prototype.GetMass=function(){this.UpdateStatistics();return this.m_mass};goog.exportProperty(box2d.b2ParticleGroup.prototype,"GetMass",box2d.b2ParticleGroup.prototype.GetMass);box2d.b2ParticleGroup.prototype.GetInertia=function(){this.UpdateStatistics();return this.m_inertia};goog.exportProperty(box2d.b2ParticleGroup.prototype,"GetInertia",box2d.b2ParticleGroup.prototype.GetInertia);
+box2d.b2ParticleGroup.prototype.GetCenter=function(){this.UpdateStatistics();return this.m_center};goog.exportProperty(box2d.b2ParticleGroup.prototype,"GetCenter",box2d.b2ParticleGroup.prototype.GetCenter);box2d.b2ParticleGroup.prototype.GetLinearVelocity=function(){this.UpdateStatistics();return this.m_linearVelocity};goog.exportProperty(box2d.b2ParticleGroup.prototype,"GetLinearVelocity",box2d.b2ParticleGroup.prototype.GetLinearVelocity);
+box2d.b2ParticleGroup.prototype.GetAngularVelocity=function(){this.UpdateStatistics();return this.m_angularVelocity};goog.exportProperty(box2d.b2ParticleGroup.prototype,"GetAngularVelocity",box2d.b2ParticleGroup.prototype.GetAngularVelocity);box2d.b2ParticleGroup.prototype.GetTransform=function(){return this.m_transform};goog.exportProperty(box2d.b2ParticleGroup.prototype,"GetTransform",box2d.b2ParticleGroup.prototype.GetTransform);box2d.b2ParticleGroup.prototype.GetPosition=function(){return this.m_transform.p};
+goog.exportProperty(box2d.b2ParticleGroup.prototype,"GetPosition",box2d.b2ParticleGroup.prototype.GetPosition);box2d.b2ParticleGroup.prototype.GetAngle=function(){return this.m_transform.q.GetAngle()};goog.exportProperty(box2d.b2ParticleGroup.prototype,"GetAngle",box2d.b2ParticleGroup.prototype.GetAngle);
+box2d.b2ParticleGroup.prototype.GetLinearVelocityFromWorldPoint=function(a,b){var c=box2d.b2ParticleGroup.prototype.GetLinearVelocityFromWorldPoint.s_t0;this.UpdateStatistics();return box2d.b2AddCross_V2_S_V2(this.m_linearVelocity,this.m_angularVelocity,box2d.b2Sub_V2_V2(a,this.m_center,c),b)};goog.exportProperty(box2d.b2ParticleGroup.prototype,"GetLinearVelocityFromWorldPoint",box2d.b2ParticleGroup.prototype.GetLinearVelocityFromWorldPoint);
+box2d.b2ParticleGroup.prototype.GetLinearVelocityFromWorldPoint.s_t0=new box2d.b2Vec2;box2d.b2ParticleGroup.prototype.GetUserData=function(){return this.m_userData};goog.exportProperty(box2d.b2ParticleGroup.prototype,"GetUserData",box2d.b2ParticleGroup.prototype.GetUserData);box2d.b2ParticleGroup.prototype.SetUserData=function(a){this.m_userData=a};goog.exportProperty(box2d.b2ParticleGroup.prototype,"SetUserData",box2d.b2ParticleGroup.prototype.SetUserData);
+box2d.b2ParticleGroup.prototype.ApplyForce=function(a){this.m_system.ApplyForce(this.m_firstIndex,this.m_lastIndex,a)};goog.exportProperty(box2d.b2ParticleGroup.prototype,"ApplyForce",box2d.b2ParticleGroup.prototype.ApplyForce);box2d.b2ParticleGroup.prototype.ApplyLinearImpulse=function(a){this.m_system.ApplyLinearImpulse(this.m_firstIndex,this.m_lastIndex,a)};goog.exportProperty(box2d.b2ParticleGroup.prototype,"ApplyLinearImpulse",box2d.b2ParticleGroup.prototype.ApplyLinearImpulse);
+box2d.b2ParticleGroup.prototype.DestroyParticles=function(a){box2d.b2Assert(!1===this.m_system.m_world.IsLocked());if(!this.m_system.m_world.IsLocked())for(var b=this.m_firstIndex;b<this.m_lastIndex;b++)this.m_system.DestroyParticle(b,a)};goog.exportProperty(box2d.b2ParticleGroup.prototype,"DestroyParticles",box2d.b2ParticleGroup.prototype.DestroyParticles);
+box2d.b2ParticleGroup.prototype.UpdateStatistics=function(){var a=new box2d.b2Vec2,b=new box2d.b2Vec2;if(this.m_timestamp!=this.m_system.m_timestamp){var c=this.m_system.GetParticleMass();this.m_mass=c*(this.m_lastIndex-this.m_firstIndex);this.m_center.SetZero();this.m_linearVelocity.SetZero();for(var d=this.m_firstIndex;d<this.m_lastIndex;d++)this.m_center.SelfMulAdd(c,this.m_system.m_positionBuffer.data[d]),this.m_linearVelocity.SelfMulAdd(c,this.m_system.m_velocityBuffer.data[d]);0<this.m_mass&&
+(d=1/this.m_mass,this.m_center.SelfMul(d),this.m_linearVelocity.SelfMul(d));this.m_angularVelocity=this.m_inertia=0;for(d=this.m_firstIndex;d<this.m_lastIndex;d++)box2d.b2Sub_V2_V2(this.m_system.m_positionBuffer.data[d],this.m_center,a),box2d.b2Sub_V2_V2(this.m_system.m_velocityBuffer.data[d],this.m_linearVelocity,b),this.m_inertia+=c*box2d.b2Dot_V2_V2(a,a),this.m_angularVelocity+=c*box2d.b2Cross_V2_V2(a,b);0<this.m_inertia&&(this.m_angularVelocity*=1/this.m_inertia);this.m_timestamp=this.m_system.m_timestamp}};
+goog.exportProperty(box2d.b2ParticleGroup.prototype,"UpdateStatistics",box2d.b2ParticleGroup.prototype.UpdateStatistics);box2d.std_iter_swap=function(a,b,c){var d=a[b];a[b]=a[c];a[c]=d};box2d.std_sort=function(a,b,c,d){"number"!==typeof b&&(b=0);"number"!==typeof c&&(c=a.length-b);"function"!==typeof d&&(d=function(a,b){return a<b});for(var e=[],f=0;;){for(;b+1<c;c++){var g=a[b+Math.floor(Math.random()*(c-b))];e[f++]=c;for(var h=b-1;;){for(;d(a[++h],g););for(;d(g,a[--c]););if(h>=c)break;box2d.std_iter_swap(a,h,c)}}if(0===f)break;b=c;c=e[--f]}return a};
+box2d.std_stable_sort=function(a,b,c,d){return box2d.std_sort(a,b,c,d)};box2d.std_remove_if=function(a,b,c){"number"!==typeof c&&(c=a.length);for(var d=0,e=0;e<c;++e)b(a[e])||(e===d?++d:box2d.std_iter_swap(a,d++,e));return d};box2d.std_lower_bound=function(a,b,c,d,e){"function"!==typeof e&&(e=function(a,b){return a<b});for(c-=b;0<c;){var f=Math.floor(c/2),g=b+f;e(a[g],d)?(b=++g,c-=f+1):c=f}return b};
+box2d.std_upper_bound=function(a,b,c,d,e){"function"!==typeof e&&(e=function(a,b){return a<b});for(c-=b;0<c;){var f=Math.floor(c/2),g=b+f;e(d,a[g])?c=f:(b=++g,c-=f+1)}return b};box2d.std_rotate=function(a,b,c,d){for(var e=c;b!==e;)box2d.std_iter_swap(a,b++,e++),e===d?e=c:b===c&&(c=e)};box2d.std_unique=function(a,b,c,d){if(b===c)return c;for(var e=b;++b!==c;)d(a[e],a[b])||box2d.std_iter_swap(a,++e,b);return++e};
+box2d.b2GrowableBuffer=function(a){this.data=[];this.capacity=this.count=0;this.allocator=a};box2d.b2GrowableBuffer.prototype.data=null;box2d.b2GrowableBuffer.prototype.count=0;box2d.b2GrowableBuffer.prototype.capacity=0;box2d.b2GrowableBuffer.prototype.allocator=function(){return null};box2d.b2GrowableBuffer.prototype.Append=function(){this.count>=this.capacity&&this.Grow();return this.count++};
+box2d.b2GrowableBuffer.prototype.Reserve=function(a){if(!(this.capacity>=a)){box2d.b2Assert(this.capacity===this.data.length);for(var b=this.capacity;b<a;++b)this.data[b]=this.allocator();this.capacity=a}};box2d.b2GrowableBuffer.prototype.Grow=function(){var a=this.capacity?2*this.capacity:box2d.b2_minParticleSystemBufferCapacity;box2d.b2Assert(a>this.capacity);this.Reserve(a)};box2d.b2GrowableBuffer.prototype.Free=function(){0!==this.data.length&&(this.data=[],this.count=this.capacity=0)};
+box2d.b2GrowableBuffer.prototype.Shorten=function(a){box2d.b2Assert(!1)};box2d.b2GrowableBuffer.prototype.Data=function(){return this.data};box2d.b2GrowableBuffer.prototype.GetCount=function(){return this.count};box2d.b2GrowableBuffer.prototype.SetCount=function(a){box2d.b2Assert(0<=a&&a<=this.capacity);this.count=a};box2d.b2GrowableBuffer.prototype.GetCapacity=function(){return this.capacity};
+box2d.b2GrowableBuffer.prototype.RemoveIf=function(a){for(var b=0,c=0;c<this.count;++c)a(this.data[c])||b++;this.count=box2d.std_remove_if(this.data,a,this.count);box2d.b2Assert(b===this.count)};box2d.b2GrowableBuffer.prototype.Unique=function(a){this.count=box2d.std_unique(this.data,0,this.count,a)};box2d.b2FixtureParticleQueryCallback=function(a){this.m_system=a};goog.inherits(box2d.b2FixtureParticleQueryCallback,box2d.b2QueryCallback);box2d.b2FixtureParticleQueryCallback.prototype.m_system=null;
+box2d.b2FixtureParticleQueryCallback.prototype.ShouldQueryParticleSystem=function(a){return!1};box2d.b2FixtureParticleQueryCallback.prototype.ReportFixture=function(a){if(a.IsSensor())return!0;for(var b=a.GetShape().GetChildCount(),c=0;c<b;c++)for(var d=a.GetAABB(c),d=this.m_system.GetInsideBoundsEnumerator(d),e;0<=(e=d.GetNext());)this.ReportFixtureAndParticle(a,c,e);return!0};goog.exportProperty(box2d.b2FixtureParticleQueryCallback.prototype,"ReportFixture",box2d.b2FixtureParticleQueryCallback.prototype.ReportFixture);
+box2d.b2FixtureParticleQueryCallback.prototype.ReportParticle=function(a,b){return!1};goog.exportProperty(box2d.b2FixtureParticleQueryCallback.prototype,"ReportParticle",box2d.b2FixtureParticleQueryCallback.prototype.ReportParticle);box2d.b2FixtureParticleQueryCallback.prototype.ReportFixtureAndParticle=function(a,b,c){box2d.b2Assert(!1)};goog.exportProperty(box2d.b2FixtureParticleQueryCallback.prototype,"ReportFixtureAndParticle",box2d.b2FixtureParticleQueryCallback.prototype.ReportFixtureAndParticle);
+box2d.b2ParticleContact=function(){this.normal=new box2d.b2Vec2};goog.exportSymbol("box2d.b2ParticleContact",box2d.b2ParticleContact);box2d.b2ParticleContact.prototype.indexA=0;goog.exportProperty(box2d.b2ParticleContact.prototype,"indexA",box2d.b2ParticleContact.prototype.indexA);box2d.b2ParticleContact.prototype.indexB=0;goog.exportProperty(box2d.b2ParticleContact.prototype,"indexB",box2d.b2ParticleContact.prototype.indexB);box2d.b2ParticleContact.prototype.weight=0;
+goog.exportProperty(box2d.b2ParticleContact.prototype,"weight",box2d.b2ParticleContact.prototype.weight);box2d.b2ParticleContact.prototype.normal=null;goog.exportProperty(box2d.b2ParticleContact.prototype,"normal",box2d.b2ParticleContact.prototype.normal);box2d.b2ParticleContact.prototype.flags=0;goog.exportProperty(box2d.b2ParticleContact.prototype,"flags",box2d.b2ParticleContact.prototype.flags);
+box2d.b2ParticleContact.prototype.SetIndices=function(a,b){box2d.b2Assert(a<=box2d.b2_maxParticleIndex&&b<=box2d.b2_maxParticleIndex);this.indexA=a;this.indexB=b};goog.exportProperty(box2d.b2ParticleContact.prototype,"SetIndices",box2d.b2ParticleContact.prototype.SetIndices);box2d.b2ParticleContact.prototype.SetWeight=function(a){this.weight=a};goog.exportProperty(box2d.b2ParticleContact.prototype,"SetWeight",box2d.b2ParticleContact.prototype.SetWeight);
+box2d.b2ParticleContact.prototype.SetNormal=function(a){this.normal.Copy(a)};goog.exportProperty(box2d.b2ParticleContact.prototype,"SetNormal",box2d.b2ParticleContact.prototype.SetNormal);box2d.b2ParticleContact.prototype.SetFlags=function(a){this.flags=a};goog.exportProperty(box2d.b2ParticleContact.prototype,"SetFlags",box2d.b2ParticleContact.prototype.SetFlags);box2d.b2ParticleContact.prototype.GetIndexA=function(){return this.indexA};
+goog.exportProperty(box2d.b2ParticleContact.prototype,"GetIndexA",box2d.b2ParticleContact.prototype.GetIndexA);box2d.b2ParticleContact.prototype.GetIndexB=function(){return this.indexB};goog.exportProperty(box2d.b2ParticleContact.prototype,"GetIndexB",box2d.b2ParticleContact.prototype.GetIndexB);box2d.b2ParticleContact.prototype.GetWeight=function(){return this.weight};goog.exportProperty(box2d.b2ParticleContact.prototype,"GetWeight",box2d.b2ParticleContact.prototype.GetWeight);
+box2d.b2ParticleContact.prototype.GetNormal=function(){return this.normal};goog.exportProperty(box2d.b2ParticleContact.prototype,"GetNormal",box2d.b2ParticleContact.prototype.GetNormal);box2d.b2ParticleContact.prototype.GetFlags=function(){return this.flags};goog.exportProperty(box2d.b2ParticleContact.prototype,"GetFlags",box2d.b2ParticleContact.prototype.GetFlags);
+box2d.b2ParticleContact.prototype.IsEqual=function(a){return this.indexA===a.indexA&&this.indexB===a.indexB&&this.flags===a.flags&&this.weight===a.weight&&this.normal.x===a.normal.x&&this.normal.y===a.normal.y};goog.exportProperty(box2d.b2ParticleContact.prototype,"IsEqual",box2d.b2ParticleContact.prototype.IsEqual);box2d.b2ParticleContact.prototype.IsNotEqual=function(a){return!this.IsEqual(a)};goog.exportProperty(box2d.b2ParticleContact.prototype,"IsNotEqual",box2d.b2ParticleContact.prototype.IsNotEqual);
+box2d.b2ParticleContact.prototype.ApproximatelyEqual=function(a){return this.indexA===a.indexA&&this.indexB===a.indexB&&this.flags===a.flags&&.01>box2d.b2Abs(this.weight-a.weight)&&1E-4>box2d.b2DistanceSquared(this.normal,a.normal)};goog.exportProperty(box2d.b2ParticleContact.prototype,"ApproximatelyEqual",box2d.b2ParticleContact.prototype.ApproximatelyEqual);box2d.b2ParticleBodyContact=function(){this.normal=new box2d.b2Vec2};goog.exportSymbol("box2d.b2ParticleBodyContact",box2d.b2ParticleBodyContact);
+box2d.b2ParticleBodyContact.prototype.index=0;goog.exportProperty(box2d.b2ParticleBodyContact.prototype,"index",box2d.b2ParticleBodyContact.prototype.index);box2d.b2ParticleBodyContact.prototype.body=null;goog.exportProperty(box2d.b2ParticleBodyContact.prototype,"body",box2d.b2ParticleBodyContact.prototype.body);box2d.b2ParticleBodyContact.prototype.fixture=null;goog.exportProperty(box2d.b2ParticleBodyContact.prototype,"fixture",box2d.b2ParticleBodyContact.prototype.fixture);
+box2d.b2ParticleBodyContact.prototype.weight=0;goog.exportProperty(box2d.b2ParticleBodyContact.prototype,"weight",box2d.b2ParticleBodyContact.prototype.weight);box2d.b2ParticleBodyContact.prototype.normal=null;goog.exportProperty(box2d.b2ParticleBodyContact.prototype,"normal",box2d.b2ParticleBodyContact.prototype.normal);box2d.b2ParticleBodyContact.prototype.mass=0;goog.exportProperty(box2d.b2ParticleBodyContact.prototype,"mass",box2d.b2ParticleBodyContact.prototype.mass);box2d.b2ParticlePair=function(){};
+goog.exportSymbol("box2d.b2ParticlePair",box2d.b2ParticlePair);box2d.b2ParticlePair.prototype.indexA=0;goog.exportProperty(box2d.b2ParticlePair.prototype,"indexA",box2d.b2ParticlePair.prototype.indexA);box2d.b2ParticlePair.prototype.indexB=0;goog.exportProperty(box2d.b2ParticlePair.prototype,"indexB",box2d.b2ParticlePair.prototype.indexB);box2d.b2ParticlePair.prototype.flags=0;goog.exportProperty(box2d.b2ParticlePair.prototype,"flags",box2d.b2ParticlePair.prototype.flags);
+box2d.b2ParticlePair.prototype.strength=0;goog.exportProperty(box2d.b2ParticlePair.prototype,"strength",box2d.b2ParticlePair.prototype.strength);box2d.b2ParticlePair.prototype.distance=0;goog.exportProperty(box2d.b2ParticlePair.prototype,"distance",box2d.b2ParticlePair.prototype.distance);box2d.b2ParticleTriad=function(){this.pa=new box2d.b2Vec2(0,0);this.pb=new box2d.b2Vec2(0,0);this.pc=new box2d.b2Vec2(0,0)};goog.exportSymbol("box2d.b2ParticleTriad",box2d.b2ParticleTriad);
+box2d.b2ParticleTriad.prototype.indexA=0;goog.exportProperty(box2d.b2ParticleTriad.prototype,"indexA",box2d.b2ParticleTriad.prototype.indexA);box2d.b2ParticleTriad.prototype.indexB=0;goog.exportProperty(box2d.b2ParticleTriad.prototype,"indexB",box2d.b2ParticleTriad.prototype.indexB);box2d.b2ParticleTriad.prototype.indexC=0;goog.exportProperty(box2d.b2ParticleTriad.prototype,"indexC",box2d.b2ParticleTriad.prototype.indexC);box2d.b2ParticleTriad.prototype.flags=0;
+goog.exportProperty(box2d.b2ParticleTriad.prototype,"flags",box2d.b2ParticleTriad.prototype.flags);box2d.b2ParticleTriad.prototype.strength=0;goog.exportProperty(box2d.b2ParticleTriad.prototype,"strength",box2d.b2ParticleTriad.prototype.strength);box2d.b2ParticleTriad.prototype.pa=null;goog.exportProperty(box2d.b2ParticleTriad.prototype,"pa",box2d.b2ParticleTriad.prototype.pa);box2d.b2ParticleTriad.prototype.pb=null;goog.exportProperty(box2d.b2ParticleTriad.prototype,"pb",box2d.b2ParticleTriad.prototype.pb);
+box2d.b2ParticleTriad.prototype.pc=null;goog.exportProperty(box2d.b2ParticleTriad.prototype,"pc",box2d.b2ParticleTriad.prototype.pc);box2d.b2ParticleTriad.prototype.ka=0;goog.exportProperty(box2d.b2ParticleTriad.prototype,"ka",box2d.b2ParticleTriad.prototype.ka);box2d.b2ParticleTriad.prototype.kb=0;goog.exportProperty(box2d.b2ParticleTriad.prototype,"kb",box2d.b2ParticleTriad.prototype.kb);box2d.b2ParticleTriad.prototype.kc=0;goog.exportProperty(box2d.b2ParticleTriad.prototype,"kc",box2d.b2ParticleTriad.prototype.kc);
+box2d.b2ParticleTriad.prototype.s=0;goog.exportProperty(box2d.b2ParticleTriad.prototype,"s",box2d.b2ParticleTriad.prototype.s);box2d.b2ParticleSystemDef=function(){};goog.exportSymbol("box2d.b2ParticleSystemDef",box2d.b2ParticleSystemDef);box2d.b2ParticleSystemDef.prototype.strictContactCheck=!1;goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"strictContactCheck",box2d.b2ParticleSystemDef.prototype.strictContactCheck);box2d.b2ParticleSystemDef.prototype.density=1;
+goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"density",box2d.b2ParticleSystemDef.prototype.density);box2d.b2ParticleSystemDef.prototype.gravityScale=1;goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"gravityScale",box2d.b2ParticleSystemDef.prototype.gravityScale);box2d.b2ParticleSystemDef.prototype.radius=1;goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"radius",box2d.b2ParticleSystemDef.prototype.radius);box2d.b2ParticleSystemDef.prototype.maxCount=0;
+goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"maxCount",box2d.b2ParticleSystemDef.prototype.maxCount);box2d.b2ParticleSystemDef.prototype.pressureStrength=.005;goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"pressureStrength",box2d.b2ParticleSystemDef.prototype.pressureStrength);box2d.b2ParticleSystemDef.prototype.dampingStrength=1;goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"dampingStrength",box2d.b2ParticleSystemDef.prototype.dampingStrength);
+box2d.b2ParticleSystemDef.prototype.elasticStrength=.25;goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"elasticStrength",box2d.b2ParticleSystemDef.prototype.elasticStrength);box2d.b2ParticleSystemDef.prototype.springStrength=.25;goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"springStrength",box2d.b2ParticleSystemDef.prototype.springStrength);box2d.b2ParticleSystemDef.prototype.viscousStrength=.25;goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"viscousStrength",box2d.b2ParticleSystemDef.prototype.viscousStrength);
+box2d.b2ParticleSystemDef.prototype.surfaceTensionPressureStrength=.2;goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"surfaceTensionPressureStrength",box2d.b2ParticleSystemDef.prototype.surfaceTensionPressureStrength);box2d.b2ParticleSystemDef.prototype.surfaceTensionNormalStrength=.2;goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"surfaceTensionNormalStrength",box2d.b2ParticleSystemDef.prototype.surfaceTensionNormalStrength);
+box2d.b2ParticleSystemDef.prototype.repulsiveStrength=1;goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"repulsiveStrength",box2d.b2ParticleSystemDef.prototype.repulsiveStrength);box2d.b2ParticleSystemDef.prototype.powderStrength=.5;goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"powderStrength",box2d.b2ParticleSystemDef.prototype.powderStrength);box2d.b2ParticleSystemDef.prototype.ejectionStrength=.5;goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"ejectionStrength",box2d.b2ParticleSystemDef.prototype.ejectionStrength);
+box2d.b2ParticleSystemDef.prototype.staticPressureStrength=.2;goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"staticPressureStrength",box2d.b2ParticleSystemDef.prototype.staticPressureStrength);box2d.b2ParticleSystemDef.prototype.staticPressureRelaxation=.2;goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"staticPressureRelaxation",box2d.b2ParticleSystemDef.prototype.staticPressureRelaxation);box2d.b2ParticleSystemDef.prototype.staticPressureIterations=8;
+goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"staticPressureIterations",box2d.b2ParticleSystemDef.prototype.staticPressureIterations);box2d.b2ParticleSystemDef.prototype.colorMixingStrength=.5;goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"colorMixingStrength",box2d.b2ParticleSystemDef.prototype.colorMixingStrength);box2d.b2ParticleSystemDef.prototype.destroyByAge=!0;goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"destroyByAge",box2d.b2ParticleSystemDef.prototype.destroyByAge);
+box2d.b2ParticleSystemDef.prototype.lifetimeGranularity=1/60;goog.exportProperty(box2d.b2ParticleSystemDef.prototype,"lifetimeGranularity",box2d.b2ParticleSystemDef.prototype.lifetimeGranularity);
+box2d.b2ParticleSystemDef.prototype.Copy=function(a){this.strictContactCheck=a.strictContactCheck;this.density=a.density;this.gravityScale=a.gravityScale;this.radius=a.radius;this.maxCount=a.maxCount;this.pressureStrength=a.pressureStrength;this.dampingStrength=a.dampingStrength;this.elasticStrength=a.elasticStrength;this.springStrength=a.springStrength;this.viscousStrength=a.viscousStrength;this.surfaceTensionPressureStrength=a.surfaceTensionPressureStrength;this.surfaceTensionNormalStrength=a.surfaceTensionNormalStrength;
+this.repulsiveStrength=a.repulsiveStrength;this.powderStrength=a.powderStrength;this.ejectionStrength=a.ejectionStrength;this.staticPressureStrength=a.staticPressureStrength;this.staticPressureRelaxation=a.staticPressureRelaxation;this.staticPressureIterations=a.staticPressureIterations;this.colorMixingStrength=a.colorMixingStrength;this.destroyByAge=a.destroyByAge;this.lifetimeGranularity=a.lifetimeGranularity;return this};box2d.b2ParticleSystemDef.prototype.Clone=function(){return(new box2d.b2ParticleSystemDef).Copy(this)};
+box2d.b2ParticleSystem=function(a,b){this._ctor_(a,b)};goog.exportSymbol("box2d.b2ParticleSystem",box2d.b2ParticleSystem);box2d.b2ParticleSystem.prototype.m_paused=!1;box2d.b2ParticleSystem.prototype.m_timestamp=0;box2d.b2ParticleSystem.prototype.m_allParticleFlags=0;box2d.b2ParticleSystem.prototype.m_needsUpdateAllParticleFlags=!1;box2d.b2ParticleSystem.prototype.m_allGroupFlags=0;box2d.b2ParticleSystem.prototype.m_needsUpdateAllGroupFlags=!1;box2d.b2ParticleSystem.prototype.m_hasForce=!1;
+box2d.b2ParticleSystem.prototype.m_iterationIndex=0;box2d.b2ParticleSystem.prototype.m_inverseDensity=0;box2d.b2ParticleSystem.prototype.m_particleDiameter=0;box2d.b2ParticleSystem.prototype.m_inverseDiameter=0;box2d.b2ParticleSystem.prototype.m_squaredDiameter=0;box2d.b2ParticleSystem.prototype.m_count=0;box2d.b2ParticleSystem.prototype.m_internalAllocatedCapacity=0;box2d.b2ParticleSystem.prototype.m_handleAllocator=null;box2d.b2ParticleSystem.prototype.m_handleIndexBuffer=null;
+box2d.b2ParticleSystem.prototype.m_flagsBuffer=null;box2d.b2ParticleSystem.prototype.m_positionBuffer=null;box2d.b2ParticleSystem.prototype.m_velocityBuffer=null;box2d.b2ParticleSystem.prototype.m_forceBuffer=null;box2d.b2ParticleSystem.prototype.m_weightBuffer=null;box2d.b2ParticleSystem.prototype.m_staticPressureBuffer=null;box2d.b2ParticleSystem.prototype.m_accumulationBuffer=null;box2d.b2ParticleSystem.prototype.m_accumulation2Buffer=null;box2d.b2ParticleSystem.prototype.m_depthBuffer=null;
+box2d.b2ParticleSystem.prototype.m_colorBuffer=null;box2d.b2ParticleSystem.prototype.m_groupBuffer=null;box2d.b2ParticleSystem.prototype.m_userDataBuffer=null;box2d.b2ParticleSystem.prototype.m_stuckThreshold=0;box2d.b2ParticleSystem.prototype.m_lastBodyContactStepBuffer=null;box2d.b2ParticleSystem.prototype.m_bodyContactCountBuffer=null;box2d.b2ParticleSystem.prototype.m_consecutiveContactStepsBuffer=null;box2d.b2ParticleSystem.prototype.m_stuckParticleBuffer=null;
+box2d.b2ParticleSystem.prototype.m_proxyBuffer=null;box2d.b2ParticleSystem.prototype.m_contactBuffer=null;box2d.b2ParticleSystem.prototype.m_bodyContactBuffer=null;box2d.b2ParticleSystem.prototype.m_pairBuffer=null;box2d.b2ParticleSystem.prototype.m_triadBuffer=null;box2d.b2ParticleSystem.prototype.m_expirationTimeBuffer=null;box2d.b2ParticleSystem.prototype.m_indexByExpirationTimeBuffer=null;box2d.b2ParticleSystem.prototype.m_timeElapsed=0;
+box2d.b2ParticleSystem.prototype.m_expirationTimeBufferRequiresSorting=!1;box2d.b2ParticleSystem.prototype.m_groupCount=0;box2d.b2ParticleSystem.prototype.m_groupList=null;box2d.b2ParticleSystem.prototype.m_def=null;box2d.b2ParticleSystem.prototype.m_world=null;box2d.b2ParticleSystem.prototype.m_prev=null;box2d.b2ParticleSystem.prototype.m_next=null;box2d.b2ParticleSystem.xTruncBits=12;box2d.b2ParticleSystem.yTruncBits=12;box2d.b2ParticleSystem.tagBits=32;
+box2d.b2ParticleSystem.yOffset=1<<box2d.b2ParticleSystem.yTruncBits-1;box2d.b2ParticleSystem.yShift=box2d.b2ParticleSystem.tagBits-box2d.b2ParticleSystem.yTruncBits;box2d.b2ParticleSystem.xShift=box2d.b2ParticleSystem.tagBits-box2d.b2ParticleSystem.yTruncBits-box2d.b2ParticleSystem.xTruncBits;box2d.b2ParticleSystem.xScale=1<<box2d.b2ParticleSystem.xShift;box2d.b2ParticleSystem.xOffset=box2d.b2ParticleSystem.xScale*(1<<box2d.b2ParticleSystem.xTruncBits-1);
+box2d.b2ParticleSystem.yMask=(1<<box2d.b2ParticleSystem.yTruncBits)-1<<box2d.b2ParticleSystem.yShift;box2d.b2ParticleSystem.xMask=~box2d.b2ParticleSystem.yMask;box2d.b2ParticleSystem.computeTag=function(a,b){return(b+box2d.b2ParticleSystem.yOffset>>>0<<box2d.b2ParticleSystem.yShift)+(box2d.b2ParticleSystem.xScale*a+box2d.b2ParticleSystem.xOffset>>>0)>>>0};box2d.b2ParticleSystem.computeRelativeTag=function(a,b,c){return a+(c<<box2d.b2ParticleSystem.yShift)+(b<<box2d.b2ParticleSystem.xShift)>>>0};
+box2d.b2ParticleSystem.FixedSetAllocator=function(){};box2d.b2ParticleSystem.FixedSetAllocator.prototype.Invalidate=function(a){};box2d.b2ParticleSystem.FixtureParticle=function(a,b){this.first=a;this.second=b};box2d.b2ParticleSystem.FixtureParticle.prototype.first=null;box2d.b2ParticleSystem.FixtureParticle.prototype.second=box2d.b2_invalidParticleIndex;box2d.b2ParticleSystem.FixtureParticleSet=function(){};goog.inherits(box2d.b2ParticleSystem.FixtureParticleSet,box2d.b2ParticleSystem.FixedSetAllocator);
+box2d.b2ParticleSystem.FixtureParticleSet.prototype.Initialize=function(a,b){};box2d.b2ParticleSystem.FixtureParticleSet.prototype.Find=function(a){};box2d.b2ParticleSystem.ParticlePair=function(a,b){};box2d.b2ParticleSystem.ParticlePair.prototype.first=box2d.b2_invalidParticleIndex;box2d.b2ParticleSystem.ParticlePair.prototype.second=box2d.b2_invalidParticleIndex;box2d.b2ParticleSystem.b2ParticlePairSet=function(){};goog.inherits(box2d.b2ParticleSystem.b2ParticlePairSet,box2d.b2ParticleSystem.FixedSetAllocator);
+box2d.b2ParticleSystem.b2ParticlePairSet.prototype.Initialize=function(a,b){};box2d.b2ParticleSystem.b2ParticlePairSet.prototype.Find=function(a){};box2d.b2ParticleSystem.ConnectionFilter=function(){};box2d.b2ParticleSystem.ConnectionFilter.prototype.IsNecessary=function(a){return!0};box2d.b2ParticleSystem.ConnectionFilter.prototype.ShouldCreatePair=function(a,b){return!0};box2d.b2ParticleSystem.ConnectionFilter.prototype.ShouldCreateTriad=function(a,b,c){return!0};
+box2d.b2ParticleSystem.prototype._ctor_=function(a,b){this.m_handleIndexBuffer=new box2d.b2ParticleSystem.UserOverridableBuffer;this.m_flagsBuffer=new box2d.b2ParticleSystem.UserOverridableBuffer;this.m_positionBuffer=new box2d.b2ParticleSystem.UserOverridableBuffer;this.m_velocityBuffer=new box2d.b2ParticleSystem.UserOverridableBuffer;this.m_forceBuffer=[];this.m_weightBuffer=[];this.m_staticPressureBuffer=[];this.m_accumulationBuffer=[];this.m_accumulation2Buffer=[];this.m_depthBuffer=[];this.m_colorBuffer=
+new box2d.b2ParticleSystem.UserOverridableBuffer;this.m_groupBuffer=[];this.m_userDataBuffer=new box2d.b2ParticleSystem.UserOverridableBuffer;this.m_lastBodyContactStepBuffer=new box2d.b2ParticleSystem.UserOverridableBuffer;this.m_bodyContactCountBuffer=new box2d.b2ParticleSystem.UserOverridableBuffer;this.m_consecutiveContactStepsBuffer=new box2d.b2ParticleSystem.UserOverridableBuffer;this.m_stuckParticleBuffer=new box2d.b2GrowableBuffer(function(){return 0});this.m_proxyBuffer=new box2d.b2GrowableBuffer(function(){return new box2d.b2ParticleSystem.Proxy});
+this.m_contactBuffer=new box2d.b2GrowableBuffer(function(){return new box2d.b2ParticleContact});this.m_bodyContactBuffer=new box2d.b2GrowableBuffer(function(){return new box2d.b2ParticleBodyContact});this.m_pairBuffer=new box2d.b2GrowableBuffer(function(){return new box2d.b2ParticlePair});this.m_triadBuffer=new box2d.b2GrowableBuffer(function(){return new box2d.b2ParticleTriad});this.m_expirationTimeBuffer=new box2d.b2ParticleSystem.UserOverridableBuffer;this.m_indexByExpirationTimeBuffer=new box2d.b2ParticleSystem.UserOverridableBuffer;
+this.m_def=new box2d.b2ParticleSystemDef;box2d.b2Assert(null!==a);this.SetStrictContactCheck(a.strictContactCheck);this.SetDensity(a.density);this.SetGravityScale(a.gravityScale);this.SetRadius(a.radius);this.SetMaxParticleCount(a.maxCount);box2d.b2Assert(0<a.lifetimeGranularity);this.m_def=a.Clone();this.m_world=b;this.SetDestructionByAge(this.m_def.destroyByAge)};
+box2d.b2ParticleSystem.prototype._dtor_=function(){for(;this.m_groupList;)this.DestroyParticleGroup(this.m_groupList);this.FreeUserOverridableBuffer(this.m_handleIndexBuffer);this.FreeUserOverridableBuffer(this.m_flagsBuffer);this.FreeUserOverridableBuffer(this.m_lastBodyContactStepBuffer);this.FreeUserOverridableBuffer(this.m_bodyContactCountBuffer);this.FreeUserOverridableBuffer(this.m_consecutiveContactStepsBuffer);this.FreeUserOverridableBuffer(this.m_positionBuffer);this.FreeUserOverridableBuffer(this.m_velocityBuffer);
+this.FreeUserOverridableBuffer(this.m_colorBuffer);this.FreeUserOverridableBuffer(this.m_userDataBuffer);this.FreeUserOverridableBuffer(this.m_expirationTimeBuffer);this.FreeUserOverridableBuffer(this.m_indexByExpirationTimeBuffer);this.FreeBuffer(this.m_forceBuffer,this.m_internalAllocatedCapacity);this.FreeBuffer(this.m_weightBuffer,this.m_internalAllocatedCapacity);this.FreeBuffer(this.m_staticPressureBuffer,this.m_internalAllocatedCapacity);this.FreeBuffer(this.m_accumulationBuffer,this.m_internalAllocatedCapacity);
+this.FreeBuffer(this.m_accumulation2Buffer,this.m_internalAllocatedCapacity);this.FreeBuffer(this.m_depthBuffer,this.m_internalAllocatedCapacity);this.FreeBuffer(this.m_groupBuffer,this.m_internalAllocatedCapacity)};box2d.b2ParticleSystem.prototype.Drop=function(){this._dtor_()};
+box2d.b2ParticleSystem.prototype.CreateParticle=function(a){box2d.b2Assert(!1===this.m_world.IsLocked());if(this.m_world.IsLocked())return 0;this.m_count>=this.m_internalAllocatedCapacity&&this.ReallocateInternalAllocatedBuffers(this.m_count?2*this.m_count:box2d.b2_minParticleSystemBufferCapacity);if(this.m_count>=this.m_internalAllocatedCapacity)if(this.m_def.destroyByAge)this.DestroyOldestParticle(0,!1),this.SolveZombie();else return box2d.b2_invalidParticleIndex;var b=this.m_count++;this.m_flagsBuffer.data[b]=
+0;this.m_lastBodyContactStepBuffer.data&&(this.m_lastBodyContactStepBuffer.data[b]=0);this.m_bodyContactCountBuffer.data&&(this.m_bodyContactCountBuffer.data[b]=0);this.m_consecutiveContactStepsBuffer.data&&(this.m_consecutiveContactStepsBuffer.data[b]=0);this.m_positionBuffer.data[b]=(this.m_positionBuffer.data[b]||new box2d.b2Vec2).Copy(a.position);this.m_velocityBuffer.data[b]=(this.m_velocityBuffer.data[b]||new box2d.b2Vec2).Copy(a.velocity);this.m_weightBuffer[b]=0;this.m_forceBuffer[b]=(this.m_forceBuffer[b]||
+new box2d.b2Vec2).SetZero();this.m_staticPressureBuffer&&(this.m_staticPressureBuffer[b]=0);this.m_depthBuffer&&(this.m_depthBuffer[b]=0);if(this.m_colorBuffer.data||!a.color.IsZero())this.m_colorBuffer.data=this.RequestBuffer(this.m_colorBuffer.data),this.m_colorBuffer.data[b]=(this.m_colorBuffer.data[b]||new box2d.b2ParticleColor).Copy(a.color);if(this.m_userDataBuffer.data||a.userData)this.m_userDataBuffer.data=this.RequestBuffer(this.m_userDataBuffer.data),this.m_userDataBuffer.data[b]=a.userData;
+this.m_handleIndexBuffer.data&&(this.m_handleIndexBuffer.data[b]=null);var c=this.m_proxyBuffer.data[this.m_proxyBuffer.Append()],d=0<a.lifetime;if(this.m_expirationTimeBuffer.data||d)this.SetParticleLifetime(b,d?a.lifetime:this.ExpirationTimeToLifetime(-this.GetQuantizedTimeElapsed())),this.m_indexByExpirationTimeBuffer.data[b]=b;c.index=b;c=a.group;if(this.m_groupBuffer[b]=c)c.m_firstIndex<c.m_lastIndex?(this.RotateBuffer(c.m_firstIndex,c.m_lastIndex,b),box2d.b2Assert(c.m_lastIndex===b)):c.m_firstIndex=
+b,c.m_lastIndex=b+1;this.SetParticleFlags(b,a.flags);return b};goog.exportProperty(box2d.b2ParticleSystem.prototype,"CreateParticle",box2d.b2ParticleSystem.prototype.CreateParticle);
+box2d.b2ParticleSystem.prototype.GetParticleHandleFromIndex=function(a){box2d.b2Assert(0<=a&&a<this.GetParticleCount()&&a!==box2d.b2_invalidParticleIndex);this.m_handleIndexBuffer.data=this.RequestBuffer(this.m_handleIndexBuffer.data);var b=this.m_handleIndexBuffer.data[a];if(b)return b;b=new box2d.b2ParticleHandle;box2d.b2Assert(null!==b);b.SetIndex(a);return this.m_handleIndexBuffer.data[a]=b};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetParticleHandleFromIndex",box2d.b2ParticleSystem.prototype.GetParticleHandleFromIndex);
+box2d.b2ParticleSystem.prototype.DestroyParticle=function(a,b){var c=box2d.b2ParticleFlag.b2_zombieParticle;b&&(c|=box2d.b2ParticleFlag.b2_destructionListenerParticle);this.SetParticleFlags(a,this.m_flagsBuffer.data[a]|c)};goog.exportProperty(box2d.b2ParticleSystem.prototype,"DestroyParticle",box2d.b2ParticleSystem.prototype.DestroyParticle);
+box2d.b2ParticleSystem.prototype.DestroyOldestParticle=function(a,b){var c=this.GetParticleCount();box2d.b2Assert(0<=a&&a<c);box2d.b2Assert(null!==this.m_indexByExpirationTimeBuffer.data);var c=this.m_indexByExpirationTimeBuffer.data[c-(a+1)],d=this.m_indexByExpirationTimeBuffer.data[a];this.DestroyParticle(0<this.m_expirationTimeBuffer.data[c]?c:d,b)};
+box2d.b2ParticleSystem.DestroyParticlesInShapeCallback=function(a,b,c,d){this.m_system=a;this.m_shape=b;this.m_xf=c;this.m_callDestructionListener=d;this.m_destroyed=0};goog.inherits(box2d.b2ParticleSystem.DestroyParticlesInShapeCallback,box2d.b2QueryCallback);box2d.b2ParticleSystem.DestroyParticlesInShapeCallback.prototype.m_system=null;box2d.b2ParticleSystem.DestroyParticlesInShapeCallback.prototype.m_shape=null;box2d.b2ParticleSystem.DestroyParticlesInShapeCallback.prototype.m_xf=null;
+box2d.b2ParticleSystem.DestroyParticlesInShapeCallback.prototype.m_callDestructionListener=!1;box2d.b2ParticleSystem.DestroyParticlesInShapeCallback.prototype.m_destroyed=0;box2d.b2ParticleSystem.DestroyParticlesInShapeCallback.prototype.ReportFixture=function(a){return!1};
+box2d.b2ParticleSystem.DestroyParticlesInShapeCallback.prototype.ReportParticle=function(a,b){if(a!==this.m_system)return!1;box2d.b2Assert(0<=b&&b<this.m_system.m_count);this.m_shape.TestPoint(this.m_xf,this.m_system.m_positionBuffer.data[b])&&(this.m_system.DestroyParticle(b,this.m_callDestructionListener),this.m_destroyed++);return!0};box2d.b2ParticleSystem.DestroyParticlesInShapeCallback.prototype.Destroyed=function(){return this.m_destroyed};
+box2d.b2ParticleSystem.prototype.DestroyParticlesInShape=function(a,b,c){var d=box2d.b2ParticleSystem.prototype.DestroyParticlesInShape.s_aabb;box2d.b2Assert(!1===this.m_world.IsLocked());if(this.m_world.IsLocked())return 0;c=new box2d.b2ParticleSystem.DestroyParticlesInShapeCallback(this,a,b,c);a.ComputeAABB(d,b,0);this.m_world.QueryAABB(c,d);return c.Destroyed()};goog.exportProperty(box2d.b2ParticleSystem.prototype,"DestroyParticlesInShape",box2d.b2ParticleSystem.prototype.DestroyParticlesInShape);
+box2d.b2ParticleSystem.prototype.DestroyParticlesInShape.s_aabb=new box2d.b2AABB;
+box2d.b2ParticleSystem.prototype.CreateParticleGroup=function(a){var b=box2d.b2ParticleSystem.prototype.CreateParticleGroup.s_transform;box2d.b2Assert(!1===this.m_world.IsLocked());if(this.m_world.IsLocked())return null;b.Set(a.position,a.angle);var c=this.m_count;a.shape&&this.CreateParticlesWithShapeForGroup(a.shape,a,b);a.shapes&&this.CreateParticlesWithShapesForGroup(a.shapes,a.shapeCount,a,b);if(a.particleCount){box2d.b2Assert(null!==a.positionData);for(var d=0;d<a.particleCount;d++)this.CreateParticleForGroup(a,
+b,a.positionData[d])}var e=this.m_count,f=new box2d.b2ParticleGroup;f.m_system=this;f.m_firstIndex=c;f.m_lastIndex=e;f.m_strength=a.strength;f.m_userData=a.userData;f.m_transform.Copy(b);f.m_prev=null;if(f.m_next=this.m_groupList)this.m_groupList.m_prev=f;this.m_groupList=f;++this.m_groupCount;for(d=c;d<e;d++)this.m_groupBuffer[d]=f;this.SetGroupFlags(f,a.groupFlags);b=new box2d.b2ParticleSystem.ConnectionFilter;this.UpdateContacts(!0);this.UpdatePairsAndTriads(c,e,b);a.group&&(this.JoinParticleGroups(a.group,
+f),f=a.group);return f};goog.exportProperty(box2d.b2ParticleSystem.prototype,"CreateParticleGroup",box2d.b2ParticleSystem.prototype.CreateParticleGroup);box2d.b2ParticleSystem.prototype.CreateParticleGroup.s_transform=new box2d.b2Transform;box2d.b2ParticleSystem.JoinParticleGroupsFilter=function(a){this.m_threshold=a};goog.inherits(box2d.b2ParticleSystem.JoinParticleGroupsFilter,box2d.b2ParticleSystem.ConnectionFilter);box2d.b2ParticleSystem.JoinParticleGroupsFilter.prototype.m_threshold=0;
+box2d.b2ParticleSystem.JoinParticleGroupsFilter.prototype.ShouldCreatePair=function(a,b){return a<this.m_threshold&&this.m_threshold<=b||b<this.m_threshold&&this.m_threshold<=a};box2d.b2ParticleSystem.JoinParticleGroupsFilter.prototype.ShouldCreateTriad=function(a,b,c){return(a<this.m_threshold||b<this.m_threshold||c<this.m_threshold)&&(this.m_threshold<=a||this.m_threshold<=b||this.m_threshold<=c)};
+box2d.b2ParticleSystem.prototype.JoinParticleGroups=function(a,b){box2d.b2Assert(!1===this.m_world.IsLocked());if(!this.m_world.IsLocked()){box2d.b2Assert(a!==b);this.RotateBuffer(b.m_firstIndex,b.m_lastIndex,this.m_count);box2d.b2Assert(b.m_lastIndex===this.m_count);this.RotateBuffer(a.m_firstIndex,a.m_lastIndex,b.m_firstIndex);box2d.b2Assert(a.m_lastIndex===b.m_firstIndex);var c=new box2d.b2ParticleSystem.JoinParticleGroupsFilter(b.m_firstIndex);this.UpdateContacts(!0);this.UpdatePairsAndTriads(a.m_firstIndex,
+b.m_lastIndex,c);for(c=b.m_firstIndex;c<b.m_lastIndex;c++)this.m_groupBuffer[c]=a;this.SetGroupFlags(a,a.m_groupFlags|b.m_groupFlags);a.m_lastIndex=b.m_lastIndex;b.m_firstIndex=b.m_lastIndex;this.DestroyParticleGroup(b)}};goog.exportProperty(box2d.b2ParticleSystem.prototype,"JoinParticleGroups",box2d.b2ParticleSystem.prototype.JoinParticleGroups);
+box2d.b2ParticleSystem.prototype.SplitParticleGroup=function(a){this.UpdateContacts(!0);var b=a.GetParticleCount(),b=box2d.b2MakeArray(b,function(a){return new box2d.b2ParticleSystem.ParticleListNode});box2d.b2ParticleSystem.InitializeParticleLists(a,b);this.MergeParticleListsInContact(a,b);var c=box2d.b2ParticleSystem.FindLongestParticleList(a,b);this.MergeZombieParticleListNodes(a,b,c);this.CreateParticleGroupsFromParticleList(a,b,c);this.UpdatePairsAndTriadsWithParticleList(a,b)};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"SplitParticleGroup",box2d.b2ParticleSystem.prototype.SplitParticleGroup);box2d.b2ParticleSystem.prototype.GetParticleGroupList=function(){return this.m_groupList};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetParticleGroupList",box2d.b2ParticleSystem.prototype.GetParticleGroupList);box2d.b2ParticleSystem.prototype.GetParticleGroupCount=function(){return this.m_groupCount};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetParticleGroupCount",box2d.b2ParticleSystem.prototype.GetParticleGroupCount);box2d.b2ParticleSystem.prototype.GetParticleCount=function(){return this.m_count};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetParticleCount",box2d.b2ParticleSystem.prototype.GetParticleCount);box2d.b2ParticleSystem.prototype.GetMaxParticleCount=function(){return this.m_def.maxCount};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetMaxParticleCount",box2d.b2ParticleSystem.prototype.GetMaxParticleCount);box2d.b2ParticleSystem.prototype.SetMaxParticleCount=function(a){box2d.b2Assert(this.m_count<=a);this.m_def.maxCount=a};goog.exportProperty(box2d.b2ParticleSystem.prototype,"SetMaxParticleCount",box2d.b2ParticleSystem.prototype.SetMaxParticleCount);box2d.b2ParticleSystem.prototype.GetAllParticleFlags=function(){return this.m_allParticleFlags};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetAllParticleFlags",box2d.b2ParticleSystem.prototype.GetAllParticleFlags);box2d.b2ParticleSystem.prototype.GetAllGroupFlags=function(){return this.m_allGroupFlags};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetAllGroupFlags",box2d.b2ParticleSystem.prototype.GetAllGroupFlags);box2d.b2ParticleSystem.prototype.SetPaused=function(a){this.m_paused=a};goog.exportProperty(box2d.b2ParticleSystem.prototype,"SetPaused",box2d.b2ParticleSystem.prototype.SetPaused);
+box2d.b2ParticleSystem.prototype.GetPaused=function(){return this.m_paused};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetPaused",box2d.b2ParticleSystem.prototype.GetPaused);box2d.b2ParticleSystem.prototype.SetDensity=function(a){this.m_def.density=a;this.m_inverseDensity=1/this.m_def.density};goog.exportProperty(box2d.b2ParticleSystem.prototype,"SetDensity",box2d.b2ParticleSystem.prototype.SetDensity);box2d.b2ParticleSystem.prototype.GetDensity=function(){return this.m_def.density};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetDensity",box2d.b2ParticleSystem.prototype.GetDensity);box2d.b2ParticleSystem.prototype.SetGravityScale=function(a){this.m_def.gravityScale=a};goog.exportProperty(box2d.b2ParticleSystem.prototype,"SetGravityScale",box2d.b2ParticleSystem.prototype.SetGravityScale);box2d.b2ParticleSystem.prototype.GetGravityScale=function(){return this.m_def.gravityScale};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetGravityScale",box2d.b2ParticleSystem.prototype.GetGravityScale);
+box2d.b2ParticleSystem.prototype.SetDamping=function(a){this.m_def.dampingStrength=a};goog.exportProperty(box2d.b2ParticleSystem.prototype,"SetDamping",box2d.b2ParticleSystem.prototype.SetDamping);box2d.b2ParticleSystem.prototype.GetDamping=function(){return this.m_def.dampingStrength};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetDamping",box2d.b2ParticleSystem.prototype.GetDamping);
+box2d.b2ParticleSystem.prototype.SetStaticPressureIterations=function(a){this.m_def.staticPressureIterations=a};goog.exportProperty(box2d.b2ParticleSystem.prototype,"SetStaticPressureIterations",box2d.b2ParticleSystem.prototype.SetStaticPressureIterations);box2d.b2ParticleSystem.prototype.GetStaticPressureIterations=function(){return this.m_def.staticPressureIterations};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetStaticPressureIterations",box2d.b2ParticleSystem.prototype.GetStaticPressureIterations);
+box2d.b2ParticleSystem.prototype.SetRadius=function(a){this.m_particleDiameter=2*a;this.m_squaredDiameter=this.m_particleDiameter*this.m_particleDiameter;this.m_inverseDiameter=1/this.m_particleDiameter};goog.exportProperty(box2d.b2ParticleSystem.prototype,"SetRadius",box2d.b2ParticleSystem.prototype.SetRadius);box2d.b2ParticleSystem.prototype.GetRadius=function(){return this.m_particleDiameter/2};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetRadius",box2d.b2ParticleSystem.prototype.GetRadius);
+box2d.b2ParticleSystem.prototype.GetPositionBuffer=function(){return this.m_positionBuffer.data};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetPositionBuffer",box2d.b2ParticleSystem.prototype.GetPositionBuffer);box2d.b2ParticleSystem.prototype.GetVelocityBuffer=function(){return this.m_velocityBuffer.data};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetVelocityBuffer",box2d.b2ParticleSystem.prototype.GetVelocityBuffer);
+box2d.b2ParticleSystem.prototype.GetColorBuffer=function(){this.m_colorBuffer.data=this.RequestBuffer(this.m_colorBuffer.data);return this.m_colorBuffer.data};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetColorBuffer",box2d.b2ParticleSystem.prototype.GetColorBuffer);box2d.b2ParticleSystem.prototype.GetGroupBuffer=function(){return this.m_groupBuffer};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetGroupBuffer",box2d.b2ParticleSystem.prototype.GetGroupBuffer);
+box2d.b2ParticleSystem.prototype.GetWeightBuffer=function(){return this.m_weightBuffer};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetWeightBuffer",box2d.b2ParticleSystem.prototype.GetWeightBuffer);box2d.b2ParticleSystem.prototype.GetUserDataBuffer=function(){this.m_userDataBuffer.data=this.RequestBuffer(this.m_userDataBuffer.data);return this.m_userDataBuffer.data};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetUserDataBuffer",box2d.b2ParticleSystem.prototype.GetUserDataBuffer);
+box2d.b2ParticleSystem.prototype.GetFlagsBuffer=function(){return this.m_flagsBuffer.data};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetFlagsBuffer",box2d.b2ParticleSystem.prototype.GetFlagsBuffer);
+box2d.b2ParticleSystem.prototype.SetParticleFlags=function(a,b){this.m_flagsBuffer.data[a]&~b&&(this.m_needsUpdateAllParticleFlags=!0);~this.m_allParticleFlags&b&&(b&box2d.b2ParticleFlag.b2_tensileParticle&&(this.m_accumulation2Buffer=this.RequestBuffer(this.m_accumulation2Buffer)),b&box2d.b2ParticleFlag.b2_colorMixingParticle&&(this.m_colorBuffer.data=this.RequestBuffer(this.m_colorBuffer.data)),this.m_allParticleFlags|=b);this.m_flagsBuffer.data[a]=b};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"SetParticleFlags",box2d.b2ParticleSystem.prototype.SetParticleFlags);box2d.b2ParticleSystem.prototype.GetParticleFlags=function(a){return this.m_flagsBuffer.data[a]};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetParticleFlags",box2d.b2ParticleSystem.prototype.GetParticleFlags);box2d.b2ParticleSystem.prototype.SetFlagsBuffer=function(a,b){this.SetUserOverridableBuffer(this.m_flagsBuffer,a,b)};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"SetFlagsBuffer",box2d.b2ParticleSystem.prototype.SetFlagsBuffer);box2d.b2ParticleSystem.prototype.SetPositionBuffer=function(a,b){this.SetUserOverridableBuffer(this.m_positionBuffer,a,b)};goog.exportProperty(box2d.b2ParticleSystem.prototype,"SetPositionBuffer",box2d.b2ParticleSystem.prototype.SetPositionBuffer);box2d.b2ParticleSystem.prototype.SetVelocityBuffer=function(a,b){this.SetUserOverridableBuffer(this.m_velocityBuffer,a,b)};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"SetVelocityBuffer",box2d.b2ParticleSystem.prototype.SetVelocityBuffer);box2d.b2ParticleSystem.prototype.SetColorBuffer=function(a,b){this.SetUserOverridableBuffer(this.m_colorBuffer,a,b)};goog.exportProperty(box2d.b2ParticleSystem.prototype,"SetColorBuffer",box2d.b2ParticleSystem.prototype.SetColorBuffer);box2d.b2ParticleSystem.prototype.SetUserDataBuffer=function(a,b){this.SetUserOverridableBuffer(this.m_userDataBuffer,a,b)};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"SetUserDataBuffer",box2d.b2ParticleSystem.prototype.SetUserDataBuffer);box2d.b2ParticleSystem.prototype.GetContacts=function(){return this.m_contactBuffer.data};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetContacts",box2d.b2ParticleSystem.prototype.GetContacts);box2d.b2ParticleSystem.prototype.GetContactCount=function(){return this.m_contactBuffer.count};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetContactCount",box2d.b2ParticleSystem.prototype.GetContactCount);
+box2d.b2ParticleSystem.prototype.GetBodyContacts=function(){return this.m_bodyContactBuffer.data};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetBodyContacts",box2d.b2ParticleSystem.prototype.GetBodyContacts);box2d.b2ParticleSystem.prototype.GetBodyContactCount=function(){return this.m_bodyContactBuffer.count};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetBodyContactCount",box2d.b2ParticleSystem.prototype.GetBodyContactCount);box2d.b2ParticleSystem.prototype.GetPairs=function(){return this.m_pairBuffer.data};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetPairs",box2d.b2ParticleSystem.prototype.GetPairs);box2d.b2ParticleSystem.prototype.GetPairCount=function(){return this.m_pairBuffer.count};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetPairCount",box2d.b2ParticleSystem.prototype.GetPairCount);box2d.b2ParticleSystem.prototype.GetTriads=function(){return this.m_triadBuffer.data};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetTriads",box2d.b2ParticleSystem.prototype.GetTriads);
+box2d.b2ParticleSystem.prototype.GetTriadCount=function(){return this.m_triadBuffer.count};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetTriadCount",box2d.b2ParticleSystem.prototype.GetTriadCount);
+box2d.b2ParticleSystem.prototype.SetStuckThreshold=function(a){this.m_stuckThreshold=a;0<a&&(this.m_lastBodyContactStepBuffer.data=this.RequestBuffer(this.m_lastBodyContactStepBuffer.data),this.m_bodyContactCountBuffer.data=this.RequestBuffer(this.m_bodyContactCountBuffer.data),this.m_consecutiveContactStepsBuffer.data=this.RequestBuffer(this.m_consecutiveContactStepsBuffer.data))};box2d.b2ParticleSystem.prototype.GetStuckCandidates=function(){return this.m_stuckParticleBuffer.Data()};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetStuckCandidates",box2d.b2ParticleSystem.prototype.GetStuckCandidates);box2d.b2ParticleSystem.prototype.GetStuckCandidateCount=function(){return this.m_stuckParticleBuffer.GetCount()};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetStuckCandidateCount",box2d.b2ParticleSystem.prototype.GetStuckCandidateCount);
+box2d.b2ParticleSystem.prototype.ComputeCollisionEnergy=function(){for(var a=box2d.b2ParticleSystem.prototype.ComputeCollisionEnergy.s_v,b=this.m_velocityBuffer.data,c=0,d=0;d<this.m_contactBuffer.count;d++){var e=this.m_contactBuffer.data[d],f=e.normal,e=box2d.b2Sub_V2_V2(b[e.indexB],b[e.indexA],a),f=box2d.b2Dot_V2_V2(e,f);0>f&&(c+=f*f)}return.5*this.GetParticleMass()*c};goog.exportProperty(box2d.b2ParticleSystem.prototype,"ComputeCollisionEnergy",box2d.b2ParticleSystem.prototype.ComputeCollisionEnergy);
+box2d.b2ParticleSystem.prototype.ComputeCollisionEnergy.s_v=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SetStrictContactCheck=function(a){this.m_def.strictContactCheck=a};goog.exportProperty(box2d.b2ParticleSystem.prototype,"SetStrictContactCheck",box2d.b2ParticleSystem.prototype.SetStrictContactCheck);box2d.b2ParticleSystem.prototype.GetStrictContactCheck=function(){return this.m_def.strictContactCheck};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetStrictContactCheck",box2d.b2ParticleSystem.prototype.GetStrictContactCheck);
+box2d.b2ParticleSystem.prototype.SetParticleLifetime=function(a,b){box2d.b2Assert(this.ValidateParticleIndex(a));var c=null===this.m_indexByExpirationTimeBuffer.data;this.m_expirationTimeBuffer.data=this.RequestBuffer(this.m_expirationTimeBuffer.data);this.m_indexByExpirationTimeBuffer.data=this.RequestBuffer(this.m_indexByExpirationTimeBuffer.data);if(c)for(var c=this.GetParticleCount(),d=0;d<c;++d)this.m_indexByExpirationTimeBuffer.data[d]=d;c=b/this.m_def.lifetimeGranularity;c=0<c?this.GetQuantizedTimeElapsed()+
+c:c;c!==this.m_expirationTimeBuffer.data[a]&&(this.m_expirationTimeBuffer.data[a]=c,this.m_expirationTimeBufferRequiresSorting=!0)};goog.exportProperty(box2d.b2ParticleSystem.prototype,"SetParticleLifetime",box2d.b2ParticleSystem.prototype.SetParticleLifetime);box2d.b2ParticleSystem.prototype.GetParticleLifetime=function(a){box2d.b2Assert(this.ValidateParticleIndex(a));return this.ExpirationTimeToLifetime(this.GetExpirationTimeBuffer()[a])};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetParticleLifetime",box2d.b2ParticleSystem.prototype.GetParticleLifetime);box2d.b2ParticleSystem.prototype.SetDestructionByAge=function(a){a&&this.GetExpirationTimeBuffer();this.m_def.destroyByAge=a};goog.exportProperty(box2d.b2ParticleSystem.prototype,"SetDestructionByAge",box2d.b2ParticleSystem.prototype.SetDestructionByAge);box2d.b2ParticleSystem.prototype.GetDestructionByAge=function(){return this.m_def.destroyByAge};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetDestructionByAge",box2d.b2ParticleSystem.prototype.GetDestructionByAge);box2d.b2ParticleSystem.prototype.GetExpirationTimeBuffer=function(){this.m_expirationTimeBuffer.data=this.RequestBuffer(this.m_expirationTimeBuffer.data);return this.m_expirationTimeBuffer.data};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetExpirationTimeBuffer",box2d.b2ParticleSystem.prototype.GetExpirationTimeBuffer);
+box2d.b2ParticleSystem.prototype.ExpirationTimeToLifetime=function(a){return(0<a?a-this.GetQuantizedTimeElapsed():a)*this.m_def.lifetimeGranularity};goog.exportProperty(box2d.b2ParticleSystem.prototype,"ExpirationTimeToLifetime",box2d.b2ParticleSystem.prototype.ExpirationTimeToLifetime);
+box2d.b2ParticleSystem.prototype.GetIndexByExpirationTimeBuffer=function(){this.GetParticleCount()?this.SetParticleLifetime(0,this.GetParticleLifetime(0)):this.m_indexByExpirationTimeBuffer.data=this.RequestBuffer(this.m_indexByExpirationTimeBuffer.data);return this.m_indexByExpirationTimeBuffer.data};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetIndexByExpirationTimeBuffer",box2d.b2ParticleSystem.prototype.GetIndexByExpirationTimeBuffer);
+box2d.b2ParticleSystem.prototype.ParticleApplyLinearImpulse=function(a,b){this.ApplyLinearImpulse(a,a+1,b)};goog.exportProperty(box2d.b2ParticleSystem.prototype,"ParticleApplyLinearImpulse",box2d.b2ParticleSystem.prototype.ParticleApplyLinearImpulse);box2d.b2ParticleSystem.prototype.ApplyLinearImpulse=function(a,b,c){var d=this.m_velocityBuffer.data,e=(b-a)*this.GetParticleMass();for(c=c.Clone().SelfMul(1/e);a<b;a++)d[a].SelfAdd(c)};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"ApplyLinearImpulse",box2d.b2ParticleSystem.prototype.ApplyLinearImpulse);box2d.b2ParticleSystem.IsSignificantForce=function(a){return 0!==a.x||0!==a.y};box2d.b2ParticleSystem.prototype.ParticleApplyForce=function(a,b){box2d.b2ParticleSystem.IsSignificantForce(b)&&this.ForceCanBeApplied(this.m_flagsBuffer.data[a])&&(this.PrepareForceBuffer(),this.m_forceBuffer[a].SelfAdd(b))};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"ParticleApplyForce",box2d.b2ParticleSystem.prototype.ParticleApplyForce);box2d.b2ParticleSystem.prototype.ApplyForce=function(a,b,c){for(var d=0,e=a;e<b;e++)d|=this.m_flagsBuffer.data[e];box2d.b2Assert(this.ForceCanBeApplied(d));c=c.Clone().SelfMul(1/(b-a));if(box2d.b2ParticleSystem.IsSignificantForce(c))for(this.PrepareForceBuffer(),e=a;e<b;e++)this.m_forceBuffer[e].SelfAdd(c)};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"ApplyForce",box2d.b2ParticleSystem.prototype.ApplyForce);box2d.b2ParticleSystem.prototype.GetNext=function(){return this.m_next};goog.exportProperty(box2d.b2ParticleSystem.prototype,"GetNext",box2d.b2ParticleSystem.prototype.GetNext);
+box2d.b2ParticleSystem.prototype.QueryAABB=function(a,b){if(0!==this.m_proxyBuffer.count)for(var c=this.m_proxyBuffer.count,d=box2d.std_lower_bound(this.m_proxyBuffer.data,0,c,box2d.b2ParticleSystem.computeTag(this.m_inverseDiameter*b.lowerBound.x,this.m_inverseDiameter*b.lowerBound.y),box2d.b2ParticleSystem.Proxy.CompareProxyTag),c=box2d.std_upper_bound(this.m_proxyBuffer.data,d,c,box2d.b2ParticleSystem.computeTag(this.m_inverseDiameter*b.upperBound.x,this.m_inverseDiameter*b.upperBound.y),box2d.b2ParticleSystem.Proxy.CompareTagProxy),
+e=this.m_positionBuffer.data;d<c;++d){var f=this.m_proxyBuffer.data[d].index,g=e[f];if(b.lowerBound.x<g.x&&g.x<b.upperBound.x&&b.lowerBound.y<g.y&&g.y<b.upperBound.y&&!a.ReportParticle(this,f))break}};goog.exportProperty(box2d.b2ParticleSystem.prototype,"QueryAABB",box2d.b2ParticleSystem.prototype.QueryAABB);box2d.b2ParticleSystem.prototype.QueryShapeAABB=function(a,b,c,d){var e=box2d.b2ParticleSystem.prototype.QueryShapeAABB.s_aabb;b.ComputeAABB(e,c,d||0);this.QueryAABB(a,e)};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"QueryShapeAABB",box2d.b2ParticleSystem.prototype.QueryShapeAABB);box2d.b2ParticleSystem.prototype.QueryShapeAABB.s_aabb=new box2d.b2AABB;box2d.b2ParticleSystem.prototype.QueryPointAABB=function(a,b,c){var d=box2d.b2ParticleSystem.prototype.QueryPointAABB.s_aabb;c="number"===typeof c?c:box2d.b2_linearSlop;d.lowerBound.Set(b.x-c,b.y-c);d.upperBound.Set(b.x+c,b.y+c);this.QueryAABB(a,d)};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"QueryPointAABB",box2d.b2ParticleSystem.prototype.QueryPointAABB);box2d.b2ParticleSystem.prototype.QueryPointAABB.s_aabb=new box2d.b2AABB;
+box2d.b2ParticleSystem.prototype.RayCast=function(a,b,c){var d=box2d.b2ParticleSystem.prototype.RayCast.s_aabb,e=box2d.b2ParticleSystem.prototype.RayCast.s_p,f=box2d.b2ParticleSystem.prototype.RayCast.s_v,g=box2d.b2ParticleSystem.prototype.RayCast.s_n,h=box2d.b2ParticleSystem.prototype.RayCast.s_point;if(0!==this.m_proxyBuffer.count){var k=this.m_positionBuffer.data;box2d.b2Min_V2_V2(b,c,d.lowerBound);box2d.b2Max_V2_V2(b,c,d.upperBound);var l=1;c=box2d.b2Sub_V2_V2(c,b,f);for(var f=box2d.b2Dot_V2_V2(c,
+c),d=this.GetInsideBoundsEnumerator(d),m;0<=(m=d.GetNext());){var n=box2d.b2Sub_V2_V2(b,k[m],e),p=box2d.b2Dot_V2_V2(n,c),q=box2d.b2Dot_V2_V2(n,n),q=p*p-f*(q-this.m_squaredDiameter);if(0<=q){var r=box2d.b2Sqrt(q),q=(-p-r)/f;if(!(q>l)){if(0>q&&(q=(-p+r)/f,0>q||q>l))continue;n=box2d.b2AddMul_V2_S_V2(n,q,c,g);n.Normalize();m=a.ReportParticle(this,m,box2d.b2AddMul_V2_S_V2(b,q,c,h),n,q);l=box2d.b2Min(l,m);if(0>=l)break}}}}};goog.exportProperty(box2d.b2ParticleSystem.prototype,"RayCast",box2d.b2ParticleSystem.prototype.RayCast);
+box2d.b2ParticleSystem.prototype.RayCast.s_aabb=new box2d.b2AABB;box2d.b2ParticleSystem.prototype.RayCast.s_p=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.RayCast.s_v=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.RayCast.s_n=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.RayCast.s_point=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.ComputeAABB=function(a){var b=this.GetParticleCount();box2d.b2Assert(null!==a);a.lowerBound.x=+box2d.b2_maxFloat;a.lowerBound.y=+box2d.b2_maxFloat;a.upperBound.x=-box2d.b2_maxFloat;a.upperBound.y=-box2d.b2_maxFloat;for(var c=this.m_positionBuffer.data,d=0;d<b;d++){var e=c[d];box2d.b2Min_V2_V2(a.lowerBound,e,a.lowerBound);box2d.b2Max_V2_V2(a.upperBound,e,a.upperBound)}a.lowerBound.x-=this.m_particleDiameter;a.lowerBound.y-=this.m_particleDiameter;a.upperBound.x+=this.m_particleDiameter;
+a.upperBound.y+=this.m_particleDiameter};goog.exportProperty(box2d.b2ParticleSystem.prototype,"ComputeAABB",box2d.b2ParticleSystem.prototype.ComputeAABB);box2d.b2ParticleSystem.UserOverridableBuffer=function(){};box2d.b2ParticleSystem.UserOverridableBuffer.prototype.data=null;box2d.b2ParticleSystem.UserOverridableBuffer.prototype.userSuppliedCapacity=0;box2d.b2ParticleSystem.Proxy=function(){};box2d.b2ParticleSystem.Proxy.prototype.index=box2d.b2_invalidParticleIndex;
+box2d.b2ParticleSystem.Proxy.prototype.tag=0;box2d.b2ParticleSystem.Proxy.CompareProxyProxy=function(a,b){return a.tag<b.tag};box2d.b2ParticleSystem.Proxy.CompareTagProxy=function(a,b){return a<b.tag};box2d.b2ParticleSystem.Proxy.CompareProxyTag=function(a,b){return a.tag<b};
+box2d.b2ParticleSystem.InsideBoundsEnumerator=function(a,b,c,d,e){this.m_system=a;this.m_xLower=(b&box2d.b2ParticleSystem.xMask)>>>0;this.m_xUpper=(c&box2d.b2ParticleSystem.xMask)>>>0;this.m_yLower=(b&box2d.b2ParticleSystem.yMask)>>>0;this.m_yUpper=(c&box2d.b2ParticleSystem.yMask)>>>0;this.m_first=d;this.m_last=e;box2d.b2Assert(this.m_first<=this.m_last)};
+box2d.b2ParticleSystem.InsideBoundsEnumerator.prototype.GetNext=function(){for(;this.m_first<this.m_last;){var a=(this.m_system.m_proxyBuffer.data[this.m_first].tag&box2d.b2ParticleSystem.xMask)>>>0,b=(this.m_system.m_proxyBuffer.data[this.m_first].tag&box2d.b2ParticleSystem.yMask)>>>0;box2d.b2Assert(b>=this.m_yLower);box2d.b2Assert(b<=this.m_yUpper);if(a>=this.m_xLower&&a<=this.m_xUpper)return this.m_system.m_proxyBuffer.data[this.m_first++].index;this.m_first++}return box2d.b2_invalidParticleIndex};
+box2d.b2ParticleSystem.ParticleListNode=function(){};box2d.b2ParticleSystem.ParticleListNode.prototype.list=null;box2d.b2ParticleSystem.ParticleListNode.prototype.next=null;box2d.b2ParticleSystem.ParticleListNode.prototype.count=0;box2d.b2ParticleSystem.ParticleListNode.prototype.index=0;box2d.b2ParticleSystem.k_pairFlags=box2d.b2ParticleFlag.b2_springParticle;box2d.b2ParticleSystem.k_triadFlags=box2d.b2ParticleFlag.b2_elasticParticle;
+box2d.b2ParticleSystem.k_noPressureFlags=box2d.b2ParticleFlag.b2_powderParticle|box2d.b2ParticleFlag.b2_tensileParticle;box2d.b2ParticleSystem.k_extraDampingFlags=box2d.b2ParticleFlag.b2_staticPressureParticle;box2d.b2ParticleSystem.k_barrierWallFlags=box2d.b2ParticleFlag.b2_barrierParticle|box2d.b2ParticleFlag.b2_wallParticle;box2d.b2ParticleSystem.prototype.FreeBuffer=function(a,b){null!==a&&(a.length=0)};
+box2d.b2ParticleSystem.prototype.FreeUserOverridableBuffer=function(a){0==a.userSuppliedCapacity&&this.FreeBuffer(a.data,this.m_internalAllocatedCapacity)};box2d.b2ParticleSystem.prototype.ReallocateBuffer3=function(a,b,c){box2d.b2Assert(c>b);a=a?a.slice():[];a.length=c;return a};box2d.b2ParticleSystem.prototype.ReallocateBuffer5=function(a,b,c,d,e){box2d.b2Assert(d>c);box2d.b2Assert(!b||d<=b);e&&!a||b||(a=this.ReallocateBuffer3(a,c,d));return a};
+box2d.b2ParticleSystem.prototype.ReallocateBuffer4=function(a,b,c,d){box2d.b2Assert(c>b);return this.ReallocateBuffer5(a.data,a.userSuppliedCapacity,b,c,d)};box2d.b2ParticleSystem.prototype.RequestBuffer=function(a){a||(0===this.m_internalAllocatedCapacity&&this.ReallocateInternalAllocatedBuffers(box2d.b2_minParticleSystemBufferCapacity),a=[],a.length=this.m_internalAllocatedCapacity);return a};
+box2d.b2ParticleSystem.prototype.ReallocateHandleBuffers=function(a){box2d.b2Assert(a>this.m_internalAllocatedCapacity);this.m_handleIndexBuffer.data=this.ReallocateBuffer4(this.m_handleIndexBuffer,this.m_internalAllocatedCapacity,a,!0)};
+box2d.b2ParticleSystem.prototype.ReallocateInternalAllocatedBuffers=function(a){function b(a,b){return b&&a>b?b:a}a=b(a,this.m_def.maxCount);a=b(a,this.m_flagsBuffer.userSuppliedCapacity);a=b(a,this.m_positionBuffer.userSuppliedCapacity);a=b(a,this.m_velocityBuffer.userSuppliedCapacity);a=b(a,this.m_colorBuffer.userSuppliedCapacity);a=b(a,this.m_userDataBuffer.userSuppliedCapacity);if(this.m_internalAllocatedCapacity<a){this.ReallocateHandleBuffers(a);this.m_flagsBuffer.data=this.ReallocateBuffer4(this.m_flagsBuffer,
+this.m_internalAllocatedCapacity,a,!1);var c=0<this.m_stuckThreshold;this.m_lastBodyContactStepBuffer.data=this.ReallocateBuffer4(this.m_lastBodyContactStepBuffer,this.m_internalAllocatedCapacity,a,c);this.m_bodyContactCountBuffer.data=this.ReallocateBuffer4(this.m_bodyContactCountBuffer,this.m_internalAllocatedCapacity,a,c);this.m_consecutiveContactStepsBuffer.data=this.ReallocateBuffer4(this.m_consecutiveContactStepsBuffer,this.m_internalAllocatedCapacity,a,c);this.m_positionBuffer.data=this.ReallocateBuffer4(this.m_positionBuffer,
+this.m_internalAllocatedCapacity,a,!1);this.m_velocityBuffer.data=this.ReallocateBuffer4(this.m_velocityBuffer,this.m_internalAllocatedCapacity,a,!1);this.m_forceBuffer=this.ReallocateBuffer5(this.m_forceBuffer,0,this.m_internalAllocatedCapacity,a,!1);this.m_weightBuffer=this.ReallocateBuffer5(this.m_weightBuffer,0,this.m_internalAllocatedCapacity,a,!1);this.m_staticPressureBuffer=this.ReallocateBuffer5(this.m_staticPressureBuffer,0,this.m_internalAllocatedCapacity,a,!0);this.m_accumulationBuffer=
+this.ReallocateBuffer5(this.m_accumulationBuffer,0,this.m_internalAllocatedCapacity,a,!1);this.m_accumulation2Buffer=this.ReallocateBuffer5(this.m_accumulation2Buffer,0,this.m_internalAllocatedCapacity,a,!0);this.m_depthBuffer=this.ReallocateBuffer5(this.m_depthBuffer,0,this.m_internalAllocatedCapacity,a,!0);this.m_colorBuffer.data=this.ReallocateBuffer4(this.m_colorBuffer,this.m_internalAllocatedCapacity,a,!0);this.m_groupBuffer=this.ReallocateBuffer5(this.m_groupBuffer,0,this.m_internalAllocatedCapacity,
+a,!1);this.m_userDataBuffer.data=this.ReallocateBuffer4(this.m_userDataBuffer,this.m_internalAllocatedCapacity,a,!0);this.m_expirationTimeBuffer.data=this.ReallocateBuffer4(this.m_expirationTimeBuffer,this.m_internalAllocatedCapacity,a,!0);this.m_indexByExpirationTimeBuffer.data=this.ReallocateBuffer4(this.m_indexByExpirationTimeBuffer,this.m_internalAllocatedCapacity,a,!1);this.m_internalAllocatedCapacity=a}};
+box2d.b2ParticleSystem.prototype.CreateParticleForGroup=function(a,b,c){var d=new box2d.b2ParticleDef;d.flags=a.flags;box2d.b2Mul_X_V2(b,c,d.position);box2d.b2Add_V2_V2(a.linearVelocity,box2d.b2Cross_S_V2(a.angularVelocity,box2d.b2Sub_V2_V2(d.position,a.position,box2d.b2Vec2.s_t0),box2d.b2Vec2.s_t0),d.velocity);d.color.Copy(a.color);d.lifetime=a.lifetime;d.userData=a.userData;this.CreateParticle(d)};goog.exportProperty(box2d.b2ParticleSystem.prototype,"CreateParticleForGroup",box2d.b2ParticleSystem.prototype.CreateParticleForGroup);
+box2d.b2ParticleSystem.prototype.CreateParticlesStrokeShapeForGroup=function(a,b,c){var d=box2d.b2ParticleSystem.prototype.CreateParticlesStrokeShapeForGroup.s_edge,e=box2d.b2ParticleSystem.prototype.CreateParticlesStrokeShapeForGroup.s_d,f=box2d.b2ParticleSystem.prototype.CreateParticlesStrokeShapeForGroup.s_p,g=b.stride;0===g&&(g=this.GetParticleStride());for(var h=0,k=a.GetChildCount(),l=0;l<k;l++){var m=null;a.GetType()===box2d.b2ShapeType.e_edgeShape?m=a:(box2d.b2Assert(a.GetType()===box2d.b2ShapeType.e_chainShape),
+m=d,a.GetChildEdge(m,l));for(var n=box2d.b2Sub_V2_V2(m.m_vertex2,m.m_vertex1,e),p=n.Length();h<p;){var q=box2d.b2AddMul_V2_S_V2(m.m_vertex1,h/p,n,f);this.CreateParticleForGroup(b,c,q);h+=g}h-=p}};goog.exportProperty(box2d.b2ParticleSystem.prototype,"CreateParticlesStrokeShapeForGroup",box2d.b2ParticleSystem.prototype.CreateParticlesStrokeShapeForGroup);box2d.b2ParticleSystem.prototype.CreateParticlesStrokeShapeForGroup.s_edge=new box2d.b2EdgeShape;
+box2d.b2ParticleSystem.prototype.CreateParticlesStrokeShapeForGroup.s_d=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.CreateParticlesStrokeShapeForGroup.s_p=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.CreateParticlesFillShapeForGroup=function(a,b,c){var d=box2d.b2ParticleSystem.prototype.CreateParticlesFillShapeForGroup.s_aabb,e=box2d.b2ParticleSystem.prototype.CreateParticlesFillShapeForGroup.s_p,f=b.stride;0===f&&(f=this.GetParticleStride());var g=box2d.b2Transform.IDENTITY;box2d.b2Assert(1===a.GetChildCount());a.ComputeAABB(d,g,0);for(var h=Math.floor(d.lowerBound.y/f)*f;h<d.upperBound.y;h+=f)for(var k=Math.floor(d.lowerBound.x/f)*f;k<d.upperBound.x;k+=f){var l=
+e.Set(k,h);a.TestPoint(g,l)&&this.CreateParticleForGroup(b,c,l)}};goog.exportProperty(box2d.b2ParticleSystem.prototype,"CreateParticlesFillShapeForGroup",box2d.b2ParticleSystem.prototype.CreateParticlesFillShapeForGroup);box2d.b2ParticleSystem.prototype.CreateParticlesFillShapeForGroup.s_aabb=new box2d.b2AABB;box2d.b2ParticleSystem.prototype.CreateParticlesFillShapeForGroup.s_p=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.CreateParticlesWithShapeForGroup=function(a,b,c){switch(a.GetType()){case box2d.b2ShapeType.e_edgeShape:case box2d.b2ShapeType.e_chainShape:this.CreateParticlesStrokeShapeForGroup(a,b,c);break;case box2d.b2ShapeType.e_polygonShape:case box2d.b2ShapeType.e_circleShape:this.CreateParticlesFillShapeForGroup(a,b,c);break;default:box2d.b2Assert(!1)}};goog.exportProperty(box2d.b2ParticleSystem.prototype,"CreateParticlesWithShapeForGroup",box2d.b2ParticleSystem.prototype.CreateParticlesWithShapeForGroup);
+box2d.b2ParticleSystem.CompositeShape=function(a,b){this.m_shapes=a;this.m_shapeCount=b};goog.inherits(box2d.b2ParticleSystem.CompositeShape,box2d.b2Shape);box2d.b2ParticleSystem.CompositeShape.prototype.m_shapes=null;box2d.b2ParticleSystem.CompositeShape.prototype.m_shapeCount=0;box2d.b2ParticleSystem.CompositeShape.prototype.Clone=function(){box2d.b2Assert(!1);return null};box2d.b2ParticleSystem.CompositeShape.prototype.GetChildCount=function(){return 1};
+box2d.b2ParticleSystem.CompositeShape.prototype.TestPoint=function(a,b){for(var c=0;c<this.m_shapeCount;c++)if(this.m_shapes[c].TestPoint(a,b))return!0;return!1};goog.exportProperty(box2d.b2ParticleSystem.CompositeShape.prototype,"TestPoint",box2d.b2ParticleSystem.CompositeShape.prototype.TestPoint);box2d.b2ParticleSystem.CompositeShape.prototype.ComputeDistance=function(a,b,c,d){box2d.b2Assert(!1);return 0};goog.exportProperty(box2d.b2ParticleSystem.CompositeShape.prototype,"ComputeDistance",box2d.b2ParticleSystem.CompositeShape.prototype.ComputeDistance);
+box2d.b2ParticleSystem.CompositeShape.prototype.RayCast=function(a,b,c,d){box2d.b2Assert(!1);return!1};goog.exportProperty(box2d.b2ParticleSystem.CompositeShape.prototype,"RayCast",box2d.b2ParticleSystem.CompositeShape.prototype.RayCast);
+box2d.b2ParticleSystem.CompositeShape.prototype.ComputeAABB=function(a,b,c){var d=new box2d.b2AABB;a.lowerBound.x=+box2d.b2_maxFloat;a.lowerBound.y=+box2d.b2_maxFloat;a.upperBound.x=-box2d.b2_maxFloat;a.upperBound.y=-box2d.b2_maxFloat;box2d.b2Assert(0===c);for(c=0;c<this.m_shapeCount;c++)for(var e=this.m_shapes[c].GetChildCount(),f=0;f<e;f++){var g=d;this.m_shapes[c].ComputeAABB(g,b,f);a.Combine1(g)}};goog.exportProperty(box2d.b2ParticleSystem.CompositeShape.prototype,"ComputeAABB",box2d.b2ParticleSystem.CompositeShape.prototype.ComputeAABB);
+box2d.b2ParticleSystem.CompositeShape.prototype.ComputeMass=function(a,b){box2d.b2Assert(!1)};goog.exportProperty(box2d.b2ParticleSystem.CompositeShape.prototype,"ComputeMass",box2d.b2ParticleSystem.CompositeShape.prototype.ComputeMass);box2d.b2ParticleSystem.prototype.CreateParticlesWithShapesForGroup=function(a,b,c,d){a=new box2d.b2ParticleSystem.CompositeShape(a,b);this.CreateParticlesFillShapeForGroup(a,c,d)};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"CreateParticlesWithShapesForGroup",box2d.b2ParticleSystem.prototype.CreateParticlesWithShapesForGroup);
+box2d.b2ParticleSystem.prototype.CloneParticle=function(a,b){var c=new box2d.b2ParticleDef;c.flags=this.m_flagsBuffer.data[a];c.position.Copy(this.m_positionBuffer.data[a]);c.velocity.Copy(this.m_velocityBuffer.data[a]);this.m_colorBuffer.data&&c.color.Copy(this.m_colorBuffer.data[a]);this.m_userDataBuffer.data&&(c.userData=this.m_userDataBuffer.data[a]);c.group=b;c=this.CreateParticle(c);if(this.m_handleIndexBuffer.data){var d=this.m_handleIndexBuffer.data[a];d&&d.SetIndex(c);this.m_handleIndexBuffer.data[c]=
+d;this.m_handleIndexBuffer.data[a]=null}this.m_lastBodyContactStepBuffer.data&&(this.m_lastBodyContactStepBuffer.data[c]=this.m_lastBodyContactStepBuffer.data[a]);this.m_bodyContactCountBuffer.data&&(this.m_bodyContactCountBuffer.data[c]=this.m_bodyContactCountBuffer.data[a]);this.m_consecutiveContactStepsBuffer.data&&(this.m_consecutiveContactStepsBuffer.data[c]=this.m_consecutiveContactStepsBuffer.data[a]);this.m_hasForce&&this.m_forceBuffer[c].Copy(this.m_forceBuffer[a]);this.m_staticPressureBuffer&&
+(this.m_staticPressureBuffer[c]=this.m_staticPressureBuffer[a]);this.m_depthBuffer&&(this.m_depthBuffer[c]=this.m_depthBuffer[a]);this.m_expirationTimeBuffer.data&&(this.m_expirationTimeBuffer.data[c]=this.m_expirationTimeBuffer.data[a]);return c};goog.exportProperty(box2d.b2ParticleSystem.prototype,"CloneParticle",box2d.b2ParticleSystem.prototype.CloneParticle);
+box2d.b2ParticleSystem.prototype.DestroyParticlesInGroup=function(a,b){for(var c=a.m_firstIndex;c<a.m_lastIndex;c++)this.DestroyParticle(c,b)};goog.exportProperty(box2d.b2ParticleSystem.prototype,"DestroyParticlesInGroup",box2d.b2ParticleSystem.prototype.DestroyParticlesInGroup);
+box2d.b2ParticleSystem.prototype.DestroyParticleGroup=function(a){box2d.b2Assert(0<this.m_groupCount);box2d.b2Assert(null!==a);this.m_world.m_destructionListener&&this.m_world.m_destructionListener.SayGoodbyeParticleGroup(a);this.SetGroupFlags(a,0);for(var b=a.m_firstIndex;b<a.m_lastIndex;b++)this.m_groupBuffer[b]=null;a.m_prev&&(a.m_prev.m_next=a.m_next);a.m_next&&(a.m_next.m_prev=a.m_prev);a===this.m_groupList&&(this.m_groupList=a.m_next);--this.m_groupCount};
+goog.exportProperty(box2d.b2ParticleSystem.prototype,"DestroyParticleGroup",box2d.b2ParticleSystem.prototype.DestroyParticleGroup);box2d.b2ParticleSystem.ParticleCanBeConnected=function(a,b){return 0!==(a&(box2d.b2ParticleFlag.b2_wallParticle|box2d.b2ParticleFlag.b2_springParticle|box2d.b2ParticleFlag.b2_elasticParticle))||null!==b&&0!==(b.GetGroupFlags()&box2d.b2ParticleGroupFlag.b2_rigidParticleGroup)};
+box2d.b2ParticleSystem.prototype.UpdatePairsAndTriads=function(a,b,c){var d=box2d.b2ParticleSystem.prototype.UpdatePairsAndTriads.s_dab,e=box2d.b2ParticleSystem.prototype.UpdatePairsAndTriads.s_dbc,f=box2d.b2ParticleSystem.prototype.UpdatePairsAndTriads.s_dca,g=this.m_positionBuffer.data;box2d.b2Assert(a<=b);for(var h=0,k=a;k<b;k++)h|=this.m_flagsBuffer.data[k];if(h&box2d.b2ParticleSystem.k_pairFlags)for(k=0;k<this.m_contactBuffer.count;k++){var l=this.m_contactBuffer.data[k],m=l.indexA,n=l.indexB,
+p=this.m_flagsBuffer.data[m],q=this.m_flagsBuffer.data[n],r=this.m_groupBuffer[m],u=this.m_groupBuffer[n];m>=a&&m<b&&n>=a&&n<b&&!((p|q)&box2d.b2ParticleFlag.b2_zombieParticle)&&(p|q)&box2d.b2ParticleSystem.k_pairFlags&&(c.IsNecessary(m)||c.IsNecessary(n))&&box2d.b2ParticleSystem.ParticleCanBeConnected(p,r)&&box2d.b2ParticleSystem.ParticleCanBeConnected(q,u)&&c.ShouldCreatePair(m,n)&&(p=this.m_pairBuffer.data[this.m_pairBuffer.Append()],p.indexA=m,p.indexB=n,p.flags=l.flags,p.strength=box2d.b2Min(r?
+r.m_strength:1,u?u.m_strength:1),p.distance=box2d.b2Distance(g[m],g[n]));box2d.std_stable_sort(this.m_pairBuffer.data,0,this.m_pairBuffer.count,box2d.b2ParticleSystem.ComparePairIndices);this.m_pairBuffer.Unique(box2d.b2ParticleSystem.MatchPairIndices)}if(h&box2d.b2ParticleSystem.k_triadFlags){h=new box2d.b2VoronoiDiagram(b-a);l=0;for(k=a;k<b;k++)m=this.m_flagsBuffer.data[k],n=this.m_groupBuffer[k],m&box2d.b2ParticleFlag.b2_zombieParticle||!box2d.b2ParticleSystem.ParticleCanBeConnected(m,n)||(c.IsNecessary(k)&&
+++l,h.AddGenerator(g[k],k,c.IsNecessary(k)));if(0===l)for(k=a;k<b;k++)c.IsNecessary(k);a=this.GetParticleStride();h.Generate(a/2,2*a);var t=this;h.GetNodes(function(a,b,h){var k=t.m_flagsBuffer.data[a],l=t.m_flagsBuffer.data[b],m=t.m_flagsBuffer.data[h];if((k|l|m)&box2d.b2ParticleSystem.k_triadFlags&&c.ShouldCreateTriad(a,b,h)){var n=g[a],p=g[b],q=g[h],r=box2d.b2Sub_V2_V2(n,p,d),u=box2d.b2Sub_V2_V2(p,q,e),C=box2d.b2Sub_V2_V2(q,n,f),A=box2d.b2_maxTriadDistanceSquared*t.m_squaredDiameter;if(!(box2d.b2Dot_V2_V2(r,
+r)>A||box2d.b2Dot_V2_V2(u,u)>A||box2d.b2Dot_V2_V2(C,C)>A)){var K=t.m_groupBuffer[a],J=t.m_groupBuffer[b],D=t.m_groupBuffer[h],A=t.m_triadBuffer.data[t.m_triadBuffer.Append()];A.indexA=a;A.indexB=b;A.indexC=h;A.flags=k|l|m;A.strength=box2d.b2Min(box2d.b2Min(K?K.m_strength:1,J?J.m_strength:1),D?D.m_strength:1);a=(n.x+p.x+q.x)/3;b=(n.y+p.y+q.y)/3;A.pa.x=n.x-a;A.pa.y=n.y-b;A.pb.x=p.x-a;A.pb.y=p.y-b;A.pc.x=q.x-a;A.pc.y=q.y-b;A.ka=-box2d.b2Dot_V2_V2(C,r);A.kb=-box2d.b2Dot_V2_V2(r,u);A.kc=-box2d.b2Dot_V2_V2(u,
+C);A.s=box2d.b2Cross_V2_V2(n,p)+box2d.b2Cross_V2_V2(p,q)+box2d.b2Cross_V2_V2(q,n)}}});box2d.std_stable_sort(this.m_triadBuffer.data,0,this.m_triadBuffer.count,box2d.b2ParticleSystem.CompareTriadIndices);this.m_triadBuffer.Unique(box2d.b2ParticleSystem.MatchTriadIndices)}};box2d.b2ParticleSystem.prototype.UpdatePairsAndTriads.s_dab=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.UpdatePairsAndTriads.s_dbc=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.UpdatePairsAndTriads.s_dca=new box2d.b2Vec2;
+box2d.b2ParticleSystem.ReactiveFilter=function(a){this.m_flagsBuffer=a};goog.inherits(box2d.b2ParticleSystem.ReactiveFilter,box2d.b2ParticleSystem.ConnectionFilter);box2d.b2ParticleSystem.ReactiveFilter.prototype.m_flagsBuffer=null;box2d.b2ParticleSystem.ReactiveFilter.prototype.IsNecessary=function(a){return 0!==(this.m_flagsBuffer[a]&box2d.b2ParticleFlag.b2_reactiveParticle)};
+box2d.b2ParticleSystem.prototype.UpdatePairsAndTriadsWithReactiveParticles=function(){var a=new box2d.b2ParticleSystem.ReactiveFilter(this.m_flagsBuffer);this.UpdatePairsAndTriads(0,this.m_count,a);for(a=0;a<this.m_count;a++)this.m_flagsBuffer.data[a]&=~box2d.b2ParticleFlag.b2_reactiveParticle;this.m_allParticleFlags&=~box2d.b2ParticleFlag.b2_reactiveParticle};box2d.b2ParticleSystem.ComparePairIndices=function(a,b){var c=a.indexA-b.indexA;return 0!==c?0>c:a.indexB<b.indexB};
+box2d.b2ParticleSystem.MatchPairIndices=function(a,b){return a.indexA===b.indexA&&a.indexB===b.indexB};box2d.b2ParticleSystem.CompareTriadIndices=function(a,b){var c=a.indexA-b.indexA;if(0!==c)return 0>c;c=a.indexB-b.indexB;return 0!==c?0>c:a.indexC<b.indexC};box2d.b2ParticleSystem.MatchTriadIndices=function(a,b){return a.indexA===b.indexA&&a.indexB===b.indexB&&a.indexC===b.indexC};
+box2d.b2ParticleSystem.InitializeParticleLists=function(a,b){for(var c=a.GetBufferIndex(),d=a.GetParticleCount(),e=0;e<d;e++){var f=b[e];f.list=f;f.next=null;f.count=1;f.index=e+c}};
+box2d.b2ParticleSystem.prototype.MergeParticleListsInContact=function(a,b){for(var c=a.GetBufferIndex(),d=0;d<this.m_contactBuffer.count;d++){var e=this.m_contactBuffer.data[d],f=e.indexA,e=e.indexB;if(a.ContainsParticle(f)&&a.ContainsParticle(e)&&(f=b[f-c].list,e=b[e-c].list,f!==e)){if(f.count<e.count)var g=f,f=e,e=g;box2d.b2Assert(f.count>=e.count);box2d.b2ParticleSystem.MergeParticleLists(f,e)}}};
+box2d.b2ParticleSystem.MergeParticleLists=function(a,b){box2d.b2Assert(a!==b);for(var c=b;;){c.list=a;var d=c.next;if(d)c=d;else{c.next=a.next;break}}a.next=b;a.count+=b.count;b.count=0};box2d.b2ParticleSystem.FindLongestParticleList=function(a,b){for(var c=a.GetParticleCount(),d=b[0],e=0;e<c;e++){var f=b[e];d.count<f.count&&(d=f)}return d};
+box2d.b2ParticleSystem.prototype.MergeZombieParticleListNodes=function(a,b,c){a=a.GetParticleCount();for(var d=0;d<a;d++){var e=b[d];e!==c&&this.m_flagsBuffer.data[e.index]&box2d.b2ParticleFlag.b2_zombieParticle&&box2d.b2ParticleSystem.MergeParticleListAndNode(c,e)}};box2d.b2ParticleSystem.MergeParticleListAndNode=function(a,b){box2d.b2Assert(b!==a);box2d.b2Assert(b.list===b);box2d.b2Assert(1===b.count);b.list=a;b.next=a.next;a.next=b;a.count++;b.count=0};
+box2d.b2ParticleSystem.prototype.CreateParticleGroupsFromParticleList=function(a,b,c){var d=a.GetParticleCount(),e=new box2d.b2ParticleGroupDef;e.groupFlags=a.GetGroupFlags();e.userData=a.GetUserData();for(a=0;a<d;a++){var f=b[a];if(f.count&&f!==c){box2d.b2Assert(f.list===f);for(var g=this.CreateParticleGroup(e);f;f=f.next){var h=f.index;box2d.b2Assert(!(this.m_flagsBuffer.data[h]&box2d.b2ParticleFlag.b2_zombieParticle));var k=this.CloneParticle(h,g);this.m_flagsBuffer.data[h]|=box2d.b2ParticleFlag.b2_zombieParticle;
+f.index=k}}}};
+box2d.b2ParticleSystem.prototype.UpdatePairsAndTriadsWithParticleList=function(a,b){for(var c=a.GetBufferIndex(),d=0;d<this.m_pairBuffer.count;d++){var e=this.m_pairBuffer.data[d],f=e.indexA,g=e.indexB;a.ContainsParticle(f)&&(e.indexA=b[f-c].index);a.ContainsParticle(g)&&(e.indexB=b[g-c].index)}for(d=0;d<this.m_triadBuffer.count;d++){var e=this.m_triadBuffer.data[d],f=e.indexA,g=e.indexB,h=e.indexC;a.ContainsParticle(f)&&(e.indexA=b[f-c].index);a.ContainsParticle(g)&&(e.indexB=b[g-c].index);a.ContainsParticle(h)&&
+(e.indexC=b[h-c].index)}};
+box2d.b2ParticleSystem.prototype.ComputeDepth=function(){for(var a=[],b=0,c=0;c<this.m_contactBuffer.count;c++){var d=this.m_contactBuffer.data[c],e=d.indexA,f=d.indexB,g=this.m_groupBuffer[e],h=this.m_groupBuffer[f];g&&g===h&&g.m_groupFlags&box2d.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth&&(a[b++]=d)}g=[];h=0;for(c=this.m_groupList;c;c=c.GetNext())if(c.m_groupFlags&box2d.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth)for(g[h++]=c,this.SetGroupFlags(c,c.m_groupFlags&~box2d.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth),
+f=c.m_firstIndex;f<c.m_lastIndex;f++)this.m_accumulationBuffer[f]=0;for(c=0;c<b;c++){var d=a[c],e=d.indexA,f=d.indexB,k=d.weight;this.m_accumulationBuffer[e]+=k;this.m_accumulationBuffer[f]+=k}box2d.b2Assert(null!==this.m_depthBuffer);for(f=0;f<h;f++)for(c=g[f],f=c.m_firstIndex;f<c.m_lastIndex;f++)k=this.m_accumulationBuffer[f],this.m_depthBuffer[f]=.8>k?0:box2d.b2_maxFloat;for(var k=box2d.b2Sqrt(this.m_count)>>0,l=0;l<k;l++){for(var m=!1,c=0;c<b;c++){var d=a[c],e=d.indexA,f=d.indexB,n=1-d.weight,
+d=this.m_depthBuffer[e],p=this.m_depthBuffer[f],q=p+n,n=d+n;d>q&&(this.m_depthBuffer[e]=q,m=!0);p>n&&(this.m_depthBuffer[f]=n,m=!0)}if(!m)break}for(f=0;f<h;f++)for(c=g[f],f=c.m_firstIndex;f<c.m_lastIndex;f++)this.m_depthBuffer[f]=this.m_depthBuffer[f]<box2d.b2_maxFloat?this.m_depthBuffer[f]*this.m_particleDiameter:0};
+box2d.b2ParticleSystem.prototype.GetInsideBoundsEnumerator=function(a){var b=box2d.b2ParticleSystem.computeTag(this.m_inverseDiameter*a.lowerBound.x-1,this.m_inverseDiameter*a.lowerBound.y-1);a=box2d.b2ParticleSystem.computeTag(this.m_inverseDiameter*a.upperBound.x+1,this.m_inverseDiameter*a.upperBound.y+1);var c=this.m_proxyBuffer.count,d=box2d.std_lower_bound(this.m_proxyBuffer.data,0,c,b,box2d.b2ParticleSystem.Proxy.CompareProxyTag),e=box2d.std_upper_bound(this.m_proxyBuffer.data,0,c,a,box2d.b2ParticleSystem.Proxy.CompareTagProxy);
+box2d.b2Assert(0<=d);box2d.b2Assert(d<=e);box2d.b2Assert(e<=c);return new box2d.b2ParticleSystem.InsideBoundsEnumerator(this,b,a,d,e)};box2d.b2ParticleSystem.prototype.UpdateAllParticleFlags=function(){for(var a=this.m_allParticleFlags=0;a<this.m_count;a++)this.m_allParticleFlags|=this.m_flagsBuffer.data[a];this.m_needsUpdateAllParticleFlags=!1};
+box2d.b2ParticleSystem.prototype.UpdateAllGroupFlags=function(){this.m_allGroupFlags=0;for(var a=this.m_groupList;a;a=a.GetNext())this.m_allGroupFlags|=a.m_groupFlags;this.m_needsUpdateAllGroupFlags=!1};
+box2d.b2ParticleSystem.prototype.AddContact=function(a,b,c){var d=box2d.b2ParticleSystem.prototype.AddContact.s_d,e=this.m_positionBuffer.data;box2d.b2Assert(c===this.m_contactBuffer);c=box2d.b2Sub_V2_V2(e[b],e[a],d);d=box2d.b2Dot_V2_V2(c,c);if(d<this.m_squaredDiameter){e=box2d.b2InvSqrt(d);isFinite(e)||(e=1.9817753699999998E19);var f=this.m_contactBuffer.data[this.m_contactBuffer.Append()];f.indexA=a;f.indexB=b;f.flags=this.m_flagsBuffer.data[a]|this.m_flagsBuffer.data[b];f.weight=1-d*e*this.m_inverseDiameter;
+box2d.b2Mul_S_V2(e,c,f.normal)}};box2d.b2ParticleSystem.prototype.AddContact.s_d=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.FindContacts_Reference=function(a){box2d.b2Assert(a===this.m_contactBuffer);a=this.m_proxyBuffer.count;for(var b=this.m_contactBuffer.count=0,c=0;b<a;b++){for(var d=box2d.b2ParticleSystem.computeRelativeTag(this.m_proxyBuffer.data[b].tag,1,0),e=b+1;e<a&&!(d<this.m_proxyBuffer.data[e].tag);e++)this.AddContact(this.m_proxyBuffer.data[b].index,this.m_proxyBuffer.data[e].index,this.m_contactBuffer);for(e=box2d.b2ParticleSystem.computeRelativeTag(this.m_proxyBuffer.data[b].tag,
+-1,1);c<a&&!(e<=this.m_proxyBuffer.data[c].tag);c++);d=box2d.b2ParticleSystem.computeRelativeTag(this.m_proxyBuffer.data[b].tag,1,1);for(e=c;e<a&&!(d<this.m_proxyBuffer.data[e].tag);e++)this.AddContact(this.m_proxyBuffer.data[b].index,this.m_proxyBuffer.data[e].index,this.m_contactBuffer)}};box2d.b2ParticleSystem.prototype.FindContacts=function(a){this.FindContacts_Reference(a)};
+box2d.b2ParticleSystem.prototype.UpdateProxies_Reference=function(a){box2d.b2Assert(a===this.m_proxyBuffer);a=this.m_positionBuffer.data;for(var b=this.m_inverseDiameter,c=0;c<this.m_proxyBuffer.count;++c){var d=this.m_proxyBuffer.data[c],e=a[d.index];d.tag=box2d.b2ParticleSystem.computeTag(b*e.x,b*e.y)}};box2d.b2ParticleSystem.prototype.UpdateProxies=function(a){this.UpdateProxies_Reference(a)};
+box2d.b2ParticleSystem.prototype.SortProxies=function(a){box2d.b2Assert(a===this.m_proxyBuffer);box2d.std_sort(this.m_proxyBuffer.data,0,this.m_proxyBuffer.count,box2d.b2ParticleSystem.Proxy.CompareProxyProxy)};
+box2d.b2ParticleSystem.prototype.FilterContacts=function(a){var b=this.GetParticleContactFilter();if(null!==b){box2d.b2Assert(a===this.m_contactBuffer);var c=this;this.m_contactBuffer.RemoveIf(function(a){return a.flags&box2d.b2ParticleFlag.b2_particleContactFilterParticle&&!b.ShouldCollideParticleParticle(c,a.indexA,a.indexB)})}};
+box2d.b2ParticleSystem.prototype.NotifyContactListenerPreContact=function(a){if(null!==this.GetParticleContactListener())throw a.Initialize(this.m_contactBuffer,this.m_flagsBuffer),Error();};box2d.b2ParticleSystem.prototype.NotifyContactListenerPostContact=function(a){a=this.GetParticleContactListener();if(null!==a){for(var b=0;b<this.m_contactBuffer.count;++b)a.BeginContactParticleParticle(this,this.m_contactBuffer.data[b]);throw Error();}};
+box2d.b2ParticleSystem.b2ParticleContactIsZombie=function(a){return(a.flags&box2d.b2ParticleFlag.b2_zombieParticle)===box2d.b2ParticleFlag.b2_zombieParticle};
+box2d.b2ParticleSystem.prototype.UpdateContacts=function(a){this.UpdateProxies(this.m_proxyBuffer);this.SortProxies(this.m_proxyBuffer);var b=new box2d.b2ParticleSystem.b2ParticlePairSet;this.NotifyContactListenerPreContact(b);this.FindContacts(this.m_contactBuffer);this.FilterContacts(this.m_contactBuffer);this.NotifyContactListenerPostContact(b);a&&this.m_contactBuffer.RemoveIf(box2d.b2ParticleSystem.b2ParticleContactIsZombie)};
+box2d.b2ParticleSystem.prototype.NotifyBodyContactListenerPreContact=function(a){if(null!==this.GetFixtureContactListener())throw a.Initialize(this.m_bodyContactBuffer,this.m_flagsBuffer),Error();};box2d.b2ParticleSystem.prototype.NotifyBodyContactListenerPostContact=function(a){a=this.GetFixtureContactListener();if(null!==a){for(var b=0;b<this.m_bodyContactBuffer.count;b++){var c=this.m_bodyContactBuffer.data[b];box2d.b2Assert(null!==c);a.BeginContactFixtureParticle(this,c)}throw Error();}};
+box2d.b2ParticleSystem.UpdateBodyContactsCallback=function(a,b){box2d.b2FixtureParticleQueryCallback.call(this,a);this.m_contactFilter=b};goog.inherits(box2d.b2ParticleSystem.UpdateBodyContactsCallback,box2d.b2FixtureParticleQueryCallback);
+box2d.b2ParticleSystem.UpdateBodyContactsCallback.prototype.ShouldCollideFixtureParticle=function(a,b,c){return this.m_contactFilter&&this.m_system.GetFlagsBuffer()[c]&box2d.b2ParticleFlag.b2_fixtureContactFilterParticle?this.m_contactFilter.ShouldCollideFixtureParticle(a,this.m_system,c):!0};goog.exportProperty(box2d.b2ParticleSystem.UpdateBodyContactsCallback.prototype,"ShouldCollideFixtureParticle",box2d.b2ParticleSystem.UpdateBodyContactsCallback.prototype.ShouldCollideFixtureParticle);
+box2d.b2ParticleSystem.UpdateBodyContactsCallback.prototype.ReportFixtureAndParticle=function(a,b,c){var d=box2d.b2ParticleSystem.UpdateBodyContactsCallback.prototype.ReportFixtureAndParticle.s_rp,e=this.m_system.m_positionBuffer.data[c],f=box2d.b2ParticleSystem.UpdateBodyContactsCallback.prototype.ReportFixtureAndParticle.s_n;b=a.ComputeDistance(e,f,b);if(b<this.m_system.m_particleDiameter&&this.ShouldCollideFixtureParticle(a,this.m_system,c)){var g=a.GetBody(),h=g.GetWorldCenter(),k=g.GetMass(),
+l=g.GetInertia()-k*g.GetLocalCenter().LengthSquared(),k=0<k?1/k:0,l=0<l?1/l:0,m=this.m_system.m_flagsBuffer.data[c]&box2d.b2ParticleFlag.b2_wallParticle?0:this.m_system.GetParticleInvMass(),d=box2d.b2Sub_V2_V2(e,h,d),d=box2d.b2Cross_V2_V2(d,f),d=m+k+l*d*d,e=this.m_system.m_bodyContactBuffer.data[this.m_system.m_bodyContactBuffer.Append()];e.index=c;e.body=g;e.fixture=a;e.weight=1-b*this.m_system.m_inverseDiameter;e.normal.Copy(f.SelfNeg());e.mass=0<d?1/d:0;this.m_system.DetectStuckParticle(c)}};
+goog.exportProperty(box2d.b2ParticleSystem.UpdateBodyContactsCallback.prototype,"ReportFixtureAndParticle",box2d.b2ParticleSystem.UpdateBodyContactsCallback.prototype.ReportFixtureAndParticle);box2d.b2ParticleSystem.UpdateBodyContactsCallback.prototype.ReportFixtureAndParticle.s_n=new box2d.b2Vec2;box2d.b2ParticleSystem.UpdateBodyContactsCallback.prototype.ReportFixtureAndParticle.s_rp=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.UpdateBodyContacts=function(){var a=box2d.b2ParticleSystem.prototype.UpdateBodyContacts.s_aabb,b=new box2d.b2ParticleSystem.FixtureParticleSet;this.NotifyBodyContactListenerPreContact(b);if(0<this.m_stuckThreshold)for(var c=this.GetParticleCount(),d=0;d<c;d++)this.m_bodyContactCountBuffer.data[d]=0,this.m_timestamp>this.m_lastBodyContactStepBuffer.data[d]+1&&(this.m_consecutiveContactStepsBuffer.data[d]=0);this.m_bodyContactBuffer.SetCount(0);this.m_stuckParticleBuffer.SetCount(0);
+this.ComputeAABB(a);c=new box2d.b2ParticleSystem.UpdateBodyContactsCallback(this,this.GetFixtureContactFilter());this.m_world.QueryAABB(c,a);this.m_def.strictContactCheck&&this.RemoveSpuriousBodyContacts();this.NotifyBodyContactListenerPostContact(b)};box2d.b2ParticleSystem.prototype.UpdateBodyContacts.s_aabb=new box2d.b2AABB;
+box2d.b2ParticleSystem.prototype.Solve=function(a){var b=box2d.b2ParticleSystem.prototype.Solve.s_subStep;if(0!==this.m_count&&(this.m_expirationTimeBuffer.data&&this.SolveLifetimes(a),this.m_allParticleFlags&box2d.b2ParticleFlag.b2_zombieParticle&&this.SolveZombie(),this.m_needsUpdateAllParticleFlags&&this.UpdateAllParticleFlags(),this.m_needsUpdateAllGroupFlags&&this.UpdateAllGroupFlags(),!this.m_paused))for(this.m_iterationIndex=0;this.m_iterationIndex<a.particleIterations;this.m_iterationIndex++){++this.m_timestamp;
+var c=b.Copy(a);c.dt/=a.particleIterations;c.inv_dt*=a.particleIterations;this.UpdateContacts(!1);this.UpdateBodyContacts();this.ComputeWeight();this.m_allGroupFlags&box2d.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth&&this.ComputeDepth();this.m_allParticleFlags&box2d.b2ParticleFlag.b2_reactiveParticle&&this.UpdatePairsAndTriadsWithReactiveParticles();this.m_hasForce&&this.SolveForce(c);this.m_allParticleFlags&box2d.b2ParticleFlag.b2_viscousParticle&&this.SolveViscous();this.m_allParticleFlags&
+box2d.b2ParticleFlag.b2_repulsiveParticle&&this.SolveRepulsive(c);this.m_allParticleFlags&box2d.b2ParticleFlag.b2_powderParticle&&this.SolvePowder(c);this.m_allParticleFlags&box2d.b2ParticleFlag.b2_tensileParticle&&this.SolveTensile(c);this.m_allGroupFlags&box2d.b2ParticleGroupFlag.b2_solidParticleGroup&&this.SolveSolid(c);this.m_allParticleFlags&box2d.b2ParticleFlag.b2_colorMixingParticle&&this.SolveColorMixing();this.SolveGravity(c);this.m_allParticleFlags&box2d.b2ParticleFlag.b2_staticPressureParticle&&
+this.SolveStaticPressure(c);this.SolvePressure(c);this.SolveDamping(c);this.m_allParticleFlags&box2d.b2ParticleSystem.k_extraDampingFlags&&this.SolveExtraDamping();this.m_allParticleFlags&box2d.b2ParticleFlag.b2_elasticParticle&&this.SolveElastic(c);this.m_allParticleFlags&box2d.b2ParticleFlag.b2_springParticle&&this.SolveSpring(c);this.LimitVelocity(c);this.m_allGroupFlags&box2d.b2ParticleGroupFlag.b2_rigidParticleGroup&&this.SolveRigidDamping();this.m_allParticleFlags&box2d.b2ParticleFlag.b2_barrierParticle&&
+this.SolveBarrier(c);this.SolveCollision(c);this.m_allGroupFlags&box2d.b2ParticleGroupFlag.b2_rigidParticleGroup&&this.SolveRigid(c);this.m_allParticleFlags&box2d.b2ParticleFlag.b2_wallParticle&&this.SolveWall();for(var d=0;d<this.m_count;d++)this.m_positionBuffer.data[d].SelfMulAdd(c.dt,this.m_velocityBuffer.data[d])}};goog.exportProperty(box2d.b2ParticleSystem.prototype,"Solve",box2d.b2ParticleSystem.prototype.Solve);box2d.b2ParticleSystem.prototype.Solve.s_subStep=new box2d.b2TimeStep;
+box2d.b2ParticleSystem.SolveCollisionCallback=function(a,b){box2d.b2FixtureParticleQueryCallback.call(this,a);this.m_step=b};goog.inherits(box2d.b2ParticleSystem.SolveCollisionCallback,box2d.b2FixtureParticleQueryCallback);
+box2d.b2ParticleSystem.SolveCollisionCallback.prototype.ReportFixtureAndParticle=function(a,b,c){var d=box2d.b2ParticleSystem.SolveCollisionCallback.prototype.ReportFixtureAndParticle.s_p1,e=box2d.b2ParticleSystem.SolveCollisionCallback.prototype.ReportFixtureAndParticle.s_output,f=box2d.b2ParticleSystem.SolveCollisionCallback.prototype.ReportFixtureAndParticle.s_input,g=box2d.b2ParticleSystem.SolveCollisionCallback.prototype.ReportFixtureAndParticle.s_p,h=box2d.b2ParticleSystem.SolveCollisionCallback.prototype.ReportFixtureAndParticle.s_v,
+k=box2d.b2ParticleSystem.SolveCollisionCallback.prototype.ReportFixtureAndParticle.s_f,l=a.GetBody(),m=this.m_system.m_positionBuffer.data[c],n=this.m_system.m_velocityBuffer.data[c];0===this.m_system.m_iterationIndex?(d=box2d.b2MulT_X_V2(l.m_xf0,m,d),a.GetShape().GetType()===box2d.b2ShapeType.e_circleShape&&(d.SelfSub(l.GetLocalCenter()),box2d.b2Mul_R_V2(l.m_xf0.q,d,d),box2d.b2MulT_R_V2(l.m_xf.q,d,d),d.SelfAdd(l.GetLocalCenter())),box2d.b2Mul_X_V2(l.m_xf,d,f.p1)):f.p1.Copy(m);box2d.b2AddMul_V2_S_V2(m,
+this.m_step.dt,n,f.p2);f.maxFraction=1;a.RayCast(e,f,b)&&(a=e.normal,g.x=(1-e.fraction)*f.p1.x+e.fraction*f.p2.x+box2d.b2_linearSlop*a.x,g.y=(1-e.fraction)*f.p1.y+e.fraction*f.p2.y+box2d.b2_linearSlop*a.y,h.x=this.m_step.inv_dt*(g.x-m.x),h.y=this.m_step.inv_dt*(g.y-m.y),this.m_system.m_velocityBuffer.data[c].Copy(h),k.x=this.m_step.inv_dt*this.m_system.GetParticleMass()*(n.x-h.x),k.y=this.m_step.inv_dt*this.m_system.GetParticleMass()*(n.y-h.y),this.m_system.ParticleApplyForce(c,k))};
+goog.exportProperty(box2d.b2ParticleSystem.SolveCollisionCallback.prototype,"ReportFixtureAndParticle",box2d.b2ParticleSystem.SolveCollisionCallback.prototype.ReportFixtureAndParticle);box2d.b2ParticleSystem.SolveCollisionCallback.prototype.ReportFixtureAndParticle.s_p1=new box2d.b2Vec2;box2d.b2ParticleSystem.SolveCollisionCallback.prototype.ReportFixtureAndParticle.s_output=new box2d.b2RayCastOutput;box2d.b2ParticleSystem.SolveCollisionCallback.prototype.ReportFixtureAndParticle.s_input=new box2d.b2RayCastInput;
+box2d.b2ParticleSystem.SolveCollisionCallback.prototype.ReportFixtureAndParticle.s_p=new box2d.b2Vec2;box2d.b2ParticleSystem.SolveCollisionCallback.prototype.ReportFixtureAndParticle.s_v=new box2d.b2Vec2;box2d.b2ParticleSystem.SolveCollisionCallback.prototype.ReportFixtureAndParticle.s_f=new box2d.b2Vec2;box2d.b2ParticleSystem.SolveCollisionCallback.prototype.ReportParticle=function(a,b){return!1};goog.exportProperty(box2d.b2ParticleSystem.SolveCollisionCallback.prototype,"ReportParticle",box2d.b2ParticleSystem.SolveCollisionCallback.prototype.ReportParticle);
+box2d.b2ParticleSystem.prototype.SolveCollision=function(a){var b=this.m_positionBuffer.data,c=this.m_velocityBuffer.data,d=box2d.b2ParticleSystem.prototype.SolveCollision.s_aabb;d.lowerBound.x=+box2d.b2_maxFloat;d.lowerBound.y=+box2d.b2_maxFloat;d.upperBound.x=-box2d.b2_maxFloat;d.upperBound.y=-box2d.b2_maxFloat;for(var e=0;e<this.m_count;e++){var f=c[e],g=b[e],h=g.x+a.dt*f.x,f=g.y+a.dt*f.y;d.lowerBound.x=box2d.b2Min(d.lowerBound.x,box2d.b2Min(g.x,h));d.lowerBound.y=box2d.b2Min(d.lowerBound.y,box2d.b2Min(g.y,
+f));d.upperBound.x=box2d.b2Max(d.upperBound.x,box2d.b2Max(g.x,h));d.upperBound.y=box2d.b2Max(d.upperBound.y,box2d.b2Max(g.y,f))}a=new box2d.b2ParticleSystem.SolveCollisionCallback(this,a);this.m_world.QueryAABB(a,d)};box2d.b2ParticleSystem.prototype.SolveCollision.s_aabb=new box2d.b2AABB;
+box2d.b2ParticleSystem.prototype.LimitVelocity=function(a){var b=this.m_velocityBuffer.data;a=this.GetCriticalVelocitySquared(a);for(var c=0;c<this.m_count;c++){var d=b[c],e=box2d.b2Dot_V2_V2(d,d);e>a&&d.SelfMul(box2d.b2Sqrt(a/e))}};box2d.b2ParticleSystem.prototype.SolveGravity=function(a){var b=box2d.b2ParticleSystem.prototype.SolveGravity.s_gravity,c=this.m_velocityBuffer.data;a=box2d.b2Mul_S_V2(a.dt*this.m_def.gravityScale,this.m_world.GetGravity(),b);for(b=0;b<this.m_count;b++)c[b].SelfAdd(a)};
+box2d.b2ParticleSystem.prototype.SolveGravity.s_gravity=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.SolveBarrier=function(a){for(var b=box2d.b2ParticleSystem.prototype.SolveBarrier.s_aabb,c=box2d.b2ParticleSystem.prototype.SolveBarrier.s_va,d=box2d.b2ParticleSystem.prototype.SolveBarrier.s_vb,e=box2d.b2ParticleSystem.prototype.SolveBarrier.s_pba,f=box2d.b2ParticleSystem.prototype.SolveBarrier.s_vba,g=box2d.b2ParticleSystem.prototype.SolveBarrier.s_vc,h=box2d.b2ParticleSystem.prototype.SolveBarrier.s_pca,k=box2d.b2ParticleSystem.prototype.SolveBarrier.s_vca,l=box2d.b2ParticleSystem.prototype.SolveBarrier.s_qba,
+m=box2d.b2ParticleSystem.prototype.SolveBarrier.s_qca,n=box2d.b2ParticleSystem.prototype.SolveBarrier.s_dv,p=box2d.b2ParticleSystem.prototype.SolveBarrier.s_f,q=this.m_positionBuffer.data,r=this.m_velocityBuffer.data,u=0;u<this.m_count;u++)0!==(this.m_flagsBuffer.data[u]&box2d.b2ParticleSystem.k_barrierWallFlags)&&r[u].SetZero();for(var u=box2d.b2_barrierCollisionTime*a.dt,t=this.GetParticleMass(),w=0;w<this.m_pairBuffer.count;w++){var x=this.m_pairBuffer.data[w];if(x.flags&box2d.b2ParticleFlag.b2_barrierParticle){var v=
+x.indexA,y=x.indexB,x=q[v],z=q[y],B=b;box2d.b2Min_V2_V2(x,z,B.lowerBound);box2d.b2Max_V2_V2(x,z,B.upperBound);for(var E=this.m_groupBuffer[v],F=this.m_groupBuffer[y],v=this.GetLinearVelocity(E,v,x,c),y=this.GetLinearVelocity(F,y,z,d),z=box2d.b2Sub_V2_V2(z,x,e),y=box2d.b2Sub_V2_V2(y,v,f),B=this.GetInsideBoundsEnumerator(B),G;0<=(G=B.GetNext());){var H=q[G],I=this.m_groupBuffer[G];if(E!==I&&F!==I){var C=this.GetLinearVelocity(I,G,H,g),A=box2d.b2Sub_V2_V2(H,x,h),K=box2d.b2Sub_V2_V2(C,v,k),J=box2d.b2Cross_V2_V2(y,
+K),D=box2d.b2Cross_V2_V2(z,K)-box2d.b2Cross_V2_V2(A,y),L=box2d.b2Cross_V2_V2(z,A),M=l,N=m;if(0===J){if(0===D)continue;L=-L/D;if(!(0<=L&&L<u))continue;box2d.b2AddMul_V2_S_V2(z,L,y,M);box2d.b2AddMul_V2_S_V2(A,L,K,N);D=box2d.b2Dot_V2_V2(M,N)/box2d.b2Dot_V2_V2(M,M);if(!(0<=D&&1>=D))continue}else{L=D*D-4*L*J;if(0>L)continue;var O=box2d.b2Sqrt(L),L=(-D-O)/(2*J),J=(-D+O)/(2*J);L>J&&(D=L,L=J,J=D);box2d.b2AddMul_V2_S_V2(z,L,y,M);box2d.b2AddMul_V2_S_V2(A,L,K,N);D=box2d.b2Dot_V2_V2(M,N)/box2d.b2Dot_V2_V2(M,
+M);if(!(0<=L&&L<u&&0<=D&&1>=D)){L=J;if(!(0<=L&&L<u))continue;box2d.b2AddMul_V2_S_V2(z,L,y,M);box2d.b2AddMul_V2_S_V2(A,L,K,N);D=box2d.b2Dot_V2_V2(M,N)/box2d.b2Dot_V2_V2(M,M);if(!(0<=D&&1>=D))continue}}A=n;A.x=v.x+D*y.x-C.x;A.y=v.y+D*y.y-C.y;C=box2d.b2Mul_S_V2(t,A,p);this.IsRigidGroup(I)?(t=I.GetMass(),A=I.GetInertia(),0<t&&I.m_linearVelocity.SelfMulAdd(1/t,C),0<A&&(I.m_angularVelocity+=box2d.b2Cross_V2_V2(box2d.b2Sub_V2_V2(H,I.GetCenter(),box2d.b2Vec2.s_t0),C)/A)):r[G].SelfAdd(A);this.ParticleApplyForce(G,
+C.SelfMul(-a.inv_dt))}}}}};box2d.b2ParticleSystem.prototype.SolveBarrier.s_aabb=new box2d.b2AABB;box2d.b2ParticleSystem.prototype.SolveBarrier.s_va=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveBarrier.s_vb=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveBarrier.s_pba=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveBarrier.s_vba=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveBarrier.s_vc=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveBarrier.s_pca=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.SolveBarrier.s_vca=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveBarrier.s_qba=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveBarrier.s_qca=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveBarrier.s_dv=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveBarrier.s_f=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.SolveStaticPressure=function(a){this.m_staticPressureBuffer=this.RequestBuffer(this.m_staticPressureBuffer);var b=this.GetCriticalPressure(a);a=this.m_def.staticPressureStrength*b;for(var b=box2d.b2_maxParticlePressure*b,c=this.m_def.staticPressureRelaxation,d=0;d<this.m_def.staticPressureIterations;d++){for(var e=0;e<this.m_count;e++)this.m_accumulationBuffer[e]=0;for(e=0;e<this.m_contactBuffer.count;e++){var f=this.m_contactBuffer.data[e];if(f.flags&box2d.b2ParticleFlag.b2_staticPressureParticle){var g=
+f.indexA,h=f.indexB,f=f.weight;this.m_accumulationBuffer[g]+=f*this.m_staticPressureBuffer[h];this.m_accumulationBuffer[h]+=f*this.m_staticPressureBuffer[g]}}for(e=0;e<this.m_count;e++)f=this.m_weightBuffer[e],this.m_staticPressureBuffer[e]=this.m_flagsBuffer.data[e]&box2d.b2ParticleFlag.b2_staticPressureParticle?box2d.b2Clamp((this.m_accumulationBuffer[e]+a*(f-box2d.b2_minParticleWeight))/(f+c),0,b):0}};
+box2d.b2ParticleSystem.prototype.ComputeWeight=function(){for(var a=0;a<this.m_count;a++)this.m_weightBuffer[a]=0;for(a=0;a<this.m_bodyContactBuffer.count;a++){var b=this.m_bodyContactBuffer.data[a],c=b.index,b=b.weight;this.m_weightBuffer[c]+=b}for(a=0;a<this.m_contactBuffer.count;a++){var b=this.m_contactBuffer.data[a],c=b.indexA,d=b.indexB,b=b.weight;this.m_weightBuffer[c]+=b;this.m_weightBuffer[d]+=b}};
+box2d.b2ParticleSystem.prototype.SolvePressure=function(a){for(var b=box2d.b2ParticleSystem.prototype.SolvePressure.s_f,c=this.m_positionBuffer.data,d=this.m_velocityBuffer.data,e=this.GetCriticalPressure(a),f=this.m_def.pressureStrength*e,g=box2d.b2_maxParticlePressure*e,h=0;h<this.m_count;h++){var e=this.m_weightBuffer[h],k=f*box2d.b2Max(0,e-box2d.b2_minParticleWeight);this.m_accumulationBuffer[h]=box2d.b2Min(k,g)}if(this.m_allParticleFlags&box2d.b2ParticleSystem.k_noPressureFlags)for(h=0;h<this.m_count;h++)this.m_flagsBuffer.data[h]&
+box2d.b2ParticleSystem.k_noPressureFlags&&(this.m_accumulationBuffer[h]=0);if(this.m_allParticleFlags&box2d.b2ParticleFlag.b2_staticPressureParticle)for(box2d.b2Assert(null!==this.m_staticPressureBuffer),h=0;h<this.m_count;h++)this.m_flagsBuffer.data[h]&box2d.b2ParticleFlag.b2_staticPressureParticle&&(this.m_accumulationBuffer[h]+=this.m_staticPressureBuffer[h]);a=a.dt/(this.m_def.density*this.m_particleDiameter);g=this.GetParticleInvMass();for(h=0;h<this.m_bodyContactBuffer.count;h++){var k=this.m_bodyContactBuffer.data[h],
+l=k.index,m=k.body,e=k.weight,n=k.mass,p=k.normal,q=c[l],k=this.m_accumulationBuffer[l]+f*e,e=box2d.b2Mul_S_V2(a*e*n*k,p,b);d[l].SelfMulSub(g,e);m.ApplyLinearImpulse(e,q,!0)}for(h=0;h<this.m_contactBuffer.count;h++)k=this.m_contactBuffer.data[h],l=k.indexA,m=k.indexB,e=k.weight,p=k.normal,k=this.m_accumulationBuffer[l]+this.m_accumulationBuffer[m],e=box2d.b2Mul_S_V2(a*e*k,p,b),d[l].SelfSub(e),d[m].SelfAdd(e)};box2d.b2ParticleSystem.prototype.SolvePressure.s_f=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.SolveDamping=function(a){var b=box2d.b2ParticleSystem.prototype.SolveDamping.s_v,c=box2d.b2ParticleSystem.prototype.SolveDamping.s_f,d=this.m_positionBuffer.data,e=this.m_velocityBuffer.data,f=this.m_def.dampingStrength;a=1/this.GetCriticalVelocity(a);for(var g=this.GetParticleInvMass(),h=0;h<this.m_bodyContactBuffer.count;h++){var k=this.m_bodyContactBuffer.data[h],l=k.index,m=k.body,n=k.weight,p=k.mass,q=k.normal,k=d[l],r=box2d.b2Sub_V2_V2(m.GetLinearVelocityFromWorldPoint(k,
+box2d.b2Vec2.s_t0),e[l],b),r=box2d.b2Dot_V2_V2(r,q);0>r&&(n=box2d.b2Max(f*n,box2d.b2Min(-a*r,.5)),p=box2d.b2Mul_S_V2(n*p*r,q,c),e[l].SelfMulAdd(g,p),m.ApplyLinearImpulse(p.SelfNeg(),k,!0))}for(h=0;h<this.m_contactBuffer.count;h++)k=this.m_contactBuffer.data[h],l=k.indexA,m=k.indexB,n=k.weight,q=k.normal,r=box2d.b2Sub_V2_V2(e[m],e[l],b),r=box2d.b2Dot_V2_V2(r,q),0>r&&(n=box2d.b2Max(f*n,box2d.b2Min(-a*r,.5)),p=box2d.b2Mul_S_V2(n*r,q,c),e[l].SelfAdd(p),e[m].SelfSub(p))};
+box2d.b2ParticleSystem.prototype.SolveDamping.s_v=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveDamping.s_f=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.SolveRigidDamping=function(){for(var a=box2d.b2ParticleSystem.prototype.SolveRigidDamping.s_t0,b=box2d.b2ParticleSystem.prototype.SolveRigidDamping.s_t1,c=box2d.b2ParticleSystem.prototype.SolveRigidDamping.s_p,d=box2d.b2ParticleSystem.prototype.SolveRigidDamping.s_v,e=[0],f=[0],g=[0],h=[0],k=[0],l=[0],m=this.m_positionBuffer.data,n=this.m_def.dampingStrength,p=0;p<this.m_bodyContactBuffer.count;p++){var q=this.m_bodyContactBuffer.data[p],r=q.index,u=this.m_groupBuffer[r];
+if(this.IsRigidGroup(u)){var t=q.body,w=q.normal,x=q.weight,q=m[r],v=box2d.b2Sub_V2_V2(t.GetLinearVelocityFromWorldPoint(q,a),u.GetLinearVelocityFromWorldPoint(q,b),d),v=box2d.b2Dot_V2_V2(v,w);0>v&&(this.InitDampingParameterWithRigidGroupOrParticle(e,f,g,!0,u,r,q,w),this.InitDampingParameter(h,k,l,t.GetMass(),t.GetInertia()-t.GetMass()*t.GetLocalCenter().LengthSquared(),t.GetWorldCenter(),q,w),x=n*box2d.b2Min(x,1)*this.ComputeDampingImpulse(e[0],f[0],g[0],h[0],k[0],l[0],v),this.ApplyDamping(e[0],
+f[0],g[0],!0,u,r,x,w),t.ApplyLinearImpulse(box2d.b2Mul_S_V2(-x,w,box2d.b2Vec2.s_t0),q,!0))}}for(p=0;p<this.m_contactBuffer.count;p++){var q=this.m_contactBuffer.data[p],r=q.indexA,t=q.indexB,w=q.normal,x=q.weight,u=this.m_groupBuffer[r],y=this.m_groupBuffer[t],z=this.IsRigidGroup(u),B=this.IsRigidGroup(y);u!==y&&(z||B)&&(q=box2d.b2Mid_V2_V2(m[r],m[t],c),v=box2d.b2Sub_V2_V2(this.GetLinearVelocity(y,t,q,a),this.GetLinearVelocity(u,r,q,b),d),v=box2d.b2Dot_V2_V2(v,w),0>v&&(this.InitDampingParameterWithRigidGroupOrParticle(e,
+f,g,z,u,r,q,w),this.InitDampingParameterWithRigidGroupOrParticle(h,k,l,B,y,t,q,w),x=n*x*this.ComputeDampingImpulse(e[0],f[0],g[0],h[0],k[0],l[0],v),this.ApplyDamping(e[0],f[0],g[0],z,u,r,x,w),this.ApplyDamping(h[0],k[0],l[0],B,y,t,-x,w)))}};box2d.b2ParticleSystem.prototype.SolveRigidDamping.s_t0=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveRigidDamping.s_t1=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveRigidDamping.s_p=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.SolveRigidDamping.s_v=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.SolveExtraDamping=function(){for(var a=box2d.b2ParticleSystem.prototype.SolveExtraDamping.s_v,b=box2d.b2ParticleSystem.prototype.SolveExtraDamping.s_f,c=this.m_velocityBuffer.data,d=this.m_positionBuffer.data,e=this.GetParticleInvMass(),f=0;f<this.m_bodyContactBuffer.count;f++){var g=this.m_bodyContactBuffer.data[f],h=g.index;if(this.m_flagsBuffer.data[h]&box2d.b2ParticleSystem.k_extraDampingFlags){var k=g.body,l=g.mass,m=g.normal,g=d[h],n=box2d.b2Sub_V2_V2(k.GetLinearVelocityFromWorldPoint(g,
+box2d.b2Vec2.s_t0),c[h],a),n=box2d.b2Dot_V2_V2(n,m);0>n&&(l=box2d.b2Mul_S_V2(.5*l*n,m,b),c[h].SelfMulAdd(e,l),k.ApplyLinearImpulse(l.SelfNeg(),g,!0))}}};box2d.b2ParticleSystem.prototype.SolveExtraDamping.s_v=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveExtraDamping.s_f=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveWall=function(){for(var a=this.m_velocityBuffer.data,b=0;b<this.m_count;b++)this.m_flagsBuffer.data[b]&box2d.b2ParticleFlag.b2_wallParticle&&a[b].SetZero()};
+box2d.b2ParticleSystem.prototype.SolveRigid=function(a){for(var b=box2d.b2ParticleSystem.prototype.SolveRigid.s_position,c=box2d.b2ParticleSystem.prototype.SolveRigid.s_rotation,d=box2d.b2ParticleSystem.prototype.SolveRigid.s_transform,e=box2d.b2ParticleSystem.prototype.SolveRigid.s_velocityTransform,f=this.m_positionBuffer.data,g=this.m_velocityBuffer.data,h=this.m_groupList;h;h=h.GetNext())if(h.m_groupFlags&box2d.b2ParticleGroupFlag.b2_rigidParticleGroup){h.UpdateStatistics();var k=c;k.SetAngle(a.dt*
+h.m_angularVelocity);var l=box2d.b2Add_V2_V2(h.m_center,box2d.b2Sub_V2_V2(box2d.b2Mul_S_V2(a.dt,h.m_linearVelocity,box2d.b2Vec2.s_t0),box2d.b2Mul_R_V2(k,h.m_center,box2d.b2Vec2.s_t1),box2d.b2Vec2.s_t0),b),m=d;m.SetPositionRotation(l,k);box2d.b2Mul_X_X(m,h.m_transform,h.m_transform);k=e;k.p.x=a.inv_dt*m.p.x;k.p.y=a.inv_dt*m.p.y;k.q.s=a.inv_dt*m.q.s;k.q.c=a.inv_dt*(m.q.c-1);for(m=h.m_firstIndex;m<h.m_lastIndex;m++)box2d.b2Mul_X_V2(k,f[m],g[m])}};
+box2d.b2ParticleSystem.prototype.SolveRigid.s_position=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveRigid.s_rotation=new box2d.b2Rot;box2d.b2ParticleSystem.prototype.SolveRigid.s_transform=new box2d.b2Transform;box2d.b2ParticleSystem.prototype.SolveRigid.s_velocityTransform=new box2d.b2Transform;
+box2d.b2ParticleSystem.prototype.SolveElastic=function(a){for(var b=box2d.b2ParticleSystem.prototype.SolveElastic.s_pa,c=box2d.b2ParticleSystem.prototype.SolveElastic.s_pb,d=box2d.b2ParticleSystem.prototype.SolveElastic.s_pc,e=box2d.b2ParticleSystem.prototype.SolveElastic.s_r,f=box2d.b2ParticleSystem.prototype.SolveElastic.s_t0,g=this.m_positionBuffer.data,h=this.m_velocityBuffer.data,k=a.inv_dt*this.m_def.elasticStrength,l=0;l<this.m_triadBuffer.count;l++){var m=this.m_triadBuffer.data[l];if(m.flags&
+box2d.b2ParticleFlag.b2_elasticParticle){var n=m.indexA,p=m.indexB,q=m.indexC,r=m.pa,u=m.pb,t=m.pc,w=b.Copy(g[n]),x=c.Copy(g[p]),v=d.Copy(g[q]),n=h[n],p=h[p],q=h[q];w.SelfMulAdd(a.dt,n);x.SelfMulAdd(a.dt,p);v.SelfMulAdd(a.dt,q);var y=(w.x+x.x+v.x)/3,z=(w.y+x.y+v.y)/3;w.x-=y;w.y-=z;x.x-=y;x.y-=z;v.x-=y;v.y-=z;y=e;y.s=box2d.b2Cross_V2_V2(r,w)+box2d.b2Cross_V2_V2(u,x)+box2d.b2Cross_V2_V2(t,v);y.c=box2d.b2Dot_V2_V2(r,w)+box2d.b2Dot_V2_V2(u,x)+box2d.b2Dot_V2_V2(t,v);z=box2d.b2InvSqrt(y.s*y.s+y.c*y.c);
+isFinite(z)||(z=1.9817753699999998E19);y.s*=z;y.c*=z;y.angle=Math.atan2(y.s,y.c);m=k*m.strength;box2d.b2Mul_R_V2(y,r,f);box2d.b2Sub_V2_V2(f,w,f);box2d.b2Mul_S_V2(m,f,f);n.SelfAdd(f);box2d.b2Mul_R_V2(y,u,f);box2d.b2Sub_V2_V2(f,x,f);box2d.b2Mul_S_V2(m,f,f);p.SelfAdd(f);box2d.b2Mul_R_V2(y,t,f);box2d.b2Sub_V2_V2(f,v,f);box2d.b2Mul_S_V2(m,f,f);q.SelfAdd(f)}}};box2d.b2ParticleSystem.prototype.SolveElastic.s_pa=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveElastic.s_pb=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.SolveElastic.s_pc=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveElastic.s_r=new box2d.b2Rot;box2d.b2ParticleSystem.prototype.SolveElastic.s_t0=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.SolveSpring=function(a){for(var b=box2d.b2ParticleSystem.prototype.SolveSpring.s_pa,c=box2d.b2ParticleSystem.prototype.SolveSpring.s_pb,d=box2d.b2ParticleSystem.prototype.SolveSpring.s_d,e=box2d.b2ParticleSystem.prototype.SolveSpring.s_f,f=this.m_positionBuffer.data,g=this.m_velocityBuffer.data,h=a.inv_dt*this.m_def.springStrength,k=0;k<this.m_pairBuffer.count;k++){var l=this.m_pairBuffer.data[k];if(l.flags&box2d.b2ParticleFlag.b2_springParticle){var m=l.indexA,n=
+l.indexB,p=b.Copy(f[m]),q=c.Copy(f[n]),m=g[m],n=g[n];p.SelfMulAdd(a.dt,m);q.SelfMulAdd(a.dt,n);var p=box2d.b2Sub_V2_V2(q,p,d),q=l.distance,r=p.Length(),l=box2d.b2Mul_S_V2(h*l.strength*(q-r)/r,p,e);m.SelfSub(l);n.SelfAdd(l)}}};box2d.b2ParticleSystem.prototype.SolveSpring.s_pa=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveSpring.s_pb=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveSpring.s_d=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveSpring.s_f=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.SolveTensile=function(a){var b=box2d.b2ParticleSystem.prototype.SolveTensile.s_weightedNormal,c=box2d.b2ParticleSystem.prototype.SolveTensile.s_s,d=box2d.b2ParticleSystem.prototype.SolveTensile.s_f,e=this.m_velocityBuffer.data;box2d.b2Assert(null!==this.m_accumulation2Buffer);for(var f=0;f<this.m_count;f++)this.m_accumulation2Buffer[f]=box2d.b2Vec2_zero.Clone(),this.m_accumulation2Buffer[f].SetZero();for(f=0;f<this.m_contactBuffer.count;f++){var g=this.m_contactBuffer.data[f];
+if(g.flags&box2d.b2ParticleFlag.b2_tensileParticle){var h=g.indexA,k=g.indexB,l=g.weight,g=g.normal,l=box2d.b2Mul_S_V2((1-l)*l,g,b);this.m_accumulation2Buffer[h].SelfSub(l);this.m_accumulation2Buffer[k].SelfAdd(l)}}f=this.GetCriticalVelocity(a);a=this.m_def.surfaceTensionPressureStrength*f;for(var b=this.m_def.surfaceTensionNormalStrength*f,m=box2d.b2_maxParticleForce*f,f=0;f<this.m_contactBuffer.count;f++)if(g=this.m_contactBuffer.data[f],g.flags&box2d.b2ParticleFlag.b2_tensileParticle){var h=g.indexA,
+k=g.indexB,l=g.weight,g=g.normal,n=this.m_weightBuffer[h]+this.m_weightBuffer[k],p=box2d.b2Sub_V2_V2(this.m_accumulation2Buffer[k],this.m_accumulation2Buffer[h],c),l=box2d.b2Min(a*(n-2)+b*box2d.b2Dot_V2_V2(p,g),m)*l,l=box2d.b2Mul_S_V2(l,g,d);e[h].SelfSub(l);e[k].SelfAdd(l)}};box2d.b2ParticleSystem.prototype.SolveTensile.s_weightedNormal=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveTensile.s_s=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveTensile.s_f=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.SolveViscous=function(){for(var a=box2d.b2ParticleSystem.prototype.SolveViscous.s_v,b=box2d.b2ParticleSystem.prototype.SolveViscous.s_f,c=this.m_positionBuffer.data,d=this.m_velocityBuffer.data,e=this.m_def.viscousStrength,f=this.GetParticleInvMass(),g=0;g<this.m_bodyContactBuffer.count;g++){var h=this.m_bodyContactBuffer.data[g],k=h.index;if(this.m_flagsBuffer.data[k]&box2d.b2ParticleFlag.b2_viscousParticle){var l=h.body,m=h.weight,n=h.mass,h=c[k],p=box2d.b2Sub_V2_V2(l.GetLinearVelocityFromWorldPoint(h,
+box2d.b2Vec2.s_t0),d[k],a),m=box2d.b2Mul_S_V2(e*n*m,p,b);d[k].SelfMulAdd(f,m);l.ApplyLinearImpulse(m.SelfNeg(),h,!0)}}for(g=0;g<this.m_contactBuffer.count;g++)h=this.m_contactBuffer.data[g],h.flags&box2d.b2ParticleFlag.b2_viscousParticle&&(k=h.indexA,l=h.indexB,m=h.weight,p=box2d.b2Sub_V2_V2(d[l],d[k],a),m=box2d.b2Mul_S_V2(e*m,p,b),d[k].SelfAdd(m),d[l].SelfSub(m))};box2d.b2ParticleSystem.prototype.SolveViscous.s_v=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveViscous.s_f=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.SolveRepulsive=function(a){var b=box2d.b2ParticleSystem.prototype.SolveRepulsive.s_f,c=this.m_velocityBuffer.data;a=this.m_def.repulsiveStrength*this.GetCriticalVelocity(a);for(var d=0;d<this.m_contactBuffer.count;d++){var e=this.m_contactBuffer.data[d];if(e.flags&box2d.b2ParticleFlag.b2_repulsiveParticle){var f=e.indexA,g=e.indexB;this.m_groupBuffer[f]!==this.m_groupBuffer[g]&&(e=box2d.b2Mul_S_V2(a*e.weight,e.normal,b),c[f].SelfSub(e),c[g].SelfAdd(e))}}};
+box2d.b2ParticleSystem.prototype.SolveRepulsive.s_f=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.SolvePowder=function(a){var b=box2d.b2ParticleSystem.prototype.SolvePowder.s_f,c=this.m_positionBuffer.data,d=this.m_velocityBuffer.data;a=this.m_def.powderStrength*this.GetCriticalVelocity(a);for(var e=1-box2d.b2_particleStride,f=this.GetParticleInvMass(),g=0;g<this.m_bodyContactBuffer.count;g++){var h=this.m_bodyContactBuffer.data[g],k=h.index;if(this.m_flagsBuffer.data[k]&box2d.b2ParticleFlag.b2_powderParticle){var l=h.weight;if(l>e){var m=h.body,n=c[k],p=h.normal,
+h=box2d.b2Mul_S_V2(a*h.mass*(l-e),p,b);d[k].SelfMulSub(f,h);m.ApplyLinearImpulse(h,n,!0)}}}for(g=0;g<this.m_contactBuffer.count;g++)h=this.m_contactBuffer.data[g],h.flags&box2d.b2ParticleFlag.b2_powderParticle&&(l=h.weight,l>e&&(k=h.indexA,m=h.indexB,p=h.normal,h=box2d.b2Mul_S_V2(a*(l-e),p,b),d[k].SelfSub(h),d[m].SelfAdd(h)))};box2d.b2ParticleSystem.prototype.SolvePowder.s_f=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.SolveSolid=function(a){var b=box2d.b2ParticleSystem.prototype.SolveSolid.s_f,c=this.m_velocityBuffer.data;this.m_depthBuffer=this.RequestBuffer(this.m_depthBuffer);a=a.inv_dt*this.m_def.ejectionStrength;for(var d=0;d<this.m_contactBuffer.count;d++){var e=this.m_contactBuffer.data[d],f=e.indexA,g=e.indexB;this.m_groupBuffer[f]!==this.m_groupBuffer[g]&&(e=box2d.b2Mul_S_V2(a*(this.m_depthBuffer[f]+this.m_depthBuffer[g])*e.weight,e.normal,b),c[f].SelfSub(e),c[g].SelfAdd(e))}};
+box2d.b2ParticleSystem.prototype.SolveSolid.s_f=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.SolveForce=function(a){var b=this.m_velocityBuffer.data;a=a.dt*this.GetParticleInvMass();for(var c=0;c<this.m_count;c++)b[c].SelfMulAdd(a,this.m_forceBuffer[c]);this.m_hasForce=!1};
+box2d.b2ParticleSystem.prototype.SolveColorMixing=function(){box2d.b2Assert(null!==this.m_colorBuffer.data);var a=Math.floor(128*this.m_def.colorMixingStrength);if(a)for(var b=0;b<this.m_contactBuffer.count;b++){var c=this.m_contactBuffer.data[b],d=c.indexA,c=c.indexB;this.m_flagsBuffer.data[d]&this.m_flagsBuffer.data[c]&box2d.b2ParticleFlag.b2_colorMixingParticle&&box2d.b2ParticleColor.MixColors(this.m_colorBuffer.data[d],this.m_colorBuffer.data[c],a)}};
+box2d.b2ParticleSystem.prototype.SolveZombie=function(){for(var a=0,b=[],c=0;c<this.m_count;c++)b[c]=box2d.b2_invalidParticleIndex;box2d.b2Assert(b.length===this.m_count);for(var d=0,c=0;c<this.m_count;c++){var e=this.m_flagsBuffer.data[c];if(e&box2d.b2ParticleFlag.b2_zombieParticle){var f=this.m_world.m_destructionListener;e&box2d.b2ParticleFlag.b2_destructionListenerParticle&&f&&f.SayGoodbyeParticle(this,c);this.m_handleIndexBuffer.data&&(f=this.m_handleIndexBuffer.data[c])&&(f.SetIndex(box2d.b2_invalidParticleIndex),
+this.m_handleIndexBuffer.data[c]=null);b[c]=box2d.b2_invalidParticleIndex}else b[c]=a,c!==a&&(this.m_handleIndexBuffer.data&&((f=this.m_handleIndexBuffer.data[c])&&f.SetIndex(a),this.m_handleIndexBuffer.data[a]=f),this.m_flagsBuffer.data[a]=this.m_flagsBuffer.data[c],this.m_lastBodyContactStepBuffer.data&&(this.m_lastBodyContactStepBuffer.data[a]=this.m_lastBodyContactStepBuffer.data[c]),this.m_bodyContactCountBuffer.data&&(this.m_bodyContactCountBuffer.data[a]=this.m_bodyContactCountBuffer.data[c]),
+this.m_consecutiveContactStepsBuffer.data&&(this.m_consecutiveContactStepsBuffer.data[a]=this.m_consecutiveContactStepsBuffer.data[c]),this.m_positionBuffer.data[a].Copy(this.m_positionBuffer.data[c]),this.m_velocityBuffer.data[a].Copy(this.m_velocityBuffer.data[c]),this.m_groupBuffer[a]=this.m_groupBuffer[c],this.m_hasForce&&this.m_forceBuffer[a].Copy(this.m_forceBuffer[c]),this.m_staticPressureBuffer&&(this.m_staticPressureBuffer[a]=this.m_staticPressureBuffer[c]),this.m_depthBuffer&&(this.m_depthBuffer[a]=
+this.m_depthBuffer[c]),this.m_colorBuffer.data&&this.m_colorBuffer.data[a].Copy(this.m_colorBuffer.data[c]),this.m_userDataBuffer.data&&(this.m_userDataBuffer.data[a]=this.m_userDataBuffer.data[c]),this.m_expirationTimeBuffer.data&&(this.m_expirationTimeBuffer.data[a]=this.m_expirationTimeBuffer.data[c])),a++,d|=e}for(c=0;c<this.m_proxyBuffer.count;c++)e=this.m_proxyBuffer.data[c],e.index=b[e.index];this.m_proxyBuffer.RemoveIf(function(a){return 0>a.index});for(c=0;c<this.m_contactBuffer.count;c++)e=
+this.m_contactBuffer.data[c],e.indexA=b[e.indexA],e.indexB=b[e.indexB];this.m_contactBuffer.RemoveIf(function(a){return 0>a.indexA||0>a.indexB});for(c=0;c<this.m_bodyContactBuffer.count;c++)e=this.m_bodyContactBuffer.data[c],e.index=b[e.index];this.m_bodyContactBuffer.RemoveIf(function(a){return 0>a.index});for(c=0;c<this.m_pairBuffer.count;c++)e=this.m_pairBuffer.data[c],e.indexA=b[e.indexA],e.indexB=b[e.indexB];this.m_pairBuffer.RemoveIf(function(a){return 0>a.indexA||0>a.indexB});for(c=0;c<this.m_triadBuffer.count;c++)e=
+this.m_triadBuffer.data[c],e.indexA=b[e.indexA],e.indexB=b[e.indexB],e.indexC=b[e.indexC];this.m_triadBuffer.RemoveIf(function(a){return 0>a.indexA||0>a.indexB||0>a.indexC});if(this.m_indexByExpirationTimeBuffer.data)for(e=c=0;e<this.m_count;e++)f=b[this.m_indexByExpirationTimeBuffer.data[e]],f!==box2d.b2_invalidParticleIndex&&(this.m_indexByExpirationTimeBuffer.data[c++]=f);for(e=this.m_groupList;e;e=e.GetNext()){for(var f=a,g=0,h=!1,c=e.m_firstIndex;c<e.m_lastIndex;c++){var k=b[c];0<=k?(f=box2d.b2Min(f,
+k),g=box2d.b2Max(g,k+1)):h=!0}f<g?(e.m_firstIndex=f,e.m_lastIndex=g,h&&e.m_groupFlags&box2d.b2ParticleGroupFlag.b2_solidParticleGroup&&this.SetGroupFlags(e,e.m_groupFlags|box2d.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth)):(e.m_firstIndex=0,e.m_lastIndex=0,e.m_groupFlags&box2d.b2ParticleGroupFlag.b2_particleGroupCanBeEmpty||this.SetGroupFlags(e,e.m_groupFlags|box2d.b2ParticleGroupFlag.b2_particleGroupWillBeDestroyed))}this.m_count=a;this.m_allParticleFlags=d;this.m_needsUpdateAllParticleFlags=
+!1;for(e=this.m_groupList;e;)a=e.GetNext(),e.m_groupFlags&box2d.b2ParticleGroupFlag.b2_particleGroupWillBeDestroyed&&this.DestroyParticleGroup(e),e=a};
+box2d.b2ParticleSystem.prototype.SolveLifetimes=function(a){box2d.b2Assert(null!==this.m_expirationTimeBuffer.data);box2d.b2Assert(null!==this.m_indexByExpirationTimeBuffer.data);this.m_timeElapsed=this.LifetimeToExpirationTime(a.dt);a=this.GetQuantizedTimeElapsed();var b=this.m_expirationTimeBuffer.data,c=this.m_indexByExpirationTimeBuffer.data,d=this.GetParticleCount();this.m_expirationTimeBufferRequiresSorting&&(box2d.std_sort(c,0,d,function(a,c){var d=b[a],e=b[c],f=0>=d;return f===0>=e?d>e:f}),
+this.m_expirationTimeBufferRequiresSorting=!1);for(--d;0<=d;--d){var e=c[d],f=b[e];if(a<f||0>=f)break;this.DestroyParticle(e)}};
+box2d.b2ParticleSystem.prototype.RotateBuffer=function(a,b,c){function d(d){return d<a?d:d<b?d+c-b:d<c?d+a-b:d}if(a!==b&&b!==c){box2d.b2Assert(b>=a&&b<=c);box2d.std_rotate(this.m_flagsBuffer.data,a,b,c);this.m_lastBodyContactStepBuffer.data&&box2d.std_rotate(this.m_lastBodyContactStepBuffer.data,a,b,c);this.m_bodyContactCountBuffer.data&&box2d.std_rotate(this.m_bodyContactCountBuffer.data,a,b,c);this.m_consecutiveContactStepsBuffer.data&&box2d.std_rotate(this.m_consecutiveContactStepsBuffer.data,
+a,b,c);box2d.std_rotate(this.m_positionBuffer.data,a,b,c);box2d.std_rotate(this.m_velocityBuffer.data,a,b,c);box2d.std_rotate(this.m_groupBuffer,a,b,c);this.m_hasForce&&box2d.std_rotate(this.m_forceBuffer,a,b,c);this.m_staticPressureBuffer&&box2d.std_rotate(this.m_staticPressureBuffer,a,b,c);this.m_depthBuffer&&box2d.std_rotate(this.m_depthBuffer,a,b,c);this.m_colorBuffer.data&&box2d.std_rotate(this.m_colorBuffer.data,a,b,c);this.m_userDataBuffer.data&&box2d.std_rotate(this.m_userDataBuffer.data,
+a,b,c);if(this.m_handleIndexBuffer.data){box2d.std_rotate(this.m_handleIndexBuffer.data,a,b,c);for(var e=a;e<c;++e){var f=this.m_handleIndexBuffer.data[e];f&&f.SetIndex(d(f.GetIndex()))}}if(this.m_expirationTimeBuffer.data){box2d.std_rotate(this.m_expirationTimeBuffer.data,a,b,c);for(var f=this.GetParticleCount(),g=this.m_indexByExpirationTimeBuffer.data,e=0;e<f;++e)g[e]=d(g[e])}for(e=0;e<this.m_proxyBuffer.count;e++)f=this.m_proxyBuffer.data[e],f.index=d(f.index);for(e=0;e<this.m_contactBuffer.count;e++)f=
+this.m_contactBuffer.data[e],f.indexA=d(f.indexA),f.indexB=d(f.indexB);for(e=0;e<this.m_bodyContactBuffer.count;e++)f=this.m_bodyContactBuffer.data[e],f.index=d(f.index);for(e=0;e<this.m_pairBuffer.count;e++)f=this.m_pairBuffer.data[e],f.indexA=d(f.indexA),f.indexB=d(f.indexB);for(e=0;e<this.m_triadBuffer.count;e++)f=this.m_triadBuffer.data[e],f.indexA=d(f.indexA),f.indexB=d(f.indexB),f.indexC=d(f.indexC);for(e=this.m_groupList;e;e=e.GetNext())e.m_firstIndex=d(e.m_firstIndex),e.m_lastIndex=d(e.m_lastIndex-
+1)+1}};box2d.b2ParticleSystem.prototype.GetCriticalVelocity=function(a){return this.m_particleDiameter*a.inv_dt};box2d.b2ParticleSystem.prototype.GetCriticalVelocitySquared=function(a){a=this.GetCriticalVelocity(a);return a*a};box2d.b2ParticleSystem.prototype.GetCriticalPressure=function(a){return this.m_def.density*this.GetCriticalVelocitySquared(a)};box2d.b2ParticleSystem.prototype.GetParticleStride=function(){return box2d.b2_particleStride*this.m_particleDiameter};
+box2d.b2ParticleSystem.prototype.GetParticleMass=function(){var a=this.GetParticleStride();return this.m_def.density*a*a};box2d.b2ParticleSystem.prototype.GetParticleInvMass=function(){var a=1/box2d.b2_particleStride*this.m_inverseDiameter;return this.m_inverseDensity*a*a};box2d.b2ParticleSystem.prototype.GetFixtureContactFilter=function(){return this.m_allParticleFlags&box2d.b2ParticleFlag.b2_fixtureContactFilterParticle?this.m_world.m_contactManager.m_contactFilter:null};
+box2d.b2ParticleSystem.prototype.GetParticleContactFilter=function(){return this.m_allParticleFlags&box2d.b2ParticleFlag.b2_particleContactFilterParticle?this.m_world.m_contactManager.m_contactFilter:null};box2d.b2ParticleSystem.prototype.GetFixtureContactListener=function(){return this.m_allParticleFlags&box2d.b2ParticleFlag.b2_fixtureContactListenerParticle?this.m_world.m_contactManager.m_contactListener:null};
+box2d.b2ParticleSystem.prototype.GetParticleContactListener=function(){return this.m_allParticleFlags&box2d.b2ParticleFlag.b2_particleContactListenerParticle?this.m_world.m_contactManager.m_contactListener:null};box2d.b2ParticleSystem.prototype.SetUserOverridableBuffer=function(a,b,c){box2d.b2Assert(null!==b&&0<c||null===b&&0===c);a.data=b;a.userSuppliedCapacity=c};
+box2d.b2ParticleSystem.prototype.SetGroupFlags=function(a,b){var c=a.m_groupFlags;(c^b)&box2d.b2ParticleGroupFlag.b2_solidParticleGroup&&(b|=box2d.b2ParticleGroupFlag.b2_particleGroupNeedsUpdateDepth);c&~b&&(this.m_needsUpdateAllGroupFlags=!0);~this.m_allGroupFlags&b&&(b&box2d.b2ParticleGroupFlag.b2_solidParticleGroup&&(this.m_depthBuffer=this.RequestBuffer(this.m_depthBuffer)),this.m_allGroupFlags|=b);a.m_groupFlags=b};
+box2d.b2ParticleSystem.prototype.RemoveSpuriousBodyContacts=function(){box2d.std_sort(this.m_bodyContactBuffer.data,0,this.m_bodyContactBuffer.count,box2d.b2ParticleSystem.BodyContactCompare);var a=box2d.b2ParticleSystem.prototype.RemoveSpuriousBodyContacts.s_n,b=box2d.b2ParticleSystem.prototype.RemoveSpuriousBodyContacts.s_pos,c=box2d.b2ParticleSystem.prototype.RemoveSpuriousBodyContacts.s_normal,d=this,e=-1,f=0,g=0;this.m_bodyContactBuffer.count=box2d.std_remove_if(this.m_bodyContactBuffer.data,
+function(h){h.index!==e&&(f=0,e=h.index);if(3<f++)return++g,!0;var k=a.Copy(h.normal);k.SelfMul(d.m_particleDiameter*(1-h.weight));k=box2d.b2Add_V2_V2(d.m_positionBuffer.data[h.index],k,b);if(!h.fixture.TestPoint(k)){for(var l=h.fixture.GetShape().GetChildCount(),m=0;m<l;m++)if(h.fixture.ComputeDistance(k,c,m)<box2d.b2_linearSlop)return!1;++g;return!0}return!1},this.m_bodyContactBuffer.count)};box2d.b2ParticleSystem.prototype.RemoveSpuriousBodyContacts.s_n=new box2d.b2Vec2;
+box2d.b2ParticleSystem.prototype.RemoveSpuriousBodyContacts.s_pos=new box2d.b2Vec2;box2d.b2ParticleSystem.prototype.RemoveSpuriousBodyContacts.s_normal=new box2d.b2Vec2;box2d.b2ParticleSystem.BodyContactCompare=function(a,b){return a.index===b.index?a.weight>b.weight:a.index<b.index};
+box2d.b2ParticleSystem.prototype.DetectStuckParticle=function(a){0>=this.m_stuckThreshold||(++this.m_bodyContactCountBuffer.data[a],2===this.m_bodyContactCountBuffer.data[a]&&(++this.m_consecutiveContactStepsBuffer.data[a],this.m_consecutiveContactStepsBuffer.data[a]>this.m_stuckThreshold&&(this.m_stuckParticleBuffer.data[this.m_stuckParticleBuffer.Append()]=a)),this.m_lastBodyContactStepBuffer.data[a]=this.m_timestamp)};
+box2d.b2ParticleSystem.prototype.ValidateParticleIndex=function(a){return 0<=a&&a<this.GetParticleCount()&&a!==box2d.b2_invalidParticleIndex};box2d.b2ParticleSystem.prototype.GetQuantizedTimeElapsed=function(){return Math.floor(this.m_timeElapsed/4294967296)};box2d.b2ParticleSystem.prototype.LifetimeToExpirationTime=function(a){return this.m_timeElapsed+Math.floor(a/this.m_def.lifetimeGranularity*4294967296)};box2d.b2ParticleSystem.prototype.ForceCanBeApplied=function(a){return!(a&box2d.b2ParticleFlag.b2_wallParticle)};
+box2d.b2ParticleSystem.prototype.PrepareForceBuffer=function(){if(!this.m_hasForce){for(var a=0;a<this.m_count;a++)this.m_forceBuffer[a].SetZero();this.m_hasForce=!0}};box2d.b2ParticleSystem.prototype.IsRigidGroup=function(a){return null!==a&&0!==(a.m_groupFlags&box2d.b2ParticleGroupFlag.b2_rigidParticleGroup)};box2d.b2ParticleSystem.prototype.GetLinearVelocity=function(a,b,c,d){return this.IsRigidGroup(a)?a.GetLinearVelocityFromWorldPoint(c,d):d.Copy(this.m_velocityBuffer.data[b])};
+box2d.b2ParticleSystem.prototype.InitDampingParameter=function(a,b,c,d,e,f,g,h){a[0]=0<d?1/d:0;b[0]=0<e?1/e:0;c[0]=box2d.b2Cross_V2_V2(box2d.b2Sub_V2_V2(g,f,box2d.b2Vec2.s_t0),h)};box2d.b2ParticleSystem.prototype.InitDampingParameterWithRigidGroupOrParticle=function(a,b,c,d,e,f,g,h){d?this.InitDampingParameter(a,b,c,e.GetMass(),e.GetInertia(),e.GetCenter(),g,h):this.InitDampingParameter(a,b,c,this.m_flagsBuffer.data[f]&box2d.b2ParticleFlag.b2_wallParticle?0:this.GetParticleMass(),0,g,g,h)};
+box2d.b2ParticleSystem.prototype.ComputeDampingImpulse=function(a,b,c,d,e,f,g){a=a+b*c*c+d+e*f*f;return 0<a?g/a:0};box2d.b2ParticleSystem.prototype.ApplyDamping=function(a,b,c,d,e,f,g,h){d?(e.m_linearVelocity.SelfMulAdd(g*a,h),e.m_angularVelocity+=g*c*b):this.m_velocityBuffer.data[f].SelfMulAdd(g*a,h)};box2d.b2StackQueue=function(a){this.m_buffer=box2d.b2MakeArray(a);this.m_end=a};box2d.b2StackQueue.prototype.m_buffer=null;box2d.b2StackQueue.prototype.m_front=0;box2d.b2StackQueue.prototype.m_back=0;box2d.b2StackQueue.prototype.m_capacity=0;
+box2d.b2StackQueue.prototype.Push=function(a){if(this.m_back>=this.m_capacity){for(var b=this.m_front;b<this.m_back;b++)this.m_buffer[b-this.m_front]=this.m_buffer[b];this.m_back-=this.m_front;this.m_front=0;this.m_back>=this.m_capacity&&(0<this.m_capacity?(this.m_buffer.concat(box2d.b2MakeArray(this.m_capacity)),this.m_capacity*=2):(this.m_buffer.concat(box2d.b2MakeArray(1)),this.m_capacity=1))}this.m_buffer[this.m_back]=a;this.m_back++};
+box2d.b2StackQueue.prototype.Pop=function(){box2d.b2Assert(this.m_front<this.m_back);this.m_buffer[this.m_front]=null;this.m_front++};box2d.b2StackQueue.prototype.Empty=function(){box2d.b2Assert(this.m_front<=this.m_back);return this.m_front===this.m_back};box2d.b2StackQueue.prototype.Front=function(){return this.m_buffer[this.m_front]};box2d.b2VoronoiDiagram=function(a){this.m_generatorBuffer=box2d.b2MakeArray(a,function(a){return new box2d.b2VoronoiDiagram.Generator});this.m_generatorCapacity=a};goog.exportSymbol("box2d.b2VoronoiDiagram",box2d.b2VoronoiDiagram);box2d.b2VoronoiDiagram.prototype.m_generatorBuffer=null;goog.exportProperty(box2d.b2VoronoiDiagram.prototype,"m_generatorBuffer",box2d.b2VoronoiDiagram.prototype.m_generatorBuffer);box2d.b2VoronoiDiagram.prototype.m_generatorCapacity=0;
+box2d.b2VoronoiDiagram.prototype.m_generatorCount=0;box2d.b2VoronoiDiagram.prototype.m_countX=0;box2d.b2VoronoiDiagram.prototype.m_countY=0;box2d.b2VoronoiDiagram.prototype.m_diagram=null;box2d.b2VoronoiDiagram.Generator=function(){this.center=new box2d.b2Vec2};box2d.b2VoronoiDiagram.Generator.prototype.center=null;box2d.b2VoronoiDiagram.Generator.prototype.tag=0;box2d.b2VoronoiDiagram.b2VoronoiDiagramTask=function(a,b,c,d){this.m_x=a;this.m_y=b;this.m_i=c;this.m_generator=d};
+box2d.b2VoronoiDiagram.b2VoronoiDiagramTask.prototype.m_x=0;box2d.b2VoronoiDiagram.b2VoronoiDiagramTask.prototype.m_y=0;box2d.b2VoronoiDiagram.b2VoronoiDiagramTask.prototype.m_i=0;box2d.b2VoronoiDiagram.b2VoronoiDiagramTask.prototype.m_generator=null;box2d.b2VoronoiDiagram.prototype.AddGenerator=function(a,b,c){box2d.b2Assert(this.m_generatorCount<this.m_generatorCapacity);var d=this.m_generatorBuffer[this.m_generatorCount++];d.center.Copy(a);d.tag=b;d.necessary=c};
+goog.exportProperty(box2d.b2VoronoiDiagram.prototype,"AddGenerator",box2d.b2VoronoiDiagram.prototype.AddGenerator);
+box2d.b2VoronoiDiagram.prototype.Generate=function(a,b){box2d.b2Assert(null===this.m_diagram);for(var c=1/a,d=new box2d.b2Vec2(+box2d.b2_maxFloat,+box2d.b2_maxFloat),e=new box2d.b2Vec2(-box2d.b2_maxFloat,-box2d.b2_maxFloat),f=0,g=0;g<this.m_generatorCount;g++){var h=this.m_generatorBuffer[g];h.necessary&&(box2d.b2Min_V2_V2(d,h.center,d),box2d.b2Max_V2_V2(e,h.center,e),++f)}if(0===f)this.m_countY=this.m_countX=0;else{d.x-=b;d.y-=b;e.x+=b;e.y+=b;this.m_countX=1+Math.floor(c*(e.x-d.x));this.m_countY=
+1+Math.floor(c*(e.y-d.y));this.m_diagram=box2d.b2MakeArray(this.m_countX*this.m_countY);e=new box2d.b2StackQueue(4*this.m_countX*this.m_countY);for(g=0;g<this.m_generatorCount;g++){h=this.m_generatorBuffer[g];h.center.SelfSub(d).SelfMul(c);var f=Math.floor(h.center.x),k=Math.floor(h.center.y);0<=f&&0<=k&&f<this.m_countX&&k<this.m_countY&&e.Push(new box2d.b2VoronoiDiagram.b2VoronoiDiagramTask(f,k,f+k*this.m_countX,h))}for(;!e.Empty();)g=e.Front(),f=g.m_x,k=g.m_y,c=g.m_i,h=g.m_generator,e.Pop(),this.m_diagram[c]||
+(this.m_diagram[c]=h,0<f&&e.Push(new box2d.b2VoronoiDiagram.b2VoronoiDiagramTask(f-1,k,c-1,h)),0<k&&e.Push(new box2d.b2VoronoiDiagram.b2VoronoiDiagramTask(f,k-1,c-this.m_countX,h)),f<this.m_countX-1&&e.Push(new box2d.b2VoronoiDiagram.b2VoronoiDiagramTask(f+1,k,c+1,h)),k<this.m_countY-1&&e.Push(new box2d.b2VoronoiDiagram.b2VoronoiDiagramTask(f,k+1,c+this.m_countX,h)));for(k=0;k<this.m_countY;k++)for(f=0;f<this.m_countX-1;f++)c=f+k*this.m_countX,d=this.m_diagram[c],g=this.m_diagram[c+1],d!==g&&(e.Push(new box2d.b2VoronoiDiagram.b2VoronoiDiagramTask(f,
+k,c,g)),e.Push(new box2d.b2VoronoiDiagram.b2VoronoiDiagramTask(f+1,k,c+1,d)));for(k=0;k<this.m_countY-1;k++)for(f=0;f<this.m_countX;f++)c=f+k*this.m_countX,d=this.m_diagram[c],g=this.m_diagram[c+this.m_countX],d!==g&&(e.Push(new box2d.b2VoronoiDiagram.b2VoronoiDiagramTask(f,k,c,g)),e.Push(new box2d.b2VoronoiDiagram.b2VoronoiDiagramTask(f,k+1,c+this.m_countX,d)));for(;!e.Empty();)if(g=e.Front(),f=g.m_x,k=g.m_y,c=g.m_i,g=g.m_generator,e.Pop(),d=this.m_diagram[c],d!==g){var h=d.center.x-f,d=d.center.y-
+k,l=g.center.x-f,m=g.center.y-k;h*h+d*d>l*l+m*m&&(this.m_diagram[c]=g,0<f&&e.Push(new box2d.b2VoronoiDiagram.b2VoronoiDiagramTask(f-1,k,c-1,g)),0<k&&e.Push(new box2d.b2VoronoiDiagram.b2VoronoiDiagramTask(f,k-1,c-this.m_countX,g)),f<this.m_countX-1&&e.Push(new box2d.b2VoronoiDiagram.b2VoronoiDiagramTask(f+1,k,c+1,g)),k<this.m_countY-1&&e.Push(new box2d.b2VoronoiDiagram.b2VoronoiDiagramTask(f,k+1,c+this.m_countX,g)))}}};goog.exportProperty(box2d.b2VoronoiDiagram.prototype,"Generate",box2d.b2VoronoiDiagram.prototype.Generate);
+box2d.b2VoronoiDiagram.prototype.GetNodes=function(a){for(var b=0;b<this.m_countY-1;b++)for(var c=0;c<this.m_countX-1;c++){var d=c+b*this.m_countX,e=this.m_diagram[d],f=this.m_diagram[d+1],g=this.m_diagram[d+this.m_countX],d=this.m_diagram[d+1+this.m_countX];f!==g&&(e!==f&&e!==g&&(e.necessary||f.necessary||g.necessary)&&a(e.tag,f.tag,g.tag),d!==f&&d!==g&&(e.necessary||f.necessary||g.necessary)&&a(f.tag,d.tag,g.tag))}};goog.exportProperty(box2d.b2VoronoiDiagram.prototype,"GetNodes",box2d.b2VoronoiDiagram.prototype.GetNodes);box2d.b2RopeDef=function(){this.vertices=[];this.masses=[];this.gravity=new box2d.b2Vec2};goog.exportSymbol("box2d.b2RopeDef",box2d.b2RopeDef);box2d.b2RopeDef.prototype.vertices=null;box2d.b2RopeDef.prototype.count=0;box2d.b2RopeDef.prototype.masses=null;box2d.b2RopeDef.prototype.gravity=null;box2d.b2RopeDef.prototype.damping=.1;box2d.b2RopeDef.prototype.k2=.9;box2d.b2RopeDef.prototype.k3=.1;box2d.b2Rope=function(){this.m_gravity=new box2d.b2Vec2};goog.exportSymbol("box2d.b2Rope",box2d.b2Rope);
+box2d.b2Rope.prototype.m_count=0;box2d.b2Rope.prototype.m_ps=null;box2d.b2Rope.prototype.m_p0s=null;box2d.b2Rope.prototype.m_vs=null;box2d.b2Rope.prototype.m_ims=null;box2d.b2Rope.prototype.m_Ls=null;box2d.b2Rope.prototype.m_as=null;box2d.b2Rope.prototype.m_gravity=null;box2d.b2Rope.prototype.m_damping=0;box2d.b2Rope.prototype.m_k2=1;box2d.b2Rope.prototype.m_k3=.1;box2d.b2Rope.prototype.GetVertexCount=function(){return this.m_count};goog.exportProperty(box2d.b2Rope.prototype,"GetVertexCount",box2d.b2Rope.prototype.GetVertexCount);
+box2d.b2Rope.prototype.GetVertices=function(){return this.m_ps};goog.exportProperty(box2d.b2Rope.prototype,"GetVertices",box2d.b2Rope.prototype.GetVertices);
+box2d.b2Rope.prototype.Initialize=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(3<=a.count);this.m_count=a.count;this.m_ps=box2d.b2Vec2.MakeArray(this.m_count);this.m_p0s=box2d.b2Vec2.MakeArray(this.m_count);this.m_vs=box2d.b2Vec2.MakeArray(this.m_count);this.m_ims=box2d.b2MakeNumberArray(this.m_count);for(var b=0;b<this.m_count;++b){this.m_ps[b].Copy(a.vertices[b]);this.m_p0s[b].Copy(a.vertices[b]);this.m_vs[b].SetZero();var c=a.masses[b];this.m_ims[b]=0<c?1/c:0}var d=this.m_count-1,c=this.m_count-
+2;this.m_Ls=box2d.b2MakeNumberArray(d);this.m_as=box2d.b2MakeNumberArray(c);for(b=0;b<d;++b){var e=this.m_ps[b],f=this.m_ps[b+1];this.m_Ls[b]=box2d.b2Distance(e,f)}for(b=0;b<c;++b)e=this.m_ps[b],f=this.m_ps[b+1],d=this.m_ps[b+2],e=box2d.b2Sub_V2_V2(f,e,box2d.b2Vec2.s_t0),d=box2d.b2Sub_V2_V2(d,f,box2d.b2Vec2.s_t1),f=box2d.b2Cross_V2_V2(e,d),e=box2d.b2Dot_V2_V2(e,d),this.m_as[b]=box2d.b2Atan2(f,e);this.m_gravity.Copy(a.gravity);this.m_damping=a.damping;this.m_k2=a.k2;this.m_k3=a.k3};
+goog.exportProperty(box2d.b2Rope.prototype,"Initialize",box2d.b2Rope.prototype.Initialize);
+box2d.b2Rope.prototype.Step=function(a,b){if(0!==a){for(var c=Math.exp(-a*this.m_damping),d=0;d<this.m_count;++d)this.m_p0s[d].Copy(this.m_ps[d]),0<this.m_ims[d]&&this.m_vs[d].SelfMulAdd(a,this.m_gravity),this.m_vs[d].SelfMul(c),this.m_ps[d].SelfMulAdd(a,this.m_vs[d]);for(d=0;d<b;++d)this.SolveC2(),this.SolveC3(),this.SolveC2();c=1/a;for(d=0;d<this.m_count;++d)box2d.b2Mul_S_V2(c,box2d.b2Sub_V2_V2(this.m_ps[d],this.m_p0s[d],box2d.b2Vec2.s_t0),this.m_vs[d])}};
+goog.exportProperty(box2d.b2Rope.prototype,"Step",box2d.b2Rope.prototype.Step);box2d.b2Rope.prototype.SolveC2=function(){for(var a=this.m_count-1,b=0;b<a;++b){var c=this.m_ps[b],d=this.m_ps[b+1],e=box2d.b2Sub_V2_V2(d,c,box2d.b2Rope.s_d),f=e.Normalize(),g=this.m_ims[b],h=this.m_ims[b+1];if(0!==g+h){var k=h/(g+h);c.SelfMulSub(g/(g+h)*this.m_k2*(this.m_Ls[b]-f),e);d.SelfMulAdd(this.m_k2*k*(this.m_Ls[b]-f),e)}}};goog.exportProperty(box2d.b2Rope.prototype,"SolveC2",box2d.b2Rope.prototype.SolveC2);
+box2d.b2Rope.s_d=new box2d.b2Vec2;box2d.b2Rope.prototype.SetAngle=function(a){for(var b=this.m_count-2,c=0;c<b;++c)this.m_as[c]=a};goog.exportProperty(box2d.b2Rope.prototype,"SetAngle",box2d.b2Rope.prototype.SetAngle);
+box2d.b2Rope.prototype.SolveC3=function(){for(var a=this.m_count-2,b=0;b<a;++b){var c=this.m_ps[b],d=this.m_ps[b+1],e=this.m_ps[b+2],f=this.m_ims[b],g=this.m_ims[b+1],h=this.m_ims[b+2],k=box2d.b2Sub_V2_V2(d,c,box2d.b2Rope.s_d1),l=box2d.b2Sub_V2_V2(e,d,box2d.b2Rope.s_d2),m=k.LengthSquared(),n=l.LengthSquared();if(0!==m*n){var p=box2d.b2Cross_V2_V2(k,l),q=box2d.b2Dot_V2_V2(k,l),p=box2d.b2Atan2(p,q),k=box2d.b2Mul_S_V2(-1/m,k.SelfSkew(),box2d.b2Rope.s_Jd1),m=box2d.b2Mul_S_V2(1/n,l.SelfSkew(),box2d.b2Rope.s_Jd2),
+l=box2d.b2Rope.s_J1.Copy(k).SelfNeg(),n=box2d.b2Sub_V2_V2(k,m,box2d.b2Rope.s_J2),k=m,m=f*box2d.b2Dot_V2_V2(l,l)+g*box2d.b2Dot_V2_V2(n,n)+h*box2d.b2Dot_V2_V2(k,k);if(0!==m){m=1/m;for(q=p-this.m_as[b];q>box2d.b2_pi;)p-=2*box2d.b2_pi,q=p-this.m_as[b];for(;q<-box2d.b2_pi;)p+=2*box2d.b2_pi,q=p-this.m_as[b];p=-this.m_k3*m*q;c.SelfMulAdd(f*p,l);d.SelfMulAdd(g*p,n);e.SelfMulAdd(h*p,k)}}}};goog.exportProperty(box2d.b2Rope.prototype,"SolveC3",box2d.b2Rope.prototype.SolveC3);box2d.b2Rope.s_d1=new box2d.b2Vec2;
+box2d.b2Rope.s_d2=new box2d.b2Vec2;box2d.b2Rope.s_Jd1=new box2d.b2Vec2;box2d.b2Rope.s_Jd2=new box2d.b2Vec2;box2d.b2Rope.s_J1=new box2d.b2Vec2;box2d.b2Rope.s_J2=new box2d.b2Vec2;box2d.b2Rope.prototype.Draw=function(a){for(var b=new box2d.b2Color(.4,.5,.7),c=0;c<this.m_count-1;++c)a.DrawSegment(this.m_ps[c],this.m_ps[c+1],b)};goog.exportProperty(box2d.b2Rope.prototype,"Draw",box2d.b2Rope.prototype.Draw);box2d.b2ControllerEdge=function(){};goog.exportSymbol("box2d.b2ControllerEdge",box2d.b2ControllerEdge);box2d.b2ControllerEdge.prototype.controller=null;goog.exportProperty(box2d.b2ControllerEdge.prototype,"controller",box2d.b2ControllerEdge.prototype.controller);box2d.b2ControllerEdge.prototype.body=null;goog.exportProperty(box2d.b2ControllerEdge.prototype,"body",box2d.b2ControllerEdge.prototype.body);box2d.b2ControllerEdge.prototype.prevBody=null;
+goog.exportProperty(box2d.b2ControllerEdge.prototype,"prevBody",box2d.b2ControllerEdge.prototype.prevBody);box2d.b2ControllerEdge.prototype.nextBody=null;goog.exportProperty(box2d.b2ControllerEdge.prototype,"nextBody",box2d.b2ControllerEdge.prototype.nextBody);box2d.b2ControllerEdge.prototype.prevController=null;goog.exportProperty(box2d.b2ControllerEdge.prototype,"prevController",box2d.b2ControllerEdge.prototype.prevController);box2d.b2ControllerEdge.prototype.nextController=null;
+goog.exportProperty(box2d.b2ControllerEdge.prototype,"nextController",box2d.b2ControllerEdge.prototype.nextController);box2d.b2Controller=function(){};goog.exportSymbol("box2d.b2Controller",box2d.b2Controller);box2d.b2Controller.prototype.m_world=null;goog.exportProperty(box2d.b2Controller.prototype,"m_world",box2d.b2Controller.prototype.m_world);box2d.b2Controller.prototype.m_bodyList=null;goog.exportProperty(box2d.b2Controller.prototype,"m_bodyList",box2d.b2Controller.prototype.m_bodyList);
+box2d.b2Controller.prototype.m_bodyCount=0;goog.exportProperty(box2d.b2Controller.prototype,"m_bodyCount",box2d.b2Controller.prototype.m_bodyCount);box2d.b2Controller.prototype.m_prev=null;goog.exportProperty(box2d.b2Controller.prototype,"m_prev",box2d.b2Controller.prototype.m_prev);box2d.b2Controller.prototype.m_next=null;goog.exportProperty(box2d.b2Controller.prototype,"m_next",box2d.b2Controller.prototype.m_next);box2d.b2Controller.prototype.Step=function(a){};
+goog.exportProperty(box2d.b2Controller.prototype,"Step",box2d.b2Controller.prototype.Step);box2d.b2Controller.prototype.Draw=function(a){};goog.exportProperty(box2d.b2Controller.prototype,"Draw",box2d.b2Controller.prototype.Draw);box2d.b2Controller.prototype.GetNext=function(){return this.m_next};goog.exportProperty(box2d.b2Controller.prototype,"GetNext",box2d.b2Controller.prototype.GetNext);box2d.b2Controller.prototype.GetPrev=function(){return this.m_prev};
+goog.exportProperty(box2d.b2Controller.prototype,"GetPrev",box2d.b2Controller.prototype.GetPrev);box2d.b2Controller.prototype.GetWorld=function(){return this.m_world};goog.exportProperty(box2d.b2Controller.prototype,"GetWorld",box2d.b2Controller.prototype.GetWorld);box2d.b2Controller.prototype.GetBodyList=function(){return this.m_bodyList};goog.exportProperty(box2d.b2Controller.prototype,"GetBodyList",box2d.b2Controller.prototype.GetBodyList);
+box2d.b2Controller.prototype.AddBody=function(a){var b=new box2d.b2ControllerEdge;b.body=a;b.controller=this;b.nextBody=this.m_bodyList;b.prevBody=null;this.m_bodyList&&(this.m_bodyList.prevBody=b);this.m_bodyList=b;++this.m_bodyCount;b.nextController=a.m_controllerList;b.prevController=null;a.m_controllerList&&(a.m_controllerList.prevController=b);a.m_controllerList=b;++a.m_controllerCount};goog.exportProperty(box2d.b2Controller.prototype,"AddBody",box2d.b2Controller.prototype.AddBody);
+box2d.b2Controller.prototype.RemoveBody=function(a){box2d.ENABLE_ASSERTS&&box2d.b2Assert(0<this.m_bodyCount);for(var b=this.m_bodyList;b&&b.body!==a;)b=b.nextBody;box2d.ENABLE_ASSERTS&&box2d.b2Assert(null!==b);b.prevBody&&(b.prevBody.nextBody=b.nextBody);b.nextBody&&(b.nextBody.prevBody=b.prevBody);this.m_bodyList===b&&(this.m_bodyList=b.nextBody);--this.m_bodyCount;b.nextController&&(b.nextController.prevController=b.prevController);b.prevController&&(b.prevController.nextController=b.nextController);
+a.m_controllerList===b&&(a.m_controllerList=b.nextController);--a.m_controllerCount};goog.exportProperty(box2d.b2Controller.prototype,"RemoveBody",box2d.b2Controller.prototype.RemoveBody);box2d.b2Controller.prototype.Clear=function(){for(;this.m_bodyList;)this.RemoveBody(this.m_bodyList.body);this.m_bodyCount=0};goog.exportProperty(box2d.b2Controller.prototype,"Clear",box2d.b2Controller.prototype.Clear);box2d.b2BuoyancyController=function(){box2d.b2Controller.call(this);this.normal=new box2d.b2Vec2(0,1);this.velocity=new box2d.b2Vec2(0,0);this.gravity=new box2d.b2Vec2(0,0)};goog.inherits(box2d.b2BuoyancyController,box2d.b2Controller);goog.exportSymbol("box2d.b2BuoyancyController",box2d.b2BuoyancyController);box2d.b2BuoyancyController.prototype.normal=null;goog.exportProperty(box2d.b2BuoyancyController.prototype,"normal",box2d.b2BuoyancyController.prototype.normal);
+box2d.b2BuoyancyController.prototype.offset=0;goog.exportProperty(box2d.b2BuoyancyController.prototype,"offset",box2d.b2BuoyancyController.prototype.offset);box2d.b2BuoyancyController.prototype.density=0;goog.exportProperty(box2d.b2BuoyancyController.prototype,"density",box2d.b2BuoyancyController.prototype.density);box2d.b2BuoyancyController.prototype.velocity=null;goog.exportProperty(box2d.b2BuoyancyController.prototype,"velocity",box2d.b2BuoyancyController.prototype.velocity);
+box2d.b2BuoyancyController.prototype.linearDrag=0;goog.exportProperty(box2d.b2BuoyancyController.prototype,"linearDrag",box2d.b2BuoyancyController.prototype.linearDrag);box2d.b2BuoyancyController.prototype.angularDrag=0;goog.exportProperty(box2d.b2BuoyancyController.prototype,"angularDrag",box2d.b2BuoyancyController.prototype.angularDrag);box2d.b2BuoyancyController.prototype.useDensity=!1;goog.exportProperty(box2d.b2BuoyancyController.prototype,"useDensity",box2d.b2BuoyancyController.prototype.useDensity);
+box2d.b2BuoyancyController.prototype.useWorldGravity=!0;goog.exportProperty(box2d.b2BuoyancyController.prototype,"useWorldGravity",box2d.b2BuoyancyController.prototype.useWorldGravity);box2d.b2BuoyancyController.prototype.gravity=null;goog.exportProperty(box2d.b2BuoyancyController.prototype,"gravity",box2d.b2BuoyancyController.prototype.gravity);
+box2d.b2BuoyancyController.prototype.Step=function(a){if(this.m_bodyList)for(this.useWorldGravity&&this.gravity.Copy(this.GetWorld().GetGravity()),a=this.m_bodyList;a;a=a.nextBody){var b=a.body;if(b.IsAwake()){for(var c=new box2d.b2Vec2,d=new box2d.b2Vec2,e=0,f=0,g=b.GetFixtureList();g;g=g.m_next){var h=new box2d.b2Vec2,k=g.GetShape().ComputeSubmergedArea(this.normal,this.offset,b.GetTransform(),h),e=e+k;c.x+=k*h.x;c.y+=k*h.y;var l=0,l=this.useDensity?g.GetDensity():1,f=f+k*l;d.x+=k*h.x*l;d.y+=k*
+h.y*l}c.x/=e;c.y/=e;d.x/=f;d.y/=f;e<box2d.b2_epsilon||(f=this.gravity.Clone().SelfNeg(),f.SelfMul(this.density*e),b.ApplyForce(f,d),d=b.GetLinearVelocityFromWorldPoint(c,new box2d.b2Vec2),d.SelfSub(this.velocity),d.SelfMul(-this.linearDrag*e),b.ApplyForce(d,c),b.ApplyTorque(-b.GetInertia()/b.GetMass()*e*b.GetAngularVelocity()*this.angularDrag))}}};goog.exportProperty(box2d.b2BuoyancyController.prototype,"Step",box2d.b2BuoyancyController.prototype.Step);
+box2d.b2BuoyancyController.prototype.Draw=function(a){var b=new box2d.b2Vec2,c=new box2d.b2Vec2;b.x=this.normal.x*this.offset+100*this.normal.y;b.y=this.normal.y*this.offset-100*this.normal.x;c.x=this.normal.x*this.offset-100*this.normal.y;c.y=this.normal.y*this.offset+100*this.normal.x;var d=new box2d.b2Color(0,0,.8);a.DrawSegment(b,c,d)};goog.exportProperty(box2d.b2BuoyancyController.prototype,"Draw",box2d.b2BuoyancyController.prototype.Draw);box2d.b2ConstantAccelController=function(){box2d.b2Controller.call(this);this.A=new box2d.b2Vec2(0,0)};goog.inherits(box2d.b2ConstantAccelController,box2d.b2Controller);goog.exportSymbol("box2d.b2ConstantAccelController",box2d.b2ConstantAccelController);box2d.b2ConstantAccelController.prototype.A=null;goog.exportProperty(box2d.b2ConstantAccelController.prototype,"A",box2d.b2ConstantAccelController.prototype.A);
+box2d.b2ConstantAccelController.prototype.Step=function(a){a=box2d.b2Mul_S_V2(a.dt,this.A,box2d.b2ConstantAccelController.prototype.Step.s_dtA);for(var b=this.m_bodyList;b;b=b.nextBody){var c=b.body;c.IsAwake()&&c.SetLinearVelocity(box2d.b2Add_V2_V2(c.GetLinearVelocity(),a,box2d.b2Vec2.s_t0))}};goog.exportProperty(box2d.b2ConstantAccelController.prototype,"Step",box2d.b2ConstantAccelController.prototype.Step);box2d.b2ConstantAccelController.prototype.Step.s_dtA=new box2d.b2Vec2;box2d.b2ConstantForceController=function(){box2d.b2Controller.call(this);this.F=new box2d.b2Vec2(0,0)};goog.inherits(box2d.b2ConstantForceController,box2d.b2Controller);goog.exportSymbol("box2d.b2ConstantForceController",box2d.b2ConstantForceController);box2d.b2ConstantAccelController.prototype.F=null;goog.exportProperty(box2d.b2ConstantAccelController.prototype,"F",box2d.b2ConstantAccelController.prototype.F);
+box2d.b2ConstantForceController.prototype.Step=function(a){for(a=this.m_bodyList;a;a=a.nextBody){var b=a.body;b.IsAwake()&&b.ApplyForce(this.F,b.GetWorldCenter())}};goog.exportProperty(box2d.b2ConstantForceController.prototype,"Step",box2d.b2ConstantForceController.prototype.Step);box2d.b2GravityController=function(){box2d.b2Controller.call(this)};goog.inherits(box2d.b2GravityController,box2d.b2Controller);goog.exportSymbol("box2d.b2GravityController",box2d.b2GravityController);box2d.b2GravityController.prototype.G=1;goog.exportProperty(box2d.b2GravityController.prototype,"G",box2d.b2GravityController.prototype.G);box2d.b2GravityController.prototype.invSqr=!0;goog.exportProperty(box2d.b2GravityController.prototype,"invSqr",box2d.b2GravityController.prototype.invSqr);
+box2d.b2GravityController.prototype.Step=function(a){if(this.invSqr)for(a=this.m_bodyList;a;a=a.nextBody)for(var b=a.body,c=b.GetWorldCenter(),d=b.GetMass(),e=this.m_bodyList;e!==a;e=e.nextBody){var f=e.body,g=f.GetWorldCenter(),h=f.GetMass(),k=g.x-c.x,l=g.y-c.y,m=k*k+l*l;m<box2d.b2_epsilon||(k=box2d.b2GravityController.prototype.Step.s_f.Set(k,l),k.SelfMul(this.G/m/box2d.b2Sqrt(m)*d*h),b.IsAwake()&&b.ApplyForce(k,c),f.IsAwake()&&f.ApplyForce(k.SelfMul(-1),g))}else for(a=this.m_bodyList;a;a=a.nextBody)for(b=
+a.body,c=b.GetWorldCenter(),d=b.GetMass(),e=this.m_bodyList;e!==a;e=e.nextBody)f=e.body,g=f.GetWorldCenter(),h=f.GetMass(),k=g.x-c.x,l=g.y-c.y,m=k*k+l*l,m<box2d.b2_epsilon||(k=box2d.b2GravityController.prototype.Step.s_f.Set(k,l),k.SelfMul(this.G/m*d*h),b.IsAwake()&&b.ApplyForce(k,c),f.IsAwake()&&f.ApplyForce(k.SelfMul(-1),g))};goog.exportProperty(box2d.b2GravityController.prototype,"Step",box2d.b2GravityController.prototype.Step);box2d.b2GravityController.prototype.Step.s_f=new box2d.b2Vec2;box2d.b2TensorDampingController=function(){box2d.b2Controller.call(this);this.T=new box2d.b2Mat22;this.maxTimestep=0};goog.inherits(box2d.b2TensorDampingController,box2d.b2Controller);goog.exportSymbol("box2d.b2TensorDampingController",box2d.b2TensorDampingController);box2d.b2TensorDampingController.prototype.T=new box2d.b2Mat22;goog.exportProperty(box2d.b2TensorDampingController.prototype,"T",box2d.b2TensorDampingController.prototype.T);box2d.b2TensorDampingController.prototype.maxTimestep=0;
+goog.exportProperty(box2d.b2TensorDampingController.prototype,"maxTimestep",box2d.b2TensorDampingController.prototype.maxTimestep);
+box2d.b2TensorDampingController.prototype.Step=function(a){a=a.dt;if(!(a<=box2d.b2_epsilon)){a>this.maxTimestep&&0<this.maxTimestep&&(a=this.maxTimestep);for(var b=this.m_bodyList;b;b=b.nextBody){var c=b.body;if(c.IsAwake()){var d=c.GetWorldVector(box2d.b2Mul_M22_V2(this.T,c.GetLocalVector(c.GetLinearVelocity(),box2d.b2Vec2.s_t0),box2d.b2Vec2.s_t1),box2d.b2TensorDampingController.prototype.Step.s_damping);c.SetLinearVelocity(box2d.b2Add_V2_V2(c.GetLinearVelocity(),box2d.b2Mul_S_V2(a,d,box2d.b2Vec2.s_t0),
+box2d.b2Vec2.s_t1))}}}};box2d.b2TensorDampingController.prototype.Step.s_damping=new box2d.b2Vec2;box2d.b2TensorDampingController.prototype.SetAxisAligned=function(a,b){this.T.ex.x=-a;this.T.ex.y=0;this.T.ey.x=0;this.T.ey.y=-b;this.maxTimestep=0<a||0<b?1/box2d.b2Max(a,b):0};
+
+box2d.b2Vec2.SubVV=function(a, b, out) { out.x = a.x - b.x; out.y = a.y - b.y; return out; };
+window.box2d=box2d;
+(function (exports, Laya) {
+    'use strict';
+
+    class IPhysics {
+    }
+    IPhysics.RigidBody = null;
+    IPhysics.Physics = null;
+
+    class ColliderBase extends Laya.Component {
+        constructor() {
+            super(...arguments);
+            this._isSensor = false;
+            this._density = 10;
+            this._friction = 0.2;
+            this._restitution = 0;
+        }
+        getDef() {
+            if (!this._def) {
+                var def = new window.box2d.b2FixtureDef();
+                def.density = this.density;
+                def.friction = this.friction;
+                def.isSensor = this.isSensor;
+                def.restitution = this.restitution;
+                def.shape = this._shape;
+                this._def = def;
+            }
+            return this._def;
+        }
+        _onEnable() {
+            if (this.rigidBody) {
+                this.refresh();
+            }
+            else {
+                Laya.Laya.systemTimer.callLater(this, this._checkRigidBody);
+            }
+        }
+        _checkRigidBody() {
+            if (!this.rigidBody) {
+                var comp = this.owner.getComponent(IPhysics.RigidBody);
+                if (comp) {
+                    this.rigidBody = comp;
+                    this.refresh();
+                }
+            }
+        }
+        _onDestroy() {
+            if (this.rigidBody) {
+                if (this.fixture) {
+                    if (this.fixture.GetBody() == this.rigidBody.body) {
+                        this.rigidBody.body.DestroyFixture(this.fixture);
+                    }
+                    this.fixture = null;
+                }
+                this.rigidBody = null;
+                this._shape = null;
+                this._def = null;
+            }
+        }
+        get isSensor() {
+            return this._isSensor;
+        }
+        set isSensor(value) {
+            this._isSensor = value;
+            if (this._def) {
+                this._def.isSensor = value;
+                this.refresh();
+            }
+        }
+        get density() {
+            return this._density;
+        }
+        set density(value) {
+            this._density = value;
+            if (this._def) {
+                this._def.density = value;
+                this.refresh();
+            }
+        }
+        get friction() {
+            return this._friction;
+        }
+        set friction(value) {
+            this._friction = value;
+            if (this._def) {
+                this._def.friction = value;
+                this.refresh();
+            }
+        }
+        get restitution() {
+            return this._restitution;
+        }
+        set restitution(value) {
+            this._restitution = value;
+            if (this._def) {
+                this._def.restitution = value;
+                this.refresh();
+            }
+        }
+        refresh() {
+            if (this.enabled && this.rigidBody) {
+                var body = this.rigidBody.body;
+                if (this.fixture) {
+                    if (this.fixture.GetBody() == this.rigidBody.body) {
+                        this.rigidBody.body.DestroyFixture(this.fixture);
+                    }
+                    this.fixture.Destroy();
+                    this.fixture = null;
+                }
+                var def = this.getDef();
+                def.filter.groupIndex = this.rigidBody.group;
+                def.filter.categoryBits = this.rigidBody.category;
+                def.filter.maskBits = this.rigidBody.mask;
+                this.fixture = body.CreateFixture(def);
+                this.fixture.collider = this;
+            }
+        }
+        resetShape(re = true) {
+        }
+        get isSingleton() {
+            return false;
+        }
+    }
+    Laya.ClassUtils.regClass("laya.physics.ColliderBase", ColliderBase);
+    Laya.ClassUtils.regClass("Laya.ColliderBase", ColliderBase);
+
+    class RigidBody extends Laya.Component {
+        constructor() {
+            super(...arguments);
+            this._type = "dynamic";
+            this._allowSleep = true;
+            this._angularVelocity = 0;
+            this._angularDamping = 0;
+            this._linearVelocity = { x: 0, y: 0 };
+            this._linearDamping = 0;
+            this._bullet = false;
+            this._allowRotation = true;
+            this._gravityScale = 1;
+            this.group = 0;
+            this.category = 1;
+            this.mask = -1;
+            this.label = "RigidBody";
+        }
+        _createBody() {
+            if (this._body || !this.owner)
+                return;
+            var sp = this.owner;
+            var box2d = window.box2d;
+            var def = new box2d.b2BodyDef();
+            var point = sp.localToGlobal(Laya.Point.TEMP.setTo(0, 0), false, IPhysics.Physics.I.worldRoot);
+            def.position.Set(point.x / IPhysics.Physics.PIXEL_RATIO, point.y / IPhysics.Physics.PIXEL_RATIO);
+            def.angle = Laya.Utils.toRadian(sp.rotation);
+            def.allowSleep = this._allowSleep;
+            def.angularDamping = this._angularDamping;
+            def.angularVelocity = this._angularVelocity;
+            def.bullet = this._bullet;
+            def.fixedRotation = !this._allowRotation;
+            def.gravityScale = this._gravityScale;
+            def.linearDamping = this._linearDamping;
+            var obj = this._linearVelocity;
+            if (obj && obj.x != 0 || obj.y != 0) {
+                def.linearVelocity = new box2d.b2Vec2(obj.x, obj.y);
+            }
+            def.type = box2d.b2BodyType["b2_" + this._type + "Body"];
+            this._body = IPhysics.Physics.I._createBody(def);
+            this.resetCollider(false);
+        }
+        _onAwake() {
+            this._createBody();
+        }
+        _onEnable() {
+            var _$this = this;
+            this._createBody();
+            Laya.Laya.physicsTimer.frameLoop(1, this, this._sysPhysicToNode);
+            var sp = this.owner;
+            if (this.accessGetSetFunc(sp, "x", "set") && !sp._changeByRigidBody) {
+                sp._changeByRigidBody = true;
+                function setX(value) {
+                    _$this.accessGetSetFunc(sp, "x", "set")(value);
+                    _$this._sysPosToPhysic();
+                }
+                this._overSet(sp, "x", setX);
+                function setY(value) {
+                    _$this.accessGetSetFunc(sp, "y", "set")(value);
+                    _$this._sysPosToPhysic();
+                }
+                this._overSet(sp, "y", setY);
+                function setRotation(value) {
+                    _$this.accessGetSetFunc(sp, "rotation", "set")(value);
+                    _$this._sysNodeToPhysic();
+                }
+                this._overSet(sp, "rotation", setRotation);
+                function setScaleX(value) {
+                    _$this.accessGetSetFunc(sp, "scaleX", "set")(value);
+                    _$this.resetCollider(true);
+                }
+                this._overSet(sp, "scaleX", setScaleX);
+                function setScaleY(value) {
+                    _$this.accessGetSetFunc(sp, "scaleY", "set")(value);
+                    _$this.resetCollider(true);
+                }
+                this._overSet(sp, "scaleY", setScaleY);
+            }
+        }
+        accessGetSetFunc(obj, prop, accessor) {
+            if (["get", "set"].indexOf(accessor) === -1) {
+                return;
+            }
+            let privateProp = `_$${accessor}_${prop}`;
+            if (obj[privateProp]) {
+                return obj[privateProp];
+            }
+            let ObjConstructor = obj.constructor;
+            let des;
+            while (ObjConstructor) {
+                des = Object.getOwnPropertyDescriptor(ObjConstructor.prototype, prop);
+                if (des && des[accessor]) {
+                    obj[privateProp] = des[accessor].bind(obj);
+                    break;
+                }
+                ObjConstructor = Object.getPrototypeOf(ObjConstructor);
+            }
+            return obj[privateProp];
+        }
+        resetCollider(resetShape) {
+            var comps = this.owner.getComponents(ColliderBase);
+            if (comps) {
+                for (var i = 0, n = comps.length; i < n; i++) {
+                    var collider = comps[i];
+                    collider.rigidBody = this;
+                    if (resetShape)
+                        collider.resetShape();
+                    else
+                        collider.refresh();
+                }
+            }
+        }
+        _sysPhysicToNode() {
+            if (this.type != "static" && this._body.IsAwake()) {
+                var pos = this._body.GetPosition();
+                var ang = this._body.GetAngle();
+                var sp = this.owner;
+                this.accessGetSetFunc(sp, "rotation", "set")(Laya.Utils.toAngle(ang) - sp.parent.globalRotation);
+                if (ang == 0) {
+                    var point = sp.parent.globalToLocal(Laya.Point.TEMP.setTo(pos.x * IPhysics.Physics.PIXEL_RATIO + sp.pivotX, pos.y * IPhysics.Physics.PIXEL_RATIO + sp.pivotY), false, IPhysics.Physics.I.worldRoot);
+                    this.accessGetSetFunc(sp, "x", "set")(point.x);
+                    this.accessGetSetFunc(sp, "y", "set")(point.y);
+                }
+                else {
+                    point = sp.globalToLocal(Laya.Point.TEMP.setTo(pos.x * IPhysics.Physics.PIXEL_RATIO, pos.y * IPhysics.Physics.PIXEL_RATIO), false, IPhysics.Physics.I.worldRoot);
+                    point.x += sp.pivotX;
+                    point.y += sp.pivotY;
+                    point = sp.toParentPoint(point);
+                    this.accessGetSetFunc(sp, "x", "set")(point.x);
+                    this.accessGetSetFunc(sp, "y", "set")(point.y);
+                }
+            }
+        }
+        _sysNodeToPhysic() {
+            var sp = this.owner;
+            this._body.SetAngle(Laya.Utils.toRadian(sp.rotation));
+            var p = sp.localToGlobal(Laya.Point.TEMP.setTo(0, 0), false, IPhysics.Physics.I.worldRoot);
+            this._body.SetPositionXY(p.x / IPhysics.Physics.PIXEL_RATIO, p.y / IPhysics.Physics.PIXEL_RATIO);
+        }
+        _sysPosToPhysic() {
+            var sp = this.owner;
+            var p = sp.localToGlobal(Laya.Point.TEMP.setTo(0, 0), false, IPhysics.Physics.I.worldRoot);
+            this._body.SetPositionXY(p.x / IPhysics.Physics.PIXEL_RATIO, p.y / IPhysics.Physics.PIXEL_RATIO);
+        }
+        _overSet(sp, prop, getfun) {
+            Object.defineProperty(sp, prop, { get: this.accessGetSetFunc(sp, prop, "get"), set: getfun, enumerable: false, configurable: true });
+        }
+        _onDisable() {
+            Laya.Laya.physicsTimer.clear(this, this._sysPhysicToNode);
+            IPhysics.Physics.I._removeBody(this._body);
+            this._body = null;
+            var owner = this.owner;
+            if (owner._changeByRigidBody) {
+                this._overSet(owner, "x", this.accessGetSetFunc(owner, "x", "set"));
+                this._overSet(owner, "y", this.accessGetSetFunc(owner, "y", "set"));
+                this._overSet(owner, "rotation", this.accessGetSetFunc(owner, "rotation", "set"));
+                this._overSet(owner, "scaleX", this.accessGetSetFunc(owner, "scaleX", "set"));
+                this._overSet(owner, "scaleY", this.accessGetSetFunc(owner, "scaleY", "set"));
+                owner._changeByRigidBody = false;
+            }
+        }
+        getBody() {
+            if (!this._body)
+                this._onAwake();
+            return this._body;
+        }
+        get body() {
+            if (!this._body)
+                this._onAwake();
+            return this._body;
+        }
+        applyForce(position, force) {
+            if (!this._body)
+                this._onAwake();
+            this._body.ApplyForce(force, position);
+        }
+        applyForceToCenter(force) {
+            if (!this._body)
+                this._onAwake();
+            this._body.ApplyForceToCenter(force);
+        }
+        applyLinearImpulse(position, impulse) {
+            if (!this._body)
+                this._onAwake();
+            this._body.ApplyLinearImpulse(impulse, position);
+        }
+        applyLinearImpulseToCenter(impulse) {
+            if (!this._body)
+                this._onAwake();
+            this._body.ApplyLinearImpulseToCenter(impulse);
+        }
+        applyTorque(torque) {
+            if (!this._body)
+                this._onAwake();
+            this._body.ApplyTorque(torque);
+        }
+        setVelocity(velocity) {
+            if (!this._body)
+                this._onAwake();
+            this._body.SetLinearVelocity(velocity);
+        }
+        setAngle(value) {
+            if (!this._body)
+                this._onAwake();
+            this._body.SetAngle(value);
+            this._body.SetAwake(true);
+        }
+        getMass() {
+            return this._body ? this._body.GetMass() : 0;
+        }
+        getCenter() {
+            if (!this._body)
+                this._onAwake();
+            var p = this._body.GetLocalCenter();
+            p.x = p.x * IPhysics.Physics.PIXEL_RATIO;
+            p.y = p.y * IPhysics.Physics.PIXEL_RATIO;
+            return p;
+        }
+        getWorldCenter() {
+            if (!this._body)
+                this._onAwake();
+            var p = this._body.GetWorldCenter();
+            p.x = p.x * IPhysics.Physics.PIXEL_RATIO;
+            p.y = p.y * IPhysics.Physics.PIXEL_RATIO;
+            return p;
+        }
+        get type() {
+            return this._type;
+        }
+        set type(value) {
+            this._type = value;
+            if (this._body)
+                this._body.SetType(window.box2d.b2BodyType["b2_" + this._type + "Body"]);
+        }
+        get gravityScale() {
+            return this._gravityScale;
+        }
+        set gravityScale(value) {
+            this._gravityScale = value;
+            if (this._body)
+                this._body.SetGravityScale(value);
+        }
+        get allowRotation() {
+            return this._allowRotation;
+        }
+        set allowRotation(value) {
+            this._allowRotation = value;
+            if (this._body)
+                this._body.SetFixedRotation(!value);
+        }
+        get allowSleep() {
+            return this._allowSleep;
+        }
+        set allowSleep(value) {
+            this._allowSleep = value;
+            if (this._body)
+                this._body.SetSleepingAllowed(value);
+        }
+        get angularDamping() {
+            return this._angularDamping;
+        }
+        set angularDamping(value) {
+            this._angularDamping = value;
+            if (this._body)
+                this._body.SetAngularDamping(value);
+        }
+        get angularVelocity() {
+            if (this._body)
+                return this._body.GetAngularVelocity();
+            return this._angularVelocity;
+        }
+        set angularVelocity(value) {
+            this._angularVelocity = value;
+            if (this._body)
+                this._body.SetAngularVelocity(value);
+        }
+        get linearDamping() {
+            return this._linearDamping;
+        }
+        set linearDamping(value) {
+            this._linearDamping = value;
+            if (this._body)
+                this._body.SetLinearDamping(value);
+        }
+        get linearVelocity() {
+            if (this._body) {
+                var vec = this._body.GetLinearVelocity();
+                return { x: vec.x, y: vec.y };
+            }
+            return this._linearVelocity;
+        }
+        set linearVelocity(value) {
+            if (!value)
+                return;
+            if (value instanceof Array) {
+                value = { x: value[0], y: value[1] };
+            }
+            this._linearVelocity = value;
+            if (this._body)
+                this._body.SetLinearVelocity(new window.box2d.b2Vec2(value.x, value.y));
+        }
+        get bullet() {
+            return this._bullet;
+        }
+        set bullet(value) {
+            this._bullet = value;
+            if (this._body)
+                this._body.SetBullet(value);
+        }
+    }
+    Laya.ClassUtils.regClass("laya.physics.RigidBody", RigidBody);
+    Laya.ClassUtils.regClass("Laya.RigidBody", RigidBody);
+
+    class Physics extends Laya.EventDispatcher {
+        constructor() {
+            super();
+            this.box2d = window.box2d;
+            this.velocityIterations = 8;
+            this.positionIterations = 3;
+            this._eventList = [];
+        }
+        static get I() {
+            return Physics._I || (Physics._I = new Physics());
+        }
+        static enable(options = null) {
+            Physics.I.start(options);
+            IPhysics.RigidBody = RigidBody;
+            IPhysics.Physics = this;
+        }
+        start(options = null) {
+            if (!this._enabled) {
+                this._enabled = true;
+                options || (options = {});
+                var box2d = window.box2d;
+                if (box2d == null) {
+                    console.error("Can not find box2d libs, you should reuqest box2d.js first.");
+                    return;
+                }
+                var gravity = new box2d.b2Vec2(0, options.gravity || 500 / Physics.PIXEL_RATIO);
+                this.world = new box2d.b2World(gravity);
+                this.world.SetContactListener(new ContactListener());
+                this.allowSleeping = options.allowSleeping == null ? true : options.allowSleeping;
+                if (!options.customUpdate)
+                    Laya.Laya.physicsTimer.frameLoop(1, this, this._update);
+                this._emptyBody = this._createBody(new window.box2d.b2BodyDef());
+            }
+        }
+        _update() {
+            this.world.Step(1 / 60, this.velocityIterations, this.positionIterations, 3);
+            var len = this._eventList.length;
+            if (len > 0) {
+                for (var i = 0; i < len; i += 2) {
+                    this._sendEvent(this._eventList[i], this._eventList[i + 1]);
+                }
+                this._eventList.length = 0;
+            }
+        }
+        _sendEvent(type, contact) {
+            var colliderA = contact.GetFixtureA().collider;
+            var colliderB = contact.GetFixtureB().collider;
+            var ownerA = colliderA.owner;
+            var ownerB = colliderB.owner;
+            contact.getHitInfo = function () {
+                var manifold = new this.box2d.b2WorldManifold();
+                this.GetWorldManifold(manifold);
+                var p = manifold.points[0];
+                p.x *= Physics.PIXEL_RATIO;
+                p.y *= Physics.PIXEL_RATIO;
+                return manifold;
+            };
+            if (ownerA) {
+                var args = [colliderB, colliderA, contact];
+                if (type === 0) {
+                    ownerA.event(Laya.Event.TRIGGER_ENTER, args);
+                    if (!ownerA["_triggered"]) {
+                        ownerA["_triggered"] = true;
+                    }
+                    else {
+                        ownerA.event(Laya.Event.TRIGGER_STAY, args);
+                    }
+                }
+                else {
+                    ownerA["_triggered"] = false;
+                    ownerA.event(Laya.Event.TRIGGER_EXIT, args);
+                }
+            }
+            if (ownerB) {
+                args = [colliderA, colliderB, contact];
+                if (type === 0) {
+                    ownerB.event(Laya.Event.TRIGGER_ENTER, args);
+                    if (!ownerB["_triggered"]) {
+                        ownerB["_triggered"] = true;
+                    }
+                    else {
+                        ownerB.event(Laya.Event.TRIGGER_STAY, args);
+                    }
+                }
+                else {
+                    ownerB["_triggered"] = false;
+                    ownerB.event(Laya.Event.TRIGGER_EXIT, args);
+                }
+            }
+        }
+        _createBody(def) {
+            if (this.world) {
+                return this.world.CreateBody(def);
+            }
+            else {
+                console.error('The physical engine should be initialized first.use "Physics.enable()"');
+                return null;
+            }
+        }
+        _removeBody(body) {
+            if (this.world) {
+                this.world.DestroyBody(body);
+            }
+            else {
+                console.error('The physical engine should be initialized first.use "Physics.enable()"');
+            }
+        }
+        _createJoint(def) {
+            if (this.world) {
+                return this.world.CreateJoint(def);
+            }
+            else {
+                console.error('The physical engine should be initialized first.use "Physics.enable()"');
+                return null;
+            }
+        }
+        _removeJoint(joint) {
+            if (this.world) {
+                this.world.DestroyJoint(joint);
+            }
+            else {
+                console.error('The physical engine should be initialized first.use "Physics.enable()"');
+            }
+        }
+        stop() {
+            Laya.Laya.physicsTimer.clear(this, this._update);
+        }
+        get allowSleeping() {
+            return this.world.GetAllowSleeping();
+        }
+        set allowSleeping(value) {
+            this.world.SetAllowSleeping(value);
+        }
+        get gravity() {
+            return this.world.GetGravity();
+        }
+        set gravity(value) {
+            this.world.SetGravity(value);
+        }
+        getBodyCount() {
+            return this.world.GetBodyCount();
+        }
+        getContactCount() {
+            return this.world.GetContactCount();
+        }
+        getJointCount() {
+            return this.world.GetJointCount();
+        }
+        get worldRoot() {
+            return this._worldRoot || Laya.Laya.stage;
+        }
+        set worldRoot(value) {
+            this._worldRoot = value;
+            if (value) {
+                var p = value.localToGlobal(Laya.Point.TEMP.setTo(0, 0));
+                this.world.ShiftOrigin({ x: p.x / Physics.PIXEL_RATIO, y: p.y / Physics.PIXEL_RATIO });
+            }
+        }
+    }
+    Physics.PIXEL_RATIO = 50;
+    Laya.ClassUtils.regClass("laya.physics.Physics", Physics);
+    Laya.ClassUtils.regClass("Laya.Physics", Physics);
+    class ContactListener {
+        BeginContact(contact) {
+            Physics.I._eventList.push(0, contact);
+        }
+        EndContact(contact) {
+            Physics.I._eventList.push(1, contact);
+        }
+        PreSolve(contact, oldManifold) {
+        }
+        PostSolve(contact, impulse) {
+        }
+    }
+
+    class BoxCollider extends ColliderBase {
+        constructor() {
+            super(...arguments);
+            this._x = 0;
+            this._y = 0;
+            this._width = 100;
+            this._height = 100;
+        }
+        getDef() {
+            if (!this._shape) {
+                this._shape = new window.box2d.b2PolygonShape();
+                this._setShape(false);
+            }
+            this.label = (this.label || "BoxCollider");
+            return super.getDef();
+        }
+        _setShape(re = true) {
+            var scaleX = (this.owner["scaleX"] || 1);
+            var scaleY = (this.owner["scaleY"] || 1);
+            this._shape.SetAsBox(this._width / 2 / Physics.PIXEL_RATIO * scaleX, this._height / 2 / Physics.PIXEL_RATIO * scaleY, new window.box2d.b2Vec2((this._width / 2 + this._x) / Physics.PIXEL_RATIO * scaleX, (this._height / 2 + this._y) / Physics.PIXEL_RATIO * scaleY));
+            if (re)
+                this.refresh();
+        }
+        get x() {
+            return this._x;
+        }
+        set x(value) {
+            this._x = value;
+            if (this._shape)
+                this._setShape();
+        }
+        get y() {
+            return this._y;
+        }
+        set y(value) {
+            this._y = value;
+            if (this._shape)
+                this._setShape();
+        }
+        get width() {
+            return this._width;
+        }
+        set width(value) {
+            if (value <= 0)
+                throw "BoxCollider size cannot be less than 0";
+            this._width = value;
+            if (this._shape)
+                this._setShape();
+        }
+        get height() {
+            return this._height;
+        }
+        set height(value) {
+            if (value <= 0)
+                throw "BoxCollider size cannot be less than 0";
+            this._height = value;
+            if (this._shape)
+                this._setShape();
+        }
+        resetShape(re = true) {
+            this._setShape();
+        }
+    }
+    Laya.ClassUtils.regClass("laya.physics.BoxCollider", BoxCollider);
+    Laya.ClassUtils.regClass("Laya.BoxCollider", BoxCollider);
+
+    class ChainCollider extends ColliderBase {
+        constructor() {
+            super(...arguments);
+            this._x = 0;
+            this._y = 0;
+            this._points = "0,0,100,0";
+            this._loop = false;
+        }
+        getDef() {
+            if (!this._shape) {
+                this._shape = new window.box2d.b2ChainShape();
+                this._setShape(false);
+            }
+            this.label = (this.label || "ChainCollider");
+            return super.getDef();
+        }
+        _setShape(re = true) {
+            var arr = this._points.split(",");
+            var len = arr.length;
+            if (len % 2 == 1)
+                throw "ChainCollider points lenth must a multiplier of 2";
+            var ps = [];
+            for (var i = 0, n = len; i < n; i += 2) {
+                ps.push(new window.box2d.b2Vec2((this._x + parseInt(arr[i])) / Physics.PIXEL_RATIO, (this._y + parseInt(arr[i + 1])) / Physics.PIXEL_RATIO));
+            }
+            this._loop ? this._shape.CreateLoop(ps, len / 2) : this._shape.CreateChain(ps, len / 2);
+            if (re)
+                this.refresh();
+        }
+        get x() {
+            return this._x;
+        }
+        set x(value) {
+            this._x = value;
+            if (this._shape)
+                this._setShape();
+        }
+        get y() {
+            return this._y;
+        }
+        set y(value) {
+            this._y = value;
+            if (this._shape)
+                this._setShape();
+        }
+        get points() {
+            return this._points;
+        }
+        set points(value) {
+            if (!value)
+                throw "ChainCollider points cannot be empty";
+            this._points = value;
+            if (this._shape)
+                this._setShape();
+        }
+        get loop() {
+            return this._loop;
+        }
+        set loop(value) {
+            this._loop = value;
+            if (this._shape)
+                this._setShape();
+        }
+    }
+    Laya.ClassUtils.regClass("laya.physics.ChainCollider", ChainCollider);
+    Laya.ClassUtils.regClass("Laya.ChainCollider", ChainCollider);
+
+    class CircleCollider extends ColliderBase {
+        constructor() {
+            super(...arguments);
+            this._x = 0;
+            this._y = 0;
+            this._radius = 50;
+        }
+        getDef() {
+            if (!this._shape) {
+                this._shape = new window.box2d.b2CircleShape();
+                this._setShape(false);
+            }
+            this.label = (this.label || "CircleCollider");
+            return super.getDef();
+        }
+        _setShape(re = true) {
+            var scale = this.owner["scaleX"] || 1;
+            this._shape.m_radius = this._radius / Physics.PIXEL_RATIO * scale;
+            this._shape.m_p.Set((this._radius + this._x) / Physics.PIXEL_RATIO * scale, (this._radius + this._y) / Physics.PIXEL_RATIO * scale);
+            if (re)
+                this.refresh();
+        }
+        get x() {
+            return this._x;
+        }
+        set x(value) {
+            this._x = value;
+            if (this._shape)
+                this._setShape();
+        }
+        get y() {
+            return this._y;
+        }
+        set y(value) {
+            this._y = value;
+            if (this._shape)
+                this._setShape();
+        }
+        get radius() {
+            return this._radius;
+        }
+        set radius(value) {
+            if (value <= 0)
+                throw "CircleCollider radius cannot be less than 0";
+            this._radius = value;
+            if (this._shape)
+                this._setShape();
+        }
+        resetShape(re = true) {
+            this._setShape();
+        }
+    }
+    Laya.ClassUtils.regClass("laya.physics.CircleCollider", CircleCollider);
+    Laya.ClassUtils.regClass("Laya.CircleCollider", CircleCollider);
+
+    class PhysicsDebugDraw extends Laya.Sprite {
+        constructor() {
+            super();
+            this.m_drawFlags = 99;
+            if (!PhysicsDebugDraw._inited) {
+                PhysicsDebugDraw._inited = true;
+                PhysicsDebugDraw.init();
+            }
+            this._camera = {};
+            this._camera.m_center = new PhysicsDebugDraw.box2d.b2Vec2(0, 0);
+            this._camera.m_extent = 25;
+            this._camera.m_zoom = 1;
+            this._camera.m_width = 1280;
+            this._camera.m_height = 800;
+            this._mG = new Laya.Graphics();
+            this.graphics = this._mG;
+            this._textSp = new Laya.Sprite();
+            this._textG = this._textSp.graphics;
+            this.addChild(this._textSp);
+        }
+        static init() {
+            PhysicsDebugDraw.box2d = Laya.Browser.window.box2d;
+            PhysicsDebugDraw.DrawString_s_color = new PhysicsDebugDraw.box2d.b2Color(0.9, 0.6, 0.6);
+            PhysicsDebugDraw.DrawStringWorld_s_p = new PhysicsDebugDraw.box2d.b2Vec2();
+            PhysicsDebugDraw.DrawStringWorld_s_cc = new PhysicsDebugDraw.box2d.b2Vec2();
+            PhysicsDebugDraw.DrawStringWorld_s_color = new PhysicsDebugDraw.box2d.b2Color(0.5, 0.9, 0.5);
+        }
+        render(ctx, x, y) {
+            this._renderToGraphic();
+            super.render(ctx, x, y);
+        }
+        _renderToGraphic() {
+            if (this.world) {
+                this._textG.clear();
+                this._mG.clear();
+                this._mG.save();
+                this._mG.scale(Physics.PIXEL_RATIO, Physics.PIXEL_RATIO);
+                this.lineWidth = 1 / Physics.PIXEL_RATIO;
+                this.world.DrawDebugData();
+                this._mG.restore();
+            }
+        }
+        SetFlags(flags) {
+            this.m_drawFlags = flags;
+        }
+        GetFlags() {
+            return this.m_drawFlags;
+        }
+        AppendFlags(flags) {
+            this.m_drawFlags |= flags;
+        }
+        ClearFlags(flags) {
+            this.m_drawFlags &= ~flags;
+        }
+        PushTransform(xf) {
+            this._mG.save();
+            this._mG.translate(xf.p.x, xf.p.y);
+            this._mG.rotate(xf.q.GetAngle());
+        }
+        PopTransform(xf) {
+            this._mG.restore();
+        }
+        DrawPolygon(vertices, vertexCount, color) {
+            var i, len;
+            len = vertices.length;
+            var points;
+            points = [];
+            for (i = 0; i < vertexCount; i++) {
+                points.push(vertices[i].x, vertices[i].y);
+            }
+            this._mG.drawPoly(0, 0, points, null, color.MakeStyleString(1), this.lineWidth);
+        }
+        DrawSolidPolygon(vertices, vertexCount, color) {
+            var i, len;
+            len = vertices.length;
+            var points;
+            points = [];
+            for (i = 0; i < vertexCount; i++) {
+                points.push(vertices[i].x, vertices[i].y);
+            }
+            this._mG.drawPoly(0, 0, points, color.MakeStyleString(0.5), color.MakeStyleString(1), this.lineWidth);
+        }
+        DrawCircle(center, radius, color) {
+            this._mG.drawCircle(center.x, center.y, radius, null, color.MakeStyleString(1), this.lineWidth);
+        }
+        DrawSolidCircle(center, radius, axis, color) {
+            var cx = center.x;
+            var cy = center.y;
+            this._mG.drawCircle(cx, cy, radius, color.MakeStyleString(0.5), color.MakeStyleString(1), this.lineWidth);
+            this._mG.drawLine(cx, cy, (cx + axis.x * radius), (cy + axis.y * radius), color.MakeStyleString(1), this.lineWidth);
+        }
+        DrawParticles(centers, radius, colors, count) {
+            if (colors !== null) {
+                for (var i = 0; i < count; ++i) {
+                    var center = centers[i];
+                    var color = colors[i];
+                    this._mG.drawCircle(center.x, center.y, radius, color.MakeStyleString(), null, this.lineWidth);
+                }
+            }
+            else {
+                for (i = 0; i < count; ++i) {
+                    center = centers[i];
+                    this._mG.drawCircle(center.x, center.y, radius, "#ffff00", null, this.lineWidth);
+                }
+            }
+        }
+        DrawSegment(p1, p2, color) {
+            this._mG.drawLine(p1.x, p1.y, p2.x, p2.y, color.MakeStyleString(1), this.lineWidth);
+        }
+        DrawTransform(xf) {
+            this.PushTransform(xf);
+            this._mG.drawLine(0, 0, 1, 0, PhysicsDebugDraw.box2d.b2Color.RED.MakeStyleString(1), this.lineWidth);
+            this._mG.drawLine(0, 0, 0, 1, PhysicsDebugDraw.box2d.b2Color.GREEN.MakeStyleString(1), this.lineWidth);
+            this.PopTransform(xf);
+        }
+        DrawPoint(p, size, color) {
+            size *= this._camera.m_zoom;
+            size /= this._camera.m_extent;
+            var hsize = size / 2;
+            this._mG.drawRect(p.x - hsize, p.y - hsize, size, size, color.MakeStyleString(), null);
+        }
+        DrawString(x, y, message) {
+            this._textG.fillText(message, x, y, "15px DroidSans", PhysicsDebugDraw.DrawString_s_color.MakeStyleString(), "left");
+        }
+        DrawStringWorld(x, y, message) {
+            this.DrawString(x, y, message);
+        }
+        DrawAABB(aabb, color) {
+            var x = aabb.lowerBound.x;
+            var y = aabb.lowerBound.y;
+            var w = aabb.upperBound.x - aabb.lowerBound.x;
+            var h = aabb.upperBound.y - aabb.lowerBound.y;
+            this._mG.drawRect(x, y, w, h, null, color.MakeStyleString(), this.lineWidth);
+        }
+        static enable(flags = 99) {
+            if (!PhysicsDebugDraw.I) {
+                var debug = new PhysicsDebugDraw();
+                debug.world = Physics.I.world;
+                debug.world.SetDebugDraw(debug);
+                debug.zOrder = 1000;
+                debug.m_drawFlags = flags;
+                Laya.Laya.stage.addChild(debug);
+                PhysicsDebugDraw.I = debug;
+            }
+            return debug;
+        }
+    }
+    PhysicsDebugDraw._inited = false;
+    Laya.ClassUtils.regClass("laya.physics.PhysicsDebugDraw", PhysicsDebugDraw);
+    Laya.ClassUtils.regClass("Laya.PhysicsDebugDraw", PhysicsDebugDraw);
+
+    class PolygonCollider extends ColliderBase {
+        constructor() {
+            super(...arguments);
+            this._x = 0;
+            this._y = 0;
+            this._points = "50,0,100,100,0,100";
+        }
+        getDef() {
+            if (!this._shape) {
+                this._shape = new window.box2d.b2PolygonShape();
+                this._setShape(false);
+            }
+            this.label = (this.label || "PolygonCollider");
+            return super.getDef();
+        }
+        _setShape(re = true) {
+            var arr = this._points.split(",");
+            var len = arr.length;
+            if (len < 6)
+                throw "PolygonCollider points must be greater than 3";
+            if (len % 2 == 1)
+                throw "PolygonCollider points lenth must a multiplier of 2";
+            var ps = [];
+            for (var i = 0, n = len; i < n; i += 2) {
+                ps.push(new window.box2d.b2Vec2((this._x + parseInt(arr[i])) / Physics.PIXEL_RATIO, (this._y + parseInt(arr[i + 1])) / Physics.PIXEL_RATIO));
+            }
+            this._shape.Set(ps, len / 2);
+            if (re)
+                this.refresh();
+        }
+        get x() {
+            return this._x;
+        }
+        set x(value) {
+            this._x = value;
+            if (this._shape)
+                this._setShape();
+        }
+        get y() {
+            return this._y;
+        }
+        set y(value) {
+            this._y = value;
+            if (this._shape)
+                this._setShape();
+        }
+        get points() {
+            return this._points;
+        }
+        set points(value) {
+            if (!value)
+                throw "PolygonCollider points cannot be empty";
+            this._points = value;
+            if (this._shape)
+                this._setShape();
+        }
+    }
+    Laya.ClassUtils.regClass("laya.physics.PolygonCollider", PolygonCollider);
+    Laya.ClassUtils.regClass("Laya.PolygonCollider", PolygonCollider);
+
+    class JointBase extends Laya.Component {
+        get joint() {
+            if (!this._joint)
+                this._createJoint();
+            return this._joint;
+        }
+        _onEnable() {
+            this._createJoint();
+        }
+        _onAwake() {
+            this._createJoint();
+        }
+        _createJoint() {
+        }
+        _onDisable() {
+            if (this._joint) {
+                Physics.I._removeJoint(this._joint);
+                this._joint = null;
+            }
+        }
+    }
+    Laya.ClassUtils.regClass("laya.physics.joint.JointBase", JointBase);
+    Laya.ClassUtils.regClass("Laya.JointBase", JointBase);
+
+    class DistanceJoint extends JointBase {
+        constructor() {
+            super(...arguments);
+            this.selfAnchor = [0, 0];
+            this.otherAnchor = [0, 0];
+            this.collideConnected = false;
+            this._length = 0;
+            this._frequency = 0;
+            this._damping = 0;
+        }
+        _createJoint() {
+            if (!this._joint) {
+                this.selfBody = this.selfBody || this.owner.getComponent(RigidBody);
+                if (!this.selfBody)
+                    throw "selfBody can not be empty";
+                var box2d = window.box2d;
+                var def = DistanceJoint._temp || (DistanceJoint._temp = new box2d.b2DistanceJointDef());
+                def.bodyA = this.otherBody ? this.otherBody.getBody() : Physics.I._emptyBody;
+                def.bodyB = this.selfBody.getBody();
+                def.localAnchorA.Set(this.otherAnchor[0] / Physics.PIXEL_RATIO, this.otherAnchor[1] / Physics.PIXEL_RATIO);
+                def.localAnchorB.Set(this.selfAnchor[0] / Physics.PIXEL_RATIO, this.selfAnchor[1] / Physics.PIXEL_RATIO);
+                def.frequencyHz = this._frequency;
+                def.dampingRatio = this._damping;
+                def.collideConnected = this.collideConnected;
+                var p1 = def.bodyA.GetWorldPoint(def.localAnchorA, new box2d.b2Vec2());
+                var p2 = def.bodyB.GetWorldPoint(def.localAnchorB, new box2d.b2Vec2());
+                def.length = this._length / Physics.PIXEL_RATIO || box2d.b2Vec2.SubVV(p2, p1, new box2d.b2Vec2()).Length();
+                this._joint = Physics.I._createJoint(def);
+            }
+        }
+        get length() {
+            return this._length;
+        }
+        set length(value) {
+            this._length = value;
+            if (this._joint)
+                this._joint.SetLength(value / Physics.PIXEL_RATIO);
+        }
+        get frequency() {
+            return this._frequency;
+        }
+        set frequency(value) {
+            this._frequency = value;
+            if (this._joint)
+                this._joint.SetFrequency(value);
+        }
+        get damping() {
+            return this._damping;
+        }
+        set damping(value) {
+            this._damping = value;
+            if (this._joint)
+                this._joint.SetDampingRatio(value);
+        }
+    }
+    Laya.ClassUtils.regClass("laya.physics.joint.DistanceJoint", DistanceJoint);
+    Laya.ClassUtils.regClass("Laya.DistanceJoint", DistanceJoint);
+
+    class GearJoint extends JointBase {
+        constructor() {
+            super(...arguments);
+            this.collideConnected = false;
+            this._ratio = 1;
+        }
+        _createJoint() {
+            if (!this._joint) {
+                if (!this.joint1)
+                    throw "Joint1 can not be empty";
+                if (!this.joint2)
+                    throw "Joint2 can not be empty";
+                var box2d = window.box2d;
+                var def = GearJoint._temp || (GearJoint._temp = new box2d.b2GearJointDef());
+                def.bodyA = this.joint1.owner.getComponent(RigidBody).getBody();
+                def.bodyB = this.joint2.owner.getComponent(RigidBody).getBody();
+                def.joint1 = this.joint1.joint;
+                def.joint2 = this.joint2.joint;
+                def.ratio = this._ratio;
+                def.collideConnected = this.collideConnected;
+                this._joint = Physics.I._createJoint(def);
+            }
+        }
+        get ratio() {
+            return this._ratio;
+        }
+        set ratio(value) {
+            this._ratio = value;
+            if (this._joint)
+                this._joint.SetRatio(value);
+        }
+    }
+    Laya.ClassUtils.regClass("laya.physics.joint.GearJoint", GearJoint);
+    Laya.ClassUtils.regClass("Laya.GearJoint", GearJoint);
+
+    class MotorJoint extends JointBase {
+        constructor() {
+            super(...arguments);
+            this.collideConnected = false;
+            this._linearOffset = [0, 0];
+            this._angularOffset = 0;
+            this._maxForce = 1000;
+            this._maxTorque = 1000;
+            this._correctionFactor = 0.3;
+        }
+        _createJoint() {
+            if (!this._joint) {
+                if (!this.otherBody)
+                    throw "otherBody can not be empty";
+                this.selfBody = this.selfBody || this.owner.getComponent(RigidBody);
+                if (!this.selfBody)
+                    throw "selfBody can not be empty";
+                var box2d = window.box2d;
+                var def = MotorJoint._temp || (MotorJoint._temp = new box2d.b2MotorJointDef());
+                def.Initialize(this.otherBody.getBody(), this.selfBody.getBody());
+                def.linearOffset = new box2d.b2Vec2(this._linearOffset[0] / Physics.PIXEL_RATIO, this._linearOffset[1] / Physics.PIXEL_RATIO);
+                def.angularOffset = this._angularOffset;
+                def.maxForce = this._maxForce;
+                def.maxTorque = this._maxTorque;
+                def.correctionFactor = this._correctionFactor;
+                def.collideConnected = this.collideConnected;
+                this._joint = Physics.I._createJoint(def);
+            }
+        }
+        get linearOffset() {
+            return this._linearOffset;
+        }
+        set linearOffset(value) {
+            this._linearOffset = value;
+            if (this._joint)
+                this._joint.SetLinearOffset(new window.box2d.b2Vec2(value[0] / Physics.PIXEL_RATIO, value[1] / Physics.PIXEL_RATIO));
+        }
+        get angularOffset() {
+            return this._angularOffset;
+        }
+        set angularOffset(value) {
+            this._angularOffset = value;
+            if (this._joint)
+                this._joint.SetAngularOffset(value);
+        }
+        get maxForce() {
+            return this._maxForce;
+        }
+        set maxForce(value) {
+            this._maxForce = value;
+            if (this._joint)
+                this._joint.SetMaxForce(value);
+        }
+        get maxTorque() {
+            return this._maxTorque;
+        }
+        set maxTorque(value) {
+            this._maxTorque = value;
+            if (this._joint)
+                this._joint.SetMaxTorque(value);
+        }
+        get correctionFactor() {
+            return this._correctionFactor;
+        }
+        set correctionFactor(value) {
+            this._correctionFactor = value;
+            if (this._joint)
+                this._joint.SetCorrectionFactor(value);
+        }
+    }
+    Laya.ClassUtils.regClass("laya.physics.joint.MotorJoint", MotorJoint);
+    Laya.ClassUtils.regClass("Laya.MotorJoint", MotorJoint);
+
+    class MouseJoint extends JointBase {
+        constructor() {
+            super(...arguments);
+            this._maxForce = 10000;
+            this._frequency = 5;
+            this._damping = 0.7;
+        }
+        _onEnable() {
+            this.owner.on(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
+        }
+        _onAwake() {
+        }
+        onMouseDown() {
+            this._createJoint();
+            Laya.Laya.stage.on(Laya.Event.MOUSE_MOVE, this, this.onMouseMove);
+            Laya.Laya.stage.once(Laya.Event.MOUSE_UP, this, this.onStageMouseUp);
+        }
+        _createJoint() {
+            if (!this._joint) {
+                this.selfBody = this.selfBody || this.owner.getComponent(RigidBody);
+                if (!this.selfBody)
+                    throw "selfBody can not be empty";
+                var box2d = window.box2d;
+                var def = MouseJoint._temp || (MouseJoint._temp = new box2d.b2MouseJointDef());
+                if (this.anchor) {
+                    var anchorPos = this.selfBody.owner.localToGlobal(Laya.Point.TEMP.setTo(this.anchor[0], this.anchor[1]), false, Physics.I.worldRoot);
+                }
+                else {
+                    anchorPos = Physics.I.worldRoot.globalToLocal(Laya.Point.TEMP.setTo(Laya.Laya.stage.mouseX, Laya.Laya.stage.mouseY));
+                }
+                var anchorVec = new box2d.b2Vec2(anchorPos.x / Physics.PIXEL_RATIO, anchorPos.y / Physics.PIXEL_RATIO);
+                def.bodyA = Physics.I._emptyBody;
+                def.bodyB = this.selfBody.getBody();
+                def.target = anchorVec;
+                def.frequencyHz = this._frequency;
+                def.damping = this._damping;
+                def.maxForce = this._maxForce;
+                this._joint = Physics.I._createJoint(def);
+            }
+        }
+        onStageMouseUp() {
+            Laya.Laya.stage.off(Laya.Event.MOUSE_MOVE, this, this.onMouseMove);
+            super._onDisable();
+        }
+        onMouseMove() {
+            this._joint.SetTarget(new window.box2d.b2Vec2(Physics.I.worldRoot.mouseX / Physics.PIXEL_RATIO, Physics.I.worldRoot.mouseY / Physics.PIXEL_RATIO));
+        }
+        _onDisable() {
+            this.owner.off(Laya.Event.MOUSE_DOWN, this, this.onMouseDown);
+            super._onDisable();
+        }
+        get maxForce() {
+            return this._maxForce;
+        }
+        set maxForce(value) {
+            this._maxForce = value;
+            if (this._joint)
+                this._joint.SetMaxForce(value);
+        }
+        get frequency() {
+            return this._frequency;
+        }
+        set frequency(value) {
+            this._frequency = value;
+            if (this._joint)
+                this._joint.SetFrequency(value);
+        }
+        get damping() {
+            return this._damping;
+        }
+        set damping(value) {
+            this._damping = value;
+            if (this._joint)
+                this._joint.SetDampingRatio(value);
+        }
+    }
+    Laya.ClassUtils.regClass("laya.physics.joint.MouseJoint", MouseJoint);
+    Laya.ClassUtils.regClass("Laya.MouseJoint", MouseJoint);
+
+    class PrismaticJoint extends JointBase {
+        constructor() {
+            super(...arguments);
+            this.anchor = [0, 0];
+            this.axis = [1, 0];
+            this.collideConnected = false;
+            this._enableMotor = false;
+            this._motorSpeed = 0;
+            this._maxMotorForce = 10000;
+            this._enableLimit = false;
+            this._lowerTranslation = 0;
+            this._upperTranslation = 0;
+        }
+        _createJoint() {
+            if (!this._joint) {
+                this.selfBody = this.selfBody || this.owner.getComponent(RigidBody);
+                if (!this.selfBody)
+                    throw "selfBody can not be empty";
+                var box2d = window.box2d;
+                var def = PrismaticJoint._temp || (PrismaticJoint._temp = new box2d.b2PrismaticJointDef());
+                var anchorPos = this.selfBody.owner.localToGlobal(Laya.Point.TEMP.setTo(this.anchor[0], this.anchor[1]), false, Physics.I.worldRoot);
+                var anchorVec = new box2d.b2Vec2(anchorPos.x / Physics.PIXEL_RATIO, anchorPos.y / Physics.PIXEL_RATIO);
+                def.Initialize(this.otherBody ? this.otherBody.getBody() : Physics.I._emptyBody, this.selfBody.getBody(), anchorVec, new box2d.b2Vec2(this.axis[0], this.axis[1]));
+                def.enableMotor = this._enableMotor;
+                def.motorSpeed = this._motorSpeed;
+                def.maxMotorForce = this._maxMotorForce;
+                def.enableLimit = this._enableLimit;
+                def.lowerTranslation = this._lowerTranslation / Physics.PIXEL_RATIO;
+                def.upperTranslation = this._upperTranslation / Physics.PIXEL_RATIO;
+                def.collideConnected = this.collideConnected;
+                this._joint = Physics.I._createJoint(def);
+            }
+        }
+        get enableMotor() {
+            return this._enableMotor;
+        }
+        set enableMotor(value) {
+            this._enableMotor = value;
+            if (this._joint)
+                this._joint.EnableMotor(value);
+        }
+        get motorSpeed() {
+            return this._motorSpeed;
+        }
+        set motorSpeed(value) {
+            this._motorSpeed = value;
+            if (this._joint)
+                this._joint.SetMotorSpeed(value);
+        }
+        get maxMotorForce() {
+            return this._maxMotorForce;
+        }
+        set maxMotorForce(value) {
+            this._maxMotorForce = value;
+            if (this._joint)
+                this._joint.SetMaxMotorForce(value);
+        }
+        get enableLimit() {
+            return this._enableLimit;
+        }
+        set enableLimit(value) {
+            this._enableLimit = value;
+            if (this._joint)
+                this._joint.EnableLimit(value);
+        }
+        get lowerTranslation() {
+            return this._lowerTranslation;
+        }
+        set lowerTranslation(value) {
+            this._lowerTranslation = value;
+            if (this._joint)
+                this._joint.SetLimits(value, this._upperTranslation);
+        }
+        get upperTranslation() {
+            return this._upperTranslation;
+        }
+        set upperTranslation(value) {
+            this._upperTranslation = value;
+            if (this._joint)
+                this._joint.SetLimits(this._lowerTranslation, value);
+        }
+    }
+    Laya.ClassUtils.regClass("laya.physics.joint.PrismaticJoint", PrismaticJoint);
+    Laya.ClassUtils.regClass("Laya.PrismaticJoint", PrismaticJoint);
+
+    class PulleyJoint extends JointBase {
+        constructor() {
+            super(...arguments);
+            this.selfAnchor = [0, 0];
+            this.otherAnchor = [0, 0];
+            this.selfGroundPoint = [0, 0];
+            this.otherGroundPoint = [0, 0];
+            this.ratio = 1.5;
+            this.collideConnected = false;
+        }
+        _createJoint() {
+            if (!this._joint) {
+                if (!this.otherBody)
+                    throw "otherBody can not be empty";
+                this.selfBody = this.selfBody || this.owner.getComponent(RigidBody);
+                if (!this.selfBody)
+                    throw "selfBody can not be empty";
+                var box2d = window.box2d;
+                var def = PulleyJoint._temp || (PulleyJoint._temp = new box2d.b2PulleyJointDef());
+                var posA = this.otherBody.owner.localToGlobal(Laya.Point.TEMP.setTo(this.otherAnchor[0], this.otherAnchor[1]), false, Physics.I.worldRoot);
+                var anchorVecA = new box2d.b2Vec2(posA.x / Physics.PIXEL_RATIO, posA.y / Physics.PIXEL_RATIO);
+                var posB = this.selfBody.owner.localToGlobal(Laya.Point.TEMP.setTo(this.selfAnchor[0], this.selfAnchor[1]), false, Physics.I.worldRoot);
+                var anchorVecB = new box2d.b2Vec2(posB.x / Physics.PIXEL_RATIO, posB.y / Physics.PIXEL_RATIO);
+                var groundA = this.otherBody.owner.localToGlobal(Laya.Point.TEMP.setTo(this.otherGroundPoint[0], this.otherGroundPoint[1]), false, Physics.I.worldRoot);
+                var groundVecA = new box2d.b2Vec2(groundA.x / Physics.PIXEL_RATIO, groundA.y / Physics.PIXEL_RATIO);
+                var groundB = this.selfBody.owner.localToGlobal(Laya.Point.TEMP.setTo(this.selfGroundPoint[0], this.selfGroundPoint[1]), false, Physics.I.worldRoot);
+                var groundVecB = new box2d.b2Vec2(groundB.x / Physics.PIXEL_RATIO, groundB.y / Physics.PIXEL_RATIO);
+                def.Initialize(this.otherBody.getBody(), this.selfBody.getBody(), groundVecA, groundVecB, anchorVecA, anchorVecB, this.ratio);
+                def.collideConnected = this.collideConnected;
+                this._joint = Physics.I._createJoint(def);
+            }
+        }
+    }
+    Laya.ClassUtils.regClass("laya.physics.joint.PulleyJoint", PulleyJoint);
+    Laya.ClassUtils.regClass("Laya.PulleyJoint", PulleyJoint);
+
+    class RevoluteJoint extends JointBase {
+        constructor() {
+            super(...arguments);
+            this.anchor = [0, 0];
+            this.collideConnected = false;
+            this._enableMotor = false;
+            this._motorSpeed = 0;
+            this._maxMotorTorque = 10000;
+            this._enableLimit = false;
+            this._lowerAngle = 0;
+            this._upperAngle = 0;
+        }
+        _createJoint() {
+            if (!this._joint) {
+                this.selfBody = this.selfBody || this.owner.getComponent(RigidBody);
+                if (!this.selfBody)
+                    throw "selfBody can not be empty";
+                var box2d = window.box2d;
+                var def = RevoluteJoint._temp || (RevoluteJoint._temp = new box2d.b2RevoluteJointDef());
+                var anchorPos = this.selfBody.owner.localToGlobal(Laya.Point.TEMP.setTo(this.anchor[0], this.anchor[1]), false, Physics.I.worldRoot);
+                var anchorVec = new box2d.b2Vec2(anchorPos.x / Physics.PIXEL_RATIO, anchorPos.y / Physics.PIXEL_RATIO);
+                def.Initialize(this.otherBody ? this.otherBody.getBody() : Physics.I._emptyBody, this.selfBody.getBody(), anchorVec);
+                def.enableMotor = this._enableMotor;
+                def.motorSpeed = this._motorSpeed;
+                def.maxMotorTorque = this._maxMotorTorque;
+                def.enableLimit = this._enableLimit;
+                def.lowerAngle = this._lowerAngle;
+                def.upperAngle = this._upperAngle;
+                def.collideConnected = this.collideConnected;
+                this._joint = Physics.I._createJoint(def);
+            }
+        }
+        get enableMotor() {
+            return this._enableMotor;
+        }
+        set enableMotor(value) {
+            this._enableMotor = value;
+            if (this._joint)
+                this._joint.EnableMotor(value);
+        }
+        get motorSpeed() {
+            return this._motorSpeed;
+        }
+        set motorSpeed(value) {
+            this._motorSpeed = value;
+            if (this._joint)
+                this._joint.SetMotorSpeed(value);
+        }
+        get maxMotorTorque() {
+            return this._maxMotorTorque;
+        }
+        set maxMotorTorque(value) {
+            this._maxMotorTorque = value;
+            if (this._joint)
+                this._joint.SetMaxMotorTorque(value);
+        }
+        get enableLimit() {
+            return this._enableLimit;
+        }
+        set enableLimit(value) {
+            this._enableLimit = value;
+            if (this._joint)
+                this._joint.EnableLimit(value);
+        }
+        get lowerAngle() {
+            return this._lowerAngle;
+        }
+        set lowerAngle(value) {
+            this._lowerAngle = value;
+            if (this._joint)
+                this._joint.SetLimits(value, this._upperAngle);
+        }
+        get upperAngle() {
+            return this._upperAngle;
+        }
+        set upperAngle(value) {
+            this._upperAngle = value;
+            if (this._joint)
+                this._joint.SetLimits(this._lowerAngle, value);
+        }
+    }
+    Laya.ClassUtils.regClass("laya.physics.joint.RevoluteJoint", RevoluteJoint);
+    Laya.ClassUtils.regClass("Laya.RevoluteJoint", RevoluteJoint);
+
+    class RopeJoint extends JointBase {
+        constructor() {
+            super(...arguments);
+            this.selfAnchor = [0, 0];
+            this.otherAnchor = [0, 0];
+            this.collideConnected = false;
+            this._maxLength = 1;
+        }
+        _createJoint() {
+            if (!this._joint) {
+                this.selfBody = this.selfBody || this.owner.getComponent(RigidBody);
+                if (!this.selfBody)
+                    throw "selfBody can not be empty";
+                var box2d = window.box2d;
+                var def = RopeJoint._temp || (RopeJoint._temp = new box2d.b2RopeJointDef());
+                def.bodyA = this.otherBody ? this.otherBody.getBody() : Physics.I._emptyBody;
+                def.bodyB = this.selfBody.getBody();
+                def.localAnchorA.Set(this.otherAnchor[0] / Physics.PIXEL_RATIO, this.otherAnchor[1] / Physics.PIXEL_RATIO);
+                def.localAnchorB.Set(this.selfAnchor[0] / Physics.PIXEL_RATIO, this.selfAnchor[1] / Physics.PIXEL_RATIO);
+                def.maxLength = this._maxLength / Physics.PIXEL_RATIO;
+                def.collideConnected = this.collideConnected;
+                this._joint = Physics.I._createJoint(def);
+            }
+        }
+        get maxLength() {
+            return this._maxLength;
+        }
+        set maxLength(value) {
+            this._maxLength = value;
+            if (this._joint)
+                this._joint.SetMaxLength(value / Physics.PIXEL_RATIO);
+        }
+    }
+    Laya.ClassUtils.regClass("laya.physics.joint.RopeJoint", RopeJoint);
+    Laya.ClassUtils.regClass("Laya.RopeJoint", RopeJoint);
+
+    class WeldJoint extends JointBase {
+        constructor() {
+            super(...arguments);
+            this.anchor = [0, 0];
+            this.collideConnected = false;
+            this._frequency = 5;
+            this._damping = 0.7;
+        }
+        _createJoint() {
+            if (!this._joint) {
+                if (!this.otherBody)
+                    throw "otherBody can not be empty";
+                this.selfBody = this.selfBody || this.owner.getComponent(RigidBody);
+                if (!this.selfBody)
+                    throw "selfBody can not be empty";
+                var box2d = window.box2d;
+                var def = WeldJoint._temp || (WeldJoint._temp = new box2d.b2WeldJointDef());
+                var anchorPos = this.selfBody.owner.localToGlobal(Laya.Point.TEMP.setTo(this.anchor[0], this.anchor[1]), false, Physics.I.worldRoot);
+                var anchorVec = new box2d.b2Vec2(anchorPos.x / Physics.PIXEL_RATIO, anchorPos.y / Physics.PIXEL_RATIO);
+                def.Initialize(this.otherBody.getBody(), this.selfBody.getBody(), anchorVec);
+                def.frequencyHz = this._frequency;
+                def.dampingRatio = this._damping;
+                def.collideConnected = this.collideConnected;
+                this._joint = Physics.I._createJoint(def);
+            }
+        }
+        get frequency() {
+            return this._frequency;
+        }
+        set frequency(value) {
+            this._frequency = value;
+            if (this._joint)
+                this._joint.SetFrequency(value);
+        }
+        get damping() {
+            return this._damping;
+        }
+        set damping(value) {
+            this._damping = value;
+            if (this._joint)
+                this._joint.SetDampingRatio(value);
+        }
+    }
+    Laya.ClassUtils.regClass("laya.physics.joint.WeldJoint", WeldJoint);
+    Laya.ClassUtils.regClass("Laya.WeldJoint", WeldJoint);
+
+    class WheelJoint extends JointBase {
+        constructor() {
+            super(...arguments);
+            this.anchor = [0, 0];
+            this.collideConnected = false;
+            this.axis = [1, 0];
+            this._frequency = 5;
+            this._damping = 0.7;
+            this._enableMotor = false;
+            this._motorSpeed = 0;
+            this._maxMotorTorque = 10000;
+        }
+        _createJoint() {
+            if (!this._joint) {
+                if (!this.otherBody)
+                    throw "otherBody can not be empty";
+                this.selfBody = this.selfBody || this.owner.getComponent(RigidBody);
+                if (!this.selfBody)
+                    throw "selfBody can not be empty";
+                var box2d = window.box2d;
+                var def = WheelJoint._temp || (WheelJoint._temp = new box2d.b2WheelJointDef());
+                var anchorPos = this.selfBody.owner.localToGlobal(Laya.Point.TEMP.setTo(this.anchor[0], this.anchor[1]), false, Physics.I.worldRoot);
+                var anchorVec = new box2d.b2Vec2(anchorPos.x / Physics.PIXEL_RATIO, anchorPos.y / Physics.PIXEL_RATIO);
+                def.Initialize(this.otherBody.getBody(), this.selfBody.getBody(), anchorVec, new box2d.b2Vec2(this.axis[0], this.axis[1]));
+                def.enableMotor = this._enableMotor;
+                def.motorSpeed = this._motorSpeed;
+                def.maxMotorTorque = this._maxMotorTorque;
+                def.frequencyHz = this._frequency;
+                def.dampingRatio = this._damping;
+                def.collideConnected = this.collideConnected;
+                this._joint = Physics.I._createJoint(def);
+            }
+        }
+        get frequency() {
+            return this._frequency;
+        }
+        set frequency(value) {
+            this._frequency = value;
+            if (this._joint)
+                this._joint.SetSpringFrequencyHz(value);
+        }
+        get damping() {
+            return this._damping;
+        }
+        set damping(value) {
+            this._damping = value;
+            if (this._joint)
+                this._joint.SetSpringDampingRatio(value);
+        }
+        get enableMotor() {
+            return this._enableMotor;
+        }
+        set enableMotor(value) {
+            this._enableMotor = value;
+            if (this._joint)
+                this._joint.EnableMotor(value);
+        }
+        get motorSpeed() {
+            return this._motorSpeed;
+        }
+        set motorSpeed(value) {
+            this._motorSpeed = value;
+            if (this._joint)
+                this._joint.SetMotorSpeed(value);
+        }
+        get maxMotorTorque() {
+            return this._maxMotorTorque;
+        }
+        set maxMotorTorque(value) {
+            this._maxMotorTorque = value;
+            if (this._joint)
+                this._joint.SetMaxMotorTorque(value);
+        }
+    }
+    Laya.ClassUtils.regClass("laya.physics.joint.WheelJoint", WheelJoint);
+    Laya.ClassUtils.regClass("Laya.WheelJoint", WheelJoint);
+
+    exports.BoxCollider = BoxCollider;
+    exports.ChainCollider = ChainCollider;
+    exports.CircleCollider = CircleCollider;
+    exports.ColliderBase = ColliderBase;
+    exports.DistanceJoint = DistanceJoint;
+    exports.GearJoint = GearJoint;
+    exports.IPhysics = IPhysics;
+    exports.JointBase = JointBase;
+    exports.MotorJoint = MotorJoint;
+    exports.MouseJoint = MouseJoint;
+    exports.Physics = Physics;
+    exports.PhysicsDebugDraw = PhysicsDebugDraw;
+    exports.PolygonCollider = PolygonCollider;
+    exports.PrismaticJoint = PrismaticJoint;
+    exports.PulleyJoint = PulleyJoint;
+    exports.RevoluteJoint = RevoluteJoint;
+    exports.RigidBody = RigidBody;
+    exports.RopeJoint = RopeJoint;
+    exports.WeldJoint = WeldJoint;
+    exports.WheelJoint = WheelJoint;
+
+}(window.Laya = window.Laya || {}, Laya));

文件差異過大導致無法顯示
+ 0 - 0
ShootingSun/bin/libs/laya.physics3D.js


+ 10 - 0
ShootingSun/bin/libs/laya.physics3D.runtime.js

@@ -0,0 +1,10 @@
+window.Physics3D = function(initialMemory, interactive) {
+	window.conch.setGetWorldTransformFunction(interactive.getWorldTransform);
+	window.conch.setSetWorldTransformFunction(interactive.setWorldTransform);
+	var conchBullet = window.layaConchBullet;
+	conchBullet.then = (complete) => {
+		complete();
+	};
+	window.Physics3D = conchBullet;
+	return conchBullet;
+};

+ 23 - 0
ShootingSun/bin/libs/laya.physics3D.wasm.js

@@ -0,0 +1,23 @@
+window.Physics3D = function (initialMemory, interactive) {
+  return new Promise((resolve) => {
+    var mem = new WebAssembly.Memory({ initial: initialMemory });
+    fetch("laya.physics3D.wasm.wasm").then((response) => {
+      response.arrayBuffer().then((buffer) => {
+        WebAssembly.instantiate(buffer, {
+          LayaAirInteractive: interactive,
+          wasi_unstable: {
+            fd_close: () => { console.log('fd_close'); },
+            fd_seek: () => { console.log('fd_seek'); },
+            fd_write: () => { console.log('fd_write'); }
+          },
+          env: {
+            memory: mem,
+          }
+        }).then((physics3D) => {
+          window.Physics3D = physics3D.instance.exports;
+          resolve();
+        });
+      });
+    });
+  });
+};

二進制
ShootingSun/bin/libs/laya.physics3D.wasm.wasm


+ 1710 - 0
ShootingSun/bin/libs/laya.qqmini.js

@@ -0,0 +1,1710 @@
+window.qqMiniGame = function (exports, Laya) {
+	'use strict';
+
+	class MiniFileMgr {
+	    static isLocalNativeFile(url) {
+	        for (var i = 0, sz = QQMiniAdapter.nativefiles.length; i < sz; i++) {
+	            if (url.indexOf(QQMiniAdapter.nativefiles[i]) != -1)
+	                return true;
+	        }
+	        return false;
+	    }
+	    static getFileInfo(fileUrl) {
+	        var fileNativePath = fileUrl;
+	        var fileObj = MiniFileMgr.fakeObj[fileNativePath];
+	        if (fileObj == null)
+	            return null;
+	        else
+	            return fileObj;
+	        return null;
+	    }
+	    static read(filePath, encoding = "utf8", callBack = null, readyUrl = "", isSaveFile = false, fileType = "") {
+	        var fileUrl;
+	        if (readyUrl != "" && (readyUrl.indexOf("http://") != -1 || readyUrl.indexOf("https://") != -1)) {
+	            fileUrl = MiniFileMgr.getFileNativePath(filePath);
+	        }
+	        else {
+	            fileUrl = filePath;
+	        }
+	        fileUrl = Laya.URL.getAdptedFilePath(fileUrl);
+	        MiniFileMgr.fs.readFile({ filePath: fileUrl, encoding: encoding, success: function (data) {
+	                callBack != null && callBack.runWith([0, data]);
+	            }, fail: function (data) {
+	                if (data && readyUrl != "")
+	                    MiniFileMgr.downFiles(readyUrl, encoding, callBack, readyUrl, isSaveFile, fileType);
+	                else
+	                    callBack != null && callBack.runWith([1]);
+	            } });
+	    }
+	    static downFiles(fileUrl, encoding = "utf8", callBack = null, readyUrl = "", isSaveFile = false, fileType = "", isAutoClear = true) {
+	        var downloadTask = MiniFileMgr.wxdown({ url: fileUrl, success: function (data) {
+	                if (data.statusCode === 200)
+	                    MiniFileMgr.readFile(data.tempFilePath, encoding, callBack, readyUrl, isSaveFile, fileType, isAutoClear);
+	                else if (data.statusCode === 403) {
+	                    callBack != null && callBack.runWith([0, fileUrl]);
+	                }
+	                else {
+	                    callBack != null && callBack.runWith([1, data]);
+	                }
+	            }, fail: function (data) {
+	                callBack != null && callBack.runWith([1, data]);
+	            } });
+	        downloadTask.onProgressUpdate(function (data) {
+	            callBack != null && callBack.runWith([2, data.progress]);
+	        });
+	    }
+	    static readFile(filePath, encoding = "utf8", callBack = null, readyUrl = "", isSaveFile = false, fileType = "", isAutoClear = true) {
+	        filePath = Laya.URL.getAdptedFilePath(filePath);
+	        MiniFileMgr.fs.readFile({ filePath: filePath, encoding: encoding, success: function (data) {
+	                if (filePath.indexOf("http://") != -1 || filePath.indexOf("https://") != -1) {
+	                    if (QQMiniAdapter.autoCacheFile || isSaveFile) {
+	                        callBack != null && callBack.runWith([0, data]);
+	                        MiniFileMgr.copyFile(filePath, readyUrl, null, encoding, isAutoClear);
+	                    }
+	                    else
+	                        callBack != null && callBack.runWith([0, data]);
+	                }
+	                else
+	                    callBack != null && callBack.runWith([0, data]);
+	            }, fail: function (data) {
+	                if (data)
+	                    callBack != null && callBack.runWith([1, data]);
+	            } });
+	    }
+	    static downOtherFiles(fileUrl, callBack = null, readyUrl = "", isSaveFile = false, isAutoClear = true) {
+	        MiniFileMgr.wxdown({ url: fileUrl, success: function (data) {
+	                if (data.statusCode === 200) {
+	                    if ((QQMiniAdapter.autoCacheFile || isSaveFile) && readyUrl.indexOf("qlogo.cn") == -1 && readyUrl.indexOf(".php") == -1) {
+	                        callBack != null && callBack.runWith([0, data.tempFilePath]);
+	                        MiniFileMgr.copyFile(data.tempFilePath, readyUrl, null, "", isAutoClear);
+	                    }
+	                    else
+	                        callBack != null && callBack.runWith([0, data.tempFilePath]);
+	                }
+	                else {
+	                    callBack != null && callBack.runWith([1, data]);
+	                }
+	            }, fail: function (data) {
+	                callBack != null && callBack.runWith([1, data]);
+	            } });
+	    }
+	    static downLoadFile(fileUrl, fileType = "", callBack = null, encoding = "utf8") {
+	        if (window.navigator.userAgent.indexOf('MiniGame') < 0) {
+	            Laya.Laya.loader.load(fileUrl, callBack);
+	        }
+	        else {
+	            if (fileType == Laya.Loader.IMAGE || fileType == Laya.Loader.SOUND)
+	                MiniFileMgr.downOtherFiles(fileUrl, callBack, fileUrl, true, false);
+	            else
+	                MiniFileMgr.downFiles(fileUrl, encoding, callBack, fileUrl, true, fileType, false);
+	        }
+	    }
+	    static copyFile(tempFilePath, readyUrl, callBack, encoding = "", isAutoClear = true) {
+	        var temp = tempFilePath.split("/");
+	        var tempFileName = temp[temp.length - 1];
+	        var fileurlkey = readyUrl;
+	        var fileObj = MiniFileMgr.getFileInfo(readyUrl);
+	        var saveFilePath = MiniFileMgr.getFileNativePath(tempFileName);
+	        MiniFileMgr.fakeObj[fileurlkey] = { md5: tempFileName, readyUrl: readyUrl, size: 0, times: Laya.Browser.now(), encoding: encoding };
+	        var totalSize = 50 * 1024 * 1024;
+	        var chaSize = 4 * 1024 * 1024;
+	        var fileUseSize = MiniFileMgr.getCacheUseSize();
+	        if (fileObj) {
+	            if (fileObj.readyUrl != readyUrl) {
+	                MiniFileMgr.fs.getFileInfo({
+	                    filePath: tempFilePath,
+	                    success: function (data) {
+	                        if ((isAutoClear && (fileUseSize + chaSize + data.size) >= totalSize)) {
+	                            if (data.size > QQMiniAdapter.minClearSize)
+	                                QQMiniAdapter.minClearSize = data.size;
+	                            MiniFileMgr.onClearCacheRes();
+	                        }
+	                        MiniFileMgr.deleteFile(tempFilePath, readyUrl, callBack, encoding, data.size);
+	                    },
+	                    fail: function (data) {
+	                        callBack != null && callBack.runWith([1, data]);
+	                    }
+	                });
+	            }
+	            else
+	                callBack != null && callBack.runWith([0]);
+	        }
+	        else {
+	            MiniFileMgr.fs.getFileInfo({
+	                filePath: tempFilePath,
+	                success: function (data) {
+	                    if ((isAutoClear && (fileUseSize + chaSize + data.size) >= totalSize)) {
+	                        if (data.size > QQMiniAdapter.minClearSize)
+	                            QQMiniAdapter.minClearSize = data.size;
+	                        MiniFileMgr.onClearCacheRes();
+	                    }
+	                    MiniFileMgr.fs.copyFile({ srcPath: tempFilePath, destPath: saveFilePath, success: function (data2) {
+	                            MiniFileMgr.onSaveFile(readyUrl, tempFileName, true, encoding, callBack, data.size);
+	                        }, fail: function (data) {
+	                            callBack != null && callBack.runWith([1, data]);
+	                        } });
+	                },
+	                fail: function (data) {
+	                    callBack != null && callBack.runWith([1, data]);
+	                }
+	            });
+	        }
+	    }
+	    static onClearCacheRes() {
+	        var memSize = QQMiniAdapter.minClearSize;
+	        var tempFileListArr = [];
+	        for (var key in MiniFileMgr.filesListObj) {
+	            if (key != "fileUsedSize")
+	                tempFileListArr.push(MiniFileMgr.filesListObj[key]);
+	        }
+	        MiniFileMgr.sortOn(tempFileListArr, "times", MiniFileMgr.NUMERIC);
+	        var clearSize = 0;
+	        for (var i = 1, sz = tempFileListArr.length; i < sz; i++) {
+	            var fileObj = tempFileListArr[i];
+	            if (clearSize >= memSize)
+	                break;
+	            clearSize += fileObj.size;
+	            MiniFileMgr.deleteFile("", fileObj.readyUrl);
+	        }
+	    }
+	    static sortOn(array, name, options = 0) {
+	        if (options == MiniFileMgr.NUMERIC)
+	            return array.sort(function (a, b) { return a[name] - b[name]; });
+	        if (options == (MiniFileMgr.NUMERIC | MiniFileMgr.DESCENDING))
+	            return array.sort(function (a, b) { return b[name] - a[name]; });
+	        return array.sort(function (a, b) { return a[name] - b[name]; });
+	    }
+	    static getFileNativePath(fileName) {
+	        return MiniFileMgr.fileNativeDir + "/" + fileName;
+	    }
+	    static deleteFile(tempFileName, readyUrl = "", callBack = null, encoding = "", fileSize = 0) {
+	        var fileObj = MiniFileMgr.getFileInfo(readyUrl);
+	        var deleteFileUrl = MiniFileMgr.getFileNativePath(fileObj.md5);
+	        var isAdd = tempFileName != "" ? true : false;
+	        MiniFileMgr.onSaveFile(readyUrl, tempFileName, isAdd, encoding, callBack, fileSize);
+	        MiniFileMgr.fs.unlink({ filePath: deleteFileUrl, success: function (data) {
+	                if (tempFileName != "") {
+	                    var saveFilePath = MiniFileMgr.getFileNativePath(tempFileName);
+	                    MiniFileMgr.fs.copyFile({ srcPath: tempFileName, destPath: saveFilePath, success: function (data) {
+	                        }, fail: function (data) {
+	                            callBack != null && callBack.runWith([1, data]);
+	                        } });
+	                }
+	            }, fail: function (data) {
+	            } });
+	    }
+	    static deleteAll() {
+	        var tempFileListArr = [];
+	        for (var key in MiniFileMgr.filesListObj) {
+	            if (key != "fileUsedSize")
+	                tempFileListArr.push(MiniFileMgr.filesListObj[key]);
+	        }
+	        for (var i = 1, sz = tempFileListArr.length; i < sz; i++) {
+	            var fileObj = tempFileListArr[i];
+	            MiniFileMgr.deleteFile("", fileObj.readyUrl);
+	        }
+	        if (MiniFileMgr.filesListObj && MiniFileMgr.filesListObj.fileUsedSize) {
+	            MiniFileMgr.filesListObj.fileUsedSize = 0;
+	        }
+	        MiniFileMgr.writeFilesList("", JSON.stringify({}), false);
+	    }
+	    static onSaveFile(readyUrl, md5Name, isAdd = true, encoding = "", callBack = null, fileSize = 0) {
+	        var fileurlkey = readyUrl;
+	        if (MiniFileMgr.filesListObj['fileUsedSize'] == null)
+	            MiniFileMgr.filesListObj['fileUsedSize'] = 0;
+	        if (isAdd) {
+	            var fileNativeName = MiniFileMgr.getFileNativePath(md5Name);
+	            MiniFileMgr.filesListObj[fileurlkey] = { md5: md5Name, readyUrl: readyUrl, size: fileSize, times: Laya.Browser.now(), encoding: encoding };
+	            MiniFileMgr.filesListObj['fileUsedSize'] = parseInt(MiniFileMgr.filesListObj['fileUsedSize']) + fileSize;
+	            MiniFileMgr.writeFilesList(fileurlkey, JSON.stringify(MiniFileMgr.filesListObj), true);
+	            callBack != null && callBack.runWith([0]);
+	        }
+	        else {
+	            if (MiniFileMgr.filesListObj[fileurlkey]) {
+	                var deletefileSize = parseInt(MiniFileMgr.filesListObj[fileurlkey].size);
+	                MiniFileMgr.filesListObj['fileUsedSize'] = parseInt(MiniFileMgr.filesListObj['fileUsedSize']) - deletefileSize;
+	                delete MiniFileMgr.filesListObj[fileurlkey];
+	                MiniFileMgr.writeFilesList(fileurlkey, JSON.stringify(MiniFileMgr.filesListObj), false);
+	                callBack != null && callBack.runWith([0]);
+	            }
+	        }
+	    }
+	    static writeFilesList(fileurlkey, filesListStr, isAdd) {
+	        var listFilesPath = MiniFileMgr.fileNativeDir + "/" + MiniFileMgr.fileListName;
+	        MiniFileMgr.fs.writeFile({ filePath: listFilesPath, encoding: 'utf8', data: filesListStr, success: function (data) {
+	            }, fail: function (data) {
+	            } });
+	        if (!QQMiniAdapter.isZiYu && QQMiniAdapter.isPosMsgYu) {
+	            QQMiniAdapter.window.qq.postMessage({ url: fileurlkey, data: MiniFileMgr.filesListObj[fileurlkey], isLoad: "filenative", isAdd: isAdd });
+	        }
+	    }
+	    static getCacheUseSize() {
+	        if (MiniFileMgr.filesListObj && MiniFileMgr.filesListObj['fileUsedSize'])
+	            return MiniFileMgr.filesListObj['fileUsedSize'];
+	        return 0;
+	    }
+	    static existDir(dirPath, callBack) {
+	        MiniFileMgr.fs.mkdir({ dirPath: dirPath, success: function (data) {
+	                callBack != null && callBack.runWith([0, { data: JSON.stringify({}) }]);
+	            }, fail: function (data) {
+	                if (data.errMsg.indexOf("file already exists") != -1)
+	                    MiniFileMgr.readSync(MiniFileMgr.fileListName, "utf8", callBack);
+	                else
+	                    callBack != null && callBack.runWith([1, data]);
+	            } });
+	    }
+	    static readSync(filePath, encoding = "utf8", callBack = null, readyUrl = "") {
+	        var fileUrl = MiniFileMgr.getFileNativePath(filePath);
+	        var filesListStr;
+	        try {
+	            filesListStr = MiniFileMgr.fs.readFileSync(fileUrl, encoding);
+	            callBack != null && callBack.runWith([0, { data: filesListStr }]);
+	        }
+	        catch (error) {
+	            callBack != null && callBack.runWith([1]);
+	        }
+	    }
+	    static setNativeFileDir(value) {
+	        MiniFileMgr.fileNativeDir = QQMiniAdapter.window.qq.env.USER_DATA_PATH + value;
+	    }
+	}
+	MiniFileMgr.fs = window.qq.getFileSystemManager();
+	MiniFileMgr.wxdown = window.qq.downloadFile;
+	MiniFileMgr.filesListObj = {};
+	MiniFileMgr.fakeObj = {};
+	MiniFileMgr.fileListName = "layaairfiles.txt";
+	MiniFileMgr.ziyuFileData = {};
+	MiniFileMgr.ziyuFileTextureData = {};
+	MiniFileMgr.loadPath = "";
+	MiniFileMgr.DESCENDING = 2;
+	MiniFileMgr.NUMERIC = 16;
+
+	class MiniSoundChannel extends Laya.SoundChannel {
+	    constructor(audio, miniSound) {
+	        super();
+	        this._audio = audio;
+	        this._miniSound = miniSound;
+	        this._onEnd = MiniSoundChannel.bindToThis(this.__onEnd, this);
+	        audio.onEnded(this._onEnd);
+	    }
+	    static bindToThis(fun, scope) {
+	        var rst = fun;
+	        rst = fun.bind(scope);
+	        return rst;
+	    }
+	    __onEnd() {
+	        if (this.loops == 1) {
+	            if (this.completeHandler) {
+	                Laya.Laya.systemTimer.once(10, this, this.__runComplete, [this.completeHandler], false);
+	                this.completeHandler = null;
+	            }
+	            this.stop();
+	            this.event(Laya.Event.COMPLETE);
+	            return;
+	        }
+	        if (this.loops > 0) {
+	            this.loops--;
+	        }
+	        this.startTime = 0;
+	        this.play();
+	    }
+	    play() {
+	        this.isStopped = false;
+	        Laya.SoundManager.addChannel(this);
+	        this._audio.play();
+	    }
+	    set startTime(time) {
+	        if (this._audio) {
+	            this._audio.startTime = time;
+	        }
+	    }
+	    set autoplay(value) {
+	        this._audio.autoplay = value;
+	    }
+	    get autoplay() {
+	        return this._audio.autoplay;
+	    }
+	    get position() {
+	        if (!this._audio)
+	            return 0;
+	        return this._audio.currentTime;
+	    }
+	    get duration() {
+	        if (!this._audio)
+	            return 0;
+	        return this._audio.duration;
+	    }
+	    stop() {
+	        this.isStopped = true;
+	        Laya.SoundManager.removeChannel(this);
+	        this.completeHandler = null;
+	        if (!this._audio)
+	            return;
+	        this._audio.stop();
+	        if (!this.loop) {
+	            this._audio.offEnded(null);
+	            this._miniSound.dispose();
+	            this._audio = null;
+	            this._miniSound = null;
+	            this._onEnd = null;
+	        }
+	    }
+	    pause() {
+	        this.isStopped = true;
+	        this._audio.pause();
+	    }
+	    get loop() {
+	        return this._audio.loop;
+	    }
+	    set loop(value) {
+	        this._audio.loop = value;
+	    }
+	    resume() {
+	        if (!this._audio)
+	            return;
+	        this.isStopped = false;
+	        Laya.SoundManager.addChannel(this);
+	        this._audio.play();
+	    }
+	    set volume(v) {
+	        if (!this._audio)
+	            return;
+	        this._audio.volume = v;
+	    }
+	    get volume() {
+	        if (!this._audio)
+	            return 1;
+	        return this._audio.volume;
+	    }
+	}
+
+	class MiniSound extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	        this.loaded = false;
+	    }
+	    static _createSound() {
+	        MiniSound._id++;
+	        return QQMiniAdapter.window.qq.createInnerAudioContext();
+	    }
+	    load(url) {
+	        if (!MiniSound._musicAudio)
+	            MiniSound._musicAudio = MiniSound._createSound();
+	        if (!MiniFileMgr.isLocalNativeFile(url)) {
+	            url = Laya.URL.formatURL(url);
+	        }
+	        else {
+	            if (url.indexOf("http://") != -1 || url.indexOf("https://") != -1) {
+	                if (MiniFileMgr.loadPath != "") {
+	                    url = url.split(MiniFileMgr.loadPath)[1];
+	                }
+	                else {
+	                    var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    if (tempStr != "")
+	                        url = url.split(tempStr)[1];
+	                }
+	            }
+	        }
+	        this.url = url;
+	        this.readyUrl = url;
+	        if (MiniSound._audioCache[this.readyUrl]) {
+	            this.event(Laya.Event.COMPLETE);
+	            return;
+	        }
+	        if (QQMiniAdapter.autoCacheFile && MiniFileMgr.getFileInfo(url)) {
+	            this.onDownLoadCallBack(url, 0);
+	        }
+	        else {
+	            if (!QQMiniAdapter.autoCacheFile) {
+	                this.onDownLoadCallBack(url, 0);
+	            }
+	            else {
+	                if (MiniFileMgr.isLocalNativeFile(url)) {
+	                    tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    var tempUrl = url;
+	                    if (tempStr != "")
+	                        url = url.split(tempStr)[1];
+	                    if (!url) {
+	                        url = tempUrl;
+	                    }
+	                    if (QQMiniAdapter.subNativeFiles && QQMiniAdapter.subNativeheads.length == 0) {
+	                        for (var key in QQMiniAdapter.subNativeFiles) {
+	                            var tempArr = QQMiniAdapter.subNativeFiles[key];
+	                            QQMiniAdapter.subNativeheads = QQMiniAdapter.subNativeheads.concat(tempArr);
+	                            for (var aa = 0; aa < tempArr.length; aa++) {
+	                                QQMiniAdapter.subMaps[tempArr[aa]] = key + "/" + tempArr[aa];
+	                            }
+	                        }
+	                    }
+	                    if (QQMiniAdapter.subNativeFiles && url.indexOf("/") != -1) {
+	                        var curfileHead = url.split("/")[0] + "/";
+	                        if (curfileHead && QQMiniAdapter.subNativeheads.indexOf(curfileHead) != -1) {
+	                            var newfileHead = QQMiniAdapter.subMaps[curfileHead];
+	                            url = url.replace(curfileHead, newfileHead);
+	                        }
+	                    }
+	                    this.onDownLoadCallBack(url, 0);
+	                }
+	                else {
+	                    if (!MiniFileMgr.isLocalNativeFile(url) && (url.indexOf("http://") == -1 && url.indexOf("https://") == -1) || (url.indexOf(QQMiniAdapter.window.qq.env.USER_DATA_PATH) != -1)) {
+	                        this.onDownLoadCallBack(url, 0);
+	                    }
+	                    else {
+	                        MiniFileMgr.downOtherFiles(encodeURI(url), Laya.Handler.create(this, this.onDownLoadCallBack, [url]), url);
+	                    }
+	                }
+	            }
+	        }
+	    }
+	    onDownLoadCallBack(sourceUrl, errorCode, tempFilePath = null) {
+	        if (!errorCode) {
+	            var fileNativeUrl;
+	            if (QQMiniAdapter.autoCacheFile) {
+	                if (!tempFilePath) {
+	                    if (MiniFileMgr.isLocalNativeFile(sourceUrl)) {
+	                        var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                        var tempUrl = sourceUrl;
+	                        if (tempStr != "" && (sourceUrl.indexOf("http://") != -1 || sourceUrl.indexOf("https://") != -1))
+	                            fileNativeUrl = sourceUrl.split(tempStr)[1];
+	                        if (!fileNativeUrl) {
+	                            fileNativeUrl = tempUrl;
+	                        }
+	                    }
+	                    else {
+	                        var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                        if (fileObj && fileObj.md5) {
+	                            var fileMd5Name = fileObj.md5;
+	                            fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                        }
+	                        else {
+	                            fileNativeUrl = sourceUrl;
+	                        }
+	                    }
+	                }
+	                else {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	                if (this.url != Laya.SoundManager._bgMusic) {
+	                    this._sound = MiniSound._createSound();
+	                    this._sound.src = this.url = fileNativeUrl;
+	                }
+	                else {
+	                    this._sound = MiniSound._musicAudio;
+	                    this._sound.src = this.url = fileNativeUrl;
+	                }
+	            }
+	            else {
+	                if (this.url != Laya.SoundManager._bgMusic) {
+	                    this._sound = MiniSound._createSound();
+	                    this._sound.src = sourceUrl;
+	                }
+	                else {
+	                    this._sound = MiniSound._musicAudio;
+	                    this._sound.src = sourceUrl;
+	                }
+	            }
+	            this._sound.onCanplay(MiniSound.bindToThis(this.onCanPlay, this));
+	            this._sound.onError(MiniSound.bindToThis(this.onError, this));
+	        }
+	        else {
+	            this.event(Laya.Event.ERROR);
+	        }
+	    }
+	    onError(error) {
+	        try {
+	            console.log("-----1---------------minisound-----id:" + MiniSound._id);
+	            console.log(error);
+	        }
+	        catch (error) {
+	            console.log("-----2---------------minisound-----id:" + MiniSound._id);
+	            console.log(error);
+	        }
+	        this.event(Laya.Event.ERROR);
+	        this._sound.offError(null);
+	    }
+	    onCanPlay() {
+	        this.loaded = true;
+	        this.event(Laya.Event.COMPLETE);
+	        this._sound.offCanplay(null);
+	    }
+	    static bindToThis(fun, scope) {
+	        var rst = fun;
+	        rst = fun.bind(scope);
+	        return rst;
+	    }
+	    play(startTime = 0, loops = 0) {
+	        var tSound;
+	        if (this.url == Laya.SoundManager._bgMusic) {
+	            if (!MiniSound._musicAudio)
+	                MiniSound._musicAudio = MiniSound._createSound();
+	            tSound = MiniSound._musicAudio;
+	        }
+	        else {
+	            if (MiniSound._audioCache[this.readyUrl]) {
+	                tSound = MiniSound._audioCache[this.readyUrl]._sound;
+	            }
+	            else {
+	                tSound = MiniSound._createSound();
+	            }
+	        }
+	        if (!tSound)
+	            return null;
+	        if (QQMiniAdapter.autoCacheFile && MiniFileMgr.getFileInfo(this.url)) {
+	            var fileObj = MiniFileMgr.getFileInfo(this.url);
+	            var fileMd5Name = fileObj.md5;
+	            tSound.src = this.url = MiniFileMgr.getFileNativePath(fileMd5Name);
+	        }
+	        else {
+	            tSound.src = encodeURI(this.url);
+	        }
+	        var channel = new MiniSoundChannel(tSound, this);
+	        channel.url = this.url;
+	        channel.loops = loops;
+	        channel.loop = (loops === 0 ? true : false);
+	        channel.startTime = startTime;
+	        channel.play();
+	        Laya.SoundManager.addChannel(channel);
+	        return channel;
+	    }
+	    get duration() {
+	        return this._sound.duration;
+	    }
+	    dispose() {
+	        var ad = MiniSound._audioCache[this.readyUrl];
+	        if (ad) {
+	            ad.src = "";
+	            if (ad._sound) {
+	                ad._sound.destroy();
+	                ad._sound = null;
+	                ad = null;
+	            }
+	            delete MiniSound._audioCache[this.readyUrl];
+	        }
+	        if (this._sound) {
+	            this._sound.destroy();
+	            this._sound = null;
+	            this.readyUrl = this.url = null;
+	        }
+	    }
+	}
+	MiniSound._id = 0;
+	MiniSound._audioCache = {};
+
+	class MiniInput {
+	    constructor() {
+	    }
+	    static _createInputElement() {
+	        Laya.Input['_initInput'](Laya.Input['area'] = Laya.Browser.createElement("textarea"));
+	        Laya.Input['_initInput'](Laya.Input['input'] = Laya.Browser.createElement("input"));
+	        Laya.Input['inputContainer'] = Laya.Browser.createElement("div");
+	        Laya.Input['inputContainer'].style.position = "absolute";
+	        Laya.Input['inputContainer'].style.zIndex = 1E5;
+	        Laya.Browser.container.appendChild(Laya.Input['inputContainer']);
+	        Laya.Laya.stage.on("resize", null, MiniInput._onStageResize);
+	        QQMiniAdapter.window.qq.onWindowResize && QQMiniAdapter.window.qq.onWindowResize(function (res) {
+	        });
+	        Laya.SoundManager._soundClass = MiniSound;
+	        Laya.SoundManager._musicClass = MiniSound;
+	        var model = QQMiniAdapter.systemInfo.model;
+	        var system = QQMiniAdapter.systemInfo.system;
+	        if (model.indexOf("iPhone") != -1) {
+	            Laya.Browser.onIPhone = true;
+	            Laya.Browser.onIOS = true;
+	            Laya.Browser.onIPad = true;
+	            Laya.Browser.onAndroid = false;
+	        }
+	        if (system.indexOf("Android") != -1 || system.indexOf("Adr") != -1) {
+	            Laya.Browser.onAndroid = true;
+	            Laya.Browser.onIPhone = false;
+	            Laya.Browser.onIOS = false;
+	            Laya.Browser.onIPad = false;
+	        }
+	    }
+	    static _onStageResize() {
+	        var ts = Laya.Laya.stage._canvasTransform.identity();
+	        ts.scale((Laya.Browser.width / Laya.Render.canvas.width / Laya.Browser.pixelRatio), Laya.Browser.height / Laya.Render.canvas.height / Laya.Browser.pixelRatio);
+	    }
+	    static wxinputFocus(e) {
+	        var _inputTarget = Laya.Input['inputElement'].target;
+	        if (_inputTarget && !_inputTarget.editable) {
+	            return;
+	        }
+	        QQMiniAdapter.window.qq.offKeyboardConfirm();
+	        QQMiniAdapter.window.qq.offKeyboardInput();
+	        QQMiniAdapter.window.qq.showKeyboard({ defaultValue: _inputTarget.text, maxLength: _inputTarget.maxChars, multiple: _inputTarget.multiline, confirmHold: true, confirmType: _inputTarget["confirmType"] || 'done', success: function (res) {
+	            }, fail: function (res) {
+	            } });
+	        QQMiniAdapter.window.qq.onKeyboardConfirm(function (res) {
+	            var str = res ? res.value : "";
+	            if (_inputTarget._restrictPattern) {
+	                str = str.replace(/\u2006|\x27/g, "");
+	                if (_inputTarget._restrictPattern.test(str)) {
+	                    str = str.replace(_inputTarget._restrictPattern, "");
+	                }
+	            }
+	            _inputTarget.text = str;
+	            _inputTarget.event(Laya.Event.INPUT);
+	            MiniInput.inputEnter();
+	            _inputTarget.event("confirm");
+	        });
+	        QQMiniAdapter.window.qq.onKeyboardInput(function (res) {
+	            var str = res ? res.value : "";
+	            if (!_inputTarget.multiline) {
+	                if (str.indexOf("\n") != -1) {
+	                    MiniInput.inputEnter();
+	                    return;
+	                }
+	            }
+	            if (_inputTarget._restrictPattern) {
+	                str = str.replace(/\u2006|\x27/g, "");
+	                if (_inputTarget._restrictPattern.test(str)) {
+	                    str = str.replace(_inputTarget._restrictPattern, "");
+	                }
+	            }
+	            _inputTarget.text = str;
+	            _inputTarget.event(Laya.Event.INPUT);
+	        });
+	    }
+	    static inputEnter() {
+	        Laya.Input['inputElement'].target.focus = false;
+	    }
+	    static wxinputblur() {
+	        MiniInput.hideKeyboard();
+	    }
+	    static hideKeyboard() {
+	        QQMiniAdapter.window.qq.offKeyboardConfirm();
+	        QQMiniAdapter.window.qq.offKeyboardInput();
+	        QQMiniAdapter.window.qq.hideKeyboard({ success: function (res) {
+	                console.log('隐藏键盘');
+	            }, fail: function (res) {
+	                console.log("隐藏键盘出错:" + (res ? res.errMsg : ""));
+	            } });
+	    }
+	}
+
+	class MiniLoader extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	    }
+	    _loadResourceFilter(type, url) {
+	        var thisLoader = this;
+	        if (url.indexOf(QQMiniAdapter.window.qq.env.USER_DATA_PATH) == -1 && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1)) {
+	            if (MiniFileMgr.loadPath != "") {
+	                url = url.split(MiniFileMgr.loadPath)[1];
+	            }
+	            else {
+	                var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                var tempUrl = url;
+	                if (tempStr != "")
+	                    url = url.split(tempStr)[1];
+	                if (!url) {
+	                    url = tempUrl;
+	                }
+	            }
+	        }
+	        if (QQMiniAdapter.subNativeFiles && QQMiniAdapter.subNativeheads.length == 0) {
+	            for (var key in QQMiniAdapter.subNativeFiles) {
+	                var tempArr = QQMiniAdapter.subNativeFiles[key];
+	                QQMiniAdapter.subNativeheads = QQMiniAdapter.subNativeheads.concat(tempArr);
+	                for (var aa = 0; aa < tempArr.length; aa++) {
+	                    QQMiniAdapter.subMaps[tempArr[aa]] = key + "/" + tempArr[aa];
+	                }
+	            }
+	        }
+	        if (QQMiniAdapter.subNativeFiles && url.indexOf("/") != -1) {
+	            var curfileHead = url.split("/")[0] + "/";
+	            if (curfileHead && QQMiniAdapter.subNativeheads.indexOf(curfileHead) != -1) {
+	                var newfileHead = QQMiniAdapter.subMaps[curfileHead];
+	                url = url.replace(curfileHead, newfileHead);
+	            }
+	        }
+	        switch (type) {
+	            case Laya.Loader.IMAGE:
+	            case "htmlimage":
+	            case "nativeimage":
+	                MiniLoader._transformImgUrl(url, type, thisLoader);
+	                break;
+	            case Laya.Loader.SOUND:
+	                thisLoader._loadSound(url);
+	                break;
+	            default:
+	                thisLoader._loadResource(type, url);
+	        }
+	    }
+	    _loadSound(url) {
+	        var thisLoader = this;
+	        var fileNativeUrl;
+	        if (MiniFileMgr.isLocalNativeFile(url)) {
+	            var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	            var tempUrl = url;
+	            if (tempStr != "" && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1))
+	                fileNativeUrl = url.split(tempStr)[1];
+	            if (!fileNativeUrl) {
+	                fileNativeUrl = tempUrl;
+	            }
+	            MiniLoader.onDownLoadCallBack(url, thisLoader, 0);
+	        }
+	        else {
+	            var tempurl = Laya.URL.formatURL(url);
+	            if (!MiniFileMgr.isLocalNativeFile(url) && (tempurl.indexOf("http://") == -1 && tempurl.indexOf("https://") == -1) || (tempurl.indexOf(QQMiniAdapter.window.qq.env.USER_DATA_PATH) != -1)) {
+	                MiniLoader.onDownLoadCallBack(url, thisLoader, 0);
+	            }
+	            else {
+	                MiniFileMgr.downOtherFiles(encodeURI(tempurl), Laya.Handler.create(MiniLoader, MiniLoader.onDownLoadCallBack, [tempurl, thisLoader]), tempurl);
+	            }
+	        }
+	    }
+	    static onDownLoadCallBack(sourceUrl, thisLoader, errorCode, tempFilePath = null) {
+	        if (!errorCode) {
+	            var fileNativeUrl;
+	            if (QQMiniAdapter.autoCacheFile) {
+	                if (!tempFilePath) {
+	                    if (MiniFileMgr.isLocalNativeFile(sourceUrl)) {
+	                        var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                        var tempUrl = sourceUrl;
+	                        if (tempStr != "" && (sourceUrl.indexOf("http://") != -1 || sourceUrl.indexOf("https://") != -1))
+	                            fileNativeUrl = sourceUrl.split(tempStr)[1];
+	                        if (!fileNativeUrl) {
+	                            fileNativeUrl = tempUrl;
+	                        }
+	                    }
+	                    else {
+	                        var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                        if (fileObj && fileObj.md5) {
+	                            var fileMd5Name = fileObj.md5;
+	                            fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                        }
+	                        else {
+	                            fileNativeUrl = sourceUrl;
+	                        }
+	                    }
+	                }
+	                else {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	            }
+	            sourceUrl = fileNativeUrl;
+	            var sound = (new Laya.SoundManager._soundClass());
+	            sound.load(encodeURI(sourceUrl));
+	            thisLoader.onLoaded(sound);
+	        }
+	        else {
+	            thisLoader.event(Laya.Event.ERROR, "Load sound failed");
+	        }
+	    }
+	    static bindToThis(fun, scope) {
+	        var rst = fun;
+	        rst = fun.bind(scope);
+	        return rst;
+	    }
+	    _loadHttpRequestWhat(url, contentType) {
+	        var thisLoader = this;
+	        var encoding = QQMiniAdapter.getUrlEncode(url, contentType);
+	        if (Laya.Loader.preLoadedMap[url])
+	            thisLoader.onLoaded(Laya.Loader.preLoadedMap[url]);
+	        else {
+	            var tempurl = Laya.URL.formatURL(url);
+	            if (!MiniFileMgr.isLocalNativeFile(url) && !MiniFileMgr.getFileInfo(tempurl) && url.indexOf(QQMiniAdapter.window.qq.env.USER_DATA_PATH) == -1 && (tempurl.indexOf("http://") != -1 || tempurl.indexOf("https://") != -1) && !QQMiniAdapter.AutoCacheDownFile) {
+	                thisLoader._loadHttpRequest(tempurl, contentType, thisLoader, thisLoader.onLoaded, thisLoader, thisLoader.onProgress, thisLoader, thisLoader.onError);
+	            }
+	            else {
+	                var fileObj = MiniFileMgr.getFileInfo(Laya.URL.formatURL(url));
+	                if (fileObj) {
+	                    fileObj.encoding = fileObj.encoding == null ? "utf8" : fileObj.encoding;
+	                    MiniFileMgr.readFile(MiniFileMgr.getFileNativePath(fileObj.md5), encoding, new Laya.Handler(MiniLoader, MiniLoader.onReadNativeCallBack, [url, contentType, thisLoader]), url);
+	                }
+	                else if (thisLoader.type == "image" || thisLoader.type == "htmlimage") {
+	                    thisLoader._transformUrl(url, contentType);
+	                }
+	                else {
+	                    if (contentType != Laya.Loader.IMAGE && ((tempurl.indexOf("http://") == -1 && tempurl.indexOf("https://") == -1) || MiniFileMgr.isLocalNativeFile(url))) {
+	                        MiniFileMgr.readFile(url, encoding, new Laya.Handler(MiniLoader, MiniLoader.onReadNativeCallBack, [url, contentType, thisLoader]), url);
+	                    }
+	                    else {
+	                        MiniFileMgr.downFiles(encodeURI(tempurl), encoding, new Laya.Handler(MiniLoader, MiniLoader.onReadNativeCallBack, [url, contentType, thisLoader]), tempurl, true);
+	                    }
+	                }
+	            }
+	        }
+	    }
+	    static onReadNativeCallBack(url, type = null, thisLoader = null, errorCode = 0, data = null) {
+	        if (!errorCode) {
+	            var tempData;
+	            if (type == Laya.Loader.JSON || type == Laya.Loader.ATLAS || type == Laya.Loader.PREFAB || type == Laya.Loader.PLF) {
+	                tempData = QQMiniAdapter.getJson(data.data);
+	            }
+	            else if (type == Laya.Loader.XML) {
+	                tempData = Laya.Utils.parseXMLFromString(data.data);
+	            }
+	            else {
+	                tempData = data.data;
+	            }
+	            if (!QQMiniAdapter.isZiYu && QQMiniAdapter.isPosMsgYu && type != Laya.Loader.BUFFER) {
+	                QQMiniAdapter.window.qq.postMessage({ url: url, data: tempData, isLoad: "filedata" });
+	            }
+	            thisLoader.onLoaded(tempData);
+	        }
+	        else if (errorCode == 1) {
+	            thisLoader._loadHttpRequest(url, type, thisLoader, thisLoader.onLoaded, thisLoader, thisLoader.onProgress, thisLoader, thisLoader.onError);
+	        }
+	    }
+	    static _transformImgUrl(url, type, thisLoader) {
+	        if (QQMiniAdapter.isZiYu) {
+	            thisLoader._loadImage(url, false);
+	            return;
+	        }
+	        if (MiniFileMgr.isLocalNativeFile(url)) {
+	            thisLoader._loadImage(url, false);
+	            return;
+	        }
+	        if (!MiniFileMgr.isLocalNativeFile(url) && !MiniFileMgr.getFileInfo(Laya.URL.formatURL(url))) {
+	            var tempUrl = Laya.URL.formatURL(url);
+	            if (url.indexOf(QQMiniAdapter.window.qq.env.USER_DATA_PATH) == -1 && (tempUrl.indexOf("http://") != -1 || tempUrl.indexOf("https://") != -1)) {
+	                if (QQMiniAdapter.isZiYu) {
+	                    thisLoader._loadImage(url, false);
+	                }
+	                else {
+	                    MiniFileMgr.downOtherFiles(encodeURI(tempUrl), new Laya.Handler(MiniLoader, MiniLoader.onDownImgCallBack, [url, thisLoader]), tempUrl);
+	                }
+	            }
+	            else
+	                thisLoader._loadImage(url, false);
+	        }
+	        else {
+	            MiniLoader.onCreateImage(url, thisLoader);
+	        }
+	    }
+	    static onDownImgCallBack(sourceUrl, thisLoader, errorCode, tempFilePath = "") {
+	        if (!errorCode)
+	            MiniLoader.onCreateImage(sourceUrl, thisLoader, false, tempFilePath);
+	        else {
+	            thisLoader.onError(null);
+	        }
+	    }
+	    static onCreateImage(sourceUrl, thisLoader, isLocal = false, tempFilePath = "") {
+	        var fileNativeUrl;
+	        if (QQMiniAdapter.autoCacheFile) {
+	            if (!isLocal) {
+	                if (tempFilePath != "") {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	                else {
+	                    var fileObj = MiniFileMgr.getFileInfo(Laya.URL.formatURL(sourceUrl));
+	                    var fileMd5Name = fileObj.md5;
+	                    fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                }
+	            }
+	            else if (QQMiniAdapter.isZiYu) {
+	                var tempUrl = Laya.URL.formatURL(sourceUrl);
+	                if (MiniFileMgr.ziyuFileTextureData[tempUrl]) {
+	                    fileNativeUrl = MiniFileMgr.ziyuFileTextureData[tempUrl];
+	                }
+	                else
+	                    fileNativeUrl = sourceUrl;
+	            }
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        else {
+	            if (!isLocal)
+	                fileNativeUrl = tempFilePath;
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        thisLoader._loadImage(fileNativeUrl, false);
+	    }
+	}
+
+	class MiniLocalStorage {
+	    constructor() {
+	    }
+	    static __init__() {
+	        MiniLocalStorage.items = MiniLocalStorage;
+	    }
+	    static setItem(key, value) {
+	        try {
+	            QQMiniAdapter.window.qq.setStorageSync(key, value);
+	        }
+	        catch (error) {
+	            QQMiniAdapter.window.qq.setStorage({
+	                key: key,
+	                data: value
+	            });
+	        }
+	    }
+	    static getItem(key) {
+	        return QQMiniAdapter.window.qq.getStorageSync(key);
+	    }
+	    static setJSON(key, value) {
+	        MiniLocalStorage.setItem(key, value);
+	    }
+	    static getJSON(key) {
+	        return MiniLocalStorage.getItem(key);
+	    }
+	    static removeItem(key) {
+	        QQMiniAdapter.window.qq.removeStorageSync(key);
+	    }
+	    static clear() {
+	        QQMiniAdapter.window.qq.clearStorageSync();
+	    }
+	    static getStorageInfoSync() {
+	        try {
+	            var res = QQMiniAdapter.window.qq.getStorageInfoSync();
+	            console.log(res.keys);
+	            console.log(res.currentSize);
+	            console.log(res.limitSize);
+	            return res;
+	        }
+	        catch (e) {
+	        }
+	        return null;
+	    }
+	}
+	MiniLocalStorage.support = true;
+
+	class QQMiniAdapter {
+	    static getJson(data) {
+	        return JSON.parse(data);
+	    }
+	    static enable() {
+	        QQMiniAdapter.init(Laya.Laya.isWXPosMsg, Laya.Laya.isWXOpenDataContext);
+	    }
+	    static init(isPosMsg = false, isSon = false) {
+	        if (QQMiniAdapter._inited)
+	            return;
+	        QQMiniAdapter._inited = true;
+	        QQMiniAdapter.window = window;
+	        if (!QQMiniAdapter.window.hasOwnProperty("qq"))
+	            return;
+	        if (QQMiniAdapter.window.navigator.userAgent.indexOf('MiniGame') < 0)
+	            return;
+	        QQMiniAdapter.isZiYu = isSon;
+	        QQMiniAdapter.isPosMsgYu = isPosMsg;
+	        QQMiniAdapter.EnvConfig = {};
+	        if (!QQMiniAdapter.isZiYu) {
+	            MiniFileMgr.setNativeFileDir("/layaairGame");
+	            MiniFileMgr.existDir(MiniFileMgr.fileNativeDir, Laya.Handler.create(QQMiniAdapter, QQMiniAdapter.onMkdirCallBack));
+	        }
+	        QQMiniAdapter.systemInfo = QQMiniAdapter.window.qq.getSystemInfoSync();
+	        QQMiniAdapter.window.focus = function () {
+	        };
+	        Laya.Laya['_getUrlPath'] = function () {
+	            return "";
+	        };
+	        QQMiniAdapter.window.logtime = function (str) {
+	        };
+	        QQMiniAdapter.window.alertTimeLog = function (str) {
+	        };
+	        QQMiniAdapter.window.resetShareInfo = function () {
+	        };
+	        QQMiniAdapter.window.CanvasRenderingContext2D = function () {
+	        };
+	        QQMiniAdapter.window.CanvasRenderingContext2D.prototype = QQMiniAdapter.window.qq.createCanvas().getContext('2d').__proto__;
+	        QQMiniAdapter.window.document.body.appendChild = function () {
+	        };
+	        QQMiniAdapter.EnvConfig.pixelRatioInt = 0;
+	        Laya.Browser["_pixelRatio"] = QQMiniAdapter.pixelRatio();
+	        QQMiniAdapter._preCreateElement = Laya.Browser.createElement;
+	        Laya.Browser["createElement"] = QQMiniAdapter.createElement;
+	        Laya.RunDriver.createShaderCondition = QQMiniAdapter.createShaderCondition;
+	        Laya.Utils['parseXMLFromString'] = QQMiniAdapter.parseXMLFromString;
+	        Laya.Input['_createInputElement'] = MiniInput['_createInputElement'];
+	        Laya.Loader.prototype._loadResourceFilter = MiniLoader.prototype._loadResourceFilter;
+	        Laya.Loader.prototype._loadSound = MiniLoader.prototype._loadSound;
+	        Laya.Loader.prototype._loadHttpRequestWhat = MiniLoader.prototype._loadHttpRequestWhat;
+	        Laya.LocalStorage._baseClass = MiniLocalStorage;
+	        MiniLocalStorage.__init__();
+	        Laya.Config.useRetinalCanvas = true;
+	        QQMiniAdapter.window.qq.onMessage && QQMiniAdapter.window.qq.onMessage(QQMiniAdapter._onMessage);
+	    }
+	    static _onMessage(data) {
+	        switch (data.type) {
+	            case "changeMatrix":
+	                Laya.Laya.stage.transform.identity();
+	                Laya.Laya.stage._width = data.w;
+	                Laya.Laya.stage._height = data.h;
+	                Laya.Laya.stage._canvasTransform = new Laya.Matrix(data.a, data.b, data.c, data.d, data.tx, data.ty);
+	                break;
+	            case "display":
+	                Laya.Laya.stage.frameRate = data.rate || Laya.Stage.FRAME_FAST;
+	                break;
+	            case "undisplay":
+	                Laya.Laya.stage.frameRate = Laya.Stage.FRAME_SLEEP;
+	                break;
+	        }
+	        if (data['isLoad'] == "opendatacontext") {
+	            if (data.url) {
+	                MiniFileMgr.ziyuFileData[data.url] = data.atlasdata;
+	                MiniFileMgr.ziyuFileTextureData[data.imgReadyUrl] = data.imgNativeUrl;
+	            }
+	        }
+	        else if (data['isLoad'] == "openJsondatacontext") {
+	            if (data.url) {
+	                MiniFileMgr.ziyuFileData[data.url] = data.atlasdata;
+	            }
+	        }
+	        else if (data['isLoad'] == "openJsondatacontextPic") {
+	            MiniFileMgr.ziyuFileTextureData[data.imgReadyUrl] = data.imgNativeUrl;
+	        }
+	    }
+	    static getUrlEncode(url, type) {
+	        if (type == "arraybuffer")
+	            return "";
+	        return "utf8";
+	    }
+	    static downLoadFile(fileUrl, fileType = "", callBack = null, encoding = "utf8") {
+	        var fileObj = MiniFileMgr.getFileInfo(fileUrl);
+	        if (!fileObj)
+	            MiniFileMgr.downLoadFile(fileUrl, fileType, callBack, encoding);
+	        else {
+	            callBack != null && callBack.runWith([0]);
+	        }
+	    }
+	    static remove(fileUrl, callBack = null) {
+	        MiniFileMgr.deleteFile("", fileUrl, callBack, "", 0);
+	    }
+	    static removeAll() {
+	        MiniFileMgr.deleteAll();
+	    }
+	    static hasNativeFile(fileUrl) {
+	        return MiniFileMgr.isLocalNativeFile(fileUrl);
+	    }
+	    static getFileInfo(fileUrl) {
+	        return MiniFileMgr.getFileInfo(fileUrl);
+	    }
+	    static getFileList() {
+	        return MiniFileMgr.filesListObj;
+	    }
+	    static exitMiniProgram() {
+	        QQMiniAdapter.window["wx"].exitMiniProgram();
+	    }
+	    static onMkdirCallBack(errorCode, data) {
+	        if (!errorCode)
+	            MiniFileMgr.filesListObj = JSON.parse(data.data);
+	        MiniFileMgr.fakeObj = MiniFileMgr.filesListObj;
+	    }
+	    static pixelRatio() {
+	        if (!QQMiniAdapter.EnvConfig.pixelRatioInt) {
+	            try {
+	                QQMiniAdapter.EnvConfig.pixelRatioInt = QQMiniAdapter.systemInfo.pixelRatio;
+	                return QQMiniAdapter.systemInfo.pixelRatio;
+	            }
+	            catch (error) {
+	            }
+	        }
+	        return QQMiniAdapter.EnvConfig.pixelRatioInt;
+	    }
+	    static createElement(type) {
+	        if (type == "canvas") {
+	            var _source;
+	            if (QQMiniAdapter.idx == 1) {
+	                if (QQMiniAdapter.isZiYu) {
+	                    _source = QQMiniAdapter.window.sharedCanvas;
+	                    _source.style = {};
+	                }
+	                else {
+	                    _source = QQMiniAdapter.window.canvas;
+	                }
+	            }
+	            else {
+	                _source = QQMiniAdapter.window.qq.createCanvas();
+	            }
+	            QQMiniAdapter.idx++;
+	            return _source;
+	        }
+	        else if (type == "textarea" || type == "input") {
+	            return QQMiniAdapter.onCreateInput(type);
+	        }
+	        else if (type == "div") {
+	            var node = QQMiniAdapter._preCreateElement(type);
+	            node.contains = function (value) {
+	                return null;
+	            };
+	            node.removeChild = function (value) {
+	            };
+	            return node;
+	        }
+	        else {
+	            return QQMiniAdapter._preCreateElement(type);
+	        }
+	    }
+	    static onCreateInput(type) {
+	        var node = QQMiniAdapter._preCreateElement(type);
+	        node.focus = MiniInput.wxinputFocus;
+	        node.blur = MiniInput.wxinputblur;
+	        node.style = {};
+	        node.value = 0;
+	        node.parentElement = {};
+	        node.placeholder = {};
+	        node.type = {};
+	        node.setColor = function (value) {
+	        };
+	        node.setType = function (value) {
+	        };
+	        node.setFontFace = function (value) {
+	        };
+	        node.addEventListener = function (value) {
+	        };
+	        node.contains = function (value) {
+	            return null;
+	        };
+	        node.removeChild = function (value) {
+	        };
+	        return node;
+	    }
+	    static createShaderCondition(conditionScript) {
+	        var func = function () {
+	            return this[conditionScript.replace("this.", "")];
+	        };
+	        return func;
+	    }
+	    static sendAtlasToOpenDataContext(url) {
+	        if (!QQMiniAdapter.isZiYu) {
+	            var atlasJson = Laya.Loader.getRes(Laya.URL.formatURL(url));
+	            if (atlasJson) {
+	                var textureArr = atlasJson.meta.image.split(",");
+	                if (atlasJson.meta && atlasJson.meta.image) {
+	                    var toloadPics = atlasJson.meta.image.split(",");
+	                    var split = url.indexOf("/") >= 0 ? "/" : "\\";
+	                    var idx = url.lastIndexOf(split);
+	                    var folderPath = idx >= 0 ? url.substr(0, idx + 1) : "";
+	                    for (var i = 0, len = toloadPics.length; i < len; i++) {
+	                        toloadPics[i] = folderPath + toloadPics[i];
+	                    }
+	                }
+	                else {
+	                    toloadPics = [url.replace(".json", ".png")];
+	                }
+	                for (i = 0; i < toloadPics.length; i++) {
+	                    var tempAtlasPngUrl = toloadPics[i];
+	                    QQMiniAdapter.postInfoToContext(Laya.Laya.URL.formatURL(url), Laya.Laya.URL.formatURL(tempAtlasPngUrl), atlasJson);
+	                }
+	            }
+	            else {
+	                throw "传递的url没有获取到对应的图集数据信息,请确保图集已经过!";
+	            }
+	        }
+	    }
+	    static postInfoToContext(url, atlaspngUrl, atlasJson) {
+	        var postData = { "frames": atlasJson.frames, "meta": atlasJson.meta };
+	        var textureUrl = atlaspngUrl;
+	        var fileObj = MiniFileMgr.getFileInfo(Laya.URL.formatURL(atlaspngUrl));
+	        if (fileObj) {
+	            var fileMd5Name = fileObj.md5;
+	            var fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	        }
+	        else {
+	            fileNativeUrl = textureUrl;
+	        }
+	        if (fileNativeUrl) {
+	            QQMiniAdapter.window.qq.postMessage({ url: url, atlasdata: postData, imgNativeUrl: fileNativeUrl, imgReadyUrl: textureUrl, isLoad: "opendatacontext" });
+	        }
+	        else {
+	            throw "获取图集的磁盘url路径不存在!";
+	        }
+	    }
+	    static sendSinglePicToOpenDataContext(url) {
+	        var tempTextureUrl = Laya.URL.formatURL(url);
+	        var fileObj = MiniFileMgr.getFileInfo(tempTextureUrl);
+	        if (fileObj) {
+	            var fileMd5Name = fileObj.md5;
+	            var fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	            url = tempTextureUrl;
+	        }
+	        else {
+	            fileNativeUrl = url;
+	        }
+	        if (fileNativeUrl) {
+	            url = Laya.Laya.URL.formatURL(url);
+	            QQMiniAdapter.window.qq.postMessage({ url: url, imgNativeUrl: fileNativeUrl, imgReadyUrl: url, isLoad: "openJsondatacontextPic" });
+	        }
+	        else {
+	            throw "获取图集的磁盘url路径不存在!";
+	        }
+	    }
+	    static sendJsonDataToDataContext(url) {
+	        if (!QQMiniAdapter.isZiYu) {
+	            url = Laya.Laya.URL.formatURL(url);
+	            var atlasJson = Laya.Loader.getRes(url);
+	            if (atlasJson) {
+	                QQMiniAdapter.window.qq.postMessage({ url: url, atlasdata: atlasJson, isLoad: "openJsondatacontext" });
+	            }
+	            else {
+	                throw "传递的url没有获取到对应的图集数据信息,请确保图集已经过!";
+	            }
+	        }
+	    }
+	}
+	QQMiniAdapter._inited = false;
+	QQMiniAdapter.autoCacheFile = true;
+	QQMiniAdapter.minClearSize = (5 * 1024 * 1024);
+	QQMiniAdapter.nativefiles = ["layaNativeDir", "wxlocal"];
+	QQMiniAdapter.subNativeFiles = [];
+	QQMiniAdapter.subNativeheads = [];
+	QQMiniAdapter.subMaps = [];
+	QQMiniAdapter.AutoCacheDownFile = false;
+	QQMiniAdapter.parseXMLFromString = function (value) {
+	    var rst;
+	    value = value.replace(/>\s+</g, '><');
+	    try {
+	        rst = (new QQMiniAdapter.window.Parser.DOMParser()).parseFromString(value, 'text/xml');
+	    }
+	    catch (error) {
+	        throw "需要引入xml解析库文件";
+	    }
+	    return rst;
+	};
+	QQMiniAdapter.idx = 1;
+
+	class MiniAccelerator extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	    }
+	    static __init__() {
+	        try {
+	            var Acc;
+	            Acc = Laya.Accelerator;
+	            if (!Acc)
+	                return;
+	            Acc["prototype"]["on"] = MiniAccelerator["prototype"]["on"];
+	            Acc["prototype"]["off"] = MiniAccelerator["prototype"]["off"];
+	        }
+	        catch (e) {
+	        }
+	    }
+	    static startListen(callBack) {
+	        MiniAccelerator._callBack = callBack;
+	        if (MiniAccelerator._isListening)
+	            return;
+	        MiniAccelerator._isListening = true;
+	        try {
+	            QQMiniAdapter.window.qq.onAccelerometerChange(MiniAccelerator.onAccelerometerChange);
+	        }
+	        catch (e) { }
+	    }
+	    static stopListen() {
+	        MiniAccelerator._isListening = false;
+	        try {
+	            QQMiniAdapter.window.qq.stopAccelerometer({});
+	        }
+	        catch (e) { }
+	    }
+	    static onAccelerometerChange(res) {
+	        var e;
+	        e = {};
+	        e.acceleration = res;
+	        e.accelerationIncludingGravity = res;
+	        e.rotationRate = {};
+	        if (MiniAccelerator._callBack != null) {
+	            MiniAccelerator._callBack(e);
+	        }
+	    }
+	    on(type, caller, listener, args = null) {
+	        super.on(type, caller, listener, args);
+	        MiniAccelerator.startListen(this["onDeviceOrientationChange"]);
+	        return this;
+	    }
+	    off(type, caller, listener, onceOnly = false) {
+	        if (!this.hasListener(type))
+	            MiniAccelerator.stopListen();
+	        return super.off(type, caller, listener, onceOnly);
+	    }
+	}
+	MiniAccelerator._isListening = false;
+
+	class MiniImage {
+	    _loadImage(url) {
+	        var thisLoader = this;
+	        if (QQMiniAdapter.isZiYu) {
+	            MiniImage.onCreateImage(url, thisLoader, true);
+	            return;
+	        }
+	        var isTransformUrl;
+	        if (!MiniFileMgr.isLocalNativeFile(url)) {
+	            isTransformUrl = true;
+	            url = Laya.URL.formatURL(url);
+	        }
+	        else {
+	            if (url.indexOf(QQMiniAdapter.window.qq.env.USER_DATA_PATH) == -1 && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1)) {
+	                if (MiniFileMgr.loadPath != "") {
+	                    url = url.split(MiniFileMgr.loadPath)[1];
+	                }
+	                else {
+	                    var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    var tempUrl = url;
+	                    if (tempStr != "")
+	                        url = url.split(tempStr)[1];
+	                    if (!url) {
+	                        url = tempUrl;
+	                    }
+	                }
+	            }
+	            if (QQMiniAdapter.subNativeFiles && QQMiniAdapter.subNativeheads.length == 0) {
+	                for (var key in QQMiniAdapter.subNativeFiles) {
+	                    var tempArr = QQMiniAdapter.subNativeFiles[key];
+	                    QQMiniAdapter.subNativeheads = QQMiniAdapter.subNativeheads.concat(tempArr);
+	                    for (var aa = 0; aa < tempArr.length; aa++) {
+	                        QQMiniAdapter.subMaps[tempArr[aa]] = key + "/" + tempArr[aa];
+	                    }
+	                }
+	            }
+	            if (QQMiniAdapter.subNativeFiles && url.indexOf("/") != -1) {
+	                var curfileHead = url.split("/")[0] + "/";
+	                if (curfileHead && QQMiniAdapter.subNativeheads.indexOf(curfileHead) != -1) {
+	                    var newfileHead = QQMiniAdapter.subMaps[curfileHead];
+	                    url = url.replace(curfileHead, newfileHead);
+	                }
+	            }
+	        }
+	        if (!MiniFileMgr.getFileInfo(url)) {
+	            if (url.indexOf(QQMiniAdapter.window.qq.env.USER_DATA_PATH) == -1 && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1)) {
+	                if (QQMiniAdapter.isZiYu) {
+	                    MiniImage.onCreateImage(url, thisLoader, true);
+	                }
+	                else {
+	                    MiniFileMgr.downOtherFiles(encodeURI(url), new Laya.Handler(MiniImage, MiniImage.onDownImgCallBack, [url, thisLoader]), url);
+	                }
+	            }
+	            else
+	                MiniImage.onCreateImage(url, thisLoader, true);
+	        }
+	        else {
+	            MiniImage.onCreateImage(url, thisLoader, !isTransformUrl);
+	        }
+	    }
+	    static onDownImgCallBack(sourceUrl, thisLoader, errorCode, tempFilePath = "") {
+	        if (!errorCode)
+	            MiniImage.onCreateImage(sourceUrl, thisLoader, false, tempFilePath);
+	        else {
+	            thisLoader.onError(null);
+	        }
+	    }
+	    static onCreateImage(sourceUrl, thisLoader, isLocal = false, tempFilePath = "") {
+	        var fileNativeUrl;
+	        if (QQMiniAdapter.autoCacheFile) {
+	            if (!isLocal) {
+	                if (tempFilePath != "") {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	                else {
+	                    var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                    var fileMd5Name = fileObj.md5;
+	                    fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                }
+	            }
+	            else if (QQMiniAdapter.isZiYu) {
+	                var tempUrl = Laya.URL.formatURL(sourceUrl);
+	                if (MiniFileMgr.ziyuFileTextureData[tempUrl]) {
+	                    fileNativeUrl = MiniFileMgr.ziyuFileTextureData[tempUrl];
+	                }
+	                else
+	                    fileNativeUrl = sourceUrl;
+	            }
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        else {
+	            if (!isLocal)
+	                fileNativeUrl = tempFilePath;
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        if (thisLoader._imgCache == null)
+	            thisLoader._imgCache = {};
+	        var image;
+	        function clear() {
+	            var img = thisLoader._imgCache[fileNativeUrl];
+	            if (img) {
+	                img.onload = null;
+	                img.onerror = null;
+	                delete thisLoader._imgCache[fileNativeUrl];
+	            }
+	        }
+	        var onerror = function () {
+	            clear();
+	            delete MiniFileMgr.fakeObj[sourceUrl];
+	            delete MiniFileMgr.filesListObj[sourceUrl];
+	            thisLoader.event(Laya.Event.ERROR, "Load image failed");
+	        };
+	        if (thisLoader._type == "nativeimage") {
+	            var onload = function () {
+	                clear();
+	                thisLoader.onLoaded(image);
+	            };
+	            image = new Laya.Browser.window.Image();
+	            image.crossOrigin = "";
+	            image.onload = onload;
+	            image.onerror = onerror;
+	            image.src = fileNativeUrl;
+	            thisLoader._imgCache[fileNativeUrl] = image;
+	        }
+	        else {
+	            var imageSource = new Laya.Browser.window.Image();
+	            onload = function () {
+	                image = Laya.HTMLImage.create(imageSource.width, imageSource.height);
+	                image.loadImageSource(imageSource, true);
+	                image._setCreateURL(fileNativeUrl);
+	                clear();
+	                thisLoader.onLoaded(image);
+	            };
+	            imageSource.crossOrigin = "";
+	            imageSource.onload = onload;
+	            imageSource.onerror = onerror;
+	            imageSource.src = fileNativeUrl;
+	            thisLoader._imgCache[fileNativeUrl] = imageSource;
+	        }
+	    }
+	}
+
+	class MiniLocation {
+	    constructor() {
+	    }
+	    static __init__() {
+	        QQMiniAdapter.window.navigator.geolocation.getCurrentPosition = MiniLocation.getCurrentPosition;
+	        QQMiniAdapter.window.navigator.geolocation.watchPosition = MiniLocation.watchPosition;
+	        QQMiniAdapter.window.navigator.geolocation.clearWatch = MiniLocation.clearWatch;
+	    }
+	    static getCurrentPosition(success = null, error = null, options = null) {
+	        var paramO;
+	        paramO = {};
+	        paramO.success = getSuccess;
+	        paramO.fail = error;
+	        QQMiniAdapter.window.qq.getLocation(paramO);
+	        function getSuccess(res) {
+	            if (success != null) {
+	                success(res);
+	            }
+	        }
+	    }
+	    static watchPosition(success = null, error = null, options = null) {
+	        MiniLocation._curID++;
+	        var curWatchO;
+	        curWatchO = {};
+	        curWatchO.success = success;
+	        curWatchO.error = error;
+	        MiniLocation._watchDic[MiniLocation._curID] = curWatchO;
+	        Laya.Laya.systemTimer.loop(1000, null, MiniLocation._myLoop);
+	        return MiniLocation._curID;
+	    }
+	    static clearWatch(id) {
+	        delete MiniLocation._watchDic[id];
+	        if (!MiniLocation._hasWatch()) {
+	            Laya.Laya.systemTimer.clear(null, MiniLocation._myLoop);
+	        }
+	    }
+	    static _hasWatch() {
+	        var key;
+	        for (key in MiniLocation._watchDic) {
+	            if (MiniLocation._watchDic[key])
+	                return true;
+	        }
+	        return false;
+	    }
+	    static _myLoop() {
+	        MiniLocation.getCurrentPosition(MiniLocation._mySuccess, MiniLocation._myError);
+	    }
+	    static _mySuccess(res) {
+	        var rst = {};
+	        rst.coords = res;
+	        rst.timestamp = Laya.Browser.now();
+	        var key;
+	        for (key in MiniLocation._watchDic) {
+	            if (MiniLocation._watchDic[key].success) {
+	                MiniLocation._watchDic[key].success(rst);
+	            }
+	        }
+	    }
+	    static _myError(res) {
+	        var key;
+	        for (key in MiniLocation._watchDic) {
+	            if (MiniLocation._watchDic[key].error) {
+	                MiniLocation._watchDic[key].error(res);
+	            }
+	        }
+	    }
+	}
+	MiniLocation._watchDic = {};
+	MiniLocation._curID = 0;
+
+	class MiniVideo {
+	    constructor(width = 320, height = 240) {
+	        this.videoend = false;
+	        this.videourl = "";
+	        this.videoElement = QQMiniAdapter.window.qq.createVideo({ width: width, height: height, autoplay: true });
+	    }
+	    static __init__() {
+	    }
+	    on(eventType, ths, callBack) {
+	        if (eventType == "loadedmetadata") {
+	            this.onPlayFunc = callBack.bind(ths);
+	            this.videoElement.onPlay = this.onPlayFunction.bind(this);
+	        }
+	        else if (eventType == "ended") {
+	            this.onEndedFunC = callBack.bind(ths);
+	            this.videoElement.onEnded = this.onEndedFunction.bind(this);
+	        }
+	        this.videoElement.onTimeUpdate = this.onTimeUpdateFunc.bind(this);
+	    }
+	    onTimeUpdateFunc(data) {
+	        this.position = data.position;
+	        this._duration = data.duration;
+	    }
+	    get duration() {
+	        return this._duration;
+	    }
+	    onPlayFunction() {
+	        if (this.videoElement)
+	            this.videoElement.readyState = 200;
+	        console.log("=====视频加载完成========");
+	        this.onPlayFunc != null && this.onPlayFunc();
+	    }
+	    onEndedFunction() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoend = true;
+	        console.log("=====视频播放完毕========");
+	        this.onEndedFunC != null && this.onEndedFunC();
+	    }
+	    off(eventType, ths, callBack) {
+	        if (eventType == "loadedmetadata") {
+	            this.onPlayFunc = callBack.bind(ths);
+	            this.videoElement.offPlay = this.onPlayFunction.bind(this);
+	        }
+	        else if (eventType == "ended") {
+	            this.onEndedFunC = callBack.bind(ths);
+	            this.videoElement.offEnded = this.onEndedFunction.bind(this);
+	        }
+	    }
+	    load(url) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.src = url;
+	    }
+	    play() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoend = false;
+	        this.videoElement.play();
+	    }
+	    pause() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoend = true;
+	        this.videoElement.pause();
+	    }
+	    get currentTime() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.initialTime;
+	    }
+	    set currentTime(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.initialTime = value;
+	    }
+	    get videoWidth() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.width;
+	    }
+	    get videoHeight() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.height;
+	    }
+	    get ended() {
+	        return this.videoend;
+	    }
+	    get loop() {
+	        if (!this.videoElement)
+	            return false;
+	        return this.videoElement.loop;
+	    }
+	    set loop(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.loop = value;
+	    }
+	    get playbackRate() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.playbackRate;
+	    }
+	    set playbackRate(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.playbackRate = value;
+	    }
+	    get muted() {
+	        if (!this.videoElement)
+	            return false;
+	        return this.videoElement.muted;
+	    }
+	    set muted(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.muted = value;
+	    }
+	    get paused() {
+	        if (!this.videoElement)
+	            return false;
+	        return this.videoElement.paused;
+	    }
+	    size(width, height) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.width = width;
+	        this.videoElement.height = height;
+	    }
+	    get x() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.x;
+	    }
+	    set x(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.x = value;
+	    }
+	    get y() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.y;
+	    }
+	    set y(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.y = value;
+	    }
+	    get currentSrc() {
+	        return this.videoElement.src;
+	    }
+	    destroy() {
+	        if (this.videoElement)
+	            this.videoElement.destroy();
+	        this.videoElement = null;
+	        this.onEndedFunC = null;
+	        this.onPlayFunc = null;
+	        this.videoend = false;
+	        this.videourl = null;
+	    }
+	    reload() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.src = this.videourl;
+	    }
+	}
+
+	exports.MiniAccelerator = MiniAccelerator;
+	exports.MiniFileMgr = MiniFileMgr;
+	exports.MiniImage = MiniImage;
+	exports.MiniInput = MiniInput;
+	exports.MiniLoader = MiniLoader;
+	exports.MiniLocalStorage = MiniLocalStorage;
+	exports.MiniLocation = MiniLocation;
+	exports.MiniSound = MiniSound;
+	exports.MiniSoundChannel = MiniSoundChannel;
+	exports.MiniVideo = MiniVideo;
+	exports.QQMiniAdapter = QQMiniAdapter;
+
+} 

+ 1686 - 0
ShootingSun/bin/libs/laya.quickgamemini.js

@@ -0,0 +1,1686 @@
+window.qgMiniGame = function (exports, Laya) {
+	'use strict';
+
+	class MiniFileMgr {
+	    static isLocalNativeFile(url) {
+	        for (var i = 0, sz = QGMiniAdapter.nativefiles.length; i < sz; i++) {
+	            if (url.indexOf(QGMiniAdapter.nativefiles[i]) != -1)
+	                return true;
+	        }
+	        return false;
+	    }
+	    static getFileInfo(fileUrl) {
+	        var fileNativePath = fileUrl;
+	        var fileObj = MiniFileMgr.fakeObj[fileNativePath];
+	        if (fileObj == null)
+	            return null;
+	        else
+	            return fileObj;
+	        return null;
+	    }
+	    static read(filePath, encoding = "utf8", callBack = null, readyUrl = "", isSaveFile = false, fileType = "") {
+	        var fileUrl;
+	        if (readyUrl != "" && (readyUrl.indexOf("http://") != -1 || readyUrl.indexOf("https://") != -1)) {
+	            fileUrl = MiniFileMgr.getFileNativePath(filePath);
+	        }
+	        else {
+	            fileUrl = filePath;
+	        }
+	        fileUrl = Laya.URL.getAdptedFilePath(fileUrl);
+	        MiniFileMgr.fs.readFile({ filePath: fileUrl, encoding: encoding, success: function (data) {
+	                callBack != null && callBack.runWith([0, data]);
+	            }, fail: function (data) {
+	                if (data && readyUrl != "")
+	                    MiniFileMgr.downFiles(readyUrl, encoding, callBack, readyUrl, isSaveFile, fileType);
+	                else
+	                    callBack != null && callBack.runWith([1]);
+	            } });
+	    }
+	    static downFiles(fileUrl, encoding = "ascii", callBack = null, readyUrl = "", isSaveFile = false, fileType = "", isAutoClear = true) {
+	        var downloadTask = MiniFileMgr.wxdown({ url: fileUrl, success: function (data) {
+	                if (data.statusCode === 200)
+	                    MiniFileMgr.readFile(data.tempFilePath, encoding, callBack, readyUrl, isSaveFile, fileType, isAutoClear);
+	                else if (data.statusCode === 403) {
+	                    callBack != null && callBack.runWith([0, fileUrl]);
+	                }
+	                else {
+	                    callBack != null && callBack.runWith([1, data]);
+	                }
+	            }, fail: function (data) {
+	                callBack != null && callBack.runWith([1, data]);
+	            } });
+	        downloadTask.onProgressUpdate(function (data) {
+	            callBack != null && callBack.runWith([2, data.progress]);
+	        });
+	    }
+	    static readFile(filePath, encoding = "utf8", callBack = null, readyUrl = "", isSaveFile = false, fileType = "", isAutoClear = true) {
+	        filePath = Laya.URL.getAdptedFilePath(filePath);
+	        MiniFileMgr.fs.readFile({ filePath: filePath, encoding: encoding, success: function (data) {
+	                if (filePath.indexOf(QGMiniAdapter.window.qg.env.USER_DATA_PATH) == -1 && (filePath.indexOf("http://") != -1 || filePath.indexOf("https://") != -1)) {
+	                    if (QGMiniAdapter.autoCacheFile || isSaveFile) {
+	                        callBack != null && callBack.runWith([0, data]);
+	                        MiniFileMgr.copyFile(filePath, readyUrl, null, encoding, isAutoClear);
+	                    }
+	                    else
+	                        callBack != null && callBack.runWith([0, data]);
+	                }
+	                else
+	                    callBack != null && callBack.runWith([0, data]);
+	            }, fail: function (data) {
+	                if (data)
+	                    callBack != null && callBack.runWith([1, data]);
+	            } });
+	    }
+	    static downOtherFiles(fileUrl, callBack = null, readyUrl = "", isSaveFile = false, isAutoClear = true) {
+	        MiniFileMgr.wxdown({ url: fileUrl, success: function (data) {
+	                if (data.statusCode === 200) {
+	                    if ((QGMiniAdapter.autoCacheFile || isSaveFile) && readyUrl.indexOf("qlogo.cn") == -1 && readyUrl.indexOf(".php") == -1) {
+	                        callBack != null && callBack.runWith([0, data.tempFilePath]);
+	                        MiniFileMgr.copyFile(data.tempFilePath, readyUrl, null, "", isAutoClear);
+	                    }
+	                    else
+	                        callBack != null && callBack.runWith([0, data.tempFilePath]);
+	                }
+	                else {
+	                    callBack != null && callBack.runWith([1, data]);
+	                }
+	            }, fail: function (data) {
+	                callBack != null && callBack.runWith([1, data]);
+	            } });
+	    }
+	    static downLoadFile(fileUrl, fileType = "", callBack = null, encoding = "ascii") {
+	        if (QGMiniAdapter.window.navigator.userAgent.indexOf('MiniGame') < 0 && QGMiniAdapter.window.navigator.userAgent.indexOf('OPPO') < 0) {
+	            Laya.Laya.loader.load(fileUrl, callBack);
+	        }
+	        else {
+	            if (fileType == Laya.Loader.IMAGE || fileType == Laya.Loader.SOUND)
+	                MiniFileMgr.downOtherFiles(fileUrl, callBack, fileUrl, true, false);
+	            else
+	                MiniFileMgr.downFiles(fileUrl, encoding, callBack, fileUrl, true, fileType, false);
+	        }
+	    }
+	    static copyFile(tempFilePath, readyUrl, callBack, encoding = "", isAutoClear = true) {
+	        var temp = tempFilePath.split("/");
+	        var tempFileName = temp[temp.length - 1];
+	        var fileurlkey = readyUrl;
+	        var fileObj = MiniFileMgr.getFileInfo(readyUrl);
+	        var saveFilePath = MiniFileMgr.getFileNativePath(tempFileName);
+	        MiniFileMgr.fakeObj[fileurlkey] = { md5: tempFileName, readyUrl: readyUrl, size: 0, times: Laya.Browser.now(), encoding: encoding };
+	        var totalSize = 50 * 1024 * 1024;
+	        var chaSize = 4 * 1024 * 1024;
+	        var fileUseSize = MiniFileMgr.getCacheUseSize();
+	        if (fileObj) {
+	            if (fileObj.readyUrl != readyUrl) {
+	                MiniFileMgr.fs.getFileInfo({
+	                    filePath: tempFilePath,
+	                    success: function (data) {
+	                        if ((isAutoClear && (fileUseSize + chaSize + data.size) >= totalSize)) {
+	                            if (data.size > QGMiniAdapter.minClearSize)
+	                                QGMiniAdapter.minClearSize = data.size;
+	                            MiniFileMgr.onClearCacheRes();
+	                        }
+	                        MiniFileMgr.deleteFile(tempFilePath, readyUrl, callBack, encoding, data.size);
+	                    },
+	                    fail: function (data) {
+	                        callBack != null && callBack.runWith([1, data]);
+	                    }
+	                });
+	            }
+	            else
+	                callBack != null && callBack.runWith([0]);
+	        }
+	        else {
+	            MiniFileMgr.fs.getFileInfo({
+	                filePath: tempFilePath,
+	                success: function (data) {
+	                    if ((isAutoClear && (fileUseSize + chaSize + data.size) >= totalSize)) {
+	                        if (data.size > QGMiniAdapter.minClearSize)
+	                            QGMiniAdapter.minClearSize = data.size;
+	                        MiniFileMgr.onClearCacheRes();
+	                    }
+	                    MiniFileMgr.fs.copyFile({ srcPath: tempFilePath, destPath: saveFilePath, success: function (data2) {
+	                            MiniFileMgr.onSaveFile(readyUrl, tempFileName, true, encoding, callBack, data.size);
+	                        }, fail: function (data) {
+	                            callBack != null && callBack.runWith([1, data]);
+	                        } });
+	                },
+	                fail: function (data) {
+	                    callBack != null && callBack.runWith([1, data]);
+	                }
+	            });
+	        }
+	    }
+	    static onClearCacheRes() {
+	        var memSize = QGMiniAdapter.minClearSize;
+	        var tempFileListArr = [];
+	        for (var key in MiniFileMgr.filesListObj) {
+	            if (key != "fileUsedSize")
+	                tempFileListArr.push(MiniFileMgr.filesListObj[key]);
+	        }
+	        MiniFileMgr.sortOn(tempFileListArr, "times", MiniFileMgr.NUMERIC);
+	        var clearSize = 0;
+	        for (var i = 1, sz = tempFileListArr.length; i < sz; i++) {
+	            var fileObj = tempFileListArr[i];
+	            if (clearSize >= memSize)
+	                break;
+	            clearSize += fileObj.size;
+	            MiniFileMgr.deleteFile("", fileObj.readyUrl);
+	        }
+	    }
+	    static sortOn(array, name, options = 0) {
+	        if (options == MiniFileMgr.NUMERIC)
+	            return array.sort(function (a, b) { return a[name] - b[name]; });
+	        if (options == (MiniFileMgr.NUMERIC | MiniFileMgr.DESCENDING))
+	            return array.sort(function (a, b) { return b[name] - a[name]; });
+	        return array.sort(function (a, b) { return a[name] - b[name]; });
+	    }
+	    static getFileNativePath(fileName) {
+	        return MiniFileMgr.fileNativeDir + "/" + fileName;
+	    }
+	    static deleteFile(tempFileName, readyUrl = "", callBack = null, encoding = "", fileSize = 0) {
+	        var fileObj = MiniFileMgr.getFileInfo(readyUrl);
+	        var deleteFileUrl = MiniFileMgr.getFileNativePath(fileObj.md5);
+	        var isAdd = tempFileName != "" ? true : false;
+	        MiniFileMgr.onSaveFile(readyUrl, tempFileName, isAdd, encoding, callBack, fileSize);
+	        MiniFileMgr.fs.unlink({ filePath: deleteFileUrl, success: function (data) {
+	                if (tempFileName != "") {
+	                    var saveFilePath = MiniFileMgr.getFileNativePath(tempFileName);
+	                    MiniFileMgr.fs.copyFile({ srcPath: tempFileName, destPath: saveFilePath, success: function (data) {
+	                        }, fail: function (data) {
+	                            callBack != null && callBack.runWith([1, data]);
+	                        } });
+	                }
+	            }, fail: function (data) {
+	            } });
+	    }
+	    static deleteAll() {
+	        var tempFileListArr = [];
+	        for (var key in MiniFileMgr.filesListObj) {
+	            if (key != "fileUsedSize")
+	                tempFileListArr.push(MiniFileMgr.filesListObj[key]);
+	        }
+	        for (var i = 1, sz = tempFileListArr.length; i < sz; i++) {
+	            var fileObj = tempFileListArr[i];
+	            MiniFileMgr.deleteFile("", fileObj.readyUrl);
+	        }
+	        if (MiniFileMgr.filesListObj && MiniFileMgr.filesListObj.fileUsedSize) {
+	            MiniFileMgr.filesListObj.fileUsedSize = 0;
+	        }
+	        MiniFileMgr.writeFilesList("", JSON.stringify({}), false);
+	    }
+	    static onSaveFile(readyUrl, md5Name, isAdd = true, encoding = "", callBack = null, fileSize = 0) {
+	        var fileurlkey = readyUrl;
+	        if (MiniFileMgr.filesListObj['fileUsedSize'] == null)
+	            MiniFileMgr.filesListObj['fileUsedSize'] = 0;
+	        if (isAdd) {
+	            var fileNativeName = MiniFileMgr.getFileNativePath(md5Name);
+	            MiniFileMgr.filesListObj[fileurlkey] = { md5: md5Name, readyUrl: readyUrl, size: fileSize, times: Laya.Browser.now(), encoding: encoding };
+	            MiniFileMgr.filesListObj['fileUsedSize'] = parseInt(MiniFileMgr.filesListObj['fileUsedSize']) + fileSize;
+	            MiniFileMgr.writeFilesList(fileurlkey, JSON.stringify(MiniFileMgr.filesListObj), true);
+	            callBack != null && callBack.runWith([0]);
+	        }
+	        else {
+	            if (MiniFileMgr.filesListObj[fileurlkey]) {
+	                var deletefileSize = parseInt(MiniFileMgr.filesListObj[fileurlkey].size);
+	                MiniFileMgr.filesListObj['fileUsedSize'] = parseInt(MiniFileMgr.filesListObj['fileUsedSize']) - deletefileSize;
+	                delete MiniFileMgr.filesListObj[fileurlkey];
+	                MiniFileMgr.writeFilesList(fileurlkey, JSON.stringify(MiniFileMgr.filesListObj), false);
+	                callBack != null && callBack.runWith([0]);
+	            }
+	        }
+	    }
+	    static writeFilesList(fileurlkey, filesListStr, isAdd) {
+	        var listFilesPath = MiniFileMgr.fileNativeDir + "/" + MiniFileMgr.fileListName;
+	        MiniFileMgr.fs.writeFile({ filePath: listFilesPath, encoding: 'utf8', data: filesListStr, success: function (data) {
+	            }, fail: function (data) {
+	            } });
+	        if (!QGMiniAdapter.isZiYu && QGMiniAdapter.isPosMsgYu && QGMiniAdapter.window.qg.postMessage) {
+	            QGMiniAdapter.window.qg.postMessage && QGMiniAdapter.window.qg.postMessage({ url: fileurlkey, data: MiniFileMgr.filesListObj[fileurlkey], isLoad: "filenative", isAdd: isAdd });
+	        }
+	    }
+	    static getCacheUseSize() {
+	        if (MiniFileMgr.filesListObj && MiniFileMgr.filesListObj['fileUsedSize'])
+	            return MiniFileMgr.filesListObj['fileUsedSize'];
+	        return 0;
+	    }
+	    static existDir(dirPath, callBack) {
+	        MiniFileMgr.fs.mkdir({ dirPath: dirPath, success: function (data) {
+	                callBack != null && callBack.runWith([0, { data: JSON.stringify({}) }]);
+	            }, fail: function (data) {
+	                if (data.errMsg.indexOf("file already exists") != -1)
+	                    MiniFileMgr.readSync(MiniFileMgr.fileListName, "utf8", callBack);
+	                else
+	                    callBack != null && callBack.runWith([1, data]);
+	            } });
+	    }
+	    static readSync(filePath, encoding = "utf8", callBack = null, readyUrl = "") {
+	        var fileUrl = MiniFileMgr.getFileNativePath(filePath);
+	        var filesListStr;
+	        try {
+	            MiniFileMgr.fs.readFile({
+	                filePath: fileUrl,
+	                encoding: encoding,
+	                success: function (data) {
+	                    filesListStr = data.data;
+	                    callBack != null && callBack.runWith([0, { data: filesListStr }]);
+	                },
+	                fail: function () {
+	                    callBack != null && callBack.runWith([1]);
+	                }
+	            });
+	        }
+	        catch (error) {
+	            callBack != null && callBack.runWith([1]);
+	        }
+	    }
+	    static setNativeFileDir(value) {
+	        MiniFileMgr.fileNativeDir = QGMiniAdapter.window.qg.env.USER_DATA_PATH + value;
+	    }
+	}
+	MiniFileMgr.fs = window.qg.getFileSystemManager();
+	MiniFileMgr.wxdown = window.qg.downloadFile;
+	MiniFileMgr.filesListObj = {};
+	MiniFileMgr.fakeObj = {};
+	MiniFileMgr.fileListName = "layaairfiles.txt";
+	MiniFileMgr.ziyuFileData = {};
+	MiniFileMgr.ziyuFileTextureData = {};
+	MiniFileMgr.loadPath = "";
+	MiniFileMgr.DESCENDING = 2;
+	MiniFileMgr.NUMERIC = 16;
+
+	class MiniSoundChannel extends Laya.SoundChannel {
+	    constructor(audio, miniSound) {
+	        super();
+	        this._audio = audio;
+	        this._miniSound = miniSound;
+	        this._onEnd = MiniSoundChannel.bindToThis(this.__onEnd, this);
+	        audio.onEnded(this._onEnd);
+	    }
+	    static bindToThis(fun, scope) {
+	        var rst = fun;
+	        rst = fun.bind(scope);
+	        return rst;
+	    }
+	    __onEnd() {
+	        if (this.loops == 1) {
+	            if (this.completeHandler) {
+	                Laya.Laya.systemTimer.once(10, this, this.__runComplete, [this.completeHandler], false);
+	                this.completeHandler = null;
+	            }
+	            this.stop();
+	            this.event(Laya.Event.COMPLETE);
+	            return;
+	        }
+	        if (this.loops > 0) {
+	            this.loops--;
+	        }
+	        this.startTime = 0;
+	        this.play();
+	    }
+	    play() {
+	        this.isStopped = false;
+	        Laya.SoundManager.addChannel(this);
+	        this._audio.play();
+	    }
+	    set startTime(time) {
+	        if (this._audio) {
+	            this._audio.startTime = time;
+	        }
+	    }
+	    set autoplay(value) {
+	        this._audio.autoplay = value;
+	    }
+	    get autoplay() {
+	        return this._audio.autoplay;
+	    }
+	    get position() {
+	        if (!this._audio)
+	            return 0;
+	        return this._audio.currentTime;
+	    }
+	    get duration() {
+	        if (!this._audio)
+	            return 0;
+	        return this._audio.duration;
+	    }
+	    stop() {
+	        this.isStopped = true;
+	        Laya.SoundManager.removeChannel(this);
+	        this.completeHandler = null;
+	        if (!this._audio)
+	            return;
+	        this._audio.stop();
+	        if (!this.loop) {
+	            this._audio.offEnded(null);
+	            this._miniSound.dispose();
+	            this._audio = null;
+	            this._miniSound = null;
+	            this._onEnd = null;
+	        }
+	    }
+	    pause() {
+	        this.isStopped = true;
+	        this._audio.pause();
+	    }
+	    get loop() {
+	        return this._audio.loop;
+	    }
+	    set loop(value) {
+	        this._audio.loop = value;
+	    }
+	    resume() {
+	        if (!this._audio)
+	            return;
+	        this.isStopped = false;
+	        Laya.SoundManager.addChannel(this);
+	        this._audio.play();
+	    }
+	    set volume(v) {
+	        if (!this._audio)
+	            return;
+	        this._audio.volume = v;
+	    }
+	    get volume() {
+	        if (!this._audio)
+	            return 1;
+	        return this._audio.volume;
+	    }
+	}
+
+	class MiniSound extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	        this.loaded = false;
+	    }
+	    static _createSound() {
+	        MiniSound._id++;
+	        return QGMiniAdapter.window.qg.createInnerAudioContext();
+	    }
+	    load(url) {
+	        if (!MiniSound._musicAudio)
+	            MiniSound._musicAudio = MiniSound._createSound();
+	        if (!MiniFileMgr.isLocalNativeFile(url)) {
+	            url = Laya.URL.formatURL(url);
+	        }
+	        else {
+	            if (url.indexOf("http://") != -1 || url.indexOf("https://") != -1) {
+	                if (MiniFileMgr.loadPath != "") {
+	                    url = url.split(MiniFileMgr.loadPath)[1];
+	                }
+	                else {
+	                    var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    if (tempStr != "")
+	                        url = url.split(tempStr)[1];
+	                }
+	            }
+	        }
+	        this.url = url;
+	        this.readyUrl = url;
+	        if (MiniSound._audioCache[this.readyUrl]) {
+	            this.event(Laya.Event.COMPLETE);
+	            return;
+	        }
+	        if (QGMiniAdapter.autoCacheFile && MiniFileMgr.getFileInfo(url)) {
+	            this.onDownLoadCallBack(url, 0);
+	        }
+	        else {
+	            if (!QGMiniAdapter.autoCacheFile) {
+	                this.onDownLoadCallBack(url, 0);
+	            }
+	            else {
+	                if (MiniFileMgr.isLocalNativeFile(url)) {
+	                    tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    var tempUrl = url;
+	                    if (tempStr != "")
+	                        url = url.split(tempStr)[1];
+	                    if (!url) {
+	                        url = tempUrl;
+	                    }
+	                    if (QGMiniAdapter.subNativeFiles && QGMiniAdapter.subNativeheads.length == 0) {
+	                        for (var key in QGMiniAdapter.subNativeFiles) {
+	                            var tempArr = QGMiniAdapter.subNativeFiles[key];
+	                            QGMiniAdapter.subNativeheads = QGMiniAdapter.subNativeheads.concat(tempArr);
+	                            for (var aa = 0; aa < tempArr.length; aa++) {
+	                                QGMiniAdapter.subMaps[tempArr[aa]] = key + "/" + tempArr[aa];
+	                            }
+	                        }
+	                    }
+	                    if (QGMiniAdapter.subNativeFiles && url.indexOf("/") != -1) {
+	                        var curfileHead = url.split("/")[0] + "/";
+	                        if (curfileHead && QGMiniAdapter.subNativeheads.indexOf(curfileHead) != -1) {
+	                            var newfileHead = QGMiniAdapter.subMaps[curfileHead];
+	                            url = url.replace(curfileHead, newfileHead);
+	                        }
+	                    }
+	                    this.onDownLoadCallBack(url, 0);
+	                }
+	                else {
+	                    if (!MiniFileMgr.isLocalNativeFile(url) && (url.indexOf("http://") == -1 && url.indexOf("https://") == -1) || (url.indexOf("http://usr/") != -1)) {
+	                        this.onDownLoadCallBack(url, 0);
+	                    }
+	                    else {
+	                        MiniFileMgr.downOtherFiles(encodeURI(url), Laya.Handler.create(this, this.onDownLoadCallBack, [url]), url);
+	                    }
+	                }
+	            }
+	        }
+	    }
+	    onDownLoadCallBack(sourceUrl, errorCode, tempFilePath = null) {
+	        if (!errorCode) {
+	            var fileNativeUrl;
+	            if (QGMiniAdapter.autoCacheFile) {
+	                if (!tempFilePath) {
+	                    if (MiniFileMgr.isLocalNativeFile(sourceUrl)) {
+	                        var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                        var tempUrl = sourceUrl;
+	                        if (tempStr != "" && (sourceUrl.indexOf("http://") != -1 || sourceUrl.indexOf("https://") != -1))
+	                            fileNativeUrl = sourceUrl.split(tempStr)[1];
+	                        if (!fileNativeUrl) {
+	                            fileNativeUrl = tempUrl;
+	                        }
+	                    }
+	                    else {
+	                        var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                        if (fileObj && fileObj.md5) {
+	                            var fileMd5Name = fileObj.md5;
+	                            fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                        }
+	                        else {
+	                            fileNativeUrl = sourceUrl;
+	                        }
+	                    }
+	                }
+	                else {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	                if (this.url != Laya.SoundManager._bgMusic) {
+	                    this._sound = MiniSound._createSound();
+	                    this._sound.src = this.url = fileNativeUrl;
+	                }
+	                else {
+	                    this._sound = MiniSound._musicAudio;
+	                    this._sound.src = this.url = fileNativeUrl;
+	                }
+	            }
+	            else {
+	                if (this.url != Laya.SoundManager._bgMusic) {
+	                    this._sound = MiniSound._createSound();
+	                    this._sound.src = sourceUrl;
+	                }
+	                else {
+	                    this._sound = MiniSound._musicAudio;
+	                    this._sound.src = sourceUrl;
+	                }
+	            }
+	            this._sound.onCanplay(MiniSound.bindToThis(this.onCanPlay, this));
+	            this._sound.onError(MiniSound.bindToThis(this.onError, this));
+	        }
+	        else {
+	            this.event(Laya.Event.ERROR);
+	        }
+	    }
+	    onError(error) {
+	        try {
+	            console.log("-----1---------------minisound-----id:" + MiniSound._id);
+	            console.log(error);
+	        }
+	        catch (error) {
+	            console.log("-----2---------------minisound-----id:" + MiniSound._id);
+	            console.log(error);
+	        }
+	        this.event(Laya.Event.ERROR);
+	        this._sound.offError(null);
+	    }
+	    onCanPlay() {
+	        this.loaded = true;
+	        this.event(Laya.Event.COMPLETE);
+	        this._sound.offCanplay(null);
+	    }
+	    static bindToThis(fun, scope) {
+	        var rst = fun;
+	        rst = fun.bind(scope);
+	        return rst;
+	    }
+	    play(startTime = 0, loops = 0) {
+	        var tSound;
+	        if (this.url == Laya.SoundManager._bgMusic) {
+	            if (!MiniSound._musicAudio)
+	                MiniSound._musicAudio = MiniSound._createSound();
+	            tSound = MiniSound._musicAudio;
+	        }
+	        else {
+	            if (MiniSound._audioCache[this.readyUrl]) {
+	                tSound = MiniSound._audioCache[this.readyUrl]._sound;
+	            }
+	            else {
+	                tSound = MiniSound._createSound();
+	            }
+	        }
+	        if (!tSound)
+	            return null;
+	        if (QGMiniAdapter.autoCacheFile && MiniFileMgr.getFileInfo(this.url)) {
+	            var fileObj = MiniFileMgr.getFileInfo(this.url);
+	            var fileMd5Name = fileObj.md5;
+	            tSound.src = this.url = MiniFileMgr.getFileNativePath(fileMd5Name);
+	        }
+	        else {
+	            tSound.src = encodeURI(this.url);
+	        }
+	        var channel = new MiniSoundChannel(tSound, this);
+	        channel.url = this.url;
+	        channel.loops = loops;
+	        channel.loop = (loops === 0 ? true : false);
+	        channel.startTime = startTime;
+	        channel.play();
+	        Laya.SoundManager.addChannel(channel);
+	        return channel;
+	    }
+	    get duration() {
+	        return this._sound.duration;
+	    }
+	    dispose() {
+	        var ad = MiniSound._audioCache[this.readyUrl];
+	        if (ad) {
+	            ad.src = "";
+	            if (ad._sound) {
+	                ad._sound.destroy();
+	                ad._sound = null;
+	                ad = null;
+	            }
+	            delete MiniSound._audioCache[this.readyUrl];
+	        }
+	        if (this._sound) {
+	            this._sound.destroy();
+	            this._sound = null;
+	            this.readyUrl = this.url = null;
+	        }
+	    }
+	}
+	MiniSound._id = 0;
+	MiniSound._audioCache = {};
+
+	class MiniInput {
+	    constructor() {
+	    }
+	    static _createInputElement() {
+	        Laya.Input['_initInput'](Laya.Input['area'] = Laya.Browser.createElement("textarea"));
+	        Laya.Input['_initInput'](Laya.Input['input'] = Laya.Browser.createElement("input"));
+	        Laya.Input['inputContainer'] = Laya.Browser.createElement("div");
+	        Laya.Input['inputContainer'].style.position = "absolute";
+	        Laya.Input['inputContainer'].style.zIndex = 1E5;
+	        Laya.Browser.container.appendChild(Laya.Input['inputContainer']);
+	        Laya.Laya.stage.on("resize", null, MiniInput._onStageResize);
+	        QGMiniAdapter.window.qg.onWindowResize && QGMiniAdapter.window.qg.onWindowResize(function (res) {
+	        });
+	        Laya.SoundManager._soundClass = MiniSound;
+	        Laya.SoundManager._musicClass = MiniSound;
+	        var model = QGMiniAdapter.systemInfo.model;
+	        var system = QGMiniAdapter.systemInfo.system;
+	        if (model && model.indexOf("iPhone") != -1) {
+	            Laya.Browser.onIPhone = true;
+	            Laya.Browser.onIOS = true;
+	            Laya.Browser.onIPad = true;
+	            Laya.Browser.onAndroid = false;
+	        }
+	        if (system && (system.indexOf("Android") != -1 || system.indexOf("Adr") != -1)) {
+	            Laya.Browser.onAndroid = true;
+	            Laya.Browser.onIPhone = false;
+	            Laya.Browser.onIOS = false;
+	            Laya.Browser.onIPad = false;
+	        }
+	    }
+	    static _onStageResize() {
+	    }
+	    static wxinputFocus(e) {
+	        var _inputTarget = Laya.Input['inputElement'].target;
+	        if (_inputTarget && !_inputTarget.editable) {
+	            return;
+	        }
+	        QGMiniAdapter.window.qg.showKeyboard({ defaultValue: _inputTarget.text, maxLength: _inputTarget.maxChars, multiple: _inputTarget.multiline, confirmHold: true, confirmType: _inputTarget["confirmType"] || 'done', success: function (res) {
+	            }, fail: function (res) {
+	            } });
+	        QGMiniAdapter.window.qg.onKeyboardComplete(function (res) {
+	            QGMiniAdapter.window.qg.offKeyboardComplete();
+	            var str = res ? res.value : "";
+	            if (_inputTarget._restrictPattern) {
+	                str = str.replace(/\u2006|\x27/g, "");
+	                if (_inputTarget._restrictPattern.test(str)) {
+	                    str = str.replace(_inputTarget._restrictPattern, "");
+	                }
+	            }
+	            _inputTarget.text = str;
+	            _inputTarget.event(Laya.Event.INPUT);
+	            MiniInput.inputEnter(true);
+	        });
+	        QGMiniAdapter.window.qg.onKeyboardConfirm(function (res) {
+	            var str = res ? res.value : "";
+	            if (_inputTarget._restrictPattern) {
+	                str = str.replace(/\u2006|\x27/g, "");
+	                if (_inputTarget._restrictPattern.test(str)) {
+	                    str = str.replace(_inputTarget._restrictPattern, "");
+	                }
+	            }
+	            _inputTarget.text = str;
+	            _inputTarget.event(Laya.Event.INPUT);
+	            MiniInput.inputEnter(true);
+	            _inputTarget.event("confirm");
+	        });
+	        QGMiniAdapter.window.qg.onKeyboardInput(function (res) {
+	            var str = res ? res.value : "";
+	            if (!_inputTarget.multiline) {
+	                if (str.indexOf("\n") != -1) {
+	                    MiniInput.inputEnter(false);
+	                    return;
+	                }
+	            }
+	            if (_inputTarget._restrictPattern) {
+	                str = str.replace(/\u2006|\x27/g, "");
+	                if (_inputTarget._restrictPattern.test(str)) {
+	                    str = str.replace(_inputTarget._restrictPattern, "");
+	                }
+	            }
+	            _inputTarget.text = str;
+	            _inputTarget.event(Laya.Event.INPUT);
+	            MiniInput.inputEnter(false);
+	        });
+	    }
+	    static inputEnter(isBool) {
+	        if (isBool) {
+	            MiniInput.hideKeyboard();
+	        }
+	        if (!Laya.Input['inputElement'].target)
+	            return;
+	        Laya.Input['inputElement'].target.focus = false;
+	    }
+	    static wxinputblur() {
+	    }
+	    static hideKeyboard() {
+	        QGMiniAdapter.window.qg.offKeyboardConfirm();
+	        QGMiniAdapter.window.qg.offKeyboardInput();
+	        QGMiniAdapter.window.qg.hideKeyboard({ success: function (res) {
+	                console.log('隐藏键盘');
+	            }, fail: function (res) {
+	                console.log("隐藏键盘出错:" + (res ? res.errMsg : ""));
+	            } });
+	    }
+	}
+
+	class MiniLoader extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	    }
+	    _loadResourceFilter(type, url) {
+	        var thisLoader = this;
+	        if (url.indexOf("http://usr/") == -1 && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1)) {
+	            if (MiniFileMgr.loadPath != "") {
+	                url = url.split(MiniFileMgr.loadPath)[1];
+	            }
+	            else {
+	                var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                var tempUrl = url;
+	                if (tempStr != "")
+	                    url = url.split(tempStr)[1];
+	                if (!url) {
+	                    url = tempUrl;
+	                }
+	            }
+	        }
+	        if (QGMiniAdapter.subNativeFiles && QGMiniAdapter.subNativeheads.length == 0) {
+	            for (var key in QGMiniAdapter.subNativeFiles) {
+	                var tempArr = QGMiniAdapter.subNativeFiles[key];
+	                QGMiniAdapter.subNativeheads = QGMiniAdapter.subNativeheads.concat(tempArr);
+	                for (var aa = 0; aa < tempArr.length; aa++) {
+	                    QGMiniAdapter.subMaps[tempArr[aa]] = key + "/" + tempArr[aa];
+	                }
+	            }
+	        }
+	        if (QGMiniAdapter.subNativeFiles && url.indexOf("/") != -1) {
+	            var curfileHead = url.split("/")[0] + "/";
+	            if (curfileHead && QGMiniAdapter.subNativeheads.indexOf(curfileHead) != -1) {
+	                var newfileHead = QGMiniAdapter.subMaps[curfileHead];
+	                url = url.replace(curfileHead, newfileHead);
+	            }
+	        }
+	        switch (type) {
+	            case Laya.Loader.IMAGE:
+	            case "htmlimage":
+	            case "nativeimage":
+	                MiniLoader._transformImgUrl(url, type, thisLoader);
+	                break;
+	            case Laya.Loader.SOUND:
+	                thisLoader._loadSound(url);
+	                break;
+	            default:
+	                thisLoader._loadResource(type, url);
+	        }
+	    }
+	    _loadSound(url) {
+	        var thisLoader = this;
+	        var fileNativeUrl;
+	        if (MiniFileMgr.isLocalNativeFile(url)) {
+	            var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	            var tempUrl = url;
+	            if (tempStr != "" && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1))
+	                fileNativeUrl = url.split(tempStr)[1];
+	            if (!fileNativeUrl) {
+	                fileNativeUrl = tempUrl;
+	            }
+	            MiniLoader.onDownLoadCallBack(url, thisLoader, 0);
+	        }
+	        else {
+	            var tempurl = Laya.URL.formatURL(url);
+	            if (!MiniFileMgr.isLocalNativeFile(url) && (tempurl.indexOf("http://") == -1 && tempurl.indexOf("https://") == -1) || (tempurl.indexOf("http://usr/") != -1)) {
+	                MiniLoader.onDownLoadCallBack(url, thisLoader, 0);
+	            }
+	            else {
+	                MiniFileMgr.downOtherFiles(tempurl, Laya.Handler.create(MiniLoader, MiniLoader.onDownLoadCallBack, [tempurl, thisLoader]), tempurl);
+	            }
+	        }
+	    }
+	    static onDownLoadCallBack(sourceUrl, thisLoader, errorCode, tempFilePath = null) {
+	        if (!errorCode) {
+	            var fileNativeUrl;
+	            if (QGMiniAdapter.autoCacheFile) {
+	                if (!tempFilePath) {
+	                    if (MiniFileMgr.isLocalNativeFile(sourceUrl)) {
+	                        var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                        var tempUrl = sourceUrl;
+	                        if (tempStr != "" && (sourceUrl.indexOf("http://") != -1 || sourceUrl.indexOf("https://") != -1))
+	                            fileNativeUrl = sourceUrl.split(tempStr)[1];
+	                        if (!fileNativeUrl) {
+	                            fileNativeUrl = tempUrl;
+	                        }
+	                    }
+	                    else {
+	                        var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                        if (fileObj && fileObj.md5) {
+	                            var fileMd5Name = fileObj.md5;
+	                            fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                        }
+	                        else {
+	                            fileNativeUrl = sourceUrl;
+	                        }
+	                    }
+	                }
+	                else {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	            }
+	            sourceUrl = fileNativeUrl;
+	            var sound = (new Laya.SoundManager._soundClass());
+	            sound.load(sourceUrl);
+	            thisLoader.onLoaded(sound);
+	        }
+	        else {
+	            thisLoader.event(Laya.Event.ERROR, "Load sound failed");
+	        }
+	    }
+	    static bindToThis(fun, scope) {
+	        var rst = fun;
+	        rst = fun.bind(scope);
+	        return rst;
+	    }
+	    _loadHttpRequestWhat(url, contentType) {
+	        var thisLoader = this;
+	        var encoding = QGMiniAdapter.getUrlEncode(url, contentType);
+	        if (Laya.Loader.preLoadedMap[url])
+	            thisLoader.onLoaded(Laya.Loader.preLoadedMap[url]);
+	        else {
+	            var tempurl = Laya.URL.formatURL(url);
+	            if (!MiniFileMgr.isLocalNativeFile(url) && !MiniFileMgr.getFileInfo(tempurl) && url.indexOf("http://usr/") == -1 && (tempurl.indexOf("http://") != -1 || tempurl.indexOf("https://") != -1) && !QGMiniAdapter.AutoCacheDownFile) {
+	                thisLoader._loadHttpRequest(tempurl, contentType, thisLoader, thisLoader.onLoaded, thisLoader, thisLoader.onProgress, thisLoader, thisLoader.onError);
+	            }
+	            else {
+	                var fileObj = MiniFileMgr.getFileInfo(Laya.URL.formatURL(url));
+	                if (fileObj) {
+	                    fileObj.encoding = fileObj.encoding == null ? "utf8" : fileObj.encoding;
+	                    MiniFileMgr.readFile(MiniFileMgr.getFileNativePath(fileObj.md5), encoding, new Laya.Handler(MiniLoader, MiniLoader.onReadNativeCallBack, [url, contentType, thisLoader]), url);
+	                }
+	                else if (thisLoader.type == "image" || thisLoader.type == "htmlimage") {
+	                    thisLoader._transformUrl(url, contentType);
+	                }
+	                else {
+	                    if (contentType != Laya.Loader.IMAGE && ((tempurl.indexOf("http://") == -1 && tempurl.indexOf("https://") == -1) || MiniFileMgr.isLocalNativeFile(url))) {
+	                        MiniFileMgr.readFile(url, encoding, new Laya.Handler(MiniLoader, MiniLoader.onReadNativeCallBack, [url, contentType, thisLoader]), url);
+	                    }
+	                    else {
+	                        MiniFileMgr.downFiles(encodeURI(tempurl), encoding, new Laya.Handler(MiniLoader, MiniLoader.onReadNativeCallBack, [url, contentType, thisLoader]), tempurl, true);
+	                    }
+	                }
+	            }
+	        }
+	    }
+	    static onReadNativeCallBack(url, type = null, thisLoader = null, errorCode = 0, data = null) {
+	        if (!errorCode) {
+	            var tempData;
+	            if (type == Laya.Loader.JSON || type == Laya.Loader.ATLAS || type == Laya.Loader.PREFAB || type == Laya.Loader.PLF) {
+	                tempData = QGMiniAdapter.getJson(data.data);
+	            }
+	            else if (type == Laya.Loader.XML) {
+	                tempData = Laya.Utils.parseXMLFromString(data.data);
+	            }
+	            else {
+	                tempData = data.data;
+	            }
+	            if (!QGMiniAdapter.isZiYu && QGMiniAdapter.isPosMsgYu && type != Laya.Loader.BUFFER) {
+	                QGMiniAdapter.window.wx.postMessage({ url: url, data: tempData, isLoad: "filedata" });
+	            }
+	            thisLoader.onLoaded(tempData);
+	        }
+	        else if (errorCode == 1) {
+	            thisLoader._loadHttpRequest(url, type, thisLoader, thisLoader.onLoaded, thisLoader, thisLoader.onProgress, thisLoader, thisLoader.onError);
+	        }
+	    }
+	    static _transformImgUrl(url, type, thisLoader) {
+	        if (QGMiniAdapter.isZiYu) {
+	            thisLoader._loadImage(url, false);
+	            return;
+	        }
+	        if (MiniFileMgr.isLocalNativeFile(url)) {
+	            thisLoader._loadImage(url, false);
+	            return;
+	        }
+	        if (!MiniFileMgr.isLocalNativeFile(url) && !MiniFileMgr.getFileInfo(Laya.URL.formatURL(url))) {
+	            var tempUrl = Laya.URL.formatURL(url);
+	            if (url.indexOf('http://usr/') == -1 && (tempUrl.indexOf("http://") != -1 || tempUrl.indexOf("https://") != -1)) {
+	                if (QGMiniAdapter.isZiYu) {
+	                    thisLoader._loadImage(url, false);
+	                }
+	                else {
+	                    MiniFileMgr.downOtherFiles(tempUrl, new Laya.Handler(MiniLoader, MiniLoader.onDownImgCallBack, [url, thisLoader]), tempUrl);
+	                }
+	            }
+	            else
+	                thisLoader._loadImage(url, false);
+	        }
+	        else {
+	            MiniLoader.onCreateImage(url, thisLoader);
+	        }
+	    }
+	    static onDownImgCallBack(sourceUrl, thisLoader, errorCode, tempFilePath = "") {
+	        if (!errorCode)
+	            MiniLoader.onCreateImage(sourceUrl, thisLoader, false, tempFilePath);
+	        else {
+	            thisLoader.onError(null);
+	        }
+	    }
+	    static onCreateImage(sourceUrl, thisLoader, isLocal = false, tempFilePath = "") {
+	        var fileNativeUrl;
+	        if (QGMiniAdapter.autoCacheFile) {
+	            if (!isLocal) {
+	                if (tempFilePath != "") {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	                else {
+	                    var fileObj = MiniFileMgr.getFileInfo(Laya.URL.formatURL(sourceUrl));
+	                    var fileMd5Name = fileObj.md5;
+	                    fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                }
+	            }
+	            else if (QGMiniAdapter.isZiYu) {
+	                var tempUrl = Laya.URL.formatURL(sourceUrl);
+	                if (MiniFileMgr.ziyuFileTextureData[tempUrl]) {
+	                    fileNativeUrl = MiniFileMgr.ziyuFileTextureData[tempUrl];
+	                }
+	                else
+	                    fileNativeUrl = sourceUrl;
+	            }
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        else {
+	            if (!isLocal)
+	                fileNativeUrl = tempFilePath;
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        thisLoader._loadImage(fileNativeUrl, false);
+	    }
+	}
+
+	class QGMiniAdapter {
+	    static getJson(data) {
+	        return JSON.parse(data);
+	    }
+	    static enable() {
+	        QGMiniAdapter.init(Laya.Laya.isWXPosMsg, Laya.Laya.isWXOpenDataContext);
+	    }
+	    static init(isPosMsg = false, isSon = false) {
+	        if (QGMiniAdapter._inited)
+	            return;
+	        QGMiniAdapter._inited = true;
+	        QGMiniAdapter.window = window;
+	        if (!QGMiniAdapter.window.hasOwnProperty('qg'))
+	            return;
+	        if (QGMiniAdapter.window.navigator.userAgent.indexOf('OPPO') < 0)
+	            return;
+	        QGMiniAdapter.isZiYu = isSon;
+	        QGMiniAdapter.isPosMsgYu = isPosMsg;
+	        QGMiniAdapter.EnvConfig = {};
+	        if (!QGMiniAdapter.isZiYu) {
+	            MiniFileMgr.setNativeFileDir("/layaairGame");
+	            MiniFileMgr.existDir(MiniFileMgr.fileNativeDir, Laya.Handler.create(QGMiniAdapter, QGMiniAdapter.onMkdirCallBack));
+	        }
+	        QGMiniAdapter.window.qg.getSystemInfo({
+	            success: function (data) {
+	                QGMiniAdapter.systemInfo = data;
+	            }
+	        });
+	        QGMiniAdapter.window.focus = function () {
+	        };
+	        Laya.Laya['_getUrlPath'] = function () {
+	            return "";
+	        };
+	        Laya.Laya['getUrlPath'] = function () {
+	            return "";
+	        };
+	        QGMiniAdapter.window.logtime = function (str) {
+	        };
+	        QGMiniAdapter.window.alertTimeLog = function (str) {
+	        };
+	        QGMiniAdapter.window.resetShareInfo = function () {
+	        };
+	        QGMiniAdapter.window.document.body.appendChild = function () {
+	        };
+	        QGMiniAdapter.EnvConfig.pixelRatioInt = 0;
+	        Laya.Browser["_pixelRatio"] = QGMiniAdapter.pixelRatio();
+	        QGMiniAdapter._preCreateElement = Laya.Browser.createElement;
+	        Laya.Browser["createElement"] = QGMiniAdapter.createElement;
+	        Laya.RunDriver.createShaderCondition = QGMiniAdapter.createShaderCondition;
+	        Laya.Utils['parseXMLFromString'] = QGMiniAdapter.parseXMLFromString;
+	        Laya.Input['_createInputElement'] = MiniInput['_createInputElement'];
+	        Laya.Loader.prototype._loadResourceFilter = MiniLoader.prototype._loadResourceFilter;
+	        Laya.Loader.prototype._loadSound = MiniLoader.prototype._loadSound;
+	        Laya.Loader.prototype._loadHttpRequestWhat = MiniLoader.prototype._loadHttpRequestWhat;
+	        Laya.Config.useRetinalCanvas = true;
+	        QGMiniAdapter.window.qg.onMessage && QGMiniAdapter.window.qg.onMessage(QGMiniAdapter._onMessage);
+	    }
+	    static _onMessage(data) {
+	        switch (data.type) {
+	            case "changeMatrix":
+	                Laya.Laya.stage.transform.identity();
+	                Laya.Laya.stage._width = data.w;
+	                Laya.Laya.stage._height = data.h;
+	                Laya.Laya.stage._canvasTransform = new Laya.Matrix(data.a, data.b, data.c, data.d, data.tx, data.ty);
+	                break;
+	            case "display":
+	                Laya.Laya.stage.frameRate = data.rate || Laya.Stage.FRAME_FAST;
+	                break;
+	            case "undisplay":
+	                Laya.Laya.stage.frameRate = Laya.Stage.FRAME_SLEEP;
+	                break;
+	        }
+	        if (data['isLoad'] == "opendatacontext") {
+	            if (data.url) {
+	                MiniFileMgr.ziyuFileData[data.url] = data.atlasdata;
+	                MiniFileMgr.ziyuFileTextureData[data.imgReadyUrl] = data.imgNativeUrl;
+	            }
+	        }
+	        else if (data['isLoad'] == "openJsondatacontext") {
+	            if (data.url) {
+	                MiniFileMgr.ziyuFileData[data.url] = data.atlasdata;
+	            }
+	        }
+	        else if (data['isLoad'] == "openJsondatacontextPic") {
+	            MiniFileMgr.ziyuFileTextureData[data.imgReadyUrl] = data.imgNativeUrl;
+	        }
+	    }
+	    static getUrlEncode(url, type) {
+	        if (type == "arraybuffer")
+	            return "";
+	        return "utf8";
+	    }
+	    static downLoadFile(fileUrl, fileType = "", callBack = null, encoding = "utf8") {
+	        var fileObj = MiniFileMgr.getFileInfo(fileUrl);
+	        if (!fileObj)
+	            MiniFileMgr.downLoadFile(fileUrl, fileType, callBack, encoding);
+	        else {
+	            callBack != null && callBack.runWith([0]);
+	        }
+	    }
+	    static remove(fileUrl, callBack = null) {
+	        MiniFileMgr.deleteFile("", fileUrl, callBack, "", 0);
+	    }
+	    static removeAll() {
+	        MiniFileMgr.deleteAll();
+	    }
+	    static hasNativeFile(fileUrl) {
+	        return MiniFileMgr.isLocalNativeFile(fileUrl);
+	    }
+	    static getFileInfo(fileUrl) {
+	        return MiniFileMgr.getFileInfo(fileUrl);
+	    }
+	    static getFileList() {
+	        return MiniFileMgr.filesListObj;
+	    }
+	    static exitMiniProgram() {
+	        QGMiniAdapter.window["wx"].exitMiniProgram();
+	    }
+	    static onMkdirCallBack(errorCode, data) {
+	        if (!errorCode)
+	            MiniFileMgr.filesListObj = JSON.parse(data.data);
+	        MiniFileMgr.fakeObj = MiniFileMgr.filesListObj;
+	    }
+	    static pixelRatio() {
+	        if (!QGMiniAdapter.EnvConfig.pixelRatioInt) {
+	            try {
+	                QGMiniAdapter.systemInfo.pixelRatio = QGMiniAdapter.window.devicePixelRatio;
+	                QGMiniAdapter.EnvConfig.pixelRatioInt = QGMiniAdapter.systemInfo.pixelRatio;
+	                return QGMiniAdapter.systemInfo.pixelRatio;
+	            }
+	            catch (error) {
+	            }
+	        }
+	        return QGMiniAdapter.EnvConfig.pixelRatioInt;
+	    }
+	    static createElement(type) {
+	        if (type == "canvas") {
+	            var _source;
+	            if (QGMiniAdapter.idx == 1) {
+	                if (QGMiniAdapter.isZiYu) {
+	                    _source = QGMiniAdapter.window.document.createElement("canvas");
+	                    _source.style = {};
+	                }
+	                else {
+	                    _source = QGMiniAdapter.window.__canvas;
+	                }
+	            }
+	            else {
+	                _source = QGMiniAdapter.window.document.createElement("canvas");
+	            }
+	            QGMiniAdapter.idx++;
+	            return _source;
+	        }
+	        else if (type == "textarea" || type == "input") {
+	            return QGMiniAdapter.onCreateInput(type);
+	        }
+	        else if (type == "div") {
+	            var node = QGMiniAdapter._preCreateElement(type);
+	            node.contains = function (value) {
+	                return null;
+	            };
+	            node.removeChild = function (value) {
+	            };
+	            return node;
+	        }
+	        else {
+	            return QGMiniAdapter._preCreateElement(type);
+	        }
+	    }
+	    static onCreateInput(type) {
+	        var node = QGMiniAdapter._preCreateElement(type);
+	        node.focus = MiniInput.wxinputFocus;
+	        node.blur = MiniInput.wxinputblur;
+	        node.style = {};
+	        node.value = 0;
+	        node.parentElement = {};
+	        node.placeholder = {};
+	        node.type = {};
+	        node.setColor = function (value) {
+	        };
+	        node.setType = function (value) {
+	        };
+	        node.setFontFace = function (value) {
+	        };
+	        node.addEventListener = function (value) {
+	        };
+	        node.contains = function (value) {
+	            return null;
+	        };
+	        node.removeChild = function (value) {
+	        };
+	        return node;
+	    }
+	    static createShaderCondition(conditionScript) {
+	        var func = function () {
+	            return this[conditionScript.replace("this.", "")];
+	        };
+	        return func;
+	    }
+	    static sendAtlasToOpenDataContext(url) {
+	        if (!QGMiniAdapter.isZiYu) {
+	            var atlasJson = Laya.Loader.getRes(Laya.URL.formatURL(url));
+	            if (atlasJson) {
+	                var textureArr = atlasJson.meta.image.split(",");
+	                if (atlasJson.meta && atlasJson.meta.image) {
+	                    var toloadPics = atlasJson.meta.image.split(",");
+	                    var split = url.indexOf("/") >= 0 ? "/" : "\\";
+	                    var idx = url.lastIndexOf(split);
+	                    var folderPath = idx >= 0 ? url.substr(0, idx + 1) : "";
+	                    for (var i = 0, len = toloadPics.length; i < len; i++) {
+	                        toloadPics[i] = folderPath + toloadPics[i];
+	                    }
+	                }
+	                else {
+	                    toloadPics = [url.replace(".json", ".png")];
+	                }
+	                for (i = 0; i < toloadPics.length; i++) {
+	                    var tempAtlasPngUrl = toloadPics[i];
+	                    QGMiniAdapter.postInfoToContext(url, tempAtlasPngUrl, atlasJson);
+	                }
+	            }
+	            else {
+	                throw "传递的url没有获取到对应的图集数据信息,请确保图集已经过!";
+	            }
+	        }
+	    }
+	    static postInfoToContext(url, atlaspngUrl, atlasJson) {
+	        var postData = { "frames": atlasJson.frames, "meta": atlasJson.meta };
+	        var textureUrl = atlaspngUrl;
+	        var fileObj = MiniFileMgr.getFileInfo(Laya.URL.formatURL(atlaspngUrl));
+	        if (fileObj) {
+	            var fileMd5Name = fileObj.md5;
+	            var fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	        }
+	        else {
+	            fileNativeUrl = textureUrl;
+	        }
+	        if (fileNativeUrl) {
+	            QGMiniAdapter.window.qg.postMessage && QGMiniAdapter.window.qg.postMessage({ url: url, atlasdata: postData, imgNativeUrl: fileNativeUrl, imgReadyUrl: textureUrl, isLoad: "opendatacontext" });
+	        }
+	        else {
+	            throw "获取图集的磁盘url路径不存在!";
+	        }
+	    }
+	    static sendSinglePicToOpenDataContext(url) {
+	        var tempTextureUrl = Laya.URL.formatURL(url);
+	        var fileObj = MiniFileMgr.getFileInfo(tempTextureUrl);
+	        if (fileObj) {
+	            var fileMd5Name = fileObj.md5;
+	            var fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	            url = tempTextureUrl;
+	        }
+	        else {
+	            fileNativeUrl = url;
+	        }
+	        if (fileNativeUrl) {
+	            QGMiniAdapter.window.qg.postMessage && QGMiniAdapter.window.qg.postMessage({ url: url, imgNativeUrl: fileNativeUrl, imgReadyUrl: url, isLoad: "openJsondatacontextPic" });
+	        }
+	        else {
+	            throw "获取图集的磁盘url路径不存在!";
+	        }
+	    }
+	    static sendJsonDataToDataContext(url) {
+	        if (!QGMiniAdapter.isZiYu) {
+	            var atlasJson = Laya.Loader.getRes(url);
+	            if (atlasJson) {
+	                QGMiniAdapter.window.qg.postMessage && QGMiniAdapter.window.qg.postMessage({ url: url, atlasdata: atlasJson, isLoad: "openJsondatacontext" });
+	            }
+	            else {
+	                throw "传递的url没有获取到对应的图集数据信息,请确保图集已经过!";
+	            }
+	        }
+	    }
+	}
+	QGMiniAdapter._inited = false;
+	QGMiniAdapter.systemInfo = {};
+	QGMiniAdapter.autoCacheFile = true;
+	QGMiniAdapter.minClearSize = (5 * 1024 * 1024);
+	QGMiniAdapter.nativefiles = ["layaNativeDir"];
+	QGMiniAdapter.subNativeheads = [];
+	QGMiniAdapter.subMaps = [];
+	QGMiniAdapter.AutoCacheDownFile = false;
+	QGMiniAdapter.parseXMLFromString = function (value) {
+	    var rst;
+	    value = value.replace(/>\s+</g, '><');
+	    try {
+	        rst = (new window.DOMParser()).parseFromString(value, 'text/xml');
+	    }
+	    catch (error) {
+	        throw "需要引入xml解析库文件";
+	    }
+	    return rst;
+	};
+	QGMiniAdapter.idx = 1;
+
+	class MiniAccelerator extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	    }
+	    static __init__() {
+	        try {
+	            var Acc;
+	            Acc = Laya.Accelerator;
+	            if (!Acc)
+	                return;
+	            Acc["prototype"]["on"] = MiniAccelerator["prototype"]["on"];
+	            Acc["prototype"]["off"] = MiniAccelerator["prototype"]["off"];
+	        }
+	        catch (e) {
+	        }
+	    }
+	    static startListen(callBack) {
+	        MiniAccelerator._callBack = callBack;
+	        if (MiniAccelerator._isListening)
+	            return;
+	        MiniAccelerator._isListening = true;
+	        try {
+	            QGMiniAdapter.window.qg.onAccelerometerChange(MiniAccelerator.onAccelerometerChange);
+	        }
+	        catch (e) { }
+	    }
+	    static stopListen() {
+	        MiniAccelerator._isListening = false;
+	        try {
+	            QGMiniAdapter.window.qg.stopAccelerometer({});
+	        }
+	        catch (e) { }
+	    }
+	    static onAccelerometerChange(res) {
+	        var e;
+	        e = {};
+	        e.acceleration = res;
+	        e.accelerationIncludingGravity = res;
+	        e.rotationRate = {};
+	        if (MiniAccelerator._callBack != null) {
+	            MiniAccelerator._callBack(e);
+	        }
+	    }
+	    on(type, caller, listener, args = null) {
+	        super.on(type, caller, listener, args);
+	        MiniAccelerator.startListen(this["onDeviceOrientationChange"]);
+	        return this;
+	    }
+	    off(type, caller, listener, onceOnly = false) {
+	        if (!this.hasListener(type))
+	            MiniAccelerator.stopListen();
+	        return super.off(type, caller, listener, onceOnly);
+	    }
+	}
+	MiniAccelerator._isListening = false;
+
+	class MiniImage {
+	    _loadImage(url) {
+	        var thisLoader = this;
+	        if (QGMiniAdapter.isZiYu) {
+	            MiniImage.onCreateImage(url, thisLoader, true);
+	            return;
+	        }
+	        var isTransformUrl;
+	        if (!MiniFileMgr.isLocalNativeFile(url)) {
+	            isTransformUrl = true;
+	            url = Laya.URL.formatURL(url);
+	        }
+	        else {
+	            if (url.indexOf("http://usr/") == -1 && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1)) {
+	                if (MiniFileMgr.loadPath != "") {
+	                    url = url.split(MiniFileMgr.loadPath)[1];
+	                }
+	                else {
+	                    var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL.basePath;
+	                    var tempUrl = url;
+	                    if (tempStr != "")
+	                        url = url.split(tempStr)[1];
+	                    if (!url) {
+	                        url = tempUrl;
+	                    }
+	                }
+	            }
+	            if (QGMiniAdapter.subNativeFiles && QGMiniAdapter.subNativeheads.length == 0) {
+	                for (var key in QGMiniAdapter.subNativeFiles) {
+	                    var tempArr = QGMiniAdapter.subNativeFiles[key];
+	                    QGMiniAdapter.subNativeheads = QGMiniAdapter.subNativeheads.concat(tempArr);
+	                    for (var aa = 0; aa < tempArr.length; aa++) {
+	                        QGMiniAdapter.subMaps[tempArr[aa]] = key + "/" + tempArr[aa];
+	                    }
+	                }
+	            }
+	            if (QGMiniAdapter.subNativeFiles && url.indexOf("/") != -1) {
+	                var curfileHead = url.split("/")[0] + "/";
+	                if (curfileHead && QGMiniAdapter.subNativeheads.indexOf(curfileHead) != -1) {
+	                    var newfileHead = QGMiniAdapter.subMaps[curfileHead];
+	                    url = url.replace(curfileHead, newfileHead);
+	                }
+	            }
+	        }
+	        if (!MiniFileMgr.getFileInfo(url)) {
+	            if (url.indexOf('http://usr/') == -1 && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1)) {
+	                if (QGMiniAdapter.isZiYu) {
+	                    MiniImage.onCreateImage(url, thisLoader, true);
+	                }
+	                else {
+	                    MiniFileMgr.downOtherFiles(encodeURI(url), new Laya.Handler(MiniImage, MiniImage.onDownImgCallBack, [url, thisLoader]), url);
+	                }
+	            }
+	            else
+	                MiniImage.onCreateImage(url, thisLoader, true);
+	        }
+	        else {
+	            MiniImage.onCreateImage(url, thisLoader, !isTransformUrl);
+	        }
+	    }
+	    static onDownImgCallBack(sourceUrl, thisLoader, errorCode, tempFilePath = "") {
+	        if (!errorCode)
+	            MiniImage.onCreateImage(sourceUrl, thisLoader, false, tempFilePath);
+	        else {
+	            thisLoader.onError(null);
+	        }
+	    }
+	    static onCreateImage(sourceUrl, thisLoader, isLocal = false, tempFilePath = "") {
+	        var fileNativeUrl;
+	        if (QGMiniAdapter.autoCacheFile) {
+	            if (!isLocal) {
+	                if (tempFilePath != "") {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	                else {
+	                    var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                    var fileMd5Name = fileObj.md5;
+	                    fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                }
+	            }
+	            else if (QGMiniAdapter.isZiYu) {
+	                var tempUrl = Laya.URL.formatURL(sourceUrl);
+	                if (MiniFileMgr.ziyuFileTextureData[tempUrl]) {
+	                    fileNativeUrl = MiniFileMgr.ziyuFileTextureData[tempUrl];
+	                }
+	                else
+	                    fileNativeUrl = sourceUrl;
+	            }
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        else {
+	            if (!isLocal)
+	                fileNativeUrl = tempFilePath;
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        if (thisLoader._imgCache == null)
+	            thisLoader._imgCache = {};
+	        var image;
+	        function clear() {
+	            var img = thisLoader._imgCache[sourceUrl];
+	            if (img) {
+	                img.onload = null;
+	                img.onerror = null;
+	                delete thisLoader._imgCache[sourceUrl];
+	            }
+	        }
+	        var onerror = function () {
+	            clear();
+	            delete MiniFileMgr.fakeObj[sourceUrl];
+	            delete MiniFileMgr.filesListObj[sourceUrl];
+	            thisLoader.event(Laya.Event.ERROR, "Load image failed");
+	        };
+	        if (thisLoader._type == "nativeimage") {
+	            var onload = function () {
+	                clear();
+	                thisLoader.onLoaded(image);
+	            };
+	            image = new Laya.Browser.window.Image();
+	            image.crossOrigin = "";
+	            image.onload = onload;
+	            image.onerror = onerror;
+	            image.src = fileNativeUrl;
+	            thisLoader._imgCache[sourceUrl] = image;
+	        }
+	        else {
+	            var imageSource = new Laya.Browser.window.Image();
+	            onload = function () {
+	                image = Laya.HTMLImage.create(imageSource.width, imageSource.height);
+	                image.loadImageSource(imageSource, true);
+	                image._setCreateURL(sourceUrl);
+	                clear();
+	                thisLoader.onLoaded(image);
+	            };
+	            imageSource.crossOrigin = "";
+	            imageSource.onload = onload;
+	            imageSource.onerror = onerror;
+	            imageSource.src = fileNativeUrl;
+	            thisLoader._imgCache[sourceUrl] = imageSource;
+	        }
+	    }
+	}
+
+	class MiniLocation {
+	    constructor() {
+	    }
+	    static __init__() {
+	        QGMiniAdapter.window.navigator.geolocation.getCurrentPosition = MiniLocation.getCurrentPosition;
+	        QGMiniAdapter.window.navigator.geolocation.watchPosition = MiniLocation.watchPosition;
+	        QGMiniAdapter.window.navigator.geolocation.clearWatch = MiniLocation.clearWatch;
+	    }
+	    static getCurrentPosition(success = null, error = null, options = null) {
+	        var paramO;
+	        paramO = {};
+	        paramO.success = getSuccess;
+	        paramO.fail = error;
+	        QGMiniAdapter.window.qg.getLocation(paramO);
+	        function getSuccess(res) {
+	            if (success != null) {
+	                success(res);
+	            }
+	        }
+	    }
+	    static watchPosition(success = null, error = null, options = null) {
+	        MiniLocation._curID++;
+	        var curWatchO;
+	        curWatchO = {};
+	        curWatchO.success = success;
+	        curWatchO.error = error;
+	        MiniLocation._watchDic[MiniLocation._curID] = curWatchO;
+	        Laya.Laya.systemTimer.loop(1000, null, MiniLocation._myLoop);
+	        return MiniLocation._curID;
+	    }
+	    static clearWatch(id) {
+	        delete MiniLocation._watchDic[id];
+	        if (!MiniLocation._hasWatch()) {
+	            Laya.Laya.systemTimer.clear(null, MiniLocation._myLoop);
+	        }
+	    }
+	    static _hasWatch() {
+	        var key;
+	        for (key in MiniLocation._watchDic) {
+	            if (MiniLocation._watchDic[key])
+	                return true;
+	        }
+	        return false;
+	    }
+	    static _myLoop() {
+	        MiniLocation.getCurrentPosition(MiniLocation._mySuccess, MiniLocation._myError);
+	    }
+	    static _mySuccess(res) {
+	        var rst = {};
+	        rst.coords = res;
+	        rst.timestamp = Laya.Browser.now();
+	        var key;
+	        for (key in MiniLocation._watchDic) {
+	            if (MiniLocation._watchDic[key].success) {
+	                MiniLocation._watchDic[key].success(rst);
+	            }
+	        }
+	    }
+	    static _myError(res) {
+	        var key;
+	        for (key in MiniLocation._watchDic) {
+	            if (MiniLocation._watchDic[key].error) {
+	                MiniLocation._watchDic[key].error(res);
+	            }
+	        }
+	    }
+	}
+	MiniLocation._watchDic = {};
+	MiniLocation._curID = 0;
+
+	class MiniVideo {
+	    constructor(width = 320, height = 240) {
+	        this.videoend = false;
+	        this.videourl = "";
+	        this.videoW = width;
+	        this.videoH = height;
+	    }
+	    static __init__() {
+	    }
+	    on(eventType, ths, callBack) {
+	        if (eventType == "loadedmetadata") {
+	            this.onPlayFunc = callBack.bind(ths);
+	        }
+	        else if (eventType == "ended") {
+	            this.onEndedFunC = callBack.bind(ths);
+	        }
+	        this.videoElement.onTimeUpdate = this.onTimeUpdateFunc.bind(this);
+	    }
+	    onTimeUpdateFunc(data) {
+	        this.position = data.position;
+	        this._duration = data.duration;
+	    }
+	    get duration() {
+	        return this._duration;
+	    }
+	    onPlayFunction() {
+	        if (this.videoElement)
+	            this.videoElement.readyState = 200;
+	        this.onPlayFunc != null && this.onPlayFunc();
+	    }
+	    onEndedFunction() {
+	        this.videoend = true;
+	        this.onEndedFunC != null && this.onEndedFunC();
+	    }
+	    off(eventType, ths, callBack) {
+	        if (eventType == "loadedmetadata") {
+	            this.onPlayFunc = callBack.bind(ths);
+	            this.videoElement.offPlay = this.onPlayFunction.bind(this);
+	        }
+	        else if (eventType == "ended") {
+	            this.onEndedFunC = callBack.bind(ths);
+	            this.videoElement.offEnded = this.onEndedFunction.bind(this);
+	        }
+	    }
+	    load(url) {
+	        if (!this.videoElement) {
+	            this.videoElement = QGMiniAdapter.window.qg.createVideo({ width: this.videoW, height: this.videoH, autoplay: true, src: url });
+	            this.videoElement.onPlay = this.onPlayFunction.bind(this);
+	            this.videoElement.onEnded = this.onEndedFunction.bind(this);
+	        }
+	        else {
+	            this.videoElement.src = url;
+	        }
+	    }
+	    play() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoend = false;
+	        this.videoElement.play();
+	    }
+	    pause() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoend = true;
+	        this.videoElement.pause();
+	    }
+	    get currentTime() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.initialTime;
+	    }
+	    set currentTime(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.initialTime = value;
+	    }
+	    get videoWidth() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.width;
+	    }
+	    get videoHeight() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.height;
+	    }
+	    get ended() {
+	        return this.videoend;
+	    }
+	    get loop() {
+	        if (!this.videoElement)
+	            return false;
+	        return this.videoElement.loop;
+	    }
+	    set loop(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.loop = value;
+	    }
+	    get playbackRate() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.playbackRate;
+	    }
+	    set playbackRate(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.playbackRate = value;
+	    }
+	    get muted() {
+	        if (!this.videoElement)
+	            return false;
+	        return this.videoElement.muted;
+	    }
+	    set muted(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.muted = value;
+	    }
+	    get paused() {
+	        if (!this.videoElement)
+	            return false;
+	        return this.videoElement.paused;
+	    }
+	    size(width, height) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.width = width;
+	        this.videoElement.height = height;
+	    }
+	    get x() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.x;
+	    }
+	    set x(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.x = value;
+	    }
+	    get y() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.y;
+	    }
+	    set y(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.y = value;
+	    }
+	    get currentSrc() {
+	        return this.videoElement.src;
+	    }
+	    destroy() {
+	        if (this.videoElement)
+	            this.videoElement.destroy();
+	        this.videoElement = null;
+	        this.onEndedFunC = null;
+	        this.onPlayFunc = null;
+	        this.videoend = false;
+	        this.videourl = null;
+	    }
+	    reload() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.src = this.videourl;
+	    }
+	}
+
+	exports.MiniAccelerator = MiniAccelerator;
+	exports.MiniFileMgr = MiniFileMgr;
+	exports.MiniImage = MiniImage;
+	exports.MiniInput = MiniInput;
+	exports.MiniLoader = MiniLoader;
+	exports.MiniLocation = MiniLocation;
+	exports.MiniSound = MiniSound;
+	exports.MiniSoundChannel = MiniSoundChannel;
+	exports.MiniVideo = MiniVideo;
+	exports.QGMiniAdapter = QGMiniAdapter;
+
+} 

+ 1604 - 0
ShootingSun/bin/libs/laya.tiledmap.js

@@ -0,0 +1,1604 @@
+(function (exports, Laya) {
+    'use strict';
+
+    class GridSprite extends Laya.Sprite {
+        constructor() {
+            super(...arguments);
+            this.relativeX = 0;
+            this.relativeY = 0;
+            this.isAloneObject = false;
+            this.isHaveAnimation = false;
+            this.drawImageNum = 0;
+            this._map = null;
+        }
+        initData(map, objectKey = false) {
+            this._map = map;
+            this.isAloneObject = objectKey;
+        }
+        addAniSprite(sprite) {
+            if (this.aniSpriteArray == null) {
+                this.aniSpriteArray = [];
+            }
+            this.aniSpriteArray.push(sprite);
+        }
+        show() {
+            if (!this.visible) {
+                this.visible = true;
+                if (this.aniSpriteArray == null) {
+                    return;
+                }
+                var tAniSprite;
+                for (var i = 0; i < this.aniSpriteArray.length; i++) {
+                    tAniSprite = this.aniSpriteArray[i];
+                    tAniSprite.show();
+                }
+            }
+        }
+        hide() {
+            if (this.visible) {
+                this.visible = false;
+                if (this.aniSpriteArray == null) {
+                    return;
+                }
+                var tAniSprite;
+                for (var i = 0; i < this.aniSpriteArray.length; i++) {
+                    tAniSprite = this.aniSpriteArray[i];
+                    tAniSprite.hide();
+                }
+            }
+        }
+        updatePos() {
+            if (this.isAloneObject) {
+                if (this._map) {
+                    this.x = this.relativeX - this._map._viewPortX;
+                    this.y = this.relativeY - this._map._viewPortY;
+                }
+                if (this.x < 0 || this.x > this._map.viewPortWidth || this.y < 0 || this.y > this._map.viewPortHeight) {
+                    this.hide();
+                }
+                else {
+                    this.show();
+                }
+            }
+            else {
+                if (this._map) {
+                    this.x = this.relativeX - this._map._viewPortX;
+                    this.y = this.relativeY - this._map._viewPortY;
+                }
+            }
+        }
+        clearAll() {
+            if (this._map) {
+                this._map = null;
+            }
+            this.visible = false;
+            var tAniSprite;
+            if (this.aniSpriteArray != null) {
+                for (var i = 0; i < this.aniSpriteArray.length; i++) {
+                    tAniSprite = this.aniSpriteArray[i];
+                    tAniSprite.clearAll();
+                }
+            }
+            this.destroy();
+            this.relativeX = 0;
+            this.relativeY = 0;
+            this.isHaveAnimation = false;
+            this.aniSpriteArray = null;
+            this.drawImageNum = 0;
+        }
+    }
+
+    class IMap {
+    }
+    IMap.TiledMap = null;
+
+    class TileAniSprite extends Laya.Sprite {
+        constructor() {
+            super(...arguments);
+            this._tileTextureSet = null;
+            this._aniName = null;
+        }
+        setTileTextureSet(aniName, tileTextureSet) {
+            this._aniName = aniName;
+            this._tileTextureSet = tileTextureSet;
+            tileTextureSet.addAniSprite(this._aniName, this);
+        }
+        show() {
+            this._tileTextureSet.addAniSprite(this._aniName, this);
+        }
+        hide() {
+            this._tileTextureSet.removeAniSprite(this._aniName);
+        }
+        clearAll() {
+            this._tileTextureSet.removeAniSprite(this._aniName);
+            this.destroy();
+            this._tileTextureSet = null;
+            this._aniName = null;
+        }
+    }
+
+    class MapLayer extends Laya.Sprite {
+        constructor() {
+            super(...arguments);
+            this._mapData = null;
+            this._tileWidthHalf = 0;
+            this._tileHeightHalf = 0;
+            this._mapWidthHalf = 0;
+            this._mapHeightHalf = 0;
+            this._gridSpriteArray = [];
+            this._objDic = null;
+            this._dataDic = null;
+            this._tempMapPos = new Laya.Point();
+            this.layerName = null;
+        }
+        init(layerData, map) {
+            this._map = map;
+            this._mapData = layerData.data;
+            var tHeight = layerData.height;
+            var tWidth = layerData.width;
+            var tTileW = map.tileWidth;
+            var tTileH = map.tileHeight;
+            this.layerName = layerData.name;
+            this._properties = layerData.properties;
+            this.alpha = layerData.opacity;
+            this._tileWidthHalf = tTileW / 2;
+            this._tileHeightHalf = tTileH / 2;
+            this._mapWidthHalf = this._map.width / 2 - this._tileWidthHalf;
+            this._mapHeightHalf = this._map.height / 2;
+            switch (layerData.type) {
+                case "tilelayer":
+                    break;
+                case "objectgroup":
+                    var tArray = layerData.objects;
+                    if (tArray.length > 0) {
+                        this._objDic = {};
+                        this._dataDic = {};
+                    }
+                    var tObjectData;
+                    var tObjWidth;
+                    var tObjHeight;
+                    for (var i = 0; i < tArray.length; i++) {
+                        tObjectData = tArray[i];
+                        this._dataDic[tObjectData.name] = tObjectData;
+                        if (tObjectData.visible == true) {
+                            tObjWidth = tObjectData.width;
+                            tObjHeight = tObjectData.height;
+                            var tSprite = map.getSprite(tObjectData.gid, tObjWidth, tObjHeight);
+                            if (tSprite != null) {
+                                switch (this._map.orientation) {
+                                    case IMap.TiledMap.ORIENTATION_ISOMETRIC:
+                                        this.getScreenPositionByTilePos(tObjectData.x / tTileH, tObjectData.y / tTileH, Laya.Point.TEMP);
+                                        tSprite.pivot(tObjWidth / 2, tObjHeight / 2);
+                                        tSprite.rotation = tObjectData.rotation;
+                                        tSprite.x = tSprite.relativeX = Laya.Point.TEMP.x + this._map.viewPortX;
+                                        tSprite.y = tSprite.relativeY = Laya.Point.TEMP.y + this._map.viewPortY - tObjHeight / 2;
+                                        break;
+                                    case IMap.TiledMap.ORIENTATION_STAGGERED:
+                                        tSprite.pivot(tObjWidth / 2, tObjHeight / 2);
+                                        tSprite.rotation = tObjectData.rotation;
+                                        tSprite.x = tSprite.relativeX = tObjectData.x + tObjWidth / 2;
+                                        tSprite.y = tSprite.relativeY = tObjectData.y - tObjHeight / 2;
+                                        break;
+                                    case IMap.TiledMap.ORIENTATION_ORTHOGONAL:
+                                        tSprite.pivot(tObjWidth / 2, tObjHeight / 2);
+                                        tSprite.rotation = tObjectData.rotation;
+                                        tSprite.x = tSprite.relativeX = tObjectData.x + tObjWidth / 2;
+                                        tSprite.y = tSprite.relativeY = tObjectData.y - tObjHeight / 2;
+                                        break;
+                                    case IMap.TiledMap.ORIENTATION_HEXAGONAL:
+                                        tSprite.x = tSprite.relativeX = tObjectData.x;
+                                        tSprite.y = tSprite.relativeY = tObjectData.y;
+                                        break;
+                                }
+                                this.addChild(tSprite);
+                                this._gridSpriteArray.push(tSprite);
+                                this._objDic[tObjectData.name] = tSprite;
+                            }
+                        }
+                    }
+                    break;
+            }
+        }
+        getObjectByName(objName) {
+            if (this._objDic) {
+                return this._objDic[objName];
+            }
+            return null;
+        }
+        getObjectDataByName(objName) {
+            if (this._dataDic) {
+                return this._dataDic[objName];
+            }
+            return null;
+        }
+        getLayerProperties(name) {
+            if (this._properties) {
+                return this._properties[name];
+            }
+            return null;
+        }
+        getTileData(tileX, tileY) {
+            if (tileY >= 0 && tileY < this._map.numRowsTile && tileX >= 0 && tileX < this._map.numColumnsTile) {
+                var tIndex = tileY * this._map.numColumnsTile + tileX;
+                var tMapData = this._mapData;
+                if (tMapData != null && tIndex < tMapData.length) {
+                    return tMapData[tIndex];
+                }
+            }
+            return 0;
+        }
+        getScreenPositionByTilePos(tileX, tileY, screenPos = null) {
+            if (screenPos) {
+                switch (this._map.orientation) {
+                    case IMap.TiledMap.ORIENTATION_ISOMETRIC:
+                        screenPos.x = this._map.width / 2 - (tileY - tileX) * this._tileWidthHalf;
+                        screenPos.y = (tileY + tileX) * this._tileHeightHalf;
+                        break;
+                    case IMap.TiledMap.ORIENTATION_STAGGERED:
+                        tileX = Math.floor(tileX);
+                        tileY = Math.floor(tileY);
+                        screenPos.x = tileX * this._map.tileWidth + (tileY & 1) * this._tileWidthHalf;
+                        screenPos.y = tileY * this._tileHeightHalf;
+                        break;
+                    case IMap.TiledMap.ORIENTATION_ORTHOGONAL:
+                        screenPos.x = tileX * this._map.tileWidth;
+                        screenPos.y = tileY * this._map.tileHeight;
+                        break;
+                    case IMap.TiledMap.ORIENTATION_HEXAGONAL:
+                        tileX = Math.floor(tileX);
+                        tileY = Math.floor(tileY);
+                        var tTileHeight = this._map.tileHeight * 2 / 3;
+                        screenPos.x = (tileX * this._map.tileWidth + tileY % 2 * this._tileWidthHalf) % this._map.gridWidth;
+                        screenPos.y = (tileY * tTileHeight) % this._map.gridHeight;
+                        break;
+                }
+                screenPos.x = (screenPos.x + this._map.viewPortX) * this._map.scale;
+                screenPos.y = (screenPos.y + this._map.viewPortY) * this._map.scale;
+            }
+        }
+        getTileDataByScreenPos(screenX, screenY) {
+            var tData = 0;
+            if (this.getTilePositionByScreenPos(screenX, screenY, this._tempMapPos)) {
+                tData = this.getTileData(Math.floor(this._tempMapPos.x), Math.floor(this._tempMapPos.y));
+            }
+            return tData;
+        }
+        getTilePositionByScreenPos(screenX, screenY, result = null) {
+            screenX = screenX / this._map.scale - this._map.viewPortX;
+            screenY = screenY / this._map.scale - this._map.viewPortY;
+            var tTileW = this._map.tileWidth;
+            var tTileH = this._map.tileHeight;
+            var tV = 0;
+            var tU = 0;
+            switch (this._map.orientation) {
+                case IMap.TiledMap.ORIENTATION_ISOMETRIC:
+                    var tDirX = screenX - this._map.width / 2;
+                    var tDirY = screenY;
+                    tV = -(tDirX / tTileW - tDirY / tTileH);
+                    tU = tDirX / tTileW + tDirY / tTileH;
+                    if (result) {
+                        result.x = tU;
+                        result.y = tV;
+                    }
+                    return true;
+                    break;
+                case IMap.TiledMap.ORIENTATION_STAGGERED:
+                    if (result) {
+                        var cx, cy, rx, ry;
+                        cx = Math.floor(screenX / tTileW) * tTileW + tTileW / 2;
+                        cy = Math.floor(screenY / tTileH) * tTileH + tTileH / 2;
+                        rx = (screenX - cx) * tTileH / 2;
+                        ry = (screenY - cy) * tTileW / 2;
+                        if (Math.abs(rx) + Math.abs(ry) <= tTileW * tTileH / 4) {
+                            tU = Math.floor(screenX / tTileW);
+                            tV = Math.floor(screenY / tTileH) * 2;
+                        }
+                        else {
+                            screenX = screenX - tTileW / 2;
+                            tU = Math.floor(screenX / tTileW) + 1;
+                            screenY = screenY - tTileH / 2;
+                            tV = Math.floor(screenY / tTileH) * 2 + 1;
+                        }
+                        result.x = tU - (tV & 1);
+                        result.y = tV;
+                    }
+                    return true;
+                    break;
+                case IMap.TiledMap.ORIENTATION_ORTHOGONAL:
+                    tU = screenX / tTileW;
+                    tV = screenY / tTileH;
+                    if (result) {
+                        result.x = tU;
+                        result.y = tV;
+                    }
+                    return true;
+                    break;
+                case IMap.TiledMap.ORIENTATION_HEXAGONAL:
+                    var tTileHeight = tTileH * 2 / 3;
+                    tV = screenY / tTileHeight;
+                    tU = (screenX - tV % 2 * this._tileWidthHalf) / tTileW;
+                    if (result) {
+                        result.x = tU;
+                        result.y = tV;
+                    }
+                    break;
+            }
+            return false;
+        }
+        getDrawSprite(gridX, gridY) {
+            var tSprite = new GridSprite();
+            tSprite.relativeX = gridX * this._map.gridWidth;
+            tSprite.relativeY = gridY * this._map.gridHeight;
+            tSprite.initData(this._map);
+            this._gridSpriteArray.push(tSprite);
+            return tSprite;
+        }
+        updateGridPos() {
+            var tSprite;
+            for (var i = 0; i < this._gridSpriteArray.length; i++) {
+                tSprite = this._gridSpriteArray[i];
+                if ((tSprite.visible || tSprite.isAloneObject) && tSprite.drawImageNum > 0) {
+                    tSprite.updatePos();
+                }
+            }
+        }
+        drawTileTexture(gridSprite, tileX, tileY) {
+            if (tileY >= 0 && tileY < this._map.numRowsTile && tileX >= 0 && tileX < this._map.numColumnsTile) {
+                var tIndex = tileY * this._map.numColumnsTile + tileX;
+                var tMapData = this._mapData;
+                if (tMapData != null && tIndex < tMapData.length) {
+                    if (tMapData[tIndex] != 0) {
+                        var tTileTexSet = this._map.getTexture(tMapData[tIndex]);
+                        if (tTileTexSet) {
+                            var tX = 0;
+                            var tY = 0;
+                            var tTexture = tTileTexSet.texture;
+                            switch (this._map.orientation) {
+                                case IMap.TiledMap.ORIENTATION_STAGGERED:
+                                    tX = tileX * this._map.tileWidth % this._map.gridWidth + (tileY & 1) * this._tileWidthHalf;
+                                    tY = tileY * this._tileHeightHalf % this._map.gridHeight;
+                                    break;
+                                case IMap.TiledMap.ORIENTATION_ORTHOGONAL:
+                                    tX = tileX * this._map.tileWidth % this._map.gridWidth;
+                                    tY = tileY * this._map.tileHeight % this._map.gridHeight;
+                                    break;
+                                case IMap.TiledMap.ORIENTATION_ISOMETRIC:
+                                    tX = (this._mapWidthHalf + (tileX - tileY) * this._tileWidthHalf) % this._map.gridWidth;
+                                    tY = ((tileX + tileY) * this._tileHeightHalf) % this._map.gridHeight;
+                                    break;
+                                case IMap.TiledMap.ORIENTATION_HEXAGONAL:
+                                    var tTileHeight = this._map.tileHeight * 2 / 3;
+                                    tX = (tileX * this._map.tileWidth + tileY % 2 * this._tileWidthHalf) % this._map.gridWidth;
+                                    tY = (tileY * tTileHeight) % this._map.gridHeight;
+                                    break;
+                            }
+                            if (tTileTexSet.isAnimation) {
+                                var tAnimationSprite = new TileAniSprite();
+                                tAnimationSprite.x = tX;
+                                tAnimationSprite.y = tY;
+                                tAnimationSprite.setTileTextureSet(tIndex.toString(), tTileTexSet);
+                                gridSprite.addAniSprite(tAnimationSprite);
+                                gridSprite.addChild(tAnimationSprite);
+                                gridSprite.isHaveAnimation = true;
+                            }
+                            else {
+                                gridSprite.graphics.drawImage(tTileTexSet.texture, tX + tTileTexSet.offX, tY + tTileTexSet.offY);
+                            }
+                            return true;
+                        }
+                    }
+                }
+            }
+            return false;
+        }
+        clearAll() {
+            this._map = null;
+            this._mapData = null;
+            this._tileWidthHalf = 0;
+            this._tileHeightHalf = 0;
+            this._mapWidthHalf = 0;
+            this._mapHeightHalf = 0;
+            this.layerName = null;
+            var i = 0;
+            if (this._objDic) {
+                for (var p in this._objDic) {
+                    delete this._objDic[p];
+                }
+                this._objDic = null;
+            }
+            if (this._dataDic) {
+                for (p in this._dataDic) {
+                    delete this._dataDic[p];
+                }
+                this._dataDic = null;
+            }
+            var tGridSprite;
+            for (i = 0; i < this._gridSpriteArray.length; i++) {
+                tGridSprite = this._gridSpriteArray[i];
+                tGridSprite.clearAll();
+            }
+            this._properties = null;
+            this._tempMapPos = null;
+            this.tarLayer = null;
+        }
+    }
+
+    class TileTexSet {
+        constructor() {
+            this.gid = -1;
+            this.offX = 0;
+            this.offY = 0;
+            this.textureArray = null;
+            this.durationTimeArray = null;
+            this.animationTotalTime = 0;
+            this.isAnimation = false;
+            this._spriteNum = 0;
+            this._aniDic = null;
+            this._frameIndex = 0;
+            this._time = 0;
+            this._interval = 0;
+            this._preFrameTime = 0;
+        }
+        addAniSprite(aniName, sprite) {
+            if (this.animationTotalTime == 0) {
+                return;
+            }
+            if (this._aniDic == null) {
+                this._aniDic = {};
+            }
+            if (this._spriteNum == 0) {
+                Laya.ILaya.timer.frameLoop(3, this, this.animate);
+                this._preFrameTime = Laya.ILaya.Browser.now();
+                this._frameIndex = 0;
+                this._time = 0;
+                this._interval = 0;
+            }
+            this._spriteNum++;
+            this._aniDic[aniName] = sprite;
+            if (this.textureArray && this._frameIndex < this.textureArray.length) {
+                var tTileTextureSet = this.textureArray[this._frameIndex];
+                this.drawTexture(sprite, tTileTextureSet);
+            }
+        }
+        animate() {
+            if (this.textureArray && this.textureArray.length > 0 && this.durationTimeArray && this.durationTimeArray.length > 0) {
+                var tNow = Laya.ILaya.Browser.now();
+                this._interval = tNow - this._preFrameTime;
+                this._preFrameTime = tNow;
+                if (this._interval > this.animationTotalTime) {
+                    this._interval = this._interval % this.animationTotalTime;
+                }
+                this._time += this._interval;
+                var tTime = this.durationTimeArray[this._frameIndex];
+                while (this._time > tTime) {
+                    this._time -= tTime;
+                    this._frameIndex++;
+                    if (this._frameIndex >= this.durationTimeArray.length || this._frameIndex >= this.textureArray.length) {
+                        this._frameIndex = 0;
+                    }
+                    var tTileTextureSet = this.textureArray[this._frameIndex];
+                    var tSprite;
+                    for (var p in this._aniDic) {
+                        tSprite = this._aniDic[p];
+                        this.drawTexture(tSprite, tTileTextureSet);
+                    }
+                    tTime = this.durationTimeArray[this._frameIndex];
+                }
+            }
+        }
+        drawTexture(sprite, tileTextSet) {
+            sprite.graphics.clear(true);
+            sprite.graphics.drawImage(tileTextSet.texture, tileTextSet.offX, tileTextSet.offY);
+        }
+        removeAniSprite(_name) {
+            if (this._aniDic && this._aniDic[_name]) {
+                delete this._aniDic[_name];
+                this._spriteNum--;
+                if (this._spriteNum == 0) {
+                    Laya.ILaya.timer.clear(this, this.animate);
+                }
+            }
+        }
+        showDebugInfo() {
+            var tInfo = null;
+            if (this._spriteNum > 0) {
+                tInfo = "TileTextureSet::gid:" + this.gid.toString() + " 动画数:" + this._spriteNum.toString();
+            }
+            return tInfo;
+        }
+        clearAll() {
+            this.gid = -1;
+            if (this.texture) {
+                this.texture.destroy();
+                this.texture = null;
+            }
+            this.offX = 0;
+            this.offY = 0;
+            this.textureArray = null;
+            this.durationTimeArray = null;
+            this.isAnimation = false;
+            this._spriteNum = 0;
+            this._aniDic = null;
+            this._frameIndex = 0;
+            this._preFrameTime = 0;
+            this._time = 0;
+            this._interval = 0;
+        }
+    }
+
+    class TiledMap {
+        constructor() {
+            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._rect = new Laya.Rectangle();
+            this._paddingRect = new Laya.Rectangle();
+            this._mapSprite = null;
+            this._layerArray = [];
+            this._renderLayerArray = [];
+            this._gridArray = [];
+            this._showGridKey = false;
+            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._mapRect = new GRect();
+            this._mapLastRect = new GRect();
+            this._index = 0;
+            this._animationDic = {};
+            this._tileProperties = {};
+            this._tileProperties2 = {};
+            this._orientation = "orthogonal";
+            this._renderOrder = "right-down";
+            this._colorArray = ["FF", "00", "33", "66"];
+            this._scale = 1;
+            this._pivotScaleX = 0.5;
+            this._pivotScaleY = 0.5;
+            this._centerX = 0;
+            this._centerY = 0;
+            this._viewPortX = 0;
+            this._viewPortY = 0;
+            this._viewPortWidth = 0;
+            this._viewPortHeight = 0;
+            this._enableLinear = true;
+            this._limitRange = false;
+            this.autoCache = true;
+            this.autoCacheType = "normal";
+            this.enableMergeLayer = false;
+            this.removeCoveredTile = false;
+            this.showGridTextureCount = false;
+            this.antiCrack = true;
+            this.cacheAllAfterInit = false;
+            this._texutreStartDic = {};
+        }
+        createMap(mapName, viewRect, completeHandler, viewRectPadding = null, gridSize = null, enableLinear = true, limitRange = false) {
+            this._enableLinear = enableLinear;
+            this._limitRange = limitRange;
+            this._rect.x = viewRect.x;
+            this._rect.y = viewRect.y;
+            this._rect.width = viewRect.width;
+            this._rect.height = viewRect.height;
+            this._viewPortWidth = viewRect.width / this._scale;
+            this._viewPortHeight = viewRect.height / this._scale;
+            this._completeHandler = completeHandler;
+            if (viewRectPadding) {
+                this._paddingRect.copyFrom(viewRectPadding);
+            }
+            else {
+                this._paddingRect.setTo(0, 0, 0, 0);
+            }
+            if (gridSize) {
+                this._gridWidth = gridSize.x;
+                this._gridHeight = gridSize.y;
+            }
+            var tIndex = mapName.lastIndexOf("/");
+            if (tIndex > -1) {
+                this._resPath = mapName.substr(0, tIndex);
+                this._pathArray = this._resPath.split("/");
+            }
+            else {
+                this._resPath = "";
+                this._pathArray = [];
+            }
+            this._jsonLoader = new Laya.Loader();
+            this._jsonLoader.once("complete", this, this.onJsonComplete);
+            this._jsonLoader.load(mapName, Laya.Loader.JSON, false);
+        }
+        onJsonComplete(e) {
+            this._mapSprite = new Laya.Sprite();
+            Laya.ILaya.stage.addChild(this._mapSprite);
+            var tJsonData = this._jsonData = e;
+            this._properties = tJsonData.properties;
+            this._orientation = tJsonData.orientation;
+            this._renderOrder = tJsonData.renderorder;
+            this._mapW = tJsonData.width;
+            this._mapH = tJsonData.height;
+            this._mapTileW = tJsonData.tilewidth;
+            this._mapTileH = tJsonData.tileheight;
+            this._width = this._mapTileW * this._mapW;
+            this._height = this._mapTileH * this._mapH;
+            if (this._orientation == TiledMap.ORIENTATION_STAGGERED) {
+                this._height = (0.5 + this._mapH * 0.5) * this._mapTileH;
+            }
+            this._mapLastRect.top = this._mapLastRect.bottom = this._mapLastRect.left = this._mapLastRect.right = -1;
+            var tArray = tJsonData.tilesets;
+            var tileset;
+            var tTileSet;
+            var i = 0;
+            for (i = 0; i < tArray.length; i++) {
+                tileset = tArray[i];
+                tTileSet = new TileSet();
+                tTileSet.init(tileset);
+                if (tTileSet.properties && tTileSet.properties.ignore)
+                    continue;
+                this._tileProperties[i] = tTileSet.tileproperties;
+                this.addTileProperties(tTileSet.tileproperties);
+                this._tileSetArray.push(tTileSet);
+                var tTiles = tileset.tiles;
+                if (tTiles) {
+                    for (var p in tTiles) {
+                        var tAnimation = tTiles[p].animation;
+                        if (tAnimation) {
+                            var tAniData = new TileMapAniData();
+                            this._animationDic[p] = tAniData;
+                            tAniData.image = tileset.image;
+                            for (var j = 0; j < tAnimation.length; j++) {
+                                var tAnimationItem = tAnimation[j];
+                                tAniData.mAniIdArray.push(tAnimationItem.tileid);
+                                tAniData.mDurationTimeArray.push(tAnimationItem.duration);
+                            }
+                        }
+                    }
+                }
+            }
+            this._tileTexSetArr.push(null);
+            if (this._tileSetArray.length > 0) {
+                tTileSet = this._currTileSet = this._tileSetArray.shift();
+                this._loader = new Laya.Loader();
+                this._loader.once("complete", this, this.onTextureComplete);
+                var tPath = this.mergePath(this._resPath, tTileSet.image);
+                this._loader.load(tPath, Laya.Loader.IMAGE, false);
+            }
+        }
+        mergePath(resPath, relativePath) {
+            var tResultPath = "";
+            var tImageArray = relativePath.split("/");
+            var tParentPathNum = 0;
+            var i = 0;
+            for (i = tImageArray.length - 1; i >= 0; i--) {
+                if (tImageArray[i] == "..") {
+                    tParentPathNum++;
+                }
+            }
+            if (tParentPathNum == 0) {
+                if (this._pathArray.length > 0) {
+                    tResultPath = resPath + "/" + relativePath;
+                }
+                else {
+                    tResultPath = relativePath;
+                }
+                return tResultPath;
+            }
+            var tSrcNum = this._pathArray.length - tParentPathNum;
+            if (tSrcNum < 0) {
+                console.log("[error]path does not exist", this._pathArray, tImageArray, resPath, relativePath);
+            }
+            for (i = 0; i < tSrcNum; i++) {
+                if (i == 0) {
+                    tResultPath += this._pathArray[i];
+                }
+                else {
+                    tResultPath = tResultPath + "/" + this._pathArray[i];
+                }
+            }
+            for (i = tParentPathNum; i < tImageArray.length; i++) {
+                tResultPath = tResultPath + "/" + tImageArray[i];
+            }
+            return tResultPath;
+        }
+        onTextureComplete(e) {
+            var json = this._jsonData;
+            var tTexture = e;
+            if (!this._enableLinear) {
+                tTexture.bitmap.minFifter = 0x2600;
+                tTexture.bitmap.magFifter = 0x2600;
+            }
+            this._texArray.push(tTexture);
+            var tTileSet = this._currTileSet;
+            var tTileTextureW = tTileSet.tilewidth;
+            var tTileTextureH = tTileSet.tileheight;
+            var tImageWidth = tTileSet.imagewidth;
+            var tImageHeight = tTileSet.imageheight;
+            var tFirstgid = tTileSet.firstgid;
+            var tTileWNum = Math.floor((tImageWidth - tTileSet.margin - tTileTextureW) / (tTileTextureW + tTileSet.spacing)) + 1;
+            var tTileHNum = Math.floor((tImageHeight - tTileSet.margin - tTileTextureH) / (tTileTextureH + tTileSet.spacing)) + 1;
+            var tTileTexSet = null;
+            this._texutreStartDic[tTileSet.image] = this._tileTexSetArr.length;
+            for (var i = 0; i < tTileHNum; i++) {
+                for (var j = 0; j < tTileWNum; j++) {
+                    tTileTexSet = new TileTexSet();
+                    tTileTexSet.offX = tTileSet.titleoffsetX;
+                    tTileTexSet.offY = tTileSet.titleoffsetY - (tTileTextureH - this._mapTileH);
+                    tTileTexSet.texture = Laya.Texture.createFromTexture(tTexture, tTileSet.margin + (tTileTextureW + tTileSet.spacing) * j, tTileSet.margin + (tTileTextureH + tTileSet.spacing) * i, tTileTextureW, tTileTextureH);
+                    if (this.antiCrack)
+                        this.adptTexture(tTileTexSet.texture);
+                    this._tileTexSetArr.push(tTileTexSet);
+                    tTileTexSet.gid = this._tileTexSetArr.length;
+                }
+            }
+            if (this._tileSetArray.length > 0) {
+                tTileSet = this._currTileSet = this._tileSetArray.shift();
+                this._loader.once("complete", this, this.onTextureComplete);
+                var tPath = this.mergePath(this._resPath, tTileSet.image);
+                this._loader.load(tPath, Laya.Loader.IMAGE, false);
+            }
+            else {
+                this._currTileSet = null;
+                this.initMap();
+            }
+        }
+        adptTexture(tex) {
+            if (!tex)
+                return;
+            var pX = tex.uv[0];
+            var pX1 = tex.uv[2];
+            var pY = tex.uv[1];
+            var pY1 = tex.uv[7];
+            var dW = 1 / tex.bitmap.width;
+            var dH = 1 / tex.bitmap.height;
+            var Tex = tex;
+            Tex.uv[0] = Tex.uv[6] = pX + dW;
+            Tex.uv[2] = Tex.uv[4] = pX1 - dW;
+            Tex.uv[1] = Tex.uv[3] = pY + dH;
+            Tex.uv[5] = Tex.uv[7] = pY1 - dH;
+        }
+        initMap() {
+            var i, n;
+            for (var p in this._animationDic) {
+                var tAniData = this._animationDic[p];
+                var gStart;
+                gStart = this._texutreStartDic[tAniData.image];
+                var tTileTexSet = this.getTexture(parseInt(p) + gStart);
+                if (tAniData.mAniIdArray.length > 0) {
+                    tTileTexSet.textureArray = [];
+                    tTileTexSet.durationTimeArray = tAniData.mDurationTimeArray;
+                    tTileTexSet.isAnimation = true;
+                    tTileTexSet.animationTotalTime = 0;
+                    for (i = 0, n = tTileTexSet.durationTimeArray.length; i < n; i++) {
+                        tTileTexSet.animationTotalTime += tTileTexSet.durationTimeArray[i];
+                    }
+                    for (i = 0, n = tAniData.mAniIdArray.length; i < n; i++) {
+                        var tTexture = this.getTexture(tAniData.mAniIdArray[i] + gStart);
+                        tTileTexSet.textureArray.push(tTexture);
+                    }
+                }
+            }
+            this._gridWidth = Math.floor(this._gridWidth / this._mapTileW) * this._mapTileW;
+            this._gridHeight = Math.floor(this._gridHeight / this._mapTileH) * this._mapTileH;
+            if (this._gridWidth < this._mapTileW) {
+                this._gridWidth = this._mapTileW;
+            }
+            if (this._gridHeight < this._mapTileH) {
+                this._gridHeight = this._mapTileH;
+            }
+            this._gridW = Math.ceil(this._width / this._gridWidth);
+            this._gridH = Math.ceil(this._height / this._gridHeight);
+            this._totalGridNum = this._gridW * this._gridH;
+            for (i = 0; i < this._gridH; i++) {
+                var tGridArray = [];
+                this._gridArray.push(tGridArray);
+                for (var j = 0; j < this._gridW; j++) {
+                    tGridArray.push(null);
+                }
+            }
+            var tLayerArray = this._jsonData.layers;
+            var isFirst = true;
+            var tLayerTarLayerName;
+            var preLayerTarName;
+            var preLayer;
+            for (var tLayerLoop = 0; tLayerLoop < tLayerArray.length; tLayerLoop++) {
+                var tLayerData = tLayerArray[tLayerLoop];
+                if (tLayerData.visible == true) {
+                    var tMapLayer = new MapLayer();
+                    tMapLayer.init(tLayerData, this);
+                    if (!this.enableMergeLayer) {
+                        this._mapSprite.addChild(tMapLayer);
+                        this._renderLayerArray.push(tMapLayer);
+                    }
+                    else {
+                        tLayerTarLayerName = tMapLayer.getLayerProperties("layer");
+                        isFirst = isFirst || (!preLayer) || (tLayerTarLayerName != preLayerTarName);
+                        if (isFirst) {
+                            isFirst = false;
+                            tMapLayer.tarLayer = tMapLayer;
+                            preLayer = tMapLayer;
+                            this._mapSprite.addChild(tMapLayer);
+                            this._renderLayerArray.push(tMapLayer);
+                        }
+                        else {
+                            tMapLayer.tarLayer = preLayer;
+                        }
+                        preLayerTarName = tLayerTarLayerName;
+                    }
+                    this._layerArray.push(tMapLayer);
+                }
+            }
+            if (this.removeCoveredTile) {
+                this.adptTiledMapData();
+            }
+            if (this.cacheAllAfterInit) {
+                this.cacheAllGrid();
+            }
+            this.moveViewPort(this._rect.x, this._rect.y);
+            if (this._completeHandler != null) {
+                this._completeHandler.run();
+            }
+        }
+        addTileProperties(tileDataDic) {
+            var key;
+            for (key in tileDataDic) {
+                this._tileProperties2[key] = tileDataDic[key];
+            }
+        }
+        getTileUserData(id, sign, defaultV = null) {
+            if (!this._tileProperties2 || !this._tileProperties2[id] || !(sign in this._tileProperties2[id]))
+                return defaultV;
+            return this._tileProperties2[id][sign];
+        }
+        adptTiledMapData() {
+            var i, len;
+            len = this._layerArray.length;
+            var tLayer;
+            var noNeeds = {};
+            var tDatas;
+            for (i = len - 1; i >= 0; i--) {
+                tLayer = this._layerArray[i];
+                tDatas = tLayer._mapData;
+                if (!tDatas)
+                    continue;
+                this.removeCoverd(tDatas, noNeeds);
+                this.collectCovers(tDatas, noNeeds, i);
+            }
+        }
+        removeCoverd(datas, noNeeds) {
+            var i, len;
+            len = datas.length;
+            for (i = 0; i < len; i++) {
+                if (noNeeds[i]) {
+                    datas[i] = 0;
+                }
+            }
+        }
+        collectCovers(datas, noNeeds, layer) {
+            var i, len;
+            len = datas.length;
+            var tTileData;
+            var isCover;
+            for (i = 0; i < len; i++) {
+                tTileData = datas[i];
+                if (tTileData > 0) {
+                    isCover = this.getTileUserData(tTileData - 1, "type", 0);
+                    if (isCover > 0) {
+                        noNeeds[i] = tTileData;
+                    }
+                }
+            }
+        }
+        getTexture(index) {
+            if (index < this._tileTexSetArr.length) {
+                return this._tileTexSetArr[index];
+            }
+            return null;
+        }
+        getMapProperties(name) {
+            if (this._properties) {
+                return this._properties[name];
+            }
+            return null;
+        }
+        getTileProperties(index, id, name) {
+            if (this._tileProperties[index] && this._tileProperties[index][id]) {
+                return this._tileProperties[index][id][name];
+            }
+            return null;
+        }
+        getSprite(index, width, height) {
+            if (0 < this._tileTexSetArr.length) {
+                var tGridSprite = new GridSprite();
+                tGridSprite.initData(this, true);
+                tGridSprite.size(width, height);
+                var tTileTexSet = this._tileTexSetArr[index];
+                if (tTileTexSet != null && tTileTexSet.texture != null) {
+                    if (tTileTexSet.isAnimation) {
+                        var tAnimationSprite = new TileAniSprite();
+                        this._index++;
+                        tAnimationSprite.setTileTextureSet(this._index.toString(), tTileTexSet);
+                        tGridSprite.addAniSprite(tAnimationSprite);
+                        tGridSprite.addChild(tAnimationSprite);
+                    }
+                    else {
+                        tGridSprite.graphics.drawImage(tTileTexSet.texture, 0, 0, width, height);
+                    }
+                    tGridSprite.drawImageNum++;
+                }
+                return tGridSprite;
+            }
+            return null;
+        }
+        setViewPortPivotByScale(scaleX, scaleY) {
+            this._pivotScaleX = scaleX;
+            this._pivotScaleY = scaleY;
+        }
+        set scale(scale) {
+            if (scale <= 0)
+                return;
+            this._scale = scale;
+            this._viewPortWidth = this._rect.width / scale;
+            this._viewPortHeight = this._rect.height / scale;
+            this._mapSprite.scale(this._scale, this._scale);
+            this.updateViewPort();
+        }
+        get scale() {
+            return this._scale;
+        }
+        moveViewPort(moveX, moveY) {
+            this._x = -moveX;
+            this._y = -moveY;
+            this._rect.x = moveX;
+            this._rect.y = moveY;
+            this.updateViewPort();
+        }
+        changeViewPort(moveX, moveY, width, height) {
+            if (moveX == this._rect.x && moveY == this._rect.y && width == this._rect.width && height == this._rect.height)
+                return;
+            this._x = -moveX;
+            this._y = -moveY;
+            this._rect.x = moveX;
+            this._rect.y = moveY;
+            this._rect.width = width;
+            this._rect.height = height;
+            this._viewPortWidth = width / this._scale;
+            this._viewPortHeight = height / this._scale;
+            this.updateViewPort();
+        }
+        changeViewPortBySize(width, height, rect = null) {
+            if (rect == null) {
+                rect = new Laya.Rectangle();
+            }
+            this._centerX = this._rect.x + this._rect.width * this._pivotScaleX;
+            this._centerY = this._rect.y + this._rect.height * this._pivotScaleY;
+            rect.x = this._centerX - width * this._pivotScaleX;
+            rect.y = this._centerY - height * this._pivotScaleY;
+            rect.width = width;
+            rect.height = height;
+            this.changeViewPort(rect.x, rect.y, rect.width, rect.height);
+            return rect;
+        }
+        updateViewPort() {
+            this._centerX = this._rect.x + this._rect.width * this._pivotScaleX;
+            this._centerY = this._rect.y + this._rect.height * this._pivotScaleY;
+            var posChanged = false;
+            var preValue = this._viewPortX;
+            this._viewPortX = this._centerX - this._rect.width * this._pivotScaleX / this._scale;
+            if (preValue != this._viewPortX) {
+                posChanged = true;
+            }
+            else {
+                preValue = this._viewPortY;
+            }
+            this._viewPortY = this._centerY - this._rect.height * this._pivotScaleY / this._scale;
+            if (!posChanged && preValue != this._viewPortY) {
+                posChanged = true;
+            }
+            if (this._limitRange) {
+                var tRight = this._viewPortX + this._viewPortWidth;
+                if (tRight > this._width) {
+                    this._viewPortX = this._width - this._viewPortWidth;
+                }
+                var tBottom = this._viewPortY + this._viewPortHeight;
+                if (tBottom > this._height) {
+                    this._viewPortY = this._height - this._viewPortHeight;
+                }
+                if (this._viewPortX < 0) {
+                    this._viewPortX = 0;
+                }
+                if (this._viewPortY < 0) {
+                    this._viewPortY = 0;
+                }
+            }
+            var tPaddingRect = this._paddingRect;
+            this._mapRect.top = Math.floor((this._viewPortY - tPaddingRect.y) / this._gridHeight);
+            this._mapRect.bottom = Math.floor((this._viewPortY + this._viewPortHeight + tPaddingRect.height + tPaddingRect.y) / this._gridHeight);
+            this._mapRect.left = Math.floor((this._viewPortX - tPaddingRect.x) / this._gridWidth);
+            this._mapRect.right = Math.floor((this._viewPortX + this._viewPortWidth + tPaddingRect.width + tPaddingRect.x) / this._gridWidth);
+            if (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;
+                posChanged = true;
+            }
+            if (!posChanged)
+                return;
+            var tMapLayer;
+            var len = this._renderLayerArray.length;
+            for (var i = 0; i < len; i++) {
+                tMapLayer = this._renderLayerArray[i];
+                if (tMapLayer._gridSpriteArray.length > 0)
+                    tMapLayer.updateGridPos();
+            }
+        }
+        clipViewPort() {
+            var tSub = 0;
+            var tAdd = 0;
+            var i, j;
+            if (this._mapRect.left > this._mapLastRect.left) {
+                tSub = this._mapRect.left - this._mapLastRect.left;
+                if (tSub > 0) {
+                    for (j = this._mapLastRect.left; j < this._mapLastRect.left + tSub; j++) {
+                        for (i = this._mapLastRect.top; i <= this._mapLastRect.bottom; i++) {
+                            this.hideGrid(j, i);
+                        }
+                    }
+                }
+            }
+            else {
+                tAdd = Math.min(this._mapLastRect.left, this._mapRect.right + 1) - this._mapRect.left;
+                if (tAdd > 0) {
+                    for (j = this._mapRect.left; j < this._mapRect.left + tAdd; j++) {
+                        for (i = this._mapRect.top; i <= this._mapRect.bottom; i++) {
+                            this.showGrid(j, i);
+                        }
+                    }
+                }
+            }
+            if (this._mapRect.right > this._mapLastRect.right) {
+                tAdd = this._mapRect.right - this._mapLastRect.right;
+                if (tAdd > 0) {
+                    for (j = Math.max(this._mapLastRect.right + 1, this._mapRect.left); j <= this._mapLastRect.right + tAdd; j++) {
+                        for (i = this._mapRect.top; i <= this._mapRect.bottom; i++) {
+                            this.showGrid(j, i);
+                        }
+                    }
+                }
+            }
+            else {
+                tSub = this._mapLastRect.right - this._mapRect.right;
+                if (tSub > 0) {
+                    for (j = this._mapRect.right + 1; j <= this._mapRect.right + tSub; j++) {
+                        for (i = this._mapLastRect.top; i <= this._mapLastRect.bottom; i++) {
+                            this.hideGrid(j, i);
+                        }
+                    }
+                }
+            }
+            if (this._mapRect.top > this._mapLastRect.top) {
+                tSub = this._mapRect.top - this._mapLastRect.top;
+                if (tSub > 0) {
+                    for (i = this._mapLastRect.top; i < this._mapLastRect.top + tSub; i++) {
+                        for (j = this._mapLastRect.left; j <= this._mapLastRect.right; j++) {
+                            this.hideGrid(j, i);
+                        }
+                    }
+                }
+            }
+            else {
+                tAdd = Math.min(this._mapLastRect.top, this._mapRect.bottom + 1) - this._mapRect.top;
+                if (tAdd > 0) {
+                    for (i = this._mapRect.top; i < this._mapRect.top + tAdd; i++) {
+                        for (j = this._mapRect.left; j <= this._mapRect.right; j++) {
+                            this.showGrid(j, i);
+                        }
+                    }
+                }
+            }
+            if (this._mapRect.bottom > this._mapLastRect.bottom) {
+                tAdd = this._mapRect.bottom - this._mapLastRect.bottom;
+                if (tAdd > 0) {
+                    for (i = Math.max(this._mapLastRect.bottom + 1, this._mapRect.top); i <= this._mapLastRect.bottom + tAdd; i++) {
+                        for (j = this._mapRect.left; j <= this._mapRect.right; j++) {
+                            this.showGrid(j, i);
+                        }
+                    }
+                }
+            }
+            else {
+                tSub = this._mapLastRect.bottom - this._mapRect.bottom;
+                if (tSub > 0) {
+                    for (i = this._mapRect.bottom + 1; i <= this._mapRect.bottom + tSub; i++) {
+                        for (j = this._mapLastRect.left; j <= this._mapLastRect.right; j++) {
+                            this.hideGrid(j, i);
+                        }
+                    }
+                }
+            }
+        }
+        showGrid(gridX, gridY) {
+            if (gridX < 0 || gridX >= this._gridW || gridY < 0 || gridY >= this._gridH) {
+                return;
+            }
+            var i;
+            var tGridSprite;
+            var tTempArray = this._gridArray[gridY][gridX];
+            if (tTempArray == null) {
+                tTempArray = this.getGridArray(gridX, gridY);
+            }
+            else {
+                for (i = 0; i < tTempArray.length && i < this._layerArray.length; i++) {
+                    var tLayerSprite = this._layerArray[i];
+                    if (tLayerSprite && tTempArray[i]) {
+                        tGridSprite = tTempArray[i];
+                        if (tGridSprite.visible == false && tGridSprite.drawImageNum > 0) {
+                            tGridSprite.show();
+                        }
+                    }
+                }
+            }
+        }
+        cacheAllGrid() {
+            var i, j;
+            var tempArr;
+            for (i = 0; i < this._gridW; i++) {
+                for (j = 0; j < this._gridH; j++) {
+                    tempArr = this.getGridArray(i, j);
+                    this.cacheGridsArray(tempArr);
+                }
+            }
+        }
+        cacheGridsArray(arr) {
+            var canvas;
+            if (!TiledMap._tempCanvas) {
+                TiledMap._tempCanvas = new Laya.HTMLCanvas();
+                var tx = TiledMap._tempCanvas.context;
+                if (!tx) {
+                    tx = TiledMap._tempCanvas.getContext('2d');
+                }
+            }
+            canvas = TiledMap._tempCanvas;
+            canvas.context.asBitmap = false;
+            var i, len;
+            len = arr.length;
+            var tGrid;
+            for (i = 0; i < len; i++) {
+                tGrid = arr[i];
+                canvas.clear();
+                canvas.size(1, 1);
+                tGrid.render(canvas.context, 0, 0);
+                tGrid.hide();
+            }
+            canvas.clear();
+            canvas.size(1, 1);
+        }
+        getGridArray(gridX, gridY) {
+            var i, j;
+            var tGridSprite;
+            var tTempArray = this._gridArray[gridY][gridX];
+            if (tTempArray == null) {
+                tTempArray = this._gridArray[gridY][gridX] = [];
+                var tLeft = 0;
+                var tRight = 0;
+                var tTop = 0;
+                var tBottom = 0;
+                var tGridWidth = this._gridWidth;
+                var tGridHeight = this._gridHeight;
+                switch (this.orientation) {
+                    case TiledMap.ORIENTATION_ISOMETRIC:
+                        tLeft = Math.floor(gridX * tGridWidth);
+                        tRight = Math.floor(gridX * tGridWidth + tGridWidth);
+                        tTop = Math.floor(gridY * tGridHeight);
+                        tBottom = Math.floor(gridY * tGridHeight + tGridHeight);
+                        var tLeft1, tRight1, tTop1, tBottom1;
+                        break;
+                    case TiledMap.ORIENTATION_STAGGERED:
+                        tLeft = Math.floor(gridX * tGridWidth / this._mapTileW);
+                        tRight = Math.floor((gridX * tGridWidth + tGridWidth) / this._mapTileW);
+                        tTop = Math.floor(gridY * tGridHeight / (this._mapTileH / 2));
+                        tBottom = Math.floor((gridY * tGridHeight + tGridHeight) / (this._mapTileH / 2));
+                        break;
+                    case TiledMap.ORIENTATION_ORTHOGONAL:
+                        tLeft = Math.floor(gridX * tGridWidth / this._mapTileW);
+                        tRight = Math.floor((gridX * tGridWidth + tGridWidth) / this._mapTileW);
+                        tTop = Math.floor(gridY * tGridHeight / this._mapTileH);
+                        tBottom = Math.floor((gridY * tGridHeight + tGridHeight) / this._mapTileH);
+                        break;
+                    case TiledMap.ORIENTATION_HEXAGONAL:
+                        var tHeight = this._mapTileH * 2 / 3;
+                        tLeft = Math.floor(gridX * tGridWidth / this._mapTileW);
+                        tRight = Math.ceil((gridX * tGridWidth + tGridWidth) / this._mapTileW);
+                        tTop = Math.floor(gridY * tGridHeight / tHeight);
+                        tBottom = Math.ceil((gridY * tGridHeight + tGridHeight) / tHeight);
+                        break;
+                }
+                var tLayer = null;
+                var tTGridSprite;
+                var tDrawMapLayer;
+                for (var z = 0; z < this._layerArray.length; z++) {
+                    tLayer = this._layerArray[z];
+                    if (this.enableMergeLayer) {
+                        if (tLayer.tarLayer != tDrawMapLayer) {
+                            tTGridSprite = null;
+                            tDrawMapLayer = tLayer.tarLayer;
+                        }
+                        if (!tTGridSprite) {
+                            tTGridSprite = tDrawMapLayer.getDrawSprite(gridX, gridY);
+                            tTempArray.push(tTGridSprite);
+                        }
+                        tGridSprite = tTGridSprite;
+                    }
+                    else {
+                        tGridSprite = tLayer.getDrawSprite(gridX, gridY);
+                        tTempArray.push(tGridSprite);
+                    }
+                    var tColorStr;
+                    if (this._showGridKey) {
+                        tColorStr = "#";
+                        tColorStr += this._colorArray[Math.floor(Math.random() * this._colorArray.length)];
+                        tColorStr += this._colorArray[Math.floor(Math.random() * this._colorArray.length)];
+                        tColorStr += this._colorArray[Math.floor(Math.random() * this._colorArray.length)];
+                    }
+                    switch (this.orientation) {
+                        case TiledMap.ORIENTATION_ISOMETRIC:
+                            var tHalfTileHeight = this.tileHeight / 2;
+                            var tHalfTileWidth = this.tileWidth / 2;
+                            var tHalfMapWidth = this._width / 2;
+                            tTop1 = Math.floor(tTop / tHalfTileHeight);
+                            tBottom1 = Math.floor(tBottom / tHalfTileHeight);
+                            tLeft1 = this._mapW + Math.floor((tLeft - tHalfMapWidth) / tHalfTileWidth);
+                            tRight1 = this._mapW + Math.floor((tRight - tHalfMapWidth) / tHalfTileWidth);
+                            var tMapW = this._mapW * 2;
+                            var tMapH = this._mapH * 2;
+                            if (tTop1 < 0) {
+                                tTop1 = 0;
+                            }
+                            if (tTop1 >= tMapH) {
+                                tTop1 = tMapH - 1;
+                            }
+                            if (tBottom1 < 0) {
+                                tBottom = 0;
+                            }
+                            if (tBottom1 >= tMapH) {
+                                tBottom1 = tMapH - 1;
+                            }
+                            tGridSprite.zOrder = this._totalGridNum * z + gridY * this._gridW + gridX;
+                            for (i = tTop1; i < tBottom1; i++) {
+                                for (j = 0; j <= i; j++) {
+                                    var tIndexX = i - j;
+                                    var tIndexY = j;
+                                    var tIndexValue = (tIndexX - tIndexY) + this._mapW;
+                                    if (tIndexValue > tLeft1 && tIndexValue <= tRight1) {
+                                        if (tLayer.drawTileTexture(tGridSprite, tIndexX, tIndexY)) {
+                                            tGridSprite.drawImageNum++;
+                                        }
+                                    }
+                                }
+                            }
+                            break;
+                        case TiledMap.ORIENTATION_STAGGERED:
+                            tGridSprite.zOrder = z * this._totalGridNum + gridY * this._gridW + gridX;
+                            for (i = tTop; i < tBottom; i++) {
+                                for (j = tLeft; j < tRight; j++) {
+                                    if (tLayer.drawTileTexture(tGridSprite, j, i)) {
+                                        tGridSprite.drawImageNum++;
+                                    }
+                                }
+                            }
+                            break;
+                        case TiledMap.ORIENTATION_ORTHOGONAL:
+                        case TiledMap.ORIENTATION_HEXAGONAL:
+                            switch (this._renderOrder) {
+                                case TiledMap.RENDERORDER_RIGHTDOWN:
+                                    tGridSprite.zOrder = z * this._totalGridNum + gridY * this._gridW + gridX;
+                                    for (i = tTop; i < tBottom; i++) {
+                                        for (j = tLeft; j < tRight; j++) {
+                                            if (tLayer.drawTileTexture(tGridSprite, j, i)) {
+                                                tGridSprite.drawImageNum++;
+                                            }
+                                        }
+                                    }
+                                    break;
+                                case TiledMap.RENDERORDER_RIGHTUP:
+                                    tGridSprite.zOrder = z * this._totalGridNum + (this._gridH - 1 - gridY) * this._gridW + gridX;
+                                    for (i = tBottom - 1; i >= tTop; i--) {
+                                        for (j = tLeft; j < tRight; j++) {
+                                            if (tLayer.drawTileTexture(tGridSprite, j, i)) {
+                                                tGridSprite.drawImageNum++;
+                                            }
+                                        }
+                                    }
+                                    break;
+                                case TiledMap.RENDERORDER_LEFTDOWN:
+                                    tGridSprite.zOrder = z * this._totalGridNum + gridY * this._gridW + (this._gridW - 1 - gridX);
+                                    for (i = tTop; i < tBottom; i++) {
+                                        for (j = tRight - 1; j >= tLeft; j--) {
+                                            if (tLayer.drawTileTexture(tGridSprite, j, i)) {
+                                                tGridSprite.drawImageNum++;
+                                            }
+                                        }
+                                    }
+                                    break;
+                                case TiledMap.RENDERORDER_LEFTUP:
+                                    tGridSprite.zOrder = z * this._totalGridNum + (this._gridH - 1 - gridY) * this._gridW + (this._gridW - 1 - gridX);
+                                    for (i = tBottom - 1; i >= tTop; i--) {
+                                        for (j = tRight - 1; j >= tLeft; j--) {
+                                            if (tLayer.drawTileTexture(tGridSprite, j, i)) {
+                                                tGridSprite.drawImageNum++;
+                                            }
+                                        }
+                                    }
+                                    break;
+                            }
+                            break;
+                    }
+                    if (!tGridSprite.isHaveAnimation) {
+                        tGridSprite.autoSize = true;
+                        if (this.autoCache)
+                            tGridSprite.cacheAs = this.autoCacheType;
+                        tGridSprite.autoSize = false;
+                    }
+                    if (!this.enableMergeLayer) {
+                        if (tGridSprite.drawImageNum > 0) {
+                            tLayer.addChild(tGridSprite);
+                        }
+                        if (this._showGridKey) {
+                            tGridSprite.graphics.drawRect(0, 0, tGridWidth, tGridHeight, null, tColorStr);
+                        }
+                    }
+                    else {
+                        if (tTGridSprite && tTGridSprite.drawImageNum > 0 && tDrawMapLayer) {
+                            tDrawMapLayer.addChild(tTGridSprite);
+                        }
+                    }
+                }
+                if (this.enableMergeLayer && this.showGridTextureCount) {
+                    if (tTGridSprite) {
+                        tTGridSprite.graphics.fillText(tTGridSprite.drawImageNum + "", 20, 20, null, "#ff0000", "left");
+                    }
+                }
+            }
+            return tTempArray;
+        }
+        hideGrid(gridX, gridY) {
+            if (gridX < 0 || gridX >= this._gridW || gridY < 0 || gridY >= this._gridH) {
+                return;
+            }
+            var tTempArray = this._gridArray[gridY][gridX];
+            if (tTempArray) {
+                var tGridSprite;
+                for (var i = 0; i < tTempArray.length; i++) {
+                    tGridSprite = tTempArray[i];
+                    if (tGridSprite.drawImageNum > 0) {
+                        if (tGridSprite != null) {
+                            tGridSprite.hide();
+                        }
+                    }
+                }
+            }
+        }
+        getLayerObject(layerName, objectName) {
+            var tLayer = null;
+            for (var i = 0; i < this._layerArray.length; i++) {
+                tLayer = this._layerArray[i];
+                if (tLayer.layerName == layerName) {
+                    break;
+                }
+            }
+            if (tLayer) {
+                return tLayer.getObjectByName(objectName);
+            }
+            return null;
+        }
+        destroy() {
+            this._orientation = TiledMap.ORIENTATION_ORTHOGONAL;
+            this._jsonData = null;
+            var i = 0;
+            this._gridArray = [];
+            var tTileTexSet;
+            for (i = 0; i < this._tileTexSetArr.length; i++) {
+                tTileTexSet = this._tileTexSetArr[i];
+                if (tTileTexSet) {
+                    tTileTexSet.clearAll();
+                }
+            }
+            this._tileTexSetArr = [];
+            var tTexture;
+            for (i = 0; i < this._texArray.length; i++) {
+                tTexture = this._texArray[i];
+                tTexture.destroy();
+            }
+            this._texArray = [];
+            this._width = 0;
+            this._height = 0;
+            this._mapW = 0;
+            this._mapH = 0;
+            this._mapTileW = 0;
+            this._mapTileH = 0;
+            this._rect.setTo(0, 0, 0, 0);
+            var tLayer;
+            for (i = 0; i < this._layerArray.length; i++) {
+                tLayer = this._layerArray[i];
+                tLayer.clearAll();
+            }
+            this._layerArray = [];
+            this._renderLayerArray = [];
+            if (this._mapSprite) {
+                this._mapSprite.destroy();
+                this._mapSprite = null;
+            }
+            this._jsonLoader = null;
+            this._loader = null;
+            var tDic = this._animationDic;
+            for (var p in tDic) {
+                delete tDic[p];
+            }
+            this._properties = null;
+            tDic = this._tileProperties;
+            for (p in tDic) {
+                delete tDic[p];
+            }
+            this._currTileSet = null;
+            this._completeHandler = null;
+            this._mapRect.clearAll();
+            this._mapLastRect.clearAll();
+            this._tileSetArray = [];
+            this._gridWidth = 450;
+            this._gridHeight = 450;
+            this._gridW = 0;
+            this._gridH = 0;
+            this._x = 0;
+            this._y = 0;
+            this._index = 0;
+            this._enableLinear = true;
+            this._resPath = null;
+            this._pathArray = null;
+        }
+        get tileWidth() {
+            return this._mapTileW;
+        }
+        get tileHeight() {
+            return this._mapTileH;
+        }
+        get width() {
+            return this._width;
+        }
+        get height() {
+            return this._height;
+        }
+        get numColumnsTile() {
+            return this._mapW;
+        }
+        get numRowsTile() {
+            return this._mapH;
+        }
+        get viewPortX() {
+            return -this._viewPortX;
+        }
+        get viewPortY() {
+            return -this._viewPortY;
+        }
+        get viewPortWidth() {
+            return this._viewPortWidth;
+        }
+        get viewPortHeight() {
+            return this._viewPortHeight;
+        }
+        get x() {
+            return this._x;
+        }
+        get y() {
+            return this._y;
+        }
+        get gridWidth() {
+            return this._gridWidth;
+        }
+        get gridHeight() {
+            return this._gridHeight;
+        }
+        get numColumnsGrid() {
+            return this._gridW;
+        }
+        get numRowsGrid() {
+            return this._gridH;
+        }
+        get orientation() {
+            return this._orientation;
+        }
+        get renderOrder() {
+            return this._renderOrder;
+        }
+        mapSprite() {
+            return this._mapSprite;
+        }
+        getLayerByName(layerName) {
+            var tMapLayer;
+            for (var i = 0; i < this._layerArray.length; i++) {
+                tMapLayer = this._layerArray[i];
+                if (layerName == tMapLayer.layerName) {
+                    return tMapLayer;
+                }
+            }
+            return null;
+        }
+        getLayerByIndex(index) {
+            if (index < this._layerArray.length) {
+                return this._layerArray[index];
+            }
+            return null;
+        }
+    }
+    TiledMap.ORIENTATION_ORTHOGONAL = "orthogonal";
+    TiledMap.ORIENTATION_ISOMETRIC = "isometric";
+    TiledMap.ORIENTATION_STAGGERED = "staggered";
+    TiledMap.ORIENTATION_HEXAGONAL = "hexagonal";
+    TiledMap.RENDERORDER_RIGHTDOWN = "right-down";
+    TiledMap.RENDERORDER_RIGHTUP = "right-up";
+    TiledMap.RENDERORDER_LEFTDOWN = "left-down";
+    TiledMap.RENDERORDER_LEFTUP = "left-up";
+    class GRect {
+        clearAll() {
+            this.left = this.top = this.right = this.bottom = 0;
+        }
+    }
+    class TileMapAniData {
+        constructor() {
+            this.mAniIdArray = [];
+            this.mDurationTimeArray = [];
+            this.mTileTexSetArr = [];
+        }
+    }
+    class TileSet {
+        constructor() {
+            this.firstgid = 0;
+            this.image = "";
+            this.imageheight = 0;
+            this.imagewidth = 0;
+            this.margin = 0;
+            this.name = 0;
+            this.spacing = 0;
+            this.tileheight = 0;
+            this.tilewidth = 0;
+            this.titleoffsetX = 0;
+            this.titleoffsetY = 0;
+        }
+        init(data) {
+            this.firstgid = data.firstgid;
+            this.image = data.image;
+            this.imageheight = data.imageheight;
+            this.imagewidth = data.imagewidth;
+            this.margin = data.margin;
+            this.name = data.name;
+            this.properties = data.properties;
+            this.spacing = data.spacing;
+            this.tileheight = data.tileheight;
+            this.tilewidth = data.tilewidth;
+            this.tileproperties = data.tileproperties;
+            var tTileoffset = data.tileoffset;
+            if (tTileoffset) {
+                this.titleoffsetX = tTileoffset.x;
+                this.titleoffsetY = tTileoffset.y;
+            }
+        }
+    }
+    IMap.TiledMap = TiledMap;
+
+    exports.GridSprite = GridSprite;
+    exports.IMap = IMap;
+    exports.MapLayer = MapLayer;
+    exports.TileAniSprite = TileAniSprite;
+    exports.TileTexSet = TileTexSet;
+    exports.TiledMap = TiledMap;
+
+}(window.Laya = window.Laya || {}, Laya));

+ 6073 - 0
ShootingSun/bin/libs/laya.ui.js

@@ -0,0 +1,6073 @@
+(function (exports, Laya) {
+	'use strict';
+
+	class UIConfig {
+	}
+	UIConfig.touchScrollEnable = true;
+	UIConfig.mouseWheelEnable = true;
+	UIConfig.showButtons = true;
+	UIConfig.popupBgColor = "#000000";
+	UIConfig.popupBgAlpha = 0.5;
+	UIConfig.closeDialogOnSide = true;
+	window.UIConfig = UIConfig;
+
+	class Styles {
+	}
+	Styles.defaultSizeGrid = [4, 4, 4, 4, 0];
+	Styles.labelColor = "#000000";
+	Styles.labelPadding = [2, 2, 2, 2];
+	Styles.inputLabelPadding = [1, 1, 1, 3];
+	Styles.buttonStateNum = 3;
+	Styles.buttonLabelColors = ["#32556b", "#32cc6b", "#ff0000", "#C0C0C0"];
+	Styles.comboBoxItemColors = ["#5e95b6", "#ffffff", "#000000", "#8fa4b1", "#ffffff"];
+	Styles.scrollBarMinNum = 15;
+	Styles.scrollBarDelayTime = 500;
+
+	class AutoBitmap extends Laya.Graphics {
+	    constructor() {
+	        super(...arguments);
+	        this.autoCacheCmd = true;
+	        this._width = 0;
+	        this._height = 0;
+	        this.uv = null;
+	    }
+	    destroy() {
+	        super.destroy();
+	        this._source = null;
+	        this._sizeGrid = null;
+	        this._offset = null;
+	    }
+	    get sizeGrid() {
+	        return this._sizeGrid;
+	    }
+	    set sizeGrid(value) {
+	        this._sizeGrid = value.map((v) => { return +v; });
+	        this._setChanged();
+	    }
+	    get width() {
+	        if (this._width)
+	            return this._width;
+	        if (this._source)
+	            return this._source.sourceWidth;
+	        return 0;
+	    }
+	    set width(value) {
+	        if (this._width != value) {
+	            this._width = value;
+	            this._setChanged();
+	        }
+	    }
+	    get height() {
+	        if (this._height)
+	            return this._height;
+	        if (this._source)
+	            return this._source.sourceHeight;
+	        return 0;
+	    }
+	    set height(value) {
+	        if (this._height != value) {
+	            this._height = value;
+	            this._setChanged();
+	        }
+	    }
+	    get source() {
+	        return this._source;
+	    }
+	    set source(value) {
+	        if (value) {
+	            this._source = value;
+	            this._setChanged();
+	        }
+	        else {
+	            this._source = null;
+	            this.clear();
+	        }
+	    }
+	    _setChanged() {
+	        if (!this._isChanged) {
+	            this._isChanged = true;
+	            Laya.ILaya.timer.callLater(this, this.changeSource);
+	        }
+	    }
+	    changeSource() {
+	        this._isChanged = false;
+	        var source = this._source;
+	        if (!source || !source.bitmap)
+	            return;
+	        var width = this.width;
+	        var height = this.height;
+	        var sizeGrid = this._sizeGrid;
+	        var sw = source.sourceWidth;
+	        var sh = source.sourceHeight;
+	        if (!sizeGrid || (sw === width && sh === height)) {
+	            this.clear();
+	            this.drawTexture(source, this._offset ? this._offset[0] : 0, this._offset ? this._offset[1] : 0, width, height, null, 1, null, null, this.uv);
+	        }
+	        else {
+	            this.clear();
+	            this.draw9Grid(source, 0, 0, width, height, sizeGrid);
+	            this._repaint();
+	            return;
+	        }
+	        this._repaint();
+	    }
+	    drawBitmap(repeat, tex, x, y, width = 0, height = 0) {
+	        if (width < 0.1 || height < 0.1)
+	            return;
+	        if (repeat && (tex.width != width || tex.height != height))
+	            this.fillTexture(tex, x, y, width, height);
+	        else
+	            this.drawImage(tex, x, y, width, height);
+	    }
+	    static getTexture(tex, x, y, width, height) {
+	        if (width <= 0)
+	            width = 1;
+	        if (height <= 0)
+	            height = 1;
+	        tex.$_GID || (tex.$_GID = Laya.Utils.getGID());
+	        var texture;
+	        if (!texture || !texture._getSource()) {
+	            texture = Laya.Texture.createFromTexture(tex, x, y, width, height);
+	        }
+	        return texture;
+	    }
+	}
+	Laya.ClassUtils.regClass("laya.ui.AutoBitmap", AutoBitmap);
+	Laya.ClassUtils.regClass("Laya.AutoBitmap", AutoBitmap);
+
+	class Widget extends Laya.Component {
+	    constructor() {
+	        super(...arguments);
+	        this._top = NaN;
+	        this._bottom = NaN;
+	        this._left = NaN;
+	        this._right = NaN;
+	        this._centerX = NaN;
+	        this._centerY = NaN;
+	    }
+	    onReset() {
+	        this._top = this._bottom = this._left = this._right = this._centerX = this._centerY = NaN;
+	    }
+	    _onEnable() {
+	        if (this.owner.parent)
+	            this._onAdded();
+	        else
+	            this.owner.once(Laya.Event.ADDED, this, this._onAdded);
+	    }
+	    _onDisable() {
+	        this.owner.off(Laya.Event.ADDED, this, this._onAdded);
+	        if (this.owner.parent)
+	            this.owner.parent.off(Laya.Event.RESIZE, this, this._onParentResize);
+	    }
+	    _onAdded() {
+	        if (this.owner.parent)
+	            this.owner.parent.on(Laya.Event.RESIZE, this, this._onParentResize);
+	        this.resetLayoutX();
+	        this.resetLayoutY();
+	    }
+	    _onParentResize() {
+	        var flagX = this.resetLayoutX();
+	        var flagY = this.resetLayoutY();
+	        if (flagX || flagY)
+	            this.owner.event(Laya.Event.RESIZE);
+	    }
+	    resetLayoutX() {
+	        var owner = this.owner;
+	        if (!owner)
+	            return false;
+	        var parent = owner.parent;
+	        if (parent) {
+	            if (!isNaN(this.centerX)) {
+	                owner.x = Math.round((parent.width - owner.displayWidth) * 0.5 + this.centerX + owner.pivotX * owner.scaleX);
+	            }
+	            else if (!isNaN(this.left)) {
+	                owner.x = Math.round(this.left + owner.pivotX * owner.scaleX);
+	                if (!isNaN(this.right)) {
+	                    var temp = (parent._width - this.left - this.right) / (owner.scaleX || 0.01);
+	                    if (temp != owner.width) {
+	                        owner.width = temp;
+	                        return true;
+	                    }
+	                }
+	            }
+	            else if (!isNaN(this.right)) {
+	                owner.x = Math.round(parent.width - owner.displayWidth - this.right + owner.pivotX * owner.scaleX);
+	            }
+	        }
+	        return false;
+	    }
+	    resetLayoutY() {
+	        var owner = this.owner;
+	        if (!owner)
+	            return false;
+	        var parent = owner.parent;
+	        if (parent) {
+	            if (!isNaN(this.centerY)) {
+	                owner.y = Math.round((parent.height - owner.displayHeight) * 0.5 + this.centerY + owner.pivotY * owner.scaleY);
+	            }
+	            else if (!isNaN(this.top)) {
+	                owner.y = Math.round(this.top + owner.pivotY * owner.scaleY);
+	                if (!isNaN(this.bottom)) {
+	                    var temp = (parent._height - this.top - this.bottom) / (owner.scaleY || 0.01);
+	                    if (temp != owner.height) {
+	                        owner.height = temp;
+	                        return true;
+	                    }
+	                }
+	            }
+	            else if (!isNaN(this.bottom)) {
+	                owner.y = Math.round(parent.height - owner.displayHeight - this.bottom + owner.pivotY * owner.scaleY);
+	            }
+	        }
+	        return false;
+	    }
+	    resetLayout() {
+	        if (this.owner) {
+	            this.resetLayoutX();
+	            this.resetLayoutY();
+	        }
+	    }
+	    get top() {
+	        return this._top;
+	    }
+	    set top(value) {
+	        if (this._top != value) {
+	            this._top = value;
+	            this.resetLayoutY();
+	        }
+	    }
+	    get bottom() {
+	        return this._bottom;
+	    }
+	    set bottom(value) {
+	        if (this._bottom != value) {
+	            this._bottom = value;
+	            this.resetLayoutY();
+	        }
+	    }
+	    get left() {
+	        return this._left;
+	    }
+	    set left(value) {
+	        if (this._left != value) {
+	            this._left = value;
+	            this.resetLayoutX();
+	        }
+	    }
+	    get right() {
+	        return this._right;
+	    }
+	    set right(value) {
+	        if (this._right != value) {
+	            this._right = value;
+	            this.resetLayoutX();
+	        }
+	    }
+	    get centerX() {
+	        return this._centerX;
+	    }
+	    set centerX(value) {
+	        if (this._centerX != value) {
+	            this._centerX = value;
+	            this.resetLayoutX();
+	        }
+	    }
+	    get centerY() {
+	        return this._centerY;
+	    }
+	    set centerY(value) {
+	        if (this._centerY != value) {
+	            this._centerY = value;
+	            this.resetLayoutY();
+	        }
+	    }
+	}
+	Widget.EMPTY = null;
+	Laya.ILaya.regClass(Widget);
+	Widget.EMPTY = new Widget();
+	Laya.ClassUtils.regClass("laya.ui.Widget", Widget);
+	Laya.ClassUtils.regClass("Laya.Widget", Widget);
+
+	class UIEvent extends Laya.Event {
+	}
+	UIEvent.SHOW_TIP = "showtip";
+	UIEvent.HIDE_TIP = "hidetip";
+	Laya.ILaya.regClass(UIEvent);
+	Laya.ClassUtils.regClass("laya.ui.UIEvent", UIEvent);
+	Laya.ClassUtils.regClass("Laya.UIEvent", UIEvent);
+
+	class UIUtils {
+	    static fillArray(arr, str, type = null) {
+	        var temp = arr.concat();
+	        if (str) {
+	            var a = str.split(",");
+	            for (var i = 0, n = Math.min(temp.length, a.length); i < n; i++) {
+	                var value = a[i];
+	                temp[i] = (value == "true" ? true : (value == "false" ? false : value));
+	                if (type != null)
+	                    temp[i] = type(value);
+	            }
+	        }
+	        return temp;
+	    }
+	    static toColor(color) {
+	        return Laya.Utils.toHexColor(color);
+	    }
+	    static gray(traget, isGray = true) {
+	        if (isGray) {
+	            UIUtils.addFilter(traget, UIUtils.grayFilter);
+	        }
+	        else {
+	            UIUtils.clearFilter(traget, Laya.ColorFilter);
+	        }
+	    }
+	    static addFilter(target, filter) {
+	        var filters = target.filters || [];
+	        filters.push(filter);
+	        target.filters = filters;
+	    }
+	    static clearFilter(target, filterType) {
+	        var filters = target.filters;
+	        if (filters != null && filters.length > 0) {
+	            for (var i = filters.length - 1; i > -1; i--) {
+	                var filter = filters[i];
+	                if (filter instanceof filterType)
+	                    filters.splice(i, 1);
+	            }
+	            target.filters = filters;
+	        }
+	    }
+	    static _getReplaceStr(word) {
+	        return UIUtils.escapeSequence[word];
+	    }
+	    static adptString(str) {
+	        return str.replace(/\\(\w)/g, UIUtils._getReplaceStr);
+	    }
+	    static getBindFun(value) {
+	        if (!UIUtils._funMap) {
+	            UIUtils._funMap = new Laya.WeakObject();
+	        }
+	        var fun = UIUtils._funMap.get(value);
+	        if (fun == null) {
+	            var temp = "\"" + value + "\"";
+	            temp = temp.replace(/^"\${|}"$/g, "").replace(/\${/g, "\"+").replace(/}/g, "+\"");
+	            var str = "(function(data){if(data==null)return;with(data){try{\nreturn " + temp + "\n}catch(e){}}})";
+	            fun = window.Laya._runScript(str);
+	            UIUtils._funMap.set(value, fun);
+	        }
+	        return fun;
+	    }
+	}
+	UIUtils.grayFilter = new Laya.ColorFilter([0.3086, 0.6094, 0.082, 0, 0, 0.3086, 0.6094, 0.082, 0, 0, 0.3086, 0.6094, 0.082, 0, 0, 0, 0, 0, 1, 0]);
+	UIUtils.escapeSequence = { "\\n": "\n", "\\t": "\t" };
+	UIUtils._funMap = null;
+	Laya.ClassUtils.regClass("laya.ui.UIUtils", UIUtils);
+	Laya.ClassUtils.regClass("Laya.UIUtils", UIUtils);
+
+	class UIComponent extends Laya.Sprite {
+	    constructor(createChildren = true) {
+	        super();
+	        this._anchorX = NaN;
+	        this._anchorY = NaN;
+	        this._widget = Widget.EMPTY;
+	        if (createChildren) {
+	            this.preinitialize();
+	            this.createChildren();
+	            this.initialize();
+	        }
+	    }
+	    destroy(destroyChild = true) {
+	        super.destroy(destroyChild);
+	        this._dataSource = null;
+	        this._tag = null;
+	        this._toolTip = null;
+	    }
+	    preinitialize() {
+	    }
+	    createChildren() {
+	    }
+	    initialize() {
+	    }
+	    get width() {
+	        return this.get_width();
+	    }
+	    get_width() {
+	        if (this._width)
+	            return this._width;
+	        return this.measureWidth();
+	    }
+	    measureWidth() {
+	        var max = 0;
+	        this.commitMeasure();
+	        for (var i = this.numChildren - 1; i > -1; i--) {
+	            var comp = this.getChildAt(i);
+	            if (comp._visible) {
+	                max = Math.max(comp._x + comp.width * comp.scaleX, max);
+	            }
+	        }
+	        return max;
+	    }
+	    commitMeasure() {
+	    }
+	    get height() {
+	        return this.get_height();
+	    }
+	    get_height() {
+	        if (this._height)
+	            return this._height;
+	        return this.measureHeight();
+	    }
+	    measureHeight() {
+	        var max = 0;
+	        this.commitMeasure();
+	        for (var i = this.numChildren - 1; i > -1; i--) {
+	            var comp = this.getChildAt(i);
+	            if (comp._visible) {
+	                max = Math.max(comp._y + comp.height * comp.scaleY, max);
+	            }
+	        }
+	        return max;
+	    }
+	    get dataSource() {
+	        return this.get_dataSource();
+	    }
+	    get_dataSource() {
+	        return this._dataSource;
+	    }
+	    set dataSource(value) {
+	        this.set_dataSource(value);
+	    }
+	    set_dataSource(value) {
+	        this._dataSource = value;
+	        for (var prop in this._dataSource) {
+	            if (prop in this && !(typeof (this[prop]) == 'function')) {
+	                this[prop] = this._dataSource[prop];
+	            }
+	        }
+	    }
+	    get top() {
+	        return this.get_top();
+	    }
+	    get_top() {
+	        return this._widget.top;
+	    }
+	    set top(value) {
+	        this.set_top(value);
+	    }
+	    set_top(value) {
+	        if (value != this._widget.top) {
+	            this._getWidget().top = value;
+	        }
+	    }
+	    get bottom() {
+	        return this.get_bottom();
+	    }
+	    get_bottom() {
+	        return this._widget.bottom;
+	    }
+	    set bottom(value) {
+	        this.set_bottom(value);
+	    }
+	    set_bottom(value) {
+	        if (value != this._widget.bottom) {
+	            this._getWidget().bottom = value;
+	        }
+	    }
+	    get left() {
+	        return this._widget.left;
+	    }
+	    set left(value) {
+	        if (value != this._widget.left) {
+	            this._getWidget().left = value;
+	        }
+	    }
+	    get right() {
+	        return this._widget.right;
+	    }
+	    set right(value) {
+	        if (value != this._widget.right) {
+	            this._getWidget().right = value;
+	        }
+	    }
+	    get centerX() {
+	        return this._widget.centerX;
+	    }
+	    set centerX(value) {
+	        if (value != this._widget.centerX) {
+	            this._getWidget().centerX = value;
+	        }
+	    }
+	    get centerY() {
+	        return this._widget.centerY;
+	    }
+	    set centerY(value) {
+	        if (value != this._widget.centerY) {
+	            this._getWidget().centerY = value;
+	        }
+	    }
+	    _sizeChanged() {
+	        if (!isNaN(this._anchorX))
+	            this.pivotX = this.anchorX * this.width;
+	        if (!isNaN(this._anchorY))
+	            this.pivotY = this.anchorY * this.height;
+	        this.event(Laya.Event.RESIZE);
+	        if (this._widget !== Widget.EMPTY)
+	            this._widget.resetLayout();
+	    }
+	    get tag() {
+	        return this._tag;
+	    }
+	    set tag(value) {
+	        this._tag = value;
+	    }
+	    get toolTip() {
+	        return this._toolTip;
+	    }
+	    set toolTip(value) {
+	        if (this._toolTip != value) {
+	            this._toolTip = value;
+	            if (value != null) {
+	                this.on(Laya.Event.MOUSE_OVER, this, this.onMouseOver);
+	                this.on(Laya.Event.MOUSE_OUT, this, this.onMouseOut);
+	            }
+	            else {
+	                this.off(Laya.Event.MOUSE_OVER, this, this.onMouseOver);
+	                this.off(Laya.Event.MOUSE_OUT, this, this.onMouseOut);
+	            }
+	        }
+	    }
+	    onMouseOver(e) {
+	        Laya.ILaya.stage.event(UIEvent.SHOW_TIP, this._toolTip);
+	    }
+	    onMouseOut(e) {
+	        Laya.ILaya.stage.event(UIEvent.HIDE_TIP, this._toolTip);
+	    }
+	    get gray() {
+	        return this._gray;
+	    }
+	    set gray(value) {
+	        if (value !== this._gray) {
+	            this._gray = value;
+	            UIUtils.gray(this, value);
+	        }
+	    }
+	    get disabled() {
+	        return this._disabled;
+	    }
+	    set disabled(value) {
+	        if (value !== this._disabled) {
+	            this.gray = this._disabled = value;
+	            this.mouseEnabled = !value;
+	        }
+	    }
+	    _getWidget() {
+	        this._widget === Widget.EMPTY && (this._widget = this.addComponent(Widget));
+	        return this._widget;
+	    }
+	    set scaleX(value) {
+	        this.set_scaleX(value);
+	    }
+	    set_scaleX(value) {
+	        if (super.get_scaleX() == value)
+	            return;
+	        super.set_scaleX(value);
+	        this.event(Laya.Event.RESIZE);
+	    }
+	    get scaleX() {
+	        return super.scaleX;
+	    }
+	    set scaleY(value) {
+	        this.set_scaleY(value);
+	    }
+	    set_scaleY(value) {
+	        if (super.get_scaleY() == value)
+	            return;
+	        super.set_scaleY(value);
+	        this.event(Laya.Event.RESIZE);
+	    }
+	    get scaleY() {
+	        return super.scaleY;
+	    }
+	    onCompResize() {
+	        this._sizeChanged();
+	    }
+	    set width(value) {
+	        this.set_width(value);
+	    }
+	    set_width(value) {
+	        if (super.get_width() == value)
+	            return;
+	        super.set_width(value);
+	        this.callLater(this._sizeChanged);
+	    }
+	    set height(value) {
+	        this.set_height(value);
+	    }
+	    set_height(value) {
+	        if (super.get_height() == value)
+	            return;
+	        super.set_height(value);
+	        this.callLater(this._sizeChanged);
+	    }
+	    get anchorX() {
+	        return this.get_anchorX();
+	    }
+	    get_anchorX() {
+	        return this._anchorX;
+	    }
+	    set anchorX(value) {
+	        this.set_anchorX(value);
+	    }
+	    set_anchorX(value) {
+	        if (this._anchorX != value) {
+	            this._anchorX = value;
+	            this.callLater(this._sizeChanged);
+	        }
+	    }
+	    get anchorY() {
+	        return this.get_anchorY();
+	    }
+	    get_anchorY() {
+	        return this._anchorY;
+	    }
+	    set anchorY(value) {
+	        this.set_anchorY(value);
+	    }
+	    set_anchorY(value) {
+	        if (this._anchorY != value) {
+	            this._anchorY = value;
+	            this.callLater(this._sizeChanged);
+	        }
+	    }
+	    _childChanged(child = null) {
+	        this.callLater(this._sizeChanged);
+	        super._childChanged(child);
+	    }
+	}
+	Laya.ILaya.regClass(UIComponent);
+	Laya.ClassUtils.regClass("laya.ui.UIComponent", UIComponent);
+	Laya.ClassUtils.regClass("Laya.UIComponent", UIComponent);
+
+	class Image extends UIComponent {
+	    constructor(skin = null) {
+	        super();
+	        this.skin = skin;
+	    }
+	    destroy(destroyChild = true) {
+	        super.destroy(true);
+	        this._bitmap && this._bitmap.destroy();
+	        this._bitmap = null;
+	    }
+	    dispose() {
+	        this.destroy(true);
+	        Laya.ILaya.loader.clearRes(this._skin);
+	    }
+	    createChildren() {
+	        this.graphics = this._bitmap = new AutoBitmap();
+	        this._bitmap.autoCacheCmd = false;
+	    }
+	    get skin() {
+	        return this._skin;
+	    }
+	    set skin(value) {
+	        if (this._skin != value) {
+	            this._skin = value;
+	            if (value) {
+	                var source = Laya.Loader.getRes(value);
+	                if (source) {
+	                    this.source = source;
+	                    this.onCompResize();
+	                }
+	                else
+	                    Laya.ILaya.loader.load(this._skin, Laya.Handler.create(this, this.setSource, [this._skin]), null, Laya.Loader.IMAGE, 1, true, this._group);
+	            }
+	            else {
+	                this.source = null;
+	            }
+	        }
+	    }
+	    get source() {
+	        return this._bitmap.source;
+	    }
+	    set source(value) {
+	        if (!this._bitmap)
+	            return;
+	        this._bitmap.source = value;
+	        this.event(Laya.Event.LOADED);
+	        this.repaint();
+	    }
+	    get group() {
+	        return this._group;
+	    }
+	    set group(value) {
+	        if (value && this._skin)
+	            Laya.Loader.setGroup(this._skin, value);
+	        this._group = value;
+	    }
+	    setSource(url, img = null) {
+	        if (url === this._skin && img) {
+	            this.source = img;
+	            this.onCompResize();
+	        }
+	    }
+	    measureWidth() {
+	        return this._bitmap.width;
+	    }
+	    measureHeight() {
+	        return this._bitmap.height;
+	    }
+	    set width(value) {
+	        super.width = value;
+	        this._bitmap.width = value == 0 ? 0.0000001 : value;
+	    }
+	    get width() {
+	        return super.width;
+	    }
+	    set height(value) {
+	        super.height = value;
+	        this._bitmap.height = value == 0 ? 0.0000001 : value;
+	    }
+	    get height() {
+	        return super.height;
+	    }
+	    get sizeGrid() {
+	        if (this._bitmap.sizeGrid)
+	            return this._bitmap.sizeGrid.join(",");
+	        return null;
+	    }
+	    set sizeGrid(value) {
+	        this._bitmap.sizeGrid = UIUtils.fillArray(Styles.defaultSizeGrid, value, Number);
+	    }
+	    set dataSource(value) {
+	        this._dataSource = value;
+	        if (typeof (value) == 'string')
+	            this.skin = value;
+	        else
+	            super.dataSource = value;
+	    }
+	    get dataSource() {
+	        return super.dataSource;
+	    }
+	}
+	Laya.ILaya.regClass(Image);
+	Laya.ClassUtils.regClass("laya.ui.Image", Image);
+	Laya.ClassUtils.regClass("Laya.Image", Image);
+
+	class AdvImage extends Image {
+	    constructor(skin = null) {
+	        super();
+	        this.advsListArr = [];
+	        this.resUrl = "https://unioncdn.layabox.com/config/iconlist.json";
+	        this._http = new Laya.Browser.window.XMLHttpRequest();
+	        this._data = [];
+	        this._resquestTime = 360000;
+	        this._playIndex = 0;
+	        this._lunboTime = 5000;
+	        this.skin = skin;
+	        this.setLoadUrl();
+	        this.init();
+	        this.size(120, 120);
+	    }
+	    setLoadUrl() {
+	    }
+	    init() {
+	        if (this.isSupportJump()) {
+	            if (Laya.Browser.onMiniGame || Laya.Browser.onBDMiniGame) {
+	                Laya.ILaya.timer.loop(this._resquestTime, this, this.onGetAdvsListData);
+	            }
+	            this.onGetAdvsListData();
+	            this.initEvent();
+	        }
+	        else
+	            this.visible = false;
+	    }
+	    initEvent() {
+	        this.on(Laya.Event.CLICK, this, this.onAdvsImgClick);
+	    }
+	    onAdvsImgClick() {
+	        var currentJumpUrl = this.getCurrentAppidObj();
+	        if (currentJumpUrl)
+	            this.jumptoGame();
+	    }
+	    revertAdvsData() {
+	        if (this.advsListArr[this._playIndex]) {
+	            this.visible = true;
+	            this.skin = this.advsListArr[this._playIndex];
+	        }
+	    }
+	    isSupportJump() {
+	        if (Laya.Browser.onMiniGame) {
+	            var isSupperJump = window.wx.navigateToMiniProgram instanceof Function;
+	            return isSupperJump;
+	        }
+	        else if (Laya.Browser.onBDMiniGame)
+	            return true;
+	        return false;
+	    }
+	    jumptoGame() {
+	        var advsObj = this.advsListArr[this._playIndex];
+	        var desGameId = parseInt(advsObj.gameid);
+	        var extendInfo = advsObj.extendInfo;
+	        var path = advsObj.path;
+	        if (Laya.Browser.onMiniGame) {
+	            if (this.isSupportJump()) {
+	                window.wx.navigateToMiniProgram({
+	                    appId: this._appid,
+	                    path: "",
+	                    extraData: "",
+	                    envVersion: "release",
+	                    success: function success() {
+	                        console.log("-------------跳转成功--------------");
+	                    },
+	                    fail: function fail() {
+	                        console.log("-------------跳转失败--------------");
+	                    },
+	                    complete: function complete() {
+	                        console.log("-------------跳转接口调用成功--------------");
+	                        this.updateAdvsInfo();
+	                    }.bind(this)
+	                });
+	            }
+	        }
+	        else if (Laya.Browser.onBDMiniGame) ;
+	        else {
+	            this.visible = false;
+	        }
+	    }
+	    updateAdvsInfo() {
+	        this.visible = false;
+	        this.onLunbo();
+	        Laya.ILaya.timer.loop(this._lunboTime, this, this.onLunbo);
+	    }
+	    onLunbo() {
+	        if (this._playIndex >= this.advsListArr.length - 1)
+	            this._playIndex = 0;
+	        else
+	            this._playIndex += 1;
+	        this.visible = true;
+	        this.revertAdvsData();
+	    }
+	    getCurrentAppidObj() {
+	        return this.advsListArr[this._playIndex];
+	    }
+	    onGetAdvsListData() {
+	        var _this = this;
+	        var random = AdvImage.randRange(10000, 1000000);
+	        var url = this.resUrl + "?" + random;
+	        this._http.open("get", url, true);
+	        this._http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+	        this._http.responseType = "text";
+	        this._http.onerror = function (e) {
+	            _this._onError(e);
+	        };
+	        this._http.onload = function (e) {
+	            _this._onLoad(e);
+	        };
+	        this._http.send(null);
+	    }
+	    static randRange(minNum, maxNum) {
+	        return (Math.floor(Math.random() * (maxNum - minNum + 1)) + minNum);
+	    }
+	    _onError(e) {
+	        this.error("Request failed Status:" + this._http.status + " text:" + this._http.statusText);
+	    }
+	    _onLoad(e) {
+	        var http = this._http;
+	        var status = http.status !== undefined ? http.status : 200;
+	        if (status === 200 || status === 204 || status === 0) {
+	            this.complete();
+	        }
+	        else {
+	            this.error("[" + http.status + "]" + http.statusText + ":" + http.responseURL);
+	        }
+	    }
+	    error(message) {
+	        this.event(Laya.Event.ERROR, message);
+	    }
+	    complete() {
+	        try {
+	            this._data = this._http.response || this._http.responseText;
+	            this._data = JSON.parse(this._data);
+	            this.advsListArr = this._data.list;
+	            this._appid = this._data.appid;
+	            this.updateAdvsInfo();
+	            this.revertAdvsData();
+	        }
+	        catch (e) {
+	            this.error(e.message);
+	        }
+	    }
+	    getAdvsQArr(data) {
+	        var tempArr = [];
+	        var gameAdvsObj = Laya.LocalStorage.getJSON("gameObj");
+	        for (var key in data) {
+	            var tempObj = data[key];
+	            if (gameAdvsObj && gameAdvsObj[tempObj.gameid] && !tempObj.isQiangZhi)
+	                continue;
+	            tempArr.push(tempObj);
+	        }
+	        return tempArr;
+	    }
+	    clear() {
+	        var http = this._http;
+	        http.onerror = http.onabort = http.onprogress = http.onload = null;
+	    }
+	    destroy(destroyChild = true) {
+	        Laya.ILaya.timer.clear(this, this.onLunbo);
+	        super.destroy(true);
+	        this.clear();
+	        Laya.ILaya.timer.clear(this, this.onGetAdvsListData);
+	    }
+	}
+	Laya.ClassUtils.regClass("laya.ui.AdvImage", AdvImage);
+	Laya.ClassUtils.regClass("Laya.AdvImage", AdvImage);
+
+	class Box extends UIComponent {
+	    set dataSource(value) {
+	        this._dataSource = value;
+	        for (var name in value) {
+	            var comp = this.getChildByName(name);
+	            if (comp)
+	                comp.dataSource = value[name];
+	            else if (name in this && !(this[name] instanceof Function))
+	                this[name] = value[name];
+	        }
+	    }
+	    get dataSource() {
+	        return super.dataSource;
+	    }
+	    get bgColor() {
+	        return this._bgColor;
+	    }
+	    set bgColor(value) {
+	        this._bgColor = value;
+	        if (value) {
+	            this._onResize(null);
+	            this.on(Laya.Event.RESIZE, this, this._onResize);
+	        }
+	        else {
+	            this.graphics.clear();
+	            this.off(Laya.Event.RESIZE, this, this._onResize);
+	        }
+	    }
+	    _onResize(e) {
+	        this.graphics.clear();
+	        this.graphics.drawRect(0, 0, this.width, this.height, this._bgColor);
+	    }
+	}
+	Laya.ILaya.regClass(Box);
+	Laya.ClassUtils.regClass("laya.ui.Box", Box);
+	Laya.ClassUtils.regClass("Laya.Box", Box);
+
+	class Button extends UIComponent {
+	    constructor(skin = null, label = "") {
+	        super();
+	        this._labelColors = Styles.buttonLabelColors;
+	        this._state = 0;
+	        this._autoSize = true;
+	        this._stateNum = Styles.buttonStateNum;
+	        this._stateChanged = false;
+	        this.skin = skin;
+	        this.label = label;
+	    }
+	    destroy(destroyChild = true) {
+	        super.destroy(destroyChild);
+	        this._bitmap && this._bitmap.destroy();
+	        this._text && this._text.destroy(destroyChild);
+	        this._bitmap = null;
+	        this._text = null;
+	        this._clickHandler = null;
+	        this._labelColors = this._sources = this._strokeColors = null;
+	    }
+	    createChildren() {
+	        this.graphics = this._bitmap = new AutoBitmap();
+	    }
+	    createText() {
+	        if (!this._text) {
+	            this._text = new Laya.Text();
+	            this._text.overflow = Laya.Text.HIDDEN;
+	            this._text.align = "center";
+	            this._text.valign = "middle";
+	            this._text.width = this._width;
+	            this._text.height = this._height;
+	        }
+	    }
+	    initialize() {
+	        if (this._mouseState !== 1) {
+	            this.mouseEnabled = true;
+	            this._setBit(Laya.Const.HAS_MOUSE, true);
+	        }
+	        this._createListener(Laya.Event.MOUSE_OVER, this, this.onMouse, null, false, false);
+	        this._createListener(Laya.Event.MOUSE_OUT, this, this.onMouse, null, false, false);
+	        this._createListener(Laya.Event.MOUSE_DOWN, this, this.onMouse, null, false, false);
+	        this._createListener(Laya.Event.MOUSE_UP, this, this.onMouse, null, false, false);
+	        this._createListener(Laya.Event.CLICK, this, this.onMouse, null, false, false);
+	    }
+	    onMouse(e) {
+	        if (this.toggle === false && this._selected)
+	            return;
+	        if (e.type === Laya.Event.CLICK) {
+	            this.toggle && (this.selected = !this._selected);
+	            this._clickHandler && this._clickHandler.run();
+	            return;
+	        }
+	        !this._selected && (this.state = Button.stateMap[e.type]);
+	    }
+	    get skin() {
+	        return this._skin;
+	    }
+	    set skin(value) {
+	        if (this._skin != value) {
+	            this._skin = value;
+	            if (value) {
+	                if (!Laya.Loader.getRes(value)) {
+	                    Laya.ILaya.loader.load(this._skin, Laya.Handler.create(this, this._skinLoaded), null, Laya.Loader.IMAGE, 1);
+	                }
+	                else {
+	                    this._skinLoaded();
+	                }
+	            }
+	            else {
+	                this._skinLoaded();
+	            }
+	        }
+	    }
+	    _skinLoaded() {
+	        this.callLater(this.changeClips);
+	        this._setStateChanged();
+	        this._sizeChanged();
+	        this.event(Laya.Event.LOADED);
+	    }
+	    get stateNum() {
+	        return this._stateNum;
+	    }
+	    set stateNum(value) {
+	        if (typeof value == 'string') {
+	            value = parseInt(value);
+	        }
+	        if (this._stateNum != value) {
+	            this._stateNum = value < 1 ? 1 : value > 3 ? 3 : value;
+	            this.callLater(this.changeClips);
+	        }
+	    }
+	    changeClips() {
+	        var img = Laya.Loader.getRes(this._skin);
+	        if (!img) {
+	            console.log("lose skin", this._skin);
+	            return;
+	        }
+	        var width = img.sourceWidth;
+	        var height = img.sourceHeight / this._stateNum;
+	        img.$_GID || (img.$_GID = Laya.Utils.getGID());
+	        var key = img.$_GID + "-" + this._stateNum;
+	        var clips = Laya.WeakObject.I.get(key);
+	        if (!Laya.Utils.isOkTextureList(clips)) {
+	            clips = null;
+	        }
+	        if (clips)
+	            this._sources = clips;
+	        else {
+	            this._sources = [];
+	            if (this._stateNum === 1) {
+	                this._sources.push(img);
+	            }
+	            else {
+	                for (var i = 0; i < this._stateNum; i++) {
+	                    this._sources.push(Laya.Texture.createFromTexture(img, 0, height * i, width, height));
+	                }
+	            }
+	            Laya.WeakObject.I.set(key, this._sources);
+	        }
+	        if (this._autoSize) {
+	            this._bitmap.width = this._width || width;
+	            this._bitmap.height = this._height || height;
+	            if (this._text) {
+	                this._text.width = this._bitmap.width;
+	                this._text.height = this._bitmap.height;
+	            }
+	        }
+	        else {
+	            this._text && (this._text.x = width);
+	        }
+	    }
+	    measureWidth() {
+	        this.runCallLater(this.changeClips);
+	        if (this._autoSize)
+	            return this._bitmap.width;
+	        this.runCallLater(this.changeState);
+	        return this._bitmap.width + (this._text ? this._text.width : 0);
+	    }
+	    measureHeight() {
+	        this.runCallLater(this.changeClips);
+	        return this._text ? Math.max(this._bitmap.height, this._text.height) : this._bitmap.height;
+	    }
+	    get label() {
+	        return this._text ? this._text.text : null;
+	    }
+	    set label(value) {
+	        if (!this._text && !value)
+	            return;
+	        this.createText();
+	        if (this._text.text != value) {
+	            value && !this._text.parent && this.addChild(this._text);
+	            this._text.text = (value + "").replace(/\\n/g, "\n");
+	            this._setStateChanged();
+	        }
+	    }
+	    get selected() {
+	        return this._selected;
+	    }
+	    set selected(value) {
+	        if (this._selected != value) {
+	            this._selected = value;
+	            this.state = this._selected ? 2 : 0;
+	            this.event(Laya.Event.CHANGE);
+	        }
+	    }
+	    get state() {
+	        return this._state;
+	    }
+	    set state(value) {
+	        if (this._state != value) {
+	            this._state = value;
+	            this._setStateChanged();
+	        }
+	    }
+	    changeState() {
+	        this._stateChanged = false;
+	        this.runCallLater(this.changeClips);
+	        var index = this._state < this._stateNum ? this._state : this._stateNum - 1;
+	        this._sources && (this._bitmap.source = this._sources[index]);
+	        if (this.label) {
+	            this._text.color = this._labelColors[index];
+	            if (this._strokeColors)
+	                this._text.strokeColor = this._strokeColors[index];
+	        }
+	    }
+	    get labelColors() {
+	        return this._labelColors.join(",");
+	    }
+	    set labelColors(value) {
+	        this._labelColors = UIUtils.fillArray(Styles.buttonLabelColors, value, String);
+	        this._setStateChanged();
+	    }
+	    get strokeColors() {
+	        return this._strokeColors ? this._strokeColors.join(",") : "";
+	    }
+	    set strokeColors(value) {
+	        this._strokeColors = UIUtils.fillArray(Styles.buttonLabelColors, value, String);
+	        this._setStateChanged();
+	    }
+	    get labelPadding() {
+	        this.createText();
+	        return this._text.padding.join(",");
+	    }
+	    set labelPadding(value) {
+	        this.createText();
+	        this._text.padding = UIUtils.fillArray(Styles.labelPadding, value, Number);
+	    }
+	    get labelSize() {
+	        this.createText();
+	        return this._text.fontSize;
+	    }
+	    set labelSize(value) {
+	        this.createText();
+	        this._text.fontSize = value;
+	    }
+	    get labelStroke() {
+	        this.createText();
+	        return this._text.stroke;
+	    }
+	    set labelStroke(value) {
+	        this.createText();
+	        this._text.stroke = value;
+	    }
+	    get labelStrokeColor() {
+	        this.createText();
+	        return this._text.strokeColor;
+	    }
+	    set labelStrokeColor(value) {
+	        this.createText();
+	        this._text.strokeColor = value;
+	    }
+	    get labelBold() {
+	        this.createText();
+	        return this._text.bold;
+	    }
+	    set labelBold(value) {
+	        this.createText();
+	        this._text.bold = value;
+	    }
+	    get labelFont() {
+	        this.createText();
+	        return this._text.font;
+	    }
+	    set labelFont(value) {
+	        this.createText();
+	        this._text.font = value;
+	    }
+	    get labelAlign() {
+	        this.createText();
+	        return this._text.align;
+	    }
+	    set labelAlign(value) {
+	        this.createText();
+	        this._text.align = value;
+	    }
+	    get clickHandler() {
+	        return this._clickHandler;
+	    }
+	    set clickHandler(value) {
+	        this._clickHandler = value;
+	    }
+	    get text() {
+	        this.createText();
+	        return this._text;
+	    }
+	    get sizeGrid() {
+	        if (this._bitmap.sizeGrid)
+	            return this._bitmap.sizeGrid.join(",");
+	        return null;
+	    }
+	    set sizeGrid(value) {
+	        this._bitmap.sizeGrid = UIUtils.fillArray(Styles.defaultSizeGrid, value, Number);
+	    }
+	    set width(value) {
+	        super.set_width(value);
+	        if (this._autoSize) {
+	            this._bitmap.width = value;
+	            this._text && (this._text.width = value);
+	        }
+	    }
+	    get width() {
+	        return super.get_width();
+	    }
+	    set height(value) {
+	        super.set_height(value);
+	        if (this._autoSize) {
+	            this._bitmap.height = value;
+	            this._text && (this._text.height = value);
+	        }
+	    }
+	    get height() {
+	        return super.get_height();
+	    }
+	    set dataSource(value) {
+	        this._dataSource = value;
+	        if (typeof (value) == 'number' || typeof (value) == 'string')
+	            this.label = value + "";
+	        else
+	            super.set_dataSource(value);
+	    }
+	    get dataSource() {
+	        return super.get_dataSource();
+	    }
+	    get iconOffset() {
+	        return this._bitmap._offset ? this._bitmap._offset.join(",") : null;
+	    }
+	    set iconOffset(value) {
+	        if (value)
+	            this._bitmap._offset = UIUtils.fillArray([1, 1], value, Number);
+	        else
+	            this._bitmap._offset = [];
+	    }
+	    _setStateChanged() {
+	        if (!this._stateChanged) {
+	            this._stateChanged = true;
+	            this.callLater(this.changeState);
+	        }
+	    }
+	}
+	Button.stateMap = { "mouseup": 0, "mouseover": 1, "mousedown": 2, "mouseout": 0 };
+	Laya.ILaya.regClass(Button);
+	Laya.ClassUtils.regClass("laya.ui.Button", Button);
+	Laya.ClassUtils.regClass("Laya.Button", Button);
+
+	class CheckBox extends Button {
+	    constructor(skin = null, label = "") {
+	        super(skin, label);
+	        this.toggle = true;
+	        this._autoSize = false;
+	    }
+	    preinitialize() {
+	        super.preinitialize();
+	        this.toggle = true;
+	        this._autoSize = false;
+	    }
+	    initialize() {
+	        super.initialize();
+	        this.createText();
+	        this._text.align = "left";
+	        this._text.valign = "top";
+	        this._text.width = 0;
+	    }
+	    set dataSource(value) {
+	        this._dataSource = value;
+	        if (value instanceof Boolean)
+	            this.selected = value;
+	        else if (typeof (value) == 'string')
+	            this.selected = value === "true";
+	        else
+	            super.dataSource = value;
+	    }
+	    get dataSource() {
+	        return super.dataSource;
+	    }
+	}
+	Laya.ILaya.regClass(CheckBox);
+	Laya.ClassUtils.regClass("laya.ui.CheckBox", CheckBox);
+	Laya.ClassUtils.regClass("Laya.CheckBox", CheckBox);
+
+	class Clip extends UIComponent {
+	    constructor(url = null, clipX = 1, clipY = 1) {
+	        super();
+	        this._clipX = 1;
+	        this._clipY = 1;
+	        this._clipWidth = 0;
+	        this._clipHeight = 0;
+	        this._interval = 50;
+	        this._index = 0;
+	        this._toIndex = -1;
+	        this._clipX = clipX;
+	        this._clipY = clipY;
+	        this.skin = url;
+	    }
+	    destroy(destroyChild = true) {
+	        super.destroy(true);
+	        this._bitmap && this._bitmap.destroy();
+	        this._bitmap = null;
+	        this._sources = null;
+	    }
+	    dispose() {
+	        this.destroy(true);
+	        Laya.ILaya.loader.clearRes(this._skin);
+	    }
+	    createChildren() {
+	        this.graphics = this._bitmap = new AutoBitmap();
+	    }
+	    _onDisplay(e) {
+	        if (this._isPlaying) {
+	            if (this._getBit(Laya.Const.DISPLAYED_INSTAGE))
+	                this.play();
+	            else
+	                this.stop();
+	        }
+	        else if (this._autoPlay) {
+	            this.play();
+	        }
+	    }
+	    get skin() {
+	        return this._skin;
+	    }
+	    set skin(value) {
+	        if (this._skin != value) {
+	            this._skin = value;
+	            if (value) {
+	                if (!Laya.Loader.getRes(value)) {
+	                    Laya.ILaya.loader.load(this._skin, Laya.Handler.create(this, this._skinLoaded), null, Laya.Loader.IMAGE, 1);
+	                }
+	                else {
+	                    this._skinLoaded();
+	                }
+	            }
+	            else {
+	                this._bitmap.source = null;
+	            }
+	        }
+	    }
+	    _skinLoaded() {
+	        this._setClipChanged();
+	        this._sizeChanged();
+	        this.event(Laya.Event.LOADED);
+	    }
+	    get clipX() {
+	        return this._clipX;
+	    }
+	    set clipX(value) {
+	        this._clipX = value || 1;
+	        this._setClipChanged();
+	    }
+	    get clipY() {
+	        return this._clipY;
+	    }
+	    set clipY(value) {
+	        this._clipY = value || 1;
+	        this._setClipChanged();
+	    }
+	    get clipWidth() {
+	        return this._clipWidth;
+	    }
+	    set clipWidth(value) {
+	        this._clipWidth = value;
+	        this._setClipChanged();
+	    }
+	    get clipHeight() {
+	        return this._clipHeight;
+	    }
+	    set clipHeight(value) {
+	        this._clipHeight = value;
+	        this._setClipChanged();
+	    }
+	    changeClip() {
+	        this._clipChanged = false;
+	        if (!this._skin)
+	            return;
+	        var img = Laya.Loader.getRes(this._skin);
+	        if (img) {
+	            this.loadComplete(this._skin, img);
+	        }
+	        else {
+	            Laya.ILaya.loader.load(this._skin, Laya.Handler.create(this, this.loadComplete, [this._skin]));
+	        }
+	    }
+	    loadComplete(url, img) {
+	        if (url === this._skin && img) {
+	            var w = this._clipWidth || Math.ceil(img.sourceWidth / this._clipX);
+	            var h = this._clipHeight || Math.ceil(img.sourceHeight / this._clipY);
+	            var key = this._skin + w + h;
+	            var clips = Laya.WeakObject.I.get(key);
+	            if (!Laya.Utils.isOkTextureList(clips)) {
+	                clips = null;
+	            }
+	            if (clips)
+	                this._sources = clips;
+	            else {
+	                this._sources = [];
+	                for (var i = 0; i < this._clipY; i++) {
+	                    for (var j = 0; j < this._clipX; j++) {
+	                        this._sources.push(Laya.Texture.createFromTexture(img, w * j, h * i, w, h));
+	                    }
+	                }
+	                Laya.WeakObject.I.set(key, this._sources);
+	            }
+	            this.index = this._index;
+	            this.event(Laya.Event.LOADED);
+	            this.onCompResize();
+	        }
+	    }
+	    get sources() {
+	        return this._sources;
+	    }
+	    set sources(value) {
+	        this._sources = value;
+	        this.index = this._index;
+	        this.event(Laya.Event.LOADED);
+	    }
+	    get group() {
+	        return this._group;
+	    }
+	    set group(value) {
+	        if (value && this._skin)
+	            Laya.Loader.setGroup(this._skin, value);
+	        this._group = value;
+	    }
+	    set width(value) {
+	        super.width = value;
+	        this._bitmap.width = value;
+	    }
+	    get width() {
+	        return super.width;
+	    }
+	    set height(value) {
+	        super.height = value;
+	        this._bitmap.height = value;
+	    }
+	    get height() {
+	        return super.height;
+	    }
+	    measureWidth() {
+	        this.runCallLater(this.changeClip);
+	        return this._bitmap.width;
+	    }
+	    measureHeight() {
+	        this.runCallLater(this.changeClip);
+	        return this._bitmap.height;
+	    }
+	    get sizeGrid() {
+	        if (this._bitmap.sizeGrid)
+	            return this._bitmap.sizeGrid.join(",");
+	        return null;
+	    }
+	    set sizeGrid(value) {
+	        this._bitmap.sizeGrid = UIUtils.fillArray(Styles.defaultSizeGrid, value, Number);
+	    }
+	    get index() {
+	        return this._index;
+	    }
+	    set index(value) {
+	        this._index = value;
+	        this._bitmap && this._sources && (this._bitmap.source = this._sources[value]);
+	        this.event(Laya.Event.CHANGE);
+	    }
+	    get total() {
+	        this.runCallLater(this.changeClip);
+	        return this._sources ? this._sources.length : 0;
+	    }
+	    get autoPlay() {
+	        return this._autoPlay;
+	    }
+	    set autoPlay(value) {
+	        if (this._autoPlay != value) {
+	            this._autoPlay = value;
+	            value ? this.play() : this.stop();
+	        }
+	    }
+	    get interval() {
+	        return this._interval;
+	    }
+	    set interval(value) {
+	        if (this._interval != value) {
+	            this._interval = value;
+	            if (this._isPlaying)
+	                this.play();
+	        }
+	    }
+	    get isPlaying() {
+	        return this._isPlaying;
+	    }
+	    set isPlaying(value) {
+	        this._isPlaying = value;
+	    }
+	    play(from = 0, to = -1) {
+	        this._isPlaying = true;
+	        this.index = from;
+	        this._toIndex = to;
+	        this._index++;
+	        Laya.ILaya.timer.loop(this.interval, this, this._loop);
+	        this.on(Laya.Event.DISPLAY, this, this._onDisplay);
+	        this.on(Laya.Event.UNDISPLAY, this, this._onDisplay);
+	    }
+	    _loop() {
+	        if (this._visible && this._sources) {
+	            this._index++;
+	            if (this._toIndex > -1 && this._index >= this._toIndex)
+	                this.stop();
+	            else if (this._index >= this._sources.length)
+	                this._index = 0;
+	            this.index = this._index;
+	        }
+	    }
+	    stop() {
+	        this._isPlaying = false;
+	        Laya.ILaya.timer.clear(this, this._loop);
+	        this.event(Laya.Event.COMPLETE);
+	    }
+	    set dataSource(value) {
+	        this._dataSource = value;
+	        if (typeof (value) == 'number' || typeof (value) == 'string')
+	            this.index = parseInt(value);
+	        else
+	            super.dataSource = value;
+	    }
+	    get dataSource() {
+	        return super.dataSource;
+	    }
+	    get bitmap() {
+	        return this._bitmap;
+	    }
+	    _setClipChanged() {
+	        if (!this._clipChanged) {
+	            this._clipChanged = true;
+	            this.callLater(this.changeClip);
+	        }
+	    }
+	}
+	Laya.ILaya.regClass(Clip);
+	Laya.ClassUtils.regClass("laya.ui.Clip", Clip);
+	Laya.ClassUtils.regClass("Laya.Clip", Clip);
+
+	class ColorPicker extends UIComponent {
+	    constructor() {
+	        super(...arguments);
+	        this._gridSize = 11;
+	        this._bgColor = "#ffffff";
+	        this._borderColor = "#000000";
+	        this._inputColor = "#000000";
+	        this._inputBgColor = "#efefef";
+	        this._colors = [];
+	        this._selectedColor = "#000000";
+	    }
+	    destroy(destroyChild = true) {
+	        super.destroy(destroyChild);
+	        this._colorPanel && this._colorPanel.destroy(destroyChild);
+	        this._colorButton && this._colorButton.destroy(destroyChild);
+	        this._colorPanel = null;
+	        this._colorTiles = null;
+	        this._colorBlock = null;
+	        this._colorInput = null;
+	        this._colorButton = null;
+	        this._colors = null;
+	        this.changeHandler = null;
+	    }
+	    createChildren() {
+	        this.addChild(this._colorButton = new Button());
+	        this._colorPanel = new Box();
+	        this._colorPanel.size(230, 166);
+	        this._colorPanel.addChild(this._colorTiles = new Laya.Sprite());
+	        this._colorPanel.addChild(this._colorBlock = new Laya.Sprite());
+	        this._colorPanel.addChild(this._colorInput = new Laya.Input());
+	    }
+	    initialize() {
+	        this._colorButton.on(Laya.Event.CLICK, this, this.onColorButtonClick);
+	        this._colorBlock.pos(5, 5);
+	        this._colorInput.pos(60, 5);
+	        this._colorInput.size(60, 20);
+	        this._colorInput.on(Laya.Event.CHANGE, this, this.onColorInputChange);
+	        this._colorInput.on(Laya.Event.KEY_DOWN, this, this.onColorFieldKeyDown);
+	        this._colorTiles.pos(5, 30);
+	        this._colorTiles.on(Laya.Event.MOUSE_MOVE, this, this.onColorTilesMouseMove);
+	        this._colorTiles.on(Laya.Event.CLICK, this, this.onColorTilesClick);
+	        this._colorTiles.size(20 * this._gridSize, 12 * this._gridSize);
+	        this._colorPanel.on(Laya.Event.MOUSE_DOWN, this, this.onPanelMouseDown);
+	        this.bgColor = this._bgColor;
+	    }
+	    onPanelMouseDown(e) {
+	        e.stopPropagation();
+	    }
+	    changePanel() {
+	        this._panelChanged = false;
+	        var g = this._colorPanel.graphics;
+	        g.clear(true);
+	        g.drawRect(0, 0, 230, 166, this._bgColor, this._borderColor);
+	        this.drawBlock(this._selectedColor);
+	        this._colorInput.borderColor = this._borderColor;
+	        this._colorInput.bgColor = this._inputBgColor;
+	        this._colorInput.color = this._inputColor;
+	        g = this._colorTiles.graphics;
+	        g.clear(true);
+	        var mainColors = [0x000000, 0x333333, 0x666666, 0x999999, 0xCCCCCC, 0xFFFFFF, 0xFF0000, 0x00FF00, 0x0000FF, 0xFFFF00, 0x00FFFF, 0xFF00FF];
+	        for (var i = 0; i < 12; i++) {
+	            for (var j = 0; j < 20; j++) {
+	                var color;
+	                if (j === 0)
+	                    color = mainColors[i];
+	                else if (j === 1)
+	                    color = 0x000000;
+	                else
+	                    color = (((i * 3 + j / 6) % 3 << 0) + ((i / 6) << 0) * 3) * 0x33 << 16 | j % 6 * 0x33 << 8 | (i << 0) % 6 * 0x33;
+	                var strColor = UIUtils.toColor(color);
+	                this._colors.push(strColor);
+	                var x = j * this._gridSize;
+	                var y = i * this._gridSize;
+	                g.drawRect(x, y, this._gridSize, this._gridSize, strColor, "#000000");
+	            }
+	        }
+	    }
+	    onColorButtonClick(e) {
+	        if (this._colorPanel.parent)
+	            this.close();
+	        else
+	            this.open();
+	    }
+	    open() {
+	        let stage = Laya.ILaya.stage;
+	        var p = this.localToGlobal(new Laya.Point());
+	        var px = p.x + this._colorPanel.width <= stage.width ? p.x : stage.width - this._colorPanel.width;
+	        var py = p.y + this._colorButton.height;
+	        py = py + this._colorPanel.height <= stage.height ? py : p.y - this._colorPanel.height;
+	        this._colorPanel.pos(px, py);
+	        this._colorPanel.zOrder = 1001;
+	        stage.addChild(this._colorPanel);
+	        stage.on(Laya.Event.MOUSE_DOWN, this, this.removeColorBox);
+	    }
+	    close() {
+	        Laya.ILaya.stage.off(Laya.Event.MOUSE_DOWN, this, this.removeColorBox);
+	        this._colorPanel.removeSelf();
+	    }
+	    removeColorBox(e = null) {
+	        this.close();
+	    }
+	    onColorFieldKeyDown(e) {
+	        if (e.keyCode == 13) {
+	            if (this._colorInput.text)
+	                this.selectedColor = this._colorInput.text;
+	            else
+	                this.selectedColor = null;
+	            this.close();
+	            e.stopPropagation();
+	        }
+	    }
+	    onColorInputChange(e = null) {
+	        if (this._colorInput.text)
+	            this.drawBlock(this._colorInput.text);
+	        else
+	            this.drawBlock("#FFFFFF");
+	    }
+	    onColorTilesClick(e) {
+	        this.selectedColor = this.getColorByMouse();
+	        this.close();
+	    }
+	    onColorTilesMouseMove(e) {
+	        this._colorInput.focus = false;
+	        var color = this.getColorByMouse();
+	        this._colorInput.text = color;
+	        this.drawBlock(color);
+	    }
+	    getColorByMouse() {
+	        var point = this._colorTiles.getMousePoint();
+	        var x = Math.floor(point.x / this._gridSize);
+	        var y = Math.floor(point.y / this._gridSize);
+	        return this._colors[y * 20 + x];
+	    }
+	    drawBlock(color) {
+	        var g = this._colorBlock.graphics;
+	        g.clear(true);
+	        var showColor = color ? color : "#ffffff";
+	        g.drawRect(0, 0, 50, 20, showColor, this._borderColor);
+	        color || g.drawLine(0, 0, 50, 20, "#ff0000");
+	    }
+	    get selectedColor() {
+	        return this._selectedColor;
+	    }
+	    set selectedColor(value) {
+	        if (this._selectedColor != value) {
+	            this._selectedColor = this._colorInput.text = value;
+	            this.drawBlock(value);
+	            this.changeColor();
+	            this.changeHandler && this.changeHandler.runWith(this._selectedColor);
+	            this.event(Laya.Event.CHANGE, Laya.Event.EMPTY.setTo(Laya.Event.CHANGE, this, this));
+	        }
+	    }
+	    get skin() {
+	        return this._colorButton.skin;
+	    }
+	    set skin(value) {
+	        this._colorButton.once(Laya.Event.LOADED, this, this.changeColor);
+	        this._colorButton.skin = value;
+	    }
+	    changeColor() {
+	        var g = this.graphics;
+	        g.clear(true);
+	        var showColor = this._selectedColor || "#000000";
+	        g.drawRect(0, 0, this._colorButton.width, this._colorButton.height, showColor);
+	    }
+	    get bgColor() {
+	        return this._bgColor;
+	    }
+	    set bgColor(value) {
+	        this._bgColor = value;
+	        this._setPanelChanged();
+	    }
+	    get borderColor() {
+	        return this._borderColor;
+	    }
+	    set borderColor(value) {
+	        this._borderColor = value;
+	        this._setPanelChanged();
+	    }
+	    get inputColor() {
+	        return this._inputColor;
+	    }
+	    set inputColor(value) {
+	        this._inputColor = value;
+	        this._setPanelChanged();
+	    }
+	    get inputBgColor() {
+	        return this._inputBgColor;
+	    }
+	    set inputBgColor(value) {
+	        this._inputBgColor = value;
+	        this._setPanelChanged();
+	    }
+	    _setPanelChanged() {
+	        if (!this._panelChanged) {
+	            this._panelChanged = true;
+	            this.callLater(this.changePanel);
+	        }
+	    }
+	}
+	Laya.ILaya.regClass(ColorPicker);
+	Laya.ClassUtils.regClass("laya.ui.ColorPicker", ColorPicker);
+	Laya.ClassUtils.regClass("Laya.ColorPicker", ColorPicker);
+
+	class Label extends UIComponent {
+	    constructor(text = "") {
+	        super();
+	        this.text = text;
+	    }
+	    destroy(destroyChild = true) {
+	        super.destroy(destroyChild);
+	        this._tf = null;
+	    }
+	    createChildren() {
+	        this.addChild(this._tf = new Laya.Text());
+	    }
+	    get text() {
+	        return this._tf.text;
+	    }
+	    set text(value) {
+	        if (this._tf.text != value) {
+	            if (value)
+	                value = UIUtils.adptString(value + "");
+	            this._tf.text = value;
+	            this.event(Laya.Event.CHANGE);
+	            if (!this._width || !this._height)
+	                this.onCompResize();
+	        }
+	    }
+	    changeText(text) {
+	        this._tf.changeText(text);
+	    }
+	    get wordWrap() {
+	        return this._tf.wordWrap;
+	    }
+	    set wordWrap(value) {
+	        this._tf.wordWrap = value;
+	    }
+	    get color() {
+	        return this._tf.color;
+	    }
+	    set color(value) {
+	        this._tf.color = value;
+	    }
+	    get font() {
+	        return this._tf.font;
+	    }
+	    set font(value) {
+	        this._tf.font = value;
+	    }
+	    get align() {
+	        return this._tf.align;
+	    }
+	    set align(value) {
+	        this._tf.align = value;
+	    }
+	    get valign() {
+	        return this._tf.valign;
+	    }
+	    set valign(value) {
+	        this._tf.valign = value;
+	    }
+	    get bold() {
+	        return this._tf.bold;
+	    }
+	    set bold(value) {
+	        this._tf.bold = value;
+	    }
+	    get italic() {
+	        return this._tf.italic;
+	    }
+	    set italic(value) {
+	        this._tf.italic = value;
+	    }
+	    get leading() {
+	        return this._tf.leading;
+	    }
+	    set leading(value) {
+	        this._tf.leading = value;
+	    }
+	    get fontSize() {
+	        return this._tf.fontSize;
+	    }
+	    set fontSize(value) {
+	        this._tf.fontSize = value;
+	    }
+	    get padding() {
+	        return this._tf.padding.join(",");
+	    }
+	    set padding(value) {
+	        this._tf.padding = UIUtils.fillArray(Styles.labelPadding, value, Number);
+	    }
+	    get bgColor() {
+	        return this._tf.bgColor;
+	    }
+	    set bgColor(value) {
+	        this._tf.bgColor = value;
+	    }
+	    get borderColor() {
+	        return this._tf.borderColor;
+	    }
+	    set borderColor(value) {
+	        this._tf.borderColor = value;
+	    }
+	    get stroke() {
+	        return this._tf.stroke;
+	    }
+	    set stroke(value) {
+	        this._tf.stroke = value;
+	    }
+	    get strokeColor() {
+	        return this._tf.strokeColor;
+	    }
+	    set strokeColor(value) {
+	        this._tf.strokeColor = value;
+	    }
+	    get textField() {
+	        return this._tf;
+	    }
+	    measureWidth() {
+	        return this._tf.width;
+	    }
+	    measureHeight() {
+	        return this._tf.height;
+	    }
+	    get width() {
+	        if (this._width || this._tf.text)
+	            return super.width;
+	        return 0;
+	    }
+	    set width(value) {
+	        super.width = value;
+	        this._tf.width = value;
+	    }
+	    get height() {
+	        if (this._height || this._tf.text)
+	            return super.height;
+	        return 0;
+	    }
+	    set height(value) {
+	        super.height = value;
+	        this._tf.height = value;
+	    }
+	    set dataSource(value) {
+	        this._dataSource = value;
+	        if (typeof (value) == 'number' || typeof (value) == 'string')
+	            this.text = value + "";
+	        else
+	            super.dataSource = value;
+	    }
+	    get dataSource() {
+	        return super.dataSource;
+	    }
+	    get overflow() {
+	        return this._tf.overflow;
+	    }
+	    set overflow(value) {
+	        this._tf.overflow = value;
+	    }
+	    get underline() {
+	        return this._tf.underline;
+	    }
+	    set underline(value) {
+	        this._tf.underline = value;
+	    }
+	    get underlineColor() {
+	        return this._tf.underlineColor;
+	    }
+	    set underlineColor(value) {
+	        this._tf.underlineColor = value;
+	    }
+	}
+	Laya.ILaya.regClass(Label);
+	Laya.ClassUtils.regClass("laya.ui.Label", Label);
+	Laya.ClassUtils.regClass("Laya.Label", Label);
+
+	class Slider extends UIComponent {
+	    constructor(skin = null) {
+	        super();
+	        this.isVertical = true;
+	        this.showLabel = true;
+	        this._max = 100;
+	        this._min = 0;
+	        this._tick = 1;
+	        this._value = 0;
+	        if (!Slider.label) {
+	            Slider.label = new Label();
+	        }
+	        this.skin = skin;
+	    }
+	    destroy(destroyChild = true) {
+	        super.destroy(destroyChild);
+	        this._bg && this._bg.destroy(destroyChild);
+	        this._bar && this._bar.destroy(destroyChild);
+	        this._progress && this._progress.destroy(destroyChild);
+	        this._bg = null;
+	        this._bar = null;
+	        this._progress = null;
+	        this.changeHandler = null;
+	    }
+	    createChildren() {
+	        this.addChild(this._bg = new Image());
+	        this.addChild(this._bar = new Button());
+	    }
+	    initialize() {
+	        this._bar.on(Laya.Event.MOUSE_DOWN, this, this.onBarMouseDown);
+	        this._bg.sizeGrid = this._bar.sizeGrid = "4,4,4,4,0";
+	        if (this._progress)
+	            this._progress.sizeGrid = this._bar.sizeGrid;
+	        this.allowClickBack = true;
+	    }
+	    onBarMouseDown(e) {
+	        var Laya$1 = Laya.ILaya;
+	        this._globalSacle || (this._globalSacle = new Laya.Point());
+	        this._globalSacle.setTo(this.globalScaleX || 0.01, this.globalScaleY || 0.01);
+	        this._maxMove = this.isVertical ? (this.height - this._bar.height) : (this.width - this._bar.width);
+	        this._tx = Laya$1.stage.mouseX;
+	        this._ty = Laya$1.stage.mouseY;
+	        Laya$1.stage.on(Laya.Event.MOUSE_MOVE, this, this.mouseMove);
+	        Laya$1.stage.once(Laya.Event.MOUSE_UP, this, this.mouseUp);
+	        Laya$1.stage.once(Laya.Event.MOUSE_OUT, this, this.mouseUp);
+	        this.showValueText();
+	    }
+	    showValueText() {
+	        if (this.showLabel) {
+	            var label = Slider.label;
+	            this.addChild(label);
+	            label.textField.changeText(this._value + "");
+	            if (this.isVertical) {
+	                label.x = this._bar._x + 20;
+	                label.y = (this._bar.height - label.height) * 0.5 + this._bar._y;
+	            }
+	            else {
+	                label.y = this._bar._y - 20;
+	                label.x = (this._bar.width - label.width) * 0.5 + this._bar._x;
+	            }
+	        }
+	    }
+	    hideValueText() {
+	        Slider.label && Slider.label.removeSelf();
+	    }
+	    mouseUp(e) {
+	        let stage = Laya.ILaya.stage;
+	        stage.off(Laya.Event.MOUSE_MOVE, this, this.mouseMove);
+	        stage.off(Laya.Event.MOUSE_UP, this, this.mouseUp);
+	        stage.off(Laya.Event.MOUSE_OUT, this, this.mouseUp);
+	        this.sendChangeEvent(Laya.Event.CHANGED);
+	        this.hideValueText();
+	    }
+	    mouseMove(e) {
+	        let stage = Laya.ILaya.stage;
+	        var oldValue = this._value;
+	        if (this.isVertical) {
+	            this._bar.y += (stage.mouseY - this._ty) / this._globalSacle.y;
+	            if (this._bar._y > this._maxMove)
+	                this._bar.y = this._maxMove;
+	            else if (this._bar._y < 0)
+	                this._bar.y = 0;
+	            this._value = this._bar._y / this._maxMove * (this._max - this._min) + this._min;
+	            if (this._progress)
+	                this._progress.height = this._bar._y + 0.5 * this._bar.height;
+	        }
+	        else {
+	            this._bar.x += (stage.mouseX - this._tx) / this._globalSacle.x;
+	            if (this._bar._x > this._maxMove)
+	                this._bar.x = this._maxMove;
+	            else if (this._bar._x < 0)
+	                this._bar.x = 0;
+	            this._value = this._bar._x / this._maxMove * (this._max - this._min) + this._min;
+	            if (this._progress)
+	                this._progress.width = this._bar._x + 0.5 * this._bar.width;
+	        }
+	        this._tx = stage.mouseX;
+	        this._ty = stage.mouseY;
+	        if (this._tick != 0) {
+	            var pow = Math.pow(10, (this._tick + "").length - 1);
+	            this._value = Math.round(Math.round(this._value / this._tick) * this._tick * pow) / pow;
+	        }
+	        if (this._value != oldValue) {
+	            this.sendChangeEvent();
+	        }
+	        this.showValueText();
+	    }
+	    sendChangeEvent(type = Laya.Event.CHANGE) {
+	        this.event(type);
+	        this.changeHandler && this.changeHandler.runWith(this._value);
+	    }
+	    get skin() {
+	        return this._skin;
+	    }
+	    set skin(value) {
+	        if (this._skin != value) {
+	            this._skin = value;
+	            if (this._skin && !Laya.Loader.getRes(this._skin)) {
+	                Laya.ILaya.loader.load([this._skin, this._skin.replace(".png", "$bar.png")], Laya.Handler.create(this, this._skinLoaded));
+	            }
+	            else {
+	                this._skinLoaded();
+	            }
+	        }
+	    }
+	    _skinLoaded() {
+	        this._bg.skin = this._skin;
+	        this._bar.skin = this._skin.replace(".png", "$bar.png");
+	        var progressSkin = this._skin.replace(".png", "$progress.png");
+	        if (Laya.Loader.getRes(progressSkin)) {
+	            if (!this._progress) {
+	                this.addChild(this._progress = new Image());
+	                this._progress.sizeGrid = this._bar.sizeGrid;
+	                this.setChildIndex(this._progress, 1);
+	            }
+	            this._progress.skin = progressSkin;
+	        }
+	        this.setBarPoint();
+	        this.callLater(this.changeValue);
+	        this._sizeChanged();
+	        this.event(Laya.Event.LOADED);
+	    }
+	    setBarPoint() {
+	        if (this.isVertical)
+	            this._bar.x = Math.round((this._bg.width - this._bar.width) * 0.5);
+	        else
+	            this._bar.y = Math.round((this._bg.height - this._bar.height) * 0.5);
+	    }
+	    measureWidth() {
+	        return Math.max(this._bg.width, this._bar.width);
+	    }
+	    measureHeight() {
+	        return Math.max(this._bg.height, this._bar.height);
+	    }
+	    _sizeChanged() {
+	        super._sizeChanged();
+	        if (this.isVertical)
+	            this._bg.height = this.height;
+	        else
+	            this._bg.width = this.width;
+	        this.setBarPoint();
+	        this.changeValue();
+	    }
+	    get sizeGrid() {
+	        return this._bg.sizeGrid;
+	    }
+	    set sizeGrid(value) {
+	        this._bg.sizeGrid = value;
+	        this._bar.sizeGrid = value;
+	        if (this._progress)
+	            this._progress.sizeGrid = this._bar.sizeGrid;
+	    }
+	    setSlider(min, max, value) {
+	        this._value = -1;
+	        this._min = min;
+	        this._max = max > min ? max : min;
+	        this.value = value < min ? min : value > max ? max : value;
+	    }
+	    get tick() {
+	        return this._tick;
+	    }
+	    set tick(value) {
+	        if (this._tick != value) {
+	            this._tick = value;
+	            this.callLater(this.changeValue);
+	        }
+	    }
+	    changeValue() {
+	        if (this.tick != 0) {
+	            var pow = Math.pow(10, (this._tick + "").length - 1);
+	            this._value = Math.round(Math.round(this._value / this._tick) * this._tick * pow) / pow;
+	        }
+	        this._value = this._value > this._max ? this._max : this._value < this._min ? this._min : this._value;
+	        var num = this._max - this._min;
+	        if (num === 0)
+	            num = 1;
+	        if (this.isVertical) {
+	            this._bar.y = (this._value - this._min) / num * (this.height - this._bar.height);
+	            if (this._progress)
+	                this._progress.height = this._bar._y + 0.5 * this._bar.height;
+	        }
+	        else {
+	            this._bar.x = (this._value - this._min) / num * (this.width - this._bar.width);
+	            if (this._progress)
+	                this._progress.width = this._bar._x + 0.5 * this._bar.width;
+	        }
+	    }
+	    get max() {
+	        return this._max;
+	    }
+	    set max(value) {
+	        if (this._max != value) {
+	            this._max = value;
+	            this.callLater(this.changeValue);
+	        }
+	    }
+	    get min() {
+	        return this._min;
+	    }
+	    set min(value) {
+	        if (this._min != value) {
+	            this._min = value;
+	            this.callLater(this.changeValue);
+	        }
+	    }
+	    get value() {
+	        return this._value;
+	    }
+	    set value(num) {
+	        if (this._value != num) {
+	            var oldValue = this._value;
+	            this._value = num;
+	            this.changeValue();
+	            if (this._value != oldValue) {
+	                this.sendChangeEvent();
+	            }
+	        }
+	    }
+	    get allowClickBack() {
+	        return this._allowClickBack;
+	    }
+	    set allowClickBack(value) {
+	        if (this._allowClickBack != value) {
+	            this._allowClickBack = value;
+	            if (value)
+	                this._bg.on(Laya.Event.MOUSE_DOWN, this, this.onBgMouseDown);
+	            else
+	                this._bg.off(Laya.Event.MOUSE_DOWN, this, this.onBgMouseDown);
+	        }
+	    }
+	    onBgMouseDown(e) {
+	        var point = this._bg.getMousePoint();
+	        if (this.isVertical)
+	            this.value = point.y / (this.height - this._bar.height) * (this._max - this._min) + this._min;
+	        else
+	            this.value = point.x / (this.width - this._bar.width) * (this._max - this._min) + this._min;
+	    }
+	    set dataSource(value) {
+	        this._dataSource = value;
+	        if (typeof (value) == 'number' || typeof (value) == 'string')
+	            this.value = Number(value);
+	        else
+	            super.dataSource = value;
+	    }
+	    get dataSource() {
+	        return super.dataSource;
+	    }
+	    get bar() {
+	        return this._bar;
+	    }
+	}
+	Slider.label = null;
+	Laya.ILaya.regClass(Slider);
+	Laya.ClassUtils.regClass("laya.ui.Slider", Slider);
+	Laya.ClassUtils.regClass("Laya.Slider", Slider);
+
+	class ScrollBar extends UIComponent {
+	    constructor(skin = null) {
+	        super();
+	        this.rollRatio = 0.97;
+	        this.scaleBar = true;
+	        this.autoHide = false;
+	        this.elasticDistance = 0;
+	        this.elasticBackTime = 500;
+	        this._showButtons = UIConfig.showButtons;
+	        this._scrollSize = 1;
+	        this._thumbPercent = 1;
+	        this._lastOffset = 0;
+	        this._checkElastic = false;
+	        this._isElastic = false;
+	        this._hide = false;
+	        this._clickOnly = true;
+	        this._touchScrollEnable = UIConfig.touchScrollEnable;
+	        this._mouseWheelEnable = UIConfig.mouseWheelEnable;
+	        this.skin = skin;
+	        this.max = 1;
+	    }
+	    destroy(destroyChild = true) {
+	        this.stopScroll();
+	        this.target = null;
+	        super.destroy(destroyChild);
+	        this.upButton && this.upButton.destroy(destroyChild);
+	        this.downButton && this.downButton.destroy(destroyChild);
+	        this.slider && this.slider.destroy(destroyChild);
+	        this.upButton = this.downButton = null;
+	        this.slider = null;
+	        this.changeHandler = null;
+	        this._offsets = null;
+	    }
+	    createChildren() {
+	        this.addChild(this.slider = new Slider());
+	        this.addChild(this.upButton = new Button());
+	        this.addChild(this.downButton = new Button());
+	    }
+	    initialize() {
+	        this.slider.showLabel = false;
+	        this.slider.tick = 0;
+	        this.slider.on(Laya.Event.CHANGE, this, this.onSliderChange);
+	        this.slider.setSlider(0, 0, 0);
+	        this.upButton.on(Laya.Event.MOUSE_DOWN, this, this.onButtonMouseDown);
+	        this.downButton.on(Laya.Event.MOUSE_DOWN, this, this.onButtonMouseDown);
+	    }
+	    onSliderChange() {
+	        if (this._value != this.slider.value)
+	            this.value = this.slider.value;
+	    }
+	    onButtonMouseDown(e) {
+	        var isUp = e.currentTarget === this.upButton;
+	        this.slide(isUp);
+	        Laya.ILaya.timer.once(Styles.scrollBarDelayTime, this, this.startLoop, [isUp]);
+	        Laya.ILaya.stage.once(Laya.Event.MOUSE_UP, this, this.onStageMouseUp);
+	    }
+	    startLoop(isUp) {
+	        Laya.ILaya.timer.frameLoop(1, this, this.slide, [isUp]);
+	    }
+	    slide(isUp) {
+	        if (isUp)
+	            this.value -= this._scrollSize;
+	        else
+	            this.value += this._scrollSize;
+	    }
+	    onStageMouseUp(e) {
+	        Laya.ILaya.timer.clear(this, this.startLoop);
+	        Laya.ILaya.timer.clear(this, this.slide);
+	    }
+	    get skin() {
+	        return this._skin;
+	    }
+	    set skin(value) {
+	        if (value == " ")
+	            return;
+	        if (this._skin != value) {
+	            this._skin = value;
+	            if (this._skin && !Laya.Loader.getRes(this._skin)) {
+	                Laya.ILaya.loader.load([this._skin, this._skin.replace(".png", "$up.png"), this._skin.replace(".png", "$down.png"), this._skin.replace(".png", "$bar.png")], Laya.Handler.create(this, this._skinLoaded));
+	            }
+	            else {
+	                this._skinLoaded();
+	            }
+	        }
+	    }
+	    _skinLoaded() {
+	        this.slider.skin = this._skin;
+	        this.callLater(this.changeScrollBar);
+	        this._sizeChanged();
+	        this.event(Laya.Event.LOADED);
+	    }
+	    changeScrollBar() {
+	        this.upButton.visible = this._showButtons;
+	        this.downButton.visible = this._showButtons;
+	        if (this._showButtons) {
+	            this.upButton.skin = this._skin.replace(".png", "$up.png");
+	            this.downButton.skin = this._skin.replace(".png", "$down.png");
+	        }
+	        if (this.slider.isVertical)
+	            this.slider.y = this._showButtons ? this.upButton.height : 0;
+	        else
+	            this.slider.x = this._showButtons ? this.upButton.width : 0;
+	        this.resetPositions();
+	        this.repaint();
+	    }
+	    _sizeChanged() {
+	        super._sizeChanged();
+	        this.repaint();
+	        this.resetPositions();
+	        this.event(Laya.Event.CHANGE);
+	        this.changeHandler && this.changeHandler.runWith(this.value);
+	    }
+	    resetPositions() {
+	        if (this.slider.isVertical)
+	            this.slider.height = this.height - (this._showButtons ? (this.upButton.height + this.downButton.height) : 0);
+	        else
+	            this.slider.width = this.width - (this._showButtons ? (this.upButton.width + this.downButton.width) : 0);
+	        this.resetButtonPosition();
+	    }
+	    resetButtonPosition() {
+	        if (this.slider.isVertical)
+	            this.downButton.y = this.slider._y + this.slider.height;
+	        else
+	            this.downButton.x = this.slider._x + this.slider.width;
+	    }
+	    measureWidth() {
+	        if (this.slider.isVertical)
+	            return this.slider.width;
+	        return 100;
+	    }
+	    measureHeight() {
+	        if (this.slider.isVertical)
+	            return 100;
+	        return this.slider.height;
+	    }
+	    setScroll(min, max, value) {
+	        this.runCallLater(this._sizeChanged);
+	        this.slider.setSlider(min, max, value);
+	        this.slider.bar.visible = max > 0;
+	        if (!this._hide && this.autoHide)
+	            this.visible = false;
+	    }
+	    get max() {
+	        return this.slider.max;
+	    }
+	    set max(value) {
+	        this.slider.max = value;
+	    }
+	    get min() {
+	        return this.slider.min;
+	    }
+	    set min(value) {
+	        this.slider.min = value;
+	    }
+	    get value() {
+	        return this._value;
+	    }
+	    set value(v) {
+	        if (v !== this._value) {
+	            this._value = v;
+	            if (!this._isElastic) {
+	                if (this.slider["_value"] != v) {
+	                    this.slider["_value"] = v;
+	                    this.slider.changeValue();
+	                }
+	                this._value = this.slider["_value"];
+	            }
+	            this.event(Laya.Event.CHANGE);
+	            this.changeHandler && this.changeHandler.runWith(this._value);
+	        }
+	    }
+	    get isVertical() {
+	        return this.slider.isVertical;
+	    }
+	    set isVertical(value) {
+	        this.slider.isVertical = value;
+	    }
+	    get sizeGrid() {
+	        return this.slider.sizeGrid;
+	    }
+	    set sizeGrid(value) {
+	        this.slider.sizeGrid = value;
+	    }
+	    get scrollSize() {
+	        return this._scrollSize;
+	    }
+	    set scrollSize(value) {
+	        this._scrollSize = value;
+	    }
+	    set dataSource(value) {
+	        this._dataSource = value;
+	        if (typeof (value) == 'number' || typeof (value) == 'string')
+	            this.value = Number(value);
+	        else
+	            super.dataSource = value;
+	    }
+	    get dataSource() {
+	        return super.dataSource;
+	    }
+	    get thumbPercent() {
+	        return this._thumbPercent;
+	    }
+	    set thumbPercent(value) {
+	        this.runCallLater(this.changeScrollBar);
+	        this.runCallLater(this._sizeChanged);
+	        value = value >= 1 ? 0.99 : value;
+	        this._thumbPercent = value;
+	        if (this.scaleBar) {
+	            if (this.slider.isVertical)
+	                this.slider.bar.height = Math.max(this.slider.height * value, Styles.scrollBarMinNum);
+	            else
+	                this.slider.bar.width = Math.max(this.slider.width * value, Styles.scrollBarMinNum);
+	        }
+	    }
+	    get target() {
+	        return this._target;
+	    }
+	    set target(value) {
+	        if (this._target) {
+	            this._target.off(Laya.Event.MOUSE_WHEEL, this, this.onTargetMouseWheel);
+	            this._target.off(Laya.Event.MOUSE_DOWN, this, this.onTargetMouseDown);
+	        }
+	        this._target = value;
+	        if (value) {
+	            this._mouseWheelEnable && this._target.on(Laya.Event.MOUSE_WHEEL, this, this.onTargetMouseWheel);
+	            this._touchScrollEnable && this._target.on(Laya.Event.MOUSE_DOWN, this, this.onTargetMouseDown);
+	        }
+	    }
+	    get hide() {
+	        return this._hide;
+	    }
+	    set hide(value) {
+	        this._hide = value;
+	        this.visible = !value;
+	    }
+	    get showButtons() {
+	        return this._showButtons;
+	    }
+	    set showButtons(value) {
+	        this._showButtons = value;
+	        this.callLater(this.changeScrollBar);
+	    }
+	    get touchScrollEnable() {
+	        return this._touchScrollEnable;
+	    }
+	    set touchScrollEnable(value) {
+	        this._touchScrollEnable = value;
+	        this.target = this._target;
+	    }
+	    get mouseWheelEnable() {
+	        return this._mouseWheelEnable;
+	    }
+	    set mouseWheelEnable(value) {
+	        this._mouseWheelEnable = value;
+	        this.target = this._target;
+	    }
+	    onTargetMouseWheel(e) {
+	        this.value -= e.delta * this._scrollSize;
+	        this.target = this._target;
+	    }
+	    onTargetMouseDown(e) {
+	        if ((this.isLockedFun) && !this.isLockedFun(e))
+	            return;
+	        this.event(Laya.Event.END);
+	        this._clickOnly = true;
+	        this._lastOffset = 0;
+	        this._checkElastic = false;
+	        this._lastPoint || (this._lastPoint = new Laya.Point());
+	        this._lastPoint.setTo(Laya.ILaya.stage.mouseX, Laya.ILaya.stage.mouseY);
+	        Laya.ILaya.timer.clear(this, this.tweenMove);
+	        Laya.Tween.clearTween(this);
+	        Laya.ILaya.stage.once(Laya.Event.MOUSE_UP, this, this.onStageMouseUp2);
+	        Laya.ILaya.stage.once(Laya.Event.MOUSE_OUT, this, this.onStageMouseUp2);
+	        Laya.ILaya.timer.frameLoop(1, this, this.loop);
+	    }
+	    startDragForce() {
+	        this._clickOnly = true;
+	        this._lastOffset = 0;
+	        this._checkElastic = false;
+	        this._lastPoint || (this._lastPoint = new Laya.Point());
+	        this._lastPoint.setTo(Laya.ILaya.stage.mouseX, Laya.ILaya.stage.mouseY);
+	        Laya.ILaya.timer.clear(this, this.tweenMove);
+	        Laya.Tween.clearTween(this);
+	        Laya.ILaya.stage.once(Laya.Event.MOUSE_UP, this, this.onStageMouseUp2);
+	        Laya.ILaya.stage.once(Laya.Event.MOUSE_OUT, this, this.onStageMouseUp2);
+	        Laya.ILaya.timer.frameLoop(1, this, this.loop);
+	    }
+	    cancelDragOp() {
+	        Laya.ILaya.stage.off(Laya.Event.MOUSE_UP, this, this.onStageMouseUp2);
+	        Laya.ILaya.stage.off(Laya.Event.MOUSE_OUT, this, this.onStageMouseUp2);
+	        Laya.ILaya.timer.clear(this, this.tweenMove);
+	        Laya.ILaya.timer.clear(this, this.loop);
+	        this._target.mouseEnabled = true;
+	    }
+	    checkTriggers(isTweenMove = false) {
+	        if (this.value >= 0 && this.value - this._lastOffset <= 0) {
+	            if ((this.triggerDownDragLimit) && this.triggerDownDragLimit(isTweenMove)) {
+	                this.cancelDragOp();
+	                this.value = 0;
+	                return true;
+	            }
+	        }
+	        if (this.value <= this.max && (this.value - this._lastOffset >= this.max)) {
+	            if ((this.triggerUpDragLimit) && this.triggerUpDragLimit(isTweenMove)) {
+	                this.cancelDragOp();
+	                this.value = this.max;
+	                return true;
+	            }
+	        }
+	        return false;
+	    }
+	    get lastOffset() {
+	        return this._lastOffset;
+	    }
+	    startTweenMoveForce(lastOffset) {
+	        this._lastOffset = lastOffset;
+	        Laya.ILaya.timer.frameLoop(1, this, this.tweenMove, [200]);
+	    }
+	    loop() {
+	        var mouseY = Laya.ILaya.stage.mouseY;
+	        var mouseX = Laya.ILaya.stage.mouseX;
+	        this._lastOffset = this.isVertical ? (mouseY - this._lastPoint.y) : (mouseX - this._lastPoint.x);
+	        if (this._clickOnly) {
+	            if (Math.abs(this._lastOffset * (this.isVertical ? Laya.ILaya.stage._canvasTransform.getScaleY() : Laya.ILaya.stage._canvasTransform.getScaleX())) > 1) {
+	                this._clickOnly = false;
+	                if (this.checkTriggers())
+	                    return;
+	                this._offsets || (this._offsets = []);
+	                this._offsets.length = 0;
+	                this._target.mouseEnabled = false;
+	                if (!this.hide && this.autoHide) {
+	                    this.alpha = 1;
+	                    this.visible = true;
+	                }
+	                this.event(Laya.Event.START);
+	            }
+	            else
+	                return;
+	        }
+	        else {
+	            if (this.checkTriggers())
+	                return;
+	        }
+	        this._offsets.push(this._lastOffset);
+	        this._lastPoint.x = mouseX;
+	        this._lastPoint.y = mouseY;
+	        if (this._lastOffset === 0)
+	            return;
+	        if (!this._checkElastic) {
+	            if (this.elasticDistance > 0) {
+	                if (!this._checkElastic && this._lastOffset != 0) {
+	                    if ((this._lastOffset > 0 && this._value <= this.min) || (this._lastOffset < 0 && this._value >= this.max)) {
+	                        this._isElastic = true;
+	                        this._checkElastic = true;
+	                    }
+	                    else {
+	                        this._isElastic = false;
+	                    }
+	                }
+	            }
+	            else {
+	                this._checkElastic = true;
+	            }
+	        }
+	        if (this._isElastic) {
+	            if (this._value <= this.min) {
+	                if (this._lastOffset > 0) {
+	                    this.value -= this._lastOffset * Math.max(0, (1 - ((this.min - this._value) / this.elasticDistance)));
+	                }
+	                else {
+	                    this.value -= this._lastOffset * 0.5;
+	                    if (this._value >= this.min)
+	                        this._checkElastic = false;
+	                }
+	            }
+	            else if (this._value >= this.max) {
+	                if (this._lastOffset < 0) {
+	                    this.value -= this._lastOffset * Math.max(0, (1 - ((this._value - this.max) / this.elasticDistance)));
+	                }
+	                else {
+	                    this.value -= this._lastOffset * 0.5;
+	                    if (this._value <= this.max)
+	                        this._checkElastic = false;
+	                }
+	            }
+	        }
+	        else {
+	            this.value -= this._lastOffset;
+	        }
+	    }
+	    onStageMouseUp2(e) {
+	        Laya.ILaya.stage.off(Laya.Event.MOUSE_UP, this, this.onStageMouseUp2);
+	        Laya.ILaya.stage.off(Laya.Event.MOUSE_OUT, this, this.onStageMouseUp2);
+	        Laya.ILaya.timer.clear(this, this.loop);
+	        if (this._clickOnly) {
+	            if (this._value >= this.min && this._value <= this.max)
+	                return;
+	        }
+	        this._target.mouseEnabled = true;
+	        if (this._isElastic) {
+	            if (this._value < this.min) {
+	                Laya.Tween.to(this, { value: this.min }, this.elasticBackTime, Laya.Ease.sineOut, Laya.Handler.create(this, this.elasticOver));
+	            }
+	            else if (this._value > this.max) {
+	                Laya.Tween.to(this, { value: this.max }, this.elasticBackTime, Laya.Ease.sineOut, Laya.Handler.create(this, this.elasticOver));
+	            }
+	        }
+	        else {
+	            if (!this._offsets)
+	                return;
+	            if (this._offsets.length < 1) {
+	                this._offsets[0] = this.isVertical ? Laya.ILaya.stage.mouseY - this._lastPoint.y : Laya.ILaya.stage.mouseX - this._lastPoint.x;
+	            }
+	            var offset = 0;
+	            var n = Math.min(this._offsets.length, 3);
+	            for (var i = 0; i < n; i++) {
+	                offset += this._offsets[this._offsets.length - 1 - i];
+	            }
+	            this._lastOffset = offset / n;
+	            offset = Math.abs(this._lastOffset);
+	            if (offset < 2) {
+	                this.event(Laya.Event.END);
+	                return;
+	            }
+	            if (offset > 250)
+	                this._lastOffset = this._lastOffset > 0 ? 250 : -250;
+	            var dis = Math.round(Math.abs(this.elasticDistance * (this._lastOffset / 150)));
+	            Laya.ILaya.timer.frameLoop(1, this, this.tweenMove, [dis]);
+	        }
+	    }
+	    elasticOver() {
+	        this._isElastic = false;
+	        if (!this.hide && this.autoHide) {
+	            Laya.Tween.to(this, { alpha: 0 }, 500);
+	        }
+	        this.event(Laya.Event.END);
+	    }
+	    tweenMove(maxDistance) {
+	        this._lastOffset *= this.rollRatio;
+	        if (this.checkTriggers(true)) {
+	            return;
+	        }
+	        var tarSpeed;
+	        if (maxDistance > 0) {
+	            if (this._lastOffset > 0 && this.value <= this.min) {
+	                this._isElastic = true;
+	                tarSpeed = -(this.min - maxDistance - this.value) * 0.5;
+	                if (this._lastOffset > tarSpeed)
+	                    this._lastOffset = tarSpeed;
+	            }
+	            else if (this._lastOffset < 0 && this.value >= this.max) {
+	                this._isElastic = true;
+	                tarSpeed = -(this.max + maxDistance - this.value) * 0.5;
+	                if (this._lastOffset < tarSpeed)
+	                    this._lastOffset = tarSpeed;
+	            }
+	        }
+	        this.value -= this._lastOffset;
+	        if (Math.abs(this._lastOffset) < 0.1) {
+	            Laya.ILaya.timer.clear(this, this.tweenMove);
+	            if (this._isElastic) {
+	                if (this._value < this.min) {
+	                    Laya.Tween.to(this, { value: this.min }, this.elasticBackTime, Laya.Ease.sineOut, Laya.Handler.create(this, this.elasticOver));
+	                }
+	                else if (this._value > this.max) {
+	                    Laya.Tween.to(this, { value: this.max }, this.elasticBackTime, Laya.Ease.sineOut, Laya.Handler.create(this, this.elasticOver));
+	                }
+	                else {
+	                    this.elasticOver();
+	                }
+	                return;
+	            }
+	            this.event(Laya.Event.END);
+	            if (!this.hide && this.autoHide) {
+	                Laya.Tween.to(this, { alpha: 0 }, 500);
+	            }
+	        }
+	    }
+	    stopScroll() {
+	        this.onStageMouseUp2(null);
+	        Laya.ILaya.timer.clear(this, this.tweenMove);
+	        Laya.Tween.clearTween(this);
+	    }
+	    get tick() {
+	        return this.slider.tick;
+	    }
+	    set tick(value) {
+	        this.slider.tick = value;
+	    }
+	}
+	Laya.ILaya.regClass(ScrollBar);
+	Laya.ClassUtils.regClass("laya.ui.ScrollBar", ScrollBar);
+	Laya.ClassUtils.regClass("Laya.ScrollBar", ScrollBar);
+
+	class VScrollBar extends ScrollBar {
+	}
+	Laya.ILaya.regClass(VScrollBar);
+	Laya.ClassUtils.regClass("laya.ui.VScrollBar", VScrollBar);
+	Laya.ClassUtils.regClass("Laya.VScrollBar", VScrollBar);
+
+	class HScrollBar extends ScrollBar {
+	    initialize() {
+	        super.initialize();
+	        this.slider.isVertical = false;
+	    }
+	}
+	Laya.ILaya.regClass(HScrollBar);
+	Laya.ClassUtils.regClass("laya.ui.HScrollBar", HScrollBar);
+	Laya.ClassUtils.regClass("Laya.HScrollBar", HScrollBar);
+
+	class List extends Box {
+	    constructor() {
+	        super(...arguments);
+	        this.selectEnable = false;
+	        this.totalPage = 0;
+	        this._$componentType = "List";
+	        this._repeatX = 0;
+	        this._repeatY = 0;
+	        this._repeatX2 = 0;
+	        this._repeatY2 = 0;
+	        this._spaceX = 0;
+	        this._spaceY = 0;
+	        this._cells = [];
+	        this._startIndex = 0;
+	        this._selectedIndex = -1;
+	        this._page = 0;
+	        this._isVertical = true;
+	        this._cellSize = 20;
+	        this._cellOffset = 0;
+	        this._createdLine = 0;
+	        this._offset = new Laya.Point();
+	        this._usedCache = null;
+	        this._elasticEnabled = false;
+	        this._preLen = 0;
+	    }
+	    destroy(destroyChild = true) {
+	        this._content && this._content.destroy(destroyChild);
+	        this._scrollBar && this._scrollBar.destroy(destroyChild);
+	        super.destroy(destroyChild);
+	        this._content = null;
+	        this._scrollBar = null;
+	        this._itemRender = null;
+	        this._cells = null;
+	        this._array = null;
+	        this.selectHandler = this.renderHandler = this.mouseHandler = null;
+	    }
+	    createChildren() {
+	        this.addChild(this._content = new Box());
+	    }
+	    set cacheAs(value) {
+	        super.cacheAs = value;
+	        if (this._scrollBar) {
+	            this._usedCache = null;
+	            if (value !== "none")
+	                this._scrollBar.on(Laya.Event.START, this, this.onScrollStart);
+	            else
+	                this._scrollBar.off(Laya.Event.START, this, this.onScrollStart);
+	        }
+	    }
+	    get cacheAs() {
+	        return super.cacheAs;
+	    }
+	    onScrollStart() {
+	        this._usedCache || (this._usedCache = super.cacheAs);
+	        super.cacheAs = "none";
+	        this._scrollBar.once(Laya.Event.END, this, this.onScrollEnd);
+	    }
+	    onScrollEnd() {
+	        super.cacheAs = this._usedCache;
+	    }
+	    get content() {
+	        return this._content;
+	    }
+	    get vScrollBarSkin() {
+	        return this._scrollBar ? this._scrollBar.skin : null;
+	    }
+	    set vScrollBarSkin(value) {
+	        this._removePreScrollBar();
+	        var scrollBar = new VScrollBar();
+	        scrollBar.name = "scrollBar";
+	        scrollBar.right = 0;
+	        scrollBar.skin = value;
+	        scrollBar.elasticDistance = this._elasticEnabled ? 200 : 0;
+	        this.scrollBar = scrollBar;
+	        this.addChild(scrollBar);
+	        this._setCellChanged();
+	    }
+	    _removePreScrollBar() {
+	        var preNode = this.removeChildByName("scrollBar");
+	        if (preNode)
+	            preNode.destroy(true);
+	    }
+	    get hScrollBarSkin() {
+	        return this._scrollBar ? this._scrollBar.skin : null;
+	    }
+	    set hScrollBarSkin(value) {
+	        this._removePreScrollBar();
+	        var scrollBar = new HScrollBar();
+	        scrollBar.name = "scrollBar";
+	        scrollBar.bottom = 0;
+	        scrollBar.skin = value;
+	        scrollBar.elasticDistance = this._elasticEnabled ? 200 : 0;
+	        this.scrollBar = scrollBar;
+	        this.addChild(scrollBar);
+	        this._setCellChanged();
+	    }
+	    get scrollBar() {
+	        return this._scrollBar;
+	    }
+	    set scrollBar(value) {
+	        if (this._scrollBar != value) {
+	            this._scrollBar = value;
+	            if (value) {
+	                this._isVertical = this._scrollBar.isVertical;
+	                this.addChild(this._scrollBar);
+	                this._scrollBar.on(Laya.Event.CHANGE, this, this.onScrollBarChange);
+	            }
+	        }
+	    }
+	    get itemRender() {
+	        return this._itemRender;
+	    }
+	    set itemRender(value) {
+	        if (this._itemRender != value) {
+	            this._itemRender = value;
+	            for (var i = this._cells.length - 1; i > -1; i--) {
+	                this._cells[i].destroy();
+	            }
+	            this._cells.length = 0;
+	            this._setCellChanged();
+	        }
+	    }
+	    set width(value) {
+	        if (value != this._width) {
+	            super.width = value;
+	            this._setCellChanged();
+	        }
+	    }
+	    get width() {
+	        return super.width;
+	    }
+	    set height(value) {
+	        if (value != this._height) {
+	            super.height = value;
+	            this._setCellChanged();
+	        }
+	    }
+	    get height() {
+	        return super.height;
+	    }
+	    get repeatX() {
+	        return this._repeatX > 0 ? this._repeatX : this._repeatX2 > 0 ? this._repeatX2 : 1;
+	    }
+	    set repeatX(value) {
+	        this._repeatX = value;
+	        this._setCellChanged();
+	    }
+	    get repeatY() {
+	        return this._repeatY > 0 ? this._repeatY : this._repeatY2 > 0 ? this._repeatY2 : 1;
+	    }
+	    set repeatY(value) {
+	        this._repeatY = value;
+	        this._setCellChanged();
+	    }
+	    get spaceX() {
+	        return this._spaceX;
+	    }
+	    set spaceX(value) {
+	        this._spaceX = value;
+	        this._setCellChanged();
+	    }
+	    get spaceY() {
+	        return this._spaceY;
+	    }
+	    set spaceY(value) {
+	        this._spaceY = value;
+	        this._setCellChanged();
+	    }
+	    changeCells() {
+	        this._cellChanged = false;
+	        if (this._itemRender) {
+	            this.scrollBar = this.getChildByName("scrollBar");
+	            var cell = this._getOneCell();
+	            var cellWidth = (cell.width + this._spaceX) || 1;
+	            var cellHeight = (cell.height + this._spaceY) || 1;
+	            if (this._width > 0)
+	                this._repeatX2 = this._isVertical ? Math.round(this._width / cellWidth) : Math.ceil(this._width / cellWidth);
+	            if (this._height > 0)
+	                this._repeatY2 = this._isVertical ? Math.ceil(this._height / cellHeight) : Math.round(this._height / cellHeight);
+	            var listWidth = this._width ? this._width : (cellWidth * this.repeatX - this._spaceX);
+	            var listHeight = this._height ? this._height : (cellHeight * this.repeatY - this._spaceY);
+	            this._cellSize = this._isVertical ? cellHeight : cellWidth;
+	            this._cellOffset = this._isVertical ? (cellHeight * Math.max(this._repeatY2, this._repeatY) - listHeight - this._spaceY) : (cellWidth * Math.max(this._repeatX2, this._repeatX) - listWidth - this._spaceX);
+	            if (this._isVertical && this.vScrollBarSkin)
+	                this._scrollBar.height = listHeight;
+	            else if (!this._isVertical && this.hScrollBarSkin)
+	                this._scrollBar.width = listWidth;
+	            this.setContentSize(listWidth, listHeight);
+	            var numX = this._isVertical ? this.repeatX : this.repeatY;
+	            var numY = (this._isVertical ? this.repeatY : this.repeatX) + (this._scrollBar ? 1 : 0);
+	            this._createItems(0, numX, numY);
+	            this._createdLine = numY;
+	            if (this._array) {
+	                this.array = this._array;
+	                this.runCallLater(this.renderItems);
+	            }
+	        }
+	    }
+	    _getOneCell() {
+	        if (this._cells.length === 0) {
+	            var item = this.createItem();
+	            this._offset.setTo(item._x, item._y);
+	            if (this.cacheContent)
+	                return item;
+	            this._cells.push(item);
+	        }
+	        return this._cells[0];
+	    }
+	    _createItems(startY, numX, numY) {
+	        var box = this._content;
+	        var cell = this._getOneCell();
+	        var cellWidth = cell.width + this._spaceX;
+	        var cellHeight = cell.height + this._spaceY;
+	        if (this.cacheContent) {
+	            var cacheBox = new Box();
+	            cacheBox.cacheAs = "normal";
+	            cacheBox.pos((this._isVertical ? 0 : startY) * cellWidth, (this._isVertical ? startY : 0) * cellHeight);
+	            this._content.addChild(cacheBox);
+	            box = cacheBox;
+	        }
+	        else {
+	            var arr = [];
+	            for (var i = this._cells.length - 1; i > -1; i--) {
+	                var item = this._cells[i];
+	                item.removeSelf();
+	                arr.push(item);
+	            }
+	            this._cells.length = 0;
+	        }
+	        for (var k = startY; k < numY; k++) {
+	            for (var l = 0; l < numX; l++) {
+	                if (arr && arr.length) {
+	                    cell = arr.pop();
+	                }
+	                else {
+	                    cell = this.createItem();
+	                }
+	                cell.x = (this._isVertical ? l : k) * cellWidth - box._x;
+	                cell.y = (this._isVertical ? k : l) * cellHeight - box._y;
+	                cell.name = "item" + (k * numX + l);
+	                box.addChild(cell);
+	                this.addCell(cell);
+	            }
+	        }
+	    }
+	    createItem() {
+	        var arr = [];
+	        if (typeof (this._itemRender) == "function") {
+	            var box = new this._itemRender();
+	        }
+	        else {
+	            box = Laya.SceneUtils.createComp(this._itemRender, null, null, arr);
+	        }
+	        if (arr.length == 0 && box["_watchMap"]) {
+	            var watchMap = box["_watchMap"];
+	            for (var name in watchMap) {
+	                var a = watchMap[name];
+	                for (var i = 0; i < a.length; i++) {
+	                    var watcher = a[i];
+	                    arr.push(watcher.comp, watcher.prop, watcher.value);
+	                }
+	            }
+	        }
+	        if (arr.length)
+	            box["_$bindData"] = arr;
+	        return box;
+	    }
+	    addCell(cell) {
+	        cell.on(Laya.Event.CLICK, this, this.onCellMouse);
+	        cell.on(Laya.Event.RIGHT_CLICK, this, this.onCellMouse);
+	        cell.on(Laya.Event.MOUSE_OVER, this, this.onCellMouse);
+	        cell.on(Laya.Event.MOUSE_OUT, this, this.onCellMouse);
+	        cell.on(Laya.Event.MOUSE_DOWN, this, this.onCellMouse);
+	        cell.on(Laya.Event.MOUSE_UP, this, this.onCellMouse);
+	        this._cells.push(cell);
+	    }
+	    _afterInited() {
+	        this.initItems();
+	    }
+	    initItems() {
+	        if (!this._itemRender && this.getChildByName("item0") != null) {
+	            this.repeatX = 1;
+	            var count;
+	            count = 0;
+	            for (var i = 0; i < 10000; i++) {
+	                var cell = this.getChildByName("item" + i);
+	                if (cell) {
+	                    this.addCell(cell);
+	                    count++;
+	                    continue;
+	                }
+	                break;
+	            }
+	            this.repeatY = count;
+	        }
+	    }
+	    setContentSize(width, height) {
+	        this._content.width = width;
+	        this._content.height = height;
+	        if (this._scrollBar || this._offset.x != 0 || this._offset.y != 0) {
+	            this._content._style.scrollRect || (this._content.scrollRect = Laya.Rectangle.create());
+	            this._content._style.scrollRect.setTo(-this._offset.x, -this._offset.y, width, height);
+	            this._content.scrollRect = this._content.scrollRect;
+	        }
+	        this.event(Laya.Event.RESIZE);
+	    }
+	    onCellMouse(e) {
+	        if (e.type === Laya.Event.MOUSE_DOWN)
+	            this._isMoved = false;
+	        var cell = e.currentTarget;
+	        var index = this._startIndex + this._cells.indexOf(cell);
+	        if (index < 0)
+	            return;
+	        if (e.type === Laya.Event.CLICK || e.type === Laya.Event.RIGHT_CLICK) {
+	            if (this.selectEnable && !this._isMoved)
+	                this.selectedIndex = index;
+	            else
+	                this.changeCellState(cell, true, 0);
+	        }
+	        else if ((e.type === Laya.Event.MOUSE_OVER || e.type === Laya.Event.MOUSE_OUT) && this._selectedIndex !== index) {
+	            this.changeCellState(cell, e.type === Laya.Event.MOUSE_OVER, 0);
+	        }
+	        this.mouseHandler && this.mouseHandler.runWith([e, index]);
+	    }
+	    changeCellState(cell, visible, index) {
+	        var selectBox = cell.getChildByName("selectBox");
+	        if (selectBox) {
+	            this.selectEnable = true;
+	            selectBox.visible = visible;
+	            selectBox.index = index;
+	        }
+	    }
+	    _sizeChanged() {
+	        super._sizeChanged();
+	        this.setContentSize(this.width, this.height);
+	        if (this._scrollBar)
+	            this.callLater(this.onScrollBarChange);
+	    }
+	    onScrollBarChange(e = null) {
+	        this.runCallLater(this.changeCells);
+	        var scrollValue = this._scrollBar.value;
+	        var lineX = (this._isVertical ? this.repeatX : this.repeatY);
+	        var lineY = (this._isVertical ? this.repeatY : this.repeatX);
+	        var scrollLine = Math.floor(scrollValue / this._cellSize);
+	        if (!this.cacheContent) {
+	            var index = scrollLine * lineX;
+	            var num = 0;
+	            if (index > this._startIndex) {
+	                num = index - this._startIndex;
+	                var down = true;
+	                var toIndex = this._startIndex + lineX * (lineY + 1);
+	                this._isMoved = true;
+	            }
+	            else if (index < this._startIndex) {
+	                num = this._startIndex - index;
+	                down = false;
+	                toIndex = this._startIndex - 1;
+	                this._isMoved = true;
+	            }
+	            for (var i = 0; i < num; i++) {
+	                if (down) {
+	                    var cell = this._cells.shift();
+	                    this._cells[this._cells.length] = cell;
+	                    var cellIndex = toIndex + i;
+	                }
+	                else {
+	                    cell = this._cells.pop();
+	                    this._cells.unshift(cell);
+	                    cellIndex = toIndex - i;
+	                }
+	                var pos = Math.floor(cellIndex / lineX) * this._cellSize;
+	                this._isVertical ? cell.y = pos : cell.x = pos;
+	                this.renderItem(cell, cellIndex);
+	            }
+	            this._startIndex = index;
+	            this.changeSelectStatus();
+	        }
+	        else {
+	            num = (lineY + 1);
+	            if (this._createdLine - scrollLine < num) {
+	                this._createItems(this._createdLine, lineX, this._createdLine + num);
+	                this.renderItems(this._createdLine * lineX, 0);
+	                this._createdLine += num;
+	            }
+	        }
+	        var r = this._content._style.scrollRect;
+	        if (this._isVertical) {
+	            r.y = scrollValue - this._offset.y;
+	            r.x = -this._offset.x;
+	        }
+	        else {
+	            r.y = -this._offset.y;
+	            r.x = scrollValue - this._offset.x;
+	        }
+	        this._content.scrollRect = r;
+	    }
+	    posCell(cell, cellIndex) {
+	        if (!this._scrollBar)
+	            return;
+	        var lineX = (this._isVertical ? this.repeatX : this.repeatY);
+	        var lineY = (this._isVertical ? this.repeatY : this.repeatX);
+	        var pos = Math.floor(cellIndex / lineX) * this._cellSize;
+	        this._isVertical ? cell._y = pos : cell.x = pos;
+	    }
+	    get selectedIndex() {
+	        return this._selectedIndex;
+	    }
+	    set selectedIndex(value) {
+	        if (this._selectedIndex != value) {
+	            this._selectedIndex = value;
+	            this.changeSelectStatus();
+	            this.event(Laya.Event.CHANGE);
+	            this.selectHandler && this.selectHandler.runWith(value);
+	            this.startIndex = this._startIndex;
+	        }
+	    }
+	    changeSelectStatus() {
+	        for (var i = 0, n = this._cells.length; i < n; i++) {
+	            this.changeCellState(this._cells[i], this._selectedIndex === this._startIndex + i, 1);
+	        }
+	    }
+	    get selectedItem() {
+	        return this._selectedIndex != -1 ? this._array[this._selectedIndex] : null;
+	    }
+	    set selectedItem(value) {
+	        this.selectedIndex = this._array.indexOf(value);
+	    }
+	    get selection() {
+	        return this.getCell(this._selectedIndex);
+	    }
+	    set selection(value) {
+	        this.selectedIndex = this._startIndex + this._cells.indexOf(value);
+	    }
+	    get startIndex() {
+	        return this._startIndex;
+	    }
+	    set startIndex(value) {
+	        this._startIndex = value > 0 ? value : 0;
+	        this.callLater(this.renderItems);
+	    }
+	    renderItems(from = 0, to = 0) {
+	        for (var i = from, n = to || this._cells.length; i < n; i++) {
+	            this.renderItem(this._cells[i], this._startIndex + i);
+	        }
+	        this.changeSelectStatus();
+	    }
+	    renderItem(cell, index) {
+	        if (this._array && index >= 0 && index < this._array.length) {
+	            cell.visible = true;
+	            if (cell["_$bindData"]) {
+	                cell["_dataSource"] = this._array[index];
+	                this._bindData(cell, this._array[index]);
+	            }
+	            else
+	                cell.dataSource = this._array[index];
+	            if (!this.cacheContent) {
+	                this.posCell(cell, index);
+	            }
+	            if (this.hasListener(Laya.Event.RENDER))
+	                this.event(Laya.Event.RENDER, [cell, index]);
+	            if (this.renderHandler)
+	                this.renderHandler.runWith([cell, index]);
+	        }
+	        else {
+	            cell.visible = false;
+	            cell.dataSource = null;
+	        }
+	    }
+	    _bindData(cell, data) {
+	        var arr = cell._$bindData;
+	        for (var i = 0, n = arr.length; i < n; i++) {
+	            var ele = arr[i++];
+	            var prop = arr[i++];
+	            var value = arr[i];
+	            var fun = UIUtils.getBindFun(value);
+	            ele[prop] = fun.call(this, data);
+	        }
+	    }
+	    get array() {
+	        return this._array;
+	    }
+	    set array(value) {
+	        this.runCallLater(this.changeCells);
+	        this._array = value || [];
+	        this._preLen = this._array.length;
+	        var length = this._array.length;
+	        this.totalPage = Math.ceil(length / (this.repeatX * this.repeatY));
+	        this._selectedIndex = this._selectedIndex < length ? this._selectedIndex : length - 1;
+	        this.startIndex = this._startIndex;
+	        if (this._scrollBar) {
+	            this._scrollBar.stopScroll();
+	            var numX = this._isVertical ? this.repeatX : this.repeatY;
+	            var numY = this._isVertical ? this.repeatY : this.repeatX;
+	            var lineCount = Math.ceil(length / numX);
+	            var total = this._cellOffset > 0 ? this.totalPage + 1 : this.totalPage;
+	            if (total > 1 && lineCount >= numY) {
+	                this._scrollBar.scrollSize = this._cellSize;
+	                this._scrollBar.thumbPercent = numY / lineCount;
+	                this._scrollBar.setScroll(0, (lineCount - numY) * this._cellSize + this._cellOffset, this._scrollBar.value);
+	                this._scrollBar.target = this._content;
+	            }
+	            else {
+	                this._scrollBar.setScroll(0, 0, 0);
+	                this._scrollBar.target = this._content;
+	            }
+	        }
+	    }
+	    updateArray(array) {
+	        this._array = array;
+	        var freshStart;
+	        if (this._array) {
+	            freshStart = this._preLen - this._startIndex;
+	            if (freshStart >= 0)
+	                this.renderItems(freshStart);
+	            this._preLen = this._array.length;
+	        }
+	        if (this._scrollBar) {
+	            var length = array.length;
+	            var numX = this._isVertical ? this.repeatX : this.repeatY;
+	            var numY = this._isVertical ? this.repeatY : this.repeatX;
+	            var lineCount = Math.ceil(length / numX);
+	            if (lineCount >= numY) {
+	                this._scrollBar.thumbPercent = numY / lineCount;
+	                this._scrollBar.slider["_max"] = (lineCount - numY) * this._cellSize + this._cellOffset;
+	            }
+	        }
+	    }
+	    get page() {
+	        return this._page;
+	    }
+	    set page(value) {
+	        this._page = value;
+	        if (this._array) {
+	            this._page = value > 0 ? value : 0;
+	            this._page = this._page < this.totalPage ? this._page : this.totalPage - 1;
+	            this.startIndex = this._page * this.repeatX * this.repeatY;
+	        }
+	    }
+	    get length() {
+	        return this._array ? this._array.length : 0;
+	    }
+	    set dataSource(value) {
+	        this._dataSource = value;
+	        if (typeof (value) == 'number' || typeof (value) == 'string')
+	            this.selectedIndex = parseInt(value);
+	        else if (value instanceof Array)
+	            this.array = value;
+	        else
+	            super.dataSource = value;
+	    }
+	    get dataSource() {
+	        return super.dataSource;
+	    }
+	    get cells() {
+	        this.runCallLater(this.changeCells);
+	        return this._cells;
+	    }
+	    get elasticEnabled() {
+	        return this._elasticEnabled;
+	    }
+	    set elasticEnabled(value) {
+	        this._elasticEnabled = value;
+	        if (this._scrollBar) {
+	            this._scrollBar.elasticDistance = value ? 200 : 0;
+	        }
+	    }
+	    refresh() {
+	        this.array = this._array;
+	    }
+	    getItem(index) {
+	        if (index > -1 && index < this._array.length) {
+	            return this._array[index];
+	        }
+	        return null;
+	    }
+	    changeItem(index, source) {
+	        if (index > -1 && index < this._array.length) {
+	            this._array[index] = source;
+	            if (index >= this._startIndex && index < this._startIndex + this._cells.length) {
+	                this.renderItem(this.getCell(index), index);
+	            }
+	        }
+	    }
+	    setItem(index, source) {
+	        this.changeItem(index, source);
+	    }
+	    addItem(souce) {
+	        this._array.push(souce);
+	        this.array = this._array;
+	    }
+	    addItemAt(souce, index) {
+	        this._array.splice(index, 0, souce);
+	        this.array = this._array;
+	    }
+	    deleteItem(index) {
+	        this._array.splice(index, 1);
+	        this.array = this._array;
+	    }
+	    getCell(index) {
+	        this.runCallLater(this.changeCells);
+	        if (index > -1 && this._cells) {
+	            return this._cells[(index - this._startIndex) % this._cells.length];
+	        }
+	        return null;
+	    }
+	    scrollTo(index) {
+	        if (this._scrollBar) {
+	            var numX = this._isVertical ? this.repeatX : this.repeatY;
+	            this._scrollBar.value = Math.floor(index / numX) * this._cellSize;
+	        }
+	        else {
+	            this.startIndex = index;
+	        }
+	    }
+	    tweenTo(index, time = 200, complete = null) {
+	        if (this._scrollBar) {
+	            this._scrollBar.stopScroll();
+	            var numX = this._isVertical ? this.repeatX : this.repeatY;
+	            Laya.Tween.to(this._scrollBar, { value: Math.floor(index / numX) * this._cellSize }, time, null, complete, 0, true);
+	        }
+	        else {
+	            this.startIndex = index;
+	            if (complete)
+	                complete.run();
+	        }
+	    }
+	    _setCellChanged() {
+	        if (!this._cellChanged) {
+	            this._cellChanged = true;
+	            this.callLater(this.changeCells);
+	        }
+	    }
+	    commitMeasure() {
+	        this.runCallLater(this.changeCells);
+	    }
+	}
+	Laya.ILaya.regClass(List);
+	Laya.ClassUtils.regClass("laya.ui.List", List);
+	Laya.ClassUtils.regClass("Laya.List", List);
+
+	class ComboBox extends UIComponent {
+	    constructor(skin = null, labels = null) {
+	        super();
+	        this._visibleNum = 6;
+	        this._itemColors = Styles.comboBoxItemColors;
+	        this._itemSize = 12;
+	        this._labels = [];
+	        this._selectedIndex = -1;
+	        this.itemRender = null;
+	        this.skin = skin;
+	        this.labels = labels;
+	    }
+	    destroy(destroyChild = true) {
+	        super.destroy(destroyChild);
+	        this._button && this._button.destroy(destroyChild);
+	        this._list && this._list.destroy(destroyChild);
+	        this._button = null;
+	        this._list = null;
+	        this._itemColors = null;
+	        this._labels = null;
+	        this._selectHandler = null;
+	    }
+	    createChildren() {
+	        this.addChild(this._button = new Button());
+	        this._button.text.align = "left";
+	        this._button.labelPadding = "0,0,0,5";
+	        this._button.on(Laya.Event.MOUSE_DOWN, this, this.onButtonMouseDown);
+	    }
+	    _createList() {
+	        this._list = new List();
+	        if (this._scrollBarSkin)
+	            this._list.vScrollBarSkin = this._scrollBarSkin;
+	        this._setListEvent(this._list);
+	    }
+	    _setListEvent(list) {
+	        this._list.selectEnable = true;
+	        this._list.on(Laya.Event.MOUSE_DOWN, this, this.onListDown);
+	        this._list.mouseHandler = Laya.Handler.create(this, this.onlistItemMouse, null, false);
+	        if (this._list.scrollBar)
+	            this._list.scrollBar.on(Laya.Event.MOUSE_DOWN, this, this.onScrollBarDown);
+	    }
+	    onListDown(e) {
+	        e.stopPropagation();
+	    }
+	    onScrollBarDown(e) {
+	        e.stopPropagation();
+	    }
+	    onButtonMouseDown(e) {
+	        this.callLater(this.switchTo, [!this._isOpen]);
+	    }
+	    get skin() {
+	        return this._button.skin;
+	    }
+	    set skin(value) {
+	        if (this._button.skin != value) {
+	            this._button.skin = value;
+	            this._listChanged = true;
+	        }
+	    }
+	    measureWidth() {
+	        return this._button.width;
+	    }
+	    measureHeight() {
+	        return this._button.height;
+	    }
+	    changeList() {
+	        this._listChanged = false;
+	        var labelWidth = this.width - 2;
+	        var labelColor = this._itemColors[2];
+	        this._itemHeight = this._itemSize + 6;
+	        this._list.itemRender = this.itemRender || { type: "Box", child: [{ type: "Label", props: { name: "label", x: 1, padding: "3,3,3,3", width: labelWidth, height: this._itemHeight, fontSize: this._itemSize, color: labelColor } }] };
+	        this._list.repeatY = this._visibleNum;
+	        this._list.refresh();
+	    }
+	    onlistItemMouse(e, index) {
+	        var type = e.type;
+	        if (type === Laya.Event.MOUSE_OVER || type === Laya.Event.MOUSE_OUT) {
+	            if (this._isCustomList)
+	                return;
+	            var box = this._list.getCell(index);
+	            if (!box)
+	                return;
+	            var label = box.getChildByName("label");
+	            if (label) {
+	                if (type === Laya.Event.ROLL_OVER) {
+	                    label.bgColor = this._itemColors[0];
+	                    label.color = this._itemColors[1];
+	                }
+	                else {
+	                    label.bgColor = null;
+	                    label.color = this._itemColors[2];
+	                }
+	            }
+	        }
+	        else if (type === Laya.Event.CLICK) {
+	            this.selectedIndex = index;
+	            this.isOpen = false;
+	        }
+	    }
+	    switchTo(value) {
+	        this.isOpen = value;
+	    }
+	    changeOpen() {
+	        this.isOpen = !this._isOpen;
+	    }
+	    set width(value) {
+	        super.width = value;
+	        this._button.width = this._width;
+	        this._itemChanged = true;
+	        this._listChanged = true;
+	    }
+	    get width() {
+	        return super.width;
+	    }
+	    set height(value) {
+	        super.height = value;
+	        this._button.height = this._height;
+	    }
+	    get height() {
+	        return super.height;
+	    }
+	    get labels() {
+	        return this._labels.join(",");
+	    }
+	    set labels(value) {
+	        if (this._labels.length > 0)
+	            this.selectedIndex = -1;
+	        if (value)
+	            this._labels = value.split(",");
+	        else
+	            this._labels.length = 0;
+	        this._itemChanged = true;
+	    }
+	    changeItem() {
+	        this._itemChanged = false;
+	        this._listHeight = this._labels.length > 0 ? Math.min(this._visibleNum, this._labels.length) * this._itemHeight : this._itemHeight;
+	        if (!this._isCustomList) {
+	            var g = this._list.graphics;
+	            g.clear(true);
+	            g.drawRect(0, 0, this.width - 1, this._listHeight, this._itemColors[4], this._itemColors[3]);
+	        }
+	        var a = this._list.array || [];
+	        a.length = 0;
+	        for (var i = 0, n = this._labels.length; i < n; i++) {
+	            a.push({ label: this._labels[i] });
+	        }
+	        this._list.height = this._listHeight;
+	        this._list.array = a;
+	    }
+	    get selectedIndex() {
+	        return this._selectedIndex;
+	    }
+	    set selectedIndex(value) {
+	        if (this._selectedIndex != value) {
+	            this._selectedIndex = value;
+	            if (this._labels.length > 0)
+	                this.changeSelected();
+	            else
+	                this.callLater(this.changeSelected);
+	            this.event(Laya.Event.CHANGE, [Laya.Event.EMPTY.setTo(Laya.Event.CHANGE, this, this)]);
+	            this._selectHandler && this._selectHandler.runWith(this._selectedIndex);
+	        }
+	    }
+	    changeSelected() {
+	        this._button.label = this.selectedLabel;
+	    }
+	    get selectHandler() {
+	        return this._selectHandler;
+	    }
+	    set selectHandler(value) {
+	        this._selectHandler = value;
+	    }
+	    get selectedLabel() {
+	        return this._selectedIndex > -1 && this._selectedIndex < this._labels.length ? this._labels[this._selectedIndex] : null;
+	    }
+	    set selectedLabel(value) {
+	        this.selectedIndex = this._labels.indexOf(value);
+	    }
+	    get visibleNum() {
+	        return this._visibleNum;
+	    }
+	    set visibleNum(value) {
+	        this._visibleNum = value;
+	        this._listChanged = true;
+	    }
+	    get itemColors() {
+	        return String(this._itemColors);
+	    }
+	    set itemColors(value) {
+	        this._itemColors = UIUtils.fillArray(this._itemColors, value, String);
+	        this._listChanged = true;
+	    }
+	    get itemSize() {
+	        return this._itemSize;
+	    }
+	    set itemSize(value) {
+	        this._itemSize = value;
+	        this._listChanged = true;
+	    }
+	    get isOpen() {
+	        return this._isOpen;
+	    }
+	    set isOpen(value) {
+	        if (this._isOpen != value) {
+	            this._isOpen = value;
+	            this._button.selected = this._isOpen;
+	            if (this._isOpen) {
+	                this._list || this._createList();
+	                this._listChanged && !this._isCustomList && this.changeList();
+	                this._itemChanged && this.changeItem();
+	                var p = this.localToGlobal(Laya.Point.TEMP.setTo(0, 0));
+	                var py = p.y + this._button.height;
+	                py = py + this._listHeight <= Laya.ILaya.stage.height ? py : p.y - this._listHeight;
+	                this._list.pos(p.x, py);
+	                this._list.zOrder = 1001;
+	                Laya.ILaya.stage.addChild(this._list);
+	                Laya.ILaya.stage.once(Laya.Event.MOUSE_DOWN, this, this.removeList);
+	                Laya.ILaya.stage.on(Laya.Event.MOUSE_WHEEL, this, this._onStageMouseWheel);
+	                this._list.selectedIndex = this._selectedIndex;
+	            }
+	            else {
+	                this._list && this._list.removeSelf();
+	            }
+	        }
+	    }
+	    _onStageMouseWheel(e) {
+	        if (!this._list || this._list.contains(e.target))
+	            return;
+	        this.removeList(null);
+	    }
+	    removeList(e) {
+	        Laya.ILaya.stage.off(Laya.Event.MOUSE_DOWN, this, this.removeList);
+	        Laya.ILaya.stage.off(Laya.Event.MOUSE_WHEEL, this, this._onStageMouseWheel);
+	        this.isOpen = false;
+	    }
+	    get scrollBarSkin() {
+	        return this._scrollBarSkin;
+	    }
+	    set scrollBarSkin(value) {
+	        this._scrollBarSkin = value;
+	    }
+	    get sizeGrid() {
+	        return this._button.sizeGrid;
+	    }
+	    set sizeGrid(value) {
+	        this._button.sizeGrid = value;
+	    }
+	    get scrollBar() {
+	        return this.list.scrollBar;
+	    }
+	    get button() {
+	        return this._button;
+	    }
+	    get list() {
+	        this._list || this._createList();
+	        return this._list;
+	    }
+	    set list(value) {
+	        if (value) {
+	            value.removeSelf();
+	            this._isCustomList = true;
+	            this._list = value;
+	            this._setListEvent(value);
+	            this._itemHeight = value.getCell(0).height + value.spaceY;
+	        }
+	    }
+	    set dataSource(value) {
+	        this._dataSource = value;
+	        if (typeof (value) == 'number' || typeof (value) == 'string')
+	            this.selectedIndex = parseInt(value);
+	        else if (value instanceof Array)
+	            this.labels = value.join(",");
+	        else
+	            super.dataSource = value;
+	    }
+	    get dataSource() {
+	        return super.dataSource;
+	    }
+	    get labelColors() {
+	        return this._button.labelColors;
+	    }
+	    set labelColors(value) {
+	        if (this._button.labelColors != value) {
+	            this._button.labelColors = value;
+	        }
+	    }
+	    get labelPadding() {
+	        return this._button.text.padding.join(",");
+	    }
+	    set labelPadding(value) {
+	        this._button.text.padding = UIUtils.fillArray(Styles.labelPadding, value, Number);
+	    }
+	    get labelSize() {
+	        return this._button.text.fontSize;
+	    }
+	    set labelSize(value) {
+	        this._button.text.fontSize = value;
+	    }
+	    get labelBold() {
+	        return this._button.text.bold;
+	    }
+	    set labelBold(value) {
+	        this._button.text.bold = value;
+	    }
+	    get labelFont() {
+	        return this._button.text.font;
+	    }
+	    set labelFont(value) {
+	        this._button.text.font = value;
+	    }
+	    get stateNum() {
+	        return this._button.stateNum;
+	    }
+	    set stateNum(value) {
+	        this._button.stateNum = value;
+	    }
+	}
+	Laya.ILaya.regClass(ComboBox);
+	Laya.ClassUtils.regClass("laya.ui.ComboBox", ComboBox);
+	Laya.ClassUtils.regClass("Laya.ComboBox", ComboBox);
+
+	class ProgressBar extends UIComponent {
+	    constructor(skin = null) {
+	        super();
+	        this._value = 0.5;
+	        this.skin = skin;
+	    }
+	    destroy(destroyChild = true) {
+	        super.destroy(destroyChild);
+	        this._bg && this._bg.destroy(destroyChild);
+	        this._bar && this._bar.destroy(destroyChild);
+	        this._bg = this._bar = null;
+	        this.changeHandler = null;
+	    }
+	    createChildren() {
+	        this.addChild(this._bg = new Image());
+	        this.addChild(this._bar = new Image());
+	        this._bar._bitmap.autoCacheCmd = false;
+	    }
+	    get skin() {
+	        return this._skin;
+	    }
+	    set skin(value) {
+	        if (this._skin != value) {
+	            this._skin = value;
+	            if (this._skin && !Laya.Loader.getRes(this._skin)) {
+	                Laya.ILaya.loader.load(this._skin, Laya.Handler.create(this, this._skinLoaded), null, Laya.Loader.IMAGE, 1);
+	            }
+	            else {
+	                this._skinLoaded();
+	            }
+	        }
+	    }
+	    _skinLoaded() {
+	        this._bg.skin = this._skin;
+	        this._bar.skin = this._skin.replace(".png", "$bar.png");
+	        this.callLater(this.changeValue);
+	        this._sizeChanged();
+	        this.event(Laya.Event.LOADED);
+	    }
+	    measureWidth() {
+	        return this._bg.width;
+	    }
+	    measureHeight() {
+	        return this._bg.height;
+	    }
+	    get value() {
+	        return this._value;
+	    }
+	    set value(num) {
+	        if (this._value != num) {
+	            num = num > 1 ? 1 : num < 0 ? 0 : num;
+	            this._value = num;
+	            this.callLater(this.changeValue);
+	            this.event(Laya.Event.CHANGE);
+	            this.changeHandler && this.changeHandler.runWith(num);
+	        }
+	    }
+	    changeValue() {
+	        if (this.sizeGrid) {
+	            var grid = this.sizeGrid.split(",");
+	            var left = Number(grid[3]);
+	            var right = Number(grid[1]);
+	            var max = this.width - left - right;
+	            var sw = max * this._value;
+	            this._bar.width = left + right + sw;
+	            this._bar.visible = this._bar.width > left + right;
+	        }
+	        else {
+	            this._bar.width = this.width * this._value;
+	        }
+	    }
+	    get bar() {
+	        return this._bar;
+	    }
+	    get bg() {
+	        return this._bg;
+	    }
+	    get sizeGrid() {
+	        return this._bg.sizeGrid;
+	    }
+	    set sizeGrid(value) {
+	        this._bg.sizeGrid = this._bar.sizeGrid = value;
+	    }
+	    set width(value) {
+	        super.width = value;
+	        this._bg.width = this._width;
+	        this.callLater(this.changeValue);
+	    }
+	    get width() {
+	        return super.width;
+	    }
+	    set height(value) {
+	        super.height = value;
+	        this._bg.height = this._height;
+	        this._bar.height = this._height;
+	    }
+	    get height() {
+	        return super.height;
+	    }
+	    set dataSource(value) {
+	        this._dataSource = value;
+	        if (typeof (value) == 'number' || typeof (value) == 'string')
+	            this.value = Number(value);
+	        else
+	            super.dataSource = value;
+	    }
+	    get dataSource() {
+	        return super.dataSource;
+	    }
+	}
+	Laya.ILaya.regClass(ProgressBar);
+	Laya.ClassUtils.regClass("laya.ui.ProgressBar", ProgressBar);
+	Laya.ClassUtils.regClass("Laya.ProgressBar", ProgressBar);
+
+	class Radio extends Button {
+	    constructor(skin = null, label = "") {
+	        super(skin, label);
+	        this.toggle = false;
+	        this._autoSize = false;
+	    }
+	    destroy(destroyChild = true) {
+	        super.destroy(destroyChild);
+	        this._value = null;
+	    }
+	    preinitialize() {
+	        super.preinitialize();
+	        this.toggle = false;
+	        this._autoSize = false;
+	    }
+	    initialize() {
+	        super.initialize();
+	        this.createText();
+	        this._text.align = "left";
+	        this._text.valign = "top";
+	        this._text.width = 0;
+	        this.on(Laya.Event.CLICK, this, this.onClick);
+	    }
+	    onClick(e) {
+	        this.selected = true;
+	    }
+	    get value() {
+	        return this._value != null ? this._value : this.label;
+	    }
+	    set value(obj) {
+	        this._value = obj;
+	    }
+	}
+	Laya.ILaya.regClass(Radio);
+	Laya.ClassUtils.regClass("laya.ui.Radio", Radio);
+	Laya.ClassUtils.regClass("Laya.Radio", Radio);
+
+	class UIGroup extends Box {
+	    constructor(labels = null, skin = null) {
+	        super();
+	        this._selectedIndex = -1;
+	        this._direction = "horizontal";
+	        this._space = 0;
+	        this.skin = skin;
+	        this.labels = labels;
+	    }
+	    preinitialize() {
+	        this.mouseEnabled = true;
+	    }
+	    destroy(destroyChild = true) {
+	        super.destroy(destroyChild);
+	        this._items && (this._items.length = 0);
+	        this._items = null;
+	        this.selectHandler = null;
+	    }
+	    addItem(item, autoLayOut = true) {
+	        var display = item;
+	        var index = this._items.length;
+	        display.name = "item" + index;
+	        this.addChild(display);
+	        this.initItems();
+	        if (autoLayOut && index > 0) {
+	            var preItem = this._items[index - 1];
+	            if (this._direction == "horizontal") {
+	                display.x = preItem._x + preItem.width + this._space;
+	            }
+	            else {
+	                display.y = preItem._y + preItem.height + this._space;
+	            }
+	        }
+	        else {
+	            if (autoLayOut) {
+	                display.x = 0;
+	                display.y = 0;
+	            }
+	        }
+	        return index;
+	    }
+	    delItem(item, autoLayOut = true) {
+	        var index = this._items.indexOf(item);
+	        if (index != -1) {
+	            var display = item;
+	            this.removeChild(display);
+	            for (var i = index + 1, n = this._items.length; i < n; i++) {
+	                var child = this._items[i];
+	                child.name = "item" + (i - 1);
+	                if (autoLayOut) {
+	                    if (this._direction == "horizontal") {
+	                        child.x -= display.width + this._space;
+	                    }
+	                    else {
+	                        child.y -= display.height + this._space;
+	                    }
+	                }
+	            }
+	            this.initItems();
+	            if (this._selectedIndex > -1) {
+	                var newIndex;
+	                newIndex = this._selectedIndex < this._items.length ? this._selectedIndex : (this._selectedIndex - 1);
+	                this._selectedIndex = -1;
+	                this.selectedIndex = newIndex;
+	            }
+	        }
+	    }
+	    _afterInited() {
+	        this.initItems();
+	    }
+	    initItems() {
+	        this._items || (this._items = []);
+	        this._items.length = 0;
+	        for (var i = 0; i < 10000; i++) {
+	            var item = this.getChildByName("item" + i);
+	            if (item == null)
+	                break;
+	            this._items.push(item);
+	            item.selected = (i === this._selectedIndex);
+	            item.clickHandler = Laya.Handler.create(this, this.itemClick, [i], false);
+	        }
+	    }
+	    itemClick(index) {
+	        this.selectedIndex = index;
+	    }
+	    get selectedIndex() {
+	        return this._selectedIndex;
+	    }
+	    set selectedIndex(value) {
+	        if (this._selectedIndex != value) {
+	            this.setSelect(this._selectedIndex, false);
+	            this._selectedIndex = value;
+	            this.setSelect(value, true);
+	            this.event(Laya.Event.CHANGE);
+	            this.selectHandler && this.selectHandler.runWith(this._selectedIndex);
+	        }
+	    }
+	    setSelect(index, selected) {
+	        if (this._items && index > -1 && index < this._items.length)
+	            this._items[index].selected = selected;
+	    }
+	    get skin() {
+	        return this._skin;
+	    }
+	    set skin(value) {
+	        if (this._skin != value) {
+	            this._skin = value;
+	            if (this._skin && !Laya.Loader.getRes(this._skin)) {
+	                Laya.ILaya.loader.load(this._skin, Laya.Handler.create(this, this._skinLoaded), null, Laya.Loader.IMAGE, 1);
+	            }
+	            else {
+	                this._skinLoaded();
+	            }
+	        }
+	    }
+	    _skinLoaded() {
+	        this._setLabelChanged();
+	        this.event(Laya.Event.LOADED);
+	    }
+	    get labels() {
+	        return this._labels;
+	    }
+	    set labels(value) {
+	        if (this._labels != value) {
+	            this._labels = value;
+	            this.removeChildren();
+	            this._setLabelChanged();
+	            if (this._labels) {
+	                var a = this._labels.split(",");
+	                for (var i = 0, n = a.length; i < n; i++) {
+	                    var item = this.createItem(this._skin, a[i]);
+	                    item.name = "item" + i;
+	                    this.addChild(item);
+	                }
+	            }
+	            this.initItems();
+	        }
+	    }
+	    createItem(skin, label) {
+	        return null;
+	    }
+	    get labelColors() {
+	        return this._labelColors;
+	    }
+	    set labelColors(value) {
+	        if (this._labelColors != value) {
+	            this._labelColors = value;
+	            this._setLabelChanged();
+	        }
+	    }
+	    get labelStroke() {
+	        return this._labelStroke;
+	    }
+	    set labelStroke(value) {
+	        if (this._labelStroke != value) {
+	            this._labelStroke = value;
+	            this._setLabelChanged();
+	        }
+	    }
+	    get labelStrokeColor() {
+	        return this._labelStrokeColor;
+	    }
+	    set labelStrokeColor(value) {
+	        if (this._labelStrokeColor != value) {
+	            this._labelStrokeColor = value;
+	            this._setLabelChanged();
+	        }
+	    }
+	    get strokeColors() {
+	        return this._strokeColors;
+	    }
+	    set strokeColors(value) {
+	        if (this._strokeColors != value) {
+	            this._strokeColors = value;
+	            this._setLabelChanged();
+	        }
+	    }
+	    get labelSize() {
+	        return this._labelSize;
+	    }
+	    set labelSize(value) {
+	        if (this._labelSize != value) {
+	            this._labelSize = value;
+	            this._setLabelChanged();
+	        }
+	    }
+	    get stateNum() {
+	        return this._stateNum;
+	    }
+	    set stateNum(value) {
+	        if (this._stateNum != value) {
+	            this._stateNum = value;
+	            this._setLabelChanged();
+	        }
+	    }
+	    get labelBold() {
+	        return this._labelBold;
+	    }
+	    set labelBold(value) {
+	        if (this._labelBold != value) {
+	            this._labelBold = value;
+	            this._setLabelChanged();
+	        }
+	    }
+	    get labelFont() {
+	        return this._labelFont;
+	    }
+	    set labelFont(value) {
+	        if (this._labelFont != value) {
+	            this._labelFont = value;
+	            this._setLabelChanged();
+	        }
+	    }
+	    get labelPadding() {
+	        return this._labelPadding;
+	    }
+	    set labelPadding(value) {
+	        if (this._labelPadding != value) {
+	            this._labelPadding = value;
+	            this._setLabelChanged();
+	        }
+	    }
+	    get direction() {
+	        return this._direction;
+	    }
+	    set direction(value) {
+	        this._direction = value;
+	        this._setLabelChanged();
+	    }
+	    get space() {
+	        return this._space;
+	    }
+	    set space(value) {
+	        this._space = value;
+	        this._setLabelChanged();
+	    }
+	    changeLabels() {
+	        this._labelChanged = false;
+	        if (this._items) {
+	            var left = 0;
+	            for (var i = 0, n = this._items.length; i < n; i++) {
+	                var btn = this._items[i];
+	                this._skin && (btn.skin = this._skin);
+	                this._labelColors && (btn.labelColors = this._labelColors);
+	                this._labelSize && (btn.labelSize = this._labelSize);
+	                this._labelStroke && (btn.labelStroke = this._labelStroke);
+	                this._labelStrokeColor && (btn.labelStrokeColor = this._labelStrokeColor);
+	                this._strokeColors && (btn.strokeColors = this._strokeColors);
+	                this._labelBold && (btn.labelBold = this._labelBold);
+	                this._labelPadding && (btn.labelPadding = this._labelPadding);
+	                this._labelAlign && (btn.labelAlign = this._labelAlign);
+	                this._stateNum && (btn.stateNum = this._stateNum);
+	                this._labelFont && (btn.labelFont = this._labelFont);
+	                if (this._direction === "horizontal") {
+	                    btn.y = 0;
+	                    btn.x = left;
+	                    left += btn.width + this._space;
+	                }
+	                else {
+	                    btn.x = 0;
+	                    btn.y = left;
+	                    left += btn.height + this._space;
+	                }
+	            }
+	        }
+	        this._sizeChanged();
+	    }
+	    commitMeasure() {
+	        this.runCallLater(this.changeLabels);
+	    }
+	    get items() {
+	        return this._items;
+	    }
+	    get selection() {
+	        return this._selectedIndex > -1 && this._selectedIndex < this._items.length ? this._items[this._selectedIndex] : null;
+	    }
+	    set selection(value) {
+	        this.selectedIndex = this._items.indexOf(value);
+	    }
+	    set dataSource(value) {
+	        this._dataSource = value;
+	        if (typeof (value) == 'number' || typeof (value) == 'string')
+	            this.selectedIndex = parseInt(value);
+	        else if (value instanceof Array)
+	            this.labels = value.join(",");
+	        else
+	            super.dataSource = value;
+	    }
+	    get dataSource() {
+	        return super.dataSource;
+	    }
+	    _setLabelChanged() {
+	        if (!this._labelChanged) {
+	            this._labelChanged = true;
+	            this.callLater(this.changeLabels);
+	        }
+	    }
+	}
+	Laya.ILaya.regClass(UIGroup);
+	Laya.ClassUtils.regClass("laya.ui.UIGroup", UIGroup);
+	Laya.ClassUtils.regClass("Laya.UIGroup", UIGroup);
+
+	class RadioGroup extends UIGroup {
+	    createItem(skin, label) {
+	        return new Radio(skin, label);
+	    }
+	}
+	Laya.ILaya.regClass(RadioGroup);
+	Laya.ClassUtils.regClass("laya.ui.RadioGroup", RadioGroup);
+	Laya.ClassUtils.regClass("Laya.RadioGroup", RadioGroup);
+
+	class Tab extends UIGroup {
+	    createItem(skin, label) {
+	        return new Button(skin, label);
+	    }
+	}
+	Laya.ILaya.regClass(Tab);
+	Laya.ClassUtils.regClass("laya.ui.Tab", Tab);
+	Laya.ClassUtils.regClass("Laya.Tab", Tab);
+
+	class ViewStack extends Box {
+	    constructor() {
+	        super(...arguments);
+	        this._setIndexHandler = Laya.Handler.create(this, this.setIndex, null, false);
+	    }
+	    setItems(views) {
+	        this.removeChildren();
+	        var index = 0;
+	        for (var i = 0, n = views.length; i < n; i++) {
+	            var item = views[i];
+	            if (item) {
+	                item.name = "item" + index;
+	                this.addChild(item);
+	                index++;
+	            }
+	        }
+	        this.initItems();
+	    }
+	    addItem(view) {
+	        view.name = "item" + this._items.length;
+	        this.addChild(view);
+	        this.initItems();
+	    }
+	    _afterInited() {
+	        this.initItems();
+	    }
+	    initItems() {
+	        this._items = [];
+	        for (var i = 0; i < 10000; i++) {
+	            var item = this.getChildByName("item" + i);
+	            if (item == null) {
+	                break;
+	            }
+	            this._items.push(item);
+	            item.visible = (i == this._selectedIndex);
+	        }
+	    }
+	    get selectedIndex() {
+	        return this._selectedIndex;
+	    }
+	    set selectedIndex(value) {
+	        if (this._selectedIndex != value) {
+	            this.setSelect(this._selectedIndex, false);
+	            this._selectedIndex = value;
+	            this.setSelect(this._selectedIndex, true);
+	        }
+	    }
+	    setSelect(index, selected) {
+	        if (this._items && index > -1 && index < this._items.length) {
+	            this._items[index].visible = selected;
+	        }
+	    }
+	    get selection() {
+	        return this._selectedIndex > -1 && this._selectedIndex < this._items.length ? this._items[this._selectedIndex] : null;
+	    }
+	    set selection(value) {
+	        this.selectedIndex = this._items.indexOf(value);
+	    }
+	    get setIndexHandler() {
+	        return this._setIndexHandler;
+	    }
+	    set setIndexHandler(value) {
+	        this._setIndexHandler = value;
+	    }
+	    setIndex(index) {
+	        this.selectedIndex = index;
+	    }
+	    get items() {
+	        return this._items;
+	    }
+	    set dataSource(value) {
+	        this._dataSource = value;
+	        if (typeof (value) == 'number' || typeof (value) == 'string') {
+	            this.selectedIndex = parseInt(value);
+	        }
+	        else {
+	            for (var prop in this._dataSource) {
+	                if (prop in this) {
+	                    this[prop] = this._dataSource[prop];
+	                }
+	            }
+	        }
+	    }
+	    get dataSource() {
+	        return super.dataSource;
+	    }
+	}
+	Laya.ILaya.regClass(ViewStack);
+	Laya.ClassUtils.regClass("laya.ui.ViewStack", ViewStack);
+	Laya.ClassUtils.regClass("Laya.ViewStack", ViewStack);
+
+	class TextInput extends Label {
+	    constructor(text = "") {
+	        super();
+	        this.text = text;
+	        this.skin = this.skin;
+	    }
+	    preinitialize() {
+	        this.mouseEnabled = true;
+	    }
+	    destroy(destroyChild = true) {
+	        super.destroy(destroyChild);
+	        this._bg && this._bg.destroy();
+	        this._bg = null;
+	    }
+	    createChildren() {
+	        this.addChild(this._tf = new Laya.Input());
+	        this._tf.padding = Styles.inputLabelPadding;
+	        this._tf.on(Laya.Event.INPUT, this, this._onInput);
+	        this._tf.on(Laya.Event.ENTER, this, this._onEnter);
+	        this._tf.on(Laya.Event.BLUR, this, this._onBlur);
+	        this._tf.on(Laya.Event.FOCUS, this, this._onFocus);
+	    }
+	    _onFocus() {
+	        this.event(Laya.Event.FOCUS, this);
+	    }
+	    _onBlur() {
+	        this.event(Laya.Event.BLUR, this);
+	    }
+	    _onInput() {
+	        this.event(Laya.Event.INPUT, this);
+	    }
+	    _onEnter() {
+	        this.event(Laya.Event.ENTER, this);
+	    }
+	    initialize() {
+	        this.width = 128;
+	        this.height = 22;
+	    }
+	    get bg() {
+	        return this._bg;
+	    }
+	    set bg(value) {
+	        this.graphics = this._bg = value;
+	    }
+	    get skin() {
+	        return this._skin;
+	    }
+	    set skin(value) {
+	        if (this._skin != value) {
+	            this._skin = value;
+	            if (this._skin && !Laya.Loader.getRes(this._skin)) {
+	                Laya.ILaya.loader.load(this._skin, Laya.Handler.create(this, this._skinLoaded), null, Laya.Loader.IMAGE, 1);
+	            }
+	            else {
+	                this._skinLoaded();
+	            }
+	        }
+	    }
+	    _skinLoaded() {
+	        this._bg || (this.graphics = this._bg = new AutoBitmap());
+	        this._bg.source = Laya.Loader.getRes(this._skin);
+	        this._width && (this._bg.width = this._width);
+	        this._height && (this._bg.height = this._height);
+	        this._sizeChanged();
+	        this.event(Laya.Event.LOADED);
+	    }
+	    get sizeGrid() {
+	        return this._bg && this._bg.sizeGrid ? this._bg.sizeGrid.join(",") : null;
+	    }
+	    set sizeGrid(value) {
+	        this._bg || (this.graphics = this._bg = new AutoBitmap());
+	        this._bg.sizeGrid = UIUtils.fillArray(Styles.defaultSizeGrid, value, Number);
+	    }
+	    set text(value) {
+	        if (this._tf.text != value) {
+	            value = value + "";
+	            this._tf.text = value;
+	            this.event(Laya.Event.CHANGE);
+	        }
+	    }
+	    get text() {
+	        return super.text;
+	    }
+	    set width(value) {
+	        super.width = value;
+	        this._bg && (this._bg.width = value);
+	    }
+	    get width() {
+	        return super.width;
+	    }
+	    set height(value) {
+	        super.height = value;
+	        this._bg && (this._bg.height = value);
+	    }
+	    get height() {
+	        return super.height;
+	    }
+	    get multiline() {
+	        return this._tf.multiline;
+	    }
+	    set multiline(value) {
+	        this._tf.multiline = value;
+	    }
+	    set editable(value) {
+	        this._tf.editable = value;
+	    }
+	    get editable() {
+	        return this._tf.editable;
+	    }
+	    select() {
+	        this._tf.select();
+	    }
+	    get restrict() {
+	        return this._tf.restrict;
+	    }
+	    set restrict(pattern) {
+	        this._tf.restrict = pattern;
+	    }
+	    get prompt() {
+	        return this._tf.prompt;
+	    }
+	    set prompt(value) {
+	        this._tf.prompt = value;
+	    }
+	    get promptColor() {
+	        return this._tf.promptColor;
+	    }
+	    set promptColor(value) {
+	        this._tf.promptColor = value;
+	    }
+	    get maxChars() {
+	        return this._tf.maxChars;
+	    }
+	    set maxChars(value) {
+	        this._tf.maxChars = value;
+	    }
+	    get focus() {
+	        return this._tf.focus;
+	    }
+	    set focus(value) {
+	        this._tf.focus = value;
+	    }
+	    get type() {
+	        return this._tf.type;
+	    }
+	    set type(value) {
+	        this._tf.type = value;
+	    }
+	    setSelection(startIndex, endIndex) {
+	        this._tf.setSelection(startIndex, endIndex);
+	    }
+	}
+	Laya.ILaya.regClass(TextInput);
+	Laya.ClassUtils.regClass("laya.ui.TextInput", TextInput);
+	Laya.ClassUtils.regClass("Laya.TextInput", TextInput);
+
+	class TextArea extends TextInput {
+	    constructor(text = "") {
+	        super(text);
+	        this.on(Laya.Event.CHANGE, this, this._onTextChange);
+	    }
+	    _onTextChange() {
+	        this.callLater(this.changeScroll);
+	    }
+	    destroy(destroyChild = true) {
+	        this._vScrollBar && this._vScrollBar.destroy();
+	        this._hScrollBar && this._hScrollBar.destroy();
+	        this._vScrollBar = null;
+	        this._hScrollBar = null;
+	        super.destroy(destroyChild);
+	    }
+	    initialize() {
+	        this.width = 180;
+	        this.height = 150;
+	        this._tf.wordWrap = true;
+	        this.multiline = true;
+	    }
+	    set width(value) {
+	        super.width = value;
+	        this.callLater(this.changeScroll);
+	    }
+	    get width() {
+	        return super.width;
+	    }
+	    set height(value) {
+	        super.height = value;
+	        this.callLater(this.changeScroll);
+	    }
+	    get height() {
+	        return super.height;
+	    }
+	    get vScrollBarSkin() {
+	        return this._vScrollBar ? this._vScrollBar.skin : null;
+	    }
+	    set vScrollBarSkin(value) {
+	        if (this._vScrollBar == null) {
+	            this.addChild(this._vScrollBar = new VScrollBar());
+	            this._vScrollBar.on(Laya.Event.CHANGE, this, this.onVBarChanged);
+	            this._vScrollBar.target = this._tf;
+	            this.callLater(this.changeScroll);
+	        }
+	        this._vScrollBar.skin = value;
+	    }
+	    get hScrollBarSkin() {
+	        return this._hScrollBar ? this._hScrollBar.skin : null;
+	    }
+	    set hScrollBarSkin(value) {
+	        if (this._hScrollBar == null) {
+	            this.addChild(this._hScrollBar = new HScrollBar());
+	            this._hScrollBar.on(Laya.Event.CHANGE, this, this.onHBarChanged);
+	            this._hScrollBar.mouseWheelEnable = false;
+	            this._hScrollBar.target = this._tf;
+	            this.callLater(this.changeScroll);
+	        }
+	        this._hScrollBar.skin = value;
+	    }
+	    onVBarChanged(e) {
+	        if (this._tf.scrollY != this._vScrollBar.value) {
+	            this._tf.scrollY = this._vScrollBar.value;
+	        }
+	    }
+	    onHBarChanged(e) {
+	        if (this._tf.scrollX != this._hScrollBar.value) {
+	            this._tf.scrollX = this._hScrollBar.value;
+	        }
+	    }
+	    get vScrollBar() {
+	        return this._vScrollBar;
+	    }
+	    get hScrollBar() {
+	        return this._hScrollBar;
+	    }
+	    get maxScrollY() {
+	        return this._tf.maxScrollY;
+	    }
+	    get scrollY() {
+	        return this._tf.scrollY;
+	    }
+	    get maxScrollX() {
+	        return this._tf.maxScrollX;
+	    }
+	    get scrollX() {
+	        return this._tf.scrollX;
+	    }
+	    changeScroll() {
+	        var vShow = this._vScrollBar && this._tf.maxScrollY > 0;
+	        var hShow = this._hScrollBar && this._tf.maxScrollX > 0;
+	        var showWidth = vShow ? this._width - this._vScrollBar.width : this._width;
+	        var showHeight = hShow ? this._height - this._hScrollBar.height : this._height;
+	        var padding = this._tf.padding || Styles.labelPadding;
+	        this._tf.width = showWidth;
+	        this._tf.height = showHeight;
+	        if (this._vScrollBar) {
+	            this._vScrollBar.x = this._width - this._vScrollBar.width - padding[2];
+	            this._vScrollBar.y = padding[1];
+	            this._vScrollBar.height = this._height - (hShow ? this._hScrollBar.height : 0) - padding[1] - padding[3];
+	            this._vScrollBar.scrollSize = 1;
+	            this._vScrollBar.thumbPercent = showHeight / Math.max(this._tf.textHeight, showHeight);
+	            this._vScrollBar.setScroll(1, this._tf.maxScrollY, this._tf.scrollY);
+	            this._vScrollBar.visible = vShow;
+	        }
+	        if (this._hScrollBar) {
+	            this._hScrollBar.x = padding[0];
+	            this._hScrollBar.y = this._height - this._hScrollBar.height - padding[3];
+	            this._hScrollBar.width = this._width - (vShow ? this._vScrollBar.width : 0) - padding[0] - padding[2];
+	            this._hScrollBar.scrollSize = Math.max(showWidth * 0.033, 1);
+	            this._hScrollBar.thumbPercent = showWidth / Math.max(this._tf.textWidth, showWidth);
+	            this._hScrollBar.setScroll(0, this.maxScrollX, this.scrollX);
+	            this._hScrollBar.visible = hShow;
+	        }
+	    }
+	    scrollTo(y) {
+	        this.commitMeasure();
+	        this._tf.scrollY = y;
+	    }
+	}
+	Laya.ILaya.regClass(TextArea);
+	Laya.ClassUtils.regClass("laya.ui.TextArea", TextArea);
+	Laya.ClassUtils.regClass("Laya.TextArea", TextArea);
+
+	class ScaleBox extends Box {
+	    constructor() {
+	        super(...arguments);
+	        this._oldW = 0;
+	        this._oldH = 0;
+	    }
+	    onEnable() {
+	        Laya.ILaya.stage.on("resize", this, this.onResize);
+	        this.onResize();
+	    }
+	    onDisable() {
+	        Laya.ILaya.stage.off("resize", this, this.onResize);
+	    }
+	    onResize() {
+	        let stage = Laya.ILaya.stage;
+	        if (this.width > 0 && this.height > 0) {
+	            var scale = Math.min(stage.width / this._oldW, stage.height / this._oldH);
+	            super.width = stage.width;
+	            super.height = stage.height;
+	            this.scale(scale, scale);
+	        }
+	    }
+	    set width(value) {
+	        super.width = value;
+	        this._oldW = value;
+	    }
+	    get width() {
+	        return super.width;
+	    }
+	    set height(value) {
+	        super.height = value;
+	        this._oldH = value;
+	    }
+	    get height() {
+	        return super.height;
+	    }
+	}
+	Laya.ILaya.regClass(ScaleBox);
+	Laya.ClassUtils.regClass("laya.ui.ScaleBox", ScaleBox);
+	Laya.ClassUtils.regClass("Laya.ScaleBox", ScaleBox);
+
+	class HSlider extends Slider {
+	    constructor(skin = null) {
+	        super(skin);
+	        this.isVertical = false;
+	    }
+	}
+	Laya.ILaya.regClass(HSlider);
+	Laya.ClassUtils.regClass("laya.ui.HSlider", HSlider);
+	Laya.ClassUtils.regClass("Laya.HSlider", HSlider);
+
+	class Panel extends Box {
+	    constructor() {
+	        super();
+	        this._usedCache = null;
+	        this._elasticEnabled = false;
+	        this.width = this.height = 100;
+	    }
+	    destroy(destroyChild = true) {
+	        super.destroy(destroyChild);
+	        this._content && this._content.destroy(destroyChild);
+	        this._vScrollBar && this._vScrollBar.destroy(destroyChild);
+	        this._hScrollBar && this._hScrollBar.destroy(destroyChild);
+	        this._vScrollBar = null;
+	        this._hScrollBar = null;
+	        this._content = null;
+	    }
+	    destroyChildren() {
+	        this._content.destroyChildren();
+	    }
+	    createChildren() {
+	        super.addChild(this._content = new Box());
+	    }
+	    addChild(child) {
+	        child.on(Laya.Event.RESIZE, this, this.onResize);
+	        this._setScrollChanged();
+	        return this._content.addChild(child);
+	    }
+	    onResize() {
+	        this._setScrollChanged();
+	    }
+	    addChildAt(child, index) {
+	        child.on(Laya.Event.RESIZE, this, this.onResize);
+	        this._setScrollChanged();
+	        return this._content.addChildAt(child, index);
+	    }
+	    removeChild(child) {
+	        child.off(Laya.Event.RESIZE, this, this.onResize);
+	        this._setScrollChanged();
+	        return this._content.removeChild(child);
+	    }
+	    removeChildAt(index) {
+	        this.getChildAt(index).off(Laya.Event.RESIZE, this, this.onResize);
+	        this._setScrollChanged();
+	        return this._content.removeChildAt(index);
+	    }
+	    removeChildren(beginIndex = 0, endIndex = 0x7fffffff) {
+	        this._content.removeChildren(beginIndex, endIndex);
+	        this._setScrollChanged();
+	        return this;
+	    }
+	    getChildAt(index) {
+	        return this._content.getChildAt(index);
+	    }
+	    getChildByName(name) {
+	        return this._content.getChildByName(name);
+	    }
+	    getChildIndex(child) {
+	        return this._content.getChildIndex(child);
+	    }
+	    get numChildren() {
+	        return this._content.numChildren;
+	    }
+	    changeScroll() {
+	        this._scrollChanged = false;
+	        var contentW = this.contentWidth || 1;
+	        var contentH = this.contentHeight || 1;
+	        var vscroll = this._vScrollBar;
+	        var hscroll = this._hScrollBar;
+	        var vShow = vscroll && contentH > this._height;
+	        var hShow = hscroll && contentW > this._width;
+	        var showWidth = vShow ? this._width - vscroll.width : this._width;
+	        var showHeight = hShow ? this._height - hscroll.height : this._height;
+	        if (vscroll) {
+	            vscroll.x = this._width - vscroll.width;
+	            vscroll.y = 0;
+	            vscroll.height = this._height - (hShow ? hscroll.height : 0);
+	            vscroll.scrollSize = Math.max(this._height * 0.033, 1);
+	            vscroll.thumbPercent = showHeight / contentH;
+	            vscroll.setScroll(0, contentH - showHeight, vscroll.value);
+	        }
+	        if (hscroll) {
+	            hscroll.x = 0;
+	            hscroll.y = this._height - hscroll.height;
+	            hscroll.width = this._width - (vShow ? vscroll.width : 0);
+	            hscroll.scrollSize = Math.max(this._width * 0.033, 1);
+	            hscroll.thumbPercent = showWidth / contentW;
+	            hscroll.setScroll(0, contentW - showWidth, hscroll.value);
+	        }
+	    }
+	    _sizeChanged() {
+	        super._sizeChanged();
+	        this.setContentSize(this._width, this._height);
+	    }
+	    get contentWidth() {
+	        var max = 0;
+	        for (var i = this._content.numChildren - 1; i > -1; i--) {
+	            var comp = this._content.getChildAt(i);
+	            max = Math.max(comp._x + comp.width * comp.scaleX - comp.pivotX, max);
+	        }
+	        return max;
+	    }
+	    get contentHeight() {
+	        var max = 0;
+	        for (var i = this._content.numChildren - 1; i > -1; i--) {
+	            var comp = this._content.getChildAt(i);
+	            max = Math.max(comp._y + comp.height * comp.scaleY - comp.pivotY, max);
+	        }
+	        return max;
+	    }
+	    setContentSize(width, height) {
+	        var content = this._content;
+	        content.width = width;
+	        content.height = height;
+	        content._style.scrollRect || (content.scrollRect = Laya.Rectangle.create());
+	        content._style.scrollRect.setTo(0, 0, width, height);
+	        content.scrollRect = content.scrollRect;
+	    }
+	    set width(value) {
+	        super.width = value;
+	        this._setScrollChanged();
+	    }
+	    get width() {
+	        return super.width;
+	    }
+	    set height(value) {
+	        super.height = value;
+	        this._setScrollChanged();
+	    }
+	    get height() {
+	        return super.height;
+	    }
+	    get vScrollBarSkin() {
+	        return this._vScrollBar ? this._vScrollBar.skin : null;
+	    }
+	    set vScrollBarSkin(value) {
+	        if (this._vScrollBar == null) {
+	            super.addChild(this._vScrollBar = new VScrollBar());
+	            this._vScrollBar.on(Laya.Event.CHANGE, this, this.onScrollBarChange, [this._vScrollBar]);
+	            this._vScrollBar.target = this._content;
+	            this._vScrollBar.elasticDistance = this._elasticEnabled ? 200 : 0;
+	            this._setScrollChanged();
+	        }
+	        this._vScrollBar.skin = value;
+	    }
+	    get hScrollBarSkin() {
+	        return this._hScrollBar ? this._hScrollBar.skin : null;
+	    }
+	    set hScrollBarSkin(value) {
+	        if (this._hScrollBar == null) {
+	            super.addChild(this._hScrollBar = new HScrollBar());
+	            this._hScrollBar.on(Laya.Event.CHANGE, this, this.onScrollBarChange, [this._hScrollBar]);
+	            this._hScrollBar.target = this._content;
+	            this._hScrollBar.elasticDistance = this._elasticEnabled ? 200 : 0;
+	            this._setScrollChanged();
+	        }
+	        this._hScrollBar.skin = value;
+	    }
+	    get vScrollBar() {
+	        return this._vScrollBar;
+	    }
+	    get hScrollBar() {
+	        return this._hScrollBar;
+	    }
+	    get content() {
+	        return this._content;
+	    }
+	    onScrollBarChange(scrollBar) {
+	        var rect = this._content._style.scrollRect;
+	        if (rect) {
+	            var start = Math.round(scrollBar.value);
+	            scrollBar.isVertical ? rect.y = start : rect.x = start;
+	            this._content.scrollRect = rect;
+	        }
+	    }
+	    scrollTo(x = 0, y = 0) {
+	        if (this.vScrollBar)
+	            this.vScrollBar.value = y;
+	        if (this.hScrollBar)
+	            this.hScrollBar.value = x;
+	    }
+	    refresh() {
+	        this.changeScroll();
+	    }
+	    set cacheAs(value) {
+	        super.cacheAs = value;
+	        this._usedCache = null;
+	        if (value !== "none") {
+	            this._hScrollBar && this._hScrollBar.on(Laya.Event.START, this, this.onScrollStart);
+	            this._vScrollBar && this._vScrollBar.on(Laya.Event.START, this, this.onScrollStart);
+	        }
+	        else {
+	            this._hScrollBar && this._hScrollBar.off(Laya.Event.START, this, this.onScrollStart);
+	            this._vScrollBar && this._vScrollBar.off(Laya.Event.START, this, this.onScrollStart);
+	        }
+	    }
+	    get cacheAs() {
+	        return super.cacheAs;
+	    }
+	    get elasticEnabled() {
+	        return this._elasticEnabled;
+	    }
+	    set elasticEnabled(value) {
+	        this._elasticEnabled = value;
+	        if (this._vScrollBar) {
+	            this._vScrollBar.elasticDistance = value ? 200 : 0;
+	        }
+	        if (this._hScrollBar) {
+	            this._hScrollBar.elasticDistance = value ? 200 : 0;
+	        }
+	    }
+	    onScrollStart() {
+	        this._usedCache || (this._usedCache = super.cacheAs);
+	        super.cacheAs = "none";
+	        this._hScrollBar && this._hScrollBar.once(Laya.Event.END, this, this.onScrollEnd);
+	        this._vScrollBar && this._vScrollBar.once(Laya.Event.END, this, this.onScrollEnd);
+	    }
+	    onScrollEnd() {
+	        super.cacheAs = this._usedCache;
+	    }
+	    _setScrollChanged() {
+	        if (!this._scrollChanged) {
+	            this._scrollChanged = true;
+	            this.callLater(this.changeScroll);
+	        }
+	    }
+	}
+	Laya.ILaya.regClass(Panel);
+	Laya.ClassUtils.regClass("laya.ui.Panel", Panel);
+	Laya.ClassUtils.regClass("Laya.Panel", Panel);
+
+	class VSlider extends Slider {
+	}
+	Laya.ILaya.regClass(VSlider);
+	Laya.ClassUtils.regClass("laya.ui.VSlider", VSlider);
+	Laya.ClassUtils.regClass("Laya.VSlider", VSlider);
+
+	class Tree extends Box {
+	    constructor() {
+	        super();
+	        this._spaceLeft = 10;
+	        this._spaceBottom = 0;
+	        this._keepStatus = true;
+	        this.width = this.height = 200;
+	    }
+	    destroy(destroyChild = true) {
+	        super.destroy(destroyChild);
+	        this._list && this._list.destroy(destroyChild);
+	        this._list = null;
+	        this._source = null;
+	        this._renderHandler = null;
+	    }
+	    createChildren() {
+	        this.addChild(this._list = new List());
+	        this._list.renderHandler = Laya.Handler.create(this, this.renderItem, null, false);
+	        this._list.repeatX = 1;
+	        this._list.on(Laya.Event.CHANGE, this, this.onListChange);
+	    }
+	    onListChange(e = null) {
+	        this.event(Laya.Event.CHANGE);
+	    }
+	    get keepStatus() {
+	        return this._keepStatus;
+	    }
+	    set keepStatus(value) {
+	        this._keepStatus = value;
+	    }
+	    get array() {
+	        return this._list.array;
+	    }
+	    set array(value) {
+	        if (this._keepStatus && this._list.array && value) {
+	            this.parseOpenStatus(this._list.array, value);
+	        }
+	        this._source = value;
+	        this._list.array = this.getArray();
+	    }
+	    get source() {
+	        return this._source;
+	    }
+	    get list() {
+	        return this._list;
+	    }
+	    get itemRender() {
+	        return this._list.itemRender;
+	    }
+	    set itemRender(value) {
+	        this._list.itemRender = value;
+	    }
+	    get scrollBarSkin() {
+	        return this._list.vScrollBarSkin;
+	    }
+	    set scrollBarSkin(value) {
+	        this._list.vScrollBarSkin = value;
+	    }
+	    get scrollBar() {
+	        return this._list.scrollBar;
+	    }
+	    get mouseHandler() {
+	        return this._list.mouseHandler;
+	    }
+	    set mouseHandler(value) {
+	        this._list.mouseHandler = value;
+	    }
+	    get renderHandler() {
+	        return this._renderHandler;
+	    }
+	    set renderHandler(value) {
+	        this._renderHandler = value;
+	    }
+	    get spaceLeft() {
+	        return this._spaceLeft;
+	    }
+	    set spaceLeft(value) {
+	        this._spaceLeft = value;
+	    }
+	    get spaceBottom() {
+	        return this._list.spaceY;
+	    }
+	    set spaceBottom(value) {
+	        this._list.spaceY = value;
+	    }
+	    get selectedIndex() {
+	        return this._list.selectedIndex;
+	    }
+	    set selectedIndex(value) {
+	        this._list.selectedIndex = value;
+	    }
+	    get selectedItem() {
+	        return this._list.selectedItem;
+	    }
+	    set selectedItem(value) {
+	        this._list.selectedItem = value;
+	    }
+	    set width(value) {
+	        super.width = value;
+	        this._list.width = value;
+	    }
+	    get width() {
+	        return super.width;
+	    }
+	    set height(value) {
+	        super.height = value;
+	        this._list.height = value;
+	    }
+	    get height() {
+	        return super.height;
+	    }
+	    getArray() {
+	        var arr = [];
+	        for (let key in this._source) {
+	            let item = this._source[key];
+	            if (this.getParentOpenStatus(item)) {
+	                item.x = this._spaceLeft * this.getDepth(item);
+	                arr.push(item);
+	            }
+	        }
+	        return arr;
+	    }
+	    getDepth(item, num = 0) {
+	        if (item.nodeParent == null)
+	            return num;
+	        else
+	            return this.getDepth(item.nodeParent, num + 1);
+	    }
+	    getParentOpenStatus(item) {
+	        var parent = item.nodeParent;
+	        if (parent == null) {
+	            return true;
+	        }
+	        else {
+	            if (parent.isOpen) {
+	                if (parent.nodeParent != null)
+	                    return this.getParentOpenStatus(parent);
+	                else
+	                    return true;
+	            }
+	            else {
+	                return false;
+	            }
+	        }
+	    }
+	    renderItem(cell, index) {
+	        var item = cell.dataSource;
+	        if (item) {
+	            cell.left = item.x;
+	            var arrow = cell.getChildByName("arrow");
+	            if (arrow) {
+	                if (item.hasChild) {
+	                    arrow.visible = true;
+	                    arrow.index = item.isOpen ? 1 : 0;
+	                    arrow.tag = index;
+	                    arrow.off(Laya.Event.CLICK, this, this.onArrowClick);
+	                    arrow.on(Laya.Event.CLICK, this, this.onArrowClick);
+	                }
+	                else {
+	                    arrow.visible = false;
+	                }
+	            }
+	            var folder = cell.getChildByName("folder");
+	            if (folder) {
+	                if (folder.clipY == 2) {
+	                    folder.index = item.isDirectory ? 0 : 1;
+	                }
+	                else {
+	                    folder.index = item.isDirectory ? item.isOpen ? 1 : 0 : 2;
+	                }
+	            }
+	            this._renderHandler && this._renderHandler.runWith([cell, index]);
+	        }
+	    }
+	    onArrowClick(e) {
+	        var arrow = e.currentTarget;
+	        var index = arrow.tag;
+	        this._list.array[index].isOpen = !this._list.array[index].isOpen;
+	        this.event(Laya.Event.OPEN);
+	        this._list.array = this.getArray();
+	    }
+	    setItemState(index, isOpen) {
+	        if (!this._list.array[index])
+	            return;
+	        this._list.array[index].isOpen = isOpen;
+	        this._list.array = this.getArray();
+	    }
+	    fresh() {
+	        this._list.array = this.getArray();
+	        this.repaint();
+	    }
+	    set dataSource(value) {
+	        this._dataSource = value;
+	        super.dataSource = value;
+	    }
+	    get dataSource() {
+	        return super.dataSource;
+	    }
+	    set xml(value) {
+	        var arr = [];
+	        this.parseXml(value.childNodes[0], arr, null, true);
+	        this.array = arr;
+	    }
+	    parseXml(xml, source, nodeParent, isRoot) {
+	        var obj;
+	        var list = xml.childNodes;
+	        var childCount = list.length;
+	        if (!isRoot) {
+	            obj = {};
+	            var list2 = xml.attributes;
+	            for (let key in list2) {
+	                var attrs = list2[key];
+	                var prop = attrs.nodeName;
+	                var value = attrs.nodeValue;
+	                obj[prop] = value == "true" ? true : value == "false" ? false : value;
+	            }
+	            obj.nodeParent = nodeParent;
+	            if (childCount > 0)
+	                obj.isDirectory = true;
+	            obj.hasChild = childCount > 0;
+	            source.push(obj);
+	        }
+	        for (var i = 0; i < childCount; i++) {
+	            var node = list[i];
+	            this.parseXml(node, source, obj, false);
+	        }
+	    }
+	    parseOpenStatus(oldSource, newSource) {
+	        for (var i = 0, n = newSource.length; i < n; i++) {
+	            var newItem = newSource[i];
+	            if (newItem.isDirectory) {
+	                for (var j = 0, m = oldSource.length; j < m; j++) {
+	                    var oldItem = oldSource[j];
+	                    if (oldItem.isDirectory && this.isSameParent(oldItem, newItem) && newItem.label == oldItem.label) {
+	                        newItem.isOpen = oldItem.isOpen;
+	                        break;
+	                    }
+	                }
+	            }
+	        }
+	    }
+	    isSameParent(item1, item2) {
+	        if (item1.nodeParent == null && item2.nodeParent == null)
+	            return true;
+	        else if (item1.nodeParent == null || item2.nodeParent == null)
+	            return false;
+	        else {
+	            if (item1.nodeParent.label == item2.nodeParent.label)
+	                return this.isSameParent(item1.nodeParent, item2.nodeParent);
+	            else
+	                return false;
+	        }
+	    }
+	    get selectedPath() {
+	        if (this._list.selectedItem) {
+	            return this._list.selectedItem.path;
+	        }
+	        return null;
+	    }
+	    filter(key) {
+	        if (Boolean(key)) {
+	            var result = [];
+	            this.getFilterSource(this._source, result, key);
+	            this._list.array = result;
+	        }
+	        else {
+	            this._list.array = this.getArray();
+	        }
+	    }
+	    getFilterSource(array, result, key) {
+	        key = key.toLocaleLowerCase();
+	        for (let item of array) {
+	            if (!item.isDirectory && String(item.label).toLowerCase().indexOf(key) > -1) {
+	                item.x = 0;
+	                result.push(item);
+	            }
+	            if (item.child && item.child.length > 0) {
+	                this.getFilterSource(item.child, result, key);
+	            }
+	        }
+	    }
+	}
+	Laya.ILaya.regClass(Tree);
+	Laya.ClassUtils.regClass("laya.ui.Tree", Tree);
+	Laya.ClassUtils.regClass("Laya.Tree", Tree);
+
+	class LayoutBox extends Box {
+	    constructor() {
+	        super(...arguments);
+	        this._space = 0;
+	        this._align = "none";
+	        this._itemChanged = false;
+	    }
+	    addChild(child) {
+	        child.on(Laya.Event.RESIZE, this, this.onResize);
+	        this._setItemChanged();
+	        return super.addChild(child);
+	    }
+	    onResize(e) {
+	        this._setItemChanged();
+	    }
+	    addChildAt(child, index) {
+	        child.on(Laya.Event.RESIZE, this, this.onResize);
+	        this._setItemChanged();
+	        return super.addChildAt(child, index);
+	    }
+	    removeChildAt(index) {
+	        this.getChildAt(index).off(Laya.Event.RESIZE, this, this.onResize);
+	        this._setItemChanged();
+	        return super.removeChildAt(index);
+	    }
+	    refresh() {
+	        this._setItemChanged();
+	    }
+	    changeItems() {
+	        this._itemChanged = false;
+	    }
+	    get space() {
+	        return this._space;
+	    }
+	    set space(value) {
+	        this._space = value;
+	        this._setItemChanged();
+	    }
+	    get align() {
+	        return this._align;
+	    }
+	    set align(value) {
+	        this._align = value;
+	        this._setItemChanged();
+	    }
+	    sortItem(items) {
+	        if (items)
+	            items.sort(function (a, b) { return a.y - b.y; });
+	    }
+	    _setItemChanged() {
+	        if (!this._itemChanged) {
+	            this._itemChanged = true;
+	            this.callLater(this.changeItems);
+	        }
+	    }
+	}
+	Laya.ILaya.regClass(LayoutBox);
+	Laya.ClassUtils.regClass("laya.ui.LayoutBox", LayoutBox);
+	Laya.ClassUtils.regClass("Laya.LayoutBox", LayoutBox);
+
+	class HBox extends LayoutBox {
+	    sortItem(items) {
+	        if (items)
+	            items.sort(function (a, b) { return a.x - b.x; });
+	    }
+	    set height(value) {
+	        if (this._height != value) {
+	            super.height = value;
+	            this.callLater(this.changeItems);
+	        }
+	    }
+	    get height() {
+	        return super.height;
+	    }
+	    changeItems() {
+	        this._itemChanged = false;
+	        var items = [];
+	        var maxHeight = 0;
+	        for (var i = 0, n = this.numChildren; i < n; i++) {
+	            var item = this.getChildAt(i);
+	            if (item) {
+	                items.push(item);
+	                maxHeight = this._height ? this._height : Math.max(maxHeight, item.height * item.scaleY);
+	            }
+	        }
+	        this.sortItem(items);
+	        var left = 0;
+	        for (i = 0, n = items.length; i < n; i++) {
+	            item = items[i];
+	            item.x = left;
+	            left += item.width * item.scaleX + this._space;
+	            if (this._align == HBox.TOP) {
+	                item.y = 0;
+	            }
+	            else if (this._align == HBox.MIDDLE) {
+	                item.y = (maxHeight - item.height * item.scaleY) * 0.5;
+	            }
+	            else if (this._align == HBox.BOTTOM) {
+	                item.y = maxHeight - item.height * item.scaleY;
+	            }
+	        }
+	        this._sizeChanged();
+	    }
+	}
+	HBox.NONE = "none";
+	HBox.TOP = "top";
+	HBox.MIDDLE = "middle";
+	HBox.BOTTOM = "bottom";
+	Laya.ILaya.regClass(HBox);
+	Laya.ClassUtils.regClass("laya.ui.HBox", HBox);
+	Laya.ClassUtils.regClass("Laya.HBox", HBox);
+
+	class VBox extends LayoutBox {
+	    set width(value) {
+	        if (this._width != value) {
+	            super.width = value;
+	            this.callLater(this.changeItems);
+	        }
+	    }
+	    get width() {
+	        return super.width;
+	    }
+	    changeItems() {
+	        this._itemChanged = false;
+	        var items = [];
+	        var maxWidth = 0;
+	        for (var i = 0, n = this.numChildren; i < n; i++) {
+	            var item = this.getChildAt(i);
+	            if (item) {
+	                items.push(item);
+	                maxWidth = this._width ? this._width : Math.max(maxWidth, item.width * item.scaleX);
+	            }
+	        }
+	        this.sortItem(items);
+	        var top = 0;
+	        for (i = 0, n = items.length; i < n; i++) {
+	            item = items[i];
+	            item.y = top;
+	            top += item.height * item.scaleY + this._space;
+	            if (this._align == VBox.LEFT) {
+	                item.x = 0;
+	            }
+	            else if (this._align == VBox.CENTER) {
+	                item.x = (maxWidth - item.width * item.scaleX) * 0.5;
+	            }
+	            else if (this._align == VBox.RIGHT) {
+	                item.x = maxWidth - item.width * item.scaleX;
+	            }
+	        }
+	        this._sizeChanged();
+	    }
+	}
+	VBox.NONE = "none";
+	VBox.LEFT = "left";
+	VBox.CENTER = "center";
+	VBox.RIGHT = "right";
+	Laya.ILaya.regClass(VBox);
+	Laya.ClassUtils.regClass("laya.ui.VBox", VBox);
+	Laya.ClassUtils.regClass("Laya.VBox", VBox);
+
+	class FontClip extends Clip {
+	    constructor(skin = null, sheet = null) {
+	        super();
+	        this._valueArr = '';
+	        this._indexMap = null;
+	        this._sheet = null;
+	        this._direction = "horizontal";
+	        this._spaceX = 0;
+	        this._spaceY = 0;
+	        this._align = "left";
+	        this._wordsW = 0;
+	        this._wordsH = 0;
+	        if (skin)
+	            this.skin = skin;
+	        if (sheet)
+	            this.sheet = sheet;
+	    }
+	    createChildren() {
+	        this._bitmap = new AutoBitmap();
+	        this.on(Laya.Event.LOADED, this, this._onClipLoaded);
+	    }
+	    _onClipLoaded() {
+	        this.callLater(this.changeValue);
+	    }
+	    get sheet() {
+	        return this._sheet;
+	    }
+	    set sheet(value) {
+	        value += "";
+	        this._sheet = value;
+	        var arr = value.split(" ");
+	        this._clipX = String(arr[0]).length;
+	        this.clipY = arr.length;
+	        this._indexMap = {};
+	        for (var i = 0; i < this._clipY; i++) {
+	            var line = arr[i].split("");
+	            for (var j = 0, n = line.length; j < n; j++) {
+	                this._indexMap[line[j]] = i * this._clipX + j;
+	            }
+	        }
+	    }
+	    get value() {
+	        if (!this._valueArr)
+	            return "";
+	        return this._valueArr;
+	    }
+	    set value(value) {
+	        value += "";
+	        this._valueArr = value;
+	        this.callLater(this.changeValue);
+	    }
+	    get direction() {
+	        return this._direction;
+	    }
+	    set direction(value) {
+	        this._direction = value;
+	        this.callLater(this.changeValue);
+	    }
+	    get spaceX() {
+	        return this._spaceX;
+	    }
+	    set spaceX(value) {
+	        this._spaceX = value;
+	        if (this._direction === "horizontal")
+	            this.callLater(this.changeValue);
+	    }
+	    get spaceY() {
+	        return this._spaceY;
+	    }
+	    set spaceY(value) {
+	        this._spaceY = value;
+	        if (!(this._direction === "horizontal"))
+	            this.callLater(this.changeValue);
+	    }
+	    set align(v) {
+	        this._align = v;
+	        this.callLater(this.changeValue);
+	    }
+	    get align() {
+	        return this._align;
+	    }
+	    changeValue() {
+	        if (!this._sources)
+	            return;
+	        if (!this._valueArr)
+	            return;
+	        this.graphics.clear(true);
+	        var texture;
+	        texture = this._sources[0];
+	        if (!texture)
+	            return;
+	        var isHorizontal = (this._direction === "horizontal");
+	        if (isHorizontal) {
+	            this._wordsW = this._valueArr.length * (texture.sourceWidth + this.spaceX);
+	            this._wordsH = texture.sourceHeight;
+	        }
+	        else {
+	            this._wordsW = texture.sourceWidth;
+	            this._wordsH = (texture.sourceHeight + this.spaceY) * this._valueArr.length;
+	        }
+	        var dX = 0;
+	        if (this._width) {
+	            switch (this._align) {
+	                case "center":
+	                    dX = 0.5 * (this._width - this._wordsW);
+	                    break;
+	                case "right":
+	                    dX = this._width - this._wordsW;
+	                    break;
+	                default:
+	                    dX = 0;
+	            }
+	        }
+	        for (var i = 0, sz = this._valueArr.length; i < sz; i++) {
+	            var index = this._indexMap[this._valueArr.charAt(i)];
+	            if (!this.sources[index])
+	                continue;
+	            texture = this.sources[index];
+	            if (isHorizontal)
+	                this.graphics.drawImage(texture, dX + i * (texture.sourceWidth + this.spaceX), 0, texture.sourceWidth, texture.sourceHeight);
+	            else
+	                this.graphics.drawImage(texture, 0 + dX, i * (texture.sourceHeight + this.spaceY), texture.sourceWidth, texture.sourceHeight);
+	        }
+	        if (!this._width) {
+	            this._widget.resetLayoutX();
+	            this.callLater(this._sizeChanged);
+	        }
+	        if (!this._height) {
+	            this._widget.resetLayoutY();
+	            this.callLater(this._sizeChanged);
+	        }
+	    }
+	    set width(value) {
+	        super.width = value;
+	        this.callLater(this.changeValue);
+	    }
+	    get width() {
+	        return super.width;
+	    }
+	    set height(value) {
+	        super.height = value;
+	        this.callLater(this.changeValue);
+	    }
+	    get height() {
+	        return super.height;
+	    }
+	    measureWidth() {
+	        return this._wordsW;
+	    }
+	    measureHeight() {
+	        return this._wordsH;
+	    }
+	    destroy(destroyChild = true) {
+	        this._valueArr = null;
+	        this._indexMap = null;
+	        this.graphics.clear(true);
+	        this.removeSelf();
+	        this.off(Laya.Event.LOADED, this, this._onClipLoaded);
+	        super.destroy(destroyChild);
+	    }
+	}
+	Laya.ILaya.regClass(FontClip);
+	Laya.ClassUtils.regClass("laya.ui.FontClip", FontClip);
+	Laya.ClassUtils.regClass("Laya.FontClip", FontClip);
+
+	class View extends Laya.Scene {
+	    constructor() {
+	        super(false);
+	        this._watchMap = {};
+	        this._anchorX = NaN;
+	        this._anchorY = NaN;
+	        this._widget = Widget.EMPTY;
+	        this.createChildren();
+	    }
+	    static __init__() {
+	        Laya.ILaya.ClassUtils.regShortClassName([ViewStack, Button, TextArea, ColorPicker, Box, ScaleBox, CheckBox, Clip, ComboBox, UIComponent,
+	            HScrollBar, HSlider, Image, Label, List, Panel, ProgressBar, Radio, RadioGroup, ScrollBar, Slider, Tab, TextInput, View,
+	            VScrollBar, VSlider, Tree, HBox, VBox, Laya.Animation, Laya.Text, FontClip]);
+	    }
+	    static regComponent(key, compClass) {
+	        Laya.ILaya.ClassUtils.regClass(key, compClass);
+	    }
+	    static regViewRuntime(key, compClass) {
+	        Laya.ILaya.ClassUtils.regClass(key, compClass);
+	    }
+	    static regUI(url, json) {
+	        Laya.ILaya.loader.cacheRes(url, json);
+	    }
+	    destroy(destroyChild = true) {
+	        this._watchMap = null;
+	        super.destroy(destroyChild);
+	    }
+	    changeData(key) {
+	        var arr = this._watchMap[key];
+	        if (!arr)
+	            return;
+	        for (var i = 0, n = arr.length; i < n; i++) {
+	            var watcher = arr[i];
+	            watcher.exe(this);
+	        }
+	    }
+	    get top() {
+	        return this._widget.top;
+	    }
+	    set top(value) {
+	        if (value != this._widget.top) {
+	            this._getWidget().top = value;
+	        }
+	    }
+	    get bottom() {
+	        return this._widget.bottom;
+	    }
+	    set bottom(value) {
+	        if (value != this._widget.bottom) {
+	            this._getWidget().bottom = value;
+	        }
+	    }
+	    get left() {
+	        return this._widget.left;
+	    }
+	    set left(value) {
+	        if (value != this._widget.left) {
+	            this._getWidget().left = value;
+	        }
+	    }
+	    get right() {
+	        return this._widget.right;
+	    }
+	    set right(value) {
+	        if (value != this._widget.right) {
+	            this._getWidget().right = value;
+	        }
+	    }
+	    get centerX() {
+	        return this._widget.centerX;
+	    }
+	    set centerX(value) {
+	        if (value != this._widget.centerX) {
+	            this._getWidget().centerX = value;
+	        }
+	    }
+	    get centerY() {
+	        return this._widget.centerY;
+	    }
+	    set centerY(value) {
+	        if (value != this._widget.centerY) {
+	            this._getWidget().centerY = value;
+	        }
+	    }
+	    get anchorX() {
+	        return this._anchorX;
+	    }
+	    set anchorX(value) {
+	        if (this._anchorX != value) {
+	            this._anchorX = value;
+	            this.callLater(this._sizeChanged);
+	        }
+	    }
+	    get anchorY() {
+	        return this._anchorY;
+	    }
+	    set anchorY(value) {
+	        if (this._anchorY != value) {
+	            this._anchorY = value;
+	            this.callLater(this._sizeChanged);
+	        }
+	    }
+	    _sizeChanged() {
+	        if (!isNaN(this._anchorX))
+	            this.pivotX = this.anchorX * this.width;
+	        if (!isNaN(this._anchorY))
+	            this.pivotY = this.anchorY * this.height;
+	        this.event(Laya.Event.RESIZE);
+	    }
+	    _getWidget() {
+	        this._widget === Widget.EMPTY && (this._widget = this.addComponent(Widget));
+	        return this._widget;
+	    }
+	    loadUI(path) {
+	        var uiView = View.uiMap[path];
+	        View.uiMap && this.createView(uiView);
+	    }
+	    get dataSource() {
+	        return this._dataSource;
+	    }
+	    set dataSource(value) {
+	        this._dataSource = value;
+	        for (var name in value) {
+	            var comp = this.getChildByName(name);
+	            if (comp instanceof UIComponent)
+	                comp.dataSource = value[name];
+	            else if (name in this && !(this[name] instanceof Function))
+	                this[name] = value[name];
+	        }
+	    }
+	}
+	View.uiMap = {};
+	Laya.ILaya.regClass(View);
+	Laya.ClassUtils.regClass("laya.ui.View", View);
+	Laya.ClassUtils.regClass("Laya.View", View);
+
+	class IUI {
+	}
+	IUI.Dialog = null;
+
+	class DialogManager extends Laya.Sprite {
+	    constructor() {
+	        super();
+	        this.maskLayer = new Laya.Sprite();
+	        this.popupEffect = (dialog) => {
+	            dialog.scale(1, 1);
+	            dialog._effectTween = Laya.Tween.from(dialog, { x: Laya.ILaya.stage.width / 2, y: Laya.ILaya.stage.height / 2, scaleX: 0, scaleY: 0 }, 300, Laya.Ease.backOut, Laya.Handler.create(this, this.doOpen, [dialog]), 0, false, false);
+	        };
+	        this.closeEffect = (dialog) => {
+	            dialog._effectTween = Laya.Tween.to(dialog, { x: Laya.ILaya.stage.width / 2, y: Laya.ILaya.stage.height / 2, scaleX: 0, scaleY: 0 }, 300, Laya.Ease.strongOut, Laya.Handler.create(this, this.doClose, [dialog]), 0, false, false);
+	        };
+	        this.popupEffectHandler = new Laya.Handler(this, this.popupEffect);
+	        this.closeEffectHandler = new Laya.Handler(this, this.closeEffect);
+	        this.mouseEnabled = this.maskLayer.mouseEnabled = true;
+	        this.zOrder = 1000;
+	        Laya.ILaya.stage.addChild(this);
+	        Laya.ILaya.stage.on(Laya.Event.RESIZE, this, this._onResize);
+	        if (UIConfig.closeDialogOnSide)
+	            this.maskLayer.on("click", this, this._closeOnSide);
+	        this._onResize(null);
+	    }
+	    _closeOnSide() {
+	        var dialog = this.getChildAt(this.numChildren - 1);
+	        if (dialog instanceof IUI.Dialog)
+	            dialog.close();
+	    }
+	    setLockView(value) {
+	        if (!this.lockLayer) {
+	            this.lockLayer = new Box();
+	            this.lockLayer.mouseEnabled = true;
+	            this.lockLayer.size(Laya.ILaya.stage.width, Laya.ILaya.stage.height);
+	        }
+	        this.lockLayer.removeChildren();
+	        if (value) {
+	            value.centerX = value.centerY = 0;
+	            this.lockLayer.addChild(value);
+	        }
+	    }
+	    _onResize(e = null) {
+	        var width = this.maskLayer.width = Laya.ILaya.stage.width;
+	        var height = this.maskLayer.height = Laya.ILaya.stage.height;
+	        if (this.lockLayer)
+	            this.lockLayer.size(width, height);
+	        this.maskLayer.graphics.clear(true);
+	        this.maskLayer.graphics.drawRect(0, 0, width, height, UIConfig.popupBgColor);
+	        this.maskLayer.alpha = UIConfig.popupBgAlpha;
+	        for (var i = this.numChildren - 1; i > -1; i--) {
+	            var item = this.getChildAt(i);
+	            if (item.isPopupCenter)
+	                this._centerDialog(item);
+	        }
+	    }
+	    _centerDialog(dialog) {
+	        dialog.x = Math.round(((Laya.ILaya.stage.width - dialog.width) >> 1) + dialog.pivotX);
+	        dialog.y = Math.round(((Laya.ILaya.stage.height - dialog.height) >> 1) + dialog.pivotY);
+	    }
+	    open(dialog, closeOther = false, showEffect = false) {
+	        if (closeOther)
+	            this._closeAll();
+	        this._clearDialogEffect(dialog);
+	        if (dialog.isPopupCenter)
+	            this._centerDialog(dialog);
+	        this.addChild(dialog);
+	        if (dialog.isModal || this._getBit(Laya.Const.HAS_ZORDER))
+	            Laya.ILaya.timer.callLater(this, this._checkMask);
+	        if (showEffect && dialog.popupEffect != null)
+	            dialog.popupEffect.runWith(dialog);
+	        else
+	            this.doOpen(dialog);
+	        this.event(Laya.Event.OPEN);
+	    }
+	    _clearDialogEffect(dialog) {
+	        if (dialog._effectTween) {
+	            Laya.Tween.clear(dialog._effectTween);
+	            dialog._effectTween = null;
+	        }
+	    }
+	    doOpen(dialog) {
+	        dialog.onOpened(dialog._param);
+	    }
+	    lock(value) {
+	        if (this.lockLayer) {
+	            if (value)
+	                this.addChild(this.lockLayer);
+	            else
+	                this.lockLayer.removeSelf();
+	        }
+	    }
+	    close(dialog) {
+	        this._clearDialogEffect(dialog);
+	        if (dialog.isShowEffect && dialog.closeEffect != null)
+	            dialog.closeEffect.runWith([dialog]);
+	        else
+	            this.doClose(dialog);
+	        this.event(Laya.Event.CLOSE);
+	    }
+	    doClose(dialog) {
+	        dialog.removeSelf();
+	        dialog.isModal && this._checkMask();
+	        dialog.closeHandler && dialog.closeHandler.runWith(dialog.closeType);
+	        dialog.onClosed(dialog.closeType);
+	        if (dialog.autoDestroyAtClosed)
+	            dialog.destroy();
+	    }
+	    closeAll() {
+	        this._closeAll();
+	        this.event(Laya.Event.CLOSE);
+	    }
+	    _closeAll() {
+	        for (var i = this.numChildren - 1; i > -1; i--) {
+	            var item = this.getChildAt(i);
+	            if (item && item.close != null) {
+	                this.doClose(item);
+	            }
+	        }
+	    }
+	    getDialogsByGroup(group) {
+	        var arr = [];
+	        for (var i = this.numChildren - 1; i > -1; i--) {
+	            var item = this.getChildAt(i);
+	            if (item && item.group === group) {
+	                arr.push(item);
+	            }
+	        }
+	        return arr;
+	    }
+	    closeByGroup(group) {
+	        var arr = [];
+	        for (var i = this.numChildren - 1; i > -1; i--) {
+	            var item = this.getChildAt(i);
+	            if (item && item.group === group) {
+	                item.close();
+	                arr.push(item);
+	            }
+	        }
+	        return arr;
+	    }
+	    _checkMask() {
+	        this.maskLayer.removeSelf();
+	        for (var i = this.numChildren - 1; i > -1; i--) {
+	            var dialog = this.getChildAt(i);
+	            if (dialog && dialog.isModal) {
+	                this.addChildAt(this.maskLayer, i);
+	                return;
+	            }
+	        }
+	    }
+	}
+	Laya.ClassUtils.regClass("laya.ui.DialogManager", DialogManager);
+	Laya.ClassUtils.regClass("Laya.DialogManager", DialogManager);
+
+	class Dialog extends View {
+	    constructor() {
+	        super();
+	        this.isShowEffect = true;
+	        this.isPopupCenter = true;
+	        this.popupEffect = Dialog.manager.popupEffectHandler;
+	        this.closeEffect = Dialog.manager.closeEffectHandler;
+	        this._dealDragArea();
+	        this.on(Laya.Event.CLICK, this, this._onClick);
+	    }
+	    static get manager() {
+	        return Dialog._manager = Dialog._manager || new DialogManager();
+	    }
+	    static set manager(value) {
+	        Dialog._manager = value;
+	    }
+	    _dealDragArea() {
+	        var dragTarget = this.getChildByName("drag");
+	        if (dragTarget) {
+	            this.dragArea = dragTarget._x + "," + dragTarget._y + "," + dragTarget.width + "," + dragTarget.height;
+	            dragTarget.removeSelf();
+	        }
+	    }
+	    get dragArea() {
+	        if (this._dragArea)
+	            return this._dragArea.toString();
+	        return null;
+	    }
+	    set dragArea(value) {
+	        if (value) {
+	            var a = UIUtils.fillArray([0, 0, 0, 0], value, Number);
+	            this._dragArea = new Laya.Rectangle(a[0], a[1], a[2], a[3]);
+	            this.on(Laya.Event.MOUSE_DOWN, this, this._onMouseDown);
+	        }
+	        else {
+	            this._dragArea = null;
+	            this.off(Laya.Event.MOUSE_DOWN, this, this._onMouseDown);
+	        }
+	    }
+	    _onMouseDown(e) {
+	        var point = this.getMousePoint();
+	        if (this._dragArea.contains(point.x, point.y))
+	            this.startDrag();
+	        else
+	            this.stopDrag();
+	    }
+	    _onClick(e) {
+	        var btn = e.target;
+	        if (btn) {
+	            switch (btn.name) {
+	                case Dialog.CLOSE:
+	                case Dialog.CANCEL:
+	                case Dialog.SURE:
+	                case Dialog.NO:
+	                case Dialog.OK:
+	                case Dialog.YES:
+	                    this.close(btn.name);
+	                    return;
+	            }
+	        }
+	    }
+	    open(closeOther = true, param = null) {
+	        this._dealDragArea();
+	        this._param = param;
+	        Dialog.manager.open(this, closeOther, this.isShowEffect);
+	        Dialog.manager.lock(false);
+	    }
+	    close(type = null) {
+	        this.closeType = type;
+	        Dialog.manager.close(this);
+	    }
+	    destroy(destroyChild = true) {
+	        this.closeHandler = null;
+	        this.popupEffect = null;
+	        this.closeEffect = null;
+	        this._dragArea = null;
+	        super.destroy(destroyChild);
+	    }
+	    show(closeOther = false, showEffect = true) {
+	        this._open(false, closeOther, showEffect);
+	    }
+	    popup(closeOther = false, showEffect = true) {
+	        this._open(true, closeOther, showEffect);
+	    }
+	    _open(modal, closeOther, showEffect) {
+	        this.isModal = modal;
+	        this.isShowEffect = showEffect;
+	        Dialog.manager.lock(true);
+	        this.open(closeOther);
+	    }
+	    get isPopup() {
+	        return this.parent != null;
+	    }
+	    set zOrder(value) {
+	        super.zOrder = value;
+	        Dialog.manager._checkMask();
+	    }
+	    get zOrder() {
+	        return super.zOrder;
+	    }
+	    static setLockView(view) {
+	        Dialog.manager.setLockView(view);
+	    }
+	    static lock(value) {
+	        Dialog.manager.lock(value);
+	    }
+	    static closeAll() {
+	        Dialog.manager.closeAll();
+	    }
+	    static getDialogsByGroup(group) {
+	        return Dialog.manager.getDialogsByGroup(group);
+	    }
+	    static closeByGroup(group) {
+	        return Dialog.manager.closeByGroup(group);
+	    }
+	}
+	Dialog.CLOSE = "close";
+	Dialog.CANCEL = "cancel";
+	Dialog.SURE = "sure";
+	Dialog.NO = "no";
+	Dialog.YES = "yes";
+	Dialog.OK = "ok";
+	IUI.Dialog = Dialog;
+	Laya.ILaya.regClass(Dialog);
+	Laya.ClassUtils.regClass("laya.ui.Dialog", Dialog);
+	Laya.ClassUtils.regClass("Laya.Dialog", Dialog);
+
+	class TipManager extends UIComponent {
+	    constructor() {
+	        super();
+	        this._tipBox = new UIComponent();
+	        this._tipBox.addChild(this._tipText = new Laya.Text());
+	        this._tipText.x = this._tipText.y = 5;
+	        this._tipText.color = TipManager.tipTextColor;
+	        this._defaultTipHandler = this._showDefaultTip;
+	        Laya.ILaya.stage.on(UIEvent.SHOW_TIP, this, this._onStageShowTip);
+	        Laya.ILaya.stage.on(UIEvent.HIDE_TIP, this, this._onStageHideTip);
+	        this.zOrder = 1100;
+	    }
+	    _onStageHideTip(e) {
+	        Laya.ILaya.timer.clear(this, this._showTip);
+	        this.closeAll();
+	        this.removeSelf();
+	    }
+	    _onStageShowTip(data) {
+	        Laya.ILaya.timer.once(TipManager.tipDelay, this, this._showTip, [data], true);
+	    }
+	    _showTip(tip) {
+	        if (typeof (tip) == 'string') {
+	            var text = String(tip);
+	            if (Boolean(text)) {
+	                this._defaultTipHandler(text);
+	            }
+	        }
+	        else if (tip instanceof Laya.Handler) {
+	            tip.run();
+	        }
+	        else if (tip instanceof Function) {
+	            tip.apply();
+	        }
+	        {
+	            Laya.ILaya.stage.on(Laya.Event.MOUSE_MOVE, this, this._onStageMouseMove);
+	            Laya.ILaya.stage.on(Laya.Event.MOUSE_DOWN, this, this._onStageMouseDown);
+	        }
+	        this._onStageMouseMove(null);
+	    }
+	    _onStageMouseDown(e) {
+	        this.closeAll();
+	    }
+	    _onStageMouseMove(e) {
+	        this._showToStage(this, TipManager.offsetX, TipManager.offsetY);
+	    }
+	    _showToStage(dis, offX = 0, offY = 0) {
+	        var rec = dis.getBounds();
+	        dis.x = Laya.ILaya.stage.mouseX + offX;
+	        dis.y = Laya.ILaya.stage.mouseY + offY;
+	        if (dis._x + rec.width > Laya.ILaya.stage.width) {
+	            dis.x -= rec.width + offX;
+	        }
+	        if (dis._y + rec.height > Laya.ILaya.stage.height) {
+	            dis.y -= rec.height + offY;
+	        }
+	    }
+	    closeAll() {
+	        Laya.ILaya.timer.clear(this, this._showTip);
+	        Laya.ILaya.stage.off(Laya.Event.MOUSE_MOVE, this, this._onStageMouseMove);
+	        Laya.ILaya.stage.off(Laya.Event.MOUSE_DOWN, this, this._onStageMouseDown);
+	        this.removeChildren();
+	    }
+	    showDislayTip(tip) {
+	        this.addChild(tip);
+	        this._showToStage(this);
+	        Laya.ILaya.stage.addChild(this);
+	    }
+	    _showDefaultTip(text) {
+	        this._tipText.text = text;
+	        var g = this._tipBox.graphics;
+	        g.clear(true);
+	        g.drawRect(0, 0, this._tipText.width + 10, this._tipText.height + 10, TipManager.tipBackColor);
+	        this.addChild(this._tipBox);
+	        this._showToStage(this);
+	        Laya.ILaya.stage.addChild(this);
+	    }
+	    get defaultTipHandler() {
+	        return this._defaultTipHandler;
+	    }
+	    set defaultTipHandler(value) {
+	        this._defaultTipHandler = value;
+	    }
+	}
+	TipManager.offsetX = 10;
+	TipManager.offsetY = 15;
+	TipManager.tipTextColor = "#ffffff";
+	TipManager.tipBackColor = "#111111";
+	TipManager.tipDelay = 200;
+	Laya.ILaya.regClass(TipManager);
+	Laya.ClassUtils.regClass("laya.ui.TipManager", TipManager);
+	Laya.ClassUtils.regClass("Laya.TipManager", TipManager);
+
+	class UILib {
+	    static __init__() {
+	    }
+	}
+
+	class WXOpenDataViewer extends UIComponent {
+	    constructor() {
+	        super();
+	        this._width = this._height = 200;
+	        var tex = new Laya.Texture();
+	        tex.bitmap = new Laya.Texture2D();
+	        this.texture = tex;
+	    }
+	    onEnable() {
+	        this.postMsg({ type: "display", rate: Laya.Laya.stage.frameRate });
+	        if (window.wx && window.sharedCanvas)
+	            Laya.Laya.timer.frameLoop(1, this, this._onLoop);
+	    }
+	    onDisable() {
+	        this.postMsg({ type: "undisplay" });
+	        Laya.Laya.timer.clear(this, this._onLoop);
+	    }
+	    _onLoop() {
+	        this.texture.bitmap.loadImageSource(window.sharedCanvas);
+	    }
+	    set width(value) {
+	        super.width = value;
+	        if (window.sharedCanvas)
+	            window.sharedCanvas.width = value;
+	        this.callLater(this._postMsg);
+	    }
+	    get width() {
+	        return super.width;
+	    }
+	    set height(value) {
+	        super.height = value;
+	        if (window.sharedCanvas)
+	            window.sharedCanvas.height = value;
+	        this.callLater(this._postMsg);
+	    }
+	    get height() {
+	        return super.height;
+	    }
+	    set x(value) {
+	        super.x = value;
+	        this.callLater(this._postMsg);
+	    }
+	    get x() {
+	        return super.x;
+	    }
+	    set y(value) {
+	        super.y = value;
+	        this.callLater(this._postMsg);
+	    }
+	    get y() {
+	        return super.y;
+	    }
+	    _postMsg() {
+	        var mat = new Laya.Matrix();
+	        mat.translate(this.x, this.y);
+	        var stage = Laya.Laya.stage;
+	        mat.scale(stage._canvasTransform.getScaleX() * this.globalScaleX * stage.transform.getScaleX(), stage._canvasTransform.getScaleY() * this.globalScaleY * stage.transform.getScaleY());
+	        this.postMsg({ type: "changeMatrix", a: mat.a, b: mat.b, c: mat.c, d: mat.d, tx: mat.tx, ty: mat.ty, w: this.width, h: this.height });
+	    }
+	    postMsg(msg) {
+	        if (window.wx && window.wx.getOpenDataContext) {
+	            var openDataContext = window.wx.getOpenDataContext();
+	            openDataContext.postMessage(msg);
+	        }
+	    }
+	}
+	Laya.ILaya.regClass(WXOpenDataViewer);
+	Laya.ClassUtils.regClass("laya.ui.WXOpenDataViewer", WXOpenDataViewer);
+	Laya.ClassUtils.regClass("Laya.WXOpenDataViewer", WXOpenDataViewer);
+
+	exports.AdvImage = AdvImage;
+	exports.AutoBitmap = AutoBitmap;
+	exports.Box = Box;
+	exports.Button = Button;
+	exports.CheckBox = CheckBox;
+	exports.Clip = Clip;
+	exports.ColorPicker = ColorPicker;
+	exports.ComboBox = ComboBox;
+	exports.Dialog = Dialog;
+	exports.DialogManager = DialogManager;
+	exports.FontClip = FontClip;
+	exports.HBox = HBox;
+	exports.HScrollBar = HScrollBar;
+	exports.HSlider = HSlider;
+	exports.IUI = IUI;
+	exports.Image = Image;
+	exports.Label = Label;
+	exports.LayoutBox = LayoutBox;
+	exports.List = List;
+	exports.Panel = Panel;
+	exports.ProgressBar = ProgressBar;
+	exports.Radio = Radio;
+	exports.RadioGroup = RadioGroup;
+	exports.ScaleBox = ScaleBox;
+	exports.ScrollBar = ScrollBar;
+	exports.Slider = Slider;
+	exports.Styles = Styles;
+	exports.Tab = Tab;
+	exports.TextArea = TextArea;
+	exports.TextInput = TextInput;
+	exports.TipManager = TipManager;
+	exports.Tree = Tree;
+	exports.UIComponent = UIComponent;
+	exports.UIConfig = UIConfig;
+	exports.UIEvent = UIEvent;
+	exports.UIGroup = UIGroup;
+	exports.UILib = UILib;
+	exports.UIUtils = UIUtils;
+	exports.VBox = VBox;
+	exports.VScrollBar = VScrollBar;
+	exports.VSlider = VSlider;
+	exports.View = View;
+	exports.ViewStack = ViewStack;
+	exports.WXOpenDataViewer = WXOpenDataViewer;
+	exports.Widget = Widget;
+
+}(window.Laya = window.Laya || {}, Laya));

+ 1691 - 0
ShootingSun/bin/libs/laya.vvmini.js

@@ -0,0 +1,1691 @@
+window.vvMiniGame = function (exports, Laya) {
+	'use strict';
+
+	class MiniFileMgr {
+	    static isLocalNativeFile(url) {
+	        for (var i = 0, sz = VVMiniAdapter.nativefiles.length; i < sz; i++) {
+	            if (url.indexOf(VVMiniAdapter.nativefiles[i]) != -1)
+	                return true;
+	        }
+	        return false;
+	    }
+	    static getFileInfo(fileUrl) {
+	        var fileNativePath = fileUrl;
+	        var fileObj = MiniFileMgr.fakeObj[fileNativePath];
+	        if (fileObj == null)
+	            return null;
+	        else
+	            return fileObj;
+	        return null;
+	    }
+	    static read(filePath, encoding = "utf8", callBack = null, readyUrl = "", isSaveFile = false, fileType = "") {
+	        var fileUrl;
+	        if (readyUrl != "" && (readyUrl.indexOf("http://") != -1 || readyUrl.indexOf("https://") != -1)) {
+	            fileUrl = MiniFileMgr.getFileNativePath(filePath);
+	        }
+	        else {
+	            fileUrl = filePath;
+	        }
+	        fileUrl = Laya.URL.getAdptedFilePath(fileUrl);
+	        MiniFileMgr.fs.readFile({ uri: fileUrl, encoding: encoding, success: function (data) {
+	                if (!data.data)
+	                    data.data = data.text;
+	                callBack != null && callBack.runWith([0, data]);
+	            }, fail: function (data) {
+	                if (data && readyUrl != "")
+	                    MiniFileMgr.downFiles(readyUrl, encoding, callBack, readyUrl, isSaveFile, fileType);
+	                else
+	                    callBack != null && callBack.runWith([1]);
+	            } });
+	    }
+	    static downFiles(fileUrl, encoding = "utf8", callBack = null, readyUrl = "", isSaveFile = false, fileType = "", isAutoClear = true) {
+	        var downloadTask = MiniFileMgr.wxdown({ url: fileUrl, success: function (data) {
+	                if (data.errCode == 0)
+	                    data.statusCode = 200;
+	                if (data.statusCode === 200)
+	                    MiniFileMgr.readFile(data.tempFilePath, encoding, callBack, readyUrl, isSaveFile, fileType, isAutoClear);
+	                else if (data.statusCode === 403) {
+	                    callBack != null && callBack.runWith([0, fileUrl]);
+	                }
+	                else {
+	                    callBack != null && callBack.runWith([1, data]);
+	                }
+	            }, fail: function (data) {
+	                callBack != null && callBack.runWith([1, data]);
+	            } });
+	        downloadTask.onProgressUpdate(function (data) {
+	            callBack != null && callBack.runWith([2, data.progress]);
+	        });
+	    }
+	    static readFile(filePath, encoding = "utf8", callBack = null, readyUrl = "", isSaveFile = false, fileType = "", isAutoClear = true) {
+	        filePath = Laya.URL.getAdptedFilePath(filePath);
+	        MiniFileMgr.fs.readFile({ uri: filePath, encoding: encoding, success: function (data) {
+	                if (filePath.indexOf(VVMiniAdapter.window.qg.env.USER_DATA_PATH) == -1 && (filePath.indexOf("http://") != -1 || filePath.indexOf("https://") != -1)) {
+	                    if (VVMiniAdapter.autoCacheFile || isSaveFile) {
+	                        if (!data.data)
+	                            data.data = data.text;
+	                        callBack != null && callBack.runWith([0, data]);
+	                        MiniFileMgr.copyFile(filePath, readyUrl, null, encoding, isAutoClear);
+	                    }
+	                    else {
+	                        if (!data.data)
+	                            data.data = data.text;
+	                        callBack != null && callBack.runWith([0, data]);
+	                    }
+	                }
+	                else {
+	                    if (!data.data)
+	                        data.data = data.text;
+	                    callBack != null && callBack.runWith([0, data]);
+	                }
+	            }, fail: function (data) {
+	                if (data)
+	                    callBack != null && callBack.runWith([1, data]);
+	            } });
+	    }
+	    static downOtherFiles(fileUrl, callBack = null, readyUrl = "", isSaveFile = false, isAutoClear = true) {
+	        MiniFileMgr.wxdown({ url: fileUrl, success: function (data) {
+	                if (data.errCode == 0)
+	                    data.statusCode = 200;
+	                if (data.statusCode === 200) {
+	                    if ((VVMiniAdapter.autoCacheFile || isSaveFile) && readyUrl.indexOf(".php") == -1) {
+	                        callBack != null && callBack.runWith([0, data.tempFilePath]);
+	                        MiniFileMgr.copyFile(data.tempFilePath, readyUrl, null, "", isAutoClear);
+	                    }
+	                    else
+	                        callBack != null && callBack.runWith([0, data.tempFilePath]);
+	                }
+	                else {
+	                    callBack != null && callBack.runWith([1, data]);
+	                }
+	            }, fail: function (data) {
+	                callBack != null && callBack.runWith([1, data]);
+	            } });
+	    }
+	    static downLoadFile(fileUrl, fileType = "", callBack = null, encoding = "utf8") {
+	        if (VVMiniAdapter.window.navigator.userAgent.indexOf('VVGame') < 0) {
+	            Laya.Laya.loader.load(fileUrl, callBack);
+	        }
+	        else {
+	            if (fileType == Laya.Loader.IMAGE || fileType == Laya.Loader.SOUND)
+	                MiniFileMgr.downOtherFiles(fileUrl, callBack, fileUrl, true, false);
+	            else
+	                MiniFileMgr.downFiles(fileUrl, encoding, callBack, fileUrl, true, fileType, false);
+	        }
+	    }
+	    static copyFile(tempFilePath, readyUrl, callBack, encoding = "", isAutoClear = true) {
+	        var temp = tempFilePath.split("/");
+	        var tempFileName = temp[temp.length - 1];
+	        var fileurlkey = readyUrl;
+	        var fileObj = MiniFileMgr.getFileInfo(readyUrl);
+	        var saveFilePath = MiniFileMgr.getFileNativePath(tempFileName);
+	        MiniFileMgr.fakeObj[fileurlkey] = { md5: tempFileName, readyUrl: readyUrl, size: 0, times: Laya.Browser.now(), encoding: encoding };
+	        var totalSize = 50 * 1024 * 1024;
+	        var chaSize = 4 * 1024 * 1024;
+	        var fileUseSize = MiniFileMgr.getCacheUseSize();
+	        if (fileObj) {
+	            if (fileObj.readyUrl != readyUrl) {
+	                MiniFileMgr.fs.getFileInfo({
+	                    uri: tempFilePath,
+	                    success: function (data) {
+	                        if (data.length)
+	                            data.size = data.length;
+	                        if ((isAutoClear && (fileUseSize + chaSize + data.size) >= totalSize)) {
+	                            if (data.size > VVMiniAdapter.minClearSize)
+	                                VVMiniAdapter.minClearSize = data.size;
+	                            MiniFileMgr.onClearCacheRes();
+	                        }
+	                        MiniFileMgr.deleteFile(tempFilePath, readyUrl, callBack, encoding, data.size);
+	                    },
+	                    fail: function (data) {
+	                        callBack != null && callBack.runWith([1, data]);
+	                    }
+	                });
+	            }
+	            else
+	                callBack != null && callBack.runWith([0]);
+	        }
+	        else {
+	            MiniFileMgr.fs.getFileInfo({
+	                uri: tempFilePath,
+	                success: function (data) {
+	                    if (data.length)
+	                        data.size = data.length;
+	                    if ((isAutoClear && (fileUseSize + chaSize + data.size) >= totalSize)) {
+	                        if (data.size > VVMiniAdapter.minClearSize)
+	                            VVMiniAdapter.minClearSize = data.size;
+	                        MiniFileMgr.onClearCacheRes();
+	                    }
+	                    MiniFileMgr.fs.copyFile({ srcUri: tempFilePath, dstUri: saveFilePath, success: function (data2) {
+	                            MiniFileMgr.onSaveFile(readyUrl, tempFileName, true, encoding, callBack, data.size);
+	                        }, fail: function (data) {
+	                            callBack != null && callBack.runWith([1, data]);
+	                        } });
+	                },
+	                fail: function (data) {
+	                    callBack != null && callBack.runWith([1, data]);
+	                }
+	            });
+	        }
+	    }
+	    static onClearCacheRes() {
+	        var memSize = VVMiniAdapter.minClearSize;
+	        var tempFileListArr = [];
+	        for (var key in MiniFileMgr.filesListObj) {
+	            if (key != "fileUsedSize")
+	                tempFileListArr.push(MiniFileMgr.filesListObj[key]);
+	        }
+	        MiniFileMgr.sortOn(tempFileListArr, "times", MiniFileMgr.NUMERIC);
+	        var clearSize = 0;
+	        for (var i = 1, sz = tempFileListArr.length; i < sz; i++) {
+	            var fileObj = tempFileListArr[i];
+	            if (clearSize >= memSize)
+	                break;
+	            clearSize += fileObj.size;
+	            MiniFileMgr.deleteFile("", fileObj.readyUrl);
+	        }
+	    }
+	    static sortOn(array, name, options = 0) {
+	        if (options == MiniFileMgr.NUMERIC)
+	            return array.sort(function (a, b) { return a[name] - b[name]; });
+	        if (options == (MiniFileMgr.NUMERIC | MiniFileMgr.DESCENDING))
+	            return array.sort(function (a, b) { return b[name] - a[name]; });
+	        return array.sort(function (a, b) { return a[name] - b[name]; });
+	    }
+	    static getFileNativePath(fileName) {
+	        return MiniFileMgr.fileNativeDir + "/" + fileName;
+	    }
+	    static deleteFile(tempFileName, readyUrl = "", callBack = null, encoding = "", fileSize = 0) {
+	        var fileObj = MiniFileMgr.getFileInfo(readyUrl);
+	        var deleteFileUrl = MiniFileMgr.getFileNativePath(fileObj.md5);
+	        var isAdd = tempFileName != "" ? true : false;
+	        MiniFileMgr.onSaveFile(readyUrl, tempFileName, isAdd, encoding, callBack, fileSize);
+	        MiniFileMgr.fs.deleteFile({ uri: deleteFileUrl, success: function (data) {
+	                if (tempFileName != "") {
+	                    var saveFilePath = MiniFileMgr.getFileNativePath(tempFileName);
+	                    MiniFileMgr.fs.copyFile({ srcUri: tempFileName, dstUri: saveFilePath, success: function (data) {
+	                        }, fail: function (data) {
+	                            callBack != null && callBack.runWith([1, data]);
+	                        } });
+	                }
+	            }, fail: function (data) {
+	            } });
+	    }
+	    static deleteAll() {
+	        var tempFileListArr = [];
+	        for (var key in MiniFileMgr.filesListObj) {
+	            if (key != "fileUsedSize")
+	                tempFileListArr.push(MiniFileMgr.filesListObj[key]);
+	        }
+	        for (var i = 1, sz = tempFileListArr.length; i < sz; i++) {
+	            var fileObj = tempFileListArr[i];
+	            MiniFileMgr.deleteFile("", fileObj.readyUrl);
+	        }
+	        if (MiniFileMgr.filesListObj && MiniFileMgr.filesListObj.fileUsedSize) {
+	            MiniFileMgr.filesListObj.fileUsedSize = 0;
+	        }
+	        MiniFileMgr.writeFilesList("", JSON.stringify({}), false);
+	    }
+	    static onSaveFile(readyUrl, md5Name, isAdd = true, encoding = "", callBack = null, fileSize = 0) {
+	        var fileurlkey = readyUrl;
+	        if (MiniFileMgr.filesListObj['fileUsedSize'] == null)
+	            MiniFileMgr.filesListObj['fileUsedSize'] = 0;
+	        if (isAdd) {
+	            var fileNativeName = MiniFileMgr.getFileNativePath(md5Name);
+	            MiniFileMgr.filesListObj[fileurlkey] = { md5: md5Name, readyUrl: readyUrl, size: fileSize, times: Laya.Browser.now(), encoding: encoding };
+	            MiniFileMgr.filesListObj['fileUsedSize'] = parseInt(MiniFileMgr.filesListObj['fileUsedSize']) + fileSize;
+	            MiniFileMgr.writeFilesList(fileurlkey, JSON.stringify(MiniFileMgr.filesListObj), true);
+	            callBack != null && callBack.runWith([0]);
+	        }
+	        else {
+	            if (MiniFileMgr.filesListObj[fileurlkey]) {
+	                var deletefileSize = parseInt(MiniFileMgr.filesListObj[fileurlkey].size);
+	                MiniFileMgr.filesListObj['fileUsedSize'] = parseInt(MiniFileMgr.filesListObj['fileUsedSize']) - deletefileSize;
+	                delete MiniFileMgr.filesListObj[fileurlkey];
+	                MiniFileMgr.writeFilesList(fileurlkey, JSON.stringify(MiniFileMgr.filesListObj), false);
+	                callBack != null && callBack.runWith([0]);
+	            }
+	        }
+	    }
+	    static writeFilesList(fileurlkey, filesListStr, isAdd) {
+	        var listFilesPath = MiniFileMgr.fileNativeDir + "/" + MiniFileMgr.fileListName;
+	        MiniFileMgr.fs.writeFile({ uri: listFilesPath, encoding: 'utf8', data: filesListStr, text: filesListStr, success: function (data) {
+	            }, fail: function (data) {
+	            } });
+	        if (!VVMiniAdapter.isZiYu && VVMiniAdapter.isPosMsgYu && VVMiniAdapter.window.qg.postMessage) {
+	            VVMiniAdapter.window.qg.postMessage({ url: fileurlkey, data: MiniFileMgr.filesListObj[fileurlkey], isLoad: "filenative", isAdd: isAdd });
+	        }
+	    }
+	    static getCacheUseSize() {
+	        if (MiniFileMgr.filesListObj && MiniFileMgr.filesListObj['fileUsedSize'])
+	            return MiniFileMgr.filesListObj['fileUsedSize'];
+	        return 0;
+	    }
+	    static existDir(dirPath, callBack) {
+	        MiniFileMgr.fs.mkdir({ uri: dirPath, success: function (data) {
+	                callBack != null && callBack.runWith([0, { data: JSON.stringify({}) }]);
+	            }, fail: function (data2, code) {
+	                if (code == 300) {
+	                    var data = {};
+	                    data.errMsg = "file already exists";
+	                }
+	                if (data.errMsg.indexOf("file already exists") != -1)
+	                    MiniFileMgr.readSync(MiniFileMgr.fileListName, "utf8", callBack);
+	                else
+	                    callBack != null && callBack.runWith([1, data]);
+	            } });
+	    }
+	    static readSync(filePath, encoding = "utf8", callBack = null, readyUrl = "") {
+	        var fileUrl = MiniFileMgr.getFileNativePath(filePath);
+	        var filesListStr;
+	        try {
+	            filesListStr = MiniFileMgr.fs.readFileSync({ uri: fileUrl, encoding: encoding });
+	            if (filesListStr.indexOf("No such file or directory") != -1) {
+	                filesListStr = JSON.stringify({});
+	            }
+	            callBack != null && callBack.runWith([0, { data: filesListStr }]);
+	        }
+	        catch (error) {
+	            callBack != null && callBack.runWith([1]);
+	        }
+	    }
+	    static setNativeFileDir(value) {
+	        MiniFileMgr.fileNativeDir = VVMiniAdapter.window.qg.env.USER_DATA_PATH + value;
+	    }
+	}
+	MiniFileMgr.fs = window.qg.getFileSystemManager ? window.qg.getFileSystemManager() : window.qg;
+	MiniFileMgr.wxdown = window.qg.download;
+	MiniFileMgr.filesListObj = {};
+	MiniFileMgr.fakeObj = {};
+	MiniFileMgr.fileListName = "layaairfiles.txt";
+	MiniFileMgr.ziyuFileData = {};
+	MiniFileMgr.ziyuFileTextureData = {};
+	MiniFileMgr.loadPath = "";
+	MiniFileMgr.DESCENDING = 2;
+	MiniFileMgr.NUMERIC = 16;
+
+	class MiniSoundChannel extends Laya.SoundChannel {
+	    constructor(audio, miniSound) {
+	        super();
+	        this._audio = audio;
+	        this._miniSound = miniSound;
+	        this._onEnd = MiniSoundChannel.bindToThis(this.__onEnd, this);
+	        audio.onEnded(this._onEnd);
+	    }
+	    static bindToThis(fun, scope) {
+	        var rst = fun;
+	        rst = fun.bind(scope);
+	        return rst;
+	    }
+	    __onEnd() {
+	        if (this.loops == 1) {
+	            if (this.completeHandler) {
+	                Laya.Laya.systemTimer.once(10, this, this.__runComplete, [this.completeHandler], false);
+	                this.completeHandler = null;
+	            }
+	            this.stop();
+	            this.event(Laya.Event.COMPLETE);
+	            return;
+	        }
+	        if (this.loops > 0) {
+	            this.loops--;
+	        }
+	        this.startTime = 0;
+	        this.play();
+	    }
+	    play() {
+	        this.isStopped = false;
+	        Laya.SoundManager.addChannel(this);
+	        this._audio.play();
+	    }
+	    set startTime(time) {
+	        if (this._audio) {
+	            this._audio.startTime = time;
+	        }
+	    }
+	    set autoplay(value) {
+	        this._audio.autoplay = value;
+	    }
+	    get autoplay() {
+	        return this._audio.autoplay;
+	    }
+	    get position() {
+	        if (!this._audio)
+	            return 0;
+	        return this._audio.currentTime;
+	    }
+	    get duration() {
+	        if (!this._audio)
+	            return 0;
+	        return this._audio.duration;
+	    }
+	    stop() {
+	        this.isStopped = true;
+	        Laya.SoundManager.removeChannel(this);
+	        this.completeHandler = null;
+	        if (!this._audio)
+	            return;
+	        this._audio.stop();
+	        if (!this.loop) {
+	            this._audio.offEnded(null);
+	            this._miniSound.dispose();
+	            this._audio = null;
+	            this._miniSound = null;
+	            this._onEnd = null;
+	        }
+	    }
+	    pause() {
+	        this.isStopped = true;
+	        this._audio.pause();
+	    }
+	    get loop() {
+	        return this._audio.loop;
+	    }
+	    set loop(value) {
+	        this._audio.loop = value;
+	    }
+	    resume() {
+	        if (!this._audio)
+	            return;
+	        this.isStopped = false;
+	        Laya.SoundManager.addChannel(this);
+	        this._audio.play();
+	    }
+	    set volume(v) {
+	        if (!this._audio)
+	            return;
+	        this._audio.volume = v;
+	    }
+	    get volume() {
+	        if (!this._audio)
+	            return 1;
+	        return this._audio.volume;
+	    }
+	}
+
+	class MiniSound extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	        this.loaded = false;
+	    }
+	    static _createSound() {
+	        MiniSound._id++;
+	        return VVMiniAdapter.window.qg.createInnerAudioContext();
+	    }
+	    load(url) {
+	        if (!MiniSound._musicAudio)
+	            MiniSound._musicAudio = MiniSound._createSound();
+	        if (!MiniFileMgr.isLocalNativeFile(url)) {
+	            url = Laya.URL.formatURL(url);
+	        }
+	        else {
+	            if (url.indexOf("http://") != -1 || url.indexOf("https://") != -1) {
+	                if (MiniFileMgr.loadPath != "") {
+	                    url = url.split(MiniFileMgr.loadPath)[1];
+	                }
+	                else {
+	                    var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    if (tempStr != "")
+	                        url = url.split(tempStr)[1];
+	                }
+	            }
+	        }
+	        this.url = url;
+	        this.readyUrl = url;
+	        if (MiniSound._audioCache[this.readyUrl]) {
+	            this.event(Laya.Event.COMPLETE);
+	            return;
+	        }
+	        if (VVMiniAdapter.autoCacheFile && MiniFileMgr.getFileInfo(url)) {
+	            this.onDownLoadCallBack(url, 0);
+	        }
+	        else {
+	            if (!VVMiniAdapter.autoCacheFile) {
+	                this.onDownLoadCallBack(url, 0);
+	            }
+	            else {
+	                if (MiniFileMgr.isLocalNativeFile(url)) {
+	                    tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    var tempUrl = url;
+	                    if (tempStr != "")
+	                        url = url.split(tempStr)[1];
+	                    if (!url) {
+	                        url = tempUrl;
+	                    }
+	                    if (VVMiniAdapter.subNativeFiles && VVMiniAdapter.subNativeheads.length == 0) {
+	                        for (var key in VVMiniAdapter.subNativeFiles) {
+	                            var tempArr = VVMiniAdapter.subNativeFiles[key];
+	                            VVMiniAdapter.subNativeheads = VVMiniAdapter.subNativeheads.concat(tempArr);
+	                            for (var aa = 0; aa < tempArr.length; aa++) {
+	                                VVMiniAdapter.subMaps[tempArr[aa]] = key + "/" + tempArr[aa];
+	                            }
+	                        }
+	                    }
+	                    if (VVMiniAdapter.subNativeFiles && url.indexOf("/") != -1) {
+	                        var curfileHead = url.split("/")[0] + "/";
+	                        if (curfileHead && VVMiniAdapter.subNativeheads.indexOf(curfileHead) != -1) {
+	                            var newfileHead = VVMiniAdapter.subMaps[curfileHead];
+	                            url = url.replace(curfileHead, newfileHead);
+	                        }
+	                    }
+	                    this.onDownLoadCallBack(url, 0);
+	                }
+	                else {
+	                    if (!MiniFileMgr.isLocalNativeFile(url) && (url.indexOf("http://") == -1 && url.indexOf("https://") == -1) || (url.indexOf("http://usr/") != -1)) {
+	                        this.onDownLoadCallBack(url, 0);
+	                    }
+	                    else {
+	                        MiniFileMgr.downOtherFiles(encodeURI(url), Laya.Handler.create(this, this.onDownLoadCallBack, [url]), url);
+	                    }
+	                }
+	            }
+	        }
+	    }
+	    onDownLoadCallBack(sourceUrl, errorCode, tempFilePath = null) {
+	        if (!errorCode) {
+	            var fileNativeUrl;
+	            if (VVMiniAdapter.autoCacheFile) {
+	                if (!tempFilePath) {
+	                    if (MiniFileMgr.isLocalNativeFile(sourceUrl)) {
+	                        var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                        var tempUrl = sourceUrl;
+	                        if (tempStr != "" && (sourceUrl.indexOf("http://") != -1 || sourceUrl.indexOf("https://") != -1))
+	                            fileNativeUrl = sourceUrl.split(tempStr)[1];
+	                        if (!fileNativeUrl) {
+	                            fileNativeUrl = tempUrl;
+	                        }
+	                    }
+	                    else {
+	                        var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                        if (fileObj && fileObj.md5) {
+	                            var fileMd5Name = fileObj.md5;
+	                            fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                        }
+	                        else {
+	                            fileNativeUrl = sourceUrl;
+	                        }
+	                    }
+	                }
+	                else {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	                if (this.url != Laya.SoundManager._bgMusic) {
+	                    this._sound = MiniSound._createSound();
+	                    this._sound.src = this.url = fileNativeUrl;
+	                }
+	                else {
+	                    this._sound = MiniSound._musicAudio;
+	                    this._sound.src = this.url = fileNativeUrl;
+	                }
+	            }
+	            else {
+	                if (this.url != Laya.SoundManager._bgMusic) {
+	                    this._sound = MiniSound._createSound();
+	                    this._sound.src = sourceUrl;
+	                }
+	                else {
+	                    this._sound = MiniSound._musicAudio;
+	                    this._sound.src = sourceUrl;
+	                }
+	            }
+	            if (this._sound.onCanplay) {
+	                this._sound.onCanplay(MiniSound.bindToThis(this.onCanPlay, this));
+	                this._sound.onError(MiniSound.bindToThis(this.onError, this));
+	            }
+	            else {
+	                Laya.Laya.timer.clear(this, this.onCheckComplete);
+	                Laya.Laya.timer.frameLoop(2, this, this.onCheckComplete);
+	            }
+	        }
+	        else {
+	            this.event(Laya.Event.ERROR);
+	        }
+	    }
+	    onCheckComplete() {
+	        if (this._sound && this._sound.duration && this._sound.duration > 0) {
+	            this.onCanPlay();
+	        }
+	        Laya.Laya.timer.clear(this, this.onCheckComplete);
+	    }
+	    onError(error) {
+	        try {
+	            console.log("-----1---------------minisound-----id:" + MiniSound._id);
+	            console.log(error);
+	        }
+	        catch (error) {
+	            console.log("-----2---------------minisound-----id:" + MiniSound._id);
+	            console.log(error);
+	        }
+	        this.event(Laya.Event.ERROR);
+	        this._sound.offError(null);
+	    }
+	    onCanPlay() {
+	        this.loaded = true;
+	        this.event(Laya.Event.COMPLETE);
+	        if (this._sound.offCanpla) {
+	            this._sound.offCanplay(null);
+	        }
+	    }
+	    static bindToThis(fun, scope) {
+	        var rst = fun;
+	        rst = fun.bind(scope);
+	        return rst;
+	    }
+	    play(startTime = 0, loops = 0) {
+	        var tSound;
+	        if (this.url == Laya.SoundManager._bgMusic) {
+	            if (!MiniSound._musicAudio)
+	                MiniSound._musicAudio = MiniSound._createSound();
+	            tSound = MiniSound._musicAudio;
+	        }
+	        else {
+	            if (MiniSound._audioCache[this.readyUrl]) {
+	                tSound = MiniSound._audioCache[this.readyUrl]._sound;
+	            }
+	            else {
+	                tSound = MiniSound._createSound();
+	            }
+	        }
+	        if (!tSound)
+	            return null;
+	        if (VVMiniAdapter.autoCacheFile && MiniFileMgr.getFileInfo(this.url)) {
+	            var fileObj = MiniFileMgr.getFileInfo(this.url);
+	            var fileMd5Name = fileObj.md5;
+	            tSound.src = this.url = MiniFileMgr.getFileNativePath(fileMd5Name);
+	        }
+	        else {
+	            tSound.src = encodeURI(this.url);
+	        }
+	        var channel = new MiniSoundChannel(tSound, this);
+	        channel.url = this.url;
+	        channel.loops = loops;
+	        channel.loop = (loops === 0 ? true : false);
+	        channel.startTime = startTime;
+	        channel.play();
+	        Laya.SoundManager.addChannel(channel);
+	        return channel;
+	    }
+	    get duration() {
+	        return this._sound.duration;
+	    }
+	    dispose() {
+	        var ad = MiniSound._audioCache[this.readyUrl];
+	        if (ad) {
+	            ad.src = "";
+	            if (ad._sound) {
+	                ad._sound.destroy();
+	                ad._sound = null;
+	                ad = null;
+	            }
+	            delete MiniSound._audioCache[this.readyUrl];
+	        }
+	        if (this._sound) {
+	            this._sound.destroy();
+	            this._sound = null;
+	            this.readyUrl = this.url = null;
+	        }
+	    }
+	}
+	MiniSound._id = 0;
+	MiniSound._audioCache = {};
+
+	class MiniInput {
+	    constructor() {
+	    }
+	    static _createInputElement() {
+	        Laya.Input['_initInput'](Laya.Input['area'] = Laya.Browser.createElement("textarea"));
+	        Laya.Input['_initInput'](Laya.Input['input'] = Laya.Browser.createElement("input"));
+	        Laya.Input['inputContainer'] = Laya.Browser.createElement("div");
+	        Laya.Input['inputContainer'].style.position = "absolute";
+	        Laya.Input['inputContainer'].style.zIndex = 1E5;
+	        Laya.Browser.container.appendChild(Laya.Input['inputContainer']);
+	        Laya.Laya.stage.on("resize", null, MiniInput._onStageResize);
+	        VVMiniAdapter.window.qg.onWindowResize && VVMiniAdapter.window.qg.onWindowResize(function (res) {
+	        });
+	        Laya.SoundManager._soundClass = MiniSound;
+	        Laya.SoundManager._musicClass = MiniSound;
+	        Laya.Browser.onAndroid = true;
+	        Laya.Browser.onIPhone = false;
+	        Laya.Browser.onIOS = false;
+	        Laya.Browser.onIPad = false;
+	    }
+	    static _onStageResize() {
+	        var ts = Laya.Laya.stage._canvasTransform.identity();
+	        ts.scale((Laya.Browser.width / Laya.Render.canvas.width / Laya.Browser.pixelRatio), Laya.Browser.height / Laya.Render.canvas.height / Laya.Browser.pixelRatio);
+	    }
+	    static wxinputFocus(e) {
+	        var _inputTarget = Laya.Input['inputElement'].target;
+	        if (_inputTarget && !_inputTarget.editable) {
+	            return;
+	        }
+	        VVMiniAdapter.window.qg.offKeyboardConfirm();
+	        VVMiniAdapter.window.qg.offKeyboardInput();
+	        VVMiniAdapter.window.qg.showKeyboard({ defaultValue: _inputTarget.text, maxLength: _inputTarget.maxChars, multiple: _inputTarget.multiline, confirmHold: true, confirmType: _inputTarget["confirmType"] || 'done', success: function (res) {
+	            }, fail: function (res) {
+	            } });
+	        VVMiniAdapter.window.qg.onKeyboardConfirm(function (res) {
+	            var str = res ? res.value : "";
+	            if (_inputTarget._restrictPattern) {
+	                str = str.replace(/\u2006|\x27/g, "");
+	                if (_inputTarget._restrictPattern.test(str)) {
+	                    str = str.replace(_inputTarget._restrictPattern, "");
+	                }
+	            }
+	            _inputTarget.text = str;
+	            _inputTarget.event(Laya.Event.INPUT);
+	            MiniInput.inputEnter();
+	            _inputTarget.event("confirm");
+	        });
+	        VVMiniAdapter.window.qg.onKeyboardInput(function (res) {
+	            var str = res ? res.value : "";
+	            if (!_inputTarget.multiline) {
+	                if (str.indexOf("\n") != -1) {
+	                    MiniInput.inputEnter();
+	                    return;
+	                }
+	            }
+	            if (_inputTarget._restrictPattern) {
+	                str = str.replace(/\u2006|\x27/g, "");
+	                if (_inputTarget._restrictPattern.test(str)) {
+	                    str = str.replace(_inputTarget._restrictPattern, "");
+	                }
+	            }
+	            _inputTarget.text = str;
+	            _inputTarget.event(Laya.Event.INPUT);
+	        });
+	    }
+	    static inputEnter() {
+	        Laya.Input['inputElement'].target.focus = false;
+	    }
+	    static wxinputblur() {
+	        MiniInput.hideKeyboard();
+	    }
+	    static hideKeyboard() {
+	        VVMiniAdapter.window.qg.offKeyboardConfirm();
+	        VVMiniAdapter.window.qg.offKeyboardInput();
+	        VVMiniAdapter.window.qg.hideKeyboard({ success: function (res) {
+	                console.log('隐藏键盘');
+	            }, fail: function (res) {
+	                console.log("隐藏键盘出错:" + (res ? res.errMsg : ""));
+	            } });
+	    }
+	}
+
+	class MiniLoader extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	    }
+	    _loadResourceFilter(type, url) {
+	        var thisLoader = this;
+	        if (url.indexOf("http://usr/") == -1 && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1)) {
+	            if (MiniFileMgr.loadPath != "") {
+	                url = url.split(MiniFileMgr.loadPath)[1];
+	            }
+	            else {
+	                var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                var tempUrl = url;
+	                if (tempStr != "")
+	                    url = url.split(tempStr)[1];
+	                if (!url) {
+	                    url = tempUrl;
+	                }
+	            }
+	        }
+	        if (VVMiniAdapter.subNativeFiles && VVMiniAdapter.subNativeheads.length == 0) {
+	            for (var key in VVMiniAdapter.subNativeFiles) {
+	                var tempArr = VVMiniAdapter.subNativeFiles[key];
+	                VVMiniAdapter.subNativeheads = VVMiniAdapter.subNativeheads.concat(tempArr);
+	                for (var aa = 0; aa < tempArr.length; aa++) {
+	                    VVMiniAdapter.subMaps[tempArr[aa]] = key + "/" + tempArr[aa];
+	                }
+	            }
+	        }
+	        if (VVMiniAdapter.subNativeFiles && url.indexOf("/") != -1) {
+	            var curfileHead = url.split("/")[0] + "/";
+	            if (curfileHead && VVMiniAdapter.subNativeheads.indexOf(curfileHead) != -1) {
+	                var newfileHead = VVMiniAdapter.subMaps[curfileHead];
+	                url = url.replace(curfileHead, newfileHead);
+	            }
+	        }
+	        switch (type) {
+	            case Laya.Loader.IMAGE:
+	            case "htmlimage":
+	            case "nativeimage":
+	                MiniLoader._transformImgUrl(url, type, thisLoader);
+	                break;
+	            case Laya.Loader.SOUND:
+	                thisLoader._loadSound(url);
+	                break;
+	            default:
+	                thisLoader._loadResource(type, url);
+	        }
+	    }
+	    _loadSound(url) {
+	        var thisLoader = this;
+	        var fileNativeUrl;
+	        if (MiniFileMgr.isLocalNativeFile(url)) {
+	            var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	            var tempUrl = url;
+	            if (tempStr != "" && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1))
+	                fileNativeUrl = url.split(tempStr)[1];
+	            if (!fileNativeUrl) {
+	                fileNativeUrl = tempUrl;
+	            }
+	            MiniLoader.onDownLoadCallBack(url, thisLoader, 0);
+	        }
+	        else {
+	            var tempurl = Laya.URL.formatURL(url);
+	            if (!MiniFileMgr.isLocalNativeFile(url) && (tempurl.indexOf("http://") == -1 && tempurl.indexOf("https://") == -1) || (tempurl.indexOf("http://usr/") != -1)) {
+	                MiniLoader.onDownLoadCallBack(url, thisLoader, 0);
+	            }
+	            else {
+	                MiniFileMgr.downOtherFiles(tempurl, Laya.Handler.create(MiniLoader, MiniLoader.onDownLoadCallBack, [tempurl, thisLoader]), tempurl);
+	            }
+	        }
+	    }
+	    static onDownLoadCallBack(sourceUrl, thisLoader, errorCode, tempFilePath = null) {
+	        if (!errorCode) {
+	            var fileNativeUrl;
+	            if (VVMiniAdapter.autoCacheFile) {
+	                if (!tempFilePath) {
+	                    if (MiniFileMgr.isLocalNativeFile(sourceUrl)) {
+	                        var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                        var tempUrl = sourceUrl;
+	                        if (tempStr != "" && (sourceUrl.indexOf("http://") != -1 || sourceUrl.indexOf("https://") != -1))
+	                            fileNativeUrl = sourceUrl.split(tempStr)[1];
+	                        if (!fileNativeUrl) {
+	                            fileNativeUrl = tempUrl;
+	                        }
+	                    }
+	                    else {
+	                        var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                        if (fileObj && fileObj.md5) {
+	                            var fileMd5Name = fileObj.md5;
+	                            fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                        }
+	                        else {
+	                            fileNativeUrl = sourceUrl;
+	                        }
+	                    }
+	                }
+	                else {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	            }
+	            sourceUrl = fileNativeUrl;
+	            var sound = (new Laya.SoundManager._soundClass());
+	            sound.load(sourceUrl);
+	            thisLoader.onLoaded(sound);
+	        }
+	        else {
+	            thisLoader.event(Laya.Event.ERROR, "Load sound failed");
+	        }
+	    }
+	    static bindToThis(fun, scope) {
+	        var rst = fun;
+	        rst = fun.bind(scope);
+	        return rst;
+	    }
+	    _loadHttpRequestWhat(url, contentType) {
+	        var thisLoader = this;
+	        var encoding = VVMiniAdapter.getUrlEncode(url, contentType);
+	        if (Laya.Loader.preLoadedMap[url])
+	            thisLoader.onLoaded(Laya.Loader.preLoadedMap[url]);
+	        else {
+	            var tempurl = Laya.URL.formatURL(url);
+	            if (!MiniFileMgr.isLocalNativeFile(url) && !MiniFileMgr.getFileInfo(tempurl) && url.indexOf("http://usr/") == -1 && (tempurl.indexOf("http://") != -1 || tempurl.indexOf("https://") != -1) && !VVMiniAdapter.AutoCacheDownFile) {
+	                thisLoader._loadHttpRequest(tempurl, contentType, thisLoader, thisLoader.onLoaded, thisLoader, thisLoader.onProgress, thisLoader, thisLoader.onError);
+	            }
+	            else {
+	                var fileObj = MiniFileMgr.getFileInfo(Laya.URL.formatURL(url));
+	                if (fileObj) {
+	                    fileObj.encoding = fileObj.encoding == null ? "utf8" : fileObj.encoding;
+	                    MiniFileMgr.readFile(MiniFileMgr.getFileNativePath(fileObj.md5), encoding, new Laya.Handler(MiniLoader, MiniLoader.onReadNativeCallBack, [url, contentType, thisLoader]), url);
+	                }
+	                else if (thisLoader.type == "image" || thisLoader.type == "htmlimage") {
+	                    thisLoader._transformUrl(url, contentType);
+	                }
+	                else {
+	                    if ((tempurl.indexOf("http://") == -1 && tempurl.indexOf("https://") == -1) || MiniFileMgr.isLocalNativeFile(url)) {
+	                        MiniFileMgr.readFile(url, encoding, new Laya.Handler(MiniLoader, MiniLoader.onReadNativeCallBack, [url, contentType, thisLoader]), url);
+	                    }
+	                    else {
+	                        MiniFileMgr.downFiles(encodeURI(tempurl), encoding, new Laya.Handler(MiniLoader, MiniLoader.onReadNativeCallBack, [url, contentType, thisLoader]), tempurl, true);
+	                    }
+	                }
+	            }
+	        }
+	    }
+	    static onReadNativeCallBack(url, type = null, thisLoader = null, errorCode = 0, data = null) {
+	        if (!errorCode) {
+	            var tempData;
+	            if (type == Laya.Loader.JSON || type == Laya.Loader.ATLAS || type == Laya.Loader.PREFAB || type == Laya.Loader.PLF) {
+	                tempData = VVMiniAdapter.getJson(data.data);
+	            }
+	            else if (type == Laya.Loader.XML) {
+	                tempData = Laya.Utils.parseXMLFromString(data.data);
+	            }
+	            else {
+	                tempData = data.data;
+	            }
+	            if (!VVMiniAdapter.isZiYu && VVMiniAdapter.isPosMsgYu && type != Laya.Loader.BUFFER && VVMiniAdapter.window.qg.postMessage) {
+	                VVMiniAdapter.window.qg.postMessage({ url: url, data: tempData, isLoad: "filedata" });
+	            }
+	            thisLoader.onLoaded(tempData);
+	        }
+	        else if (errorCode == 1) {
+	            thisLoader._loadHttpRequest(url, type, thisLoader, thisLoader.onLoaded, thisLoader, thisLoader.onProgress, thisLoader, thisLoader.onError);
+	        }
+	    }
+	    static _transformImgUrl(url, type, thisLoader) {
+	        if (VVMiniAdapter.isZiYu) {
+	            thisLoader._loadImage(url, false);
+	            return;
+	        }
+	        if (MiniFileMgr.isLocalNativeFile(url)) {
+	            thisLoader._loadImage(url, false);
+	            return;
+	        }
+	        if (!MiniFileMgr.isLocalNativeFile(url) && !MiniFileMgr.getFileInfo(Laya.URL.formatURL(url))) {
+	            var tempUrl = Laya.URL.formatURL(url);
+	            if (url.indexOf(VVMiniAdapter.window.qg.env.USER_DATA_PATH) == -1 && (tempUrl.indexOf("http://") != -1 || tempUrl.indexOf("https://") != -1)) {
+	                if (VVMiniAdapter.isZiYu) {
+	                    thisLoader._loadImage(url, false);
+	                }
+	                else {
+	                    MiniFileMgr.downOtherFiles(encodeURI(tempUrl), new Laya.Handler(MiniLoader, MiniLoader.onDownImgCallBack, [url, thisLoader]), tempUrl);
+	                }
+	            }
+	            else
+	                thisLoader._loadImage(url, false);
+	        }
+	        else {
+	            MiniLoader.onCreateImage(url, thisLoader);
+	        }
+	    }
+	    static onDownImgCallBack(sourceUrl, thisLoader, errorCode, tempFilePath = "") {
+	        if (!errorCode)
+	            MiniLoader.onCreateImage(sourceUrl, thisLoader, false, tempFilePath);
+	        else {
+	            thisLoader.onError(null);
+	        }
+	    }
+	    static onCreateImage(sourceUrl, thisLoader, isLocal = false, tempFilePath = "") {
+	        var fileNativeUrl;
+	        if (VVMiniAdapter.autoCacheFile) {
+	            if (!isLocal) {
+	                if (tempFilePath != "") {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	                else {
+	                    var fileObj = MiniFileMgr.getFileInfo(Laya.URL.formatURL(sourceUrl));
+	                    var fileMd5Name = fileObj.md5;
+	                    fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                }
+	            }
+	            else if (VVMiniAdapter.isZiYu) {
+	                var tempUrl = Laya.URL.formatURL(sourceUrl);
+	                if (MiniFileMgr.ziyuFileTextureData[tempUrl]) {
+	                    fileNativeUrl = MiniFileMgr.ziyuFileTextureData[tempUrl];
+	                }
+	                else
+	                    fileNativeUrl = sourceUrl;
+	            }
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        else {
+	            if (!isLocal)
+	                fileNativeUrl = tempFilePath;
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        thisLoader._loadImage(fileNativeUrl, false);
+	    }
+	}
+
+	class VVMiniAdapter {
+	    static getJson(data) {
+	        return JSON.parse(data);
+	    }
+	    static enable() {
+	        VVMiniAdapter.init(Laya.Laya.isWXPosMsg, Laya.Laya.isWXOpenDataContext);
+	    }
+	    static init(isPosMsg = false, isSon = false) {
+	        if (VVMiniAdapter._inited)
+	            return;
+	        VVMiniAdapter._inited = true;
+	        VVMiniAdapter.window = window;
+	        if (!VVMiniAdapter.window.hasOwnProperty("qg"))
+	            return;
+	        if (VVMiniAdapter.window.navigator.userAgent.indexOf('VVGame') < 0)
+	            return;
+	        VVMiniAdapter.isZiYu = isSon;
+	        VVMiniAdapter.isPosMsgYu = isPosMsg;
+	        VVMiniAdapter.EnvConfig = {};
+	        if (!VVMiniAdapter.window.qg.env) {
+	            VVMiniAdapter.window.qg.env = {};
+	            VVMiniAdapter.window.qg.env.USER_DATA_PATH = "internal://files";
+	        }
+	        if (!VVMiniAdapter.isZiYu) {
+	            MiniFileMgr.setNativeFileDir("/layaairGame");
+	            MiniFileMgr.existDir(MiniFileMgr.fileNativeDir, Laya.Handler.create(VVMiniAdapter, VVMiniAdapter.onMkdirCallBack));
+	        }
+	        VVMiniAdapter.systemInfo = VVMiniAdapter.window.qg.getSystemInfoSync();
+	        VVMiniAdapter.window.focus = function () {
+	        };
+	        Laya.Laya['_getUrlPath'] = function () {
+	            return "";
+	        };
+	        VVMiniAdapter.window.logtime = function (str) {
+	        };
+	        VVMiniAdapter.window.alertTimeLog = function (str) {
+	        };
+	        VVMiniAdapter.window.resetShareInfo = function () {
+	        };
+	        VVMiniAdapter.window.CanvasRenderingContext2D = function () {
+	        };
+	        VVMiniAdapter.window.CanvasRenderingContext2D.prototype = VVMiniAdapter.window.qg.createCanvas().getContext('2d').__proto__;
+	        VVMiniAdapter.window.document.body.appendChild = function () {
+	        };
+	        VVMiniAdapter.EnvConfig.pixelRatioInt = 0;
+	        Laya.Browser["_pixelRatio"] = VVMiniAdapter.pixelRatio();
+	        VVMiniAdapter._preCreateElement = Laya.Browser.createElement;
+	        Laya.Browser["createElement"] = VVMiniAdapter.createElement;
+	        Laya.RunDriver.createShaderCondition = VVMiniAdapter.createShaderCondition;
+	        Laya.Utils['parseXMLFromString'] = VVMiniAdapter.parseXMLFromString;
+	        Laya.Input['_createInputElement'] = MiniInput['_createInputElement'];
+	        Laya.Loader.prototype._loadResourceFilter = MiniLoader.prototype._loadResourceFilter;
+	        Laya.Loader.prototype._loadSound = MiniLoader.prototype._loadSound;
+	        Laya.Loader.prototype._loadHttpRequestWhat = MiniLoader.prototype._loadHttpRequestWhat;
+	        VVMiniAdapter.window.qg.onMessage && VVMiniAdapter.window.qg.onMessage(VVMiniAdapter._onMessage);
+	        Laya.Config.useRetinalCanvas = true;
+	    }
+	    static _onMessage(data) {
+	        switch (data.type) {
+	            case "changeMatrix":
+	                Laya.Laya.stage.transform.identity();
+	                Laya.Laya.stage._width = data.w;
+	                Laya.Laya.stage._height = data.h;
+	                Laya.Laya.stage._canvasTransform = new Laya.Matrix(data.a, data.b, data.c, data.d, data.tx, data.ty);
+	                break;
+	            case "display":
+	                Laya.Laya.stage.frameRate = data.rate || Laya.Stage.FRAME_FAST;
+	                break;
+	            case "undisplay":
+	                Laya.Laya.stage.frameRate = Laya.Stage.FRAME_SLEEP;
+	                break;
+	        }
+	        if (data['isLoad'] == "opendatacontext") {
+	            if (data.url) {
+	                MiniFileMgr.ziyuFileData[data.url] = data.atlasdata;
+	                MiniFileMgr.ziyuFileTextureData[data.imgReadyUrl] = data.imgNativeUrl;
+	            }
+	        }
+	        else if (data['isLoad'] == "openJsondatacontext") {
+	            if (data.url) {
+	                MiniFileMgr.ziyuFileData[data.url] = data.atlasdata;
+	            }
+	        }
+	        else if (data['isLoad'] == "openJsondatacontextPic") {
+	            MiniFileMgr.ziyuFileTextureData[data.imgReadyUrl] = data.imgNativeUrl;
+	        }
+	    }
+	    static getUrlEncode(url, type) {
+	        if (type == "arraybuffer")
+	            return "binary";
+	        return "utf8";
+	    }
+	    static downLoadFile(fileUrl, fileType = "", callBack = null, encoding = "utf8") {
+	        var fileObj = MiniFileMgr.getFileInfo(fileUrl);
+	        if (!fileObj)
+	            MiniFileMgr.downLoadFile(fileUrl, fileType, callBack, encoding);
+	        else {
+	            callBack != null && callBack.runWith([0]);
+	        }
+	    }
+	    static remove(fileUrl, callBack = null) {
+	        MiniFileMgr.deleteFile("", fileUrl, callBack, "", 0);
+	    }
+	    static removeAll() {
+	        MiniFileMgr.deleteAll();
+	    }
+	    static hasNativeFile(fileUrl) {
+	        return MiniFileMgr.isLocalNativeFile(fileUrl);
+	    }
+	    static getFileInfo(fileUrl) {
+	        return MiniFileMgr.getFileInfo(fileUrl);
+	    }
+	    static getFileList() {
+	        return MiniFileMgr.filesListObj;
+	    }
+	    static exitMiniProgram() {
+	        VVMiniAdapter.window.qg.exitMiniProgram();
+	    }
+	    static onMkdirCallBack(errorCode, data) {
+	        if (!errorCode)
+	            MiniFileMgr.filesListObj = JSON.parse(data.data);
+	        MiniFileMgr.fakeObj = MiniFileMgr.filesListObj;
+	    }
+	    static pixelRatio() {
+	        if (!VVMiniAdapter.EnvConfig.pixelRatioInt) {
+	            try {
+	                VVMiniAdapter.systemInfo.pixelRatio = VVMiniAdapter.window.devicePixelRatio;
+	                VVMiniAdapter.EnvConfig.pixelRatioInt = VVMiniAdapter.systemInfo.pixelRatio;
+	                return VVMiniAdapter.systemInfo.pixelRatio;
+	            }
+	            catch (error) {
+	            }
+	        }
+	        return VVMiniAdapter.EnvConfig.pixelRatioInt;
+	    }
+	    static createElement(type) {
+	        if (type == "canvas") {
+	            var _source;
+	            if (VVMiniAdapter.idx == 1) {
+	                if (VVMiniAdapter.isZiYu) {
+	                    _source = {};
+	                    _source.style = {};
+	                }
+	                else {
+	                    _source = document.getElementById("canvas");
+	                }
+	            }
+	            else {
+	                _source = VVMiniAdapter.window.qg.createCanvas();
+	            }
+	            VVMiniAdapter.idx++;
+	            return _source;
+	        }
+	        else if (type == "textarea" || type == "input") {
+	            return VVMiniAdapter.onCreateInput(type);
+	        }
+	        else if (type == "div") {
+	            var node = VVMiniAdapter._preCreateElement(type);
+	            node.contains = function (value) {
+	                return null;
+	            };
+	            node.removeChild = function (value) {
+	            };
+	            return node;
+	        }
+	        else {
+	            return VVMiniAdapter._preCreateElement(type);
+	        }
+	    }
+	    static onCreateInput(type) {
+	        var node = VVMiniAdapter._preCreateElement(type);
+	        node.focus = MiniInput.wxinputFocus;
+	        node.blur = MiniInput.wxinputblur;
+	        node.style = {};
+	        node.value = 0;
+	        node.parentElement = {};
+	        node.placeholder = {};
+	        node.type = {};
+	        node.setColor = function (value) {
+	        };
+	        node.setType = function (value) {
+	        };
+	        node.setFontFace = function (value) {
+	        };
+	        node.addEventListener = function (value) {
+	        };
+	        node.contains = function (value) {
+	            return null;
+	        };
+	        node.removeChild = function (value) {
+	        };
+	        return node;
+	    }
+	    static createShaderCondition(conditionScript) {
+	        var func = function () {
+	            return this[conditionScript.replace("this.", "")];
+	        };
+	        return func;
+	    }
+	    static sendAtlasToOpenDataContext(url) {
+	        if (!VVMiniAdapter.isZiYu) {
+	            var atlasJson = Laya.Loader.getRes(Laya.URL.formatURL(url));
+	            if (atlasJson) {
+	                var textureArr = atlasJson.meta.image.split(",");
+	                if (atlasJson.meta && atlasJson.meta.image) {
+	                    var toloadPics = atlasJson.meta.image.split(",");
+	                    var split = url.indexOf("/") >= 0 ? "/" : "\\";
+	                    var idx = url.lastIndexOf(split);
+	                    var folderPath = idx >= 0 ? url.substr(0, idx + 1) : "";
+	                    for (var i = 0, len = toloadPics.length; i < len; i++) {
+	                        toloadPics[i] = folderPath + toloadPics[i];
+	                    }
+	                }
+	                else {
+	                    toloadPics = [url.replace(".json", ".png")];
+	                }
+	                for (i = 0; i < toloadPics.length; i++) {
+	                    var tempAtlasPngUrl = toloadPics[i];
+	                    VVMiniAdapter.postInfoToContext(url, tempAtlasPngUrl, atlasJson);
+	                }
+	            }
+	            else {
+	                throw "传递的url没有获取到对应的图集数据信息,请确保图集已经过!";
+	            }
+	        }
+	    }
+	    static postInfoToContext(url, atlaspngUrl, atlasJson) {
+	        var postData = { "frames": atlasJson.frames, "meta": atlasJson.meta };
+	        var textureUrl = atlaspngUrl;
+	        var fileObj = MiniFileMgr.getFileInfo(Laya.URL.formatURL(atlaspngUrl));
+	        if (fileObj) {
+	            var fileMd5Name = fileObj.md5;
+	            var fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	        }
+	        else {
+	            fileNativeUrl = textureUrl;
+	        }
+	        if (fileNativeUrl) {
+	            VVMiniAdapter.window.qg.postMessage({ url: url, atlasdata: postData, imgNativeUrl: fileNativeUrl, imgReadyUrl: textureUrl, isLoad: "opendatacontext" });
+	        }
+	        else {
+	            throw "获取图集的磁盘url路径不存在!";
+	        }
+	    }
+	    static sendSinglePicToOpenDataContext(url) {
+	        var tempTextureUrl = Laya.URL.formatURL(url);
+	        var fileObj = MiniFileMgr.getFileInfo(tempTextureUrl);
+	        if (fileObj) {
+	            var fileMd5Name = fileObj.md5;
+	            var fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	            url = tempTextureUrl;
+	        }
+	        else {
+	            fileNativeUrl = url;
+	        }
+	        if (fileNativeUrl) {
+	            VVMiniAdapter.window.qg.postMessage({ url: url, imgNativeUrl: fileNativeUrl, imgReadyUrl: url, isLoad: "openJsondatacontextPic" });
+	        }
+	        else {
+	            throw "获取图集的磁盘url路径不存在!";
+	        }
+	    }
+	    static sendJsonDataToDataContext(url) {
+	        if (!VVMiniAdapter.isZiYu) {
+	            var atlasJson = Laya.Loader.getRes(url);
+	            if (atlasJson) {
+	                VVMiniAdapter.window.qg.postMessage({ url: url, atlasdata: atlasJson, isLoad: "openJsondatacontext" });
+	            }
+	            else {
+	                throw "传递的url没有获取到对应的图集数据信息,请确保图集已经过!";
+	            }
+	        }
+	    }
+	}
+	VVMiniAdapter._inited = false;
+	VVMiniAdapter.autoCacheFile = true;
+	VVMiniAdapter.minClearSize = (5 * 1024 * 1024);
+	VVMiniAdapter.nativefiles = ["layaNativeDir", "wxlocal"];
+	VVMiniAdapter.subNativeheads = [];
+	VVMiniAdapter.subMaps = [];
+	VVMiniAdapter.AutoCacheDownFile = false;
+	VVMiniAdapter.parseXMLFromString = function (value) {
+	    var rst;
+	    value = value.replace(/>\s+</g, '><');
+	    try {
+	        rst = (new window.DOMParser()).parseFromString(value, 'text/xml');
+	    }
+	    catch (error) {
+	        throw "需要引入xml解析库文件";
+	    }
+	    return rst;
+	};
+	VVMiniAdapter.idx = 1;
+
+	class MiniAccelerator extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	    }
+	    static __init__() {
+	        try {
+	            var Acc;
+	            Acc = Laya.Accelerator;
+	            if (!Acc)
+	                return;
+	            Acc["prototype"]["on"] = MiniAccelerator["prototype"]["on"];
+	            Acc["prototype"]["off"] = MiniAccelerator["prototype"]["off"];
+	        }
+	        catch (e) {
+	        }
+	    }
+	    static startListen(callBack) {
+	        MiniAccelerator._callBack = callBack;
+	        if (MiniAccelerator._isListening)
+	            return;
+	        MiniAccelerator._isListening = true;
+	        try {
+	            VVMiniAdapter.window.qg.onAccelerometerChange(MiniAccelerator.onAccelerometerChange);
+	        }
+	        catch (e) { }
+	    }
+	    static stopListen() {
+	        MiniAccelerator._isListening = false;
+	        try {
+	            VVMiniAdapter.window.qg.stopAccelerometer({});
+	        }
+	        catch (e) { }
+	    }
+	    static onAccelerometerChange(res) {
+	        var e;
+	        e = {};
+	        e.acceleration = res;
+	        e.accelerationIncludingGravity = res;
+	        e.rotationRate = {};
+	        if (MiniAccelerator._callBack != null) {
+	            MiniAccelerator._callBack(e);
+	        }
+	    }
+	    on(type, caller, listener, args = null) {
+	        super.on(type, caller, listener, args);
+	        MiniAccelerator.startListen(this["onDeviceOrientationChange"]);
+	        return this;
+	    }
+	    off(type, caller, listener, onceOnly = false) {
+	        if (!this.hasListener(type))
+	            MiniAccelerator.stopListen();
+	        return super.off(type, caller, listener, onceOnly);
+	    }
+	}
+	MiniAccelerator._isListening = false;
+
+	class MiniImage {
+	    _loadImage(url) {
+	        var thisLoader = this;
+	        if (VVMiniAdapter.isZiYu) {
+	            MiniImage.onCreateImage(url, thisLoader, true);
+	            return;
+	        }
+	        var isTransformUrl;
+	        if (!MiniFileMgr.isLocalNativeFile(url)) {
+	            isTransformUrl = true;
+	            url = Laya.URL.formatURL(url);
+	        }
+	        else {
+	            if (url.indexOf("http://usr/") == -1 && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1)) {
+	                if (MiniFileMgr.loadPath != "") {
+	                    url = url.split(MiniFileMgr.loadPath)[1];
+	                }
+	                else {
+	                    var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    var tempUrl = url;
+	                    if (tempStr != "")
+	                        url = url.split(tempStr)[1];
+	                    if (!url) {
+	                        url = tempUrl;
+	                    }
+	                }
+	            }
+	            if (VVMiniAdapter.subNativeFiles && VVMiniAdapter.subNativeheads.length == 0) {
+	                for (var key in VVMiniAdapter.subNativeFiles) {
+	                    var tempArr = VVMiniAdapter.subNativeFiles[key];
+	                    VVMiniAdapter.subNativeheads = VVMiniAdapter.subNativeheads.concat(tempArr);
+	                    for (var aa = 0; aa < tempArr.length; aa++) {
+	                        VVMiniAdapter.subMaps[tempArr[aa]] = key + "/" + tempArr[aa];
+	                    }
+	                }
+	            }
+	            if (VVMiniAdapter.subNativeFiles && url.indexOf("/") != -1) {
+	                var curfileHead = url.split("/")[0] + "/";
+	                if (curfileHead && VVMiniAdapter.subNativeheads.indexOf(curfileHead) != -1) {
+	                    var newfileHead = VVMiniAdapter.subMaps[curfileHead];
+	                    url = url.replace(curfileHead, newfileHead);
+	                }
+	            }
+	        }
+	        if (!MiniFileMgr.getFileInfo(url)) {
+	            if (url.indexOf('http://usr/') == -1 && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1)) {
+	                if (VVMiniAdapter.isZiYu) {
+	                    MiniImage.onCreateImage(url, thisLoader, true);
+	                }
+	                else {
+	                    MiniFileMgr.downOtherFiles(url, new Laya.Handler(MiniImage, MiniImage.onDownImgCallBack, [url, thisLoader]), url);
+	                }
+	            }
+	            else
+	                MiniImage.onCreateImage(url, thisLoader, true);
+	        }
+	        else {
+	            MiniImage.onCreateImage(url, thisLoader, !isTransformUrl);
+	        }
+	    }
+	    static onDownImgCallBack(sourceUrl, thisLoader, errorCode, tempFilePath = "") {
+	        if (!errorCode)
+	            MiniImage.onCreateImage(sourceUrl, thisLoader, false, tempFilePath);
+	        else {
+	            thisLoader.onError(null);
+	        }
+	    }
+	    static onCreateImage(sourceUrl, thisLoader, isLocal = false, tempFilePath = "") {
+	        var fileNativeUrl;
+	        if (VVMiniAdapter.autoCacheFile) {
+	            if (!isLocal) {
+	                if (tempFilePath != "") {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	                else {
+	                    var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                    var fileMd5Name = fileObj.md5;
+	                    fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                }
+	            }
+	            else if (VVMiniAdapter.isZiYu) {
+	                var tempUrl = Laya.URL.formatURL(sourceUrl);
+	                if (MiniFileMgr.ziyuFileTextureData[tempUrl]) {
+	                    fileNativeUrl = MiniFileMgr.ziyuFileTextureData[tempUrl];
+	                }
+	                else
+	                    fileNativeUrl = sourceUrl;
+	            }
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        else {
+	            if (!isLocal)
+	                fileNativeUrl = tempFilePath;
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        if (thisLoader._imgCache == null)
+	            thisLoader._imgCache = {};
+	        var image;
+	        function clear() {
+	            var img = thisLoader._imgCache[fileNativeUrl];
+	            if (img) {
+	                img.onload = null;
+	                img.onerror = null;
+	                delete thisLoader._imgCache[fileNativeUrl];
+	            }
+	        }
+	        var onerror = function () {
+	            clear();
+	            delete MiniFileMgr.fakeObj[sourceUrl];
+	            delete MiniFileMgr.filesListObj[sourceUrl];
+	            thisLoader.event(Laya.Event.ERROR, "Load image failed");
+	        };
+	        if (thisLoader._type == "nativeimage") {
+	            var onload = function () {
+	                clear();
+	                thisLoader.onLoaded(image);
+	            };
+	            image = new Laya.Browser.window.Image();
+	            image.crossOrigin = "";
+	            image.onload = onload;
+	            image.onerror = onerror;
+	            image.src = fileNativeUrl;
+	            thisLoader._imgCache[fileNativeUrl] = image;
+	        }
+	        else {
+	            var imageSource = new Laya.Browser.window.Image();
+	            onload = function () {
+	                image = Laya.HTMLImage.create(imageSource.width, imageSource.height);
+	                image.loadImageSource(imageSource, true);
+	                image._setCreateURL(fileNativeUrl);
+	                clear();
+	                thisLoader.onLoaded(image);
+	            };
+	            imageSource.crossOrigin = "";
+	            imageSource.onload = onload;
+	            imageSource.onerror = onerror;
+	            imageSource.src = fileNativeUrl;
+	            thisLoader._imgCache[fileNativeUrl] = imageSource;
+	        }
+	    }
+	}
+
+	class MiniLocation {
+	    constructor() {
+	    }
+	    static __init__() {
+	        VVMiniAdapter.window.navigator.geolocation.getCurrentPosition = MiniLocation.getCurrentPosition;
+	        VVMiniAdapter.window.navigator.geolocation.watchPosition = MiniLocation.watchPosition;
+	        VVMiniAdapter.window.navigator.geolocation.clearWatch = MiniLocation.clearWatch;
+	    }
+	    static getCurrentPosition(success = null, error = null, options = null) {
+	        var paramO;
+	        paramO = {};
+	        paramO.success = getSuccess;
+	        paramO.fail = error;
+	        VVMiniAdapter.window.qg.getLocation(paramO);
+	        function getSuccess(res) {
+	            if (success != null) {
+	                success(res);
+	            }
+	        }
+	    }
+	    static watchPosition(success = null, error = null, options = null) {
+	        MiniLocation._curID++;
+	        var curWatchO;
+	        curWatchO = {};
+	        curWatchO.success = success;
+	        curWatchO.error = error;
+	        MiniLocation._watchDic[MiniLocation._curID] = curWatchO;
+	        Laya.Laya.systemTimer.loop(1000, null, MiniLocation._myLoop);
+	        return MiniLocation._curID;
+	    }
+	    static clearWatch(id) {
+	        delete MiniLocation._watchDic[id];
+	        if (!MiniLocation._hasWatch()) {
+	            Laya.Laya.systemTimer.clear(null, MiniLocation._myLoop);
+	        }
+	    }
+	    static _hasWatch() {
+	        var key;
+	        for (key in MiniLocation._watchDic) {
+	            if (MiniLocation._watchDic[key])
+	                return true;
+	        }
+	        return false;
+	    }
+	    static _myLoop() {
+	        MiniLocation.getCurrentPosition(MiniLocation._mySuccess, MiniLocation._myError);
+	    }
+	    static _mySuccess(res) {
+	        var rst = {};
+	        rst.coords = res;
+	        rst.timestamp = Laya.Browser.now();
+	        var key;
+	        for (key in MiniLocation._watchDic) {
+	            if (MiniLocation._watchDic[key].success) {
+	                MiniLocation._watchDic[key].success(rst);
+	            }
+	        }
+	    }
+	    static _myError(res) {
+	        var key;
+	        for (key in MiniLocation._watchDic) {
+	            if (MiniLocation._watchDic[key].error) {
+	                MiniLocation._watchDic[key].error(res);
+	            }
+	        }
+	    }
+	}
+	MiniLocation._watchDic = {};
+	MiniLocation._curID = 0;
+
+	class MiniVideo {
+	    constructor(width = 320, height = 240) {
+	        this.videoend = false;
+	        this.videourl = "";
+	        this.videoElement = VVMiniAdapter.window.qg.createVideo({ width: width, height: height, autoplay: true });
+	    }
+	    static __init__() {
+	    }
+	    on(eventType, ths, callBack) {
+	        if (eventType == "loadedmetadata") {
+	            this.onPlayFunc = callBack.bind(ths);
+	            this.videoElement.onPlay = this.onPlayFunction.bind(this);
+	        }
+	        else if (eventType == "ended") {
+	            this.onEndedFunC = callBack.bind(ths);
+	            this.videoElement.onEnded = this.onEndedFunction.bind(this);
+	        }
+	        this.videoElement.onTimeUpdate = this.onTimeUpdateFunc.bind(this);
+	    }
+	    onTimeUpdateFunc(data) {
+	        this.position = data.position;
+	        this._duration = data.duration;
+	    }
+	    get duration() {
+	        return this._duration;
+	    }
+	    onPlayFunction() {
+	        if (this.videoElement)
+	            this.videoElement.readyState = 200;
+	        console.log("=====视频加载完成========");
+	        this.onPlayFunc != null && this.onPlayFunc();
+	    }
+	    onEndedFunction() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoend = true;
+	        console.log("=====视频播放完毕========");
+	        this.onEndedFunC != null && this.onEndedFunC();
+	    }
+	    off(eventType, ths, callBack) {
+	        if (eventType == "loadedmetadata") {
+	            this.onPlayFunc = callBack.bind(ths);
+	            this.videoElement.offPlay = this.onPlayFunction.bind(this);
+	        }
+	        else if (eventType == "ended") {
+	            this.onEndedFunC = callBack.bind(ths);
+	            this.videoElement.offEnded = this.onEndedFunction.bind(this);
+	        }
+	    }
+	    load(url) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.src = url;
+	    }
+	    play() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoend = false;
+	        this.videoElement.play();
+	    }
+	    pause() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoend = true;
+	        this.videoElement.pause();
+	    }
+	    get currentTime() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.initialTime;
+	    }
+	    set currentTime(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.initialTime = value;
+	    }
+	    get videoWidth() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.width;
+	    }
+	    get videoHeight() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.height;
+	    }
+	    get ended() {
+	        return this.videoend;
+	    }
+	    get loop() {
+	        if (!this.videoElement)
+	            return false;
+	        return this.videoElement.loop;
+	    }
+	    set loop(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.loop = value;
+	    }
+	    get playbackRate() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.playbackRate;
+	    }
+	    set playbackRate(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.playbackRate = value;
+	    }
+	    get muted() {
+	        if (!this.videoElement)
+	            return false;
+	        return this.videoElement.muted;
+	    }
+	    set muted(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.muted = value;
+	    }
+	    get paused() {
+	        if (!this.videoElement)
+	            return false;
+	        return this.videoElement.paused;
+	    }
+	    size(width, height) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.width = width;
+	        this.videoElement.height = height;
+	    }
+	    get x() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.x;
+	    }
+	    set x(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.x = value;
+	    }
+	    get y() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.y;
+	    }
+	    set y(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.y = value;
+	    }
+	    get currentSrc() {
+	        return this.videoElement.src;
+	    }
+	    destroy() {
+	        if (this.videoElement)
+	            this.videoElement.destroy();
+	        this.videoElement = null;
+	        this.onEndedFunC = null;
+	        this.onPlayFunc = null;
+	        this.videoend = false;
+	        this.videourl = null;
+	    }
+	    reload() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.src = this.videourl;
+	    }
+	}
+
+	exports.MiniAccelerator = MiniAccelerator;
+	exports.MiniFileMgr = MiniFileMgr;
+	exports.MiniImage = MiniImage;
+	exports.MiniInput = MiniInput;
+	exports.MiniLoader = MiniLoader;
+	exports.MiniLocation = MiniLocation;
+	exports.MiniSound = MiniSound;
+	exports.MiniSoundChannel = MiniSoundChannel;
+	exports.MiniVideo = MiniVideo;
+	exports.VVMiniAdapter = VVMiniAdapter;
+
+} 

+ 1709 - 0
ShootingSun/bin/libs/laya.wxmini.js

@@ -0,0 +1,1709 @@
+window.wxMiniGame = function (exports, Laya) {
+	'use strict';
+
+	class MiniFileMgr {
+	    static isLocalNativeFile(url) {
+	        for (var i = 0, sz = MiniAdpter.nativefiles.length; i < sz; i++) {
+	            if (url.indexOf(MiniAdpter.nativefiles[i]) != -1)
+	                return true;
+	        }
+	        return false;
+	    }
+	    static getFileInfo(fileUrl) {
+	        var fileNativePath = fileUrl;
+	        var fileObj = MiniFileMgr.fakeObj[fileNativePath];
+	        if (fileObj == null)
+	            return null;
+	        else
+	            return fileObj;
+	        return null;
+	    }
+	    static read(filePath, encoding = "utf8", callBack = null, readyUrl = "", isSaveFile = false, fileType = "") {
+	        var fileUrl;
+	        if (readyUrl != "" && (readyUrl.indexOf("http://") != -1 || readyUrl.indexOf("https://") != -1)) {
+	            fileUrl = MiniFileMgr.getFileNativePath(filePath);
+	        }
+	        else {
+	            fileUrl = filePath;
+	        }
+	        fileUrl = Laya.URL.getAdptedFilePath(fileUrl);
+	        MiniFileMgr.fs.readFile({ filePath: fileUrl, encoding: encoding, success: function (data) {
+	                callBack != null && callBack.runWith([0, data]);
+	            }, fail: function (data) {
+	                if (data && readyUrl != "")
+	                    MiniFileMgr.downFiles(readyUrl, encoding, callBack, readyUrl, isSaveFile, fileType);
+	                else
+	                    callBack != null && callBack.runWith([1]);
+	            } });
+	    }
+	    static downFiles(fileUrl, encoding = "utf8", callBack = null, readyUrl = "", isSaveFile = false, fileType = "", isAutoClear = true) {
+	        var downloadTask = MiniFileMgr.wxdown({ url: fileUrl, success: function (data) {
+	                if (data.statusCode === 200)
+	                    MiniFileMgr.readFile(data.tempFilePath, encoding, callBack, readyUrl, isSaveFile, fileType, isAutoClear);
+	                else if (data.statusCode === 403) {
+	                    callBack != null && callBack.runWith([0, fileUrl]);
+	                }
+	                else {
+	                    callBack != null && callBack.runWith([1, data]);
+	                }
+	            }, fail: function (data) {
+	                callBack != null && callBack.runWith([1, data]);
+	            } });
+	        downloadTask.onProgressUpdate(function (data) {
+	            callBack != null && callBack.runWith([2, data.progress]);
+	        });
+	    }
+	    static readFile(filePath, encoding = "utf8", callBack = null, readyUrl = "", isSaveFile = false, fileType = "", isAutoClear = true) {
+	        filePath = Laya.URL.getAdptedFilePath(filePath);
+	        MiniFileMgr.fs.readFile({ filePath: filePath, encoding: encoding, success: function (data) {
+	                if (filePath.indexOf("http://") != -1 || filePath.indexOf("https://") != -1) {
+	                    if (MiniAdpter.autoCacheFile || isSaveFile) {
+	                        callBack != null && callBack.runWith([0, data]);
+	                        MiniFileMgr.copyFile(filePath, readyUrl, null, encoding, isAutoClear);
+	                    }
+	                    else
+	                        callBack != null && callBack.runWith([0, data]);
+	                }
+	                else
+	                    callBack != null && callBack.runWith([0, data]);
+	            }, fail: function (data) {
+	                if (data)
+	                    callBack != null && callBack.runWith([1, data]);
+	            } });
+	    }
+	    static downOtherFiles(fileUrl, callBack = null, readyUrl = "", isSaveFile = false, isAutoClear = true) {
+	        MiniFileMgr.wxdown({ url: fileUrl, success: function (data) {
+	                if (data.statusCode === 200) {
+	                    if ((MiniAdpter.autoCacheFile || isSaveFile) && readyUrl.indexOf("qlogo.cn") == -1 && readyUrl.indexOf(".php") == -1) {
+	                        callBack != null && callBack.runWith([0, data.tempFilePath]);
+	                        MiniFileMgr.copyFile(data.tempFilePath, readyUrl, null, "", isAutoClear);
+	                    }
+	                    else
+	                        callBack != null && callBack.runWith([0, data.tempFilePath]);
+	                }
+	                else {
+	                    callBack != null && callBack.runWith([1, data]);
+	                }
+	            }, fail: function (data) {
+	                callBack != null && callBack.runWith([1, data]);
+	            } });
+	    }
+	    static downLoadFile(fileUrl, fileType = "", callBack = null, encoding = "utf8") {
+	        if (window.navigator.userAgent.indexOf('MiniGame') < 0) {
+	            Laya.Laya.loader.load(fileUrl, callBack);
+	        }
+	        else {
+	            if (fileType == Laya.Loader.IMAGE || fileType == Laya.Loader.SOUND)
+	                MiniFileMgr.downOtherFiles(fileUrl, callBack, fileUrl, true, false);
+	            else
+	                MiniFileMgr.downFiles(fileUrl, encoding, callBack, fileUrl, true, fileType, false);
+	        }
+	    }
+	    static copyFile(tempFilePath, readyUrl, callBack, encoding = "", isAutoClear = true) {
+	        var temp = tempFilePath.split("/");
+	        var tempFileName = temp[temp.length - 1];
+	        var fileurlkey = readyUrl;
+	        var fileObj = MiniFileMgr.getFileInfo(readyUrl);
+	        var saveFilePath = MiniFileMgr.getFileNativePath(tempFileName);
+	        MiniFileMgr.fakeObj[fileurlkey] = { md5: tempFileName, readyUrl: readyUrl, size: 0, times: Laya.Browser.now(), encoding: encoding };
+	        var totalSize = 50 * 1024 * 1024;
+	        var chaSize = 4 * 1024 * 1024;
+	        var fileUseSize = MiniFileMgr.getCacheUseSize();
+	        if (fileObj) {
+	            if (fileObj.readyUrl != readyUrl) {
+	                MiniFileMgr.fs.getFileInfo({
+	                    filePath: tempFilePath,
+	                    success: function (data) {
+	                        if ((isAutoClear && (fileUseSize + chaSize + data.size) >= totalSize)) {
+	                            if (data.size > MiniAdpter.minClearSize)
+	                                MiniAdpter.minClearSize = data.size;
+	                            MiniFileMgr.onClearCacheRes();
+	                        }
+	                        MiniFileMgr.deleteFile(tempFilePath, readyUrl, callBack, encoding, data.size);
+	                    },
+	                    fail: function (data) {
+	                        callBack != null && callBack.runWith([1, data]);
+	                    }
+	                });
+	            }
+	            else
+	                callBack != null && callBack.runWith([0]);
+	        }
+	        else {
+	            MiniFileMgr.fs.getFileInfo({
+	                filePath: tempFilePath,
+	                success: function (data) {
+	                    if ((isAutoClear && (fileUseSize + chaSize + data.size) >= totalSize)) {
+	                        if (data.size > MiniAdpter.minClearSize)
+	                            MiniAdpter.minClearSize = data.size;
+	                        MiniFileMgr.onClearCacheRes();
+	                    }
+	                    MiniFileMgr.fs.copyFile({ srcPath: tempFilePath, destPath: saveFilePath, success: function (data2) {
+	                            MiniFileMgr.onSaveFile(readyUrl, tempFileName, true, encoding, callBack, data.size);
+	                        }, fail: function (data) {
+	                            callBack != null && callBack.runWith([1, data]);
+	                        } });
+	                },
+	                fail: function (data) {
+	                    callBack != null && callBack.runWith([1, data]);
+	                }
+	            });
+	        }
+	    }
+	    static onClearCacheRes() {
+	        var memSize = MiniAdpter.minClearSize;
+	        var tempFileListArr = [];
+	        for (var key in MiniFileMgr.filesListObj) {
+	            if (key != "fileUsedSize")
+	                tempFileListArr.push(MiniFileMgr.filesListObj[key]);
+	        }
+	        MiniFileMgr.sortOn(tempFileListArr, "times", MiniFileMgr.NUMERIC);
+	        var clearSize = 0;
+	        for (var i = 1, sz = tempFileListArr.length; i < sz; i++) {
+	            var fileObj = tempFileListArr[i];
+	            if (clearSize >= memSize)
+	                break;
+	            clearSize += fileObj.size;
+	            MiniFileMgr.deleteFile("", fileObj.readyUrl);
+	        }
+	    }
+	    static sortOn(array, name, options = 0) {
+	        if (options == MiniFileMgr.NUMERIC)
+	            return array.sort(function (a, b) { return a[name] - b[name]; });
+	        if (options == (MiniFileMgr.NUMERIC | MiniFileMgr.DESCENDING))
+	            return array.sort(function (a, b) { return b[name] - a[name]; });
+	        return array.sort(function (a, b) { return a[name] - b[name]; });
+	    }
+	    static getFileNativePath(fileName) {
+	        return MiniFileMgr.fileNativeDir + "/" + fileName;
+	    }
+	    static deleteFile(tempFileName, readyUrl = "", callBack = null, encoding = "", fileSize = 0) {
+	        var fileObj = MiniFileMgr.getFileInfo(readyUrl);
+	        var deleteFileUrl = MiniFileMgr.getFileNativePath(fileObj.md5);
+	        var isAdd = tempFileName != "" ? true : false;
+	        MiniFileMgr.onSaveFile(readyUrl, tempFileName, isAdd, encoding, callBack, fileSize);
+	        MiniFileMgr.fs.unlink({ filePath: deleteFileUrl, success: function (data) {
+	                if (tempFileName != "") {
+	                    var saveFilePath = MiniFileMgr.getFileNativePath(tempFileName);
+	                    MiniFileMgr.fs.copyFile({ srcPath: tempFileName, destPath: saveFilePath, success: function (data) {
+	                        }, fail: function (data) {
+	                            callBack != null && callBack.runWith([1, data]);
+	                        } });
+	                }
+	            }, fail: function (data) {
+	            } });
+	    }
+	    static deleteAll() {
+	        var tempFileListArr = [];
+	        for (var key in MiniFileMgr.filesListObj) {
+	            if (key != "fileUsedSize")
+	                tempFileListArr.push(MiniFileMgr.filesListObj[key]);
+	        }
+	        for (var i = 1, sz = tempFileListArr.length; i < sz; i++) {
+	            var fileObj = tempFileListArr[i];
+	            MiniFileMgr.deleteFile("", fileObj.readyUrl);
+	        }
+	        if (MiniFileMgr.filesListObj && MiniFileMgr.filesListObj.fileUsedSize) {
+	            MiniFileMgr.filesListObj.fileUsedSize = 0;
+	        }
+	        MiniFileMgr.writeFilesList("", JSON.stringify({}), false);
+	    }
+	    static onSaveFile(readyUrl, md5Name, isAdd = true, encoding = "", callBack = null, fileSize = 0) {
+	        var fileurlkey = readyUrl;
+	        if (MiniFileMgr.filesListObj['fileUsedSize'] == null)
+	            MiniFileMgr.filesListObj['fileUsedSize'] = 0;
+	        if (isAdd) {
+	            var fileNativeName = MiniFileMgr.getFileNativePath(md5Name);
+	            MiniFileMgr.filesListObj[fileurlkey] = { md5: md5Name, readyUrl: readyUrl, size: fileSize, times: Laya.Browser.now(), encoding: encoding };
+	            MiniFileMgr.filesListObj['fileUsedSize'] = parseInt(MiniFileMgr.filesListObj['fileUsedSize']) + fileSize;
+	            MiniFileMgr.writeFilesList(fileurlkey, JSON.stringify(MiniFileMgr.filesListObj), true);
+	            callBack != null && callBack.runWith([0]);
+	        }
+	        else {
+	            if (MiniFileMgr.filesListObj[fileurlkey]) {
+	                var deletefileSize = parseInt(MiniFileMgr.filesListObj[fileurlkey].size);
+	                MiniFileMgr.filesListObj['fileUsedSize'] = parseInt(MiniFileMgr.filesListObj['fileUsedSize']) - deletefileSize;
+	                delete MiniFileMgr.filesListObj[fileurlkey];
+	                MiniFileMgr.writeFilesList(fileurlkey, JSON.stringify(MiniFileMgr.filesListObj), false);
+	                callBack != null && callBack.runWith([0]);
+	            }
+	        }
+	    }
+	    static writeFilesList(fileurlkey, filesListStr, isAdd) {
+	        var listFilesPath = MiniFileMgr.fileNativeDir + "/" + MiniFileMgr.fileListName;
+	        MiniFileMgr.fs.writeFile({ filePath: listFilesPath, encoding: 'utf8', data: filesListStr, success: function (data) {
+	            }, fail: function (data) {
+	            } });
+	        if (!MiniAdpter.isZiYu && MiniAdpter.isPosMsgYu) {
+	            MiniAdpter.window.wx.postMessage({ url: fileurlkey, data: MiniFileMgr.filesListObj[fileurlkey], isLoad: "filenative", isAdd: isAdd });
+	        }
+	    }
+	    static getCacheUseSize() {
+	        if (MiniFileMgr.filesListObj && MiniFileMgr.filesListObj['fileUsedSize'])
+	            return MiniFileMgr.filesListObj['fileUsedSize'];
+	        return 0;
+	    }
+	    static existDir(dirPath, callBack) {
+	        MiniFileMgr.fs.mkdir({ dirPath: dirPath, success: function (data) {
+	                callBack != null && callBack.runWith([0, { data: JSON.stringify({}) }]);
+	            }, fail: function (data) {
+	                if (data.errMsg.indexOf("file already exists") != -1)
+	                    MiniFileMgr.readSync(MiniFileMgr.fileListName, "utf8", callBack);
+	                else
+	                    callBack != null && callBack.runWith([1, data]);
+	            } });
+	    }
+	    static readSync(filePath, encoding = "utf8", callBack = null, readyUrl = "") {
+	        var fileUrl = MiniFileMgr.getFileNativePath(filePath);
+	        var filesListStr;
+	        try {
+	            filesListStr = MiniFileMgr.fs.readFileSync(fileUrl, encoding);
+	            callBack != null && callBack.runWith([0, { data: filesListStr }]);
+	        }
+	        catch (error) {
+	            callBack != null && callBack.runWith([1]);
+	        }
+	    }
+	    static setNativeFileDir(value) {
+	        MiniFileMgr.fileNativeDir = MiniAdpter.window.wx.env.USER_DATA_PATH + value;
+	    }
+	}
+	MiniFileMgr.fs = window.wx.getFileSystemManager();
+	MiniFileMgr.wxdown = window.wx.downloadFile;
+	MiniFileMgr.filesListObj = {};
+	MiniFileMgr.fakeObj = {};
+	MiniFileMgr.fileListName = "layaairfiles.txt";
+	MiniFileMgr.ziyuFileData = {};
+	MiniFileMgr.ziyuFileTextureData = {};
+	MiniFileMgr.loadPath = "";
+	MiniFileMgr.DESCENDING = 2;
+	MiniFileMgr.NUMERIC = 16;
+
+	class MiniSoundChannel extends Laya.SoundChannel {
+	    constructor(audio, miniSound) {
+	        super();
+	        this._audio = audio;
+	        this._miniSound = miniSound;
+	        this._onEnd = MiniSoundChannel.bindToThis(this.__onEnd, this);
+	        audio.onEnded(this._onEnd);
+	    }
+	    static bindToThis(fun, scope) {
+	        var rst = fun;
+	        rst = fun.bind(scope);
+	        return rst;
+	    }
+	    __onEnd() {
+	        if (this.loops == 1) {
+	            if (this.completeHandler) {
+	                Laya.Laya.systemTimer.once(10, this, this.__runComplete, [this.completeHandler], false);
+	                this.completeHandler = null;
+	            }
+	            this.stop();
+	            this.event(Laya.Event.COMPLETE);
+	            return;
+	        }
+	        if (this.loops > 0) {
+	            this.loops--;
+	        }
+	        this.startTime = 0;
+	        this.play();
+	    }
+	    play() {
+	        this.isStopped = false;
+	        Laya.SoundManager.addChannel(this);
+	        this._audio.play();
+	    }
+	    set startTime(time) {
+	        if (this._audio) {
+	            this._audio.startTime = time;
+	        }
+	    }
+	    set autoplay(value) {
+	        this._audio.autoplay = value;
+	    }
+	    get autoplay() {
+	        return this._audio.autoplay;
+	    }
+	    get position() {
+	        if (!this._audio)
+	            return 0;
+	        return this._audio.currentTime;
+	    }
+	    get duration() {
+	        if (!this._audio)
+	            return 0;
+	        return this._audio.duration;
+	    }
+	    stop() {
+	        this.isStopped = true;
+	        Laya.SoundManager.removeChannel(this);
+	        this.completeHandler = null;
+	        if (!this._audio)
+	            return;
+	        this._audio.stop();
+	        if (!this.loop) {
+	            this._audio.offEnded(null);
+	            this._miniSound.dispose();
+	            this._audio = null;
+	            this._miniSound = null;
+	            this._onEnd = null;
+	        }
+	    }
+	    pause() {
+	        this.isStopped = true;
+	        this._audio.pause();
+	    }
+	    get loop() {
+	        return this._audio.loop;
+	    }
+	    set loop(value) {
+	        this._audio.loop = value;
+	    }
+	    resume() {
+	        if (!this._audio)
+	            return;
+	        this.isStopped = false;
+	        Laya.SoundManager.addChannel(this);
+	        this._audio.play();
+	    }
+	    set volume(v) {
+	        if (!this._audio)
+	            return;
+	        this._audio.volume = v;
+	    }
+	    get volume() {
+	        if (!this._audio)
+	            return 1;
+	        return this._audio.volume;
+	    }
+	}
+
+	class MiniSound extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	        this.loaded = false;
+	    }
+	    static _createSound() {
+	        MiniSound._id++;
+	        return MiniAdpter.window.wx.createInnerAudioContext();
+	    }
+	    load(url) {
+	        if (!MiniSound._musicAudio)
+	            MiniSound._musicAudio = MiniSound._createSound();
+	        if (!MiniFileMgr.isLocalNativeFile(url)) {
+	            url = Laya.URL.formatURL(url);
+	        }
+	        else {
+	            if (url.indexOf("http://") != -1 || url.indexOf("https://") != -1) {
+	                if (MiniFileMgr.loadPath != "") {
+	                    url = url.split(MiniFileMgr.loadPath)[1];
+	                }
+	                else {
+	                    var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    if (tempStr != "")
+	                        url = url.split(tempStr)[1];
+	                }
+	            }
+	        }
+	        this.url = url;
+	        this.readyUrl = url;
+	        if (MiniSound._audioCache[this.readyUrl]) {
+	            this.event(Laya.Event.COMPLETE);
+	            return;
+	        }
+	        if (MiniAdpter.autoCacheFile && MiniFileMgr.getFileInfo(url)) {
+	            this.onDownLoadCallBack(url, 0);
+	        }
+	        else {
+	            if (!MiniAdpter.autoCacheFile) {
+	                this.onDownLoadCallBack(url, 0);
+	            }
+	            else {
+	                if (MiniFileMgr.isLocalNativeFile(url)) {
+	                    tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    var tempUrl = url;
+	                    if (tempStr != "")
+	                        url = url.split(tempStr)[1];
+	                    if (!url) {
+	                        url = tempUrl;
+	                    }
+	                    if (MiniAdpter.subNativeFiles && MiniAdpter.subNativeheads.length == 0) {
+	                        for (var key in MiniAdpter.subNativeFiles) {
+	                            var tempArr = MiniAdpter.subNativeFiles[key];
+	                            MiniAdpter.subNativeheads = MiniAdpter.subNativeheads.concat(tempArr);
+	                            for (var aa = 0; aa < tempArr.length; aa++) {
+	                                MiniAdpter.subMaps[tempArr[aa]] = key + "/" + tempArr[aa];
+	                            }
+	                        }
+	                    }
+	                    if (MiniAdpter.subNativeFiles && url.indexOf("/") != -1) {
+	                        var curfileHead = url.split("/")[0] + "/";
+	                        if (curfileHead && MiniAdpter.subNativeheads.indexOf(curfileHead) != -1) {
+	                            var newfileHead = MiniAdpter.subMaps[curfileHead];
+	                            url = url.replace(curfileHead, newfileHead);
+	                        }
+	                    }
+	                    this.onDownLoadCallBack(url, 0);
+	                }
+	                else {
+	                    if (!MiniFileMgr.isLocalNativeFile(url) && (url.indexOf("http://") == -1 && url.indexOf("https://") == -1) || (url.indexOf("http://usr/") != -1)) {
+	                        this.onDownLoadCallBack(url, 0);
+	                    }
+	                    else {
+	                        MiniFileMgr.downOtherFiles(url, Laya.Handler.create(this, this.onDownLoadCallBack, [url]), url);
+	                    }
+	                }
+	            }
+	        }
+	    }
+	    onDownLoadCallBack(sourceUrl, errorCode, tempFilePath = null) {
+	        if (!errorCode) {
+	            var fileNativeUrl;
+	            if (MiniAdpter.autoCacheFile) {
+	                if (!tempFilePath) {
+	                    if (MiniFileMgr.isLocalNativeFile(sourceUrl)) {
+	                        var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                        var tempUrl = sourceUrl;
+	                        if (tempStr != "" && (sourceUrl.indexOf("http://") != -1 || sourceUrl.indexOf("https://") != -1))
+	                            fileNativeUrl = sourceUrl.split(tempStr)[1];
+	                        if (!fileNativeUrl) {
+	                            fileNativeUrl = tempUrl;
+	                        }
+	                    }
+	                    else {
+	                        var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                        if (fileObj && fileObj.md5) {
+	                            var fileMd5Name = fileObj.md5;
+	                            fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                        }
+	                        else {
+	                            fileNativeUrl = sourceUrl;
+	                        }
+	                    }
+	                }
+	                else {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	                if (this.url != Laya.SoundManager._bgMusic) {
+	                    this._sound = MiniSound._createSound();
+	                    this._sound.src = this.url = fileNativeUrl;
+	                }
+	                else {
+	                    this._sound = MiniSound._musicAudio;
+	                    this._sound.src = this.url = fileNativeUrl;
+	                }
+	            }
+	            else {
+	                if (this.url != Laya.SoundManager._bgMusic) {
+	                    this._sound = MiniSound._createSound();
+	                    this._sound.src = sourceUrl;
+	                }
+	                else {
+	                    this._sound = MiniSound._musicAudio;
+	                    this._sound.src = sourceUrl;
+	                }
+	            }
+	            this._sound.onCanplay(MiniSound.bindToThis(this.onCanPlay, this));
+	            this._sound.onError(MiniSound.bindToThis(this.onError, this));
+	        }
+	        else {
+	            this.event(Laya.Event.ERROR);
+	        }
+	    }
+	    onError(error) {
+	        try {
+	            console.log("-----1---------------minisound-----id:" + MiniSound._id);
+	            console.log(error);
+	        }
+	        catch (error) {
+	            console.log("-----2---------------minisound-----id:" + MiniSound._id);
+	            console.log(error);
+	        }
+	        this.event(Laya.Event.ERROR);
+	        this._sound.offError(null);
+	    }
+	    onCanPlay() {
+	        this.loaded = true;
+	        this.event(Laya.Event.COMPLETE);
+	        this._sound.offCanplay(null);
+	    }
+	    static bindToThis(fun, scope) {
+	        var rst = fun;
+	        rst = fun.bind(scope);
+	        return rst;
+	    }
+	    play(startTime = 0, loops = 0) {
+	        var tSound;
+	        if (this.url == Laya.SoundManager._bgMusic) {
+	            if (!MiniSound._musicAudio)
+	                MiniSound._musicAudio = MiniSound._createSound();
+	            tSound = MiniSound._musicAudio;
+	        }
+	        else {
+	            if (MiniSound._audioCache[this.readyUrl]) {
+	                tSound = MiniSound._audioCache[this.readyUrl]._sound;
+	            }
+	            else {
+	                tSound = MiniSound._createSound();
+	            }
+	        }
+	        if (!tSound)
+	            return null;
+	        if (MiniAdpter.autoCacheFile && MiniFileMgr.getFileInfo(this.url)) {
+	            var fileObj = MiniFileMgr.getFileInfo(this.url);
+	            var fileMd5Name = fileObj.md5;
+	            tSound.src = this.url = MiniFileMgr.getFileNativePath(fileMd5Name);
+	        }
+	        else {
+	            tSound.src = this.url;
+	        }
+	        var channel = new MiniSoundChannel(tSound, this);
+	        channel.url = this.url;
+	        channel.loops = loops;
+	        channel.loop = (loops === 0 ? true : false);
+	        channel.startTime = startTime;
+	        channel.play();
+	        Laya.SoundManager.addChannel(channel);
+	        return channel;
+	    }
+	    get duration() {
+	        return this._sound.duration;
+	    }
+	    dispose() {
+	        var ad = MiniSound._audioCache[this.readyUrl];
+	        if (ad) {
+	            ad.src = "";
+	            if (ad._sound) {
+	                ad._sound.destroy();
+	                ad._sound = null;
+	                ad = null;
+	            }
+	            delete MiniSound._audioCache[this.readyUrl];
+	        }
+	        if (this._sound) {
+	            this._sound.destroy();
+	            this._sound = null;
+	            this.readyUrl = this.url = null;
+	        }
+	    }
+	}
+	MiniSound._id = 0;
+	MiniSound._audioCache = {};
+
+	class MiniInput {
+	    constructor() {
+	    }
+	    static _createInputElement() {
+	        Laya.Input['_initInput'](Laya.Input['area'] = Laya.Browser.createElement("textarea"));
+	        Laya.Input['_initInput'](Laya.Input['input'] = Laya.Browser.createElement("input"));
+	        Laya.Input['inputContainer'] = Laya.Browser.createElement("div");
+	        Laya.Input['inputContainer'].style.position = "absolute";
+	        Laya.Input['inputContainer'].style.zIndex = 1E5;
+	        Laya.Browser.container.appendChild(Laya.Input['inputContainer']);
+	        Laya.Laya.stage.on("resize", null, MiniInput._onStageResize);
+	        MiniAdpter.window.wx.onWindowResize && MiniAdpter.window.wx.onWindowResize(function (res) {
+	        });
+	        Laya.SoundManager._soundClass = MiniSound;
+	        Laya.SoundManager._musicClass = MiniSound;
+	        var model = MiniAdpter.systemInfo.model;
+	        var system = MiniAdpter.systemInfo.system;
+	        if (model.indexOf("iPhone") != -1) {
+	            Laya.Browser.onIPhone = true;
+	            Laya.Browser.onIOS = true;
+	            Laya.Browser.onIPad = true;
+	            Laya.Browser.onAndroid = false;
+	        }
+	        if (system.indexOf("Android") != -1 || system.indexOf("Adr") != -1) {
+	            Laya.Browser.onAndroid = true;
+	            Laya.Browser.onIPhone = false;
+	            Laya.Browser.onIOS = false;
+	            Laya.Browser.onIPad = false;
+	        }
+	    }
+	    static _onStageResize() {
+	        var ts = Laya.Laya.stage._canvasTransform.identity();
+	        ts.scale((Laya.Browser.width / Laya.Render.canvas.width / Laya.Browser.pixelRatio), Laya.Browser.height / Laya.Render.canvas.height / Laya.Browser.pixelRatio);
+	    }
+	    static wxinputFocus(e) {
+	        var _inputTarget = Laya.Input['inputElement'].target;
+	        if (_inputTarget && !_inputTarget.editable) {
+	            return;
+	        }
+	        MiniAdpter.window.wx.offKeyboardConfirm();
+	        MiniAdpter.window.wx.offKeyboardInput();
+	        MiniAdpter.window.wx.showKeyboard({ defaultValue: _inputTarget.text, maxLength: _inputTarget.maxChars, multiple: _inputTarget.multiline, confirmHold: true, confirmType: _inputTarget["confirmType"] || 'done', success: function (res) {
+	            }, fail: function (res) {
+	            } });
+	        MiniAdpter.window.wx.onKeyboardConfirm(function (res) {
+	            var str = res ? res.value : "";
+	            if (_inputTarget._restrictPattern) {
+	                str = str.replace(/\u2006|\x27/g, "");
+	                if (_inputTarget._restrictPattern.test(str)) {
+	                    str = str.replace(_inputTarget._restrictPattern, "");
+	                }
+	            }
+	            _inputTarget.text = str;
+	            _inputTarget.event(Laya.Event.INPUT);
+	            MiniInput.inputEnter();
+	            _inputTarget.event("confirm");
+	        });
+	        MiniAdpter.window.wx.onKeyboardInput(function (res) {
+	            var str = res ? res.value : "";
+	            if (!_inputTarget.multiline) {
+	                if (str.indexOf("\n") != -1) {
+	                    MiniInput.inputEnter();
+	                    return;
+	                }
+	            }
+	            if (_inputTarget._restrictPattern) {
+	                str = str.replace(/\u2006|\x27/g, "");
+	                if (_inputTarget._restrictPattern.test(str)) {
+	                    str = str.replace(_inputTarget._restrictPattern, "");
+	                }
+	            }
+	            _inputTarget.text = str;
+	            _inputTarget.event(Laya.Event.INPUT);
+	        });
+	    }
+	    static inputEnter() {
+	        Laya.Input['inputElement'].target.focus = false;
+	    }
+	    static wxinputblur() {
+	        MiniInput.hideKeyboard();
+	    }
+	    static hideKeyboard() {
+	        MiniAdpter.window.wx.offKeyboardConfirm();
+	        MiniAdpter.window.wx.offKeyboardInput();
+	        MiniAdpter.window.wx.hideKeyboard({ success: function (res) {
+	                console.log('隐藏键盘');
+	            }, fail: function (res) {
+	                console.log("隐藏键盘出错:" + (res ? res.errMsg : ""));
+	            } });
+	    }
+	}
+
+	class MiniLoader extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	    }
+	    _loadResourceFilter(type, url) {
+	        var thisLoader = this;
+	        if (url.indexOf(MiniAdpter.window.wx.env.USER_DATA_PATH) == -1 && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1)) {
+	            if (MiniFileMgr.loadPath != "") {
+	                url = url.split(MiniFileMgr.loadPath)[1];
+	            }
+	            else {
+	                var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                var tempUrl = url;
+	                if (tempStr != "")
+	                    url = url.split(tempStr)[1];
+	                if (!url) {
+	                    url = tempUrl;
+	                }
+	            }
+	        }
+	        if (MiniAdpter.subNativeFiles && MiniAdpter.subNativeheads.length == 0) {
+	            for (var key in MiniAdpter.subNativeFiles) {
+	                var tempArr = MiniAdpter.subNativeFiles[key];
+	                MiniAdpter.subNativeheads = MiniAdpter.subNativeheads.concat(tempArr);
+	                for (var aa = 0; aa < tempArr.length; aa++) {
+	                    MiniAdpter.subMaps[tempArr[aa]] = key + "/" + tempArr[aa];
+	                }
+	            }
+	        }
+	        if (MiniAdpter.subNativeFiles && url.indexOf("/") != -1) {
+	            var curfileHead = url.split("/")[0] + "/";
+	            if (curfileHead && MiniAdpter.subNativeheads.indexOf(curfileHead) != -1) {
+	                var newfileHead = MiniAdpter.subMaps[curfileHead];
+	                url = url.replace(curfileHead, newfileHead);
+	            }
+	        }
+	        switch (type) {
+	            case Laya.Loader.IMAGE:
+	            case "htmlimage":
+	            case "nativeimage":
+	                MiniLoader._transformImgUrl(url, type, thisLoader);
+	                break;
+	            case Laya.Loader.SOUND:
+	                thisLoader._loadSound(url);
+	                break;
+	            default:
+	                thisLoader._loadResource(type, url);
+	        }
+	    }
+	    _loadSound(url) {
+	        var thisLoader = this;
+	        var fileNativeUrl;
+	        if (MiniFileMgr.isLocalNativeFile(url)) {
+	            var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	            var tempUrl = url;
+	            if (tempStr != "" && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1))
+	                fileNativeUrl = url.split(tempStr)[1];
+	            if (!fileNativeUrl) {
+	                fileNativeUrl = tempUrl;
+	            }
+	            MiniLoader.onDownLoadCallBack(url, thisLoader, 0);
+	        }
+	        else {
+	            var tempurl = Laya.URL.formatURL(url);
+	            if (!MiniFileMgr.isLocalNativeFile(url) && (tempurl.indexOf("http://") == -1 && tempurl.indexOf("https://") == -1) || (tempurl.indexOf(MiniAdpter.window.wx.env.USER_DATA_PATH) != -1)) {
+	                MiniLoader.onDownLoadCallBack(url, thisLoader, 0);
+	            }
+	            else {
+	                MiniFileMgr.downOtherFiles(encodeURI(tempurl), Laya.Handler.create(MiniLoader, MiniLoader.onDownLoadCallBack, [tempurl, thisLoader]), tempurl);
+	            }
+	        }
+	    }
+	    static onDownLoadCallBack(sourceUrl, thisLoader, errorCode, tempFilePath = null) {
+	        if (!errorCode) {
+	            var fileNativeUrl;
+	            if (MiniAdpter.autoCacheFile) {
+	                if (!tempFilePath) {
+	                    if (MiniFileMgr.isLocalNativeFile(sourceUrl)) {
+	                        var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                        var tempUrl = sourceUrl;
+	                        if (tempStr != "" && (sourceUrl.indexOf("http://") != -1 || sourceUrl.indexOf("https://") != -1))
+	                            fileNativeUrl = sourceUrl.split(tempStr)[1];
+	                        if (!fileNativeUrl) {
+	                            fileNativeUrl = tempUrl;
+	                        }
+	                    }
+	                    else {
+	                        var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                        if (fileObj && fileObj.md5) {
+	                            var fileMd5Name = fileObj.md5;
+	                            fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                        }
+	                        else {
+	                            fileNativeUrl = sourceUrl;
+	                        }
+	                    }
+	                }
+	                else {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	            }
+	            sourceUrl = fileNativeUrl;
+	            var sound = (new Laya.SoundManager._soundClass());
+	            sound.load(sourceUrl);
+	            thisLoader.onLoaded(sound);
+	        }
+	        else {
+	            thisLoader.event(Laya.Event.ERROR, "Load sound failed");
+	        }
+	    }
+	    static bindToThis(fun, scope) {
+	        var rst = fun;
+	        rst = fun.bind(scope);
+	        return rst;
+	    }
+	    _loadHttpRequestWhat(url, contentType) {
+	        var thisLoader = this;
+	        var encoding = MiniAdpter.getUrlEncode(url, contentType);
+	        if (Laya.Loader.preLoadedMap[url])
+	            thisLoader.onLoaded(Laya.Loader.preLoadedMap[url]);
+	        else {
+	            var tempurl = Laya.URL.formatURL(url);
+	            if (!MiniFileMgr.isLocalNativeFile(url) && !MiniFileMgr.getFileInfo(tempurl) && url.indexOf(MiniAdpter.window.wx.env.USER_DATA_PATH) == -1 && (tempurl.indexOf("http://") != -1 || tempurl.indexOf("https://") != -1) && !MiniAdpter.AutoCacheDownFile) {
+	                thisLoader._loadHttpRequest(tempurl, contentType, thisLoader, thisLoader.onLoaded, thisLoader, thisLoader.onProgress, thisLoader, thisLoader.onError);
+	            }
+	            else {
+	                var fileObj = MiniFileMgr.getFileInfo(Laya.URL.formatURL(url));
+	                if (fileObj) {
+	                    fileObj.encoding = fileObj.encoding == null ? "utf8" : fileObj.encoding;
+	                    MiniFileMgr.readFile(MiniFileMgr.getFileNativePath(fileObj.md5), encoding, new Laya.Handler(MiniLoader, MiniLoader.onReadNativeCallBack, [url, contentType, thisLoader]), url);
+	                }
+	                else if (thisLoader.type == "image" || thisLoader.type == "htmlimage") {
+	                    thisLoader._transformUrl(url, contentType);
+	                }
+	                else {
+	                    if (contentType != Laya.Loader.IMAGE && ((tempurl.indexOf("http://") == -1 && tempurl.indexOf("https://") == -1) || MiniFileMgr.isLocalNativeFile(url))) {
+	                        MiniFileMgr.readFile(url, encoding, new Laya.Handler(MiniLoader, MiniLoader.onReadNativeCallBack, [url, contentType, thisLoader]), url);
+	                    }
+	                    else {
+	                        MiniFileMgr.downFiles(tempurl, encoding, new Laya.Handler(MiniLoader, MiniLoader.onReadNativeCallBack, [url, contentType, thisLoader]), tempurl, true);
+	                    }
+	                }
+	            }
+	        }
+	    }
+	    static onReadNativeCallBack(url, type = null, thisLoader = null, errorCode = 0, data = null) {
+	        if (!errorCode) {
+	            var tempData;
+	            if (type == Laya.Loader.JSON || type == Laya.Loader.ATLAS || type == Laya.Loader.PREFAB || type == Laya.Loader.PLF) {
+	                tempData = MiniAdpter.getJson(data.data);
+	            }
+	            else if (type == Laya.Loader.XML) {
+	                tempData = Laya.Utils.parseXMLFromString(data.data);
+	            }
+	            else {
+	                tempData = data.data;
+	            }
+	            if (!MiniAdpter.isZiYu && MiniAdpter.isPosMsgYu && type != Laya.Loader.BUFFER) {
+	                MiniAdpter.window.wx.postMessage({ url: url, data: tempData, isLoad: "filedata" });
+	            }
+	            thisLoader.onLoaded(tempData);
+	        }
+	        else if (errorCode == 1) {
+	            thisLoader._loadHttpRequest(url, type, thisLoader, thisLoader.onLoaded, thisLoader, thisLoader.onProgress, thisLoader, thisLoader.onError);
+	        }
+	    }
+	    static _transformImgUrl(url, type, thisLoader) {
+	        if (MiniAdpter.isZiYu) {
+	            thisLoader._loadImage(url, false);
+	            return;
+	        }
+	        if (MiniFileMgr.isLocalNativeFile(url)) {
+	            thisLoader._loadImage(url, false);
+	            return;
+	        }
+	        if (!MiniFileMgr.isLocalNativeFile(url) && !MiniFileMgr.getFileInfo(Laya.URL.formatURL(url))) {
+	            var tempUrl = Laya.URL.formatURL(url);
+	            if (url.indexOf(MiniAdpter.window.wx.env.USER_DATA_PATH) == -1 && (tempUrl.indexOf("http://") != -1 || tempUrl.indexOf("https://") != -1)) {
+	                if (MiniAdpter.isZiYu) {
+	                    thisLoader._loadImage(url, false);
+	                }
+	                else {
+	                    MiniFileMgr.downOtherFiles(tempUrl, new Laya.Handler(MiniLoader, MiniLoader.onDownImgCallBack, [url, thisLoader]), tempUrl);
+	                }
+	            }
+	            else
+	                thisLoader._loadImage(url, false);
+	        }
+	        else {
+	            MiniLoader.onCreateImage(url, thisLoader);
+	        }
+	    }
+	    static onDownImgCallBack(sourceUrl, thisLoader, errorCode, tempFilePath = "") {
+	        if (!errorCode)
+	            MiniLoader.onCreateImage(sourceUrl, thisLoader, false, tempFilePath);
+	        else {
+	            thisLoader.onError(null);
+	        }
+	    }
+	    static onCreateImage(sourceUrl, thisLoader, isLocal = false, tempFilePath = "") {
+	        var fileNativeUrl;
+	        if (MiniAdpter.autoCacheFile) {
+	            if (!isLocal) {
+	                if (tempFilePath != "") {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	                else {
+	                    var fileObj = MiniFileMgr.getFileInfo(Laya.URL.formatURL(sourceUrl));
+	                    var fileMd5Name = fileObj.md5;
+	                    fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                }
+	            }
+	            else if (MiniAdpter.isZiYu) {
+	                var tempUrl = Laya.URL.formatURL(sourceUrl);
+	                if (MiniFileMgr.ziyuFileTextureData[tempUrl]) {
+	                    fileNativeUrl = MiniFileMgr.ziyuFileTextureData[tempUrl];
+	                }
+	                else
+	                    fileNativeUrl = sourceUrl;
+	            }
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        else {
+	            if (!isLocal)
+	                fileNativeUrl = tempFilePath;
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        thisLoader._loadImage(fileNativeUrl, false);
+	    }
+	}
+
+	class MiniLocalStorage {
+	    constructor() {
+	    }
+	    static __init__() {
+	        MiniLocalStorage.items = MiniLocalStorage;
+	    }
+	    static setItem(key, value) {
+	        try {
+	            MiniAdpter.window.wx.setStorageSync(key, value);
+	        }
+	        catch (error) {
+	            MiniAdpter.window.wx.setStorage({
+	                key: key,
+	                data: value
+	            });
+	        }
+	    }
+	    static getItem(key) {
+	        return MiniAdpter.window.wx.getStorageSync(key);
+	    }
+	    static setJSON(key, value) {
+	        MiniLocalStorage.setItem(key, value);
+	    }
+	    static getJSON(key) {
+	        return MiniLocalStorage.getItem(key);
+	    }
+	    static removeItem(key) {
+	        MiniAdpter.window.wx.removeStorageSync(key);
+	    }
+	    static clear() {
+	        MiniAdpter.window.wx.clearStorageSync();
+	    }
+	    static getStorageInfoSync() {
+	        try {
+	            var res = MiniAdpter.window.wx.getStorageInfoSync();
+	            console.log(res.keys);
+	            console.log(res.currentSize);
+	            console.log(res.limitSize);
+	            return res;
+	        }
+	        catch (e) {
+	        }
+	        return null;
+	    }
+	}
+	MiniLocalStorage.support = true;
+
+	class MiniAdpter {
+	    static getJson(data) {
+	        return JSON.parse(data);
+	    }
+	    static enable() {
+	        MiniAdpter.init(Laya.Laya.isWXPosMsg, Laya.Laya.isWXOpenDataContext);
+	    }
+	    static init(isPosMsg = false, isSon = false) {
+	        if (MiniAdpter._inited)
+	            return;
+	        MiniAdpter._inited = true;
+	        MiniAdpter.window = window;
+	        if (!MiniAdpter.window.hasOwnProperty("wx"))
+	            return;
+	        if (MiniAdpter.window.navigator.userAgent.indexOf('MiniGame') < 0)
+	            return;
+	        MiniAdpter.isZiYu = isSon;
+	        MiniAdpter.isPosMsgYu = isPosMsg;
+	        MiniAdpter.EnvConfig = {};
+	        if (!MiniAdpter.isZiYu) {
+	            MiniFileMgr.setNativeFileDir("/layaairGame");
+	            MiniFileMgr.existDir(MiniFileMgr.fileNativeDir, Laya.Handler.create(MiniAdpter, MiniAdpter.onMkdirCallBack));
+	        }
+	        MiniAdpter.systemInfo = MiniAdpter.window.wx.getSystemInfoSync();
+	        MiniAdpter.window.focus = function () {
+	        };
+	        Laya.Laya['_getUrlPath'] = function () {
+	            return "";
+	        };
+	        MiniAdpter.window.logtime = function (str) {
+	        };
+	        MiniAdpter.window.alertTimeLog = function (str) {
+	        };
+	        MiniAdpter.window.resetShareInfo = function () {
+	        };
+	        MiniAdpter.window.CanvasRenderingContext2D = function () {
+	        };
+	        MiniAdpter.window.CanvasRenderingContext2D.prototype = MiniAdpter.window.wx.createCanvas().getContext('2d').__proto__;
+	        MiniAdpter.window.document.body.appendChild = function () {
+	        };
+	        MiniAdpter.EnvConfig.pixelRatioInt = 0;
+	        Laya.Browser["_pixelRatio"] = MiniAdpter.pixelRatio();
+	        MiniAdpter._preCreateElement = Laya.Browser.createElement;
+	        Laya.Browser["createElement"] = MiniAdpter.createElement;
+	        Laya.RunDriver.createShaderCondition = MiniAdpter.createShaderCondition;
+	        Laya.Utils['parseXMLFromString'] = MiniAdpter.parseXMLFromString;
+	        Laya.Input['_createInputElement'] = MiniInput['_createInputElement'];
+	        Laya.Loader.prototype._loadResourceFilter = MiniLoader.prototype._loadResourceFilter;
+	        Laya.Loader.prototype._loadSound = MiniLoader.prototype._loadSound;
+	        Laya.Loader.prototype._loadHttpRequestWhat = MiniLoader.prototype._loadHttpRequestWhat;
+	        Laya.LocalStorage._baseClass = MiniLocalStorage;
+	        MiniLocalStorage.__init__();
+	        MiniAdpter.window.wx.onMessage && MiniAdpter.window.wx.onMessage(MiniAdpter._onMessage);
+	    }
+	    static _onMessage(data) {
+	        switch (data.type) {
+	            case "changeMatrix":
+	                Laya.Laya.stage.transform.identity();
+	                Laya.Laya.stage._width = data.w;
+	                Laya.Laya.stage._height = data.h;
+	                Laya.Laya.stage._canvasTransform = new Laya.Matrix(data.a, data.b, data.c, data.d, data.tx, data.ty);
+	                break;
+	            case "display":
+	                Laya.Laya.stage.frameRate = data.rate || Laya.Stage.FRAME_FAST;
+	                break;
+	            case "undisplay":
+	                Laya.Laya.stage.frameRate = Laya.Stage.FRAME_SLEEP;
+	                break;
+	        }
+	        if (data['isLoad'] == "opendatacontext") {
+	            if (data.url) {
+	                MiniFileMgr.ziyuFileData[data.url] = data.atlasdata;
+	                MiniFileMgr.ziyuFileTextureData[data.imgReadyUrl] = data.imgNativeUrl;
+	            }
+	        }
+	        else if (data['isLoad'] == "openJsondatacontext") {
+	            if (data.url) {
+	                MiniFileMgr.ziyuFileData[data.url] = data.atlasdata;
+	            }
+	        }
+	        else if (data['isLoad'] == "openJsondatacontextPic") {
+	            MiniFileMgr.ziyuFileTextureData[data.imgReadyUrl] = data.imgNativeUrl;
+	        }
+	    }
+	    static getUrlEncode(url, type) {
+	        if (type == "arraybuffer")
+	            return "";
+	        return "utf8";
+	    }
+	    static downLoadFile(fileUrl, fileType = "", callBack = null, encoding = "utf8") {
+	        var fileObj = MiniFileMgr.getFileInfo(fileUrl);
+	        if (!fileObj)
+	            MiniFileMgr.downLoadFile(fileUrl, fileType, callBack, encoding);
+	        else {
+	            callBack != null && callBack.runWith([0]);
+	        }
+	    }
+	    static remove(fileUrl, callBack = null) {
+	        MiniFileMgr.deleteFile("", fileUrl, callBack, "", 0);
+	    }
+	    static removeAll() {
+	        MiniFileMgr.deleteAll();
+	    }
+	    static hasNativeFile(fileUrl) {
+	        return MiniFileMgr.isLocalNativeFile(fileUrl);
+	    }
+	    static getFileInfo(fileUrl) {
+	        return MiniFileMgr.getFileInfo(fileUrl);
+	    }
+	    static getFileList() {
+	        return MiniFileMgr.filesListObj;
+	    }
+	    static exitMiniProgram() {
+	        MiniAdpter.window["wx"].exitMiniProgram();
+	    }
+	    static onMkdirCallBack(errorCode, data) {
+	        if (!errorCode)
+	            MiniFileMgr.filesListObj = JSON.parse(data.data);
+	        MiniFileMgr.fakeObj = MiniFileMgr.filesListObj;
+	    }
+	    static pixelRatio() {
+	        if (!MiniAdpter.EnvConfig.pixelRatioInt) {
+	            try {
+	                MiniAdpter.EnvConfig.pixelRatioInt = MiniAdpter.systemInfo.pixelRatio;
+	                return MiniAdpter.systemInfo.pixelRatio;
+	            }
+	            catch (error) {
+	            }
+	        }
+	        return MiniAdpter.EnvConfig.pixelRatioInt;
+	    }
+	    static createElement(type) {
+	        if (type == "canvas") {
+	            var _source;
+	            if (MiniAdpter.idx == 1) {
+	                if (MiniAdpter.isZiYu) {
+	                    _source = MiniAdpter.window.sharedCanvas;
+	                    _source.style = {};
+	                }
+	                else {
+	                    _source = MiniAdpter.window.canvas;
+	                }
+	            }
+	            else {
+	                _source = MiniAdpter.window.wx.createCanvas();
+	            }
+	            MiniAdpter.idx++;
+	            return _source;
+	        }
+	        else if (type == "textarea" || type == "input") {
+	            return MiniAdpter.onCreateInput(type);
+	        }
+	        else if (type == "div") {
+	            var node = MiniAdpter._preCreateElement(type);
+	            node.contains = function (value) {
+	                return null;
+	            };
+	            node.removeChild = function (value) {
+	            };
+	            return node;
+	        }
+	        else {
+	            return MiniAdpter._preCreateElement(type);
+	        }
+	    }
+	    static onCreateInput(type) {
+	        var node = MiniAdpter._preCreateElement(type);
+	        node.focus = MiniInput.wxinputFocus;
+	        node.blur = MiniInput.wxinputblur;
+	        node.style = {};
+	        node.value = 0;
+	        node.parentElement = {};
+	        node.placeholder = {};
+	        node.type = {};
+	        node.setColor = function (value) {
+	        };
+	        node.setType = function (value) {
+	        };
+	        node.setFontFace = function (value) {
+	        };
+	        node.addEventListener = function (value) {
+	        };
+	        node.contains = function (value) {
+	            return null;
+	        };
+	        node.removeChild = function (value) {
+	        };
+	        return node;
+	    }
+	    static createShaderCondition(conditionScript) {
+	        var func = function () {
+	            return this[conditionScript.replace("this.", "")];
+	        };
+	        return func;
+	    }
+	    static sendAtlasToOpenDataContext(url) {
+	        if (!MiniAdpter.isZiYu) {
+	            var atlasJson = Laya.Loader.getRes(Laya.URL.formatURL(url));
+	            if (atlasJson) {
+	                var textureArr = atlasJson.meta.image.split(",");
+	                if (atlasJson.meta && atlasJson.meta.image) {
+	                    var toloadPics = atlasJson.meta.image.split(",");
+	                    var split = url.indexOf("/") >= 0 ? "/" : "\\";
+	                    var idx = url.lastIndexOf(split);
+	                    var folderPath = idx >= 0 ? url.substr(0, idx + 1) : "";
+	                    for (var i = 0, len = toloadPics.length; i < len; i++) {
+	                        toloadPics[i] = folderPath + toloadPics[i];
+	                    }
+	                }
+	                else {
+	                    toloadPics = [url.replace(".json", ".png")];
+	                }
+	                for (i = 0; i < toloadPics.length; i++) {
+	                    var tempAtlasPngUrl = toloadPics[i];
+	                    MiniAdpter.postInfoToContext(Laya.Laya.URL.formatURL(url), Laya.Laya.URL.formatURL(tempAtlasPngUrl), atlasJson);
+	                }
+	            }
+	            else {
+	                throw "传递的url没有获取到对应的图集数据信息,请确保图集已经过!";
+	            }
+	        }
+	    }
+	    static postInfoToContext(url, atlaspngUrl, atlasJson) {
+	        var postData = { "frames": atlasJson.frames, "meta": atlasJson.meta };
+	        var textureUrl = atlaspngUrl;
+	        var fileObj = MiniFileMgr.getFileInfo(Laya.URL.formatURL(atlaspngUrl));
+	        if (fileObj) {
+	            var fileMd5Name = fileObj.md5;
+	            var fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	        }
+	        else {
+	            fileNativeUrl = textureUrl;
+	        }
+	        if (fileNativeUrl) {
+	            MiniAdpter.window.wx.postMessage({ url: url, atlasdata: postData, imgNativeUrl: fileNativeUrl, imgReadyUrl: textureUrl, isLoad: "opendatacontext" });
+	        }
+	        else {
+	            throw "获取图集的磁盘url路径不存在!";
+	        }
+	    }
+	    static sendSinglePicToOpenDataContext(url) {
+	        var tempTextureUrl = Laya.URL.formatURL(url);
+	        var fileObj = MiniFileMgr.getFileInfo(tempTextureUrl);
+	        if (fileObj) {
+	            var fileMd5Name = fileObj.md5;
+	            var fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	            url = tempTextureUrl;
+	        }
+	        else {
+	            fileNativeUrl = url;
+	        }
+	        if (fileNativeUrl) {
+	            url = Laya.Laya.URL.formatURL(url);
+	            MiniAdpter.window.wx.postMessage({ url: url, imgNativeUrl: fileNativeUrl, imgReadyUrl: url, isLoad: "openJsondatacontextPic" });
+	        }
+	        else {
+	            throw "获取图集的磁盘url路径不存在!";
+	        }
+	    }
+	    static sendJsonDataToDataContext(url) {
+	        if (!MiniAdpter.isZiYu) {
+	            url = Laya.Laya.URL.formatURL(url);
+	            var atlasJson = Laya.Loader.getRes(url);
+	            if (atlasJson) {
+	                MiniAdpter.window.wx.postMessage({ url: url, atlasdata: atlasJson, isLoad: "openJsondatacontext" });
+	            }
+	            else {
+	                throw "传递的url没有获取到对应的图集数据信息,请确保图集已经过!";
+	            }
+	        }
+	    }
+	}
+	MiniAdpter._inited = false;
+	MiniAdpter.autoCacheFile = true;
+	MiniAdpter.minClearSize = (5 * 1024 * 1024);
+	MiniAdpter.nativefiles = ["layaNativeDir", "wxlocal"];
+	MiniAdpter.subNativeFiles = [];
+	MiniAdpter.subNativeheads = [];
+	MiniAdpter.subMaps = [];
+	MiniAdpter.AutoCacheDownFile = false;
+	MiniAdpter.parseXMLFromString = function (value) {
+	    var rst;
+	    value = value.replace(/>\s+</g, '><');
+	    try {
+	        rst = (new MiniAdpter.window.Parser.DOMParser()).parseFromString(value, 'text/xml');
+	    }
+	    catch (error) {
+	        throw "需要引入xml解析库文件";
+	    }
+	    return rst;
+	};
+	MiniAdpter.idx = 1;
+
+	class MiniAccelerator extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	    }
+	    static __init__() {
+	        try {
+	            var Acc;
+	            Acc = Laya.Accelerator;
+	            if (!Acc)
+	                return;
+	            Acc["prototype"]["on"] = MiniAccelerator["prototype"]["on"];
+	            Acc["prototype"]["off"] = MiniAccelerator["prototype"]["off"];
+	        }
+	        catch (e) {
+	        }
+	    }
+	    static startListen(callBack) {
+	        MiniAccelerator._callBack = callBack;
+	        if (MiniAccelerator._isListening)
+	            return;
+	        MiniAccelerator._isListening = true;
+	        try {
+	            MiniAdpter.window.wx.onAccelerometerChange(MiniAccelerator.onAccelerometerChange);
+	        }
+	        catch (e) { }
+	    }
+	    static stopListen() {
+	        MiniAccelerator._isListening = false;
+	        try {
+	            MiniAdpter.window.wx.stopAccelerometer({});
+	        }
+	        catch (e) { }
+	    }
+	    static onAccelerometerChange(res) {
+	        var e;
+	        e = {};
+	        e.acceleration = res;
+	        e.accelerationIncludingGravity = res;
+	        e.rotationRate = {};
+	        if (MiniAccelerator._callBack != null) {
+	            MiniAccelerator._callBack(e);
+	        }
+	    }
+	    on(type, caller, listener, args = null) {
+	        super.on(type, caller, listener, args);
+	        MiniAccelerator.startListen(this["onDeviceOrientationChange"]);
+	        return this;
+	    }
+	    off(type, caller, listener, onceOnly = false) {
+	        if (!this.hasListener(type))
+	            MiniAccelerator.stopListen();
+	        return super.off(type, caller, listener, onceOnly);
+	    }
+	}
+	MiniAccelerator._isListening = false;
+
+	class MiniImage {
+	    _loadImage(url) {
+	        var thisLoader = this;
+	        if (MiniAdpter.isZiYu) {
+	            MiniImage.onCreateImage(url, thisLoader, true);
+	            return;
+	        }
+	        var isTransformUrl;
+	        if (!MiniFileMgr.isLocalNativeFile(url)) {
+	            isTransformUrl = true;
+	            url = Laya.URL.formatURL(url);
+	        }
+	        else {
+	            if (url.indexOf(MiniAdpter.window.wx.env.USER_DATA_PATH) == -1 && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1)) {
+	                if (MiniFileMgr.loadPath != "") {
+	                    url = url.split(MiniFileMgr.loadPath)[1];
+	                }
+	                else {
+	                    var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    var tempUrl = url;
+	                    if (tempStr != "")
+	                        url = url.split(tempStr)[1];
+	                    if (!url) {
+	                        url = tempUrl;
+	                    }
+	                }
+	            }
+	            if (MiniAdpter.subNativeFiles && MiniAdpter.subNativeheads.length == 0) {
+	                for (var key in MiniAdpter.subNativeFiles) {
+	                    var tempArr = MiniAdpter.subNativeFiles[key];
+	                    MiniAdpter.subNativeheads = MiniAdpter.subNativeheads.concat(tempArr);
+	                    for (var aa = 0; aa < tempArr.length; aa++) {
+	                        MiniAdpter.subMaps[tempArr[aa]] = key + "/" + tempArr[aa];
+	                    }
+	                }
+	            }
+	            if (MiniAdpter.subNativeFiles && url.indexOf("/") != -1) {
+	                var curfileHead = url.split("/")[0] + "/";
+	                if (curfileHead && MiniAdpter.subNativeheads.indexOf(curfileHead) != -1) {
+	                    var newfileHead = MiniAdpter.subMaps[curfileHead];
+	                    url = url.replace(curfileHead, newfileHead);
+	                }
+	            }
+	        }
+	        if (!MiniFileMgr.getFileInfo(url)) {
+	            if (url.indexOf(MiniAdpter.window.wx.env.USER_DATA_PATH) == -1 && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1)) {
+	                if (MiniAdpter.isZiYu) {
+	                    MiniImage.onCreateImage(url, thisLoader, true);
+	                }
+	                else {
+	                    MiniFileMgr.downOtherFiles(url, new Laya.Handler(MiniImage, MiniImage.onDownImgCallBack, [url, thisLoader]), url);
+	                }
+	            }
+	            else
+	                MiniImage.onCreateImage(url, thisLoader, true);
+	        }
+	        else {
+	            MiniImage.onCreateImage(url, thisLoader, !isTransformUrl);
+	        }
+	    }
+	    static onDownImgCallBack(sourceUrl, thisLoader, errorCode, tempFilePath = "") {
+	        if (!errorCode)
+	            MiniImage.onCreateImage(sourceUrl, thisLoader, false, tempFilePath);
+	        else {
+	            thisLoader.onError(null);
+	        }
+	    }
+	    static onCreateImage(sourceUrl, thisLoader, isLocal = false, tempFilePath = "") {
+	        var fileNativeUrl;
+	        if (MiniAdpter.autoCacheFile) {
+	            if (!isLocal) {
+	                if (tempFilePath != "") {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	                else {
+	                    var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                    var fileMd5Name = fileObj.md5;
+	                    fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                }
+	            }
+	            else if (MiniAdpter.isZiYu) {
+	                var tempUrl = Laya.URL.formatURL(sourceUrl);
+	                if (MiniFileMgr.ziyuFileTextureData[tempUrl]) {
+	                    fileNativeUrl = MiniFileMgr.ziyuFileTextureData[tempUrl];
+	                }
+	                else
+	                    fileNativeUrl = sourceUrl;
+	            }
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        else {
+	            if (!isLocal)
+	                fileNativeUrl = tempFilePath;
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        if (thisLoader._imgCache == null)
+	            thisLoader._imgCache = {};
+	        var image;
+	        function clear() {
+	            var img = thisLoader._imgCache[fileNativeUrl];
+	            if (img) {
+	                img.onload = null;
+	                img.onerror = null;
+	                delete thisLoader._imgCache[fileNativeUrl];
+	            }
+	        }
+	        var onerror = function () {
+	            clear();
+	            delete MiniFileMgr.fakeObj[sourceUrl];
+	            delete MiniFileMgr.filesListObj[sourceUrl];
+	            thisLoader.event(Laya.Event.ERROR, "Load image failed");
+	        };
+	        if (thisLoader._type == "nativeimage") {
+	            var onload = function () {
+	                clear();
+	                thisLoader.onLoaded(image);
+	            };
+	            image = new Laya.Browser.window.Image();
+	            image.crossOrigin = "";
+	            image.onload = onload;
+	            image.onerror = onerror;
+	            image.src = fileNativeUrl;
+	            thisLoader._imgCache[fileNativeUrl] = image;
+	        }
+	        else {
+	            var imageSource = new Laya.Browser.window.Image();
+	            onload = function () {
+	                image = Laya.HTMLImage.create(imageSource.width, imageSource.height);
+	                image.loadImageSource(imageSource, true);
+	                image._setCreateURL(fileNativeUrl);
+	                clear();
+	                thisLoader.onLoaded(image);
+	            };
+	            imageSource.crossOrigin = "";
+	            imageSource.onload = onload;
+	            imageSource.onerror = onerror;
+	            imageSource.src = fileNativeUrl;
+	            thisLoader._imgCache[fileNativeUrl] = imageSource;
+	        }
+	    }
+	}
+
+	class MiniLocation {
+	    constructor() {
+	    }
+	    static __init__() {
+	        MiniAdpter.window.navigator.geolocation.getCurrentPosition = MiniLocation.getCurrentPosition;
+	        MiniAdpter.window.navigator.geolocation.watchPosition = MiniLocation.watchPosition;
+	        MiniAdpter.window.navigator.geolocation.clearWatch = MiniLocation.clearWatch;
+	    }
+	    static getCurrentPosition(success = null, error = null, options = null) {
+	        var paramO;
+	        paramO = {};
+	        paramO.success = getSuccess;
+	        paramO.fail = error;
+	        MiniAdpter.window.wx.getLocation(paramO);
+	        function getSuccess(res) {
+	            if (success != null) {
+	                success(res);
+	            }
+	        }
+	    }
+	    static watchPosition(success = null, error = null, options = null) {
+	        MiniLocation._curID++;
+	        var curWatchO;
+	        curWatchO = {};
+	        curWatchO.success = success;
+	        curWatchO.error = error;
+	        MiniLocation._watchDic[MiniLocation._curID] = curWatchO;
+	        Laya.Laya.systemTimer.loop(1000, null, MiniLocation._myLoop);
+	        return MiniLocation._curID;
+	    }
+	    static clearWatch(id) {
+	        delete MiniLocation._watchDic[id];
+	        if (!MiniLocation._hasWatch()) {
+	            Laya.Laya.systemTimer.clear(null, MiniLocation._myLoop);
+	        }
+	    }
+	    static _hasWatch() {
+	        var key;
+	        for (key in MiniLocation._watchDic) {
+	            if (MiniLocation._watchDic[key])
+	                return true;
+	        }
+	        return false;
+	    }
+	    static _myLoop() {
+	        MiniLocation.getCurrentPosition(MiniLocation._mySuccess, MiniLocation._myError);
+	    }
+	    static _mySuccess(res) {
+	        var rst = {};
+	        rst.coords = res;
+	        rst.timestamp = Laya.Browser.now();
+	        var key;
+	        for (key in MiniLocation._watchDic) {
+	            if (MiniLocation._watchDic[key].success) {
+	                MiniLocation._watchDic[key].success(rst);
+	            }
+	        }
+	    }
+	    static _myError(res) {
+	        var key;
+	        for (key in MiniLocation._watchDic) {
+	            if (MiniLocation._watchDic[key].error) {
+	                MiniLocation._watchDic[key].error(res);
+	            }
+	        }
+	    }
+	}
+	MiniLocation._watchDic = {};
+	MiniLocation._curID = 0;
+
+	class MiniVideo {
+	    constructor(width = 320, height = 240) {
+	        this.videoend = false;
+	        this.videourl = "";
+	        this.videoElement = MiniAdpter.window.wx.createVideo({ width: width, height: height, autoplay: true });
+	    }
+	    static __init__() {
+	    }
+	    on(eventType, ths, callBack) {
+	        if (eventType == "loadedmetadata") {
+	            this.onPlayFunc = callBack.bind(ths);
+	            this.videoElement.onPlay = this.onPlayFunction.bind(this);
+	        }
+	        else if (eventType == "ended") {
+	            this.onEndedFunC = callBack.bind(ths);
+	            this.videoElement.onEnded = this.onEndedFunction.bind(this);
+	        }
+	        this.videoElement.onTimeUpdate = this.onTimeUpdateFunc.bind(this);
+	    }
+	    onTimeUpdateFunc(data) {
+	        this.position = data.position;
+	        this._duration = data.duration;
+	    }
+	    get duration() {
+	        return this._duration;
+	    }
+	    onPlayFunction() {
+	        if (this.videoElement)
+	            this.videoElement.readyState = 200;
+	        console.log("=====视频加载完成========");
+	        this.onPlayFunc != null && this.onPlayFunc();
+	    }
+	    onEndedFunction() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoend = true;
+	        console.log("=====视频播放完毕========");
+	        this.onEndedFunC != null && this.onEndedFunC();
+	    }
+	    off(eventType, ths, callBack) {
+	        if (eventType == "loadedmetadata") {
+	            this.onPlayFunc = callBack.bind(ths);
+	            this.videoElement.offPlay = this.onPlayFunction.bind(this);
+	        }
+	        else if (eventType == "ended") {
+	            this.onEndedFunC = callBack.bind(ths);
+	            this.videoElement.offEnded = this.onEndedFunction.bind(this);
+	        }
+	    }
+	    load(url) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.src = url;
+	    }
+	    play() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoend = false;
+	        this.videoElement.play();
+	    }
+	    pause() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoend = true;
+	        this.videoElement.pause();
+	    }
+	    get currentTime() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.initialTime;
+	    }
+	    set currentTime(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.initialTime = value;
+	    }
+	    get videoWidth() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.width;
+	    }
+	    get videoHeight() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.height;
+	    }
+	    get ended() {
+	        return this.videoend;
+	    }
+	    get loop() {
+	        if (!this.videoElement)
+	            return false;
+	        return this.videoElement.loop;
+	    }
+	    set loop(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.loop = value;
+	    }
+	    get playbackRate() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.playbackRate;
+	    }
+	    set playbackRate(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.playbackRate = value;
+	    }
+	    get muted() {
+	        if (!this.videoElement)
+	            return false;
+	        return this.videoElement.muted;
+	    }
+	    set muted(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.muted = value;
+	    }
+	    get paused() {
+	        if (!this.videoElement)
+	            return false;
+	        return this.videoElement.paused;
+	    }
+	    size(width, height) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.width = width;
+	        this.videoElement.height = height;
+	    }
+	    get x() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.x;
+	    }
+	    set x(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.x = value;
+	    }
+	    get y() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.y;
+	    }
+	    set y(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.y = value;
+	    }
+	    get currentSrc() {
+	        return this.videoElement.src;
+	    }
+	    destroy() {
+	        if (this.videoElement)
+	            this.videoElement.destroy();
+	        this.videoElement = null;
+	        this.onEndedFunC = null;
+	        this.onPlayFunc = null;
+	        this.videoend = false;
+	        this.videourl = null;
+	    }
+	    reload() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.src = this.videourl;
+	    }
+	}
+
+	exports.MiniAccelerator = MiniAccelerator;
+	exports.MiniAdpter = MiniAdpter;
+	exports.MiniFileMgr = MiniFileMgr;
+	exports.MiniImage = MiniImage;
+	exports.MiniInput = MiniInput;
+	exports.MiniLoader = MiniLoader;
+	exports.MiniLocalStorage = MiniLocalStorage;
+	exports.MiniLocation = MiniLocation;
+	exports.MiniSound = MiniSound;
+	exports.MiniSoundChannel = MiniSoundChannel;
+	exports.MiniVideo = MiniVideo;
+
+} 

+ 1693 - 0
ShootingSun/bin/libs/laya.xmmini.js

@@ -0,0 +1,1693 @@
+window.miMiniGame = function (exports, Laya) {
+	'use strict';
+
+	class MiniFileMgr {
+	    static isLocalNativeFile(url) {
+	        for (var i = 0, sz = KGMiniAdapter.nativefiles.length; i < sz; i++) {
+	            if (url.indexOf(KGMiniAdapter.nativefiles[i]) != -1)
+	                return true;
+	        }
+	        return false;
+	    }
+	    static getFileInfo(fileUrl) {
+	        var fileNativePath = fileUrl;
+	        var fileObj = MiniFileMgr.fakeObj[fileNativePath];
+	        if (fileObj == null)
+	            return null;
+	        else
+	            return fileObj;
+	        return null;
+	    }
+	    static read(filePath, encoding = "utf8", callBack = null, readyUrl = "", isSaveFile = false, fileType = "") {
+	        var fileUrl;
+	        if (readyUrl != "" && (readyUrl.indexOf("http://") != -1 || readyUrl.indexOf("https://") != -1)) {
+	            fileUrl = MiniFileMgr.getFileNativePath(filePath);
+	        }
+	        else {
+	            fileUrl = filePath;
+	        }
+	        fileUrl = Laya.URL.getAdptedFilePath(fileUrl);
+	        MiniFileMgr.fs.readFile({ filePath: fileUrl, encoding: encoding, success: function (data) {
+	                callBack != null && callBack.runWith([0, data]);
+	            }, fail: function (data) {
+	                if (data && readyUrl != "")
+	                    MiniFileMgr.downFiles(readyUrl, encoding, callBack, readyUrl, isSaveFile, fileType);
+	                else
+	                    callBack != null && callBack.runWith([1]);
+	            } });
+	    }
+	    static downFiles(fileUrl, encoding = "utf8", callBack = null, readyUrl = "", isSaveFile = false, fileType = "", isAutoClear = true) {
+	        var downloadTask = MiniFileMgr.wxdown({ url: fileUrl, success: function (data) {
+	                if (data.statusCode === 200)
+	                    MiniFileMgr.readFile(data.tempFilePath, encoding, callBack, readyUrl, isSaveFile, fileType, isAutoClear);
+	                else if (data.statusCode === 403) {
+	                    callBack != null && callBack.runWith([0, fileUrl]);
+	                }
+	                else {
+	                    callBack != null && callBack.runWith([1, data]);
+	                }
+	            }, fail: function (data) {
+	                callBack != null && callBack.runWith([1, data]);
+	            } });
+	        downloadTask.onProgressUpdate(function (data) {
+	            callBack != null && callBack.runWith([2, data.progress]);
+	        });
+	    }
+	    static readFile(filePath, encoding = "utf8", callBack = null, readyUrl = "", isSaveFile = false, fileType = "", isAutoClear = true) {
+	        filePath = Laya.URL.getAdptedFilePath(filePath);
+	        MiniFileMgr.fs.readFile({ filePath: filePath, encoding: encoding, success: function (data) {
+	                if (filePath.indexOf(KGMiniAdapter.window.qg.env.USER_DATA_PATH) == -1 && (filePath.indexOf("http://") != -1 || filePath.indexOf("https://") != -1)) {
+	                    if (KGMiniAdapter.autoCacheFile || isSaveFile) {
+	                        callBack != null && callBack.runWith([0, data]);
+	                        MiniFileMgr.copyFile(filePath, readyUrl, null, encoding, isAutoClear);
+	                    }
+	                    else
+	                        callBack != null && callBack.runWith([0, data]);
+	                }
+	                else
+	                    callBack != null && callBack.runWith([0, data]);
+	            }, fail: function (data) {
+	                if (data)
+	                    callBack != null && callBack.runWith([1, data]);
+	            } });
+	    }
+	    static downOtherFiles(fileUrl, callBack = null, readyUrl = "", isSaveFile = false, isAutoClear = true) {
+	        MiniFileMgr.wxdown({ url: fileUrl, success: function (data) {
+	                if (data.statusCode === 200) {
+	                    if ((KGMiniAdapter.autoCacheFile || isSaveFile) && readyUrl.indexOf("qlogo.cn") == -1 && readyUrl.indexOf(".php") == -1) {
+	                        callBack != null && callBack.runWith([0, data.tempFilePath]);
+	                        MiniFileMgr.copyFile(data.tempFilePath, readyUrl, null, "", isAutoClear);
+	                    }
+	                    else
+	                        callBack != null && callBack.runWith([0, data.tempFilePath]);
+	                }
+	                else {
+	                    callBack != null && callBack.runWith([1, data]);
+	                }
+	            }, fail: function (data) {
+	                callBack != null && callBack.runWith([1, data]);
+	            } });
+	    }
+	    static downLoadFile(fileUrl, fileType = "", callBack = null, encoding = "utf8") {
+	        if (window.navigator.userAgent.indexOf('QuickGame') < 0) {
+	            Laya.Laya.loader.load(fileUrl, callBack);
+	        }
+	        else {
+	            if (fileType == Laya.Loader.IMAGE || fileType == Laya.Loader.SOUND)
+	                MiniFileMgr.downOtherFiles(fileUrl, callBack, fileUrl, true, false);
+	            else
+	                MiniFileMgr.downFiles(fileUrl, encoding, callBack, fileUrl, true, fileType, false);
+	        }
+	    }
+	    static copyFile(tempFilePath, readyUrl, callBack, encoding = "", isAutoClear = true) {
+	        var temp = tempFilePath.split("/");
+	        var tempFileName = temp[temp.length - 1];
+	        var fileurlkey = readyUrl;
+	        var fileObj = MiniFileMgr.getFileInfo(readyUrl);
+	        var saveFilePath = MiniFileMgr.getFileNativePath(tempFileName);
+	        MiniFileMgr.fakeObj[fileurlkey] = { md5: tempFileName, readyUrl: readyUrl, size: 0, times: Laya.Browser.now(), encoding: encoding };
+	        var totalSize = 50 * 1024 * 1024;
+	        var chaSize = 4 * 1024 * 1024;
+	        var fileUseSize = MiniFileMgr.getCacheUseSize();
+	        if (fileObj) {
+	            if (fileObj.readyUrl != readyUrl) {
+	                MiniFileMgr.fs.getFileInfo({
+	                    filePath: tempFilePath,
+	                    success: function (data) {
+	                        if ((isAutoClear && (fileUseSize + chaSize + data.size) >= totalSize)) {
+	                            if (data.size > KGMiniAdapter.minClearSize)
+	                                KGMiniAdapter.minClearSize = data.size;
+	                            MiniFileMgr.onClearCacheRes();
+	                        }
+	                        MiniFileMgr.deleteFile(tempFilePath, readyUrl, callBack, encoding, data.size);
+	                    },
+	                    fail: function (data) {
+	                        callBack != null && callBack.runWith([1, data]);
+	                    }
+	                });
+	            }
+	            else
+	                callBack != null && callBack.runWith([0]);
+	        }
+	        else {
+	            MiniFileMgr.fs.getFileInfo({
+	                filePath: tempFilePath,
+	                success: function (data) {
+	                    if ((isAutoClear && (fileUseSize + chaSize + data.size) >= totalSize)) {
+	                        if (data.size > KGMiniAdapter.minClearSize)
+	                            KGMiniAdapter.minClearSize = data.size;
+	                        MiniFileMgr.onClearCacheRes();
+	                    }
+	                    MiniFileMgr.fs.copyFile({ srcPath: tempFilePath, destPath: saveFilePath, success: function (data2) {
+	                            MiniFileMgr.onSaveFile(readyUrl, tempFileName, true, encoding, callBack, data.size);
+	                        }, fail: function (data) {
+	                            callBack != null && callBack.runWith([1, data]);
+	                        } });
+	                },
+	                fail: function (data) {
+	                    callBack != null && callBack.runWith([1, data]);
+	                }
+	            });
+	        }
+	    }
+	    static onClearCacheRes() {
+	        var memSize = KGMiniAdapter.minClearSize;
+	        var tempFileListArr = [];
+	        for (var key in MiniFileMgr.filesListObj) {
+	            if (key != "fileUsedSize")
+	                tempFileListArr.push(MiniFileMgr.filesListObj[key]);
+	        }
+	        MiniFileMgr.sortOn(tempFileListArr, "times", MiniFileMgr.NUMERIC);
+	        var clearSize = 0;
+	        for (var i = 1, sz = tempFileListArr.length; i < sz; i++) {
+	            var fileObj = tempFileListArr[i];
+	            if (clearSize >= memSize)
+	                break;
+	            clearSize += fileObj.size;
+	            MiniFileMgr.deleteFile("", fileObj.readyUrl);
+	        }
+	    }
+	    static sortOn(array, name, options = 0) {
+	        if (options == MiniFileMgr.NUMERIC)
+	            return array.sort(function (a, b) { return a[name] - b[name]; });
+	        if (options == (MiniFileMgr.NUMERIC | MiniFileMgr.DESCENDING))
+	            return array.sort(function (a, b) { return b[name] - a[name]; });
+	        return array.sort(function (a, b) { return a[name] - b[name]; });
+	    }
+	    static getFileNativePath(fileName) {
+	        return MiniFileMgr.fileNativeDir + "/" + fileName;
+	    }
+	    static deleteFile(tempFileName, readyUrl = "", callBack = null, encoding = "", fileSize = 0) {
+	        var fileObj = MiniFileMgr.getFileInfo(readyUrl);
+	        var deleteFileUrl = MiniFileMgr.getFileNativePath(fileObj.md5);
+	        var isAdd = tempFileName != "" ? true : false;
+	        MiniFileMgr.onSaveFile(readyUrl, tempFileName, isAdd, encoding, callBack, fileSize);
+	        MiniFileMgr.fs.unlink({ filePath: deleteFileUrl, success: function (data) {
+	                if (tempFileName != "") {
+	                    var saveFilePath = MiniFileMgr.getFileNativePath(tempFileName);
+	                    MiniFileMgr.fs.copyFile({ srcPath: tempFileName, destPath: saveFilePath, success: function (data) {
+	                        }, fail: function (data) {
+	                            callBack != null && callBack.runWith([1, data]);
+	                        } });
+	                }
+	            }, fail: function (data) {
+	            } });
+	    }
+	    static deleteAll() {
+	        var tempFileListArr = [];
+	        for (var key in MiniFileMgr.filesListObj) {
+	            if (key != "fileUsedSize")
+	                tempFileListArr.push(MiniFileMgr.filesListObj[key]);
+	        }
+	        for (var i = 1, sz = tempFileListArr.length; i < sz; i++) {
+	            var fileObj = tempFileListArr[i];
+	            MiniFileMgr.deleteFile("", fileObj.readyUrl);
+	        }
+	        if (MiniFileMgr.filesListObj && MiniFileMgr.filesListObj.fileUsedSize) {
+	            MiniFileMgr.filesListObj.fileUsedSize = 0;
+	        }
+	        MiniFileMgr.writeFilesList("", JSON.stringify({}), false);
+	    }
+	    static onSaveFile(readyUrl, md5Name, isAdd = true, encoding = "", callBack = null, fileSize = 0) {
+	        var fileurlkey = readyUrl;
+	        if (MiniFileMgr.filesListObj['fileUsedSize'] == null)
+	            MiniFileMgr.filesListObj['fileUsedSize'] = 0;
+	        if (isAdd) {
+	            var fileNativeName = MiniFileMgr.getFileNativePath(md5Name);
+	            MiniFileMgr.filesListObj[fileurlkey] = { md5: md5Name, readyUrl: readyUrl, size: fileSize, times: Laya.Browser.now(), encoding: encoding };
+	            MiniFileMgr.filesListObj['fileUsedSize'] = parseInt(MiniFileMgr.filesListObj['fileUsedSize']) + fileSize;
+	            MiniFileMgr.writeFilesList(fileurlkey, JSON.stringify(MiniFileMgr.filesListObj), true);
+	            callBack != null && callBack.runWith([0]);
+	        }
+	        else {
+	            if (MiniFileMgr.filesListObj[fileurlkey]) {
+	                var deletefileSize = parseInt(MiniFileMgr.filesListObj[fileurlkey].size);
+	                MiniFileMgr.filesListObj['fileUsedSize'] = parseInt(MiniFileMgr.filesListObj['fileUsedSize']) - deletefileSize;
+	                delete MiniFileMgr.filesListObj[fileurlkey];
+	                MiniFileMgr.writeFilesList(fileurlkey, JSON.stringify(MiniFileMgr.filesListObj), false);
+	                callBack != null && callBack.runWith([0]);
+	            }
+	        }
+	    }
+	    static writeFilesList(fileurlkey, filesListStr, isAdd) {
+	        var listFilesPath = MiniFileMgr.fileNativeDir + "/" + MiniFileMgr.fileListName;
+	        MiniFileMgr.fs.writeFile({ filePath: listFilesPath, encoding: 'utf8', data: filesListStr, success: function (data) {
+	            }, fail: function (data) {
+	            } });
+	        if (!KGMiniAdapter.isZiYu && KGMiniAdapter.isPosMsgYu) {
+	            KGMiniAdapter.window.qg.postMessage({ url: fileurlkey, data: MiniFileMgr.filesListObj[fileurlkey], isLoad: "filenative", isAdd: isAdd });
+	        }
+	    }
+	    static getCacheUseSize() {
+	        if (MiniFileMgr.filesListObj && MiniFileMgr.filesListObj['fileUsedSize'])
+	            return MiniFileMgr.filesListObj['fileUsedSize'];
+	        return 0;
+	    }
+	    static existDir(dirPath, callBack) {
+	        MiniFileMgr.fs.mkdir({ dirPath: dirPath, success: function (data) {
+	                callBack != null && callBack.runWith([0, { data: JSON.stringify({}) }]);
+	            }, fail: function (data) {
+	                if (data.errMsg.indexOf("file already exists") != -1)
+	                    MiniFileMgr.readSync(MiniFileMgr.fileListName, "utf8", callBack);
+	                else
+	                    callBack != null && callBack.runWith([1, data]);
+	            } });
+	    }
+	    static readSync(filePath, encoding = "utf8", callBack = null, readyUrl = "") {
+	        var fileUrl = MiniFileMgr.getFileNativePath(filePath);
+	        var filesListStr;
+	        try {
+	            filesListStr = MiniFileMgr.fs.readFileSync(fileUrl, encoding);
+	            callBack != null && callBack.runWith([0, { data: filesListStr }]);
+	        }
+	        catch (error) {
+	            callBack != null && callBack.runWith([1]);
+	        }
+	    }
+	    static setNativeFileDir(value) {
+	        MiniFileMgr.fileNativeDir = KGMiniAdapter.window.qg.env.USER_DATA_PATH + value;
+	    }
+	}
+	MiniFileMgr.fs = window.qg.getFileSystemManager();
+	MiniFileMgr.wxdown = window.qg.downloadFile;
+	MiniFileMgr.filesListObj = {};
+	MiniFileMgr.fakeObj = {};
+	MiniFileMgr.fileListName = "layaairfiles.txt";
+	MiniFileMgr.ziyuFileData = {};
+	MiniFileMgr.ziyuFileTextureData = {};
+	MiniFileMgr.loadPath = "";
+	MiniFileMgr.DESCENDING = 2;
+	MiniFileMgr.NUMERIC = 16;
+
+	class MiniSoundChannel extends Laya.SoundChannel {
+	    constructor(audio, miniSound) {
+	        super();
+	        this._audio = audio;
+	        this._miniSound = miniSound;
+	        this._onEnd = MiniSoundChannel.bindToThis(this.__onEnd, this);
+	        audio.onEnded(this._onEnd);
+	    }
+	    static bindToThis(fun, scope) {
+	        var rst = fun;
+	        rst = fun.bind(scope);
+	        return rst;
+	    }
+	    __onEnd() {
+	        if (this.loops == 1) {
+	            if (this.completeHandler) {
+	                Laya.Laya.systemTimer.once(10, this, this.__runComplete, [this.completeHandler], false);
+	                this.completeHandler = null;
+	            }
+	            this.stop();
+	            this.event(Laya.Event.COMPLETE);
+	            return;
+	        }
+	        if (this.loops > 0) {
+	            this.loops--;
+	        }
+	        this.startTime = 0;
+	        this.play();
+	    }
+	    play() {
+	        this.isStopped = false;
+	        Laya.SoundManager.addChannel(this);
+	        this._audio.play();
+	    }
+	    set startTime(time) {
+	        if (this._audio) {
+	            this._audio.startTime = time;
+	        }
+	    }
+	    set autoplay(value) {
+	        this._audio.autoplay = value;
+	    }
+	    get autoplay() {
+	        return this._audio.autoplay;
+	    }
+	    get position() {
+	        if (!this._audio)
+	            return 0;
+	        return this._audio.currentTime;
+	    }
+	    get duration() {
+	        if (!this._audio)
+	            return 0;
+	        return this._audio.duration;
+	    }
+	    stop() {
+	        this.isStopped = true;
+	        Laya.SoundManager.removeChannel(this);
+	        this.completeHandler = null;
+	        if (!this._audio)
+	            return;
+	        this._audio.stop();
+	        if (!this.loop) {
+	            this._audio.offEnded(null);
+	            this._miniSound.dispose();
+	            this._audio = null;
+	            this._miniSound = null;
+	            this._onEnd = null;
+	        }
+	    }
+	    pause() {
+	        this.isStopped = true;
+	        this._audio.pause();
+	    }
+	    get loop() {
+	        return this._audio.loop;
+	    }
+	    set loop(value) {
+	        this._audio.loop = value;
+	    }
+	    resume() {
+	        if (!this._audio)
+	            return;
+	        this.isStopped = false;
+	        Laya.SoundManager.addChannel(this);
+	        this._audio.play();
+	    }
+	    set volume(v) {
+	        if (!this._audio)
+	            return;
+	        this._audio.volume = v;
+	    }
+	    get volume() {
+	        if (!this._audio)
+	            return 1;
+	        return this._audio.volume;
+	    }
+	}
+
+	class MiniSound extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	        this.loaded = false;
+	    }
+	    static _createSound() {
+	        MiniSound._id++;
+	        return KGMiniAdapter.window.qg.createInnerAudioContext();
+	    }
+	    load(url) {
+	        if (!MiniSound._musicAudio)
+	            MiniSound._musicAudio = MiniSound._createSound();
+	        if (!MiniFileMgr.isLocalNativeFile(url)) {
+	            url = Laya.URL.formatURL(url);
+	        }
+	        else {
+	            if (url.indexOf("http://") != -1 || url.indexOf("https://") != -1) {
+	                if (MiniFileMgr.loadPath != "") {
+	                    url = url.split(MiniFileMgr.loadPath)[1];
+	                }
+	                else {
+	                    var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    if (tempStr != "")
+	                        url = url.split(tempStr)[1];
+	                }
+	            }
+	        }
+	        this.url = url;
+	        this.readyUrl = url;
+	        if (MiniSound._audioCache[this.readyUrl]) {
+	            this.event(Laya.Event.COMPLETE);
+	            return;
+	        }
+	        if (KGMiniAdapter.autoCacheFile && MiniFileMgr.getFileInfo(url)) {
+	            this.onDownLoadCallBack(url, 0);
+	        }
+	        else {
+	            if (!KGMiniAdapter.autoCacheFile) {
+	                this.onDownLoadCallBack(url, 0);
+	            }
+	            else {
+	                if (MiniFileMgr.isLocalNativeFile(url)) {
+	                    tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    var tempUrl = url;
+	                    if (tempStr != "")
+	                        url = url.split(tempStr)[1];
+	                    if (!url) {
+	                        url = tempUrl;
+	                    }
+	                    if (KGMiniAdapter.subNativeFiles && KGMiniAdapter.subNativeheads.length == 0) {
+	                        for (var key in KGMiniAdapter.subNativeFiles) {
+	                            var tempArr = KGMiniAdapter.subNativeFiles[key];
+	                            KGMiniAdapter.subNativeheads = KGMiniAdapter.subNativeheads.concat(tempArr);
+	                            for (var aa = 0; aa < tempArr.length; aa++) {
+	                                KGMiniAdapter.subMaps[tempArr[aa]] = key + "/" + tempArr[aa];
+	                            }
+	                        }
+	                    }
+	                    if (KGMiniAdapter.subNativeFiles && url.indexOf("/") != -1) {
+	                        var curfileHead = url.split("/")[0] + "/";
+	                        if (curfileHead && KGMiniAdapter.subNativeheads.indexOf(curfileHead) != -1) {
+	                            var newfileHead = KGMiniAdapter.subMaps[curfileHead];
+	                            url = url.replace(curfileHead, newfileHead);
+	                        }
+	                    }
+	                    this.onDownLoadCallBack(url, 0);
+	                }
+	                else {
+	                    if (!MiniFileMgr.isLocalNativeFile(url) && (url.indexOf("http://") == -1 && url.indexOf("https://") == -1) || (url.indexOf(KGMiniAdapter.window.qg.env.USER_DATA_PATH) != -1)) {
+	                        this.onDownLoadCallBack(url, 0);
+	                    }
+	                    else {
+	                        MiniFileMgr.downOtherFiles(encodeURI(url), Laya.Handler.create(this, this.onDownLoadCallBack, [url]), url);
+	                    }
+	                }
+	            }
+	        }
+	    }
+	    onDownLoadCallBack(sourceUrl, errorCode) {
+	        if (!errorCode) {
+	            var fileNativeUrl;
+	            if (KGMiniAdapter.autoCacheFile) {
+	                if (MiniFileMgr.isLocalNativeFile(sourceUrl)) {
+	                    var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    var tempUrl = sourceUrl;
+	                    if (tempStr != "" && (sourceUrl.indexOf("http://") != -1 || sourceUrl.indexOf("https://") != -1))
+	                        fileNativeUrl = sourceUrl.split(tempStr)[1];
+	                    if (!fileNativeUrl) {
+	                        fileNativeUrl = tempUrl;
+	                    }
+	                }
+	                else {
+	                    var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                    if (fileObj && fileObj.md5) {
+	                        var fileMd5Name = fileObj.md5;
+	                        fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                    }
+	                    else {
+	                        fileNativeUrl = sourceUrl;
+	                    }
+	                }
+	                if (this.url != Laya.SoundManager._bgMusic) {
+	                    this._sound = MiniSound._createSound();
+	                    this._sound.src = this.url = fileNativeUrl;
+	                }
+	                else {
+	                    this._sound = MiniSound._musicAudio;
+	                    this._sound.src = this.url = fileNativeUrl;
+	                }
+	            }
+	            else {
+	                if (this.url != Laya.SoundManager._bgMusic) {
+	                    this._sound = MiniSound._createSound();
+	                    this._sound.src = sourceUrl;
+	                }
+	                else {
+	                    this._sound = MiniSound._musicAudio;
+	                    this._sound.src = sourceUrl;
+	                }
+	            }
+	            this._sound.onCanplay(MiniSound.bindToThis(this.onCanPlay, this));
+	            this._sound.onError(MiniSound.bindToThis(this.onError, this));
+	        }
+	        else {
+	            this.event(Laya.Event.ERROR);
+	        }
+	    }
+	    onError(error) {
+	        try {
+	            console.log("-----1---------------minisound-----id:" + MiniSound._id);
+	            console.log(error);
+	        }
+	        catch (error) {
+	            console.log("-----2---------------minisound-----id:" + MiniSound._id);
+	            console.log(error);
+	        }
+	        this.event(Laya.Event.ERROR);
+	        this._sound.offError(null);
+	    }
+	    onCanPlay() {
+	        this.loaded = true;
+	        this.event(Laya.Event.COMPLETE);
+	        this._sound.offCanplay(null);
+	    }
+	    static bindToThis(fun, scope) {
+	        var rst = fun;
+	        rst = fun.bind(scope);
+	        return rst;
+	    }
+	    play(startTime = 0, loops = 0) {
+	        var tSound;
+	        if (this.url == Laya.SoundManager._bgMusic) {
+	            if (!MiniSound._musicAudio)
+	                MiniSound._musicAudio = MiniSound._createSound();
+	            tSound = MiniSound._musicAudio;
+	        }
+	        else {
+	            if (MiniSound._audioCache[this.readyUrl]) {
+	                tSound = MiniSound._audioCache[this.readyUrl]._sound;
+	            }
+	            else {
+	                tSound = MiniSound._createSound();
+	            }
+	        }
+	        if (!tSound)
+	            return null;
+	        if (KGMiniAdapter.autoCacheFile && MiniFileMgr.getFileInfo(this.url)) {
+	            var fileObj = MiniFileMgr.getFileInfo(this.url);
+	            var fileMd5Name = fileObj.md5;
+	            tSound.src = this.url = MiniFileMgr.getFileNativePath(fileMd5Name);
+	        }
+	        else {
+	            tSound.src = encodeURI(this.url);
+	        }
+	        var channel = new MiniSoundChannel(tSound, this);
+	        channel.url = this.url;
+	        channel.loops = loops;
+	        channel.loop = (loops === 0 ? true : false);
+	        channel.startTime = startTime;
+	        channel.play();
+	        Laya.SoundManager.addChannel(channel);
+	        return channel;
+	    }
+	    get duration() {
+	        return this._sound.duration;
+	    }
+	    dispose() {
+	        var ad = MiniSound._audioCache[this.readyUrl];
+	        if (ad) {
+	            ad.src = "";
+	            if (ad._sound) {
+	                ad._sound.destroy();
+	                ad._sound = null;
+	                ad = null;
+	            }
+	            delete MiniSound._audioCache[this.readyUrl];
+	        }
+	        if (this._sound) {
+	            this._sound.destroy();
+	            this._sound = null;
+	            this.readyUrl = this.url = null;
+	        }
+	    }
+	}
+	MiniSound._id = 0;
+	MiniSound._audioCache = {};
+
+	class MiniInput {
+	    constructor() {
+	    }
+	    static _createInputElement() {
+	        Laya.Input['_initInput'](Laya.Input['area'] = Laya.Browser.createElement("textarea"));
+	        Laya.Input['_initInput'](Laya.Input['input'] = Laya.Browser.createElement("input"));
+	        Laya.Input['inputContainer'] = Laya.Browser.createElement("div");
+	        Laya.Input['inputContainer'].style.position = "absolute";
+	        Laya.Input['inputContainer'].style.zIndex = 1E5;
+	        Laya.Browser.container.appendChild(Laya.Input['inputContainer']);
+	        Laya.Laya.stage.on("resize", null, MiniInput._onStageResize);
+	        KGMiniAdapter.window.qg.onWindowResize && KGMiniAdapter.window.qg.onWindowResize(function (res) {
+	        });
+	        Laya.SoundManager._soundClass = MiniSound;
+	        Laya.SoundManager._musicClass = MiniSound;
+	        var model = KGMiniAdapter.systemInfo.model;
+	        var system = KGMiniAdapter.systemInfo.system;
+	        if (model.indexOf("iPhone") != -1) {
+	            Laya.Browser.onIPhone = true;
+	            Laya.Browser.onIOS = true;
+	            Laya.Browser.onIPad = true;
+	            Laya.Browser.onAndroid = false;
+	        }
+	        if (system.indexOf("Android") != -1 || system.indexOf("Adr") != -1) {
+	            Laya.Browser.onAndroid = true;
+	            Laya.Browser.onIPhone = false;
+	            Laya.Browser.onIOS = false;
+	            Laya.Browser.onIPad = false;
+	        }
+	    }
+	    static _onStageResize() {
+	        var ts = Laya.Laya.stage._canvasTransform.identity();
+	        ts.scale((Laya.Browser.width / Laya.Render.canvas.width / Laya.Browser.pixelRatio), Laya.Browser.height / Laya.Render.canvas.height / Laya.Browser.pixelRatio);
+	    }
+	    static wxinputFocus(e) {
+	        var _inputTarget = Laya.Input['inputElement'].target;
+	        if (_inputTarget && !_inputTarget.editable) {
+	            return;
+	        }
+	        KGMiniAdapter.window.qg.offKeyboardConfirm();
+	        KGMiniAdapter.window.qg.offKeyboardInput();
+	        KGMiniAdapter.window.qg.showKeyboard({ defaultValue: _inputTarget.text, maxLength: _inputTarget.maxChars, multiple: _inputTarget.multiline, confirmHold: true, confirmType: _inputTarget["confirmType"] || 'done', success: function (res) {
+	            }, fail: function (res) {
+	            } });
+	        KGMiniAdapter.window.qg.onKeyboardConfirm(function (res) {
+	            var str = res ? res.value : "";
+	            if (_inputTarget._restrictPattern) {
+	                str = str.replace(/\u2006|\x27/g, "");
+	                if (_inputTarget._restrictPattern.test(str)) {
+	                    str = str.replace(_inputTarget._restrictPattern, "");
+	                }
+	            }
+	            _inputTarget.text = str;
+	            _inputTarget.event(Laya.Event.INPUT);
+	            MiniInput.inputEnter();
+	            _inputTarget.event("confirm");
+	        });
+	        KGMiniAdapter.window.qg.onKeyboardInput(function (res) {
+	            var str = res ? res.value : "";
+	            if (!_inputTarget.multiline) {
+	                if (str.indexOf("\n") != -1) {
+	                    MiniInput.inputEnter();
+	                    return;
+	                }
+	            }
+	            if (_inputTarget._restrictPattern) {
+	                str = str.replace(/\u2006|\x27/g, "");
+	                if (_inputTarget._restrictPattern.test(str)) {
+	                    str = str.replace(_inputTarget._restrictPattern, "");
+	                }
+	            }
+	            _inputTarget.text = str;
+	            _inputTarget.event(Laya.Event.INPUT);
+	        });
+	    }
+	    static inputEnter() {
+	        Laya.Input['inputElement'].target.focus = false;
+	    }
+	    static wxinputblur() {
+	        MiniInput.hideKeyboard();
+	    }
+	    static hideKeyboard() {
+	        KGMiniAdapter.window.qg.offKeyboardConfirm();
+	        KGMiniAdapter.window.qg.offKeyboardInput();
+	        KGMiniAdapter.window.qg.hideKeyboard({ success: function (res) {
+	                console.log('隐藏键盘');
+	            }, fail: function (res) {
+	                console.log("隐藏键盘出错:" + (res ? res.errMsg : ""));
+	            } });
+	    }
+	}
+
+	class MiniLoader extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	    }
+	    _loadResourceFilter(type, url) {
+	        var thisLoader = this;
+	        if (url.indexOf(KGMiniAdapter.window.qg.env.USER_DATA_PATH) == -1 && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1)) {
+	            if (MiniFileMgr.loadPath != "") {
+	                url = url.split(MiniFileMgr.loadPath)[1];
+	            }
+	            else {
+	                var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                var tempUrl = url;
+	                if (tempStr != "")
+	                    url = url.split(tempStr)[1];
+	                if (!url) {
+	                    url = tempUrl;
+	                }
+	            }
+	        }
+	        if (KGMiniAdapter.subNativeFiles && KGMiniAdapter.subNativeheads.length == 0) {
+	            for (var key in KGMiniAdapter.subNativeFiles) {
+	                var tempArr = KGMiniAdapter.subNativeFiles[key];
+	                KGMiniAdapter.subNativeheads = KGMiniAdapter.subNativeheads.concat(tempArr);
+	                for (var aa = 0; aa < tempArr.length; aa++) {
+	                    KGMiniAdapter.subMaps[tempArr[aa]] = key + "/" + tempArr[aa];
+	                }
+	            }
+	        }
+	        if (KGMiniAdapter.subNativeFiles && url.indexOf("/") != -1) {
+	            var curfileHead = url.split("/")[0] + "/";
+	            if (curfileHead && KGMiniAdapter.subNativeheads.indexOf(curfileHead) != -1) {
+	                var newfileHead = KGMiniAdapter.subMaps[curfileHead];
+	                url = url.replace(curfileHead, newfileHead);
+	            }
+	        }
+	        switch (type) {
+	            case Laya.Loader.IMAGE:
+	            case "htmlimage":
+	            case "nativeimage":
+	                MiniLoader._transformImgUrl(url, type, thisLoader);
+	                break;
+	            case Laya.Loader.SOUND:
+	                thisLoader._loadSound(url);
+	                break;
+	            default:
+	                thisLoader._loadResource(type, url);
+	        }
+	    }
+	    _loadSound(url) {
+	        var thisLoader = this;
+	        var fileNativeUrl;
+	        if (MiniFileMgr.isLocalNativeFile(url)) {
+	            var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	            var tempUrl = url;
+	            if (tempStr != "" && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1))
+	                fileNativeUrl = url.split(tempStr)[1];
+	            if (!fileNativeUrl) {
+	                fileNativeUrl = tempUrl;
+	            }
+	            MiniLoader.onDownLoadCallBack(url, thisLoader, 0);
+	        }
+	        else {
+	            var tempurl = Laya.URL.formatURL(url);
+	            if (!MiniFileMgr.isLocalNativeFile(url) && (tempurl.indexOf("http://") == -1 && tempurl.indexOf("https://") == -1) || (tempurl.indexOf(KGMiniAdapter.window.qg.env.USER_DATA_PATH) != -1)) {
+	                MiniLoader.onDownLoadCallBack(url, thisLoader, 0);
+	            }
+	            else {
+	                MiniFileMgr.downOtherFiles(tempurl, Laya.Handler.create(MiniLoader, MiniLoader.onDownLoadCallBack, [tempurl, thisLoader]), tempurl);
+	            }
+	        }
+	    }
+	    static onDownLoadCallBack(sourceUrl, thisLoader, errorCode, tempFilePath = null) {
+	        if (!errorCode) {
+	            var fileNativeUrl;
+	            if (KGMiniAdapter.autoCacheFile) {
+	                if (!tempFilePath) {
+	                    if (MiniFileMgr.isLocalNativeFile(sourceUrl)) {
+	                        var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                        var tempUrl = sourceUrl;
+	                        if (tempStr != "" && (sourceUrl.indexOf("http://") != -1 || sourceUrl.indexOf("https://") != -1))
+	                            fileNativeUrl = sourceUrl.split(tempStr)[1];
+	                        if (!fileNativeUrl) {
+	                            fileNativeUrl = tempUrl;
+	                        }
+	                    }
+	                    else {
+	                        var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                        if (fileObj && fileObj.md5) {
+	                            var fileMd5Name = fileObj.md5;
+	                            fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                        }
+	                        else {
+	                            fileNativeUrl = sourceUrl;
+	                        }
+	                    }
+	                }
+	                else {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	            }
+	            sourceUrl = fileNativeUrl;
+	            var sound = (new Laya.SoundManager._soundClass());
+	            sound.load(sourceUrl);
+	            thisLoader.onLoaded(sound);
+	        }
+	        else {
+	            thisLoader.event(Laya.Event.ERROR, "Load sound failed");
+	        }
+	    }
+	    static bindToThis(fun, scope) {
+	        var rst = fun;
+	        rst = fun.bind(scope);
+	        return rst;
+	    }
+	    _loadHttpRequestWhat(url, contentType) {
+	        var thisLoader = this;
+	        var encoding = KGMiniAdapter.getUrlEncode(url, contentType);
+	        if (Laya.Loader.preLoadedMap[url])
+	            thisLoader.onLoaded(Laya.Loader.preLoadedMap[url]);
+	        else {
+	            var tempurl = Laya.URL.formatURL(url);
+	            if (!MiniFileMgr.isLocalNativeFile(url) && !MiniFileMgr.getFileInfo(tempurl) && url.indexOf(KGMiniAdapter.window.qg.env.USER_DATA_PATH) == -1 && (tempurl.indexOf("http://") != -1 || tempurl.indexOf("https://") != -1) && !KGMiniAdapter.AutoCacheDownFile) {
+	                thisLoader._loadHttpRequest(tempurl, contentType, thisLoader, thisLoader.onLoaded, thisLoader, thisLoader.onProgress, thisLoader, thisLoader.onError);
+	            }
+	            else {
+	                var fileObj = MiniFileMgr.getFileInfo(Laya.URL.formatURL(url));
+	                if (fileObj) {
+	                    fileObj.encoding = fileObj.encoding == null ? "utf8" : fileObj.encoding;
+	                    MiniFileMgr.readFile(MiniFileMgr.getFileNativePath(fileObj.md5), encoding, new Laya.Handler(MiniLoader, MiniLoader.onReadNativeCallBack, [url, contentType, thisLoader]), url);
+	                }
+	                else if (thisLoader.type == "image" || thisLoader.type == "htmlimage") {
+	                    thisLoader._transformUrl(url, contentType);
+	                }
+	                else {
+	                    if (contentType != Laya.Loader.IMAGE && ((tempurl.indexOf("http://") == -1 && tempurl.indexOf("https://") == -1) || MiniFileMgr.isLocalNativeFile(url))) {
+	                        MiniFileMgr.readFile(url, encoding, new Laya.Handler(MiniLoader, MiniLoader.onReadNativeCallBack, [url, contentType, thisLoader]), url);
+	                    }
+	                    else {
+	                        MiniFileMgr.downFiles(encodeURI(tempurl), encoding, new Laya.Handler(MiniLoader, MiniLoader.onReadNativeCallBack, [url, contentType, thisLoader]), tempurl, true);
+	                    }
+	                }
+	            }
+	        }
+	    }
+	    static onReadNativeCallBack(url, type = null, thisLoader = null, errorCode = 0, data = null) {
+	        if (!errorCode) {
+	            var tempData;
+	            if (type == Laya.Loader.JSON || type == Laya.Loader.ATLAS || type == Laya.Loader.PREFAB || type == Laya.Loader.PLF) {
+	                tempData = KGMiniAdapter.getJson(data.data);
+	            }
+	            else if (type == Laya.Loader.XML) {
+	                tempData = Laya.Utils.parseXMLFromString(data.data);
+	            }
+	            else {
+	                tempData = data.data;
+	            }
+	            if (!KGMiniAdapter.isZiYu && KGMiniAdapter.isPosMsgYu && type != Laya.Loader.BUFFER) {
+	                KGMiniAdapter.window.wx.postMessage({ url: url, data: tempData, isLoad: "filedata" });
+	            }
+	            thisLoader.onLoaded(tempData);
+	        }
+	        else if (errorCode == 1) {
+	            thisLoader._loadHttpRequest(url, type, thisLoader, thisLoader.onLoaded, thisLoader, thisLoader.onProgress, thisLoader, thisLoader.onError);
+	        }
+	    }
+	    static _transformImgUrl(url, type, thisLoader) {
+	        if (KGMiniAdapter.isZiYu) {
+	            thisLoader._loadImage(url, false);
+	            return;
+	        }
+	        if (MiniFileMgr.isLocalNativeFile(url)) {
+	            thisLoader._loadImage(url, false);
+	            return;
+	        }
+	        if (!MiniFileMgr.isLocalNativeFile(url) && !MiniFileMgr.getFileInfo(Laya.URL.formatURL(url))) {
+	            var tempUrl = Laya.URL.formatURL(url);
+	            if (url.indexOf('http://usr/') == -1 && (tempUrl.indexOf("http://") != -1 || tempUrl.indexOf("https://") != -1)) {
+	                if (KGMiniAdapter.isZiYu) {
+	                    thisLoader._loadImage(url, false);
+	                }
+	                else {
+	                    MiniFileMgr.downOtherFiles(tempUrl, new Laya.Handler(MiniLoader, MiniLoader.onDownImgCallBack, [url, thisLoader]), tempUrl);
+	                }
+	            }
+	            else
+	                thisLoader._loadImage(url, false);
+	        }
+	        else {
+	            thisLoader._loadImage(url);
+	        }
+	    }
+	    static onDownImgCallBack(sourceUrl, thisLoader, errorCode, tempFilePath = "") {
+	        if (!errorCode)
+	            MiniLoader.onCreateImage(sourceUrl, thisLoader, false, tempFilePath);
+	        else {
+	            thisLoader.onError(null);
+	        }
+	    }
+	    static onCreateImage(sourceUrl, thisLoader, isLocal = false, tempFilePath = "") {
+	        var fileNativeUrl;
+	        if (KGMiniAdapter.autoCacheFile) {
+	            if (!isLocal) {
+	                if (tempFilePath != "") {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	                else {
+	                    var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                    var fileMd5Name = fileObj.md5;
+	                    fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                }
+	            }
+	            else if (KGMiniAdapter.isZiYu) {
+	                var tempUrl = Laya.URL.formatURL(sourceUrl);
+	                if (MiniFileMgr.ziyuFileTextureData[tempUrl]) {
+	                    fileNativeUrl = MiniFileMgr.ziyuFileTextureData[tempUrl];
+	                }
+	                else
+	                    fileNativeUrl = sourceUrl;
+	            }
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        else {
+	            if (!isLocal)
+	                fileNativeUrl = tempFilePath;
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        thisLoader._loadImage(fileNativeUrl, false);
+	    }
+	}
+
+	class KGMiniAdapter {
+	    static getJson(data) {
+	        return JSON.parse(data);
+	    }
+	    static enable() {
+	        KGMiniAdapter.init(Laya.Laya.isWXPosMsg, Laya.Laya.isWXOpenDataContext);
+	    }
+	    static init(isPosMsg = false, isSon = false) {
+	        if (KGMiniAdapter._inited)
+	            return;
+	        KGMiniAdapter._inited = true;
+	        KGMiniAdapter.window = window;
+	        if (KGMiniAdapter.window.navigator.userAgent.indexOf('QuickGame') < 0)
+	            return;
+	        KGMiniAdapter.isZiYu = isSon;
+	        KGMiniAdapter.isPosMsgYu = isPosMsg;
+	        KGMiniAdapter.EnvConfig = {};
+	        if (!KGMiniAdapter.isZiYu) {
+	            MiniFileMgr.setNativeFileDir("/layaairGame");
+	            MiniFileMgr.existDir(MiniFileMgr.fileNativeDir, Laya.Handler.create(KGMiniAdapter, KGMiniAdapter.onMkdirCallBack));
+	        }
+	        KGMiniAdapter.systemInfo = KGMiniAdapter.window.qg.getSystemInfoSync();
+	        KGMiniAdapter.window.focus = function () {
+	        };
+	        Laya.Laya['_getUrlPath'] = function () {
+	            return "";
+	        };
+	        KGMiniAdapter.window.logtime = function (str) {
+	        };
+	        KGMiniAdapter.window.alertTimeLog = function (str) {
+	        };
+	        KGMiniAdapter.window.resetShareInfo = function () {
+	        };
+	        KGMiniAdapter.EnvConfig.pixelRatioInt = 0;
+	        Laya.Browser["_pixelRatio"] = KGMiniAdapter.pixelRatio();
+	        KGMiniAdapter._preCreateElement = Laya.Browser.createElement;
+	        Laya.Browser["createElement"] = KGMiniAdapter.createElement;
+	        Laya.RunDriver.createShaderCondition = KGMiniAdapter.createShaderCondition;
+	        Laya.Utils['parseXMLFromString'] = KGMiniAdapter.parseXMLFromString;
+	        Laya.Input['_createInputElement'] = MiniInput['_createInputElement'];
+	        Laya.Loader.prototype._loadResourceFilter = MiniLoader.prototype._loadResourceFilter;
+	        Laya.Loader.prototype._loadSound = MiniLoader.prototype._loadSound;
+	        Laya.Loader.prototype._loadHttpRequestWhat = MiniLoader.prototype._loadHttpRequestWhat;
+	        KGMiniAdapter.window.qg.onMessage && KGMiniAdapter.window.qg.onMessage(KGMiniAdapter._onMessage);
+	    }
+	    static _onMessage(data) {
+	        switch (data.type) {
+	            case "changeMatrix":
+	                Laya.Laya.stage.transform.identity();
+	                Laya.Laya.stage._width = data.w;
+	                Laya.Laya.stage._height = data.h;
+	                Laya.Laya.stage._canvasTransform = new Laya.Matrix(data.a, data.b, data.c, data.d, data.tx, data.ty);
+	                break;
+	            case "display":
+	                Laya.Laya.stage.frameRate = data.rate || Laya.Stage.FRAME_FAST;
+	                break;
+	            case "undisplay":
+	                Laya.Laya.stage.frameRate = Laya.Stage.FRAME_SLEEP;
+	                break;
+	        }
+	        if (data['isLoad'] == "opendatacontext") {
+	            if (data.url) {
+	                MiniFileMgr.ziyuFileData[data.url] = data.atlasdata;
+	                MiniFileMgr.ziyuFileTextureData[data.imgReadyUrl] = data.imgNativeUrl;
+	            }
+	        }
+	        else if (data['isLoad'] == "openJsondatacontext") {
+	            if (data.url) {
+	                MiniFileMgr.ziyuFileData[data.url] = data.atlasdata;
+	            }
+	        }
+	        else if (data['isLoad'] == "openJsondatacontextPic") {
+	            MiniFileMgr.ziyuFileTextureData[data.imgReadyUrl] = data.imgNativeUrl;
+	        }
+	    }
+	    static getUrlEncode(url, type) {
+	        if (type == "arraybuffer")
+	            return "";
+	        return "utf8";
+	    }
+	    static downLoadFile(fileUrl, fileType = "", callBack = null, encoding = "utf8") {
+	        var fileObj = MiniFileMgr.getFileInfo(fileUrl);
+	        if (!fileObj)
+	            MiniFileMgr.downLoadFile(fileUrl, fileType, callBack, encoding);
+	        else {
+	            callBack != null && callBack.runWith([0]);
+	        }
+	    }
+	    static remove(fileUrl, callBack = null) {
+	        MiniFileMgr.deleteFile("", fileUrl, callBack, "", 0);
+	    }
+	    static removeAll() {
+	        MiniFileMgr.deleteAll();
+	    }
+	    static hasNativeFile(fileUrl) {
+	        return MiniFileMgr.isLocalNativeFile(fileUrl);
+	    }
+	    static getFileInfo(fileUrl) {
+	        return MiniFileMgr.getFileInfo(fileUrl);
+	    }
+	    static getFileList() {
+	        return MiniFileMgr.filesListObj;
+	    }
+	    static exitMiniProgram() {
+	        KGMiniAdapter.window["wx"].exitMiniProgram();
+	    }
+	    static onMkdirCallBack(errorCode, data) {
+	        if (!errorCode)
+	            MiniFileMgr.filesListObj = JSON.parse(data.data);
+	        MiniFileMgr.fakeObj = MiniFileMgr.filesListObj;
+	    }
+	    static pixelRatio() {
+	        if (!KGMiniAdapter.EnvConfig.pixelRatioInt) {
+	            try {
+	                KGMiniAdapter.EnvConfig.pixelRatioInt = KGMiniAdapter.systemInfo.pixelRatio;
+	                return KGMiniAdapter.systemInfo.pixelRatio;
+	            }
+	            catch (error) {
+	            }
+	        }
+	        return KGMiniAdapter.EnvConfig.pixelRatioInt;
+	    }
+	    static createElement(type) {
+	        if (type == "canvas") {
+	            var _source;
+	            if (KGMiniAdapter.idx == 1) {
+	                if (KGMiniAdapter.isZiYu) ;
+	                else {
+	                    _source = KGMiniAdapter.window.canvas;
+	                    _source.style = {
+	                        width: _source.width + "px",
+	                        height: _source.height + "px"
+	                    };
+	                }
+	            }
+	            else {
+	                var tempCanvas = window.document.createElement('canvas');
+	                _source = tempCanvas;
+	            }
+	            KGMiniAdapter.idx++;
+	            return _source;
+	        }
+	        else if (type == "textarea" || type == "input") {
+	            return KGMiniAdapter.onCreateInput(type);
+	        }
+	        else if (type == "div") {
+	            var node = KGMiniAdapter._preCreateElement(type);
+	            node.contains = function (value) {
+	                return null;
+	            };
+	            node.removeChild = function (value) {
+	            };
+	            return node;
+	        }
+	        else {
+	            return KGMiniAdapter._preCreateElement(type);
+	        }
+	    }
+	    static onCreateInput(type) {
+	        var node = KGMiniAdapter._preCreateElement(type);
+	        node.focus = MiniInput.wxinputFocus;
+	        node.blur = MiniInput.wxinputblur;
+	        node.style = {};
+	        node.value = 0;
+	        node.placeholder = {};
+	        node.setColor = function (value) {
+	        };
+	        node.setType = function (value) {
+	        };
+	        node.setFontFace = function (value) {
+	        };
+	        node.addEventListener = function (value) {
+	        };
+	        node.contains = function (value) {
+	            return null;
+	        };
+	        node.removeChild = function (value) {
+	        };
+	        return node;
+	    }
+	    static createShaderCondition(conditionScript) {
+	        var func = function () {
+	            return this[conditionScript.replace("this.", "")];
+	        };
+	        return func;
+	    }
+	    static sendAtlasToOpenDataContext(url) {
+	        if (!KGMiniAdapter.isZiYu) {
+	            var atlasJson = Laya.Loader.getRes(Laya.URL.formatURL(url));
+	            if (atlasJson) {
+	                var textureArr = atlasJson.meta.image.split(",");
+	                if (atlasJson.meta && atlasJson.meta.image) {
+	                    var toloadPics = atlasJson.meta.image.split(",");
+	                    var split = url.indexOf("/") >= 0 ? "/" : "\\";
+	                    var idx = url.lastIndexOf(split);
+	                    var folderPath = idx >= 0 ? url.substr(0, idx + 1) : "";
+	                    for (var i = 0, len = toloadPics.length; i < len; i++) {
+	                        toloadPics[i] = folderPath + toloadPics[i];
+	                    }
+	                }
+	                else {
+	                    toloadPics = [url.replace(".json", ".png")];
+	                }
+	                for (i = 0; i < toloadPics.length; i++) {
+	                    var tempAtlasPngUrl = toloadPics[i];
+	                    KGMiniAdapter.postInfoToContext(url, tempAtlasPngUrl, atlasJson);
+	                }
+	            }
+	            else {
+	                throw "传递的url没有获取到对应的图集数据信息,请确保图集已经过!";
+	            }
+	        }
+	    }
+	    static postInfoToContext(url, atlaspngUrl, atlasJson) {
+	        var postData = { "frames": atlasJson.frames, "meta": atlasJson.meta };
+	        var textureUrl = atlaspngUrl;
+	        var fileObj = MiniFileMgr.getFileInfo(Laya.URL.formatURL(atlaspngUrl));
+	        if (fileObj) {
+	            var fileMd5Name = fileObj.md5;
+	            var fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	        }
+	        else {
+	            fileNativeUrl = textureUrl;
+	        }
+	        if (fileNativeUrl) {
+	            KGMiniAdapter.window.qg.postMessage({ url: url, atlasdata: postData, imgNativeUrl: fileNativeUrl, imgReadyUrl: textureUrl, isLoad: "opendatacontext" });
+	        }
+	        else {
+	            throw "获取图集的磁盘url路径不存在!";
+	        }
+	    }
+	    static sendSinglePicToOpenDataContext(url) {
+	        var tempTextureUrl = Laya.URL.formatURL(url);
+	        var fileObj = MiniFileMgr.getFileInfo(tempTextureUrl);
+	        if (fileObj) {
+	            var fileMd5Name = fileObj.md5;
+	            var fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	            url = tempTextureUrl;
+	        }
+	        else {
+	            fileNativeUrl = url;
+	        }
+	        if (fileNativeUrl) {
+	            KGMiniAdapter.window.qg.postMessage({ url: url, imgNativeUrl: fileNativeUrl, imgReadyUrl: url, isLoad: "openJsondatacontextPic" });
+	        }
+	        else {
+	            throw "获取图集的磁盘url路径不存在!";
+	        }
+	    }
+	    static sendJsonDataToDataContext(url) {
+	        if (!KGMiniAdapter.isZiYu) {
+	            var atlasJson = Laya.Loader.getRes(url);
+	            if (atlasJson) {
+	                KGMiniAdapter.window.qg.postMessage({ url: url, atlasdata: atlasJson, isLoad: "openJsondatacontext" });
+	            }
+	            else {
+	                throw "传递的url没有获取到对应的图集数据信息,请确保图集已经过!";
+	            }
+	        }
+	    }
+	}
+	KGMiniAdapter._inited = false;
+	KGMiniAdapter.autoCacheFile = true;
+	KGMiniAdapter.minClearSize = (5 * 1024 * 1024);
+	KGMiniAdapter.nativefiles = ["layaNativeDir", "wxlocal"];
+	KGMiniAdapter.subNativeFiles = [];
+	KGMiniAdapter.subNativeheads = [];
+	KGMiniAdapter.subMaps = [];
+	KGMiniAdapter.AutoCacheDownFile = false;
+	KGMiniAdapter.parseXMLFromString = function (value) {
+	    var rst;
+	    value = value.replace(/>\s+</g, '><');
+	    try {
+	        rst = (new KGMiniAdapter.window.Parser.DOMParser()).parseFromString(value, 'text/xml');
+	    }
+	    catch (error) {
+	        throw "需要引入xml解析库文件";
+	    }
+	    return rst;
+	};
+	KGMiniAdapter.idx = 1;
+
+	class MiniAccelerator extends Laya.EventDispatcher {
+	    constructor() {
+	        super();
+	    }
+	    static __init__() {
+	        try {
+	            var Acc;
+	            Acc = Laya.Accelerator;
+	            if (!Acc)
+	                return;
+	            Acc["prototype"]["on"] = MiniAccelerator["prototype"]["on"];
+	            Acc["prototype"]["off"] = MiniAccelerator["prototype"]["off"];
+	        }
+	        catch (e) {
+	        }
+	    }
+	    static startListen(callBack) {
+	        MiniAccelerator._callBack = callBack;
+	        if (MiniAccelerator._isListening)
+	            return;
+	        MiniAccelerator._isListening = true;
+	        try {
+	            KGMiniAdapter.window.swan.onAccelerometerChange(MiniAccelerator.onAccelerometerChange);
+	        }
+	        catch (e) { }
+	    }
+	    static stopListen() {
+	        MiniAccelerator._isListening = false;
+	        try {
+	            KGMiniAdapter.window.swan.stopAccelerometer({});
+	        }
+	        catch (e) { }
+	    }
+	    static onAccelerometerChange(res) {
+	        var e;
+	        e = {};
+	        e.acceleration = res;
+	        e.accelerationIncludingGravity = res;
+	        e.rotationRate = {};
+	        if (MiniAccelerator._callBack != null) {
+	            MiniAccelerator._callBack(e);
+	        }
+	    }
+	    on(type, caller, listener, args = null) {
+	        super.on(type, caller, listener, args);
+	        MiniAccelerator.startListen(this["onDeviceOrientationChange"]);
+	        return this;
+	    }
+	    off(type, caller, listener, onceOnly = false) {
+	        if (!this.hasListener(type))
+	            MiniAccelerator.stopListen();
+	        return super.off(type, caller, listener, onceOnly);
+	    }
+	}
+	MiniAccelerator._isListening = false;
+
+	class MiniImage {
+	    _loadImage(url) {
+	        var thisLoader = this;
+	        if (KGMiniAdapter.isZiYu) {
+	            MiniImage.onCreateImage(url, thisLoader, true);
+	            return;
+	        }
+	        var isTransformUrl;
+	        if (!MiniFileMgr.isLocalNativeFile(url)) {
+	            isTransformUrl = true;
+	            url = Laya.URL.formatURL(url);
+	        }
+	        else {
+	            if (url.indexOf("http://usr/") == -1 && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1)) {
+	                if (MiniFileMgr.loadPath != "") {
+	                    url = url.split(MiniFileMgr.loadPath)[1];
+	                }
+	                else {
+	                    var tempStr = Laya.URL.rootPath != "" ? Laya.URL.rootPath : Laya.URL._basePath;
+	                    var tempUrl = url;
+	                    if (tempStr != "")
+	                        url = url.split(tempStr)[1];
+	                    if (!url) {
+	                        url = tempUrl;
+	                    }
+	                }
+	            }
+	            if (KGMiniAdapter.subNativeFiles && KGMiniAdapter.subNativeheads.length == 0) {
+	                for (var key in KGMiniAdapter.subNativeFiles) {
+	                    var tempArr = KGMiniAdapter.subNativeFiles[key];
+	                    KGMiniAdapter.subNativeheads = KGMiniAdapter.subNativeheads.concat(tempArr);
+	                    for (var aa = 0; aa < tempArr.length; aa++) {
+	                        KGMiniAdapter.subMaps[tempArr[aa]] = key + "/" + tempArr[aa];
+	                    }
+	                }
+	            }
+	            if (KGMiniAdapter.subNativeFiles && url.indexOf("/") != -1) {
+	                var curfileHead = url.split("/")[0] + "/";
+	                if (curfileHead && KGMiniAdapter.subNativeheads.indexOf(curfileHead) != -1) {
+	                    var newfileHead = KGMiniAdapter.subMaps[curfileHead];
+	                    url = url.replace(curfileHead, newfileHead);
+	                }
+	            }
+	        }
+	        if (!MiniFileMgr.getFileInfo(url)) {
+	            if (url.indexOf('http://usr/') == -1 && (url.indexOf("http://") != -1 || url.indexOf("https://") != -1)) {
+	                if (KGMiniAdapter.isZiYu) {
+	                    MiniImage.onCreateImage(url, thisLoader, true);
+	                }
+	                else {
+	                    MiniFileMgr.downOtherFiles(url, new Laya.Handler(MiniImage, MiniImage.onDownImgCallBack, [url, thisLoader]), url);
+	                }
+	            }
+	            else
+	                MiniImage.onCreateImage(url, thisLoader, true);
+	        }
+	        else {
+	            MiniImage.onCreateImage(url, thisLoader, !isTransformUrl);
+	        }
+	    }
+	    static onDownImgCallBack(sourceUrl, thisLoader, errorCode, tempFilePath = "") {
+	        if (!errorCode)
+	            MiniImage.onCreateImage(sourceUrl, thisLoader, false, tempFilePath);
+	        else {
+	            thisLoader.onError(null);
+	        }
+	    }
+	    static onCreateImage(sourceUrl, thisLoader, isLocal = false, tempFilePath = "") {
+	        var fileNativeUrl;
+	        if (KGMiniAdapter.autoCacheFile) {
+	            if (!isLocal) {
+	                if (tempFilePath != "") {
+	                    fileNativeUrl = tempFilePath;
+	                }
+	                else {
+	                    var fileObj = MiniFileMgr.getFileInfo(sourceUrl);
+	                    var fileMd5Name = fileObj.md5;
+	                    fileNativeUrl = MiniFileMgr.getFileNativePath(fileMd5Name);
+	                }
+	            }
+	            else if (KGMiniAdapter.isZiYu) {
+	                var tempUrl = Laya.URL.formatURL(sourceUrl);
+	                if (MiniFileMgr.ziyuFileTextureData[tempUrl]) {
+	                    fileNativeUrl = MiniFileMgr.ziyuFileTextureData[tempUrl];
+	                }
+	                else
+	                    fileNativeUrl = sourceUrl;
+	            }
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        else {
+	            if (!isLocal)
+	                fileNativeUrl = tempFilePath;
+	            else
+	                fileNativeUrl = sourceUrl;
+	        }
+	        if (thisLoader._imgCache == null)
+	            thisLoader._imgCache = {};
+	        var image;
+	        function clear() {
+	            var img = thisLoader._imgCache[fileNativeUrl];
+	            if (img) {
+	                img.onload = null;
+	                img.onerror = null;
+	                delete thisLoader._imgCache[fileNativeUrl];
+	            }
+	        }
+	        var onerror = function () {
+	            clear();
+	            delete MiniFileMgr.fakeObj[sourceUrl];
+	            delete MiniFileMgr.filesListObj[sourceUrl];
+	            thisLoader.event(Laya.Event.ERROR, "Load image failed");
+	        };
+	        if (thisLoader._type == "nativeimage") {
+	            var onload = function () {
+	                clear();
+	                thisLoader.onLoaded(image);
+	            };
+	            image = new Laya.Browser.window.Image();
+	            image.crossOrigin = "";
+	            image.onload = onload;
+	            image.onerror = onerror;
+	            image.src = fileNativeUrl;
+	            thisLoader._imgCache[fileNativeUrl] = image;
+	        }
+	        else {
+	            var imageSource = new Laya.Browser.window.Image();
+	            onload = function () {
+	                image = Laya.HTMLImage.create(imageSource.width, imageSource.height);
+	                image.loadImageSource(imageSource, true);
+	                image._setCreateURL(fileNativeUrl);
+	                clear();
+	                thisLoader.onLoaded(image);
+	            };
+	            imageSource.crossOrigin = "";
+	            imageSource.onload = onload;
+	            imageSource.onerror = onerror;
+	            imageSource.src = fileNativeUrl;
+	            thisLoader._imgCache[fileNativeUrl] = imageSource;
+	        }
+	    }
+	}
+
+	class MiniLocalStorage {
+	    constructor() {
+	    }
+	    static __init__() {
+	        MiniLocalStorage.items = MiniLocalStorage;
+	    }
+	    static setItem(key, value) {
+	        try {
+	            KGMiniAdapter.window.qg.setStorageSync(key, value);
+	        }
+	        catch (error) {
+	            KGMiniAdapter.window.qg.setStorage({
+	                key: key,
+	                data: value
+	            });
+	        }
+	    }
+	    static getItem(key) {
+	        return KGMiniAdapter.window.qg.getStorageSync(key);
+	    }
+	    static setJSON(key, value) {
+	        MiniLocalStorage.setItem(key, value);
+	    }
+	    static getJSON(key) {
+	        return MiniLocalStorage.getItem(key);
+	    }
+	    static removeItem(key) {
+	        KGMiniAdapter.window.qg.removeStorageSync(key);
+	    }
+	    static clear() {
+	        KGMiniAdapter.window.qg.clearStorageSync();
+	    }
+	    static getStorageInfoSync() {
+	        try {
+	            var res = KGMiniAdapter.window.qg.getStorageInfoSync();
+	            console.log(res.keys);
+	            console.log(res.currentSize);
+	            console.log(res.limitSize);
+	            return res;
+	        }
+	        catch (e) {
+	        }
+	        return null;
+	    }
+	}
+	MiniLocalStorage.support = true;
+
+	class MiniLocation {
+	    constructor() {
+	    }
+	    static __init__() {
+	        KGMiniAdapter.window.navigator.geolocation.getCurrentPosition = MiniLocation.getCurrentPosition;
+	        KGMiniAdapter.window.navigator.geolocation.watchPosition = MiniLocation.watchPosition;
+	        KGMiniAdapter.window.navigator.geolocation.clearWatch = MiniLocation.clearWatch;
+	    }
+	    static getCurrentPosition(success = null, error = null, options = null) {
+	        var paramO;
+	        paramO = {};
+	        paramO.success = getSuccess;
+	        paramO.fail = error;
+	        KGMiniAdapter.window.qg.getLocation(paramO);
+	        function getSuccess(res) {
+	            if (success != null) {
+	                success(res);
+	            }
+	        }
+	    }
+	    static watchPosition(success = null, error = null, options = null) {
+	        MiniLocation._curID++;
+	        var curWatchO;
+	        curWatchO = {};
+	        curWatchO.success = success;
+	        curWatchO.error = error;
+	        MiniLocation._watchDic[MiniLocation._curID] = curWatchO;
+	        Laya.Laya.systemTimer.loop(1000, null, MiniLocation._myLoop);
+	        return MiniLocation._curID;
+	    }
+	    static clearWatch(id) {
+	        delete MiniLocation._watchDic[id];
+	        if (!MiniLocation._hasWatch()) {
+	            Laya.Laya.systemTimer.clear(null, MiniLocation._myLoop);
+	        }
+	    }
+	    static _hasWatch() {
+	        var key;
+	        for (key in MiniLocation._watchDic) {
+	            if (MiniLocation._watchDic[key])
+	                return true;
+	        }
+	        return false;
+	    }
+	    static _myLoop() {
+	        MiniLocation.getCurrentPosition(MiniLocation._mySuccess, MiniLocation._myError);
+	    }
+	    static _mySuccess(res) {
+	        var rst = {};
+	        rst.coords = res;
+	        rst.timestamp = Laya.Browser.now();
+	        var key;
+	        for (key in MiniLocation._watchDic) {
+	            if (MiniLocation._watchDic[key].success) {
+	                MiniLocation._watchDic[key].success(rst);
+	            }
+	        }
+	    }
+	    static _myError(res) {
+	        var key;
+	        for (key in MiniLocation._watchDic) {
+	            if (MiniLocation._watchDic[key].error) {
+	                MiniLocation._watchDic[key].error(res);
+	            }
+	        }
+	    }
+	}
+	MiniLocation._watchDic = {};
+	MiniLocation._curID = 0;
+
+	class MiniVideo {
+	    constructor(width = 320, height = 240) {
+	        this.videoend = false;
+	        this.videourl = "";
+	        this.videoElement = KGMiniAdapter.window.qg.createVideo({ width: width, height: height, autoplay: true });
+	    }
+	    static __init__() {
+	    }
+	    on(eventType, ths, callBack) {
+	        if (eventType == "loadedmetadata") {
+	            this.onPlayFunc = callBack.bind(ths);
+	            this.videoElement.onPlay = this.onPlayFunction.bind(this);
+	        }
+	        else if (eventType == "ended") {
+	            this.onEndedFunC = callBack.bind(ths);
+	            this.videoElement.onEnded = this.onEndedFunction.bind(this);
+	        }
+	        this.videoElement.onTimeUpdate = this.onTimeUpdateFunc.bind(this);
+	    }
+	    onTimeUpdateFunc(data) {
+	        this.position = data.position;
+	        this._duration = data.duration;
+	    }
+	    get duration() {
+	        return this._duration;
+	    }
+	    onPlayFunction() {
+	        if (this.videoElement)
+	            this.videoElement.readyState = 200;
+	        console.log("=====视频加载完成========");
+	        this.onPlayFunc != null && this.onPlayFunc();
+	    }
+	    onEndedFunction() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoend = true;
+	        console.log("=====视频播放完毕========");
+	        this.onEndedFunC != null && this.onEndedFunC();
+	    }
+	    off(eventType, ths, callBack) {
+	        if (eventType == "loadedmetadata") {
+	            this.onPlayFunc = callBack.bind(ths);
+	            this.videoElement.offPlay = this.onPlayFunction.bind(this);
+	        }
+	        else if (eventType == "ended") {
+	            this.onEndedFunC = callBack.bind(ths);
+	            this.videoElement.offEnded = this.onEndedFunction.bind(this);
+	        }
+	    }
+	    load(url) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.src = url;
+	    }
+	    play() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoend = false;
+	        this.videoElement.play();
+	    }
+	    pause() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoend = true;
+	        this.videoElement.pause();
+	    }
+	    get currentTime() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.initialTime;
+	    }
+	    set currentTime(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.initialTime = value;
+	    }
+	    get videoWidth() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.width;
+	    }
+	    get videoHeight() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.height;
+	    }
+	    get ended() {
+	        return this.videoend;
+	    }
+	    get loop() {
+	        if (!this.videoElement)
+	            return false;
+	        return this.videoElement.loop;
+	    }
+	    set loop(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.loop = value;
+	    }
+	    get playbackRate() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.playbackRate;
+	    }
+	    set playbackRate(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.playbackRate = value;
+	    }
+	    get muted() {
+	        if (!this.videoElement)
+	            return false;
+	        return this.videoElement.muted;
+	    }
+	    set muted(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.muted = value;
+	    }
+	    get paused() {
+	        if (!this.videoElement)
+	            return false;
+	        return this.videoElement.paused;
+	    }
+	    size(width, height) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.width = width;
+	        this.videoElement.height = height;
+	    }
+	    get x() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.x;
+	    }
+	    set x(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.x = value;
+	    }
+	    get y() {
+	        if (!this.videoElement)
+	            return 0;
+	        return this.videoElement.y;
+	    }
+	    set y(value) {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.y = value;
+	    }
+	    get currentSrc() {
+	        return this.videoElement.src;
+	    }
+	    destroy() {
+	        if (this.videoElement)
+	            this.videoElement.destroy();
+	        this.videoElement = null;
+	        this.onEndedFunC = null;
+	        this.onPlayFunc = null;
+	        this.videoend = false;
+	        this.videourl = null;
+	    }
+	    reload() {
+	        if (!this.videoElement)
+	            return;
+	        this.videoElement.src = this.videourl;
+	    }
+	}
+
+	exports.KGMiniAdapter = KGMiniAdapter;
+	exports.MiniAccelerator = MiniAccelerator;
+	exports.MiniFileMgr = MiniFileMgr;
+	exports.MiniImage = MiniImage;
+	exports.MiniInput = MiniInput;
+	exports.MiniLoader = MiniLoader;
+	exports.MiniLocalStorage = MiniLocalStorage;
+	exports.MiniLocation = MiniLocation;
+	exports.MiniSound = MiniSound;
+	exports.MiniSoundChannel = MiniSoundChannel;
+	exports.MiniVideo = MiniVideo;
+
+} 

文件差異過大導致無法顯示
+ 0 - 0
ShootingSun/bin/libs/worker.js


+ 132 - 0
ShootingSun/bin/libs/workerloader.js

@@ -0,0 +1,132 @@
+var createImageBitmapOK=self.createImageBitmap?true:false;
+onmessage =function (evt){
+  
+  var data = evt.data;//通过evt.data获得发送来的数据
+  loadImage2(data);
+  if(!isSet)
+  {
+	  isSet=true;
+	  setInterval(workerloop,1000);
+   }
+}
+var isSet=true;
+function workerloop()
+{
+	myTrace("png:workerloop");
+}
+
+
+var enableTrace=false;
+var ifShowTraceToMain=false;
+function myTrace(msg)
+{
+	if(!enableTrace) return;
+	console.log("png:"+msg)
+	if(ifShowTraceToMain)
+	{
+		showMsgToMain(msg);
+	}
+}
+function loadImage2(url)
+{
+	var xhr,
+    _this = this;
+	var failed=false;
+      xhr = new XMLHttpRequest;
+      xhr.open("GET", url, true);
+	  //showMsgToMain("loadImage2");
+	  xhr.responseType = "arraybuffer";
+      myTrace("load:"+url);
+      xhr.onload = function() {
+		var response=xhr.response || xhr.mozResponseArrayBuffer;
+		//showMsgToMain("onload:");
+		myTrace("onload:"+url);
+		if((xhr.status != 200&&xhr.status!=0)||response.byteLength<10)
+		{
+			if(!failed)
+			{
+				failed=true;
+				pngFail(url,"loadFail from onload"+xhr.status);
+			}
+			
+			return;
+		}
+        var data, png;
+        data = new Uint8Array(response);
+		doCreateImageBitmap(data,url);
+        
+      };
+	  xhr.onerror = function(e){
+		pngFail(url,"loadFail");
+	}
+
+      xhr.send(null);
+}
+function doCreateImageBitmap(response,url)
+{
+	try
+	{
+		//showMsgToMain("hihidoCreateImageBitmap");
+		//showMsgToMain("doCreateImageBitmap:"+response);
+		//var startTime=getTimeNow();
+		//showMsgToMain("new self.Blob");
+		var startTime=getTimeNow();
+		
+		response = new self.Blob([response],{type:"image/png"});
+		self.createImageBitmap(response).then(function(imageBitmap) {
+			//showMsgToMain("imageBitmapCreated:");
+			var data={};
+	        data.url=url;
+			data.imageBitmap=imageBitmap;
+			data.dataType="imageBitmap";
+			
+			data.startTime=startTime;
+	        data.decodeTime=getTimeNow()-startTime;
+			data.sendTime=getTimeNow();
+			
+			myTrace("png:Decode By createImageBitmap,"+data.decodeTime,url);
+			
+			data.type="Image";
+			postMessage(data,[data.imageBitmap]);
+        }).catch(
+		function(e)
+		{
+			showMsgToMain("catch e:"+e);
+			pngFail(url,"parse fail"+e+":ya");
+		}
+		)
+	}catch(e)
+	{
+		pngFail(url,"parse fail"+e.toString()+":ya");
+	}
+}
+function getTimeNow()
+{
+	return new Date().getTime();
+}
+function disableWorker(msg)
+{
+	var data={};
+	data.url=url;
+	data.imagedata=null;
+	data.type="Disable";
+	data.msg=msg;
+	postMessage(data);
+}
+function pngFail(url,msg)
+{
+	var data={};
+	data.url=url;
+	data.imagedata=null;
+	data.type="Image";
+	data.msg=msg;
+	console.log("png:"+msg+" "+url);
+	postMessage(data);
+}
+function showMsgToMain(msg)
+{
+	var data={};
+	data.type="Msg";
+	data.msg=msg;
+	postMessage(data);
+}

二進制
ShootingSun/bin/music/bgMusic.mp3


二進制
ShootingSun/bin/music/btnClick.mp3


二進制
ShootingSun/bin/music/gameFailed.mp3


二進制
ShootingSun/bin/music/gameSuccess.mp3


二進制
ShootingSun/bin/music/getCoins.mp3


二進制
ShootingSun/bin/music/hitObstacle.wav


二進制
ShootingSun/bin/music/knifeAttackSun.mp3


二進制
ShootingSun/bin/music/planetDie.mp3


二進制
ShootingSun/bin/music/useProp.wav


+ 15 - 0
ShootingSun/bin/openData/index.js

@@ -0,0 +1,15 @@
+require("weapp-adapter.js");
+window.loadLib = require;
+/**
+ * 设置LayaNative屏幕方向,可设置以下值
+ * landscape           横屏
+ * portrait            竖屏
+ * sensor_landscape    横屏(双方向)
+ * sensor_portrait     竖屏(双方向)
+ */
+window.screenOrientation = "sensor_landscape";
+
+//-----libs-begin-----
+loadLib("libs/laya.opendata.min.js")
+//-----libs-end-------
+loadLib("js/bundle.js");

文件差異過大導致無法顯示
+ 151 - 0
ShootingSun/bin/openData/js/bundle.js


文件差異過大導致無法顯示
+ 0 - 0
ShootingSun/bin/openData/libs/laya.opendata.min.js


+ 1662 - 0
ShootingSun/bin/openData/weapp-adapter.js

@@ -0,0 +1,1662 @@
+/******/ (function(modules) { // webpackBootstrap
+/******/ 	// The module cache
+/******/ 	var installedModules = {};
+
+/******/ 	// The require function
+/******/ 	function __webpack_require__(moduleId) {
+
+/******/ 		// Check if module is in cache
+/******/ 		if(installedModules[moduleId])
+/******/ 			return installedModules[moduleId].exports;
+
+/******/ 		// Create a new module (and put it into the cache)
+/******/ 		var module = installedModules[moduleId] = {
+/******/ 			exports: {},
+/******/ 			id: moduleId,
+/******/ 			loaded: false
+/******/ 		};
+
+/******/ 		// Execute the module function
+/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+
+/******/ 		// Flag the module as loaded
+/******/ 		module.loaded = true;
+
+/******/ 		// Return the exports of the module
+/******/ 		return module.exports;
+/******/ 	}
+
+
+/******/ 	// expose the modules object (__webpack_modules__)
+/******/ 	__webpack_require__.m = modules;
+
+/******/ 	// expose the module cache
+/******/ 	__webpack_require__.c = installedModules;
+
+/******/ 	// __webpack_public_path__
+/******/ 	__webpack_require__.p = "";
+
+/******/ 	// Load entry module and return exports
+/******/ 	return __webpack_require__(0);
+/******/ })
+/************************************************************************/
+/******/ ([
+/* 0 */
+/***/ (function(module, exports, __webpack_require__) {
+
+	'use strict';
+
+	var _window2 = __webpack_require__(1);
+
+	var _window = _interopRequireWildcard(_window2);
+
+	var _HTMLElement = __webpack_require__(4);
+
+	var _HTMLElement2 = _interopRequireDefault(_HTMLElement);
+
+	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+	function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
+
+	var global = GameGlobal;
+
+	function inject() {
+	  _window.addEventListener = function (type, listener) {
+	    _window.document.addEventListener(type, listener);
+	  };
+	  _window.removeEventListener = function (type, listener) {
+	    _window.document.removeEventListener(type, listener);
+	  };
+
+	  if (_window.canvas) {
+	    _window.canvas.addEventListener = _window.addEventListener;
+	    _window.canvas.removeEventListener = _window.removeEventListener;
+	  }
+
+	  if (global.sharedCanvas) {
+	    // eslint-disable-next-line no-undef
+	    sharedCanvas.__proto__.__proto__ = new _HTMLElement2.default('canvas');
+	    // eslint-disable-next-line no-undef
+	    sharedCanvas.addEventListener = _window.addEventListener;
+	    // eslint-disable-next-line no-undef
+	    sharedCanvas.removeEventListener = _window.removeEventListener;
+	  }
+
+	  var _wx$getSystemInfoSync = wx.getSystemInfoSync(),
+	      platform = _wx$getSystemInfoSync.platform;
+
+	  // 开发者工具无法重定义 window
+
+
+	  if (typeof __devtoolssubcontext === 'undefined' && platform === 'devtools') {
+	    for (var key in _window) {
+	      var descriptor = Object.getOwnPropertyDescriptor(global, key);
+
+	      if (!descriptor || descriptor.configurable === true) {
+	        Object.defineProperty(window, key, {
+	          value: _window[key]
+	        });
+	      }
+	    }
+
+	    for (var _key in _window.document) {
+	      var _descriptor = Object.getOwnPropertyDescriptor(global.document, _key);
+
+	      if (!_descriptor || _descriptor.configurable === true) {
+	        Object.defineProperty(global.document, _key, {
+	          value: _window.document[_key]
+	        });
+	      }
+	    }
+	    window.parent = window;
+	  } else {
+	    for (var _key2 in _window) {
+	      global[_key2] = _window[_key2];
+	    }
+	    global.window = _window;
+	    window = global;
+	    window.top = window.parent = window;
+	  }
+	}
+
+	if (!GameGlobal.__isAdapterInjected) {
+	  GameGlobal.__isAdapterInjected = true;
+	  inject();
+	}
+
+/***/ }),
+/* 1 */
+/***/ (function(module, exports, __webpack_require__) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+	exports.cancelAnimationFrame = exports.requestAnimationFrame = exports.clearInterval = exports.clearTimeout = exports.setInterval = exports.setTimeout = exports.canvas = exports.location = exports.localStorage = exports.HTMLElement = exports.FileReader = exports.Audio = exports.Image = exports.WebSocket = exports.XMLHttpRequest = exports.navigator = exports.document = undefined;
+
+	var _WindowProperties = __webpack_require__(2);
+
+	Object.keys(_WindowProperties).forEach(function (key) {
+	  if (key === "default" || key === "__esModule") return;
+	  Object.defineProperty(exports, key, {
+	    enumerable: true,
+	    get: function get() {
+	      return _WindowProperties[key];
+	    }
+	  });
+	});
+
+	var _constructor = __webpack_require__(3);
+
+	Object.keys(_constructor).forEach(function (key) {
+	  if (key === "default" || key === "__esModule") return;
+	  Object.defineProperty(exports, key, {
+	    enumerable: true,
+	    get: function get() {
+	      return _constructor[key];
+	    }
+	  });
+	});
+
+	var _Canvas = __webpack_require__(9);
+
+	var _Canvas2 = _interopRequireDefault(_Canvas);
+
+	var _Util = __webpack_require__(17);
+
+	var _document2 = __webpack_require__(10);
+
+	var _document3 = _interopRequireDefault(_document2);
+
+	var _navigator2 = __webpack_require__(18);
+
+	var _navigator3 = _interopRequireDefault(_navigator2);
+
+	var _XMLHttpRequest2 = __webpack_require__(19);
+
+	var _XMLHttpRequest3 = _interopRequireDefault(_XMLHttpRequest2);
+
+	var _WebSocket2 = __webpack_require__(20);
+
+	var _WebSocket3 = _interopRequireDefault(_WebSocket2);
+
+	var _Image2 = __webpack_require__(11);
+
+	var _Image3 = _interopRequireDefault(_Image2);
+
+	var _Audio2 = __webpack_require__(12);
+
+	var _Audio3 = _interopRequireDefault(_Audio2);
+
+	var _FileReader2 = __webpack_require__(21);
+
+	var _FileReader3 = _interopRequireDefault(_FileReader2);
+
+	var _HTMLElement2 = __webpack_require__(4);
+
+	var _HTMLElement3 = _interopRequireDefault(_HTMLElement2);
+
+	var _localStorage2 = __webpack_require__(22);
+
+	var _localStorage3 = _interopRequireDefault(_localStorage2);
+
+	var _location2 = __webpack_require__(23);
+
+	var _location3 = _interopRequireDefault(_location2);
+
+	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+	exports.document = _document3.default;
+	exports.navigator = _navigator3.default;
+	exports.XMLHttpRequest = _XMLHttpRequest3.default;
+	exports.WebSocket = _WebSocket3.default;
+	exports.Image = _Image3.default;
+	exports.Audio = _Audio3.default;
+	exports.FileReader = _FileReader3.default;
+	exports.HTMLElement = _HTMLElement3.default;
+	exports.localStorage = _localStorage3.default;
+	exports.location = _location3.default;
+
+
+	// 暴露全局的 canvas
+	var canvas = (0, _Util.isSubContext)() ? undefined : new _Canvas2.default();
+
+	exports.canvas = canvas;
+	exports.setTimeout = setTimeout;
+	exports.setInterval = setInterval;
+	exports.clearTimeout = clearTimeout;
+	exports.clearInterval = clearInterval;
+	exports.requestAnimationFrame = requestAnimationFrame;
+	exports.cancelAnimationFrame = cancelAnimationFrame;
+
+/***/ }),
+/* 2 */
+/***/ (function(module, exports) {
+
+	"use strict";
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+
+	var _wx$getSystemInfoSync = wx.getSystemInfoSync(),
+	    screenWidth = _wx$getSystemInfoSync.screenWidth,
+	    screenHeight = _wx$getSystemInfoSync.screenHeight,
+	    devicePixelRatio = _wx$getSystemInfoSync.devicePixelRatio;
+
+	var innerWidth = exports.innerWidth = screenWidth;
+	var innerHeight = exports.innerHeight = screenHeight;
+	exports.devicePixelRatio = devicePixelRatio;
+	var screen = exports.screen = {
+	  availWidth: innerWidth,
+	  availHeight: innerHeight
+	};
+	var performance = exports.performance = {
+	  now: function now() {
+	    return Date.now() / 1000;
+	  }
+	};
+	var ontouchstart = exports.ontouchstart = null;
+	var ontouchmove = exports.ontouchmove = null;
+	var ontouchend = exports.ontouchend = null;
+
+/***/ }),
+/* 3 */
+/***/ (function(module, exports, __webpack_require__) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+	exports.HTMLCanvasElement = exports.HTMLImageElement = undefined;
+
+	var _HTMLElement3 = __webpack_require__(4);
+
+	var _HTMLElement4 = _interopRequireDefault(_HTMLElement3);
+
+	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+	function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+	function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+	function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+	var HTMLImageElement = exports.HTMLImageElement = function (_HTMLElement) {
+	  _inherits(HTMLImageElement, _HTMLElement);
+
+	  function HTMLImageElement() {
+	    _classCallCheck(this, HTMLImageElement);
+
+	    return _possibleConstructorReturn(this, (HTMLImageElement.__proto__ || Object.getPrototypeOf(HTMLImageElement)).call(this, 'img'));
+	  }
+
+	  return HTMLImageElement;
+	}(_HTMLElement4.default);
+
+	var HTMLCanvasElement = exports.HTMLCanvasElement = function (_HTMLElement2) {
+	  _inherits(HTMLCanvasElement, _HTMLElement2);
+
+	  function HTMLCanvasElement() {
+	    _classCallCheck(this, HTMLCanvasElement);
+
+	    return _possibleConstructorReturn(this, (HTMLCanvasElement.__proto__ || Object.getPrototypeOf(HTMLCanvasElement)).call(this, 'canvas'));
+	  }
+
+	  return HTMLCanvasElement;
+	}(_HTMLElement4.default);
+
+/***/ }),
+/* 4 */
+/***/ (function(module, exports, __webpack_require__) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+
+	var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+	var _Element2 = __webpack_require__(5);
+
+	var _Element3 = _interopRequireDefault(_Element2);
+
+	var _util = __webpack_require__(8);
+
+	var _WindowProperties = __webpack_require__(2);
+
+	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+	function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+	function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+	function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+	var HTMLElement = function (_Element) {
+	  _inherits(HTMLElement, _Element);
+
+	  function HTMLElement() {
+	    var tagName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
+
+	    _classCallCheck(this, HTMLElement);
+
+	    var _this = _possibleConstructorReturn(this, (HTMLElement.__proto__ || Object.getPrototypeOf(HTMLElement)).call(this));
+
+	    _this.className = '';
+	    _this.childern = [];
+	    _this.style = {
+	      width: _WindowProperties.innerWidth + 'px',
+	      height: _WindowProperties.innerHeight + 'px'
+	    };
+	    _this.insertBefore = _util.noop;
+	    _this.innerHTML = '';
+
+	    _this.tagName = tagName.toUpperCase();
+	    return _this;
+	  }
+
+	  _createClass(HTMLElement, [{
+	    key: 'setAttribute',
+	    value: function setAttribute(name, value) {
+	      this[name] = value;
+	    }
+	  }, {
+	    key: 'getAttribute',
+	    value: function getAttribute(name) {
+	      return this[name];
+	    }
+	  }, {
+	    key: 'getBoundingClientRect',
+	    value: function getBoundingClientRect() {
+	      return {
+	        top: 0,
+	        left: 0,
+	        width: _WindowProperties.innerWidth,
+	        height: _WindowProperties.innerHeight
+	      };
+	    }
+	  }, {
+	    key: 'focus',
+	    value: function focus() {}
+	  }, {
+	    key: 'clientWidth',
+	    get: function get() {
+	      var ret = parseInt(this.style.fontSize, 10) * this.innerHTML.length;
+
+	      return Number.isNaN(ret) ? 0 : ret;
+	    }
+	  }, {
+	    key: 'clientHeight',
+	    get: function get() {
+	      var ret = parseInt(this.style.fontSize, 10);
+
+	      return Number.isNaN(ret) ? 0 : ret;
+	    }
+	  }]);
+
+	  return HTMLElement;
+	}(_Element3.default);
+
+	exports.default = HTMLElement;
+
+/***/ }),
+/* 5 */
+/***/ (function(module, exports, __webpack_require__) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+
+	var _Node2 = __webpack_require__(6);
+
+	var _Node3 = _interopRequireDefault(_Node2);
+
+	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+	function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+	function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+	function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+	var ELement = function (_Node) {
+	  _inherits(ELement, _Node);
+
+	  function ELement() {
+	    _classCallCheck(this, ELement);
+
+	    var _this = _possibleConstructorReturn(this, (ELement.__proto__ || Object.getPrototypeOf(ELement)).call(this));
+
+	    _this.className = '';
+	    _this.children = [];
+	    return _this;
+	  }
+
+	  return ELement;
+	}(_Node3.default);
+
+	exports.default = ELement;
+
+/***/ }),
+/* 6 */
+/***/ (function(module, exports, __webpack_require__) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+
+	var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+	var _EventTarget2 = __webpack_require__(7);
+
+	var _EventTarget3 = _interopRequireDefault(_EventTarget2);
+
+	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+	function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+	function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+	function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+	var Node = function (_EventTarget) {
+	  _inherits(Node, _EventTarget);
+
+	  function Node() {
+	    _classCallCheck(this, Node);
+
+	    var _this = _possibleConstructorReturn(this, (Node.__proto__ || Object.getPrototypeOf(Node)).call(this));
+
+	    _this.childNodes = [];
+	    return _this;
+	  }
+
+	  _createClass(Node, [{
+	    key: 'appendChild',
+	    value: function appendChild(node) {
+	      if (node instanceof Node) {
+	        this.childNodes.push(node);
+	      } else {
+	        throw new TypeError('Failed to executed \'appendChild\' on \'Node\': parameter 1 is not of type \'Node\'.');
+	      }
+	    }
+	  }, {
+	    key: 'cloneNode',
+	    value: function cloneNode() {
+	      var copyNode = Object.create(this);
+
+	      Object.assign(copyNode, this);
+	      return copyNode;
+	    }
+	  }, {
+	    key: 'removeChild',
+	    value: function removeChild(node) {
+	      var index = this.childNodes.findIndex(function (child) {
+	        return child === node;
+	      });
+
+	      if (index > -1) {
+	        return this.childNodes.splice(index, 1);
+	      }
+	      return null;
+	    }
+	  }]);
+
+	  return Node;
+	}(_EventTarget3.default);
+
+	exports.default = Node;
+
+/***/ }),
+/* 7 */
+/***/ (function(module, exports) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+
+	var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+	function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+	var _events = new WeakMap();
+
+	var EventTarget = function () {
+	  function EventTarget() {
+	    _classCallCheck(this, EventTarget);
+
+	    _events.set(this, {});
+	  }
+
+	  _createClass(EventTarget, [{
+	    key: 'addEventListener',
+	    value: function addEventListener(type, listener) {
+	      var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
+
+	      var events = _events.get(this);
+
+	      if (!events) {
+	        events = {};
+	        _events.set(this, events);
+	      }
+	      if (!events[type]) {
+	        events[type] = [];
+	      }
+	      events[type].push(listener);
+
+	      if (options.capture) {
+	        console.warn('EventTarget.addEventListener: options.capture is not implemented.');
+	      }
+	      if (options.once) {
+	        console.warn('EventTarget.addEventListener: options.once is not implemented.');
+	      }
+	      if (options.passive) {
+	        console.warn('EventTarget.addEventListener: options.passive is not implemented.');
+	      }
+	    }
+	  }, {
+	    key: 'removeEventListener',
+	    value: function removeEventListener(type, listener) {
+	      var listeners = _events.get(this)[type];
+
+	      if (listeners && listeners.length > 0) {
+	        for (var i = listeners.length; i--; i > 0) {
+	          if (listeners[i] === listener) {
+	            listeners.splice(i, 1);
+	            break;
+	          }
+	        }
+	      }
+	    }
+	  }, {
+	    key: 'dispatchEvent',
+	    value: function dispatchEvent() {
+	      var event = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
+
+	      var listeners = _events.get(this)[event.type];
+
+	      if (listeners) {
+	        for (var i = 0; i < listeners.length; i++) {
+	          listeners[i](event);
+	        }
+	      }
+	    }
+	  }]);
+
+	  return EventTarget;
+	}();
+
+	exports.default = EventTarget;
+
+/***/ }),
+/* 8 */
+/***/ (function(module, exports) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+	exports.noop = noop;
+	exports.isSubContext = isSubContext;
+	function noop() {}
+
+	function isSubContext() {
+	  return typeof GameGlobal !== 'undefined' && GameGlobal.__isSubContext === true;
+	}
+
+/***/ }),
+/* 9 */
+/***/ (function(module, exports, __webpack_require__) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+	exports.default = Canvas;
+
+	var _constructor = __webpack_require__(3);
+
+	var _HTMLElement = __webpack_require__(4);
+
+	var _HTMLElement2 = _interopRequireDefault(_HTMLElement);
+
+	var _document = __webpack_require__(10);
+
+	var _document2 = _interopRequireDefault(_document);
+
+	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+	var hasModifiedCanvasPrototype = false;
+	var hasInit2DContextConstructor = false;
+	var hasInitWebGLContextConstructor = false;
+
+	function Canvas() {
+	  var canvas = wx.createCanvas();
+
+	  canvas.type = 'canvas';
+
+	  canvas.__proto__.__proto__ = new _HTMLElement2.default('canvas');
+
+	  var _getContext = canvas.getContext;
+
+	  canvas.getBoundingClientRect = function () {
+	    var ret = {
+	      top: 0,
+	      left: 0,
+	      width: window.innerWidth,
+	      height: window.innerHeight
+	    };
+	    return ret;
+	  };
+
+	  return canvas;
+	}
+
+/***/ }),
+/* 10 */
+/***/ (function(module, exports, __webpack_require__) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+
+	var _window = __webpack_require__(1);
+
+	var window = _interopRequireWildcard(_window);
+
+	var _HTMLElement = __webpack_require__(4);
+
+	var _HTMLElement2 = _interopRequireDefault(_HTMLElement);
+
+	var _Image = __webpack_require__(11);
+
+	var _Image2 = _interopRequireDefault(_Image);
+
+	var _Audio = __webpack_require__(12);
+
+	var _Audio2 = _interopRequireDefault(_Audio);
+
+	var _Canvas = __webpack_require__(9);
+
+	var _Canvas2 = _interopRequireDefault(_Canvas);
+
+	__webpack_require__(15);
+
+	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+	function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
+
+	var events = {};
+
+	var document = {
+	  readyState: 'complete',
+	  visibilityState: 'visible',
+	  documentElement: window,
+	  hidden: false,
+	  style: {},
+	  location: window.location,
+	  ontouchstart: null,
+	  ontouchmove: null,
+	  ontouchend: null,
+
+	  head: new _HTMLElement2.default('head'),
+	  body: new _HTMLElement2.default('body'),
+
+	  createElement: function createElement(tagName) {
+	    if (tagName === 'canvas') {
+	      return new _Canvas2.default();
+	    } else if (tagName === 'audio') {
+	      return new _Audio2.default();
+	    } else if (tagName === 'img') {
+	      return new _Image2.default();
+	    }
+
+	    return new _HTMLElement2.default(tagName);
+	  },
+	  getElementById: function getElementById(id) {
+	    if (id === window.canvas.id) {
+	      return window.canvas;
+	    }
+	    return null;
+	  },
+	  getElementsByTagName: function getElementsByTagName(tagName) {
+	    if (tagName === 'head') {
+	      return [document.head];
+	    } else if (tagName === 'body') {
+	      return [document.body];
+	    } else if (tagName === 'canvas') {
+	      return [window.canvas];
+	    }
+	    return [];
+	  },
+	  querySelector: function querySelector(query) {
+	    if (query === 'head') {
+	      return document.head;
+	    } else if (query === 'body') {
+	      return document.body;
+	    } else if (query === 'canvas') {
+	      return window.canvas;
+	    } else if (query === '#' + window.canvas.id) {
+	      return window.canvas;
+	    }
+	    return null;
+	  },
+	  querySelectorAll: function querySelectorAll(query) {
+	    if (query === 'head') {
+	      return [document.head];
+	    } else if (query === 'body') {
+	      return [document.body];
+	    } else if (query === 'canvas') {
+	      return [window.canvas];
+	    }
+	    return [];
+	  },
+	  addEventListener: function addEventListener(type, listener) {
+	    if (!events[type]) {
+	      events[type] = [];
+	    }
+	    events[type].push(listener);
+	  },
+	  removeEventListener: function removeEventListener(type, listener) {
+	    var listeners = events[type];
+
+	    if (listeners && listeners.length > 0) {
+	      for (var i = listeners.length; i--; i > 0) {
+	        if (listeners[i] === listener) {
+	          listeners.splice(i, 1);
+	          break;
+	        }
+	      }
+	    }
+	  },
+	  dispatchEvent: function dispatchEvent(event) {
+	    var listeners = events[event.type];
+
+	    if (listeners) {
+	      for (var i = 0; i < listeners.length; i++) {
+	        listeners[i](event);
+	      }
+	    }
+	  }
+	};
+
+	exports.default = document;
+
+/***/ }),
+/* 11 */
+/***/ (function(module, exports) {
+
+	"use strict";
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+	exports.default = Image;
+	function Image() {
+	  var image = wx.createImage();
+
+	  return image;
+	}
+
+/***/ }),
+/* 12 */
+/***/ (function(module, exports, __webpack_require__) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+
+	var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+	var _HTMLAudioElement2 = __webpack_require__(13);
+
+	var _HTMLAudioElement3 = _interopRequireDefault(_HTMLAudioElement2);
+
+	var _util = __webpack_require__(8);
+
+	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+	function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+	function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+	function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+	var HAVE_NOTHING = 0;
+	var HAVE_METADATA = 1;
+	var HAVE_CURRENT_DATA = 2;
+	var HAVE_FUTURE_DATA = 3;
+	var HAVE_ENOUGH_DATA = 4;
+
+	var _innerAudioContext = new WeakMap();
+	var _src = new WeakMap();
+	var _loop = new WeakMap();
+	var _autoplay = new WeakMap();
+
+	var Audio = function (_HTMLAudioElement) {
+	  _inherits(Audio, _HTMLAudioElement);
+
+	  function Audio(url) {
+	    _classCallCheck(this, Audio);
+
+	    var _this = _possibleConstructorReturn(this, (Audio.__proto__ || Object.getPrototypeOf(Audio)).call(this));
+
+	    _this.HAVE_NOTHING = HAVE_NOTHING;
+	    _this.HAVE_METADATA = HAVE_METADATA;
+	    _this.HAVE_CURRENT_DATA = HAVE_CURRENT_DATA;
+	    _this.HAVE_FUTURE_DATA = HAVE_FUTURE_DATA;
+	    _this.HAVE_ENOUGH_DATA = HAVE_ENOUGH_DATA;
+	    _this.readyState = HAVE_NOTHING;
+
+
+	    if ((0, _util.isSubContext)()) {
+	      console.warn('HTMLAudioElement is not supported in SubContext.');
+	      return _possibleConstructorReturn(_this);
+	    }
+
+	    _src.set(_this, '');
+
+	    var innerAudioContext = wx.createInnerAudioContext();
+
+	    _innerAudioContext.set(_this, innerAudioContext);
+
+	    innerAudioContext.onCanplay(function () {
+	      _this.dispatchEvent({ type: 'load' });
+	      _this.dispatchEvent({ type: 'loadend' });
+	      _this.dispatchEvent({ type: 'canplay' });
+	      _this.dispatchEvent({ type: 'canplaythrough' });
+	      _this.dispatchEvent({ type: 'loadedmetadata' });
+	      _this.readyState = HAVE_CURRENT_DATA;
+	    });
+	    innerAudioContext.onPlay(function () {
+	      _this.dispatchEvent({ type: 'play' });
+	    });
+	    innerAudioContext.onPause(function () {
+	      _this.dispatchEvent({ type: 'pause' });
+	    });
+	    innerAudioContext.onEnded(function () {
+	      _this.dispatchEvent({ type: 'ended' });
+	      _this.readyState = HAVE_ENOUGH_DATA;
+	    });
+	    innerAudioContext.onError(function () {
+	      _this.dispatchEvent({ type: 'error' });
+	    });
+
+	    if (url) {
+	      _innerAudioContext.get(_this).src = url;
+	    }
+	    return _this;
+	  }
+
+	  _createClass(Audio, [{
+	    key: 'load',
+	    value: function load() {
+	      console.warn('HTMLAudioElement.load() is not implemented.');
+	    }
+	  }, {
+	    key: 'play',
+	    value: function play() {
+	      if (!(0, _util.isSubContext)()) {
+	        _innerAudioContext.get(this).play();
+	      }
+	    }
+	  }, {
+	    key: 'pause',
+	    value: function pause() {
+	      if (!(0, _util.isSubContext)()) {
+	        _innerAudioContext.get(this).pause();
+	      }
+	    }
+	  }, {
+	    key: 'canPlayType',
+	    value: function canPlayType() {
+	      var mediaType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
+
+	      if (typeof mediaType !== 'string') {
+	        return '';
+	      }
+
+	      if (mediaType.indexOf('audio/mpeg') > -1 || mediaType.indexOf('audio/mp4')) {
+	        return 'probably';
+	      }
+	      return '';
+	    }
+	  }, {
+	    key: 'cloneNode',
+	    value: function cloneNode() {
+	      var newAudio = new Audio();
+	      if (!(0, _util.isSubContext)()) {
+	        newAudio.loop = _innerAudioContext.get(this).loop;
+	        newAudio.autoplay = _innerAudioContext.get(this).loop;
+	        newAudio.src = this.src;
+	      }
+	      return newAudio;
+	    }
+	  }, {
+	    key: 'currentTime',
+	    get: function get() {
+	      if (!(0, _util.isSubContext)()) {
+	        return _innerAudioContext.get(this).currentTime;
+	      }
+	      return 0;
+	    },
+	    set: function set(value) {
+	      if (!(0, _util.isSubContext)()) {
+	        _innerAudioContext.get(this).seek(value);
+	      }
+	    }
+	  }, {
+	    key: 'src',
+	    get: function get() {
+	      return _src.get(this);
+	    },
+	    set: function set(value) {
+	      _src.set(this, value);
+	      if (!(0, _util.isSubContext)()) {
+	        _innerAudioContext.get(this).src = value;
+	      }
+	    }
+	  }, {
+	    key: 'loop',
+	    get: function get() {
+	      if (!(0, _util.isSubContext)()) {
+	        return _innerAudioContext.get(this).loop;
+	      }
+	      return false;
+	    },
+	    set: function set(value) {
+	      if (!(0, _util.isSubContext)()) {
+	        _innerAudioContext.get(this).loop = value;
+	      }
+	    }
+	  }, {
+	    key: 'autoplay',
+	    get: function get() {
+	      if (!(0, _util.isSubContext)()) {
+	        return _innerAudioContext.get(this).autoplay;
+	      }
+	      return false;
+	    },
+	    set: function set(value) {
+	      if (!(0, _util.isSubContext)()) {
+	        _innerAudioContext.get(this).autoplay = value;
+	      }
+	    }
+	  }, {
+	    key: 'paused',
+	    get: function get() {
+	      if (!(0, _util.isSubContext)()) {
+	        return _innerAudioContext.get(this).paused;
+	      }
+	      return false;
+	    }
+	  }]);
+
+	  return Audio;
+	}(_HTMLAudioElement3.default);
+
+	exports.default = Audio;
+
+/***/ }),
+/* 13 */
+/***/ (function(module, exports, __webpack_require__) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+
+	var _HTMLMediaElement2 = __webpack_require__(14);
+
+	var _HTMLMediaElement3 = _interopRequireDefault(_HTMLMediaElement2);
+
+	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+	function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+	function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+	function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+	var HTMLAudioElement = function (_HTMLMediaElement) {
+	  _inherits(HTMLAudioElement, _HTMLMediaElement);
+
+	  function HTMLAudioElement() {
+	    _classCallCheck(this, HTMLAudioElement);
+
+	    return _possibleConstructorReturn(this, (HTMLAudioElement.__proto__ || Object.getPrototypeOf(HTMLAudioElement)).call(this, 'audio'));
+	  }
+
+	  return HTMLAudioElement;
+	}(_HTMLMediaElement3.default);
+
+	exports.default = HTMLAudioElement;
+
+/***/ }),
+/* 14 */
+/***/ (function(module, exports, __webpack_require__) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+
+	var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+	var _HTMLElement2 = __webpack_require__(4);
+
+	var _HTMLElement3 = _interopRequireDefault(_HTMLElement2);
+
+	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+	function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+	function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+	function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
+
+	var HTMLMediaElement = function (_HTMLElement) {
+	  _inherits(HTMLMediaElement, _HTMLElement);
+
+	  function HTMLMediaElement(type) {
+	    _classCallCheck(this, HTMLMediaElement);
+
+	    return _possibleConstructorReturn(this, (HTMLMediaElement.__proto__ || Object.getPrototypeOf(HTMLMediaElement)).call(this, type));
+	  }
+
+	  _createClass(HTMLMediaElement, [{
+	    key: 'addTextTrack',
+	    value: function addTextTrack() {}
+	  }, {
+	    key: 'captureStream',
+	    value: function captureStream() {}
+	  }, {
+	    key: 'fastSeek',
+	    value: function fastSeek() {}
+	  }, {
+	    key: 'load',
+	    value: function load() {}
+	  }, {
+	    key: 'pause',
+	    value: function pause() {}
+	  }, {
+	    key: 'play',
+	    value: function play() {}
+	  }]);
+
+	  return HTMLMediaElement;
+	}(_HTMLElement3.default);
+
+	exports.default = HTMLMediaElement;
+
+/***/ }),
+/* 15 */
+/***/ (function(module, exports, __webpack_require__) {
+
+	'use strict';
+
+	__webpack_require__(16);
+
+/***/ }),
+/* 16 */
+/***/ (function(module, exports, __webpack_require__) {
+
+	'use strict';
+
+	var _window = __webpack_require__(1);
+
+	var window = _interopRequireWildcard(_window);
+
+	var _document = __webpack_require__(10);
+
+	var _document2 = _interopRequireDefault(_document);
+
+	var _util = __webpack_require__(8);
+
+	function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
+
+	function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
+
+	function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+	var TouchEvent = function TouchEvent(type) {
+	  _classCallCheck(this, TouchEvent);
+
+	  this.target = window.canvas;
+	  this.currentTarget = window.canvas;
+	  this.touches = [];
+	  this.targetTouches = [];
+	  this.changedTouches = [];
+	  this.preventDefault = _util.noop;
+	  this.stopPropagation = _util.noop;
+
+	  this.type = type;
+	};
+
+	function touchEventHandlerFactory(type) {
+	  return function (event) {
+	    var touchEvent = new TouchEvent(type);
+
+	    touchEvent.touches = event.touches;
+	    touchEvent.targetTouches = Array.prototype.slice.call(event.touches);
+	    touchEvent.changedTouches = event.changedTouches;
+	    touchEvent.timeStamp = event.timeStamp;
+	    _document2.default.dispatchEvent(touchEvent);
+	  };
+	}
+
+	wx.onTouchStart(touchEventHandlerFactory('touchstart'));
+	wx.onTouchMove(touchEventHandlerFactory('touchmove'));
+	wx.onTouchEnd(touchEventHandlerFactory('touchend'));
+	wx.onTouchCancel(touchEventHandlerFactory('touchcancel'));
+
+/***/ }),
+/* 17 */
+/***/ (function(module, exports) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+	exports.noop = noop;
+	exports.isSubContext = isSubContext;
+	function noop() {}
+
+	function isSubContext() {
+	  return typeof GameGlobal !== 'undefined' && GameGlobal.__isSubContext === true;
+	}
+
+/***/ }),
+/* 18 */
+/***/ (function(module, exports, __webpack_require__) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+
+	var _util = __webpack_require__(8);
+
+	// TODO 需要 wx.getSystemInfo 获取更详细信息
+	var _wx$getSystemInfoSync = wx.getSystemInfoSync(),
+	    platform = _wx$getSystemInfoSync.platform;
+
+	var navigator = {
+	  platform: platform,
+	  language: 'zh-cn',
+	  appVersion: '5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1',
+	  userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30 (KHTML, like Gecko) Mobile/14E8301 MicroMessenger/6.6.0 MiniGame NetType/WIFI Language/zh_CN',
+	  onLine: true, // TODO 用 wx.getNetworkStateChange 和 wx.onNetworkStateChange 来返回真实的状态
+
+	  // TODO 用 wx.getLocation 来封装 geolocation
+	  geolocation: {
+	    getCurrentPosition: _util.noop,
+	    watchPosition: _util.noop,
+	    clearWatch: _util.noop
+	  }
+	};
+
+	exports.default = navigator;
+
+/***/ }),
+/* 19 */
+/***/ (function(module, exports) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+
+	var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+	function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+	var _url = new WeakMap();
+	var _method = new WeakMap();
+	var _requestHeader = new WeakMap();
+	var _responseHeader = new WeakMap();
+	var _requestTask = new WeakMap();
+
+	function _triggerEvent(type) {
+	  if (typeof this['on' + type] === 'function') {
+	    for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
+	      args[_key - 1] = arguments[_key];
+	    }
+
+	    this['on' + type].apply(this, args);
+	  }
+	}
+
+	function _changeReadyState(readyState) {
+	  this.readyState = readyState;
+	  _triggerEvent.call(this, 'readystatechange');
+	}
+
+	var XMLHttpRequest = function () {
+	  // TODO 没法模拟 HEADERS_RECEIVED 和 LOADING 两个状态
+	  function XMLHttpRequest() {
+	    _classCallCheck(this, XMLHttpRequest);
+
+	    this.onabort = null;
+	    this.onerror = null;
+	    this.onload = null;
+	    this.onloadstart = null;
+	    this.onprogress = null;
+	    this.ontimeout = null;
+	    this.onloadend = null;
+	    this.onreadystatechange = null;
+	    this.readyState = 0;
+	    this.response = null;
+	    this.responseText = null;
+	    this.responseType = '';
+	    this.responseXML = null;
+	    this.status = 0;
+	    this.statusText = '';
+	    this.upload = {};
+	    this.withCredentials = false;
+
+	    _requestHeader.set(this, {
+	      'content-type': 'application/x-www-form-urlencoded'
+	    });
+	    _responseHeader.set(this, {});
+	  }
+
+	  /*
+	   * TODO 这一批事件应该是在 XMLHttpRequestEventTarget.prototype 上面的
+	   */
+
+
+	  _createClass(XMLHttpRequest, [{
+	    key: 'abort',
+	    value: function abort() {
+	      var myRequestTask = _requestTask.get(this);
+
+	      if (myRequestTask) {
+	        myRequestTask.abort();
+	      }
+	    }
+	  }, {
+	    key: 'getAllResponseHeaders',
+	    value: function getAllResponseHeaders() {
+	      var responseHeader = _responseHeader.get(this);
+
+	      return Object.keys(responseHeader).map(function (header) {
+	        return header + ': ' + responseHeader[header];
+	      }).join('\n');
+	    }
+	  }, {
+	    key: 'getResponseHeader',
+	    value: function getResponseHeader(header) {
+	      return _responseHeader.get(this)[header];
+	    }
+	  }, {
+	    key: 'open',
+	    value: function open(method, url /* async, user, password 这几个参数在小程序内不支持*/) {
+	      _method.set(this, method);
+	      _url.set(this, url);
+	      _changeReadyState.call(this, XMLHttpRequest.OPENED);
+	    }
+	  }, {
+	    key: 'overrideMimeType',
+	    value: function overrideMimeType() {}
+	  }, {
+	    key: 'send',
+	    value: function send() {
+	      var _this = this;
+
+	      var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
+
+	      if (this.readyState !== XMLHttpRequest.OPENED) {
+	        throw new Error("Failed to execute 'send' on 'XMLHttpRequest': The object's state must be OPENED.");
+	      } else {
+	        wx.request({
+	          data: data,
+	          url: _url.get(this),
+	          method: _method.get(this),
+	          header: _requestHeader.get(this),
+	          responseType: this.responseType,
+	          success: function success(_ref) {
+	            var data = _ref.data,
+	                statusCode = _ref.statusCode,
+	                header = _ref.header;
+
+	            if (typeof data !== 'string' && !(data instanceof ArrayBuffer)) {
+	              try {
+	                data = JSON.stringify(data);
+	              } catch (e) {
+	                data = data;
+	              }
+	            }
+
+	            _this.status = statusCode;
+	            _responseHeader.set(_this, header);
+	            _triggerEvent.call(_this, 'loadstart');
+	            _changeReadyState.call(_this, XMLHttpRequest.HEADERS_RECEIVED);
+	            _changeReadyState.call(_this, XMLHttpRequest.LOADING);
+
+	            _this.response = data;
+
+	            if (data instanceof ArrayBuffer) {
+	              _this.responseText = '';
+	              var bytes = new Uint8Array(data);
+	              var len = bytes.byteLength;
+
+	              for (var i = 0; i < len; i++) {
+	                _this.responseText += String.fromCharCode(bytes[i]);
+	              }
+	            } else {
+	              _this.responseText = data;
+	            }
+	            _changeReadyState.call(_this, XMLHttpRequest.DONE);
+	            _triggerEvent.call(_this, 'load');
+	            _triggerEvent.call(_this, 'loadend');
+	          },
+	          fail: function fail(_ref2) {
+	            var errMsg = _ref2.errMsg;
+
+	            // TODO 规范错误
+	            if (errMsg.indexOf('abort') !== -1) {
+	              _triggerEvent.call(_this, 'abort');
+	            } else {
+	              _triggerEvent.call(_this, 'error', errMsg);
+	            }
+	            _triggerEvent.call(_this, 'loadend');
+	          }
+	        });
+	      }
+	    }
+	  }, {
+	    key: 'setRequestHeader',
+	    value: function setRequestHeader(header, value) {
+	      var myHeader = _requestHeader.get(this);
+
+	      myHeader[header] = value;
+	      _requestHeader.set(this, myHeader);
+	    }
+	  }]);
+
+	  return XMLHttpRequest;
+	}();
+
+	XMLHttpRequest.UNSEND = 0;
+	XMLHttpRequest.OPENED = 1;
+	XMLHttpRequest.HEADERS_RECEIVED = 2;
+	XMLHttpRequest.LOADING = 3;
+	XMLHttpRequest.DONE = 4;
+	exports.default = XMLHttpRequest;
+
+/***/ }),
+/* 20 */
+/***/ (function(module, exports, __webpack_require__) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+
+	var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+	var _util = __webpack_require__(8);
+
+	function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+	var _socketTask = new WeakMap();
+
+	var WebSocket = function () {
+	  // TODO 更新 binaryType
+	  // The connection is in the process of closing.
+	  // The connection is not yet open.
+	  function WebSocket(url) {
+	    var _this = this;
+
+	    var protocols = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
+
+	    _classCallCheck(this, WebSocket);
+
+	    this.binaryType = '';
+	    this.bufferedAmount = 0;
+	    this.extensions = '';
+	    this.onclose = null;
+	    this.onerror = null;
+	    this.onmessage = null;
+	    this.onopen = null;
+	    this.protocol = '';
+	    this.readyState = 3;
+
+	    if ((0, _util.isSubContext)()) {
+	      throw new Error('WebSocket is not supported in SubContext.');
+	    }
+
+	    if (typeof url !== 'string' || !/(^ws:\/\/)|(^wss:\/\/)/.test(url)) {
+	      throw new TypeError('Failed to construct \'WebSocket\': The URL \'' + url + '\' is invalid');
+	    }
+
+	    this.url = url;
+	    this.readyState = WebSocket.CONNECTING;
+
+	    var socketTask = wx.connectSocket({
+	      url: url,
+	      protocols: Array.isArray(protocols) ? protocols : [protocols]
+	    });
+
+	    _socketTask.set(this, socketTask);
+
+	    socketTask.onClose(function (res) {
+	      _this.readyState = WebSocket.CLOSED;
+	      if (typeof _this.onclose === 'function') {
+	        _this.onclose(res);
+	      }
+	    });
+
+	    socketTask.onMessage(function (res) {
+	      if (typeof _this.onmessage === 'function') {
+	        _this.onmessage(res);
+	      }
+	    });
+
+	    socketTask.onOpen(function () {
+	      _this.readyState = WebSocket.OPEN;
+	      if (typeof _this.onopen === 'function') {
+	        _this.onopen();
+	      }
+	    });
+
+	    socketTask.onError(function (res) {
+	      if (typeof _this.onerror === 'function') {
+	        _this.onerror(new Error(res.errMsg));
+	      }
+	    });
+
+	    return this;
+	  } // TODO 小程序内目前获取不到,实际上需要根据服务器选择的 sub-protocol 返回
+	  // TODO 更新 bufferedAmount
+	  // The connection is closed or couldn't be opened.
+
+	  // The connection is open and ready to communicate.
+
+
+	  _createClass(WebSocket, [{
+	    key: 'close',
+	    value: function close(code, reason) {
+	      this.readyState = WebSocket.CLOSING;
+	      var socketTask = _socketTask.get(this);
+
+	      socketTask.close({
+	        code: code,
+	        reason: reason
+	      });
+	    }
+	  }, {
+	    key: 'send',
+	    value: function send(data) {
+	      if (typeof data !== 'string' && !(data instanceof ArrayBuffer)) {
+	        throw new TypeError('Failed to send message: The data ' + data + ' is invalid');
+	      }
+
+	      var socketTask = _socketTask.get(this);
+
+	      socketTask.send({
+	        data: data
+	      });
+	    }
+	  }]);
+
+	  return WebSocket;
+	}();
+
+	WebSocket.CONNECTING = 0;
+	WebSocket.OPEN = 1;
+	WebSocket.CLOSING = 2;
+	WebSocket.CLOSED = 3;
+	exports.default = WebSocket;
+
+/***/ }),
+/* 21 */
+/***/ (function(module, exports, __webpack_require__) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+
+	var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
+
+	var _util = __webpack_require__(8);
+
+	function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+	/*
+	 * TODO 使用 wx.readFile 来封装 FileReader
+	 */
+	var FileReader = function () {
+	  function FileReader() {
+	    _classCallCheck(this, FileReader);
+	  }
+
+	  _createClass(FileReader, [{
+	    key: 'construct',
+	    value: function construct() {
+	      if ((0, _util.isSubContext)()) {
+	        throw new Error('FileReader is not supported in SubContext.');
+	      }
+	    }
+	  }]);
+
+	  return FileReader;
+	}();
+
+	exports.default = FileReader;
+
+/***/ }),
+/* 22 */
+/***/ (function(module, exports, __webpack_require__) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+
+	var _util = __webpack_require__(8);
+
+	var mainContext = {
+	  get length() {
+	    var _wx$getStorageInfoSyn = wx.getStorageInfoSync(),
+	        keys = _wx$getStorageInfoSyn.keys;
+
+	    return keys.length;
+	  },
+
+	  key: function key(n) {
+	    var _wx$getStorageInfoSyn2 = wx.getStorageInfoSync(),
+	        keys = _wx$getStorageInfoSyn2.keys;
+
+	    return keys[n];
+	  },
+	  getItem: function getItem(key) {
+	    return wx.getStorageSync(key);
+	  },
+	  setItem: function setItem(key, value) {
+	    return wx.setStorageSync(key, value);
+	  },
+	  removeItem: function removeItem(key) {
+	    wx.removeStorageSync(key);
+	  },
+	  clear: function clear() {
+	    wx.clearStorageSync();
+	  }
+	};
+
+	var memLocalStorage = {};
+
+	var subContext = {
+	  get length() {
+	    var keys = Object.keys(memLocalStorage);
+
+	    return keys.length;
+	  },
+
+	  key: function key(n) {
+	    var keys = Object.keys(memLocalStorage);
+
+	    return keys[n];
+	  },
+	  getItem: function getItem(key) {
+	    return memLocalStorage[key];
+	  },
+	  setItem: function setItem(key, value) {
+	    memLocalStorage[key] = value;
+	  },
+	  removeItem: function removeItem(key) {
+	    delete memLocalStorage[key];
+	  },
+	  clear: function clear() {
+	    memLocalStorage = {};
+	  }
+	};
+
+	var localStorage = (0, _util.isSubContext)() ? subContext : mainContext;
+
+	exports.default = localStorage;
+
+/***/ }),
+/* 23 */
+/***/ (function(module, exports) {
+
+	'use strict';
+
+	Object.defineProperty(exports, "__esModule", {
+	  value: true
+	});
+	var location = {
+	  href: 'game.js',
+	  reload: function reload() {}
+	};
+
+	exports.default = location;
+
+/***/ })
+/******/ ]);

+ 32 - 0
ShootingSun/bin/project.config.json

@@ -0,0 +1,32 @@
+{
+    "description": "项目配置文件。",
+    "setting": {
+        "urlCheck": false,
+        "es6": false,
+        "postcss": true,
+        "minified": false,
+        "newFeature": true
+    },
+    "compileType": "game",
+    "libVersion": "game",
+    "appid": "wx0b9ac84ef4a5b8c2",
+    "projectname": "shootingsun2.4.0",
+    "condition": {
+        "search": {
+            "current": -1,
+            "list": []
+        },
+        "conversation": {
+            "current": -1,
+            "list": []
+        },
+        "game": {
+            "currentL": -1,
+            "list": []
+        },
+        "miniprogram": {
+            "current": -1,
+            "list": []
+        }
+    }
+}

+ 1 - 0
ShootingSun/bin/project.swan.json

@@ -0,0 +1 @@
+{"appid":"15052700","compilation-args":{"common":{"ignoreTransJs":true}},"compileType":"game","condition":{"swan":{"current":-2,"list":[]}},"editor":{"curPath":"","expands":[],"markdownUploadTimeMap":{},"paths":[],"recentlyFiles":[]},"libVersion":"1.13.29","libversion":"1.7.7","setting":{"urlCheck":true}}

二進制
ShootingSun/bin/rank/ad.jpg


二進制
ShootingSun/bin/rank/bg.png


二進制
ShootingSun/bin/rank/btnLeft.png


二進制
ShootingSun/bin/rank/btnRight.png


二進制
ShootingSun/bin/rank/button.png


二進制
ShootingSun/bin/rank/default.png


二進制
ShootingSun/bin/rank/rank1.png


二進制
ShootingSun/bin/rank/rank2.png


二進制
ShootingSun/bin/rank/rank3.png


二進制
ShootingSun/bin/rank/rect1.png


二進制
ShootingSun/bin/rank/rect2.png


二進制
ShootingSun/bin/rank/rect3.png


二進制
ShootingSun/bin/rank/rect4.png


二進制
ShootingSun/bin/rank/round.png


二進制
ShootingSun/bin/rank/titleRank.png


二進制
ShootingSun/bin/rank/txtBack.png


+ 383 - 0
ShootingSun/bin/res/atlas/.rec

@@ -0,0 +1,383 @@
+D .
+D dragonBone
+D music
+R E2DDA79A bgMusic.mp3
+R DEDBAEC4 btnClick.mp3
+R 41A3E0F5 gameFailed.mp3
+R 9CDA7164 gameSuccess.mp3
+R 932EA1E1 getCoins.mp3
+R 8D8B13C3 hitObstacle.wav
+R F959AD49 knifeAttackSun.mp3
+R 60FFA760 planetDie.mp3
+R 072BC0CB useProp.wav
+D rank
+D texture
+D UI
+D texture/aniJump
+P E621BF48 tiao28.png
+P F9B4378B tiao29.png
+P 9E4BB308 tiao30.png
+P E3995441 tiao31.png
+P 522EAFC6 tiao32.png
+P 49E6EDED tiao33.png
+P 8ECAA837 tiao34.png
+P C69D480A tiao35.png
+P 62FD31C3 tiao36.png
+P 12EBA533 tiao37.png
+P D08696DC tiao38.png
+P BD24D6D9 tiao39.png
+P F4FE25E1 tiao40.png
+P 8C457946 tiao41.png
+P E6661EE7 tiao42.png
+P 1A8E7DD1 tiao43.png
+P 170F9AC2 tiao44.png
+P E1390B17 tiao45.png
+P C1A9E4ED tiao46.png
+P 4D9F825C tiao47.png
+P 1BCE688D tiao48.png
+P 08D8F6C3 tiao49.png
+P 9F86AAFA tiao50.png
+P 5AB0780C tiao51.png
+P 59C70127 tiao52.png
+P 244F0B81 tiao53.png
+P 35DBC8E6 tiao54.png
+P FB4D9C4F tiao55.png
+P 2AB0F75E tiao56.png
+P 1CA0CB91 tiao57.png
+D texture/BG
+R C308EFF6 BG1.jpg
+R CDB504D3 BG2.jpg
+R 02189B99 BG3.jpg
+R 808715F4 BG4.jpg
+R 46F8EFA5 BG5.jpg
+R 262B20DF BG_halation.png
+P E35E5126 BG_planet1.png
+P EEA42F26 BG_planet2.png
+R AAC59EDD BG_stars.png
+P 0613B705 star1.png
+P BD786754 star2.png
+P F7EC8DC1 star3.png
+P B2C8BDF6 star4.png
+D texture/Dialog_CoinAndStrength
+P B470CD2D btn_clickReceive.png
+P 422152DE btn_getStrength.png
+P C192E03C btn_nextTime.png
+P 50A2C1B8 btn_threeTimesFaster.png
+P 383FF410 btn_threeTimesReceiving.png
+P 7D3E4DA1 coinOutGlow.png
+R 85C1E11A dialogBG.png
+P C8F7D46A ring.png
+P C8D2869C strengthRingBG.png
+P 8853C397 title_fasterReceiving.png
+P 8A83A54B title_profitCanBeReceived.png
+P D1E187DA title_strengthRecovery.png
+D texture/Dialog_GetProp
+P BCA45B8D btn_freeRevive.png
+P C192E03C btn_nextTime.png
+R BDDBCD37 dialogBG.png
+P 01FDF9D7 rocket.png
+P E48DE511 slowDown.png
+P 17142EEE subBlood.png
+D texture/Dialog_LevelOver
+P 5013F3B5 btn_giveUp.png
+P EA3884C3 btn_receiveRightNow.png
+P 727C3983 btn_revive.png
+P BA8CD41D btn_threeTimesReceiving.png
+P B85232A6 light_defeat.png
+P 2D7FC284 light_victory.png
+P C42A3248 title_defeat.png
+P C2F22825 title_victory.png
+D texture/Dialog_NewPlanet
+P C614F247 btn_OK.png
+R E21CA3D7 dialogBG.png
+D texture/Effect
+D texture/GameOverPage
+P 0359A399 btn_playAgain.png
+D texture/GameScene
+P 9BDE9EC4 icon_blood.png
+P 464DCA7F icon_invincibleRocket.png
+P 536568F1 icon_rocket.png
+R 0B6777C9 innerRing.png
+P A59B26F0 invincibleRocket.png
+P 77773B25 obstacle.png
+R B0F09FBC outRing.png
+P 10491C46 progress_shield.png
+R E4B918DC progressBar_blood.png
+R FFA37E31 progressBG_blood.png
+P F179A889 propIcon_rocket.png
+P 4230A6F8 propIcon_slowDown.png
+P DF7BAD4A propIcon_subBlood.png
+P 159E318C propNumBG.png
+P F4065162 propNumBG2.png
+P 49450B22 radialLine.png
+P 719DABD2 redTwinkle.png
+P EB299950 redTwinkle_propRocket.png
+P 5C5ECB93 redTwinkle_tree.png
+P A561B5C9 rocket.png
+D texture/MainScene
+P 24690D6B btn_add.png
+P F2DD2C2C btn_startGame.png
+P 6CCDE80C coinAStrengthBG.png
+P A7FDDF46 gameTitle.png
+P BBCD6D13 icon_coin.png
+P D6504CFB icon_rank.png
+P D7E63156 icon_strength.png
+D texture/Planet
+P F09A8FEE Jupiter.png
+P BC2A0F8B Mars.png
+P 88AE7445 Mercury.png
+P 016906AA Saturn.png
+P 5FDB230D Venus.png
+D texture/Public
+P C4741060 jumpBG.png
+R D230699A mask.jpg
+P C9CC9876 returnHome.png
+D texture/Sun
+P 36C5D19B biaoqing_baonu.png
+P 0BD8A503 biaoqing_chaoxiao.png
+P 3700722F biaoqing_jingkong.png
+P F0BF7D6A biaoqing_kaixin.png
+P D4A6791F biaoqing_kuqi.png
+P 2FBDC806 biaoqing_shuai.png
+P 6E11282E biaoqing_tiaoxin.png
+P C51972E3 biaoqing_wuliao.png
+P 90371224 outerGrowOfSun.png
+P FFD1FD03 sunBG_jingkong.png
+P 3413272E sunBG_normal.png
+P F06D3793 sunBG_shuai.png
+R 1CE11722 sunShine1.png
+R CE30B705 sunShine2.png
+D texture/Dialog_CoinAndStrength/threeTimesFasterProgress
+P A4AB6FC2 clip_num_fasterProfit.png
+P 07072EC1 fasterCountTime_bar.png
+P 75599DC1 fasterCountTime_bg.png
+P 9E966128 maohao.png
+D texture/Effect/Crit
+R C1085B73 clip_num_crit.png
+P AFA909C2 CritFire.png
+P E4B8348D CritText.png
+P D885BB2F hp.png
+P 7C00BAF2 symbol.png
+D texture/Effect/Finger
+P 59CABF1C Click1.png
+P 7C32C425 Click2.png
+P 9E4F295D Click3.png
+P D2C9A15D Click4.png
+D texture/Effect/Planet_Jupiter
+P BBABE1B1 fire10.png
+P 495E647E fire11.png
+P 8AD1F08F fire12.png
+P 9F96FEC9 fire13.png
+P D9B48B4E fire14.png
+P 0D05BF56 fire15.png
+P A50302FB fire16.png
+P C11368DA fire17.png
+P DAE50EA9 fire18.png
+P 8A4E6DC1 fire19.png
+P 37AD8AB9 fire20.png
+P AA8FEC3F fire21.png
+P 3B1F10A6 fire22.png
+D texture/Effect/Planet_Mars
+D texture/Effect/Planet_Mercury
+P 0B0352F3 add.png
+D texture/Effect/Planet_Saturn
+P 2464D7B7 icon_SaturnSkill.png
+D texture/Effect/Planet_Venus
+D texture/Effect/PlanetExplode
+P FECB9AA0 explode01.png
+P 0A96E423 explode02.png
+P 8DCA883D explode03.png
+P E3C9EACD explode04.png
+P D10F6EC7 explode05.png
+P 7516B5B4 explode06.png
+P 890A9569 explode07.png
+P 7F1AB0DC explode08.png
+P AFDC6416 explode09.png
+P 78149669 explode10.png
+D texture/Effect/PlanetRift
+P 611DE9FD Rift01.png
+P EA57CBE2 Rift02.png
+P F3BF656B Rift03.png
+D texture/Effect/ReviveFire
+P 4121FF5E fire01.png
+P E5DE0C17 fire02.png
+P 3574C388 fire03.png
+P EE959FCA fire04.png
+P 989F87AB fire05.png
+P BB402C67 fire06.png
+P 32069EF2 fire07.png
+P 7A878378 fire08.png
+P 24FFC19A fire09.png
+P 206EADC5 fire10.png
+P 1DC4B87A fire11.png
+D texture/Effect/ringEffect
+R 20B6AFC0 .DS_Store
+P E5A77A1C add_blood.png
+P FCA62072 fast.png
+D texture/Effect/RocketFire
+P 52C67AD1 01.png
+P 1F241B14 02.png
+P 24DB962F 03.png
+P F5BEDD1B 04.png
+P E2ACA58E 05.png
+P 12934A49 06.png
+P B3E1D9C4 07.png
+P FD75D9C6 08.png
+P 20433B6B 09.png
+D texture/Effect/SunDieFlame
+P 38F61B10 flame01.png
+P DA591875 flame02.png
+P 6FA6BB97 flame03.png
+P 10CB3B8B flame04.png
+P AB710F8F flame05.png
+P 9A36F8B0 flame06.png
+P 1FCA223E flame07.png
+P 42E480BF flame08.png
+P DC4EE8C7 flame09.png
+P F5EEB3AA flame10.png
+P 43FE21C7 flame11.png
+P 76A41AC7 flame12.png
+P 39616049 flame13.png
+P B3A27BF6 flame14.png
+D texture/Effect/SunLiquidBig01
+P FAB0D166 liquid1.png
+P FADB9CC1 liquid2.png
+P F8EA010E liquid3.png
+P 047B2FEF liquid4.png
+P CE6743B4 liquid5.png
+P 2EE71C90 liquid6.png
+P D03BC0DB liquid7.png
+P CF7B6C2B liquid8.png
+P 89546A68 liquid9.png
+D texture/Effect/SunLiquidBig02
+P 9D9ACD03 liquid01.png
+P E58773A1 liquid02.png
+P 6EFCC2DA liquid03.png
+P FA2ED49F liquid04.png
+P A0797C8C liquid05.png
+P D4937724 liquid06.png
+P 780218DE liquid07.png
+P F875AD63 liquid08.png
+P 9AFD48FA liquid09.png
+P 1E04B85F liquid10.png
+D texture/Effect/SunLiquidBig03
+P 41732153 liquid01.png
+P 38970BD5 liquid02.png
+P 7092E09C liquid03.png
+P E2B5D8BD liquid04.png
+P D692EEFE liquid05.png
+P 7C691BD9 liquid06.png
+P 291AEE62 liquid07.png
+P BFCC8C7F liquid08.png
+P AC9628C2 liquid09.png
+P 5715E6A9 liquid10.png
+P 0926C712 liquid11.png
+D texture/Effect/SunLiquidSmall01
+P 3BF7A734 liquid01.png
+P 0142A1AA liquid02.png
+P 1E1523C1 liquid03.png
+P 1B4727E8 liquid04.png
+P 62C428A1 liquid05.png
+P 2F9266FA liquid06.png
+P 2D9DA56D liquid07.png
+P F5B2E6FC liquid08.png
+P 15F0F54D liquid09.png
+P 0944885F liquid10.png
+D texture/Effect/SunLiquidSmall02
+P 89778767 liquid1.png
+P 62A068BD liquid2.png
+P EB43F794 liquid3.png
+P F155AA58 liquid4.png
+P E25FB686 liquid5.png
+P A2F28CF2 liquid6.png
+P 4298B3AF liquid7.png
+P 747FF000 liquid8.png
+D texture/Effect/SunLiquidSmall03
+P C5C2D2DC liquid01.png
+P 93595EBD liquid02.png
+P 70E1F457 liquid03.png
+P A51D33AE liquid04.png
+P 1E02ECA9 liquid05.png
+P 03FB75D9 liquid06.png
+P 16B75851 liquid07.png
+P 124EF5FE liquid08.png
+P E3DAF4F6 liquid09.png
+P 6ACFFDD1 liquid10.png
+D texture/Effect/SunRift
+P 63D0FA44 Rift01_01.png
+P 9136EC25 Rift01_02.png
+P 7D33FB0E Rift01_03.png
+P E45C7BF9 Rift02_01.png
+P F27C7759 Rift02_02.png
+P B3C6AE83 Rift02_03.png
+P B753A6A3 Rift03_01.png
+P 07A6F3D9 Rift03_02.png
+P 5FF913DD Rift03_03.png
+P B5634C01 Rift04.png
+P A29A0A81 Rift05.png
+P 9A483CA0 Rift06.png
+D texture/MainScene/CoinProfit
+P 540F208C coinProducing.png
+P 5BB7CA45 coinProfitcircle.png
+P 39378416 profitRingBG.png
+P AF7F7383 progress$bar.png
+P C18DBA92 progress.png
+P 5F16AD93 receiveCoin.png
+D texture/MainScene/LevelList
+P 1EFF5129 btn_arrow.png
+P E3FE4380 btn_close.png
+P 6B6CEDA3 icon_currentUnlockedLevel.png
+P 29353EFC icon_lockedLevel.png
+P 65672BE6 icon_unlockedLevel.png
+P CDB79CE4 mask.png
+D texture/MainScene/TAB
+P 85713D3C btn_coin_checked.png
+P 78B9658C btn_coin_unchecked.png
+P 4EF993DA btn_crit_checked.png
+P E20F39C0 btn_crit_unchecked.png
+P E3BFBFBE btn_notOptional.png
+P 81BBF266 btn_optional.png
+P 5EE022BF btn_rocket_checked.png
+P 0E52E6F4 btn_rocket_unchecked.png
+R 48C0B48F bubble_coin.png
+R 0C5D0AE8 bubble_crit.png
+P 0C3CDC7F bubble_lock.png
+R 3B2A6FF2 bubble_rocket.png
+P 3CE372C6 icon_Coin.png
+P DF2C97F8 icon_strength.png
+P B2CE45AE redDot.png
+D texture/Planet/other
+P C085A5BA icon_tree.png
+D texture/Effect/Planet_Mars/BlowUpRocket
+P 2921A476 fire1.png
+P 957FC549 fire2.png
+P B89664AE fire3.png
+P 2037ACCB fire4.png
+P F6E16699 fire5.png
+P B56F41CD fire6.png
+P 31FA0D3E fire7.png
+P 5659AD1D fire8.png
+D texture/Effect/Planet_Mars/fireball
+P 48343521 fire10.png
+P 3572C425 fire11.png
+P C45F4591 fire12.png
+P B3711888 fire13.png
+P 248ABF10 fire14.png
+P DC0A2FDC fire15.png
+P DAEF1EB8 fire16.png
+P F51DE0DA fire17.png
+P 3C0AE740 fire18.png
+P C23D27F3 fire19.png
+P 18311147 fire20.png
+D texture/Effect/Planet_Venus/fireball
+P 17DD50B7 fire01.png
+P 3A118FA8 fire02.png
+P F8BC93D5 fire03.png
+P 09FDDF6B fire04.png
+P 6AAC25C6 fire05.png
+P 8E9C23B4 fire06.png
+P 25811235 fire07.png
+P CFA7B046 fire08.png
+P B6F433EE fire09.png
+P 1A25C663 fire10.png
+P FFCC9988 fire11.png

+ 1 - 0
ShootingSun/bin/res/atlas/texture/BG.atlas

@@ -0,0 +1 @@
+{"frames":{"BG_planet1.png":{"frame":{"h":125,"idx":0,"w":84,"x":103,"y":0},"sourceSize":{"h":125,"w":84},"spriteSourceSize":{"x":0,"y":0}},"BG_planet2.png":{"frame":{"h":174,"idx":0,"w":102,"x":0,"y":0},"sourceSize":{"h":174,"w":102},"spriteSourceSize":{"x":0,"y":0}},"star1.png":{"frame":{"h":49,"idx":0,"w":44,"x":103,"y":126},"sourceSize":{"h":49,"w":44},"spriteSourceSize":{"x":0,"y":0}},"star2.png":{"frame":{"h":14,"idx":0,"w":14,"x":148,"y":165},"sourceSize":{"h":14,"w":14},"spriteSourceSize":{"x":0,"y":0}},"star3.png":{"frame":{"h":14,"idx":0,"w":14,"x":163,"y":165},"sourceSize":{"h":14,"w":14},"spriteSourceSize":{"x":0,"y":0}},"star4.png":{"frame":{"h":38,"idx":0,"w":36,"x":148,"y":126},"sourceSize":{"h":38,"w":36},"spriteSourceSize":{"x":0,"y":0}}},"meta":{"image":"BG.png","prefix":"texture/BG/"}}

二進制
ShootingSun/bin/res/atlas/texture/BG.png


+ 1 - 0
ShootingSun/bin/res/atlas/texture/Dialog_CoinAndStrength.atlas

@@ -0,0 +1 @@
+{"frames":{"btn_clickReceive.png":{"frame":{"h":139,"idx":0,"w":434,"x":0,"y":281},"sourceSize":{"h":139,"w":434},"spriteSourceSize":{"x":0,"y":0}},"btn_getStrength.png":{"frame":{"h":120,"idx":0,"w":320,"x":279,"y":129},"sourceSize":{"h":125,"w":330},"spriteSourceSize":{"x":5,"y":5}},"btn_nextTime.png":{"frame":{"h":30,"idx":0,"w":129,"x":279,"y":250},"sourceSize":{"h":30,"w":129},"spriteSourceSize":{"x":0,"y":0}},"btn_threeTimesFaster.png":{"frame":{"h":128,"idx":0,"w":348,"x":279,"y":0},"sourceSize":{"h":128,"w":348},"spriteSourceSize":{"x":0,"y":0}},"btn_threeTimesReceiving.png":{"frame":{"h":139,"idx":0,"w":434,"x":0,"y":421},"sourceSize":{"h":139,"w":434},"spriteSourceSize":{"x":0,"y":0}},"coinOutGlow.png":{"frame":{"h":280,"idx":0,"w":278,"x":0,"y":0},"sourceSize":{"h":280,"w":278},"spriteSourceSize":{"x":0,"y":0}},"ring.png":{"frame":{"h":184,"idx":0,"w":184,"x":435,"y":250},"sourceSize":{"h":184,"w":184},"spriteSourceSize":{"x":0,"y":0}},"strengthRingBG.png":{"frame":{"h":184,"idx":0,"w":184,"x":435,"y":435},"sourceSize":{"h":184,"w":184},"spriteSourceSize":{"x":0,"y":0}},"title_fasterReceiving.png":{"frame":{"h":54,"idx":0,"w":199,"x":0,"y":616},"sourceSize":{"h":54,"w":199},"spriteSourceSize":{"x":0,"y":0}},"title_profitCanBeReceived.png":{"frame":{"h":54,"idx":0,"w":337,"x":0,"y":561},"sourceSize":{"h":54,"w":337},"spriteSourceSize":{"x":0,"y":0}},"title_strengthRecovery.png":{"frame":{"h":54,"idx":0,"w":198,"x":200,"y":616},"sourceSize":{"h":54,"w":198},"spriteSourceSize":{"x":0,"y":0}}},"meta":{"image":"Dialog_CoinAndStrength.png","prefix":"texture/Dialog_CoinAndStrength/"}}

二進制
ShootingSun/bin/res/atlas/texture/Dialog_CoinAndStrength.png


+ 1 - 0
ShootingSun/bin/res/atlas/texture/Dialog_CoinAndStrength/threeTimesFasterProgress.atlas

@@ -0,0 +1 @@
+{"frames":{"clip_num_fasterProfit.png":{"frame":{"h":35,"idx":0,"w":286,"x":0,"y":186},"sourceSize":{"h":35,"w":290},"spriteSourceSize":{"x":2,"y":0}},"fasterCountTime_bar.png":{"frame":{"h":92,"idx":0,"w":348,"x":0,"y":0},"sourceSize":{"h":92,"w":348},"spriteSourceSize":{"x":0,"y":0}},"fasterCountTime_bg.png":{"frame":{"h":92,"idx":0,"w":348,"x":0,"y":93},"sourceSize":{"h":92,"w":348},"spriteSourceSize":{"x":0,"y":0}},"maohao.png":{"frame":{"h":25,"idx":0,"w":8,"x":287,"y":186},"sourceSize":{"h":35,"w":16},"spriteSourceSize":{"x":4,"y":5}}},"meta":{"image":"threeTimesFasterProgress.png","prefix":"texture/Dialog_CoinAndStrength/threeTimesFasterProgress/"}}

二進制
ShootingSun/bin/res/atlas/texture/Dialog_CoinAndStrength/threeTimesFasterProgress.png


+ 1 - 0
ShootingSun/bin/res/atlas/texture/Dialog_GetProp.atlas

@@ -0,0 +1 @@
+{"frames":{"btn_freeRevive.png":{"frame":{"h":120,"idx":0,"w":320,"x":0,"y":0},"sourceSize":{"h":120,"w":320},"spriteSourceSize":{"x":0,"y":0}},"btn_nextTime.png":{"frame":{"h":30,"idx":0,"w":129,"x":327,"y":191},"sourceSize":{"h":30,"w":129},"spriteSourceSize":{"x":0,"y":0}},"rocket.png":{"frame":{"h":190,"idx":0,"w":162,"x":327,"y":0},"sourceSize":{"h":190,"w":162},"spriteSourceSize":{"x":0,"y":0}},"slowDown.png":{"frame":{"h":190,"idx":0,"w":163,"x":163,"y":121},"sourceSize":{"h":190,"w":163},"spriteSourceSize":{"x":0,"y":0}},"subBlood.png":{"frame":{"h":199,"idx":0,"w":162,"x":0,"y":121},"sourceSize":{"h":199,"w":162},"spriteSourceSize":{"x":0,"y":0}}},"meta":{"image":"Dialog_GetProp.png","prefix":"texture/Dialog_GetProp/"}}

二進制
ShootingSun/bin/res/atlas/texture/Dialog_GetProp.png


+ 1 - 0
ShootingSun/bin/res/atlas/texture/Dialog_LevelOver.atlas

@@ -0,0 +1 @@
+{"frames":{"btn_giveUp.png":{"frame":{"h":32,"idx":0,"w":64,"x":938,"y":0},"sourceSize":{"h":32,"w":64},"spriteSourceSize":{"x":0,"y":0}},"btn_receiveRightNow.png":{"frame":{"h":138,"idx":0,"w":468,"x":0,"y":430},"sourceSize":{"h":138,"w":468},"spriteSourceSize":{"x":0,"y":0}},"btn_revive.png":{"frame":{"h":128,"idx":0,"w":328,"x":0,"y":569},"sourceSize":{"h":128,"w":328},"spriteSourceSize":{"x":0,"y":0}},"btn_threeTimesReceiving.png":{"frame":{"h":138,"idx":0,"w":468,"x":469,"y":430},"sourceSize":{"h":138,"w":468},"spriteSourceSize":{"x":0,"y":0}},"light_defeat.png":{"frame":{"h":429,"idx":0,"w":427,"x":0,"y":0},"sourceSize":{"h":429,"w":427},"spriteSourceSize":{"x":0,"y":0}},"light_victory.png":{"frame":{"h":429,"idx":0,"w":427,"x":428,"y":0},"sourceSize":{"h":429,"w":427},"spriteSourceSize":{"x":0,"y":0}},"title_defeat.png":{"frame":{"h":56,"idx":0,"w":236,"x":329,"y":627},"sourceSize":{"h":56,"w":236},"spriteSourceSize":{"x":0,"y":0}},"title_victory.png":{"frame":{"h":57,"idx":0,"w":236,"x":329,"y":569},"sourceSize":{"h":57,"w":236},"spriteSourceSize":{"x":0,"y":0}}},"meta":{"image":"Dialog_LevelOver.png","prefix":"texture/Dialog_LevelOver/"}}

二進制
ShootingSun/bin/res/atlas/texture/Dialog_LevelOver.png


+ 1 - 0
ShootingSun/bin/res/atlas/texture/Dialog_NewPlanet.atlas

@@ -0,0 +1 @@
+{"frames":{"btn_OK.png":{"frame":{"h":134,"idx":0,"w":334,"x":0,"y":0},"sourceSize":{"h":134,"w":334},"spriteSourceSize":{"x":0,"y":0}}},"meta":{"image":"Dialog_NewPlanet.png","prefix":"texture/Dialog_NewPlanet/"}}

二進制
ShootingSun/bin/res/atlas/texture/Dialog_NewPlanet.png


+ 1 - 0
ShootingSun/bin/res/atlas/texture/Effect/Crit.atlas

@@ -0,0 +1 @@
+{"frames":{"CritFire.png":{"frame":{"h":220,"idx":0,"w":214,"x":0,"y":0},"sourceSize":{"h":220,"w":214},"spriteSourceSize":{"x":0,"y":0}},"CritText.png":{"frame":{"h":56,"idx":0,"w":128,"x":0,"y":221},"sourceSize":{"h":83,"w":128},"spriteSourceSize":{"x":0,"y":23}},"hp.png":{"frame":{"h":65,"idx":0,"w":79,"x":129,"y":221},"sourceSize":{"h":83,"w":79},"spriteSourceSize":{"x":0,"y":18}},"symbol.png":{"frame":{"h":27,"idx":0,"w":44,"x":209,"y":221},"sourceSize":{"h":83,"w":44},"spriteSourceSize":{"x":0,"y":28}}},"meta":{"image":"Crit.png","prefix":"texture/Effect/Crit/"}}

部分文件因文件數量過多而無法顯示