当前位置:网站首页>Threejs rendering obj+mtl model source code, 3D factory model
Threejs rendering obj+mtl model source code, 3D factory model
2022-07-05 04:01:00 【Zuo Ben】
1, Introduce
Threejs Implement the introduction of the factory model , load obj+mtl Model source code download , It can be used for learning and research , Secondary development
2, Part of the code
// Create a scene , It will contain all our elements , Like an object , Cameras and lights .
var scene = new THREE.Scene();
var cubeLoader = new THREE.CubeTextureLoader();
// Create a camera , It defines where we are looking
camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
// Aim the camera at the center of the scene
camera.position.x = 10;
camera.position.y = 50;
camera.position.z = 90;
camera.lookAt(scene.position);
var orbit = new THREE.OrbitControls(camera);
// Create a renderer and set the size ,WebGLRenderer The computer graphics card will be used to render the scene
renderer = new THREE.WebGLRenderer({
antialias: true,
logarithmicDepthBuffer: true,
});
renderer.setClearColor(new THREE.Color("#0e0934"));
renderer.setSize(window.innerWidth, window.innerHeight);
// Basic light source , And apply to the scene
scene.add(new THREE.AmbientLight("#ffffff", 1.5));
initModel();
// Add the output of the renderer to HTML Elements
document.getElementById("dom").appendChild(renderer.domElement);
// Start animation
renderScene();
// Add model
function initModel() {
var mtlLoader = new THREE.MTLLoader();
mtlLoader.setPath("assets/models/factory_new/")
mtlLoader.load('factory.mtl', function(materials) {
materials.preload();
var objLoader = new THREE.OBJLoader();
objLoader.setMaterials(materials);
objLoader.load('assets/models/factory_new/factory.obj', function(object) {
mesh = object;
mesh.scale.set(0.0003, 0.0003, 0.0003);
mesh.position.set(-200, 0.5, -200);
scene.add(mesh);
}, function(xhr) {
let num = Math.floor(xhr.loaded / xhr.total * 100) / 100;
NProgress.set(num)
console.log(' Percentage of load complete '+(xhr.loaded/xhr.total*100)+'%');
});
});
}
3, download
Use threejs Render factory model source code , Download now
Model source file .max Format ,obj+mtl Format , Download now
边栏推荐
- EasyCVR平台出现WebRTC协议视频播放不了是什么原因?
- C # use awaiter
- 【web源码-代码审计方法】审计技巧及审计工具
- [C language] address book - dynamic and static implementation
- JVM garbage collection
- 阿里云ECS使用cloudfs4oss挂载OSS
- [数组]566. 重塑矩阵-简单
- Official announcement! The third cloud native programming challenge is officially launched!
- Pyqt5 displays file names and pictures
- Rust区块琏开发——签名加密与私钥公钥
猜你喜欢
Alibaba cloud ECS uses cloudfs4oss to mount OSS
Differences among 10 addressing modes
A brief introduction to the behavior tree of unity AI
MindFusion.Virtual Keyboard for WPF
An elegant program for Euclid‘s algorithm
ActiveReportsJS 3.1 VS ActiveReportsJS 3.0
在线SQL转Excel(xls/xlsx)工具
[brush questions] BFS topic selection
[C language] address book - dynamic and static implementation
Clickhouse materialized view
随机推荐
【刷题】BFS题目精选
Use of vscode software
EasyCVR更改录像存储路径,不生成录像文件如何解决?
[wp]bmzclub几道题的writeup
@Transactional 注解导致跨库查询失效的问题
请问一下我的请求是条件更新,但在buffer中就被拦截了,这种情况我只能每次去flush缓存么?
How does the applet solve the rendering layer network layer error?
输入的查询SQL语句,是如何执行的?
Wechat applet development process (with mind map)
C language course setting: cinema ticket selling management system
Laravel8 export excel file
It took two nights to get Wu Enda's machine learning course certificate from Stanford University
[an Xun cup 2019] not file upload
ActiveReportsJS 3.1 VS ActiveReportsJS 3.0
[punch in questions] integrated daily 5-question sharing (phase III)
[move pictures up, down, left and right through the keyboard in JS]
About the recent experience of writing questions
北京程序员的真实一天!!!!!
[wp][入门]刷弱类型题目
IronXL for . NET 2022.6