diff --git a/healthlink-his-ui/src/views/reconstruction/3d/viewer.vue b/healthlink-his-ui/src/views/reconstruction/3d/viewer.vue index bc831f1d5..96c0f39df 100644 --- a/healthlink-his-ui/src/views/reconstruction/3d/viewer.vue +++ b/healthlink-his-ui/src/views/reconstruction/3d/viewer.vue @@ -230,7 +230,9 @@ function init(){ // Generate volume const volData=genVolume() - const volTex=new THREE.DataTexture(volData,SZ,SZ,SZ,THREE.RedFormat,THREE.FloatType) + const volTex=new THREE.Data3DTexture(volData,SZ,SZ,SZ) + volTex.format=THREE.RedFormat + volTex.type=THREE.FloatType volTex.needsUpdate=true volTex.minFilter=THREE.LinearFilter volTex.magFilter=THREE.LinearFilter @@ -321,9 +323,19 @@ watch(mode,(val)=>{ }) onMounted(()=>{ - nextTick(()=>{ - setTimeout(init,100) + // Use ResizeObserver to init only when container has dimensions + const el=containerRef.value + if(!el)return + const ro=new ResizeObserver(entries=>{ + for(const e of entries){ + if(e.contentRect.width>0&&e.contentRect.height>0&&!renderer){ + init() + ro.disconnect() + break + } + } }) + ro.observe(el) window.addEventListener('resize',onResize) }) @@ -336,9 +348,9 @@ onUnmounted(()=>{