【问题标题】:How do I attach a texture to JSON object in Three.js?如何在 Three.js 中将纹理附加到 JSON 对象?
【发布时间】:2015-04-24 13:16:11
【问题描述】:

如何在 Three.js 中将纹理附加到 JSON 对象? 谁来帮帮我。请在下面查看我的无能电源线。

var texture  = new THREE.ImageUtils.loadTexture('panel.png');   
texture.wrapS = THREE.RepeatWrapping;
texture.wrapT = THREE.RepeatWrapping;
texture.repeat.set( 1, 1 );

var loader = new THREE.JSONLoader();
    loader.load( 'panel.json', function ( geometry ) {
    model = new THREE.Mesh( geometry, new THREE.MeshPhongMaterial( {map: texture} ) );
    scene.add( model )
} );

【问题讨论】:

    标签: javascript json three.js


    【解决方案1】:

    试试下面的代码,在你的 json 文件中定义材质。

    var loader = new THREE.JSONLoader();
        loader.load( 'panel.json', function ( geometry, material ) {
            model = new THREE.Mesh( geometry, material);
            scene.add( model )
        }, 'panel.png');
    

    【讨论】:

    • 嗨,user4814065。感谢您的回复!但它并没有很好地工作...... Json 的对象出现了没有纹理的着色。我不知道为什么,每次重新加载都会改变颜色。
    • 向我发送 json 文件
    • 你在 Json 中设置了 UV 吗?
    • 这是我的 Blender 的 JSON 文件。没有紫外线...link
    • 在Json文件中添加素材
    猜你喜欢
    • 2018-06-30
    • 2018-05-13
    • 1970-01-01
    • 2018-03-25
    • 1970-01-01
    • 2015-03-12
    • 1970-01-01
    • 2013-10-02
    • 1970-01-01
    相关资源
    最近更新 更多