当前位置:网站首页>Three. JS basic element usage
Three. JS basic element usage
2022-07-19 11:46:00 【The sadness of No.7 Park】
One 、Scene
Where can the scene make you 、 Put something for three.js To render , This is where you place the object 、 Where the lights and cameras .
// Create a scene
const scene = new THREE.Scene();
// Scene background color
scene.background = new THREE.Color(0xffffff);
// Fog
scene.fog = new THREE.Fog(0xffffff, 0, 750);Two 、camera
After you create a camera, you need to add it to the scene ,scene.add(camera);
2.1 Perspective camera (PerspectiveCamera)
This projection mode is used to simulate the scene seen by the human eye , It is 3D The most common projection mode used in scene rendering .
const camera = new THREE.PerspectiveCamera(75, element.offsetWidth / element.offsetHeight, 1, 1000);
// Set the camera position (x,y,z)
camera.position.set(0, 10, 0);PerspectiveCamera( fov : Number, aspect : Number, near : Number, far : Number )
fov — Camera cone vertical field of view angle
aspect — Camera cone aspect ratio
near — Camera cone near end face
far — Far end of camera cone 2.2 Orthographic camera (OrthographicCamera)
In this projection mode , Whether the object is far or close to the camera , The size of the object remains the same in the final rendered image .
3、 ... and 、WebGLRenderer Renderers
3.1 Constructors :WebGLRenderer( parameters : Object )
parameters Parameters can be chosen :
- antialias: Anti-Aliasing , The default is false
- depth: Whether the drawing cache has at least 6 Bit deep cache . The default is true
const renderer = new THREE.WebGLRenderer({ antialias: true });3.1 Method
setPixelRatio(value: number) Set the device pixel ratio . Usually used to avoid HiDPI The drawing on the device is blurred
setSize(width : Integer, height : Integer, updateStyle : Boolean) Will output canvas The size of is adjusted to (width, height) And consider the device pixel ratio , And change the viewport from (0, 0) Start adjusting to fit take updateStyle Set to false To prevent canvas Make any changes to the style of .
renderer.setPixelRatio(window.devicePixelRatio);
renderer.setSize(element.offsetWidth, element.offsetHeight);render( scene : Object3D, camera : Camera ) Render a scene with a camera
边栏推荐
- 搭建OpenStack-M版的Cinder所碰到过的状况
- SQL UNION操作符
- Resources for Physics based simulation in Computer Graphics 图形学中物理模拟的资源整理
- Redis Distributed cache - Redis Cluster
- TCP congestion control details | 7 Surpass TCP
- Choice is more important than effort
- Mpu9250 ky9250 attitude, angle module and mpu9250 MPL DMA comparison
- 02-3、指针和引用的区别
- Antd form setting array fields
- 466-82(3、146、215)
猜你喜欢

华为无线设备配置频谱导航

Opencv draw a black rectangle and write the serial number

Redis Distributed cache - Redis Cluster

Bet Net is a good thing

Huawei firewall authentication technology

Lychee sound quality high fidelity AI noise reduction technology sharing

03-1、内联函数、auto关键字、typeid、nullptr

From "passive" to "active", how can zeta technology help to upgrade "rfid2.0"?

JVM钩子hooks函数

Dual machine hot standby of Huawei firewall (NGFW)
随机推荐
Keras deep learning practice (14) -- r-cnn target detection from scratch
TiKV 内存参数性能调优
Delegate parents and other loaders
Round table record: fireside dialogue -- how to realize innovation in Web3
[unity technology accumulation] simple timer & Co process & delay function
Push down calculation result cache
Play with the one-stop scheme of cann target detection and recognition
Unity3d read mpu9250 example source code
Keras深度学习实战(14)——从零开始实现R-CNN目标检测
Wechat applet cloud development 1 - Database
Solve the problem that QQ mail and Thunderbird cannot log in to outlook
【PostgreSQL 】PostgreSQL 15对distinct的优化
Cv02 Roge matrix, rotation vector, angle
热议:老公今年已经34周岁想读博,以后做科研,怎么办?
03-1. Inline function, auto keyword, typeID, nullptr
Leetcode 1252. 奇数值单元格的数目
Introduction of database lock, shared with InnoDB, exclusive lock
Solution of connecting MySQL instance with public network
QT -- excellent open source project
NAT technology and NAT alg