Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
syui committed Nov 3, 2023
1 parent 529646a commit 023d57c
Show file tree
Hide file tree
Showing 18 changed files with 145 additions and 46 deletions.
1 change: 1 addition & 0 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
.DS_Store
node_modules
/dist
*.lock
# local env files
.env.local
Expand Down
Binary file added dist/obj/ai.vrm
Binary file not shown.
Binary file added dist/obj/ai_mode_ai.vrm
Binary file not shown.
Binary file added dist/obj/ai_mode_card.vrm
Binary file not shown.
Binary file added dist/obj/ai_mode_normal.vrm
Binary file not shown.
Binary file added dist/obj/ai_mode_sword.vrm
Binary file not shown.
Binary file added dist/obj/ai_mode_sword_hand.vrm
Binary file not shown.
Binary file added dist/obj/ai_mode_ten.vrm
Binary file not shown.
Binary file added dist/obj/ai_mode_zen_light.vrm
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
<div class="ts dimmer" id="loading">
<div class="ts big loader"></div>
</div>
<div class="menu">
</div>
<div id="menu" style="display:none"></div>
<div class="cell">
<div class="ts-content">
<div class="ts-app-navbar is-unlabeled is-fluid">
<div class="button_menu">
<button id='btn-menu' value="card" ></button>
</div>
<button id='btn-models_d' value="normal" >ノーマル</button>
<button id='btn-models_c' value="ai" >モード</button>
<button id='btn-models_b' value="sword" >アタック</button>
Expand Down
9 changes: 9 additions & 0 deletions src/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,12 @@ img[src^="blob:"] {
button {
padding: 10px 20px;
}

div#menu li {
list-style: none;
}

div#menu {
padding: 20px;
background-color: #d9edff;
}
124 changes: 87 additions & 37 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down Expand Up @@ -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', "<li>model : " + res.data.model + "</li>");
html_menu.insertAdjacentHTML('afterbegin', "<li>@" + res.data.username + "</li>");
}

if (res.data.model === true && html_menu != null){
html_menu.insertAdjacentHTML('afterbegin', "<li>limit : Lv " + res.data.model_limit + "</li>");
html_menu.insertAdjacentHTML('afterbegin', "<li>skill : Lv " + res.data.model_skill + "</li>");
html_menu.insertAdjacentHTML('afterbegin', "<li>attack : Lv " + res.data.model_attach + "</li>");
html_menu.insertAdjacentHTML('afterbegin', "<li>mode : Lv " + res.data.model_mode + "</li>");
html_menu.insertAdjacentHTML('afterbegin', "<li>model : " + res.data.model + "</li>");
html_menu.insertAdjacentHTML('afterbegin', "<li>@" + res.data.username + "</li>");
}

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){
Expand All @@ -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;
Expand All @@ -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));
Expand Down Expand Up @@ -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();
5 changes: 5 additions & 0 deletions src/setupProxy.js
Original file line number Diff line number Diff line change
@@ -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'}));
};
4 changes: 2 additions & 2 deletions src/worker/scene/floor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
15 changes: 12 additions & 3 deletions webpack.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -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$/,
Expand Down
25 changes: 24 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -2474,7 +2481,18 @@ [email protected]:
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==
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 023d57c

Please sign in to comment.