3D object placement

Hello All,
I was thinking whether placement of 3D objects can be done as shown in games using three.js or A-Frame.js. Like you try to build a building on a playground but it won’t place your building if there is a tree in that position. Specifically speaking what could be the logic to determine that and how am I gonna define that tree in an empty canvas.
Please help.

You better start with the examples, it sounds like you just started with THREE.

Basically you need a spatial managed scene, speaking of octrees to track down your objects very fast, a simple way would be to use a raycaster against the scene, but this means all your checking has to be done against all objects. If your world is small, it might be ok for you without extra management.

To place the object (the position first) you can use a raycaster, feeding a list of your ground objects (a plane for example), at the resulting position you can use for a simple check the bounding box of the object’s geometry you want to place, and test it with the surrounding ones around the raycast position (this requires to apply the matrix of each, but there is a simple library for basic shape collisions too). With a spatial manager you can minimize the number of computations massively here - but it depends on your usecase, if you want to build a big city you definetly need management here, if you don’t need thousands of objects you can leave that point out, just to mention it.

Thanks Fyrestar. Thanks for your comment. Collision detection can be done via raycaster.