Random multiple object position in area and image group + random image open

Hello, I got a project where is 100 rotating 3D objects, right now I’ve placed them manually around centre object, but I would like to define area in which those 3D objects randomly by themselves spread evenly and randomly rotate around their own centre (not moving around, just 360’ rotating in the same position). Is it even possible? Because at the moment my code is very, very long and hard to orientate in it, this would make it easier to view and to work with in the future.
The other thing that I don’t know how to make, I need to make a group of images, and when in VR mode someone clicks on any of those 100 rotating objects, randomly one of the images of the group opens. The idea, you can click 15 times on the same object, but every time it will open different image.

I’m using A-frame.

I hope that I’ve wrote enough clear. I’m so new to this and my vocabulary isn’t that advanced to explain what I need, sorry.

Could you please enlighten me?

I’m not sure how much help I can be with the actual code but I can assure you that if you can position things manually you can certainly calculate a position and assign it through code. I would suggest that you reduce your problem set to start. So rather than 100 objects (which you are going to lose track of) start with 3 and evenly space them. Once the algorithm is correct then you can set it to 5, 20 or more and see it continues to work. Set it to 100 objects again after that.

Same sort of solution for the clicking part. Set the number of objects to 1, stop their rotation (these should all be settings) and concentrate on handling the click event on one of them. When that is working adjust the code as needed and turn on all the objects.

Simplify the problem… hope that helps.

1 Like