express - 使用nodejs express将gltf结果加载到404(未找到)的threejs
问题描述
我知道这是常见错误,但我尝试了 stackoverflow 中的答案,但它不起作用。我正在从本教程加载一个 gltf 文件:https ://threejsfundamentals.org/threejs/lessons/threejs-load-gltf.html
我使用 nodejs express 作为我的服务器,我的目录结构是
where in public 设置为这样的公用文件夹
app.use(express.static('public'));
公共文件夹内包含必要的threejs库文件和GLTF加载器,因此由于公共文件夹已经是“公共”并且公开了它还包含资产或gltf文件
但是,从该目录加载 gltf 文件时,结果为 404。
const loader = new GLTFLoader();
loader.load('assets/city/scene.gtlf',
(gltf) => {
const root = gltf.scene;
scene.add(root);
},
(xhr)=>{
},
(error)=>{
console.log(error);
});
我在这里缺少什么?
解决方案
推荐阅读
- apache - pi raspbian buster apache2 www-data 禁止在不同的目录 2021
- javascript - 系统信息仅待处理,在vue中不显示任何结果
- .htaccess - htaccess 删除 php 以获得干净的 SEO 友好 url
- c# - MVVC - 使用 ViewBag 和控件传递参数的问题
- c# - 使用部分类添加注释/元数据
- c# - .NET Core 控制台的 AcquireTokenInteractive 不提供响应
- javascript - jQuery Confirm3 $.confirm 既不返回布尔值也不返回预期结果
- javascript - Charts.js - 值间隔的条形图不同颜色不起作用
- javascript - Onclick 侦听器和单击触发器不起作用
- ssis - SSIS 包在 SIT 环境中失败