editor-new.js 190 KB

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