将 3D 模型转换为 SceneJS JSON,包括纹理

发布于 2024-12-09 02:18:16 字数 1581 浏览 1 评论 0原文

动机
我正在尝试使用 WebGL 创建一个小型演示应用程序。我选择使用 SceneJS,因为它看起来是一个简单的框架,并且足以满足此目的。

我已经下载了几个 .blend 模型 (Amy Rose 等)并使用 Blender 将它们导出为 Collada (.dae) 文件。然后我使用 scenejs-pycollada 将它们转换为 json 模型。

我刚刚花了几个小时让 scenejs-pycollada 转换器正常工作。显然,如果您以前从未使用过 Python,那么让这些 Python 依赖项在 Windows 中运行并不是那么容易。 ;)

问题
但现在我(再次)陷入困境。我的问题是模型没有任何纹理或材质。

我使用了 SceneJS 的 Seymour 平面示例。我转换的模型几乎不可见。它是黑色的,似乎对场景中的灯光没有反应。如果我将飞机和模型一起加载,我可以看到模型已加载,因为它的手臂和腿伸出飞机。

现在,我遵循了几个教程,可以将纹理导出为 PNG 图像。然后我修改了 JSON 模型中的纹理文件名以匹配文件名,但没有帮助。

所以我希望有人可以帮助我找到一种方法将 Blender 模型(或其他常见的 3D 模型)导出为 SceneJS 使用的 JSON 格式,包括纹理。

在 SceneJS 中加载模型的任何其他方法也可以,只要它有效。

如果有人有免费下载身体/人物 JSON 模型的链接,那现在会有帮助,但我宁愿了解它是如何工作的。 :)

我正在使用

  • Windows 7 Home Premium 64 位
  • Python 2.7 (Windows 32 位)
    我选择了 32 位版本,因为似乎对库有更好的支持,并且有更多可用的安装程序。起初我混淆了 32 位和 64 位,这给我带来了麻烦,但现在一切似乎都正常(除了纹理)。
  • Blender 2.59
  • SceneJS 0.8.0

我的工作流程
在 Blender 中,我将模型导出到 Collada (*.dae) 文件,然后使用 scenejs-pycollada 将它们转换为原始 JSON。这给了我一个包含两个对象的 JSON 文件。第一个似乎是场景,第二个似乎是模型。我保留第二个并将其放入 SceneJS 示例代码中使用的 Javascript 变量中。该模型以属性 , "type": "library", "parent": "Scene" 结尾,我需要从代码中删除这些属性才能加载它。

Motive
I'm trying to create a small demo application using WebGL. I chose to use SceneJS, because it seemed an easy framework and would more than suffice for this purpose.

I have downloaded a couple of .blend models (Amy Rose, amongst others) and exported them as a Collada (.dae) file using Blender. Then I used scenejs-pycollada to convert them to a json model.

I just spent a couple of hours getting the scenejs-pycollada convertor to work. Apparently getting those Python dependencies to work in Windows isn't that easy if you've never used Python before. ;)

Problem
But now I'm stuck (again). My problem is that the models don't have any textures or materials.

I used the Seymour Plane Example of SceneJS. The model I converted is hardly visible. It is black and doesn't seem to respond to the lighting in the scene. If I load the plane and the model together, I can see the model is loaded, because its arms and legs are sticking out of the plane.

Now I followed a couple of tutorials that would let me export the texture as a PNG image. I then modified the texture file name in the JSON model to match the file name, but it doesn't help.

So I hope someone can help me to find a way to export Blender models (or other common 3D models) to the JSON format used by SceneJS, including the textures.

Any other method of loading models in SceneJS will do too, as long as it works.

If one 's got a link to free downloads of body/figure JSON models, that would help for now, but I rather learn how this works. :)

I'm using

  • Windows 7 Home Premium 64bit
  • Python 2.7 (Windows 32bit)
    I chose the 32 bit version, because of seemingly better support for libraries, and more available installers. At first I mixed up 32 and 64 bit and it caused me trouble, but now everything seems to work (except for the textures, that is).
  • Blender 2.59
  • SceneJS 0.8.0

My workflow
In Blender I export the models to Collada (*.dae) files, and then convert them to Raw JSON using scenejs-pycollada. This gives me a JSON file with two objects in it. The first seems to be the scene, the second the model. I keep the second and put it in a Javascript variable that is used in the code of the SceneJS example. The model ends with the properties , "type": "library", "parent": "Scene" which I need to remove from the code to make it load at all.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

献世佛 2024-12-16 02:18:16

我实际上是 scenejs-pycollada 的作者。让我看看是否可以帮助你:)

我看到你正在使用 SceneJS 的 0.8 版本...事情一直在不断变化,所以实际上可能最容易拉 来自 github 的 SceneJS 2.0 分支 和来自我的 个人仓库。我基本上将 SceneJS 0.9 定位为 scenejs-pycollada 的第一个版本,但该版本从未正式发布。另外,从长远来看,如果你现在就切换的话,你将不必重写所有内容......

有问题的 Windows 编译也是一个大刺,我真的希望 numpy 开发人员能为你的 Windows 人员解决这个问题。一旦 SceneJS 2.0 发布,我将发布 scenejs-pycollada 的正式版本,其中包含 Windows 所需的所有依赖项。

因此,请随意对此答案发表评论或更新您的问题。我会尽力关注它。

PS 或者,如果您真的感到沮丧,我实际上在 https:// github.com/rehno-lindeque/Blender-WebGL-exporter,但我不建议使用这个 - 它已经过时了。唯一的另一个 scenejs collada 导出器很久以前就被弃用了。

PPS scenejs-pycollada 本身也有示例和一些测试模型。如果您只想快速使用模型,请查看 https:// github.com/rehno-lindeque/scenejs-pycollada/tree/master/example 尽管不可否认它不是有史以来最漂亮的模型。

PPPS 实际上,Amy Rose 模型不适合您的原因之一是 scenejs-pycollada 尚不支持多种材质。今晚我很快就会对此添加一些支持。

I'm actually the author of scenejs-pycollada. Let me see if I can help you :)

I see you're using version 0.8 of SceneJS... Things have been rather in flux, so it might actually easiest to pull the 2.0 branch of SceneJS from github and scenejs-pycollada from my personal repo. I was basically targeting SceneJS 0.9 for the first release of scenejs-pycollada, but that version never got officially released. Also, in the long run you won't have to rewrite everything if you just switch over now...

The problematic windows compile is also a big thorn, I really wish the numpy devs would fix this up for you windows folk. Once SceneJS 2.0 is released I'll release an official version of scenejs-pycollada that comes packaged with all the necessary dependencies for windows.

So, feel free to comment on this answer or update your question. I'll try to keep an eye on it.

P.S. Alternatively, if you're really frustrated I actually have a second blender exporter at https://github.com/rehno-lindeque/Blender-WebGL-exporter, but I don't recommend using this one - it's very outdated. The only other scenejs collada exporter was deprecated a long time ago.

P.P.S. There's also and example and some test models in scenejs-pycollada itself. If you just want a quick model to play with, check out https://github.com/rehno-lindeque/scenejs-pycollada/tree/master/example although admittedly it's not the prettiest model ever.

P.P.P.S. Actually one of the reasons why the Amy Rose model wasn't working well for you is because scenejs-pycollada didn't support multiple materials yet. I'm quickly adding some support for this tonight.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文