
Join the Conversation!
Subscribing gives you access to the comments so you can share your ideas, ask questions, and connect with others.
"Please login to view comments"
Subscribing gives you access to the comments so you can share your ideas, ask questions, and connect with others.
Welcome to this lesson on in ! Now that you’ve got the basics with , it’s time to level up and explore something more advanced: . This material is powerful, flexible, and can create stunningly realistic objects. But don’t worry, we’ll take it step by step, and by the end of this lesson, you’ll be making shiny, lifelike 3D objects like a pro.
Let’s dive in!
MeshStandardMaterial is a physically-based rendering (PBR) material. That’s a fancy way of saying it mimics how light interacts with real-world surfaces. Unlike , which ignores lighting,
Think of it like this: if is a plain sheet of paper, is a polished metal ball or a glossy ceramic vase. It’s all about realism.
Let’s break down the key properties of and how they can be used:
The base color of the material. You can set it using a hexadecimal value (e.g., for red) or a CSS-style string (e.g., ).
const material = new THREE.MeshStandardMaterial({
color: 0xff0000, // Red color
});
Controls how rough or smooth the surface appears. A value of makes the surface perfectly smooth (like a mirror), while a value of makes it completely rough (like chalk).
const material = new THREE.MeshStandardMaterial({
roughness: 0.5, // Semi-rough surface
});
Determines how metallic the surface appears. A value of makes the surface non-metallic (like plastic), while a value of makes it fully metallic (like polished metal).
const material = new THREE.MeshStandardMaterial({
metalness: 0.5, // Semi-metallic surface
});
The color of the material’s glow. This makes the object appear as if it’s emitting light, even though it doesn’t actually illuminate other objects. Example: .
const material = new THREE.MeshStandardMaterial({
emissive: 0x460c1a, // Dark red glow
});
A boolean property that determines whether the object is rendered as a wireframe. When set to , only the edges of the geometry are drawn.
const material = new THREE.MeshStandardMaterial({
flatShading: true, // Use flat shading
});
A boolean property that determines whether the material uses flat shading. When set to , the surface appears faceted instead of smooth.
const material = new THREE.MeshStandardMaterial({
flatShading: true, // Use flat shading
});
A texture that can be applied to the material. This allows you to add images or patterns to the surface of the object. Example: texture loaded from .
const textureLoader = new THREE.TextureLoader();
const texture = textureLoader.load('path/to/texture.jpg');
const material = new THREE.MeshStandardMaterial({
map: texture, // Apply the texture
});
Before we dive into , let’s set up a basic scene. We’ll need:
Now, let’s create a . This material has two key properties that make it special:
Do you see the result ? Instead of flat and just color appearance, we get a matte or glossy look of the objects. That's how is better than MeshBasicMaterial.
is perfect for creating realistic 3D objects. Whether you’re building a game, a product visualization, or an interactive art piece, this material gives you the tools to make your objects look lifelike.
How did you manage to remove the blur property and reach here?
Upgrading gives you access to quizzes so you can test your knowledge, track progress, and improve your skills.