Skip to content

Commit 6e207b3

Browse files
authored
RawTexture: Rename to ExternalTexture. (#1760)
* RawTexture: Rename to ExternalTexture. * Update three.js * Add src * Update patch and delete src * Add examples * Update patch and delete examples * Fix * Add src * Update * Update patch and delete src
1 parent b90822b commit 6e207b3

File tree

5 files changed

+107
-26
lines changed

5 files changed

+107
-26
lines changed

examples-testing/changes.patch

Lines changed: 97 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15520,21 +15520,96 @@ index 27986a7d..05ee79b0 100644
1552015520
init();
1552115521

1552215522
diff --git a/examples-testing/examples/webgpu_loader_materialx.ts b/examples-testing/examples/webgpu_loader_materialx.ts
15523-
index 8a2d2a0e..603f034c 100644
15523+
index a790281e..b2740408 100644
1552415524
--- a/examples-testing/examples/webgpu_loader_materialx.ts
1552515525
+++ b/examples-testing/examples/webgpu_loader_materialx.ts
15526-
@@ -59,8 +59,8 @@ const localSamples = [
15526+
@@ -1,6 +1,19 @@
15527+
import * as THREE from 'three/webgpu';
15528+
15529+
-import { Fn, length, fract, vec4, positionWorld, smoothstep, max, abs, float, cameraPosition, clamp } from 'three/tsl';
15530+
+import {
15531+
+ Fn,
15532+
+ length,
15533+
+ fract,
15534+
+ vec4,
15535+
+ positionWorld,
15536+
+ smoothstep,
15537+
+ max,
15538+
+ abs,
15539+
+ float,
15540+
+ cameraPosition,
15541+
+ clamp,
15542+
+ ShaderNodeObject,
15543+
+} from 'three/tsl';
15544+
15545+
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
15546+
15547+
@@ -61,9 +74,9 @@ const localSamples = [
1552715548
'sheen_test.mtlx',
1552815549
];
1552915550

15530-
-let camera, scene, renderer, prefab;
15551+
-let camera, scene, renderer;
15552+
-let controls, prefab;
1553115553
-const models = [];
15532-
+let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGPURenderer, prefab: THREE.Group;
15554+
+let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGPURenderer;
15555+
+let controls: OrbitControls, prefab: THREE.Group;
1553315556
+const models: THREE.Group[] = [];
1553415557

1553515558
init();
1553615559

15537-
@@ -129,7 +129,7 @@ function updateModelsAlign() {
15560+
@@ -89,29 +102,33 @@ function init() {
15561+
15562+
const material = new THREE.MeshStandardNodeMaterial();
15563+
15564+
- const gridXZ = Fn(([gridSize = float(1.0), dotWidth = float(0.1), lineWidth = float(0.02)]) => {
15565+
- const worldPos = positionWorld;
15566+
- const grid = fract(worldPos.xz.div(gridSize));
15567+
+ const gridXZ = Fn<[ShaderNodeObject<THREE.Node>, ShaderNodeObject<THREE.Node>, ShaderNodeObject<THREE.Node>]>(
15568+
+ ([gridSize = float(1.0), dotWidth = float(0.1), lineWidth = float(0.02)]) => {
15569+
+ const worldPos = positionWorld;
15570+
+ const grid = fract(worldPos.xz.div(gridSize));
15571+
15572+
- // Distance-based antialiasing
15573+
- const distToCamera = length(worldPos.sub(cameraPosition));
15574+
- const smoothing = clamp(distToCamera.div(100.0), 0.01, 0.02);
15575+
+ // Distance-based antialiasing
15576+
+ const distToCamera = length(worldPos.sub(cameraPosition));
15577+
+ const smoothing = clamp(distToCamera.div(100.0), 0.01, 0.02);
15578+
15579+
- // Create dots at cell centers
15580+
- const dotDist = length(grid.sub(0.5));
15581+
- const dots = smoothstep(dotWidth.add(smoothing), dotWidth.sub(smoothing), dotDist);
15582+
+ // Create dots at cell centers
15583+
+ const dotDist = length(grid.sub(0.5));
15584+
+ const dots = smoothstep(dotWidth.add(smoothing), dotWidth.sub(smoothing), dotDist);
15585+
15586+
- // Create grid lines
15587+
- const lineX = smoothstep(lineWidth.add(smoothing), lineWidth.sub(smoothing), abs(grid.x.sub(0.5)));
15588+
- const lineZ = smoothstep(lineWidth.add(smoothing), lineWidth.sub(smoothing), abs(grid.y.sub(0.5)));
15589+
- const lines = max(lineX, lineZ);
15590+
+ // Create grid lines
15591+
+ const lineX = smoothstep(lineWidth.add(smoothing), lineWidth.sub(smoothing), abs(grid.x.sub(0.5)));
15592+
+ const lineZ = smoothstep(lineWidth.add(smoothing), lineWidth.sub(smoothing), abs(grid.y.sub(0.5)));
15593+
+ const lines = max(lineX, lineZ);
15594+
15595+
- return max(dots, lines);
15596+
- });
15597+
+ return max(dots, lines);
15598+
+ },
15599+
+ );
15600+
15601+
- const radialGradient = Fn(([radius = float(10.0), falloff = float(1.0)]) => {
15602+
- return smoothstep(radius, radius.sub(falloff), length(positionWorld));
15603+
- });
15604+
+ const radialGradient = Fn<[ShaderNodeObject<THREE.Node>, ShaderNodeObject<THREE.Node>]>(
15605+
+ ([radius = float(10.0), falloff = float(1.0)]) => {
15606+
+ return smoothstep(radius, radius.sub(falloff), length(positionWorld));
15607+
+ },
15608+
+ );
15609+
15610+
// Create grid pattern
15611+
const gridPattern = gridXZ(1.0, 0.04, 0.01);
15612+
@@ -176,7 +193,7 @@ function updateModelsAlign() {
1553815613
}
1553915614
}
1554015615

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

1554515620
models.push(model);
15546-
@@ -143,12 +143,12 @@ async function addSample(sample, path) {
15621+
@@ -190,12 +207,12 @@ async function addSample(sample, path) {
1554715622
const material = await new MaterialXLoader()
1554815623
.setPath(path)
1554915624
.loadAsync(sample)
@@ -15557,9 +15632,9 @@ index 8a2d2a0e..603f034c 100644
1555715632
- const previewMesh = model.getObjectByName('Preview_Mesh');
1555815633
+ const previewMesh = model.getObjectByName('Preview_Mesh') as THREE.Mesh;
1555915634
previewMesh.material = material;
15560-
}
1556115635

15562-
@@ -177,9 +177,9 @@ function addGUI() {
15636+
if (material.transparent) {
15637+
@@ -229,9 +246,9 @@ function addGUI() {
1556315638
});
1556415639
}
1556515640

@@ -16347,7 +16422,7 @@ index b4694ef3..68ad678b 100644
1634716422
init();
1634816423

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

1755517630
diff --git a/examples-testing/examples/webgpu_postprocessing_ssr.ts b/examples-testing/examples/webgpu_postprocessing_ssr.ts
17556-
index 1579a8d8..e5a06ef1 100644
17631+
index 00320f58..22780f64 100644
1755717632
--- a/examples-testing/examples/webgpu_postprocessing_ssr.ts
1755817633
+++ b/examples-testing/examples/webgpu_postprocessing_ssr.ts
17559-
@@ -11,8 +11,9 @@ import {
17560-
sample,
17634+
@@ -13,8 +13,9 @@ import {
1756117635
directionToColor,
1756217636
colorToDirection,
17637+
vec2,
1756317638
+ ShaderNodeObject,
1756417639
} from 'three/tsl';
1756517640
-import { ssr } from 'three/addons/tsl/display/SSRNode.js';
1756617641
+import SSRNode, { ssr } from 'three/addons/tsl/display/SSRNode.js';
1756717642
import { smaa } from 'three/addons/tsl/display/SMAANode.js';
1756817643

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

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

1758317658
init();
1758417659

17585-
@@ -49,9 +54,9 @@ async function init() {
17660+
@@ -51,13 +56,12 @@ async function init() {
1758617661
loader.setDRACOLoader(dracoLoader);
1758717662
loader.load('models/gltf/steampunk_camera.glb', function (gltf) {
1758817663
gltf.scene.traverse(function (object) {
1758917664
- if (object.material) {
17590-
+ if ((object as THREE.Mesh).material) {
17665+
- if (object.material.name === 'Lense_Casing') {
17666+
- object.material.transparent = true;
17667+
+ if ((object as THREE.Mesh<THREE.BufferGeometry, THREE.Material>).material) {
17668+
+ if ((object as THREE.Mesh<THREE.BufferGeometry, THREE.Material>).material.name === 'Lense_Casing') {
17669+
+ (object as THREE.Mesh<THREE.BufferGeometry, THREE.Material>).material.transparent = true;
17670+
}
17671+
-
1759117672
// Avoid overdrawing
1759217673
- object.material.side = THREE.FrontSide;
1759317674
+ (object as THREE.Mesh<THREE.BufferGeometry, THREE.Material>).material.side = THREE.FrontSide;
@@ -17748,7 +17829,7 @@ index d4b197b3..ae7a2ade 100644
1774817829

1774917830
const fxSceneA = new FXScene(new THREE.BoxGeometry(2, 2, 2), new THREE.Vector3(0, -0.4, 0), 0xffffff);
1775017831
diff --git a/examples-testing/examples/webgpu_procedural_texture.ts b/examples-testing/examples/webgpu_procedural_texture.ts
17751-
index 98516c6c..d0de6c2c 100644
17832+
index 04630e74..01152c09 100644
1775217833
--- a/examples-testing/examples/webgpu_procedural_texture.ts
1775317834
+++ b/examples-testing/examples/webgpu_procedural_texture.ts
1775417835
@@ -4,7 +4,7 @@ import { gaussianBlur } from 'three/addons/tsl/display/GaussianBlurNode.js';

types/three/src/renderers/webxr/WebXRDepthSensing.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Mesh } from "../../objects/Mesh.js";
2-
import { RawTexture } from "../../textures/RawTexture.js";
2+
import { ExternalTexture } from "../../textures/ExternalTexture.js";
33
import { WebXRArrayCamera } from "./WebXRManager.js";
44

55
export class WebXRDepthSensing {
6-
texture: RawTexture | null;
6+
texture: ExternalTexture | null;
77
mesh: Mesh | null;
88

99
depthNear: number;
@@ -17,5 +17,5 @@ export class WebXRDepthSensing {
1717

1818
reset(): void;
1919

20-
getDepthTexture(): RawTexture | null;
20+
getDepthTexture(): ExternalTexture | null;
2121
}

types/three/src/renderers/webxr/WebXRManager.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { PerspectiveCamera } from "../../cameras/PerspectiveCamera.js";
55
import { EventDispatcher } from "../../core/EventDispatcher.js";
66
import { Vector4 } from "../../math/Vector4.js";
77
import { Mesh } from "../../objects/Mesh.js";
8-
import { RawTexture } from "../../textures/RawTexture.js";
8+
import { ExternalTexture } from "../../textures/ExternalTexture.js";
99
import { WebGLRenderer } from "../WebGLRenderer.js";
1010
import { XRGripSpace, XRHandSpace, XRTargetRaySpace } from "./WebXRController.js";
1111

@@ -65,7 +65,7 @@ export class WebXRManager extends EventDispatcher<WebXRManagerEventMap> {
6565

6666
getEnvironmentBlendMode: () => XREnvironmentBlendMode | undefined;
6767

68-
getDepthTexture: () => RawTexture | null;
68+
getDepthTexture: () => ExternalTexture | null;
6969

7070
updateCamera: (camera: PerspectiveCamera) => void;
7171

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

8080
getDepthSensingMesh: () => Mesh | null;
8181

82-
getCameraTexture: (xrCamera: WebXRCamera) => RawTexture | undefined;
82+
getCameraTexture: (xrCamera: WebXRCamera) => ExternalTexture | undefined;
8383

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import { Texture } from "./Texture.js";
22

3-
declare class RawTexture extends Texture {
3+
declare class ExternalTexture extends Texture {
44
sourceTexture: WebGLTexture | null;
55

6-
readonly isRawTexture: true;
6+
readonly isExternalTexture: true;
77

88
constructor(sourceTexture?: WebGLTexture | null);
99
}
1010

11-
export { RawTexture };
11+
export { ExternalTexture };

0 commit comments

Comments
 (0)