<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<!-- <script src="http://www.yanhuangxueyuan.com/threejs/build/three.js"></script>
<script src="http://www.yanhuangxueyuan.com/threejs/examples/js/loaders/GLTFLoader.js"></script> -->
<script src="../build/three.js"></script>
<script src="../examples/js/loaders/GLTFLoader.js"></script>
<script src="../examples/js/exporters/GLTFExporter.js"></script>
<script src="../examples/js/controls/OrbitControls.js"></script>
<script src="../examples/js/utils/BufferGeometryUtils.js"></script>
</head>
<body>
<script>
const link = document.createElement( 'a' );
function save( blob, filename ) {
if ( link.href ) {
URL.revokeObjectURL( link.href );
}
link.href = URL.createObjectURL( blob );
link.download = filename || 'data.json';
link.dispatchEvent( new MouseEvent( 'click' ) );
}
function saveString( text, filename ) {
save( new Blob( [ text ], { type: 'text/plain' } ), filename );
}
//存放文件的gltf的Scene
let scene &#
合并mesh导致几何体位置不对的解决办法
最新推荐文章于 2024-07-16 17:13:30 发布
在处理gltf文件时遇到合并mesh导致的位置不正确问题,原因是仅考虑了geometry而忽略了mesh的世界坐标矩阵。解决方法是确保每个geometry与对应的世界坐标矩阵相乘,并且在遍历scene时,包括group在内的所有对象都需要更新其世界坐标矩阵。通过理解`updateMatrixWorld()`函数的工作原理,即对象世界矩阵等于父对象世界矩阵与自身本地矩阵的乘积,最终解决了模型比例和位置的调整问题。
摘要由CSDN通过智能技术生成