|
@@ -209,8 +209,8 @@
|
|
|
// scene.environment = new THREE.Color("#F2F2F2");
|
|
|
|
|
|
// 创建相机位置-投影相机
|
|
|
- camera = new THREE.PerspectiveCamera( 80, window.innerWidth / that.canvasHeight, 0.1, 10000 );
|
|
|
- // let aspect = window.innerWidth / that.canvasHeight;
|
|
|
+ camera = new THREE.PerspectiveCamera( 80, window.screen.width / that.canvasHeight, 0.1, 10000 );
|
|
|
+ // let aspect = window.screen.width / 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);
|
|
@@ -248,7 +248,7 @@
|
|
|
renderer.physicallyCorrectLights = true;//关键参数,模拟物理光照影响,必须设置为true
|
|
|
|
|
|
renderer.setPixelRatio( window.devicePixelRatio );
|
|
|
- renderer.setSize( window.innerWidth, that.canvasHeight );
|
|
|
+ renderer.setSize( window.screen.width, that.canvasHeight );
|
|
|
container.appendChild( renderer.domElement );
|
|
|
|
|
|
controls = new OrbitControls(camera, renderer.domElement);
|
|
@@ -281,9 +281,9 @@
|
|
|
controls.reset();
|
|
|
}
|
|
|
function onWindowResize() {
|
|
|
- camera.aspect = window.innerWidth / that.canvasHeight;
|
|
|
+ camera.aspect = window.screen.width / that.canvasHeight;
|
|
|
camera.updateProjectionMatrix();
|
|
|
- renderer.setSize( window.innerWidth, that.canvasHeight );
|
|
|
+ renderer.setSize( window.screen.width, that.canvasHeight );
|
|
|
console.warn("****onWindowResize**")
|
|
|
}
|
|
|
function attendEvent () {
|
|
@@ -301,9 +301,9 @@
|
|
|
//取消事件监听-避免二次进入时触发多次事件
|
|
|
function clearEvent(){
|
|
|
console.warn("**clearEvent****")
|
|
|
- renderer.domElement && renderer.domElement.removeEventListener('touchstart', onPointerStart);
|
|
|
- renderer.domElement && renderer.domElement.removeEventListener('touchmove', onPointerMove );
|
|
|
- renderer.domElement && renderer.domElement.removeEventListener('touchend', onPointerUp );
|
|
|
+ renderer && renderer.domElement && renderer.domElement.removeEventListener('touchstart', onPointerStart);
|
|
|
+ renderer && renderer.domElement && renderer.domElement.removeEventListener('touchmove', onPointerMove );
|
|
|
+ renderer && renderer.domElement && renderer.domElement.removeEventListener('touchend', onPointerUp );
|
|
|
}
|
|
|
// 手指移动开始
|
|
|
function onPointerStart(event){
|
|
@@ -463,7 +463,7 @@
|
|
|
.easing(TWEEN.Easing.Linear.None)
|
|
|
.onUpdate((object)=> {
|
|
|
if(camera.isOrthographicCamera){//正交相机
|
|
|
- let aspect = window.innerWidth / object.h1;
|
|
|
+ let aspect = window.screen.width / object.h1;
|
|
|
camera.left = frustumSize * aspect / - 2;
|
|
|
camera.right = frustumSize * aspect / 2;
|
|
|
camera.top = frustumSize / 2;
|
|
@@ -472,15 +472,15 @@
|
|
|
// that.canvasHeight = object.h1;
|
|
|
}
|
|
|
else if(camera.isPerspectiveCamera){//透视相机
|
|
|
- camera.aspect = window.innerWidth / object.h1;
|
|
|
+ camera.aspect = window.screen.width / object.h1;
|
|
|
camera.updateProjectionMatrix();
|
|
|
- renderer.setSize( window.innerWidth, object.h1 );
|
|
|
+ renderer.setSize( window.screen.width, object.h1 );
|
|
|
// that.canvasHeight = object.h1;
|
|
|
}
|
|
|
}).onComplete(()=>{
|
|
|
- camera.aspect = window.innerWidth / that.canvasHeight;
|
|
|
+ camera.aspect = window.screen.width / that.canvasHeight;
|
|
|
camera.updateProjectionMatrix();
|
|
|
- renderer.setSize( window.innerWidth, that.canvasHeight );
|
|
|
+ renderer.setSize( window.screen.width, that.canvasHeight );
|
|
|
tweenCameraAnma = false;
|
|
|
that.showLables = true;
|
|
|
updateLables();//更新lable
|
|
@@ -507,7 +507,7 @@
|
|
|
position.setFromMatrixPosition(stratMatrix);//从四维向量中提取位置信息
|
|
|
// console.warn("***updateLables***",item.instancedAtIndex,JSON.stringify(position));
|
|
|
position.project(camera);
|
|
|
- const x = (position.x * .5 + .5) * window.innerWidth;
|
|
|
+ const x = (position.x * .5 + .5) * window.screen.width;
|
|
|
const y = (position.y * -.5 + .5) * that.canvasHeight;
|
|
|
lable.transform = `translate(-50%, -50%) translate(${x}px,${y}px)`;
|
|
|
})
|
|
@@ -1593,14 +1593,6 @@
|
|
|
onMouseMove(e){
|
|
|
return false;
|
|
|
},
|
|
|
- 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)
|
|
|
-
|
|
|
- },
|
|
|
goRoam1(spaceId){
|
|
|
let gltf = this.lableItem.find(it=>it.spaceId==spaceId);
|
|
|
if(gltf){
|