Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <script src="https://threejs.org/build/three.min.js"></script>
<script src="https://threejs.org/examples/js/controls/OrbitControls.js"></script>
              
            
!

CSS

              
                html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}
canvas {
  width: 100%;
  height: 100%;
  display; block;
}
              
            
!

JS

              
                var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(60, 1, 1, 1000);
camera.position.setScalar(20);
var renderer = new THREE.WebGLRenderer({
  antialias: true
});
renderer.setClearColor(0x404040);
var canvas = renderer.domElement;
document.body.appendChild(canvas);

//var controls = new THREE.OrbitControls(camera, renderer.domElement);
const radius = 10;
//THIS IS HOROSHO
function convert(coord={
  lat:8.442042,
  lon:77.148370,
}){
  const parisSpherical = {
    lat: THREE.Math.degToRad(90 - coord.lat),
    lon: THREE.Math.degToRad(coord.lon)
  };
  const radius = 10;
  const vector = new THREE.Vector3().setFromSphericalCoords(
    radius,
    parisSpherical.lat,
    parisSpherical.lon
  );
  console.log(vector)
  return vector
}
// \ THIS IS HOROSHO

// check we did it correctly
//var spherical = new THREE.Spherical().setFromVector3(parisVector);
//console.log(spherical);
////////////////////////////

var texLoader = new THREE.TextureLoader();
texLoader.setCrossOrigin("anonymous");
var tex = texLoader.load(
      "https://cywarr.github.io/small-shop/map-political1.gif"
    );
var globe = new THREE.Mesh(
  new THREE.SphereGeometry(radius, 18, 9),
  new THREE.MeshBasicMaterial({
    map: tex,
    transparent: true,
    opacity: 0.25
  })
);
globe.geometry.rotateY(-Math.PI * 0.5);
scene.add(globe);

//HOW TO USE
var lineGeom = new THREE.BufferGeometry().setFromPoints([
  convert({lat:-50.606498,lon:-70.9632}),
  convert(),
]);

var line = new THREE.Line(
  lineGeom,
  new THREE.LineBasicMaterial({ color: "yellow" })
);
globe.add(line);

render();

function resize(renderer) {
  const canvas = renderer.domElement;
  const width = canvas.clientWidth;
  const height = canvas.clientHeight;
  const needResize = canvas.width !== width || canvas.height !== height;
  if (needResize) {
    renderer.setSize(width, height, false);
  }
  return needResize;
}

function render() {
  if (resize(renderer)) {
    camera.aspect = canvas.clientWidth / canvas.clientHeight;
    camera.updateProjectionMatrix();
  }
  renderer.render(scene, camera);
  requestAnimationFrame(render);
}

              
            
!
999px

Console