math.vector.d.ts 204 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299
  1. import type { Viewport } from "./math.viewport";
  2. import type { DeepImmutable, Nullable, FloatArray, float, Tuple } from "../types";
  3. import type { Plane } from "./math.plane";
  4. import type { TransformNode } from "../Meshes/transformNode";
  5. import type { Dimension, Tensor, TensorStatic } from "./tensor";
  6. import type { IVector2Like, IVector3Like, IVector4Like, IQuaternionLike, IMatrixLike, IPlaneLike } from "./math.like";
  7. /**
  8. * Represents a vector of any dimension
  9. */
  10. export interface Vector<N extends number[] = number[]> extends Tensor<N> {
  11. /**
  12. * @see Tensor.dimension
  13. */
  14. readonly dimension: Readonly<Dimension<N>>;
  15. /**
  16. * @see Tensor.rank
  17. */
  18. readonly rank: 1;
  19. /**
  20. * Gets the length of the vector
  21. * @returns the vector length (float)
  22. */
  23. length(): number;
  24. /**
  25. * Gets the vector squared length
  26. * @returns the vector squared length (float)
  27. */
  28. lengthSquared(): number;
  29. /**
  30. * Normalize the vector
  31. * @returns the current updated Vector
  32. */
  33. normalize(): this;
  34. /**
  35. * Normalize the current Vector with the given input length.
  36. * Please note that this is an in place operation.
  37. * @param len the length of the vector
  38. * @returns the current updated Vector
  39. */
  40. normalizeFromLength(len: number): this;
  41. /**
  42. * Normalize the current Vector to a new vector
  43. * @returns the new Vector
  44. */
  45. normalizeToNew(): this;
  46. /**
  47. * Normalize the current Vector to the reference
  48. * @param reference define the Vector to update
  49. * @returns the updated Vector
  50. */
  51. normalizeToRef(reference: this): this;
  52. }
  53. /**
  54. * Static side of Vector
  55. */
  56. export interface VectorStatic<T extends Vector> extends TensorStatic<T> {
  57. /**
  58. * Checks if a given vector is inside a specific range
  59. * @param v defines the vector to test
  60. * @param min defines the minimum range
  61. * @param max defines the maximum range
  62. */
  63. CheckExtends(v: T, min: T, max: T): void;
  64. /**
  65. * Returns a new Vector equal to the normalized given vector
  66. * @param vector defines the vector to normalize
  67. * @returns a new Vector
  68. */
  69. Normalize(vector: DeepImmutable<T>): T;
  70. /**
  71. * Normalize a given vector into a second one
  72. * @param vector defines the vector to normalize
  73. * @param result defines the vector where to store the result
  74. * @returns result input
  75. */
  76. NormalizeToRef(vector: DeepImmutable<T>, result: T): T;
  77. }
  78. /**
  79. * Class representing a vector containing 2 coordinates
  80. * Example Playground - Overview - https://playground.babylonjs.com/#QYBWV4#9
  81. */
  82. export declare class Vector2 implements Vector<Tuple<number, 2>>, IVector2Like {
  83. /** defines the first coordinate */
  84. x: number;
  85. /** defines the second coordinate */
  86. y: number;
  87. private static _ZeroReadOnly;
  88. /**
  89. * @see Tensor.dimension
  90. */
  91. readonly dimension: Readonly<[2]>;
  92. /**
  93. * @see Tensor.rank
  94. */
  95. readonly rank: 1;
  96. /**
  97. * Creates a new Vector2 from the given x and y coordinates
  98. * @param x defines the first coordinate
  99. * @param y defines the second coordinate
  100. */
  101. constructor(
  102. /** defines the first coordinate */
  103. x?: number,
  104. /** defines the second coordinate */
  105. y?: number);
  106. /**
  107. * Gets a string with the Vector2 coordinates
  108. * @returns a string with the Vector2 coordinates
  109. */
  110. toString(): string;
  111. /**
  112. * Gets class name
  113. * @returns the string "Vector2"
  114. */
  115. getClassName(): string;
  116. /**
  117. * Gets current vector hash code
  118. * @returns the Vector2 hash code as a number
  119. */
  120. getHashCode(): number;
  121. /**
  122. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  123. * Example Playground https://playground.babylonjs.com/#QYBWV4#15
  124. * @param array defines the source array
  125. * @param index defines the offset in source array
  126. * @returns the current Vector2
  127. */
  128. toArray(array: FloatArray, index?: number): this;
  129. /**
  130. * Update the current vector from an array
  131. * Example Playground https://playground.babylonjs.com/#QYBWV4#39
  132. * @param array defines the destination array
  133. * @param offset defines the offset in the destination array
  134. * @returns the current Vector2
  135. */
  136. fromArray(array: FloatArray, offset?: number): this;
  137. /**
  138. * Copy the current vector to an array
  139. * Example Playground https://playground.babylonjs.com/#QYBWV4#40
  140. * @returns a new array with 2 elements: the Vector2 coordinates.
  141. */
  142. asArray(): [number, number];
  143. /**
  144. * Sets the Vector2 coordinates with the given Vector2 coordinates
  145. * Example Playground https://playground.babylonjs.com/#QYBWV4#24
  146. * @param source defines the source Vector2
  147. * @returns the current updated Vector2
  148. */
  149. copyFrom(source: DeepImmutable<this>): this;
  150. /**
  151. * Sets the Vector2 coordinates with the given floats
  152. * Example Playground https://playground.babylonjs.com/#QYBWV4#25
  153. * @param x defines the first coordinate
  154. * @param y defines the second coordinate
  155. * @returns the current updated Vector2
  156. */
  157. copyFromFloats(x: number, y: number): this;
  158. /**
  159. * Sets the Vector2 coordinates with the given floats
  160. * Example Playground https://playground.babylonjs.com/#QYBWV4#62
  161. * @param x defines the first coordinate
  162. * @param y defines the second coordinate
  163. * @returns the current updated Vector2
  164. */
  165. set(x: number, y: number): this;
  166. /**
  167. * Copies the given float to the current Vector2 coordinates
  168. * @param v defines the x and y coordinates of the operand
  169. * @returns the current updated Vector2
  170. */
  171. setAll(v: number): this;
  172. /**
  173. * Add another vector with the current one
  174. * Example Playground https://playground.babylonjs.com/#QYBWV4#11
  175. * @param otherVector defines the other vector
  176. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  177. */
  178. add(otherVector: DeepImmutable<this>): this;
  179. /**
  180. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  181. * Example Playground https://playground.babylonjs.com/#QYBWV4#12
  182. * @param otherVector defines the other vector
  183. * @param result defines the target vector
  184. * @returns result input
  185. */
  186. addToRef<T extends this>(otherVector: DeepImmutable<this>, result: T): T;
  187. /**
  188. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  189. * Example Playground https://playground.babylonjs.com/#QYBWV4#13
  190. * @param otherVector defines the other vector
  191. * @returns the current updated Vector2
  192. */
  193. addInPlace(otherVector: DeepImmutable<this>): this;
  194. /**
  195. * Adds the given coordinates to the current Vector2
  196. * @param x defines the x coordinate of the operand
  197. * @param y defines the y coordinate of the operand
  198. * @returns the current updated Vector2
  199. */
  200. addInPlaceFromFloats(x: number, y: number): this;
  201. /**
  202. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  203. * Example Playground https://playground.babylonjs.com/#QYBWV4#14
  204. * @param otherVector defines the other vector
  205. * @returns a new Vector2
  206. */
  207. addVector3(otherVector: Vector3): this;
  208. /**
  209. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  210. * Example Playground https://playground.babylonjs.com/#QYBWV4#61
  211. * @param otherVector defines the other vector
  212. * @returns a new Vector2
  213. */
  214. subtract(otherVector: DeepImmutable<this>): this;
  215. /**
  216. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  217. * Example Playground https://playground.babylonjs.com/#QYBWV4#63
  218. * @param otherVector defines the other vector
  219. * @param result defines the target vector
  220. * @returns result input
  221. */
  222. subtractToRef<T extends this>(otherVector: DeepImmutable<this>, result: T): T;
  223. /**
  224. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  225. * Example Playground https://playground.babylonjs.com/#QYBWV4#88
  226. * @param otherVector defines the other vector
  227. * @returns the current updated Vector2
  228. */
  229. subtractInPlace(otherVector: DeepImmutable<this>): this;
  230. /**
  231. * Multiplies in place the current Vector2 coordinates by the given ones
  232. * Example Playground https://playground.babylonjs.com/#QYBWV4#43
  233. * @param otherVector defines the other vector
  234. * @returns the current updated Vector2
  235. */
  236. multiplyInPlace(otherVector: DeepImmutable<this>): this;
  237. /**
  238. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  239. * Example Playground https://playground.babylonjs.com/#QYBWV4#42
  240. * @param otherVector defines the other vector
  241. * @returns a new Vector2
  242. */
  243. multiply(otherVector: DeepImmutable<this>): this;
  244. /**
  245. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  246. * Example Playground https://playground.babylonjs.com/#QYBWV4#44
  247. * @param otherVector defines the other vector
  248. * @param result defines the target vector
  249. * @returns result input
  250. */
  251. multiplyToRef<T extends this>(otherVector: DeepImmutable<this>, result: T): T;
  252. /**
  253. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  254. * Example Playground https://playground.babylonjs.com/#QYBWV4#89
  255. * @param x defines the first coordinate
  256. * @param y defines the second coordinate
  257. * @returns a new Vector2
  258. */
  259. multiplyByFloats(x: number, y: number): this;
  260. /**
  261. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  262. * Example Playground https://playground.babylonjs.com/#QYBWV4#27
  263. * @param otherVector defines the other vector
  264. * @returns a new Vector2
  265. */
  266. divide(otherVector: DeepImmutable<this>): this;
  267. /**
  268. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  269. * Example Playground https://playground.babylonjs.com/#QYBWV4#30
  270. * @param otherVector defines the other vector
  271. * @param result defines the target vector
  272. * @returns result input
  273. */
  274. divideToRef<T extends this>(otherVector: DeepImmutable<this>, result: T): T;
  275. /**
  276. * Divides the current Vector2 coordinates by the given ones
  277. * Example Playground https://playground.babylonjs.com/#QYBWV4#28
  278. * @param otherVector defines the other vector
  279. * @returns the current updated Vector2
  280. */
  281. divideInPlace(otherVector: DeepImmutable<this>): this;
  282. /**
  283. * Updates the current Vector2 with the minimal coordinate values between its and the given vector ones
  284. * @param other defines the second operand
  285. * @returns the current updated Vector2
  286. */
  287. minimizeInPlace(other: DeepImmutable<this>): this;
  288. /**
  289. * Updates the current Vector2 with the maximal coordinate values between its and the given vector ones.
  290. * @param other defines the second operand
  291. * @returns the current updated Vector2
  292. */
  293. maximizeInPlace(other: DeepImmutable<this>): this;
  294. /**
  295. * Updates the current Vector2 with the minimal coordinate values between its and the given coordinates
  296. * @param x defines the x coordinate of the operand
  297. * @param y defines the y coordinate of the operand
  298. * @returns the current updated Vector2
  299. */
  300. minimizeInPlaceFromFloats(x: number, y: number): this;
  301. /**
  302. * Updates the current Vector2 with the maximal coordinate values between its and the given coordinates.
  303. * @param x defines the x coordinate of the operand
  304. * @param y defines the y coordinate of the operand
  305. * @returns the current updated Vector2
  306. */
  307. maximizeInPlaceFromFloats(x: number, y: number): this;
  308. /**
  309. * Returns a new Vector2 set with the subtraction of the given floats from the current Vector2 coordinates
  310. * @param x defines the x coordinate of the operand
  311. * @param y defines the y coordinate of the operand
  312. * @returns the resulting Vector2
  313. */
  314. subtractFromFloats(x: number, y: number): this;
  315. /**
  316. * Subtracts the given floats from the current Vector2 coordinates and set the given vector "result" with this result
  317. * @param x defines the x coordinate of the operand
  318. * @param y defines the y coordinate of the operand
  319. * @param result defines the Vector2 object where to store the result
  320. * @returns the result
  321. */
  322. subtractFromFloatsToRef<T extends this>(x: number, y: number, result: T): T;
  323. /**
  324. * Gets a new Vector2 with current Vector2 negated coordinates
  325. * @returns a new Vector2
  326. */
  327. negate(): this;
  328. /**
  329. * Negate this vector in place
  330. * Example Playground https://playground.babylonjs.com/#QYBWV4#23
  331. * @returns this
  332. */
  333. negateInPlace(): this;
  334. /**
  335. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  336. * Example Playground https://playground.babylonjs.com/#QYBWV4#41
  337. * @param result defines the Vector3 object where to store the result
  338. * @returns the result
  339. */
  340. negateToRef<T extends this>(result: T): T;
  341. /**
  342. * Multiply the Vector2 coordinates by
  343. * Example Playground https://playground.babylonjs.com/#QYBWV4#59
  344. * @param scale defines the scaling factor
  345. * @returns the current updated Vector2
  346. */
  347. scaleInPlace(scale: number): this;
  348. /**
  349. * Returns a new Vector2 scaled by "scale" from the current Vector2
  350. * Example Playground https://playground.babylonjs.com/#QYBWV4#52
  351. * @param scale defines the scaling factor
  352. * @returns a new Vector2
  353. */
  354. scale(scale: number): this;
  355. /**
  356. * Scale the current Vector2 values by a factor to a given Vector2
  357. * Example Playground https://playground.babylonjs.com/#QYBWV4#57
  358. * @param scale defines the scale factor
  359. * @param result defines the Vector2 object where to store the result
  360. * @returns result input
  361. */
  362. scaleToRef<T extends this>(scale: number, result: T): T;
  363. /**
  364. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  365. * Example Playground https://playground.babylonjs.com/#QYBWV4#58
  366. * @param scale defines the scale factor
  367. * @param result defines the Vector2 object where to store the result
  368. * @returns result input
  369. */
  370. scaleAndAddToRef<T extends this>(scale: number, result: T): T;
  371. /**
  372. * Gets a boolean if two vectors are equals
  373. * Example Playground https://playground.babylonjs.com/#QYBWV4#31
  374. * @param otherVector defines the other vector
  375. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  376. */
  377. equals(otherVector: DeepImmutable<this>): boolean;
  378. /**
  379. * Gets a boolean if two vectors are equals (using an epsilon value)
  380. * Example Playground https://playground.babylonjs.com/#QYBWV4#32
  381. * @param otherVector defines the other vector
  382. * @param epsilon defines the minimal distance to consider equality
  383. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  384. */
  385. equalsWithEpsilon(otherVector: DeepImmutable<this>, epsilon?: number): boolean;
  386. /**
  387. * Returns true if the current Vector2 coordinates equals the given floats
  388. * @param x defines the x coordinate of the operand
  389. * @param y defines the y coordinate of the operand
  390. * @returns true if both vectors are equal
  391. */
  392. equalsToFloats(x: number, y: number): boolean;
  393. /**
  394. * Gets a new Vector2 from current Vector2 floored values
  395. * Example Playground https://playground.babylonjs.com/#QYBWV4#35
  396. * eg (1.2, 2.31) returns (1, 2)
  397. * @returns a new Vector2
  398. */
  399. floor(): this;
  400. /**
  401. * Gets the current Vector2's floored values and stores them in result
  402. * @param result the Vector2 to store the result in
  403. * @returns the result Vector2
  404. */
  405. floorToRef<T extends this>(result: T): T;
  406. /**
  407. * Gets a new Vector2 from current Vector2 fractional values
  408. * Example Playground https://playground.babylonjs.com/#QYBWV4#34
  409. * eg (1.2, 2.31) returns (0.2, 0.31)
  410. * @returns a new Vector2
  411. */
  412. fract(): this;
  413. /**
  414. * Gets the current Vector2's fractional values and stores them in result
  415. * @param result the Vector2 to store the result in
  416. * @returns the result Vector2
  417. */
  418. fractToRef<T extends this>(result: T): T;
  419. /**
  420. * Rotate the current vector into a given result vector
  421. * Example Playground https://playground.babylonjs.com/#QYBWV4#49
  422. * @param angle defines the rotation angle
  423. * @param result defines the result vector where to store the rotated vector
  424. * @returns result input
  425. */
  426. rotateToRef<T extends this>(angle: number, result: T): T;
  427. /**
  428. * Gets the length of the vector
  429. * @returns the vector length (float)
  430. */
  431. length(): number;
  432. /**
  433. * Gets the vector squared length
  434. * @returns the vector squared length (float)
  435. */
  436. lengthSquared(): number;
  437. /**
  438. * Normalize the vector
  439. * Example Playground https://playground.babylonjs.com/#QYBWV4#48
  440. * @returns the current updated Vector2
  441. */
  442. normalize(): this;
  443. /**
  444. * Normalize the current Vector2 with the given input length.
  445. * Please note that this is an in place operation.
  446. * @param len the length of the vector
  447. * @returns the current updated Vector2
  448. */
  449. normalizeFromLength(len: number): this;
  450. /**
  451. * Normalize the current Vector2 to a new vector
  452. * @returns the new Vector2
  453. */
  454. normalizeToNew(): this;
  455. /**
  456. * Normalize the current Vector2 to the reference
  457. * @param reference define the Vector to update
  458. * @returns the updated Vector2
  459. */
  460. normalizeToRef<T extends this>(reference: T): T;
  461. /**
  462. * Gets a new Vector2 copied from the Vector2
  463. * Example Playground https://playground.babylonjs.com/#QYBWV4#20
  464. * @returns a new Vector2
  465. */
  466. clone(): this;
  467. /**
  468. * Gets the dot product of the current vector and the vector "otherVector"
  469. * @param otherVector defines second vector
  470. * @returns the dot product (float)
  471. */
  472. dot(otherVector: DeepImmutable<this>): number;
  473. /**
  474. * Gets a new Vector2(0, 0)
  475. * @returns a new Vector2
  476. */
  477. static Zero(): Vector2;
  478. /**
  479. * Gets a new Vector2(1, 1)
  480. * @returns a new Vector2
  481. */
  482. static One(): Vector2;
  483. /**
  484. * Returns a new Vector2 with random values between min and max
  485. * @param min the minimum random value
  486. * @param max the maximum random value
  487. * @returns a Vector2 with random values between min and max
  488. */
  489. static Random(min?: number, max?: number): Vector2;
  490. /**
  491. * Sets a Vector2 with random values between min and max
  492. * @param min the minimum random value
  493. * @param max the maximum random value
  494. * @param ref the ref to store the values in
  495. * @returns the ref with random values between min and max
  496. */
  497. static RandomToRef<T extends Vector2>(min: number | undefined, max: number | undefined, ref: T): T;
  498. /**
  499. * Gets a zero Vector2 that must not be updated
  500. */
  501. static get ZeroReadOnly(): DeepImmutable<Vector2>;
  502. /**
  503. * Gets a new Vector2 set from the given index element of the given array
  504. * Example Playground https://playground.babylonjs.com/#QYBWV4#79
  505. * @param array defines the data source
  506. * @param offset defines the offset in the data source
  507. * @returns a new Vector2
  508. */
  509. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  510. /**
  511. * Sets "result" from the given index element of the given array
  512. * Example Playground https://playground.babylonjs.com/#QYBWV4#80
  513. * @param array defines the data source
  514. * @param offset defines the offset in the data source
  515. * @param result defines the target vector
  516. * @returns result input
  517. */
  518. static FromArrayToRef<T extends Vector2>(array: DeepImmutable<ArrayLike<number>>, offset: number, result: T): T;
  519. /**
  520. * Sets the given vector "result" with the given floats.
  521. * @param x defines the x coordinate of the source
  522. * @param y defines the y coordinate of the source
  523. * @param result defines the Vector2 where to store the result
  524. * @returns the result vector
  525. */
  526. static FromFloatsToRef<T extends Vector2>(x: number, y: number, result: T): T;
  527. /**
  528. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  529. * Example Playground https://playground.babylonjs.com/#QYBWV4#65
  530. * @param value1 defines 1st point of control
  531. * @param value2 defines 2nd point of control
  532. * @param value3 defines 3rd point of control
  533. * @param value4 defines 4th point of control
  534. * @param amount defines the interpolation factor
  535. * @returns a new Vector2
  536. */
  537. static CatmullRom<T extends Vector2>(value1: DeepImmutable<T>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): T;
  538. /**
  539. * Sets reference with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  540. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  541. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  542. * @param value defines the value to clamp
  543. * @param min defines the lower limit
  544. * @param max defines the upper limit
  545. * @param ref the reference
  546. * @returns the reference
  547. */
  548. static ClampToRef<T extends Vector2>(value: DeepImmutable<T>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>, ref: T): T;
  549. /**
  550. * 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".
  551. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  552. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  553. * Example Playground https://playground.babylonjs.com/#QYBWV4#76
  554. * @param value defines the value to clamp
  555. * @param min defines the lower limit
  556. * @param max defines the upper limit
  557. * @returns a new Vector2
  558. */
  559. static Clamp<T extends Vector2>(value: DeepImmutable<T>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): T;
  560. /**
  561. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value2", "tangent1", "tangent2"
  562. * Example Playground https://playground.babylonjs.com/#QYBWV4#81
  563. * @param value1 defines the 1st control point
  564. * @param tangent1 defines the outgoing tangent
  565. * @param value2 defines the 2nd control point
  566. * @param tangent2 defines the incoming tangent
  567. * @param amount defines the interpolation factor
  568. * @returns a new Vector2
  569. */
  570. static Hermite<T extends Vector2>(value1: DeepImmutable<T>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): T;
  571. /**
  572. * Returns a new Vector2 which is the 1st derivative of the Hermite spline defined by the vectors "value1", "value2", "tangent1", "tangent2".
  573. * Example Playground https://playground.babylonjs.com/#QYBWV4#82
  574. * @param value1 defines the first control point
  575. * @param tangent1 defines the first tangent
  576. * @param value2 defines the second control point
  577. * @param tangent2 defines the second tangent
  578. * @param time define where the derivative must be done
  579. * @returns 1st derivative
  580. */
  581. static Hermite1stDerivative<T extends Vector2>(value1: DeepImmutable<T>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, time: number): T;
  582. /**
  583. * Returns a new Vector2 which is the 1st derivative of the Hermite spline defined by the vectors "value1", "value2", "tangent1", "tangent2".
  584. * Example Playground https://playground.babylonjs.com/#QYBWV4#83
  585. * @param value1 defines the first control point
  586. * @param tangent1 defines the first tangent
  587. * @param value2 defines the second control point
  588. * @param tangent2 defines the second tangent
  589. * @param time define where the derivative must be done
  590. * @param result define where the derivative will be stored
  591. * @returns result input
  592. */
  593. static Hermite1stDerivativeToRef<T extends Vector2>(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, time: number, result: T): T;
  594. /**
  595. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  596. * Example Playground https://playground.babylonjs.com/#QYBWV4#84
  597. * @param start defines the start vector
  598. * @param end defines the end vector
  599. * @param amount defines the interpolation factor
  600. * @returns a new Vector2
  601. */
  602. static Lerp<T extends Vector2>(start: DeepImmutable<T>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  603. /**
  604. * Gets the dot product of the vector "left" and the vector "right"
  605. * Example Playground https://playground.babylonjs.com/#QYBWV4#90
  606. * @param left defines first vector
  607. * @param right defines second vector
  608. * @returns the dot product (float)
  609. */
  610. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  611. /**
  612. * Returns a new Vector2 equal to the normalized given vector
  613. * Example Playground https://playground.babylonjs.com/#QYBWV4#46
  614. * @param vector defines the vector to normalize
  615. * @returns a new Vector2
  616. */
  617. static Normalize<T extends Vector2>(vector: DeepImmutable<T>): T;
  618. /**
  619. * Normalize a given vector into a second one
  620. * Example Playground https://playground.babylonjs.com/#QYBWV4#50
  621. * @param vector defines the vector to normalize
  622. * @param result defines the vector where to store the result
  623. * @returns result input
  624. */
  625. static NormalizeToRef<T extends Vector2>(vector: DeepImmutable<Vector2>, result: T): T;
  626. /**
  627. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  628. * Example Playground https://playground.babylonjs.com/#QYBWV4#86
  629. * @param left defines 1st vector
  630. * @param right defines 2nd vector
  631. * @returns a new Vector2
  632. */
  633. static Minimize<T extends Vector2>(left: DeepImmutable<T>, right: DeepImmutable<Vector2>): T;
  634. /**
  635. * Gets a new Vector2 set with the maximal coordinate values from the "left" and "right" vectors
  636. * Example Playground https://playground.babylonjs.com/#QYBWV4#86
  637. * @param left defines 1st vector
  638. * @param right defines 2nd vector
  639. * @returns a new Vector2
  640. */
  641. static Maximize<T extends Vector2>(left: DeepImmutable<T>, right: DeepImmutable<Vector2>): T;
  642. /**
  643. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  644. * Example Playground https://playground.babylonjs.com/#QYBWV4#17
  645. * @param vector defines the vector to transform
  646. * @param transformation defines the matrix to apply
  647. * @returns a new Vector2
  648. */
  649. static Transform<T extends Vector2>(vector: DeepImmutable<T>, transformation: DeepImmutable<Matrix>): T;
  650. /**
  651. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  652. * Example Playground https://playground.babylonjs.com/#QYBWV4#19
  653. * @param vector defines the vector to transform
  654. * @param transformation defines the matrix to apply
  655. * @param result defines the target vector
  656. * @returns result input
  657. */
  658. static TransformToRef<T extends Vector2>(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: T): T;
  659. /**
  660. * Determines if a given vector is included in a triangle
  661. * Example Playground https://playground.babylonjs.com/#QYBWV4#87
  662. * @param p defines the vector to test
  663. * @param p0 defines 1st triangle point
  664. * @param p1 defines 2nd triangle point
  665. * @param p2 defines 3rd triangle point
  666. * @returns true if the point "p" is in the triangle defined by the vectors "p0", "p1", "p2"
  667. */
  668. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  669. /**
  670. * Gets the distance between the vectors "value1" and "value2"
  671. * Example Playground https://playground.babylonjs.com/#QYBWV4#71
  672. * @param value1 defines first vector
  673. * @param value2 defines second vector
  674. * @returns the distance between vectors
  675. */
  676. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  677. /**
  678. * Returns the squared distance between the vectors "value1" and "value2"
  679. * Example Playground https://playground.babylonjs.com/#QYBWV4#72
  680. * @param value1 defines first vector
  681. * @param value2 defines second vector
  682. * @returns the squared distance between vectors
  683. */
  684. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  685. /**
  686. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  687. * Example Playground https://playground.babylonjs.com/#QYBWV4#86
  688. * Example Playground https://playground.babylonjs.com/#QYBWV4#66
  689. * @param value1 defines first vector
  690. * @param value2 defines second vector
  691. * @returns a new Vector2
  692. */
  693. static Center<T extends Vector2>(value1: DeepImmutable<T>, value2: DeepImmutable<Vector2>): T;
  694. /**
  695. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  696. * Example Playground https://playground.babylonjs.com/#QYBWV4#66
  697. * @param value1 defines first vector
  698. * @param value2 defines second vector
  699. * @param ref defines third vector
  700. * @returns ref
  701. */
  702. static CenterToRef<T extends Vector2>(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: T): T;
  703. /**
  704. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  705. * Example Playground https://playground.babylonjs.com/#QYBWV4#77
  706. * @param p defines the middle point
  707. * @param segA defines one point of the segment
  708. * @param segB defines the other point of the segment
  709. * @returns the shortest distance
  710. */
  711. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  712. }
  713. /**
  714. * Class used to store (x,y,z) vector representation
  715. * A Vector3 is the main object used in 3D geometry
  716. * It can represent either the coordinates of a point the space, either a direction
  717. * Reminder: js uses a left handed forward facing system
  718. * Example Playground - Overview - https://playground.babylonjs.com/#R1F8YU
  719. */
  720. export declare class Vector3 implements Vector<Tuple<number, 3>>, IVector3Like {
  721. private static _UpReadOnly;
  722. private static _DownReadOnly;
  723. private static _LeftHandedForwardReadOnly;
  724. private static _RightHandedForwardReadOnly;
  725. private static _LeftHandedBackwardReadOnly;
  726. private static _RightHandedBackwardReadOnly;
  727. private static _RightReadOnly;
  728. private static _LeftReadOnly;
  729. private static _ZeroReadOnly;
  730. private static _OneReadOnly;
  731. /**
  732. * @see Tensor.dimension
  733. */
  734. readonly dimension: Readonly<[3]>;
  735. /**
  736. * @see Tensor.rank
  737. */
  738. readonly rank: 1;
  739. /** @internal */
  740. _x: number;
  741. /** @internal */
  742. _y: number;
  743. /** @internal */
  744. _z: number;
  745. /** @internal */
  746. _isDirty: boolean;
  747. /** Gets or sets the x coordinate */
  748. get x(): number;
  749. set x(value: number);
  750. /** Gets or sets the y coordinate */
  751. get y(): number;
  752. set y(value: number);
  753. /** Gets or sets the z coordinate */
  754. get z(): number;
  755. set z(value: number);
  756. /**
  757. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  758. * @param x defines the first coordinates (on X axis)
  759. * @param y defines the second coordinates (on Y axis)
  760. * @param z defines the third coordinates (on Z axis)
  761. */
  762. constructor(x?: number, y?: number, z?: number);
  763. /**
  764. * Creates a string representation of the Vector3
  765. * Example Playground https://playground.babylonjs.com/#R1F8YU#67
  766. * @returns a string with the Vector3 coordinates.
  767. */
  768. toString(): string;
  769. /**
  770. * Gets the class name
  771. * @returns the string "Vector3"
  772. */
  773. getClassName(): string;
  774. /**
  775. * Creates the Vector3 hash code
  776. * @returns a number which tends to be unique between Vector3 instances
  777. */
  778. getHashCode(): number;
  779. /**
  780. * Creates an array containing three elements : the coordinates of the Vector3
  781. * Example Playground https://playground.babylonjs.com/#R1F8YU#10
  782. * @returns a new array of numbers
  783. */
  784. asArray(): Tuple<number, 3>;
  785. /**
  786. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  787. * Example Playground https://playground.babylonjs.com/#R1F8YU#65
  788. * @param array defines the destination array
  789. * @param index defines the offset in the destination array
  790. * @returns the current Vector3
  791. */
  792. toArray(array: FloatArray, index?: number): this;
  793. /**
  794. * Update the current vector from an array
  795. * Example Playground https://playground.babylonjs.com/#R1F8YU#24
  796. * @param array defines the destination array
  797. * @param offset defines the offset in the destination array
  798. * @returns the current Vector3
  799. */
  800. fromArray(array: DeepImmutable<FloatArray>, offset?: number): this;
  801. /**
  802. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  803. * Example Playground https://playground.babylonjs.com/#R1F8YU#66
  804. * @returns a new Quaternion object, computed from the Vector3 coordinates
  805. */
  806. toQuaternion(): Quaternion;
  807. /**
  808. * Adds the given vector to the current Vector3
  809. * Example Playground https://playground.babylonjs.com/#R1F8YU#4
  810. * @param otherVector defines the second operand
  811. * @returns the current updated Vector3
  812. */
  813. addInPlace(otherVector: DeepImmutable<Vector3>): this;
  814. /**
  815. * Adds the given coordinates to the current Vector3
  816. * Example Playground https://playground.babylonjs.com/#R1F8YU#5
  817. * @param x defines the x coordinate of the operand
  818. * @param y defines the y coordinate of the operand
  819. * @param z defines the z coordinate of the operand
  820. * @returns the current updated Vector3
  821. */
  822. addInPlaceFromFloats(x: number, y: number, z: number): this;
  823. /**
  824. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  825. * Example Playground https://playground.babylonjs.com/#R1F8YU#3
  826. * @param otherVector defines the second operand
  827. * @returns the resulting Vector3
  828. */
  829. add(otherVector: DeepImmutable<Vector3>): this;
  830. /**
  831. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  832. * Example Playground https://playground.babylonjs.com/#R1F8YU#6
  833. * @param otherVector defines the second operand
  834. * @param result defines the Vector3 object where to store the result
  835. * @returns the result
  836. */
  837. addToRef<T extends Vector3>(otherVector: DeepImmutable<Vector3>, result: T): T;
  838. /**
  839. * Subtract the given vector from the current Vector3
  840. * Example Playground https://playground.babylonjs.com/#R1F8YU#61
  841. * @param otherVector defines the second operand
  842. * @returns the current updated Vector3
  843. */
  844. subtractInPlace(otherVector: DeepImmutable<Vector3>): this;
  845. /**
  846. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  847. * Example Playground https://playground.babylonjs.com/#R1F8YU#60
  848. * @param otherVector defines the second operand
  849. * @returns the resulting Vector3
  850. */
  851. subtract(otherVector: DeepImmutable<Vector3>): this;
  852. /**
  853. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  854. * Example Playground https://playground.babylonjs.com/#R1F8YU#63
  855. * @param otherVector defines the second operand
  856. * @param result defines the Vector3 object where to store the result
  857. * @returns the result
  858. */
  859. subtractToRef<T extends Vector3>(otherVector: DeepImmutable<Vector3>, result: T): T;
  860. /**
  861. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  862. * Example Playground https://playground.babylonjs.com/#R1F8YU#62
  863. * @param x defines the x coordinate of the operand
  864. * @param y defines the y coordinate of the operand
  865. * @param z defines the z coordinate of the operand
  866. * @returns the resulting Vector3
  867. */
  868. subtractFromFloats(x: number, y: number, z: number): this;
  869. /**
  870. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  871. * Example Playground https://playground.babylonjs.com/#R1F8YU#64
  872. * @param x defines the x coordinate of the operand
  873. * @param y defines the y coordinate of the operand
  874. * @param z defines the z coordinate of the operand
  875. * @param result defines the Vector3 object where to store the result
  876. * @returns the result
  877. */
  878. subtractFromFloatsToRef<T extends Vector3>(x: number, y: number, z: number, result: T): T;
  879. /**
  880. * Gets a new Vector3 set with the current Vector3 negated coordinates
  881. * Example Playground https://playground.babylonjs.com/#R1F8YU#35
  882. * @returns a new Vector3
  883. */
  884. negate(): this;
  885. /**
  886. * Negate this vector in place
  887. * Example Playground https://playground.babylonjs.com/#R1F8YU#36
  888. * @returns this
  889. */
  890. negateInPlace(): this;
  891. /**
  892. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  893. * Example Playground https://playground.babylonjs.com/#R1F8YU#37
  894. * @param result defines the Vector3 object where to store the result
  895. * @returns the result
  896. */
  897. negateToRef<T extends Vector3 = Vector3>(result: T): T;
  898. /**
  899. * Multiplies the Vector3 coordinates by the float "scale"
  900. * Example Playground https://playground.babylonjs.com/#R1F8YU#56
  901. * @param scale defines the multiplier factor
  902. * @returns the current updated Vector3
  903. */
  904. scaleInPlace(scale: number): this;
  905. /**
  906. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  907. * Example Playground https://playground.babylonjs.com/#R1F8YU#53
  908. * @param scale defines the multiplier factor
  909. * @returns a new Vector3
  910. */
  911. scale(scale: number): this;
  912. /**
  913. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  914. * Example Playground https://playground.babylonjs.com/#R1F8YU#57
  915. * @param scale defines the multiplier factor
  916. * @param result defines the Vector3 object where to store the result
  917. * @returns the result
  918. */
  919. scaleToRef<T extends Vector3>(scale: number, result: T): T;
  920. /**
  921. * Creates a vector normal (perpendicular) to the current Vector3 and stores the result in the given vector
  922. * Out of the infinite possibilities the normal chosen is the one formed by rotating the current vector
  923. * 90 degrees about an axis which lies perpendicular to the current vector
  924. * and its projection on the xz plane. In the case of a current vector in the xz plane
  925. * the normal is calculated to be along the y axis.
  926. * Example Playground https://playground.babylonjs.com/#R1F8YU#230
  927. * Example Playground https://playground.babylonjs.com/#R1F8YU#231
  928. * @param result defines the Vector3 object where to store the resultant normal
  929. * @returns the result
  930. */
  931. getNormalToRef(result: Vector3): Vector3;
  932. /**
  933. * Rotates the vector using the given unit quaternion and stores the new vector in result
  934. * Example Playground https://playground.babylonjs.com/#R1F8YU#9
  935. * @param q the unit quaternion representing the rotation
  936. * @param result the output vector
  937. * @returns the result
  938. */
  939. applyRotationQuaternionToRef<T extends Vector3>(q: Quaternion, result: T): T;
  940. /**
  941. * Rotates the vector in place using the given unit quaternion
  942. * Example Playground https://playground.babylonjs.com/#R1F8YU#8
  943. * @param q the unit quaternion representing the rotation
  944. * @returns the current updated Vector3
  945. */
  946. applyRotationQuaternionInPlace(q: Quaternion): this;
  947. /**
  948. * Rotates the vector using the given unit quaternion and returns the new vector
  949. * Example Playground https://playground.babylonjs.com/#R1F8YU#7
  950. * @param q the unit quaternion representing the rotation
  951. * @returns a new Vector3
  952. */
  953. applyRotationQuaternion(q: Quaternion): this;
  954. /**
  955. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  956. * Example Playground https://playground.babylonjs.com/#R1F8YU#55
  957. * @param scale defines the scale factor
  958. * @param result defines the Vector3 object where to store the result
  959. * @returns result input
  960. */
  961. scaleAndAddToRef<T extends Vector3>(scale: number, result: T): T;
  962. /**
  963. * Projects the current point Vector3 to a plane along a ray starting from a specified origin and passing through the current point Vector3.
  964. * Example Playground https://playground.babylonjs.com/#R1F8YU#48
  965. * @param plane defines the plane to project to
  966. * @param origin defines the origin of the projection ray
  967. * @returns the projected vector3
  968. */
  969. projectOnPlane<T extends Vector3>(plane: Plane, origin: Vector3): T;
  970. /**
  971. * Projects the current point Vector3 to a plane along a ray starting from a specified origin and passing through the current point Vector3.
  972. * Example Playground https://playground.babylonjs.com/#R1F8YU#49
  973. * @param plane defines the plane to project to
  974. * @param origin defines the origin of the projection ray
  975. * @param result defines the Vector3 where to store the result
  976. * @returns result input
  977. */
  978. projectOnPlaneToRef<T extends Vector3>(plane: Plane, origin: Vector3, result: T): T;
  979. /**
  980. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  981. * Example Playground https://playground.babylonjs.com/#R1F8YU#19
  982. * @param otherVector defines the second operand
  983. * @returns true if both vectors are equals
  984. */
  985. equals(otherVector: DeepImmutable<Vector3>): boolean;
  986. /**
  987. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  988. * Example Playground https://playground.babylonjs.com/#R1F8YU#21
  989. * @param otherVector defines the second operand
  990. * @param epsilon defines the minimal distance to define values as equals
  991. * @returns true if both vectors are distant less than epsilon
  992. */
  993. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  994. /**
  995. * Returns true if the current Vector3 coordinates equals the given floats
  996. * Example Playground https://playground.babylonjs.com/#R1F8YU#20
  997. * @param x defines the x coordinate of the operand
  998. * @param y defines the y coordinate of the operand
  999. * @param z defines the z coordinate of the operand
  1000. * @returns true if both vectors are equal
  1001. */
  1002. equalsToFloats(x: number, y: number, z: number): boolean;
  1003. /**
  1004. * Multiplies the current Vector3 coordinates by the given ones
  1005. * Example Playground https://playground.babylonjs.com/#R1F8YU#32
  1006. * @param otherVector defines the second operand
  1007. * @returns the current updated Vector3
  1008. */
  1009. multiplyInPlace(otherVector: DeepImmutable<Vector3>): this;
  1010. /**
  1011. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1012. * Example Playground https://playground.babylonjs.com/#R1F8YU#31
  1013. * @param otherVector defines the second operand
  1014. * @returns the new Vector3
  1015. */
  1016. multiply(otherVector: DeepImmutable<Vector3>): this;
  1017. /**
  1018. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1019. * Example Playground https://playground.babylonjs.com/#R1F8YU#33
  1020. * @param otherVector defines the second operand
  1021. * @param result defines the Vector3 object where to store the result
  1022. * @returns the result
  1023. */
  1024. multiplyToRef<T extends Vector3>(otherVector: DeepImmutable<Vector3>, result: T): T;
  1025. /**
  1026. * Returns a new Vector3 set with the result of the multiplication of the current Vector3 coordinates by the given floats
  1027. * Example Playground https://playground.babylonjs.com/#R1F8YU#34
  1028. * @param x defines the x coordinate of the operand
  1029. * @param y defines the y coordinate of the operand
  1030. * @param z defines the z coordinate of the operand
  1031. * @returns the new Vector3
  1032. */
  1033. multiplyByFloats(x: number, y: number, z: number): this;
  1034. /**
  1035. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1036. * Example Playground https://playground.babylonjs.com/#R1F8YU#16
  1037. * @param otherVector defines the second operand
  1038. * @returns the new Vector3
  1039. */
  1040. divide(otherVector: DeepImmutable<Vector3>): this;
  1041. /**
  1042. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1043. * Example Playground https://playground.babylonjs.com/#R1F8YU#18
  1044. * @param otherVector defines the second operand
  1045. * @param result defines the Vector3 object where to store the result
  1046. * @returns the result
  1047. */
  1048. divideToRef<T extends Vector3>(otherVector: DeepImmutable<Vector3>, result: T): T;
  1049. /**
  1050. * Divides the current Vector3 coordinates by the given ones.
  1051. * Example Playground https://playground.babylonjs.com/#R1F8YU#17
  1052. * @param otherVector defines the second operand
  1053. * @returns the current updated Vector3
  1054. */
  1055. divideInPlace(otherVector: DeepImmutable<Vector3>): this;
  1056. /**
  1057. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1058. * Example Playground https://playground.babylonjs.com/#R1F8YU#29
  1059. * @param other defines the second operand
  1060. * @returns the current updated Vector3
  1061. */
  1062. minimizeInPlace(other: DeepImmutable<Vector3>): this;
  1063. /**
  1064. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1065. * Example Playground https://playground.babylonjs.com/#R1F8YU#27
  1066. * @param other defines the second operand
  1067. * @returns the current updated Vector3
  1068. */
  1069. maximizeInPlace(other: DeepImmutable<Vector3>): this;
  1070. /**
  1071. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1072. * Example Playground https://playground.babylonjs.com/#R1F8YU#30
  1073. * @param x defines the x coordinate of the operand
  1074. * @param y defines the y coordinate of the operand
  1075. * @param z defines the z coordinate of the operand
  1076. * @returns the current updated Vector3
  1077. */
  1078. minimizeInPlaceFromFloats(x: number, y: number, z: number): this;
  1079. /**
  1080. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1081. * Example Playground https://playground.babylonjs.com/#R1F8YU#28
  1082. * @param x defines the x coordinate of the operand
  1083. * @param y defines the y coordinate of the operand
  1084. * @param z defines the z coordinate of the operand
  1085. * @returns the current updated Vector3
  1086. */
  1087. maximizeInPlaceFromFloats(x: number, y: number, z: number): this;
  1088. /**
  1089. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1090. * Check if is non uniform within a certain amount of decimal places to account for this
  1091. * @param epsilon the amount the values can differ
  1092. * @returns if the vector is non uniform to a certain number of decimal places
  1093. */
  1094. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1095. /**
  1096. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1097. */
  1098. get isNonUniform(): boolean;
  1099. /**
  1100. * Gets the current Vector3's floored values and stores them in result
  1101. * @param result the vector to store the result in
  1102. * @returns the result vector
  1103. */
  1104. floorToRef<T extends this>(result: T): T;
  1105. /**
  1106. * Gets a new Vector3 from current Vector3 floored values
  1107. * Example Playground https://playground.babylonjs.com/#R1F8YU#22
  1108. * @returns a new Vector3
  1109. */
  1110. floor(): this;
  1111. /**
  1112. * Gets the current Vector3's fractional values and stores them in result
  1113. * @param result the vector to store the result in
  1114. * @returns the result vector
  1115. */
  1116. fractToRef<T extends this>(result: T): T;
  1117. /**
  1118. * Gets a new Vector3 from current Vector3 fractional values
  1119. * Example Playground https://playground.babylonjs.com/#R1F8YU#23
  1120. * @returns a new Vector3
  1121. */
  1122. fract(): this;
  1123. /**
  1124. * Gets the length of the Vector3
  1125. * Example Playground https://playground.babylonjs.com/#R1F8YU#25
  1126. * @returns the length of the Vector3
  1127. */
  1128. length(): number;
  1129. /**
  1130. * Gets the squared length of the Vector3
  1131. * Example Playground https://playground.babylonjs.com/#R1F8YU#26
  1132. * @returns squared length of the Vector3
  1133. */
  1134. lengthSquared(): number;
  1135. /**
  1136. * Gets a boolean indicating if the vector contains a zero in one of its components
  1137. * Example Playground https://playground.babylonjs.com/#R1F8YU#1
  1138. */
  1139. get hasAZeroComponent(): boolean;
  1140. /**
  1141. * Normalize the current Vector3.
  1142. * Please note that this is an in place operation.
  1143. * Example Playground https://playground.babylonjs.com/#R1F8YU#122
  1144. * @returns the current updated Vector3
  1145. */
  1146. normalize(): this;
  1147. /**
  1148. * Reorders the x y z properties of the vector in place
  1149. * Example Playground https://playground.babylonjs.com/#R1F8YU#44
  1150. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1151. * @returns the current updated vector
  1152. */
  1153. reorderInPlace(order: string): this;
  1154. /**
  1155. * Rotates the vector around 0,0,0 by a quaternion
  1156. * Example Playground https://playground.babylonjs.com/#R1F8YU#47
  1157. * @param quaternion the rotation quaternion
  1158. * @param result vector to store the result
  1159. * @returns the resulting vector
  1160. */
  1161. rotateByQuaternionToRef<T extends Vector3>(quaternion: Quaternion, result: T): T;
  1162. /**
  1163. * Rotates a vector around a given point
  1164. * Example Playground https://playground.babylonjs.com/#R1F8YU#46
  1165. * @param quaternion the rotation quaternion
  1166. * @param point the point to rotate around
  1167. * @param result vector to store the result
  1168. * @returns the resulting vector
  1169. */
  1170. rotateByQuaternionAroundPointToRef<T extends Vector3>(quaternion: Quaternion, point: Vector3, result: T): T;
  1171. /**
  1172. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1173. * The cross product is then orthogonal to both current and "other"
  1174. * Example Playground https://playground.babylonjs.com/#R1F8YU#14
  1175. * @param other defines the right operand
  1176. * @returns the cross product
  1177. */
  1178. cross(other: Vector3): this;
  1179. /**
  1180. * Normalize the current Vector3 with the given input length.
  1181. * Please note that this is an in place operation.
  1182. * Example Playground https://playground.babylonjs.com/#R1F8YU#123
  1183. * @param len the length of the vector
  1184. * @returns the current updated Vector3
  1185. */
  1186. normalizeFromLength(len: number): this;
  1187. /**
  1188. * Normalize the current Vector3 to a new vector
  1189. * Example Playground https://playground.babylonjs.com/#R1F8YU#124
  1190. * @returns the new Vector3
  1191. */
  1192. normalizeToNew(): this;
  1193. /**
  1194. * Normalize the current Vector3 to the reference
  1195. * Example Playground https://playground.babylonjs.com/#R1F8YU#125
  1196. * @param reference define the Vector3 to update
  1197. * @returns the updated Vector3
  1198. */
  1199. normalizeToRef<T extends Vector3>(reference: T): T;
  1200. /**
  1201. * Creates a new Vector3 copied from the current Vector3
  1202. * Example Playground https://playground.babylonjs.com/#R1F8YU#11
  1203. * @returns the new Vector3
  1204. */
  1205. clone(): this;
  1206. /**
  1207. * Copies the given vector coordinates to the current Vector3 ones
  1208. * Example Playground https://playground.babylonjs.com/#R1F8YU#12
  1209. * @param source defines the source Vector3
  1210. * @returns the current updated Vector3
  1211. */
  1212. copyFrom(source: DeepImmutable<Vector3>): this;
  1213. /**
  1214. * Copies the given floats to the current Vector3 coordinates
  1215. * Example Playground https://playground.babylonjs.com/#R1F8YU#13
  1216. * @param x defines the x coordinate of the operand
  1217. * @param y defines the y coordinate of the operand
  1218. * @param z defines the z coordinate of the operand
  1219. * @returns the current updated Vector3
  1220. */
  1221. copyFromFloats(x: number, y: number, z: number): this;
  1222. /**
  1223. * Copies the given floats to the current Vector3 coordinates
  1224. * Example Playground https://playground.babylonjs.com/#R1F8YU#58
  1225. * @param x defines the x coordinate of the operand
  1226. * @param y defines the y coordinate of the operand
  1227. * @param z defines the z coordinate of the operand
  1228. * @returns the current updated Vector3
  1229. */
  1230. set(x: number, y: number, z: number): this;
  1231. /**
  1232. * Copies the given float to the current Vector3 coordinates
  1233. * Example Playground https://playground.babylonjs.com/#R1F8YU#59
  1234. * @param v defines the x, y and z coordinates of the operand
  1235. * @returns the current updated Vector3
  1236. */
  1237. setAll(v: number): this;
  1238. /**
  1239. * Get the clip factor between two vectors
  1240. * Example Playground https://playground.babylonjs.com/#R1F8YU#126
  1241. * @param vector0 defines the first operand
  1242. * @param vector1 defines the second operand
  1243. * @param axis defines the axis to use
  1244. * @param size defines the size along the axis
  1245. * @returns the clip factor
  1246. */
  1247. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1248. /**
  1249. * Get angle between two vectors
  1250. * Example Playground https://playground.babylonjs.com/#R1F8YU#86
  1251. * @param vector0 the starting point
  1252. * @param vector1 the ending point
  1253. * @param normal direction of the normal
  1254. * @returns the angle between vector0 and vector1
  1255. */
  1256. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1257. /**
  1258. * Get angle between two vectors projected on a plane
  1259. * Example Playground https://playground.babylonjs.com/#R1F8YU#87
  1260. * Expectation compute time: 0.01 ms (median) and 0.02 ms (percentile 95%)
  1261. * @param vector0 angle between vector0 and vector1
  1262. * @param vector1 angle between vector0 and vector1
  1263. * @param normal Normal of the projection plane
  1264. * @returns the angle in radians (float) between vector0 and vector1 projected on the plane with the specified normal
  1265. */
  1266. static GetAngleBetweenVectorsOnPlane(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1267. /**
  1268. * Gets the rotation that aligns the roll axis (Y) to the line joining the start point to the target point and stores it in the ref Vector3
  1269. * Example PG https://playground.babylonjs.com/#R1F8YU#189
  1270. * @param start the starting point
  1271. * @param target the target point
  1272. * @param ref the vector3 to store the result
  1273. * @returns ref in the form (pitch, yaw, 0)
  1274. */
  1275. static PitchYawRollToMoveBetweenPointsToRef<T extends Vector3>(start: Vector3, target: Vector3, ref: T): T;
  1276. /**
  1277. * Gets the rotation that aligns the roll axis (Y) to the line joining the start point to the target point
  1278. * Example PG https://playground.babylonjs.com/#R1F8YU#188
  1279. * @param start the starting point
  1280. * @param target the target point
  1281. * @returns the rotation in the form (pitch, yaw, 0)
  1282. */
  1283. static PitchYawRollToMoveBetweenPoints(start: Vector3, target: Vector3): Vector3;
  1284. /**
  1285. * Slerp between two vectors. See also `SmoothToRef`
  1286. * Slerp is a spherical linear interpolation
  1287. * giving a slow in and out effect
  1288. * Example Playground 1 https://playground.babylonjs.com/#R1F8YU#108
  1289. * Example Playground 2 https://playground.babylonjs.com/#R1F8YU#109
  1290. * @param vector0 Start vector
  1291. * @param vector1 End vector
  1292. * @param slerp amount (will be clamped between 0 and 1)
  1293. * @param result The slerped vector
  1294. * @returns The slerped vector
  1295. */
  1296. static SlerpToRef<T extends Vector3 = Vector3>(vector0: Vector3, vector1: Vector3, slerp: number, result: T): T;
  1297. /**
  1298. * Smooth interpolation between two vectors using Slerp
  1299. * Example Playground https://playground.babylonjs.com/#R1F8YU#110
  1300. * @param source source vector
  1301. * @param goal goal vector
  1302. * @param deltaTime current interpolation frame
  1303. * @param lerpTime total interpolation time
  1304. * @param result the smoothed vector
  1305. * @returns the smoothed vector
  1306. */
  1307. static SmoothToRef<T extends Vector3 = Vector3>(source: Vector3, goal: Vector3, deltaTime: number, lerpTime: number, result: T): T;
  1308. /**
  1309. * Returns a new Vector3 set from the index "offset" of the given array
  1310. * Example Playground https://playground.babylonjs.com/#R1F8YU#83
  1311. * @param array defines the source array
  1312. * @param offset defines the offset in the source array
  1313. * @returns the new Vector3
  1314. */
  1315. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1316. /**
  1317. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1318. * @param array defines the source array
  1319. * @param offset defines the offset in the source array
  1320. * @returns the new Vector3
  1321. * @deprecated Please use FromArray instead.
  1322. */
  1323. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1324. /**
  1325. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1326. * Example Playground https://playground.babylonjs.com/#R1F8YU#84
  1327. * @param array defines the source array
  1328. * @param offset defines the offset in the source array
  1329. * @param result defines the Vector3 where to store the result
  1330. * @returns result input
  1331. */
  1332. static FromArrayToRef<T extends Vector3>(array: DeepImmutable<ArrayLike<number>>, offset: number, result: T): T;
  1333. /**
  1334. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1335. * @param array defines the source array
  1336. * @param offset defines the offset in the source array
  1337. * @param result defines the Vector3 where to store the result
  1338. * @deprecated Please use FromArrayToRef instead.
  1339. * @returns result input
  1340. */
  1341. static FromFloatArrayToRef<T extends Vector3>(array: DeepImmutable<Float32Array>, offset: number, result: T): T;
  1342. /**
  1343. * Sets the given vector "result" with the given floats.
  1344. * Example Playground https://playground.babylonjs.com/#R1F8YU#85
  1345. * @param x defines the x coordinate of the source
  1346. * @param y defines the y coordinate of the source
  1347. * @param z defines the z coordinate of the source
  1348. * @param result defines the Vector3 where to store the result
  1349. * @returns the result vector
  1350. */
  1351. static FromFloatsToRef<T extends Vector3 = Vector3>(x: number, y: number, z: number, result: T): T;
  1352. /**
  1353. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1354. * @returns a new empty Vector3
  1355. */
  1356. static Zero(): Vector3;
  1357. /**
  1358. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1359. * @returns a new Vector3
  1360. */
  1361. static One(): Vector3;
  1362. /**
  1363. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1364. * Example Playground https://playground.babylonjs.com/#R1F8YU#71
  1365. * @returns a new up Vector3
  1366. */
  1367. static Up(): Vector3;
  1368. /**
  1369. * Gets an up Vector3 that must not be updated
  1370. */
  1371. static get UpReadOnly(): DeepImmutable<Vector3>;
  1372. /**
  1373. * Gets a down Vector3 that must not be updated
  1374. */
  1375. static get DownReadOnly(): DeepImmutable<Vector3>;
  1376. /**
  1377. * Gets a right Vector3 that must not be updated
  1378. */
  1379. static get RightReadOnly(): DeepImmutable<Vector3>;
  1380. /**
  1381. * Gets a left Vector3 that must not be updated
  1382. */
  1383. static get LeftReadOnly(): DeepImmutable<Vector3>;
  1384. /**
  1385. * Gets a forward Vector3 that must not be updated
  1386. */
  1387. static get LeftHandedForwardReadOnly(): DeepImmutable<Vector3>;
  1388. /**
  1389. * Gets a forward Vector3 that must not be updated
  1390. */
  1391. static get RightHandedForwardReadOnly(): DeepImmutable<Vector3>;
  1392. /**
  1393. * Gets a backward Vector3 that must not be updated
  1394. */
  1395. static get LeftHandedBackwardReadOnly(): DeepImmutable<Vector3>;
  1396. /**
  1397. * Gets a backward Vector3 that must not be updated
  1398. */
  1399. static get RightHandedBackwardReadOnly(): DeepImmutable<Vector3>;
  1400. /**
  1401. * Gets a zero Vector3 that must not be updated
  1402. */
  1403. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  1404. /**
  1405. * Gets a one Vector3 that must not be updated
  1406. */
  1407. static get OneReadOnly(): DeepImmutable<Vector3>;
  1408. /**
  1409. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1410. * Example Playground https://playground.babylonjs.com/#R1F8YU#71
  1411. * @returns a new down Vector3
  1412. */
  1413. static Down(): Vector3;
  1414. /**
  1415. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1416. * Example Playground https://playground.babylonjs.com/#R1F8YU#71
  1417. * @param rightHandedSystem is the scene right-handed (negative z)
  1418. * @returns a new forward Vector3
  1419. */
  1420. static Forward(rightHandedSystem?: boolean): Vector3;
  1421. /**
  1422. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1423. * Example Playground https://playground.babylonjs.com/#R1F8YU#71
  1424. * @param rightHandedSystem is the scene right-handed (negative-z)
  1425. * @returns a new Backward Vector3
  1426. */
  1427. static Backward(rightHandedSystem?: boolean): Vector3;
  1428. /**
  1429. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1430. * Example Playground https://playground.babylonjs.com/#R1F8YU#71
  1431. * @returns a new right Vector3
  1432. */
  1433. static Right(): Vector3;
  1434. /**
  1435. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1436. * Example Playground https://playground.babylonjs.com/#R1F8YU#71
  1437. * @returns a new left Vector3
  1438. */
  1439. static Left(): Vector3;
  1440. /**
  1441. * Returns a new Vector3 with random values between min and max
  1442. * @param min the minimum random value
  1443. * @param max the maximum random value
  1444. * @returns a Vector3 with random values between min and max
  1445. */
  1446. static Random(min?: number, max?: number): Vector3;
  1447. /**
  1448. * Sets a Vector3 with random values between min and max
  1449. * @param min the minimum random value
  1450. * @param max the maximum random value
  1451. * @param ref the ref to store the values in
  1452. * @returns the ref with random values between min and max
  1453. */
  1454. static RandomToRef<T extends Vector3>(min: number | undefined, max: number | undefined, ref: T): T;
  1455. /**
  1456. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1457. * This method computes transformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1458. * Example Playground https://playground.babylonjs.com/#R1F8YU#111
  1459. * @param vector defines the Vector3 to transform
  1460. * @param transformation defines the transformation matrix
  1461. * @returns the transformed Vector3
  1462. */
  1463. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1464. /**
  1465. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1466. * This method computes transformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1467. * Example Playground https://playground.babylonjs.com/#R1F8YU#113
  1468. * @param vector defines the Vector3 to transform
  1469. * @param transformation defines the transformation matrix
  1470. * @param result defines the Vector3 where to store the result
  1471. * @returns result input
  1472. */
  1473. static TransformCoordinatesToRef<T extends Vector3>(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: T): T;
  1474. /**
  1475. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1476. * This method computes transformed coordinates only, not transformed direction vectors
  1477. * Example Playground https://playground.babylonjs.com/#R1F8YU#115
  1478. * @param x define the x coordinate of the source vector
  1479. * @param y define the y coordinate of the source vector
  1480. * @param z define the z coordinate of the source vector
  1481. * @param transformation defines the transformation matrix
  1482. * @param result defines the Vector3 where to store the result
  1483. * @returns result input
  1484. */
  1485. static TransformCoordinatesFromFloatsToRef<T extends Vector3>(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: T): T;
  1486. /**
  1487. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1488. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1489. * Example Playground https://playground.babylonjs.com/#R1F8YU#112
  1490. * @param vector defines the Vector3 to transform
  1491. * @param transformation defines the transformation matrix
  1492. * @returns the new Vector3
  1493. */
  1494. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1495. /**
  1496. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1497. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1498. * Example Playground https://playground.babylonjs.com/#R1F8YU#114
  1499. * @param vector defines the Vector3 to transform
  1500. * @param transformation defines the transformation matrix
  1501. * @param result defines the Vector3 where to store the result
  1502. * @returns result input
  1503. */
  1504. static TransformNormalToRef<T extends Vector3>(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: T): T;
  1505. /**
  1506. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1507. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1508. * Example Playground https://playground.babylonjs.com/#R1F8YU#116
  1509. * @param x define the x coordinate of the source vector
  1510. * @param y define the y coordinate of the source vector
  1511. * @param z define the z coordinate of the source vector
  1512. * @param transformation defines the transformation matrix
  1513. * @param result defines the Vector3 where to store the result
  1514. * @returns result input
  1515. */
  1516. static TransformNormalFromFloatsToRef<T extends Vector3>(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: T): T;
  1517. /**
  1518. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1519. * Example Playground https://playground.babylonjs.com/#R1F8YU#69
  1520. * @param value1 defines the first control point
  1521. * @param value2 defines the second control point
  1522. * @param value3 defines the third control point
  1523. * @param value4 defines the fourth control point
  1524. * @param amount defines the amount on the spline to use
  1525. * @returns the new Vector3
  1526. */
  1527. static CatmullRom<T extends Vector3>(value1: DeepImmutable<T>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): T;
  1528. /**
  1529. * 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"
  1530. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1531. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1532. * Example Playground https://playground.babylonjs.com/#R1F8YU#76
  1533. * @param value defines the current value
  1534. * @param min defines the lower range value
  1535. * @param max defines the upper range value
  1536. * @returns the new Vector3
  1537. */
  1538. static Clamp<T extends Vector3>(value: DeepImmutable<T>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): T;
  1539. /**
  1540. * 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"
  1541. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1542. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1543. * Example Playground https://playground.babylonjs.com/#R1F8YU#77
  1544. * @param value defines the current value
  1545. * @param min defines the lower range value
  1546. * @param max defines the upper range value
  1547. * @param result defines the Vector3 where to store the result
  1548. * @returns result input
  1549. */
  1550. static ClampToRef<T extends Vector3>(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: T): T;
  1551. /**
  1552. * Checks if a given vector is inside a specific range
  1553. * Example Playground https://playground.babylonjs.com/#R1F8YU#75
  1554. * @param v defines the vector to test
  1555. * @param min defines the minimum range
  1556. * @param max defines the maximum range
  1557. */
  1558. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1559. /**
  1560. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1561. * Example Playground https://playground.babylonjs.com/#R1F8YU#89
  1562. * @param value1 defines the first control point
  1563. * @param tangent1 defines the first tangent vector
  1564. * @param value2 defines the second control point
  1565. * @param tangent2 defines the second tangent vector
  1566. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1567. * @returns the new Vector3
  1568. */
  1569. static Hermite<T extends Vector3>(value1: DeepImmutable<T>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): T;
  1570. /**
  1571. * Returns a new Vector3 which is the 1st derivative of the Hermite spline defined by the vectors "value1", "value2", "tangent1", "tangent2".
  1572. * Example Playground https://playground.babylonjs.com/#R1F8YU#90
  1573. * @param value1 defines the first control point
  1574. * @param tangent1 defines the first tangent
  1575. * @param value2 defines the second control point
  1576. * @param tangent2 defines the second tangent
  1577. * @param time define where the derivative must be done
  1578. * @returns 1st derivative
  1579. */
  1580. static Hermite1stDerivative<T extends Vector3>(value1: DeepImmutable<T>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, time: number): T;
  1581. /**
  1582. * Update a Vector3 with the 1st derivative of the Hermite spline defined by the vectors "value1", "value2", "tangent1", "tangent2".
  1583. * Example Playground https://playground.babylonjs.com/#R1F8YU#91
  1584. * @param value1 defines the first control point
  1585. * @param tangent1 defines the first tangent
  1586. * @param value2 defines the second control point
  1587. * @param tangent2 defines the second tangent
  1588. * @param time define where the derivative must be done
  1589. * @param result define where to store the derivative
  1590. * @returns result input
  1591. */
  1592. static Hermite1stDerivativeToRef<T extends Vector3>(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, time: number, result: T): T;
  1593. /**
  1594. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1595. * Example Playground https://playground.babylonjs.com/#R1F8YU#95
  1596. * @param start defines the start value
  1597. * @param end defines the end value
  1598. * @param amount max defines amount between both (between 0 and 1)
  1599. * @returns the new Vector3
  1600. */
  1601. static Lerp<T extends Vector3>(start: DeepImmutable<T>, end: DeepImmutable<Vector3>, amount: number): T;
  1602. /**
  1603. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1604. * Example Playground https://playground.babylonjs.com/#R1F8YU#93
  1605. * @param start defines the start value
  1606. * @param end defines the end value
  1607. * @param amount max defines amount between both (between 0 and 1)
  1608. * @param result defines the Vector3 where to store the result
  1609. * @returns result input
  1610. */
  1611. static LerpToRef<T extends Vector3>(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: T): T;
  1612. /**
  1613. * Returns the dot product (float) between the vectors "left" and "right"
  1614. * Example Playground https://playground.babylonjs.com/#R1F8YU#82
  1615. * @param left defines the left operand
  1616. * @param right defines the right operand
  1617. * @returns the dot product
  1618. */
  1619. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1620. /**
  1621. * Returns the dot product (float) between the current vectors and "otherVector"
  1622. * @param otherVector defines the right operand
  1623. * @returns the dot product
  1624. */
  1625. dot(otherVector: DeepImmutable<this>): number;
  1626. /**
  1627. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1628. * The cross product is then orthogonal to both "left" and "right"
  1629. * Example Playground https://playground.babylonjs.com/#R1F8YU#15
  1630. * @param left defines the left operand
  1631. * @param right defines the right operand
  1632. * @returns the cross product
  1633. */
  1634. static Cross<T extends Vector3>(left: DeepImmutable<T>, right: DeepImmutable<Vector3>): T;
  1635. /**
  1636. * Sets the given vector "result" with the cross product of "left" and "right"
  1637. * The cross product is then orthogonal to both "left" and "right"
  1638. * Example Playground https://playground.babylonjs.com/#R1F8YU#78
  1639. * @param left defines the left operand
  1640. * @param right defines the right operand
  1641. * @param result defines the Vector3 where to store the result
  1642. * @returns result input
  1643. */
  1644. static CrossToRef<T extends Vector3>(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: T): T;
  1645. /**
  1646. * Returns a new Vector3 as the normalization of the given vector
  1647. * Example Playground https://playground.babylonjs.com/#R1F8YU#98
  1648. * @param vector defines the Vector3 to normalize
  1649. * @returns the new Vector3
  1650. */
  1651. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1652. /**
  1653. * Sets the given vector "result" with the normalization of the given first vector
  1654. * Example Playground https://playground.babylonjs.com/#R1F8YU#98
  1655. * @param vector defines the Vector3 to normalize
  1656. * @param result defines the Vector3 where to store the result
  1657. * @returns result input
  1658. */
  1659. static NormalizeToRef<T extends Vector3>(vector: DeepImmutable<Vector3>, result: T): T;
  1660. /**
  1661. * Project a Vector3 onto screen space
  1662. * Example Playground https://playground.babylonjs.com/#R1F8YU#101
  1663. * @param vector defines the Vector3 to project
  1664. * @param world defines the world matrix to use
  1665. * @param transform defines the transform (view x projection) matrix to use
  1666. * @param viewport defines the screen viewport to use
  1667. * @returns the new Vector3
  1668. */
  1669. static Project<T extends Vector3>(vector: DeepImmutable<T>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): T;
  1670. /**
  1671. * Project a Vector3 onto screen space to reference
  1672. * Example Playground https://playground.babylonjs.com/#R1F8YU#102
  1673. * @param vector defines the Vector3 to project
  1674. * @param world defines the world matrix to use
  1675. * @param transform defines the transform (view x projection) matrix to use
  1676. * @param viewport defines the screen viewport to use
  1677. * @param result the vector in which the screen space will be stored
  1678. * @returns result input
  1679. */
  1680. static ProjectToRef<T extends Vector3>(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: T): T;
  1681. /**
  1682. * Reflects a vector off the plane defined by a normalized normal
  1683. * @param inDirection defines the vector direction
  1684. * @param normal defines the normal - Must be normalized
  1685. * @returns the resulting vector
  1686. */
  1687. static Reflect(inDirection: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Vector3;
  1688. /**
  1689. * Reflects a vector off the plane defined by a normalized normal to reference
  1690. * @param inDirection defines the vector direction
  1691. * @param normal defines the normal - Must be normalized
  1692. * @param ref defines the Vector3 where to store the result
  1693. * @returns the resulting vector
  1694. */
  1695. static ReflectToRef<T extends Vector3>(inDirection: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, ref: T): T;
  1696. /**
  1697. * @internal
  1698. */
  1699. static _UnprojectFromInvertedMatrixToRef<T extends Vector3>(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: T): T;
  1700. /**
  1701. * Unproject from screen space to object space
  1702. * Example Playground https://playground.babylonjs.com/#R1F8YU#121
  1703. * @param source defines the screen space Vector3 to use
  1704. * @param viewportWidth defines the current width of the viewport
  1705. * @param viewportHeight defines the current height of the viewport
  1706. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1707. * @param transform defines the transform (view x projection) matrix to use
  1708. * @returns the new Vector3
  1709. */
  1710. static UnprojectFromTransform<T extends Vector3>(source: DeepImmutable<T>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): T;
  1711. /**
  1712. * Unproject from screen space to object space
  1713. * Example Playground https://playground.babylonjs.com/#R1F8YU#117
  1714. * @param source defines the screen space Vector3 to use
  1715. * @param viewportWidth defines the current width of the viewport
  1716. * @param viewportHeight defines the current height of the viewport
  1717. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1718. * @param view defines the view matrix to use
  1719. * @param projection defines the projection matrix to use
  1720. * @returns the new Vector3
  1721. */
  1722. static Unproject<T extends Vector3>(source: DeepImmutable<T>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): T;
  1723. /**
  1724. * Unproject from screen space to object space
  1725. * Example Playground https://playground.babylonjs.com/#R1F8YU#119
  1726. * @param source defines the screen space Vector3 to use
  1727. * @param viewportWidth defines the current width of the viewport
  1728. * @param viewportHeight defines the current height of the viewport
  1729. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1730. * @param view defines the view matrix to use
  1731. * @param projection defines the projection matrix to use
  1732. * @param result defines the Vector3 where to store the result
  1733. * @returns result input
  1734. */
  1735. static UnprojectToRef<T extends Vector3>(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: T): T;
  1736. /**
  1737. * Unproject from screen space to object space
  1738. * Example Playground https://playground.babylonjs.com/#R1F8YU#120
  1739. * @param sourceX defines the screen space x coordinate to use
  1740. * @param sourceY defines the screen space y coordinate to use
  1741. * @param sourceZ defines the screen space z coordinate to use
  1742. * @param viewportWidth defines the current width of the viewport
  1743. * @param viewportHeight defines the current height of the viewport
  1744. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1745. * @param view defines the view matrix to use
  1746. * @param projection defines the projection matrix to use
  1747. * @param result defines the Vector3 where to store the result
  1748. * @returns result input
  1749. */
  1750. static UnprojectFloatsToRef<T extends Vector3>(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: T): T;
  1751. /**
  1752. * Gets the minimal coordinate values between two Vector3
  1753. * Example Playground https://playground.babylonjs.com/#R1F8YU#97
  1754. * @param left defines the first operand
  1755. * @param right defines the second operand
  1756. * @returns the new Vector3
  1757. */
  1758. static Minimize<T extends Vector3>(left: DeepImmutable<T>, right: DeepImmutable<Vector3>): T;
  1759. /**
  1760. * Gets the maximal coordinate values between two Vector3
  1761. * Example Playground https://playground.babylonjs.com/#R1F8YU#96
  1762. * @param left defines the first operand
  1763. * @param right defines the second operand
  1764. * @returns the new Vector3
  1765. */
  1766. static Maximize<T extends Vector3>(left: DeepImmutable<T>, right: DeepImmutable<Vector3>): T;
  1767. /**
  1768. * Returns the distance between the vectors "value1" and "value2"
  1769. * Example Playground https://playground.babylonjs.com/#R1F8YU#81
  1770. * @param value1 defines the first operand
  1771. * @param value2 defines the second operand
  1772. * @returns the distance
  1773. */
  1774. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1775. /**
  1776. * Returns the squared distance between the vectors "value1" and "value2"
  1777. * Example Playground https://playground.babylonjs.com/#R1F8YU#80
  1778. * @param value1 defines the first operand
  1779. * @param value2 defines the second operand
  1780. * @returns the squared distance
  1781. */
  1782. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1783. /**
  1784. * Projects "vector" on the triangle determined by its extremities "p0", "p1" and "p2", stores the result in "ref"
  1785. * and returns the distance to the projected point.
  1786. * Example Playground https://playground.babylonjs.com/#R1F8YU#104
  1787. * From http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.104.4264&rep=rep1&type=pdf
  1788. *
  1789. * @param vector the vector to get distance from
  1790. * @param p0 extremity of the triangle
  1791. * @param p1 extremity of the triangle
  1792. * @param p2 extremity of the triangle
  1793. * @param ref variable to store the result to
  1794. * @returns The distance between "ref" and "vector"
  1795. */
  1796. static ProjectOnTriangleToRef(vector: DeepImmutable<Vector3>, p0: DeepImmutable<Vector3>, p1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, ref: Vector3): number;
  1797. /**
  1798. * Returns a new Vector3 located at the center between "value1" and "value2"
  1799. * Example Playground https://playground.babylonjs.com/#R1F8YU#72
  1800. * @param value1 defines the first operand
  1801. * @param value2 defines the second operand
  1802. * @returns the new Vector3
  1803. */
  1804. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1805. /**
  1806. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  1807. * Example Playground https://playground.babylonjs.com/#R1F8YU#73
  1808. * @param value1 defines first vector
  1809. * @param value2 defines second vector
  1810. * @param ref defines third vector
  1811. * @returns ref
  1812. */
  1813. static CenterToRef<T extends Vector3>(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: T): T;
  1814. /**
  1815. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1816. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1817. * to something in order to rotate it from its local system to the given target system
  1818. * Note: axis1, axis2 and axis3 are normalized during this operation
  1819. * Example Playground https://playground.babylonjs.com/#R1F8YU#106
  1820. * @param axis1 defines the first axis
  1821. * @param axis2 defines the second axis
  1822. * @param axis3 defines the third axis
  1823. * @returns a new Vector3
  1824. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/transforms/center_origin/target_align
  1825. */
  1826. static RotationFromAxis<T extends Vector3>(axis1: DeepImmutable<T>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): T;
  1827. /**
  1828. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1829. * Example Playground https://playground.babylonjs.com/#R1F8YU#107
  1830. * @param axis1 defines the first axis
  1831. * @param axis2 defines the second axis
  1832. * @param axis3 defines the third axis
  1833. * @param ref defines the Vector3 where to store the result
  1834. * @returns result input
  1835. */
  1836. static RotationFromAxisToRef<T extends Vector3>(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: T): T;
  1837. }
  1838. /**
  1839. * Vector4 class created for EulerAngle class conversion to Quaternion
  1840. */
  1841. export declare class Vector4 implements Vector<Tuple<number, 4>>, IVector4Like {
  1842. /** x value of the vector */
  1843. x: number;
  1844. /** y value of the vector */
  1845. y: number;
  1846. /** z value of the vector */
  1847. z: number;
  1848. /** w value of the vector */
  1849. w: number;
  1850. private static _ZeroReadOnly;
  1851. /**
  1852. * @see Tensor.dimension
  1853. */
  1854. readonly dimension: Readonly<[4]>;
  1855. /**
  1856. * @see Tensor.rank
  1857. */
  1858. readonly rank: 1;
  1859. /**
  1860. * Creates a Vector4 object from the given floats.
  1861. * @param x x value of the vector
  1862. * @param y y value of the vector
  1863. * @param z z value of the vector
  1864. * @param w w value of the vector
  1865. */
  1866. constructor(
  1867. /** x value of the vector */
  1868. x?: number,
  1869. /** y value of the vector */
  1870. y?: number,
  1871. /** z value of the vector */
  1872. z?: number,
  1873. /** w value of the vector */
  1874. w?: number);
  1875. /**
  1876. * Returns the string with the Vector4 coordinates.
  1877. * @returns a string containing all the vector values
  1878. */
  1879. toString(): string;
  1880. /**
  1881. * Returns the string "Vector4".
  1882. * @returns "Vector4"
  1883. */
  1884. getClassName(): string;
  1885. /**
  1886. * Returns the Vector4 hash code.
  1887. * @returns a unique hash code
  1888. */
  1889. getHashCode(): number;
  1890. /**
  1891. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1892. * @returns the resulting array
  1893. */
  1894. asArray(): Tuple<number, 4>;
  1895. /**
  1896. * Populates the given array from the given index with the Vector4 coordinates.
  1897. * @param array array to populate
  1898. * @param index index of the array to start at (default: 0)
  1899. * @returns the Vector4.
  1900. */
  1901. toArray(array: FloatArray, index?: number): this;
  1902. /**
  1903. * Update the current vector from an array
  1904. * @param array defines the destination array
  1905. * @param offset defines the offset in the destination array
  1906. * @returns the current Vector3
  1907. */
  1908. fromArray(array: FloatArray, offset?: number): this;
  1909. /**
  1910. * Adds the given vector to the current Vector4.
  1911. * @param otherVector the vector to add
  1912. * @returns the updated Vector4.
  1913. */
  1914. addInPlace(otherVector: DeepImmutable<Vector4>): this;
  1915. /**
  1916. * Adds the given coordinates to the current Vector4
  1917. * @param x defines the x coordinate of the operand
  1918. * @param y defines the y coordinate of the operand
  1919. * @param z defines the z coordinate of the operand
  1920. * @param w defines the w coordinate of the operand
  1921. * @returns the current updated Vector4
  1922. */
  1923. addInPlaceFromFloats(x: number, y: number, z: number, w: number): this;
  1924. /**
  1925. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1926. * @param otherVector the vector to add
  1927. * @returns the resulting vector
  1928. */
  1929. add(otherVector: DeepImmutable<Vector4>): this;
  1930. /**
  1931. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1932. * @param otherVector the vector to add
  1933. * @param result the vector to store the result
  1934. * @returns result input
  1935. */
  1936. addToRef<T extends Vector4>(otherVector: DeepImmutable<Vector4>, result: T): T;
  1937. /**
  1938. * Subtract in place the given vector from the current Vector4.
  1939. * @param otherVector the vector to subtract
  1940. * @returns the updated Vector4.
  1941. */
  1942. subtractInPlace(otherVector: DeepImmutable<Vector4>): this;
  1943. /**
  1944. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  1945. * @param otherVector the vector to add
  1946. * @returns the new vector with the result
  1947. */
  1948. subtract(otherVector: DeepImmutable<Vector4>): this;
  1949. /**
  1950. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  1951. * @param otherVector the vector to subtract
  1952. * @param result the vector to store the result
  1953. * @returns result input
  1954. */
  1955. subtractToRef<T extends Vector4>(otherVector: DeepImmutable<Vector4>, result: T): T;
  1956. /**
  1957. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  1958. * @param x value to subtract
  1959. * @param y value to subtract
  1960. * @param z value to subtract
  1961. * @param w value to subtract
  1962. * @returns new vector containing the result
  1963. */
  1964. subtractFromFloats(x: number, y: number, z: number, w: number): this;
  1965. /**
  1966. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  1967. * @param x value to subtract
  1968. * @param y value to subtract
  1969. * @param z value to subtract
  1970. * @param w value to subtract
  1971. * @param result the vector to store the result in
  1972. * @returns result input
  1973. */
  1974. subtractFromFloatsToRef<T extends Vector4>(x: number, y: number, z: number, w: number, result: T): T;
  1975. /**
  1976. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  1977. * @returns a new vector with the negated values
  1978. */
  1979. negate(): this;
  1980. /**
  1981. * Negate this vector in place
  1982. * @returns this
  1983. */
  1984. negateInPlace(): this;
  1985. /**
  1986. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  1987. * @param result defines the Vector3 object where to store the result
  1988. * @returns the result
  1989. */
  1990. negateToRef<T extends Vector4>(result: T): T;
  1991. /**
  1992. * Multiplies the current Vector4 coordinates by scale (float).
  1993. * @param scale the number to scale with
  1994. * @returns the updated Vector4.
  1995. */
  1996. scaleInPlace(scale: number): this;
  1997. /**
  1998. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  1999. * @param scale the number to scale with
  2000. * @returns a new vector with the result
  2001. */
  2002. scale(scale: number): this;
  2003. /**
  2004. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2005. * @param scale the number to scale with
  2006. * @param result a vector to store the result in
  2007. * @returns result input
  2008. */
  2009. scaleToRef<T extends Vector4>(scale: number, result: T): T;
  2010. /**
  2011. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2012. * @param scale defines the scale factor
  2013. * @param result defines the Vector4 object where to store the result
  2014. * @returns result input
  2015. */
  2016. scaleAndAddToRef<T extends Vector4>(scale: number, result: T): T;
  2017. /**
  2018. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2019. * @param otherVector the vector to compare against
  2020. * @returns true if they are equal
  2021. */
  2022. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2023. /**
  2024. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2025. * @param otherVector vector to compare against
  2026. * @param epsilon (Default: very small number)
  2027. * @returns true if they are equal
  2028. */
  2029. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2030. /**
  2031. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2032. * @param x x value to compare against
  2033. * @param y y value to compare against
  2034. * @param z z value to compare against
  2035. * @param w w value to compare against
  2036. * @returns true if equal
  2037. */
  2038. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2039. /**
  2040. * Multiplies in place the current Vector4 by the given one.
  2041. * @param otherVector vector to multiple with
  2042. * @returns the updated Vector4.
  2043. */
  2044. multiplyInPlace(otherVector: DeepImmutable<Vector4>): this;
  2045. /**
  2046. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2047. * @param otherVector vector to multiple with
  2048. * @returns resulting new vector
  2049. */
  2050. multiply(otherVector: DeepImmutable<Vector4>): this;
  2051. /**
  2052. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2053. * @param otherVector vector to multiple with
  2054. * @param result vector to store the result
  2055. * @returns result input
  2056. */
  2057. multiplyToRef<T extends Vector4>(otherVector: DeepImmutable<Vector4>, result: T): T;
  2058. /**
  2059. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2060. * @param x x value multiply with
  2061. * @param y y value multiply with
  2062. * @param z z value multiply with
  2063. * @param w w value multiply with
  2064. * @returns resulting new vector
  2065. */
  2066. multiplyByFloats(x: number, y: number, z: number, w: number): this;
  2067. /**
  2068. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2069. * @param otherVector vector to devide with
  2070. * @returns resulting new vector
  2071. */
  2072. divide(otherVector: DeepImmutable<Vector4>): this;
  2073. /**
  2074. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2075. * @param otherVector vector to devide with
  2076. * @param result vector to store the result
  2077. * @returns result input
  2078. */
  2079. divideToRef<T extends Vector4>(otherVector: DeepImmutable<Vector4>, result: T): T;
  2080. /**
  2081. * Divides the current Vector3 coordinates by the given ones.
  2082. * @param otherVector vector to devide with
  2083. * @returns the updated Vector3.
  2084. */
  2085. divideInPlace(otherVector: DeepImmutable<Vector4>): this;
  2086. /**
  2087. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2088. * @param other defines the second operand
  2089. * @returns the current updated Vector4
  2090. */
  2091. minimizeInPlace(other: DeepImmutable<Vector4>): this;
  2092. /**
  2093. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2094. * @param other defines the second operand
  2095. * @returns the current updated Vector4
  2096. */
  2097. maximizeInPlace(other: DeepImmutable<Vector4>): this;
  2098. /**
  2099. * Updates the current Vector4 with the minimal coordinate values between its and the given coordinates
  2100. * @param x defines the x coordinate of the operand
  2101. * @param y defines the y coordinate of the operand
  2102. * @param z defines the z coordinate of the operand
  2103. * @param w defines the w coordinate of the operand
  2104. * @returns the current updated Vector4
  2105. */
  2106. minimizeInPlaceFromFloats(x: number, y: number, z: number, w: number): this;
  2107. /**
  2108. * Updates the current Vector4 with the maximal coordinate values between its and the given coordinates.
  2109. * @param x defines the x coordinate of the operand
  2110. * @param y defines the y coordinate of the operand
  2111. * @param z defines the z coordinate of the operand
  2112. * @param w defines the w coordinate of the operand
  2113. * @returns the current updated Vector4
  2114. */
  2115. maximizeInPlaceFromFloats(x: number, y: number, z: number, w: number): this;
  2116. /**
  2117. * Gets the current Vector4's floored values and stores them in result
  2118. * @param result the vector to store the result in
  2119. * @returns the result vector
  2120. */
  2121. floorToRef<T extends this>(result: T): T;
  2122. /**
  2123. * Gets a new Vector4 from current Vector4 floored values
  2124. * @returns a new Vector4
  2125. */
  2126. floor(): this;
  2127. /**
  2128. * Gets the current Vector4's fractional values and stores them in result
  2129. * @param result the vector to store the result in
  2130. * @returns the result vector
  2131. */
  2132. fractToRef<T extends this>(result: T): T;
  2133. /**
  2134. * Gets a new Vector4 from current Vector4 fractional values
  2135. * @returns a new Vector4
  2136. */
  2137. fract(): this;
  2138. /**
  2139. * Returns the Vector4 length (float).
  2140. * @returns the length
  2141. */
  2142. length(): number;
  2143. /**
  2144. * Returns the Vector4 squared length (float).
  2145. * @returns the length squared
  2146. */
  2147. lengthSquared(): number;
  2148. /**
  2149. * Normalizes in place the Vector4.
  2150. * @returns the updated Vector4.
  2151. */
  2152. normalize(): this;
  2153. /**
  2154. * Normalize the current Vector4 with the given input length.
  2155. * Please note that this is an in place operation.
  2156. * @param len the length of the vector
  2157. * @returns the current updated Vector4
  2158. */
  2159. normalizeFromLength(len: number): this;
  2160. /**
  2161. * Normalize the current Vector4 to a new vector
  2162. * @returns the new Vector4
  2163. */
  2164. normalizeToNew(): this;
  2165. /**
  2166. * Normalize the current Vector4 to the reference
  2167. * @param reference define the Vector4 to update
  2168. * @returns the updated Vector4
  2169. */
  2170. normalizeToRef<T extends this>(reference: T): T;
  2171. /**
  2172. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2173. * @returns this converted to a new vector3
  2174. */
  2175. toVector3(): Vector3;
  2176. /**
  2177. * Returns a new Vector4 copied from the current one.
  2178. * @returns the new cloned vector
  2179. */
  2180. clone(): this;
  2181. /**
  2182. * Updates the current Vector4 with the given one coordinates.
  2183. * @param source the source vector to copy from
  2184. * @returns the updated Vector4.
  2185. */
  2186. copyFrom(source: DeepImmutable<Vector4>): this;
  2187. /**
  2188. * Updates the current Vector4 coordinates with the given floats.
  2189. * @param x float to copy from
  2190. * @param y float to copy from
  2191. * @param z float to copy from
  2192. * @param w float to copy from
  2193. * @returns the updated Vector4.
  2194. */
  2195. copyFromFloats(x: number, y: number, z: number, w: number): this;
  2196. /**
  2197. * Updates the current Vector4 coordinates with the given floats.
  2198. * @param x float to set from
  2199. * @param y float to set from
  2200. * @param z float to set from
  2201. * @param w float to set from
  2202. * @returns the updated Vector4.
  2203. */
  2204. set(x: number, y: number, z: number, w: number): this;
  2205. /**
  2206. * Copies the given float to the current Vector4 coordinates
  2207. * @param v defines the x, y, z and w coordinates of the operand
  2208. * @returns the current updated Vector4
  2209. */
  2210. setAll(v: number): this;
  2211. /**
  2212. * Returns the dot product (float) between the current vectors and "otherVector"
  2213. * @param otherVector defines the right operand
  2214. * @returns the dot product
  2215. */
  2216. dot(otherVector: DeepImmutable<this>): number;
  2217. /**
  2218. * Returns a new Vector4 set from the starting index of the given array.
  2219. * @param array the array to pull values from
  2220. * @param offset the offset into the array to start at
  2221. * @returns the new vector
  2222. */
  2223. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2224. /**
  2225. * Updates the given vector "result" from the starting index of the given array.
  2226. * @param array the array to pull values from
  2227. * @param offset the offset into the array to start at
  2228. * @param result the vector to store the result in
  2229. * @returns result input
  2230. */
  2231. static FromArrayToRef<T extends Vector4>(array: DeepImmutable<ArrayLike<number>>, offset: number, result: T): T;
  2232. /**
  2233. * Updates the given vector "result" from the starting index of the given Float32Array.
  2234. * @param array the array to pull values from
  2235. * @param offset the offset into the array to start at
  2236. * @param result the vector to store the result in
  2237. * @returns result input
  2238. */
  2239. static FromFloatArrayToRef<T extends Vector4>(array: DeepImmutable<Float32Array>, offset: number, result: T): T;
  2240. /**
  2241. * Updates the given vector "result" coordinates from the given floats.
  2242. * @param x float to set from
  2243. * @param y float to set from
  2244. * @param z float to set from
  2245. * @param w float to set from
  2246. * @param result the vector to the floats in
  2247. * @returns result input
  2248. */
  2249. static FromFloatsToRef<T extends Vector4>(x: number, y: number, z: number, w: number, result: T): T;
  2250. /**
  2251. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2252. * @returns the new vector
  2253. */
  2254. static Zero(): Vector4;
  2255. /**
  2256. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2257. * @returns the new vector
  2258. */
  2259. static One(): Vector4;
  2260. /**
  2261. * Returns a new Vector4 with random values between min and max
  2262. * @param min the minimum random value
  2263. * @param max the maximum random value
  2264. * @returns a Vector4 with random values between min and max
  2265. */
  2266. static Random(min?: number, max?: number): Vector4;
  2267. /**
  2268. * Sets a Vector4 with random values between min and max
  2269. * @param min the minimum random value
  2270. * @param max the maximum random value
  2271. * @param ref the ref to store the values in
  2272. * @returns the ref with random values between min and max
  2273. */
  2274. static RandomToRef<T extends Vector4>(min: number | undefined, max: number | undefined, ref: T): T;
  2275. /**
  2276. * Returns a new Vector4 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2277. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2278. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2279. * @param value defines the current value
  2280. * @param min defines the lower range value
  2281. * @param max defines the upper range value
  2282. * @returns the new Vector4
  2283. */
  2284. static Clamp<T extends Vector4>(value: DeepImmutable<T>, min: DeepImmutable<Vector4>, max: DeepImmutable<Vector4>): T;
  2285. /**
  2286. * 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"
  2287. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2288. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2289. * @param value defines the current value
  2290. * @param min defines the lower range value
  2291. * @param max defines the upper range value
  2292. * @param result defines the Vector4 where to store the result
  2293. * @returns result input
  2294. */
  2295. static ClampToRef<T extends Vector4>(value: DeepImmutable<Vector4>, min: DeepImmutable<Vector4>, max: DeepImmutable<Vector4>, result: T): T;
  2296. /**
  2297. * Checks if a given vector is inside a specific range
  2298. * Example Playground https://playground.babylonjs.com/#R1F8YU#75
  2299. * @param v defines the vector to test
  2300. * @param min defines the minimum range
  2301. * @param max defines the maximum range
  2302. */
  2303. static CheckExtends(v: Vector4, min: Vector4, max: Vector4): void;
  2304. /**
  2305. * Gets a zero Vector4 that must not be updated
  2306. */
  2307. static get ZeroReadOnly(): DeepImmutable<Vector4>;
  2308. /**
  2309. * Returns a new normalized Vector4 from the given one.
  2310. * @param vector the vector to normalize
  2311. * @returns the vector
  2312. */
  2313. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2314. /**
  2315. * Updates the given vector "result" from the normalization of the given one.
  2316. * @param vector the vector to normalize
  2317. * @param result the vector to store the result in
  2318. * @returns result input
  2319. */
  2320. static NormalizeToRef<T extends Vector4>(vector: DeepImmutable<Vector4>, result: T): T;
  2321. /**
  2322. * Returns a vector with the minimum values from the left and right vectors
  2323. * @param left left vector to minimize
  2324. * @param right right vector to minimize
  2325. * @returns a new vector with the minimum of the left and right vector values
  2326. */
  2327. static Minimize<T extends Vector4>(left: DeepImmutable<T>, right: DeepImmutable<Vector4>): T;
  2328. /**
  2329. * Returns a vector with the maximum values from the left and right vectors
  2330. * @param left left vector to maximize
  2331. * @param right right vector to maximize
  2332. * @returns a new vector with the maximum of the left and right vector values
  2333. */
  2334. static Maximize<T extends Vector4>(left: DeepImmutable<T>, right: DeepImmutable<Vector4>): T;
  2335. /**
  2336. * Returns the distance (float) between the vectors "value1" and "value2".
  2337. * @param value1 value to calulate the distance between
  2338. * @param value2 value to calulate the distance between
  2339. * @returns the distance between the two vectors
  2340. */
  2341. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2342. /**
  2343. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2344. * @param value1 value to calulate the distance between
  2345. * @param value2 value to calulate the distance between
  2346. * @returns the distance between the two vectors squared
  2347. */
  2348. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2349. /**
  2350. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2351. * @param value1 value to calulate the center between
  2352. * @param value2 value to calulate the center between
  2353. * @returns the center between the two vectors
  2354. */
  2355. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2356. /**
  2357. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  2358. * @param value1 defines first vector
  2359. * @param value2 defines second vector
  2360. * @param ref defines third vector
  2361. * @returns ref
  2362. */
  2363. static CenterToRef<T extends Vector4>(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: T): T;
  2364. /**
  2365. * Returns a new Vector4 set with the result of the transformation by the given matrix of the given vector.
  2366. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2367. * The difference with Vector3.TransformCoordinates is that the w component is not used to divide the other coordinates but is returned in the w coordinate instead
  2368. * @param vector defines the Vector3 to transform
  2369. * @param transformation defines the transformation matrix
  2370. * @returns the transformed Vector4
  2371. */
  2372. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector4;
  2373. /**
  2374. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2375. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2376. * The difference with Vector3.TransformCoordinatesToRef is that the w component is not used to divide the other coordinates but is returned in the w coordinate instead
  2377. * @param vector defines the Vector3 to transform
  2378. * @param transformation defines the transformation matrix
  2379. * @param result defines the Vector4 where to store the result
  2380. * @returns result input
  2381. */
  2382. static TransformCoordinatesToRef<T extends Vector4>(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: T): T;
  2383. /**
  2384. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2385. * This method computes tranformed coordinates only, not transformed direction vectors
  2386. * The difference with Vector3.TransformCoordinatesFromFloatsToRef is that the w component is not used to divide the other coordinates but is returned in the w coordinate instead
  2387. * @param x define the x coordinate of the source vector
  2388. * @param y define the y coordinate of the source vector
  2389. * @param z define the z coordinate of the source vector
  2390. * @param transformation defines the transformation matrix
  2391. * @param result defines the Vector4 where to store the result
  2392. * @returns result input
  2393. */
  2394. static TransformCoordinatesFromFloatsToRef<T extends Vector4>(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: T): T;
  2395. /**
  2396. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2397. * This methods computes transformed normalized direction vectors only.
  2398. * @param vector the vector to transform
  2399. * @param transformation the transformation matrix to apply
  2400. * @returns the new vector
  2401. */
  2402. static TransformNormal<T extends Vector4>(vector: DeepImmutable<T>, transformation: DeepImmutable<Matrix>): T;
  2403. /**
  2404. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2405. * This methods computes transformed normalized direction vectors only.
  2406. * @param vector the vector to transform
  2407. * @param transformation the transformation matrix to apply
  2408. * @param result the vector to store the result in
  2409. * @returns result input
  2410. */
  2411. static TransformNormalToRef<T extends Vector4>(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: T): T;
  2412. /**
  2413. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2414. * This methods computes transformed normalized direction vectors only.
  2415. * @param x value to transform
  2416. * @param y value to transform
  2417. * @param z value to transform
  2418. * @param w value to transform
  2419. * @param transformation the transformation matrix to apply
  2420. * @param result the vector to store the results in
  2421. * @returns result input
  2422. */
  2423. static TransformNormalFromFloatsToRef<T extends Vector4>(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: T): T;
  2424. /**
  2425. * Creates a new Vector4 from a Vector3
  2426. * @param source defines the source data
  2427. * @param w defines the 4th component (default is 0)
  2428. * @returns a new Vector4
  2429. */
  2430. static FromVector3(source: Vector3, w?: number): Vector4;
  2431. /**
  2432. * Returns the dot product (float) between the vectors "left" and "right"
  2433. * @param left defines the left operand
  2434. * @param right defines the right operand
  2435. * @returns the dot product
  2436. */
  2437. static Dot(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): number;
  2438. }
  2439. /**
  2440. * Class used to store quaternion data
  2441. * Example Playground - Overview - https://playground.babylonjs.com/#L49EJ7#100
  2442. * @see https://en.wikipedia.org/wiki/Quaternion
  2443. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/transforms
  2444. */
  2445. export declare class Quaternion implements Tensor<Tuple<number, 4>>, IQuaternionLike {
  2446. /** @internal */
  2447. _x: number;
  2448. /** @internal */
  2449. _y: number;
  2450. /** @internal */
  2451. _z: number;
  2452. /** @internal */
  2453. _w: number;
  2454. /** @internal */
  2455. _isDirty: boolean;
  2456. /** Gets or sets the x coordinate */
  2457. get x(): number;
  2458. set x(value: number);
  2459. /** Gets or sets the y coordinate */
  2460. get y(): number;
  2461. set y(value: number);
  2462. /** Gets or sets the z coordinate */
  2463. get z(): number;
  2464. set z(value: number);
  2465. /** Gets or sets the w coordinate */
  2466. get w(): number;
  2467. set w(value: number);
  2468. /**
  2469. * @see Tensor.dimension
  2470. */
  2471. readonly dimension: Readonly<[4]>;
  2472. /**
  2473. * @see Tensor.rank
  2474. */
  2475. readonly rank: 1;
  2476. /**
  2477. * Creates a new Quaternion from the given floats
  2478. * @param x defines the first component (0 by default)
  2479. * @param y defines the second component (0 by default)
  2480. * @param z defines the third component (0 by default)
  2481. * @param w defines the fourth component (1.0 by default)
  2482. */
  2483. constructor(x?: number, y?: number, z?: number, w?: number);
  2484. /**
  2485. * Gets a string representation for the current quaternion
  2486. * @returns a string with the Quaternion coordinates
  2487. */
  2488. toString(): string;
  2489. /**
  2490. * Gets the class name of the quaternion
  2491. * @returns the string "Quaternion"
  2492. */
  2493. getClassName(): string;
  2494. /**
  2495. * Gets a hash code for this quaternion
  2496. * @returns the quaternion hash code
  2497. */
  2498. getHashCode(): number;
  2499. /**
  2500. * Copy the quaternion to an array
  2501. * Example Playground https://playground.babylonjs.com/#L49EJ7#13
  2502. * @returns a new array populated with 4 elements from the quaternion coordinates
  2503. */
  2504. asArray(): Tuple<number, 4>;
  2505. /**
  2506. * Stores from the starting index in the given array the Quaternion successive values
  2507. * Example Playground https://playground.babylonjs.com/#L49EJ7#59
  2508. * @param array defines the array where to store the x,y,z,w components
  2509. * @param index defines an optional index in the target array to define where to start storing values
  2510. * @returns the current Quaternion object
  2511. */
  2512. toArray(array: FloatArray, index?: number): this;
  2513. fromArray(array: FloatArray, index?: number): this;
  2514. /**
  2515. * Check if two quaternions are equals
  2516. * Example Playground https://playground.babylonjs.com/#L49EJ7#38
  2517. * @param otherQuaternion defines the second operand
  2518. * @returns true if the current quaternion and the given one coordinates are strictly equals
  2519. */
  2520. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2521. /**
  2522. * Gets a boolean if two quaternions are equals (using an epsilon value)
  2523. * Example Playground https://playground.babylonjs.com/#L49EJ7#37
  2524. * @param otherQuaternion defines the other quaternion
  2525. * @param epsilon defines the minimal distance to consider equality
  2526. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  2527. */
  2528. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  2529. /**
  2530. * Clone the current quaternion
  2531. * Example Playground https://playground.babylonjs.com/#L49EJ7#12
  2532. * @returns a new quaternion copied from the current one
  2533. */
  2534. clone(): this;
  2535. /**
  2536. * Copy a quaternion to the current one
  2537. * Example Playground https://playground.babylonjs.com/#L49EJ7#86
  2538. * @param other defines the other quaternion
  2539. * @returns the updated current quaternion
  2540. */
  2541. copyFrom(other: DeepImmutable<Quaternion>): this;
  2542. /**
  2543. * Updates the current quaternion with the given float coordinates
  2544. * Example Playground https://playground.babylonjs.com/#L49EJ7#87
  2545. * @param x defines the x coordinate
  2546. * @param y defines the y coordinate
  2547. * @param z defines the z coordinate
  2548. * @param w defines the w coordinate
  2549. * @returns the updated current quaternion
  2550. */
  2551. copyFromFloats(x: number, y: number, z: number, w: number): this;
  2552. /**
  2553. * Updates the current quaternion from the given float coordinates
  2554. * Example Playground https://playground.babylonjs.com/#L49EJ7#56
  2555. * @param x defines the x coordinate
  2556. * @param y defines the y coordinate
  2557. * @param z defines the z coordinate
  2558. * @param w defines the w coordinate
  2559. * @returns the updated current quaternion
  2560. */
  2561. set(x: number, y: number, z: number, w: number): this;
  2562. setAll(value: number): this;
  2563. /**
  2564. * Adds two quaternions
  2565. * Example Playground https://playground.babylonjs.com/#L49EJ7#10
  2566. * @param other defines the second operand
  2567. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2568. */
  2569. add(other: DeepImmutable<Quaternion>): this;
  2570. /**
  2571. * Add a quaternion to the current one
  2572. * Example Playground https://playground.babylonjs.com/#L49EJ7#11
  2573. * @param other defines the quaternion to add
  2574. * @returns the current quaternion
  2575. */
  2576. addInPlace(other: DeepImmutable<Quaternion>): this;
  2577. addToRef<T extends this>(other: DeepImmutable<this>, result: T): T;
  2578. addInPlaceFromFloats(x: number, y: number, z: number, w: number): this;
  2579. subtractToRef<T extends this>(other: DeepImmutable<this>, result: T): T;
  2580. subtractFromFloats(x: number, y: number, z: number, w: number): this;
  2581. subtractFromFloatsToRef<T extends this>(x: number, y: number, z: number, w: number, result: T): T;
  2582. /**
  2583. * Subtract two quaternions
  2584. * Example Playground https://playground.babylonjs.com/#L49EJ7#57
  2585. * @param other defines the second operand
  2586. * @returns a new quaternion as the subtraction result of the given one from the current one
  2587. */
  2588. subtract(other: DeepImmutable<this>): this;
  2589. /**
  2590. * Subtract a quaternion to the current one
  2591. * Example Playground https://playground.babylonjs.com/#L49EJ7#58
  2592. * @param other defines the quaternion to subtract
  2593. * @returns the current quaternion
  2594. */
  2595. subtractInPlace(other: DeepImmutable<Quaternion>): this;
  2596. /**
  2597. * Multiplies the current quaternion by a scale factor
  2598. * Example Playground https://playground.babylonjs.com/#L49EJ7#88
  2599. * @param value defines the scale factor
  2600. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2601. */
  2602. scale(value: number): this;
  2603. /**
  2604. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2605. * Example Playground https://playground.babylonjs.com/#L49EJ7#89
  2606. * @param scale defines the scale factor
  2607. * @param result defines the Quaternion object where to store the result
  2608. * @returns result input
  2609. */
  2610. scaleToRef<T extends Quaternion>(scale: number, result: T): T;
  2611. /**
  2612. * Multiplies in place the current quaternion by a scale factor
  2613. * Example Playground https://playground.babylonjs.com/#L49EJ7#90
  2614. * @param value defines the scale factor
  2615. * @returns the current modified quaternion
  2616. */
  2617. scaleInPlace(value: number): this;
  2618. /**
  2619. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2620. * Example Playground https://playground.babylonjs.com/#L49EJ7#91
  2621. * @param scale defines the scale factor
  2622. * @param result defines the Quaternion object where to store the result
  2623. * @returns result input
  2624. */
  2625. scaleAndAddToRef<T extends Quaternion>(scale: number, result: T): T;
  2626. /**
  2627. * Multiplies two quaternions
  2628. * Example Playground https://playground.babylonjs.com/#L49EJ7#43
  2629. * @param q1 defines the second operand
  2630. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2631. */
  2632. multiply(q1: DeepImmutable<Quaternion>): this;
  2633. /**
  2634. * Sets the given "result" as the multiplication result of the current one with the given one "q1"
  2635. * Example Playground https://playground.babylonjs.com/#L49EJ7#45
  2636. * @param q1 defines the second operand
  2637. * @param result defines the target quaternion
  2638. * @returns the current quaternion
  2639. */
  2640. multiplyToRef<T extends Quaternion>(q1: DeepImmutable<Quaternion>, result: T): T;
  2641. /**
  2642. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2643. * Example Playground https://playground.babylonjs.com/#L49EJ7#46
  2644. * @param other defines the second operand
  2645. * @returns the currentupdated quaternion
  2646. */
  2647. multiplyInPlace(other: DeepImmutable<Quaternion>): this;
  2648. multiplyByFloats(x: number, y: number, z: number, w: number): this;
  2649. /**
  2650. * @internal
  2651. * Do not use
  2652. */
  2653. divide(_other: DeepImmutable<this>): this;
  2654. /**
  2655. * @internal
  2656. * Do not use
  2657. */
  2658. divideToRef<T extends this>(_other: DeepImmutable<this>, _result: T): T;
  2659. /**
  2660. * @internal
  2661. * Do not use
  2662. */
  2663. divideInPlace(_other: DeepImmutable<this>): this;
  2664. /**
  2665. * @internal
  2666. * Do not use
  2667. */
  2668. minimizeInPlace(): this;
  2669. /**
  2670. * @internal
  2671. * Do not use
  2672. */
  2673. minimizeInPlaceFromFloats(): this;
  2674. /**
  2675. * @internal
  2676. * Do not use
  2677. */
  2678. maximizeInPlace(): this;
  2679. /**
  2680. * @internal
  2681. * Do not use
  2682. */
  2683. maximizeInPlaceFromFloats(): this;
  2684. negate(): this;
  2685. negateInPlace(): this;
  2686. negateToRef<T extends this>(result: T): T;
  2687. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2688. /**
  2689. * @internal
  2690. * Do not use
  2691. */
  2692. floorToRef<T extends this>(_result: T): T;
  2693. /**
  2694. * @internal
  2695. * Do not use
  2696. */
  2697. floor(): this;
  2698. /**
  2699. * @internal
  2700. * Do not use
  2701. */
  2702. fractToRef<T extends this>(_result: T): T;
  2703. /**
  2704. * @internal
  2705. * Do not use
  2706. */
  2707. fract(): this;
  2708. /**
  2709. * Conjugates the current quaternion and stores the result in the given quaternion
  2710. * Example Playground https://playground.babylonjs.com/#L49EJ7#81
  2711. * @param ref defines the target quaternion
  2712. * @returns result input
  2713. */
  2714. conjugateToRef<T extends Quaternion>(ref: T): T;
  2715. /**
  2716. * Conjugates in place the current quaternion
  2717. * Example Playground https://playground.babylonjs.com/#L49EJ7#82
  2718. * @returns the current updated quaternion
  2719. */
  2720. conjugateInPlace(): this;
  2721. /**
  2722. * Conjugates (1-q) the current quaternion
  2723. * Example Playground https://playground.babylonjs.com/#L49EJ7#83
  2724. * @returns a new quaternion
  2725. */
  2726. conjugate(): this;
  2727. /**
  2728. * Returns the inverse of the current quaternion
  2729. * Example Playground https://playground.babylonjs.com/#L49EJ7#84
  2730. * @returns a new quaternion
  2731. */
  2732. invert(): this;
  2733. /**
  2734. * Invert in place the current quaternion
  2735. * Example Playground https://playground.babylonjs.com/#L49EJ7#85
  2736. * @returns this quaternion
  2737. */
  2738. invertInPlace(): this;
  2739. /**
  2740. * Gets squared length of current quaternion
  2741. * Example Playground https://playground.babylonjs.com/#L49EJ7#29
  2742. * @returns the quaternion length (float)
  2743. */
  2744. lengthSquared(): number;
  2745. /**
  2746. * Gets length of current quaternion
  2747. * Example Playground https://playground.babylonjs.com/#L49EJ7#28
  2748. * @returns the quaternion length (float)
  2749. */
  2750. length(): number;
  2751. /**
  2752. * Normalize in place the current quaternion
  2753. * Example Playground https://playground.babylonjs.com/#L49EJ7#54
  2754. * @returns the current updated quaternion
  2755. */
  2756. normalize(): this;
  2757. /**
  2758. * Normalize the current quaternion with the given input length.
  2759. * Please note that this is an in place operation.
  2760. * @param len the length of the quaternion
  2761. * @returns the current updated Quaternion
  2762. */
  2763. normalizeFromLength(len: number): this;
  2764. /**
  2765. * Normalize a copy of the current quaternion
  2766. * Example Playground https://playground.babylonjs.com/#L49EJ7#55
  2767. * @returns the normalized quaternion
  2768. */
  2769. normalizeToNew(): this;
  2770. /**
  2771. * Normalize the current Quaternion to the reference
  2772. * @param reference define the Quaternion to update
  2773. * @returns the updated Quaternion
  2774. */
  2775. normalizeToRef<T extends Quaternion>(reference: T): T;
  2776. /**
  2777. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2778. * Example Playground https://playground.babylonjs.com/#L49EJ7#32
  2779. * @returns a new Vector3 containing the Euler angles
  2780. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/transforms/center_origin/rotation_conventions
  2781. */
  2782. toEulerAngles(): Vector3;
  2783. /**
  2784. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2785. * Example Playground https://playground.babylonjs.com/#L49EJ7#31
  2786. * @param result defines the vector which will be filled with the Euler angles
  2787. * @returns result input
  2788. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/transforms/center_origin/rotation_conventions
  2789. */
  2790. toEulerAnglesToRef<T extends Vector3>(result: T): T;
  2791. /**
  2792. * Updates the given rotation matrix with the current quaternion values
  2793. * Example Playground https://playground.babylonjs.com/#L49EJ7#67
  2794. * @param result defines the target matrix
  2795. * @returns the updated matrix with the rotation
  2796. */
  2797. toRotationMatrix<T extends Matrix>(result: T): T;
  2798. /**
  2799. * Updates the current quaternion from the given rotation matrix values
  2800. * Example Playground https://playground.babylonjs.com/#L49EJ7#41
  2801. * @param matrix defines the source matrix
  2802. * @returns the current updated quaternion
  2803. */
  2804. fromRotationMatrix(matrix: DeepImmutable<Matrix>): this;
  2805. /**
  2806. * Returns the dot product (float) between the current quaternions and "other"
  2807. * @param other defines the right operand
  2808. * @returns the dot product
  2809. */
  2810. dot(other: DeepImmutable<this>): number;
  2811. /**
  2812. * Creates a new quaternion from a rotation matrix
  2813. * Example Playground https://playground.babylonjs.com/#L49EJ7#101
  2814. * @param matrix defines the source matrix
  2815. * @returns a new quaternion created from the given rotation matrix values
  2816. */
  2817. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2818. /**
  2819. * Updates the given quaternion with the given rotation matrix values
  2820. * Example Playground https://playground.babylonjs.com/#L49EJ7#102
  2821. * @param matrix defines the source matrix
  2822. * @param result defines the target quaternion
  2823. * @returns result input
  2824. */
  2825. static FromRotationMatrixToRef<T extends Quaternion>(matrix: DeepImmutable<Matrix>, result: T): T;
  2826. /**
  2827. * Returns the dot product (float) between the quaternions "left" and "right"
  2828. * Example Playground https://playground.babylonjs.com/#L49EJ7#61
  2829. * @param left defines the left operand
  2830. * @param right defines the right operand
  2831. * @returns the dot product
  2832. */
  2833. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2834. /**
  2835. * Checks if the orientations of two rotation quaternions are close to each other
  2836. * Example Playground https://playground.babylonjs.com/#L49EJ7#60
  2837. * @param quat0 defines the first quaternion to check
  2838. * @param quat1 defines the second quaternion to check
  2839. * @param epsilon defines closeness, 0 same orientation, 1 PI apart, default 0.1
  2840. * @returns true if the two quaternions are close to each other within epsilon
  2841. */
  2842. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  2843. /**
  2844. * Smooth interpolation between two quaternions using Slerp
  2845. * Example Playground https://playground.babylonjs.com/#L49EJ7#93
  2846. * @param source source quaternion
  2847. * @param goal goal quaternion
  2848. * @param deltaTime current interpolation frame
  2849. * @param lerpTime total interpolation time
  2850. * @param result the smoothed quaternion
  2851. * @returns the smoothed quaternion
  2852. */
  2853. static SmoothToRef<T extends Quaternion>(source: Quaternion, goal: Quaternion, deltaTime: number, lerpTime: number, result: T): T;
  2854. /**
  2855. * Creates an empty quaternion
  2856. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2857. */
  2858. static Zero(): Quaternion;
  2859. /**
  2860. * Inverse a given quaternion
  2861. * Example Playground https://playground.babylonjs.com/#L49EJ7#103
  2862. * @param q defines the source quaternion
  2863. * @returns a new quaternion as the inverted current quaternion
  2864. */
  2865. static Inverse<T extends Quaternion>(q: DeepImmutable<T>): T;
  2866. /**
  2867. * Inverse a given quaternion
  2868. * Example Playground https://playground.babylonjs.com/#L49EJ7#104
  2869. * @param q defines the source quaternion
  2870. * @param result the quaternion the result will be stored in
  2871. * @returns the result quaternion
  2872. */
  2873. static InverseToRef<T extends Quaternion>(q: Quaternion, result: T): T;
  2874. /**
  2875. * Creates an identity quaternion
  2876. * @returns the identity quaternion
  2877. */
  2878. static Identity(): Quaternion;
  2879. /**
  2880. * Gets a boolean indicating if the given quaternion is identity
  2881. * @param quaternion defines the quaternion to check
  2882. * @returns true if the quaternion is identity
  2883. */
  2884. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2885. /**
  2886. * Creates a quaternion from a rotation around an axis
  2887. * Example Playground https://playground.babylonjs.com/#L49EJ7#72
  2888. * @param axis defines the axis to use
  2889. * @param angle defines the angle to use
  2890. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2891. */
  2892. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2893. /**
  2894. * Creates a rotation around an axis and stores it into the given quaternion
  2895. * Example Playground https://playground.babylonjs.com/#L49EJ7#73
  2896. * @param axis defines the axis to use
  2897. * @param angle defines the angle to use
  2898. * @param result defines the target quaternion
  2899. * @returns the target quaternion
  2900. */
  2901. static RotationAxisToRef<T extends Quaternion>(axis: DeepImmutable<Vector3>, angle: number, result: T): T;
  2902. /**
  2903. * Creates a new quaternion from data stored into an array
  2904. * Example Playground https://playground.babylonjs.com/#L49EJ7#63
  2905. * @param array defines the data source
  2906. * @param offset defines the offset in the source array where the data starts
  2907. * @returns a new quaternion
  2908. */
  2909. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2910. /**
  2911. * Updates the given quaternion "result" from the starting index of the given array.
  2912. * Example Playground https://playground.babylonjs.com/#L49EJ7#64
  2913. * @param array the array to pull values from
  2914. * @param offset the offset into the array to start at
  2915. * @param result the quaternion to store the result in
  2916. * @returns result input
  2917. */
  2918. static FromArrayToRef<T extends Quaternion>(array: DeepImmutable<ArrayLike<number>>, offset: number, result: T): T;
  2919. /**
  2920. * Sets the given quaternion "result" with the given floats.
  2921. * @param x defines the x coordinate of the source
  2922. * @param y defines the y coordinate of the source
  2923. * @param z defines the z coordinate of the source
  2924. * @param w defines the w coordinate of the source
  2925. * @param result defines the quaternion where to store the result
  2926. * @returns the result quaternion
  2927. */
  2928. static FromFloatsToRef<T extends Quaternion = Quaternion>(x: number, y: number, z: number, w: number, result: T): T;
  2929. /**
  2930. * Create a quaternion from Euler rotation angles
  2931. * Example Playground https://playground.babylonjs.com/#L49EJ7#33
  2932. * @param x Pitch
  2933. * @param y Yaw
  2934. * @param z Roll
  2935. * @returns the new Quaternion
  2936. */
  2937. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2938. /**
  2939. * Updates a quaternion from Euler rotation angles
  2940. * Example Playground https://playground.babylonjs.com/#L49EJ7#34
  2941. * @param x Pitch
  2942. * @param y Yaw
  2943. * @param z Roll
  2944. * @param result the quaternion to store the result
  2945. * @returns the updated quaternion
  2946. */
  2947. static FromEulerAnglesToRef<T extends Quaternion>(x: number, y: number, z: number, result: T): T;
  2948. /**
  2949. * Create a quaternion from Euler rotation vector
  2950. * Example Playground https://playground.babylonjs.com/#L49EJ7#35
  2951. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2952. * @returns the new Quaternion
  2953. */
  2954. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2955. /**
  2956. * Updates a quaternion from Euler rotation vector
  2957. * Example Playground https://playground.babylonjs.com/#L49EJ7#36
  2958. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2959. * @param result the quaternion to store the result
  2960. * @returns the updated quaternion
  2961. */
  2962. static FromEulerVectorToRef<T extends Quaternion>(vec: DeepImmutable<Vector3>, result: T): T;
  2963. /**
  2964. * Updates a quaternion so that it rotates vector vecFrom to vector vecTo
  2965. * Example Playground - https://playground.babylonjs.com/#L49EJ7#70
  2966. * @param vecFrom defines the direction vector from which to rotate
  2967. * @param vecTo defines the direction vector to which to rotate
  2968. * @param result the quaternion to store the result
  2969. * @param epsilon defines the minimal dot value to define vecs as opposite. Default: `BABYLON.Epsilon`
  2970. * @returns the updated quaternion
  2971. */
  2972. static FromUnitVectorsToRef<T extends Quaternion>(vecFrom: DeepImmutable<Vector3>, vecTo: DeepImmutable<Vector3>, result: T, epsilon?: number): T;
  2973. /**
  2974. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2975. * Example Playground https://playground.babylonjs.com/#L49EJ7#77
  2976. * @param yaw defines the rotation around Y axis
  2977. * @param pitch defines the rotation around X axis
  2978. * @param roll defines the rotation around Z axis
  2979. * @returns the new quaternion
  2980. */
  2981. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2982. /**
  2983. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2984. * Example Playground https://playground.babylonjs.com/#L49EJ7#78
  2985. * @param yaw defines the rotation around Y axis
  2986. * @param pitch defines the rotation around X axis
  2987. * @param roll defines the rotation around Z axis
  2988. * @param result defines the target quaternion
  2989. * @returns result input
  2990. */
  2991. static RotationYawPitchRollToRef<T extends Quaternion>(yaw: number, pitch: number, roll: number, result: T): T;
  2992. /**
  2993. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2994. * Example Playground https://playground.babylonjs.com/#L49EJ7#68
  2995. * @param alpha defines the rotation around first axis
  2996. * @param beta defines the rotation around second axis
  2997. * @param gamma defines the rotation around third axis
  2998. * @returns the new quaternion
  2999. */
  3000. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3001. /**
  3002. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3003. * Example Playground https://playground.babylonjs.com/#L49EJ7#69
  3004. * @param alpha defines the rotation around first axis
  3005. * @param beta defines the rotation around second axis
  3006. * @param gamma defines the rotation around third axis
  3007. * @param result defines the target quaternion
  3008. * @returns result input
  3009. */
  3010. static RotationAlphaBetaGammaToRef<T extends Quaternion>(alpha: number, beta: number, gamma: number, result: T): T;
  3011. /**
  3012. * 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)
  3013. * Example Playground https://playground.babylonjs.com/#L49EJ7#75
  3014. * @param axis1 defines the first axis
  3015. * @param axis2 defines the second axis
  3016. * @param axis3 defines the third axis
  3017. * @returns the new quaternion
  3018. */
  3019. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3020. /**
  3021. * 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
  3022. * Example Playground https://playground.babylonjs.com/#L49EJ7#76
  3023. * @param axis1 defines the first axis
  3024. * @param axis2 defines the second axis
  3025. * @param axis3 defines the third axis
  3026. * @param ref defines the target quaternion
  3027. * @returns result input
  3028. */
  3029. static RotationQuaternionFromAxisToRef<T extends Quaternion>(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: T): T;
  3030. /**
  3031. * Creates a new rotation value to orient an object to look towards the given forward direction, the up direction being oriented like "up".
  3032. * This function works in left handed mode
  3033. * Example Playground https://playground.babylonjs.com/#L49EJ7#96
  3034. * @param forward defines the forward direction - Must be normalized and orthogonal to up.
  3035. * @param up defines the up vector for the entity - Must be normalized and orthogonal to forward.
  3036. * @returns A new quaternion oriented toward the specified forward and up.
  3037. */
  3038. static FromLookDirectionLH(forward: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Quaternion;
  3039. /**
  3040. * Creates a new rotation value to orient an object to look towards the given forward direction with the up direction being oriented like "up", and stores it in the target quaternion.
  3041. * This function works in left handed mode
  3042. * Example Playground https://playground.babylonjs.com/#L49EJ7#97
  3043. * @param forward defines the forward direction - Must be normalized and orthogonal to up.
  3044. * @param up defines the up vector for the entity - Must be normalized and orthogonal to forward.
  3045. * @param ref defines the target quaternion.
  3046. * @returns result input
  3047. */
  3048. static FromLookDirectionLHToRef<T extends Quaternion>(forward: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, ref: T): T;
  3049. /**
  3050. * Creates a new rotation value to orient an object to look towards the given forward direction, the up direction being oriented like "up".
  3051. * This function works in right handed mode
  3052. * Example Playground https://playground.babylonjs.com/#L49EJ7#98
  3053. * @param forward defines the forward direction - Must be normalized and orthogonal to up.
  3054. * @param up defines the up vector for the entity - Must be normalized and orthogonal to forward.
  3055. * @returns A new quaternion oriented toward the specified forward and up.
  3056. */
  3057. static FromLookDirectionRH(forward: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Quaternion;
  3058. /**
  3059. * Creates a new rotation value to orient an object to look towards the given forward direction with the up direction being oriented like "up", and stores it in the target quaternion.
  3060. * This function works in right handed mode
  3061. * Example Playground https://playground.babylonjs.com/#L49EJ7#105
  3062. * @param forward defines the forward direction - Must be normalized and orthogonal to up.
  3063. * @param up defines the up vector for the entity - Must be normalized and orthogonal to forward.
  3064. * @param ref defines the target quaternion.
  3065. * @returns result input
  3066. */
  3067. static FromLookDirectionRHToRef<T extends Quaternion>(forward: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, ref: T): T;
  3068. /**
  3069. * Interpolates between two quaternions
  3070. * Example Playground https://playground.babylonjs.com/#L49EJ7#79
  3071. * @param left defines first quaternion
  3072. * @param right defines second quaternion
  3073. * @param amount defines the gradient to use
  3074. * @returns the new interpolated quaternion
  3075. */
  3076. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3077. /**
  3078. * Interpolates between two quaternions and stores it into a target quaternion
  3079. * Example Playground https://playground.babylonjs.com/#L49EJ7#92
  3080. * @param left defines first quaternion
  3081. * @param right defines second quaternion
  3082. * @param amount defines the gradient to use
  3083. * @param result defines the target quaternion
  3084. * @returns result input
  3085. */
  3086. static SlerpToRef<T extends Quaternion>(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: T): T;
  3087. /**
  3088. * Interpolate between two quaternions using Hermite interpolation
  3089. * Example Playground https://playground.babylonjs.com/#L49EJ7#47
  3090. * @see https://doc.babylonjs.com/features/featuresDeepDive/mesh/drawCurves#hermite-quaternion-spline
  3091. * @param value1 defines first quaternion
  3092. * @param tangent1 defines the incoming tangent
  3093. * @param value2 defines second quaternion
  3094. * @param tangent2 defines the outgoing tangent
  3095. * @param amount defines the target quaternion
  3096. * @returns the new interpolated quaternion
  3097. */
  3098. static Hermite<T extends Quaternion>(value1: DeepImmutable<T>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): T;
  3099. /**
  3100. * Returns a new Quaternion which is the 1st derivative of the Hermite spline defined by the quaternions "value1", "value2", "tangent1", "tangent2".
  3101. * Example Playground https://playground.babylonjs.com/#L49EJ7#48
  3102. * @param value1 defines the first control point
  3103. * @param tangent1 defines the first tangent
  3104. * @param value2 defines the second control point
  3105. * @param tangent2 defines the second tangent
  3106. * @param time define where the derivative must be done
  3107. * @returns 1st derivative
  3108. */
  3109. static Hermite1stDerivative<T extends Quaternion>(value1: DeepImmutable<T>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, time: number): T;
  3110. /**
  3111. * Update a Quaternion with the 1st derivative of the Hermite spline defined by the quaternions "value1", "value2", "tangent1", "tangent2".
  3112. * Example Playground https://playground.babylonjs.com/#L49EJ7#49
  3113. * @param value1 defines the first control point
  3114. * @param tangent1 defines the first tangent
  3115. * @param value2 defines the second control point
  3116. * @param tangent2 defines the second tangent
  3117. * @param time define where the derivative must be done
  3118. * @param result define where to store the derivative
  3119. * @returns result input
  3120. */
  3121. static Hermite1stDerivativeToRef<T extends Quaternion>(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, time: number, result: T): T;
  3122. /**
  3123. * Returns a new Quaternion as the normalization of the given Quaternion
  3124. * @param quat defines the Quaternion to normalize
  3125. * @returns the new Quaternion
  3126. */
  3127. static Normalize(quat: DeepImmutable<Quaternion>): Quaternion;
  3128. /**
  3129. * Sets the given Quaternion "result" with the normalization of the given first Quaternion
  3130. * @param quat defines the Quaternion to normalize
  3131. * @param result defines the Quaternion where to store the result
  3132. * @returns result input
  3133. */
  3134. static NormalizeToRef<T extends Quaternion>(quat: DeepImmutable<Quaternion>, result: T): T;
  3135. /**
  3136. * Returns a new Quaternion set with the coordinates of "value", if the quaternion "value" is in the cube defined by the quaternions "min" and "max"
  3137. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3138. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3139. * @param value defines the current value
  3140. * @param min defines the lower range value
  3141. * @param max defines the upper range value
  3142. * @returns the new Quaternion
  3143. */
  3144. static Clamp<T extends Quaternion>(value: DeepImmutable<T>, min: DeepImmutable<Quaternion>, max: DeepImmutable<Quaternion>): T;
  3145. /**
  3146. * Sets the given quaternion "result" with the coordinates of "value", if the quaternion "value" is in the cube defined by the quaternions "min" and "max"
  3147. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3148. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3149. * @param value defines the current value
  3150. * @param min defines the lower range value
  3151. * @param max defines the upper range value
  3152. * @param result defines the Quaternion where to store the result
  3153. * @returns result input
  3154. */
  3155. static ClampToRef<T extends Quaternion>(value: DeepImmutable<Quaternion>, min: DeepImmutable<Quaternion>, max: DeepImmutable<Quaternion>, result: T): T;
  3156. /**
  3157. * Returns a new Quaternion with random values between min and max
  3158. * @param min the minimum random value
  3159. * @param max the maximum random value
  3160. * @returns a Quaternion with random values between min and max
  3161. */
  3162. static Random(min?: number, max?: number): Quaternion;
  3163. /**
  3164. * Sets a Quaternion with random values between min and max
  3165. * @param min the minimum random value
  3166. * @param max the maximum random value
  3167. * @param ref the ref to store the values in
  3168. * @returns the ref with random values between min and max
  3169. */
  3170. static RandomToRef<T extends Quaternion>(min: number | undefined, max: number | undefined, ref: T): T;
  3171. /**
  3172. * Do not use
  3173. * @internal
  3174. */
  3175. static Minimize(): Quaternion;
  3176. /**
  3177. * Do not use
  3178. * @internal
  3179. */
  3180. static Maximize(): Quaternion;
  3181. /**
  3182. * Returns the distance (float) between the quaternions "value1" and "value2".
  3183. * @param value1 value to calulate the distance between
  3184. * @param value2 value to calulate the distance between
  3185. * @returns the distance between the two quaternions
  3186. */
  3187. static Distance(value1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>): number;
  3188. /**
  3189. * Returns the squared distance (float) between the quaternions "value1" and "value2".
  3190. * @param value1 value to calulate the distance between
  3191. * @param value2 value to calulate the distance between
  3192. * @returns the distance between the two quaternions squared
  3193. */
  3194. static DistanceSquared(value1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>): number;
  3195. /**
  3196. * Returns a new Quaternion located at the center between the quaternions "value1" and "value2".
  3197. * @param value1 value to calulate the center between
  3198. * @param value2 value to calulate the center between
  3199. * @returns the center between the two quaternions
  3200. */
  3201. static Center(value1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>): Quaternion;
  3202. /**
  3203. * Gets the center of the quaternions "value1" and "value2" and stores the result in the quaternion "ref"
  3204. * @param value1 defines first quaternion
  3205. * @param value2 defines second quaternion
  3206. * @param ref defines third quaternion
  3207. * @returns ref
  3208. */
  3209. static CenterToRef<T extends Quaternion>(value1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, ref: T): T;
  3210. }
  3211. /**
  3212. * Class used to store matrix data (4x4)
  3213. * Note on matrix definitions in Babylon.js for setting values directly
  3214. * rather than using one of the methods available.
  3215. * Matrix size is given by rows x columns.
  3216. * A Vector3 is a 1 X 3 matrix [x, y, z].
  3217. *
  3218. * In Babylon.js multiplying a 1 x 3 matrix by a 4 x 4 matrix
  3219. * is done using BABYLON.Vector4.TransformCoordinates(Vector3, Matrix).
  3220. * and extending the passed Vector3 to a Vector4, V = [x, y, z, 1].
  3221. * Let M be a matrix with elements m(row, column), so that
  3222. * m(2, 3) is the element in row 2 column 3 of M.
  3223. *
  3224. * Multiplication is of the form VM and has the resulting Vector4
  3225. * VM = [xm(0, 0) + ym(1, 0) + zm(2, 0) + m(3, 0), xm(0, 1) + ym(1, 1) + zm(2, 1) + m(3, 1), xm(0, 2) + ym(1, 2) + zm(2, 2) + m(3, 2), xm(0, 3) + ym(1, 3) + zm(2, 3) + m(3, 3)].
  3226. * On the web you will find many examples that use the opposite convention of MV,
  3227. * in which case to make use of the examples you will need to transpose the matrix.
  3228. *
  3229. * Example Playground - Overview Linear Algebra - https://playground.babylonjs.com/#AV9X17
  3230. * Example Playground - Overview Transformation - https://playground.babylonjs.com/#AV9X17#1
  3231. * Example Playground - Overview Projection - https://playground.babylonjs.com/#AV9X17#2
  3232. */
  3233. export declare class Matrix implements Tensor<Tuple<Tuple<number, 4>, 4>>, IMatrixLike {
  3234. /**
  3235. * @see Tensor.dimension
  3236. */
  3237. readonly dimension: Readonly<[4, 4]>;
  3238. /**
  3239. * @see Tensor.rank
  3240. */
  3241. readonly rank: 2;
  3242. /**
  3243. * Gets the precision of matrix computations
  3244. */
  3245. static get Use64Bits(): boolean;
  3246. private static _UpdateFlagSeed;
  3247. private static _IdentityReadOnly;
  3248. private _isIdentity;
  3249. private _isIdentityDirty;
  3250. private _isIdentity3x2;
  3251. private _isIdentity3x2Dirty;
  3252. /**
  3253. * Gets the update flag of the matrix which is an unique number for the matrix.
  3254. * It will be incremented every time the matrix data change.
  3255. * You can use it to speed the comparison between two versions of the same matrix.
  3256. */
  3257. updateFlag: number;
  3258. private readonly _m;
  3259. /**
  3260. * Gets the internal data of the matrix
  3261. */
  3262. get m(): DeepImmutable<Tuple<number, 16>>;
  3263. /**
  3264. * Update the updateFlag to indicate that the matrix has been updated
  3265. */
  3266. markAsUpdated(): void;
  3267. private _updateIdentityStatus;
  3268. /**
  3269. * Creates an empty matrix (filled with zeros)
  3270. */
  3271. constructor();
  3272. /**
  3273. * Check if the current matrix is identity
  3274. * @returns true is the matrix is the identity matrix
  3275. */
  3276. isIdentity(): boolean;
  3277. /**
  3278. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3279. * @returns true is the matrix is the identity matrix
  3280. */
  3281. isIdentityAs3x2(): boolean;
  3282. /**
  3283. * Gets the determinant of the matrix
  3284. * Example Playground - https://playground.babylonjs.com/#AV9X17#34
  3285. * @returns the matrix determinant
  3286. */
  3287. determinant(): number;
  3288. /**
  3289. * Gets a string with the Matrix values
  3290. * @returns a string with the Matrix values
  3291. */
  3292. toString(): string;
  3293. /**
  3294. * Returns the matrix as a Float32Array or Array<number>
  3295. * @deprecated Use asArray
  3296. */
  3297. toArray(): FloatArray;
  3298. /**
  3299. * Stores the matrix in a Float32Array or Array<number>
  3300. * Example Playground - https://playground.babylonjs.com/#AV9X17#49
  3301. * @param array The destination array
  3302. * @param index The destination index to start ay
  3303. * @returns the matrix
  3304. */
  3305. toArray(array: FloatArray, index: number): this;
  3306. /**
  3307. * Returns the matrix as a Float32Array or Array<number>
  3308. * Example Playground - https://playground.babylonjs.com/#AV9X17#114
  3309. * @returns the matrix underlying array.
  3310. */
  3311. asArray(): Tuple<number, 16>;
  3312. fromArray(array: FloatArray, index?: number): this;
  3313. copyFromFloats(...floats: Tuple<number, 16>): this;
  3314. set(...values: Tuple<number, 16>): this;
  3315. setAll(value: number): this;
  3316. /**
  3317. * Inverts the current matrix in place
  3318. * Example Playground - https://playground.babylonjs.com/#AV9X17#118
  3319. * @returns the current inverted matrix
  3320. */
  3321. invert(): this;
  3322. /**
  3323. * Sets all the matrix elements to zero
  3324. * @returns the current matrix
  3325. */
  3326. reset(): this;
  3327. /**
  3328. * Adds the current matrix with a second one
  3329. * Example Playground - https://playground.babylonjs.com/#AV9X17#44
  3330. * @param other defines the matrix to add
  3331. * @returns a new matrix as the addition of the current matrix and the given one
  3332. */
  3333. add(other: DeepImmutable<Matrix>): this;
  3334. /**
  3335. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3336. * Example Playground - https://playground.babylonjs.com/#AV9X17#45
  3337. * @param other defines the matrix to add
  3338. * @param result defines the target matrix
  3339. * @returns result input
  3340. */
  3341. addToRef<T extends Matrix>(other: DeepImmutable<Matrix>, result: T): T;
  3342. /**
  3343. * Adds in place the given matrix to the current matrix
  3344. * Example Playground - https://playground.babylonjs.com/#AV9X17#46
  3345. * @param other defines the second operand
  3346. * @returns the current updated matrix
  3347. */
  3348. addToSelf(other: DeepImmutable<Matrix>): this;
  3349. addInPlace(other: DeepImmutable<this>): this;
  3350. addInPlaceFromFloats(...floats: Tuple<number, 16>): this;
  3351. subtract(other: DeepImmutable<this>): this;
  3352. subtractToRef<T extends this>(other: DeepImmutable<this>, result: T): T;
  3353. subtractInPlace(other: DeepImmutable<this>): this;
  3354. subtractFromFloats(...floats: Tuple<number, 16>): this;
  3355. subtractFromFloatsToRef<T extends this>(...args: [...Tuple<number, 16>, T]): T;
  3356. /**
  3357. * Sets the given matrix to the current inverted Matrix
  3358. * Example Playground - https://playground.babylonjs.com/#AV9X17#119
  3359. * @param other defines the target matrix
  3360. * @returns result input
  3361. */
  3362. invertToRef<T extends Matrix>(other: T): T;
  3363. /**
  3364. * add a value at the specified position in the current Matrix
  3365. * Example Playground - https://playground.babylonjs.com/#AV9X17#47
  3366. * @param index the index of the value within the matrix. between 0 and 15.
  3367. * @param value the value to be added
  3368. * @returns the current updated matrix
  3369. */
  3370. addAtIndex(index: number, value: number): this;
  3371. /**
  3372. * mutiply the specified position in the current Matrix by a value
  3373. * @param index the index of the value within the matrix. between 0 and 15.
  3374. * @param value the value to be added
  3375. * @returns the current updated matrix
  3376. */
  3377. multiplyAtIndex(index: number, value: number): this;
  3378. /**
  3379. * Inserts the translation vector (using 3 floats) in the current matrix
  3380. * Example Playground - https://playground.babylonjs.com/#AV9X17#120
  3381. * @param x defines the 1st component of the translation
  3382. * @param y defines the 2nd component of the translation
  3383. * @param z defines the 3rd component of the translation
  3384. * @returns the current updated matrix
  3385. */
  3386. setTranslationFromFloats(x: number, y: number, z: number): this;
  3387. /**
  3388. * Adds the translation vector (using 3 floats) in the current matrix
  3389. * Example Playground - https://playground.babylonjs.com/#AV9X17#20
  3390. * Example Playground - https://playground.babylonjs.com/#AV9X17#48
  3391. * @param x defines the 1st component of the translation
  3392. * @param y defines the 2nd component of the translation
  3393. * @param z defines the 3rd component of the translation
  3394. * @returns the current updated matrix
  3395. */
  3396. addTranslationFromFloats(x: number, y: number, z: number): this;
  3397. /**
  3398. * Inserts the translation vector in the current matrix
  3399. * Example Playground - https://playground.babylonjs.com/#AV9X17#121
  3400. * @param vector3 defines the translation to insert
  3401. * @returns the current updated matrix
  3402. */
  3403. setTranslation(vector3: DeepImmutable<Vector3>): this;
  3404. /**
  3405. * Gets the translation value of the current matrix
  3406. * Example Playground - https://playground.babylonjs.com/#AV9X17#122
  3407. * @returns a new Vector3 as the extracted translation from the matrix
  3408. */
  3409. getTranslation(): Vector3;
  3410. /**
  3411. * Fill a Vector3 with the extracted translation from the matrix
  3412. * Example Playground - https://playground.babylonjs.com/#AV9X17#123
  3413. * @param result defines the Vector3 where to store the translation
  3414. * @returns the current matrix
  3415. */
  3416. getTranslationToRef<T extends Vector3>(result: T): T;
  3417. /**
  3418. * Remove rotation and scaling part from the matrix
  3419. * @returns the updated matrix
  3420. */
  3421. removeRotationAndScaling(): this;
  3422. /**
  3423. * Copy the current matrix from the given one
  3424. * Example Playground - https://playground.babylonjs.com/#AV9X17#21
  3425. * @param other defines the source matrix
  3426. * @returns the current updated matrix
  3427. */
  3428. copyFrom(other: DeepImmutable<Matrix>): this;
  3429. /**
  3430. * Populates the given array from the starting index with the current matrix values
  3431. * @param array defines the target array
  3432. * @param offset defines the offset in the target array where to start storing values
  3433. * @returns the current matrix
  3434. */
  3435. copyToArray(array: Float32Array | Array<number>, offset?: number): this;
  3436. /**
  3437. * Multiply two matrices
  3438. * Example Playground - https://playground.babylonjs.com/#AV9X17#15
  3439. * A.multiply(B) means apply B to A so result is B x A
  3440. * @param other defines the second operand
  3441. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3442. */
  3443. multiply(other: DeepImmutable<Matrix>): this;
  3444. /**
  3445. * This method performs component-by-component in-place multiplication, rather than true matrix multiplication.
  3446. * Use multiply or multiplyToRef for matrix multiplication.
  3447. * @param other defines the second operand
  3448. * @returns the current updated matrix
  3449. */
  3450. multiplyInPlace(other: DeepImmutable<this>): this;
  3451. /**
  3452. * This method performs a component-by-component multiplication of the current matrix with the array of transmitted numbers.
  3453. * Use multiply or multiplyToRef for matrix multiplication.
  3454. * @param floats defines the array of numbers to multiply the matrix by
  3455. * @returns the current updated matrix
  3456. */
  3457. multiplyByFloats(...floats: Tuple<number, 16>): this;
  3458. /**
  3459. * Multiples the current matrix by the given floats and stores them in the given ref
  3460. * @param args The floats and ref
  3461. * @returns The updated ref
  3462. */
  3463. multiplyByFloatsToRef<T extends this>(...args: [...Tuple<number, 16>, T]): T;
  3464. /**
  3465. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3466. * A.multiplyToRef(B, R) means apply B to A and store in R and R = B x A
  3467. * Example Playground - https://playground.babylonjs.com/#AV9X17#16
  3468. * @param other defines the second operand
  3469. * @param result defines the matrix where to store the multiplication
  3470. * @returns result input
  3471. */
  3472. multiplyToRef<T extends Matrix>(other: DeepImmutable<Matrix>, result: T): T;
  3473. /**
  3474. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3475. * @param other defines the second operand
  3476. * @param result defines the array where to store the multiplication
  3477. * @param offset defines the offset in the target array where to start storing values
  3478. * @returns the current matrix
  3479. */
  3480. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): this;
  3481. divide(other: DeepImmutable<this>): this;
  3482. divideToRef<T extends this>(other: DeepImmutable<this>, result: T): T;
  3483. divideInPlace(other: DeepImmutable<this>): this;
  3484. minimizeInPlace(other: DeepImmutable<this>): this;
  3485. minimizeInPlaceFromFloats(...floats: Tuple<number, 16>): this;
  3486. maximizeInPlace(other: DeepImmutable<this>): this;
  3487. maximizeInPlaceFromFloats(...floats: Tuple<number, 16>): this;
  3488. negate(): this;
  3489. negateInPlace(): this;
  3490. negateToRef<T extends this>(result: T): T;
  3491. /**
  3492. * Check equality between this matrix and a second one
  3493. * @param value defines the second matrix to compare
  3494. * @returns true is the current matrix and the given one values are strictly equal
  3495. */
  3496. equals(value: DeepImmutable<Matrix>): boolean;
  3497. equalsWithEpsilon(other: DeepImmutable<this>, epsilon?: number): boolean;
  3498. equalsToFloats(...floats: Tuple<number, 16>): boolean;
  3499. floor(): this;
  3500. floorToRef<T extends this>(result: T): T;
  3501. fract(): this;
  3502. fractToRef<T extends this>(result: T): T;
  3503. /**
  3504. * Clone the current matrix
  3505. * Example Playground - https://playground.babylonjs.com/#AV9X17#18
  3506. * @returns a new matrix from the current matrix
  3507. */
  3508. clone(): this;
  3509. /**
  3510. * Returns the name of the current matrix class
  3511. * @returns the string "Matrix"
  3512. */
  3513. getClassName(): string;
  3514. /**
  3515. * Gets the hash code of the current matrix
  3516. * @returns the hash code
  3517. */
  3518. getHashCode(): number;
  3519. /**
  3520. * Decomposes the current Matrix into a translation, rotation and scaling components of the provided node
  3521. * Example Playground - https://playground.babylonjs.com/#AV9X17#13
  3522. * @param node the node to decompose the matrix to
  3523. * @returns true if operation was successful
  3524. */
  3525. decomposeToTransformNode(node: TransformNode): boolean;
  3526. /**
  3527. * Decomposes the current Matrix into a translation, rotation and scaling components
  3528. * Example Playground - https://playground.babylonjs.com/#AV9X17#12
  3529. * @param scale defines the scale vector3 given as a reference to update
  3530. * @param rotation defines the rotation quaternion given as a reference to update
  3531. * @param translation defines the translation vector3 given as a reference to update
  3532. * @param preserveScalingNode Use scaling sign coming from this node. Otherwise scaling sign might change.
  3533. * @param useAbsoluteScaling Use scaling sign coming from this absoluteScaling when true or scaling otherwise.
  3534. * @returns true if operation was successful
  3535. */
  3536. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3, preserveScalingNode?: TransformNode, useAbsoluteScaling?: boolean): boolean;
  3537. /**
  3538. * Gets specific row of the matrix
  3539. * Example Playground - https://playground.babylonjs.com/#AV9X17#36
  3540. * @param index defines the number of the row to get
  3541. * @returns the index-th row of the current matrix as a new Vector4
  3542. */
  3543. getRow(index: number): Nullable<Vector4>;
  3544. /**
  3545. * Gets specific row of the matrix to ref
  3546. * Example Playground - https://playground.babylonjs.com/#AV9X17#36
  3547. * @param index defines the number of the row to get
  3548. * @param rowVector vector to store the index-th row of the current matrix
  3549. * @returns result input
  3550. */
  3551. getRowToRef<T extends Vector4>(index: number, rowVector: T): T;
  3552. /**
  3553. * Sets the index-th row of the current matrix to the vector4 values
  3554. * Example Playground - https://playground.babylonjs.com/#AV9X17#36
  3555. * @param index defines the number of the row to set
  3556. * @param row defines the target vector4
  3557. * @returns the updated current matrix
  3558. */
  3559. setRow(index: number, row: Vector4): this;
  3560. /**
  3561. * Compute the transpose of the matrix
  3562. * Example Playground - https://playground.babylonjs.com/#AV9X17#40
  3563. * @returns the new transposed matrix
  3564. */
  3565. transpose(): this;
  3566. /**
  3567. * Compute the transpose of the matrix and store it in a given matrix
  3568. * Example Playground - https://playground.babylonjs.com/#AV9X17#41
  3569. * @param result defines the target matrix
  3570. * @returns result input
  3571. */
  3572. transposeToRef<T extends Matrix>(result: T): T;
  3573. /**
  3574. * Sets the index-th row of the current matrix with the given 4 x float values
  3575. * Example Playground - https://playground.babylonjs.com/#AV9X17#36
  3576. * @param index defines the row index
  3577. * @param x defines the x component to set
  3578. * @param y defines the y component to set
  3579. * @param z defines the z component to set
  3580. * @param w defines the w component to set
  3581. * @returns the updated current matrix
  3582. */
  3583. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): this;
  3584. /**
  3585. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3586. * @param scale defines the scale factor
  3587. * @returns a new matrix
  3588. */
  3589. scale(scale: number): this;
  3590. /**
  3591. * Scale the current matrix values by a factor to a given result matrix
  3592. * @param scale defines the scale factor
  3593. * @param result defines the matrix to store the result
  3594. * @returns result input
  3595. */
  3596. scaleToRef<T extends Matrix>(scale: number, result: T): T;
  3597. /**
  3598. * Scale the current matrix values by a factor and add the result to a given matrix
  3599. * @param scale defines the scale factor
  3600. * @param result defines the Matrix to store the result
  3601. * @returns result input
  3602. */
  3603. scaleAndAddToRef<T extends Matrix>(scale: number, result: T): T;
  3604. scaleInPlace(scale: number): this;
  3605. /**
  3606. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3607. * Example Playground - https://playground.babylonjs.com/#AV9X17#17
  3608. * @param ref matrix to store the result
  3609. * @returns the reference matrix
  3610. */
  3611. toNormalMatrix<T extends Matrix>(ref: T): T;
  3612. /**
  3613. * Gets only rotation part of the current matrix
  3614. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3615. */
  3616. getRotationMatrix(): this;
  3617. /**
  3618. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3619. * @param result defines the target matrix to store data to
  3620. * @returns result input
  3621. */
  3622. getRotationMatrixToRef<T extends Matrix>(result: T): T;
  3623. /**
  3624. * Toggles model matrix from being right handed to left handed in place and vice versa
  3625. * @returns the current updated matrix
  3626. */
  3627. toggleModelMatrixHandInPlace(): this;
  3628. /**
  3629. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3630. * @returns the current updated matrix
  3631. */
  3632. toggleProjectionMatrixHandInPlace(): this;
  3633. /**
  3634. * Creates a matrix from an array
  3635. * Example Playground - https://playground.babylonjs.com/#AV9X17#42
  3636. * @param array defines the source array
  3637. * @param offset defines an offset in the source array
  3638. * @returns a new Matrix set from the starting index of the given array
  3639. */
  3640. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3641. /**
  3642. * Copy the content of an array into a given matrix
  3643. * Example Playground - https://playground.babylonjs.com/#AV9X17#43
  3644. * @param array defines the source array
  3645. * @param offset defines an offset in the source array
  3646. * @param result defines the target matrix
  3647. * @returns result input
  3648. */
  3649. static FromArrayToRef<T extends Matrix>(array: DeepImmutable<ArrayLike<number>>, offset: number, result: T): T;
  3650. /**
  3651. * Stores an array into a matrix after having multiplied each component by a given factor
  3652. * Example Playground - https://playground.babylonjs.com/#AV9X17#50
  3653. * @param array defines the source array
  3654. * @param offset defines the offset in the source array
  3655. * @param scale defines the scaling factor
  3656. * @param result defines the target matrix
  3657. * @returns result input
  3658. */
  3659. static FromFloat32ArrayToRefScaled<T extends Matrix>(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: T): T;
  3660. /**
  3661. * Gets an identity matrix that must not be updated
  3662. */
  3663. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  3664. /**
  3665. * Stores a list of values (16) inside a given matrix
  3666. * @param initialM11 defines 1st value of 1st row
  3667. * @param initialM12 defines 2nd value of 1st row
  3668. * @param initialM13 defines 3rd value of 1st row
  3669. * @param initialM14 defines 4th value of 1st row
  3670. * @param initialM21 defines 1st value of 2nd row
  3671. * @param initialM22 defines 2nd value of 2nd row
  3672. * @param initialM23 defines 3rd value of 2nd row
  3673. * @param initialM24 defines 4th value of 2nd row
  3674. * @param initialM31 defines 1st value of 3rd row
  3675. * @param initialM32 defines 2nd value of 3rd row
  3676. * @param initialM33 defines 3rd value of 3rd row
  3677. * @param initialM34 defines 4th value of 3rd row
  3678. * @param initialM41 defines 1st value of 4th row
  3679. * @param initialM42 defines 2nd value of 4th row
  3680. * @param initialM43 defines 3rd value of 4th row
  3681. * @param initialM44 defines 4th value of 4th row
  3682. * @param result defines the target matrix
  3683. */
  3684. 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;
  3685. /**
  3686. * Creates new matrix from a list of values (16)
  3687. * @param initialM11 defines 1st value of 1st row
  3688. * @param initialM12 defines 2nd value of 1st row
  3689. * @param initialM13 defines 3rd value of 1st row
  3690. * @param initialM14 defines 4th value of 1st row
  3691. * @param initialM21 defines 1st value of 2nd row
  3692. * @param initialM22 defines 2nd value of 2nd row
  3693. * @param initialM23 defines 3rd value of 2nd row
  3694. * @param initialM24 defines 4th value of 2nd row
  3695. * @param initialM31 defines 1st value of 3rd row
  3696. * @param initialM32 defines 2nd value of 3rd row
  3697. * @param initialM33 defines 3rd value of 3rd row
  3698. * @param initialM34 defines 4th value of 3rd row
  3699. * @param initialM41 defines 1st value of 4th row
  3700. * @param initialM42 defines 2nd value of 4th row
  3701. * @param initialM43 defines 3rd value of 4th row
  3702. * @param initialM44 defines 4th value of 4th row
  3703. * @returns the new matrix
  3704. */
  3705. 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;
  3706. /**
  3707. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3708. * Example Playground - https://playground.babylonjs.com/#AV9X17#24
  3709. * @param scale defines the scale vector3
  3710. * @param rotation defines the rotation quaternion
  3711. * @param translation defines the translation vector3
  3712. * @returns a new matrix
  3713. */
  3714. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3715. /**
  3716. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3717. * Example Playground - https://playground.babylonjs.com/#AV9X17#25
  3718. * @param scale defines the scale vector3
  3719. * @param rotation defines the rotation quaternion
  3720. * @param translation defines the translation vector3
  3721. * @param result defines the target matrix
  3722. * @returns result input
  3723. */
  3724. static ComposeToRef<T extends Matrix>(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: T): T;
  3725. /**
  3726. * Creates a new identity matrix
  3727. * @returns a new identity matrix
  3728. */
  3729. static Identity(): Matrix;
  3730. /**
  3731. * Creates a new identity matrix and stores the result in a given matrix
  3732. * @param result defines the target matrix
  3733. * @returns result input
  3734. */
  3735. static IdentityToRef<T extends Matrix>(result: T): T;
  3736. /**
  3737. * Creates a new zero matrix
  3738. * @returns a new zero matrix
  3739. */
  3740. static Zero(): Matrix;
  3741. /**
  3742. * Creates a new rotation matrix for "angle" radians around the X axis
  3743. * Example Playground - https://playground.babylonjs.com/#AV9X17#97
  3744. * @param angle defines the angle (in radians) to use
  3745. * @returns the new matrix
  3746. */
  3747. static RotationX(angle: number): Matrix;
  3748. /**
  3749. * Creates a new matrix as the invert of a given matrix
  3750. * Example Playground - https://playground.babylonjs.com/#AV9X17#124
  3751. * @param source defines the source matrix
  3752. * @returns the new matrix
  3753. */
  3754. static Invert<T extends Matrix>(source: DeepImmutable<T>): T;
  3755. /**
  3756. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3757. * Example Playground - https://playground.babylonjs.com/#AV9X17#98
  3758. * @param angle defines the angle (in radians) to use
  3759. * @param result defines the target matrix
  3760. * @returns result input
  3761. */
  3762. static RotationXToRef<T extends Matrix>(angle: number, result: T): T;
  3763. /**
  3764. * Creates a new rotation matrix for "angle" radians around the Y axis
  3765. * Example Playground - https://playground.babylonjs.com/#AV9X17#99
  3766. * @param angle defines the angle (in radians) to use
  3767. * @returns the new matrix
  3768. */
  3769. static RotationY(angle: number): Matrix;
  3770. /**
  3771. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3772. * Example Playground - https://playground.babylonjs.com/#AV9X17#100
  3773. * @param angle defines the angle (in radians) to use
  3774. * @param result defines the target matrix
  3775. * @returns result input
  3776. */
  3777. static RotationYToRef<T extends Matrix>(angle: number, result: T): T;
  3778. /**
  3779. * Creates a new rotation matrix for "angle" radians around the Z axis
  3780. * Example Playground - https://playground.babylonjs.com/#AV9X17#101
  3781. * @param angle defines the angle (in radians) to use
  3782. * @returns the new matrix
  3783. */
  3784. static RotationZ(angle: number): Matrix;
  3785. /**
  3786. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3787. * Example Playground - https://playground.babylonjs.com/#AV9X17#102
  3788. * @param angle defines the angle (in radians) to use
  3789. * @param result defines the target matrix
  3790. * @returns result input
  3791. */
  3792. static RotationZToRef<T extends Matrix>(angle: number, result: T): T;
  3793. /**
  3794. * Creates a new rotation matrix for "angle" radians around the given axis
  3795. * Example Playground - https://playground.babylonjs.com/#AV9X17#96
  3796. * @param axis defines the axis to use
  3797. * @param angle defines the angle (in radians) to use
  3798. * @returns the new matrix
  3799. */
  3800. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3801. /**
  3802. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3803. * Example Playground - https://playground.babylonjs.com/#AV9X17#94
  3804. * @param axis defines the axis to use
  3805. * @param angle defines the angle (in radians) to use
  3806. * @param result defines the target matrix
  3807. * @returns result input
  3808. */
  3809. static RotationAxisToRef<T extends Matrix>(axis: DeepImmutable<Vector3>, angle: number, result: T): T;
  3810. /**
  3811. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3812. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3813. * Example Playground - https://playground.babylonjs.com/#AV9X17#93
  3814. * @param from defines the vector to align
  3815. * @param to defines the vector to align to
  3816. * @param result defines the target matrix
  3817. * @param useYAxisForCoplanar defines a boolean indicating that we should favor Y axis for coplanar vectors (default is false)
  3818. * @returns result input
  3819. */
  3820. static RotationAlignToRef<T extends Matrix>(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: T, useYAxisForCoplanar?: boolean): T;
  3821. /**
  3822. * Creates a rotation matrix
  3823. * Example Playground - https://playground.babylonjs.com/#AV9X17#103
  3824. * Example Playground - https://playground.babylonjs.com/#AV9X17#105
  3825. * @param yaw defines the yaw angle in radians (Y axis)
  3826. * @param pitch defines the pitch angle in radians (X axis)
  3827. * @param roll defines the roll angle in radians (Z axis)
  3828. * @returns the new rotation matrix
  3829. */
  3830. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3831. /**
  3832. * Creates a rotation matrix and stores it in a given matrix
  3833. * Example Playground - https://playground.babylonjs.com/#AV9X17#104
  3834. * @param yaw defines the yaw angle in radians (Y axis)
  3835. * @param pitch defines the pitch angle in radians (X axis)
  3836. * @param roll defines the roll angle in radians (Z axis)
  3837. * @param result defines the target matrix
  3838. * @returns result input
  3839. */
  3840. static RotationYawPitchRollToRef<T extends Matrix>(yaw: number, pitch: number, roll: number, result: T): T;
  3841. /**
  3842. * Creates a scaling matrix
  3843. * Example Playground - https://playground.babylonjs.com/#AV9X17#107
  3844. * @param x defines the scale factor on X axis
  3845. * @param y defines the scale factor on Y axis
  3846. * @param z defines the scale factor on Z axis
  3847. * @returns the new matrix
  3848. */
  3849. static Scaling(x: number, y: number, z: number): Matrix;
  3850. /**
  3851. * Creates a scaling matrix and stores it in a given matrix
  3852. * Example Playground - https://playground.babylonjs.com/#AV9X17#108
  3853. * @param x defines the scale factor on X axis
  3854. * @param y defines the scale factor on Y axis
  3855. * @param z defines the scale factor on Z axis
  3856. * @param result defines the target matrix
  3857. * @returns result input
  3858. */
  3859. static ScalingToRef<T extends Matrix>(x: number, y: number, z: number, result: T): T;
  3860. /**
  3861. * Creates a translation matrix
  3862. * Example Playground - https://playground.babylonjs.com/#AV9X17#109
  3863. * @param x defines the translation on X axis
  3864. * @param y defines the translation on Y axis
  3865. * @param z defines the translationon Z axis
  3866. * @returns the new matrix
  3867. */
  3868. static Translation(x: number, y: number, z: number): Matrix;
  3869. /**
  3870. * Creates a translation matrix and stores it in a given matrix
  3871. * Example Playground - https://playground.babylonjs.com/#AV9X17#110
  3872. * @param x defines the translation on X axis
  3873. * @param y defines the translation on Y axis
  3874. * @param z defines the translationon Z axis
  3875. * @param result defines the target matrix
  3876. * @returns result input
  3877. */
  3878. static TranslationToRef<T extends Matrix>(x: number, y: number, z: number, result: T): T;
  3879. /**
  3880. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3881. * Example Playground - https://playground.babylonjs.com/#AV9X17#55
  3882. * @param startValue defines the start value
  3883. * @param endValue defines the end value
  3884. * @param gradient defines the gradient factor
  3885. * @returns the new matrix
  3886. */
  3887. static Lerp<T extends Matrix>(startValue: DeepImmutable<T>, endValue: DeepImmutable<Matrix>, gradient: number): T;
  3888. /**
  3889. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3890. * Example Playground - https://playground.babylonjs.com/#AV9X17#54
  3891. * @param startValue defines the start value
  3892. * @param endValue defines the end value
  3893. * @param gradient defines the gradient factor
  3894. * @param result defines the Matrix object where to store data
  3895. * @returns result input
  3896. */
  3897. static LerpToRef<T extends Matrix>(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: T): T;
  3898. /**
  3899. * Builds a new matrix whose values are computed by:
  3900. * * decomposing the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3901. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3902. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3903. * Example Playground - https://playground.babylonjs.com/#AV9X17#22
  3904. * Example Playground - https://playground.babylonjs.com/#AV9X17#51
  3905. * @param startValue defines the first matrix
  3906. * @param endValue defines the second matrix
  3907. * @param gradient defines the gradient between the two matrices
  3908. * @returns the new matrix
  3909. */
  3910. static DecomposeLerp<T extends Matrix>(startValue: DeepImmutable<T>, endValue: DeepImmutable<Matrix>, gradient: number): T;
  3911. /**
  3912. * Update a matrix to values which are computed by:
  3913. * * decomposing the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3914. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3915. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3916. * Example Playground - https://playground.babylonjs.com/#AV9X17#23
  3917. * Example Playground - https://playground.babylonjs.com/#AV9X17#53
  3918. * @param startValue defines the first matrix
  3919. * @param endValue defines the second matrix
  3920. * @param gradient defines the gradient between the two matrices
  3921. * @param result defines the target matrix
  3922. * @returns result input
  3923. */
  3924. static DecomposeLerpToRef<T extends Matrix>(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: T): T;
  3925. /**
  3926. * Creates a new matrix that transforms vertices from world space to camera space. It takes three vectors as arguments that together describe the position and orientation of the camera.
  3927. * This function generates a matrix suitable for a left handed coordinate system
  3928. * Example Playground - https://playground.babylonjs.com/#AV9X17#58
  3929. * Example Playground - https://playground.babylonjs.com/#AV9X17#59
  3930. * @param eye defines the final position of the entity
  3931. * @param target defines where the entity should look at
  3932. * @param up defines the up vector for the entity
  3933. * @returns the new matrix
  3934. */
  3935. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3936. /**
  3937. * Sets the given "result" Matrix to a matrix that transforms vertices from world space to camera space. It takes three vectors as arguments that together describe the position and orientation of the camera.
  3938. * This function generates a matrix suitable for a left handed coordinate system
  3939. * Example Playground - https://playground.babylonjs.com/#AV9X17#60
  3940. * Example Playground - https://playground.babylonjs.com/#AV9X17#61
  3941. * @param eye defines the final position of the entity
  3942. * @param target defines where the entity should look at
  3943. * @param up defines the up vector for the entity
  3944. * @param result defines the target matrix
  3945. * @returns result input
  3946. */
  3947. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): Matrix;
  3948. /**
  3949. * Creates a new matrix that transforms vertices from world space to camera space. It takes three vectors as arguments that together describe the position and orientation of the camera.
  3950. * This function generates a matrix suitable for a right handed coordinate system
  3951. * Example Playground - https://playground.babylonjs.com/#AV9X17#62
  3952. * Example Playground - https://playground.babylonjs.com/#AV9X17#63
  3953. * @param eye defines the final position of the entity
  3954. * @param target defines where the entity should look at
  3955. * @param up defines the up vector for the entity
  3956. * @returns the new matrix
  3957. */
  3958. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3959. /**
  3960. * Sets the given "result" Matrix to a matrix that transforms vertices from world space to camera space. It takes three vectors as arguments that together describe the position and orientation of the camera.
  3961. * This function generates a matrix suitable for a right handed coordinate system
  3962. * Example Playground - https://playground.babylonjs.com/#AV9X17#64
  3963. * Example Playground - https://playground.babylonjs.com/#AV9X17#65
  3964. * @param eye defines the final position of the entity
  3965. * @param target defines where the entity should look at
  3966. * @param up defines the up vector for the entity
  3967. * @param result defines the target matrix
  3968. * @returns result input
  3969. */
  3970. static LookAtRHToRef<T extends Matrix>(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: T): T;
  3971. /**
  3972. * Creates a new matrix that transforms vertices from world space to camera space. It takes two vectors as arguments that together describe the orientation of the camera. The position is assumed to be at the origin (0,0,0)
  3973. * This function generates a matrix suitable for a left handed coordinate system
  3974. * Example Playground - https://playground.babylonjs.com/#AV9X17#66
  3975. * @param forward defines the forward direction - Must be normalized and orthogonal to up.
  3976. * @param up defines the up vector for the entity - Must be normalized and orthogonal to forward.
  3977. * @returns the new matrix
  3978. */
  3979. static LookDirectionLH(forward: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3980. /**
  3981. * Sets the given "result" Matrix to a matrix that transforms vertices from world space to camera space. It takes two vectors as arguments that together describe the orientation of the camera. The position is assumed to be at the origin (0,0,0)
  3982. * This function generates a matrix suitable for a left handed coordinate system
  3983. * Example Playground - https://playground.babylonjs.com/#AV9X17#67
  3984. * @param forward defines the forward direction - Must be normalized and orthogonal to up.
  3985. * @param up defines the up vector for the entity - Must be normalized and orthogonal to forward.
  3986. * @param result defines the target matrix
  3987. * @returns result input
  3988. */
  3989. static LookDirectionLHToRef<T extends Matrix>(forward: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: T): T;
  3990. /**
  3991. * Creates a new matrix that transforms vertices from world space to camera space. It takes two vectors as arguments that together describe the orientation of the camera. The position is assumed to be at the origin (0,0,0)
  3992. * This function generates a matrix suitable for a right handed coordinate system
  3993. * Example Playground - https://playground.babylonjs.com/#AV9X17#68
  3994. * @param forward defines the forward direction - Must be normalized and orthogonal to up.
  3995. * @param up defines the up vector for the entity - Must be normalized and orthogonal to forward.
  3996. * @returns the new matrix
  3997. */
  3998. static LookDirectionRH(forward: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3999. /**
  4000. * Sets the given "result" Matrix to a matrix that transforms vertices from world space to camera space. It takes two vectors as arguments that together describe the orientation of the camera. The position is assumed to be at the origin (0,0,0)
  4001. * This function generates a matrix suitable for a right handed coordinate system
  4002. * Example Playground - https://playground.babylonjs.com/#AV9X17#69
  4003. * @param forward defines the forward direction - Must be normalized and orthogonal to up.
  4004. * @param up defines the up vector for the entity - Must be normalized and orthogonal to forward.
  4005. * @param result defines the target matrix
  4006. * @returns result input
  4007. */
  4008. static LookDirectionRHToRef<T extends Matrix>(forward: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: T): T;
  4009. /**
  4010. * Create a left-handed orthographic projection matrix
  4011. * Example Playground - https://playground.babylonjs.com/#AV9X17#70
  4012. * @param width defines the viewport width
  4013. * @param height defines the viewport height
  4014. * @param znear defines the near clip plane
  4015. * @param zfar defines the far clip plane
  4016. * @param halfZRange true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
  4017. * @returns a new matrix as a left-handed orthographic projection matrix
  4018. */
  4019. static OrthoLH(width: number, height: number, znear: number, zfar: number, halfZRange?: boolean): Matrix;
  4020. /**
  4021. * Store a left-handed orthographic projection to a given matrix
  4022. * Example Playground - https://playground.babylonjs.com/#AV9X17#71
  4023. * @param width defines the viewport width
  4024. * @param height defines the viewport height
  4025. * @param znear defines the near clip plane
  4026. * @param zfar defines the far clip plane
  4027. * @param result defines the target matrix
  4028. * @param halfZRange true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
  4029. * @returns result input
  4030. */
  4031. static OrthoLHToRef<T extends Matrix>(width: number, height: number, znear: number, zfar: number, result: T, halfZRange?: boolean): T;
  4032. /**
  4033. * Create a left-handed orthographic projection matrix
  4034. * Example Playground - https://playground.babylonjs.com/#AV9X17#72
  4035. * @param left defines the viewport left coordinate
  4036. * @param right defines the viewport right coordinate
  4037. * @param bottom defines the viewport bottom coordinate
  4038. * @param top defines the viewport top coordinate
  4039. * @param znear defines the near clip plane
  4040. * @param zfar defines the far clip plane
  4041. * @param halfZRange true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
  4042. * @returns a new matrix as a left-handed orthographic projection matrix
  4043. */
  4044. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, halfZRange?: boolean): Matrix;
  4045. /**
  4046. * Stores a left-handed orthographic projection into a given matrix
  4047. * Example Playground - https://playground.babylonjs.com/#AV9X17#73
  4048. * @param left defines the viewport left coordinate
  4049. * @param right defines the viewport right coordinate
  4050. * @param bottom defines the viewport bottom coordinate
  4051. * @param top defines the viewport top coordinate
  4052. * @param znear defines the near clip plane
  4053. * @param zfar defines the far clip plane
  4054. * @param result defines the target matrix
  4055. * @param halfZRange true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
  4056. * @returns result input
  4057. */
  4058. static OrthoOffCenterLHToRef<T extends Matrix>(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: T, halfZRange?: boolean): T;
  4059. /**
  4060. * Stores a left-handed oblique projection into a given matrix
  4061. * @param left defines the viewport left coordinate
  4062. * @param right defines the viewport right coordinate
  4063. * @param bottom defines the viewport bottom coordinate
  4064. * @param top defines the viewport top coordinate
  4065. * @param znear defines the near clip plane
  4066. * @param zfar defines the far clip plane
  4067. * @param length Length of the shear
  4068. * @param angle Angle (along X/Y Plane) to apply shear
  4069. * @param distance Distance from shear point
  4070. * @param result defines the target matrix
  4071. * @param halfZRange true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
  4072. * @returns result input
  4073. */
  4074. static ObliqueOffCenterLHToRef<T extends Matrix>(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, length: number, angle: number, distance: number, result: T, halfZRange?: boolean): T;
  4075. /**
  4076. * Creates a right-handed orthographic projection matrix
  4077. * Example Playground - https://playground.babylonjs.com/#AV9X17#76
  4078. * @param left defines the viewport left coordinate
  4079. * @param right defines the viewport right coordinate
  4080. * @param bottom defines the viewport bottom coordinate
  4081. * @param top defines the viewport top coordinate
  4082. * @param znear defines the near clip plane
  4083. * @param zfar defines the far clip plane
  4084. * @param halfZRange true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
  4085. * @returns a new matrix as a right-handed orthographic projection matrix
  4086. */
  4087. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, halfZRange?: boolean): Matrix;
  4088. /**
  4089. * Stores a right-handed orthographic projection into a given matrix
  4090. * Example Playground - https://playground.babylonjs.com/#AV9X17#77
  4091. * @param left defines the viewport left coordinate
  4092. * @param right defines the viewport right coordinate
  4093. * @param bottom defines the viewport bottom coordinate
  4094. * @param top defines the viewport top coordinate
  4095. * @param znear defines the near clip plane
  4096. * @param zfar defines the far clip plane
  4097. * @param result defines the target matrix
  4098. * @param halfZRange true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
  4099. * @returns result input
  4100. */
  4101. static OrthoOffCenterRHToRef<T extends Matrix>(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: T, halfZRange?: boolean): T;
  4102. /**
  4103. * Stores a right-handed oblique projection into a given matrix
  4104. * @param left defines the viewport left coordinate
  4105. * @param right defines the viewport right coordinate
  4106. * @param bottom defines the viewport bottom coordinate
  4107. * @param top defines the viewport top coordinate
  4108. * @param znear defines the near clip plane
  4109. * @param zfar defines the far clip plane
  4110. * @param length Length of the shear
  4111. * @param angle Angle (along X/Y Plane) to apply shear
  4112. * @param distance Distance from shear point
  4113. * @param result defines the target matrix
  4114. * @param halfZRange true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
  4115. * @returns result input
  4116. */
  4117. static ObliqueOffCenterRHToRef<T extends Matrix>(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, length: number, angle: number, distance: number, result: T, halfZRange?: boolean): T;
  4118. /**
  4119. * Creates a left-handed perspective projection matrix
  4120. * Example Playground - https://playground.babylonjs.com/#AV9X17#85
  4121. * @param width defines the viewport width
  4122. * @param height defines the viewport height
  4123. * @param znear defines the near clip plane
  4124. * @param zfar defines the far clip plane
  4125. * @param halfZRange true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
  4126. * @param projectionPlaneTilt optional tilt angle of the projection plane around the X axis (horizontal)
  4127. * @returns a new matrix as a left-handed perspective projection matrix
  4128. */
  4129. static PerspectiveLH(width: number, height: number, znear: number, zfar: number, halfZRange?: boolean, projectionPlaneTilt?: number): Matrix;
  4130. /**
  4131. * Creates a left-handed perspective projection matrix
  4132. * Example Playground - https://playground.babylonjs.com/#AV9X17#78
  4133. * @param fov defines the horizontal field of view
  4134. * @param aspect defines the aspect ratio
  4135. * @param znear defines the near clip plane
  4136. * @param zfar defines the far clip plane. If 0, assume we are in "infinite zfar" mode
  4137. * @param halfZRange true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
  4138. * @param projectionPlaneTilt optional tilt angle of the projection plane around the X axis (horizontal)
  4139. * @param reverseDepthBufferMode true to indicate that we are in a reverse depth buffer mode (meaning znear and zfar have been inverted when calling the function)
  4140. * @returns a new matrix as a left-handed perspective projection matrix
  4141. */
  4142. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number, halfZRange?: boolean, projectionPlaneTilt?: number, reverseDepthBufferMode?: boolean): Matrix;
  4143. /**
  4144. * Stores a left-handed perspective projection into a given matrix
  4145. * Example Playground - https://playground.babylonjs.com/#AV9X17#81
  4146. * @param fov defines the horizontal field of view
  4147. * @param aspect defines the aspect ratio
  4148. * @param znear defines the near clip plane
  4149. * @param zfar defines the far clip plane. If 0, assume we are in "infinite zfar" mode
  4150. * @param result defines the target matrix
  4151. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4152. * @param halfZRange true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
  4153. * @param projectionPlaneTilt optional tilt angle of the projection plane around the X axis (horizontal)
  4154. * @param reverseDepthBufferMode true to indicate that we are in a reverse depth buffer mode (meaning znear and zfar have been inverted when calling the function)
  4155. * @returns result input
  4156. */
  4157. static PerspectiveFovLHToRef<T extends Matrix>(fov: number, aspect: number, znear: number, zfar: number, result: T, isVerticalFovFixed?: boolean, halfZRange?: boolean, projectionPlaneTilt?: number, reverseDepthBufferMode?: boolean): T;
  4158. /**
  4159. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4160. * Example Playground - https://playground.babylonjs.com/#AV9X17#89
  4161. * @param fov defines the horizontal field of view
  4162. * @param aspect defines the aspect ratio
  4163. * @param znear defines the near clip plane
  4164. * @param zfar not used as infinity is used as far clip
  4165. * @param result defines the target matrix
  4166. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4167. * @param halfZRange true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
  4168. * @param projectionPlaneTilt optional tilt angle of the projection plane around the X axis (horizontal)
  4169. * @returns result input
  4170. */
  4171. static PerspectiveFovReverseLHToRef<T extends Matrix>(fov: number, aspect: number, znear: number, zfar: number, result: T, isVerticalFovFixed?: boolean, halfZRange?: boolean, projectionPlaneTilt?: number): T;
  4172. /**
  4173. * Creates a right-handed perspective projection matrix
  4174. * Example Playground - https://playground.babylonjs.com/#AV9X17#83
  4175. * @param fov defines the horizontal field of view
  4176. * @param aspect defines the aspect ratio
  4177. * @param znear defines the near clip plane
  4178. * @param zfar defines the far clip plane. If 0, assume we are in "infinite zfar" mode
  4179. * @param halfZRange true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
  4180. * @param projectionPlaneTilt optional tilt angle of the projection plane around the X axis (horizontal)
  4181. * @param reverseDepthBufferMode true to indicate that we are in a reverse depth buffer mode (meaning znear and zfar have been inverted when calling the function)
  4182. * @returns a new matrix as a right-handed perspective projection matrix
  4183. */
  4184. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number, halfZRange?: boolean, projectionPlaneTilt?: number, reverseDepthBufferMode?: boolean): Matrix;
  4185. /**
  4186. * Stores a right-handed perspective projection into a given matrix
  4187. * Example Playground - https://playground.babylonjs.com/#AV9X17#84
  4188. * @param fov defines the horizontal field of view
  4189. * @param aspect defines the aspect ratio
  4190. * @param znear defines the near clip plane
  4191. * @param zfar defines the far clip plane. If 0, assume we are in "infinite zfar" mode
  4192. * @param result defines the target matrix
  4193. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4194. * @param halfZRange true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
  4195. * @param projectionPlaneTilt optional tilt angle of the projection plane around the X axis (horizontal)
  4196. * @param reverseDepthBufferMode true to indicate that we are in a reverse depth buffer mode (meaning znear and zfar have been inverted when calling the function)
  4197. * @returns result input
  4198. */
  4199. static PerspectiveFovRHToRef<T extends Matrix>(fov: number, aspect: number, znear: number, zfar: number, result: T, isVerticalFovFixed?: boolean, halfZRange?: boolean, projectionPlaneTilt?: number, reverseDepthBufferMode?: boolean): T;
  4200. /**
  4201. * Stores a right-handed perspective projection into a given matrix
  4202. * Example Playground - https://playground.babylonjs.com/#AV9X17#90
  4203. * @param fov defines the horizontal field of view
  4204. * @param aspect defines the aspect ratio
  4205. * @param znear defines the near clip plane
  4206. * @param zfar not used as infinity is used as far clip
  4207. * @param result defines the target matrix
  4208. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4209. * @param halfZRange true to generate NDC coordinates between 0 and 1 instead of -1 and 1 (default: false)
  4210. * @param projectionPlaneTilt optional tilt angle of the projection plane around the X axis (horizontal)
  4211. * @returns result input
  4212. */
  4213. static PerspectiveFovReverseRHToRef<T extends Matrix>(fov: number, aspect: number, znear: number, zfar: number, result: T, isVerticalFovFixed?: boolean, halfZRange?: boolean, projectionPlaneTilt?: number): T;
  4214. /**
  4215. * Computes a complete transformation matrix
  4216. * Example Playground - https://playground.babylonjs.com/#AV9X17#113
  4217. * @param viewport defines the viewport to use
  4218. * @param world defines the world matrix
  4219. * @param view defines the view matrix
  4220. * @param projection defines the projection matrix
  4221. * @param zmin defines the near clip plane
  4222. * @param zmax defines the far clip plane
  4223. * @returns the transformation matrix
  4224. */
  4225. static GetFinalMatrix<T extends Matrix>(viewport: DeepImmutable<Viewport>, world: DeepImmutable<T>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): T;
  4226. /**
  4227. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4228. * @param matrix defines the matrix to use
  4229. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4230. */
  4231. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4232. /**
  4233. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4234. * @param matrix defines the matrix to use
  4235. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4236. */
  4237. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4238. /**
  4239. * Compute the transpose of a given matrix
  4240. * Example Playground - https://playground.babylonjs.com/#AV9X17#111
  4241. * @param matrix defines the matrix to transpose
  4242. * @returns the new matrix
  4243. */
  4244. static Transpose<T extends Matrix>(matrix: DeepImmutable<T>): T;
  4245. /**
  4246. * Compute the transpose of a matrix and store it in a target matrix
  4247. * Example Playground - https://playground.babylonjs.com/#AV9X17#112
  4248. * @param matrix defines the matrix to transpose
  4249. * @param result defines the target matrix
  4250. * @returns result input
  4251. */
  4252. static TransposeToRef<T extends Matrix>(matrix: DeepImmutable<Matrix>, result: T): T;
  4253. /**
  4254. * Computes a reflection matrix from a plane
  4255. * Example Playground - https://playground.babylonjs.com/#AV9X17#87
  4256. * @param plane defines the reflection plane
  4257. * @returns a new matrix
  4258. */
  4259. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4260. /**
  4261. * Computes a reflection matrix from a plane
  4262. * Example Playground - https://playground.babylonjs.com/#AV9X17#88
  4263. * @param plane defines the reflection plane
  4264. * @param result defines the target matrix
  4265. * @returns result input
  4266. */
  4267. static ReflectionToRef<T extends Matrix>(plane: DeepImmutable<IPlaneLike>, result: T): T;
  4268. /**
  4269. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4270. * @param xaxis defines the value of the 1st axis
  4271. * @param yaxis defines the value of the 2nd axis
  4272. * @param zaxis defines the value of the 3rd axis
  4273. * @param result defines the target matrix
  4274. * @returns result input
  4275. */
  4276. static FromXYZAxesToRef<T extends Matrix>(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: T): T;
  4277. /**
  4278. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4279. * @param quat defines the quaternion to use
  4280. * @param result defines the target matrix
  4281. * @returns result input
  4282. */
  4283. static FromQuaternionToRef<T extends Matrix>(quat: DeepImmutable<Quaternion>, result: T): T;
  4284. }
  4285. /**
  4286. * @internal
  4287. */
  4288. export declare class TmpVectors {
  4289. /** 3 temp Vector2 at once should be enough */
  4290. static Vector2: [Vector2, Vector2, Vector2];
  4291. /** 13 temp Vector3 at once should be enough */
  4292. static Vector3: [Vector3, Vector3, Vector3, Vector3, Vector3, Vector3, Vector3, Vector3, Vector3, Vector3, Vector3, Vector3, Vector3];
  4293. /** 3 temp Vector4 at once should be enough */
  4294. static Vector4: [Vector4, Vector4, Vector4];
  4295. /** 2 temp Quaternion at once should be enough */
  4296. static Quaternion: [Quaternion, Quaternion];
  4297. /** 8 temp Matrices at once should be enough */
  4298. static Matrix: [Matrix, Matrix, Matrix, Matrix, Matrix, Matrix, Matrix, Matrix];
  4299. }