You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WebCAD/sample/CameraUtil.ts

23 lines
969 B

import * as THREE from 'three'
export namespace CameraUtil
{
//创建基于名称的Map相机.
export function createCameraMap(): Map<string, THREE.Camera>
{
let cameraMap = new Map<string, THREE.Camera>();
//正交相机
let hei = 2 * window.innerHeight / window.innerWidth;
let wid = 2;
var f = 2;
let cameraOrt = new THREE.OrthographicCamera(window.innerWidth / - f, window.innerWidth / f, window.innerHeight / f, window.innerHeight / - f, - 50000, 100000);
7 years ago
cameraOrt.position.set(0, 0, 30);
cameraOrt.up.set(0, 0, -1);
cameraOrt.lookAt(new THREE.Vector3(0, 0, 0));
cameraMap.set("OrthographicCamera", cameraOrt);
//透视相机
let cameraPre = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 1, 200000);
cameraPre.position.set(0, 0, 5);
cameraMap.set("PerspectiveCamera", cameraPre);
return cameraMap;
}
}