使用JSONloader加载纹理 [英] Loading textures with JSONloader

查看:138
本文介绍了使用JSONloader加载纹理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新手,我想我错过了一些事情.
有人可以检查吗?
HTML页面: http://xalien95.altervista.org/pkmnxy_engine/alisopoli.html
模型和纹理: http://xalien95.altervista.org/pkmnxy_engine/alisopoli/
我可以看到模型(具有怪异的颜色),但看不到纹理(它是具有多种材质的网格).

预先感谢!

I'm a newbie, and I think I missed something.
Could someone check, please?
HTML page: http://xalien95.altervista.org/pkmnxy_engine/alisopoli.html
MODEL and TEXTURES: http://xalien95.altervista.org/pkmnxy_engine/alisopoli/
I can see the model (with weird colors), but not the textures (it's a mesh with multiple materials).

Thanks in advance!

我尝试了所有材料类型:

I tried with all the materials types:

  • 三个.MeshBasicMaterial
  • THREE.MeshDepthMaterial
  • THREE.MeshLambertMaterial
  • THREE.MeshNormalMaterial
  • 三.网状材料

但是没人能工作,所以我想我错过了一些东西(或者材料途径不一样). 这是脚本:

But noone works, so I think I've missed something (or the materials path is different). Here's the script:

var camera, scene, renderer, mesh, loader;

        init();
        animate();

        function init() {

            camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 1, 10000 );
            camera.position.z = 1000;

            scene = new THREE.Scene();

            loader = new THREE.JSONLoader();

            loader.load( "./alisopoli/alisopoli.js", function( geometry, materials ) {
                var faceMaterial = new THREE.MeshPhongMaterial( materials );
                mesh = new THREE.Mesh( geometry, faceMaterial );
                mesh.scale.set( 100, 100, 100 );
                mesh.position.y = -150;
                mesh.position.x = 0;
                mesh.rotation.x = 60;
                scene.add( mesh );
            } );


            var ambientLight = new THREE.AmbientLight(0x555555);
            scene.add(ambientLight);

            //var directionalLight = new THREE.DirectionalLight(0xffffff);
            //directionalLight.position.set(1, 1, 1).normalize();
            //scene.add(directionalLight);

            renderer = new THREE.WebGLRenderer();
            renderer.setSize( window.innerWidth, window.innerHeight );

            document.body.appendChild( renderer.domElement );

        }

        function animate() {

            requestAnimationFrame( animate );

            //mesh.rotation.y += 0.005;

            renderer.render( scene, camera );
        }

提前谢谢!

推荐答案

奇怪的颜色是因为在加载过程中为每个网格分配了"MeshNormalMaterial".您应该检查three.js json加载器示例,或者以某种方式获取正确的材料,而不是将MeshNormalMaterials分配给子网格

The weird colors are because you are assigning every mesh a "MeshNormalMaterial" during your load. You should check the three.js json loader examples or somehow get the correct material instead of assignen MeshNormalMaterials to the sub-meshes

这篇关于使用JSONloader加载纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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