修改模型前端代码

This commit is contained in:
shaoleiliu-netizen123 2026-06-22 14:27:12 +08:00
parent a9ce1a4f77
commit 284775bd9c
2 changed files with 19 additions and 9 deletions

View File

@ -45,7 +45,7 @@ export const plmModelApi = {
url: '/biz/plm/model/preview',
method: 'get',
params,
timeout: 120000,
timeout: 360000,
})
},
}

View File

@ -46,8 +46,10 @@ let animationId = null
let currentModel = null
let dracoLoader
let gltfLoader
let defaultCameraPosition = new THREE.Vector3(0,0,9)
let defaultTarget = new THREE.Vector3(0,0,0)
let resetCameraPos = new THREE.Vector3()
let resetLookTarget = new THREE.Vector3()
let grid = new THREE.GridHelper(200,20,0x666666,0xdcdcdc)
function resolveUrl(modelUrl) {
@ -100,10 +102,7 @@ const initScene = () => {
const fillLight = new THREE.DirectionalLight(0xffffff, 0.35)
fillLight.position.set(-200, -100, -200)
scene.add(fillLight)
const grid = new THREE.GridHelper(10, 20, 0xcccccc, 0xe8e8e8)
scene.add(grid)
// scene.add(grid)
controls = new OrbitControls(camera, renderer.domElement)
controls.enableDamping = true
@ -149,6 +148,16 @@ const fitModelToView = (model) => {
camera.updateProjectionMatrix()
controls.target.set(0, 0, 0)
controls.update()
// 2.5
const gridSize = Math.ceil(maxDim * 2.5)
//
const gridDivisions = Math.max(10, Math.floor(gridSize / 10))
grid = new THREE.GridHelper(gridSize, gridDivisions, 0x666666, 0xdcdcdc)
scene.add(grid)
resetCameraPos.copy(camera.position)
resetLookTarget.copy(controls.target)
}
const loadModel = () => {
@ -225,8 +234,9 @@ const onWindowResize = () => {
function resetView() {
if (!camera || !controls) return
camera.position.copy(defaultCameraPosition)
controls.target.copy(defaultTarget)
camera.position.copy(resetCameraPos)
controls.target.copy(resetLookTarget)
camera.updateProjectionMatrix()
controls.update()
}