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.

61 lines 2.6 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 { serializeable } from "../../engine/engine_serialization_decorator.js"; import { getParam } from "../../engine/engine_utils.js"; import { PostProcessingEffect } from "./PostProcessingEffect.js"; const debug = getParam("debugpost"); const customEffects = {}; export function registerCustomEffectType(name, effect) { customEffects[name] = effect; } // resolve the types: function resolveComponentType(data) { if (data.__type in customEffects) return customEffects[data.__type]; // if ("mode" in data) return ToneMapping; // if ("postExposure" in data) return ColorAdjustments; // switch (data.__type) { // // case "Bloom": return Bloom; // // case "DepthOfField": return DepthOfField; // // case "Vignette": return Vignette // // case "ColorAdjustments": return ColorAdjustments; // // case "Tonemapping": return ToneMapping; // } if (debug && data.__type) console.warn("Unknown postprocessing type", data.__type, data); return PostProcessingEffect; } /** @internal */ export class VolumeProfile { /** effects added to the volume */ components = []; /** * call init on all components * @hidden **/ __init(owner) { this.components?.forEach(c => { // Make sure all components are added to the gameobject (this is not the case when e.g. effects are serialized from Unity) if (c.gameObject === undefined) { owner.gameObject.addComponent(c); } c.init(); }); } addEffect(effect) { this.components.push(effect); } removeEffect(effect) { const idx = this.components.indexOf(effect); if (idx >= 0) this.components.splice(idx, 1); } } __decorate([ serializeable([d => resolveComponentType(d), PostProcessingEffect]) ], VolumeProfile.prototype, "components", void 0); //# sourceMappingURL=VolumeProfile.js.map