Align outdoor tree footprints in 2D editor

This commit is contained in:
sudhir
2026-04-29 13:45:09 +05:30
parent 2b588cd30f
commit 3c185144e0
+38 -3
View File
@@ -139,6 +139,21 @@ export function buildFloorplanItemEntry(
return null
}
const dimensionPolygon = getItemDimensionPolygon(item, transform)
const [width, , depth] = getScaledDimensions(item)
if (shouldUseDimensionFloorplanFootprint(item)) {
return {
dimensionPolygon,
item,
polygon: dimensionPolygon,
usesRealMesh: true,
center: transform.position,
rotation: transform.rotation,
width,
depth,
}
}
const object = sceneRegistry.nodes.get(item.id)
const realMeshPolygon = object
? getRealMeshFloorplanPolygon(transform, object)
@@ -147,9 +162,6 @@ export function buildFloorplanItemEntry(
return null
}
const dimensionPolygon = getItemDimensionPolygon(item, transform)
const [width, , depth] = getScaledDimensions(item)
return {
dimensionPolygon,
item,
@@ -167,6 +179,29 @@ type Point = {
y: number
}
const DIMENSION_FOOTPRINT_ASSET_IDS = new Set(['tree', 'fir-tree', 'palm', 'bush'])
const DIMENSION_FOOTPRINT_TAGS = new Set([
'botanical',
'foliage',
'greenery',
'plant',
'tree',
'vegetation',
])
function shouldUseDimensionFloorplanFootprint(item: ItemNode) {
const asset = item.asset
if (asset.category !== 'outdoor') {
return false
}
if (DIMENSION_FOOTPRINT_ASSET_IDS.has(asset.id)) {
return true
}
return asset.tags?.some((tag) => DIMENSION_FOOTPRINT_TAGS.has(tag.toLowerCase())) ?? false
}
function getItemDimensionPolygon(item: ItemNode, transform: FloorplanNodeTransform): Point[] {
const [width, , depth] = getScaledDimensions(item)
const centerLocalZ = item.asset.attachTo === 'wall-side' ? -depth / 2 : 0