manage_new.js 68 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026
  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. window.isLocal = true
  8. var g_index=null;
  9. var g_modeldata=null;
  10. var g_weixinTitle=null;
  11. var g_Hots=null;
  12. var g_HotMeshes=[];
  13. var g_HotMeshSize = {
  14. g_HotMeshWidth: 0.3,
  15. g_HotMeshHeight:0.3
  16. };
  17. //add表示添加,delete表示删除
  18. var g_HotStatus=null;
  19. var g_newHot = [];//存储新加热点
  20. var g_HotImage= {
  21. "point":"https://super.4dage.com/images/4dagePoint2.png",
  22. "point2":"https://super.4dage.com/images/4dagePoint.png"
  23. };
  24. var g_saveHot=false;
  25. var g_TextColor=0x7777ff;
  26. var g_Text=null;
  27. var g_TextPlaneMesh=[];
  28. var g_TextIconMesh=[];
  29. var g_TextIcon="./images/text.png";
  30. var g_SelectTextIndex=null;
  31. var g_TextShow=null;
  32. var g_audioPlay=false;
  33. var g_background=null;
  34. var g_roof=null;
  35. var g_data2 = null;//加载的data2.js的内容
  36. var g_bgAudio=null;//背景音乐
  37. var g_tourAudio=null;//导览音乐
  38. var g_play = 1;//表示播放图标状态
  39. var g_playAudio = null;//当前在播放或当继续播放时应该播放的,是g_bgAudio或g_tourAudio
  40. var g_currentHot = null;//当前打开的热点
  41. //var g_Texture=null;
  42. //var g_ChunknameTexture={}; //chunkname和贴图名称对应
  43. var g_NormalTexture=false;
  44. var g_SpecularTexture=false;
  45. var g_DirectionalLight=null;
  46. var g_snapShotWidth = 200; //截图下载图片的大小
  47. var g_snapShotHeight = 140;
  48. //微信分享
  49. var g_weixinObj = {
  50. "title": document.querySelector("head title").innerHTML,
  51. "lineLink" : window.location.href,
  52. "imgUrl" : "https://www.4dmodel.com/SuperPanoramic/images/weixintitle.jpg",
  53. "desc" : "四维时代提供技术支持",
  54. }
  55. var settings = {
  56. hotClickEvent:{
  57. video:{
  58. playAndPause:true,
  59. examine:false,
  60. openHot:false
  61. },
  62. photo:{
  63. examine:false,
  64. openHot:false
  65. },
  66. shine:{
  67. examine:true,
  68. openHot:true
  69. }
  70. },
  71. hotClickActions:['playAndPause','examine','openHot','fastTran'],
  72. //默认的:
  73. teleportTime: 1500,//瞬间过渡的时间
  74. /* flytimeDistanceMultiplier:150,
  75. flyTime:750, */
  76. tourRotTime:2, //默认停留2秒
  77. //dontExamHot:true,
  78. hotFastTran:false,
  79. transparentBg: false,
  80. bgImg: null,
  81. localPrefix: '',
  82. tileClass:{//默认全景贴图加载的清晰度
  83. pc:{
  84. nav: '2k',
  85. max: '4k',
  86. },
  87. bigMobile:{ //width和height都超过一定值
  88. nav: '2k',
  89. max: '2k',//'2k',
  90. },
  91. mobile:{
  92. nav: '2k', //不放大时
  93. max: '2k', //放大最大
  94. }
  95. }, //可以稍后自行修改
  96. }
  97. if(window.number == '725'||window.number == '724'){
  98. //settings.mobileNavHigh = true
  99. settings.tileClass.mobile = {nav:'2k', max: '2k'}
  100. }
  101. //共用函数:
  102. window.common = null;
  103. window.MathLight = null;
  104. window.math = null
  105. window.easing = null
  106. window.lerp = null
  107. window.transitions = null
  108. function watch(object, propName, initialValue){ //监听某个属性的变化
  109. let v = initialValue
  110. Object.defineProperty(object, propName, {
  111. get: function() {
  112. return v
  113. },
  114. set: function(e) {
  115. console.log('watch:',propName, e)
  116. v = e
  117. }
  118. })
  119. }
  120. var toPrecision = function(e, t) {
  121. function i(e, t) {
  122. var i = Math.pow(10, t);
  123. return Math.round(e * i) / i
  124. }
  125. if (e instanceof Array) {
  126. for (var n = 0; n < e.length; n++)
  127. e[n] = i(e[n], t);
  128. return e
  129. }
  130. return i(e, t)
  131. }
  132. var dealMap = (map, o={} )=>{
  133. //使不resize when image is not power of two ,但缩小时会有锯齿
  134. if(!o.ignoreResize){
  135. if(!map.image || !THREE.Math.isPowerOfTwo(map.image.width ) || !THREE.Math.isPowerOfTwo(map.image.height )){
  136. map.wrapS = map.wrapT = THREE.ClampToEdgeWrapping;
  137. map.minFilter = THREE.LinearFilter;
  138. //map.generateMipmaps = true;
  139. }
  140. }
  141. if(!browser.isMobile()) map.anisotropy = 3
  142. }
  143. var dom = {
  144. getOffset: function(type, element, parent) {
  145. left = (type == "left") ? element.offsetLeft : element.offsetTop;
  146. if (!parent) parent = $("body")[0];
  147. while (element = element.offsetParent) {
  148. if (element == parent) break;
  149. left += (type == "left") ? element.offsetLeft : element.offsetTop;
  150. }
  151. return left;
  152. }
  153. };
  154. var getTransformSid = function(){
  155. var name
  156. if(player.mode == 'panorama'){
  157. name = player.currentPano ? player.currentPano.id : 'outside'
  158. }else{
  159. name = 'outside'
  160. }
  161. return name
  162. }
  163. var LineDraw = {
  164. /* createLine: function(posArr, o) {
  165. var e = new THREE.BufferGeometry
  166. , p = new Float32Array(6);
  167. e.addAttribute("position", new THREE.BufferAttribute(p,3));
  168. //这句新旧版写法不同 旧版这样:e.addAttribute("position",Float32Array,2,3);
  169. var p = e.attributes.position.array;
  170. for (var i = 0; i < 2; i++) {
  171. p[i * 3] = posArr[i].x;
  172. p[i * 3 + 1] = posArr[i].y;
  173. p[i * 3 + 2] = posArr[i].z;
  174. }
  175. var mat = new THREE[o.deshed ? "LineDashedMaterial" : "LineBasicMaterial"]({
  176. linewidth: o.width || 1,
  177. //windows无效。 似乎mac/ios上粗细有效 ?
  178. color: o.color || defaultColor,
  179. transparent: o.dontAlwaysSeen ? false : true,
  180. depthTest: o.dontAlwaysSeen ? true : false
  181. })
  182. var line = new THREE.Line(e,mat);
  183. line.renderOrder = o.renderOrder || 4
  184. //同tagStem; //如果不加高,可能会部分被model遮住
  185. return line;
  186. } */
  187. createLine: function (posArr, o={}) {
  188. //多段普通线 (第二个点和第三个点之间是没有线段的, 所以不用在意线段顺序)
  189. var mat
  190. if(o.mat){
  191. mat = o.mat
  192. }else{
  193. let prop = {
  194. color: o.color || defaultColor,
  195. transparent: o.dontAlwaysSeen ? false : true,
  196. depthTest: o.dontAlwaysSeen ? true : false,
  197. opacity: o.opacity != void 0 ? o.opacity : 1,
  198. }
  199. if(o.deshed ){
  200. prop.dashSize = o.dashSize || 0.1,
  201. prop.gapSize = o.gapSize || 0.1
  202. }
  203. mat = new THREE[o.deshed ? "LineDashedMaterial" : "LineBasicMaterial"](prop)
  204. }
  205. var line = new THREE.LineSegments(new THREE.BufferGeometry, mat);
  206. line.renderOrder = o.renderOrder || 4
  207. this.moveLine(line, posArr)
  208. return line;
  209. },
  210. moveLine: function (line, posArr) {
  211. if(posArr.length == 0)return
  212. let position = new Float32Array(posArr.length * 3); //[]
  213. for (var i = 0; i < 2; i++) {
  214. position[i * 3] = posArr[i].x;
  215. position[i * 3 + 1] = posArr[i].y;
  216. position[i * 3 + 2] = posArr[i].z;
  217. }
  218. line.geometry.addAttribute("position", new THREE.BufferAttribute(position,3));
  219. //line.geometry.setAttribute('position', new THREE.Float32BufferAttribute(new Float32Array(position), 3));
  220. line.geometry.attributes.position.needsUpdate = true;
  221. line.geometry.computeBoundingSphere();
  222. /* if(line.material instanceof THREE.LineDashedMaterial){
  223. line.computeLineDistances() //只有非buffer的geometry才有
  224. } */
  225. }
  226. ,
  227. }
  228. var convertTool = {
  229. getPos2d : function(point, camera, dom){//获取一个三维坐标对应屏幕中的二维坐标
  230. var camera = camera || player.camera;
  231. var dom = dom || player.domElement;
  232. if(!camera)return
  233. 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);
  234. var x,y;
  235. x = (pos.x + 1) / 2 * dom.clientWidth;
  236. y = (1 - (pos.y + 1) / 2) * dom.clientHeight;
  237. var inSight = x <= dom.clientWidth && x >= 0 //是否在屏幕中
  238. && y <= dom.clientHeight && y >= 0
  239. return {
  240. pos: new THREE.Vector2(x,y), // 屏幕像素坐标
  241. vector: pos, //(范围 -1 ~ 1)
  242. trueSide : pos.z<1, //trueSide为false时,即使在屏幕范围内可见,也是反方向的另一个不可以被渲染的点 参见Tag.update
  243. inSight : inSight //在屏幕范围内可见
  244. };
  245. },
  246. ifShelter: function (pos3d, pos2d, camera, floorIndex) {
  247. //检测某点在视线中是否被mesh遮挡
  248. if (!pos2d) pos2d = convertTool.getPos2d(pos3d )
  249. camera = camera || player.camera
  250. var ori = new THREE.Vector3(pos2d.x, pos2d.y, -1).unproject(camera) //找到视线原点
  251. var dir = pos3d.clone().sub(ori).normalize()
  252. var ray = new THREE.Raycaster(ori, dir); //由外向里 因为模型从内侧是可见的所以从外侧
  253. /* if(config.isEdit && publicObjectSet.editor.mainDesign.editing){
  254. var o = ray.intersectObjects(publicObjectSet.editor.mainDesign.wallMeshes);
  255. }else{ */
  256. let colliders = player.model.allFloorsVisible ? player.model.colliders : (floorIndex != void 0 ? player.model.floors.index[floorIndex] : player.model.currentFloor).collider.children
  257. //let colliders = (floorIndex == void 0 ) ? player.model.colliders : player.model.floors.index[floorIndex].collider.children
  258. var o = ray.intersectObjects(colliders);
  259. //}
  260. var len = pos3d.distanceTo(ori);
  261. if (o && o.length) {
  262. for(var i=0;i<o.length;i++){
  263. if(o[i].distance < len){ return true; }//有遮挡
  264. }
  265. }
  266. },
  267. /*
  268. 拖拽时,获取鼠标在拖拽面上的位置(需要借助另一个intersectPlane面来计算,即和相机方向一样的面,可保证铺满屏幕)
  269. 但是不一定能获取到,比如鼠标射线不朝向拖拽面时,即使获取也会是一个意外的反方向的交点。
  270. */
  271. getPosAtPlane : function(pos, info/* , mouse, camera */){ //pos:与intersectPlane的交点 见笔记
  272. var A = pos;
  273. var player = player;
  274. var mouse = player.mouse;
  275. var O = new THREE.Vector3(mouse.x, mouse.y, -1).unproject(player.camera);
  276. if(info.y != void 0){//地面线的
  277. var y = info.y;
  278. if(player.mode == "floorplan"/* || Math.abs(O.x-pos.x)<0.0001 && Math.abs(O.z-pos.z)<0.0001) */){
  279. //intersectPlane和地面平行,无交点
  280. var x = pos.x, z = pos.z;
  281. }else{
  282. if(y<player.camera.position.y && O.y <= A.y /* || y>player.camera.position.y && O.y >= A.y */)return null; //鼠标射线向上。因为相机一定位于地面以上(地面不会抬高到相机上吧?),所以无交点。
  283. if(O.y == A.y){console.log('一样??');return;}
  284. if(A.y == y){console.log('一样2??');return;}
  285. var r = (O.y-y)/(A.y-y);
  286. var x = (r*A.x-O.x)/(r-1);
  287. var z = (r*A.z-O.z)/(r-1);
  288. }
  289. }else{//垂直的也有越过消失点以后反向变化的情况,但使用时影响不大
  290. var N = info.normalVec;
  291. var P = info.pullPos;
  292. if(N.y != 0 ){console.log('N.y != 0');return;} //仅仅支持垂直于地面的的墙壁,目前都是
  293. if(O.z==A.z){console.log('O.z==A.z?');return;}
  294. if(N.z!=0 && N.x != 0){//直接用这个通用的也可以,支持斜线的墙
  295. //console.log('N.z==0 && N.x == 0?');
  296. var c = ( N.x*(A.x-O.x) + N.y*(A.y-O.y) + N.z*(A.z-O.z));
  297. if(c == 0){console.log("分母为0?? return;");return;}
  298. 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
  299. var x = t * (A.x - O.x) + O.x;
  300. var y = t * (A.y - O.y) + O.y;
  301. var z = t * (A.z - O.z) + O.z;
  302. /*原理: 已知空间直线L:(x-a)/m=(x-b)/n=(z-c)/p和空间平面π:Ax+By+Cz+D=0;
  303. 求直线L与平面π的交点的坐标。
  304. 把直线方程改写成参数形式:设(x-a)/m=(x-b)/n=(z-c)/p=t;
  305. 则x=mt+a;y=nt+b;z=pt+c;代入平面π的方程得:
  306. A(mt+a)+B(nt+b)+C(pt+c)+D=0
  307. 由此解得t=-(Aa+Bb+Cc+D)/(Am+Bn+Cp)
  308. 再代入参数方程即得交点的坐标(x,y,z). */
  309. }else if(N.x ==0 ){ //z与pullPos相等
  310. var z = P.z;
  311. if(O.y == A.y){console.log('一样??');return;}
  312. if(A.y == y){console.log('一样2??');return;}
  313. if(A.z == z){console.log('一样3??');return;}
  314. var r = (O.z-z)/(A.z-z);
  315. var x = (r*A.x-O.x)/(r-1);
  316. var y = (r*A.y-O.y)/(r-1);
  317. }else if(N.z == 0){//x与pullPos相等
  318. var x = P.x;
  319. if(O.y == A.y){console.log('一样??');return;}
  320. if(A.y == y){console.log('一样2??');return;}
  321. if(A.x == x){console.log('一样3??');return;}
  322. var r = (O.x-x)/(A.x-x);
  323. var y = (r*A.y-O.y)/(r-1);
  324. var z = (r*A.z-O.z)/(r-1);
  325. }
  326. }
  327. return new THREE.Vector3(x,y,z);
  328. },
  329. getMouseIntersect : function(camera, meshes, mouse){//获取鼠标和meshes交点
  330. var raycaster = new THREE.Raycaster;
  331. camera.updateMatrixWorld();
  332. var origin = new THREE.Vector3(mouse.x,mouse.y,-1).unproject(camera)
  333. , end = new THREE.Vector3(mouse.x,mouse.y,1).unproject(camera);
  334. var dir = end.sub(origin).normalize()
  335. raycaster.set(origin, dir);
  336. var n = raycaster.intersectObjects(meshes);
  337. if (0 === n.length)
  338. return null;
  339. return n[0];
  340. },
  341. ifIntersectChunks : function(A,B,options={}){//获取某个线段/射线和meshes的交点
  342. var dir = B.clone().sub(A).normalize();
  343. var len = options.InfinityLen ? Infinity : A.distanceTo(B) + (options.extLen||0);
  344. var ray = new THREE.Raycaster(A.clone(), dir, 0, len);
  345. var o = ray.intersectObjects(options.model || player.model.colliders);
  346. if (o && o.length)return o;
  347. if(options.throughWidth){ //允许最小宽度,防止穿过极小的缝隙导致撞墙感
  348. var normal = math.getNormal({points:[{x:A.x, y:A.z},{x:B.x, y:B.z}]});//线段法线
  349. normal.multiplyScalar(options.throughWidth)
  350. var normalVec3 = new THREE.Vector3(normal.x, 0, normal.y);
  351. var A2 = A.clone().add(normalVec3)
  352. ray.set(A2, dir);
  353. var o2 = ray.intersectObjects(options.model || player.model.colliders);
  354. ray.set(A.clone().add(normalVec3.negate()), dir);
  355. if (o2 && o2.length)return o2;
  356. var o3 = ray.intersectObjects(options.model || player.model.colliders);
  357. if (o3 && o3.length)return o3;
  358. }
  359. return null;
  360. },
  361. getPosAtSphere : function(pos3d, toPanoPos){
  362. var dir = pos3d.clone().sub(toPanoPos);
  363. dir.normalize();//然后计算在球中
  364. dir.multiplyScalar(Constants.skyRadius);
  365. dir.add(toPanoPos);
  366. return dir;
  367. } ,
  368. getScaleForConstantSize : function(op={}){ //获得规定二维大小的mesh的scale值。可以避免因camera的projection造成的mesh视觉大小改变。 来源:tag.updateDisc
  369. var w;
  370. var i = new THREE.Vector3, o = new THREE.Vector3, l = new THREE.Vector3, c = new THREE.Vector3, h = new THREE.Vector3
  371. if(!op.resolution){
  372. let renderSize = player.sceneRenderer.renderer.getSize()
  373. op.resolution = {x:renderSize.width, y:renderSize.height}
  374. }
  375. if(!op.camera){
  376. let camera = player.cameraControls.activeControl ? player.cameraControls.activeControl.camera : player.camera
  377. let camera2 = camera.clone();
  378. camera2.matrixWorld.copy(player.camera.matrixWorld) //因为其他原因该camera的matrixWorld被还原了,而player.camera的是正确的
  379. op.camera = camera2
  380. }
  381. if(op.width2d) w = op.width2d //如果恒定二维宽度
  382. else{//否则考虑上距离,加一丢丢近大远小的效果
  383. var currentDis, nearBound, farBound
  384. if(op.camera.type == "OrthographicCamera"){
  385. currentDis = (op.camera.right - op.camera.left) / op.camera.zoom
  386. }else{
  387. currentDis = op.position.distanceTo(op.camera.position);
  388. }
  389. w = op.maxSize - ( op.maxSize - op.minSize) * THREE.Math.smoothstep(currentDis, op.nearBound, op.farBound);
  390. //maxSize : mesh要表现的最大像素宽度; nearBound: 最近距离,若比nearBound近,则使用maxSize
  391. }
  392. i.copy(op.position).project(op.camera), //tag中心在屏幕上的二维坐标
  393. o.set(op.resolution.x / 2, op.resolution.y / 2, 1).multiply(i), //转化成px -w/2 到 w/2的范围
  394. l.set(w / 2, 0, 0).add(o), //加上tag宽度的一半
  395. c.set(2 / op.resolution.x, 2 / op.resolution.y, 1).multiply(l), //再转回 -1 到 1的范围
  396. h.copy(c).unproject(op.camera);//再转成三维坐标,求得tag边缘的位置
  397. var g = h.distanceTo(op.position)//就能得到tag的三维半径
  398. return g //可能NAN 当相机和position重叠时
  399. } ,
  400. updateVisible : function(object, reason, ifShow, level=0, type){//当所有加入的条件都不为false时才显示. reason='force'一般是强制、临时的
  401. if(!object.unvisibleReasons) object.unvisibleReasons = []; //如果length>0代表不可见
  402. if(!object.visibleReasons) object.visibleReasons = []; //在同级时,优先可见
  403. var update = function(){
  404. //先按从高到低的level排列
  405. object.unvisibleReasons = object.unvisibleReasons.sort((a,b)=>b.level-a.level)
  406. object.visibleReasons = object.visibleReasons.sort((a,b)=>b.level-a.level)
  407. var maxVisiLevel = object.visibleReasons[0] ? object.visibleReasons[0].level : -1
  408. var maxunVisiLevel = object.unvisibleReasons[0] ? object.unvisibleReasons[0].level : -1
  409. var shouldVisi = maxVisiLevel >= maxunVisiLevel
  410. var visiBefore = object.visible
  411. if(visiBefore != shouldVisi){
  412. object.visible = shouldVisi
  413. object.dispatchEvent({
  414. type: 'isVisible',
  415. visible: shouldVisi,
  416. reason,
  417. })
  418. }
  419. }
  420. if(ifShow){
  421. var index = object.unvisibleReasons.findIndex(e=>e.reason == reason)
  422. if(index > -1){
  423. type = 'cancel'
  424. object.unvisibleReasons.splice(index, 1);
  425. }
  426. if(type == 'add' ){
  427. if(!object.visibleReasons.some(e=>e.reason == reason)){
  428. object.visibleReasons.push({reason,level})
  429. }
  430. }
  431. }else{
  432. var index = object.visibleReasons.findIndex(e=>e.reason == reason)
  433. if(index > -1){
  434. type = 'cancel'
  435. object.visibleReasons.splice(index, 1);
  436. }
  437. if(type != 'cancel' ){
  438. if(!object.unvisibleReasons.some(e=>e.reason == reason)){
  439. object.unvisibleReasons.push({reason,level})
  440. }
  441. }
  442. }
  443. update()
  444. },
  445. getObjVisiByReason : function(object,reason){//获取在某条件下是否可见. 注: 用户在数据集选择可不可见为"datasetSelection"
  446. if(object.visible)return true
  447. else{
  448. return !object.unvisibleReasons || !object.unvisibleReasons.some(e=>e.reason == reason)
  449. }
  450. }
  451. }
  452. window.browser = { //提前定义
  453. isMobile: function() {
  454. var e = navigator.userAgent || navigator.vendor || window.opera;
  455. 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))
  456. },
  457. isFullscreen: function() {
  458. return document.fullscreenElement || document.mozFullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement
  459. },
  460. }
  461. window.expandCommon = function(common){
  462. Object.assign(common,{
  463. intervalTool : { //延时update,防止卡顿
  464. list:[],
  465. isWaiting:function(name, func, delayTime){
  466. if(!this.list.includes(name)){ //如果没有该项, 则开始判断
  467. var needWait = func(); //触发了改变,则等待一段时间后再自动判断
  468. if(needWait){
  469. this.list.push(name);
  470. setTimeout(()=>{
  471. var a = this.list.indexOf(name);
  472. this.list.splice(a,1);
  473. this.isWaiting(name, func, delayTime) //循环
  474. },delayTime)
  475. }
  476. }
  477. },
  478. },
  479. sortByScore : function(list, request, rank) {
  480. var i = request ? common.filterAll(list, request) : list
  481. return 0 === i.length ? null : i = i.map(function(e) {
  482. let scores = rank.map(function(f){return f(e)}) //add
  483. return {
  484. item: e,
  485. scores,
  486. score: scores.reduce(function(t, i) {
  487. return t + i
  488. }, 0)
  489. }
  490. }).sort(function(e, t) {
  491. return t.score - e.score;
  492. })
  493. },
  494. getVisiblePano : function(positions = [], panos, options={}){//add
  495. var visiblePanos = [];
  496. options.posAtPanos = options.posAtPanos || {}//在不同漫游点的positions
  497. panos.forEach((pano)=>{
  498. if(!pano.isAligned())return;
  499. var A = pano.position.clone();
  500. var posB = options.posAtPanos[pano.id] || positions;
  501. var posLength = posB.length
  502. for(let i=0;i<posLength;i++){
  503. var B = posB[i];
  504. var ray = new THREE.Raycaster(A.clone(), B.clone().sub(A).normalize(), 0, A.distanceTo(B) - (options.tolerance||0) )
  505. var o = ray.intersectObjects(options.model || player.model.colliders, true);
  506. if (!o || !o.length){ //只要有一点可见,就算整体可见
  507. visiblePanos.push(pano.id);
  508. break;
  509. }
  510. }
  511. })
  512. return visiblePanos
  513. }
  514. })
  515. }
  516. //--------------------------------------
  517. //管理js文件 获取modeldata.js 判断是否有特殊的字段,如果有就先加载SpecialScene.js 里面有对特殊场景处理的代码 否则就直接加载main
  518. var Manage = function(){
  519. this.weixinURL = "https://res.wx.qq.com/open/js/jweixin-1.2.0.js",
  520. this.time = "?"+new Date().getTime();
  521. this.loadAudio();
  522. // this.loadWeixin();
  523. }
  524. //动态加载js文件
  525. Manage.prototype.LoadJs = function(_files, succes){
  526. /* 已加载文件缓存列表,用于判断文件是否已加载过,若已加载则不再次加载*/
  527. var classcodes = [];
  528. var FileArray = [];
  529. if (typeof _files === "object") {
  530. FileArray = _files;
  531. } else {
  532. /*如果文件列表是字符串,则用,切分成数组*/
  533. if (typeof _files === "string") {
  534. FileArray = _files.split(",");
  535. }
  536. }
  537. if (FileArray != null && FileArray.length > 0) {
  538. var LoadedCount = 0;
  539. for (var i = 0; i < FileArray.length; i++) {
  540. loadFile(FileArray[i], function() {
  541. LoadedCount++;
  542. if (LoadedCount == FileArray.length) {
  543. try {
  544. succes();
  545. }
  546. catch(err) {
  547. console.log("err: 您未定义回调");
  548. }
  549. }
  550. })
  551. }
  552. }
  553. /*加载JS文件,url:文件路径,success:加载成功回调函数*/
  554. function loadFile(url, success) {
  555. if (!FileIsExt(classcodes, url)) {
  556. var _ThisType = GetFileType(url);
  557. var ThisType = _ThisType.indexOf("?") == -1 ? _ThisType : _ThisType.substring(0,_ThisType.indexOf("?"));
  558. var fileObj = null;
  559. if (ThisType == ".js") {
  560. fileObj = document.createElement('script');
  561. fileObj.src = url;
  562. } else if (ThisType == ".css") {
  563. fileObj = document.createElement('link');
  564. fileObj.href = url;
  565. fileObj.type = "text/css";
  566. fileObj.rel = "stylesheet";
  567. } else if (ThisType == ".less") {
  568. fileObj = document.createElement('link');
  569. fileObj.href = url;
  570. fileObj.type = "text/css";
  571. fileObj.rel = "stylesheet/less";
  572. }
  573. success = success || function() {};
  574. fileObj.onload = fileObj.onreadystatechange = function() {
  575. if (!this.readyState || 'loaded' === this.readyState || 'complete' === this.readyState) {
  576. success();
  577. classcodes.push(url)
  578. }
  579. }
  580. document.getElementsByTagName('head')[0].appendChild(fileObj);
  581. } else {
  582. success();
  583. }
  584. }
  585. /*获取文件类型,后缀名,小写*/
  586. function GetFileType(url) {
  587. if (url != null && url.length > 0) {
  588. return url.substr(url.lastIndexOf(".")).toLowerCase();
  589. }
  590. return "";
  591. }
  592. /*文件是否已加载*/
  593. function FileIsExt(FileArray, _url) {
  594. if (FileArray != null && FileArray.length > 0) {
  595. var len = FileArray.length;
  596. for (var i = 0; i < len; i++) {
  597. if (FileArray[i] == _url) {
  598. return true;
  599. }
  600. }
  601. }
  602. return false;
  603. }
  604. };
  605. //获取页面url后面的参数
  606. Manage.prototype.number = function(variable) {
  607. var query = window.location.search.substring(1);
  608. var vars = query.split("&");
  609. for (var i=0;i<vars.length;i++) {
  610. var pair = vars[i].split("=");
  611. if(pair[0] == variable){return pair[1];}
  612. }
  613. return(false);
  614. };
  615. Manage.prototype.loadWeixin = function() {
  616. var that = this;
  617. this.LoadJs(that.weixinURL+that.time,function(){ });
  618. }
  619. Manage.prototype.weixinShare = function() {
  620. console.log("weixinShare")
  621. $.ajax({
  622. url: 'https://www.4dage.com/wechat/jssdk/share/',
  623. type: "post",
  624. data: {
  625. 'uri': location.href.split('#')[0], //当前页面地址
  626. 'name': "四维5号" //哪个公众号,对应上方的名称
  627. },
  628. dataType: "jsonp",
  629. jsonpCallback: "success_jsonp",
  630. success: function (data, textStatus) {
  631. wx.config({
  632. debug: false,
  633. appId: data.appId,
  634. timestamp: data.timestamp,
  635. nonceStr: data.nonceStr,
  636. signature: data.signature,
  637. jsApiList: ['checkJsApi', 'onMenuShareTimeline',
  638. 'onMenuShareAppMessage', 'onMenuShareQQ',
  639. 'onMenuShareWeibo', 'hideMenuItems',
  640. 'showMenuItems', 'hideAllNonBaseMenuItem',
  641. 'showAllNonBaseMenuItem', 'translateVoice',
  642. 'startRecord', 'stopRecord', 'onRecordEnd',
  643. 'playVoice', 'pauseVoice', 'stopVoice',
  644. 'uploadVoice', 'downloadVoice', 'chooseImage',
  645. 'previewImage', 'uploadImage', 'downloadImage',
  646. 'getNetworkType', 'openLocation', 'getLocation',
  647. 'hideOptionMenu', 'showOptionMenu', 'closeWindow',
  648. 'scanQRCode', 'chooseWXPay',
  649. 'openProductSpecificView', 'addCard', 'chooseCard',
  650. 'openCard']
  651. });
  652. },
  653. error: function (XMLHttpRequest, textStatus, errorThrown) {
  654. console.log("jsonp.error:" + textStatus);
  655. }
  656. });
  657. var success_jsonp = function(json){
  658. console.log(json);
  659. };
  660. wx.ready(function(){
  661. // config信息验证后会执行ready方法,所有接口调用都必须在config接口获得结果之后,config是一个客户端的异步操作,所以如果需要在页面加载时就调用相关接口,则须把相关接口放在ready函数中调用来确保正确执行〿
  662. //对于用户触发时才调用的接口,则可以直接调用,不需要放在ready函数中〿
  663. //分享到朋友圈
  664. console.log(g_weixinObj)
  665. wx.onMenuShareTimeline({
  666. title: g_weixinObj.title, // 分享标题
  667. link: g_weixinObj.lineLink, // 分享链接
  668. imgUrl: g_weixinObj.imgUrl, // 分享图标
  669. desc: g_weixinObj.desc
  670. });
  671. //获取“分享给朋友”按钮点击状态及自定义分享内容接叿
  672. wx.onMenuShareAppMessage({
  673. title: g_weixinObj.title, // 分享标题
  674. desc: g_weixinObj.desc, // 分享描述
  675. link: g_weixinObj.lineLink, // 分享链接
  676. imgUrl: g_weixinObj.imgUrl, // 分享图标
  677. type: '', // 分享类型,music、video或link,不填默认为link
  678. dataUrl: '' // 如果type是music或video,则要提供数据链接,默认为空
  679. });
  680. wx.onMenuShareWeibo({
  681. title: g_weixinObj.title, // 分享标题
  682. desc: g_weixinObj.desc, // 分享描述
  683. link: g_weixinObj.lineLink, // 分享链接
  684. imgUrl: g_weixinObj.imgUrl, // 分享图标
  685. success: function () {
  686. // 用户确认分享后执行的回调函数
  687. },
  688. cancel: function () {
  689. // 用户取消分享后执行的回调函数
  690. }
  691. });
  692. wx.onMenuShareQZone({
  693. title: g_weixinObj.title, // 分享标题
  694. desc: g_weixinObj.desc, // 分享描述
  695. link: g_weixinObj.lineLink, // 分享链接
  696. imgUrl: g_weixinObj.imgUrl, // 分享图标
  697. success: function () {
  698. // 用户确认分享后执行的回调函数
  699. },
  700. cancel: function () {
  701. // 用户取消分享后执行的回调函数
  702. }
  703. });
  704. wx.onMenuShareQQ({
  705. title: g_weixinObj.title, // 分享标题
  706. desc: g_weixinObj.desc, // 分享描述
  707. link: g_weixinObj.lineLink, // 分享链接
  708. imgUrl: g_weixinObj.imgUrl, // 分享图标
  709. success: function () {
  710. // 用户确认分享后执行的回调函数
  711. },
  712. cancel: function () {
  713. // 用户取消分享后执行的回调函数
  714. }
  715. });
  716. wx.error(function(res){
  717. // config信息验证失败会执行error函数,如签名过期导致验证失败,具体错误信息可以打开config的debug模式查看,也可以在返回的res参数中查看,对于SPA可以在这里更新签名〿
  718. });
  719. });
  720. }
  721. Manage.prototype.dealURL = function(src, type){
  722. //music: "///super.4dage.com/data/LYW/edit/20200928_151633415.mp3"
  723. //"https://super.4dage.com/data/LYW/edit/20200928_165319399.jpg"]
  724. if(window.isLocal && settings.localPrefix!=void 0){//本地将线上的前缀替换
  725. var oldPrefix = 'super.4dage.com/'; //最简单的地址写一个,如果有其他完全不一样的地址就用数组逐个判断
  726. var index = src.indexOf(oldPrefix);
  727. if(index>-1){
  728. var wholeOldPrefix = src.slice(0, index+oldPrefix.length);
  729. return src.replace(wholeOldPrefix, settings.localPrefix)
  730. }else console.error("没有找到合适的本地链接")
  731. return src
  732. }else{
  733. //add https://
  734. var prefix = g_Prefix.replace('https://','').replace('http://','')
  735. if(!src.includes('http:/') && !src.includes('https:/') && src.includes(prefix)){
  736. src = 'https://'+src
  737. }
  738. return src
  739. }
  740. }
  741. Manage.prototype.removeSrcPostMark = function(url){//去除texture.load时自动加上的'?'
  742. var index = url.indexOf('?')
  743. if(index>-1){
  744. return url.slice(0, index)
  745. }else return url
  746. }
  747. Manage.prototype.showInfo = function (o) { // ({result:true, title:"发布成功"});
  748. var box = $(".resultBox");
  749. var title = o.title || o || i18n.get('保存成功');
  750. box.children().eq(0).html(title)
  751. //var time = o.time || THREE.Math.clamp((Config.lang=='en') ? title.length*50 : title.length*130 ,1300,5000);
  752. var time = o.time || THREE.Math.clamp(title.length*130 ,1300, 5000);
  753. o.time || console.log("showtime " + time)
  754. //实际有一半的时间在渐变透明度
  755. this.showInfoTimer && clearTimeout(this.showInfoTimer)
  756. box.removeClass("animate");//如果之后不久又要showinfo一个的话,先停止前面的animate
  757. setTimeout(function () {
  758. box.css(
  759. {
  760. '-webkit-animation-duration': time + 'ms',
  761. 'animation-duration': time + 'ms'
  762. }
  763. )
  764. if(o.top){
  765. box.children().css('top', o.top + "%");
  766. }else{
  767. box.children().css('top', '' )
  768. }
  769. box.removeClass("hide");
  770. box.addClass("animate");
  771. if (o.dontInteract) {//遮挡对屏幕的操作
  772. box.css('pointer-events', 'auto')
  773. } else {
  774. box.css('pointer-events', 'none')
  775. }
  776. this.showInfoTimer = setTimeout(function () {
  777. box.removeClass("animate");
  778. box.addClass("hide");
  779. this.showInfoTimer = null;
  780. }.bind(this), time + 20)
  781. }.bind(this), 50)//这个数字太小的话后面触发的没有重新animate的效果 应该要比帧率大吧
  782. }//like: manage.showInfo({title:'a', top:20})
  783. //公用的函数
  784. function getQueryVariable(variable)
  785. {
  786. var query = window.location.search.substring(1);
  787. var vars = query.split("&");
  788. for (var i=0;i<vars.length;i++) {
  789. var pair = vars[i].split("=");
  790. if(pair[0] == variable){return pair[1];}
  791. }
  792. return(false);
  793. }
  794. //隐藏公司Logo
  795. function showLogo(){
  796. $("#myCompany").hide();
  797. $("#loaderCoBrandName").hide();
  798. $("#title-logo").hide();
  799. $(".title-container").css("justify-content","center")
  800. }
  801. //czj 添加随机的时间
  802. function randomTime(){
  803. return new Date()
  804. }
  805. function matcher(data){
  806. if(!data || !g_version ) return data;
  807. delete data.model.vision_version;
  808. var _data = {
  809. files: {
  810. "templates": ["images/images{{number}}/{{filename}}"]
  811. },
  812. model :{
  813. sid :window.number,
  814. camera_start:
  815. data.model.images && data.model.images.length != 0 ?
  816. {
  817. camera: {
  818. zoom: "-1",
  819. quaternion: [
  820. JSON.parse(data.model.images[0].metadata).camera_quaternion.z,
  821. JSON.parse(data.model.images[0].metadata).camera_quaternion.w,
  822. JSON.parse(data.model.images[0].metadata).camera_quaternion.x,
  823. JSON.parse(data.model.images[0].metadata).camera_quaternion.y
  824. ]
  825. },
  826. pano: { uuid: JSON.parse(data.model.images[0].metadata).scan_id },
  827. mode: "0"
  828. }
  829. : ''
  830. },
  831. sid: window.number,
  832. hoticon: {
  833. default: "https://super.4dage.com/images/4dagePoint2.png",
  834. higt: "https://super.4dage.com/images/4dagePoint.png"
  835. },
  836. special: "false",
  837. weixinDesc: ""
  838. };
  839. $.extend(true,data,_data)
  840. return data;
  841. }
  842. function hotMatcher(data={}){
  843. //if(!data || !g_version) return data;
  844. if(g_version) {
  845. data.tourAudio = data.audio || {};
  846. }else{
  847. data.tourAudio = {}
  848. }
  849. return data;
  850. }
  851. var GifTexDeal = {
  852. animateObjects : [],
  853. animateTexs : [] ,
  854. addAnimation : function(texture, owner, info, id){
  855. /* if(this.animateObjects.find(e=>
  856. e.texture == texture && !ifSame(info, e.info)
  857. )) */
  858. var animation
  859. var tex = this.animateTexs.find(e=>e.texture == texture)
  860. if(tex){
  861. animation = tex
  862. }else{
  863. animation = {texture,info }
  864. this.animateTexs.push(animation)
  865. this.setRepeart(animation)
  866. }
  867. var object = {
  868. animation, //默认相同的texture对应的info是一样的, 对应一个animation
  869. owner,
  870. }
  871. this.animateObjects.push(object)
  872. return object
  873. },
  874. remove : function(object){
  875. var index = this.animateObjects.indexOf(object)
  876. if(index>-1){
  877. this.animateObjects.splice(index, 1)
  878. if(!this.animateObjects.find(e=>e.animation == object.animation)){
  879. let i = this.animateTexs.indexOf(object.animation)
  880. this.animateTexs.splice(i, 1)
  881. object.animation.texture.repeat.set(1,1)
  882. }
  883. this.stop(object)
  884. }
  885. },
  886. setRepeart : function(animation){
  887. animation.texture.repeat.set(1/animation.info.cellXcount, 1/animation.info.cellYcount)
  888. },
  889. start: function(object){
  890. if(!object || object.started )return;
  891. object.started = true
  892. if(object.animation.started)return;
  893. object.animation.started = true
  894. var info = object.animation.info
  895. var count = info.cellXcount * info.cellYcount - (info.voidCount || 0)
  896. if(count <= 1)return;
  897. transitions.start( (progress)=>{
  898. var index = Math.floor(count * progress);
  899. var indexX = index % info.cellXcount
  900. var indexY = info.cellYcount - Math.floor(index /info.cellXcount ) - 1; //uv.offset.y是从下到上的
  901. object.animation.texture.offset.x = indexX / info.cellXcount;
  902. object.animation.texture.offset.y = indexY / info.cellYcount;
  903. //console.log(object.id + " : "+ object.texture.offset.toArray())
  904. } , info.duration * (-1), null,/* ()=>{//done (-1):循环
  905. object.started = false
  906. object.texture.offset.x = 0;
  907. object.texture.offset.y = 0;
  908. this.start(object)
  909. }, */ 0 ,null, object.id, "gif_"+object.animation.texture.id);
  910. },
  911. stop: function(object){
  912. if(!object || !object.started)return;
  913. object.started = false
  914. //只有该object对应的texture对应的所有object都停止了,才能真的停止动画:
  915. if(this.animateObjects.find(e=>e.animation == object.animation && e.started)) return;
  916. transitions.cancelById("gif_"+object.animation.texture.id);
  917. object.animation.texture.offset.set(0,0)
  918. object.animation.started = false
  919. }
  920. }
  921. var CloneObject = function(copyObj, result, isSimpleCopy, extraReplace) {
  922. //isSimpleCopy只复制最外层
  923. //复制json result的可能:普通数字或字符串、普通数组、复杂对象
  924. if(!copyObj)return copyObj //0 null undefined ''
  925. result = result || {};
  926. if (copyObj instanceof Array) {
  927. /* if (copyObj[0]instanceof Object) {
  928. //不支持含有 [[Object]] 这样二级数组里面还是复杂数据的,普通和复杂的数据混合可能也不支持
  929. console.error("不支持含有 [[Object]] 这样二级数组里面还是复杂数据的...")
  930. }
  931. return copyObj.slice(0);*/ //如果是数组,直接复制返回(排除数组内是object
  932. return copyObj.map(e=>{
  933. if(e instanceof Object){
  934. return CloneObject(e)
  935. }else return e
  936. })
  937. }else{
  938. if(copyObj.clone instanceof Function ){ //解决一部分
  939. return copyObj.clone()
  940. }
  941. }
  942. for (var key in copyObj) {
  943. if (copyObj[key] instanceof Object && !isSimpleCopy)
  944. result[key] = CloneObject(copyObj[key]);
  945. else
  946. result[key] = copyObj[key];
  947. //如果是函数类同基本数据,即复制引用
  948. }
  949. return result;
  950. }
  951. ;
  952. var ifSame = function(object1, object2){
  953. if(object1 == object2 )return true // 0 != undefined , 0 == ''
  954. else if(!object1 || !object2) return false
  955. else if(object1.constructor != object2.constructor){
  956. return false
  957. }else if(object1 instanceof Array ) {
  958. if(object1.length != object2.length)return false;
  959. var _object2 = object2.slice(0);
  960. for(let i=0;i<object1.length;i++){
  961. var u = _object2.find(e=>ifSame(object1[i], e));
  962. if(u == void 0 && !_object2.includes(u) && !object1.includes(u))return false;
  963. else{
  964. let index = _object2.indexOf(u);
  965. _object2.splice(index,1);
  966. }
  967. }
  968. return true
  969. }else if(object1.equals instanceof Function ){//复杂数据仅支持这种,其他的可能卡住?
  970. return object1.equals(object2)
  971. }else if(typeof object1 == 'number' || typeof object1 == 'string'){
  972. if(isNaN(object1) && isNaN(object2))return true
  973. else return object1 == object2
  974. }else if(typeof object1 == "object"){
  975. var keys1 = Object.keys(object1)
  976. var keys2 = Object.keys(object2)
  977. if(!ifSame(keys1,keys2))return false;
  978. for(let i in object1){
  979. var same = ifSame(object1[i], object2[i]);
  980. if(!same)return false
  981. }
  982. return true
  983. }else{
  984. console.log('isSame出现例外')
  985. }
  986. }
  987. function initByTHREE(THREE){
  988. window.bus = new THREE.EventDispatcher();//因为player一开始总是没创建好,所以加一个事件传递器
  989. THREE.TransitionPass = function ( scene, camera ) {
  990. this.renderScene = scene;
  991. this.renderCamera = camera;
  992. this.coverRenderTarget = new THREE.WebGLRenderTarget( 100, 100, {
  993. minFilter: THREE.LinearFilter, magFilter: THREE.LinearFilter,
  994. format: THREE.RGBAFormat
  995. });
  996. this.coverTex = this.coverRenderTarget.texture;
  997. this.enabled = false;
  998. this.oldClearColor = new THREE.Color();
  999. this.oldClearAlpha = 1;
  1000. this.camera = new THREE.OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
  1001. this.scene = new THREE.Scene();
  1002. this.material = this.getMaskMaterial()
  1003. var copyShader = THREE.CopyShader;
  1004. this.materialCopy = new THREE.ShaderMaterial( {
  1005. uniforms: this.copyUniforms,
  1006. vertexShader: copyShader.vertexShader,
  1007. fragmentShader: copyShader.fragmentShader,
  1008. blending: THREE.NoBlending,
  1009. depthTest: false,
  1010. depthWrite: false,
  1011. transparent: true
  1012. } );
  1013. this.quad = new THREE.Mesh( new THREE.PlaneBufferGeometry( 2, 2 ), this.material);
  1014. this.quad.frustumCulled = false; // Avoid getting clipped
  1015. this.scene.add( this.quad );
  1016. }
  1017. THREE.TransitionPass.prototype = {//波形扩散,出下一个画面
  1018. constructor: THREE.TransitionPass,
  1019. setSize: function ( width, height ) {
  1020. this.coverRenderTarget.setSize( width, height );
  1021. },
  1022. render: function ( renderer, writeBuffer, readBuffer, delta, maskActive ) {
  1023. var oldAutoClear = renderer.autoClear;
  1024. renderer.autoClear = false;
  1025. var uniforms = this.quad.material.uniforms
  1026. uniforms.bgTex.value = readBuffer.texture; //更新
  1027. uniforms.coverTex.value = this.coverTex;
  1028. uniforms.progress.value = player.model.skybox.material.uniforms.progress.value//
  1029. uniforms.screenRatio.value = player.domElement.clientWidth / player.domElement.clientHeight;// 使波纹为圆形
  1030. uniforms.screenRatio.value *= uniforms.screenRatio.value
  1031. renderer.render( this.scene, this.camera);
  1032. renderer.autoClear = oldAutoClear;
  1033. },
  1034. start:function(sceneRenderer){
  1035. this.enabled = true
  1036. //draw coverTex
  1037. this.quad.material.uniforms.progress.value = 1;
  1038. sceneRenderer.renderer.render( sceneRenderer.scene, sceneRenderer.camera, this.coverRenderTarget, true );
  1039. console.log('start111')
  1040. },
  1041. stop:function(){
  1042. this.enabled = false
  1043. console.log('stop111')
  1044. }
  1045. ,
  1046. getMaskMaterial :function(){
  1047. return new THREE.ShaderMaterial( {
  1048. uniforms: {
  1049. coverTex: {
  1050. type: "t",
  1051. value: null
  1052. },
  1053. bgTex: {
  1054. type: "t",
  1055. value: null
  1056. },
  1057. progress:{
  1058. type: "f",
  1059. value: 0
  1060. },
  1061. screenRatio:{
  1062. type: "f",
  1063. value: 1
  1064. }
  1065. },
  1066. vertexShader: `
  1067. varying vec2 vUv;
  1068. void main()
  1069. {
  1070. vUv = uv;
  1071. gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
  1072. }
  1073. `,
  1074. fragmentShader: `
  1075. uniform sampler2D coverTex;
  1076. uniform sampler2D bgTex;
  1077. uniform float progress;
  1078. uniform float screenRatio;
  1079. varying vec2 vUv;
  1080. void main() {
  1081. const float maxRadius = 0.708; // sqrt(0.5^2+0.5^2)
  1082. const float minRadius = 0.0 ;
  1083. 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));
  1084. float diff = 0.292; //1.0-maxRadius;
  1085. float radiusIn = maxRadius * progress + minRadius * (1.0-progress);
  1086. float radiusOut = radiusIn + diff;
  1087. if(radius < radiusIn) {
  1088. gl_FragColor = texture2D(bgTex, vUv);
  1089. //gl_FragColor = vec4(0.0,0.0,1.0,1.0);//
  1090. }else if(radius>radiusOut){
  1091. gl_FragColor = texture2D(coverTex, vUv) ;
  1092. //gl_FragColor = vec4(1.0,1.0,0.0,1.0);//
  1093. }else{
  1094. vec4 color1 = texture2D(bgTex, vUv);
  1095. vec4 color2 = texture2D(coverTex, vUv);
  1096. float rotio = smoothstep(radiusIn ,radiusOut,radius);
  1097. gl_FragColor = mix(color1, color2, rotio);
  1098. }
  1099. }
  1100. `
  1101. } );
  1102. },
  1103. }
  1104. let labels = []
  1105. class Label2D extends THREE.EventDispatcher{
  1106. constructor(o={}){
  1107. super()
  1108. this.position = o.position
  1109. this.elem = $(o.innerHTML || '<div ><a></a></div>');
  1110. $(o.domElement).append(this.elem)
  1111. this.pos2d = new THREE.Vector3
  1112. this.elem.css({position: 'absolute', 'z-index':999})
  1113. this.clickFun = o.clickFun;
  1114. this.clickFun && this.elem.on('click',this.clickFun.bind(this))
  1115. if(o.autoUpdate){
  1116. let update = (e)=>{if(e.cameraChanged) this.update()}
  1117. player.on("view.changed",update) //确保player存在
  1118. this.addEventListener('dispose', (e)=>{
  1119. player.off("view.changed",update)
  1120. })
  1121. }
  1122. this.visible = true
  1123. this.shelterByModel = o.shelterByModel
  1124. this.floorIndex = o.floorIndex
  1125. labels.push(this)
  1126. if(window.player.model){
  1127. this.init()
  1128. }else{
  1129. let f = ()=>{
  1130. window.bus.removeEventListener('playerAndModelReady',f)
  1131. this.init()
  1132. }
  1133. window.bus.addEventListener('playerAndModelReady',f)
  1134. }
  1135. }
  1136. init(){
  1137. if(this.floorIndex != void 0){
  1138. player.model.on("floor.changed",(currentFloor, mode, oldFloor)=>{
  1139. this.update(currentFloor) //注: currentFloor 这时候还没成为 model.currentFloor
  1140. })
  1141. }
  1142. }
  1143. update(currentFloor){
  1144. if(!this.position || !this.visible)return
  1145. var p = convertTool.getPos2d(this.position);
  1146. if(!p || !p.trueSide){
  1147. this.elem.css('display','none'); return;
  1148. }
  1149. //判断label是否被模型遮挡,遮挡则消失(如果是漫游模式最好提前计算visiblePanos)
  1150. if(player.mode != 'panorama'){
  1151. currentFloor = currentFloor || player.model.currentFloor
  1152. if(!player.model.allFloorsVisible && this.floorIndex != void 0 && this.floorIndex!= currentFloor.floorIndex){
  1153. this.elem.css('display','none'); return;
  1154. }
  1155. if(this.shelterByModel && convertTool.ifShelter(this.position , p.vector, player.camera, this.floorIndex )){
  1156. this.elem.css('display','none'); return;
  1157. }
  1158. }
  1159. this.elem.css({
  1160. left: p.pos.x +'px',
  1161. top: p.pos.y +'px'
  1162. })
  1163. /* if(settings.vrEnabled){
  1164. this.elem.css({transform:'rotate('+window.screenFaceOrient+'deg)'})
  1165. }else{
  1166. this.elem.css({transform:''})
  1167. } */
  1168. this.elem.css('display','block');
  1169. this.pos2d = p.vector;
  1170. }
  1171. setVisible(visi, reason, level=0, type){
  1172. convertTool.updateVisible(this, reason, visi, level, type )
  1173. if(!this.visible){
  1174. this.elem.css('display','none');
  1175. }else{
  1176. this.update()
  1177. }
  1178. }
  1179. setPos(pos){
  1180. this.position = pos;
  1181. this.update()
  1182. }
  1183. dispose(){
  1184. this.elem.remove();
  1185. this._listeners = {}
  1186. this.dispatchEvent({type:'dispose'})
  1187. let index = labels.indexOf(this)
  1188. index > -1 && labels.splice(index,1)
  1189. }
  1190. }
  1191. window.Label2D = Label2D
  1192. class RoomLabel extends Label2D{
  1193. constructor(o){
  1194. if(o.position instanceof Array) o.position = new THREE.Vector3().fromArray(o.position)
  1195. o.innerHTML = `<div class="room-label" ><a><p><span>${o.title}</span></p></a></div>`
  1196. o.domElement = $(".widgets-doll-labels")[0]
  1197. o.shelterByModel = true , o.autoUpdate = true
  1198. o.clickFun = ()=>{
  1199. if(player.roomLebelClickUnabled)return
  1200. let result = common.sortByScore(player.model.floors.index[this.floorIndex].panos, [], [(pano)=>{
  1201. return -pano.position.distanceToSquared(this.position)
  1202. }]);
  1203. player.flyToPano({
  1204. pano : result && result[0] && result[0].item
  1205. })
  1206. }
  1207. super(o)
  1208. this.setTitle(o.title )
  1209. }
  1210. init(){
  1211. super.init()
  1212. //飞入后不可见
  1213. player.on("mode.changing",(oldMode, mode, pano, duration)=>{//准备飞
  1214. this.setStyle(oldMode, mode, duration)
  1215. })
  1216. this.setStyle()
  1217. }
  1218. setStyle(oldMode, mode, duration){
  1219. if(!mode) mode = player.modeTran.split('-')[1] || player.mode //要变成的mode或当前mode
  1220. if(mode == 'panorama'){
  1221. this.setVisible(false, 'isPanorama')
  1222. }else if(oldMode == 'panorama'){
  1223. setTimeout(()=>{
  1224. this.setVisible(true, 'isPanorama')
  1225. },duration*0.7)
  1226. }
  1227. }
  1228. setTitle(title){
  1229. this.title = title || ''
  1230. this.elem.html(`<a><p><span>${this.title}</span></p></a>`)
  1231. }
  1232. setEditSelect(state){//编辑页面用
  1233. this.editing = !!state
  1234. this.setVisible(state, 'editSelected', 1, state ? 'add':'cancel') //强制可见
  1235. }
  1236. }
  1237. window.RoomLabel = RoomLabel
  1238. let f = ()=>{
  1239. window.bus.removeEventListener('playerAndModelReady',f)
  1240. player.on("mode.changing",(currentMode, mode, pano, duration)=>{
  1241. let noLine = mode == 'floorplan';
  1242. if(noLine){
  1243. $('.widgets-doll-labels').addClass('noLine').addClass('noCorner')
  1244. }else{
  1245. $('.widgets-doll-labels').removeClass('noLine').removeClass('noCorner')
  1246. }
  1247. })
  1248. player.on("view.changed",(e)=>{
  1249. if(e.cameraChanged){
  1250. //if(needUpdateZIndex){ //如果某个label显示时需要更新index的话,加个参数
  1251. let label_ = labels.filter(e=>e.elem[0].style.display == 'block')
  1252. label_.sort((a,b)=>b.pos2d.z - a.pos2d.z)
  1253. label_.forEach((e,index)=>e.elem.css('z-index', index+1000));
  1254. //}
  1255. }
  1256. })
  1257. player.model.hotGroup.children.length ? logSth() : player.on('gotHotAndStartload',logSth)
  1258. }
  1259. window.bus.addEventListener('playerAndModelReady',f) //player model currentPano都已有
  1260. window.bus.dispatchEvent({type: 'THREE_inited'})
  1261. }
  1262. //最好能知道应该播放到的currentTime
  1263. var SoundManager = {//暂不支持同时播放
  1264. currentAudio:null,//当前正在播放list中的哪一个
  1265. enableSound:true,//是否允许有声音
  1266. playHistory:[],//被打断的加入播放历史
  1267. list:[ ],//同一级别可以互相打断 //暂时不做多级别
  1268. play:function(name, src, currentTime){
  1269. var object = this.list.find(e=>e.name == name)
  1270. if(object){
  1271. if(this.currentAudio){
  1272. this.pause(this.currentAudio.name, false, true)
  1273. }
  1274. {//将当前要播放的播放历史中清除
  1275. let index = this.playHistory.indexOf(object)
  1276. if(index>-1)this.playHistory.splice(index,1);
  1277. }
  1278. this.currentAudio = object
  1279. if(src){
  1280. this.setSrc(name, src)
  1281. }
  1282. if(currentTime!=void 0){
  1283. object.audio.currentTime = currentTime
  1284. }
  1285. if(object.audio && object.src){
  1286. object.audio.load(); // iOS 9 还需要额外的 load 一下, 否则直接 play 无效 *///https://www.cnblogs.com/interdrp/p/4211883.html 部分资料
  1287. object.audio.play();
  1288. object.audio.paused || object.callback && object.callback(true)
  1289. Log(name + ' 播放 ' )
  1290. }
  1291. }
  1292. },
  1293. pause:function(name, autoReplayLast, isInterrupt){//需要能自动恢复上一个被打算的音频。恢复前判断是否还需要播放
  1294. var object = this.list.find(e=>e.name == name)
  1295. if(object && this.currentAudio == object){
  1296. this.currentAudio = null
  1297. if(object.audio){
  1298. object.audio.pause()
  1299. object.callback && object.callback(false)
  1300. object.audio.src && Log(name + ' 中断音频 '+ "("+common.getFileNameFromUrl(object.audio.src)+')' )
  1301. }
  1302. if(isInterrupt){//一般主动调用不需要加这个
  1303. this.playHistory.push(object)//如果是被中断的,加入播放历史,等待恢复播放
  1304. }
  1305. if(autoReplayLast){ //播放之前的音频。它们是被打断过的。
  1306. while(this.playHistory.length){
  1307. var last = this.playHistory.pop();
  1308. if(last.src && last.canplay(last.audio)){
  1309. this.play(last.name )
  1310. }
  1311. }
  1312. }
  1313. }
  1314. },
  1315. setSrc : function(name, src){//不能直接给audio赋src!一定要用这个函数!因为我要拿这里的src来判断有无src,因为貌似audio的src会自动变,''时会变成html的链接
  1316. var object = this.list.find(e=>e.name == name)
  1317. object.src = src
  1318. object.audio.src = src
  1319. Log(`${object.name} 设置src: ${src}`)
  1320. },
  1321. createAudio:function(object={}){//name, level, canplay
  1322. if(!object.fake){
  1323. object.audio = new Audio();
  1324. object.audio.loop = !!object.loop;
  1325. //object.audio.autoplay = true;
  1326. object.audio.addEventListener('ended', ()=>{
  1327. if(object.loop){//循环
  1328. Log(`${object.name} 播放完毕,重新播放`)
  1329. object.audio.play()
  1330. }else{
  1331. this.pause(object.name, true);//停止后的后续处理
  1332. }
  1333. });
  1334. object.audio.oncanplaythrough = ()=>{
  1335. Log(`${object.name} canplaythrough `)
  1336. }
  1337. }
  1338. this.list.push(object)
  1339. },
  1340. initAutoPlay:function(){ //处理设备自动播放限制
  1341. let play = function(){
  1342. if (this.currentAudio && this.currentAudio.audio && this.currentAudio.src && this.currentAudio.audio.paused ) {
  1343. this.currentAudio.audio.play() //一般触屏了都会播放成功,就不识别paused了
  1344. this.currentAudio.callback && this.currentAudio.callback(true)
  1345. Log(`${this.currentAudio.name} 自动播放成功`) //即使设置src在这之后好像也能成功播放
  1346. }else{
  1347. }
  1348. document.removeEventListener("touchstart",play);
  1349. document.removeEventListener("click",play);
  1350. $('#player')[0].removeEventListener("touchstart", play);
  1351. }.bind(this);
  1352. document.addEventListener("WeixinJSBridgeReady", play, false);
  1353. document.addEventListener("touchstart", play);//ios需要加个事件才能播放 不能自动播放;如果还有浏览器不行,换成别的交互事件
  1354. document.addEventListener("click", play);
  1355. $('#player')[0].addEventListener("touchstart", play);
  1356. }
  1357. }
  1358. function Log(value, color, fontSize){
  1359. color = color || '#13f'
  1360. fontSize = fontSize || 14
  1361. console.warn(`%c${value}`, `color:${color};font-size:${fontSize}px`)
  1362. }
  1363. Manage.prototype.loadAudio = function() { //相关:g_tourAudio \ g_playAudio
  1364. //热点页面因为挡住了界面,所以暂时不存在别的音频阻止热点音频的可能
  1365. //box视频都静音,所以暂时不考虑
  1366. SoundManager.createAudio({
  1367. name:'bgm',
  1368. level:0,
  1369. src:'',
  1370. loop:true,
  1371. canplay:(audio)=>{
  1372. return this.bgmShouldPlay
  1373. },
  1374. callback:(state)=>{//play或pause时随之触发的函数(即使还没开始播放)
  1375. if(state){
  1376. $("#volume a img").attr("src", "./images/Volume btn_off.png")
  1377. $("#volume").attr("title", "关闭声音");
  1378. }else{
  1379. $("#volume a img").attr("src", "./images/Volume btn_on.png")
  1380. $("#volume").attr("title", "打开声音");
  1381. }
  1382. }
  1383. })
  1384. SoundManager.createAudio({
  1385. name:'tour',
  1386. level:0,
  1387. src:'',
  1388. loop:false,
  1389. canplay:(audio)=>{
  1390. return player.director && player.director.tourIsPlaying && player.director.getAudio()
  1391. }
  1392. })
  1393. SoundManager.createAudio({
  1394. name:'hot',
  1395. fake:true,//实际上没有audio. 只是为了来停止和续播其他音频
  1396. level:1,
  1397. src:'',
  1398. loop:false,
  1399. canplay:(audio)=>{
  1400. }
  1401. })
  1402. $("#volume").find("a").on("click", ()=> {
  1403. if($("#volume img")[0].src.indexOf("btn_on.png")>-1)
  1404. {
  1405. this.switchBgmState(true);
  1406. }
  1407. else if($("#volume img")[0].src.indexOf("btn_off.png")>-1)
  1408. {
  1409. this.switchBgmState(false);
  1410. }
  1411. })
  1412. // this.switchBgmState(true);//初始设置允许播放bgm
  1413. SoundManager.initAutoPlay()
  1414. }
  1415. Manage.prototype.switchBgmState = function(state){//按钮的状态完全代表是否应该播放bgm,即使还没加载完
  1416. this.bgmShouldPlay = state
  1417. if(state){
  1418. SoundManager.play('bgm')
  1419. }else{
  1420. SoundManager.pause('bgm')
  1421. }
  1422. /* if(!g_bgAudio || !g_bgAudio.src) return;
  1423. var played = function(){
  1424. console.log('begin play bgm');
  1425. g_play = 1;
  1426. g_playAudio = g_bgAudio;
  1427. g_tourAudio && g_tourAudio.pause()
  1428. }
  1429. var paused = function(){
  1430. g_play = 0;
  1431. g_playAudio == g_bgAudio && (g_playAudio = null)
  1432. }
  1433. if(state ){
  1434. g_bgAudio.play();
  1435. if(g_bgAudio.paused){
  1436. paused()
  1437. }else{
  1438. played()
  1439. return true
  1440. }
  1441. }else{
  1442. g_bgAudio.pause();
  1443. paused()
  1444. }
  1445. g_bgAudio.pauseByHot = false
  1446. g_bgAudio.pauseByTour = false */
  1447. }
  1448. var manage = new Manage();
  1449. //处理cursor优先级
  1450. var CursorDeal = {
  1451. priorityEvent : [//在前面的优先级高
  1452. {"noIntersect":'not-allowed'},
  1453. {"addHot":'cell'},
  1454. {"hoverFootIcon":'pointer'},
  1455. {"hoverHot":'pointer'},
  1456. {"addLabel":'cell'},
  1457. {"moveLabel":'grab'},
  1458. ],
  1459. domElements :[$('#player')[0]],
  1460. list:[], //当前存在的cursor状态
  1461. currentCursorIndex:null,
  1462. /* init : function(viewer){
  1463. this.priorityEvent.forEach(e=>{//刚开始Potree.resourcePath没值,现在换
  1464. for(let i in e){
  1465. e[i] = Common.replaceAll(e[i],'{Potree.resourcePath}',Potree.resourcePath)
  1466. }
  1467. })
  1468. this.domElements = [viewer.renderArea, viewer.mapViewer.renderArea];
  1469. viewer.addEventListener("CursorChange",(e)=>{
  1470. if(e.action == 'add'){
  1471. this.add(e.name)
  1472. }else{
  1473. this.remove(e.name)
  1474. }
  1475. })
  1476. }, */
  1477. add : function(name){
  1478. var priorityItem = this.priorityEvent.find(e=>e[name])
  1479. if(!priorityItem){
  1480. console.error('CursorDeal 未定义优先级 name:'+ name);
  1481. return
  1482. }
  1483. if(!this.list.includes(name)){
  1484. this.judge({addItem: priorityItem, name})
  1485. this.list.push(name)
  1486. }
  1487. },
  1488. remove : function(name){
  1489. var index = this.list.indexOf(name);
  1490. if(index > -1){
  1491. this.list.splice(index, 1)
  1492. this.judge()
  1493. }
  1494. },
  1495. judge:function(o={}){
  1496. //console.log(o,this.list)
  1497. if(o.addItem){
  1498. var addIndex = this.priorityEvent.indexOf(o.addItem)
  1499. if(addIndex < this.currentCursorIndex || this.currentCursorIndex == void 0){
  1500. this.domElements.forEach(e=>e.style.cursor = o.addItem[o.name] )
  1501. this.currentCursorIndex = addIndex
  1502. }
  1503. }else{
  1504. var levelMax = {index:Infinity, cursor:null }
  1505. this.list.forEach(name=>{
  1506. var priorityItem = this.priorityEvent.find(e=>e[name])
  1507. var index = this.priorityEvent.indexOf(priorityItem)
  1508. if(index < levelMax.index){
  1509. levelMax.index = index;
  1510. levelMax.cursor = priorityItem[name]
  1511. }
  1512. })
  1513. this.currentCursorIndex = levelMax.index
  1514. this.domElements.forEach(e=>e.style.cursor = levelMax.cursor || '')
  1515. }
  1516. }
  1517. }
  1518. function logSth(){
  1519. let hotCount = player.model.hotGroup.children.length
  1520. let videoCount = player.model.hotGroup.children.filter(e=>e.texType == 'video').length
  1521. let photoCount = player.model.hotGroup.children.filter(e=>e.texType == 'photo').length
  1522. let shineCount = player.model.hotGroup.children.filter(e=>e.texType == 'shine').length
  1523. let aniCount = player.model.hotGroup.children.filter(e=>e.info.animateInfo).length
  1524. let objCount = player.model.hotGroup.children.filter(e=>e.objObject).length
  1525. let chunkLen = player.model.chunks.length
  1526. let vertexC = player.model.chunks.reduce(function(total, chunk ){return total+chunk.geometry.attributes.position.count}, 0)
  1527. let panoCount = player.model.panos.list.length
  1528. Log(`共有chunk个数 ${chunkLen} ( 顶点数 ${vertexC} )
  1529. 热点个数 ${hotCount} ( vedio ${videoCount} 个,photo ${photoCount} 个,shine ${shineCount}个。 gif ${aniCount} 个,obj ${objCount} 个
  1530. 漫游点数 ${panoCount} 个)`, '#FF4399', 14)
  1531. }
  1532. window.sceneFrom = number.slice(0,3) == 'KJ-' ? 'kankan' : '' //看看or看见转来的
  1533. //兼容一代的場景
  1534. //請求地址統一管理
  1535. var g_onePregix = "https://bigscene.4dage.com/" //对应一代 http://www.4dmodel.com/SuperPanoramic/index.html?m=55
  1536. var g_version = manage.number("version");
  1537. g_version === "one" ? g_Prefix = g_onePregix : '';