three.js学习(4):相机

相机的类型
1.CubeCamera(立方体相机)
创建6个摄像机,将他们所拍摄的场景渲染到WebGLRenderTargetCube上。
(1)构造函数:
CubeCamera(near:number, far:number, cubeResolution:number,options:object)
*near–近端剪切面的距离
*far–远端剪切面的距离
*cubeResolution–立方体边缘的长度设置
*options–传递给自动生成的WebGLRenderTargetCube的纹理参数,默认为
{ format: RGBFormat, magFilter: LinearFilter, minFilter: LinearFilter }
(2)属性:
*Object3D类的公用属性
*.renderTarget:生成的立方体纹理
(3)方法:
*Object3D类的公用方法
*.update(renderer:WebGLRenderer,scene:scene):null
renderer–当前的WebGL渲染器
scene–当前场景
*.clear(renderer:WebGLRenderer,color:Boolean,depth:Boolean,stencil:Boolean):null
清空渲染目标的颜色、深度、模板缓冲区。
2.OrthographicCamera(正交相机)
一个使用正交投影的相机。在这种投影模式下,无论物体距离相机距离远或者近,在最终渲染的图片中物体的大小都保持不变。 这对于渲染2D场景或者UI元素是非常有用的。
(1)构造函数:
OrthographicCamera(left:number,right:number,top:number,bottom:number,near:number,far:number)
left–摄像机视椎体的左侧面
right–摄像机视椎体的右侧面
top–摄像机视椎体的上侧面
bottom–摄像机视椎体的下侧面
near --摄像机视椎体近端面
far–摄像机视椎体远端面
(2)属性:
*Object3D类的公用属性
*.left: float
*.right: float
*.top: float
*.bottom: float
*.near: float
*.far: float
*.isOrthographicCamera: boolean
测试这个类是否为正交相机,默认为true。
*.view: object
由setViewOffset设置,默认为null。
*.zoom: number
获取相机的缩放倍数,默认为1。
(3)方法:
*Camera的共有方法
*.setViewOffset(fullwidth: float,fullheight:float,x:float,y:float,width:float,height:float):null
fullWidth — 多视图的全宽设置
fullHeight — 多视图的全高设置
x — 副摄像机的水平偏移
y — 副摄像机的垂直偏移
width — 副摄像机的宽度
height — 副摄像机的高度
设置视椎体的偏移量
*.clearViewOffset():null
清空视椎体的偏移量
*.updateProjectionMatrix():null
更新相机矩阵
*.toJSON():json
使用json格式返回摄像机数据。

猜你喜欢

转载自blog.csdn.net/qq_31976161/article/details/84166746