manage.js 90 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615
  1. var g_ProjectName=window.location.pathname.substring(window.location.pathname.indexOf("/")+1,window.location.pathname.lastIndexOf("/"));
  2. var g_Prefix="https://super.4dage.com/";
  3. // var g_Prefix=window.location.href.substring(0,window.location.href.indexOf("/index.html")+1);
  4. var s = window.location.href.split('/');
  5. s.pop();
  6. //var g_Prefix = s.join('/');
  7. var g_index=null;
  8. var g_modeldata=null;
  9. var g_weixinTitle=null;
  10. var g_Hots=null;
  11. var g_HotMeshes=[];
  12. var g_HotMeshSize = {
  13. g_HotMeshWidth: 0.3,
  14. g_HotMeshHeight:0.3
  15. };
  16. //add表示添加,delete表示删除
  17. var g_HotStatus=null;
  18. var g_newHot = [];//存储新加热点
  19. var g_HotImage= {
  20. "point":"https://super.4dage.com/images/4dagePoint2.png",
  21. "point2":"https://super.4dage.com/images/4dagePoint.png"
  22. };
  23. var g_saveHot=false;
  24. var g_TextColor=0x7777ff;
  25. var g_Text=null;
  26. var g_TextPlaneMesh=[];
  27. var g_TextIconMesh=[];
  28. var g_TextIcon="./images/text.png";
  29. var g_SelectTextIndex=null;
  30. var g_TextShow=null;
  31. var g_audioPlay=false;
  32. var g_background=null;
  33. var g_roof=null;
  34. var g_data2 = null;//加载的data2.js的内容
  35. var g_bgAudio=null;//背景音乐
  36. var g_tourAudio=null;//导览音乐
  37. var g_play = 1;//表示播放图标状态
  38. var g_playAudio = null;//当前在播放或当继续播放时应该播放的,是g_bgAudio或g_tourAudio
  39. var g_currentHot = null;//当前打开的热点
  40. //var g_Texture=null;
  41. //var g_ChunknameTexture={}; //chunkname和贴图名称对应
  42. var g_NormalTexture=false;
  43. var g_SpecularTexture=false;
  44. var g_DirectionalLight=null;
  45. var g_snapShotWidth = 200; //截图下载图片的大小
  46. var g_snapShotHeight = 140;
  47. //微信分享
  48. var g_weixinObj = {
  49. "title": document.querySelector("head title").innerHTML,
  50. "lineLink" : window.location.href,
  51. "imgUrl" : "https://www.4dmodel.com/SuperPanoramic/images/weixintitle.jpg",
  52. "desc" : "四维时代提供技术支持",
  53. }
  54. window.browser = { //提前定义
  55. isMobile: function() {
  56. var e = navigator.userAgent || navigator.vendor || window.opera;
  57. return /(android|bb\d+|meego).+mobile|android|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od|ad)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(e) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0, 4))
  58. },
  59. isFullscreen: function() {
  60. return document.fullscreenElement || document.mozFullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement
  61. },
  62. valueFromHash: function(e, t) {
  63. var i = new RegExp("[#&?]" + e + "=([^#&?]*)")
  64. , n = i.exec(window.location.href);
  65. if (!n)
  66. return t;
  67. var r = n[1];
  68. return "boolean" == typeof t ? "true" === r || "1" === r : "number" == typeof t ? parseFloat(r) : window.decodeURIComponent(r)
  69. },
  70. urlHasValue: function(key, isGetValue) {
  71. let querys = window.location.search.substr(1).split("&")
  72. if (isGetValue) {
  73. for (let i = 0; i < querys.length; i++) {
  74. let keypair = querys[i].split("=")
  75. if (keypair.length === 2 && keypair[0] === key) {
  76. return keypair[1]
  77. }
  78. }
  79. return ""
  80. } else {
  81. for (let i = 0; i < querys.length; i++) {
  82. let keypair = querys[i].split("=")
  83. if (keypair[0] == key) {
  84. return true
  85. }
  86. }
  87. return false
  88. }
  89. },
  90. }
  91. var settings = {
  92. hotClickEvent:{
  93. video:{
  94. playAndPause:true,
  95. examine:false,
  96. openHot:false
  97. },
  98. photo:{
  99. examine:false,
  100. openHot:false
  101. },
  102. shine:{
  103. examine:true,
  104. openHot:true
  105. }
  106. },
  107. hotClickActions:['playAndPause','examine','openHot','fastTran'],
  108. markerHeight: 0.05,//距离地板高出多少,
  109. //默认的:
  110. teleportTime: 1500,//瞬间过渡的时间
  111. /* flytimeDistanceMultiplier:150,
  112. flyTime:750, */
  113. tourRotTime:2, //默认停留2秒
  114. //dontExamHot:true,
  115. hotFastTran:false,
  116. transparentBg: false,
  117. bgImg: null,
  118. tileClass:{//默认全景贴图加载的清晰度
  119. pc:{
  120. nav: '4k',
  121. max: '4k',
  122. },
  123. bigMobile:{ //width和height都超过一定值
  124. nav: '2k',
  125. max: '4k',//'2k',
  126. },
  127. mobile:{
  128. nav: '2k', //不放大时
  129. max: '4k', //放大最大
  130. }
  131. }, //可以稍后自行修改
  132. extractFloor : { //提取一部分chunk作为新的floor,该floor不在楼层列表里显示,一般用于飞出后隐藏屋顶
  133. 'KJ-t-tHpdpKvb0ew' : [1,2,3,4,5,6,7,8], //第0层的第1,2,3个chunk是屋顶
  134. }
  135. }
  136. if(window.number == '725'||window.number == '724'){
  137. //settings.mobileNavHigh = true
  138. settings.tileClass.mobile = {nav:'2k', max: '2k'}
  139. }
  140. //共用函数:
  141. window.common = null;
  142. window.MathLight = null;
  143. window.math = null
  144. window.easing = null
  145. window.lerp = null
  146. window.transitions = null
  147. function watch(object, propName, initialValue){ //监听某个属性的变化
  148. let v = initialValue
  149. Object.defineProperty(object, propName, {
  150. get: function() {
  151. return v
  152. },
  153. set: function(e) {
  154. console.log('watch:',propName, e)
  155. v = e
  156. }
  157. })
  158. }
  159. var toPrecision = function(e, t) {
  160. function i(e, t) {
  161. var i = Math.pow(10, t);
  162. return Math.round(e * i) / i
  163. }
  164. if (e instanceof Array) {
  165. for (var n = 0; n < e.length; n++)
  166. e[n] = i(e[n], t);
  167. return e
  168. }
  169. return i(e, t)
  170. }
  171. var dealMap = (map, o={} )=>{
  172. //使不resize when image is not power of two ,但缩小时会有锯齿
  173. if(!o.ignoreResize){
  174. if(!map.image || !THREE.Math.isPowerOfTwo(map.image.width ) || !THREE.Math.isPowerOfTwo(map.image.height )){
  175. map.wrapS = map.wrapT = THREE.ClampToEdgeWrapping;
  176. map.minFilter = THREE.LinearFilter;
  177. //map.generateMipmaps = true;
  178. }
  179. }
  180. if(!browser.isMobile()) map.anisotropy = 3
  181. }
  182. var dom = {
  183. getOffset: function(type, element, parent) {
  184. left = (type == "left") ? element.offsetLeft : element.offsetTop;
  185. if (!parent) parent = $("body")[0];
  186. while (element = element.offsetParent) {
  187. if (element == parent) break;
  188. left += (type == "left") ? element.offsetLeft : element.offsetTop;
  189. }
  190. return left;
  191. }
  192. };
  193. var getTransformSid = function(){
  194. var name
  195. if(player.mode == 'panorama'){
  196. name = player.currentPano ? player.currentPano.id : 'outside'
  197. }else{
  198. name = 'outside'
  199. }
  200. return name
  201. }
  202. var LineDraw = {
  203. /* createLine: function(posArr, o) {
  204. var e = new THREE.BufferGeometry
  205. , p = new Float32Array(6);
  206. e.addAttribute("position", new THREE.BufferAttribute(p,3));
  207. //这句新旧版写法不同 旧版这样:e.addAttribute("position",Float32Array,2,3);
  208. var p = e.attributes.position.array;
  209. for (var i = 0; i < 2; i++) {
  210. p[i * 3] = posArr[i].x;
  211. p[i * 3 + 1] = posArr[i].y;
  212. p[i * 3 + 2] = posArr[i].z;
  213. }
  214. var mat = new THREE[o.deshed ? "LineDashedMaterial" : "LineBasicMaterial"]({
  215. linewidth: o.width || 1,
  216. //windows无效。 似乎mac/ios上粗细有效 ?
  217. color: o.color || defaultColor,
  218. transparent: o.dontAlwaysSeen ? false : true,
  219. depthTest: o.dontAlwaysSeen ? true : false
  220. })
  221. var line = new THREE.Line(e,mat);
  222. line.renderOrder = o.renderOrder || 4
  223. //同tagStem; //如果不加高,可能会部分被model遮住
  224. return line;
  225. } */
  226. createLine: function (posArr, o={}) {
  227. //多段普通线 (第二个点和第三个点之间是没有线段的, 所以不用在意线段顺序)
  228. var mat
  229. if(o.mat){
  230. mat = o.mat
  231. }else{
  232. let prop = {
  233. color: o.color || defaultColor,
  234. transparent: o.dontAlwaysSeen ? false : true,
  235. depthTest: o.dontAlwaysSeen ? true : false,
  236. opacity: o.opacity != void 0 ? o.opacity : 1,
  237. }
  238. if(o.deshed ){
  239. prop.dashSize = o.dashSize || 0.1,
  240. prop.gapSize = o.gapSize || 0.1
  241. }
  242. mat = new THREE[o.deshed ? "LineDashedMaterial" : "LineBasicMaterial"](prop)
  243. }
  244. var line = new THREE.LineSegments(new THREE.BufferGeometry, mat);
  245. line.renderOrder = o.renderOrder || 4
  246. this.moveLine(line, posArr)
  247. return line;
  248. },
  249. moveLine: function (line, posArr) {
  250. if(posArr.length == 0)return
  251. let position = new Float32Array(posArr.length * 3); //[]
  252. for (var i = 0; i < 2; i++) {
  253. position[i * 3] = posArr[i].x;
  254. position[i * 3 + 1] = posArr[i].y;
  255. position[i * 3 + 2] = posArr[i].z;
  256. }
  257. line.geometry.addAttribute("position", new THREE.BufferAttribute(position,3));
  258. //line.geometry.setAttribute('position', new THREE.Float32BufferAttribute(new Float32Array(position), 3));
  259. line.geometry.attributes.position.needsUpdate = true;
  260. line.geometry.computeBoundingSphere();
  261. /* if(line.material instanceof THREE.LineDashedMaterial){
  262. line.computeLineDistances() //只有非buffer的geometry才有
  263. } */
  264. }
  265. ,
  266. }
  267. var convertTool = {
  268. getPos2d : function(point, camera, dom){//获取一个三维坐标对应屏幕中的二维坐标
  269. var camera = camera || player.camera;
  270. var dom = dom || player.domElement;
  271. if(!camera)return
  272. var pos = point.clone().project(camera) //比之前hotspot的计算方式写得简单 project用于3转2(求法同shader); unproject用于2转3 :new r.Vector3(e.x, e.y, -1).unproject(this.camera);
  273. var x,y;
  274. x = (pos.x + 1) / 2 * dom.clientWidth;
  275. y = (1 - (pos.y + 1) / 2) * dom.clientHeight;
  276. var inSight = x <= dom.clientWidth && x >= 0 //是否在屏幕中
  277. && y <= dom.clientHeight && y >= 0
  278. return {
  279. pos: new THREE.Vector2(x,y), // 屏幕像素坐标
  280. vector: pos, //(范围 -1 ~ 1)
  281. trueSide : pos.z<1, //trueSide为false时,即使在屏幕范围内可见,也是反方向的另一个不可以被渲染的点 参见Tag.update
  282. inSight : inSight //在屏幕范围内可见
  283. };
  284. },
  285. ifShelter: function (pos3d, pos2d, camera, floorIndex) {
  286. //检测某点在视线中是否被mesh遮挡
  287. if (!pos2d) pos2d = convertTool.getPos2d(pos3d )
  288. camera = camera || player.camera
  289. var ori = new THREE.Vector3(pos2d.x, pos2d.y, -1).unproject(camera) //找到视线原点
  290. var dir = pos3d.clone().sub(ori).normalize()
  291. var ray = new THREE.Raycaster(ori, dir); //由外向里 因为模型从内侧是可见的所以从外侧
  292. /* if(config.isEdit && publicObjectSet.editor.mainDesign.editing){
  293. var o = ray.intersectObjects(publicObjectSet.editor.mainDesign.wallMeshes);
  294. }else{ */
  295. let colliders = player.model.allFloorsVisible ? player.model.colliders : (floorIndex != void 0 ? player.model.floors.index[floorIndex] : player.model.currentFloor).collider.children
  296. //let colliders = (floorIndex == void 0 ) ? player.model.colliders : player.model.floors.index[floorIndex].collider.children
  297. var o = ray.intersectObjects(colliders);
  298. //}
  299. var len = pos3d.distanceTo(ori);
  300. if (o && o.length) {
  301. for(var i=0;i<o.length;i++){
  302. if(o[i].distance < len){ return true; }//有遮挡
  303. }
  304. }
  305. },
  306. /*
  307. 拖拽时,获取鼠标在拖拽面上的位置(需要借助另一个intersectPlane面来计算,即和相机方向一样的面,可保证铺满屏幕)
  308. 但是不一定能获取到,比如鼠标射线不朝向拖拽面时,即使获取也会是一个意外的反方向的交点。
  309. */
  310. getPosAtPlane : function(pos, info/* , mouse, camera */){ //pos:与intersectPlane的交点 见笔记
  311. var A = pos;
  312. var player = player;
  313. var mouse = player.mouse;
  314. var O = new THREE.Vector3(mouse.x, mouse.y, -1).unproject(player.camera);
  315. if(info.y != void 0){//地面线的
  316. var y = info.y;
  317. if(player.mode == "floorplan"/* || Math.abs(O.x-pos.x)<0.0001 && Math.abs(O.z-pos.z)<0.0001) */){
  318. //intersectPlane和地面平行,无交点
  319. var x = pos.x, z = pos.z;
  320. }else{
  321. if(y<player.camera.position.y && O.y <= A.y /* || y>player.camera.position.y && O.y >= A.y */)return null; //鼠标射线向上。因为相机一定位于地面以上(地面不会抬高到相机上吧?),所以无交点。
  322. if(O.y == A.y){console.log('一样??');return;}
  323. if(A.y == y){console.log('一样2??');return;}
  324. var r = (O.y-y)/(A.y-y);
  325. var x = (r*A.x-O.x)/(r-1);
  326. var z = (r*A.z-O.z)/(r-1);
  327. }
  328. }else{//垂直的也有越过消失点以后反向变化的情况,但使用时影响不大
  329. var N = info.normalVec;
  330. var P = info.pullPos;
  331. if(N.y != 0 ){console.log('N.y != 0');return;} //仅仅支持垂直于地面的的墙壁,目前都是
  332. if(O.z==A.z){console.log('O.z==A.z?');return;}
  333. if(N.z!=0 && N.x != 0){//直接用这个通用的也可以,支持斜线的墙
  334. //console.log('N.z==0 && N.x == 0?');
  335. var c = ( N.x*(A.x-O.x) + N.y*(A.y-O.y) + N.z*(A.z-O.z));
  336. if(c == 0){console.log("分母为0?? return;");return;}
  337. var t = -((N.x*O.x + N.y*O.y + N.z*O.z) - (P.x*N.x + P.y*N.y + P.z*N.z) ) / c
  338. var x = t * (A.x - O.x) + O.x;
  339. var y = t * (A.y - O.y) + O.y;
  340. var z = t * (A.z - O.z) + O.z;
  341. /*原理: 已知空间直线L:(x-a)/m=(x-b)/n=(z-c)/p和空间平面π:Ax+By+Cz+D=0;
  342. 求直线L与平面π的交点的坐标。
  343. 把直线方程改写成参数形式:设(x-a)/m=(x-b)/n=(z-c)/p=t;
  344. 则x=mt+a;y=nt+b;z=pt+c;代入平面π的方程得:
  345. A(mt+a)+B(nt+b)+C(pt+c)+D=0
  346. 由此解得t=-(Aa+Bb+Cc+D)/(Am+Bn+Cp)
  347. 再代入参数方程即得交点的坐标(x,y,z). */
  348. }else if(N.x ==0 ){ //z与pullPos相等
  349. var z = P.z;
  350. if(O.y == A.y){console.log('一样??');return;}
  351. if(A.y == y){console.log('一样2??');return;}
  352. if(A.z == z){console.log('一样3??');return;}
  353. var r = (O.z-z)/(A.z-z);
  354. var x = (r*A.x-O.x)/(r-1);
  355. var y = (r*A.y-O.y)/(r-1);
  356. }else if(N.z == 0){//x与pullPos相等
  357. var x = P.x;
  358. if(O.y == A.y){console.log('一样??');return;}
  359. if(A.y == y){console.log('一样2??');return;}
  360. if(A.x == x){console.log('一样3??');return;}
  361. var r = (O.x-x)/(A.x-x);
  362. var y = (r*A.y-O.y)/(r-1);
  363. var z = (r*A.z-O.z)/(r-1);
  364. }
  365. }
  366. return new THREE.Vector3(x,y,z);
  367. },
  368. getMouseIntersect : function(camera, meshes, mouse){//获取鼠标和meshes交点
  369. var raycaster = new THREE.Raycaster;
  370. camera.updateMatrixWorld();
  371. var origin = new THREE.Vector3(mouse.x,mouse.y,-1).unproject(camera)
  372. , end = new THREE.Vector3(mouse.x,mouse.y,1).unproject(camera);
  373. var dir = end.sub(origin).normalize()
  374. raycaster.set(origin, dir);
  375. var n = raycaster.intersectObjects(meshes);
  376. if (0 === n.length)
  377. return null;
  378. return n[0];
  379. },
  380. ifIntersectChunks : function(A,B,options={}){//获取某个线段/射线和meshes的交点
  381. var dir = B.clone().sub(A).normalize();
  382. var len = options.InfinityLen ? Infinity : A.distanceTo(B) + (options.extLen||0);
  383. var ray = new THREE.Raycaster(A.clone(), dir, 0, len);
  384. var o = ray.intersectObjects(options.model || player.model.colliders);
  385. if (o && o.length)return o;
  386. if(options.throughWidth){ //允许最小宽度,防止穿过极小的缝隙导致撞墙感
  387. var normal = math.getNormal({points:[{x:A.x, y:A.z},{x:B.x, y:B.z}]});//线段法线
  388. normal.multiplyScalar(options.throughWidth)
  389. var normalVec3 = new THREE.Vector3(normal.x, 0, normal.y);
  390. var A2 = A.clone().add(normalVec3)
  391. ray.set(A2, dir);
  392. var o2 = ray.intersectObjects(options.model || player.model.colliders);
  393. ray.set(A.clone().add(normalVec3.negate()), dir);
  394. if (o2 && o2.length)return o2;
  395. var o3 = ray.intersectObjects(options.model || player.model.colliders);
  396. if (o3 && o3.length)return o3;
  397. }
  398. return null;
  399. },
  400. getPosAtSphere : function(pos3d, toPanoPos){
  401. var dir = pos3d.clone().sub(toPanoPos);
  402. dir.normalize();//然后计算在球中
  403. dir.multiplyScalar(Constants.skyRadius);
  404. dir.add(toPanoPos);
  405. return dir;
  406. } ,
  407. getScaleForConstantSize : function(op={}){ //获得规定二维大小的mesh的scale值。可以避免因camera的projection造成的mesh视觉大小改变。 来源:tag.updateDisc
  408. var w;
  409. var i = new THREE.Vector3, o = new THREE.Vector3, l = new THREE.Vector3, c = new THREE.Vector3, h = new THREE.Vector3
  410. if(!op.resolution){
  411. let renderSize = player.sceneRenderer.renderer.getSize()
  412. op.resolution = {x:renderSize.width, y:renderSize.height}
  413. }
  414. if(!op.camera){
  415. let camera = player.cameraControls.activeControl ? player.cameraControls.activeControl.camera : player.camera
  416. let camera2 = camera.clone();
  417. camera2.matrixWorld.copy(player.camera.matrixWorld) //因为其他原因该camera的matrixWorld被还原了,而player.camera的是正确的
  418. op.camera = camera2
  419. }
  420. if(op.width2d) w = op.width2d //如果恒定二维宽度
  421. else{//否则考虑上距离,加一丢丢近大远小的效果
  422. var currentDis, nearBound, farBound
  423. if(op.camera.type == "OrthographicCamera"){
  424. currentDis = (op.camera.right - op.camera.left) / op.camera.zoom
  425. }else{
  426. currentDis = op.position.distanceTo(op.camera.position);
  427. }
  428. w = op.maxSize - ( op.maxSize - op.minSize) * THREE.Math.smoothstep(currentDis, op.nearBound, op.farBound);
  429. //maxSize : mesh要表现的最大像素宽度; nearBound: 最近距离,若比nearBound近,则使用maxSize
  430. }
  431. i.copy(op.position).project(op.camera), //tag中心在屏幕上的二维坐标
  432. o.set(op.resolution.x / 2, op.resolution.y / 2, 1).multiply(i), //转化成px -w/2 到 w/2的范围
  433. l.set(w / 2, 0, 0).add(o), //加上tag宽度的一半
  434. c.set(2 / op.resolution.x, 2 / op.resolution.y, 1).multiply(l), //再转回 -1 到 1的范围
  435. h.copy(c).unproject(op.camera);//再转成三维坐标,求得tag边缘的位置
  436. var g = h.distanceTo(op.position)//就能得到tag的三维半径
  437. return g //可能NAN 当相机和position重叠时
  438. } ,
  439. updateVisible : function(object, reason, ifShow, level=0, type){//当所有加入的条件都不为false时才显示. reason='force'一般是强制、临时的
  440. if(!object.unvisibleReasons) object.unvisibleReasons = []; //如果length>0代表不可见
  441. if(!object.visibleReasons) object.visibleReasons = []; //在同级时,优先可见
  442. var update = function(){
  443. //先按从高到低的level排列
  444. object.unvisibleReasons = object.unvisibleReasons.sort((a,b)=>b.level-a.level)
  445. object.visibleReasons = object.visibleReasons.sort((a,b)=>b.level-a.level)
  446. var maxVisiLevel = object.visibleReasons[0] ? object.visibleReasons[0].level : -1
  447. var maxunVisiLevel = object.unvisibleReasons[0] ? object.unvisibleReasons[0].level : -1
  448. var shouldVisi = maxVisiLevel >= maxunVisiLevel
  449. var visiBefore = object.visible
  450. if(visiBefore != shouldVisi){
  451. object.visible = shouldVisi
  452. object.dispatchEvent({
  453. type: 'isVisible',
  454. visible: shouldVisi,
  455. reason,
  456. })
  457. }
  458. }
  459. if(ifShow){
  460. var index = object.unvisibleReasons.findIndex(e=>e.reason == reason)
  461. if(index > -1){
  462. type = 'cancel'
  463. object.unvisibleReasons.splice(index, 1);
  464. }
  465. if(type == 'add' ){
  466. if(!object.visibleReasons.some(e=>e.reason == reason)){
  467. object.visibleReasons.push({reason,level})
  468. }
  469. }
  470. }else{
  471. var index = object.visibleReasons.findIndex(e=>e.reason == reason)
  472. if(index > -1){
  473. type = 'cancel'
  474. object.visibleReasons.splice(index, 1);
  475. }
  476. if(type != 'cancel' ){
  477. if(!object.unvisibleReasons.some(e=>e.reason == reason)){
  478. object.unvisibleReasons.push({reason,level})
  479. }
  480. }
  481. }
  482. update()
  483. },
  484. getObjVisiByReason : function(object,reason){//获取在某条件下是否可见. 注: 用户在数据集选择可不可见为"datasetSelection"
  485. if(object.visible)return true
  486. else{
  487. return !object.unvisibleReasons || !object.unvisibleReasons.some(e=>e.reason == reason)
  488. }
  489. }
  490. }
  491. window.expandCommon = function(common){
  492. Object.assign(common,{
  493. intervalTool : { //延时update,防止卡顿
  494. list:[],
  495. isWaiting:function(name, func, delayTime/* , autoCycle */){
  496. let item = this.list.find(e=>e.name == name);
  497. if(!item){ //如果没有该项, 则加入循环
  498. let ifContinue = func();
  499. item = {name, func, delayTime};
  500. this.list.push(item);
  501. setTimeout(()=>{
  502. var a = this.list.indexOf(item);
  503. this.list.splice(a,1);
  504. let {func, delayTime} = item;
  505. if(item.requestUpdate || ifContinue ) this.isWaiting(name, func, delayTime); //循环
  506. },delayTime);
  507. }else {//如果有该项,说明现在请求下一次继续更新
  508. //更新属性
  509. item.func = func;
  510. item.delayTime = delayTime;
  511. item.requestUpdate = true;
  512. }
  513. },
  514. },
  515. sortByScore : function(list, request, rank) {
  516. var i = request ? common.filterAll(list, request) : list
  517. return 0 === i.length ? null : i = i.map(function(e) {
  518. let scores = rank.map(function(f){return f(e)}) //add
  519. return {
  520. item: e,
  521. scores,
  522. score: scores.reduce(function(t, i) {
  523. return t + i
  524. }, 0)
  525. }
  526. }).sort(function(e, t) {
  527. return t.score - e.score;
  528. })
  529. },
  530. getVisiblePano : function(positions = [], panos, options={}){//add
  531. var visiblePanos = [];
  532. options.posAtPanos = options.posAtPanos || {}//在不同漫游点的positions
  533. panos.forEach((pano)=>{
  534. if(!pano.isAligned())return;
  535. var A = pano.position.clone();
  536. var posB = options.posAtPanos[pano.id] || positions;
  537. var posLength = posB.length
  538. for(let i=0;i<posLength;i++){
  539. var B = posB[i];
  540. var ray = new THREE.Raycaster(A.clone(), B.clone().sub(A).normalize(), 0, A.distanceTo(B) - (options.tolerance||0) )
  541. var o = ray.intersectObjects(options.model || player.model.colliders, true);
  542. if (!o || !o.length){ //只要有一点可见,就算整体可见
  543. visiblePanos.push(pano.id);
  544. break;
  545. }
  546. }
  547. })
  548. return visiblePanos
  549. } ,
  550. realVisible : function (object) {
  551. var v = true;
  552. var parent = object;
  553. var lastParent;
  554. while (parent) {
  555. if (parent.visible === false) {
  556. v = false;
  557. break
  558. }
  559. lastParent = parent;
  560. parent = parent.parent;
  561. }
  562. if (v && !(lastParent instanceof THREE.Scene)) {
  563. //已被删除
  564. v = false;
  565. }
  566. return v
  567. }
  568. })
  569. }
  570. window.expandMath = function(math){
  571. Object.assign(math,{
  572. linearClamp(value, xArr, yArr) {
  573. if (arguments.length == 5) {
  574. xArr = [arguments[1], arguments[2]]
  575. yArr = [arguments[3], arguments[4]]
  576. }
  577. let len = xArr.length
  578. if (value <= xArr[0]) return yArr[0]
  579. if (value >= xArr[len - 1]) return yArr[len - 1]
  580. let i = 0
  581. while (++i < len) {
  582. if (value < xArr[i]) {
  583. let x1 = xArr[i - 1],
  584. x2 = xArr[i],
  585. y1 = yArr[i - 1],
  586. y2 = yArr[i]
  587. value = y1 + ((y2 - y1) * (value - x1)) / (x2 - x1)
  588. break
  589. }
  590. }
  591. return value
  592. },
  593. getBaseLog(x, y) {//返回以 x 为底 y 的对数(即 logx y) . Math.log 返回一个数的自然对数
  594. return Math.log(y) / Math.log(x);
  595. },
  596. getSpreadRatio(n){//n为整数,返回的0-1的数。 目的是获得较为平均的数字,主要用于颜色hue。数字含义:按顺序将1不停平分下去,每刀都切在每段的二分之一处,则第n刀在原先整体的几分之几处
  597. if(n==0)return 0
  598. let k = Math.floor(math.getBaseLog(2,n)) //是2的几次幂
  599. let r = ((n - Math.pow(2,k) ) * 2 + 1)/ Math.pow(2,k+1)
  600. console.log('getSpreadRatio',n,r)
  601. return r
  602. }
  603. })
  604. }
  605. //--------------------------------------
  606. //管理js文件 获取modeldata.js 判断是否有特殊的字段,如果有就先加载SpecialScene.js 里面有对特殊场景处理的代码 否则就直接加载main
  607. var Manage = function(){
  608. this.weixinURL = "https://res.wx.qq.com/open/js/jweixin-1.2.0.js",
  609. this.time = "?"+new Date().getTime();
  610. this.loadAudio();
  611. this.loadWeixin();
  612. }
  613. //动态加载js文件
  614. Manage.prototype.LoadJs = function(_files, succes){
  615. /* 已加载文件缓存列表,用于判断文件是否已加载过,若已加载则不再次加载*/
  616. var classcodes = [];
  617. var FileArray = [];
  618. if (typeof _files === "object") {
  619. FileArray = _files;
  620. } else {
  621. /*如果文件列表是字符串,则用,切分成数组*/
  622. if (typeof _files === "string") {
  623. FileArray = _files.split(",");
  624. }
  625. }
  626. if (FileArray != null && FileArray.length > 0) {
  627. var LoadedCount = 0;
  628. for (var i = 0; i < FileArray.length; i++) {
  629. loadFile(FileArray[i], function() {
  630. LoadedCount++;
  631. if (LoadedCount == FileArray.length) {
  632. try {
  633. succes();
  634. }
  635. catch(err) {
  636. console.log("err: 您未定义回调");
  637. }
  638. }
  639. })
  640. }
  641. }
  642. /*加载JS文件,url:文件路径,success:加载成功回调函数*/
  643. function loadFile(url, success) {
  644. if (!FileIsExt(classcodes, url)) {
  645. var _ThisType = GetFileType(url);
  646. var ThisType = _ThisType.indexOf("?") == -1 ? _ThisType : _ThisType.substring(0,_ThisType.indexOf("?"));
  647. var fileObj = null;
  648. if (ThisType == ".js") {
  649. fileObj = document.createElement('script');
  650. fileObj.src = url;
  651. } else if (ThisType == ".css") {
  652. fileObj = document.createElement('link');
  653. fileObj.href = url;
  654. fileObj.type = "text/css";
  655. fileObj.rel = "stylesheet";
  656. } else if (ThisType == ".less") {
  657. fileObj = document.createElement('link');
  658. fileObj.href = url;
  659. fileObj.type = "text/css";
  660. fileObj.rel = "stylesheet/less";
  661. }
  662. success = success || function() {};
  663. fileObj.onload = fileObj.onreadystatechange = function() {
  664. if (!this.readyState || 'loaded' === this.readyState || 'complete' === this.readyState) {
  665. success();
  666. classcodes.push(url)
  667. }
  668. }
  669. document.getElementsByTagName('head')[0].appendChild(fileObj);
  670. } else {
  671. success();
  672. }
  673. }
  674. /*获取文件类型,后缀名,小写*/
  675. function GetFileType(url) {
  676. if (url != null && url.length > 0) {
  677. return url.substr(url.lastIndexOf(".")).toLowerCase();
  678. }
  679. return "";
  680. }
  681. /*文件是否已加载*/
  682. function FileIsExt(FileArray, _url) {
  683. if (FileArray != null && FileArray.length > 0) {
  684. var len = FileArray.length;
  685. for (var i = 0; i < len; i++) {
  686. if (FileArray[i] == _url) {
  687. return true;
  688. }
  689. }
  690. }
  691. return false;
  692. }
  693. };
  694. //获取页面url后面的参数
  695. Manage.prototype.number = function(variable) {
  696. var query = window.location.search.substring(1);
  697. var vars = query.split("&");
  698. for (var i=0;i<vars.length;i++) {
  699. var pair = vars[i].split("=");
  700. if(pair[0] == variable){return pair[1];}
  701. }
  702. return(false);
  703. };
  704. Manage.prototype.loadWeixin = function() {
  705. var that = this;
  706. this.LoadJs(that.weixinURL+that.time,function(){ });
  707. }
  708. Manage.prototype.weixinShare = function() {
  709. console.log("weixinShare")
  710. $.ajax({
  711. url:'https://www.4dage.com/wechat/jssdk/',
  712. type: "post",
  713. data : {
  714. 'url' : location.href.split('#')[0]
  715. },
  716. dataType:"jsonp",
  717. jsonpCallback:"success_jsonp",
  718. success:function(data,textStatus){
  719. console.log("weixinShare success")
  720. console.log(data.appId)
  721. wx.config({
  722. // debug : true,
  723. appId : data.appId,
  724. timestamp : data.timestamp,
  725. nonceStr : data.nonceStr,
  726. signature : data.signature,
  727. jsApiList : [ 'checkJsApi', 'onMenuShareTimeline',
  728. 'onMenuShareAppMessage', 'onMenuShareQQ',
  729. 'onMenuShareWeibo', 'hideMenuItems',
  730. 'showMenuItems', 'hideAllNonBaseMenuItem',
  731. 'showAllNonBaseMenuItem', 'translateVoice',
  732. 'startRecord', 'stopRecord', 'onRecordEnd',
  733. 'playVoice', 'pauseVoice', 'stopVoice',
  734. 'uploadVoice', 'downloadVoice', 'chooseImage',
  735. 'previewImage', 'uploadImage', 'downloadImage',
  736. 'getNetworkType', 'openLocation', 'getLocation',
  737. 'hideOptionMenu', 'showOptionMenu', 'closeWindow',
  738. 'scanQRCode', 'chooseWXPay',
  739. 'openProductSpecificView', 'addCard', 'chooseCard',
  740. 'openCard' ]
  741. });
  742. },
  743. error:function(XMLHttpRequest,textStatus,errorThrown){
  744. console.log("jsonp.error:"+textStatus);
  745. }
  746. });
  747. var success_jsonp = function(json){
  748. console.log(json);
  749. };
  750. wx.ready(function(){
  751. // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行〿
  752. //对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中〿
  753. //分享到朋友圈
  754. console.log(g_weixinObj)
  755. wx.onMenuShareTimeline({
  756. title: g_weixinObj.title, // 分享标题
  757. link: g_weixinObj.lineLink, // 分享链接
  758. imgUrl: g_weixinObj.imgUrl, // 分享图标
  759. desc: g_weixinObj.desc
  760. });
  761. //获取“分享给朋友”按钮点击状态及自定义分享内容接叿
  762. wx.onMenuShareAppMessage({
  763. title: g_weixinObj.title, // 分享标题
  764. desc: g_weixinObj.desc, // 分享描述
  765. link: g_weixinObj.lineLink, // 分享链接
  766. imgUrl: g_weixinObj.imgUrl, // 分享图标
  767. type: '', // 分享类型,music、video或link,不填默认为link
  768. dataUrl: '' // 如果type是music或video,则要提供数据链接,默认为空
  769. });
  770. wx.onMenuShareWeibo({
  771. title: g_weixinObj.title, // 分享标题
  772. desc: g_weixinObj.desc, // 分享描述
  773. link: g_weixinObj.lineLink, // 分享链接
  774. imgUrl: g_weixinObj.imgUrl, // 分享图标
  775. success: function () {
  776. // 用户确认分享后执行的回调函数
  777. },
  778. cancel: function () {
  779. // 用户取消分享后执行的回调函数
  780. }
  781. });
  782. wx.onMenuShareQZone({
  783. title: g_weixinObj.title, // 分享标题
  784. desc: g_weixinObj.desc, // 分享描述
  785. link: g_weixinObj.lineLink, // 分享链接
  786. imgUrl: g_weixinObj.imgUrl, // 分享图标
  787. success: function () {
  788. // 用户确认分享后执行的回调函数
  789. },
  790. cancel: function () {
  791. // 用户取消分享后执行的回调函数
  792. }
  793. });
  794. wx.onMenuShareQQ({
  795. title: g_weixinObj.title, // 分享标题
  796. desc: g_weixinObj.desc, // 分享描述
  797. link: g_weixinObj.lineLink, // 分享链接
  798. imgUrl: g_weixinObj.imgUrl, // 分享图标
  799. success: function () {
  800. // 用户确认分享后执行的回调函数
  801. },
  802. cancel: function () {
  803. // 用户取消分享后执行的回调函数
  804. }
  805. });
  806. wx.error(function(res){
  807. // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名〿
  808. });
  809. });
  810. }
  811. Manage.prototype.dealURL = function(src, type){
  812. //music: "///super.4dage.com/data/LYW/edit/20200928_151633415.mp3"
  813. //"https://super.4dage.com/data/LYW/edit/20200928_165319399.jpg"]
  814. if(window.isLocal && settings.localPrefix!=void 0){//本地将线上的前缀替换
  815. var oldPrefix = 'super.4dage.com/'; //最简单的地址写一个,如果有其他完全不一样的地址就用数组逐个判断
  816. var index = src.indexOf(oldPrefix);
  817. if(index>-1){
  818. var wholeOldPrefix = src.slice(0, index+oldPrefix.length);
  819. return src.replace(wholeOldPrefix, settings.localPrefix)
  820. }else console.error("没有找到合适的本地链接")
  821. return src
  822. }else{
  823. //add https://
  824. var prefix = g_Prefix.replace('https://','').replace('http://','')
  825. if(!src.includes('http:/') && !src.includes('https:/') && src.includes(prefix)){
  826. src = 'https://'+src
  827. }
  828. return src
  829. }
  830. }
  831. Manage.prototype.removeSrcPostMark = function(url){//去除texture.load时自动加上的'?'
  832. var index = url.indexOf('?')
  833. if(index>-1){
  834. return url.slice(0, index)
  835. }else return url
  836. }
  837. Manage.prototype.showInfo = function (o) { // ({result:true, title:"发布成功"});
  838. var box = $(".resultBox");
  839. var title = o.title || o || i18n.get('保存成功');
  840. box.children().eq(0).html(title)
  841. //var time = o.time || THREE.Math.clamp((Config.lang=='en') ? title.length*50 : title.length*130 ,1300,5000);
  842. var time = o.time || THREE.Math.clamp(title.length*130 ,1300, 5000);
  843. o.time || console.log("showtime " + time)
  844. //实际有一半的时间在渐变透明度
  845. this.showInfoTimer && clearTimeout(this.showInfoTimer)
  846. box.removeClass("animate");//如果之后不久又要showinfo一个的话,先停止前面的animate
  847. setTimeout(function () {
  848. box.css(
  849. {
  850. '-webkit-animation-duration': time + 'ms',
  851. 'animation-duration': time + 'ms'
  852. }
  853. )
  854. if(o.top){
  855. box.children().css('top', o.top + "%");
  856. }else{
  857. box.children().css('top', '' )
  858. }
  859. box.removeClass("hide");
  860. box.addClass("animate");
  861. if (o.dontInteract) {//遮挡对屏幕的操作
  862. box.css('pointer-events', 'auto')
  863. } else {
  864. box.css('pointer-events', 'none')
  865. }
  866. this.showInfoTimer = setTimeout(function () {
  867. box.removeClass("animate");
  868. box.addClass("hide");
  869. this.showInfoTimer = null;
  870. }.bind(this), time + 20)
  871. }.bind(this), 50)//这个数字太小的话后面触发的没有重新animate的效果 应该要比帧率大吧
  872. }//like: manage.showInfo({title:'a', top:20})
  873. //公用的函数
  874. function getQueryVariable(variable)
  875. {
  876. var query = window.location.search.substring(1);
  877. var vars = query.split("&");
  878. for (var i=0;i<vars.length;i++) {
  879. var pair = vars[i].split("=");
  880. if(pair[0] == variable){return pair[1];}
  881. }
  882. return(false);
  883. }
  884. //隐藏公司Logo
  885. function showLogo(){
  886. $("#myCompany").hide();
  887. $("#loaderCoBrandName").hide();
  888. $("#title-logo").hide();
  889. $(".title-container").css("justify-content","center")
  890. }
  891. //czj 添加随机的时间
  892. function randomTime(){
  893. return new Date()
  894. }
  895. function matcher(data){
  896. if(!data || !g_version ) return data;
  897. delete data.model.vision_version;
  898. var _data = {
  899. files: {
  900. "templates": ["images/images{{number}}/{{filename}}"]
  901. },
  902. model :{
  903. sid :window.number,
  904. camera_start:
  905. data.model.images && data.model.images.length != 0 ?
  906. {
  907. camera: {
  908. zoom: "-1",
  909. quaternion: [
  910. JSON.parse(data.model.images[0].metadata).camera_quaternion.z,
  911. JSON.parse(data.model.images[0].metadata).camera_quaternion.w,
  912. JSON.parse(data.model.images[0].metadata).camera_quaternion.x,
  913. JSON.parse(data.model.images[0].metadata).camera_quaternion.y
  914. ]
  915. },
  916. pano: { uuid: JSON.parse(data.model.images[0].metadata).scan_id },
  917. mode: "0"
  918. }
  919. : ''
  920. },
  921. sid: window.number,
  922. hoticon: {
  923. default: "https://super.4dage.com/images/4dagePoint2.png",
  924. higt: "https://super.4dage.com/images/4dagePoint.png"
  925. },
  926. special: "false",
  927. weixinDesc: ""
  928. };
  929. $.extend(true,data,_data)
  930. return data;
  931. }
  932. function hotMatcher(data={}){
  933. //if(!data || !g_version) return data;
  934. if(g_version) {
  935. data.tourAudio = data.audio || {};
  936. }else{
  937. data.tourAudio = {}
  938. }
  939. return data;
  940. }
  941. var GifTexDeal = {
  942. animateObjects : [],
  943. animateTexs : [] ,
  944. addAnimation : function(texture, owner, info, id){
  945. /* if(this.animateObjects.find(e=>
  946. e.texture == texture && !ifSame(info, e.info)
  947. )) */
  948. var animation
  949. var tex = this.animateTexs.find(e=>e.texture == texture)
  950. if(tex){
  951. animation = tex
  952. }else{
  953. animation = {texture,info }
  954. this.animateTexs.push(animation)
  955. this.setRepeart(animation)
  956. }
  957. var object = {
  958. animation, //默认相同的texture对应的info是一样的, 对应一个animation
  959. owner,
  960. }
  961. this.animateObjects.push(object)
  962. return object
  963. },
  964. remove : function(object){
  965. var index = this.animateObjects.indexOf(object)
  966. if(index>-1){
  967. this.animateObjects.splice(index, 1)
  968. if(!this.animateObjects.find(e=>e.animation == object.animation)){
  969. let i = this.animateTexs.indexOf(object.animation)
  970. this.animateTexs.splice(i, 1)
  971. object.animation.texture.repeat.set(1,1)
  972. }
  973. this.stop(object)
  974. }
  975. },
  976. setRepeart : function(animation){
  977. animation.texture.repeat.set(1/animation.info.cellXcount, 1/animation.info.cellYcount)
  978. },
  979. start: function(object){
  980. if(!object || object.started )return;
  981. object.started = true
  982. if(object.animation.started)return;
  983. object.animation.started = true
  984. var info = object.animation.info
  985. var count = info.cellXcount * info.cellYcount - (info.voidCount || 0)
  986. if(count <= 1)return;
  987. transitions.start( (progress)=>{
  988. var index = Math.floor((count-1) * progress);
  989. var indexX = index % info.cellXcount
  990. var indexY = info.cellYcount - Math.floor(index /info.cellXcount ) - 1; //uv.offset.y是从下到上的
  991. object.animation.texture.offset.x = indexX / info.cellXcount;
  992. object.animation.texture.offset.y = indexY / info.cellYcount;
  993. //console.log(object.id + " : "+ object.texture.offset.toArray())
  994. } , info.duration * (-1), null,/* ()=>{//done (-1):循环
  995. object.started = false
  996. object.texture.offset.x = 0;
  997. object.texture.offset.y = 0;
  998. this.start(object)
  999. }, */ 0 ,null, object.id, "gif_"+object.animation.texture.id);
  1000. },
  1001. stop: function(object){
  1002. if(!object || !object.started)return;
  1003. object.started = false
  1004. //只有该object对应的texture对应的所有object都停止了,才能真的停止动画:
  1005. if(this.animateObjects.find(e=>e.animation == object.animation && e.started)) return;
  1006. transitions.cancelById("gif_"+object.animation.texture.id);
  1007. object.animation.texture.offset.set(0,0)
  1008. object.animation.started = false
  1009. }
  1010. }
  1011. var CloneObject = function(copyObj, result, isSimpleCopy, extraReplace) {
  1012. //isSimpleCopy只复制最外层
  1013. //复制json result的可能:普通数字或字符串、普通数组、复杂对象
  1014. if(!copyObj)return copyObj //0 null undefined ''
  1015. result = result || {};
  1016. if (copyObj instanceof Array) {
  1017. /* if (copyObj[0]instanceof Object) {
  1018. //不支持含有 [[Object]] 这样二级数组里面还是复杂数据的,普通和复杂的数据混合可能也不支持
  1019. console.error("不支持含有 [[Object]] 这样二级数组里面还是复杂数据的...")
  1020. }
  1021. return copyObj.slice(0);*/ //如果是数组,直接复制返回(排除数组内是object
  1022. return copyObj.map(e=>{
  1023. if(e instanceof Object){
  1024. return CloneObject(e)
  1025. }else return e
  1026. })
  1027. }else{
  1028. if(copyObj.clone instanceof Function ){ //解决一部分
  1029. return copyObj.clone()
  1030. }
  1031. }
  1032. for (var key in copyObj) {
  1033. if (copyObj[key] instanceof Object && !isSimpleCopy)
  1034. result[key] = CloneObject(copyObj[key]);
  1035. else
  1036. result[key] = copyObj[key];
  1037. //如果是函数类同基本数据,即复制引用
  1038. }
  1039. return result;
  1040. }
  1041. ;
  1042. var ifSame = function(object1, object2){
  1043. if(object1 == object2 )return true // 0 != undefined , 0 == ''
  1044. else if(!object1 || !object2) return false
  1045. else if(object1.constructor != object2.constructor){
  1046. return false
  1047. }else if(object1 instanceof Array ) {
  1048. if(object1.length != object2.length)return false;
  1049. var _object2 = object2.slice(0);
  1050. for(let i=0;i<object1.length;i++){
  1051. var u = _object2.find(e=>ifSame(object1[i], e));
  1052. if(u == void 0 && !_object2.includes(u) && !object1.includes(u))return false;
  1053. else{
  1054. let index = _object2.indexOf(u);
  1055. _object2.splice(index,1);
  1056. }
  1057. }
  1058. return true
  1059. }else if(object1.equals instanceof Function ){//复杂数据仅支持这种,其他的可能卡住?
  1060. return object1.equals(object2)
  1061. }else if(typeof object1 == 'number' || typeof object1 == 'string'){
  1062. if(isNaN(object1) && isNaN(object2))return true
  1063. else return object1 == object2
  1064. }else if(typeof object1 == "object"){
  1065. var keys1 = Object.keys(object1)
  1066. var keys2 = Object.keys(object2)
  1067. if(!ifSame(keys1,keys2))return false;
  1068. for(let i in object1){
  1069. var same = ifSame(object1[i], object2[i]);
  1070. if(!same)return false
  1071. }
  1072. return true
  1073. }else{
  1074. console.log('isSame出现例外')
  1075. }
  1076. }
  1077. function initByTHREE(THREE){
  1078. window.bus = new THREE.EventDispatcher();//因为player一开始总是没创建好,所以加一个事件传递器
  1079. THREE.TransitionPass = function ( scene, camera ) {
  1080. this.renderScene = scene;
  1081. this.renderCamera = camera;
  1082. this.coverRenderTarget = new THREE.WebGLRenderTarget( 100, 100, {
  1083. minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter,
  1084. format: THREE.RGBAFormat
  1085. });
  1086. this.coverTex = this.coverRenderTarget.texture;
  1087. this.enabled = false;
  1088. this.oldClearColor = new THREE.Color();
  1089. this.oldClearAlpha = 1;
  1090. this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
  1091. this.scene = new THREE.Scene();
  1092. this.material = this.getMaskMaterial()
  1093. var copyShader = THREE.CopyShader;
  1094. this.materialCopy = new THREE.ShaderMaterial( {
  1095. uniforms: this.copyUniforms,
  1096. vertexShader: copyShader.vertexShader,
  1097. fragmentShader: copyShader.fragmentShader,
  1098. blending: THREE.NoBlending,
  1099. depthTest: false,
  1100. depthWrite: false,
  1101. transparent: true
  1102. } );
  1103. this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), this.material);
  1104. this.quad.frustumCulled = false; // Avoid getting clipped
  1105. this.scene.add( this.quad );
  1106. }
  1107. THREE.TransitionPass.prototype = {//波形扩散,出下一个画面
  1108. constructor: THREE.TransitionPass,
  1109. setSize: function ( width, height ) {
  1110. this.coverRenderTarget.setSize( width, height );
  1111. },
  1112. render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
  1113. var oldAutoClear = renderer.autoClear;
  1114. renderer.autoClear = false;
  1115. var uniforms = this.quad.material.uniforms
  1116. uniforms.bgTex.value = readBuffer.texture; //更新
  1117. uniforms.coverTex.value = this.coverTex;
  1118. uniforms.progress.value = player.model.skybox.material.uniforms.progress.value//
  1119. uniforms.screenRatio.value = player.domElement.clientWidth / player.domElement.clientHeight;// 使波纹为圆形
  1120. uniforms.screenRatio.value *= uniforms.screenRatio.value
  1121. renderer.render( this.scene, this.camera);
  1122. renderer.autoClear = oldAutoClear;
  1123. },
  1124. start:function(sceneRenderer){
  1125. this.enabled = true
  1126. //draw coverTex
  1127. this.quad.material.uniforms.progress.value = 1;
  1128. sceneRenderer.renderer.render( sceneRenderer.scene, sceneRenderer.camera, this.coverRenderTarget, true );
  1129. },
  1130. stop:function(){
  1131. this.enabled = false
  1132. }
  1133. ,
  1134. getMaskMaterial :function(){
  1135. return new THREE.ShaderMaterial( {
  1136. uniforms: {
  1137. coverTex: {
  1138. type: "t",
  1139. value: null
  1140. },
  1141. bgTex: {
  1142. type: "t",
  1143. value: null
  1144. },
  1145. progress:{
  1146. type: "f",
  1147. value: 0
  1148. },
  1149. screenRatio:{
  1150. type: "f",
  1151. value: 1
  1152. }
  1153. },
  1154. vertexShader: `
  1155. varying vec2 vUv;
  1156. void main()
  1157. {
  1158. vUv = uv;
  1159. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  1160. }
  1161. `,
  1162. fragmentShader: `
  1163. uniform sampler2D coverTex;
  1164. uniform sampler2D bgTex;
  1165. uniform float progress;
  1166. uniform float screenRatio;
  1167. varying vec2 vUv;
  1168. void main() {
  1169. const float maxRadius = 0.708; // sqrt(0.5^2+0.5^2)
  1170. const float minRadius = 0.0 ;
  1171. float radius = screenRatio>1.0 ? sqrt((vUv.x - 0.5)*(vUv.x - 0.5) + (vUv.y - 0.5)*(vUv.y - 0.5)/screenRatio) : sqrt((vUv.x - 0.5)*(vUv.x - 0.5)*screenRatio+ (vUv.y - 0.5)*(vUv.y - 0.5));
  1172. float diff = 0.292; //1.0-maxRadius;
  1173. float radiusIn = maxRadius * progress + minRadius * (1.0-progress);
  1174. float radiusOut = radiusIn + diff;
  1175. if(radius < radiusIn) {
  1176. gl_FragColor = texture2D(bgTex, vUv);
  1177. //gl_FragColor = vec4(0.0,0.0,1.0,1.0);//
  1178. }else if(radius>radiusOut){
  1179. gl_FragColor = texture2D(coverTex, vUv) ;
  1180. //gl_FragColor = vec4(1.0,1.0,0.0,1.0);//
  1181. }else{
  1182. vec4 color1 = texture2D(bgTex, vUv);
  1183. vec4 color2 = texture2D(coverTex, vUv);
  1184. float rotio = smoothstep(radiusIn ,radiusOut,radius);
  1185. gl_FragColor = mix(color1, color2, rotio);
  1186. }
  1187. }
  1188. `
  1189. } );
  1190. },
  1191. }
  1192. Object.assign(Manage.prototype, THREE.EventDispatcher.prototype)
  1193. let labels = []
  1194. class Label2D extends THREE.EventDispatcher{
  1195. constructor(o={}){
  1196. super()
  1197. this.position = o.position
  1198. this.elem = $(o.innerHTML || '<div ><a></a></div>');
  1199. $(o.domElement).append(this.elem)
  1200. this.pos2d = new THREE.Vector3
  1201. this.elem.css({position: 'absolute', 'z-index':999})
  1202. this.clickFun = o.clickFun;
  1203. this.clickFun && this.elem.on('click',this.clickFun.bind(this))
  1204. if(o.autoUpdate){
  1205. let update = (e)=>{if(e.cameraChanged) this.update()}
  1206. player.on("view.changed",update) //确保player存在
  1207. this.addEventListener('dispose', (e)=>{
  1208. player.removeListener("view.changed",update)
  1209. })
  1210. }
  1211. this.visible = true
  1212. this.shelterByModel = o.shelterByModel
  1213. this.floorIndex = o.floorIndex
  1214. labels.push(this)
  1215. if(window.player.model){
  1216. this.init()
  1217. }else{
  1218. let f = ()=>{
  1219. window.bus.removeEventListener('playerAndModelReady',f)
  1220. this.init()
  1221. }
  1222. window.bus.addEventListener('playerAndModelReady',f)
  1223. }
  1224. }
  1225. init(){
  1226. if(this.floorIndex != void 0){
  1227. player.model.on("floor.changed",(currentFloor, mode, oldFloor)=>{
  1228. this.update(currentFloor) //注: currentFloor 这时候还没成为 model.currentFloor
  1229. })
  1230. }
  1231. }
  1232. update(currentFloor){
  1233. if(!this.position || !this.visible)return
  1234. if(!this.visible && this.unvisibleReasons.some(e=>e.level == 1) && !this.unvisibleReasons.some(e=>e.level>1) )return;
  1235. var p = convertTool.getPos2d(this.position);
  1236. if(!p || !p.trueSide){
  1237. return this.setVisible(false, 'notTrueSide', 3, null, true)
  1238. //this.elem.css('display','none'); return;
  1239. }
  1240. this.setVisible(true, 'notTrueSide', 3, null, true)
  1241. this.setVisible(true, 'shelter', 0, null, true)
  1242. //判断label是否被模型遮挡,遮挡则消失(如果是漫游模式最好提前计算visiblePanos)
  1243. if(player.mode != 'panorama'){
  1244. currentFloor = currentFloor || player.model.currentFloor
  1245. if(!player.model.allFloorsVisible && this.floorIndex != void 0 && this.floorIndex!= currentFloor.floorIndex){
  1246. this.setVisible(false, 'shelter', 0, null, true)
  1247. //this.elem.css('display','none'); return;
  1248. if(!this.visible)return
  1249. }
  1250. if(this.shelterByModel && convertTool.ifShelter(this.position , p.vector, player.camera, this.floorIndex )){
  1251. //this.elem.css('display','none'); return;
  1252. this.setVisible(false, 'shelter', 0, null, true)
  1253. if(!this.visible)return
  1254. }
  1255. }
  1256. this.elem.css({
  1257. left: p.pos.x +'px',
  1258. top: p.pos.y +'px'
  1259. })
  1260. /* if(settings.vrEnabled){
  1261. this.elem.css({transform:'rotate('+window.screenFaceOrient+'deg)'})
  1262. }else{
  1263. this.elem.css({transform:''})
  1264. } */
  1265. //this.elem.css('display','block');
  1266. this.pos2d = p.vector;
  1267. }
  1268. setVisible(visi, reason, level=1, type, updating){
  1269. let visiOld = this.visible
  1270. convertTool.updateVisible(this, reason, visi, level, type )
  1271. updating || this.update() //再次更新可见性并计算位置
  1272. this.elem.css('display',this.visible?'block':'none');
  1273. /* if(!this.visible){
  1274. this.elem.css('display','none');
  1275. }else{
  1276. if(!visiOld){
  1277. updating || this.update()
  1278. this.elem.css('display','block');
  1279. }
  1280. } */
  1281. }
  1282. setPos(pos){
  1283. this.position = pos;
  1284. this.update()
  1285. }
  1286. dispose(){
  1287. this.elem.remove();
  1288. this.dispatchEvent({type:'dispose'})
  1289. let index = labels.indexOf(this)
  1290. index > -1 && labels.splice(index,1)
  1291. }
  1292. }
  1293. window.Label2D = Label2D
  1294. class RoomLabel extends Label2D{
  1295. constructor(o){
  1296. if(o.position instanceof Array) o.position = new THREE.Vector3().fromArray(o.position)
  1297. o.innerHTML = `<div class="room-label" ><a><p><span>${o.title}</span></p></a></div>`
  1298. o.domElement = $(".widgets-doll-labels")[0]
  1299. o.shelterByModel = true , o.autoUpdate = true
  1300. o.clickFun = ()=>{
  1301. if(player.roomLebelClickUnabled)return
  1302. let result = common.sortByScore(player.model.floors.index[this.floorIndex].panos, [], [(pano)=>{
  1303. return -pano.position.distanceToSquared(this.position)
  1304. }]);
  1305. let pano = result && result[0] && result[0].item
  1306. if(pano){
  1307. const minDisSquard = 200
  1308. if(pano.position.distanceToSquared(this.position) > minDisSquard){
  1309. pano = null
  1310. }
  1311. }
  1312. if(pano){
  1313. player.flyToPano({
  1314. pano
  1315. })
  1316. }else{
  1317. player.focusPoint({aim: this.position, radius: 20, dur:1000})
  1318. }
  1319. }
  1320. super(o)
  1321. this.setTitle(o.title )
  1322. }
  1323. init(){
  1324. super.init()
  1325. //飞入后不可见
  1326. player.on("mode.changing",(oldMode, mode, pano, duration)=>{//准备飞
  1327. this.setStyle(oldMode, mode, duration)
  1328. })
  1329. this.setStyle()
  1330. }
  1331. setStyle(oldMode, mode, duration){
  1332. if(!mode) mode = player.modeTran.split('-')[1] || player.mode //要变成的mode或当前mode
  1333. if(mode == 'panorama'){
  1334. this.setVisible(false, 'isPanorama', 1)
  1335. }else if(oldMode == 'panorama'){
  1336. setTimeout(()=>{
  1337. this.setVisible(true, 'isPanorama', 1)
  1338. },duration*0.7)
  1339. }
  1340. }
  1341. setTitle(title){
  1342. this.title = title || ''
  1343. this.elem.html(`<a><p><span>${this.title}</span></p></a>`)
  1344. }
  1345. setEditSelect(state){//编辑页面用
  1346. this.editing = !!state
  1347. this.setVisible(state, 'editSelected', 2, state ? 'add':'cancel') //强制可见
  1348. }
  1349. }
  1350. window.RoomLabel = RoomLabel
  1351. /* class VideoPlayer extends THREE.EventDispatcher{
  1352. constructor(player) {
  1353. super()
  1354. this.instances = new Map()
  1355. this.isFlv = false
  1356. }
  1357. addVideo(src) {
  1358. let video = this._createVideo(src)
  1359. this.instances.set(src, video)
  1360. return video
  1361. }
  1362. getVideo(src) {
  1363. let video = this.instances.get(src)
  1364. if (!video) {
  1365. video = this.addVideo(src)
  1366. }
  1367. return video
  1368. }
  1369. _createVideo(src) {
  1370. let video = document.createElement('video')
  1371. video.setAttribute('crossOrigin', 'anonymous')
  1372. video.setAttribute('playsinline', 'true')
  1373. video.setAttribute('x5-playsinline', 'true')
  1374. video.setAttribute('webkit-playsinline', 'true')
  1375. video.setAttribute('x5-video-player-type', 'h5')
  1376. video.setAttribute('controls', 'true')
  1377. video.setAttribute('controlslist', 'nodownload')
  1378. video.setAttribute('preload', 'meta') //注意,src赋值就会自动加载, preload="meta" 只加载元数据,提高加载速度,否则一开始卡
  1379. video.autoplay = false
  1380. video.muted = true
  1381. video.loop = true
  1382. video.style.position = 'fixed'
  1383. video.style.left = '0'
  1384. video.style.top = '0'
  1385. video.style.zIndex = '1000'
  1386. video.style.width = '200px'
  1387. video.style.display = 'none'
  1388. //document.body.appendChild(video)
  1389. //video.style.display = browser.urlHasValue('debug') ? 'block' : 'none'
  1390. video.src = src
  1391. if(this.isFlv) this.attachFlv(video)
  1392. return video
  1393. }
  1394. attachFlv(video){ 四维看看的会把视频转码成flv和mp4存在服务器, 但是大场景不会,所以安卓(如vivo)加载不了。flv必须用flvjs播放,且苹果有的支持不了
  1395. if(video.flvjsPlayer)return
  1396. let player = flvjs.createPlayer({ type: 'flv', url: video.src }) //需要是flv格式才行
  1397. player.videoElement = video
  1398. player.attachMediaElement(video)
  1399. player.on(flvjs.Events.ERROR, this._onPlayerError.bind(this))
  1400. player.load()
  1401. video.flvjsPlayer = player;
  1402. }
  1403. _onPlayerError() {
  1404. console.warn('视频加载失败')
  1405. }
  1406. changeTypeToFlv(){
  1407. this.isFlv = true
  1408. for(let [key,value] of this.instances){
  1409. this.attachFlv(value)
  1410. }
  1411. }
  1412. } */
  1413. window.initRouteArrow = ()=>{
  1414. if(window.isEdit)return
  1415. if(!window.DATA.route?.data || Object.keys(window.DATA.route.data).length == 0)return
  1416. let {hide, gradualShow, opacityShine, data={}} = window.DATA.route || {} //hide 默认是否隐藏,若隐藏也可以通过函数展示
  1417. let panos = player.model.panos
  1418. panos.routeNextMap = {} //下一个
  1419. panos.routePreMap = {} //上一个
  1420. panos.list.forEach((pano,i)=>{
  1421. panos.routePreMap[pano.id] = []
  1422. panos.routeNextMap[pano.id] = data[pano.id] ? data[pano.id].map(id=>panos.get(id)) : []
  1423. })
  1424. for(let panoId in data){
  1425. data[panoId].forEach(id=>{
  1426. panos.routePreMap[id].push(panos.get(panoId))
  1427. })
  1428. }
  1429. var arrowInfo = {
  1430. animateDur : 5000,
  1431. showDur: 1000,
  1432. minOpa: 0.2,
  1433. maxOpa: 0.5
  1434. }
  1435. let arrowTex = Texture.load('static/images/arrow.png')
  1436. arrowTex.anisotropy = 4
  1437. let arrowMat = new THREE.MeshBasicMaterial({
  1438. name: 'arrow',
  1439. transparent:true,
  1440. map:arrowTex,
  1441. side:2,
  1442. opacity: arrowInfo.maxOpa
  1443. depthWrite:false, //防止和导览路线重叠闪烁
  1444. })
  1445. let mats = {
  1446. default: arrowMat,
  1447. fadeIn: arrowMat.clone()
  1448. }
  1449. mats.fadeIn.name = 'fadeInArrow'
  1450. let plane = new THREE.PlaneBufferGeometry(1,1)
  1451. let arrows = new THREE.Object3D; arrows.name = 'groundArrows'
  1452. player.model.add(arrows)
  1453. var createArrow = function(mat){
  1454. var arrow = new THREE.Mesh(plane, mat)
  1455. arrow.name = 'arrow'
  1456. let s = 0.15
  1457. arrow.scale.set(s,s,s)
  1458. arrows.add(arrow)
  1459. return arrow
  1460. }
  1461. var updateArrowPose = function(from, to, mat ){
  1462. var vec = to.floorPosition.clone().clone().sub(from.floorPosition).setY(0);
  1463. let spaceDis = 0.4//箭头之间的间距
  1464. let margin = 0.3 //marker端需要留一点距离
  1465. let sliceCount = Math.max(2, Math.round((vec.length()-margin) / spaceDis)) //分段
  1466. let arrowCount = sliceCount - 1
  1467. let dir = vec.clone().normalize()
  1468. let dir2d = new THREE.Vector2(dir.x, dir.z)
  1469. let angle = dir2d.angle() - Math.PI/2
  1470. let sliceLen = (vec.length()-margin) / sliceCount
  1471. let i = arrowCount
  1472. while(i>0){
  1473. let pos = from.floorPosition.clone().add(dir.clone().multiplyScalar(margin/2 + i*sliceLen))
  1474. pos.y+=settings.markerHeight
  1475. let arrow = createArrow(mat)
  1476. arrow.name = 'arrow:'+from.id+"-"+to.id+"|"+i
  1477. arrow.rotation.set(Math.PI/2, 0, angle);
  1478. arrow.position.copy(pos)
  1479. i--
  1480. }
  1481. }
  1482. var updateArrowOpacity = function(e){//不停更新所有arrow的透明度
  1483. var transition = function(a){
  1484. if(!arrows.visible)return
  1485. var opa = a > 0.5 ? 2-a*2 : 2*a ;
  1486. opa = arrowInfo.maxOpa*opa+ arrowInfo.minOpa*(1-opa)
  1487. mats.default.opacity = opa
  1488. mats.fadeIn.opacity = opa * mats.fadeIn.opacity2
  1489. }
  1490. transitions.start(transition, arrowInfo.animateDur, updateArrowOpacity, 0, easing.easeInOutCubic, "updateArrowOpacity")
  1491. }
  1492. var fadeInArrow = function(){
  1493. transitions.cancelById('updateArrowOpacity2')
  1494. var arrows_ = arrows.children.filter(e=> e.material == mats.fadeIn)
  1495. if(arrows_.length == 0)return
  1496. mats.fadeIn.opacity = 0
  1497. var transition = function(a){
  1498. if(!opacityShine) mats.fadeIn.opacity = a * arrowInfo.maxOpa
  1499. else mats.fadeIn.opacity2 = a
  1500. }
  1501. transitions.start(transition, arrowInfo.showDur, function done(){
  1502. arrows_.forEach(e=>e.material = mats.default)
  1503. }, 0, easing.easeInOutCubic, "updateArrowOpacity", "updateArrowOpacity2")
  1504. }
  1505. var lastArrowPanos = []
  1506. var updateArrow = function(){//根据当前pano更新
  1507. if(player.mode != 'panorama' || hide){ //飞出
  1508. arrows.visible = false
  1509. lastArrowPanos = []
  1510. return;
  1511. }
  1512. arrows.visible = true
  1513. let currentPano = player.currentPano
  1514. //先获取所有需要箭头的pano
  1515. var maxDistance = 6;//该距离内pano可见箭头
  1516. var maxPathCount = 8;
  1517. var dis = 0
  1518. var curPano = currentPano;
  1519. var panos_ = [];
  1520. var getAngle = function(pano1,pano2){
  1521. let dir = new THREE.Vector3().subVectors(pano1.position,pano2.position)
  1522. dir = new THREE.Vector2(dir.x, dir.z)
  1523. return dir.angle()
  1524. }
  1525. var search = function(pano, path=[pano], angles=[]){//多分支搜寻
  1526. var neighbor = panos.routeNextMap[pano.id];
  1527. if(!neighbor || !neighbor.length)return //path.length>1 && console.log('branchPath',path);
  1528. neighbor.forEach(e=>{
  1529. let branchPath = path.slice(), angles_ = angles.slice()
  1530. if(panos_.find(arr=>arr[0]==e))return //console.log('不回头branchPath',branchPath); //不回头
  1531. dis = e.floorPosition.distanceTo(currentPano.floorPosition)
  1532. branchPath.push(e)
  1533. if(branchPath.length>2){//不折回,否则感觉在面前饶了一圈回来很难看
  1534. let i=0
  1535. while(i<branchPath.length-1){ //补全angles
  1536. if(angles_[i] == void 0){
  1537. angles_[i] = getAngle(branchPath[i], branchPath[i+1])
  1538. }
  1539. i++
  1540. }
  1541. let lastAngle = angles_[branchPath.length-2]//getAngle(branchPath[i], e)
  1542. let reverse = angles_.find((angle, n)=> {
  1543. let angleDiff = Math.abs(( lastAngle - angle) % (Math.PI*2) ) //越远限制越大
  1544. let minDiff = math.linearClamp(branchPath.length,[3,6],[0.2,0.5])
  1545. if(Math.abs(angleDiff - Math.PI ) < minDiff){
  1546. //console.log('因为折回而提前结束', n, branchPath)
  1547. return true
  1548. }
  1549. })
  1550. if(reverse != void 0){
  1551. return
  1552. }
  1553. }
  1554. if(branchPath.length<3 || dis < maxDistance){
  1555. panos_.push([pano, e])
  1556. search(e, branchPath, angles_)
  1557. }else{
  1558. //console.log('branchPath',branchPath)
  1559. }
  1560. })
  1561. }
  1562. //search(currentPano)
  1563. let disMap = new Map, cosMap = new Map
  1564. let camDir = player.getDirection()
  1565. let neighbors = currentPano.neighbourUUIDs.map(e=>panos.get(e))
  1566. .filter(p=>{
  1567. let dir = new THREE.Vector3().subVectors(p.position, currentPano.position)
  1568. let d = dir.lengthSq()
  1569. if(d < 15){//最大距离
  1570. disMap.set(p, d);
  1571. cosMap.set(p, dir.normalize().dot(camDir))
  1572. return true
  1573. }
  1574. }).sort((a,b)=>{
  1575. let score = disMap.get(a) - disMap.get(b)
  1576. score += (cosMap.get(b) - cosMap.get(a)) * 5
  1577. return score
  1578. })//从近到远,尽量在前方
  1579. let seedPanos = [currentPano, ...neighbors]//如果没有从当前点出发的箭头,就展示隔壁点的(缺点是隔壁点可能是指向当前点的,原规则是不展示来的路径的,所以会有点奇怪。虽然也可以在search后剔除啦)
  1580. for(let seed of seedPanos){
  1581. search(seed)
  1582. if(panos_.length != 0){
  1583. break;
  1584. }
  1585. }
  1586. arrows.children.slice().forEach(child=>arrows.remove(child))
  1587. panos_.forEach((panoArr,i)=>{
  1588. var isNew = !lastArrowPanos.find(e=>e[0]==panoArr[0] && e[1]==panoArr[1])//新出现的点 渐变出现
  1589. updateArrowPose(panoArr[0], panoArr[1], isNew ? mats.fadeIn : mats.default )//更新位置
  1590. })
  1591. fadeInArrow()
  1592. lastArrowPanos = panos_
  1593. }
  1594. let inited
  1595. let init = ()=>{
  1596. if(inited)return
  1597. if(gradualShow){
  1598. player.on("flying.ended", updateArrow )
  1599. }else{
  1600. //展示全部
  1601. for(let id1 in panos.routeNextMap){
  1602. for(let pano2 of panos.routeNextMap[id1]){
  1603. updateArrowPose(panos.get(id1), pano2, mats.default)
  1604. }
  1605. }
  1606. player.on("mode.changed", ()=>{
  1607. if(hide)return
  1608. arrows.visible = player.mode == 'panorama'
  1609. })
  1610. }
  1611. opacityShine && updateArrowOpacity()
  1612. inited = true
  1613. }
  1614. {//ui控制显示
  1615. let changeShow = (e)=>{
  1616. hide = !e.show
  1617. e.show && init()
  1618. gradualShow ? updateArrow() : (arrows.visible = e.show)
  1619. }
  1620. player.on('changeArrowShow',changeShow)
  1621. changeShow({show:!hide})
  1622. }
  1623. }
  1624. {
  1625. let f = ()=>{
  1626. window.bus.removeEventListener('playerAndModelReady',f)
  1627. player.on("mode.changing",(currentMode, mode, pano, duration)=>{
  1628. let noLine = mode == 'floorplan';
  1629. if(noLine){
  1630. $('.widgets-doll-labels').addClass('noLine').addClass('noCorner')
  1631. }else{
  1632. $('.widgets-doll-labels').removeClass('noLine').removeClass('noCorner')
  1633. }
  1634. })
  1635. player.on("view.changed",(e)=>{
  1636. if(e.cameraChanged){
  1637. //if(needUpdateZIndex){ //如果某个label显示时需要更新index的话,加个参数
  1638. let label_ = labels.filter(e=>e.elem[0].style.display == 'block')
  1639. label_.sort((a,b)=>b.pos2d.z - a.pos2d.z)
  1640. label_.forEach((e,index)=>e.elem.css('z-index', index+1000));
  1641. //}
  1642. }
  1643. })
  1644. player.model.hotGroup.children.length ? logSth() : player.on('gotHotAndStartload',logSth);
  1645. /* {//如果是flv格式的话
  1646. window.videoPlayer = new VideoPlayer()
  1647. if(browser.detectAndroidMobile()){//安卓常常播放不了
  1648. let scriptdom = document.querySelector('#flvJs')
  1649. if(scriptdom){
  1650. scriptdom.src = 'js/lib/flv.min.js'
  1651. scriptdom.onload = ()=>{
  1652. window.videoPlayer.changeTypeToFlv()
  1653. window.bus.dispatchEvent('VideoPlayerReady' )
  1654. //Hot.startLoad()
  1655. }
  1656. }
  1657. }
  1658. } */
  1659. initRouteArrow()
  1660. browser.urlHasValue('panoLabel') && player.model.panos.forEach(p=>p.addLabel())
  1661. if(settings.extractFloor){
  1662. let data = settings.extractFloor[number]
  1663. if(data){
  1664. setTimeout(()=>{
  1665. let roof = new player.model.floors.list[0].constructor(player.model, player.model.floors.length);//放在第三层 隐藏起来
  1666. roof.build()
  1667. player.model.floors.add(roof)
  1668. for(let i=0;i<data.length;i++){
  1669. let chunk = player.model.chunks[data[i]]
  1670. let oldFloor = chunk.parent
  1671. roof.addChunk(chunk)
  1672. let index = oldFloor.chunks.indexOf(chunk)
  1673. oldFloor.chunks.splice(index,1)
  1674. }
  1675. //更改一下楼层按钮的样式,不用文字,用图标
  1676. $(".gui-floor-title").remove()
  1677. $(".gui-floor-number").remove()
  1678. player.mode == 'panorama' && $('.gui-floor').hide()
  1679. $('.gui-floor [data-index=all]').text('外部')
  1680. $('.gui-floor [data-index=0]').text('内部')
  1681. },10)
  1682. }
  1683. }
  1684. player.model.on("floor.changed",(currentFloor, mode, oldFloor)=>{
  1685. if(player.model.allFloorsVisible){
  1686. $('.gui-floor .gui-floor-icon').removeClass('inside')
  1687. }else{
  1688. $('.gui-floor .gui-floor-icon').addClass('inside')
  1689. }
  1690. })
  1691. player.on('mode.changed',()=>{
  1692. if(player.mode == 'panorama'){
  1693. $('.gui-floor').hide()
  1694. }else{
  1695. $('.gui-floor').show()
  1696. }
  1697. })
  1698. }
  1699. window.bus.addEventListener('playerAndModelReady',f) //player model currentPano都已有
  1700. }
  1701. window.bus.dispatchEvent({type: 'THREE_inited'})
  1702. }
  1703. //最好能知道应该播放到的currentTime
  1704. var SoundManager = {//暂不支持同时播放
  1705. currentAudio:null,//当前正在播放list中的哪一个
  1706. enableSound:true,//是否允许有声音
  1707. playHistory:[],//被打断的加入播放历史
  1708. list:[ ],//同一级别可以互相打断 //暂时不做多级别
  1709. play:function(name, src, currentTime){
  1710. var object = this.list.find(e=>e.name == name)
  1711. if(object){
  1712. if(this.currentAudio){
  1713. this.pause(this.currentAudio.name, false, true)
  1714. }
  1715. {//将当前要播放的播放历史中清除
  1716. let index = this.playHistory.indexOf(object)
  1717. if(index>-1)this.playHistory.splice(index,1);
  1718. }
  1719. this.currentAudio = object
  1720. if(src){
  1721. this.setSrc(name, src)
  1722. }
  1723. if(currentTime!=void 0){
  1724. object.audio.currentTime = currentTime
  1725. }
  1726. if(object.audio && object.src){
  1727. object.audio.load(); // iOS 9 还需要额外的 load 一下, 否则直接 play 无效 *///https://www.cnblogs.com/interdrp/p/4211883.html 部分资料
  1728. object.audio.play();
  1729. object.audio.paused || object.callback && object.callback(true)
  1730. Log(name + ' 播放 ' )
  1731. }
  1732. }
  1733. },
  1734. pause:function(name, autoReplayLast, isInterrupt){//需要能自动恢复上一个被打算的音频。恢复前判断是否还需要播放
  1735. var object = this.list.find(e=>e.name == name)
  1736. if(object && this.currentAudio == object){
  1737. this.currentAudio = null
  1738. if(object.audio){
  1739. object.audio.pause()
  1740. object.callback && object.callback(false)
  1741. object.audio.src && Log(name + ' 中断音频 '+ "("+common.getFileNameFromUrl(object.audio.src)+')' )
  1742. }
  1743. if(isInterrupt){//一般主动调用不需要加这个
  1744. this.playHistory.push(object)//如果是被中断的,加入播放历史,等待恢复播放
  1745. }
  1746. if(autoReplayLast){ //播放之前的音频。它们是被打断过的。
  1747. while(this.playHistory.length){
  1748. var last = this.playHistory.pop();
  1749. if(last.src && last.canplay(last.audio)){
  1750. this.play(last.name )
  1751. }
  1752. }
  1753. }
  1754. }
  1755. },
  1756. setSrc : function(name, src){//不能直接给audio赋src!一定要用这个函数!因为我要拿这里的src来判断有无src,因为貌似audio的src会自动变,''时会变成html的链接
  1757. var object = this.list.find(e=>e.name == name)
  1758. object.src = src
  1759. object.audio.src = src
  1760. Log(`${object.name} 设置src: ${src}`)
  1761. },
  1762. createAudio:function(object={}){//name, level, canplay
  1763. if(!object.fake){
  1764. object.audio = new Audio();
  1765. object.audio.loop = !!object.loop;
  1766. //object.audio.autoplay = true;
  1767. object.audio.addEventListener('ended', ()=>{
  1768. if(object.loop){//循环
  1769. Log(`${object.name} 播放完毕,重新播放`)
  1770. object.audio.play()
  1771. }else{
  1772. this.pause(object.name, true);//停止后的后续处理
  1773. }
  1774. });
  1775. object.audio.oncanplaythrough = ()=>{
  1776. Log(`${object.name} canplaythrough `)
  1777. }
  1778. }
  1779. this.list.push(object)
  1780. },
  1781. initAutoPlay:function(){ //处理设备自动播放限制
  1782. let play = function(){
  1783. if (this.currentAudio && this.currentAudio.audio && this.currentAudio.src && this.currentAudio.audio.paused ) {
  1784. this.currentAudio.audio.play() //一般触屏了都会播放成功,就不识别paused了
  1785. this.currentAudio.callback && this.currentAudio.callback(true)
  1786. Log(`${this.currentAudio.name} 自动播放成功`) //即使设置src在这之后好像也能成功播放
  1787. }else{
  1788. }
  1789. document.removeEventListener("touchstart",play);
  1790. document.removeEventListener("click",play);
  1791. $('#player')[0].removeEventListener("touchstart", play);
  1792. }.bind(this);
  1793. document.addEventListener("WeixinJSBridgeReady", play, false);
  1794. document.addEventListener("touchstart", play);//ios需要加个事件才能播放 不能自动播放;如果还有浏览器不行,换成别的交互事件
  1795. document.addEventListener("click", play);
  1796. $('#player')[0].addEventListener("touchstart", play);
  1797. }
  1798. }
  1799. function Log(value, color, fontSize){
  1800. color = color || '#13f'
  1801. fontSize = fontSize || 14
  1802. console.warn(`%c${value}`, `color:${color};font-size:${fontSize}px`)
  1803. }
  1804. Manage.prototype.loadAudio = function() { //相关:g_tourAudio \ g_playAudio
  1805. //热点页面因为挡住了界面,所以暂时不存在别的音频阻止热点音频的可能
  1806. //box视频都静音,所以暂时不考虑
  1807. SoundManager.createAudio({
  1808. name:'bgm',
  1809. level:0,
  1810. src:'',
  1811. loop:true,
  1812. canplay:(audio)=>{
  1813. return this.bgmShouldPlay
  1814. },
  1815. callback:(state)=>{//play或pause时随之触发的函数(即使还没开始播放)
  1816. try{
  1817. if(state){
  1818. console.log('播放背景音乐');
  1819. document.querySelector('#openMusic').style.display='block'
  1820. document.querySelector('#closeMusic').style.display='none'
  1821. }else{
  1822. console.log('暂停背景音乐');
  1823. document.querySelector('#openMusic').style.display='none'
  1824. document.querySelector('#closeMusic').style.display='block'
  1825. }
  1826. }catch(err){
  1827. }
  1828. }
  1829. })
  1830. SoundManager.createAudio({
  1831. name:'tour',
  1832. level:0,
  1833. src:'',
  1834. loop:false,
  1835. canplay:(audio)=>{
  1836. return player.director && player.director.tourIsPlaying && player.director.getAudio()
  1837. }
  1838. })
  1839. SoundManager.createAudio({
  1840. name:'hot',
  1841. fake:true,//实际上没有audio. 只是为了来停止和续播其他音频
  1842. level:1,
  1843. src:'',
  1844. loop:false,
  1845. canplay:(audio)=>{
  1846. }
  1847. })
  1848. $("#volume").find("a").on("click", ()=> {
  1849. if($("#volume img")[0].src.indexOf("btn_on.png")>-1)
  1850. {
  1851. this.switchBgmState(true);
  1852. }
  1853. else if($("#volume img")[0].src.indexOf("btn_off.png")>-1)
  1854. {
  1855. this.switchBgmState(false);
  1856. }
  1857. })
  1858. // this.switchBgmState(true);//初始设置允许播放bgm
  1859. // SoundManager.initAutoPlay()
  1860. }
  1861. Manage.prototype.switchBgmState = function(state){//按钮的状态完全代表是否应该播放bgm,即使还没加载完
  1862. this.bgmShouldPlay = state
  1863. if(state){
  1864. SoundManager.play('bgm')
  1865. }else{
  1866. SoundManager.pause('bgm')
  1867. }
  1868. /* if(!g_bgAudio || !g_bgAudio.src) return;
  1869. var played = function(){
  1870. console.log('begin play bgm');
  1871. g_play = 1;
  1872. g_playAudio = g_bgAudio;
  1873. g_tourAudio && g_tourAudio.pause()
  1874. }
  1875. var paused = function(){
  1876. g_play = 0;
  1877. g_playAudio == g_bgAudio && (g_playAudio = null)
  1878. }
  1879. if(state ){
  1880. g_bgAudio.play();
  1881. if(g_bgAudio.paused){
  1882. paused()
  1883. }else{
  1884. played()
  1885. return true
  1886. }
  1887. }else{
  1888. g_bgAudio.pause();
  1889. paused()
  1890. }
  1891. g_bgAudio.pauseByHot = false
  1892. g_bgAudio.pauseByTour = false */
  1893. }
  1894. var manage = new Manage();
  1895. //处理cursor优先级
  1896. var CursorDeal = {
  1897. priorityEvent : [//在前面的优先级高
  1898. {"noIntersect":'not-allowed'},
  1899. {"addHot":'cell'},
  1900. {"hoverFootIcon":'pointer'},
  1901. {"hoverHot":'pointer'},
  1902. {"addLabel":'cell'},
  1903. {"moveLabel":'grab'},
  1904. ],
  1905. domElements :[$('#player')[0]],
  1906. list:[], //当前存在的cursor状态
  1907. currentCursorIndex:null,
  1908. /* init : function(viewer){
  1909. this.priorityEvent.forEach(e=>{//刚开始Potree.resourcePath没值,现在换
  1910. for(let i in e){
  1911. e[i] = Common.replaceAll(e[i],'{Potree.resourcePath}',Potree.resourcePath)
  1912. }
  1913. })
  1914. this.domElements = [viewer.renderArea, viewer.mapViewer.renderArea];
  1915. viewer.addEventListener("CursorChange",(e)=>{
  1916. if(e.action == 'add'){
  1917. this.add(e.name)
  1918. }else{
  1919. this.remove(e.name)
  1920. }
  1921. })
  1922. }, */
  1923. add : function(name){
  1924. var priorityItem = this.priorityEvent.find(e=>e[name])
  1925. if(!priorityItem){
  1926. console.error('CursorDeal 未定义优先级 name:'+ name);
  1927. return
  1928. }
  1929. if(!this.list.includes(name)){
  1930. this.judge({addItem: priorityItem, name})
  1931. this.list.push(name)
  1932. }
  1933. },
  1934. remove : function(name){
  1935. var index = this.list.indexOf(name);
  1936. if(index > -1){
  1937. this.list.splice(index, 1)
  1938. this.judge()
  1939. }
  1940. },
  1941. judge:function(o={}){
  1942. //console.log(o,this.list)
  1943. if(o.addItem){
  1944. var addIndex = this.priorityEvent.indexOf(o.addItem)
  1945. if(addIndex < this.currentCursorIndex || this.currentCursorIndex == void 0){
  1946. this.domElements.forEach(e=>e.style.cursor = o.addItem[o.name] )
  1947. this.currentCursorIndex = addIndex
  1948. }
  1949. }else{
  1950. var levelMax = {index:Infinity, cursor:null }
  1951. this.list.forEach(name=>{
  1952. var priorityItem = this.priorityEvent.find(e=>e[name])
  1953. var index = this.priorityEvent.indexOf(priorityItem)
  1954. if(index < levelMax.index){
  1955. levelMax.index = index;
  1956. levelMax.cursor = priorityItem[name]
  1957. }
  1958. })
  1959. this.currentCursorIndex = levelMax.index
  1960. this.domElements.forEach(e=>e.style.cursor = levelMax.cursor || '')
  1961. }
  1962. }
  1963. }
  1964. function logSth(){
  1965. let hotCount = player.model.hotGroup.children.length
  1966. let videoCount = player.model.hotGroup.children.filter(e=>e.texType == 'video').length
  1967. let photoCount = player.model.hotGroup.children.filter(e=>e.texType == 'photo').length
  1968. let shineCount = player.model.hotGroup.children.filter(e=>e.texType == 'shine').length
  1969. let aniCount = player.model.hotGroup.children.filter(e=>e.info.animateInfo).length
  1970. let objCount = player.model.hotGroup.children.filter(e=>e.objObject).length
  1971. let chunkLen = player.model.chunks.length
  1972. let vertexC = player.model.chunks.reduce(function(total, chunk ){return total+chunk.geometry.attributes.position.count}, 0)
  1973. let panoCount = player.model.panos.list.length
  1974. Log(`共有chunk个数 ${chunkLen} ( 顶点数 ${vertexC} )
  1975. 热点个数 ${hotCount} ( vedio ${videoCount} 个,photo ${photoCount} 个,shine ${shineCount}个。 gif ${aniCount} 个,obj ${objCount} 个
  1976. 漫游点数 ${panoCount} 个)`, '#FF4399', 14)
  1977. }
  1978. window.sceneFrom = (number.length > 6 && number.slice(0,3).includes('-') || browser.urlHasValue('kankan') ) ? 'kankan' : '' //看看or看见转来的
  1979. //兼容一代的場景
  1980. //請求地址統一管理
  1981. var g_onePregix = "https://bigscene.4dage.com/" //对应一代 http://www.4dmodel.com/SuperPanoramic/index.html?m=55
  1982. var g_version = manage.number("version");
  1983. g_version === "one" ? g_Prefix = g_onePregix : '';