I’ve tried with your properties. May be problem is in objLoader and light? Here is working example for inspection:
site with error
Here is code of addWire function:
function addWire() {
let coords = [
{
lat: 18, long: 24//
},
{
lat: -8, long: -3//
},
{
lat: -15, long:-101//
},
{
lat: 50, long: 18//
},
{
lat: 35, long: -105//
},
{
lat: 73, long: -102
}
];
coords.forEach(function(item, i, coords) {
var mtlLoader = new MTLLoader();
mtlLoader.load('1.mtl', function (materials) {
materials.flatShading = true;
//
console.log(materials);
materials.preload();
var objLoader = new THREE.OBJLoader();
objLoader.setMaterials(materials);
objLoader.load('1.obj', function (object) {
group.add(object);
console.log(object);
object.translate(0, 0, 0.25 + 595);
var startVector = new THREE.Vector3(0, 0, 0);
var endVector = new THREE.Vector3(xrad, yrad, zrad);
var phi = (90-item.lat)*(Math.PI/180);
var theta = (item.long-180)*(Math.PI/180);
let xrad = -((595) * Math.sin(phi)*Math.cos(theta));
let zrad = ((595) * Math.sin(phi)*Math.sin(theta));
let yrad = ((595) * Math.cos(phi));
if ((item.lat < 0)&(item.lat > -45)&(item.long < 0)&(item.long > -45)){
var xrot = new THREE.Matrix4().makeRotationX( (180)*(Math.PI/180) - (90-item.lat)*(Math.PI/180) );
var yrot = new THREE.Matrix4().makeRotationY( (270)*(Math.PI/180) - (item.long-180)*(Math.PI/180) );
var xyrot = xrot.multiply(yrot);
var zrot = new THREE.Matrix4().makeRotationZ( 0 );
var xyzrot = xyrot.multiply(zrot);
object.applyMatrix( xyzrot );
};
if ((item.lat < 0)&(item.lat > -45)&(item.long < -90)&(item.long > -135)){
var xrot = new THREE.Matrix4().makeRotationX( (180)*(Math.PI/180) - (90-item.lat)*(Math.PI/180) );
var yrot = new THREE.Matrix4().makeRotationY( (270)*(Math.PI/180) - (item.long-180)*(Math.PI/180) );
var xyrot = xrot.multiply(yrot);
var zrot = new THREE.Matrix4().makeRotationZ( 0 );
var xyzrot = xyrot.multiply(zrot);
object.applyMatrix( xyzrot );
};
if ((item.lat > 0)&(item.lat < 45)&(item.long < -90)&(item.long > -135)){
var xrot = new THREE.Matrix4().makeRotationX( (180)*(Math.PI/180) - (90-item.lat)*(Math.PI/180) );
var yrot = new THREE.Matrix4().makeRotationY( (270)*(Math.PI/180) - (item.long-180)*(Math.PI/180) );
var xyrot = xrot.multiply(yrot);
var zrot = new THREE.Matrix4().makeRotationZ( 0 );
var xyzrot = xyrot.multiply(zrot);
object.applyMatrix( xyzrot );
};
if ((item.lat > 45)&(item.lat < 90)&(item.long < -90)&(item.long > -135)){
var xrot = new THREE.Matrix4().makeRotationX( (180)*(Math.PI/180) - (90-item.lat)*(Math.PI/180) );
var yrot = new THREE.Matrix4().makeRotationY( (264)*(Math.PI/180) - (item.long-180)*(Math.PI/180) );
var xyrot = xrot.multiply(yrot);
var zrot = new THREE.Matrix4().makeRotationZ( 0 );
var xyzrot = xyrot.multiply(zrot);
object.applyMatrix( xyzrot );
};
if ((item.lat > 0)&(item.lat < 45)&(item.long > 0)){
var xrot = new THREE.Matrix4().makeRotationX( (300)*(Math.PI/180) - (90-item.lat)*(Math.PI/180) );
var yrot = new THREE.Matrix4().makeRotationY( (-35)*(Math.PI/180) - (item.long-180)*(Math.PI/180) );
var xyrot = xrot.multiply(yrot);
var zrot = new THREE.Matrix4().makeRotationZ( 0 );
var xyzrot = xyrot.multiply(zrot);
object.applyMatrix( xyzrot );
};
if ((item.lat > 45)&(item.lat < 90)&(item.long > 0)){
var xrot = new THREE.Matrix4().makeRotationX( (-25)*(Math.PI/180) + (90-item.lat)*(Math.PI/180) );
var yrot = new THREE.Matrix4().makeRotationY( (-160)*(Math.PI/180) + (item.long-180)*(Math.PI/180) );
var xyrot = xrot.multiply(yrot);
var zrot = new THREE.Matrix4().makeRotationZ( 0 );
var xyzrot = xyrot.multiply(zrot);
object.applyMatrix( xyzrot );
};
object.position.set(xrad, zrad, yrad);
object.receiveShadow = true;
object.scale.multiplyScalar(0.25);
//object.getObjectByName( "Line012" ).material = new THREE.MeshPhongMaterial({
// color: 0x000000,
// shininess: 100,
// lights: true
//});
//object.lights = true;
object.traverse (function (child) {
if (child instanceof THREE.Mesh) {
child.material.emissive.setHex( 0x00ff00 );
child.material.specular.setHex( 0xff0000 );
child.material.lights=true;
child.material.shininess=300;
}
});
});
});
});
};
addConnectore is same. And start part of init:
var THREE = require('three')
var OBJLoader = require('three-obj-loader');
var MTLLoader = require('three-mtl-loader');
OBJLoader(THREE);
MTLLoader(THREE);
//VARIABLES
let canvas = document.getElementById('basicScene');
let width = window.innerWidth;
let height = window.innerHeight;
var fov = 75;
var near = 0.1;
var far = 20000;
var pos_x = 0;
var pos_y = 0;
var pos_z = 1800;
var color = 0x000000;
var mouse = new THREE.Vector2(), INTERSECTED;
var camera, scene, renderer, backgroundScene, backgroundCamera, group, controls, earth_texture, target;
init();
animate();
//CREATE_SCENE
function createScene() {
scene = new THREE.Scene();
scene.fog = new THREE.FogExp2( 0x000104, 0.0000675 );
group = new THREE.Object3D();
camera = new THREE.PerspectiveCamera( fov, width / height, near, far );
camera.position.set( pos_x, pos_y, pos_z );
let backgroundSceneMap = new THREE.TextureLoader().load( 'background_map.jpg' );
var backgroundSceneMesh = new THREE.Mesh( new THREE.PlaneGeometry(2, 2, 0), new THREE.MeshBasicMaterial( { map: backgroundSceneMap } ) );
backgroundSceneMesh.material.depthTest = false;
backgroundSceneMesh.material.depthWrite = false;
backgroundScene = new THREE.Scene();
backgroundCamera = new THREE.Camera();
backgroundScene.add(backgroundCamera);
backgroundScene.add(backgroundSceneMesh);
scene.add(group);
scene.add(camera);
};
function createRenderer() {
renderer = new THREE.WebGLRenderer( { canvas: canvas, antialias: true } );
renderer.setPixelRatio(window.devicePixelRatio > 1 ? 2 : 1);
renderer.setSize(width, height);
renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFSoftShadowMap;
controls = new OrbitControls(camera, renderer.domElement);
};