Skip to content

Commit

Permalink
Merge pull request #5 from ammein/main
Browse files Browse the repository at this point in the history
Hotfix for Typescript & Cleaner Package Publish.
  • Loading branch information
patriciogonzalezvivo authored Nov 19, 2023
2 parents cef4777 + a74b91b commit 277c0d2
Show file tree
Hide file tree
Showing 100 changed files with 2,626 additions and 333 deletions.
7 changes: 7 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ module.exports = {
isTSX: true,
allExtensions: true
}
],
[
"minify",
{
removeConsole: true,
removeDebugger: true
}
]
]
}
2 changes: 1 addition & 1 deletion examples/react-js/postprocessing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@react-three/fiber": "^8.15.11",
"glsl-pipeline": "^2.0.0",
"glsl-pipeline": "^2.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"resolve-lygia": "^1.0.4",
Expand Down
2 changes: 1 addition & 1 deletion examples/react-js/shader_options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@react-three/fiber": "^8.15.11",
"glsl-pipeline": "^2.0.0",
"glsl-pipeline": "^2.0.2",
"leva": "^0.9.35",
"react": "^18.2.0",
"react-dom": "^18.2.0",
Expand Down
2 changes: 1 addition & 1 deletion examples/react-ts/typescript_postprocessing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"dependencies": {
"@react-three/fiber": "^8.15.11",
"glsl-pipeline": "^2.0.0",
"glsl-pipeline": "^2.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"resolve-lygia": "^1.0.4",
Expand Down
5 changes: 3 additions & 2 deletions examples/react-ts/typescript_shader_options/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
},
"dependencies": {
"@react-three/fiber": "^8.15.11",
"glsl-pipeline": "^2.0.0",
"glsl-pipeline": "^2.0.2",
"leva": "^0.9.35",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"resolve-lygia": "^1.0.4"
"resolve-lygia": "^1.0.4",
"three": "^0.158.0"
},
"devDependencies": {
"@types/react": "^18.2.37",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Camera, Size, useThree } from '@react-three/fiber';
import { resolveLygia } from 'resolve-lygia'
import * as THREE from 'three';
import { useControls } from 'leva'
import { GlslPipelineClass, isPerspectiveCamera } from 'glsl-pipeline/src/types-helper';
import { GlslPipelineClass, isPerspectiveCamera } from 'glsl-pipeline/types';

// eslint-disable-next-line no-unused-vars
const Effect = () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/vanilla-js/2d_clock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"vite": "^4.4.5"
},
"dependencies": {
"glsl-pipeline": "^2.0.0",
"glsl-pipeline": "^2.0.2",
"resolve-lygia": "^1.0.4",
"three": "^0.158.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/vanilla-js/2d_reaction_diffusion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"vite": "^4.4.5"
},
"dependencies": {
"glsl-pipeline": "^2.0.0",
"glsl-pipeline": "^2.0.2",
"resolve-lygia": "^1.0.4",
"three": "^0.158.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/vanilla-js/2d_trails/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"vite": "^4.4.5"
},
"dependencies": {
"glsl-pipeline": "^2.0.0",
"glsl-pipeline": "^2.0.2",
"resolve-lygia": "^1.0.4",
"three": "^0.158.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/vanilla-js/3d_pbr_shadow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"vite": "^4.4.5"
},
"dependencies": {
"glsl-pipeline": "^2.0.0",
"glsl-pipeline": "^2.0.2",
"resolve-lygia": "^1.0.4",
"three": "^0.158.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/vanilla-js/3d_pbr_shadow_dof/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"vite": "^4.4.5"
},
"dependencies": {
"glsl-pipeline": "^2.0.0",
"glsl-pipeline": "^2.0.2",
"resolve-lygia": "^1.0.4",
"three": "^0.158.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/vanilla-js/3d_pbr_shadow_environment/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"vite": "^4.4.5"
},
"dependencies": {
"glsl-pipeline": "^2.0.0",
"glsl-pipeline": "^2.0.2",
"resolve-lygia": "^1.0.4",
"three": "^0.158.0"
}
Expand Down
2 changes: 1 addition & 1 deletion examples/vanilla-js/3d_trails/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"vite": "^4.4.5"
},
"dependencies": {
"glsl-pipeline": "^2.0.0",
"glsl-pipeline": "^2.0.2",
"resolve-lygia": "^1.0.4",
"three": "^0.158.0"
}
Expand Down
24 changes: 24 additions & 0 deletions examples/vanilla-ts/typescript_2d_clock/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
13 changes: 13 additions & 0 deletions examples/vanilla-ts/typescript_2d_clock/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + TS</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
21 changes: 21 additions & 0 deletions examples/vanilla-ts/typescript_2d_clock/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "typescript_2d_clock",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview"
},
"devDependencies": {
"typescript": "^5.2.2",
"vite": "^4.4.5"
},
"dependencies": {
"@types/three": "^0.158.2",
"glsl-pipeline": "^2.0.2",
"resolve-lygia": "^1.0.4",
"three": "^0.158.0"
}
}
1 change: 1 addition & 0 deletions examples/vanilla-ts/typescript_2d_clock/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/vanilla-ts/typescript_2d_clock/resolve-lygia.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare module 'resolve-lygia' {
function resolveLygia(shader: string): string
}
118 changes: 118 additions & 0 deletions examples/vanilla-ts/typescript_2d_clock/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
import './style.css'
import { WebGLRenderer } from 'three';
import { resolveLygia } from 'resolve-lygia';

