aframeComponent.js 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620
  1. /*
  2. The MIT License (MIT)
  3. Copyright (c) 2014-2020 Nikolai Suslov and the Krestianstvo.org project contributors. (https://github.com/NikolaySuslov/livecodingspace/blob/master/LICENSE.md)
  4. */
  5. // VWF & A-Frame components model driver
  6. import { Fabric } from '/core/vwf/fabric.js';
  7. class AFrameComponentModel extends Fabric {
  8. constructor(module) {
  9. console.log("AFrameComponentModel constructor");
  10. super(module, "Model");
  11. }
  12. factory() {
  13. let _self_ = this;
  14. return this.load(this.module,
  15. {
  16. // == Module Definition ====================================================================
  17. // -- pipeline -----------------------------------------------------------------------------
  18. // pipeline: [ log ], // vwf <=> log <=> scene
  19. // -- initialize ---------------------------------------------------------------------------
  20. initialize: function () {
  21. let self = this;
  22. this.state = {
  23. nodes: {},
  24. scenes: {},
  25. prototypes: {},
  26. createLocalNode: function (nodeID, childID, childExtendsID, childImplementsIDs,
  27. childSource, childType, childIndex, childName, callback) {
  28. return {
  29. "parentID": nodeID,
  30. "ID": childID,
  31. "extendsID": childExtendsID,
  32. "implementsIDs": childImplementsIDs,
  33. "source": childSource,
  34. "type": childType,
  35. "name": childName,
  36. "prototypes": undefined,
  37. "aframeObj": undefined,
  38. "componentName": undefined
  39. };
  40. },
  41. isComponentClass: function (prototypes, classID) {
  42. if (prototypes) {
  43. for (var i = 0; i < prototypes.length; i++) {
  44. if (prototypes[i] === classID) {
  45. //console.info( "prototypes[ i ]: " + prototypes[ i ] );
  46. return true;
  47. }
  48. }
  49. }
  50. return false;
  51. },
  52. isComponentNode: function (prototypes) {
  53. var found = false;
  54. if (prototypes) {
  55. for (var i = 0; i < prototypes.length && !found; i++) {
  56. found = (prototypes[i] === "proxy/aframe/componentNode.vwf");
  57. }
  58. }
  59. return found;
  60. },
  61. isAAnimMixerDefinition: function (prototypes) {
  62. var found = false;
  63. if (prototypes) {
  64. for (var i = 0; i < prototypes.length && !found; i++) {
  65. found = (prototypes[i] == "proxy/aframe/anim-mixer-component.vwf");
  66. }
  67. }
  68. return found;
  69. },
  70. isAInterpolationDefinition: function (prototypes) {
  71. var found = false;
  72. if (prototypes) {
  73. for (var i = 0; i < prototypes.length && !found; i++) {
  74. found = (prototypes[i] == "proxy/aframe/interpolation-component.vwf");
  75. }
  76. }
  77. return found;
  78. },
  79. isALinePathDefinition: function (prototypes) {
  80. var found = false;
  81. if (prototypes) {
  82. for (var i = 0; i < prototypes.length && !found; i++) {
  83. found = (prototypes[i] == "proxy/aframe/linepath.vwf");
  84. }
  85. }
  86. return found;
  87. },
  88. isAMaterialDefinition: function (prototypes) {
  89. var found = false;
  90. if (prototypes) {
  91. for (var i = 0; i < prototypes.length && !found; i++) {
  92. found = (prototypes[i] == "proxy/aframe/aMaterialComponent.vwf");
  93. }
  94. }
  95. return found;
  96. },
  97. isASoundDefinition: function (prototypes) {
  98. var found = false;
  99. if (prototypes) {
  100. for (var i = 0; i < prototypes.length && !found; i++) {
  101. found = (prototypes[i] == "proxy/aframe/a-sound-component.vwf");
  102. }
  103. }
  104. return found;
  105. },
  106. isAViewOffsetCameraDefinition: function (prototypes) {
  107. var found = false;
  108. if (prototypes) {
  109. for (var i = 0; i < prototypes.length && !found; i++) {
  110. found = (prototypes[i] == "proxy/aframe/viewOffsetCamera-component.vwf");
  111. }
  112. }
  113. return found;
  114. },
  115. isAGizmoDefinition: function (prototypes) {
  116. var found = false;
  117. if (prototypes) {
  118. for (var i = 0; i < prototypes.length && !found; i++) {
  119. found = (prototypes[i] == "proxy/aframe/gizmoComponent.vwf");
  120. }
  121. }
  122. return found;
  123. },
  124. isAFogDefinition: function (prototypes) {
  125. var found = false;
  126. if (prototypes) {
  127. for (var i = 0; i < prototypes.length && !found; i++) {
  128. found = (prototypes[i] == "proxy/aframe/aSceneFogComponent.vwf");
  129. }
  130. }
  131. return found;
  132. },
  133. isAShadowDefinition: function (prototypes) {
  134. var found = false;
  135. if (prototypes) {
  136. for (var i = 0; i < prototypes.length && !found; i++) {
  137. found = (prototypes[i] == "proxy/aframe/shadowComponent.vwf");
  138. }
  139. }
  140. return found;
  141. },
  142. isAAabbColliderDefinition: function (prototypes) {
  143. var found = false;
  144. if (prototypes) {
  145. for (var i = 0; i < prototypes.length && !found; i++) {
  146. found = (prototypes[i] == "proxy/aframe/aabb-collider-component.vwf");
  147. }
  148. }
  149. return found;
  150. },
  151. isAMirrorDefinition: function (prototypes) {
  152. var found = false;
  153. if (prototypes) {
  154. for (var i = 0; i < prototypes.length && !found; i++) {
  155. found = (prototypes[i] == "proxy/aframe/a-mirror-component.vwf");
  156. }
  157. }
  158. return found;
  159. },
  160. isARayCasterDefinition: function (prototypes) {
  161. var found = false;
  162. if (prototypes) {
  163. for (var i = 0; i < prototypes.length && !found; i++) {
  164. found = (prototypes[i] == "proxy/aframe/raycasterComponent.vwf");
  165. }
  166. }
  167. return found;
  168. },
  169. isARayCasterListenerDefinition: function (prototypes) {
  170. var found = false;
  171. if (prototypes) {
  172. for (var i = 0; i < prototypes.length && !found; i++) {
  173. found = (prototypes[i] == "proxy/aframe/app-raycaster-listener-component.vwf");
  174. }
  175. }
  176. return found;
  177. },
  178. isAAabbColliderListenerDefinition: function (prototypes) {
  179. var found = false;
  180. if (prototypes) {
  181. for (var i = 0; i < prototypes.length && !found; i++) {
  182. found = (prototypes[i] == "proxy/aframe/app-aabb-collider-listener-component.vwf");
  183. }
  184. }
  185. return found;
  186. },
  187. isALineDefinition: function (prototypes) {
  188. var found = false;
  189. if (prototypes) {
  190. for (var i = 0; i < prototypes.length && !found; i++) {
  191. found = (prototypes[i] == "proxy/aframe/lineComponent.vwf");
  192. }
  193. }
  194. return found;
  195. },
  196. isGearVRControlsDefinition: function (prototypes) {
  197. var found = false;
  198. if (prototypes) {
  199. for (var i = 0; i < prototypes.length && !found; i++) {
  200. found = (prototypes[i] == "proxy/aframe/gearvr-controlsComponent.vwf");
  201. }
  202. }
  203. return found;
  204. },
  205. isComponentNodeDefinition: function (prototypes) {
  206. var found = false;
  207. if (prototypes) {
  208. for (var i = 0; i < prototypes.length && !found; i++) {
  209. found = (prototypes[i] == "proxy/aframe/componentNode.vwf");
  210. }
  211. }
  212. return found;
  213. },
  214. isComponentDefinition: function (prototypes) {
  215. var found = false;
  216. if (prototypes) {
  217. for (var i = 0; i < prototypes.length && !found; i++) {
  218. found = (prototypes[i] == "proxy/aframe/aentityComponent.vwf");
  219. }
  220. }
  221. return found;
  222. },
  223. checkAttribute: function(aframeObj){
  224. if(aframeObj.el.getAttribute(aframeObj.compName)){
  225. aframeObj.el.removeAttribute(aframeObj.compName);
  226. }
  227. },
  228. setAFrameObject: function (node, config) {
  229. var protos = node.prototypes;
  230. var aframeObj = {};
  231. var sceneEl = document.querySelector('a-scene');
  232. aframeObj.id = node.parentID;
  233. // aframeObj.el = sceneEl.children[node.parentID];
  234. aframeObj.el = Array.from(sceneEl.querySelectorAll('*')).filter(item => { return item.id == aframeObj.id })[0];
  235. if (this.isComponentClass(protos, "proxy/aframe/lineComponent.vwf")) {
  236. // aframeObj.id = node.parentID;
  237. // aframeObj.el = sceneEl.children[node.parentID];
  238. if (node.name !== 'line') {
  239. aframeObj.compName = node.name;
  240. } else {
  241. aframeObj.compName = "line";
  242. }
  243. //aframeObj.el.setAttribute(node.type, {});
  244. this.checkAttribute(aframeObj);
  245. aframeObj.el.setAttribute(aframeObj.compName, {});
  246. }
  247. if (this.isComponentClass(protos, "proxy/aframe/gizmoComponent.vwf")) {
  248. // aframeObj.el.setAttribute(node.type, {});
  249. aframeObj.compName = "gizmo";
  250. this.checkAttribute(aframeObj);
  251. aframeObj.el.setAttribute(aframeObj.compName, {});
  252. }
  253. if (this.isComponentClass(protos, "proxy/aframe/aSceneFogComponent.vwf")) {
  254. // aframeObj.el.setAttribute(node.type, {});
  255. aframeObj = {};
  256. //var sceneEl = document.querySelector('a-scene');
  257. aframeObj.id = node.parentID;
  258. aframeObj.el = document.querySelector('a-scene');
  259. aframeObj.compName = "fog";
  260. this.checkAttribute(aframeObj);
  261. aframeObj.el.setAttribute('fog', {});
  262. }
  263. if (this.isComponentClass(protos, "proxy/aframe/raycasterComponent.vwf")) {
  264. // aframeObj.el.setAttribute(node.type, {});
  265. aframeObj.compName = "raycaster";
  266. this.checkAttribute(aframeObj);
  267. aframeObj.el.setAttribute(aframeObj.compName, {});
  268. }
  269. if (this.isComponentClass(protos, "proxy/aframe/shadowComponent.vwf")) {
  270. // aframeObj.el.setAttribute(node.type, {});
  271. aframeObj.compName = "shadow";
  272. this.checkAttribute(aframeObj);
  273. aframeObj.el.setAttribute(aframeObj.compName, {});
  274. }
  275. if (this.isComponentClass(protos, "proxy/aframe/aabb-collider-component.vwf")) {
  276. // aframeObj.el.setAttribute(node.type, {});
  277. aframeObj.compName = "aabb-collider";
  278. this.checkAttribute(aframeObj);
  279. aframeObj.el.setAttribute(aframeObj.compName, {});
  280. aframeObj.el.addEventListener('hitstart', function (evt) {
  281. let elms = evt.detail.intersectedEls;
  282. let el = elms ?
  283. elms.map(m=> {return m.id})
  284. : null;
  285. vwf_view.kernel.fireEvent(evt.target.id, "fromhitstartEvent", [el]);
  286. })
  287. aframeObj.el.addEventListener('hitend', function (evt) {
  288. vwf_view.kernel.fireEvent(evt.target.id, "fromhitendEvent", [null]);
  289. })
  290. }
  291. if (this.isComponentClass(protos, "proxy/aframe/a-mirror-component.vwf")) {
  292. // aframeObj.el.setAttribute(node.type, {});
  293. aframeObj.compName = "mirror";
  294. this.checkAttribute(aframeObj);
  295. aframeObj.el.setAttribute(aframeObj.compName, {});
  296. }
  297. if (this.isComponentClass(protos, "proxy/aframe/viewOffsetCamera-component.vwf")) {
  298. // aframeObj.el.setAttribute(node.type, {});
  299. aframeObj.compName = "viewoffset";
  300. this.checkAttribute(aframeObj);
  301. aframeObj.el.setAttribute(aframeObj.compName, {});
  302. }
  303. if (this.isComponentClass(protos, "proxy/aframe/streamSoundComponent.vwf")) {
  304. // aframeObj.el.setAttribute(node.type, {});
  305. aframeObj.compName = "streamsound";
  306. aframeObj.el.setAttribute(aframeObj.compName, {});
  307. }
  308. if (this.isComponentClass(protos, "proxy/aframe/linepath.vwf")) {
  309. // aframeObj.el.setAttribute(node.type, {});
  310. aframeObj.compName = "linepath";
  311. this.checkAttribute(aframeObj);
  312. aframeObj.el.setAttribute(aframeObj.compName, {});
  313. }
  314. if (this.isComponentClass(protos, "proxy/aframe/aMaterialComponent.vwf")) {
  315. // aframeObj.el.setAttribute(node.type, {});
  316. aframeObj.compName = "material";
  317. // let name = aframeObj.compName = "material";
  318. // if(aframeObj.el.getAttribute(name)){
  319. // aframeObj.el.removeAttribute(name);
  320. // }
  321. this.checkAttribute(aframeObj);
  322. aframeObj.el.setAttribute(aframeObj.compName, {});
  323. }
  324. if (this.isComponentClass(protos, "proxy/aframe/a-sound-component.vwf")) {
  325. // aframeObj.el.setAttribute(node.type, {});
  326. aframeObj.compName = "sound";
  327. this.checkAttribute(aframeObj);
  328. aframeObj.el.setAttribute(aframeObj.compName, {});
  329. }
  330. if (this.isComponentClass(protos, "proxy/aframe/interpolation-component.vwf")) {
  331. // aframeObj.el.setAttribute(node.type, {});
  332. aframeObj.compName = "interpolation";
  333. this.checkAttribute(aframeObj);
  334. aframeObj.el.setAttribute(aframeObj.compName, {});
  335. }
  336. if (this.isComponentClass(protos, "proxy/aframe/anim-mixer-component.vwf")) {
  337. // aframeObj.el.setAttribute(node.type, {});
  338. aframeObj.compName = "animation-mixer";
  339. this.checkAttribute(aframeObj);
  340. aframeObj.el.setAttribute(aframeObj.compName, {});
  341. }
  342. if (this.isComponentClass(protos, "proxy/aframe/app-envmap-component.vwf")) {
  343. // aframeObj.el.setAttribute(node.type, {});
  344. aframeObj.compName = "envmap";
  345. this.checkAttribute(aframeObj);
  346. aframeObj.el.setAttribute(aframeObj.compName, {});
  347. }
  348. if (this.isComponentClass(protos, "proxy/aframe/app-avatarbvh-component.vwf")) {
  349. // aframeObj.el.setAttribute(node.type, {});
  350. aframeObj.compName = "avatarbvh";
  351. this.checkAttribute(aframeObj);
  352. aframeObj.el.setAttribute(aframeObj.compName, {});
  353. }
  354. if (this.isComponentClass(protos, "proxy/aframe/app-sun-component.vwf")) {
  355. // aframeObj.el.setAttribute(node.type, {});
  356. aframeObj.compName = "sun";
  357. aframeObj.el.setAttribute('id', "sun");
  358. this.checkAttribute(aframeObj);
  359. aframeObj.el.setAttribute(aframeObj.compName, {});
  360. }
  361. if (this.isComponentClass(protos, "proxy/aframe/app-skyshader-component.vwf")) {
  362. // aframeObj.el.setAttribute(node.type, {});
  363. aframeObj.compName = "skyshader";
  364. this.checkAttribute(aframeObj);
  365. aframeObj.el.setAttribute(aframeObj.compName, {});
  366. }
  367. if (this.isComponentClass(protos, "proxy/aframe/app-raycaster-listener-component.vwf")) {
  368. // aframeObj.el.setAttribute(node.type, {});
  369. aframeObj.compName = "raycaster-listener";
  370. this.checkAttribute(aframeObj);
  371. aframeObj.el.setAttribute(aframeObj.compName, {});
  372. }
  373. if (this.isComponentClass(protos, "proxy/aframe/app-aabb-collider-listener-component.vwf")) {
  374. // aframeObj.el.setAttribute(node.type, {});
  375. aframeObj.compName = "aabb-collider-listener";
  376. this.checkAttribute(aframeObj);
  377. aframeObj.el.setAttribute(aframeObj.compName, {});
  378. }
  379. if (this.isComponentClass(protos, "proxy/aframe/app-cursor-listener-component.vwf")) {
  380. // aframeObj.el.setAttribute(node.type, {});
  381. aframeObj.compName = "cursor-listener";
  382. this.checkAttribute(aframeObj);
  383. aframeObj.el.setAttribute(aframeObj.compName, {});
  384. }
  385. return aframeObj;
  386. },
  387. addNodeToHierarchy: function (node) {
  388. if (node.aframeObj) {
  389. if (this.nodes[node.parentID] !== undefined) {
  390. var parent = this.nodes[node.parentID];
  391. if (parent.aframeObj) {
  392. if (parent.children === undefined) {
  393. parent.children = [];
  394. }
  395. parent.children.push(node.ID);
  396. }
  397. }
  398. }
  399. }
  400. };
  401. this.state.kernel = this.kernel.kernel.kernel;
  402. this.aframeComponentDef = {
  403. 'A-SOUND': [
  404. "autoplay", "distanceModel", "loop", "maxDistance", "on", "poolSize", "refDistance",
  405. "rolloffFactor", "src", "volume"
  406. ],
  407. 'aabb-collider': [
  408. "collideNonVisible", "debug", "enabled", "objects", "interval"
  409. ],
  410. 'mirror': [
  411. "camera", "renderothermirror"
  412. ]
  413. }
  414. //this.state.kernel = this.kernel.kernel.kernel;
  415. },
  416. // == Model API ============================================================================
  417. // -- creatingNode -------------------------------------------------------------------------
  418. creatingNode: function (nodeID, childID, childExtendsID, childImplementsIDs,
  419. childSource, childType, childIndex, childName, callback /* ( ready ) */) {
  420. let self = this;
  421. // If the parent nodeID is 0, this node is attached directly to the root and is therefore either
  422. // the scene or a prototype. In either of those cases, save the uri of the new node
  423. var childURI = (nodeID === 0 ? childIndex : undefined);
  424. var appID = this.kernel.application();
  425. // If the node being created is a prototype, construct it and add it to the array of prototypes,
  426. // and then return
  427. var prototypeID = _self_.utility.ifPrototypeGetId(appID, this.state.prototypes, nodeID, childID);
  428. if (prototypeID !== undefined) {
  429. this.state.prototypes[prototypeID] = {
  430. parentID: nodeID,
  431. ID: childID,
  432. extendsID: childExtendsID,
  433. implementsID: childImplementsIDs,
  434. source: childSource,
  435. type: childType,
  436. name: childName
  437. };
  438. return;
  439. }
  440. var protos = _self_.constructor.getPrototypes(this.kernel, childExtendsID);
  441. //var kernel = this.kernel.kernel.kernel;
  442. var node;
  443. if (this.state.isComponentNode(protos)) {
  444. // Create the local copy of the node properties
  445. if (this.state.nodes[childID] === undefined) {
  446. this.state.nodes[childID] = this.state.createLocalNode(nodeID, childID, childExtendsID, childImplementsIDs,
  447. childSource, childType, childIndex, childName, callback);
  448. }
  449. node = this.state.nodes[childID];
  450. node.prototypes = protos;
  451. //node.aframeObj = createAFrameObject(node);
  452. node.aframeObj = this.state.setAFrameObject(node);
  453. // addNodeToHierarchy(node);
  454. //notifyDriverOfPrototypeAndBehaviorProps();
  455. }
  456. },
  457. // -- initializingNode -------------------------------------------------------------------------
  458. // initializingNode: function( nodeID, childID, childExtendsID, childImplementsIDs,
  459. // childSource, childType, childIndex, childName ) {
  460. // },
  461. // -- deletingNode -------------------------------------------------------------------------
  462. deletingNode: function (nodeID, replaceFlag) {
  463. if (this.state.nodes[nodeID] !== undefined) {
  464. var node = this.state.nodes[nodeID];
  465. if (node.aframeObj.compName !== undefined) {
  466. // removes and destroys object
  467. if(!replaceFlag)
  468. node.aframeObj.el.removeAttribute(node.aframeObj.compName);
  469. node.aframeObj = undefined;
  470. }
  471. delete this.state.nodes[nodeID];
  472. }
  473. },
  474. // -- initializingProperty -----------------------------------------------------------------
  475. initializingProperty: function (nodeID, propertyName, propertyValue) {
  476. var value = undefined;
  477. var node = this.state.nodes[nodeID];
  478. if (node !== undefined) {
  479. value = this.settingProperty(nodeID, propertyName, propertyValue);
  480. }
  481. return value;
  482. },
  483. // -- creatingProperty ---------------------------------------------------------------------
  484. creatingProperty: function (nodeID, propertyName, propertyValue) {
  485. return this.initializingProperty(nodeID, propertyName, propertyValue);
  486. },
  487. // -- settingProperty ----------------------------------------------------------------------
  488. settingProperty: function (nodeID, propertyName, propertyValue) {
  489. let self = this;
  490. var node = this.state.nodes[nodeID];
  491. var value = undefined;
  492. if (node && node.aframeObj && _self_.utility.validObject(propertyValue)) {
  493. var aframeObject = node.aframeObj;
  494. if (self.state.isComponentNodeDefinition(node.prototypes)) {
  495. value = propertyValue;
  496. switch (propertyName) {
  497. default:
  498. value = undefined;
  499. break;
  500. }
  501. }
  502. if (value === undefined && self.state.isComponentDefinition(node.prototypes)) {
  503. value = propertyValue;
  504. switch (propertyName) {
  505. case "compName":
  506. break;
  507. default:
  508. value = undefined;
  509. break;
  510. }
  511. }
  512. if (value === undefined && self.state.isAViewOffsetCameraDefinition(node.prototypes)) {
  513. if (aframeObject.el.getAttribute(aframeObject.compName)) {
  514. value = propertyValue;
  515. let parentNodeAF = aframeObject.el;
  516. // let defs = ['fullWidth', 'fullHeight', 'xoffset', 'yoffset'];
  517. // defs.forEach(element => {
  518. // element == propertyName ? parentNodeAF.setAttribute('viewoffset', element, propertyValue) :
  519. // value = undefined;
  520. // })
  521. switch (propertyName) {
  522. case "fullWidth":
  523. parentNodeAF.setAttribute('viewoffset', 'fullWidth', propertyValue);
  524. break;
  525. case "fullHeight":
  526. parentNodeAF.setAttribute('viewoffset', 'fullHeight', propertyValue);
  527. break;
  528. case "yoffset":
  529. parentNodeAF.setAttribute('viewoffset', 'yoffset', propertyValue);
  530. break;
  531. case "xoffset":
  532. parentNodeAF.setAttribute('viewoffset', 'xoffset', propertyValue);
  533. break;
  534. case "subcamWidth":
  535. parentNodeAF.setAttribute('viewoffset', 'width', propertyValue);
  536. break;
  537. case "subcamHeight":
  538. parentNodeAF.setAttribute('viewoffset', 'height', propertyValue);
  539. break;
  540. default:
  541. value = undefined;
  542. break;
  543. }
  544. }
  545. }
  546. // if (value === undefined && isARayCasterListenerDefinition(node.prototypes)) {
  547. // if (aframeObject.el.getAttribute(aframeObject.compName)) {
  548. // value = propertyValue;
  549. // let parentNodeAF = aframeObject.el;
  550. // switch (propertyName) {
  551. // default:
  552. // value = undefined;
  553. // break;
  554. // }
  555. // }
  556. // }
  557. //aframeObj.el.setAttribute('data-aabb-collider-dynamic', "");
  558. if (value === undefined && self.state.isAAabbColliderListenerDefinition(node.prototypes)) {
  559. if (aframeObject.el.getAttribute(aframeObject.compName)) {
  560. value = propertyValue;
  561. let parentNodeAF = aframeObject.el;
  562. if(propertyName == "dynamic"){
  563. if(propertyValue){
  564. parentNodeAF.setAttribute('data-aabb-collider-dynamic', propertyValue);
  565. } else {
  566. let attr = parentNodeAF.getAttribute('data-aabb-collider-dynamic');
  567. if(attr !== undefined)
  568. parentNodeAF.removeAttribute('data-aabb-collider-dynamic');
  569. }
  570. }
  571. }
  572. }
  573. if (value === undefined && self.state.isAShadowDefinition(node.prototypes)) {
  574. if (aframeObject.el.getAttribute(aframeObject.compName)) {
  575. value = propertyValue;
  576. let parentNodeAF = aframeObject.el;
  577. switch (propertyName) {
  578. case "cast":
  579. parentNodeAF.setAttribute('shadow', 'cast', propertyValue);
  580. break;
  581. case "receive":
  582. parentNodeAF.setAttribute('shadow', 'receive', propertyValue);
  583. break;
  584. default:
  585. value = undefined;
  586. break;
  587. }
  588. }
  589. }
  590. if (value === undefined && self.state.isAMaterialDefinition(node.prototypes)) {
  591. if (aframeObject.el.getAttribute(aframeObject.compName)) {
  592. value = propertyValue;
  593. let parentNodeAF = aframeObject.el;
  594. //let defs = ['color', 'transparent', 'opacity', 'side'];
  595. let schema = Object.keys(AFRAME.components.material.schema).concat(Object.keys(AFRAME.shaders.standard.schema));
  596. let el = schema.includes(propertyName);
  597. if (el) {
  598. parentNodeAF.setAttribute('material', propertyName, propertyValue);
  599. } else {
  600. value = undefined
  601. }
  602. }
  603. }
  604. if (value === undefined && self.state.isASoundDefinition(node.prototypes)) {
  605. if (aframeObject.el.getAttribute(aframeObject.compName)) {
  606. value = propertyValue;
  607. let parentNodeAF = aframeObject.el;
  608. //let defs = ['color', 'transparent', 'opacity', 'side'];
  609. let el = self.aframeComponentDef['A-SOUND'].includes(propertyName);
  610. if (el) {
  611. parentNodeAF.setAttribute('sound', propertyName, propertyValue);
  612. } else {
  613. value = undefined
  614. }
  615. // self.aframeComponentDef['A-SOUND'].forEach(element => {
  616. // element == propertyName ? parentNodeAF.setAttribute('sound', element, propertyValue) :
  617. // value = undefined;
  618. // })
  619. }
  620. }
  621. if (value === undefined && self.state.isAMirrorDefinition(node.prototypes)) {
  622. if (aframeObject.el.getAttribute(aframeObject.compName)) {
  623. value = propertyValue;
  624. let parentNodeAF = aframeObject.el;
  625. let el = self.aframeComponentDef['mirror'].includes(propertyName);
  626. if (el) {
  627. parentNodeAF.setAttribute('mirror', propertyName, propertyValue);
  628. } else {
  629. value = undefined
  630. }
  631. // self.aframeComponentDef['mirror'].forEach(element => {
  632. // element == propertyName ? parentNodeAF.setAttribute('mirror', element, propertyValue) :
  633. // value = undefined;
  634. // })
  635. }
  636. }
  637. if (value === undefined && self.state.isAAabbColliderDefinition(node.prototypes)) {
  638. if (aframeObject.el.getAttribute(aframeObject.compName)) {
  639. value = propertyValue;
  640. let parentNodeAF = aframeObject.el;
  641. //let defs = ['color', 'transparent', 'opacity', 'side'];
  642. let el = self.aframeComponentDef['aabb-collider'].includes(propertyName);
  643. if (el) {
  644. parentNodeAF.setAttribute('aabb-collider', propertyName, propertyValue);
  645. } else {
  646. value = undefined
  647. }
  648. // self.aframeComponentDef['aabb-collider'].forEach(element => {
  649. // element == propertyName ? parentNodeAF.setAttribute('aabb-collider', element, propertyValue) :
  650. // value = undefined;
  651. // })
  652. }
  653. }
  654. if (value === undefined && self.state.isAFogDefinition(node.prototypes)) {
  655. if (aframeObject.el.getAttribute(aframeObject.compName)) {
  656. value = propertyValue;
  657. let parentNodeAF = aframeObject.el;
  658. let defs = ['fogType', 'fogColor', 'density', 'near', 'far'];
  659. defs.forEach(element => {
  660. if (element == propertyName) {
  661. switch (element) {
  662. case 'fogType':
  663. parentNodeAF.setAttribute('fog', 'type', propertyValue);
  664. break;
  665. case 'fogColor':
  666. parentNodeAF.setAttribute('fog', 'color', propertyValue);
  667. break;
  668. default:
  669. value = parentNodeAF.setAttribute('fog', element, propertyValue);
  670. break;
  671. }
  672. } else {
  673. value = undefined
  674. }
  675. // element == propertyName ? parentNodeAF.setAttribute('fog', element, propertyValue) :
  676. // value = undefined;
  677. })
  678. }
  679. }
  680. if (value === undefined && self.state.isARayCasterDefinition(node.prototypes)) {
  681. if (aframeObject.el.getAttribute(aframeObject.compName)) {
  682. value = propertyValue;
  683. let parentNodeAF = aframeObject.el;
  684. let defs = ['direction', 'far', 'interval', 'near', 'objects', 'origin', 'recursive', 'showLine', 'useWorldCoordinates'];
  685. let el = defs.includes(propertyName);
  686. if (el) {
  687. parentNodeAF.setAttribute('raycaster', propertyName, propertyValue);
  688. } else {
  689. value = undefined
  690. }
  691. // defs.forEach(element => {
  692. // element == propertyName ? parentNodeAF.setAttribute('raycaster', element, propertyValue) :
  693. // value = undefined;
  694. // })
  695. }
  696. }
  697. if (value === undefined && self.state.isALinePathDefinition(node.prototypes)) {
  698. if (aframeObject.el.getAttribute(aframeObject.compName)) {
  699. value = propertyValue;
  700. let parentNodeAF = aframeObject.el;
  701. switch (propertyName) {
  702. case "color":
  703. parentNodeAF.setAttribute(aframeObject.compName, 'color', propertyValue);
  704. break;
  705. case "path":
  706. parentNodeAF.setAttribute(aframeObject.compName, 'path', propertyValue);
  707. break;
  708. case "width":
  709. parentNodeAF.setAttribute(aframeObject.compName, 'width', propertyValue);
  710. break;
  711. case "taper":
  712. parentNodeAF.setAttribute(aframeObject.compName, 'taper', propertyValue);
  713. break;
  714. case "transparent":
  715. parentNodeAF.setAttribute(aframeObject.compName, 'transparent', propertyValue);
  716. break;
  717. case "opacity":
  718. parentNodeAF.setAttribute(aframeObject.compName, 'opacity', propertyValue);
  719. break;
  720. default:
  721. value = undefined;
  722. break;
  723. }
  724. }
  725. }
  726. //isALineDefinition(node.prototypes)
  727. //if (value === undefined && node.componentName == 'line') { //isALineDefinition( node.prototypes )
  728. if (node.extendsID == "proxy/aframe/lineComponent.vwf") {
  729. if (value === undefined && aframeObject.el.getAttribute(aframeObject.compName)) {
  730. value = propertyValue;
  731. //let parentNodeAF = self.state.kernel.find(node.parentID);
  732. // aframeObject.el.setAttribute('line', 'color')
  733. let parentNodeAF = aframeObject.el;
  734. switch (propertyName) {
  735. case "start":
  736. parentNodeAF.setAttribute(aframeObject.compName, { start: propertyValue });
  737. break;
  738. case "end":
  739. parentNodeAF.setAttribute(aframeObject.compName, { end: propertyValue });
  740. break;
  741. case "color":
  742. parentNodeAF.setAttribute(aframeObject.compName, 'color', propertyValue);
  743. break;
  744. case "opacity":
  745. parentNodeAF.setAttribute(aframeObject.compName, 'opacity', propertyValue);
  746. break;
  747. case "visible":
  748. parentNodeAF.setAttribute(aframeObject.compName, 'visible', propertyValue);
  749. break;
  750. default:
  751. value = undefined;
  752. break;
  753. }
  754. }
  755. }
  756. if (value === undefined && self.state.isAAnimMixerDefinition(node.prototypes)) {
  757. if (aframeObject.el.getAttribute(aframeObject.compName)) {
  758. value = propertyValue;
  759. let parentNodeAF = aframeObject.el;
  760. switch (propertyName) {
  761. case "clip":
  762. parentNodeAF.setAttribute(aframeObject.compName, 'clip', propertyValue);
  763. break;
  764. case "duration":
  765. parentNodeAF.setAttribute(aframeObject.compName, 'duration', propertyValue);
  766. break;
  767. case "crossFadeDuration":
  768. parentNodeAF.setAttribute(aframeObject.compName, 'crossFadeDuration', propertyValue);
  769. break;
  770. case "loop":
  771. parentNodeAF.setAttribute(aframeObject.compName, 'loop', propertyValue);
  772. break;
  773. case "repetitions":
  774. parentNodeAF.setAttribute(aframeObject.compName, 'repetitions', propertyValue);
  775. break;
  776. default:
  777. value = undefined;
  778. break;
  779. }
  780. }
  781. }
  782. if (value === undefined && self.state.isAInterpolationDefinition(node.prototypes)) {
  783. if (aframeObject.el.getAttribute(aframeObject.compName)) {
  784. value = propertyValue;
  785. let parentNodeAF = aframeObject.el;
  786. switch (propertyName) {
  787. case "enabled":
  788. parentNodeAF.setAttribute(aframeObject.compName, 'enabled', propertyValue);
  789. break;
  790. case "deltaPos":
  791. parentNodeAF.setAttribute(aframeObject.compName, 'deltaPos', propertyValue);
  792. break;
  793. case "deltaRot":
  794. parentNodeAF.setAttribute(aframeObject.compName, 'deltaRot', propertyValue);
  795. break;
  796. case "deltaScale":
  797. parentNodeAF.setAttribute(aframeObject.compName, 'deltaScale', propertyValue);
  798. break;
  799. default:
  800. value = undefined;
  801. break;
  802. }
  803. }
  804. }
  805. if (value === undefined && self.state.isAGizmoDefinition(node.prototypes)) {
  806. if (aframeObject.el.getAttribute(aframeObject.compName)) {
  807. value = propertyValue;
  808. let parentNodeAF = aframeObject.el;
  809. switch (propertyName) {
  810. case "mode":
  811. parentNodeAF.setAttribute(aframeObject.compName, 'mode', propertyValue);
  812. break;
  813. default:
  814. value = undefined;
  815. break;
  816. }
  817. }
  818. }
  819. }
  820. return value;
  821. },
  822. // -- callingMethod ------------------------------------------------------------------------
  823. callingMethod: function (nodeID, methodName, methodParameters) {
  824. let self = this;
  825. var node = this.state.nodes[nodeID];
  826. if (!node) return;
  827. if (node && node.aframeObj) {
  828. let aframeObject = node.aframeObj;
  829. let parentNodeAF = aframeObject.el;
  830. if(methodName == "getIntersectedElement") {
  831. let comp = parentNodeAF.components['raycaster'];
  832. if (comp.intersectedEls.length>0){
  833. //console.log(comp.intersectedEls);
  834. let intersecedObjID = comp.intersectedEls[0].id
  835. return intersecedObjID
  836. }
  837. return undefined
  838. }
  839. if(methodName == "getIntersectionPoint") {
  840. //let nodes = vwf.models["/drivers/model/aframe"].model.state.nodes;
  841. let comp = parentNodeAF.components['raycaster'];
  842. let objID = methodParameters[0];
  843. if (comp.intersectedEls.length>0){
  844. //console.log(comp.intersectedEls);
  845. let intersecedObj = comp.intersectedEls[0]; //objID ? nodes[objID] : nodes[comp.intersectedEls[0].id];
  846. //comp.checkIntersections();
  847. let intersection = comp.getIntersection(intersecedObj);
  848. if(intersection)
  849. return {id: intersecedObj.id, point: intersection.point}
  850. }
  851. return undefined
  852. }
  853. }
  854. },
  855. // -- gettingProperty ----------------------------------------------------------------------
  856. gettingProperty: function (nodeID, propertyName, propertyValue) {
  857. let self = this;
  858. var node = this.state.nodes[nodeID];
  859. var value = undefined;
  860. if (node && node.aframeObj) {
  861. var aframeObject = node.aframeObj;
  862. if (self.state.isComponentNodeDefinition(node.prototypes)) {
  863. switch (propertyName) {
  864. }
  865. }
  866. if (value === undefined && self.state.isComponentDefinition(node.prototypes)) {
  867. switch (propertyName) {
  868. case "compName":
  869. break;
  870. }
  871. }
  872. // isALineDefinition( node.prototypes ) aframeObject.compName == compName
  873. if (value === undefined && self.state.isARayCasterDefinition(node.prototypes)) {
  874. value = propertyValue;
  875. let parentNodeAF = aframeObject.el;
  876. let defs = ['direction', 'far', 'interval', 'near', 'objects', 'origin', 'recursive', 'showLine', 'useWorldCoordinates'];
  877. let el = defs.includes(propertyName);
  878. value = el ? parentNodeAF.getAttribute('raycaster')[propertyName] : undefined;
  879. // defs.forEach(element => {
  880. // if (element == propertyName) {
  881. // let val = parentNodeAF.getAttribute('raycaster').element;
  882. // value = AFRAME.utils.coordinates.isCoordinates(val) ? AFRAME.utils.coordinates.stringify(val) : val
  883. // }
  884. // })
  885. }
  886. // if (value === undefined && isARayCasterListenerDefinition(node.prototypes)) {
  887. // value = propertyValue;
  888. // let parentNodeAF = aframeObject.el;
  889. // switch (propertyName) {
  890. // default:
  891. // value = undefined;
  892. // break;
  893. // }
  894. // }
  895. if (value === undefined && self.state.isAFogDefinition(node.prototypes)) {
  896. value = propertyValue;
  897. let parentNodeAF = aframeObject.el;
  898. let defs = ['fogType', 'color', 'density', 'near', 'far'];
  899. defs.forEach(element => {
  900. if (element == propertyName) {
  901. switch (element) {
  902. case 'fogType':
  903. value = parentNodeAF.getAttribute('fog').type;
  904. break;
  905. case 'fogColor':
  906. value = parentNodeAF.getAttribute('fog').color;
  907. break;
  908. default:
  909. value = parentNodeAF.getAttribute('fog').element;
  910. break;
  911. }
  912. }
  913. })
  914. }
  915. if (value === undefined && self.state.isAAabbColliderListenerDefinition(node.prototypes)) {
  916. let parentNodeAF = aframeObject.el;
  917. if(propertyName == "dynamic"){
  918. let attr = parentNodeAF.getAttribute('data-aabb-collider-dynamic');
  919. value = attr ? true : false
  920. }
  921. }
  922. if (value === undefined && self.state.isAShadowDefinition(node.prototypes)) {
  923. value = propertyValue;
  924. // let parentNodeAF = self.state.nodes[node.parentID].aframeObj;
  925. let parentNodeAF = aframeObject.el;
  926. switch (propertyName) {
  927. case "cast":
  928. value = parentNodeAF.getAttribute(aframeObject.compName).cast;
  929. break;
  930. case "receive":
  931. value = parentNodeAF.getAttribute(aframeObject.compName).receive;
  932. break;
  933. }
  934. }
  935. if (value === undefined && self.state.isALineDefinition(node.prototypes)) {
  936. value = propertyValue;
  937. // let parentNodeAF = self.state.nodes[node.parentID].aframeObj;
  938. let parentNodeAF = aframeObject.el;
  939. switch (propertyName) {
  940. case "start":
  941. value = AFRAME.utils.coordinates.stringify(parentNodeAF.getAttribute(aframeObject.compName).start);
  942. break;
  943. case "end":
  944. value = AFRAME.utils.coordinates.stringify(parentNodeAF.getAttribute(aframeObject.compName).end);
  945. break;
  946. case "color":
  947. value = parentNodeAF.getAttribute(aframeObject.compName).color;
  948. break;
  949. case "opacity":
  950. value = parentNodeAF.getAttribute(aframeObject.compName).opacity;
  951. break;
  952. case "visible":
  953. value = parentNodeAF.getAttribute(aframeObject.compName).visible;
  954. break;
  955. }
  956. }
  957. if (value === undefined && self.state.isAAnimMixerDefinition(node.prototypes)) {
  958. value = propertyValue;
  959. // let parentNodeAF = self.state.nodes[node.parentID].aframeObj;
  960. let parentNodeAF = aframeObject.el;
  961. switch (propertyName) {
  962. case "clip":
  963. value = parentNodeAF.getAttribute(aframeObject.compName).clip;
  964. break;
  965. case "duration":
  966. value = parentNodeAF.getAttribute(aframeObject.compName).duration;
  967. break;
  968. case "crossFadeDuration":
  969. value = parentNodeAF.getAttribute(aframeObject.compName).crossFadeDuration;
  970. break;
  971. case "loop":
  972. value = parentNodeAF.getAttribute(aframeObject.compName).loop;
  973. break;
  974. case "repetitions":
  975. value = parentNodeAF.getAttribute(aframeObject.compName).repetitions;
  976. break;
  977. }
  978. }
  979. //A-Frame material
  980. if (value === undefined && self.state.isAMaterialDefinition(node.prototypes)) {
  981. value = propertyValue;
  982. // let parentNodeAF = self.state.nodes[node.parentID].aframeObj;
  983. let parentNodeAF = aframeObject.el;
  984. let schema = Object.keys(AFRAME.components.material.schema).concat(Object.keys(AFRAME.shaders.standard.schema));
  985. let el = schema.includes(propertyName);
  986. value = el ? parentNodeAF.getAttribute('material')[propertyName] : undefined;
  987. switch (propertyName) {
  988. case "src":
  989. if (typeof value == "string" && value !== ""){
  990. value = value
  991. } else {
  992. value = (value) ? ('#' + value.getAttribute('id')) : value;
  993. }
  994. break;
  995. }
  996. }
  997. if (value === undefined && self.state.isASoundDefinition(node.prototypes)) {
  998. value = propertyValue;
  999. // let parentNodeAF = self.state.nodes[node.parentID].aframeObj;
  1000. let parentNodeAF = aframeObject.el;
  1001. let el = self.aframeComponentDef['A-SOUND'].includes(propertyName);
  1002. value = el ? parentNodeAF.getAttribute('sound')[propertyName] : undefined;
  1003. // self.aframeComponentDef['A-SOUND'].forEach(element => {
  1004. // if (element == propertyName) {
  1005. // value = parentNodeAF.getAttribute('sound').element;
  1006. // }
  1007. // })
  1008. }
  1009. if (value === undefined && self.state.isAMirrorDefinition(node.prototypes)) {
  1010. value = propertyValue;
  1011. // let parentNodeAF = self.state.nodes[node.parentID].aframeObj;
  1012. let parentNodeAF = aframeObject.el;
  1013. let el = self.aframeComponentDef['mirror'].includes(propertyName);
  1014. value = el ? parentNodeAF.getAttribute('mirror')[propertyName] : undefined;
  1015. // self.aframeComponentDef['mirror'].forEach(element => {
  1016. // if (element == propertyName) {
  1017. // value = parentNodeAF.getAttribute('mirror').element;
  1018. // }
  1019. // })
  1020. }
  1021. if (value === undefined && self.state.isAAabbColliderDefinition(node.prototypes)) {
  1022. value = propertyValue;
  1023. // let parentNodeAF = self.state.nodes[node.parentID].aframeObj;
  1024. let parentNodeAF = aframeObject.el;
  1025. let el = self.aframeComponentDef['aabb-collider'].includes(propertyName);
  1026. value = el ? parentNodeAF.getAttribute('aabb-collider')[propertyName] : undefined;
  1027. // self.aframeComponentDef['aabb-collider'].forEach(element => {
  1028. // if (element == propertyName) {
  1029. // value = parentNodeAF.getAttribute('aabb-collider').element;
  1030. // }
  1031. // })
  1032. }
  1033. if (value === undefined && self.state.isALinePathDefinition(node.prototypes)) {
  1034. value = propertyValue;
  1035. // let parentNodeAF = self.state.nodes[node.parentID].aframeObj;
  1036. let parentNodeAF = aframeObject.el;
  1037. switch (propertyName) {
  1038. case "color":
  1039. value = parentNodeAF.getAttribute(aframeObject.compName).color;
  1040. break;
  1041. case "path":
  1042. value = parentNodeAF.getAttribute(aframeObject.compName).path;
  1043. break;
  1044. case "width":
  1045. value = parentNodeAF.getAttribute(aframeObject.compName).width;
  1046. break;
  1047. case "taper":
  1048. value = parentNodeAF.getAttribute(aframeObject.compName).taper;
  1049. break;
  1050. case "transparent":
  1051. value = parentNodeAF.getAttribute(aframeObject.compName).transparent;
  1052. break;
  1053. case "opacity":
  1054. value = parentNodeAF.getAttribute(aframeObject.compName).opacity;
  1055. break;
  1056. }
  1057. }
  1058. if (value === undefined && self.state.isAViewOffsetCameraDefinition(node.prototypes)) {
  1059. value = propertyValue;
  1060. // let parentNodeAF = self.state.nodes[node.parentID].aframeObj;
  1061. let parentNodeAF = aframeObject.el;
  1062. switch (propertyName) {
  1063. case "fullWidth":
  1064. value = parentNodeAF.getAttribute(aframeObject.compName).fullWidth;
  1065. break;
  1066. case "fullHeight":
  1067. value = parentNodeAF.getAttribute(aframeObject.compName).fullHeight;
  1068. break;
  1069. case "subcamWidth":
  1070. value = parentNodeAF.getAttribute(aframeObject.compName).width;
  1071. break;
  1072. case "subcamHeight":
  1073. value = parentNodeAF.getAttribute(aframeObject.compName).height;
  1074. break;
  1075. case "xoffset":
  1076. value = parentNodeAF.getAttribute(aframeObject.compName).xoffset;
  1077. break;
  1078. case "yoffset":
  1079. value = parentNodeAF.getAttribute(aframeObject.compName).yoffset;
  1080. break;
  1081. }
  1082. }
  1083. if (value === undefined && self.state.isAInterpolationDefinition(node.prototypes)) {
  1084. value = propertyValue;
  1085. // let parentNodeAF = self.state.nodes[node.parentID].aframeObj;
  1086. let parentNodeAF = aframeObject.el;
  1087. switch (propertyName) {
  1088. case "enabled":
  1089. value = parentNodeAF.getAttribute(aframeObject.compName).enabled;
  1090. break;
  1091. case "deltaPos":
  1092. value = parentNodeAF.getAttribute(aframeObject.compName).deltaPos;
  1093. break;
  1094. case "deltaRot":
  1095. value = parentNodeAF.getAttribute(aframeObject.compName).deltaRot;
  1096. break;
  1097. case "deltaScale":
  1098. value = parentNodeAF.getAttribute(aframeObject.compName).deltaScale;
  1099. break;
  1100. }
  1101. }
  1102. if (value === undefined && self.state.isAGizmoDefinition(node.prototypes)) {
  1103. value = propertyValue;
  1104. // let parentNodeAF = self.state.nodes[node.parentID].aframeObj;
  1105. let parentNodeAF = aframeObject.el;
  1106. switch (propertyName) {
  1107. case "mode":
  1108. value = parentNodeAF.getAttribute(aframeObject.compName).mode;
  1109. break;
  1110. }
  1111. }
  1112. }
  1113. if (value !== undefined) {
  1114. propertyValue = value;
  1115. }
  1116. return value;
  1117. }
  1118. });
  1119. }
  1120. }
  1121. export {
  1122. AFrameComponentModel as default
  1123. }