当前位置:网站首页>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
边栏推荐
- [web Audit - source code disclosure] obtain source code methods and use tools
- postman和postman interceptor的安装
- BDF application - topology sequence
- 如何实现实时音视频聊天功能
- Test d'automatisation de l'interface utilisateur télécharger manuellement le pilote du navigateur à partir de maintenant
- Wechat applet development process (with mind map)
- lds链接的 顺序问题
- Use object composition in preference to class inheritance
- ClickPaaS低代码平台
- Plasticscm enterprise crack
猜你喜欢
我就一写代码的,王总整天和我谈格局...
Some enterprise interview questions of unity interview
Three level linkage demo of uniapp uview u-picker components
UI自动化测试从此告别手动下载浏览器驱动
How is the entered query SQL statement executed?
An elegant program for Euclid‘s algorithm
特殊版:SpreadJS v15.1 VS SpreadJS v15.0
ABP vNext microservice architecture detailed tutorial - distributed permission framework (Part 1)
error Couldn‘t find a package. JSON file in "your path“
我国算力规模排名全球第二:计算正向智算跨越
随机推荐
Uni app change the default component style
Pyqt pyside custom telescopic menu bar sharing (including tutorial)
[数组]566. 重塑矩阵-简单
Resolved (sqlalchemy+pandas.read_sql) attributeerror: 'engine' object has no attribute 'execution_ options‘
一文带你了解BI的前世今身与企业数字化转型的关系
Use object composition in preference to class inheritance
Redis source code analysis: redis cluster
Operation flow of UE4 DMX and grandma2 onpc 3.1.2.5
MindFusion.Virtual Keyboard for WPF
An elegant program for Euclid‘s algorithm
EasyCVR平台出现WebRTC协议视频播放不了是什么原因?
CTF stegano practice stegano 9
如何实现实时音视频聊天功能
[software reverse analysis tool] disassembly and decompilation tool
Laravel8 export excel file
深度学习——LSTM基础
ABP vNext microservice architecture detailed tutorial - distributed permission framework (Part 1)
Use threejs to create geometry and add materials, lights, shadows, animations, and axes
[understand series after reading] 6000 words teach you to realize interface automation from 0 to 1
[software reverse - basic knowledge] analysis method, assembly instruction architecture