not sure i uderstand it right, i am guessing you want a bunch of meshes to form a clump. if yes, you can get something like this quite easily with a physics model and a basic force attractor pushing objects into the center: BestServedBold Christmas Baubles - CodeSandbox
function initCannon() {
world = new CANNON.World({
gravity: new CANNON.Vec3(0, 0, 0),
iterations: 10,
broadphase: new CANNON.SAPBroadphase(world)
})
const radius = 1
body = new CANNON.Body({
mass: 1,
shape: new CANNON.Sphere(radius),
})
body.position.set(0, 10, 0)
world.addBody(body)
}
yes, looking good. start by letting them drop on a plane or something just to confirm. if you have that implementing the applyForce isn’t much work. btw that picture you posted is almost too good looking, i think i’d try to make it as well if i find time. im using three in react though. we could still compare notes.
Yes i let them drop, thank you , actually the example that you posted it : BestServedBold Christmas Baubles - CodeSandbox
this is all i need more than my pic , so i will try to make it in threejs !
btw @prisoner849 since you’re here, in the sandbox above i forked the AO shader from threejs, do you know how i could make the AO red? black looks terrible. i know PP can do it, but they just refactored the entire api and i can’t get it to work no more.
But a question , we have all spheres in the center cuz we have a gravity in 0,0,0 right ?
if we want to make a multiple groups of spheres then all of them return on center point
we have to set multiple worlds
one it’s gravity on 0,0,0
second it’s gravity on 1,1,0
third it’s gravity on 1,0,0
and so on
to get a deferent sets on center point ???
what do you think @drcmda
multiple worlds wouldn’t work because spheres would just pierce through one another. gravity is 0 anyway if you want spheres to float. what you can quite easily do is apply more or less force to specific spheres. the more force the faster they rush to center point. in the baubles demo above i do something like that, by multiplying the size of the sphere to the force.
I’m not sure in correctness of my approach, but I get red AO just by modifying blurMaterial only of SSAOPass, with .onBeforeCompile(), like for any other material, and I got this: https://99rjuc.csb.app/
for (let i = 0; i < 40; i++) {
instances.getMatrixAt(i, m)
bodies[i].applyForce(v3.setFromMatrixPosition(m).normalize().multiplyScalar(-50).toArray(), [0, 0, 0])
}
but again, it’s hard for me to go back to vanilla. physics especially. if you have the body you take the current position of it, normalize it and multiply with a negative force, that will push the object back to center. i am not 100% sure if cannon takes THREE.Vector3 i think it has its own vectors. in the abstraction i am using all of this has been taken care of, it’s integrated into threejs fully.