UNPKG

@needle-tools/engine

Version:

Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in

56 lines (41 loc) 1.7 kB
import { MODULES } from "../../../engine/engine_modules.js"; import { serializable } from "../../../engine/engine_serialization.js"; import { type EffectProviderResult, PostProcessingEffect } from "../PostProcessingEffect.js"; import { VolumeParameter } from "../VolumeParameter.js"; import { registerCustomEffectType } from "../VolumeProfile.js"; export enum QualityLevel { LOW = 0, MEDIUM = 1, HIGH = 2, ULTRA = 3 } /** * @category Effects * @group Components */ export class Antialiasing extends PostProcessingEffect { get typeName(): string { return "Antialiasing"; } // @serializable(VolumeParameter) // edgeDetectionThreshold!: VolumeParameter; @serializable(VolumeParameter) readonly preset: VolumeParameter = new VolumeParameter(2); // 2 is HIGH: https://github.com/pmndrs/postprocessing/blob/main/src/enums/SMAAPreset.js#L14 onCreateEffect(): EffectProviderResult { const effect = new MODULES.POSTPROCESSING.MODULE.SMAAEffect({ preset: MODULES.POSTPROCESSING.MODULE.SMAAPreset.HIGH, edgeDetectionMode: MODULES.POSTPROCESSING.MODULE.EdgeDetectionMode.DEPTH }); this.preset.onValueChanged = (newValue) => { effect.applyPreset(newValue); }; // effect.edgeDetectionMaterial.edgeDetectionThreshold = .01; // this.edgeDetectionThreshold.onValueChanged = (newValue) => { // console.log(newValue); // effect.edgeDetectionMaterial.edgeDetectionThreshold = newValue; // } return effect; } } registerCustomEffectType("Antialiasing", Antialiasing)