当前位置:网站首页>Threejs realizes the simulation of river, surface flow, pipe flow and sea surface
Threejs realizes the simulation of river, surface flow, pipe flow and sea surface
2022-06-30 04:23:00 【Zuo Ben】
1, Introduce
Use Three.js introduce Water.js, Realize the simulation of river surface , Piped water .
The renderings are as follows :
Reference cases :three.js webgl - shaders - ocean (threejs.org)
https://threejs.org/examples/webgl_shaders_ocean.html
three.js - water (threejs.org)
https://threejs.org/examples/webgl_water.html
2, Implementation notes
1, The river implementation needs to create an irregular geometry , Then create Water Object incoming Geometry
2, Simulating pipe flow requires creating two pipes , A pipe simulates the flow of water , A pipe is wrapped outside
// Create a smooth 2D spline
const curve = new THREE.SplineCurve([
new THREE.Vector2(1520, 2850),
new THREE.Vector2(420, 180),
new THREE.Vector2(220, 280),
new THREE.Vector2(100, -380),
new THREE.Vector2(-500, 780),
]);
// Returns the set of points at a given position on a curve
const points = curve.getPoints(1000);
// Points to create a smooth 3D spline
const curves = new THREE.CatmullRomCurve3([
new THREE.Vector3(100, 0, 100),
new THREE.Vector3(0, 0, 100),
new THREE.Vector3(0, -100, 100),
]);
// Create pipe Geometry
const geometryTube1 = new THREE.TubeGeometry(curves, 200, 10, 50);
const geometryTube = new THREE.TubeGeometry(curves, 200, 9, 50);
// Create materials
const materialTube = new THREE.MeshBasicMaterial({
color: "#00aa00", // Tube color
transparent: true, // Whether the pipe is transparent
side: THREE.DoubleSide,
opacity: 0.5, // Tube transparency
});
// Create a tube object
const meshTube = new THREE.Mesh(geometryTube1, materialTube);
meshTube.position.x = -300;
meshTube.rotation.y = Math.PI;
// Add to scene
scene.add(meshTube);
water = new Water(geometryTube, {
textureWidth: 112, // Water turbidity , density
textureHeight: 112, // Water turbidity , density
waterNormals: new THREE.TextureLoader().load('assets/textures/waternormals.jpg', function(texture) {
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
}),
waterColor: "#ffffff",
});
water.position.x = -300;
water.rotation.y = Math.PI;
scene.add(water);
let splineShape = new THREE.Shape(points);
let geometry = new THREE.ShapeGeometry(splineShape);
water1 = new Water(geometry, {
textureWidth: 1512, // Water turbidity , density
textureHeight: 1512, // Water turbidity , density
waterNormals: new THREE.TextureLoader().load('assets/textures/waternormals.jpg', function(texture) {
texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
}),
waterColor: "#ffffff", // Water color
});
water1.position.y = -90;
water1.position.x = -200;
water1.rotation.x = Math.PI * -0.5;
scene.add(water1);
Finally, pay attention to whether the water surface can have wave effect , stay render Add the following code
water.material.uniforms['time'].value += 2.0 / 60.0;边栏推荐
- Qt Creator 8 Beta2发布
- 2021-11-04
- el-upload上傳文件(手動上傳,自動上傳,上傳進度)
- 管道实现进程间通信之命名管道
- Anonymous pipeline for interprocess communication
- Pig-Latin (UVA492)
- Es2018 key summary
- How the FortiGate firewall rejects a port by using the local in policy policy
- 基于servlet+jsp+mysql实现的工资管理系统【源码+数据库】
- Error in conditional filter (if) syntax in sum function in SQL Server2005
猜你喜欢

Grasp grpc communication framework in simple terms

FortiGate firewall configuration log uploading regularly

Technology sharing | broadcast function design in integrated dispatching

el-upload上傳文件(手動上傳,自動上傳,上傳進度)
![Tea mall system based on SSM framework [project source code + database script + report]](/img/d9/0a46c0da9839a7186bd3a9ae55f0a5.png)
Tea mall system based on SSM framework [project source code + database script + report]

尝试链接数据库时出现链接超时报错,如何解决?

Interview topic of MySQL

MySQL DDL change

lego_ Reading and summary of loam code

Five methods to clear floating and their advantages and disadvantages
随机推荐
I get n offers in two months. I don't have any difficult interviewers here
Junior students summarize JS basic interview questions
Troubleshoot abnormal video playback problems in public network deployment based on Haikang ehomedemo tool
Educoder group purchase suspension box page production
《机器人SLAM导航核心技术与实战》第1季:第0章_SLAM发展综述
Implementation steps of dynamic proxy
How the FortiGate firewall rejects a port by using the local in policy policy
How to solve the problem of link hyperlinks when trying to link the database?
Error encountered in SQL statement, solve
el-upload上传文件(手动上传,自动上传,上传进度)
Error in conditional filter (if) syntax in sum function in SQL Server2005
Day 10 data saving and loading
Cloud native -- websocket of Web real-time communication technology
MySQL updates JSON string in array form
SQL append field
OneNote production schedule
Stack implementation integrated Calculator - code implementation
487-3279(POJ1002)
An error occurs when sqlyog imports the database. Please help solve it!
JS deconstruction assignment