Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita0340a6

Browse files
committed
added in some animation
1 parent7b7cbb6 commita0340a6

File tree

1 file changed

+80
-3
lines changed

1 file changed

+80
-3
lines changed

‎pyscriptjs/examples/webgl/raycaster/index.html

Lines changed: 80 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,59 @@
5757
particularGruop.add(particular);
5858
}
5959
}
60+
varmouse=newTHREE.Vector2(),INTERSECTED;
61+
varintersected;
62+
63+
functiononMouseMove(event){
64+
event.preventDefault();
65+
mouse.x=(event.clientX/window.innerWidth)*2-1;
66+
mouse.y=-(event.clientY/window.innerHeight)*2+1;
67+
}
68+
functiononMouseDown(event){
69+
event.preventDefault();
70+
onMouseMove(event);
71+
raycaster.setFromCamera(mouse,camera);
72+
varintersected=raycaster.intersectObjects(modularGruop.children);
73+
if(intersected.length>0){
74+
cameraValue=false;
75+
if(INTERSECTED!=intersected[0].object){
76+
if(INTERSECTED)INTERSECTED.material.emissive.setHex(INTERSECTED.currentHex);
77+
78+
INTERSECTED=intersected[0].object;
79+
INTERSECTED.currentHex=INTERSECTED.material.emissive.getHex();
80+
INTERSECTED.material.emissive.setHex(0xFFFF00);
81+
//INTERSECTED.material.map = null;
82+
//lightBack.position.set(INTERSECTED.position.x,INTERSECTED.position.y,INTERSECTED.position.z);
83+
84+
TweenMax.to(camera.position,1,{
85+
x:INTERSECTED.position.x,
86+
y:INTERSECTED.position.y,
87+
z:INTERSECTED.position.z+3,
88+
ease:Power2.easeInOut
89+
});
90+
91+
}else{
92+
if(INTERSECTED)INTERSECTED.material.emissive.setHex(INTERSECTED.currentHex);
93+
INTERSECTED=null;
94+
95+
}
96+
}
97+
console.log(intersected.length);
98+
}
99+
functiononMouseUp(event){
100+
101+
}
102+
103+
window.addEventListener('mousedown',onMouseDown,false);
104+
window.addEventListener('mouseup',onMouseUp,false);
105+
window.addEventListener('mousemove',onMouseMove,false);
60106
</script>
61107
<py-script>
62108
from pyodide import create_proxy, to_js
63109
from js import window
64110
from js import Math
65111
from js import THREE
66-
from js import create_objects, generateParticle
112+
from js import create_objects, generateParticle, performance, mouse, intersected
67113

68114
renderer = THREE.WebGLRenderer.new({"antialias":True})
69115
renderer.setSize(1000, 1000)
@@ -134,8 +180,39 @@
134180
uSpeed = 0.1
135181

136182
time = 0.0003;
137-
camera.lookAt(scene.position)
138-
renderer.render( scene, camera )
183+
184+
while True:
185+
time = performance.now() * 0.0003;
186+
i = 0
187+
while i<particularGruop.children.length:
188+
newObject =particularGruop.children[i];
189+
newObject.rotation.x+=newObject.speedValue/10;
190+
newObject.rotation.y+=newObject.speedValue/10;
191+
newObject.rotation.z+=newObject.speedValue/10;
192+
i+=1
193+
194+
i =0
195+
whilei<modularGruop.children.length:
196+
newCubes =modularGruop.children[i];
197+
newCubes.rotation.x+=0.008;
198+
newCubes.rotation.y+=0.005;
199+
newCubes.rotation.z+=0.003;
200+
201+
newCubes.position.x =Math.sin(time*newCubes.positionZ)*newCubes.positionY;
202+
newCubes.position.y =Math.cos(time*newCubes.positionX)*newCubes.positionZ;
203+
newCubes.position.z =Math.sin(time*newCubes.positionY)*newCubes.positionX;
204+
i+=1
205+
206+
particularGruop.rotation.y+=0.005;
207+
208+
modularGruop.rotation.y-=((mouse.x*4)+modularGruop.rotation.y)*uSpeed;
209+
modularGruop.rotation.x-=((-mouse.y*4)+modularGruop.rotation.x)*uSpeed;
210+
211+
camera.lookAt(scene.position)
212+
renderer.render(scene,camera)
213+
awaitasyncio.sleep(0.01)
214+
215+
139216
</py-script>
140217
</body>
141218
</html>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp