Add cloth simulation page with WGSL shaders
Introduce a new cloth simulation feature: adds ClothComponent (TS/HTML/SCSS) and WGSL compute/vertex/fragment shaders implementing an XPBD-based cloth sim. Wire up routing and RouterConstants, add the cloth entry to the algorithms list, and add English/German i18n strings. Also include small refactors/renames for algorithm-category and algorithms.service imports and update BabylonCanvas to tolerate optional shader configuration and avoid null access during setup.
This commit is contained in:
1 parent
885e609082
commit
954211b3cf
12 files changed
+461
-11
No files matched your search
@@ -5,9 +5,9 @@ export interface RenderConfig {
|
||||
mode: '2D' | '3D';
|
||||
shaderLanguage?: number; //0 GLSL, 1 WGSL
|
||||
initialViewSize: number;
|
||||
vertexShader: string;
|
||||
fragmentShader: string;
|
||||
uniformNames: string[];
|
||||
vertexShader?: string;
|
||||
fragmentShader?: string;
|
||||
uniformNames?: string[];
|
||||
uniformBufferNames?: string[];
|
||||
}
|
||||
|
||||
@@ -120,8 +120,10 @@ export class BabylonCanvas implements AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
private createFullScreenRect() {
|
||||
if (!this.config.vertexShader || !this.config.fragmentShader) {
|
||||
return;
|
||||
}
|
||||
const plane = MeshBuilder.CreatePlane("plane", {size: 100}, this.scene);
|
||||
|
||||
if (this.config.mode === '3D') {
|
||||
plane.parent = this.camera;
|
||||
plane.position.z = 1;
|
||||
@@ -134,6 +136,10 @@ export class BabylonCanvas implements AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
private createShaderMaterial() {
|
||||
if (!this.config.vertexShader || !this.config.fragmentShader || !this.config.uniformNames) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.shaderMaterial = new ShaderMaterial(
|
||||
"shaderMaterial",
|
||||
this.scene,
|
||||
@@ -161,8 +167,10 @@ export class BabylonCanvas implements AfterViewInit, OnDestroy {
|
||||
}
|
||||
|
||||
// default uniforms which maybe each scene has
|
||||
this.shaderMaterial.setVector2("resolution", new Vector2(canvas.width, canvas.height));
|
||||
this.shaderMaterial.setVector3("cameraPosition", this.camera.position);
|
||||
if (this.shaderMaterial) {
|
||||
this.shaderMaterial.setVector2("resolution", new Vector2(canvas.width, canvas.height));
|
||||
this.shaderMaterial.setVector3("cameraPosition", this.camera.position);
|
||||
}
|
||||
|
||||
this.scene.render();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user