|
@@ -253,6 +253,24 @@ var Common = {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+
|
|
|
+ cleanUrl(url){//斜杠处理 协议aaa://保留双斜杠,其余单斜杠
|
|
|
+ //分离协议和路径部分
|
|
|
+ const protocolMatch = url.match(/^(\w+:)\/{2,}/);
|
|
|
+
|
|
|
+ if (protocolMatch) {
|
|
|
+ const protocol = protocolMatch[1];
|
|
|
+ const path = url.slice(protocolMatch[0].length);
|
|
|
+ return protocol + '//' + path.replace(/\/+/g, '/');
|
|
|
+ } else {
|
|
|
+ return url.replace(/\/+/g, '/');
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ joinUrl(){//拼接地址。总是出现前后多个/造成双斜杠或者缺斜杠的问题,处理一下
|
|
|
+ return this.cleanUrl(Array.from(arguments).join('/'))
|
|
|
+ },
|
|
|
+
|
|
|
dealURL(url=''){
|
|
|
let urlNew = this.replaceAll(url, "+", "%2B"); //this.replaceAll(url, "\\+", "%2B");// 浏览器似乎不支持访问带+的地址
|
|
|
|
|
@@ -604,6 +622,35 @@ var Common = {
|
|
|
|
|
|
},
|
|
|
|
|
|
+
|
|
|
+ mobileAutoPlay(media, playFun){//移动端。不这么写video不会播放 . (2022.11.29: 可为何加了Hot.updateHots之后又会自动播了?https有关?
|
|
|
+
|
|
|
+
|
|
|
+ if(this.autoPlayList.includes(media))return
|
|
|
+ this.autoPlayList.push(media)
|
|
|
+ viewer.addEventListener
|
|
|
+ let events = ['global_touchstart','global_mousedown']
|
|
|
+
|
|
|
+ let fun = ()=>{
|
|
|
+ let index = this.autoPlayList.indexOf(media)
|
|
|
+ if(index>-1){
|
|
|
+
|
|
|
+ console.log( 'try autoplay '+ media.src)
|
|
|
+ playFun()
|
|
|
+ this.autoPlayList.splice(index,1)
|
|
|
+ events.forEach((eventName)=>{
|
|
|
+ viewer.removeEventListener(eventName,fun)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ events.forEach((eventName)=>{
|
|
|
+ viewer.addEventListener(eventName,fun)
|
|
|
+ })
|
|
|
+
|
|
|
+
|
|
|
+ },
|
|
|
+
|
|
|
/* changeShaderToWebgl2(vs, fs, matType, otherReplaces=[]){//部分shader要根据webgl版本作更改
|
|
|
if(!Potree.settings.isWebgl2)return {vs, fs}
|
|
|
let turnTo300 = matType != 'ShaderMaterial' && (vs.includes('gl_FragDepthEXT') || fs.includes('gl_FragDepthEXT') )
|