Skip to content

Commit

Permalink
Pop a little.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Mihailik authored and Oleg Mihailik committed Sep 15, 2023
1 parent 3de5fca commit 722c7a3
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -777,19 +777,26 @@ function atlas(invokeType) {

function flashesRenderer() {
const rend = billboardShaderRenderer({
fragmentShader: /* glsl */`
gl_FragColor = tintColor;
vertexShader: /* glsl */`
float startTime = min(extra.x, extra.y);
float endTime = max(extra.x, extra.y);
float timeRatio = (time - startTime) / (endTime - startTime);
float step = 0.1;
float timeFunction = timeRatio < step ? timeRatio / step : 1.0 - (timeRatio - step) * (1.0 - step);
gl_Position.y += timeFunction * timeFunction * timeFunction * 0.01;
`,
fragmentShader: /* glsl */`
gl_FragColor = tintColor;
float startTime = min(extra.x, extra.y);
float endTime = max(extra.x, extra.y);
float timeRatio = (time - startTime) / (endTime - startTime);
float step = 0.1;
float timeFunction = timeRatio < step ? timeRatio / step : 1.0 - (timeRatio - step) * (1.0 - step);
gl_FragColor = tintColor;
gl_FragColor.a *= timeFunction * timeFunction * timeFunction;
// gl_FragColor =
Expand Down Expand Up @@ -977,11 +984,12 @@ function atlas(invokeType) {
* userKeys: K[];
* userMapper(i: K, pos: THREE.Vector4, extra: THREE.Vector4): void;
* userColorer(i: K): number;
* fragmentShader: string;
* fragmentShader?: string;
* vertexShader?: string;
* }} _
* @template K
*/
function billboardShaderRenderer({ userKeys, userMapper, userColorer, fragmentShader }) {
function billboardShaderRenderer({ userKeys, userMapper, userColorer, fragmentShader, vertexShader }) {
const baseHalf = 1.5 * Math.tan(Math.PI / 6);
let positions = new Float32Array([
-baseHalf, 0, -0.5,
Expand Down Expand Up @@ -1045,6 +1053,8 @@ function atlas(invokeType) {
vColor = vec4(float(rInt) / 255.0f, float(gInt) / 255.0f, float(bInt) / 255.0f, float(aInt) / 255.0f);
vFogDist = distance(cameraPosition, offset);
${vertexShader || ''}
}
`,
fragmentShader: /* glsl */`
Expand Down Expand Up @@ -1086,7 +1096,7 @@ function atlas(invokeType) {
float diameter = vDiameter;
vec4 extra = vExtra;
${fragmentShader}
${fragmentShader || ''}
}
`,
side: THREE.BackSide,
Expand Down

0 comments on commit 722c7a3

Please sign in to comment.