用於導入模型后,自動調整模型的縮放比例
//適合模型觀察的縮放比例 setScaleToFitSize(obj) { const boxHelper = new THREE.BoxHelper(obj); boxHelper.geometry.computeBoundingBox(); const box = boxHelper.geometry.boundingBox; const maxDiameter = Math.max((box.max.x - box.min.x), (box.max.y - box.min.y), (box.max.z - box.min.z)); const scaleValue = this.camera.position.z / maxDiameter; obj.scale.set(scaleValue, scaleValue, scaleValue); }