smty.js 74 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283
  1. var settings = {};
  2. settings["onstart"] = "trace('on start...')";
  3. settings["view.hlookat"] = 30;
  4. const house ={
  5. // curr_id:2,
  6. idx:0,
  7. // direction:'B',
  8. nextId:null,
  9. isLoading:false,
  10. numLoaded:0,
  11. mode:'full',
  12. texture:{
  13. id:-1,
  14. curr:null,
  15. next:null,
  16. isloading:false,
  17. },
  18. config:{
  19. lat_step:10,
  20. lon_step:10,
  21. },
  22. title:"南京世茂项目",
  23. src:[
  24. {id:1,name:"01frontGate",title:'01正门',home:{T:50,R:70},view:0,image:"panos/01frontGate.png",
  25. ath: 192.7678496377909,atv: 3.342656268019511,
  26. direction:[
  27. {id:14,name:'L',angle:{lat: -10, lon: 16.3},offset:180},
  28. {id:25,name:'R',angle:{lat: -13.7, lon: 75.3},offset:-70},
  29. {id:null,name:'F'},
  30. {id:null,name:'B'},
  31. {id:null,name:'LF'},
  32. {id:null,name:'LB'},
  33. {id:null,name:'RF'},
  34. {id:null,name:'RB'}
  35. ],
  36. // L:{id:14,angle:{lat: -10, lon: 16.3},offset:180},R:{id:25,angle:{lat: -13.7, lon: 75.3},offset:-70},F:null,B:null,LF:null,
  37. // LB:null,RF:null,RB:null,
  38. spots:[
  39. {name:'spot1',id:14,ath: -151.72625593816582 ,atv: 17.778666220467294 },
  40. {name:'spot2',id:25,ath: -98.82302271267214 ,atv: 5.022944264223217}
  41. ]},
  42. {id:2,name:"02masterBedroom",title:'02主卧',home:{T:83,R:45},view:-90,image:"panos/02masterBedroom.png",
  43. ath: 0,atv: 0,
  44. direction:[
  45. {id:null,name:'L'},
  46. {id:4,name:'R',angle:{lat: -9.5, lon: 50},offset:180},
  47. {id:6,name:'F',angle:{lat: -4, lon: -77},offset:-90},
  48. {id:3,name:'B',angle:{lat: -3.7, lon: 0.5},offset:0},
  49. {id:null,name:'LF'},
  50. {id:null,name:'LB'},
  51. {id:null,name:'RF'},
  52. {id:null,name:'RB'}
  53. ],
  54. spots:[
  55. {name:'spot1',id:3,ath: 133.13789336284296 ,atv: 4.413364336761442},
  56. {name:'spot2',id:4,ath: -96.33845818870535 ,atv: 9.822282761777577},
  57. {name:'spot3',id:6,ath: 60.349644552524836 ,atv: 2.0688887045111275}
  58. ],},
  59. {id:3,name:"03masterBedroom",title:'03主卧',home:{T:85,R:36},view:-180,
  60. ath: 0 ,atv: 0 ,
  61. image:"panos/03masterBedroom.png",
  62. direction:[
  63. {id:null,name:'L'},
  64. {id:4,name:'R',angle:{lat: -13.6, lon: 54},offset:180},
  65. {id:2,name:'F',angle:{lat: 2.7, lon: 16.7},offset:90},
  66. {id:null,name:'B'},
  67. {id:null,name:'LF'},
  68. {id:null,name:'LB'},
  69. {id:null,name:'RF'},
  70. {id:null,name:'RB'}
  71. ],
  72. // L:null,R:{id:4,angle:{lat: -13.6, lon: 54},offset:180},F:{id:2,angle:{lat: 2.7, lon: 16.7},
  73. // offset:90},B:null,LF:null,LB:null,RF:null,RB:null,
  74. spots:[
  75. {name:'spot1',id:2,ath: -87.28296784192219 ,atv: 0.39869598547481716}
  76. ]},
  77. {id:4,name:"04masterBedroom",title:'04主卧',home:{T:75,R:30},view:0,
  78. ath: 0 ,atv: 0 ,
  79. image:"panos/04masterBedroom.png",
  80. direction:[
  81. {id:null,name:'L'},
  82. {id:3,name:'R',angle:{lat: 0, lon: 13.5},offset:0},
  83. {id:null,name:'F'},
  84. {id:2,name:'B',angle:{lat: 3, lon: 17.1},offset:90},
  85. {id:null,name:'LF'},
  86. {id:null,name:'LB'},
  87. {id:null,name:'RF'},
  88. {id:null,name:'RB'}
  89. ],
  90. // L:null,R:{id:3,angle:{lat: 0, lon: 13.5},offset:0},F:null,B:{id:2,angle:{lat: 3, lon: 17.1},offset:90},
  91. // LF:null,LB:null,RF:null,RB:null,
  92. spots:[
  93. {name:'spot1',ath: 116.66721467605558 ,atv: 6.234077010079432}
  94. ]},
  95. {id:5,name:"05masterBedroomToilet",title:'05主卧卫生间',home:{T:60,R:30},view:162,
  96. ath: 0 ,atv: 0 ,
  97. image:"panos/05masterBedroomToilet.png",
  98. direction:[
  99. {id:null,name:'L'},
  100. {id:null,name:'R'},
  101. {id:7,name:'F',angle:{lat: -13, lon: 50},offset:0},
  102. {id:null,name:'B'},
  103. {id:null,name:'LF'},
  104. {id:null,name:'LB'},
  105. {id:null,name:'RF'},
  106. {id:null,name:'RB'}
  107. ],
  108. // L:null,R:null,F:{id:7,angle:{lat: -13, lon: 50},offset:0},B:null,LF:null,LB:null,
  109. // RF:null,RB:null,
  110. spots:[
  111. {name:'spot1',ath: 201.88304453026302 ,atv: 15.237691096136444}
  112. ]},
  113. {id:6,name:"06masterBedroomPorch",title:'06主卧门廊',home:{T:66,R:45},view:82,
  114. ath: 0 ,atv: 0 ,
  115. image:"panos/06masterBedroomPorch.png",
  116. direction:[
  117. {id:null,name:'L'},
  118. {id:25,name:'R',angle:{lat: -10, lon: 150},offset:-75},
  119. {id:2,name:'F',angle:{lat: -6.5, lon: -86},offset:90},
  120. {id:7,name:'B',angle:{lat: -2, lon: 146},offset:35},
  121. {id:null,name:'LF'},
  122. {id:null,name:'LB'},
  123. {id:null,name:'RF'},
  124. {id:null,name:'RB'}
  125. ],
  126. // L:null,R:{id:25,angle:{lat: -10, lon: 150},offset:-75},F:{id:2,angle:{lat: -6.5, lon: -86},
  127. // offset:90},B:{id:7,angle:{lat: -2, lon: 146},offset:35},LF:null,LB:null,RF:null,RB:null,
  128. spots:[
  129. {name:'spot1',ath: 94.50577474627525 ,atv: 13.840215177648496},
  130. {name:'spot2',ath: -1.7020717516536996 ,atv: 9.14341656185524},
  131. {name:'spot3',ath: -18.006209788374164 ,atv: 9.440229909461376}
  132. ]},
  133. {id:7,name:"07masterBedroomCloakroom",title:'07主卧衣帽间',home:{T:60,R:48},view:-117,
  134. ath: 137.87124014202362 ,atv: 4.554532782347062 ,
  135. image:"panos/07masterBedroomCloakroom.png",
  136. direction:[
  137. {id:6,name:'L',angle:{lat: 1.9, lon: 86},offset:-90},
  138. {id:null,name:'R'},
  139. {id:null,name:'F'},
  140. {id:null,name:'B'},
  141. {id:null,name:'LF'},
  142. {id:6,name:'LB',angle:{lat: 1.9, lon: 86},offset:-90},
  143. {id:null,name:'RF'},
  144. {id:5,name:'RB',angle:{lat: -3.2, lon: -80},offset:0}
  145. ],
  146. // L:{id:6,angle:{lat: 1.9, lon: 86},offset:-90},R:null,F:null,B:null,LF:null,LB:{id:6,
  147. // angle:{lat: 1.9, lon: 86},offset:-90},RF:null,RB:{id:5,angle:{lat: -3.2, lon: -80},offset:0},
  148. spots:[
  149. {name:'spot1',ath: 96.20953150513165 ,atv: 4.985635364720976},
  150. {name:'spot2',ath: -93.74469395101436 ,atv: 4.428720411954739}
  151. ]},
  152. {id:8,name:"08AguestRoom",title:'08客房',home:{T:90,R:100},view:216,image:"panos/08AguestRoom.png",
  153. ath: 0 ,atv: 0 ,
  154. direction:[
  155. {id:null,name:'L'},
  156. {id:9,name:'R',angle:{lat: -4.5, lon: -48},offset:-90},
  157. {id:null,name:'F'},
  158. {id:null,name:'B'},
  159. {id:null,name:'LF'},
  160. {id:null,name:'LB'},
  161. {id:null,name:'RF'},
  162. {id:null,name:'RB'}
  163. ],
  164. // L:null,R:{id:9,angle:{lat: -4.5, lon: -48},offset:-90},F:null,B:null,LF:null,LB:null,RF:null,RB:null,
  165. spots:[
  166. {name:'spot1',ath: 109.16957231125022 ,atv: 12.40371665877947}
  167. ]},
  168. {id:9,name:"09guestRoomA",title:'09客房A',home:{T:80,R:90},view:82,image:"panos/09guestRoomA.png",
  169. ath: 0 ,atv: 0 ,
  170. direction:[
  171. {id:null,name:'L'},
  172. {id:null,name:'R'},
  173. {id:8,name:'F',angle:{lat: -5.7, lon: -25},offset:30},
  174. {id:10,name:'B',angle:{lat: -6.4, lon: 187},offset:-90},
  175. {id:null,name:'LF'},
  176. {id:null,name:'LB'},
  177. {id:null,name:'RF'},
  178. {id:null,name:'RB'}
  179. ],
  180. // L:null,R:null,F:{id:8,angle:{lat: -5.7, lon: -25},offset:30},B:{id:10,angle:{lat: -6.4, lon: 187},offset:-90},LF:null,LB:null,RF:null,
  181. // RB:null,
  182. spots:[
  183. {name:'spot1',ath: -130.3400553399444 ,atv: 9.438736212478796},
  184. {name:'spot2',ath: 274.56764156555914 ,atv: 9.440470721743205}
  185. ]},
  186. {id:10,name:"10guestRoomAToilet",title:'10客房卫生间',home:{T:70,R:100},view:87,
  187. ath: 0 ,atv: 0 ,
  188. image:"panos/10guestRoomAToilet.png",
  189. direction:[
  190. {id:null,name:'L'},
  191. {id:null,name:'R'},
  192. {id:25,name:'F',angle:{lat: 3.8, lon: -15},offset:-90},
  193. {id:null,name:'B'},
  194. {id:null,name:'LF'},
  195. {id:null,name:'LB'},
  196. {id:null,name:'RF'},
  197. {id:null,name:'RB'}
  198. ],
  199. // L:null,R:null,F:{id:25,angle:{lat: 3.8, lon: -15},offset:-90},B:null,LF:null,LB:null,
  200. // RF:null,RB:null,
  201. spots:[
  202. {name:'spot1',ath: 151.61586215506478 ,atv: -0.45354419026090353}
  203. ]},
  204. {id:11,name:"11guestRoomB",title:'11客房B',home:{T:85,R:70},view:-122,
  205. ath: -42.73263618598905 ,atv: 6.204768550626101 ,
  206. image:"panos/11guestRoomB.png",
  207. direction:[
  208. {id:null,name:'L'},
  209. {id:12,name:'R',angle:{lat: -2.8, lon: 17},offset:180},
  210. {id:25,name:'F',angle:{lat: -7, lon: -118},offset:-60},
  211. {id:null,name:'B'},
  212. {id:null,name:'LF'},
  213. {id:13,name:'LB',angle:{lat: -1.4, lon: -172},offset:160},
  214. {id:null,name:'RF'},
  215. {id:null,name:'RB'}
  216. ],
  217. // L:null,R:{id:12,angle:{lat: -2.8, lon: 17},offset:180},F:{id:25,angle:{lat: -7, lon: -118},offset:-60},
  218. // B:null,LF:null,LB:{id:13,angle:{lat: -1.4, lon: -172},offset:160},RF:null,RB:null,
  219. spots:[
  220. {name:'spot1',ath: -7.909766096794434 ,atv: 2.941497893049414},
  221. {name:'spot2',ath: 184.60326417337728 ,atv: 9.006718467442129},
  222. {name:'spot3',ath: 65.1465767375114 ,atv: 4.286209242983865}
  223. ]},
  224. {id:12,name:"12guestRoomB",title:'12客房B',home:{T:80,R:60},view:0,image:"panos/12guestRoomB.png",
  225. ath: 0 ,atv: 0 ,
  226. direction:[
  227. {id:null,name:'L'},
  228. {id:11,name:'R',angle:{lat: -10, lon: -43},offset:90},
  229. {id:null,name:'F'},
  230. {id:null,name:'B'},
  231. {id:null,name:'LF'},
  232. {id:null,name:'LB'},
  233. {id:null,name:'RF'},
  234. {id:null,name:'RB'}
  235. ],
  236. // L:null,R:{id:11,angle:{lat: -10, lon: -43},offset:90},F:null,B:null,LF:null,LB:null,RF:null,RB:null,
  237. spots:[
  238. {name:'spot1',ath: 164.12603590034158 ,atv: 8.112912774069422}
  239. ]},
  240. {id:13,name:"13guestRoomB",title:'13客房B',home:{T:95,R:70},view:0,
  241. ath: 0 ,atv: 0 ,
  242. image:"panos/13guestRoomB.png",
  243. direction:[
  244. {id:11,name:'L',angle:{lat: -6, lon: 120},offset:60},
  245. {id:null,name:'R'},
  246. {id:null,name:'F'},
  247. {id:null,name:'B'},
  248. {id:null,name:'LF'},
  249. {id:null,name:'LB'},
  250. {id:null,name:'RF'},
  251. {id:null,name:'RB'}
  252. ],
  253. // L:{id:11,angle:{lat: -6, lon: 120},offset:60},R:null,F:null,B:null,LF:null,LB:null,RF:null,RB:null,
  254. spots:[
  255. {name:'spot1',ath: -60.01092914454077 ,atv: 5.090054004721674}
  256. ]},
  257. {id:14,name:"14livingRoom",title:'14客厅',home:{T:20,R:70},view:0,image:"panos/14livingRoom.png",
  258. ath: -159.27567207943517 ,atv: 2.528526758360995 ,
  259. direction:[
  260. {id:null,name:'L'},
  261. {id:null,name:'R'},
  262. {id:16,name:'F',angle:{lat: 1.4, lon: 80},offset:180},
  263. {id:null,name:'B'},
  264. {id:17,name:'LF',angle:{lat: -2.4, lon: 36},offset:150},
  265. {id:null,name:'LB'},
  266. {id:15,name:'RF',angle:{lat: -6, lon: 148},offset:130},
  267. {id:1,name:'RB',angle:{lat: -2.1, lon: 187},offset:180}
  268. ],
  269. // L:null,R:null,
  270. // F:{id:16,angle:{lat: 1.4, lon: 80},offset:180},B:null,LF:{id:17,angle:{lat: -2.4, lon: 36},offset:150},LB:null,RF:{id:15,
  271. // angle:{lat: -6, lon: 148},offset:130},RB:{id:1,angle:{lat: -2.1, lon: 187},offset:180},
  272. spots:[
  273. {name:'spot1',ath: 0 ,atv: 0},
  274. {name:'spot2',ath: -34.1113442467674 ,atv: 1.2404792099651585},
  275. {name:'spot3',ath: -160.35289454417364 ,atv: 5.634326613316236}
  276. ]},
  277. {id:15,name:"15livingRoom",title:'15客厅',home:{T:30,R:50},view:-32,image:"panos/15livingRoom.png",
  278. ath: 47.69703936335866 ,atv: 2.3057414659561863 ,
  279. direction:[
  280. {id:null,name:'L'},
  281. {id:null,name:'R'},
  282. {id:null,name:'F'},
  283. {id:null,name:'B'},
  284. {id:16,name:'LF',angle:{lat: -7.2, lon: -13},offset:180},
  285. {id:14,name:'LB',angle:{lat: 0, lon: -57},offset:150},
  286. {id:22,name:'RF',angle:{lat: -1.4, lon: 73},offset:180},
  287. {id:20,name:'RB',angle:{lat: 0, lon: 0},offset:0}
  288. ],
  289. // L:null,R:null,F:null,B:null,LF:{id:16,angle:{lat: -7.2, lon: -13},offset:180},LB:{id:14,angle:{lat: 0, lon: -57},offset:150},
  290. // RF:{id:22,angle:{lat: -1.4, lon: 73},offset:180},RB:{id:20,angle:{lat: 0, lon: 0},offset:0},
  291. spots:[
  292. {name:'spot1',ath: 86.3591887709863 ,atv: 8.985133895285943},
  293. {name:'spot2',ath: 184.14294012777333 ,atv: 12.990747276430952},
  294. {name:'spot3',ath: -105.87657622463723 ,atv: 4.238607961667052},
  295. {name:'spot4',ath: -192.37100866081815 ,atv: 13.779938500215556}
  296. ]},
  297. {id:16,name:"16livingRoom",title:'16客厅',home:{T:20,R:50},view:0,
  298. ath: 0 ,atv: 0 ,
  299. image:"panos/16livingRoom.png",
  300. direction:[
  301. {id:19,name:'L',angle:{lat: -2, lon: -3},offset:180},
  302. {id:15,name:'R',angle:{lat: -3, lon: 230},offset:120},
  303. {id:22,name:'F',angle:{lat: 4.5, lon: 119},offset:180},
  304. {id:14,name:'B',angle:{lat: 2.5, lon: -80},offset:160},
  305. {id:18,name:'LF',angle:{lat: -10, lon: -20},offset:-130},
  306. {id:17,name:'LB',angle:{lat: 0, lon: 0},offset:160},
  307. {id:null,name:'RF'},
  308. {id:null,name:'RB'}
  309. ],
  310. // L:{id:19,angle:{lat: -2, lon: -3},offset:180},R:{id:15,angle:{lat: -3, lon: 230},offset:120},
  311. // F:{id:22,angle:{lat: 4.5, lon: 119},offset:180},B:{id:14,angle:{lat: 2.5, lon: -80},offset:160},LF:{id:18,angle:{lat: -10, lon: -20},
  312. // offset:-130},LB:{id:17,angle:{lat: 0, lon: 0},offset:160},RF:null,RB:null,
  313. spots:[
  314. {name:'spot1',ath: 51.63316742817771 ,atv: 5.736857709477558},
  315. {name:'spot2',ath: 82.21482834381248 ,atv: 6.968294282167136}
  316. ]},
  317. {id:17,name:"17livingRoom",title:'17客厅',home:{T:8,R:60},view:-20,image:"panos/17livingRoom.png",
  318. ath: 0 ,atv: 0 ,
  319. direction:[
  320. {id:23,name:'L',angle:{lat: -1, lon: -236},offset:30},
  321. {id:16,name:'R',angle:{lat: -8.2, lon: 178},offset:180},
  322. {id:null,name:'F'},
  323. {id:null,name:'B'},
  324. {id:23,name:'LF',angle:{lat: -1.4, lon: -210},offset:80},
  325. {id:null,name:'LB'},
  326. {id:19,name:'RF',angle:{lat: -2, lon: 75},offset:180},
  327. {id:14,name:'RB',angle:{lat: -6.3, lon: 221},offset:150}
  328. ],
  329. // L:{id:23,angle:{lat: -1, lon: -236},offset:30},R:{id:16,angle:{lat: -8.2, lon: 178},offset:180},F:null,B:null,LF:{id:23,
  330. // angle:{lat: -1.4, lon: -210},offset:80},LB:null,RF:{id:19,angle:{lat: -2, lon: 75},offset:180},RB:{id:14,
  331. // angle:{lat: -6.3, lon: 221},offset:150},
  332. spots:[
  333. {name:'spot1',ath: -70.81558713811852 ,atv: 10.759984298964255},
  334. {name:'spot2',ath: -96.12639873331034 ,atv: 9.263834623023362}
  335. ]},
  336. {id:18,name:"18livingRoom",title:'18客厅',home:{T:8,R:40},view:34,
  337. ath: 0 ,atv: 0 ,
  338. image:"panos/18livingRoom.png",
  339. direction:[
  340. {id:null,name:'L'},
  341. {id:null,name:'R'},
  342. {id:null,name:'F'},
  343. {id:null,name:'B'},
  344. {id:null,name:'LF'},
  345. {id:24,name:'LB',angle:{lat: -3, lon: -52},offset:-120},
  346. {id:16,name:'RF',angle:{lat: 5.2, lon: 179},offset:180},
  347. {id:19,name:'RB',angle:{lat: -1.2, lon: -81},offset:180}
  348. ],
  349. // L:null,R:null,F:null,B:null,LF:null,LB:{id:24,angle:{lat: -3, lon: -52},offset:-120},
  350. // RF:{id:16,angle:{lat: 5.2, lon: 179},offset:180},RB:{id:19,angle:{lat: -1.2, lon: -81},offset:180},
  351. spots:[
  352. {name:'spot1',ath: 134.77850440502587 ,atv: 5.364103665080412},
  353. {name:'spot2',ath: 92.86339414071163 ,atv: 9.792108196602182}
  354. ]},
  355. {id:19,name:"19livingRoom",title:'19客厅',home:{T:8,R:50},view:16,
  356. ath: 0 ,atv: 0 ,
  357. image:"panos/19livingRoom.png",
  358. direction:[
  359. {id:null,name:'L'},
  360. {id:16,name:'R',angle:{lat: -8.2, lon: 178},offset:180},
  361. {id:18,name:'F',angle:{lat: -2, lon: 75},offset:180},
  362. {id:17,name:'B',angle:{lat: -1.2, lon: -81},offset:180},
  363. {id:null,name:'LF'},
  364. {id:23,name:'LB',angle:{lat: -1, lon: -236},offset:0},
  365. {id:null,name:'RF'},
  366. {id:14,name:'RB',angle:{lat: -7, lon: 251},offset:120}
  367. ],
  368. // L:null,R:{id:16,angle:{lat: -8.2, lon: 178},offset:180},F:{id:18,angle:{lat: -2, lon: 75},offset:180},
  369. // B:{id:17,angle:{lat: -1.2, lon: -81},offset:180},LF:null,LB:{id:23,angle:{lat: -1, lon: -236},offset:0},RF:null,
  370. // RB:{id:14,angle:{lat: -7, lon: 251},offset:120},
  371. spots:[
  372. {name:'spot1',ath: -128.32247090615235 ,atv: -0.5647930758786627},
  373. {name:'spot2',ath: 109.80857804731679 ,atv: 5.539688389992394},
  374. {name:'spot3',ath: -4.651827901703093 ,atv: -1.3955474335607447}
  375. ]},
  376. {id:20,name:"20livingRoom",title:'20客厅',home:{T:40,R:45},view:170,
  377. ath: 0 ,atv: 0 ,
  378. image:"panos/20livingRoom.png",
  379. direction:[
  380. {id:21,name:'L',angle:{lat: -0.6, lon: -117},offset:150},
  381. {id:15,name:'R',angle:{lat: 2, lon: 55},offset:120},
  382. {id:null,name:'F'},
  383. {id:22,name:'B',angle:{lat: -1, lon: 70},offset:180},
  384. {id:null,name:'LF'},
  385. {id:null,name:'LB'},
  386. {id:14,name:'RF',angle:{lat: -1.8, lon: -44},offset:180},
  387. {id:null,name:'RB'}
  388. ],
  389. // L:{id:21,angle:{lat: -0.6, lon: -117},offset:150},R:{id:15,angle:{lat: 2, lon: 55},offset:120},
  390. // F:null,B:{id:22,angle:{lat: -1, lon: 70},offset:180},LF:null,LB:null,RF:{id:14,angle:{lat: -1.8, lon: -44},offset:180},RB:null,
  391. spots:[
  392. {name:'spot1',ath: 78.95542730570243 ,atv: 6.367749153204735},
  393. {name:'spot2',ath: -127.6284013542717 ,atv: 7.7561750263021505}
  394. ]},
  395. {id:21,name:"21livingRoom",title:'21客厅',home:{T:42,R:55},view:28,
  396. ath: 0 ,atv: 0 ,
  397. image:"panos/21livingRoom.png",
  398. direction:[
  399. {id:null,name:'L'},
  400. {id:null,name:'R'},
  401. {id:20,name:'F',angle:{lat: 0, lon: -179},offset:0},
  402. {id:null,name:'B'},
  403. {id:20,name:'LF',angle:{lat: -1.1, lon: -190},offset:0},
  404. {id:null,name:'LB'},
  405. {id:null,name:'RF'},
  406. {id:null,name:'RB'}
  407. ],
  408. // L:null,R:null,F:{id:20,angle:{lat: 0, lon: -179},offset:0},B:null,LF:{id:20,angle:{lat: -1.1, lon: -190},
  409. // offset:0},LB:null,RF:null,RB:null,
  410. spots:[
  411. {name:'spot1',ath: -5.271215815194857 ,atv: -0.3104829540388001}
  412. ]},
  413. {id:22,name:"22livingRoom",title:'22客厅',home:{T:23,R:20},view:0,
  414. ath: 0 ,atv: 0 ,
  415. image:"panos/22livingRoom.png",
  416. direction:[
  417. {id:null,name:'L'},
  418. {id:null,name:'R'},
  419. {id:null,name:'F'},
  420. {id:null,name:'B'},
  421. {id:null,name:'LF'},
  422. {id:null,name:'LB'},
  423. {id:null,name:'RF'},
  424. {id:20,name:'RB',id:20,angle:{lat: -2, lon: 84},offset:0}
  425. ],
  426. // L:null,R:null,F:null,B:null,LF:null,LB:null,RF:null,RB:{id:20,angle:{lat: -2, lon: 84},offset:0},
  427. spots:[
  428. {name:'spot1',ath: -127.25382000507834 ,atv: 5.000840647364074},
  429. ]},
  430. {id:23,name:"23kitchen",title:'23厨房',home:{T:-5,R:65},view:-113,image:"panos/23kitchen.png",
  431. ath: -26.247969873262953 ,atv: 1.9511418415203767 ,
  432. direction:[
  433. {id:null,name:'L'},
  434. {id:null,name:'R'},
  435. {id:null,name:'F'},
  436. {id:17,name:'B',angle:{lat: 0, lon: 165},offset:180},
  437. {id:null,name:'LF'},
  438. {id:17,name:'LB',angle:{lat: -5.7, lon: 197},offset:160},
  439. {id:null,name:'RF'},
  440. {id:null,name:'RB'}
  441. ],
  442. // L:null,R:null,F:null,B:{id:17,angle:{lat: 0, lon: 165},offset:180},LF:null,LB:{id:17,angle:{lat: -5.7, lon: 197},offset:160},
  443. // RF:null,RB:null,
  444. spots:[
  445. {name:'spot1',ath: 11.318635649670778 ,atv: -4.031145651752962}
  446. ]},
  447. {id:24,name:"24laundry",title:'24洗衣间',home:{T:-5,R:40},view:65,image:"panos/24laundry.png",
  448. ath: 67.48094136994914 ,atv: 1.300446246164014 ,
  449. direction:[
  450. {id:null,name:'L'},
  451. {id:null,name:'R'},
  452. {id:null,name:'F'},
  453. {id:null,name:'B'},
  454. {id:null,name:'LF'},
  455. {id:null,name:'LB'},
  456. {id:18,name:'RF',angle:{lat: 1.3, lon: 152},offset:230},
  457. {id:null,name:'RB'}
  458. ],
  459. // L:null,R:null,F:null,B:null,LF:null,LB:null,RF:{id:18,angle:{lat: 1.3, lon: 152},offset:230},RB:null,
  460. spots:[
  461. {name:'spot1',ath: -15.195869050543152 ,atv: 0.46518191001488113}
  462. ]},
  463. {id:25,name:"25frontGatePorch",title:'25前门门廊',home:{T:65,R:75},view:86,
  464. ath: 70.61235161030685 ,atv: 3.5989063222258157 ,
  465. image:"panos/25frontGatePorch.jpg",
  466. direction:[
  467. {id:6,name:'L',angle:{lat: -6, lon: 47},offset:-90},
  468. {id:10,name:'R',angle:{lat: 2.2, lon: -85},offset:180},
  469. {id:11,name:'F',angle:{lat: -5, lon: -67},offset:60},
  470. {id:1,name:'B',angle:{lat: 1.7, lon: 17},offset:180},
  471. {id:null,name:'LF'},
  472. {id:null,name:'LB'},
  473. {id:9,name:'RF',angle:{lat: -10, lon: -230},offset:-90},
  474. {id:1,name:'RB',angle:{lat: 0, lon: 0},offset:180}
  475. ],
  476. // L:{id:6,angle:{lat: -6, lon: 47},offset:-90},R:{id:10,angle:{lat: 2.2, lon: -85},offset:180},
  477. // F:{id:11,angle:{lat: -5, lon: -67},offset:60},B:{id:1,angle:{lat: 1.7, lon: 17},offset:180},LF:null,LB:null,
  478. // RF:{id:9,angle:{lat: -10, lon: -230},offset:-90},RB:{id:1,angle:{lat: 0, lon: 0},offset:180},
  479. spots:[
  480. {name:'spot1',ath: 208.84654004725317 ,atv: -1.6201573883004305},
  481. {name:'spot2',ath: 238.06985082121847 ,atv: 9.05712968309981},
  482. {name:'spot3',ath: -56.2838380127777 ,atv: 8.217283259609147},
  483. {name:'spot4',ath: 110.2991070639365 ,atv: 7.7864420999452335}
  484. ]},
  485. ],
  486. direction:[
  487. {id:1,name:"B",at:{x:0,y:0,z:-1}},
  488. {id:2,name:"F",at:{x:0,y:0,z:1}},
  489. {id:3,name:"R",at:{x:-1,y:0,z:0}},
  490. {id:4,name:"L",at:{x:1,y:0,z:0}},
  491. {id:5,name:"down",at:{x:0,y:1,z:0}},
  492. {id:6,name:"up",at:{x:0,y:-1,z:0}},
  493. {id:1,name:"LF",at:{x:1,y:0,z:1}},
  494. {id:2,name:"RF",at:{x:-1,y:0,z:1}},
  495. {id:3,name:"LB",at:{x:1,y:0,z:-1}},
  496. {id:4,name:"RB",at:{x:-1,y:0,z:-1}},
  497. ],
  498. playList:{
  499. idx:0,
  500. orders:[
  501. {id:1},{id:14},{id:17},{id:23},{id:19},{id:24},{id:18},{id:16},{id:22},{id:20},{id:21},{id:15},
  502. {id:25},{id:2},{id:3},{id:4},{id:5},{id:6},{id:7},{id:8},{id:9},{id:10},{id:11},{id:12},
  503. {id:13}
  504. ]
  505. },
  506. menuList:[
  507. {id:1},{id:2},{id:5},{id:9},{id:12},{id:14},{id:16},{id:17},{id:20}
  508. ]
  509. }
  510. embedpano({ id: "krpanoSWFObject_",swf:"lib/tour.swf", xml:"js/tour.xml", target:"pano", html5:"auto", mobilescale:1.0,
  511. passQueryParameters:true, onready: krpanoReady, vars:settings});
  512. function krpanoReady(krpano){
  513. // var krpano = document.getElementById('krpanoSWFObject_');
  514. window.krpano = krpano
  515. // krpano.call("trace(krpano is ready...)");
  516. changeTourMode()
  517. krpano.set("events.onviewchange", function()
  518. {
  519. updateHome()
  520. });
  521. krpano.set("events.onloadcomplete", function(e)
  522. {
  523. const scene_full_name = krpano.get('xml.scene')
  524. for(let i=0;i<house.src.length;i++){
  525. if(scene_full_name.toLowerCase().indexOf(house.src[i].name.toLowerCase())>=0 ){
  526. house.idx = i
  527. i = house.src.length
  528. }
  529. }
  530. setHomePosition()
  531. updateHome()
  532. });
  533. }
  534. function changeTourMode(){
  535. if(house.mode==='menu'){
  536. // krpano.set('autorotate.enabled',true)
  537. }else{
  538. }
  539. }
  540. function onKeyEvent(e){
  541. }
  542. init();
  543. animate();
  544. function init() {
  545. const queryString = window.location.search;
  546. const urlParams = new URLSearchParams(queryString);
  547. const panoId = urlParams.get('id')?urlParams.get('id'):0
  548. house.idx = panoId
  549. const backurl = urlParams.get('backurl')?urlParams.get('backurl'):'ybf.html'
  550. house.backurl = backurl
  551. const scene_name = 'scene_' + house.src[house.idx ].name
  552. changeScene(scene_name)
  553. const ath = house.src[house.idx].ath
  554. const atv = house.src[house.idx].atv
  555. krpano.call('lookat('+ath+','+atv+')')
  556. initMenu()
  557. setHomePosition()
  558. document.addEventListener('mousedown', onPointerStart, false);
  559. document.addEventListener('mousemove', onPointerMove, false);
  560. document.addEventListener('mouseup', onPointerUp, false);
  561. document.addEventListener('wheel', onDocumentMouseWheel, false);
  562. document.addEventListener('touchstart', onPointerStart, false);
  563. document.addEventListener('touchmove', onPointerMove, false);
  564. document.addEventListener('touchend', onPointerUp, false);
  565. // document.getElementById("menuTip").style.display='flex';
  566. // setTimeout( function(){
  567. // document.getElementById("menuTip").style.display='none';
  568. // }, 5000 );
  569. // document.addEventListener('keydown', onKeyDown);
  570. // document.addEventListener('keyup', onKeyUp);
  571. // window.addEventListener('resize', onWindowResize, false);
  572. }
  573. // function updateDirection(){
  574. // for(let d of house.src[house.idx].direction){
  575. // switch(d.name){
  576. // case 'F':
  577. // if(d.id!=null){
  578. // document.getElementById("directionTop").innerHTML = house.src[d.id-1].title
  579. // // document.getElementById("directionTop").style.visibility = true
  580. // document.getElementById("direct_top").style.color = '#ffffff'
  581. // document.getElementById("direct_top_img").src = './yaoimages/direction_top.png'
  582. // }else{
  583. // document.getElementById("directionTop").innerHTML = ''
  584. // // document.getElementById("directionTop").style.visibility = false
  585. // document.getElementById("direct_top").style.color = '#c1c1c1'
  586. // document.getElementById("direct_top_img").src = './yaoimages/direction_top_disable.png'
  587. // }
  588. // break
  589. // case 'B':
  590. // if(d.id!=null){
  591. // document.getElementById("directionLeft").innerHTML = house.src[d.id-1].title
  592. // document.getElementById("direct_left").style.color = '#ffffff'
  593. // document.getElementById("direct_left_img").src = './yaoimages/direction_left.png'
  594. // }else{
  595. // document.getElementById("directionLeft").innerHTML = ''
  596. // document.getElementById("direct_left").style.color = '#c1c1c1'
  597. // document.getElementById("direct_left_img").src = './yaoimages/direction_left_disable.png'
  598. // }
  599. // break
  600. // case 'L':
  601. // if(d.id!=null){
  602. // document.getElementById("directionBottom").innerHTML = house.src[d.id-1].title
  603. // document.getElementById("direct_bottom").style.color = '#ffffff'
  604. // document.getElementById("direct_bottom_img").src = './yaoimages/direction_bottom.png'
  605. // }else{
  606. // document.getElementById("directionBottom").innerHTML = ''
  607. // document.getElementById("direct_bottom").style.color = '#c1c1c1'
  608. // document.getElementById("direct_bottom_img").src = './yaoimages/direction_bottom_disable.png'
  609. // }
  610. // break
  611. // case 'R':
  612. // if(d.id!=null){
  613. // document.getElementById("directionRight").innerHTML = house.src[d.id-1].title
  614. // document.getElementById("direct_right").style.color = '#ffffff'
  615. // document.getElementById("direct_right_img").src = './yaoimages/direction_right.png'
  616. // }else{
  617. // document.getElementById("directionRight").innerHTML = ''
  618. // document.getElementById("direct_right").style.color = '#c1c1c1'
  619. // document.getElementById("direct_right_img").src = './yaoimages/direction_right_disable.png'
  620. // }
  621. // break
  622. // default:
  623. // break
  624. // }
  625. // }
  626. // // }
  627. // changeSpots()
  628. // }
  629. // function directionBack(){
  630. // const parent_id = house.src[house.idx].parent
  631. // if(parent_id){
  632. // const idx = getIdxFromId(parent_id)
  633. // changeTexture(idx)
  634. // }
  635. // }
  636. // function createText(textWord){
  637. // let canvas = document.getElementById('textCanvas')
  638. // // let canvas = document.createElement('canvas')
  639. // canvas.width = 320
  640. // canvas.height = 60
  641. // let ctx = canvas.getContext('2d')
  642. // ctx.fillStyle = "#fffff0";
  643. // // // ctx.font = 'normal 24pt "Microsoft Yahei"'
  644. // // // // const name = clientZhou.country[clientZhou.idx].name
  645. // // // ctx.fillText(name, 120, 60)
  646. // // // let textWord = clientZhou.country[clientZhou.idx].description
  647. // ctx.font = 'normal 24pt "Microsoft Yahei"'
  648. // let len = parseInt(textWord.length / 35)
  649. // const offset = (320 - 30*parseInt(textWord.length))/2
  650. // for (let i = 0; i < (len + 1); i++) {
  651. // let space = (320 - 40*parseInt(textWord.length))/2
  652. // if (i === len) {
  653. // space = textWord.length - len * 35
  654. // }
  655. // let word = textWord.substr(i * 20, space)
  656. // ctx.fillText(word, offset, 15+35*(i+1))
  657. // }
  658. // let url = canvas.toDataURL('image/png')
  659. // let texture = new THREE.TextureLoader().load( url);
  660. // const tmaterial = new THREE.SpriteMaterial( {map:texture,transparent : true,opacity:1, side: THREE.DoubleSide} );
  661. // let text_plane2 = new THREE.Sprite( tmaterial );
  662. // text_plane2.scale.set(32,10,1);
  663. // // text_plane.position.set(30,30,30)
  664. // return text_plane2;
  665. // }
  666. function initMenu(){
  667. var menu=document.getElementById("menu");
  668. while (menu.firstChild) {
  669. menu.removeChild(menu.firstChild);
  670. }
  671. let mid = 0
  672. for(let item of house.menuList){
  673. const dpano = document.createElement("div");
  674. dpano.className = 'pano'
  675. // dpano.attr({'data-id':item.id})
  676. for(let i in house.src){
  677. if(house.src[i].id===item.id){
  678. mid = i
  679. break
  680. }
  681. }
  682. dpano.setAttribute('data-id',mid);
  683. const title = document.createElement("div");
  684. title.className = 'title'
  685. title.innerHTML = house.src[mid].title
  686. const thumb = document.createElement("div");
  687. thumb.className = 'thumb'
  688. // thumb.innerHTML = house.src[i].name
  689. const img=document.createElement("img");
  690. img.src= './thumb1k/'+house.src[mid].name + '1k_f.jpg';
  691. thumb.appendChild(img);
  692. dpano.appendChild(title);
  693. dpano.appendChild(thumb);
  694. menu.appendChild(dpano);
  695. }
  696. const ddiv = document.createElement("div");
  697. ddiv.innerHTML='-'
  698. ddiv.className = 'panoEnd'
  699. menu.appendChild(ddiv);
  700. // displayMenuNone()
  701. // house.menu_control_select = 0
  702. // const firstChild = document.getElementById('menu').firstChild
  703. // firstChild.className = 'panoSelect'
  704. // document.getElementById('menu').scrollLeft = 0
  705. }
  706. // function walkingCamera(){
  707. // const d = getCameraDirection()
  708. // walkOn(d)
  709. // }
  710. // function zoomIn(){
  711. // fov = camera.fov + 10
  712. // fov = THREE.MathUtils.clamp(fov, 15, 75);
  713. // if(fov!==camera.fov){
  714. // updateCameraTo(fov)
  715. // }
  716. // }
  717. // function zoomOut(){
  718. // fov = camera.fov - 10
  719. // fov = THREE.MathUtils.clamp(fov, 15, 75);
  720. // if(fov!==camera.fov){
  721. // updateCameraTo(fov)
  722. // }
  723. // }
  724. function displayMenu(){
  725. house.mode = 'menu'
  726. document.getElementById("menu").style.display='flex';
  727. //
  728. // document.getElementById("menuTitle").style.display='flex';
  729. // document.getElementById("menuControl").style.display='flex';
  730. // document.getElementById("wholeDirection").style.display='none';
  731. const control = krpano.get("control");
  732. control.keybaccelerate =0
  733. krpano.set("control",control);
  734. }
  735. function displayMenuNone(){
  736. house.mode = 'full'
  737. document.getElementById("menu").style.display='none';
  738. // document.getElementById("menuTip").style.display='none';
  739. // document.getElementById("menuTitle").style.display='none';
  740. // document.getElementById("menuControl").style.display='none';
  741. // document.getElementById("wholeDirection").style.display='flex';
  742. // document.getElementById("menuTip").style.display='flex';
  743. // setTimeout( function(){
  744. // document.getElementById("menuTip").style.display='none';
  745. // }, 5000 );
  746. // let fov = 75
  747. // camera.fov = fov
  748. // camera.updateProjectionMatrix();
  749. // house.zoom.is_selected = false
  750. // house.zoom.status = 'zoom'
  751. // document.getElementById('zoom').src="./yaoimages/zoomin.png"
  752. // document.getElementById('zoom_title').innerHTML='放大'
  753. const control = krpano.get("control");
  754. control.keybaccelerate =0.5
  755. krpano.set("control",control);
  756. }
  757. // function doubleDelay(doubleCallback,callback,p){
  758. // timeId = setTimeout( function(){
  759. // if(Date.now()-delta<400){
  760. // for(let i in timeIds){
  761. // clearTimeout(timeIds[i])
  762. // }
  763. // // const d = getCameraDirection()
  764. // // walkOn(d)
  765. // if(doubleCallback){
  766. // // doubleCallback()
  767. // }
  768. // }else{
  769. // // lookDirection(2)
  770. // callback(p)
  771. // }
  772. // }, 400 );
  773. // timeIds.push(timeId)
  774. // }
  775. function onKeyDown(e){
  776. // key_down_frequency++
  777. // delta = Date.now()
  778. // if(key_down_frequency>LONG_PRESS_TIMES){
  779. // switch(e.keyCode){
  780. // case 38://ArrowUp
  781. // lat +=1.5
  782. // break
  783. // case 40: //ArrowDown
  784. // lat -=1.5
  785. // break
  786. // case 37: //ArrowLeft
  787. // lon -= 1.5
  788. // break
  789. // case 39://ArrowRight
  790. // lon += 1.5
  791. // break
  792. // case 13://Enter
  793. // house.is_auto_play = true
  794. // break
  795. // default:
  796. // break
  797. // }
  798. // }
  799. }
  800. function setHomePosition(){
  801. // const angle = house.src[house.idx].home.A
  802. const top = house.src[house.idx].home.T
  803. const right = house.src[house.idx].home.R
  804. document.getElementById('cam').style.top = top + 'px';
  805. document.getElementById('cam').style.right = right+ 'px';
  806. // const offset = house.nextId!==null?house.nextId.offset:180
  807. const angle = house.src[house.idx].view.h//+house.src[house.idx].view.offset
  808. document.getElementById('cam').style.transform = 'rotate('+angle+'deg)';
  809. // if(!isAutoPlay){
  810. // updateMapPoint()
  811. // changeSpots()
  812. // }
  813. }
  814. function updateHome(){
  815. if(!house.isLoading){
  816. let angle = house.src[house.idx].view
  817. angle += krpano.get("view.hlookat")
  818. document.getElementById('cam').style.transform = 'rotate('+angle+'deg)';
  819. }
  820. }
  821. function arrowUp(){
  822. if(house.mode==='full'){
  823. // doubleDelay(walkingCamera,lookDirection,2)
  824. }else if(house.mode==='menu'){
  825. }
  826. }
  827. function arrowDown(){
  828. if(house.mode==='full'){
  829. // doubleDelay(null,lookDirection,1)
  830. }else if(house.mode==='menu'){
  831. // const firstChild = document.getElementById('menu').firstChild
  832. // firstChild.className = 'panoSelect'
  833. }
  834. }
  835. function arrowLeft(){
  836. if(house.mode==='full'){
  837. // doubleDelay(zoomIn,lookDirection,3)
  838. }else if(house.mode==='menu'){
  839. let pano_select = -1
  840. const nodess = document.getElementById("menu").childNodes;
  841. for(let i =0;i<nodess.length-1;i++){
  842. if(nodess[i].className==='panoSelect'){
  843. pano_select=i===0?nodess.length -2:i-1
  844. nodess[i].className = 'pano'
  845. nodess[pano_select].className = 'panoSelect'
  846. const fromLeft = document.getElementById('menu').scrollLeft
  847. const toLeft = 270*pano_select;
  848. const coords = {x: fromLeft, y: 0} // Start at (0, 0)
  849. const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
  850. .to({x: toLeft, y: 200}, 1000) // Move to (300, 200) in 1 second.
  851. .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
  852. .onUpdate(() => {
  853. // Called after tween.js updates 'coords'.
  854. // Move 'box' to the position described by 'coords' with a CSS translation.
  855. document.getElementById('menu').scrollLeft = coords.x
  856. })
  857. .start() // Start the tween immediately.
  858. i = nodess.length
  859. }
  860. }
  861. if(pano_select==-1){
  862. for(let i=0;i<house.menuList.length;i++){
  863. if(house.menuList[i].id===house.idx){
  864. pano_select = i
  865. i = house.menuList.length
  866. }
  867. }
  868. if(pano_select==-1){
  869. pano_select=0
  870. }
  871. nodess[pano_select].className = 'panoSelect'
  872. const fromLeft = document.getElementById('menu').scrollLeft
  873. const toLeft = 270*pano_select;
  874. const coords = {x: fromLeft, y: 0} // Start at (0, 0)
  875. const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
  876. .to({x: toLeft, y: 200}, 1000) // Move to (300, 200) in 1 second.
  877. .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
  878. .onUpdate(() => {
  879. // Called after tween.js updates 'coords'.
  880. // Move 'box' to the position described by 'coords' with a CSS translation.
  881. document.getElementById('menu').scrollLeft = coords.x
  882. })
  883. .start() // Start the tween immediately.
  884. }
  885. }
  886. }
  887. function arrowRight(){
  888. if(house.mode==='full'){
  889. // doubleDelay(zoomOut,lookDirection,4)
  890. }else if(house.mode==='menu'){
  891. let pano_select = -1
  892. const nodess = document.getElementById("menu").childNodes;
  893. for(let i =0;i<nodess.length-1;i++){
  894. if(nodess[i].className==='panoSelect'){
  895. pano_select=nodess.length-2===i?0:i+1
  896. // document.getElementById('menu').scrollLeft =270*pano_select;
  897. const fromLeft = document.getElementById('menu').scrollLeft
  898. const toLeft = 270*pano_select;
  899. const coords = {x: fromLeft, y: 0} // Start at (0, 0)
  900. const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
  901. .to({x: toLeft, y: 200}, 1000) // Move to (300, 200) in 1 second.
  902. .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
  903. .onUpdate(() => {
  904. // Called after tween.js updates 'coords'.
  905. // Move 'box' to the position described by 'coords' with a CSS translation.
  906. document.getElementById('menu').scrollLeft = coords.x
  907. })
  908. .start() // Start the tween immediately.
  909. nodess[i].className = 'pano'
  910. nodess[pano_select].className = 'panoSelect'
  911. i = nodess.length
  912. }
  913. }
  914. if(pano_select==-1){
  915. for(let i=0;i<house.menuList.length;i++){
  916. if(house.menuList[i].id===house.idx){
  917. pano_select = i
  918. i = house.menuList.length
  919. }
  920. }
  921. if(pano_select==-1){
  922. pano_select=0
  923. }
  924. nodess[pano_select].className = 'panoSelect'
  925. const fromLeft = document.getElementById('menu').scrollLeft
  926. const toLeft = 270*pano_select;
  927. const coords = {x: fromLeft, y: 0} // Start at (0, 0)
  928. const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
  929. .to({x: toLeft, y: 200}, 1000) // Move to (300, 200) in 1 second.
  930. .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
  931. .onUpdate(() => {
  932. // Called after tween.js updates 'coords'.
  933. // Move 'box' to the position described by 'coords' with a CSS translation.
  934. document.getElementById('menu').scrollLeft = coords.x
  935. })
  936. .start() // Start the tween immediately.
  937. }
  938. }
  939. }
  940. window.onMenuEvent= function(){
  941. changeMode()
  942. // if(house.mode==='full'){
  943. // }else if(house.mode==='menu'){
  944. // }
  945. }
  946. function onKeyUp(e){
  947. // if(key_down_frequency<LONG_PRESS_TIMES){
  948. // switch(e.keyCode){
  949. // case 38://ArrowUp
  950. // arrowUp()
  951. // break
  952. // case 40: //
  953. // arrowDown()
  954. // break
  955. // case 37: //ArrowLeft
  956. // arrowLeft()
  957. // break
  958. // case 39://ArrowRight
  959. // arrowRight()
  960. // break
  961. // case 13://Enter
  962. // // console.log('house.mode',house.mode)
  963. // // enterPano()
  964. // walkingCamera()
  965. // break
  966. // case 48: //0
  967. // directionBack()
  968. // break
  969. // case 49://1
  970. // walkOn('F')
  971. // break
  972. // case 50://2
  973. // walkOn('B')
  974. // break
  975. // case 51://3
  976. // walkOn('L')
  977. // break
  978. // case 52://4
  979. // walkOn('R')
  980. // break
  981. // case 53:
  982. // window.onMenuEvent()
  983. // break
  984. // default:
  985. // break
  986. // }
  987. // }
  988. // key_down_frequency = 0
  989. }
  990. function onWindowResize() {
  991. // camera.aspect = window.innerWidth / window.innerHeight;
  992. // camera.updateProjectionMatrix();
  993. // renderer.setSize(window.innerWidth, window.innerHeight);
  994. }
  995. function onPointerStart(event) {
  996. // isUserInteracting = true;
  997. // if(is_pc){
  998. // // pauseEvent(event)
  999. // }
  1000. // var clientX = event.clientX || event.touches[0].clientX;
  1001. // var clientY = event.clientY || event.touches[0].clientY;
  1002. // onMouseDownMouseX = clientX;
  1003. // onMouseDownMouseY = clientY;
  1004. // onMouseDownLon = lon;
  1005. // onMouseDownLat = lat;
  1006. }
  1007. function onPointerMove(event) {
  1008. // if (isUserInteracting === true) {
  1009. // var clientX = event.clientX || (typeof(event.touches)!=='undefined'?event.touches[0].clientX:0);
  1010. // var clientY = event.clientY || (typeof(event.touches)!=='undefined'?event.touches[0].clientY:0);
  1011. // // lon = (onMouseDownMouseX - clientX) * 0.1 + onMouseDownLon;
  1012. // // lat = (clientY - onMouseDownMouseY) * 0.1 + onMouseDownLat;
  1013. // if(house.mode==='full'){
  1014. // lon = (onMouseDownMouseX - clientX) * 0.075 + onMouseDownLon;
  1015. // lat = (clientY - onMouseDownMouseY) * 0.075 + onMouseDownLat;
  1016. // }else if(house.mode==='menu'){
  1017. // const deltaX = (onMouseDownMouseX - clientX) * 0.031
  1018. // const fromLeft = document.getElementById('menu').scrollLeft
  1019. // const toLeft = fromLeft + deltaX
  1020. // document.getElementById('menu').scrollLeft = toLeft
  1021. // }
  1022. // }
  1023. }
  1024. function onPointerUp() {
  1025. // isUserInteracting = false;
  1026. // mouse.x = ( event.clientX / window.innerWidth ) * 2 - 1;
  1027. // mouse.y = - ( event.clientY / window.innerHeight ) * 2 + 1;
  1028. // onRay()
  1029. }
  1030. function onRay() {
  1031. // update the picking ray with the camera and mouse position
  1032. // raycaster.setFromCamera( mouse, camera );
  1033. // // calculate objects intersecting the picking ray
  1034. // const intersects = raycaster.intersectObjects( scene.children );
  1035. // if(intersects.length>0){
  1036. // // console.log(intersects[0])
  1037. // }
  1038. }
  1039. function onDocumentMouseWheel(event) {
  1040. // var fov = camera.fov + event.deltaY * 0.05;
  1041. // camera.fov = THREE.MathUtils.clamp(fov, 15, 75);
  1042. // camera.updateProjectionMatrix();
  1043. }
  1044. function IsPC(){
  1045. var userAgentInfo = navigator.userAgent;
  1046. var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
  1047. var flag = true;
  1048. for (var v = 0; v < Agents.length; v++) {
  1049. if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }
  1050. }
  1051. return flag;
  1052. }
  1053. //------------------------------------------
  1054. function getCameraDirection(){
  1055. // let min_angle = Math.PI/2
  1056. // let target_name = null
  1057. // const cameraTarget = camera.target.normalize()
  1058. // for(const d in house.direction){
  1059. // const dat = new THREE.Vector3(house.direction[d].at.x,house.direction[d].at.y,house.direction[d].at.z).normalize()
  1060. // const angle = cameraTarget.angleTo(dat)
  1061. // if(min_angle>angle){
  1062. // for(let direct of house.src[house.idx].direction){
  1063. // if(direct.name==house.direction[d].name&&direct.id!=null){
  1064. // min_angle = angle
  1065. // target_name = direct
  1066. // }
  1067. // }
  1068. // }
  1069. // }
  1070. // return target_name
  1071. }
  1072. function walkOn(d){
  1073. // // const arr = ['F','B','L','R']
  1074. // let next_d = d
  1075. // if(typeof(d) == 'string'){
  1076. // for(let dd of house.src[house.idx].direction){
  1077. // if(dd.name===d){
  1078. // next_d = dd
  1079. // break
  1080. // }
  1081. // }
  1082. // }
  1083. // const nextId = next_d
  1084. // if(nextId&&!house.isLoading){
  1085. // const idx = getIdxFromId(nextId.id)
  1086. // // changeTexture(idx)
  1087. // preChangeTexture(idx)
  1088. // }else{
  1089. // moveNull()
  1090. // }
  1091. }
  1092. //------------------------------------------------------
  1093. function preChangeTexture(idx){
  1094. // if(idx>=0){
  1095. // for(let i=spotGroup.children.length-1;i>=0;i--){
  1096. // spotGroup.remove(spotGroup.children[i])
  1097. // }
  1098. // house.numLoaded = 0
  1099. // house.isLoading = true
  1100. // // document.getElementById('tip').style.display = 'flex'
  1101. // preUpdateFaceTexture(idx,'f')
  1102. // preUpdateFaceTexture(idx,'b')
  1103. // preUpdateFaceTexture(idx,'l')
  1104. // preUpdateFaceTexture(idx,'r')
  1105. // preUpdateFaceTexture(idx,'u')
  1106. // preUpdateFaceTexture(idx,'d')
  1107. // }
  1108. }
  1109. function preUpdateFaceTexture(idx, face){
  1110. // const imgPath = house.src[idx].name +"1k_"+face+'.jpg'
  1111. // // load a resource
  1112. // loader.load(
  1113. // // resource URL
  1114. // imgPath,
  1115. // // onLoad callback
  1116. // function ( texture ) {
  1117. // house.numLoaded++
  1118. // updateFaceMaterial(texture,face)
  1119. // if(house.numLoaded===mesh.material.length){
  1120. // house.numLoaded = 0
  1121. // // console.log('sssssssssss')
  1122. // // updateFaceCamera(texture,idx,face)
  1123. // // changeTexture(idx)
  1124. // changeTexture2k(idx)
  1125. // }
  1126. // },
  1127. // // onProgress callback currently not supported
  1128. // undefined,
  1129. // // onError callback
  1130. // function ( err ) {
  1131. // console.error( 'An error happened.' );
  1132. // }
  1133. // );
  1134. }
  1135. function changeTexture2k(idx){
  1136. // for(let i=spotGroup.children.length-1;i>=0;i--){
  1137. // spotGroup.remove(spotGroup.children[i])
  1138. // }
  1139. // house.numLoaded = 0
  1140. // house.isLoading = true
  1141. // // document.getElementById('tip').style.display = 'flex'
  1142. // updateFaceTexture2k(idx,'f')
  1143. // updateFaceTexture2k(idx,'b')
  1144. // updateFaceTexture2k(idx,'l')
  1145. // updateFaceTexture2k(idx,'r')
  1146. // updateFaceTexture2k(idx,'u')
  1147. // updateFaceTexture2k(idx,'d')
  1148. }
  1149. function updateFaceTexture2k(idx, face){
  1150. // const imgPath = house.src[idx].name +"2k_"+face+'.jpg'
  1151. // // load a resource
  1152. // loader.load(
  1153. // // resource URL
  1154. // imgPath,
  1155. // // onLoad callback
  1156. // function ( texture ) {
  1157. // house.numLoaded++
  1158. // updateFaceMaterial(texture,face)
  1159. // if(house.numLoaded===mesh.material.length){
  1160. // house.numLoaded=0
  1161. // // updateFaceCamera(texture,idx,face)
  1162. // changeTexture(idx)
  1163. // }
  1164. // },
  1165. // // onProgress callback currently not supported
  1166. // undefined,
  1167. // // onError callback
  1168. // function ( err ) {
  1169. // console.error( 'An error happened.' );
  1170. // }
  1171. // );
  1172. }
  1173. function changeTexture(idx){
  1174. // for(let i=spotGroup.children.length-1;i>=0;i--){
  1175. // spotGroup.remove(spotGroup.children[i])
  1176. // }
  1177. // house.numLoaded = 0
  1178. // house.isLoading = true
  1179. // // document.getElementById('tip').style.display = 'flex'
  1180. // updateFaceTexture(idx,'f')
  1181. // updateFaceTexture(idx,'b')
  1182. // updateFaceTexture(idx,'l')
  1183. // updateFaceTexture(idx,'r')
  1184. // updateFaceTexture(idx,'u')
  1185. // updateFaceTexture(idx,'d')
  1186. }
  1187. function updateFaceTexture(idx, face){
  1188. // const imgPath = house.src[idx].name +"8k_"+face+'.jpg'
  1189. // // load a resource
  1190. // loader.load(
  1191. // // resource URL
  1192. // imgPath,
  1193. // // onLoad callback
  1194. // function ( texture ) {
  1195. // house.numLoaded++
  1196. // updateFaceMaterial(texture,face)
  1197. // if(house.numLoaded===mesh.material.length){
  1198. // updateFaceCamera(texture,idx,face)
  1199. // }
  1200. // },
  1201. // // onProgress callback currently not supported
  1202. // undefined,
  1203. // // onError callback
  1204. // function ( err ) {
  1205. // console.error( 'An error happened.' );
  1206. // }
  1207. // );
  1208. }
  1209. function updateFaceMaterial(texture,face){
  1210. // for(let i=0;i<mesh.material.length;i++){
  1211. // if(mesh.material[i].name===face){
  1212. // mesh.material[i].map.dispose()
  1213. // mesh.material[i].map = texture
  1214. // mesh.material[i].map.needsUpdate = true;
  1215. // i=mesh.material.length
  1216. // }
  1217. // }
  1218. }
  1219. function updateFaceCamera(texture,idx,face){
  1220. // const coords = {x: camera.fov*35/20, y: lat,z:lon} // Start at (0, 0)
  1221. // const fov = camera.fov
  1222. // lat = house.src[idx].view.lat
  1223. // lon = house.src[idx].view.lon
  1224. // const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
  1225. // .to({x:fov}, 1200) // Move to (300, 200) in 1 second.
  1226. // .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
  1227. // .onUpdate((e,t) => {
  1228. // camera.fov = coords.x
  1229. // camera.updateProjectionMatrix();
  1230. // })
  1231. // .onComplete(()=>{
  1232. // // house.nextId = nextId
  1233. // house.idx = idx
  1234. // camera.fov = THREE.MathUtils.clamp(fov, 15, 75);
  1235. // camera.updateProjectionMatrix();
  1236. // house.isLoading = false
  1237. // updateDirection()
  1238. // })
  1239. // .start() // Start the tween immediately.
  1240. }
  1241. function range360(a){
  1242. while(a>360){
  1243. a -=360
  1244. }
  1245. while(a<0){
  1246. a +=360
  1247. }
  1248. return a
  1249. }
  1250. function defaultCameraFov(){
  1251. // let ilat = range360(lat)
  1252. // let ilon = range360(lon)
  1253. // const coords = {x: camera.fov, y: ilat,z:ilon} // Start at (0, 0)
  1254. // // const fov = 45
  1255. // const fov = 75
  1256. // const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
  1257. // .to({x:fov,y:0,z:0}, 1200) // Move to (300, 200) in 1 second.
  1258. // .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
  1259. // .onUpdate((e,t) => {
  1260. // camera.fov = coords.x
  1261. // camera.updateProjectionMatrix();
  1262. // // lat = coords.y
  1263. // lon = coords.z
  1264. // })
  1265. // .onComplete(()=>{
  1266. // })
  1267. // .start() // Start the tween immediately.
  1268. }
  1269. // ------------- auto update material ------------
  1270. function autoLoadNextTexture(idx,face){
  1271. // const imgPath = house.src[idx].name +"8k_"+face+'.jpg'
  1272. // // load a resource
  1273. // loader.load(
  1274. // // resource URL
  1275. // imgPath,
  1276. // // onLoad callback
  1277. // function ( texture ) {
  1278. // house.numLoaded++
  1279. // updateFaceMaterial(texture,face)
  1280. // if(house.numLoaded===mesh.material.length){
  1281. // house.isLoading = false
  1282. // // document.getElementById('tip').style.display = 'none'
  1283. // lat = house.src[idx].view.lat
  1284. // lon = house.src[idx].view.lon
  1285. // // setHomePosition()
  1286. // updateDirection()
  1287. // }
  1288. // },
  1289. // // onProgress callback currently not supported
  1290. // undefined,
  1291. // // onError callback
  1292. // function ( err ) {
  1293. // console.error( 'An error happened.' );
  1294. // }
  1295. // );
  1296. }
  1297. function autoUpdateMaterial(idx){
  1298. // house.numLoaded = 0
  1299. // house.isLoading = true
  1300. // // document.getElementById('tip').style.display = 'flex'
  1301. // autoLoadNextTexture(idx,'f')
  1302. // autoLoadNextTexture(idx,'b')
  1303. // autoLoadNextTexture(idx,'l')
  1304. // autoLoadNextTexture(idx,'r')
  1305. // autoLoadNextTexture(idx,'u')
  1306. // autoLoadNextTexture(idx,'d')
  1307. }
  1308. function updateCameraTo(fov){
  1309. // const coords = {x: camera.fov, y: 0} // Start at (0, 0)
  1310. // const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
  1311. // .to({x:fov,y:0}, 600) // Move to (300, 200) in 1 second.
  1312. // .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
  1313. // .delay(300)
  1314. // .onUpdate((e,t) => {
  1315. // camera.fov = coords.x
  1316. // camera.updateProjectionMatrix();
  1317. // })
  1318. // .onComplete(()=>{
  1319. // })
  1320. // .start() // Start the tween immediately.
  1321. }
  1322. function moveNull(){
  1323. var fov = Number( krpano.get("view.fov") );
  1324. const t_fov = fov - 5
  1325. const coords= {x:fov}
  1326. const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
  1327. .to({x:t_fov}, 500) // Move to (300, 200) in 1 second.
  1328. .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
  1329. .onUpdate((e,t) => {
  1330. krpano.set("view.fov", coords.x);
  1331. })
  1332. .start() // Start the tween immediately.
  1333. const coords2= {x:t_fov}
  1334. const tween2 = new TWEEN.Tween(coords2) // Create a new tween that modifies 'coords'.
  1335. .to({x:fov}, 500) // Move to (300, 200) in 1 second.
  1336. .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
  1337. .onUpdate((e,t) => {
  1338. krpano.set("view.fov", coords2.x);
  1339. })
  1340. // .start() // Start the tween immediately.
  1341. tween.chain(tween2)
  1342. }
  1343. function lookZoom(z=5,t=600){
  1344. // const fromX = camera.fov
  1345. // const coords = {x: fromX, y: 0} // Start at (0, 0)
  1346. // const toX = camera.fov + z
  1347. // const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
  1348. // .to({x:toX,y:0}, t) // Move to (300, 200) in 1 second.
  1349. // .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
  1350. // .onUpdate((e,t) => {
  1351. // camera.fov = coords.x
  1352. // camera.updateProjectionMatrix();
  1353. // })
  1354. // .start() // Start the tween immediately.
  1355. }
  1356. // direction 1/up 2/down 3/left 4/right
  1357. function lookDirection(d=1){
  1358. // const fromX = d===1||d===2?lat:lon
  1359. // const coords = {x: fromX, y: 0} // Start at (0, 0)
  1360. // const toX = d===1?lat-house.config.lat_step:d===2?lat+house.config.lat_step:d===3?lon-house.config.lon_step:lon+house.config.lon_step
  1361. // const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
  1362. // .to({x:toX,y:0}, 600) // Move to (300, 200) in 1 second.
  1363. // .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
  1364. // .onUpdate((e,t) => {
  1365. // if(d===1||d===2){
  1366. // lat = coords.x
  1367. // }else{
  1368. // lon = coords.x
  1369. // }
  1370. // })
  1371. // .start() // Start the tween immediately.
  1372. }
  1373. function updateMapPoint(){
  1374. // const idx = house.idx
  1375. // let id = -1
  1376. // var points=document.getElementById("redPoints");
  1377. // while (points.firstChild) {
  1378. // points.removeChild(points.firstChild);
  1379. // }
  1380. // // points.remove();
  1381. // if(house.src[idx].D1){
  1382. // id = house.src[idx].D1.id - 1
  1383. // createMapPoint(id)
  1384. // }
  1385. // if(house.src[idx].D2){
  1386. // id = house.src[idx].D2.id - 1
  1387. // createMapPoint(id)
  1388. // }
  1389. // if(house.src[idx].D3){
  1390. // id = house.src[idx].D3.id - 1
  1391. // createMapPoint(id)
  1392. // }
  1393. // if(house.src[idx].D4){
  1394. // id = house.src[idx].D4.id - 1
  1395. // createMapPoint(id)
  1396. // }
  1397. }
  1398. function createMapPoint(id){
  1399. // const top = house.src[id].home.T
  1400. // const right = house.src[id].home.D2
  1401. // const img=document.createElement("img");
  1402. // img.src="panos/redPoint.png";
  1403. // img.style.position = 'absolute'
  1404. // img.style.top = top +15+ 'px';
  1405. // img.style.right = right-5+ 'px';
  1406. // img.style.width = 8+ 'px';
  1407. // img.style.height = 8+ 'px';
  1408. // const points=document.getElementById("redPoints");
  1409. // points.appendChild(img);
  1410. }
  1411. function getIdxFromId(id){
  1412. let idx = -1
  1413. for(const item in house.src){
  1414. if(house.src[item].id===id){
  1415. idx = item
  1416. break
  1417. }
  1418. }
  1419. return idx
  1420. }
  1421. function animate() {
  1422. requestAnimationFrame(animate);
  1423. // updateHome()
  1424. TWEEN.update()
  1425. // update();
  1426. }
  1427. function update() {
  1428. // // controls.update();
  1429. // if (isUserInteracting === false) {
  1430. // // lon += 0.1;
  1431. // }
  1432. // if(house.is_auto_play){
  1433. // // if(lon>360&&!house.texture.isloading){
  1434. // if(lon>360&&!house.isloading){
  1435. // lon = 0
  1436. // // house.idx++
  1437. // // if(house.idx>=house.src.length){
  1438. // // house.idx = 0
  1439. // // }
  1440. // house.playList.idx++
  1441. // if(house.playList.idx>=house.playList.orders.length){
  1442. // house.playList.idx = 0
  1443. // }
  1444. // for(let i in house.src){
  1445. // if(house.src[i].id===house.playList.orders[house.playList.idx].id){
  1446. // house.idx = i
  1447. // break
  1448. // }
  1449. // }
  1450. // // house.idx = house.playList.orders[house.playList.idx].id-1
  1451. // autoUpdateMaterial(house.idx)
  1452. // }else{
  1453. // lon += 0.2;
  1454. // }
  1455. // }
  1456. // lat = Math.max(-85, Math.min(85, lat));
  1457. // phi = THREE.MathUtils.degToRad(90 - lat);
  1458. // theta = THREE.MathUtils.degToRad(lon);
  1459. // camera.target.x = 512 * Math.sin(phi) * Math.cos(theta);
  1460. // camera.target.y = 512 * Math.cos(phi);
  1461. // camera.target.z = 512 * Math.sin(phi) * Math.sin(theta);
  1462. // // updateHome()
  1463. // camera.lookAt(camera.target);
  1464. // renderer.render(scene, camera);
  1465. }
  1466. window.onBackEvent= function(){
  1467. }
  1468. var btn = new tvSysBtnBind({
  1469. id: "Jdoc",
  1470. className: "ctrlBtn",
  1471. currentClass: "current",
  1472. keyRemoveDefault: false,
  1473. effect: "base",
  1474. currentIndex: 0,
  1475. onLoad: function(e) {
  1476. // console.log(e);
  1477. },
  1478. onPress:function() {
  1479. var keyCode = this.event.keyCode;
  1480. // console.log('keyCode:'+keyCode)
  1481. switch (keyCode) {
  1482. case 37: // left
  1483. // reloadData();
  1484. arrowLeft()
  1485. break;
  1486. case 39: // right
  1487. arrowRight()
  1488. break;
  1489. case 38: //up
  1490. arrowUp()
  1491. break;
  1492. case 40: //down
  1493. arrowDown()
  1494. break;
  1495. // case 13: //enter
  1496. // break;
  1497. case 33: //chanel +
  1498. break;
  1499. case 34: //chanel -
  1500. break;
  1501. case 48: //0
  1502. // console.log('ddddd')
  1503. // displayMenu()
  1504. break;
  1505. case 49://1
  1506. walkingOn('F')
  1507. break
  1508. case 50://2
  1509. walkingOn('B')
  1510. break
  1511. case 51://3
  1512. walkingOn('L')
  1513. break
  1514. case 52://4
  1515. walkingOn('R')
  1516. break;
  1517. case 53: //5
  1518. const hlookat = krpano.get("view.hlookat")
  1519. const vlookat = krpano.get("view.vlookat")
  1520. // console.log(',ath:',hlookat,',atv:',vlookat)
  1521. // var hotspotID = krpano.get('hotspot[spot1].atv');
  1522. // var hotspotID = krpano.get('hotspot');
  1523. // console.log(hotspotID);
  1524. break;
  1525. case 54: //6
  1526. walkingDirection()
  1527. break;
  1528. case 55: //7
  1529. break;
  1530. case 57: //9
  1531. changeMode()
  1532. break;
  1533. default:
  1534. break;
  1535. }
  1536. },
  1537. onEnterPress: function() {
  1538. changeMode()
  1539. },
  1540. onBack: function() {
  1541. if(house.is_auto_play){
  1542. house.is_auto_play = false
  1543. }else{
  1544. if(house.mode==='menu'){
  1545. displayMenuNone()
  1546. }else{
  1547. // window.location.href="index2.html?id="+house.idx
  1548. const url = "index.html?id="+house.idx +"&backurl="+house.backurl
  1549. window.location.href = url
  1550. // VrBrowserToJS.vrBrowerExit()
  1551. }
  1552. }
  1553. }
  1554. });
  1555. //----------------------------------------------
  1556. function makeZoom(tfov){
  1557. var fov = Number( krpano.get("view.fov") );
  1558. const t_fov = tfov
  1559. // krpano.set("view.fov", fov);
  1560. console.log('fov',fov,'tfov',tfov)
  1561. const coords= {x:fov}
  1562. const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
  1563. .to({x:t_fov}, 500) // Move to (300, 200) in 1 second.
  1564. .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
  1565. .onUpdate((e,t) => {
  1566. // camera.fov = coords.x
  1567. // camera.updateProjectionMatrix();
  1568. krpano.set("view.fov", coords.x);
  1569. })
  1570. .onComplete(()=>{
  1571. })
  1572. .start() // Start the tween immediately.
  1573. }
  1574. // function zoomOut(){
  1575. // makeZoom(75)
  1576. // }
  1577. // function zoomIn(){
  1578. // makeZoom(30)
  1579. // }
  1580. function makeRotationAuto(is_auto){
  1581. krpano.set('autorotate.enabled',is_auto)
  1582. }
  1583. function changeScene(scene_name){
  1584. // krpano.call("loadscene('scene_gushu',null,MERGE,BLEND(1));");
  1585. krpano.call("loadscene("+scene_name+",null,MERGE,BLEND(1));");
  1586. updateDirection()
  1587. setHomePosition()
  1588. }
  1589. function changeMode(){
  1590. // krpano.call("stopmovements();");
  1591. // krpano.call("stoplookto();");
  1592. // console.log('menuMode')
  1593. // house.mode = 'menu'
  1594. if(house.mode==='full'){
  1595. fullMode()
  1596. }else{
  1597. menuMode()
  1598. }
  1599. }
  1600. function menuMode(){
  1601. if(house.mode=='menu'){
  1602. // if(house.menu_control_select==0||house.menu_control_select == -1){
  1603. displayMenuNone()
  1604. let pano_select = -1
  1605. const nodess = document.getElementById("menu").childNodes;
  1606. for(let i =0;i<nodess.length;i++){
  1607. if(nodess[i].className==='panoSelect'){
  1608. pano_select=nodess[i].getAttribute('data-id')
  1609. i = nodess.length
  1610. house.idx = pano_select
  1611. }
  1612. }
  1613. const scene_name = 'scene_'+house.src[house.idx].name
  1614. changeScene(scene_name)
  1615. const ath = house.src[house.idx].ath
  1616. const atv = house.src[house.idx].atv
  1617. krpano.call('lookat('+ath+','+atv+')')
  1618. // }else if(house.menu_control_select==1){ // zoom
  1619. // let zoom_title = 0
  1620. // let zoom_image = 0
  1621. // switch(house.zoom.status){
  1622. // case 'zoom':
  1623. // zoom_title = '放大'
  1624. // house.zoom.status = 'x0.9'
  1625. // house.zoom.direction = 1
  1626. // house.zoom.factor = 1 // 1.5
  1627. // zoom_image="./yaoimages/zoomin.png"
  1628. // house.menu_control_select=0
  1629. // break
  1630. // case 'x0.9':
  1631. // zoom_title = 'x1'
  1632. // house.zoom.status = 'x1'
  1633. // house.zoom.direction = 1
  1634. // house.zoom.factor = 1 // 1.5
  1635. // zoom_image="./yaoimages/zoomin_click.png"
  1636. // break
  1637. // case 'x1':
  1638. // zoom_title = 'x1.5'
  1639. // house.zoom.status = 'x1.5'
  1640. // house.zoom.direction = 1
  1641. // house.zoom.factor = 1.5 // 1.5
  1642. // zoom_image="./yaoimages/zoomin_click.png"
  1643. // break
  1644. // case 'x1.5':
  1645. // zoom_title = 'x2'
  1646. // house.zoom.status = 'x2'
  1647. // house.zoom.direction = 1
  1648. // house.zoom.factor = 2
  1649. // house.zoom.is_selected = false // 1
  1650. // zoom_image="./yaoimages/zoomout_click.png"
  1651. // break
  1652. // case 'x2':
  1653. // zoom_title = 'x1.5'
  1654. // house.zoom.status = 'x-1.5'
  1655. // house.zoom.direction = -1
  1656. // house.zoom.factor = 1.5
  1657. // house.zoom.is_selected = false // 1
  1658. // zoom_image="./yaoimages/zoomout_click.png"
  1659. // break
  1660. // case 'x-1.5':
  1661. // zoom_title = 'x1'
  1662. // house.zoom.status = 'zoom'
  1663. // house.zoom.direction = -1
  1664. // house.zoom.factor = 1
  1665. // house.zoom.is_selected = false // 1
  1666. // zoom_image="./yaoimages/zoomout_click.png"
  1667. // break
  1668. // case 'x-1':
  1669. // zoom_title = 'zoom'
  1670. // house.zoom.status = 'zoom'
  1671. // house.zoom.direction = 0
  1672. // house.zoom.factor = 1
  1673. // house.zoom.is_selected = false // 1
  1674. // zoom_image="./yaoimages/zoomout_click.png"
  1675. // break
  1676. // default:
  1677. // break
  1678. // }
  1679. // document.getElementById('zoom_title').innerHTML=zoom_title
  1680. // document.getElementById('zoom').src=zoom_image
  1681. // let fov = house.zoom.factor==1?120:house.zoom.factor==2?30:75
  1682. // console.log('fov',fov)
  1683. // makeZoom(fov)
  1684. // // // let fov = 75 - house.zoom.factor * house.zoom.step
  1685. // // // console.log('factor',house.zoom.factor, 'step',house.zoom.step,'fov',fov)
  1686. // // fov = THREE.MathUtils.clamp(fov, 15, 75);
  1687. // // camera.fov = fov
  1688. // // camera.updateProjectionMatrix();
  1689. // }else if(house.menu_control_select==2){ //rotation
  1690. // displayMenuNone()
  1691. // house.is_auto_play = true
  1692. // house.menu_control_select=0
  1693. // makeRotationAuto(true)
  1694. // // house.menu_control_select=0
  1695. // }else{
  1696. // // displayMenuNone()
  1697. // }
  1698. }
  1699. }
  1700. function fullMode(){
  1701. if(house.is_auto_play){
  1702. house.is_auto_play = false
  1703. if(house.rotation.is_auto==true){
  1704. house.rotation.is_auto==false
  1705. document.getElementById('auto_rotation').src="./yaoimages/auto_rotation.png"
  1706. }
  1707. makeRotationAuto(false)
  1708. }
  1709. const nodess = document.getElementById("menu").childNodes;
  1710. for(let i =0;i<nodess.length-1;i++){
  1711. if(nodess[i].getAttribute('data-id')==house.idx){
  1712. // pano_select=i===0?nodess.length -2:i-1
  1713. // nodess[i].className = 'pano'
  1714. nodess[i].className = 'panoSelect'
  1715. // document.getElementById('menu').scrollLeft = 270*i;
  1716. const fromLeft = document.getElementById('menu').scrollLeft
  1717. const toLeft = 270*i;
  1718. const coords = {x: fromLeft, y: 0} // Start at (0, 0)
  1719. const tween = new TWEEN.Tween(coords) // Create a new tween that modifies 'coords'.
  1720. .to({x: toLeft, y: 200}, 1000) // Move to (300, 200) in 1 second.
  1721. .easing(TWEEN.Easing.Quadratic.Out) // Use an easing function to make the animation smooth.
  1722. .onUpdate(() => {
  1723. // Called after tween.js updates 'coords'.
  1724. // Move 'box' to the position described by 'coords' with a CSS translation.
  1725. document.getElementById('menu').scrollLeft = coords.x
  1726. })
  1727. .start() // Start the tween immediately.
  1728. // i = nodess.length
  1729. } else{
  1730. nodess[i].className = 'pano'
  1731. }
  1732. }
  1733. displayMenu()
  1734. // doubleDelay(defaultCameraFov,displayMenu,null)
  1735. }
  1736. function updateDirection(){
  1737. // for(let d of house.src[house.idx].direction){
  1738. // switch(d.name){
  1739. // case 'F':
  1740. // if(d.id!=null){
  1741. // document.getElementById("directionTop").innerHTML = house.src[d.id-1].title
  1742. // // document.getElementById("directionTop").style.visibility = true
  1743. // document.getElementById("direct_top").style.color = '#ffffff'
  1744. // document.getElementById("direct_top_img").src = './yaoimages/direction_top.png'
  1745. // }else{
  1746. // document.getElementById("directionTop").innerHTML = ''
  1747. // // document.getElementById("directionTop").style.visibility = false
  1748. // document.getElementById("direct_top").style.color = '#c1c1c1'
  1749. // document.getElementById("direct_top_img").src = './yaoimages/direction_top_disable.png'
  1750. // }
  1751. // break
  1752. // case 'B':
  1753. // if(d.id!=null){
  1754. // document.getElementById("directionLeft").innerHTML = house.src[d.id-1].title
  1755. // document.getElementById("direct_left").style.color = '#ffffff'
  1756. // document.getElementById("direct_left_img").src = './yaoimages/direction_left.png'
  1757. // }else{
  1758. // document.getElementById("directionLeft").innerHTML = ''
  1759. // document.getElementById("direct_left").style.color = '#c1c1c1'
  1760. // document.getElementById("direct_left_img").src = './yaoimages/direction_left_disable.png'
  1761. // }
  1762. // break
  1763. // case 'L':
  1764. // if(d.id!=null){
  1765. // document.getElementById("directionBottom").innerHTML = house.src[d.id-1].title
  1766. // document.getElementById("direct_bottom").style.color = '#ffffff'
  1767. // document.getElementById("direct_bottom_img").src = './yaoimages/direction_bottom.png'
  1768. // }else{
  1769. // document.getElementById("directionBottom").innerHTML = ''
  1770. // document.getElementById("direct_bottom").style.color = '#c1c1c1'
  1771. // document.getElementById("direct_bottom_img").src = './yaoimages/direction_bottom_disable.png'
  1772. // }
  1773. // break
  1774. // case 'R':
  1775. // if(d.id!=null){
  1776. // document.getElementById("directionRight").innerHTML = house.src[d.id-1].title
  1777. // document.getElementById("direct_right").style.color = '#ffffff'
  1778. // document.getElementById("direct_right_img").src = './yaoimages/direction_right.png'
  1779. // }else{
  1780. // document.getElementById("directionRight").innerHTML = ''
  1781. // document.getElementById("direct_right").style.color = '#c1c1c1'
  1782. // document.getElementById("direct_right_img").src = './yaoimages/direction_right_disable.png'
  1783. // }
  1784. // break
  1785. // default:
  1786. // break
  1787. // }
  1788. // }
  1789. // // }
  1790. // changeSpots()
  1791. }
  1792. function compareAngle(angle_1,angle_2){
  1793. let max_a = Math.max(angle_1,angle_2)
  1794. let min_a = Math.min(angle_1,angle_2)
  1795. let theta = max_a-min_a>180?(360-max_a)-min_a:max_a-min_a
  1796. return theta
  1797. }
  1798. function getCameraDirection(){
  1799. const hlookat = range360(krpano.get("view.hlookat"))
  1800. // const vlookat = range360(krpano.get("view.vlookat"))
  1801. const spots = house.src[house.idx].spots
  1802. let min_dis = 100000
  1803. let min_spot = null
  1804. for(let spot of spots){
  1805. const name = spot.name
  1806. var hotspot = krpano.get('hotspot['+name+']');
  1807. const spot_h = range360(hotspot.ath*1)
  1808. // const spot_v = range360(hotspot.atv*1)
  1809. const theta = compareAngle(hlookat,spot_h)
  1810. const distance = Math.pow(theta, 2)
  1811. if(min_dis>distance){
  1812. min_dis = distance
  1813. min_spot = hotspot
  1814. min_spot.wath = spot.ath
  1815. min_spot.watv = spot.atv
  1816. }
  1817. }
  1818. return min_spot
  1819. }
  1820. function walkingDirection(){
  1821. const spot = getCameraDirection()
  1822. if(spot){
  1823. const scene_name = spot.linkedscene
  1824. for(let g of house.src){
  1825. if(scene_name.indexOf(g.name.toLowerCase())>=0){
  1826. house.idx = g.id - 1
  1827. }
  1828. }
  1829. //
  1830. changeScene(scene_name)
  1831. const ath = spot.wath
  1832. const atv = spot.watv
  1833. krpano.call('lookat('+ath+','+atv+')')
  1834. }else{
  1835. console.log('no walking')
  1836. moveNull()
  1837. }
  1838. }
  1839. function walkingOn(d){
  1840. let next_d = d
  1841. if(typeof(d) == 'string'){
  1842. for(let dd of house.src[house.idx].direction){
  1843. if(dd.name===d){
  1844. next_d = dd
  1845. break
  1846. }
  1847. }
  1848. }
  1849. if(next_d&&typeof(next_d.id)!='undefined'&&next_d.id){
  1850. house.idx = next_d.id - 1
  1851. const scene_name = 'scene_' + house.src[house.idx].name
  1852. changeScene(scene_name)
  1853. const ath = house.src[house.idx].ath
  1854. const atv = house.src[house.idx].atv
  1855. krpano.call('lookat('+ath+','+atv+')')
  1856. }else{
  1857. console.log('no walking')
  1858. moveNull()
  1859. }
  1860. }