【发布时间】:2020-07-07 01:39:47
【问题描述】:
无论我尝试导入什么类型的文件,我都不会让它显示在我的画布中。
我尝试过的:
- 在 3D 查看器、巴比伦沙箱和搅拌机中打开文件,那里 模型没有错
- 使用加载器导入模型后上下缩放模型 (是的,导入成功,没有控制台错误和 onSuccess 回调被调用),因为我认为这可能只是方式 太大或太小,相机无法拍摄。
- 不同的文件格式(.babylon、.glb、.obj)
- 所有不同类型的 SceneLoader 函数,(导入网格、追加...)
这是我的代码:
import { SceneLoader, Scene } from "babylonjs";
import "babylonjs-loaders";
const importFile = (
path: string,
fileName: string,
ext: string,
scene: Scene
) => {
console.log(SceneLoader.IsPluginForExtensionAvailable(ext));
SceneLoader.ImportMeshAsync("", path, fileName + ext, scene).then((meshes) =>
// this actually does log some object with a bunch of fields, which dont seem to help me
identify the problem. Maybe someone knows what kind of info that could give me.
console.log(meshes)
);
};
//specific Model being loaded
export const createChessBoard = (scene: Scene) => {
importFile("/home/tom/Models/", "ChessBoard", ".obj", scene);
};
这里被调用
// the rest of the scene
const scene = new Scene(engine);
const camera = new ArcRotateCamera(
"Camera",
Math.PI / 2,
Math.PI / 2,
2,
Vector3.Zero(),
scene
);
if (canvas) {
camera.attachControl(canvas, true);
}
const light1 = new HemisphericLight(
"ambientlight",
new Vector3(1, 1, 0),
scene
);
const light2 = new PointLight("spotlight", new Vector3(0, 1, -1), scene);
createChessBoard(scene);
使用 MeshBuilder 创建相机、场景和所有这些或形状可以完美地工作。我在任何地方都找不到任何人在使用加载器时遇到问题......通常他们被高度赞扬为如此轻松地工作,我希望有人能帮助我解决这个问题,因为巴比伦看起来像一个很酷的图书馆
【问题讨论】:
标签: babylonjs