hello every one ,
i am new to three.js.
i want to use three.js in augmented reality with ionic 1 framework.
i need to display three.js sphere at specific latitude longitude. and as i rotate my device it should be displayed in my device by my application camera. all things will be dynamic. do i need to use three.js DeviceOrientationControls ? if yes then how can I ?
var scene = new THREE.Scene();
var camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
var renderer = new THREE.WebGLRenderer({
alpha: true
});
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));
var geometry0 = new THREE.Geometry()
geometry0.vertices = [new THREE.Vector3(x,y,z)];
var spheres ;
for (var i = 0; i < geometry0.vertices.length; i++) {
var sphereGeometry = new THREE.SphereGeometry(0, 0, 0);
var sphereMaterial = new THREE.MeshBasicMaterial({
color: 0xff0000,
opacity: 1
});
var spheres= new THREE.Mesh(sphereGeometry, sphereMaterial);
spheres.position.set(geometry0.vertices[i].x,
geometry0.vertices.y,
geometry0.vertices.z);
scene.add(spheres);
renderer.setClearColor(0x000000, 0);
renderer.setSize(window.innerWidth, window.innerHeight);
camera.position.z = 3;
var render = function() {
requestAnimationFrame(render);
renderer.render(scene, camera);
};
render();
}
}
calcPosFromLatLonRad(21.1830, 72.8316, 10000);
here is my code but it displays nothing.
i can run simple cube demo in my application but not able to display three.js object on latitude and longitude.
please help me. is there anyone expert with three.js then please help me.