Update picking and raycasting to use pick meshes and calculate accurate Y coordinates based on terrain height
This commit is contained in:
@@ -9145,7 +9145,7 @@ export class ViewportHost {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const renderObjects of this.terrainRenderObjects.values()) {
|
for (const renderObjects of this.terrainRenderObjects.values()) {
|
||||||
raycastObjects.push(renderObjects.mesh);
|
raycastObjects.push(...renderObjects.pickMeshes);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const renderGroup of this.modelRenderObjects.values()) {
|
for (const renderGroup of this.modelRenderObjects.values()) {
|
||||||
@@ -9186,11 +9186,25 @@ export class ViewportHost {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const terrain = this.getDisplayedTerrainState(terrainId);
|
||||||
|
const sourceHeight =
|
||||||
|
terrain === null
|
||||||
|
? null
|
||||||
|
: sampleTerrainHeightAtWorldPosition(
|
||||||
|
terrain,
|
||||||
|
hit.point.x,
|
||||||
|
hit.point.z,
|
||||||
|
true
|
||||||
|
);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
terrainId,
|
terrainId,
|
||||||
point: {
|
point: {
|
||||||
x: hit.point.x,
|
x: hit.point.x,
|
||||||
y: hit.point.y,
|
y:
|
||||||
|
terrain === null || sourceHeight === null
|
||||||
|
? hit.point.y
|
||||||
|
: terrain.position.y + sourceHeight,
|
||||||
z: hit.point.z
|
z: hit.point.z
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -9871,8 +9885,8 @@ export class ViewportHost {
|
|||||||
]).flat(),
|
]).flat(),
|
||||||
...Array.from(
|
...Array.from(
|
||||||
this.terrainRenderObjects.values(),
|
this.terrainRenderObjects.values(),
|
||||||
(renderObjects) => renderObjects.mesh
|
(renderObjects) => renderObjects.pickMeshes
|
||||||
),
|
).flat(),
|
||||||
...Array.from(this.modelRenderObjects.values()),
|
...Array.from(this.modelRenderObjects.values()),
|
||||||
...this.getBrushPickableObjects()
|
...this.getBrushPickableObjects()
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user