Skip to content

Commit dd0410f

Browse files
committed
update icosahedron
Used 2024.8.2 fixed lighting - changed since version 147
1 parent 1ee3844 commit dd0410f

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

icosahedron/index.html

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
<meta name="viewport" content="width=device-width,initial-scale=1.0">
88

99
<!-- PyScript CSS -->
10-
<link rel="stylesheet" href="https://pyscript.net/releases/2024.1.1/core.css">
10+
<link rel="stylesheet" href="https://pyscript.net/releases/2024.8.2/core.css">
1111
<!-- CSS for examples -->
1212
<link rel="stylesheet" href="./assets/css/examples.css" />
1313

1414
<!-- This script tag bootstraps PyScript -->
15-
<script type="module" src="https://pyscript.net/releases/2024.1.1/core.js"></script>
15+
<script type="module" src="https://pyscript.net/releases/2024.8.2/core.js"></script>
1616

1717
<!-- for splashscreen -->
1818
<style>
@@ -29,9 +29,6 @@
2929

3030
<!-- Icosahedron Example Specific CSS -->
3131
<link rel="stylesheet" href="./assets/css/icosahedron.css" />
32-
33-
<!-- Script for Three js -->
34-
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/0.147.0/three.min.js"></script>
3532
</head>
3633

3734
<body>

icosahedron/main.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from pyodide.ffi import to_js
1+
from pyscript.ffi import to_js
2+
from pyscript.js_modules import THREE
23
from pyscript import when, window, document
3-
from js import Math, THREE, performance, Object
4+
from js import Math, performance
45
import asyncio
56

67
mouse = THREE.Vector2.new()
@@ -42,11 +43,9 @@ def mathRandom(num = 1):
4243
particularGroup = THREE.Object3D.new()
4344
modularGroup = THREE.Object3D.new()
4445

45-
perms = {"flatShading":True, "color":"#111111", "transparent":False, "opacity":1, "wireframe":False}
46-
perms = Object.fromEntries(to_js(perms))
46+
perms = to_js({"flatShading":True, "color":"#111111", "transparent":False, "opacity":1, "wireframe":False})
4747

48-
particle_perms = {"color":"#FFFFFF", "side":THREE.DoubleSide}
49-
particle_perms = Object.fromEntries(to_js(particle_perms))
48+
particle_perms = to_js({"color":"#FFFFFF", "side":THREE.DoubleSide})
5049

5150
def create_cubes(mathRandom, modularGroup):
5251
i = 0
@@ -108,11 +107,12 @@ def generateParticle(mathRandom, particularGroup, num, amp = 2):
108107
lightBack.position.set(0, -3, -1)
109108

110109
scene.add(sceneGroup)
111-
scene.add(light)
112-
scene.add(lightBack)
110+
#scene.add(light)
111+
#scene.add(lightBack)
112+
#scene.add(ambientLight)
113113

114-
rectSize = 2
115-
intensity = 14
114+
rectSize = 3
115+
intensity = 44
116116
rectLight = THREE.RectAreaLight.new( 0x0FFFFF, intensity, rectSize, rectSize )
117117
rectLight.position.set( 0, 0, 1 )
118118
rectLight.lookAt( 0, 0, 0 )
@@ -155,4 +155,4 @@ async def main():
155155
renderer.render( scene, camera )
156156
await asyncio.sleep(0.02)
157157

158-
asyncio.ensure_future(main())
158+
main()

icosahedron/pyscript.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
name = "WebGL Icosahedron"
22
description = "An example how to use Three.js and WebGL to render an Icosahedron in PyScript."
3+
4+
[js_modules.main]
5+
"https://esm.run/three" = "THREE"

0 commit comments

Comments
 (0)