-
Notifications
You must be signed in to change notification settings - Fork 2
/
globe.html
58 lines (44 loc) · 1.59 KB
/
globe.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
<html>
<head>
<title>pyscript globe</title>
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
<script src="./js/three.min.js"></script>
<script src="./examples/js/controls/OrbitControls.js"></script>
<style>
body { margin: 0;}
canvas{width: 100%; height: 100%;}
</style>
</head>
<body>
<py-script>
from pyodide import create_proxy
from js import THREE, window, document
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>