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.

84 lines 3.18 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 { Color, Fog as Fog3 } from "three"; import { serializable } from "../engine/engine_serialization.js"; import { Behaviour } from "./Component.js"; /** * Fog rendering mode */ var FogMode; (function (FogMode) { /** Linear fog increases uniformly with distance */ FogMode[FogMode["Linear"] = 1] = "Linear"; /** Exponential fog increases exponentially with distance */ FogMode[FogMode["Exponential"] = 2] = "Exponential"; /** Exponential squared fog for denser falloff */ FogMode[FogMode["ExponentialSquared"] = 3] = "ExponentialSquared"; })(FogMode || (FogMode = {})); /** * Adds distance-based fog effect to the scene. * When enabled, objects will fade into the fog color based on their distance from the camera. * * This component is automatically added to the scene when fog is enabled in the editor. * For setting fog from code you can simply use `scene.fog = new Fog3(color, near, far)` without adding this component. * * @summary Adds fog effect to the scene * @category Rendering * @group Components * @link https://threejs.org/docs/#Fog */ export class Fog extends Behaviour { /** * The underlying Three.js Fog object. You can modify its properties directly for more advanced control. * @remarks The Fog component provides convenient access to common fog properties like `near`, `far`, and `color`. Modifying those will update the underlying `fog` object accordingly. However, you can also access and modify the `fog` object directly for more advanced use cases, such as changing the fog mode or using a custom shader. * @link https://threejs.org/docs/#Fog for available properties and methods on the Fog object. */ get fog() { if (!this._fog) this._fog = new Fog3(0x000000, 0, 50); return this._fog; } get mode() { return FogMode.Linear; } set near(value) { this.fog.near = value; } get near() { return this.fog.near; } set far(value) { this.fog.far = value; } get far() { return this.fog.far; } set color(value) { this.fog.color.copy(value); } get color() { return this.fog.color; } _fog; onEnable() { this.scene.fog = this.fog; } onDisable() { if (this.scene.fog === this._fog) this.scene.fog = null; } } __decorate([ serializable() ], Fog.prototype, "near", null); __decorate([ serializable() ], Fog.prototype, "far", null); __decorate([ serializable(Color) ], Fog.prototype, "color", null); //# sourceMappingURL=Fog.js.map