|
@@ -4,7 +4,7 @@
|
|
<script>
|
|
<script>
|
|
import * as THREE from 'three';
|
|
import * as THREE from 'three';
|
|
import Stats from 'three/addons/libs/stats.module.js';
|
|
import Stats from 'three/addons/libs/stats.module.js';
|
|
- // import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
|
|
|
|
+ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
|
|
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
|
|
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
|
|
|
|
|
|
import TWEEN from 'three/addons/libs/tween.module.js';
|
|
import TWEEN from 'three/addons/libs/tween.module.js';
|
|
@@ -12,7 +12,6 @@
|
|
var requestId = "";
|
|
var requestId = "";
|
|
const util = require('@/utils/util.js');
|
|
const util = require('@/utils/util.js');
|
|
const config = require('@/services/urlConfig.js');
|
|
const config = require('@/services/urlConfig.js');
|
|
- // import requestConfig from '@/static/lib/requestConfig.js';
|
|
|
|
import loadModel from '@/mixins/loadModel.js';
|
|
import loadModel from '@/mixins/loadModel.js';
|
|
import wallMethod from '@/mixins/wallMethod.js';
|
|
import wallMethod from '@/mixins/wallMethod.js';
|
|
import floorMethod from '@/mixins/floorMethod.js';
|
|
import floorMethod from '@/mixins/floorMethod.js';
|
|
@@ -76,10 +75,15 @@
|
|
curSpaceObj:null, //当前应该定位到的空间
|
|
curSpaceObj:null, //当前应该定位到的空间
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ computed: {
|
|
|
|
+ userId() {
|
|
|
|
+ return this.$store.state.userId;
|
|
|
|
+ },
|
|
|
|
+ },
|
|
watch:{
|
|
watch:{
|
|
|
|
|
|
},
|
|
},
|
|
- onUnload() {
|
|
|
|
|
|
+ destroyed() {
|
|
cancelAnimationFrame(requestId, this.canvas)
|
|
cancelAnimationFrame(requestId, this.canvas)
|
|
this.worker && this.worker.terminate()
|
|
this.worker && this.worker.terminate()
|
|
setTimeout(() => {
|
|
setTimeout(() => {
|
|
@@ -99,19 +103,24 @@
|
|
this.gltfLayouts = [];
|
|
this.gltfLayouts = [];
|
|
this.instancedFurList = [];
|
|
this.instancedFurList = [];
|
|
TWEEN && TWEEN.removeAll();//清除所有的tween;
|
|
TWEEN && TWEEN.removeAll();//清除所有的tween;
|
|
|
|
+ console.warn("***destroyed-webgl_rxdz_look***")
|
|
},
|
|
},
|
|
- async onLoad(options) {
|
|
|
|
- uni.hideShareMenu && uni.hideShareMenu();
|
|
|
|
|
|
+ async mounted(options) {
|
|
var that = this;
|
|
var that = this;
|
|
- let unit = app.globalData.systemInfo.screenWidth / 750;//单位rpx 对应 px 的值
|
|
|
|
- that.canvasHeight = window.innerHeight;
|
|
|
|
-
|
|
|
|
- const canvas3d = this.canvas = await document.createElementAsync("canvas","webgl")
|
|
|
|
- //uniapp 兼容写法,因为uni的页面对象的Vue 实例是$vm
|
|
|
|
- let curent = getCurrentPages()[getCurrentPages().length - 1];
|
|
|
|
- let currUniPage = getCurrentPages()[getCurrentPages().length - 1].$vm;
|
|
|
|
- curent = Object.assign(curent,currUniPage);
|
|
|
|
- let container = null, clock = null, controls = {target:{}};
|
|
|
|
|
|
+
|
|
|
|
+ this.houseId = this.$route.query.houseId?this.$route.query.houseId:'';
|
|
|
|
+ this.spaceId = this.$route.query.spaceId?this.$route.query.spaceId:'';
|
|
|
|
+ this.id = this.$route.query.id?this.$route.query.id:'';
|
|
|
|
+ console.warn("***mounted-webgl_rxdz_look****",this.id,this.$route.query)
|
|
|
|
+ if(this.id){
|
|
|
|
+ this.getIdData()
|
|
|
|
+ }else{
|
|
|
|
+ this.$store.state.loadingMsg = "没有数据~";
|
|
|
|
+ }
|
|
|
|
+ let container = this.$refs.webgl;
|
|
|
|
+ let canvas3d = this.canvas = this.$refs.glcanvas;
|
|
|
|
+
|
|
|
|
+ let clock = null, controls = {target:{}};
|
|
let camera = null, renderer = null, mixer = null;
|
|
let camera = null, renderer = null, mixer = null;
|
|
|
|
|
|
let loader = this.loader = new GLTFLoader();
|
|
let loader = this.loader = new GLTFLoader();
|
|
@@ -120,49 +129,28 @@
|
|
// let mouse = new THREE.Vector2();
|
|
// let mouse = new THREE.Vector2();
|
|
let chooseMesh = this.chooseMesh;//标记鼠标拾取到的mesh
|
|
let chooseMesh = this.chooseMesh;//标记鼠标拾取到的mesh
|
|
let isUserContorl = false;//是否进入漫游状态
|
|
let isUserContorl = false;//是否进入漫游状态
|
|
- let scaleCameraStarPY = 0;
|
|
|
|
-
|
|
|
|
- let TouchContact = 0; //滑动时上一次的手指数目
|
|
|
|
- let fingerCount = 0; //触摸时的手指数目
|
|
|
|
- let touchStart = { //
|
|
|
|
- clientX: 0,
|
|
|
|
- clientY: 0,
|
|
|
|
- distance:0,
|
|
|
|
- };
|
|
|
|
- let startTime = 0, cameraPositionY = 0; //非漫游时的移动变量
|
|
|
|
|
|
|
|
|
|
+ let stats;
|
|
let tweenCameraAnma = false; //表示当前是否处在动画过程中
|
|
let tweenCameraAnma = false; //表示当前是否处在动画过程中
|
|
|
|
|
|
-
|
|
|
|
- let spherical = new THREE.Spherical();
|
|
|
|
- let sphericalDelta = new THREE.Spherical();
|
|
|
|
- // let panOffset = new THREE.Vector3();
|
|
|
|
- let quat = null;
|
|
|
|
- let quatInverse = null;//倒置的
|
|
|
|
- let rotateStart = new THREE.Vector2();
|
|
|
|
- let rotateEnd = new THREE.Vector2();
|
|
|
|
- let rotateDelta = new THREE.Vector2();
|
|
|
|
- let minPolarAngle = 0;// 默认0
|
|
|
|
- let maxPolarAngle = Math.PI / 2; // 默认Math.PI,即可以向下旋转到撒旦视角。
|
|
|
|
-
|
|
|
|
|
|
+
|
|
init();
|
|
init();
|
|
- this.$refs.myLoading.showLoading("加载中...1%")
|
|
|
|
- this.myLoadingStatus = true;
|
|
|
|
|
|
+ this.$store.state.loadingMsg="加载中...1%";
|
|
this.progress = 1;
|
|
this.progress = 1;
|
|
this.clearEvent = clearEvent;
|
|
this.clearEvent = clearEvent;
|
|
this.tweenCameraAnmaChange = tweenCameraAnmaChange;
|
|
this.tweenCameraAnmaChange = tweenCameraAnmaChange;
|
|
this.updateLables = updateLables;
|
|
this.updateLables = updateLables;
|
|
this.moveMeshCenterHandle = moveMeshCenterHandle;
|
|
this.moveMeshCenterHandle = moveMeshCenterHandle;
|
|
|
|
+ this.cameraInit = cameraInit;
|
|
|
|
+ this.resetControl = resetControl;
|
|
function init() {
|
|
function init() {
|
|
- container = document.getElementById( 'container' );
|
|
|
|
|
|
|
|
scene.background = new THREE.Color("#F2F2F2");
|
|
scene.background = new THREE.Color("#F2F2F2");
|
|
scene.environment = new THREE.Color("#F2F2F2");
|
|
scene.environment = new THREE.Color("#F2F2F2");
|
|
|
|
|
|
// 创建相机位置
|
|
// 创建相机位置
|
|
- camera = new THREE.PerspectiveCamera( 80, window.innerWidth / that.canvasHeight, 0.1, 10000 );
|
|
|
|
- // camera.up.set(0, 0, -1);//俯视状态,将相机的up向量设置为z轴负方向
|
|
|
|
- camera.position.set(that.cameraStarPosition.x, that.cameraStarPosition.y, that.cameraStarPosition.z);
|
|
|
|
|
|
+ camera = new THREE.PerspectiveCamera( 80, window.innerWidth / window.innerHeight, 0.1, 10000 );
|
|
|
|
+ camera.up.set(0, 1, 0);//俯视状态,将相机的up向量设置为z轴负方向
|
|
scene.add(camera);
|
|
scene.add(camera);
|
|
that.camera = camera;
|
|
that.camera = camera;
|
|
// 时间
|
|
// 时间
|
|
@@ -181,9 +169,12 @@
|
|
light.position.set(-14.8, 9.188, -7.448); //default; light shining from top
|
|
light.position.set(-14.8, 9.188, -7.448); //default; light shining from top
|
|
scene.add(light);
|
|
scene.add(light);
|
|
//antialias 这个值得设置为false,不然IOS上截图会失效
|
|
//antialias 这个值得设置为false,不然IOS上截图会失效
|
|
- renderer = that.renderer = new THREE.WebGLRenderer( { canvas:canvas3d, alpha: true,
|
|
|
|
|
|
+ renderer = that.renderer = new THREE.WebGLRenderer({
|
|
|
|
+ canvas:canvas3d,
|
|
|
|
+ alpha: true,
|
|
// 如果想保存three.js canvas画布上的信息,注意设置preserveDrawingBuffer
|
|
// 如果想保存three.js canvas画布上的信息,注意设置preserveDrawingBuffer
|
|
- preserveDrawingBuffer: true, } );
|
|
|
|
|
|
+ preserveDrawingBuffer: true,
|
|
|
|
+ });
|
|
renderer.outputEncoding = THREE.sRGBEncoding;
|
|
renderer.outputEncoding = THREE.sRGBEncoding;
|
|
renderer.outputColorSpace = THREE.SRGBColorSpace;
|
|
renderer.outputColorSpace = THREE.SRGBColorSpace;
|
|
// renderer.toneMappingExposure = 0.1;//色调映射的曝光级别。默认是1
|
|
// renderer.toneMappingExposure = 0.1;//色调映射的曝光级别。默认是1
|
|
@@ -191,153 +182,77 @@
|
|
renderer.physicallyCorrectLights = true;//关键参数,模拟物理光照影响,必须设置为true
|
|
renderer.physicallyCorrectLights = true;//关键参数,模拟物理光照影响,必须设置为true
|
|
|
|
|
|
renderer.setPixelRatio( window.devicePixelRatio );
|
|
renderer.setPixelRatio( window.devicePixelRatio );
|
|
- renderer.setSize( window.innerWidth, that.canvasHeight );
|
|
|
|
|
|
+ renderer.setSize( window.innerWidth, window.innerHeight );
|
|
container.appendChild( renderer.domElement );
|
|
container.appendChild( renderer.domElement );
|
|
|
|
|
|
|
|
|
|
- controls.target = new THREE.Vector3( that.controlStarPosition.x, that.controlStarPosition.y, that.controlStarPosition.z );;
|
|
|
|
- that.controls = controls;
|
|
|
|
- camera.lookAt(that.controlStarPosition.x,that.controlStarPosition.y,that.controlStarPosition.z);
|
|
|
|
- // 监听
|
|
|
|
- // window.addEventListener( 'resize', onWindowResize );
|
|
|
|
|
|
+ // controls.target = new THREE.Vector3( that.controlStarPosition.x, that.controlStarPosition.y, that.controlStarPosition.z );;
|
|
|
|
+
|
|
|
|
+ controls = new OrbitControls(camera, renderer.domElement);
|
|
|
|
+ controls.screenSpacePanning = true;
|
|
|
|
+ controls.enableDamping = true;
|
|
|
|
+ controls.minDistance = 1;
|
|
|
|
+ controls.maxDistance = 400;
|
|
|
|
+ controls.minPolarAngle = 0;// 默认0
|
|
|
|
+ controls.maxPolarAngle = Math.PI / 2; // 默认Math.PI,即可以向下旋转到的视角。
|
|
|
|
+ controls.target.set(that.controlStarPosition.x, that.controlStarPosition.y, that.controlStarPosition.z);
|
|
|
|
+ controls.enableZoom = true;//启用摄像机的缩放
|
|
|
|
+
|
|
|
|
+ stats = new Stats();
|
|
|
|
+ container.appendChild( stats.dom );
|
|
|
|
+ // 监听
|
|
|
|
+ window.addEventListener( 'resize', onWindowResize );
|
|
// raycaster = new THREE.Raycaster();
|
|
// raycaster = new THREE.Raycaster();
|
|
- document.addEventListener('touchstart', onPointerStart, false);
|
|
|
|
- document.addEventListener('touchmove', onPointerMove, false);
|
|
|
|
- document.addEventListener('touchend', onPointerUp, false);
|
|
|
|
|
|
+ renderer.domElement.addEventListener('touchstart', onPointerStart, false);
|
|
|
|
+ renderer.domElement.addEventListener('touchmove', onPointerMove, false);
|
|
|
|
+ renderer.domElement.addEventListener('touchend', onPointerUp, false);
|
|
render();//重启渲染
|
|
render();//重启渲染
|
|
|
|
+ cameraInit();
|
|
|
|
+ controls.saveState();//保存当前控制器的状态
|
|
}
|
|
}
|
|
|
|
+ //初始化相机位置
|
|
|
|
+ function cameraInit(){
|
|
|
|
+ camera.position.set(that.cameraStarPosition.x, that.cameraStarPosition.y, that.cameraStarPosition.z);
|
|
|
|
+ camera.lookAt(that.controlStarPosition.x,that.controlStarPosition.y,that.controlStarPosition.z);
|
|
|
|
+ }
|
|
|
|
+ //初始状态
|
|
|
|
+ function resetControl(){
|
|
|
|
+ controls.reset();
|
|
|
|
+ }
|
|
function tweenCameraAnmaChange (value) {
|
|
function tweenCameraAnmaChange (value) {
|
|
tweenCameraAnma = value
|
|
tweenCameraAnma = value
|
|
}
|
|
}
|
|
//取消事件监听-避免二次进入时触发多次事件
|
|
//取消事件监听-避免二次进入时触发多次事件
|
|
function clearEvent(){
|
|
function clearEvent(){
|
|
console.warn("**clearEvent****")
|
|
console.warn("**clearEvent****")
|
|
- document.removeEventListener('touchstart', onPointerStart);
|
|
|
|
- document.removeEventListener('touchmove', onPointerMove );
|
|
|
|
- document.removeEventListener('touchend', onPointerUp );
|
|
|
|
- }
|
|
|
|
- function rotateLeft( angle ) {
|
|
|
|
- sphericalDelta.theta -= angle;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- function rotateUp( angle ) {
|
|
|
|
- sphericalDelta.phi -= angle;
|
|
|
|
- }
|
|
|
|
- //更新球坐标 这里的up向量影响到了水平滑动的效果,需要仔细研究
|
|
|
|
- function update() {
|
|
|
|
- camera.up.set(0, 1, 0);//俯视状态,将相机的up向量设置为z轴负方向
|
|
|
|
- const offset = new THREE.Vector3();
|
|
|
|
- quat = new THREE.Quaternion().setFromUnitVectors( camera.up, new THREE.Vector3( 0, 1, 0 ) );
|
|
|
|
- quatInverse = quat.clone().invert();//翻转该四元数
|
|
|
|
- const position = camera.position;
|
|
|
|
- // console.warn("***camera-info0***",JSON.stringify(camera.up),JSON.stringify(camera.position),JSON.stringify(quat))
|
|
|
|
- offset.copy( position ).sub( controls.target );
|
|
|
|
- // rotate offset to "y-axis-is-up" space
|
|
|
|
- offset.applyQuaternion( quat );
|
|
|
|
- // 设置球坐标的radius、phi和theta值
|
|
|
|
- spherical.setFromVector3( offset );// 以上是构建当前状态下的摄像机和观测点之间的球坐标
|
|
|
|
- spherical.theta += sphericalDelta.theta;
|
|
|
|
- if(camera.isPerspectiveCamera){//透视相机
|
|
|
|
- spherical.phi += sphericalDelta.phi;
|
|
|
|
- // restrict phi to be between desired limits
|
|
|
|
- spherical.phi = Math.max( minPolarAngle, Math.min( maxPolarAngle, spherical.phi ) );
|
|
|
|
- }
|
|
|
|
- spherical.makeSafe();
|
|
|
|
- // spherical.radius *= 1;
|
|
|
|
- // restrict radius to be between desired limits
|
|
|
|
- // spherical.radius = Math.max( scope.minDistance, Math.min( scope.maxDistance, spherical.radius ) );
|
|
|
|
- // controls.target.add( panOffset );
|
|
|
|
- //以上是根据条件更新球坐标的值,然后从球坐标当中获取位置等信息
|
|
|
|
- offset.setFromSpherical( spherical );
|
|
|
|
- offset.applyQuaternion( quatInverse );
|
|
|
|
- position.copy( controls.target ).add( offset );
|
|
|
|
- camera.lookAt( controls.target );
|
|
|
|
-
|
|
|
|
- sphericalDelta.set( 0, 0, 0 );
|
|
|
|
- };
|
|
|
|
- //更新初始点
|
|
|
|
- function touchOne(touches,event) {
|
|
|
|
- // 只有一个手指时记录当前点的坐标作为平移起始点
|
|
|
|
- if (isUserContorl === false) {// 非漫游状态
|
|
|
|
- rotateStart.set( event.clientX, event.clientY );
|
|
|
|
- }
|
|
|
|
|
|
+ renderer.domElement && renderer.domElement.removeEventListener('touchstart', onPointerStart);
|
|
|
|
+ renderer.domElement && renderer.domElement.removeEventListener('touchmove', onPointerMove );
|
|
|
|
+ renderer.domElement && renderer.domElement.removeEventListener('touchend', onPointerUp );
|
|
}
|
|
}
|
|
// 手指移动开始
|
|
// 手指移动开始
|
|
function onPointerStart(event){
|
|
function onPointerStart(event){
|
|
- startTime = (new Date()).getTime();
|
|
|
|
- fingerCount = event.touches.length;//手指个数
|
|
|
|
- console.log('开始触摸事件:',fingerCount,tweenCameraAnma,isUserContorl,camera.position.y,event,event.touches)
|
|
|
|
- if (fingerCount === 1) {
|
|
|
|
- // 只有一个手指时记录当前点的坐标作为平移起始点
|
|
|
|
- if (isUserContorl === false) {//非漫游模式
|
|
|
|
- touchOne(event.touches[0],event);
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- // 有两个手指时记录两个点的距离和中点作为缩放起始点
|
|
|
|
- let xMove = event.touches[1].clientX - event.touches[0].clientX;
|
|
|
|
- let yMove = event.touches[1].clientY - event.touches[0].clientY;
|
|
|
|
- //计算开始触发两个手指坐标的距离
|
|
|
|
- let distance = Math.sqrt(xMove * xMove + yMove * yMove);
|
|
|
|
- touchStart.distance = distance;
|
|
|
|
- scaleCameraStarPY = camera.position.y;
|
|
|
|
|
|
+ console.log('开始触摸事件:',that.overChange)
|
|
|
|
+ if(that.overChange){//形变中,不能相应用户操作
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//持续触摸中
|
|
//持续触摸中
|
|
function onPointerMove( event ) {
|
|
function onPointerMove( event ) {
|
|
- fingerCount = event.touches.length;//手指个数
|
|
|
|
- that.showLables = false;
|
|
|
|
- if(fingerCount==1){
|
|
|
|
- // 当触屏,两个手指变成一个手指;此时缩放动作结束,滑动图片开始
|
|
|
|
- if (TouchContact == 2) {//上一次滑动的触摸点个数
|
|
|
|
- console.warn('两个手指变成一个手指');
|
|
|
|
- touchOne(event.touches[0],event);
|
|
|
|
- }else{
|
|
|
|
- if (isUserContorl === false) {// 非漫游状态
|
|
|
|
- rotateEnd.set( event.clientX, event.clientY );
|
|
|
|
- rotateDelta.subVectors( rotateEnd, rotateStart ).multiplyScalar( 1 );
|
|
|
|
- const element = renderer.domElement;
|
|
|
|
- rotateLeft( 2 * Math.PI * rotateDelta.x / element.clientHeight ); // yes, height
|
|
|
|
- rotateUp( 2 * Math.PI * rotateDelta.y / element.clientHeight );
|
|
|
|
- rotateStart.copy( rotateEnd );
|
|
|
|
- update();
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } else if (fingerCount === 2) {
|
|
|
|
- // console.warn(fingerCount,"***onPointerMove-lon***",lon)
|
|
|
|
- //双手指运动 x移动后的坐标和y移动后的坐标
|
|
|
|
- let xMove = event.touches[1].clientX - event.touches[0].clientX;
|
|
|
|
- let yMove = event.touches[1].clientY - event.touches[0].clientY;
|
|
|
|
- //双手指运动新的 ditance
|
|
|
|
- let distance = Math.sqrt(xMove * xMove + yMove * yMove);
|
|
|
|
- //计算移动的过程中实际移动了多少的距离
|
|
|
|
- let distanceDiff = distance - touchStart.distance;
|
|
|
|
- // 双手滑动得距离
|
|
|
|
- cameraPositionY = 0.1 * distanceDiff;
|
|
|
|
|
|
+ if(that.overChange){//形变中,不能相应用户操作
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
- TouchContact = fingerCount;
|
|
|
|
|
|
+ that.showLables = false;
|
|
}
|
|
}
|
|
//触摸结束
|
|
//触摸结束
|
|
function onPointerUp(event) {
|
|
function onPointerUp(event) {
|
|
- fingerCount = event.touches.length;//手指个数
|
|
|
|
- // console.warn(fingerCount,"***onPointerUp***",startTime)
|
|
|
|
- if(fingerCount==0){
|
|
|
|
- let now = new Date().getTime()
|
|
|
|
- if (Math.abs(event.clientX - rotateStart.x) < 10
|
|
|
|
- && Math.abs(event.clientY - rotateStart.y) < 10
|
|
|
|
- && (now - startTime) < 300 ){
|
|
|
|
- // 点击事件-先注释
|
|
|
|
- // checkIntersection(event);
|
|
|
|
- }else{
|
|
|
|
- if (isUserContorl === false) {// 非漫游状态
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if(that.overChange){//形变中,不能相应用户操作
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ // enableRender();
|
|
|
|
+ if(event.touches.length==0){
|
|
that.showLables = true;
|
|
that.showLables = true;
|
|
updateLables();
|
|
updateLables();
|
|
}
|
|
}
|
|
- else if(fingerCount==1){//双指情况下,松开一指
|
|
|
|
- console.warn(fingerCount,"***onPointerUp***",cameraPositionY)
|
|
|
|
- cameraPositionY = 0;
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
//把摄像机移动的选中模型的正上方,观察点也变更为模型中心点,同时选中模型
|
|
//把摄像机移动的选中模型的正上方,观察点也变更为模型中心点,同时选中模型
|
|
function moveMeshCenterHandle(mesh = null,noChangeColor = true){
|
|
function moveMeshCenterHandle(mesh = null,noChangeColor = true){
|
|
@@ -377,7 +292,7 @@
|
|
z:-spaceObj.centerY/100,
|
|
z:-spaceObj.centerY/100,
|
|
}
|
|
}
|
|
oldUp = camera.up;//俯视状态
|
|
oldUp = camera.up;//俯视状态
|
|
- newUp = camera.up
|
|
|
|
|
|
+ newUp = camera.up;
|
|
// that.cameraLastPosition = cameraNewPosition;//记录下上一次摄像头位置
|
|
// that.cameraLastPosition = cameraNewPosition;//记录下上一次摄像头位置
|
|
// that.controlLastPosition = targetNewPosition;//记录下上一次观察点位置
|
|
// that.controlLastPosition = targetNewPosition;//记录下上一次观察点位置
|
|
}
|
|
}
|
|
@@ -387,7 +302,7 @@
|
|
setTimeout(()=>{
|
|
setTimeout(()=>{
|
|
that.showLables = true;
|
|
that.showLables = true;
|
|
updateLables();
|
|
updateLables();
|
|
- controls.enable = true;//控制器不响应用户的操作
|
|
|
|
|
|
+ controls.enable = true;//控制器响应用户的操作
|
|
},601);//动画结束后回复原始状态
|
|
},601);//动画结束后回复原始状态
|
|
}
|
|
}
|
|
|
|
|
|
@@ -451,9 +366,9 @@
|
|
tween.start();
|
|
tween.start();
|
|
}
|
|
}
|
|
function onWindowResize() {
|
|
function onWindowResize() {
|
|
- camera.aspect = window.innerWidth / that.canvasHeight;
|
|
|
|
|
|
+ camera.aspect = window.innerWidth / window.innerHeight;
|
|
camera.updateProjectionMatrix();
|
|
camera.updateProjectionMatrix();
|
|
- renderer.setSize( window.innerWidth, that.canvasHeight );
|
|
|
|
|
|
+ renderer.setSize( window.innerWidth, window.innerHeight );
|
|
}
|
|
}
|
|
//计算漫游时当前选中空间的观察点和摄像机的放置点位
|
|
//计算漫游时当前选中空间的观察点和摄像机的放置点位
|
|
//distance 表示要沿着视角移动的距离
|
|
//distance 表示要沿着视角移动的距离
|
|
@@ -472,42 +387,20 @@
|
|
// console.warn("***updateLables***",item.instancedAtIndex,JSON.stringify(position));
|
|
// console.warn("***updateLables***",item.instancedAtIndex,JSON.stringify(position));
|
|
position.project(camera);
|
|
position.project(camera);
|
|
const x = (position.x * .5 + .5) * window.innerWidth;
|
|
const x = (position.x * .5 + .5) * window.innerWidth;
|
|
- const y = (position.y * -.5 + .5) * that.canvasHeight;
|
|
|
|
|
|
+ const y = (position.y * -.5 + .5) * window.innerHeight;
|
|
lable.transform = `translate(-50%, -50%) translate(${x}px,${y}px)`;
|
|
lable.transform = `translate(-50%, -50%) translate(${x}px,${y}px)`;
|
|
})
|
|
})
|
|
}
|
|
}
|
|
function render() {
|
|
function render() {
|
|
TWEEN && TWEEN.update();
|
|
TWEEN && TWEEN.update();
|
|
- if (mixer) {
|
|
|
|
- let delta = clock.getDelta();
|
|
|
|
- mixer.update(delta);
|
|
|
|
- }
|
|
|
|
|
|
+ stats.update();
|
|
//不处在动画过程中,则可以处理移动等动作
|
|
//不处在动画过程中,则可以处理移动等动作
|
|
if(tweenCameraAnma==false){
|
|
if(tweenCameraAnma==false){
|
|
- if (isUserContorl === false ) { // 非漫游
|
|
|
|
- if(fingerCount==2){//双指情况下
|
|
|
|
- console.warn("***camera.isPerspectiveCamera***",scaleCameraStarPY,cameraPositionY,JSON.stringify(camera.position))
|
|
|
|
- let _cha = scaleCameraStarPY - cameraPositionY;
|
|
|
|
- if(_cha < 1.2){
|
|
|
|
- _cha = 1.2;
|
|
|
|
- }
|
|
|
|
- if(camera.position.y!=_cha){//不等才更新camera.position
|
|
|
|
- camera.position.set(camera.position.x, _cha, camera.position.z);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ controls.update();
|
|
}
|
|
}
|
|
renderer.render(scene, camera);//单次渲染
|
|
renderer.render(scene, camera);//单次渲染
|
|
requestId = requestAnimationFrame(render, canvas3d);
|
|
requestId = requestAnimationFrame(render, canvas3d);
|
|
}
|
|
}
|
|
-
|
|
|
|
- const eventChannel = this.getOpenerEventChannel();
|
|
|
|
- // 监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据
|
|
|
|
- eventChannel && eventChannel.hasOwnProperty('on') && eventChannel.on('acceptDataFromOpenerPage', (data) => {
|
|
|
|
- console.log('监听acceptDataFromOpenerPage事件,获取上一页面通过eventChannel传送到当前页面的数据',data)
|
|
|
|
- this.setHouseDetail(data)
|
|
|
|
- })
|
|
|
|
-
|
|
|
|
},
|
|
},
|
|
|
|
|
|
methods: {
|
|
methods: {
|
|
@@ -542,22 +435,35 @@
|
|
this.instancedFurList = [];
|
|
this.instancedFurList = [];
|
|
this.wallList = [];
|
|
this.wallList = [];
|
|
//恢复初始视角
|
|
//恢复初始视角
|
|
- this.camera.position.set(this.cameraStarPosition.x, this.cameraStarPosition.y, this.cameraStarPosition.z);
|
|
|
|
- this.controls.target = new THREE.Vector3( this.controlStarPosition.x, this.controlStarPosition.y, this.controlStarPosition.z );;
|
|
|
|
- this.camera.lookAt(this.controlStarPosition.x,this.controlStarPosition.y,this.controlStarPosition.z);
|
|
|
|
-
|
|
|
|
|
|
+ this.cameraInit();
|
|
|
|
+ this.resetControl();
|
|
setTimeout(()=>{
|
|
setTimeout(()=>{
|
|
this.loadSpace();
|
|
this.loadSpace();
|
|
}, 100);
|
|
}, 100);
|
|
// this.$emit("curHouseFloorChange", item);//通知页面,户型楼层发生了变更
|
|
// this.$emit("curHouseFloorChange", item);//通知页面,户型楼层发生了变更
|
|
},
|
|
},
|
|
|
|
+ async getIdData(){
|
|
|
|
+ let userId = this.userId || '';
|
|
|
|
+ let params = {
|
|
|
|
+ id: this.id,
|
|
|
|
+ brandId: config.brandId,
|
|
|
|
+ houseId:this.houseId,
|
|
|
|
+ userId,
|
|
|
|
+ };
|
|
|
|
+ const res = await requestConfig('getCustomizedRecord', params);
|
|
|
|
+ if (res.success ) {
|
|
|
|
+ let single = res.list[0];
|
|
|
|
+ this.layoutStruct = JSON.parse(JSON.stringify(single));
|
|
|
|
+ this.setHouseDetail(this.layoutStruct)
|
|
|
|
+ }
|
|
|
|
+ },
|
|
/**
|
|
/**
|
|
* 设置户型详情信息
|
|
* 设置户型详情信息
|
|
* @param {Object} data 户型详情
|
|
* @param {Object} data 户型详情
|
|
*/
|
|
*/
|
|
setHouseDetail(data){
|
|
setHouseDetail(data){
|
|
if(data && data.layoutStruct){
|
|
if(data && data.layoutStruct){
|
|
- let curData = data.layoutStruct;
|
|
|
|
|
|
+ let curData = data;
|
|
this.curHouseObj = curData.layoutStruct.find(it=>it.floor==curData.curFloor);;
|
|
this.curHouseObj = curData.layoutStruct.find(it=>it.floor==curData.curFloor);;
|
|
// this.spaceId = this.curHouseObj.spaceId;
|
|
// this.spaceId = this.curHouseObj.spaceId;
|
|
console.warn("***curHouseObj***",this.curHouseObj)
|
|
console.warn("***curHouseObj***",this.curHouseObj)
|
|
@@ -590,7 +496,6 @@
|
|
if(cube.spaceName && !cube.isSizeLock){
|
|
if(cube.spaceName && !cube.isSizeLock){
|
|
this.lableItem.push(
|
|
this.lableItem.push(
|
|
{
|
|
{
|
|
- // text:this.spaceTypes[cube.spaceType - 1],
|
|
|
|
text:cube.spaceName,
|
|
text:cube.spaceName,
|
|
spaceId:cube.spaceId,
|
|
spaceId:cube.spaceId,
|
|
transform:'',
|
|
transform:'',
|
|
@@ -602,20 +507,6 @@
|
|
this.showLables = true;
|
|
this.showLables = true;
|
|
this.updateLables();//更新lable
|
|
this.updateLables();//更新lable
|
|
},
|
|
},
|
|
- /**
|
|
|
|
- * 返回列表页
|
|
|
|
- */
|
|
|
|
- backHouseList(){
|
|
|
|
- uni.navigateBack();
|
|
|
|
- },
|
|
|
|
- webgl_touch(e) {
|
|
|
|
- const web_e = Event.fix(e)
|
|
|
|
- window.dispatchEvent(web_e)
|
|
|
|
- let web_e2 = Object.assign(e,web_e)
|
|
|
|
- document.dispatchEvent(web_e2)
|
|
|
|
- this.canvas.dispatchEvent(web_e)
|
|
|
|
-
|
|
|
|
- },
|
|
|
|
//obj 物体对象,type 是否改变颜色
|
|
//obj 物体对象,type 是否改变颜色
|
|
moveMeshCenter(obj,type){
|
|
moveMeshCenter(obj,type){
|
|
console.warn("**moveMeshCenter***",obj)
|
|
console.warn("**moveMeshCenter***",obj)
|
|
@@ -678,18 +569,18 @@
|
|
for (let index = 0; index < wallList.length; index++) {//每个空间对应一个数据
|
|
for (let index = 0; index < wallList.length; index++) {//每个空间对应一个数据
|
|
let element = JSON.parse(wallList[index].wallJson);
|
|
let element = JSON.parse(wallList[index].wallJson);
|
|
let space = this.spaceList.find(space=>space.spaceId==element.spaceId);
|
|
let space = this.spaceList.find(space=>space.spaceId==element.spaceId);
|
|
- this.computeWallHandle(space,element);//提前计算
|
|
|
|
|
|
+ this.computeWallHandleOld(space,element);//提前计算
|
|
for (let i = 0; i < element.wallData.length; i ++) {//对应空间里面的4个方向的墙壁数据
|
|
for (let i = 0; i < element.wallData.length; i ++) {//对应空间里面的4个方向的墙壁数据
|
|
let wallData = element.wallData[i];
|
|
let wallData = element.wallData[i];
|
|
//对应方向的墙壁的墙体模型数据列表,每一面墙可能有多个模型
|
|
//对应方向的墙壁的墙体模型数据列表,每一面墙可能有多个模型
|
|
for (let j = 0; j < wallData.wallModelData.length; j ++) {
|
|
for (let j = 0; j < wallData.wallModelData.length; j ++) {
|
|
let wallModelData = wallData.wallModelData[j];
|
|
let wallModelData = wallData.wallModelData[j];
|
|
wallArr.push({spaceId:element.spaceId, wallModelData:wallModelData, wallDirection:wallData.wallDirection})
|
|
wallArr.push({spaceId:element.spaceId, wallModelData:wallModelData, wallDirection:wallData.wallDirection})
|
|
- // console.log("wallModelData", element,wallData.wallDirection, wallModelData.wallType );
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- this.loadSpaceObjWalls(wallArr, wallList)
|
|
|
|
|
|
+ this.loadSpaceObjWalls(wallArr, wallList);
|
|
|
|
+ this.getOverallArrangementDetailsList(2);
|
|
},
|
|
},
|
|
// 加载单个空间墙体资源
|
|
// 加载单个空间墙体资源
|
|
async loadSpaceObjWalls(wallArr, wallList){
|
|
async loadSpaceObjWalls(wallArr, wallList){
|
|
@@ -712,22 +603,21 @@
|
|
this.$nextTick(()=>{
|
|
this.$nextTick(()=>{
|
|
this.moveMeshCenter(this.curSpaceObj);
|
|
this.moveMeshCenter(this.curSpaceObj);
|
|
this.progress = 100;
|
|
this.progress = 100;
|
|
- this.$refs.myLoading.showLoading("加载中..." + this.progress + '%')
|
|
|
|
|
|
+ // this.$refs.myLoading.showLoading("加载中..." + this.progress + '%')
|
|
|
|
+ this.$store.state.loadingMsg="加载中..." + this.progress + '%';
|
|
this.$nextTick(()=>{
|
|
this.$nextTick(()=>{
|
|
this.myLoadingStatus = false;
|
|
this.myLoadingStatus = false;
|
|
- this.$refs.myLoading.hideLoading();
|
|
|
|
|
|
+ // this.$refs.myLoading.hideLoading();
|
|
setTimeout(()=>{
|
|
setTimeout(()=>{
|
|
this.addWordLabel(); // 添加文字标签
|
|
this.addWordLabel(); // 添加文字标签
|
|
}, 610);
|
|
}, 610);
|
|
})
|
|
})
|
|
- // this.getOverallArrangementDetailsList();
|
|
|
|
})
|
|
})
|
|
})
|
|
})
|
|
},
|
|
},
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</script>
|
|
-<style lang="css" scoped>
|
|
|
|
- @import "./webgl_rxdz_look.css";
|
|
|
|
- /* @import "@/common/css/common.css"; */
|
|
|
|
|
|
+<style lang="scss" scoped>
|
|
|
|
+ @import "./webgl_rxdz_look.scss";
|
|
</style>
|
|
</style>
|