|
|
@@ -768,12 +768,29 @@ function createTilesetCullingController(scene, plans, instances, failed, onChang
|
|
|
},
|
|
|
})
|
|
|
region.setPipeline(regionPipeline)
|
|
|
+ const lowModels = []
|
|
|
const unmask = model.tileVisible.addEventListener(tile => {
|
|
|
if (tile.content?.trianglesLength > 0) coarseRendered = true
|
|
|
const c = tile.content
|
|
|
if (c?.featuresLength === 1) { const feature = c.getFeature(0); feature.show = !region.detailReady(feature.getProperty('region')) }
|
|
|
+ // 粗模批次每个 tile 就是一个区域(coarse-<id>-*.glb),但 GLB 内含多个 primitive,
|
|
|
+ // featuresLength 不一定为 1,仅靠 feature 遮罩会失效,导致粗模与明细两套模型同位置重叠。
|
|
|
+ // 因此按 tile URL 解析 region,直接隐藏/恢复整个粗模模型。
|
|
|
+ const coarseMatch = /coarse-(\d+)-/.exec(c?.url || '')
|
|
|
+ if (coarseMatch && c?._model) c._model.show = !region.detailReady(Number(coarseMatch[1]))
|
|
|
+ // preview/medium 低模与 fine 精模同样会共面重叠;记下低模实例,fine 可见时按帧隐藏。
|
|
|
+ const detailMatch = /region-(\d+)\//.exec(c?.url || '')
|
|
|
+ if (detailMatch && c?._model && /\/(preview|medium)-\d+\.glb$/.test(c.url) && !lowModels.some(item => item.model === c._model)) {
|
|
|
+ lowModels.push({ model: c._model, region: Number(detailMatch[1]) })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ const detachFrame = scene.postRender.addEventListener(() => {
|
|
|
+ region.onRender()
|
|
|
+ for (const item of lowModels) {
|
|
|
+ const visible = !region.fineVisible(item.region)
|
|
|
+ if (item.model && item.model.show !== visible) item.model.show = visible
|
|
|
+ }
|
|
|
})
|
|
|
- const detachFrame = scene.postRender.addEventListener(region.onRender)
|
|
|
regionControllers.set(model, region)
|
|
|
regionHandles.push({ region, detachFrame, unmask })
|
|
|
region.refresh()
|