babylon.scene.js 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385
  1. var BABYLON;
  2. (function (BABYLON) {
  3. var Scene = (function () {
  4. // Constructor
  5. function Scene(engine) {
  6. // Members
  7. this.autoClear = true;
  8. this.clearColor = new BABYLON.Color3(0.2, 0.2, 0.3);
  9. this.ambientColor = new BABYLON.Color3(0, 0, 0);
  10. this.forceWireframe = false;
  11. this.cameraToUseForPointers = null;
  12. // Fog
  13. this.fogMode = BABYLON.Scene.FOGMODE_NONE;
  14. this.fogColor = new BABYLON.Color3(0.2, 0.2, 0.3);
  15. this.fogDensity = 0.1;
  16. this.fogStart = 0;
  17. this.fogEnd = 1000.0;
  18. // Lights
  19. this.lightsEnabled = true;
  20. this.lights = new Array();
  21. // Cameras
  22. this.cameras = new Array();
  23. this.activeCameras = new Array();
  24. // Meshes
  25. this.meshes = new Array();
  26. // Geometries
  27. this._geometries = new Array();
  28. this.materials = new Array();
  29. this.multiMaterials = new Array();
  30. this.defaultMaterial = new BABYLON.StandardMaterial("default material", this);
  31. // Textures
  32. this.texturesEnabled = true;
  33. this.textures = new Array();
  34. // Particles
  35. this.particlesEnabled = true;
  36. this.particleSystems = new Array();
  37. // Sprites
  38. this.spriteManagers = new Array();
  39. // Layers
  40. this.layers = new Array();
  41. // Skeletons
  42. this.skeletons = new Array();
  43. // Lens flares
  44. this.lensFlareSystems = new Array();
  45. // Collisions
  46. this.collisionsEnabled = true;
  47. this.gravity = new BABYLON.Vector3(0, -9.0, 0);
  48. // Postprocesses
  49. this.postProcessesEnabled = true;
  50. // Customs render targets
  51. this.renderTargetsEnabled = true;
  52. this.customRenderTargets = new Array();
  53. // Imported meshes
  54. this.importedMeshesFiles = new Array();
  55. this._actionManagers = new Array();
  56. this._meshesForIntersections = new BABYLON.SmartArray(256);
  57. this._totalVertices = 0;
  58. this._activeVertices = 0;
  59. this._activeParticles = 0;
  60. this._lastFrameDuration = 0;
  61. this._evaluateActiveMeshesDuration = 0;
  62. this._renderTargetsDuration = 0;
  63. this._particlesDuration = 0;
  64. this._renderDuration = 0;
  65. this._spritesDuration = 0;
  66. this._animationRatio = 0;
  67. this._renderId = 0;
  68. this._executeWhenReadyTimeoutId = -1;
  69. this._toBeDisposed = new BABYLON.SmartArray(256);
  70. this._onReadyCallbacks = new Array();
  71. this._pendingData = [];
  72. this._onBeforeRenderCallbacks = new Array();
  73. this._activeMeshes = new BABYLON.SmartArray(256);
  74. this._processedMaterials = new BABYLON.SmartArray(256);
  75. this._renderTargets = new BABYLON.SmartArray(256);
  76. this._activeParticleSystems = new BABYLON.SmartArray(256);
  77. this._activeSkeletons = new BABYLON.SmartArray(32);
  78. this._activeAnimatables = new Array();
  79. this._transformMatrix = BABYLON.Matrix.Zero();
  80. this._scaledPosition = BABYLON.Vector3.Zero();
  81. this._scaledVelocity = BABYLON.Vector3.Zero();
  82. this._engine = engine;
  83. engine.scenes.push(this);
  84. this._renderingManager = new BABYLON.RenderingManager(this);
  85. this.postProcessManager = new BABYLON.PostProcessManager(this);
  86. this.postProcessRenderPipelineManager = new BABYLON.PostProcessRenderPipelineManager();
  87. this._boundingBoxRenderer = new BABYLON.BoundingBoxRenderer(this);
  88. this.attachControl();
  89. }
  90. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  91. // Properties
  92. get: function () {
  93. return this._meshUnderPointer;
  94. },
  95. enumerable: true,
  96. configurable: true
  97. });
  98. Object.defineProperty(Scene.prototype, "pointerX", {
  99. get: function () {
  100. return this._pointerX;
  101. },
  102. enumerable: true,
  103. configurable: true
  104. });
  105. Object.defineProperty(Scene.prototype, "pointerY", {
  106. get: function () {
  107. return this._pointerY;
  108. },
  109. enumerable: true,
  110. configurable: true
  111. });
  112. Scene.prototype.getBoundingBoxRenderer = function () {
  113. return this._boundingBoxRenderer;
  114. };
  115. Scene.prototype.getEngine = function () {
  116. return this._engine;
  117. };
  118. Scene.prototype.getTotalVertices = function () {
  119. return this._totalVertices;
  120. };
  121. Scene.prototype.getActiveVertices = function () {
  122. return this._activeVertices;
  123. };
  124. Scene.prototype.getActiveParticles = function () {
  125. return this._activeParticles;
  126. };
  127. // Stats
  128. Scene.prototype.getLastFrameDuration = function () {
  129. return this._lastFrameDuration;
  130. };
  131. Scene.prototype.getEvaluateActiveMeshesDuration = function () {
  132. return this._evaluateActiveMeshesDuration;
  133. };
  134. Scene.prototype.getActiveMeshes = function () {
  135. return this._activeMeshes;
  136. };
  137. Scene.prototype.getRenderTargetsDuration = function () {
  138. return this._renderTargetsDuration;
  139. };
  140. Scene.prototype.getRenderDuration = function () {
  141. return this._renderDuration;
  142. };
  143. Scene.prototype.getParticlesDuration = function () {
  144. return this._particlesDuration;
  145. };
  146. Scene.prototype.getSpritesDuration = function () {
  147. return this._spritesDuration;
  148. };
  149. Scene.prototype.getAnimationRatio = function () {
  150. return this._animationRatio;
  151. };
  152. Scene.prototype.getRenderId = function () {
  153. return this._renderId;
  154. };
  155. Scene.prototype._updatePointerPosition = function (evt) {
  156. var canvasRect = this._engine.getRenderingCanvasClientRect();
  157. this._pointerX = evt.clientX - canvasRect.left;
  158. this._pointerY = evt.clientY - canvasRect.top;
  159. if (this.cameraToUseForPointers) {
  160. this._pointerX = this._pointerX - this.cameraToUseForPointers.viewport.x * this._engine.getRenderWidth();
  161. this._pointerY = this._pointerY - this.cameraToUseForPointers.viewport.y * this._engine.getRenderHeight();
  162. }
  163. };
  164. // Pointers handling
  165. Scene.prototype.attachControl = function () {
  166. var _this = this;
  167. this._onPointerMove = function (evt) {
  168. var canvas = _this._engine.getRenderingCanvas();
  169. _this._updatePointerPosition(evt);
  170. var pickResult = _this.pick(_this._pointerX, _this._pointerY, function (mesh) {
  171. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasPointerTriggers;
  172. }, false, _this.cameraToUseForPointers);
  173. if (pickResult.hit) {
  174. _this.setPointerOverMesh(pickResult.pickedMesh);
  175. canvas.style.cursor = "pointer";
  176. _this._meshUnderPointer = pickResult.pickedMesh;
  177. } else {
  178. _this.setPointerOverMesh(null);
  179. canvas.style.cursor = "";
  180. _this._meshUnderPointer = null;
  181. }
  182. };
  183. this._onPointerDown = function (evt) {
  184. var predicate = null;
  185. if (!_this.onPointerDown) {
  186. predicate = function (mesh) {
  187. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasPickTriggers;
  188. };
  189. }
  190. _this._updatePointerPosition(evt);
  191. var pickResult = _this.pick(_this._pointerX, _this._pointerY, predicate, false, _this.cameraToUseForPointers);
  192. if (pickResult.hit) {
  193. if (pickResult.pickedMesh.actionManager) {
  194. switch (evt.button) {
  195. case 0:
  196. pickResult.pickedMesh.actionManager.processTrigger(BABYLON.ActionManager.OnLeftPickTrigger, BABYLON.ActionEvent.CreateNew(pickResult.pickedMesh));
  197. break;
  198. case 1:
  199. pickResult.pickedMesh.actionManager.processTrigger(BABYLON.ActionManager.OnCenterPickTrigger, BABYLON.ActionEvent.CreateNew(pickResult.pickedMesh));
  200. break;
  201. case 2:
  202. pickResult.pickedMesh.actionManager.processTrigger(BABYLON.ActionManager.OnRightPickTrigger, BABYLON.ActionEvent.CreateNew(pickResult.pickedMesh));
  203. break;
  204. }
  205. pickResult.pickedMesh.actionManager.processTrigger(BABYLON.ActionManager.OnPickTrigger, BABYLON.ActionEvent.CreateNew(pickResult.pickedMesh));
  206. }
  207. }
  208. if (_this.onPointerDown) {
  209. _this.onPointerDown(evt, pickResult);
  210. }
  211. };
  212. this._onKeyDown = function (evt) {
  213. if (_this.actionManager) {
  214. _this.actionManager.processTrigger(BABYLON.ActionManager.OnKeyDownTrigger, BABYLON.ActionEvent.CreateNewFromScene(_this, evt));
  215. }
  216. };
  217. this._onKeyUp = function (evt) {
  218. if (_this.actionManager) {
  219. _this.actionManager.processTrigger(BABYLON.ActionManager.OnKeyUpTrigger, BABYLON.ActionEvent.CreateNewFromScene(_this, evt));
  220. }
  221. };
  222. var eventPrefix = BABYLON.Tools.GetPointerPrefix();
  223. this._engine.getRenderingCanvas().addEventListener(eventPrefix + "move", this._onPointerMove, false);
  224. this._engine.getRenderingCanvas().addEventListener(eventPrefix + "down", this._onPointerDown, false);
  225. window.addEventListener("keydown", this._onKeyDown, false);
  226. window.addEventListener("keyup", this._onKeyUp, false);
  227. };
  228. Scene.prototype.detachControl = function () {
  229. var eventPrefix = BABYLON.Tools.GetPointerPrefix();
  230. this._engine.getRenderingCanvas().removeEventListener(eventPrefix + "move", this._onPointerMove);
  231. this._engine.getRenderingCanvas().removeEventListener(eventPrefix + "down", this._onPointerDown);
  232. window.removeEventListener("keydown", this._onKeyDown);
  233. window.removeEventListener("keyup", this._onKeyUp);
  234. };
  235. // Ready
  236. Scene.prototype.isReady = function () {
  237. if (this._pendingData.length > 0) {
  238. return false;
  239. }
  240. for (var index = 0; index < this._geometries.length; index++) {
  241. var geometry = this._geometries[index];
  242. if (geometry.delayLoadState === BABYLON.Engine.DELAYLOADSTATE_LOADING) {
  243. return false;
  244. }
  245. }
  246. for (index = 0; index < this.meshes.length; index++) {
  247. var mesh = this.meshes[index];
  248. if (!mesh.isReady()) {
  249. return false;
  250. }
  251. var mat = mesh.material;
  252. if (mat) {
  253. if (!mat.isReady(mesh)) {
  254. return false;
  255. }
  256. }
  257. }
  258. return true;
  259. };
  260. Scene.prototype.registerBeforeRender = function (func) {
  261. this._onBeforeRenderCallbacks.push(func);
  262. };
  263. Scene.prototype.unregisterBeforeRender = function (func) {
  264. var index = this._onBeforeRenderCallbacks.indexOf(func);
  265. if (index > -1) {
  266. this._onBeforeRenderCallbacks.splice(index, 1);
  267. }
  268. };
  269. Scene.prototype._addPendingData = function (data) {
  270. this._pendingData.push(data);
  271. };
  272. Scene.prototype._removePendingData = function (data) {
  273. var index = this._pendingData.indexOf(data);
  274. if (index !== -1) {
  275. this._pendingData.splice(index, 1);
  276. }
  277. };
  278. Scene.prototype.getWaitingItemsCount = function () {
  279. return this._pendingData.length;
  280. };
  281. Scene.prototype.executeWhenReady = function (func) {
  282. var _this = this;
  283. this._onReadyCallbacks.push(func);
  284. if (this._executeWhenReadyTimeoutId !== -1) {
  285. return;
  286. }
  287. this._executeWhenReadyTimeoutId = setTimeout(function () {
  288. _this._checkIsReady();
  289. }, 150);
  290. };
  291. Scene.prototype._checkIsReady = function () {
  292. var _this = this;
  293. if (this.isReady()) {
  294. this._onReadyCallbacks.forEach(function (func) {
  295. func();
  296. });
  297. this._onReadyCallbacks = [];
  298. this._executeWhenReadyTimeoutId = -1;
  299. return;
  300. }
  301. this._executeWhenReadyTimeoutId = setTimeout(function () {
  302. _this._checkIsReady();
  303. }, 150);
  304. };
  305. // Animations
  306. Scene.prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable) {
  307. if (speedRatio === undefined) {
  308. speedRatio = 1.0;
  309. }
  310. this.stopAnimation(target);
  311. if (!animatable) {
  312. animatable = new BABYLON.Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd);
  313. }
  314. // Local animations
  315. if (target.animations) {
  316. animatable.appendAnimations(target, target.animations);
  317. }
  318. // Children animations
  319. if (target.getAnimatables) {
  320. var animatables = target.getAnimatables();
  321. for (var index = 0; index < animatables.length; index++) {
  322. this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable);
  323. }
  324. }
  325. return animatable;
  326. };
  327. Scene.prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd) {
  328. if (speedRatio === undefined) {
  329. speedRatio = 1.0;
  330. }
  331. var animatable = new BABYLON.Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, animations);
  332. return animatable;
  333. };
  334. Scene.prototype.getAnimatableByTarget = function (target) {
  335. for (var index = 0; index < this._activeAnimatables.length; index++) {
  336. if (this._activeAnimatables[index].target === target) {
  337. return this._activeAnimatables[index];
  338. }
  339. }
  340. return null;
  341. };
  342. Scene.prototype.stopAnimation = function (target) {
  343. var animatable = this.getAnimatableByTarget(target);
  344. if (animatable) {
  345. animatable.stop();
  346. }
  347. };
  348. Scene.prototype._animate = function () {
  349. if (!this._animationStartDate) {
  350. this._animationStartDate = new Date().getTime();
  351. }
  352. // Getting time
  353. var now = new Date().getTime();
  354. var delay = now - this._animationStartDate;
  355. for (var index = 0; index < this._activeAnimatables.length; index++) {
  356. if (!this._activeAnimatables[index]._animate(delay)) {
  357. this._activeAnimatables.splice(index, 1);
  358. index--;
  359. }
  360. }
  361. };
  362. // Matrix
  363. Scene.prototype.getViewMatrix = function () {
  364. return this._viewMatrix;
  365. };
  366. Scene.prototype.getProjectionMatrix = function () {
  367. return this._projectionMatrix;
  368. };
  369. Scene.prototype.getTransformMatrix = function () {
  370. return this._transformMatrix;
  371. };
  372. Scene.prototype.setTransformMatrix = function (view, projection) {
  373. this._viewMatrix = view;
  374. this._projectionMatrix = projection;
  375. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  376. };
  377. // Methods
  378. Scene.prototype.setActiveCameraByID = function (id) {
  379. var camera = this.getCameraByID(id);
  380. if (camera) {
  381. this.activeCamera = camera;
  382. return camera;
  383. }
  384. return null;
  385. };
  386. Scene.prototype.setActiveCameraByName = function (name) {
  387. var camera = this.getCameraByName(name);
  388. if (camera) {
  389. this.activeCamera = camera;
  390. return camera;
  391. }
  392. return null;
  393. };
  394. Scene.prototype.getMaterialByID = function (id) {
  395. for (var index = 0; index < this.materials.length; index++) {
  396. if (this.materials[index].id === id) {
  397. return this.materials[index];
  398. }
  399. }
  400. return null;
  401. };
  402. Scene.prototype.getMaterialByName = function (name) {
  403. for (var index = 0; index < this.materials.length; index++) {
  404. if (this.materials[index].name === name) {
  405. return this.materials[index];
  406. }
  407. }
  408. return null;
  409. };
  410. Scene.prototype.getCameraByID = function (id) {
  411. for (var index = 0; index < this.cameras.length; index++) {
  412. if (this.cameras[index].id === id) {
  413. return this.cameras[index];
  414. }
  415. }
  416. return null;
  417. };
  418. Scene.prototype.getCameraByName = function (name) {
  419. for (var index = 0; index < this.cameras.length; index++) {
  420. if (this.cameras[index].name === name) {
  421. return this.cameras[index];
  422. }
  423. }
  424. return null;
  425. };
  426. Scene.prototype.getLightByName = function (name) {
  427. for (var index = 0; index < this.lights.length; index++) {
  428. if (this.lights[index].name === name) {
  429. return this.lights[index];
  430. }
  431. }
  432. return null;
  433. };
  434. Scene.prototype.getLightByID = function (id) {
  435. for (var index = 0; index < this.lights.length; index++) {
  436. if (this.lights[index].id === id) {
  437. return this.lights[index];
  438. }
  439. }
  440. return null;
  441. };
  442. Scene.prototype.getGeometryByID = function (id) {
  443. for (var index = 0; index < this._geometries.length; index++) {
  444. if (this._geometries[index].id === id) {
  445. return this._geometries[index];
  446. }
  447. }
  448. return null;
  449. };
  450. Scene.prototype.pushGeometry = function (geometry, force) {
  451. if (!force && this.getGeometryByID(geometry.id)) {
  452. return false;
  453. }
  454. this._geometries.push(geometry);
  455. return true;
  456. };
  457. Scene.prototype.getGeometries = function () {
  458. return this._geometries;
  459. };
  460. Scene.prototype.getMeshByID = function (id) {
  461. for (var index = 0; index < this.meshes.length; index++) {
  462. if (this.meshes[index].id === id) {
  463. return this.meshes[index];
  464. }
  465. }
  466. return null;
  467. };
  468. Scene.prototype.getLastMeshByID = function (id) {
  469. for (var index = this.meshes.length - 1; index >= 0; index--) {
  470. if (this.meshes[index].id === id) {
  471. return this.meshes[index];
  472. }
  473. }
  474. return null;
  475. };
  476. Scene.prototype.getLastEntryByID = function (id) {
  477. for (var index = this.meshes.length - 1; index >= 0; index--) {
  478. if (this.meshes[index].id === id) {
  479. return this.meshes[index];
  480. }
  481. }
  482. for (index = this.cameras.length - 1; index >= 0; index--) {
  483. if (this.cameras[index].id === id) {
  484. return this.cameras[index];
  485. }
  486. }
  487. for (index = this.lights.length - 1; index >= 0; index--) {
  488. if (this.lights[index].id === id) {
  489. return this.lights[index];
  490. }
  491. }
  492. return null;
  493. };
  494. Scene.prototype.getMeshByName = function (name) {
  495. for (var index = 0; index < this.meshes.length; index++) {
  496. if (this.meshes[index].name === name) {
  497. return this.meshes[index];
  498. }
  499. }
  500. return null;
  501. };
  502. Scene.prototype.getLastSkeletonByID = function (id) {
  503. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  504. if (this.skeletons[index].id === id) {
  505. return this.skeletons[index];
  506. }
  507. }
  508. return null;
  509. };
  510. Scene.prototype.getSkeletonById = function (id) {
  511. for (var index = 0; index < this.skeletons.length; index++) {
  512. if (this.skeletons[index].id === id) {
  513. return this.skeletons[index];
  514. }
  515. }
  516. return null;
  517. };
  518. Scene.prototype.getSkeletonByName = function (name) {
  519. for (var index = 0; index < this.skeletons.length; index++) {
  520. if (this.skeletons[index].name === name) {
  521. return this.skeletons[index];
  522. }
  523. }
  524. return null;
  525. };
  526. Scene.prototype.isActiveMesh = function (mesh) {
  527. return (this._activeMeshes.indexOf(mesh) !== -1);
  528. };
  529. Scene.prototype._evaluateSubMesh = function (subMesh, mesh) {
  530. if (mesh.subMeshes.length == 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  531. var material = subMesh.getMaterial();
  532. if (mesh.showSubMeshesBoundingBox) {
  533. this._boundingBoxRenderer.renderList.push(subMesh.getBoundingInfo().boundingBox);
  534. }
  535. if (material) {
  536. // Render targets
  537. if (material.getRenderTargetTextures) {
  538. if (this._processedMaterials.indexOf(material) === -1) {
  539. this._processedMaterials.push(material);
  540. this._renderTargets.concat(material.getRenderTargetTextures());
  541. }
  542. }
  543. // Dispatch
  544. this._activeVertices += subMesh.verticesCount;
  545. this._renderingManager.dispatch(subMesh);
  546. }
  547. }
  548. };
  549. Scene.prototype._evaluateActiveMeshes = function () {
  550. this._activeMeshes.reset();
  551. this._renderingManager.reset();
  552. this._processedMaterials.reset();
  553. this._activeParticleSystems.reset();
  554. this._activeSkeletons.reset();
  555. this._boundingBoxRenderer.reset();
  556. if (!this._frustumPlanes) {
  557. this._frustumPlanes = BABYLON.Frustum.GetPlanes(this._transformMatrix);
  558. } else {
  559. BABYLON.Frustum.GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  560. }
  561. // Meshes
  562. var meshes;
  563. var len;
  564. if (this._selectionOctree) {
  565. var selection = this._selectionOctree.select(this._frustumPlanes);
  566. meshes = selection.data;
  567. len = selection.length;
  568. } else {
  569. len = this.meshes.length;
  570. meshes = this.meshes;
  571. }
  572. for (var meshIndex = 0; meshIndex < len; meshIndex++) {
  573. var mesh = meshes[meshIndex];
  574. this._totalVertices += mesh.getTotalVertices();
  575. if (!mesh.isReady()) {
  576. continue;
  577. }
  578. mesh.computeWorldMatrix();
  579. mesh._preActivate();
  580. // Intersections
  581. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers([BABYLON.ActionManager.OnIntersectionEnterTrigger, BABYLON.ActionManager.OnIntersectionExitTrigger])) {
  582. this._meshesForIntersections.pushNoDuplicate(mesh);
  583. }
  584. if (mesh.isEnabled() && mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) != 0) && mesh.isInFrustum(this._frustumPlanes)) {
  585. this._activeMeshes.push(mesh);
  586. mesh._activate(this._renderId);
  587. this._activeMesh(mesh);
  588. }
  589. }
  590. // Particle systems
  591. var beforeParticlesDate = new Date().getTime();
  592. if (this.particlesEnabled) {
  593. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  594. var particleSystem = this.particleSystems[particleIndex];
  595. if (!particleSystem.isStarted()) {
  596. continue;
  597. }
  598. if (!particleSystem.emitter.position || (particleSystem.emitter && particleSystem.emitter.isEnabled())) {
  599. this._activeParticleSystems.push(particleSystem);
  600. particleSystem.animate();
  601. }
  602. }
  603. }
  604. this._particlesDuration += new Date().getTime() - beforeParticlesDate;
  605. };
  606. Scene.prototype._activeMesh = function (mesh) {
  607. if (mesh.skeleton) {
  608. this._activeSkeletons.pushNoDuplicate(mesh.skeleton);
  609. }
  610. if (mesh.showBoundingBox) {
  611. this._boundingBoxRenderer.renderList.push(mesh.getBoundingInfo().boundingBox);
  612. }
  613. if (mesh.subMeshes) {
  614. // Submeshes Octrees
  615. var len;
  616. var subMeshes;
  617. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  618. var intersections = mesh._submeshesOctree.select(this._frustumPlanes);
  619. len = intersections.length;
  620. subMeshes = intersections.data;
  621. } else {
  622. subMeshes = mesh.subMeshes;
  623. len = subMeshes.length;
  624. }
  625. for (var subIndex = 0; subIndex < len; subIndex++) {
  626. var subMesh = subMeshes[subIndex];
  627. this._evaluateSubMesh(subMesh, mesh);
  628. }
  629. }
  630. };
  631. Scene.prototype.updateTransformMatrix = function (force) {
  632. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  633. };
  634. Scene.prototype._renderForCamera = function (camera) {
  635. var engine = this._engine;
  636. this.activeCamera = camera;
  637. if (!this.activeCamera)
  638. throw new Error("Active camera not set");
  639. // Viewport
  640. engine.setViewport(this.activeCamera.viewport);
  641. // Camera
  642. this._renderId++;
  643. this.updateTransformMatrix();
  644. if (this.beforeCameraRender) {
  645. this.beforeCameraRender(this.activeCamera);
  646. }
  647. // Meshes
  648. var beforeEvaluateActiveMeshesDate = new Date().getTime();
  649. this._evaluateActiveMeshes();
  650. this._evaluateActiveMeshesDuration += new Date().getTime() - beforeEvaluateActiveMeshesDate;
  651. for (var skeletonIndex = 0; skeletonIndex < this._activeSkeletons.length; skeletonIndex++) {
  652. var skeleton = this._activeSkeletons.data[skeletonIndex];
  653. skeleton.prepare();
  654. }
  655. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  656. var renderTarget = this.customRenderTargets[customIndex];
  657. this._renderTargets.push(renderTarget);
  658. }
  659. // Render targets
  660. var beforeRenderTargetDate = new Date().getTime();
  661. if (this.renderTargetsEnabled) {
  662. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  663. renderTarget = this._renderTargets.data[renderIndex];
  664. if (renderTarget._shouldRender()) {
  665. this._renderId++;
  666. renderTarget.render();
  667. }
  668. }
  669. this._renderId++;
  670. }
  671. if (this._renderTargets.length > 0) {
  672. engine.restoreDefaultFramebuffer();
  673. }
  674. this._renderTargetsDuration = new Date().getTime() - beforeRenderTargetDate;
  675. // Prepare Frame
  676. this.postProcessManager._prepareFrame();
  677. var beforeRenderDate = new Date().getTime();
  678. // Backgrounds
  679. if (this.layers.length) {
  680. engine.setDepthBuffer(false);
  681. var layerIndex;
  682. var layer;
  683. for (layerIndex = 0; layerIndex < this.layers.length; layerIndex++) {
  684. layer = this.layers[layerIndex];
  685. if (layer.isBackground) {
  686. layer.render();
  687. }
  688. }
  689. engine.setDepthBuffer(true);
  690. }
  691. // Render
  692. this._renderingManager.render(null, null, true, true);
  693. // Bounding boxes
  694. this._boundingBoxRenderer.render();
  695. for (var lensFlareSystemIndex = 0; lensFlareSystemIndex < this.lensFlareSystems.length; lensFlareSystemIndex++) {
  696. this.lensFlareSystems[lensFlareSystemIndex].render();
  697. }
  698. // Foregrounds
  699. if (this.layers.length) {
  700. engine.setDepthBuffer(false);
  701. for (layerIndex = 0; layerIndex < this.layers.length; layerIndex++) {
  702. layer = this.layers[layerIndex];
  703. if (!layer.isBackground) {
  704. layer.render();
  705. }
  706. }
  707. engine.setDepthBuffer(true);
  708. }
  709. this._renderDuration += new Date().getTime() - beforeRenderDate;
  710. // Finalize frame
  711. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  712. // Update camera
  713. this.activeCamera._updateFromScene();
  714. // Reset some special arrays
  715. this._renderTargets.reset();
  716. if (this.afterCameraRender) {
  717. this.afterCameraRender(this.activeCamera);
  718. }
  719. };
  720. Scene.prototype._processSubCameras = function (camera) {
  721. if (camera.subCameras.length == 0) {
  722. this._renderForCamera(camera);
  723. return;
  724. }
  725. for (var index = 0; index < camera.subCameras.length; index++) {
  726. this._renderForCamera(camera.subCameras[index]);
  727. }
  728. this.activeCamera = camera;
  729. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  730. // Update camera
  731. this.activeCamera._updateFromScene();
  732. };
  733. Scene.prototype._checkIntersections = function () {
  734. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  735. var sourceMesh = this._meshesForIntersections.data[index];
  736. for (var actionIndex = 0; actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  737. var action = sourceMesh.actionManager.actions[actionIndex];
  738. if (action.trigger == BABYLON.ActionManager.OnIntersectionEnterTrigger || action.trigger == BABYLON.ActionManager.OnIntersectionExitTrigger) {
  739. var otherMesh = action.getTriggerParameter();
  740. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, false);
  741. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  742. if (areIntersecting && currentIntersectionInProgress === -1 && action.trigger == BABYLON.ActionManager.OnIntersectionEnterTrigger) {
  743. sourceMesh.actionManager.processTrigger(BABYLON.ActionManager.OnIntersectionEnterTrigger, BABYLON.ActionEvent.CreateNew(sourceMesh));
  744. sourceMesh._intersectionsInProgress.push(otherMesh);
  745. } else if (!areIntersecting && currentIntersectionInProgress > -1 && action.trigger == BABYLON.ActionManager.OnIntersectionExitTrigger) {
  746. sourceMesh.actionManager.processTrigger(BABYLON.ActionManager.OnIntersectionExitTrigger, BABYLON.ActionEvent.CreateNew(sourceMesh));
  747. var indexOfOther = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  748. if (indexOfOther > -1) {
  749. sourceMesh._intersectionsInProgress.splice(indexOfOther, 1);
  750. }
  751. }
  752. }
  753. }
  754. }
  755. };
  756. Scene.prototype.render = function () {
  757. var startDate = new Date().getTime();
  758. this._particlesDuration = 0;
  759. this._spritesDuration = 0;
  760. this._activeParticles = 0;
  761. this._renderDuration = 0;
  762. this._evaluateActiveMeshesDuration = 0;
  763. this._totalVertices = 0;
  764. this._activeVertices = 0;
  765. this._meshesForIntersections.reset();
  766. // Actions
  767. if (this.actionManager) {
  768. this.actionManager.processTrigger(BABYLON.ActionManager.OnEveryFrameTrigger, null);
  769. }
  770. // Before render
  771. if (this.beforeRender) {
  772. this.beforeRender();
  773. }
  774. for (var callbackIndex = 0; callbackIndex < this._onBeforeRenderCallbacks.length; callbackIndex++) {
  775. this._onBeforeRenderCallbacks[callbackIndex]();
  776. }
  777. // Animations
  778. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(BABYLON.Tools.GetDeltaTime(), Scene.MaxDeltaTime));
  779. this._animationRatio = deltaTime * (60.0 / 1000.0);
  780. this._animate();
  781. // Physics
  782. if (this._physicsEngine) {
  783. this._physicsEngine._runOneStep(deltaTime / 1000.0);
  784. }
  785. // Clear
  786. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe, true);
  787. for (var lightIndex = 0; lightIndex < this.lights.length; lightIndex++) {
  788. var light = this.lights[lightIndex];
  789. var shadowGenerator = light.getShadowGenerator();
  790. if (light.isEnabled() && shadowGenerator && shadowGenerator.getShadowMap().getScene().textures.indexOf(shadowGenerator.getShadowMap()) !== -1) {
  791. this._renderTargets.push(shadowGenerator.getShadowMap());
  792. }
  793. }
  794. // RenderPipeline
  795. this.postProcessRenderPipelineManager.update();
  796. // Multi-cameras?
  797. if (this.activeCameras.length > 0) {
  798. var currentRenderId = this._renderId;
  799. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  800. this._renderId = currentRenderId;
  801. this._processSubCameras(this.activeCameras[cameraIndex]);
  802. }
  803. } else {
  804. this._processSubCameras(this.activeCamera);
  805. }
  806. // Intersection checks
  807. this._checkIntersections();
  808. // After render
  809. if (this.afterRender) {
  810. this.afterRender();
  811. }
  812. for (var index = 0; index < this._toBeDisposed.length; index++) {
  813. this._toBeDisposed.data[index].dispose();
  814. this._toBeDisposed[index] = null;
  815. }
  816. this._toBeDisposed.reset();
  817. this._lastFrameDuration = new Date().getTime() - startDate;
  818. };
  819. Scene.prototype.dispose = function () {
  820. this.beforeRender = null;
  821. this.afterRender = null;
  822. this.skeletons = [];
  823. this._boundingBoxRenderer.dispose();
  824. // Events
  825. if (this.onDispose) {
  826. this.onDispose();
  827. }
  828. this.detachControl();
  829. // Detach cameras
  830. var canvas = this._engine.getRenderingCanvas();
  831. var index;
  832. for (index = 0; index < this.cameras.length; index++) {
  833. this.cameras[index].detachControl(canvas);
  834. }
  835. while (this.lights.length) {
  836. this.lights[0].dispose();
  837. }
  838. while (this.meshes.length) {
  839. this.meshes[0].dispose(true);
  840. }
  841. while (this.cameras.length) {
  842. this.cameras[0].dispose();
  843. }
  844. while (this.materials.length) {
  845. this.materials[0].dispose();
  846. }
  847. while (this.particleSystems.length) {
  848. this.particleSystems[0].dispose();
  849. }
  850. while (this.spriteManagers.length) {
  851. this.spriteManagers[0].dispose();
  852. }
  853. while (this.layers.length) {
  854. this.layers[0].dispose();
  855. }
  856. while (this.textures.length) {
  857. this.textures[0].dispose();
  858. }
  859. // Post-processes
  860. this.postProcessManager.dispose();
  861. // Physics
  862. if (this._physicsEngine) {
  863. this.disablePhysicsEngine();
  864. }
  865. // Remove from engine
  866. index = this._engine.scenes.indexOf(this);
  867. this._engine.scenes.splice(index, 1);
  868. this._engine.wipeCaches();
  869. };
  870. // Collisions
  871. Scene.prototype._getNewPosition = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  872. if (typeof excludedMesh === "undefined") { excludedMesh = null; }
  873. position.divideToRef(collider.radius, this._scaledPosition);
  874. velocity.divideToRef(collider.radius, this._scaledVelocity);
  875. collider.retry = 0;
  876. collider.initialVelocity = this._scaledVelocity;
  877. collider.initialPosition = this._scaledPosition;
  878. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, finalPosition, excludedMesh);
  879. finalPosition.multiplyInPlace(collider.radius);
  880. };
  881. Scene.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  882. if (typeof excludedMesh === "undefined") { excludedMesh = null; }
  883. var closeDistance = BABYLON.Engine.CollisionsEpsilon * 10.0;
  884. if (collider.retry >= maximumRetry) {
  885. finalPosition.copyFrom(position);
  886. return;
  887. }
  888. collider._initialize(position, velocity, closeDistance);
  889. for (var index = 0; index < this.meshes.length; index++) {
  890. var mesh = this.meshes[index];
  891. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh) {
  892. mesh._checkCollision(collider);
  893. }
  894. }
  895. if (!collider.collisionFound) {
  896. position.addToRef(velocity, finalPosition);
  897. return;
  898. }
  899. if (velocity.x != 0 || velocity.y != 0 || velocity.z != 0) {
  900. collider._getResponse(position, velocity);
  901. }
  902. if (velocity.length() <= closeDistance) {
  903. finalPosition.copyFrom(position);
  904. return;
  905. }
  906. collider.retry++;
  907. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  908. };
  909. // Octrees
  910. Scene.prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  911. if (typeof maxCapacity === "undefined") { maxCapacity = 64; }
  912. if (typeof maxDepth === "undefined") { maxDepth = 2; }
  913. if (!this._selectionOctree) {
  914. this._selectionOctree = new BABYLON.Octree(BABYLON.Octree.CreationFuncForMeshes, maxCapacity, maxDepth);
  915. }
  916. var min = new BABYLON.Vector3(Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  917. var max = new BABYLON.Vector3(-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  918. for (var index = 0; index < this.meshes.length; index++) {
  919. var mesh = this.meshes[index];
  920. mesh.computeWorldMatrix(true);
  921. var minBox = mesh.getBoundingInfo().boundingBox.minimumWorld;
  922. var maxBox = mesh.getBoundingInfo().boundingBox.maximumWorld;
  923. BABYLON.Tools.CheckExtends(minBox, min, max);
  924. BABYLON.Tools.CheckExtends(maxBox, min, max);
  925. }
  926. // Update octree
  927. this._selectionOctree.update(min, max, this.meshes);
  928. return this._selectionOctree;
  929. };
  930. // Picking
  931. Scene.prototype.createPickingRay = function (x, y, world, camera) {
  932. var engine = this._engine;
  933. if (!camera) {
  934. if (!this.activeCamera)
  935. throw new Error("Active camera not set");
  936. camera = this.activeCamera;
  937. }
  938. var cameraViewport = camera.viewport;
  939. var viewport = cameraViewport.toGlobal(engine);
  940. // Moving coordinates to local viewport world
  941. x = x / this._engine.getHardwareScalingLevel() - viewport.x;
  942. y = y / this._engine.getHardwareScalingLevel() - (this._engine.getRenderHeight() - viewport.y - viewport.height);
  943. return BABYLON.Ray.CreateNew(x / window.devicePixelRatio, y / window.devicePixelRatio, viewport.width, viewport.height, world ? world : BABYLON.Matrix.Identity(), camera.getViewMatrix(), camera.getProjectionMatrix());
  944. };
  945. Scene.prototype._internalPick = function (rayFunction, predicate, fastCheck) {
  946. var pickingInfo = null;
  947. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  948. var mesh = this.meshes[meshIndex];
  949. if (predicate) {
  950. if (!predicate(mesh)) {
  951. continue;
  952. }
  953. } else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  954. continue;
  955. }
  956. var world = mesh.getWorldMatrix();
  957. var ray = rayFunction(world);
  958. var result = mesh.intersects(ray, fastCheck);
  959. if (!result || !result.hit)
  960. continue;
  961. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance)
  962. continue;
  963. pickingInfo = result;
  964. if (fastCheck) {
  965. break;
  966. }
  967. }
  968. return pickingInfo || new BABYLON.PickingInfo();
  969. };
  970. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera) {
  971. var _this = this;
  972. /// <summary>Launch a ray to try to pick a mesh in the scene</summary>
  973. /// <param name="x">X position on screen</param>
  974. /// <param name="y">Y position on screen</param>
  975. /// <param name="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</param>
  976. /// <param name="fastCheck">Launch a fast check only using the bounding boxes. Can be set to null.</param>
  977. /// <param name="camera">camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used</param>
  978. return this._internalPick(function (world) {
  979. return _this.createPickingRay(x, y, world, camera);
  980. }, predicate, fastCheck);
  981. };
  982. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck) {
  983. var _this = this;
  984. return this._internalPick(function (world) {
  985. if (!_this._pickWithRayInverseMatrix) {
  986. _this._pickWithRayInverseMatrix = BABYLON.Matrix.Identity();
  987. }
  988. world.invertToRef(_this._pickWithRayInverseMatrix);
  989. return BABYLON.Ray.Transform(ray, _this._pickWithRayInverseMatrix);
  990. }, predicate, fastCheck);
  991. };
  992. Scene.prototype.setPointerOverMesh = function (mesh) {
  993. if (this._pointerOverMesh === mesh) {
  994. return;
  995. }
  996. if (this._pointerOverMesh && this._pointerOverMesh.actionManager) {
  997. this._pointerOverMesh.actionManager.processTrigger(BABYLON.ActionManager.OnPointerOutTrigger, BABYLON.ActionEvent.CreateNew(this._pointerOverMesh));
  998. }
  999. this._pointerOverMesh = mesh;
  1000. if (this._pointerOverMesh && this._pointerOverMesh.actionManager) {
  1001. this._pointerOverMesh.actionManager.processTrigger(BABYLON.ActionManager.OnPointerOverTrigger, BABYLON.ActionEvent.CreateNew(this._pointerOverMesh));
  1002. }
  1003. };
  1004. Scene.prototype.getPointerOverMesh = function () {
  1005. return this._pointerOverMesh;
  1006. };
  1007. // Physics
  1008. Scene.prototype.getPhysicsEngine = function () {
  1009. return this._physicsEngine;
  1010. };
  1011. Scene.prototype.enablePhysics = function (gravity, plugin) {
  1012. if (this._physicsEngine) {
  1013. return true;
  1014. }
  1015. this._physicsEngine = new BABYLON.PhysicsEngine(plugin);
  1016. if (!this._physicsEngine.isSupported()) {
  1017. this._physicsEngine = null;
  1018. return false;
  1019. }
  1020. this._physicsEngine._initialize(gravity);
  1021. return true;
  1022. };
  1023. Scene.prototype.disablePhysicsEngine = function () {
  1024. if (!this._physicsEngine) {
  1025. return;
  1026. }
  1027. this._physicsEngine.dispose();
  1028. this._physicsEngine = undefined;
  1029. };
  1030. Scene.prototype.isPhysicsEnabled = function () {
  1031. return this._physicsEngine !== undefined;
  1032. };
  1033. Scene.prototype.setGravity = function (gravity) {
  1034. if (!this._physicsEngine) {
  1035. return;
  1036. }
  1037. this._physicsEngine._setGravity(gravity);
  1038. };
  1039. Scene.prototype.createCompoundImpostor = function (parts, options) {
  1040. if (parts.parts) {
  1041. options = parts;
  1042. parts = parts.parts;
  1043. }
  1044. if (!this._physicsEngine) {
  1045. return null;
  1046. }
  1047. for (var index = 0; index < parts.length; index++) {
  1048. var mesh = parts[index].mesh;
  1049. mesh._physicImpostor = parts[index].impostor;
  1050. mesh._physicsMass = options.mass / parts.length;
  1051. mesh._physicsFriction = options.friction;
  1052. mesh._physicRestitution = options.restitution;
  1053. }
  1054. return this._physicsEngine._registerMeshesAsCompound(parts, options);
  1055. };
  1056. //ANY
  1057. Scene.prototype.deleteCompoundImpostor = function (compound) {
  1058. for (var index = 0; index < compound.parts.length; index++) {
  1059. var mesh = compound.parts[index].mesh;
  1060. mesh._physicImpostor = BABYLON.PhysicsEngine.NoImpostor;
  1061. this._physicsEngine._unregisterMesh(mesh);
  1062. }
  1063. };
  1064. // Tags
  1065. Scene.prototype._getByTags = function (list, tagsQuery) {
  1066. if (tagsQuery === undefined) {
  1067. // returns the complete list (could be done with BABYLON.Tags.MatchesQuery but no need to have a for-loop here)
  1068. return list;
  1069. }
  1070. var listByTags = [];
  1071. for (var i in list) {
  1072. var item = list[i];
  1073. if (BABYLON.Tags.MatchesQuery(item, tagsQuery)) {
  1074. listByTags.push(item);
  1075. }
  1076. }
  1077. return listByTags;
  1078. };
  1079. Scene.prototype.getMeshesByTags = function (tagsQuery) {
  1080. return this._getByTags(this.meshes, tagsQuery);
  1081. };
  1082. Scene.prototype.getCamerasByTags = function (tagsQuery) {
  1083. return this._getByTags(this.cameras, tagsQuery);
  1084. };
  1085. Scene.prototype.getLightsByTags = function (tagsQuery) {
  1086. return this._getByTags(this.lights, tagsQuery);
  1087. };
  1088. Scene.prototype.getMaterialByTags = function (tagsQuery) {
  1089. return this._getByTags(this.materials, tagsQuery).concat(this._getByTags(this.multiMaterials, tagsQuery));
  1090. };
  1091. Scene.FOGMODE_NONE = 0;
  1092. Scene.FOGMODE_EXP = 1;
  1093. Scene.FOGMODE_EXP2 = 2;
  1094. Scene.FOGMODE_LINEAR = 3;
  1095. Scene.MinDeltaTime = 1.0;
  1096. Scene.MaxDeltaTime = 1000.0;
  1097. return Scene;
  1098. })();
  1099. BABYLON.Scene = Scene;
  1100. })(BABYLON || (BABYLON = {}));
  1101. //# sourceMappingURL=babylon.scene.js.map