Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

一些Bug和我的解决 #6

Open
wzh656 opened this issue Jan 28, 2024 · 0 comments
Open

一些Bug和我的解决 #6

wzh656 opened this issue Jan 28, 2024 · 0 comments

Comments

@wzh656
Copy link

wzh656 commented Jan 28, 2024

1.ShaderTest.ts构建时报错

我先用git clone后,
(我使用的是pnpm
直接执行pnpm vite可以运行
执行pnpm run build
src/core/components/ShaderTest.ts报错

src/core/components/ShaderTest.ts(2,125): error TS2307: Cannot find module "../libs/xviewer" or its corresponding type declarations.
src/core/components/ShaderTest.ts(35,14): error TS2339: Property "viewer" does not exist on type "ShaderTest".
src/core/components/ShaderTest.ts(46,14): error TS2339: Property "viewer" does not exist on type "ShaderTest".
src/core/components/ShaderTest.ts(52,33): error TS2304: Cannot find name "cameraCenter".
src/core/components/ShaderTest.ts(53,34): error TS2304: Cannot find name "cameraCenter".

我的解决:

  • 将第2行的../libs/xviewer改为../../libs/xviewer(路径错误)
-import { Color, Mesh, MeshPhysicalMaterial, PlaneGeometry, Plugin, ShaderMaterial, SphereGeometry, Vector3, property } from "../libs/xviewer";
+import { Color, Mesh, MeshPhysicalMaterial, PlaneGeometry, Plugin, ShaderMaterial, SphereGeometry, Vector3, property } from "../../libs/xviewer";
  • 注释掉第52~53行(cameraCenter未知报错)
-this.mesh.position.copy(cameraCenter.clone().add(new Vector3(0, -10, -100)))
-this.plane.position.copy(cameraCenter.clone().add(new Vector3(30, -27, -100)))
+//this.mesh.position.copy(cameraCenter.clone().add(new Vector3(0, -10, -100)))
+//this.plane.position.copy(cameraCenter.clone().add(new Vector3(30, -27, -100)))

2.文件路径报错

打包到dist文件夹后,直接pnpm run preview可以正常运行,但是将dist放到自己的服务器下运行时资源路径会出现错误
(一些png, mp3文件路径/Genshin/*被直接定向至域名下的根目录localhost:8080/Genshin/*,而实际路径为localhost:8080/www-genshin/Genshin/*

我的解决:

  • vite.config.ts配置文件中修改为相对路径
export default defineConfig({
+  base: "./",
  plugins: [react()],
})
  • 修改src/pages/Menu.tsx中引用的jump.png文件路径(第45行)
-backgroundImage: `url("/Genshin/jump.png")`
+backgroundImage: `url("./Genshin/jump.png")`
  • 修改src/core/Game.ts中引用的mp3文件路径(第191~194行)
-AssetManager.Load({ url: "/Genshin/BGM.mp3" });
-AssetManager.Load({ url: "/Genshin/Genshin Impact [Duang].mp3" });
-AssetManager.Load({ url: "/Genshin/Genshin Impact [DoorThrough].mp3" });
-AssetManager.Load({ url: "/Genshin/Genshin Impact [DoorComeout].mp3" });
+AssetManager.Load({ url: "./Genshin/BGM.mp3" });
+AssetManager.Load({ url: "./Genshin/Genshin Impact [Duang].mp3" });
+AssetManager.Load({ url: "./Genshin/Genshin Impact [DoorThrough].mp3" });
+AssetManager.Load({ url: "./Genshin/Genshin Impact [DoorComeout].mp3" });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant