editor-new.js 199 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496
  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().user;
  891. let genWorldID = 'world' + self.helpers.randId();
  892. if (_LCSDB.user().is) {
  893. if (worldOwner == _LCSDB.user().is.alias) {
  894. userGUI.push(
  895. {
  896. $type: "div",
  897. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  898. $components: [
  899. {
  900. $type: "h3",
  901. class: "mdc-typography--title",
  902. $text: self.helpers.appPath
  903. },
  904. self.widgets.buttonStroked(
  905. {
  906. "label": "Save world",
  907. "onclick": function (e) {
  908. _app.saveWorld();
  909. //let fileName = self.helpers.getRoot().root;
  910. //_app.saveState(fileName);
  911. //// let fileName = self.helpers.worldStateName;
  912. ////_app.saveStateAsFile(fileName);
  913. //document.querySelector('#fileName')
  914. //document.querySelector("#fileName").value = '';
  915. //document.querySelector('#' + 'viewSettings').style.visibility = 'hidden';
  916. }
  917. })
  918. ]
  919. }
  920. );
  921. }
  922. userGUI.push(
  923. {
  924. $type: "div",
  925. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  926. $components: [
  927. {
  928. $type: "div",
  929. $components: [
  930. self.widgets.inputTextFieldOutlined({
  931. "id": 'fileName',
  932. "label": genWorldID,
  933. //"value": 'world' + self.helpers.randId(), //self.getSaveName() //self.getRoot()
  934. "change": function (e) {
  935. }
  936. })
  937. // {
  938. // class: "mdc-text-field__input prop-text-field-input",
  939. // id: "fileName",
  940. // $type: "input",
  941. // type: "text",
  942. // value: 'world' + self.helpers.randId() //self.getSaveName() //self.getRoot()
  943. // }
  944. ]
  945. }
  946. ]
  947. },
  948. {
  949. $type: "div",
  950. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  951. $components: [
  952. self.widgets.buttonStroked(
  953. {
  954. "label": "Clone world",
  955. "onclick": function (e) {
  956. let fileName = document.querySelector('#fileName')
  957. let worldOwner = self.helpers.getRoot().user;
  958. let worldName = _app.worldName;
  959. if (_LCSDB.user().is) {
  960. let wn = fileName.value ? fileName.value : genWorldID;
  961. _app.cloneWorld(worldName, worldOwner, wn, true)
  962. // if (worldOwner == _LCSDB.user().is.alias) {
  963. // _app.saveStateAsFile(fileName.value);
  964. // } else {
  965. // console.log('clone world with prototype to: ' + fileName);
  966. // _app.cloneWorldState(fileName.value);
  967. // }
  968. }
  969. //saveStateAsFile.call(self, fileName.value);
  970. //document.querySelector("#fileName").value = '';
  971. //document.querySelector('#' + 'viewSettings').style.visibility = 'hidden';
  972. }
  973. })
  974. ]
  975. }
  976. );
  977. if (worldOwner == _LCSDB.user().is.alias) {
  978. userGUI.push(
  979. {
  980. $type: "div",
  981. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  982. $components: [
  983. {
  984. $type: "p",
  985. },
  986. self.widgets.buttonStroked(
  987. {
  988. "label": "Save state",
  989. "onclick": function (e) {
  990. // _app.saveWorld();
  991. let myWorldName = self.helpers.getRoot().root;
  992. let fileName = document.querySelector('#fileName');
  993. let wn = fileName.value ? fileName.value : myWorldName;
  994. _app.saveState(wn);
  995. //document.querySelector('#fileName')
  996. //document.querySelector("#fileName").value = '';
  997. //document.querySelector('#' + 'viewSettings').style.visibility = 'hidden';
  998. }
  999. })
  1000. ]
  1001. }
  1002. );
  1003. }
  1004. // let saveGUI = document.querySelector('#saveGUI');
  1005. // saveGUI.$components = userGUI.concat(saveGUI.$components);
  1006. //document.querySelector('#fileName').value = 'world' + _app.helpers.randId();
  1007. } else {
  1008. userGUI.push(
  1009. self.widgets.getLoginGUI()
  1010. );
  1011. }
  1012. let saveGUI = document.querySelector('#saveGUI');
  1013. saveGUI.$components = userGUI.concat(saveGUI.$components);
  1014. },
  1015. $update: function () {
  1016. },
  1017. $components:
  1018. [
  1019. {
  1020. $type: "div",
  1021. class: "mdc-layout-grid__inner",
  1022. id: "saveGUI",
  1023. $components: [
  1024. ]
  1025. }
  1026. ]
  1027. }
  1028. let protoPropertiesCell = function (m) {
  1029. return {
  1030. $type: "div",
  1031. class: "mdc-layout-grid__inner",
  1032. _prop: {},
  1033. $init: function () {
  1034. let prop = m[1].prop;
  1035. if (prop.value == undefined && this._currentNode !== undefined) {
  1036. prop.value = JSON.stringify(utility.transform(vwf.getProperty(this._currentNode, prop.name, []), utility.transforms.transit));
  1037. }
  1038. this._prop = prop
  1039. },
  1040. $update: function () {
  1041. this.$components = [
  1042. // {
  1043. // $type: "div",
  1044. // class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-10",
  1045. // $components: [
  1046. // { $text: this._prop.name }
  1047. // ]
  1048. // },
  1049. // {
  1050. // $type: "div",
  1051. // class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1052. // },
  1053. {
  1054. $type: "div",
  1055. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  1056. $components: [
  1057. // {
  1058. // $type: "span",
  1059. // class: "mdc-typography--body2 mdc-typography--adjust-margin protoPropLabel",
  1060. // $text: this._prop.name + ': '
  1061. // },
  1062. {
  1063. $type: "div",
  1064. $components: [
  1065. self.widgets.inputTextFieldStandart({
  1066. "id": 'proto_' + this._prop.name,
  1067. "label": this._prop.name,
  1068. "value": this._prop.getValue(),
  1069. "change": function (e) {
  1070. //set property
  1071. let value = this.value;
  1072. var propValue = value;
  1073. if (_app.helpers.testJSON(value)){
  1074. propValue = JSON.parse(value);
  1075. } else {
  1076. propValue = value;
  1077. }
  1078. self.kernel.setProperty(this._currentNode, this._prop.name, propValue);
  1079. // let propValue = this.value;
  1080. // try {
  1081. // propValue = JSON.parse(propValue);
  1082. // self.kernel.setProperty(this._currentNode, this._prop.name, propValue);
  1083. // } catch (e) {
  1084. // // restore the original value on error
  1085. // this.value = propValue;
  1086. // }
  1087. }
  1088. })
  1089. ]
  1090. }
  1091. ]
  1092. }
  1093. ]
  1094. }
  1095. }
  1096. }
  1097. let propertiesCell = function (m) {
  1098. var editComponents = [{}, {}];
  1099. // fullWidth:
  1100. // fullHeight:
  1101. // xoffset:
  1102. // yoffset:
  1103. // width:
  1104. // height:
  1105. let sliderPropNames = ['width', 'height', 'depth', 'fullWidth', 'fullHeight', 'xoffset', 'yoffset', 'subcamWidth', 'subcamHeight'];
  1106. let sliderProps = {
  1107. 'width': {
  1108. min: 0,
  1109. max: 30
  1110. },
  1111. 'height': {
  1112. min: 0,
  1113. max: 30
  1114. },
  1115. 'depth': {
  1116. min: 0,
  1117. max: 30
  1118. },
  1119. 'fullWidth': {
  1120. min: 0,
  1121. max: 5000,
  1122. step: 10
  1123. },
  1124. 'fullHeight': {
  1125. min: 0,
  1126. max: 5000,
  1127. step: 10
  1128. },
  1129. 'xoffset': {
  1130. min: -10000,
  1131. max: 10000,
  1132. step: 10
  1133. },
  1134. 'yoffset': {
  1135. min: -10000,
  1136. max: 10000,
  1137. step: 10
  1138. },
  1139. 'subcamWidth': {
  1140. min: 0,
  1141. max: 5000,
  1142. step: 10
  1143. },
  1144. 'subcamHeight': {
  1145. min: 0,
  1146. max: 5000,
  1147. step: 10
  1148. }
  1149. }
  1150. if (sliderPropNames.includes(m.name)) {
  1151. let currenValue = JSON.parse(m.getValue());
  1152. var sliderComponent = self.widgets.sliderContinuous({
  1153. 'id': 'prop-slider-' + m.name,
  1154. 'label': 'Slider',
  1155. 'min': sliderProps[m.name].min,
  1156. 'max': sliderProps[m.name].max,
  1157. 'step': sliderProps[m.name].step ? sliderProps[m.name].step : 0.1,
  1158. 'value': currenValue,
  1159. 'init': function () {
  1160. const myEl = this;
  1161. var continuousSlider = new mdc.slider.MDCSlider(myEl);
  1162. this._comp = continuousSlider;
  1163. continuousSlider.listen('MDCSlider:input', function (e) {
  1164. // console.log(continuousSlider.value)
  1165. let myEl = e.currentTarget;
  1166. // let prop = myEl._prop.body;
  1167. //document.querySelector('#propAceEditor').env.editor.setValue(prop);
  1168. self.kernel.setProperty(myEl._currentNode, m.name, continuousSlider.value);
  1169. //continuousValue.textContent = continuousSlider.value;
  1170. });
  1171. continuousSlider.listen('MDCSlider:change', function (e) {
  1172. //console.log(continuousSlider.value);
  1173. let myEl = e.currentTarget;
  1174. // let prop = myEl._prop.body;
  1175. //document.querySelector('#propAceEditor').env.editor.setValue(prop);
  1176. self.kernel.setProperty(myEl._currentNode, m.name, continuousSlider.value);
  1177. //continuousCommittedValue.textContent = continuousSlider.value;
  1178. })
  1179. }
  1180. })
  1181. } else {
  1182. sliderComponent = {}
  1183. }
  1184. if (m.name.indexOf("semantics") > -1) { }
  1185. else if (m.name.indexOf("grammar") > -1) { }
  1186. else if (m.name.indexOf("ohm") > -1) {
  1187. editComponents = [
  1188. {
  1189. $type: "div",
  1190. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-6",
  1191. $components: [
  1192. {
  1193. $type: "button",
  1194. class: "mdc-button",
  1195. $text: "Edit", //edit grammar
  1196. onclick: function (e) {
  1197. var currentNode = document.querySelector('#currentNode')._currentNode;
  1198. if (currentNode == '') {
  1199. currentNode = vwf_view.kernel.find("", "/")[0];
  1200. }
  1201. let editor = document.querySelector('#livePropEditor');
  1202. editor._setNode(currentNode);
  1203. editor._propName = m.name;
  1204. editor._prop = { body: m.rawValue, type: 'complex' }
  1205. document.querySelector('#propEditorWindow').style.visibility = 'visible';
  1206. }
  1207. }
  1208. ]
  1209. },
  1210. {
  1211. $type: "div",
  1212. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1",
  1213. $components: []
  1214. }
  1215. ]
  1216. } else {
  1217. editComponents = [
  1218. {
  1219. $type: "div",
  1220. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-6",
  1221. $components: [
  1222. sliderComponent,
  1223. {
  1224. class: "mdc-text-field prop-mdc-text-field",
  1225. $type: "div",
  1226. $components: [
  1227. self.widgets.inputTextFieldStandart({
  1228. "id": "prop-" + m.name,
  1229. "label": m.name,
  1230. "value": m.getValue(),
  1231. "change": function (e) {
  1232. //set property
  1233. let value = this.value;
  1234. var propValue = value;
  1235. if (_app.helpers.testJSON(value)){
  1236. propValue = JSON.parse(value);
  1237. } else {
  1238. propValue = value;
  1239. //this.value = JSON.parse(JSON.stringify(propValue));
  1240. }
  1241. self.kernel.setProperty(this._currentNode, m.name, propValue);
  1242. //this.value = propValue.toString();
  1243. // let propValue = this.value;
  1244. // try {
  1245. // propValue = JSON.parse(propValue);
  1246. // self.kernel.setProperty(this._currentNode, m.name, propValue);
  1247. // } catch (e) {
  1248. // // restore the original value on error
  1249. // this.value = propValue;
  1250. // }
  1251. }
  1252. })
  1253. ]
  1254. }
  1255. ]
  1256. },
  1257. {
  1258. $type: "div",
  1259. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1",
  1260. $components: [
  1261. {
  1262. $type: "button",
  1263. class: "mdc-button mdc-button--compact",
  1264. $text: "^", //edit grammar
  1265. onclick: function (e) {
  1266. var currentNode = document.querySelector('#currentNode')._currentNode;
  1267. if (currentNode == '') {
  1268. currentNode = vwf_view.kernel.find("", "/")[0];
  1269. }
  1270. let editor = document.querySelector('#livePropEditor');
  1271. editor._setNode(currentNode);
  1272. editor._propName = m.name;
  1273. editor._prop = { body: m.getValue(), type: 'simple' }
  1274. document.querySelector('#propEditorWindow').style.visibility = 'visible';
  1275. }
  1276. }
  1277. ]
  1278. }
  1279. ];
  1280. }
  1281. return {
  1282. $type: "div",
  1283. class: "mdc-layout-grid__inner",
  1284. $components: [
  1285. {
  1286. $type: "div",
  1287. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-3",
  1288. $components: [
  1289. { $text: m.name }
  1290. ]
  1291. },
  1292. {
  1293. $type: "div",
  1294. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1295. },
  1296. editComponents[0],
  1297. editComponents[1]
  1298. ]
  1299. }
  1300. }
  1301. let nodeLink = function (m) {
  1302. var myClass = "nodeItem";
  1303. let myAvatarName = 'avatar-' + self.kernel.moniker();
  1304. (myAvatarName == m.name) ? (myClass = "avatarName mdc-typography--subheading2") :
  1305. myClass = "nodeItem"
  1306. var nodeName = m.name;
  1307. let displayName = vwf.getProperty(m.ID, 'displayName');
  1308. if (displayName) {
  1309. nodeName = displayName
  1310. }
  1311. return {
  1312. $type: "li",
  1313. class: "mdc-list-item",
  1314. $components: [{
  1315. $type: "a",
  1316. class: "mdc-list-item",
  1317. $href: "#",
  1318. $components: [{
  1319. $type: 'span',
  1320. class: myClass,
  1321. $text: nodeName
  1322. }
  1323. ],
  1324. onclick: function (e) {
  1325. //self.currentNodeID = m.ID;
  1326. document.querySelector('#currentNode')._setNode(m.ID);
  1327. // document.querySelector('#liveCodeEditor')._editorNode = m.ID;
  1328. // createAceEditor(self, m.ID);
  1329. }
  1330. }]
  1331. }
  1332. };
  1333. let listDivider = {
  1334. $type: "hr",
  1335. class: "mdc-list-divider",
  1336. }
  1337. let webrtcGUI = {
  1338. $type: "div",
  1339. class: "propGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  1340. $components: [
  1341. {
  1342. $type: "div",
  1343. class: "mdc-layout-grid__inner",
  1344. $components: [
  1345. {
  1346. $type: "div",
  1347. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1348. $components: [
  1349. {
  1350. $type: "span",
  1351. $text: "Chat"
  1352. }
  1353. ]
  1354. },
  1355. {
  1356. $type: "div",
  1357. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1358. $components: [
  1359. self.widgets.icontoggle({
  1360. 'id': "webrtcswitch",
  1361. 'label': 'visibility',
  1362. 'on': JSON.stringify({ "content": "visibility", "label": "Turn On Mic" }),
  1363. 'off': JSON.stringify({ "content": "visibility_off", "label": "Turn Off Mic" }),
  1364. 'state': false,
  1365. 'init': function () {
  1366. this._driver = vwf.views["vwf/view/webrtc"];
  1367. if (!this._driver) {
  1368. //this.classList.add('mdc-icon-toggle--disabled');
  1369. this.setAttribute('disabled',"");
  1370. }
  1371. mdc.iconButton.MDCIconButtonToggle.attachTo(this);
  1372. this.addEventListener('MDCIconButtonToggle:change', (e) => {
  1373. let driver = e.target._driver;
  1374. let chkAttr = e.detail.isOn;
  1375. let avatarID = 'avatar-' + self.kernel.moniker();
  1376. let micToggle = document.querySelector('#webrtcaudio');
  1377. let camToggle = document.querySelector('#webrtcvideo');
  1378. if (chkAttr) {
  1379. driver.startWebRTC(avatarID);
  1380. micToggle.removeAttribute('disabled');
  1381. camToggle.removeAttribute('disabled');
  1382. //micToggle.classList.remove('mdc-icon-toggle--disabled');
  1383. //camToggle.classList.remove('mdc-icon-toggle--disabled');
  1384. console.log("on")
  1385. } else {
  1386. driver.stopWebRTC(avatarID);
  1387. micToggle.setAttribute('disabled',"");
  1388. camToggle.setAttribute('disabled',"");
  1389. //micToggle.classList.add('mdc-icon-toggle--disabled');
  1390. //camToggle.classList.add('mdc-icon-toggle--disabled');
  1391. console.log("off")
  1392. }
  1393. //console.log(e, detail)
  1394. //status.textContent = `Icon Toggle is ${detail.isOn ? 'on' : 'off'}`;
  1395. });
  1396. }
  1397. })
  1398. ]
  1399. },
  1400. {
  1401. $type: "div",
  1402. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1403. $components: [
  1404. self.widgets.icontoggle({
  1405. 'id': "webrtcaudio",
  1406. 'label': 'mic',
  1407. 'on': JSON.stringify({ "content": "mic", "label": "Turn On Mic" }),
  1408. 'off': JSON.stringify({ "content": "mic_off", "label": "Turn Off Mic" }),
  1409. 'state': false,
  1410. 'init': function () {
  1411. this._driver = vwf.views["vwf/view/webrtc"];
  1412. let webrtcswitch = document.querySelector('#webrtcswitch');
  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.muteAudio(chkAttr);
  1424. console.log("on")
  1425. } else {
  1426. driver.muteAudio(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. $type: "div",
  1438. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1439. $components: [
  1440. self.widgets.icontoggle({
  1441. 'id': "webrtcvideo",
  1442. 'label': 'videocam',
  1443. 'on': JSON.stringify({ "content": "videocam", "label": "Turn On Video" }),
  1444. 'off': JSON.stringify({ "content": "videocam_off", "label": "Turn Off Video" }),
  1445. 'state': false,
  1446. 'init': function () {
  1447. this._driver = vwf.views["vwf/view/webrtc"];
  1448. if (!this._driver) {
  1449. //this.classList.add('mdc-icon-toggle--disabled');
  1450. this.setAttribute("disabled", "");
  1451. }
  1452. // this.classList.add('mdc-icon-toggle--disabled');
  1453. this.setAttribute("disabled", "");
  1454. this.addEventListener('MDCIconButtonToggle:change', (e) => {
  1455. let driver = e.target._driver;
  1456. let chkAttr = e.detail.isOn;
  1457. if (chkAttr) {
  1458. driver.muteVideo(chkAttr);
  1459. console.log("on")
  1460. } else {
  1461. driver.muteVideo(chkAttr);
  1462. console.log("off")
  1463. }
  1464. //console.log(e, detail)
  1465. //status.textContent = `Icon Toggle is ${detail.isOn ? 'on' : 'off'}`;
  1466. });
  1467. }
  1468. })
  1469. ]
  1470. }
  1471. ]
  1472. }
  1473. ]
  1474. }
  1475. let audioGUI = {
  1476. $type: "div",
  1477. class: "propGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  1478. $components: [
  1479. {
  1480. $type: "div",
  1481. class: "mdc-layout-grid__inner",
  1482. $components: [
  1483. {
  1484. $type: "div",
  1485. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1486. $components: [
  1487. {
  1488. $type: "span",
  1489. $text: "Sound: "
  1490. }
  1491. ]
  1492. },
  1493. {
  1494. $type: "div",
  1495. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1496. $components: [
  1497. self.widgets.icontoggle({
  1498. 'id': "soundStopStartSwitch",
  1499. 'label': 'play',
  1500. 'on': JSON.stringify({ "content": "pause", "label": "stop" }),
  1501. 'off': JSON.stringify({ "content": "play_arrow", "label": "play" }),
  1502. 'state': false,
  1503. 'init': function () {
  1504. var nodeID = this._currentNode;
  1505. this._comp = new mdc.iconButtonToggle.MDCIconButtonToggle(this);
  1506. this.setAttribute('id', "soundStopStartSwitch-" + nodeID);
  1507. let isPlaying = vwf.getProperty(nodeID, 'isPlaying');
  1508. //mdc.iconToggle.MDCIconToggle.attachTo(this);
  1509. this._comp.on = isPlaying;
  1510. this.addEventListener('MDCIconButtonToggle:change', (e) => {
  1511. // let avatarID = 'avatar-'+ vwf.moniker_;
  1512. // let avatarNode = self.nodes['avatar-'+ vwf.moniker_];
  1513. // let mode = JSON.parse(avatarNode.properties.selectMode.getValue());
  1514. var nodeID = document.querySelector('#currentNode')._currentNode;
  1515. let isPlaying = vwf.getProperty(nodeID, 'isPlaying');
  1516. if (isPlaying) {
  1517. console.log("stop");
  1518. vwf_view.kernel.callMethod(nodeID, "pauseSound");
  1519. } else {
  1520. console.log("play")
  1521. vwf_view.kernel.callMethod(nodeID, "playSound");
  1522. }
  1523. });
  1524. }
  1525. })
  1526. ]
  1527. },
  1528. {
  1529. $type: "div",
  1530. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1531. $components: [
  1532. {
  1533. $type: "div",
  1534. style: "padding: 12px",
  1535. $components: [
  1536. self.widgets.iconButton({
  1537. 'label': 'stop',
  1538. onclickfunc: function () {
  1539. var nodeID = this._currentNode;
  1540. vwf_view.kernel.callMethod(nodeID, "stopSound");
  1541. }
  1542. })
  1543. ]
  1544. }
  1545. ]
  1546. }
  1547. // {
  1548. // $type: "div",
  1549. // class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-3",
  1550. // $components: [
  1551. // widgets.switch({
  1552. // 'id': 'editnode',
  1553. // 'init': function(){
  1554. // vwf_view.kernel.getProperty(this._currentNode, 'edit');
  1555. // },
  1556. // 'onchange': function(e){
  1557. // var nodeID = document.querySelector('#currentNode')._currentNode;
  1558. // let chkAttr = this.getAttribute('checked');
  1559. // if (chkAttr == "") {
  1560. // self.kernel.setProperty(this._currentNode, 'edit', false);
  1561. // } else {
  1562. // self.kernel.setProperty(this._currentNode, 'edit', true);
  1563. // }
  1564. // vwf_view.kernel.callMethod(nodeID, "showCloseGizmo");
  1565. // }
  1566. // }
  1567. // )
  1568. // ]
  1569. // }
  1570. ]
  1571. }
  1572. ]
  1573. }
  1574. var saveGUI = {};
  1575. if (_LCSDB.user().is) {
  1576. saveGUI = self.widgets.floatActionButton({
  1577. label: "save",
  1578. styleClass: "mdc-fab--mini",
  1579. onclickfunc: function () {
  1580. var nodeID = document.querySelector('#currentNode')._currentNode;
  1581. let node = self.nodes[nodeID];
  1582. let nodeDef = self.helpers.getNodeDef(nodeID);
  1583. console.log(nodeDef);
  1584. //let saveID = this.GUID();
  1585. // _LCSUSER.get('saves').get(node.name).put(JSON.stringify(nodeDef), acc=>{
  1586. // console.log("saved: " + acc + 'to '+ node.name)
  1587. // });
  1588. }
  1589. })
  1590. }
  1591. let gizmoEdit = {
  1592. $type: "div",
  1593. class: "propGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  1594. $components: [
  1595. {
  1596. $type: "div",
  1597. class: "mdc-layout-grid__inner",
  1598. $components: [
  1599. {
  1600. $type: "div",
  1601. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1602. $components: [
  1603. {
  1604. $type: "span",
  1605. $text: "Edit: ",
  1606. }
  1607. ]
  1608. },
  1609. {
  1610. $type: "div",
  1611. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-3",
  1612. $components: [
  1613. self.widgets.switch({
  1614. 'id': 'editnode',
  1615. 'init': function () {
  1616. vwf_view.kernel.getProperty(this._currentNode, 'edit');
  1617. this._switch = new mdc.switchControl.MDCSwitch(this);
  1618. this._switch.checked = false;
  1619. },
  1620. 'onchange': function (e) {
  1621. var nodeID = document.querySelector('#currentNode')._currentNode;
  1622. if (this._switch) {
  1623. let chkAttr = this._switch.checked;//this.getAttribute('checked');
  1624. if (chkAttr) {
  1625. self.kernel.setProperty(this._currentNode, 'edit', true);
  1626. //this._switch.checked = false;
  1627. } else {
  1628. self.kernel.setProperty(this._currentNode, 'edit', false);
  1629. //this._switch.checked = true;
  1630. }
  1631. vwf_view.kernel.callMethod(nodeID, "showCloseGizmo");
  1632. }
  1633. }
  1634. }
  1635. )
  1636. ]
  1637. },
  1638. {
  1639. $type: "div",
  1640. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1641. $components: [
  1642. self.widgets.imageButton({
  1643. imgSrc: "/vwf/view/lib/images/ui/icons/translate.png",
  1644. styleClass: "editButton",
  1645. onclickfunc: function (e) {
  1646. vwf_view.kernel.callMethod(this._currentNode, "setGizmoMode", ['translate'])
  1647. }
  1648. })
  1649. ]
  1650. },
  1651. {
  1652. $type: "div",
  1653. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1654. $components: [
  1655. self.widgets.imageButton({
  1656. imgSrc: "/vwf/view/lib/images/ui/icons/rotate.png",
  1657. styleClass: "editButton",
  1658. onclickfunc: function (e) {
  1659. vwf_view.kernel.callMethod(this._currentNode, "setGizmoMode", ['rotate'])
  1660. }
  1661. })
  1662. ]
  1663. },
  1664. {
  1665. $type: "div",
  1666. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  1667. $components: [
  1668. self.widgets.imageButton({
  1669. imgSrc: "/vwf/view/lib/images/ui/icons/scale.png",
  1670. styleClass: "editButton",
  1671. onclickfunc: function (e) {
  1672. vwf_view.kernel.callMethod(this._currentNode, "setGizmoMode", ['scale'])
  1673. }
  1674. })
  1675. ]
  1676. },
  1677. {
  1678. $type: "div",
  1679. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  1680. $components: [
  1681. // self.widgets.floatActionButton({
  1682. // label: "content_copy",
  1683. // styleClass: "mdc-fab--mini"
  1684. // }),
  1685. // {
  1686. // $type: "span",
  1687. // $text: " "
  1688. // },
  1689. self.widgets.floatActionButton({
  1690. label: "delete_forever",
  1691. styleClass: "mdc-fab--mini",
  1692. onclickfunc: function () {
  1693. var nodeID = document.querySelector('#currentNode')._currentNode;
  1694. let node = self.nodes[nodeID];
  1695. //vwf_view.kernel.deleteChild(node.parentID, node.name);
  1696. vwf_view.kernel.deleteNode(nodeID);
  1697. //vwf_view.kernel.callMethod(node.parentID, "deleteNode", [node.name])
  1698. }
  1699. }),
  1700. // self.widgets.floatActionButton({
  1701. // label: "person",
  1702. // styleClass: "mdc-fab--mini",
  1703. // onclickfunc: function () {
  1704. // var nodeID = document.querySelector('#currentNode')._currentNode;
  1705. // let node = self.nodes[nodeID];
  1706. // //vwf_view.kernel.deleteChild(node.parentID, node.name);
  1707. // let me = self.kernel.moniker();
  1708. // vwf_view.kernel.setProperty(nodeID, 'ownedBy', me);
  1709. // }
  1710. // }),
  1711. saveGUI
  1712. ]
  1713. },
  1714. ]
  1715. }
  1716. ]
  1717. }
  1718. let nodesCell = {
  1719. $cell: true,
  1720. $type: "div",
  1721. id: "currentNode",
  1722. _childNodes: [],
  1723. _currentNode: '',
  1724. _displayedProperties: {},
  1725. _setNode: function (aNode) {
  1726. this._currentNode = aNode;
  1727. document.querySelector('#sideBar')._sideCurrentNode = this._currentNode
  1728. },
  1729. $init: function () {
  1730. this._currentNode = document.querySelector('#sideBar')._sideCurrentNode
  1731. //this._currentNode = vwf_view.kernel.find("", "/")[0];
  1732. //this._currentNode = '3333';
  1733. },
  1734. _getChildNodes: function () {
  1735. this._childNodes = self.nodes[this._currentNode];
  1736. if (this._childNodes !== undefined) {
  1737. return this._childNodes.children
  1738. } else {
  1739. return []
  1740. }
  1741. //let nodeIDAlpha = he.encode(this._currentNode);
  1742. },
  1743. // _getNodeComplexProperties: function () {
  1744. // let node = self.nodes[this._currentNode];
  1745. // let props = this._getNodeProperties();
  1746. // let filterFunction = function (prop) {
  1747. // return (prop.name == 'ohmLang')
  1748. // };
  1749. // let complexProps = props.filter(filterFunction.bind(this));
  1750. // return complexProps
  1751. // },
  1752. _getNodeProperties: function () {
  1753. let node = self.nodes[this._currentNode];
  1754. this._displayedProperties = {};
  1755. let filterFunction = function (prop) {
  1756. return (!this._displayedProperties[prop.name] && prop.name.indexOf('$') === -1) ? (this._displayedProperties[prop.name] = "instance", true) : (false);
  1757. };
  1758. let props = node.properties.filter(filterFunction.bind(this));
  1759. return props
  1760. },
  1761. _getNodeProtoProperties: function () {
  1762. let node = self.nodes[this._currentNode];
  1763. let filterFunction = function (prop) {
  1764. return (!this._displayedProperties[prop[1].prop.name]) ? (this._displayedProperties[prop[1].prop.name] = prop[1].prototype, true) : (false);
  1765. };
  1766. let props = Object.entries(getProperties.call(self, self.kernel, node.extendsID)).filter(filterFunction.bind(this));
  1767. return props
  1768. },
  1769. $update: function () {
  1770. //this.$text = this._currentNode;
  1771. let node = self.nodes[this._currentNode];
  1772. let nodeProtos = getPrototypes(self.kernel, node.extendsID);
  1773. var viewerProps = {};
  1774. var viewerPropsCell = {};
  1775. var propsActions = {};
  1776. var propsActionsCell = {};
  1777. var gizmoCell = {};
  1778. if (this._currentNode !== self.kernel.application()) {
  1779. if (nodeProtos.includes('proxy/aframe/componentNode.vwf')) {
  1780. //gizmoCell = {};
  1781. if (nodeProtos.includes('proxy/aframe/a-sound-component.vwf')) {
  1782. //console.log("sound gui")
  1783. gizmoCell = audioGUI
  1784. }
  1785. } else {
  1786. gizmoCell = gizmoEdit
  1787. }
  1788. }
  1789. if (node !== undefined) {
  1790. propsActions = {
  1791. $type: "li",
  1792. class: "mdc-list-item",
  1793. $components: [
  1794. {
  1795. $text: "Actions",
  1796. $type: "span",
  1797. class: "mdc-list-item__text mdc-typography--button"
  1798. }
  1799. ]
  1800. }
  1801. let actionsGUI = [];
  1802. if(node.properties.meta) {
  1803. if(node.properties.meta.rawValue == 'avatarCostume'){
  1804. actionsGUI.push(self.widgets.buttonStroked(
  1805. {
  1806. "label": "Use this costume",
  1807. "onclick": function (e) {
  1808. console.log("COSTUME NEW!!!");
  1809. let nodeDef = self.helpers.getNodeDef(this._currentNode);
  1810. console.log(nodeDef);
  1811. let avatarID = 'avatar-' + self.kernel.moniker();
  1812. vwf_view.kernel.callMethod(avatarID, "changeCostume", [nodeDef]);
  1813. //vwf_view.kernel.callMethod(this._currentNode, "setCameraToActive", [vwf.moniker_]);
  1814. }
  1815. }))
  1816. }
  1817. } else if(node.name.includes('xrcontroller')){
  1818. actionsGUI.push(self.widgets.buttonStroked(
  1819. {
  1820. "label": "Set as World default XR controller",
  1821. "onclick": function (e) {
  1822. vwf_view.kernel.callMethod(node.ID, "saveToScene", []);
  1823. }
  1824. }))
  1825. }
  1826. propsActionsCell = {
  1827. $cell: true,
  1828. $type: "div",
  1829. class: "propGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  1830. $components: [
  1831. {
  1832. $type: "div",
  1833. class: "mdc-layout-grid__inner",
  1834. $components: [
  1835. {
  1836. $type: "div",
  1837. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  1838. $components: [].concat(actionsGUI)
  1839. }
  1840. ]
  1841. }
  1842. ]
  1843. //$components: this._getNodeProtoProperties().map(protoPropertiesCell)
  1844. }
  1845. if (node.extendsID == "proxy/aframe/acamera.vwf") {
  1846. viewerProps = {
  1847. $type: "li",
  1848. class: "mdc-list-item",
  1849. $components: [
  1850. {
  1851. $text: "Viewer properties",
  1852. $type: "span",
  1853. class: "mdc-list-item__text mdc-typography--button"
  1854. }
  1855. ]
  1856. }
  1857. viewerPropsCell = {
  1858. $cell: true,
  1859. $type: "div",
  1860. class: "propGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  1861. $components: [
  1862. {
  1863. $type: "div",
  1864. class: "mdc-layout-grid__inner",
  1865. $components: [
  1866. {
  1867. $type: "div",
  1868. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  1869. $components: [
  1870. self.widgets.buttonStroked(
  1871. {
  1872. "label": "Active",
  1873. "onclick": function (e) {
  1874. //let camera = document.querySelector('#' + this._currentNode);
  1875. vwf_view.kernel.callMethod(this._currentNode, "setCameraToActive", [vwf.moniker_]);
  1876. //camera.setAttribute('camera', 'active', true);
  1877. }
  1878. })
  1879. ]
  1880. }
  1881. ]
  1882. }
  1883. ]
  1884. //$components: this._getNodeProtoProperties().map(protoPropertiesCell)
  1885. }
  1886. } else {
  1887. viewerProps = {};
  1888. viewerPropsCell = {};
  1889. }
  1890. }
  1891. this.$components = [
  1892. {
  1893. $type: "ul",
  1894. class: "mdc-list",
  1895. $components: [
  1896. self.widgets.buttonStroked(
  1897. {
  1898. "label": "<--",
  1899. "onclick": function (e) {
  1900. let node = self.nodes[this._currentNode];
  1901. if (node.parentID !== 0) {
  1902. //self.currentNodeID = node.parentID,
  1903. document.querySelector('#currentNode')._setNode(node.parentID)
  1904. }
  1905. }
  1906. }),
  1907. {
  1908. $type: "li",
  1909. class: "mdc-list-item",
  1910. $components: [
  1911. {
  1912. $text: "name",
  1913. $type: "span",
  1914. $init: function () {
  1915. let node = self.nodes[this._currentNode];
  1916. if (node) {
  1917. let displayName = vwf.getProperty(node.ID, 'displayName');
  1918. if (displayName) {
  1919. this.$text = displayName
  1920. } else {
  1921. this.$text = node.name;
  1922. }
  1923. }
  1924. //console.log(node.properties.displayName)
  1925. },
  1926. class: "mdc-list-item__text mdc-typography--headline"
  1927. //<h1 class="mdc-typography--display4">Big header</h1>
  1928. }]
  1929. }, listDivider,
  1930. {
  1931. // $cell: true,
  1932. // $type: "ul",
  1933. // class: "mdc-list",
  1934. $type: "div",
  1935. class: "propGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  1936. $components: [
  1937. {
  1938. $type: "div",
  1939. class: "mdc-layout-grid__inner",
  1940. $components: [
  1941. {
  1942. $type: "div",
  1943. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  1944. $components: [
  1945. self.widgets.buttonStroked(
  1946. {
  1947. "label": "Methods browser",
  1948. "onclick": function (e) {
  1949. var currentNode = document.querySelector('#currentNode')._currentNode;
  1950. if (currentNode == '') {
  1951. currentNode = vwf_view.kernel.find("", "/")[0];
  1952. }
  1953. if (isAFrameEntity(currentNode)) {
  1954. vwf.views["vwf/view/aframe"].nodes[currentNode].liveBindings = {};
  1955. } else if(isAFrameComponent(currentNode)) {
  1956. vwf.views["vwf/view/aframeComponent"].nodes[currentNode].liveBindings = {};
  1957. }
  1958. document.querySelector('#liveCodeEditor')._setNode(currentNode);
  1959. //createAceEditor(self, currentNode);
  1960. document.querySelector('#codeEditorWindow').style.visibility = 'visible';
  1961. }
  1962. })
  1963. ]
  1964. }
  1965. ]
  1966. }
  1967. ]
  1968. },
  1969. gizmoCell,
  1970. listDivider,
  1971. {
  1972. $type: "li",
  1973. class: "mdc-list-item",
  1974. $components: [
  1975. {
  1976. $text: "Children",
  1977. $type: "span",
  1978. class: "mdc-list-item__text mdc-typography--button"
  1979. }]
  1980. },
  1981. {
  1982. $type: "ul",
  1983. class: "mdc-list",
  1984. $components: this._getChildNodes().map(nodeLink)
  1985. }, listDivider, {
  1986. $type: "li",
  1987. class: "mdc-list-item",
  1988. $components: [
  1989. {
  1990. $text: "Properties",
  1991. $type: "span",
  1992. class: "mdc-list-item__text mdc-typography--button"
  1993. //<h1 class="mdc-typography--display4">Big header</h1>
  1994. }]
  1995. },
  1996. {
  1997. // $cell: true,
  1998. // $type: "ul",
  1999. // class: "mdc-list",
  2000. $type: "div",
  2001. class: "propGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  2002. $components: this._getNodeProperties().map(propertiesCell)
  2003. },
  2004. listDivider,
  2005. {
  2006. $type: "li",
  2007. class: "mdc-list-item",
  2008. $components: [
  2009. {
  2010. $text: "Proto properties",
  2011. $type: "span",
  2012. class: "mdc-list-item__text mdc-typography--button"
  2013. }]
  2014. },
  2015. {
  2016. $type: "div",
  2017. class: "propGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  2018. $components: this._getNodeProtoProperties().map(protoPropertiesCell)
  2019. }, listDivider,
  2020. propsActions,
  2021. propsActionsCell,
  2022. listDivider,
  2023. viewerProps,
  2024. viewerPropsCell
  2025. ]
  2026. }
  2027. ]
  2028. }
  2029. }
  2030. let numberSliderComponent = {
  2031. $cell: true,
  2032. $type: "div",
  2033. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-4",
  2034. $init: function () {
  2035. },
  2036. $components: [
  2037. {
  2038. $type: "div",
  2039. style: "padding: 0 16px;",
  2040. $components: [
  2041. {}
  2042. ]
  2043. }
  2044. ]
  2045. }
  2046. let colorPickerComponent = {
  2047. $cell: true,
  2048. $type: "div",
  2049. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-4",
  2050. $init: function () {
  2051. let myEl = this;
  2052. let cp = ColorPicker(
  2053. document.getElementById('slide'),
  2054. document.getElementById('picker'),
  2055. function (hex, hsv, rgb, mousePicker, mouseSlide) {
  2056. ColorPicker.positionIndicators(
  2057. document.getElementById('slide-indicator'),
  2058. document.getElementById('picker-indicator'),
  2059. mouseSlide, mousePicker
  2060. );
  2061. if (myEl._propName.toLowerCase().includes('color')) {
  2062. // console.log(hex);
  2063. document.querySelector('#propAceEditor').env.editor.setValue(JSON.stringify(hex));
  2064. self.kernel.setProperty(myEl._editorNode, myEl._propName, hex);
  2065. }
  2066. });
  2067. if (myEl._propName.toLowerCase().includes('color')) {
  2068. cp.setHex(JSON.parse(myEl._prop.body));
  2069. }
  2070. },
  2071. $components: [
  2072. {
  2073. $type: "div",
  2074. id: "color-picker",
  2075. class: "cp-default",
  2076. $components: [
  2077. {
  2078. $type: "div",
  2079. class: "picker-wrapper",
  2080. $components: [
  2081. {
  2082. $type: "div",
  2083. id: "picker",
  2084. class: "picker",
  2085. style: "width: 130px; height: 130px"
  2086. },
  2087. {
  2088. $type: "div",
  2089. id: "picker-indicator",
  2090. class: "picker-indicator"
  2091. }
  2092. ]
  2093. },
  2094. {
  2095. $type: "div",
  2096. class: "slide-wrapper",
  2097. $components: [
  2098. {
  2099. $type: "div",
  2100. id: "slide",
  2101. class: "slide",
  2102. style: "width: 30px; height: 130px"
  2103. },
  2104. {
  2105. $type: "div",
  2106. id: "slide-indicator",
  2107. class: "slide-indicator"
  2108. }
  2109. ]
  2110. }
  2111. ]
  2112. }
  2113. // {
  2114. // $cell: true,
  2115. // $type: "div",
  2116. // id: "color-picker",
  2117. // $init: function () {
  2118. // }
  2119. // }
  2120. ]
  2121. }
  2122. let propEditorWindow = {
  2123. $cell: true,
  2124. $type: "div",
  2125. _editorNode: '',
  2126. _prop: { body: '', type: 'simple' },
  2127. _propName: '',
  2128. id: "livePropEditor",
  2129. _setNode: function (node) {
  2130. this._editorNode = node;
  2131. this._prop.body = ''
  2132. },
  2133. class: "propEditorGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  2134. $update: function () {
  2135. var editorClass = "mdc-layout-grid__cell mdc-layout-grid__cell--span-8"
  2136. var livePropertyComponent = {}
  2137. if (this._prop.type == 'simple') {
  2138. if (this._propName.toLowerCase().includes('color')) {
  2139. livePropertyComponent = colorPickerComponent
  2140. }
  2141. } else {
  2142. editorClass = "mdc-layout-grid__cell mdc-layout-grid__cell--span-12"
  2143. }
  2144. this.$components = [
  2145. {
  2146. $type: "div",
  2147. class: "mdc-layout-grid__inner",
  2148. $components: [
  2149. {
  2150. $type: "div",
  2151. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  2152. $components: [
  2153. self.widgets.buttonStroked(
  2154. {
  2155. "label": "Update",
  2156. "onclick": function (e) {
  2157. let editor = document.querySelector("#propAceEditor").env.editor;
  2158. let value = editor.getValue();
  2159. var propValue = value;
  2160. if (this._prop.type == 'simple') {
  2161. if (_app.helpers.testJSON(value)){
  2162. propValue = JSON.parse(value);
  2163. }
  2164. } else {
  2165. propValue = value;
  2166. }
  2167. self.kernel.setProperty(this._editorNode, this._propName, propValue);
  2168. // try {
  2169. // let propValue = (this._prop.type == 'simple') ? (JSON.parse(value)) : (value)
  2170. // //propValue = JSON.parse(value);
  2171. // self.kernel.setProperty(this._editorNode, this._propName, propValue);
  2172. // } catch (e) {
  2173. // // restore the original value on error
  2174. // this.value = propValue;
  2175. // }
  2176. }
  2177. }
  2178. )]
  2179. },
  2180. {
  2181. $type: "div",
  2182. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-5",
  2183. $components: [
  2184. {
  2185. $type: "h3",
  2186. class: "mdc-list-group__subheader mdc-list-item__text mdc-typography--subheading1",
  2187. $text: this._editorNode
  2188. }
  2189. ]
  2190. },
  2191. {
  2192. $type: "div",
  2193. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-5",
  2194. $components: [
  2195. {
  2196. $type: "h3",
  2197. class: "mdc-list-group__subheader mdc-list-item__text mdc-typography--subheading1",
  2198. $text: this._propName
  2199. }
  2200. ]
  2201. }
  2202. ]
  2203. },
  2204. {
  2205. $type: "div",
  2206. class: "mdc-layout-grid__inner",
  2207. $components: [
  2208. {
  2209. $type: "div",
  2210. class: editorClass,
  2211. $components: [
  2212. {
  2213. class: "aceEditor",
  2214. id: "propAceEditor",
  2215. $type: "div",
  2216. $text: this._prop.body,
  2217. $init: function () {
  2218. createAceEditor(self, this._editorNode, "propAceEditor");
  2219. this.env.editor.$blockScrolling = Infinity
  2220. }
  2221. }
  2222. ]
  2223. }, livePropertyComponent
  2224. // {
  2225. // $cell: true,
  2226. // $type: "div",
  2227. // class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  2228. // $components: []
  2229. // },
  2230. ]
  2231. }
  2232. ]
  2233. //$components:
  2234. }
  2235. }
  2236. let codeEditorWindow = {
  2237. $cell: true,
  2238. $type: "div",
  2239. _editorNode: '',
  2240. _method: { body: '' },
  2241. _methodName: '',
  2242. _tabIndex: '',
  2243. _getNodeMethods: function () {
  2244. let node = self.nodes[this._editorNode];
  2245. return node.methods
  2246. },
  2247. _getProtoNodeMethods: function () {
  2248. let node = self.nodes[this._editorNode];
  2249. let prototypeMethods = getMethods.call(self, self.kernel, node.extendsID);
  2250. return prototypeMethods
  2251. },
  2252. id: "liveCodeEditor",
  2253. _setNode: function (node) {
  2254. this._editorNode = node;
  2255. this._method.body = ''
  2256. },
  2257. class: "codeEditorGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  2258. // _getComplexProps: function(){
  2259. // let node = self.nodes[this._editorNode];
  2260. // let currentNode = document.querySelector('#currentNode');
  2261. // var props = {}
  2262. // if (currentNode !== null) {
  2263. // props = currentNode._getNodeComplexProperties();
  2264. // }
  2265. // return props
  2266. // },
  2267. // _listPropertyElement: function (m) {
  2268. // return {
  2269. // $type: "li",
  2270. // class: "mdc-list-item",
  2271. // $components: [{
  2272. // $type: "a",
  2273. // class: "mdc-list-item",
  2274. // $href: "#",
  2275. // $text: m[1].name,
  2276. // onclick: function (e) {
  2277. // this._method = {};
  2278. // this._methodName = m[1].name;
  2279. // this._method.body = m[1].rawValue
  2280. // this._method.type = "complexProperty"
  2281. // }
  2282. // }]
  2283. // }
  2284. // },
  2285. _listElement: function (m) {
  2286. return {
  2287. $type: "li",
  2288. class: "mdc-list-item",
  2289. $components: [{
  2290. $type: "a",
  2291. class: "mdc-list-item",
  2292. $href: "#",
  2293. $text: m[0],
  2294. onclick: function (e) {
  2295. let method = vwf.getMethod(this._editorNode, m[0]);
  2296. //document.querySelector('#aceEditor').
  2297. this._method = method;
  2298. this._methodName = m[0];
  2299. //self.currentNodeID = m.ID;
  2300. //document.querySelector('#currentNode')._setNode(m.ID);
  2301. }
  2302. }]
  2303. }
  2304. },
  2305. $update: function () {
  2306. this.$components = [
  2307. {
  2308. $type: "div",
  2309. class: "mdc-layout-grid__inner",
  2310. $components: [
  2311. {
  2312. $type: "div",
  2313. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-3",
  2314. $components: [
  2315. {
  2316. $type: "h3",
  2317. class: "mdc-list-group__subheader mdc-list-item__text mdc-typography--subheading1",
  2318. $text: this._editorNode
  2319. }
  2320. ]
  2321. },
  2322. {
  2323. $type: "div",
  2324. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1 tooltip",
  2325. $components: [
  2326. {
  2327. class: "tooltiptext",
  2328. $type: "span",
  2329. $text: "Update"
  2330. },
  2331. self.widgets.iconButton({
  2332. 'label': 'refresh',
  2333. "styleClass": "mdc-button--outlined",
  2334. // self.widgets.buttonStroked(
  2335. // {
  2336. // "label": "Update",
  2337. "onclick": function (e) {
  2338. let editor = document.querySelector("#aceEditor").env.editor;
  2339. let evalText = editor.getValue();
  2340. // if (this._method.type == 'complexProperty') {
  2341. // let propValue = evalText;
  2342. // try {
  2343. // //propValue = JSON.parse(propValue);
  2344. // self.kernel.setProperty(this._editorNode, this._methodName, propValue);
  2345. // } catch (e) {
  2346. // // restore the original value on error
  2347. // this.value = propValue;
  2348. // }
  2349. // } else {
  2350. // }
  2351. self.kernel.setMethod(this._editorNode, this._methodName,
  2352. { body: evalText, type: "application/javascript", parameters: this._method.parameters });
  2353. }
  2354. }
  2355. )]
  2356. },
  2357. {
  2358. $type: "div",
  2359. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1 tooltip",
  2360. $components: [
  2361. {
  2362. class: "tooltiptext",
  2363. $type: "span",
  2364. $text: "Call It"
  2365. },
  2366. self.widgets.iconButton({
  2367. 'label': 'play_arrow',
  2368. "styleClass": "mdc-button--outlined",
  2369. // self.widgets.buttonStroked(
  2370. // {
  2371. // "label": "Call",
  2372. "onclick": function (e) {
  2373. var params = [];
  2374. if (this._method.parameters) {
  2375. let paramsLength = this._method.parameters.length
  2376. if (paramsLength >= 1) {
  2377. let paramsVal = document.querySelector("#methodParams").value;
  2378. try {
  2379. params = JSON.parse(paramsVal);
  2380. //params.push(prmtr);
  2381. } catch (e) {
  2382. self.logger.error('Invalid Value');
  2383. }
  2384. }
  2385. };
  2386. let editor = document.querySelector("#aceEditor").env.editor;
  2387. let evalText = editor.getValue();
  2388. let allLines = editor.selection.doc.getAllLines();
  2389. let search = this._methodName+'(';
  2390. let findLine = Object.entries(allLines).filter(el=>el[1].includes(search))[0];
  2391. //TODO: temporal fix for recursive future call from the editor
  2392. if(findLine) {
  2393. if(findLine[1].includes(search)) {
  2394. let position = {
  2395. row: findLine[0],
  2396. column: 0
  2397. };
  2398. var Range = ace.require("ace/range").Range;
  2399. let tempString = "//CLICK FOR CALL AGAIN ";
  2400. if(findLine[1].includes(tempString)){
  2401. let newText = findLine[1].replace(tempString, "");
  2402. editor.session.replace(new Range(position.row, 0, position.row, Number.MAX_VALUE), newText);
  2403. self.kernel.setMethod(this._editorNode, this._methodName,
  2404. { body: editor.getValue(), type: "application/javascript", parameters: this._method.parameters });
  2405. } else if(findLine[1].includes("//")) { //startsWith
  2406. } else {
  2407. let newText = tempString + findLine[1];
  2408. editor.session.replace(new Range(position.row, 0, position.row, Number.MAX_VALUE), newText);
  2409. self.kernel.setMethod(this._editorNode, this._methodName,
  2410. { body: editor.getValue(), type: "application/javascript", parameters: this._method.parameters });
  2411. }
  2412. }
  2413. }
  2414. self.kernel.callMethod(this._editorNode, this._methodName, params);
  2415. }
  2416. })
  2417. ]
  2418. },
  2419. {
  2420. $type: "div",
  2421. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1 tooltip",
  2422. $components: [
  2423. {
  2424. class: "tooltiptext",
  2425. $type: "span",
  2426. $text: "Do It"
  2427. },
  2428. self.widgets.iconButton({
  2429. 'label': 'arrow_forward',
  2430. "styleClass": "mdc-button--outlined",
  2431. // self.widgets.buttonStroked(
  2432. // {
  2433. // "label": "Do It",
  2434. "onclick": function (e) {
  2435. let editor = document.querySelector("#aceEditor").env.editor;
  2436. codeEditorDoit.call(self, editor, this._editorNode);
  2437. }
  2438. })
  2439. ]
  2440. },
  2441. {
  2442. $type: "div",
  2443. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1 tooltip",
  2444. $components: [
  2445. {
  2446. class: "tooltiptext",
  2447. $type: "span",
  2448. $text: "Print It"
  2449. },
  2450. self.widgets.iconButton({
  2451. 'label': 'details',
  2452. "styleClass": "mdc-button--outlined",
  2453. // self.widgets.buttonStroked(
  2454. // {
  2455. // "label": "Print It",
  2456. "onclick": function (e) {
  2457. let editor = document.querySelector("#aceEditor").env.editor;
  2458. codeEditorPrintit.call(self, editor, this._editorNode);
  2459. }
  2460. })
  2461. ]
  2462. },
  2463. {
  2464. $type: "div",
  2465. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-1 tooltip",
  2466. $components: [
  2467. {
  2468. class: "tooltiptext",
  2469. $type: "span",
  2470. $text: "Print It on Console"
  2471. },
  2472. self.widgets.iconButton({
  2473. 'label': 'code',
  2474. "styleClass": "mdc-button--outlined",
  2475. // self.widgets.buttonStroked(
  2476. // {
  2477. // "label": "Print It on Console",
  2478. "onclick": function (e) {
  2479. let editor = document.querySelector("#aceEditor").env.editor;
  2480. codeEditorPrintitInDebugger.call(self, editor, this._editorNode);
  2481. }
  2482. })
  2483. ]
  2484. }
  2485. ]
  2486. },
  2487. {
  2488. $type: "div",
  2489. class: "mdc-layout-grid__inner",
  2490. $components: [
  2491. {
  2492. $type: "div",
  2493. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-3",
  2494. style: "overflow-y: scroll; max-height: 400px;",
  2495. $components: [
  2496. {
  2497. $type: "div",
  2498. class: "mdc-list-group",
  2499. $components: [
  2500. {
  2501. $type: "h3",
  2502. class: "mdc-list-group__subheader mdc-list-item__text mdc-typography--button",
  2503. $text: "Node methods"
  2504. },
  2505. {
  2506. $type: "ul",
  2507. class: "mdc-list",
  2508. $components: Object.entries(this._getNodeMethods()).map(this._listElement)
  2509. }, listDivider,
  2510. {
  2511. $type: "h3",
  2512. class: "mdc-list-group__subheader mdc-list-item__text mdc-typography--button",
  2513. $text: "Proto methods"
  2514. },
  2515. {
  2516. $type: "ul",
  2517. class: "mdc-list",
  2518. $components: Object.entries(this._getProtoNodeMethods()).map(this._listElement)
  2519. }, listDivider,
  2520. {
  2521. $type: "h3",
  2522. class: "mdc-list-group__subheader mdc-list-item__text mdc-typography--button",
  2523. $text: "Events"
  2524. }
  2525. // {
  2526. //
  2527. // $type: "ul",
  2528. // class: "mdc-list",
  2529. // $components: Object.entries(this._getComplexProps()).map(this._listPropertyElement)
  2530. // }
  2531. ]
  2532. }
  2533. ]
  2534. },
  2535. {
  2536. $type: "div",
  2537. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-9",
  2538. $components: [
  2539. {
  2540. class: "aceEditor",
  2541. id: "aceEditor",
  2542. $type: "div",
  2543. $text: this._method.body,
  2544. $init: function () {
  2545. createAceEditor(self, this._editorNode, "aceEditor");
  2546. }
  2547. }
  2548. ]
  2549. }
  2550. ]
  2551. },
  2552. {
  2553. $type: "div",
  2554. class: "mdc-layout-grid__inner",
  2555. $components: [
  2556. {
  2557. $type: "div",
  2558. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  2559. $components: [
  2560. {
  2561. $type: "span",
  2562. $text: "*"
  2563. }
  2564. ]
  2565. }
  2566. ]
  2567. },
  2568. { //params input
  2569. $type: "div",
  2570. class: "mdc-layout-grid__inner",
  2571. $components: [
  2572. {
  2573. $type: "div",
  2574. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-3",
  2575. $components: [
  2576. self.widgets.inputTextFieldOutlined({
  2577. "id": 'methodName',
  2578. "label": "Method name",
  2579. "value": "newMethodName",
  2580. "change": function (e) {
  2581. let propValue = this.value;
  2582. try {
  2583. } catch (e) {
  2584. // restore the original value on error
  2585. }
  2586. }
  2587. })
  2588. ]
  2589. },
  2590. {
  2591. $type: "div",
  2592. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-7",
  2593. $components: [
  2594. self.widgets.inputTextFieldOutlined({
  2595. "id": 'methodParams',
  2596. "label": "Method parameters",
  2597. "value": JSON.stringify(this._method.parameters),
  2598. "change": function (e) {
  2599. let propValue = this.value;
  2600. try {
  2601. } catch (e) {
  2602. // restore the original value on error
  2603. }
  2604. }
  2605. })
  2606. ]
  2607. },
  2608. {
  2609. $type: "div",
  2610. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-2",
  2611. $components: [
  2612. self.widgets.buttonStroked(
  2613. {
  2614. "label": "Create",
  2615. "onclick": function (e) {
  2616. let methodName = document.querySelector('#methodName').value;
  2617. //let methodParams = document.querySelector('#methodParams');
  2618. var params = [];
  2619. let body = '';
  2620. let paramsVal = document.querySelector("#methodParams").value;
  2621. if (paramsVal !== '') {
  2622. try {
  2623. params = JSON.parse(paramsVal);
  2624. //params.push(prmtr);
  2625. } catch (e) {
  2626. self.logger.error('Invalid Value');
  2627. }
  2628. }
  2629. self.kernel.createMethod(this._editorNode, methodName, params, body);
  2630. this._setNode(this._editorNode);
  2631. // let editor = document.querySelector("#aceEditor").env.editor;
  2632. // codeEditorDoit.call(self, editor, this._editorNode);
  2633. }
  2634. })
  2635. ]
  2636. }
  2637. ]
  2638. }
  2639. ]
  2640. //$components:
  2641. }
  2642. }
  2643. let propWindow = {
  2644. $cell: true,
  2645. $type: "div",
  2646. class: "propGrid mdc-layout-grid max-width mdc-layout-grid--align-left",
  2647. style: "overflow-y: scroll; max-height: 800px;",
  2648. $components: [
  2649. {
  2650. $type: "div",
  2651. class: "mdc-layout-grid__inner",
  2652. $components: [
  2653. {
  2654. $type: "div",
  2655. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  2656. $components: [
  2657. nodesCell
  2658. ]
  2659. }
  2660. ]
  2661. }
  2662. // <button class="mdc-button">
  2663. // Flat button
  2664. // </button>
  2665. ]
  2666. }
  2667. let clientListCell = {
  2668. $cell: true,
  2669. $type: "div",
  2670. class: "mdc-list",
  2671. id: "clientsList",
  2672. _watchNodes: [],
  2673. _listElement: function (m) {
  2674. return {
  2675. $type: "a",
  2676. class: "mdc-list-item",
  2677. $href: "#",
  2678. $text: m.name,
  2679. onclick: function (e) {
  2680. //self.currentNodeID = m.ID;
  2681. //document.querySelector('#currentNode')._setNode(m.ID);
  2682. }
  2683. }
  2684. },
  2685. $init: function () {
  2686. var t = this;
  2687. setInterval(function () {
  2688. t._updateMe();
  2689. }, 1000);
  2690. },
  2691. _updateMe: function () {
  2692. let clientNodes = self.nodes["proxy/clients.vwf"];
  2693. if (clientNodes) this._watchNodes = self.nodes["proxy/clients.vwf"].children.slice();
  2694. },
  2695. $update: function () {
  2696. //this._clientNodes
  2697. this.$components = this._watchNodes.map(this._listElement)
  2698. }
  2699. }
  2700. //createCellWindow("clientsWindow", clientListCell, "Clients");
  2701. //createCellWindow("propWindow", propWindow, "Scene");
  2702. createCellWindow("codeEditorWindow", codeEditorWindow, "Code editor");
  2703. createCellWindow("propEditorWindow", propEditorWindow, "Prop editor");
  2704. let viewSceneProps = {
  2705. $cell: true,
  2706. $type: "div",
  2707. class: "propGrid mdc-layout-grid mdc-layout-grid--align-left",
  2708. //style: "overflow-y: scroll; max-height: 500px; overflow-x: hidden;",
  2709. $components: [
  2710. {
  2711. $type: "div",
  2712. class: "mdc-layout-grid__inner",
  2713. $components: [
  2714. {
  2715. $type: "div",
  2716. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  2717. $components: [
  2718. nodesCell
  2719. ]
  2720. }]
  2721. }
  2722. ]
  2723. }
  2724. let sideBar = {
  2725. $cell: true,
  2726. $type: "div",
  2727. id: 'sideBar',
  2728. class: "sideBar mdc-top-app-bar--fixed-adjust",
  2729. _sideBarComponent: {},
  2730. _sideCurrentNode: '',
  2731. $init: function () {
  2732. this.style.visibility = 'hidden';
  2733. let fileName = 'appui_js';
  2734. let worldName = self.helpers.getRoot().root;//url.split('/')[0];
  2735. let userDB = _LCSDB.user(_LCS_WORLD_USER.pub);
  2736. userDB.get('worlds').get(worldName).get(fileName).once(res => {
  2737. this._importScript(res);
  2738. })
  2739. },
  2740. _importScript: function (sSrc, fOnload) {
  2741. var oScript = document.createElement("script");
  2742. oScript.type = "text\/javascript";
  2743. oScript.async = false;
  2744. //oScript.onerror = loadError;
  2745. if (fOnload) { oScript.onload = fOnload; }
  2746. oScript.text = sSrc;
  2747. //let sideBar = document.querySelector('#sideBar');
  2748. this.appendChild(oScript);
  2749. },
  2750. _getAppDef: async function () {
  2751. // let response = await fetch("/" + self.getRoot() + "/appui.js");
  2752. // let data = await response.text();
  2753. // //console.log(data)
  2754. // return data
  2755. },
  2756. $update: function () {
  2757. this.$components = [
  2758. {
  2759. $type: "button",
  2760. class: "mdc-button mdc-button--compact",
  2761. $text: "X",
  2762. onclick: function (e) {
  2763. document.querySelector('#sideBar').style.visibility = 'hidden';
  2764. this._sideBarComponent = Object.assign({}, {});
  2765. }
  2766. },
  2767. this._sideBarComponent
  2768. ]
  2769. }
  2770. //$components: [this._sideComponents]
  2771. }
  2772. document.querySelector('#' + 'sideBar').$cell(sideBar)
  2773. let defaultApp = function () {
  2774. return {
  2775. $cell: true,
  2776. $type: "div",
  2777. class: "propGrid max-width mdc-layout-grid mdc-layout-grid--align-left",
  2778. $components: [
  2779. {
  2780. $type: "div",
  2781. class: "mdc-layout-grid__inner",
  2782. $components: [
  2783. {
  2784. $type: "div",
  2785. class: "mdc-layout-grid__cell mdc-layout-grid__cell--span-12",
  2786. $components: [
  2787. {
  2788. $type: "h3",
  2789. class: "mdc-typography--headline",
  2790. $text: "Application",
  2791. }
  2792. ]
  2793. }
  2794. ]
  2795. }
  2796. ]
  2797. }
  2798. }
  2799. let drawerCell = {
  2800. $cell: true,
  2801. $type: "div",
  2802. class: "mdc-drawer__content",
  2803. $components: [
  2804. {
  2805. $type: "nav",
  2806. class: "mdc-list",
  2807. $init: function () { },
  2808. $components: [
  2809. {
  2810. $type: "a",
  2811. class: "mdc-list-item mdc-list-item--activated",
  2812. $href: "#",
  2813. tabindex: "-1",
  2814. onclick: function (e) {
  2815. e.preventDefault();
  2816. let sideBar = document.querySelector('#sideBar');
  2817. try {
  2818. sideBar._sideBarComponent = createApp.call(self);
  2819. } catch (e) {
  2820. sideBar._sideBarComponent = defaultApp();
  2821. }
  2822. self.drawer.open = false//!self.drawer.open
  2823. //self.drawer.close();
  2824. document.querySelector('#sideBar').style.visibility = 'visible';
  2825. },
  2826. $components: [{
  2827. $type: "i",
  2828. class: "material-icons mdc-list-item__graphic",
  2829. 'aria-hidden': "true",
  2830. $text: "play_arrow"
  2831. },
  2832. {
  2833. $text: self.lang.t("App")
  2834. }]
  2835. },
  2836. {
  2837. $type: "a",
  2838. class: "mdc-list-item",
  2839. $href: "#",
  2840. tabindex: "-1",
  2841. onclick: function (e) {
  2842. e.preventDefault();
  2843. let sideBar = document.querySelector('#sideBar');
  2844. sideBar._sideBarComponent = viewSceneProps;
  2845. let currentNode = document.querySelector('#sideBar')._sideCurrentNode;
  2846. currentNode == '' ? document.querySelector('#sideBar')._sideCurrentNode = (vwf_view.kernel.find("", "/")[0]) :
  2847. document.querySelector('#sideBar')._sideCurrentNode = currentNode;
  2848. document.querySelector('#sideBar').style.visibility = 'visible';
  2849. self.drawer.open = !self.drawer.open
  2850. // let currentNode = document.querySelector('#currentNode')._currentNode;
  2851. // currentNode == '' ? document.querySelector('#currentNode')._setNode(vwf_view.kernel.find("", "/")[0]) :
  2852. // document.querySelector('#currentNode')._setNode(currentNode);
  2853. },
  2854. $components: [{
  2855. $type: "i",
  2856. class: "material-icons mdc-list-item__graphic",
  2857. $text: "description"
  2858. },
  2859. {
  2860. $text: "Scene"
  2861. }
  2862. ]
  2863. },
  2864. {
  2865. $type: "a",
  2866. class: "mdc-list-item",
  2867. $href: "#",
  2868. tabindex: "-1",
  2869. onclick: function (e) {
  2870. e.preventDefault();
  2871. //self.currentNodeID = m.ID;
  2872. // document.querySelector('#clientsList')._setClientNodes(self.nodes["proxy/clients.vwf"]);
  2873. // document.querySelector('#clientsWindow').style.visibility = 'visible';
  2874. let sideBar = document.querySelector('#sideBar');
  2875. sideBar._sideBarComponent = createSettings;
  2876. self.drawer.open = !self.drawer.open
  2877. document.querySelector('#sideBar').style.visibility = 'visible';
  2878. },
  2879. $components: [{
  2880. $type: "i",
  2881. class: "material-icons mdc-list-item__graphic",
  2882. 'aria-hidden': "true",
  2883. $text: "create"
  2884. },
  2885. {
  2886. $text: "Create"
  2887. }]
  2888. },
  2889. {
  2890. $type: "a",
  2891. class: "mdc-list-item",
  2892. $href: "#",
  2893. tabindex: "-1",
  2894. onclick: function (e) {
  2895. e.preventDefault();
  2896. // var currentNode = document.querySelector('#currentNode')._currentNode;
  2897. // if (currentNode == '') {
  2898. // currentNode = vwf_view.kernel.find("", "/")[0];
  2899. // }
  2900. document.querySelector('#liveCodeEditor')._setNode(vwf_view.kernel.find("", "/")[0]);
  2901. //createAceEditor(self, currentNode);
  2902. document.querySelector('#codeEditorWindow').style.visibility = 'visible';
  2903. },
  2904. $components: [{
  2905. $type: "i",
  2906. class: "material-icons mdc-list-item__graphic",
  2907. 'aria-hidden': "true",
  2908. $text: "code"
  2909. },
  2910. {
  2911. $text: "Code editor"
  2912. }]
  2913. },
  2914. {
  2915. $type: "a",
  2916. class: "mdc-list-item",
  2917. $href: "#",
  2918. tabindex: "-1",
  2919. onclick: function (e) {
  2920. e.preventDefault();
  2921. //self.currentNodeID = m.ID;
  2922. // document.querySelector('#clientsList')._setClientNodes(self.nodes["proxy/clients.vwf"]);
  2923. // document.querySelector('#clientsWindow').style.visibility = 'visible';
  2924. let sideBar = document.querySelector('#sideBar');
  2925. sideBar._sideBarComponent = avatarSettings;
  2926. self.drawer.open = !self.drawer.open
  2927. document.querySelector('#sideBar').style.visibility = 'visible';
  2928. },
  2929. $components: [{
  2930. $type: "i",
  2931. class: "material-icons mdc-list-item__graphic",
  2932. 'aria-hidden': "true",
  2933. $text: "account_circle"
  2934. },
  2935. {
  2936. $text: "My Avatar"
  2937. }]
  2938. },
  2939. {
  2940. $type: "a",
  2941. class: "mdc-list-item",
  2942. $href: "#",
  2943. tabindex: "-1",
  2944. onclick: function (e) {
  2945. e.preventDefault();
  2946. //self.currentNodeID = m.ID;
  2947. // document.querySelector('#clientsList')._setClientNodes(self.nodes["proxy/clients.vwf"]);
  2948. let sideBar = document.querySelector('#sideBar');
  2949. sideBar._sideBarComponent = viewSettings;
  2950. self.drawer.open = !self.drawer.open
  2951. document.querySelector('#sideBar').style.visibility = 'visible';
  2952. },
  2953. $components: [{
  2954. $type: "i",
  2955. class: "material-icons mdc-list-item__graphic",
  2956. 'aria-hidden': "true",
  2957. $text: "settings"
  2958. },
  2959. {
  2960. $text: "Settings"
  2961. }]
  2962. },
  2963. {
  2964. $type: "a",
  2965. class: "mdc-list-item",
  2966. $href: "#",
  2967. tabindex: "-1",
  2968. onclick: function (e) {
  2969. e.preventDefault();
  2970. //self.currentNodeID = m.ID;
  2971. // document.querySelector('#clientsList')._setClientNodes(self.nodes["proxy/clients.vwf"]);
  2972. let sideBar = document.querySelector('#sideBar');
  2973. sideBar._sideBarComponent = loadSaveSettings;
  2974. if (document.querySelector('#loadSaveSettings')) {
  2975. //document.querySelector('#loadSaveSettings')._refresh();
  2976. //document.querySelector('#loadSaveSettings')._getStates();
  2977. }
  2978. //sideBar._sideBarComponent._getStates();
  2979. self.drawer.open = !self.drawer.open
  2980. document.querySelector('#sideBar').style.visibility = 'visible';
  2981. },
  2982. $components: [{
  2983. $type: "i",
  2984. class: "material-icons mdc-list-item__graphic",
  2985. 'aria-hidden': "true",
  2986. $text: "save"
  2987. },
  2988. {
  2989. $text: "Clone/Save"
  2990. }]
  2991. },
  2992. self.widgets.divider,
  2993. webrtcGUI,
  2994. self.widgets.divider,
  2995. self.widgets.headerH3("h3", "Users online", "userList mdc-list-group__subheader"),
  2996. clientListCell
  2997. //widgets.headerH3("h3", "WebRTC", "userList mdc-list-group__subheader"),
  2998. ]
  2999. }
  3000. // {
  3001. // $cell: true,
  3002. // $type: "div",
  3003. // class: "mdc-persistent-drawer__toolbar-spacer",
  3004. // },
  3005. // {
  3006. // $cell: true,
  3007. // $type: "div",
  3008. // class: "mdc-list-group",
  3009. // $components: [{
  3010. // $cell: true,
  3011. // $type: "nav",
  3012. // class: "mdc-list",
  3013. // $components: [
  3014. // ]
  3015. // }]
  3016. // }
  3017. ]
  3018. };
  3019. // <div class="mdc-form-field">
  3020. // <input type="checkbox" id="input">
  3021. // <label for="input">Input Label</label>
  3022. // </div>
  3023. document.querySelector("#drawer").$cell({
  3024. $cell: true,
  3025. $type: "aside",
  3026. class: "mdc-drawer mdc-drawer--modal",
  3027. $init: function () {
  3028. let elScrim = document.createElement("div");
  3029. elScrim.classList.add("mdc-drawer-scrim");
  3030. this.after(elScrim);
  3031. self.drawer = new mdc.drawer.MDCDrawer(this);
  3032. },
  3033. $components: [
  3034. {
  3035. $type: "div",
  3036. class: "mdc-drawer__header",
  3037. $components: [
  3038. {
  3039. $type: "h3",
  3040. class: "mdc-drawer__title",
  3041. $text: self.lang.t("home")
  3042. },
  3043. {
  3044. $type: "h6",
  3045. class: "mdc-drawer__subtitle",
  3046. $text: "menu"
  3047. }
  3048. ]
  3049. },
  3050. // {
  3051. // $type: "button"
  3052. // },
  3053. drawerCell]
  3054. }
  3055. );
  3056. let toolbar = {
  3057. $cell: true,
  3058. $type: "div",
  3059. class: "mdc-top-app-bar__row",
  3060. $components: [{
  3061. $type: "section",
  3062. class: "mdc-top-app-bar__section mdc-top-app-bar__section--align-start",
  3063. $components: [
  3064. {
  3065. $type: "button",
  3066. type: "button",
  3067. class: "mdc-icon-button material-icons mdc-top-app-bar__navigation-icon",
  3068. $text: "menu"
  3069. },
  3070. {
  3071. $type: "span",
  3072. class: "mdc-top-app-bar__title catalog-title",
  3073. $text: "LiveCoding.space"
  3074. },
  3075. {
  3076. $type: "div",
  3077. class: "mdc-menu-anchor",
  3078. $components: [
  3079. {
  3080. $type: "a",
  3081. class: "mdc-icon-button material-icons mdc-top-app-bar__action-item",
  3082. id: "toggleCreate",
  3083. $text: "apps",
  3084. 'aria-label': "More"
  3085. },
  3086. {
  3087. $type: "div",
  3088. class: "mdc-menu mdc-menu-surface",
  3089. "tabindex": "-1",
  3090. id: "create-menu",
  3091. $init: function () {
  3092. //var menuEl = document.querySelector('#demo-menu');
  3093. var menu = new mdc.menu.MDCMenu(this);
  3094. var toggle = document.querySelector('#toggleCreate');
  3095. toggle.addEventListener('click', function () {
  3096. menu.open = !menu.open;
  3097. });
  3098. },
  3099. style: "transform-origin: right top 0px; right: 0px; top: 0px;",
  3100. $components: [
  3101. {
  3102. $type: "ul",
  3103. class: "mdc-menu__items mdc-list",
  3104. role: "menu",
  3105. 'aria-hidden': "true",
  3106. // style: "transform: scale(1, 1);",
  3107. $components: [
  3108. {
  3109. $type: "li",
  3110. class: "mdc-list-item",
  3111. role: "menuitem",
  3112. tabindex: "0",
  3113. $text: "Apps"
  3114. }
  3115. ]
  3116. }
  3117. ]
  3118. }
  3119. ]
  3120. },
  3121. self.widgets.icontoggle({
  3122. 'styleClass': "mdc-top-app-bar__action-item",
  3123. 'id': "selectNodeSwitch",
  3124. 'label': 'select',
  3125. 'on': JSON.stringify({ "content": "radio_button_checked", "label": "Select" }),
  3126. 'off': JSON.stringify({ "content": "radio_button_unchecked", "label": "Unselect" }),
  3127. 'state': false,
  3128. 'init': function () {
  3129. this._comp = mdc.iconButton.MDCIconButtonToggle.attachTo(this);
  3130. this.addEventListener('MDCIconButtonToggle:change', (e) => {
  3131. let avatarID = 'avatar-' + vwf.moniker_;
  3132. let avatarNode = self.nodes['avatar-' + vwf.moniker_];
  3133. let mode = JSON.parse(avatarNode.properties.selectMode.getValue());
  3134. if (mode) {
  3135. console.log("unselect");
  3136. vwf_view.kernel.setProperty(avatarID, "selectMode", false);
  3137. } else {
  3138. console.log("select")
  3139. vwf_view.kernel.setProperty(avatarID, "selectMode", true);
  3140. }
  3141. });
  3142. }
  3143. })
  3144. ]
  3145. },
  3146. {
  3147. $type: "section",
  3148. class: "mdc-top-app-bar__section mdc-top-app-bar__section--align-end",
  3149. $components: [
  3150. {
  3151. $type: "a",
  3152. href: "#",
  3153. class: "mdc-icon-button menuItem mdc-top-app-bar__action-item",
  3154. $text: "EN",
  3155. onclick: function () {
  3156. //self.lang.changeLanguageTo('en')
  3157. localStorage.setItem('krestianstvo_locale', 'en');
  3158. window.location.reload(true);
  3159. }
  3160. },
  3161. {
  3162. $type: "a",
  3163. href: "#",
  3164. class: "mdc-icon-button menuItem mdc-top-app-bar__action-item",
  3165. $text: "RU",
  3166. onclick: function () {
  3167. //self.lang.changeLanguageTo('ru')
  3168. localStorage.setItem('krestianstvo_locale', 'ru');
  3169. window.location.reload(true);
  3170. }
  3171. },
  3172. {
  3173. $type: "a",
  3174. href: "#",
  3175. class: "material-icons mdc-icon-button mdc-top-app-bar__action-item",
  3176. $text: "help",
  3177. 'aria-label': "Help",
  3178. onclick: function (e) {
  3179. e.preventDefault();
  3180. console.log("TODO: help window")
  3181. }
  3182. }
  3183. ]
  3184. }
  3185. ]
  3186. };
  3187. document.querySelector("#toolbar").$cell({
  3188. $cell: true,
  3189. $type: "div",
  3190. class: "drawer-frame-app-content",
  3191. $components: [
  3192. {
  3193. $type: "header",
  3194. class: "mdc-top-app-bar drawer-top-app-bar",
  3195. $init: function () {
  3196. const topAppBar = new mdc.topAppBar.MDCTopAppBar.attachTo(this);
  3197. topAppBar.listen('MDCTopAppBar:nav', () => {
  3198. self.drawer.open = !self.drawer.open;
  3199. });
  3200. },
  3201. $components: [
  3202. toolbar
  3203. ]
  3204. }
  3205. ]
  3206. }
  3207. );
  3208. // var toggleNodes = document.querySelectorAll('.mdc-icon-button');
  3209. // toggleNodes.forEach(el => {
  3210. // mdc.iconButton.MDCIconButtonToggle.attachTo(el);
  3211. // });
  3212. //==============
  3213. },
  3214. createdNode: function (nodeID, childID, childExtendsID, childImplementsIDs,
  3215. childSource, childType, childIndex, childName, callback /* ( ready ) */) {
  3216. // var nodeIDAttribute = $.encoder.encodeForHTMLAttribute("id", nodeID, true);
  3217. // var childIDAttribute = $.encoder.encodeForHTMLAttribute("id", childID, true);
  3218. // var childIDAlpha = $.encoder.encodeForAlphaNumeric(childID);
  3219. var kernel = this.kernel;
  3220. var self = this;
  3221. var parent = this.nodes[nodeID];
  3222. var node = this.nodes[childID] = {
  3223. children: [],
  3224. properties: [],
  3225. events: {},
  3226. methods: {},
  3227. parent: parent,
  3228. parentID: nodeID,
  3229. ID: childID,
  3230. extendsID: childExtendsID,
  3231. implementsIDs: childImplementsIDs,
  3232. source: childSource,
  3233. name: childName,
  3234. };
  3235. if (parent) {
  3236. parent.children.push(node);
  3237. }
  3238. if (childID == vwf_view.kernel.find("", "/")[0] && childExtendsID && this.kernel.test(childExtendsID,
  3239. "self::element(*,'proxy/aframe/ascene.vwf')", childExtendsID)) {
  3240. this.scenes[childID] = node;
  3241. }
  3242. let nodeCell = document.querySelector("#currentNode");
  3243. if (nodeCell !== null) {
  3244. if (nodeCell._currentNode === nodeID) {
  3245. nodeCell._getChildNodes();
  3246. }
  3247. }
  3248. if (nodeID === this.kernel.application()) {
  3249. // document.querySelector('a-scene').classList.add("mdc-toolbar-fixed-adjust");
  3250. document.querySelector('body').classList.add("editor-body");
  3251. }
  3252. },
  3253. createdProperty: function (nodeID, propertyName, propertyValue) {
  3254. return this.initializedProperty(nodeID, propertyName, propertyValue);
  3255. },
  3256. initializedProperty: function (nodeID, propertyName, propertyValue) {
  3257. var node = this.nodes[nodeID];
  3258. if (!node) return; // TODO: patch until full-graph sync is working; drivers should be able to assume that nodeIDs refer to valid objects
  3259. var property = node.properties[propertyName] = createProperty.call(this, node, propertyName, propertyValue);
  3260. node.properties.push(property);
  3261. let nodeCell = document.querySelector("#currentNode");
  3262. if (nodeCell !== null) {
  3263. if (nodeCell._currentNode === nodeID) {
  3264. nodeCell._getNodeProperties();
  3265. }
  3266. }
  3267. },
  3268. deletedNode: function (nodeID) {
  3269. var node = this.nodes[nodeID];
  3270. node.parent.children.splice(node.parent.children.indexOf(node), 1);
  3271. delete this.nodes[nodeID];
  3272. let nodeCell = document.querySelector("#currentNode");
  3273. if (nodeCell) {
  3274. if (nodeCell._currentNode !== "") {
  3275. if (nodeCell._currentNode !== nodeID) {
  3276. //&& (this.nodes[nodeID] !== undefined)
  3277. nodeCell._getChildNodes();
  3278. } else {
  3279. nodeCell._setNode(vwf_view.kernel.find("", "/")[0]);
  3280. nodeCell._getChildNodes();
  3281. }
  3282. }
  3283. }
  3284. },
  3285. //addedChild: [ /* nodeID, childID, childName */ ],
  3286. //removedChild: [ /* nodeID, childID */ ],
  3287. satProperty: function (nodeID, propertyName, propertyValue) {
  3288. var node = this.nodes[nodeID];
  3289. if (!node) return; // TODO: patch until full-graph sync is working; drivers should be able to assume that nodeIDs refer to valid objects
  3290. // It is possible for a property to have satProperty called for it without ever getting an
  3291. // initializedProperty (if that property delegated to itself or another on replication)
  3292. // Catch that case here and create the property
  3293. if (!node.properties[propertyName]) {
  3294. var property = node.properties[propertyName] = createProperty.call(this, node, propertyName, propertyValue);
  3295. node.properties.push(property);
  3296. }
  3297. try {
  3298. propertyValue = utility.transform(propertyValue, utility.transforms.transit);
  3299. node.properties[propertyName].value = JSON.stringify(propertyValue);
  3300. node.properties[propertyName].rawValue = propertyValue;
  3301. } catch (e) {
  3302. this.logger.warnx("satProperty", nodeID, propertyName, propertyValue,
  3303. "stringify error:", e.message);
  3304. node.properties[propertyName].value = propertyValue;
  3305. }
  3306. let nodeCell = document.querySelector('#currentNode');
  3307. if (nodeCell !== null) {
  3308. if (nodeCell._currentNode == nodeID && propertyName == 'isPlaying') {
  3309. console.log('SET PLAY !!!');
  3310. let compID = 'soundStopStartSwitch-' + nodeID;
  3311. let playSwitch = document.querySelector("[id='" + compID + "']");
  3312. if (playSwitch) {
  3313. // const mycomp = new mdc.iconToggle.MDCIconToggle(playSwitch); //new mdc.select.MDCIconToggle
  3314. playSwitch._comp.on = propertyValue;
  3315. }
  3316. }
  3317. }
  3318. if (nodeCell !== null) {
  3319. if (nodeCell._currentNode == nodeID && propertyName == 'edit') {
  3320. console.log('EDIT !!!')
  3321. }
  3322. }
  3323. let propCell = document.querySelector("#currentNode #prop-" + propertyName);
  3324. let propSlider = document.querySelector("#currentNode #prop-slider-" + propertyName);
  3325. if (propCell !== null) {
  3326. if (propCell._currentNode == nodeID) {
  3327. propCell.value = node.properties[propertyName].getValue();
  3328. }
  3329. }
  3330. if (propSlider !== null) {
  3331. if (propSlider._currentNode == nodeID) {
  3332. //const propSliderComp = new new mdc.slider.MDCSlider(propSlider);
  3333. propSlider._comp.value = node.properties[propertyName].getValue();
  3334. }
  3335. }
  3336. },
  3337. //gotProperty: [ /* nodeID, propertyName, propertyValue */ ],
  3338. gotProperty: function (nodeID, propertyName, propertyValue) {
  3339. var node = this.nodes[nodeID];
  3340. if (!node) return; // TODO: patch until full-graph sync is working; drivers should be able to assume that nodeIDs refer to valid objects
  3341. let nodeCell = document.querySelector('#currentNode');
  3342. if (nodeCell !== null) {
  3343. if (nodeCell._currentNode == nodeID && propertyName == 'edit') {
  3344. let gizmoChild = node.children.filter(el=>el.ID.includes('gizmo'));
  3345. if (gizmoChild.length > 0) {
  3346. let editCheckBox = document.querySelector("#currentNode #editnode");
  3347. if (editCheckBox) {
  3348. let mdcSwitch = editCheckBox._switch;
  3349. if (mdcSwitch) {
  3350. mdcSwitch.checked = propertyValue
  3351. }
  3352. }
  3353. console.log('EDIT !!! is ' + propertyValue)
  3354. }
  3355. }
  3356. }
  3357. },
  3358. createdMethod: function (nodeID, methodName, methodParameters, methodBody) {
  3359. var node = this.nodes[nodeID];
  3360. if (node) {
  3361. node.methods[methodName] = methodParameters;
  3362. }
  3363. },
  3364. //calledMethod: function( nodeID, methodName, methodParameters, methodValue ) {
  3365. //},
  3366. createdEvent: function (nodeID, eventName, eventParameters) {
  3367. var node = this.nodes[nodeID];
  3368. if (node) {
  3369. node.events[eventName] = eventParameters;
  3370. }
  3371. },
  3372. firedEvent: function (nodeID, eventName, eventParameters) {
  3373. var node = this.nodes[nodeID];
  3374. if (node) {
  3375. if (eventName == 'printEvent'){
  3376. var clientThatSatProperty = self.kernel.client();
  3377. var me = self.kernel.moniker();
  3378. // If the transform property was initially updated by this view....
  3379. if ( clientThatSatProperty == me) {
  3380. let editor = document.querySelector("#aceEditor").env.editor;
  3381. if(editor){
  3382. var cursorPosition = editor.getCursorPosition();
  3383. var selectedText = editor.getSession().doc.getTextRange(editor.selection.getRange());
  3384. if (selectedText !== "") {
  3385. cursorPosition = editor.selection.getRange().end;
  3386. }
  3387. let data = eventParameters[0];//JSON.stringify(eventParameters[0]);
  3388. editor.session.insert(cursorPosition, data);
  3389. }
  3390. //console.log(eventParameters);
  3391. }
  3392. }
  3393. }
  3394. },
  3395. executed: function (nodeID, scriptText, scriptType) {
  3396. // var nodeScript = {
  3397. // text: scriptText,
  3398. // type: scriptType,
  3399. // };
  3400. // if ( !this.allScripts[ nodeID ] ) {
  3401. // var nodeScripts = new Array();
  3402. // nodeScripts.push(nodeScript);
  3403. // this.allScripts[ nodeID ] = nodeScripts;
  3404. // }
  3405. // else {
  3406. // this.allScripts[ nodeID ].push(nodeScript);
  3407. // }
  3408. },
  3409. //ticked: [ /* time */ ],
  3410. });
  3411. function createCellWindow(elementID, cellNode, title) {
  3412. document.querySelector('#' + elementID).$cell({
  3413. $cell: true,
  3414. $type: "div",
  3415. id: elementID,
  3416. style: 'position: absolute;',
  3417. class: 'draggable',
  3418. $init: function () {
  3419. // let draggie = new Draggabilly('.draggable', {
  3420. // handle: '.handle',
  3421. // containment: true
  3422. // });
  3423. // get all draggie elements
  3424. var draggableElems = document.querySelectorAll('.draggable');
  3425. // array of Draggabillies
  3426. var draggies = []
  3427. // init Draggabillies
  3428. for (var i = 0, len = draggableElems.length; i < len; i++) {
  3429. var draggableElem = draggableElems[i];
  3430. var draggie = new Draggabilly(draggableElem, {
  3431. handle: '.handle'
  3432. //containment: true
  3433. });
  3434. draggies.push(draggie);
  3435. }
  3436. this.style.visibility = 'hidden';
  3437. },
  3438. $components: [
  3439. {
  3440. $type: "div",
  3441. class: "handle"
  3442. },
  3443. {
  3444. $type: "button",
  3445. class: "mdc-button mdc-button--compact",
  3446. $text: "X",
  3447. onclick: function (e) {
  3448. //self.currentNodeID = m.ID;
  3449. if( elementID == 'codeEditorWindow'){
  3450. //self.nodes[currentNode].liveBindings = {};
  3451. }
  3452. document.querySelector('#' + elementID).style.visibility = 'hidden';
  3453. }
  3454. },
  3455. {
  3456. $type: "span",
  3457. class: "mdc-typography--button",
  3458. $text: title
  3459. },
  3460. cellNode,
  3461. {
  3462. $type: "div",
  3463. class: "handle",
  3464. style: "height: 10px; width: inherit;",
  3465. //$text: "sdfsdf"
  3466. }
  3467. // { $text: "23423"}
  3468. ]
  3469. }
  3470. );
  3471. }
  3472. // -- getChildByName --------------------------------------------------------------------
  3473. function getChildByName(node, childName) {
  3474. var childNode = undefined;
  3475. for (var i = 0; i < node.children.length && childNode === undefined; i++) {
  3476. if (node.children[i].name == childName) {
  3477. childNode = node.children[i];
  3478. }
  3479. }
  3480. return childNode;
  3481. };
  3482. // -- viewScript ------------------------------------------------------------------------
  3483. function createAceEditor(view, nodeID, elID) {
  3484. var editor = view.ace.edit(elID);
  3485. editor.setTheme("ace/theme/monokai");
  3486. editor.setFontSize(20);
  3487. editor.getSession().setMode("ace/mode/javascript");
  3488. editor.commands.addCommand({
  3489. name: "doit",
  3490. bindKey: { win: "Ctrl-e", mac: "Command-e" },
  3491. exec: function () {
  3492. codeEditorDoit(editor, nodeID);
  3493. }
  3494. });
  3495. editor.commands.addCommand({
  3496. name: "printit",
  3497. bindKey: { win: "Ctrl-b", mac: "Command-b" },
  3498. exec: function () {
  3499. codeEditorPrintit(editor, nodeID);
  3500. }
  3501. });
  3502. return editor;
  3503. }
  3504. function isAFrameComponent(nodeID) {
  3505. let node = self.nodes[nodeID];
  3506. let nodeProtos = getPrototypes(self.kernel, node.extendsID);
  3507. if (nodeProtos.includes('proxy/aframe/componentNode.vwf')) {
  3508. return true
  3509. }
  3510. return false
  3511. }
  3512. function isAFrameEntity(nodeID) {
  3513. let node = self.nodes[nodeID];
  3514. let nodeProtos = getPrototypes(self.kernel, node.extendsID);
  3515. if (nodeProtos.includes('proxy/aframe/node.vwf')) {
  3516. return true
  3517. }
  3518. return false
  3519. }
  3520. function getPrototypes(kernel, extendsID) {
  3521. var prototypes = [];
  3522. var id = extendsID;
  3523. while (id !== undefined) {
  3524. prototypes.push(id);
  3525. id = kernel.prototype(id);
  3526. }
  3527. return prototypes;
  3528. }
  3529. function getPrototypes(kernel, extendsID) {
  3530. var prototypes = [];
  3531. var id = extendsID;
  3532. while (id !== undefined) {
  3533. prototypes.push(id);
  3534. id = kernel.prototype(id);
  3535. }
  3536. return prototypes;
  3537. }
  3538. function createProperty(node, propertyName, propertyValue) {
  3539. var property = {
  3540. name: propertyName,
  3541. rawValue: propertyValue,
  3542. value: undefined,
  3543. getValue: function () {
  3544. var propertyValue;
  3545. if (this.value == undefined) {
  3546. try {
  3547. propertyValue = utility.transform(this.rawValue, utility.transforms.transit);
  3548. this.value = JSON.stringify(propertyValue);
  3549. } catch (e) {
  3550. this.logger.warnx("createdProperty", nodeID, this.propertyName, this.rawValue,
  3551. "stringify error:", e.message);
  3552. this.value = this.rawValue;
  3553. }
  3554. }
  3555. return this.value;
  3556. }
  3557. };
  3558. return property;
  3559. }
  3560. function getProperties(kernel, extendsID) {
  3561. var pTypes = getPrototypes(kernel, extendsID);
  3562. var pProperties = {};
  3563. if (pTypes) {
  3564. for (var i = 0; i < pTypes.length; i++) {
  3565. var nd = this.nodes[pTypes[i]];
  3566. if (nd && nd.properties) {
  3567. for (var key in nd.properties) {
  3568. pProperties[key] = { "prop": nd.properties[key], "prototype": pTypes[i] };
  3569. }
  3570. }
  3571. }
  3572. }
  3573. return pProperties;
  3574. }
  3575. function getChildren(kernel, extendsID) {
  3576. var pTypes = getPrototypes(kernel, extendsID);
  3577. var pChildren = {};
  3578. if (pTypes) {
  3579. for (var i = 0; i < pTypes.length; i++) {
  3580. var nd = this.nodes[pTypes[i]];
  3581. if (nd && nd.children) {
  3582. for (var key in nd.children) {
  3583. pChildren[key] = nd.children[key];
  3584. }
  3585. }
  3586. }
  3587. }
  3588. return pChildren;
  3589. }
  3590. function getEvents(kernel, extendsID) {
  3591. var pTypes = getPrototypes(kernel, extendsID);
  3592. var events = {};
  3593. if (pTypes) {
  3594. for (var i = 0; i < pTypes.length; i++) {
  3595. var nd = this.nodes[pTypes[i]];
  3596. if (nd && nd.events) {
  3597. for (var key in nd.events) {
  3598. events[key] = nd.events[key];
  3599. }
  3600. }
  3601. }
  3602. }
  3603. return events;
  3604. }
  3605. function getMethods(kernel, extendsID) {
  3606. var pTypes = getPrototypes(kernel, extendsID);
  3607. var methods = {};
  3608. if (pTypes) {
  3609. for (var i = 0; i < pTypes.length; i++) {
  3610. var nd = this.nodes[pTypes[i]];
  3611. if (nd && nd.methods) {
  3612. for (var key in nd.methods) {
  3613. methods[key] = nd.methods[key];
  3614. }
  3615. }
  3616. }
  3617. }
  3618. return methods;
  3619. }
  3620. // -- Show Code Editor tab
  3621. function codeEditorDoit(editor, nodeID) {
  3622. var selectedText = editor.getSession().doc.getTextRange(editor.selection.getRange());
  3623. if (selectedText == "") {
  3624. var currline = editor.getSelectionRange().start.row;
  3625. var selectedText = editor.session.getLine(currline);
  3626. }
  3627. //console.log(selectedText);
  3628. //var sceneID = self.kernel.application();
  3629. vwf_view.kernel.execute(nodeID, selectedText);
  3630. }
  3631. function codeEditorPrintitInDebugger(editor, nodeID) {
  3632. var selectedText = editor.getSession().doc.getTextRange(editor.selection.getRange());
  3633. if (selectedText == "") {
  3634. var currline = editor.getSelectionRange().start.row;
  3635. var selectedText = editor.session.getLine(currline);
  3636. }
  3637. let scriptText = 'console.log(' + selectedText + ');'
  3638. self.kernel.execute(nodeID, scriptText);
  3639. }
  3640. function codeEditorPrintit(editor, nodeID) {
  3641. var selectedText = editor.getSession().doc.getTextRange(editor.selection.getRange());
  3642. if (selectedText == "") {
  3643. var currline = editor.getSelectionRange().start.row;
  3644. var selectedText = editor.session.getLine(currline);
  3645. }
  3646. //console.log(selectedText);
  3647. //var sceneID = self.kernel.application();
  3648. //vwf.views["vwf/view/editor-new"].nodes[this.id].liveBindings
  3649. //let node = self.nodes[nodeID];
  3650. let me = self.kernel.moniker();
  3651. vwf_view.kernel.fireEvent(nodeID, 'printIt', [selectedText, me]);
  3652. // let printText = _app.helpers.replaceSubStringALL(selectedText,'this','me');
  3653. // let bindString = 'vwf.views["vwf/view/aframe"].nodes["'+ nodeID + '"].liveBindings';
  3654. // let scriptText = 'let binding = '+ bindString +'; binding.me = this; lively.vm.syncEval("var print = ' + printText + '",{topLevelVarRecorder: binding});';
  3655. // vwf_view.kernel.execute(nodeID, scriptText);
  3656. // let scriptText = 'console.log(' + selectedText + ');'
  3657. // self.kernel.execute(nodeID, scriptText);
  3658. }
  3659. function codeEditorPrintitConsole (editor, nodeID) {
  3660. var selectedText = editor.getSession().doc.getTextRange(editor.selection.getRange());
  3661. if (selectedText == "") {
  3662. var currline = editor.getSelectionRange().start.row;
  3663. var selectedText = editor.session.getLine(currline);
  3664. }
  3665. let scriptText = 'console.log(' + selectedText + ');'
  3666. self.kernel.execute(nodeID, scriptText);
  3667. }
  3668. // -- SupportAjax -----------------------------------------------------------------------------
  3669. // function supportAjaxUploadWithProgress() {
  3670. // return supportAjaxUploadProgressEvents();
  3671. // function supportAjaxUploadProgressEvents() {
  3672. // var xhr = new XMLHttpRequest();
  3673. // return !!(xhr && ('upload' in xhr) && ('onprogress' in xhr.upload));
  3674. // }
  3675. // }
  3676. });