editor-new.js 197 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446
  1. "use strict";
  2. /*
  3. The MIT License (MIT)
  4. Copyright (c) 2014-2018 Nikolai Suslov and the Krestianstvo.org project contributors. (https://github.com/NikolaySuslov/livecodingspace/blob/master/LICENSE.md)
  5. Virtual World Framework Apache 2.0 license (https://github.com/NikolaySuslov/livecodingspace/blob/master/licenses/LICENSE_VWF.md)
  6. */
  7. //
  8. /// vwf/view/editor creates a view interface for editor functions.
  9. ///
  10. /// @module vwf/view/editor
  11. /// @requires version
  12. /// @requires vwf/view
  13. /// @requires vwf/utility
  14. define([
  15. "module",
  16. "version",
  17. "vwf/view",
  18. "vwf/utility",
  19. "vwf/view/lib/colorpicker/colorpicker.min"
  20. ], function (module, version, view, utility, colorpicker) {
  21. var self;
  22. return view.load(module, {
  23. // == Module Definition ====================================================================
  24. initialize: function () {
  25. self = this;
  26. this.ace = window.ace;
  27. this.widgets = window._cellWidgets; //widgets;
  28. this.lang = _LangManager.language;
  29. this.helpers = _app.helpers;
  30. this.nodes = {};
  31. this.scenes = {};
  32. this.allScripts = {};
  33. //$(document.head).append('<style type="text/css" media="screen"> #editorlive { height: 500px; width: 800px; } </style>');
  34. document.querySelector('head').innerHTML += '<style type="text/css" media="screen"> #editorlive { height: 500px; width: 800px; } </style>';
  35. document.querySelector('head').innerHTML += '<link rel="stylesheet" href="/vwf/view/lib/editorLive.css">';
  36. //document.querySelector('head').innerHTML += '<script type="text/javascript" src="vwf/view/lib/colorpicker/colorpicker.min.js">';
  37. document.querySelector('head').innerHTML += '<link rel="stylesheet" href="/vwf/view/lib/colorpicker/themes.css">';
  38. //$(document.head).append('<meta name="viewport" content="width=device-width, initial-scale=1">');
  39. document.querySelector('head').innerHTML += '<meta name="viewport" content="width=device-width, initial-scale=1">';
  40. // $('body').append('<script>mdc.autoInit()</script>');
  41. ["drawer", "toolbar", "sideBar", "propWindow", "clientsWindow", "codeEditorWindow", "propEditorWindow", "viewSceneProps"].forEach(item => {
  42. let el = document.createElement("div");
  43. el.setAttribute("id", item);
  44. document.body.appendChild(el);
  45. }
  46. );
  47. _LCSDB.on('auth', function (ack) {
  48. if (ack.sea.pub) {
  49. _app.helpers.checkUserCollision();
  50. console.log(_LCSDB.user().is);
  51. let loadSave = document.querySelector('#loadSaveSettings');
  52. if(loadSave){
  53. }
  54. //self.authGUI();
  55. }
  56. });
  57. this.avatarCardDef = function (src, desc, onclickfunc) {
  58. return {
  59. $cell: true,
  60. $type: "div",
  61. class: "mdc-card avatar-card",
  62. $init: function () {
  63. this.style.backgroundImage = 'linear-gradient(0deg, rgba(0, 0, 0, 0.0), rgba(0, 0, 0, 0.0) ), url(' + src + ')'
  64. },
  65. onclick: onclickfunc,
  66. $components: [
  67. {
  68. $type: "section",
  69. class: "mdc-card__primary",
  70. style: "padding: 1rem;",
  71. $components: [
  72. {
  73. $type: "h1",
  74. class: "mdc-card__title mdc-typography--title",
  75. $text: desc.subtitle
  76. },
  77. {
  78. $type: "h2",
  79. class: "mdc-typography--subheading1",
  80. $text: desc.title
  81. }
  82. ]
  83. },
  84. {
  85. $type: "section",
  86. class: "mdc-card__actions",
  87. $components: [
  88. {
  89. $type: "button",
  90. class: "mdc-button mdc-button--compact mdc-card__action",
  91. //$text: "Use it",
  92. onclick: onclickfunc
  93. }
  94. ]
  95. }
  96. ]
  97. }
  98. }
  99. let createSettings =
  100. {
  101. $cell: true,
  102. $type: "div",
  103. class: "propGrid max-width mdc-layout-grid mdc-layout-grid--align-left",
  104. $components: [
  105. self.widgets.listTitle({text: 'Primitives'}),
  106. {
  107. $type: "div",
  108. class: "mdc-layout-grid__inner",
  109. $components: make3DPrimitiveList()
  110. },
  111. self.widgets.listTitle({text: 'Lights'}),
  112. {
  113. $type: "div",
  114. class: "mdc-layout-grid__inner",
  115. $components: makeLightsList()
  116. },
  117. self.widgets.listTitle({text: 'Objects'}),
  118. {
  119. $type: "div",
  120. class: "mdc-layout-grid__inner",
  121. $components: [
  122. self.widgets.gridListItem({
  123. imgSrc: "/vwf/view/lib/images/ui/icons/camera.png",
  124. title: 'Camera',
  125. imgSize: '30px',
  126. styleClass: "",
  127. onclickfunc: function () {
  128. let avatarID = 'avatar-' + vwf.moniker_;
  129. //let cubeName = self.GUID();
  130. vwf_view.kernel.callMethod(vwf.application(), "createCamera", [null, null, avatarID])
  131. //let cubeName = self.GUID();
  132. // vwf_view.kernel.callMethod(vwf.application(), "createFloor")
  133. }
  134. }),
  135. self.widgets.gridListItem({
  136. imgSrc: "/vwf/view/lib/images/ui/icons/camera_offset.png",
  137. title: 'Camera with view offset',
  138. imgSize: '30px',
  139. styleClass: "",
  140. onclickfunc: function () {
  141. let avatarID = 'avatar-' + vwf.moniker_;
  142. //let cubeName = self.GUID();
  143. vwf_view.kernel.callMethod(vwf.application(), "createCameraWithOffset", [null, null, avatarID])
  144. //let cubeName = self.GUID();
  145. // vwf_view.kernel.callMethod(vwf.application(), "createFloor")
  146. }
  147. }),
  148. self.widgets.gridListItem({
  149. imgSrc: "/vwf/view/lib/images/ui/icons/mirror.png",
  150. title: 'Mirror',
  151. imgSize: '30px',
  152. styleClass: "",
  153. onclickfunc: function () {
  154. let avatarID = 'avatar-' + vwf.moniker_;
  155. //let cubeName = self.GUID();
  156. vwf_view.kernel.callMethod(vwf.application(), "createMirror", [null, null, avatarID])
  157. //let cubeName = self.GUID();
  158. // vwf_view.kernel.callMethod(vwf.application(), "createFloor")
  159. }
  160. }),
  161. ]
  162. },
  163. self.widgets.listTitle({text: 'Assets'}),
  164. {
  165. $type: "div",
  166. class: "mdc-layout-grid__inner",
  167. $components: [
  168. {
  169. $type: "div",
  170. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  171. $components: [
  172. self.widgets.inputTextFieldOutlined({
  173. "id": 'assetsrc',
  174. "fieldStyle": 'width: 400px',
  175. "label": "Enter URL to asset source",
  176. "value": '',
  177. "change": function (e) {
  178. console.log(this.value)
  179. }
  180. })
  181. ]
  182. }
  183. ]
  184. },
  185. {
  186. $type: "div",
  187. class: "mdc-layout-grid__inner",
  188. $components: [
  189. {
  190. $type: "div",
  191. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  192. $components: [
  193. self.widgets.buttonSimple(
  194. {
  195. label: "Image",
  196. onclick: function (e) {
  197. let srcEl = document.querySelector('#assetsrc');
  198. let avatarID = 'avatar-' + vwf.moniker_;
  199. vwf_view.kernel.callMethod(vwf.application(), "createImage", [srcEl.value, null, null, avatarID])
  200. }
  201. }
  202. ),
  203. self.widgets.buttonSimple(
  204. {
  205. label: "Sound",
  206. onclick: function (e) {
  207. let srcEl = document.querySelector('#assetsrc');
  208. let avatarID = 'avatar-' + vwf.moniker_;
  209. vwf_view.kernel.callMethod(vwf.application(), "createAudio", [srcEl.value, null, null, avatarID])
  210. }
  211. }
  212. ),
  213. self.widgets.buttonSimple(
  214. {
  215. label: "Video",
  216. onclick: function (e) {
  217. let srcEl = document.querySelector('#assetsrc');
  218. let avatarID = 'avatar-' + vwf.moniker_;
  219. vwf_view.kernel.callMethod(vwf.application(), "createVideo", [srcEl.value, null, null, avatarID])
  220. }
  221. }
  222. ),
  223. self.widgets.buttonSimple(
  224. {
  225. label: "GLTF",
  226. onclick: function (e) {
  227. let srcEl = document.querySelector('#assetsrc');
  228. let avatarID = 'avatar-' + vwf.moniker_;
  229. if (srcEl.value.includes('.gltf'))
  230. vwf_view.kernel.callMethod(vwf.application(), "createModel", ['GLTF', srcEl.value, avatarID])
  231. }
  232. }
  233. ),
  234. self.widgets.buttonSimple(
  235. {
  236. label: "DAE",
  237. onclick: function (e) {
  238. let srcEl = document.querySelector('#assetsrc');
  239. let avatarID = 'avatar-' + vwf.moniker_;
  240. if (srcEl.value.includes('.dae'))
  241. vwf_view.kernel.callMethod(vwf.application(), "createModel", ['DAE', srcEl.value, avatarID])
  242. }
  243. }
  244. ),
  245. self.widgets.buttonSimple(
  246. {
  247. label: "OBJ",
  248. onclick: function (e) {
  249. let srcEl = document.querySelector('#assetsrc');
  250. let avatarID = 'avatar-' + vwf.moniker_;
  251. if (srcEl.value.includes('.obj'))
  252. vwf_view.kernel.callMethod(vwf.application(), "createModel", ['OBJ', srcEl.value, avatarID])
  253. }
  254. }
  255. )
  256. ]
  257. }
  258. ]
  259. },
  260. self.widgets.listTitle({text: 'Resources'}),
  261. {
  262. $type: "div",
  263. class: "mdc-layout-grid__inner",
  264. $components: [
  265. self.widgets.gridListItem({
  266. imgSrc: "/vwf/view/lib/images/ui/icons/3ditem.png",
  267. title: 'Asset item',
  268. imgSize: '30px',
  269. styleClass: "",
  270. onclickfunc: function () {
  271. let srcEl = document.querySelector('#assetsrc');
  272. vwf_view.kernel.callMethod(vwf.application(), "createAssetResource", ['ITEM', srcEl.value])
  273. }
  274. }),
  275. self.widgets.gridListItem({
  276. imgSrc: "/vwf/view/lib/images/ui/icons/image.png",
  277. title: 'Image',
  278. imgSize: '30px',
  279. styleClass: "",
  280. onclickfunc: function () {
  281. //let cubeName = self.GUID();
  282. let srcEl = document.querySelector('#assetsrc');
  283. vwf_view.kernel.callMethod(vwf.application(), "createAssetResource", ['IMG', srcEl.value])
  284. }
  285. }),
  286. self.widgets.gridListItem({
  287. imgSrc: "/vwf/view/lib/images/ui/icons/video.png",
  288. title: 'Video',
  289. imgSize: '30px',
  290. styleClass: "",
  291. onclickfunc: function () {
  292. let srcEl = document.querySelector('#assetsrc');
  293. vwf_view.kernel.callMethod(vwf.application(), "createAssetResource", ['VIDEO', srcEl.value])
  294. }
  295. }),
  296. self.widgets.gridListItem({
  297. imgSrc: "/vwf/view/lib/images/ui/icons/sound.png",
  298. title: 'Sound',
  299. imgSize: '30px',
  300. styleClass: "",
  301. onclickfunc: function () {
  302. let srcEl = document.querySelector('#assetsrc');
  303. vwf_view.kernel.callMethod(vwf.application(), "createAssetResource", ['AUDIO', srcEl.value])
  304. }
  305. }),
  306. self.widgets.buttonSimple(
  307. {
  308. label: "MTL",
  309. onclick: function (e) {
  310. let srcEl = document.querySelector('#assetsrc');
  311. if (srcEl.value.includes('.mtl'))
  312. vwf_view.kernel.callMethod(vwf.application(), "createAssetResource", ['ITEM', srcEl.value])
  313. }
  314. }
  315. )
  316. ]
  317. },
  318. {
  319. $type: "div",
  320. class: "mdc-layout-grid__inner",
  321. $components: [
  322. {
  323. $type: "div",
  324. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  325. $components: [
  326. self.widgets.divider
  327. ]
  328. },
  329. {
  330. $type: "div",
  331. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  332. $components: [
  333. {
  334. $type: "h3",
  335. class: "",
  336. $text: 'Google Poly'
  337. }
  338. ]
  339. },
  340. {
  341. $type: "div",
  342. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  343. $components: [
  344. self.widgets.inputTextFieldOutlined({
  345. "id": 'googlepolyid',
  346. "fieldStyle": 'width: 400px',
  347. "label": "Enter Google Poly model ID",
  348. "value": '',
  349. "change": function (e) {
  350. console.log(this.value)
  351. }
  352. })
  353. ]
  354. },
  355. {
  356. $type: "div",
  357. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  358. $components: [
  359. self.widgets.buttonSimple(
  360. {
  361. label: "Load from Poly",
  362. onclick: function (e) {
  363. let srcEl = document.querySelector('#googlepolyid');
  364. let avatarID = 'avatar-' + vwf.moniker_;
  365. vwf_view.kernel.callMethod(vwf.application(), "createGooglePoly", [srcEl.value, null, null, avatarID])
  366. }
  367. }
  368. )
  369. ]
  370. }
  371. ]
  372. }
  373. ]
  374. }
  375. function getUniqueDisplayName(newname, addcount) {
  376. if (!addcount) addcount = 0;
  377. if (!newname) newname = 'Object';
  378. newname = newname.replace(/[0-9]*$/g, "");
  379. var nodes = self.nodes; //vwf.models.object.objects;
  380. var count = 1 + addcount;
  381. for (var i in nodes) {
  382. if (nodes[i].id !== 0) {
  383. if (nodes[i].id !== "" && nodes[i].properties.length !== 0) {
  384. let thisname = vwf.getProperty(nodes[i].ID, 'displayName') || '';
  385. console.log(thisname);
  386. if (thisname.replace(/[0-9]*$/g, "") == newname)
  387. count++;
  388. }
  389. }
  390. }
  391. return newname + count;
  392. }
  393. function make3DPrimitiveList() {
  394. let nodeNames = ['Plane', 'Cube', 'Sphere', 'Cylinder', 'Cone', 'Text'];
  395. return nodeNames.map(el => {
  396. return self.widgets.gridListItem({
  397. imgSrc: "/vwf/view/lib/images/ui/icons/" + el.toLowerCase() + ".png",
  398. imgSize: "30px",
  399. styleClass:"", //"createListItem",
  400. title: el,
  401. onclickfunc: function () {
  402. let avatarID = 'avatar-' + vwf.moniker_;
  403. //let cubeName = self.GUID();
  404. let displayName = getUniqueDisplayName.call(self, el.toLowerCase());
  405. vwf_view.kernel.callMethod(vwf.application(), "createPrimitive", [el.toLowerCase(), null, displayName, null, avatarID])
  406. }
  407. })
  408. })
  409. }
  410. function makeLightsList() {
  411. let nodeNames = ['Ambient', 'Directional', 'Hemisphere', 'Point', 'Spot'];
  412. return nodeNames.map(el => {
  413. return self.widgets.gridListItem({
  414. imgSize: "30px",
  415. styleClass: "",
  416. imgSrc: "/vwf/view/lib/images/ui/icons/light_" + el.toLowerCase() + ".png",
  417. title: el,
  418. onclickfunc: function () {
  419. let avatarID = 'avatar-' + vwf.moniker_;
  420. //let cubeName = self.GUID();
  421. let displayName = getUniqueDisplayName.call(self, el.toLowerCase());
  422. vwf_view.kernel.callMethod(vwf.application(), "createPrimitive", ["light", el.toLowerCase(), displayName, null, avatarID])
  423. }
  424. })
  425. })
  426. }
  427. var saveAvatar = {};
  428. var loadAvatar = {};
  429. if (_LCSDB.user().is) {
  430. saveAvatar = self.widgets.floatActionButton({
  431. label: "save",
  432. styleClass: "mdc-fab--mini",
  433. onclickfunc: function () {
  434. //var nodeID = document.querySelector('#currentNode')._currentNode;
  435. let nodeID = 'avatar-' + self.kernel.moniker();
  436. let node = self.nodes[nodeID];
  437. let nodeDef = self.helpers.getNodeDef(nodeID).children.avatarNode;
  438. console.log(nodeDef);
  439. _LCSDB.user().get('profile').get('avatarNode').put(JSON.stringify(nodeDef), acc => {
  440. console.log("saved: " + acc)
  441. });
  442. //vwf_view.kernel.deleteChild(node.parentID, node.name);
  443. //vwf_view.kernel.deleteNode(nodeID);
  444. //vwf_view.kernel.callMethod(node.parentID, "deleteNode", [node.name])
  445. }
  446. });
  447. loadAvatar = self.widgets.floatActionButton({
  448. label: "restore",
  449. styleClass: "mdc-fab--mini",
  450. onclickfunc: function () {
  451. let nodeID = 'avatar-' + self.kernel.moniker();
  452. _LCSDB.user().get('profile').get('avatarNode').once(res => {
  453. if (res) {
  454. var myNode = res;
  455. if (_app.helpers.testJSON(res)){
  456. myNode = JSON.parse(res);
  457. }
  458. vwf_view.kernel.callMethod(nodeID, "changeCostume", [myNode, true]);
  459. }
  460. })
  461. }
  462. })
  463. }
  464. let avatarSettings =
  465. {
  466. $cell: true,
  467. $type: "div",
  468. class: "propGrid max-width mdc-layout-grid mdc-layout-grid--align-left",
  469. $components: [
  470. {
  471. $type: "div",
  472. class: "mdc-layout-grid__inner",
  473. $components: [
  474. {
  475. $type: "div",
  476. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  477. $components: [
  478. self.widgets.icontoggle({
  479. 'id': "mobile_joystick",
  480. 'label': 'visibility',
  481. 'on': JSON.stringify({ "content": "gamepad", "label": "Show" }),
  482. 'off': JSON.stringify({ "content": "gamepad", "label": "Hide" }),
  483. 'state': false,
  484. 'init': function () {
  485. this._driver = vwf.views["vwf/view/aframe"];
  486. this._comp = new mdc.iconButton.MDCIconButtonToggle(this);
  487. //mdc.iconButton.MDCIconButtonToggle.attachTo(this);
  488. if (document.getElementsByClassName('touchZone').length > 0){
  489. this._comp.on = true;
  490. this.style.color = "#3e7e40";
  491. } else {
  492. this._comp.on = false;
  493. this.style.color = "#333333";
  494. }
  495. this.addEventListener('MDCIconButtonToggle:change', (e) => {
  496. let chkAttr = e.detail.isOn;
  497. let driver = e.target._driver;
  498. if (chkAttr) {
  499. driver.state.showMobileJoystick();
  500. this.style.color = "#3e7e40";
  501. // this.classList.add('mdc-icon-toggle--enabled');
  502. console.log("on");
  503. } else {
  504. driver.state.hideMobileJoystick();
  505. this.style.color = "#333333";
  506. //this.classList.add('mdc-icon-toggle--disabled');
  507. console.log("off")
  508. }
  509. });
  510. }
  511. }),
  512. self.widgets.divider
  513. ]
  514. },
  515. {
  516. $type: "div",
  517. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  518. $components: [
  519. saveAvatar,
  520. loadAvatar,
  521. self.widgets.divider,
  522. self.widgets.buttonStroked(
  523. {
  524. "label": "Reset camera view",
  525. "onclick": function (e) {
  526. //document.querySelector('#' + 'viewSettings').style.visibility = 'hidden';
  527. let controlEl = document.querySelector('#avatarControl');
  528. controlEl.setAttribute('camera', 'active', true);
  529. }
  530. }),
  531. self.widgets.buttonStroked(
  532. {
  533. "label": "Hide cursor",
  534. "onclick": function (e) {
  535. //document.querySelector('#' + 'viewSettings').style.visibility = 'hidden';
  536. let avatarID = 'avatar-' + self.kernel.moniker();
  537. let cursorID = vwf.find(avatarID, "./avatarNode/myHead/myCursor")[0];
  538. //let cursorID = 'myCursor-' + avatarID;
  539. let controlEl = document.querySelector("[id='" + cursorID + "']");
  540. let vis = controlEl.getAttribute('visible');
  541. this.$text = vis ? 'Show cursor' : 'Hide cursor';
  542. vwf_view.kernel.callMethod(avatarID, "showHideCursor", [!vis]);
  543. //controlEl.setAttribute('visible', !vis);
  544. }
  545. }),
  546. self.widgets.buttonStroked(
  547. {
  548. "label": "Hide Avatar",
  549. "onclick": function (e) {
  550. //document.querySelector('#' + 'viewSettings').style.visibility = 'hidden';
  551. let avatarID = 'avatar-' + self.kernel.moniker();
  552. //let cursorID = 'myCursor-' + avatarID;
  553. let controlEl = document.querySelector("[id='" + avatarID + "']");
  554. let vis = controlEl.getAttribute('visible');
  555. this.$text = vis ? 'Show Avatar' : 'Show Avatar';
  556. vwf_view.kernel.callMethod(avatarID, "showHideAvatar", [!vis]);
  557. //controlEl.setAttribute('visible', !vis);
  558. }
  559. }
  560. ),
  561. self.widgets.buttonStroked(
  562. {
  563. "label": "Reset Avatar",
  564. "onclick": function (e) {
  565. let avatarID = 'avatar-' + self.kernel.moniker();
  566. //TODO: add XR check
  567. vwf_view.kernel.callMethod(avatarID, "resetAvatar", []);
  568. }
  569. }
  570. )
  571. ]
  572. },
  573. {
  574. $type: "div",
  575. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  576. $components: [
  577. {
  578. $type: "div",
  579. class: "mdc-layout-grid",
  580. $components: [
  581. {
  582. $type: "div",
  583. class: "mdc-layout-grid__inner",
  584. $components: [
  585. {
  586. $type: "div",
  587. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  588. $components: [
  589. self.avatarCardDef("/defaults/assets/avatars/ico/simple.jpg", { title: "Simple", subtitle: "Cube" },
  590. function (e) {
  591. let avatarID = 'avatar-' + self.kernel.moniker();
  592. vwf_view.kernel.callMethod(avatarID, "createSimpleAvatar");
  593. }
  594. )
  595. ]
  596. },
  597. {
  598. $type: "div",
  599. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  600. $components: [
  601. self.avatarCardDef("/defaults/assets/avatars/ico/female.jpg", { title: "Human", subtitle: "Female" },
  602. function (e) {
  603. let avatarID = 'avatar-' + self.kernel.moniker();
  604. vwf_view.kernel.callMethod(avatarID, "createAvatarFromGLTF", ["/defaults/assets/avatars/female/avatar1.gltf"]);
  605. }
  606. )]
  607. },
  608. {
  609. $type: "div",
  610. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  611. $components: [
  612. self.avatarCardDef("/defaults/assets/avatars/ico/male.jpg", { title: "Human", subtitle: "Male" },
  613. function (e) {
  614. let avatarID = 'avatar-' + self.kernel.moniker();
  615. vwf_view.kernel.callMethod(avatarID, "createAvatarFromGLTF", ["/defaults/assets/avatars/male/avatar1.gltf"]);
  616. }
  617. )]
  618. }
  619. ]
  620. }
  621. ]
  622. }
  623. ]
  624. },
  625. {
  626. $type: "div",
  627. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  628. $components: [
  629. self.widgets.buttonStroked(
  630. {
  631. "label": "Wide",
  632. "onclick": function (e) {
  633. let avatarID = 'avatar-' + vwf.moniker_;
  634. vwf_view.kernel.callMethod(avatarID, "setBigVideoHead", []);
  635. }
  636. }),
  637. self.widgets.buttonStroked(
  638. {
  639. "label": "Small",
  640. "onclick": function (e) {
  641. let avatarID = 'avatar-' + vwf.moniker_;
  642. vwf_view.kernel.callMethod(avatarID, "setSmallVideoHead", []);
  643. }
  644. })
  645. ]
  646. }
  647. ]
  648. }
  649. ]
  650. }
  651. let viewSettings =
  652. {
  653. $cell: true,
  654. $type: "div",
  655. class: "propGrid max-width mdc-layout-grid mdc-layout-grid--align-left",
  656. $components: [
  657. {
  658. $type: "div",
  659. class: "mdc-layout-grid__inner",
  660. $components: [
  661. {
  662. $type: "div",
  663. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  664. $components: [
  665. self.widgets.buttonStroked(
  666. {
  667. "label": "OSC Settings",
  668. "onclick": function (e) {
  669. let sideBar = document.querySelector('#sideBar');
  670. sideBar._sideBarComponent = oscSettings;
  671. //document.querySelector('#' + 'viewSettings').style.visibility = 'hidden';
  672. }
  673. })
  674. ]
  675. }
  676. ]
  677. }
  678. ]
  679. }
  680. let savedStateEl = function (item) {
  681. return {
  682. $type: "li",
  683. class: "mdc-list-item",
  684. role: "option",
  685. $components: [
  686. {
  687. $text: "Saved world"
  688. }
  689. ]
  690. }
  691. }
  692. let stateListElement = function (item) {
  693. let liEl = {
  694. $type: "option",
  695. id: "",
  696. applicationpath: "",
  697. value: "no_saves",
  698. $components: [
  699. {
  700. $text: "no saves"
  701. }
  702. ]
  703. }
  704. let applicationName = item.applicationpath.split("/");
  705. if (applicationName == "") {
  706. return liEl
  707. }
  708. if (applicationName.length > 0) {
  709. applicationName = applicationName[applicationName.length - 1];
  710. }
  711. if (applicationName.length > 0) {
  712. applicationName = applicationName.charAt(0).toUpperCase() + applicationName.slice(1);
  713. }
  714. if (item.latestsave) {
  715. liEl = {
  716. $type: "option",
  717. id: item.savename,
  718. value: item.savename,
  719. applicationpath: item.applicationpath,
  720. $components: [
  721. {
  722. $text: applicationName + ": " + item.savename
  723. }
  724. ]
  725. }
  726. }
  727. else {
  728. liEl = {
  729. $type: "option",
  730. id: item.savename,
  731. value: item.savename,
  732. revision: item.revision,
  733. applicationpath: item.applicationpath,
  734. $components: [
  735. {
  736. $text: applicationName + ": " + item.savename + " Rev(" + item.revision + ")"
  737. }
  738. ]
  739. }
  740. }
  741. return liEl
  742. }
  743. let oscSettings =
  744. {
  745. $cell: true,
  746. $type: "div",
  747. id: "oscSettings",
  748. class: "propGrid max-width mdc-layout-grid mdc-layout-grid--align-left",
  749. _oscHost: '',
  750. _oscPort: '',
  751. _oscStatus: '',
  752. _updateStatus: function () {
  753. this._oscStatus = window._OSCManager.getStatus()
  754. },
  755. $init: function () {
  756. if (window._OSCManager) {
  757. this._oscHost = window._OSCManager.hostValue;
  758. this._oscPort = window._OSCManager.portValue;
  759. this._oscStatus = window._OSCManager.getStatus();
  760. // var t = this;
  761. // setInterval(function () {
  762. // t._updateStatus();
  763. // }, 1000);
  764. }
  765. },
  766. $update: function () {
  767. let that = this
  768. var buttonText = "Connect";
  769. var buttonFunc = function (e) {
  770. }
  771. if (this._oscStatus == 1) {
  772. buttonText = "Disconnect";
  773. buttonFunc = function (e) {
  774. window._OSCManager.disconnect();
  775. }
  776. } else {
  777. var buttonFunc = function (e) {
  778. window._OSCManager.connect();
  779. window._OSCManager.port.on("open", function () {
  780. that._oscStatus = window._OSCManager.getStatus();
  781. console.log("connected");
  782. });
  783. window._OSCManager.port.on("close", function () {
  784. that._oscStatus = window._OSCManager.getStatus();
  785. console.log("disconnected");
  786. });
  787. }
  788. }
  789. this.$components = [
  790. {
  791. $type: "div",
  792. class: "mdc-layout-grid__inner",
  793. $components: [
  794. {
  795. $type: "div",
  796. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  797. $components: [
  798. self.widgets.inputTextFieldOutlined({
  799. "id": 'oscHostInput',
  800. "label": "Host",
  801. "value": this._oscHost,
  802. "change": function (e) {
  803. this._oscHost = this.value;
  804. window._OSCManager.setOSCHostAndPort(this._oscHost, this._oscPort);
  805. }
  806. })
  807. // {
  808. // $type: "span",
  809. // $text: "Host: "
  810. // },
  811. // {
  812. // class: "mdc-text-field",
  813. // $type: "span",
  814. // $components: [
  815. // {
  816. // class: "mdc-text-field__input prop-text-field-input",
  817. // id: "oscHost",
  818. // $type: "input",
  819. // type: "text",
  820. // value: this._oscHost,
  821. // onchange: function (e) {
  822. // this._oscHost = this.value;
  823. // window._OSCManager.setOSCHostAndPort(this._oscHost, this._oscPort);
  824. // }
  825. // }
  826. // ]
  827. // }
  828. ]
  829. },
  830. {
  831. $type: "div",
  832. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  833. $components: [
  834. self.widgets.inputTextFieldOutlined({
  835. "id": 'oscPortInput',
  836. "label": "Port",
  837. "value": this._oscPort,
  838. "change": function (e) {
  839. this._oscPort = this.value;
  840. window._OSCManager.setOSCHostAndPort(this._oscHost, this._oscPort);
  841. }
  842. })
  843. // {
  844. // $type: "span",
  845. // $text: "Port: "
  846. // },
  847. // {
  848. // class: "mdc-text-field",
  849. // $type: "span",
  850. // $components: [
  851. // {
  852. // class: "mdc-text-field__input prop-text-field-input",
  853. // id: "oscPort",
  854. // $type: "input",
  855. // type: "text",
  856. // value: this._oscPort,
  857. // onchange: function (e) {
  858. // this._oscPort = this.value;
  859. // window._OSCManager.setOSCHostAndPort(this._oscHost, this._oscPort);
  860. // }
  861. // }
  862. // ]
  863. // }
  864. ]
  865. },
  866. {
  867. $type: "div",
  868. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  869. $components: [
  870. self.widgets.buttonStroked(
  871. {
  872. "label": buttonText,
  873. "onclick": buttonFunc
  874. })
  875. ]
  876. }
  877. ]
  878. }
  879. ]
  880. }
  881. }
  882. let loadSaveSettings =
  883. {
  884. $cell: true,
  885. $type: "div",
  886. id: "loadSaveSettings",
  887. class: "propGrid max-width mdc-layout-grid mdc-layout-grid--align-left",
  888. $init: function () {
  889. var userGUI = [];
  890. let worldOwner = self.helpers.getRoot(false).root.split('/')[0];
  891. if (_LCSDB.user().is) {
  892. if (worldOwner == _LCSDB.user().is.alias) {
  893. userGUI.push(
  894. {
  895. $type: "div",
  896. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  897. $components: [
  898. {
  899. $type: "h3",
  900. class: "mdc-typography--title",
  901. $text: self.helpers.worldStateName
  902. },
  903. self.widgets.buttonStroked(
  904. {
  905. "label": "Save world",
  906. "onclick": function (e) {
  907. let fileName = self.helpers.worldStateName;//document.querySelector('#fileName')
  908. _app.saveStateAsFile(fileName);
  909. //document.querySelector("#fileName").value = '';
  910. //document.querySelector('#' + 'viewSettings').style.visibility = 'hidden';
  911. }
  912. })
  913. ]
  914. }
  915. );
  916. }
  917. userGUI.push(
  918. {
  919. $type: "div",
  920. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  921. $components: [
  922. {
  923. $type: "div",
  924. $components: [
  925. self.widgets.inputTextFieldOutlined({
  926. "id": 'fileName',
  927. "label": "World clone name",
  928. "value": 'world' + self.helpers.randId(), //self.getSaveName() //self.getRoot()
  929. "change": function (e) {
  930. }
  931. })
  932. // {
  933. // class: "mdc-text-field__input prop-text-field-input",
  934. // id: "fileName",
  935. // $type: "input",
  936. // type: "text",
  937. // value: 'world' + self.helpers.randId() //self.getSaveName() //self.getRoot()
  938. // }
  939. ]
  940. }
  941. ]
  942. },
  943. {
  944. $type: "div",
  945. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  946. $components: [
  947. self.widgets.buttonStroked(
  948. {
  949. "label": "Clone world",
  950. "onclick": function (e) {
  951. let fileName = document.querySelector('#fileName')
  952. let worldOwner = self.helpers.getRoot(false).root.split('/')[0];
  953. if (_LCSDB.user().is) {
  954. if (worldOwner == _LCSDB.user().is.alias) {
  955. _app.saveStateAsFile(fileName.value);
  956. } else {
  957. console.log('clone world with prototype to: ' + fileName);
  958. _app.cloneWorldState(fileName.value);
  959. }
  960. }
  961. //saveStateAsFile.call(self, fileName.value);
  962. //document.querySelector("#fileName").value = '';
  963. //document.querySelector('#' + 'viewSettings').style.visibility = 'hidden';
  964. }
  965. })
  966. ]
  967. }
  968. )
  969. // let saveGUI = document.querySelector('#saveGUI');
  970. // saveGUI.$components = userGUI.concat(saveGUI.$components);
  971. //document.querySelector('#fileName').value = 'world' + _app.helpers.randId();
  972. } else {
  973. userGUI.push(
  974. self.widgets.getLoginGUI()
  975. );
  976. }
  977. let saveGUI = document.querySelector('#saveGUI');
  978. saveGUI.$components = userGUI.concat(saveGUI.$components);
  979. },
  980. $update: function () {
  981. },
  982. $components:
  983. [
  984. {
  985. $type: "div",
  986. class: "mdc-layout-grid__inner",
  987. id: "saveGUI",
  988. $components: [
  989. ]
  990. }
  991. ]
  992. }
  993. let protoPropertiesCell = function (m) {
  994. return {
  995. $type: "div",
  996. class: "mdc-layout-grid__inner",
  997. _prop: {},
  998. $init: function () {
  999. let prop = m[1].prop;
  1000. if (prop.value == undefined && this._currentNode !== undefined) {
  1001. prop.value = JSON.stringify(utility.transform(vwf.getProperty(this._currentNode, prop.name, []), utility.transforms.transit));
  1002. }
  1003. this._prop = prop
  1004. },
  1005. $update: function () {
  1006. this.$components = [
  1007. // {
  1008. // $type: "div",
  1009. // class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-10",
  1010. // $components: [
  1011. // { $text: this._prop.name }
  1012. // ]
  1013. // },
  1014. // {
  1015. // $type: "div",
  1016. // class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1017. // },
  1018. {
  1019. $type: "div",
  1020. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  1021. $components: [
  1022. // {
  1023. // $type: "span",
  1024. // class: "mdc-typography--body2 mdc-typography--adjust-margin protoPropLabel",
  1025. // $text: this._prop.name + ': '
  1026. // },
  1027. {
  1028. $type: "div",
  1029. $components: [
  1030. self.widgets.inputTextFieldStandart({
  1031. "id": 'proto_' + this._prop.name,
  1032. "label": this._prop.name,
  1033. "value": this._prop.getValue(),
  1034. "change": function (e) {
  1035. //set property
  1036. let value = this.value;
  1037. var propValue = value;
  1038. if (_app.helpers.testJSON(value)){
  1039. propValue = JSON.parse(value);
  1040. } else {
  1041. propValue = value;
  1042. }
  1043. self.kernel.setProperty(this._currentNode, this._prop.name, propValue);
  1044. // let propValue = this.value;
  1045. // try {
  1046. // propValue = JSON.parse(propValue);
  1047. // self.kernel.setProperty(this._currentNode, this._prop.name, propValue);
  1048. // } catch (e) {
  1049. // // restore the original value on error
  1050. // this.value = propValue;
  1051. // }
  1052. }
  1053. })
  1054. ]
  1055. }
  1056. ]
  1057. }
  1058. ]
  1059. }
  1060. }
  1061. }
  1062. let propertiesCell = function (m) {
  1063. var editComponents = [{}, {}];
  1064. // fullWidth:
  1065. // fullHeight:
  1066. // xoffset:
  1067. // yoffset:
  1068. // width:
  1069. // height:
  1070. let sliderPropNames = ['width', 'height', 'depth', 'fullWidth', 'fullHeight', 'xoffset', 'yoffset', 'subcamWidth', 'subcamHeight'];
  1071. let sliderProps = {
  1072. 'width': {
  1073. min: 0,
  1074. max: 30
  1075. },
  1076. 'height': {
  1077. min: 0,
  1078. max: 30
  1079. },
  1080. 'depth': {
  1081. min: 0,
  1082. max: 30
  1083. },
  1084. 'fullWidth': {
  1085. min: 0,
  1086. max: 5000,
  1087. step: 10
  1088. },
  1089. 'fullHeight': {
  1090. min: 0,
  1091. max: 5000,
  1092. step: 10
  1093. },
  1094. 'xoffset': {
  1095. min: -10000,
  1096. max: 10000,
  1097. step: 10
  1098. },
  1099. 'yoffset': {
  1100. min: -10000,
  1101. max: 10000,
  1102. step: 10
  1103. },
  1104. 'subcamWidth': {
  1105. min: 0,
  1106. max: 5000,
  1107. step: 10
  1108. },
  1109. 'subcamHeight': {
  1110. min: 0,
  1111. max: 5000,
  1112. step: 10
  1113. }
  1114. }
  1115. if (sliderPropNames.includes(m.name)) {
  1116. let currenValue = JSON.parse(m.getValue());
  1117. var sliderComponent = self.widgets.sliderContinuous({
  1118. 'id': 'prop-slider-' + m.name,
  1119. 'label': 'Slider',
  1120. 'min': sliderProps[m.name].min,
  1121. 'max': sliderProps[m.name].max,
  1122. 'step': sliderProps[m.name].step ? sliderProps[m.name].step : 0.1,
  1123. 'value': currenValue,
  1124. 'init': function () {
  1125. const myEl = this;
  1126. var continuousSlider = new mdc.slider.MDCSlider(myEl);
  1127. this._comp = continuousSlider;
  1128. continuousSlider.listen('MDCSlider:input', function (e) {
  1129. // console.log(continuousSlider.value)
  1130. let myEl = e.currentTarget;
  1131. // let prop = myEl._prop.body;
  1132. //document.querySelector('#propAceEditor').env.editor.setValue(prop);
  1133. self.kernel.setProperty(myEl._currentNode, m.name, continuousSlider.value);
  1134. //continuousValue.textContent = continuousSlider.value;
  1135. });
  1136. continuousSlider.listen('MDCSlider:change', function (e) {
  1137. //console.log(continuousSlider.value);
  1138. let myEl = e.currentTarget;
  1139. // let prop = myEl._prop.body;
  1140. //document.querySelector('#propAceEditor').env.editor.setValue(prop);
  1141. self.kernel.setProperty(myEl._currentNode, m.name, continuousSlider.value);
  1142. //continuousCommittedValue.textContent = continuousSlider.value;
  1143. })
  1144. }
  1145. })
  1146. } else {
  1147. sliderComponent = {}
  1148. }
  1149. if (m.name.indexOf("semantics") > -1) { }
  1150. else if (m.name.indexOf("grammar") > -1) { }
  1151. else if (m.name.indexOf("ohm") > -1) {
  1152. editComponents = [
  1153. {
  1154. $type: "div",
  1155. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-6",
  1156. $components: [
  1157. {
  1158. $type: "button",
  1159. class: "mdc-button",
  1160. $text: "Edit", //edit grammar
  1161. onclick: function (e) {
  1162. var currentNode = document.querySelector('#currentNode')._currentNode;
  1163. if (currentNode == '') {
  1164. currentNode = vwf_view.kernel.find("", "/")[0];
  1165. }
  1166. let editor = document.querySelector('#livePropEditor');
  1167. editor._setNode(currentNode);
  1168. editor._propName = m.name;
  1169. editor._prop = { body: m.rawValue, type: 'complex' }
  1170. document.querySelector('#propEditorWindow').style.visibility = 'visible';
  1171. }
  1172. }
  1173. ]
  1174. },
  1175. {
  1176. $type: "div",
  1177. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1",
  1178. $components: []
  1179. }
  1180. ]
  1181. } else {
  1182. editComponents = [
  1183. {
  1184. $type: "div",
  1185. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-6",
  1186. $components: [
  1187. sliderComponent,
  1188. {
  1189. class: "mdc-text-field prop-mdc-text-field",
  1190. $type: "div",
  1191. $components: [
  1192. self.widgets.inputTextFieldStandart({
  1193. "id": "prop-" + m.name,
  1194. "label": m.name,
  1195. "value": m.getValue(),
  1196. "change": function (e) {
  1197. //set property
  1198. let value = this.value;
  1199. var propValue = value;
  1200. if (_app.helpers.testJSON(value)){
  1201. propValue = JSON.parse(value);
  1202. } else {
  1203. propValue = value;
  1204. //this.value = JSON.parse(JSON.stringify(propValue));
  1205. }
  1206. self.kernel.setProperty(this._currentNode, m.name, propValue);
  1207. //this.value = propValue.toString();
  1208. // let propValue = this.value;
  1209. // try {
  1210. // propValue = JSON.parse(propValue);
  1211. // self.kernel.setProperty(this._currentNode, m.name, propValue);
  1212. // } catch (e) {
  1213. // // restore the original value on error
  1214. // this.value = propValue;
  1215. // }
  1216. }
  1217. })
  1218. ]
  1219. }
  1220. ]
  1221. },
  1222. {
  1223. $type: "div",
  1224. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1",
  1225. $components: [
  1226. {
  1227. $type: "button",
  1228. class: "mdc-button mdc-button--compact",
  1229. $text: "^", //edit grammar
  1230. onclick: function (e) {
  1231. var currentNode = document.querySelector('#currentNode')._currentNode;
  1232. if (currentNode == '') {
  1233. currentNode = vwf_view.kernel.find("", "/")[0];
  1234. }
  1235. let editor = document.querySelector('#livePropEditor');
  1236. editor._setNode(currentNode);
  1237. editor._propName = m.name;
  1238. editor._prop = { body: m.getValue(), type: 'simple' }
  1239. document.querySelector('#propEditorWindow').style.visibility = 'visible';
  1240. }
  1241. }
  1242. ]
  1243. }
  1244. ];
  1245. }
  1246. return {
  1247. $type: "div",
  1248. class: "mdc-layout-grid__inner",
  1249. $components: [
  1250. {
  1251. $type: "div",
  1252. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-3",
  1253. $components: [
  1254. { $text: m.name }
  1255. ]
  1256. },
  1257. {
  1258. $type: "div",
  1259. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1260. },
  1261. editComponents[0],
  1262. editComponents[1]
  1263. ]
  1264. }
  1265. }
  1266. let nodeLink = function (m) {
  1267. var myClass = "nodeItem";
  1268. let myAvatarName = 'avatar-' + self.kernel.moniker();
  1269. (myAvatarName == m.name) ? (myClass = "avatarName mdc-typography--subheading2") :
  1270. myClass = "nodeItem"
  1271. var nodeName = m.name;
  1272. let displayName = vwf.getProperty(m.ID, 'displayName');
  1273. if (displayName) {
  1274. nodeName = displayName
  1275. }
  1276. return {
  1277. $type: "li",
  1278. class: "mdc-list-item",
  1279. $components: [{
  1280. $type: "a",
  1281. class: "mdc-list-item",
  1282. $href: "#",
  1283. $components: [{
  1284. $type: 'span',
  1285. class: myClass,
  1286. $text: nodeName
  1287. }
  1288. ],
  1289. onclick: function (e) {
  1290. //self.currentNodeID = m.ID;
  1291. document.querySelector('#currentNode')._setNode(m.ID);
  1292. // document.querySelector('#liveCodeEditor')._editorNode = m.ID;
  1293. // createAceEditor(self, m.ID);
  1294. }
  1295. }]
  1296. }
  1297. };
  1298. let listDivider = {
  1299. $type: "hr",
  1300. class: "mdc-list-divider",
  1301. }
  1302. let webrtcGUI = {
  1303. $type: "div",
  1304. class: "propGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  1305. $components: [
  1306. {
  1307. $type: "div",
  1308. class: "mdc-layout-grid__inner",
  1309. $components: [
  1310. {
  1311. $type: "div",
  1312. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1313. $components: [
  1314. {
  1315. $type: "span",
  1316. $text: "Chat"
  1317. }
  1318. ]
  1319. },
  1320. {
  1321. $type: "div",
  1322. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1323. $components: [
  1324. self.widgets.icontoggle({
  1325. 'id': "webrtcswitch",
  1326. 'label': 'visibility',
  1327. 'on': JSON.stringify({ "content": "visibility", "label": "Turn On Mic" }),
  1328. 'off': JSON.stringify({ "content": "visibility_off", "label": "Turn Off Mic" }),
  1329. 'state': false,
  1330. 'init': function () {
  1331. this._driver = vwf.views["vwf/view/webrtc"];
  1332. if (!this._driver) {
  1333. //this.classList.add('mdc-icon-toggle--disabled');
  1334. this.setAttribute('disabled',"");
  1335. }
  1336. mdc.iconButton.MDCIconButtonToggle.attachTo(this);
  1337. this.addEventListener('MDCIconButtonToggle:change', (e) => {
  1338. let driver = e.target._driver;
  1339. let chkAttr = e.detail.isOn;
  1340. let avatarID = 'avatar-' + self.kernel.moniker();
  1341. let micToggle = document.querySelector('#webrtcaudio');
  1342. let camToggle = document.querySelector('#webrtcvideo');
  1343. if (chkAttr) {
  1344. driver.startWebRTC(avatarID);
  1345. micToggle.removeAttribute('disabled');
  1346. camToggle.removeAttribute('disabled');
  1347. //micToggle.classList.remove('mdc-icon-toggle--disabled');
  1348. //camToggle.classList.remove('mdc-icon-toggle--disabled');
  1349. console.log("on")
  1350. } else {
  1351. driver.stopWebRTC(avatarID);
  1352. micToggle.setAttribute('disabled',"");
  1353. camToggle.setAttribute('disabled',"");
  1354. //micToggle.classList.add('mdc-icon-toggle--disabled');
  1355. //camToggle.classList.add('mdc-icon-toggle--disabled');
  1356. console.log("off")
  1357. }
  1358. //console.log(e, detail)
  1359. //status.textContent = `Icon Toggle is ${detail.isOn ? 'on' : 'off'}`;
  1360. });
  1361. }
  1362. })
  1363. ]
  1364. },
  1365. {
  1366. $type: "div",
  1367. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1368. $components: [
  1369. self.widgets.icontoggle({
  1370. 'id': "webrtcaudio",
  1371. 'label': 'mic',
  1372. 'on': JSON.stringify({ "content": "mic", "label": "Turn On Mic" }),
  1373. 'off': JSON.stringify({ "content": "mic_off", "label": "Turn Off Mic" }),
  1374. 'state': false,
  1375. 'init': function () {
  1376. this._driver = vwf.views["vwf/view/webrtc"];
  1377. let webrtcswitch = document.querySelector('#webrtcswitch');
  1378. if (!this._driver) {
  1379. //this.classList.add('mdc-icon-toggle--disabled');
  1380. this.setAttribute("disabled", "");
  1381. }
  1382. //this.classList.add('mdc-icon-toggle--disabled');
  1383. this.setAttribute("disabled", "");
  1384. this.addEventListener('MDCIconButtonToggle:change', (e) => {
  1385. let driver = e.target._driver;
  1386. let chkAttr = e.detail.isOn;
  1387. if (chkAttr) {
  1388. driver.muteAudio(chkAttr);
  1389. console.log("on")
  1390. } else {
  1391. driver.muteAudio(chkAttr);
  1392. console.log("off")
  1393. }
  1394. //console.log(e, detail)
  1395. //status.textContent = `Icon Toggle is ${detail.isOn ? 'on' : 'off'}`;
  1396. });
  1397. }
  1398. })
  1399. ]
  1400. },
  1401. {
  1402. $type: "div",
  1403. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1404. $components: [
  1405. self.widgets.icontoggle({
  1406. 'id': "webrtcvideo",
  1407. 'label': 'videocam',
  1408. 'on': JSON.stringify({ "content": "videocam", "label": "Turn On Video" }),
  1409. 'off': JSON.stringify({ "content": "videocam_off", "label": "Turn Off Video" }),
  1410. 'state': false,
  1411. 'init': function () {
  1412. this._driver = vwf.views["vwf/view/webrtc"];
  1413. if (!this._driver) {
  1414. //this.classList.add('mdc-icon-toggle--disabled');
  1415. this.setAttribute("disabled", "");
  1416. }
  1417. // this.classList.add('mdc-icon-toggle--disabled');
  1418. this.setAttribute("disabled", "");
  1419. this.addEventListener('MDCIconButtonToggle:change', (e) => {
  1420. let driver = e.target._driver;
  1421. let chkAttr = e.detail.isOn;
  1422. if (chkAttr) {
  1423. driver.muteVideo(chkAttr);
  1424. console.log("on")
  1425. } else {
  1426. driver.muteVideo(chkAttr);
  1427. console.log("off")
  1428. }
  1429. //console.log(e, detail)
  1430. //status.textContent = `Icon Toggle is ${detail.isOn ? 'on' : 'off'}`;
  1431. });
  1432. }
  1433. })
  1434. ]
  1435. }
  1436. ]
  1437. }
  1438. ]
  1439. }
  1440. let audioGUI = {
  1441. $type: "div",
  1442. class: "propGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  1443. $components: [
  1444. {
  1445. $type: "div",
  1446. class: "mdc-layout-grid__inner",
  1447. $components: [
  1448. {
  1449. $type: "div",
  1450. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1451. $components: [
  1452. {
  1453. $type: "span",
  1454. $text: "Sound: "
  1455. }
  1456. ]
  1457. },
  1458. {
  1459. $type: "div",
  1460. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1461. $components: [
  1462. self.widgets.icontoggle({
  1463. 'id': "soundStopStartSwitch",
  1464. 'label': 'play',
  1465. 'on': JSON.stringify({ "content": "pause", "label": "stop" }),
  1466. 'off': JSON.stringify({ "content": "play_arrow", "label": "play" }),
  1467. 'state': false,
  1468. 'init': function () {
  1469. var nodeID = this._currentNode;
  1470. this._comp = new mdc.iconButtonToggle.MDCIconButtonToggle(this);
  1471. this.setAttribute('id', "soundStopStartSwitch-" + nodeID);
  1472. let isPlaying = vwf.getProperty(nodeID, 'isPlaying');
  1473. //mdc.iconToggle.MDCIconToggle.attachTo(this);
  1474. this._comp.on = isPlaying;
  1475. this.addEventListener('MDCIconButtonToggle:change', (e) => {
  1476. // let avatarID = 'avatar-'+ vwf.moniker_;
  1477. // let avatarNode = self.nodes['avatar-'+ vwf.moniker_];
  1478. // let mode = JSON.parse(avatarNode.properties.selectMode.getValue());
  1479. var nodeID = document.querySelector('#currentNode')._currentNode;
  1480. let isPlaying = vwf.getProperty(nodeID, 'isPlaying');
  1481. if (isPlaying) {
  1482. console.log("stop");
  1483. vwf_view.kernel.callMethod(nodeID, "pauseSound");
  1484. } else {
  1485. console.log("play")
  1486. vwf_view.kernel.callMethod(nodeID, "playSound");
  1487. }
  1488. });
  1489. }
  1490. })
  1491. ]
  1492. },
  1493. {
  1494. $type: "div",
  1495. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1496. $components: [
  1497. {
  1498. $type: "div",
  1499. style: "padding: 12px",
  1500. $components: [
  1501. self.widgets.iconButton({
  1502. 'label': 'stop',
  1503. onclickfunc: function () {
  1504. var nodeID = this._currentNode;
  1505. vwf_view.kernel.callMethod(nodeID, "stopSound");
  1506. }
  1507. })
  1508. ]
  1509. }
  1510. ]
  1511. }
  1512. // {
  1513. // $type: "div",
  1514. // class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-3",
  1515. // $components: [
  1516. // widgets.switch({
  1517. // 'id': 'editnode',
  1518. // 'init': function(){
  1519. // vwf_view.kernel.getProperty(this._currentNode, 'edit');
  1520. // },
  1521. // 'onchange': function(e){
  1522. // var nodeID = document.querySelector('#currentNode')._currentNode;
  1523. // let chkAttr = this.getAttribute('checked');
  1524. // if (chkAttr == "") {
  1525. // self.kernel.setProperty(this._currentNode, 'edit', false);
  1526. // } else {
  1527. // self.kernel.setProperty(this._currentNode, 'edit', true);
  1528. // }
  1529. // vwf_view.kernel.callMethod(nodeID, "showCloseGizmo");
  1530. // }
  1531. // }
  1532. // )
  1533. // ]
  1534. // }
  1535. ]
  1536. }
  1537. ]
  1538. }
  1539. var saveGUI = {};
  1540. if (_LCSDB.user().is) {
  1541. saveGUI = self.widgets.floatActionButton({
  1542. label: "save",
  1543. styleClass: "mdc-fab--mini",
  1544. onclickfunc: function () {
  1545. var nodeID = document.querySelector('#currentNode')._currentNode;
  1546. let node = self.nodes[nodeID];
  1547. let nodeDef = self.helpers.getNodeDef(nodeID);
  1548. console.log(nodeDef);
  1549. //let saveID = this.GUID();
  1550. // _LCSUSER.get('saves').get(node.name).put(JSON.stringify(nodeDef), acc=>{
  1551. // console.log("saved: " + acc + 'to '+ node.name)
  1552. // });
  1553. }
  1554. })
  1555. }
  1556. let gizmoEdit = {
  1557. $type: "div",
  1558. class: "propGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  1559. $components: [
  1560. {
  1561. $type: "div",
  1562. class: "mdc-layout-grid__inner",
  1563. $components: [
  1564. {
  1565. $type: "div",
  1566. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1567. $components: [
  1568. {
  1569. $type: "span",
  1570. $text: "Edit: ",
  1571. }
  1572. ]
  1573. },
  1574. {
  1575. $type: "div",
  1576. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-3",
  1577. $components: [
  1578. self.widgets.switch({
  1579. 'id': 'editnode',
  1580. 'init': function () {
  1581. vwf_view.kernel.getProperty(this._currentNode, 'edit');
  1582. this._switch = new mdc.switchControl.MDCSwitch(this);
  1583. this._switch.checked = false;
  1584. },
  1585. 'onchange': function (e) {
  1586. var nodeID = document.querySelector('#currentNode')._currentNode;
  1587. if (this._switch) {
  1588. let chkAttr = this._switch.checked;//this.getAttribute('checked');
  1589. if (chkAttr) {
  1590. self.kernel.setProperty(this._currentNode, 'edit', true);
  1591. //this._switch.checked = false;
  1592. } else {
  1593. self.kernel.setProperty(this._currentNode, 'edit', false);
  1594. //this._switch.checked = true;
  1595. }
  1596. vwf_view.kernel.callMethod(nodeID, "showCloseGizmo");
  1597. }
  1598. }
  1599. }
  1600. )
  1601. ]
  1602. },
  1603. {
  1604. $type: "div",
  1605. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1606. $components: [
  1607. self.widgets.imageButton({
  1608. imgSrc: "/vwf/view/lib/images/ui/icons/translate.png",
  1609. styleClass: "editButton",
  1610. onclickfunc: function (e) {
  1611. vwf_view.kernel.callMethod(this._currentNode, "setGizmoMode", ['translate'])
  1612. }
  1613. })
  1614. ]
  1615. },
  1616. {
  1617. $type: "div",
  1618. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1619. $components: [
  1620. self.widgets.imageButton({
  1621. imgSrc: "/vwf/view/lib/images/ui/icons/rotate.png",
  1622. styleClass: "editButton",
  1623. onclickfunc: function (e) {
  1624. vwf_view.kernel.callMethod(this._currentNode, "setGizmoMode", ['rotate'])
  1625. }
  1626. })
  1627. ]
  1628. },
  1629. {
  1630. $type: "div",
  1631. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1632. $components: [
  1633. self.widgets.imageButton({
  1634. imgSrc: "/vwf/view/lib/images/ui/icons/scale.png",
  1635. styleClass: "editButton",
  1636. onclickfunc: function (e) {
  1637. vwf_view.kernel.callMethod(this._currentNode, "setGizmoMode", ['scale'])
  1638. }
  1639. })
  1640. ]
  1641. },
  1642. {
  1643. $type: "div",
  1644. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  1645. $components: [
  1646. // self.widgets.floatActionButton({
  1647. // label: "content_copy",
  1648. // styleClass: "mdc-fab--mini"
  1649. // }),
  1650. // {
  1651. // $type: "span",
  1652. // $text: " "
  1653. // },
  1654. self.widgets.floatActionButton({
  1655. label: "delete_forever",
  1656. styleClass: "mdc-fab--mini",
  1657. onclickfunc: function () {
  1658. var nodeID = document.querySelector('#currentNode')._currentNode;
  1659. let node = self.nodes[nodeID];
  1660. //vwf_view.kernel.deleteChild(node.parentID, node.name);
  1661. vwf_view.kernel.deleteNode(nodeID);
  1662. //vwf_view.kernel.callMethod(node.parentID, "deleteNode", [node.name])
  1663. }
  1664. }),
  1665. // self.widgets.floatActionButton({
  1666. // label: "person",
  1667. // styleClass: "mdc-fab--mini",
  1668. // onclickfunc: function () {
  1669. // var nodeID = document.querySelector('#currentNode')._currentNode;
  1670. // let node = self.nodes[nodeID];
  1671. // //vwf_view.kernel.deleteChild(node.parentID, node.name);
  1672. // let me = self.kernel.moniker();
  1673. // vwf_view.kernel.setProperty(nodeID, 'ownedBy', me);
  1674. // }
  1675. // }),
  1676. saveGUI
  1677. ]
  1678. },
  1679. ]
  1680. }
  1681. ]
  1682. }
  1683. let nodesCell = {
  1684. $cell: true,
  1685. $type: "div",
  1686. id: "currentNode",
  1687. _childNodes: [],
  1688. _currentNode: '',
  1689. _displayedProperties: {},
  1690. _setNode: function (aNode) {
  1691. this._currentNode = aNode;
  1692. document.querySelector('#sideBar')._sideCurrentNode = this._currentNode
  1693. },
  1694. $init: function () {
  1695. this._currentNode = document.querySelector('#sideBar')._sideCurrentNode
  1696. //this._currentNode = vwf_view.kernel.find("", "/")[0];
  1697. //this._currentNode = '3333';
  1698. },
  1699. _getChildNodes: function () {
  1700. this._childNodes = self.nodes[this._currentNode];
  1701. if (this._childNodes !== undefined) {
  1702. return this._childNodes.children
  1703. } else {
  1704. return []
  1705. }
  1706. //let nodeIDAlpha = he.encode(this._currentNode);
  1707. },
  1708. // _getNodeComplexProperties: function () {
  1709. // let node = self.nodes[this._currentNode];
  1710. // let props = this._getNodeProperties();
  1711. // let filterFunction = function (prop) {
  1712. // return (prop.name == 'ohmLang')
  1713. // };
  1714. // let complexProps = props.filter(filterFunction.bind(this));
  1715. // return complexProps
  1716. // },
  1717. _getNodeProperties: function () {
  1718. let node = self.nodes[this._currentNode];
  1719. this._displayedProperties = {};
  1720. let filterFunction = function (prop) {
  1721. return (!this._displayedProperties[prop.name] && prop.name.indexOf('$') === -1) ? (this._displayedProperties[prop.name] = "instance", true) : (false);
  1722. };
  1723. let props = node.properties.filter(filterFunction.bind(this));
  1724. return props
  1725. },
  1726. _getNodeProtoProperties: function () {
  1727. let node = self.nodes[this._currentNode];
  1728. let filterFunction = function (prop) {
  1729. return (!this._displayedProperties[prop[1].prop.name]) ? (this._displayedProperties[prop[1].prop.name] = prop[1].prototype, true) : (false);
  1730. };
  1731. let props = Object.entries(getProperties.call(self, self.kernel, node.extendsID)).filter(filterFunction.bind(this));
  1732. return props
  1733. },
  1734. $update: function () {
  1735. //this.$text = this._currentNode;
  1736. let node = self.nodes[this._currentNode];
  1737. let nodeProtos = getPrototypes(self.kernel, node.extendsID);
  1738. var viewerProps = {};
  1739. var viewerPropsCell = {};
  1740. var propsActions = {};
  1741. var propsActionsCell = {};
  1742. var gizmoCell = {};
  1743. if (this._currentNode !== self.kernel.application()) {
  1744. if (nodeProtos.includes('http://vwf.example.com/aframe/componentNode.vwf')) {
  1745. //gizmoCell = {};
  1746. if (nodeProtos.includes('http://vwf.example.com/aframe/a-sound-component.vwf')) {
  1747. //console.log("sound gui")
  1748. gizmoCell = audioGUI
  1749. }
  1750. } else {
  1751. gizmoCell = gizmoEdit
  1752. }
  1753. }
  1754. if (node !== undefined) {
  1755. propsActions = {
  1756. $type: "li",
  1757. class: "mdc-list-item",
  1758. $components: [
  1759. {
  1760. $text: "Actions",
  1761. $type: "span",
  1762. class: "mdc-list-item__text mdc-typography--button"
  1763. }
  1764. ]
  1765. }
  1766. let actionsGUI = [];
  1767. if(node.properties.meta) {
  1768. if(node.properties.meta.rawValue == 'avatarCostume'){
  1769. actionsGUI.push(self.widgets.buttonStroked(
  1770. {
  1771. "label": "Use this costume",
  1772. "onclick": function (e) {
  1773. console.log("COSTUME NEW!!!");
  1774. let nodeDef = self.helpers.getNodeDef(this._currentNode);
  1775. console.log(nodeDef);
  1776. let avatarID = 'avatar-' + self.kernel.moniker();
  1777. vwf_view.kernel.callMethod(avatarID, "changeCostume", [nodeDef]);
  1778. //vwf_view.kernel.callMethod(this._currentNode, "setCameraToActive", [vwf.moniker_]);
  1779. }
  1780. }))
  1781. }
  1782. } else if(node.name.includes('xrcontroller')){
  1783. actionsGUI.push(self.widgets.buttonStroked(
  1784. {
  1785. "label": "Set as World default XR controller",
  1786. "onclick": function (e) {
  1787. vwf_view.kernel.callMethod(node.ID, "saveToScene", []);
  1788. }
  1789. }))
  1790. }
  1791. propsActionsCell = {
  1792. $cell: true,
  1793. $type: "div",
  1794. class: "propGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  1795. $components: [
  1796. {
  1797. $type: "div",
  1798. class: "mdc-layout-grid__inner",
  1799. $components: [
  1800. {
  1801. $type: "div",
  1802. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  1803. $components: [].concat(actionsGUI)
  1804. }
  1805. ]
  1806. }
  1807. ]
  1808. //$components: this._getNodeProtoProperties().map(protoPropertiesCell)
  1809. }
  1810. if (node.extendsID == "http://vwf.example.com/aframe/acamera.vwf") {
  1811. viewerProps = {
  1812. $type: "li",
  1813. class: "mdc-list-item",
  1814. $components: [
  1815. {
  1816. $text: "Viewer properties",
  1817. $type: "span",
  1818. class: "mdc-list-item__text mdc-typography--button"
  1819. }
  1820. ]
  1821. }
  1822. viewerPropsCell = {
  1823. $cell: true,
  1824. $type: "div",
  1825. class: "propGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  1826. $components: [
  1827. {
  1828. $type: "div",
  1829. class: "mdc-layout-grid__inner",
  1830. $components: [
  1831. {
  1832. $type: "div",
  1833. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  1834. $components: [
  1835. self.widgets.buttonStroked(
  1836. {
  1837. "label": "Active",
  1838. "onclick": function (e) {
  1839. //let camera = document.querySelector('#' + this._currentNode);
  1840. vwf_view.kernel.callMethod(this._currentNode, "setCameraToActive", [vwf.moniker_]);
  1841. //camera.setAttribute('camera', 'active', true);
  1842. }
  1843. })
  1844. ]
  1845. }
  1846. ]
  1847. }
  1848. ]
  1849. //$components: this._getNodeProtoProperties().map(protoPropertiesCell)
  1850. }
  1851. } else {
  1852. viewerProps = {};
  1853. viewerPropsCell = {};
  1854. }
  1855. }
  1856. this.$components = [
  1857. {
  1858. $type: "ul",
  1859. class: "mdc-list",
  1860. $components: [
  1861. self.widgets.buttonStroked(
  1862. {
  1863. "label": "<--",
  1864. "onclick": function (e) {
  1865. let node = self.nodes[this._currentNode];
  1866. if (node.parentID !== 0) {
  1867. //self.currentNodeID = node.parentID,
  1868. document.querySelector('#currentNode')._setNode(node.parentID)
  1869. }
  1870. }
  1871. }),
  1872. {
  1873. $type: "li",
  1874. class: "mdc-list-item",
  1875. $components: [
  1876. {
  1877. $text: "name",
  1878. $type: "span",
  1879. $init: function () {
  1880. let node = self.nodes[this._currentNode];
  1881. if (node) {
  1882. let displayName = vwf.getProperty(node.ID, 'displayName');
  1883. if (displayName) {
  1884. this.$text = displayName
  1885. } else {
  1886. this.$text = node.name;
  1887. }
  1888. }
  1889. //console.log(node.properties.displayName)
  1890. },
  1891. class: "mdc-list-item__text mdc-typography--headline"
  1892. //<h1 class="mdc-typography--display4">Big header</h1>
  1893. }]
  1894. }, listDivider,
  1895. {
  1896. // $cell: true,
  1897. // $type: "ul",
  1898. // class: "mdc-list",
  1899. $type: "div",
  1900. class: "propGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  1901. $components: [
  1902. {
  1903. $type: "div",
  1904. class: "mdc-layout-grid__inner",
  1905. $components: [
  1906. {
  1907. $type: "div",
  1908. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  1909. $components: [
  1910. self.widgets.buttonStroked(
  1911. {
  1912. "label": "Methods browser",
  1913. "onclick": function (e) {
  1914. var currentNode = document.querySelector('#currentNode')._currentNode;
  1915. if (currentNode == '') {
  1916. currentNode = vwf_view.kernel.find("", "/")[0];
  1917. }
  1918. if (isAFrameEntity(currentNode)) {
  1919. vwf.views["vwf/view/aframe"].nodes[currentNode].liveBindings = {};
  1920. } else if(isAFrameComponent(currentNode)) {
  1921. vwf.views["vwf/view/aframeComponent"].nodes[currentNode].liveBindings = {};
  1922. }
  1923. document.querySelector('#liveCodeEditor')._setNode(currentNode);
  1924. //createAceEditor(self, currentNode);
  1925. document.querySelector('#codeEditorWindow').style.visibility = 'visible';
  1926. }
  1927. })
  1928. ]
  1929. }
  1930. ]
  1931. }
  1932. ]
  1933. },
  1934. gizmoCell,
  1935. listDivider,
  1936. {
  1937. $type: "li",
  1938. class: "mdc-list-item",
  1939. $components: [
  1940. {
  1941. $text: "Children",
  1942. $type: "span",
  1943. class: "mdc-list-item__text mdc-typography--button"
  1944. }]
  1945. },
  1946. {
  1947. $type: "ul",
  1948. class: "mdc-list",
  1949. $components: this._getChildNodes().map(nodeLink)
  1950. }, listDivider, {
  1951. $type: "li",
  1952. class: "mdc-list-item",
  1953. $components: [
  1954. {
  1955. $text: "Properties",
  1956. $type: "span",
  1957. class: "mdc-list-item__text mdc-typography--button"
  1958. //<h1 class="mdc-typography--display4">Big header</h1>
  1959. }]
  1960. },
  1961. {
  1962. // $cell: true,
  1963. // $type: "ul",
  1964. // class: "mdc-list",
  1965. $type: "div",
  1966. class: "propGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  1967. $components: this._getNodeProperties().map(propertiesCell)
  1968. },
  1969. listDivider,
  1970. {
  1971. $type: "li",
  1972. class: "mdc-list-item",
  1973. $components: [
  1974. {
  1975. $text: "Proto properties",
  1976. $type: "span",
  1977. class: "mdc-list-item__text mdc-typography--button"
  1978. }]
  1979. },
  1980. {
  1981. $type: "div",
  1982. class: "propGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  1983. $components: this._getNodeProtoProperties().map(protoPropertiesCell)
  1984. }, listDivider,
  1985. propsActions,
  1986. propsActionsCell,
  1987. listDivider,
  1988. viewerProps,
  1989. viewerPropsCell
  1990. ]
  1991. }
  1992. ]
  1993. }
  1994. }
  1995. let numberSliderComponent = {
  1996. $cell: true,
  1997. $type: "div",
  1998. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-4",
  1999. $init: function () {
  2000. },
  2001. $components: [
  2002. {
  2003. $type: "div",
  2004. style: "padding: 0 16px;",
  2005. $components: [
  2006. {}
  2007. ]
  2008. }
  2009. ]
  2010. }
  2011. let colorPickerComponent = {
  2012. $cell: true,
  2013. $type: "div",
  2014. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-4",
  2015. $init: function () {
  2016. let myEl = this;
  2017. let cp = ColorPicker(
  2018. document.getElementById('slide'),
  2019. document.getElementById('picker'),
  2020. function (hex, hsv, rgb, mousePicker, mouseSlide) {
  2021. ColorPicker.positionIndicators(
  2022. document.getElementById('slide-indicator'),
  2023. document.getElementById('picker-indicator'),
  2024. mouseSlide, mousePicker
  2025. );
  2026. if (myEl._propName.toLowerCase().includes('color')) {
  2027. // console.log(hex);
  2028. document.querySelector('#propAceEditor').env.editor.setValue(JSON.stringify(hex));
  2029. self.kernel.setProperty(myEl._editorNode, myEl._propName, hex);
  2030. }
  2031. });
  2032. if (myEl._propName.toLowerCase().includes('color')) {
  2033. cp.setHex(JSON.parse(myEl._prop.body));
  2034. }
  2035. },
  2036. $components: [
  2037. {
  2038. $type: "div",
  2039. id: "color-picker",
  2040. class: "cp-default",
  2041. $components: [
  2042. {
  2043. $type: "div",
  2044. class: "picker-wrapper",
  2045. $components: [
  2046. {
  2047. $type: "div",
  2048. id: "picker",
  2049. class: "picker",
  2050. style: "width: 130px; height: 130px"
  2051. },
  2052. {
  2053. $type: "div",
  2054. id: "picker-indicator",
  2055. class: "picker-indicator"
  2056. }
  2057. ]
  2058. },
  2059. {
  2060. $type: "div",
  2061. class: "slide-wrapper",
  2062. $components: [
  2063. {
  2064. $type: "div",
  2065. id: "slide",
  2066. class: "slide",
  2067. style: "width: 30px; height: 130px"
  2068. },
  2069. {
  2070. $type: "div",
  2071. id: "slide-indicator",
  2072. class: "slide-indicator"
  2073. }
  2074. ]
  2075. }
  2076. ]
  2077. }
  2078. // {
  2079. // $cell: true,
  2080. // $type: "div",
  2081. // id: "color-picker",
  2082. // $init: function () {
  2083. // }
  2084. // }
  2085. ]
  2086. }
  2087. let propEditorWindow = {
  2088. $cell: true,
  2089. $type: "div",
  2090. _editorNode: '',
  2091. _prop: { body: '', type: 'simple' },
  2092. _propName: '',
  2093. id: "livePropEditor",
  2094. _setNode: function (node) {
  2095. this._editorNode = node;
  2096. this._prop.body = ''
  2097. },
  2098. class: "propEditorGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  2099. $update: function () {
  2100. var editorClass = "mdc-layout-grid__cell mdc-layout-grid__cell--span-8"
  2101. var livePropertyComponent = {}
  2102. if (this._prop.type == 'simple') {
  2103. if (this._propName.toLowerCase().includes('color')) {
  2104. livePropertyComponent = colorPickerComponent
  2105. }
  2106. } else {
  2107. editorClass = "mdc-layout-grid__cell mdc-layout-grid__cell--span-12"
  2108. }
  2109. this.$components = [
  2110. {
  2111. $type: "div",
  2112. class: "mdc-layout-grid__inner",
  2113. $components: [
  2114. {
  2115. $type: "div",
  2116. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  2117. $components: [
  2118. self.widgets.buttonStroked(
  2119. {
  2120. "label": "Update",
  2121. "onclick": function (e) {
  2122. let editor = document.querySelector("#propAceEditor").env.editor;
  2123. let value = editor.getValue();
  2124. var propValue = value;
  2125. if (this._prop.type == 'simple') {
  2126. if (_app.helpers.testJSON(value)){
  2127. propValue = JSON.parse(value);
  2128. }
  2129. } else {
  2130. propValue = value;
  2131. }
  2132. self.kernel.setProperty(this._editorNode, this._propName, propValue);
  2133. // try {
  2134. // let propValue = (this._prop.type == 'simple') ? (JSON.parse(value)) : (value)
  2135. // //propValue = JSON.parse(value);
  2136. // self.kernel.setProperty(this._editorNode, this._propName, propValue);
  2137. // } catch (e) {
  2138. // // restore the original value on error
  2139. // this.value = propValue;
  2140. // }
  2141. }
  2142. }
  2143. )]
  2144. },
  2145. {
  2146. $type: "div",
  2147. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-5",
  2148. $components: [
  2149. {
  2150. $type: "h3",
  2151. class: "mdc-list-group__subheader mdc-list-item__text mdc-typography--subheading1",
  2152. $text: this._editorNode
  2153. }
  2154. ]
  2155. },
  2156. {
  2157. $type: "div",
  2158. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-5",
  2159. $components: [
  2160. {
  2161. $type: "h3",
  2162. class: "mdc-list-group__subheader mdc-list-item__text mdc-typography--subheading1",
  2163. $text: this._propName
  2164. }
  2165. ]
  2166. }
  2167. ]
  2168. },
  2169. {
  2170. $type: "div",
  2171. class: "mdc-layout-grid__inner",
  2172. $components: [
  2173. {
  2174. $type: "div",
  2175. class: editorClass,
  2176. $components: [
  2177. {
  2178. class: "aceEditor",
  2179. id: "propAceEditor",
  2180. $type: "div",
  2181. $text: this._prop.body,
  2182. $init: function () {
  2183. createAceEditor(self, this._editorNode, "propAceEditor");
  2184. this.env.editor.$blockScrolling = Infinity
  2185. }
  2186. }
  2187. ]
  2188. }, livePropertyComponent
  2189. // {
  2190. // $cell: true,
  2191. // $type: "div",
  2192. // class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  2193. // $components: []
  2194. // },
  2195. ]
  2196. }
  2197. ]
  2198. //$components:
  2199. }
  2200. }
  2201. let codeEditorWindow = {
  2202. $cell: true,
  2203. $type: "div",
  2204. _editorNode: '',
  2205. _method: { body: '' },
  2206. _methodName: '',
  2207. _getNodeMethods: function () {
  2208. let node = self.nodes[this._editorNode];
  2209. return node.methods
  2210. },
  2211. _getProtoNodeMethods: function () {
  2212. let node = self.nodes[this._editorNode];
  2213. let prototypeMethods = getMethods.call(self, self.kernel, node.extendsID);
  2214. return prototypeMethods
  2215. },
  2216. id: "liveCodeEditor",
  2217. _setNode: function (node) {
  2218. this._editorNode = node;
  2219. this._method.body = ''
  2220. },
  2221. class: "codeEditorGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  2222. // _getComplexProps: function(){
  2223. // let node = self.nodes[this._editorNode];
  2224. // let currentNode = document.querySelector('#currentNode');
  2225. // var props = {}
  2226. // if (currentNode !== null) {
  2227. // props = currentNode._getNodeComplexProperties();
  2228. // }
  2229. // return props
  2230. // },
  2231. // _listPropertyElement: function (m) {
  2232. // return {
  2233. // $type: "li",
  2234. // class: "mdc-list-item",
  2235. // $components: [{
  2236. // $type: "a",
  2237. // class: "mdc-list-item",
  2238. // $href: "#",
  2239. // $text: m[1].name,
  2240. // onclick: function (e) {
  2241. // this._method = {};
  2242. // this._methodName = m[1].name;
  2243. // this._method.body = m[1].rawValue
  2244. // this._method.type = "complexProperty"
  2245. // }
  2246. // }]
  2247. // }
  2248. // },
  2249. _listElement: function (m) {
  2250. return {
  2251. $type: "li",
  2252. class: "mdc-list-item",
  2253. $components: [{
  2254. $type: "a",
  2255. class: "mdc-list-item",
  2256. $href: "#",
  2257. $text: m[0],
  2258. onclick: function (e) {
  2259. let method = vwf.getMethod(this._editorNode, m[0]);
  2260. //document.querySelector('#aceEditor').
  2261. this._method = method;
  2262. this._methodName = m[0];
  2263. //self.currentNodeID = m.ID;
  2264. //document.querySelector('#currentNode')._setNode(m.ID);
  2265. }
  2266. }]
  2267. }
  2268. },
  2269. $update: function () {
  2270. this.$components = [
  2271. {
  2272. $type: "div",
  2273. class: "mdc-layout-grid__inner",
  2274. $components: [
  2275. {
  2276. $type: "div",
  2277. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-3",
  2278. $components: [
  2279. {
  2280. $type: "h3",
  2281. class: "mdc-list-group__subheader mdc-list-item__text mdc-typography--subheading1",
  2282. $text: this._editorNode
  2283. }
  2284. ]
  2285. },
  2286. {
  2287. $type: "div",
  2288. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1 tooltip",
  2289. $components: [
  2290. {
  2291. class: "tooltiptext",
  2292. $type: "span",
  2293. $text: "Update"
  2294. },
  2295. self.widgets.iconButton({
  2296. 'label': 'refresh',
  2297. "styleClass": "mdc-button--outlined",
  2298. // self.widgets.buttonStroked(
  2299. // {
  2300. // "label": "Update",
  2301. "onclick": function (e) {
  2302. let editor = document.querySelector("#aceEditor").env.editor;
  2303. let evalText = editor.getValue();
  2304. // if (this._method.type == 'complexProperty') {
  2305. // let propValue = evalText;
  2306. // try {
  2307. // //propValue = JSON.parse(propValue);
  2308. // self.kernel.setProperty(this._editorNode, this._methodName, propValue);
  2309. // } catch (e) {
  2310. // // restore the original value on error
  2311. // this.value = propValue;
  2312. // }
  2313. // } else {
  2314. // }
  2315. self.kernel.setMethod(this._editorNode, this._methodName,
  2316. { body: evalText, type: "application/javascript", parameters: this._method.parameters });
  2317. }
  2318. }
  2319. )]
  2320. },
  2321. {
  2322. $type: "div",
  2323. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1 tooltip",
  2324. $components: [
  2325. {
  2326. class: "tooltiptext",
  2327. $type: "span",
  2328. $text: "Call It"
  2329. },
  2330. self.widgets.iconButton({
  2331. 'label': 'play_arrow',
  2332. "styleClass": "mdc-button--outlined",
  2333. // self.widgets.buttonStroked(
  2334. // {
  2335. // "label": "Call",
  2336. "onclick": function (e) {
  2337. var params = [];
  2338. if (this._method.parameters) {
  2339. let paramsLength = this._method.parameters.length
  2340. if (paramsLength >= 1) {
  2341. let paramsVal = document.querySelector("#methodParams").value;
  2342. try {
  2343. params = JSON.parse(paramsVal);
  2344. //params.push(prmtr);
  2345. } catch (e) {
  2346. self.logger.error('Invalid Value');
  2347. }
  2348. }
  2349. };
  2350. let editor = document.querySelector("#aceEditor").env.editor;
  2351. let evalText = editor.getValue();
  2352. let allLines = editor.selection.doc.getAllLines();
  2353. let search = this._methodName+'(';
  2354. let findLine = Object.entries(allLines).filter(el=>el[1].includes(search))[0];
  2355. //TODO: temporal fix for recursive future call from the editor
  2356. if(findLine) {
  2357. if(findLine[1].includes(search)) {
  2358. let position = {
  2359. row: findLine[0],
  2360. column: 0
  2361. };
  2362. var Range = ace.require("ace/range").Range;
  2363. let tempString = "//CLICK FOR CALL AGAIN ";
  2364. if(findLine[1].includes(tempString)){
  2365. let newText = findLine[1].replace(tempString, "");
  2366. editor.session.replace(new Range(position.row, 0, position.row, Number.MAX_VALUE), newText);
  2367. self.kernel.setMethod(this._editorNode, this._methodName,
  2368. { body: editor.getValue(), type: "application/javascript", parameters: this._method.parameters });
  2369. } else if(findLine[1].includes("//")) { //startsWith
  2370. } else {
  2371. let newText = tempString + findLine[1];
  2372. editor.session.replace(new Range(position.row, 0, position.row, Number.MAX_VALUE), newText);
  2373. self.kernel.setMethod(this._editorNode, this._methodName,
  2374. { body: editor.getValue(), type: "application/javascript", parameters: this._method.parameters });
  2375. }
  2376. }
  2377. }
  2378. self.kernel.callMethod(this._editorNode, this._methodName, params);
  2379. }
  2380. })
  2381. ]
  2382. },
  2383. {
  2384. $type: "div",
  2385. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1 tooltip",
  2386. $components: [
  2387. {
  2388. class: "tooltiptext",
  2389. $type: "span",
  2390. $text: "Do It"
  2391. },
  2392. self.widgets.iconButton({
  2393. 'label': 'arrow_forward',
  2394. "styleClass": "mdc-button--outlined",
  2395. // self.widgets.buttonStroked(
  2396. // {
  2397. // "label": "Do It",
  2398. "onclick": function (e) {
  2399. let editor = document.querySelector("#aceEditor").env.editor;
  2400. codeEditorDoit.call(self, editor, this._editorNode);
  2401. }
  2402. })
  2403. ]
  2404. },
  2405. {
  2406. $type: "div",
  2407. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1 tooltip",
  2408. $components: [
  2409. {
  2410. class: "tooltiptext",
  2411. $type: "span",
  2412. $text: "Print It"
  2413. },
  2414. self.widgets.iconButton({
  2415. 'label': 'details',
  2416. "styleClass": "mdc-button--outlined",
  2417. // self.widgets.buttonStroked(
  2418. // {
  2419. // "label": "Print It",
  2420. "onclick": function (e) {
  2421. let editor = document.querySelector("#aceEditor").env.editor;
  2422. codeEditorPrintit.call(self, editor, this._editorNode);
  2423. }
  2424. })
  2425. ]
  2426. },
  2427. {
  2428. $type: "div",
  2429. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1 tooltip",
  2430. $components: [
  2431. {
  2432. class: "tooltiptext",
  2433. $type: "span",
  2434. $text: "Print It on Console"
  2435. },
  2436. self.widgets.iconButton({
  2437. 'label': 'code',
  2438. "styleClass": "mdc-button--outlined",
  2439. // self.widgets.buttonStroked(
  2440. // {
  2441. // "label": "Print It on Console",
  2442. "onclick": function (e) {
  2443. let editor = document.querySelector("#aceEditor").env.editor;
  2444. codeEditorPrintitInDebugger.call(self, editor, this._editorNode);
  2445. }
  2446. })
  2447. ]
  2448. }
  2449. ]
  2450. },
  2451. {
  2452. $type: "div",
  2453. class: "mdc-layout-grid__inner",
  2454. $components: [
  2455. {
  2456. $type: "div",
  2457. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-3",
  2458. style: "overflow-y: scroll; max-height: 400px;",
  2459. $components: [
  2460. {
  2461. $type: "div",
  2462. class: "mdc-list-group",
  2463. $components: [
  2464. {
  2465. $type: "h3",
  2466. class: "mdc-list-group__subheader mdc-list-item__text mdc-typography--button",
  2467. $text: "Node methods"
  2468. },
  2469. {
  2470. $type: "ul",
  2471. class: "mdc-list",
  2472. $components: Object.entries(this._getNodeMethods()).map(this._listElement)
  2473. }, listDivider,
  2474. {
  2475. $type: "h3",
  2476. class: "mdc-list-group__subheader mdc-list-item__text mdc-typography--button",
  2477. $text: "Proto methods"
  2478. },
  2479. {
  2480. $type: "ul",
  2481. class: "mdc-list",
  2482. $components: Object.entries(this._getProtoNodeMethods()).map(this._listElement)
  2483. }, listDivider,
  2484. {
  2485. $type: "h3",
  2486. class: "mdc-list-group__subheader mdc-list-item__text mdc-typography--button",
  2487. $text: "Events"
  2488. }
  2489. // {
  2490. //
  2491. // $type: "ul",
  2492. // class: "mdc-list",
  2493. // $components: Object.entries(this._getComplexProps()).map(this._listPropertyElement)
  2494. // }
  2495. ]
  2496. }
  2497. ]
  2498. },
  2499. {
  2500. $type: "div",
  2501. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-9",
  2502. $components: [
  2503. {
  2504. class: "aceEditor",
  2505. id: "aceEditor",
  2506. $type: "div",
  2507. $text: this._method.body,
  2508. $init: function () {
  2509. createAceEditor(self, this._editorNode, "aceEditor");
  2510. }
  2511. }
  2512. ]
  2513. }
  2514. ]
  2515. },
  2516. {
  2517. $type: "div",
  2518. class: "mdc-layout-grid__inner",
  2519. $components: [
  2520. {
  2521. $type: "div",
  2522. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  2523. $components: [
  2524. {
  2525. $type: "span",
  2526. $text: "*"
  2527. }
  2528. ]
  2529. }
  2530. ]
  2531. },
  2532. { //params input
  2533. $type: "div",
  2534. class: "mdc-layout-grid__inner",
  2535. $components: [
  2536. {
  2537. $type: "div",
  2538. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-3",
  2539. $components: [
  2540. self.widgets.inputTextFieldOutlined({
  2541. "id": 'methodName',
  2542. "label": "Method name",
  2543. "value": "newMethodName",
  2544. "change": function (e) {
  2545. let propValue = this.value;
  2546. try {
  2547. } catch (e) {
  2548. // restore the original value on error
  2549. }
  2550. }
  2551. })
  2552. ]
  2553. },
  2554. {
  2555. $type: "div",
  2556. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-7",
  2557. $components: [
  2558. self.widgets.inputTextFieldOutlined({
  2559. "id": 'methodParams',
  2560. "label": "Method parameters",
  2561. "value": JSON.stringify(this._method.parameters),
  2562. "change": function (e) {
  2563. let propValue = this.value;
  2564. try {
  2565. } catch (e) {
  2566. // restore the original value on error
  2567. }
  2568. }
  2569. })
  2570. ]
  2571. },
  2572. {
  2573. $type: "div",
  2574. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  2575. $components: [
  2576. self.widgets.buttonStroked(
  2577. {
  2578. "label": "Create",
  2579. "onclick": function (e) {
  2580. let methodName = document.querySelector('#methodName').value;
  2581. //let methodParams = document.querySelector('#methodParams');
  2582. var params = [];
  2583. let body = '';
  2584. let paramsVal = document.querySelector("#methodParams").value;
  2585. if (paramsVal !== '') {
  2586. try {
  2587. params = JSON.parse(paramsVal);
  2588. //params.push(prmtr);
  2589. } catch (e) {
  2590. self.logger.error('Invalid Value');
  2591. }
  2592. }
  2593. self.kernel.createMethod(this._editorNode, methodName, params, body);
  2594. this._setNode(this._editorNode);
  2595. // let editor = document.querySelector("#aceEditor").env.editor;
  2596. // codeEditorDoit.call(self, editor, this._editorNode);
  2597. }
  2598. })
  2599. ]
  2600. }
  2601. ]
  2602. }
  2603. ]
  2604. //$components:
  2605. }
  2606. }
  2607. let propWindow = {
  2608. $cell: true,
  2609. $type: "div",
  2610. class: "propGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  2611. style: "overflow-y: scroll; max-height: 800px;",
  2612. $components: [
  2613. {
  2614. $type: "div",
  2615. class: "mdc-layout-grid__inner",
  2616. $components: [
  2617. {
  2618. $type: "div",
  2619. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  2620. $components: [
  2621. nodesCell
  2622. ]
  2623. }
  2624. ]
  2625. }
  2626. // <button class="mdc-button">
  2627. // Flat button
  2628. // </button>
  2629. ]
  2630. }
  2631. let clientListCell = {
  2632. $cell: true,
  2633. $type: "div",
  2634. class: "mdc-list",
  2635. id: "clientsList",
  2636. _watchNodes: [],
  2637. _listElement: function (m) {
  2638. return {
  2639. $type: "a",
  2640. class: "mdc-list-item",
  2641. $href: "#",
  2642. $text: m.name,
  2643. onclick: function (e) {
  2644. //self.currentNodeID = m.ID;
  2645. //document.querySelector('#currentNode')._setNode(m.ID);
  2646. }
  2647. }
  2648. },
  2649. $init: function () {
  2650. var t = this;
  2651. setInterval(function () {
  2652. t._updateMe();
  2653. }, 1000);
  2654. },
  2655. _updateMe: function () {
  2656. let clientNodes = self.nodes["http://vwf.example.com/clients.vwf"];
  2657. if (clientNodes) this._watchNodes = self.nodes["http://vwf.example.com/clients.vwf"].children.slice();
  2658. },
  2659. $update: function () {
  2660. //this._clientNodes
  2661. this.$components = this._watchNodes.map(this._listElement)
  2662. }
  2663. }
  2664. //createCellWindow("clientsWindow", clientListCell, "Clients");
  2665. //createCellWindow("propWindow", propWindow, "Scene");
  2666. createCellWindow("codeEditorWindow", codeEditorWindow, "Code editor");
  2667. createCellWindow("propEditorWindow", propEditorWindow, "Prop editor");
  2668. let viewSceneProps = {
  2669. $cell: true,
  2670. $type: "div",
  2671. class: "propGrid mdc-layout-grid mdc-layout-grid--align-left",
  2672. //style: "overflow-y: scroll; max-height: 500px; overflow-x: hidden;",
  2673. $components: [
  2674. {
  2675. $type: "div",
  2676. class: "mdc-layout-grid__inner",
  2677. $components: [
  2678. {
  2679. $type: "div",
  2680. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  2681. $components: [
  2682. nodesCell
  2683. ]
  2684. }]
  2685. }
  2686. ]
  2687. }
  2688. let sideBar = {
  2689. $cell: true,
  2690. $type: "div",
  2691. id: 'sideBar',
  2692. class: "sideBar mdc-top-app-bar--fixed-adjust",
  2693. _sideBarComponent: {},
  2694. _sideCurrentNode: '',
  2695. $init: function () {
  2696. this.style.visibility = 'hidden';
  2697. let fileName = 'appui_js';
  2698. let worldName = self.helpers.getRoot(true).root;//url.split('/')[0];
  2699. let userDB = _LCSDB.user(_LCS_WORLD_USER.pub);
  2700. userDB.get('worlds').get(worldName).get(fileName).once(res => {
  2701. this._importScript(res);
  2702. })
  2703. },
  2704. _importScript: function (sSrc, fOnload) {
  2705. var oScript = document.createElement("script");
  2706. oScript.type = "text\/javascript";
  2707. oScript.async = false;
  2708. //oScript.onerror = loadError;
  2709. if (fOnload) { oScript.onload = fOnload; }
  2710. oScript.text = sSrc;
  2711. //let sideBar = document.querySelector('#sideBar');
  2712. this.appendChild(oScript);
  2713. },
  2714. _getAppDef: async function () {
  2715. // let response = await fetch("/" + self.getRoot() + "/appui.js");
  2716. // let data = await response.text();
  2717. // //console.log(data)
  2718. // return data
  2719. },
  2720. $update: function () {
  2721. this.$components = [
  2722. {
  2723. $type: "button",
  2724. class: "mdc-button mdc-button--compact",
  2725. $text: "X",
  2726. onclick: function (e) {
  2727. document.querySelector('#sideBar').style.visibility = 'hidden';
  2728. this._sideBarComponent = Object.assign({}, {});
  2729. }
  2730. },
  2731. this._sideBarComponent
  2732. ]
  2733. }
  2734. //$components: [this._sideComponents]
  2735. }
  2736. document.querySelector('#' + 'sideBar').$cell(sideBar)
  2737. let defaultApp = function () {
  2738. return {
  2739. $cell: true,
  2740. $type: "div",
  2741. class: "propGrid max-width mdc-layout-grid mdc-layout-grid--align-left",
  2742. $components: [
  2743. {
  2744. $type: "div",
  2745. class: "mdc-layout-grid__inner",
  2746. $components: [
  2747. {
  2748. $type: "div",
  2749. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  2750. $components: [
  2751. {
  2752. $type: "h3",
  2753. class: "mdc-typography--headline",
  2754. $text: "Application",
  2755. }
  2756. ]
  2757. }
  2758. ]
  2759. }
  2760. ]
  2761. }
  2762. }
  2763. let drawerCell = {
  2764. $cell: true,
  2765. $type: "div",
  2766. class: "mdc-drawer__content",
  2767. $components: [
  2768. {
  2769. $type: "nav",
  2770. class: "mdc-list",
  2771. $init: function () { },
  2772. $components: [
  2773. {
  2774. $type: "a",
  2775. class: "mdc-list-item mdc-list-item--activated",
  2776. $href: "#",
  2777. tabindex: "-1",
  2778. onclick: function (e) {
  2779. e.preventDefault();
  2780. let sideBar = document.querySelector('#sideBar');
  2781. try {
  2782. sideBar._sideBarComponent = createApp.call(self);
  2783. } catch (e) {
  2784. sideBar._sideBarComponent = defaultApp();
  2785. }
  2786. self.drawer.open = false//!self.drawer.open
  2787. //self.drawer.close();
  2788. document.querySelector('#sideBar').style.visibility = 'visible';
  2789. },
  2790. $components: [{
  2791. $type: "i",
  2792. class: "material-icons mdc-list-item__graphic",
  2793. 'aria-hidden': "true",
  2794. $text: "play_arrow"
  2795. },
  2796. {
  2797. $text: self.lang.t("App")
  2798. }]
  2799. },
  2800. {
  2801. $type: "a",
  2802. class: "mdc-list-item",
  2803. $href: "#",
  2804. tabindex: "-1",
  2805. onclick: function (e) {
  2806. e.preventDefault();
  2807. let sideBar = document.querySelector('#sideBar');
  2808. sideBar._sideBarComponent = viewSceneProps;
  2809. let currentNode = document.querySelector('#sideBar')._sideCurrentNode;
  2810. currentNode == '' ? document.querySelector('#sideBar')._sideCurrentNode = (vwf_view.kernel.find("", "/")[0]) :
  2811. document.querySelector('#sideBar')._sideCurrentNode = currentNode;
  2812. document.querySelector('#sideBar').style.visibility = 'visible';
  2813. self.drawer.open = !self.drawer.open
  2814. // let currentNode = document.querySelector('#currentNode')._currentNode;
  2815. // currentNode == '' ? document.querySelector('#currentNode')._setNode(vwf_view.kernel.find("", "/")[0]) :
  2816. // document.querySelector('#currentNode')._setNode(currentNode);
  2817. },
  2818. $components: [{
  2819. $type: "i",
  2820. class: "material-icons mdc-list-item__graphic",
  2821. $text: "description"
  2822. },
  2823. {
  2824. $text: "Scene"
  2825. }
  2826. ]
  2827. },
  2828. {
  2829. $type: "a",
  2830. class: "mdc-list-item",
  2831. $href: "#",
  2832. tabindex: "-1",
  2833. onclick: function (e) {
  2834. e.preventDefault();
  2835. //self.currentNodeID = m.ID;
  2836. // document.querySelector('#clientsList')._setClientNodes(self.nodes["http://vwf.example.com/clients.vwf"]);
  2837. // document.querySelector('#clientsWindow').style.visibility = 'visible';
  2838. let sideBar = document.querySelector('#sideBar');
  2839. sideBar._sideBarComponent = createSettings;
  2840. self.drawer.open = !self.drawer.open
  2841. document.querySelector('#sideBar').style.visibility = 'visible';
  2842. },
  2843. $components: [{
  2844. $type: "i",
  2845. class: "material-icons mdc-list-item__graphic",
  2846. 'aria-hidden': "true",
  2847. $text: "create"
  2848. },
  2849. {
  2850. $text: "Create"
  2851. }]
  2852. },
  2853. {
  2854. $type: "a",
  2855. class: "mdc-list-item",
  2856. $href: "#",
  2857. tabindex: "-1",
  2858. onclick: function (e) {
  2859. e.preventDefault();
  2860. // var currentNode = document.querySelector('#currentNode')._currentNode;
  2861. // if (currentNode == '') {
  2862. // currentNode = vwf_view.kernel.find("", "/")[0];
  2863. // }
  2864. document.querySelector('#liveCodeEditor')._setNode(vwf_view.kernel.find("", "/")[0]);
  2865. //createAceEditor(self, currentNode);
  2866. document.querySelector('#codeEditorWindow').style.visibility = 'visible';
  2867. },
  2868. $components: [{
  2869. $type: "i",
  2870. class: "material-icons mdc-list-item__graphic",
  2871. 'aria-hidden': "true",
  2872. $text: "code"
  2873. },
  2874. {
  2875. $text: "Code editor"
  2876. }]
  2877. },
  2878. {
  2879. $type: "a",
  2880. class: "mdc-list-item",
  2881. $href: "#",
  2882. tabindex: "-1",
  2883. onclick: function (e) {
  2884. e.preventDefault();
  2885. //self.currentNodeID = m.ID;
  2886. // document.querySelector('#clientsList')._setClientNodes(self.nodes["http://vwf.example.com/clients.vwf"]);
  2887. // document.querySelector('#clientsWindow').style.visibility = 'visible';
  2888. let sideBar = document.querySelector('#sideBar');
  2889. sideBar._sideBarComponent = avatarSettings;
  2890. self.drawer.open = !self.drawer.open
  2891. document.querySelector('#sideBar').style.visibility = 'visible';
  2892. },
  2893. $components: [{
  2894. $type: "i",
  2895. class: "material-icons mdc-list-item__graphic",
  2896. 'aria-hidden': "true",
  2897. $text: "account_circle"
  2898. },
  2899. {
  2900. $text: "My Avatar"
  2901. }]
  2902. },
  2903. {
  2904. $type: "a",
  2905. class: "mdc-list-item",
  2906. $href: "#",
  2907. tabindex: "-1",
  2908. onclick: function (e) {
  2909. e.preventDefault();
  2910. //self.currentNodeID = m.ID;
  2911. // document.querySelector('#clientsList')._setClientNodes(self.nodes["http://vwf.example.com/clients.vwf"]);
  2912. let sideBar = document.querySelector('#sideBar');
  2913. sideBar._sideBarComponent = viewSettings;
  2914. self.drawer.open = !self.drawer.open
  2915. document.querySelector('#sideBar').style.visibility = 'visible';
  2916. },
  2917. $components: [{
  2918. $type: "i",
  2919. class: "material-icons mdc-list-item__graphic",
  2920. 'aria-hidden': "true",
  2921. $text: "settings"
  2922. },
  2923. {
  2924. $text: "Settings"
  2925. }]
  2926. },
  2927. {
  2928. $type: "a",
  2929. class: "mdc-list-item",
  2930. $href: "#",
  2931. tabindex: "-1",
  2932. onclick: function (e) {
  2933. e.preventDefault();
  2934. //self.currentNodeID = m.ID;
  2935. // document.querySelector('#clientsList')._setClientNodes(self.nodes["http://vwf.example.com/clients.vwf"]);
  2936. let sideBar = document.querySelector('#sideBar');
  2937. sideBar._sideBarComponent = loadSaveSettings;
  2938. if (document.querySelector('#loadSaveSettings')) {
  2939. //document.querySelector('#loadSaveSettings')._refresh();
  2940. //document.querySelector('#loadSaveSettings')._getStates();
  2941. }
  2942. //sideBar._sideBarComponent._getStates();
  2943. self.drawer.open = !self.drawer.open
  2944. document.querySelector('#sideBar').style.visibility = 'visible';
  2945. },
  2946. $components: [{
  2947. $type: "i",
  2948. class: "material-icons mdc-list-item__graphic",
  2949. 'aria-hidden': "true",
  2950. $text: "save"
  2951. },
  2952. {
  2953. $text: "Clone/Save"
  2954. }]
  2955. },
  2956. self.widgets.divider,
  2957. webrtcGUI,
  2958. self.widgets.divider,
  2959. self.widgets.headerH3("h3", "Users online", "userList mdc-list-group__subheader"),
  2960. clientListCell
  2961. //widgets.headerH3("h3", "WebRTC", "userList mdc-list-group__subheader"),
  2962. ]
  2963. }
  2964. // {
  2965. // $cell: true,
  2966. // $type: "div",
  2967. // class: "mdc-persistent-drawer__toolbar-spacer",
  2968. // },
  2969. // {
  2970. // $cell: true,
  2971. // $type: "div",
  2972. // class: "mdc-list-group",
  2973. // $components: [{
  2974. // $cell: true,
  2975. // $type: "nav",
  2976. // class: "mdc-list",
  2977. // $components: [
  2978. // ]
  2979. // }]
  2980. // }
  2981. ]
  2982. };
  2983. // <div class="mdc-form-field">
  2984. // <input type="checkbox" id="input">
  2985. // <label for="input">Input Label</label>
  2986. // </div>
  2987. document.querySelector("#drawer").$cell({
  2988. $cell: true,
  2989. $type: "aside",
  2990. class: "mdc-drawer mdc-drawer--modal",
  2991. $init: function () {
  2992. let elScrim = document.createElement("div");
  2993. elScrim.classList.add("mdc-drawer-scrim");
  2994. this.after(elScrim);
  2995. self.drawer = new mdc.drawer.MDCDrawer(this);
  2996. },
  2997. $components: [
  2998. {
  2999. $type: "div",
  3000. class: "mdc-drawer__header",
  3001. $components: [
  3002. {
  3003. $type: "h3",
  3004. class: "mdc-drawer__title",
  3005. $text: self.lang.t("home")
  3006. },
  3007. {
  3008. $type: "h6",
  3009. class: "mdc-drawer__subtitle",
  3010. $text: "menu"
  3011. }
  3012. ]
  3013. },
  3014. // {
  3015. // $type: "button"
  3016. // },
  3017. drawerCell]
  3018. }
  3019. );
  3020. let toolbar = {
  3021. $cell: true,
  3022. $type: "div",
  3023. class: "mdc-top-app-bar__row",
  3024. $components: [{
  3025. $type: "section",
  3026. class: "mdc-top-app-bar__section mdc-top-app-bar__section--align-start",
  3027. $components: [
  3028. {
  3029. $type: "button",
  3030. type: "button",
  3031. class: "mdc-icon-button material-icons mdc-top-app-bar__navigation-icon",
  3032. $text: "menu"
  3033. },
  3034. {
  3035. $type: "span",
  3036. class: "mdc-top-app-bar__title catalog-title",
  3037. $text: "LiveCoding.space"
  3038. },
  3039. {
  3040. $type: "div",
  3041. class: "mdc-menu-anchor",
  3042. $components: [
  3043. {
  3044. $type: "a",
  3045. class: "mdc-icon-button material-icons mdc-top-app-bar__action-item",
  3046. id: "toggleCreate",
  3047. $text: "apps",
  3048. 'aria-label': "More"
  3049. },
  3050. {
  3051. $type: "div",
  3052. class: "mdc-menu mdc-menu-surface",
  3053. "tabindex": "-1",
  3054. id: "create-menu",
  3055. $init: function () {
  3056. //var menuEl = document.querySelector('#demo-menu');
  3057. var menu = new mdc.menu.MDCMenu(this);
  3058. var toggle = document.querySelector('#toggleCreate');
  3059. toggle.addEventListener('click', function () {
  3060. menu.open = !menu.open;
  3061. });
  3062. },
  3063. style: "transform-origin: right top 0px; right: 0px; top: 0px;",
  3064. $components: [
  3065. {
  3066. $type: "ul",
  3067. class: "mdc-menu__items mdc-list",
  3068. role: "menu",
  3069. 'aria-hidden': "true",
  3070. // style: "transform: scale(1, 1);",
  3071. $components: [
  3072. {
  3073. $type: "li",
  3074. class: "mdc-list-item",
  3075. role: "menuitem",
  3076. tabindex: "0",
  3077. $text: "Apps"
  3078. }
  3079. ]
  3080. }
  3081. ]
  3082. }
  3083. ]
  3084. },
  3085. self.widgets.icontoggle({
  3086. 'styleClass': "mdc-top-app-bar__action-item",
  3087. 'id': "selectNodeSwitch",
  3088. 'label': 'select',
  3089. 'on': JSON.stringify({ "content": "radio_button_checked", "label": "Select" }),
  3090. 'off': JSON.stringify({ "content": "radio_button_unchecked", "label": "Unselect" }),
  3091. 'state': false,
  3092. 'init': function () {
  3093. this._comp = mdc.iconButton.MDCIconButtonToggle.attachTo(this);
  3094. this.addEventListener('MDCIconButtonToggle:change', (e) => {
  3095. let avatarID = 'avatar-' + vwf.moniker_;
  3096. let avatarNode = self.nodes['avatar-' + vwf.moniker_];
  3097. let mode = JSON.parse(avatarNode.properties.selectMode.getValue());
  3098. if (mode) {
  3099. console.log("unselect");
  3100. vwf_view.kernel.setProperty(avatarID, "selectMode", false);
  3101. } else {
  3102. console.log("select")
  3103. vwf_view.kernel.setProperty(avatarID, "selectMode", true);
  3104. }
  3105. });
  3106. }
  3107. })
  3108. ]
  3109. },
  3110. {
  3111. $type: "section",
  3112. class: "mdc-top-app-bar__section mdc-top-app-bar__section--align-end",
  3113. $components: [
  3114. {
  3115. $type: "a",
  3116. href: "#",
  3117. class: "mdc-icon-button menuItem mdc-top-app-bar__action-item",
  3118. $text: "EN",
  3119. onclick: function () {
  3120. //self.lang.changeLanguageTo('en')
  3121. localStorage.setItem('krestianstvo_locale', 'en');
  3122. window.location.reload(true);
  3123. }
  3124. },
  3125. {
  3126. $type: "a",
  3127. href: "#",
  3128. class: "mdc-icon-button menuItem mdc-top-app-bar__action-item",
  3129. $text: "RU",
  3130. onclick: function () {
  3131. //self.lang.changeLanguageTo('ru')
  3132. localStorage.setItem('krestianstvo_locale', 'ru');
  3133. window.location.reload(true);
  3134. }
  3135. },
  3136. {
  3137. $type: "a",
  3138. href: "#",
  3139. class: "material-icons mdc-icon-button mdc-top-app-bar__action-item",
  3140. $text: "help",
  3141. 'aria-label': "Help",
  3142. onclick: function (e) {
  3143. e.preventDefault();
  3144. console.log("TODO: help window")
  3145. }
  3146. }
  3147. ]
  3148. }
  3149. ]
  3150. };
  3151. document.querySelector("#toolbar").$cell({
  3152. $cell: true,
  3153. $type: "div",
  3154. class: "drawer-frame-app-content",
  3155. $components: [
  3156. {
  3157. $type: "header",
  3158. class: "mdc-top-app-bar drawer-top-app-bar",
  3159. $init: function () {
  3160. const topAppBar = new mdc.topAppBar.MDCTopAppBar.attachTo(this);
  3161. topAppBar.listen('MDCTopAppBar:nav', () => {
  3162. self.drawer.open = !self.drawer.open;
  3163. });
  3164. },
  3165. $components: [
  3166. toolbar
  3167. ]
  3168. }
  3169. ]
  3170. }
  3171. );
  3172. // var toggleNodes = document.querySelectorAll('.mdc-icon-button');
  3173. // toggleNodes.forEach(el => {
  3174. // mdc.iconButton.MDCIconButtonToggle.attachTo(el);
  3175. // });
  3176. //==============
  3177. },
  3178. createdNode: function (nodeID, childID, childExtendsID, childImplementsIDs,
  3179. childSource, childType, childIndex, childName, callback /* ( ready ) */) {
  3180. // var nodeIDAttribute = $.encoder.encodeForHTMLAttribute("id", nodeID, true);
  3181. // var childIDAttribute = $.encoder.encodeForHTMLAttribute("id", childID, true);
  3182. // var childIDAlpha = $.encoder.encodeForAlphaNumeric(childID);
  3183. var kernel = this.kernel;
  3184. var self = this;
  3185. var parent = this.nodes[nodeID];
  3186. var node = this.nodes[childID] = {
  3187. children: [],
  3188. properties: [],
  3189. events: {},
  3190. methods: {},
  3191. parent: parent,
  3192. parentID: nodeID,
  3193. ID: childID,
  3194. extendsID: childExtendsID,
  3195. implementsIDs: childImplementsIDs,
  3196. source: childSource,
  3197. name: childName,
  3198. };
  3199. if (parent) {
  3200. parent.children.push(node);
  3201. }
  3202. if (childID == vwf_view.kernel.find("", "/")[0] && childExtendsID && this.kernel.test(childExtendsID,
  3203. "self::element(*,'http://vwf.example.com/aframe/ascene.vwf')", childExtendsID)) {
  3204. this.scenes[childID] = node;
  3205. }
  3206. let nodeCell = document.querySelector("#currentNode");
  3207. if (nodeCell !== null) {
  3208. if (nodeCell._currentNode === nodeID) {
  3209. nodeCell._getChildNodes();
  3210. }
  3211. }
  3212. if (nodeID === this.kernel.application()) {
  3213. // document.querySelector('a-scene').classList.add("mdc-toolbar-fixed-adjust");
  3214. document.querySelector('body').classList.add("editor-body");
  3215. }
  3216. },
  3217. createdProperty: function (nodeID, propertyName, propertyValue) {
  3218. return this.initializedProperty(nodeID, propertyName, propertyValue);
  3219. },
  3220. initializedProperty: function (nodeID, propertyName, propertyValue) {
  3221. var node = this.nodes[nodeID];
  3222. if (!node) return; // TODO: patch until full-graph sync is working; drivers should be able to assume that nodeIDs refer to valid objects
  3223. var property = node.properties[propertyName] = createProperty.call(this, node, propertyName, propertyValue);
  3224. node.properties.push(property);
  3225. let nodeCell = document.querySelector("#currentNode");
  3226. if (nodeCell !== null) {
  3227. if (nodeCell._currentNode === nodeID) {
  3228. nodeCell._getNodeProperties();
  3229. }
  3230. }
  3231. },
  3232. deletedNode: function (nodeID) {
  3233. var node = this.nodes[nodeID];
  3234. node.parent.children.splice(node.parent.children.indexOf(node), 1);
  3235. delete this.nodes[nodeID];
  3236. let nodeCell = document.querySelector("#currentNode");
  3237. if (nodeCell) {
  3238. if (nodeCell._currentNode !== "") {
  3239. if (nodeCell._currentNode !== nodeID) {
  3240. //&& (this.nodes[nodeID] !== undefined)
  3241. nodeCell._getChildNodes();
  3242. } else {
  3243. nodeCell._setNode(vwf_view.kernel.find("", "/")[0]);
  3244. nodeCell._getChildNodes();
  3245. }
  3246. }
  3247. }
  3248. },
  3249. //addedChild: [ /* nodeID, childID, childName */ ],
  3250. //removedChild: [ /* nodeID, childID */ ],
  3251. satProperty: function (nodeID, propertyName, propertyValue) {
  3252. var node = this.nodes[nodeID];
  3253. if (!node) return; // TODO: patch until full-graph sync is working; drivers should be able to assume that nodeIDs refer to valid objects
  3254. // It is possible for a property to have satProperty called for it without ever getting an
  3255. // initializedProperty (if that property delegated to itself or another on replication)
  3256. // Catch that case here and create the property
  3257. if (!node.properties[propertyName]) {
  3258. var property = node.properties[propertyName] = createProperty.call(this, node, propertyName, propertyValue);
  3259. node.properties.push(property);
  3260. }
  3261. try {
  3262. propertyValue = utility.transform(propertyValue, utility.transforms.transit);
  3263. node.properties[propertyName].value = JSON.stringify(propertyValue);
  3264. node.properties[propertyName].rawValue = propertyValue;
  3265. } catch (e) {
  3266. this.logger.warnx("satProperty", nodeID, propertyName, propertyValue,
  3267. "stringify error:", e.message);
  3268. node.properties[propertyName].value = propertyValue;
  3269. }
  3270. let nodeCell = document.querySelector('#currentNode');
  3271. if (nodeCell !== null) {
  3272. if (nodeCell._currentNode == nodeID && propertyName == 'isPlaying') {
  3273. console.log('SET PLAY !!!');
  3274. let compID = 'soundStopStartSwitch-' + nodeID;
  3275. let playSwitch = document.querySelector("[id='" + compID + "']");
  3276. if (playSwitch) {
  3277. // const mycomp = new mdc.iconToggle.MDCIconToggle(playSwitch); //new mdc.select.MDCIconToggle
  3278. playSwitch._comp.on = propertyValue;
  3279. }
  3280. }
  3281. }
  3282. if (nodeCell !== null) {
  3283. if (nodeCell._currentNode == nodeID && propertyName == 'edit') {
  3284. console.log('EDIT !!!')
  3285. }
  3286. }
  3287. let propCell = document.querySelector("#currentNode #prop-" + propertyName);
  3288. let propSlider = document.querySelector("#currentNode #prop-slider-" + propertyName);
  3289. if (propCell !== null) {
  3290. if (propCell._currentNode == nodeID) {
  3291. propCell.value = node.properties[propertyName].getValue();
  3292. }
  3293. }
  3294. if (propSlider !== null) {
  3295. if (propSlider._currentNode == nodeID) {
  3296. //const propSliderComp = new new mdc.slider.MDCSlider(propSlider);
  3297. propSlider._comp.value = node.properties[propertyName].getValue();
  3298. }
  3299. }
  3300. },
  3301. //gotProperty: [ /* nodeID, propertyName, propertyValue */ ],
  3302. gotProperty: function (nodeID, propertyName, propertyValue) {
  3303. var node = this.nodes[nodeID];
  3304. if (!node) return; // TODO: patch until full-graph sync is working; drivers should be able to assume that nodeIDs refer to valid objects
  3305. let nodeCell = document.querySelector('#currentNode');
  3306. if (nodeCell !== null) {
  3307. if (nodeCell._currentNode == nodeID && propertyName == 'edit') {
  3308. let gizmoChild = node.children.filter(el=>el.ID.includes('gizmo'));
  3309. if (gizmoChild.length > 0) {
  3310. let editCheckBox = document.querySelector("#currentNode #editnode");
  3311. if (editCheckBox) {
  3312. let mdcSwitch = editCheckBox._switch;
  3313. if (mdcSwitch) {
  3314. mdcSwitch.checked = propertyValue
  3315. }
  3316. }
  3317. console.log('EDIT !!! is ' + propertyValue)
  3318. }
  3319. }
  3320. }
  3321. },
  3322. createdMethod: function (nodeID, methodName, methodParameters, methodBody) {
  3323. var node = this.nodes[nodeID];
  3324. if (node) {
  3325. node.methods[methodName] = methodParameters;
  3326. }
  3327. },
  3328. //calledMethod: function( nodeID, methodName, methodParameters, methodValue ) {
  3329. //},
  3330. createdEvent: function (nodeID, eventName, eventParameters) {
  3331. var node = this.nodes[nodeID];
  3332. if (node) {
  3333. node.events[eventName] = eventParameters;
  3334. }
  3335. },
  3336. firedEvent: function (nodeID, eventName, eventParameters) {
  3337. var node = this.nodes[nodeID];
  3338. if (node) {
  3339. if (eventName == 'printEvent'){
  3340. var clientThatSatProperty = self.kernel.client();
  3341. var me = self.kernel.moniker();
  3342. // If the transform property was initially updated by this view....
  3343. if ( clientThatSatProperty == me) {
  3344. let editor = document.querySelector("#aceEditor").env.editor;
  3345. if(editor){
  3346. var cursorPosition = editor.getCursorPosition();
  3347. var selectedText = editor.getSession().doc.getTextRange(editor.selection.getRange());
  3348. if (selectedText !== "") {
  3349. cursorPosition = editor.selection.getRange().end;
  3350. }
  3351. let data = eventParameters[0];//JSON.stringify(eventParameters[0]);
  3352. editor.session.insert(cursorPosition, data);
  3353. }
  3354. //console.log(eventParameters);
  3355. }
  3356. }
  3357. }
  3358. },
  3359. executed: function (nodeID, scriptText, scriptType) {
  3360. // var nodeScript = {
  3361. // text: scriptText,
  3362. // type: scriptType,
  3363. // };
  3364. // if ( !this.allScripts[ nodeID ] ) {
  3365. // var nodeScripts = new Array();
  3366. // nodeScripts.push(nodeScript);
  3367. // this.allScripts[ nodeID ] = nodeScripts;
  3368. // }
  3369. // else {
  3370. // this.allScripts[ nodeID ].push(nodeScript);
  3371. // }
  3372. },
  3373. //ticked: [ /* time */ ],
  3374. });
  3375. function createCellWindow(elementID, cellNode, title) {
  3376. document.querySelector('#' + elementID).$cell({
  3377. $cell: true,
  3378. $type: "div",
  3379. id: elementID,
  3380. style: 'position: absolute;',
  3381. class: 'draggable',
  3382. $init: function () {
  3383. // let draggie = new Draggabilly('.draggable', {
  3384. // handle: '.handle',
  3385. // containment: true
  3386. // });
  3387. // get all draggie elements
  3388. var draggableElems = document.querySelectorAll('.draggable');
  3389. // array of Draggabillies
  3390. var draggies = []
  3391. // init Draggabillies
  3392. for (var i = 0, len = draggableElems.length; i < len; i++) {
  3393. var draggableElem = draggableElems[i];
  3394. var draggie = new Draggabilly(draggableElem, {
  3395. handle: '.handle'
  3396. //containment: true
  3397. });
  3398. draggies.push(draggie);
  3399. }
  3400. this.style.visibility = 'hidden';
  3401. },
  3402. $components: [
  3403. {
  3404. $type: "div",
  3405. class: "handle"
  3406. },
  3407. {
  3408. $type: "button",
  3409. class: "mdc-button mdc-button--compact",
  3410. $text: "X",
  3411. onclick: function (e) {
  3412. //self.currentNodeID = m.ID;
  3413. if( elementID == 'codeEditorWindow'){
  3414. //self.nodes[currentNode].liveBindings = {};
  3415. }
  3416. document.querySelector('#' + elementID).style.visibility = 'hidden';
  3417. }
  3418. },
  3419. {
  3420. $type: "span",
  3421. class: "mdc-typography--button",
  3422. $text: title
  3423. },
  3424. cellNode,
  3425. {
  3426. $type: "div",
  3427. class: "handle",
  3428. style: "height: 10px; width: inherit;",
  3429. //$text: "sdfsdf"
  3430. }
  3431. // { $text: "23423"}
  3432. ]
  3433. }
  3434. );
  3435. }
  3436. // -- getChildByName --------------------------------------------------------------------
  3437. function getChildByName(node, childName) {
  3438. var childNode = undefined;
  3439. for (var i = 0; i < node.children.length && childNode === undefined; i++) {
  3440. if (node.children[i].name == childName) {
  3441. childNode = node.children[i];
  3442. }
  3443. }
  3444. return childNode;
  3445. };
  3446. // -- viewScript ------------------------------------------------------------------------
  3447. function createAceEditor(view, nodeID, elID) {
  3448. var editor = view.ace.edit(elID);
  3449. editor.setTheme("ace/theme/monokai");
  3450. editor.setFontSize(20);
  3451. editor.getSession().setMode("ace/mode/javascript");
  3452. editor.commands.addCommand({
  3453. name: "doit",
  3454. bindKey: { win: "Ctrl-e", mac: "Command-e" },
  3455. exec: function () {
  3456. codeEditorDoit(editor, nodeID);
  3457. }
  3458. });
  3459. editor.commands.addCommand({
  3460. name: "printit",
  3461. bindKey: { win: "Ctrl-b", mac: "Command-b" },
  3462. exec: function () {
  3463. codeEditorPrintit(editor, nodeID);
  3464. }
  3465. });
  3466. return editor;
  3467. }
  3468. function isAFrameComponent(nodeID) {
  3469. let node = self.nodes[nodeID];
  3470. let nodeProtos = getPrototypes(self.kernel, node.extendsID);
  3471. if (nodeProtos.includes('http://vwf.example.com/aframe/componentNode.vwf')) {
  3472. return true
  3473. }
  3474. return false
  3475. }
  3476. function isAFrameEntity(nodeID) {
  3477. let node = self.nodes[nodeID];
  3478. let nodeProtos = getPrototypes(self.kernel, node.extendsID);
  3479. if (nodeProtos.includes('http://vwf.example.com/aframe/node.vwf')) {
  3480. return true
  3481. }
  3482. return false
  3483. }
  3484. function getPrototypes(kernel, extendsID) {
  3485. var prototypes = [];
  3486. var id = extendsID;
  3487. while (id !== undefined) {
  3488. prototypes.push(id);
  3489. id = kernel.prototype(id);
  3490. }
  3491. return prototypes;
  3492. }
  3493. function getPrototypes(kernel, extendsID) {
  3494. var prototypes = [];
  3495. var id = extendsID;
  3496. while (id !== undefined) {
  3497. prototypes.push(id);
  3498. id = kernel.prototype(id);
  3499. }
  3500. return prototypes;
  3501. }
  3502. function createProperty(node, propertyName, propertyValue) {
  3503. var property = {
  3504. name: propertyName,
  3505. rawValue: propertyValue,
  3506. value: undefined,
  3507. getValue: function () {
  3508. var propertyValue;
  3509. if (this.value == undefined) {
  3510. try {
  3511. propertyValue = utility.transform(this.rawValue, utility.transforms.transit);
  3512. this.value = JSON.stringify(propertyValue);
  3513. } catch (e) {
  3514. this.logger.warnx("createdProperty", nodeID, this.propertyName, this.rawValue,
  3515. "stringify error:", e.message);
  3516. this.value = this.rawValue;
  3517. }
  3518. }
  3519. return this.value;
  3520. }
  3521. };
  3522. return property;
  3523. }
  3524. function getProperties(kernel, extendsID) {
  3525. var pTypes = getPrototypes(kernel, extendsID);
  3526. var pProperties = {};
  3527. if (pTypes) {
  3528. for (var i = 0; i < pTypes.length; i++) {
  3529. var nd = this.nodes[pTypes[i]];
  3530. if (nd && nd.properties) {
  3531. for (var key in nd.properties) {
  3532. pProperties[key] = { "prop": nd.properties[key], "prototype": pTypes[i] };
  3533. }
  3534. }
  3535. }
  3536. }
  3537. return pProperties;
  3538. }
  3539. function getChildren(kernel, extendsID) {
  3540. var pTypes = getPrototypes(kernel, extendsID);
  3541. var pChildren = {};
  3542. if (pTypes) {
  3543. for (var i = 0; i < pTypes.length; i++) {
  3544. var nd = this.nodes[pTypes[i]];
  3545. if (nd && nd.children) {
  3546. for (var key in nd.children) {
  3547. pChildren[key] = nd.children[key];
  3548. }
  3549. }
  3550. }
  3551. }
  3552. return pChildren;
  3553. }
  3554. function getEvents(kernel, extendsID) {
  3555. var pTypes = getPrototypes(kernel, extendsID);
  3556. var events = {};
  3557. if (pTypes) {
  3558. for (var i = 0; i < pTypes.length; i++) {
  3559. var nd = this.nodes[pTypes[i]];
  3560. if (nd && nd.events) {
  3561. for (var key in nd.events) {
  3562. events[key] = nd.events[key];
  3563. }
  3564. }
  3565. }
  3566. }
  3567. return events;
  3568. }
  3569. function getMethods(kernel, extendsID) {
  3570. var pTypes = getPrototypes(kernel, extendsID);
  3571. var methods = {};
  3572. if (pTypes) {
  3573. for (var i = 0; i < pTypes.length; i++) {
  3574. var nd = this.nodes[pTypes[i]];
  3575. if (nd && nd.methods) {
  3576. for (var key in nd.methods) {
  3577. methods[key] = nd.methods[key];
  3578. }
  3579. }
  3580. }
  3581. }
  3582. return methods;
  3583. }
  3584. // -- Show Code Editor tab
  3585. function codeEditorDoit(editor, nodeID) {
  3586. var selectedText = editor.getSession().doc.getTextRange(editor.selection.getRange());
  3587. if (selectedText == "") {
  3588. var currline = editor.getSelectionRange().start.row;
  3589. var selectedText = editor.session.getLine(currline);
  3590. }
  3591. //console.log(selectedText);
  3592. //var sceneID = self.kernel.application();
  3593. vwf_view.kernel.execute(nodeID, selectedText);
  3594. }
  3595. function codeEditorPrintitInDebugger(editor, nodeID) {
  3596. var selectedText = editor.getSession().doc.getTextRange(editor.selection.getRange());
  3597. if (selectedText == "") {
  3598. var currline = editor.getSelectionRange().start.row;
  3599. var selectedText = editor.session.getLine(currline);
  3600. }
  3601. let scriptText = 'console.log(' + selectedText + ');'
  3602. self.kernel.execute(nodeID, scriptText);
  3603. }
  3604. function codeEditorPrintit(editor, nodeID) {
  3605. var selectedText = editor.getSession().doc.getTextRange(editor.selection.getRange());
  3606. if (selectedText == "") {
  3607. var currline = editor.getSelectionRange().start.row;
  3608. var selectedText = editor.session.getLine(currline);
  3609. }
  3610. //console.log(selectedText);
  3611. //var sceneID = self.kernel.application();
  3612. //vwf.views["vwf/view/editor-new"].nodes[this.id].liveBindings
  3613. //let node = self.nodes[nodeID];
  3614. let me = self.kernel.moniker();
  3615. vwf_view.kernel.fireEvent(nodeID, 'printIt', [selectedText, me]);
  3616. // let printText = _app.helpers.replaceSubStringALL(selectedText,'this','me');
  3617. // let bindString = 'vwf.views["vwf/view/aframe"].nodes["'+ nodeID + '"].liveBindings';
  3618. // let scriptText = 'let binding = '+ bindString +'; binding.me = this; lively.vm.syncEval("var print = ' + printText + '",{topLevelVarRecorder: binding});';
  3619. // vwf_view.kernel.execute(nodeID, scriptText);
  3620. // let scriptText = 'console.log(' + selectedText + ');'
  3621. // self.kernel.execute(nodeID, scriptText);
  3622. }
  3623. function codeEditorPrintitConsole (editor, nodeID) {
  3624. var selectedText = editor.getSession().doc.getTextRange(editor.selection.getRange());
  3625. if (selectedText == "") {
  3626. var currline = editor.getSelectionRange().start.row;
  3627. var selectedText = editor.session.getLine(currline);
  3628. }
  3629. let scriptText = 'console.log(' + selectedText + ');'
  3630. self.kernel.execute(nodeID, scriptText);
  3631. }
  3632. // -- SupportAjax -----------------------------------------------------------------------------
  3633. // function supportAjaxUploadWithProgress() {
  3634. // return supportAjaxUploadProgressEvents();
  3635. // function supportAjaxUploadProgressEvents() {
  3636. // var xhr = new XMLHttpRequest();
  3637. // return !!(xhr && ('upload' in xhr) && ('onprogress' in xhr.upload));
  3638. // }
  3639. // }
  3640. });