@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.
53 lines (46 loc) • 1.74 kB
text/typescript
import { Object3D, Vector3 } 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: boolean = true;
/**
* When true, the look-at position is locked and won't update
* even if source objects move.
*/
()
locked: boolean = false;
/**
* Objects to look at. The first object in the array is used
* as the primary look-at target.
*/
(Object3D)
sources: Object3D[] = [];
/**
* 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: Vector3) {
const source = this.sources[0];
if (source) source.worldPosition = worldPosition;
}
}