declare module BABYLON { /** Alias type for value that can be null */ export type Nullable = T | null; /** * Alias type for number that are floats * @ignorenaming */ export type float = number; /** * Alias type for number that are doubles. * @ignorenaming */ export type double = number; /** * Alias type for number that are integer * @ignorenaming */ export type int = number; /** Alias type for number array or Float32Array */ export type FloatArray = number[] | Float32Array; /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */ export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array; /** * Alias for types that can be used by a Buffer or VertexBuffer. */ export type DataArray = number[] | ArrayBuffer | ArrayBufferView; /** * Alias type for primitive types * @ignorenaming */ type Primitive = undefined | null | boolean | string | number | Function; /** * Type modifier to make all the properties of an object Readonly */ export type Immutable = T extends Primitive ? T : T extends Array ? ReadonlyArray : DeepImmutable; /** * Type modifier to make all the properties of an object Readonly recursively */ export type DeepImmutable = T extends Primitive ? T : T extends Array ? DeepImmutableArray : DeepImmutableObject; /** @hidden */ interface DeepImmutableArray extends ReadonlyArray> { } /** @hidden */ /** @hidden */ type DeepImmutableObject = { readonly [K in keyof T]: DeepImmutable; }; } declare module BABYLON { /** * Class containing a set of static utilities functions for arrays. */ export class ArrayTools { /** * Returns an array of the given size filled with element built from the given constructor and the paramters * @param size the number of element to construct and put in the array * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry. * @returns a new array filled with new objects */ static BuildArray(size: number, itemBuilder: () => T): Array; } } declare module BABYLON { /** * Scalar computation library */ export class Scalar { /** * Two pi constants convenient for computation. */ static TwoPi: number; /** * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45) * @param a number * @param b number * @param epsilon (default = 1.401298E-45) * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45) */ static WithinEpsilon(a: number, b: number, epsilon?: number): boolean; /** * Returns a string : the upper case translation of the number i to hexadecimal. * @param i number * @returns the upper case translation of the number i to hexadecimal. */ static ToHex(i: number): string; /** * Returns -1 if value is negative and +1 is value is positive. * @param value the value * @returns the value itself if it's equal to zero. */ static Sign(value: number): number; /** * Returns the value itself if it's between min and max. * Returns min if the value is lower than min. * Returns max if the value is greater than max. * @param value the value to clmap * @param min the min value to clamp to (default: 0) * @param max the max value to clamp to (default: 1) * @returns the clamped value */ static Clamp(value: number, min?: number, max?: number): number; /** * the log2 of value. * @param value the value to compute log2 of * @returns the log2 of value. */ static Log2(value: number): number; /** * Loops the value, so that it is never larger than length and never smaller than 0. * * This is similar to the modulo operator but it works with floating point numbers. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5. * With t = 5 and length = 2.5, the result would be 0.0. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator * @param value the value * @param length the length * @returns the looped value */ static Repeat(value: number, length: number): number; /** * Normalize the value between 0.0 and 1.0 using min and max values * @param value value to normalize * @param min max to normalize between * @param max min to normalize between * @returns the normalized value */ static Normalize(value: number, min: number, max: number): number; /** * Denormalize the value from 0.0 and 1.0 using min and max values * @param normalized value to denormalize * @param min max to denormalize between * @param max min to denormalize between * @returns the denormalized value */ static Denormalize(normalized: number, min: number, max: number): number; /** * Calculates the shortest difference between two given angles given in degrees. * @param current current angle in degrees * @param target target angle in degrees * @returns the delta */ static DeltaAngle(current: number, target: number): number; /** * PingPongs the value t, so that it is never larger than length and never smaller than 0. * @param tx value * @param length length * @returns The returned value will move back and forth between 0 and length */ static PingPong(tx: number, length: number): number; /** * Interpolates between min and max with smoothing at the limits. * * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions. * @param from from * @param to to * @param tx value * @returns the smooth stepped value */ static SmoothStep(from: number, to: number, tx: number): number; /** * Moves a value current towards target. * * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta. * Negative values of maxDelta pushes the value away from target. * @param current current value * @param target target value * @param maxDelta max distance to move * @returns resulting value */ static MoveTowards(current: number, target: number, maxDelta: number): number; /** * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees. * * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead. * @param current current value * @param target target value * @param maxDelta max distance to move * @returns resulting angle */ static MoveTowardsAngle(current: number, target: number, maxDelta: number): number; /** * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar. * @param start start value * @param end target value * @param amount amount to lerp between * @returns the lerped value */ static Lerp(start: number, end: number, amount: number): number; /** * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees. * @param start start value * @param end target value * @param amount amount to lerp between * @returns the lerped value */ static LerpAngle(start: number, end: number, amount: number): number; /** * Calculates the linear parameter t that produces the interpolant value within the range [a, b]. * @param a start value * @param b target value * @param value value between a and b * @returns the inverseLerp value */ static InverseLerp(a: number, b: number, value: number): number; /** * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2". * @see http://mathworld.wolfram.com/HermitePolynomial.html * @param value1 spline value * @param tangent1 spline value * @param value2 spline value * @param tangent2 spline value * @param amount input value * @returns hermite result */ static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number; /** * Returns a random float number between and min and max values * @param min min value of random * @param max max value of random * @returns random value */ static RandomRange(min: number, max: number): number; /** * This function returns percentage of a number in a given range. * * RangeToPercent(40,20,60) will return 0.5 (50%) * RangeToPercent(34,0,100) will return 0.34 (34%) * @param number to convert to percentage * @param min min range * @param max max range * @returns the percentage */ static RangeToPercent(number: number, min: number, max: number): number; /** * This function returns number that corresponds to the percentage in a given range. * * PercentToRange(0.34,0,100) will return 34. * @param percent to convert to number * @param min min range * @param max max range * @returns the number */ static PercentToRange(percent: number, min: number, max: number): number; /** * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians. * @param angle The angle to normalize in radian. * @return The converted angle. */ static NormalizeRadians(angle: number): number; } } declare module BABYLON { /** * Constant used to convert a value to gamma space * @ignorenaming */ export const ToGammaSpace: number; /** * Constant used to convert a value to linear space * @ignorenaming */ export const ToLinearSpace = 2.2; /** * Constant used to define the minimal number value in Babylon.js * @ignorenaming */ let Epsilon: number; /** * Class used to hold a RBG color */ export class Color3 { /** * Defines the red component (between 0 and 1, default is 0) */ r: number; /** * Defines the green component (between 0 and 1, default is 0) */ g: number; /** * Defines the blue component (between 0 and 1, default is 0) */ b: number; /** * Creates a new Color3 object from red, green, blue values, all between 0 and 1 * @param r defines the red component (between 0 and 1, default is 0) * @param g defines the green component (between 0 and 1, default is 0) * @param b defines the blue component (between 0 and 1, default is 0) */ constructor( /** * Defines the red component (between 0 and 1, default is 0) */ r?: number, /** * Defines the green component (between 0 and 1, default is 0) */ g?: number, /** * Defines the blue component (between 0 and 1, default is 0) */ b?: number); /** * Creates a string with the Color3 current values * @returns the string representation of the Color3 object */ toString(): string; /** * Returns the string "Color3" * @returns "Color3" */ getClassName(): string; /** * Compute the Color3 hash code * @returns an unique number that can be used to hash Color3 objects */ getHashCode(): number; /** * Stores in the given array from the given starting index the red, green, blue values as successive elements * @param array defines the array where to store the r,g,b components * @param index defines an optional index in the target array to define where to start storing values * @returns the current Color3 object */ toArray(array: FloatArray, index?: number): Color3; /** * Returns a new Color4 object from the current Color3 and the given alpha * @param alpha defines the alpha component on the new Color4 object (default is 1) * @returns a new Color4 object */ toColor4(alpha?: number): Color4; /** * Returns a new array populated with 3 numeric elements : red, green and blue values * @returns the new array */ asArray(): number[]; /** * Returns the luminance value * @returns a float value */ toLuminance(): number; /** * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object * @param otherColor defines the second operand * @returns the new Color3 object */ multiply(otherColor: DeepImmutable): Color3; /** * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result" * @param otherColor defines the second operand * @param result defines the Color3 object where to store the result * @returns the current Color3 */ multiplyToRef(otherColor: DeepImmutable, result: Color3): Color3; /** * Determines equality between Color3 objects * @param otherColor defines the second operand * @returns true if the rgb values are equal to the given ones */ equals(otherColor: DeepImmutable): boolean; /** * Determines equality between the current Color3 object and a set of r,b,g values * @param r defines the red component to check * @param g defines the green component to check * @param b defines the blue component to check * @returns true if the rgb values are equal to the given ones */ equalsFloats(r: number, g: number, b: number): boolean; /** * Multiplies in place each rgb value by scale * @param scale defines the scaling factor * @returns the updated Color3 */ scale(scale: number): Color3; /** * Multiplies the rgb values by scale and stores the result into "result" * @param scale defines the scaling factor * @param result defines the Color3 object where to store the result * @returns the unmodified current Color3 */ scaleToRef(scale: number, result: Color3): Color3; /** * Scale the current Color3 values by a factor and add the result to a given Color3 * @param scale defines the scale factor * @param result defines color to store the result into * @returns the unmodified current Color3 */ scaleAndAddToRef(scale: number, result: Color3): Color3; /** * Clamps the rgb values by the min and max values and stores the result into "result" * @param min defines minimum clamping value (default is 0) * @param max defines maximum clamping value (default is 1) * @param result defines color to store the result into * @returns the original Color3 */ clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3; /** * Creates a new Color3 set with the added values of the current Color3 and of the given one * @param otherColor defines the second operand * @returns the new Color3 */ add(otherColor: DeepImmutable): Color3; /** * Stores the result of the addition of the current Color3 and given one rgb values into "result" * @param otherColor defines the second operand * @param result defines Color3 object to store the result into * @returns the unmodified current Color3 */ addToRef(otherColor: DeepImmutable, result: Color3): Color3; /** * Returns a new Color3 set with the subtracted values of the given one from the current Color3 * @param otherColor defines the second operand * @returns the new Color3 */ subtract(otherColor: DeepImmutable): Color3; /** * Stores the result of the subtraction of given one from the current Color3 rgb values into "result" * @param otherColor defines the second operand * @param result defines Color3 object to store the result into * @returns the unmodified current Color3 */ subtractToRef(otherColor: DeepImmutable, result: Color3): Color3; /** * Copy the current object * @returns a new Color3 copied the current one */ clone(): Color3; /** * Copies the rgb values from the source in the current Color3 * @param source defines the source Color3 object * @returns the updated Color3 object */ copyFrom(source: DeepImmutable): Color3; /** * Updates the Color3 rgb values from the given floats * @param r defines the red component to read from * @param g defines the green component to read from * @param b defines the blue component to read from * @returns the current Color3 object */ copyFromFloats(r: number, g: number, b: number): Color3; /** * Updates the Color3 rgb values from the given floats * @param r defines the red component to read from * @param g defines the green component to read from * @param b defines the blue component to read from * @returns the current Color3 object */ set(r: number, g: number, b: number): Color3; /** * Compute the Color3 hexadecimal code as a string * @returns a string containing the hexadecimal representation of the Color3 object */ toHexString(): string; /** * Computes a new Color3 converted from the current one to linear space * @returns a new Color3 object */ toLinearSpace(): Color3; /** * Converts current color in rgb space to HSV values * @returns a new color3 representing the HSV values */ toHSV(): Color3; /** * Converts current color in rgb space to HSV values * @param result defines the Color3 where to store the HSV values */ toHSVToRef(result: Color3): void; /** * Converts the Color3 values to linear space and stores the result in "convertedColor" * @param convertedColor defines the Color3 object where to store the linear space version * @returns the unmodified Color3 */ toLinearSpaceToRef(convertedColor: Color3): Color3; /** * Computes a new Color3 converted from the current one to gamma space * @returns a new Color3 object */ toGammaSpace(): Color3; /** * Converts the Color3 values to gamma space and stores the result in "convertedColor" * @param convertedColor defines the Color3 object where to store the gamma space version * @returns the unmodified Color3 */ toGammaSpaceToRef(convertedColor: Color3): Color3; private static _BlackReadOnly; /** * Convert Hue, saturation and value to a Color3 (RGB) * @param hue defines the hue * @param saturation defines the saturation * @param value defines the value * @param result defines the Color3 where to store the RGB values */ static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void; /** * Creates a new Color3 from the string containing valid hexadecimal values * @param hex defines a string containing valid hexadecimal values * @returns a new Color3 object */ static FromHexString(hex: string): Color3; /** * Creates a new Color3 from the starting index of the given array * @param array defines the source array * @param offset defines an offset in the source array * @returns a new Color3 object */ static FromArray(array: DeepImmutable>, offset?: number): Color3; /** * Creates a new Color3 from integer values (< 256) * @param r defines the red component to read from (value between 0 and 255) * @param g defines the green component to read from (value between 0 and 255) * @param b defines the blue component to read from (value between 0 and 255) * @returns a new Color3 object */ static FromInts(r: number, g: number, b: number): Color3; /** * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3 * @param start defines the start Color3 value * @param end defines the end Color3 value * @param amount defines the gradient value between start and end * @returns a new Color3 object */ static Lerp(start: DeepImmutable, end: DeepImmutable, amount: number): Color3; /** * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3 * @param left defines the start value * @param right defines the end value * @param amount defines the gradient factor * @param result defines the Color3 object where to store the result */ static LerpToRef(left: DeepImmutable, right: DeepImmutable, amount: number, result: Color3): void; /** * Returns a Color3 value containing a red color * @returns a new Color3 object */ static Red(): Color3; /** * Returns a Color3 value containing a green color * @returns a new Color3 object */ static Green(): Color3; /** * Returns a Color3 value containing a blue color * @returns a new Color3 object */ static Blue(): Color3; /** * Returns a Color3 value containing a black color * @returns a new Color3 object */ static Black(): Color3; /** * Gets a Color3 value containing a black color that must not be updated */ static readonly BlackReadOnly: DeepImmutable; /** * Returns a Color3 value containing a white color * @returns a new Color3 object */ static White(): Color3; /** * Returns a Color3 value containing a purple color * @returns a new Color3 object */ static Purple(): Color3; /** * Returns a Color3 value containing a magenta color * @returns a new Color3 object */ static Magenta(): Color3; /** * Returns a Color3 value containing a yellow color * @returns a new Color3 object */ static Yellow(): Color3; /** * Returns a Color3 value containing a gray color * @returns a new Color3 object */ static Gray(): Color3; /** * Returns a Color3 value containing a teal color * @returns a new Color3 object */ static Teal(): Color3; /** * Returns a Color3 value containing a random color * @returns a new Color3 object */ static Random(): Color3; } /** * Class used to hold a RBGA color */ export class Color4 { /** * Defines the red component (between 0 and 1, default is 0) */ r: number; /** * Defines the green component (between 0 and 1, default is 0) */ g: number; /** * Defines the blue component (between 0 and 1, default is 0) */ b: number; /** * Defines the alpha component (between 0 and 1, default is 1) */ a: number; /** * Creates a new Color4 object from red, green, blue values, all between 0 and 1 * @param r defines the red component (between 0 and 1, default is 0) * @param g defines the green component (between 0 and 1, default is 0) * @param b defines the blue component (between 0 and 1, default is 0) * @param a defines the alpha component (between 0 and 1, default is 1) */ constructor( /** * Defines the red component (between 0 and 1, default is 0) */ r?: number, /** * Defines the green component (between 0 and 1, default is 0) */ g?: number, /** * Defines the blue component (between 0 and 1, default is 0) */ b?: number, /** * Defines the alpha component (between 0 and 1, default is 1) */ a?: number); /** * Adds in place the given Color4 values to the current Color4 object * @param right defines the second operand * @returns the current updated Color4 object */ addInPlace(right: DeepImmutable): Color4; /** * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values * @returns the new array */ asArray(): number[]; /** * Stores from the starting index in the given array the Color4 successive values * @param array defines the array where to store the r,g,b components * @param index defines an optional index in the target array to define where to start storing values * @returns the current Color4 object */ toArray(array: number[], index?: number): Color4; /** * Determines equality between Color4 objects * @param otherColor defines the second operand * @returns true if the rgba values are equal to the given ones */ equals(otherColor: DeepImmutable): boolean; /** * Creates a new Color4 set with the added values of the current Color4 and of the given one * @param right defines the second operand * @returns a new Color4 object */ add(right: DeepImmutable): Color4; /** * Creates a new Color4 set with the subtracted values of the given one from the current Color4 * @param right defines the second operand * @returns a new Color4 object */ subtract(right: DeepImmutable): Color4; /** * Subtracts the given ones from the current Color4 values and stores the results in "result" * @param right defines the second operand * @param result defines the Color4 object where to store the result * @returns the current Color4 object */ subtractToRef(right: DeepImmutable, result: Color4): Color4; /** * Creates a new Color4 with the current Color4 values multiplied by scale * @param scale defines the scaling factor to apply * @returns a new Color4 object */ scale(scale: number): Color4; /** * Multiplies the current Color4 values by scale and stores the result in "result" * @param scale defines the scaling factor to apply * @param result defines the Color4 object where to store the result * @returns the current unmodified Color4 */ scaleToRef(scale: number, result: Color4): Color4; /** * Scale the current Color4 values by a factor and add the result to a given Color4 * @param scale defines the scale factor * @param result defines the Color4 object where to store the result * @returns the unmodified current Color4 */ scaleAndAddToRef(scale: number, result: Color4): Color4; /** * Clamps the rgb values by the min and max values and stores the result into "result" * @param min defines minimum clamping value (default is 0) * @param max defines maximum clamping value (default is 1) * @param result defines color to store the result into. * @returns the cuurent Color4 */ clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4; /** * Multipy an Color4 value by another and return a new Color4 object * @param color defines the Color4 value to multiply by * @returns a new Color4 object */ multiply(color: Color4): Color4; /** * Multipy a Color4 value by another and push the result in a reference value * @param color defines the Color4 value to multiply by * @param result defines the Color4 to fill the result in * @returns the result Color4 */ multiplyToRef(color: Color4, result: Color4): Color4; /** * Creates a string with the Color4 current values * @returns the string representation of the Color4 object */ toString(): string; /** * Returns the string "Color4" * @returns "Color4" */ getClassName(): string; /** * Compute the Color4 hash code * @returns an unique number that can be used to hash Color4 objects */ getHashCode(): number; /** * Creates a new Color4 copied from the current one * @returns a new Color4 object */ clone(): Color4; /** * Copies the given Color4 values into the current one * @param source defines the source Color4 object * @returns the current updated Color4 object */ copyFrom(source: Color4): Color4; /** * Copies the given float values into the current one * @param r defines the red component to read from * @param g defines the green component to read from * @param b defines the blue component to read from * @param a defines the alpha component to read from * @returns the current updated Color4 object */ copyFromFloats(r: number, g: number, b: number, a: number): Color4; /** * Copies the given float values into the current one * @param r defines the red component to read from * @param g defines the green component to read from * @param b defines the blue component to read from * @param a defines the alpha component to read from * @returns the current updated Color4 object */ set(r: number, g: number, b: number, a: number): Color4; /** * Compute the Color4 hexadecimal code as a string * @returns a string containing the hexadecimal representation of the Color4 object */ toHexString(): string; /** * Computes a new Color4 converted from the current one to linear space * @returns a new Color4 object */ toLinearSpace(): Color4; /** * Converts the Color4 values to linear space and stores the result in "convertedColor" * @param convertedColor defines the Color4 object where to store the linear space version * @returns the unmodified Color4 */ toLinearSpaceToRef(convertedColor: Color4): Color4; /** * Computes a new Color4 converted from the current one to gamma space * @returns a new Color4 object */ toGammaSpace(): Color4; /** * Converts the Color4 values to gamma space and stores the result in "convertedColor" * @param convertedColor defines the Color4 object where to store the gamma space version * @returns the unmodified Color4 */ toGammaSpaceToRef(convertedColor: Color4): Color4; /** * Creates a new Color4 from the string containing valid hexadecimal values * @param hex defines a string containing valid hexadecimal values * @returns a new Color4 object */ static FromHexString(hex: string): Color4; /** * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object * @param left defines the start value * @param right defines the end value * @param amount defines the gradient factor * @returns a new Color4 object */ static Lerp(left: DeepImmutable, right: DeepImmutable, amount: number): Color4; /** * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object * @param left defines the start value * @param right defines the end value * @param amount defines the gradient factor * @param result defines the Color4 object where to store data */ static LerpToRef(left: DeepImmutable, right: DeepImmutable, amount: number, result: Color4): void; /** * Creates a new Color4 from a Color3 and an alpha value * @param color3 defines the source Color3 to read from * @param alpha defines the alpha component (1.0 by default) * @returns a new Color4 object */ static FromColor3(color3: DeepImmutable, alpha?: number): Color4; /** * Creates a new Color4 from the starting index element of the given array * @param array defines the source array to read from * @param offset defines the offset in the source array * @returns a new Color4 object */ static FromArray(array: DeepImmutable>, offset?: number): Color4; /** * Creates a new Color3 from integer values (< 256) * @param r defines the red component to read from (value between 0 and 255) * @param g defines the green component to read from (value between 0 and 255) * @param b defines the blue component to read from (value between 0 and 255) * @param a defines the alpha component to read from (value between 0 and 255) * @returns a new Color3 object */ static FromInts(r: number, g: number, b: number, a: number): Color4; /** * Check the content of a given array and convert it to an array containing RGBA data * If the original array was already containing count * 4 values then it is returned directly * @param colors defines the array to check * @param count defines the number of RGBA data to expect * @returns an array containing count * 4 values (RGBA) */ static CheckColors4(colors: number[], count: number): number[]; } /** * Class representing a vector containing 2 coordinates */ export class Vector2 { /** defines the first coordinate */ x: number; /** defines the second coordinate */ y: number; /** * Creates a new Vector2 from the given x and y coordinates * @param x defines the first coordinate * @param y defines the second coordinate */ constructor( /** defines the first coordinate */ x?: number, /** defines the second coordinate */ y?: number); /** * Gets a string with the Vector2 coordinates * @returns a string with the Vector2 coordinates */ toString(): string; /** * Gets class name * @returns the string "Vector2" */ getClassName(): string; /** * Gets current vector hash code * @returns the Vector2 hash code as a number */ getHashCode(): number; /** * Sets the Vector2 coordinates in the given array or Float32Array from the given index. * @param array defines the source array * @param index defines the offset in source array * @returns the current Vector2 */ toArray(array: FloatArray, index?: number): Vector2; /** * Copy the current vector to an array * @returns a new array with 2 elements: the Vector2 coordinates. */ asArray(): number[]; /** * Sets the Vector2 coordinates with the given Vector2 coordinates * @param source defines the source Vector2 * @returns the current updated Vector2 */ copyFrom(source: DeepImmutable): Vector2; /** * Sets the Vector2 coordinates with the given floats * @param x defines the first coordinate * @param y defines the second coordinate * @returns the current updated Vector2 */ copyFromFloats(x: number, y: number): Vector2; /** * Sets the Vector2 coordinates with the given floats * @param x defines the first coordinate * @param y defines the second coordinate * @returns the current updated Vector2 */ set(x: number, y: number): Vector2; /** * Add another vector with the current one * @param otherVector defines the other vector * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates */ add(otherVector: DeepImmutable): Vector2; /** * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates * @param otherVector defines the other vector * @param result defines the target vector * @returns the unmodified current Vector2 */ addToRef(otherVector: DeepImmutable, result: Vector2): Vector2; /** * Set the Vector2 coordinates by adding the given Vector2 coordinates * @param otherVector defines the other vector * @returns the current updated Vector2 */ addInPlace(otherVector: DeepImmutable): Vector2; /** * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates * @param otherVector defines the other vector * @returns a new Vector2 */ addVector3(otherVector: Vector3): Vector2; /** * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2 * @param otherVector defines the other vector * @returns a new Vector2 */ subtract(otherVector: Vector2): Vector2; /** * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates. * @param otherVector defines the other vector * @param result defines the target vector * @returns the unmodified current Vector2 */ subtractToRef(otherVector: DeepImmutable, result: Vector2): Vector2; /** * Sets the current Vector2 coordinates by subtracting from it the given one coordinates * @param otherVector defines the other vector * @returns the current updated Vector2 */ subtractInPlace(otherVector: DeepImmutable): Vector2; /** * Multiplies in place the current Vector2 coordinates by the given ones * @param otherVector defines the other vector * @returns the current updated Vector2 */ multiplyInPlace(otherVector: DeepImmutable): Vector2; /** * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates * @param otherVector defines the other vector * @returns a new Vector2 */ multiply(otherVector: DeepImmutable): Vector2; /** * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates * @param otherVector defines the other vector * @param result defines the target vector * @returns the unmodified current Vector2 */ multiplyToRef(otherVector: DeepImmutable, result: Vector2): Vector2; /** * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats * @param x defines the first coordinate * @param y defines the second coordinate * @returns a new Vector2 */ multiplyByFloats(x: number, y: number): Vector2; /** * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates * @param otherVector defines the other vector * @returns a new Vector2 */ divide(otherVector: Vector2): Vector2; /** * Sets the "result" coordinates with the Vector2 divided by the given one coordinates * @param otherVector defines the other vector * @param result defines the target vector * @returns the unmodified current Vector2 */ divideToRef(otherVector: DeepImmutable, result: Vector2): Vector2; /** * Divides the current Vector2 coordinates by the given ones * @param otherVector defines the other vector * @returns the current updated Vector2 */ divideInPlace(otherVector: DeepImmutable): Vector2; /** * Gets a new Vector2 with current Vector2 negated coordinates * @returns a new Vector2 */ negate(): Vector2; /** * Multiply the Vector2 coordinates by scale * @param scale defines the scaling factor * @returns the current updated Vector2 */ scaleInPlace(scale: number): Vector2; /** * Returns a new Vector2 scaled by "scale" from the current Vector2 * @param scale defines the scaling factor * @returns a new Vector2 */ scale(scale: number): Vector2; /** * Scale the current Vector2 values by a factor to a given Vector2 * @param scale defines the scale factor * @param result defines the Vector2 object where to store the result * @returns the unmodified current Vector2 */ scaleToRef(scale: number, result: Vector2): Vector2; /** * Scale the current Vector2 values by a factor and add the result to a given Vector2 * @param scale defines the scale factor * @param result defines the Vector2 object where to store the result * @returns the unmodified current Vector2 */ scaleAndAddToRef(scale: number, result: Vector2): Vector2; /** * Gets a boolean if two vectors are equals * @param otherVector defines the other vector * @returns true if the given vector coordinates strictly equal the current Vector2 ones */ equals(otherVector: DeepImmutable): boolean; /** * Gets a boolean if two vectors are equals (using an epsilon value) * @param otherVector defines the other vector * @param epsilon defines the minimal distance to consider equality * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon. */ equalsWithEpsilon(otherVector: DeepImmutable, epsilon?: number): boolean; /** * Gets a new Vector2 from current Vector2 floored values * @returns a new Vector2 */ floor(): Vector2; /** * Gets a new Vector2 from current Vector2 floored values * @returns a new Vector2 */ fract(): Vector2; /** * Gets the length of the vector * @returns the vector length (float) */ length(): number; /** * Gets the vector squared length * @returns the vector squared length (float) */ lengthSquared(): number; /** * Normalize the vector * @returns the current updated Vector2 */ normalize(): Vector2; /** * Gets a new Vector2 copied from the Vector2 * @returns a new Vector2 */ clone(): Vector2; /** * Gets a new Vector2(0, 0) * @returns a new Vector2 */ static Zero(): Vector2; /** * Gets a new Vector2(1, 1) * @returns a new Vector2 */ static One(): Vector2; /** * Gets a new Vector2 set from the given index element of the given array * @param array defines the data source * @param offset defines the offset in the data source * @returns a new Vector2 */ static FromArray(array: DeepImmutable>, offset?: number): Vector2; /** * Sets "result" from the given index element of the given array * @param array defines the data source * @param offset defines the offset in the data source * @param result defines the target vector */ static FromArrayToRef(array: DeepImmutable>, offset: number, result: Vector2): void; /** * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2 * @param value1 defines 1st point of control * @param value2 defines 2nd point of control * @param value3 defines 3rd point of control * @param value4 defines 4th point of control * @param amount defines the interpolation factor * @returns a new Vector2 */ static CatmullRom(value1: DeepImmutable, value2: DeepImmutable, value3: DeepImmutable, value4: DeepImmutable, amount: number): Vector2; /** * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max". * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate * @param value defines the value to clamp * @param min defines the lower limit * @param max defines the upper limit * @returns a new Vector2 */ static Clamp(value: DeepImmutable, min: DeepImmutable, max: DeepImmutable): Vector2; /** * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2" * @param value1 defines the 1st control point * @param tangent1 defines the outgoing tangent * @param value2 defines the 2nd control point * @param tangent2 defines the incoming tangent * @param amount defines the interpolation factor * @returns a new Vector2 */ static Hermite(value1: DeepImmutable, tangent1: DeepImmutable, value2: DeepImmutable, tangent2: DeepImmutable, amount: number): Vector2; /** * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end". * @param start defines the start vector * @param end defines the end vector * @param amount defines the interpolation factor * @returns a new Vector2 */ static Lerp(start: DeepImmutable, end: DeepImmutable, amount: number): Vector2; /** * Gets the dot product of the vector "left" and the vector "right" * @param left defines first vector * @param right defines second vector * @returns the dot product (float) */ static Dot(left: DeepImmutable, right: DeepImmutable): number; /** * Returns a new Vector2 equal to the normalized given vector * @param vector defines the vector to normalize * @returns a new Vector2 */ static Normalize(vector: DeepImmutable): Vector2; /** * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors * @param left defines 1st vector * @param right defines 2nd vector * @returns a new Vector2 */ static Minimize(left: DeepImmutable, right: DeepImmutable): Vector2; /** * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors * @param left defines 1st vector * @param right defines 2nd vector * @returns a new Vector2 */ static Maximize(left: DeepImmutable, right: DeepImmutable): Vector2; /** * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix * @param vector defines the vector to transform * @param transformation defines the matrix to apply * @returns a new Vector2 */ static Transform(vector: DeepImmutable, transformation: DeepImmutable): Vector2; /** * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates * @param vector defines the vector to transform * @param transformation defines the matrix to apply * @param result defines the target vector */ static TransformToRef(vector: DeepImmutable, transformation: DeepImmutable, result: Vector2): void; /** * Determines if a given vector is included in a triangle * @param p defines the vector to test * @param p0 defines 1st triangle point * @param p1 defines 2nd triangle point * @param p2 defines 3rd triangle point * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2" */ static PointInTriangle(p: DeepImmutable, p0: DeepImmutable, p1: DeepImmutable, p2: DeepImmutable): boolean; /** * Gets the distance between the vectors "value1" and "value2" * @param value1 defines first vector * @param value2 defines second vector * @returns the distance between vectors */ static Distance(value1: DeepImmutable, value2: DeepImmutable): number; /** * Returns the squared distance between the vectors "value1" and "value2" * @param value1 defines first vector * @param value2 defines second vector * @returns the squared distance between vectors */ static DistanceSquared(value1: DeepImmutable, value2: DeepImmutable): number; /** * Gets a new Vector2 located at the center of the vectors "value1" and "value2" * @param value1 defines first vector * @param value2 defines second vector * @returns a new Vector2 */ static Center(value1: DeepImmutable, value2: DeepImmutable): Vector2; /** * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB". * @param p defines the middle point * @param segA defines one point of the segment * @param segB defines the other point of the segment * @returns the shortest distance */ static DistanceOfPointFromSegment(p: DeepImmutable, segA: DeepImmutable, segB: DeepImmutable): number; } /** * Classed used to store (x,y,z) vector representation * A Vector3 is the main object used in 3D geometry * It can represent etiher the coordinates of a point the space, either a direction * Reminder: js uses a left handed forward facing system */ export class Vector3 { /** * Defines the first coordinates (on X axis) */ x: number; /** * Defines the second coordinates (on Y axis) */ y: number; /** * Defines the third coordinates (on Z axis) */ z: number; private static _UpReadOnly; private static _ZeroReadOnly; /** * Creates a new Vector3 object from the given x, y, z (floats) coordinates. * @param x defines the first coordinates (on X axis) * @param y defines the second coordinates (on Y axis) * @param z defines the third coordinates (on Z axis) */ constructor( /** * Defines the first coordinates (on X axis) */ x?: number, /** * Defines the second coordinates (on Y axis) */ y?: number, /** * Defines the third coordinates (on Z axis) */ z?: number); /** * Creates a string representation of the Vector3 * @returns a string with the Vector3 coordinates. */ toString(): string; /** * Gets the class name * @returns the string "Vector3" */ getClassName(): string; /** * Creates the Vector3 hash code * @returns a number which tends to be unique between Vector3 instances */ getHashCode(): number; /** * Creates an array containing three elements : the coordinates of the Vector3 * @returns a new array of numbers */ asArray(): number[]; /** * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3 * @param array defines the destination array * @param index defines the offset in the destination array * @returns the current Vector3 */ toArray(array: FloatArray, index?: number): Vector3; /** * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation) * @returns a new Quaternion object, computed from the Vector3 coordinates */ toQuaternion(): Quaternion; /** * Adds the given vector to the current Vector3 * @param otherVector defines the second operand * @returns the current updated Vector3 */ addInPlace(otherVector: DeepImmutable): Vector3; /** * Adds the given coordinates to the current Vector3 * @param x defines the x coordinate of the operand * @param y defines the y coordinate of the operand * @param z defines the z coordinate of the operand * @returns the current updated Vector3 */ addInPlaceFromFloats(x: number, y: number, z: number): Vector3; /** * Gets a new Vector3, result of the addition the current Vector3 and the given vector * @param otherVector defines the second operand * @returns the resulting Vector3 */ add(otherVector: DeepImmutable): Vector3; /** * Adds the current Vector3 to the given one and stores the result in the vector "result" * @param otherVector defines the second operand * @param result defines the Vector3 object where to store the result * @returns the current Vector3 */ addToRef(otherVector: DeepImmutable, result: Vector3): Vector3; /** * Subtract the given vector from the current Vector3 * @param otherVector defines the second operand * @returns the current updated Vector3 */ subtractInPlace(otherVector: DeepImmutable): Vector3; /** * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3 * @param otherVector defines the second operand * @returns the resulting Vector3 */ subtract(otherVector: DeepImmutable): Vector3; /** * Subtracts the given vector from the current Vector3 and stores the result in the vector "result". * @param otherVector defines the second operand * @param result defines the Vector3 object where to store the result * @returns the current Vector3 */ subtractToRef(otherVector: DeepImmutable, result: Vector3): Vector3; /** * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates * @param x defines the x coordinate of the operand * @param y defines the y coordinate of the operand * @param z defines the z coordinate of the operand * @returns the resulting Vector3 */ subtractFromFloats(x: number, y: number, z: number): Vector3; /** * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result * @param x defines the x coordinate of the operand * @param y defines the y coordinate of the operand * @param z defines the z coordinate of the operand * @param result defines the Vector3 object where to store the result * @returns the current Vector3 */ subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3; /** * Gets a new Vector3 set with the current Vector3 negated coordinates * @returns a new Vector3 */ negate(): Vector3; /** * Multiplies the Vector3 coordinates by the float "scale" * @param scale defines the multiplier factor * @returns the current updated Vector3 */ scaleInPlace(scale: number): Vector3; /** * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale" * @param scale defines the multiplier factor * @returns a new Vector3 */ scale(scale: number): Vector3; /** * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates * @param scale defines the multiplier factor * @param result defines the Vector3 object where to store the result * @returns the current Vector3 */ scaleToRef(scale: number, result: Vector3): Vector3; /** * Scale the current Vector3 values by a factor and add the result to a given Vector3 * @param scale defines the scale factor * @param result defines the Vector3 object where to store the result * @returns the unmodified current Vector3 */ scaleAndAddToRef(scale: number, result: Vector3): Vector3; /** * Returns true if the current Vector3 and the given vector coordinates are strictly equal * @param otherVector defines the second operand * @returns true if both vectors are equals */ equals(otherVector: DeepImmutable): boolean; /** * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon * @param otherVector defines the second operand * @param epsilon defines the minimal distance to define values as equals * @returns true if both vectors are distant less than epsilon */ equalsWithEpsilon(otherVector: DeepImmutable, epsilon?: number): boolean; /** * Returns true if the current Vector3 coordinates equals the given floats * @param x defines the x coordinate of the operand * @param y defines the y coordinate of the operand * @param z defines the z coordinate of the operand * @returns true if both vectors are equals */ equalsToFloats(x: number, y: number, z: number): boolean; /** * Multiplies the current Vector3 coordinates by the given ones * @param otherVector defines the second operand * @returns the current updated Vector3 */ multiplyInPlace(otherVector: DeepImmutable): Vector3; /** * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector * @param otherVector defines the second operand * @returns the new Vector3 */ multiply(otherVector: DeepImmutable): Vector3; /** * Multiplies the current Vector3 by the given one and stores the result in the given vector "result" * @param otherVector defines the second operand * @param result defines the Vector3 object where to store the result * @returns the current Vector3 */ multiplyToRef(otherVector: DeepImmutable, result: Vector3): Vector3; /** * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats * @param x defines the x coordinate of the operand * @param y defines the y coordinate of the operand * @param z defines the z coordinate of the operand * @returns the new Vector3 */ multiplyByFloats(x: number, y: number, z: number): Vector3; /** * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones * @param otherVector defines the second operand * @returns the new Vector3 */ divide(otherVector: DeepImmutable): Vector3; /** * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result" * @param otherVector defines the second operand * @param result defines the Vector3 object where to store the result * @returns the current Vector3 */ divideToRef(otherVector: DeepImmutable, result: Vector3): Vector3; /** * Divides the current Vector3 coordinates by the given ones. * @param otherVector defines the second operand * @returns the current updated Vector3 */ divideInPlace(otherVector: Vector3): Vector3; /** * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones * @param other defines the second operand * @returns the current updated Vector3 */ minimizeInPlace(other: DeepImmutable): Vector3; /** * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones. * @param other defines the second operand * @returns the current updated Vector3 */ maximizeInPlace(other: DeepImmutable): Vector3; /** * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates * @param x defines the x coordinate of the operand * @param y defines the y coordinate of the operand * @param z defines the z coordinate of the operand * @returns the current updated Vector3 */ minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3; /** * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates. * @param x defines the x coordinate of the operand * @param y defines the y coordinate of the operand * @param z defines the z coordinate of the operand * @returns the current updated Vector3 */ maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3; /** * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction * Check if is non uniform within a certain amount of decimal places to account for this * @param epsilon the amount the values can differ * @returns if the the vector is non uniform to a certain number of decimal places */ isNonUniformWithinEpsilon(epsilon: number): boolean; /** * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same */ readonly isNonUniform: boolean; /** * Gets a new Vector3 from current Vector3 floored values * @returns a new Vector3 */ floor(): Vector3; /** * Gets a new Vector3 from current Vector3 floored values * @returns a new Vector3 */ fract(): Vector3; /** * Gets the length of the Vector3 * @returns the length of the Vecto3 */ length(): number; /** * Gets the squared length of the Vector3 * @returns squared length of the Vector3 */ lengthSquared(): number; /** * Normalize the current Vector3. * Please note that this is an in place operation. * @returns the current updated Vector3 */ normalize(): Vector3; /** * Reorders the x y z properties of the vector in place * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1) * @returns the current updated vector */ reorderInPlace(order: string): this; /** * Rotates the vector around 0,0,0 by a quaternion * @param quaternion the rotation quaternion * @param result vector to store the result * @returns the resulting vector */ rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3; /** * Rotates a vector around a given point * @param quaternion the rotation quaternion * @param point the point to rotate around * @param result vector to store the result * @returns the resulting vector */ rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3; /** * Normalize the current Vector3 with the given input length. * Please note that this is an in place operation. * @param len the length of the vector * @returns the current updated Vector3 */ normalizeFromLength(len: number): Vector3; /** * Normalize the current Vector3 to a new vector * @returns the new Vector3 */ normalizeToNew(): Vector3; /** * Normalize the current Vector3 to the reference * @param reference define the Vector3 to update * @returns the updated Vector3 */ normalizeToRef(reference: DeepImmutable): Vector3; /** * Creates a new Vector3 copied from the current Vector3 * @returns the new Vector3 */ clone(): Vector3; /** * Copies the given vector coordinates to the current Vector3 ones * @param source defines the source Vector3 * @returns the current updated Vector3 */ copyFrom(source: DeepImmutable): Vector3; /** * Copies the given floats to the current Vector3 coordinates * @param x defines the x coordinate of the operand * @param y defines the y coordinate of the operand * @param z defines the z coordinate of the operand * @returns the current updated Vector3 */ copyFromFloats(x: number, y: number, z: number): Vector3; /** * Copies the given floats to the current Vector3 coordinates * @param x defines the x coordinate of the operand * @param y defines the y coordinate of the operand * @param z defines the z coordinate of the operand * @returns the current updated Vector3 */ set(x: number, y: number, z: number): Vector3; /** * Copies the given float to the current Vector3 coordinates * @param v defines the x, y and z coordinates of the operand * @returns the current updated Vector3 */ setAll(v: number): Vector3; /** * Get the clip factor between two vectors * @param vector0 defines the first operand * @param vector1 defines the second operand * @param axis defines the axis to use * @param size defines the size along the axis * @returns the clip factor */ static GetClipFactor(vector0: DeepImmutable, vector1: DeepImmutable, axis: DeepImmutable, size: number): number; /** * Get angle between two vectors * @param vector0 angle between vector0 and vector1 * @param vector1 angle between vector0 and vector1 * @param normal direction of the normal * @return the angle between vector0 and vector1 */ static GetAngleBetweenVectors(vector0: DeepImmutable, vector1: DeepImmutable, normal: DeepImmutable): number; /** * Returns a new Vector3 set from the index "offset" of the given array * @param array defines the source array * @param offset defines the offset in the source array * @returns the new Vector3 */ static FromArray(array: DeepImmutable>, offset?: number): Vector3; /** * Returns a new Vector3 set from the index "offset" of the given Float32Array * This function is deprecated. Use FromArray instead * @param array defines the source array * @param offset defines the offset in the source array * @returns the new Vector3 */ static FromFloatArray(array: DeepImmutable, offset?: number): Vector3; /** * Sets the given vector "result" with the element values from the index "offset" of the given array * @param array defines the source array * @param offset defines the offset in the source array * @param result defines the Vector3 where to store the result */ static FromArrayToRef(array: DeepImmutable>, offset: number, result: Vector3): void; /** * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array * This function is deprecated. Use FromArrayToRef instead. * @param array defines the source array * @param offset defines the offset in the source array * @param result defines the Vector3 where to store the result */ static FromFloatArrayToRef(array: DeepImmutable, offset: number, result: Vector3): void; /** * Sets the given vector "result" with the given floats. * @param x defines the x coordinate of the source * @param y defines the y coordinate of the source * @param z defines the z coordinate of the source * @param result defines the Vector3 where to store the result */ static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void; /** * Returns a new Vector3 set to (0.0, 0.0, 0.0) * @returns a new empty Vector3 */ static Zero(): Vector3; /** * Returns a new Vector3 set to (1.0, 1.0, 1.0) * @returns a new unit Vector3 */ static One(): Vector3; /** * Returns a new Vector3 set to (0.0, 1.0, 0.0) * @returns a new up Vector3 */ static Up(): Vector3; /** * Gets a up Vector3 that must not be updated */ static readonly UpReadOnly: DeepImmutable; /** * Gets a zero Vector3 that must not be updated */ static readonly ZeroReadOnly: DeepImmutable; /** * Returns a new Vector3 set to (0.0, -1.0, 0.0) * @returns a new down Vector3 */ static Down(): Vector3; /** * Returns a new Vector3 set to (0.0, 0.0, 1.0) * @returns a new forward Vector3 */ static Forward(): Vector3; /** * Returns a new Vector3 set to (0.0, 0.0, -1.0) * @returns a new forward Vector3 */ static Backward(): Vector3; /** * Returns a new Vector3 set to (1.0, 0.0, 0.0) * @returns a new right Vector3 */ static Right(): Vector3; /** * Returns a new Vector3 set to (-1.0, 0.0, 0.0) * @returns a new left Vector3 */ static Left(): Vector3; /** * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account) * @param vector defines the Vector3 to transform * @param transformation defines the transformation matrix * @returns the transformed Vector3 */ static TransformCoordinates(vector: DeepImmutable, transformation: DeepImmutable): Vector3; /** * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account) * @param vector defines the Vector3 to transform * @param transformation defines the transformation matrix * @param result defines the Vector3 where to store the result */ static TransformCoordinatesToRef(vector: DeepImmutable, transformation: DeepImmutable, result: Vector3): void; /** * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z) * This method computes tranformed coordinates only, not transformed direction vectors * @param x define the x coordinate of the source vector * @param y define the y coordinate of the source vector * @param z define the z coordinate of the source vector * @param transformation defines the transformation matrix * @param result defines the Vector3 where to store the result */ static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable, result: Vector3): void; /** * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector * This methods computes transformed normalized direction vectors only (ie. it does not apply translation) * @param vector defines the Vector3 to transform * @param transformation defines the transformation matrix * @returns the new Vector3 */ static TransformNormal(vector: DeepImmutable, transformation: DeepImmutable): Vector3; /** * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector * This methods computes transformed normalized direction vectors only (ie. it does not apply translation) * @param vector defines the Vector3 to transform * @param transformation defines the transformation matrix * @param result defines the Vector3 where to store the result */ static TransformNormalToRef(vector: DeepImmutable, transformation: DeepImmutable, result: Vector3): void; /** * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z) * This methods computes transformed normalized direction vectors only (ie. it does not apply translation) * @param x define the x coordinate of the source vector * @param y define the y coordinate of the source vector * @param z define the z coordinate of the source vector * @param transformation defines the transformation matrix * @param result defines the Vector3 where to store the result */ static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable, result: Vector3): void; /** * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4" * @param value1 defines the first control point * @param value2 defines the second control point * @param value3 defines the third control point * @param value4 defines the fourth control point * @param amount defines the amount on the spline to use * @returns the new Vector3 */ static CatmullRom(value1: DeepImmutable, value2: DeepImmutable, value3: DeepImmutable, value4: DeepImmutable, amount: number): Vector3; /** * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max" * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one * @param value defines the current value * @param min defines the lower range value * @param max defines the upper range value * @returns the new Vector3 */ static Clamp(value: DeepImmutable, min: DeepImmutable, max: DeepImmutable): Vector3; /** * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max" * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one * @param value defines the current value * @param min defines the lower range value * @param max defines the upper range value * @param result defines the Vector3 where to store the result */ static ClampToRef(value: DeepImmutable, min: DeepImmutable, max: DeepImmutable, result: Vector3): void; /** * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2" * @param value1 defines the first control point * @param tangent1 defines the first tangent vector * @param value2 defines the second control point * @param tangent2 defines the second tangent vector * @param amount defines the amount on the interpolation spline (between 0 and 1) * @returns the new Vector3 */ static Hermite(value1: DeepImmutable, tangent1: DeepImmutable, value2: DeepImmutable, tangent2: DeepImmutable, amount: number): Vector3; /** * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end" * @param start defines the start value * @param end defines the end value * @param amount max defines amount between both (between 0 and 1) * @returns the new Vector3 */ static Lerp(start: DeepImmutable, end: DeepImmutable, amount: number): Vector3; /** * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end" * @param start defines the start value * @param end defines the end value * @param amount max defines amount between both (between 0 and 1) * @param result defines the Vector3 where to store the result */ static LerpToRef(start: DeepImmutable, end: DeepImmutable, amount: number, result: Vector3): void; /** * Returns the dot product (float) between the vectors "left" and "right" * @param left defines the left operand * @param right defines the right operand * @returns the dot product */ static Dot(left: DeepImmutable, right: DeepImmutable): number; /** * Returns a new Vector3 as the cross product of the vectors "left" and "right" * The cross product is then orthogonal to both "left" and "right" * @param left defines the left operand * @param right defines the right operand * @returns the cross product */ static Cross(left: DeepImmutable, right: DeepImmutable): Vector3; /** * Sets the given vector "result" with the cross product of "left" and "right" * The cross product is then orthogonal to both "left" and "right" * @param left defines the left operand * @param right defines the right operand * @param result defines the Vector3 where to store the result */ static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void; /** * Returns a new Vector3 as the normalization of the given vector * @param vector defines the Vector3 to normalize * @returns the new Vector3 */ static Normalize(vector: DeepImmutable): Vector3; /** * Sets the given vector "result" with the normalization of the given first vector * @param vector defines the Vector3 to normalize * @param result defines the Vector3 where to store the result */ static NormalizeToRef(vector: DeepImmutable, result: Vector3): void; /** * Project a Vector3 onto screen space * @param vector defines the Vector3 to project * @param world defines the world matrix to use * @param transform defines the transform (view x projection) matrix to use * @param viewport defines the screen viewport to use * @returns the new Vector3 */ static Project(vector: DeepImmutable, world: DeepImmutable, transform: DeepImmutable, viewport: DeepImmutable): Vector3; /** @hidden */ static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable, matrix: DeepImmutable, result: Vector3): void; /** * Unproject from screen space to object space * @param source defines the screen space Vector3 to use * @param viewportWidth defines the current width of the viewport * @param viewportHeight defines the current height of the viewport * @param world defines the world matrix to use (can be set to Identity to go to world space) * @param transform defines the transform (view x projection) matrix to use * @returns the new Vector3 */ static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable, transform: DeepImmutable): Vector3; /** * Unproject from screen space to object space * @param source defines the screen space Vector3 to use * @param viewportWidth defines the current width of the viewport * @param viewportHeight defines the current height of the viewport * @param world defines the world matrix to use (can be set to Identity to go to world space) * @param view defines the view matrix to use * @param projection defines the projection matrix to use * @returns the new Vector3 */ static Unproject(source: DeepImmutable, viewportWidth: number, viewportHeight: number, world: DeepImmutable, view: DeepImmutable, projection: DeepImmutable): Vector3; /** * Unproject from screen space to object space * @param source defines the screen space Vector3 to use * @param viewportWidth defines the current width of the viewport * @param viewportHeight defines the current height of the viewport * @param world defines the world matrix to use (can be set to Identity to go to world space) * @param view defines the view matrix to use * @param projection defines the projection matrix to use * @param result defines the Vector3 where to store the result */ static UnprojectToRef(source: DeepImmutable, viewportWidth: number, viewportHeight: number, world: DeepImmutable, view: DeepImmutable, projection: DeepImmutable, result: Vector3): void; /** * Unproject from screen space to object space * @param sourceX defines the screen space x coordinate to use * @param sourceY defines the screen space y coordinate to use * @param sourceZ defines the screen space z coordinate to use * @param viewportWidth defines the current width of the viewport * @param viewportHeight defines the current height of the viewport * @param world defines the world matrix to use (can be set to Identity to go to world space) * @param view defines the view matrix to use * @param projection defines the projection matrix to use * @param result defines the Vector3 where to store the result */ static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable, view: DeepImmutable, projection: DeepImmutable, result: Vector3): void; /** * Gets the minimal coordinate values between two Vector3 * @param left defines the first operand * @param right defines the second operand * @returns the new Vector3 */ static Minimize(left: DeepImmutable, right: DeepImmutable): Vector3; /** * Gets the maximal coordinate values between two Vector3 * @param left defines the first operand * @param right defines the second operand * @returns the new Vector3 */ static Maximize(left: DeepImmutable, right: DeepImmutable): Vector3; /** * Returns the distance between the vectors "value1" and "value2" * @param value1 defines the first operand * @param value2 defines the second operand * @returns the distance */ static Distance(value1: DeepImmutable, value2: DeepImmutable): number; /** * Returns the squared distance between the vectors "value1" and "value2" * @param value1 defines the first operand * @param value2 defines the second operand * @returns the squared distance */ static DistanceSquared(value1: DeepImmutable, value2: DeepImmutable): number; /** * Returns a new Vector3 located at the center between "value1" and "value2" * @param value1 defines the first operand * @param value2 defines the second operand * @returns the new Vector3 */ static Center(value1: DeepImmutable, value2: DeepImmutable): Vector3; /** * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system), * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply * to something in order to rotate it from its local system to the given target system * Note: axis1, axis2 and axis3 are normalized during this operation * @param axis1 defines the first axis * @param axis2 defines the second axis * @param axis3 defines the third axis * @returns a new Vector3 */ static RotationFromAxis(axis1: DeepImmutable, axis2: DeepImmutable, axis3: DeepImmutable): Vector3; /** * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3 * @param axis1 defines the first axis * @param axis2 defines the second axis * @param axis3 defines the third axis * @param ref defines the Vector3 where to store the result */ static RotationFromAxisToRef(axis1: DeepImmutable, axis2: DeepImmutable, axis3: DeepImmutable, ref: Vector3): void; } /** * Vector4 class created for EulerAngle class conversion to Quaternion */ export class Vector4 { /** x value of the vector */ x: number; /** y value of the vector */ y: number; /** z value of the vector */ z: number; /** w value of the vector */ w: number; /** * Creates a Vector4 object from the given floats. * @param x x value of the vector * @param y y value of the vector * @param z z value of the vector * @param w w value of the vector */ constructor( /** x value of the vector */ x: number, /** y value of the vector */ y: number, /** z value of the vector */ z: number, /** w value of the vector */ w: number); /** * Returns the string with the Vector4 coordinates. * @returns a string containing all the vector values */ toString(): string; /** * Returns the string "Vector4". * @returns "Vector4" */ getClassName(): string; /** * Returns the Vector4 hash code. * @returns a unique hash code */ getHashCode(): number; /** * Returns a new array populated with 4 elements : the Vector4 coordinates. * @returns the resulting array */ asArray(): number[]; /** * Populates the given array from the given index with the Vector4 coordinates. * @param array array to populate * @param index index of the array to start at (default: 0) * @returns the Vector4. */ toArray(array: FloatArray, index?: number): Vector4; /** * Adds the given vector to the current Vector4. * @param otherVector the vector to add * @returns the updated Vector4. */ addInPlace(otherVector: DeepImmutable): Vector4; /** * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one. * @param otherVector the vector to add * @returns the resulting vector */ add(otherVector: DeepImmutable): Vector4; /** * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one. * @param otherVector the vector to add * @param result the vector to store the result * @returns the current Vector4. */ addToRef(otherVector: DeepImmutable, result: Vector4): Vector4; /** * Subtract in place the given vector from the current Vector4. * @param otherVector the vector to subtract * @returns the updated Vector4. */ subtractInPlace(otherVector: DeepImmutable): Vector4; /** * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4. * @param otherVector the vector to add * @returns the new vector with the result */ subtract(otherVector: DeepImmutable): Vector4; /** * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4. * @param otherVector the vector to subtract * @param result the vector to store the result * @returns the current Vector4. */ subtractToRef(otherVector: DeepImmutable, result: Vector4): Vector4; /** * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates. */ /** * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates. * @param x value to subtract * @param y value to subtract * @param z value to subtract * @param w value to subtract * @returns new vector containing the result */ subtractFromFloats(x: number, y: number, z: number, w: number): Vector4; /** * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates. * @param x value to subtract * @param y value to subtract * @param z value to subtract * @param w value to subtract * @param result the vector to store the result in * @returns the current Vector4. */ subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4; /** * Returns a new Vector4 set with the current Vector4 negated coordinates. * @returns a new vector with the negated values */ negate(): Vector4; /** * Multiplies the current Vector4 coordinates by scale (float). * @param scale the number to scale with * @returns the updated Vector4. */ scaleInPlace(scale: number): Vector4; /** * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float). * @param scale the number to scale with * @returns a new vector with the result */ scale(scale: number): Vector4; /** * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float). * @param scale the number to scale with * @param result a vector to store the result in * @returns the current Vector4. */ scaleToRef(scale: number, result: Vector4): Vector4; /** * Scale the current Vector4 values by a factor and add the result to a given Vector4 * @param scale defines the scale factor * @param result defines the Vector4 object where to store the result * @returns the unmodified current Vector4 */ scaleAndAddToRef(scale: number, result: Vector4): Vector4; /** * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones. * @param otherVector the vector to compare against * @returns true if they are equal */ equals(otherVector: DeepImmutable): boolean; /** * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones. * @param otherVector vector to compare against * @param epsilon (Default: very small number) * @returns true if they are equal */ equalsWithEpsilon(otherVector: DeepImmutable, epsilon?: number): boolean; /** * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates. * @param x x value to compare against * @param y y value to compare against * @param z z value to compare against * @param w w value to compare against * @returns true if equal */ equalsToFloats(x: number, y: number, z: number, w: number): boolean; /** * Multiplies in place the current Vector4 by the given one. * @param otherVector vector to multiple with * @returns the updated Vector4. */ multiplyInPlace(otherVector: Vector4): Vector4; /** * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one. * @param otherVector vector to multiple with * @returns resulting new vector */ multiply(otherVector: DeepImmutable): Vector4; /** * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one. * @param otherVector vector to multiple with * @param result vector to store the result * @returns the current Vector4. */ multiplyToRef(otherVector: DeepImmutable, result: Vector4): Vector4; /** * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates. * @param x x value multiply with * @param y y value multiply with * @param z z value multiply with * @param w w value multiply with * @returns resulting new vector */ multiplyByFloats(x: number, y: number, z: number, w: number): Vector4; /** * Returns a new Vector4 set with the division result of the current Vector4 by the given one. * @param otherVector vector to devide with * @returns resulting new vector */ divide(otherVector: DeepImmutable): Vector4; /** * Updates the given vector "result" with the division result of the current Vector4 by the given one. * @param otherVector vector to devide with * @param result vector to store the result * @returns the current Vector4. */ divideToRef(otherVector: DeepImmutable, result: Vector4): Vector4; /** * Divides the current Vector3 coordinates by the given ones. * @param otherVector vector to devide with * @returns the updated Vector3. */ divideInPlace(otherVector: DeepImmutable): Vector4; /** * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones * @param other defines the second operand * @returns the current updated Vector4 */ minimizeInPlace(other: DeepImmutable): Vector4; /** * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones * @param other defines the second operand * @returns the current updated Vector4 */ maximizeInPlace(other: DeepImmutable): Vector4; /** * Gets a new Vector4 from current Vector4 floored values * @returns a new Vector4 */ floor(): Vector4; /** * Gets a new Vector4 from current Vector3 floored values * @returns a new Vector4 */ fract(): Vector4; /** * Returns the Vector4 length (float). * @returns the length */ length(): number; /** * Returns the Vector4 squared length (float). * @returns the length squared */ lengthSquared(): number; /** * Normalizes in place the Vector4. * @returns the updated Vector4. */ normalize(): Vector4; /** * Returns a new Vector3 from the Vector4 (x, y, z) coordinates. * @returns this converted to a new vector3 */ toVector3(): Vector3; /** * Returns a new Vector4 copied from the current one. * @returns the new cloned vector */ clone(): Vector4; /** * Updates the current Vector4 with the given one coordinates. * @param source the source vector to copy from * @returns the updated Vector4. */ copyFrom(source: DeepImmutable): Vector4; /** * Updates the current Vector4 coordinates with the given floats. * @param x float to copy from * @param y float to copy from * @param z float to copy from * @param w float to copy from * @returns the updated Vector4. */ copyFromFloats(x: number, y: number, z: number, w: number): Vector4; /** * Updates the current Vector4 coordinates with the given floats. * @param x float to set from * @param y float to set from * @param z float to set from * @param w float to set from * @returns the updated Vector4. */ set(x: number, y: number, z: number, w: number): Vector4; /** * Copies the given float to the current Vector3 coordinates * @param v defines the x, y, z and w coordinates of the operand * @returns the current updated Vector3 */ setAll(v: number): Vector4; /** * Returns a new Vector4 set from the starting index of the given array. * @param array the array to pull values from * @param offset the offset into the array to start at * @returns the new vector */ static FromArray(array: DeepImmutable>, offset?: number): Vector4; /** * Updates the given vector "result" from the starting index of the given array. * @param array the array to pull values from * @param offset the offset into the array to start at * @param result the vector to store the result in */ static FromArrayToRef(array: DeepImmutable>, offset: number, result: Vector4): void; /** * Updates the given vector "result" from the starting index of the given Float32Array. * @param array the array to pull values from * @param offset the offset into the array to start at * @param result the vector to store the result in */ static FromFloatArrayToRef(array: DeepImmutable, offset: number, result: Vector4): void; /** * Updates the given vector "result" coordinates from the given floats. * @param x float to set from * @param y float to set from * @param z float to set from * @param w float to set from * @param result the vector to the floats in */ static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void; /** * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0) * @returns the new vector */ static Zero(): Vector4; /** * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0) * @returns the new vector */ static One(): Vector4; /** * Returns a new normalized Vector4 from the given one. * @param vector the vector to normalize * @returns the vector */ static Normalize(vector: DeepImmutable): Vector4; /** * Updates the given vector "result" from the normalization of the given one. * @param vector the vector to normalize * @param result the vector to store the result in */ static NormalizeToRef(vector: DeepImmutable, result: Vector4): void; /** * Returns a vector with the minimum values from the left and right vectors * @param left left vector to minimize * @param right right vector to minimize * @returns a new vector with the minimum of the left and right vector values */ static Minimize(left: DeepImmutable, right: DeepImmutable): Vector4; /** * Returns a vector with the maximum values from the left and right vectors * @param left left vector to maximize * @param right right vector to maximize * @returns a new vector with the maximum of the left and right vector values */ static Maximize(left: DeepImmutable, right: DeepImmutable): Vector4; /** * Returns the distance (float) between the vectors "value1" and "value2". * @param value1 value to calulate the distance between * @param value2 value to calulate the distance between * @return the distance between the two vectors */ static Distance(value1: DeepImmutable, value2: DeepImmutable): number; /** * Returns the squared distance (float) between the vectors "value1" and "value2". * @param value1 value to calulate the distance between * @param value2 value to calulate the distance between * @return the distance between the two vectors squared */ static DistanceSquared(value1: DeepImmutable, value2: DeepImmutable): number; /** * Returns a new Vector4 located at the center between the vectors "value1" and "value2". * @param value1 value to calulate the center between * @param value2 value to calulate the center between * @return the center between the two vectors */ static Center(value1: DeepImmutable, value2: DeepImmutable): Vector4; /** * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector. * This methods computes transformed normalized direction vectors only. * @param vector the vector to transform * @param transformation the transformation matrix to apply * @returns the new vector */ static TransformNormal(vector: DeepImmutable, transformation: DeepImmutable): Vector4; /** * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector. * This methods computes transformed normalized direction vectors only. * @param vector the vector to transform * @param transformation the transformation matrix to apply * @param result the vector to store the result in */ static TransformNormalToRef(vector: DeepImmutable, transformation: DeepImmutable, result: Vector4): void; /** * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w). * This methods computes transformed normalized direction vectors only. * @param x value to transform * @param y value to transform * @param z value to transform * @param w value to transform * @param transformation the transformation matrix to apply * @param result the vector to store the results in */ static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable, result: Vector4): void; /** * Creates a new Vector4 from a Vector3 * @param source defines the source data * @param w defines the 4th component (default is 0) * @returns a new Vector4 */ static FromVector3(source: Vector3, w?: number): Vector4; } /** * Interface for the size containing width and height */ export interface ISize { /** * Width */ width: number; /** * Heighht */ height: number; } /** * Size containing widht and height */ export class Size implements ISize { /** * Width */ width: number; /** * Height */ height: number; /** * Creates a Size object from the given width and height (floats). * @param width width of the new size * @param height height of the new size */ constructor(width: number, height: number); /** * Returns a string with the Size width and height * @returns a string with the Size width and height */ toString(): string; /** * "Size" * @returns the string "Size" */ getClassName(): string; /** * Returns the Size hash code. * @returns a hash code for a unique width and height */ getHashCode(): number; /** * Updates the current size from the given one. * @param src the given size */ copyFrom(src: Size): void; /** * Updates in place the current Size from the given floats. * @param width width of the new size * @param height height of the new size * @returns the updated Size. */ copyFromFloats(width: number, height: number): Size; /** * Updates in place the current Size from the given floats. * @param width width to set * @param height height to set * @returns the updated Size. */ set(width: number, height: number): Size; /** * Multiplies the width and height by numbers * @param w factor to multiple the width by * @param h factor to multiple the height by * @returns a new Size set with the multiplication result of the current Size and the given floats. */ multiplyByFloats(w: number, h: number): Size; /** * Clones the size * @returns a new Size copied from the given one. */ clone(): Size; /** * True if the current Size and the given one width and height are strictly equal. * @param other the other size to compare against * @returns True if the current Size and the given one width and height are strictly equal. */ equals(other: Size): boolean; /** * The surface of the Size : width * height (float). */ readonly surface: number; /** * Create a new size of zero * @returns a new Size set to (0.0, 0.0) */ static Zero(): Size; /** * Sums the width and height of two sizes * @param otherSize size to add to this size * @returns a new Size set as the addition result of the current Size and the given one. */ add(otherSize: Size): Size; /** * Subtracts the width and height of two * @param otherSize size to subtract to this size * @returns a new Size set as the subtraction result of the given one from the current Size. */ subtract(otherSize: Size): Size; /** * Creates a new Size set at the linear interpolation "amount" between "start" and "end" * @param start starting size to lerp between * @param end end size to lerp between * @param amount amount to lerp between the start and end values * @returns a new Size set at the linear interpolation "amount" between "start" and "end" */ static Lerp(start: Size, end: Size, amount: number): Size; } /** * Class used to store quaternion data * @see https://en.wikipedia.org/wiki/Quaternion * @see http://doc.babylonjs.com/features/position,_rotation,_scaling */ export class Quaternion { /** defines the first component (0 by default) */ x: number; /** defines the second component (0 by default) */ y: number; /** defines the third component (0 by default) */ z: number; /** defines the fourth component (1.0 by default) */ w: number; /** * Creates a new Quaternion from the given floats * @param x defines the first component (0 by default) * @param y defines the second component (0 by default) * @param z defines the third component (0 by default) * @param w defines the fourth component (1.0 by default) */ constructor( /** defines the first component (0 by default) */ x?: number, /** defines the second component (0 by default) */ y?: number, /** defines the third component (0 by default) */ z?: number, /** defines the fourth component (1.0 by default) */ w?: number); /** * Gets a string representation for the current quaternion * @returns a string with the Quaternion coordinates */ toString(): string; /** * Gets the class name of the quaternion * @returns the string "Quaternion" */ getClassName(): string; /** * Gets a hash code for this quaternion * @returns the quaternion hash code */ getHashCode(): number; /** * Copy the quaternion to an array * @returns a new array populated with 4 elements from the quaternion coordinates */ asArray(): number[]; /** * Check if two quaternions are equals * @param otherQuaternion defines the second operand * @return true if the current quaternion and the given one coordinates are strictly equals */ equals(otherQuaternion: DeepImmutable): boolean; /** * Clone the current quaternion * @returns a new quaternion copied from the current one */ clone(): Quaternion; /** * Copy a quaternion to the current one * @param other defines the other quaternion * @returns the updated current quaternion */ copyFrom(other: DeepImmutable): Quaternion; /** * Updates the current quaternion with the given float coordinates * @param x defines the x coordinate * @param y defines the y coordinate * @param z defines the z coordinate * @param w defines the w coordinate * @returns the updated current quaternion */ copyFromFloats(x: number, y: number, z: number, w: number): Quaternion; /** * Updates the current quaternion from the given float coordinates * @param x defines the x coordinate * @param y defines the y coordinate * @param z defines the z coordinate * @param w defines the w coordinate * @returns the updated current quaternion */ set(x: number, y: number, z: number, w: number): Quaternion; /** * Adds two quaternions * @param other defines the second operand * @returns a new quaternion as the addition result of the given one and the current quaternion */ add(other: DeepImmutable): Quaternion; /** * Add a quaternion to the current one * @param other defines the quaternion to add * @returns the current quaternion */ addInPlace(other: DeepImmutable): Quaternion; /** * Subtract two quaternions * @param other defines the second operand * @returns a new quaternion as the subtraction result of the given one from the current one */ subtract(other: Quaternion): Quaternion; /** * Multiplies the current quaternion by a scale factor * @param value defines the scale factor * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale" */ scale(value: number): Quaternion; /** * Scale the current quaternion values by a factor and stores the result to a given quaternion * @param scale defines the scale factor * @param result defines the Quaternion object where to store the result * @returns the unmodified current quaternion */ scaleToRef(scale: number, result: Quaternion): Quaternion; /** * Multiplies in place the current quaternion by a scale factor * @param value defines the scale factor * @returns the current modified quaternion */ scaleInPlace(value: number): Quaternion; /** * Scale the current quaternion values by a factor and add the result to a given quaternion * @param scale defines the scale factor * @param result defines the Quaternion object where to store the result * @returns the unmodified current quaternion */ scaleAndAddToRef(scale: number, result: Quaternion): Quaternion; /** * Multiplies two quaternions * @param q1 defines the second operand * @returns a new quaternion set as the multiplication result of the current one with the given one "q1" */ multiply(q1: DeepImmutable): Quaternion; /** * Sets the given "result" as the the multiplication result of the current one with the given one "q1" * @param q1 defines the second operand * @param result defines the target quaternion * @returns the current quaternion */ multiplyToRef(q1: DeepImmutable, result: Quaternion): Quaternion; /** * Updates the current quaternion with the multiplication of itself with the given one "q1" * @param q1 defines the second operand * @returns the currentupdated quaternion */ multiplyInPlace(q1: DeepImmutable): Quaternion; /** * Conjugates (1-q) the current quaternion and stores the result in the given quaternion * @param ref defines the target quaternion * @returns the current quaternion */ conjugateToRef(ref: Quaternion): Quaternion; /** * Conjugates in place (1-q) the current quaternion * @returns the current updated quaternion */ conjugateInPlace(): Quaternion; /** * Conjugates in place (1-q) the current quaternion * @returns a new quaternion */ conjugate(): Quaternion; /** * Gets length of current quaternion * @returns the quaternion length (float) */ length(): number; /** * Normalize in place the current quaternion * @returns the current updated quaternion */ normalize(): Quaternion; /** * Returns a new Vector3 set with the Euler angles translated from the current quaternion * @param order is a reserved parameter and is ignore for now * @returns a new Vector3 containing the Euler angles */ toEulerAngles(order?: string): Vector3; /** * Sets the given vector3 "result" with the Euler angles translated from the current quaternion * @param result defines the vector which will be filled with the Euler angles * @param order is a reserved parameter and is ignore for now * @returns the current unchanged quaternion */ toEulerAnglesToRef(result: Vector3): Quaternion; /** * Updates the given rotation matrix with the current quaternion values * @param result defines the target matrix * @returns the current unchanged quaternion */ toRotationMatrix(result: Matrix): Quaternion; /** * Updates the current quaternion from the given rotation matrix values * @param matrix defines the source matrix * @returns the current updated quaternion */ fromRotationMatrix(matrix: DeepImmutable): Quaternion; /** * Creates a new quaternion from a rotation matrix * @param matrix defines the source matrix * @returns a new quaternion created from the given rotation matrix values */ static FromRotationMatrix(matrix: DeepImmutable): Quaternion; /** * Updates the given quaternion with the given rotation matrix values * @param matrix defines the source matrix * @param result defines the target quaternion */ static FromRotationMatrixToRef(matrix: DeepImmutable, result: Quaternion): void; /** * Returns the dot product (float) between the quaternions "left" and "right" * @param left defines the left operand * @param right defines the right operand * @returns the dot product */ static Dot(left: DeepImmutable, right: DeepImmutable): number; /** * Checks if the two quaternions are close to each other * @param quat0 defines the first quaternion to check * @param quat1 defines the second quaternion to check * @returns true if the two quaternions are close to each other */ static AreClose(quat0: DeepImmutable, quat1: DeepImmutable): boolean; /** * Creates an empty quaternion * @returns a new quaternion set to (0.0, 0.0, 0.0) */ static Zero(): Quaternion; /** * Inverse a given quaternion * @param q defines the source quaternion * @returns a new quaternion as the inverted current quaternion */ static Inverse(q: DeepImmutable): Quaternion; /** * Inverse a given quaternion * @param q defines the source quaternion * @param result the quaternion the result will be stored in * @returns the result quaternion */ static InverseToRef(q: Quaternion, result: Quaternion): Quaternion; /** * Creates an identity quaternion * @returns the identity quaternion */ static Identity(): Quaternion; /** * Gets a boolean indicating if the given quaternion is identity * @param quaternion defines the quaternion to check * @returns true if the quaternion is identity */ static IsIdentity(quaternion: DeepImmutable): boolean; /** * Creates a quaternion from a rotation around an axis * @param axis defines the axis to use * @param angle defines the angle to use * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float) */ static RotationAxis(axis: DeepImmutable, angle: number): Quaternion; /** * Creates a rotation around an axis and stores it into the given quaternion * @param axis defines the axis to use * @param angle defines the angle to use * @param result defines the target quaternion * @returns the target quaternion */ static RotationAxisToRef(axis: DeepImmutable, angle: number, result: Quaternion): Quaternion; /** * Creates a new quaternion from data stored into an array * @param array defines the data source * @param offset defines the offset in the source array where the data starts * @returns a new quaternion */ static FromArray(array: DeepImmutable>, offset?: number): Quaternion; /** * Create a quaternion from Euler rotation angles * @param x Pitch * @param y Yaw * @param z Roll * @returns the new Quaternion */ static FromEulerAngles(x: number, y: number, z: number): Quaternion; /** * Updates a quaternion from Euler rotation angles * @param x Pitch * @param y Yaw * @param z Roll * @param result the quaternion to store the result * @returns the updated quaternion */ static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion; /** * Create a quaternion from Euler rotation vector * @param vec the Euler vector (x Pitch, y Yaw, z Roll) * @returns the new Quaternion */ static FromEulerVector(vec: DeepImmutable): Quaternion; /** * Updates a quaternion from Euler rotation vector * @param vec the Euler vector (x Pitch, y Yaw, z Roll) * @param result the quaternion to store the result * @returns the updated quaternion */ static FromEulerVectorToRef(vec: DeepImmutable, result: Quaternion): Quaternion; /** * Creates a new quaternion from the given Euler float angles (y, x, z) * @param yaw defines the rotation around Y axis * @param pitch defines the rotation around X axis * @param roll defines the rotation around Z axis * @returns the new quaternion */ static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion; /** * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion * @param yaw defines the rotation around Y axis * @param pitch defines the rotation around X axis * @param roll defines the rotation around Z axis * @param result defines the target quaternion */ static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void; /** * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation * @param alpha defines the rotation around first axis * @param beta defines the rotation around second axis * @param gamma defines the rotation around third axis * @returns the new quaternion */ static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion; /** * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion * @param alpha defines the rotation around first axis * @param beta defines the rotation around second axis * @param gamma defines the rotation around third axis * @param result defines the target quaternion */ static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void; /** * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) * @param axis1 defines the first axis * @param axis2 defines the second axis * @param axis3 defines the third axis * @returns the new quaternion */ static RotationQuaternionFromAxis(axis1: DeepImmutable, axis2: DeepImmutable, axis3: DeepImmutable): Quaternion; /** * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion * @param axis1 defines the first axis * @param axis2 defines the second axis * @param axis3 defines the third axis * @param ref defines the target quaternion */ static RotationQuaternionFromAxisToRef(axis1: DeepImmutable, axis2: DeepImmutable, axis3: DeepImmutable, ref: Quaternion): void; /** * Interpolates between two quaternions * @param left defines first quaternion * @param right defines second quaternion * @param amount defines the gradient to use * @returns the new interpolated quaternion */ static Slerp(left: DeepImmutable, right: DeepImmutable, amount: number): Quaternion; /** * Interpolates between two quaternions and stores it into a target quaternion * @param left defines first quaternion * @param right defines second quaternion * @param amount defines the gradient to use * @param result defines the target quaternion */ static SlerpToRef(left: DeepImmutable, right: DeepImmutable, amount: number, result: Quaternion): void; /** * Interpolate between two quaternions using Hermite interpolation * @param value1 defines first quaternion * @param tangent1 defines the incoming tangent * @param value2 defines second quaternion * @param tangent2 defines the outgoing tangent * @param amount defines the target quaternion * @returns the new interpolated quaternion */ static Hermite(value1: DeepImmutable, tangent1: DeepImmutable, value2: DeepImmutable, tangent2: DeepImmutable, amount: number): Quaternion; } /** * Class used to store matrix data (4x4) */ export class Matrix { private static _updateFlagSeed; private static _identityReadOnly; private _isIdentity; private _isIdentityDirty; private _isIdentity3x2; private _isIdentity3x2Dirty; /** * Gets the update flag of the matrix which is an unique number for the matrix. * It will be incremented every time the matrix data change. * You can use it to speed the comparison between two versions of the same matrix. */ updateFlag: number; private readonly _m; /** * Gets the internal data of the matrix */ readonly m: DeepImmutable; /** @hidden */ _markAsUpdated(): void; /** @hidden */ private _updateIdentityStatus; /** * Creates an empty matrix (filled with zeros) */ constructor(); /** * Check if the current matrix is identity * @returns true is the matrix is the identity matrix */ isIdentity(): boolean; /** * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4) * @returns true is the matrix is the identity matrix */ isIdentityAs3x2(): boolean; /** * Gets the determinant of the matrix * @returns the matrix determinant */ determinant(): number; /** * Returns the matrix as a Float32Array * @returns the matrix underlying array */ toArray(): DeepImmutable; /** * Returns the matrix as a Float32Array * @returns the matrix underlying array. */ asArray(): DeepImmutable; /** * Inverts the current matrix in place * @returns the current inverted matrix */ invert(): Matrix; /** * Sets all the matrix elements to zero * @returns the current matrix */ reset(): Matrix; /** * Adds the current matrix with a second one * @param other defines the matrix to add * @returns a new matrix as the addition of the current matrix and the given one */ add(other: DeepImmutable): Matrix; /** * Sets the given matrix "result" to the addition of the current matrix and the given one * @param other defines the matrix to add * @param result defines the target matrix * @returns the current matrix */ addToRef(other: DeepImmutable, result: Matrix): Matrix; /** * Adds in place the given matrix to the current matrix * @param other defines the second operand * @returns the current updated matrix */ addToSelf(other: DeepImmutable): Matrix; /** * Sets the given matrix to the current inverted Matrix * @param other defines the target matrix * @returns the unmodified current matrix */ invertToRef(other: Matrix): Matrix; /** * add a value at the specified position in the current Matrix * @param index the index of the value within the matrix. between 0 and 15. * @param value the value to be added * @returns the current updated matrix */ addAtIndex(index: number, value: number): Matrix; /** * mutiply the specified position in the current Matrix by a value * @param index the index of the value within the matrix. between 0 and 15. * @param value the value to be added * @returns the current updated matrix */ multiplyAtIndex(index: number, value: number): Matrix; /** * Inserts the translation vector (using 3 floats) in the current matrix * @param x defines the 1st component of the translation * @param y defines the 2nd component of the translation * @param z defines the 3rd component of the translation * @returns the current updated matrix */ setTranslationFromFloats(x: number, y: number, z: number): Matrix; /** * Adds the translation vector (using 3 floats) in the current matrix * @param x defines the 1st component of the translation * @param y defines the 2nd component of the translation * @param z defines the 3rd component of the translation * @returns the current updated matrix */ addTranslationFromFloats(x: number, y: number, z: number): Matrix; /** * Inserts the translation vector in the current matrix * @param vector3 defines the translation to insert * @returns the current updated matrix */ setTranslation(vector3: DeepImmutable): Matrix; /** * Gets the translation value of the current matrix * @returns a new Vector3 as the extracted translation from the matrix */ getTranslation(): Vector3; /** * Fill a Vector3 with the extracted translation from the matrix * @param result defines the Vector3 where to store the translation * @returns the current matrix */ getTranslationToRef(result: Vector3): Matrix; /** * Remove rotation and scaling part from the matrix * @returns the updated matrix */ removeRotationAndScaling(): Matrix; /** * Multiply two matrices * @param other defines the second operand * @returns a new matrix set with the multiplication result of the current Matrix and the given one */ multiply(other: DeepImmutable): Matrix; /** * Copy the current matrix from the given one * @param other defines the source matrix * @returns the current updated matrix */ copyFrom(other: DeepImmutable): Matrix; /** * Populates the given array from the starting index with the current matrix values * @param array defines the target array * @param offset defines the offset in the target array where to start storing values * @returns the current matrix */ copyToArray(array: Float32Array, offset?: number): Matrix; /** * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one * @param other defines the second operand * @param result defines the matrix where to store the multiplication * @returns the current matrix */ multiplyToRef(other: DeepImmutable, result: Matrix): Matrix; /** * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one * @param other defines the second operand * @param result defines the array where to store the multiplication * @param offset defines the offset in the target array where to start storing values * @returns the current matrix */ multiplyToArray(other: DeepImmutable, result: Float32Array, offset: number): Matrix; /** * Check equality between this matrix and a second one * @param value defines the second matrix to compare * @returns true is the current matrix and the given one values are strictly equal */ equals(value: DeepImmutable): boolean; /** * Clone the current matrix * @returns a new matrix from the current matrix */ clone(): Matrix; /** * Returns the name of the current matrix class * @returns the string "Matrix" */ getClassName(): string; /** * Gets the hash code of the current matrix * @returns the hash code */ getHashCode(): number; /** * Decomposes the current Matrix into a translation, rotation and scaling components * @param scale defines the scale vector3 given as a reference to update * @param rotation defines the rotation quaternion given as a reference to update * @param translation defines the translation vector3 given as a reference to update * @returns true if operation was successful */ decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean; /** * Gets specific row of the matrix * @param index defines the number of the row to get * @returns the index-th row of the current matrix as a new Vector4 */ getRow(index: number): Nullable; /** * Sets the index-th row of the current matrix to the vector4 values * @param index defines the number of the row to set * @param row defines the target vector4 * @returns the updated current matrix */ setRow(index: number, row: Vector4): Matrix; /** * Compute the transpose of the matrix * @returns the new transposed matrix */ transpose(): Matrix; /** * Compute the transpose of the matrix and store it in a given matrix * @param result defines the target matrix * @returns the current matrix */ transposeToRef(result: Matrix): Matrix; /** * Sets the index-th row of the current matrix with the given 4 x float values * @param index defines the row index * @param x defines the x component to set * @param y defines the y component to set * @param z defines the z component to set * @param w defines the w component to set * @returns the updated current matrix */ setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix; /** * Compute a new matrix set with the current matrix values multiplied by scale (float) * @param scale defines the scale factor * @returns a new matrix */ scale(scale: number): Matrix; /** * Scale the current matrix values by a factor to a given result matrix * @param scale defines the scale factor * @param result defines the matrix to store the result * @returns the current matrix */ scaleToRef(scale: number, result: Matrix): Matrix; /** * Scale the current matrix values by a factor and add the result to a given matrix * @param scale defines the scale factor * @param result defines the Matrix to store the result * @returns the current matrix */ scaleAndAddToRef(scale: number, result: Matrix): Matrix; /** * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column). * @param ref matrix to store the result */ toNormalMatrix(ref: Matrix): void; /** * Gets only rotation part of the current matrix * @returns a new matrix sets to the extracted rotation matrix from the current one */ getRotationMatrix(): Matrix; /** * Extracts the rotation matrix from the current one and sets it as the given "result" * @param result defines the target matrix to store data to * @returns the current matrix */ getRotationMatrixToRef(result: Matrix): Matrix; /** * Toggles model matrix from being right handed to left handed in place and vice versa */ toggleModelMatrixHandInPlace(): void; /** * Toggles projection matrix from being right handed to left handed in place and vice versa */ toggleProjectionMatrixHandInPlace(): void; /** * Creates a matrix from an array * @param array defines the source array * @param offset defines an offset in the source array * @returns a new Matrix set from the starting index of the given array */ static FromArray(array: DeepImmutable>, offset?: number): Matrix; /** * Copy the content of an array into a given matrix * @param array defines the source array * @param offset defines an offset in the source array * @param result defines the target matrix */ static FromArrayToRef(array: DeepImmutable>, offset: number, result: Matrix): void; /** * Stores an array into a matrix after having multiplied each component by a given factor * @param array defines the source array * @param offset defines the offset in the source array * @param scale defines the scaling factor * @param result defines the target matrix */ static FromFloat32ArrayToRefScaled(array: DeepImmutable, offset: number, scale: number, result: Matrix): void; /** * Gets an identity matrix that must not be updated */ static readonly IdentityReadOnly: DeepImmutable; /** * Stores a list of values (16) inside a given matrix * @param initialM11 defines 1st value of 1st row * @param initialM12 defines 2nd value of 1st row * @param initialM13 defines 3rd value of 1st row * @param initialM14 defines 4th value of 1st row * @param initialM21 defines 1st value of 2nd row * @param initialM22 defines 2nd value of 2nd row * @param initialM23 defines 3rd value of 2nd row * @param initialM24 defines 4th value of 2nd row * @param initialM31 defines 1st value of 3rd row * @param initialM32 defines 2nd value of 3rd row * @param initialM33 defines 3rd value of 3rd row * @param initialM34 defines 4th value of 3rd row * @param initialM41 defines 1st value of 4th row * @param initialM42 defines 2nd value of 4th row * @param initialM43 defines 3rd value of 4th row * @param initialM44 defines 4th value of 4th row * @param result defines the target matrix */ static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void; /** * Creates new matrix from a list of values (16) * @param initialM11 defines 1st value of 1st row * @param initialM12 defines 2nd value of 1st row * @param initialM13 defines 3rd value of 1st row * @param initialM14 defines 4th value of 1st row * @param initialM21 defines 1st value of 2nd row * @param initialM22 defines 2nd value of 2nd row * @param initialM23 defines 3rd value of 2nd row * @param initialM24 defines 4th value of 2nd row * @param initialM31 defines 1st value of 3rd row * @param initialM32 defines 2nd value of 3rd row * @param initialM33 defines 3rd value of 3rd row * @param initialM34 defines 4th value of 3rd row * @param initialM41 defines 1st value of 4th row * @param initialM42 defines 2nd value of 4th row * @param initialM43 defines 3rd value of 4th row * @param initialM44 defines 4th value of 4th row * @returns the new matrix */ static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix; /** * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3) * @param scale defines the scale vector3 * @param rotation defines the rotation quaternion * @param translation defines the translation vector3 * @returns a new matrix */ static Compose(scale: DeepImmutable, rotation: DeepImmutable, translation: DeepImmutable): Matrix; /** * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3) * @param scale defines the scale vector3 * @param rotation defines the rotation quaternion * @param translation defines the translation vector3 * @param result defines the target matrix */ static ComposeToRef(scale: DeepImmutable, rotation: DeepImmutable, translation: DeepImmutable, result: Matrix): void; /** * Creates a new identity matrix * @returns a new identity matrix */ static Identity(): Matrix; /** * Creates a new identity matrix and stores the result in a given matrix * @param result defines the target matrix */ static IdentityToRef(result: Matrix): void; /** * Creates a new zero matrix * @returns a new zero matrix */ static Zero(): Matrix; /** * Creates a new rotation matrix for "angle" radians around the X axis * @param angle defines the angle (in radians) to use * @return the new matrix */ static RotationX(angle: number): Matrix; /** * Creates a new matrix as the invert of a given matrix * @param source defines the source matrix * @returns the new matrix */ static Invert(source: DeepImmutable): Matrix; /** * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix * @param angle defines the angle (in radians) to use * @param result defines the target matrix */ static RotationXToRef(angle: number, result: Matrix): void; /** * Creates a new rotation matrix for "angle" radians around the Y axis * @param angle defines the angle (in radians) to use * @return the new matrix */ static RotationY(angle: number): Matrix; /** * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix * @param angle defines the angle (in radians) to use * @param result defines the target matrix */ static RotationYToRef(angle: number, result: Matrix): void; /** * Creates a new rotation matrix for "angle" radians around the Z axis * @param angle defines the angle (in radians) to use * @return the new matrix */ static RotationZ(angle: number): Matrix; /** * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix * @param angle defines the angle (in radians) to use * @param result defines the target matrix */ static RotationZToRef(angle: number, result: Matrix): void; /** * Creates a new rotation matrix for "angle" radians around the given axis * @param axis defines the axis to use * @param angle defines the angle (in radians) to use * @return the new matrix */ static RotationAxis(axis: DeepImmutable, angle: number): Matrix; /** * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix * @param axis defines the axis to use * @param angle defines the angle (in radians) to use * @param result defines the target matrix */ static RotationAxisToRef(axis: DeepImmutable, angle: number, result: Matrix): void; /** * Takes normalised vectors and returns a rotation matrix to align "from" with "to". * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm * @param from defines the vector to align * @param to defines the vector to align to * @param result defines the target matrix */ static RotationAlignToRef(from: DeepImmutable, to: DeepImmutable, result: Matrix): void; /** * Creates a rotation matrix * @param yaw defines the yaw angle in radians (Y axis) * @param pitch defines the pitch angle in radians (X axis) * @param roll defines the roll angle in radians (X axis) * @returns the new rotation matrix */ static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix; /** * Creates a rotation matrix and stores it in a given matrix * @param yaw defines the yaw angle in radians (Y axis) * @param pitch defines the pitch angle in radians (X axis) * @param roll defines the roll angle in radians (X axis) * @param result defines the target matrix */ static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void; /** * Creates a scaling matrix * @param x defines the scale factor on X axis * @param y defines the scale factor on Y axis * @param z defines the scale factor on Z axis * @returns the new matrix */ static Scaling(x: number, y: number, z: number): Matrix; /** * Creates a scaling matrix and stores it in a given matrix * @param x defines the scale factor on X axis * @param y defines the scale factor on Y axis * @param z defines the scale factor on Z axis * @param result defines the target matrix */ static ScalingToRef(x: number, y: number, z: number, result: Matrix): void; /** * Creates a translation matrix * @param x defines the translation on X axis * @param y defines the translation on Y axis * @param z defines the translationon Z axis * @returns the new matrix */ static Translation(x: number, y: number, z: number): Matrix; /** * Creates a translation matrix and stores it in a given matrix * @param x defines the translation on X axis * @param y defines the translation on Y axis * @param z defines the translationon Z axis * @param result defines the target matrix */ static TranslationToRef(x: number, y: number, z: number, result: Matrix): void; /** * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue". * @param startValue defines the start value * @param endValue defines the end value * @param gradient defines the gradient factor * @returns the new matrix */ static Lerp(startValue: DeepImmutable, endValue: DeepImmutable, gradient: number): Matrix; /** * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue". * @param startValue defines the start value * @param endValue defines the end value * @param gradient defines the gradient factor * @param result defines the Matrix object where to store data */ static LerpToRef(startValue: DeepImmutable, endValue: DeepImmutable, gradient: number, result: Matrix): void; /** * Builds a new matrix whose values are computed by: * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices * @param startValue defines the first matrix * @param endValue defines the second matrix * @param gradient defines the gradient between the two matrices * @returns the new matrix */ static DecomposeLerp(startValue: DeepImmutable, endValue: DeepImmutable, gradient: number): Matrix; /** * Update a matrix to values which are computed by: * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices * @param startValue defines the first matrix * @param endValue defines the second matrix * @param gradient defines the gradient between the two matrices * @param result defines the target matrix */ static DecomposeLerpToRef(startValue: DeepImmutable, endValue: DeepImmutable, gradient: number, result: Matrix): void; /** * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up" * This function works in left handed mode * @param eye defines the final position of the entity * @param target defines where the entity should look at * @param up defines the up vector for the entity * @returns the new matrix */ static LookAtLH(eye: DeepImmutable, target: DeepImmutable, up: DeepImmutable): Matrix; /** * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up". * This function works in left handed mode * @param eye defines the final position of the entity * @param target defines where the entity should look at * @param up defines the up vector for the entity * @param result defines the target matrix */ static LookAtLHToRef(eye: DeepImmutable, target: DeepImmutable, up: DeepImmutable, result: Matrix): void; /** * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up" * This function works in right handed mode * @param eye defines the final position of the entity * @param target defines where the entity should look at * @param up defines the up vector for the entity * @returns the new matrix */ static LookAtRH(eye: DeepImmutable, target: DeepImmutable, up: DeepImmutable): Matrix; /** * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up". * This function works in right handed mode * @param eye defines the final position of the entity * @param target defines where the entity should look at * @param up defines the up vector for the entity * @param result defines the target matrix */ static LookAtRHToRef(eye: DeepImmutable, target: DeepImmutable, up: DeepImmutable, result: Matrix): void; /** * Create a left-handed orthographic projection matrix * @param width defines the viewport width * @param height defines the viewport height * @param znear defines the near clip plane * @param zfar defines the far clip plane * @returns a new matrix as a left-handed orthographic projection matrix */ static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix; /** * Store a left-handed orthographic projection to a given matrix * @param width defines the viewport width * @param height defines the viewport height * @param znear defines the near clip plane * @param zfar defines the far clip plane * @param result defines the target matrix */ static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void; /** * Create a left-handed orthographic projection matrix * @param left defines the viewport left coordinate * @param right defines the viewport right coordinate * @param bottom defines the viewport bottom coordinate * @param top defines the viewport top coordinate * @param znear defines the near clip plane * @param zfar defines the far clip plane * @returns a new matrix as a left-handed orthographic projection matrix */ static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; /** * Stores a left-handed orthographic projection into a given matrix * @param left defines the viewport left coordinate * @param right defines the viewport right coordinate * @param bottom defines the viewport bottom coordinate * @param top defines the viewport top coordinate * @param znear defines the near clip plane * @param zfar defines the far clip plane * @param result defines the target matrix */ static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; /** * Creates a right-handed orthographic projection matrix * @param left defines the viewport left coordinate * @param right defines the viewport right coordinate * @param bottom defines the viewport bottom coordinate * @param top defines the viewport top coordinate * @param znear defines the near clip plane * @param zfar defines the far clip plane * @returns a new matrix as a right-handed orthographic projection matrix */ static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; /** * Stores a right-handed orthographic projection into a given matrix * @param left defines the viewport left coordinate * @param right defines the viewport right coordinate * @param bottom defines the viewport bottom coordinate * @param top defines the viewport top coordinate * @param znear defines the near clip plane * @param zfar defines the far clip plane * @param result defines the target matrix */ static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; /** * Creates a left-handed perspective projection matrix * @param width defines the viewport width * @param height defines the viewport height * @param znear defines the near clip plane * @param zfar defines the far clip plane * @returns a new matrix as a left-handed perspective projection matrix */ static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix; /** * Creates a left-handed perspective projection matrix * @param fov defines the horizontal field of view * @param aspect defines the aspect ratio * @param znear defines the near clip plane * @param zfar defines the far clip plane * @returns a new matrix as a left-handed perspective projection matrix */ static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix; /** * Stores a left-handed perspective projection into a given matrix * @param fov defines the horizontal field of view * @param aspect defines the aspect ratio * @param znear defines the near clip plane * @param zfar defines the far clip plane * @param result defines the target matrix * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally */ static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; /** * Creates a right-handed perspective projection matrix * @param fov defines the horizontal field of view * @param aspect defines the aspect ratio * @param znear defines the near clip plane * @param zfar defines the far clip plane * @returns a new matrix as a right-handed perspective projection matrix */ static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix; /** * Stores a right-handed perspective projection into a given matrix * @param fov defines the horizontal field of view * @param aspect defines the aspect ratio * @param znear defines the near clip plane * @param zfar defines the far clip plane * @param result defines the target matrix * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally */ static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; /** * Stores a perspective projection for WebVR info a given matrix * @param fov defines the field of view * @param znear defines the near clip plane * @param zfar defines the far clip plane * @param result defines the target matrix * @param rightHanded defines if the matrix must be in right-handed mode (false by default) */ static PerspectiveFovWebVRToRef(fov: { upDegrees: number; downDegrees: number; leftDegrees: number; rightDegrees: number; }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void; /** * Computes a complete transformation matrix * @param viewport defines the viewport to use * @param world defines the world matrix * @param view defines the view matrix * @param projection defines the projection matrix * @param zmin defines the near clip plane * @param zmax defines the far clip plane * @returns the transformation matrix */ static GetFinalMatrix(viewport: DeepImmutable, world: DeepImmutable, view: DeepImmutable, projection: DeepImmutable, zmin: number, zmax: number): Matrix; /** * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array * @param matrix defines the matrix to use * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix */ static GetAsMatrix2x2(matrix: DeepImmutable): Float32Array; /** * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array * @param matrix defines the matrix to use * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix */ static GetAsMatrix3x3(matrix: DeepImmutable): Float32Array; /** * Compute the transpose of a given matrix * @param matrix defines the matrix to transpose * @returns the new matrix */ static Transpose(matrix: DeepImmutable): Matrix; /** * Compute the transpose of a matrix and store it in a target matrix * @param matrix defines the matrix to transpose * @param result defines the target matrix */ static TransposeToRef(matrix: DeepImmutable, result: Matrix): void; /** * Computes a reflection matrix from a plane * @param plane defines the reflection plane * @returns a new matrix */ static Reflection(plane: DeepImmutable): Matrix; /** * Computes a reflection matrix from a plane * @param plane defines the reflection plane * @param result defines the target matrix */ static ReflectionToRef(plane: DeepImmutable, result: Matrix): void; /** * Sets the given matrix as a rotation matrix composed from the 3 left handed axes * @param xaxis defines the value of the 1st axis * @param yaxis defines the value of the 2nd axis * @param zaxis defines the value of the 3rd axis * @param result defines the target matrix */ static FromXYZAxesToRef(xaxis: DeepImmutable, yaxis: DeepImmutable, zaxis: DeepImmutable, result: Matrix): void; /** * Creates a rotation matrix from a quaternion and stores it in a target matrix * @param quat defines the quaternion to use * @param result defines the target matrix */ static FromQuaternionToRef(quat: DeepImmutable, result: Matrix): void; } /** * Represens a plane by the equation ax + by + cz + d = 0 */ export class Plane { /** * Normal of the plane (a,b,c) */ normal: Vector3; /** * d component of the plane */ d: number; /** * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0 * @param a a component of the plane * @param b b component of the plane * @param c c component of the plane * @param d d component of the plane */ constructor(a: number, b: number, c: number, d: number); /** * @returns the plane coordinates as a new array of 4 elements [a, b, c, d]. */ asArray(): number[]; /** * @returns a new plane copied from the current Plane. */ clone(): Plane; /** * @returns the string "Plane". */ getClassName(): string; /** * @returns the Plane hash code. */ getHashCode(): number; /** * Normalize the current Plane in place. * @returns the updated Plane. */ normalize(): Plane; /** * Applies a transformation the plane and returns the result * @param transformation the transformation matrix to be applied to the plane * @returns a new Plane as the result of the transformation of the current Plane by the given matrix. */ transform(transformation: DeepImmutable): Plane; /** * Calcualtte the dot product between the point and the plane normal * @param point point to calculate the dot product with * @returns the dot product (float) of the point coordinates and the plane normal. */ dotCoordinate(point: DeepImmutable): number; /** * Updates the current Plane from the plane defined by the three given points. * @param point1 one of the points used to contruct the plane * @param point2 one of the points used to contruct the plane * @param point3 one of the points used to contruct the plane * @returns the updated Plane. */ copyFromPoints(point1: DeepImmutable, point2: DeepImmutable, point3: DeepImmutable): Plane; /** * Checks if the plane is facing a given direction * @param direction the direction to check if the plane is facing * @param epsilon value the dot product is compared against (returns true if dot <= epsilon) * @returns True is the vector "direction" is the same side than the plane normal. */ isFrontFacingTo(direction: DeepImmutable, epsilon: number): boolean; /** * Calculates the distance to a point * @param point point to calculate distance to * @returns the signed distance (float) from the given point to the Plane. */ signedDistanceTo(point: DeepImmutable): number; /** * Creates a plane from an array * @param array the array to create a plane from * @returns a new Plane from the given array. */ static FromArray(array: DeepImmutable>): Plane; /** * Creates a plane from three points * @param point1 point used to create the plane * @param point2 point used to create the plane * @param point3 point used to create the plane * @returns a new Plane defined by the three given points. */ static FromPoints(point1: DeepImmutable, point2: DeepImmutable, point3: DeepImmutable): Plane; /** * Creates a plane from an origin point and a normal * @param origin origin of the plane to be constructed * @param normal normal of the plane to be constructed * @returns a new Plane the normal vector to this plane at the given origin point. * Note : the vector "normal" is updated because normalized. */ static FromPositionAndNormal(origin: DeepImmutable, normal: DeepImmutable): Plane; /** * Calculates the distance from a plane and a point * @param origin origin of the plane to be constructed * @param normal normal of the plane to be constructed * @param point point to calculate distance to * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point. */ static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable, normal: DeepImmutable, point: DeepImmutable): number; } /** * Class used to represent a viewport on screen */ export class Viewport { /** viewport left coordinate */ x: number; /** viewport top coordinate */ y: number; /**viewport width */ width: number; /** viewport height */ height: number; /** * Creates a Viewport object located at (x, y) and sized (width, height) * @param x defines viewport left coordinate * @param y defines viewport top coordinate * @param width defines the viewport width * @param height defines the viewport height */ constructor( /** viewport left coordinate */ x: number, /** viewport top coordinate */ y: number, /**viewport width */ width: number, /** viewport height */ height: number); /** * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1) * @param renderWidth defines the rendering width * @param renderHeight defines the rendering height * @returns a new Viewport */ toGlobal(renderWidth: number, renderHeight: number): Viewport; /** * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1) * @param renderWidth defines the rendering width * @param renderHeight defines the rendering height * @param ref defines the target viewport * @returns the current viewport */ toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport; /** * Returns a new Viewport copied from the current one * @returns a new Viewport */ clone(): Viewport; } /** * Reprasents a camera frustum */ export class Frustum { /** * Gets the planes representing the frustum * @param transform matrix to be applied to the returned planes * @returns a new array of 6 Frustum planes computed by the given transformation matrix. */ static GetPlanes(transform: DeepImmutable): Plane[]; /** * Gets the near frustum plane transformed by the transform matrix * @param transform transformation matrix to be applied to the resulting frustum plane * @param frustumPlane the resuling frustum plane */ static GetNearPlaneToRef(transform: DeepImmutable, frustumPlane: Plane): void; /** * Gets the far frustum plane transformed by the transform matrix * @param transform transformation matrix to be applied to the resulting frustum plane * @param frustumPlane the resuling frustum plane */ static GetFarPlaneToRef(transform: DeepImmutable, frustumPlane: Plane): void; /** * Gets the left frustum plane transformed by the transform matrix * @param transform transformation matrix to be applied to the resulting frustum plane * @param frustumPlane the resuling frustum plane */ static GetLeftPlaneToRef(transform: DeepImmutable, frustumPlane: Plane): void; /** * Gets the right frustum plane transformed by the transform matrix * @param transform transformation matrix to be applied to the resulting frustum plane * @param frustumPlane the resuling frustum plane */ static GetRightPlaneToRef(transform: DeepImmutable, frustumPlane: Plane): void; /** * Gets the top frustum plane transformed by the transform matrix * @param transform transformation matrix to be applied to the resulting frustum plane * @param frustumPlane the resuling frustum plane */ static GetTopPlaneToRef(transform: DeepImmutable, frustumPlane: Plane): void; /** * Gets the bottom frustum plane transformed by the transform matrix * @param transform transformation matrix to be applied to the resulting frustum plane * @param frustumPlane the resuling frustum plane */ static GetBottomPlaneToRef(transform: DeepImmutable, frustumPlane: Plane): void; /** * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix. * @param transform transformation matrix to be applied to the resulting frustum planes * @param frustumPlanes the resuling frustum planes */ static GetPlanesToRef(transform: DeepImmutable, frustumPlanes: Plane[]): void; } /** Defines supported spaces */ export enum Space { /** Local (object) space */ LOCAL = 0, /** World space */ WORLD = 1, /** Bone space */ BONE = 2 } /** Defines the 3 main axes */ export class Axis { /** X axis */ static X: Vector3; /** Y axis */ static Y: Vector3; /** Z axis */ static Z: Vector3; } /** Class used to represent a Bezier curve */ export class BezierCurve { /** * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats * @param t defines the time * @param x1 defines the left coordinate on X axis * @param y1 defines the left coordinate on Y axis * @param x2 defines the right coordinate on X axis * @param y2 defines the right coordinate on Y axis * @returns the interpolated value */ static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number; } /** * Defines potential orientation for back face culling */ export enum Orientation { /** * Clockwise */ CW = 0, /** Counter clockwise */ CCW = 1 } /** * Defines angle representation */ export class Angle { private _radians; /** * Creates an Angle object of "radians" radians (float). * @param radians the angle in radians */ constructor(radians: number); /** * Get value in degrees * @returns the Angle value in degrees (float) */ degrees(): number; /** * Get value in radians * @returns the Angle value in radians (float) */ radians(): number; /** * Gets a new Angle object valued with the angle value in radians between the two given vectors * @param a defines first vector * @param b defines second vector * @returns a new Angle */ static BetweenTwoPoints(a: DeepImmutable, b: DeepImmutable): Angle; /** * Gets a new Angle object from the given float in radians * @param radians defines the angle value in radians * @returns a new Angle */ static FromRadians(radians: number): Angle; /** * Gets a new Angle object from the given float in degrees * @param degrees defines the angle value in degrees * @returns a new Angle */ static FromDegrees(degrees: number): Angle; } /** * This represents an arc in a 2d space. */ export class Arc2 { /** Defines the start point of the arc */ startPoint: Vector2; /** Defines the mid point of the arc */ midPoint: Vector2; /** Defines the end point of the arc */ endPoint: Vector2; /** * Defines the center point of the arc. */ centerPoint: Vector2; /** * Defines the radius of the arc. */ radius: number; /** * Defines the angle of the arc (from mid point to end point). */ angle: Angle; /** * Defines the start angle of the arc (from start point to middle point). */ startAngle: Angle; /** * Defines the orientation of the arc (clock wise/counter clock wise). */ orientation: Orientation; /** * Creates an Arc object from the three given points : start, middle and end. * @param startPoint Defines the start point of the arc * @param midPoint Defines the midlle point of the arc * @param endPoint Defines the end point of the arc */ constructor( /** Defines the start point of the arc */ startPoint: Vector2, /** Defines the mid point of the arc */ midPoint: Vector2, /** Defines the end point of the arc */ endPoint: Vector2); } /** * Represents a 2D path made up of multiple 2D points */ export class Path2 { private _points; private _length; /** * If the path start and end point are the same */ closed: boolean; /** * Creates a Path2 object from the starting 2D coordinates x and y. * @param x the starting points x value * @param y the starting points y value */ constructor(x: number, y: number); /** * Adds a new segment until the given coordinates (x, y) to the current Path2. * @param x the added points x value * @param y the added points y value * @returns the updated Path2. */ addLineTo(x: number, y: number): Path2; /** * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2. * @param midX middle point x value * @param midY middle point y value * @param endX end point x value * @param endY end point y value * @param numberOfSegments (default: 36) * @returns the updated Path2. */ addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2; /** * Closes the Path2. * @returns the Path2. */ close(): Path2; /** * Gets the sum of the distance between each sequential point in the path * @returns the Path2 total length (float). */ length(): number; /** * Gets the points which construct the path * @returns the Path2 internal array of points. */ getPoints(): Vector2[]; /** * Retreives the point at the distance aways from the starting point * @param normalizedLengthPosition the length along the path to retreive the point from * @returns a new Vector2 located at a percentage of the Path2 total length on this path. */ getPointAtLengthPosition(normalizedLengthPosition: number): Vector2; /** * Creates a new path starting from an x and y position * @param x starting x value * @param y starting y value * @returns a new Path2 starting at the coordinates (x, y). */ static StartingAt(x: number, y: number): Path2; } /** * Represents a 3D path made up of multiple 3D points */ export class Path3D { /** * an array of Vector3, the curve axis of the Path3D */ path: Vector3[]; private _curve; private _distances; private _tangents; private _normals; private _binormals; private _raw; /** * new Path3D(path, normal, raw) * Creates a Path3D. A Path3D is a logical math object, so not a mesh. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d * @param path an array of Vector3, the curve axis of the Path3D * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed. */ constructor( /** * an array of Vector3, the curve axis of the Path3D */ path: Vector3[], firstNormal?: Nullable, raw?: boolean); /** * Returns the Path3D array of successive Vector3 designing its curve. * @returns the Path3D array of successive Vector3 designing its curve. */ getCurve(): Vector3[]; /** * Returns an array populated with tangent vectors on each Path3D curve point. * @returns an array populated with tangent vectors on each Path3D curve point. */ getTangents(): Vector3[]; /** * Returns an array populated with normal vectors on each Path3D curve point. * @returns an array populated with normal vectors on each Path3D curve point. */ getNormals(): Vector3[]; /** * Returns an array populated with binormal vectors on each Path3D curve point. * @returns an array populated with binormal vectors on each Path3D curve point. */ getBinormals(): Vector3[]; /** * Returns an array populated with distances (float) of the i-th point from the first curve point. * @returns an array populated with distances (float) of the i-th point from the first curve point. */ getDistances(): number[]; /** * Forces the Path3D tangent, normal, binormal and distance recomputation. * @param path path which all values are copied into the curves points * @param firstNormal which should be projected onto the curve * @returns the same object updated. */ update(path: Vector3[], firstNormal?: Nullable): Path3D; private _compute; private _getFirstNonNullVector; private _getLastNonNullVector; private _normalVector; } /** * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space. * A Curve3 is designed from a series of successive Vector3. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3 */ export class Curve3 { private _points; private _length; /** * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve * @param v0 (Vector3) the origin point of the Quadratic Bezier * @param v1 (Vector3) the control point * @param v2 (Vector3) the end point of the Quadratic Bezier * @param nbPoints (integer) the wanted number of points in the curve * @returns the created Curve3 */ static CreateQuadraticBezier(v0: DeepImmutable, v1: DeepImmutable, v2: DeepImmutable, nbPoints: number): Curve3; /** * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve * @param v0 (Vector3) the origin point of the Cubic Bezier * @param v1 (Vector3) the first control point * @param v2 (Vector3) the second control point * @param v3 (Vector3) the end point of the Cubic Bezier * @param nbPoints (integer) the wanted number of points in the curve * @returns the created Curve3 */ static CreateCubicBezier(v0: DeepImmutable, v1: DeepImmutable, v2: DeepImmutable, v3: DeepImmutable, nbPoints: number): Curve3; /** * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline * @param p1 (Vector3) the origin point of the Hermite Spline * @param t1 (Vector3) the tangent vector at the origin point * @param p2 (Vector3) the end point of the Hermite Spline * @param t2 (Vector3) the tangent vector at the end point * @param nbPoints (integer) the wanted number of points in the curve * @returns the created Curve3 */ static CreateHermiteSpline(p1: DeepImmutable, t1: DeepImmutable, p2: DeepImmutable, t2: DeepImmutable, nbPoints: number): Curve3; /** * Returns a Curve3 object along a CatmullRom Spline curve : * @param points (array of Vector3) the points the spline must pass through. At least, four points required * @param nbPoints (integer) the wanted number of points between each curve control points * @param closed (boolean) optional with default false, when true forms a closed loop from the points * @returns the created Curve3 */ static CreateCatmullRomSpline(points: DeepImmutable, nbPoints: number, closed?: boolean): Curve3; /** * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space. * A Curve3 is designed from a series of successive Vector3. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object * @param points points which make up the curve */ constructor(points: Vector3[]); /** * @returns the Curve3 stored array of successive Vector3 */ getPoints(): Vector3[]; /** * @returns the computed length (float) of the curve. */ length(): number; /** * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB); * This new Curve3 is built by translating and sticking the curveB at the end of the curveA. * curveA and curveB keep unchanged. * @param curve the curve to continue from this curve * @returns the newly constructed curve */ continue(curve: DeepImmutable): Curve3; private _computeLength; } /** * Contains position and normal vectors for a vertex */ export class PositionNormalVertex { /** the position of the vertex (defaut: 0,0,0) */ position: Vector3; /** the normal of the vertex (defaut: 0,1,0) */ normal: Vector3; /** * Creates a PositionNormalVertex * @param position the position of the vertex (defaut: 0,0,0) * @param normal the normal of the vertex (defaut: 0,1,0) */ constructor( /** the position of the vertex (defaut: 0,0,0) */ position?: Vector3, /** the normal of the vertex (defaut: 0,1,0) */ normal?: Vector3); /** * Clones the PositionNormalVertex * @returns the cloned PositionNormalVertex */ clone(): PositionNormalVertex; } /** * Contains position, normal and uv vectors for a vertex */ export class PositionNormalTextureVertex { /** the position of the vertex (defaut: 0,0,0) */ position: Vector3; /** the normal of the vertex (defaut: 0,1,0) */ normal: Vector3; /** the uv of the vertex (default: 0,0) */ uv: Vector2; /** * Creates a PositionNormalTextureVertex * @param position the position of the vertex (defaut: 0,0,0) * @param normal the normal of the vertex (defaut: 0,1,0) * @param uv the uv of the vertex (default: 0,0) */ constructor( /** the position of the vertex (defaut: 0,0,0) */ position?: Vector3, /** the normal of the vertex (defaut: 0,1,0) */ normal?: Vector3, /** the uv of the vertex (default: 0,0) */ uv?: Vector2); /** * Clones the PositionNormalTextureVertex * @returns the cloned PositionNormalTextureVertex */ clone(): PositionNormalTextureVertex; } /** * @hidden */ export class Tmp { static Color3: Color3[]; static Color4: Color4[]; static Vector2: Vector2[]; static Vector3: Vector3[]; static Vector4: Vector4[]; static Quaternion: Quaternion[]; static Matrix: Matrix[]; } } declare module BABYLON { /** * Class used to enable access to offline support * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb */ export interface IOfflineProvider { /** * Gets a boolean indicating if scene must be saved in the database */ enableSceneOffline: boolean; /** * Gets a boolean indicating if textures must be saved in the database */ enableTexturesOffline: boolean; /** * Open the offline support and make it available * @param successCallback defines the callback to call on success * @param errorCallback defines the callback to call on error */ open(successCallback: () => void, errorCallback: () => void): void; /** * Loads an image from the offline support * @param url defines the url to load from * @param image defines the target DOM image */ loadImage(url: string, image: HTMLImageElement): void; /** * Loads a file from offline support * @param url defines the URL to load from * @param sceneLoaded defines a callback to call on success * @param progressCallBack defines a callback to call when progress changed * @param errorCallback defines a callback to call on error * @param useArrayBuffer defines a boolean to use array buffer instead of text string */ loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void; } } declare module BABYLON { /** * A class serves as a medium between the observable and its observers */ export class EventState { /** * Create a new EventState * @param mask defines the mask associated with this state * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true * @param target defines the original target of the state * @param currentTarget defines the current target of the state */ constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any); /** * Initialize the current event state * @param mask defines the mask associated with this state * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true * @param target defines the original target of the state * @param currentTarget defines the current target of the state * @returns the current event state */ initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState; /** * An Observer can set this property to true to prevent subsequent observers of being notified */ skipNextObservers: boolean; /** * Get the mask value that were used to trigger the event corresponding to this EventState object */ mask: number; /** * The object that originally notified the event */ target?: any; /** * The current object in the bubbling phase */ currentTarget?: any; /** * This will be populated with the return value of the last function that was executed. * If it is the first function in the callback chain it will be the event data. */ lastReturnValue?: any; } /** * Represent an Observer registered to a given Observable object. */ export class Observer { /** * Defines the callback to call when the observer is notified */ callback: (eventData: T, eventState: EventState) => void; /** * Defines the mask of the observer (used to filter notifications) */ mask: number; /** * Defines the current scope used to restore the JS context */ scope: any; /** @hidden */ _willBeUnregistered: boolean; /** * Gets or sets a property defining that the observer as to be unregistered after the next notification */ unregisterOnNextCall: boolean; /** * Creates a new observer * @param callback defines the callback to call when the observer is notified * @param mask defines the mask of the observer (used to filter notifications) * @param scope defines the current scope used to restore the JS context */ constructor( /** * Defines the callback to call when the observer is notified */ callback: (eventData: T, eventState: EventState) => void, /** * Defines the mask of the observer (used to filter notifications) */ mask: number, /** * Defines the current scope used to restore the JS context */ scope?: any); } /** * Represent a list of observers registered to multiple Observables object. */ export class MultiObserver { private _observers; private _observables; /** * Release associated resources */ dispose(): void; /** * Raise a callback when one of the observable will notify * @param observables defines a list of observables to watch * @param callback defines the callback to call on notification * @param mask defines the mask used to filter notifications * @param scope defines the current scope used to restore the JS context * @returns the new MultiObserver */ static Watch(observables: Observable[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver; } /** * The Observable class is a simple implementation of the Observable pattern. * * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified. * This enable a more fine grained execution without having to rely on multiple different Observable objects. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08). * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right. */ export class Observable { private _observers; private _eventState; private _onObserverAdded; /** * Creates a new observable * @param onObserverAdded defines a callback to call when a new observer is added */ constructor(onObserverAdded?: (observer: Observer) => void); /** * Create a new Observer with the specified callback * @param callback the callback that will be executed for that Observer * @param mask the mask used to filter observers * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present. * @param scope optional scope for the callback to be called from * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification * @returns the new observer created for the callback */ add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable>; /** * Create a new Observer with the specified callback and unregisters after the next notification * @param callback the callback that will be executed for that Observer * @returns the new observer created for the callback */ addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable>; /** * Remove an Observer from the Observable object * @param observer the instance of the Observer to remove * @returns false if it doesn't belong to this Observable */ remove(observer: Nullable>): boolean; /** * Remove a callback from the Observable object * @param callback the callback to remove * @param scope optional scope. If used only the callbacks with this scope will be removed * @returns false if it doesn't belong to this Observable */ removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean; private _deferUnregister; private _remove; /** * Moves the observable to the top of the observer list making it get called first when notified * @param observer the observer to move */ makeObserverTopPriority(observer: Observer): void; /** * Moves the observable to the bottom of the observer list making it get called last when notified * @param observer the observer to move */ makeObserverBottomPriority(observer: Observer): void; /** * Notify all Observers by calling their respective callback with the given data * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute * @param eventData defines the data to send to all observers * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified) * @param target defines the original target of the state * @param currentTarget defines the current target of the state * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true) */ notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean; /** * Calling this will execute each callback, expecting it to be a promise or return a value. * If at any point in the chain one function fails, the promise will fail and the execution will not continue. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object * and it is crucial that all callbacks will be executed. * The order of the callbacks is kept, callbacks are not executed parallel. * * @param eventData The data to be sent to each callback * @param mask is used to filter observers defaults to -1 * @param target defines the callback target (see EventState) * @param currentTarget defines he current object in the bubbling phase * @returns {Promise} will return a Promise than resolves when all callbacks executed successfully. */ notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise; /** * Notify a specific observer * @param observer defines the observer to notify * @param eventData defines the data to be sent to each callback * @param mask is used to filter observers defaults to -1 */ notifyObserver(observer: Observer, eventData: T, mask?: number): void; /** * Gets a boolean indicating if the observable has at least one observer * @returns true is the Observable has at least one Observer registered */ hasObservers(): boolean; /** * Clear the list of observers */ clear(): void; /** * Clone the current observable * @returns a new observable */ clone(): Observable; /** * Does this observable handles observer registered with a given mask * @param mask defines the mask to be tested * @return whether or not one observer registered with the given mask is handeled **/ hasSpecificMask(mask?: number): boolean; } } declare module BABYLON { /** * Class used to help managing file picking and drag'n'drop * File Storage */ export class FilesInputStore { /** * List of files ready to be loaded */ static FilesToLoad: { [key: string]: File; }; } } declare module BABYLON { /** Defines the cross module used constants to avoid circular dependncies */ export class Constants { /** Defines that alpha blending is disabled */ static readonly ALPHA_DISABLE: number; /** Defines that alpha blending to SRC ALPHA * SRC + DEST */ static readonly ALPHA_ADD: number; /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */ static readonly ALPHA_COMBINE: number; /** Defines that alpha blending to DEST - SRC * DEST */ static readonly ALPHA_SUBTRACT: number; /** Defines that alpha blending to SRC * DEST */ static readonly ALPHA_MULTIPLY: number; /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */ static readonly ALPHA_MAXIMIZED: number; /** Defines that alpha blending to SRC + DEST */ static readonly ALPHA_ONEONE: number; /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */ static readonly ALPHA_PREMULTIPLIED: number; /** * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA */ static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number; /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */ static readonly ALPHA_INTERPOLATE: number; /** * Defines that alpha blending to SRC + (1 - SRC) * DEST * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA */ static readonly ALPHA_SCREENMODE: number; /** Defines that the ressource is not delayed*/ static readonly DELAYLOADSTATE_NONE: number; /** Defines that the ressource was successfully delay loaded */ static readonly DELAYLOADSTATE_LOADED: number; /** Defines that the ressource is currently delay loading */ static readonly DELAYLOADSTATE_LOADING: number; /** Defines that the ressource is delayed and has not started loading */ static readonly DELAYLOADSTATE_NOTLOADED: number; /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */ static readonly NEVER: number; /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */ static readonly ALWAYS: number; /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */ static readonly LESS: number; /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */ static readonly EQUAL: number; /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */ static readonly LEQUAL: number; /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */ static readonly GREATER: number; /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */ static readonly GEQUAL: number; /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */ static readonly NOTEQUAL: number; /** Passed to stencilOperation to specify that stencil value must be kept */ static readonly KEEP: number; /** Passed to stencilOperation to specify that stencil value must be replaced */ static readonly REPLACE: number; /** Passed to stencilOperation to specify that stencil value must be incremented */ static readonly INCR: number; /** Passed to stencilOperation to specify that stencil value must be decremented */ static readonly DECR: number; /** Passed to stencilOperation to specify that stencil value must be inverted */ static readonly INVERT: number; /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */ static readonly INCR_WRAP: number; /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */ static readonly DECR_WRAP: number; /** Texture is not repeating outside of 0..1 UVs */ static readonly TEXTURE_CLAMP_ADDRESSMODE: number; /** Texture is repeating outside of 0..1 UVs */ static readonly TEXTURE_WRAP_ADDRESSMODE: number; /** Texture is repeating and mirrored */ static readonly TEXTURE_MIRROR_ADDRESSMODE: number; /** ALPHA */ static readonly TEXTUREFORMAT_ALPHA: number; /** LUMINANCE */ static readonly TEXTUREFORMAT_LUMINANCE: number; /** LUMINANCE_ALPHA */ static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number; /** RGB */ static readonly TEXTUREFORMAT_RGB: number; /** RGBA */ static readonly TEXTUREFORMAT_RGBA: number; /** RED */ static readonly TEXTUREFORMAT_RED: number; /** RED (2nd reference) */ static readonly TEXTUREFORMAT_R: number; /** RG */ static readonly TEXTUREFORMAT_RG: number; /** RED_INTEGER */ static readonly TEXTUREFORMAT_RED_INTEGER: number; /** RED_INTEGER (2nd reference) */ static readonly TEXTUREFORMAT_R_INTEGER: number; /** RG_INTEGER */ static readonly TEXTUREFORMAT_RG_INTEGER: number; /** RGB_INTEGER */ static readonly TEXTUREFORMAT_RGB_INTEGER: number; /** RGBA_INTEGER */ static readonly TEXTUREFORMAT_RGBA_INTEGER: number; /** UNSIGNED_BYTE */ static readonly TEXTURETYPE_UNSIGNED_BYTE: number; /** UNSIGNED_BYTE (2nd reference) */ static readonly TEXTURETYPE_UNSIGNED_INT: number; /** FLOAT */ static readonly TEXTURETYPE_FLOAT: number; /** HALF_FLOAT */ static readonly TEXTURETYPE_HALF_FLOAT: number; /** BYTE */ static readonly TEXTURETYPE_BYTE: number; /** SHORT */ static readonly TEXTURETYPE_SHORT: number; /** UNSIGNED_SHORT */ static readonly TEXTURETYPE_UNSIGNED_SHORT: number; /** INT */ static readonly TEXTURETYPE_INT: number; /** UNSIGNED_INT */ static readonly TEXTURETYPE_UNSIGNED_INTEGER: number; /** UNSIGNED_SHORT_4_4_4_4 */ static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number; /** UNSIGNED_SHORT_5_5_5_1 */ static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number; /** UNSIGNED_SHORT_5_6_5 */ static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number; /** UNSIGNED_INT_2_10_10_10_REV */ static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number; /** UNSIGNED_INT_24_8 */ static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number; /** UNSIGNED_INT_10F_11F_11F_REV */ static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number; /** UNSIGNED_INT_5_9_9_9_REV */ static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number; /** FLOAT_32_UNSIGNED_INT_24_8_REV */ static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number; /** nearest is mag = nearest and min = nearest and mip = linear */ static readonly TEXTURE_NEAREST_SAMPLINGMODE: number; /** Bilinear is mag = linear and min = linear and mip = nearest */ static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number; /** Trilinear is mag = linear and min = linear and mip = linear */ static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number; /** nearest is mag = nearest and min = nearest and mip = linear */ static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number; /** Bilinear is mag = linear and min = linear and mip = nearest */ static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number; /** Trilinear is mag = linear and min = linear and mip = linear */ static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number; /** mag = nearest and min = nearest and mip = nearest */ static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number; /** mag = nearest and min = linear and mip = nearest */ static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number; /** mag = nearest and min = linear and mip = linear */ static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number; /** mag = nearest and min = linear and mip = none */ static readonly TEXTURE_NEAREST_LINEAR: number; /** mag = nearest and min = nearest and mip = none */ static readonly TEXTURE_NEAREST_NEAREST: number; /** mag = linear and min = nearest and mip = nearest */ static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number; /** mag = linear and min = nearest and mip = linear */ static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number; /** mag = linear and min = linear and mip = none */ static readonly TEXTURE_LINEAR_LINEAR: number; /** mag = linear and min = nearest and mip = none */ static readonly TEXTURE_LINEAR_NEAREST: number; /** Explicit coordinates mode */ static readonly TEXTURE_EXPLICIT_MODE: number; /** Spherical coordinates mode */ static readonly TEXTURE_SPHERICAL_MODE: number; /** Planar coordinates mode */ static readonly TEXTURE_PLANAR_MODE: number; /** Cubic coordinates mode */ static readonly TEXTURE_CUBIC_MODE: number; /** Projection coordinates mode */ static readonly TEXTURE_PROJECTION_MODE: number; /** Skybox coordinates mode */ static readonly TEXTURE_SKYBOX_MODE: number; /** Inverse Cubic coordinates mode */ static readonly TEXTURE_INVCUBIC_MODE: number; /** Equirectangular coordinates mode */ static readonly TEXTURE_EQUIRECTANGULAR_MODE: number; /** Equirectangular Fixed coordinates mode */ static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number; /** Equirectangular Fixed Mirrored coordinates mode */ static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number; /** Defines that texture rescaling will use a floor to find the closer power of 2 size */ static readonly SCALEMODE_FLOOR: number; /** Defines that texture rescaling will look for the nearest power of 2 size */ static readonly SCALEMODE_NEAREST: number; /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */ static readonly SCALEMODE_CEILING: number; /** * The dirty texture flag value */ static readonly MATERIAL_TextureDirtyFlag: number; /** * The dirty light flag value */ static readonly MATERIAL_LightDirtyFlag: number; /** * The dirty fresnel flag value */ static readonly MATERIAL_FresnelDirtyFlag: number; /** * The dirty attribute flag value */ static readonly MATERIAL_AttributesDirtyFlag: number; /** * The dirty misc flag value */ static readonly MATERIAL_MiscDirtyFlag: number; /** * The all dirty flag value */ static readonly MATERIAL_AllDirtyFlag: number; /** * Returns the triangle fill mode */ static readonly MATERIAL_TriangleFillMode: number; /** * Returns the wireframe mode */ static readonly MATERIAL_WireFrameFillMode: number; /** * Returns the point fill mode */ static readonly MATERIAL_PointFillMode: number; /** * Returns the point list draw mode */ static readonly MATERIAL_PointListDrawMode: number; /** * Returns the line list draw mode */ static readonly MATERIAL_LineListDrawMode: number; /** * Returns the line loop draw mode */ static readonly MATERIAL_LineLoopDrawMode: number; /** * Returns the line strip draw mode */ static readonly MATERIAL_LineStripDrawMode: number; /** * Returns the triangle strip draw mode */ static readonly MATERIAL_TriangleStripDrawMode: number; /** * Returns the triangle fan draw mode */ static readonly MATERIAL_TriangleFanDrawMode: number; /** * Stores the clock-wise side orientation */ static readonly MATERIAL_ClockWiseSideOrientation: number; /** * Stores the counter clock-wise side orientation */ static readonly MATERIAL_CounterClockWiseSideOrientation: number; /** * Nothing * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly ACTION_NothingTrigger: number; /** * On pick * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly ACTION_OnPickTrigger: number; /** * On left pick * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly ACTION_OnLeftPickTrigger: number; /** * On right pick * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly ACTION_OnRightPickTrigger: number; /** * On center pick * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly ACTION_OnCenterPickTrigger: number; /** * On pick down * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly ACTION_OnPickDownTrigger: number; /** * On double pick * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly ACTION_OnDoublePickTrigger: number; /** * On pick up * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly ACTION_OnPickUpTrigger: number; /** * On pick out. * This trigger will only be raised if you also declared a OnPickDown * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly ACTION_OnPickOutTrigger: number; /** * On long press * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly ACTION_OnLongPressTrigger: number; /** * On pointer over * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly ACTION_OnPointerOverTrigger: number; /** * On pointer out * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly ACTION_OnPointerOutTrigger: number; /** * On every frame * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly ACTION_OnEveryFrameTrigger: number; /** * On intersection enter * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly ACTION_OnIntersectionEnterTrigger: number; /** * On intersection exit * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly ACTION_OnIntersectionExitTrigger: number; /** * On key down * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly ACTION_OnKeyDownTrigger: number; /** * On key up * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly ACTION_OnKeyUpTrigger: number; /** * Billboard mode will only apply to Y axis */ static readonly PARTICLES_BILLBOARDMODE_Y: number; /** * Billboard mode will apply to all axes */ static readonly PARTICLES_BILLBOARDMODE_ALL: number; /** * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction */ static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number; /** * Gets or sets base Assets URL */ static PARTICLES_BaseAssetsUrl: string; /** Default culling strategy : this is an exclusion test and it's the more accurate. * Test order : * Is the bounding sphere outside the frustum ? * If not, are the bounding box vertices outside the frustum ? * It not, then the cullable object is in the frustum. */ static readonly MESHES_CULLINGSTRATEGY_STANDARD: number; /** Culling strategy : Bounding Sphere Only. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested. * It's also less accurate than the standard because some not visible objects can still be selected. * Test : is the bounding sphere outside the frustum ? * If not, then the cullable object is in the frustum. */ static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number; /** Culling strategy : Optimistic Inclusion. * This in an inclusion test first, then the standard exclusion test. * This can be faster when a cullable object is expected to be almost always in the camera frustum. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside. * Anyway, it's as accurate as the standard strategy. * Test : * Is the cullable object bounding sphere center in the frustum ? * If not, apply the default culling strategy. */ static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number; /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only. * This in an inclusion test first, then the bounding sphere only exclusion test. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy. * Test : * Is the cullable object bounding sphere center in the frustum ? * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here. */ static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number; /** * No logging while loading */ static readonly SCENELOADER_NO_LOGGING: number; /** * Minimal logging while loading */ static readonly SCENELOADER_MINIMAL_LOGGING: number; /** * Summary logging while loading */ static readonly SCENELOADER_SUMMARY_LOGGING: number; /** * Detailled logging while loading */ static readonly SCENELOADER_DETAILED_LOGGING: number; } } declare module BABYLON { /** * Sets of helpers dealing with the DOM and some of the recurrent functions needed in * Babylon.js */ export class DomManagement { /** * Checks if the window object exists * @returns true if the window object exists */ static IsWindowObjectExist(): boolean; /** * Extracts text content from a DOM element hierarchy * @param element defines the root element * @returns a string */ static GetDOMTextContent(element: HTMLElement): string; } } declare module BABYLON { /** * Logger used througouht the application to allow configuration of * the log level required for the messages. */ export class Logger { /** * No log */ static readonly NoneLogLevel: number; /** * Only message logs */ static readonly MessageLogLevel: number; /** * Only warning logs */ static readonly WarningLogLevel: number; /** * Only error logs */ static readonly ErrorLogLevel: number; /** * All logs */ static readonly AllLogLevel: number; private static _LogCache; /** * Gets a value indicating the number of loading errors * @ignorenaming */ static errorsCount: number; /** * Callback called when a new log is added */ static OnNewCacheEntry: (entry: string) => void; private static _AddLogEntry; private static _FormatMessage; private static _LogDisabled; private static _LogEnabled; private static _WarnDisabled; private static _WarnEnabled; private static _ErrorDisabled; private static _ErrorEnabled; /** * Log a message to the console */ static Log: (message: string) => void; /** * Write a warning message to the console */ static Warn: (message: string) => void; /** * Write an error message to the console */ static Error: (message: string) => void; /** * Gets current log cache (list of logs) */ static readonly LogCache: string; /** * Clears the log cache */ static ClearLogCache(): void; /** * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel) */ static LogLevels: number; } } declare module BABYLON { /** @hidden */ export class _TypeStore { /** @hidden */ static RegisteredTypes: { [key: string]: Object; }; /** @hidden */ static GetClass(fqdn: string): any; } } declare module BABYLON { /** * Class containing a set of static utilities functions for deep copy. */ export class DeepCopier { /** * Tries to copy an object by duplicating every property * @param source defines the source object * @param destination defines the target object * @param doNotCopyList defines a list of properties to avoid * @param mustCopyList defines a list of properties to copy (even if they start with _) */ static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void; } } declare module BABYLON { /** * Class containing a set of static utilities functions for precision date */ export class PrecisionDate { /** * Gets either window.performance.now() if supported or Date.now() else */ static readonly Now: number; } } declare module BABYLON { /** @hidden */ export class _DevTools { static WarnImport(name: string): string; } } declare module BABYLON { /** * Extended version of XMLHttpRequest with support for customizations (headers, ...) */ export class WebRequest { private _xhr; /** * Custom HTTP Request Headers to be sent with XMLHttpRequests * i.e. when loading files, where the server/service expects an Authorization header */ static CustomRequestHeaders: { [key: string]: string; }; /** * Add callback functions in this array to update all the requests before they get sent to the network */ static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[]; private _injectCustomRequestHeaders; /** * Gets or sets a function to be called when loading progress changes */ onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null; /** * Returns client's state */ readonly readyState: number; /** * Returns client's status */ readonly status: number; /** * Returns client's status as a text */ readonly statusText: string; /** * Returns client's response */ readonly response: any; /** * Returns client's response url */ readonly responseURL: string; /** * Returns client's response as text */ readonly responseText: string; /** * Gets or sets the expected response type */ responseType: XMLHttpRequestResponseType; /** @hidden */ addEventListener(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; /** @hidden */ removeEventListener(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void; /** * Cancels any network activity */ abort(): void; /** * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD * @param body defines an optional request body */ send(body?: Document | BodyInit | null): void; /** * Sets the request method, request URL * @param method defines the method to use (GET, POST, etc..) * @param url defines the url to connect with */ open(method: string, url: string): void; } } declare module BABYLON { /** * Class used to evalaute queries containing `and` and `or` operators */ export class AndOrNotEvaluator { /** * Evaluate a query * @param query defines the query to evaluate * @param evaluateCallback defines the callback used to filter result * @returns true if the query matches */ static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean; private static _HandleParenthesisContent; private static _SimplifyNegation; } } declare module BABYLON { /** * Class used to store custom tags */ export class Tags { /** * Adds support for tags on the given object * @param obj defines the object to use */ static EnableFor(obj: any): void; /** * Removes tags support * @param obj defines the object to use */ static DisableFor(obj: any): void; /** * Gets a boolean indicating if the given object has tags * @param obj defines the object to use * @returns a boolean */ static HasTags(obj: any): boolean; /** * Gets the tags available on a given object * @param obj defines the object to use * @param asString defines if the tags must be returned as a string instead of an array of strings * @returns the tags */ static GetTags(obj: any, asString?: boolean): any; /** * Adds tags to an object * @param obj defines the object to use * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces */ static AddTagsTo(obj: any, tagsString: string): void; /** * @hidden */ static _AddTagTo(obj: any, tag: string): void; /** * Removes specific tags from a specific object * @param obj defines the object to use * @param tagsString defines the tags to remove */ static RemoveTagsFrom(obj: any, tagsString: string): void; /** * @hidden */ static _RemoveTagFrom(obj: any, tag: string): void; /** * Defines if tags hosted on an object match a given query * @param obj defines the object to use * @param tagsQuery defines the tag query * @returns a boolean */ static MatchesQuery(obj: any, tagsQuery: string): boolean; } } declare module BABYLON { /** * Manages the defines for the Material */ export class MaterialDefines { /** @hidden */ protected _keys: string[]; private _isDirty; /** @hidden */ _renderId: number; /** @hidden */ _areLightsDirty: boolean; /** @hidden */ _areAttributesDirty: boolean; /** @hidden */ _areTexturesDirty: boolean; /** @hidden */ _areFresnelDirty: boolean; /** @hidden */ _areMiscDirty: boolean; /** @hidden */ _areImageProcessingDirty: boolean; /** @hidden */ _normals: boolean; /** @hidden */ _uvs: boolean; /** @hidden */ _needNormals: boolean; /** @hidden */ _needUVs: boolean; [id: string]: any; /** * Specifies if the material needs to be re-calculated */ readonly isDirty: boolean; /** * Marks the material to indicate that it has been re-calculated */ markAsProcessed(): void; /** * Marks the material to indicate that it needs to be re-calculated */ markAsUnprocessed(): void; /** * Marks the material to indicate all of its defines need to be re-calculated */ markAllAsDirty(): void; /** * Marks the material to indicate that image processing needs to be re-calculated */ markAsImageProcessingDirty(): void; /** * Marks the material to indicate the lights need to be re-calculated */ markAsLightDirty(): void; /** * Marks the attribute state as changed */ markAsAttributesDirty(): void; /** * Marks the texture state as changed */ markAsTexturesDirty(): void; /** * Marks the fresnel state as changed */ markAsFresnelDirty(): void; /** * Marks the misc state as changed */ markAsMiscDirty(): void; /** * Rebuilds the material defines */ rebuild(): void; /** * Specifies if two material defines are equal * @param other - A material define instance to compare to * @returns - Boolean indicating if the material defines are equal (true) or not (false) */ isEqual(other: MaterialDefines): boolean; /** * Clones this instance's defines to another instance * @param other - material defines to clone values to */ cloneTo(other: MaterialDefines): void; /** * Resets the material define values */ reset(): void; /** * Converts the material define values to a string * @returns - String of material define information */ toString(): string; } } declare module BABYLON { /** * Class used to store and describe the pipeline context associated with an effect */ export interface IPipelineContext { /** * Gets a boolean indicating that this pipeline context is supporting asynchronous creating */ isAsync: boolean; /** * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance) */ isReady: boolean; /** @hidden */ _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void; } } declare module BABYLON { /** * Class used to store gfx data (like WebGLBuffer) */ export class DataBuffer { /** * Gets or sets the number of objects referencing this buffer */ references: number; /** Gets or sets the size of the underlying buffer */ capacity: number; /** * Gets or sets a boolean indicating if the buffer contains 32bits indices */ is32Bits: boolean; /** * Gets the underlying buffer */ readonly underlyingResource: any; } } declare module BABYLON { /** @hidden */ export interface IShaderProcessor { attributeProcessor?: (attribute: string) => string; varyingProcessor?: (varying: string, isFragment: boolean) => string; preProcessor?: (code: string, defines: string[], isFragment: boolean) => string; postProcessor?: (code: string, defines: string[], isFragment: boolean) => string; } } declare module BABYLON { /** @hidden */ export interface ProcessingOptions { defines: string[]; indexParameters: any; isFragment: boolean; shouldUseHighPrecisionShader: boolean; supportsUniformBuffers: boolean; shadersRepository: string; includesShadersStore: { [key: string]: string; }; processor?: IShaderProcessor; version: string; } } declare module BABYLON { /** @hidden */ export class ShaderCodeNode { line: string; children: ShaderCodeNode[]; additionalDefineKey?: string; additionalDefineValue?: string; isValid(preprocessors: { [key: string]: string; }): boolean; process(preprocessors: { [key: string]: string; }, options: ProcessingOptions): string; private _lineStartsWith; } } declare module BABYLON { /** @hidden */ export class ShaderCodeCursor { private _lines; lineIndex: number; readonly currentLine: string; readonly canRead: boolean; lines: string[]; } } declare module BABYLON { /** @hidden */ export class ShaderCodeConditionNode extends ShaderCodeNode { process(preprocessors: { [key: string]: string; }, options: ProcessingOptions): string; } } declare module BABYLON { /** @hidden */ export class ShaderDefineExpression { isTrue(preprocessors: { [key: string]: string; }): boolean; } } declare module BABYLON { /** @hidden */ export class ShaderCodeTestNode extends ShaderCodeNode { testExpression: ShaderDefineExpression; isValid(preprocessors: { [key: string]: string; }): boolean; } } declare module BABYLON { /** @hidden */ export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression { define: string; not: boolean; constructor(define: string, not?: boolean); isTrue(preprocessors: { [key: string]: string; }): boolean; } } declare module BABYLON { /** @hidden */ export class ShaderDefineOrOperator extends ShaderDefineExpression { leftOperand: ShaderDefineExpression; rightOperand: ShaderDefineExpression; isTrue(preprocessors: { [key: string]: string; }): boolean; } } declare module BABYLON { /** @hidden */ export class ShaderDefineAndOperator extends ShaderDefineExpression { leftOperand: ShaderDefineExpression; rightOperand: ShaderDefineExpression; isTrue(preprocessors: { [key: string]: string; }): boolean; } } declare module BABYLON { /** @hidden */ export class ShaderDefineArithmeticOperator extends ShaderDefineExpression { define: string; operand: string; testValue: string; constructor(define: string, operand: string, testValue: string); isTrue(preprocessors: { [key: string]: string; }): boolean; } } declare module BABYLON { /** @hidden */ export class ShaderProcessor { static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void; private static _ProcessPrecision; private static _ExtractOperation; private static _BuildSubExpression; private static _BuildExpression; private static _MoveCursorWithinIf; private static _MoveCursor; private static _EvaluatePreProcessors; private static _PreparePreProcessors; private static _ProcessShaderConversion; private static _ProcessIncludes; } } declare module BABYLON { /** * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window */ export class PerformanceMonitor { private _enabled; private _rollingFrameTime; private _lastFrameTimeMs; /** * constructor * @param frameSampleSize The number of samples required to saturate the sliding window */ constructor(frameSampleSize?: number); /** * Samples current frame * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames */ sampleFrame(timeMs?: number): void; /** * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far) */ readonly averageFrameTime: number; /** * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far) */ readonly averageFrameTimeVariance: number; /** * Returns the frame time of the most recent frame */ readonly instantaneousFrameTime: number; /** * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far) */ readonly averageFPS: number; /** * Returns the average framerate in frames per second using the most recent frame time */ readonly instantaneousFPS: number; /** * Returns true if enough samples have been taken to completely fill the sliding window */ readonly isSaturated: boolean; /** * Enables contributions to the sliding window sample set */ enable(): void; /** * Disables contributions to the sliding window sample set * Samples will not be interpolated over the disabled period */ disable(): void; /** * Returns true if sampling is enabled */ readonly isEnabled: boolean; /** * Resets performance monitor */ reset(): void; } /** * RollingAverage * * Utility to efficiently compute the rolling average and variance over a sliding window of samples */ export class RollingAverage { /** * Current average */ average: number; /** * Current variance */ variance: number; protected _samples: Array; protected _sampleCount: number; protected _pos: number; protected _m2: number; /** * constructor * @param length The number of samples required to saturate the sliding window */ constructor(length: number); /** * Adds a sample to the sample set * @param v The sample value */ add(v: number): void; /** * Returns previously added values or null if outside of history or outside the sliding window domain * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that * @return Value previously recorded with add() or null if outside of range */ history(i: number): number; /** * Returns true if enough samples have been taken to completely fill the sliding window * @return true if sample-set saturated */ isSaturated(): boolean; /** * Resets the rolling average (equivalent to 0 samples taken so far) */ reset(): void; /** * Wraps a value around the sample range boundaries * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned. * @return Wrapped position in sample range */ protected _wrapPosition(i: number): number; } } declare module BABYLON { /** * This class implement a typical dictionary using a string as key and the generic type T as value. * The underlying implementation relies on an associative array to ensure the best performances. * The value can be anything including 'null' but except 'undefined' */ export class StringDictionary { /** * This will clear this dictionary and copy the content from the 'source' one. * If the T value is a custom object, it won't be copied/cloned, the same object will be used * @param source the dictionary to take the content from and copy to this dictionary */ copyFrom(source: StringDictionary): void; /** * Get a value based from its key * @param key the given key to get the matching value from * @return the value if found, otherwise undefined is returned */ get(key: string): T | undefined; /** * Get a value from its key or add it if it doesn't exist. * This method will ensure you that a given key/data will be present in the dictionary. * @param key the given key to get the matching value from * @param factory the factory that will create the value if the key is not present in the dictionary. * The factory will only be invoked if there's no data for the given key. * @return the value corresponding to the key. */ getOrAddWithFactory(key: string, factory: (key: string) => T): T; /** * Get a value from its key if present in the dictionary otherwise add it * @param key the key to get the value from * @param val if there's no such key/value pair in the dictionary add it with this value * @return the value corresponding to the key */ getOrAdd(key: string, val: T): T; /** * Check if there's a given key in the dictionary * @param key the key to check for * @return true if the key is present, false otherwise */ contains(key: string): boolean; /** * Add a new key and its corresponding value * @param key the key to add * @param value the value corresponding to the key * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary */ add(key: string, value: T): boolean; /** * Update a specific value associated to a key * @param key defines the key to use * @param value defines the value to store * @returns true if the value was updated (or false if the key was not found) */ set(key: string, value: T): boolean; /** * Get the element of the given key and remove it from the dictionary * @param key defines the key to search * @returns the value associated with the key or null if not found */ getAndRemove(key: string): Nullable; /** * Remove a key/value from the dictionary. * @param key the key to remove * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary */ remove(key: string): boolean; /** * Clear the whole content of the dictionary */ clear(): void; /** * Gets the current count */ readonly count: number; /** * Execute a callback on each key/val of the dictionary. * Note that you can remove any element in this dictionary in the callback implementation * @param callback the callback to execute on a given key/value pair */ forEach(callback: (key: string, val: T) => void): void; /** * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object. * If the callback returns null or undefined the method will iterate to the next key/value pair * Note that you can remove any element in this dictionary in the callback implementation * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned * @returns the first item */ first(callback: (key: string, val: T) => TRes): TRes | null; private _count; private _data; } } declare module BABYLON { /** * Helper class that provides a small promise polyfill */ export class PromisePolyfill { /** * Static function used to check if the polyfill is required * If this is the case then the function will inject the polyfill to window.Promise * @param force defines a boolean used to force the injection (mostly for testing purposes) */ static Apply(force?: boolean): void; } } declare module BABYLON { /** * Class used to store data that will be store in GPU memory */ export class Buffer { private _engine; private _buffer; /** @hidden */ _data: Nullable; private _updatable; private _instanced; /** * Gets the byte stride. */ readonly byteStride: number; /** * Constructor * @param engine the engine * @param data the data to use for this buffer * @param updatable whether the data is updatable * @param stride the stride (optional) * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional) * @param instanced whether the buffer is instanced (optional) * @param useBytes set to true if the stride in in bytes (optional) */ constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean); /** * Create a new VertexBuffer based on the current buffer * @param kind defines the vertex buffer kind (position, normal, etc.) * @param offset defines offset in the buffer (0 by default) * @param size defines the size in floats of attributes (position is 3 for instance) * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved) * @param instanced defines if the vertex buffer contains indexed data * @param useBytes defines if the offset and stride are in bytes * @returns the new vertex buffer */ createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer; /** * Gets a boolean indicating if the Buffer is updatable? * @returns true if the buffer is updatable */ isUpdatable(): boolean; /** * Gets current buffer's data * @returns a DataArray or null */ getData(): Nullable; /** * Gets underlying native buffer * @returns underlying native buffer */ getBuffer(): Nullable; /** * Gets the stride in float32 units (i.e. byte stride / 4). * May not be an integer if the byte stride is not divisible by 4. * DEPRECATED. Use byteStride instead. * @returns the stride in float32 units */ getStrideSize(): number; /** * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property * @param data defines the data to store */ create(data?: Nullable): void; /** @hidden */ _rebuild(): void; /** * Update current buffer data * @param data defines the data to store */ update(data: DataArray): void; /** * Updates the data directly. * @param data the new data * @param offset the new offset * @param vertexCount the vertex count (optional) * @param useBytes set to true if the offset is in bytes */ updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void; /** * Release all resources */ dispose(): void; } /** * Specialized buffer used to store vertex data */ export class VertexBuffer { /** @hidden */ _buffer: Buffer; private _kind; private _size; private _ownsBuffer; private _instanced; private _instanceDivisor; /** * The byte type. */ static readonly BYTE: number; /** * The unsigned byte type. */ static readonly UNSIGNED_BYTE: number; /** * The short type. */ static readonly SHORT: number; /** * The unsigned short type. */ static readonly UNSIGNED_SHORT: number; /** * The integer type. */ static readonly INT: number; /** * The unsigned integer type. */ static readonly UNSIGNED_INT: number; /** * The float type. */ static readonly FLOAT: number; /** * Gets or sets the instance divisor when in instanced mode */ instanceDivisor: number; /** * Gets the byte stride. */ readonly byteStride: number; /** * Gets the byte offset. */ readonly byteOffset: number; /** * Gets whether integer data values should be normalized into a certain range when being casted to a float. */ readonly normalized: boolean; /** * Gets the data type of each component in the array. */ readonly type: number; /** * Constructor * @param engine the engine * @param data the data to use for this vertex buffer * @param kind the vertex buffer kind * @param updatable whether the data is updatable * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional) * @param stride the stride (optional) * @param instanced whether the buffer is instanced (optional) * @param offset the offset of the data (optional) * @param size the number of components (optional) * @param type the type of the component (optional) * @param normalized whether the data contains normalized data (optional) * @param useBytes set to true if stride and offset are in bytes (optional) */ constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean); /** @hidden */ _rebuild(): void; /** * Returns the kind of the VertexBuffer (string) * @returns a string */ getKind(): string; /** * Gets a boolean indicating if the VertexBuffer is updatable? * @returns true if the buffer is updatable */ isUpdatable(): boolean; /** * Gets current buffer's data * @returns a DataArray or null */ getData(): Nullable; /** * Gets underlying native buffer * @returns underlying native buffer */ getBuffer(): Nullable; /** * Gets the stride in float32 units (i.e. byte stride / 4). * May not be an integer if the byte stride is not divisible by 4. * DEPRECATED. Use byteStride instead. * @returns the stride in float32 units */ getStrideSize(): number; /** * Returns the offset as a multiple of the type byte length. * DEPRECATED. Use byteOffset instead. * @returns the offset in bytes */ getOffset(): number; /** * Returns the number of components per vertex attribute (integer) * @returns the size in float */ getSize(): number; /** * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced * @returns true if this buffer is instanced */ getIsInstanced(): boolean; /** * Returns the instancing divisor, zero for non-instanced (integer). * @returns a number */ getInstanceDivisor(): number; /** * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property * @param data defines the data to store */ create(data?: DataArray): void; /** * Updates the underlying buffer according to the passed numeric array or Float32Array. * This function will create a new buffer if the current one is not updatable * @param data defines the data to store */ update(data: DataArray): void; /** * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array. * Returns the directly updated WebGLBuffer. * @param data the new data * @param offset the new offset * @param useBytes set to true if the offset is in bytes */ updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void; /** * Disposes the VertexBuffer and the underlying WebGLBuffer. */ dispose(): void; /** * Enumerates each value of this vertex buffer as numbers. * @param count the number of values to enumerate * @param callback the callback function called for each value */ forEach(count: number, callback: (value: number, index: number) => void): void; /** * Positions */ static readonly PositionKind: string; /** * Normals */ static readonly NormalKind: string; /** * Tangents */ static readonly TangentKind: string; /** * Texture coordinates */ static readonly UVKind: string; /** * Texture coordinates 2 */ static readonly UV2Kind: string; /** * Texture coordinates 3 */ static readonly UV3Kind: string; /** * Texture coordinates 4 */ static readonly UV4Kind: string; /** * Texture coordinates 5 */ static readonly UV5Kind: string; /** * Texture coordinates 6 */ static readonly UV6Kind: string; /** * Colors */ static readonly ColorKind: string; /** * Matrix indices (for bones) */ static readonly MatricesIndicesKind: string; /** * Matrix weights (for bones) */ static readonly MatricesWeightsKind: string; /** * Additional matrix indices (for bones) */ static readonly MatricesIndicesExtraKind: string; /** * Additional matrix weights (for bones) */ static readonly MatricesWeightsExtraKind: string; /** * Deduces the stride given a kind. * @param kind The kind string to deduce * @returns The deduced stride */ static DeduceStride(kind: string): number; /** * Gets the byte length of the given type. * @param type the type * @returns the number of bytes */ static GetTypeByteLength(type: number): number; /** * Enumerates each value of the given parameters as numbers. * @param data the data to enumerate * @param byteOffset the byte offset of the data * @param byteStride the byte stride of the data * @param componentCount the number of components per element * @param componentType the type of the component * @param count the total number of components * @param normalized whether the data is normalized * @param callback the callback function called for each value */ static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void; private static _GetFloatValue; } } declare module BABYLON { /** * Class representing spherical harmonics coefficients to the 3rd degree */ export class SphericalHarmonics { /** * Defines whether or not the harmonics have been prescaled for rendering. */ preScaled: boolean; /** * The l0,0 coefficients of the spherical harmonics */ l00: Vector3; /** * The l1,-1 coefficients of the spherical harmonics */ l1_1: Vector3; /** * The l1,0 coefficients of the spherical harmonics */ l10: Vector3; /** * The l1,1 coefficients of the spherical harmonics */ l11: Vector3; /** * The l2,-2 coefficients of the spherical harmonics */ l2_2: Vector3; /** * The l2,-1 coefficients of the spherical harmonics */ l2_1: Vector3; /** * The l2,0 coefficients of the spherical harmonics */ l20: Vector3; /** * The l2,1 coefficients of the spherical harmonics */ l21: Vector3; /** * The l2,2 coefficients of the spherical harmonics */ l22: Vector3; /** * Adds a light to the spherical harmonics * @param direction the direction of the light * @param color the color of the light * @param deltaSolidAngle the delta solid angle of the light */ addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void; /** * Scales the spherical harmonics by the given amount * @param scale the amount to scale */ scaleInPlace(scale: number): void; /** * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere. * * ``` * E_lm = A_l * L_lm * ``` * * In spherical harmonics this convolution amounts to scaling factors for each frequency band. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where * the scaling factors are given in equation 9. */ convertIncidentRadianceToIrradiance(): void; /** * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation. * * ``` * L = (1/pi) * E * rho * ``` * * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually. */ convertIrradianceToLambertianRadiance(): void; /** * Integrates the reconstruction coefficients directly in to the SH preventing further * required operations at run time. * * This is simply done by scaling back the SH with Ylm constants parameter. * The trigonometric part being applied by the shader at run time. */ preScaleForRendering(): void; /** * Constructs a spherical harmonics from an array. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22) * @returns the spherical harmonics */ static FromArray(data: ArrayLike>): SphericalHarmonics; /** * Gets the spherical harmonics from polynomial * @param polynomial the spherical polynomial * @returns the spherical harmonics */ static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics; } /** * Class representing spherical polynomial coefficients to the 3rd degree */ export class SphericalPolynomial { private _harmonics; /** * The spherical harmonics used to create the polynomials. */ readonly preScaledHarmonics: SphericalHarmonics; /** * The x coefficients of the spherical polynomial */ x: Vector3; /** * The y coefficients of the spherical polynomial */ y: Vector3; /** * The z coefficients of the spherical polynomial */ z: Vector3; /** * The xx coefficients of the spherical polynomial */ xx: Vector3; /** * The yy coefficients of the spherical polynomial */ yy: Vector3; /** * The zz coefficients of the spherical polynomial */ zz: Vector3; /** * The xy coefficients of the spherical polynomial */ xy: Vector3; /** * The yz coefficients of the spherical polynomial */ yz: Vector3; /** * The zx coefficients of the spherical polynomial */ zx: Vector3; /** * Adds an ambient color to the spherical polynomial * @param color the color to add */ addAmbient(color: Color3): void; /** * Scales the spherical polynomial by the given amount * @param scale the amount to scale */ scaleInPlace(scale: number): void; /** * Gets the spherical polynomial from harmonics * @param harmonics the spherical harmonics * @returns the spherical polynomial */ static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial; /** * Constructs a spherical polynomial from an array. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy) * @returns the spherical polynomial */ static FromArray(data: ArrayLike>): SphericalPolynomial; } } declare module BABYLON { /** * CubeMap information grouping all the data for each faces as well as the cubemap size. */ export interface CubeMapInfo { /** * The pixel array for the front face. * This is stored in format, left to right, up to down format. */ front: Nullable; /** * The pixel array for the back face. * This is stored in format, left to right, up to down format. */ back: Nullable; /** * The pixel array for the left face. * This is stored in format, left to right, up to down format. */ left: Nullable; /** * The pixel array for the right face. * This is stored in format, left to right, up to down format. */ right: Nullable; /** * The pixel array for the up face. * This is stored in format, left to right, up to down format. */ up: Nullable; /** * The pixel array for the down face. * This is stored in format, left to right, up to down format. */ down: Nullable; /** * The size of the cubemap stored. * * Each faces will be size * size pixels. */ size: number; /** * The format of the texture. * * RGBA, RGB. */ format: number; /** * The type of the texture data. * * UNSIGNED_INT, FLOAT. */ type: number; /** * Specifies whether the texture is in gamma space. */ gammaSpace: boolean; } /** * Helper class useful to convert panorama picture to their cubemap representation in 6 faces. */ export class PanoramaToCubeMapTools { private static FACE_FRONT; private static FACE_BACK; private static FACE_RIGHT; private static FACE_LEFT; private static FACE_DOWN; private static FACE_UP; /** * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces). * * @param float32Array The source data. * @param inputWidth The width of the input panorama. * @param inputHeight The height of the input panorama. * @param size The willing size of the generated cubemap (each faces will be size * size pixels) * @return The cubemap data */ static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo; private static CreateCubemapTexture; private static CalcProjectionSpherical; } } declare module BABYLON { /** * Helper class dealing with the extraction of spherical polynomial dataArray * from a cube map. */ export class CubeMapToSphericalPolynomialTools { private static FileFaces; /** * Converts a texture to the according Spherical Polynomial data. * This extracts the first 3 orders only as they are the only one used in the lighting. * * @param texture The texture to extract the information from. * @return The Spherical Polynomial data. */ static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null; /** * Converts a cubemap to the according Spherical Polynomial data. * This extracts the first 3 orders only as they are the only one used in the lighting. * * @param cubeInfo The Cube map to extract the information from. * @return The Spherical Polynomial data. */ static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial; } } declare module BABYLON { /** * The engine store class is responsible to hold all the instances of Engine and Scene created * during the life time of the application. */ export class EngineStore { /** Gets the list of created engines */ static Instances: Engine[]; /** @hidden */ static _LastCreatedScene: Nullable; /** * Gets the latest created engine */ static readonly LastCreatedEngine: Nullable; /** * Gets the latest created scene */ static readonly LastCreatedScene: Nullable; } } declare module BABYLON { /** * Define options used to create a render target texture */ export class RenderTargetCreationOptions { /** * Specifies is mipmaps must be generated */ generateMipMaps?: boolean; /** Specifies whether or not a depth should be allocated in the texture (true by default) */ generateDepthBuffer?: boolean; /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/ generateStencilBuffer?: boolean; /** Defines texture type (int by default) */ type?: number; /** Defines sampling mode (trilinear by default) */ samplingMode?: number; /** Defines format (RGBA by default) */ format?: number; } } declare module BABYLON { /** * @hidden **/ export class _AlphaState { private _isAlphaBlendDirty; private _isBlendFunctionParametersDirty; private _isBlendEquationParametersDirty; private _isBlendConstantsDirty; private _alphaBlend; private _blendFunctionParameters; private _blendEquationParameters; private _blendConstants; /** * Initializes the state. */ constructor(); readonly isDirty: boolean; alphaBlend: boolean; setAlphaBlendConstants(r: number, g: number, b: number, a: number): void; setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void; setAlphaEquationParameters(rgb: number, alpha: number): void; reset(): void; apply(gl: WebGLRenderingContext): void; } } declare module BABYLON { /** * @hidden **/ export class _DepthCullingState { private _isDepthTestDirty; private _isDepthMaskDirty; private _isDepthFuncDirty; private _isCullFaceDirty; private _isCullDirty; private _isZOffsetDirty; private _isFrontFaceDirty; private _depthTest; private _depthMask; private _depthFunc; private _cull; private _cullFace; private _zOffset; private _frontFace; /** * Initializes the state. */ constructor(); readonly isDirty: boolean; zOffset: number; cullFace: Nullable; cull: Nullable; depthFunc: Nullable; depthMask: boolean; depthTest: boolean; frontFace: Nullable; reset(): void; apply(gl: WebGLRenderingContext): void; } } declare module BABYLON { /** * @hidden **/ export class _StencilState { /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */ static readonly ALWAYS: number; /** Passed to stencilOperation to specify that stencil value must be kept */ static readonly KEEP: number; /** Passed to stencilOperation to specify that stencil value must be replaced */ static readonly REPLACE: number; private _isStencilTestDirty; private _isStencilMaskDirty; private _isStencilFuncDirty; private _isStencilOpDirty; private _stencilTest; private _stencilMask; private _stencilFunc; private _stencilFuncRef; private _stencilFuncMask; private _stencilOpStencilFail; private _stencilOpDepthFail; private _stencilOpStencilDepthPass; readonly isDirty: boolean; stencilFunc: number; stencilFuncRef: number; stencilFuncMask: number; stencilOpStencilFail: number; stencilOpDepthFail: number; stencilOpStencilDepthPass: number; stencilMask: number; stencilTest: boolean; constructor(); reset(): void; apply(gl: WebGLRenderingContext): void; } } declare module BABYLON { /** * @hidden **/ export class _TimeToken { _startTimeQuery: Nullable; _endTimeQuery: Nullable; _timeElapsedQuery: Nullable; _timeElapsedQueryEnded: boolean; } } declare module BABYLON { /** * Class used to store data associated with WebGL texture data for the engine * This class should not be used directly */ export class InternalTexture { /** @hidden */ static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise; /** * The source of the texture data is unknown */ static DATASOURCE_UNKNOWN: number; /** * Texture data comes from an URL */ static DATASOURCE_URL: number; /** * Texture data is only used for temporary storage */ static DATASOURCE_TEMP: number; /** * Texture data comes from raw data (ArrayBuffer) */ static DATASOURCE_RAW: number; /** * Texture content is dynamic (video or dynamic texture) */ static DATASOURCE_DYNAMIC: number; /** * Texture content is generated by rendering to it */ static DATASOURCE_RENDERTARGET: number; /** * Texture content is part of a multi render target process */ static DATASOURCE_MULTIRENDERTARGET: number; /** * Texture data comes from a cube data file */ static DATASOURCE_CUBE: number; /** * Texture data comes from a raw cube data */ static DATASOURCE_CUBERAW: number; /** * Texture data come from a prefiltered cube data file */ static DATASOURCE_CUBEPREFILTERED: number; /** * Texture content is raw 3D data */ static DATASOURCE_RAW3D: number; /** * Texture content is a depth texture */ static DATASOURCE_DEPTHTEXTURE: number; /** * Texture data comes from a raw cube data encoded with RGBD */ static DATASOURCE_CUBERAW_RGBD: number; /** * Defines if the texture is ready */ isReady: boolean; /** * Defines if the texture is a cube texture */ isCube: boolean; /** * Defines if the texture contains 3D data */ is3D: boolean; /** * Defines if the texture contains multiview data */ isMultiview: boolean; /** * Gets the URL used to load this texture */ url: string; /** * Gets the sampling mode of the texture */ samplingMode: number; /** * Gets a boolean indicating if the texture needs mipmaps generation */ generateMipMaps: boolean; /** * Gets the number of samples used by the texture (WebGL2+ only) */ samples: number; /** * Gets the type of the texture (int, float...) */ type: number; /** * Gets the format of the texture (RGB, RGBA...) */ format: number; /** * Observable called when the texture is loaded */ onLoadedObservable: Observable; /** * Gets the width of the texture */ width: number; /** * Gets the height of the texture */ height: number; /** * Gets the depth of the texture */ depth: number; /** * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures) */ baseWidth: number; /** * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures) */ baseHeight: number; /** * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures) */ baseDepth: number; /** * Gets a boolean indicating if the texture is inverted on Y axis */ invertY: boolean; /** @hidden */ _invertVScale: boolean; /** @hidden */ _associatedChannel: number; /** @hidden */ _dataSource: number; /** @hidden */ _buffer: Nullable; /** @hidden */ _bufferView: Nullable; /** @hidden */ _bufferViewArray: Nullable; /** @hidden */ _bufferViewArrayArray: Nullable; /** @hidden */ _size: number; /** @hidden */ _extension: string; /** @hidden */ _files: Nullable; /** @hidden */ _workingCanvas: Nullable; /** @hidden */ _workingContext: Nullable; /** @hidden */ _framebuffer: Nullable; /** @hidden */ _depthStencilBuffer: Nullable; /** @hidden */ _MSAAFramebuffer: Nullable; /** @hidden */ _MSAARenderBuffer: Nullable; /** @hidden */ _attachments: Nullable; /** @hidden */ _cachedCoordinatesMode: Nullable; /** @hidden */ _cachedWrapU: Nullable; /** @hidden */ _cachedWrapV: Nullable; /** @hidden */ _cachedWrapR: Nullable; /** @hidden */ _cachedAnisotropicFilteringLevel: Nullable; /** @hidden */ _isDisabled: boolean; /** @hidden */ _compression: Nullable; /** @hidden */ _generateStencilBuffer: boolean; /** @hidden */ _generateDepthBuffer: boolean; /** @hidden */ _comparisonFunction: number; /** @hidden */ _sphericalPolynomial: Nullable; /** @hidden */ _lodGenerationScale: number; /** @hidden */ _lodGenerationOffset: number; /** @hidden */ _colorTextureArray: Nullable; /** @hidden */ _depthStencilTextureArray: Nullable; /** @hidden */ _lodTextureHigh: Nullable; /** @hidden */ _lodTextureMid: Nullable; /** @hidden */ _lodTextureLow: Nullable; /** @hidden */ _isRGBD: boolean; /** @hidden */ _linearSpecularLOD: boolean; /** @hidden */ _irradianceTexture: Nullable; /** @hidden */ _webGLTexture: Nullable; /** @hidden */ _references: number; private _engine; /** * Gets the Engine the texture belongs to. * @returns The babylon engine */ getEngine(): Engine; /** * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX) */ readonly dataSource: number; /** * Creates a new InternalTexture * @param engine defines the engine to use * @param dataSource defines the type of data that will be used * @param delayAllocation if the texture allocation should be delayed (default: false) */ constructor(engine: Engine, dataSource: number, delayAllocation?: boolean); /** * Increments the number of references (ie. the number of Texture that point to it) */ incrementReferences(): void; /** * Change the size of the texture (not the size of the content) * @param width defines the new width * @param height defines the new height * @param depth defines the new depth (1 by default) */ updateSize(width: int, height: int, depth?: int): void; /** @hidden */ _rebuild(): void; /** @hidden */ _swapAndDie(target: InternalTexture): void; /** * Dispose the current allocated resources */ dispose(): void; } } declare module BABYLON { /** * This represents the main contract an easing function should follow. * Easing functions are used throughout the animation system. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ export interface IEasingFunction { /** * Given an input gradient between 0 and 1, this returns the corrseponding value * of the easing function. * The link below provides some of the most common examples of easing functions. * @see https://easings.net/ * @param gradient Defines the value between 0 and 1 we want the easing value for * @returns the corresponding value on the curve defined by the easing function */ ease(gradient: number): number; } /** * Base class used for every default easing function. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ export class EasingFunction implements IEasingFunction { /** * Interpolation follows the mathematical formula associated with the easing function. */ static readonly EASINGMODE_EASEIN: number; /** * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function. */ static readonly EASINGMODE_EASEOUT: number; /** * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half. */ static readonly EASINGMODE_EASEINOUT: number; private _easingMode; /** * Sets the easing mode of the current function. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT) */ setEasingMode(easingMode: number): void; /** * Gets the current easing mode. * @returns the easing mode */ getEasingMode(): number; /** * @hidden */ easeInCore(gradient: number): number; /** * Given an input gradient between 0 and 1, this returns the corrseponding value * of the easing function. * @param gradient Defines the value between 0 and 1 we want the easing value for * @returns the corresponding value on the curve defined by the easing function */ ease(gradient: number): number; } /** * Easing function with a circle shape (see link below). * @see https://easings.net/#easeInCirc * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ export class CircleEase extends EasingFunction implements IEasingFunction { /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with a ease back shape (see link below). * @see https://easings.net/#easeInBack * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ export class BackEase extends EasingFunction implements IEasingFunction { /** Defines the amplitude of the function */ amplitude: number; /** * Instantiates a back ease easing * @see https://easings.net/#easeInBack * @param amplitude Defines the amplitude of the function */ constructor( /** Defines the amplitude of the function */ amplitude?: number); /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with a bouncing shape (see link below). * @see https://easings.net/#easeInBounce * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ export class BounceEase extends EasingFunction implements IEasingFunction { /** Defines the number of bounces */ bounces: number; /** Defines the amplitude of the bounce */ bounciness: number; /** * Instantiates a bounce easing * @see https://easings.net/#easeInBounce * @param bounces Defines the number of bounces * @param bounciness Defines the amplitude of the bounce */ constructor( /** Defines the number of bounces */ bounces?: number, /** Defines the amplitude of the bounce */ bounciness?: number); /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with a power of 3 shape (see link below). * @see https://easings.net/#easeInCubic * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ export class CubicEase extends EasingFunction implements IEasingFunction { /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with an elastic shape (see link below). * @see https://easings.net/#easeInElastic * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ export class ElasticEase extends EasingFunction implements IEasingFunction { /** Defines the number of oscillations*/ oscillations: number; /** Defines the amplitude of the oscillations*/ springiness: number; /** * Instantiates an elastic easing function * @see https://easings.net/#easeInElastic * @param oscillations Defines the number of oscillations * @param springiness Defines the amplitude of the oscillations */ constructor( /** Defines the number of oscillations*/ oscillations?: number, /** Defines the amplitude of the oscillations*/ springiness?: number); /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with an exponential shape (see link below). * @see https://easings.net/#easeInExpo * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ export class ExponentialEase extends EasingFunction implements IEasingFunction { /** Defines the exponent of the function */ exponent: number; /** * Instantiates an exponential easing function * @see https://easings.net/#easeInExpo * @param exponent Defines the exponent of the function */ constructor( /** Defines the exponent of the function */ exponent?: number); /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with a power shape (see link below). * @see https://easings.net/#easeInQuad * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ export class PowerEase extends EasingFunction implements IEasingFunction { /** Defines the power of the function */ power: number; /** * Instantiates an power base easing function * @see https://easings.net/#easeInQuad * @param power Defines the power of the function */ constructor( /** Defines the power of the function */ power?: number); /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with a power of 2 shape (see link below). * @see https://easings.net/#easeInQuad * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ export class QuadraticEase extends EasingFunction implements IEasingFunction { /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with a power of 4 shape (see link below). * @see https://easings.net/#easeInQuart * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ export class QuarticEase extends EasingFunction implements IEasingFunction { /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with a power of 5 shape (see link below). * @see https://easings.net/#easeInQuint * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ export class QuinticEase extends EasingFunction implements IEasingFunction { /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with a sin shape (see link below). * @see https://easings.net/#easeInSine * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ export class SineEase extends EasingFunction implements IEasingFunction { /** @hidden */ easeInCore(gradient: number): number; } /** * Easing function with a bezier shape (see link below). * @see http://cubic-bezier.com/#.17,.67,.83,.67 * @see http://doc.babylonjs.com/babylon101/animations#easing-functions */ export class BezierCurveEase extends EasingFunction implements IEasingFunction { /** Defines the x component of the start tangent in the bezier curve */ x1: number; /** Defines the y component of the start tangent in the bezier curve */ y1: number; /** Defines the x component of the end tangent in the bezier curve */ x2: number; /** Defines the y component of the end tangent in the bezier curve */ y2: number; /** * Instantiates a bezier function * @see http://cubic-bezier.com/#.17,.67,.83,.67 * @param x1 Defines the x component of the start tangent in the bezier curve * @param y1 Defines the y component of the start tangent in the bezier curve * @param x2 Defines the x component of the end tangent in the bezier curve * @param y2 Defines the y component of the end tangent in the bezier curve */ constructor( /** Defines the x component of the start tangent in the bezier curve */ x1?: number, /** Defines the y component of the start tangent in the bezier curve */ y1?: number, /** Defines the x component of the end tangent in the bezier curve */ x2?: number, /** Defines the y component of the end tangent in the bezier curve */ y2?: number); /** @hidden */ easeInCore(gradient: number): number; } } declare module BABYLON { /** * Defines an interface which represents an animation key frame */ export interface IAnimationKey { /** * Frame of the key frame */ frame: number; /** * Value at the specifies key frame */ value: any; /** * The input tangent for the cubic hermite spline */ inTangent?: any; /** * The output tangent for the cubic hermite spline */ outTangent?: any; /** * The animation interpolation type */ interpolation?: AnimationKeyInterpolation; } /** * Enum for the animation key frame interpolation type */ export enum AnimationKeyInterpolation { /** * Do not interpolate between keys and use the start key value only. Tangents are ignored */ STEP = 1 } } declare module BABYLON { /** * Represents the range of an animation */ export class AnimationRange { /**The name of the animation range**/ name: string; /**The starting frame of the animation */ from: number; /**The ending frame of the animation*/ to: number; /** * Initializes the range of an animation * @param name The name of the animation range * @param from The starting frame of the animation * @param to The ending frame of the animation */ constructor( /**The name of the animation range**/ name: string, /**The starting frame of the animation */ from: number, /**The ending frame of the animation*/ to: number); /** * Makes a copy of the animation range * @returns A copy of the animation range */ clone(): AnimationRange; } } declare module BABYLON { /** * Composed of a frame, and an action function */ export class AnimationEvent { /** The frame for which the event is triggered **/ frame: number; /** The event to perform when triggered **/ action: (currentFrame: number) => void; /** Specifies if the event should be triggered only once**/ onlyOnce?: boolean | undefined; /** * Specifies if the animation event is done */ isDone: boolean; /** * Initializes the animation event * @param frame The frame for which the event is triggered * @param action The event to perform when triggered * @param onlyOnce Specifies if the event should be triggered only once */ constructor( /** The frame for which the event is triggered **/ frame: number, /** The event to perform when triggered **/ action: (currentFrame: number) => void, /** Specifies if the event should be triggered only once**/ onlyOnce?: boolean | undefined); /** @hidden */ _clone(): AnimationEvent; } } declare module BABYLON { /** * Interface used to define a behavior */ export interface Behavior { /** gets or sets behavior's name */ name: string; /** * Function called when the behavior needs to be initialized (after attaching it to a target) */ init(): void; /** * Called when the behavior is attached to a target * @param target defines the target where the behavior is attached to */ attach(target: T): void; /** * Called when the behavior is detached from its target */ detach(): void; } /** * Interface implemented by classes supporting behaviors */ export interface IBehaviorAware { /** * Attach a behavior * @param behavior defines the behavior to attach * @returns the current host */ addBehavior(behavior: Behavior): T; /** * Remove a behavior from the current object * @param behavior defines the behavior to detach * @returns the current host */ removeBehavior(behavior: Behavior): T; /** * Gets a behavior using its name to search * @param name defines the name to search * @returns the behavior or null if not found */ getBehaviorByName(name: string): Nullable>; } } declare module BABYLON { /** * @hidden */ export class IntersectionInfo { bu: Nullable; bv: Nullable; distance: number; faceId: number; subMeshId: number; constructor(bu: Nullable, bv: Nullable, distance: number); } } declare module BABYLON { /** * Class used to store bounding sphere information */ export class BoundingSphere { /** * Gets the center of the bounding sphere in local space */ readonly center: Vector3; /** * Radius of the bounding sphere in local space */ radius: number; /** * Gets the center of the bounding sphere in world space */ readonly centerWorld: Vector3; /** * Radius of the bounding sphere in world space */ radiusWorld: number; /** * Gets the minimum vector in local space */ readonly minimum: Vector3; /** * Gets the maximum vector in local space */ readonly maximum: Vector3; private _worldMatrix; private static readonly TmpVector3; /** * Creates a new bounding sphere * @param min defines the minimum vector (in local space) * @param max defines the maximum vector (in local space) * @param worldMatrix defines the new world matrix */ constructor(min: DeepImmutable, max: DeepImmutable, worldMatrix?: DeepImmutable); /** * Recreates the entire bounding sphere from scratch as if we call the constructor in place * @param min defines the new minimum vector (in local space) * @param max defines the new maximum vector (in local space) * @param worldMatrix defines the new world matrix */ reConstruct(min: DeepImmutable, max: DeepImmutable, worldMatrix?: DeepImmutable): void; /** * Scale the current bounding sphere by applying a scale factor * @param factor defines the scale factor to apply * @returns the current bounding box */ scale(factor: number): BoundingSphere; /** * Gets the world matrix of the bounding box * @returns a matrix */ getWorldMatrix(): DeepImmutable; /** @hidden */ _update(worldMatrix: DeepImmutable): void; /** * Tests if the bounding sphere is intersecting the frustum planes * @param frustumPlanes defines the frustum planes to test * @returns true if there is an intersection */ isInFrustum(frustumPlanes: Array>): boolean; /** * Tests if the bounding sphere center is in between the frustum planes. * Used for optimistic fast inclusion. * @param frustumPlanes defines the frustum planes to test * @returns true if the sphere center is in between the frustum planes */ isCenterInFrustum(frustumPlanes: Array>): boolean; /** * Tests if a point is inside the bounding sphere * @param point defines the point to test * @returns true if the point is inside the bounding sphere */ intersectsPoint(point: DeepImmutable): boolean; /** * Checks if two sphere intersct * @param sphere0 sphere 0 * @param sphere1 sphere 1 * @returns true if the speres intersect */ static Intersects(sphere0: DeepImmutable, sphere1: DeepImmutable): boolean; } } declare module BABYLON { /** * Class used to store bounding box information */ export class BoundingBox implements ICullable { /** * Gets the 8 vectors representing the bounding box in local space */ readonly vectors: Vector3[]; /** * Gets the center of the bounding box in local space */ readonly center: Vector3; /** * Gets the center of the bounding box in world space */ readonly centerWorld: Vector3; /** * Gets the extend size in local space */ readonly extendSize: Vector3; /** * Gets the extend size in world space */ readonly extendSizeWorld: Vector3; /** * Gets the OBB (object bounding box) directions */ readonly directions: Vector3[]; /** * Gets the 8 vectors representing the bounding box in world space */ readonly vectorsWorld: Vector3[]; /** * Gets the minimum vector in world space */ readonly minimumWorld: Vector3; /** * Gets the maximum vector in world space */ readonly maximumWorld: Vector3; /** * Gets the minimum vector in local space */ readonly minimum: Vector3; /** * Gets the maximum vector in local space */ readonly maximum: Vector3; private _worldMatrix; private static readonly TmpVector3; /** * @hidden */ _tag: number; /** * Creates a new bounding box * @param min defines the minimum vector (in local space) * @param max defines the maximum vector (in local space) * @param worldMatrix defines the new world matrix */ constructor(min: DeepImmutable, max: DeepImmutable, worldMatrix?: DeepImmutable); /** * Recreates the entire bounding box from scratch as if we call the constructor in place * @param min defines the new minimum vector (in local space) * @param max defines the new maximum vector (in local space) * @param worldMatrix defines the new world matrix */ reConstruct(min: DeepImmutable, max: DeepImmutable, worldMatrix?: DeepImmutable): void; /** * Scale the current bounding box by applying a scale factor * @param factor defines the scale factor to apply * @returns the current bounding box */ scale(factor: number): BoundingBox; /** * Gets the world matrix of the bounding box * @returns a matrix */ getWorldMatrix(): DeepImmutable; /** @hidden */ _update(world: DeepImmutable): void; /** * Tests if the bounding box is intersecting the frustum planes * @param frustumPlanes defines the frustum planes to test * @returns true if there is an intersection */ isInFrustum(frustumPlanes: Array>): boolean; /** * Tests if the bounding box is entirely inside the frustum planes * @param frustumPlanes defines the frustum planes to test * @returns true if there is an inclusion */ isCompletelyInFrustum(frustumPlanes: Array>): boolean; /** * Tests if a point is inside the bounding box * @param point defines the point to test * @returns true if the point is inside the bounding box */ intersectsPoint(point: DeepImmutable): boolean; /** * Tests if the bounding box intersects with a bounding sphere * @param sphere defines the sphere to test * @returns true if there is an intersection */ intersectsSphere(sphere: DeepImmutable): boolean; /** * Tests if the bounding box intersects with a box defined by a min and max vectors * @param min defines the min vector to use * @param max defines the max vector to use * @returns true if there is an intersection */ intersectsMinMax(min: DeepImmutable, max: DeepImmutable): boolean; /** * Tests if two bounding boxes are intersections * @param box0 defines the first box to test * @param box1 defines the second box to test * @returns true if there is an intersection */ static Intersects(box0: DeepImmutable, box1: DeepImmutable): boolean; /** * Tests if a bounding box defines by a min/max vectors intersects a sphere * @param minPoint defines the minimum vector of the bounding box * @param maxPoint defines the maximum vector of the bounding box * @param sphereCenter defines the sphere center * @param sphereRadius defines the sphere radius * @returns true if there is an intersection */ static IntersectsSphere(minPoint: DeepImmutable, maxPoint: DeepImmutable, sphereCenter: DeepImmutable, sphereRadius: number): boolean; /** * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes * @param boundingVectors defines an array of 8 vectors representing a bounding box * @param frustumPlanes defines the frustum planes to test * @return true if there is an inclusion */ static IsCompletelyInFrustum(boundingVectors: Array>, frustumPlanes: Array>): boolean; /** * Tests if a bounding box defined with 8 vectors intersects frustum planes * @param boundingVectors defines an array of 8 vectors representing a bounding box * @param frustumPlanes defines the frustum planes to test * @return true if there is an intersection */ static IsInFrustum(boundingVectors: Array>, frustumPlanes: Array>): boolean; } } declare module BABYLON { /** @hidden */ export class Collider { /** Define if a collision was found */ collisionFound: boolean; /** * Define last intersection point in local space */ intersectionPoint: Vector3; /** * Define last collided mesh */ collidedMesh: Nullable; private _collisionPoint; private _planeIntersectionPoint; private _tempVector; private _tempVector2; private _tempVector3; private _tempVector4; private _edge; private _baseToVertex; private _destinationPoint; private _slidePlaneNormal; private _displacementVector; /** @hidden */ _radius: Vector3; /** @hidden */ _retry: number; private _velocity; private _basePoint; private _epsilon; /** @hidden */ _velocityWorldLength: number; /** @hidden */ _basePointWorld: Vector3; private _velocityWorld; private _normalizedVelocity; /** @hidden */ _initialVelocity: Vector3; /** @hidden */ _initialPosition: Vector3; private _nearestDistance; private _collisionMask; collisionMask: number; /** * Gets the plane normal used to compute the sliding response (in local space) */ readonly slidePlaneNormal: Vector3; /** @hidden */ _initialize(source: Vector3, dir: Vector3, e: number): void; /** @hidden */ _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean; /** @hidden */ _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean; /** @hidden */ _testTriangle(faceIndex: number, trianglePlaneArray: Array, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void; /** @hidden */ _collide(trianglePlaneArray: Array, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void; /** @hidden */ _getResponse(pos: Vector3, vel: Vector3): void; } } declare module BABYLON { /** * Interface for cullable objects * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling */ export interface ICullable { /** * Checks if the object or part of the object is in the frustum * @param frustumPlanes Camera near/planes * @returns true if the object is in frustum otherwise false */ isInFrustum(frustumPlanes: Plane[]): boolean; /** * Checks if a cullable object (mesh...) is in the camera frustum * Unlike isInFrustum this cheks the full bounding box * @param frustumPlanes Camera near/planes * @returns true if the object is in frustum otherwise false */ isCompletelyInFrustum(frustumPlanes: Plane[]): boolean; } /** * Info for a bounding data of a mesh */ export class BoundingInfo implements ICullable { /** * Bounding box for the mesh */ readonly boundingBox: BoundingBox; /** * Bounding sphere for the mesh */ readonly boundingSphere: BoundingSphere; private _isLocked; private static readonly TmpVector3; /** * Constructs bounding info * @param minimum min vector of the bounding box/sphere * @param maximum max vector of the bounding box/sphere * @param worldMatrix defines the new world matrix */ constructor(minimum: DeepImmutable, maximum: DeepImmutable, worldMatrix?: DeepImmutable); /** * Recreates the entire bounding info from scratch as if we call the constructor in place * @param min defines the new minimum vector (in local space) * @param max defines the new maximum vector (in local space) * @param worldMatrix defines the new world matrix */ reConstruct(min: DeepImmutable, max: DeepImmutable, worldMatrix?: DeepImmutable): void; /** * min vector of the bounding box/sphere */ readonly minimum: Vector3; /** * max vector of the bounding box/sphere */ readonly maximum: Vector3; /** * If the info is locked and won't be updated to avoid perf overhead */ isLocked: boolean; /** * Updates the bounding sphere and box * @param world world matrix to be used to update */ update(world: DeepImmutable): void; /** * Recreate the bounding info to be centered around a specific point given a specific extend. * @param center New center of the bounding info * @param extend New extend of the bounding info * @returns the current bounding info */ centerOn(center: DeepImmutable, extend: DeepImmutable): BoundingInfo; /** * Scale the current bounding info by applying a scale factor * @param factor defines the scale factor to apply * @returns the current bounding info */ scale(factor: number): BoundingInfo; /** * Returns `true` if the bounding info is within the frustum defined by the passed array of planes. * @param frustumPlanes defines the frustum to test * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD) * @returns true if the bounding info is in the frustum planes */ isInFrustum(frustumPlanes: Array>, strategy?: number): boolean; /** * Gets the world distance between the min and max points of the bounding box */ readonly diagonalLength: number; /** * Checks if a cullable object (mesh...) is in the camera frustum * Unlike isInFrustum this cheks the full bounding box * @param frustumPlanes Camera near/planes * @returns true if the object is in frustum otherwise false */ isCompletelyInFrustum(frustumPlanes: Array>): boolean; /** @hidden */ _checkCollision(collider: Collider): boolean; /** * Checks if a point is inside the bounding box and bounding sphere or the mesh * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh * @param point the point to check intersection with * @returns if the point intersects */ intersectsPoint(point: DeepImmutable): boolean; /** * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh * @param boundingInfo the bounding info to check intersection with * @param precise if the intersection should be done using OBB * @returns if the bounding info intersects */ intersects(boundingInfo: DeepImmutable, precise: boolean): boolean; } } declare module BABYLON { /** * Defines an array and its length. * It can be helpfull to group result from both Arrays and smart arrays in one structure. */ export interface ISmartArrayLike { /** * The data of the array. */ data: Array; /** * The active length of the array. */ length: number; } /** * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations. */ export class SmartArray implements ISmartArrayLike { /** * The full set of data from the array. */ data: Array; /** * The active length of the array. */ length: number; protected _id: number; /** * Instantiates a Smart Array. * @param capacity defines the default capacity of the array. */ constructor(capacity: number); /** * Pushes a value at the end of the active data. * @param value defines the object to push in the array. */ push(value: T): void; /** * Iterates over the active data and apply the lambda to them. * @param func defines the action to apply on each value. */ forEach(func: (content: T) => void): void; /** * Sorts the full sets of data. * @param compareFn defines the comparison function to apply. */ sort(compareFn: (a: T, b: T) => number): void; /** * Resets the active data to an empty array. */ reset(): void; /** * Releases all the data from the array as well as the array. */ dispose(): void; /** * Concats the active data with a given array. * @param array defines the data to concatenate with. */ concat(array: any): void; /** * Returns the position of a value in the active data. * @param value defines the value to find the index for * @returns the index if found in the active data otherwise -1 */ indexOf(value: T): number; /** * Returns whether an element is part of the active data. * @param value defines the value to look for * @returns true if found in the active data otherwise false */ contains(value: T): boolean; private static _GlobalId; } /** * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations. * The data in this array can only be present once */ export class SmartArrayNoDuplicate extends SmartArray { private _duplicateId; /** * Pushes a value at the end of the active data. * THIS DOES NOT PREVENT DUPPLICATE DATA * @param value defines the object to push in the array. */ push(value: T): void; /** * Pushes a value at the end of the active data. * If the data is already present, it won t be added again * @param value defines the object to push in the array. * @returns true if added false if it was already present */ pushNoDuplicate(value: T): boolean; /** * Resets the active data to an empty array. */ reset(): void; /** * Concats the active data with a given array. * This ensures no dupplicate will be present in the result. * @param array defines the data to concatenate with. */ concatWithNoDuplicate(array: any): void; } } declare module BABYLON { /** * A multi-material is used to apply different materials to different parts of the same object without the need of * separate meshes. This can be use to improve performances. * @see http://doc.babylonjs.com/how_to/multi_materials */ export class MultiMaterial extends Material { private _subMaterials; /** * Gets or Sets the list of Materials used within the multi material. * They need to be ordered according to the submeshes order in the associated mesh */ subMaterials: Nullable[]; /** * Function used to align with Node.getChildren() * @returns the list of Materials used within the multi material */ getChildren(): Nullable[]; /** * Instantiates a new Multi Material * A multi-material is used to apply different materials to different parts of the same object without the need of * separate meshes. This can be use to improve performances. * @see http://doc.babylonjs.com/how_to/multi_materials * @param name Define the name in the scene * @param scene Define the scene the material belongs to */ constructor(name: string, scene: Scene); private _hookArray; /** * Get one of the submaterial by its index in the submaterials array * @param index The index to look the sub material at * @returns The Material if the index has been defined */ getSubMaterial(index: number): Nullable; /** * Get the list of active textures for the whole sub materials list. * @returns All the textures that will be used during the rendering */ getActiveTextures(): BaseTexture[]; /** * Gets the current class name of the material e.g. "MultiMaterial" * Mainly use in serialization. * @returns the class name */ getClassName(): string; /** * Checks if the material is ready to render the requested sub mesh * @param mesh Define the mesh the submesh belongs to * @param subMesh Define the sub mesh to look readyness for * @param useInstances Define whether or not the material is used with instances * @returns true if ready, otherwise false */ isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean; /** * Clones the current material and its related sub materials * @param name Define the name of the newly cloned material * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance * @returns the cloned material */ clone(name: string, cloneChildren?: boolean): MultiMaterial; /** * Serializes the materials into a JSON representation. * @returns the JSON representation */ serialize(): any; /** * Dispose the material and release its associated resources * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on) * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app) * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app) */ dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void; /** * Creates a MultiMaterial from parsed MultiMaterial data. * @param parsedMultiMaterial defines parsed MultiMaterial data. * @param scene defines the hosting scene * @returns a new MultiMaterial */ static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial; } } declare module BABYLON { /** * Class used to represent data loading progression */ export class SceneLoaderFlags { private static _ForceFullSceneLoadingForIncremental; private static _ShowLoadingScreen; private static _CleanBoneMatrixWeights; private static _loggingLevel; /** * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data */ static ForceFullSceneLoadingForIncremental: boolean; /** * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene */ static ShowLoadingScreen: boolean; /** * Defines the current logging level (while loading the scene) * @ignorenaming */ static loggingLevel: number; /** * Gets or set a boolean indicating if matrix weights must be cleaned upon loading */ static CleanBoneMatrixWeights: boolean; } } declare module BABYLON { /** * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix. * @see https://doc.babylonjs.com/how_to/transformnode */ export class TransformNode extends Node { /** * Object will not rotate to face the camera */ static BILLBOARDMODE_NONE: number; /** * Object will rotate to face the camera but only on the x axis */ static BILLBOARDMODE_X: number; /** * Object will rotate to face the camera but only on the y axis */ static BILLBOARDMODE_Y: number; /** * Object will rotate to face the camera but only on the z axis */ static BILLBOARDMODE_Z: number; /** * Object will rotate to face the camera */ static BILLBOARDMODE_ALL: number; private _forward; private _forwardInverted; private _up; private _right; private _rightInverted; private _position; private _rotation; private _rotationQuaternion; protected _scaling: Vector3; protected _isDirty: boolean; private _transformToBoneReferal; private _billboardMode; /** * Gets or sets the billboard mode. Default is 0. * * | Value | Type | Description | * | --- | --- | --- | * | 0 | BILLBOARDMODE_NONE | | * | 1 | BILLBOARDMODE_X | | * | 2 | BILLBOARDMODE_Y | | * | 4 | BILLBOARDMODE_Z | | * | 7 | BILLBOARDMODE_ALL | | * */ billboardMode: number; private _preserveParentRotationForBillboard; /** * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed */ preserveParentRotationForBillboard: boolean; /** * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube */ scalingDeterminant: number; private _infiniteDistance; /** * Gets or sets the distance of the object to max, often used by skybox */ infiniteDistance: boolean; /** * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored. * By default the system will update normals to compensate */ ignoreNonUniformScaling: boolean; /** * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both */ reIntegrateRotationIntoRotationQuaternion: boolean; /** @hidden */ _poseMatrix: Nullable; /** @hidden */ _localMatrix: Matrix; private _usePivotMatrix; private _absolutePosition; private _pivotMatrix; private _pivotMatrixInverse; protected _postMultiplyPivotMatrix: boolean; protected _isWorldMatrixFrozen: boolean; /** @hidden */ _indexInSceneTransformNodesArray: number; /** * An event triggered after the world matrix is updated */ onAfterWorldMatrixUpdateObservable: Observable; constructor(name: string, scene?: Nullable, isPure?: boolean); /** * Gets a string identifying the name of the class * @returns "TransformNode" string */ getClassName(): string; /** * Gets or set the node position (default is (0.0, 0.0, 0.0)) */ position: Vector3; /** * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)). * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion */ rotation: Vector3; /** * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)). */ scaling: Vector3; /** * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null). * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored) */ rotationQuaternion: Nullable; /** * The forward direction of that transform in world space. */ readonly forward: Vector3; /** * The up direction of that transform in world space. */ readonly up: Vector3; /** * The right direction of that transform in world space. */ readonly right: Vector3; /** * Copies the parameter passed Matrix into the mesh Pose matrix. * @param matrix the matrix to copy the pose from * @returns this TransformNode. */ updatePoseMatrix(matrix: Matrix): TransformNode; /** * Returns the mesh Pose matrix. * @returns the pose matrix */ getPoseMatrix(): Matrix; /** @hidden */ _isSynchronized(): boolean; /** @hidden */ _initCache(): void; /** * Flag the transform node as dirty (Forcing it to update everything) * @param property if set to "rotation" the objects rotationQuaternion will be set to null * @returns this transform node */ markAsDirty(property: string): TransformNode; /** * Returns the current mesh absolute position. * Returns a Vector3. */ readonly absolutePosition: Vector3; /** * Sets a new matrix to apply before all other transformation * @param matrix defines the transform matrix * @returns the current TransformNode */ setPreTransformMatrix(matrix: Matrix): TransformNode; /** * Sets a new pivot matrix to the current node * @param matrix defines the new pivot matrix to use * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect * @returns the current TransformNode */ setPivotMatrix(matrix: DeepImmutable, postMultiplyPivotMatrix?: boolean): TransformNode; /** * Returns the mesh pivot matrix. * Default : Identity. * @returns the matrix */ getPivotMatrix(): Matrix; /** * Prevents the World matrix to be computed any longer. * @returns the TransformNode. */ freezeWorldMatrix(): TransformNode; /** * Allows back the World matrix computation. * @returns the TransformNode. */ unfreezeWorldMatrix(): this; /** * True if the World matrix has been frozen. */ readonly isWorldMatrixFrozen: boolean; /** * Retuns the mesh absolute position in the World. * @returns a Vector3. */ getAbsolutePosition(): Vector3; /** * Sets the mesh absolute position in the World from a Vector3 or an Array(3). * @param absolutePosition the absolute position to set * @returns the TransformNode. */ setAbsolutePosition(absolutePosition: Vector3): TransformNode; /** * Sets the mesh position in its local space. * @param vector3 the position to set in localspace * @returns the TransformNode. */ setPositionWithLocalVector(vector3: Vector3): TransformNode; /** * Returns the mesh position in the local space from the current World matrix values. * @returns a new Vector3. */ getPositionExpressedInLocalSpace(): Vector3; /** * Translates the mesh along the passed Vector3 in its local space. * @param vector3 the distance to translate in localspace * @returns the TransformNode. */ locallyTranslate(vector3: Vector3): TransformNode; private static _lookAtVectorCache; /** * Orients a mesh towards a target point. Mesh must be drawn facing user. * @param targetPoint the position (must be in same space as current mesh) to look at * @param yawCor optional yaw (y-axis) correction in radians * @param pitchCor optional pitch (x-axis) correction in radians * @param rollCor optional roll (z-axis) correction in radians * @param space the choosen space of the target * @returns the TransformNode. */ lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode; /** * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh. * This Vector3 is expressed in the World space. * @param localAxis axis to rotate * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh. */ getDirection(localAxis: Vector3): Vector3; /** * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh. * localAxis is expressed in the mesh local space. * result is computed in the Wordl space from the mesh World matrix. * @param localAxis axis to rotate * @param result the resulting transformnode * @returns this TransformNode. */ getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode; /** * Sets this transform node rotation to the given local axis. * @param localAxis the axis in local space * @param yawCor optional yaw (y-axis) correction in radians * @param pitchCor optional pitch (x-axis) correction in radians * @param rollCor optional roll (z-axis) correction in radians * @returns this TransformNode */ setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode; /** * Sets a new pivot point to the current node * @param point defines the new pivot point to use * @param space defines if the point is in world or local space (local by default) * @returns the current TransformNode */ setPivotPoint(point: Vector3, space?: Space): TransformNode; /** * Returns a new Vector3 set with the mesh pivot point coordinates in the local space. * @returns the pivot point */ getPivotPoint(): Vector3; /** * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space. * @param result the vector3 to store the result * @returns this TransformNode. */ getPivotPointToRef(result: Vector3): TransformNode; /** * Returns a new Vector3 set with the mesh pivot point World coordinates. * @returns a new Vector3 set with the mesh pivot point World coordinates. */ getAbsolutePivotPoint(): Vector3; /** * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates. * @param result vector3 to store the result * @returns this TransformNode. */ getAbsolutePivotPointToRef(result: Vector3): TransformNode; /** * Defines the passed node as the parent of the current node. * The node will remain exactly where it is and its position / rotation will be updated accordingly * @see https://doc.babylonjs.com/how_to/parenting * @param node the node ot set as the parent * @returns this TransformNode. */ setParent(node: Nullable): TransformNode; private _nonUniformScaling; /** * True if the scaling property of this object is non uniform eg. (1,2,1) */ readonly nonUniformScaling: boolean; /** @hidden */ _updateNonUniformScalingState(value: boolean): boolean; /** * Attach the current TransformNode to another TransformNode associated with a bone * @param bone Bone affecting the TransformNode * @param affectedTransformNode TransformNode associated with the bone * @returns this object */ attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode; /** * Detach the transform node if its associated with a bone * @returns this object */ detachFromBone(): TransformNode; private static _rotationAxisCache; /** * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used. * The passed axis is also normalized. * @param axis the axis to rotate around * @param amount the amount to rotate in radians * @param space Space to rotate in (Default: local) * @returns the TransformNode. */ rotate(axis: Vector3, amount: number, space?: Space): TransformNode; /** * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used. * The passed axis is also normalized. . * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm * @param point the point to rotate around * @param axis the axis to rotate around * @param amount the amount to rotate in radians * @returns the TransformNode */ rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode; /** * Translates the mesh along the axis vector for the passed distance in the given space. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD. * @param axis the axis to translate in * @param distance the distance to translate * @param space Space to rotate in (Default: local) * @returns the TransformNode. */ translate(axis: Vector3, distance: number, space?: Space): TransformNode; /** * Adds a rotation step to the mesh current rotation. * x, y, z are Euler angles expressed in radians. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set. * This means this rotation is made in the mesh local space only. * It's useful to set a custom rotation order different from the BJS standard one YXZ. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis. * ```javascript * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3); * ``` * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles. * @param x Rotation to add * @param y Rotation to add * @param z Rotation to add * @returns the TransformNode. */ addRotation(x: number, y: number, z: number): TransformNode; /** * @hidden */ protected _getEffectiveParent(): Nullable; /** * Computes the world matrix of the node * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch * @returns the world matrix */ computeWorldMatrix(force?: boolean): Matrix; protected _afterComputeWorldMatrix(): void; /** * If you'd like to be called back after the mesh position, rotation or scaling has been updated. * @param func callback function to add * * @returns the TransformNode. */ registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode; /** * Removes a registered callback function. * @param func callback function to remove * @returns the TransformNode. */ unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode; /** * Gets the position of the current mesh in camera space * @param camera defines the camera to use * @returns a position */ getPositionInCameraSpace(camera?: Nullable): Vector3; /** * Returns the distance from the mesh to the active camera * @param camera defines the camera to use * @returns the distance */ getDistanceToCamera(camera?: Nullable): number; /** * Clone the current transform node * @param name Name of the new clone * @param newParent New parent for the clone * @param doNotCloneChildren Do not clone children hierarchy * @returns the new transform node */ clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable; /** * Serializes the objects information. * @param currentSerializationObject defines the object to serialize in * @returns the serialized object */ serialize(currentSerializationObject?: any): any; /** * Returns a new TransformNode object parsed from the source provided. * @param parsedTransformNode is the source. * @param scene the scne the object belongs to * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with * @returns a new TransformNode object parsed from the source provided. */ static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode; /** * Get all child-transformNodes of this node * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored * @returns an array of TransformNode */ getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[]; /** * Releases resources associated with this transform node. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default) * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default) */ dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void; } } declare module BABYLON { /** * Class used to override all child animations of a given target */ export class AnimationPropertiesOverride { /** * Gets or sets a value indicating if animation blending must be used */ enableBlending: boolean; /** * Gets or sets the blending speed to use when enableBlending is true */ blendingSpeed: number; /** * Gets or sets the default loop mode to use */ loopMode: number; } } declare module BABYLON { /** * Class used to store bone information * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons */ export class Bone extends Node { /** * defines the bone name */ name: string; private static _tmpVecs; private static _tmpQuat; private static _tmpMats; /** * Gets the list of child bones */ children: Bone[]; /** Gets the animations associated with this bone */ animations: Animation[]; /** * Gets or sets bone length */ length: number; /** * @hidden Internal only * Set this value to map this bone to a different index in the transform matrices * Set this value to -1 to exclude the bone from the transform matrices */ _index: Nullable; private _skeleton; private _localMatrix; private _restPose; private _baseMatrix; private _absoluteTransform; private _invertedAbsoluteTransform; private _parent; private _scalingDeterminant; private _worldTransform; private _localScaling; private _localRotation; private _localPosition; private _needToDecompose; private _needToCompose; /** @hidden */ _linkedTransformNode: Nullable; /** @hidden */ _waitingTransformNodeId: Nullable; /** @hidden */ /** @hidden */ _matrix: Matrix; /** * Create a new bone * @param name defines the bone name * @param skeleton defines the parent skeleton * @param parentBone defines the parent (can be null if the bone is the root) * @param localMatrix defines the local matrix * @param restPose defines the rest pose matrix * @param baseMatrix defines the base matrix * @param index defines index of the bone in the hiearchy */ constructor( /** * defines the bone name */ name: string, skeleton: Skeleton, parentBone?: Nullable, localMatrix?: Nullable, restPose?: Nullable, baseMatrix?: Nullable, index?: Nullable); /** * Gets the current object class name. * @return the class name */ getClassName(): string; /** * Gets the parent skeleton * @returns a skeleton */ getSkeleton(): Skeleton; /** * Gets parent bone * @returns a bone or null if the bone is the root of the bone hierarchy */ getParent(): Nullable; /** * Returns an array containing the root bones * @returns an array containing the root bones */ getChildren(): Array; /** * Sets the parent bone * @param parent defines the parent (can be null if the bone is the root) * @param updateDifferenceMatrix defines if the difference matrix must be updated */ setParent(parent: Nullable, updateDifferenceMatrix?: boolean): void; /** * Gets the local matrix * @returns a matrix */ getLocalMatrix(): Matrix; /** * Gets the base matrix (initial matrix which remains unchanged) * @returns a matrix */ getBaseMatrix(): Matrix; /** * Gets the rest pose matrix * @returns a matrix */ getRestPose(): Matrix; /** * Gets a matrix used to store world matrix (ie. the matrix sent to shaders) */ getWorldMatrix(): Matrix; /** * Sets the local matrix to rest pose matrix */ returnToRest(): void; /** * Gets the inverse of the absolute transform matrix. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state) * @returns a matrix */ getInvertedAbsoluteTransform(): Matrix; /** * Gets the absolute transform matrix (ie base matrix * parent world matrix) * @returns a matrix */ getAbsoluteTransform(): Matrix; /** * Links with the given transform node. * The local matrix of this bone is copied from the transform node every frame. * @param transformNode defines the transform node to link to */ linkTransformNode(transformNode: Nullable): void; /** Gets or sets current position (in local space) */ position: Vector3; /** Gets or sets current rotation (in local space) */ rotation: Vector3; /** Gets or sets current rotation quaternion (in local space) */ rotationQuaternion: Quaternion; /** Gets or sets current scaling (in local space) */ scaling: Vector3; /** * Gets the animation properties override */ readonly animationPropertiesOverride: Nullable; private _decompose; private _compose; /** * Update the base and local matrices * @param matrix defines the new base or local matrix * @param updateDifferenceMatrix defines if the difference matrix must be updated * @param updateLocalMatrix defines if the local matrix should be updated */ updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void; /** @hidden */ _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void; /** * Flag the bone as dirty (Forcing it to update everything) */ markAsDirty(): void; /** @hidden */ _markAsDirtyAndCompose(): void; private _markAsDirtyAndDecompose; /** * Translate the bone in local or world space * @param vec The amount to translate the bone * @param space The space that the translation is in * @param mesh The mesh that this bone is attached to. This is only used in world space */ translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void; /** * Set the postion of the bone in local or world space * @param position The position to set the bone * @param space The space that the position is in * @param mesh The mesh that this bone is attached to. This is only used in world space */ setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void; /** * Set the absolute position of the bone (world space) * @param position The position to set the bone * @param mesh The mesh that this bone is attached to */ setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void; /** * Scale the bone on the x, y and z axes (in local space) * @param x The amount to scale the bone on the x axis * @param y The amount to scale the bone on the y axis * @param z The amount to scale the bone on the z axis * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default) */ scale(x: number, y: number, z: number, scaleChildren?: boolean): void; /** * Set the bone scaling in local space * @param scale defines the scaling vector */ setScale(scale: Vector3): void; /** * Gets the current scaling in local space * @returns the current scaling vector */ getScale(): Vector3; /** * Gets the current scaling in local space and stores it in a target vector * @param result defines the target vector */ getScaleToRef(result: Vector3): void; /** * Set the yaw, pitch, and roll of the bone in local or world space * @param yaw The rotation of the bone on the y axis * @param pitch The rotation of the bone on the x axis * @param roll The rotation of the bone on the z axis * @param space The space that the axes of rotation are in * @param mesh The mesh that this bone is attached to. This is only used in world space */ setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void; /** * Add a rotation to the bone on an axis in local or world space * @param axis The axis to rotate the bone on * @param amount The amount to rotate the bone * @param space The space that the axis is in * @param mesh The mesh that this bone is attached to. This is only used in world space */ rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void; /** * Set the rotation of the bone to a particular axis angle in local or world space * @param axis The axis to rotate the bone on * @param angle The angle that the bone should be rotated to * @param space The space that the axis is in * @param mesh The mesh that this bone is attached to. This is only used in world space */ setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void; /** * Set the euler rotation of the bone in local of world space * @param rotation The euler rotation that the bone should be set to * @param space The space that the rotation is in * @param mesh The mesh that this bone is attached to. This is only used in world space */ setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void; /** * Set the quaternion rotation of the bone in local of world space * @param quat The quaternion rotation that the bone should be set to * @param space The space that the rotation is in * @param mesh The mesh that this bone is attached to. This is only used in world space */ setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void; /** * Set the rotation matrix of the bone in local of world space * @param rotMat The rotation matrix that the bone should be set to * @param space The space that the rotation is in * @param mesh The mesh that this bone is attached to. This is only used in world space */ setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void; private _rotateWithMatrix; private _getNegativeRotationToRef; /** * Get the position of the bone in local or world space * @param space The space that the returned position is in * @param mesh The mesh that this bone is attached to. This is only used in world space * @returns The position of the bone */ getPosition(space?: Space, mesh?: Nullable): Vector3; /** * Copy the position of the bone to a vector3 in local or world space * @param space The space that the returned position is in * @param mesh The mesh that this bone is attached to. This is only used in world space * @param result The vector3 to copy the position to */ getPositionToRef(space: Space | undefined, mesh: Nullable, result: Vector3): void; /** * Get the absolute position of the bone (world space) * @param mesh The mesh that this bone is attached to * @returns The absolute position of the bone */ getAbsolutePosition(mesh?: Nullable): Vector3; /** * Copy the absolute position of the bone (world space) to the result param * @param mesh The mesh that this bone is attached to * @param result The vector3 to copy the absolute position to */ getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void; /** * Compute the absolute transforms of this bone and its children */ computeAbsoluteTransforms(): void; /** * Get the world direction from an axis that is in the local space of the bone * @param localAxis The local direction that is used to compute the world direction * @param mesh The mesh that this bone is attached to * @returns The world direction */ getDirection(localAxis: Vector3, mesh?: Nullable): Vector3; /** * Copy the world direction to a vector3 from an axis that is in the local space of the bone * @param localAxis The local direction that is used to compute the world direction * @param mesh The mesh that this bone is attached to * @param result The vector3 that the world direction will be copied to */ getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void; /** * Get the euler rotation of the bone in local or world space * @param space The space that the rotation should be in * @param mesh The mesh that this bone is attached to. This is only used in world space * @returns The euler rotation */ getRotation(space?: Space, mesh?: Nullable): Vector3; /** * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space * @param space The space that the rotation should be in * @param mesh The mesh that this bone is attached to. This is only used in world space * @param result The vector3 that the rotation should be copied to */ getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void; /** * Get the quaternion rotation of the bone in either local or world space * @param space The space that the rotation should be in * @param mesh The mesh that this bone is attached to. This is only used in world space * @returns The quaternion rotation */ getRotationQuaternion(space?: Space, mesh?: Nullable): Quaternion; /** * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space * @param space The space that the rotation should be in * @param mesh The mesh that this bone is attached to. This is only used in world space * @param result The quaternion that the rotation should be copied to */ getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void; /** * Get the rotation matrix of the bone in local or world space * @param space The space that the rotation should be in * @param mesh The mesh that this bone is attached to. This is only used in world space * @returns The rotation matrix */ getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix; /** * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space * @param space The space that the rotation should be in * @param mesh The mesh that this bone is attached to. This is only used in world space * @param result The quaternion that the rotation should be copied to */ getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void; /** * Get the world position of a point that is in the local space of the bone * @param position The local position * @param mesh The mesh that this bone is attached to * @returns The world position */ getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable): Vector3; /** * Get the world position of a point that is in the local space of the bone and copy it to the result param * @param position The local position * @param mesh The mesh that this bone is attached to * @param result The vector3 that the world position should be copied to */ getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void; /** * Get the local position of a point that is in world space * @param position The world position * @param mesh The mesh that this bone is attached to * @returns The local position */ getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable): Vector3; /** * Get the local position of a point that is in world space and copy it to the result param * @param position The world position * @param mesh The mesh that this bone is attached to * @param result The vector3 that the local position should be copied to */ getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void; } } declare module BABYLON { /** * Enum that determines the text-wrapping mode to use. */ export enum InspectableType { /** * Checkbox for booleans */ Checkbox = 0, /** * Sliders for numbers */ Slider = 1, /** * Vector3 */ Vector3 = 2, /** * Quaternions */ Quaternion = 3, /** * Color3 */ Color3 = 4 } /** * Interface used to define custom inspectable properties. * This interface is used by the inspector to display custom property grids * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility */ export interface IInspectable { /** * Gets the label to display */ label: string; /** * Gets the name of the property to edit */ propertyName: string; /** * Gets the type of the editor to use */ type: InspectableType; /** * Gets the minimum value of the property when using in "slider" mode */ min?: number; /** * Gets the maximum value of the property when using in "slider" mode */ max?: number; /** * Gets the setp to use when using in "slider" mode */ step?: number; } } declare module BABYLON { /** * This represents the required contract to create a new type of texture loader. */ export interface IInternalTextureLoader { /** * Defines wether the loader supports cascade loading the different faces. */ supportCascades: boolean; /** * This returns if the loader support the current file information. * @param extension defines the file extension of the file being loaded * @param textureFormatInUse defines the current compressed format in use iun the engine * @param fallback defines the fallback internal texture if any * @param isBase64 defines whether the texture is encoded as a base64 * @param isBuffer defines whether the texture data are stored as a buffer * @returns true if the loader can load the specified file */ canLoad(extension: string, textureFormatInUse: Nullable, fallback: Nullable, isBase64: boolean, isBuffer: boolean): boolean; /** * Transform the url before loading if required. * @param rootUrl the url of the texture * @param textureFormatInUse defines the current compressed format in use iun the engine * @returns the transformed texture */ transformUrl(rootUrl: string, textureFormatInUse: Nullable): string; /** * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work * @param rootUrl the url of the texture * @param textureFormatInUse defines the current compressed format in use iun the engine * @returns the fallback texture */ getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable): Nullable; /** * Uploads the cube texture data to the WebGl Texture. It has alreday been bound. * @param data contains the texture data * @param texture defines the BabylonJS internal texture * @param createPolynomials will be true if polynomials have been requested * @param onLoad defines the callback to trigger once the texture is ready * @param onError defines the callback to trigger in case of error */ loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void; /** * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback. * @param data contains the texture data * @param texture defines the BabylonJS internal texture * @param callback defines the method to call once ready to upload */ loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void; } } declare module BABYLON { interface Engine { /** * Creates a depth stencil cube texture. * This is only available in WebGL 2. * @param size The size of face edge in the cube texture. * @param options The options defining the cube texture. * @returns The cube texture */ _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture; /** * Creates a cube texture * @param rootUrl defines the url where the files to load is located * @param scene defines the current scene * @param files defines the list of files to load (1 per face) * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default) * @param onLoad defines an optional callback raised when the texture is loaded * @param onError defines an optional callback raised if there is an issue to load the texture * @param format defines the format of the data * @param forcedExtension defines the extension to use to pick the right loader * @param createPolynomials if a polynomial sphere should be created for the cube texture * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness * @param fallback defines texture to use while falling back when (compressed) texture file not found. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array) * @returns the cube texture as an InternalTexture */ createCubeTexture(rootUrl: string, scene: Nullable, files: Nullable, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable, excludeLoaders: Array): InternalTexture; /** * Creates a cube texture * @param rootUrl defines the url where the files to load is located * @param scene defines the current scene * @param files defines the list of files to load (1 per face) * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default) * @param onLoad defines an optional callback raised when the texture is loaded * @param onError defines an optional callback raised if there is an issue to load the texture * @param format defines the format of the data * @param forcedExtension defines the extension to use to pick the right loader * @returns the cube texture as an InternalTexture */ createCubeTexture(rootUrl: string, scene: Nullable, files: Nullable, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture; /** * Creates a cube texture * @param rootUrl defines the url where the files to load is located * @param scene defines the current scene * @param files defines the list of files to load (1 per face) * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default) * @param onLoad defines an optional callback raised when the texture is loaded * @param onError defines an optional callback raised if there is an issue to load the texture * @param format defines the format of the data * @param forcedExtension defines the extension to use to pick the right loader * @param createPolynomials if a polynomial sphere should be created for the cube texture * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness * @returns the cube texture as an InternalTexture */ createCubeTexture(rootUrl: string, scene: Nullable, files: Nullable, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture; /** @hidden */ _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void; /** @hidden */ _cascadeLoadFiles(scene: Nullable, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void; /** @hidden */ _cascadeLoadImgs(scene: Nullable, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void; /** @hidden */ _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void; } } declare module BABYLON { /** * Class for creating a cube texture */ export class CubeTexture extends BaseTexture { private _delayedOnLoad; /** * The url of the texture */ url: string; /** * Gets or sets the center of the bounding box associated with the cube texture. * It must define where the camera used to render the texture was set * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode */ boundingBoxPosition: Vector3; private _boundingBoxSize; /** * Gets or sets the size of the bounding box associated with the cube texture * When defined, the cubemap will switch to local mode * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity * @example https://www.babylonjs-playground.com/#RNASML */ /** * Returns the bounding box size * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode */ boundingBoxSize: Vector3; protected _rotationY: number; /** * Sets texture matrix rotation angle around Y axis in radians. */ /** * Gets texture matrix rotation angle around Y axis radians. */ rotationY: number; /** * Are mip maps generated for this texture or not. */ readonly noMipmap: boolean; private _noMipmap; private _files; private _extensions; private _textureMatrix; private _format; private _createPolynomials; /** @hidden */ _prefiltered: boolean; /** * Creates a cube texture from an array of image urls * @param files defines an array of image urls * @param scene defines the hosting scene * @param noMipmap specifies if mip maps are not used * @returns a cube texture */ static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture; /** * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys. * @param url defines the url of the prefiltered texture * @param scene defines the scene the texture is attached to * @param forcedExtension defines the extension of the file if different from the url * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary * @return the prefiltered texture */ static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture; /** * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well * as prefiltered data. * @param rootUrl defines the url of the texture or the root name of the six images * @param scene defines the scene the texture is attached to * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg... * @param noMipmap defines if mipmaps should be created or not * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz * @param onLoad defines a callback triggered at the end of the file load if no errors occured * @param onError defines a callback triggered in case of error during load * @param format defines the internal format to use for the texture once loaded * @param prefiltered defines whether or not the texture is created from prefiltered data * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness * @return the cube texture */ constructor(rootUrl: string, scene: Scene, extensions?: Nullable, noMipmap?: boolean, files?: Nullable, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number); /** * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR) */ readonly isPrefiltered: boolean; /** * Get the current class name of the texture useful for serialization or dynamic coding. * @returns "CubeTexture" */ getClassName(): string; /** * Update the url (and optional buffer) of this texture if url was null during construction. * @param url the url of the texture * @param forcedExtension defines the extension to use * @param onLoad callback called when the texture is loaded (defaults to null) */ updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void; /** * Delays loading of the cube texture * @param forcedExtension defines the extension to use */ delayLoad(forcedExtension?: string): void; /** * Returns the reflection texture matrix * @returns the reflection texture matrix */ getReflectionTextureMatrix(): Matrix; /** * Sets the reflection texture matrix * @param value Reflection texture matrix */ setReflectionTextureMatrix(value: Matrix): void; /** * Parses text to create a cube texture * @param parsedTexture define the serialized text to read from * @param scene defines the hosting scene * @param rootUrl defines the root url of the cube texture * @returns a cube texture */ static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture; /** * Makes a clone, or deep copy, of the cube texture * @returns a new cube texture */ clone(): CubeTexture; } } declare module BABYLON { /** @hidden */ export var postprocessVertexShader: { name: string; shader: string; }; } declare module BABYLON { /** * A target camera takes a mesh or position as a target and continues to look at it while it moves. * This is the base of the follow, arc rotate cameras and Free camera * @see http://doc.babylonjs.com/features/cameras */ export class TargetCamera extends Camera { private static _RigCamTransformMatrix; private static _TargetTransformMatrix; private static _TargetFocalPoint; /** * Define the current direction the camera is moving to */ cameraDirection: Vector3; /** * Define the current rotation the camera is rotating to */ cameraRotation: Vector2; /** * When set, the up vector of the camera will be updated by the rotation of the camera */ updateUpVectorFromRotation: boolean; private _tmpQuaternion; /** * Define the current rotation of the camera */ rotation: Vector3; /** * Define the current rotation of the camera as a quaternion to prevent Gimbal lock */ rotationQuaternion: Quaternion; /** * Define the current speed of the camera */ speed: number; /** * Add cconstraint to the camera to prevent it to move freely in all directions and * around all axis. */ noRotationConstraint: boolean; /** * Define the current target of the camera as an object or a position. */ lockedTarget: any; /** @hidden */ _currentTarget: Vector3; /** @hidden */ _initialFocalDistance: number; /** @hidden */ _viewMatrix: Matrix; /** @hidden */ _camMatrix: Matrix; /** @hidden */ _cameraTransformMatrix: Matrix; /** @hidden */ _cameraRotationMatrix: Matrix; /** @hidden */ _referencePoint: Vector3; /** @hidden */ _transformedReferencePoint: Vector3; protected _globalCurrentTarget: Vector3; protected _globalCurrentUpVector: Vector3; /** @hidden */ _reset: () => void; private _defaultUp; /** * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves. * This is the base of the follow, arc rotate cameras and Free camera * @see http://doc.babylonjs.com/features/cameras * @param name Defines the name of the camera in the scene * @param position Defines the start position of the camera in the scene * @param scene Defines the scene the camera belongs to * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined */ constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean); /** * Gets the position in front of the camera at a given distance. * @param distance The distance from the camera we want the position to be * @returns the position */ getFrontPosition(distance: number): Vector3; /** @hidden */ _getLockedTargetPosition(): Nullable; private _storedPosition; private _storedRotation; private _storedRotationQuaternion; /** * Store current camera state of the camera (fov, position, rotation, etc..) * @returns the camera */ storeState(): Camera; /** * Restored camera state. You must call storeState() first * @returns whether it was successful or not * @hidden */ _restoreStateValues(): boolean; /** @hidden */ _initCache(): void; /** @hidden */ _updateCache(ignoreParentClass?: boolean): void; /** @hidden */ _isSynchronizedViewMatrix(): boolean; /** @hidden */ _computeLocalCameraSpeed(): number; /** * Defines the target the camera should look at. * This will automatically adapt alpha beta and radius to fit within the new target. * @param target Defines the new target as a Vector or a mesh */ setTarget(target: Vector3): void; /** * Return the current target position of the camera. This value is expressed in local space. * @returns the target position */ getTarget(): Vector3; /** @hidden */ _decideIfNeedsToMove(): boolean; /** @hidden */ _updatePosition(): void; /** @hidden */ _checkInputs(): void; protected _updateCameraRotationMatrix(): void; /** * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well) * @returns the current camera */ private _rotateUpVectorWithCameraRotationMatrix; private _cachedRotationZ; private _cachedQuaternionRotationZ; /** @hidden */ _getViewMatrix(): Matrix; protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void; /** * @hidden */ createRigCamera(name: string, cameraIndex: number): Nullable; /** * @hidden */ _updateRigCameras(): void; private _getRigCamPositionAndTarget; /** * Gets the current object class name. * @return the class name */ getClassName(): string; } } declare module BABYLON { /** * @ignore * This is a list of all the different input types that are available in the application. * Fo instance: ArcRotateCameraGamepadInput... */ export var CameraInputTypes: {}; /** * This is the contract to implement in order to create a new input class. * Inputs are dealing with listening to user actions and moving the camera accordingly. */ export interface ICameraInput { /** * Defines the camera the input is attached to. */ camera: Nullable; /** * Gets the class name of the current intput. * @returns the class name */ getClassName(): string; /** * Get the friendly name associated with the input class. * @returns the input friendly name */ getSimpleName(): string; /** * Attach the input controls to a specific dom element to get the input from. * @param element Defines the element the controls should be listened from * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault) */ attachControl(element: HTMLElement, noPreventDefault?: boolean): void; /** * Detach the current controls from the specified dom element. * @param element Defines the element to stop listening the inputs from */ detachControl(element: Nullable): void; /** * Update the current camera state depending on the inputs that have been used this frame. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop. */ checkInputs?: () => void; } /** * Represents a map of input types to input instance or input index to input instance. */ export interface CameraInputsMap { /** * Accessor to the input by input type. */ [name: string]: ICameraInput; /** * Accessor to the input by input index. */ [idx: number]: ICameraInput; } /** * This represents the input manager used within a camera. * It helps dealing with all the different kind of input attached to a camera. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs */ export class CameraInputsManager { /** * Defines the list of inputs attahed to the camera. */ attached: CameraInputsMap; /** * Defines the dom element the camera is collecting inputs from. * This is null if the controls have not been attached. */ attachedElement: Nullable; /** * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault) */ noPreventDefault: boolean; /** * Defined the camera the input manager belongs to. */ camera: TCamera; /** * Update the current camera state depending on the inputs that have been used this frame. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop. */ checkInputs: () => void; /** * Instantiate a new Camera Input Manager. * @param camera Defines the camera the input manager blongs to */ constructor(camera: TCamera); /** * Add an input method to a camera * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs * @param input camera input method */ add(input: ICameraInput): void; /** * Remove a specific input method from a camera * example: camera.inputs.remove(camera.inputs.attached.mouse); * @param inputToRemove camera input method */ remove(inputToRemove: ICameraInput): void; /** * Remove a specific input type from a camera * example: camera.inputs.remove("ArcRotateCameraGamepadInput"); * @param inputType the type of the input to remove */ removeByType(inputType: string): void; private _addCheckInputs; /** * Attach the input controls to the currently attached dom element to listen the events from. * @param input Defines the input to attach */ attachInput(input: ICameraInput): void; /** * Attach the current manager inputs controls to a specific dom element to listen the events from. * @param element Defines the dom element to collect the events from * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault) */ attachElement(element: HTMLElement, noPreventDefault?: boolean): void; /** * Detach the current manager inputs controls from a specific dom element. * @param element Defines the dom element to collect the events from * @param disconnect Defines whether the input should be removed from the current list of attached inputs */ detachElement(element: HTMLElement, disconnect?: boolean): void; /** * Rebuild the dynamic inputCheck function from the current list of * defined inputs in the manager. */ rebuildInputCheck(): void; /** * Remove all attached input methods from a camera */ clear(): void; /** * Serialize the current input manager attached to a camera. * This ensures than once parsed, * the input associated to the camera will be identical to the current ones * @param serializedCamera Defines the camera serialization JSON the input serialization should write to */ serialize(serializedCamera: any): void; /** * Parses an input manager serialized JSON to restore the previous list of inputs * and states associated to a camera. * @param parsedCamera Defines the JSON to parse */ parse(parsedCamera: any): void; } } declare module BABYLON { /** * Gather the list of keyboard event types as constants. */ export class KeyboardEventTypes { /** * The keydown event is fired when a key becomes active (pressed). */ static readonly KEYDOWN: number; /** * The keyup event is fired when a key has been released. */ static readonly KEYUP: number; } /** * This class is used to store keyboard related info for the onKeyboardObservable event. */ export class KeyboardInfo { /** * Defines the type of event (KeyboardEventTypes) */ type: number; /** * Defines the related dom event */ event: KeyboardEvent; /** * Instantiates a new keyboard info. * This class is used to store keyboard related info for the onKeyboardObservable event. * @param type Defines the type of event (KeyboardEventTypes) * @param event Defines the related dom event */ constructor( /** * Defines the type of event (KeyboardEventTypes) */ type: number, /** * Defines the related dom event */ event: KeyboardEvent); } /** * This class is used to store keyboard related info for the onPreKeyboardObservable event. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable */ export class KeyboardInfoPre extends KeyboardInfo { /** * Defines the type of event (KeyboardEventTypes) */ type: number; /** * Defines the related dom event */ event: KeyboardEvent; /** * Defines whether the engine should skip the next onKeyboardObservable associated to this pre. */ skipOnPointerObservable: boolean; /** * Instantiates a new keyboard pre info. * This class is used to store keyboard related info for the onPreKeyboardObservable event. * @param type Defines the type of event (KeyboardEventTypes) * @param event Defines the related dom event */ constructor( /** * Defines the type of event (KeyboardEventTypes) */ type: number, /** * Defines the related dom event */ event: KeyboardEvent); } } declare module BABYLON { /** * Manage the keyboard inputs to control the movement of a free camera. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs */ export class FreeCameraKeyboardMoveInput implements ICameraInput { /** * Defines the camera the input is attached to. */ camera: FreeCamera; /** * Gets or Set the list of keyboard keys used to control the forward move of the camera. */ keysUp: number[]; /** * Gets or Set the list of keyboard keys used to control the backward move of the camera. */ keysDown: number[]; /** * Gets or Set the list of keyboard keys used to control the left strafe move of the camera. */ keysLeft: number[]; /** * Gets or Set the list of keyboard keys used to control the right strafe move of the camera. */ keysRight: number[]; private _keys; private _onCanvasBlurObserver; private _onKeyboardObserver; private _engine; private _scene; /** * Attach the input controls to a specific dom element to get the input from. * @param element Defines the element the controls should be listened from * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault) */ attachControl(element: HTMLElement, noPreventDefault?: boolean): void; /** * Detach the current controls from the specified dom element. * @param element Defines the element to stop listening the inputs from */ detachControl(element: Nullable): void; /** * Update the current camera state depending on the inputs that have been used this frame. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop. */ checkInputs(): void; /** * Gets the class name of the current intput. * @returns the class name */ getClassName(): string; /** @hidden */ _onLostFocus(): void; /** * Get the friendly name associated with the input class. * @returns the input friendly name */ getSimpleName(): string; } } declare module BABYLON { /** * Interface describing all the common properties and methods a shadow light needs to implement. * This helps both the shadow generator and materials to genrate the corresponding shadow maps * as well as binding the different shadow properties to the effects. */ export interface IShadowLight extends Light { /** * The light id in the scene (used in scene.findLighById for instance) */ id: string; /** * The position the shdow will be casted from. */ position: Vector3; /** * In 2d mode (needCube being false), the direction used to cast the shadow. */ direction: Vector3; /** * The transformed position. Position of the light in world space taking parenting in account. */ transformedPosition: Vector3; /** * The transformed direction. Direction of the light in world space taking parenting in account. */ transformedDirection: Vector3; /** * The friendly name of the light in the scene. */ name: string; /** * Defines the shadow projection clipping minimum z value. */ shadowMinZ: number; /** * Defines the shadow projection clipping maximum z value. */ shadowMaxZ: number; /** * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light * @returns true if the information has been computed, false if it does not need to (no parenting) */ computeTransformedInformation(): boolean; /** * Gets the scene the light belongs to. * @returns The scene */ getScene(): Scene; /** * Callback defining a custom Projection Matrix Builder. * This can be used to override the default projection matrix computation. */ customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array, result: Matrix) => void; /** * Sets the shadow projection matrix in parameter to the generated projection matrix. * @param matrix The materix to updated with the projection information * @param viewMatrix The transform matrix of the light * @param renderList The list of mesh to render in the map * @returns The current light */ setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array): IShadowLight; /** * Gets the current depth scale used in ESM. * @returns The scale */ getDepthScale(): number; /** * Returns whether or not the shadow generation require a cube texture or a 2d texture. * @returns true if a cube texture needs to be use */ needCube(): boolean; /** * Detects if the projection matrix requires to be recomputed this frame. * @returns true if it requires to be recomputed otherwise, false. */ needProjectionMatrixCompute(): boolean; /** * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed. */ forceProjectionMatrixCompute(): void; /** * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed. * @param faceIndex The index of the face we are computed the direction to generate shadow * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true */ getShadowDirection(faceIndex?: number): Vector3; /** * Gets the minZ used for shadow according to both the scene and the light. * @param activeCamera The camera we are returning the min for * @returns the depth min z */ getDepthMinZ(activeCamera: Camera): number; /** * Gets the maxZ used for shadow according to both the scene and the light. * @param activeCamera The camera we are returning the max for * @returns the depth max z */ getDepthMaxZ(activeCamera: Camera): number; } /** * Base implementation IShadowLight * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern. */ export abstract class ShadowLight extends Light implements IShadowLight { protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array): void; protected _position: Vector3; protected _setPosition(value: Vector3): void; /** * Sets the position the shadow will be casted from. Also use as the light position for both * point and spot lights. */ /** * Sets the position the shadow will be casted from. Also use as the light position for both * point and spot lights. */ position: Vector3; protected _direction: Vector3; protected _setDirection(value: Vector3): void; /** * In 2d mode (needCube being false), gets the direction used to cast the shadow. * Also use as the light direction on spot and directional lights. */ /** * In 2d mode (needCube being false), sets the direction used to cast the shadow. * Also use as the light direction on spot and directional lights. */ direction: Vector3; private _shadowMinZ; /** * Gets the shadow projection clipping minimum z value. */ /** * Sets the shadow projection clipping minimum z value. */ shadowMinZ: number; private _shadowMaxZ; /** * Sets the shadow projection clipping maximum z value. */ /** * Gets the shadow projection clipping maximum z value. */ shadowMaxZ: number; /** * Callback defining a custom Projection Matrix Builder. * This can be used to override the default projection matrix computation. */ customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array, result: Matrix) => void; /** * The transformed position. Position of the light in world space taking parenting in account. */ transformedPosition: Vector3; /** * The transformed direction. Direction of the light in world space taking parenting in account. */ transformedDirection: Vector3; private _needProjectionMatrixCompute; /** * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light * @returns true if the information has been computed, false if it does not need to (no parenting) */ computeTransformedInformation(): boolean; /** * Return the depth scale used for the shadow map. * @returns the depth scale. */ getDepthScale(): number; /** * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed. * @param faceIndex The index of the face we are computed the direction to generate shadow * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true */ getShadowDirection(faceIndex?: number): Vector3; /** * Returns the ShadowLight absolute position in the World. * @returns the position vector in world space */ getAbsolutePosition(): Vector3; /** * Sets the ShadowLight direction toward the passed target. * @param target The point to target in local space * @returns the updated ShadowLight direction */ setDirectionToTarget(target: Vector3): Vector3; /** * Returns the light rotation in euler definition. * @returns the x y z rotation in local space. */ getRotation(): Vector3; /** * Returns whether or not the shadow generation require a cube texture or a 2d texture. * @returns true if a cube texture needs to be use */ needCube(): boolean; /** * Detects if the projection matrix requires to be recomputed this frame. * @returns true if it requires to be recomputed otherwise, false. */ needProjectionMatrixCompute(): boolean; /** * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed. */ forceProjectionMatrixCompute(): void; /** @hidden */ _initCache(): void; /** @hidden */ _isSynchronized(): boolean; /** * Computes the world matrix of the node * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch * @returns the world matrix */ computeWorldMatrix(force?: boolean): Matrix; /** * Gets the minZ used for shadow according to both the scene and the light. * @param activeCamera The camera we are returning the min for * @returns the depth min z */ getDepthMinZ(activeCamera: Camera): number; /** * Gets the maxZ used for shadow according to both the scene and the light. * @param activeCamera The camera we are returning the max for * @returns the depth max z */ getDepthMaxZ(activeCamera: Camera): number; /** * Sets the shadow projection matrix in parameter to the generated projection matrix. * @param matrix The materix to updated with the projection information * @param viewMatrix The transform matrix of the light * @param renderList The list of mesh to render in the map * @returns The current light */ setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array): IShadowLight; } } declare module BABYLON { /** * "Static Class" containing the most commonly used helper while dealing with material for * rendering purpose. * * It contains the basic tools to help defining defines, binding uniform for the common part of the materials. * * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions. */ export class MaterialHelper { /** * Bind the current view position to an effect. * @param effect The effect to be bound * @param scene The scene the eyes position is used from */ static BindEyePosition(effect: Effect, scene: Scene): void; /** * Helps preparing the defines values about the UVs in used in the effect. * UVs are shared as much as we can accross channels in the shaders. * @param texture The texture we are preparing the UVs for * @param defines The defines to update * @param key The channel key "diffuse", "specular"... used in the shader */ static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void; /** * Binds a texture matrix value to its corrsponding uniform * @param texture The texture to bind the matrix for * @param uniformBuffer The uniform buffer receivin the data * @param key The channel key "diffuse", "specular"... used in the shader */ static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void; /** * Gets the current status of the fog (should it be enabled?) * @param mesh defines the mesh to evaluate for fog support * @param scene defines the hosting scene * @returns true if fog must be enabled */ static GetFogState(mesh: AbstractMesh, scene: Scene): boolean; /** * Helper used to prepare the list of defines associated with misc. values for shader compilation * @param mesh defines the current mesh * @param scene defines the current scene * @param useLogarithmicDepth defines if logarithmic depth has to be turned on * @param pointsCloud defines if point cloud rendering has to be turned on * @param fogEnabled defines if fog has to be turned on * @param alphaTest defines if alpha testing has to be turned on * @param defines defines the current list of defines */ static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void; /** * Helper used to prepare the list of defines associated with frame values for shader compilation * @param scene defines the current scene * @param engine defines the current engine * @param defines specifies the list of active defines * @param useInstances defines if instances have to be turned on * @param useClipPlane defines if clip plane have to be turned on */ static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable): void; /** * Prepares the defines for bones * @param mesh The mesh containing the geometry data we will draw * @param defines The defines to update */ static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void; /** * Prepares the defines for morph targets * @param mesh The mesh containing the geometry data we will draw * @param defines The defines to update */ static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void; /** * Prepares the defines used in the shader depending on the attributes data available in the mesh * @param mesh The mesh containing the geometry data we will draw * @param defines The defines to update * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info) * @param useBones Precise whether bones should be used or not (override mesh info) * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info) * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info) * @returns false if defines are considered not dirty and have not been checked */ static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean; /** * Prepares the defines related to multiview * @param scene The scene we are intending to draw * @param defines The defines to update */ static PrepareDefinesForMultiview(scene: Scene, defines: any): void; /** * Prepares the defines related to the light information passed in parameter * @param scene The scene we are intending to draw * @param mesh The mesh the effect is compiling for * @param defines The defines to update * @param specularSupported Specifies whether specular is supported or not (override lights data) * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max * @param disableLighting Specifies whether the lighting is disabled (override scene and light) * @returns true if normals will be required for the rest of the effect */ static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean; /** * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms * that won t be acctive due to defines being turned off. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information * @param samplersList The samplers list * @param defines The defines helping in the list generation * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect */ static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void; /** * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality) * @param defines The defines to update while falling back * @param fallbacks The authorized effect fallbacks * @param maxSimultaneousLights The maximum number of lights allowed * @param rank the current rank of the Effect * @returns The newly affected rank */ static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number; /** * Prepares the list of attributes required for morph targets according to the effect defines. * @param attribs The current list of supported attribs * @param mesh The mesh to prepare the morph targets attributes for * @param defines The current Defines of the effect */ static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void; /** * Prepares the list of attributes required for bones according to the effect defines. * @param attribs The current list of supported attribs * @param mesh The mesh to prepare the bones attributes for * @param defines The current Defines of the effect * @param fallbacks The current efffect fallback strategy */ static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void; /** * Check and prepare the list of attributes required for instances according to the effect defines. * @param attribs The current list of supported attribs * @param defines The current MaterialDefines of the effect */ static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void; /** * Add the list of attributes required for instances to the attribs array. * @param attribs The current list of supported attribs */ static PushAttributesForInstances(attribs: string[]): void; /** * Binds the light shadow information to the effect for the given mesh. * @param light The light containing the generator * @param scene The scene the lights belongs to * @param mesh The mesh we are binding the information to render * @param lightIndex The light index in the effect used to render the mesh * @param effect The effect we are binding the data to */ static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void; /** * Binds the light information to the effect. * @param light The light containing the generator * @param effect The effect we are binding the data to * @param lightIndex The light index in the effect used to render */ static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void; /** * Binds the lights information from the scene to the effect for the given mesh. * @param scene The scene the lights belongs to * @param mesh The mesh we are binding the information to render * @param effect The effect we are binding the data to * @param defines The generated defines for the effect * @param maxSimultaneousLights The maximum number of light that can be bound to the effect * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not */ static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void; private static _tempFogColor; /** * Binds the fog information from the scene to the effect for the given mesh. * @param scene The scene the lights belongs to * @param mesh The mesh we are binding the information to render * @param effect The effect we are binding the data to * @param linearSpace Defines if the fog effect is applied in linear space */ static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void; /** * Binds the bones information from the mesh to the effect. * @param mesh The mesh we are binding the information to render * @param effect The effect we are binding the data to */ static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void; /** * Binds the morph targets information from the mesh to the effect. * @param abstractMesh The mesh we are binding the information to render * @param effect The effect we are binding the data to */ static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void; /** * Binds the logarithmic depth information from the scene to the effect for the given defines. * @param defines The generated defines used in the effect * @param effect The effect we are binding the data to * @param scene The scene we are willing to render with logarithmic scale for */ static BindLogDepth(defines: any, effect: Effect, scene: Scene): void; /** * Binds the clip plane information from the scene to the effect. * @param scene The scene the clip plane information are extracted from * @param effect The effect we are binding the data to */ static BindClipPlane(effect: Effect, scene: Scene): void; } } declare module BABYLON { /** @hidden */ export var kernelBlurVaryingDeclaration: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var kernelBlurFragment: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var kernelBlurFragment2: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var kernelBlurPixelShader: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var kernelBlurVertex: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var kernelBlurVertexShader: { name: string; shader: string; }; } declare module BABYLON { /** * The Blur Post Process which blurs an image based on a kernel and direction. * Can be used twice in x and y directions to perform a guassian blur in two passes. */ export class BlurPostProcess extends PostProcess { /** The direction in which to blur the image. */ direction: Vector2; private blockCompilation; protected _kernel: number; protected _idealKernel: number; protected _packedFloat: boolean; private _staticDefines; /** * Sets the length in pixels of the blur sample region */ /** * Gets the length in pixels of the blur sample region */ kernel: number; /** * Sets wether or not the blur needs to unpack/repack floats */ /** * Gets wether or not the blur is unpacking/repacking floats */ packedFloat: boolean; /** * Creates a new instance BlurPostProcess * @param name The name of the effect. * @param direction The direction in which to blur the image. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size) * @param camera The camera to apply the render pass to. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0) * @param engine The engine which the post process will be applied. (default: current engine) * @param reusable If the post process can be reused on the same frame. (default: false) * @param textureType Type of textures used when performing the post process. (default: 0) * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false) */ constructor(name: string, /** The direction in which to blur the image. */ direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean); /** * Updates the effect with the current post process compile time values and recompiles the shader. * @param defines Define statements that should be added at the beginning of the shader. (default: null) * @param uniforms Set of uniform variables that will be passed to the shader. (default: null) * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null) * @param indexParameters The index parameters to be used for babylons include syntax "#include[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx * @param onCompiled Called when the shader has been compiled. * @param onError Called if there is an error when compiling a shader. */ updateEffect(defines?: Nullable, uniforms?: Nullable, samplers?: Nullable, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void; protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void; /** * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard. * The gaps between physical kernels are compensated for in the weighting of the samples * @param idealKernel Ideal blur kernel. * @return Nearest best kernel. */ protected _nearestBestKernel(idealKernel: number): number; /** * Calculates the value of a Gaussian distribution with sigma 3 at a given point. * @param x The point on the Gaussian distribution to sample. * @return the value of the Gaussian function at x. */ protected _gaussianWeight(x: number): number; /** * Generates a string that can be used as a floating point number in GLSL. * @param x Value to print. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s). * @return GLSL float string. */ protected _glslFloat(x: number, decimalFigures?: number): string; } } declare module BABYLON { /** @hidden */ export var shadowMapPixelShader: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var bonesDeclaration: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var morphTargetsVertexGlobalDeclaration: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var morphTargetsVertexDeclaration: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var instancesDeclaration: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var helperFunctions: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var morphTargetsVertex: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var instancesVertex: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var bonesVertex: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var shadowMapVertexShader: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var depthBoxBlurPixelShader: { name: string; shader: string; }; } declare module BABYLON { /** * Defines the options associated with the creation of a custom shader for a shadow generator. */ export interface ICustomShaderOptions { /** * Gets or sets the custom shader name to use */ shaderName: string; /** * The list of attribute names used in the shader */ attributes?: string[]; /** * The list of unifrom names used in the shader */ uniforms?: string[]; /** * The list of sampler names used in the shader */ samplers?: string[]; /** * The list of defines used in the shader */ defines?: string[]; } /** * Interface to implement to create a shadow generator compatible with BJS. */ export interface IShadowGenerator { /** * Gets the main RTT containing the shadow map (usually storing depth from the light point of view). * @returns The render target texture if present otherwise, null */ getShadowMap(): Nullable; /** * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself). * @returns The render target texture if the shadow map is present otherwise, null */ getShadowMapForRendering(): Nullable; /** * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready). * @param subMesh The submesh we want to render in the shadow map * @param useInstances Defines wether will draw in the map using instances * @returns true if ready otherwise, false */ isReady(subMesh: SubMesh, useInstances: boolean): boolean; /** * Prepare all the defines in a material relying on a shadow map at the specified light index. * @param defines Defines of the material we want to update * @param lightIndex Index of the light in the enabled light list of the material */ prepareDefines(defines: MaterialDefines, lightIndex: number): void; /** * Binds the shadow related information inside of an effect (information like near, far, darkness... * defined in the generator but impacting the effect). * It implies the unifroms available on the materials are the standard BJS ones. * @param lightIndex Index of the light in the enabled light list of the material owning the effect * @param effect The effect we are binfing the information for */ bindShadowLight(lightIndex: string, effect: Effect): void; /** * Gets the transformation matrix used to project the meshes into the map from the light point of view. * (eq to shadow prjection matrix * light transform matrix) * @returns The transform matrix used to create the shadow map */ getTransformMatrix(): Matrix; /** * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between * Cube and 2D textures for instance. */ recreateShadowMap(): void; /** * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects. * @param onCompiled Callback triggered at the and of the effects compilation * @param options Sets of optional options forcing the compilation with different modes */ forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{ useInstances: boolean; }>): void; /** * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects. * @param options Sets of optional options forcing the compilation with different modes * @returns A promise that resolves when the compilation completes */ forceCompilationAsync(options?: Partial<{ useInstances: boolean; }>): Promise; /** * Serializes the shadow generator setup to a json object. * @returns The serialized JSON object */ serialize(): any; /** * Disposes the Shadow map and related Textures and effects. */ dispose(): void; } /** * Default implementation IShadowGenerator. * This is the main object responsible of generating shadows in the framework. * Documentation: https://doc.babylonjs.com/babylon101/shadows */ export class ShadowGenerator implements IShadowGenerator { /** * Shadow generator mode None: no filtering applied. */ static readonly FILTER_NONE: number; /** * Shadow generator mode ESM: Exponential Shadow Mapping. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf) */ static readonly FILTER_EXPONENTIALSHADOWMAP: number; /** * Shadow generator mode Poisson Sampling: Percentage Closer Filtering. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength) */ static readonly FILTER_POISSONSAMPLING: number; /** * Shadow generator mode ESM: Blurred Exponential Shadow Mapping. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf) */ static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number; /** * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing * edge artifacts on steep falloff. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf) */ static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number; /** * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing * edge artifacts on steep falloff. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf) */ static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number; /** * Shadow generator mode PCF: Percentage Closer Filtering * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1 * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html) */ static readonly FILTER_PCF: number; /** * Shadow generator mode PCSS: Percentage Closering Soft Shadow. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1 * Contact Hardening */ static readonly FILTER_PCSS: number; /** * Reserved for PCF and PCSS * Highest Quality. * * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts. * * Execute PCSS with 32 taps blocker search and 64 taps PCF. */ static readonly QUALITY_HIGH: number; /** * Reserved for PCF and PCSS * Good tradeoff for quality/perf cross devices * * Execute PCF on a 3*3 kernel. * * Execute PCSS with 16 taps blocker search and 32 taps PCF. */ static readonly QUALITY_MEDIUM: number; /** * Reserved for PCF and PCSS * The lowest quality but the fastest. * * Execute PCF on a 1*1 kernel. * * Execute PCSS with 16 taps blocker search and 16 taps PCF. */ static readonly QUALITY_LOW: number; /** Gets or sets the custom shader name to use */ customShaderOptions: ICustomShaderOptions; /** * Observable triggered before the shadow is rendered. Can be used to update internal effect state */ onBeforeShadowMapRenderObservable: Observable; /** * Observable triggered after the shadow is rendered. Can be used to restore internal effect state */ onAfterShadowMapRenderObservable: Observable; /** * Observable triggered before a mesh is rendered in the shadow map. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable) */ onBeforeShadowMapRenderMeshObservable: Observable; /** * Observable triggered after a mesh is rendered in the shadow map. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable) */ onAfterShadowMapRenderMeshObservable: Observable; private _bias; /** * Gets the bias: offset applied on the depth preventing acnea (in light direction). */ /** * Sets the bias: offset applied on the depth preventing acnea (in light direction). */ bias: number; private _normalBias; /** * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle). */ /** * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle). */ normalBias: number; private _blurBoxOffset; /** * Gets the blur box offset: offset applied during the blur pass. * Only useful if useKernelBlur = false */ /** * Sets the blur box offset: offset applied during the blur pass. * Only useful if useKernelBlur = false */ blurBoxOffset: number; private _blurScale; /** * Gets the blur scale: scale of the blurred texture compared to the main shadow map. * 2 means half of the size. */ /** * Sets the blur scale: scale of the blurred texture compared to the main shadow map. * 2 means half of the size. */ blurScale: number; private _blurKernel; /** * Gets the blur kernel: kernel size of the blur pass. * Only useful if useKernelBlur = true */ /** * Sets the blur kernel: kernel size of the blur pass. * Only useful if useKernelBlur = true */ blurKernel: number; private _useKernelBlur; /** * Gets whether the blur pass is a kernel blur (if true) or box blur. * Only useful in filtered mode (useBlurExponentialShadowMap...) */ /** * Sets whether the blur pass is a kernel blur (if true) or box blur. * Only useful in filtered mode (useBlurExponentialShadowMap...) */ useKernelBlur: boolean; private _depthScale; /** * Gets the depth scale used in ESM mode. */ /** * Sets the depth scale used in ESM mode. * This can override the scale stored on the light. */ depthScale: number; private _filter; /** * Gets the current mode of the shadow generator (normal, PCF, ESM...). * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE */ /** * Sets the current mode of the shadow generator (normal, PCF, ESM...). * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE */ filter: number; /** * Gets if the current filter is set to Poisson Sampling. */ /** * Sets the current filter to Poisson Sampling. */ usePoissonSampling: boolean; /** * Gets if the current filter is set to ESM. */ /** * Sets the current filter is to ESM. */ useExponentialShadowMap: boolean; /** * Gets if the current filter is set to filtered ESM. */ /** * Gets if the current filter is set to filtered ESM. */ useBlurExponentialShadowMap: boolean; /** * Gets if the current filter is set to "close ESM" (using the inverse of the * exponential to prevent steep falloff artifacts). */ /** * Sets the current filter to "close ESM" (using the inverse of the * exponential to prevent steep falloff artifacts). */ useCloseExponentialShadowMap: boolean; /** * Gets if the current filter is set to filtered "close ESM" (using the inverse of the * exponential to prevent steep falloff artifacts). */ /** * Sets the current filter to filtered "close ESM" (using the inverse of the * exponential to prevent steep falloff artifacts). */ useBlurCloseExponentialShadowMap: boolean; /** * Gets if the current filter is set to "PCF" (percentage closer filtering). */ /** * Sets the current filter to "PCF" (percentage closer filtering). */ usePercentageCloserFiltering: boolean; private _filteringQuality; /** * Gets the PCF or PCSS Quality. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true. */ /** * Sets the PCF or PCSS Quality. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true. */ filteringQuality: number; /** * Gets if the current filter is set to "PCSS" (contact hardening). */ /** * Sets the current filter to "PCSS" (contact hardening). */ useContactHardeningShadow: boolean; private _contactHardeningLightSizeUVRatio; /** * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size. * Using a ratio helps keeping shape stability independently of the map size. * * It does not account for the light projection as it was having too much * instability during the light setup or during light position changes. * * Only valid if useContactHardeningShadow is true. */ /** * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size. * Using a ratio helps keeping shape stability independently of the map size. * * It does not account for the light projection as it was having too much * instability during the light setup or during light position changes. * * Only valid if useContactHardeningShadow is true. */ contactHardeningLightSizeUVRatio: number; private _darkness; /** Gets or sets the actual darkness of a shadow */ darkness: number; /** * Returns the darkness value (float). This can only decrease the actual darkness of a shadow. * 0 means strongest and 1 would means no shadow. * @returns the darkness. */ getDarkness(): number; /** * Sets the darkness value (float). This can only decrease the actual darkness of a shadow. * @param darkness The darkness value 0 means strongest and 1 would means no shadow. * @returns the shadow generator allowing fluent coding. */ setDarkness(darkness: number): ShadowGenerator; private _transparencyShadow; /** Gets or sets the ability to have transparent shadow */ transparencyShadow: boolean; /** * Sets the ability to have transparent shadow (boolean). * @param transparent True if transparent else False * @returns the shadow generator allowing fluent coding */ setTransparencyShadow(transparent: boolean): ShadowGenerator; private _shadowMap; private _shadowMap2; /** * Gets the main RTT containing the shadow map (usually storing depth from the light point of view). * @returns The render target texture if present otherwise, null */ getShadowMap(): Nullable; /** * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself). * @returns The render target texture if the shadow map is present otherwise, null */ getShadowMapForRendering(): Nullable; /** * Gets the class name of that object * @returns "ShadowGenerator" */ getClassName(): string; /** * Helper function to add a mesh and its descendants to the list of shadow casters. * @param mesh Mesh to add * @param includeDescendants boolean indicating if the descendants should be added. Default to true * @returns the Shadow Generator itself */ addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator; /** * Helper function to remove a mesh and its descendants from the list of shadow casters * @param mesh Mesh to remove * @param includeDescendants boolean indicating if the descendants should be removed. Default to true * @returns the Shadow Generator itself */ removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator; /** * Controls the extent to which the shadows fade out at the edge of the frustum * Used only by directionals and spots */ frustumEdgeFalloff: number; private _light; /** * Returns the associated light object. * @returns the light generating the shadow */ getLight(): IShadowLight; /** * If true the shadow map is generated by rendering the back face of the mesh instead of the front face. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset. * It might on the other hand introduce peter panning. */ forceBackFacesOnly: boolean; private _scene; private _lightDirection; private _effect; private _viewMatrix; private _projectionMatrix; private _transformMatrix; private _cachedPosition; private _cachedDirection; private _cachedDefines; private _currentRenderID; private _boxBlurPostprocess; private _kernelBlurXPostprocess; private _kernelBlurYPostprocess; private _blurPostProcesses; private _mapSize; private _currentFaceIndex; private _currentFaceIndexCache; private _textureType; private _defaultTextureMatrix; /** @hidden */ static _SceneComponentInitialization: (scene: Scene) => void; /** * Creates a ShadowGenerator object. * A ShadowGenerator is the required tool to use the shadows. * Each light casting shadows needs to use its own ShadowGenerator. * Documentation : https://doc.babylonjs.com/babylon101/shadows * @param mapSize The size of the texture what stores the shadows. Example : 1024. * @param light The light object generating the shadows. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture. */ constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean); private _initializeGenerator; private _initializeShadowMap; private _initializeBlurRTTAndPostProcesses; private _renderForShadowMap; private _renderSubMeshForShadowMap; private _applyFilterValues; /** * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects. * @param onCompiled Callback triggered at the and of the effects compilation * @param options Sets of optional options forcing the compilation with different modes */ forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{ useInstances: boolean; }>): void; /** * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects. * @param options Sets of optional options forcing the compilation with different modes * @returns A promise that resolves when the compilation completes */ forceCompilationAsync(options?: Partial<{ useInstances: boolean; }>): Promise; /** * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready). * @param subMesh The submesh we want to render in the shadow map * @param useInstances Defines wether will draw in the map using instances * @returns true if ready otherwise, false */ isReady(subMesh: SubMesh, useInstances: boolean): boolean; /** * Prepare all the defines in a material relying on a shadow map at the specified light index. * @param defines Defines of the material we want to update * @param lightIndex Index of the light in the enabled light list of the material */ prepareDefines(defines: any, lightIndex: number): void; /** * Binds the shadow related information inside of an effect (information like near, far, darkness... * defined in the generator but impacting the effect). * @param lightIndex Index of the light in the enabled light list of the material owning the effect * @param effect The effect we are binfing the information for */ bindShadowLight(lightIndex: string, effect: Effect): void; /** * Gets the transformation matrix used to project the meshes into the map from the light point of view. * (eq to shadow prjection matrix * light transform matrix) * @returns The transform matrix used to create the shadow map */ getTransformMatrix(): Matrix; /** * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between * Cube and 2D textures for instance. */ recreateShadowMap(): void; private _disposeBlurPostProcesses; private _disposeRTTandPostProcesses; /** * Disposes the ShadowGenerator. * Returns nothing. */ dispose(): void; /** * Serializes the shadow generator setup to a json object. * @returns The serialized JSON object */ serialize(): any; /** * Parses a serialized ShadowGenerator and returns a new ShadowGenerator. * @param parsedShadowGenerator The JSON object to parse * @param scene The scene to create the shadow map for * @returns The parsed shadow generator */ static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator; } } declare module BABYLON { /** * Base class of all the lights in Babylon. It groups all the generic information about lights. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased. */ export abstract class Light extends Node { /** * Falloff Default: light is falling off following the material specification: * standard material is using standard falloff whereas pbr material can request special falloff per materials. */ static readonly FALLOFF_DEFAULT: number; /** * Falloff Physical: light is falling off following the inverse squared distance law. */ static readonly FALLOFF_PHYSICAL: number; /** * Falloff gltf: light is falling off as described in the gltf moving to PBR document * to enhance interoperability with other engines. */ static readonly FALLOFF_GLTF: number; /** * Falloff Standard: light is falling off like in the standard material * to enhance interoperability with other materials. */ static readonly FALLOFF_STANDARD: number; /** * If every light affecting the material is in this lightmapMode, * material.lightmapTexture adds or multiplies * (depends on material.useLightmapAsShadowmap) * after every other light calculations. */ static readonly LIGHTMAP_DEFAULT: number; /** * material.lightmapTexture as only diffuse lighting from this light * adds only specular lighting from this light * adds dynamic shadows */ static readonly LIGHTMAP_SPECULAR: number; /** * material.lightmapTexture as only lighting * no light calculation from this light * only adds dynamic shadows from this light */ static readonly LIGHTMAP_SHADOWSONLY: number; /** * Each light type uses the default quantity according to its type: * point/spot lights use luminous intensity * directional lights use illuminance */ static readonly INTENSITYMODE_AUTOMATIC: number; /** * lumen (lm) */ static readonly INTENSITYMODE_LUMINOUSPOWER: number; /** * candela (lm/sr) */ static readonly INTENSITYMODE_LUMINOUSINTENSITY: number; /** * lux (lm/m^2) */ static readonly INTENSITYMODE_ILLUMINANCE: number; /** * nit (cd/m^2) */ static readonly INTENSITYMODE_LUMINANCE: number; /** * Light type const id of the point light. */ static readonly LIGHTTYPEID_POINTLIGHT: number; /** * Light type const id of the directional light. */ static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number; /** * Light type const id of the spot light. */ static readonly LIGHTTYPEID_SPOTLIGHT: number; /** * Light type const id of the hemispheric light. */ static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number; /** * Diffuse gives the basic color to an object. */ diffuse: Color3; /** * Specular produces a highlight color on an object. * Note: This is note affecting PBR materials. */ specular: Color3; /** * Defines the falloff type for this light. This lets overrriding how punctual light are * falling off base on range or angle. * This can be set to any values in Light.FALLOFF_x. * * Note: This is only useful for PBR Materials at the moment. This could be extended if required to * other types of materials. */ falloffType: number; /** * Strength of the light. * Note: By default it is define in the framework own unit. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in. */ intensity: number; private _range; protected _inverseSquaredRange: number; /** * Defines how far from the source the light is impacting in scene units. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff. */ /** * Defines how far from the source the light is impacting in scene units. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff. */ range: number; /** * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type * of light. */ private _photometricScale; private _intensityMode; /** * Gets the photometric scale used to interpret the intensity. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way. */ /** * Sets the photometric scale used to interpret the intensity. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way. */ intensityMode: number; private _radius; /** * Gets the light radius used by PBR Materials to simulate soft area lights. */ /** * sets the light radius used by PBR Materials to simulate soft area lights. */ radius: number; private _renderPriority; /** * Defines the rendering priority of the lights. It can help in case of fallback or number of lights * exceeding the number allowed of the materials. */ renderPriority: number; private _shadowEnabled; /** * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching * the current shadow generator. */ /** * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching * the current shadow generator. */ shadowEnabled: boolean; private _includedOnlyMeshes; /** * Gets the only meshes impacted by this light. */ /** * Sets the only meshes impacted by this light. */ includedOnlyMeshes: AbstractMesh[]; private _excludedMeshes; /** * Gets the meshes not impacted by this light. */ /** * Sets the meshes not impacted by this light. */ excludedMeshes: AbstractMesh[]; private _excludeWithLayerMask; /** * Gets the layer id use to find what meshes are not impacted by the light. * Inactive if 0 */ /** * Sets the layer id use to find what meshes are not impacted by the light. * Inactive if 0 */ excludeWithLayerMask: number; private _includeOnlyWithLayerMask; /** * Gets the layer id use to find what meshes are impacted by the light. * Inactive if 0 */ /** * Sets the layer id use to find what meshes are impacted by the light. * Inactive if 0 */ includeOnlyWithLayerMask: number; private _lightmapMode; /** * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x) */ /** * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x) */ lightmapMode: number; /** * Shadow generator associted to the light. * @hidden Internal use only. */ _shadowGenerator: Nullable; /** * @hidden Internal use only. */ _excludedMeshesIds: string[]; /** * @hidden Internal use only. */ _includedOnlyMeshesIds: string[]; /** * The current light unifom buffer. * @hidden Internal use only. */ _uniformBuffer: UniformBuffer; /** * Creates a Light object in the scene. * Documentation : https://doc.babylonjs.com/babylon101/lights * @param name The firendly name of the light * @param scene The scene the light belongs too */ constructor(name: string, scene: Scene); protected abstract _buildUniformLayout(): void; /** * Sets the passed Effect "effect" with the Light information. * @param effect The effect to update * @param lightIndex The index of the light in the effect to update * @returns The light */ abstract transferToEffect(effect: Effect, lightIndex: string): Light; /** * Returns the string "Light". * @returns the class name */ getClassName(): string; /** @hidden */ readonly _isLight: boolean; /** * Converts the light information to a readable string for debug purpose. * @param fullDetails Supports for multiple levels of logging within scene loading * @returns the human readable light info */ toString(fullDetails?: boolean): string; /** @hidden */ protected _syncParentEnabledState(): void; /** * Set the enabled state of this node. * @param value - the new enabled state */ setEnabled(value: boolean): void; /** * Returns the Light associated shadow generator if any. * @return the associated shadow generator. */ getShadowGenerator(): Nullable; /** * Returns a Vector3, the absolute light position in the World. * @returns the world space position of the light */ getAbsolutePosition(): Vector3; /** * Specifies if the light will affect the passed mesh. * @param mesh The mesh to test against the light * @return true the mesh is affected otherwise, false. */ canAffectMesh(mesh: AbstractMesh): boolean; /** * Sort function to order lights for rendering. * @param a First Light object to compare to second. * @param b Second Light object to compare first. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b. */ static CompareLightsPriority(a: Light, b: Light): number; /** * Releases resources associated with this node. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default) * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default) */ dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void; /** * Returns the light type ID (integer). * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x */ getTypeID(): number; /** * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode. * @returns the scaled intensity in intensity mode unit */ getScaledIntensity(): number; /** * Returns a new Light object, named "name", from the current one. * @param name The name of the cloned light * @returns the new created light */ clone(name: string): Nullable; /** * Serializes the current light into a Serialization object. * @returns the serialized object. */ serialize(): any; /** * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3. * This new light is named "name" and added to the passed scene. * @param type Type according to the types available in Light.LIGHTTYPEID_x * @param name The friendly name of the light * @param scene The scene the new light will belong to * @returns the constructor function */ static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>; /** * Parses the passed "parsedLight" and returns a new instanced Light from this parsing. * @param parsedLight The JSON representation of the light * @param scene The scene to create the parsed light in * @returns the created light after parsing */ static Parse(parsedLight: any, scene: Scene): Nullable; private _hookArrayForExcluded; private _hookArrayForIncludedOnly; private _resyncMeshes; /** * Forces the meshes to update their light related information in their rendering used effects * @hidden Internal Use Only */ _markMeshesAsLightDirty(): void; /** * Recomputes the cached photometric scale if needed. */ private _computePhotometricScale; /** * Returns the Photometric Scale according to the light type and intensity mode. */ private _getPhotometricScale; /** * Reorder the light in the scene according to their defined priority. * @hidden Internal Use Only */ _reorderLightsInScene(): void; /** * Prepares the list of defines specific to the light type. * @param defines the list of defines * @param lightIndex defines the index of the light for the effect */ abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void; } } declare module BABYLON { /** * Interface used to define Action */ export interface IAction { /** * Trigger for the action */ trigger: number; /** Options of the trigger */ triggerOptions: any; /** * Gets the trigger parameters * @returns the trigger parameters */ getTriggerParameter(): any; /** * Internal only - executes current action event * @hidden */ _executeCurrent(evt?: ActionEvent): void; /** * Serialize placeholder for child classes * @param parent of child * @returns the serialized object */ serialize(parent: any): any; /** * Internal only * @hidden */ _prepare(): void; /** * Internal only - manager for action * @hidden */ _actionManager: AbstractActionManager; /** * Adds action to chain of actions, may be a DoNothingAction * @param action defines the next action to execute * @returns The action passed in * @see https://www.babylonjs-playground.com/#1T30HR#0 */ then(action: IAction): IAction; } /** * The action to be carried out following a trigger * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions */ export class Action implements IAction { /** the trigger, with or without parameters, for the action */ triggerOptions: any; /** * Trigger for the action */ trigger: number; /** * Internal only - manager for action * @hidden */ _actionManager: ActionManager; private _nextActiveAction; private _child; private _condition?; private _triggerParameter; /** * An event triggered prior to action being executed. */ onBeforeExecuteObservable: Observable; /** * Creates a new Action * @param triggerOptions the trigger, with or without parameters, for the action * @param condition an optional determinant of action */ constructor( /** the trigger, with or without parameters, for the action */ triggerOptions: any, condition?: Condition); /** * Internal only * @hidden */ _prepare(): void; /** * Gets the trigger parameters * @returns the trigger parameters */ getTriggerParameter(): any; /** * Internal only - executes current action event * @hidden */ _executeCurrent(evt?: ActionEvent): void; /** * Execute placeholder for child classes * @param evt optional action event */ execute(evt?: ActionEvent): void; /** * Skips to next active action */ skipToNextActiveAction(): void; /** * Adds action to chain of actions, may be a DoNothingAction * @param action defines the next action to execute * @returns The action passed in * @see https://www.babylonjs-playground.com/#1T30HR#0 */ then(action: Action): Action; /** * Internal only * @hidden */ _getProperty(propertyPath: string): string; /** * Internal only * @hidden */ _getEffectiveTarget(target: any, propertyPath: string): any; /** * Serialize placeholder for child classes * @param parent of child * @returns the serialized object */ serialize(parent: any): any; /** * Internal only called by serialize * @hidden */ protected _serialize(serializedAction: any, parent?: any): any; /** * Internal only * @hidden */ static _SerializeValueAsString: (value: any) => string; /** * Internal only * @hidden */ static _GetTargetProperty: (target: Scene | Node) => { name: string; targetType: string; value: string; }; } } declare module BABYLON { /** * A Condition applied to an Action */ export class Condition { /** * Internal only - manager for action * @hidden */ _actionManager: ActionManager; /** * Internal only * @hidden */ _evaluationId: number; /** * Internal only * @hidden */ _currentResult: boolean; /** * Creates a new Condition * @param actionManager the manager of the action the condition is applied to */ constructor(actionManager: ActionManager); /** * Check if the current condition is valid * @returns a boolean */ isValid(): boolean; /** * Internal only * @hidden */ _getProperty(propertyPath: string): string; /** * Internal only * @hidden */ _getEffectiveTarget(target: any, propertyPath: string): any; /** * Serialize placeholder for child classes * @returns the serialized object */ serialize(): any; /** * Internal only * @hidden */ protected _serialize(serializedCondition: any): any; } /** * Defines specific conditional operators as extensions of Condition */ export class ValueCondition extends Condition { /** path to specify the property of the target the conditional operator uses */ propertyPath: string; /** the value compared by the conditional operator against the current value of the property */ value: any; /** the conditional operator, default ValueCondition.IsEqual */ operator: number; /** * Internal only * @hidden */ private static _IsEqual; /** * Internal only * @hidden */ private static _IsDifferent; /** * Internal only * @hidden */ private static _IsGreater; /** * Internal only * @hidden */ private static _IsLesser; /** * returns the number for IsEqual */ static readonly IsEqual: number; /** * Returns the number for IsDifferent */ static readonly IsDifferent: number; /** * Returns the number for IsGreater */ static readonly IsGreater: number; /** * Returns the number for IsLesser */ static readonly IsLesser: number; /** * Internal only The action manager for the condition * @hidden */ _actionManager: ActionManager; /** * Internal only * @hidden */ private _target; /** * Internal only * @hidden */ private _effectiveTarget; /** * Internal only * @hidden */ private _property; /** * Creates a new ValueCondition * @param actionManager manager for the action the condition applies to * @param target for the action * @param propertyPath path to specify the property of the target the conditional operator uses * @param value the value compared by the conditional operator against the current value of the property * @param operator the conditional operator, default ValueCondition.IsEqual */ constructor(actionManager: ActionManager, target: any, /** path to specify the property of the target the conditional operator uses */ propertyPath: string, /** the value compared by the conditional operator against the current value of the property */ value: any, /** the conditional operator, default ValueCondition.IsEqual */ operator?: number); /** * Compares the given value with the property value for the specified conditional operator * @returns the result of the comparison */ isValid(): boolean; /** * Serialize the ValueCondition into a JSON compatible object * @returns serialization object */ serialize(): any; /** * Gets the name of the conditional operator for the ValueCondition * @param operator the conditional operator * @returns the name */ static GetOperatorName(operator: number): string; } /** * Defines a predicate condition as an extension of Condition */ export class PredicateCondition extends Condition { /** defines the predicate function used to validate the condition */ predicate: () => boolean; /** * Internal only - manager for action * @hidden */ _actionManager: ActionManager; /** * Creates a new PredicateCondition * @param actionManager manager for the action the condition applies to * @param predicate defines the predicate function used to validate the condition */ constructor(actionManager: ActionManager, /** defines the predicate function used to validate the condition */ predicate: () => boolean); /** * @returns the validity of the predicate condition */ isValid(): boolean; } /** * Defines a state condition as an extension of Condition */ export class StateCondition extends Condition { /** Value to compare with target state */ value: string; /** * Internal only - manager for action * @hidden */ _actionManager: ActionManager; /** * Internal only * @hidden */ private _target; /** * Creates a new StateCondition * @param actionManager manager for the action the condition applies to * @param target of the condition * @param value to compare with target state */ constructor(actionManager: ActionManager, target: any, /** Value to compare with target state */ value: string); /** * Gets a boolean indicating if the current condition is met * @returns the validity of the state */ isValid(): boolean; /** * Serialize the StateCondition into a JSON compatible object * @returns serialization object */ serialize(): any; } } declare module BABYLON { /** * This defines an action responsible to toggle a boolean once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ export class SwitchBooleanAction extends Action { /** * The path to the boolean property in the target object */ propertyPath: string; private _target; private _effectiveTarget; private _property; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param target defines the object containing the boolean * @param propertyPath defines the path to the boolean property in the target object * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition); /** @hidden */ _prepare(): void; /** * Execute the action toggle the boolean value. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } /** * This defines an action responsible to set a the state field of the target * to a desired value once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ export class SetStateAction extends Action { /** * The value to store in the state field. */ value: string; private _target; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param target defines the object containing the state property * @param value defines the value to store in the state field * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, target: any, value: string, condition?: Condition); /** * Execute the action and store the value on the target state property. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } /** * This defines an action responsible to set a property of the target * to a desired value once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ export class SetValueAction extends Action { /** * The path of the property to set in the target. */ propertyPath: string; /** * The value to set in the property */ value: any; private _target; private _effectiveTarget; private _property; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param target defines the object containing the property * @param propertyPath defines the path of the property to set in the target * @param value defines the value to set in the property * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition); /** @hidden */ _prepare(): void; /** * Execute the action and set the targetted property to the desired value. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } /** * This defines an action responsible to increment the target value * to a desired value once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ export class IncrementValueAction extends Action { /** * The path of the property to increment in the target. */ propertyPath: string; /** * The value we should increment the property by. */ value: any; private _target; private _effectiveTarget; private _property; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param target defines the object containing the property * @param propertyPath defines the path of the property to increment in the target * @param value defines the value value we should increment the property by * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition); /** @hidden */ _prepare(): void; /** * Execute the action and increment the target of the value amount. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } /** * This defines an action responsible to start an animation once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ export class PlayAnimationAction extends Action { /** * Where the animation should start (animation frame) */ from: number; /** * Where the animation should stop (animation frame) */ to: number; /** * Define if the animation should loop or stop after the first play. */ loop?: boolean; private _target; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param target defines the target animation or animation name * @param from defines from where the animation should start (animation frame) * @param end defines where the animation should stop (animation frame) * @param loop defines if the animation should loop or stop after the first play * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition); /** @hidden */ _prepare(): void; /** * Execute the action and play the animation. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } /** * This defines an action responsible to stop an animation once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ export class StopAnimationAction extends Action { private _target; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param target defines the target animation or animation name * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, target: any, condition?: Condition); /** @hidden */ _prepare(): void; /** * Execute the action and stop the animation. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } /** * This defines an action responsible that does nothing once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ export class DoNothingAction extends Action { /** * Instantiate the action * @param triggerOptions defines the trigger options * @param condition defines the trigger related conditions */ constructor(triggerOptions?: any, condition?: Condition); /** * Execute the action and do nothing. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } /** * This defines an action responsible to trigger several actions once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ export class CombineAction extends Action { /** * The list of aggregated animations to run. */ children: Action[]; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param children defines the list of aggregated animations to run * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, children: Action[], condition?: Condition); /** @hidden */ _prepare(): void; /** * Execute the action and executes all the aggregated actions. */ execute(evt: ActionEvent): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } /** * This defines an action responsible to run code (external event) once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ export class ExecuteCodeAction extends Action { /** * The callback function to run. */ func: (evt: ActionEvent) => void; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param func defines the callback function to run * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition); /** * Execute the action and run the attached code. */ execute(evt: ActionEvent): void; } /** * This defines an action responsible to set the parent property of the target once triggered. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ export class SetParentAction extends Action { private _parent; private _target; /** * Instantiate the action * @param triggerOptions defines the trigger options * @param target defines the target containing the parent property * @param parent defines from where the animation should start (animation frame) * @param condition defines the trigger related conditions */ constructor(triggerOptions: any, target: any, parent: any, condition?: Condition); /** @hidden */ _prepare(): void; /** * Execute the action and set the parent property. */ execute(): void; /** * Serializes the actions and its related information. * @param parent defines the object to serialize in * @returns the serialized object */ serialize(parent: any): any; } } declare module BABYLON { /** * Action Manager manages all events to be triggered on a given mesh or the global scene. * A single scene can have many Action Managers to handle predefined actions on specific meshes. * @see http://doc.babylonjs.com/how_to/how_to_use_actions */ export class ActionManager extends AbstractActionManager { /** * Nothing * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly NothingTrigger: number; /** * On pick * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnPickTrigger: number; /** * On left pick * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnLeftPickTrigger: number; /** * On right pick * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnRightPickTrigger: number; /** * On center pick * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnCenterPickTrigger: number; /** * On pick down * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnPickDownTrigger: number; /** * On double pick * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnDoublePickTrigger: number; /** * On pick up * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnPickUpTrigger: number; /** * On pick out. * This trigger will only be raised if you also declared a OnPickDown * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnPickOutTrigger: number; /** * On long press * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnLongPressTrigger: number; /** * On pointer over * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnPointerOverTrigger: number; /** * On pointer out * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnPointerOutTrigger: number; /** * On every frame * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnEveryFrameTrigger: number; /** * On intersection enter * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnIntersectionEnterTrigger: number; /** * On intersection exit * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnIntersectionExitTrigger: number; /** * On key down * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnKeyDownTrigger: number; /** * On key up * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers */ static readonly OnKeyUpTrigger: number; private _scene; /** * Creates a new action manager * @param scene defines the hosting scene */ constructor(scene: Scene); /** * Releases all associated resources */ dispose(): void; /** * Gets hosting scene * @returns the hosting scene */ getScene(): Scene; /** * Does this action manager handles actions of any of the given triggers * @param triggers defines the triggers to be tested * @return a boolean indicating whether one (or more) of the triggers is handled */ hasSpecificTriggers(triggers: number[]): boolean; /** * Does this action manager handles actions of any of the given triggers. This function takes two arguments for * speed. * @param triggerA defines the trigger to be tested * @param triggerB defines the trigger to be tested * @return a boolean indicating whether one (or more) of the triggers is handled */ hasSpecificTriggers2(triggerA: number, triggerB: number): boolean; /** * Does this action manager handles actions of a given trigger * @param trigger defines the trigger to be tested * @param parameterPredicate defines an optional predicate to filter triggers by parameter * @return whether the trigger is handled */ hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean; /** * Does this action manager has pointer triggers */ readonly hasPointerTriggers: boolean; /** * Does this action manager has pick triggers */ readonly hasPickTriggers: boolean; /** * Registers an action to this action manager * @param action defines the action to be registered * @return the action amended (prepared) after registration */ registerAction(action: IAction): Nullable; /** * Unregisters an action to this action manager * @param action defines the action to be unregistered * @return a boolean indicating whether the action has been unregistered */ unregisterAction(action: IAction): Boolean; /** * Process a specific trigger * @param trigger defines the trigger to process * @param evt defines the event details to be processed */ processTrigger(trigger: number, evt?: IActionEvent): void; /** @hidden */ _getEffectiveTarget(target: any, propertyPath: string): any; /** @hidden */ _getProperty(propertyPath: string): string; /** * Serialize this manager to a JSON object * @param name defines the property name to store this manager * @returns a JSON representation of this manager */ serialize(name: string): any; /** * Creates a new ActionManager from a JSON data * @param parsedActions defines the JSON data to read from * @param object defines the hosting mesh * @param scene defines the hosting scene */ static Parse(parsedActions: any, object: Nullable, scene: Scene): void; /** * Get a trigger name by index * @param trigger defines the trigger index * @returns a trigger name */ static GetTriggerName(trigger: number): string; } } declare module BABYLON { /** * Class representing a ray with position and direction */ export class Ray { /** origin point */ origin: Vector3; /** direction */ direction: Vector3; /** length of the ray */ length: number; private static readonly TmpVector3; private _tmpRay; /** * Creates a new ray * @param origin origin point * @param direction direction * @param length length of the ray */ constructor( /** origin point */ origin: Vector3, /** direction */ direction: Vector3, /** length of the ray */ length?: number); /** * Checks if the ray intersects a box * @param minimum bound of the box * @param maximum bound of the box * @param intersectionTreshold extra extend to be added to the box in all direction * @returns if the box was hit */ intersectsBoxMinMax(minimum: DeepImmutable, maximum: DeepImmutable, intersectionTreshold?: number): boolean; /** * Checks if the ray intersects a box * @param box the bounding box to check * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction * @returns if the box was hit */ intersectsBox(box: DeepImmutable, intersectionTreshold?: number): boolean; /** * If the ray hits a sphere * @param sphere the bounding sphere to check * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction * @returns true if it hits the sphere */ intersectsSphere(sphere: DeepImmutable, intersectionTreshold?: number): boolean; /** * If the ray hits a triange * @param vertex0 triangle vertex * @param vertex1 triangle vertex * @param vertex2 triangle vertex * @returns intersection information if hit */ intersectsTriangle(vertex0: DeepImmutable, vertex1: DeepImmutable, vertex2: DeepImmutable): Nullable; /** * Checks if ray intersects a plane * @param plane the plane to check * @returns the distance away it was hit */ intersectsPlane(plane: DeepImmutable): Nullable; /** * Checks if ray intersects a mesh * @param mesh the mesh to check * @param fastCheck if only the bounding box should checked * @returns picking info of the intersecton */ intersectsMesh(mesh: DeepImmutable, fastCheck?: boolean): PickingInfo; /** * Checks if ray intersects a mesh * @param meshes the meshes to check * @param fastCheck if only the bounding box should checked * @param results array to store result in * @returns Array of picking infos */ intersectsMeshes(meshes: Array>, fastCheck?: boolean, results?: Array): Array; private _comparePickingInfo; private static smallnum; private static rayl; /** * Intersection test between the ray and a given segment whithin a given tolerance (threshold) * @param sega the first point of the segment to test the intersection against * @param segb the second point of the segment to test the intersection against * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection */ intersectionSegment(sega: DeepImmutable, segb: DeepImmutable, threshold: number): number; /** * Update the ray from viewport position * @param x position * @param y y position * @param viewportWidth viewport width * @param viewportHeight viewport height * @param world world matrix * @param view view matrix * @param projection projection matrix * @returns this ray updated */ update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable, view: DeepImmutable, projection: DeepImmutable): Ray; /** * Creates a ray with origin and direction of 0,0,0 * @returns the new ray */ static Zero(): Ray; /** * Creates a new ray from screen space and viewport * @param x position * @param y y position * @param viewportWidth viewport width * @param viewportHeight viewport height * @param world world matrix * @param view view matrix * @param projection projection matrix * @returns new ray */ static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable, view: DeepImmutable, projection: DeepImmutable): Ray; /** * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be * transformed to the given world matrix. * @param origin The origin point * @param end The end point * @param world a matrix to transform the ray to. Default is the identity matrix. * @returns the new ray */ static CreateNewFromTo(origin: DeepImmutable, end: DeepImmutable, world?: DeepImmutable): Ray; /** * Transforms a ray by a matrix * @param ray ray to transform * @param matrix matrix to apply * @returns the resulting new ray */ static Transform(ray: DeepImmutable, matrix: DeepImmutable): Ray; /** * Transforms a ray by a matrix * @param ray ray to transform * @param matrix matrix to apply * @param result ray to store result in */ static TransformToRef(ray: DeepImmutable, matrix: DeepImmutable, result: Ray): void; /** * Unproject a ray from screen space to object space * @param sourceX defines the screen space x coordinate to use * @param sourceY defines the screen space y coordinate to use * @param viewportWidth defines the current width of the viewport * @param viewportHeight defines the current height of the viewport * @param world defines the world matrix to use (can be set to Identity to go to world space) * @param view defines the view matrix to use * @param projection defines the projection matrix to use */ unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable, view: DeepImmutable, projection: DeepImmutable): void; } /** * Type used to define predicate used to select faces when a mesh intersection is detected */ export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean; interface Scene { /** @hidden */ _tempPickingRay: Nullable; /** @hidden */ _cachedRayForTransform: Ray; /** @hidden */ _pickWithRayInverseMatrix: Matrix; /** @hidden */ _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable; /** @hidden */ _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable; } } declare module BABYLON { /** * Groups all the scene component constants in one place to ease maintenance. * @hidden */ export class SceneComponentConstants { static readonly NAME_EFFECTLAYER: string; static readonly NAME_LAYER: string; static readonly NAME_LENSFLARESYSTEM: string; static readonly NAME_BOUNDINGBOXRENDERER: string; static readonly NAME_PARTICLESYSTEM: string; static readonly NAME_GAMEPAD: string; static readonly NAME_SIMPLIFICATIONQUEUE: string; static readonly NAME_GEOMETRYBUFFERRENDERER: string; static readonly NAME_DEPTHRENDERER: string; static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string; static readonly NAME_SPRITE: string; static readonly NAME_OUTLINERENDERER: string; static readonly NAME_PROCEDURALTEXTURE: string; static readonly NAME_SHADOWGENERATOR: string; static readonly NAME_OCTREE: string; static readonly NAME_PHYSICSENGINE: string; static readonly NAME_AUDIO: string; static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number; static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number; static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number; static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number; static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number; static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number; static readonly STEP_BEFORECAMERADRAW_LAYER: number; static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number; static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number; static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number; static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number; static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number; static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number; static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number; static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number; static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number; static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number; static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number; static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number; static readonly STEP_AFTERCAMERADRAW_LAYER: number; static readonly STEP_AFTERRENDER_AUDIO: number; static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number; static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number; static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number; static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number; static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number; static readonly STEP_POINTERMOVE_SPRITE: number; static readonly STEP_POINTERDOWN_SPRITE: number; static readonly STEP_POINTERUP_SPRITE: number; } /** * This represents a scene component. * * This is used to decouple the dependency the scene is having on the different workloads like * layers, post processes... */ export interface ISceneComponent { /** * The name of the component. Each component must have a unique name. */ name: string; /** * The scene the component belongs to. */ scene: Scene; /** * Register the component to one instance of a scene. */ register(): void; /** * Rebuilds the elements related to this component in case of * context lost for instance. */ rebuild(): void; /** * Disposes the component and the associated ressources. */ dispose(): void; } /** * This represents a SERIALIZABLE scene component. * * This extends Scene Component to add Serialization methods on top. */ export interface ISceneSerializableComponent extends ISceneComponent { /** * Adds all the elements from the container to the scene * @param container the container holding the elements */ addFromContainer(container: AbstractScene): void; /** * Removes all the elements in the container from the scene * @param container contains the elements to remove * @param dispose if the removed element should be disposed (default: false) */ removeFromContainer(container: AbstractScene, dispose?: boolean): void; /** * Serializes the component data to the specified json object * @param serializationObject The object to serialize to */ serialize(serializationObject: any): void; } /** * Strong typing of a Mesh related stage step action */ export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean; /** * Strong typing of a Evaluate Sub Mesh related stage step action */ export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void; /** * Strong typing of a Active Mesh related stage step action */ export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void; /** * Strong typing of a Camera related stage step action */ export type CameraStageAction = (camera: Camera) => void; /** * Strong typing of a Camera Frame buffer related stage step action */ export type CameraStageFrameBufferAction = (camera: Camera) => boolean; /** * Strong typing of a Render Target related stage step action */ export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void; /** * Strong typing of a RenderingGroup related stage step action */ export type RenderingGroupStageAction = (renderingGroupId: number) => void; /** * Strong typing of a Mesh Render related stage step action */ export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void; /** * Strong typing of a simple stage step action */ export type SimpleStageAction = () => void; /** * Strong typing of a render target action. */ export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate) => void; /** * Strong typing of a pointer move action. */ export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable; /** * Strong typing of a pointer up/down action. */ export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable, evt: PointerEvent) => Nullable; /** * Repressentation of a stage in the scene (Basically a list of ordered steps) * @hidden */ export class Stage extends Array<{ index: number; component: ISceneComponent; action: T; }> { /** * Hide ctor from the rest of the world. * @param items The items to add. */ private constructor(); /** * Creates a new Stage. * @returns A new instance of a Stage */ static Create(): Stage; /** * Registers a step in an ordered way in the targeted stage. * @param index Defines the position to register the step in * @param component Defines the component attached to the step * @param action Defines the action to launch during the step */ registerStep(index: number, component: ISceneComponent, action: T): void; /** * Clears all the steps from the stage. */ clear(): void; } } declare module BABYLON { interface Scene { /** @hidden */ _pointerOverSprite: Nullable; /** @hidden */ _pickedDownSprite: Nullable; /** @hidden */ _tempSpritePickingRay: Nullable; /** * All of the sprite managers added to this scene * @see http://doc.babylonjs.com/babylon101/sprites */ spriteManagers: Array; /** * An event triggered when sprites rendering is about to start * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well) */ onBeforeSpritesRenderingObservable: Observable; /** * An event triggered when sprites rendering is done * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well) */ onAfterSpritesRenderingObservable: Observable; /** @hidden */ _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable; /** Launch a ray to try to pick a sprite in the scene * @param x position on screen * @param y position on screen * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used * @returns a PickingInfo */ pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable; /** Use the given ray to pick a sprite in the scene * @param ray The ray (in world space) to use to pick meshes * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used * @returns a PickingInfo */ pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable; /** * Force the sprite under the pointer * @param sprite defines the sprite to use */ setPointerOverSprite(sprite: Nullable): void; /** * Gets the sprite under the pointer * @returns a Sprite or null if no sprite is under the pointer */ getPointerOverSprite(): Nullable; } /** * Defines the sprite scene component responsible to manage sprites * in a given scene. */ export class SpriteSceneComponent implements ISceneComponent { /** * The component name helpfull to identify the component in the list of scene components. */ readonly name: string; /** * The scene the component belongs to. */ scene: Scene; /** @hidden */ private _spritePredicate; /** * Creates a new instance of the component for the given scene * @param scene Defines the scene to register the component in */ constructor(scene: Scene); /** * Registers the component in a given scene */ register(): void; /** * Rebuilds the elements related to this component in case of * context lost for instance. */ rebuild(): void; /** * Disposes the component and the associated ressources. */ dispose(): void; private _pickSpriteButKeepRay; private _pointerMove; private _pointerDown; private _pointerUp; } } declare module BABYLON { /** @hidden */ export var fogFragmentDeclaration: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var fogFragment: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var spritesPixelShader: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var fogVertexDeclaration: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var spritesVertexShader: { name: string; shader: string; }; } declare module BABYLON { /** * Defines the minimum interface to fullfil in order to be a sprite manager. */ export interface ISpriteManager extends IDisposable { /** * Restricts the camera to viewing objects with the same layerMask. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0 */ layerMask: number; /** * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true */ isPickable: boolean; /** * Specifies the rendering group id for this mesh (0 by default) * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups */ renderingGroupId: number; /** * Defines the list of sprites managed by the manager. */ sprites: Array; /** * Tests the intersection of a sprite with a specific ray. * @param ray The ray we are sending to test the collision * @param camera The camera space we are sending rays in * @param predicate A predicate allowing excluding sprites from the list of object to test * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise * @returns picking info or null. */ intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable; /** * Renders the list of sprites on screen. */ render(): void; } /** * Class used to manage multiple sprites on the same spritesheet * @see http://doc.babylonjs.com/babylon101/sprites */ export class SpriteManager implements ISpriteManager { /** defines the manager's name */ name: string; /** Gets the list of sprites */ sprites: Sprite[]; /** Gets or sets the rendering group id (0 by default) */ renderingGroupId: number; /** Gets or sets camera layer mask */ layerMask: number; /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */ fogEnabled: boolean; /** Gets or sets a boolean indicating if the sprites are pickable */ isPickable: boolean; /** Defines the default width of a cell in the spritesheet */ cellWidth: number; /** Defines the default height of a cell in the spritesheet */ cellHeight: number; /** * An event triggered when the manager is disposed. */ onDisposeObservable: Observable; private _onDisposeObserver; /** * Callback called when the manager is disposed */ onDispose: () => void; private _capacity; private _spriteTexture; private _epsilon; private _scene; private _vertexData; private _buffer; private _vertexBuffers; private _indexBuffer; private _effectBase; private _effectFog; /** * Gets or sets the spritesheet texture */ texture: Texture; /** * Creates a new sprite manager * @param name defines the manager's name * @param imgUrl defines the sprite sheet url * @param capacity defines the maximum allowed number of sprites * @param cellSize defines the size of a sprite cell * @param scene defines the hosting scene * @param epsilon defines the epsilon value to align texture (0.01 by default) * @param samplingMode defines the smapling mode to use with spritesheet */ constructor( /** defines the manager's name */ name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number); private _appendSpriteVertex; /** * Intersects the sprites with a ray * @param ray defines the ray to intersect with * @param camera defines the current active camera * @param predicate defines a predicate used to select candidate sprites * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer) * @returns null if no hit or a PickingInfo */ intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable; /** * Render all child sprites */ render(): void; /** * Release associated resources */ dispose(): void; } } declare module BABYLON { /** * Class used to represent a sprite * @see http://doc.babylonjs.com/babylon101/sprites */ export class Sprite { /** defines the name */ name: string; /** Gets or sets the current world position */ position: Vector3; /** Gets or sets the main color */ color: Color4; /** Gets or sets the width */ width: number; /** Gets or sets the height */ height: number; /** Gets or sets rotation angle */ angle: number; /** Gets or sets the cell index in the sprite sheet */ cellIndex: number; /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */ invertU: number; /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */ invertV: number; /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */ disposeWhenFinishedAnimating: boolean; /** Gets the list of attached animations */ animations: Animation[]; /** Gets or sets a boolean indicating if the sprite can be picked */ isPickable: boolean; /** * Gets or sets the associated action manager */ actionManager: Nullable; private _animationStarted; private _loopAnimation; private _fromIndex; private _toIndex; private _delay; private _direction; private _manager; private _time; private _onAnimationEnd; /** * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */ isVisible: boolean; /** * Gets or sets the sprite size */ size: number; /** * Creates a new Sprite * @param name defines the name * @param manager defines the manager */ constructor( /** defines the name */ name: string, manager: ISpriteManager); /** * Starts an animation * @param from defines the initial key * @param to defines the end key * @param loop defines if the animation must loop * @param delay defines the start delay (in ms) * @param onAnimationEnd defines a callback to call when animation ends */ playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void; /** Stops current animation (if any) */ stopAnimation(): void; /** @hidden */ _animate(deltaTime: number): void; /** Release associated resources */ dispose(): void; } } declare module BABYLON { /** * Information about the result of picking within a scene * @see https://doc.babylonjs.com/babylon101/picking_collisions */ export class PickingInfo { /** @hidden */ _pickingUnavailable: boolean; /** * If the pick collided with an object */ hit: boolean; /** * Distance away where the pick collided */ distance: number; /** * The location of pick collision */ pickedPoint: Nullable; /** * The mesh corresponding the the pick collision */ pickedMesh: Nullable; /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/ bu: number; /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/ bv: number; /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */ faceId: number; /** Id of the the submesh that was picked */ subMeshId: number; /** If a sprite was picked, this will be the sprite the pick collided with */ pickedSprite: Nullable; /** * If a mesh was used to do the picking (eg. 6dof controller) this will be populated. */ originMesh: Nullable; /** * The ray that was used to perform the picking. */ ray: Nullable; /** * Gets the normal correspodning to the face the pick collided with * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false) * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map * @returns The normal correspodning to the face the pick collided with */ getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable; /** * Gets the texture coordinates of where the pick occured * @returns the vector containing the coordnates of the texture */ getTextureCoordinates(): Nullable; } } declare module BABYLON { /** * Gather the list of pointer event types as constants. */ export class PointerEventTypes { /** * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer. */ static readonly POINTERDOWN: number; /** * The pointerup event is fired when a pointer is no longer active. */ static readonly POINTERUP: number; /** * The pointermove event is fired when a pointer changes coordinates. */ static readonly POINTERMOVE: number; /** * The pointerwheel event is fired when a mouse wheel has been rotated. */ static readonly POINTERWHEEL: number; /** * The pointerpick event is fired when a mesh or sprite has been picked by the pointer. */ static readonly POINTERPICK: number; /** * The pointertap event is fired when a the object has been touched and released without drag. */ static readonly POINTERTAP: number; /** * The pointerdoubletap event is fired when a the object has been touched and released twice without drag. */ static readonly POINTERDOUBLETAP: number; } /** * Base class of pointer info types. */ export class PointerInfoBase { /** * Defines the type of event (PointerEventTypes) */ type: number; /** * Defines the related dom event */ event: PointerEvent | MouseWheelEvent; /** * Instantiates the base class of pointers info. * @param type Defines the type of event (PointerEventTypes) * @param event Defines the related dom event */ constructor( /** * Defines the type of event (PointerEventTypes) */ type: number, /** * Defines the related dom event */ event: PointerEvent | MouseWheelEvent); } /** * This class is used to store pointer related info for the onPrePointerObservable event. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable */ export class PointerInfoPre extends PointerInfoBase { /** * Ray from a pointer if availible (eg. 6dof controller) */ ray: Nullable; /** * Defines the local position of the pointer on the canvas. */ localPosition: Vector2; /** * Defines whether the engine should skip the next OnPointerObservable associated to this pre. */ skipOnPointerObservable: boolean; /** * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event. * @param type Defines the type of event (PointerEventTypes) * @param event Defines the related dom event * @param localX Defines the local x coordinates of the pointer when the event occured * @param localY Defines the local y coordinates of the pointer when the event occured */ constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number); } /** * This type contains all the data related to a pointer event in Babylon.js. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class. */ export class PointerInfo extends PointerInfoBase { /** * Defines the picking info associated to the info (if any)\ */ pickInfo: Nullable; /** * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event. * @param type Defines the type of event (PointerEventTypes) * @param event Defines the related dom event * @param pickInfo Defines the picking info associated to the info (if any)\ */ constructor(type: number, event: PointerEvent | MouseWheelEvent, /** * Defines the picking info associated to the info (if any)\ */ pickInfo: Nullable); } /** * Data relating to a touch event on the screen. */ export interface PointerTouch { /** * X coordinate of touch. */ x: number; /** * Y coordinate of touch. */ y: number; /** * Id of touch. Unique for each finger. */ pointerId: number; /** * Event type passed from DOM. */ type: any; } } declare module BABYLON { /** * Manage the mouse inputs to control the movement of a free camera. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs */ export class FreeCameraMouseInput implements ICameraInput { /** * Define if touch is enabled in the mouse input */ touchEnabled: boolean; /** * Defines the camera the input is attached to. */ camera: FreeCamera; /** * Defines the buttons associated with the input to handle camera move. */ buttons: number[]; /** * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating. */ angularSensibility: number; private _pointerInput; private _onMouseMove; private _observer; private previousPosition; /** * Observable for when a pointer move event occurs containing the move offset */ onPointerMovedObservable: Observable<{ offsetX: number; offsetY: number; }>; /** * @hidden * If the camera should be rotated automatically based on pointer movement */ _allowCameraRotation: boolean; /** * Manage the mouse inputs to control the movement of a free camera. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs * @param touchEnabled Defines if touch is enabled or not */ constructor( /** * Define if touch is enabled in the mouse input */ touchEnabled?: boolean); /** * Attach the input controls to a specific dom element to get the input from. * @param element Defines the element the controls should be listened from * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault) */ attachControl(element: HTMLElement, noPreventDefault?: boolean): void; /** * Called on JS contextmenu event. * Override this method to provide functionality. */ protected onContextMenu(evt: PointerEvent): void; /** * Detach the current controls from the specified dom element. * @param element Defines the element to stop listening the inputs from */ detachControl(element: Nullable): void; /** * Gets the class name of the current intput. * @returns the class name */ getClassName(): string; /** * Get the friendly name associated with the input class. * @returns the input friendly name */ getSimpleName(): string; } } declare module BABYLON { /** * Manage the touch inputs to control the movement of a free camera. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs */ export class FreeCameraTouchInput implements ICameraInput { /** * Defines the camera the input is attached to. */ camera: FreeCamera; /** * Defines the touch sensibility for rotation. * The higher the faster. */ touchAngularSensibility: number; /** * Defines the touch sensibility for move. * The higher the faster. */ touchMoveSensibility: number; private _offsetX; private _offsetY; private _pointerPressed; private _pointerInput; private _observer; private _onLostFocus; /** * Attach the input controls to a specific dom element to get the input from. * @param element Defines the element the controls should be listened from * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault) */ attachControl(element: HTMLElement, noPreventDefault?: boolean): void; /** * Detach the current controls from the specified dom element. * @param element Defines the element to stop listening the inputs from */ detachControl(element: Nullable): void; /** * Update the current camera state depending on the inputs that have been used this frame. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop. */ checkInputs(): void; /** * Gets the class name of the current intput. * @returns the class name */ getClassName(): string; /** * Get the friendly name associated with the input class. * @returns the input friendly name */ getSimpleName(): string; } } declare module BABYLON { /** * Default Inputs manager for the FreeCamera. * It groups all the default supported inputs for ease of use. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs */ export class FreeCameraInputsManager extends CameraInputsManager { /** * @hidden */ _mouseInput: Nullable; /** * Instantiates a new FreeCameraInputsManager. * @param camera Defines the camera the inputs belong to */ constructor(camera: FreeCamera); /** * Add keyboard input support to the input manager. * @returns the current input manager */ addKeyboard(): FreeCameraInputsManager; /** * Add mouse input support to the input manager. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true) * @returns the current input manager */ addMouse(touchEnabled?: boolean): FreeCameraInputsManager; /** * Removes the mouse input support from the manager * @returns the current input manager */ removeMouse(): FreeCameraInputsManager; /** * Add touch input support to the input manager. * @returns the current input manager */ addTouch(): FreeCameraInputsManager; /** * Remove all attached input methods from a camera */ clear(): void; } } declare module BABYLON { /** * This represents a free type of camera. It can be useful in First Person Shooter game for instance. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad. * @see http://doc.babylonjs.com/features/cameras#universal-camera */ export class FreeCamera extends TargetCamera { /** * Define the collision ellipsoid of the camera. * This is helpful to simulate a camera body like the player body around the camera * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera */ ellipsoid: Vector3; /** * Define an offset for the position of the ellipsoid around the camera. * This can be helpful to determine the center of the body near the gravity center of the body * instead of its head. */ ellipsoidOffset: Vector3; /** * Enable or disable collisions of the camera with the rest of the scene objects. */ checkCollisions: boolean; /** * Enable or disable gravity on the camera. */ applyGravity: boolean; /** * Define the input manager associated to the camera. */ inputs: FreeCameraInputsManager; /** * Gets the input sensibility for a mouse input. (default is 2000.0) * Higher values reduce sensitivity. */ /** * Sets the input sensibility for a mouse input. (default is 2000.0) * Higher values reduce sensitivity. */ angularSensibility: number; /** * Gets or Set the list of keyboard keys used to control the forward move of the camera. */ keysUp: number[]; /** * Gets or Set the list of keyboard keys used to control the backward move of the camera. */ keysDown: number[]; /** * Gets or Set the list of keyboard keys used to control the left strafe move of the camera. */ keysLeft: number[]; /** * Gets or Set the list of keyboard keys used to control the right strafe move of the camera. */ keysRight: number[]; /** * Event raised when the camera collide with a mesh in the scene. */ onCollide: (collidedMesh: AbstractMesh) => void; private _collider; private _needMoveForGravity; private _oldPosition; private _diffPosition; private _newPosition; /** @hidden */ _localDirection: Vector3; /** @hidden */ _transformedDirection: Vector3; /** * Instantiates a Free Camera. * This represents a free type of camera. It can be useful in First Person Shooter game for instance. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera. * @see http://doc.babylonjs.com/features/cameras#universal-camera * @param name Define the name of the camera in the scene * @param position Define the start position of the camera in the scene * @param scene Define the scene the camera belongs to * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined */ constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean); /** * Attached controls to the current camera. * @param element Defines the element the controls should be listened from * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault) */ attachControl(element: HTMLElement, noPreventDefault?: boolean): void; /** * Detach the current controls from the camera. * The camera will stop reacting to inputs. * @param element Defines the element to stop listening the inputs from */ detachControl(element: HTMLElement): void; private _collisionMask; /** * Define a collision mask to limit the list of object the camera can collide with */ collisionMask: number; /** @hidden */ _collideWithWorld(displacement: Vector3): void; private _onCollisionPositionChange; /** @hidden */ _checkInputs(): void; /** @hidden */ _decideIfNeedsToMove(): boolean; /** @hidden */ _updatePosition(): void; /** * Destroy the camera and release the current resources hold by it. */ dispose(): void; /** * Gets the current object class name. * @return the class name */ getClassName(): string; } } declare module BABYLON { /** * Represents a gamepad control stick position */ export class StickValues { /** * The x component of the control stick */ x: number; /** * The y component of the control stick */ y: number; /** * Initializes the gamepad x and y control stick values * @param x The x component of the gamepad control stick value * @param y The y component of the gamepad control stick value */ constructor( /** * The x component of the control stick */ x: number, /** * The y component of the control stick */ y: number); } /** * An interface which manages callbacks for gamepad button changes */ export interface GamepadButtonChanges { /** * Called when a gamepad has been changed */ changed: boolean; /** * Called when a gamepad press event has been triggered */ pressChanged: boolean; /** * Called when a touch event has been triggered */ touchChanged: boolean; /** * Called when a value has changed */ valueChanged: boolean; } /** * Represents a gamepad */ export class Gamepad { /** * The id of the gamepad */ id: string; /** * The index of the gamepad */ index: number; /** * The browser gamepad */ browserGamepad: any; /** * Specifies what type of gamepad this represents */ type: number; private _leftStick; private _rightStick; /** @hidden */ _isConnected: boolean; private _leftStickAxisX; private _leftStickAxisY; private _rightStickAxisX; private _rightStickAxisY; /** * Triggered when the left control stick has been changed */ private _onleftstickchanged; /** * Triggered when the right control stick has been changed */ private _onrightstickchanged; /** * Represents a gamepad controller */ static GAMEPAD: number; /** * Represents a generic controller */ static GENERIC: number; /** * Represents an XBox controller */ static XBOX: number; /** * Represents a pose-enabled controller */ static POSE_ENABLED: number; /** * Specifies whether the left control stick should be Y-inverted */ protected _invertLeftStickY: boolean; /** * Specifies if the gamepad has been connected */ readonly isConnected: boolean; /** * Initializes the gamepad * @param id The id of the gamepad * @param index The index of the gamepad * @param browserGamepad The browser gamepad * @param leftStickX The x component of the left joystick * @param leftStickY The y component of the left joystick * @param rightStickX The x component of the right joystick * @param rightStickY The y component of the right joystick */ constructor( /** * The id of the gamepad */ id: string, /** * The index of the gamepad */ index: number, /** * The browser gamepad */ browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number); /** * Callback triggered when the left joystick has changed * @param callback */ onleftstickchanged(callback: (values: StickValues) => void): void; /** * Callback triggered when the right joystick has changed * @param callback */ onrightstickchanged(callback: (values: StickValues) => void): void; /** * Gets the left joystick */ /** * Sets the left joystick values */ leftStick: StickValues; /** * Gets the right joystick */ /** * Sets the right joystick value */ rightStick: StickValues; /** * Updates the gamepad joystick positions */ update(): void; /** * Disposes the gamepad */ dispose(): void; } /** * Represents a generic gamepad */ export class GenericPad extends Gamepad { private _buttons; private _onbuttondown; private _onbuttonup; /** * Observable triggered when a button has been pressed */ onButtonDownObservable: Observable; /** * Observable triggered when a button has been released */ onButtonUpObservable: Observable; /** * Callback triggered when a button has been pressed * @param callback Called when a button has been pressed */ onbuttondown(callback: (buttonPressed: number) => void): void; /** * Callback triggered when a button has been released * @param callback Called when a button has been released */ onbuttonup(callback: (buttonReleased: number) => void): void; /** * Initializes the generic gamepad * @param id The id of the generic gamepad * @param index The index of the generic gamepad * @param browserGamepad The browser gamepad */ constructor(id: string, index: number, browserGamepad: any); private _setButtonValue; /** * Updates the generic gamepad */ update(): void; /** * Disposes the generic gamepad */ dispose(): void; } } declare module BABYLON { /** * Defines the types of pose enabled controllers that are supported */ export enum PoseEnabledControllerType { /** * HTC Vive */ VIVE = 0, /** * Oculus Rift */ OCULUS = 1, /** * Windows mixed reality */ WINDOWS = 2, /** * Samsung gear VR */ GEAR_VR = 3, /** * Google Daydream */ DAYDREAM = 4, /** * Generic */ GENERIC = 5 } /** * Defines the MutableGamepadButton interface for the state of a gamepad button */ export interface MutableGamepadButton { /** * Value of the button/trigger */ value: number; /** * If the button/trigger is currently touched */ touched: boolean; /** * If the button/trigger is currently pressed */ pressed: boolean; } /** * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller * @hidden */ export interface ExtendedGamepadButton extends GamepadButton { /** * If the button/trigger is currently pressed */ readonly pressed: boolean; /** * If the button/trigger is currently touched */ readonly touched: boolean; /** * Value of the button/trigger */ readonly value: number; } /** @hidden */ export interface _GamePadFactory { /** * Returns wether or not the current gamepad can be created for this type of controller. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs. * @returns true if it can be created, otherwise false */ canCreate(gamepadInfo: any): boolean; /** * Creates a new instance of the Gamepad. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs. * @returns the new gamepad instance */ create(gamepadInfo: any): Gamepad; } /** * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller) */ export class PoseEnabledControllerHelper { /** @hidden */ static _ControllerFactories: _GamePadFactory[]; /** @hidden */ static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>; /** * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller) * @param vrGamepad the gamepad to initialized * @returns a vr controller of the type the gamepad identified as */ static InitiateController(vrGamepad: any): Gamepad; } /** * Defines the PoseEnabledController object that contains state of a vr capable controller */ export class PoseEnabledController extends Gamepad implements PoseControlled { private _deviceRoomPosition; private _deviceRoomRotationQuaternion; /** * The device position in babylon space */ devicePosition: Vector3; /** * The device rotation in babylon space */ deviceRotationQuaternion: Quaternion; /** * The scale factor of the device in babylon space */ deviceScaleFactor: number; /** * (Likely devicePosition should be used instead) The device position in its room space */ position: Vector3; /** * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space */ rotationQuaternion: Quaternion; /** * The type of controller (Eg. Windows mixed reality) */ controllerType: PoseEnabledControllerType; protected _calculatedPosition: Vector3; private _calculatedRotation; /** * The raw pose from the device */ rawPose: DevicePose; private _trackPosition; private _maxRotationDistFromHeadset; private _draggedRoomRotation; /** * @hidden */ _disableTrackPosition(fixedPosition: Vector3): void; /** * Internal, the mesh attached to the controller * @hidden */ _mesh: Nullable; private _poseControlledCamera; private _leftHandSystemQuaternion; /** * Internal, matrix used to convert room space to babylon space * @hidden */ _deviceToWorld: Matrix; /** * Node to be used when casting a ray from the controller * @hidden */ _pointingPoseNode: Nullable; /** * Name of the child mesh that can be used to cast a ray from the controller */ static readonly POINTING_POSE: string; /** * Creates a new PoseEnabledController from a gamepad * @param browserGamepad the gamepad that the PoseEnabledController should be created from */ constructor(browserGamepad: any); private _workingMatrix; /** * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller */ update(): void; /** * Updates only the pose device and mesh without doing any button event checking */ protected _updatePoseAndMesh(): void; /** * Updates the state of the pose enbaled controller based on the raw pose data from the device * @param poseData raw pose fromthe device */ updateFromDevice(poseData: DevicePose): void; /** * @hidden */ _meshAttachedObservable: Observable; /** * Attaches a mesh to the controller * @param mesh the mesh to be attached */ attachToMesh(mesh: AbstractMesh): void; /** * Attaches the controllers mesh to a camera * @param camera the camera the mesh should be attached to */ attachToPoseControlledCamera(camera: TargetCamera): void; /** * Disposes of the controller */ dispose(): void; /** * The mesh that is attached to the controller */ readonly mesh: Nullable; /** * Gets the ray of the controller in the direction the controller is pointing * @param length the length the resulting ray should be * @returns a ray in the direction the controller is pointing */ getForwardRay(length?: number): Ray; } } declare module BABYLON { /** * Defines the WebVRController object that represents controllers tracked in 3D space */ export abstract class WebVRController extends PoseEnabledController { /** * Internal, the default controller model for the controller */ protected _defaultModel: AbstractMesh; /** * Fired when the trigger state has changed */ onTriggerStateChangedObservable: Observable; /** * Fired when the main button state has changed */ onMainButtonStateChangedObservable: Observable; /** * Fired when the secondary button state has changed */ onSecondaryButtonStateChangedObservable: Observable; /** * Fired when the pad state has changed */ onPadStateChangedObservable: Observable; /** * Fired when controllers stick values have changed */ onPadValuesChangedObservable: Observable; /** * Array of button availible on the controller */ protected _buttons: Array; private _onButtonStateChange; /** * Fired when a controller button's state has changed * @param callback the callback containing the button that was modified */ onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void; /** * X and Y axis corrisponding to the controllers joystick */ pad: StickValues; /** * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum */ hand: string; /** * The default controller model for the controller */ readonly defaultModel: AbstractMesh; /** * Creates a new WebVRController from a gamepad * @param vrGamepad the gamepad that the WebVRController should be created from */ constructor(vrGamepad: any); /** * Updates the state of the controller and mesh based on the current position and rotation of the controller */ update(): void; /** * Function to be called when a button is modified */ protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void; /** * Loads a mesh and attaches it to the controller * @param scene the scene the mesh should be added to * @param meshLoaded callback for when the mesh has been loaded */ abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void; private _setButtonValue; private _changes; private _checkChanges; /** * Disposes of th webVRCOntroller */ dispose(): void; } } declare module BABYLON { /** * The HemisphericLight simulates the ambient environment light, * so the passed direction is the light reflection direction, not the incoming direction. */ export class HemisphericLight extends Light { /** * The groundColor is the light in the opposite direction to the one specified during creation. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction. */ groundColor: Color3; /** * The light reflection direction, not the incoming direction. */ direction: Vector3; /** * Creates a HemisphericLight object in the scene according to the passed direction (Vector3). * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction. * The HemisphericLight can't cast shadows. * Documentation : https://doc.babylonjs.com/babylon101/lights * @param name The friendly name of the light * @param direction The direction of the light reflection * @param scene The scene the light belongs to */ constructor(name: string, direction: Vector3, scene: Scene); protected _buildUniformLayout(): void; /** * Returns the string "HemisphericLight". * @return The class name */ getClassName(): string; /** * Sets the HemisphericLight direction towards the passed target (Vector3). * Returns the updated direction. * @param target The target the direction should point to * @return The computed direction */ setDirectionToTarget(target: Vector3): Vector3; /** * Returns the shadow generator associated to the light. * @returns Always null for hemispheric lights because it does not support shadows. */ getShadowGenerator(): Nullable; /** * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string). * @param effect The effect to update * @param lightIndex The index of the light in the effect to update * @returns The hemispheric light */ transferToEffect(effect: Effect, lightIndex: string): HemisphericLight; /** * Computes the world matrix of the node * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch * @param useWasUpdatedFlag defines a reserved property * @returns the world matrix */ computeWorldMatrix(): Matrix; /** * Returns the integer 3. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x */ getTypeID(): number; /** * Prepares the list of defines specific to the light type. * @param defines the list of defines * @param lightIndex defines the index of the light for the effect */ prepareLightSpecificDefines(defines: any, lightIndex: number): void; } } declare module BABYLON { /** @hidden */ export var vrMultiviewToSingleviewPixelShader: { name: string; shader: string; }; } declare module BABYLON { /** * Renders to multiple views with a single draw call * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/ */ export class MultiviewRenderTarget extends RenderTargetTexture { /** * Creates a multiview render target * @param scene scene used with the render target * @param size the size of the render target (used for each view) */ constructor(scene: Scene, size?: number | { width: number; height: number; } | { ratio: number; }); /** * @hidden * @param faceIndex the face index, if its a cube texture */ _bindFrameBuffer(faceIndex?: number): void; /** * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1) * @returns the view count */ getViewCount(): number; } } declare module BABYLON { interface Engine { /** * Creates a new multiview render target * @param width defines the width of the texture * @param height defines the height of the texture * @returns the created multiview texture */ createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture; /** * Binds a multiview framebuffer to be drawn to * @param multiviewTexture texture to bind */ bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void; } interface Camera { /** * @hidden * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there) */ _useMultiviewToSingleView: boolean; /** * @hidden * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there) */ _multiviewTexture: Nullable; /** * @hidden * ensures the multiview texture of the camera exists and has the specified width/height * @param width height to set on the multiview texture * @param height width to set on the multiview texture */ _resizeOrCreateMultiviewTexture(width: number, height: number): void; } interface Scene { /** @hidden */ _transformMatrixR: Matrix; /** @hidden */ _multiviewSceneUbo: Nullable; /** @hidden */ _createMultiviewUbo(): void; /** @hidden */ _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void; /** @hidden */ _renderMultiviewToSingleView(camera: Camera): void; } } declare module BABYLON { /** * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR * This will not be used for webXR as it supports displaying texture arrays directly */ export class VRMultiviewToSingleviewPostProcess extends PostProcess { /** * Initializes a VRMultiviewToSingleview * @param name name of the post process * @param camera camera to be applied to * @param scaleFactor scaling factor to the size of the output texture */ constructor(name: string, camera: Camera, scaleFactor: number); } } declare module BABYLON { interface Engine { /** @hidden */ _vrDisplay: any; /** @hidden */ _vrSupported: boolean; /** @hidden */ _oldSize: Size; /** @hidden */ _oldHardwareScaleFactor: number; /** @hidden */ _vrExclusivePointerMode: boolean; /** @hidden */ _webVRInitPromise: Promise; /** @hidden */ _onVRDisplayPointerRestricted: () => void; /** @hidden */ _onVRDisplayPointerUnrestricted: () => void; /** @hidden */ _onVrDisplayConnect: Nullable<(display: any) => void>; /** @hidden */ _onVrDisplayDisconnect: Nullable<() => void>; /** @hidden */ _onVrDisplayPresentChange: Nullable<() => void>; /** * Observable signaled when VR display mode changes */ onVRDisplayChangedObservable: Observable; /** * Observable signaled when VR request present is complete */ onVRRequestPresentComplete: Observable; /** * Observable signaled when VR request present starts */ onVRRequestPresentStart: Observable; /** * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input */ isInVRExclusivePointerMode: boolean; /** * Gets a boolean indicating if a webVR device was detected * @returns true if a webVR device was detected */ isVRDevicePresent(): boolean; /** * Gets the current webVR device * @returns the current webVR device (or null) */ getVRDevice(): any; /** * Initializes a webVR display and starts listening to display change events * The onVRDisplayChangedObservable will be notified upon these changes * @returns A promise containing a VRDisplay and if vr is supported */ initWebVRAsync(): Promise; /** @hidden */ _getVRDisplaysAsync(): Promise; /** * Call this function to switch to webVR mode * Will do nothing if webVR is not supported or if there is no webVR device * @see http://doc.babylonjs.com/how_to/webvr_camera */ enableVR(): void; /** @hidden */ _onVRFullScreenTriggered(): void; } } declare module BABYLON { /** * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose * IMPORTANT!! The data is right-hand data. * @export * @interface DevicePose */ export interface DevicePose { /** * The position of the device, values in array are [x,y,z]. */ readonly position: Nullable; /** * The linearVelocity of the device, values in array are [x,y,z]. */ readonly linearVelocity: Nullable; /** * The linearAcceleration of the device, values in array are [x,y,z]. */ readonly linearAcceleration: Nullable; /** * The orientation of the device in a quaternion array, values in array are [x,y,z,w]. */ readonly orientation: Nullable; /** * The angularVelocity of the device, values in array are [x,y,z]. */ readonly angularVelocity: Nullable; /** * The angularAcceleration of the device, values in array are [x,y,z]. */ readonly angularAcceleration: Nullable; } /** * Interface representing a pose controlled object in Babylon. * A pose controlled object has both regular pose values as well as pose values * from an external device such as a VR head mounted display */ export interface PoseControlled { /** * The position of the object in babylon space. */ position: Vector3; /** * The rotation quaternion of the object in babylon space. */ rotationQuaternion: Quaternion; /** * The position of the device in babylon space. */ devicePosition?: Vector3; /** * The rotation quaternion of the device in babylon space. */ deviceRotationQuaternion: Quaternion; /** * The raw pose coming from the device. */ rawPose: Nullable; /** * The scale of the device to be used when translating from device space to babylon space. */ deviceScaleFactor: number; /** * Updates the poseControlled values based on the input device pose. * @param poseData the pose data to update the object with */ updateFromDevice(poseData: DevicePose): void; } /** * Set of options to customize the webVRCamera */ export interface WebVROptions { /** * Sets if the webVR camera should be tracked to the vrDevice. (default: true) */ trackPosition?: boolean; /** * Sets the scale of the vrDevice in babylon space. (default: 1) */ positionScale?: number; /** * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay) */ displayName?: string; /** * Should the native controller meshes be initialized. (default: true) */ controllerMeshes?: boolean; /** * Creating a default HemiLight only on controllers. (default: true) */ defaultLightingOnControllers?: boolean; /** * If you don't want to use the default VR button of the helper. (default: false) */ useCustomVRButton?: boolean; /** * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button) */ customVRButton?: HTMLButtonElement; /** * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100) */ rayLength?: number; /** * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7) */ defaultHeight?: number; /** * If multiview should be used if availible (default: false) */ useMultiview?: boolean; } /** * This represents a WebVR camera. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift. * @example http://doc.babylonjs.com/how_to/webvr_camera */ export class WebVRFreeCamera extends FreeCamera implements PoseControlled { private webVROptions; /** * @hidden * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay */ _vrDevice: any; /** * The rawPose of the vrDevice. */ rawPose: Nullable; private _onVREnabled; private _specsVersion; private _attached; private _frameData; protected _descendants: Array; private _deviceRoomPosition; /** @hidden */ _deviceRoomRotationQuaternion: Quaternion; private _standingMatrix; /** * Represents device position in babylon space. */ devicePosition: Vector3; /** * Represents device rotation in babylon space. */ deviceRotationQuaternion: Quaternion; /** * The scale of the device to be used when translating from device space to babylon space. */ deviceScaleFactor: number; private _deviceToWorld; private _worldToDevice; /** * References to the webVR controllers for the vrDevice. */ controllers: Array; /** * Emits an event when a controller is attached. */ onControllersAttachedObservable: Observable; /** * Emits an event when a controller's mesh has been loaded; */ onControllerMeshLoadedObservable: Observable; /** * Emits an event when the HMD's pose has been updated. */ onPoseUpdatedFromDeviceObservable: Observable; private _poseSet; /** * If the rig cameras be used as parent instead of this camera. */ rigParenting: boolean; private _lightOnControllers; private _defaultHeight?; /** * Instantiates a WebVRFreeCamera. * @param name The name of the WebVRFreeCamera * @param position The starting anchor position for the camera * @param scene The scene the camera belongs to * @param webVROptions a set of customizable options for the webVRCamera */ constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions); /** * Gets the device distance from the ground in meters. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned. */ deviceDistanceToRoomGround(): number; /** * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported. */ useStandingMatrix(callback?: (bool: boolean) => void): void; /** * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground. * @returns A promise with a boolean set to if the standing matrix is supported. */ useStandingMatrixAsync(): Promise; /** * Disposes the camera */ dispose(): void; /** * Gets a vrController by name. * @param name The name of the controller to retreive * @returns the controller matching the name specified or null if not found */ getControllerByName(name: string): Nullable; private _leftController; /** * The controller corrisponding to the users left hand. */ readonly leftController: Nullable; private _rightController; /** * The controller corrisponding to the users right hand. */ readonly rightController: Nullable; /** * Casts a ray forward from the vrCamera's gaze. * @param length Length of the ray (default: 100) * @returns the ray corrisponding to the gaze */ getForwardRay(length?: number): Ray; /** * @hidden * Updates the camera based on device's frame data */ _checkInputs(): void; /** * Updates the poseControlled values based on the input device pose. * @param poseData Pose coming from the device */ updateFromDevice(poseData: DevicePose): void; private _htmlElementAttached; private _detachIfAttached; /** * WebVR's attach control will start broadcasting frames to the device. * Note that in certain browsers (chrome for example) this function must be called * within a user-interaction callback. Example: *
 scene.onPointerDown = function() { camera.attachControl(canvas); }
* * @param element html element to attach the vrDevice to * @param noPreventDefault prevent the default html element operation when attaching the vrDevice */ attachControl(element: HTMLElement, noPreventDefault?: boolean): void; /** * Detaches the camera from the html element and disables VR * * @param element html element to detach from */ detachControl(element: HTMLElement): void; /** * @returns the name of this class */ getClassName(): string; /** * Calls resetPose on the vrDisplay * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose */ resetToCurrentRotation(): void; /** * @hidden * Updates the rig cameras (left and right eye) */ _updateRigCameras(): void; private _workingVector; private _oneVector; private _workingMatrix; private updateCacheCalled; private _correctPositionIfNotTrackPosition; /** * @hidden * Updates the cached values of the camera * @param ignoreParentClass ignores updating the parent class's cache (default: false) */ _updateCache(ignoreParentClass?: boolean): void; /** * @hidden * Get current device position in babylon world */ _computeDevicePosition(): void; /** * Updates the current device position and rotation in the babylon world */ update(): void; /** * @hidden * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix) * @returns an identity matrix */ _getViewMatrix(): Matrix; private _tmpMatrix; /** * This function is called by the two RIG cameras. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance) * @hidden */ _getWebVRViewMatrix(): Matrix; /** @hidden */ _getWebVRProjectionMatrix(): Matrix; private _onGamepadConnectedObserver; private _onGamepadDisconnectedObserver; private _updateCacheWhenTrackingDisabledObserver; /** * Initializes the controllers and their meshes */ initControllers(): void; } } declare module BABYLON { /** * Size options for a post process */ export type PostProcessOptions = { width: number; height: number; }; /** * PostProcess can be used to apply a shader to a texture after it has been rendered * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses */ export class PostProcess { /** Name of the PostProcess. */ name: string; /** * Gets or sets the unique id of the post process */ uniqueId: number; /** * Width of the texture to apply the post process on */ width: number; /** * Height of the texture to apply the post process on */ height: number; /** * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain) * @hidden */ _outputTexture: Nullable; /** * Sampling mode used by the shader * See https://doc.babylonjs.com/classes/3.1/texture */ renderTargetSamplingMode: number; /** * Clear color to use when screen clearing */ clearColor: Color4; /** * If the buffer needs to be cleared before applying the post process. (default: true) * Should be set to false if shader will overwrite all previous pixels. */ autoClear: boolean; /** * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE) */ alphaMode: number; /** * Sets the setAlphaBlendConstants of the babylon engine */ alphaConstants: Color4; /** * Animations to be used for the post processing */ animations: Animation[]; /** * Enable Pixel Perfect mode where texture is not scaled to be power of 2. * Can only be used on a single postprocess or on the last one of a chain. (default: false) */ enablePixelPerfectMode: boolean; /** * Force the postprocess to be applied without taking in account viewport */ forceFullscreenViewport: boolean; /** * List of inspectable custom properties (used by the Inspector) * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility */ inspectableCustomProperties: IInspectable[]; /** * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR) * * | Value | Type | Description | * | ----- | ----------------------------------- | ----------- | * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) | * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) | * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) | * */ scaleMode: number; /** * Force textures to be a power of two (default: false) */ alwaysForcePOT: boolean; private _samples; /** * Number of sample textures (default: 1) */ samples: number; /** * Modify the scale of the post process to be the same as the viewport (default: false) */ adaptScaleToCurrentViewport: boolean; private _camera; private _scene; private _engine; private _options; private _reusable; private _textureType; /** * Smart array of input and output textures for the post process. * @hidden */ _textures: SmartArray; /** * The index in _textures that corresponds to the output texture. * @hidden */ _currentRenderTextureInd: number; private _effect; private _samplers; private _fragmentUrl; private _vertexUrl; private _parameters; private _scaleRatio; protected _indexParameters: any; private _shareOutputWithPostProcess; private _texelSize; private _forcedOutputTexture; /** * Returns the fragment url or shader name used in the post process. * @returns the fragment url or name in the shader store. */ getEffectName(): string; /** * An event triggered when the postprocess is activated. */ onActivateObservable: Observable; private _onActivateObserver; /** * A function that is added to the onActivateObservable */ onActivate: Nullable<(camera: Camera) => void>; /** * An event triggered when the postprocess changes its size. */ onSizeChangedObservable: Observable; private _onSizeChangedObserver; /** * A function that is added to the onSizeChangedObservable */ onSizeChanged: (postProcess: PostProcess) => void; /** * An event triggered when the postprocess applies its effect. */ onApplyObservable: Observable; private _onApplyObserver; /** * A function that is added to the onApplyObservable */ onApply: (effect: Effect) => void; /** * An event triggered before rendering the postprocess */ onBeforeRenderObservable: Observable; private _onBeforeRenderObserver; /** * A function that is added to the onBeforeRenderObservable */ onBeforeRender: (effect: Effect) => void; /** * An event triggered after rendering the postprocess */ onAfterRenderObservable: Observable; private _onAfterRenderObserver; /** * A function that is added to the onAfterRenderObservable */ onAfterRender: (efect: Effect) => void; /** * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process. */ inputTexture: InternalTexture; /** * Gets the camera which post process is applied to. * @returns The camera the post process is applied to. */ getCamera(): Camera; /** * Gets the texel size of the postprocess. * See https://en.wikipedia.org/wiki/Texel_(graphics) */ readonly texelSize: Vector2; /** * Creates a new instance PostProcess * @param name The name of the PostProcess. * @param fragmentUrl The url of the fragment shader to be used. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size) * @param camera The camera to apply the render pass to. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0) * @param engine The engine which the post process will be applied. (default: current engine) * @param reusable If the post process can be reused on the same frame. (default: false) * @param defines String of defines that will be set when running the fragment shader. (default: null) * @param textureType Type of textures used when performing the post process. (default: 0) * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess") * @param indexParameters The index parameters to be used for babylons include syntax "#include[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx * @param blockCompilation If the shader should not be compiled imediatly. (default: false) */ constructor( /** Name of the PostProcess. */ name: string, fragmentUrl: string, parameters: Nullable, samplers: Nullable, options: number | PostProcessOptions, camera: Nullable, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean); /** * Gets a string idenfifying the name of the class * @returns "PostProcess" string */ getClassName(): string; /** * Gets the engine which this post process belongs to. * @returns The engine the post process was enabled with. */ getEngine(): Engine; /** * The effect that is created when initializing the post process. * @returns The created effect corrisponding the the postprocess. */ getEffect(): Effect; /** * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another. * @param postProcess The post process to share the output with. * @returns This post process. */ shareOutputWith(postProcess: PostProcess): PostProcess; /** * Reverses the effect of calling shareOutputWith and returns the post process back to its original state. * This should be called if the post process that shares output with this post process is disabled/disposed. */ useOwnOutput(): void; /** * Updates the effect with the current post process compile time values and recompiles the shader. * @param defines Define statements that should be added at the beginning of the shader. (default: null) * @param uniforms Set of uniform variables that will be passed to the shader. (default: null) * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null) * @param indexParameters The index parameters to be used for babylons include syntax "#include[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx * @param onCompiled Called when the shader has been compiled. * @param onError Called if there is an error when compiling a shader. */ updateEffect(defines?: Nullable, uniforms?: Nullable, samplers?: Nullable, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void; /** * The post process is reusable if it can be used multiple times within one frame. * @returns If the post process is reusable */ isReusable(): boolean; /** invalidate frameBuffer to hint the postprocess to create a depth buffer */ markTextureDirty(): void; /** * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null) * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false) * @returns The target texture that was bound to be written to. */ activate(camera: Nullable, sourceTexture?: Nullable, forceDepthStencil?: boolean): InternalTexture; /** * If the post process is supported. */ readonly isSupported: boolean; /** * The aspect ratio of the output texture. */ readonly aspectRatio: number; /** * Get a value indicating if the post-process is ready to be used * @returns true if the post-process is ready (shader is compiled) */ isReady(): boolean; /** * Binds all textures and uniforms to the shader, this will be run on every pass. * @returns the effect corrisponding to this post process. Null if not compiled or not ready. */ apply(): Nullable; private _disposeTextures; /** * Disposes the post process. * @param camera The camera to dispose the post process on. */ dispose(camera?: Camera): void; } } declare module BABYLON { /** * PostProcessManager is used to manage one or more post processes or post process pipelines * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses */ export class PostProcessManager { private _scene; private _indexBuffer; private _vertexBuffers; /** * Creates a new instance PostProcess * @param scene The scene that the post process is associated with. */ constructor(scene: Scene); private _prepareBuffers; private _buildIndexBuffer; /** * Rebuilds the vertex buffers of the manager. * @hidden */ _rebuild(): void; /** * Prepares a frame to be run through a post process. * @param sourceTexture The input texture to the post procesess. (default: null) * @param postProcesses An array of post processes to be run. (default: null) * @returns True if the post processes were able to be run. * @hidden */ _prepareFrame(sourceTexture?: Nullable, postProcesses?: Nullable): boolean; /** * Manually render a set of post processes to a texture. * @param postProcesses An array of post processes to be run. * @param targetTexture The target texture to render to. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight * @param faceIndex defines the face to render to if a cubemap is defined as the target * @param lodLevel defines which lod of the texture to render to */ directRender(postProcesses: PostProcess[], targetTexture?: Nullable, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void; /** * Finalize the result of the output of the postprocesses. * @param doNotPresent If true the result will not be displayed to the screen. * @param targetTexture The target texture to render to. * @param faceIndex The index of the face to bind the target texture to. * @param postProcesses The array of post processes to render. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false) * @hidden */ _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array, forceFullscreenViewport?: boolean): void; /** * Disposes of the post process manager. */ dispose(): void; } } declare module BABYLON { interface AbstractScene { /** * The list of procedural textures added to the scene * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures */ proceduralTextures: Array; } /** * Defines the Procedural Texture scene component responsible to manage any Procedural Texture * in a given scene. */ export class ProceduralTextureSceneComponent implements ISceneComponent { /** * The component name helpfull to identify the component in the list of scene components. */ readonly name: string; /** * The scene the component belongs to. */ scene: Scene; /** * Creates a new instance of the component for the given scene * @param scene Defines the scene to register the component in */ constructor(scene: Scene); /** * Registers the component in a given scene */ register(): void; /** * Rebuilds the elements related to this component in case of * context lost for instance. */ rebuild(): void; /** * Disposes the component and the associated ressources. */ dispose(): void; private _beforeClear; } } declare module BABYLON { interface Engine { /** * Creates a new render target cube texture * @param size defines the size of the texture * @param options defines the options used to create the texture * @returns a new render target cube texture stored in an InternalTexture */ createRenderTargetCubeTexture(size: number, options?: Partial): InternalTexture; } } declare module BABYLON { /** @hidden */ export var proceduralVertexShader: { name: string; shader: string; }; } declare module BABYLON { /** * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images. * This is the base class of any Procedural texture and contains most of the shareable code. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures */ export class ProceduralTexture extends Texture { isCube: boolean; /** * Define if the texture is enabled or not (disabled texture will not render) */ isEnabled: boolean; /** * Define if the texture must be cleared before rendering (default is true) */ autoClear: boolean; /** * Callback called when the texture is generated */ onGenerated: () => void; /** * Event raised when the texture is generated */ onGeneratedObservable: Observable; /** @hidden */ _generateMipMaps: boolean; /** @hidden **/ _effect: Effect; /** @hidden */ _textures: { [key: string]: Texture; }; private _size; private _currentRefreshId; private _refreshRate; private _vertexBuffers; private _indexBuffer; private _uniforms; private _samplers; private _fragment; private _floats; private _ints; private _floatsArrays; private _colors3; private _colors4; private _vectors2; private _vectors3; private _matrices; private _fallbackTexture; private _fallbackTextureUsed; private _engine; private _cachedDefines; private _contentUpdateId; private _contentData; /** * Instantiates a new procedural texture. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images. * This is the base class of any Procedural texture and contains most of the shareable code. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures * @param name Define the name of the texture * @param size Define the size of the texture to create * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later * @param scene Define the scene the texture belongs to * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture * @param generateMipMaps Define if the texture should creates mip maps or not * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube) */ constructor(name: string, size: any, fragment: any, scene: Nullable, fallbackTexture?: Nullable, generateMipMaps?: boolean, isCube?: boolean); /** * The effect that is created when initializing the post process. * @returns The created effect corrisponding the the postprocess. */ getEffect(): Effect; /** * Gets texture content (Use this function wisely as reading from a texture can be slow) * @returns an ArrayBufferView (Uint8Array or Float32Array) */ getContent(): Nullable; private _createIndexBuffer; /** @hidden */ _rebuild(): void; /** * Resets the texture in order to recreate its associated resources. * This can be called in case of context loss */ reset(): void; protected _getDefines(): string; /** * Is the texture ready to be used ? (rendered at least once) * @returns true if ready, otherwise, false. */ isReady(): boolean; /** * Resets the refresh counter of the texture and start bak from scratch. * Could be useful to regenerate the texture if it is setup to render only once. */ resetRefreshCounter(): void; /** * Set the fragment shader to use in order to render the texture. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property. */ setFragment(fragment: any): void; /** * Define the refresh rate of the texture or the rendering frequency. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on... */ refreshRate: number; /** @hidden */ _shouldRender(): boolean; /** * Get the size the texture is rendering at. * @returns the size (texture is always squared) */ getRenderSize(): number; /** * Resize the texture to new value. * @param size Define the new size the texture should have * @param generateMipMaps Define whether the new texture should create mip maps */ resize(size: number, generateMipMaps: boolean): void; private _checkUniform; /** * Set a texture in the shader program used to render. * @param name Define the name of the uniform samplers as defined in the shader * @param texture Define the texture to bind to this sampler * @return the texture itself allowing "fluent" like uniform updates */ setTexture(name: string, texture: Texture): ProceduralTexture; /** * Set a float in the shader. * @param name Define the name of the uniform as defined in the shader * @param value Define the value to give to the uniform * @return the texture itself allowing "fluent" like uniform updates */ setFloat(name: string, value: number): ProceduralTexture; /** * Set a int in the shader. * @param name Define the name of the uniform as defined in the shader * @param value Define the value to give to the uniform * @return the texture itself allowing "fluent" like uniform updates */ setInt(name: string, value: number): ProceduralTexture; /** * Set an array of floats in the shader. * @param name Define the name of the uniform as defined in the shader * @param value Define the value to give to the uniform * @return the texture itself allowing "fluent" like uniform updates */ setFloats(name: string, value: number[]): ProceduralTexture; /** * Set a vec3 in the shader from a Color3. * @param name Define the name of the uniform as defined in the shader * @param value Define the value to give to the uniform * @return the texture itself allowing "fluent" like uniform updates */ setColor3(name: string, value: Color3): ProceduralTexture; /** * Set a vec4 in the shader from a Color4. * @param name Define the name of the uniform as defined in the shader * @param value Define the value to give to the uniform * @return the texture itself allowing "fluent" like uniform updates */ setColor4(name: string, value: Color4): ProceduralTexture; /** * Set a vec2 in the shader from a Vector2. * @param name Define the name of the uniform as defined in the shader * @param value Define the value to give to the uniform * @return the texture itself allowing "fluent" like uniform updates */ setVector2(name: string, value: Vector2): ProceduralTexture; /** * Set a vec3 in the shader from a Vector3. * @param name Define the name of the uniform as defined in the shader * @param value Define the value to give to the uniform * @return the texture itself allowing "fluent" like uniform updates */ setVector3(name: string, value: Vector3): ProceduralTexture; /** * Set a mat4 in the shader from a MAtrix. * @param name Define the name of the uniform as defined in the shader * @param value Define the value to give to the uniform * @return the texture itself allowing "fluent" like uniform updates */ setMatrix(name: string, value: Matrix): ProceduralTexture; /** * Render the texture to its associated render target. * @param useCameraPostProcess Define if camera post process should be applied to the texture */ render(useCameraPostProcess?: boolean): void; /** * Clone the texture. * @returns the cloned texture */ clone(): ProceduralTexture; /** * Dispose the texture and release its asoociated resources. */ dispose(): void; } } declare module BABYLON { /** * This represents the base class for particle system in Babylon. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function. * @example https://doc.babylonjs.com/babylon101/particles */ export class BaseParticleSystem { /** * Source color is added to the destination color without alpha affecting the result */ static BLENDMODE_ONEONE: number; /** * Blend current color and particle color using particle’s alpha */ static BLENDMODE_STANDARD: number; /** * Add current color and particle color multiplied by particle’s alpha */ static BLENDMODE_ADD: number; /** * Multiply current color with particle color */ static BLENDMODE_MULTIPLY: number; /** * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha */ static BLENDMODE_MULTIPLYADD: number; /** * List of animations used by the particle system. */ animations: Animation[]; /** * The id of the Particle system. */ id: string; /** * The friendly name of the Particle system. */ name: string; /** * The rendering group used by the Particle system to chose when to render. */ renderingGroupId: number; /** * The emitter represents the Mesh or position we are attaching the particle system to. */ emitter: Nullable; /** * The maximum number of particles to emit per frame */ emitRate: number; /** * If you want to launch only a few particles at once, that can be done, as well. */ manualEmitCount: number; /** * The overall motion speed (0.01 is default update speed, faster updates = faster animation) */ updateSpeed: number; /** * The amount of time the particle system is running (depends of the overall update speed). */ targetStopDuration: number; /** * Specifies whether the particle system will be disposed once it reaches the end of the animation. */ disposeOnStop: boolean; /** * Minimum power of emitting particles. */ minEmitPower: number; /** * Maximum power of emitting particles. */ maxEmitPower: number; /** * Minimum life time of emitting particles. */ minLifeTime: number; /** * Maximum life time of emitting particles. */ maxLifeTime: number; /** * Minimum Size of emitting particles. */ minSize: number; /** * Maximum Size of emitting particles. */ maxSize: number; /** * Minimum scale of emitting particles on X axis. */ minScaleX: number; /** * Maximum scale of emitting particles on X axis. */ maxScaleX: number; /** * Minimum scale of emitting particles on Y axis. */ minScaleY: number; /** * Maximum scale of emitting particles on Y axis. */ maxScaleY: number; /** * Gets or sets the minimal initial rotation in radians. */ minInitialRotation: number; /** * Gets or sets the maximal initial rotation in radians. */ maxInitialRotation: number; /** * Minimum angular speed of emitting particles (Z-axis rotation for each particle). */ minAngularSpeed: number; /** * Maximum angular speed of emitting particles (Z-axis rotation for each particle). */ maxAngularSpeed: number; /** * The texture used to render each particle. (this can be a spritesheet) */ particleTexture: Nullable; /** * The layer mask we are rendering the particles through. */ layerMask: number; /** * This can help using your own shader to render the particle system. * The according effect will be created */ customShader: any; /** * By default particle system starts as soon as they are created. This prevents the * automatic start to happen and let you decide when to start emitting particles. */ preventAutoStart: boolean; private _noiseTexture; /** * Gets or sets a texture used to add random noise to particle positions */ noiseTexture: Nullable; /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */ noiseStrength: Vector3; /** * Callback triggered when the particle animation is ending. */ onAnimationEnd: Nullable<() => void>; /** * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD. */ blendMode: number; /** * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls * to override the particles. */ forceDepthWrite: boolean; /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */ preWarmCycles: number; /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */ preWarmStepOffset: number; /** * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime) */ spriteCellChangeSpeed: number; /** * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display */ startSpriteCellID: number; /** * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display */ endSpriteCellID: number; /** * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use */ spriteCellWidth: number; /** * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use */ spriteCellHeight: number; /** * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID */ spriteRandomStartCell: boolean; /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */ translationPivot: Vector2; /** @hidden */ protected _isAnimationSheetEnabled: boolean; /** * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called */ beginAnimationOnStart: boolean; /** * Gets or sets the frame to start the animation from when beginAnimationOnStart is true */ beginAnimationFrom: number; /** * Gets or sets the frame to end the animation on when beginAnimationOnStart is true */ beginAnimationTo: number; /** * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true */ beginAnimationLoop: boolean; /** * Gets or sets a world offset applied to all particles */ worldOffset: Vector3; /** * Gets or sets whether an animation sprite sheet is enabled or not on the particle system */ isAnimationSheetEnabled: boolean; /** * Get hosting scene * @returns the scene */ getScene(): Scene; /** * You can use gravity if you want to give an orientation to your particles. */ gravity: Vector3; protected _colorGradients: Nullable>; protected _sizeGradients: Nullable>; protected _lifeTimeGradients: Nullable>; protected _angularSpeedGradients: Nullable>; protected _velocityGradients: Nullable>; protected _limitVelocityGradients: Nullable>; protected _dragGradients: Nullable>; protected _emitRateGradients: Nullable>; protected _startSizeGradients: Nullable>; protected _rampGradients: Nullable>; protected _colorRemapGradients: Nullable>; protected _alphaRemapGradients: Nullable>; protected _hasTargetStopDurationDependantGradient(): boolean | null; /** * Defines the delay in milliseconds before starting the system (0 by default) */ startDelay: number; /** * Gets the current list of drag gradients. * You must use addDragGradient and removeDragGradient to udpate this list * @returns the list of drag gradients */ getDragGradients(): Nullable>; /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */ limitVelocityDamping: number; /** * Gets the current list of limit velocity gradients. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list * @returns the list of limit velocity gradients */ getLimitVelocityGradients(): Nullable>; /** * Gets the current list of color gradients. * You must use addColorGradient and removeColorGradient to udpate this list * @returns the list of color gradients */ getColorGradients(): Nullable>; /** * Gets the current list of size gradients. * You must use addSizeGradient and removeSizeGradient to udpate this list * @returns the list of size gradients */ getSizeGradients(): Nullable>; /** * Gets the current list of color remap gradients. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list * @returns the list of color remap gradients */ getColorRemapGradients(): Nullable>; /** * Gets the current list of alpha remap gradients. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list * @returns the list of alpha remap gradients */ getAlphaRemapGradients(): Nullable>; /** * Gets the current list of life time gradients. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list * @returns the list of life time gradients */ getLifeTimeGradients(): Nullable>; /** * Gets the current list of angular speed gradients. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list * @returns the list of angular speed gradients */ getAngularSpeedGradients(): Nullable>; /** * Gets the current list of velocity gradients. * You must use addVelocityGradient and removeVelocityGradient to udpate this list * @returns the list of velocity gradients */ getVelocityGradients(): Nullable>; /** * Gets the current list of start size gradients. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list * @returns the list of start size gradients */ getStartSizeGradients(): Nullable>; /** * Gets the current list of emit rate gradients. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list * @returns the list of emit rate gradients */ getEmitRateGradients(): Nullable>; /** * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors. * This only works when particleEmitterTyps is a BoxParticleEmitter */ direction1: Vector3; /** * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors. * This only works when particleEmitterTyps is a BoxParticleEmitter */ direction2: Vector3; /** * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so. * This only works when particleEmitterTyps is a BoxParticleEmitter */ minEmitBox: Vector3; /** * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so. * This only works when particleEmitterTyps is a BoxParticleEmitter */ maxEmitBox: Vector3; /** * Random color of each particle after it has been emitted, between color1 and color2 vectors */ color1: Color4; /** * Random color of each particle after it has been emitted, between color1 and color2 vectors */ color2: Color4; /** * Color the particle will have at the end of its lifetime */ colorDead: Color4; /** * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel */ textureMask: Color4; /** * The particle emitter type defines the emitter used by the particle system. * It can be for example box, sphere, or cone... */ particleEmitterType: IParticleEmitterType; /** @hidden */ _isSubEmitter: boolean; /** * Gets or sets the billboard mode to use when isBillboardBased = true. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED */ billboardMode: number; protected _isBillboardBased: boolean; /** * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction */ isBillboardBased: boolean; /** * The scene the particle system belongs to. */ protected _scene: Scene; /** * Local cache of defines for image processing. */ protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines; /** * Default configuration related to image processing available in the standard Material. */ protected _imageProcessingConfiguration: ImageProcessingConfiguration; /** * Gets the image processing configuration used either in this material. */ /** * Sets the Default image processing configuration used either in the this material. * * If sets to null, the scene one is in use. */ imageProcessingConfiguration: ImageProcessingConfiguration; /** * Attaches a new image processing configuration to the Standard Material. * @param configuration */ protected _attachImageProcessingConfiguration(configuration: Nullable): void; /** @hidden */ protected _reset(): void; /** @hidden */ protected _removeGradientAndTexture(gradient: number, gradients: Nullable, texture: Nullable): BaseParticleSystem; /** * Instantiates a particle system. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust. * @param name The name of the particle system */ constructor(name: string); /** * Creates a Point Emitter for the particle system (emits directly from the emitter position) * @param direction1 Particles are emitted between the direction1 and direction2 from within the box * @param direction2 Particles are emitted between the direction1 and direction2 from within the box * @returns the emitter */ createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter; /** * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius) * @param radius The radius of the hemisphere to emit from * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius * @returns the emitter */ createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter; /** * Creates a Sphere Emitter for the particle system (emits along the sphere radius) * @param radius The radius of the sphere to emit from * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius * @returns the emitter */ createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter; /** * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2) * @param radius The radius of the sphere to emit from * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere * @returns the emitter */ createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter; /** * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position) * @param radius The radius of the emission cylinder * @param height The height of the emission cylinder * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius * @param directionRandomizer How much to randomize the particle direction [0-1] * @returns the emitter */ createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter; /** * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2) * @param radius The radius of the cylinder to emit from * @param height The height of the emission cylinder * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default) * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder * @returns the emitter */ createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter; /** * Creates a Cone Emitter for the particle system (emits from the cone to the particle position) * @param radius The radius of the cone to emit from * @param angle The base angle of the cone * @returns the emitter */ createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter; /** * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox) * @param direction1 Particles are emitted between the direction1 and direction2 from within the box * @param direction2 Particles are emitted between the direction1 and direction2 from within the box * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox * @returns the emitter */ createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter; } } declare module BABYLON { /** * Type of sub emitter */ export enum SubEmitterType { /** * Attached to the particle over it's lifetime */ ATTACHED = 0, /** * Created when the particle dies */ END = 1 } /** * Sub emitter class used to emit particles from an existing particle */ export class SubEmitter { /** * the particle system to be used by the sub emitter */ particleSystem: ParticleSystem; /** * Type of the submitter (Default: END) */ type: SubEmitterType; /** * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false) * Note: This only is supported when using an emitter of type Mesh */ inheritDirection: boolean; /** * How much of the attached particles speed should be added to the sub emitted particle (default: 0) */ inheritedVelocityAmount: number; /** * Creates a sub emitter * @param particleSystem the particle system to be used by the sub emitter */ constructor( /** * the particle system to be used by the sub emitter */ particleSystem: ParticleSystem); /** * Clones the sub emitter * @returns the cloned sub emitter */ clone(): SubEmitter; /** * Serialize current object to a JSON object * @returns the serialized object */ serialize(): any; /** @hidden */ static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem; /** * Creates a new SubEmitter from a serialized JSON version * @param serializationObject defines the JSON object to read from * @param scene defines the hosting scene * @param rootUrl defines the rootUrl for data loading * @returns a new SubEmitter */ static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter; /** Release associated resources */ dispose(): void; } } declare module BABYLON { /** @hidden */ export var clipPlaneFragmentDeclaration: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var imageProcessingDeclaration: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var imageProcessingFunctions: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var clipPlaneFragment: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var particlesPixelShader: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var clipPlaneVertexDeclaration: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var clipPlaneVertex: { name: string; shader: string; }; } declare module BABYLON { /** @hidden */ export var particlesVertexShader: { name: string; shader: string; }; } declare module BABYLON { /** * This represents a particle system in Babylon. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function. * @example https://doc.babylonjs.com/babylon101/particles */ export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem { /** * Billboard mode will only apply to Y axis */ static readonly BILLBOARDMODE_Y: number; /** * Billboard mode will apply to all axes */ static readonly BILLBOARDMODE_ALL: number; /** * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction */ static readonly BILLBOARDMODE_STRETCHED: number; /** * This function can be defined to provide custom update for active particles. * This function will be called instead of regular update (age, position, color, etc.). * Do not forget that this function will be called on every frame so try to keep it simple and fast :) */ updateFunction: (particles: Particle[]) => void; private _emitterWorldMatrix; /** * This function can be defined to specify initial direction for every new particle. * It by default use the emitterType defined function */ startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void; /** * This function can be defined to specify initial position for every new particle. * It by default use the emitterType defined function */ startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void; /** * @hidden */ _inheritedVelocityOffset: Vector3; /** * An event triggered when the system is disposed */ onDisposeObservable: Observable; private _onDisposeObserver; /** * Sets a callback that will be triggered when the system is disposed */ onDispose: () => void; private _particles; private _epsilon; private _capacity; private _stockParticles; private _newPartsExcess; private _vertexData; private _vertexBuffer; private _vertexBuffers; private _spriteBuffer; private _indexBuffer; private _effect; private _customEffect; private _cachedDefines; private _scaledColorStep; private _colorDiff; private _scaledDirection; private _scaledGravity; private _currentRenderId; private _alive; private _useInstancing; private _started; private _stopped; private _actualFrame; private _scaledUpdateSpeed; private _vertexBufferSize; /** @hidden */ _currentEmitRateGradient: Nullable; /** @hidden */ _currentEmitRate1: number; /** @hidden */ _currentEmitRate2: number; /** @hidden */ _currentStartSizeGradient: Nullable; /** @hidden */ _currentStartSize1: number; /** @hidden */ _currentStartSize2: number; private readonly _rawTextureWidth; private _rampGradientsTexture; private _useRampGradients; /** Gets or sets a boolean indicating that ramp gradients must be used * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients */ useRampGradients: boolean; /** * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: []) */ subEmitters: Array>; private _subEmitters; /** * @hidden * If the particle systems emitter should be disposed when the particle system is disposed */ _disposeEmitterOnDispose: boolean; /** * The current active Sub-systems, this property is used by the root particle system only. */ activeSubSystems: Array; private _rootParticleSystem; /** * Gets the current list of active particles */ readonly particles: Particle[]; /** * Returns the string "ParticleSystem" * @returns a string containing the class name */ getClassName(): string; /** * Instantiates a particle system. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust. * @param name The name of the particle system * @param capacity The max number of particles alive at the same time * @param scene The scene the particle system belongs to * @param customEffect a custom effect used to change the way particles are rendered by default * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture * @param epsilon Offset used to render the particles */ constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable, isAnimationSheetEnabled?: boolean, epsilon?: number); private _addFactorGradient; private _removeFactorGradient; /** * Adds a new life time gradient * @param gradient defines the gradient to use (between 0 and 1) * @param factor defines the life time factor to affect to the specified gradient * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from * @returns the current particle system */ addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem; /** * Remove a specific life time gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeLifeTimeGradient(gradient: number): IParticleSystem; /** * Adds a new size gradient * @param gradient defines the gradient to use (between 0 and 1) * @param factor defines the size factor to affect to the specified gradient * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from * @returns the current particle system */ addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem; /** * Remove a specific size gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeSizeGradient(gradient: number): IParticleSystem; /** * Adds a new color remap gradient * @param gradient defines the gradient to use (between 0 and 1) * @param min defines the color remap minimal range * @param max defines the color remap maximal range * @returns the current particle system */ addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem; /** * Remove a specific color remap gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeColorRemapGradient(gradient: number): IParticleSystem; /** * Adds a new alpha remap gradient * @param gradient defines the gradient to use (between 0 and 1) * @param min defines the alpha remap minimal range * @param max defines the alpha remap maximal range * @returns the current particle system */ addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem; /** * Remove a specific alpha remap gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeAlphaRemapGradient(gradient: number): IParticleSystem; /** * Adds a new angular speed gradient * @param gradient defines the gradient to use (between 0 and 1) * @param factor defines the angular speed to affect to the specified gradient * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from * @returns the current particle system */ addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem; /** * Remove a specific angular speed gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeAngularSpeedGradient(gradient: number): IParticleSystem; /** * Adds a new velocity gradient * @param gradient defines the gradient to use (between 0 and 1) * @param factor defines the velocity to affect to the specified gradient * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from * @returns the current particle system */ addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem; /** * Remove a specific velocity gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeVelocityGradient(gradient: number): IParticleSystem; /** * Adds a new limit velocity gradient * @param gradient defines the gradient to use (between 0 and 1) * @param factor defines the limit velocity value to affect to the specified gradient * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from * @returns the current particle system */ addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem; /** * Remove a specific limit velocity gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeLimitVelocityGradient(gradient: number): IParticleSystem; /** * Adds a new drag gradient * @param gradient defines the gradient to use (between 0 and 1) * @param factor defines the drag value to affect to the specified gradient * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from * @returns the current particle system */ addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem; /** * Remove a specific drag gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeDragGradient(gradient: number): IParticleSystem; /** * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property) * @param gradient defines the gradient to use (between 0 and 1) * @param factor defines the emit rate value to affect to the specified gradient * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from * @returns the current particle system */ addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem; /** * Remove a specific emit rate gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeEmitRateGradient(gradient: number): IParticleSystem; /** * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property) * @param gradient defines the gradient to use (between 0 and 1) * @param factor defines the start size value to affect to the specified gradient * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from * @returns the current particle system */ addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem; /** * Remove a specific start size gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeStartSizeGradient(gradient: number): IParticleSystem; private _createRampGradientTexture; /** * Gets the current list of ramp gradients. * You must use addRampGradient and removeRampGradient to udpate this list * @returns the list of ramp gradients */ getRampGradients(): Nullable>; /** * Adds a new ramp gradient used to remap particle colors * @param gradient defines the gradient to use (between 0 and 1) * @param color defines the color to affect to the specified gradient * @returns the current particle system */ addRampGradient(gradient: number, color: Color3): ParticleSystem; /** * Remove a specific ramp gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeRampGradient(gradient: number): ParticleSystem; /** * Adds a new color gradient * @param gradient defines the gradient to use (between 0 and 1) * @param color1 defines the color to affect to the specified gradient * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from * @returns this particle system */ addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem; /** * Remove a specific color gradient * @param gradient defines the gradient to remove * @returns this particle system */ removeColorGradient(gradient: number): IParticleSystem; private _fetchR; protected _reset(): void; private _resetEffect; private _createVertexBuffers; private _createIndexBuffer; /** * Gets the maximum number of particles active at the same time. * @returns The max number of active particles. */ getCapacity(): number; /** * Gets whether there are still active particles in the system. * @returns True if it is alive, otherwise false. */ isAlive(): boolean; /** * Gets if the system has been started. (Note: this will still be true after stop is called) * @returns True if it has been started, otherwise false. */ isStarted(): boolean; private _prepareSubEmitterInternalArray; /** * Starts the particle system and begins to emit * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default) */ start(delay?: number): void; /** * Stops the particle system. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true. */ stop(stopSubEmitters?: boolean): void; /** * Remove all active particles */ reset(): void; /** * @hidden (for internal use only) */ _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void; /** * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list. * Its lifetime will start back at 0. */ recycleParticle: (particle: Particle) => void; private _stopSubEmitters; private _createParticle; private _removeFromRoot; private _emitFromParticle; private _update; /** @hidden */ static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[]; /** @hidden */ static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[]; /** @hidden */ private _getEffect; /** * Animates the particle system for the current frame by emitting new particles and or animating the living ones. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false) */ animate(preWarmOnly?: boolean): void; private _appendParticleVertices; /** * Rebuilds the particle system. */ rebuild(): void; /** * Is this system ready to be used/rendered * @return true if the system is ready */ isReady(): boolean; private _render; /** * Renders the particle system in its current state. * @returns the current number of particles */ render(): number; /** * Disposes the particle system and free the associated resources * @param disposeTexture defines if the particule texture must be disposed as well (true by default) */ dispose(disposeTexture?: boolean): void; /** * Clones the particle system. * @param name The name of the cloned object * @param newEmitter The new emitter to use * @returns the cloned particle system */ clone(name: string, newEmitter: any): ParticleSystem; /** * Serializes the particle system to a JSON object. * @returns the JSON object */ serialize(): any; /** @hidden */ static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void; /** @hidden */ static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void; /** * Parses a JSON object to create a particle system. * @param parsedParticleSystem The JSON object to parse * @param scene The scene to create the particle system in * @param rootUrl The root url to use to load external dependencies like texture * @param doNotStart Ignore the preventAutoStart attribute and does not start * @returns the Parsed particle system */ static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem; } } declare module BABYLON { /** * A particle represents one of the element emitted by a particle system. * This is mainly define by its coordinates, direction, velocity and age. */ export class Particle { /** * The particle system the particle belongs to. */ particleSystem: ParticleSystem; private static _Count; /** * Unique ID of the particle */ id: number; /** * The world position of the particle in the scene. */ position: Vector3; /** * The world direction of the particle in the scene. */ direction: Vector3; /** * The color of the particle. */ color: Color4; /** * The color change of the particle per step. */ colorStep: Color4; /** * Defines how long will the life of the particle be. */ lifeTime: number; /** * The current age of the particle. */ age: number; /** * The current size of the particle. */ size: number; /** * The current scale of the particle. */ scale: Vector2; /** * The current angle of the particle. */ angle: number; /** * Defines how fast is the angle changing. */ angularSpeed: number; /** * Defines the cell index used by the particle to be rendered from a sprite. */ cellIndex: number; /** * The information required to support color remapping */ remapData: Vector4; /** @hidden */ _randomCellOffset?: number; /** @hidden */ _initialDirection: Nullable; /** @hidden */ _attachedSubEmitters: Nullable>; /** @hidden */ _initialStartSpriteCellID: number; /** @hidden */ _initialEndSpriteCellID: number; /** @hidden */ _currentColorGradient: Nullable; /** @hidden */ _currentColor1: Color4; /** @hidden */ _currentColor2: Color4; /** @hidden */ _currentSizeGradient: Nullable; /** @hidden */ _currentSize1: number; /** @hidden */ _currentSize2: number; /** @hidden */ _currentAngularSpeedGradient: Nullable; /** @hidden */ _currentAngularSpeed1: number; /** @hidden */ _currentAngularSpeed2: number; /** @hidden */ _currentVelocityGradient: Nullable; /** @hidden */ _currentVelocity1: number; /** @hidden */ _currentVelocity2: number; /** @hidden */ _currentLimitVelocityGradient: Nullable; /** @hidden */ _currentLimitVelocity1: number; /** @hidden */ _currentLimitVelocity2: number; /** @hidden */ _currentDragGradient: Nullable; /** @hidden */ _currentDrag1: number; /** @hidden */ _currentDrag2: number; /** @hidden */ _randomNoiseCoordinates1: Vector3; /** @hidden */ _randomNoiseCoordinates2: Vector3; /** * Creates a new instance Particle * @param particleSystem the particle system the particle belongs to */ constructor( /** * The particle system the particle belongs to. */ particleSystem: ParticleSystem); private updateCellInfoFromSystem; /** * Defines how the sprite cell index is updated for the particle */ updateCellIndex(): void; /** @hidden */ _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void; /** @hidden */ _inheritParticleInfoToSubEmitters(): void; /** @hidden */ _reset(): void; /** * Copy the properties of particle to another one. * @param other the particle to copy the information to. */ copyTo(other: Particle): void; } } declare module BABYLON { /** * Particle emitter represents a volume emitting particles. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box. */ export interface IParticleEmitterType { /** * Called by the particle System when the direction is computed for the created particle. * @param worldMatrix is the world matrix of the particle system * @param directionToUpdate is the direction vector to update with the result * @param particle is the particle we are computed the direction for */ startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void; /** * Called by the particle System when the position is computed for the created particle. * @param worldMatrix is the world matrix of the particle system * @param positionToUpdate is the position vector to update with the result * @param particle is the particle we are computed the position for */ startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void; /** * Clones the current emitter and returns a copy of it * @returns the new emitter */ clone(): IParticleEmitterType; /** * Called by the GPUParticleSystem to setup the update shader * @param effect defines the update shader */ applyToShader(effect: Effect): void; /** * Returns a string to use to update the GPU particles update shader * @returns the effect defines string */ getEffectDefines(): string; /** * Returns a string representing the class name * @returns a string containing the class name */ getClassName(): string; /** * Serializes the particle system to a JSON object. * @returns the JSON object */ serialize(): any; /** * Parse properties from a JSON object * @param serializationObject defines the JSON object */ parse(serializationObject: any): void; } } declare module BABYLON { /** * Particle emitter emitting particles from the inside of a box. * It emits the particles randomly between 2 given directions. */ export class BoxParticleEmitter implements IParticleEmitterType { /** * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors. */ direction1: Vector3; /** * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors. */ direction2: Vector3; /** * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so. */ minEmitBox: Vector3; /** * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so. */ maxEmitBox: Vector3; /** * Creates a new instance BoxParticleEmitter */ constructor(); /** * Called by the particle System when the direction is computed for the created particle. * @param worldMatrix is the world matrix of the particle system * @param directionToUpdate is the direction vector to update with the result * @param particle is the particle we are computed the direction for */ startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void; /** * Called by the particle System when the position is computed for the created particle. * @param worldMatrix is the world matrix of the particle system * @param positionToUpdate is the position vector to update with the result * @param particle is the particle we are computed the position for */ startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void; /** * Clones the current emitter and returns a copy of it * @returns the new emitter */ clone(): BoxParticleEmitter; /** * Called by the GPUParticleSystem to setup the update shader * @param effect defines the update shader */ applyToShader(effect: Effect): void; /** * Returns a string to use to update the GPU particles update shader * @returns a string containng the defines string */ getEffectDefines(): string; /** * Returns the string "BoxParticleEmitter" * @returns a string containing the class name */ getClassName(): string; /** * Serializes the particle system to a JSON object. * @returns the JSON object */ serialize(): any; /** * Parse properties from a JSON object * @param serializationObject defines the JSON object */ parse(serializationObject: any): void; } } declare module BABYLON { /** * Particle emitter emitting particles from the inside of a cone. * It emits the particles alongside the cone volume from the base to the particle. * The emission direction might be randomized. */ export class ConeParticleEmitter implements IParticleEmitterType { /** defines how much to randomize the particle direction [0-1] (default is 0) */ directionRandomizer: number; private _radius; private _angle; private _height; /** * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface) */ radiusRange: number; /** * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface) */ heightRange: number; /** * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone) */ emitFromSpawnPointOnly: boolean; /** * Gets or sets the radius of the emission cone */ radius: number; /** * Gets or sets the angle of the emission cone */ angle: number; private _buildHeight; /** * Creates a new instance ConeParticleEmitter * @param radius the radius of the emission cone (1 by default) * @param angle the cone base angle (PI by default) * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0) */ constructor(radius?: number, angle?: number, /** defines how much to randomize the particle direction [0-1] (default is 0) */ directionRandomizer?: number); /** * Called by the particle System when the direction is computed for the created particle. * @param worldMatrix is the world matrix of the particle system * @param directionToUpdate is the direction vector to update with the result * @param particle is the particle we are computed the direction for */ startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void; /** * Called by the particle System when the position is computed for the created particle. * @param worldMatrix is the world matrix of the particle system * @param positionToUpdate is the position vector to update with the result * @param particle is the particle we are computed the position for */ startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void; /** * Clones the current emitter and returns a copy of it * @returns the new emitter */ clone(): ConeParticleEmitter; /** * Called by the GPUParticleSystem to setup the update shader * @param effect defines the update shader */ applyToShader(effect: Effect): void; /** * Returns a string to use to update the GPU particles update shader * @returns a string containng the defines string */ getEffectDefines(): string; /** * Returns the string "ConeParticleEmitter" * @returns a string containing the class name */ getClassName(): string; /** * Serializes the particle system to a JSON object. * @returns the JSON object */ serialize(): any; /** * Parse properties from a JSON object * @param serializationObject defines the JSON object */ parse(serializationObject: any): void; } } declare module BABYLON { /** * Particle emitter emitting particles from the inside of a cylinder. * It emits the particles alongside the cylinder radius. The emission direction might be randomized. */ export class CylinderParticleEmitter implements IParticleEmitterType { /** * The radius of the emission cylinder. */ radius: number; /** * The height of the emission cylinder. */ height: number; /** * The range of emission [0-1] 0 Surface only, 1 Entire Radius. */ radiusRange: number; /** * How much to randomize the particle direction [0-1]. */ directionRandomizer: number; /** * Creates a new instance CylinderParticleEmitter * @param radius the radius of the emission cylinder (1 by default) * @param height the height of the emission cylinder (1 by default) * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default) * @param directionRandomizer defines how much to randomize the particle direction [0-1] */ constructor( /** * The radius of the emission cylinder. */ radius?: number, /** * The height of the emission cylinder. */ height?: number, /** * The range of emission [0-1] 0 Surface only, 1 Entire Radius. */ radiusRange?: number, /** * How much to randomize the particle direction [0-1]. */ directionRandomizer?: number); /** * Called by the particle System when the direction is computed for the created particle. * @param worldMatrix is the world matrix of the particle system * @param directionToUpdate is the direction vector to update with the result * @param particle is the particle we are computed the direction for */ startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void; /** * Called by the particle System when the position is computed for the created particle. * @param worldMatrix is the world matrix of the particle system * @param positionToUpdate is the position vector to update with the result * @param particle is the particle we are computed the position for */ startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void; /** * Clones the current emitter and returns a copy of it * @returns the new emitter */ clone(): CylinderParticleEmitter; /** * Called by the GPUParticleSystem to setup the update shader * @param effect defines the update shader */ applyToShader(effect: Effect): void; /** * Returns a string to use to update the GPU particles update shader * @returns a string containng the defines string */ getEffectDefines(): string; /** * Returns the string "CylinderParticleEmitter" * @returns a string containing the class name */ getClassName(): string; /** * Serializes the particle system to a JSON object. * @returns the JSON object */ serialize(): any; /** * Parse properties from a JSON object * @param serializationObject defines the JSON object */ parse(serializationObject: any): void; } /** * Particle emitter emitting particles from the inside of a cylinder. * It emits the particles randomly between two vectors. */ export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter { /** * The min limit of the emission direction. */ direction1: Vector3; /** * The max limit of the emission direction. */ direction2: Vector3; /** * Creates a new instance CylinderDirectedParticleEmitter * @param radius the radius of the emission cylinder (1 by default) * @param height the height of the emission cylinder (1 by default) * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default) * @param direction1 the min limit of the emission direction (up vector by default) * @param direction2 the max limit of the emission direction (up vector by default) */ constructor(radius?: number, height?: number, radiusRange?: number, /** * The min limit of the emission direction. */ direction1?: Vector3, /** * The max limit of the emission direction. */ direction2?: Vector3); /** * Called by the particle System when the direction is computed for the created particle. * @param worldMatrix is the world matrix of the particle system * @param directionToUpdate is the direction vector to update with the result * @param particle is the particle we are computed the direction for */ startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void; /** * Clones the current emitter and returns a copy of it * @returns the new emitter */ clone(): CylinderDirectedParticleEmitter; /** * Called by the GPUParticleSystem to setup the update shader * @param effect defines the update shader */ applyToShader(effect: Effect): void; /** * Returns a string to use to update the GPU particles update shader * @returns a string containng the defines string */ getEffectDefines(): string; /** * Returns the string "CylinderDirectedParticleEmitter" * @returns a string containing the class name */ getClassName(): string; /** * Serializes the particle system to a JSON object. * @returns the JSON object */ serialize(): any; /** * Parse properties from a JSON object * @param serializationObject defines the JSON object */ parse(serializationObject: any): void; } } declare module BABYLON { /** * Particle emitter emitting particles from the inside of a hemisphere. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized. */ export class HemisphericParticleEmitter implements IParticleEmitterType { /** * The radius of the emission hemisphere. */ radius: number; /** * The range of emission [0-1] 0 Surface only, 1 Entire Radius. */ radiusRange: number; /** * How much to randomize the particle direction [0-1]. */ directionRandomizer: number; /** * Creates a new instance HemisphericParticleEmitter * @param radius the radius of the emission hemisphere (1 by default) * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default) * @param directionRandomizer defines how much to randomize the particle direction [0-1] */ constructor( /** * The radius of the emission hemisphere. */ radius?: number, /** * The range of emission [0-1] 0 Surface only, 1 Entire Radius. */ radiusRange?: number, /** * How much to randomize the particle direction [0-1]. */ directionRandomizer?: number); /** * Called by the particle System when the direction is computed for the created particle. * @param worldMatrix is the world matrix of the particle system * @param directionToUpdate is the direction vector to update with the result * @param particle is the particle we are computed the direction for */ startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void; /** * Called by the particle System when the position is computed for the created particle. * @param worldMatrix is the world matrix of the particle system * @param positionToUpdate is the position vector to update with the result * @param particle is the particle we are computed the position for */ startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void; /** * Clones the current emitter and returns a copy of it * @returns the new emitter */ clone(): HemisphericParticleEmitter; /** * Called by the GPUParticleSystem to setup the update shader * @param effect defines the update shader */ applyToShader(effect: Effect): void; /** * Returns a string to use to update the GPU particles update shader * @returns a string containng the defines string */ getEffectDefines(): string; /** * Returns the string "HemisphericParticleEmitter" * @returns a string containing the class name */ getClassName(): string; /** * Serializes the particle system to a JSON object. * @returns the JSON object */ serialize(): any; /** * Parse properties from a JSON object * @param serializationObject defines the JSON object */ parse(serializationObject: any): void; } } declare module BABYLON { /** * Particle emitter emitting particles from a point. * It emits the particles randomly between 2 given directions. */ export class PointParticleEmitter implements IParticleEmitterType { /** * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors. */ direction1: Vector3; /** * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors. */ direction2: Vector3; /** * Creates a new instance PointParticleEmitter */ constructor(); /** * Called by the particle System when the direction is computed for the created particle. * @param worldMatrix is the world matrix of the particle system * @param directionToUpdate is the direction vector to update with the result * @param particle is the particle we are computed the direction for */ startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void; /** * Called by the particle System when the position is computed for the created particle. * @param worldMatrix is the world matrix of the particle system * @param positionToUpdate is the position vector to update with the result * @param particle is the particle we are computed the position for */ startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void; /** * Clones the current emitter and returns a copy of it * @returns the new emitter */ clone(): PointParticleEmitter; /** * Called by the GPUParticleSystem to setup the update shader * @param effect defines the update shader */ applyToShader(effect: Effect): void; /** * Returns a string to use to update the GPU particles update shader * @returns a string containng the defines string */ getEffectDefines(): string; /** * Returns the string "PointParticleEmitter" * @returns a string containing the class name */ getClassName(): string; /** * Serializes the particle system to a JSON object. * @returns the JSON object */ serialize(): any; /** * Parse properties from a JSON object * @param serializationObject defines the JSON object */ parse(serializationObject: any): void; } } declare module BABYLON { /** * Particle emitter emitting particles from the inside of a sphere. * It emits the particles alongside the sphere radius. The emission direction might be randomized. */ export class SphereParticleEmitter implements IParticleEmitterType { /** * The radius of the emission sphere. */ radius: number; /** * The range of emission [0-1] 0 Surface only, 1 Entire Radius. */ radiusRange: number; /** * How much to randomize the particle direction [0-1]. */ directionRandomizer: number; /** * Creates a new instance SphereParticleEmitter * @param radius the radius of the emission sphere (1 by default) * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default) * @param directionRandomizer defines how much to randomize the particle direction [0-1] */ constructor( /** * The radius of the emission sphere. */ radius?: number, /** * The range of emission [0-1] 0 Surface only, 1 Entire Radius. */ radiusRange?: number, /** * How much to randomize the particle direction [0-1]. */ directionRandomizer?: number); /** * Called by the particle System when the direction is computed for the created particle. * @param worldMatrix is the world matrix of the particle system * @param directionToUpdate is the direction vector to update with the result * @param particle is the particle we are computed the direction for */ startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void; /** * Called by the particle System when the position is computed for the created particle. * @param worldMatrix is the world matrix of the particle system * @param positionToUpdate is the position vector to update with the result * @param particle is the particle we are computed the position for */ startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void; /** * Clones the current emitter and returns a copy of it * @returns the new emitter */ clone(): SphereParticleEmitter; /** * Called by the GPUParticleSystem to setup the update shader * @param effect defines the update shader */ applyToShader(effect: Effect): void; /** * Returns a string to use to update the GPU particles update shader * @returns a string containng the defines string */ getEffectDefines(): string; /** * Returns the string "SphereParticleEmitter" * @returns a string containing the class name */ getClassName(): string; /** * Serializes the particle system to a JSON object. * @returns the JSON object */ serialize(): any; /** * Parse properties from a JSON object * @param serializationObject defines the JSON object */ parse(serializationObject: any): void; } /** * Particle emitter emitting particles from the inside of a sphere. * It emits the particles randomly between two vectors. */ export class SphereDirectedParticleEmitter extends SphereParticleEmitter { /** * The min limit of the emission direction. */ direction1: Vector3; /** * The max limit of the emission direction. */ direction2: Vector3; /** * Creates a new instance SphereDirectedParticleEmitter * @param radius the radius of the emission sphere (1 by default) * @param direction1 the min limit of the emission direction (up vector by default) * @param direction2 the max limit of the emission direction (up vector by default) */ constructor(radius?: number, /** * The min limit of the emission direction. */ direction1?: Vector3, /** * The max limit of the emission direction. */ direction2?: Vector3); /** * Called by the particle System when the direction is computed for the created particle. * @param worldMatrix is the world matrix of the particle system * @param directionToUpdate is the direction vector to update with the result * @param particle is the particle we are computed the direction for */ startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void; /** * Clones the current emitter and returns a copy of it * @returns the new emitter */ clone(): SphereDirectedParticleEmitter; /** * Called by the GPUParticleSystem to setup the update shader * @param effect defines the update shader */ applyToShader(effect: Effect): void; /** * Returns a string to use to update the GPU particles update shader * @returns a string containng the defines string */ getEffectDefines(): string; /** * Returns the string "SphereDirectedParticleEmitter" * @returns a string containing the class name */ getClassName(): string; /** * Serializes the particle system to a JSON object. * @returns the JSON object */ serialize(): any; /** * Parse properties from a JSON object * @param serializationObject defines the JSON object */ parse(serializationObject: any): void; } } declare module BABYLON { /** * Interface representing a particle system in Babylon.js. * This groups the common functionalities that needs to be implemented in order to create a particle system. * A particle system represents a way to manage particles from their emission to their animation and rendering. */ export interface IParticleSystem { /** * List of animations used by the particle system. */ animations: Animation[]; /** * The id of the Particle system. */ id: string; /** * The name of the Particle system. */ name: string; /** * The emitter represents the Mesh or position we are attaching the particle system to. */ emitter: Nullable; /** * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction */ isBillboardBased: boolean; /** * The rendering group used by the Particle system to chose when to render. */ renderingGroupId: number; /** * The layer mask we are rendering the particles through. */ layerMask: number; /** * The overall motion speed (0.01 is default update speed, faster updates = faster animation) */ updateSpeed: number; /** * The amount of time the particle system is running (depends of the overall update speed). */ targetStopDuration: number; /** * The texture used to render each particle. (this can be a spritesheet) */ particleTexture: Nullable; /** * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD. */ blendMode: number; /** * Minimum life time of emitting particles. */ minLifeTime: number; /** * Maximum life time of emitting particles. */ maxLifeTime: number; /** * Minimum Size of emitting particles. */ minSize: number; /** * Maximum Size of emitting particles. */ maxSize: number; /** * Minimum scale of emitting particles on X axis. */ minScaleX: number; /** * Maximum scale of emitting particles on X axis. */ maxScaleX: number; /** * Minimum scale of emitting particles on Y axis. */ minScaleY: number; /** * Maximum scale of emitting particles on Y axis. */ maxScaleY: number; /** * Random color of each particle after it has been emitted, between color1 and color2 vectors. */ color1: Color4; /** * Random color of each particle after it has been emitted, between color1 and color2 vectors. */ color2: Color4; /** * Color the particle will have at the end of its lifetime. */ colorDead: Color4; /** * The maximum number of particles to emit per frame until we reach the activeParticleCount value */ emitRate: number; /** * You can use gravity if you want to give an orientation to your particles. */ gravity: Vector3; /** * Minimum power of emitting particles. */ minEmitPower: number; /** * Maximum power of emitting particles. */ maxEmitPower: number; /** * Minimum angular speed of emitting particles (Z-axis rotation for each particle). */ minAngularSpeed: number; /** * Maximum angular speed of emitting particles (Z-axis rotation for each particle). */ maxAngularSpeed: number; /** * Gets or sets the minimal initial rotation in radians. */ minInitialRotation: number; /** * Gets or sets the maximal initial rotation in radians. */ maxInitialRotation: number; /** * The particle emitter type defines the emitter used by the particle system. * It can be for example box, sphere, or cone... */ particleEmitterType: Nullable; /** * Defines the delay in milliseconds before starting the system (0 by default) */ startDelay: number; /** * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */ preWarmCycles: number; /** * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */ preWarmStepOffset: number; /** * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime) */ spriteCellChangeSpeed: number; /** * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display */ startSpriteCellID: number; /** * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display */ endSpriteCellID: number; /** * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use */ spriteCellWidth: number; /** * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use */ spriteCellHeight: number; /** * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID */ spriteRandomStartCell: boolean; /** * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture */ isAnimationSheetEnabled: boolean; /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */ translationPivot: Vector2; /** * Gets or sets a texture used to add random noise to particle positions */ noiseTexture: Nullable; /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */ noiseStrength: Vector3; /** * Gets or sets the billboard mode to use when isBillboardBased = true. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED */ billboardMode: number; /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */ limitVelocityDamping: number; /** * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called */ beginAnimationOnStart: boolean; /** * Gets or sets the frame to start the animation from when beginAnimationOnStart is true */ beginAnimationFrom: number; /** * Gets or sets the frame to end the animation on when beginAnimationOnStart is true */ beginAnimationTo: number; /** * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true */ beginAnimationLoop: boolean; /** * Specifies whether the particle system will be disposed once it reaches the end of the animation. */ disposeOnStop: boolean; /** * Gets the maximum number of particles active at the same time. * @returns The max number of active particles. */ getCapacity(): number; /** * Gets if the system has been started. (Note: this will still be true after stop is called) * @returns True if it has been started, otherwise false. */ isStarted(): boolean; /** * Animates the particle system for this frame. */ animate(): void; /** * Renders the particle system in its current state. * @returns the current number of particles */ render(): number; /** * Dispose the particle system and frees its associated resources. * @param disposeTexture defines if the particule texture must be disposed as well (true by default) */ dispose(disposeTexture?: boolean): void; /** * Clones the particle system. * @param name The name of the cloned object * @param newEmitter The new emitter to use * @returns the cloned particle system */ clone(name: string, newEmitter: any): Nullable; /** * Serializes the particle system to a JSON object. * @returns the JSON object */ serialize(): any; /** * Rebuild the particle system */ rebuild(): void; /** * Starts the particle system and begins to emit * @param delay defines the delay in milliseconds before starting the system (0 by default) */ start(delay?: number): void; /** * Stops the particle system. */ stop(): void; /** * Remove all active particles */ reset(): void; /** * Is this system ready to be used/rendered * @return true if the system is ready */ isReady(): boolean; /** * Adds a new color gradient * @param gradient defines the gradient to use (between 0 and 1) * @param color1 defines the color to affect to the specified gradient * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from * @returns the current particle system */ addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem; /** * Remove a specific color gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeColorGradient(gradient: number): IParticleSystem; /** * Adds a new size gradient * @param gradient defines the gradient to use (between 0 and 1) * @param factor defines the size factor to affect to the specified gradient * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from * @returns the current particle system */ addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem; /** * Remove a specific size gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeSizeGradient(gradient: number): IParticleSystem; /** * Gets the current list of color gradients. * You must use addColorGradient and removeColorGradient to udpate this list * @returns the list of color gradients */ getColorGradients(): Nullable>; /** * Gets the current list of size gradients. * You must use addSizeGradient and removeSizeGradient to udpate this list * @returns the list of size gradients */ getSizeGradients(): Nullable>; /** * Gets the current list of angular speed gradients. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list * @returns the list of angular speed gradients */ getAngularSpeedGradients(): Nullable>; /** * Adds a new angular speed gradient * @param gradient defines the gradient to use (between 0 and 1) * @param factor defines the angular speed to affect to the specified gradient * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from * @returns the current particle system */ addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem; /** * Remove a specific angular speed gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeAngularSpeedGradient(gradient: number): IParticleSystem; /** * Gets the current list of velocity gradients. * You must use addVelocityGradient and removeVelocityGradient to udpate this list * @returns the list of velocity gradients */ getVelocityGradients(): Nullable>; /** * Adds a new velocity gradient * @param gradient defines the gradient to use (between 0 and 1) * @param factor defines the velocity to affect to the specified gradient * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from * @returns the current particle system */ addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem; /** * Remove a specific velocity gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeVelocityGradient(gradient: number): IParticleSystem; /** * Gets the current list of limit velocity gradients. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list * @returns the list of limit velocity gradients */ getLimitVelocityGradients(): Nullable>; /** * Adds a new limit velocity gradient * @param gradient defines the gradient to use (between 0 and 1) * @param factor defines the limit velocity to affect to the specified gradient * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from * @returns the current particle system */ addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem; /** * Remove a specific limit velocity gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeLimitVelocityGradient(gradient: number): IParticleSystem; /** * Adds a new drag gradient * @param gradient defines the gradient to use (between 0 and 1) * @param factor defines the drag to affect to the specified gradient * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from * @returns the current particle system */ addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem; /** * Remove a specific drag gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeDragGradient(gradient: number): IParticleSystem; /** * Gets the current list of drag gradients. * You must use addDragGradient and removeDragGradient to udpate this list * @returns the list of drag gradients */ getDragGradients(): Nullable>; /** * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property) * @param gradient defines the gradient to use (between 0 and 1) * @param factor defines the emit rate to affect to the specified gradient * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from * @returns the current particle system */ addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem; /** * Remove a specific emit rate gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeEmitRateGradient(gradient: number): IParticleSystem; /** * Gets the current list of emit rate gradients. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list * @returns the list of emit rate gradients */ getEmitRateGradients(): Nullable>; /** * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property) * @param gradient defines the gradient to use (between 0 and 1) * @param factor defines the start size to affect to the specified gradient * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from * @returns the current particle system */ addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem; /** * Remove a specific start size gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeStartSizeGradient(gradient: number): IParticleSystem; /** * Gets the current list of start size gradients. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list * @returns the list of start size gradients */ getStartSizeGradients(): Nullable>; /** * Adds a new life time gradient * @param gradient defines the gradient to use (between 0 and 1) * @param factor defines the life time factor to affect to the specified gradient * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from * @returns the current particle system */ addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem; /** * Remove a specific life time gradient * @param gradient defines the gradient to remove * @returns the current particle system */ removeLifeTimeGradient(gradient: number): IParticleSystem; /** * Gets the current list of life time gradients. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list * @returns the list of life time gradients */ getLifeTimeGradients(): Nullable>; /** * Gets the current list of color gradients. * You must use addColorGradient and removeColorGradient to udpate this list * @returns the list of color gradients */ getColorGradients(): Nullable>; /** * Adds a new ramp gradient used to remap particle colors * @param gradient defines the gradient to use (between 0 and 1) * @param color defines the color to affect to the specified gradient * @returns the current particle system */ addRampGradient(gradient: number, color: Color3): IParticleSystem; /** * Gets the current list of ramp gradients. * You must use addRampGradient and removeRampGradient to udpate this list * @returns the list of ramp gradients */ getRampGradients(): Nullable>; /** Gets or sets a boolean indicating that ramp gradients must be used * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients */ useRampGradients: boolean; /** * Adds a new color remap gradient * @param gradient defines the gradient to use (between 0 and 1) * @param min defines the color remap minimal range * @param max defines the color remap maximal range * @returns the current particle system */ addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem; /** * Gets the current list of color remap gradients. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list * @returns the list of color remap gradients */ getColorRemapGradients(): Nullable>; /** * Adds a new alpha remap gradient * @param gradient defines the gradient to use (between 0 and 1) * @param min defines the alpha remap minimal range * @param max defines the alpha remap maximal range * @returns the current particle system */ addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem; /** * Gets the current list of alpha remap gradients. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list * @returns the list of alpha remap gradients */ getAlphaRemapGradients(): Nullable>; /** * Creates a Point Emitter for the particle system (emits directly from the emitter position) * @param direction1 Particles are emitted between the direction1 and direction2 from within the box * @param direction2 Particles are emitted between the direction1 and direction2 from within the box * @returns the emitter */ createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter; /** * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius) * @param radius The radius of the hemisphere to emit from * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius * @returns the emitter */ createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter; /** * Creates a Sphere Emitter for the particle system (emits along the sphere radius) * @param radius The radius of the sphere to emit from * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius * @returns the emitter */ createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter; /** * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2) * @param radius The radius of the sphere to emit from * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere * @returns the emitter */ createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter; /** * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position) * @param radius The radius of the emission cylinder * @param height The height of the emission cylinder * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius * @param directionRandomizer How much to randomize the particle direction [0-1] * @returns the emitter */ createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter; /** * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2) * @param radius The radius of the cylinder to emit from * @param height The height of the emission cylinder * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default) * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder * @returns the emitter */ createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter; /** * Creates a Cone Emitter for the particle system (emits from the cone to the particle position) * @param radius The radius of the cone to emit from * @param angle The base angle of the cone * @returns the emitter */ createConeEmitter(radius: number, angle: number): ConeParticleEmitter; /** * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox) * @param direction1 Particles are emitted between the direction1 and direction2 from within the box * @param direction2 Particles are emitted between the direction1 and direction2 from within the box * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox * @returns the emitter */ createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter; /** * Get hosting scene * @returns the scene */ getScene(): Scene; } } declare module BABYLON { /** * Creates an instance based on a source mesh. */ export class InstancedMesh extends AbstractMesh { private _sourceMesh; private _currentLOD; /** @hidden */ _indexInSourceMeshInstanceArray: number; constructor(name: string, source: Mesh); /** * Returns the string "InstancedMesh". */ getClassName(): string; /** Gets the list of lights affecting that mesh */ readonly lightSources: Light[]; _resyncLightSources(): void; _resyncLighSource(light: Light): void; _removeLightSource(light: Light): void; /** * If the source mesh receives shadows */ readonly receiveShadows: boolean; /** * The material of the source mesh */ readonly material: Nullable; /** * Visibility of the source mesh */ readonly visibility: number; /** * Skeleton of the source mesh */ readonly skeleton: Nullable; /** * Rendering ground id of the source mesh */ renderingGroupId: number; /** * Returns the total number of vertices (integer). */ getTotalVertices(): number; /** * Returns a positive integer : the total number of indices in this mesh geometry. * @returns the numner of indices or zero if the mesh has no geometry. */ getTotalIndices(): number; /** * The source mesh of the instance */ readonly sourceMesh: Mesh; /** * Is this node ready to be used/rendered * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default) * @return {boolean} is it ready */ isReady(completeCheck?: boolean): boolean; /** * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.) * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc. */ getVerticesData(kind: string, copyWhenShared?: boolean): Nullable; /** * Sets the vertex data of the mesh geometry for the requested `kind`. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data. * The `data` are either a numeric array either a Float32Array. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc). * Note that a new underlying VertexBuffer object is created each call. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed. * * Possible `kind` values : * - VertexBuffer.PositionKind * - VertexBuffer.UVKind * - VertexBuffer.UV2Kind * - VertexBuffer.UV3Kind * - VertexBuffer.UV4Kind * - VertexBuffer.UV5Kind * - VertexBuffer.UV6Kind * - VertexBuffer.ColorKind * - VertexBuffer.MatricesIndicesKind * - VertexBuffer.MatricesIndicesExtraKind * - VertexBuffer.MatricesWeightsKind * - VertexBuffer.MatricesWeightsExtraKind * * Returns the Mesh. */ setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh; /** * Updates the existing vertex data of the mesh geometry for the requested `kind`. * If the mesh has no geometry, it is simply returned as it is. * The `data` are either a numeric array either a Float32Array. * No new underlying VertexBuffer object is created. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh. * * Possible `kind` values : * - VertexBuffer.PositionKind * - VertexBuffer.UVKind * - VertexBuffer.UV2Kind * - VertexBuffer.UV3Kind * - VertexBuffer.UV4Kind * - VertexBuffer.UV5Kind * - VertexBuffer.UV6Kind * - VertexBuffer.ColorKind * - VertexBuffer.MatricesIndicesKind * - VertexBuffer.MatricesIndicesExtraKind * - VertexBuffer.MatricesWeightsKind * - VertexBuffer.MatricesWeightsExtraKind * * Returns the Mesh. */ updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh; /** * Sets the mesh indices. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array). * If the mesh has no geometry, a new Geometry object is created and set to the mesh. * This method creates a new index buffer each call. * Returns the Mesh. */ setIndices(indices: IndicesArray, totalVertices?: Nullable): Mesh; /** * Boolean : True if the mesh owns the requested kind of data. */ isVerticesDataPresent(kind: string): boolean; /** * Returns an array of indices (IndicesArray). */ getIndices(): Nullable; readonly _positions: Nullable; /** * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked. * This means the mesh underlying bounding box and sphere are recomputed. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info * @returns the current mesh */ refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh; /** @hidden */ _preActivate(): InstancedMesh; /** @hidden */ _activate(renderId: number, intermediateRendering: boolean): boolean; /** @hidden */ _postActivate(): void; getWorldMatrix(): Matrix; readonly isAnInstance: boolean; /** * Returns the current associated LOD AbstractMesh. */ getLOD(camera: Camera): AbstractMesh; /** @hidden */ _syncSubMeshes(): InstancedMesh; /** @hidden */ _generatePointsArray(): boolean; /** * Creates a new InstancedMesh from the current mesh. * - name (string) : the cloned mesh name * - newParent (optional Node) : the optional Node to parent the clone to. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned. * * Returns the clone. */ clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh; /** * Disposes the InstancedMesh. * Returns nothing. */ dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void; } } declare module BABYLON { /** * Defines the options associated with the creation of a shader material. */ export interface IShaderMaterialOptions { /** * Does the material work in alpha blend mode */ needAlphaBlending: boolean; /** * Does the material work in alpha test mode */ needAlphaTesting: boolean; /** * The list of attribute names used in the shader */ attributes: string[]; /** * The list of unifrom names used in the shader */ uniforms: string[]; /** * The list of UBO names used in the shader */ uniformBuffers: string[]; /** * The list of sampler names used in the shader */ samplers: string[]; /** * The list of defines used in the shader */ defines: string[]; } /** * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh. * * This returned material effects how the mesh will look based on the code in the shaders. * * @see http://doc.babylonjs.com/how_to/shader_material */ export class ShaderMaterial extends Material { private _shaderPath; private _options; private _textures; private _textureArrays; private _floats; private _ints; private _floatsArrays; private _colors3; private _colors3Arrays; private _colors4; private _vectors2; private _vectors3; private _vectors4; private _matrices; private _matrices3x3; private _matrices2x2; private _vectors2Arrays; private _vectors3Arrays; private _cachedWorldViewMatrix; private _cachedWorldViewProjectionMatrix; private _renderId; /** * Instantiate a new shader material. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh. * This returned material effects how the mesh will look based on the code in the shaders. * @see http://doc.babylonjs.com/how_to/shader_material * @param name Define the name of the material in the scene * @param scene Define the scene the material belongs to * @param shaderPath Defines the route to the shader code in one of three ways: * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"] * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in