///
import { VRM } from '@pixiv/three-vrm';
import { VRMAnimation } from '@pixiv/three-vrm-animation';
import { default as VrmCanvas } from '@/components/VrmCanvas.vue';
declare const ACESFilmicToneMapping: 4;
declare const AddEquation: 100;
declare const AdditiveAnimationBlendMode: 2501;
declare const AdditiveBlending: 2;
declare const AddOperation: 2;
declare const AgXToneMapping: 6;
/** {@link AlphaFormat} discards the red, green and blue components and reads just the alpha component. */
declare const AlphaFormat: 1021;
declare const AlwaysCompare: 519;
declare const AlwaysDepth: 1;
declare const AlwaysStencilFunc: 519;
/**
* An instance of `AnimationAction` schedules the playback of an animation which is
* stored in {@link AnimationClip}.
*/
declare class AnimationAction {
/**
* Constructs a new animation action.
*
* @param {AnimationMixer} mixer - The mixer that is controlled by this action.
* @param {AnimationClip} clip - The animation clip that holds the actual keyframes.
* @param {?Object3D} [localRoot=null] - The root object on which this action is performed.
* @param {(NormalAnimationBlendMode|AdditiveAnimationBlendMode)} [blendMode] - The blend mode.
*/
constructor(
mixer: AnimationMixer,
clip: AnimationClip,
localRoot?: Object3D | null,
blendMode?: AnimationBlendMode,
);
/**
* Defines how the animation is blended/combined when two or more animations
* are simultaneously played.
*/
blendMode: AnimationBlendMode;
/**
* The loop mode, set via {@link AnimationAction#setLoop}.
*
* @default LoopRepeat
*/
loop: AnimationActionLoopStyles;
/**
* The local time of this action (in seconds, starting with `0`).
*
* The value gets clamped or wrapped to `[0,clip.duration]` (according to the
* loop state).
*
* @default Infinity
*/
time: number;
/**
* Scaling factor for the {@link AnimationAction#time}. A value of `0` causes the
* animation to pause. Negative values cause the animation to play backwards.
*
* @default 1
*/
timeScale: number;
/**
* The degree of influence of this action (in the interval `[0, 1]`). Values
* between `0` (no impact) and `1` (full impact) can be used to blend between
* several actions.
*
* @default 1
*/
weight: number;
/**
* The number of repetitions of the performed clip over the course of this action.
* Can be set via {@link AnimationAction#setLoop}.
*
* Setting this number has no effect if {@link AnimationAction#loop} is set to
* `THREE:LoopOnce`.
*
* @default Infinity
*/
repetitions: number;
/**
* If set to `true`, the playback of the action is paused.
*
* @default false
*/
paused: boolean;
/**
* If set to `false`, the action is disabled so it has no impact.
*
* When the action is re-enabled, the animation continues from its current
* time (setting `enabled` to `false` doesn't reset the action).
*
* @default true
*/
enabled: boolean;
/**
* If set to true the animation will automatically be paused on its last frame.
*
* If set to false, {@link AnimationAction#enabled} will automatically be switched
* to `false` when the last loop of the action has finished, so that this action has
* no further impact.
*
* Note: This member has no impact if the action is interrupted (it
* has only an effect if its last loop has really finished).
*
* @default false
*/
clampWhenFinished: boolean;
/**
* Enables smooth interpolation without separate clips for start, loop and end.
*
* @default true
*/
zeroSlopeAtStart: boolean;
/**
* Enables smooth interpolation without separate clips for start, loop and end.
*
* @default true
*/
zeroSlopeAtEnd: boolean;
/**
* Starts the playback of the animation.
*
* @return {AnimationAction} A reference to this animation action.
*/
play(): AnimationAction;
/**
* Stops the playback of the animation.
*
* @return {AnimationAction} A reference to this animation action.
*/
stop(): AnimationAction;
/**
* Resets the playback of the animation.
*
* @return {AnimationAction} A reference to this animation action.
*/
reset(): AnimationAction;
/**
* Returns `true` if the animation is running.
*
* @return {boolean} Whether the animation is running or not.
*/
isRunning(): boolean;
/**
* Returns `true` when {@link AnimationAction#play} has been called.
*
* @return {boolean} Whether the animation is scheduled or not.
*/
isScheduled(): boolean;
/**
* Defines the time when the animation should start.
*
* @param {number} time - The start time in seconds.
* @return {AnimationAction} A reference to this animation action.
*/
startAt(time: number): AnimationAction;
/**
* Configures the loop settings for this action.
*
* @param {(LoopRepeat|LoopOnce|LoopPingPong)} mode - The loop mode.
* @param {number} repetitions - The number of repetitions.
* @return {AnimationAction} A reference to this animation action.
*/
setLoop(mode: AnimationActionLoopStyles, repetitions: number): AnimationAction;
/**
* Sets the effective weight of this action.
*
* An action has no effect and thus an effective weight of zero when the
* action is disabled.
*
* @param {number} weight - The weight to set.
* @return {AnimationAction} A reference to this animation action.
*/
setEffectiveWeight(weight: number): AnimationAction;
/**
* Returns the effective weight of this action.
*
* @return {number} The effective weight.
*/
getEffectiveWeight(): number;
/**
* Fades the animation in by increasing its weight gradually from `0` to `1`,
* within the passed time interval.
*
* @param {number} duration - The duration of the fade.
* @return {AnimationAction} A reference to this animation action.
*/
fadeIn(duration: number): AnimationAction;
/**
* Fades the animation out by decreasing its weight gradually from `1` to `0`,
* within the passed time interval.
*
* @param {number} duration - The duration of the fade.
* @return {AnimationAction} A reference to this animation action.
*/
fadeOut(duration: number): AnimationAction;
/**
* Causes this action to fade in and the given action to fade out,
* within the passed time interval.
*
* @param {AnimationAction} fadeOutAction - The animation action to fade out.
* @param {number} duration - The duration of the fade.
* @param {boolean} [warp=false] - Whether warping should be used or not.
* @return {AnimationAction} A reference to this animation action.
*/
crossFadeFrom(fadeOutAction: AnimationAction, duration: number, warp?: boolean): AnimationAction;
/**
* Causes this action to fade out and the given action to fade in,
* within the passed time interval.
*
* @param {AnimationAction} fadeInAction - The animation action to fade in.
* @param {number} duration - The duration of the fade.
* @param {boolean} [warp=false] - Whether warping should be used or not.
* @return {AnimationAction} A reference to this animation action.
*/
crossFadeTo(fadeInAction: AnimationAction, duration: number, warp?: boolean): AnimationAction;
/**
* Stops any fading which is applied to this action.
*
* @return {AnimationAction} A reference to this animation action.
*/
stopFading(): AnimationAction;
/**
* Sets the effective time scale of this action.
*
* An action has no effect and thus an effective time scale of zero when the
* action is paused.
*
* @param {number} timeScale - The time scale to set.
* @return {AnimationAction} A reference to this animation action.
*/
setEffectiveTimeScale(timeScale: number): AnimationAction;
/**
* Returns the effective time scale of this action.
*
* @return {number} The effective time scale.
*/
getEffectiveTimeScale(): number;
/**
* Sets the duration for a single loop of this action.
*
* @param {number} duration - The duration to set.
* @return {AnimationAction} A reference to this animation action.
*/
setDuration(duration: number): AnimationAction;
/**
* Synchronizes this action with the passed other action.
*
* @param {AnimationAction} action - The action to sync with.
* @return {AnimationAction} A reference to this animation action.
*/
syncWith(action: AnimationAction): AnimationAction;
/**
* Decelerates this animation's speed to `0` within the passed time interval.
*
* @param {number} duration - The duration.
* @return {AnimationAction} A reference to this animation action.
*/
halt(duration: number): AnimationAction;
/**
* Changes the playback speed, within the passed time interval, by modifying
* {@link AnimationAction#timeScale} gradually from `startTimeScale` to
* `endTimeScale`.
*
* @param {number} startTimeScale - The start time scale.
* @param {number} endTimeScale - The end time scale.
* @param {number} duration - The duration.
* @return {AnimationAction} A reference to this animation action.
*/
warp(startTimeScale: number, endTimeScale: number, duration: number): AnimationAction;
/**
* Stops any scheduled warping which is applied to this action.
*
* @return {AnimationAction} A reference to this animation action.
*/
stopWarping(): AnimationAction;
/**
* Returns the animation mixer of this animation action.
*
* @return {AnimationMixer} The animation mixer.
*/
getMixer(): AnimationMixer;
/**
* Returns the animation clip of this animation action.
*
* @return {AnimationClip} The animation clip.
*/
getClip(): AnimationClip;
/**
* Returns the root object of this animation action.
*
* @return {Object3D} The root object.
*/
getRoot(): Object3D;
_scheduleFading(duration: number, weightNow: number, weightThen: number): this;
}
declare type AnimationActionLoopStyles = typeof LoopOnce | typeof LoopRepeat | typeof LoopPingPong;
declare type AnimationBlendMode = typeof NormalAnimationBlendMode | typeof AdditiveAnimationBlendMode;
/**
* A reusable set of keyframe tracks which represent an animation.
*/
declare class AnimationClip {
/**
* Factory method for creating an animation clip from the given JSON.
*
* @static
* @param {Object} json - The serialized animation clip.
* @return {AnimationClip} The new animation clip.
*/
static parse(json: AnimationClipJSON): AnimationClip;
/**
* Serializes the given animation clip into JSON.
*
* @static
* @param {AnimationClip} clip - The animation clip to serialize.
* @return {Object} The JSON object.
*/
static toJSON(clip: AnimationClip): AnimationClipJSON;
/**
* Returns a new animation clip from the passed morph targets array of a
* geometry, taking a name and the number of frames per second.
*
* Note: The fps parameter is required, but the animation speed can be
* overridden via {@link AnimationAction#setDuration}.
*
* @static
* @param {string} name - The name of the animation clip.
* @param {Array} morphTargetSequence - A sequence of morph targets.
* @param {number} fps - The Frames-Per-Second value.
* @param {boolean} noLoop - Whether the clip should be no loop or not.
* @return {AnimationClip} The new animation clip.
*/
static CreateFromMorphTargetSequence(
name: string,
morphTargetSequence: Array,
fps: number,
noLoop: boolean,
): AnimationClip;
/**
* Searches for an animation clip by name, taking as its first parameter
* either an array of clips, or a mesh or geometry that contains an
* array named "animations" property.
*
* @static
* @param {(Array|Object3D)} objectOrClipArray - The array or object to search through.
* @param {string} name - The name to search for.
* @return {?AnimationClip} The found animation clip. Returns `null` if no clip has been found.
*/
static findByName(objectOrClipArray: Array | Object3D, name: string): AnimationClip | null;
/**
* Returns an array of new AnimationClips created from the morph target
* sequences of a geometry, trying to sort morph target names into
* animation-group-based patterns like "Walk_001, Walk_002, Run_001, Run_002...".
*
* See {@link MD2Loader#parse} as an example for how the method should be used.
*
* @static
* @param {Array} morphTargets - A sequence of morph targets.
* @param {number} fps - The Frames-Per-Second value.
* @param {boolean} noLoop - Whether the clip should be no loop or not.
* @return {Array} An array of new animation clips.
*/
static CreateClipsFromMorphTargetSequences(
morphTargets: Array,
fps: number,
noLoop: boolean,
): Array;
/**
* Constructs a new animation clip.
*
* Note: Instead of instantiating an AnimationClip directly with the constructor, you can
* use the static interface of this class for creating clips. In most cases though, animation clips
* will automatically be created by loaders when importing animated 3D assets.
*
* @param {string} [name=''] - The clip's name.
* @param {number} [duration=-1] - The clip's duration in seconds. If a negative value is passed,
* the duration will be calculated from the passed keyframes.
* @param {Array} tracks - An array of keyframe tracks.
* @param {(NormalAnimationBlendMode|AdditiveAnimationBlendMode)} [blendMode=NormalAnimationBlendMode] - Defines how the animation
* is blended/combined when two or more animations are simultaneously played.
*/
constructor(name?: string, duration?: number, tracks?: Array, blendMode?: AnimationBlendMode);
/**
* The clip's name.
*/
name: string;
/**
* An array of keyframe tracks.
*/
tracks: Array;
/**
* The clip's duration in seconds.
*/
duration: number;
/**
* Defines how the animation is blended/combined when two or more animations
* are simultaneously played.
*/
blendMode: AnimationBlendMode;
/**
* The UUID of the animation clip.
*/
readonly uuid: string;
/**
* An object that can be used to store custom data about the animation clip.
* It should not hold references to functions as these will not be cloned.
*/
userData: Record;
/**
* Sets the duration of this clip to the duration of its longest keyframe track.
*
* @return {AnimationClip} A reference to this animation clip.
*/
resetDuration(): AnimationClip;
/**
* Trims all tracks to the clip's duration.
*
* @return {AnimationClip} A reference to this animation clip.
*/
trim(): AnimationClip;
/**
* Performs minimal validation on each track in the clip. Returns `true` if all
* tracks are valid.
*
* @return {boolean} Whether the clip's keyframes are valid or not.
*/
validate(): boolean;
/**
* Optimizes each track by removing equivalent sequential keys (which are
* common in morph target sequences).
*
* @return {AnimationClip} A reference to this animation clip.
*/
optimize(): AnimationClip;
/**
* Returns a new animation clip with copied values from this instance.
*
* @return {AnimationClip} A clone of this instance.
*/
clone(): this;
/**
* Serializes this animation clip into JSON.
*
* @return {Object} The JSON object.
*/
toJSON(): AnimationClipJSON;
}
declare interface AnimationClipJSON {
name: string;
duration: number;
tracks: KeyframeTrackJSON[];
uuid: string;
blendMode: AnimationBlendMode;
}
/**
* `AnimationMixer` is a player for animations on a particular object in
* the scene. When multiple objects in the scene are animated independently,
* one `AnimationMixer` may be used for each object.
*/
declare class AnimationMixer
extends EventDispatcher
{
/**
* Constructs a new animation mixer.
*
* @param {Object3D} root - The object whose animations shall be played by this mixer.
*/
constructor(root: Object3D | AnimationObjectGroup);
/**
* The global mixer time (in seconds; starting with `0` on the mixer's creation).
*
* @default 0
*/
time: number;
protected _root: Object3D | AnimationObjectGroup;
protected _actions: AnimationAction[];
protected _nActiveActions: number;
protected _bindings: PropertyMixer[];
protected _nActiveBindings: number;
protected _controlInterpolants: MixerControlInterpolant[];
protected _nActiveControlInterpolants: number;
protected _bindingsByRootAndName: {
[rootUuid: string]: { [trackName: string]: PropertyMixer };
};
protected _actionsByClip: {
[clipUuid: string]: {
knownActions: AnimationAction[];
actionByRoot: { [rootUuid: string]: AnimationAction };
};
};
protected _accuIndex: number;
/**
* A scaling factor for the global time.
*
* Note: Setting this member to `0` and later back to `1` is a
* possibility to pause/unpause all actions that are controlled by this
* mixer.
*
* @default 1
*/
timeScale: number;
/**
* The AnimationMixer stats track the actions of the mixer.
*/
stats: AnimationMixerStats;
/**
* Returns an instance of {@link AnimationAction} for the passed clip.
*
* If an action fitting the clip and root parameters doesn't yet exist, it
* will be created by this method. Calling this method several times with the
* same clip and root parameters always returns the same action.
*
* @param {AnimationClip|string} clip - An animation clip or alternatively the name of the animation clip.
* @param {Object3D} [optionalRoot] - An alternative root object.
* @param {(NormalAnimationBlendMode|AdditiveAnimationBlendMode)} [blendMode] - The blend mode.
* @return {?AnimationAction} The animation action.
*/
clipAction(
clip: AnimationClip,
optionalRoot?: Object3D | AnimationObjectGroup,
blendMode?: AnimationBlendMode,
): AnimationAction;
clipAction(
clip: AnimationClip | string,
optionalRoot?: Object3D | AnimationObjectGroup,
blendMode?: AnimationBlendMode,
): AnimationAction | null;
/**
* Returns an existing animation action for the passed clip.
*
* @param {AnimationClip|string} clip - An animation clip or alternatively the name of the animation clip.
* @param {Object3D} [optionalRoot] - An alternative root object.
* @return {?AnimationAction} The animation action. Returns `null` if no action was found.
*/
existingAction(
clip: AnimationClip | string,
optionalRoot?: Object3D | AnimationObjectGroup,
): AnimationAction | null;
/**
* Deactivates all previously scheduled actions on this mixer.
*
* @return {AnimationMixer} A reference to this animation mixer.
*/
stopAllAction(): AnimationMixer;
/**
* Advances the global mixer time and updates the animation.
*
* This is usually done in the render loop by passing the delta
* time from {@link Clock} or {@link Timer}.
*
* @param {number} deltaTime - The delta time in seconds.
* @return {AnimationMixer} A reference to this animation mixer.
*/
update(deltaTime: number): AnimationMixer;
/**
* Sets the global mixer to a specific time and updates the animation accordingly.
*
* This is useful when you need to jump to an exact time in an animation. The
* input parameter will be scaled by {@link AnimationMixer#timeScale}
*
* @param {number} time - The time to set in seconds.
* @return {AnimationMixer} A reference to this animation mixer.
*/
setTime(time: number): AnimationMixer;
/**
* Returns this mixer's root object.
*
* @return {Object3D} The mixer's root object.
*/
getRoot(): Object3D | AnimationObjectGroup;
/**
* Deallocates all memory resources for a clip. Before using this method make
* sure to call {@link AnimationAction#stop} for all related actions.
*
* @param {AnimationClip} clip - The clip to uncache.
*/
uncacheClip(clip: AnimationClip): void;
/**
* Deallocates all memory resources for a root object. Before using this
* method make sure to call {@link AnimationAction#stop} for all related
* actions or alternatively {@link AnimationMixer#stopAllAction} when the
* mixer operates on a single root.
*
* @param {Object3D} root - The root object to uncache.
*/
uncacheRoot(root: Object3D | AnimationObjectGroup): void;
/**
* Deallocates all memory resources for an action. The action is identified by the
* given clip and an optional root object. Before using this method make
* sure to call {@link AnimationAction#stop} to deactivate the action.
*
* @param {AnimationClip|string} clip - An animation clip or alternatively the name of the animation clip.
* @param {Object3D} [optionalRoot] - An alternative root object.
*/
uncacheAction(clip: AnimationClip | string, optionalRoot?: Object3D | AnimationObjectGroup): void;
}
declare interface AnimationMixerEventMap {
loop: { action: AnimationAction; loopDelta: number };
finished: { action: AnimationAction; direction: number };
}
declare interface AnimationMixerStats {
actions: {
readonly total: number;
readonly inUse: number;
};
bindings: {
readonly total: number;
readonly inUse: number;
};
controlInterpolants: {
readonly total: number;
readonly inUse: number;
};
}
/**
* A group of objects that receives a shared animation state.
*
* Usage:
*
* - Add objects you would otherwise pass as 'root' to the
* constructor or the .clipAction method of AnimationMixer.
* - Instead pass this object as 'root'.
* - You can also add and remove objects later when the mixer is running.
*
* Note:
*
* - Objects of this class appear as one object to the mixer,
* so cache control of the individual objects must be done on the group.
*
* Limitation:
*
* - The animated properties must be compatible among the all objects in the group.
* - A single property can either be controlled through a target group or directly, but not both.
*/
declare class AnimationObjectGroup {
/**
* Constructs a new animation group.
*
* @param {...Object3D} arguments - An arbitrary number of 3D objects that share the same animation state.
*/
constructor(...args: Object3D[]);
/**
* This flag can be used for type testing.
*
* @default true
*/
readonly isAnimationObjectGroup: true;
/**
* The UUID of the 3D object.
*/
readonly uuid: string;
/**
* Adds an arbitrary number of objects to this animation group.
*
* @param {...Object3D} arguments - The 3D objects to add.
*/
add(...args: Object3D[]): void;
/**
* Removes an arbitrary number of objects to this animation group
*
* @param {...Object3D} arguments - The 3D objects to remove.
*/
remove(...args: Object3D[]): void;
/**
* Deallocates all memory resources for the passed 3D objects of this animation group.
*
* @param {...Object3D} arguments - The 3D objects to uncache.
*/
uncache(...args: Object3D[]): void;
}
/**
* Texture Mapping Modes for any type of Textures
* @see {@link Mapping} and {@link CubeTextureMapping}
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
*/
declare type AnyMapping = Mapping | CubeTextureMapping;
/**
* All Possible Texture Pixel Formats Modes. For any Type or SubType of Textures.
* @remarks Note that the texture must have the correct {@link THREE.Texture.type} set, as described in {@link TextureDataType}.
* @see {@link WebGLRenderingContext.texImage2D} for details.
* @see {@link PixelFormat} and {@link DepthTexturePixelFormat} and {@link CompressedPixelFormat}
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
*/
declare type AnyPixelFormat = PixelFormat | DepthTexturePixelFormat | CompressedPixelFormat;
/**
* This type of camera can be used in order to efficiently render a scene with a
* predefined set of cameras. This is an important performance aspect for
* rendering VR scenes.
*
* An instance of `ArrayCamera` always has an array of sub cameras. It's mandatory
* to define for each sub camera the `viewport` property which determines the
* part of the viewport that is rendered with this camera.
*/
declare class ArrayCamera extends PerspectiveCamera {
/**
* Constructs a new array camera.
*
* @param {Array} [array=[]] - An array of perspective sub cameras.
*/
constructor(array?: PerspectiveCamera[]);
/**
* This flag can be used for type testing.
*
* @default true
*/
readonly isArrayCamera: boolean;
/**
* Whether this camera is used with multiview rendering or not.
*
* @default false
*/
readonly isMultiViewCamera: boolean;
/**
* An array of perspective sub cameras.
*/
cameras: PerspectiveCamera[];
}
declare type AttributeGPUType = typeof FloatType | typeof IntType;
/**
* Position a freshly loaded VRM so that its feet rest on y=0.
* Assumes the VRM's root is at the model origin and that the model is properly centered.
* Modifies the VRM's scene position in-place.
* Does not throw if the VRM has no scene or if bounding box calculation fails; in that case, the VRM is left unmodified.
*
* @param vrm The VRM instance to adjust.
*/
export declare function autoPositionY(vrm: VRM): void {
vrm.scene.updateMatrixWorld(true);
const box = new Box3().setFromObject(vrm.scene);
const minY = box.min.y;
vrm.scene.position.y -= minY;
}
declare const BackSide: 1;
/**
* The minimal basic Event that can be dispatched by a {@link EventDispatcher<>}.
*/
declare interface BaseEvent {
readonly type: TEventType;
}
declare const BasicDepthPacking: 3200;
declare const BasicShadowMap: 0;
/**
* A Bezier interpolant using cubic Bezier curves with 2D control points.
*
* This interpolant supports the COLLADA/Maya style of Bezier animation where
* each keyframe has explicit in/out tangent control points specified as
* 2D coordinates (time, value).
*
* Tangent data is read from `inTangents` and `outTangents` on the interpolant
* (populated by `KeyframeTrack.InterpolantFactoryMethodBezier`).
*
* For a track with N keyframes and stride S:
* - Each tangent array has N * S * 2 values
* - Layout: [k0_c0_time, k0_c0_value, k0_c1_time, k0_c1_value, ..., k0_cS_time, k0_cS_value,
* k1_c0_time, k1_c0_value, ...]
*
* @augments Interpolant
*/
declare class BezierInterpolant extends Interpolant {
interpolate_(i1: number, t0: number, t: number, t1: number): TypedArray;
}
declare type Blending =
| typeof NoBlending
| typeof NormalBlending
| typeof AdditiveBlending
| typeof SubtractiveBlending
| typeof MultiplyBlending
| typeof CustomBlending
| typeof MaterialBlending;
declare type BlendingDstFactor =
| typeof ZeroFactor
| typeof OneFactor
| typeof SrcColorFactor
| typeof OneMinusSrcColorFactor
| typeof SrcAlphaFactor
| typeof OneMinusSrcAlphaFactor
| typeof DstAlphaFactor
| typeof OneMinusDstAlphaFactor
| typeof DstColorFactor
| typeof OneMinusDstColorFactor
| typeof ConstantColorFactor
| typeof OneMinusConstantColorFactor
| typeof ConstantAlphaFactor
| typeof OneMinusConstantAlphaFactor;
declare type BlendingEquation =
| typeof AddEquation
| typeof SubtractEquation
| typeof ReverseSubtractEquation
| typeof MinEquation
| typeof MaxEquation;
declare type BlendingSrcFactor = BlendingDstFactor | typeof SrcAlphaSaturateFactor;
/**
* A {@link Bone} which is part of a {@link THREE.Skeleton | Skeleton}
* @remarks
* The skeleton in turn is used by the {@link THREE.SkinnedMesh | SkinnedMesh}
* Bones are almost identical to a blank {@link THREE.Object3D | Object3D}.
* @example
* ```typescript
* const root = new THREE.Bone();
* const child = new THREE.Bone();
* root.add(child);
* child.position.y = 5;
* ```
* @see {@link https://threejs.org/docs/index.html#api/en/objects/Bone | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/objects/Bone.js | Source}
*/
declare class Bone extends Object3D {
/**
* Creates a new {@link Bone}.
*/
constructor();
/**
* Read-only flag to check if a given object is of type {@link Bone}.
* @remarks This is a _constant_ value
* @defaultValue `true`
*/
readonly isBone: true;
/**
* @override
* @defaultValue `Bone`
*/
override readonly type: string | "Bone";
}
declare class Box2 {
constructor(min?: Vector2, max?: Vector2);
/**
* @default new THREE.Vector2( + Infinity, + Infinity )
*/
min: Vector2;
/**
* @default new THREE.Vector2( - Infinity, - Infinity )
*/
max: Vector2;
set(min: Vector2, max: Vector2): Box2;
setFromPoints(points: Vector2Like[]): Box2;
setFromCenterAndSize(center: Vector2, size: Vector2): Box2;
clone(): this;
copy(box: Box2): this;
makeEmpty(): Box2;
isEmpty(): boolean;
getCenter(target: Vector2): Vector2;
getSize(target: Vector2): Vector2;
expandByPoint(point: Vector2Like): Box2;
expandByVector(vector: Vector2): Box2;
expandByScalar(scalar: number): Box2;
containsPoint(point: Vector2): boolean;
containsBox(box: Box2): boolean;
getParameter(point: Vector2, target: Vector2): Vector2;
intersectsBox(box: Box2): boolean;
clampPoint(point: Vector2, target: Vector2): Vector2;
distanceToPoint(point: Vector2): number;
intersect(box: Box2): Box2;
union(box: Box2): Box2;
translate(offset: Vector2): Box2;
equals(box: Box2): boolean;
/**
* @deprecated Use {@link Box2#isEmpty .isEmpty()} instead.
*/
empty(): any;
/**
* @deprecated Use {@link Box2#intersectsBox .intersectsBox()} instead.
*/
isIntersectionBox(b: any): any;
}
/**
* Represents an axis-aligned bounding box (AABB) in 3D space.
*/
declare class Box3 {
/**
* Constructs a new bounding box.
*
* @param {Vector3} [min=(Infinity,Infinity,Infinity)] - A vector representing the lower boundary of the box.
* @param {Vector3} [max=(-Infinity,-Infinity,-Infinity)] - A vector representing the upper boundary of the box.
*/
constructor(min?: Vector3, max?: Vector3);
/**
* This flag can be used for type testing.
*
* @type {boolean}
* @readonly
* @default true
*/
readonly isBox3: boolean;
/**
* The lower boundary of the box.
*
* @type {Vector3}
*/
min: Vector3;
/**
* The upper boundary of the box.
*
* @type {Vector3}
*/
max: Vector3;
/**
* Sets the lower and upper boundaries of this box.
* Please note that this method only copies the values from the given objects.
*
* @param {Vector3} min - The lower boundary of the box.
* @param {Vector3} max - The upper boundary of the box.
* @return {Box3} A reference to this bounding box.
*/
set(min: Vector3, max: Vector3): this;
/**
* Sets the upper and lower bounds of this box so it encloses the position data
* in the given array.
*
* @param {Array} array - An array holding 3D position data.
* @return {Box3} A reference to this bounding box.
*/
setFromArray(array: ArrayLike): this;
/**
* Sets the upper and lower bounds of this box so it encloses the position data
* in the given buffer attribute.
*
* @param {BufferAttribute} attribute - A buffer attribute holding 3D position data.
* @return {Box3} A reference to this bounding box.
*/
setFromBufferAttribute(attribute: BufferAttribute): this;
/**
* Sets the upper and lower bounds of this box so it encloses the position data
* in the given array.
*
* @param {Array} points - An array holding 3D position data as instances of {@link Vector3}.
* @return {Box3} A reference to this bounding box.
*/
setFromPoints(points: Array): this;
/**
* Centers this box on the given center vector and sets this box's width, height and
* depth to the given size values.
*
* @param {Vector3} center - The center of the box.
* @param {Vector3} size - The x, y and z dimensions of the box.
* @return {Box3} A reference to this bounding box.
*/
setFromCenterAndSize(center: Vector3, size: Vector3): this;
/**
* Computes the world-axis-aligned bounding box for the given 3D object
* (including its children), accounting for the object's, and children's,
* world transforms. The function may result in a larger box than strictly necessary.
*
* Note: To compute the correct bounding box, make sure the given 3D object
* has an up-to-date world matrix that reflects the current transformation of its
* ancestor nodes. Call `object.updateWorldMatrix( true, false )` beforehand if
* you're unsure.
*
* @param {Object3D} object - The 3D object to compute the bounding box for.
* @param {boolean} [precise=false] - If set to `true`, the method computes the smallest
* world-axis-aligned bounding box at the expense of more computation.
* @return {Box3} A reference to this bounding box.
*/
setFromObject(object: Object3D, precise?: boolean): this;
/**
* Returns a new box with copied values from this instance.
*
* @return {Box3} A clone of this instance.
*/
clone(): this;
/**
* Copies the values of the given box to this instance.
*
* @param {Box3} box - The box to copy.
* @return {Box3} A reference to this bounding box.
*/
copy(box: Box3): this;
/**
* Makes this box empty which means in encloses a zero space in 3D.
*
* @return {Box3} A reference to this bounding box.
*/
makeEmpty(): this;
/**
* Returns true if this box includes zero points within its bounds.
* Note that a box with equal lower and upper bounds still includes one
* point, the one both bounds share.
*
* @return {boolean} Whether this box is empty or not.
*/
isEmpty(): boolean;
/**
* Returns the center point of this box.
*
* @param {Vector3} target - The target vector that is used to store the method's result.
* @return {Vector3} The center point.
*/
getCenter(target: Vector3): Vector3;
/**
* Returns the dimensions of this box.
*
* @param {Vector3} target - The target vector that is used to store the method's result.
* @return {Vector3} The size.
*/
getSize(target: Vector3): Vector3;
/**
* Expands the boundaries of this box to include the given point.
*
* @param {Vector3} point - The point that should be included by the bounding box.
* @return {Box3} A reference to this bounding box.
*/
expandByPoint(point: Vector3Like): this;
/**
* Expands this box equilaterally by the given vector. The width of this
* box will be expanded by the x component of the vector in both
* directions. The height of this box will be expanded by the y component of
* the vector in both directions. The depth of this box will be
* expanded by the z component of the vector in both directions.
*
* @param {Vector3} vector - The vector that should expand the bounding box.
* @return {Box3} A reference to this bounding box.
*/
expandByVector(vector: Vector3): this;
/**
* Expands each dimension of the box by the given scalar. If negative, the
* dimensions of the box will be contracted.
*
* @param {number} scalar - The scalar value that should expand the bounding box.
* @return {Box3} A reference to this bounding box.
*/
expandByScalar(scalar: number): this;
/**
* Expands the boundaries of this box to include the given 3D object and
* its children, accounting for the object's, and children's, world
* transforms. The function may result in a larger box than strictly
* necessary (unless the precise parameter is set to true).
*
* @param {Object3D} object - The 3D object that should expand the bounding box.
* @param {boolean} precise - If set to `true`, the method expands the bounding box
* as little as necessary at the expense of more computation.
* @return {Box3} A reference to this bounding box.
*/
expandByObject(object: Object3D, precise?: boolean): this;
/**
* Returns `true` if the given point lies within or on the boundaries of this box.
*
* @param {Vector3} point - The point to test.
* @return {boolean} Whether the bounding box contains the given point or not.
*/
containsPoint(point: Vector3): boolean;
/**
* Returns `true` if this bounding box includes the entirety of the given bounding box.
* If this box and the given one are identical, this function also returns `true`.
*
* @param {Box3} box - The bounding box to test.
* @return {boolean} Whether the bounding box contains the given bounding box or not.
*/
containsBox(box: Box3): boolean;
/**
* Returns a point as a proportion of this box's width, height and depth.
*
* @param {Vector3} point - A point in 3D space.
* @param {Vector3} target - The target vector that is used to store the method's result.
* @return {Vector3} A point as a proportion of this box's width, height and depth.
*/
getParameter(point: Vector3, target: Vector3): Vector3;
/**
* Returns `true` if the given bounding box intersects with this bounding box.
*
* @param {Box3} box - The bounding box to test.
* @return {boolean} Whether the given bounding box intersects with this bounding box.
*/
intersectsBox(box: Box3): boolean;
/**
* Returns `true` if the given bounding sphere intersects with this bounding box.
*
* @param {Sphere} sphere - The bounding sphere to test.
* @return {boolean} Whether the given bounding sphere intersects with this bounding box.
*/
intersectsSphere(sphere: Sphere): boolean;
/**
* Returns `true` if the given plane intersects with this bounding box.
*
* @param {Plane} plane - The plane to test.
* @return {boolean} Whether the given plane intersects with this bounding box.
*/
intersectsPlane(plane: Plane): boolean;
/**
* Returns `true` if the given triangle intersects with this bounding box.
*
* @param {Triangle} triangle - The triangle to test.
* @return {boolean} Whether the given triangle intersects with this bounding box.
*/
intersectsTriangle(triangle: Triangle): boolean;
/**
* Clamps the given point within the bounds of this box.
*
* @param {Vector3} point - The point to clamp.
* @param {Vector3} target - The target vector that is used to store the method's result.
* @return {Vector3} The clamped point.
*/
clampPoint(point: Vector3, target: Vector3): Vector3;
/**
* Returns the euclidean distance from any edge of this box to the specified point. If
* the given point lies inside of this box, the distance will be `0`.
*
* @param {Vector3} point - The point to compute the distance to.
* @return {number} The euclidean distance.
*/
distanceToPoint(point: Vector3): number;
/**
* Returns a bounding sphere that encloses this bounding box.
*
* @param {Sphere} target - The target sphere that is used to store the method's result.
* @return {Sphere} The bounding sphere that encloses this bounding box.
*/
getBoundingSphere(target: Sphere): Sphere;
/**
* Computes the intersection of this bounding box and the given one, setting the upper
* bound of this box to the lesser of the two boxes' upper bounds and the
* lower bound of this box to the greater of the two boxes' lower bounds. If
* there's no overlap, makes this box empty.
*
* @param {Box3} box - The bounding box to intersect with.
* @return {Box3} A reference to this bounding box.
*/
intersect(box: Box3): this;
/**
* Computes the union of this box and another and the given one, setting the upper
* bound of this box to the greater of the two boxes' upper bounds and the
* lower bound of this box to the lesser of the two boxes' lower bounds.
*
* @param {Box3} box - The bounding box that will be unioned with this instance.
* @return {Box3} A reference to this bounding box.
*/
union(box: Box3): this;
/**
* Transforms this bounding box by the given 4x4 transformation matrix.
*
* @param {Matrix4} matrix - The transformation matrix.
* @return {Box3} A reference to this bounding box.
*/
applyMatrix4(matrix: Matrix4): this;
/**
* Adds the given offset to both the upper and lower bounds of this bounding box,
* effectively moving it in 3D space.
*
* @param {Vector3} offset - The offset that should be used to translate the bounding box.
* @return {Box3} A reference to this bounding box.
*/
translate(offset: Vector3): this;
/**
* Returns `true` if this bounding box is equal with the given one.
*
* @param {Box3} box - The box to test for equality.
* @return {boolean} Whether this bounding box is equal with the given one.
*/
equals(box: Box3): boolean;
/**
* Returns a serialized structure of the bounding box.
*
* @return {Object} Serialized structure with fields representing the object state.
*/
toJSON(): Box3JSON;
/**
* Returns a serialized structure of the bounding box.
*
* @param {Object} json - The serialized json to set the box from.
* @return {Box3} A reference to this bounding box.
*/
fromJSON(json: Box3JSON): this;
}
declare interface Box3JSON {
min: number[];
max: number[];
}
/**
* This class stores data for an attribute (such as vertex positions, face indices, normals, colors, UVs, and any custom attributes )
* associated with a {@link THREE.BufferGeometry | BufferGeometry}, which allows for more efficient passing of data to the GPU
* @remarks
* When working with _vector-like_ data, the _`.fromBufferAttribute( attribute, index )`_ helper methods on
* {@link THREE.Vector2.fromBufferAttribute | Vector2},
* {@link THREE.Vector3.fromBufferAttribute | Vector3},
* {@link THREE.Vector4.fromBufferAttribute | Vector4}, and
* {@link THREE.Color.fromBufferAttribute | Color} classes may be helpful.
* @see {@link THREE.BufferGeometry | BufferGeometry} for details and a usage examples.
* @see Example: {@link https://threejs.org/examples/#webgl_buffergeometry | WebGL / BufferGeometry - Clean up Memory}
* @see {@link https://threejs.org/docs/index.html#api/en/core/BufferAttribute | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/core/BufferAttribute.js | Source}
*/
declare class BufferAttribute
extends EventDispatcher
{
/**
* This creates a new {@link THREE.GLBufferAttribute | GLBufferAttribute} object.
* @param array Must be a `TypedArray`. Used to instantiate the buffer.
* This array should have `itemSize * numVertices` elements, where numVertices is the number of vertices in the associated {@link THREE.BufferGeometry | BufferGeometry}.
* @param itemSize the number of values of the {@link array} that should be associated with a particular vertex.
* For instance, if this attribute is storing a 3-component vector (such as a _position_, _normal_, or _color_),
* then itemSize should be `3`.
* @param normalized Applies to integer data only.
* Indicates how the underlying data in the buffer maps to the values in the GLSL code.
* For instance, if {@link array} is an instance of `UInt16Array`, and {@link normalized} is true,
* the values `0` - `+65535` in the array data will be mapped to `0.0f` - `+1.0f` in the GLSL attribute.
* An `Int16Array` (signed) would map from `-32768` - `+32767` to `-1.0f` - `+1.0f`.
* If normalized is false, the values will be converted to floats unmodified,
* i.e. `32767` becomes `32767.0f`.
* Default `false`.
* @throws `TypeError` When the {@link array} is not a `TypedArray`;
*/
constructor(array: TypedArray, itemSize: number, normalized?: boolean);
/**
* Unique number for this attribute instance.
*/
readonly id: number;
/**
* Optional name for this attribute instance.
* @defaultValue ''
*/
name: string;
/**
* The {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray | TypedArray} holding data stored in the buffer.
* @returns `TypedArray`
*/
array: TypedArray;
/**
* The length of vectors that are being stored in the {@link BufferAttribute.array | array}.
* @remarks Expects a `Integer`
*/
itemSize: number;
/**
* Defines the intended usage pattern of the data store for optimization purposes.
* Corresponds to the {@link BufferAttribute.usage | usage} parameter of
* {@link https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData | WebGLRenderingContext.bufferData}.
* @remarks
* After the initial use of a buffer, its usage cannot be changed. Instead, instantiate a new one and set the desired usage before the next render.
* @see {@link https://threejs.org/docs/index.html#api/en/constants/BufferAttributeUsage | Buffer Attribute Usage Constants} for all possible values.
* @see {@link BufferAttribute.setUsage | setUsage}
* @defaultValue {@link THREE.StaticDrawUsage | THREE.StaticDrawUsage}.
*/
usage: Usage;
/**
* Configures the bound GPU type for use in shaders. Either {@link FloatType} or {@link IntType}, default is {@link FloatType}.
*
* Note: this only has an effect for integer arrays and is not configurable for float arrays. For lower precision
* float types, see https://threejs.org/docs/#api/en/core/bufferAttributeTypes/BufferAttributeTypes.
*/
gpuType: AttributeGPUType;
/**
* This can be used to only update some components of stored vectors (for example, just the component related to
* color). Use the {@link .addUpdateRange} function to add ranges to this array.
*/
updateRanges: Array<{
/**
* Position at which to start update.
*/
start: number;
/**
* The number of components to update.
*/
count: number;
}>;
/**
* A version number, incremented every time the {@link BufferAttribute.needsUpdate | needsUpdate} property is set to true.
* @remarks Expects a `Integer`
* @defaultValue `0`
*/
version: number;
/**
* Indicates how the underlying data in the buffer maps to the values in the GLSL shader code.
* @see `constructor` above for details.
* @defaultValue `false`
*/
normalized: boolean;
/**
* Represents the number of items this buffer attribute stores. It is internally computed by dividing the
* {@link BufferAttribute.array | array}'s length by the {@link BufferAttribute.itemSize | itemSize}. Read-only
* property.
*/
readonly count: number;
/**
* Flag to indicate that this attribute has changed and should be re-sent to the GPU.
* Set this to true when you modify the value of the array.
* @remarks Setting this to true also increments the {@link BufferAttribute.version | version}.
* @remarks _set-only property_.
*/
set needsUpdate(value: boolean);
/**
* Read-only flag to check if a given object is of type {@link BufferAttribute}.
* @remarks This is a _constant_ value
* @defaultValue `true`
*/
readonly isBufferAttribute: true;
/**
* A callback function that is executed after the Renderer has transferred the attribute array data to the GPU.
*/
onUploadCallback: () => void;
/**
* Sets the value of the {@link onUploadCallback} property.
* @see Example: {@link https://threejs.org/examples/#webgl_buffergeometry | WebGL / BufferGeometry} this is used to free memory after the buffer has been transferred to the GPU.
* @see {@link onUploadCallback}
* @param callback function that is executed after the Renderer has transferred the attribute array data to the GPU.
*/
onUpload(callback: () => void): this;
/**
* Set {@link BufferAttribute.usage | usage}
* @remarks
* After the initial use of a buffer, its usage cannot be changed. Instead, instantiate a new one and set the desired usage before the next render.
* @see {@link https://threejs.org/docs/index.html#api/en/constants/BufferAttributeUsage | Buffer Attribute Usage Constants} for all possible values.
* @see {@link BufferAttribute.usage | usage}
* @param value Corresponds to the {@link BufferAttribute.usage | usage} parameter of
* {@link https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData | WebGLRenderingContext.bufferData}.
*/
setUsage(usage: Usage): this;
/**
* Adds a range of data in the data array to be updated on the GPU. Adds an object describing the range to the
* {@link .updateRanges} array.
*/
addUpdateRange(start: number, count: number): void;
/**
* Clears the {@link .updateRanges} array.
*/
clearUpdateRanges(): void;
/**
* @returns a copy of this {@link BufferAttribute}.
*/
clone(): BufferAttribute;
/**
* Copies another {@link BufferAttribute} to this {@link BufferAttribute}.
* @param bufferAttribute
*/
copy(source: BufferAttribute): this;
/**
* Copy a vector from bufferAttribute[index2] to {@link BufferAttribute.array | array}[index1].
* @param index1
* @param bufferAttribute
* @param index2
*/
copyAt(index1: number, attribute: BufferAttribute, index2: number): this;
/**
* Copy the array given here (which can be a normal array or `TypedArray`) into {@link BufferAttribute.array | array}.
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set | TypedArray.set} for notes on requirements if copying a `TypedArray`.
*/
copyArray(array: ArrayLike): this;
/**
* Applies matrix {@link Matrix3 | m} to every Vector3 element of this {@link BufferAttribute}.
* @param m
*/
applyMatrix3(m: Matrix3): this;
/**
* Applies matrix {@link Matrix4 | m} to every Vector3 element of this {@link BufferAttribute}.
* @param m
*/
applyMatrix4(m: Matrix4): this;
/**
* Applies normal matrix {@link Matrix3 | m} to every Vector3 element of this {@link BufferAttribute}.
* @param m
*/
applyNormalMatrix(m: Matrix3): this;
/**
* Applies matrix {@link Matrix4 | m} to every Vector3 element of this {@link BufferAttribute}, interpreting the elements as a direction vectors.
* @param m
*/
transformDirection(m: Matrix4): this;
/**
* Calls {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set | TypedArray.set}( {@link value}, {@link offset} )
* on the {@link BufferAttribute.array | array}.
* @param value {@link Array | Array} or `TypedArray` from which to copy values.
* @param offset index of the {@link BufferAttribute.array | array} at which to start copying. Expects a `Integer`. Default `0`.
* @throws `RangeError` When {@link offset} is negative or is too large.
*/
set(value: ArrayLike | ArrayBufferView, offset?: number): this;
/**
* Returns the given component of the vector at the given index.
*/
getComponent(index: number, component: number): number;
/**
* Sets the given component of the vector at the given index.
*/
setComponent(index: number, component: number, value: number): void;
/**
* Returns the x component of the vector at the given index.
* @param index Expects a `Integer`
*/
getX(index: number): number;
/**
* Sets the x component of the vector at the given index.
* @param index Expects a `Integer`
* @param x
*/
setX(index: number, x: number): this;
/**
* Returns the y component of the vector at the given index.
* @param index Expects a `Integer`
*/
getY(index: number): number;
/**
* Sets the y component of the vector at the given index.
* @param index Expects a `Integer`
* @param y
*/
setY(index: number, y: number): this;
/**
* Returns the z component of the vector at the given index.
* @param index Expects a `Integer`
*/
getZ(index: number): number;
/**
* Sets the z component of the vector at the given index.
* @param index Expects a `Integer`
* @param z
*/
setZ(index: number, z: number): this;
/**
* Returns the w component of the vector at the given index.
* @param index Expects a `Integer`
*/
getW(index: number): number;
/**
* Sets the w component of the vector at the given index.
* @param index Expects a `Integer`
* @param w
*/
setW(index: number, z: number): this;
/**
* Sets the x and y components of the vector at the given index.
* @param index Expects a `Integer`
* @param x
* @param y
*/
setXY(index: number, x: number, y: number): this;
/**
* Sets the x, y and z components of the vector at the given index.
* @param index Expects a `Integer`
* @param x
* @param y
* @param z
*/
setXYZ(index: number, x: number, y: number, z: number): this;
/**
* Sets the x, y, z and w components of the vector at the given index.
* @param index Expects a `Integer`
* @param x
* @param y
* @param z
* @param w
*/
setXYZW(index: number, x: number, y: number, z: number, w: number): this;
/**
* Convert this object to three.js to the `data.attributes` part of {@link https://github.com/mrdoob/three.js/wiki/JSON-Geometry-format-4 | JSON Geometry format v4},
*/
toJSON(): BufferAttributeJSON;
/**
* Disposes of the buffer attribute. Available only in {@link WebGPURenderer}.
*/
dispose(): void;
}
declare interface BufferAttributeEventMap {
dispose: {};
}
declare interface BufferAttributeJSON {
itemSize: number;
type: string;
array: number[];
normalized: boolean;
name?: string;
usage?: Usage;
}
/**
* A representation of mesh, line, or point geometry
* Includes vertex positions, face indices, normals, colors, UVs, and custom attributes within buffers, reducing the cost of passing all this data to the GPU.
* @remarks
* To read and edit data in BufferGeometry attributes, see {@link THREE.BufferAttribute | BufferAttribute} documentation.
* @example
* ```typescript
* const geometry = new THREE.BufferGeometry();
*
* // create a simple square shape. We duplicate the top left and bottom right
* // vertices because each vertex needs to appear once per triangle.
* const vertices = new Float32Array( [
* -1.0, -1.0, 1.0, // v0
* 1.0, -1.0, 1.0, // v1
* 1.0, 1.0, 1.0, // v2
*
* 1.0, 1.0, 1.0, // v3
* -1.0, 1.0, 1.0, // v4
* -1.0, -1.0, 1.0 // v5
* ] );
*
* // itemSize = 3 because there are 3 values (components) per vertex
* geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
* const material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
* const mesh = new THREE.Mesh( geometry, material );
* ```
* @example
* ```typescript
* const geometry = new THREE.BufferGeometry();
*
* const vertices = new Float32Array( [
* -1.0, -1.0, 1.0, // v0
* 1.0, -1.0, 1.0, // v1
* 1.0, 1.0, 1.0, // v2
* -1.0, 1.0, 1.0, // v3
* ] );
* geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
*
* const indices = [
* 0, 1, 2,
* 2, 3, 0,
* ];
*
* geometry.setIndex( indices );
* geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
*
* const material = new THREE.MeshBasicMaterial( { color: 0xff0000 } );
* const mesh = new THREE.Mesh( geometry, material );
* ```
* @see Example: {@link https://threejs.org/examples/#webgl_buffergeometry | Mesh with non-indexed faces}
* @see Example: {@link https://threejs.org/examples/#webgl_buffergeometry_indexed | Mesh with indexed faces}
* @see Example: {@link https://threejs.org/examples/#webgl_buffergeometry_lines | Lines}
* @see Example: {@link https://threejs.org/examples/#webgl_buffergeometry_lines_indexed | Indexed Lines}
* @see Example: {@link https://threejs.org/examples/#webgl_buffergeometry_custom_attributes_particles | Particles}
* @see Example: {@link https://threejs.org/examples/#webgl_buffergeometry_rawshader | Raw Shaders}
* @see {@link https://threejs.org/docs/index.html#api/en/core/BufferGeometry | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/core/BufferGeometry.js | Source}
*/
declare class BufferGeometry<
Attributes extends NormalOrGLBufferAttributes = NormalBufferAttributes,
TEventMap extends BufferGeometryEventMap = BufferGeometryEventMap,
> extends EventDispatcher {
/**
* This creates a new {@link THREE.BufferGeometry | BufferGeometry} object.
*/
constructor();
/**
* Unique number for this {@link THREE.BufferGeometry | BufferGeometry} instance.
* @remarks Expects a `Integer`
*/
id: number;
/**
* {@link http://en.wikipedia.org/wiki/Universally_unique_identifier | UUID} of this object instance.
* @remarks This gets automatically assigned and shouldn't be edited.
*/
uuid: string;
/**
* Optional name for this {@link THREE.BufferGeometry | BufferGeometry} instance.
* @defaultValue `''`
*/
name: string;
/**
* A Read-only _string_ to check if `this` object type.
* @remarks Sub-classes will update this value.
* @defaultValue `BufferGeometry`
*/
readonly type: string | "BufferGeometry";
/**
* Allows for vertices to be re-used across multiple triangles; this is called using "indexed triangles".
* Each triangle is associated with the indices of three vertices. This attribute therefore stores the index of each vertex for each triangular face.
* If this attribute is not set, the {@link THREE.WebGLRenderer | renderer} assumes that each three contiguous positions represent a single triangle.
* @defaultValue `null`
*/
index: BufferAttribute | null;
indirect: IndirectStorageBufferAttribute | null;
indirectOffset: number | number[];
/**
* This hashmap has as id the name of the attribute to be set and as value the {@link THREE.BufferAttribute | buffer} to set it to. Rather than accessing this property directly,
* use {@link setAttribute | .setAttribute} and {@link getAttribute | .getAttribute} to access attributes of this geometry.
* @defaultValue `{}`
*/
attributes: Attributes;
/**
* Hashmap of {@link THREE.BufferAttribute | BufferAttributes} holding details of the geometry's morph targets.
* @remarks
* Once the geometry has been rendered, the morph attribute data cannot be changed.
* You will have to call {@link dispose | .dispose}(), and create a new instance of {@link THREE.BufferGeometry | BufferGeometry}.
* @defaultValue `{}`
*/
morphAttributes: {
position?: Array | undefined;
normal?: Array | undefined;
color?: Array | undefined;
};
/**
* Used to control the morph target behavior; when set to true, the morph target data is treated as relative offsets, rather than as absolute positions/normals.
* @defaultValue `false`
*/
morphTargetsRelative: boolean;
/**
* Split the geometry into groups, each of which will be rendered in a separate WebGL draw call. This allows an array of materials to be used with the geometry.
* @remarks Every vertex and index must belong to exactly one group — groups must not share vertices or indices, and must not leave vertices or indices unused.
* @remarks Use {@link addGroup | .addGroup} to add groups, rather than modifying this array directly.
* @defaultValue `[]`
*/
groups: GeometryGroup[];
/**
* Bounding box for the {@link THREE.BufferGeometry | BufferGeometry}, which can be calculated with {@link computeBoundingBox | .computeBoundingBox()}.
* @remarks Bounding boxes aren't computed by default. They need to be explicitly computed, otherwise they are `null`.
* @defaultValue `null`
*/
boundingBox: Box3 | null;
/**
* Bounding sphere for the {@link THREE.BufferGeometry | BufferGeometry}, which can be calculated with {@link computeBoundingSphere | .computeBoundingSphere()}.
* @remarks bounding spheres aren't computed by default. They need to be explicitly computed, otherwise they are `null`.
* @defaultValue `null`
*/
boundingSphere: Sphere | null;
/**
* Determines the part of the geometry to render. This should not be set directly, instead use {@link setDrawRange | .setDrawRange(...)}.
* @remarks For non-indexed {@link THREE.BufferGeometry | BufferGeometry}, count is the number of vertices to render.
* @remarks For indexed {@link THREE.BufferGeometry | BufferGeometry}, count is the number of indices to render.
* @defaultValue `{ start: 0, count: Infinity }`
*/
drawRange: { start: number; count: number };
/**
* An object that can be used to store custom data about the BufferGeometry. It should not hold references to functions as these will not be cloned.
* @defaultValue `{}`
*/
userData: Record;
/**
* Read-only flag to check if a given object is of type {@link BufferGeometry}.
* @remarks This is a _constant_ value
* @defaultValue `true`
*/
readonly isBufferGeometry: true;
/**
* Return the {@link index | .index} buffer.
*/
getIndex(): BufferAttribute | null;
/**
* Set the {@link THREE.BufferGeometry.index | .index} buffer.
* @param index
*/
setIndex(index: BufferAttribute | number[] | null): this;
setIndirect(indirect: IndirectStorageBufferAttribute | null, indirectOffset?: number | number[]): this;
getIndirect(): IndirectStorageBufferAttribute | null;
/**
* Sets an {@link attributes | attribute} to this geometry with the specified name.
* @remarks
* Use this rather than the attributes property, because an internal hashmap of {@link attributes | .attributes} is maintained to speed up iterating over attributes.
* @param name
* @param attribute
*/
setAttribute(name: K, attribute: Attributes[K]): this;
/**
* Returns the {@link attributes | attribute} with the specified name.
* @param name
*/
getAttribute(name: K): Attributes[K];
/**
* Deletes the {@link attributes | attribute} with the specified name.
* @param name
*/
deleteAttribute(name: keyof Attributes): this;
/**
* Returns true if the {@link attributes | attribute} with the specified name exists.
* @param name
*/
hasAttribute(name: keyof Attributes): boolean;
/**
* Adds a group to this geometry
* @see the {@link BufferGeometry.groups | groups} property for details.
* @param start
* @param count
* @param materialIndex
*/
addGroup(start: number, count: number, materialIndex?: number): void;
/**
* Clears all groups.
*/
clearGroups(): void;
/**
* Set the {@link drawRange | .drawRange} property
* @remarks For non-indexed BufferGeometry, count is the number of vertices to render
* @remarks For indexed BufferGeometry, count is the number of indices to render.
* @param start
* @param count is the number of vertices or indices to render. Expects a `Integer`
*/
setDrawRange(start: number, count: number): void;
/**
* Applies the matrix transform to the geometry.
* @param matrix
*/
applyMatrix4(matrix: Matrix4): this;
/**
* Applies the rotation represented by the quaternion to the geometry.
* @param quaternion
*/
applyQuaternion(quaternion: Quaternion): this;
/**
* Rotate the geometry about the X axis. This is typically done as a one time operation, and not during a loop.
* @remarks Use {@link THREE.Object3D.rotation | Object3D.rotation} for typical real-time mesh rotation.
* @param angle radians. Expects a `Float`
*/
rotateX(angle: number): this;
/**
* Rotate the geometry about the Y axis.
* @remarks This is typically done as a one time operation, and not during a loop.
* @remarks Use {@link THREE.Object3D.rotation | Object3D.rotation} for typical real-time mesh rotation.
* @param angle radians. Expects a `Float`
*/
rotateY(angle: number): this;
/**
* Rotate the geometry about the Z axis.
* @remarks This is typically done as a one time operation, and not during a loop.
* @remarks Use {@link THREE.Object3D.rotation | Object3D.rotation} for typical real-time mesh rotation.
* @param angle radians. Expects a `Float`
*/
rotateZ(angle: number): this;
/**
* Translate the geometry.
* @remarks This is typically done as a one time operation, and not during a loop.
* @remarks Use {@link THREE.Object3D.position | Object3D.position} for typical real-time mesh rotation.
* @param x Expects a `Float`
* @param y Expects a `Float`
* @param z Expects a `Float`
*/
translate(x: number, y: number, z: number): this;
/**
* Scale the geometry data.
* @remarks This is typically done as a one time operation, and not during a loop.
* @remarks Use {@link THREE.Object3D.scale | Object3D.scale} for typical real-time mesh scaling.
* @param x Expects a `Float`
* @param y Expects a `Float`
* @param z Expects a `Float`
*/
scale(x: number, y: number, z: number): this;
/**
* Rotates the geometry to face a point in space.
* @remarks This is typically done as a one time operation, and not during a loop.
* @remarks Use {@link THREE.Object3D.lookAt | Object3D.lookAt} for typical real-time mesh usage.
* @param vector A world vector to look at.
*/
lookAt(vector: Vector3): this;
/**
* Center the geometry based on the bounding box.
*/
center(): this;
/**
* Defines a geometry by creating a `position` attribute based on the given array of points. The array can hold
* instances of {@link Vector2} or {@link Vector3}. When using two-dimensional data, the `z` coordinate for all
* vertices is set to `0`.
*
* If the method is used with an existing `position` attribute, the vertex data are overwritten with the data from
* the array. The length of the array must match the vertex count.
*/
setFromPoints(points: Vector3[] | Vector2[]): this;
/**
* Computes the bounding box of the geometry, and updates the {@link .boundingBox} attribute. The bounding box is
* not computed by the engine; it must be computed by your app. You may need to recompute the bounding box if the
* geometry vertices are modified.
*/
computeBoundingBox(): void;
/**
* Computes the bounding sphere of the geometry, and updates the {@link .boundingSphere} attribute. The engine
* automatically computes the bounding sphere when it is needed, e.g., for ray casting or view frustum culling. You
* may need to recompute the bounding sphere if the geometry vertices are modified.
*/
computeBoundingSphere(): void;
/**
* Calculates and adds a tangent attribute to this geometry.
* The computation is only supported for indexed geometries and if position, normal, and uv attributes are defined
* @remarks
* When using a tangent space normal map, prefer the MikkTSpace algorithm provided by
* {@link BufferGeometryUtils.computeMikkTSpaceTangents} instead.
*/
computeTangents(): void;
/**
* Computes vertex normals for the given vertex data. For indexed geometries, the method sets each vertex normal to
* be the average of the face normals of the faces that share that vertex. For non-indexed geometries, vertices are
* not shared, and the method sets each vertex normal to be the same as the face normal.
*/
computeVertexNormals(): void;
/**
* Every normal vector in a geometry will have a magnitude of 1
* @remarks This will correct lighting on the geometry surfaces.
*/
normalizeNormals(): void;
/**
* Return a non-index version of an indexed BufferGeometry.
*/
toNonIndexed(): BufferGeometry;
/**
* Convert the buffer geometry to three.js {@link https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 | JSON Object/Scene format}.
*/
toJSON(): BufferGeometryJSON;
/**
* Creates a clone of this BufferGeometry
*/
clone(): this;
/**
* Copies another BufferGeometry to this BufferGeometry.
* @param source
*/
copy(source: BufferGeometry): this;
/**
* Frees the GPU-related resources allocated by this instance.
* @remarks Call this method whenever this instance is no longer used in your app.
*/
dispose(): void;
}
declare interface BufferGeometryEventMap {
dispose: {};
}
declare interface BufferGeometryJSON {
metadata?: { version: number; type: string; generator: string };
uuid: string;
type: string;
name?: string;
userData?: Record;
data?: {
attributes: Record;
index?: { type: string; array: number[] };
morphAttributes?: Record;
morphTargetsRelative?: boolean;
groups?: GeometryGroup[];
boundingSphere?: { center: Vector3Tuple; radius: number };
};
}
declare const ByteType: 1010;
/**
* Abstract base class for cameras. This class should always be inherited
* when you build a new camera.
*/
declare class Camera extends Object3D {
/**
* This flag can be used for type testing.
*
* @default true
*/
readonly isCamera: boolean;
/**
* The inverse of the camera's world matrix.
*/
matrixWorldInverse: Matrix4;
/**
* The camera's projection matrix.
*/
projectionMatrix: Matrix4;
/**
* The inverse of the camera's projection matrix.
*/
projectionMatrixInverse: Matrix4;
/**
* The coordinate system in which the camera is used.
*/
coordinateSystem: CoordinateSystem;
viewport?: Vector4;
/**
* The flag that indicates whether the camera uses a reversed depth buffer.
*
* @default false
*/
get reversedDepth(): boolean;
clone(): this;
copy(source: Camera, recursive?: boolean): this;
}
declare const CineonToneMapping: 3;
/**
* With {@link ClampToEdgeWrapping} the last pixel of the texture stretches to the edge of the mesh.
* @remarks This is the _default_ value and behaver for Wrapping Mapping.
*/
declare const ClampToEdgeWrapping: 1001;
/**
* Class representing a color.
*
* A Color instance is represented by RGB components in the linear working color space , which defaults to
* `LinearSRGBColorSpace`. Inputs conventionally using `SRGBColorSpace` (such as hexadecimals and CSS strings) are
* converted to the working color space automatically.
*
* ```
* // converted automatically from SRGBColorSpace to LinearSRGBColorSpace
* const color = new THREE.Color().setHex( 0x112233 );
* ```
*
* Source color spaces may be specified explicitly, to ensure correct conversions.
*
* ```
* // assumed already LinearSRGBColorSpace; no conversion
* const color = new THREE.Color().setRGB( 0.5, 0.5, 0.5 );
*
* // converted explicitly from SRGBColorSpace to LinearSRGBColorSpace
* const color = new THREE.Color().setRGB( 0.5, 0.5, 0.5, SRGBColorSpace );
* ```
*
* If THREE.ColorManagement is disabled, no conversions occur. For details, see Color management .
*
* Iterating through a Color instance will yield its components (r, g, b) in the corresponding order.
*/
declare class Color {
constructor(color?: ColorRepresentation);
constructor(r: number, g: number, b: number);
readonly isColor: true;
/**
* Red channel value between `0.0` and `1.0`. Default is `1`.
* @default 1
*/
r: number;
/**
* Green channel value between `0.0` and `1.0`. Default is `1`.
* @default 1
*/
g: number;
/**
* Blue channel value between `0.0` and `1.0`. Default is `1`.
* @default 1
*/
b: number;
// eslint-disable-next-line @definitelytyped/no-single-element-tuple-type
set(...args: [color: ColorRepresentation] | [r: number, g: number, b: number]): this;
/**
* Sets this color's {@link r}, {@link g} and {@link b} components from the x, y, and z components of the specified
* {@link Vector3 | vector}.
*/
setFromVector3(vector: Vector3): this;
setScalar(scalar: number): this;
setHex(hex: number, colorSpace?: string): this;
/**
* Sets this color from RGB values.
* @param r Red channel value between 0 and 1.
* @param g Green channel value between 0 and 1.
* @param b Blue channel value between 0 and 1.
*/
setRGB(r: number, g: number, b: number, colorSpace?: string): this;
/**
* Sets this color from HSL values.
* Based on MochiKit implementation by Bob Ippolito.
*
* @param h Hue channel value between 0 and 1.
* @param s Saturation value channel between 0 and 1.
* @param l Value channel value between 0 and 1.
*/
setHSL(h: number, s: number, l: number, colorSpace?: string): this;
/**
* Sets this color from a CSS context style string.
* @param contextStyle Color in CSS context style format.
*/
setStyle(style: string, colorSpace?: string): this;
/**
* Sets this color from a color name.
* Faster than {@link Color#setStyle .setStyle()} method if you don't need the other CSS-style formats.
* @param style Color name in X11 format.
*/
setColorName(style: string, colorSpace?: string): this;
/**
* Clones this color.
*/
clone(): this;
/**
* Copies given color.
* @param color Color to copy.
*/
copy(color: Color): this;
/**
* Copies given color making conversion from `SRGBColorSpace` to `LinearSRGBColorSpace`.
* @param color Color to copy.
*/
copySRGBToLinear(color: Color): this;
/**
* Copies given color making conversion from `LinearSRGBColorSpace` to `SRGBColorSpace`.
* @param color Color to copy.
*/
copyLinearToSRGB(color: Color): this;
/**
* Converts this color from `SRGBColorSpace` to `LinearSRGBColorSpace`.
*/
convertSRGBToLinear(): this;
/**
* Converts this color from `LinearSRGBColorSpace` to `SRGBColorSpace`.
*/
convertLinearToSRGB(): this;
/**
* Returns the hexadecimal value of this color.
*/
getHex(colorSpace?: string): number;
/**
* Returns the string formatted hexadecimal value of this color.
*/
getHexString(colorSpace?: string): string;
getHSL(target: HSL, colorSpace?: string): HSL;
getRGB(target: RGB, colorSpace?: string): RGB;
/**
* Returns the value of this color in CSS context style.
* Example: rgb(r, g, b)
*/
getStyle(colorSpace?: string): string;
offsetHSL(h: number, s: number, l: number): this;
add(color: Color): this;
addColors(color1: Color, color2: Color): this;
addScalar(s: number): this;
/**
* Applies the transform {@link Matrix3 | m} to this color's RGB components.
*/
applyMatrix3(m: Matrix3): this;
sub(color: Color): this;
multiply(color: Color): this;
multiplyScalar(s: number): this;
lerp(color: Color, alpha: number): this;
lerpColors(color1: Color, color2: Color, alpha: number): this;
lerpHSL(color: Color, alpha: number): this;
equals(color: Color): boolean;
/**
* Sets this color's red, green and blue value from the provided array or array-like.
* @param array the source array or array-like.
* @param offset (optional) offset into the array-like. Default is 0.
*/
fromArray(array: number[] | ArrayLike, offset?: number): this;
/**
* Returns an array [red, green, blue], or copies red, green and blue into the provided array.
* @param array (optional) array to store the color to. If this is not provided, a new array will be created.
* @param offset (optional) optional offset into the array.
* @return The created or provided array.
*/
toArray(array?: number[], offset?: number): number[];
/**
* Copies red, green and blue into the provided array-like.
* @param array array-like to store the color to.
* @param offset (optional) optional offset into the array-like.
* @return The provided array-like.
*/
toArray(xyz: ArrayLike, offset?: number): ArrayLike;
/**
* This method defines the serialization result of Color.
* @return The color as a hexadecimal value.
*/
toJSON(): number;
fromBufferAttribute(attribute: BufferAttribute | InterleavedBufferAttribute, index: number): this;
[Symbol.iterator](): Generator;
/**
* List of X11 color names.
*/
static NAMES: typeof _colorKeywords;
}
declare const _colorKeywords: {
aliceblue: 0xf0f8ff;
antiquewhite: 0xfaebd7;
aqua: 0x00ffff;
aquamarine: 0x7fffd4;
azure: 0xf0ffff;
beige: 0xf5f5dc;
bisque: 0xffe4c4;
black: 0x000000;
blanchedalmond: 0xffebcd;
blue: 0x0000ff;
blueviolet: 0x8a2be2;
brown: 0xa52a2a;
burlywood: 0xdeb887;
cadetblue: 0x5f9ea0;
chartreuse: 0x7fff00;
chocolate: 0xd2691e;
coral: 0xff7f50;
cornflowerblue: 0x6495ed;
cornsilk: 0xfff8dc;
crimson: 0xdc143c;
cyan: 0x00ffff;
darkblue: 0x00008b;
darkcyan: 0x008b8b;
darkgoldenrod: 0xb8860b;
darkgray: 0xa9a9a9;
darkgreen: 0x006400;
darkgrey: 0xa9a9a9;
darkkhaki: 0xbdb76b;
darkmagenta: 0x8b008b;
darkolivegreen: 0x556b2f;
darkorange: 0xff8c00;
darkorchid: 0x9932cc;
darkred: 0x8b0000;
darksalmon: 0xe9967a;
darkseagreen: 0x8fbc8f;
darkslateblue: 0x483d8b;
darkslategray: 0x2f4f4f;
darkslategrey: 0x2f4f4f;
darkturquoise: 0x00ced1;
darkviolet: 0x9400d3;
deeppink: 0xff1493;
deepskyblue: 0x00bfff;
dimgray: 0x696969;
dimgrey: 0x696969;
dodgerblue: 0x1e90ff;
firebrick: 0xb22222;
floralwhite: 0xfffaf0;
forestgreen: 0x228b22;
fuchsia: 0xff00ff;
gainsboro: 0xdcdcdc;
ghostwhite: 0xf8f8ff;
gold: 0xffd700;
goldenrod: 0xdaa520;
gray: 0x808080;
green: 0x008000;
greenyellow: 0xadff2f;
grey: 0x808080;
honeydew: 0xf0fff0;
hotpink: 0xff69b4;
indianred: 0xcd5c5c;
indigo: 0x4b0082;
ivory: 0xfffff0;
khaki: 0xf0e68c;
lavender: 0xe6e6fa;
lavenderblush: 0xfff0f5;
lawngreen: 0x7cfc00;
lemonchiffon: 0xfffacd;
lightblue: 0xadd8e6;
lightcoral: 0xf08080;
lightcyan: 0xe0ffff;
lightgoldenrodyellow: 0xfafad2;
lightgray: 0xd3d3d3;
lightgreen: 0x90ee90;
lightgrey: 0xd3d3d3;
lightpink: 0xffb6c1;
lightsalmon: 0xffa07a;
lightseagreen: 0x20b2aa;
lightskyblue: 0x87cefa;
lightslategray: 0x778899;
lightslategrey: 0x778899;
lightsteelblue: 0xb0c4de;
lightyellow: 0xffffe0;
lime: 0x00ff00;
limegreen: 0x32cd32;
linen: 0xfaf0e6;
magenta: 0xff00ff;
maroon: 0x800000;
mediumaquamarine: 0x66cdaa;
mediumblue: 0x0000cd;
mediumorchid: 0xba55d3;
mediumpurple: 0x9370db;
mediumseagreen: 0x3cb371;
mediumslateblue: 0x7b68ee;
mediumspringgreen: 0x00fa9a;
mediumturquoise: 0x48d1cc;
mediumvioletred: 0xc71585;
midnightblue: 0x191970;
mintcream: 0xf5fffa;
mistyrose: 0xffe4e1;
moccasin: 0xffe4b5;
navajowhite: 0xffdead;
navy: 0x000080;
oldlace: 0xfdf5e6;
olive: 0x808000;
olivedrab: 0x6b8e23;
orange: 0xffa500;
orangered: 0xff4500;
orchid: 0xda70d6;
palegoldenrod: 0xeee8aa;
palegreen: 0x98fb98;
paleturquoise: 0xafeeee;
palevioletred: 0xdb7093;
papayawhip: 0xffefd5;
peachpuff: 0xffdab9;
peru: 0xcd853f;
pink: 0xffc0cb;
plum: 0xdda0dd;
powderblue: 0xb0e0e6;
purple: 0x800080;
rebeccapurple: 0x663399;
red: 0xff0000;
rosybrown: 0xbc8f8f;
royalblue: 0x4169e1;
saddlebrown: 0x8b4513;
salmon: 0xfa8072;
sandybrown: 0xf4a460;
seagreen: 0x2e8b57;
seashell: 0xfff5ee;
sienna: 0xa0522d;
silver: 0xc0c0c0;
skyblue: 0x87ceeb;
slateblue: 0x6a5acd;
slategray: 0x708090;
slategrey: 0x708090;
snow: 0xfffafa;
springgreen: 0x00ff7f;
steelblue: 0x4682b4;
tan: 0xd2b48c;
teal: 0x008080;
thistle: 0xd8bfd8;
tomato: 0xff6347;
turquoise: 0x40e0d0;
violet: 0xee82ee;
wheat: 0xf5deb3;
white: 0xffffff;
whitesmoke: 0xf5f5f5;
yellow: 0xffff00;
yellowgreen: 0x9acd32;
};
declare type ColorRepresentation = Color | string | number;
declare type ColorSpace =
| typeof NoColorSpace
| typeof SRGBColorSpace
| typeof LinearSRGBColorSpace;
declare type Combine = typeof MultiplyOperation | typeof MixOperation | typeof AddOperation;
declare class Composite {
}
/**
* For use with a {@link THREE.CompressedTexture}'s {@link THREE.CompressedTexture.format | .format} property.
* @remarks Compressed Require support for correct WebGL extension.
*/
declare type CompressedPixelFormat =
| typeof RGB_S3TC_DXT1_Format
| typeof RGBA_S3TC_DXT1_Format
| typeof RGBA_S3TC_DXT3_Format
| typeof RGBA_S3TC_DXT5_Format
| typeof RGB_PVRTC_4BPPV1_Format
| typeof RGB_PVRTC_2BPPV1_Format
| typeof RGBA_PVRTC_4BPPV1_Format
| typeof RGBA_PVRTC_2BPPV1_Format
| typeof RGB_ETC1_Format
| typeof RGB_ETC2_Format
| typeof RGBA_ETC2_EAC_Format
| typeof R11_EAC_Format
| typeof SIGNED_R11_EAC_Format
| typeof RG11_EAC_Format
| typeof SIGNED_RG11_EAC_Format
| typeof RGBA_ASTC_4x4_Format
| typeof RGBA_ASTC_5x4_Format
| typeof RGBA_ASTC_5x5_Format
| typeof RGBA_ASTC_6x5_Format
| typeof RGBA_ASTC_6x6_Format
| typeof RGBA_ASTC_8x5_Format
| typeof RGBA_ASTC_8x6_Format
| typeof RGBA_ASTC_8x8_Format
| typeof RGBA_ASTC_10x5_Format
| typeof RGBA_ASTC_10x6_Format
| typeof RGBA_ASTC_10x8_Format
| typeof RGBA_ASTC_10x10_Format
| typeof RGBA_ASTC_12x10_Format
| typeof RGBA_ASTC_12x12_Format
| typeof RGBA_BPTC_Format
| typeof RGB_BPTC_SIGNED_Format
| typeof RGB_BPTC_UNSIGNED_Format
| typeof RED_RGTC1_Format
| typeof SIGNED_RED_RGTC1_Format
| typeof RED_GREEN_RGTC2_Format
| typeof SIGNED_RED_GREEN_RGTC2_Format;
declare interface CompressedTextureMipmap {
data: TypedArray;
width: number;
height: number;
}
declare const ConstantAlphaFactor: 213;
declare const ConstantColorFactor: 211;
declare type CoordinateSystem =
| typeof WebGLCoordinateSystem
| typeof WebGPUCoordinateSystem;
/**
* Replace the AnimationMixer with a new one created against `vrm.scene` and
* register all clips with the given weights.
*
* @example
* // Create a mixer with two animations, weighted 70% and 30%.
* const mixer = createMixerWithClips(vrm, [anim1, anim2], [0.7, 0.3]);
* // Create a mixer with three animations, with equal weights (1/3 each).
* const mixer = createMixerWithClips(vrm, [anim1, anim2, anim3]);
* // Create a mixer with two animations, with equal weights (1/2 each) even though weights are invalid.
* const mixer = createMixerWithClips(vrm, [anim1, anim2], [10, 20]);
*
* Weight validation rules:
* - Empty/undefined weights → equal split (1 / N).
* - Length mismatch → equal split (1 / N).
* - Sum > 1.0 (with epsilon) → throws.
*
* Does not dispose the old mixer or its actions; caller is responsible for that if needed.
*
* @param vrm The VRM instance to animate.
* @param animations The VRMAnimation instances to create clips from.
* @param weights Optional weights for each animation; if not provided or invalid, defaults to equal split.
* @returns The new AnimationMixer instance.
* @throws If the weights are invalid (sum exceeds 1.0).
*/
export declare function createMixerWithClips(
vrm: VRM,
animations: VRMAnimation[],
weights?: number[] | null,
): AnimationMixer {
const n = animations.length;
const lengthOk = weights?.length === n;
const allFinite = weights?.every((v) => Number.isFinite(v)) ?? false;
const useEqual = !(lengthOk && allFinite);
const w = useEqual
? animations.map(() => 1 / n)
: (weights ?? []).slice(0, n);
const total = w.reduce((sum, v) => sum + v, 0);
if (total > 1 + Number.EPSILON) {
throw new Error(
`[VrmCanvas] The sum of animationWeights exceeds 1.0: ${total.toFixed(4)}`,
);
}
const mixer = new AnimationMixer(vrm.scene);
// Reduce the chance of T-pose by applying a neutral pose if there is no idle animation (i.e. only one animation with weight 1).
if (!mixer) {
applyNeutralPose(vrm);
}
animations.forEach((anim, i) => {
const clip = createVRMAnimationClip(anim, vrm);
const action = mixer.clipAction(clip);
action.weight = w[i] ?? 0;
action.play();
});
return mixer;
}
/**
* @remarks This is the _default_ value and behaver for Cube Texture Mapping.
*/
declare const CubeReflectionMapping: 301;
declare const CubeRefractionMapping: 302;
/**
* Creates a cube texture made up of six images.
* @remarks
* {@link CubeTexture} is almost equivalent in functionality and usage to {@link Texture}.
* The only differences are that the images are an array of _6_ images as opposed to a single image,
* and the mapping options are {@link THREE.CubeReflectionMapping} (default) or {@link THREE.CubeRefractionMapping}
* @example
* ```typescript
* const loader = new THREE.CubeTextureLoader();
* loader.setPath('textures/cube/pisa/');
* const textureCube = loader.load(['px.png', 'nx.png', 'py.png', 'ny.png', 'pz.png', 'nz.png']);
* const material = new THREE.MeshBasicMaterial({
* color: 0xffffff,
* envMap: textureCube
* });
* ```
* @see {@link https://threejs.org/docs/index.html#api/en/textures/CubeTexture | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/textures/CubeTexture.js | Source}
*/
declare class CubeTexture extends Texture {
/**
* This creates a new {@link THREE.CubeTexture | CubeTexture} object.
* @param images
* @param mapping See {@link CubeTexture.mapping | .mapping}. Default {@link THREE.CubeReflectionMapping}
* @param wrapS See {@link Texture.wrapS | .wrapS}. Default {@link THREE.ClampToEdgeWrapping}
* @param wrapT See {@link Texture.wrapT | .wrapT}. Default {@link THREE.ClampToEdgeWrapping}
* @param magFilter See {@link Texture.magFilter | .magFilter}. Default {@link THREE.LinearFilter}
* @param minFilter See {@link Texture.minFilter | .minFilter}. Default {@link THREE.LinearMipmapLinearFilter}
* @param format See {@link Texture.format | .format}. Default {@link THREE.RGBAFormat}
* @param type See {@link Texture.type | .type}. Default {@link THREE.UnsignedByteType}
* @param anisotropy See {@link Texture.anisotropy | .anisotropy}. Default {@link THREE.Texture.DEFAULT_ANISOTROPY}
* @param colorSpace See {@link Texture.colorSpace | .colorSpace}. Default {@link NoColorSpace}
*/
constructor(
images?: TImage[],
mapping?: CubeTextureMapping,
wrapS?: Wrapping,
wrapT?: Wrapping,
magFilter?: MagnificationTextureFilter,
minFilter?: MinificationTextureFilter,
format?: PixelFormat,
type?: TextureDataType,
anisotropy?: number,
colorSpace?: string,
);
/**
* Read-only flag to check if a given object is of type {@link CubeTexture}.
* @remarks This is a _constant_ value
* @defaultValue `true`
*/
readonly isCubeTexture: true;
/**
* An image object, typically created using the {@link THREE.CubeTextureLoader.load | CubeTextureLoader.load()} method.
* @see {@link Texture.image}
*/
get images(): TImage[];
set images(value: TImage[]);
/**
* @inheritDoc
* @defaultValue {@link THREE.CubeReflectionMapping}
*/
mapping: CubeTextureMapping;
/**
* @inheritDoc
* @defaultValue `false`
*/
flipY: boolean;
}
/**
* Texture Mapping Modes for cube Textures
* @remarks {@link CubeReflectionMapping} is the _default_ value and behaver for Cube Texture Mapping.
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
*/
declare type CubeTextureMapping =
| typeof CubeReflectionMapping
| typeof CubeRefractionMapping
| typeof CubeUVReflectionMapping;
declare const CubeUVReflectionMapping: 306;
/**
* Fast and simple cubic spline interpolant.
*
* It was derived from a Hermitian construction setting the first derivative
* at each sample position to the linear slope between neighboring positions
* over their parameter interval.
*
* @augments Interpolant
*/
declare class CubicInterpolant extends Interpolant {
intervalChanged_(i1: number, t0: number, t1: number): void;
interpolate_(i1: number, t0: number, t: number, t1: number): TypedArray;
}
declare interface CubicInterpolantSettings {
endingStart: InterpolationEndingModes;
endingEnd: InterpolationEndingModes;
}
declare type CullFace = typeof CullFaceNone | typeof CullFaceBack | typeof CullFaceFront | typeof CullFaceFrontBack;
declare const CullFaceBack: 1;
declare const CullFaceFront: 2;
declare const CullFaceFrontBack: 3;
declare const CullFaceNone: 0;
declare interface CurveJSON {
metadata: { version: number; type: string; generator: string };
arcLengthDivisions: number;
type: string;
}
declare interface CurvePathJSON extends CurveJSON {
autoClose: boolean;
curves: CurveJSON[];
}
declare const CustomBlending: 5;
declare const CustomToneMapping: 5;
declare class Cylindrical {
constructor(radius?: number, theta?: number, y?: number);
/**
* @default 1
*/
radius: number;
/**
* @default 0
*/
theta: number;
/**
* @default 0
*/
y: number;
clone(): this;
copy(other: Cylindrical): this;
set(radius: number, theta: number, y: number): this;
setFromVector3(vec3: Vector3): this;
setFromCartesianCoords(x: number, y: number, z: number): this;
}
/**
* Creates a texture directly from raw data, width and height.
* @example
* ```typescript
* // create a buffer with color data
* const width = 512;
* const height = 512;
* const size = width * height;
* const data = new Uint8Array(4 * size);
* const color = new THREE.Color(0xffffff);
* const r = Math.floor(color.r * 255);
* const g = Math.floor(color.g * 255);
* const b = Math.floor(color.b * 255);
* for (let i = 0; i & lt; size; i++) {
* const stride = i * 4;
* data[stride] = r;
* data[stride + 1] = g;
* data[stride + 2] = b;
* data[stride + 3] = 255;
* }
* // used the buffer to create a [name]
* const texture = new THREE.DataTexture(data, width, height);
* texture.needsUpdate = true;
* ```
* @see {@link https://threejs.org/docs/index.html#api/en/textures/DataTexture | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/textures/DataTexture.js | Source}
*/
declare class DataTexture extends Texture {
/**
* @param data {@link https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView | ArrayBufferView} of the texture. Default `null`.
* @param width Width of the texture. Default `1`.
* @param height Height of the texture. Default `1`.
* @param format See {@link Texture.format | .format}. Default {@link THREE.RGBAFormat}
* @param type See {@link Texture.type | .type}. Default {@link THREE.UnsignedByteType}
* @param mapping See {@link Texture.mapping | .mapping}. Default {@link THREE.Texture.DEFAULT_MAPPING}
* @param wrapS See {@link Texture.wrapS | .wrapS}. Default {@link THREE.ClampToEdgeWrapping}
* @param wrapT See {@link Texture.wrapT | .wrapT}. Default {@link THREE.ClampToEdgeWrapping}
* @param magFilter See {@link Texture.magFilter | .magFilter}. Default {@link THREE.NearestFilter}
* @param minFilter See {@link Texture.minFilter | .minFilter}. Default {@link THREE.NearestFilter}
* @param anisotropy See {@link Texture.anisotropy | .anisotropy}. Default {@link THREE.Texture.DEFAULT_ANISOTROPY}
* @param colorSpace See {@link Texture.colorSpace | .colorSpace}. Default {@link NoColorSpace}
*/
constructor(
data?: TypedArray | null,
width?: number,
height?: number,
format?: PixelFormat,
type?: TextureDataType,
mapping?: Mapping,
wrapS?: Wrapping,
wrapT?: Wrapping,
magFilter?: MagnificationTextureFilter,
minFilter?: MinificationTextureFilter,
anisotropy?: number,
colorSpace?: ColorSpace,
);
/**
* Read-only flag to check if a given object is of type {@link DataTexture}.
* @remarks This is a _constant_ value
* @defaultValue `true`
*/
readonly isDataTexture: true;
/**
* @override
* @defaultValue {@link THREE.NearestFilter}
*/
magFilter: MagnificationTextureFilter;
/**
* @override
* @defaultValue {@link THREE.NearestFilter}
*/
minFilter: MinificationTextureFilter;
/**
* @override
* @defaultValue `false`
*/
flipY: boolean;
/**
* @override
* @defaultValue `false`
*/
generateMipmaps: boolean;
/**
* @override
* @defaultValue `1`
*/
unpackAlignment: number;
}
declare interface DataTextureImageData {
data: TypedArray | null;
width: number;
height: number;
}
declare const DecrementStencilOp: 7283;
declare const DecrementWrapStencilOp: 34056;
/**
* {@link DepthFormat} reads each element as a single depth value, converts it to floating point, and clamps to the range `[0,1]`.
* @remarks This is the default for {@link THREE.DepthTexture}.
*/
declare const DepthFormat: 1026;
declare type DepthModes =
| typeof NeverDepth
| typeof AlwaysDepth
| typeof LessDepth
| typeof LessEqualDepth
| typeof EqualDepth
| typeof GreaterEqualDepth
| typeof GreaterDepth
| typeof NotEqualDepth;
declare type DepthPackingStrategies =
| typeof BasicDepthPacking
| typeof RGBADepthPacking
| typeof RGBDepthPacking
| typeof RGDepthPacking;
/**
* {@link DepthStencilFormat} reads each element is a pair of depth and stencil values.
* The depth component of the pair is interpreted as in {@link DepthFormat}.
* The stencil component is interpreted based on the depth + stencil internal format.
*/
declare const DepthStencilFormat: 1027;
/**
* This class can be used to automatically save the depth information of a rendering into a texture
* @see Example: {@link https://threejs.org/examples/#webgl_depth_texture | depth / texture}
* @see {@link https://threejs.org/docs/index.html#api/en/textures/DepthTexture | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/textures/DepthTexture.js | Source}
*/
declare class DepthTexture extends Texture {
/**
* Create a new instance of {@link DepthTexture}
* @param width Width of the texture.
* @param height Height of the texture.
* @param type See {@link Texture.type | .type}. Default {@link THREE.UnsignedByteType} or {@link THREE.UnsignedInt248Type}
* @param mapping See {@link Texture.mapping | .mapping}. Default {@link THREE.Texture.DEFAULT_MAPPING}
* @param wrapS See {@link Texture.wrapS | .wrapS}. Default {@link THREE.ClampToEdgeWrapping}
* @param wrapT See {@link Texture.wrapT | .wrapT}. Default {@link THREE.ClampToEdgeWrapping}
* @param magFilter See {@link Texture.magFilter | .magFilter}. Default {@link THREE.NearestFilter}
* @param minFilter See {@link Texture.minFilter | .minFilter}. Default {@link THREE.NearestFilter}
* @param anisotropy See {@link Texture.anisotropy | .anisotropy}. Default {@link THREE.Texture.DEFAULT_ANISOTROPY}
* @param format See {@link DepthTexture.format | .format}. Default {@link THREE.DepthFormat}
* @param {number} [depth=1] - The depth of the texture.
*/
constructor(
width?: number,
height?: number,
type?: TextureDataType,
mapping?: Mapping,
wrapS?: Wrapping,
wrapT?: Wrapping,
magFilter?: MagnificationTextureFilter,
minFilter?: MinificationTextureFilter,
anisotropy?: number,
format?: DepthTexturePixelFormat,
depth?: number,
);
/**
* Read-only flag to check if a given object is of type {@link DepthTexture}.
* @remarks This is a _constant_ value
* @defaultValue `true`
*/
readonly isDepthTexture: true;
/**
* @override
* @defaultValue `false`
*/
flipY: boolean;
/**
* @override
* @defaultValue {@link THREE.NearestFilter}
*/
magFilter: MagnificationTextureFilter;
/**
* @override
* @defaultValue {@link THREE.NearestFilter}
*/
minFilter: MinificationTextureFilter;
/**
* @override Depth textures do not use mipmaps.
* @defaultValue `false`
*/
generateMipmaps: boolean;
/**
* @override
* @see {@link Texture.format | Texture.format}
* @defaultValue {@link THREE.DepthFormat}.
*/
format: DepthTexturePixelFormat;
/**
* @override
* @defaultValue {@link THREE.UnsignedByteType} when {@link format | .format} === {@link THREE.DepthFormat}
* @defaultValue {@link THREE.UnsignedInt248Type} when {@link format | .format} === {@link THREE.DepthStencilFormat}
*/
type: TextureDataType;
/**
* This is used to define the comparison function used when comparing texels in the depth texture to the value in
* the depth buffer. Default is `null` which means comparison is disabled.
*
* See {@link THREE.TextureComparisonFunction} for functions.
*/
compareFunction: TextureComparisonFunction | null;
}
declare interface DepthTextureImageData {
width: number | undefined;
height: number | undefined;
depth: number;
}
/**
* All Texture Pixel Formats Modes for {@link THREE.DepthTexture}.
* @see {@link WebGLRenderingContext.texImage2D} for details.
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
*/
declare type DepthTexturePixelFormat = typeof DepthFormat | typeof DepthStencilFormat;
/**
* Interpolant that evaluates to the sample value at the position preceding
* the parameter.
*
* @augments Interpolant
*/
declare class DiscreteInterpolant extends Interpolant {
interpolate_(i1: number): TypedArray;
}
/**
* Stop and dispose the given mixer.
* Does not throw if the mixer is already stopped or has no root.
*
* @param mixer The AnimationMixer instance to dispose.
*/
export declare function disposeMixer(mixer: AnimationMixer): void {
mixer.stopAllAction();
const root = mixer.getRoot();
if (root) mixer.uncacheRoot(root as Object3D);
}
/**
* Dispose a VRM instance and free its GPU resources.
* Does not throw if the VRM is already disposed or has no scene.
*
* @param vrm The VRM instance to dispose.
*/
export declare function disposeVrm(vrm: VRM): void {
VRMUtils.deepDispose(vrm.scene);
}
declare const DoubleSide: 2;
declare const DstAlphaFactor: 206;
declare const DstColorFactor: 208;
declare const DynamicCopyUsage: 35050;
declare const DynamicDrawUsage: 35048;
declare const DynamicReadUsage: 35049;
declare interface Effect {
setSize(width: number, height: number): void;
render(
renderer: WebGLRenderer,
writeBuffer: WebGLRenderTarget,
readBuffer: WebGLRenderTarget,
deltaTime: number,
maskActive: boolean,
): void;
}
declare const EqualCompare: 514;
declare const EqualDepth: 4;
declare const EqualStencilFunc: 514;
declare const EquirectangularReflectionMapping: 303;
declare const EquirectangularRefractionMapping: 304;
declare class Euler {
constructor(x?: number, y?: number, z?: number, order?: EulerOrder);
/**
* @default 0
*/
x: number;
/**
* @default 0
*/
y: number;
/**
* @default 0
*/
z: number;
/**
* @default THREE.Euler.DEFAULT_ORDER
*/
order: EulerOrder;
readonly isEuler: true;
_onChangeCallback: () => void;
set(x: number, y: number, z: number, order?: EulerOrder): Euler;
clone(): this;
copy(euler: Euler): this;
setFromRotationMatrix(m: Matrix4, order?: EulerOrder, update?: boolean): Euler;
setFromQuaternion(q: Quaternion, order?: EulerOrder, update?: boolean): Euler;
setFromVector3(v: Vector3, order?: EulerOrder): Euler;
reorder(newOrder: EulerOrder): Euler;
equals(euler: Euler): boolean;
fromArray(array: EulerTuple): Euler;
toArray(array?: Partial, offset?: number): EulerTuple;
_onChange(callback: () => void): this;
static DEFAULT_ORDER: "XYZ";
[Symbol.iterator](): Generator;
}
declare type EulerOrder = "XYZ" | "YXZ" | "ZXY" | "ZYX" | "YZX" | "XZY";
declare type EulerTuple = [x: number, y: number, z: number, order?: EulerOrder];
/**
* The minimal expected contract of a fired Event that was dispatched by a {@link EventDispatcher<>}.
*/
declare interface Event_2 {
readonly type: TEventType;
readonly target: TTarget;
}
/**
* JavaScript events for custom objects
* @example
* ```typescript
* // Adding events to a custom object
* class Car extends EventDispatcher {
* start() {
* this.dispatchEvent( { type: 'start', message: 'vroom vroom!' } );
* }
* };
* // Using events with the custom object
* const car = new Car();
* car.addEventListener( 'start', ( event ) => {
* alert( event.message );
* } );
* car.start();
* ```
* @see {@link https://github.com/mrdoob/eventdispatcher.js | mrdoob EventDispatcher on GitHub}
* @see {@link https://threejs.org/docs/index.html#api/en/core/EventDispatcher | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/core/EventDispatcher.js | Source}
*/
declare class EventDispatcher {
/**
* Creates {@link THREE.EventDispatcher | EventDispatcher} object.
*/
constructor();
/**
* Adds a listener to an event type.
* @param type The type of event to listen to.
* @param listener The function that gets called when the event is fired.
*/
addEventListener>(
type: T,
listener: EventListener_2,
): void;
/**
* Checks if listener is added to an event type.
* @param type The type of event to listen to.
* @param listener The function that gets called when the event is fired.
*/
hasEventListener>(
type: T,
listener: EventListener_2,
): boolean;
/**
* Removes a listener from an event type.
* @param type The type of the listener that gets removed.
* @param listener The listener function that gets removed.
*/
removeEventListener>(
type: T,
listener: EventListener_2,
): void;
/**
* Fire an event type.
* @param event The event that gets fired.
*/
dispatchEvent>(event: BaseEvent & TEventMap[T]): void;
}
declare type EventListener_2 = (
event: TEventData & Event_2,
) => void;
declare class ExternalTexture extends Texture {
sourceTexture: WebGLTexture | GPUTexture | null;
readonly isExternalTexture: true;
constructor(sourceTexture?: WebGLTexture | GPUTexture | null);
}
declare interface Face {
a: number;
b: number;
c: number;
normal: Vector3;
materialIndex: number;
}
declare const FloatType: 1015;
/**
* This class can be used to define a linear fog that grows linearly denser
* with the distance.
*
* ```js
* const scene = new THREE.Scene();
* scene.fog = new THREE.Fog( 0xcccccc, 10, 15 );
* ```
*/
declare class Fog {
/**
* Constructs a new fog.
*
* @param {number|Color} color - The fog's color.
* @param {number} [near=1] - The minimum distance to start applying fog.
* @param {number} [far=1000] - The maximum distance at which fog stops being calculated and applied.
*/
constructor(color: ColorRepresentation, near?: number, far?: number);
/**
* This flag can be used for type testing.
*
* @default true
*/
readonly isFog: boolean;
/**
* The name of the fog.
*/
name: string;
/**
* The fog's color.
*/
color: Color;
/**
* The minimum distance to start applying fog. Objects that are less than
* `near` units from the active camera won't be affected by fog.
*
* @default 1
*/
near: number;
/**
* The maximum distance at which fog stops being calculated and applied.
* Objects that are more than `far` units away from the active camera won't
* be affected by fog.
*
* @default 1000
*/
far: number;
/**
* Returns a new fog with copied values from this instance.
*
* @return {Fog} A clone of this instance.
*/
clone(): Fog;
/**
* Serializes the fog into JSON.
*
* @param {?(Object|string)} meta - An optional value holding meta information about the serialization.
* @return {Object} A JSON object representing the serialized fog
*/
toJSON(): FogJSON;
}
/**
* This class can be used to define an exponential squared fog,
* which gives a clear view near the camera and a faster than exponentially
* densening fog farther from the camera.
*
* ```js
* const scene = new THREE.Scene();
* scene.fog = new THREE.FogExp2( 0xcccccc, 0.002 );
* ```
*/
declare class FogExp2 {
/**
* Constructs a new fog.
*
* @param {number|Color} color - The fog's color.
* @param {number} [density=0.00025] - Defines how fast the fog will grow dense.
*/
constructor(color: ColorRepresentation, density?: number);
/**
* This flag can be used for type testing.
*
* @default true
*/
readonly isFogExp2: boolean;
/**
* The name of the fog.
*/
name: string;
/**
* The fog's color.
*/
color: Color;
/**
* Defines how fast the fog will grow dense.
*
* @default 0.00025
*/
density: number;
/**
* Returns a new fog with copied values from this instance.
*
* @return {FogExp2} A clone of this instance.
*/
clone(): FogExp2;
/**
* Serializes the fog into JSON.
*
* @param {?(Object|string)} meta - An optional value holding meta information about the serialization.
* @return {Object} A JSON object representing the serialized fog
*/
toJSON(): FogExp2JSON;
}
declare interface FogExp2JSON {
type: string;
name: string;
color: number;
density: number;
}
declare interface FogJSON {
type: string;
name: string;
color: number;
near: number;
far: number;
}
declare const FrontSide: 0;
declare interface GeometryGroup {
/**
* Specifies the first element in this draw call – the first vertex for non-indexed geometry, otherwise the first triangle index.
* @remarks Expects a `Integer`
*/
start: number;
/**
* Specifies how many vertices (or indices) are included.
* @remarks Expects a `Integer`
*/
count: number;
/**
* Specifies the material array index to use.
* @remarks Expects a `Integer`
*/
materialIndex?: number | undefined;
}
/**
* This buffer attribute class does not construct a VBO.
* Instead, it uses whatever VBO is passed in constructor and can later be altered via the {@link buffer | .buffer} property.
* @remarks
* It is required to pass additional params alongside the VBO
* Those are: the GL context, the GL data type, the number of components per vertex, the number of bytes per component, and the number of vertices.
* @remarks
* The most common use case for this class is when some kind of GPGPU calculation interferes or even produces the VBOs in question.
* @see Example: {@link https://threejs.org/examples/#webgl_buffergeometry_glbufferattribute | WebGL / buffergeometry / glbufferattribute}
* @see {@link https://threejs.org/docs/index.html#api/en/core/GLBufferAttribute | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/core/GLBufferAttribute.js | Source}
*/
declare class GLBufferAttribute {
/**
* This creates a new GLBufferAttribute object.
* @param buffer Must be a {@link https://developer.mozilla.org/en-US/docs/Web/API/WebGLBuffer | WebGLBuffer}. See {@link GLBufferAttribute.buffer | .buffer}
* @param type One of {@link https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants#Data_types | WebGL Data Types}. See {@link GLBufferAttribute.type | .type}
* @param itemSize How many values make up each item (vertex). See {@link GLBufferAttribute.itemSize | .itemSize}
* @param elementSize `1`, `2` or `4`. The corresponding size (in bytes) for the given {@link type} param. See {@link GLBufferAttribute.elementSize | .elementSize}
* @param count The expected number of vertices in VBO. See {@link GLBufferAttribute.count | .count}
* @param {boolean} [normalized=false] - Whether the data are normalized or not.
*/
constructor(
buffer: WebGLBuffer,
type: GLenum,
itemSize: number,
elementSize: 1 | 2 | 4,
count: number,
normalized?: boolean,
);
/**
* Read-only flag to check if a given object is of type {@link GLBufferAttribute}.
* @remarks This is a _constant_ value
* @defaultValue `true`
*/
readonly isGLBufferAttribute: true;
/**
* Optional name for this attribute instance.
* @defaultValue `""`
*/
name: string;
/**
* The current {@link https://developer.mozilla.org/en-US/docs/Web/API/WebGLBuffer | WebGLBuffer} instance.
*/
buffer: WebGLBuffer;
/**
* A {@link https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Constants#Data_types | WebGL Data Type} describing the underlying VBO contents.
*
* #### WebGL Data Type (`GLenum`)
* - gl.BYTE: 0x1400
* - gl.UNSIGNED_BYTE: 0x1401
* - gl.SHORT: 0x1402
* - gl.UNSIGNED_SHORT: 0x1403
* - gl.INT: 0x1404
* - gl.UNSIGNED_INT: 0x1405
* - gl.FLOAT: 0x1406
* @remarks Set this property together with {@link elementSize | .elementSize}. The recommended way is using the {@link setType | .setType()} method.
* @remarks Expects a `DataType` `GLenum` _possible values:_ `0x1400` `0x1401` `0x1402` `0x1403` `0x1404` `0x1405` `0x1406`
*/
type: GLenum;
/**
* How many values make up each item (vertex).
* @remarks The number of values of the array that should be associated with a particular vertex.
* For instance, if this attribute is storing a 3-component vector (such as a position, normal, or color), then itemSize should be 3.
* @remarks Expects a `Integer`
*/
itemSize: number;
/**
* Stores the corresponding size in bytes for the current {@link type | .type} property value.
*
* The corresponding size (_in bytes_) for the given "type" param.
* #### WebGL Data Type (`GLenum`)
* - gl.BYTE: 1
* - gl.UNSIGNED_BYTE: 1
* - gl.SHORT: 2
* - gl.UNSIGNED_SHORT: 2
* - gl.INT: 4
* - gl.UNSIGNED_INT: 4
* - gl.FLOAT: 4
* @remarks Set this property together with {@link type | .type}. The recommended way is using the {@link setType | .setType} method.
* @see `constructor`` for a list of known type sizes.
* @remarks Expects a `1`, `2` or `4`
*/
elementSize: 1 | 2 | 4;
/**
* The expected number of vertices in VBO.
* @remarks Expects a `Integer`
*/
count: number;
/**
* Applies to integer data only. Indicates how the underlying data in the buffer maps to
* the values in the GLSL code. For instance, if `buffer` contains data of `gl.UNSIGNED_SHORT`,
* and `normalized` is `true`, the values `0 - +65535` in the buffer data will be mapped to
* `0.0f - +1.0f` in the GLSL attribute. If `normalized` is `false`, the values will be converted
* to floats unmodified, i.e. `65535` becomes `65535.0f`.
*/
normalized: boolean;
/**
* A version number, incremented every time the needsUpdate property is set to true.
* @remarks Expects a `Integer`
*/
version: number;
/**
* Setting this to true increments {@link version | .version}.
* @remarks _set-only property_.
*/
set needsUpdate(value: boolean);
/**
* Sets the {@link buffer | .buffer} property.
*/
setBuffer(buffer: WebGLBuffer): this;
/**
* Sets the both {@link GLBufferAttribute.type | type} and {@link GLBufferAttribute.elementSize | elementSize} properties.
*/
setType(type: GLenum, elementSize: 1 | 2 | 4): this;
/**
* Sets the {@link GLBufferAttribute.itemSize | itemSize} property.
*/
setItemSize(itemSize: number): this;
/**
* Sets the {@link GLBufferAttribute.count | count} property.
*/
setCount(count: number): this;
}
declare const GLSL1: "100";
declare const GLSL3: "300 es";
declare type GLSLVersion = typeof GLSL1 | typeof GLSL3;
declare interface GPUTexture {
}
declare const GreaterCompare: 516;
declare const GreaterDepth: 6;
declare const GreaterEqualCompare: 518;
declare const GreaterEqualDepth: 5;
declare const GreaterEqualStencilFunc: 518;
declare const GreaterStencilFunc: 516;
/**
* Its purpose is to make working with groups of objects syntactically clearer.
* @remarks This is almost identical to an {@link Object3D | Object3D}
* @example
* ```typescript
* const geometry = new THREE.BoxGeometry(1, 1, 1);
* const material = new THREE.MeshBasicMaterial({
* color: 0x00ff00
* });
* const cubeA = new THREE.Mesh(geometry, material);
* cubeA.position.set(100, 100, 0);
* const cubeB = new THREE.Mesh(geometry, material);
* cubeB.position.set(-100, -100, 0);
* //create a {@link Group} and add the two cubes
* //These cubes can now be rotated / scaled etc as a {@link Group} * const {@link Group} = new THREE.Group();
* group.add(cubeA);
* group.add(cubeB);
* scene.add(group);
* ```
* @see {@link https://threejs.org/docs/index.html#api/en/objects/Group | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/objects/Group.js | Source}
*/
declare class Group extends Object3D {
/**
* Creates a new {@link Group}.
*/
constructor();
/**
* Read-only flag to check if a given object is of type {@link Group}.
* @remarks This is a _constant_ value
* @defaultValue `true`
*/
readonly isGroup: true;
}
declare const HalfFloatType: 1016;
declare interface HSL {
h: number;
s: number;
l: number;
}
declare const IncrementStencilOp: 7682;
declare const IncrementWrapStencilOp: 34055;
declare class IndirectStorageBufferAttribute extends StorageBufferAttribute {
readonly isIndirectStorageBufferAttribute: true;
constructor(array: TypedArray, itemSize: number);
}
/**
* **"Interleaved"** means that multiple attributes, possibly of different types, (e.g., _position, normal, uv, color_) are packed into a single array buffer.
* An introduction into interleaved arrays can be found here: {@link https://blog.tojicode.com/2011/05/interleaved-array-basics.html | Interleaved array basics}
* @see Example: {@link https://threejs.org/examples/#webgl_buffergeometry_points_interleaved | webgl / buffergeometry / points / interleaved}
* @see {@link https://threejs.org/docs/index.html#api/en/core/InterleavedBuffer | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/core/InterleavedBuffer.js | Source}
*/
declare class InterleavedBuffer {
readonly isInterleavedBuffer: true;
/**
* Create a new instance of {@link InterleavedBuffer}
* @param array A {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray | TypedArray} with a shared buffer. Stores the geometry data.
* @param stride The number of typed-array elements per vertex. Expects a `Integer`
*/
constructor(array: TypedArray, stride: number);
/**
* A {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray | TypedArray} with a shared buffer. Stores the geometry data.
*/
array: TypedArray;
/**
* The number of {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray | TypedArray} elements per vertex.
* @remarks Expects a `Integer`
*/
stride: number;
/**
* Defines the intended usage pattern of the data store for optimization purposes.
* Corresponds to the {@link BufferAttribute.usage | usage} parameter of
* {@link https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData | WebGLRenderingContext.bufferData}.
* @remarks
* After the initial use of a buffer, its usage cannot be changed. Instead, instantiate a new one and set the desired usage before the next render.
* @see {@link https://threejs.org/docs/index.html#api/en/constants/BufferAttributeUsage | Buffer Attribute Usage Constants} for all possible values.
* @see {@link BufferAttribute.setUsage | setUsage}
* @defaultValue {@link THREE.StaticDrawUsage | THREE.StaticDrawUsage}.
*/
usage: Usage;
/**
* This can be used to only update some components of stored data. Use the {@link .addUpdateRange} function to add
* ranges to this array.
*/
updateRanges: Array<{
/**
* Position at which to start update.
*/
start: number;
/**
* The number of components to update.
*/
count: number;
}>;
/**
* A version number, incremented every time the {@link BufferAttribute.needsUpdate | needsUpdate} property is set to true.
* @remarks Expects a `Integer`
* @defaultValue `0`
*/
version: number;
/**
* Gives the total number of elements in the array.
* @remarks Expects a `Integer`
* @defaultValue 0
*/
count: number;
/**
* Flag to indicate that this attribute has changed and should be re-sent to the GPU.
* Set this to true when you modify the value of the array.
* @remarks Setting this to true also increments the {@link BufferAttribute.version | version}.
* @remarks _set-only property_.
*/
set needsUpdate(value: boolean);
/**
* {@link http://en.wikipedia.org/wiki/Universally_unique_identifier | UUID} of this object instance.
* @remarks This gets automatically assigned and shouldn't be edited.
*/
uuid: string;
/**
* A callback function that is executed after the Renderer has transferred the geometry data to the GPU.
*/
onUploadCallback: () => void;
/**
* Sets the value of the {@link onUploadCallback} property.
* @see {@link onUploadCallback}
* @param callback function that is executed after the Renderer has transferred the geometry data to the GPU.
*/
onUpload(callback: () => void): this;
/**
* Calls {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set | TypedArray.set}( {@link value}, {@link offset} )
* on the {@link BufferAttribute.array | array}.
* @param value The source `TypedArray`.
* @param offset index of the {@link BufferAttribute.array | array} at which to start copying. Expects a `Integer`. Default `0`.
* @throws `RangeError` When {@link offset} is negative or is too large.
*/
set(value: ArrayLike, offset?: number): this;
/**
* Set {@link BufferAttribute.usage | usage}
* @remarks
* After the initial use of a buffer, its usage cannot be changed. Instead, instantiate a new one and set the desired usage before the next render.
* @see {@link https://threejs.org/docs/index.html#api/en/constants/BufferAttributeUsage | Buffer Attribute Usage Constants} for all possible values.
* @see {@link BufferAttribute.usage | usage}
* @param value Corresponds to the {@link BufferAttribute.usage | usage} parameter of
* {@link https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/bufferData | WebGLRenderingContext.bufferData}.
*/
setUsage(value: Usage): this;
/**
* Adds a range of data in the data array to be updated on the GPU. Adds an object describing the range to the
* {@link .updateRanges} array.
*/
addUpdateRange(start: number, count: number): void;
/**
* Clears the {@link .updateRanges} array.
*/
clearUpdateRanges(): void;
/**
* Copies another {@link InterleavedBuffer} to this {@link InterleavedBuffer} instance.
* @param source
*/
copy(source: InterleavedBuffer): this;
/**
* Copies data from {@link attribute}[{@link index2}] to {@link InterleavedBuffer.array | array}[{@link index1}].
* @param index1 Expects a `Integer`
* @param attribute
* @param index2 Expects a `Integer`
*/
copyAt(index1: number, attribute: InterleavedBufferAttribute, index2: number): this;
/**
* Creates a clone of this {@link InterleavedBuffer}.
* @param data This object holds shared array buffers required for properly cloning geometries with interleaved attributes.
*/
clone(data: {}): InterleavedBuffer;
/**
* Serializes this {@link InterleavedBuffer}.
* Converting to {@link https://github.com/mrdoob/three.js/wiki/JSON-Geometry-format-4 | JSON Geometry format v4},
* @param data This object holds shared array buffers required for properly serializing geometries with interleaved attributes.
*/
toJSON(data: {}): {
uuid: string;
buffer: string;
type: string;
stride: number;
};
}
/**
* @see {@link https://threejs.org/docs/index.html#api/en/core/InterleavedBufferAttribute | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/core/InterleavedBufferAttribute.js | Source}
*/
declare class InterleavedBufferAttribute {
/**
* Create a new instance of {@link THREE.InterleavedBufferAttribute | InterleavedBufferAttribute}.
* @param interleavedBuffer
* @param itemSize
* @param offset
* @param normalized Default `false`.
*/
constructor(interleavedBuffer: InterleavedBuffer, itemSize: number, offset: number, normalized?: boolean);
/**
* Optional name for this attribute instance.
* @defaultValue `''`
*/
name: string;
/**
* The {@link InterleavedBuffer | InterleavedBuffer} instance passed in the constructor.
*/
data: InterleavedBuffer;
/**
* How many values make up each item.
* @remarks Expects a `Integer`
*/
itemSize: number;
/**
* The offset in the underlying array buffer where an item starts.
* @remarks Expects a `Integer`
*/
offset: number;
/**
* @defaultValue `false`
*/
normalized: boolean;
/**
* The value of {@link data | .data}.{@link InterleavedBuffer.count | count}.
* If the buffer is storing a 3-component item (such as a _position, normal, or color_), then this will count the number of such items stored.
* @remarks _get-only property_.
* @remarks Expects a `Integer`
*/
get count(): number;
/**
* The value of {@link InterleavedBufferAttribute.data | data}.{@link InterleavedBuffer.array | array}.
* @remarks _get-only property_.
*/
get array(): TypedArray;
/**
* Flag to indicate that the {@link data | .data} ({@link InterleavedBuffer}) attribute has changed and should be re-sent to the GPU.
* @remarks Setting this to have the same result of setting true also increments the {@link InterleavedBuffer.needsUpdate | InterleavedBuffer.needsUpdate} of {@link data | .data}.
* @remarks Setting this to true also increments the {@link InterleavedBuffer.version | InterleavedBuffer.version}.
* @remarks _set-only property_.
*/
set needsUpdate(value: boolean);
/**
* Read-only flag to check if a given object is of type {@link InterleavedBufferAttribute}.
* @remarks This is a _constant_ value
* @defaultValue `true`
*/
readonly isInterleavedBufferAttribute: true;
/**
* Applies matrix {@link Matrix4 | m} to every Vector3 element of this InterleavedBufferAttribute.
* @param m
*/
applyMatrix4(m: Matrix4): this;
/**
* Applies normal matrix {@link Matrix3 | m} to every Vector3 element of this InterleavedBufferAttribute.
* @param m
*/
applyNormalMatrix(m: Matrix3): this;
/**
* Applies matrix {@link Matrix4 | m} to every Vector3 element of this InterleavedBufferAttribute, interpreting the elements as a direction vectors.
* @param m
*/
transformDirection(m: Matrix4): this;
/**
* Returns the given component of the vector at the given index.
*/
getComponent(index: number, component: number): number;
/**
* Sets the given component of the vector at the given index.
*/
setComponent(index: number, component: number, value: number): this;
/**
* Returns the x component of the item at the given index.
* @param index Expects a `Integer`
*/
getX(index: number): number;
/**
* Sets the x component of the item at the given index.
* @param index Expects a `Integer`
* @param x Expects a `Float`
*/
setX(index: number, x: number): this;
/**
* Returns the y component of the item at the given index.
* @param index Expects a `Integer`
*/
getY(index: number): number;
/**
* Sets the y component of the item at the given index.
* @param index Expects a `Integer`
* @param y Expects a `Float`
*/
setY(index: number, y: number): this;
/**
* Returns the z component of the item at the given index.
* @param index Expects a `Integer`
*/
getZ(index: number): number;
/**
* Sets the z component of the item at the given index.
* @param index Expects a `Integer`
* @param z Expects a `Float`
*/
setZ(index: number, z: number): this;
/**
* Returns the w component of the item at the given index.
* @param index Expects a `Integer`
*/
getW(index: number): number;
/**
* Sets the w component of the item at the given index.
* @param index Expects a `Integer`
* @param w Expects a `Float`
*/
setW(index: number, z: number): this;
/**
* Sets the x and y components of the item at the given index.
* @param index Expects a `Integer`
* @param x Expects a `Float`
* @param y Expects a `Float`
*/
setXY(index: number, x: number, y: number): this;
/**
* Sets the x, y and z components of the item at the given index.
* @param index Expects a `Integer`
* @param x Expects a `Float`
* @param y Expects a `Float`
* @param z Expects a `Float`
*/
setXYZ(index: number, x: number, y: number, z: number): this;
/**
* Sets the x, y, z and w components of the item at the given index.
* @param index Expects a `Integer`
* @param x Expects a `Float`
* @param y Expects a `Float`
* @param z Expects a `Float`
* @param w Expects a `Float`
*/
setXYZW(index: number, x: number, y: number, z: number, w: number): this;
/**
* Creates a clone of this {@link InterleavedBufferAttribute}.
* @param data This object holds shared array buffers required for properly cloning geometries with interleaved attributes.
*/
clone(data?: {}): BufferAttribute;
/**
* Serializes this {@link InterleavedBufferAttribute}.
* Converting to {@link https://github.com/mrdoob/three.js/wiki/JSON-Geometry-format-4 | JSON Geometry format v4},
* @param data This object holds shared array buffers required for properly serializing geometries with interleaved attributes.
*/
toJSON(data?: {}): {
isInterleavedBufferAttribute: true;
itemSize: number;
data: string;
offset: number;
normalized: boolean;
};
}
/**
* Abstract base class of interpolants over parametric samples.
*
* The parameter domain is one dimensional, typically the time or a path
* along a curve defined by the data.
*
* The sample values can have any dimensionality and derived classes may
* apply special interpretations to the data.
*
* This class provides the interval seek in a Template Method, deferring
* the actual interpolation to derived classes.
*
* Time complexity is O(1) for linear access crossing at most two points
* and O(log N) for random access, where N is the number of positions.
*
* References: {@link http://www.oodesign.com/template-method-pattern.html}
*
* @abstract
*/
declare abstract class Interpolant {
/**
* Constructs a new interpolant.
*
* @param {TypedArray} parameterPositions - The parameter positions hold the interpolation factors.
* @param {TypedArray} sampleValues - The sample values.
* @param {number} sampleSize - The sample size
* @param {TypedArray} [resultBuffer] - The result buffer.
*/
constructor(
parameterPositions: TypedArray,
sampleValues: TypedArray,
sampleSize: number,
resultBuffer?: TypedArray,
);
/**
* The parameter positions.
*
* @type {TypedArray}
*/
parameterPositions: TypedArray;
/**
* The result buffer.
*
* @type {TypedArray}
*/
resultBuffer: TypedArray;
/**
* The sample values.
*
* @type {TypedArray}
*/
sampleValues: TypedArray;
/**
* The value size.
*
* @type {TypedArray}
*/
valueSize: number;
/**
* The interpolation settings.
*
* @type {?Object}
* @default null
*/
settings: TSettings | null;
/**
* The default settings object.
*
* @type {Object}
*/
DefaultSettings_: TSettings;
/**
* Evaluate the interpolant at position `t`.
*
* @param {number} t - The interpolation factor.
* @return {TypedArray} The result buffer.
*/
evaluate(t: number): TypedArray;
/**
* Returns the interpolation settings.
*
* @return {Object} The interpolation settings.
*/
getSettings_(): unknown;
/**
* Copies a sample value to the result buffer.
*
* @param {number} index - An index into the sample value buffer.
* @return {TypedArray} The result buffer.
*/
copySampleValue_(index: number): TypedArray;
/**
* Copies a sample value to the result buffer.
*
* @abstract
* @param {number} i1 - An index into the sample value buffer.
* @param {number} t0 - The previous interpolation factor.
* @param {number} t - The current interpolation factor.
* @param {number} t1 - The next interpolation factor.
* @return {TypedArray} The result buffer.
*/
abstract interpolate_(i1: number, t0: number, t: number, t1: number): TypedArray;
/**
* Optional method that is executed when the interval has changed.
*
* @param {number} i1 - An index into the sample value buffer.
* @param {number} t0 - The previous interpolation factor.
* @param {number} t - The current interpolation factor.
*/
intervalChanged_(i1: number, t0: number, t: number): void;
}
declare const InterpolateBezier: 2303;
declare const InterpolateDiscrete: 2300;
declare const InterpolateLinear: 2301;
declare const InterpolateSmooth: 2302;
declare type InterpolationEndingModes = typeof ZeroCurvatureEnding | typeof ZeroSlopeEnding | typeof WrapAroundEnding;
declare type InterpolationModes =
| typeof InterpolateDiscrete
| typeof InterpolateLinear
| typeof InterpolateSmooth
| typeof InterpolateBezier;
declare interface Intersection {
/** Distance between the origin of the ray and the intersection */
distance: number;
/**
* Some objects (f.e. {@link Points}) provide the distance of the intersection to the nearest point on the ray. For
* other objects it will be `undefined`
*/
distanceToRay?: number | undefined;
/** Point of intersection, in world coordinates */
point: Vector3;
index?: number | undefined;
/** Intersected face */
face?: Face | null | undefined;
/** Index of the intersected face */
faceIndex?: number | null | undefined;
barycoord?: Vector3 | null;
/** The intersected object */
object: TIntersected;
uv?: Vector2 | undefined;
uv1?: Vector2 | undefined;
normal?: Vector3;
/** The index number of the instance where the ray intersects the {@link THREE.InstancedMesh | InstancedMesh } */
instanceId?: number | undefined;
pointOnLine?: Vector3;
batchId?: number;
}
declare const IntType: 1013;
declare const InvertStencilOp: 5386;
declare interface IUniform {
value: TValue;
}
declare interface JSONMeta {
geometries: Record;
materials: Record;
textures: Record;
images: Record;
shapes: Record;
skeletons: Record;
animations: Record;
nodes: Record;
}
declare const KeepStencilOp: 7680;
/**
* Represents a timed sequence of keyframes, which are composed of lists of
* times and related values, and which are used to animate a specific property
* of an object.
*/
declare class KeyframeTrack {
/**
* Converts the keyframe track to JSON.
*
* @static
* @param {KeyframeTrack} track - The keyframe track to serialize.
* @return {Object} The serialized keyframe track as JSON.
*/
static toJSON(track: KeyframeTrack): KeyframeTrackJSON;
/**
* Constructs a new keyframe track.
*
* @param {string} name - The keyframe track's name.
* @param {Array} times - A list of keyframe times.
* @param {Array} values - A list of keyframe values.
* @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth|InterpolateBezier)} [interpolation] - The interpolation type.
*/
constructor(
name: string,
times: ArrayLike,
values: ArrayLike,
interpolation?: InterpolationModes,
);
/**
* The track's name can refer to morph targets or bones or
* possibly other values within an animated object. See {@link PropertyBinding#parseTrackName}
* for the forms of strings that can be parsed for property binding.
*/
name: string;
/**
* The keyframe times.
*/
times: Float32Array;
/**
* The keyframe values.
*/
values: Float32Array;
/**
* Factory method for creating a new discrete interpolant.
*
* @static
* @param {TypedArray} [result] - The result buffer.
* @return {DiscreteInterpolant} The new interpolant.
*/
InterpolantFactoryMethodDiscrete(result?: TypedArray): DiscreteInterpolant;
/**
* Factory method for creating a new linear interpolant.
*
* @static
* @param {TypedArray} [result] - The result buffer.
* @return {LinearInterpolant} The new interpolant.
*/
InterpolantFactoryMethodLinear(result?: TypedArray): LinearInterpolant;
/**
* Factory method for creating a new smooth interpolant.
*
* @static
* @param {TypedArray} [result] - The result buffer.
* @return {CubicInterpolant} The new interpolant.
*/
InterpolantFactoryMethodSmooth(result?: TypedArray): CubicInterpolant;
/**
* Factory method for creating a new Bezier interpolant.
*
* The Bezier interpolant requires tangent data to be set via the `settings` property
* on the track before creating the interpolant. The settings should contain:
* - `inTangents`: Float32Array with [time, value] pairs per keyframe per component
* - `outTangents`: Float32Array with [time, value] pairs per keyframe per component
*
* @static
* @param {TypedArray} [result] - The result buffer.
* @return {BezierInterpolant} The new interpolant.
*/
InterpolantFactoryMethodBezier(result?: TypedArray): BezierInterpolant;
/**
* Defines the interpolation factor method for this keyframe track.
*
* @param {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth|InterpolateBezier)} interpolation - The interpolation type.
* @return {KeyframeTrack} A reference to this keyframe track.
*/
setInterpolation(interpolation: InterpolationModes): KeyframeTrack;
/**
* Returns the current interpolation type.
*
* @return {(InterpolateLinear|InterpolateDiscrete|InterpolateSmooth|InterpolateBezier)} The interpolation type.
*/
getInterpolation(): InterpolationModes;
/**
* Returns the value size.
*
* @return {number} The value size.
*/
getValueSize(): number;
/**
* Moves all keyframes either forward or backward in time.
*
* @param {number} timeOffset - The offset to move the time values.
* @return {KeyframeTrack} A reference to this keyframe track.
*/
shift(timeOffset: number): KeyframeTrack;
/**
* Scale all keyframe times by a factor (useful for frame - seconds conversions).
*
* @param {number} timeScale - The time scale.
* @return {KeyframeTrack} A reference to this keyframe track.
*/
scale(timeScale: number): KeyframeTrack;
/**
* Removes keyframes before and after animation without changing any values within the defined time range.
*
* Note: The method does not shift around keys to the start of the track time, because for interpolated
* keys this will change their values
*
* @param {number} startTime - The start time.
* @param {number} endTime - The end time.
* @return {KeyframeTrack} A reference to this keyframe track.
*/
trim(startTime: number, endTime: number): KeyframeTrack;
/**
* Performs minimal validation on the keyframe track. Returns `true` if the values
* are valid.
*
* @return {boolean} Whether the keyframes are valid or not.
*/
validate(): boolean;
/**
* Optimizes this keyframe track by removing equivalent sequential keys (which are
* common in morph target sequences).
*
* @return {KeyframeTrack} A reference to this keyframe track.
*/
optimize(): this;
/**
* Returns a new keyframe track with copied values from this instance.
*
* @return {KeyframeTrack} A clone of this instance.
*/
clone(): this;
/**
* The value type name.
*
* @default ''
*/
ValueTypeName: string;
/**
* The time buffer type of this keyframe track.
*
* @default Float32Array.constructor
*/
TimeBufferType: TypedArrayConstructor | ArrayConstructor;
/**
* The value buffer type of this keyframe track.
*
* @default Float32Array.constructor
*/
ValueBufferType: TypedArrayConstructor | ArrayConstructor;
/**
* The default interpolation type of this keyframe track.
*
* @default InterpolateLinear
*/
DefaultInterpolation: InterpolationModes;
}
declare interface KeyframeTrackJSON {
name: string;
times: number[];
values: number[];
interpolation?: InterpolationModes;
type: string;
}
/**
* A {@link THREE.Layers | Layers} object assigns an {@link THREE.Object3D | Object3D} to 1 or more of 32 layers numbered `0` to `31` - internally the
* layers are stored as a {@link https://en.wikipedia.org/wiki/Mask_(computing) | bit mask}, and
* by default all Object3Ds are a member of layer `0`.
* @remarks
* This can be used to control visibility - an object must share a layer with a {@link Camera | camera} to be visible when that camera's view is rendered.
* @remarks
* All classes that inherit from {@link THREE.Object3D | Object3D} have an {@link THREE.Object3D.layers | Object3D.layers} property which is an instance of this class.
* @see Example: {@link https://threejs.org/examples/#webgl_layers | WebGL / layers}
* @see Example: {@link https://threejs.org/examples/#webxr_vr_layers | Webxr / vr / layers}
* @see {@link https://threejs.org/docs/index.html#api/en/core/Layers | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/core/Layers.js | Source}
*/
declare class Layers {
/**
* Create a new Layers object, with membership initially set to layer 0.
*/
constructor();
/**
* A bit mask storing which of the 32 layers this layers object is currently a member of.
* @defaultValue `1 | 0`
* @remarks Expects a `Integer`
*/
mask: number;
/**
* Set membership to `layer`, and remove membership all other layers.
* @param layer An integer from 0 to 31.
*/
set(layer: number): void;
/**
* Add membership of this `layer`.
* @param layer An integer from 0 to 31.
*/
enable(layer: number): void;
/**
* Add membership to all layers.
*/
enableAll(): void;
/**
* Toggle membership of `layer`.
* @param layer An integer from 0 to 31.
*/
toggle(layer: number): void;
/**
* Remove membership of this `layer`.
* @param layer An integer from 0 to 31.
*/
disable(layer: number): void;
/**
* Remove membership from all layers.
*/
disableAll(): void;
/**
* Returns true if this and the passed `layers` object have at least one layer in common.
* @param layers A Layers object
*/
test(layers: Layers): boolean;
/**
* Returns true if the given layer is enabled.
* @param layer An integer from 0 to 31.
*/
isEnabled(layer: number): boolean;
}
declare const LessCompare: 513;
declare const LessDepth: 2;
declare const LessEqualCompare: 515;
declare const LessEqualDepth: 3;
declare const LessEqualStencilFunc: 515;
declare const LessStencilFunc: 513;
/**
* Abstract base class for lights - all other light types inherit the
* properties and methods described here.
*/
declare abstract class Light extends Object3D {
/**
* Constructs a new light.
*
* @param {(number|Color|string)} [color=0xffffff] - The light's color.
* @param {number} [intensity=1] - The light's strength/intensity.
*/
constructor(color?: ColorRepresentation, intensity?: number);
/**
* This flag can be used for type testing.
*
* @default true
*/
readonly isLight: boolean;
/**
* The light's color.
*/
color: Color;
/**
* The light's intensity.
*
* @default 1
*/
intensity: number;
/**
* Frees the GPU-related resources allocated by this instance. Call this
* method whenever this instance is no longer used in your app.
*/
dispose(): void;
copy(source: Light, recursive?: boolean): this;
toJSON(meta?: JSONMeta): LightJSON;
}
declare interface LightEventMap extends Object3DEventMap {
dispose: {};
}
declare interface LightJSON extends Object3DJSON {
color: number;
intensity: number;
}
declare class Line3 {
constructor(start?: Vector3, end?: Vector3);
/**
* @default new THREE.Vector3()
*/
start: Vector3;
/**
* @default new THREE.Vector3()
*/
end: Vector3;
set(start?: Vector3, end?: Vector3): Line3;
clone(): this;
copy(line: Line3): this;
getCenter(target: Vector3): Vector3;
delta(target: Vector3): Vector3;
distanceSq(): number;
distance(): number;
at(t: number, target: Vector3): Vector3;
closestPointToPointParameter(point: Vector3, clampToLine?: boolean): number;
closestPointToPoint(point: Vector3, clampToLine: boolean, target: Vector3): Vector3;
distanceSqToLine3(line: Line3, c1?: Vector3, c2?: Vector3): number;
applyMatrix4(matrix: Matrix4): Line3;
equals(line: Line3): boolean;
}
/**
* {@link LinearFilter} returns the weighted average of the four texture elements that are closest to the specified texture coordinates,
* and can include items wrapped or repeated from other parts of a texture,
* depending on the values of {@link THREE.Texture.wrapS | wrapS} and {@link THREE.Texture.wrapT | wrapT}, and on the exact mapping.
*/
declare const LinearFilter: 1006;
/**
* A basic linear interpolant.
*
* @augments Interpolant
*/
declare class LinearInterpolant extends Interpolant {
interpolate_(i1: number, t0: number, t: number, t1: number): TypedArray;
}
/**
* {@link LinearMipMapLinearFilter} is the default and chooses the two mipmaps that most closely match the size of the pixel being textured and
* uses the {@link LinearFilter} criterion to produce a texture value from each mipmap.
* The final texture value is a weighted average of those two values.
*/
declare const LinearMipMapLinearFilter: 1008;
/**
* {@link LinearMipmapLinearFilter} is the default and chooses the two mipmaps that most closely match the size of the pixel being textured and
* uses the {@link LinearFilter} criterion to produce a texture value from each mipmap.
* The final texture value is a weighted average of those two values.
*/
declare const LinearMipmapLinearFilter: 1008;
/**
* {@link LinearMipMapNearestFilter} chooses the mipmap that most closely matches the size of the pixel being textured and
* uses the {@link LinearFilter} criterion (a weighted average of the four texels that are closest to the center of the pixel) to produce a texture value.
*/
declare const LinearMipMapNearestFilter: 1007;
/**
* {@link LinearMipmapNearestFilter} chooses the mipmap that most closely matches the size of the pixel being textured and
* uses the {@link LinearFilter} criterion (a weighted average of the four texels that are closest to the center of the pixel) to produce a texture value.
*/
declare const LinearMipmapNearestFilter: 1007;
declare const LinearSRGBColorSpace: "srgb-linear";
declare const LinearToneMapping: 1;
/**
* Load a VRM 1.0 model from an ArrayBuffer.
* Validates the GLB binary first, then parses with three-vrm.
*
* @param buffer The GLB file as an ArrayBuffer.
* @returns The loaded VRM instance.
* @throws If the buffer is not a valid VRM 1.0 GLB or if parsing fails.
*/
export declare async function loadVrm(buffer: ArrayBuffer): Promise {
validateVrm(buffer);
const loader = new GLTFLoader();
loader.register((parser) => new VRMLoaderPlugin(parser));
// Register a VRMLoaderPlugin
loader.register((parser) => {
// create a WebGPU compatible MToonMaterialLoaderPlugin
const mtoonMaterialPlugin = new MToonMaterialLoaderPlugin(parser, {
// set the material type to MToonNodeMaterial
materialType: MToonNodeMaterial,
});
return new VRMLoaderPlugin(parser, {
// Specify the MToonMaterialLoaderPlugin to use in the VRMLoaderPlugin instance
mtoonMaterialPlugin,
});
});
const gltf = await loader.parseAsync(buffer, '');
const vrm = (gltf.userData as { vrm?: VRM }).vrm;
if (!vrm) {
throw new Error('[VrmCanvas] Failed to extract VRM from GLB.');
}
// Optimize for performance.
VRMUtils.removeUnnecessaryVertices(gltf.scene);
VRMUtils.combineSkeletons(gltf.scene);
// Disable frustum culling to keep skinned meshes visible.
vrm.scene.traverse((obj) => {
obj.frustumCulled = false;
});
return vrm;
}
/**
* Load a single VRMA animation from an ArrayBuffer.
* Validates the GLB binary first, then parses with three-vrm-animation.
*
* @param buffer The GLB file as an ArrayBuffer.
* @returns The loaded VRMAnimation instance.
* @throws If the buffer is not a valid VRMA GLB or if parsing fails.
*/
export declare async function loadVRMAnimation(
buffer: ArrayBuffer,
): Promise {
validateVrma(buffer);
const loader = new GLTFLoader();
loader.register((parser) => new VRMAnimationLoaderPlugin(parser));
const gltf = await loader.parseAsync(buffer, '');
const animations = (gltf.userData as { vrmAnimations?: VRMAnimation[] })
.vrmAnimations;
if (!animations || animations.length === 0) {
throw new Error('[VrmCanvas] Failed to extract VRMAnimation from GLB.');
}
return animations[0];
}
declare const LoopOnce: 2200;
declare const LoopPingPong: 2202;
declare const LoopRepeat: 2201;
/**
* Texture Magnification Filter Modes.
* For use with a texture's {@link THREE.Texture.magFilter | magFilter} property,
* these define the texture magnification function to be used when the pixel being textured maps to an area less than or equal to one texture element (texel).
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
* @see {@link https://sbcode.net/threejs/mipmaps/ | Texture Mipmaps (non-official)}
*/
declare type MagnificationTextureFilter = typeof NearestFilter | typeof LinearFilter;
declare type MapColorPropertiesToColorRepresentations = {
[P in keyof T]: T[P] extends Color ? ColorRepresentation : T[P];
};
/**
* Texture Mapping Modes for non-cube Textures
* @remarks {@link UVMapping} is the _default_ value and behaver for Texture Mapping.
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
*/
declare type Mapping =
| typeof UVMapping
| typeof EquirectangularReflectionMapping
| typeof EquirectangularRefractionMapping;
/**
* Abstract base class for materials.
*
* Materials define the appearance of renderable 3D objects.
*
* @abstract
*/
declare class Material extends EventDispatcher {
/**
* This flag can be used for type testing.
*
* @default true
*/
readonly isMaterial: boolean;
/**
* The UUID of the material.
*/
readonly uuid: string;
/**
* The type property is used for detecting the object type
* in context of serialization/deserialization.
*/
type: string;
/**
* This starts at `0` and counts how many times {@link Material#needsUpdate} is set to `true`.
*
* @default 0
*/
readonly version: number;
defines?: Record | undefined;
/**
* An optional callback that is executed immediately before the material is used to render a 3D object.
*
* This method can only be used when rendering with {@link WebGLRenderer}.
*
* @param {WebGLRenderer} renderer - The renderer.
* @param {Scene} scene - The scene.
* @param {Camera} camera - The camera that is used to render the scene.
* @param {BufferGeometry} geometry - The 3D object's geometry.
* @param {Object3D} object - The 3D object.
* @param {Object} group - The geometry group data.
*/
onBeforeRender(
renderer: WebGLRenderer,
scene: Scene,
camera: Camera,
geometry: BufferGeometry,
object: Object3D,
group: Group,
): void;
/**
* An optional callback that is executed immediately before the shader
* program is compiled. This function is called with the shader source code
* as a parameter. Useful for the modification of built-in materials.
*
* This method can only be used when rendering with {@link WebGLRenderer}. The
* recommended approach when customizing materials is to use `WebGPURenderer` with the new
* Node Material system and [TSL](https://github.com/mrdoob/three.js/wiki/Three.js-Shading-Language).
*
* @param {{vertexShader:string,fragmentShader:string,uniforms:Object}} shaderobject - The object holds the uniforms and the vertex and fragment shader source.
* @param {WebGLRenderer} renderer - A reference to the renderer.
*/
onBeforeCompile(parameters: WebGLProgramParametersWithUniforms, renderer: WebGLRenderer): void;
/**
* In case {@link Material#onBeforeCompile} is used, this callback can be used to identify
* values of settings used in `onBeforeCompile()`, so three.js can reuse a cached
* shader or recompile the shader for this material as needed.
*
* This method can only be used when rendering with {@link WebGLRenderer}.
*
* @return {string} The custom program cache key.
*/
customProgramCacheKey(): string;
/**
* This method can be used to set default values from parameter objects.
* It is a generic implementation so it can be used with different types
* of materials.
*
* @param {Object} [values] - The material values to set.
*/
setValues(values?: MaterialParameters): void;
/**
* Serializes the material into JSON.
*
* @param {?(Object|string)} meta - An optional value holding meta information about the serialization.
* @return {Object} A JSON object representing the serialized material.
* @see {@link ObjectLoader#parse}
*/
toJSON(meta?: JSONMeta): MaterialJSON;
/**
* Deserializes the material from the given JSON.
*
* @param {Object} json - The JSON holding the serialized material.
* @param {Object} textures - A dictionary holding textures referenced by the material.
* @return {Material} A reference to this material.
*/
fromJSON(json: MaterialJSON, textures: Record): this;
/**
* Returns a new material with copied values from this instance.
*
* @return {Material} A clone of this instance.
*/
clone(): this;
/**
* Copies the values of the given material to this instance.
*
* @param {Material} source - The material to copy.
* @return {Material} A reference to this instance.
*/
copy(source: Material): this;
/**
* Frees the GPU-related resources allocated by this instance. Call this
* method whenever this instance is no longer used in your app.
*
* @fires Material#dispose
*/
dispose(): void;
/**
* Setting this property to `true` indicates the engine the material
* needs to be recompiled.
*
* @default false
* @param {boolean} value
*/
set needsUpdate(value: boolean);
}
declare interface Material extends MaterialProperties {}
declare const MaterialBlending: 6;
declare interface MaterialEventMap {
dispose: {};
}
declare interface MaterialJSON {
metadata: { version: number; type: string; generator: string };
uuid: string;
type: string;
name?: string;
color?: number;
roughness?: number;
metalness?: number;
sheen?: number;
sheenColor?: number;
sheenRoughness?: number;
emissive?: number;
emissiveIntensity?: number;
specular?: number;
specularIntensity?: number;
specularColor?: number;
shininess?: number;
clearcoat?: number;
clearcoatRoughness?: number;
clearcoatMap?: string;
clearcoatRoughnessMap?: string;
clearcoatNormalMap?: string;
clearcoatNormalScale?: Vector2Tuple;
dispersion?: number;
iridescence?: number;
iridescenceIOR?: number;
iridescenceThicknessRange?: number;
iridescenceMap?: string;
iridescenceThicknessMap?: string;
anisotropy?: number;
anisotropyRotation?: number;
anisotropyMap?: string;
map?: string;
matcap?: string;
alphaMap?: string;
lightMap?: string;
lightMapIntensity?: number;
aoMap?: string;
aoMapIntensity?: number;
bumpMap?: string;
bumpScale?: number;
normalMap?: string;
normalMapType?: NormalMapTypes;
normalScale?: Vector2Tuple;
displacementMap?: string;
displacementScale?: number;
displacementBias?: number;
roughnessMap?: string;
metalnessMap?: string;
emissiveMap?: string;
specularMap?: string;
specularIntensityMap?: string;
specularColorMap?: string;
envMap?: string;
combine?: Combine;
envMapRotation?: EulerTuple;
envMapIntensity?: number;
reflectivity?: number;
refractionRatio?: number;
gradientMap?: string;
transmission?: number;
transmissionMap?: string;
thickness?: number;
thicknessMap?: string;
attenuationDistance?: number;
attenuationColor?: number;
size?: number;
shadowSide?: number;
sizeAttenuation?: boolean;
blending?: Blending;
side?: Side;
vertexColors?: boolean;
opacity?: number;
transparent?: boolean;
blendSrc?: BlendingSrcFactor;
blendDst?: BlendingDstFactor;
blendEquation?: BlendingEquation;
blendSrcAlpha?: number | null;
blendDstAlpha?: number | null;
blendEquationAlpha?: number | null;
blendColor?: number;
blendAlpha?: number;
depthFunc?: DepthModes;
depthTest?: boolean;
depthWrite?: boolean;
colorWrite?: boolean;
stencilWriteMask?: number;
stencilFunc?: StencilFunc;
stencilRef?: number;
stencilFuncMask?: number;
stencilFail?: StencilOp;
stencilZFail?: StencilOp;
stencilZPass?: StencilOp;
stencilWrite?: boolean;
rotation?: number;
polygonOffset?: boolean;
polygonOffsetFactor?: number;
polygonOffsetUnits?: number;
linewidth?: number;
dashSize?: number;
gapSize?: number;
scale?: number;
dithering?: boolean;
alphaTest?: number;
alphaHash?: boolean;
alphaToCoverage?: boolean;
premultipliedAlpha?: boolean;
forceSinglePass?: boolean;
wireframe?: boolean;
wireframeLinewidth?: number;
wireframeLinecap?: string;
wireframeLinejoin?: string;
flatShading?: boolean;
visible?: boolean;
toneMapped?: boolean;
fog?: boolean;
userData?: Record;
textures?: Array>;
images?: SourceJSON[];
}
declare interface MaterialParameters extends Partial> {}
declare interface MaterialProperties {
/**
* The name of the material.
*/
name: string;
/**
* Defines the blending type of the material.
*
* It must be set to `CustomBlending` if custom blending properties like
* {@link Material#blendSrc}, {@link Material#blendDst} or {@link Material#blendEquation}
* should have any effect.
*
* @default NormalBlending
*/
blending: Blending;
/**
* Defines which side of faces will be rendered - front, back or both.
*
* @default FrontSide
*/
side: Side;
/**
* If set to `true`, vertex colors should be used.
*
* The engine supports RGB and RGBA vertex colors depending on whether a three (RGB) or
* four (RGBA) component color buffer attribute is used.
*
* @default false
*/
vertexColors: boolean;
/**
* Defines how transparent the material is.
* A value of `0.0` indicates fully transparent, `1.0` is fully opaque.
*
* If the {@link Material#transparent} is not set to `true`,
* the material will remain fully opaque and this value will only affect its color.
*
* @default 1
*/
opacity: number;
/**
* Defines whether this material is transparent. This has an effect on
* rendering as transparent objects need special treatment and are rendered
* after non-transparent objects.
*
* When set to true, the extent to which the material is transparent is
* controlled by {@link Material#opacity}.
*
* @default false
*/
transparent: boolean;
/**
* Enables alpha hashed transparency, an alternative to {@link Material#transparent} or
* {@link Material#alphaTest}. The material will not be rendered if opacity is lower than
* a random threshold. Randomization introduces some grain or noise, but approximates alpha
* blending without the associated problems of sorting. Using TAA can reduce the resulting noise.
*
* @default false
*/
alphaHash: boolean;
/**
* Defines the blending source factor.
*
* @default SrcAlphaFactor
*/
blendSrc: BlendingSrcFactor;
/**
* Defines the blending destination factor.
*
* @default OneMinusSrcAlphaFactor
*/
blendDst: BlendingDstFactor;
/**
* Defines the blending equation.
*
* @default AddEquation
*/
blendEquation: BlendingEquation;
/**
* Defines the blending source alpha factor.
*
* @default null
*/
blendSrcAlpha: BlendingSrcFactor | null;
/**
* Defines the blending destination alpha factor.
*
* @default null
*/
blendDstAlpha: BlendingDstFactor | null;
/**
* Defines the blending equation of the alpha channel.
*
* @default null
*/
blendEquationAlpha: BlendingEquation | null;
/**
* Represents the RGB values of the constant blend color.
*
* This property has only an effect when using custom blending with `ConstantColor` or `OneMinusConstantColor`.
*
* @default (0,0,0)
*/
blendColor: Color;
/**
* Represents the alpha value of the constant blend color.
*
* This property has only an effect when using custom blending with `ConstantAlpha` or `OneMinusConstantAlpha`.
*
* @default 0
*/
blendAlpha: number;
/**
* Defines the depth function.
*
* @default LessEqualDepth
*/
depthFunc: DepthModes;
/**
* Whether to have depth test enabled when rendering this material.
* When the depth test is disabled, the depth write will also be implicitly disabled.
*
* @default true
*/
depthTest: boolean;
/**
* Whether rendering this material has any effect on the depth buffer.
*
* When drawing 2D overlays it can be useful to disable the depth writing in
* order to layer several things together without creating z-index artifacts.
*
* @default true
*/
depthWrite: boolean;
/**
* The bit mask to use when writing to the stencil buffer.
*
* @default 0xff
*/
stencilWriteMask: number;
/**
* The stencil comparison function to use.
*
* @default AlwaysStencilFunc
*/
stencilFunc: StencilFunc;
/**
* The value to use when performing stencil comparisons or stencil operations.
*
* @default 0
*/
stencilRef: number;
/**
* The bit mask to use when comparing against the stencil buffer.
*
* @default 0xff
*/
stencilFuncMask: number;
/**
* Which stencil operation to perform when the comparison function returns `false`.
*
* @default KeepStencilOp
*/
stencilFail: StencilOp;
/**
* Which stencil operation to perform when the comparison function returns
* `true` but the depth test fails.
*
* @default KeepStencilOp
*/
stencilZFail: StencilOp;
/**
* Which stencil operation to perform when the comparison function returns
* `true` and the depth test passes.
*
* @default KeepStencilOp
*/
stencilZPass: StencilOp;
/**
* Whether stencil operations are performed against the stencil buffer. In
* order to perform writes or comparisons against the stencil buffer this
* value must be `true`.
*
* @default false
*/
stencilWrite: boolean;
/**
* User-defined clipping planes specified as THREE.Plane objects in world
* space. These planes apply to the objects this material is attached to.
* Points in space whose signed distance to the plane is negative are clipped
* (not rendered). This requires {@link WebGLRenderer#localClippingEnabled} to
* be `true`.
*
* @default null
*/
clippingPlanes: Array | null;
/**
* Changes the behavior of clipping planes so that only their intersection is
* clipped, rather than their union.
*
* @default false
*/
clipIntersection: boolean;
/**
* Defines whether to clip shadows according to the clipping planes specified
* on this material.
*
* @default false
*/
clipShadows: boolean;
/**
* Defines which side of faces cast shadows. If `null`, the side casting shadows
* is determined as follows:
*
* - When {@link Material#side} is set to `FrontSide`, the back side cast shadows.
* - When {@link Material#side} is set to `BackSide`, the front side cast shadows.
* - When {@link Material#side} is set to `DoubleSide`, both sides cast shadows.
*
* @default null
*/
shadowSide: Side | null;
/**
* Whether to render the material's color.
*
* This can be used in conjunction with {@link Object3D#renderOder} to create invisible
* objects that occlude other objects.
*
* @default true
*/
colorWrite: boolean;
/**
* Override the renderer's default precision for this material.
*
* @default null
*/
precision: ("highp" | "mediump" | "lowp") | null;
/**
* Whether to use polygon offset or not. When enabled, each fragment's depth value will
* be offset after it is interpolated from the depth values of the appropriate vertices.
* The offset is added before the depth test is performed and before the value is written
* into the depth buffer.
*
* Can be useful for rendering hidden-line images, for applying decals to surfaces, and for
* rendering solids with highlighted edges.
*
* @default false
*/
polygonOffset: boolean;
/**
* Specifies a scale factor that is used to create a variable depth offset for each polygon.
*
* @default 0
*/
polygonOffsetFactor: number;
/**
* Is multiplied by an implementation-specific value to create a constant depth offset.
*
* @default 0
*/
polygonOffsetUnits: number;
/**
* Whether to apply dithering to the color to remove the appearance of banding.
*
* @default false
*/
dithering: boolean;
/**
* Whether alpha to coverage should be enabled or not. Can only be used with MSAA-enabled contexts
* (meaning when the renderer was created with *antialias* parameter set to `true`). Enabling this
* will smooth aliasing on clip plane edges and alphaTest-clipped edges.
*
* @default false
*/
alphaToCoverage: boolean;
/**
* Whether to premultiply the alpha (transparency) value.
*
* @default false
*/
premultipliedAlpha: boolean;
/**
* Whether double-sided, transparent objects should be rendered with a single pass or not.
*
* The engine renders double-sided, transparent objects with two draw calls (back faces first,
* then front faces) to mitigate transparency artifacts. There are scenarios however where this
* approach produces no quality gains but still doubles draw calls e.g. when rendering flat
* vegetation like grass sprites. In these cases, set the `forceSinglePass` flag to `true` to
* disable the two pass rendering to avoid performance issues.
*
* @default false
*/
forceSinglePass: boolean;
/**
* Whether it's possible to override the material with {@link Scene#overrideMaterial} or not.
*
* @default true
*/
allowOverride: boolean;
/**
* Defines whether 3D objects using this material are visible.
*
* @default true
*/
visible: boolean;
/**
* Defines whether this material is tone mapped according to the renderer's tone mapping setting.
*
* It is ignored when rendering to a render target or using post processing or when using
* `WebGPURenderer`. In all these cases, all materials are honored by tone mapping.
*
* @default true
*/
toneMapped: boolean;
/**
* An object that can be used to store custom data about the Material. It
* should not hold references to functions as these will not be cloned.
*/
userData: Record;
set alphaTest(value: number);
/**
* Sets the alpha value to be used when running an alpha test. The material
* will not be rendered if the opacity is lower than this value.
*
* @default 0
*/
get alphaTest(): number;
}
declare class Matrix3 {
readonly isMatrix3: true;
/**
* Array with matrix values.
* @default [1, 0, 0, 0, 1, 0, 0, 0, 1]
*/
elements: Matrix3Tuple;
/**
* Creates an identity matrix.
*/
constructor();
/**
* Creates a 3x3 matrix with the given arguments in row-major order.
*/
constructor(
n11: number,
n12: number,
n13: number,
n21: number,
n22: number,
n23: number,
n31: number,
n32: number,
n33: number,
);
set(
n11: number,
n12: number,
n13: number,
n21: number,
n22: number,
n23: number,
n31: number,
n32: number,
n33: number,
): Matrix3;
identity(): this;
copy(m: Matrix3): this;
extractBasis(xAxis: Vector3, yAxis: Vector3, zAxis: Vector3): this;
setFromMatrix4(m: Matrix4): Matrix3;
/**
* Multiplies this matrix by m.
*/
multiply(m: Matrix3): this;
premultiply(m: Matrix3): this;
/**
* Sets this matrix to a x b.
*/
multiplyMatrices(a: Matrix3, b: Matrix3): this;
multiplyScalar(s: number): this;
determinant(): number;
/**
* Inverts this matrix in place.
*/
invert(): this;
/**
* Transposes this matrix in place.
*/
transpose(): this;
getNormalMatrix(matrix4: Matrix4): this;
/**
* Transposes this matrix into the supplied array r, and returns itself.
*/
transposeIntoArray(r: number[]): this;
setUvTransform(tx: number, ty: number, sx: number, sy: number, rotation: number, cx: number, cy: number): this;
/**
* @deprecated Use .makeScale() instead.
*/
scale(sx: number, sy: number): this;
/**
* @deprecated Use .makeRotation() instead.
*/
rotate(theta: number): this;
/**
* @deprecated Use .makeTranslation() instead.
*/
translate(tx: number, ty: number): this;
/**
* Sets this matrix as a 2D translation transform:
*
* ```
* 1, 0, x,
* 0, 1, y,
* 0, 0, 1
* ```
*
* @param v the amount to translate.
*/
makeTranslation(v: Vector2): this;
/**
* Sets this matrix as a 2D translation transform:
*
* ```
* 1, 0, x,
* 0, 1, y,
* 0, 0, 1
* ```
*
* @param x the amount to translate in the X axis.
* @param y the amount to translate in the Y axis.
*/
makeTranslation(x: number, y: number): this;
/**
* Sets this matrix as a 2D rotational transformation by theta radians. The resulting matrix will be:
*
* ```
* cos(θ) -sin(θ) 0
* sin(θ) cos(θ) 0
* 0 0 1
* ```
*
* @param theta Rotation angle in radians. Positive values rotate counterclockwise.
*/
makeRotation(theta: number): this;
/**
* Sets this matrix as a 2D scale transform:
*
* ```
* x, 0, 0,
* 0, y, 0,
* 0, 0, 1
* ```
*
* @param x the amount to scale in the X axis.
* @param y the amount to scale in the Y axis.
*/
makeScale(x: number, y: number): this;
equals(matrix: Matrix3): boolean;
/**
* Sets the values of this matrix from the provided array or array-like.
* @param array the source array or array-like.
* @param offset (optional) offset into the array-like. Default is 0.
*/
fromArray(array: ArrayLike, offset?: number): this;
/**
* Writes the elements of this matrix to an array in
* {@link https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major} format.
*/
toArray(): Matrix3Tuple;
/**
* Writes the elements of this matrix to an array in
* {@link https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order column-major} format.
* @param array array to store the resulting vector in. If not given a new array will be created.
* @param offset (optional) offset in the array at which to put the result.
*/
toArray>(array: TArray, offset?: number): TArray;
clone(): this;
}
declare type Matrix3Tuple = [
n11: number,
n12: number,
n13: number,
n21: number,
n22: number,
n23: number,
n31: number,
n32: number,
n33: number,
];
/**
* Represents a 4x4 matrix.
*
* The most common use of a 4x4 matrix in 3D computer graphics is as a transformation matrix.
* For an introduction to transformation matrices as used in WebGL, check out [this tutorial](https://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices)
*
* This allows a 3D vector representing a point in 3D space to undergo
* transformations such as translation, rotation, shear, scale, reflection,
* orthogonal or perspective projection and so on, by being multiplied by the
* matrix. This is known as `applying` the matrix to the vector.
*
* A Note on Row-Major and Column-Major Ordering:
*
* The constructor and {@link Matrix3#set} method take arguments in
* [row-major](https://en.wikipedia.org/wiki/Row-_and_column-major_order#Column-major_order)
* order, while internally they are stored in the {@link Matrix3#elements} array in column-major order.
* This means that calling:
* ```js
* const m = new THREE.Matrix4();
* m.set( 11, 12, 13, 14,
* 21, 22, 23, 24,
* 31, 32, 33, 34,
* 41, 42, 43, 44 );
* ```
* will result in the elements array containing:
* ```js
* m.elements = [ 11, 21, 31, 41,
* 12, 22, 32, 42,
* 13, 23, 33, 43,
* 14, 24, 34, 44 ];
* ```
* and internally all calculations are performed using column-major ordering.
* However, as the actual ordering makes no difference mathematically and
* most people are used to thinking about matrices in row-major order, the
* three.js documentation shows matrices in row-major order. Just bear in
* mind that if you are reading the source code, you'll have to take the
* transpose of any matrices outlined here to make sense of the calculations.
*/
declare class Matrix4 {
/**
* Constructs a new 4x4 matrix. This constructor
* initializes the matrix as an identity matrix.
*/
constructor();
/**
* Constructs a new 4x4 matrix. The arguments are supposed to be
* in row-major order.
*
* @param {number} [n11] - 1-1 matrix element.
* @param {number} [n12] - 1-2 matrix element.
* @param {number} [n13] - 1-3 matrix element.
* @param {number} [n14] - 1-4 matrix element.
* @param {number} [n21] - 2-1 matrix element.
* @param {number} [n22] - 2-2 matrix element.
* @param {number} [n23] - 2-3 matrix element.
* @param {number} [n24] - 2-4 matrix element.
* @param {number} [n31] - 3-1 matrix element.
* @param {number} [n32] - 3-2 matrix element.
* @param {number} [n33] - 3-3 matrix element.
* @param {number} [n34] - 3-4 matrix element.
* @param {number} [n41] - 4-1 matrix element.
* @param {number} [n42] - 4-2 matrix element.
* @param {number} [n43] - 4-3 matrix element.
* @param {number} [n44] - 4-4 matrix element.
*/
constructor(
n11: number,
n12: number,
n13: number,
n14: number,
n21: number,
n22: number,
n23: number,
n24: number,
n31: number,
n32: number,
n33: number,
n34: number,
n41: number,
n42: number,
n43: number,
n44: number,
);
/**
* A column-major list of matrix values.
*
* @type {Array}
*/
elements: Matrix4Tuple;
/**
* Sets the elements of the matrix.The arguments are supposed to be
* in row-major order.
*
* @param {number} [n11] - 1-1 matrix element.
* @param {number} [n12] - 1-2 matrix element.
* @param {number} [n13] - 1-3 matrix element.
* @param {number} [n14] - 1-4 matrix element.
* @param {number} [n21] - 2-1 matrix element.
* @param {number} [n22] - 2-2 matrix element.
* @param {number} [n23] - 2-3 matrix element.
* @param {number} [n24] - 2-4 matrix element.
* @param {number} [n31] - 3-1 matrix element.
* @param {number} [n32] - 3-2 matrix element.
* @param {number} [n33] - 3-3 matrix element.
* @param {number} [n34] - 3-4 matrix element.
* @param {number} [n41] - 4-1 matrix element.
* @param {number} [n42] - 4-2 matrix element.
* @param {number} [n43] - 4-3 matrix element.
* @param {number} [n44] - 4-4 matrix element.
* @return {Matrix4} A reference to this matrix.
*/
set(
n11: number,
n12: number,
n13: number,
n14: number,
n21: number,
n22: number,
n23: number,
n24: number,
n31: number,
n32: number,
n33: number,
n34: number,
n41: number,
n42: number,
n43: number,
n44: number,
): this;
/**
* Sets this matrix to the 4x4 identity matrix.
*
* @return {Matrix4} A reference to this matrix.
*/
identity(): this;
/**
* Returns a matrix with copied values from this instance.
*
* @return {Matrix4} A clone of this instance.
*/
clone(): Matrix4;
/**
* Copies the values of the given matrix to this instance.
*
* @param {Matrix4} m - The matrix to copy.
* @return {Matrix4} A reference to this matrix.
*/
copy(m: Matrix4): this;
/**
* Copies the translation component of the given matrix
* into this matrix's translation component.
*
* @param {Matrix4} m - The matrix to copy the translation component.
* @return {Matrix4} A reference to this matrix.
*/
copyPosition(m: Matrix4): this;
/**
* Set the upper 3x3 elements of this matrix to the values of given 3x3 matrix.
*
* @param {Matrix3} m - The 3x3 matrix.
* @return {Matrix4} A reference to this matrix.
*/
setFromMatrix3(m: Matrix3): this;
/**
* Extracts the basis of this matrix into the three axis vectors provided.
*
* @param {Vector3} xAxis - The basis's x axis.
* @param {Vector3} yAxis - The basis's y axis.
* @param {Vector3} zAxis - The basis's z axis.
* @return {Matrix4} A reference to this matrix.
*/
extractBasis(xAxis: Vector3, yAxis: Vector3, zAxis: Vector3): this;
/**
* Sets the given basis vectors to this matrix.
*
* @param {Vector3} xAxis - The basis's x axis.
* @param {Vector3} yAxis - The basis's y axis.
* @param {Vector3} zAxis - The basis's z axis.
* @return {Matrix4} A reference to this matrix.
*/
makeBasis(xAxis: Vector3, yAxis: Vector3, zAxis: Vector3): this;
/**
* Extracts the rotation component of the given matrix
* into this matrix's rotation component.
*
* Note: This method does not support reflection matrices.
*
* @param {Matrix4} m - The matrix.
* @return {Matrix4} A reference to this matrix.
*/
extractRotation(m: Matrix4): this;
/**
* Sets the rotation component (the upper left 3x3 matrix) of this matrix to
* the rotation specified by the given Euler angles. The rest of
* the matrix is set to the identity. Depending on the {@link Euler#order},
* there are six possible outcomes. See [this page](https://en.wikipedia.org/wiki/Euler_angles#Rotation_matrix)
* for a complete list.
*
* @param {Euler} euler - The Euler angles.
* @return {Matrix4} A reference to this matrix.
*/
makeRotationFromEuler(euler: Euler): this;
/**
* Sets the rotation component of this matrix to the rotation specified by
* the given Quaternion as outlined [here](https://en.wikipedia.org/wiki/Rotation_matrix#Quaternion)
* The rest of the matrix is set to the identity.
*
* @param {Quaternion} q - The Quaternion.
* @return {Matrix4} A reference to this matrix.
*/
makeRotationFromQuaternion(q: Quaternion): this;
/**
* Sets the rotation component of the transformation matrix, looking from `eye` towards
* `target`, and oriented by the up-direction.
*
* @param {Vector3} eye - The eye vector.
* @param {Vector3} target - The target vector.
* @param {Vector3} up - The up vector.
* @return {Matrix4} A reference to this matrix.
*/
lookAt(eye: Vector3, target: Vector3, up: Vector3): this;
/**
* Post-multiplies this matrix by the given 4x4 matrix.
*
* @param {Matrix4} m - The matrix to multiply with.
* @return {Matrix4} A reference to this matrix.
*/
multiply(m: Matrix4): this;
/**
* Pre-multiplies this matrix by the given 4x4 matrix.
*
* @param {Matrix4} m - The matrix to multiply with.
* @return {Matrix4} A reference to this matrix.
*/
premultiply(m: Matrix4): this;
/**
* Multiples the given 4x4 matrices and stores the result
* in this matrix.
*
* @param {Matrix4} a - The first matrix.
* @param {Matrix4} b - The second matrix.
* @return {Matrix4} A reference to this matrix.
*/
multiplyMatrices(a: Matrix4, b: Matrix4): this;
/**
* Multiplies every component of the matrix by the given scalar.
*
* @param {number} s - The scalar.
* @return {Matrix4} A reference to this matrix.
*/
multiplyScalar(s: number): this;
/**
* Computes and returns the determinant of this matrix.
*
* Based on the method outlined [here](http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.html).
*
* @return {number} The determinant.
*/
determinant(): number;
/**
* Computes and returns the determinant of the 4x4 matrix, but assumes the
* matrix is affine, saving some computations.
*
* For affine matrices (like an object's world matrix), this value equals the
* full 4x4 {@link Matrix4#determinant} but is cheaper to compute.
*
* Assumes the bottom row is [0, 0, 0, 1].
*
* @return {number} The determinant of the matrix.
*/
determinantAffine(): number;
/**
* Transposes this matrix in place.
*
* @return {Matrix4} A reference to this matrix.
*/
transpose(): this;
/**
* Sets the position component for this matrix from the given vector,
* without affecting the rest of the matrix.
*
* @param {number|Vector3} v - The vector object.
* @return {Matrix4} A reference to this matrix.
*/
setPosition(v: Vector3): this;
/**
* Sets the position component for this matrix from the given vector,
* without affecting the rest of the matrix.
*
* @param {number} x - The x component of the vector.
* @param {number} y - The y component of the vector.
* @param {number} z - The z component of the vector.
* @return {Matrix4} A reference to this matrix.
*/
setPosition(x: number, y: number, z: number): this;
/**
* Inverts this matrix, using the [analytic method](https://en.wikipedia.org/wiki/Invertible_matrix#Analytic_solution).
* You can not invert with a determinant of zero. If you attempt this, the method produces
* a zero matrix instead.
*
* @return {Matrix4} A reference to this matrix.
*/
invert(): this;
/**
* Multiplies the columns of this matrix by the given vector.
*
* @param {Vector3} v - The scale vector.
* @return {Matrix4} A reference to this matrix.
*/
scale(v: Vector3): this;
/**
* Gets the maximum scale value of the three axes.
*
* @return {number} The maximum scale.
*/
getMaxScaleOnAxis(): number;
/**
* Sets this matrix as a translation transform from the given vector.
*
* @param {Vector3} v - A translation vector.
* @return {Matrix4} A reference to this matrix.
*/
makeTranslation(v: Vector3): this;
/**
* Sets this matrix as a translation transform from the given vector.
*
* @param {number} x - The amount to translate in the X axis.
* @param {number} y - The amount to translate in the Y axis.
* @param {number} z - The amount to translate in the z axis.
* @return {Matrix4} A reference to this matrix.
*/
makeTranslation(x: number, y: number, z: number): this;
/**
* Sets this matrix as a rotational transformation around the X axis by
* the given angle.
*
* @param {number} theta - The rotation in radians.
* @return {Matrix4} A reference to this matrix.
*/
makeRotationX(theta: number): this;
/**
* Sets this matrix as a rotational transformation around the Y axis by
* the given angle.
*
* @param {number} theta - The rotation in radians.
* @return {Matrix4} A reference to this matrix.
*/
makeRotationY(theta: number): this;
/**
* Sets this matrix as a rotational transformation around the Z axis by
* the given angle.
*
* @param {number} theta - The rotation in radians.
* @return {Matrix4} A reference to this matrix.
*/
makeRotationZ(theta: number): this;
/**
* Sets this matrix as a rotational transformation around the given axis by
* the given angle.
*
* This is a somewhat controversial but mathematically sound alternative to
* rotating via Quaternions. See the discussion [here](https://www.gamedev.net/articles/programming/math-and-physics/do-we-really-need-quaternions-r1199).
*
* @param {Vector3} axis - The normalized rotation axis.
* @param {number} angle - The rotation in radians.
* @return {Matrix4} A reference to this matrix.
*/
makeRotationAxis(axis: Vector3, angle: number): this;
/**
* Sets this matrix as a scale transformation.
*
* @param {number} x - The amount to scale in the X axis.
* @param {number} y - The amount to scale in the Y axis.
* @param {number} z - The amount to scale in the Z axis.
* @return {Matrix4} A reference to this matrix.
*/
makeScale(x: number, y: number, z: number): this;
/**
* Sets this matrix as a shear transformation.
*
* @param {number} xy - The amount to shear X by Y.
* @param {number} xz - The amount to shear X by Z.
* @param {number} yx - The amount to shear Y by X.
* @param {number} yz - The amount to shear Y by Z.
* @param {number} zx - The amount to shear Z by X.
* @param {number} zy - The amount to shear Z by Y.
* @return {Matrix4} A reference to this matrix.
*/
makeShear(xy: number, xz: number, yx: number, yz: number, zx: number, zy: number): this;
/**
* Sets this matrix to the transformation composed of the given position,
* rotation (Quaternion) and scale.
*
* @param {Vector3} position - The position vector.
* @param {Quaternion} quaternion - The rotation as a Quaternion.
* @param {Vector3} scale - The scale vector.
* @return {Matrix4} A reference to this matrix.
*/
compose(position: Vector3, quaternion: Quaternion, scale: Vector3): this;
/**
* Decomposes this matrix into its position, rotation and scale components
* and provides the result in the given objects.
*
* Note: Not all matrices are decomposable in this way. For example, if an
* object has a non-uniformly scaled parent, then the object's world matrix
* may not be decomposable, and this method may not be appropriate.
*
* @param {Vector3} position - The position vector.
* @param {Quaternion} quaternion - The rotation as a Quaternion.
* @param {Vector3} scale - The scale vector.
* @return {Matrix4} A reference to this matrix.
*/
decompose(position: Vector3, quaternion: Quaternion, scale: Vector3): this;
/**
* Creates a perspective projection matrix. This is used internally by
* {@link PerspectiveCamera#updateProjectionMatrix}.
* @param {number} left - Left boundary of the viewing frustum at the near plane.
* @param {number} right - Right boundary of the viewing frustum at the near plane.
* @param {number} top - Top boundary of the viewing frustum at the near plane.
* @param {number} bottom - Bottom boundary of the viewing frustum at the near plane.
* @param {number} near - The distance from the camera to the near plane.
* @param {number} far - The distance from the camera to the far plane.
* @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system.
* @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.
* @return {Matrix4} A reference to this matrix.
*/
makePerspective(
left: number,
right: number,
top: number,
bottom: number,
near: number,
far: number,
coordinateSystem?: CoordinateSystem,
reversedDepth?: boolean,
): this;
/**
* Creates a orthographic projection matrix. This is used internally by
* {@link OrthographicCamera#updateProjectionMatrix}.
* @param {number} left - Left boundary of the viewing frustum at the near plane.
* @param {number} right - Right boundary of the viewing frustum at the near plane.
* @param {number} top - Top boundary of the viewing frustum at the near plane.
* @param {number} bottom - Bottom boundary of the viewing frustum at the near plane.
* @param {number} near - The distance from the camera to the near plane.
* @param {number} far - The distance from the camera to the far plane.
* @param {(WebGLCoordinateSystem|WebGPUCoordinateSystem)} [coordinateSystem=WebGLCoordinateSystem] - The coordinate system.
* @param {boolean} [reversedDepth=false] - Whether to use a reversed depth.
* @return {Matrix4} A reference to this matrix.
*/
makeOrthographic(
left: number,
right: number,
top: number,
bottom: number,
near: number,
far: number,
coordinateSystem?: CoordinateSystem,
reversedDepth?: boolean,
): this;
/**
* Returns `true` if this matrix is equal with the given one.
*
* @param {Matrix4} matrix - The matrix to test for equality.
* @return {boolean} Whether this matrix is equal with the given one.
*/
equals(matrix: Matrix4): boolean;
/**
* Sets the elements of the matrix from the given array.
*
* @param {Array} array - The matrix elements in column-major order.
* @param {number} [offset=0] - Index of the first element in the array.
* @return {Matrix4} A reference to this matrix.
*/
fromArray(array: ArrayLike, offset?: number): this;
/**
* Writes the elements of this matrix to the given array. If no array is provided,
* the method returns a new instance.
*
* @param {Array} [array=[]] - The target array holding the matrix elements in column-major order.
* @param {number} [offset=0] - Index of the first element in the array.
* @return {Array} The matrix elements in column-major order.
*/
toArray = Matrix4Tuple>(array?: TArray, offset?: number): TArray;
}
declare type Matrix4Tuple = [
n11: number,
n12: number,
n13: number,
n14: number,
n21: number,
n22: number,
n23: number,
n24: number,
n31: number,
n32: number,
n33: number,
n34: number,
n41: number,
n42: number,
n43: number,
n44: number,
];
declare const MaxEquation: 104;
/**
* Class representing triangular {@link https://en.wikipedia.org/wiki/Polygon_mesh | polygon mesh} based objects.
* @remarks
* Also serves as a base for other classes such as {@link THREE.SkinnedMesh | SkinnedMesh}, {@link THREE.InstancedMesh | InstancedMesh}.
* @example
* ```typescript
* const geometry = new THREE.BoxGeometry(1, 1, 1);
* const material = new THREE.MeshBasicMaterial({
* color: 0xffff00
* });
* const {@link Mesh} = new THREE.Mesh(geometry, material);
* scene.add(mesh);
* ```
* @see {@link https://threejs.org/docs/index.html#api/en/objects/Mesh | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/objects/Mesh.js | Source}
*/
declare class Mesh<
TGeometry extends BufferGeometry = BufferGeometry,
TMaterial extends Material | Material[] = Material | Material[],
TEventMap extends Object3DEventMap = Object3DEventMap,
> extends Object3D {
/**
* Create a new instance of {@link Mesh}
* @param geometry An instance of {@link THREE.BufferGeometry | BufferGeometry}. Default {@link THREE.BufferGeometry | `new THREE.BufferGeometry()`}.
* @param material A single or an array of {@link THREE.Material | Material}. Default {@link THREE.MeshBasicMaterial | `new THREE.MeshBasicMaterial()`}.
*/
constructor(geometry?: TGeometry, material?: TMaterial);
/**
* Read-only flag to check if a given object is of type {@link Mesh}.
* @remarks This is a _constant_ value
* @defaultValue `true`
*/
readonly isMesh: true;
/**
* @override
* @defaultValue `Mesh`
*/
override readonly type: string | "Mesh";
/**
* An instance of {@link THREE.BufferGeometry | BufferGeometry} (or derived classes), defining the object's structure.
* @defaultValue {@link THREE.BufferGeometry | `new THREE.BufferGeometry()`}.
*/
geometry: TGeometry;
/**
* An instance of material derived from the {@link THREE.Material | Material} base class or an array of materials, defining the object's appearance.
* @defaultValue {@link THREE.MeshBasicMaterial | `new THREE.MeshBasicMaterial()`}.
*/
material: TMaterial;
/**
* An array of weights typically from `0-1` that specify how much of the morph is applied.
* @defaultValue `undefined`, _but reset to a blank array by {@link updateMorphTargets | .updateMorphTargets()}._
*/
morphTargetInfluences?: number[] | undefined;
/**
* A dictionary of morphTargets based on the `morphTarget.name` property.
* @defaultValue `undefined`, _but rebuilt by {@link updateMorphTargets | .updateMorphTargets()}._
*/
morphTargetDictionary?: { [key: string]: number } | undefined;
/**
* The number of instances of this mesh.
* Can only be used with {@link WebGPURenderer}.
*
* @default 1
*/
count: number;
/**
* Updates the morphTargets to have no influence on the object
* @remarks Resets the {@link morphTargetInfluences} and {@link morphTargetDictionary} properties.
*/
updateMorphTargets(): void;
/**
* Get the local-space position of the vertex at the given index,
* taking into account the current animation state of both morph targets and skinning.
* @param index Expects a `Integer`
* @param target
*/
getVertexPosition(index: number, target: Vector3): Vector3;
toJSON(meta?: JSONMeta): MeshJSON;
}
declare interface MeshJSON extends Object3DJSON {
object: MeshJSONObject;
}
declare interface MeshJSONObject extends Object3DJSONObject {
geometry: string;
}
/** Build information meta data */
export declare type Meta = {
/** Version */
version: string;
/** Build date */
date: string;
};
export declare const Meta: Meta = {
version: __APP_VERSION__,
date: __BUILD_DATE__,
};
declare const MinEquation: 103;
/**
* Texture Minification Filter Modes.
* For use with a texture's {@link THREE.Texture.minFilter | minFilter} property,
* these define the texture minifying function that is used whenever the pixel being textured maps to an area greater than one texture element (texel).
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
* @see {@link https://sbcode.net/threejs/mipmaps/ | Texture Mipmaps (non-official)}
*/
declare type MinificationTextureFilter =
| typeof NearestFilter
| typeof NearestMipmapNearestFilter
| typeof NearestMipMapNearestFilter
| typeof NearestMipmapLinearFilter
| typeof NearestMipMapLinearFilter
| typeof LinearFilter
| typeof LinearMipmapNearestFilter
| typeof LinearMipMapNearestFilter
| typeof LinearMipmapLinearFilter
| typeof LinearMipMapLinearFilter;
/** With {@link MirroredRepeatWrapping} the texture will repeats to infinity, mirroring on each repeat. */
declare const MirroredRepeatWrapping: 1002;
declare interface MixerControlInterpolant extends LinearInterpolant {
__cacheIndex: number;
}
declare const MixOperation: 1;
declare interface MorphTarget {
name: string;
vertices: Vector3[];
}
declare const MultiplyBlending: 4;
declare const MultiplyOperation: 0;
/** {@link NearestFilter} returns the value of the texture element that is nearest (in Manhattan distance) to the specified texture coordinates. */
declare const NearestFilter: 1003;
/**
* {@link NearestMipMapLinearFilter} chooses the two mipmaps that most closely match the size of the pixel being textured
* and uses the {@link NearestFilter} criterion to produce a texture value from each mipmap.
* The final texture value is a weighted average of those two values.
*/
declare const NearestMipMapLinearFilter: 1005;
/**
* {@link NearestMipmapLinearFilter} chooses the two mipmaps that most closely match the size of the pixel being textured
* and uses the {@link NearestFilter} criterion to produce a texture value from each mipmap.
* The final texture value is a weighted average of those two values.
*/
declare const NearestMipmapLinearFilter: 1005;
/**
* {@link NearestMipmapNearestFilter} chooses the mipmap that most closely matches the size of the pixel being textured
* and uses the {@link NearestFilter} criterion (the texel nearest to the center of the pixel) to produce a texture value.
*/
declare const NearestMipMapNearestFilter: 1004;
/**
* {@link NearestMipmapNearestFilter} chooses the mipmap that most closely matches the size of the pixel being textured
* and uses the {@link NearestFilter} criterion (the texel nearest to the center of the pixel) to produce a texture value.
*/
declare const NearestMipmapNearestFilter: 1004;
declare const NeutralToneMapping: 7;
declare const NeverCompare: 512;
declare const NeverDepth: 0;
declare const NeverStencilFunc: 512;
declare const NoBlending: 0;
declare const NoColorSpace: "";
declare interface NodesHandler {
setRenderer(renderer: WebGLRenderer): void;
renderStart(scene: Object3D, camera: Camera): void;
renderEnd(): void;
build(material: Material, object: Object3D, parameters: WebGLProgramParametersWithUniforms): void;
}
declare const NormalAnimationBlendMode: 2500;
declare const NormalBlending: 1;
declare type NormalBufferAttributes = Record;
declare type NormalMapTypes = typeof TangentSpaceNormalMap | typeof ObjectSpaceNormalMap;
declare type NormalOrGLBufferAttributes = Record<
string,
BufferAttribute | InterleavedBufferAttribute | GLBufferAttribute
>;
declare const NotEqualCompare: 517;
declare const NotEqualDepth: 7;
declare const NotEqualStencilFunc: 517;
declare const NoToneMapping: 0;
/**
* This is the base class for most objects in three.js and provides a set of properties and methods for manipulating objects in 3D space.
* @remarks Note that this can be used for grouping objects via the {@link THREE.Object3D.add | .add()} method which adds the object as a child,
* however it is better to use {@link THREE.Group | Group} for this.
* @see {@link https://threejs.org/docs/index.html#api/en/core/Object3D | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/core/Object3D.js | Source}
*/
declare class Object3D extends EventDispatcher {
/**
* This creates a new {@link Object3D} object.
*/
constructor();
/**
* Flag to check if a given object is of type {@link Object3D}.
* @remarks This is a _constant_ value
* @defaultValue `true`
*/
readonly isObject3D: true;
/**
* Unique number for this {@link Object3D} instance.
* @remarks Note that ids are assigned in chronological order: 1, 2, 3, ..., incrementing by one for each new object.
* Expects a `Integer`
*/
readonly id: number;
/**
* {@link http://en.wikipedia.org/wiki/Universally_unique_identifier | UUID} of this object instance.
* @remarks This gets automatically assigned and shouldn't be edited.
*/
uuid: string;
/**
* Optional name of the object
* @remarks _(doesn't need to be unique)_.
* @defaultValue `""`
*/
name: string;
/**
* A Read-only _string_ to check `this` object type.
* @remarks This can be used to find a specific type of Object3D in a scene.
* Sub-classes will update this value.
* @defaultValue `Object3D`
*/
readonly type: string;
/**
* Object's parent in the {@link https://en.wikipedia.org/wiki/Scene_graph | scene graph}.
* @remarks An object can have at most one parent.
* @defaultValue `null`
*/
parent: Object3D | null;
/**
* Array with object's children.
* @see {@link THREE.Object3DGroup | Group} for info on manually grouping objects.
* @defaultValue `[]`
*/
children: Object3D[];
/**
* This is used by the {@link lookAt | lookAt} method, for example, to determine the orientation of the result.
* @defaultValue {@link DEFAULT_UP | Object3D.DEFAULT_UP} - that is `(0, 1, 0)`.
*/
up: Vector3;
/**
* Object's local position.
* @defaultValue `new THREE.Vector3()` - that is `(0, 0, 0)`.
*/
readonly position: Vector3;
/**
* Object's local rotation ({@link https://en.wikipedia.org/wiki/Euler_angles | Euler angles}), in radians.
* @defaultValue `new THREE.Euler()` - that is `(0, 0, 0, Euler.DEFAULT_ORDER)`.
*/
readonly rotation: Euler;
/**
* Object's local rotation as a {@link THREE.Quaternion | Quaternion}.
* @defaultValue `new THREE.Quaternion()` - that is `(0, 0, 0, 1)`.
*/
readonly quaternion: Quaternion;
/**
* The object's local scale.
* @defaultValue `new THREE.Vector3( 1, 1, 1 )`
*/
readonly scale: Vector3;
/**
* @defaultValue `new THREE.Matrix4()`
*/
readonly modelViewMatrix: Matrix4;
/**
* @defaultValue `new THREE.Matrix3()`
*/
readonly normalMatrix: Matrix3;
/**
* The local transform matrix.
* @defaultValue `new THREE.Matrix4()`
*/
matrix: Matrix4;
/**
* The global transform of the object.
* @remarks If the {@link Object3D} has no parent, then it's identical to the local transform {@link THREE.Object3D.matrix | .matrix}.
* @defaultValue `new THREE.Matrix4()`
*/
matrixWorld: Matrix4;
/**
* When this is set, it calculates the matrix of position, (rotation or quaternion) and
* scale every frame and also recalculates the matrixWorld property.
* @defaultValue {@link DEFAULT_MATRIX_AUTO_UPDATE} - that is `(true)`.
*/
matrixAutoUpdate: boolean;
/**
* If set, then the renderer checks every frame if the object and its children need matrix updates.
* When it isn't, then you have to maintain all matrices in the object and its children yourself.
* @defaultValue {@link DEFAULT_MATRIX_WORLD_AUTO_UPDATE} - that is `(true)`.
*/
matrixWorldAutoUpdate: boolean;
/**
* When this is set, it calculates the matrixWorld in that frame and resets this property to false.
* @defaultValue `false`
*/
matrixWorldNeedsUpdate: boolean;
/**
* The layer membership of the object.
* @remarks The object is only visible if it has at least one layer in common with the {@link THREE.Object3DCamera | Camera} in use.
* This property can also be used to filter out unwanted objects in ray-intersection tests when using {@link THREE.Raycaster | Raycaster}.
* @defaultValue `new THREE.Layers()`
*/
layers: Layers;
/**
* Object gets rendered if `true`.
* @defaultValue `true`
*/
visible: boolean;
/**
* Whether the object gets rendered into shadow map.
* @defaultValue `false`
*/
castShadow: boolean;
/**
* Whether the material receives shadows.
* @defaultValue `false`
*/
receiveShadow: boolean;
/**
* When this is set, it checks every frame if the object is in the frustum of the camera before rendering the object.
* If set to `false` the object gets rendered every frame even if it is not in the frustum of the camera.
* @defaultValue `true`
*/
frustumCulled: boolean;
/**
* This value allows the default rendering order of {@link https://en.wikipedia.org/wiki/Scene_graph | scene graph}
* objects to be overridden although opaque and transparent objects remain sorted independently.
* @remarks When this property is set for an instance of {@link Group | Group}, all descendants objects will be sorted and rendered together.
* Sorting is from lowest to highest renderOrder.
* @defaultValue `0`
*/
renderOrder: number;
/**
* Array with object's animation clips.
* @defaultValue `[]`
*/
animations: AnimationClip[];
/**
* Custom depth material to be used when rendering to the depth map.
* @remarks Can only be used in context of meshes.
* When shadow-casting with a {@link THREE.DirectionalLight | DirectionalLight} or {@link THREE.SpotLight | SpotLight},
* if you are modifying vertex positions in the vertex shader you must specify a customDepthMaterial for proper shadows.
* @defaultValue `undefined`
*/
customDepthMaterial?: Material | undefined;
/**
* Same as {@link customDepthMaterial}, but used with {@link THREE.Object3DPointLight | PointLight}.
* @defaultValue `undefined`
*/
customDistanceMaterial?: Material | undefined;
/**
* Whether the 3D object is supposed to be static or not. If set to `true`, it means
* the 3D object is not going to be changed after the initial renderer. This includes
* geometry and material settings. A static 3D object can be processed by the renderer
* slightly faster since certain state checks can be bypassed.
*
* Only relevant in context of {@link WebGPURenderer}.
*
* @default false
*/
static: boolean;
/**
* An object that can be used to store custom data about the {@link Object3D}.
* @remarks It should not hold references to _functions_ as these **will not** be cloned.
* @default `{}`
*/
userData: Record;
/**
* The pivot point for rotation and scale transformations.
* When set, rotation and scale are applied around this point
* instead of the object's origin.
*
* @default null
*/
pivot: Vector3 | null;
/**
* An optional callback that is executed immediately before a 3D object is rendered to a shadow map.
* @remarks This function is called with the following parameters: renderer, scene, camera, shadowCamera, geometry,
* depthMaterial, group.
* Please notice that this callback is only executed for `renderable` 3D objects. Meaning 3D objects which
* define their visual appearance with geometries and materials like instances of {@link Mesh}, {@link Line},
* {@link Points} or {@link Sprite}. Instances of {@link Object3D}, {@link Group} or {@link Bone} are not renderable
* and thus this callback is not executed for such objects.
*/
onBeforeShadow(
renderer: WebGLRenderer,
scene: Scene,
camera: Camera,
shadowCamera: Camera,
geometry: BufferGeometry,
depthMaterial: Material,
group: Group,
): void;
/**
* An optional callback that is executed immediately after a 3D object is rendered to a shadow map.
* @remarks This function is called with the following parameters: renderer, scene, camera, shadowCamera, geometry,
* depthMaterial, group.
* Please notice that this callback is only executed for `renderable` 3D objects. Meaning 3D objects which
* define their visual appearance with geometries and materials like instances of {@link Mesh}, {@link Line},
* {@link Points} or {@link Sprite}. Instances of {@link Object3D}, {@link Group} or {@link Bone} are not renderable
* and thus this callback is not executed for such objects.
*/
onAfterShadow(
renderer: WebGLRenderer,
scene: Scene,
camera: Camera,
shadowCamera: Camera,
geometry: BufferGeometry,
depthMaterial: Material,
group: Group,
): void;
/**
* An optional callback that is executed immediately before a 3D object is rendered.
* @remarks This function is called with the following parameters: renderer, scene, camera, geometry, material, group.
* Please notice that this callback is only executed for `renderable` 3D objects. Meaning 3D objects which
* define their visual appearance with geometries and materials like instances of {@link Mesh}, {@link Line},
* {@link Points} or {@link Sprite}. Instances of {@link Object3D}, {@link Group} or {@link Bone} are not renderable
* and thus this callback is not executed for such objects.
*/
onBeforeRender(
renderer: WebGLRenderer,
scene: Scene,
camera: Camera,
geometry: BufferGeometry,
material: Material,
group: Group,
): void;
/**
* An optional callback that is executed immediately after a 3D object is rendered.
* @remarks This function is called with the following parameters: renderer, scene, camera, geometry, material, group.
* Please notice that this callback is only executed for `renderable` 3D objects. Meaning 3D objects which
* define their visual appearance with geometries and materials like instances of {@link Mesh}, {@link Line},
* {@link Points} or {@link Sprite}. Instances of {@link Object3D}, {@link Group} or {@link Bone} are not renderable
* and thus this callback is not executed for such objects.
*/
onAfterRender(
renderer: WebGLRenderer,
scene: Scene,
camera: Camera,
geometry: BufferGeometry,
material: Material,
group: Group,
): void;
/**
* The default {@link up} direction for objects, also used as the default position for {@link THREE.DirectionalLight | DirectionalLight},
* {@link THREE.HemisphereLight | HemisphereLight} and {@link THREE.Spotlight | Spotlight} (which creates lights shining from the top down).
* @defaultValue `new THREE.Vector3( 0, 1, 0)`
*/
static DEFAULT_UP: Vector3;
/**
* The default setting for {@link matrixAutoUpdate} for newly created Object3Ds.
* @defaultValue `true`
*/
static DEFAULT_MATRIX_AUTO_UPDATE: boolean;
/**
* The default setting for {@link matrixWorldAutoUpdate} for newly created Object3Ds.
* @defaultValue `true`
*/
static DEFAULT_MATRIX_WORLD_AUTO_UPDATE: boolean;
/**
* Applies the matrix transform to the object and updates the object's position, rotation and scale.
* @param matrix
*/
applyMatrix4(matrix: Matrix4): void;
/**
* Applies the rotation represented by the quaternion to the object.
* @param quaternion
*/
applyQuaternion(quaternion: Quaternion): this;
/**
* Calls {@link THREE.Quaternion.setFromAxisAngle | setFromAxisAngle}({@link axis}, {@link angle}) on the {@link quaternion | .quaternion}.
* @param axis A normalized vector in object space.
* @param angle Angle in radians. Expects a `Float`
*/
setRotationFromAxisAngle(axis: Vector3, angle: number): void;
/**
* Calls {@link THREE.Quaternion.setFromEuler | setFromEuler}({@link euler}) on the {@link quaternion | .quaternion}.
* @param euler Euler angle specifying rotation amount.
*/
setRotationFromEuler(euler: Euler): void;
/**
* Calls {@link THREE.Quaternion.setFromRotationMatrix | setFromRotationMatrix}({@link m}) on the {@link quaternion | .quaternion}.
* @remarks Note that this assumes that the upper 3x3 of m is a pure rotation matrix (i.e, unscaled).
* @param m Rotate the quaternion by the rotation component of the matrix.
*/
setRotationFromMatrix(m: Matrix4): void;
/**
* Copy the given {@link THREE.Quaternion | Quaternion} into {@link quaternion | .quaternion}.
* @param q Normalized Quaternion.
*/
setRotationFromQuaternion(q: Quaternion): void;
/**
* Rotate an object along an axis in object space.
* @remarks The axis is assumed to be normalized.
* @param axis A normalized vector in object space.
* @param angle The angle in radians. Expects a `Float`
*/
rotateOnAxis(axis: Vector3, angle: number): this;
/**
* Rotate an object along an axis in world space.
* @remarks The axis is assumed to be normalized
* Method Assumes no rotated parent.
* @param axis A normalized vector in world space.
* @param angle The angle in radians. Expects a `Float`
*/
rotateOnWorldAxis(axis: Vector3, angle: number): this;
/**
* Rotates the object around _x_ axis in local space.
* @param rad The angle to rotate in radians. Expects a `Float`
*/
rotateX(angle: number): this;
/**
* Rotates the object around _y_ axis in local space.
* @param rad The angle to rotate in radians. Expects a `Float`
*/
rotateY(angle: number): this;
/**
* Rotates the object around _z_ axis in local space.
* @param rad The angle to rotate in radians. Expects a `Float`
*/
rotateZ(angle: number): this;
/**
* Translate an object by distance along an axis in object space
* @remarks The axis is assumed to be normalized.
* @param axis A normalized vector in object space.
* @param distance The distance to translate. Expects a `Float`
*/
translateOnAxis(axis: Vector3, distance: number): this;
/**
* Translates object along x axis in object space by {@link distance} units.
* @param distance Expects a `Float`
*/
translateX(distance: number): this;
/**
* Translates object along _y_ axis in object space by {@link distance} units.
* @param distance Expects a `Float`
*/
translateY(distance: number): this;
/**
* Translates object along _z_ axis in object space by {@link distance} units.
* @param distance Expects a `Float`
*/
translateZ(distance: number): this;
/**
* Converts the vector from this object's local space to world space.
* @param vector A vector representing a position in this object's local space.
*/
localToWorld(vector: Vector3): Vector3;
/**
* Converts the vector from world space to this object's local space.
* @param vector A vector representing a position in world space.
*/
worldToLocal(vector: Vector3): Vector3;
/**
* Rotates the object to face a point in world space.
* @remarks This method does not support objects having non-uniformly-scaled parent(s).
* @param vector A vector representing a position in world space to look at.
*/
lookAt(vector: Vector3): void;
/**
* Rotates the object to face a point in world space.
* @remarks This method does not support objects having non-uniformly-scaled parent(s).
* @param x Expects a `Float`
* @param y Expects a `Float`
* @param z Expects a `Float`
*/
lookAt(x: number, y: number, z: number): void;
/**
* Adds another {@link Object3D} as child of this {@link Object3D}.
* @remarks An arbitrary number of objects may be added
* Any current parent on an {@link object} passed in here will be removed, since an {@link Object3D} can have at most one parent.
* @see {@link attach}
* @see {@link THREE.Group | Group} for info on manually grouping objects.
* @param object
*/
add(...object: Object3D[]): this;
/**
* Removes a {@link Object3D} as child of this {@link Object3D}.
* @remarks An arbitrary number of objects may be removed.
* @see {@link THREE.Group | Group} for info on manually grouping objects.
* @param object
*/
remove(...object: Object3D[]): this;
/**
* Removes this object from its current parent.
*/
removeFromParent(): this;
/**
* Removes all child objects.
*/
clear(): this;
/**
* Adds a {@link Object3D} as a child of this, while maintaining the object's world transform.
* @remarks Note: This method does not support scene graphs having non-uniformly-scaled nodes(s).
* @see {@link add}
* @param object
*/
attach(object: Object3D): this;
/**
* Searches through an object and its children, starting with the object itself, and returns the first with a matching id.
* @remarks Note that ids are assigned in chronological order: 1, 2, 3, ..., incrementing by one for each new object.
* @see {@link id}
* @param id Unique number of the object instance. Expects a `Integer`
*/
getObjectById(id: number): Object3D | undefined;
/**
* Searches through an object and its children, starting with the object itself, and returns the first with a matching name.
* @remarks Note that for most objects the name is an empty string by default
* You will have to set it manually to make use of this method.
* @param name String to match to the children's Object3D.name property.
*/
getObjectByName(name: string): Object3D | undefined;
/**
* Searches through an object and its children, starting with the object itself,
* and returns the first with a property that matches the value given.
*
* @param name - the property name to search for.
* @param value - value of the given property.
*/
getObjectByProperty(name: string, value: any): Object3D | undefined;
/**
* Searches through an object and its children, starting with the object itself,
* and returns the first with a property that matches the value given.
* @param name The property name to search for.
* @param value Value of the given property.
* @param optionalTarget target to set the result. Otherwise a new Array is instantiated. If set, you must clear
* this array prior to each call (i.e., array.length = 0;).
*/
getObjectsByProperty(name: string, value: any, optionalTarget?: Object3D[]): Object3D[];
/**
* Returns a vector representing the position of the object in world space.
* @param target The result will be copied into this Vector3.
*/
getWorldPosition(target: Vector3): Vector3;
/**
* Returns a quaternion representing the rotation of the object in world space.
* @param target The result will be copied into this Quaternion.
*/
getWorldQuaternion(target: Quaternion): Quaternion;
/**
* Returns a vector of the scaling factors applied to the object for each axis in world space.
* @param target The result will be copied into this Vector3.
*/
getWorldScale(target: Vector3): Vector3;
/**
* Returns a vector representing the direction of object's positive z-axis in world space.
* @param target The result will be copied into this Vector3.
*/
getWorldDirection(target: Vector3): Vector3;
/**
* Abstract (empty) method to get intersections between a casted ray and this object
* @remarks Subclasses such as {@link THREE.Mesh | Mesh}, {@link THREE.Line | Line}, and {@link THREE.Points | Points} implement this method in order to use raycasting.
* @see {@link THREE.Raycaster | Raycaster}
* @param raycaster
* @param intersects
* @defaultValue `() => {}`
*/
raycast(raycaster: Raycaster, intersects: Intersection[]): void;
/**
* Executes the callback on this object and all descendants.
* @remarks Note: Modifying the scene graph inside the callback is discouraged.
* @param callback A function with as first argument an {@link Object3D} object.
*/
traverse(callback: (object: Object3D) => any): void;
/**
* Like traverse, but the callback will only be executed for visible objects
* @remarks Descendants of invisible objects are not traversed.
* Note: Modifying the scene graph inside the callback is discouraged.
* @param callback A function with as first argument an {@link Object3D} object.
*/
traverseVisible(callback: (object: Object3D) => any): void;
/**
* Executes the callback on all ancestors.
* @remarks Note: Modifying the scene graph inside the callback is discouraged.
* @param callback A function with as first argument an {@link Object3D} object.
*/
traverseAncestors(callback: (object: Object3D) => any): void;
/**
* Updates local transform.
*/
updateMatrix(): void;
/**
* Updates the global transform of the object.
* And will update the object descendants if {@link matrixWorldNeedsUpdate | .matrixWorldNeedsUpdate} is set to true or if the {@link force} parameter is set to `true`.
* @param force A boolean that can be used to bypass {@link matrixWorldAutoUpdate | .matrixWorldAutoUpdate}, to recalculate the world matrix of the object and descendants on the current frame.
* Useful if you cannot wait for the renderer to update it on the next frame, assuming {@link matrixWorldAutoUpdate | .matrixWorldAutoUpdate} set to `true`.
*/
updateMatrixWorld(force?: boolean): void;
/**
* An alternative version of {@link Object3D#updateMatrixWorld} with more control over the
* update of ancestor and descendant nodes.
*
* @param {boolean} [updateParents=false] Whether ancestor nodes should be updated or not.
* @param {boolean} [updateChildren=false] Whether descendant nodes should be updated or not.
* @param {boolean} [force=false] - When set to `true`, a recomputation of world matrices is forced even
* when {@link Object3D#matrixWorldNeedsUpdate} is `false`.
*/
updateWorldMatrix(updateParents: boolean, updateChildren: boolean, force?: boolean): void;
/**
* Convert the object to three.js {@link https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 | JSON Object/Scene format}.
* @param meta Object containing metadata such as materials, textures or images for the object.
*/
toJSON(meta?: JSONMeta): Object3DJSON;
/**
* Returns a clone of `this` object and optionally all descendants.
* @param recursive If true, descendants of the object are also cloned. Default `true`
*/
clone(recursive?: boolean): this;
/**
* Copies the given object into this object.
* @remarks Event listeners and user-defined callbacks ({@link .onAfterRender} and {@link .onBeforeRender}) are not copied.
* @param object
* @param recursive If set to `true`, descendants of the object are copied next to the existing ones. If set to
* `false`, descendants are left unchanged. Default is `true`.
*/
copy(object: Object3D, recursive?: boolean): this;
}
declare interface Object3DEventMap {
/**
* Fires when the object has been added to its parent object.
*/
added: {};
/**
* Fires when the object has been removed from its parent object.
*/
removed: {};
/**
* Fires when a new child object has been added.
*/
childadded: { child: Object3D };
/**
* Fires when a new child object has been removed.
*/
childremoved: { child: Object3D };
}
declare interface Object3DJSON {
metadata?: { version: number; type: string; generator: string };
object: Object3DJSONObject;
}
declare interface Object3DJSONObject {
uuid: string;
type: string;
name?: string;
castShadow?: boolean;
receiveShadow?: boolean;
visible?: boolean;
frustumCulled?: boolean;
renderOrder?: number;
static?: boolean;
userData?: Record;
layers: number;
matrix: Matrix4Tuple;
up: Vector3Tuple;
pivot?: Vector3Tuple;
matrixAutoUpdate?: boolean;
material?: string | string[];
children?: string[];
animations?: string[];
}
declare const ObjectSpaceNormalMap: 1;
/** Shim for OffscreenCanvas. */
// eslint-disable-next-line @typescript-eslint/no-empty-interface
declare interface OffscreenCanvas_2 extends EventTarget {}
declare const OneFactor: 201;
declare const OneMinusConstantAlphaFactor: 214;
declare const OneMinusConstantColorFactor: 212;
declare const OneMinusDstAlphaFactor: 207;
declare const OneMinusDstColorFactor: 209;
declare const OneMinusSrcAlphaFactor: 205;
declare const OneMinusSrcColorFactor: 203;
declare interface ParseTrackNameResults {
nodeName: string;
objectName: string;
objectIndex: string;
propertyName: string;
propertyIndex: string;
}
declare interface PathJSON extends CurvePathJSON {
currentPoint: Vector2Tuple;
}
declare const PCFShadowMap: 1;
declare const PCFSoftShadowMap: 2;
/**
* Camera that uses [perspective projection](https://en.wikipedia.org/wiki/Perspective_(graphical)).
*
* This projection mode is designed to mimic the way the human eye sees. It
* is the most common projection mode used for rendering a 3D scene.
*
* ```js
* const camera = new THREE.PerspectiveCamera( 45, width / height, 1, 1000 );
* scene.add( camera );
* ```
*/
declare class PerspectiveCamera extends Camera {
/**
* Constructs a new perspective camera.
*
* @param {number} [fov=50] - The vertical field of view.
* @param {number} [aspect=1] - The aspect ratio.
* @param {number} [near=0.1] - The camera's near plane.
* @param {number} [far=2000] - The camera's far plane.
*/
constructor(fov?: number, aspect?: number, near?: number, far?: number);
/**
* This flag can be used for type testing.
*
* @default true
*/
readonly isPerspectiveCamera: boolean;
/**
* The vertical field of view, from bottom to top of view,
* in degrees.
*
* @default 50
*/
fov: number;
/**
* The zoom factor of the camera.
*
* @default 1
*/
zoom: number;
/**
* The camera's near plane. The valid range is greater than `0`
* and less than the current value of {@link PerspectiveCamera#far}.
*
* Note that, unlike for the {@link OrthographicCamera}, `0` is not a
* valid value for a perspective camera's near plane.
*
* @default 0.1
*/
near: number;
/**
* The camera's far plane. Must be greater than the
* current value of {@link PerspectiveCamera#near}.
*
* @default 2000
*/
far: number;
/**
* Object distance used for stereoscopy and depth-of-field effects. This
* parameter does not influence the projection matrix unless a
* {@link StereoCamera} is being used.
*
* @default 10
*/
focus: number;
/**
* The aspect ratio, usually the canvas width / canvas height.
*
* @default 1
*/
aspect: number;
/**
* Represents the frustum window specification. This property should not be edited
* directly but via {@link PerspectiveCamera#setViewOffset} and {@link PerspectiveCamera#clearViewOffset}.
*
* @default null
*/
view: {
enabled: boolean;
fullWidth: number;
fullHeight: number;
offsetX: number;
offsetY: number;
width: number;
height: number;
} | null;
/**
* Film size used for the larger axis. Default is `35` (millimeters). This
* parameter does not influence the projection matrix unless {@link PerspectiveCamera#filmOffset}
* is set to a nonzero value.
*
* @default 35
*/
filmGauge: number;
/**
* Horizontal off-center offset in the same unit as {@link PerspectiveCamera#filmGauge}.
*
* @default 0
*/
filmOffset: number;
copy(source: PerspectiveCamera, recursive?: boolean): this;
/**
* Sets the FOV by focal length in respect to the current {@link PerspectiveCamera#filmGauge}.
*
* The default film gauge is 35, so that the focal length can be specified for
* a 35mm (full frame) camera.
*
* @param {number} focalLength - Values for focal length and film gauge must have the same unit.
*/
setFocalLength(focalLength: number): void;
/**
* Returns the focal length from the current {@link PerspectiveCamera#fov} and
* {@link PerspectiveCamera#filmGauge}.
*
* @return {number} The computed focal length.
*/
getFocalLength(): number;
/**
* Returns the current vertical field of view angle in degrees considering {@link PerspectiveCamera#zoom}.
*
* @return {number} The effective FOV.
*/
getEffectiveFOV(): number;
/**
* Returns the width of the image on the film. If {@link PerspectiveCamera#aspect} is greater than or
* equal to one (landscape format), the result equals {@link PerspectiveCamera#filmGauge}.
*
* @return {number} The film width.
*/
getFilmWidth(): number;
/**
* Returns the height of the image on the film. If {@link PerspectiveCamera#aspect} is greater than or
* equal to one (landscape format), the result equals {@link PerspectiveCamera#filmGauge}.
*
* @return {number} The film width.
*/
getFilmHeight(): number;
/**
* Computes the 2D bounds of the camera's viewable rectangle at a given distance along the viewing direction.
* Sets `minTarget` and `maxTarget` to the coordinates of the lower-left and upper-right corners of the view rectangle.
*
* @param {number} distance - The viewing distance.
* @param {Vector2} minTarget - The lower-left corner of the view rectangle is written into this vector.
* @param {Vector2} maxTarget - The upper-right corner of the view rectangle is written into this vector.
*/
getViewBounds(distance: number, minTarget: Vector2, maxTarget: Vector2): void;
/**
* Computes the width and height of the camera's viewable rectangle at a given distance along the viewing direction.
*
* @param {number} distance - The viewing distance.
* @param {Vector2} target - The target vector that is used to store result where x is width and y is height.
* @returns {Vector2} The view size.
*/
getViewSize(distance: number, target: Vector2): Vector2;
/**
* Sets an offset in a larger frustum. This is useful for multi-window or
* multi-monitor/multi-machine setups.
*
* For example, if you have 3x2 monitors and each monitor is 1920x1080 and
* the monitors are in grid like this
* ```
* +---+---+---+
* | A | B | C |
* +---+---+---+
* | D | E | F |
* +---+---+---+
* ```
* then for each monitor you would call it like this:
* ```js
* const w = 1920;
* const h = 1080;
* const fullWidth = w * 3;
* const fullHeight = h * 2;
*
* // --A--
* camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );
* // --B--
* camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );
* // --C--
* camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );
* // --D--
* camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );
* // --E--
* camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );
* // --F--
* camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );
* ```
*
* Note there is no reason monitors have to be the same size or in a grid.
*
* @param {number} fullWidth - The full width of multiview setup.
* @param {number} fullHeight - The full height of multiview setup.
* @param {number} x - The horizontal offset of the subcamera.
* @param {number} y - The vertical offset of the subcamera.
* @param {number} width - The width of subcamera.
* @param {number} height - The height of subcamera.
*/
setViewOffset(fullWidth: number, fullHeight: number, x: number, y: number, width: number, height: number): void;
/**
* Removes the view offset from the projection matrix.
*/
clearViewOffset(): void;
/**
* Updates the camera's projection matrix. Must be called after any change of
* camera properties.
*/
updateProjectionMatrix(): void;
toJSON(meta?: JSONMeta): PerspectiveCameraJSON;
}
declare interface PerspectiveCameraJSON extends Object3DJSON {
object: PerspectiveCameraJSONObject;
}
declare interface PerspectiveCameraJSONObject extends Object3DJSONObject {
fov: number;
zoom: number;
near: number;
far: number;
focus: number;
aspect: number;
view?: {
enabled: boolean;
fullWidth: number;
fullHeight: number;
offsetX: number;
offsetY: number;
width: number;
height: number;
};
filmGauge: number;
filmOffset: number;
}
/**
* All Texture Pixel Formats Modes.
* @remarks Note that the texture must have the correct {@link THREE.Texture.type} set, as described in {@link TextureDataType}.
* @see {@link WebGLRenderingContext.texImage2D} for details.
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
*/
declare type PixelFormat =
| typeof AlphaFormat
| typeof RGBFormat
| typeof RGBAFormat
| typeof DepthFormat
| typeof DepthStencilFormat
| typeof RedFormat
| typeof RedIntegerFormat
| typeof RGFormat
| typeof RGIntegerFormat
| typeof RGBIntegerFormat
| typeof RGBAIntegerFormat;
/**
* For use with a texture's {@link THREE.Texture.internalFormat} property, these define how elements of a {@link THREE.Texture}, or texels, are stored on the GPU.
* - `R8` stores the red component on 8 bits.
* - `R8_SNORM` stores the red component on 8 bits. The component is stored as normalized.
* - `R8I` stores the red component on 8 bits. The component is stored as an integer.
* - `R8UI` stores the red component on 8 bits. The component is stored as an unsigned integer.
* - `R16I` stores the red component on 16 bits. The component is stored as an integer.
* - `R16UI` stores the red component on 16 bits. The component is stored as an unsigned integer.
* - `R16F` stores the red component on 16 bits. The component is stored as floating point.
* - `R32I` stores the red component on 32 bits. The component is stored as an integer.
* - `R32UI` stores the red component on 32 bits. The component is stored as an unsigned integer.
* - `R32F` stores the red component on 32 bits. The component is stored as floating point.
* - `RG8` stores the red and green components on 8 bits each.
* - `RG8_SNORM` stores the red and green components on 8 bits each. Every component is stored as normalized.
* - `RG8I` stores the red and green components on 8 bits each. Every component is stored as an integer.
* - `RG8UI` stores the red and green components on 8 bits each. Every component is stored as an unsigned integer.
* - `RG16I` stores the red and green components on 16 bits each. Every component is stored as an integer.
* - `RG16UI` stores the red and green components on 16 bits each. Every component is stored as an unsigned integer.
* - `RG16F` stores the red and green components on 16 bits each. Every component is stored as floating point.
* - `RG32I` stores the red and green components on 32 bits each. Every component is stored as an integer.
* - `RG32UI` stores the red and green components on 32 bits. Every component is stored as an unsigned integer.
* - `RG32F` stores the red and green components on 32 bits. Every component is stored as floating point.
* - `RGB8` stores the red, green, and blue components on 8 bits each. RGB8_SNORM` stores the red, green, and blue components on 8 bits each. Every component is stored as normalized.
* - `RGB8I` stores the red, green, and blue components on 8 bits each. Every component is stored as an integer.
* - `RGB8UI` stores the red, green, and blue components on 8 bits each. Every component is stored as an unsigned integer.
* - `RGB16I` stores the red, green, and blue components on 16 bits each. Every component is stored as an integer.
* - `RGB16UI` stores the red, green, and blue components on 16 bits each. Every component is stored as an unsigned integer.
* - `RGB16F` stores the red, green, and blue components on 16 bits each. Every component is stored as floating point
* - `RGB32I` stores the red, green, and blue components on 32 bits each. Every component is stored as an integer.
* - `RGB32UI` stores the red, green, and blue components on 32 bits each. Every component is stored as an unsigned integer.
* - `RGB32F` stores the red, green, and blue components on 32 bits each. Every component is stored as floating point
* - `R11F_G11F_B10F` stores the red, green, and blue components respectively on 11 bits, 11 bits, and 10bits. Every component is stored as floating point.
* - `RGB565` stores the red, green, and blue components respectively on 5 bits, 6 bits, and 5 bits.
* - `RGB9_E5` stores the red, green, and blue components on 9 bits each.
* - `RGBA8` stores the red, green, blue, and alpha components on 8 bits each.
* - `RGBA8_SNORM` stores the red, green, blue, and alpha components on 8 bits. Every component is stored as normalized.
* - `RGBA8I` stores the red, green, blue, and alpha components on 8 bits each. Every component is stored as an integer.
* - `RGBA8UI` stores the red, green, blue, and alpha components on 8 bits. Every component is stored as an unsigned integer.
* - `RGBA16I` stores the red, green, blue, and alpha components on 16 bits. Every component is stored as an integer.
* - `RGBA16UI` stores the red, green, blue, and alpha components on 16 bits. Every component is stored as an unsigned integer.
* - `RGBA16F` stores the red, green, blue, and alpha components on 16 bits. Every component is stored as floating point.
* - `RGBA32I` stores the red, green, blue, and alpha components on 32 bits. Every component is stored as an integer.
* - `RGBA32UI` stores the red, green, blue, and alpha components on 32 bits. Every component is stored as an unsigned integer.
* - `RGBA32F` stores the red, green, blue, and alpha components on 32 bits. Every component is stored as floating point.
* - `RGB5_A1` stores the red, green, blue, and alpha components respectively on 5 bits, 5 bits, 5 bits, and 1 bit.
* - `RGB10_A2` stores the red, green, blue, and alpha components respectively on 10 bits, 10 bits, 10 bits and 2 bits.
* - `RGB10_A2UI` stores the red, green, blue, and alpha components respectively on 10 bits, 10 bits, 10 bits and 2 bits. Every component is stored as an unsigned integer.
* - `SRGB8` stores the red, green, and blue components on 8 bits each.
* - `SRGB8_ALPHA8` stores the red, green, blue, and alpha components on 8 bits each.
* - `DEPTH_COMPONENT16` stores the depth component on 16bits.
* - `DEPTH_COMPONENT24` stores the depth component on 24bits.
* - `DEPTH_COMPONENT32F` stores the depth component on 32bits. The component is stored as floating point.
* - `DEPTH24_STENCIL8` stores the depth, and stencil components respectively on 24 bits and 8 bits. The stencil component is stored as an unsigned integer.
* - `DEPTH32F_STENCIL8` stores the depth, and stencil components respectively on 32 bits and 8 bits. The depth component is stored as floating point, and the stencil component as an unsigned integer.
* @remark Note that the texture must have the correct {@link THREE.Texture.type} set, as well as the correct {@link THREE.Texture.format}.
* @see {@link WebGLRenderingContext.texImage2D} and {@link WebGLRenderingContext.texImage3D} for more details regarding the possible combination
* of {@link THREE.Texture.format}, {@link THREE.Texture.internalFormat}, and {@link THREE.Texture.type}.
* @see {@link https://registry.khronos.org/webgl/specs/latest/2.0/ | WebGL2 Specification} and
* {@link https://registry.khronos.org/OpenGL/specs/es/3.0/es_spec_3.0.pdf | OpenGL ES 3.0 Specification} For more in-depth information regarding internal formats.
*/
declare type PixelFormatGPU =
| "ALPHA"
| "RGB"
| "RGBA"
| "LUMINANCE"
| "LUMINANCE_ALPHA"
| "RED_INTEGER"
| "R8"
| "R8_SNORM"
| "R8I"
| "R8UI"
| "R16I"
| "R16UI"
| "R16F"
| "R32I"
| "R32UI"
| "R32F"
| "RG8"
| "RG8_SNORM"
| "RG8I"
| "RG8UI"
| "RG16I"
| "RG16UI"
| "RG16F"
| "RG32I"
| "RG32UI"
| "RG32F"
| "RGB565"
| "RGB8"
| "RGB8_SNORM"
| "RGB8I"
| "RGB8UI"
| "RGB16I"
| "RGB16UI"
| "RGB16F"
| "RGB32I"
| "RGB32UI"
| "RGB32F"
| "RGB9_E5"
| "SRGB8"
| "R11F_G11F_B10F"
| "RGBA4"
| "RGBA8"
| "RGBA8_SNORM"
| "RGBA8I"
| "RGBA8UI"
| "RGBA16I"
| "RGBA16UI"
| "RGBA16F"
| "RGBA32I"
| "RGBA32UI"
| "RGBA32F"
| "RGB5_A1"
| "RGB10_A2"
| "RGB10_A2UI"
| "SRGB8_ALPHA8"
| "SRGB8"
| "DEPTH_COMPONENT16"
| "DEPTH_COMPONENT24"
| "DEPTH_COMPONENT32F"
| "DEPTH24_STENCIL8"
| "DEPTH32F_STENCIL8";
declare class Plane {
constructor(normal?: Vector3, constant?: number);
/**
* @default new THREE.Vector3( 1, 0, 0 )
*/
normal: Vector3;
/**
* @default 0
*/
constant: number;
readonly isPlane: true;
set(normal: Vector3, constant: number): Plane;
setComponents(x: number, y: number, z: number, w: number): Plane;
setFromNormalAndCoplanarPoint(normal: Vector3, point: Vector3): Plane;
setFromCoplanarPoints(a: Vector3, b: Vector3, c: Vector3): Plane;
clone(): this;
copy(plane: Plane): this;
normalize(): Plane;
negate(): Plane;
distanceToPoint(point: Vector3): number;
distanceToSphere(sphere: Sphere): number;
projectPoint(point: Vector3, target: Vector3): Vector3;
intersectLine(line: Line3, target: Vector3, clampToLine?: boolean): Vector3 | null;
intersectsLine(line: Line3): boolean;
intersectsBox(box: Box3): boolean;
intersectsSphere(sphere: Sphere): boolean;
coplanarPoint(target: Vector3): Vector3;
applyMatrix4(matrix: Matrix4, optionalNormalMatrix?: Matrix3): Plane;
translate(offset: Vector3): Plane;
equals(plane: Plane): boolean;
/**
* @deprecated Use {@link Plane#intersectsLine .intersectsLine()} instead.
*/
isIntersectionLine(l: any): any;
}
/**
* This holds a reference to a real property in the scene graph; used internally.
*/
declare class PropertyBinding {
/**
* Factory method for creating a property binding from the given parameters.
*
* @static
* @param {Object} root - The root node.
* @param {string} path - The path.
* @param {?Object} [parsedPath] - The parsed path.
* @return {PropertyBinding|Composite} The created property binding or composite.
*/
static create(root: object, path: string, parsedPath?: object | null): PropertyBinding | Composite;
/**
* Replaces spaces with underscores and removes unsupported characters from
* node names, to ensure compatibility with parseTrackName().
*
* @param {string} name - Node name to be sanitized.
* @return {string} The sanitized node name.
*/
static sanitizeNodeName(name: string): string;
/**
* Parses the given track name (an object path to an animated property) and
* returns an object with information about the path. Matches strings in the following forms:
*
* - nodeName.property
* - nodeName.property[accessor]
* - nodeName.material.property[accessor]
* - uuid.property[accessor]
* - uuid.objectName[objectIndex].propertyName[propertyIndex]
* - parentName/nodeName.property
* - parentName/parentName/nodeName.property[index]
* - .bone[Armature.DEF_cog].position
* - scene:helium_balloon_model:helium_balloon_model.position
*
* @static
* @param {string} trackName - The track name to parse.
* @return {Object} The parsed track name as an object.
*/
static parseTrackName(trackName: string): ParseTrackNameResults;
/**
* Searches for a node in the hierarchy of the given root object by the given
* node name.
*
* @static
* @param {Object} root - The root object.
* @param {string|number} nodeName - The name of the node.
* @return {?Object} The found node. Returns `null` if no object was found.
*/
static findNode(root: object, nodeName: string | number): object | null;
/**
* Constructs a new property binding.
*
* @param {Object} rootNode - The root node.
* @param {string} path - The path.
* @param {?Object} [parsedPath] - The parsed path.
*/
constructor(rootNode: Object3D | Skeleton, path: string, parsedPath?: object | null);
/**
* The object path to the animated property.
*/
path: string;
/**
* An object holding information about the path.
*/
parsedPath: object;
/**
* The object owns the animated property.
*/
node: object | null;
/**
* The root node.
*/
rootNode: Object3D | Skeleton;
/**
* Creates a getter / setter pair for the property tracked by this binding.
*/
bind(): void;
/**
* Unbinds the property.
*/
unbind(): void;
}
declare namespace PropertyBinding {
export { Composite };
}
/**
* Buffered scene graph property that allows weighted accumulation; used internally.
*/
declare class PropertyMixer {
/**
* Constructs a new property mixer.
*
* @param {PropertyBinding} binding - The property binding.
* @param {string} typeName - The keyframe track type name.
* @param {number} valueSize - The keyframe track value size.
*/
constructor(binding: PropertyBinding, typeName: string, valueSize: number);
/**
* The property binding.
*/
binding: PropertyBinding;
/**
* The keyframe track value size.
*/
valueSize: number;
buffer: Float64Array | unknown[];
/**
* Accumulated weight of the property binding.
*
* @default 0
*/
cumulativeWeight: number;
/**
* Accumulated additive weight of the property binding.
*
* @default 0
*/
cumulativeWeightAdditive: number;
/**
* Number of active keyframe tracks currently using this property binding.
*
* @default 0
*/
useCount: number;
/**
* Number of keyframe tracks referencing this property binding.
*
* @default 0
*/
referenceCount: number;
/**
* Accumulates data in the `incoming` region into `accu`.
*
* @param {number} accuIndex - The accumulation index.
* @param {number} weight - The weight.
*/
accumulate(accuIndex: number, weight: number): void;
/**
* Accumulates data in the `incoming` region into `add`.
*
* @param {number} weight - The weight.
*/
accumulateAdditive(weight: number): void;
/**
* Applies the state of `accu` to the binding when accus differ.
*
* @param {number} accuIndex - The accumulation index.
*/
apply(accuIndex: number): void;
/**
* Remembers the state of the bound property and copy it to both accus.
*/
saveOriginalState(): void;
/**
* Applies the state previously taken via {@link PropertyMixer#saveOriginalState} to the binding.
*/
restoreOriginalState(): void;
}
/**
* Implementation of a quaternion. This is used for rotating things without incurring in the dreaded gimbal lock issue, amongst other advantages.
*
* @example
* const quaternion = new THREE.Quaternion();
* quaternion.setFromAxisAngle( new THREE.Vector3( 0, 1, 0 ), Math.PI / 2 );
* const vector = new THREE.Vector3( 1, 0, 0 );
* vector.applyQuaternion( quaternion );
*/
declare class Quaternion {
/**
* @param x x coordinate
* @param y y coordinate
* @param z z coordinate
* @param w w coordinate
*/
constructor(x?: number, y?: number, z?: number, w?: number);
/**
* @default 0
*/
x: number;
/**
* @default 0
*/
y: number;
/**
* @default 0
*/
z: number;
/**
* @default 1
*/
w: number;
readonly isQuaternion: true;
/**
* Sets values of this quaternion.
*/
set(x: number, y: number, z: number, w: number): this;
/**
* Clones this quaternion.
*/
clone(): this;
/**
* Copies values of q to this quaternion.
*/
copy(q: QuaternionLike): this;
/**
* Sets this quaternion from rotation specified by Euler angles.
*/
setFromEuler(euler: Euler, update?: boolean): this;
/**
* Sets this quaternion from rotation specified by axis and angle.
* Adapted from http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm.
* Axis have to be normalized, angle is in radians.
*/
setFromAxisAngle(axis: Vector3Like, angle: number): this;
/**
* Sets this quaternion from rotation component of m. Adapted from http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm.
*/
setFromRotationMatrix(m: Matrix4): this;
setFromUnitVectors(vFrom: Vector3, vTo: Vector3Like): this;
angleTo(q: Quaternion): number;
rotateTowards(q: Quaternion, step: number): this;
identity(): this;
/**
* Inverts this quaternion.
*/
invert(): this;
conjugate(): this;
dot(v: Quaternion): number;
lengthSq(): number;
/**
* Computes length of this quaternion.
*/
length(): number;
/**
* Normalizes this quaternion.
*/
normalize(): this;
/**
* Multiplies this quaternion by b.
*/
multiply(q: Quaternion): this;
premultiply(q: Quaternion): this;
/**
* Sets this quaternion to a x b
* Adapted from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm.
*/
multiplyQuaternions(a: Quaternion, b: Quaternion): this;
slerp(qb: Quaternion, t: number): this;
slerpQuaternions(qa: Quaternion, qb: Quaternion, t: number): this;
equals(v: Quaternion): boolean;
/**
* Sets this quaternion's x, y, z and w value from the provided array or array-like.
* @param array the source array or array-like.
* @param offset (optional) offset into the array. Default is 0.
*/
fromArray(array: number[] | ArrayLike, offset?: number): this;
/**
* Returns an array [x, y, z, w], or copies x, y, z and w into the provided array.
* @param array (optional) array to store the quaternion to. If this is not provided, a new array will be created.
* @param offset (optional) optional offset into the array.
* @return The created or provided array.
*/
toArray(array?: number[], offset?: number): number[];
toArray(array?: QuaternionTuple, offset?: 0): QuaternionTuple;
/**
* Copies x, y, z and w into the provided array-like.
* @param array array-like to store the quaternion to.
* @param offset (optional) optional offset into the array.
* @return The provided array-like.
*/
toArray(array: ArrayLike, offset?: number): ArrayLike;
/**
* This method defines the serialization result of Quaternion.
* @return The numerical elements of this quaternion in an array of format [x, y, z, w].
*/
toJSON(): [number, number, number, number];
/**
* Sets x, y, z, w properties of this quaternion from the attribute.
* @param attribute the source attribute.
* @param index index in the attribute.
*/
fromBufferAttribute(attribute: BufferAttribute | InterleavedBufferAttribute, index: number): this;
_onChange(callback: () => void): this;
_onChangeCallback: () => void;
static slerpFlat(
dst: number[],
dstOffset: number,
src0: number[],
srcOffset: number,
src1: number[],
stcOffset1: number,
t: number,
): void;
static multiplyQuaternionsFlat(
dst: number[],
dstOffset: number,
src0: number[],
srcOffset: number,
src1: number[],
stcOffset1: number,
): number[];
random(): this;
[Symbol.iterator](): Generator;
}
declare interface QuaternionLike {
readonly x: number;
readonly y: number;
readonly z: number;
readonly w: number;
}
declare type QuaternionTuple = [x: number, y: number, z: number, w: number];
declare const R11_EAC_Format: 37488;
declare class Ray {
constructor(origin?: Vector3, direction?: Vector3);
/**
* @default new THREE.Vector3()
*/
origin: Vector3;
/**
* @default new THREE.Vector3( 0, 0, - 1 )
*/
direction: Vector3;
set(origin: Vector3, direction: Vector3): Ray;
clone(): this;
copy(ray: Ray): this;
at(t: number, target: Vector3): Vector3;
lookAt(v: Vector3): Ray;
recast(t: number): Ray;
closestPointToPoint(point: Vector3, target: Vector3): Vector3;
distanceToPoint(point: Vector3): number;
distanceSqToPoint(point: Vector3): number;
distanceSqToSegment(
v0: Vector3,
v1: Vector3,
optionalPointOnRay?: Vector3,
optionalPointOnSegment?: Vector3,
): number;
intersectSphere(sphere: Sphere, target: Vector3): Vector3 | null;
intersectsSphere(sphere: Sphere): boolean;
distanceToPlane(plane: Plane): number;
intersectPlane(plane: Plane, target: Vector3): Vector3 | null;
intersectsPlane(plane: Plane): boolean;
intersectBox(box: Box3, target: Vector3): Vector3 | null;
intersectsBox(box: Box3): boolean;
intersectTriangle(a: Vector3, b: Vector3, c: Vector3, backfaceCulling: boolean, target: Vector3): Vector3 | null;
applyMatrix4(matrix4: Matrix4): Ray;
equals(ray: Ray): boolean;
/**
* @deprecated Use {@link Ray#intersectsBox .intersectsBox()} instead.
*/
isIntersectionBox(b: any): any;
/**
* @deprecated Use {@link Ray#intersectsPlane .intersectsPlane()} instead.
*/
isIntersectionPlane(p: any): any;
/**
* @deprecated Use {@link Ray#intersectsSphere .intersectsSphere()} instead.
*/
isIntersectionSphere(s: any): any;
}
/**
* This class is designed to assist with {@link https://en.wikipedia.org/wiki/Ray_casting | raycasting}
* @remarks
* Raycasting is used for mouse picking (working out what objects in the 3d space the mouse is over) amongst other things.
* @example
* ```typescript
* const raycaster = new THREE.Raycaster();
* const pointer = new THREE.Vector2();
*
* function onPointerMove(event) {
* // calculate pointer position in normalized device coordinates (-1 to +1) for both components
* pointer.x = (event.clientX / window.innerWidth) * 2 - 1;
* pointer.y = -(event.clientY / window.innerHeight) * 2 + 1;
* }
*
* function render() {
* // update the picking ray with the camera and pointer position
* raycaster.setFromCamera(pointer, camera);
* // calculate objects intersecting the picking ray
* const intersects = raycaster.intersectObjects(scene.children);
* for (let i = 0; i & lt; intersects.length; i++) {
* intersects[i].object.material.color.set(0xff0000);
* }
* renderer.render(scene, camera);
* }
* window.addEventListener('pointermove', onPointerMove);
* window.requestAnimationFrame(render);
* ```
* @see Example: {@link https://threejs.org/examples/#webgl_interactive_cubes | Raycasting to a Mesh}
* @see Example: {@link https://threejs.org/examples/#webgl_interactive_cubes_ortho | Raycasting to a Mesh in using an OrthographicCamera}
* @see Example: {@link https://threejs.org/examples/#webgl_interactive_buffergeometry | Raycasting to a Mesh with BufferGeometry}
* @see Example: {@link https://threejs.org/examples/#webgl_instancing_raycast | Raycasting to a InstancedMesh}
* @see Example: {@link https://threejs.org/examples/#webgl_interactive_lines | Raycasting to a Line}
* @see Example: {@link https://threejs.org/examples/#webgl_interactive_raycasting_points | Raycasting to Points}
* @see Example: {@link https://threejs.org/examples/#webgl_geometry_terrain_raycast | Terrain raycasting}
* @see Example: {@link https://threejs.org/examples/#webgl_interactive_voxelpainter | Raycasting to paint voxels}
* @see Example: {@link https://threejs.org/examples/#webgl_raycaster_texture | Raycast to a Texture}
* @see {@link https://threejs.org/docs/index.html#api/en/core/Raycaster | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/core/Raycaster.js | Source}
*/
declare class Raycaster {
/**
* This creates a new {@link Raycaster} object.
* @param origin The origin vector where the ray casts from. Default `new Vector3()`
* @param direction The direction vector that gives direction to the ray. Should be normalized. Default `new Vector3(0, 0, -1)`
* @param near All results returned are further away than near. Near can't be negative. Expects a `Float`. Default `0`
* @param far All results returned are closer than far. Far can't be lower than near. Expects a `Float`. Default `Infinity`
*/
constructor(origin?: Vector3, direction?: Vector3, near?: number, far?: number);
/**
* The {@link THREE.RaycasterRay | Ray} used for the raycasting.
*/
ray: Ray;
/**
* The near factor of the raycaster. This value indicates which objects can be discarded based on the distance.
* This value shouldn't be negative and should be smaller than the far property.
* @remarks Expects a `Float`
* @defaultValue `0`
*/
near: number;
/**
* The far factor of the raycaster. This value indicates which objects can be discarded based on the distance.
* This value shouldn't be negative and should be larger than the near property.
* @remarks Expects a `Float`
* @defaultValue `Infinity`
*/
far: number;
/**
* The camera to use when raycasting against view-dependent objects such as billboarded objects like {@link THREE.Sprites | Sprites}.
* This field can be set manually or is set when calling {@link setFromCamera}.
* @defaultValue `null`
*/
camera: Camera;
/**
* Used by {@link Raycaster} to selectively ignore 3D objects when performing intersection tests.
* The following code example ensures that only 3D objects on layer `1` will be honored by the instance of Raycaster.
* ```
* raycaster.layers.set( 1 );
* object.layers.enable( 1 );
* ```
* @defaultValue `new THREE.Layers()` - See {@link THREE.Layers | Layers}.
*/
layers: Layers;
/**
* An data object where threshold is the precision of the {@link Raycaster} when intersecting objects, in world units.
* @defaultValue `{ Mesh: {}, Line: { threshold: 1 }, LOD: {}, Points: { threshold: 1 }, Sprite: {} }`
*/
params: RaycasterParameters;
/**
* Updates the ray with a new origin and direction
* @remarks
* Please note that this method only copies the values from the arguments.
* @param origin The origin vector where the ray casts from.
* @param direction The normalized direction vector that gives direction to the ray.
*/
set(origin: Vector3, direction: Vector3): void;
/**
* Updates the ray with a new origin and direction.
* @param coords 2D coordinates of the mouse, in normalized device coordinates (NDC)---X and Y components should be between -1 and 1.
* @param camera camera from which the ray should originate
*/
setFromCamera(coords: Vector2, camera: Camera): void;
/**
* Updates the ray with a new origin and direction.
* @param controller The controller to copy the position and direction from.
*/
setFromXRController(controller: XRTargetRaySpace): this;
/**
* Checks all intersection between the ray and the object with or without the descendants
* @remarks Intersections are returned sorted by distance, closest first
* @remarks {@link Raycaster} delegates to the {@link Object3D.raycast | raycast} method of the passed object, when evaluating whether the ray intersects the object or not
* This allows {@link THREE.Mesh | meshes} to respond differently to ray casting than {@link THREE.Line | lines} and {@link THREE.Points | pointclouds}.
* **Note** that for meshes, faces must be pointed towards the origin of the {@link Raycaster.ray | ray} in order to be detected;
* intersections of the ray passing through the back of a face will not be detected
* To raycast against both faces of an object, you'll want to set the {@link Mesh.material | material}'s {@link Material.side | side} property to `THREE.DoubleSide`.
* @see {@link intersectObjects | .intersectObjects()}.
* @param object The object to check for intersection with the ray.
* @param recursive If true, it also checks all descendants. Otherwise it only checks intersection with the object. Default `true`
* @param optionalTarget Target to set the result. Otherwise a new {@link Array | Array} is instantiated.
* If set, you must clear this array prior to each call (i.e., array.length = 0;). Default `[]`
* @returns An array of intersections is returned.
*/
intersectObject(
object: Object3D,
recursive?: boolean,
optionalTarget?: Array>,
): Array>;
/**
* Checks all intersection between the ray and the objects with or without the descendants
* @remarks Intersections are returned sorted by distance, closest first
* @remarks Intersections are of the same form as those returned by {@link intersectObject | .intersectObject()}.
* @remarks {@link Raycaster} delegates to the {@link Object3D.raycast | raycast} method of the passed object, when evaluating whether the ray intersects the object or not
* This allows {@link THREE.Mesh | meshes} to respond differently to ray casting than {@link THREE.Line | lines} and {@link THREE.Points | pointclouds}.
* **Note** that for meshes, faces must be pointed towards the origin of the {@link Raycaster.ray | ray} in order to be detected;
* intersections of the ray passing through the back of a face will not be detected
* To raycast against both faces of an object, you'll want to set the {@link Mesh.material | material}'s {@link Material.side | side} property to `THREE.DoubleSide`.
* @see {@link intersectObject | .intersectObject()}.
* @param objects The objects to check for intersection with the ray.
* @param recursive If true, it also checks all descendants of the objects. Otherwise it only checks intersection with the objects. Default `true`
* @param optionalTarget Target to set the result. Otherwise a new {@link Array | Array} is instantiated.
* If set, you must clear this array prior to each call (i.e., array.length = 0;). Default `[]`
* @returns An array of intersections is returned.
*/
intersectObjects(
objects: Object3D[],
recursive?: boolean,
optionalTarget?: Array>,
): Array>;
}
declare interface RaycasterParameters {
Mesh: any;
Line: { threshold: number };
Line2?: { threshold: number };
LOD: any;
Points: { threshold: number };
Sprite: any;
}
declare const RED_GREEN_RGTC2_Format: 36285;
declare const RED_RGTC1_Format: 36283;
/**
* {@link RedFormat} discards the green and blue components and reads just the red component.
*/
declare const RedFormat: 1028;
/**
* {@link RedIntegerFormat} discards the green and blue components and reads just the red component.
* The texels are read as integers instead of floating point.
*/
declare const RedIntegerFormat: 1029;
declare const ReinhardToneMapping: 2;
declare interface RenderItem {
id: number;
object: Object3D;
geometry: BufferGeometry | null;
material: Material;
materialVariant: number;
groupOrder: number;
renderOrder: number;
z: number;
group: Group | null;
}
declare class RenderTarget<
TTexture extends Texture | Texture[] = Texture,
TEventMap extends RenderTargetEventMap = RenderTargetEventMap,
> extends EventDispatcher {
readonly isRenderTarget: true;
width: number;
height: number;
depth: number;
scissor: Vector4;
/**
* @default false
*/
scissorTest: boolean;
viewport: Vector4;
textures: TTexture[];
/**
* @default true
*/
depthBuffer: boolean;
/**
* @default false
*/
stencilBuffer: boolean;
/**
* Defines whether the depth buffer should be resolved when rendering into a multisampled render target.
* @default true
*/
resolveDepthBuffer: boolean;
/**
* Defines whether the stencil buffer should be resolved when rendering into a multisampled render target.
* This property has no effect when {@link .resolveDepthBuffer} is set to `false`.
* @default true
*/
resolveStencilBuffer: boolean;
/**
* Defines the count of MSAA samples. Can only be used with WebGL 2. Default is **0**.
* @default 0
*/
samples: number;
/**
* Whether to this target is used in multiview rendering.
*
* @default false
*/
multiview: boolean;
/**
* Whether to create the depth texture as an array texture for per-layer depth testing.
* This is separate from multiview so layered render targets can use array depth without
* the multiview extension.
*
* @type {boolean}
* @default false
*/
useArrayDepthTexture: boolean;
constructor(width?: number, height?: number, options?: RenderTargetOptions);
get texture(): TTexture;
set texture(value: TTexture);
set depthTexture(current: DepthTexture | null);
get depthTexture(): DepthTexture | null;
setSize(width: number, height: number, depth?: number): void;
clone(): this;
copy(source: RenderTarget): this;
dispose(): void;
}
declare interface RenderTargetEventMap {
dispose: {};
}
declare interface RenderTargetOptions extends TextureParameters {
depthBuffer?: boolean | undefined; // true
stencilBuffer?: boolean | undefined; // false
resolveDepthBuffer?: boolean | undefined; // true
resolveStencilBuffer?: boolean | undefined; // true
depthTexture?: DepthTexture | null | undefined; // null
/**
* Defines the count of MSAA samples. Can only be used with WebGL 2. Default is **0**.
* @default 0
*/
samples?: number | undefined;
count?: number | undefined;
depth?: number | undefined;
multiview?: boolean | undefined;
useArrayDepthTexture?: boolean | undefined;
}
/** With {@link RepeatWrapping} the texture will simply repeat to infinity. */
declare const RepeatWrapping: 1000;
declare const ReplaceStencilOp: 7681;
export declare function resetVrmCanvasCamera(instance?: VrmCanvasExposed): void;
declare const ReverseSubtractEquation: 102;
declare const RG11_EAC_Format: 37490;
declare interface RGB {
r: number;
g: number;
b: number;
}
declare const RGB_BPTC_SIGNED_Format = 36494;
declare const RGB_BPTC_UNSIGNED_Format = 36495;
/**
* @remarks Require support for the _WEBGL_compressed_texture_etc1_ (ETC1) or _WEBGL_compressed_texture_etc_ (ETC2) WebGL extension.
*/
declare const RGB_ETC1_Format: 36196;
/**
* @remarks Require support for the _WEBGL_compressed_texture_etc1_ (ETC1) or _WEBGL_compressed_texture_etc_ (ETC2) WebGL extension.
*/
declare const RGB_ETC2_Format: 37492;
/**
* RGB compression in 2-bit mode. One block for each 8×4 pixels.
* @remarks Require support for the _WEBGL_compressed_texture_pvrtc_ WebGL extension.
*/
declare const RGB_PVRTC_2BPPV1_Format: 35841;
/**
* RGB compression in 4-bit mode. One block for each 4×4 pixels.
* @remarks Require support for the _WEBGL_compressed_texture_pvrtc_ WebGL extension.
*/
declare const RGB_PVRTC_4BPPV1_Format: 35840;
/**
* A DXT1-compressed image in an RGB image format.
* @remarks Require support for the _WEBGL_compressed_texture_s3tc_ WebGL extension.
*/
declare const RGB_S3TC_DXT1_Format: 33776;
/**
* @remarks Require support for the _WEBGL_compressed_texture_astc_ WebGL extension.
*/
declare const RGBA_ASTC_10x10_Format: 37819;
/**
* @remarks Require support for the _WEBGL_compressed_texture_astc_ WebGL extension.
*/
declare const RGBA_ASTC_10x5_Format: 37816;
/**
* @remarks Require support for the _WEBGL_compressed_texture_astc_ WebGL extension.
*/
declare const RGBA_ASTC_10x6_Format: 37817;
/**
* @remarks Require support for the _WEBGL_compressed_texture_astc_ WebGL extension.
*/
declare const RGBA_ASTC_10x8_Format: 37818;
/**
* @remarks Require support for the _WEBGL_compressed_texture_astc_ WebGL extension.
*/
declare const RGBA_ASTC_12x10_Format: 37820;
/**
* @remarks Require support for the _WEBGL_compressed_texture_astc_ WebGL extension.
*/
declare const RGBA_ASTC_12x12_Format: 37821;
/**
* @remarks Require support for the _WEBGL_compressed_texture_astc_ WebGL extension.
*/
declare const RGBA_ASTC_4x4_Format: 37808;
/**
* @remarks Require support for the _WEBGL_compressed_texture_astc_ WebGL extension.
*/
declare const RGBA_ASTC_5x4_Format: 37809;
/**
* @remarks Require support for the _WEBGL_compressed_texture_astc_ WebGL extension.
*/
declare const RGBA_ASTC_5x5_Format: 37810;
/**
* @remarks Require support for the _WEBGL_compressed_texture_astc_ WebGL extension.
*/
declare const RGBA_ASTC_6x5_Format: 37811;
/**
* @remarks Require support for the _WEBGL_compressed_texture_astc_ WebGL extension.
*/
declare const RGBA_ASTC_6x6_Format: 37812;
/**
* @remarks Require support for the _WEBGL_compressed_texture_astc_ WebGL extension.
*/
declare const RGBA_ASTC_8x5_Format: 37813;
/**
* @remarks Require support for the _WEBGL_compressed_texture_astc_ WebGL extension.
*/
declare const RGBA_ASTC_8x6_Format: 37814;
/**
* @remarks Require support for the _WEBGL_compressed_texture_astc_ WebGL extension.
*/
declare const RGBA_ASTC_8x8_Format: 37815;
/**
* @remarks Require support for the _EXT_texture_compression_bptc_ WebGL extension.
*/
declare const RGBA_BPTC_Format: 36492;
/**
* @remarks Require support for the _WEBGL_compressed_texture_etc1_ (ETC1) or _WEBGL_compressed_texture_etc_ (ETC2) WebGL extension.
*/
declare const RGBA_ETC2_EAC_Format: 37496;
/**
* RGBA compression in 2-bit mode. One block for each 8×4 pixels.
* @remarks Require support for the _WEBGL_compressed_texture_pvrtc_ WebGL extension.
*/
declare const RGBA_PVRTC_2BPPV1_Format: 35843;
/**
* RGBA compression in 4-bit mode. One block for each 4×4 pixels.
* @remarks Require support for the _WEBGL_compressed_texture_pvrtc_ WebGL extension.
*/
declare const RGBA_PVRTC_4BPPV1_Format: 35842;
/**
* A DXT1-compressed image in an RGB image format with a simple on/off alpha value.
* @remarks Require support for the _WEBGL_compressed_texture_s3tc_ WebGL extension.
*/
declare const RGBA_S3TC_DXT1_Format: 33777;
/**
* A DXT3-compressed image in an RGBA image format. Compared to a 32-bit RGBA texture, it offers 4:1 compression.
* @remarks Require support for the _WEBGL_compressed_texture_s3tc_ WebGL extension.
*/
declare const RGBA_S3TC_DXT3_Format: 33778;
/**
* A DXT5-compressed image in an RGBA image format. It also provides a 4:1 compression, but differs from the DXT3 compression in how the alpha compression is done.
* @remarks Require support for the _WEBGL_compressed_texture_s3tc_ WebGL extension.
*/
declare const RGBA_S3TC_DXT5_Format: 33779;
declare const RGBADepthPacking: 3201;
/** {@link RGBAFormat} is the default and reads the red, green, blue and alpha components. */
declare const RGBAFormat: 1023;
/**
* {@link RGBAIntegerFormat} reads the red, green, blue and alpha component
* @remarks This is the default for {@link THREE.Texture}.
*/
declare const RGBAIntegerFormat: 1033;
declare const RGBDepthPacking: 3202;
declare const RGBFormat: 1022;
/**
* {@link RGBIntegerFormat} discards the alpha components and reads the red, green, and blue components.
*/
declare const RGBIntegerFormat: 1032;
declare const RGDepthPacking: 3203;
/**
* {@link RGFormat} discards the alpha, and blue components and reads the red, and green components.
*/
declare const RGFormat: 1030;
/**
* {@link RGIntegerFormat} discards the alpha, and blue components and reads the red, and green components.
* The texels are read as integers instead of floating point.
*/
declare const RGIntegerFormat: 1031;
/**
* Scenes allow you to set up what is to be rendered and where by three.js.
* This is where you place 3D objects like meshes, lines or lights.
*/
declare class Scene extends Object3D {
/**
* This flag can be used for type testing.
*
* @default true
*/
readonly isScene: boolean;
/**
* Defines the background of the scene. Valid inputs are:
*
* - A color for defining a uniform colored background.
* - A texture for defining a (flat) textured background.
* - Cube textures or equirectangular textures for defining a skybox.
*
* @default null
*/
background: (Color | Texture) | null;
/**
* Sets the environment map for all physical materials in the scene. However,
* it's not possible to overwrite an existing texture assigned to the `envMap`
* material property.
*
* @default null
*/
environment: Texture | null;
/**
* A fog instance defining the type of fog that affects everything
* rendered in the scene.
*
* @default null
*/
fog: (Fog | FogExp2) | null;
/**
* Sets the blurriness of the background. Only influences environment maps
* assigned to {@link Scene#background}. Valid input is a float between `0`
* and `1`.
*
* @default 0
*/
backgroundBlurriness: number;
/**
* Attenuates the color of the background. Only applies to background textures.
*
* @default 1
*/
backgroundIntensity: number;
/**
* The rotation of the background in radians. Only influences environment maps
* assigned to {@link Scene#background}.
*
* @default (0,0,0)
*/
backgroundRotation: Euler;
/**
* Attenuates the color of the environment. Only influences environment maps
* assigned to {@link Scene#environment}.
*
* @default 1
*/
environmentIntensity: number;
/**
* The rotation of the environment map in radians. Only influences physical materials
* in the scene when {@link Scene#environment} is used.
*
* @default (0,0,0)
*/
environmentRotation: Euler;
/**
* Forces everything in the scene to be rendered with the defined material. It is possible
* to exclude materials from override by setting {@link Material#allowOverride} to `false`.
*
* @default null
*/
overrideMaterial: Material | null;
copy(source: Scene, recursive?: boolean): this;
toJSON(meta?: JSONMeta): SceneJSON;
}
declare interface SceneJSON extends Object3DJSON {
object: SceneJSONObject;
}
declare interface SceneJSONObject extends Object3DJSONObject {
fog?: FogJSON | FogExp2JSON;
backgroundBlurriness?: number;
backgroundIntensity?: number;
backgroundRotation: EulerTuple;
environmentIntensity?: number;
environmentRotation: EulerTuple;
}
declare type SerializedImage =
| string
| {
data: number[];
width: number;
height: number;
type: string;
};
declare type ShadowMapType = typeof BasicShadowMap | typeof PCFShadowMap | typeof PCFSoftShadowMap | typeof VSMShadowMap;
declare interface ShapeJSON extends PathJSON {
uuid: string;
holes: PathJSON[];
}
declare const ShortType: 1011;
/**
* Defines which side of faces will be rendered - front, back or both.
* Default is {@link FrontSide}.
*/
declare type Side = typeof FrontSide | typeof BackSide | typeof DoubleSide;
declare const SIGNED_R11_EAC_Format: 37489;
declare const SIGNED_RED_GREEN_RGTC2_Format: 36286;
declare const SIGNED_RED_RGTC1_Format: 36284;
declare const SIGNED_RG11_EAC_Format: 37491;
/**
* Use an array of {@link Bone | bones} to create a {@link Skeleton} that can be used by a {@link THREE.SkinnedMesh | SkinnedMesh}.
* @example
* ```typescript
* // Create a simple "arm"
* const bones = [];
* const shoulder = new THREE.Bone();
* const elbow = new THREE.Bone();
* const hand = new THREE.Bone();
* shoulder.add(elbow);
* elbow.add(hand);
* bones.push(shoulder);
* bones.push(elbow);
* bones.push(hand);
* shoulder.position.y = -5;
* elbow.position.y = 0;
* hand.position.y = 5;
* const armSkeleton = new THREE.Skeleton(bones);
* See the[page: SkinnedMesh] page
* for an example of usage with standard[page: BufferGeometry].
* ```
* @see {@link https://threejs.org/docs/index.html#api/en/objects/Skeleton | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/objects/Skeleton.js | Source}
*/
declare class Skeleton {
/**
* Creates a new Skeleton.
* @param bones The array of {@link THREE.Bone | bones}. Default `[]`.
* @param boneInverses An array of {@link THREE.Matrix4 | Matrix4s}. Default `[]`.
*/
constructor(bones?: Bone[], boneInverses?: Matrix4[]);
/**
* {@link http://en.wikipedia.org/wiki/Universally_unique_identifier | UUID} of this object instance.
* @remarks This gets automatically assigned and shouldn't be edited.
*/
uuid: string;
/**
* The array of {@link THREE.Bone | Bones}.
* @remarks Note this is a copy of the original array, not a reference, so you can modify the original array without effecting this one.
*/
bones: Bone[];
/**
* An array of {@link Matrix4 | Matrix4s} that represent the inverse of the {@link THREE.Matrix4 | matrixWorld} of the individual bones.
*/
boneInverses: Matrix4[];
/**
* The array buffer holding the bone data when using a vertex texture.
*/
boneMatrices: Float32Array | null;
/**
* The {@link THREE.DataTexture | DataTexture} holding the bone data when using a vertex texture.
*/
boneTexture: DataTexture | null;
frame: number;
init(): void;
/**
* Generates the {@link boneInverses} array if not provided in the constructor.
*/
calculateInverses(): void;
/**
* Computes an instance of {@link THREE.DataTexture | DataTexture} in order to pass the bone data more efficiently to the shader
* @remarks
* The texture is assigned to {@link boneTexture}.
*/
computeBoneTexture(): this;
/**
* Returns the skeleton to the base pose.
*/
pose(): void;
/**
* Updates the {@link boneMatrices} and {@link boneTexture} after changing the bones
* @remarks
* This is called automatically by the {@link THREE.WebGLRenderer | WebGLRenderer} if the {@link Skeleton} is used with a {@link THREE.SkinnedMesh | SkinnedMesh}.
*/
update(): void;
/**
* Returns a clone of this {@link Skeleton} object.
*/
clone(): Skeleton;
/**
* Searches through the skeleton's bone array and returns the first with a matching name.
* @param name String to match to the Bone's {@link THREE.Bone.name | .name} property.
*/
getBoneByName(name: string): undefined | Bone;
/**
* Frees the GPU-related resources allocated by this instance
* @remarks
* Call this method whenever this instance is no longer used in your app.
*/
dispose(): void;
toJSON(): SkeletonJSON;
fromJSON(json: SkeletonJSON, bones: Record): void;
}
declare interface SkeletonJSON {
metadata: { version: number; type: string; generator: string };
bones: string[];
boneInverses: Matrix4Tuple[];
uuid: string;
}
/**
* Represents the data {@link Source} of a texture.
* @see {@link https://threejs.org/docs/index.html#api/en/textures/Source | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/textures/Source.js | Source}
*/
declare class Source {
/**
* Flag to check if a given object is of type {@link Source}.
* @remarks This is a _constant_ value
* @defaultValue `true`
*/
readonly isSource: true;
readonly id: number;
/**
* {@link http://en.wikipedia.org/wiki/Universally_unique_identifier | UUID} of this object instance.
* @remarks This gets automatically assigned and shouldn't be edited.
*/
uuid: string;
/**
* The actual data of a texture.
* @remarks The type of this property depends on the texture that uses this instance.
*/
data: TData;
/**
* This property is only relevant when {@link .needsUpdate} is set to `true` and provides more control on how
* texture data should be processed.
* When `dataReady` is set to `false`, the engine performs the memory allocation (if necessary) but does not
* transfer the data into the GPU memory.
* @default true
*/
dataReady: boolean;
/**
* This starts at `0` and counts how many times {@link needsUpdate | .needsUpdate} is set to `true`.
* @remarks Expects a `Integer`
* @defaultValue `0`
*/
version: number;
/**
* Create a new instance of {@link Source}
* @param data The data definition of a texture. Default `null`
*/
constructor(data: TData);
getSize(target: Vector3): Vector3;
/**
* When the property is set to `true`, the engine allocates the memory for the texture (if necessary) and triggers
* the actual texture upload to the GPU next time the source is used.
*/
set needsUpdate(value: boolean);
/**
* Convert the data {@link Source} to three.js {@link https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 | JSON Object/Scene format}.
* @param meta Optional object containing metadata.
*/
toJSON(meta?: string | {}): SourceJSON;
}
declare class SourceJSON {
uuid: string;
url: SerializedImage | SerializedImage[];
}
declare class Sphere {
constructor(center?: Vector3, radius?: number);
/**
* Read-only flag to check if a given object is of type {@link Sphere}.
*/
readonly isSphere: true;
/**
* @default new Vector3()
*/
center: Vector3;
/**
* @default 1
*/
radius: number;
set(center: Vector3, radius: number): Sphere;
setFromPoints(points: Vector3[], optionalCenter?: Vector3): Sphere;
clone(): this;
copy(sphere: Sphere): this;
expandByPoint(point: Vector3): this;
isEmpty(): boolean;
makeEmpty(): this;
containsPoint(point: Vector3): boolean;
distanceToPoint(point: Vector3): number;
intersectsSphere(sphere: Sphere): boolean;
intersectsBox(box: Box3): boolean;
intersectsPlane(plane: Plane): boolean;
clampPoint(point: Vector3, target: Vector3): Vector3;
getBoundingBox(target: Box3): Box3;
applyMatrix4(matrix: Matrix4): Sphere;
translate(offset: Vector3): Sphere;
equals(sphere: Sphere): boolean;
union(sphere: Sphere): this;
/**
* @deprecated Use {@link Sphere#isEmpty .isEmpty()} instead.
*/
empty(): any;
toJSON(): SphereJSON;
fromJSON(json: SphereJSON): this;
}
declare interface SphereJSON {
radius: number;
center: number[];
}
declare class Spherical {
constructor(radius?: number, phi?: number, theta?: number);
/**
* @default 1
*/
radius: number;
/**
* @default 0
*/
phi: number;
/**
* @default 0
*/
theta: number;
set(radius: number, phi: number, theta: number): this;
clone(): this;
copy(other: Spherical): this;
makeSafe(): this;
setFromVector3(v: Vector3): this;
setFromCartesianCoords(x: number, y: number, z: number): this;
}
declare const SrcAlphaFactor: 204;
declare const SrcAlphaSaturateFactor: 210;
declare const SrcColorFactor: 202;
declare const SRGBColorSpace: "srgb";
declare const StaticCopyUsage: 35046;
declare const StaticDrawUsage: 35044;
declare const StaticReadUsage: 35045;
declare type StencilFunc =
| typeof NeverStencilFunc
| typeof LessStencilFunc
| typeof EqualStencilFunc
| typeof LessEqualStencilFunc
| typeof GreaterStencilFunc
| typeof NotEqualStencilFunc
| typeof GreaterEqualStencilFunc
| typeof AlwaysStencilFunc;
declare type StencilOp =
| typeof ZeroStencilOp
| typeof KeepStencilOp
| typeof ReplaceStencilOp
| typeof IncrementStencilOp
| typeof DecrementStencilOp
| typeof IncrementWrapStencilOp
| typeof DecrementWrapStencilOp
| typeof InvertStencilOp;
declare class StorageBufferAttribute extends BufferAttribute {
readonly isStorageBufferAttribute: true;
constructor(array: TypedArray | number, itemSize: number);
}
declare const StreamCopyUsage: 35042;
declare const StreamDrawUsage: 35040;
declare const StreamReadUsage: 35041;
declare const SubtractEquation: 101;
declare const SubtractiveBlending: 3;
declare const TangentSpaceNormalMap: 0;
/**
* Create a {@link Texture} to apply to a surface or as a reflection or refraction map.
* @remarks
* After the initial use of a texture, its **dimensions**, {@link format}, and {@link type} cannot be changed
* Instead, call {@link dispose | .dispose()} on the {@link Texture} and instantiate a new {@link Texture}.
* @example
* ```typescript
* // load a texture, set wrap mode to repeat
* const texture = new THREE.TextureLoader().load("textures/water.jpg");
* texture.wrapS = THREE.RepeatWrapping;
* texture.wrapT = THREE.RepeatWrapping;
* texture.repeat.set(4, 4);
* ```
* @see Example: {@link https://threejs.org/examples/#webgl_materials_texture_filters | webgl materials texture filters}
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
* @see {@link https://threejs.org/docs/index.html#api/en/textures/Texture | Official Documentation}
* @see {@link https://github.com/mrdoob/three.js/blob/master/src/Textures/Texture.js | Source}
*/
declare class Texture
extends EventDispatcher
{
/**
* This creates a new {@link THREE.Texture | Texture} object.
* @param image See {@link Texture.image | .image}. Default {@link THREE.Texture.DEFAULT_IMAGE}
* @param mapping See {@link Texture.mapping | .mapping}. Default {@link THREE.Texture.DEFAULT_MAPPING}
* @param wrapS See {@link Texture.wrapS | .wrapS}. Default {@link THREE.ClampToEdgeWrapping}
* @param wrapT See {@link Texture.wrapT | .wrapT}. Default {@link THREE.ClampToEdgeWrapping}
* @param magFilter See {@link Texture.magFilter | .magFilter}. Default {@link THREE.LinearFilter}
* @param minFilter See {@link Texture.minFilter | .minFilter}. Default {@link THREE.LinearMipmapLinearFilter}
* @param format See {@link Texture.format | .format}. Default {@link THREE.RGBAFormat}
* @param type See {@link Texture.type | .type}. Default {@link THREE.UnsignedByteType}
* @param anisotropy See {@link Texture.anisotropy | .anisotropy}. Default {@link THREE.Texture.DEFAULT_ANISOTROPY}
* @param colorSpace See {@link Texture.colorSpace | .colorSpace}. Default {@link THREE.NoColorSpace}
*/
constructor(
image?: TImage,
mapping?: Mapping,
wrapS?: Wrapping,
wrapT?: Wrapping,
magFilter?: MagnificationTextureFilter,
minFilter?: MinificationTextureFilter,
format?: PixelFormat,
type?: TextureDataType,
anisotropy?: number,
colorSpace?: ColorSpace,
);
/**
* @deprecated
*/
constructor(
image: TImage,
mapping: Mapping,
wrapS: Wrapping,
wrapT: Wrapping,
magFilter: MagnificationTextureFilter,
minFilter: MinificationTextureFilter,
format: PixelFormat,
type: TextureDataType,
anisotropy: number,
);
/**
* Read-only flag to check if a given object is of type {@link Texture}.
* @remarks This is a _constant_ value
* @defaultValue `true`
*/
readonly isTexture: true;
/**
* Unique number for this {@link Texture} instance.
* @remarks Note that ids are assigned in chronological order: 1, 2, 3, ..., incrementing by one for each new object.
* @remarks Expects a `Integer`
*/
readonly id: number;
/**
* {@link http://en.wikipedia.org/wiki/Universally_unique_identifier | UUID} of this object instance.
* @remarks This gets automatically assigned and shouldn't be edited.
*/
uuid: string;
/**
* Optional name of the object
* @remarks _(doesn't need to be unique)_.
* @defaultValue `""`
*/
name: string;
/**
* The data definition of a texture. A reference to the data source can be shared across textures.
* This is often useful in context of spritesheets where multiple textures render the same data
* but with different {@link Texture} transformations.
*/
source: Source;
/**
* The width of the texture in pixels.
*/
get width(): number;
/**
* The height of the texture in pixels.
*/
get height(): number;
/**
* The depth of the texture in pixels.
*/
get depth(): number;
/**
* An image object, typically created using the {@link THREE.TextureLoader.load | TextureLoader.load()} method.
* @remarks This can be any image (e.g., PNG, JPG, GIF, DDS) or video (e.g., MP4, OGG/OGV) type supported by three.js.
* @remarks To use video as a {@link Texture} you need to have a playing HTML5 video element as a source
* for your {@link Texture} image and continuously update this {@link Texture}
* as long as video is playing - the {@link THREE.VideoTexture | VideoTexture} class handles this automatically.
*/
get image(): TImage;
set image(data: TImage);
/**
* Array of user-specified mipmaps
* @defaultValue `[]`
*/
mipmaps: CompressedTextureMipmap[] | CubeTexture[] | HTMLCanvasElement[];
/**
* How the image is applied to the object.
* @remarks All {@link Texture} types except {@link THREE.CubeTexture} expect the _values_ be {@link THREE.Mapping}
* @remarks {@link CubeTexture} expect the _values_ be {@link THREE.CubeTextureMapping}
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
* @defaultValue _value of_ {@link THREE.Texture.DEFAULT_MAPPING}
*/
mapping: AnyMapping;
/**
* Lets you select the uv attribute to map the texture to. `0` for `uv`, `1` for `uv1`, `2` for `uv2` and `3` for
* `uv3`.
*/
channel: number;
/**
* This defines how the {@link Texture} is wrapped *horizontally* and corresponds to **U** in UV mapping.
* @remarks for **WEBGL1** - tiling of images in textures only functions if image dimensions are powers of two
* (2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, ...) in terms of pixels.
* Individual dimensions need not be equal, but each must be a power of two. This is a limitation of WebGL1, not three.js.
* **WEBGL2** does not have this limitation.
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
* @see {@link wrapT}
* @see {@link repeat}
* @defaultValue {@link THREE.ClampToEdgeWrapping}
*/
wrapS: Wrapping;
/**
* This defines how the {@link Texture} is wrapped *vertically* and corresponds to **V** in UV mapping.
* @remarks for **WEBGL1** - tiling of images in textures only functions if image dimensions are powers of two
* (2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, ...) in terms of pixels.
* Individual dimensions need not be equal, but each must be a power of two. This is a limitation of WebGL1, not three.js.
* **WEBGL2** does not have this limitation.
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
* @see {@link wrapS}
* @see {@link repeat}
* @defaultValue {@link THREE.ClampToEdgeWrapping}
*/
wrapT: Wrapping;
/**
* How the {@link Texture} is sampled when a texel covers more than one pixel.
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
* @see {@link minFilter}
* @see {@link THREE.MagnificationTextureFilter}
* @defaultValue {@link THREE.LinearFilter}
*/
magFilter: MagnificationTextureFilter;
/**
* How the {@link Texture} is sampled when a texel covers less than one pixel.
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
* @see {@link magFilter}
* @see {@link THREE.MinificationTextureFilter}
* @defaultValue {@link THREE.LinearMipmapLinearFilter}
*/
minFilter: MinificationTextureFilter;
/**
* The number of samples taken along the axis through the pixel that has the highest density of texels.
* @remarks A higher value gives a less blurry result than a basic mipmap, at the cost of more {@link Texture} samples being used.
* @remarks Use {@link THREE.WebGLCapabilities.getMaxAnisotropy() | renderer.capabilities.getMaxAnisotropy()} to find the maximum valid anisotropy value for the GPU;
* @remarks This value is usually a power of 2.
* @default _value of_ {@link THREE.Texture.DEFAULT_ANISOTROPY}. That is normally `1`.
*/
anisotropy: number;
/**
* These define how elements of a 2D texture, or texels, are read by shaders.
* @remarks All {@link Texture} types except {@link THREE.DepthTexture} and {@link THREE.CompressedPixelFormat} expect the _values_ be {@link THREE.PixelFormat}
* @remarks {@link DepthTexture} expect the _values_ be {@link THREE.CubeTextureMapping}
* @remarks {@link CompressedPixelFormat} expect the _values_ be {@link THREE.CubeTextureMapping}
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
* @see {@link THREE.PixelFormat}
* @defaultValue {@link THREE.RGBAFormat}.
*/
format: AnyPixelFormat;
/**
* This must correspond to the {@link Texture.format | .format}.
* @remarks {@link THREE.UnsignedByteType}, is the type most used by Texture formats.
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
* @see {@link THREE.TextureDataType}
* @defaultValue {@link THREE.UnsignedByteType}
*/
type: TextureDataType;
/**
* The GPU Pixel Format allows the developer to specify how the data is going to be stored on the GPU.
* @remarks Compatible only with {@link WebGL2RenderingContext | WebGL 2 Rendering Context}.
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
* @defaultValue The default value is obtained using a combination of {@link Texture.format | .format} and {@link Texture.type | .type}.
*/
internalFormat: PixelFormatGPU | null;
/**
* The uv-transform matrix for the texture.
* @remarks
* When {@link Texture.matrixAutoUpdate | .matrixAutoUpdate} property is `true`.
* Will be updated by the renderer from the properties:
* - {@link Texture.offset | .offset}
* - {@link Texture.repeat | .repeat}
* - {@link Texture.rotation | .rotation}
* - {@link Texture.center | .center}
* @remarks
* When {@link Texture.matrixAutoUpdate | .matrixAutoUpdate} property is `false`.
* This matrix may be set manually.
* @see {@link matrixAutoUpdate | .matrixAutoUpdate}
* @defaultValue `new THREE.Matrix3()`
*/
matrix: Matrix3;
/**
* Whether is to update the texture's uv-transform {@link matrix | .matrix}.
* @remarks Set this to `false` if you are specifying the uv-transform {@link matrix} directly.
* @see {@link matrix | .matrix}
* @defaultValue `true`
*/
matrixAutoUpdate: boolean;
/**
* How much a single repetition of the texture is offset from the beginning, in each direction **U** and **V**.
* @remarks Typical range is `0.0` to `1.0`.
* @defaultValue `new THREE.Vector2(0, 0)`
*/
offset: Vector2;
/**
* How many times the texture is repeated across the surface, in each direction **U** and **V**.
* @remarks
* If repeat is set greater than `1` in either direction, the corresponding *Wrap* parameter should
* also be set to {@link THREE.RepeatWrapping} or {@link THREE.MirroredRepeatWrapping} to achieve the desired tiling effect.
* @see {@link wrapS}
* @see {@link wrapT}
* @defaultValue `new THREE.Vector2( 1, 1 )`
*/
repeat: Vector2;
/**
* The point around which rotation occurs.
* @remarks A value of `(0.5, 0.5)` corresponds to the center of the texture.
* @defaultValue `new THREE.Vector2( 0, 0 )`, _lower left._
*/
center: Vector2;
/**
* How much the texture is rotated around the center point, in radians.
* @remarks Positive values are counter-clockwise.
* @defaultValue `0`
*/
rotation: number;
/**
* Whether to generate mipmaps, _(if possible)_ for a texture.
* @remarks Set this to false if you are creating mipmaps manually.
* @defaultValue true
*/
generateMipmaps: boolean;
/**
* If set to `true`, the alpha channel, if present, is multiplied into the color channels when the texture is uploaded to the GPU.
* @remarks
* Note that this property has no effect for {@link https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap | ImageBitmap}.
* You need to configure on bitmap creation instead. See {@link THREE.ImageBitmapLoader | ImageBitmapLoader}.
* @see {@link THREE.ImageBitmapLoader | ImageBitmapLoader}.
* @defaultValue `false`
*/
premultiplyAlpha: boolean;
/**
* If set to `true`, the texture is flipped along the vertical axis when uploaded to the GPU.
* @remarks
* Note that this property has no effect for {@link https://developer.mozilla.org/en-US/docs/Web/API/ImageBitmap | ImageBitmap}.
* You need to configure on bitmap creation instead. See {@link THREE.ImageBitmapLoader | ImageBitmapLoader}.
* @see {@link THREE.ImageBitmapLoader | ImageBitmapLoader}.
* @defaultValue `true`
*/
flipY: boolean;
/**
* Specifies the alignment requirements for the start of each pixel row in memory.
* @remarks
* The allowable values are:
* - `1` (byte-alignment)
* - `2` (rows aligned to even-numbered bytes)
* - `4` (word-alignment)
* - `8` (rows start on double-word boundaries).
* @see {@link http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml | glPixelStorei} for more information.
* @defaultValue `4`
*/
unpackAlignment: number; // TODO Fix typing to only allow the expected values.
/**
* The {@link Textures | {@link Texture} constants} page for details of other color spaces.
* @remarks
* Textures containing color data should be annotated with {@link SRGBColorSpace THREE.SRGBColorSpace} or
* {@link LinearSRGBColorSpace THREE.LinearSRGBColorSpace}.
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
* @see {@link THREE.TextureDataType}
* @defaultValue {@link THREE.NoColorSpace}
*/
colorSpace: string;
/**
* Indicates whether a texture belongs to a render target or not
* @defaultValue `false`
*/
isRenderTargetTexture: boolean;
/**
* Indicates if a texture should be handled like a texture array.
*
* @default false
*/
isArrayTexture: boolean;
/**
* An object that can be used to store custom data about the texture.
* @remarks It should not hold references to functions as these will not be cloned.
* @defaultValue `{}`
*/
userData: Record;
/**
* This can be used to only update a subregion or specific rows of the texture (for example, just the
* first 3 rows). Use the `addUpdateRange()` function to add ranges to this array.
*/
updateRanges: Array<{ start: number; count: number }>;
/**
* This starts at `0` and counts how many times {@link needsUpdate | .needsUpdate} is set to `true`.
* @remarks Expects a `Integer`
* @defaultValue `0`
*/
version: number;
/**
* Indicates whether this texture should be processed by PMREMGenerator or not (only relevant for render target
* textures)
*/
pmremVersion: number;
/**
* Whether the texture should use one of the 16 bit integer formats which are normalized
* to [0, 1] or [-1, 1] (depending on signed/unsigned) when sampled.
*
* @type {boolean}
* @default false
*/
normalized: boolean;
/**
* Set this to `true` to trigger an update next time the texture is used. Particularly important for setting the wrap mode.
*/
set needsUpdate(value: boolean);
/**
* Indicates whether this texture should be processed by {@link THREE.PMREMGenerator} or not.
* @remarks Only relevant for render target textures.
* @defaultValue `false`
*/
set needsPMREMUpdate(value: boolean);
/**
* The Global default value for {@link anisotropy | .anisotropy}.
* @defaultValue `1`.
*/
static DEFAULT_ANISOTROPY: number;
/**
* The Global default value for {@link Texture.image | .image}.
* @defaultValue `null`.
*/
static DEFAULT_IMAGE: null;
/**
* The Global default value for {@link mapping | .mapping}.
* @defaultValue {@link THREE.UVMapping}
*/
static DEFAULT_MAPPING: Mapping;
renderTarget: RenderTarget | null;
/**
* A callback function, called when the texture is updated _(e.g., when needsUpdate has been set to true and then the texture is used)_.
*/
onUpdate: ((texture: Texture) => void) | null;
/**
* Transform the **UV** based on the value of this texture's
* {@link offset | .offset},
* {@link repeat | .repeat},
* {@link wrapS | .wrapS},
* {@link wrapT | .wrapT} and
* {@link flipY | .flipY} properties.
* @param uv
*/
transformUv(uv: Vector2): Vector2;
/**
* Update the texture's **UV-transform** {@link matrix | .matrix} from the texture properties
* {@link offset | .offset},
* {@link repeat | .repeat},
* {@link rotation | .rotation} and
* {@link center | .center}.
*/
updateMatrix(): void;
/**
* Adds a range of data in the data texture to be updated on the GPU.
*
* @param {number} start - Position at which to start update.
* @param {number} count - The number of components to update.
*/
addUpdateRange(start: number, count: number): void;
/**
* Clears the update ranges.
*/
clearUpdateRanges(): void;
/**
* Make copy of the texture. Note this is not a "deep copy", the image is shared. Cloning the texture automatically
* marks it for texture upload.
*/
clone(): this;
copy(source: Texture): this;
/**
* Sets this texture's properties based on `values`.
* @param values - A container with texture parameters.
*/
setValues(values: TextureParameters): void;
/**
* Convert the texture to three.js {@link https://github.com/mrdoob/three.js/wiki/JSON-Object-Scene-format-4 | JSON Object/Scene format}.
* @param meta Optional object containing metadata.
*/
toJSON(meta?: string | {}): TextureJSON;
/**
* Frees the GPU-related resources allocated by this instance
* @remarks Call this method whenever this instance is no longer used in your app.
*/
dispose(): void;
}
declare type TextureComparisonFunction =
| typeof NeverCompare
| typeof LessCompare
| typeof EqualCompare
| typeof LessEqualCompare
| typeof GreaterCompare
| typeof NotEqualCompare
| typeof GreaterEqualCompare
| typeof AlwaysCompare;
/**
* Texture Types.
* @remarks Must correspond to the correct {@link PixelFormat | format}.
* @see {@link THREE.Texture.type}
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
*/
declare type TextureDataType =
| typeof UnsignedByteType
| typeof ByteType
| typeof ShortType
| typeof UnsignedShortType
| typeof IntType
| typeof UnsignedIntType
| typeof FloatType
| typeof HalfFloatType
| typeof UnsignedShort4444Type
| typeof UnsignedShort5551Type
| typeof UnsignedInt248Type
| typeof UnsignedInt5999Type
| typeof UnsignedInt101111Type;
declare interface TextureEventMap {
dispose: {};
}
declare interface TextureJSON {
metadata: { version: number; type: string; generator: string };
uuid: string;
name: string;
image: string;
mapping: AnyMapping;
channel: number;
repeat: [x: number, y: number];
offset: [x: number, y: number];
center: [x: number, y: number];
rotation: number;
wrap: [wrapS: number, wrapT: number];
format: AnyPixelFormat;
internalFormat: PixelFormatGPU | null;
type: TextureDataType;
colorSpace: string;
minFilter: MinificationTextureFilter;
magFilter: MagnificationTextureFilter;
anisotropy: number;
flipY: boolean;
generateMipmaps: boolean;
premultiplyAlpha: boolean;
unpackAlignment: number;
userData?: Record;
}
declare interface TextureParameters {
mapping?: AnyMapping | undefined;
// image?: TexImageSource | OffscreenCanvas | undefined;
// channel?: number | undefined;
wrapS?: Wrapping | undefined;
wrapT?: Wrapping | undefined;
wrapR?: Wrapping | undefined;
format?: PixelFormat | undefined;
internalFormat?: PixelFormatGPU | null | undefined;
type?: TextureDataType | undefined;
colorSpace?: ColorSpace | undefined;
magFilter?: MagnificationTextureFilter | undefined;
minFilter?: MinificationTextureFilter | undefined;
anisotropy?: number | undefined;
flipY?: boolean | undefined;
generateMipmaps?: boolean | undefined;
// premultiplyAlpha?: boolean | undefined;
// unpackAlignment?: number | undefined;
}
declare type ToneMapping =
| typeof NoToneMapping
| typeof LinearToneMapping
| typeof ReinhardToneMapping
| typeof CineonToneMapping
| typeof ACESFilmicToneMapping
| typeof CustomToneMapping
| typeof AgXToneMapping
| typeof NeutralToneMapping;
declare class Triangle {
constructor(a?: Vector3, b?: Vector3, c?: Vector3);
/**
* @default new THREE.Vector3()
*/
a: Vector3;
/**
* @default new THREE.Vector3()
*/
b: Vector3;
/**
* @default new THREE.Vector3()
*/
c: Vector3;
set(a: Vector3, b: Vector3, c: Vector3): Triangle;
setFromPointsAndIndices(points: Vector3[], i0: number, i1: number, i2: number): this;
setFromAttributeAndIndices(
attribute: BufferAttribute | InterleavedBufferAttribute,
i0: number,
i1: number,
i2: number,
): this;
clone(): this;
copy(triangle: Triangle): this;
getArea(): number;
getMidpoint(target: Vector3): Vector3;
getNormal(target: Vector3): Vector3;
getPlane(target: Plane): Plane;
getBarycoord(point: Vector3, target: Vector3): Vector3 | null;
getInterpolation(point: Vector3, v1: Vector2, v2: Vector2, v3: Vector2, target: Vector2): Vector2 | null;
getInterpolation(point: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, target: Vector3): Vector3 | null;
getInterpolation(point: Vector3, v1: Vector4, v2: Vector4, v3: Vector4, target: Vector4): Vector4 | null;
containsPoint(point: Vector3): boolean;
intersectsBox(box: Box3): boolean;
isFrontFacing(direction: Vector3): boolean;
closestPointToPoint(point: Vector3, target: Vector3): Vector3;
equals(triangle: Triangle): boolean;
static getNormal(a: Vector3, b: Vector3, c: Vector3, target: Vector3): Vector3;
static getBarycoord(point: Vector3, a: Vector3, b: Vector3, c: Vector3, target: Vector3): Vector3 | null;
static containsPoint(point: Vector3, a: Vector3, b: Vector3, c: Vector3): boolean;
static getInterpolation(
point: Vector3,
p1: Vector3,
p2: Vector3,
p3: Vector3,
v1: Vector2,
v2: Vector2,
v3: Vector2,
target: Vector2,
): Vector2 | null;
static getInterpolation(
point: Vector3,
p1: Vector3,
p2: Vector3,
p3: Vector3,
v1: Vector3,
v2: Vector3,
v3: Vector3,
target: Vector3,
): Vector3 | null;
static getInterpolation(
point: Vector3,
p1: Vector3,
p2: Vector3,
p3: Vector3,
v1: Vector4,
v2: Vector4,
v3: Vector4,
target: Vector4,
): Vector4 | null;
static getInterpolatedAttribute(
attr: BufferAttribute | InterleavedBufferAttribute,
i1: number,
i2: number,
i3: number,
barycoord: Vector3,
target: Vector2,
): Vector2;
static getInterpolatedAttribute(
attr: BufferAttribute | InterleavedBufferAttribute,
i1: number,
i2: number,
i3: number,
barycoord: Vector3,
target: Vector3,
): Vector3;
static getInterpolatedAttribute(
attr: BufferAttribute | InterleavedBufferAttribute,
i1: number,
i2: number,
i3: number,
barycoord: Vector3,
target: Vector4,
): Vector4;
static isFrontFacing(a: Vector3, b: Vector3, c: Vector3, direction: Vector3): boolean;
}
declare type TypedArray =
| Int8Array
| Uint8Array
| Uint8ClampedArray
| Int16Array
| Uint16Array
| Int32Array
| Uint32Array
| Float32Array
| Float64Array;
declare type TypedArrayConstructor =
| Int8ArrayConstructor
| Uint8ArrayConstructor
| Uint8ClampedArrayConstructor
| Int16ArrayConstructor
| Uint16ArrayConstructor
| Int32ArrayConstructor
| Uint32ArrayConstructor
| Float32ArrayConstructor
| Float64ArrayConstructor;
declare const UnsignedByteType: 1009;
declare const UnsignedInt101111Type: 35899;
declare const UnsignedInt248Type: 1020;
declare const UnsignedInt5999Type: 35902;
declare const UnsignedIntType: 1014;
declare const UnsignedShort4444Type: 1017;
declare const UnsignedShort5551Type: 1018;
declare const UnsignedShortType: 1012;
declare type Usage =
| typeof StaticDrawUsage
| typeof DynamicDrawUsage
| typeof StreamDrawUsage
| typeof StaticReadUsage
| typeof DynamicReadUsage
| typeof StreamReadUsage
| typeof StaticCopyUsage
| typeof DynamicCopyUsage
| typeof StreamCopyUsage;
/**
* Maps the texture using the mesh's UV coordinates.
* @remarks This is the _default_ value and behaver for Texture Mapping.
*/
declare const UVMapping: 300;
/**
* Validate if the buffer is a valid VRM 1.0 model
* Checks for the presence of the VRMC_vrm extension and absence of the older VRM extension.
* @param buffer The GLB file as an ArrayBuffer.
* @throws If the buffer is not a valid VRM 1.0 GLB.
*/
export declare function validateVrm(buffer: ArrayBuffer): void {
const json = parseGlbJson(buffer);
const ext = (json.extensions ?? {}) as Record;
if ('VRM' in ext && !('VRMC_vrm' in ext)) {
throw new Error(
'[VrmCanvas] VRM 0.x is not supported. Please use a VRM 1.0 model.',
);
}
if (!('VRMC_vrm' in ext)) {
throw new Error('[VrmCanvas] Invalid VRM: VRMC_vrm extension not found.');
}
}
/**
* Validate if the buffer is a valid VRMA (VRM Animation) model
* Checks for the presence of the VRMC_vrm_animation extension.
* @param buffer The GLB file as an ArrayBuffer.
* @throws If the buffer is not a valid VRMA GLB.
*/
export declare function validateVrma(buffer: ArrayBuffer): void {
const json = parseGlbJson(buffer);
const ext = (json.extensions ?? {}) as Record;
if (!('VRMC_vrm_animation' in ext)) {
throw new Error(
'[VrmCanvas] Invalid VRMA: VRMC_vrm_animation extension not found.',
);
}
}
/**
* 2D vector.
*/
declare class Vector2 {
constructor(x?: number, y?: number);
/**
* @default 0
*/
x: number;
/**
* @default 0
*/
y: number;
width: number;
height: number;
readonly isVector2: true;
/**
* Sets value of this vector.
*/
set(x: number, y: number): this;
/**
* Sets the x and y values of this vector both equal to scalar.
*/
setScalar(scalar: number): this;
/**
* Sets X component of this vector.
*/
setX(x: number): this;
/**
* Sets Y component of this vector.
*/
setY(y: number): this;
/**
* Sets a component of this vector.
*/
setComponent(index: number, value: number): this;
/**
* Gets a component of this vector.
*/
getComponent(index: number): number;
/**
* Returns a new Vector2 instance with the same `x` and `y` values.
*/
clone(): this;
/**
* Copies value of v to this vector.
*/
copy(v: Vector2Like): this;
/**
* Adds v to this vector.
*/
add(v: Vector2Like): this;
/**
* Adds the scalar value s to this vector's x and y values.
*/
addScalar(s: number): this;
/**
* Sets this vector to a + b.
*/
addVectors(a: Vector2Like, b: Vector2Like): this;
/**
* Adds the multiple of v and s to this vector.
*/
addScaledVector(v: Vector2Like, s: number): this;
/**
* Subtracts v from this vector.
*/
sub(v: Vector2Like): this;
/**
* Subtracts s from this vector's x and y components.
*/
subScalar(s: number): this;
/**
* Sets this vector to a - b.
*/
subVectors(a: Vector2Like, b: Vector2Like): this;
/**
* Multiplies this vector by v.
*/
multiply(v: Vector2Like): this;
/**
* Multiplies this vector by scalar s.
*/
multiplyScalar(scalar: number): this;
/**
* Divides this vector by v.
*/
divide(v: Vector2Like): this;
/**
* Divides this vector by scalar s.
* Set vector to ( 0, 0 ) if s == 0.
*/
divideScalar(s: number): this;
/**
* Multiplies this vector (with an implicit 1 as the 3rd component) by m.
*/
applyMatrix3(m: Matrix3): this;
/**
* If this vector's x or y value is greater than v's x or y value, replace that value with the corresponding min value.
*/
min(v: Vector2Like): this;
/**
* If this vector's x or y value is less than v's x or y value, replace that value with the corresponding max value.
*/
max(v: Vector2Like): this;
/**
* If this vector's x or y value is greater than the max vector's x or y value, it is replaced by the corresponding value.
* If this vector's x or y value is less than the min vector's x or y value, it is replaced by the corresponding value.
* @param min the minimum x and y values.
* @param max the maximum x and y values in the desired range.
*/
clamp(min: Vector2Like, max: Vector2Like): this;
/**
* If this vector's x or y values are greater than the max value, they are replaced by the max value.
* If this vector's x or y values are less than the min value, they are replaced by the min value.
* @param min the minimum value the components will be clamped to.
* @param max the maximum value the components will be clamped to.
*/
clampScalar(min: number, max: number): this;
/**
* If this vector's length is greater than the max value, it is replaced by the max value.
* If this vector's length is less than the min value, it is replaced by the min value.
* @param min the minimum value the length will be clamped to.
* @param max the maximum value the length will be clamped to.
*/
clampLength(min: number, max: number): this;
/**
* The components of the vector are rounded down to the nearest integer value.
*/
floor(): this;
/**
* The x and y components of the vector are rounded up to the nearest integer value.
*/
ceil(): this;
/**
* The components of the vector are rounded to the nearest integer value.
*/
round(): this;
/**
* The components of the vector are rounded towards zero (up if negative, down if positive) to an integer value.
*/
roundToZero(): this;
/**
* Inverts this vector.
*/
negate(): this;
/**
* Computes dot product of this vector and v.
*/
dot(v: Vector2Like): number;
/**
* Computes cross product of this vector and v.
*/
cross(v: Vector2Like): number;
/**
* Computes squared length of this vector.
*/
lengthSq(): number;
/**
* Computes length of this vector.
*/
length(): number;
/**
* Computes the Manhattan length of this vector.
*
* see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry}
*/
manhattanLength(): number;
/**
* Normalizes this vector.
*/
normalize(): this;
/**
* computes the angle in radians with respect to the positive x-axis
*/
angle(): number;
/**
* Returns the angle between this vector and vector {@link Vector2 | v} in radians.
*/
angleTo(v: Vector2): number;
/**
* Computes distance of this vector to v.
*/
distanceTo(v: Vector2Like): number;
/**
* Computes squared distance of this vector to v.
*/
distanceToSquared(v: Vector2Like): number;
/**
* Computes the Manhattan length (distance) from this vector to the given vector v
*
* see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry}
*/
manhattanDistanceTo(v: Vector2Like): number;
/**
* Normalizes this vector and multiplies it by l.
*/
setLength(length: number): this;
/**
* Linearly interpolates between this vector and v, where alpha is the distance along the line - alpha = 0 will be this vector, and alpha = 1 will be v.
* @param v vector to interpolate towards.
* @param alpha interpolation factor in the closed interval [0, 1].
*/
lerp(v: Vector2Like, alpha: number): this;
/**
* Sets this vector to be the vector linearly interpolated between v1 and v2 where alpha is the distance along the line connecting the two vectors - alpha = 0 will be v1, and alpha = 1 will be v2.
* @param v1 the starting vector.
* @param v2 vector to interpolate towards.
* @param alpha interpolation factor in the closed interval [0, 1].
*/
lerpVectors(v1: Vector2Like, v2: Vector2Like, alpha: number): this;
/**
* Checks for strict equality of this vector and v.
*/
equals(v: Vector2Like): boolean;
/**
* Sets this vector's x and y value from the provided array or array-like.
* @param array the source array or array-like.
* @param offset (optional) offset into the array. Default is 0.
*/
fromArray(array: number[] | ArrayLike, offset?: number): this;
/**
* Returns an array [x, y], or copies x and y into the provided array.
* @param array (optional) array to store the vector to. If this is not provided, a new array will be created.
* @param offset (optional) optional offset into the array.
* @return The created or provided array.
*/
toArray(array?: number[], offset?: number): number[];
toArray(array?: Vector2Tuple, offset?: 0): Vector2Tuple;
/**
* Copies x and y into the provided array-like.
* @param array array-like to store the vector to.
* @param offset (optional) optional offset into the array.
* @return The provided array-like.
*/
toArray(array: ArrayLike, offset?: number): ArrayLike;
/**
* Sets this vector's x and y values from the attribute.
* @param attribute the source attribute.
* @param index index in the attribute.
*/
fromBufferAttribute(attribute: BufferAttribute, index: number): this;
/**
* Rotates the vector around center by angle radians.
* @param center the point around which to rotate.
* @param angle the angle to rotate, in radians.
*/
rotateAround(center: Vector2Like, angle: number): this;
/**
* Sets this vector's x and y from Math.random
*/
random(): this;
/**
* Iterating through a Vector2 instance will yield its components (x, y) in the corresponding order.
*/
[Symbol.iterator](): Iterator;
}
declare interface Vector2Like {
readonly x: number;
readonly y: number;
}
declare type Vector2Tuple = [x: number, y: number];
/**
* 3D vector.
*
* see {@link https://github.com/mrdoob/three.js/blob/master/src/math/Vector3.js}
*
* @example
* const a = new THREE.Vector3( 1, 0, 0 );
* const b = new THREE.Vector3( 0, 1, 0 );
* const c = new THREE.Vector3();
* c.crossVectors( a, b );
*/
declare class Vector3 {
constructor(x?: number, y?: number, z?: number);
/**
* @default 0
*/
x: number;
/**
* @default 0
*/
y: number;
/**
* @default 0
*/
z: number;
readonly isVector3: true;
/**
* Sets value of this vector.
*/
set(x: number, y: number, z?: number): this;
/**
* Sets all values of this vector.
*/
setScalar(scalar: number): this;
/**
* Sets x value of this vector.
*/
setX(x: number): this;
/**
* Sets y value of this vector.
*/
setY(y: number): this;
/**
* Sets z value of this vector.
*/
setZ(z: number): this;
setComponent(index: number, value: number): this;
getComponent(index: number): number;
/**
* Clones this vector.
*/
clone(): this;
/**
* Copies value of v to this vector.
*/
copy(v: Vector3Like): this;
/**
* Adds v to this vector.
*/
add(v: Vector3Like): this;
addScalar(s: number): this;
/**
* Sets this vector to a + b.
*/
addVectors(a: Vector3Like, b: Vector3Like): this;
addScaledVector(v: Vector3Like, s: number): this;
/**
* Subtracts v from this vector.
*/
sub(v: Vector3Like): this;
subScalar(s: number): this;
/**
* Sets this vector to a - b.
*/
subVectors(a: Vector3Like, b: Vector3Like): this;
multiply(v: Vector3Like): this;
/**
* Multiplies this vector by scalar s.
*/
multiplyScalar(s: number): this;
multiplyVectors(a: Vector3Like, b: Vector3Like): this;
applyEuler(euler: Euler): this;
applyAxisAngle(axis: Vector3Like, angle: number): this;
applyMatrix3(m: Matrix3): this;
applyNormalMatrix(m: Matrix3): this;
applyMatrix4(m: Matrix4): this;
applyQuaternion(q: QuaternionLike): this;
project(camera: Camera): this;
unproject(camera: Camera): this;
transformDirection(m: Matrix4): this;
divide(v: Vector3Like): this;
/**
* Divides this vector by scalar s.
* Set vector to ( 0, 0, 0 ) if s == 0.
*/
divideScalar(s: number): this;
min(v: Vector3Like): this;
max(v: Vector3Like): this;
clamp(min: Vector3Like, max: Vector3Like): this;
clampScalar(min: number, max: number): this;
clampLength(min: number, max: number): this;
floor(): this;
ceil(): this;
round(): this;
roundToZero(): this;
/**
* Inverts this vector.
*/
negate(): this;
/**
* Computes dot product of this vector and v.
*/
dot(v: Vector3Like): number;
/**
* Computes squared length of this vector.
*/
lengthSq(): number;
/**
* Computes length of this vector.
*/
length(): number;
/**
* Computes the Manhattan length of this vector.
*
* see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry}
*/
manhattanLength(): number;
/**
* Normalizes this vector.
*/
normalize(): this;
/**
* Normalizes this vector and multiplies it by l.
*/
setLength(l: number): this;
lerp(v: Vector3Like, alpha: number): this;
lerpVectors(v1: Vector3Like, v2: Vector3Like, alpha: number): this;
/**
* Sets this vector to cross product of itself and v.
*/
cross(v: Vector3Like): this;
/**
* Sets this vector to cross product of a and b.
*/
crossVectors(a: Vector3Like, b: Vector3Like): this;
projectOnVector(v: Vector3): this;
projectOnPlane(planeNormal: Vector3): this;
reflect(normal: Vector3Like): this;
angleTo(v: Vector3): number;
/**
* Computes distance of this vector to v.
*/
distanceTo(v: Vector3Like): number;
/**
* Computes squared distance of this vector to v.
*/
distanceToSquared(v: Vector3Like): number;
/**
* Computes the Manhattan length (distance) from this vector to the given vector v
*
* see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry}
*/
manhattanDistanceTo(v: Vector3Like): number;
setFromSpherical(s: Spherical): this;
setFromSphericalCoords(r: number, phi: number, theta: number): this;
setFromCylindrical(s: Cylindrical): this;
setFromCylindricalCoords(radius: number, theta: number, y: number): this;
setFromMatrixPosition(m: Matrix4): this;
setFromMatrixScale(m: Matrix4): this;
setFromMatrixColumn(matrix: Matrix4, index: number): this;
setFromMatrix3Column(matrix: Matrix3, index: number): this;
/**
* Sets this vector's {@link x}, {@link y} and {@link z} components from the x, y, and z components of the specified {@link Euler Euler Angle}.
*/
setFromEuler(e: Euler): this;
/**
* Sets this vector's {@link x}, {@link y} and {@link z} components from the r, g, and b components of the specified
* {@link Color | color}.
*/
setFromColor(color: RGB): this;
/**
* Checks for strict equality of this vector and v.
*/
equals(v: Vector3Like): boolean;
/**
* Sets this vector's x, y and z value from the provided array or array-like.
* @param array the source array or array-like.
* @param offset (optional) offset into the array. Default is 0.
*/
fromArray(array: number[] | ArrayLike, offset?: number): this;
/**
* Returns an array [x, y, z], or copies x, y and z into the provided array.
* @param array (optional) array to store the vector to. If this is not provided, a new array will be created.
* @param offset (optional) optional offset into the array.
* @return The created or provided array.
*/
toArray(array?: number[], offset?: number): number[];
toArray(array?: Vector3Tuple, offset?: 0): Vector3Tuple;
/**
* Copies x, y and z into the provided array-like.
* @param array array-like to store the vector to.
* @param offset (optional) optional offset into the array-like.
* @return The provided array-like.
*/
toArray(array: ArrayLike, offset?: number): ArrayLike;
fromBufferAttribute(attribute: BufferAttribute | InterleavedBufferAttribute, index: number): this;
/**
* Sets this vector's x, y and z from Math.random
*/
random(): this;
randomDirection(): this;
/**
* Iterating through a Vector3 instance will yield its components (x, y, z) in the corresponding order.
*/
[Symbol.iterator](): Iterator;
}
declare interface Vector3Like {
readonly x: number;
readonly y: number;
readonly z: number;
}
declare type Vector3Tuple = [number, number, number];
/**
* 4D vector.
*/
declare class Vector4 {
constructor(x?: number, y?: number, z?: number, w?: number);
/**
* @default 0
*/
x: number;
/**
* @default 0
*/
y: number;
/**
* @default 0
*/
z: number;
/**
* @default 0
*/
w: number;
width: number;
height: number;
readonly isVector4: true;
/**
* Sets value of this vector.
*/
set(x: number, y: number, z: number, w: number): this;
/**
* Sets all values of this vector.
*/
setScalar(scalar: number): this;
/**
* Sets X component of this vector.
*/
setX(x: number): this;
/**
* Sets Y component of this vector.
*/
setY(y: number): this;
/**
* Sets Z component of this vector.
*/
setZ(z: number): this;
/**
* Sets w component of this vector.
*/
setW(w: number): this;
setComponent(index: number, value: number): this;
getComponent(index: number): number;
/**
* Clones this vector.
*/
clone(): this;
/**
* Copies value of v to this vector.
*/
copy(v: Vector4Like): this;
/**
* Adds v to this vector.
*/
add(v: Vector4Like): this;
addScalar(scalar: number): this;
/**
* Sets this vector to a + b.
*/
addVectors(a: Vector4Like, b: Vector4Like): this;
addScaledVector(v: Vector4Like, s: number): this;
/**
* Subtracts v from this vector.
*/
sub(v: Vector4Like): this;
subScalar(s: number): this;
/**
* Sets this vector to a - b.
*/
subVectors(a: Vector4Like, b: Vector4Like): this;
multiply(v: Vector4Like): this;
/**
* Multiplies this vector by scalar s.
*/
multiplyScalar(s: number): this;
applyMatrix4(m: Matrix4): this;
divide(v: Vector4Like): this;
/**
* Divides this vector by scalar s.
* Set vector to ( 0, 0, 0 ) if s == 0.
*/
divideScalar(s: number): this;
/**
* http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm
* @param q is assumed to be normalized
*/
setAxisAngleFromQuaternion(q: QuaternionLike): this;
/**
* http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm
* @param m assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)
*/
setAxisAngleFromRotationMatrix(m: Matrix4): this;
/**
* Sets this vector to the position elements of the
* [transformation matrix]{@link https://en.wikipedia.org/wiki/Transformation_matrix} m.
*/
setFromMatrixPosition(m: Matrix4): this;
min(v: Vector4Like): this;
max(v: Vector4Like): this;
clamp(min: Vector4Like, max: Vector4Like): this;
clampScalar(min: number, max: number): this;
floor(): this;
ceil(): this;
round(): this;
roundToZero(): this;
/**
* Inverts this vector.
*/
negate(): this;
/**
* Computes dot product of this vector and v.
*/
dot(v: Vector4Like): number;
/**
* Computes squared length of this vector.
*/
lengthSq(): number;
/**
* Computes length of this vector.
*/
length(): number;
/**
* Computes the Manhattan length of this vector.
*
* see {@link http://en.wikipedia.org/wiki/Taxicab_geometry|Wikipedia: Taxicab Geometry}
*/
manhattanLength(): number;
/**
* Normalizes this vector.
*/
normalize(): this;
/**
* Normalizes this vector and multiplies it by l.
*/
setLength(length: number): this;
/**
* Linearly interpolate between this vector and v with alpha factor.
*/
lerp(v: Vector4Like, alpha: number): this;
lerpVectors(v1: Vector4Like, v2: Vector4Like, alpha: number): this;
/**
* Checks for strict equality of this vector and v.
*/
equals(v: Vector4Like): boolean;
/**
* Sets this vector's x, y, z and w value from the provided array or array-like.
* @param array the source array or array-like.
* @param offset (optional) offset into the array. Default is 0.
*/
fromArray(array: number[] | ArrayLike, offset?: number): this;
/**
* Returns an array [x, y, z, w], or copies x, y, z and w into the provided array.
* @param array (optional) array to store the vector to. If this is not provided, a new array will be created.
* @param offset (optional) optional offset into the array.
* @return The created or provided array.
*/
toArray(array?: number[], offset?: number): number[];
toArray(array?: Vector4Tuple, offset?: 0): Vector4Tuple;
/**
* Copies x, y, z and w into the provided array-like.
* @param array array-like to store the vector to.
* @param offset (optional) optional offset into the array-like.
* @return The provided array-like.
*/
toArray(array: ArrayLike, offset?: number): ArrayLike;
fromBufferAttribute(attribute: BufferAttribute, index: number): this;
/**
* Sets this vector's x, y, z and w from Math.random
*/
random(): this;
/**
* Iterating through a Vector4 instance will yield its components (x, y, z, w) in the corresponding order.
*/
[Symbol.iterator](): Iterator;
}
declare interface Vector4Like {
readonly x: number;
readonly y: number;
readonly z: number;
readonly w: number;
}
declare type Vector4Tuple = [number, number, number, number];
export { VrmCanvas }
export declare type VrmCanvasExposed = {
resetCamera: () => void;
resetCameraPose?: () => void;
};
declare const VSMShadowMap: 3;
declare interface WebGLAttribute {
buffer: WebGLBuffer;
type: number;
bytesPerElement: number;
version: number;
size: number;
}
declare class WebGLAttributes {
constructor(gl: WebGLRenderingContext | WebGL2RenderingContext);
get(attribute: BufferAttribute | InterleavedBufferAttribute | GLBufferAttribute):
| WebGLAttribute
| undefined;
remove(attribute: BufferAttribute | InterleavedBufferAttribute | GLBufferAttribute): void;
update(attribute: BufferAttribute | InterleavedBufferAttribute | GLBufferAttribute, bufferType: number): void;
}
declare class WebGLBindingStates {
constructor(gl: WebGLRenderingContext, attributes: WebGLAttributes);
setup(
object: Object3D,
material: Material,
program: WebGLProgram_2,
geometry: BufferGeometry,
index: BufferAttribute,
): void;
reset(): void;
resetDefaultState(): void;
dispose(): void;
releaseStatesOfGeometry(): void;
releaseStatesOfProgram(): void;
initAttributes(): void;
enableAttribute(attribute: number): void;
disableUnusedAttributes(): void;
}
declare class WebGLCapabilities {
constructor(gl: WebGLRenderingContext, extensions: any, parameters: WebGLCapabilitiesParameters);
readonly isWebGL2: boolean;
getMaxAnisotropy: () => number;
getMaxPrecision: (precision: string) => string;
textureFormatReadable: (textureFormat: PixelFormat) => boolean;
textureTypeReadable: (textureType: TextureDataType) => boolean;
precision: string;
logarithmicDepthBuffer: boolean;
reversedDepthBuffer: boolean;
maxTextures: number;
maxVertexTextures: number;
maxTextureSize: number;
maxCubemapSize: number;
maxAttributes: number;
maxVertexUniforms: number;
maxVaryings: number;
maxFragmentUniforms: number;
maxSamples: number;
samples: number;
}
declare interface WebGLCapabilitiesParameters {
/**
* shader precision. Can be "highp", "mediump" or "lowp".
*/
precision?: string | undefined;
/**
* default is false.
*/
logarithmicDepthBuffer?: boolean | undefined;
/**
* default is false.
*/
reversedDepthBuffer?: boolean | undefined;
}
declare class WebGLColorBuffer {
setMask(colorMask: boolean): void;
setLocked(lock: boolean): void;
setClear(r: number, g: number, b: number, a: number, premultipliedAlpha: boolean): void;
reset(): void;
}
declare const WebGLCoordinateSystem: 2000;
declare interface WebGLDebug {
/**
* Enables error checking and reporting when shader programs are being compiled.
*/
checkShaderErrors: boolean;
/**
* A callback function that can be used for custom error reporting. The callback receives the WebGL context, an
* instance of WebGLProgram as well two instances of WebGLShader representing the vertex and fragment shader.
* Assigning a custom function disables the default error reporting.
* @default `null`
*/
onShaderError:
| ((
gl: WebGLRenderingContext,
program: WebGLProgram_2,
glVertexShader: WebGLShader,
glFragmentShader: WebGLShader,
) => void)
| null;
}
declare class WebGLDepthBuffer {
constructor();
setReversed(value: boolean): void;
getReversed(): boolean;
setTest(depthTest: boolean): void;
setMask(depthMask: boolean): void;
setFunc(depthFunc: DepthModes): void;
setLocked(lock: boolean): void;
setClear(depth: number): void;
reset(): void;
}
declare class WebGLExtensions {
constructor(gl: WebGLRenderingContext);
has(name: string): boolean;
init(): void;
get(name: string): unknown;
}
declare class WebGLGeometries {
constructor(gl: WebGLRenderingContext, attributes: WebGLAttributes, info: WebGLInfo);
get(object: Object3D, geometry: BufferGeometry): BufferGeometry;
update(geometry: BufferGeometry): void;
getWireframeAttribute(geometry: BufferGeometry): BufferAttribute;
}
/**
* An object with a series of statistical information about the graphics board memory and the rendering process.
*/
declare class WebGLInfo {
constructor(gl: WebGLRenderingContext);
/**
* @default true
*/
autoReset: boolean;
/**
* @default { geometries: 0, textures: 0 }
*/
memory: {
geometries: number;
textures: number;
};
/**
* @default null
*/
programs: WebGLProgram_2[] | null;
/**
* @default { frame: 0, calls: 0, triangles: 0, points: 0, lines: 0 }
*/
render: {
calls: number;
frame: number;
lines: number;
points: number;
triangles: number;
};
update(count: number, mode: number, instanceCount: number): void;
reset(): void;
}
declare class WebGLObjects {
constructor(
gl: WebGLRenderingContext,
geometries: WebGLGeometries,
attributes: WebGLAttributes,
bindingStates: WebGLBindingStates,
info: WebGLInfo,
);
update(object: Object3D): BufferGeometry;
dispose(): void;
}
declare class WebGLProgram_2 {
constructor(renderer: WebGLRenderer, cacheKey: string, parameters: object);
name: string;
id: number;
cacheKey: string; // unique identifier for this program, used for looking up compiled programs from cache.
/**
* @default 1
*/
usedTimes: number;
program: unknown; // TODO This should be the WebGLProgram in the DOM types
vertexShader: WebGLShader;
fragmentShader: WebGLShader;
getUniforms(): WebGLUniforms;
getAttributes(): unknown;
destroy(): void;
}
declare interface WebGLProgramParameters {
shaderID: string;
shaderType: string;
shaderName: string;
vertexShader: string;
fragmentShader: string;
defines: { [define: string]: string | number | boolean } | undefined;
customVertexShaderID: string | undefined;
customFragmentShaderID: string | undefined;
isRawShaderMaterial: boolean;
glslVersion: GLSLVersion | null | undefined;
precision: "lowp" | "mediump" | "highp";
batching: boolean;
batchingColor: boolean;
instancing: boolean;
instancingColor: boolean;
instancingMorph: boolean;
outputColorSpace: string;
alphaToCoverage: boolean;
map: boolean;
matcap: boolean;
envMap: boolean;
envMapMode: Mapping | false;
envMapCubeUVHeight: number | null;
aoMap: boolean;
lightMap: boolean;
bumpMap: boolean;
normalMap: boolean;
displacementMap: boolean;
emissiveMap: boolean;
normalMapObjectSpace: boolean;
normalMapTangentSpace: boolean;
packedNormalMap: boolean;
metalnessMap: boolean;
roughnessMap: boolean;
anisotropy: boolean;
anisotropyMap: boolean;
clearcoat: boolean;
clearcoatMap: boolean;
clearcoatNormalMap: boolean;
clearcoatRoughnessMap: boolean;
dispersion: boolean;
iridescence: boolean;
iridescenceMap: boolean;
iridescenceThicknessMap: boolean;
sheen: boolean;
sheenColorMap: boolean;
sheenRoughnessMap: boolean;
specularMap: boolean;
specularColorMap: boolean;
specularIntensityMap: boolean;
transmission: boolean;
transmissionMap: boolean;
thicknessMap: boolean;
gradientMap: boolean;
opaque: boolean;
alphaMap: boolean;
alphaTest: boolean;
alphaHash: boolean;
combine: Combine | undefined;
//
mapUv: string | false;
aoMapUv: string | false;
lightMapUv: string | false;
bumpMapUv: string | false;
normalMapUv: string | false;
displacementMapUv: string | false;
emissiveMapUv: string | false;
metalnessMapUv: string | false;
roughnessMapUv: string | false;
anisotropyMapUv: string | false;
clearcoatMapUv: string | false;
clearcoatNormalMapUv: string | false;
clearcoatRoughnessMapUv: string | false;
iridescenceMapUv: string | false;
iridescenceThicknessMapUv: string | false;
sheenColorMapUv: string | false;
sheenRoughnessMapUv: string | false;
specularMapUv: string | false;
specularColorMapUv: string | false;
specularIntensityMapUv: string | false;
transmissionMapUv: string | false;
thicknessMapUv: string | false;
alphaMapUv: string | false;
//
vertexTangents: boolean;
vertexNormals: boolean;
vertexColors: boolean;
vertexAlphas: boolean;
vertexUv1s: boolean;
vertexUv2s: boolean;
vertexUv3s: boolean;
pointsUvs: boolean;
fog: boolean;
useFog: boolean;
fogExp2: boolean;
flatShading: boolean;
sizeAttenuation: boolean;
logarithmicDepthBuffer: boolean;
reverseDepthBuffer: boolean;
skinning: boolean;
hasPositionAttribute: boolean;
morphTargets: boolean;
morphNormals: boolean;
morphColors: boolean;
morphTargetsCount: number;
morphTextureStride: number;
numDirLights: number;
numPointLights: number;
numSpotLights: number;
numSpotLightMaps: number;
numRectAreaLights: number;
numHemiLights: number;
numDirLightShadows: number;
numPointLightShadows: number;
numSpotLightShadows: number;
numSpotLightShadowsWithMaps: number;
numLightProbes: number;
numLightProbeGrids: number;
numClippingPlanes: number;
numClipIntersection: number;
dithering: boolean;
shadowMapEnabled: boolean;
shadowMapType: ShadowMapType;
toneMapping: ToneMapping;
decodeVideoTexture: boolean;
decodeVideoTextureEmissive: boolean;
premultipliedAlpha: boolean;
doubleSided: boolean;
flipSided: boolean;
useDepthPacking: boolean;
depthPacking: DepthPackingStrategies | 0;
index0AttributeName: string | undefined;
extensionClipCullDistance: boolean;
extensionMultiDraw: boolean;
rendererExtensionParallelShaderCompile: boolean;
customProgramCacheKey: string;
}
declare interface WebGLProgramParametersWithUniforms extends WebGLProgramParameters {
uniforms: { [uniform: string]: IUniform };
}
declare class WebGLProperties {
constructor();
has: (object: unknown) => boolean;
get: (object: unknown) => unknown;
remove: (object: unknown) => void;
update: (object: unknown, key: unknown, value: unknown) => unknown;
dispose: () => void;
}
/**
* The WebGL renderer displays your beautifully crafted scenes using WebGL, if your device supports it.
* This renderer has way better performance than CanvasRenderer.
*
* see {@link https://github.com/mrdoob/three.js/blob/master/src/renderers/WebGLRenderer.js|src/renderers/WebGLRenderer.js}
*/
declare class WebGLRenderer {
/**
* parameters is an optional object with properties defining the renderer's behavior.
* The constructor also accepts no parameters at all.
* In all cases, it will assume sane defaults when parameters are missing.
*/
constructor(parameters?: WebGLRendererParameters);
/**
* A Canvas where the renderer draws its output.
* This is automatically created by the renderer in the constructor (if not provided already); you just need to add it to your page.
* @default document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' )
*/
domElement: HTMLCanvasElement;
/**
* Defines whether the renderer should automatically clear its output before rendering.
* @default true
*/
autoClear: boolean;
/**
* If autoClear is true, defines whether the renderer should clear the color buffer. Default is true.
* @default true
*/
autoClearColor: boolean;
/**
* If autoClear is true, defines whether the renderer should clear the depth buffer. Default is true.
* @default true
*/
autoClearDepth: boolean;
/**
* If autoClear is true, defines whether the renderer should clear the stencil buffer. Default is true.
* @default true
*/
autoClearStencil: boolean;
/**
* Debug configurations.
* @default { checkShaderErrors: true }
*/
debug: WebGLDebug;
/**
* Defines whether the renderer should sort objects. Default is true.
* @default true
*/
sortObjects: boolean;
/**
* @default []
*/
clippingPlanes: Plane[];
/**
* @default false
*/
localClippingEnabled: boolean;
extensions: WebGLExtensions;
/**
* Color space used for output to HTMLCanvasElement. Supported values are
* {@link SRGBColorSpace} and {@link LinearSRGBColorSpace}.
* @default THREE.SRGBColorSpace.
*/
get outputColorSpace(): string;
set outputColorSpace(colorSpace: string);
get coordinateSystem(): typeof WebGLCoordinateSystem;
/**
* @default THREE.NoToneMapping
*/
toneMapping: ToneMapping;
/**
* @default 1
*/
toneMappingExposure: number;
/**
* The normalized resolution scale for the transmission render target, measured in percentage of viewport
* dimensions. Lowering this value can result in significant improvements to {@link MeshPhysicalMaterial}
* transmission performance. Default is `1`.
*/
transmissionResolutionScale: number;
info: WebGLInfo;
shadowMap: WebGLShadowMap;
capabilities: WebGLCapabilities;
properties: WebGLProperties;
renderLists: WebGLRenderLists;
state: WebGLState;
xr: WebXRManager;
/**
* Return the WebGL context.
*/
getContext(): WebGLRenderingContext | WebGL2RenderingContext;
getContextAttributes(): WebGLContextAttributes;
forceContextLoss(): void;
forceContextRestore(): void;
getPixelRatio(): number;
setPixelRatio(value: number): void;
getSize(target: Vector2): Vector2;
/**
* Resizes the output canvas to (width, height), and also sets the viewport to fit that size, starting in (0, 0).
*/
setSize(width: number, height: number, updateStyle?: boolean): void;
getDrawingBufferSize(target: Vector2): Vector2;
setDrawingBufferSize(width: number, height: number, pixelRatio: number): void;
setEffects(effects: Effect[] | null): void;
getCurrentViewport(target: Vector4): Vector4;
/**
* Copies the viewport into target.
*/
getViewport(target: Vector4): Vector4;
/**
* Sets the viewport to render from (x, y) to (x + width, y + height).
* (x, y) is the lower-left corner of the region.
*/
setViewport(x: Vector4 | number, y?: number, width?: number, height?: number): void;
/**
* Copies the scissor area into target.
*/
getScissor(target: Vector4): Vector4;
/**
* Sets the scissor area from (x, y) to (x + width, y + height).
*/
setScissor(x: Vector4 | number, y?: number, width?: number, height?: number): void;
/**
* Returns true if scissor test is enabled; returns false otherwise.
*/
getScissorTest(): boolean;
/**
* Enable the scissor test. When this is enabled, only the pixels within the defined scissor area will be affected by further renderer actions.
*/
setScissorTest(enable: boolean): void;
/**
* Sets the custom opaque sort function for the WebGLRenderLists. Pass null to use the default painterSortStable function.
*/
setOpaqueSort(method: ((a: any, b: any) => number) | null): void;
/**
* Sets the custom transparent sort function for the WebGLRenderLists. Pass null to use the default reversePainterSortStable function.
*/
setTransparentSort(method: ((a: any, b: any) => number) | null): void;
/**
* Returns a THREE.Color instance with the current clear color.
*/
getClearColor(target: Color): Color;
/**
* Sets the clear color, using color for the color and alpha for the opacity.
*/
setClearColor(color: ColorRepresentation, alpha?: number): void;
/**
* Returns a float with the current clear alpha. Ranges from 0 to 1.
*/
getClearAlpha(): number;
setClearAlpha(alpha: number): void;
/**
* Tells the renderer to clear its color, depth or stencil drawing buffer(s).
* Arguments default to true
*/
clear(color?: boolean, depth?: boolean, stencil?: boolean): void;
clearColor(): void;
clearDepth(): void;
clearStencil(): void;
setNodesHandler(nodesHandler: NodesHandler): void;
dispose(): void;
renderBufferDirect(
camera: Camera,
scene: Scene,
geometry: BufferGeometry,
material: Material,
object: Object3D,
group: GeometryGroup,
): void;
/**
* A build in function that can be used instead of requestAnimationFrame. For WebXR projects this function must be used.
* @param callback The function will be called every available frame. If `null` is passed it will stop any already ongoing animation.
*/
setAnimationLoop(callback: XRFrameRequestCallback | null): void;
/**
* Compiles all materials in the scene with the camera. This is useful to precompile shaders before the first
* rendering. If you want to add a 3D object to an existing scene, use the third optional parameter for applying the
* target scene.
* Note that the (target) scene's lighting should be configured before calling this method.
*/
compile: (scene: Object3D, camera: Camera, targetScene?: Scene | null) => Set;
/**
* Asynchronous version of {@link compile}(). The method returns a Promise that resolves when the given scene can be
* rendered without unnecessary stalling due to shader compilation.
* This method makes use of the KHR_parallel_shader_compile WebGL extension.
*/
compileAsync: (scene: Object3D, camera: Camera, targetScene?: Scene | null) => Promise;
/**
* Render a scene or an object using a camera.
* The render is done to a previously specified {@link WebGLRenderTarget#renderTarget .renderTarget} set by calling
* {@link WebGLRenderer#setRenderTarget .setRenderTarget} or to the canvas as usual.
*
* By default render buffers are cleared before rendering but you can prevent this by setting the property
* {@link WebGLRenderer#autoClear autoClear} to false. If you want to prevent only certain buffers being cleared
* you can set either the {@link WebGLRenderer#autoClearColor autoClearColor},
* {@link WebGLRenderer#autoClearStencil autoClearStencil} or {@link WebGLRenderer#autoClearDepth autoClearDepth}
* properties to false. To forcibly clear one ore more buffers call {@link WebGLRenderer#clear .clear}.
*/
render(scene: Object3D, camera: Camera): void;
/**
* Returns the current active cube face.
*/
getActiveCubeFace(): number;
/**
* Returns the current active mipmap level.
*/
getActiveMipmapLevel(): number;
/**
* Returns the current render target. If no render target is set, null is returned.
*/
getRenderTarget(): WebGLRenderTarget | null;
/**
* Sets the active render target.
*
* @param renderTarget The {@link WebGLRenderTarget renderTarget} that needs to be activated. When `null` is given, the canvas is set as the active render target instead.
* @param activeCubeFace Specifies the active cube side (PX 0, NX 1, PY 2, NY 3, PZ 4, NZ 5) of {@link WebGLCubeRenderTarget}.
* @param activeMipmapLevel Specifies the active mipmap level.
*/
setRenderTarget(
renderTarget: WebGLRenderTarget | WebGLRenderTarget | null,
activeCubeFace?: number,
activeMipmapLevel?: number,
): void;
readRenderTargetPixels(
renderTarget: WebGLRenderTarget | WebGLRenderTarget,
x: number,
y: number,
width: number,
height: number,
buffer: TypedArray,
activeCubeFaceIndex?: number,
textureIndex?: number,
): void;
readRenderTargetPixelsAsync(
renderTarget: WebGLRenderTarget | WebGLRenderTarget,
x: number,
y: number,
width: number,
height: number,
buffer: TypedArray,
activeCubeFaceIndex?: number,
textureIndex?: number,
): Promise;
/**
* Copies a region of the currently bound framebuffer into the selected mipmap level of the selected texture.
* This region is defined by the size of the destination texture's mip level, offset by the input position.
*
* @param texture Specifies the destination texture.
* @param position Specifies the pixel offset from which to copy out of the framebuffer.
* @param level Specifies the destination mipmap level of the texture.
*/
copyFramebufferToTexture(texture: Texture, position?: Vector2 | null, level?: number): void;
/**
* Copies the pixels of a texture in the bounds [srcRegion]{@link Box3} in the destination texture starting from the
* given position. 2D Texture, 3D Textures, or a mix of the two can be used as source and destination texture
* arguments for copying between layers of 3d textures
*
* The `depthTexture` and `texture` property of render targets are supported as well.
*
* When using render target textures as `srcTexture` and `dstTexture`, you must make sure both render targets are
* initialized e.g. via {@link .initRenderTarget}().
*
* @param srcTexture Specifies the source texture.
* @param dstTexture Specifies the destination texture.
* @param srcRegion Specifies the bounds
* @param dstPosition Specifies the pixel offset into the dstTexture where the copy will occur.
* @param srcLevel Specifies the source mipmap level of the texture.
* @param dstLevel Specifies the destination mipmap level of the texture.
*/
copyTextureToTexture(
srcTexture: Texture,
dstTexture: Texture,
srcRegion?: Box2 | Box3 | null,
dstPosition?: Vector2 | Vector3 | null,
srcLevel?: number,
dstLevel?: number,
): void;
/**
* Initializes the given WebGLRenderTarget memory. Useful for initializing a render target so data can be copied
* into it using {@link WebGLRenderer.copyTextureToTexture} before it has been rendered to.
* @param target
*/
initRenderTarget(target: WebGLRenderTarget): void;
/**
* Initializes the given texture. Can be used to preload a texture rather than waiting until first render (which can cause noticeable lags due to decode and GPU upload overhead).
*
* @param texture The texture to Initialize.
*/
initTexture(texture: Texture): void;
/**
* Can be used to reset the internal WebGL state.
*/
resetState(): void;
}
declare interface WebGLRendererParameters extends WebGLCapabilitiesParameters {
/**
* A Canvas where the renderer draws its output.
*/
canvas?: HTMLCanvasElement | OffscreenCanvas_2 | undefined;
/**
* A WebGL Rendering Context.
* (https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext)
* Default is null
*/
context?: WebGLRenderingContext | undefined;
/**
* default is false.
*/
alpha?: boolean | undefined;
/**
* default is true.
*/
premultipliedAlpha?: boolean | undefined;
/**
* default is false.
*/
antialias?: boolean | undefined;
/**
* default is false.
*/
stencil?: boolean | undefined;
/**
* default is false.
*/
preserveDrawingBuffer?: boolean | undefined;
/**
* Can be "high-performance", "low-power" or "default"
*/
powerPreference?: WebGLPowerPreference | undefined;
/**
* default is true.
*/
depth?: boolean | undefined;
/**
* default is false.
*/
failIfMajorPerformanceCaveat?: boolean | undefined;
/**
* @default UnsignedByteType
*/
outputBufferType?: TextureDataType | undefined;
}
declare class WebGLRenderList {
constructor(properties: WebGLProperties);
/**
* @default []
*/
opaque: RenderItem[];
/**
* @default []
*/
transparent: RenderItem[];
/**
* @default []
*/
transmissive: RenderItem[];
init(): void;
push(
object: Object3D,
geometry: BufferGeometry | null,
material: Material,
groupOrder: number,
z: number,
group: Group | null,
): void;
unshift(
object: Object3D,
geometry: BufferGeometry | null,
material: Material,
groupOrder: number,
z: number,
group: Group | null,
): void;
sort(
opaqueSort: (a: any, b: any) => number,
transparentSort: (a: any, b: any) => number,
reversedDepth: boolean,
): void;
finish(): void;
}
declare class WebGLRenderLists {
constructor(properties: WebGLProperties);
dispose(): void;
get(scene: Scene, renderCallDepth: number): WebGLRenderList;
}
declare class WebGLRenderTarget extends RenderTarget {
constructor(width?: number, height?: number, options?: RenderTargetOptions);
readonly isWebGLRenderTarget: true;
}
declare class WebGLShadowMap {
constructor(_renderer: WebGLRenderer, _objects: WebGLObjects, _capabilities: WebGLCapabilities);
/**
* @default false
*/
enabled: boolean;
/**
* @default true
*/
autoUpdate: boolean;
/**
* @default false
*/
needsUpdate: boolean;
/**
* @default THREE.PCFShadowMap
*/
type: ShadowMapType;
render(shadowsArray: Light[], scene: Scene, camera: Camera): void;
}
declare class WebGLState {
constructor(gl: WebGLRenderingContext, extensions: WebGLExtensions);
buffers: {
color: WebGLColorBuffer;
depth: WebGLDepthBuffer;
stencil: WebGLStencilBuffer;
};
enable(id: number): void;
disable(id: number): void;
bindFramebuffer(target: number, framebuffer: WebGLFramebuffer | null): void;
drawBuffers(renderTarget: WebGLRenderTarget | null, framebuffer: WebGLFramebuffer | null): void;
useProgram(program: WebGLProgram): boolean;
setBlending(
blending: Blending,
blendEquation?: BlendingEquation,
blendSrc?: BlendingSrcFactor,
blendDst?: BlendingDstFactor,
blendEquationAlpha?: BlendingEquation,
blendSrcAlpha?: BlendingSrcFactor,
blendDstAlpha?: BlendingDstFactor,
premultiplyAlpha?: boolean,
): void;
setMaterial(material: Material, frontFaceCW: boolean, hardwareClippingPlanes: number): void;
setFlipSided(flipSided: boolean): void;
setCullFace(cullFace: CullFace): void;
setLineWidth(width: number): void;
setPolygonOffset(polygonoffset: boolean, factor?: number, units?: number): void;
setScissorTest(scissorTest: boolean): void;
activeTexture(webglSlot: number): void;
bindTexture(webglType: number, webglTexture: WebGLTexture, webglSlot?: number): void;
unbindTexture(): void;
pixelStorei(name: GLenum, value: GLint | GLboolean): void;
getParameter(name: GLenum): unknown;
// Same interface as https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/compressedTexImage2D
compressedTexImage2D(
target: GLenum,
level: GLint,
internalformat: GLenum,
width: GLsizei,
height: GLsizei,
border: GLint,
imageSize: GLsizei,
offset: GLintptr,
): void;
compressedTexImage2D(
target: GLenum,
level: GLint,
internalformat: GLenum,
width: GLsizei,
height: GLsizei,
border: GLint,
srcData: ArrayBufferView,
srcOffset?: number,
srcLengthOverride?: GLuint,
): void;
compressedTexImage3D(
target: GLenum,
level: GLint,
internalformat: GLenum,
width: GLsizei,
height: GLsizei,
depth: GLsizei,
border: GLint,
imageSize: GLsizei,
offset: GLintptr,
): void;
compressedTexImage3D(
target: GLenum,
level: GLint,
internalformat: GLenum,
width: GLsizei,
height: GLsizei,
depth: GLsizei,
border: GLint,
srcData: ArrayBufferView,
srcOffset?: number,
srcLengthOverride?: GLuint,
): void;
texSubImage2D(
target: GLenum,
level: GLint,
xoffset: GLint,
yoffset: GLint,
width: GLsizei,
height: GLsizei,
format: GLenum,
type: GLenum,
pixels: ArrayBufferView | null,
): void;
texSubImage2D(
target: GLenum,
level: GLint,
xoffset: GLint,
yoffset: GLint,
format: GLenum,
type: GLenum,
source: TexImageSource,
): void;
texSubImage2D(
target: GLenum,
level: GLint,
xoffset: GLint,
yoffset: GLint,
width: GLsizei,
height: GLsizei,
format: GLenum,
type: GLenum,
pboOffset: GLintptr,
): void;
texSubImage2D(
target: GLenum,
level: GLint,
xoffset: GLint,
yoffset: GLint,
width: GLsizei,
height: GLsizei,
format: GLenum,
type: GLenum,
source: TexImageSource,
): void;
texSubImage2D(
target: GLenum,
level: GLint,
xoffset: GLint,
yoffset: GLint,
width: GLsizei,
height: GLsizei,
format: GLenum,
type: GLenum,
srcData: ArrayBufferView,
srcOffset: number,
): void;
texSubImage3D(
target: GLenum,
level: GLint,
xoffset: GLint,
yoffset: GLint,
zoffset: GLint,
width: GLsizei,
height: GLsizei,
depth: GLsizei,
format: GLenum,
type: GLenum,
pboOffset: GLintptr,
): void;
texSubImage3D(
target: GLenum,
level: GLint,
xoffset: GLint,
yoffset: GLint,
zoffset: GLint,
width: GLsizei,
height: GLsizei,
depth: GLsizei,
format: GLenum,
type: GLenum,
source: TexImageSource,
): void;
texSubImage3D(
target: GLenum,
level: GLint,
xoffset: GLint,
yoffset: GLint,
zoffset: GLint,
width: GLsizei,
height: GLsizei,
depth: GLsizei,
format: GLenum,
type: GLenum,
srcData: ArrayBufferView | null,
srcOffset?: number,
): void;
compressedTexSubImage2D(
target: GLenum,
level: GLint,
xoffset: GLint,
yoffset: GLint,
width: GLsizei,
height: GLsizei,
format: GLenum,
imageSize: GLsizei,
offset: GLintptr,
): void;
compressedTexSubImage2D(
target: GLenum,
level: GLint,
xoffset: GLint,
yoffset: GLint,
width: GLsizei,
height: GLsizei,
format: GLenum,
srcData: ArrayBufferView,
srcOffset?: number,
srcLengthOverride?: GLuint,
): void;
compressedTexSubImage3D(
target: GLenum,
level: GLint,
xoffset: GLint,
yoffset: GLint,
zoffset: GLint,
width: GLsizei,
height: GLsizei,
depth: GLsizei,
format: GLenum,
imageSize: GLsizei,
offset: GLintptr,
): void;
compressedTexSubImage3D(
target: GLenum,
level: GLint,
xoffset: GLint,
yoffset: GLint,
zoffset: GLint,
width: GLsizei,
height: GLsizei,
depth: GLsizei,
format: GLenum,
srcData: ArrayBufferView,
srcOffset?: number,
srcLengthOverride?: GLuint,
): void;
texStorage2D(target: GLenum, levels: GLsizei, internalformat: GLenum, width: GLsizei, height: GLsizei): void;
texStorage3D(
target: GLenum,
levels: GLsizei,
internalformat: GLenum,
width: GLsizei,
height: GLsizei,
depth: GLsizei,
): void;
// Same interface as https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D
texImage2D(
target: GLenum,
level: GLint,
internalformat: GLint,
width: GLsizei,
height: GLsizei,
border: GLint,
format: GLenum,
type: GLenum,
pixels: ArrayBufferView | null,
): void;
texImage2D(
target: GLenum,
level: GLint,
internalformat: GLint,
format: GLenum,
type: GLenum,
source: TexImageSource,
): void;
texImage2D(
target: GLenum,
level: GLint,
internalformat: GLint,
width: GLsizei,
height: GLsizei,
border: GLint,
format: GLenum,
type: GLenum,
pboOffset: GLintptr,
): void;
texImage2D(
target: GLenum,
level: GLint,
internalformat: GLint,
width: GLsizei,
height: GLsizei,
border: GLint,
format: GLenum,
type: GLenum,
source: TexImageSource,
): void;
texImage2D(
target: GLenum,
level: GLint,
internalformat: GLint,
width: GLsizei,
height: GLsizei,
border: GLint,
format: GLenum,
type: GLenum,
srcData: ArrayBufferView,
srcOffset: number,
): void;
texImage3D(
target: GLenum,
level: GLint,
internalformat: GLint,
width: GLsizei,
height: GLsizei,
depth: GLsizei,
border: GLint,
format: GLenum,
type: GLenum,
pboOffset: GLintptr,
): void;
texImage3D(
target: GLenum,
level: GLint,
internalformat: GLint,
width: GLsizei,
height: GLsizei,
depth: GLsizei,
border: GLint,
format: GLenum,
type: GLenum,
source: TexImageSource,
): void;
texImage3D(
target: GLenum,
level: GLint,
internalformat: GLint,
width: GLsizei,
height: GLsizei,
depth: GLsizei,
border: GLint,
format: GLenum,
type: GLenum,
srcData: ArrayBufferView | null,
): void;
texImage3D(
target: GLenum,
level: GLint,
internalformat: GLint,
width: GLsizei,
height: GLsizei,
depth: GLsizei,
border: GLint,
format: GLenum,
type: GLenum,
srcData: ArrayBufferView,
srcOffset: number,
): void;
scissor(scissor: Vector4): void;
viewport(viewport: Vector4): void;
reset(): void;
}
declare class WebGLStencilBuffer {
constructor();
setTest(stencilTest: boolean): void;
setMask(stencilMask: number): void;
setFunc(stencilFunc: number, stencilRef: number, stencilMask: number): void;
setOp(stencilFail: number, stencilZFail: number, stencilZPass: number): void;
setLocked(lock: boolean): void;
setClear(stencil: number): void;
reset(): void;
}
declare class WebGLUniforms {
constructor(gl: WebGLRenderingContext, program: WebGLProgram_2);
}
declare const WebGPUCoordinateSystem: 2001;
declare type WebXRArrayCamera = Omit & { cameras: [WebXRCamera, WebXRCamera] };
declare type WebXRCamera = PerspectiveCamera & { viewport: Vector4 };
declare class WebXRController {
constructor();
getHandSpace(): XRHandSpace;
getTargetRaySpace(): XRTargetRaySpace;
getGripSpace(): XRGripSpace;
dispatchEvent(event: { type: XRControllerEventType; data?: XRInputSource }): this;
connect(inputSource: XRInputSource): this;
disconnect(inputSource: XRInputSource): this;
update(inputSource: XRInputSource, frame: XRFrame, referenceSpace: XRReferenceSpace): this;
}
declare interface WebXRGripSpaceEventMap extends WebXRSpaceEventMap {
gripUpdated: { data: XRInputSource; target: WebXRController }; // This Event break the THREE.EventDispatcher contract, replacing the target to the wrong instance.
}
declare class WebXRManager
extends EventDispatcher
{
/**
* @default true
*/
cameraAutoUpdate: boolean;
/**
* @default false
*/
enabled: boolean;
/**
* @default false
*/
isPresenting: boolean;
constructor(renderer: WebGLRenderer, gl: WebGLRenderingContext);
getController: (index: number) => XRTargetRaySpace;
getControllerGrip: (index: number) => XRGripSpace;
getHand: (index: number) => XRHandSpace;
setFramebufferScaleFactor: (value: number) => void;
setReferenceSpaceType: (value: XRReferenceSpaceType) => void;
getReferenceSpace: () => XRReferenceSpace | null;
setReferenceSpace: (value: XRReferenceSpace) => void;
getBaseLayer: () => XRWebGLLayer | XRProjectionLayer;
getBinding: () => XRWebGLBinding;
getFrame: () => XRFrame;
getSession: () => XRSession | null;
setSession: (value: XRSession | null) => Promise;
getEnvironmentBlendMode: () => XREnvironmentBlendMode | undefined;
getDepthTexture: () => ExternalTexture | null;
updateCamera: (camera: PerspectiveCamera) => void;
getCamera: () => WebXRArrayCamera;
getFoveation: () => number | undefined;
setFoveation: (value: number) => void;
hasDepthSensing: () => boolean;
getDepthSensingMesh: () => Mesh | null;
getCameraTexture: (xrCamera: WebXRCamera) => ExternalTexture | undefined;
setAnimationLoop: (callback: XRFrameRequestCallback | null) => void;
dispose: () => void;
}
declare interface WebXRManagerEventMap {
sessionstart: {};
sessionend: {};
planeadded: { data: XRPlane };
planeremoved: { data: XRPlane };
planechanged: { data: XRPlane };
planesdetected: { data: XRPlaneSet };
}
declare interface WebXRSpaceEventMap extends Object3DEventMap {
select: { data: XRInputSource };
selectstart: { data: XRInputSource };
selectend: { data: XRInputSource };
squeeze: { data: XRInputSource };
squeezestart: { data: XRInputSource };
squeezeend: { data: XRInputSource };
connected: { data: XRInputSource };
disconnected: { data: XRInputSource };
pinchend: { handedness: XRHandedness; target: WebXRController }; // This Event break the THREE.EventDispatcher contract, replacing the target to the wrong instance.
pinchstart: { handedness: XRHandedness; target: WebXRController }; // This Event break the THREE.EventDispatcher contract, replacing the target to the wrong instance.
move: {};
}
declare const WrapAroundEnding: 2402;
/**
* Texture Wrapping Modes
* @remarks {@link ClampToEdgeWrapping} is the _default_ value and behaver for Wrapping Mapping.
* @see {@link https://threejs.org/docs/index.html#api/en/constants/Textures | Texture Constants}
*/
declare type Wrapping = typeof RepeatWrapping | typeof ClampToEdgeWrapping | typeof MirroredRepeatWrapping;
declare type XRControllerEventType = XRSessionEventType | XRInputSourceEventType | "disconnected" | "connected";
declare class XRGripSpace extends Group {
hasLinearVelocity: boolean;
readonly linearVelocity: Vector3;
hasAngularVelocity: boolean;
readonly angularVelocity: Vector3;
}
declare interface XRHandInputState {
pinching: boolean;
}
declare type XRHandJoints = Record;
declare class XRHandSpace extends Group {
readonly joints: Partial;
readonly inputState: XRHandInputState;
}
declare class XRJointSpace_2 extends Group {
readonly jointRadius: number | undefined;
}
declare class XRTargetRaySpace extends Group {
hasLinearVelocity: boolean;
readonly linearVelocity: Vector3;
hasAngularVelocity: boolean;
readonly angularVelocity: Vector3;
}
declare const ZeroCurvatureEnding: 2400;
declare const ZeroFactor: 200;
declare const ZeroSlopeEnding: 2401;
declare const ZeroStencilOp: 0;
export { }