|
@@ -156,8 +156,16 @@
|
|
|
var that = this;
|
|
|
this.houseId = this.$store.state.houseId || '';
|
|
|
this.childLayout = this.$route.query.childLayout || 0;//4-测试户型
|
|
|
- let unit = window.screen.width / 750;//单位rpm 对应 px 的值
|
|
|
- that.canvasHeight = window.screen.height - (200 * unit) + (20 * unit);
|
|
|
+ let screenWidth = window.screen.width;
|
|
|
+ let screenHeight = window.screen.height;
|
|
|
+ if(window.innerWidth && window.screen.width){
|
|
|
+ screenWidth = Math.min(window.innerWidth,window.screen.width)
|
|
|
+ }
|
|
|
+ if(window.innerHeight && window.screen.height){
|
|
|
+ screenHeight = Math.min(window.innerHeight,window.screen.height)
|
|
|
+ }
|
|
|
+ let unit = screenWidth / 750;//单位rpm 对应 px 的值
|
|
|
+ that.canvasHeight = screenHeight - (200 * unit) + (20 * unit);
|
|
|
|
|
|
const container = this.$refs.webgl;
|
|
|
const canvas3d = this.canvas = this.$refs.glcanvas;
|
|
@@ -196,8 +204,8 @@
|
|
|
// scene.environment = new THREE.Color("#F2F2F2");
|
|
|
|
|
|
// 创建相机位置-投影相机
|
|
|
- camera = new THREE.PerspectiveCamera( 80, window.screen.width / that.canvasHeight, 0.1, 10000 );
|
|
|
- // let aspect = window.screen.width / that.canvasHeight;
|
|
|
+ camera = new THREE.PerspectiveCamera( 80, screenWidth / that.canvasHeight, 0.1, 10000 );
|
|
|
+ // let aspect = screenWidth / that.canvasHeight;
|
|
|
// camera = new THREE.OrthographicCamera( frustumSize * aspect / - 2, frustumSize * aspect / 2, frustumSize / 2, frustumSize / - 2, 0.1,1000);
|
|
|
camera.up.set(0, 1, 0);//俯视状态,将相机的up向量设置为z轴负方向
|
|
|
scene.add(camera);
|
|
@@ -257,7 +265,7 @@
|
|
|
renderer.physicallyCorrectLights = true;//关键参数,模拟物理光照影响,必须设置为true
|
|
|
|
|
|
renderer.setPixelRatio( window.devicePixelRatio );
|
|
|
- renderer.setSize( window.screen.width, that.canvasHeight );
|
|
|
+ renderer.setSize( screenWidth, that.canvasHeight );
|
|
|
container.appendChild( renderer.domElement );
|
|
|
|
|
|
controls = new OrbitControls(camera, renderer.domElement);
|
|
@@ -296,9 +304,9 @@
|
|
|
controls.reset();
|
|
|
}
|
|
|
function onWindowResize() {
|
|
|
- camera.aspect = window.screen.width / that.canvasHeight;
|
|
|
+ camera.aspect = screenWidth / that.canvasHeight;
|
|
|
camera.updateProjectionMatrix();
|
|
|
- renderer.setSize( window.screen.width, that.canvasHeight );
|
|
|
+ renderer.setSize( screenWidth, that.canvasHeight );
|
|
|
console.warn("****onWindowResize**")
|
|
|
}
|
|
|
function attendEvent () {
|
|
@@ -461,10 +469,10 @@
|
|
|
//高度持续变化处理 time 动画持续时间 单位秒
|
|
|
function gradientResize (time,startHeight,endHeight) {
|
|
|
let _timeStep = 20;//单位 毫秒
|
|
|
- // let unit = window.screen.width / 750;//单位rpm 对应 px 的值
|
|
|
- // that.canvasHeight = window.screen.height - (200 * unit) + (20 * unit);
|
|
|
+ // let unit = screenWidth / 750;//单位rpm 对应 px 的值
|
|
|
+ // that.canvasHeight = screenHeight - (200 * unit) + (20 * unit);
|
|
|
|
|
|
- let unit = window.screen.width / 750;//单位rpx 对应 px 的值
|
|
|
+ let unit = screenWidth / 750;//单位rpx 对应 px 的值
|
|
|
let _height = startHeight - endHeight;//高度变化-单位rpx
|
|
|
let _jisua = that.canvasHeight;
|
|
|
let lastHeight = _jisua + (_height * unit);//动画结束时的高度值; 单位 px
|
|
@@ -483,7 +491,7 @@
|
|
|
.easing(TWEEN.Easing.Linear.None)
|
|
|
.onUpdate((object)=> {
|
|
|
if(camera.isOrthographicCamera){//正交相机
|
|
|
- let aspect = window.screen.width / object.h1;
|
|
|
+ let aspect = screenWidth / object.h1;
|
|
|
camera.left = frustumSize * aspect / - 2;
|
|
|
camera.right = frustumSize * aspect / 2;
|
|
|
camera.top = frustumSize / 2;
|
|
@@ -492,15 +500,15 @@
|
|
|
// that.canvasHeight = object.h1;
|
|
|
}
|
|
|
else if(camera.isPerspectiveCamera){//透视相机
|
|
|
- camera.aspect = window.screen.width / object.h1;
|
|
|
+ camera.aspect = screenWidth / object.h1;
|
|
|
camera.updateProjectionMatrix();
|
|
|
- renderer.setSize( window.screen.width, object.h1 );
|
|
|
+ renderer.setSize( screenWidth, object.h1 );
|
|
|
// that.canvasHeight = object.h1;
|
|
|
}
|
|
|
}).onComplete(()=>{
|
|
|
- camera.aspect = window.screen.width / that.canvasHeight;
|
|
|
+ camera.aspect = screenWidth / that.canvasHeight;
|
|
|
camera.updateProjectionMatrix();
|
|
|
- renderer.setSize( window.screen.width, that.canvasHeight );
|
|
|
+ renderer.setSize( screenWidth, that.canvasHeight );
|
|
|
tweenCameraAnma = false;
|
|
|
// that.showLables = true;
|
|
|
// updateLables();//更新lable
|
|
@@ -527,7 +535,7 @@
|
|
|
position.setFromMatrixPosition(stratMatrix);//从四维向量中提取位置信息
|
|
|
// console.warn("***updateLables***",item.instancedAtIndex,JSON.stringify(position));
|
|
|
position.project(camera);
|
|
|
- const x = (position.x * .5 + .5) * window.screen.width;
|
|
|
+ const x = (position.x * .5 + .5) * screenWidth;
|
|
|
const y = (position.y * -.5 + .5) * that.canvasHeight;
|
|
|
lable.transform = `translate(-50%, -50%) translate(${x}px,${y}px)`;
|
|
|
})
|