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.

96 lines 3.21 kB
import { Vector3 } from "three"; import { CircularBuffer } from "./engine_utils.js"; export function isGLTFModel(model) { const gltf = model; if (gltf.parser && gltf.parser.json) { return true; } return false; } export var HideFlags; (function (HideFlags) { HideFlags[HideFlags["None"] = 0] = "None"; /** When enabled the glTF exporter will omit this object and all children from being exported */ HideFlags[HideFlags["DontExport"] = 1] = "DontExport"; })(HideFlags || (HideFlags = {})); export function isComponent(obj) { return obj && obj.isComponent; } export const $physicsKey = Symbol("object"); const contactsVectorBuffer = new CircularBuffer(() => new Vector3(), 20); /** * Holds information about physics contacts */ export class ContactPoint { _point; _normal; _tangentVelocity; /** the distance of the collision point */ distance; /** the impulse velocity */ impulse; friction; /** worldspace point */ get point() { const target = contactsVectorBuffer.get(); return target.set(this._point.x, this._point.y, this._point.z); } /** worldspace normal */ get normal() { const target = contactsVectorBuffer.get(); return target.set(this._normal.x, this._normal.y, this._normal.z); } /** worldspace tangent */ get tangentVelocity() { const target = contactsVectorBuffer.get(); return target.set(this._tangentVelocity.x, this._tangentVelocity.y, this._tangentVelocity.z); } /** @internal */ constructor(point, dist, normal, impulse, friction, tangentVelocity) { this._point = point; this.distance = dist; this._normal = normal; this.impulse = impulse; this.friction = friction; this._tangentVelocity = tangentVelocity; } } /** * Holds information about a collision event. Includes a list of contact points and the colliders involved */ export class Collision { /** The contact points of this collision. Contains information about positions, normals, distance, friction, impulse... */ contacts; /** @internal */ constructor(obj, otherCollider, contacts) { this.me = obj; this._collider = otherCollider; this._gameObject = otherCollider.gameObject; this.contacts = contacts; } /** the gameobject this collision event belongs to (e.g. if onCollisionEnter is called then `me` is the same as `this.gameObject`) */ me; _collider; /** the other collider the collision happened with */ get collider() { return this._collider; } _gameObject; /** the other object the collision happened with */ get gameObject() { return this._gameObject; } /** the other rigidbody we hit, null if none attached */ get rigidBody() { return this.collider?.attachedRigidbody; } } export class SphereOverlapResult { object; collider; constructor(object, collider) { this.object = object; this.collider = collider; } } //# sourceMappingURL=engine_types.js.map