├── .editorconfig ├── .env.example ├── .eslintrc.json ├── .gitignore ├── .husky └── pre-commit ├── LICENSE ├── README.md ├── components ├── Header.tsx ├── ModelList.tsx ├── UserIcon.tsx └── progressBar.tsx ├── lib ├── normalizeCharacterModel.ts ├── useVRM.ts └── vroid-hub-api.ts ├── next.config.js ├── package.json ├── pages ├── _app.tsx ├── _document.tsx ├── api │ ├── auth │ │ └── [...nextauth].ts │ └── vroid │ │ ├── models │ │ ├── account.ts │ │ ├── hearts.ts │ │ └── staff_picks.ts │ │ └── vrm.ts ├── index.tsx └── vrm.tsx ├── public ├── favicon.ico ├── human.vrm ├── idle_loop.vrma ├── next.svg └── vercel.svg ├── src ├── env.d.ts └── globals.css ├── tsconfig.json ├── types ├── Response │ ├── index.ts │ └── models │ │ ├── AgeLimitSerializer.ts │ │ ├── AttachedItemCoinSerializer.ts │ │ ├── AttachedItemSerializer.ts │ │ ├── CharacterModelBoothItemSerializer.ts │ │ ├── CharacterModelCollectionResponse.ts │ │ ├── CharacterModelLicenseSerializer.ts │ │ ├── CharacterModelSerializer.ts │ │ ├── CharacterModelVersionSerializer.ts │ │ ├── CharacterSerializer.ts │ │ ├── ErrorField.ts │ │ ├── FullBodyImageSerializer.ts │ │ ├── HeartCollectionResponse.ts │ │ ├── HeartSerializer.ts │ │ ├── ImageSerializer.ts │ │ ├── LinkField.ts │ │ ├── LinksField.ts │ │ ├── ModelBasisConversionStateSerializer.ts │ │ ├── PortraitImageSerializer.ts │ │ ├── ResponseSerializer.ts │ │ ├── TagSerializer.ts │ │ ├── UserIconSerializer.ts │ │ ├── UserSerializer.ts │ │ └── VendorSpecifiedLicenseSerializer.ts ├── next-auth.d.ts └── vroid.ts └── yarn.lock /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | indent_style = space 3 | indent_size = 2 4 | 5 | [*.{ts,tsx,yml}] 6 | end_of_line = lf 7 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | CLIENT_ID=hogehoge123456789 2 | CLIENT_SECRET=hogehogesecret 3 | NEXT_PUBLIC_NEXTAUTH_SECRET=hogehoge 4 | NEXTAUTH_URL=https://example.com 5 | NEXT_PUBLIC_VROID_HUB_URL=https://hub.vroid.com -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | # local env files 28 | .env*.local 29 | .env 30 | 31 | # vercel 32 | .vercel 33 | 34 | # typescript 35 | *.tsbuildinfo 36 | next-env.d.ts 37 | -------------------------------------------------------------------------------- /.husky/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | . "$(dirname -- "$0")/_/husky.sh" 3 | 4 | yarn lint-staged 5 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2023 pixiv Inc. 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VRoid Hub API Example 2 | 3 | ## 目次 4 | 5 | - [概要](#概要) 6 | - [デモ](#デモ) 7 | - [推奨動作環境](#license) 8 | - [セットアップと実行](#セットアップと実行) 9 | - [開発者登録](#開発者登録) 10 | - [アプリケーション作成](#アプリケーション作成) 11 | - [VRoid Hub APIについて](#vroid-hub-apiについて) 12 | - [LICENSE](#license) 13 | 14 | ## 概要 15 | 16 | このExampleでは[VRoid Hub API](https://developer.vroid.com/api)を利用して、 17 | 18 | - VRoid HubとのOAuth2.0連携([NextAuth.js](https://github.com/nextauthjs/next-auth)を利用) 19 | - キャラクターモデル一覧の取得 20 | - キャラクターモデルに紐づいたアバターファイル(.vrmファイル)の読み込み 21 | - アバターモデルの表示([@pixiv/three-vrm](https://github.com/pixiv/three-vrm)を利用) 22 | 23 | を行うことができます。 24 | 25 | ## デモ 26 | 27 | mainブランチの最新のコードで動作しているデモを公開しています。 28 | 29 | ## 推奨動作環境 30 | 31 | - Node.js: v18.16.0 32 | - yarn: 1.22.19 33 | - 推奨ブラウザ: Chrome 34 | 35 | ## セットアップと実行 36 | 37 | ### 開発者登録 38 | 39 | 1. VRoid Hubの[開発者登録ページ](https://hub.vroid.com/developer/registration)にアクセスします。 40 | 2. VRoid Hubにログインした上で、必要事項を入力し、開発者登録を行ってください。 41 | 3. VRoid HubとOAuth連携するアプリケーションの情報をVRoid Hubに登録します。次項に進んでください。 42 | 43 | ### アプリケーション作成 44 | 45 | 1. VRoid Hubの[連携アプリケーション管理ページ](https://hub.vroid.com/oauth/applications)にアクセスします。
※連携アプリケーション管理ページの言語設定はVRoid Hubの言語設定に依存します。 46 | 2. 「新しいアプリケーション」ボタンを押下し、アプリケーション作成画面に遷移します。 47 | 3. 必要事項を入力し、「登録」ボタンを押下するとアプリケーションが作成されます。
※ローカルでこのリポジトリを動かす場合は、スコープに `default` 、リダイレクトURIに `http://localhost:3000/api/auth/callback/vroid` を設定してください。 48 | 4. 作成されたアプリケーションは[連携アプリケーション管理ページ](https://hub.vroid.com/oauth/applications)に一覧表示されます。 49 | 5. 作成したアプリケーションのページに遷移すると、アプリケーションID(ClientID)とシークレット(ClientSecret)が確認できます。これらの認証情報が記述されたJSONファイルを「Credentialファイル作成」よりダウンロードすることができます。重要な情報なので安全に保管してください。 50 | 51 | ### リポジトリのセットアップ 52 | 53 | 1. このリポジトリをクローンするかダウンロードしてください。 54 | 55 | ``` 56 | git clone git@github.com:pixiv/VRoidHub-API-Example.git 57 | ``` 58 | 59 | 2. `.env` ファイルに下記の環境変数を設定してください 60 | 61 | ``` 62 | CLIENT_ID= アプリケーションページから閲覧できるアプリケーションIDの値を入力してください 63 | CLIENT_SECRET= アプリケーションページから閲覧できるシークレットの値を入力してください 64 | NEXT_PUBLIC_NEXTAUTH_SECRET= openssl rand -base64 32 コマンドで生成したシークレット値を入力してください 65 | NEXTAUTH_URL= ExampleをホストしているURLのroot URLを入力してください 66 | NEXT_PUBLIC_VROID_HUB_URL= https://hub.vroid.com と入力してください 67 | ``` 68 | 69 | 3. 必要なパッケージをインストールしてください。 70 | 71 | ``` 72 | yarn install 73 | ``` 74 | 75 | 4. パッケージのインストール完了後、下記コマンドで開発用webサーバーが起動します 76 | 77 | ``` 78 | yarn dev 79 | ``` 80 | 81 | 5. 実行後、以下のURLにアクセスして動作を確認してください 82 | http://localhost:3000 83 | 84 | --- 85 | 86 | ## VRoid Hub APIについて 87 | 88 | VRoid Hubでは外部アプリケーションがVRoid Hubにあるアバターファイルを利用するためのAPIを公開しています。 89 | 90 | APIの利用にはVRoid Hubでの[開発者登録](#開発者登録)と[アプリケーションの作成](#アプリケーション作成)、OAuth2.0による認可が必要です。 91 | 92 | VRoid Hub APIを利用すると、VRoid Hubに登録されたキャラクターを自分のアプリケーションで利用できるようになります。 93 | 94 | ## LICENSE 95 | 96 | Apache2.0ライセンスに準拠しています。詳細は[LICENSE](https://github.com/pixiv/VRoidHub-API-Example/blob/master/LICENSE)を参照してください。 97 | -------------------------------------------------------------------------------- /components/Header.tsx: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components'; 2 | import { Icon } from './UserIcon'; 3 | 4 | type Props = { 5 | icon_img_url: string; 6 | username: string; 7 | }; 8 | 9 | export function IndexPageHeader(props: Props) { 10 | return ( 11 | 12 | キャラクターを選択 13 | 14 | 15 | ); 16 | } 17 | 18 | const HeaderContainer = styled.div` 19 | margin: 0px; 20 | display: flex; 21 | justify-content: center; 22 | `; 23 | 24 | const HeaderTitle = styled.h2` 25 | font-size: ${(props) => props.theme.typography.size[20].fontSize}px; 26 | font-family: 'Noto Sans JP', sans-serif; 27 | font-weight: 700; 28 | `; 29 | -------------------------------------------------------------------------------- /components/ModelList.tsx: -------------------------------------------------------------------------------- 1 | import { useCallback, useState } from 'react'; 2 | import { useRouter } from 'next/router'; 3 | import { 4 | Modal, 5 | ModalHeader, 6 | ModalBody, 7 | Button, 8 | Checkbox, 9 | ModalAlign, 10 | ModalButtons, 11 | LoadingSpinner, 12 | } from '@charcoal-ui/react'; 13 | import styled from 'styled-components'; 14 | import type { ModelData } from '../types/vroid'; 15 | 16 | type Props = { 17 | items: ModelData[]; 18 | title: string; 19 | message: string; 20 | loading: boolean; 21 | hasNext: boolean; 22 | onRequestLoadNext: () => void; 23 | }; 24 | 25 | /** キャラクター一覧コンポーネント */ 26 | export function ModelList({ items, title, message, loading, hasNext, onRequestLoadNext }: Props) { 27 | const showMore = useCallback(() => { 28 | onRequestLoadNext(); 29 | }, [onRequestLoadNext]); 30 | 31 | return ( 32 |
33 | 34 | {title} 35 | {message} 36 | 37 | {items.length === 0 && loading ? ( 38 |
39 | 40 |
41 | ) : ( 42 | 43 | {items.map((model: ModelData) => { 44 | return ; 45 | })} 46 | 47 | )} 48 | 49 | {hasNext ? ( 50 | 51 |
52 | 55 |
56 |
57 | ) : ( 58 | <> 59 | )} 60 |
61 |
62 | ); 63 | } 64 | 65 | const EachModel = ({ model }: { model: ModelData }) => { 66 | const [isOpen, setIsOpen] = useState(false); 67 | const [isMoralAgreed, setIsMoralAgreed] = useState(false); 68 | const router = useRouter(); 69 | 70 | const handleClick = useCallback(() => { 71 | setIsOpen((prev) => !prev); 72 | }, [setIsOpen]); 73 | 74 | const handleClickUseModel = useCallback( 75 | () => router.push(`/vrm?id=${model.id}&size=${model.originalFileSize}`), 76 | [router, model.id, model.originalFileSize], 77 | ); 78 | 79 | const handleClickMoralAgreed = useCallback((value: boolean) => setIsMoralAgreed(() => value), [setIsMoralAgreed]); 80 | 81 | const makeDateString = (isoStr: string) => { 82 | // 時間が0-9分の時の対応。例えば、「15:9」ではなく「15:09」と表示するため。 83 | const makeMinutesSafe = (min: number) => { 84 | if (0 <= min && min <= 9) { 85 | return `0${min}`; 86 | } 87 | return min; 88 | }; 89 | 90 | const date = new Date(isoStr); 91 | return `${date.getFullYear()}年${date.getMonth()}月${date.getDate()}日 ${date.getHours()}:${makeMinutesSafe( 92 | date.getMinutes(), 93 | )}`; 94 | }; 95 | 96 | return ( 97 | <> 98 | 99 | 100 | 101 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 |
118 | 119 | {model.characterName} 120 | {model.modelName ? ` / ${model.modelName}` : ''} 121 | 122 | 123 | 124 | {model.user.name} 125 | {makeDateString(model.createdAt)} 126 | 127 |
128 |
129 | 130 | {/* モーダルの利用条件部分 */} 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 142 | 146 | 147 | 148 | 149 | 150 | 151 | {/* モーダルフッター部分 */} 152 | 153 | 154 | 155 | 利用条件にしたがってモデルデータを利用する 156 | 157 | 158 | 159 | 162 | 163 | 164 |
165 |
166 | 167 | ); 168 | }; 169 | 170 | // 一番外側のやつ。 171 | const ModelBoxContiner = styled.div` 172 | container-type: inline-size; 173 | max-width: 1224px; 174 | width: 100%; 175 | `; 176 | 177 | // 「あなたのキャラクター」「❤︎したキャラクター」とか 178 | const ModelBoxTitle = styled.h3` 179 | font-weight: 700; 180 | margin: 0px; 181 | padding-bottom: 8px; 182 | font-size: ${(props) => props.theme.typography.size[20].fontSize}px; 183 | display: block; 184 | `; 185 | 186 | // 上の「あなたのキャラクター」などの下に出てくる説明文 187 | const ExplainMessage = styled.h5` 188 | display: block; 189 | font-weight: 400; 190 | font-size: ${(props) => props.theme.typography.size[16].fontSize}px; 191 | margin: 0px; 192 | margin-bottom: 8px; 193 | `; 194 | 195 | // grid. この中でmapしてる 196 | const ModelsGrid = styled.div` 197 | gap: 16px; 198 | display: grid; 199 | @container (min-width: 700px) { 200 | grid-template-columns: repeat(6, minmax(100px, 1fr)); 201 | } 202 | @container (max-width: 699px) { 203 | grid-template-columns: repeat(3, minmax(100px, 1fr)); 204 | } 205 | `; 206 | 207 | // 「もっと見る」ボタンの入れ物 208 | const ShowMoreButtonWrapper = styled.div` 209 | margin: 0px; 210 | margin-top: ${(props) => props.theme.spacing[24]}px; 211 | display: flex; 212 | justify-content: center; 213 | `; 214 | 215 | // 「もっと見る」ボタンの中身テキスト 216 | const ShowMoreButtonText = styled.p` 217 | font-size: ${(props) => props.theme.typography.size[14].fontSize}px; 218 | margin: 0px; 219 | `; 220 | 221 | // モデル一覧表示の画像。下のListCharacterImgを囲む。 222 | const ListModelImgContaier = styled.div` 223 | position: relative; 224 | margin: 0px; 225 | padding: 0px; 226 | width: 100%; 227 | height: 100%; 228 | // この辺はhover/clickした時のオーバーレイ 229 | &:hover { 230 | &:before { 231 | content: ''; 232 | position: absolute; 233 | width: 100%; 234 | height: 100%; 235 | background: ${(props) => props.theme.color.surface7}; 236 | pointer-events: none; 237 | } 238 | } 239 | &:active { 240 | &:before { 241 | pointer-events: none; 242 | content: ''; 243 | position: absolute; 244 | width: 100%; 245 | height: 100; 246 | background: ${(props) => props.theme.color.surface3}; 247 | } 248 | } 249 | `; 250 | 251 | const ListModelImg = styled.img` 252 | border-radius: 2px; 253 | width: 100%; 254 | height: 100%; 255 | object-fit: cover; 256 | `; 257 | 258 | // -------------以下モーダル用------------------ 259 | 260 | // モーダルの上半分。写真と名前 261 | const ModalUpper = styled.div` 262 | padding: ${(props) => props.theme.spacing[16]}px; 263 | `; 264 | 265 | // モーダルに表示される写真 266 | const ModalImage = styled.img` 267 | width: 100%; 268 | display: inline-block; 269 | border-radius: 10px; 270 | `; 271 | 272 | // ModalImageを囲む。立ち絵が「胸から上」と「全身」で2つあって、そのコンテナ。 273 | const ModalImageContainer = styled.div` 274 | margin-bottom: ${(props) => props.theme.spacing[16]}px; 275 | display: grid; 276 | grid-template-columns: repeat(2, 1fr); 277 | gap: 8px; 278 | `; 279 | 280 | // Modalで表示する、モデル作成者のusername 281 | const UserName = styled.h5` 282 | color: rbg(200, 200, 200); 283 | display: inline-block; 284 | margin: 0px; 285 | font-weight: 400; 286 | `; 287 | 288 | // Modalで表示する、モデル作成者のアイコン 289 | const UserIcon = styled.img` 290 | border-radius: 50%; 291 | display: inline-block; 292 | width: 20px; 293 | vertical-align: middle; 294 | margin-right: ${(props) => props.theme.spacing[8]}px; 295 | `; 296 | 297 | // Modalで表示する、作成者データの入れ物 298 | const AuthorData = styled.div``; 299 | 300 | // キャラクター名・モデル名の入れ物 301 | const ChracterModelNameContainer = styled.div` 302 | margin-bottom: 4px; 303 | `; 304 | 305 | // Modalで表示する、キャラクターの名前 306 | const CharacterName = styled.h2` 307 | margin: 0px; 308 | font-weight: 700; 309 | display: inline; 310 | `; 311 | 312 | // Modalで表示する、モデル名 313 | const ModelName = styled.h2` 314 | margin: 0px; 315 | font-weight: 700; 316 | color: #858585; 317 | display: inline; 318 | `; 319 | 320 | const ModalFooter = styled.div` 321 | margin: 0px; 322 | padding: 0px; 323 | margin-top: 16px; 324 | `; 325 | 326 | // Modalで表示する、created_at 327 | const CreatedAt = styled.h6` 328 | color: gray; 329 | display: inline-block; 330 | margin: 0px; 331 | margin-left: ${(props) => props.theme.spacing[8]}px; 332 | font-weight: 400; 333 | `; 334 | 335 | const LicenseRowContainer = styled.div` 336 | margin: 0px; 337 | margin: ${(props) => props.theme.spacing[8]}px; 338 | font-size: ${(props) => props.theme.typography.size[14].fontSize}px; 339 | line-height: ${(props) => props.theme.typography.size[14].lineHeight}px; 340 | `; 341 | 342 | // モーダルの利用規約確認。項目の方。色毎に分かれてるだけ。 343 | const LicenseTitleGrey = styled.p` 344 | color: ${(props) => props.theme.color.surface4}; 345 | display: inline; 346 | font-weight: 400; 347 | `; 348 | const LicenseTitleBlack = styled.p` 349 | color: ${(props) => props.theme.color.text2}; 350 | display: inline; 351 | font-weight: 400; 352 | `; 353 | 354 | // モーダルの利用規約確認。「OK」「NG」の方。色毎に分かれてるだけ。 355 | const LicenseItemGreen = styled.h4` 356 | color: ${(props) => props.theme.color.success}; 357 | display: inline; 358 | font-weight: 700; 359 | `; 360 | const LicenseItemGrey = styled.h4` 361 | color: ${(props) => props.theme.color.surface4}; 362 | display: inline; 363 | font-weight: 700; 364 | `; 365 | const LicenseItemBlack = styled.h4` 366 | color: ${(props) => props.theme.color.text2}; 367 | display: inline; 368 | font-weight: 700; 369 | `; 370 | 371 | // モーダルのライセンスの入れ物 372 | const LicenseContainer = styled.div` 373 | border-top: solid thin ${(props) => props.theme.color.surface10}; 374 | border-bottom: solid thin ${(props) => props.theme.color.surface10}; 375 | padding: ${(props) => props.theme.spacing[16]}px; 376 | `; 377 | 378 | // ライセンスの表示ロジック切り出し 379 | // title:value の形で表示。 380 | // これの色が 黒:黒をinfo, 黒:緑をok, 灰色:灰色をng, としてstyleを受け取る 381 | const LicenseRow = ({ style, title, value }: { style: 'info' | 'ok' | 'ng'; title: string; value?: string }) => { 382 | if (value == null) value = style == 'ok' ? 'OK' : 'NG'; 383 | 384 | switch (style) { 385 | case 'info': 386 | return ( 387 | 388 | {title} : {value} 389 | 390 | ); 391 | case 'ok': 392 | return ( 393 | 394 | {title} : {value} 395 | 396 | ); 397 | case 'ng': 398 | return ( 399 | 400 | {title} : {value} 401 | 402 | ); 403 | } 404 | }; 405 | -------------------------------------------------------------------------------- /components/UserIcon.tsx: -------------------------------------------------------------------------------- 1 | import { useCallback, useState } from 'react'; 2 | import { useRouter } from 'next/router'; 3 | import { signOut } from 'next-auth/client'; 4 | import styled from 'styled-components'; 5 | 6 | type IconProps = { 7 | icon_img_url: string; 8 | username: string; 9 | }; 10 | 11 | export function Icon({ icon_img_url, username }: IconProps) { 12 | const [isOpen, setIsOpen] = useState(false); 13 | const router = useRouter(); 14 | 15 | const handleClick = useCallback(() => { 16 | setIsOpen((prev) => !prev); 17 | }, []); 18 | 19 | const handleClickVroidHubItem = useCallback(() => { 20 | router.push(`${process.env.NEXT_PUBLIC_VROID_HUB_URL}`); 21 | }, [router]); 22 | 23 | const handleClickLogout = useCallback(() => signOut(), []); 24 | 25 | return ( 26 | 27 | 28 | {isOpen ? ( 29 | 30 | 31 | 32 | {username} 33 | 34 | 35 | VRoid Hub 36 | 37 | 38 | ログアウト 39 | 40 | 41 | ) : ( 42 | <> 43 | )} 44 | 45 | ); 46 | } 47 | 48 | // 一番外側のやつ 49 | const IconContainer = styled.div` 50 | display: inline-block; 51 | margin-left: auto; 52 | position: absolute; 53 | right: 0px; 54 | top: 10px; 55 | `; 56 | 57 | // これが右上に出てるアイコン 58 | const IconImg = styled.img` 59 | border-radius: 50%; 60 | width: 32px; 61 | display: inline-block; 62 | vertical-align: bottom; 63 | `; 64 | 65 | // アイコンをクリックして出てくるメニュー全体 66 | const IconModal = styled.div` 67 | position: absolute; 68 | right: 0; 69 | top: 100%; 70 | padding: 8px 0; 71 | width: 250px; 72 | border-radius: 8px; 73 | background-color: white; 74 | border: solid 1px rgb(200, 200, 200); 75 | z-index: 1; 76 | `; 77 | 78 | // メニューのヘッダー。ユーザー名とアイコンが入る 79 | const IconModalHeader = styled.div` 80 | display: flex; 81 | align-items: center; 82 | padding: 8px 16px; 83 | `; 84 | 85 | // メニューの各項目。行。 86 | const IconModalItem = styled.div` 87 | padding: 16px; 88 | padding-top: 6px; 89 | padding-bottom: 6px; 90 | &:hover { 91 | background-color: rgb(220, 220, 220); 92 | } 93 | `; 94 | 95 | // クリックして出てくるメニュー内のアイコン 96 | const IconModalImg = styled.img` 97 | border-radius: 50%; 98 | width: 32px; 99 | height: 32px; 100 | display: inline-block; 101 | margin-right: 10px; 102 | vertical-align: middle; 103 | `; 104 | 105 | // メニュー内のテキスト。「VRoidHub」・「ログアウト」・「終了」 106 | const ModalText = styled.h4` 107 | display: inline-block; 108 | margin: 0px; 109 | font-size: ${(props) => props.theme.typography.size[12].fontSize}px; 110 | font-weight: 400; 111 | `; 112 | 113 | // メニューで、アイコンの横のユーザー名 114 | const IconUserName = styled.h4` 115 | margin: 0; 116 | display: inline-block; 117 | font-size: ${(props) => props.theme.typography.size[12].fontSize}px; 118 | font-weight: 700; 119 | `; 120 | -------------------------------------------------------------------------------- /components/progressBar.tsx: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components'; 2 | 3 | type Props = { max: number; value: number }; 4 | 5 | export function ProgressBar(props: Props) { 6 | return ( 7 | 8 | 9 | 10 | ); 11 | } 12 | 13 | const ProgressBarOutside = styled.div` 14 | height: 4px; 15 | background-color: #ffffff; 16 | border-radius: 2px; 17 | `; 18 | 19 | const ProgressBarInside = styled.div` 20 | background-color: ${(props) => props.theme.color.brand}; 21 | height: 100%; 22 | `; 23 | -------------------------------------------------------------------------------- /lib/normalizeCharacterModel.ts: -------------------------------------------------------------------------------- 1 | import { CharacterModelSerializer } from '../types/Response'; 2 | 3 | export const normalizeCharacterModel = (model: CharacterModelSerializer) => { 4 | const format = model.latest_character_model_version.spec_version; 5 | const license = { 6 | characterization: false, 7 | violentExpression: false, 8 | sexualExpression: false, 9 | corporateCommercialUse: false, 10 | personalCommercialUse: false, 11 | personalNonCommercialUse: false, 12 | credit: false, 13 | redistribution: false, 14 | modification: false, 15 | }; 16 | 17 | if (format == '1.0') { 18 | license.characterization = 19 | model.latest_character_model_version.vrm_meta.avatarPermission == 'everyone' ? true : false; 20 | license.violentExpression = model.latest_character_model_version.vrm_meta.allowExcessivelyViolentUsage; 21 | license.sexualExpression = model.latest_character_model_version.vrm_meta.allowExcessivelySexualUsage; 22 | license.corporateCommercialUse = 23 | model.latest_character_model_version.vrm_meta.commercialUsage == 'corporation' ? true : false; 24 | license.personalCommercialUse = 25 | model.latest_character_model_version.vrm_meta.commercialUsage == 'personalProfit' || 26 | license.corporateCommercialUse 27 | ? true 28 | : false; 29 | license.personalNonCommercialUse = 30 | model.latest_character_model_version.vrm_meta.commercialUsage == 'personalNonProfit' || 31 | license.personalCommercialUse 32 | ? true 33 | : false; 34 | license.credit = model.latest_character_model_version.vrm_meta.creditNotation == 'unnecessary' ? true : false; 35 | license.redistribution = model.latest_character_model_version.vrm_meta.allowRedistribution; 36 | license.modification = 37 | model.latest_character_model_version.vrm_meta.modification == 'allowModificationRedistribution' ? true : false; 38 | } else { 39 | license.characterization = model.license.characterization_allowed_user == 'everyone' ? true : false; 40 | license.violentExpression = model.license.violent_expression == 'allow' ? true : false; 41 | license.sexualExpression = model.license.sexual_expression == 'allow' ? true : false; 42 | license.corporateCommercialUse = model.license.corporate_commercial_use == 'allow' ? true : false; 43 | license.personalCommercialUse = model.license.personal_commercial_use == 'profit' ? true : false; 44 | license.personalNonCommercialUse = model.license.personal_commercial_use == 'nonprofit' || 'profit' ? true : false; 45 | license.credit = model.license.credit == 'unnecessary' ? true : false; 46 | license.redistribution = model.license.redistribution == 'allow' ? true : false; 47 | license.modification = model.license.modification == 'allow' ? true : false; 48 | } 49 | 50 | return { 51 | id: model.id, 52 | characterName: model.character.name, 53 | modelName: model.name, 54 | portraitImageUrl: model.portrait_image.w600.url, 55 | fullBodyImageUrl: model.full_body_image.w600.url, 56 | iconSquareImageUrl: model.portrait_image.sq300.url, 57 | license: license, 58 | format: format ? `VRM${format}` : 'VRM0.0', 59 | user: { 60 | name: model.character.user.name, 61 | iconUrl: model.character.user.icon.sq50.url, 62 | }, 63 | createdAt: model.character.created_at, 64 | originalFileSize: model.latest_character_model_version.original_file_size, 65 | }; 66 | }; 67 | -------------------------------------------------------------------------------- /lib/useVRM.ts: -------------------------------------------------------------------------------- 1 | import { VRM, VRMLoaderPlugin, VRMUtils } from '@pixiv/three-vrm'; 2 | import { useEffect, useRef, useState } from 'react'; 3 | import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'; 4 | 5 | export function useVRM(id: string): { 6 | /** vrm本体  */ 7 | vrm: VRM; 8 | /** fetch済みのサイズ(byte) */ 9 | fetchedSize: number; 10 | } { 11 | // vrmをfetchしてその中身と、その進捗状況を保持する 12 | // vrm:fetchしてきたVRMファイル 13 | // fetchedSize:fetchの進捗(バイト数) 14 | 15 | const [vrm, setVrm] = useState(null); 16 | const [fetchedSize, setFetchedSize] = useState(0); 17 | const refVRM = useRef(); 18 | 19 | useEffect(() => { 20 | const fetchModel = async () => { 21 | const res = await fetch(`api/vroid/vrm?id=${id}`); 22 | 23 | // fetchの進捗を取得する 24 | const vrmReader = res.body.getReader(); 25 | 26 | let receivedBytes = 0; 27 | let chunks = []; 28 | while (true) { 29 | const { done, value } = await vrmReader.read(); 30 | if (done) break; 31 | 32 | chunks.push(value); 33 | receivedBytes += value.length; 34 | setFetchedSize(receivedBytes); 35 | } 36 | 37 | const modelBlob = new Blob(chunks); 38 | const vrmUrl = URL.createObjectURL(modelBlob); 39 | const loader = new GLTFLoader(); 40 | loader.register((parser) => { 41 | return new VRMLoaderPlugin(parser); 42 | }); 43 | 44 | loader.load( 45 | vrmUrl, 46 | (gltf) => { 47 | // dispose previous VRM 48 | const prevVRM = refVRM.current; 49 | if (prevVRM) { 50 | VRMUtils.deepDispose(prevVRM.scene); 51 | setVrm(null); 52 | setFetchedSize(0); 53 | } 54 | 55 | // prepare vrm 56 | const vrm = gltf.userData.vrm as VRM; 57 | 58 | vrm.scene.traverse((obj) => { 59 | obj.frustumCulled = false; 60 | if ((obj as THREE.Mesh).isMesh) { 61 | obj.castShadow = true; 62 | } 63 | }); 64 | 65 | VRMUtils.rotateVRM0(vrm); 66 | 67 | // set VRM 68 | setVrm(vrm); 69 | refVRM.current = vrm; 70 | }, 71 | (xhr) => console.log((xhr.loaded / xhr.total) * 100 + '% loaded'), 72 | (error) => { 73 | console.error('An error happened'); 74 | console.error(error); 75 | }, 76 | ); 77 | }; 78 | fetchModel(); 79 | }, [id]); 80 | 81 | return { vrm: vrm, fetchedSize: fetchedSize }; 82 | } 83 | -------------------------------------------------------------------------------- /lib/vroid-hub-api.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * 認証が必要なVRoid Hub APIをコールするためのfetchのラッパー関数 3 | */ 4 | export async function fetchWithAuthorized(url: string, token: string, init?: RequestInit) { 5 | return fetch(url, { 6 | ...init, 7 | headers: { 8 | // VRoid HubのAPI Version 9 | 'X-Api-Version': '11', 10 | Authorization: `Bearer ${token}`, 11 | ...init?.headers, 12 | }, 13 | }); 14 | } 15 | 16 | /** 17 | * VRMのダウンロードURLを取得する 18 | */ 19 | export async function fetchVRMModel(id: string, token: string): Promise { 20 | // download_licensesにPOSTしてlicenseIdを取得 21 | const licenseRes = await vroidHubApi.postDownloadLicense(token, id); 22 | if (licenseRes.status != 200) { 23 | console.error(`fetch /api/download_licenses ended with status ${licenseRes.status}`); 24 | return; 25 | } 26 | 27 | const licenseId = (await licenseRes.json()).data.id; 28 | 29 | // license_idが取れなかった時 30 | if (!licenseId) { 31 | console.error('failed to get license_id'); 32 | return; 33 | } 34 | 35 | // 取得したlicenseIdでダウンロードURLを取得する 36 | // 302 redirectが返ってくるので、Locationに指定されたURLを取得してreturnする 37 | // ファイルサイズが大きいため、VRMのダウンロードはクライアント側で行う 38 | const downloadRes = await vroidHubApi.getDownloadLicenseDownload(token, licenseId); 39 | return downloadRes.headers.get('location'); 40 | } 41 | 42 | export const vroidHubApi = { 43 | getAccountCharacterModels: (token: string, options: { max_id?: string; count?: number } = {}) => { 44 | const url = new URL(`${process.env.NEXT_PUBLIC_VROID_HUB_URL}/api/account/character_models`); 45 | if (options.max_id) url.searchParams.append('max_id', options.max_id); 46 | if (options.count) url.searchParams.append('count', options.count.toString(10)); 47 | return fetchWithAuthorized(url.toString(), token); 48 | }, 49 | getHeartCharacterModels: (token: string, options: { max_id?: string; count?: number } = {}) => { 50 | const url = new URL(`${process.env.NEXT_PUBLIC_VROID_HUB_URL}/api/hearts`); 51 | if (options.max_id) url.searchParams.append('max_id', options.max_id); 52 | if (options.count) url.searchParams.append('count', options.count.toString(10)); 53 | return fetchWithAuthorized(url.toString(), token); 54 | }, 55 | getStaffPicksModels: (token: string, options: { max_id?: string; count?: number } = {}) => { 56 | const url = new URL(`${process.env.NEXT_PUBLIC_VROID_HUB_URL}/api/staff_picks`); 57 | if (options.max_id) url.searchParams.append('max_id', options.max_id); 58 | if (options.count) url.searchParams.append('count', options.count.toString(10)); 59 | return fetchWithAuthorized(url.toString(), token); 60 | }, 61 | postDownloadLicense: (token: string, modelId: string) => { 62 | return fetchWithAuthorized(`${process.env.NEXT_PUBLIC_VROID_HUB_URL}/api/download_licenses`, token, { 63 | method: 'POST', 64 | headers: { 65 | 'Content-Type': 'application/json', 66 | }, 67 | body: JSON.stringify({ 68 | character_model_id: modelId, 69 | }), 70 | }); 71 | }, 72 | getDownloadLicenseDownload: (token: string, licenseId: string) => { 73 | return fetchWithAuthorized(`${process.env.NEXT_PUBLIC_VROID_HUB_URL}/api/download_licenses/${licenseId}/download`, token, { 74 | method: 'GET', 75 | // リダイレクト先URLを取得するため、redirect: manualにする 76 | redirect: 'manual', 77 | headers: { 78 | 'Accept-Encoding': 'gzip', 79 | }, 80 | }); 81 | }, 82 | }; 83 | -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | typescript: { 3 | ignoreBuildErrors: true, 4 | }, 5 | }; 6 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sippo-vroidsdk-test2", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint", 10 | "fmt": "prettier --write '**/*.{ts,tsx}'" 11 | }, 12 | "dependencies": { 13 | "@charcoal-ui/react": "^3.1.0", 14 | "@charcoal-ui/styled": "^3.1.1", 15 | "@gltf-transform/core": "^3.4.8", 16 | "@pixiv/three-vrm": "^3.1.4", 17 | "@pixiv/three-vrm-animation": "^3.1.4", 18 | "@react-three/drei": "^9.78.1", 19 | "@react-three/fiber": "^8.13.4", 20 | "@types/node": "^22.7.0", 21 | "@types/react": "^18.2.9", 22 | "@types/three": "^0.153.0", 23 | "eslint": "^8.42.0", 24 | "eslint-config-next": "13.4.4", 25 | "next": "13.4.4", 26 | "next-auth": "3", 27 | "react": "18.2.0", 28 | "react-dom": "18.2.0", 29 | "react-use": "^17.4.0", 30 | "styled-components": "^6.0.5", 31 | "three": "^0.154.0", 32 | "typescript": "^5.1.6" 33 | }, 34 | "lint-staged": { 35 | "*.{ts,tsx}": [ 36 | "prettier --write" 37 | ] 38 | }, 39 | "prettier": { 40 | "singleQuote": true, 41 | "arrowParens": "always", 42 | "trailingComma": "all", 43 | "printWidth": 120 44 | }, 45 | "devDependencies": { 46 | "lint-staged": "^13.2.3", 47 | "prettier": "^3.0.0", 48 | "webpack-bundle-analyzer": "^4.9.0" 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /pages/_app.tsx: -------------------------------------------------------------------------------- 1 | import { Provider } from 'next-auth/client'; 2 | import { ThemeProvider, createGlobalStyle } from 'styled-components'; 3 | import { light } from '@charcoal-ui/theme'; 4 | import { CharcoalProvider, OverlayProvider, SSRProvider } from '@charcoal-ui/react'; 5 | import '../src/globals.css'; 6 | import Head from 'next/head'; 7 | 8 | export default function App({ Component, pageProps }) { 9 | return ( 10 | <> 11 | 12 | VRoid Hub API Example 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | ); 31 | } 32 | 33 | const GlobalStyle = createGlobalStyle` 34 | body { 35 | font-family: 'Noto Sans JP', sans-serif; 36 | font-size: ${(props) => props.theme.typography.size[14].fontSize}px; 37 | } 38 | `; 39 | -------------------------------------------------------------------------------- /pages/_document.tsx: -------------------------------------------------------------------------------- 1 | import Document, { DocumentContext, DocumentInitialProps } from 'next/document'; 2 | import { ServerStyleSheet } from 'styled-components'; 3 | 4 | export default class MyDocument extends Document { 5 | static async getInitialProps(ctx: DocumentContext): Promise { 6 | const sheet = new ServerStyleSheet(); 7 | const originalRenderPage = ctx.renderPage; 8 | 9 | try { 10 | ctx.renderPage = () => 11 | originalRenderPage({ 12 | enhanceApp: (App) => (props) => sheet.collectStyles(), 13 | }); 14 | 15 | const initialProps = await Document.getInitialProps(ctx); 16 | return { 17 | ...initialProps, 18 | styles: ( 19 | <> 20 | {initialProps.styles} 21 | {sheet.getStyleElement()} 22 | 23 | ), 24 | }; 25 | } finally { 26 | sheet.seal(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /pages/api/auth/[...nextauth].ts: -------------------------------------------------------------------------------- 1 | import NextAuth, { Account, Profile, User } from 'next-auth'; 2 | 3 | export default NextAuth({ 4 | providers: [ 5 | { 6 | // The name to display on the sign in form (e.g. 'Sign in with...') 7 | id: 'vroid', 8 | name: 'VRoidHub', 9 | type: 'oauth', 10 | version: '2.0', 11 | scope: 'default', 12 | params: { grant_type: 'authorization_code' }, 13 | accessTokenUrl: `${process.env.NEXT_PUBLIC_VROID_HUB_URL}/oauth/token`, 14 | requestTokenUrl: `${process.env.NEXT_PUBLIC_VROID_HUB_URL}/oauth/token`, 15 | authorizationUrl: `${process.env.NEXT_PUBLIC_VROID_HUB_URL}/authorize/confirm?response_type=code`, 16 | profileUrl: `${process.env.NEXT_PUBLIC_VROID_HUB_URL}/api/account`, 17 | headers: { 18 | 'X-Api-Version': 11, 19 | }, 20 | async profile(profile: any, tokens) { 21 | // You can use the tokens, in case you want to fetch more profile information 22 | // For example several OAuth providers do not return email by default. 23 | // Depending on your provider, will have tokens like `access_token`, `id_token` and or `refresh_token` 24 | return { 25 | id: profile.data.user_detail.user.id, 26 | name: profile.data.user_detail.user.name, 27 | image: profile.data.user_detail.user.icon.sq170.url, 28 | }; 29 | }, 30 | clientId: process.env.CLIENT_ID, 31 | clientSecret: process.env.CLIENT_SECRET, 32 | }, 33 | ], 34 | secret: process.env.NEXT_PUBLIC_NEXTAUTH_SECRET, 35 | callbacks: { 36 | async jwt(token, user, account, profile, isNewUser) { 37 | if (account?.accessToken) { 38 | token.accessToken = account.access_token; 39 | } 40 | if (profile) { 41 | token.id = profile.id; 42 | } 43 | return token; 44 | }, 45 | 46 | async session(session, token) { 47 | session.accessToken = token.accessToken; 48 | return session; 49 | }, 50 | 51 | async signIn(user: User, account: Account, profile: Profile) { 52 | return true; 53 | }, 54 | }, 55 | }); 56 | -------------------------------------------------------------------------------- /pages/api/vroid/models/account.ts: -------------------------------------------------------------------------------- 1 | import { getSession } from 'next-auth/client'; 2 | import type { ModelData } from '../../../../types/vroid'; 3 | import { CharacterModelCollectionResponse } from '../../../../types/Response'; 4 | import { NextApiRequest, NextApiResponse } from 'next'; 5 | import { vroidHubApi } from '../../../../lib/vroid-hub-api'; 6 | import { normalizeCharacterModel } from '../../../../lib/normalizeCharacterModel'; 7 | 8 | type Query = { 9 | max_id: string; 10 | }; 11 | 12 | export default async function handler(req: NextApiRequest, res: NextApiResponse) { 13 | const query = req.query as Query; 14 | 15 | // oauthのアクセストークンを取得 16 | const token: string = (await getSession({ req }))?.accessToken as string; 17 | 18 | if (!token) { 19 | // トークンを保持していなければ401 20 | return res.status(401).json({ message: 'Failed to get access token!' }); 21 | } 22 | 23 | // モデル一覧をfetch 24 | const apiRes = await vroidHubApi.getAccountCharacterModels(token, { max_id: query.max_id as string, count: 12 }); 25 | if (apiRes.status !== 200) { 26 | return res.status(apiRes.status); 27 | } 28 | 29 | const apiResJson = (await apiRes.json()) as CharacterModelCollectionResponse; 30 | 31 | // それぞれのモデルについて、パラメータを集める 32 | const resJson: { maxId: string | null; data: Array } = { maxId: null, data: [] }; 33 | if (apiResJson._links.next) { 34 | const url = new URL(apiResJson._links.next.href, process.env.NEXT_PUBLIC_VROID_HUB_URL); 35 | resJson.maxId = url.searchParams.get('max_id'); 36 | } 37 | 38 | for (const modelJson of apiResJson.data) { 39 | resJson.data.push(normalizeCharacterModel(modelJson)); 40 | } 41 | 42 | return res.status(200).json(resJson); 43 | } 44 | -------------------------------------------------------------------------------- /pages/api/vroid/models/hearts.ts: -------------------------------------------------------------------------------- 1 | import { getSession } from 'next-auth/client'; 2 | import type { ModelData } from '../../../../types/vroid'; 3 | import { CharacterModelCollectionResponse, CharacterModelSerializer } from '../../../../types/Response'; 4 | import { NextApiRequest, NextApiResponse } from 'next'; 5 | import { vroidHubApi } from '../../../../lib/vroid-hub-api'; 6 | import { normalizeCharacterModel } from '../../../../lib/normalizeCharacterModel'; 7 | 8 | type Query = { 9 | max_id: string; 10 | }; 11 | 12 | export default async function handler(req: NextApiRequest, res: NextApiResponse) { 13 | const query = req.query as Query; 14 | 15 | // oauthのアクセストークンを取得 16 | const token: string = (await getSession({ req }))?.accessToken as string; 17 | 18 | if (!token) { 19 | // トークンを保持していなければ401 20 | return res.status(401).json({ message: 'Failed to get access token!' }); 21 | } 22 | 23 | // モデル一覧をfetch 24 | const apiRes = await vroidHubApi.getHeartCharacterModels(token, { max_id: query.max_id as string, count: 12 }); 25 | if (apiRes.status !== 200) { 26 | return res.status(apiRes.status); 27 | } 28 | 29 | const apiResJson = (await apiRes.json()) as CharacterModelCollectionResponse; 30 | 31 | // それぞれのモデルについて、パラメータを集める 32 | const resJson: { maxId: string | null; data: Array } = { maxId: null, data: [] }; 33 | if (apiResJson._links.next) { 34 | const url = new URL(apiResJson._links.next.href, process.env.NEXT_PUBLIC_VROID_HUB_URL); 35 | resJson.maxId = url.searchParams.get('max_id'); 36 | } 37 | 38 | for (const modelJson of apiResJson.data) { 39 | resJson.data.push(normalizeCharacterModel(modelJson)); 40 | } 41 | 42 | return res.status(200).json(resJson); 43 | } 44 | -------------------------------------------------------------------------------- /pages/api/vroid/models/staff_picks.ts: -------------------------------------------------------------------------------- 1 | import { getSession } from 'next-auth/client'; 2 | import type { ModelData } from '../../../../types/vroid'; 3 | import { HeartCollectionResponse } from '../../../../types/Response'; 4 | import { NextApiRequest, NextApiResponse } from 'next'; 5 | import { vroidHubApi } from '../../../../lib/vroid-hub-api'; 6 | import { normalizeCharacterModel } from '../../../../lib/normalizeCharacterModel'; 7 | 8 | type Query = { 9 | max_id: string; 10 | }; 11 | 12 | export default async function handler(req: NextApiRequest, res: NextApiResponse) { 13 | const query = req.query as Query; 14 | 15 | // oauthのアクセストークンを取得 16 | const token: string = (await getSession({ req }))?.accessToken as string; 17 | 18 | if (!token) { 19 | // トークンを保持していなければ401 20 | return res.status(401).json({ message: 'Failed to get access token!' }); 21 | } 22 | 23 | // モデル一覧をfetch 24 | const apiRes = await vroidHubApi.getStaffPicksModels(token, { max_id: query.max_id as string, count: 12 }); 25 | if (apiRes.status !== 200) { 26 | return res.status(apiRes.status); 27 | } 28 | 29 | const apiResJson = (await apiRes.json()) as HeartCollectionResponse; 30 | 31 | // それぞれのモデルについて、パラメータを集める 32 | const resJson: { maxId: string | null; data: Array } = { maxId: null, data: [] }; 33 | if (apiResJson._links.next) { 34 | const url = new URL(apiResJson._links.next.href, process.env.NEXT_PUBLIC_VROID_HUB_URL); 35 | resJson.maxId = url.searchParams.get('max_id'); 36 | } 37 | 38 | for (const modelJson of apiResJson.data) { 39 | resJson.data.push(normalizeCharacterModel(modelJson.character_model)); 40 | } 41 | 42 | return res.status(200).json(resJson); 43 | } 44 | -------------------------------------------------------------------------------- /pages/api/vroid/vrm.ts: -------------------------------------------------------------------------------- 1 | import { getSession } from 'next-auth/client'; 2 | import type { NextApiRequest, NextApiResponse } from 'next'; 3 | import { fetchVRMModel } from '../../../lib/vroid-hub-api'; 4 | 5 | type Query = { 6 | id?: string; 7 | }; 8 | 9 | // モデルのurlを取得してきて、クライアント側でリダイレクトさせる 10 | export default async function handler(req: NextApiRequest, res: NextApiResponse) { 11 | const { id } = req.query as Query; 12 | 13 | if (!id) { 14 | return res.status(400).json({ message: 'please specify the id.' }); 15 | } 16 | 17 | const token = (await getSession({ req }))?.accessToken as string | undefined; 18 | 19 | // tokenが取れなかった時は401 20 | if (!token) { 21 | return res.status(401).json({ message: 'connot get access token!' }); 22 | } 23 | 24 | const redirectUrl: string = await fetchVRMModel(id as string, token); 25 | return res.redirect(redirectUrl); 26 | } 27 | -------------------------------------------------------------------------------- /pages/index.tsx: -------------------------------------------------------------------------------- 1 | import { signIn, useSession } from 'next-auth/client'; 2 | 3 | import React, { useCallback, useState } from 'react'; 4 | import { useAsync } from 'react-use'; 5 | import { useRouter } from 'next/router'; 6 | 7 | import { Button } from '@charcoal-ui/react'; 8 | import styled from 'styled-components'; 9 | 10 | import { ModelList } from '../components/ModelList'; 11 | import type { ModelData } from '../types/vroid'; 12 | import { IndexPageHeader } from '../components/Header'; 13 | 14 | type ModelsListState = { 15 | nextMaxId: string | null; 16 | maxId: string | null; 17 | items: ModelData[]; 18 | }; 19 | 20 | export default function Index() { 21 | const [session] = useSession(); 22 | const router = useRouter(); 23 | 24 | // ユーザーが保持しているモデルの一覧 25 | const [userModels, setUserModels] = useState({ maxId: null, nextMaxId: null, items: [] }); 26 | const [heartsModels, setHeartsModels] = useState({ maxId: null, nextMaxId: null, items: [] }); 27 | const [staffPickModels, setStaffPickModels] = useState({ maxId: null, nextMaxId: null, items: [] }); 28 | 29 | // あなたのキャラクター 30 | const { loading: userModelsLoading } = useAsync(async () => { 31 | const url = new URL('/api/vroid/models/account', location.origin); 32 | if (userModels.maxId) url.searchParams.append('max_id', userModels.maxId); 33 | 34 | const accountRes = await fetch(url); 35 | if (accountRes.status != 200) return console.log('failed to fetch account...'); 36 | const json = await accountRes.json(); 37 | 38 | setUserModels((prev) => ({ 39 | maxId: prev.maxId, 40 | nextMaxId: json.maxId, 41 | items: [...prev.items, ...json.data], 42 | })); 43 | }, [userModels.maxId]); 44 | 45 | // ❤︎したキャラクター 46 | const { loading: heartsModelsLoading } = useAsync(async () => { 47 | const url = new URL('/api/vroid/models/hearts', location.origin); 48 | if (heartsModels.maxId) url.searchParams.append('max_id', heartsModels.maxId); 49 | 50 | const heartsRes = await fetch(url); 51 | if (heartsRes.status != 200) return console.log('failed to fetch hearts...'); 52 | const json = await heartsRes.json(); 53 | 54 | setHeartsModels((prev) => ({ 55 | maxId: prev.maxId, 56 | nextMaxId: json.maxId, 57 | items: [...prev.items, ...json.data], 58 | })); 59 | }, [heartsModels.maxId]); 60 | 61 | // 注目のモデル 62 | const { loading: staffPickModelsLoading } = useAsync(async () => { 63 | const url = new URL('/api/vroid/models/staff_picks', location.origin); 64 | if (staffPickModels.maxId) url.searchParams.append('max_id', staffPickModels.maxId); 65 | 66 | const staffPickRes = await fetch(url); 67 | if (staffPickRes.status != 200) return console.log('failed to fetch staff_picks...'); 68 | const json = await staffPickRes.json(); 69 | 70 | setStaffPickModels((prev) => ({ 71 | maxId: prev.maxId, 72 | nextMaxId: json.maxId, 73 | items: [...prev.items, ...json.data], 74 | })); 75 | }, [staffPickModels.maxId]); 76 | 77 | const handleNextUserModels = useCallback(() => { 78 | setUserModels((prev) => ({ ...prev, maxId: prev.nextMaxId })); 79 | }, [setUserModels]); 80 | 81 | const handleNextHeartsModels = useCallback(() => { 82 | setHeartsModels((prev) => ({ ...prev, maxId: prev.nextMaxId })); 83 | }, [setHeartsModels]); 84 | 85 | const handleNextStaffPickModels = useCallback(() => { 86 | setStaffPickModels((prev) => ({ ...prev, maxId: prev.nextMaxId })); 87 | }, [setStaffPickModels]); 88 | 89 | return ( 90 |
91 | {!session && ( 92 | <> 93 | 94 | 97 | 98 | 99 | )} 100 | {session && ( 101 | 102 | 103 | 104 | <> 105 | 113 | 114 | 115 | 116 | <> 117 | 125 | 126 | 127 | 128 | <> 129 | 137 | 138 | 139 | 140 | 141 | 142 |
143 | 146 |
147 |
148 |
149 | 150 | 自分のキャラクター(VRM形式)を登録するには 151 | 152 |
153 |
154 | )} 155 |
156 | ); 157 | } 158 | 159 | const BodyDiv = styled.div` 160 | margin: 20px; 161 | position: relative; 162 | `; 163 | 164 | const LoginButtonWrapper = styled.div` 165 | display: grid; 166 | position: absolute; 167 | top: 50%; 168 | left: 50%; 169 | transform: translate(-50%, -50%); 170 | `; 171 | 172 | const TitleContentSpacer = styled.div` 173 | padding: 20px; 174 | `; 175 | 176 | // 「あなたもモデル」と「❤︎したモデル」の間のスペース。 177 | const SectionSpacer = styled.div` 178 | margin: 64px; 179 | `; 180 | 181 | // 「VRoid Hubで探す」ボタンの入れ物 182 | const ToVRoidHubButtonWrapper = styled.div` 183 | margin: 0px; 184 | display: flex; 185 | justify-content: center; 186 | `; 187 | 188 | // 「VRoid Hubで探す」ボタンの中のテキスト 189 | const ToVRoidHubButtonText = styled.p` 190 | margin: 0px; 191 | `; 192 | 193 | const PageBottomDivider = styled.div` 194 | border-bottom: solid 1px #d6d6d6; 195 | margin: 0px; 196 | padding-bottom: 36px; 197 | margin-bottom: 40px; 198 | `; 199 | 200 | // 「自分のキャラクター(VRM形式)を登録するには」 201 | const HowToRegisterText = styled.a` 202 | color: ${(props) => props.theme.color.link1}; 203 | margin-top: 24px; 204 | margin-bottom: 48px; 205 | text-decoration: none; 206 | `; 207 | -------------------------------------------------------------------------------- /pages/vrm.tsx: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useLayoutEffect, useState, useRef, useCallback } from 'react'; 2 | import { useRouter } from 'next/router'; 3 | 4 | import { Button } from '@charcoal-ui/react'; 5 | import styled from 'styled-components'; 6 | import { ProgressBar } from '../components/progressBar'; 7 | 8 | // for vrm 9 | import * as THREE from 'three'; 10 | import { VRM } from '@pixiv/three-vrm'; 11 | import { useVRM } from '../lib/useVRM'; 12 | import { Canvas, useFrame, useLoader } from '@react-three/fiber'; 13 | import { PerspectiveCamera } from '@react-three/drei'; 14 | import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader'; 15 | import { createVRMAnimationClip, VRMAnimation, VRMAnimationLoaderPlugin } from '@pixiv/three-vrm-animation'; 16 | 17 | export default function Model() { 18 | const router = useRouter(); 19 | const { id, size } = router.query; 20 | 21 | const rootRef = useRef(null); 22 | const { vrm, fetchedSize } = useVRM(id as string); 23 | 24 | const onClickBackToHome = useCallback(() => { 25 | router.push('/'); 26 | }, [router]); 27 | 28 | useLayoutEffect(() => { 29 | const root = rootRef.current; 30 | if (!root) return; 31 | 32 | const resizeCanvas = () => { 33 | root.style.width = `${document.documentElement.clientWidth}px`; 34 | root.style.height = `${document.documentElement.clientHeight}px`; 35 | }; 36 | resizeCanvas(); 37 | 38 | window.addEventListener('resize', resizeCanvas); 39 | return () => { 40 | window.removeEventListener('resize', resizeCanvas); 41 | }; 42 | }, []); 43 | 44 | return ( 45 |
46 | {vrm == undefined ? ( 47 | 48 |
49 | 呼び出しています 50 |
51 | 52 |
53 | ) : ( 54 | 55 | 56 | 57 | 58 | 59 | )} 60 | 61 | 64 | 65 |
66 | ); 67 | } 68 | 69 | /** VRMアバターを表示するコンポーネント */ 70 | const Avatar = ({ vrm }: { vrm: VRM }) => { 71 | const mixer = useRef(); 72 | const action = useRef(); 73 | const [show, setShow] = useState(false); 74 | 75 | useFrame((state, delta) => { 76 | if (mixer.current) { 77 | mixer.current.update(delta); 78 | } 79 | 80 | if (vrm) { 81 | vrm.update(delta); 82 | } 83 | }); 84 | 85 | const vrmaContainer = useLoader(GLTFLoader, '/idle_loop.vrma', (loader) => { 86 | loader.register((parser) => { 87 | return new VRMAnimationLoaderPlugin(parser); 88 | }); 89 | }); 90 | 91 | const vrma = (vrmaContainer.userData.vrmAnimations?.[0] ?? undefined) as VRMAnimation | undefined; 92 | 93 | useEffect(() => { 94 | const loadAnimation = async () => { 95 | if (!vrm) return; 96 | if (!vrma) return; 97 | 98 | const mixerTmp: THREE.AnimationMixer = new THREE.AnimationMixer(vrm.scene); 99 | mixer.current = mixerTmp; 100 | 101 | const clip = createVRMAnimationClip(vrma, vrm); 102 | action.current = mixer.current.clipAction(clip); 103 | action.current.play(); 104 | 105 | setShow(true); 106 | }; 107 | loadAnimation(); 108 | }, [vrm, vrma]); 109 | 110 | return show ? : <>; 111 | }; 112 | 113 | // プログレスバーを真ん中に寄せるため 114 | const ProgressBarContainer = styled.div` 115 | position: absolute; 116 | top: 50%; 117 | left: 50%; 118 | display: grid; 119 | grid-template-rows: 22px 4px; 120 | gap: 16px; 121 | transform: translate(-50%, -50%); 122 | width: 208px; 123 | `; 124 | 125 | // 「表示中」 126 | const ProgressBarText = styled.p` 127 | font-size: ${(props) => props.theme.typography.size[14].fontSize}px; 128 | font-family: 'Noto Sans JP', sans-serif; 129 | font-weight: 400; 130 | color: ${(props) => props.theme.color.text2}; 131 | margin: 0px; 132 | `; 133 | 134 | // 「キャラクター選択に戻る」ボタン 135 | const ButtonContainer = styled.div` 136 | position: absolute; 137 | display: grid; 138 | bottom: 40px; 139 | width: 200px; 140 | left: 50%; 141 | transform: translate(-50%, 0px); 142 | `; 143 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pixiv/VRoidHub-API-Example/1da725b9683263ae00d61b6761d8e207dee7676d/public/favicon.ico -------------------------------------------------------------------------------- /public/human.vrm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pixiv/VRoidHub-API-Example/1da725b9683263ae00d61b6761d8e207dee7676d/public/human.vrm -------------------------------------------------------------------------------- /public/idle_loop.vrma: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pixiv/VRoidHub-API-Example/1da725b9683263ae00d61b6761d8e207dee7676d/public/idle_loop.vrma -------------------------------------------------------------------------------- /public/next.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/vercel.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/env.d.ts: -------------------------------------------------------------------------------- 1 | declare global { 2 | namespace NodeJS { 3 | interface ProcessEnv { 4 | CLIENT_ID: string; 5 | CLIENT_SECRET: string; 6 | NEXT_PUBLIC_NEXTAUTH_SECRET: string; 7 | NEXTAUTH_URL: string; 8 | NEXT_PUBLIC_VROID_HUB_URL: string; 9 | } 10 | } 11 | } 12 | 13 | export {}; 14 | -------------------------------------------------------------------------------- /src/globals.css: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;700&display=swap'); 2 | 3 | body { 4 | margin:0px; 5 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "lib": [ 4 | "dom", 5 | "dom.iterable", 6 | "esnext" 7 | ], 8 | "target": "es2015", 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "strict": false, 12 | "forceConsistentCasingInFileNames": true, 13 | "noEmit": true, 14 | "incremental": true, 15 | "esModuleInterop": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "jsx": "preserve" 21 | }, 22 | "include": [ 23 | "next-env.d.ts", 24 | "src/env.d.ts", 25 | "**/*.ts", 26 | "**/*.tsx" 27 | ], 28 | "exclude": [ 29 | "node_modules" 30 | ], 31 | } 32 | -------------------------------------------------------------------------------- /types/Response/index.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | export type { CharacterModelCollectionResponse } from './models/CharacterModelCollectionResponse'; 6 | export type { HeartCollectionResponse } from './models/HeartCollectionResponse'; 7 | export type { CharacterModelSerializer } from './models/CharacterModelSerializer'; 8 | export type { HeartSerializer } from './models/HeartSerializer'; 9 | -------------------------------------------------------------------------------- /types/Response/models/AgeLimitSerializer.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | export type AgeLimitSerializer = { 6 | is_r18: boolean; 7 | is_r15: boolean; 8 | is_adult: boolean; 9 | }; 10 | -------------------------------------------------------------------------------- /types/Response/models/AttachedItemCoinSerializer.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | export type AttachedItemCoinSerializer = { 6 | coin_type: 'apple' | 'google'; 7 | price: number; 8 | }; 9 | -------------------------------------------------------------------------------- /types/Response/models/AttachedItemSerializer.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type { AttachedItemCoinSerializer } from './AttachedItemCoinSerializer'; 6 | 7 | export type AttachedItemSerializer = { 8 | item_display_name: string; 9 | category_type: 10 | | 'skin' 11 | | 'eyebrow' 12 | | 'nose' 13 | | 'mouth' 14 | | 'ear' 15 | | 'face_shape' 16 | | 'lip' 17 | | 'eye_surrounding' 18 | | 'eyeline' 19 | | 'eyelash' 20 | | 'iris' 21 | | 'eye_white' 22 | | 'eye_highlight' 23 | | 'base_hair' 24 | | 'all_hair' 25 | | 'hair_front' 26 | | 'hair_back' 27 | | 'whole_body' 28 | | 'head' 29 | | 'neck' 30 | | 'shoulder' 31 | | 'arm' 32 | | 'hand' 33 | | 'chest' 34 | | 'torso' 35 | | 'waist' 36 | | 'leg' 37 | | 'tops' 38 | | 'bottoms' 39 | | 'onepiece' 40 | | 'shoes' 41 | | 'inner' 42 | | 'socks' 43 | | 'neck_accessory' 44 | | 'arm_accessory' 45 | | 'safety' 46 | | 'cheek'; 47 | downloadable: boolean; 48 | take_free: boolean; 49 | id: string; 50 | attached_item_coins: Array; 51 | }; 52 | -------------------------------------------------------------------------------- /types/Response/models/CharacterModelBoothItemSerializer.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | export type CharacterModelBoothItemSerializer = { 6 | booth_item_id: number; 7 | part_category: string | null; 8 | }; 9 | -------------------------------------------------------------------------------- /types/Response/models/CharacterModelCollectionResponse.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | import type { CharacterModelSerializer } from './CharacterModelSerializer'; 5 | import type { ResponseSerializer } from './ResponseSerializer'; 6 | export type CharacterModelCollectionResponse = { 7 | data: Array; 8 | } & ResponseSerializer; 9 | -------------------------------------------------------------------------------- /types/Response/models/CharacterModelLicenseSerializer.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | export type CharacterModelLicenseSerializer = { 6 | /** 7 | * v3から廃止 8 | * @deprecated 9 | */ 10 | allow_modification?: boolean; 11 | /** 12 | * v3から廃止 13 | * @deprecated 14 | */ 15 | allow_redistribution?: boolean; 16 | /** 17 | * v3から廃止 18 | * @deprecated 19 | */ 20 | allow_sexual_expression?: boolean; 21 | /** 22 | * v3から廃止 23 | * @deprecated 24 | */ 25 | allow_violent_expression?: boolean; 26 | /** 27 | * v3から廃止 28 | * @deprecated 29 | */ 30 | allow_corporate_commercial_use?: boolean; 31 | modification: 'default' | 'disallow' | 'allow'; 32 | redistribution: 'default' | 'disallow' | 'allow'; 33 | /** 34 | * v3からdefaultが追加 35 | */ 36 | credit: 'default' | 'necessary' | 'unnecessary'; 37 | /** 38 | * v3からdefaultが追加 39 | */ 40 | characterization_allowed_user: 'default' | 'author' | 'everyone'; 41 | sexual_expression: 'default' | 'disallow' | 'allow'; 42 | violent_expression: 'default' | 'disallow' | 'allow'; 43 | corporate_commercial_use: 'default' | 'disallow' | 'allow'; 44 | /** 45 | * v3からdefaultが追加 46 | */ 47 | personal_commercial_use: 'default' | 'disallow' | 'profit' | 'nonprofit'; 48 | }; 49 | -------------------------------------------------------------------------------- /types/Response/models/CharacterModelSerializer.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type { AgeLimitSerializer } from './AgeLimitSerializer'; 6 | import type { CharacterModelBoothItemSerializer } from './CharacterModelBoothItemSerializer'; 7 | import type { CharacterModelLicenseSerializer } from './CharacterModelLicenseSerializer'; 8 | import type { CharacterModelVersionSerializer } from './CharacterModelVersionSerializer'; 9 | import type { CharacterSerializer } from './CharacterSerializer'; 10 | import type { FullBodyImageSerializer } from './FullBodyImageSerializer'; 11 | import type { PortraitImageSerializer } from './PortraitImageSerializer'; 12 | import type { TagSerializer } from './TagSerializer'; 13 | 14 | export type CharacterModelSerializer = { 15 | id: string; 16 | name: string | null; 17 | is_private: boolean; 18 | is_downloadable: boolean; 19 | is_comment_off: boolean; 20 | is_other_users_available: boolean; 21 | is_other_users_allow_viewer_preview: boolean; 22 | is_hearted: boolean; 23 | portrait_image: PortraitImageSerializer; 24 | full_body_image: FullBodyImageSerializer; 25 | license?: CharacterModelLicenseSerializer; 26 | created_at: string; 27 | heart_count: number; 28 | download_count: number; 29 | usage_count: number; 30 | view_count: number; 31 | published_at: string | null; 32 | tags: Array; 33 | age_limit: AgeLimitSerializer; 34 | character: CharacterSerializer; 35 | latest_character_model_version?: CharacterModelVersionSerializer; 36 | character_model_booth_items: Array; 37 | }; 38 | -------------------------------------------------------------------------------- /types/Response/models/CharacterModelVersionSerializer.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type { AttachedItemSerializer } from './AttachedItemSerializer'; 6 | import type { ModelBasisConversionStateSerializer } from './ModelBasisConversionStateSerializer'; 7 | import type { VendorSpecifiedLicenseSerializer } from './VendorSpecifiedLicenseSerializer'; 8 | 9 | export type CharacterModelVersionSerializer = { 10 | id: string; 11 | created_at: string; 12 | spec_version: string | null; 13 | exporter_version: string | null; 14 | triangle_count: number; 15 | mesh_count: number; 16 | mesh_primitive_count: number; 17 | mesh_primitive_morph_count: number; 18 | material_count: number; 19 | texture_count: number; 20 | joint_count: number; 21 | is_vendor_forbidden_use_by_others: boolean; 22 | is_vendor_protected_download: boolean; 23 | is_vendor_forbidden_other_users_preview: boolean; 24 | original_file_size: number | null; 25 | vrm_meta: any; 26 | original_compressed_file_size: number | null; 27 | conversion_state?: ModelBasisConversionStateSerializer; 28 | vendor_specified_license?: VendorSpecifiedLicenseSerializer; 29 | attached_items?: Array; 30 | }; 31 | -------------------------------------------------------------------------------- /types/Response/models/CharacterSerializer.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type { UserSerializer } from './UserSerializer'; 6 | 7 | export type CharacterSerializer = { 8 | user: UserSerializer; 9 | id: string; 10 | name: string; 11 | is_private: boolean; 12 | created_at: string; 13 | published_at: string | null; 14 | }; 15 | -------------------------------------------------------------------------------- /types/Response/models/ErrorField.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | export type ErrorField = { 6 | code?: string; 7 | message?: string; 8 | details?: any; 9 | }; 10 | -------------------------------------------------------------------------------- /types/Response/models/FullBodyImageSerializer.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type { ImageSerializer } from './ImageSerializer'; 6 | 7 | export type FullBodyImageSerializer = { 8 | is_default_image: boolean; 9 | original: ImageSerializer; 10 | w600: ImageSerializer; 11 | w300: ImageSerializer; 12 | }; 13 | -------------------------------------------------------------------------------- /types/Response/models/HeartCollectionResponse.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | import type { HeartSerializer } from './HeartSerializer'; 5 | import type { ResponseSerializer } from './ResponseSerializer'; 6 | export type HeartCollectionResponse = { 7 | data: Array; 8 | } & ResponseSerializer; 9 | -------------------------------------------------------------------------------- /types/Response/models/HeartSerializer.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type { CharacterModelSerializer } from './CharacterModelSerializer'; 6 | 7 | export type HeartSerializer = { 8 | id: string; 9 | character_model: CharacterModelSerializer; 10 | created_at: string; 11 | }; 12 | -------------------------------------------------------------------------------- /types/Response/models/ImageSerializer.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | export type ImageSerializer = { 6 | url: string; 7 | url2x: string | null; 8 | width: number; 9 | height: number; 10 | }; 11 | -------------------------------------------------------------------------------- /types/Response/models/LinkField.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | export type LinkField = { 6 | href?: string; 7 | }; 8 | -------------------------------------------------------------------------------- /types/Response/models/LinksField.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type { LinkField } from './LinkField'; 6 | 7 | export type LinksField = { 8 | next?: LinkField; 9 | }; 10 | -------------------------------------------------------------------------------- /types/Response/models/ModelBasisConversionStateSerializer.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | export type ModelBasisConversionStateSerializer = { 6 | current_state: 'pending' | 'processing' | 'completed' | 'failed'; 7 | }; 8 | -------------------------------------------------------------------------------- /types/Response/models/PortraitImageSerializer.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type { ImageSerializer } from './ImageSerializer'; 6 | 7 | export type PortraitImageSerializer = { 8 | is_default_image: boolean; 9 | original: ImageSerializer; 10 | w600: ImageSerializer; 11 | w300: ImageSerializer; 12 | sq600: ImageSerializer; 13 | sq300: ImageSerializer; 14 | sq150: ImageSerializer; 15 | }; 16 | -------------------------------------------------------------------------------- /types/Response/models/ResponseSerializer.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type { ErrorField } from './ErrorField'; 6 | import type { LinksField } from './LinksField'; 7 | 8 | export type ResponseSerializer = { 9 | error: ErrorField; 10 | _links: LinksField; 11 | rand: string; 12 | }; 13 | -------------------------------------------------------------------------------- /types/Response/models/TagSerializer.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | export type TagSerializer = { 6 | name: string; 7 | locale: string | null; 8 | en_name: string | null; 9 | ja_name: string | null; 10 | }; 11 | -------------------------------------------------------------------------------- /types/Response/models/UserIconSerializer.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type { ImageSerializer } from './ImageSerializer'; 6 | 7 | export type UserIconSerializer = { 8 | is_default_image: boolean; 9 | sq170: ImageSerializer; 10 | sq50: ImageSerializer; 11 | }; 12 | -------------------------------------------------------------------------------- /types/Response/models/UserSerializer.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | import type { UserIconSerializer } from './UserIconSerializer'; 6 | 7 | export type UserSerializer = { 8 | id: string; 9 | pixiv_user_id: string; 10 | name: string; 11 | icon: UserIconSerializer; 12 | }; 13 | -------------------------------------------------------------------------------- /types/Response/models/VendorSpecifiedLicenseSerializer.ts: -------------------------------------------------------------------------------- 1 | /* istanbul ignore file */ 2 | /* tslint:disable */ 3 | /* eslint-disable */ 4 | 5 | export type VendorSpecifiedLicenseSerializer = { 6 | modification: 'default' | 'disallow' | 'allow'; 7 | redistribution: 'default' | 'disallow' | 'allow'; 8 | credit: 'default' | 'necessary' | 'unnecessary'; 9 | characterization_allowed_user: 'default' | 'author' | 'everyone'; 10 | sexual_expression: 'default' | 'disallow' | 'allow'; 11 | violent_expression: 'default' | 'disallow' | 'allow'; 12 | corporate_commercial_use: 'default' | 'disallow' | 'allow'; 13 | personal_commercial_use: 'default' | 'disallow' | 'profit' | 'nonprofit'; 14 | }; 15 | -------------------------------------------------------------------------------- /types/next-auth.d.ts: -------------------------------------------------------------------------------- 1 | import NextAuth from 'next-auth'; 2 | 3 | declare module 'next-auth' {} 4 | -------------------------------------------------------------------------------- /types/vroid.ts: -------------------------------------------------------------------------------- 1 | export type ModelData = { 2 | id: string; 3 | characterName: string; 4 | modelName: string; 5 | portraitImageUrl: string; 6 | fullBodyImageUrl: string; 7 | iconSquareImageUrl: string; 8 | license: { 9 | characterization: boolean; 10 | violentExpression: boolean; 11 | sexualExpression: boolean; 12 | corporateCommercialUse: boolean; 13 | personalCommercialUse: boolean; 14 | personalNonCommercialUse: boolean; 15 | modification: boolean; 16 | credit: boolean; //不要時にtrue 17 | redistribution: boolean; 18 | }; 19 | user: { 20 | name: string; 21 | iconUrl: string; 22 | }; 23 | format: string; 24 | createdAt: string; 25 | originalFileSize: number; 26 | }; 27 | --------------------------------------------------------------------------------