123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- import Xverse from "./Xverse.js";
- import Codes from "./enum/Codes.js";
- // import './h264Decoder/index'
- const xverse = new Xverse({
- env: "DEV",
- appId: "10016",
- releaseId: "2203181838_1375a0",
- });
- const l = async () => {
- var R;
- try {
- await ((R = xverse.preload) == null
- ? void 0
- : R.start("full", (M, x) => {
- const I = `(${M}/${x})`;
- //s(I)
- }));
- } catch (M) {
- if ((console.error(M), M.code === Codes.PreloadCanceled)) {
- toast("\u9884\u52A0\u8F7D\u88AB\u53D6\u6D88");
- return;
- }
- toast("\u8FDB\u5165\u5931\u8D25, \u8BF7\u91CD\u8BD5");
- return;
- }
- nickname = Math.random().toString(16).slice(2)
- try {
- let room = await xverse.joinRoom({
- canvas: document.getElementById("canvas"),
- skinId: "10092",
- avatarId: "KGe_Boy",
- roomId: "e629ef3e-022d-4e64-8654-703bb96410eb",
- userId: nickname,
- wsServerUrl: "wss://uat-eks.xverse.cn/ws",
- appId: "10016",
- token: " ",
- nickname: nickname,
- firends: ["user1"],
- viewMode: "full",
- resolution: {
- width: 1728,
- height: 720,
- },
- pathName: "thirdwalk",
- objectFit: null,
- hasAvatar: !0,
- syncToOthers: !0,
- });
- window.room = room;
- readPointData()
- u();
- c();
- //e(!1);
- } catch (M) {
- console.error(M);
- alert(M);
- return;
- }
- };
- const u = () => {
- window.room.on("_coreClick", ({ point: f }) => {
- window.room._userAvatar.moveTo({
- point: f,
- });
- });
- };
- const c = () => {
- window.room.on("repeatLogin", function () {
- toast(
- "\u8BE5\u7528\u6237\u5DF2\u7ECF\u5728\u5176\u4ED6\u5730\u70B9\u767B\u5F55",
- {
- duration: 1e4,
- }
- );
- }),
- window.room.on("reconnecting", function ({ count: f }) {
- toast(`\u5C1D\u8BD5\u7B2C${f}\u6B21\u91CD\u8FDE`);
- }),
- window.room.on("reconnected", function () {
- toast("\u91CD\u8FDE\u6210\u529F");
- }),
- window.room.on("disconnected", function () {
- const f = toast(
- "\u8FDE\u63A5\u5931\u8D25\uFF0C\u624B\u52A8\u70B9\u51FB\u91CD\u8BD5",
- {
- duration: 1e5,
- onClick() {
- f.hideToast(), window.room.reconnect();
- },
- }
- );
- });
- };
- l();
- const BREATH_POINT_TYPE = "debugBreathPoint"
- , TAP_BREATH_POINT_TYPE = "debugTapBreathPoint"
- , DEFAULT_SEARCH_RANGE = 1e3;
- function xversePosition2Ue4(i){
- return {
- x: i.x * 100,
- y: -1 * i.z * 100,
- z: i.y * 100
- }
- }
- function readPointData() {
- return fetch("./assets/points.json", {
- headers: {
- 'content-type': 'application/json'
- },
- method: 'GET',
- })
- .then(response => response.json())
- .then(response => {
- response.forEach(data => {
- let ue4Pos = xversePosition2Ue4({x: -data.position.x, y: data.position.y, z: data.position.z})
- data.position0 = data.position
- data.position = new BABYLON.Vector3(ue4Pos.x, ue4Pos.y, ue4Pos.z)
- const a = JSON.stringify(data.position);
- window.room.breathPointManager.breathPoints.get(a) || window.room.breathPointManager.addBreathPoint({
- id: a,
- position: data.position,
- type: BREATH_POINT_TYPE,
- rotation: {
- pitch: 90,
- yaw: 0,
- roll: 0
- },
- forceLeaveGround: !0
- })
-
- })
- window.points = response
- })
- }
- // console.log("tinyh264", tinyh264);
- // debugger;
|