ascene.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  1. this.initialize = function () {
  2. this.future(0).clientWatch();
  3. };
  4. this.clientWatch = function () {
  5. var self = this;
  6. if (this.children.length !== 0) {
  7. var clients = this.find("doc('http://vwf.example.com/clients.vwf')")[0];
  8. if (clients !== undefined) {
  9. //console.log(clients.children);
  10. let clientsArray = [];
  11. clients.children.forEach(function (element) {
  12. clientsArray.push(element.name);
  13. });
  14. this.children.forEach(function (node) {
  15. if (node.id.indexOf('avatar-') != -1) {
  16. if (clientsArray.includes(node.id.slice(7))) {
  17. //console.log(node.id + 'is here!');
  18. } else {
  19. //console.log(node.id + " needed to delete!");
  20. self.children.delete(self.children[node.id]);
  21. //'gearvr-'
  22. let controllerVR = self.children['gearvr-' + node.id.slice(7)];
  23. if (controllerVR) {
  24. self.children.delete(controllerVR);
  25. }
  26. let wmrvR = self.children['wmrvr-right-' + node.id.slice(7)];
  27. if (wmrvR) {
  28. self.children.delete(wmrvR);
  29. }
  30. let wmrvL = self.children['wmrvr-left-' + node.id.slice(7)];
  31. if (wmrvL) {
  32. self.children.delete(wmrvL);
  33. }
  34. }
  35. }
  36. });
  37. }
  38. }
  39. this.future(5).clientWatch();
  40. };
  41. this.sphereProto = function () {
  42. let node = {
  43. "extends": "http://vwf.example.com/aframe/asphere.vwf",
  44. "properties": {
  45. "displayName": "sphere",
  46. "radius": 1,
  47. "clickable": true
  48. },
  49. children: {
  50. "material": {
  51. "extends": "http://vwf.example.com/aframe/aMaterialComponent.vwf",
  52. "type": "component",
  53. "properties":{
  54. "color": "white"
  55. }
  56. },
  57. "interpolation":
  58. {
  59. "extends": "http://vwf.example.com/aframe/interpolation-component.vwf",
  60. "type": "component",
  61. "properties": {
  62. "enabled": true
  63. }
  64. },
  65. "cursor-listener": {
  66. "extends": "http://vwf.example.com/aframe/app-cursor-listener-component.vwf",
  67. "type": "component"
  68. }
  69. },
  70. events: {
  71. "clickEvent": {
  72. "body": ""
  73. }
  74. }
  75. }
  76. return node
  77. }
  78. this.cylinderProto = function () {
  79. let node = {
  80. "extends": "http://vwf.example.com/aframe/acylinder.vwf",
  81. "properties": {
  82. "displayName": "cylinder",
  83. "radius": 1,
  84. "height": 1,
  85. "clickable": true
  86. },
  87. children: {
  88. "material": {
  89. "extends": "http://vwf.example.com/aframe/aMaterialComponent.vwf",
  90. "type": "component",
  91. "properties":{
  92. "color": "white"
  93. }
  94. },
  95. "interpolation":
  96. {
  97. "extends": "http://vwf.example.com/aframe/interpolation-component.vwf",
  98. "type": "component",
  99. "properties": {
  100. "enabled": true
  101. }
  102. },
  103. "cursor-listener": {
  104. "extends": "http://vwf.example.com/aframe/app-cursor-listener-component.vwf",
  105. "type": "component"
  106. }
  107. },
  108. events: {
  109. "clickEvent": {
  110. "body": ""
  111. }
  112. }
  113. }
  114. return node
  115. }
  116. this.coneProto = function () {
  117. let node = {
  118. "extends": "http://vwf.example.com/aframe/acone.vwf",
  119. "properties": {
  120. "displayName": "cone",
  121. "radius-bottom": 1,
  122. "radius-top": 0.01,
  123. "height": 1,
  124. "clickable": true
  125. },
  126. children: {
  127. "material": {
  128. "extends": "http://vwf.example.com/aframe/aMaterialComponent.vwf",
  129. "type": "component",
  130. "properties":{
  131. "color": "white"
  132. }
  133. },
  134. "interpolation":
  135. {
  136. "extends": "http://vwf.example.com/aframe/interpolation-component.vwf",
  137. "type": "component",
  138. "properties": {
  139. "enabled": true
  140. }
  141. },
  142. "cursor-listener": {
  143. "extends": "http://vwf.example.com/aframe/app-cursor-listener-component.vwf",
  144. "type": "component"
  145. }
  146. },
  147. events: {
  148. "clickEvent": {
  149. "body": ""
  150. }
  151. }
  152. }
  153. return node
  154. }
  155. this.textProto = function () {
  156. let node = {
  157. "extends": "http://vwf.example.com/aframe/atext.vwf",
  158. "properties": {
  159. "displayName": "text",
  160. "color": "white",
  161. "value": "Text",
  162. "side": "double",
  163. "clickable": true
  164. },
  165. children: {
  166. "interpolation":
  167. {
  168. "extends": "http://vwf.example.com/aframe/interpolation-component.vwf",
  169. "type": "component",
  170. "properties": {
  171. "enabled": true
  172. }
  173. },
  174. "cursor-listener": {
  175. "extends": "http://vwf.example.com/aframe/app-cursor-listener-component.vwf",
  176. "type": "component"
  177. }
  178. },
  179. events: {
  180. "clickEvent": {
  181. "body": ""
  182. }
  183. }
  184. }
  185. return node
  186. }
  187. this.cubeProto = function () {
  188. let node = {
  189. "extends": "http://vwf.example.com/aframe/abox.vwf",
  190. "properties": {
  191. "displayName": "cube",
  192. "height": 1,
  193. "width": 1,
  194. "depth": 1,
  195. "clickable": true
  196. },
  197. children: {
  198. "interpolation":
  199. {
  200. "extends": "http://vwf.example.com/aframe/interpolation-component.vwf",
  201. "type": "component",
  202. "properties": {
  203. "enabled": true
  204. }
  205. },
  206. "cursor-listener": {
  207. "extends": "http://vwf.example.com/aframe/app-cursor-listener-component.vwf",
  208. "type": "component"
  209. },
  210. "material": {
  211. "extends": "http://vwf.example.com/aframe/aMaterialComponent.vwf",
  212. "type": "component",
  213. "properties":{
  214. "color": "white"
  215. }
  216. }
  217. },
  218. events: {
  219. "clickEvent": {
  220. "body": ""
  221. }
  222. }
  223. }
  224. return node
  225. }
  226. this.lightProto = function (lightType) {
  227. var newLightType = lightType
  228. if (!newLightType){
  229. newLightType = "directional"
  230. }
  231. let node = {
  232. "extends": "http://vwf.example.com/aframe/alight.vwf",
  233. "properties": {
  234. "displayName": newLightType,
  235. "type": newLightType,
  236. "clickable": true
  237. },
  238. children: {
  239. "interpolation":
  240. {
  241. "extends": "http://vwf.example.com/aframe/interpolation-component.vwf",
  242. "type": "component",
  243. "properties": {
  244. "enabled": true
  245. }
  246. },
  247. "cursor-listener": {
  248. "extends": "http://vwf.example.com/aframe/app-cursor-listener-component.vwf",
  249. "type": "component"
  250. }
  251. },
  252. events: {
  253. "clickEvent": {
  254. "body": ""
  255. }
  256. }
  257. }
  258. return node
  259. }
  260. this.planeProto = function () {
  261. let node = {
  262. "extends": "http://vwf.example.com/aframe/aplane.vwf",
  263. "properties": {
  264. "displayName": "plane",
  265. "height": 1,
  266. "width": 1,
  267. "clickable": true
  268. },
  269. children: {
  270. "material": {
  271. "extends": "http://vwf.example.com/aframe/aMaterialComponent.vwf",
  272. "type": "component",
  273. "properties": {
  274. "side": "double",
  275. "color": "white"
  276. }
  277. },
  278. "interpolation":
  279. {
  280. "extends": "http://vwf.example.com/aframe/interpolation-component.vwf",
  281. "type": "component",
  282. "properties": {
  283. "enabled": true
  284. }
  285. },
  286. "cursor-listener": {
  287. "extends": "http://vwf.example.com/aframe/app-cursor-listener-component.vwf",
  288. "type": "component"
  289. }
  290. },
  291. events: {
  292. "clickEvent": {
  293. "body": ""
  294. }
  295. }
  296. }
  297. return node
  298. }
  299. this.createModelObj = function (mtlSrc, objSrc, name, avatar) {
  300. var self = this;
  301. var position = "0 0 0";
  302. var nodeName = this.GUID();
  303. if (avatar) {
  304. let myAvatar = this.children[avatar];
  305. let cursorNode = myAvatar.avatarNode.myHead.myCursor.vis;
  306. if (cursorNode) {
  307. position = cursorNode.worldPosition;
  308. //console.log(position);
  309. }
  310. }
  311. let modelNode = {
  312. "extends": "http://vwf.example.com/aframe/aobjmodel.vwf",
  313. "properties": {
  314. "src": '#' + objSrc,
  315. "mtl": '#' + mtlSrc,
  316. "position": position
  317. },
  318. children:{
  319. "interpolation":
  320. {
  321. "extends": "http://vwf.example.com/aframe/interpolation-component.vwf",
  322. "type": "component",
  323. "properties": {
  324. "enabled": true
  325. }
  326. }
  327. }
  328. }
  329. if (name) {
  330. modelNode.properties.displayName = name;
  331. }
  332. self.children.create(nodeName, modelNode, function( child ) {
  333. if (avatar) child.lookAt(self.children[avatar].worldPosition)
  334. });
  335. }
  336. this.createModel = function (modelType, modelSrc, avatar) {
  337. var self = this;
  338. let tagName = modelType + '-ASSET-'+ this.GUID();
  339. let tagNode = {
  340. "extends": "http://vwf.example.com/aframe/a-asset-item.vwf",
  341. "properties": {
  342. "itemID": tagName,
  343. "itemSrc": modelSrc
  344. }
  345. }
  346. this.children.create(tagName, tagNode, function( child ) {
  347. let nodeName = modelType + '-MODEL-'+self.GUID();
  348. var position = "0 0 0";
  349. if (avatar) {
  350. let myAvatar = self.children[avatar];
  351. let cursorNode = myAvatar.avatarNode.myHead.myCursor.vis;
  352. if (cursorNode) {
  353. position = cursorNode.worldPosition;
  354. //console.log(position);
  355. }
  356. }
  357. const protos = {
  358. DAE: "http://vwf.example.com/aframe/acolladamodel.vwf",
  359. OBJ: "http://vwf.example.com/aframe/aobjmodel.vwf",
  360. GLTF: "http://vwf.example.com/aframe/agltfmodel.vwf"
  361. }
  362. let extendsName = Object.entries(protos).filter(el => el[0] == modelType)[0];
  363. let modelNode = {
  364. "extends": extendsName[1],
  365. "properties": {
  366. "src": '#' + child.itemID,
  367. "position": position
  368. },
  369. children:{
  370. "interpolation":
  371. {
  372. "extends": "http://vwf.example.com/aframe/interpolation-component.vwf",
  373. "type": "component",
  374. "properties": {
  375. "enabled": true
  376. }
  377. }
  378. }
  379. }
  380. self.children.create(nodeName, modelNode, function( child ) {
  381. if (avatar) child.lookAt(self.children[avatar].worldPosition)
  382. });
  383. });
  384. }
  385. this.createAssetResource = function(resType, resSrc){
  386. var self = this;
  387. const protos = {
  388. IMG: "http://vwf.example.com/aframe/a-asset-image-item.vwf",
  389. AUDIO: "http://vwf.example.com/aframe/a-asset-audio-item.vwf",
  390. VIDEO: "http://vwf.example.com/aframe/a-asset-video-item.vwf",
  391. ITEM: "http://vwf.example.com/aframe/a-asset-item.vwf"
  392. };
  393. let extendsName = Object.entries(protos).filter(el => el[0] == resType)[0];
  394. let tagName = resType + '-ASSET-'+ this.GUID();
  395. let tagNode = {
  396. "extends": extendsName[1],
  397. "properties": {
  398. "itemID": tagName,
  399. "itemSrc": resSrc
  400. }
  401. }
  402. this.children.create(tagName, tagNode);
  403. }
  404. this.createPrimitive = function (type, params, name, node, avatar) {
  405. var position = "0 0 0";
  406. var nodeName = name;
  407. if (!nodeName) {
  408. nodeName = this.GUID();
  409. }
  410. if (avatar) {
  411. let myAvatar = this.children[avatar];
  412. let cursorNode = myAvatar.avatarNode.myHead.myCursor.vis;
  413. if (cursorNode) {
  414. position = cursorNode.worldPosition;
  415. //console.log(position);
  416. }
  417. }
  418. var newNode = {};
  419. switch (type) {
  420. case "cube":
  421. newNode = this.cubeProto();
  422. break;
  423. case "sphere":
  424. newNode = this.sphereProto();
  425. break;
  426. case "plane":
  427. newNode = this.planeProto();
  428. break;
  429. case "light":
  430. newNode = this.lightProto(params);
  431. break;
  432. case "text":
  433. newNode = this.textProto(params);
  434. break;
  435. case "cylinder":
  436. newNode = this.cylinderProto();
  437. break;
  438. case "cone":
  439. newNode = this.coneProto();
  440. break;
  441. default:
  442. newNode = undefined;
  443. break;
  444. }
  445. var self = this;
  446. if (newNode) {
  447. newNode.properties.position = position;
  448. this.children.create(nodeName, newNode, function( child ) {
  449. if (avatar)child.lookAt(self.children[avatar].worldPosition)
  450. });
  451. }
  452. }
  453. this.createImage = function (imgSrc, name, node, avatar) {
  454. var self = this;
  455. var position = "0 0 0";
  456. var nodeName = name;
  457. if (!nodeName) {
  458. nodeName = this.GUID();
  459. }
  460. if (avatar) {
  461. let myAvatar = this.children[avatar];
  462. let cursorNode = myAvatar.avatarNode.myHead.myCursor.vis;
  463. if (cursorNode) {
  464. position = cursorNode.worldPosition;
  465. //console.log(position);
  466. }
  467. }
  468. let tagName = 'IMG-ASSET-'+ this.GUID();
  469. let tagNode = {
  470. "extends": "http://vwf.example.com/aframe/a-asset-image-item.vwf",
  471. "properties": {
  472. "itemID": tagName,
  473. "itemSrc": imgSrc
  474. }
  475. }
  476. this.children.create(tagName, tagNode, function( child ) {
  477. let allNodes = vwf.models["vwf/model/aframe"].model.state.nodes;
  478. let imgAssetNode = allNodes[child.id];
  479. imgAssetNode.aframeObj.onload = function(){
  480. // console.log(imgAssetNode);
  481. let nodeName = 'IMAGE-'+self.GUID();
  482. var position = "0 0 0";
  483. if (avatar) {
  484. let myAvatar = self.children[avatar];
  485. let cursorNode = myAvatar.avatarNode.myHead.myCursor.vis;
  486. if (cursorNode) {
  487. position = cursorNode.worldPosition;
  488. //console.log(position);
  489. }
  490. }
  491. let newNode = self.planeProto();
  492. newNode.properties.displayName = "image";
  493. newNode.children.material.properties.src = '#' + child.itemID;
  494. newNode.properties.position = position;
  495. newNode.properties.width = child.width;
  496. newNode.properties.height = child.height;
  497. newNode.properties.scale = [0.003, 0.003, 0.003];
  498. self.children.create(nodeName, newNode, function( child ) {
  499. if (avatar) child.lookAt(self.children[avatar].worldPosition)
  500. });
  501. }
  502. });
  503. }
  504. this.createVideo = function (vidSrc, name, node, avatar) {
  505. var self = this;
  506. var position = "0 0 0";
  507. var nodeName = name;
  508. if (!nodeName) {
  509. nodeName = this.GUID();
  510. }
  511. if (avatar) {
  512. let myAvatar = this.children[avatar];
  513. let cursorNode = myAvatar.avatarNode.myHead.myCursor.vis;
  514. if (cursorNode) {
  515. position = cursorNode.worldPosition;
  516. //console.log(position);
  517. }
  518. }
  519. let tagName = 'VIDEO-ASSET-'+ this.GUID();
  520. let tagNode = {
  521. "extends": "http://vwf.example.com/aframe/a-asset-video-item.vwf",
  522. "properties": {
  523. "itemID": tagName,
  524. "itemSrc": vidSrc
  525. }
  526. }
  527. this.children.create(tagName, tagNode, function( child ) {
  528. let allNodes = vwf.models["vwf/model/aframe"].model.state.nodes;
  529. let imgAssetNode = allNodes[child.id];
  530. imgAssetNode.aframeObj.onloadeddata = function(){
  531. //console.log(imgAssetNode);
  532. let nodeName = 'VIDEO-'+self.GUID();
  533. var position = "0 0 0";
  534. if (avatar) {
  535. let myAvatar = self.children[avatar];
  536. let cursorNode = myAvatar.avatarNode.myHead.myCursor.vis;
  537. if (cursorNode) {
  538. position = cursorNode.worldPosition;
  539. //console.log(position);
  540. }
  541. }
  542. let newNode = self.planeProto();
  543. newNode.properties.displayName = "video";
  544. newNode.children.material.properties.src = '#' + child.itemID;
  545. newNode.properties.position = position;
  546. // newNode.properties.width = 3;
  547. // newNode.properties.height = 1.75;
  548. newNode.properties.width = child.videoWidth;
  549. newNode.properties.height = child.videoHeight;
  550. newNode.properties.scale = [0.003, 0.003, 0.003];
  551. self.children.create(nodeName, newNode, function( child ) {
  552. if (avatar) child.lookAt(self.children[avatar].worldPosition)
  553. });
  554. }
  555. });
  556. }
  557. this.createAudio = function (itemSrc, name, node, avatar) {
  558. var self = this;
  559. var position = "0 0 0";
  560. var nodeName = name;
  561. if (!nodeName) {
  562. nodeName = this.GUID();
  563. }
  564. if (avatar) {
  565. let myAvatar = this.children[avatar];
  566. let cursorNode = myAvatar.avatarNode.myHead.myCursor.vis;
  567. if (cursorNode) {
  568. position = cursorNode.worldPosition;
  569. //console.log(position);
  570. }
  571. }
  572. let tagName = 'AUDIO-ASSET-'+ this.GUID();
  573. let tagNode = {
  574. "extends": "http://vwf.example.com/aframe/a-asset-audio-item.vwf",
  575. "properties": {
  576. "itemID": tagName,
  577. "itemSrc": itemSrc
  578. }
  579. }
  580. this.children.create(tagName, tagNode, function( child ) {
  581. // let allNodes = vwf.models["vwf/model/aframe"].model.state.nodes;
  582. // let itemAssetNode = allNodes[child.id];
  583. // itemAssetNode.aframeObj.onload = function(){
  584. // console.log(itemAssetNode);
  585. let nodeName = 'AUDIO-'+self.GUID();
  586. var position = "0 0 0";
  587. if (avatar) {
  588. let myAvatar = self.children[avatar];
  589. let cursorNode = myAvatar.avatarNode.myHead.myCursor.vis;
  590. if (cursorNode) {
  591. position = cursorNode.worldPosition;
  592. //console.log(position);
  593. }
  594. }
  595. let newNode = self.cubeProto();
  596. newNode.properties.displayName = "audio";
  597. newNode.properties.position = position;
  598. newNode.properties.width = 0.3;
  599. newNode.properties.height = 0.3;
  600. newNode.properties.depth= 0.3;
  601. newNode.children.material.properties.opacity = 0.5;
  602. newNode.children.material.properties.color = "yellow";
  603. newNode.children.sound = {
  604. "extends": "http://vwf.example.com/aframe/a-sound-component.vwf",
  605. "type": "component",
  606. "properties": {
  607. "autoplay": true,
  608. "loop": true,
  609. "src": '#' + child.itemID
  610. }
  611. };
  612. self.children.create(nodeName, newNode, function( child ) {
  613. if (avatar) child.lookAt(self.children[avatar].worldPosition)
  614. });
  615. // }
  616. });
  617. }
  618. this.createGooglePoly = function(polyID, name, node, avatar){
  619. // all done in aframe view driver
  620. let params = [polyID, name, node, avatar];
  621. this.loadGooglePolyAsset(params)
  622. }
  623. this.loadGooglePolyAsset = function( params ) {
  624. var self = this;
  625. const API_KEY = "AIzaSyCGx2_idlUJ88yW5GBkOllIkyxJyKbEgDk";
  626. const id = params[0];
  627. const avatarID = params[3];
  628. var url = `https://poly.googleapis.com/v1/assets/${id}/?key=${API_KEY}`;
  629. var request = new XMLHttpRequest();
  630. request.open( 'GET', url, true );
  631. request.addEventListener( 'load', function ( event ) {
  632. var asset = JSON.parse( event.target.response );
  633. // asset_name.textContent = asset.displayName;
  634. // asset_author.textContent = asset.authorName;
  635. var format = asset.formats.find( format => { return format.formatType === 'OBJ'; } );
  636. if ( format !== undefined ) {
  637. var obj = format.root;
  638. var mtl = format.resources.find( resource => { return resource.url.endsWith( 'mtl' ) } );
  639. var path = obj.url.slice( 0, obj.url.indexOf( obj.relativePath ) );
  640. //const createOnNodeID = vwf.application();
  641. let mtlName = 'MTL-ASSET-'+ self.GUID();
  642. let mtlNode = {
  643. "extends": "http://vwf.example.com/aframe/a-asset-item.vwf",
  644. "properties": {
  645. "itemID": mtlName,
  646. "itemSrc": mtl.url
  647. }
  648. }
  649. self.children.create(mtlName, mtlNode, function( mtlChild ) {
  650. let objName = 'OBJ-ASSET-'+ self.GUID();
  651. let objNode = {
  652. "extends": "http://vwf.example.com/aframe/a-asset-item.vwf",
  653. "properties": {
  654. "itemID": objName,
  655. "itemSrc": obj.url
  656. }
  657. }
  658. self.children.create(objName, objNode, function( objChild ) {
  659. self.createModelObj(mtlChild.itemID, objChild.itemID, asset.displayName, avatarID);
  660. })
  661. })
  662. }
  663. } );
  664. request.send( null );
  665. }
  666. this.GUID = function () {
  667. var self = this;
  668. var S4 = function () {
  669. return Math.floor(
  670. self.random() * 0x10000 /* 65536 */
  671. ).toString(16);
  672. };
  673. return (
  674. S4() + S4() + "-" +
  675. S4() + "-" +
  676. S4() + "-" +
  677. S4() + "-" +
  678. S4() + S4() + S4()
  679. );
  680. }
  681. this.smallRandomId = function() {
  682. return '_' + this.random().toString(36).substr(2, 9);
  683. }
  684. this.assetImgProto = function () {
  685. let node = {
  686. "extends": "http://vwf.example.com/aframe/a-asset-image-item.vwf",
  687. "properties": {
  688. },
  689. }
  690. return node
  691. }
  692. this.createAssetItemImg = function(){
  693. console.log("create new asset item for img");
  694. let nodeName = "asset-item-img-" + this.smallRandomId();
  695. let newNode = {
  696. "extends": "http://vwf.example.com/aframe/a-asset-image-item.vwf",
  697. "properties": {
  698. itemID: nodeName,
  699. itemSrc: ""
  700. }
  701. }
  702. this.children.create(nodeName, newNode);
  703. }
  704. this.deleteNode = function(nodeName){
  705. let node = this.children[nodeName];
  706. if (node) this.children.delete(node);
  707. }