|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
import { Database, Engine, RenderingManager, Scene } from "@babylonjs/core"; |
|
|
|
|
import { Database, Engine, FileTools, RenderingManager, Scene } from "@babylonjs/core"; |
|
|
|
|
|
|
|
|
|
import { SceneManager } from "./controller/scene-manager"; |
|
|
|
|
import { LoginSatus } from "./controller/status/login-status"; |
|
|
|
@ -18,8 +18,9 @@ export class Game {
|
|
|
|
|
//初始化引擎和画布
|
|
|
|
|
public init(canvas: HTMLCanvasElement) { |
|
|
|
|
|
|
|
|
|
// FileTools.DefaultRetryStrategy = MyRetryStrategy.ExponentialBackoff(2, 1000);
|
|
|
|
|
// FileTools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff(2, 1000);
|
|
|
|
|
FileTools.DefaultRetryStrategy = MyRetryStrategy.ExponentialBackoff(2, 1000); |
|
|
|
|
// FileTools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff(2, 1000);
|
|
|
|
|
|
|
|
|
|
if (Game.instance != null) { |
|
|
|
|
// canvas.setAttribute("touch-action", "none");
|
|
|
|
|
// canvas.style.touchAction = "none";
|
|
|
|
@ -117,27 +118,30 @@ export class Game {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// /**
|
|
|
|
|
// * 重试策略
|
|
|
|
|
// */
|
|
|
|
|
// var MyRetryStrategy = /** @class */ (function () {
|
|
|
|
|
// function RetryStrategy() {
|
|
|
|
|
// }
|
|
|
|
|
// /**
|
|
|
|
|
// * Function used to defines an exponential back off strategy
|
|
|
|
|
// * @param maxRetries defines the maximum number of retries (3 by default)
|
|
|
|
|
// * @param baseInterval defines the interval between retries
|
|
|
|
|
// * @returns the strategy function to use
|
|
|
|
|
// */
|
|
|
|
|
// MyRetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
|
|
|
|
|
// if (maxRetries === void 0) { maxRetries = 3; }
|
|
|
|
|
// if (baseInterval === void 0) { baseInterval = 500; }
|
|
|
|
|
// return function (url, request, retryIndex) {
|
|
|
|
|
// if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
|
|
|
|
|
// return -1;
|
|
|
|
|
// }
|
|
|
|
|
// return Math.pow(2, retryIndex) * baseInterval;
|
|
|
|
|
// };
|
|
|
|
|
// };
|
|
|
|
|
// return MyRetryStrategy;
|
|
|
|
|
// }());
|
|
|
|
|
/** |
|
|
|
|
* 重试策略 |
|
|
|
|
*/ |
|
|
|
|
var MyRetryStrategy = /** @class */ (function () { |
|
|
|
|
function MyRetryStrategy() { |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* Function used to defines an exponential back off strategy |
|
|
|
|
* @param maxRetries defines the maximum number of retries (3 by default) |
|
|
|
|
* @param baseInterval defines the interval between retries |
|
|
|
|
* @returns the strategy function to use |
|
|
|
|
*/ |
|
|
|
|
MyRetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) { |
|
|
|
|
if (maxRetries === void 0) { maxRetries = 3; } |
|
|
|
|
if (baseInterval === void 0) { baseInterval = 500; } |
|
|
|
|
return function (url, request, retryIndex) { |
|
|
|
|
|
|
|
|
|
if (request.status == 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) { |
|
|
|
|
console.log("不重试加载", request.status, retryIndex, url.indexOf("file:")); |
|
|
|
|
return -1; |
|
|
|
|
} |
|
|
|
|
console.log("重试加载", request.status, retryIndex, url.indexOf("file:")); |
|
|
|
|
return Math.pow(2, retryIndex) * baseInterval; |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|
return MyRetryStrategy; |
|
|
|
|
}()); |
|
|
|
|