-
Notifications
You must be signed in to change notification settings - Fork 2
/
sky.html
67 lines (53 loc) · 1.92 KB
/
sky.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
<html>
<head>
<title>pyscript sky</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/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-script>
from pyodide import create_proxy
from js import THREE, window, document, console, Array
scene = THREE.Scene.new()
camera = THREE.PerspectiveCamera.new(55, window.innerWidth/window.innerHeight,45,30000)
camera.position.set(1200, -250, 2000)
renderer = THREE.WebGLRenderer.new()
renderer.setSize(window.innerWidth, window.innerHeight)
document.body.appendChild(renderer.domElement)
controls = THREE.OrbitControls.new(camera, renderer.domElement)
controls.enabled = True
controls.minDistance = 700
controls.maxDistance = 1500
controls.autoRotate = True
controls.autoRotateSpeed = 1.0
ft = THREE.TextureLoader.new().load("skybox_front.png")
bk = THREE.TextureLoader.new().load("skybox_back.png")
up = THREE.TextureLoader.new().load("skybox_up.png")
dn = THREE.TextureLoader.new().load("skybox_down.png")
rt = THREE.TextureLoader.new().load("skybox_right.png")
lf = THREE.TextureLoader.new().load("skybox_left.png")
textures = [ft, bk, up, dn, rt, lf]
materials = Array.new()
for i in textures:
mat = THREE.MeshBasicMaterial.new()
mat.map = i
mat.side = THREE.BackSide
materials.push(mat)
skyboxGeo = THREE.BoxGeometry.new(10000, 10000, 10000)
skybox = THREE.Mesh.new(skyboxGeo, materials)
scene.add(skybox)
def animate(*args):
window.requestAnimationFrame( create_proxy(animate) )
controls.update()
renderer.render( scene, camera )
animate()
</py-script>
</body>
</html>