当前位置:网站首页>Three. JS introductory learning notes 03: perspective projection camera
Three. JS introductory learning notes 03: perspective projection camera
2022-07-07 15:48:00 【Jiang Duoduo_ Mostly Harmless 】
Reference Content :
https://www.ituring.com.cn/book/miniarticle/49446
## Perspective projection camera
Different from orthogonal projection , The size of an object is not affected by distance , Perspective projection is more in line with physical vision , Near and far away .
structure :
var camera = new THREE.PerspectiveCamera(fov, aspect, near, far);
Gray is the visual body , Parts that can be rendered ,fov Is the angle in the vertical direction of the visual body ( Angle system ).
Code
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>3d_camera</title>
<script type="text/javascript" src="js/three.js"></script>
</head>
<body>
<script type="text/javascript">
//renderer
//
var renderer = new THREE.WebGLRenderer();
renderer.setSize(400, 300);
//
document.getElementsByTagName("body")[0].appendChild(renderer.domElement);
//scene
var scene = new THREE.Scene();
//camera
var camera = new THREE.PerspectiveCamera(45, 400 / 300, 1, 10);
camera.position.set(0, 0, 5);
scene.add(camera);
//cube
var cube = new THREE.Mesh(new THREE.CubeGeometry(1,1,1),
new THREE.MeshBasicMaterial({
color:0xff0000,
wireframe:true
})
);
scene.add(cube);
//render
renderer.render(scene, camera);
</script>
</body>
</html>
fov Change to 60 The effect is as follows :
fov Change to 60 in the future ,cube Instead, it shrinks , As shown in the figure below , Although the actual size of the cube has not changed , But when the vertical angle of the camera is set larger , The visual body has become larger , Therefore, the size of the cube relative to the whole visual body becomes smaller , The square looks smaller .
in other words ,canvas The drawn area is still wide 400 high 300, This size has not changed , After the scene volume increases , Projected on the original width 400 high 300 In the drawing area , it seems cube It shrinks .
change fov It will not cause the horizontal and vertical proportion of the picture to change , And change aspect Will change the horizontal and vertical proportions . This effect is similar 2.3 section , The description will not be repeated here .
The size of the rendered object is a relative change .
边栏推荐
- 【数字IC验证快速入门】25、SystemVerilog项目实践之AHB-SRAMC(5)(AHB 重点回顾,要点提炼)
- Cocos creator collision and collision callback do not take effect
- 【数字IC验证快速入门】26、SystemVerilog项目实践之AHB-SRAMC(6)(APB协议基本要点)
- Getting started with webgl (3)
- [Lanzhou University] information sharing of postgraduate entrance examination and re examination
- 【微信小程序】Chapter(5):微信小程序基础API接口
- Points for attention in porting gd32 F4 series programs to gd32 F3 series
- postman生成时间戳,未来时间戳
- 2. Basic knowledge of golang
- 【数字IC验证快速入门】18、SystemVerilog学习之基本语法5(并发线程...内含实践练习)
猜你喜欢
[deep learning] image hyperspectral experiment: srcnn/fsrcnn
Briefly describe the working principle of kept
Vertex shader to slice shader procedure, varying variable
webgl_ Enter the three-dimensional world (1)
[quick start of Digital IC Verification] 18. Basic grammar of SystemVerilog learning 5 (concurrent threads... Including practical exercises)
HW初级流量监控,到底该怎么做
numpy--疫情数据分析案例
[target detection] yolov5 Runtong voc2007 data set
[quickstart to Digital IC Validation] 20. Basic syntax for system verilog Learning 7 (Coverage Driven... Including practical exercises)
AB package details in unity (super detail, features, packaging, loading, manager)
随机推荐
OpenGL common functions
Getting started with webgl (1)
[original] all management without assessment is nonsense!
一大波开源小抄来袭
Implementation of crawling web pages and saving them to MySQL using the scrapy framework
【数字IC验证快速入门】22、SystemVerilog项目实践之AHB-SRAMC(2)(AMBA总线介绍)
[quick start of Digital IC Verification] 25. AHB sramc of SystemVerilog project practice (5) (AHB key review, key points refining)
居然从408改考自命题!211华北电力大学(北京)
Postman generate timestamp, future timestamp
【數字IC驗證快速入門】26、SystemVerilog項目實踐之AHB-SRAMC(6)(APB協議基本要點)
Stm32f103c8t6 PWM drive steering gear (sg90)
Do you know the relationship between the most important indicators of two strong wind control and the quality of the customer base
Yunxiaoduo software internal test distribution test platform description document
【兰州大学】考研初试复试资料分享
2022 all open source enterprise card issuing network repair short website and other bugs_ 2022 enterprise level multi merchant card issuing platform source code
避坑:Sql中 in 和not in中有null值的情况说明
从 1.5 开始搭建一个微服务框架链路追踪 traceId
Zhongang Mining: Fluorite continues to lead the growth of new energy market
XMIND frame drawing tool
Window环境下配置Mongodb数据库