如何使用VRMLLoader在从Blender导出为wrl并导入到threejs的网格上应用纹理

时间:2019-05-03 15:18:34

标签: three.js blender vrml

我已经从Blender中导出了一个简单的盒子网格作为wrl。我也有“智能紫外线解开”网格。我仅将此网格用于其几何形状,并通过threejs应用材料。然后,我将纹理与导入的网格绑定,并且还将材质(MeshPhongMaterial)的needsUpdate属性设置为true。

结果如下:

enter image description here

应用的纹理:

enter image description here

代码摘录如下:

function generateCustomTHREEMeshFromWRL(name) {
    return vrmlLoader.parse(getResource(name).content).children[0]
    //the getResource(name).content returns the entire wrl file content
}
mesh = generateCustomTHREEMeshFromWRL('unwrapped.wrl')  
mesh.material.map = textureLoader.load('lavatile.jpg')
mesh.material.needsUpdate = true;
scene.add(mesh)

WRL文件如下:

#VRML V2.0 utf8
#modeled using blender3d http://blender.org

# 'Cube'
Shape {
    appearance Appearance {
        material Material {
        }
    }
    geometry IndexedFaceSet {
        coord Coordinate {
            point [ -1.000000 -1.000000 1.000000 -1.000000 -1.000000 -1.000000 1.000000 -1.000000 -1.000000 1.000000 -1.000000 1.000000 -1.000000 1.000000 0.999999 -0.999999 1.000000 -1.000001 1.000000 1.000000 -1.000000 1.000000 1.000000 1.000000 ]
        }
        colorPerVertex FALSE
        color Color {
            color [ 0.80 0.80 0.80 ]
        }
        colorIndex [ 0 0 0 0 0 0 0 0 0 0 0 0 ]
        coordIndex [ 1 3 0 -1 7 5 4 -1 4 1 0 -1 5 2 1 -1 2 7 3 -1 0 7 4 -1 1 2 3 -1 7 6 5 -1 4 5 1 -1 5 6 2 -1 2 6 7 -1 0 3 7 -1 ]
    }
}

这是我在搅拌机中执行的动作的一瞥 enter image description here

0 个答案:

没有答案