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

40 lines (35 loc) 1.23 kB
import { AxesHelper as _AxesHelper } from "three"; import * as params from "../engine/engine_default_parameters.js"; import { serializable } from "../engine/engine_serialization_decorator.js"; import { Behaviour } from "./Component.js"; /** * AxesHelper is a component that displays the axes of the object in the scene. * @category Helpers * @group Components */ export class AxesHelper extends Behaviour { @serializable() public length: number = 1; @serializable() public depthTest: boolean = true; @serializable() public isGizmo: boolean = false; private _axes: _AxesHelper | null = null; onEnable(): void { if (this.isGizmo && !params.showGizmos) return; if (!this._axes) this._axes = new _AxesHelper(this.length); this._axes.layers.disableAll(); this._axes.layers.set(this.layer); this.gameObject.add(this._axes); const mat: any = this._axes.material; if (mat) { if (mat.depthTest !== undefined) mat.depthTest = this.depthTest; } } onDisable(): void { if (!this._axes) return; this.gameObject.remove(this._axes); } }