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

NodeMaterial: Remove WebGLNodeBuilder #913

Merged
merged 4 commits into from
Apr 22, 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
257 changes: 15 additions & 242 deletions examples-testing/changes.patch
Original file line number Diff line number Diff line change
Expand Up @@ -9991,248 +9991,6 @@ index 94987b7c..4e920e2c 100644

view.updateCamera(camera, scene, mouseX, mouseY);

diff --git a/examples-testing/examples/webgl_nodes_loader_gltf_iridescence.ts b/examples-testing/examples/webgl_nodes_loader_gltf_iridescence.ts
index 6ff0f3b3..c845683f 100644
--- a/examples-testing/examples/webgl_nodes_loader_gltf_iridescence.ts
+++ b/examples-testing/examples/webgl_nodes_loader_gltf_iridescence.ts
@@ -7,7 +7,7 @@ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { RGBELoader } from 'three/addons/loaders/RGBELoader.js';

-let renderer, scene, camera, controls;
+let renderer: THREE.WebGLRenderer, scene: THREE.Scene, camera: THREE.PerspectiveCamera, controls: OrbitControls;

init().catch(function (err) {
console.error(err);
@@ -42,21 +42,21 @@ async function init() {
// nodes

gltf.scene.traverse(mesh => {
- const material = mesh.material;
+ const material = (mesh as THREE.Mesh).material;

- if (material && material.iridescence > 0) {
+ if (material && (material as THREE.MeshPhysicalMaterial).iridescence > 0) {
const iridescenceFactorNode = checker(
uv()
.add(vec2(timerLocal(-0.05), 0))
.mul(20),
);

- const nodeMaterial = NodeMaterial.fromMaterial(material); // @TODO: NodeMaterial.fromMaterial can be removed if WebGLNodes will apply it by default (as in WebGPURenderer)
+ const nodeMaterial = NodeMaterial.fromMaterial(material as THREE.MeshPhysicalMaterial); // @TODO: NodeMaterial.fromMaterial can be removed if WebGLNodes will apply it by default (as in WebGPURenderer)
nodeMaterial.iridescenceNode = iridescenceFactorNode;
nodeMaterial.iridescenceIORNode = float(1.3);
nodeMaterial.iridescenceThicknessNode = float(400);

- mesh.material = nodeMaterial;
+ (mesh as THREE.Mesh).material = nodeMaterial;
}
});

diff --git a/examples-testing/examples/webgl_nodes_loader_gltf_sheen.ts b/examples-testing/examples/webgl_nodes_loader_gltf_sheen.ts
index 589658f6..473434db 100644
--- a/examples-testing/examples/webgl_nodes_loader_gltf_sheen.ts
+++ b/examples-testing/examples/webgl_nodes_loader_gltf_sheen.ts
@@ -7,7 +7,7 @@ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
import { RoomEnvironment } from 'three/addons/environments/RoomEnvironment.js';

-let camera, scene, renderer, controls;
+let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGLRenderer, controls: OrbitControls;

init();
animate();
@@ -26,10 +26,10 @@ function init() {
new GLTFLoader().setPath('models/gltf/').load('SheenChair.glb', function (gltf) {
scene.add(gltf.scene);

- const object = gltf.scene.getObjectByName('SheenChair_fabric');
+ const object = gltf.scene.getObjectByName('SheenChair_fabric') as THREE.Mesh;

// Convert to NodeMaterial
- const material = NodeMaterial.fromMaterial(object.material); // @TODO: NodeMaterial.fromMaterial can be removed if WebGLNodes will apply it by default (as in WebGPURenderer)
+ const material = NodeMaterial.fromMaterial(object.material as THREE.MeshPhysicalMaterial); // @TODO: NodeMaterial.fromMaterial can be removed if WebGLNodes will apply it by default (as in WebGPURenderer)

const checkerNode = checker(uv().mul(5));

diff --git a/examples-testing/examples/webgl_nodes_loader_materialx.ts b/examples-testing/examples/webgl_nodes_loader_materialx.ts
index a70415ab..371f648e 100644
--- a/examples-testing/examples/webgl_nodes_loader_materialx.ts
+++ b/examples-testing/examples/webgl_nodes_loader_materialx.ts
@@ -1,11 +1,11 @@
import * as THREE from 'three';

-import { MaterialXLoader } from './jsm/loaders/MaterialXLoader.js';
-import { OrbitControls } from './jsm/controls/OrbitControls.js';
-import { RGBELoader } from './jsm/loaders/RGBELoader.js';
-import { GLTFLoader } from './jsm/loaders/GLTFLoader.js';
+import { MaterialXLoader } from 'three/addons/loaders/MaterialXLoader.js';
+import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
+import { RGBELoader } from 'three/addons/loaders/RGBELoader.js';
+import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';

-import { nodeFrame } from './jsm/renderers/webgl-legacy/nodes/WebGLNodes.js';
+import { nodeFrame } from 'three/addons/renderers/webgl-legacy/nodes/WebGLNodes.js';

const SAMPLE_PATH =
'https://raw.githubusercontent.com/materialx/MaterialX/main/resources/Materials/Examples/StandardSurface/';
@@ -34,8 +34,8 @@ const samples = [
'standard_surface_wood_tiled.mtlx',
];

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

init();

@@ -98,7 +98,7 @@ function updateModelsAlign() {
}
}

-async function addSample(sample) {
+async function addSample(sample: string) {
const model = prefab.clone();

models.push(model);
@@ -109,15 +109,15 @@ async function addSample(sample) {

//

- const material = await new MaterialXLoader()
+ const material = (await new MaterialXLoader()
.setPath(SAMPLE_PATH)
.loadAsync(sample)
- .then(({ materials }) => Object.values(materials).pop());
+ .then(({ materials }) => Object.values(materials).pop()))!;

- const calibrationMesh = model.getObjectByName('Calibration_Mesh');
+ const calibrationMesh = model.getObjectByName('Calibration_Mesh') as THREE.Mesh;
calibrationMesh.material = material;

- const Preview_Mesh = model.getObjectByName('Preview_Mesh');
+ const Preview_Mesh = model.getObjectByName('Preview_Mesh') as THREE.Mesh;
Preview_Mesh.material = material;
}

diff --git a/examples-testing/examples/webgl_nodes_materials_instance_uniform.ts b/examples-testing/examples/webgl_nodes_materials_instance_uniform.ts
index 0c911aaa..ec8e186a 100644
--- a/examples-testing/examples/webgl_nodes_materials_instance_uniform.ts
+++ b/examples-testing/examples/webgl_nodes_materials_instance_uniform.ts
@@ -1,5 +1,15 @@
import * as THREE from 'three';
-import { MeshStandardNodeMaterial, Node, NodeUpdateType, nodeObject, uniform, cubeTexture } from 'three/nodes';
+import {
+ MeshStandardNodeMaterial,
+ Node,
+ NodeUpdateType,
+ nodeObject,
+ uniform,
+ cubeTexture,
+ NodeFrame,
+ NodeBuilder,
+ UniformNode,
+} from 'three/nodes';

import Stats from 'three/addons/libs/stats.module.js';

@@ -8,6 +18,8 @@ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { nodeFrame } from 'three/addons/renderers/webgl-legacy/nodes/WebGLNodes.js';

class InstanceUniformNode extends Node {
+ uniformNode: UniformNode<THREE.Color>;
+
constructor() {
super('vec3');

@@ -16,22 +28,22 @@ class InstanceUniformNode extends Node {
this.uniformNode = uniform(new THREE.Color());
}

- update(frame) {
- this.uniformNode.value.copy(frame.object.color);
+ update(frame: NodeFrame) {
+ this.uniformNode.value.copy((frame.object as THREE.Mesh & { color: THREE.Color }).color);
}

- generate(builder, output) {
+ generate(builder: NodeBuilder, output?: string | null) {
return this.uniformNode.build(builder, output);
}
}

-let stats;
+let stats: Stats;

-let camera, scene, renderer;
-let controls;
-let pointLight;
+let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: THREE.WebGLRenderer;
+let controls: OrbitControls;
+let pointLight: THREE.PointLight;

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

init();
animate();
@@ -126,10 +138,10 @@ function init() {
window.addEventListener('resize', onWindowResize);
}

-function addMesh(geometry, material) {
+function addMesh(geometry: THREE.SphereGeometry, material: MeshStandardNodeMaterial) {
const mesh = new THREE.Mesh(geometry, material);

- mesh.color = new THREE.Color(Math.random() * 0xffffff);
+ (mesh as THREE.Mesh & { color?: THREE.Color }).color = new THREE.Color(Math.random() * 0xffffff);

mesh.position.x = (objects.length % 4) * 20 - 30;
mesh.position.z = Math.floor(objects.length / 4) * 20 - 20;
diff --git a/examples-testing/examples/webgl_nodes_materials_physical_clearcoat.ts b/examples-testing/examples/webgl_nodes_materials_physical_clearcoat.ts
index 615179ee..41a86a6f 100644
--- a/examples-testing/examples/webgl_nodes_materials_physical_clearcoat.ts
+++ b/examples-testing/examples/webgl_nodes_materials_physical_clearcoat.ts
@@ -10,12 +10,12 @@ import { HDRCubeTextureLoader } from 'three/addons/loaders/HDRCubeTextureLoader.

import { FlakesTexture } from 'three/addons/textures/FlakesTexture.js';

-let container, stats;
+let container: HTMLDivElement, stats: Stats;

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

-let particleLight;
-let group;
+let particleLight: THREE.Mesh;
+let group: THREE.Group;

init();
animate();
diff --git a/examples-testing/examples/webgl_nodes_materialx_noise.ts b/examples-testing/examples/webgl_nodes_materialx_noise.ts
index 028b06b5..07e50e83 100644
--- a/examples-testing/examples/webgl_nodes_materialx_noise.ts
+++ b/examples-testing/examples/webgl_nodes_materialx_noise.ts
@@ -16,12 +16,12 @@ import Stats from 'three/addons/libs/stats.module.js';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { HDRCubeTextureLoader } from 'three/addons/loaders/HDRCubeTextureLoader.js';

-let container, stats;
+let container: HTMLDivElement, stats: Stats;

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

-let particleLight;
-let group;
+let particleLight: THREE.Mesh;
+let group: THREE.Group;

init();
animate();
diff --git a/examples-testing/examples/webgl_panorama_cube.ts b/examples-testing/examples/webgl_panorama_cube.ts
index 951e6bee..a66d5f0c 100644
--- a/examples-testing/examples/webgl_panorama_cube.ts
Expand Down Expand Up @@ -14136,6 +13894,21 @@ index e8de51c0..1db14de9 100644

init();

diff --git a/examples-testing/examples/webgpu_materials_lightmap.ts b/examples-testing/examples/webgpu_materials_lightmap.ts
index 99b484c4..9eb3c67b 100644
--- a/examples-testing/examples/webgpu_materials_lightmap.ts
+++ b/examples-testing/examples/webgpu_materials_lightmap.ts
@@ -8,8 +8,8 @@ import { OrbitControls } from 'three/addons/controls/OrbitControls.js';

import { MeshBasicNodeMaterial, vec4, color, positionLocal, mix } from 'three/nodes';

-let container, stats;
-let camera, scene, renderer;
+let container: HTMLDivElement, stats: Stats;
+let camera: THREE.PerspectiveCamera, scene: THREE.Scene, renderer: WebGPURenderer;

init();

diff --git a/examples-testing/examples/webgpu_materials_texture_anisotropy.ts b/examples-testing/examples/webgpu_materials_texture_anisotropy.ts
index ca0ae9e7..2125232e 100644
--- a/examples-testing/examples/webgpu_materials_texture_anisotropy.ts
Expand Down
4 changes: 0 additions & 4 deletions examples-testing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const exceptionList = [
'webgl_loader_texture_lottie',
'webgl_loader_texture_pvrtc',
'webgl_materials_channels',
'webgl_materials_lightmap',
'webgl_materials_matcap',
'webgl_materials_normalmap',
'webgl_materials_subsurface_scattering',
Expand All @@ -42,9 +41,6 @@ const exceptionList = [
'webgl_points_dynamic',
'webgl_raycaster_bvh',
'webgl_renderer_pathtracer',
'webgl_nodes_loader_gltf_transmission',
'webgl_nodes_materials_standard',
'webgl_nodes_points',
'webgl_postprocessing_3dlut',
'webgl_postprocessing_dof',
'webgl_postprocessing_dof2',
Expand Down
2 changes: 1 addition & 1 deletion three.js
Submodule three.js updated 61 files
+1 −1 docs/api/ar/loaders/ObjectLoader.html
+0 −1 docs/api/ar/materials/ShaderMaterial.html
+1 −1 docs/api/en/loaders/ObjectLoader.html
+0 −1 docs/api/en/materials/ShaderMaterial.html
+0 −1 docs/api/fr/materials/ShaderMaterial.html
+1 −1 docs/api/it/loaders/ObjectLoader.html
+0 −1 docs/api/it/materials/ShaderMaterial.html
+4 −5 docs/api/zh/extras/ImageUtils.html
+1 −1 docs/api/zh/loaders/ObjectLoader.html
+0 −1 docs/api/zh/materials/ShaderMaterial.html
+1 −1 docs/manual/en/introduction/How-to-use-post-processing.html
+1 −12 examples/files.json
+1 −1 examples/jsm/loaders/VRMLLoader.js
+1 −0 examples/jsm/nodes/Nodes.js
+1 −1 examples/jsm/nodes/accessors/MaterialNode.js
+7 −26 examples/jsm/nodes/display/BumpMapNode.js
+24 −0 examples/jsm/nodes/lighting/IrradianceNode.js
+10 −6 examples/jsm/nodes/materials/Line2NodeMaterial.js
+8 −1 examples/jsm/nodes/materials/NodeMaterial.js
+2 −0 examples/jsm/renderers/common/RenderObject.js
+5 −4 examples/jsm/renderers/common/Renderer.js
+0 −318 examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js
+0 −26 examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js
+0 −792 examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js
+0 −51 examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js
+1 −1 examples/jsm/renderers/webgl/WebGLBackend.js
+1 −1 examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js
+1 −1 examples/jsm/renderers/webgpu/WebGPUBackend.js
+ examples/screenshots/webgl_materials_lightmap.jpg
+ examples/screenshots/webgl_nodes_loader_gltf_iridescence.jpg
+ examples/screenshots/webgl_nodes_loader_gltf_sheen.jpg
+ examples/screenshots/webgl_nodes_loader_gltf_transmission.jpg
+ examples/screenshots/webgl_nodes_loader_materialx.jpg
+ examples/screenshots/webgl_nodes_materials_instance_uniform.jpg
+ examples/screenshots/webgl_nodes_materials_physical_clearcoat.jpg
+ examples/screenshots/webgl_nodes_materials_standard.jpg
+ examples/screenshots/webgl_nodes_materialx_noise.jpg
+ examples/screenshots/webgl_nodes_points.jpg
+ examples/screenshots/webgpu_materials_lightmap.jpg
+2 −2 examples/tags.json
+0 −131 examples/webgl_nodes_loader_gltf_iridescence.html
+0 −135 examples/webgl_nodes_loader_gltf_sheen.html
+0 −156 examples/webgl_nodes_loader_gltf_transmission.html
+0 −190 examples/webgl_nodes_loader_materialx.html
+0 −226 examples/webgl_nodes_materials_instance_uniform.html
+0 −250 examples/webgl_nodes_materials_physical_clearcoat.html
+0 −261 examples/webgl_nodes_materials_standard.html
+0 −203 examples/webgl_nodes_materialx_noise.html
+0 −205 examples/webgl_nodes_points.html
+11 −13 examples/webgpu_materials_lightmap.html
+4 −37 playground/NodeEditor.js
+0 −0 playground/examples/basic/fresnel.json
+0 −0 playground/examples/basic/matcap.json
+0 −0 playground/examples/basic/particles.json
+1 −0 playground/examples/basic/teapot.json
+0 −1 playground/examples/universal/teapot.json
+0 −1 playground/examples/webgl/car.json
+7 −41 playground/index.html
+12 −11 src/extras/PMREMGenerator.js
+0 −3 test/e2e/puppeteer.js
+1 −1 utils/build/rollup.config.js

This file was deleted.

Loading