Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CubeTextureNode: Support CubeRefractionMapping. #1102

Merged
merged 4 commits into from
Jul 21, 2024
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
42 changes: 42 additions & 0 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -13821,6 +13821,48 @@ index 04023326..05ee79b0 100644

init();

diff --git a/examples-testing/examples/webgpu_materials_basic.ts b/examples-testing/examples/webgpu_materials_basic.ts
index 0161a9c7..590f668d 100644
--- a/examples-testing/examples/webgpu_materials_basic.ts
+++ b/examples-testing/examples/webgpu_materials_basic.ts
@@ -1,10 +1,10 @@
-import * as THREE from 'three';
+import * as THREE from 'three/webgpu';

import { GUI } from 'three/addons/libs/lil-gui.module.min.js';

-let camera, scene, renderer;
+let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGPURenderer;

-const spheres = [];
+const spheres: THREE.Mesh[] = [];

let mouseX = 0;
let mouseY = 0;
@@ -12,7 +12,13 @@ let mouseY = 0;
let windowHalfX = window.innerWidth / 2;
let windowHalfY = window.innerHeight / 2;

-const params = {
+const params: {
+ color: string;
+ mapping: THREE.CubeTextureMapping;
+ refractionRatio: number;
+ transparent: boolean;
+ opacity: number;
+} = {
color: '#ffffff',
mapping: THREE.CubeReflectionMapping,
refractionRatio: 0.98,
@@ -111,7 +117,7 @@ function onWindowResize() {
renderer.setSize(window.innerWidth, window.innerHeight);
}

-function onDocumentMouseMove(event) {
+function onDocumentMouseMove(event: MouseEvent) {
mouseX = (event.clientX - windowHalfX) / 100;
mouseY = (event.clientY - windowHalfY) / 100;
}
diff --git a/examples-testing/examples/webgpu_materials_displacementmap.ts b/examples-testing/examples/webgpu_materials_displacementmap.ts
index 54d26d65..824c087a 100644
--- a/examples-testing/examples/webgpu_materials_displacementmap.ts
Expand Down
5 changes: 4 additions & 1 deletion types/three/src/nodes/accessors/MaterialNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ export type MaterialNodeScope =
| typeof MaterialNode.POINT_WIDTH
| typeof MaterialNode.DISPERSION
| typeof MaterialNode.LIGHT_MAP
| typeof MaterialNode.AO_MAP;
| typeof MaterialNode.AO_MAP
| typeof MaterialNode.REFRACTION_RATIO;

export default class MaterialNode extends Node {
static ALPHA_TEST: "alphaTest";
Expand Down Expand Up @@ -80,6 +81,7 @@ export default class MaterialNode extends Node {
static DISPERSION: "dispersion";
static LIGHT_MAP: "light";
static AO_MAP: "ao";
static REFRACTION_RATIO: "refractionRatio";

scope: MaterialNodeScope;
constructor(scope?: MaterialNodeScope);
Expand Down Expand Up @@ -124,4 +126,5 @@ export const materialPointWidth: ShaderNodeObject<MaterialNode>;
export const materialDispersion: ShaderNodeObject<MaterialNode>;
export const materialLightMap: ShaderNodeObject<MaterialNode>;
export const materialAOMap: ShaderNodeObject<MaterialNode>;
export const materialRefractionRatio: ShaderNodeObject<MaterialNode>;
export const materialAnisotropyVector: ShaderNodeObject<UniformNode<Vector2>>;
3 changes: 3 additions & 0 deletions types/three/src/nodes/accessors/ReflectVectorNode.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@ import VarNode from "../core/VarNode.js";
import { ShaderNodeObject } from "../shadernode/ShaderNode.js";

export const reflectView: ShaderNodeObject<Node>;
export const refractView: ShaderNodeObject<Node>;

export const reflectVector: ShaderNodeObject<VarNode>;
export const refractVector: ShaderNodeObject<VarNode>;
Loading