fix: 3D'解析失败'根因修复+错误信息可见
- watch immediate 首跑时 camera 未创建而 build() 触碰 camera → TypeError 被 catch 显示为'解析失败' 移除 build 内相机定位(每帧 loop 已定位, 首跑安全) - 移除 shadowMap.type 赋值(three r186 已移除 PCFSoft 常量) - 解析失败时显示真实错误信息(console+画布标注) - dist 重建, PCFSoft 赋值触发路径清零
This commit is contained in:
@@ -421,7 +421,6 @@ onMounted(() => {
|
||||
renderer = new THREE.WebGLRenderer({ canvas: cv, antialias: true, preserveDrawingBuffer: true })
|
||||
renderer.setSize(wrap.clientWidth, wrap.clientHeight)
|
||||
renderer.shadowMap.enabled = true
|
||||
renderer.shadowMap.type = THREE.PCFSoftShadowMap
|
||||
camera = new THREE.PerspectiveCamera(50, wrap.clientWidth / wrap.clientHeight, 0.01, 100)
|
||||
cv.addEventListener('mousedown', onDown)
|
||||
window.addEventListener('mousemove', onMove)
|
||||
@@ -430,7 +429,12 @@ onMounted(() => {
|
||||
cv.addEventListener('contextmenu', e => e.preventDefault())
|
||||
window.addEventListener('resize', onResize)
|
||||
watch(() => props.drawingData, () => {
|
||||
try { if (props.drawingData) build(parseDrawing(props.drawingData)) } catch { info.value = '解析失败' }
|
||||
try {
|
||||
if (props.drawingData) build(parseDrawing(props.drawingData))
|
||||
} catch (e) {
|
||||
console.error('[WindoorThreed] 构建/解析失败:', e)
|
||||
info.value = '解析失败: ' + (e as Error).message
|
||||
}
|
||||
}, { immediate: true })
|
||||
watch([lightMode], () => applyLight())
|
||||
loop()
|
||||
|
||||
Reference in New Issue
Block a user