JSFiddle - React, Tailwind, and code Playground
HTML
<script src="http://jeromeetienne.github.io/threex.planets/examples/vendor/three.js/build/three.min.js"></script>
CSS
body {
background-color:black;
}
JavaScript
function calcPosFromLatLonRad(lat,lon,radius){
var phi = (90-lat)*(Math.PI/180);
var theta = (lon+180)*(Math.PI/180);
x = -((radius) * Math.sin(phi)*Math.cos(theta));
z = ((radius) * Math.sin(phi)*Math.sin(theta));
y = ((radius) * Math.cos(phi));
console.log([x,y,z]);
return [x,y,z];
}
var THREEx = THREEx || {}
THREEx.Planets = {}
THREEx.Planets.baseURL = '../'
THREEx.Planets.createRandomPoints = function(){
meshes=[];
for(var i = 0 ; i < 10 ; i++){
var geometry = new THREE.SphereGeometry(0.025, 20, 20)
var material = new THREE.MeshBasicMaterial({
color: new THREE.Color('white')
})
var mesh = new THREE.Mesh(geometry, material)
meshes.push(mesh);
}
return meshes
}
THREEx.Planets.createEarth = function(){
var geometry = new THREE.SphereGeometry(0.5, 32, 32)
var material = new THREE.MeshPhongMaterial({
map : THREE.ImageUtils.loadTexture('http://i.imgur.com/puZgGjm.jpg'),
})
var mesh = new THREE.Mesh(geometry, material)
return mesh
}
var renderer = new THREE.WebGLRenderer({
antialias : true
});
renderer.setSize( window.innerWidth, window.innerHeight );
document.body.appendChild( renderer.domElement );
renderer.shadowMapEnabled = true
var updateFcts = [];
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.01, 100 );
camera.position.z = 1.5;
var light = new THREE.AmbientLight( 0x888888 )
scene.add( light )
// var light = new THREE.DirectionalLight( 'white', 1)
// light.position.set(5,5,5)
// light.target.position.set( 0, 0, 0 )
// scene.add( light )
var light = new THREE.DirectionalLight( 0xcccccc, 1 )
light.position.set(5,5,5)
scene.add( light )
light.castShadow = true
light.shadowCameraNear = 0.01
light.shadowCameraFar = 15
light.shadowCameraFov = 45
light.shadowCameraLeft = -1
light.shadowCameraRight = 1
light.shadowCameraTop = 1
light.shadowCameraBottom= -1
// light.shadowCameraVisible =...