mesh.vertexData.d.ts 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. import type { Nullable, FloatArray, IndicesArray } from "../types";
  2. import type { Matrix, Vector2 } from "../Maths/math.vector";
  3. import { Vector3, Vector4 } from "../Maths/math.vector";
  4. import type { Color3 } from "../Maths/math.color";
  5. import { Color4 } from "../Maths/math.color";
  6. import type { Coroutine } from "../Misc/coroutine";
  7. import type { ICreateCapsuleOptions } from "./Builders/capsuleBuilder";
  8. import type { Geometry } from "../Meshes/geometry";
  9. import type { Mesh } from "../Meshes/mesh";
  10. /**
  11. * Define an interface for all classes that will get and set the data on vertices
  12. */
  13. export interface IGetSetVerticesData {
  14. /**
  15. * Gets a boolean indicating if specific vertex data is present
  16. * @param kind defines the vertex data kind to use
  17. * @returns true is data kind is present
  18. */
  19. isVerticesDataPresent(kind: string): boolean;
  20. /**
  21. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22. * @param kind defines the data kind (Position, normal, etc...)
  23. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  24. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25. * @returns a float array containing vertex data
  26. */
  27. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28. /**
  29. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  30. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  31. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32. * @returns the indices array or an empty array if the mesh has no geometry
  33. */
  34. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  35. /**
  36. * Set specific vertex data
  37. * @param kind defines the data kind (Position, normal, etc...)
  38. * @param data defines the vertex data to use
  39. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  40. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  41. */
  42. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  43. /**
  44. * Update a specific associated vertex buffer
  45. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  46. * - VertexBuffer.PositionKind
  47. * - VertexBuffer.UVKind
  48. * - VertexBuffer.UV2Kind
  49. * - VertexBuffer.UV3Kind
  50. * - VertexBuffer.UV4Kind
  51. * - VertexBuffer.UV5Kind
  52. * - VertexBuffer.UV6Kind
  53. * - VertexBuffer.ColorKind
  54. * - VertexBuffer.MatricesIndicesKind
  55. * - VertexBuffer.MatricesIndicesExtraKind
  56. * - VertexBuffer.MatricesWeightsKind
  57. * - VertexBuffer.MatricesWeightsExtraKind
  58. * @param data defines the data source
  59. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  60. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  61. */
  62. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  63. /**
  64. * Creates a new index buffer
  65. * @param indices defines the indices to store in the index buffer
  66. * @param totalVertices defines the total number of vertices (could be null)
  67. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  68. */
  69. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  70. }
  71. /** Class used to attach material info to sub section of a vertex data class */
  72. export declare class VertexDataMaterialInfo {
  73. /** Defines the material index to use */
  74. materialIndex: number;
  75. /** Defines vertex index start*/
  76. verticesStart: number;
  77. /** Defines vertices count */
  78. verticesCount: number;
  79. /** Defines index start */
  80. indexStart: number;
  81. /** Defines indices count */
  82. indexCount: number;
  83. }
  84. /**
  85. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  86. */
  87. export declare class VertexData {
  88. /**
  89. * Mesh side orientation : usually the external or front surface
  90. */
  91. static readonly FRONTSIDE = 0;
  92. /**
  93. * Mesh side orientation : usually the internal or back surface
  94. */
  95. static readonly BACKSIDE = 1;
  96. /**
  97. * Mesh side orientation : both internal and external or front and back surfaces
  98. */
  99. static readonly DOUBLESIDE = 2;
  100. /**
  101. * Mesh side orientation : by default, `FRONTSIDE`
  102. */
  103. static readonly DEFAULTSIDE = 0;
  104. private static _UniqueIDGenerator;
  105. /**
  106. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  107. */
  108. positions: Nullable<FloatArray>;
  109. /**
  110. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  111. */
  112. normals: Nullable<FloatArray>;
  113. /**
  114. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  115. */
  116. tangents: Nullable<FloatArray>;
  117. /**
  118. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  119. */
  120. uvs: Nullable<FloatArray>;
  121. /**
  122. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  123. */
  124. uvs2: Nullable<FloatArray>;
  125. /**
  126. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  127. */
  128. uvs3: Nullable<FloatArray>;
  129. /**
  130. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  131. */
  132. uvs4: Nullable<FloatArray>;
  133. /**
  134. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  135. */
  136. uvs5: Nullable<FloatArray>;
  137. /**
  138. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  139. */
  140. uvs6: Nullable<FloatArray>;
  141. /**
  142. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  143. */
  144. colors: Nullable<FloatArray>;
  145. /**
  146. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  147. */
  148. matricesIndices: Nullable<FloatArray>;
  149. /**
  150. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  151. */
  152. matricesWeights: Nullable<FloatArray>;
  153. /**
  154. * An array extending the number of possible indices
  155. */
  156. matricesIndicesExtra: Nullable<FloatArray>;
  157. /**
  158. * An array extending the number of possible weights when the number of indices is extended
  159. */
  160. matricesWeightsExtra: Nullable<FloatArray>;
  161. /**
  162. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  163. */
  164. indices: Nullable<IndicesArray>;
  165. /**
  166. * An array defining material association for sub sections of the vertex data
  167. */
  168. materialInfos: Nullable<Array<VertexDataMaterialInfo>>;
  169. /**
  170. * Gets the unique ID of this vertex Data
  171. */
  172. uniqueId: number;
  173. /**
  174. * Metadata used to store contextual values
  175. */
  176. metadata: any;
  177. /**
  178. * Gets or sets a value indicating that the mesh must be flagged with hasVertexAlpha = true
  179. */
  180. hasVertexAlpha: boolean;
  181. /**
  182. * Creates a new VertexData
  183. */
  184. constructor();
  185. /**
  186. * Uses the passed data array to set the set the values for the specified kind of data
  187. * @param data a linear array of floating numbers
  188. * @param kind the type of data that is being set, eg positions, colors etc
  189. */
  190. set(data: FloatArray, kind: string): void;
  191. /**
  192. * Associates the vertexData to the passed Mesh.
  193. * Sets it as updatable or not (default `false`)
  194. * @param mesh the mesh the vertexData is applied to
  195. * @param updatable when used and having the value true allows new data to update the vertexData
  196. * @returns the VertexData
  197. */
  198. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  199. /**
  200. * Associates the vertexData to the passed Geometry.
  201. * Sets it as updatable or not (default `false`)
  202. * @param geometry the geometry the vertexData is applied to
  203. * @param updatable when used and having the value true allows new data to update the vertexData
  204. * @returns VertexData
  205. */
  206. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  207. /**
  208. * Updates the associated mesh
  209. * @param mesh the mesh to be updated
  210. * @returns VertexData
  211. */
  212. updateMesh(mesh: Mesh): VertexData;
  213. /**
  214. * Updates the associated geometry
  215. * @param geometry the geometry to be updated
  216. * @returns VertexData.
  217. */
  218. updateGeometry(geometry: Geometry): VertexData;
  219. private readonly _applyTo;
  220. /**
  221. * @internal
  222. */
  223. _applyToCoroutine(meshOrGeometry: IGetSetVerticesData, updatable: boolean | undefined, isAsync: boolean): Coroutine<VertexData>;
  224. private _update;
  225. private static _TransformVector3Coordinates;
  226. private static _TransformVector3Normals;
  227. private static _TransformVector4Normals;
  228. private static _FlipFaces;
  229. /**
  230. * Transforms each position and each normal of the vertexData according to the passed Matrix
  231. * @param matrix the transforming matrix
  232. * @returns the VertexData
  233. */
  234. transform(matrix: Matrix): VertexData;
  235. /**
  236. * Generates an array of vertex data where each vertex data only has one material info
  237. * @returns An array of VertexData
  238. */
  239. splitBasedOnMaterialID(): VertexData[];
  240. /**
  241. * Merges the passed VertexData into the current one
  242. * @param others the VertexData to be merged into the current one
  243. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  244. * @param forceCloneIndices defines a boolean indicating if indices are forced to be cloned
  245. * @param mergeMaterialIds defines a boolean indicating if we need to merge the material infos
  246. * @param enableCompletion defines a boolean indicating if the vertex data should be completed to be compatible
  247. * @returns the modified VertexData
  248. */
  249. merge(others: VertexData | VertexData[], use32BitsIndices?: boolean, forceCloneIndices?: boolean, mergeMaterialIds?: boolean, enableCompletion?: boolean): VertexData;
  250. /**
  251. * @internal
  252. */
  253. _mergeCoroutine(transform: Matrix | undefined, vertexDatas: {
  254. vertexData: VertexData;
  255. transform?: Matrix;
  256. }[], use32BitsIndices: boolean | undefined, isAsync: boolean, forceCloneIndices: boolean, mergeMaterialIds?: boolean, enableCompletion?: boolean): Coroutine<VertexData>;
  257. private static _MergeElement;
  258. private _validate;
  259. /**
  260. * Clone the current vertex data
  261. * @returns a copy of the current data
  262. */
  263. clone(): VertexData;
  264. /**
  265. * Serializes the VertexData
  266. * @returns a serialized object
  267. */
  268. serialize(): any;
  269. /**
  270. * Extracts the vertexData from a mesh
  271. * @param mesh the mesh from which to extract the VertexData
  272. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  273. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  274. * @returns the object VertexData associated to the passed mesh
  275. */
  276. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  277. /**
  278. * Extracts the vertexData from the geometry
  279. * @param geometry the geometry from which to extract the VertexData
  280. * @param copyWhenShared defines if the VertexData must be cloned when the geometry is shared between multiple meshes, optional, default false
  281. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  282. * @returns the object VertexData associated to the passed mesh
  283. */
  284. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  285. private static _ExtractFrom;
  286. /**
  287. * Creates the VertexData for a Ribbon
  288. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  289. * * pathArray array of paths, each of which an array of successive Vector3
  290. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  291. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  292. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  293. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  294. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  295. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  296. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  297. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  298. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  299. * @returns the VertexData of the ribbon
  300. * @deprecated use CreateRibbonVertexData instead
  301. */
  302. static CreateRibbon(options: {
  303. pathArray: Vector3[][];
  304. closeArray?: boolean;
  305. closePath?: boolean;
  306. offset?: number;
  307. sideOrientation?: number;
  308. frontUVs?: Vector4;
  309. backUVs?: Vector4;
  310. invertUV?: boolean;
  311. uvs?: Vector2[];
  312. colors?: Color4[];
  313. }): VertexData;
  314. /**
  315. * Creates the VertexData for a box
  316. * @param options an object used to set the following optional parameters for the box, required but can be empty
  317. * * size sets the width, height and depth of the box to the value of size, optional default 1
  318. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  319. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  320. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  321. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  322. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  323. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  324. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  325. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  326. * @returns the VertexData of the box
  327. * @deprecated Please use CreateBoxVertexData from the BoxBuilder file instead
  328. */
  329. static CreateBox(options: {
  330. size?: number;
  331. width?: number;
  332. height?: number;
  333. depth?: number;
  334. faceUV?: Vector4[];
  335. faceColors?: Color4[];
  336. sideOrientation?: number;
  337. frontUVs?: Vector4;
  338. backUVs?: Vector4;
  339. }): VertexData;
  340. /**
  341. * Creates the VertexData for a tiled box
  342. * @param options an object used to set the following optional parameters for the box, required but can be empty
  343. * * faceTiles sets the pattern, tile size and number of tiles for a face
  344. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  345. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  346. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  347. * @param options.pattern
  348. * @param options.width
  349. * @param options.height
  350. * @param options.depth
  351. * @param options.tileSize
  352. * @param options.tileWidth
  353. * @param options.tileHeight
  354. * @param options.alignHorizontal
  355. * @param options.alignVertical
  356. * @param options.faceUV
  357. * @param options.faceColors
  358. * @param options.sideOrientation
  359. * @returns the VertexData of the box
  360. * @deprecated Please use CreateTiledBoxVertexData instead
  361. */
  362. static CreateTiledBox(options: {
  363. pattern?: number;
  364. width?: number;
  365. height?: number;
  366. depth?: number;
  367. tileSize?: number;
  368. tileWidth?: number;
  369. tileHeight?: number;
  370. alignHorizontal?: number;
  371. alignVertical?: number;
  372. faceUV?: Vector4[];
  373. faceColors?: Color4[];
  374. sideOrientation?: number;
  375. }): VertexData;
  376. /**
  377. * Creates the VertexData for a tiled plane
  378. * @param options an object used to set the following optional parameters for the box, required but can be empty
  379. * * pattern a limited pattern arrangement depending on the number
  380. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  381. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  382. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  383. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  384. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  385. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  386. * @returns the VertexData of the tiled plane
  387. * @deprecated use CreateTiledPlaneVertexData instead
  388. */
  389. static CreateTiledPlane(options: {
  390. pattern?: number;
  391. tileSize?: number;
  392. tileWidth?: number;
  393. tileHeight?: number;
  394. size?: number;
  395. width?: number;
  396. height?: number;
  397. alignHorizontal?: number;
  398. alignVertical?: number;
  399. sideOrientation?: number;
  400. frontUVs?: Vector4;
  401. backUVs?: Vector4;
  402. }): VertexData;
  403. /**
  404. * Creates the VertexData for an ellipsoid, defaults to a sphere
  405. * @param options an object used to set the following optional parameters for the box, required but can be empty
  406. * * segments sets the number of horizontal strips optional, default 32
  407. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  408. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  409. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  410. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  411. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  412. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  413. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  414. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  415. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  416. * @returns the VertexData of the ellipsoid
  417. * @deprecated use CreateSphereVertexData instead
  418. */
  419. static CreateSphere(options: {
  420. segments?: number;
  421. diameter?: number;
  422. diameterX?: number;
  423. diameterY?: number;
  424. diameterZ?: number;
  425. arc?: number;
  426. slice?: number;
  427. sideOrientation?: number;
  428. frontUVs?: Vector4;
  429. backUVs?: Vector4;
  430. }): VertexData;
  431. /**
  432. * Creates the VertexData for a cylinder, cone or prism
  433. * @param options an object used to set the following optional parameters for the box, required but can be empty
  434. * * height sets the height (y direction) of the cylinder, optional, default 2
  435. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  436. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  437. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  438. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  439. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  440. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  441. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  442. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  443. * * hasRings when true makes each subdivision independently treated as a face for faceUV and faceColors, optional, default false
  444. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  445. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  446. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  447. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  448. * @returns the VertexData of the cylinder, cone or prism
  449. * @deprecated please use CreateCylinderVertexData instead
  450. */
  451. static CreateCylinder(options: {
  452. height?: number;
  453. diameterTop?: number;
  454. diameterBottom?: number;
  455. diameter?: number;
  456. tessellation?: number;
  457. subdivisions?: number;
  458. arc?: number;
  459. faceColors?: Color4[];
  460. faceUV?: Vector4[];
  461. hasRings?: boolean;
  462. enclose?: boolean;
  463. sideOrientation?: number;
  464. frontUVs?: Vector4;
  465. backUVs?: Vector4;
  466. }): VertexData;
  467. /**
  468. * Creates the VertexData for a torus
  469. * @param options an object used to set the following optional parameters for the box, required but can be empty
  470. * * diameter the diameter of the torus, optional default 1
  471. * * thickness the diameter of the tube forming the torus, optional default 0.5
  472. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  473. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  474. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  475. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  476. * @returns the VertexData of the torus
  477. * @deprecated use CreateTorusVertexData instead
  478. */
  479. static CreateTorus(options: {
  480. diameter?: number;
  481. thickness?: number;
  482. tessellation?: number;
  483. sideOrientation?: number;
  484. frontUVs?: Vector4;
  485. backUVs?: Vector4;
  486. }): VertexData;
  487. /**
  488. * Creates the VertexData of the LineSystem
  489. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  490. * - lines an array of lines, each line being an array of successive Vector3
  491. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  492. * @returns the VertexData of the LineSystem
  493. * @deprecated use CreateLineSystemVertexData instead
  494. */
  495. static CreateLineSystem(options: {
  496. lines: Vector3[][];
  497. colors?: Nullable<Color4[][]>;
  498. }): VertexData;
  499. /**
  500. * Create the VertexData for a DashedLines
  501. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  502. * - points an array successive Vector3
  503. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  504. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  505. * - dashNb the intended total number of dashes, optional, default 200
  506. * @returns the VertexData for the DashedLines
  507. * @deprecated use CreateDashedLinesVertexData instead
  508. */
  509. static CreateDashedLines(options: {
  510. points: Vector3[];
  511. dashSize?: number;
  512. gapSize?: number;
  513. dashNb?: number;
  514. }): VertexData;
  515. /**
  516. * Creates the VertexData for a Ground
  517. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  518. * - width the width (x direction) of the ground, optional, default 1
  519. * - height the height (z direction) of the ground, optional, default 1
  520. * - subdivisions the number of subdivisions per side, optional, default 1
  521. * @returns the VertexData of the Ground
  522. * @deprecated Please use CreateGroundVertexData instead
  523. */
  524. static CreateGround(options: {
  525. width?: number;
  526. height?: number;
  527. subdivisions?: number;
  528. subdivisionsX?: number;
  529. subdivisionsY?: number;
  530. }): VertexData;
  531. /**
  532. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  533. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  534. * * xmin the ground minimum X coordinate, optional, default -1
  535. * * zmin the ground minimum Z coordinate, optional, default -1
  536. * * xmax the ground maximum X coordinate, optional, default 1
  537. * * zmax the ground maximum Z coordinate, optional, default 1
  538. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  539. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  540. * @returns the VertexData of the TiledGround
  541. * @deprecated use CreateTiledGroundVertexData instead
  542. */
  543. static CreateTiledGround(options: {
  544. xmin: number;
  545. zmin: number;
  546. xmax: number;
  547. zmax: number;
  548. subdivisions?: {
  549. w: number;
  550. h: number;
  551. };
  552. precision?: {
  553. w: number;
  554. h: number;
  555. };
  556. }): VertexData;
  557. /**
  558. * Creates the VertexData of the Ground designed from a heightmap
  559. * @param options an object used to set the following parameters for the Ground, required and provided by CreateGroundFromHeightMap
  560. * * width the width (x direction) of the ground
  561. * * height the height (z direction) of the ground
  562. * * subdivisions the number of subdivisions per side
  563. * * minHeight the minimum altitude on the ground, optional, default 0
  564. * * maxHeight the maximum altitude on the ground, optional default 1
  565. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  566. * * buffer the array holding the image color data
  567. * * bufferWidth the width of image
  568. * * bufferHeight the height of image
  569. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  570. * @returns the VertexData of the Ground designed from a heightmap
  571. * @deprecated use CreateGroundFromHeightMapVertexData instead
  572. */
  573. static CreateGroundFromHeightMap(options: {
  574. width: number;
  575. height: number;
  576. subdivisions: number;
  577. minHeight: number;
  578. maxHeight: number;
  579. colorFilter: Color3;
  580. buffer: Uint8Array;
  581. bufferWidth: number;
  582. bufferHeight: number;
  583. alphaFilter: number;
  584. }): VertexData;
  585. /**
  586. * Creates the VertexData for a Plane
  587. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  588. * * size sets the width and height of the plane to the value of size, optional default 1
  589. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  590. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  591. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  592. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  593. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  594. * @returns the VertexData of the box
  595. * @deprecated use CreatePlaneVertexData instead
  596. */
  597. static CreatePlane(options: {
  598. size?: number;
  599. width?: number;
  600. height?: number;
  601. sideOrientation?: number;
  602. frontUVs?: Vector4;
  603. backUVs?: Vector4;
  604. }): VertexData;
  605. /**
  606. * Creates the VertexData of the Disc or regular Polygon
  607. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  608. * * radius the radius of the disc, optional default 0.5
  609. * * tessellation the number of polygon sides, optional, default 64
  610. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  611. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  612. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  613. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  614. * @returns the VertexData of the box
  615. * @deprecated use CreateDiscVertexData instead
  616. */
  617. static CreateDisc(options: {
  618. radius?: number;
  619. tessellation?: number;
  620. arc?: number;
  621. sideOrientation?: number;
  622. frontUVs?: Vector4;
  623. backUVs?: Vector4;
  624. }): VertexData;
  625. /**
  626. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  627. * All parameters are provided by CreatePolygon as needed
  628. * @param polygon a mesh built from polygonTriangulation.build()
  629. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  630. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  631. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  632. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  633. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  634. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  635. * @returns the VertexData of the Polygon
  636. * @deprecated use CreatePolygonVertexData instead
  637. */
  638. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  639. /**
  640. * Creates the VertexData of the IcoSphere
  641. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  642. * * radius the radius of the IcoSphere, optional default 1
  643. * * radiusX allows stretching in the x direction, optional, default radius
  644. * * radiusY allows stretching in the y direction, optional, default radius
  645. * * radiusZ allows stretching in the z direction, optional, default radius
  646. * * flat when true creates a flat shaded mesh, optional, default true
  647. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  648. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  649. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  650. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  651. * @returns the VertexData of the IcoSphere
  652. * @deprecated use CreateIcoSphereVertexData instead
  653. */
  654. static CreateIcoSphere(options: {
  655. radius?: number;
  656. radiusX?: number;
  657. radiusY?: number;
  658. radiusZ?: number;
  659. flat?: boolean;
  660. subdivisions?: number;
  661. sideOrientation?: number;
  662. frontUVs?: Vector4;
  663. backUVs?: Vector4;
  664. }): VertexData;
  665. /**
  666. * Creates the VertexData for a Polyhedron
  667. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  668. * * type provided types are:
  669. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  670. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  671. * * size the size of the IcoSphere, optional default 1
  672. * * sizeX allows stretching in the x direction, optional, default size
  673. * * sizeY allows stretching in the y direction, optional, default size
  674. * * sizeZ allows stretching in the z direction, optional, default size
  675. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  676. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  677. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  678. * * flat when true creates a flat shaded mesh, optional, default true
  679. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  680. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  681. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  682. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  683. * @returns the VertexData of the Polyhedron
  684. * @deprecated use CreatePolyhedronVertexData instead
  685. */
  686. static CreatePolyhedron(options: {
  687. type?: number;
  688. size?: number;
  689. sizeX?: number;
  690. sizeY?: number;
  691. sizeZ?: number;
  692. custom?: any;
  693. faceUV?: Vector4[];
  694. faceColors?: Color4[];
  695. flat?: boolean;
  696. sideOrientation?: number;
  697. frontUVs?: Vector4;
  698. backUVs?: Vector4;
  699. }): VertexData;
  700. /**
  701. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  702. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  703. * @returns the VertexData of the Capsule
  704. * @deprecated Please use CreateCapsuleVertexData from the capsuleBuilder file instead
  705. */
  706. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  707. /**
  708. * Creates the VertexData for a TorusKnot
  709. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  710. * * radius the radius of the torus knot, optional, default 2
  711. * * tube the thickness of the tube, optional, default 0.5
  712. * * radialSegments the number of sides on each tube segments, optional, default 32
  713. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  714. * * p the number of windings around the z axis, optional, default 2
  715. * * q the number of windings around the x axis, optional, default 3
  716. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  717. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  718. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  719. * @returns the VertexData of the Torus Knot
  720. * @deprecated use CreateTorusKnotVertexData instead
  721. */
  722. static CreateTorusKnot(options: {
  723. radius?: number;
  724. tube?: number;
  725. radialSegments?: number;
  726. tubularSegments?: number;
  727. p?: number;
  728. q?: number;
  729. sideOrientation?: number;
  730. frontUVs?: Vector4;
  731. backUVs?: Vector4;
  732. }): VertexData;
  733. /**
  734. * Compute normals for given positions and indices
  735. * @param positions an array of vertex positions, [...., x, y, z, ......]
  736. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  737. * @param normals an array of vertex normals, [...., x, y, z, ......]
  738. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  739. * * facetNormals : optional array of facet normals (vector3)
  740. * * facetPositions : optional array of facet positions (vector3)
  741. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  742. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  743. * * bInfo : optional bounding info, required for facetPartitioning computation
  744. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  745. * * subDiv : optional partitioning data about subdivisions on each axis (int), required for facetPartitioning computation
  746. * * useRightHandedSystem: optional boolean to for right handed system computation
  747. * * depthSort : optional boolean to enable the facet depth sort computation
  748. * * distanceTo : optional Vector3 to compute the facet depth from this location
  749. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  750. */
  751. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  752. facetNormals?: any;
  753. facetPositions?: any;
  754. facetPartitioning?: any;
  755. ratio?: number;
  756. bInfo?: any;
  757. bbSize?: Vector3;
  758. subDiv?: any;
  759. useRightHandedSystem?: boolean;
  760. depthSort?: boolean;
  761. distanceTo?: Vector3;
  762. depthSortedFacets?: any;
  763. }): void;
  764. /**
  765. * @internal
  766. */
  767. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray | IndicesArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  768. /**
  769. * Creates a VertexData from serialized data
  770. * @param parsedVertexData the parsed data from an imported file
  771. * @returns a VertexData
  772. */
  773. static Parse(parsedVertexData: any): VertexData;
  774. /**
  775. * Applies VertexData created from the imported parameters to the geometry
  776. * @param parsedVertexData the parsed data from an imported file
  777. * @param geometry the geometry to apply the VertexData to
  778. */
  779. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  780. }