webgl_rxdz_clipImg.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. <template src="./webgl_rxdz_clipImg.html">
  2. </template>
  3. <script>
  4. import * as THREE from 'three';
  5. import {OrbitControls} from 'three/addons/controls/OrbitControls.js';
  6. import {getStorage} from '@/utils/localStorage';
  7. import { MessageBox } from 'mint-ui';
  8. var requestId = "";
  9. const util = require('@/utils/util.js').default;
  10. import commonPageMethod from '@/mixins/commonPageMethod.js';
  11. import screenshot from '@/mixins/screenshot.js';
  12. // import commonPageMethod from '@/common/commonPageMethod.js';
  13. export default {
  14. mixins: [commonPageMethod,screenshot],
  15. /**
  16. * 页面的初始数据
  17. */
  18. data() {
  19. return {
  20. pvCurPageName: "webgl_720",
  21. locusBehaviorName: "720展示",
  22. pvCurPageParams: null,
  23. houseId: "",
  24. pvId: 'p_2cmina_23121201',
  25. canvas: null,
  26. navbar: {
  27. showCapsule: 1,
  28. title: '',
  29. titleColor: '#000',
  30. navPadding: 0,
  31. navPaddingBg: 'transparent',
  32. navBarColor: 'transparent',
  33. navBackColor: 'transparent',
  34. haveCallback: true, // 如果是 true 会接手 navbarBackClk
  35. fromShare: false,
  36. fromProject: 0,
  37. shareToken: "",
  38. pageName: this.pvCurPageName,
  39. },
  40. id: '', // 户型编号
  41. loader: null,
  42. scene: null,
  43. camera: null,
  44. controlStarPosition: {
  45. x: 0,
  46. y: 0,
  47. z: 0
  48. }, //控制器初始位置
  49. cameraStarPosition: {
  50. x: 0,
  51. y: 0,
  52. z: 5
  53. }, //摄像头初始位置
  54. cameraLastPosition: null, //摄像头上一次移动到的位置
  55. controlLastPosition: null, //观察点上一次移动到的位置
  56. myLoadingStatus: false,
  57. repeatFlag: false, //重复点击
  58. canvasHeight:'',
  59. isIOS: false,
  60. videoUrl:'', //绿幕视频地址
  61. bgUrl:'',
  62. width:'620',
  63. height:'620',
  64. left:'65',
  65. top:'300',
  66. startX:0,
  67. startY:0,
  68. clientX:0,
  69. clientY:0,
  70. unit:0.5,
  71. screenWidth:0,
  72. screenHeight:0,
  73. type:1,
  74. bottomLeftX:0,
  75. bottomLeftY:0,
  76. }
  77. },
  78. beforeDestroy() {
  79. cancelAnimationFrame(requestId, this.canvas)
  80. this.worker && this.worker.terminate()
  81. if (this.renderer instanceof THREE.WebGLRenderer) {
  82. // 遍历场景中的所有子对象,找到类型为Mesh的对象并移除
  83. let deleList = this.scene.children.filter(object => {
  84. if (object instanceof THREE.Mesh) {
  85. return object
  86. }
  87. })
  88. if (deleList && deleList.length > 0) {
  89. this.scene.remove(...deleList);
  90. }
  91. this.scene.traverse(function(object) {
  92. if (object instanceof THREE.Mesh) {
  93. if (object.geometry && typeof(object.geometry.dispose) == 'function') {
  94. object.geometry.dispose();
  95. }
  96. if (object.material && typeof(object.material.dispose) == 'function') {
  97. object.material.dispose();
  98. }
  99. if (object.texture && typeof(object.texture.dispose) == 'function') {
  100. object.texture.dispose();
  101. }
  102. }
  103. });
  104. this.renderer.clear();
  105. this.renderer.dispose();
  106. this.renderer.forceContextLoss();
  107. this.renderer.context = null;
  108. this.renderer.domElement = null;
  109. this.renderer = null;;
  110. }
  111. console.warn("***beforeDestroy-webgl_rxdz_clipImg***");
  112. },
  113. mounted(options) {
  114. var that = this;
  115. console.warn("***webgl_rxdz_roam-options***", this.$route.query)
  116. this.isIOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
  117. this.videoUrl = this.$route.query.videoUrl || 'https://dm.static.elab-plus.com/miniProgram/007.mp4';
  118. this.bgUrl = this.$route.query.bgUrl || 'https://dm.static.elab-plus.com/miniProgram/tears_of_steel_bridge_2k.jpg';
  119. let screenWidth = window.screen.width;
  120. let screenHeight = window.screen.height;
  121. if (window.innerWidth && window.screen.width) {
  122. this.screenWidth = screenWidth = Math.min(window.innerWidth, window.screen.width);
  123. }
  124. if (window.innerHeight && window.screen.height) {
  125. this.screenHeight = screenHeight = Math.min(window.innerHeight, window.screen.height)
  126. }
  127. let unit = screenWidth / 750; //单位rpm 对应 px 的值
  128. this.unit = unit;
  129. this.width = this.width * unit;
  130. this.height = this.height * unit;
  131. this.left = this.left * unit;
  132. this.top = this.top * unit;
  133. this.canvasHeight = screenHeight;
  134. this.houseId = this.$route.query.houseId ? this.$route.query.houseId : '';
  135. this.spaceId = this.$route.query.spaceId ? this.$route.query.spaceId : '';
  136. let container = this.$refs.webgl;
  137. let canvas3d = this.canvas = this.$refs.glcanvas;
  138. //uniapp 兼容写法,因为uni的页面对象的Vue 实例是$vm
  139. let camera = null,
  140. renderer = null;
  141. let needRender = false; //是否需要渲染 false表示不需要渲染;true 表示需要渲染
  142. let scene = this.scene = new THREE.Scene();
  143. let controls = null,
  144. boundary = null;
  145. let videoMesh = null;
  146. init();
  147. // this.clearEvent = clearEvent;
  148. // this.attendEvent = attendEvent;
  149. this.starRender = starRender; //对外暴露启动渲染的方法
  150. this.stopRender = stopRender; //对外暴露停止渲染的方法
  151. function init() {
  152. // 创建相机位置
  153. camera = new THREE.PerspectiveCamera(120, screenWidth / that.canvasHeight, 0.1, 10000);
  154. // camera.up.set(0, 1, 0);//俯视状态,将相机的up向量设置为z轴负方向 {x:0,y:1,z:0}
  155. camera.position.set(that.cameraStarPosition.x, that.cameraStarPosition.y, that.cameraStarPosition.z);
  156. scene.add(camera);
  157. that.camera = camera;
  158. // 环境光会均匀的照亮场景中的所有物体
  159. // const ambientLight = new THREE.AmbientLight(0xFFEFE0, 3.5);
  160. // scene.add(ambientLight);
  161. // 辅助方格
  162. // const axesHelper = new THREE.AxesHelper( 50 );
  163. // scene.add( axesHelper );
  164. // const gridHelper = new THREE.GridHelper(50, 10, 0xcccccc, 0xcccccc);
  165. // gridHelper.position.y = 0;
  166. // gridHelper.position.x = 0;
  167. // scene.add(gridHelper);
  168. //加载环境720贴图
  169. const loader = new THREE.TextureLoader();
  170. const texture = loader.load(that.bgUrl, () => {
  171. const rt = new THREE.WebGLCubeRenderTarget(texture.image.height);
  172. rt.fromEquirectangularTexture(renderer, texture);
  173. scene.background = rt.texture;
  174. });
  175. //antialias 这个值得设置为false,不然IOS上截图会失效
  176. renderer = that.renderer = new THREE.WebGLRenderer({
  177. canvas:canvas3d,
  178. alpha: true,
  179. antialias:false,
  180. // 如果想保存three.js canvas画布上的信息,注意设置preserveDrawingBuffer
  181. preserveDrawingBuffer: true,
  182. });
  183. renderer.setPixelRatio(window.devicePixelRatio);
  184. renderer.setSize(screenWidth, that.canvasHeight);
  185. container.appendChild(renderer.domElement);
  186. controls = new OrbitControls(camera, renderer.domElement);
  187. controls.enableDamping = true; //启动缓动
  188. controls.minDistance = 0.0001;
  189. controls.maxDistance = 30;
  190. // controls.minPolarAngle = 0; // 默认0
  191. // controls.maxPolarAngle = Math.PI / 2; // 默认Math.PI,即可以向下旋转到的视角。
  192. controls.enableZoom = true; //启用摄像机的缩放
  193. controls.enablePan = true; //禁用摄像机平移
  194. controls.enableRotate = true; //启用摄像机水平或垂直旋转
  195. // 监听相机移动事件-限制只能在当前空间范围内移动
  196. // controls.addEventListener('change', () => {
  197. // // 检查相机位置是否超出边界框
  198. // if (boundary && !boundary.containsPoint(camera.position)) {
  199. // let clampedPosition = new THREE.Vector3();
  200. // boundary.clampPoint(camera.position, clampedPosition);
  201. // if (clampedPosition) {
  202. // camera.position.copy(clampedPosition);
  203. // }
  204. // }
  205. // });
  206. camera.lookAt(that.controlStarPosition.x, that.controlStarPosition.y, that.controlStarPosition.z);
  207. starRender(); //启动渲染
  208. // var guideMask = document.querySelector('#guide-mask');
  209. if(that.isIOS){
  210. document.addEventListener("WeixinJSBridgeReady", function (){
  211.     videoHandle();
  212. }, false)
  213. }else{
  214. document.addEventListener("touchstart", ()=> {
  215. // guideMask.classList.add('guide-mask-hide');
  216. setTimeout(()=>{
  217. videoHandle();
  218. },200)
  219. }, false);
  220. }
  221. }
  222. function videoHandle() {
  223. if(videoMesh){
  224. return false
  225. }
  226. // 创建视频元素
  227. // var video = document.createElement('video');
  228. var video = document.getElementById('myvideo');
  229. video.src = that.videoUrl; // 视频文件的路径
  230. video.setAttribute("crossOrigin", "Anonymous");
  231. video.loop = true;
  232. video.muted = true;
  233. video.controls = false;
  234. video.setAttribute('webkit-playsinline', true);
  235. video.setAttribute('playsinline', true);
  236. // video['custom-cache'] = false;
  237. // video['x5-playsinline'] = '';
  238. // video['webkit-playsinline'] = true;
  239. // video['playsinline'] = true;
  240. // video['x-webkit-airplay'] = '';
  241. // // video['x5-video-player-fullscreen'] = false;
  242. // video['x5-video-player-type'] = 'h5-page';
  243. video.play();
  244. console.warn("***video***",video,video.width);
  245. // 创建视频纹理
  246. var videoTexture = new THREE.VideoTexture(video);
  247. // videoTexture.minFilter = THREE.LinearFilter;
  248. // videoTexture.format = THREE.RGBFormat;
  249. var keyColorObject = new THREE.Color("#00ff05");
  250. var myuniforms = {
  251. pointTexture: {
  252. type: "t",
  253. value: videoTexture
  254. },
  255. color: {
  256. type: "c",
  257. value: keyColorObject
  258. },
  259. videowidth: {
  260. type: "f",
  261. value: 501.0
  262. },
  263. videoheight: {
  264. type: "f",
  265. value: 1024.0
  266. },
  267. filterType: {
  268. type: "i",
  269. value: 0
  270. },
  271. lightLevel: {
  272. type: "f",
  273. value: 0.2
  274. },
  275. gridSize: {
  276. type: "f",
  277. value: 0.8
  278. }
  279. };
  280. // 创建绿幕着色器
  281. let greenScreenShader = {
  282. uniforms: myuniforms,
  283. transparent: true,
  284. vertexShader: `
  285. varying vec2 vUv;
  286. void main() {
  287. vUv = uv;
  288. vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );
  289. gl_Position = projectionMatrix * mvPosition;
  290. } `,
  291. fragmentShader: `
  292. precision mediump float;
  293. uniform sampler2D pointTexture;
  294. uniform sampler2D colorlut;
  295. uniform vec3 color;
  296. uniform float videowidth;
  297. uniform float videoheight;
  298. uniform int filterType;
  299. uniform float gridSize;
  300. uniform float lightLevel;
  301. varying vec2 vUv;
  302. float alter=3.0;
  303. float u_mode=0.0;
  304. float u_threshold=1.0;
  305. float u_clipBlack=0.9;
  306. float u_clipWhite=1.0;
  307. float rgb2cb(float r, float g, float b){
  308. return 0.5 + -0.168736*r - 0.331264*g + 0.5*b;
  309. }
  310. float rgb2cr(float r, float g, float b){
  311. return 0.5 + 0.5*r - 0.418688*g - 0.081312*b;
  312. }
  313. float smoothclip(float low, float high, float x){
  314. if (x <= low){
  315. return 0.0;
  316. }
  317. if(x >= high){
  318. return 1.0;
  319. }
  320. return (x-low)/(high-low);
  321. }
  322. vec4 greenscreen(vec4 colora, float Cb_key,float Cr_key, float tola,float tolb, float clipBlack, float clipWhite){
  323. float cb = rgb2cb(colora.r,colora.g,colora.b);
  324. float cr = rgb2cr(colora.r,colora.g,colora.b);
  325. float alpha = distance(vec2(cb, cr), vec2(Cb_key, Cr_key));
  326. alpha = smoothclip(tola, tolb, alpha);
  327. float r = max(gl_FragColor.r - (1.0-alpha)*color.r, 0.0);
  328. float g = max(gl_FragColor.g - (1.0-alpha)*color.g, 0.0);
  329. float b = max(gl_FragColor.b - (1.0-alpha)*color.b, 0.0);
  330. if(alpha < clipBlack){
  331. alpha = r = g = b = 0.0;
  332. }
  333. if(alpha > clipWhite){
  334. alpha = 1.0;
  335. }
  336. if(clipWhite < 1.0){
  337. alpha = alpha/max(clipWhite, 0.9);
  338. }
  339. return vec4(r,g,b, alpha);
  340. }
  341. void main()
  342. {
  343. gl_FragColor = texture2D( pointTexture, vUv );
  344. float tola = 0.0;
  345. float tolb = u_threshold/2.0;
  346. float cb_key = rgb2cb(color.r, color.g, color.b);
  347. float cr_key = rgb2cr(color.r, color.g, color.b);
  348. gl_FragColor = greenscreen(gl_FragColor, cb_key, cr_key, tola, tolb, u_clipBlack, u_clipWhite);
  349. if(u_mode > 0.5 && u_mode < 1.5){
  350. gl_FragColor = mix(vec4(1.0, 1.0, 1.0, 1.0), gl_FragColor, gl_FragColor.a);
  351. gl_FragColor.a = 1.0;
  352. }
  353. if(u_mode > 1.5 && u_mode < 2.5){
  354. gl_FragColor = vec4(gl_FragColor.a, gl_FragColor.a, gl_FragColor.a, 1.0);
  355. }
  356. if(filterType==1){
  357. float gray = 0.2989*gl_FragColor.r+0.5870*gl_FragColor.g+0.1140*gl_FragColor.b;
  358. gl_FragColor = vec4(gray,gray,gray , gl_FragColor.a);
  359. }else if(filterType==2){
  360. vec3 tColor2 = texture2D( pointTexture, vec2(vUv[0]+(1.0/videowidth) , vUv[1]) ).rgb;
  361. vec3 tColor3 = texture2D( pointTexture, vec2(vUv[0]-(1.0/videowidth) , vUv[1]) ).rgb;
  362. vec3 tColor4 = texture2D( pointTexture, vec2(vUv[0]+(1.0/videowidth) , vUv[1]+(1.0/videoheight)) ).rgb;
  363. vec3 tColor5 = texture2D( pointTexture, vec2(vUv[0]-(1.0/videowidth) , vUv[1]-(1.0/videoheight)) ).rgb;
  364. vec3 tColor6 = texture2D( pointTexture, vec2(vUv[0]+(1.0/videowidth) , vUv[1]-(1.0/videoheight)) ).rgb;
  365. vec3 tColor7 = texture2D( pointTexture, vec2(vUv[0]-(1.0/videowidth) , vUv[1]+(1.0/videoheight)) ).rgb;
  366. vec3 tColor8 = texture2D( pointTexture, vec2(vUv[0] , vUv[1]+(1.0/videoheight)) ).rgb;
  367. vec3 tColor9 = texture2D( pointTexture, vec2(vUv[0] , vUv[1]+(1.0/videoheight)) ).rgb;
  368. vec3 tColor10 = texture2D( pointTexture, vec2(vUv[0]+(2.0/videowidth) , vUv[1]) ).rgb;
  369. vec3 tColor11 = texture2D( pointTexture, vec2(vUv[0]+(2.0/videowidth) , vUv[1]) ).rgb;
  370. gl_FragColor = vec4( (gl_FragColor.r+tColor2[0]+tColor3[0]+tColor4[0]+tColor5[0]+tColor6[0]+tColor7[0]+tColor8[0]+tColor9[0]+tColor10[0]+tColor11[0])/11.0,
  371. (gl_FragColor.g+tColor2[1]+tColor3[1]+tColor4[1]+tColor5[1]+tColor6[1]+tColor7[1]+tColor8[1]+tColor9[1]+tColor10[1]+tColor11[1])/11.0,
  372. (gl_FragColor.b+tColor2[2]+tColor3[2]+tColor4[2]+tColor5[2]+tColor6[2]+tColor7[2]+tColor8[2]+tColor9[2]+tColor10[2]+tColor11[2])/11.0,
  373. gl_FragColor.a);
  374. }else if(filterType==3){
  375. float brightr=gl_FragColor.r+lightLevel;
  376. float brightg=gl_FragColor.g+lightLevel;
  377. float brightb=gl_FragColor.b+lightLevel;
  378. gl_FragColor = vec4(brightr,brightg,brightb , gl_FragColor.a);
  379. }else if(filterType==4){
  380. float reverser=1.0 - gl_FragColor.r;
  381. float reverseg=1.0 - gl_FragColor.g;
  382. float reverseb=1.0 - gl_FragColor.b;
  383. gl_FragColor = vec4(reverser,reverseg,reverseb,gl_FragColor.a);
  384. }else if(filterType==5){
  385. float dx = fract(sin(dot(vUv ,vec2(12.9898,78.233))) * 43758.5453);
  386. vec3 cResult = gl_FragColor.rgb + gl_FragColor.rgb * clamp( 0.1 + dx, 0.0, 1.0 );
  387. vec2 sc = vec2( sin( vUv.y * 4096.0 ), cos( vUv.y * 4096.0 ) );
  388. cResult += gl_FragColor.rgb * vec3( sc.x, sc.y, sc.x ) * 0.025;
  389. cResult = gl_FragColor.rgb + clamp( 0.35, 0.0,1.0 ) * ( cResult - gl_FragColor.rgb );
  390. if( false ) {
  391. cResult = vec3( cResult.r * 0.3 + cResult.g * 0.59 + cResult.b * 0.11 );
  392. }
  393. float oldr=0.393*cResult[0]+0.769*cResult[1]+0.189*cResult[2];
  394. float oldg=0.349*cResult[0]+0.686*cResult[1]+0.168*cResult[2];
  395. float oldb=0.272*cResult[0]+0.534*cResult[1]+0.131*cResult[2];
  396. gl_FragColor = vec4( oldr,oldg,oldb , gl_FragColor.a);
  397. }else if(filterType==6){
  398. float average = ( gl_FragColor.r + gl_FragColor.g + gl_FragColor.b ) / 2.0;
  399. float s = sin( 0.5 ), c = cos( 0.5 );
  400. vec2 tex = vUv * vec2(videowidth,videoheight) - vec2(0,0);
  401. vec2 point = vec2( c * tex.x - s * tex.y, s * tex.x + c * tex.y ) * gridSize;
  402. float pattern = ( sin( point.x ) * sin( point.y ) ) * 4.0;
  403. float seed = average * 10.0 - 5.0 + pattern ;
  404. gl_FragColor = vec4( seed*0.3+gl_FragColor.r*0.7,seed*0.3+gl_FragColor.g*0.7 ,seed*0.3+gl_FragColor.b*0.7, gl_FragColor.a );
  405. }
  406. }
  407. `,
  408. };
  409. // 创建绿幕材质
  410. let greenScreenMaterial = new THREE.ShaderMaterial(greenScreenShader);
  411. greenScreenMaterial.side = THREE.DoubleSide;
  412. let geometry = new THREE.PlaneGeometry(9, 16);
  413. // 应用绿幕材质到对象上
  414. let mesh = new THREE.Mesh(geometry, greenScreenMaterial);
  415. mesh.position.set(0, 0, -10);//设置视频位置
  416. // mesh.lookAt(camera.position);
  417. scene.add(mesh);
  418. videoMesh = mesh;
  419. }
  420. function stopRender() {
  421. needRender = false;
  422. }
  423. function starRender() {
  424. if (needRender == true) { //如果已经在渲染中了,则不能再次开启,避免渲染过多
  425. false;
  426. }
  427. needRender = true;
  428. render(); //开始渲染
  429. }
  430. function render() {
  431. if (needRender == false) {
  432. return false;
  433. }
  434. if(videoMesh){
  435. videoMesh.lookAt(camera.position);
  436. }
  437. renderer.render(scene, camera); //单次渲染
  438. requestId = requestAnimationFrame(render, canvas3d);
  439. }
  440. },
  441. methods: {
  442. async clipImgHandle(){
  443. this.bottomLeftX = this.left;
  444. this.bottomLeftY = this.screenHeight - this.top - this.height;
  445. console.warn("***clipImgHandle***")
  446. let shottingImg = await this.shottingAction(3) + "?x-oss-process=image/auto-orient,1/quality,Q_46/format,jpg";//开始截图
  447. console.warn("***clipImgHandle1***",shottingImg);
  448. // alert(shottingImg)
  449. // alert('getClipPicUrl3'+img.width)
  450. // MessageBox({
  451. // title: '提示',
  452. // message: shottingImg,
  453. // showCancelButton: true
  454. // });
  455. // window.open(shottingImg, "_blank");
  456. window.location.href = shottingImg
  457. },
  458. navbarBackClk() {
  459. },
  460. clearHandle() {
  461. this.clearEvent();
  462. },
  463. mytouchstart(e,type) {
  464. console.warn("***mytouchstart***",type)
  465. this.type = type;
  466. this.startLeft = this.left;
  467. // this.clientX = 0;
  468. // this.clientY = 0;
  469. this.startX = e.changedTouches[0].clientX;
  470. this.startY = e.changedTouches[0].clientY;
  471. e.preventDefault();
  472. },
  473. mytouchmove(e) {
  474. let startX = this.startX; // 开始x坐标
  475. let startY = this.startY; //开始y坐标
  476. let touchMoveX = e.changedTouches[0].clientX //滑动变化坐标
  477. let touchMoveY = e.changedTouches[0].clientY //滑动变化坐标
  478. // this.clientX = touchMoveX - startX;
  479. // this.clientY = touchMoveY - startY;
  480. this.widthHandle(touchMoveX,1);
  481. e.preventDefault();
  482. },
  483. mytouchend(e) {
  484. },
  485. widthHandle(touchMoveX){
  486. let clientX = touchMoveX - this.startX;
  487. if(this.type==1){//左上角
  488. if(clientX < 0){//左移动
  489. let _juli = Math.abs(clientX);
  490. this.left = this.startLeft - _juli;
  491. this.width = this.screenWidth - (this.left * 2);
  492. if(this.left < 0){
  493. this.left = 0;
  494. this.width = this.screenWidth;
  495. }
  496. }else if(clientX > 0){//右移动
  497. let _juli = Math.abs(clientX);
  498. this.left = this.startLeft + _juli;
  499. this.width = this.screenWidth - (this.left * 2);
  500. if(this.left > (this.screenWidth - 200)/2){
  501. this.left = (this.screenWidth - 200)/2;
  502. this.width = 200;
  503. }
  504. }
  505. this.height = this.width;
  506. }else if(this.type==2){//右上角
  507. if(clientX < 0){//左移动
  508. let _juli = Math.abs(clientX);
  509. this.left = this.startLeft + _juli;
  510. this.width = this.screenWidth - (this.left * 2);
  511. if(this.left > (this.screenWidth - 200)/2){
  512. this.left = (this.screenWidth - 200)/2;
  513. this.width = 200;
  514. }
  515. }else if(clientX > 0){//右移动
  516. let _juli = Math.abs(clientX);
  517. this.left = this.startLeft - _juli;
  518. this.width = this.screenWidth - (this.left * 2);
  519. if(this.left < 0){
  520. this.left = 0;
  521. this.width = this.screenWidth;
  522. }
  523. }
  524. this.height = this.width;
  525. }else if(this.type==3){//右下角
  526. if(clientX < 0){//左移动
  527. let _juli = Math.abs(clientX);
  528. this.left = this.startLeft + _juli;
  529. this.width = this.screenWidth - (this.left * 2);
  530. if(this.left > (this.screenWidth - 200)/2){
  531. this.left = (this.screenWidth - 200)/2;
  532. this.width = 200;
  533. }
  534. }else if(clientX > 0){//右移动
  535. let _juli = Math.abs(clientX);
  536. this.left = this.startLeft - _juli;
  537. this.width = this.screenWidth - (this.left * 2);
  538. if(this.left < 0){
  539. this.left = 0;
  540. this.width = this.screenWidth;
  541. }
  542. }
  543. this.height = this.width;
  544. }else if(this.type==4){//左下角
  545. if(clientX < 0){//左移动
  546. let _juli = Math.abs(clientX);
  547. this.left = this.startLeft - _juli;
  548. this.width = this.screenWidth - (this.left * 2);
  549. if(this.left < 0){
  550. this.left = 0;
  551. this.width = this.screenWidth;
  552. }
  553. }else if(clientX > 0){//右移动
  554. let _juli = Math.abs(clientX);
  555. this.left = this.startLeft + _juli;
  556. this.width = this.screenWidth - (this.left * 2);
  557. if(this.left > (this.screenWidth - 200)/2){
  558. this.left = (this.screenWidth - 200)/2;
  559. this.width = 200;
  560. }
  561. }
  562. this.height = this.width;
  563. }
  564. // this.unit = unit;
  565. // this.width = this.width * unit;
  566. // this.height = this.height * unit;
  567. // this.left = this.left * unit;
  568. // this.top = this.top * unit;
  569. }
  570. }
  571. }
  572. </script>
  573. <style lang="scss" scoped>
  574. @import "./webgl_rxdz_clipImg.scss";
  575. /* @import "@/common/css/common.css"; */
  576. </style>