import { GlslPipeline } from 'glsl-pipeline';

let W = window,
D = document.querySelector('#app') as Element;

let width = W.innerWidth;
let height = W.innerHeight;
let pixelRatio = W.devicePixelRatio;

const renderer = new WebGLRenderer({
alpha: true
});
renderer.setPixelRatio(pixelRatio);
renderer.setSize(width, height);
D.appendChild(renderer.domElement);

const shader_frag = resolveLygia(/* glsl */`
uniform sampler2D u_buffer0; // 256x256
uniform sampler2D u_buffer1; // 256x256
uniform vec4 u_date;
uniform vec2 u_resolution;
uniform float u_time;
#include "lygia/math/const.glsl"
#include "lygia/math/decimate.glsl"
#include "lygia/space/ratio.glsl"
#include "lygia/space/scale.glsl"
#define DIGITS_SIZE vec2(0.1)
#define DIGITS_LEADING_INT 2.0
#include "lygia/draw/digits.glsl"
#include "lygia/sample/clamp2edge.glsl"
#include "lygia/filter/gaussianBlur/1D_fast13.glsl"
#include "lygia/space/sqTile.glsl"
#include "lygia/draw/circle.glsl"
void main() {
vec3 color = vec3(0.0);
vec2 pixel = 1.0/u_resolution.xy;
vec2 st = gl_FragCoord.xy * pixel;
vec2 sst = ratio(st, u_resolution);
#ifdef BUFFER_0
// Draw the digital clock
sst = scale(sst, 0.5);
float h = floor( u_date.w / 3600.0);
float m = floor( mod(u_date.w, 3600.0) / 60.0 );
float time = 0.0;
// blinking :
color += (circle(sst - vec2(0.0, 0.025), 0.02) +
circle(sst + vec2(0.0, 0.025), 0.02)) *
mod(floor(u_time), 2.0);
sst -= vec2(0.3, 0.45);
// Hr and Min
color += digits(sst, h, 0.0, 1.0);
color += digits(sst - vec2(0.23, 0.0), m, 0.0, 1.0);
color *= vec3(0.5, 1.0, 0.9);
#elif defined(BUFFER_1)
// First pass blur
color = gaussianBlur1D_fast13(u_buffer0, st, vec2(1.0, 0.0) * pixel).rgb;
#else
// Second pass blur
vec3 blur = gaussianBlur1D_fast13(u_buffer1, sst, 1.0/vec2(0.0, 512.0)).rgb;
// sample the fist buffer but using a dot matrix
float s = 80.0;
vec4 t = sqTile(sst * s * 2.0 + 0.5);
vec3 value = sampleClamp2edge(u_buffer0, decimate(sst, s) - pixel).rgb;
// Draw pixels + glow
color += value * fill(circleSDF(t.xy), 0.5, 0.5) * 0.8;
color *= sin(st.y * u_resolution.y * 0.25 - u_time * 5.0) * 0.25 + 0.75;
color += blur;
#endif
gl_FragColor = vec4(color, 1.);
}`);

// GLSL Buffers
const glsl_sandbox = new GlslPipeline(renderer);
glsl_sandbox.load(shader_frag);

const draw = () => {
glsl_sandbox.renderMain();
requestAnimationFrame(draw);
};

const resize = () => {
width = W.innerWidth;
height = W.innerHeight;
pixelRatio = W.devicePixelRatio;

renderer.setPixelRatio(pixelRatio);
renderer.setSize(width, height);

glsl_sandbox.setSize(width, height);
};

W.addEventListener("resize", resize);
resize();

draw();
Loading

0 comments on commit 277c0d2

Please sign in to comment.