@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 (47 loc) • 1.14 kB
text/typescript
import { Color, Fog as Fog3 } from "three";
import { serializable } from "../engine/engine_serialization.js";
import { Behaviour } from "./Component.js";
enum FogMode {
Linear = 1,
Exponential = 2,
ExponentialSquared = 3,
}
/** @internal */
export class Fog extends Behaviour {
get fog() {
if (!this._fog) this._fog = new Fog3(0x000000, 0, 50);
return this._fog;
}
get mode() {
return FogMode.Linear;
}
set near(value: number) {
this.fog.near = value;
}
get near() {
return this.fog.near;
}
set far(value: number) {
this.fog.far = value;
}
get far() {
return this.fog.far;
}
set color(value: Color) {
this.fog.color.copy(value);
}
get color() {
return this.fog.color;
}
private _fog?: Fog3;
onEnable() {
this.scene.fog = this.fog;
}
onDisable() {
if (this.scene.fog === this._fog)
this.scene.fog = null;
}
}