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.

69 lines (68 loc) 3.64 kB
import { Object3D, Quaternion, Vector3 } from "three"; import { type AssetReference } from "./engine_addressables.js"; import { Context } from "./engine_setup.js"; import { type Constructor, type IComponent as Component, type IComponent, type IGameObject as GameObject, type UIDProvider } from "./engine_types.js"; export type IInstantiateOptions = { idProvider?: UIDProvider; parent?: string | Object3D; /** position in local space. Set `keepWorldPosition` to true if this is world space */ position?: Vector3; /** for duplicatable parenting */ keepWorldPosition?: boolean; /** rotation in local space. Set `keepWorldPosition` to true if this is world space */ rotation?: Quaternion; scale?: Vector3; /** if the instantiated object should be visible */ visible?: boolean; context?: Context; /** If true the components will be cloned as well * @default true */ components?: boolean; }; /** * Instantiation options for {@link syncInstantiate} */ export declare class InstantiateOptions implements IInstantiateOptions { idProvider?: UIDProvider | undefined; parent?: string | undefined | Object3D; keepWorldPosition?: boolean; position?: Vector3 | undefined; rotation?: Quaternion | undefined; scale?: Vector3 | undefined; visible?: boolean | undefined; context?: Context | undefined; components?: boolean | undefined; clone(): InstantiateOptions; /** Copy fields from another object, clone field references */ cloneAssign(other: InstantiateOptions | IInstantiateOptions): void; } export declare function isActiveSelf(go: Object3D): boolean; export declare function setActive(go: Object3D, active: boolean | number): boolean; export declare function isActiveInHierarchy(go: Object3D): boolean; export declare function markAsInstancedRendered(go: Object3D, instanced: boolean): void; export declare function isUsingInstancing(instance: Object3D): boolean; export declare function findByGuid(guid: string, hierarchy: Object3D): GameObject | IComponent | null | undefined; export declare function isDestroyed(go: Object3D): boolean; export declare function setDestroyed(go: Object3D, value: boolean): void; /** Mark an Object3D or component as not destroyable * @param instance the object to be marked as not destroyable * @param value true if the object should not be destroyed in `destroy` */ export declare function setDontDestroy(instance: Object3D | Component, value?: boolean): void; export declare function destroy(instance: Object3D | Component, recursive?: boolean, dispose?: boolean): void; declare type ForEachComponentCallback = (comp: Component) => any; export declare function foreachComponent(instance: Object3D, cb: ForEachComponentCallback, recursive?: boolean): any; export declare function foreachComponentEnumerator<T extends IComponent>(instance: Object3D, type?: Constructor<T>, includeChildren?: boolean, maxLevel?: number, _currentLevel?: number): Generator<T>; declare type ObjectCloneReference = { readonly original: object; readonly clone: object; }; declare type InstantiateReferenceMap = Record<string, ObjectCloneReference>; /** * Provides access to the instantiated object and its clone */ export declare type InstantiateContext = Readonly<InstantiateReferenceMap>; export declare function instantiate(instance: AssetReference, opts?: IInstantiateOptions | null): Promise<Object3D | null>; export declare function instantiate(instance: GameObject | Object3D, opts?: IInstantiateOptions | null): GameObject; export {};