|
|
@@ -37,6 +37,8 @@ export class DataVT1Component implements OnInit { |
|
|
|
// 创建相机 |
|
|
|
this.camera = new THREE.PerspectiveCamera(40, window.innerWidth / window.innerHeight, 1, 20000); |
|
|
|
this.camera.position.set(2200, 300, -3100); |
|
|
|
this.camera.fov = 60; // 调整视角大小 |
|
|
|
this.camera.updateProjectionMatrix(); // 更新相机的投影矩阵 |
|
|
|
|
|
|
|
//创建场景 |
|
|
|
this.scene = new THREE.Scene(); |
|
|
@@ -78,7 +80,9 @@ export class DataVT1Component implements OnInit { |
|
|
|
|
|
|
|
this.renderer = new THREE.WebGLRenderer({ antialias: true }); |
|
|
|
this.renderer.setPixelRatio(window.devicePixelRatio); |
|
|
|
this.renderer.setSize(window.innerWidth, window.innerHeight); |
|
|
|
// this.renderer.setSize(window.innerWidth, window.innerHeight); |
|
|
|
this.renderer.setSize(400, 300); // 设置渲染器的宽度和高度 |
|
|
|
|
|
|
|
this.renderer.shadowMap.enabled = true; |
|
|
|
this.container.nativeElement.appendChild(this.renderer.domElement); |
|
|
|
|
|
|
@@ -96,8 +100,6 @@ export class DataVT1Component implements OnInit { |
|
|
|
|
|
|
|
//const axesHelper = new THREE.AxesHelper(1000); |
|
|
|
//this.scene.add(axesHelper); |
|
|
|
|
|
|
|
window.addEventListener('resize', this.onWindowResize); |
|
|
|
} |
|
|
|
|
|
|
|
public render(): void { |
|
|
@@ -107,9 +109,9 @@ export class DataVT1Component implements OnInit { |
|
|
|
} |
|
|
|
|
|
|
|
onWindowResize() { |
|
|
|
this.camera.aspect = window.innerWidth / window.innerHeight; |
|
|
|
this.camera.updateProjectionMatrix(); |
|
|
|
this.renderer.setSize(window.innerWidth, window.innerHeight); |
|
|
|
// this.camera.aspect = window.innerWidth / window.innerHeight; |
|
|
|
// this.camera.updateProjectionMatrix(); |
|
|
|
// this.renderer.setSize(window.innerWidth, window.innerHeight); |
|
|
|
} |
|
|
|
animate = () => { |
|
|
|
requestAnimationFrame(this.animate); |
|
|
|