diff --git a/.github/workflows/gh-pages.yml b/.github/workflows/gh-pages.yml index 84d91cd6..c63cf7e8 100644 --- a/.github/workflows/gh-pages.yml +++ b/.github/workflows/gh-pages.yml @@ -24,6 +24,7 @@ jobs: run: | yarn build cp -rf CNAME ./public/ + cp -rf dist/obj ./public/ - name: Deploy uses: peaceiris/actions-gh-pages@v3 diff --git a/.gitignore b/.gitignore index ff78bd8d..35e1a768 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ .DS_Store node_modules -/dist *.lock # local env files .env.local diff --git a/dist/obj/ai.vrm b/dist/obj/ai.vrm new file mode 100644 index 00000000..fbfa6583 Binary files /dev/null and b/dist/obj/ai.vrm differ diff --git a/dist/obj/ai_mode_ai.vrm b/dist/obj/ai_mode_ai.vrm new file mode 100644 index 00000000..6df07a55 Binary files /dev/null and b/dist/obj/ai_mode_ai.vrm differ diff --git a/dist/obj/ai_mode_card.vrm b/dist/obj/ai_mode_card.vrm new file mode 100644 index 00000000..81c777ca Binary files /dev/null and b/dist/obj/ai_mode_card.vrm differ diff --git a/dist/obj/ai_mode_normal.vrm b/dist/obj/ai_mode_normal.vrm new file mode 100644 index 00000000..ab7c6167 Binary files /dev/null and b/dist/obj/ai_mode_normal.vrm differ diff --git a/dist/obj/ai_mode_sword.vrm b/dist/obj/ai_mode_sword.vrm new file mode 100644 index 00000000..48b4dc9f Binary files /dev/null and b/dist/obj/ai_mode_sword.vrm differ diff --git a/dist/obj/ai_mode_sword_hand.vrm b/dist/obj/ai_mode_sword_hand.vrm new file mode 100644 index 00000000..63c8cf00 Binary files /dev/null and b/dist/obj/ai_mode_sword_hand.vrm differ diff --git a/dist/obj/ai_mode_ten.vrm b/dist/obj/ai_mode_ten.vrm new file mode 100644 index 00000000..31b95031 Binary files /dev/null and b/dist/obj/ai_mode_ten.vrm differ diff --git a/dist/obj/ai_mode_zen_light.vrm b/dist/obj/ai_mode_zen_light.vrm new file mode 100644 index 00000000..b33bec9f Binary files /dev/null and b/dist/obj/ai_mode_zen_light.vrm differ diff --git a/package.json b/package.json index 3fb35b47..f7b2c2ef 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "@types/webpack-env": "latest", "axios": "^1.5.1", "dseg": "latest", + "http-proxy-middleware": "^2.0.6", "hyperscript": "latest", "i18next": "latest", "i18next-browser-languagedetector": "latest", diff --git a/src/index.html b/src/index.html index 1c79f300..f1268d5f 100644 --- a/src/index.html +++ b/src/index.html @@ -13,11 +13,13 @@
- +
+
+ +
diff --git a/src/main.css b/src/main.css index 8ccc3b32..3c287940 100644 --- a/src/main.css +++ b/src/main.css @@ -74,3 +74,12 @@ img[src^="blob:"] { button { padding: 10px 20px; } + +div#menu li { + list-style: none; +} + +div#menu { + padding: 20px; + background-color: #d9edff; +} diff --git a/src/main.ts b/src/main.ts index 0d3603d3..c3aeb45d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -111,44 +111,30 @@ if (targetY) workerService.trigger('setTargetY', Number(targetY)); const targetZ = searchParams.get('tz'); if (targetZ) workerService.trigger('setTargetZ', Number(targetZ)); +let url = new URL(window.location.href); +let params = url.searchParams; +if(params.get('id') != null){ + var api_url = "/api/users/" + params.get('id'); +} else { + var api_url = "/api/users/" + 2; +} let date = new Date(); var num_h = date.getHours(); -var model_url = "https://card.syui.ai/obj/ai.vrm"; -var model_url_default = "https://card.syui.ai/obj/ai.vrm"; -var model_url_light = "https://card.syui.ai/obj/ai_mode_zen_light.vrm"; -var model_url_ten = "https://card.syui.ai/obj/ai_mode_ten.vrm"; -var model_url_sword = "https://card.syui.ai/obj/ai_mode_sword.vrm"; -var model_url_sword_hand = "https://card.syui.ai/obj/ai_mode_sword_hand.vrm"; -var model_url_normal = "https://card.syui.ai/obj/ai_mode_normal.vrm"; -var model_url_ai = "https://card.syui.ai/obj/ai_mode_ai.vrm"; -var model_url_card = "https://card.syui.ai/obj/ai_mode_card.vrm"; -var anime_url = "https://card.syui.ai/obj/motion_v0.bvh"; -var item_url = "https://card.syui.ai/obj/ai_mode_sword.vrm"; +var test_url = "https://card.syui.ai/obj/" +var test_url = "./obj/" +var model_url = test_url + "ai.vrm"; +var model_url_default = test_url + "ai.vrm"; +var model_url_light = test_url + "ai_mode_zen_light.vrm"; +var model_url_ten = test_url + "ai_mode_ten.vrm"; +var model_url_sword = test_url + "ai_mode_sword.vrm"; +var model_url_sword_hand = test_url + "ai_mode_sword_hand.vrm"; +var model_url_normal = test_url + "ai_mode_normal.vrm"; +var model_url_ai = test_url + "ai_mode_ai.vrm"; +var model_url_card = test_url + "ai_mode_card.vrm"; +var anime_url = test_url + "motion_v0.bvh"; +var item_url = test_url + "ai_mode_sword.vrm"; let num_model = Math.floor(Math.random() * 12) + 1 -//if (card_time == num_h){ -// var model_url = model_url_card; -//} else if (num_model == 1) { -// var model_url = model_url_light; -//} else if (num_model == 2) { -// var model_url = model_url_normal; -//} else if (num_model == 3) { -// var model_url = model_url_ai; -//} else if (num_model == 4) { -// var model_url = model_url_sword; -//} else if (num_model == 5) { -// var model_url = model_url_sword_hand; -//} else if (num_model == 6) { -// var model_url = model_url_ten; -//} -//var model_url = model_url_ten; - -//if (num_model == 1){ -// var model_url = model_url_light; -//} else { -// var model_url = model_url_ai; -//} - import axios, {isCancel, AxiosError} from 'axios'; function model_load(){ axios.get(model_url, { @@ -192,8 +178,56 @@ function item_load(){ }) } +function status_load(){ + axios.get(api_url, { + responseType: "json" + }) + .then(res => { + let html_menu = document.querySelector('#menu') as HTMLInputElement | null; + let html_model = document.getElementById('btn-models') as HTMLInputElement | null + let html_model_a = document.getElementById('btn-models_a') as HTMLInputElement | null + let html_model_b = document.getElementById('btn-models_b') as HTMLInputElement | null + let html_model_c = document.getElementById('btn-models_c') as HTMLInputElement | null + let html_model_d = document.getElementById('btn-models_d') as HTMLInputElement | null + + if (res.data.model === true){ + model_load(); + } + + if (res.data.model === false && html_menu != null){ + html_menu.insertAdjacentHTML('afterbegin', "
  • model : " + res.data.model + "
  • "); + html_menu.insertAdjacentHTML('afterbegin', "
  • @" + res.data.username + "
  • "); + } + + if (res.data.model === true && html_menu != null){ + html_menu.insertAdjacentHTML('afterbegin', "
  • limit : Lv " + res.data.model_limit + "
  • "); + html_menu.insertAdjacentHTML('afterbegin', "
  • skill : Lv " + res.data.model_skill + "
  • "); + html_menu.insertAdjacentHTML('afterbegin', "
  • attack : Lv " + res.data.model_attach + "
  • "); + html_menu.insertAdjacentHTML('afterbegin', "
  • mode : Lv " + res.data.model_mode + "
  • "); + html_menu.insertAdjacentHTML('afterbegin', "
  • model : " + res.data.model + "
  • "); + html_menu.insertAdjacentHTML('afterbegin', "
  • @" + res.data.username + "
  • "); + } + + if (res.data.model_skill === 0 && html_model != null){ + html_model.style.display = "none"; + } + if (res.data.model_limit === 0 && html_model_a != null){ + html_model_a.style.display = "none"; + } + if (res.data.model_attach === 0 && html_model_b != null){ + html_model_b.style.display = "none"; + } + if (res.data.model_mode === 0 && html_model_c != null){ + html_model_c.style.display = "none"; + } + if (res.data.model === false && html_model_d != null){ + html_model_d.style.display = "none"; + } + }) +} + if (model_url !== null) { - model_load(); + status_load(); } function getModels(a?:string){ @@ -203,8 +237,7 @@ function getModels(a?:string){ var model_url = model_url_ten; } else if (a == "sword"){ var model_url = model_url_sword_hand; - -} else if (a == "sword_out"){ + } else if (a == "sword_out"){ var model_url = model_url_sword; } else if (a == "ai"){ var model_url = model_url_light; @@ -226,6 +259,18 @@ function getModels(a?:string){ }) } + +function getMenus() { + var x = document.querySelector('#menu') as HTMLInputElement | null; + if (x != null) { + if (x.style.display === "none") { + x.style.display = "block"; + } else { + x.style.display = "none"; + } + } +} + const el = document.querySelector('#btn-models') as HTMLInputElement | null; if(el != null) { el.addEventListener('click', (e:Event) => getModels(el.value)); @@ -253,4 +298,9 @@ if(eld != null) { eld.addEventListener('click', (e:Event) => getModels(eld.value)); } +const el_menu = document.querySelector('#btn-menu') as HTMLInputElement | null; +if(el_menu != null) { + el_menu.addEventListener('click', (e:Event) => getMenus()); +} + if (loadingPromises.length) triggerLoading(); diff --git a/src/setupProxy.js b/src/setupProxy.js new file mode 100644 index 00000000..744c405d --- /dev/null +++ b/src/setupProxy.js @@ -0,0 +1,5 @@ +const { createProxyMiddleware } = require('http-proxy-middleware'); + +module.exports = function(app) { + app.use(createProxyMiddleware('https://api.syui.ai', {target: 'http://localhost:8080'})); +}; diff --git a/src/worker/scene/floor.ts b/src/worker/scene/floor.ts index fdaf8b91..04db9571 100644 --- a/src/worker/scene/floor.ts +++ b/src/worker/scene/floor.ts @@ -11,9 +11,9 @@ floor.position.y = -0.5; floor.rotation.x = -Math.PI / 2; scene.add(floor); -const grid = new GridHelper(0, 0, 0xfff700, 0xfff700); +//const grid = new GridHelper(0, 0, 0xfff700, 0xfff700); //const grid = new GridHelper(50, 100, 0xfff700, 0xfff700); -//const grid = new GridHelper(50, 100, 0xAAAAAA, 0xAAAAAA); +const grid = new GridHelper(50, 100, 0xAAAAAA, 0xAAAAAA); scene.add(grid); export function setCenter({ x, z }: Vector3) { diff --git a/webpack.dev.js b/webpack.dev.js index 81a896a7..67480d22 100644 --- a/webpack.dev.js +++ b/webpack.dev.js @@ -12,9 +12,18 @@ module.exports = merge(common, { contentBase: path.join(__dirname, 'dist'), compress: true, port: 8080, - }, - - module: { + proxy: { + '/api/users/': { + target: 'https://api.syui.ai/users/', + secure: false, + changeOrigin: true, + pathRewrite: { + '^/api/users' : '' + } + } + } + }, + module: { rules: [{ enforce: 'pre', test: /\.js$/, diff --git a/yarn.lock b/yarn.lock index d8248786..2267bb3f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -136,6 +136,13 @@ resolved "https://registry.yarnpkg.com/@types/html-minifier-terser/-/html-minifier-terser-5.1.1.tgz#3c9ee980f1a10d6021ae6632ca3e79ca2ec4fb50" integrity sha512-giAlZwstKbmvMk1OO7WXSj4OZ0keXAcl2TQq4LWHiiPH2ByaH7WeUzng+Qej8UPxxv+8lRTuouo0iaNDBuzIBA== +"@types/http-proxy@^1.17.8": + version "1.17.13" + resolved "https://registry.yarnpkg.com/@types/http-proxy/-/http-proxy-1.17.13.tgz#dd3a4da550580eb0557d4c7128a2ff1d1a38d465" + integrity sha512-GkhdWcMNiR5QSQRYnJ+/oXzu0+7JJEPC8vkWXK351BkhjraZF+1W13CUYARUvX9+NqIU2n6YHA4iwywsc/M6Sw== + dependencies: + "@types/node" "*" + "@types/hyperscript@latest": version "0.0.4" resolved "https://registry.yarnpkg.com/@types/hyperscript/-/hyperscript-0.0.4.tgz#209df6d6f304a8515c8fadb395fe40446d64655a" @@ -2474,7 +2481,18 @@ http-proxy-middleware@0.19.1: lodash "^4.17.11" micromatch "^3.1.10" -http-proxy@^1.17.0: +http-proxy-middleware@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.6.tgz#e1a4dd6979572c7ab5a4e4b55095d1f32a74963f" + integrity sha512-ya/UeJ6HVBYxrgYotAZo1KvPWlgB48kUJLDePFeneHsVujFaW5WNj2NgWCAE//B1Dl02BIfYlpNgBy8Kf8Rjmw== + dependencies: + "@types/http-proxy" "^1.17.8" + http-proxy "^1.18.1" + is-glob "^4.0.1" + is-plain-obj "^3.0.0" + micromatch "^4.0.2" + +http-proxy@^1.17.0, http-proxy@^1.18.1: version "1.18.1" resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549" integrity sha512-7mz/721AbnJwIVbnaSv1Cz3Am0ZLT/UBwkC92VlxhXv/k/BBQfM2fXElQNC27BVGr0uwUpplYPQM9LnaBMR5NQ== @@ -2869,6 +2887,11 @@ is-path-inside@^2.1.0: dependencies: path-is-inside "^1.0.2" +is-plain-obj@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-3.0.0.tgz#af6f2ea14ac5a646183a5bbdb5baabbc156ad9d7" + integrity sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA== + is-plain-object@^2.0.3, is-plain-object@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677"