Skip to content

Commit f0f0e19

Browse files
committed
Examples: Improved webgpu_lights_custom.
1 parent 7c1e61a commit f0f0e19

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed
47.2 KB
Loading

examples/webgpu_lights_custom.html

+8-6
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,24 @@
6060
}
6161

6262
camera = new THREE.PerspectiveCamera( 70, window.innerWidth / window.innerHeight, 0.1, 10 );
63-
camera.position.z = 2;
63+
camera.position.z = 1.5;
6464

6565
scene = new THREE.Scene();
6666
scene.background = new THREE.Color( 0x222222 );
6767

6868
// lights
6969

70-
const sphereGeometry = new THREE.SphereGeometry( 0.02, 16, 8 );
70+
const sphereGeometry = new THREE.SphereGeometry( 0.01, 16, 8 );
7171

72-
const addLight = ( hexColor, intensity = 2, distance = 1 ) => {
72+
const addLight = ( hexColor ) => {
7373

7474
const material = new MeshStandardNodeMaterial();
7575
material.colorNode = color( hexColor );
7676
material.lightsNode = lights(); // ignore scene lights
7777

7878
const mesh = new THREE.Mesh( sphereGeometry, material );
7979

80-
const light = new THREE.PointLight( hexColor, intensity, distance );
80+
const light = new THREE.PointLight( hexColor, 0.1, 0.8 );
8181
light.add( mesh );
8282

8383
scene.add( light );
@@ -98,7 +98,7 @@
9898

9999
const points = [];
100100

101-
for ( let i = 0; i < 3000; i ++ ) {
101+
for ( let i = 0; i < 1_000_000; i ++ ) {
102102

103103
const point = new THREE.Vector3().random().subScalar( 0.5 ).multiplyScalar( 2 );
104104
points.push( point );
@@ -126,7 +126,7 @@
126126
renderer.setPixelRatio( window.devicePixelRatio );
127127
renderer.setSize( window.innerWidth, window.innerHeight );
128128
renderer.setAnimationLoop( animate );
129-
renderer.toneMappingNode = toneMapping( THREE.LinearToneMapping, 1 );
129+
renderer.toneMappingNode = toneMapping( THREE.NeutralToneMapping, 1 );
130130
document.body.appendChild( renderer.domElement );
131131

132132
// controls
@@ -167,6 +167,8 @@
167167
light3.position.y = Math.cos( time * 0.3 ) * scale;
168168
light3.position.z = Math.sin( time * 0.5 ) * scale;
169169

170+
scene.rotation.y = time * 0.6;
171+
170172
renderer.render( scene, camera );
171173

172174
}

0 commit comments

Comments
 (0)