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.

60 lines 2.5 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 { Object3D } from "three"; import { serializable } from "../engine/engine_serialization.js"; import { Behaviour } from "./Component.js"; /** * @deprecated LookAtConstraint will be removed in future versions. Please either use a direct object reference instead (e.g. assigning an Object3D as a look target in scripts that reply on the LookAtConstraint) or implement the LookAtConstraint signature in your web project: * ```ts * export class LookAtConstraint extends Behaviour { * constraintActive: boolean = true; * locked: boolean = false; * sources: Object3D[] = []; * setConstraintPosition(worldPosition: Vector3) { * const source = this.sources[0]; * if (source) source.worldPosition = worldPosition; * } * } * ``` */ export class LookAtConstraint extends Behaviour { /** * When true, the constraint is active and affects the target. * Set to false to temporarily disable without removing sources. */ constraintActive = true; /** * When true, the look-at position is locked and won't update * even if source objects move. */ locked = false; /** * Objects to look at. The first object in the array is used * as the primary look-at target. */ sources = []; /** * Sets the world position that the constraint should look at. * Updates the first source object's position. * @param worldPosition The world-space position to look at */ setConstraintPosition(worldPosition) { const source = this.sources[0]; if (source) source.worldPosition = worldPosition; } } __decorate([ serializable() ], LookAtConstraint.prototype, "constraintActive", void 0); __decorate([ serializable() ], LookAtConstraint.prototype, "locked", void 0); __decorate([ serializable(Object3D) ], LookAtConstraint.prototype, "sources", void 0); //# sourceMappingURL=LookAtConstraint.js.map