Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 97 additions & 16 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -15520,21 +15520,96 @@ index 27986a7d..05ee79b0 100644
init();

diff --git a/examples-testing/examples/webgpu_loader_materialx.ts b/examples-testing/examples/webgpu_loader_materialx.ts
index 8a2d2a0e..603f034c 100644
index a790281e..b2740408 100644
--- a/examples-testing/examples/webgpu_loader_materialx.ts
+++ b/examples-testing/examples/webgpu_loader_materialx.ts
@@ -59,8 +59,8 @@ const localSamples = [
@@ -1,6 +1,19 @@
import * as THREE from 'three/webgpu';

-import { Fn, length, fract, vec4, positionWorld, smoothstep, max, abs, float, cameraPosition, clamp } from 'three/tsl';
+import {
+ Fn,
+ length,
+ fract,
+ vec4,
+ positionWorld,
+ smoothstep,
+ max,
+ abs,
+ float,
+ cameraPosition,
+ clamp,
+ ShaderNodeObject,
+} from 'three/tsl';

import { OrbitControls } from 'three/addons/controls/OrbitControls.js';

@@ -61,9 +74,9 @@ const localSamples = [
'sheen_test.mtlx',
];

-let camera, scene, renderer, prefab;
-let camera, scene, renderer;
-let controls, prefab;
-const models = [];
+let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGPURenderer, prefab: THREE.Group;
+let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGPURenderer;
+let controls: OrbitControls, prefab: THREE.Group;
+const models: THREE.Group[] = [];

init();

@@ -129,7 +129,7 @@ function updateModelsAlign() {
@@ -89,29 +102,33 @@ function init() {

const material = new THREE.MeshStandardNodeMaterial();

- const gridXZ = Fn(([gridSize = float(1.0), dotWidth = float(0.1), lineWidth = float(0.02)]) => {
- const worldPos = positionWorld;
- const grid = fract(worldPos.xz.div(gridSize));
+ const gridXZ = Fn<[ShaderNodeObject<THREE.Node>, ShaderNodeObject<THREE.Node>, ShaderNodeObject<THREE.Node>]>(
+ ([gridSize = float(1.0), dotWidth = float(0.1), lineWidth = float(0.02)]) => {
+ const worldPos = positionWorld;
+ const grid = fract(worldPos.xz.div(gridSize));

- // Distance-based antialiasing
- const distToCamera = length(worldPos.sub(cameraPosition));
- const smoothing = clamp(distToCamera.div(100.0), 0.01, 0.02);
+ // Distance-based antialiasing
+ const distToCamera = length(worldPos.sub(cameraPosition));
+ const smoothing = clamp(distToCamera.div(100.0), 0.01, 0.02);

- // Create dots at cell centers
- const dotDist = length(grid.sub(0.5));
- const dots = smoothstep(dotWidth.add(smoothing), dotWidth.sub(smoothing), dotDist);
+ // Create dots at cell centers
+ const dotDist = length(grid.sub(0.5));
+ const dots = smoothstep(dotWidth.add(smoothing), dotWidth.sub(smoothing), dotDist);

- // Create grid lines
- const lineX = smoothstep(lineWidth.add(smoothing), lineWidth.sub(smoothing), abs(grid.x.sub(0.5)));
- const lineZ = smoothstep(lineWidth.add(smoothing), lineWidth.sub(smoothing), abs(grid.y.sub(0.5)));
- const lines = max(lineX, lineZ);
+ // Create grid lines
+ const lineX = smoothstep(lineWidth.add(smoothing), lineWidth.sub(smoothing), abs(grid.x.sub(0.5)));
+ const lineZ = smoothstep(lineWidth.add(smoothing), lineWidth.sub(smoothing), abs(grid.y.sub(0.5)));
+ const lines = max(lineX, lineZ);

- return max(dots, lines);
- });
+ return max(dots, lines);
+ },
+ );

- const radialGradient = Fn(([radius = float(10.0), falloff = float(1.0)]) => {
- return smoothstep(radius, radius.sub(falloff), length(positionWorld));
- });
+ const radialGradient = Fn<[ShaderNodeObject<THREE.Node>, ShaderNodeObject<THREE.Node>]>(
+ ([radius = float(10.0), falloff = float(1.0)]) => {
+ return smoothstep(radius, radius.sub(falloff), length(positionWorld));
+ },
+ );

// Create grid pattern
const gridPattern = gridXZ(1.0, 0.04, 0.01);
@@ -176,7 +193,7 @@ function updateModelsAlign() {
}
}

Expand All @@ -15543,7 +15618,7 @@ index 8a2d2a0e..603f034c 100644
const model = prefab.clone();

models.push(model);
@@ -143,12 +143,12 @@ async function addSample(sample, path) {
@@ -190,12 +207,12 @@ async function addSample(sample, path) {
const material = await new MaterialXLoader()
.setPath(path)
.loadAsync(sample)
Expand All @@ -15557,9 +15632,9 @@ index 8a2d2a0e..603f034c 100644
- const previewMesh = model.getObjectByName('Preview_Mesh');
+ const previewMesh = model.getObjectByName('Preview_Mesh') as THREE.Mesh;
previewMesh.material = material;
}

@@ -177,9 +177,9 @@ function addGUI() {
if (material.transparent) {
@@ -229,9 +246,9 @@ function addGUI() {
});
}

Expand Down Expand Up @@ -16347,7 +16422,7 @@ index b4694ef3..68ad678b 100644
init();

diff --git a/examples-testing/examples/webgpu_mrt_mask.ts b/examples-testing/examples/webgpu_mrt_mask.ts
index eec81e1c..4aa3cbac 100644
index 6125b972..f579d340 100644
--- a/examples-testing/examples/webgpu_mrt_mask.ts
+++ b/examples-testing/examples/webgpu_mrt_mask.ts
@@ -6,11 +6,11 @@ import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
Expand Down Expand Up @@ -17553,21 +17628,21 @@ index 45e298e7..207a463b 100644
postProcessing.render();

diff --git a/examples-testing/examples/webgpu_postprocessing_ssr.ts b/examples-testing/examples/webgpu_postprocessing_ssr.ts
index 1579a8d8..e5a06ef1 100644
index 00320f58..22780f64 100644
--- a/examples-testing/examples/webgpu_postprocessing_ssr.ts
+++ b/examples-testing/examples/webgpu_postprocessing_ssr.ts
@@ -11,8 +11,9 @@ import {
sample,
@@ -13,8 +13,9 @@ import {
directionToColor,
colorToDirection,
vec2,
+ ShaderNodeObject,
} from 'three/tsl';
-import { ssr } from 'three/addons/tsl/display/SSRNode.js';
+import SSRNode, { ssr } from 'three/addons/tsl/display/SSRNode.js';
import { smaa } from 'three/addons/tsl/display/SMAANode.js';

import { DRACOLoader } from 'three/addons/loaders/DRACOLoader.js';
@@ -29,8 +30,12 @@ const params = {
@@ -31,8 +32,12 @@ const params = {
enabled: true,
};

Expand All @@ -17582,12 +17657,18 @@ index 1579a8d8..e5a06ef1 100644

init();

@@ -49,9 +54,9 @@ async function init() {
@@ -51,13 +56,12 @@ async function init() {
loader.setDRACOLoader(dracoLoader);
loader.load('models/gltf/steampunk_camera.glb', function (gltf) {
gltf.scene.traverse(function (object) {
- if (object.material) {
+ if ((object as THREE.Mesh).material) {
- if (object.material.name === 'Lense_Casing') {
- object.material.transparent = true;
+ if ((object as THREE.Mesh<THREE.BufferGeometry, THREE.Material>).material) {
+ if ((object as THREE.Mesh<THREE.BufferGeometry, THREE.Material>).material.name === 'Lense_Casing') {
+ (object as THREE.Mesh<THREE.BufferGeometry, THREE.Material>).material.transparent = true;
}
-
// Avoid overdrawing
- object.material.side = THREE.FrontSide;
+ (object as THREE.Mesh<THREE.BufferGeometry, THREE.Material>).material.side = THREE.FrontSide;
Expand Down Expand Up @@ -17748,7 +17829,7 @@ index d4b197b3..ae7a2ade 100644

const fxSceneA = new FXScene(new THREE.BoxGeometry(2, 2, 2), new THREE.Vector3(0, -0.4, 0), 0xffffff);
diff --git a/examples-testing/examples/webgpu_procedural_texture.ts b/examples-testing/examples/webgpu_procedural_texture.ts
index 98516c6c..d0de6c2c 100644
index 04630e74..01152c09 100644
--- a/examples-testing/examples/webgpu_procedural_texture.ts
+++ b/examples-testing/examples/webgpu_procedural_texture.ts
@@ -4,7 +4,7 @@ import { gaussianBlur } from 'three/addons/tsl/display/GaussianBlurNode.js';
Expand Down
6 changes: 3 additions & 3 deletions types/three/src/renderers/webxr/WebXRDepthSensing.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Mesh } from "../../objects/Mesh.js";
import { RawTexture } from "../../textures/RawTexture.js";
import { ExternalTexture } from "../../textures/ExternalTexture.js";
import { WebXRArrayCamera } from "./WebXRManager.js";

export class WebXRDepthSensing {
texture: RawTexture | null;
texture: ExternalTexture | null;
mesh: Mesh | null;

depthNear: number;
Expand All @@ -17,5 +17,5 @@ export class WebXRDepthSensing {

reset(): void;

getDepthTexture(): RawTexture | null;
getDepthTexture(): ExternalTexture | null;
}
6 changes: 3 additions & 3 deletions types/three/src/renderers/webxr/WebXRManager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { PerspectiveCamera } from "../../cameras/PerspectiveCamera.js";
import { EventDispatcher } from "../../core/EventDispatcher.js";
import { Vector4 } from "../../math/Vector4.js";
import { Mesh } from "../../objects/Mesh.js";
import { RawTexture } from "../../textures/RawTexture.js";
import { ExternalTexture } from "../../textures/ExternalTexture.js";
import { WebGLRenderer } from "../WebGLRenderer.js";
import { XRGripSpace, XRHandSpace, XRTargetRaySpace } from "./WebXRController.js";

Expand Down Expand Up @@ -65,7 +65,7 @@ export class WebXRManager extends EventDispatcher<WebXRManagerEventMap> {

getEnvironmentBlendMode: () => XREnvironmentBlendMode | undefined;

getDepthTexture: () => RawTexture | null;
getDepthTexture: () => ExternalTexture | null;

updateCamera: (camera: PerspectiveCamera) => void;

Expand All @@ -79,7 +79,7 @@ export class WebXRManager extends EventDispatcher<WebXRManagerEventMap> {

getDepthSensingMesh: () => Mesh | null;

getCameraTexture: (xrCamera: WebXRCamera) => RawTexture | undefined;
getCameraTexture: (xrCamera: WebXRCamera) => ExternalTexture | undefined;

setAnimationLoop: (callback: XRFrameRequestCallback | null) => void;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Texture } from "./Texture.js";

declare class RawTexture extends Texture {
declare class ExternalTexture extends Texture {
sourceTexture: WebGLTexture | null;

readonly isRawTexture: true;
readonly isExternalTexture: true;

constructor(sourceTexture?: WebGLTexture | null);
}

export { RawTexture };
export { ExternalTexture };
Loading