UNPKG

threepipe

Version:

A modern 3D viewer framework built on top of three.js, written in TypeScript, designed to make creating high-quality, modular, and extensible 3D experiences on the web simple and enjoyable.

84 lines 3.19 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { uiColor, uiFolderContainer, uiSlider, uiToggle } from 'uiconfig.js'; import { Color } from 'three'; import { glsl, onChange, serialize } from 'ts-browser-helpers'; import { uniform } from '../../three'; import vignette from './shaders/VignettePlugin.glsl'; import { AScreenPassExtensionPlugin } from './AScreenPassExtensionPlugin'; /** * Vignette Plugin * * Adds an extension to {@link ScreenPass} material * for applying vignette effect on the final buffer before rendering to screen. * The power of the vignette can be controlled with the `power` property. * The color of the vignette can be controlled with the `color`(previously `bgcolor`) property. * * @category Plugins */ let VignettePlugin = class VignettePlugin extends AScreenPassExtensionPlugin { /** * @deprecated */ get bgcolor() { console.warn('VignettePlugin.bgcolor is deprecated, use VignettePlugin.color instead'); return this.color; } /** * @deprecated */ set bgcolor(v) { console.warn('VignettePlugin.bgcolor is deprecated, use VignettePlugin.color instead'); this.color = v; } constructor(enabled = true) { super(); this.extraUniforms = { power: { value: 1 }, bgcolor: { value: new Color() }, }; this.power = 0.5; this.color = new Color(0x000000); /** * The priority of the material extension when applied to the material in ScreenPass * set to very low priority, so applied at the end */ this.priority = -50; this.parsFragmentSnippet = () => { if (this.isDisabled()) return ''; return glsl ` uniform float power; uniform vec3 bgcolor; ${vignette} `; }; this._shaderPatch = 'diffuseColor = Vignette(diffuseColor);'; this.enabled = enabled; } }; VignettePlugin.PluginType = 'Vignette'; __decorate([ onChange(VignettePlugin.prototype.setDirty), uiToggle('Enable'), serialize() ], VignettePlugin.prototype, "enabled", void 0); __decorate([ uiSlider('Power', [0.1, 4], 0.01), uniform({ propKey: 'power' }), serialize() ], VignettePlugin.prototype, "power", void 0); __decorate([ uiColor('Color', t => ({ onChange: () => t?.setDirty() })), uniform({ propKey: 'bgcolor' }), serialize('bgcolor') ], VignettePlugin.prototype, "color", void 0); VignettePlugin = __decorate([ uiFolderContainer('Vignette') ], VignettePlugin); export { VignettePlugin }; //# sourceMappingURL=VignettePlugin.js.map