diff --git a/app/components/ModelLoad.tsx b/app/components/ModelLoad.tsx index 058bb31..b9c02a6 100644 --- a/app/components/ModelLoad.tsx +++ b/app/components/ModelLoad.tsx @@ -2,6 +2,7 @@ import { Billboard, OrbitControls, Text, useGLTF } from "@react-three/drei"; import { Canvas, useFrame, useThree } from "@react-three/fiber"; import { Bloom, EffectComposer } from "@react-three/postprocessing"; import { type ReactNode, Suspense, useEffect, useMemo, useRef } from "react"; +import { ErrorBoundary, useErrorBoundary } from "react-error-boundary"; import type { MeshStandardMaterial } from "three"; import * as THREE from "three"; import { OutlineEffect } from "three/addons/effects/OutlineEffect.js"; @@ -145,54 +146,70 @@ function Character({ characterSetting }: ModelProps): ReactNode { ); } -export function ModelViewer({ characterSetting }: ModelProps): ReactNode { +export function Viewer({ characterSetting }: ModelProps): ReactNode { return ( -
- + {/* ライトを設定 */} + + + {/* ポストプロセッシング */} + + + + + + 読み込み中… + + + } > - {/* ライトを設定 */} - - - {/* ポストプロセッシング */} - - - - - - 読み込み中… - - - } - > - {/* GLBモデルの読み込みと表示 */} - - - {/* カメラコントロールの追加(ユーザーが自由にカメラを操作できるようにする) */} - - {/* アウトラインエフェクト */} - {/* */} - + {/* GLBモデルの読み込みと表示 */} + + + {/* カメラコントロールの追加(ユーザーが自由にカメラを操作できるようにする) */} + + {/* アウトラインエフェクト */} + {/* */} + + ); +} + +function ErrorFallback(): ReactNode { + return ( +
+

表示できません :(

+
+ ); +} + +export function ModelViewer({ characterSetting }: ModelProps): ReactNode { + return ( +
+ }> + +
); } diff --git a/package.json b/package.json index 93f0dc0..c447a7d 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "qrcode.react": "4.1.0", "react": "18.3.1", "react-dom": "18.3.1", + "react-error-boundary": "4.1.2", "react-hook-form": "7.53.1", "swr": "2.2.5", "tailwind-merge": "2.5.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 160cbf1..4864981 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -62,6 +62,9 @@ importers: react-dom: specifier: 18.3.1 version: 18.3.1(react@18.3.1) + react-error-boundary: + specifier: 4.1.2 + version: 4.1.2(react@18.3.1) react-hook-form: specifier: 7.53.1 version: 7.53.1(react@18.3.1) @@ -4199,6 +4202,11 @@ packages: react: ^0.14.8 || ^15.0.1 || ^16.0.0 || ^17.0.1 || ^18.0.0 react-dom: ^0.14.8 || ^15.0.1 || ^16.0.0 || ^17.0.1 || ^18.0.0 + react-error-boundary@4.1.2: + resolution: {integrity: sha512-GQDxZ5Jd+Aq/qUxbCm1UtzmL/s++V7zKgE8yMktJiCQXCCFZnMZh9ng+6/Ne6PjNSXH0L9CjeOEREfRnq6Duag==} + peerDependencies: + react: '>=16.13.1' + react-hook-form@7.53.1: resolution: {integrity: sha512-6aiQeBda4zjcuaugWvim9WsGqisoUk+etmFEsSUMm451/Ic8L/UAb7sRtMj3V+Hdzm6mMjU1VhiSzYUZeBm0Vg==} engines: {node: '>=18.0.0'} @@ -9588,6 +9596,11 @@ snapshots: react-dom: 18.3.1(react@18.3.1) react-is: 18.1.0 + react-error-boundary@4.1.2(react@18.3.1): + dependencies: + '@babel/runtime': 7.26.0 + react: 18.3.1 + react-hook-form@7.53.1(react@18.3.1): dependencies: react: 18.3.1