Skip to content

Commit 36eeccb

Browse files
authored
WebGPU Renderer: cache GPUBindGroupLayouts (#1197)
* Update three.js * Add src * Update patch and delete src * Update declarations * Add examples * Update patch and delete examples
1 parent bc7450f commit 36eeccb

File tree

4 files changed

+87
-161
lines changed

4 files changed

+87
-161
lines changed

examples-testing/changes.patch

Lines changed: 1 addition & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -8193,97 +8193,6 @@ index 599a1369..a23a0582 100644
81938193
const geometry = new THREE.BoxGeometry(5, 5, 5);
81948194

81958195
const material = new THREE.ShaderMaterial({
8196-
diff --git a/examples-testing/examples/webgl_materials_curvature.ts b/examples-testing/examples/webgl_materials_curvature.ts
8197-
index 60992dbc..15625389 100644
8198-
--- a/examples-testing/examples/webgl_materials_curvature.ts
8199-
+++ b/examples-testing/examples/webgl_materials_curvature.ts
8200-
@@ -4,14 +4,16 @@ import { GUI } from 'three/addons/libs/lil-gui.module.min.js';
8201-
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
8202-
import { OBJLoader } from 'three/addons/loaders/OBJLoader.js';
8203-
8204-
-let camera, scene, renderer;
8205-
+let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGLRenderer;
8206-
8207-
-let ninjaMeshRaw, curvatureAttribute, bufferGeo;
8208-
+let ninjaMeshRaw: THREE.Mesh,
8209-
+ curvatureAttribute: Float32Array,
8210-
+ bufferGeo: THREE.BufferGeometry<Record<string, THREE.BufferAttribute>>;
8211-
8212-
init();
8213-
8214-
//returns average of elements in a dictionary
8215-
-function average(dict) {
8216-
+function average(dict: Record<string, number>) {
8217-
let sum = 0;
8218-
let length = 0;
8219-
8220-
@@ -24,26 +26,26 @@ function average(dict) {
8221-
}
8222-
8223-
//clamp a number between min and max
8224-
-function clamp(number, min, max) {
8225-
+function clamp(number: number, min: number, max: number) {
8226-
return Math.max(min, Math.min(number, max));
8227-
}
8228-
8229-
//filter the curvature array to only show concave values
8230-
-function filterConcave(curvature) {
8231-
+function filterConcave(curvature: Float32Array) {
8232-
for (let i = 0; i < curvature.length; i++) {
8233-
curvature[i] = Math.abs(clamp(curvature[i], -1, 0));
8234-
}
8235-
}
8236-
8237-
//filter the curvature array to only show convex values
8238-
-function filterConvex(curvature) {
8239-
+function filterConvex(curvature: Float32Array) {
8240-
for (let i = 0; i < curvature.length; i++) {
8241-
curvature[i] = clamp(curvature[i], 0, 1);
8242-
}
8243-
}
8244-
8245-
//filter the curvature array to show both the concave and convex values
8246-
-function filterBoth(curvature) {
8247-
+function filterBoth(curvature: Float32Array) {
8248-
for (let i = 0; i < curvature.length; i++) {
8249-
curvature[i] = Math.abs(curvature[i]);
8250-
}
8251-
@@ -74,10 +76,12 @@ function init() {
8252-
//load the obj
8253-
loader.load('models/obj/ninja/ninjaHead_Low.obj', function (object) {
8254-
object.traverse(function (child) {
8255-
- if (child.isMesh) {
8256-
- bufferGeo = child.geometry;
8257-
+ if ((child as THREE.Mesh).isMesh) {
8258-
+ bufferGeo = (child as THREE.Mesh).geometry as THREE.BufferGeometry<
8259-
+ Record<string, THREE.BufferAttribute>
8260-
+ >;
8261-
bufferGeo.center();
8262-
- const dict = {};
8263-
+ const dict: Record<string, Record<string, number>> = {};
8264-
8265-
for (let i = 0; i < bufferGeo.attributes.position.count; i += 3) {
8266-
//create a dictionary of every position, and its neighboring positions
8267-
@@ -140,7 +144,7 @@ function init() {
8268-
dict[strC][strB] = c2b;
8269-
}
8270-
8271-
- let curvatureDict = {};
8272-
+ let curvatureDict: Record<string, number> = {};
8273-
let min = 10,
8274-
max = 0;
8275-
8276-
@@ -197,8 +201,8 @@ function init() {
8277-
filterBoth(curvatureFiltered);
8278-
8279-
const materialRaw = new THREE.ShaderMaterial({
8280-
- vertexShader: document.getElementById('vertexShaderRaw').textContent,
8281-
- fragmentShader: document.getElementById('fragmentShaderRaw').textContent,
8282-
+ vertexShader: document.getElementById('vertexShaderRaw')!.textContent!,
8283-
+ fragmentShader: document.getElementById('fragmentShaderRaw')!.textContent!,
8284-
});
8285-
8286-
ninjaMeshRaw = new THREE.Mesh(bufferGeo, materialRaw);
82878196
diff --git a/examples-testing/examples/webgl_materials_displacementmap.ts b/examples-testing/examples/webgl_materials_displacementmap.ts
82888197
index fd0be9a5..9b08fe73 100644
82898198
--- a/examples-testing/examples/webgl_materials_displacementmap.ts
@@ -15329,7 +15238,7 @@ index 097d06af..3836e7ee 100644
1532915238
init();
1533015239

1533115240
diff --git a/examples-testing/examples/webgpu_textures_anisotropy.ts b/examples-testing/examples/webgpu_textures_anisotropy.ts
15332-
index 21cc1197..eec04d7e 100644
15241+
index 7eb0ce1b..7528f59f 100644
1533315242
--- a/examples-testing/examples/webgpu_textures_anisotropy.ts
1533415243
+++ b/examples-testing/examples/webgpu_textures_anisotropy.ts
1533515244
@@ -1,10 +1,10 @@

0 commit comments

Comments
 (0)