当前位置:网站首页>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 .
边栏推荐
- Vertex shader to slice shader procedure, varying variable
- How to create Apple Developer personal account P8 certificate
- MongoD管理数据库的方法介绍
- Cocos creator collision and collision callback do not take effect
- Oracle control file loss recovery archive mode method
- MySQL bit type resolution
- 【数字IC验证快速入门】19、SystemVerilog学习之基本语法6(线程内部通信...内含实践练习)
- Postman generate timestamp, future timestamp
- 一大波开源小抄来袭
- 大表delete删数据导致数据库异常解决
猜你喜欢
[make a boat diary] [shapr3d STL format to gcode]
unnamed prototyped parameters not allowed when body is present
【数字IC验证快速入门】23、SystemVerilog项目实践之AHB-SRAMC(3)(AHB协议基本要点)
When opening the system window under UE4 shipping, the problem of crash is attached with the plug-in download address
Create lib Library in keil and use lib Library
[Lanzhou University] information sharing of postgraduate entrance examination and re examination
Use of SVN
Cocos creator collision and collision callback do not take effect
Yunxiaoduo software internal test distribution test platform description document
Postman generate timestamp, future timestamp
随机推荐
Introduction of mongod management database method
Pit avoidance: description of null values in in and not in SQL
OpenGL common functions
The "go to definition" in VS2010 does not respond or prompts the solution of "symbol not found"
Keil5 does not support online simulation of STM32 F0 series
Vertex shader to slice shader procedure, varying variable
How to release NFT in batches in opensea (rinkeby test network)
STM32F103C8T6 PWM驱动舵机(SG90)
【数字IC验证快速入门】23、SystemVerilog项目实践之AHB-SRAMC(3)(AHB协议基本要点)
如何在opensea批量发布NFT(Rinkeby测试网)
The rebound problem of using Scrollview in cocos Creator
【數字IC驗證快速入門】20、SystemVerilog學習之基本語法7(覆蓋率驅動...內含實踐練習)
AB package details in unity (super detail, features, packaging, loading, manager)
摘抄的只言片语
Connecting FTP server tutorial
Unity's ASE realizes cartoon flame
MongoD管理数据库的方法介绍
Please supervise the 2022 plan
[quick start of Digital IC Verification] 29. Ahb-sramc (9) (ahb-sramc svtb overview) of SystemVerilog project practice
全日制研究生和非全日制研究生的区别!