作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我将一个 3D 模型从 Sketchup 导出到 collada 并使用 Threejs Collada 加载器加载它。但我收到以下警告:
THREE.DirectGeometry.fromGeometry(): Undefined vertexUv 2
Uncaught TypeError: Cannot read property '0' of undefined (12:59:20:764 | error, javascript)
at raycast (public_html/libs/three.js:17237:19)
at intersectObject (public_html/libs/three.js:7678:10)
at intersectObject (public_html/libs/three.js:7686:5)
at intersectObject (public_html/libs/three.js:7686:5)
at intersectObject (public_html/libs/three.js:7686:5)
at THREE.Raycaster.intersectObject (public_html/libs/three.js:7734:4)
at adjustCameraPositionForCollision (public_html/PointerLockControls.js:302:86)
at update (public_html/PointerLockControls.js:257:14)
at render (public_html/simbuilding.js:113:24)
最佳答案
您可以尝试将 Uvs 分配给您的几何体
assignUVs(geometry) {
geometry.computeFaceNormals();
geometry.mergeVertices();
geometry.faceVertexUvs[0] = [];
geometry.faces.forEach((face) => {
const components = ['x', 'y', 'z'].sort((a, b) => {
return Math.abs(face.normal[a]) > Math.abs(face.normal[b]);
});
const v1 = geometry.vertices[face.a];
const v2 = geometry.vertices[face.b];
const v3 = geometry.vertices[face.c];
geometry.faceVertexUvs[0].push([
new THREE.Vector2(v1[components[0]], v1[components[1]]),
new THREE.Vector2(v2[components[0]], v2[components[1]]),
new THREE.Vector2(v3[components[0]], v3[components[1]])
]);
});
geometry.uvsNeedUpdate = true;
return geometry;
}
关于three.js - 未定义的 vertexUv 警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33154369/
我将一个 3D 模型从 Sketchup 导出到 collada 并使用 Threejs Collada 加载器加载它。但我收到以下警告: THREE.DirectGeometry.fromGeome
我是一名优秀的程序员,十分优秀!