import '../scss/main.scss' import '../scss/iphonex1.scss' import '../scss/swiper-4.1.6.min.css' import * as THREE from 'three'; import 'three/examples/js/loaders/GLTFLoader'; import Swiper from './lib/swiper-4.1.6.min'; import UTIL from './util'; import Video from './video'; import 'three/examples/js/controls/OrbitControls'; import touch from './lib/touch'; // 全景图 import negx from '../texture/wzrybg/negx.jpg' import negy from '../texture/wzrybg/negy.jpg' import negz from '../texture/wzrybg/negz.jpg' import posx from '../texture/wzrybg/posx.jpg' import posy from '../texture/wzrybg/posy.jpg' import posz from '../texture/wzrybg/posz.jpg' var container, controls; var camera, scene, renderer; var projectiveObj;//定义上次投射到的对象 var raycaster = new THREE.Raycaster();//光线投射器 var mouse = new THREE.Vector2();//二维向量 /** * 添加鼠标点击事件,捕获点击时当前选中的物体 */ document.body.addEventListener('touchmove', function(e) { e.preventDefault() }, {passive: false}) var href=document.getElementsByTagName('a'); for(var i=0;i 0) { var currentProjectiveObjT = intersects[0].object; if (projectiveObj != currentProjectiveObjT) { if((currentProjectiveObjT instanceof THREE.AxisHelper) || (currentProjectiveObjT instanceof THREE.GridHelper)){ //穿过的是坐标轴线和网格线 return; } projectiveObj = intersects[0].object; } } else { projectiveObj = null; } } init(); animate() // ---- 弹窗交互相关 ------ var timer var scrollFlag = false var frontCameraSwiper = null var screenSwiper = null var planeSwiper = null var faceSwiper = null var backCameraSwiper = null var View = { init() { this.setVideoSrc() this.handleModal() }, setVideoSrc() { var vids = [8904623, 8908143, 8908435,8909221, 8925251,8925097] var videoEls = { '8904623': 'face-video1', '8908143': 'back-camera-video', '8908435': 'front-camera-video', '8925251': 'screen-video1', '8925097': 'suggest-video', '8909221': 'plane-video' } Video.getVideoSource(vids, videoEls) }, videoPause() { var videoList = document.getElementsByTagName('video') for(var i = 0; i < videoList.length; i++) { videoList[i].pause() } }, handleModal() { var $videoCon = $('.full-video-wrap') touch.tap('.close-full-video', function(e){ console.log(e) $(this).parent().hide() $videoCon.find('video').hide() var videoList = document.getElementsByTagName('video') for(var i = 0; i < videoList.length; i++) { videoList[i].pause() } }) touch.tap('.full-video-wrap', function(e){ $(this).hide() $videoCon.find('video').hide() var videoList = document.getElementsByTagName('video') for(var i = 0; i < videoList.length; i++) { videoList[i].pause() } }) document.getElementById('tips-masker').addEventListener('touchstart', function() { $('.tips-masker').hide() }) // 屏幕 document.getElementById('screen-poster').addEventListener('touchstart', function(){ $('#screen-video1').show() $videoCon.show() document.getElementById('screen-video1').play() }) document.getElementById('screen-know-more').addEventListener('touchstart', function(){ $('.screen-swiper').removeClass('fadeOutDown').addClass('fadeInUp').show() if(!screenSwiper) { View.swiperScreenCamera() } }) document.getElementById('close-screen-swiper').addEventListener('touchstart', function(){ $('.screen-swiper').removeClass('fadeInUp').addClass('fadeOutDown') screenSwiper.slideTo(0, 0, false) }) // faceid document.getElementById('faceid-poster').addEventListener('touchstart', function(){ $('#face-video1').show() $videoCon.show() document.getElementById('face-video1').play() }) document.getElementById('face-know-more').addEventListener('touchstart', function(){ $('.face-swiper').removeClass('fadeOutDown').addClass('fadeInUp').show() if(!faceSwiper) { View.swiperFace() } }) document.getElementById('close-face-swiper').addEventListener('touchstart', function(){ $('.face-swiper').removeClass('fadeInUp').addClass('fadeOutDown') faceSwiper.slideTo(0, 0, false) }) // 前置摄像头 document.getElementById('front-poster').addEventListener('touchstart', function(){ $('#front-camera-video').show() $videoCon.show() document.getElementById('front-camera-video').play() }) document.getElementById('camera-know-more').addEventListener('touchstart', function(){ $('.camera-swiper').removeClass('fadeOutDown').addClass('fadeInUp').show() if(!frontCameraSwiper) { View.swiperFrontCamera() } }) document.getElementById('close-camera-siwper').addEventListener('touchstart', function(){ $('.camera-swiper').removeClass('fadeInUp').addClass('fadeOutDown') frontCameraSwiper.slideTo(0, 0, false) }) // 后置摄像头 document.getElementById('back-poster').addEventListener('touchstart', function(){ $('#back-camera-video').show() $videoCon.show() document.getElementById('back-camera-video').play() }) document.getElementById('backcamera-know-more').addEventListener('touchstart', function(){ $('.back-camera-swiper').removeClass('fadeOutDown').addClass('fadeInUp').show() if(!backCameraSwiper) { View.swiperBackCamera() } }) document.getElementById('close-backcamera-swiper').addEventListener('touchstart', function(){ $('.back-camera-swiper').removeClass('fadeInUp').addClass('fadeOutDown') backCameraSwiper.slideTo(0, 0, false) }) // 玻璃后盖 document.getElementById('plane-poster').addEventListener('touchstart', function(){ $('#plane-video').show() $videoCon.show() document.getElementById('plane-video').play() }) document.getElementById('plane-know-more').addEventListener('touchstart', function(){ $('.plane-swiper').removeClass('fadeOutDown').addClass('fadeInUp').show() if(!planeSwiper) { View.swiperPlane() } }) document.getElementById('close-plane-swiper').addEventListener('touchstart', function(){ $('.plane-swiper').removeClass('fadeInUp').addClass('fadeOutDown') planeSwiper.slideTo(0, 0, false) }) // 全屏视频结束自动退出 var videoBox = document.getElementsByClassName('full-video-wrap')[0] var videos = videoBox.getElementsByTagName('video') for(var i = 0; i < videos.length; i++) { videos[i].addEventListener('ended', function() { $videoCon.hide() $videoCon.find('video').hide() }) } // 评测视频 document.getElementById('suggest-watch').addEventListener('touchstart', function(e) { // e.preventDefault() $('#suggest-video').show() $videoCon.show() document.getElementById('suggest-video').play() }) // 进入扩展页,停止转动和缩放 touch.tap('.bottom-more-btn', function(e){ controls.enableZoom = false // console.log(e) e.cancelBubble = true }) touch.tap('.close-swiper-btn', function(e){ controls.enableZoom = true e.cancelBubble = true }) }, swiperFrontCamera() { // 前置 frontCameraSwiper = new Swiper('.swiper-front-camera',{ direction : 'vertical', speed:800, mousewheel: true, pagination: { el: '.swiper-pagination', clickable: true, }, on:{ slideChangeTransitionStart: function(){ } } }); }, swiperScreenCamera() { screenSwiper = new Swiper('#screen-swiper',{ direction : 'vertical', speed:400, mousewheel: true, pagination: { el: '.swiper-pagination', clickable: true, }, on:{ } }); }, swiperPlane() { planeSwiper = new Swiper('.swiper-plane',{ direction : 'vertical', speed:400, mousewheel: true, pagination: { el: '.swiper-pagination', clickable: true, }, on:{ } }); }, swiperFace() { faceSwiper = new Swiper('.swiper-face',{ direction : 'vertical', speed:400, pagination: { el: '.swiper-pagination', clickable: true, }, on:{ } }); }, swiperBackCamera() { backCameraSwiper = new Swiper('.swiper-back-camera',{ direction : 'vertical', speed:400, mousewheel: true, pagination: { el: '.swiper-pagination', clickable: true, }, on:{ } }); } } View.init() // $(function() { // attachFastClick(document.body); // });