babylon.node.ts 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. module BABYLON {
  2. /**
  3. * Defines how a node can be built from a string name.
  4. */
  5. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  6. /**
  7. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  8. */
  9. export class Node implements IBehaviorAware<Node> {
  10. private static _NodeConstructors: { [key: string]: any } = {};
  11. /**
  12. * Add a new node constructor
  13. * @param type defines the type name of the node to construct
  14. * @param constructorFunc defines the constructor function
  15. */
  16. public static AddNodeConstructor(type: string, constructorFunc: NodeConstructor) {
  17. this._NodeConstructors[type] = constructorFunc;
  18. }
  19. /**
  20. * Returns a node constructor based on type name
  21. * @param type defines the type name
  22. * @param name defines the new node name
  23. * @param scene defines the hosting scene
  24. * @param options defines optional options to transmit to constructors
  25. * @returns the new constructor or null
  26. */
  27. public static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node> {
  28. let constructorFunc = this._NodeConstructors[type];
  29. if (!constructorFunc) {
  30. return null;
  31. }
  32. return constructorFunc(name, scene, options);
  33. }
  34. /**
  35. * Gets or sets the name of the node
  36. */
  37. @serialize()
  38. public name: string;
  39. /**
  40. * Gets or sets the id of the node
  41. */
  42. @serialize()
  43. public id: string;
  44. /**
  45. * Gets or sets the unique id of the node
  46. */
  47. @serialize()
  48. public uniqueId: number;
  49. /**
  50. * Gets or sets a string used to store user defined state for the node
  51. */
  52. @serialize()
  53. public state = "";
  54. /**
  55. * Gets or sets an object used to store user defined information for the node
  56. */
  57. @serialize()
  58. public metadata: any = null;
  59. /**
  60. * For internal use only. Please do not use.
  61. */
  62. public reservedDataStore: any = null;
  63. /**
  64. * Gets or sets a boolean used to define if the node must be serialized
  65. */
  66. public doNotSerialize = false;
  67. /** @hidden */
  68. public _isDisposed = false;
  69. /**
  70. * Gets a list of Animations associated with the node
  71. */
  72. public animations = new Array<Animation>();
  73. protected _ranges: { [name: string]: Nullable<AnimationRange> } = {};
  74. /**
  75. * Callback raised when the node is ready to be used
  76. */
  77. public onReady: (node: Node) => void;
  78. private _isEnabled = true;
  79. private _isParentEnabled = true;
  80. private _isReady = true;
  81. /** @hidden */
  82. public _currentRenderId = -1;
  83. private _parentRenderId = -1;
  84. protected _childRenderId = -1;
  85. /** @hidden */
  86. public _waitingParentId: Nullable<string>;
  87. /** @hidden */
  88. public _scene: Scene;
  89. /** @hidden */
  90. public _cache: any;
  91. private _parentNode: Nullable<Node>;
  92. private _children: Node[];
  93. /** @hidden */
  94. public _worldMatrix = Matrix.Identity();
  95. /** @hidden */
  96. public _worldMatrixDeterminant = 0;
  97. /** @hidden */
  98. private _sceneRootNodesIndex = -1;
  99. /**
  100. * Gets a boolean indicating if the node has been disposed
  101. * @returns true if the node was disposed
  102. */
  103. public isDisposed(): boolean {
  104. return this._isDisposed;
  105. }
  106. /**
  107. * Gets or sets the parent of the node
  108. */
  109. public set parent(parent: Nullable<Node>) {
  110. if (this._parentNode === parent) {
  111. return;
  112. }
  113. const previousParentNode = this._parentNode;
  114. // Remove self from list of children of parent
  115. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  116. var index = this._parentNode._children.indexOf(this);
  117. if (index !== -1) {
  118. this._parentNode._children.splice(index, 1);
  119. }
  120. if (!parent) {
  121. this.addToSceneRootNodes();
  122. }
  123. }
  124. // Store new parent
  125. this._parentNode = parent;
  126. // Add as child to new parent
  127. if (this._parentNode) {
  128. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  129. this._parentNode._children = new Array<Node>();
  130. }
  131. this._parentNode._children.push(this);
  132. if (!previousParentNode) {
  133. this.removeFromSceneRootNodes();
  134. }
  135. }
  136. // Enabled state
  137. this._syncParentEnabledState();
  138. }
  139. public get parent(): Nullable<Node> {
  140. return this._parentNode;
  141. }
  142. private addToSceneRootNodes() {
  143. if (this._sceneRootNodesIndex === -1) {
  144. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  145. this._scene.rootNodes.push(this);
  146. }
  147. }
  148. private removeFromSceneRootNodes() {
  149. if (this._sceneRootNodesIndex !== -1) {
  150. const rootNodes = this._scene.rootNodes;
  151. const lastIdx = rootNodes.length - 1;
  152. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  153. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  154. this._scene.rootNodes.pop();
  155. this._sceneRootNodesIndex = -1;
  156. }
  157. }
  158. private _animationPropertiesOverride: Nullable<AnimationPropertiesOverride> = null;
  159. /**
  160. * Gets or sets the animation properties override
  161. */
  162. public get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride> {
  163. if (!this._animationPropertiesOverride) {
  164. return this._scene.animationPropertiesOverride;
  165. }
  166. return this._animationPropertiesOverride;
  167. }
  168. public set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>) {
  169. this._animationPropertiesOverride = value;
  170. }
  171. /**
  172. * Gets a string idenfifying the name of the class
  173. * @returns "Node" string
  174. */
  175. public getClassName(): string {
  176. return "Node";
  177. }
  178. /**
  179. * An event triggered when the mesh is disposed
  180. */
  181. public onDisposeObservable = new Observable<Node>();
  182. private _onDisposeObserver: Nullable<Observer<Node>>;
  183. /**
  184. * Sets a callback that will be raised when the node will be disposed
  185. */
  186. public set onDispose(callback: () => void) {
  187. if (this._onDisposeObserver) {
  188. this.onDisposeObservable.remove(this._onDisposeObserver);
  189. }
  190. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  191. }
  192. /**
  193. * Creates a new Node
  194. * @param name the name and id to be given to this node
  195. * @param scene the scene this node will be added to
  196. * @param addToRootNodes the node will be added to scene.rootNodes
  197. */
  198. constructor(name: string, scene: Nullable<Scene> = null, addToRootNodes = true) {
  199. this.name = name;
  200. this.id = name;
  201. this._scene = <Scene>(scene || Engine.LastCreatedScene);
  202. this.uniqueId = this._scene.getUniqueId();
  203. this._initCache();
  204. if (addToRootNodes) {
  205. this.addToSceneRootNodes();
  206. }
  207. }
  208. /**
  209. * Gets the scene of the node
  210. * @returns a scene
  211. */
  212. public getScene(): Scene {
  213. return this._scene;
  214. }
  215. /**
  216. * Gets the engine of the node
  217. * @returns a Engine
  218. */
  219. public getEngine(): Engine {
  220. return this._scene.getEngine();
  221. }
  222. // Behaviors
  223. private _behaviors = new Array<Behavior<Node>>();
  224. /**
  225. * Attach a behavior to the node
  226. * @see http://doc.babylonjs.com/features/behaviour
  227. * @param behavior defines the behavior to attach
  228. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  229. * @returns the current Node
  230. */
  231. public addBehavior(behavior: Behavior<Node>, attachImmediately = false): Node {
  232. var index = this._behaviors.indexOf(behavior);
  233. if (index !== -1) {
  234. return this;
  235. }
  236. behavior.init();
  237. if (this._scene.isLoading && !attachImmediately) {
  238. // We defer the attach when the scene will be loaded
  239. this._scene.onDataLoadedObservable.addOnce(() => {
  240. behavior.attach(this);
  241. });
  242. } else {
  243. behavior.attach(this);
  244. }
  245. this._behaviors.push(behavior);
  246. return this;
  247. }
  248. /**
  249. * Remove an attached behavior
  250. * @see http://doc.babylonjs.com/features/behaviour
  251. * @param behavior defines the behavior to attach
  252. * @returns the current Node
  253. */
  254. public removeBehavior(behavior: Behavior<Node>): Node {
  255. var index = this._behaviors.indexOf(behavior);
  256. if (index === -1) {
  257. return this;
  258. }
  259. this._behaviors[index].detach();
  260. this._behaviors.splice(index, 1);
  261. return this;
  262. }
  263. /**
  264. * Gets the list of attached behaviors
  265. * @see http://doc.babylonjs.com/features/behaviour
  266. */
  267. public get behaviors(): Behavior<Node>[] {
  268. return this._behaviors;
  269. }
  270. /**
  271. * Gets an attached behavior by name
  272. * @param name defines the name of the behavior to look for
  273. * @see http://doc.babylonjs.com/features/behaviour
  274. * @returns null if behavior was not found else the requested behavior
  275. */
  276. public getBehaviorByName(name: string): Nullable<Behavior<Node>> {
  277. for (var behavior of this._behaviors) {
  278. if (behavior.name === name) {
  279. return behavior;
  280. }
  281. }
  282. return null;
  283. }
  284. /**
  285. * Returns the latest update of the World matrix
  286. * @returns a Matrix
  287. */
  288. public getWorldMatrix(): Matrix {
  289. if (this._currentRenderId !== this._scene.getRenderId()) {
  290. this.computeWorldMatrix();
  291. }
  292. return this._worldMatrix;
  293. }
  294. /** @hidden */
  295. public _getWorldMatrixDeterminant(): number {
  296. return this._worldMatrixDeterminant;
  297. }
  298. /**
  299. * Returns directly the latest state of the mesh World matrix.
  300. * A Matrix is returned.
  301. */
  302. public get worldMatrixFromCache(): Matrix {
  303. return this._worldMatrix;
  304. }
  305. // override it in derived class if you add new variables to the cache
  306. // and call the parent class method
  307. /** @hidden */
  308. public _initCache() {
  309. this._cache = {};
  310. this._cache.parent = undefined;
  311. }
  312. /** @hidden */
  313. public updateCache(force?: boolean): void {
  314. if (!force && this.isSynchronized()) {
  315. return;
  316. }
  317. this._cache.parent = this.parent;
  318. this._updateCache();
  319. }
  320. // override it in derived class if you add new variables to the cache
  321. // and call the parent class method if !ignoreParentClass
  322. /** @hidden */
  323. public _updateCache(ignoreParentClass?: boolean): void {
  324. }
  325. // override it in derived class if you add new variables to the cache
  326. /** @hidden */
  327. public _isSynchronized(): boolean {
  328. return true;
  329. }
  330. /** @hidden */
  331. public _markSyncedWithParent() {
  332. if (this._parentNode) {
  333. this._parentRenderId = this._parentNode._childRenderId;
  334. }
  335. }
  336. /** @hidden */
  337. public isSynchronizedWithParent(): boolean {
  338. if (!this._parentNode) {
  339. return true;
  340. }
  341. if (this._parentRenderId !== this._parentNode._childRenderId) {
  342. return false;
  343. }
  344. return this._parentNode.isSynchronized();
  345. }
  346. /** @hidden */
  347. public isSynchronized(): boolean {
  348. if (this._cache.parent != this._parentNode) {
  349. this._cache.parent = this._parentNode;
  350. return false;
  351. }
  352. if (this._parentNode && !this.isSynchronizedWithParent()) {
  353. return false;
  354. }
  355. return this._isSynchronized();
  356. }
  357. /**
  358. * Is this node ready to be used/rendered
  359. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  360. * @return true if the node is ready
  361. */
  362. public isReady(completeCheck = false): boolean {
  363. return this._isReady;
  364. }
  365. /**
  366. * Is this node enabled?
  367. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  368. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  369. * @return whether this node (and its parent) is enabled
  370. */
  371. public isEnabled(checkAncestors: boolean = true): boolean {
  372. if (checkAncestors === false) {
  373. return this._isEnabled;
  374. }
  375. if (!this._isEnabled) {
  376. return false;
  377. }
  378. return this._isParentEnabled;
  379. }
  380. /** @hidden */
  381. protected _syncParentEnabledState() {
  382. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  383. if (this._children) {
  384. this._children.forEach((c) => {
  385. c._syncParentEnabledState(); // Force children to update accordingly
  386. });
  387. }
  388. }
  389. /**
  390. * Set the enabled state of this node
  391. * @param value defines the new enabled state
  392. */
  393. public setEnabled(value: boolean): void {
  394. this._isEnabled = value;
  395. this._syncParentEnabledState();
  396. }
  397. /**
  398. * Is this node a descendant of the given node?
  399. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  400. * @param ancestor defines the parent node to inspect
  401. * @returns a boolean indicating if this node is a descendant of the given node
  402. */
  403. public isDescendantOf(ancestor: Node): boolean {
  404. if (this.parent) {
  405. if (this.parent === ancestor) {
  406. return true;
  407. }
  408. return this.parent.isDescendantOf(ancestor);
  409. }
  410. return false;
  411. }
  412. /** @hidden */
  413. public _getDescendants(results: Node[], directDescendantsOnly: boolean = false, predicate?: (node: Node) => boolean): void {
  414. if (!this._children) {
  415. return;
  416. }
  417. for (var index = 0; index < this._children.length; index++) {
  418. var item = this._children[index];
  419. if (!predicate || predicate(item)) {
  420. results.push(item);
  421. }
  422. if (!directDescendantsOnly) {
  423. item._getDescendants(results, false, predicate);
  424. }
  425. }
  426. }
  427. /**
  428. * Will return all nodes that have this node as ascendant
  429. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  430. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  431. * @return all children nodes of all types
  432. */
  433. public getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[] {
  434. var results = new Array<Node>();
  435. this._getDescendants(results, directDescendantsOnly, predicate);
  436. return results;
  437. }
  438. /**
  439. * Get all child-meshes of this node
  440. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  441. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  442. * @returns an array of AbstractMesh
  443. */
  444. public getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[] {
  445. var results: Array<AbstractMesh> = [];
  446. this._getDescendants(results, directDescendantsOnly, (node: Node) => {
  447. return ((!predicate || predicate(node)) && (node instanceof AbstractMesh));
  448. });
  449. return results;
  450. }
  451. /**
  452. * Get all child-transformNodes of this node
  453. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  454. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  455. * @returns an array of TransformNode
  456. */
  457. public getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[] {
  458. var results: Array<TransformNode> = [];
  459. this._getDescendants(results, directDescendantsOnly, (node: Node) => {
  460. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  461. });
  462. return results;
  463. }
  464. /**
  465. * Get all direct children of this node
  466. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  467. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  468. * @returns an array of Node
  469. */
  470. public getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly = true): Node[] {
  471. return this.getDescendants(directDescendantsOnly, predicate);
  472. }
  473. /** @hidden */
  474. public _setReady(state: boolean): void {
  475. if (state === this._isReady) {
  476. return;
  477. }
  478. if (!state) {
  479. this._isReady = false;
  480. return;
  481. }
  482. if (this.onReady) {
  483. this.onReady(this);
  484. }
  485. this._isReady = true;
  486. }
  487. /**
  488. * Get an animation by name
  489. * @param name defines the name of the animation to look for
  490. * @returns null if not found else the requested animation
  491. */
  492. public getAnimationByName(name: string): Nullable<Animation> {
  493. for (var i = 0; i < this.animations.length; i++) {
  494. var animation = this.animations[i];
  495. if (animation.name === name) {
  496. return animation;
  497. }
  498. }
  499. return null;
  500. }
  501. /**
  502. * Creates an animation range for this node
  503. * @param name defines the name of the range
  504. * @param from defines the starting key
  505. * @param to defines the end key
  506. */
  507. public createAnimationRange(name: string, from: number, to: number): void {
  508. // check name not already in use
  509. if (!this._ranges[name]) {
  510. this._ranges[name] = new AnimationRange(name, from, to);
  511. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  512. if (this.animations[i]) {
  513. this.animations[i].createRange(name, from, to);
  514. }
  515. }
  516. }
  517. }
  518. /**
  519. * Delete a specific animation range
  520. * @param name defines the name of the range to delete
  521. * @param deleteFrames defines if animation frames from the range must be deleted as well
  522. */
  523. public deleteAnimationRange(name: string, deleteFrames = true): void {
  524. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  525. if (this.animations[i]) {
  526. this.animations[i].deleteRange(name, deleteFrames);
  527. }
  528. }
  529. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  530. }
  531. /**
  532. * Get an animation range by name
  533. * @param name defines the name of the animation range to look for
  534. * @returns null if not found else the requested animation range
  535. */
  536. public getAnimationRange(name: string): Nullable<AnimationRange> {
  537. return this._ranges[name];
  538. }
  539. /**
  540. * Will start the animation sequence
  541. * @param name defines the range frames for animation sequence
  542. * @param loop defines if the animation should loop (false by default)
  543. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  544. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  545. * @returns the object created for this animation. If range does not exist, it will return null
  546. */
  547. public beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable> {
  548. var range = this.getAnimationRange(name);
  549. if (!range) {
  550. return null;
  551. }
  552. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  553. }
  554. /**
  555. * Serialize animation ranges into a JSON compatible object
  556. * @returns serialization object
  557. */
  558. public serializeAnimationRanges(): any {
  559. var serializationRanges = [];
  560. for (var name in this._ranges) {
  561. var localRange = this._ranges[name];
  562. if (!localRange) {
  563. continue;
  564. }
  565. var range: any = {};
  566. range.name = name;
  567. range.from = localRange.from;
  568. range.to = localRange.to;
  569. serializationRanges.push(range);
  570. }
  571. return serializationRanges;
  572. }
  573. /**
  574. * Computes the world matrix of the node
  575. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  576. * @returns the world matrix
  577. */
  578. public computeWorldMatrix(force?: boolean): Matrix {
  579. if (!this._worldMatrix) {
  580. this._worldMatrix = Matrix.Identity();
  581. }
  582. return this._worldMatrix;
  583. }
  584. /**
  585. * Releases resources associated with this node.
  586. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  587. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  588. */
  589. public dispose(doNotRecurse?: boolean, disposeMaterialAndTextures = false): void {
  590. if (!doNotRecurse) {
  591. const nodes = this.getDescendants(true);
  592. for (const node of nodes) {
  593. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  594. }
  595. } else {
  596. const transformNodes = this.getChildTransformNodes(true);
  597. for (const transformNode of transformNodes) {
  598. transformNode.parent = null;
  599. transformNode.computeWorldMatrix(true);
  600. }
  601. }
  602. if (!this.parent) {
  603. this.removeFromSceneRootNodes();
  604. } else {
  605. this.parent = null;
  606. }
  607. // Callback
  608. this.onDisposeObservable.notifyObservers(this);
  609. this.onDisposeObservable.clear();
  610. // Behaviors
  611. for (var behavior of this._behaviors) {
  612. behavior.detach();
  613. }
  614. this._behaviors = [];
  615. this._isDisposed = true;
  616. }
  617. /**
  618. * Parse animation range data from a serialization object and store them into a given node
  619. * @param node defines where to store the animation ranges
  620. * @param parsedNode defines the serialization object to read data from
  621. * @param scene defines the hosting scene
  622. */
  623. public static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void {
  624. if (parsedNode.ranges) {
  625. for (var index = 0; index < parsedNode.ranges.length; index++) {
  626. var data = parsedNode.ranges[index];
  627. node.createAnimationRange(data.name, data.from, data.to);
  628. }
  629. }
  630. }
  631. }
  632. }