当前位置:网站首页>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
边栏推荐
- CTF stegano practice stegano 9
- [web Audit - source code disclosure] obtain source code methods and use tools
- 陇原战“疫“2021网络安全大赛 Web EasyJaba
- Analysis of dagger2 principle
- 测试开发是什么?为什么现在那么多公司都要招聘测试开发?
- PlasticSCM 企业版Crack
- 【看完就懂系列】一文6000字教你从0到1实现接口自动化
- 北京程序员的真实一天!!!!!
- ABP vNext microservice architecture detailed tutorial - distributed permission framework (Part 2)
- NEW:Devart dotConnect ADO.NET
猜你喜欢
Thread Basics
测试开发是什么?为什么现在那么多公司都要招聘测试开发?
[wp][introduction] brush weak type questions
DMX parameter exploration of grandma2 onpc 3.1.2.5
A brief introduction to the behavior tree of unity AI
在线SQL转Excel(xls/xlsx)工具
[untitled]
On the day 25K joined Tencent, I cried
NEW:Devart dotConnect ADO. NET
深度学习——LSTM基础
随机推荐
Summary of scene design
UE4 DMX和grandMA2 onPC 3.1.2.5的操作流程
ABP vNext microservice architecture detailed tutorial - distributed permission framework (Part 1)
企业级:Spire.Office for .NET:Platinum|7.7.x
KVM virtualization
Resolved (sqlalchemy+pandas.read_sql) attributeerror: 'engine' object has no attribute 'execution_ options‘
优先使用对象组合,而不是类继承
特殊版:SpreadJS v15.1 VS SpreadJS v15.0
NEW:Devart dotConnect ADO. NET
Basic function learning 02
How to use jedis of redis
[数组]566. 重塑矩阵-简单
Containerization Foundation
DMX parameter exploration of grandma2 onpc 3.1.2.5
如何实现实时音视频聊天功能
Why can't all browsers on my computer open web pages
[an Xun cup 2019] not file upload
DFS and BFS concepts of trees and graphs
As soon as I write the code, President Wang talks with me about the pattern all day
官宣!第三届云原生编程挑战赛正式启动!