from pyodide import create_proxy, to_js from js import window from js import Math from js import THREE from js import create_objects, generateParticle, performance, mouse, intersected renderer = THREE.WebGLRenderer.new({"antialias":True}) renderer.setSize(1000, 1000) renderer.shadowMap.enabled = False renderer.shadowMap.type = THREE.PCFSoftShadowMap renderer.shadowMap.needsUpdate = True document.body.appendChild( renderer.domElement ) camera = THREE.PerspectiveCamera.new( 35, window.innerWidth / window.innerHeight, 1, 500 ) scene = THREE.Scene.new() cameraRange = 3 camera.aspect = window.innerWidth / window.innerHeight camera.updateProjectionMatrix() renderer.setSize( window.innerWidth, window.innerHeight ) setcolor = "#000000" scene.background = THREE.Color.new(setcolor) scene.fog = THREE.Fog.new(setcolor, 2.5, 3.5); sceneGruop = THREE.Object3D.new(); particularGruop = THREE.Object3D.new(); def mathRandom(num = 1): setNumber = - Math.random() * num + Math.random() * num return setNumber particularGruop = THREE.Object3D.new(); modularGruop = THREE.Object3D.new(); create_objects(mathRandom, modularGruop) generateParticle(mathRandom, particularGruop, 200, 2) sceneGruop.add(particularGruop); scene.add(modularGruop); scene.add(sceneGruop); camera.position.set(0, 0, cameraRange); cameraValue = False; ambientLight = THREE.AmbientLight.new(0xFFFFFF, 0.1); light = THREE.SpotLight.new(0xFFFFFF, 3); light.position.set(5, 5, 2); light.castShadow = True; light.shadow.mapSize.width = 10000; light.shadow.mapSize.height = light.shadow.mapSize.width; light.penumbra = 0.5; lightBack = THREE.PointLight.new(0x0FFFFF, 1); lightBack.position.set(0, -3, -1); scene.add(sceneGruop); scene.add(light); scene.add(lightBack); rectSize = 2 intensity = 100 rectLight = THREE.RectAreaLight.new( 0x0FFFFF, intensity, rectSize, rectSize ) rectLight.position.set( 0, 0, 1 ) rectLight.lookAt( 0, 0, 0 ) scene.add( rectLight ) rectLightHelper = THREE.RectAreaLightHelper.new( rectLight ); raycaster = THREE.Raycaster.new(); uSpeed = 0.1 time = 0.0003; while True: time = performance.now() * 0.0003; i = 0 while i < particularGruop.children.length: newObject = particularGruop.children[i]; newObject.rotation.x += newObject.speedValue/10; newObject.rotation.y += newObject.speedValue/10; newObject.rotation.z += newObject.speedValue/10; i += 1 i = 0 while i < modularGruop.children.length: newCubes = modularGruop.children[i]; newCubes.rotation.x += 0.008; newCubes.rotation.y += 0.005; newCubes.rotation.z += 0.003; newCubes.position.x = Math.sin(time * newCubes.positionZ) * newCubes.positionY; newCubes.position.y = Math.cos(time * newCubes.positionX) * newCubes.positionZ; newCubes.position.z = Math.sin(time * newCubes.positionY) * newCubes.positionX; i += 1 particularGruop.rotation.y += 0.005; modularGruop.rotation.y -= ((mouse.x * 4) + modularGruop.rotation.y) * uSpeed; modularGruop.rotation.x -= ((-mouse.y * 4) + modularGruop.rotation.x) * uSpeed; camera.lookAt(scene.position) renderer.render( scene, camera ) await asyncio.sleep(0.01)