如何等待纹理完成从 Three.js 中的 JSON 模型加载? [英] How to wait for textures to finish loading from JSON model in Three.js?

查看:26
本文介绍了如何等待纹理完成从 Three.js 中的 JSON 模型加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个基于 AlteredQualia 的蒙皮示例成功加载的 JSON 模型.但是,在模型加载完成之前,我不想透露模型.正如你在这个例子中看到的,模型首先出现,然后它们的纹理资源随后加载:http:///alteredqualia.com/three/examples/webgl_animation_skinning_tf2.html

I have a JSON model being loaded successfully based on AlteredQualia's skinning example. However, I would like to not reveal the model until it is finished loading. As you can see in this example, the models appear first and then their texture resources load afterwards: http://alteredqualia.com/three/examples/webgl_animation_skinning_tf2.html

我在网页中添加了一个不透明的 div,然后使用 JSONloader.load() 函数的回调将该 div 移开.不幸的是,当网格被添加到场景中时会触发这个回调,这似乎并没有被仍在加载的蒙皮图像所阻挡,所以我最终揭示"了一个不完整的场景.

I added an opaque div to my webpage and then using the callback of the JSONloader.load() function I move that div out of the way. Unfortunately this callback is triggered when the mesh is added to the scene, which does not seem to be blocked by the skinning images still being loaded, so I end up "revealing" an incomplete scene.

我应该如何解决这个问题?我已经看到有一个函数 THREE.ImageUtils.loadTexture() 它有一个回调函数,但它似乎没有涉及到网格像这样声明和定义的用例:

How should I go about fixing this? I have seen that there is a function THREE.ImageUtils.loadTexture() which has a callback function but it does not seem to be involved in this use case where the mesh is declared and defined like so:

var mesh = new THREE.SkinnedMesh(geometry,new THREE.MeshFaceMaterial(materials));
//geometry and materials are both parameters of jsonloader.load callback

我查看了 MeshFaceMaterial 和 SkinnedMesh 的源代码,但在那里找不到解决方案.

I had a look at the source code of MeshFaceMaterial and SkinnedMesh but could not see a solution there.

感谢您提供的任何帮助.

Thanks for any assistance offered.

推荐答案

目前没有正确整理.目前在加载所有内容时没有回调或调度事件:/

This is currently not properly sorted out. At the moment there is no callback or event dispatched when everything is loaded :/

这篇关于如何等待纹理完成从 Three.js 中的 JSON 模型加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