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

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

问题描述

我有一个基于AlteredQualia的skinning示例成功加载的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的回调)function我把那个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.

感谢您提供任何帮助。

推荐答案

适当整理出来。目前,在加载所有内容时,没有调用回调或事件:/

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天全站免登陆