在模型的另一侧可见三JS网格 [英] Three-JS Mesh visible on opposite side of model

查看:98
本文介绍了在模型的另一侧可见三JS网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我使用的是在搅拌器中为ThreeJS制作的自定义模型。我将它导出到.obj文件并使用Three-js转换实用程序生成json文件。我把它设置为旋转,当它旋转时,你可以看到模型的另一面。
这是我用来加载它的代码:

So I'm using a custom model made in blender for ThreeJS. I exported it to a .obj file and used the Three-js conversion utility to make a json file. I have it set to rotate, and as it rotates, you can see the other side of the model. This is the code I'm using to load it:

  loader.load("pegnin.js", function(geometry, materials){
    material = new THREE.MeshPhongMaterial( {
      color: 0xff0000,
      polygonOffset: true,
      polygonOffsetFactor: 1, // positive value pushes polygon further away
      polygonOffsetUnits: 1
    });
    material.depthTest = true;
    mesh = new THREE.Mesh(geometry, material);
    scene.add(mesh);
  });

现场演示

推荐答案

three.js假设前脸有逆时针绕线顺序。换句话说,three.js中的前脸由面部的缠绕顺序决定 - 而不是面部正常。

three.js assumes that front-faces have counter-clockwise winding order. Stated another way, the front-face in three.js is determined by the winding order of the face -- not the face normal.

可能是正面在您的模型中有顺时针缠绕顺序。

It is likely that front-faces in your model have clockwise winding order.

不需要您更改模型的解决方法是设置:

A work-around that does not require you to change your model is to set:

mesh.material.side = THREE.DoubleSide;

three.js r.85

three.js r.85

这篇关于在模型的另一侧可见三JS网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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