-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathglobe2.html
81 lines (66 loc) · 2.33 KB
/
globe2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<html>
<head>
<title>pyscript globe</title>
<link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
<script defer src="https://pyscript.net/latest/pyscript.js"></script>
<script src="./js/three.min.js"></script>
<script src="./examples/js/loaders/GLTFLoader.js"></script>
<script src="./examples/js/controls/OrbitControls.js"></script>
<style>
body { margin: 0;}
canvas{width: 100%; height: 100%;}
</style>
</head>
<body>
<py-title>Globe with Location Search</py-title>
<py-box widths="4/5;1/5">
<py-inputbox id="new-task-content">
</py-inputbox>
<py-button id="new-task-btn" label="search">
def on_click(evt):
get_from_photon(new_task_content.value)
</py-button>
</py-box>
<ul>
<li >milk</li>
<li >eggs</li>
<li>bread</li>
</ul>
<p id="msg"> </p>
<py-script>
import pyodide
import json
from pyodide import create_proxy
from js import THREE, window, document
def get_from_photon(search):
url = 'https://photon.komoot.io/api/?q=' + search.replace(' ', '+')
response = pyodide.open_url(url)
Element('msg').write(json.loads(response.getvalue()))
scene = THREE.Scene.new();
light = THREE.AmbientLight.new( 0x777777 )
scene.add( light )
light = THREE.DirectionalLight.new( 0xffffff, 0.5 )
light.position.set(3, 5, 1)
camera = THREE.PerspectiveCamera.new(75, window.innerWidth / window.innerHeight, 0.1, 1000)
camera.position.set(0, 5, 3)
camera.add(light)
renderer = THREE.WebGLRenderer.new()
renderer.setSize(window.innerWidth, window.innerHeight)
controls = THREE.OrbitControls.new( camera, renderer.domElement );
geometry = THREE.SphereGeometry.new(0.5, 32, 32)
#material = THREE.MeshBasicMaterial.new(color="#00ff00")
material = THREE.MeshPhongMaterial.new()
texture = THREE.TextureLoader.new().load("./eo_base_2020_clean_720x360.jpg")
material.map = texture
sphere = THREE.Mesh.new( geometry, material )
scene.add( sphere )
renderer.render( scene, camera )
document.body.appendChild( renderer.domElement )
def animate(*args):
window.requestAnimationFrame( create_proxy(animate) )
controls.update()
renderer.render( scene, camera )
animate()
</py-script>
</body>
</html>