0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

leafletを鍛える。Advent Calendar 2019

Day 13

leafletを鍛える。その9

Last updated at Posted at 2018-09-15

#概要
leafletを鍛えてみた。
threeで、東京ドーム1個分、書いてみた。

#写真

image

#サンプルコード

var map = L.map('map').setView([37.9, 140.1], 15);
var mapLink = '<a href="http://openstreetmap.org">OpenStreetMap</a>';
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
    attribution: '&copy; ' + mapLink + ' Contributors',
    maxZoom: 18,
}).addTo(map);

var scene = new THREE.Scene();
var renderer = new THREE.WebGLRenderer();
var glLayer = L.canvasOverlay().drawing(drawingOnCanvas).addTo(map);
var canvas = glLayer.canvas();
glLayer.canvas.width = canvas.clientWidth;
glLayer.canvas.height = canvas.clientHeight;
renderer = new THREE.WebGLRenderer({
    canvas: canvas,
    alpha: true
});
renderer.setSize(450, 450);

var camera0 = new THREE.PerspectiveCamera(45, 1, 1, 1000);
camera0.position.set(100, 100, 100);
camera0.lookAt(new THREE.Vector3(0.0, 0.0, 0.0));
scene.add(camera0);

var light = new THREE.DirectionalLight(0xffffff);
light.position.set(0, 0, 1);
scene.add(light);

var geometry = new THREE.SphereGeometry(23, 16, 16, 0, Math.PI * 2, 0, Math.PI / 2);
var material = new THREE.MeshBasicMaterial({
    color: 0xff0000
});
var mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);   

renderer.render(scene, camera0);
function drawingOnCanvas(canvasOverlay, params) {    
    var camera0;
    if (params.zoom == 16) camera0 = new THREE.PerspectiveCamera(25, 1, 1, 1000);    
    if (params.zoom == 15) camera0 = new THREE.PerspectiveCamera(45, 1, 1, 1000);
    if (params.zoom == 14) camera0 = new THREE.PerspectiveCamera(75, 1, 1, 1000);    
    if (params.zoom == 13) camera0 = new THREE.PerspectiveCamera(105, 1, 1, 1000);    
    camera0.position.set(100, 100, 100);
    camera0.lookAt(new THREE.Vector3(0.0, 0.0, 0.0));

    renderer.render(scene, camera0);
}




#成果物

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?