|
@@ -4,6 +4,7 @@ import { UWB } from "../public/plugin/uwb/index.js";
|
|
|
import { FXAAShader } from "../public/shader/FAAXShader.js"
|
|
|
import '../public/libs/tools.js'
|
|
|
import { OBJLoader } from 'three/examples/js/loaders/OBJLoader.js';
|
|
|
+import { MTLLoader } from 'three/examples/js/loaders/MTLLoader.js';
|
|
|
import { OrbitControls } from 'three/examples/js/controls/OrbitControls.js';
|
|
|
|
|
|
|
|
@@ -767,8 +768,10 @@ if(objInited)
|
|
|
objInited = true;
|
|
|
//document.getElementById('mapMine').appendChild(renderer.domElement);
|
|
|
// set ambient light: roof, window, floor color
|
|
|
-const hlight = new THREE.AmbientLight(0xFFFFFF,500);
|
|
|
-scene.add(hlight);
|
|
|
+//const hlight = new THREE.AmbientLight(0xFFFFFF,1);
|
|
|
+//scene.add(hlight);
|
|
|
+//const colorfulLight = new THREE.PointLight(0xffffff, 1, 100); // red light
|
|
|
+//colorfulLight.position.set(-200, 130, -190);
|
|
|
// set orbit control
|
|
|
controls = new THREE.OrbitControls(camera,renderer.domElement);
|
|
|
|
|
@@ -808,36 +811,77 @@ var fileNo = 0;
|
|
|
const loader = new THREE.OBJLoader();
|
|
|
console.log('loader ok.')
|
|
|
|
|
|
+let textureLoader = new THREE.TextureLoader();
|
|
|
+
|
|
|
+//let material = new THREE.MeshBasicMaterial( { color: 0x00ff00 } ); // 绿色材质
|
|
|
+
|
|
|
+//let texture = textureLoader.load('bansei_1_392k_20200425_u1_v1.jpg'); // 加载你的纹理图片
|
|
|
+//
|
|
|
+//let material = new THREE.MeshBasicMaterial({ map: texture });
|
|
|
+
|
|
|
+//loader.setMaterials(new THREE.MeshPhongMaterial({ vertexColors: THREE.VertexColors }));
|
|
|
//loader.load('Warehouse.obj', (obj) => {
|
|
|
+
|
|
|
+let mtlLoader = new THREE.MTLLoader();
|
|
|
+mtlLoader.load('bansei_1_392k_20200425.mtl', function (materials) {
|
|
|
+
|
|
|
+ materials.preload();
|
|
|
+
|
|
|
+ loader.setMaterials(materials);
|
|
|
+
|
|
|
+
|
|
|
loader.load('bansei_1_392k_20200425.obj', (obj) => {
|
|
|
-obj.traverse((child) => {
|
|
|
- if (child instanceof THREE.Mesh) {
|
|
|
- // check if this part of the model should be transparent
|
|
|
- if (child.material.transparent == false) {
|
|
|
- child.material.transparent = true;
|
|
|
- child.material.opacity = 0.5; // Adjust opacity as needed
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
-// create model material
|
|
|
- var material = new THREE.MeshBasicMaterial({ color: 0x272727, transparent: true, opacity: 0.7 });
|
|
|
- obj.children[0].material = material;
|
|
|
-// scale model
|
|
|
-//obj.scale.set(4,4,4);
|
|
|
-obj.scale.set(12,12,12);
|
|
|
-obj.rotation.set(-Math.PI / 2, 0, 0);
|
|
|
- scene.add(obj);
|
|
|
-// [sample dataset] keep updating object location
|
|
|
-var interval = setInterval(function() {
|
|
|
- var formattedNumber = String(fileNo).padStart(6, '0');
|
|
|
- // call loadCoordinate function with parameters
|
|
|
- loadCoordinateData('/sample-dataset/'+formattedNumber+'.txt');
|
|
|
- // move to the next sample data file
|
|
|
- fileNo += 1;
|
|
|
- if (fileNo == 1806) clearInterval(interval);
|
|
|
-}, 100);
|
|
|
-animate();
|
|
|
+ obj.traverse((child) => {
|
|
|
+ if (child instanceof THREE.Mesh) {
|
|
|
+ // check if this part of the model should be transparent
|
|
|
+ if (child.material.transparent == false) {
|
|
|
+ child.material.transparent = true;
|
|
|
+ child.material.opacity = 0.8; // Adjust opacity as needed
|
|
|
+ //child.material = material;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ const directionalLight = new THREE.DirectionalLight( 0xffffff, 1 );
|
|
|
+ scene.add( directionalLight );
|
|
|
+
|
|
|
+ // Set the material with color
|
|
|
+ //const material = new THREE.MeshPhongMaterial({color: 0x888888 });
|
|
|
+
|
|
|
+ // Apply material to your object
|
|
|
+ //obj.children[0].material = material;
|
|
|
+
|
|
|
+ // create model material
|
|
|
+ //var material = new THREE.MeshBasicMaterial({ color: 0x272727, transparent: true, opacity: 0.7 });
|
|
|
+ //obj.children[0].material = material;
|
|
|
+ // scale model
|
|
|
+ //obj.scale.set(4,4,4);
|
|
|
+
|
|
|
+
|
|
|
+ obj.scale.set(12,12,12);
|
|
|
+ obj.rotation.set(-Math.PI / 2, 0, 0);
|
|
|
+ scene.add(obj);
|
|
|
+
|
|
|
+ //const hlight = new THREE.AmbientLight(0xFFFFFF,1);
|
|
|
+ //scene.add(hlight);
|
|
|
+
|
|
|
+ //renderer.render( scene, camera );
|
|
|
+ //return;
|
|
|
+ // [sample dataset] keep updating object location
|
|
|
+ var interval = setInterval(function() {
|
|
|
+ var formattedNumber = String(fileNo).padStart(6, '0');
|
|
|
+ // call loadCoordinate function with parameters
|
|
|
+ loadCoordinateData('/sample-dataset/'+formattedNumber+'.txt');
|
|
|
+ // move to the next sample data file
|
|
|
+ fileNo += 1;
|
|
|
+ if (fileNo == 1806) clearInterval(interval);
|
|
|
+ }, 100);
|
|
|
+ animate();
|
|
|
+ });
|
|
|
+
|
|
|
});
|
|
|
+
|
|
|
+
|
|
|
},500);
|
|
|
|
|
|
return;
|