Skip to content

Commit d50dbd8

Browse files
authored
Lensflare: Add WebGPU version. (#1272)
* Update three.js * Add examples * Update patch and delete examples * Format
1 parent f495247 commit d50dbd8

File tree

4 files changed

+69
-12
lines changed

4 files changed

+69
-12
lines changed

examples-testing/changes.patch

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7354,7 +7354,7 @@ index c8bce4bf..a28a7f00 100644
73547354

73557355
loader.load(`textures/equirectangular/spruit_sunrise_${resolution}.hdr.jpg`, function (texture) {
73567356
diff --git a/examples-testing/examples/webgl_loader_tilt.ts b/examples-testing/examples/webgl_loader_tilt.ts
7357-
index 2a583c2b..8e3e976b 100644
7357+
index 843b3cfd..ea737c79 100644
73587358
--- a/examples-testing/examples/webgl_loader_tilt.ts
73597359
+++ b/examples-testing/examples/webgl_loader_tilt.ts
73607360
@@ -3,7 +3,7 @@ import * as THREE from 'three';
@@ -9944,7 +9944,7 @@ index ecc9b28e..2e894236 100644
99449944
init();
99459945

99469946
diff --git a/examples-testing/examples/webgl_postprocessing_advanced.ts b/examples-testing/examples/webgl_postprocessing_advanced.ts
9947-
index adaef620..2b43e46a 100644
9947+
index 82fc39be..1a14c2b9 100644
99489948
--- a/examples-testing/examples/webgl_postprocessing_advanced.ts
99499949
+++ b/examples-testing/examples/webgl_postprocessing_advanced.ts
99509950
@@ -21,11 +21,21 @@ import { GammaCorrectionShader } from 'three/addons/shaders/GammaCorrectionShade
@@ -13622,6 +13622,38 @@ index cfd72172..ae3271f9 100644
1362213622
}
1362313623

1362413624
renderer.render(scene, camera);
13625+
diff --git a/examples-testing/examples/webgpu_lensflares.ts b/examples-testing/examples/webgpu_lensflares.ts
13626+
index 40478039..0abdb8f1 100644
13627+
--- a/examples-testing/examples/webgpu_lensflares.ts
13628+
+++ b/examples-testing/examples/webgpu_lensflares.ts
13629+
@@ -1,14 +1,14 @@
13630+
-import * as THREE from 'three';
13631+
+import * as THREE from 'three/webgpu';
13632+
13633+
import Stats from 'three/addons/libs/stats.module.js';
13634+
13635+
import { FlyControls } from 'three/addons/controls/FlyControls.js';
13636+
import { LensflareMesh, LensflareElement } from 'three/addons/objects/LensflareMesh.js';
13637+
13638+
-let container, stats;
13639+
+let container: HTMLDivElement, stats: Stats;
13640+
13641+
-let camera, scene, renderer;
13642+
-let controls;
13643+
+let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGPURenderer;
13644+
+let controls: FlyControls;
13645+
13646+
const clock = new THREE.Clock();
13647+
13648+
@@ -73,7 +73,7 @@ function init() {
13649+
addLight(0.08, 0.8, 0.5, 0, 0, -1000);
13650+
addLight(0.995, 0.5, 0.9, 5000, 5000, -1000);
13651+
13652+
- function addLight(h, s, l, x, y, z) {
13653+
+ function addLight(h: number, s: number, l: number, x: number, y: number, z: number) {
13654+
const light = new THREE.PointLight(0xffffff, 1.5, 2000, 0);
13655+
light.color.setHSL(h, s, l);
13656+
light.position.set(x, y, z);
1362513657
diff --git a/examples-testing/examples/webgpu_lightprobe.ts b/examples-testing/examples/webgpu_lightprobe.ts
1362613658
index 66f9ffcb..0bcfb599 100644
1362713659
--- a/examples-testing/examples/webgpu_lightprobe.ts

three.js

Submodule three.js updated 53 files
Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
import { Color, Mesh, Texture } from "three";
22

3-
export class LensflareElement {
4-
constructor(texture: Texture, size?: number, distance?: number, color?: Color);
3+
declare class Lensflare extends Mesh {
4+
readonly isLensflare: true;
5+
6+
constructor();
7+
8+
addElement: (element: LensflareElement) => void;
9+
dispose: () => void;
10+
}
11+
12+
declare class LensflareElement {
513
texture: Texture;
614
size: number;
715
distance: number;
816
color: Color;
9-
}
10-
11-
export class Lensflare extends Mesh {
12-
constructor();
13-
readonly isLensflare: true;
1417

15-
addElement(element: LensflareElement): void;
16-
dispose(): void;
18+
constructor(texture: Texture, size?: number, distance?: number, color?: Color);
1719
}
20+
21+
export { Lensflare, LensflareElement };
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Color, Mesh, Texture } from "three";
2+
3+
declare class LensflareMesh extends Mesh {
4+
readonly isLensflare: true;
5+
6+
constructor();
7+
8+
addElement: (element: LensflareElement) => void;
9+
dispose: () => void;
10+
}
11+
12+
declare class LensflareElement {
13+
texture: Texture;
14+
size: number;
15+
distance: number;
16+
color: Color;
17+
18+
constructor(texture: Texture, size?: number, distance?: number, color?: Color);
19+
}
20+
21+
export { LensflareElement, LensflareMesh };

0 commit comments

Comments
 (0)