Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update icosahedron #23

Merged
merged 1 commit into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions icosahedron/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<meta name="viewport" content="width=device-width,initial-scale=1.0">

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

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

<!-- for splashscreen -->
<style>
Expand All @@ -29,9 +29,6 @@

<!-- Icosahedron Example Specific CSS -->
<link rel="stylesheet" href="./assets/css/icosahedron.css" />

<!-- Script for Three js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/0.147.0/three.min.js"></script>
</head>

<body>
Expand Down
22 changes: 11 additions & 11 deletions icosahedron/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pyodide.ffi import to_js
from pyscript.ffi import to_js
from pyscript.js_modules import THREE
from pyscript import when, window, document
from js import Math, THREE, performance, Object
from js import Math, performance
import asyncio

mouse = THREE.Vector2.new()
Expand Down Expand Up @@ -42,11 +43,9 @@ def mathRandom(num = 1):
particularGroup = THREE.Object3D.new()
modularGroup = THREE.Object3D.new()

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

particle_perms = {"color":"#FFFFFF", "side":THREE.DoubleSide}
particle_perms = Object.fromEntries(to_js(particle_perms))
particle_perms = to_js({"color":"#FFFFFF", "side":THREE.DoubleSide})

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

scene.add(sceneGroup)
scene.add(light)
scene.add(lightBack)
#scene.add(light)
#scene.add(lightBack)
#scene.add(ambientLight)

rectSize = 2
intensity = 14
rectSize = 3
intensity = 44
rectLight = THREE.RectAreaLight.new( 0x0FFFFF, intensity, rectSize, rectSize )
rectLight.position.set( 0, 0, 1 )
rectLight.lookAt( 0, 0, 0 )
Expand Down Expand Up @@ -155,4 +155,4 @@ async def main():
renderer.render( scene, camera )
await asyncio.sleep(0.02)

asyncio.ensure_future(main())
main()
3 changes: 3 additions & 0 deletions icosahedron/pyscript.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
name = "WebGL Icosahedron"
description = "An example how to use Three.js and WebGL to render an Icosahedron in PyScript."

[js_modules.main]
"https://esm.run/three" = "THREE"