aframe.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. "use strict";
  2. // VWF & A-Frame view driver
  3. // Copyright 2017 Krestianstvo.org project
  4. //
  5. // Copyright 2012 United States Government, as represented by the Secretary of Defense, Under
  6. // Secretary of Defense (Personnel & Readiness).
  7. //
  8. // Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
  9. // in compliance with the License. You may obtain a copy of the License at
  10. //
  11. // http://www.apache.org/licenses/LICENSE-2.0
  12. //
  13. // Unless required by applicable law or agreed to in writing, software distributed under the License
  14. // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
  15. // or implied. See the License for the specific language governing permissions and limitations under
  16. // the License.
  17. /// vwf/view/lesson creates a view interface for instruction text.
  18. ///
  19. /// @module vwf/view/aframe
  20. /// @requires vwf/view
  21. define(["module", "vwf/view"], function (module, view) {
  22. var self;
  23. return view.load(module, {
  24. // == Module Definition ====================================================================
  25. initialize: function (options) {
  26. self = this;
  27. this.nodes = {};
  28. // this.tickTime = 0;
  29. // this.realTickDif = 50;
  30. // this.lastrealTickDif = 50;
  31. // this.lastRealTick = performance.now();
  32. this.state.appInitialized = false;
  33. if (options === undefined) { options = {}; }
  34. if (typeof options == "object") {
  35. this.rootSelector = options["application-root"];
  36. }
  37. else {
  38. this.rootSelector = options;
  39. }
  40. this.gearvr = options.gearvr !== undefined ? options.gearvr : false;
  41. this.wmrright = options.wmrright !== undefined ? options.wmrright : false;
  42. this.wmrleft = options.wmrleft !== undefined ? options.wmrleft : false;
  43. },
  44. createdNode: function (nodeID, childID, childExtendsID, childImplementsIDs,
  45. childSource, childType, childIndex, childName, callback /* ( ready ) */) {
  46. var node = this.state.nodes[childID];
  47. // If the "nodes" object does not have this object in it, it must not be one that
  48. // this driver cares about
  49. if (!node) {
  50. return;
  51. }
  52. if (this.state.scenes[childID]) {
  53. let scene = this.state.scenes[childID];
  54. document.body.appendChild(scene); //append is not working in Edge browser
  55. createAvatarControl(scene);
  56. createAvatar.call(this, childID);
  57. // this.state.appInitialized = true;
  58. if (this.gearvr == true) {
  59. console.log("CREATE GEARVR HERE!!");
  60. if (AFRAME.utils.device.isGearVR()) {
  61. let nodeName = 'gearvr-' + self.kernel.moniker();
  62. createGearVRControls();
  63. createGearVRController.call(this, childID, nodeName);
  64. }
  65. }
  66. if (this.wmrright == true) {
  67. console.log("CREATE WMR RIGHT HERE!!");
  68. if (AFRAME.utils.device.checkHasPositionalTracking()) {
  69. let nodeName = 'wmrvr-right-' + self.kernel.moniker();
  70. createWMRVRControls('right');
  71. createWMRVR.call(this, childID, nodeName);
  72. }
  73. }
  74. if (this.wmrleft == true) {
  75. console.log("CREATE WMR LEFT HERE!!");
  76. if (AFRAME.utils.device.checkHasPositionalTracking()) {
  77. let nodeName = 'wmrvr-left-' + self.kernel.moniker();
  78. createWMRVRControls('left');
  79. createWMRVR.call(this, childID, nodeName);
  80. }
  81. }
  82. }
  83. if (this.state.nodes[childID] && this.state.nodes[childID].aframeObj) {
  84. this.nodes[childID] = {
  85. id: childID,
  86. extends: childExtendsID,
  87. // lastTransformStep: 0,
  88. // lastAnimationStep: 0
  89. };
  90. }
  91. // if(this.state.nodes[childID]) {
  92. // this.nodes[childID] = {id:childID,extends:childExtendsID};
  93. // }
  94. // else if (this.state.nodes[childID] && this.state.nodes[childID].aframeObj.object3D instanceof THREE.Object3D) {
  95. // this.nodes[childID] = {id:childID,extends:childExtendsID};
  96. // }
  97. },
  98. initializedNode: function (nodeID, childID) {
  99. var node = this.state.nodes[childID];
  100. if (!node) {
  101. return;
  102. }
  103. if (node.extendsID == "http://vwf.example.com/aframe/gearvrcontroller.vwf"){
  104. console.log("gearVR controller initialized")
  105. }
  106. },
  107. createdProperty: function (nodeId, propertyName, propertyValue) {
  108. return this.satProperty(nodeId, propertyName, propertyValue);
  109. },
  110. initializedProperty: function (nodeId, propertyName, propertyValue) {
  111. return this.satProperty(nodeId, propertyName, propertyValue);
  112. },
  113. gotProperty: function (nodeId, propertyName, propertyValue) {
  114. var selfs = this;
  115. var node = this.state.nodes[nodeId];
  116. if (!(node && node.aframeObj)) {
  117. return;
  118. }
  119. },
  120. satProperty: function (nodeId, propertyName, propertyValue) {
  121. var selfs = this;
  122. var node = this.state.nodes[nodeId];
  123. if (!(node && node.aframeObj)) {
  124. return;
  125. }
  126. // if (node.aframeObj.nodeName == "AUDIO" && propertyName == 'itemSrc') {
  127. // //console.log("sat new item");
  128. // let elID = '#' + node.aframeObj.getAttribute('id');
  129. // Object.entries(this.state.nodes).forEach(el => {
  130. // let src = el[1].aframeObj.getAttribute('src');
  131. // if (src){
  132. // // console.log("my: " + src);
  133. // if (src == elID)
  134. // self.kernel.callMethod(el[0], "updateSrc", [elID])
  135. // }
  136. // })
  137. // }
  138. if (node.aframeObj.nodeName == "AUDIO" && propertyName == 'itemSrc') {
  139. //console.log("sat new item");
  140. let elID = '#' + node.aframeObj.getAttribute('id');
  141. Object.entries(this.state.nodes).forEach(el => {
  142. let sound = el[1].aframeObj.getAttribute('sound');
  143. if(sound) {
  144. let soundID = vwf.find(el[0], 'sound');
  145. self.kernel.callMethod(soundID, "refreshSrc", [elID])
  146. // if (sound.src !== ""){
  147. // let src = '#' + sound.src.id;
  148. // if (src == elID){
  149. // let soundID = vwf.find(el[0], 'sound');
  150. // self.kernel.callMethod(soundID, "updateSrc", [elID])
  151. // }
  152. // }
  153. }
  154. })
  155. }
  156. if (node.aframeObj.nodeName == "IMG" && propertyName == 'itemSrc') {
  157. //console.log("sat new item");
  158. let elID = '#' + node.aframeObj.getAttribute('id');
  159. Object.entries(this.state.nodes).forEach(el => {
  160. let material = el[1].aframeObj.getAttribute('material');
  161. if(material) {
  162. if (material.src !== ""){
  163. // console.log("my: " + src);
  164. let src = '#' + material.src.id;
  165. if (src == elID){
  166. let materialID = vwf.find(el[0], 'material');
  167. self.kernel.callMethod(materialID, "updateSrc", [elID])
  168. }
  169. }
  170. }
  171. })
  172. }
  173. if (node.aframeObj.nodeName == "VIDEO" && propertyName == 'itemSrc') {
  174. //console.log("sat new item");
  175. let elID = '#' + node.aframeObj.getAttribute('id');
  176. Object.entries(this.state.nodes).forEach(el => {
  177. let material = el[1].aframeObj.getAttribute('material');
  178. if(material) {
  179. if (material.src !== ""){
  180. // console.log("my: " + src);
  181. let src = '#' + material.src.id;
  182. if (src == elID){
  183. let materialID = vwf.find(el[0], 'material');
  184. self.kernel.callMethod(materialID, "updateSrc", [elID])
  185. }
  186. }
  187. }
  188. })
  189. }
  190. if (node.aframeObj.nodeName == "A-ASSET-ITEM" && propertyName == 'itemSrc') {
  191. //console.log("sat new item");
  192. let elID = '#' + node.aframeObj.getAttribute('id');
  193. Object.entries(this.state.nodes).forEach(el => {
  194. let src = el[1].aframeObj.getAttribute('src');
  195. let mtl = el[1].aframeObj.getAttribute('mtl');
  196. if (src){
  197. // console.log("my: " + src);
  198. if (src == elID)
  199. self.kernel.callMethod(el[0], "updateModel", [elID])
  200. }
  201. if (mtl){
  202. // console.log("my: " + mtl);
  203. if (mtl == elID)
  204. self.kernel.callMethod(el[0], "updateModelMtl", [elID])
  205. }
  206. })
  207. }
  208. // if (node.aframeObj.nodeName == "A-BOX" && propertyName == 'color') {
  209. // console.log("sat color");
  210. // let materialName = '/' + node.name + '/material';
  211. // let materialID = vwf.find('', materialName)[0];
  212. // if (materialID) {
  213. // vwf.setProperty(materialID, propertyName, propertyValue);
  214. // }
  215. // }
  216. // if (propertyName == 'position') {
  217. // this.nodes[nodeId].lastTransformStep = vwf.time();
  218. // }
  219. // var aframeObject = node.aframeObj;
  220. // switch (propertyName) {
  221. // case "clickable":
  222. // if (propertyValue) {
  223. // aframeObject.addEventListener('click', function (evt) {
  224. // let cursorID = 'cursor-avatar-'+selfs.kernel.moniker();
  225. // if (evt.detail.cursorEl.id == cursorID) {
  226. // vwf_view.kernel.fireEvent(nodeId, "clickEvent")
  227. // }
  228. // });
  229. // }
  230. // break;
  231. // }
  232. },
  233. deletedNode: function(childID)
  234. {
  235. delete this.nodes[childID];
  236. },
  237. firedEvent: function (nodeID, eventName, eventParameters) {
  238. //var avatarID = vwf_view.kernel.find("", avatarName)
  239. var avatarName = 'avatar-' + self.kernel.moniker();
  240. if (eventName == "createAvatar") {
  241. console.log("!!!!");
  242. let avatarID = self.kernel.moniker();
  243. var nodeName = 'avatar-' + avatarID;
  244. var newNode = {
  245. "id": avatarName,
  246. "uri": avatarName,
  247. "extends": "http://vwf.example.com/aframe/avatar.vwf",
  248. "properties": {
  249. "localUrl": '',
  250. "remoteUrl": '',
  251. "displayName": 'Avatar '+ randId(),
  252. "sharing": { audio: true, video: true },
  253. "selectMode": false,
  254. "position": "0 1.6 0"
  255. }
  256. }
  257. if (!self.state.nodes[avatarName]) {
  258. vwf_view.kernel.createChild(nodeID, avatarName, newNode);
  259. vwf_view.kernel.callMethod(avatarName, "createAvatarBody", []);
  260. //"/../assets/avatars/male/avatar1.gltf"
  261. }
  262. }
  263. // if (eventName == "setAvatarRotation") {
  264. // vwf_view.kernel.setProperty(avatarName, "rotation", [eventParameters.x, eventParameters.y, eventParameters.z]);
  265. // }
  266. // if (eventName == "setAvatarPosition") {
  267. // vwf_view.kernel.setProperty(avatarName, "position", [eventParameters.x, eventParameters.y, eventParameters.z]);
  268. // }
  269. if (eventName == "clickEvent") {
  270. if (self.kernel.moniker() == eventParameters[0]){
  271. let avatar = self.nodes[avatarName];
  272. let mode = vwf.getProperty(avatarName, 'selectMode');
  273. if(mode) {
  274. console.log("allow to click!!!")
  275. vwf_view.kernel.setProperty(avatarName, 'selectMode', false);
  276. let editorDriver = vwf.views["vwf/view/editor-new"];
  277. if (editorDriver){
  278. let selectSwitch = document.querySelector('#selectNodeSwitch');
  279. const selectSwitchComp = new mdc.iconToggle.MDCIconToggle(selectSwitch); //new mdc.select.MDCIconToggle
  280. selectSwitchComp.on = false;
  281. let currentNodeDIV = document.querySelector('#currentNode');
  282. if (currentNodeDIV) currentNodeDIV._setNode(nodeID);
  283. }
  284. }
  285. }
  286. }
  287. },
  288. ticked: function (vwfTime) {
  289. updateAvatarPosition();
  290. //update vr controllers
  291. if (this.gearvr == true) {
  292. updateHandControllerVR('gearvr-', '#gearvrcontrol');
  293. }
  294. if (this.wmrright == true) {
  295. updateHandControllerVR('wmrvr-right-', '#wmrvrcontrolright');
  296. }
  297. if (this.wmrleft == true) {
  298. updateHandControllerVR('wmrvr-left-', '#wmrvrcontrolleft');
  299. }
  300. // console.log(vwfTime);
  301. //lerpTick ();
  302. },
  303. calledMethod: function( nodeID, methodName, methodParameters, methodValue ) {
  304. var node = this.state.nodes[nodeID];
  305. if (!(node && node.aframeObj)) {
  306. return;
  307. }
  308. if (this.nodes[nodeID].extends == "http://vwf.example.com/aframe/acamera.vwf"){
  309. if (methodName == "setCameraToActive"){
  310. if (methodParameters[0] == vwf.moniker_){
  311. console.log("set active");
  312. let offsetComp = node.aframeObj.getAttribute('viewoffset');
  313. if (offsetComp) {
  314. let offsetCompID = vwf.find(nodeID, 'viewoffset');
  315. self.kernel.callMethod(offsetCompID, "setParams", []);
  316. }
  317. node.aframeObj.setAttribute('camera', 'active', true);
  318. }
  319. }
  320. }
  321. if(methodName == "createGooglePoly"){
  322. }
  323. }
  324. });
  325. function compareCoordinates(a, b, delta) {
  326. return Math.abs(a.x - b.x) > delta || Math.abs(a.y - b.y) > delta || Math.abs(a.z - b.z) > delta
  327. }
  328. function getWorldRotation(el) {
  329. var worldQuat = new THREE.Quaternion();
  330. el.object3D.getWorldQuaternion(worldQuat);
  331. //console.log(worldQuat);
  332. let angle = (new THREE.Euler()).setFromQuaternion(worldQuat, 'YXZ');
  333. let rotation = (new THREE.Vector3(THREE.Math.radToDeg(angle.x),
  334. THREE.Math.radToDeg(angle.y), THREE.Math.radToDeg(angle.z) ));
  335. return rotation
  336. }
  337. function updateAvatarPosition() {
  338. let delta = 0.0001;
  339. let avatarName = 'avatar-' + self.kernel.moniker();
  340. var node = self.state.nodes[avatarName];
  341. if (!node) return;
  342. if (!node.aframeObj) return;
  343. let el = document.querySelector('#avatarControl');
  344. if (el) {
  345. //let position = el.object3D.getWorldPosition(); //el.getAttribute('position');
  346. let position = new THREE.Vector3();
  347. el.object3D.getWorldPosition(position);
  348. let rotation = getWorldRotation(el);
  349. // console.log(rotation);
  350. //let rotation = el.getAttribute('rotation');
  351. let lastRotation = self.nodes[avatarName].selfTickRotation;
  352. let lastPosition = self.nodes[avatarName].selfTickPosition;
  353. // let currentPosition = node.aframeObj.getAttribute('position');
  354. // let currentRotation = node.aframeObj.getAttribute('rotation');
  355. if (position && rotation && lastPosition && lastRotation) {
  356. if (compareCoordinates(position, lastPosition, delta) || Math.abs(rotation.y - lastRotation.y) > delta) {
  357. console.log("not equal!!")
  358. vwf_view.kernel.callMethod(avatarName, "followAvatarControl", [position, rotation]);
  359. }
  360. }
  361. self.nodes[avatarName].selfTickRotation = Object.assign({}, rotation);
  362. self.nodes[avatarName].selfTickPosition = Object.assign({}, position);
  363. }
  364. }
  365. function updateHandControllerVR(aName, aSelector) {
  366. //let avatarName = 'avatar-' + self.kernel.moniker();
  367. let delta = 0.0001
  368. let avatarName = aName + self.kernel.moniker();
  369. var node = self.state.nodes[avatarName];
  370. if (!node) return;
  371. if (!node.aframeObj) return;
  372. let el = document.querySelector(aSelector);
  373. if (el) {
  374. //let position = el.object3D.getWorldPosition() //el.getAttribute('position');
  375. let position = new THREE.Vector3();
  376. el.object3D.getWorldPosition(position);
  377. let rotation = getWorldRotation(el);
  378. //let rotation = el.getAttribute('rotation');
  379. let lastRotation = self.nodes[avatarName].selfTickRotation;
  380. let lastPosition = self.nodes[avatarName].selfTickPosition;
  381. // let currentPosition = node.aframeObj.getAttribute('position');
  382. //let currentRotation = node.aframeObj.getAttribute('rotation');
  383. if (position && rotation && lastRotation && lastPosition) {
  384. if (compareCoordinates(position, lastPosition, delta) || compareCoordinates(rotation, lastRotation, delta)) {
  385. console.log("not equal!!");
  386. vwf_view.kernel.callMethod(avatarName, "updateVRControl", [position, rotation]);
  387. }
  388. }
  389. //vwf_view.kernel.callMethod(avatarName, "updateVRControl", [position, rotation]);
  390. self.nodes[avatarName].selfTickPosition = Object.assign({}, position);
  391. self.nodes[avatarName].selfTickRotation = Object.assign({}, rotation);
  392. }
  393. }
  394. function createAvatarControl(aScene) {
  395. let avatarName = 'avatar-' + self.kernel.moniker();
  396. let avatarEl = document.createElement('a-entity');
  397. avatarEl.setAttribute('id', 'avatarControlParent');
  398. if (AFRAME.utils.device.isGearVR()) {
  399. avatarEl.setAttribute('movement-controls', {});//{'controls': 'gamepad'});
  400. //avatarEl.setAttribute('position', '0 0 0');
  401. }
  402. let controlEl = document.createElement('a-camera');
  403. controlEl.setAttribute('id', 'avatarControl');
  404. //controlEl.setAttribute('wasd-controls', {});
  405. controlEl.setAttribute('look-controls', {pointerLockEnabled: false});
  406. //controlEl.setAttribute('gamepad-controls', {'controller': 0});
  407. //controlEl.setAttribute('gearvr-controls',{});
  408. // controlEl.setAttribute('camera', 'near', 0.51);
  409. //controlEl.setAttribute('position', '0 0 0');
  410. controlEl.setAttribute('camera', 'active', true);
  411. let cursorEl = document.createElement('a-cursor');
  412. cursorEl.setAttribute('id', 'cursor-' + avatarName);
  413. cursorEl.setAttribute('raycaster', {});
  414. cursorEl.setAttribute('raycaster', 'objects', '.intersectable');
  415. cursorEl.setAttribute('raycaster', 'showLine', false);
  416. if (AFRAME.utils.device.isGearVR()) {}
  417. // cursorEl.setAttribute('raycaster', {objects: '.intersectable', showLine: true, far: 100});
  418. // cursorEl.setAttribute('raycaster', 'showLine', true);
  419. controlEl.appendChild(cursorEl);
  420. avatarEl.appendChild(controlEl);
  421. aScene.appendChild(avatarEl);
  422. // let gearVRControlsEl = document.createElement('a-entity');
  423. // gearVRControlsEl.setAttribute('id', 'gearvr-'+avatarName);
  424. // gearVRControlsEl.setAttribute('gearvr-controls', {});
  425. // aScene.appendChild(gearVRControlsEl);
  426. // controlEl.addEventListener('componentchanged', function (evt) {
  427. // if (evt.detail.name === 'position') {
  428. // var eventParameters = evt.detail.newData;
  429. // vwf_view.kernel.setProperty(avatarName, "position", [eventParameters.x, eventParameters.y, eventParameters.z]);
  430. // }
  431. // if (evt.detail.name === 'rotation') {
  432. // var eventParameters = evt.detail.newData;
  433. // vwf_view.kernel.setProperty(avatarName, "rotation", [eventParameters.x, eventParameters.y, eventParameters.z]);
  434. // }
  435. // });
  436. }
  437. function createWMRVR (nodeID, nodeName) {
  438. var newNode = {
  439. "id": nodeName,
  440. "uri": nodeName,
  441. "extends": "http://vwf.example.com/aframe/wmrvrcontroller.vwf",
  442. "properties": {
  443. }
  444. }
  445. if (!self.state.nodes[nodeName]) {
  446. vwf_view.kernel.createChild(nodeID, nodeName, newNode);
  447. vwf_view.kernel.callMethod(nodeName, "createController", []);
  448. //"/../assets/controller/wmrvr.gltf"
  449. }
  450. }
  451. function createGearVRController(nodeID, nodeName) {
  452. var newNode = {
  453. "id": nodeName,
  454. "uri": nodeName,
  455. "extends": "http://vwf.example.com/aframe/gearvrcontroller.vwf",
  456. "properties": {
  457. }
  458. }
  459. if (!self.state.nodes[nodeName]) {
  460. vwf_view.kernel.createChild(nodeID, nodeName, newNode);
  461. vwf_view.kernel.callMethod(nodeName, "createController", []);
  462. //"/../assets/controller/gearvr.gltf"
  463. }
  464. }
  465. function createAvatar(nodeID) {
  466. vwf_view.kernel.fireEvent(nodeID, "createAvatar")
  467. // let avatarID = self.kernel.moniker();
  468. // var nodeName = 'avatar-' + avatarID;
  469. // var newNode = {
  470. // "id": nodeName,
  471. // "uri": nodeName,
  472. // "extends": "http://vwf.example.com/aframe/avatar.vwf"
  473. // }
  474. // vwf_view.kernel.createChild(nodeID, nodeName, newNode);
  475. // vwf_view.kernel.callMethod(nodeName, "createAvatarBody");
  476. }
  477. function randId() {
  478. return '_' + Math.random().toString(36).substr(2, 9);
  479. }
  480. function createGearVRControls() {
  481. let sceneEl = document.querySelector('a-scene');
  482. let avatarControl = document.querySelector('#avatarControlParent');
  483. let gearvr = document.createElement('a-entity');
  484. gearvr.setAttribute('id', 'gearvrcontrol');
  485. gearvr.setAttribute('gearvr-controls', {
  486. 'hand': 'right',
  487. 'model': true });
  488. // gearvr.setAttribute('gearvr-controls', 'hand', 'right');
  489. gearvr.setAttribute('gearvrcontrol', {});
  490. avatarControl.appendChild(gearvr);
  491. }
  492. function createWMRVRControls(hand) {
  493. let sceneEl = document.querySelector('a-scene');
  494. let avatarControl = document.querySelector('#avatarControlParent');
  495. let wmrvr = document.createElement('a-entity');
  496. wmrvr.setAttribute('id', 'wmrvrcontrol' + hand);
  497. wmrvr.setAttribute('windows-motion-controls', '');
  498. wmrvr.setAttribute('windows-motion-controls', 'hand', hand);
  499. wmrvr.setAttribute('wmrvrcontrol', {'hand': hand});
  500. avatarControl.appendChild(wmrvr);
  501. }
  502. });