如何在使用three.js和jsonLoader的同时制作加载屏幕? [英] How to make a loading screen while using three.js and jsonLoader?

查看:95
本文介绍了如何在使用three.js和jsonLoader的同时制作加载屏幕?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有大量的纹理文件和模型要加载到我的项目中.我正在尝试在加载所有内容时显示状态栏或某种加载屏幕.如果有人能给我有关如何执行此操作的任何信息,那将是非常棒的.

I have a very large amount of texture files and models to load into my project. I am trying to show a status bar or some sort of loading screen while everything is loading. If anyone could give me any info on how to do this that would be awesome.

谢谢!

推荐答案

您可以使用以下模式来管理加载过程:

You can use a pattern like this to manage the loading process:

var manager = new THREE.LoadingManager();

manager.onStart = function( item, loaded, total ) {

    console.log( 'Loading started' );

};

manager.onLoad = function() {

    console.log( 'Loading complete' );

};

manager.onProgress = function( item, loaded, total ) {

    console.log( item, loaded, total );

};

manager.onError = function( url ) {

    console.log( 'Error loading' );

};

var loader = new THREE.TextureLoader( manager );

var texture = loader.load( 'texture.jpg', function ( texture ) {

    texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
    texture.repeat.set( 2, 2 );

} );

var loader = new THREE.OBJLoader( manager );

loader.load( 'file.obj', function( object ) {

    // your code

 } );

three.js r.85

three.js r.85

这篇关于如何在使用three.js和jsonLoader的同时制作加载屏幕?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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