playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
28 lines (24 loc) • 875 B
JavaScript
var particleUpdaterSphere_default = (
/* wgsl */
`
uniform spawnBoundsSphere: f32;
uniform spawnBoundsSphereInnerRatio: f32;
fn calcSpawnPosition(inBounds: vec3f, rndFactor: f32) -> vec3f {
let rnd4: f32 = fract(rndFactor * 1000.0);
let norm: vec3f = normalize(inBounds.xyz - vec3f(0.5));
let r: f32 = rnd4 * (1.0 - uniform.spawnBoundsSphereInnerRatio) + uniform.spawnBoundsSphereInnerRatio;
return uniform.emitterPos + norm * r * uniform.spawnBoundsSphere;
return norm * r * uniform.spawnBoundsSphere;
}
fn addInitialVelocity(localVelocity: ptr<function, vec3f>, inBounds: vec3f) {
let initialVelOffset: vec3f = normalize(inBounds - vec3f(0.5)) * uniform.initialVelocity;
*localVelocity = *localVelocity + initialVelOffset;
}
`
);
export {
particleUpdaterSphere_default as default
};