javascript - 三JS | 加载 OBJ 数据合并网格
问题描述
在我的 ThreeJS 应用程序中,我从本地服务器加载了一个 .OBJ 文件。例如,我现在想为每个子网格(子组件)赋予不同的颜色。
执行以下操作,ThreeJS 总是为多个网格着色:
var counter = 0;
object.traverse(function (child) {
if (child instanceof THREE.Mesh) {
//Also tested with if(counter == 300) or if (child.name == '625')...
if(child.id == 635){
var randomColor = '#' + (Math.random().toString(16)+'00000').slice(2,8)
child.material.color.set(randomColor);
}
counter++;
}
});
结果是:
然而,在您选择的 3D 模型查看器(我测试过 FreeCAD、Blender、Autodesk 和 Creo)中,每个组件似乎都是单一的,因为它应该是......:
这是怎么发生的?或者是否有我没有看到的导出选项?完整代码:https ://www.toptal.com/developers/hastebin/fosugibuni.php (不是很壮观)...
解决方案
推荐阅读
- c# - 提取我的应用程序的每个 XAML 页面的确切内容
- android - 如何为 png 或 svg 沿轮廓绘制阴影?
- javascript - JavaScript test() 方法改变返回值
- javascript - 从 json 数据中删除特定或选定的属性。我不想只删除具有 Category :null 的所有键值对
- javascript - 在 JavaScript 中单击另一个手风琴时删除活动的手风琴
- ios - UICollectionViewCell - 将不同的 CAGradientLayer 应用于不同的 UIView
- kubernetes - 如何在 openshift 中获取最新部署的修订版?
- java - Tomcat7 SESSIONID在应用redis RedisSessionManager应用后不断变化
- windows - 如何停止文件资源管理器运行?
- java - 从 ExternalFilesDir 访问时出现随机 Permission Denied 错误