Replace addons with conventional handles
Provide the single-loadout Scene API, SAB-backed meshes, cameras, materials, lights, workers, post effects, and tutorial playgrounds. Batch matching row growth so active GPU loadouts refresh once. Amp-Thread-ID: https://ampcode.com/threads/T-01a01380-b478-77d0-84a0-102880a5c5ae Co-authored-by: Heaust Azure <heaust.azure@gmail.com>
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import { PostProcess } from "./PostProcess";
|
||||
import type { Scene } from "../Scene";
|
||||
|
||||
export type ToneMap = "aces" | "reinhard" | "linear";
|
||||
export class ColorGrading extends PostProcess {
|
||||
constructor(scene: Scene, options: { amount?: number; toneMap?: ToneMap; enabled?: boolean } = {}) {
|
||||
super(scene, "colorGrading", options);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { PostProcess } from "./PostProcess";
|
||||
import type { Scene } from "../Scene";
|
||||
|
||||
export class DynamicExposure extends PostProcess {
|
||||
constructor(scene: Scene, options: { exposure?: number; enabled?: boolean } = {}) { super(scene, "dynamicExposure", options); }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { PostProcess } from "./PostProcess";
|
||||
import type { Scene } from "../Scene";
|
||||
|
||||
export class Edges extends PostProcess {
|
||||
constructor(scene: Scene, options: { amount?: number; enabled?: boolean } = {}) { super(scene, "edges", options); }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { PostProcess } from "./PostProcess";
|
||||
import type { Scene } from "../Scene";
|
||||
|
||||
export class FXAA extends PostProcess {
|
||||
constructor(scene: Scene, options: { enabled?: boolean } = {}) { super(scene, "fxaa", options); }
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import type { Scene } from "../Scene";
|
||||
|
||||
let nextPostProcess = 1;
|
||||
|
||||
/** Shared graph-membership behavior for the small post-process handles. */
|
||||
export class PostProcess {
|
||||
readonly scene: Scene;
|
||||
readonly id: string;
|
||||
readonly kind: string;
|
||||
options: Record<string, unknown>;
|
||||
enabled: boolean;
|
||||
ready: Promise<void>;
|
||||
|
||||
protected constructor(scene: Scene, kind: string, options: Record<string, unknown> = {}) {
|
||||
this.scene = scene;
|
||||
this.kind = kind;
|
||||
this.id = `${kind}-${nextPostProcess++}`;
|
||||
this.enabled = options.enabled !== false;
|
||||
const { enabled: _, ...effectOptions } = options;
|
||||
this.options = effectOptions;
|
||||
this.ready = scene.setPostProcess(this, this.enabled);
|
||||
}
|
||||
|
||||
setEnabled(enabled: boolean) {
|
||||
this.enabled = enabled;
|
||||
this.ready = this.scene.setPostProcess(this, enabled);
|
||||
return this.ready;
|
||||
}
|
||||
|
||||
update(options: Record<string, unknown>) {
|
||||
this.options = { ...this.options, ...options };
|
||||
this.ready = this.scene.setPostProcess(this, this.enabled);
|
||||
return this.ready;
|
||||
}
|
||||
|
||||
dispose() { return this.setEnabled(false); }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { PostProcess } from "./PostProcess";
|
||||
import type { Scene } from "../Scene";
|
||||
|
||||
export class SSAO extends PostProcess {
|
||||
constructor(scene: Scene, options: { amount?: number; enabled?: boolean } = {}) { super(scene, "ssao", options); }
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { PostProcess } from "./PostProcess";
|
||||
import type { Scene } from "../Scene";
|
||||
|
||||
export class Silhouette extends PostProcess {
|
||||
constructor(scene: Scene, options: { amount?: number; enabled?: boolean } = {}) { super(scene, "silhouette", options); }
|
||||
}
|
||||
Reference in New Issue
Block a user