Add pendulum demo and WGSL support
Introduce a new Pendulum demo (component, template, stylesheet) and wire it into routing and the algorithms list. Extend Babylon canvas API to emit a SceneReadyEvent (scene + engine) and accept a shaderLanguage option in RenderConfig so materials/shaders can target WGSL; update Fractal to consume the new SceneReadyEvent signature. Also add i18n entries for the pendulum demo.
This commit is contained in:
1 parent
68e21489ea
commit
55ece27e1c
10 files changed
+215
-9
No files matched your search
@@ -1,9 +1,9 @@
|
||||
import {AfterViewInit, Component, ElementRef, EventEmitter, inject, Input, NgZone, OnDestroy, Output, ViewChild} from '@angular/core';
|
||||
import {ArcRotateCamera, Camera, MeshBuilder, Scene, ShaderMaterial, Vector2, Vector3, WebGPUEngine} from '@babylonjs/core';
|
||||
import {ArcRotateCamera, Camera, MeshBuilder, Scene, ShaderLanguage, ShaderMaterial, Vector2, Vector3, WebGPUEngine} from '@babylonjs/core';
|
||||
|
||||
export interface RenderConfig {
|
||||
mode: '2D' | '3D';
|
||||
computeShaderSupport?: boolean;
|
||||
shaderLanguage?: number; //0 GLSL, 1 WGSL
|
||||
initialViewSize: number;
|
||||
vertexShader: string;
|
||||
fragmentShader: string;
|
||||
@@ -12,6 +12,11 @@ export interface RenderConfig {
|
||||
|
||||
export type RenderCallback = (material: ShaderMaterial, camera: Camera, canvas: HTMLCanvasElement, scene: Scene) => void;
|
||||
|
||||
export interface SceneReadyEvent {
|
||||
scene: Scene;
|
||||
engine: WebGPUEngine;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-babylon-canvas',
|
||||
imports: [],
|
||||
@@ -26,7 +31,7 @@ export class BabylonCanvas implements AfterViewInit, OnDestroy {
|
||||
@Input({ required: true }) config!: RenderConfig;
|
||||
@Input() renderCallback?: RenderCallback;
|
||||
|
||||
@Output() sceneReady = new EventEmitter<Scene>();
|
||||
@Output() sceneReady = new EventEmitter<SceneReadyEvent>();
|
||||
|
||||
private engine!: WebGPUEngine;
|
||||
private scene!: Scene;
|
||||
@@ -63,7 +68,10 @@ export class BabylonCanvas implements AfterViewInit, OnDestroy {
|
||||
this.addListener(canvas);
|
||||
this.createShaderMaterial();
|
||||
this.createFullScreenRect();
|
||||
this.sceneReady.emit(this.scene);
|
||||
this.sceneReady.emit({
|
||||
scene: this.scene,
|
||||
engine: this.engine
|
||||
});
|
||||
this.addRenderLoop(canvas);
|
||||
});
|
||||
}
|
||||
@@ -133,7 +141,8 @@ export class BabylonCanvas implements AfterViewInit, OnDestroy {
|
||||
},
|
||||
{
|
||||
attributes: ["position", "uv"],
|
||||
uniforms: ["resolution", "cameraPosition", ...this.config.uniformNames]
|
||||
uniforms: ["resolution", "cameraPosition", ...this.config.uniformNames],
|
||||
shaderLanguage: this.config.shaderLanguage ?? ShaderLanguage.GLSL
|
||||
}
|
||||
);
|
||||
this.shaderMaterial.disableDepthWrite = true;
|
||||
|
||||
Reference in new issue
Block a user