
Product
Secure Your AI-Generated Code with Socket MCP
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
@triangular/shader
Advanced tools
If you want to use a fancy WebGL shader in your Angular App, this small demo can get you started.
If you want to use a fancy WebGL shader in your Angular App, this small demo can get you started.
You can see the component running in the background of the example app. Press p
to toggle the pause, and press s
to download a screenshot of the simulation. Press w
to create more splashes.
You can find the live demo at: https://shader.akehir.com.
If you just want to use the library, follow the following 3 simple steps. For contributing, or building the library locally, see the section on building the library.
Supported Angular Versions
Angular Version | WebGL Shader Library |
---|---|
10.x | ^0.4.0 |
Install the npm package.
npm i @triangular/shader
Then, add the FluidSimulationModule to the imports of your app.
import { ShaderModule } from '@triangular/shader';
@NgModule({
declarations: [
AppComponent,
...,
],
imports: [
...,
ShaderModule.forRoot(),
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Now you can use the provided component to create a canvas element with the simulation.
<webgl-shader></webgl-shader>
Depending on whether you want to use certain features, or positions for the module, you can add styles as follows. It is important to note, that the canvas itself should not be absolutely positioned.
webgl-shader {
top: 0;
left: 0;
right: 0;
bottom: 0;
position: absolute;
z-index: -1;
}
webgl-shader canvas {
width: 100%;
height: 100%;
/* the canvas position cannot be absolute, otherwise the js resize will bug out */
position: fixed;
}
You can configure your module by using the ShaderModule.forRoot()
method.
@NgModule({
declarations: [
AppComponent,
ExampleComponent,
],
imports: [
BrowserModule,
ShaderModule.forRoot({
SCREENSHOT_KEY_CODE: 'KeyS',
PAUSE_KEY_CODE: 'KeyP',
SPLASH_KEY: 'w',
DITHERING_TEXTURE: true,
DITHERING_TEXTURE_URI: 'assets/LDR_LLL1_0.png',
}),
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
In order to change the config interactively (for instance pausing and playing the simulation, or changing the settings) , you can use the provided service.
The service will be extended to include more functionality (for example triggering screenshots or adding splashes).
import { Component } from '@angular/core';
import { ShaderService } from '@triangular/shader';
@Component({
selector: 'app-example',
templateUrl: './example.component.html',
styleUrls: ['./example.component.css'],
})
export class ExampleComponent implements AfterViewInit {
constructor(private shader: ShaderService) { }
ngAfterViewInit() {
this.shader.RESIZE = true;
this.shader.createProgram(
'shader-bane',
`#version 300 es
in vec4 a_position;
void main() {
gl_Position = a_position;
}
`,
`#version 300 es
precision highp float;
out vec4 outColor;
void main() {
outColor = vec4(1, 0, 0.5, 1); // return reddish-purple
}
`,
).subscribe();
}
}
As a pre-requisite to build the library, you need to install all the dependencies via npm install
or yarn
.
Before the sample app can be run, you need to build the library itself.
npm run ng -- build shader-lib --progress=false
After building the library, it is either possible to build the sample app, via
npm run ng -- build example-app --prod --progress=false
,or to run the sample app with a local dev server:
npm run ng -- serve
There are not many tests, but those that are can be run with:
npm run test -- --no-watch --progress=false --code-coverage --browsers ChromeHeadless
The project follows the angular style guide and lints with the following command:
npm run lint
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.
We use SemVer for versioning.
render
function to programs
allowing for custom vertices
to be used by a program. See examples 2 and 9.step
function to programs
allowing for custom updating of uniforms
. See example 5.See also the list of contributors who participated in this project.
This project is licensed under the MIT License - see the LICENSE.md file for details
FAQs
If you want to use a fancy WebGL shader in your Angular App, this small demo can get you started.
The npm package @triangular/shader receives a total of 0 weekly downloads. As such, @triangular/shader popularity was classified as not popular.
We found that @triangular/shader demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Product
Socket MCP brings real-time security checks to AI-generated code, helping developers catch risky dependencies before they enter the codebase.
Security News
As vulnerability data bottlenecks grow, the federal government is formally investigating NIST’s handling of the National Vulnerability Database.
Research
Security News
Socket’s Threat Research Team has uncovered 60 npm packages using post-install scripts to silently exfiltrate hostnames, IP addresses, DNS servers, and user directories to a Discord-controlled endpoint.