8000 Improve WebGL Raycaster example (#478) · testnest/pyscript@715ceb9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 715ceb9

Browse files
authored
Improve WebGL Raycaster example (pyscript#478)
Signed-off-by: Ryan Russell <ryanrussell@users.noreply.github.com>
1 parent 0115b15 commit 715ceb9

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

examples/webgl/raycaster/index.html

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,23 @@
6868
scene.background = THREE.Color.new(setcolor)
6969
scene.fog = THREE.Fog.new(setcolor, 2.5, 3.5);
7070

71-
sceneGruop = THREE.Object3D.new();
72-
particularGruop = THREE.Object3D.new();
71+
sceneGroup = THREE.Object3D.new();
72+
particularGroup = THREE.Object3D.new();
7373

7474
def mathRandom(num = 1):
7575
setNumber = - Math.random() * num + Math.random() * num
7676
return setNumber
7777

78-
particularGruop = THREE.Object3D.new();
79-
modularGruop = THREE.Object3D.new();
78+
particularGroup = THREE.Object3D.new();
79+
modularGroup = THREE.Object3D.new();
8080

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

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

87-
def create_cubes(mathRandom, modularGruop):
87+
def create_cubes(mathRandom, modularGroup):
8888
i = 0
8989
while i < 30:
9090
geometry = THREE.IcosahedronGeometry.new();
@@ -102,13 +102,13 @@
102102
cube.rotation.y = mathRandom(180 * Math.PI / 180);
103103
cube.rotation.z = mathRandom(180 * Math.PI / 180);
104104
cube.position.set(cube.positionX, cube.positionY, cube.positionZ);
105-
modularGruop.add(cube);
105+
modularGroup.add(cube);
106106
i += 1
107107

108-
create_cubes(mathRandom, modularGruop)
108+
create_cubes(mathRandom, modularGroup)
109109

110110

111-
def generateParticle(mathRandom, particularGruop, num, amp = 2):
111+
def generateParticle(mathRandom, particularGroup, num, amp = 2):
112112
gmaterial = THREE.MeshPhysicalMaterial.new(particle_perms);
113113
gparticular = THREE.CircleGeometry.new(0.2,5);
114114
i = 0
@@ -119,14 +119,14 @@
119119
particular.rotation.set(mathRandom(),mathRandom(),mathRandom());
120120
particular.scale.set(pscale,pscale,pscale);
121121
particular.speedValue = mathRandom(1);
122-
particularGruop.add(particular);
122+
particularGroup.add(particular);
123123
i += 1
124124

125-
generateParticle(mathRandom, particularGruop, 200, 2)
125+
generateParticle(mathRandom, particularGroup, 200, 2)
126126

127-
sceneGruop.add(particularGruop);
128-
scene.add(modularGruop);
129-
scene.add(sceneGruop);
127+
sceneGroup.add(particularGroup);
128+
scene.add(modularGroup);
129+
scene.add(sceneGroup);
130130

131131
camera.position.set(0, 0, cameraRange);
132132
cameraValue = False;
@@ -143,7 +143,7 @@
143143
lightBack = THREE.PointLight.new(0x0FFFFF, 1);
144144
lightBack.position.set(0, -3, -1);
145145

146-
scene.add(sceneGruop);
146+
scene.add(sceneGroup);
147147
scene.add(light);
148148
scene.add(lightBack);
149149

@@ -164,16 +164,16 @@
164164
while True:
165165
time = performance.now() * 0.0003;
166166
i = 0
167-
while i < particularGruop.children.length:
168-
newObject = particularGruop.children[i];
167+
while i < particularGroup.children.length:
168+
newObject = particularGroup.children[i];
169169
newObject.rotation.x += newObject.speedValue/10;
170170
newObject.rotation.y += newObject.speedValue/10;
171171
newObject.rotation.z += newObject.speedValue/10;
172172
i += 1
173173

174174
i = 0
175-
while i < modularGruop.children.length:
176-
newCubes = modularGruop.children[i];
175+
while i < modularGroup.children.length:
176+
newCubes = modularGroup.children[i];
177177
newCubes.rotation.x += 0.008;
178178
newCubes.rotation.y += 0.005;
179179
newCubes.rotation.z += 0.003;
@@ -183,10 +183,10 @@
183183
newCubes.position.z = Math.sin(time * newCubes.positionY) * newCubes.positionX;
184184
i += 1
185185

186-
particularGruop.rotation.y += 0.005;
186+
particularGroup.rotation.y += 0.005;
187187

188-
modularGruop.rotation.y -= ((mouse.x * 4) + modularGruop.rotation.y) * uSpeed;
189-
modularGruop.rotation.x -= ((-mouse.y * 4) + modularGruop.rotation.x) * uSpeed;
188+
modularGroup.rotation.y -= ((mouse.x * 4) + modularGroup.rotation.y) * uSpeed;
189+
modularGroup.rotation.x -= ((-mouse.y * 4) + modularGroup.rotation.x) * uSpeed;
190190

191191
renderer.render( scene, camera )
192192
await asyncio.sleep(0.02)

0 commit comments

Comments
 (0)
0