i added shader
const dust = new THREE.Points(geometry, material);
scene.add(dust);
it updates in gameloop
const positionAttribute = dustGeometry.getAttribute("position");
for (let i = 0; i < count; i++) {
const i3 = i * 3;
...
if (positionAttribute.array[i3 + 1] > 2.5) {
positionAttribute.array[i3] = (Math.random() - 0.5) * 8;
positionAttribute.array[i3 + 1] = -2.5;
positionAttribute.array[i3 + 2] = (Math.random() - 0.5) * 4;
}
and there i use these lines to allow dust follow rcCar
let throughDiffDustAndRCCar = new THREE.Vector3().subVectors(new THREE.Vector3(dust.position.x,0, dust.position.z), new THREE.Vector3(samplePickRCCar.position.x,0, samplePickRCCar.position.z) )
dust.position.copy({x: samplePickRCCar.position.x, y: camera.position.y, z: samplePickRCCar.position.z + throughDiffDustAndRCCar.z })
the issue is that samplePickRCCar.position.z and dust.position.z are expected to be different to allow dust be shown in camera
what diff of vectors i may use?
dust expected to be in the end of the car, it depends of camera.y
and there diff between rcCar.position.z and dust.position.z to be shown in camera
meded90
2
@PavelBoytchev @Lawrence3DPK
Excuse for pointing
Still didnt find a solution for that
Thanks
meded90
3
i found this one, particle works, camera position is not handled
https://github.com/BilguunTs/Space-Dust-with-threejs/tree/main
do you need to do this for a reason? alternatively you could use
RCCar.add(dust)
so the dust object is attached to the car and use an offset so it sits at the back of the car…
meded90
5
@Lawrence3DPK
dust became mappd to camera, it became visible only when has same y that camera has
i did
RCCar.add(dust)
and dust became not visible, RCCar on scene
that is how i did working dust with position copy
dust.position.copy({x: samplePickRCCar.position.x, y: camera.position.y, z: samplePickRCCar.position.z + throughDiffDustAndRCCar.z })
position copy
it is walkin through x when car is moving through z
meded90
6
There i attached royal palm into car using position copy
and dust attached to viewport and camera
may be pick another vfx dust
palm position copy