Currently, I am developing a cargo planning application that involves loading cargo into containers. To achieve this, I am utilizing three.js to create a 3D model. Despite being new to three.js, I have successfully created 3D objects (cargo) and placed them inside a container (another 3D object). However, I am encountering a challenge where the 3D objects overlap when multiple items are added to the container.
In my attempts to address this issue, I have only resorted to basic mathematical calculations to determine the correct positioning of objects within the scene.
For reference, here is the JSFiddle link:
https://jsfiddle.net/nro48e6u/1/
The logic responsible for calculating the object positions resides in the 'addCargo' function, which primarily relies on fundamental math concepts. The code snippet for this function is as follows:
function addCargo(dimension, color, isPallete) {
// Code implementation for adding cargo objects
}
Despite implementing these calculations, I'm still facing challenges with objects overlapping within the container. The current solution does not effectively prevent this issue, and I remain uncertain about how to resolve it.