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

Commit7b7cbb6

Browse files
committed
added in a WIP for raycaster
1 parent520fe84 commit7b7cbb6

File tree

2 files changed

+194
-0
lines changed

2 files changed

+194
-0
lines changed
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<!DOCTYPE html>
2+
<htmllang="en">
3+
<head>
4+
<metacharset="UTF-8">
5+
<title>Raycaster</title>
6+
<metaname="viewport"content="width=device-width, initial-scale=1">
7+
<linkrel="stylesheet"href="./style.css">
8+
</head>
9+
<body>
10+
<divclass="container-fluid fixed-top header disable-selection">
11+
<divclass="row">
12+
<divclass="col"></div>
13+
<divclass="col-md-6">
14+
<divclass="row">
15+
<divclass="col">
16+
</div>
17+
</div>
18+
</div>
19+
<divclass="col"></div>
20+
</div>
21+
</div>
22+
<scriptsrc='https://cdnjs.cloudflare.com/ajax/libs/three.js/89/three.min.js'></script>
23+
24+
<scriptdefersrc="/build/pyscript.js"></script>
25+
<linkrel="stylesheet"href="/build/pyscript.css"/>
26+
<script>
27+
functioncreate_objects(mathRandom,modularGruop){
28+
for(vari=0;i<30;i++){
29+
vargeometry=newTHREE.IcosahedronGeometry(1);
30+
varmaterial=newTHREE.MeshStandardMaterial({flatShading:true,color:0x111111,transparent:false,opacity:1,wireframe:false});
31+
varcube=newTHREE.Mesh(geometry,material);
32+
cube.speedRotation=Math.random()*0.1;
33+
cube.positionX=mathRandom();
34+
cube.positionY=mathRandom();
35+
cube.positionZ=mathRandom();
36+
cube.castShadow=true;
37+
cube.receiveShadow=true;
38+
varnewScaleValue=mathRandom(0.3);
39+
cube.scale.set(newScaleValue,newScaleValue,newScaleValue);
40+
cube.rotation.x=mathRandom(180*Math.PI/180);
41+
cube.rotation.y=mathRandom(180*Math.PI/180);
42+
cube.rotation.z=mathRandom(180*Math.PI/180);
43+
cube.position.set(cube.positionX,cube.positionY,cube.positionZ);
44+
modularGruop.add(cube);
45+
}
46+
}
47+
functiongenerateParticle(mathRandom,particularGruop,num,amp=2){
48+
vargmaterial=newTHREE.MeshPhysicalMaterial({color:0xFFFFFF,side:THREE.DoubleSide});
49+
vargparticular=newTHREE.CircleGeometry(0.2,5);
50+
for(vari=1;i<num;i++){
51+
varpscale=0.001+Math.abs(mathRandom(0.03));
52+
varparticular=newTHREE.Mesh(gparticular,gmaterial);
53+
particular.position.set(mathRandom(amp),mathRandom(amp),mathRandom(amp));
54+
particular.rotation.set(mathRandom(),mathRandom(),mathRandom());
55+
particular.scale.set(pscale,pscale,pscale);
56+
particular.speedValue=mathRandom(1);
57+
particularGruop.add(particular);
58+
}
59+
}
60+
</script>
61+
<py-script>
62+
from pyodide import create_proxy, to_js
63+
from js import window
64+
from js import Math
65+
from js import THREE
66+
from js import create_objects, generateParticle
67+
68+
renderer = THREE.WebGLRenderer.new({"antialias":True})
69+
renderer.setSize(1000, 1000)
70+
renderer.shadowMap.enabled = False
71+
renderer.shadowMap.type = THREE.PCFSoftShadowMap
72+
renderer.shadowMap.needsUpdate = True
73+
74+
document.body.appendChild( renderer.domElement )
75+
76+
camera = THREE.PerspectiveCamera.new( 35, window.innerWidth / window.innerHeight, 1, 500 )
77+
scene = THREE.Scene.new()
78+
cameraRange = 3
79+
80+
camera.aspect = window.innerWidth / window.innerHeight
81+
camera.updateProjectionMatrix()
82+
renderer.setSize( window.innerWidth, window.innerHeight )
83+
84+
setcolor = "#000000"
85+
86+
scene.background = THREE.Color.new(setcolor)
87+
scene.fog = THREE.Fog.new(setcolor, 2.5, 3.5);
88+
89+
sceneGruop = THREE.Object3D.new();
90+
particularGruop = THREE.Object3D.new();
91+
92+
def mathRandom(num = 1):
93+
setNumber = - Math.random() * num + Math.random() * num
94+
return setNumber
95+
96+
particularGruop = THREE.Object3D.new();
97+
modularGruop = THREE.Object3D.new();
98+
99+
create_objects(mathRandom, modularGruop)
100+
generateParticle(mathRandom, particularGruop, 200, 2)
101+
102+
sceneGruop.add(particularGruop);
103+
scene.add(modularGruop);
104+
scene.add(sceneGruop);
105+
106+
camera.position.set(0, 0, cameraRange);
107+
cameraValue = False;
108+
109+
ambientLight = THREE.AmbientLight.new(0xFFFFFF, 0.1);
110+
111+
light = THREE.SpotLight.new(0xFFFFFF, 3);
112+
light.position.set(5, 5, 2);
113+
light.castShadow = True;
114+
light.shadow.mapSize.width = 10000;
115+
light.shadow.mapSize.height = light.shadow.mapSize.width;
116+
light.penumbra = 0.5;
117+
118+
lightBack = THREE.PointLight.new(0x0FFFFF, 1);
119+
lightBack.position.set(0, -3, -1);
120+
121+
scene.add(sceneGruop);
122+
scene.add(light);
123+
scene.add(lightBack);
124+
125+
rectSize = 2
126+
intensity = 100
127+
rectLight = THREE.RectAreaLight.new( 0x0FFFFF, intensity, rectSize, rectSize )
128+
rectLight.position.set( 0, 0, 1 )
129+
rectLight.lookAt( 0, 0, 0 )
130+
scene.add( rectLight )
131+
132+
rectLightHelper = THREE.RectAreaLightHelper.new( rectLight );
133+
raycaster = THREE.Raycaster.new();
134+
uSpeed = 0.1
135+
136+
time = 0.0003;
137+
camera.lookAt(scene.position)
138+
renderer.render( scene, camera )
139+
</py-script>
140+
</body>
141+
</html>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
body {
2+
margin:0;
3+
text-align: center;
4+
background-color: black;
5+
cursor: crosshair;
6+
}
7+
canvas {
8+
display: block;
9+
width:100%;
10+
height:100%;
11+
}
12+
.header {
13+
/*top:45%;*/
14+
top:45%;
15+
color:#DDDDDD;
16+
}
17+
.footer {
18+
bottom:3%;
19+
}
20+
.description {
21+
color: gray;
22+
padding-top:50px;
23+
}
24+
.btn {
25+
border-radius:30px;
26+
padding:10px30px;
27+
}
28+
a,a:hover,a:visited {
29+
color: red;
30+
text-decoration: none;
31+
}
32+
.disable-selection {
33+
-moz-user-select: none;/* Firefox */
34+
-ms-user-select: none;/* Internet Explorer */
35+
-khtml-user-select: none;/* KHTML browsers (e.g. Konqueror) */
36+
-webkit-user-select: none;/* Chrome, Safari, and Opera */
37+
-webkit-touch-callout: none;/* Disable Android and iOS callouts*/
38+
}
39+
h1::after {
40+
content:' V 2.0';
41+
font-size:12px;
42+
position:absolute;
43+
top:3px;
44+
padding-left:5px;
45+
font-weight:400;
46+
}
47+
h2::after {
48+
content:'2';
49+
font-size:12px;
50+
position:absolute;
51+
top:14px;
52+
padding-left:5px;
53+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp