BufferGeometry
Object3D
Raycaster
Camera
CubeCamera
PerspectiveCamera
OrthographicCamera
StereoCamera
Clock
Curve
CurvePath
Path
Shape
ShapePath
ArrowHelper
AxesHelper
BoxHelper
Box3Helper
CameraHelper
DirectionalLightHelper
GridHelper
PolarGridHelper
HemisphereLightHelper
PlaneHelper
PointLightHelper
SkeletonHelper
SpotLightHelper
Light
PointLight
RectAreaLight
SpotLight
DirectionalLight
HemisphereLight
LightShadow
PointLightShadow
AnimationLoader
AudioLoader
BufferGeometryLoader
CompressedTextureLoader
CubeTextureLoader
DataTextureLoader
FileLoader
ImageBitmapLoader
ImageLoader
Loader
LoaderUtils
MaterialLoader
ObjectLoader
TextureLoader
LoadingManager
Material
Box2
Box3
Color
Cylindrical
Euler
Frustum
Interpolant
Line3
MathUtils
Matrix3
Matrix4
Plane
Quaternion
AnimationAction
AnimationClip
AnimationMixer
AnimationObjectGroup
AnimationUtils
keyframeTrack
PropertyBinding
PropertyMixer
BooleanKeyframeTrack
QuaternionKeyframeTrack
StringKeyframeTrack
Audio
AudioAnalyser
AudioContext
AudioListener
PositionalAudio

PerspectiveCamera.setViewOffset()

PerspectiveCamera.setViewOffset() 方法将视角镜头的显示区域分成四个部分,并按照给定的偏移量和相对大小将它们放置在窗口中。

语法

camera.setViewOffset( fullWidth, fullHeight, x, y, width, height );

参数

  • fullWidth:完整的视口宽度,即不考虑偏移量的情况下视口的宽度。
  • fullHeight:完整的视口高度,即不考虑偏移量的情况下视口的高度。
  • x:视角镜头的左下角距左侧边缘的像素偏移量。
  • y:视角镜头的左下角距底部边缘的像素偏移量。
  • width:视角镜头显示区域的宽度。
  • height:视角镜头显示区域的高度。

返回值

没有返回值。

示例

var camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );
camera.position.z = 5;

// 将视角镜头的显示区域分成四份,其中左上方为主要显示区域
camera.setViewOffset( window.innerWidth, window.innerHeight, -50, -50, window.innerWidth / 2, window.innerHeight / 2 );

var renderer = new THREE.WebGLRenderer( { alpha: true } );
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );

var geometry = new THREE.BoxGeometry( 1, 1, 1 );
var material = new THREE.MeshBasicMaterial( { color: 0xffffff } );
var cube = new THREE.Mesh( geometry, material );
scene.add( cube );

function animate() {
	requestAnimationFrame( animate );

	cube.rotation.x += 0.01;
	cube.rotation.y += 0.01;

	renderer.render( scene, camera );
}
animate();

此示例将视角镜头的显示区域分成四个部分,并将左上方视口设置为主要显示区域。