scene.d.ts 99 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347
  1. import type { Nullable } from "./types";
  2. import type { IAnimatable } from "./Animations/animatable.interface";
  3. import { Observable } from "./Misc/observable";
  4. import type { ISmartArrayLike } from "./Misc/smartArray";
  5. import { SmartArrayNoDuplicate, SmartArray } from "./Misc/smartArray";
  6. import type { Vector2, Vector4 } from "./Maths/math.vector";
  7. import { Vector3, Matrix } from "./Maths/math.vector";
  8. import type { IParticleSystem } from "./Particles/IParticleSystem";
  9. import { AbstractScene } from "./abstractScene";
  10. import { ImageProcessingConfiguration } from "./Materials/imageProcessingConfiguration";
  11. import { UniformBuffer } from "./Materials/uniformBuffer";
  12. import { PickingInfo } from "./Collisions/pickingInfo";
  13. import type { ICollisionCoordinator } from "./Collisions/collisionCoordinator";
  14. import type { PointerEventTypes, PointerInfoPre, PointerInfo } from "./Events/pointerEvents";
  15. import type { KeyboardInfoPre, KeyboardInfo } from "./Events/keyboardEvents";
  16. import { PostProcessManager } from "./PostProcesses/postProcessManager";
  17. import type { IOfflineProvider } from "./Offline/IOfflineProvider";
  18. import type { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "./Rendering/renderingManager";
  19. import { RenderingManager } from "./Rendering/renderingManager";
  20. import type { ISceneComponent, ISceneSerializableComponent, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, PreActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "./sceneComponent";
  21. import { Stage } from "./sceneComponent";
  22. import type { AbstractActionManager } from "./Actions/abstractActionManager";
  23. import type { WebRequest } from "./Misc/webRequest";
  24. import { InputManager } from "./Inputs/scene.inputManager";
  25. import { PerfCounter } from "./Misc/perfCounter";
  26. import type { IFileRequest } from "./Misc/fileRequest";
  27. import { Color4, Color3 } from "./Maths/math.color";
  28. import type { Plane } from "./Maths/math.plane";
  29. import type { LoadFileError, RequestFileError, ReadFileError } from "./Misc/fileTools";
  30. import type { IClipPlanesHolder } from "./Misc/interfaces/iClipPlanesHolder";
  31. import type { IPointerEvent } from "./Events/deviceInputEvents";
  32. import type { AnimationPropertiesOverride } from "./Animations/animationPropertiesOverride";
  33. import type { AnimationGroup } from "./Animations/animationGroup";
  34. import type { Skeleton } from "./Bones/skeleton";
  35. import type { Bone } from "./Bones/bone";
  36. import type { Camera } from "./Cameras/camera";
  37. import type { Collider } from "./Collisions/collider";
  38. import type { Ray, TrianglePickingPredicate } from "./Culling/ray";
  39. import type { Light } from "./Lights/light";
  40. import type { PerformanceViewerCollector } from "./Misc/PerformanceViewer/performanceViewerCollector";
  41. import type { MorphTarget } from "./Morph/morphTarget";
  42. import type { MorphTargetManager } from "./Morph/morphTargetManager";
  43. import type { PostProcess } from "./PostProcesses/postProcess";
  44. import type { Material } from "./Materials/material";
  45. import type { BaseTexture } from "./Materials/Textures/baseTexture";
  46. import type { Geometry } from "./Meshes/geometry";
  47. import type { TransformNode } from "./Meshes/transformNode";
  48. import type { AbstractMesh } from "./Meshes/abstractMesh";
  49. import type { MultiMaterial } from "./Materials/multiMaterial";
  50. import type { Effect } from "./Materials/effect";
  51. import type { RenderTargetTexture } from "./Materials/Textures/renderTargetTexture";
  52. import type { SubMesh } from "./Meshes/subMesh";
  53. import type { Node } from "./node";
  54. import type { Animation } from "./Animations/animation";
  55. import type { Animatable } from "./Animations/animatable";
  56. import type { AbstractEngine } from "./Engines/abstractEngine";
  57. /**
  58. * Define an interface for all classes that will hold resources
  59. */
  60. export interface IDisposable {
  61. /**
  62. * Releases all held resources
  63. */
  64. dispose(): void;
  65. }
  66. /** Interface defining initialization parameters for Scene class */
  67. export interface SceneOptions {
  68. /**
  69. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  70. * It will improve performance when the number of geometries becomes important.
  71. */
  72. useGeometryUniqueIdsMap?: boolean;
  73. /**
  74. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast disposing
  75. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  76. */
  77. useMaterialMeshMap?: boolean;
  78. /**
  79. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast disposing
  80. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  81. */
  82. useClonedMeshMap?: boolean;
  83. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  84. virtual?: boolean;
  85. }
  86. /**
  87. * Define how the scene should favor performance over ease of use
  88. */
  89. export declare enum ScenePerformancePriority {
  90. /** Default mode. No change. Performance will be treated as less important than backward compatibility */
  91. BackwardCompatible = 0,
  92. /** Some performance options will be turned on trying to strike a balance between perf and ease of use */
  93. Intermediate = 1,
  94. /** Performance will be top priority */
  95. Aggressive = 2
  96. }
  97. /**
  98. * Represents a scene to be rendered by the engine.
  99. * @see https://doc.babylonjs.com/features/featuresDeepDive/scene
  100. */
  101. export declare class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  102. /** The fog is deactivated */
  103. static readonly FOGMODE_NONE: number;
  104. /** The fog density is following an exponential function */
  105. static readonly FOGMODE_EXP: number;
  106. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  107. static readonly FOGMODE_EXP2: number;
  108. /** The fog density is following a linear function. */
  109. static readonly FOGMODE_LINEAR: number;
  110. /**
  111. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  112. * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#deterministic-lockstep
  113. */
  114. static MinDeltaTime: number;
  115. /**
  116. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  117. * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#deterministic-lockstep
  118. */
  119. static MaxDeltaTime: number;
  120. /**
  121. * Factory used to create the default material.
  122. * @param scene The scene to create the material for
  123. * @returns The default material
  124. */
  125. static DefaultMaterialFactory(scene: Scene): Material;
  126. /**
  127. * Factory used to create the a collision coordinator.
  128. * @returns The collision coordinator
  129. */
  130. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  131. /** @internal */
  132. _inputManager: InputManager;
  133. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  134. cameraToUseForPointers: Nullable<Camera>;
  135. /** @internal */
  136. readonly _isScene = true;
  137. /** @internal */
  138. _blockEntityCollection: boolean;
  139. /**
  140. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  141. */
  142. autoClear: boolean;
  143. /**
  144. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  145. */
  146. autoClearDepthAndStencil: boolean;
  147. /**
  148. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  149. */
  150. clearColor: Color4;
  151. /**
  152. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  153. */
  154. ambientColor: Color3;
  155. /**
  156. * This is use to store the default BRDF lookup for PBR materials in your scene.
  157. * It should only be one of the following (if not the default embedded one):
  158. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  159. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  160. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  161. * The material properties need to be setup according to the type of texture in use.
  162. */
  163. environmentBRDFTexture: BaseTexture;
  164. /**
  165. * Texture used in all pbr material as the reflection texture.
  166. * As in the majority of the scene they are the same (exception for multi room and so on),
  167. * this is easier to reference from here than from all the materials.
  168. */
  169. get environmentTexture(): Nullable<BaseTexture>;
  170. /**
  171. * Texture used in all pbr material as the reflection texture.
  172. * As in the majority of the scene they are the same (exception for multi room and so on),
  173. * this is easier to set here than in all the materials.
  174. */
  175. set environmentTexture(value: Nullable<BaseTexture>);
  176. /**
  177. * Intensity of the environment in all pbr material.
  178. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  179. * As in the majority of the scene they are the same (exception for multi room and so on),
  180. * this is easier to reference from here than from all the materials.
  181. */
  182. environmentIntensity: number;
  183. /** @internal */
  184. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  185. /**
  186. * Default image processing configuration used either in the rendering
  187. * Forward main pass or through the imageProcessingPostProcess if present.
  188. * As in the majority of the scene they are the same (exception for multi camera),
  189. * this is easier to reference from here than from all the materials and post process.
  190. *
  191. * No setter as we it is a shared configuration, you can set the values instead.
  192. */
  193. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  194. private _performancePriority;
  195. /**
  196. * Observable triggered when the performance priority is changed
  197. */
  198. onScenePerformancePriorityChangedObservable: Observable<ScenePerformancePriority>;
  199. /**
  200. * Gets or sets a value indicating how to treat performance relatively to ease of use and backward compatibility
  201. */
  202. get performancePriority(): ScenePerformancePriority;
  203. set performancePriority(value: ScenePerformancePriority);
  204. private _forceWireframe;
  205. /**
  206. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  207. */
  208. set forceWireframe(value: boolean);
  209. get forceWireframe(): boolean;
  210. private _skipFrustumClipping;
  211. /**
  212. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  213. */
  214. set skipFrustumClipping(value: boolean);
  215. get skipFrustumClipping(): boolean;
  216. private _forcePointsCloud;
  217. /**
  218. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  219. */
  220. set forcePointsCloud(value: boolean);
  221. get forcePointsCloud(): boolean;
  222. /**
  223. * Gets or sets the active clipplane 1
  224. */
  225. clipPlane: Nullable<Plane>;
  226. /**
  227. * Gets or sets the active clipplane 2
  228. */
  229. clipPlane2: Nullable<Plane>;
  230. /**
  231. * Gets or sets the active clipplane 3
  232. */
  233. clipPlane3: Nullable<Plane>;
  234. /**
  235. * Gets or sets the active clipplane 4
  236. */
  237. clipPlane4: Nullable<Plane>;
  238. /**
  239. * Gets or sets the active clipplane 5
  240. */
  241. clipPlane5: Nullable<Plane>;
  242. /**
  243. * Gets or sets the active clipplane 6
  244. */
  245. clipPlane6: Nullable<Plane>;
  246. /**
  247. * Gets or sets a boolean indicating if animations are enabled
  248. */
  249. animationsEnabled: boolean;
  250. private _animationPropertiesOverride;
  251. /**
  252. * Gets or sets the animation properties override
  253. */
  254. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  255. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  256. /**
  257. * Gets or sets a boolean indicating if a constant deltatime has to be used
  258. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  259. */
  260. useConstantAnimationDeltaTime: boolean;
  261. /**
  262. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  263. * Please note that it requires to run a ray cast through the scene on every frame
  264. */
  265. constantlyUpdateMeshUnderPointer: boolean;
  266. /**
  267. * Defines the HTML cursor to use when hovering over interactive elements
  268. */
  269. hoverCursor: string;
  270. /**
  271. * Defines the HTML default cursor to use (empty by default)
  272. */
  273. defaultCursor: string;
  274. /**
  275. * Defines whether cursors are handled by the scene.
  276. */
  277. doNotHandleCursors: boolean;
  278. /**
  279. * This is used to call preventDefault() on pointer down
  280. * in order to block unwanted artifacts like system double clicks
  281. */
  282. preventDefaultOnPointerDown: boolean;
  283. /**
  284. * This is used to call preventDefault() on pointer up
  285. * in order to block unwanted artifacts like system double clicks
  286. */
  287. preventDefaultOnPointerUp: boolean;
  288. /**
  289. * Gets or sets user defined metadata
  290. */
  291. metadata: any;
  292. /**
  293. * For internal use only. Please do not use.
  294. */
  295. reservedDataStore: any;
  296. /**
  297. * Gets the name of the plugin used to load this scene (null by default)
  298. */
  299. loadingPluginName: string;
  300. /**
  301. * Use this array to add regular expressions used to disable offline support for specific urls
  302. */
  303. disableOfflineSupportExceptionRules: RegExp[];
  304. /**
  305. * An event triggered when the scene is disposed.
  306. */
  307. onDisposeObservable: Observable<Scene>;
  308. private _onDisposeObserver;
  309. /** Sets a function to be executed when this scene is disposed. */
  310. set onDispose(callback: () => void);
  311. /**
  312. * An event triggered before rendering the scene (right after animations and physics)
  313. */
  314. onBeforeRenderObservable: Observable<Scene>;
  315. private _onBeforeRenderObserver;
  316. /** Sets a function to be executed before rendering this scene */
  317. set beforeRender(callback: Nullable<() => void>);
  318. /**
  319. * An event triggered after rendering the scene
  320. */
  321. onAfterRenderObservable: Observable<Scene>;
  322. /**
  323. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  324. * This is triggered for each "sub" camera in a Camera Rig unlike onAfterCameraRenderObservable
  325. */
  326. onAfterRenderCameraObservable: Observable<Camera>;
  327. private _onAfterRenderObserver;
  328. /** Sets a function to be executed after rendering this scene */
  329. set afterRender(callback: Nullable<() => void>);
  330. /**
  331. * An event triggered before animating the scene
  332. */
  333. onBeforeAnimationsObservable: Observable<Scene>;
  334. /**
  335. * An event triggered after animations processing
  336. */
  337. onAfterAnimationsObservable: Observable<Scene>;
  338. /**
  339. * An event triggered before draw calls are ready to be sent
  340. */
  341. onBeforeDrawPhaseObservable: Observable<Scene>;
  342. /**
  343. * An event triggered after draw calls have been sent
  344. */
  345. onAfterDrawPhaseObservable: Observable<Scene>;
  346. /**
  347. * An event triggered when the scene is ready
  348. */
  349. onReadyObservable: Observable<Scene>;
  350. /**
  351. * An event triggered before rendering a camera
  352. */
  353. onBeforeCameraRenderObservable: Observable<Camera>;
  354. private _onBeforeCameraRenderObserver;
  355. /** Sets a function to be executed before rendering a camera*/
  356. set beforeCameraRender(callback: () => void);
  357. /**
  358. * An event triggered after rendering a camera
  359. * This is triggered for the full rig Camera only unlike onAfterRenderCameraObservable
  360. */
  361. onAfterCameraRenderObservable: Observable<Camera>;
  362. private _onAfterCameraRenderObserver;
  363. /** Sets a function to be executed after rendering a camera*/
  364. set afterCameraRender(callback: () => void);
  365. /**
  366. * An event triggered when active meshes evaluation is about to start
  367. */
  368. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  369. /**
  370. * An event triggered when active meshes evaluation is done
  371. */
  372. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  373. /**
  374. * An event triggered when particles rendering is about to start
  375. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  376. */
  377. onBeforeParticlesRenderingObservable: Observable<Scene>;
  378. /**
  379. * An event triggered when particles rendering is done
  380. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  381. */
  382. onAfterParticlesRenderingObservable: Observable<Scene>;
  383. /**
  384. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  385. */
  386. onDataLoadedObservable: Observable<Scene>;
  387. /**
  388. * An event triggered when a camera is created
  389. */
  390. onNewCameraAddedObservable: Observable<Camera>;
  391. /**
  392. * An event triggered when a camera is removed
  393. */
  394. onCameraRemovedObservable: Observable<Camera>;
  395. /**
  396. * An event triggered when a light is created
  397. */
  398. onNewLightAddedObservable: Observable<Light>;
  399. /**
  400. * An event triggered when a light is removed
  401. */
  402. onLightRemovedObservable: Observable<Light>;
  403. /**
  404. * An event triggered when a geometry is created
  405. */
  406. onNewGeometryAddedObservable: Observable<Geometry>;
  407. /**
  408. * An event triggered when a geometry is removed
  409. */
  410. onGeometryRemovedObservable: Observable<Geometry>;
  411. /**
  412. * An event triggered when a transform node is created
  413. */
  414. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  415. /**
  416. * An event triggered when a transform node is removed
  417. */
  418. onTransformNodeRemovedObservable: Observable<TransformNode>;
  419. /**
  420. * An event triggered when a mesh is created
  421. */
  422. onNewMeshAddedObservable: Observable<AbstractMesh>;
  423. /**
  424. * An event triggered when a mesh is removed
  425. */
  426. onMeshRemovedObservable: Observable<AbstractMesh>;
  427. /**
  428. * An event triggered when a skeleton is created
  429. */
  430. onNewSkeletonAddedObservable: Observable<Skeleton>;
  431. /**
  432. * An event triggered when a skeleton is removed
  433. */
  434. onSkeletonRemovedObservable: Observable<Skeleton>;
  435. /**
  436. * An event triggered when a material is created
  437. */
  438. onNewMaterialAddedObservable: Observable<Material>;
  439. /**
  440. * An event triggered when a multi material is created
  441. */
  442. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  443. /**
  444. * An event triggered when a material is removed
  445. */
  446. onMaterialRemovedObservable: Observable<Material>;
  447. /**
  448. * An event triggered when a multi material is removed
  449. */
  450. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  451. /**
  452. * An event triggered when a texture is created
  453. */
  454. onNewTextureAddedObservable: Observable<BaseTexture>;
  455. /**
  456. * An event triggered when a texture is removed
  457. */
  458. onTextureRemovedObservable: Observable<BaseTexture>;
  459. /**
  460. * An event triggered when render targets are about to be rendered
  461. * Can happen multiple times per frame.
  462. */
  463. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  464. /**
  465. * An event triggered when render targets were rendered.
  466. * Can happen multiple times per frame.
  467. */
  468. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  469. /**
  470. * An event triggered before calculating deterministic simulation step
  471. */
  472. onBeforeStepObservable: Observable<Scene>;
  473. /**
  474. * An event triggered after calculating deterministic simulation step
  475. */
  476. onAfterStepObservable: Observable<Scene>;
  477. /**
  478. * An event triggered when the activeCamera property is updated
  479. */
  480. onActiveCameraChanged: Observable<Scene>;
  481. /**
  482. * An event triggered when the activeCameras property is updated
  483. */
  484. onActiveCamerasChanged: Observable<Scene>;
  485. /**
  486. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  487. * The RenderingGroupInfo class contains all the information about the context in which the observable is called
  488. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  489. */
  490. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  491. /**
  492. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  493. * The RenderingGroupInfo class contains all the information about the context in which the observable is called
  494. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  495. */
  496. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  497. /**
  498. * This Observable will when a mesh has been imported into the scene.
  499. */
  500. onMeshImportedObservable: Observable<AbstractMesh>;
  501. /**
  502. * This Observable will when an animation file has been imported into the scene.
  503. */
  504. onAnimationFileImportedObservable: Observable<Scene>;
  505. /**
  506. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  507. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  508. */
  509. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  510. /** @internal */
  511. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  512. private _pointerPickingConfiguration;
  513. /**
  514. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  515. */
  516. get pointerDownPredicate(): (Mesh: AbstractMesh) => boolean;
  517. set pointerDownPredicate(value: (Mesh: AbstractMesh) => boolean);
  518. /**
  519. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  520. */
  521. get pointerUpPredicate(): (Mesh: AbstractMesh) => boolean;
  522. set pointerUpPredicate(value: (Mesh: AbstractMesh) => boolean);
  523. /**
  524. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  525. */
  526. get pointerMovePredicate(): (Mesh: AbstractMesh) => boolean;
  527. set pointerMovePredicate(value: (Mesh: AbstractMesh) => boolean);
  528. /**
  529. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  530. */
  531. get pointerDownFastCheck(): boolean;
  532. set pointerDownFastCheck(value: boolean);
  533. /**
  534. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  535. */
  536. get pointerUpFastCheck(): boolean;
  537. set pointerUpFastCheck(value: boolean);
  538. /**
  539. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  540. */
  541. get pointerMoveFastCheck(): boolean;
  542. set pointerMoveFastCheck(value: boolean);
  543. /**
  544. * Gets or sets a boolean indicating if the user want to entirely skip the picking phase when a pointer move event occurs.
  545. */
  546. get skipPointerMovePicking(): boolean;
  547. set skipPointerMovePicking(value: boolean);
  548. /**
  549. * Gets or sets a boolean indicating if the user want to entirely skip the picking phase when a pointer down event occurs.
  550. */
  551. get skipPointerDownPicking(): boolean;
  552. set skipPointerDownPicking(value: boolean);
  553. /**
  554. * Gets or sets a boolean indicating if the user want to entirely skip the picking phase when a pointer up event occurs. Off by default.
  555. */
  556. get skipPointerUpPicking(): boolean;
  557. set skipPointerUpPicking(value: boolean);
  558. /** Callback called when a pointer move is detected */
  559. onPointerMove?: (evt: IPointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  560. /** Callback called when a pointer down is detected */
  561. onPointerDown?: (evt: IPointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  562. /** Callback called when a pointer up is detected */
  563. onPointerUp?: (evt: IPointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  564. /** Callback called when a pointer pick is detected */
  565. onPointerPick?: (evt: IPointerEvent, pickInfo: PickingInfo) => void;
  566. /**
  567. * Gets or sets a predicate used to select candidate faces for a pointer move event
  568. */
  569. pointerMoveTrianglePredicate: ((p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean) | undefined;
  570. /**
  571. * Gets or sets a predicate used to select candidate faces for a pointer down event
  572. */
  573. pointerDownTrianglePredicate: ((p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean) | undefined;
  574. /**
  575. * Gets or sets a predicate used to select candidate faces for a pointer up event
  576. */
  577. pointerUpTrianglePredicate: ((p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean) | undefined;
  578. /**
  579. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  580. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  581. */
  582. onPrePointerObservable: Observable<PointerInfoPre>;
  583. /**
  584. * Observable event triggered each time an input event is received from the rendering canvas
  585. */
  586. onPointerObservable: Observable<PointerInfo>;
  587. /**
  588. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  589. */
  590. get unTranslatedPointer(): Vector2;
  591. /**
  592. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  593. */
  594. static get DragMovementThreshold(): number;
  595. static set DragMovementThreshold(value: number);
  596. /**
  597. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  598. */
  599. static get LongPressDelay(): number;
  600. static set LongPressDelay(value: number);
  601. /**
  602. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  603. */
  604. static get DoubleClickDelay(): number;
  605. static set DoubleClickDelay(value: number);
  606. /** If you need to check double click without raising a single click at first click, enable this flag */
  607. static get ExclusiveDoubleClickMode(): boolean;
  608. static set ExclusiveDoubleClickMode(value: boolean);
  609. /**
  610. * Bind the current view position to an effect.
  611. * @param effect The effect to be bound
  612. * @param variableName name of the shader variable that will hold the eye position
  613. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  614. * @returns the computed eye position
  615. */
  616. bindEyePosition(effect: Nullable<Effect>, variableName?: string, isVector3?: boolean): Vector4;
  617. /**
  618. * Update the scene ubo before it can be used in rendering processing
  619. * @returns the scene UniformBuffer
  620. */
  621. finalizeSceneUbo(): UniformBuffer;
  622. /** @internal */
  623. _mirroredCameraPosition: Nullable<Vector3>;
  624. /**
  625. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  626. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  627. */
  628. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  629. /**
  630. * Observable event triggered each time an keyboard event is received from the hosting window
  631. */
  632. onKeyboardObservable: Observable<KeyboardInfo>;
  633. private _useRightHandedSystem;
  634. /**
  635. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  636. */
  637. set useRightHandedSystem(value: boolean);
  638. get useRightHandedSystem(): boolean;
  639. private _timeAccumulator;
  640. private _currentStepId;
  641. private _currentInternalStep;
  642. /**
  643. * Sets the step Id used by deterministic lock step
  644. * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#deterministic-lockstep
  645. * @param newStepId defines the step Id
  646. */
  647. setStepId(newStepId: number): void;
  648. /**
  649. * Gets the step Id used by deterministic lock step
  650. * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#deterministic-lockstep
  651. * @returns the step Id
  652. */
  653. getStepId(): number;
  654. /**
  655. * Gets the internal step used by deterministic lock step
  656. * @see https://doc.babylonjs.com/features/featuresDeepDive/animation/advanced_animations#deterministic-lockstep
  657. * @returns the internal step
  658. */
  659. getInternalStep(): number;
  660. private _fogEnabled;
  661. /**
  662. * Gets or sets a boolean indicating if fog is enabled on this scene
  663. * @see https://doc.babylonjs.com/features/featuresDeepDive/environment/environment_introduction#fog
  664. * (Default is true)
  665. */
  666. set fogEnabled(value: boolean);
  667. get fogEnabled(): boolean;
  668. private _fogMode;
  669. /**
  670. * Gets or sets the fog mode to use
  671. * @see https://doc.babylonjs.com/features/featuresDeepDive/environment/environment_introduction#fog
  672. * | mode | value |
  673. * | --- | --- |
  674. * | FOGMODE_NONE | 0 |
  675. * | FOGMODE_EXP | 1 |
  676. * | FOGMODE_EXP2 | 2 |
  677. * | FOGMODE_LINEAR | 3 |
  678. */
  679. set fogMode(value: number);
  680. get fogMode(): number;
  681. /**
  682. * Gets or sets the fog color to use
  683. * @see https://doc.babylonjs.com/features/featuresDeepDive/environment/environment_introduction#fog
  684. * (Default is Color3(0.2, 0.2, 0.3))
  685. */
  686. fogColor: Color3;
  687. /**
  688. * Gets or sets the fog density to use
  689. * @see https://doc.babylonjs.com/features/featuresDeepDive/environment/environment_introduction#fog
  690. * (Default is 0.1)
  691. */
  692. fogDensity: number;
  693. /**
  694. * Gets or sets the fog start distance to use
  695. * @see https://doc.babylonjs.com/features/featuresDeepDive/environment/environment_introduction#fog
  696. * (Default is 0)
  697. */
  698. fogStart: number;
  699. /**
  700. * Gets or sets the fog end distance to use
  701. * @see https://doc.babylonjs.com/features/featuresDeepDive/environment/environment_introduction#fog
  702. * (Default is 1000)
  703. */
  704. fogEnd: number;
  705. /**
  706. * Flag indicating that the frame buffer binding is handled by another component
  707. */
  708. get prePass(): boolean;
  709. /**
  710. * Flag indicating if we need to store previous matrices when rendering
  711. */
  712. needsPreviousWorldMatrices: boolean;
  713. private _shadowsEnabled;
  714. /**
  715. * Gets or sets a boolean indicating if shadows are enabled on this scene
  716. */
  717. set shadowsEnabled(value: boolean);
  718. get shadowsEnabled(): boolean;
  719. private _lightsEnabled;
  720. /**
  721. * Gets or sets a boolean indicating if lights are enabled on this scene
  722. */
  723. set lightsEnabled(value: boolean);
  724. get lightsEnabled(): boolean;
  725. private _activeCameras;
  726. private _unObserveActiveCameras;
  727. /** All of the active cameras added to this scene. */
  728. get activeCameras(): Nullable<Camera[]>;
  729. set activeCameras(cameras: Nullable<Camera[]>);
  730. /** @internal */
  731. _activeCamera: Nullable<Camera>;
  732. /** Gets or sets the current active camera */
  733. get activeCamera(): Nullable<Camera>;
  734. set activeCamera(value: Nullable<Camera>);
  735. private _defaultMaterial;
  736. /** The default material used on meshes when no material is affected */
  737. get defaultMaterial(): Material;
  738. /** The default material used on meshes when no material is affected */
  739. set defaultMaterial(value: Material);
  740. private _texturesEnabled;
  741. /**
  742. * Gets or sets a boolean indicating if textures are enabled on this scene
  743. */
  744. set texturesEnabled(value: boolean);
  745. get texturesEnabled(): boolean;
  746. /**
  747. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  748. */
  749. physicsEnabled: boolean;
  750. /**
  751. * Gets or sets a boolean indicating if particles are enabled on this scene
  752. */
  753. particlesEnabled: boolean;
  754. /**
  755. * Gets or sets a boolean indicating if sprites are enabled on this scene
  756. */
  757. spritesEnabled: boolean;
  758. private _skeletonsEnabled;
  759. /**
  760. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  761. */
  762. set skeletonsEnabled(value: boolean);
  763. get skeletonsEnabled(): boolean;
  764. /**
  765. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  766. */
  767. lensFlaresEnabled: boolean;
  768. /**
  769. * Gets or sets a boolean indicating if collisions are enabled on this scene
  770. * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_collisions
  771. */
  772. collisionsEnabled: boolean;
  773. private _collisionCoordinator;
  774. /** @internal */
  775. get collisionCoordinator(): ICollisionCoordinator;
  776. /**
  777. * Defines the gravity applied to this scene (used only for collisions)
  778. * @see https://doc.babylonjs.com/features/featuresDeepDive/cameras/camera_collisions
  779. */
  780. gravity: Vector3;
  781. /**
  782. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  783. */
  784. postProcessesEnabled: boolean;
  785. /**
  786. * Gets the current postprocess manager
  787. */
  788. postProcessManager: PostProcessManager;
  789. /**
  790. * Gets or sets a boolean indicating if render targets are enabled on this scene
  791. */
  792. renderTargetsEnabled: boolean;
  793. /**
  794. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  795. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  796. */
  797. dumpNextRenderTargets: boolean;
  798. /**
  799. * The list of user defined render targets added to the scene
  800. */
  801. customRenderTargets: RenderTargetTexture[];
  802. /**
  803. * Defines if texture loading must be delayed
  804. * If true, textures will only be loaded when they need to be rendered
  805. */
  806. useDelayedTextureLoading: boolean;
  807. /**
  808. * Gets the list of meshes imported to the scene through SceneLoader
  809. */
  810. importedMeshesFiles: string[];
  811. /**
  812. * Gets or sets a boolean indicating if probes are enabled on this scene
  813. */
  814. probesEnabled: boolean;
  815. /**
  816. * Gets or sets the current offline provider to use to store scene data
  817. * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimizeCached
  818. */
  819. offlineProvider: IOfflineProvider;
  820. /**
  821. * Gets or sets the action manager associated with the scene
  822. * @see https://doc.babylonjs.com/features/featuresDeepDive/events/actions
  823. */
  824. actionManager: AbstractActionManager;
  825. private _meshesForIntersections;
  826. /**
  827. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  828. */
  829. proceduralTexturesEnabled: boolean;
  830. private _engine;
  831. private _totalVertices;
  832. /** @internal */
  833. _activeIndices: PerfCounter;
  834. /** @internal */
  835. _activeParticles: PerfCounter;
  836. /** @internal */
  837. _activeBones: PerfCounter;
  838. private _animationRatio;
  839. /** @internal */
  840. _animationTimeLast: number;
  841. /** @internal */
  842. _animationTime: number;
  843. /**
  844. * Gets or sets a general scale for animation speed
  845. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  846. */
  847. animationTimeScale: number;
  848. /** @internal */
  849. _cachedMaterial: Nullable<Material>;
  850. /** @internal */
  851. _cachedEffect: Nullable<Effect>;
  852. /** @internal */
  853. _cachedVisibility: Nullable<number>;
  854. private _renderId;
  855. private _frameId;
  856. private _executeWhenReadyTimeoutId;
  857. private _intermediateRendering;
  858. private _defaultFrameBufferCleared;
  859. private _viewUpdateFlag;
  860. private _projectionUpdateFlag;
  861. /** @internal */
  862. _toBeDisposed: Nullable<IDisposable>[];
  863. private _activeRequests;
  864. /** @internal */
  865. _pendingData: any[];
  866. private _isDisposed;
  867. /**
  868. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  869. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  870. */
  871. dispatchAllSubMeshesOfActiveMeshes: boolean;
  872. private _activeMeshes;
  873. private _processedMaterials;
  874. private _renderTargets;
  875. private _materialsRenderTargets;
  876. /** @internal */
  877. _activeParticleSystems: SmartArray<IParticleSystem>;
  878. private _activeSkeletons;
  879. private _softwareSkinnedMeshes;
  880. private _renderingManager;
  881. /**
  882. * Gets the scene's rendering manager
  883. */
  884. get renderingManager(): RenderingManager;
  885. /** @internal */
  886. _activeAnimatables: Animatable[];
  887. private _transformMatrix;
  888. private _sceneUbo;
  889. /** @internal */
  890. _viewMatrix: Matrix;
  891. /** @internal */
  892. _projectionMatrix: Matrix;
  893. /** @internal */
  894. _forcedViewPosition: Nullable<Vector3>;
  895. /** @internal */
  896. _frustumPlanes: Plane[];
  897. /**
  898. * Gets the list of frustum planes (built from the active camera)
  899. */
  900. get frustumPlanes(): Plane[];
  901. /**
  902. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  903. * This is useful if there are more lights that the maximum simulteanous authorized
  904. */
  905. requireLightSorting: boolean;
  906. /** @internal */
  907. readonly useMaterialMeshMap: boolean;
  908. /** @internal */
  909. readonly useClonedMeshMap: boolean;
  910. private _externalData;
  911. private _uid;
  912. /**
  913. * @internal
  914. * Backing store of defined scene components.
  915. */
  916. _components: ISceneComponent[];
  917. /**
  918. * @internal
  919. * Backing store of defined scene components.
  920. */
  921. _serializableComponents: ISceneSerializableComponent[];
  922. /**
  923. * List of components to register on the next registration step.
  924. */
  925. private _transientComponents;
  926. /**
  927. * Registers the transient components if needed.
  928. */
  929. private _registerTransientComponents;
  930. /**
  931. * @internal
  932. * Add a component to the scene.
  933. * Note that the ccomponent could be registered on th next frame if this is called after
  934. * the register component stage.
  935. * @param component Defines the component to add to the scene
  936. */
  937. _addComponent(component: ISceneComponent): void;
  938. /**
  939. * @internal
  940. * Gets a component from the scene.
  941. * @param name defines the name of the component to retrieve
  942. * @returns the component or null if not present
  943. */
  944. _getComponent(name: string): Nullable<ISceneComponent>;
  945. /**
  946. * @internal
  947. * Defines the actions happening before camera updates.
  948. */
  949. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  950. /**
  951. * @internal
  952. * Defines the actions happening before clear the canvas.
  953. */
  954. _beforeClearStage: Stage<SimpleStageAction>;
  955. /**
  956. * @internal
  957. * Defines the actions happening before clear the canvas.
  958. */
  959. _beforeRenderTargetClearStage: Stage<RenderTargetStageAction>;
  960. /**
  961. * @internal
  962. * Defines the actions when collecting render targets for the frame.
  963. */
  964. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  965. /**
  966. * @internal
  967. * Defines the actions happening for one camera in the frame.
  968. */
  969. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  970. /**
  971. * @internal
  972. * Defines the actions happening during the per mesh ready checks.
  973. */
  974. _isReadyForMeshStage: Stage<MeshStageAction>;
  975. /**
  976. * @internal
  977. * Defines the actions happening before evaluate active mesh checks.
  978. */
  979. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  980. /**
  981. * @internal
  982. * Defines the actions happening during the evaluate sub mesh checks.
  983. */
  984. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  985. /**
  986. * @internal
  987. * Defines the actions happening during the active mesh stage.
  988. */
  989. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  990. /**
  991. * @internal
  992. * Defines the actions happening during the per camera render target step.
  993. */
  994. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  995. /**
  996. * @internal
  997. * Defines the actions happening just before the active camera is drawing.
  998. */
  999. _beforeCameraDrawStage: Stage<CameraStageAction>;
  1000. /**
  1001. * @internal
  1002. * Defines the actions happening just before a render target is drawing.
  1003. */
  1004. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1005. /**
  1006. * @internal
  1007. * Defines the actions happening just before a rendering group is drawing.
  1008. */
  1009. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1010. /**
  1011. * @internal
  1012. * Defines the actions happening just before a mesh is drawing.
  1013. */
  1014. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1015. /**
  1016. * @internal
  1017. * Defines the actions happening just after a mesh has been drawn.
  1018. */
  1019. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  1020. /**
  1021. * @internal
  1022. * Defines the actions happening just after a rendering group has been drawn.
  1023. */
  1024. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  1025. /**
  1026. * @internal
  1027. * Defines the actions happening just after the active camera has been drawn.
  1028. */
  1029. _afterCameraDrawStage: Stage<CameraStageAction>;
  1030. /**
  1031. * @internal
  1032. * Defines the actions happening just after the post processing
  1033. */
  1034. _afterCameraPostProcessStage: Stage<CameraStageAction>;
  1035. /**
  1036. * @internal
  1037. * Defines the actions happening just after a render target has been drawn.
  1038. */
  1039. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  1040. /**
  1041. * Defines the actions happening just after the post processing on a render target
  1042. */
  1043. _afterRenderTargetPostProcessStage: Stage<RenderTargetStageAction>;
  1044. /**
  1045. * @internal
  1046. * Defines the actions happening just after rendering all cameras and computing intersections.
  1047. */
  1048. _afterRenderStage: Stage<SimpleStageAction>;
  1049. /**
  1050. * @internal
  1051. * Defines the actions happening when a pointer move event happens.
  1052. */
  1053. _pointerMoveStage: Stage<PointerMoveStageAction>;
  1054. /**
  1055. * @internal
  1056. * Defines the actions happening when a pointer down event happens.
  1057. */
  1058. _pointerDownStage: Stage<PointerUpDownStageAction>;
  1059. /**
  1060. * @internal
  1061. * Defines the actions happening when a pointer up event happens.
  1062. */
  1063. _pointerUpStage: Stage<PointerUpDownStageAction>;
  1064. /**
  1065. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  1066. */
  1067. private _geometriesByUniqueId;
  1068. /**
  1069. * Creates a new Scene
  1070. * @param engine defines the engine to use to render this scene
  1071. * @param options defines the scene options
  1072. */
  1073. constructor(engine: AbstractEngine, options?: SceneOptions);
  1074. /**
  1075. * Gets a string identifying the name of the class
  1076. * @returns "Scene" string
  1077. */
  1078. getClassName(): string;
  1079. private _defaultMeshCandidates;
  1080. /**
  1081. * @internal
  1082. */
  1083. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  1084. private _defaultSubMeshCandidates;
  1085. /**
  1086. * @internal
  1087. */
  1088. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  1089. /**
  1090. * Sets the default candidate providers for the scene.
  1091. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  1092. * and getCollidingSubMeshCandidates to their default function
  1093. */
  1094. setDefaultCandidateProviders(): void;
  1095. /**
  1096. * Gets the mesh that is currently under the pointer
  1097. */
  1098. get meshUnderPointer(): Nullable<AbstractMesh>;
  1099. /**
  1100. * Gets or sets the current on-screen X position of the pointer
  1101. */
  1102. get pointerX(): number;
  1103. set pointerX(value: number);
  1104. /**
  1105. * Gets or sets the current on-screen Y position of the pointer
  1106. */
  1107. get pointerY(): number;
  1108. set pointerY(value: number);
  1109. /**
  1110. * Gets the cached material (ie. the latest rendered one)
  1111. * @returns the cached material
  1112. */
  1113. getCachedMaterial(): Nullable<Material>;
  1114. /**
  1115. * Gets the cached effect (ie. the latest rendered one)
  1116. * @returns the cached effect
  1117. */
  1118. getCachedEffect(): Nullable<Effect>;
  1119. /**
  1120. * Gets the cached visibility state (ie. the latest rendered one)
  1121. * @returns the cached visibility state
  1122. */
  1123. getCachedVisibility(): Nullable<number>;
  1124. /**
  1125. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  1126. * @param material defines the current material
  1127. * @param effect defines the current effect
  1128. * @param visibility defines the current visibility state
  1129. * @returns true if one parameter is not cached
  1130. */
  1131. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  1132. /**
  1133. * Gets the engine associated with the scene
  1134. * @returns an Engine
  1135. */
  1136. getEngine(): AbstractEngine;
  1137. /**
  1138. * Gets the total number of vertices rendered per frame
  1139. * @returns the total number of vertices rendered per frame
  1140. */
  1141. getTotalVertices(): number;
  1142. /**
  1143. * Gets the performance counter for total vertices
  1144. * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimize_your_scene#instrumentation
  1145. */
  1146. get totalVerticesPerfCounter(): PerfCounter;
  1147. /**
  1148. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  1149. * @returns the total number of active indices rendered per frame
  1150. */
  1151. getActiveIndices(): number;
  1152. /**
  1153. * Gets the performance counter for active indices
  1154. * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimize_your_scene#instrumentation
  1155. */
  1156. get totalActiveIndicesPerfCounter(): PerfCounter;
  1157. /**
  1158. * Gets the total number of active particles rendered per frame
  1159. * @returns the total number of active particles rendered per frame
  1160. */
  1161. getActiveParticles(): number;
  1162. /**
  1163. * Gets the performance counter for active particles
  1164. * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimize_your_scene#instrumentation
  1165. */
  1166. get activeParticlesPerfCounter(): PerfCounter;
  1167. /**
  1168. * Gets the total number of active bones rendered per frame
  1169. * @returns the total number of active bones rendered per frame
  1170. */
  1171. getActiveBones(): number;
  1172. /**
  1173. * Gets the performance counter for active bones
  1174. * @see https://doc.babylonjs.com/features/featuresDeepDive/scene/optimize_your_scene#instrumentation
  1175. */
  1176. get activeBonesPerfCounter(): PerfCounter;
  1177. /**
  1178. * Gets the array of active meshes
  1179. * @returns an array of AbstractMesh
  1180. */
  1181. getActiveMeshes(): SmartArray<AbstractMesh>;
  1182. /**
  1183. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  1184. * @returns a number
  1185. */
  1186. getAnimationRatio(): number;
  1187. /**
  1188. * Gets an unique Id for the current render phase
  1189. * @returns a number
  1190. */
  1191. getRenderId(): number;
  1192. /**
  1193. * Gets an unique Id for the current frame
  1194. * @returns a number
  1195. */
  1196. getFrameId(): number;
  1197. /** Call this function if you want to manually increment the render Id*/
  1198. incrementRenderId(): void;
  1199. private _createUbo;
  1200. /**
  1201. * Use this method to simulate a pointer move on a mesh
  1202. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1203. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1204. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1205. * @returns the current scene
  1206. */
  1207. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1208. /**
  1209. * Use this method to simulate a pointer down on a mesh
  1210. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1211. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1212. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1213. * @returns the current scene
  1214. */
  1215. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  1216. /**
  1217. * Use this method to simulate a pointer up on a mesh
  1218. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  1219. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  1220. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  1221. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  1222. * @returns the current scene
  1223. */
  1224. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  1225. /**
  1226. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  1227. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  1228. * @returns true if the pointer was captured
  1229. */
  1230. isPointerCaptured(pointerId?: number): boolean;
  1231. /**
  1232. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  1233. * @param attachUp defines if you want to attach events to pointerup
  1234. * @param attachDown defines if you want to attach events to pointerdown
  1235. * @param attachMove defines if you want to attach events to pointermove
  1236. */
  1237. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  1238. /** Detaches all event handlers*/
  1239. detachControl(): void;
  1240. /**
  1241. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  1242. * Delay loaded resources are not taking in account
  1243. * @param checkRenderTargets true to also check that the meshes rendered as part of a render target are ready (default: true)
  1244. * @returns true if all required resources are ready
  1245. */
  1246. isReady(checkRenderTargets?: boolean): boolean;
  1247. /** Resets all cached information relative to material (including effect and visibility) */
  1248. resetCachedMaterial(): void;
  1249. /**
  1250. * Registers a function to be called before every frame render
  1251. * @param func defines the function to register
  1252. */
  1253. registerBeforeRender(func: () => void): void;
  1254. /**
  1255. * Unregisters a function called before every frame render
  1256. * @param func defines the function to unregister
  1257. */
  1258. unregisterBeforeRender(func: () => void): void;
  1259. /**
  1260. * Registers a function to be called after every frame render
  1261. * @param func defines the function to register
  1262. */
  1263. registerAfterRender(func: () => void): void;
  1264. /**
  1265. * Unregisters a function called after every frame render
  1266. * @param func defines the function to unregister
  1267. */
  1268. unregisterAfterRender(func: () => void): void;
  1269. private _executeOnceBeforeRender;
  1270. /**
  1271. * The provided function will run before render once and will be disposed afterwards.
  1272. * A timeout delay can be provided so that the function will be executed in N ms.
  1273. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  1274. * @param func The function to be executed.
  1275. * @param timeout optional delay in ms
  1276. */
  1277. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  1278. /**
  1279. * This function can help adding any object to the list of data awaited to be ready in order to check for a complete scene loading.
  1280. * @param data defines the object to wait for
  1281. */
  1282. addPendingData(data: any): void;
  1283. /**
  1284. * Remove a pending data from the loading list which has previously been added with addPendingData.
  1285. * @param data defines the object to remove from the pending list
  1286. */
  1287. removePendingData(data: any): void;
  1288. /**
  1289. * Returns the number of items waiting to be loaded
  1290. * @returns the number of items waiting to be loaded
  1291. */
  1292. getWaitingItemsCount(): number;
  1293. /**
  1294. * Returns a boolean indicating if the scene is still loading data
  1295. */
  1296. get isLoading(): boolean;
  1297. /**
  1298. * Registers a function to be executed when the scene is ready
  1299. * @param func - the function to be executed
  1300. * @param checkRenderTargets true to also check that the meshes rendered as part of a render target are ready (default: false)
  1301. */
  1302. executeWhenReady(func: () => void, checkRenderTargets?: boolean): void;
  1303. /**
  1304. * Returns a promise that resolves when the scene is ready
  1305. * @param checkRenderTargets true to also check that the meshes rendered as part of a render target are ready (default: false)
  1306. * @returns A promise that resolves when the scene is ready
  1307. */
  1308. whenReadyAsync(checkRenderTargets?: boolean): Promise<void>;
  1309. /**
  1310. * @internal
  1311. */
  1312. _checkIsReady(checkRenderTargets?: boolean): void;
  1313. /**
  1314. * Gets all animatable attached to the scene
  1315. */
  1316. get animatables(): Animatable[];
  1317. /**
  1318. * Resets the last animation time frame.
  1319. * Useful to override when animations start running when loading a scene for the first time.
  1320. */
  1321. resetLastAnimationTimeFrame(): void;
  1322. /**
  1323. * Gets the current view matrix
  1324. * @returns a Matrix
  1325. */
  1326. getViewMatrix(): Matrix;
  1327. /**
  1328. * Gets the current projection matrix
  1329. * @returns a Matrix
  1330. */
  1331. getProjectionMatrix(): Matrix;
  1332. /**
  1333. * Gets the current transform matrix
  1334. * @returns a Matrix made of View * Projection
  1335. */
  1336. getTransformMatrix(): Matrix;
  1337. /**
  1338. * Sets the current transform matrix
  1339. * @param viewL defines the View matrix to use
  1340. * @param projectionL defines the Projection matrix to use
  1341. * @param viewR defines the right View matrix to use (if provided)
  1342. * @param projectionR defines the right Projection matrix to use (if provided)
  1343. */
  1344. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  1345. /**
  1346. * Gets the uniform buffer used to store scene data
  1347. * @returns a UniformBuffer
  1348. */
  1349. getSceneUniformBuffer(): UniformBuffer;
  1350. /**
  1351. * Creates a scene UBO
  1352. * @param name name of the uniform buffer (optional, for debugging purpose only)
  1353. * @returns a new ubo
  1354. */
  1355. createSceneUniformBuffer(name?: string): UniformBuffer;
  1356. /**
  1357. * Sets the scene ubo
  1358. * @param ubo the ubo to set for the scene
  1359. */
  1360. setSceneUniformBuffer(ubo: UniformBuffer): void;
  1361. /**
  1362. * Gets an unique (relatively to the current scene) Id
  1363. * @returns an unique number for the scene
  1364. */
  1365. getUniqueId(): number;
  1366. /**
  1367. * Add a mesh to the list of scene's meshes
  1368. * @param newMesh defines the mesh to add
  1369. * @param recursive if all child meshes should also be added to the scene
  1370. */
  1371. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  1372. /**
  1373. * Remove a mesh for the list of scene's meshes
  1374. * @param toRemove defines the mesh to remove
  1375. * @param recursive if all child meshes should also be removed from the scene
  1376. * @returns the index where the mesh was in the mesh list
  1377. */
  1378. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  1379. /**
  1380. * Add a transform node to the list of scene's transform nodes
  1381. * @param newTransformNode defines the transform node to add
  1382. */
  1383. addTransformNode(newTransformNode: TransformNode): void;
  1384. /**
  1385. * Remove a transform node for the list of scene's transform nodes
  1386. * @param toRemove defines the transform node to remove
  1387. * @returns the index where the transform node was in the transform node list
  1388. */
  1389. removeTransformNode(toRemove: TransformNode): number;
  1390. /**
  1391. * Remove a skeleton for the list of scene's skeletons
  1392. * @param toRemove defines the skeleton to remove
  1393. * @returns the index where the skeleton was in the skeleton list
  1394. */
  1395. removeSkeleton(toRemove: Skeleton): number;
  1396. /**
  1397. * Remove a morph target for the list of scene's morph targets
  1398. * @param toRemove defines the morph target to remove
  1399. * @returns the index where the morph target was in the morph target list
  1400. */
  1401. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1402. /**
  1403. * Remove a light for the list of scene's lights
  1404. * @param toRemove defines the light to remove
  1405. * @returns the index where the light was in the light list
  1406. */
  1407. removeLight(toRemove: Light): number;
  1408. /**
  1409. * Remove a camera for the list of scene's cameras
  1410. * @param toRemove defines the camera to remove
  1411. * @returns the index where the camera was in the camera list
  1412. */
  1413. removeCamera(toRemove: Camera): number;
  1414. /**
  1415. * Remove a particle system for the list of scene's particle systems
  1416. * @param toRemove defines the particle system to remove
  1417. * @returns the index where the particle system was in the particle system list
  1418. */
  1419. removeParticleSystem(toRemove: IParticleSystem): number;
  1420. /**
  1421. * Remove a animation for the list of scene's animations
  1422. * @param toRemove defines the animation to remove
  1423. * @returns the index where the animation was in the animation list
  1424. */
  1425. removeAnimation(toRemove: Animation): number;
  1426. /**
  1427. * Will stop the animation of the given target
  1428. * @param target - the target
  1429. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  1430. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  1431. */
  1432. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  1433. /**
  1434. * Removes the given animation group from this scene.
  1435. * @param toRemove The animation group to remove
  1436. * @returns The index of the removed animation group
  1437. */
  1438. removeAnimationGroup(toRemove: AnimationGroup): number;
  1439. /**
  1440. * Removes the given multi-material from this scene.
  1441. * @param toRemove The multi-material to remove
  1442. * @returns The index of the removed multi-material
  1443. */
  1444. removeMultiMaterial(toRemove: MultiMaterial): number;
  1445. /**
  1446. * Removes the given material from this scene.
  1447. * @param toRemove The material to remove
  1448. * @returns The index of the removed material
  1449. */
  1450. removeMaterial(toRemove: Material): number;
  1451. /**
  1452. * Removes the given action manager from this scene.
  1453. * @deprecated
  1454. * @param toRemove The action manager to remove
  1455. * @returns The index of the removed action manager
  1456. */
  1457. removeActionManager(toRemove: AbstractActionManager): number;
  1458. /**
  1459. * Removes the given texture from this scene.
  1460. * @param toRemove The texture to remove
  1461. * @returns The index of the removed texture
  1462. */
  1463. removeTexture(toRemove: BaseTexture): number;
  1464. /**
  1465. * Adds the given light to this scene
  1466. * @param newLight The light to add
  1467. */
  1468. addLight(newLight: Light): void;
  1469. /**
  1470. * Sorts the list list based on light priorities
  1471. */
  1472. sortLightsByPriority(): void;
  1473. /**
  1474. * Adds the given camera to this scene
  1475. * @param newCamera The camera to add
  1476. */
  1477. addCamera(newCamera: Camera): void;
  1478. /**
  1479. * Adds the given skeleton to this scene
  1480. * @param newSkeleton The skeleton to add
  1481. */
  1482. addSkeleton(newSkeleton: Skeleton): void;
  1483. /**
  1484. * Adds the given particle system to this scene
  1485. * @param newParticleSystem The particle system to add
  1486. */
  1487. addParticleSystem(newParticleSystem: IParticleSystem): void;
  1488. /**
  1489. * Adds the given animation to this scene
  1490. * @param newAnimation The animation to add
  1491. */
  1492. addAnimation(newAnimation: Animation): void;
  1493. /**
  1494. * Adds the given animation group to this scene.
  1495. * @param newAnimationGroup The animation group to add
  1496. */
  1497. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  1498. /**
  1499. * Adds the given multi-material to this scene
  1500. * @param newMultiMaterial The multi-material to add
  1501. */
  1502. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1503. /**
  1504. * Adds the given material to this scene
  1505. * @param newMaterial The material to add
  1506. */
  1507. addMaterial(newMaterial: Material): void;
  1508. /**
  1509. * Adds the given morph target to this scene
  1510. * @param newMorphTargetManager The morph target to add
  1511. */
  1512. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1513. /**
  1514. * Adds the given geometry to this scene
  1515. * @param newGeometry The geometry to add
  1516. */
  1517. addGeometry(newGeometry: Geometry): void;
  1518. /**
  1519. * Adds the given action manager to this scene
  1520. * @deprecated
  1521. * @param newActionManager The action manager to add
  1522. */
  1523. addActionManager(newActionManager: AbstractActionManager): void;
  1524. /**
  1525. * Adds the given texture to this scene.
  1526. * @param newTexture The texture to add
  1527. */
  1528. addTexture(newTexture: BaseTexture): void;
  1529. /**
  1530. * Switch active camera
  1531. * @param newCamera defines the new active camera
  1532. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  1533. */
  1534. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1535. /**
  1536. * sets the active camera of the scene using its Id
  1537. * @param id defines the camera's Id
  1538. * @returns the new active camera or null if none found.
  1539. */
  1540. setActiveCameraById(id: string): Nullable<Camera>;
  1541. /**
  1542. * sets the active camera of the scene using its name
  1543. * @param name defines the camera's name
  1544. * @returns the new active camera or null if none found.
  1545. */
  1546. setActiveCameraByName(name: string): Nullable<Camera>;
  1547. /**
  1548. * get an animation group using its name
  1549. * @param name defines the material's name
  1550. * @returns the animation group or null if none found.
  1551. */
  1552. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1553. private _getMaterial;
  1554. /**
  1555. * Get a material using its unique id
  1556. * @param uniqueId defines the material's unique id
  1557. * @param allowMultiMaterials determines whether multimaterials should be considered
  1558. * @returns the material or null if none found.
  1559. */
  1560. getMaterialByUniqueID(uniqueId: number, allowMultiMaterials?: boolean): Nullable<Material>;
  1561. /**
  1562. * get a material using its id
  1563. * @param id defines the material's Id
  1564. * @param allowMultiMaterials determines whether multimaterials should be considered
  1565. * @returns the material or null if none found.
  1566. */
  1567. getMaterialById(id: string, allowMultiMaterials?: boolean): Nullable<Material>;
  1568. /**
  1569. * Gets a material using its name
  1570. * @param name defines the material's name
  1571. * @param allowMultiMaterials determines whether multimaterials should be considered
  1572. * @returns the material or null if none found.
  1573. */
  1574. getMaterialByName(name: string, allowMultiMaterials?: boolean): Nullable<Material>;
  1575. /**
  1576. * Gets a last added material using a given id
  1577. * @param id defines the material's id
  1578. * @param allowMultiMaterials determines whether multimaterials should be considered
  1579. * @returns the last material with the given id or null if none found.
  1580. */
  1581. getLastMaterialById(id: string, allowMultiMaterials?: boolean): Nullable<Material>;
  1582. /**
  1583. * Get a texture using its unique id
  1584. * @param uniqueId defines the texture's unique id
  1585. * @returns the texture or null if none found.
  1586. */
  1587. getTextureByUniqueId(uniqueId: number): Nullable<BaseTexture>;
  1588. /**
  1589. * Gets a texture using its name
  1590. * @param name defines the texture's name
  1591. * @returns the texture or null if none found.
  1592. */
  1593. getTextureByName(name: string): Nullable<BaseTexture>;
  1594. /**
  1595. * Gets a camera using its Id
  1596. * @param id defines the Id to look for
  1597. * @returns the camera or null if not found
  1598. */
  1599. getCameraById(id: string): Nullable<Camera>;
  1600. /**
  1601. * Gets a camera using its unique Id
  1602. * @param uniqueId defines the unique Id to look for
  1603. * @returns the camera or null if not found
  1604. */
  1605. getCameraByUniqueId(uniqueId: number): Nullable<Camera>;
  1606. /**
  1607. * Gets a camera using its name
  1608. * @param name defines the camera's name
  1609. * @returns the camera or null if none found.
  1610. */
  1611. getCameraByName(name: string): Nullable<Camera>;
  1612. /**
  1613. * Gets a bone using its Id
  1614. * @param id defines the bone's Id
  1615. * @returns the bone or null if not found
  1616. */
  1617. getBoneById(id: string): Nullable<Bone>;
  1618. /**
  1619. * Gets a bone using its id
  1620. * @param name defines the bone's name
  1621. * @returns the bone or null if not found
  1622. */
  1623. getBoneByName(name: string): Nullable<Bone>;
  1624. /**
  1625. * Gets a light node using its name
  1626. * @param name defines the light's name
  1627. * @returns the light or null if none found.
  1628. */
  1629. getLightByName(name: string): Nullable<Light>;
  1630. /**
  1631. * Gets a light node using its Id
  1632. * @param id defines the light's Id
  1633. * @returns the light or null if none found.
  1634. */
  1635. getLightById(id: string): Nullable<Light>;
  1636. /**
  1637. * Gets a light node using its scene-generated unique Id
  1638. * @param uniqueId defines the light's unique Id
  1639. * @returns the light or null if none found.
  1640. */
  1641. getLightByUniqueId(uniqueId: number): Nullable<Light>;
  1642. /**
  1643. * Gets a particle system by Id
  1644. * @param id defines the particle system Id
  1645. * @returns the corresponding system or null if none found
  1646. */
  1647. getParticleSystemById(id: string): Nullable<IParticleSystem>;
  1648. /**
  1649. * Gets a geometry using its Id
  1650. * @param id defines the geometry's Id
  1651. * @returns the geometry or null if none found.
  1652. */
  1653. getGeometryById(id: string): Nullable<Geometry>;
  1654. private _getGeometryByUniqueId;
  1655. /**
  1656. * Add a new geometry to this scene
  1657. * @param geometry defines the geometry to be added to the scene.
  1658. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  1659. * @returns a boolean defining if the geometry was added or not
  1660. */
  1661. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  1662. /**
  1663. * Removes an existing geometry
  1664. * @param geometry defines the geometry to be removed from the scene
  1665. * @returns a boolean defining if the geometry was removed or not
  1666. */
  1667. removeGeometry(geometry: Geometry): boolean;
  1668. /**
  1669. * Gets the list of geometries attached to the scene
  1670. * @returns an array of Geometry
  1671. */
  1672. getGeometries(): Geometry[];
  1673. /**
  1674. * Gets the first added mesh found of a given Id
  1675. * @param id defines the Id to search for
  1676. * @returns the mesh found or null if not found at all
  1677. */
  1678. getMeshById(id: string): Nullable<AbstractMesh>;
  1679. /**
  1680. * Gets a list of meshes using their Id
  1681. * @param id defines the Id to search for
  1682. * @returns a list of meshes
  1683. */
  1684. getMeshesById(id: string): Array<AbstractMesh>;
  1685. /**
  1686. * Gets the first added transform node found of a given Id
  1687. * @param id defines the Id to search for
  1688. * @returns the found transform node or null if not found at all.
  1689. */
  1690. getTransformNodeById(id: string): Nullable<TransformNode>;
  1691. /**
  1692. * Gets a transform node with its auto-generated unique Id
  1693. * @param uniqueId defines the unique Id to search for
  1694. * @returns the found transform node or null if not found at all.
  1695. */
  1696. getTransformNodeByUniqueId(uniqueId: number): Nullable<TransformNode>;
  1697. /**
  1698. * Gets a list of transform nodes using their Id
  1699. * @param id defines the Id to search for
  1700. * @returns a list of transform nodes
  1701. */
  1702. getTransformNodesById(id: string): Array<TransformNode>;
  1703. /**
  1704. * Gets a mesh with its auto-generated unique Id
  1705. * @param uniqueId defines the unique Id to search for
  1706. * @returns the found mesh or null if not found at all.
  1707. */
  1708. getMeshByUniqueId(uniqueId: number): Nullable<AbstractMesh>;
  1709. /**
  1710. * Gets a the last added mesh using a given Id
  1711. * @param id defines the Id to search for
  1712. * @returns the found mesh or null if not found at all.
  1713. */
  1714. getLastMeshById(id: string): Nullable<AbstractMesh>;
  1715. /**
  1716. * Gets a the last transform node using a given Id
  1717. * @param id defines the Id to search for
  1718. * @returns the found mesh or null if not found at all.
  1719. */
  1720. getLastTransformNodeById(id: string): Nullable<TransformNode>;
  1721. /**
  1722. * Gets a the last added node (Mesh, Camera, Light) using a given Id
  1723. * @param id defines the Id to search for
  1724. * @returns the found node or null if not found at all
  1725. */
  1726. getLastEntryById(id: string): Nullable<Node>;
  1727. /**
  1728. * Gets a node (Mesh, Camera, Light) using a given Id
  1729. * @param id defines the Id to search for
  1730. * @returns the found node or null if not found at all
  1731. */
  1732. getNodeById(id: string): Nullable<Node>;
  1733. /**
  1734. * Gets a node (Mesh, Camera, Light) using a given name
  1735. * @param name defines the name to search for
  1736. * @returns the found node or null if not found at all.
  1737. */
  1738. getNodeByName(name: string): Nullable<Node>;
  1739. /**
  1740. * Gets a mesh using a given name
  1741. * @param name defines the name to search for
  1742. * @returns the found mesh or null if not found at all.
  1743. */
  1744. getMeshByName(name: string): Nullable<AbstractMesh>;
  1745. /**
  1746. * Gets a transform node using a given name
  1747. * @param name defines the name to search for
  1748. * @returns the found transform node or null if not found at all.
  1749. */
  1750. getTransformNodeByName(name: string): Nullable<TransformNode>;
  1751. /**
  1752. * Gets a skeleton using a given Id (if many are found, this function will pick the last one)
  1753. * @param id defines the Id to search for
  1754. * @returns the found skeleton or null if not found at all.
  1755. */
  1756. getLastSkeletonById(id: string): Nullable<Skeleton>;
  1757. /**
  1758. * Gets a skeleton using a given auto generated unique id
  1759. * @param uniqueId defines the unique id to search for
  1760. * @returns the found skeleton or null if not found at all.
  1761. */
  1762. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  1763. /**
  1764. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  1765. * @param id defines the id to search for
  1766. * @returns the found skeleton or null if not found at all.
  1767. */
  1768. getSkeletonById(id: string): Nullable<Skeleton>;
  1769. /**
  1770. * Gets a skeleton using a given name
  1771. * @param name defines the name to search for
  1772. * @returns the found skeleton or null if not found at all.
  1773. */
  1774. getSkeletonByName(name: string): Nullable<Skeleton>;
  1775. /**
  1776. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  1777. * @param id defines the id to search for
  1778. * @returns the found morph target manager or null if not found at all.
  1779. */
  1780. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  1781. /**
  1782. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  1783. * @param id defines the id to search for
  1784. * @returns the found morph target or null if not found at all.
  1785. */
  1786. getMorphTargetById(id: string): Nullable<MorphTarget>;
  1787. /**
  1788. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  1789. * @param name defines the name to search for
  1790. * @returns the found morph target or null if not found at all.
  1791. */
  1792. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  1793. /**
  1794. * Gets a post process using a given name (if many are found, this function will pick the first one)
  1795. * @param name defines the name to search for
  1796. * @returns the found post process or null if not found at all.
  1797. */
  1798. getPostProcessByName(name: string): Nullable<PostProcess>;
  1799. /**
  1800. * Gets a boolean indicating if the given mesh is active
  1801. * @param mesh defines the mesh to look for
  1802. * @returns true if the mesh is in the active list
  1803. */
  1804. isActiveMesh(mesh: AbstractMesh): boolean;
  1805. /**
  1806. * Return a unique id as a string which can serve as an identifier for the scene
  1807. */
  1808. get uid(): string;
  1809. /**
  1810. * Add an externally attached data from its key.
  1811. * This method call will fail and return false, if such key already exists.
  1812. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  1813. * @param key the unique key that identifies the data
  1814. * @param data the data object to associate to the key for this Engine instance
  1815. * @returns true if no such key were already present and the data was added successfully, false otherwise
  1816. */
  1817. addExternalData<T extends Object>(key: string, data: T): boolean;
  1818. /**
  1819. * Get an externally attached data from its key
  1820. * @param key the unique key that identifies the data
  1821. * @returns the associated data, if present (can be null), or undefined if not present
  1822. */
  1823. getExternalData<T>(key: string): Nullable<T>;
  1824. /**
  1825. * Get an externally attached data from its key, create it using a factory if it's not already present
  1826. * @param key the unique key that identifies the data
  1827. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  1828. * @returns the associated data, can be null if the factory returned null.
  1829. */
  1830. getOrAddExternalDataWithFactory<T extends Object>(key: string, factory: (k: string) => T): T;
  1831. /**
  1832. * Remove an externally attached data from the Engine instance
  1833. * @param key the unique key that identifies the data
  1834. * @returns true if the data was successfully removed, false if it doesn't exist
  1835. */
  1836. removeExternalData(key: string): boolean;
  1837. private _evaluateSubMesh;
  1838. /**
  1839. * Clear the processed materials smart array preventing retention point in material dispose.
  1840. */
  1841. freeProcessedMaterials(): void;
  1842. private _preventFreeActiveMeshesAndRenderingGroups;
  1843. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  1844. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  1845. * when disposing several meshes in a row or a hierarchy of meshes.
  1846. * When used, it is the responsibility of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  1847. */
  1848. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  1849. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  1850. /**
  1851. * Clear the active meshes smart array preventing retention point in mesh dispose.
  1852. */
  1853. freeActiveMeshes(): void;
  1854. /**
  1855. * Clear the info related to rendering groups preventing retention points during dispose.
  1856. */
  1857. freeRenderingGroups(): void;
  1858. /** @internal */
  1859. _isInIntermediateRendering(): boolean;
  1860. /**
  1861. * Lambda returning the list of potentially active meshes.
  1862. */
  1863. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  1864. /**
  1865. * Lambda returning the list of potentially active sub meshes.
  1866. */
  1867. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  1868. /**
  1869. * Lambda returning the list of potentially intersecting sub meshes.
  1870. */
  1871. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  1872. /**
  1873. * Lambda returning the list of potentially colliding sub meshes.
  1874. */
  1875. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  1876. /** @internal */
  1877. _activeMeshesFrozen: boolean;
  1878. /** @internal */
  1879. _activeMeshesFrozenButKeepClipping: boolean;
  1880. private _skipEvaluateActiveMeshesCompletely;
  1881. /**
  1882. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  1883. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  1884. * @param onSuccess optional success callback
  1885. * @param onError optional error callback
  1886. * @param freezeMeshes defines if meshes should be frozen (true by default)
  1887. * @param keepFrustumCulling defines if you want to keep running the frustum clipping (false by default)
  1888. * @returns the current scene
  1889. */
  1890. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void, freezeMeshes?: boolean, keepFrustumCulling?: boolean): Scene;
  1891. /**
  1892. * Use this function to restart evaluating active meshes on every frame
  1893. * @returns the current scene
  1894. */
  1895. unfreezeActiveMeshes(): Scene;
  1896. private _executeActiveContainerCleanup;
  1897. private _evaluateActiveMeshes;
  1898. private _activeMesh;
  1899. /**
  1900. * Update the transform matrix to update from the current active camera
  1901. * @param force defines a boolean used to force the update even if cache is up to date
  1902. */
  1903. updateTransformMatrix(force?: boolean): void;
  1904. private _bindFrameBuffer;
  1905. private _clearFrameBuffer;
  1906. /** @internal */
  1907. _allowPostProcessClearColor: boolean;
  1908. /**
  1909. * @internal
  1910. */
  1911. _renderForCamera(camera: Camera, rigParent?: Camera, bindFrameBuffer?: boolean): void;
  1912. private _processSubCameras;
  1913. private _checkIntersections;
  1914. /**
  1915. * @internal
  1916. */
  1917. _advancePhysicsEngineStep(step: number): void;
  1918. /**
  1919. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  1920. * @returns the frame time
  1921. */
  1922. getDeterministicFrameTime: () => number;
  1923. /** @internal */
  1924. _animate(customDeltaTime?: number): void;
  1925. /** Execute all animations (for a frame) */
  1926. animate(): void;
  1927. private _clear;
  1928. private _checkCameraRenderTarget;
  1929. /**
  1930. * Resets the draw wrappers cache of all meshes
  1931. * @param passId If provided, releases only the draw wrapper corresponding to this render pass id
  1932. */
  1933. resetDrawCache(passId?: number): void;
  1934. /**
  1935. * Render the scene
  1936. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  1937. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  1938. */
  1939. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  1940. /**
  1941. * Freeze all materials
  1942. * A frozen material will not be updatable but should be faster to render
  1943. * Note: multimaterials will not be frozen, but their submaterials will
  1944. */
  1945. freezeMaterials(): void;
  1946. /**
  1947. * Unfreeze all materials
  1948. * A frozen material will not be updatable but should be faster to render
  1949. */
  1950. unfreezeMaterials(): void;
  1951. /**
  1952. * Releases all held resources
  1953. */
  1954. dispose(): void;
  1955. private _disposeList;
  1956. /**
  1957. * Gets if the scene is already disposed
  1958. */
  1959. get isDisposed(): boolean;
  1960. /**
  1961. * Call this function to reduce memory footprint of the scene.
  1962. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  1963. */
  1964. clearCachedVertexData(): void;
  1965. /**
  1966. * This function will remove the local cached buffer data from texture.
  1967. * It will save memory but will prevent the texture from being rebuilt
  1968. */
  1969. cleanCachedTextureBuffer(): void;
  1970. /**
  1971. * Get the world extend vectors with an optional filter
  1972. *
  1973. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  1974. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  1975. */
  1976. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  1977. min: Vector3;
  1978. max: Vector3;
  1979. };
  1980. /**
  1981. * Creates a ray that can be used to pick in the scene
  1982. * @param x defines the x coordinate of the origin (on-screen)
  1983. * @param y defines the y coordinate of the origin (on-screen)
  1984. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  1985. * @param camera defines the camera to use for the picking
  1986. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  1987. * @returns a Ray
  1988. */
  1989. createPickingRay(x: number, y: number, world: Nullable<Matrix>, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  1990. /**
  1991. * Creates a ray that can be used to pick in the scene
  1992. * @param x defines the x coordinate of the origin (on-screen)
  1993. * @param y defines the y coordinate of the origin (on-screen)
  1994. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  1995. * @param result defines the ray where to store the picking ray
  1996. * @param camera defines the camera to use for the picking
  1997. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  1998. * @param enableDistantPicking defines if picking should handle large values for mesh position/scaling (false by default)
  1999. * @returns the current scene
  2000. */
  2001. createPickingRayToRef(x: number, y: number, world: Nullable<Matrix>, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean, enableDistantPicking?: boolean): Scene;
  2002. /**
  2003. * Creates a ray that can be used to pick in the scene
  2004. * @param x defines the x coordinate of the origin (on-screen)
  2005. * @param y defines the y coordinate of the origin (on-screen)
  2006. * @param camera defines the camera to use for the picking
  2007. * @returns a Ray
  2008. */
  2009. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  2010. /**
  2011. * Creates a ray that can be used to pick in the scene
  2012. * @param x defines the x coordinate of the origin (on-screen)
  2013. * @param y defines the y coordinate of the origin (on-screen)
  2014. * @param result defines the ray where to store the picking ray
  2015. * @param camera defines the camera to use for the picking
  2016. * @returns the current scene
  2017. */
  2018. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  2019. /** @internal */
  2020. get _pickingAvailable(): boolean;
  2021. /** @internal */
  2022. _registeredActions: number;
  2023. /** Launch a ray to try to pick a mesh in the scene
  2024. * @param x position on screen
  2025. * @param y position on screen
  2026. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2027. * @param fastCheck defines if the first intersection will be used (and not the closest)
  2028. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2029. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  2030. * @returns a PickingInfo
  2031. */
  2032. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  2033. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  2034. * @param x position on screen
  2035. * @param y position on screen
  2036. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2037. * @param fastCheck defines if the first intersection will be used (and not the closest)
  2038. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2039. * @returns a PickingInfo (Please note that some info will not be set like distance, bv, bu and everything that cannot be capture by only using bounding infos)
  2040. */
  2041. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  2042. /**
  2043. * Use the given ray to pick a mesh in the scene. A mesh triangle can be picked both from its front and back sides,
  2044. * irrespective of orientation.
  2045. * @param ray The ray to use to pick meshes
  2046. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  2047. * @param fastCheck defines if the first intersection will be used (and not the closest)
  2048. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  2049. * @returns a PickingInfo
  2050. */
  2051. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  2052. /**
  2053. * Launch a ray to try to pick a mesh in the scene. A mesh triangle can be picked both from its front and back sides,
  2054. * irrespective of orientation.
  2055. * @param x X position on screen
  2056. * @param y Y position on screen
  2057. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2058. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  2059. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  2060. * @returns an array of PickingInfo
  2061. */
  2062. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  2063. /**
  2064. * Launch a ray to try to pick a mesh in the scene
  2065. * @param ray Ray to use
  2066. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  2067. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  2068. * @returns an array of PickingInfo
  2069. */
  2070. multiPickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  2071. /**
  2072. * Force the value of meshUnderPointer
  2073. * @param mesh defines the mesh to use
  2074. * @param pointerId optional pointer id when using more than one pointer
  2075. * @param pickResult optional pickingInfo data used to find mesh
  2076. */
  2077. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number, pickResult?: Nullable<PickingInfo>): void;
  2078. /**
  2079. * Gets the mesh under the pointer
  2080. * @returns a Mesh or null if no mesh is under the pointer
  2081. */
  2082. getPointerOverMesh(): Nullable<AbstractMesh>;
  2083. /** @internal */
  2084. _rebuildGeometries(): void;
  2085. /** @internal */
  2086. _rebuildTextures(): void;
  2087. /**
  2088. * Get from a list of objects by tags
  2089. * @param list the list of objects to use
  2090. * @param tagsQuery the query to use
  2091. * @param filter a predicate to filter for tags
  2092. * @returns
  2093. */
  2094. private _getByTags;
  2095. /**
  2096. * Get a list of meshes by tags
  2097. * @param tagsQuery defines the tags query to use
  2098. * @param filter defines a predicate used to filter results
  2099. * @returns an array of Mesh
  2100. */
  2101. getMeshesByTags(tagsQuery: string, filter?: (mesh: AbstractMesh) => boolean): AbstractMesh[];
  2102. /**
  2103. * Get a list of cameras by tags
  2104. * @param tagsQuery defines the tags query to use
  2105. * @param filter defines a predicate used to filter results
  2106. * @returns an array of Camera
  2107. */
  2108. getCamerasByTags(tagsQuery: string, filter?: (camera: Camera) => boolean): Camera[];
  2109. /**
  2110. * Get a list of lights by tags
  2111. * @param tagsQuery defines the tags query to use
  2112. * @param filter defines a predicate used to filter results
  2113. * @returns an array of Light
  2114. */
  2115. getLightsByTags(tagsQuery: string, filter?: (light: Light) => boolean): Light[];
  2116. /**
  2117. * Get a list of materials by tags
  2118. * @param tagsQuery defines the tags query to use
  2119. * @param filter defines a predicate used to filter results
  2120. * @returns an array of Material
  2121. */
  2122. getMaterialByTags(tagsQuery: string, filter?: (material: Material) => boolean): Material[];
  2123. /**
  2124. * Get a list of transform nodes by tags
  2125. * @param tagsQuery defines the tags query to use
  2126. * @param filter defines a predicate used to filter results
  2127. * @returns an array of TransformNode
  2128. */
  2129. getTransformNodesByTags(tagsQuery: string, filter?: (transform: TransformNode) => boolean): TransformNode[];
  2130. /**
  2131. * Overrides the default sort function applied in the rendering group to prepare the meshes.
  2132. * This allowed control for front to back rendering or reversly depending of the special needs.
  2133. *
  2134. * @param renderingGroupId The rendering group id corresponding to its index
  2135. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  2136. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  2137. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  2138. */
  2139. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  2140. /**
  2141. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  2142. *
  2143. * @param renderingGroupId The rendering group id corresponding to its index
  2144. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  2145. * @param depth Automatically clears depth between groups if true and autoClear is true.
  2146. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  2147. */
  2148. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  2149. /**
  2150. * Gets the current auto clear configuration for one rendering group of the rendering
  2151. * manager.
  2152. * @param index the rendering group index to get the information for
  2153. * @returns The auto clear setup for the requested rendering group
  2154. */
  2155. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  2156. private _blockMaterialDirtyMechanism;
  2157. /** @internal */
  2158. _forceBlockMaterialDirtyMechanism(value: boolean): void;
  2159. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  2160. get blockMaterialDirtyMechanism(): boolean;
  2161. set blockMaterialDirtyMechanism(value: boolean);
  2162. /**
  2163. * Will flag all materials as dirty to trigger new shader compilation
  2164. * @param flag defines the flag used to specify which material part must be marked as dirty
  2165. * @param predicate If not null, it will be used to specify if a material has to be marked as dirty
  2166. */
  2167. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  2168. /**
  2169. * @internal
  2170. */
  2171. _loadFile(fileOrUrl: File | string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  2172. _loadFileAsync(fileOrUrl: File | string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: false, onOpened?: (request: WebRequest) => void): Promise<string>;
  2173. _loadFileAsync(fileOrUrl: File | string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: true, onOpened?: (request: WebRequest) => void): Promise<ArrayBuffer>;
  2174. /**
  2175. * @internal
  2176. */
  2177. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  2178. /**
  2179. * @internal
  2180. */
  2181. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  2182. /**
  2183. * @internal
  2184. */
  2185. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  2186. /**
  2187. * @internal
  2188. */
  2189. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  2190. /**
  2191. * Internal perfCollector instance used for sharing between inspector and playground.
  2192. * Marked as protected to allow sharing between prototype extensions, but disallow access at toplevel.
  2193. */
  2194. protected _perfCollector: Nullable<PerformanceViewerCollector>;
  2195. /**
  2196. * This method gets the performance collector belonging to the scene, which is generally shared with the inspector.
  2197. * @returns the perf collector belonging to the scene.
  2198. */
  2199. getPerfCollector(): PerformanceViewerCollector;
  2200. /**
  2201. * Sets the active camera of the scene using its Id
  2202. * @param id defines the camera's Id
  2203. * @returns the new active camera or null if none found.
  2204. * @deprecated Please use setActiveCameraById instead
  2205. */
  2206. setActiveCameraByID(id: string): Nullable<Camera>;
  2207. /**
  2208. * Get a material using its id
  2209. * @param id defines the material's Id
  2210. * @returns the material or null if none found.
  2211. * @deprecated Please use getMaterialById instead
  2212. */
  2213. getMaterialByID(id: string): Nullable<Material>;
  2214. /**
  2215. * Gets a the last added material using a given id
  2216. * @param id defines the material's Id
  2217. * @returns the last material with the given id or null if none found.
  2218. * @deprecated Please use getLastMaterialById instead
  2219. */
  2220. getLastMaterialByID(id: string): Nullable<Material>;
  2221. /**
  2222. * Get a texture using its unique id
  2223. * @param uniqueId defines the texture's unique id
  2224. * @returns the texture or null if none found.
  2225. * @deprecated Please use getTextureByUniqueId instead
  2226. */
  2227. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  2228. /**
  2229. * Gets a camera using its Id
  2230. * @param id defines the Id to look for
  2231. * @returns the camera or null if not found
  2232. * @deprecated Please use getCameraById instead
  2233. */
  2234. getCameraByID(id: string): Nullable<Camera>;
  2235. /**
  2236. * Gets a camera using its unique Id
  2237. * @param uniqueId defines the unique Id to look for
  2238. * @returns the camera or null if not found
  2239. * @deprecated Please use getCameraByUniqueId instead
  2240. */
  2241. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  2242. /**
  2243. * Gets a bone using its Id
  2244. * @param id defines the bone's Id
  2245. * @returns the bone or null if not found
  2246. * @deprecated Please use getBoneById instead
  2247. */
  2248. getBoneByID(id: string): Nullable<Bone>;
  2249. /**
  2250. * Gets a light node using its Id
  2251. * @param id defines the light's Id
  2252. * @returns the light or null if none found.
  2253. * @deprecated Please use getLightById instead
  2254. */
  2255. getLightByID(id: string): Nullable<Light>;
  2256. /**
  2257. * Gets a light node using its scene-generated unique Id
  2258. * @param uniqueId defines the light's unique Id
  2259. * @returns the light or null if none found.
  2260. * @deprecated Please use getLightByUniqueId instead
  2261. */
  2262. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  2263. /**
  2264. * Gets a particle system by Id
  2265. * @param id defines the particle system Id
  2266. * @returns the corresponding system or null if none found
  2267. * @deprecated Please use getParticleSystemById instead
  2268. */
  2269. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  2270. /**
  2271. * Gets a geometry using its Id
  2272. * @param id defines the geometry's Id
  2273. * @returns the geometry or null if none found.
  2274. * @deprecated Please use getGeometryById instead
  2275. */
  2276. getGeometryByID(id: string): Nullable<Geometry>;
  2277. /**
  2278. * Gets the first added mesh found of a given Id
  2279. * @param id defines the Id to search for
  2280. * @returns the mesh found or null if not found at all
  2281. * @deprecated Please use getMeshById instead
  2282. */
  2283. getMeshByID(id: string): Nullable<AbstractMesh>;
  2284. /**
  2285. * Gets a mesh with its auto-generated unique Id
  2286. * @param uniqueId defines the unique Id to search for
  2287. * @returns the found mesh or null if not found at all.
  2288. * @deprecated Please use getMeshByUniqueId instead
  2289. */
  2290. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  2291. /**
  2292. * Gets a the last added mesh using a given Id
  2293. * @param id defines the Id to search for
  2294. * @returns the found mesh or null if not found at all.
  2295. * @deprecated Please use getLastMeshById instead
  2296. */
  2297. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  2298. /**
  2299. * Gets a list of meshes using their Id
  2300. * @param id defines the Id to search for
  2301. * @returns a list of meshes
  2302. * @deprecated Please use getMeshesById instead
  2303. */
  2304. getMeshesByID(id: string): Array<AbstractMesh>;
  2305. /**
  2306. * Gets the first added transform node found of a given Id
  2307. * @param id defines the Id to search for
  2308. * @returns the found transform node or null if not found at all.
  2309. * @deprecated Please use getTransformNodeById instead
  2310. */
  2311. getTransformNodeByID(id: string): Nullable<TransformNode>;
  2312. /**
  2313. * Gets a transform node with its auto-generated unique Id
  2314. * @param uniqueId defines the unique Id to search for
  2315. * @returns the found transform node or null if not found at all.
  2316. * @deprecated Please use getTransformNodeByUniqueId instead
  2317. */
  2318. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  2319. /**
  2320. * Gets a list of transform nodes using their Id
  2321. * @param id defines the Id to search for
  2322. * @returns a list of transform nodes
  2323. * @deprecated Please use getTransformNodesById instead
  2324. */
  2325. getTransformNodesByID(id: string): Array<TransformNode>;
  2326. /**
  2327. * Gets a node (Mesh, Camera, Light) using a given Id
  2328. * @param id defines the Id to search for
  2329. * @returns the found node or null if not found at all
  2330. * @deprecated Please use getNodeById instead
  2331. */
  2332. getNodeByID(id: string): Nullable<Node>;
  2333. /**
  2334. * Gets a the last added node (Mesh, Camera, Light) using a given Id
  2335. * @param id defines the Id to search for
  2336. * @returns the found node or null if not found at all
  2337. * @deprecated Please use getLastEntryById instead
  2338. */
  2339. getLastEntryByID(id: string): Nullable<Node>;
  2340. /**
  2341. * Gets a skeleton using a given Id (if many are found, this function will pick the last one)
  2342. * @param id defines the Id to search for
  2343. * @returns the found skeleton or null if not found at all.
  2344. * @deprecated Please use getLastSkeletonById instead
  2345. */
  2346. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  2347. }