var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameDefined_1 = require("./script/GameLogic/GameDefined");
var SceneController_1 = require("./script/GameLogic/SceneController");
var OimoHelper_1 = require("./script/Oimo/OimoHelper");
var AssetController = /** @class */ (function () {
    function AssetController() {
    }
    Object.defineProperty(AssetController, "Instance", {
        get: function () {
            return this.instance || (this.instance = new AssetController());
        },
        enumerable: true,
        configurable: true
    });
    AssetController.prototype.GameStart = function () {
        Laya.loader.create(GameDefined_1.default.main_path, new Laya.Handler(this, function (res) {
            var _scene = res;
            OimoHelper_1.default.Inst.createWolrd();
            SceneController_1.SceneController.Instance.Init(_scene);
        }));
    };
    // private CreateBody() {
    //     var panel = this.panel.addComponent(StandBehaviour) as StandBehaviour;
    //     var data = new OimoBodyData();
    //     data.move = false;
    //     data.type = "box";
    //     panel.init(data);
    //     for (let index = 0; index < this.move._children.length; index++) {
    //         const element = this.move._children[index];
    //         var shell = element.addComponent(ShellBehaviour) as ShellBehaviour;
    //         var data1 = new OimoBodyData();
    //         data1.move = true;
    //         data1.type = "box";
    //         data1.friction=3;
    //         shell.init(data1);
    //     }
    //     var player = this.cube1.addComponent(PlayerBehaviour) as PlayerBehaviour;
    //     var data2 = new OimoBodyData();
    //     data2.move = true;
    //     data2.type = "box";
    //     data2.kinematic = true;
    //     data2.name = 1000;
    //     player.init(data2);
    // }
    AssetController.prototype.MouseContr = function () {
        Laya.stage.on(Laya.Event.MOUSE_DOWN, this, this.OnClickDown);
        Laya.stage.on(Laya.Event.MOUSE_UP, this, this.OnClickUp);
        Laya.stage.on(Laya.Event.MOUSE_OUT, this, this.OnClickUp);
    };
    AssetController.prototype.OnClickDown = function (e) {
        Laya.stage.on(Laya.Event.MOUSE_MOVE, this, this.OnSlider);
        this.curMousePos = new Laya.Vector3(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY);
        console.log(this.curMousePos);
    };
    AssetController.prototype.OnClickUp = function () {
        Laya.stage.off(Laya.Event.MOUSE_MOVE, this, this.OnSlider);
        var MousePos = new Laya.Vector3(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY);
        console.log(MousePos);
    };
    AssetController.prototype.OnSlider = function () {
        var MousePos = new Laya.Vector3(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY);
        var offestX = MousePos.x - this.curMousePos.x;
        var offestZ = MousePos.y - this.curMousePos.y;
        if (offestX > 0)
            offestX = offestX < 0.1 ? offestX : 0.1;
        if (offestX < 0)
            offestX = offestX > -0.1 ? offestX : -0.1;
        if (offestZ > 0)
            offestZ = offestZ < 0.1 ? offestZ : 0.1;
        if (offestZ < 0)
            offestZ = offestZ > -0.1 ? offestZ : -0.1;
        console.log(offestX);
        // this.cube1.transform.localPositionX += offestX;
        // this.cube1.transform.localPositionZ += offestZ;
        this.curMousePos = new Laya.Vector3(Laya.MouseManager.instance.mouseX, Laya.MouseManager.instance.mouseY);
        ;
    };
    return AssetController;
}());
exports.default = AssetController;
},{"./script/GameLogic/GameDefined":8,"./script/GameLogic/SceneController":11,"./script/Oimo/OimoHelper":13}],2:[function(require,module,exports){
"use strict";
/**This class is automatically generated by LayaAirIDE, please do not make any modifications. */
Object.defineProperty(exports, "__esModule", { value: true });
/*
* 游戏初始化配置;
*/
var GameConfig = /** @class */ (function () {
    function GameConfig() {
    }
    GameConfig.init = function () {
        var reg = Laya.ClassUtils.regClass;
    };
    GameConfig.width = 720;
    GameConfig.height = 1280;
    GameConfig.scaleMode = "fixedwidth";
    GameConfig.screenMode = "none";
    GameConfig.alignV = "middle";
    GameConfig.alignH = "center";
    GameConfig.startScene = "game_ui.scene";
    GameConfig.sceneRoot = "";
    GameConfig.debug = false;
    GameConfig.stat = false;
    GameConfig.physicsDebug = false;
    GameConfig.exportSceneToJson = true;
    return GameConfig;
}());
exports.default = GameConfig;
GameConfig.init();
},{}],3:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameConfig_1 = require("./GameConfig");
var AssetController_1 = require("./AssetController");
var Main = /** @class */ (function () {
    function Main() {
        //根据IDE设置初始化引擎		
        if (window["Laya3D"])
            Laya3D.init(GameConfig_1.default.width, GameConfig_1.default.height);
        else
            Laya.init(GameConfig_1.default.width, GameConfig_1.default.height, Laya["WebGL"]);
        Laya["Physics"] && Laya["Physics"].enable();
        Laya["DebugPanel"] && Laya["DebugPanel"].enable();
        Laya.stage.scaleMode = GameConfig_1.default.scaleMode;
        Laya.stage.screenMode = GameConfig_1.default.screenMode;
        //兼容微信不支持加载scene后缀场景
        Laya.URL.exportSceneToJson = GameConfig_1.default.exportSceneToJson;
        //打开调试面板（通过IDE设置调试模式，或者url地址增加debug=true参数，均可打开调试面板）
        if (GameConfig_1.default.debug || Laya.Utils.getQueryString("debug") == "true")
            Laya.enableDebugPanel();
        if (GameConfig_1.default.physicsDebug && Laya["PhysicsDebugDraw"])
            Laya["PhysicsDebugDraw"].enable();
        if (GameConfig_1.default.stat)
            Laya.Stat.show();
        Laya.alertGlobalError = true;
        //激活资源版本控制，version.json由IDE发布功能自动生成，如果没有也不影响后续流程
        Laya.ResourceVersion.enable("version.json", Laya.Handler.create(this, this.onVersionLoaded), Laya.ResourceVersion.FILENAME_VERSION);
    }
    Main.prototype.onVersionLoaded = function () {
        //激活大小图映射，加载小图的时候，如果发现小图在大图合集里面，则优先加载大图合集，而不是小图
        Laya.AtlasInfoManager.enable("fileconfig.json", Laya.Handler.create(this, this.onConfigLoaded));
    };
    Main.prototype.onConfigLoaded = function () {
        AssetController_1.default.Instance.GameStart();
    };
    return Main;
}());
//激活启动类
new Main();
},{"./AssetController":1,"./GameConfig":2}],4:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var OimoRigibody_1 = require("../Oimo/OimoRigibody");
var OimoBodyData_1 = require("../Oimo/OimoBodyData");
var PassivityBehaviour = /** @class */ (function (_super) {
    __extends(PassivityBehaviour, _super);
    function PassivityBehaviour() {
        var _this = _super.call(this) || this;
        _this.disZ = 35;
        _this.disY = -2;
        _this.speed = 500;
        _this.tempvev = new Laya.Vector3();
        _this.tragetZ = 0;
        _this.force = new Laya.Vector3();
        return _this;
    }
    PassivityBehaviour.prototype.init = function (data) {
        if (!data)
            data = new OimoBodyData_1.default();
        data.density = 1;
        data.move = true;
        _super.prototype.init.call(this, data);
    };
    // public setData(vec: Laya.Vector3) {
    //     this.velocity = vec;
    //     this.tragetZ = this.transform.position.z + this.disZ;
    //     let pos = this.transform.position;
    //     let forceVec3 = new OIMO.Vec3(vec.x, vec.y, vec.z * 300);
    //     let posVec3 = new OIMO.Vec3(pos.x, pos.y, pos.z);
    //     this.body.applyImpulse(posVec3, forceVec3);
    // }
    PassivityBehaviour.prototype.onAwake = function () {
    };
    PassivityBehaviour.prototype.onStart = function () {
    };
    PassivityBehaviour.prototype.onUpdate = function () {
        _super.prototype.onUpdate.call(this);
        _super.prototype.checkContact.call(this, 1111);
    };
    PassivityBehaviour.prototype.onDisable = function () {
        if (this.body && this.body.parent)
            this.body.dispose();
        this.body = null;
    };
    return PassivityBehaviour;
}(OimoRigibody_1.default));
exports.default = PassivityBehaviour;
},{"../Oimo/OimoBodyData":12,"../Oimo/OimoRigibody":14}],5:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var OimoRigibody_1 = require("../Oimo/OimoRigibody");
var OimoBodyData_1 = require("../Oimo/OimoBodyData");
var GameDefined_1 = require("../GameLogic/GameDefined");
var PlayerBehaviour = /** @class */ (function (_super) {
    __extends(PlayerBehaviour, _super);
    function PlayerBehaviour() {
        var _this = _super.call(this) || this;
        _this.bodyVc3 = new OIMO.Vec3(0, 0, 0);
        _this.bodyQut = new OIMO.Quat(0, 0, 0, 1);
        return _this;
    }
    PlayerBehaviour.prototype.init = function (data) {
        if (!data)
            data = new OimoBodyData_1.default();
        data.move = true;
        data.kinematic = true;
        data.name = GameDefined_1.default.playerbodyname;
        _super.prototype.init.call(this, data);
    };
    PlayerBehaviour.prototype.onAwake = function () {
    };
    PlayerBehaviour.prototype.onStart = function () {
    };
    PlayerBehaviour.prototype.onUpdate = function () {
        var transPos = this.transform.position;
        var transQut = this.transform.rotation;
        this.bodyVc3.set(transPos.x, transPos.y, transPos.z);
        this.bodyQut.set(transQut.x, transQut.y, transQut.z, transQut.w);
        this.body.setPosition(this.bodyVc3);
        this.body.setQuaternion(this.bodyQut);
    };
    PlayerBehaviour.prototype.checkContact = function (name) {
        return false;
    };
    PlayerBehaviour.prototype.onDisable = function () {
        if (this.body && this.body.parent)
            this.body.dispose();
        this.body = null;
    };
    Object.defineProperty(PlayerBehaviour.prototype, "name", {
        get: function () {
            if (this.body)
                return this.body.name;
            return -1;
        },
        enumerable: true,
        configurable: true
    });
    return PlayerBehaviour;
}(OimoRigibody_1.default));
exports.default = PlayerBehaviour;
},{"../GameLogic/GameDefined":8,"../Oimo/OimoBodyData":12,"../Oimo/OimoRigibody":14}],6:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var OimoRigibody_1 = require("../Oimo/OimoRigibody");
var OimoBodyData_1 = require("../Oimo/OimoBodyData");
var StandBehaviour = /** @class */ (function (_super) {
    __extends(StandBehaviour, _super);
    function StandBehaviour() {
        return _super.call(this) || this;
    }
    StandBehaviour.prototype.init = function (data) {
        if (!data)
            data = new OimoBodyData_1.default();
        //   this.sprite = this.owner as Laya.MeshSprite3D;
        data.name = 1000000000;
        data.move = false;
        //  data.type = DealPackaging.DealLayer(this.sprite.layer);
        _super.prototype.init.call(this, data);
    };
    StandBehaviour.prototype.onAwake = function () {
    };
    StandBehaviour.prototype.onUpdate = function () {
    };
    StandBehaviour.prototype.onStart = function () {
    };
    StandBehaviour.prototype.onDisable = function () {
        if (this.body && this.body.parent) {
            this.body.dispose();
            this.body.id = -1;
            this.body.name = -1;
        }
        this.body = null;
    };
    return StandBehaviour;
}(OimoRigibody_1.default));
exports.default = StandBehaviour;
},{"../Oimo/OimoBodyData":12,"../Oimo/OimoRigibody":14}],7:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameDefined_1 = require("./GameDefined");
var DealPackaging = /** @class */ (function () {
    function DealPackaging() {
    }
    DealPackaging.DealLayer = function (_layaer) {
        if (_layaer == GameDefined_1.BodyType.box) {
            return "box";
        }
        else if (_layaer == GameDefined_1.BodyType.sphere) {
            return "sphere";
        }
        else if (_layaer == GameDefined_1.BodyType.cylinder) {
            return "cylinder";
        }
        else {
            return "box";
        }
    };
    return DealPackaging;
}());
exports.DealPackaging = DealPackaging;
},{"./GameDefined":8}],8:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var GameDefined = /** @class */ (function () {
    function GameDefined() {
    }
    GameDefined.main_path = "res/LayaScene_main/Conventional/main.ls";
    GameDefined.playerbodyname = 1111;
    return GameDefined;
}());
exports.default = GameDefined;
var BodyType;
(function (BodyType) {
    BodyType[BodyType["sphere"] = 8] = "sphere";
    BodyType[BodyType["cylinder"] = 9] = "cylinder";
    BodyType[BodyType["box"] = 10] = "box";
})(BodyType = exports.BodyType || (exports.BodyType = {}));
},{}],9:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var PassivityBehaviour_1 = require("../Behaviour/PassivityBehaviour");
var ObsController = /** @class */ (function () {
    function ObsController() {
    }
    Object.defineProperty(ObsController, "Instance", {
        get: function () {
            return ObsController.instance || (ObsController.instance = new ObsController());
        },
        enumerable: true,
        configurable: true
    });
    ObsController.prototype.Init = function (obs) {
        if (obs && obs.length > 0) {
            for (var index = 0; index < obs.length; index++) {
                for (var j = 0; j < obs[index]._children.length; j++) {
                    var element = obs[index].getChildAt(j);
                    var _o = element.getChildAt(0);
                    var _pb = _o.addComponent(PassivityBehaviour_1.default);
                    _pb.init();
                }
            }
        }
    };
    return ObsController;
}());
exports.ObsController = ObsController;
},{"../Behaviour/PassivityBehaviour":4}],10:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var PlayerBehaviour_1 = require("../Behaviour/PlayerBehaviour");
var PlayerController = /** @class */ (function () {
    function PlayerController() {
    }
    Object.defineProperty(PlayerController, "Instance", {
        get: function () {
            return PlayerController.instance || (PlayerController.instance = new PlayerController());
        },
        enumerable: true,
        configurable: true
    });
    PlayerController.prototype.Init = function (_p) {
        if (_p) {
            this.player = _p;
            var _pb = this.player.getComponent(PlayerBehaviour_1.default);
            if (!_pb)
                _pb = this.player.addComponent(PlayerBehaviour_1.default);
            _pb.init();
        }
    };
    return PlayerController;
}());
exports.PlayerController = PlayerController;
},{"../Behaviour/PlayerBehaviour":5}],11:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var PlayerController_1 = require("./PlayerController");
var ObsController_1 = require("./ObsController");
var StandBehaviour_1 = require("../Behaviour/StandBehaviour");
var SceneController = /** @class */ (function () {
    function SceneController() {
    }
    Object.defineProperty(SceneController, "Instance", {
        get: function () {
            return SceneController.instance || (SceneController.instance = new SceneController());
        },
        enumerable: true,
        configurable: true
    });
    SceneController.prototype.Init = function (_s) {
        if (_s) {
            Laya.stage.addChild(_s);
        }
        else {
            console.error("场景不存在");
            return;
        }
        var road = _s.getChildByName("road");
        var obs = road.getChildByName("road")._children;
        this.floor = road.getChildByName("floor").getChildAt(0);
        var player = _s.getChildByName("player");
        this._camera = _s.getChildByName("Main Camera");
        PlayerController_1.PlayerController.Instance.Init(player);
        ObsController_1.ObsController.Instance.Init(obs);
        this.InitScene();
    };
    SceneController.prototype.InitScene = function () {
        if (this.floor) {
            var floor = this.floor.getComponent(StandBehaviour_1.default);
            if (!floor)
                floor = this.floor.addComponent(StandBehaviour_1.default);
            floor.init();
        }
    };
    return SceneController;
}());
exports.SceneController = SceneController;
},{"../Behaviour/StandBehaviour":6,"./ObsController":9,"./PlayerController":10}],12:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var OimoBodyData = /** @class */ (function () {
    function OimoBodyData() {
    }
    return OimoBodyData;
}());
exports.default = OimoBodyData;
},{}],13:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var OimoHelper = /** @class */ (function () {
    function OimoHelper() {
    }
    Object.defineProperty(OimoHelper, "Inst", {
        get: function () {
            if (this.instance == null) {
                this.instance = new OimoHelper();
            }
            return this.instance;
        },
        enumerable: true,
        configurable: true
    });
    OimoHelper.prototype.createWolrd = function () {
        this.world = new OIMO.World({
            timestep: 1 / 60,
            iterations: 8,
            broadphase: 2,
            worldscale: 1,
            random: true,
            info: false,
            gravity: [0, -100, 0]
        });
        this.world.play();
    };
    OimoHelper.prototype.createBody = function (data) {
        return this.world.add(data);
    };
    OimoHelper.prototype.clearWorld = function () {
        if (this.world) {
            this.world.clear();
        }
    };
    OimoHelper.prototype.playWorld = function () {
        if (this.world) {
            this.world.play();
        }
    };
    return OimoHelper;
}());
exports.default = OimoHelper;
},{}],14:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var OimoHelper_1 = require("./OimoHelper");
var DealPackaging_1 = require("../GameLogic/DealPackaging");
var OimoRigidBody = /** @class */ (function (_super) {
    __extends(OimoRigidBody, _super);
    function OimoRigidBody() {
        return _super.call(this) || this;
    }
    OimoRigidBody.prototype.init = function (data) {
        this.bodyData = data;
        this.sprite = this.owner;
        this.transform = this.sprite.transform;
        data.type = DealPackaging_1.DealPackaging.DealLayer(this.sprite.layer);
        this.initBodyData(data);
        if (this.body && this.body.parent)
            this.body.dispose();
        this.body = OimoHelper_1.default.Inst.createBody(data);
    };
    OimoRigidBody.prototype.onAwake = function () {
    };
    OimoRigidBody.prototype.onStart = function () {
    };
    OimoRigidBody.prototype.onUpdate = function () {
        var bodyPos = this.body.getPosition();
        var bodyQut = this.body.getQuaternion();
        var transPos = this.transform.position;
        var transQut = this.transform.rotation;
        transPos.x = bodyPos.x;
        transPos.y = bodyPos.y;
        transPos.z = bodyPos.z;
        this.transform.position = transPos;
        transQut.x = bodyQut.x;
        transQut.y = bodyQut.y;
        transQut.z = bodyQut.z;
        transQut.w = bodyQut.w;
        this.transform.rotation = transQut;
    };
    OimoRigidBody.prototype.checkContact = function (name) {
        if (this.body && this.body.contactLink) {
            var otherBody = this.body.contactLink.body;
            if (otherBody.name == name)
                return true;
        }
        return false;
    };
    OimoRigidBody.prototype.initBodyData = function (data) {
        data.type = data.type === undefined ? this.sprite.name : data.type;
        data.pos = this.getPos();
        data.rot = this.getRot();
        data.size = data.size === undefined ? this.getSize() : data.size;
        // if (data.type == "cube" || data.type == "barrier") data.type = "box";
        // else if (data.type == "capsule") data.type = "cylinder";
        // else if (data.type == "shell") data.type = "sphere";
        // else data.type = "box";
    };
    OimoRigidBody.prototype.getPos = function () {
        var position = this.transform.position;
        var pos = [position.x, position.y, position.z];
        return pos;
    };
    OimoRigidBody.prototype.getSize = function () {
        var w, h, d, size;
        var _scale = this.transform.scale;
        if (this.bodyData.type == "capsule" || this.bodyData.type == "cylinder") {
            var _scale = this.transform.scale;
            // w = this.transform.localScale.x;
            // h = this.transform.localScale.y * 2;
            // d = this.transform.localScale.z;
            w = _scale.x;
            h = _scale.y * 2;
            d = _scale.z;
            size = [w, h, d];
        }
        else if (this.bodyData.type == "sphere") {
            // w = this.transform.localScale.x;
            w = _scale.x;
            size = [w];
        }
        else if (this.bodyData.type == "barrier" || this.bodyData.type == "cube" || this.bodyData.type == "box") {
            // w = this.transform.localScale.x;
            // h = this.transform.localScale.y;//* 2;
            // d = this.transform.localScale.z;
            w = _scale.x;
            h = _scale.y;
            d = _scale.z;
            size = [w, h, d];
        }
        console.log(size);
        return size;
    };
    OimoRigidBody.prototype.getRot = function () {
        var euler = this.transform.rotationEuler;
        var rot = [euler.x, euler.y, euler.z];
        return rot;
    };
    OimoRigidBody.prototype.bodyName = function () {
        if (this.body)
            return this.body.name;
        return -1;
    };
    return OimoRigidBody;
}(Laya.Script3D));
exports.default = OimoRigidBody;
},{"../GameLogic/DealPackaging":7,"./OimoHelper":13}]},{},[3])
//# sourceMappingURL=data:application/json;charset=utf-8;base64,[encoded data, 48196 characters]
