![見出し画像](https://assets.st-note.com/production/uploads/images/128494281/rectangle_large_type_2_ebb51258068ba1f92ae8b2ffbbbab055.png?width=800)
CodeSandbox上コードをCodeSandbox形式からDevbox形式にコンバート
■CodeSandbox形式からDevbox形式に変換
久しぶりにCodeSandboxで作業をしようと思ったら、無料で投稿できるCodeSandboxのコード数が20までに制限されるらしく、それを上回る数はDevboxというものに変換しなけば Read Only 状態になってしまうとのことだったので、あわててそのDevbox形式に変換しました。 その記録を残しておきます。
参考
変換前のCodeSandboxへの投稿コードについてのまとめnoteは以下になります。 Devbox形式に変換後も、環境設定や使用ライブラリなどは基本的にまとめ先で説明しているものが維持されていると思います。
CodeSandboxでReact Three Fiber実験まとめ
ちなみに変換により正常に動かなくなったもの多数ですw。 CodeSandbox形式からDevbox形式に変換した自分のコードは、主に Three React Fiber によるプログラムとなります。
このnote内で使用しているそれぞれのコードのサムネイル画像について、Practice01~27のサムネイルは前に使用したサムネイルのうち手元に残っていたもの、Practice28~38のサムネイルは今回新しく画面をキャプチャしたもの、となります。 そのためPractice01~27のサムネイルは、Devbox形式への変換によりコードが動いていないものでも、正常に動いているかのようになっているものもあります。
CodeSandbox形式からDevbox形式への変換により正常に動かなくなったコードは以下となります。
glTF Loader、Practice14~16はglTFファイルの読み込み失敗エラー?
Practice30はテスクチャ読み込めず
Practice35はアニメーションせず
Practice37はテスクチャ読み込めず
Practice38はコンパイルエラー?
■おまけ
テキトー英語力でCodeSandboxの説明を読んだ感じでは、Devbox形式はアクセスの総時間制限(1ヶ月40時間?)のかわりにいくつでも作れて、CodeSandbox形式より速い実行ができる? そして、40時間のアクセスを越えるとその月はアクセスがブロックされるようになる?
参考サイト
Introducing a Unified Development Platform
Upcoming Pricing & Billing Changes その1?
Upcoming Pricing & Billing Changes その2?
Convert a Sandbox into a Devbox
■Discover機能
自分のコードの一覧を見る方法がわからなかったので、一覧表示に使用しました。 以下「siouxcitizen」で検索した結果へのリンクとなります。
https://codesandbox.io/search?query=siouxciizen
42 results found
と、42個の作成したプログラムが検索結果として表示されました。 これがないと作業しづらかったです。
では、前置きが長くなりましたが、以下から修正したプログラムへのリンクとサムネイルのリストとなります。 対象プログラムがDevbox形式への変換で正常に動かなくなったものの場合は、それへの軽いコメントとがっつりエラー文を貼り付けている場合があります。
■最初にReact Three Fiberの本家によるコードをforkしたものです(サムネイルなし)
forked from React Three Fiber Basic Demo
■Practice01
React Three Fiber Practice01
![](https://assets.st-note.com/img/1705875247712-EwEJE1aYaU.png)
■Practice02
React Three Fiber Practice02 Box Rotation by Mouse Move
![](https://assets.st-note.com/img/1705875279140-KMJ30yaQYh.png)
■Practice03
React Three Fiber Practice03 GUI Test by HTML&CSS
![](https://assets.st-note.com/img/1705875293555-MKTwCjzwUW.png)
■Practice04
React Three Fiber Practice04 GUI Test by Material UI
![](https://assets.st-note.com/img/1705875308187-cSdKRt1z2C.png)
■Practice05
React Three Fiber Practice05 GUI Test by Material UI + CSS
![](https://assets.st-note.com/img/1705875323033-R9ES7pL4DG.png)
■Practice06
React Three Fiber Practice06 Plane
![](https://assets.st-note.com/img/1705875336237-xi4E0o05IL.png)
■Practice07
React Three Fiber Practice07 Sphere
![](https://assets.st-note.com/img/1705875348996-zKJluTg19r.png)
■Practice08
React Three Fiber Practice08 Torus
![](https://assets.st-note.com/img/1705875363516-WK3FOnDXff.png)
■Practice09
React Three Fiber Practice09 Torusknot
![](https://assets.st-note.com/img/1705875374435-1SmVzQjy3A.png)
■Practice10
React Three Fiber Practice10 Cylinder
![](https://assets.st-note.com/img/1705875384420-qMKKnoVbbB.png)
■Practice11
React Three Fiber Practice11 Box Texture
![](https://assets.st-note.com/img/1705875393400-rFjFUhkETO.png)
■Practice12
React Three Fiber Practice12 Plane Texture
![](https://assets.st-note.com/img/1705875407827-Qbq26y4bUG.png)
■Practice13
React Three Fiber Practice13 Sphere Texture
![](https://assets.st-note.com/img/1705875419762-mNzFTHUGIS.png)
■glTF Loader てすと?
変換失敗
GLTFLoader (forked)
![](https://assets.st-note.com/img/1705875427308-0xjWQBtKkM.png)
■Practice14
変換失敗
React Three Fiber Practice14 glTF Model01
![](https://assets.st-note.com/img/1705875438092-98wSh2nW2M.png)
以下、変換失敗時のエラーを記録しています。
Compiled with problems:
ERROR in ./src/App.js 18:0-45
Module not found: Error: You attempted to import ../public/yuusha.gltf which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
Failed to compile.
Module not found: Error: You attempted to import ../public/yuusha.gltf which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
ERROR in ./src/App.js 18:0-45
Module not found: Error: You attempted to import ../public/yuusha.gltf which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
webpack compiled with 1 error
■Practice15
変換失敗
React Three Fiber Practice15 glTF Model02
![](https://assets.st-note.com/img/1705875448405-cOwrMRhmRt.png)
以下、変換失敗時のエラーを記録しています。
Failed to compile.
Module not found: Error: You attempted to import ../public/yuusha.glb which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
ERROR in ./src/App.js 18:0-44
Module not found: Error: You attempted to import ../public/yuusha.glb which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
webpack compiled with 1 error
Compiled with problems:
ERROR in ./src/App.js 18:0-44
Module not found: Error: You attempted to import ../public/yuusha.glb which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
■Practice16
変換失敗
React Three Fiber Practice16 Multiple glTF Models
![](https://assets.st-note.com/img/1706110656713-YjwvnwHe5W.png)
以下、変換失敗時のエラーを記録しています。
Failed to compile.
Module not found: Error: You attempted to import ../public/yuusha.glb which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
ERROR in ./src/App.js 21:0-46
Module not found: Error: You attempted to import ../public/yuusha.glb which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
ERROR in ./src/App.js 22:0-46
Module not found: Error: You attempted to import ../public/souryo.glb which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
ERROR in ./src/App.js 23:0-46
Module not found: Error: You attempted to import ../public/soncho.glb which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
webpack compiled with 3 errors
Compiled with problems:
ERROR in ./src/App.js 21:0-46
Module not found: Error: You attempted to import ../public/yuusha.glb which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
ERROR in ./src/App.js 22:0-46
Module not found: Error: You attempted to import ../public/souryo.glb which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
ERROR in ./src/App.js 23:0-46
Module not found: Error: You attempted to import ../public/soncho.glb which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
■Practice17
React Three Fiber Practice17 glTF Model03
![](https://assets.st-note.com/img/1705875469652-2Y3pY9g3oX.png)
■Practice18
React Three Fiber Practice18 glTF Model04
![](https://assets.st-note.com/img/1705875480927-B6qoRnWFG5.png)
■Practice19
React Three Fiber Practice19 glTF Model05
![](https://assets.st-note.com/img/1705875494715-SAb7k9hiUE.png)
■Practice20
React Three Fiber Practice20 glTF Model06
![](https://assets.st-note.com/img/1705875503280-dCZ3LLWeKb.png)
■Practice21
React Three Fiber Practice21 glTF Model07
![](https://assets.st-note.com/img/1705875518841-RbWxyLrdiA.png)
■Practice22
React Three Fiber Practice22 glTF Model08
![](https://assets.st-note.com/img/1705875530895-OXxaDObH52.png)
■Practice23
React Three Fiber Practice23 glTF Model09
![](https://assets.st-note.com/img/1705875541160-GkvzP79gwK.png)
■Practice24
React Three Fiber Practice24 glTF Model10
![](https://assets.st-note.com/img/1705875552095-sEyyOnxKSE.png)
■Practice25
React Three Fiber Practice25 glTF Model Animation01
![](https://assets.st-note.com/img/1705875561815-UF2n4wrhQ4.png)
■Practice26
React Three Fiber Practice26 glTF Model Animation02
![](https://assets.st-note.com/img/1705875570999-XzhiWR0rLK.png)
■Practice27
React Three Fiber Practice27 glTF Model Animation03
![](https://assets.st-note.com/img/1705875580615-kYMBOBQzPL.png)
■Practice28
React Three Fiber Practice28 glTF Model Multiple Animations Change01
![](https://assets.st-note.com/img/1705936540304-frFiZ2rfXl.png)
■Practice29
React Three Fiber Practice29 glTF Model Multiple Animations Change02
![](https://assets.st-note.com/img/1705936527822-gnw6GnoZyB.png)
■Practice30
変換失敗 テクスチャが読み込めていない?
React Three Fiber Practice30 glTF Model Multiple Animations Change03
![](https://assets.st-note.com/img/1705936509743-XMtKj75BEo.png)
■Practice31
React Three Fiber Practice31 glTF Model Multiple Animations Change04
![](https://assets.st-note.com/img/1705936487982-rDJdLd5u4r.png)
■Practice32
React Three Fiber Practice32 glTF Model Animation04
![](https://assets.st-note.com/img/1705936462124-NOcwFyvR61.png)
■Practice33
React Three Fiber Practice33 glTF Model Animation05
![](https://assets.st-note.com/img/1705961192452-Hb3biuvz5q.png)
■Practice34
React Three Fiber Practice34 glTF Model Animation06
![](https://assets.st-note.com/img/1705961210016-luzdOmwDjh.png)
■Practice35
変換失敗 なぜだか3Dモデルがアニメーションしない
React Three Fiber Practice35 glTF Model Animation07
![](https://assets.st-note.com/img/1705961225076-MZFZy7a2aT.png)
■Practice36
React Three Fiber Practice36 glTF Model Animation08
![](https://assets.st-note.com/img/1705961246814-DFk0DBEVyb.png)
■Practice37
変換失敗 テクスチャが読み込めていない?
React Three Fiber Practice37 glTF Model Multiple Animations Change05
![](https://assets.st-note.com/img/1705961260062-LKyId0sk9Q.png)
■Practice38
変換失敗 謎エラーにて失敗
React Three Fiber Practice38 Cannon Physics Test01
![](https://assets.st-note.com/img/1705961452734-GgXGUjHAFX.png)
以下、変換失敗時のエラーを長々と記録しています。
yarn run v1.22.19 warning package.json: No license field $ vite The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details. Failed to resolve dependency: react/jsx-dev-runtime, present in 'optimizeDeps.include' Failed to resolve dependency: react/jsx-runtime, present in 'optimizeDeps.include'
VITE v5.0.12 ready in 447 ms
➜ Local: http://localhost:5173/ ➜ Network: use --host to expose ➜ press h + enter to show help Error: The following dependencies are imported but could not be resolved:
react/jsx-runtime (imported by /workspace/src/App.jsx)
Are they installed? at file:///workspace/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:65506:23 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async file:///workspace/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:64906:38
3:13:34 PM [vite] Pre-transform error: Failed to resolve import "react/jsx-dev-runtime" from "src/index.jsx". Does the file exist? 3:13:34 PM [vite] Pre-transform error: Failed to resolve import "react/jsx-dev-runtime" from "src/App.jsx". Does the file exist? 3:13:34 PM [vite] Pre-transform error: Failed to resolve import "react/jsx-dev-runtime" from "src/index.jsx". Does the file exist? 3:13:34 PM [vite] Pre-transform error: Failed to resolve import "react/jsx-dev-runtime" from "src/App.jsx". Does the file exist?
3:13:35 PM [vite] Internal server error: Failed to resolve import "react/jsx-dev-runtime" from "src/index.jsx". Does the file exist?
Plugin: vite:import-analysis File: /workspace/src/index.jsx:9:4
1 | import { jsxDEV } from "react/jsx-dev-runtime"; | ^ 2 | import React from "react"; 3 | import ReactDOM from "react-dom";
at formatError (file:///workspace/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:63768:46) at TransformContext.error (file:///workspace/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:63762:19) at normalizeUrl (file:///workspace/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:62037:33) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async file:///workspace/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:62191:47 at async Promise.all (index 0) at async TransformContext.transform (file:///workspace/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:62112:13) at async Object.transform (file:///workspace/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:64063:30) at async loadAndTransform (file:///workspace/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:49741:29) at async viteTransformMiddleware (file:///workspace/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:59342:32)
3:13:35 PM [vite] Pre-transform error: Failed to resolve import "react/jsx-dev-runtime" from "src/App.jsx". Does the file exist?
[plugin:vite:import-analysis] Failed to resolve import "react/jsx-dev-runtime" from "src/index.jsx". Does the file exist?
/workspace/src/index.jsx:9:4
1 | import { jsxDEV } from "react/jsx-dev-runtime";
| ^
2 | import React from "react";
3 | import ReactDOM from "react-dom";
at formatError (file:///workspace/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:63768:46)
at TransformContext.error (file:///workspace/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:63762:19)
at normalizeUrl (file:///workspace/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:62037:33)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///workspace/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:62191:47
at async Promise.all (index 0)
at async TransformContext.transform (file:///workspace/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:62112:13)
at async Object.transform (file:///workspace/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:64063:30)
at async loadAndTransform (file:///workspace/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:49741:29)
at async viteTransformMiddleware (file:///workspace/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:59342:32
Click outside, press Esc key, or fix the code to dismiss.
You can also disable this overlay by setting server.hmr.overlay to false in vite.config.ts.
この記事が気に入ったらサポートをしてみませんか?