
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
babel-plugin-glsl
Advanced tools
A Babel plugin to process GLSL code with glslify, a module system for GLSL.
import glsl from 'glslify';
const fragmentShader = glsl`
#pragma glslify: random = require(glsl-random)
void main () {
float brightness = random(gl_FragCoord.xy / resolution.xy);
gl_FragColor = vec4(vec3(brightness), 1.0);
}
`;
const fragmentShader = `
highp float random(vec2 co) {
highp float a = 12.9898;
highp float b = 78.233;
highp float c = 43758.5453;
highp float dt= dot(co.xy, vec2(a,b));
highp float sn= mod(dt, 3.14);
return fract(sin(sn) * c);
}
void main () {
float brightness = random(gl_FragCoord.xy / resolution.xy);
gl_FragColor = vec4(vec3(brightness), 1.0);
}
`;
# yarn
yarn add -D glslify babel-plugin-glsl
# npm
npm i --save-dev glslify babel-plugin-glsl
Add the plugin to your .babelrc
{
"plugins": ["babel-plugin-glsl"]
}
Please note that the Babel plugin should run before other plugins or presets to ensure the template literals are correctly transformed.
Alternatively, instead of using the Babel plugin, you can use this package with babel-plugin-macros. After installing babel-plugin-macros
and adding it to your Babel config, you can use the transform directly with:
import glsl from 'babel-plugin-glsl/macro';
const fragmentShader = glsl`
// ...
`;
FAQs
Process GLSL code with glslify
The npm package babel-plugin-glsl receives a total of 1,121 weekly downloads. As such, babel-plugin-glsl popularity was classified as popular.
We found that babel-plugin-glsl demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.