Points bounce/movement within BoxBufferGeometry

All, I made a CodePen with just my scaling box to help show my issue. I want those points to bounce around within that wireframe box (or randomly move). Instead, I have only learned how to scale the points.

I was referred by @prisoner849 and @Fyrestar to .reflect() and Box3 as ideas for how to fix this in my last thread. I’m sure those are the right answers, but after four more straight days of this, I still need a little more detail on how to apply these.

Absolutely any help would be greatly appreciated!

Each point has to have direction and speed.
And has to be checked, if it exceeded the limit on x or y or z , then reflect its direction relatively a desired normal.

So what you’re saying is, within that function I need to declare something like:
p.velocity = THREE.Vector3( integer, integer, integer);
p.direction = THREE.Vector3(integer, integer, integer);

Then in my animation loop, with those elements moving the points, I need to set some sort of parameter using reflect().

Would that be like an if-else statement or just:
v.reflect(hist)? with hist being the wireframe box?

Teaching myself some coding via THREE and java is my COVID stay-at-home project. So thank you for your patience as I learn the ropes.

Here is a very rough example, with the using of THREE.Geometry() for simplicity:

Or you can take a look at the source code of this example: https://threejs.org/examples/?q=rang#webgl_buffergeometry_drawrange . It uses THREE.BufferGeometry().

2 Likes

Wow, that is exactly what I am looking to do! Thank you for taking the time to teach it so thoroughly. I should be able to implement and have a project to show off soon thanks to your help!