UNPKG

playcanvas

Version:

PlayCanvas WebGL game engine

20 lines (18 loc) 654 B
var particleUpdaterSpherePS = ` uniform float spawnBoundsSphere; uniform float spawnBoundsSphereInnerRatio; vec3 calcSpawnPosition(vec3 inBounds, float rndFactor) { float rnd4 = fract(rndFactor * 1000.0); vec3 norm = normalize(inBounds.xyz - vec3(0.5)); float r = rnd4 * (1.0 - spawnBoundsSphereInnerRatio) + spawnBoundsSphereInnerRatio; #ifndef LOCAL_SPACE return emitterPos + norm * r * spawnBoundsSphere; #else return norm * r * spawnBoundsSphere; #endif } void addInitialVelocity(inout vec3 localVelocity, vec3 inBounds) { localVelocity += normalize(inBounds - vec3(0.5)) * initialVelocity; } `; export { particleUpdaterSpherePS as default };