मुख्य सामग्री पर जाएँ
Skillpedia
वेबसाइट और UI (frontend)6.6k · #13862

threejs-materials-lighting

यह क्या करती है

यह स्किल बताती है कि materials, लाइट, शैडो और रिफ़्लेक्शन से three.js की 3D सतहें यथार्थ दिखें। यह उन डेवलपर्स के लिए है जिनके मॉडल अंधेरे या सपाट दिखते हैं।

कब इस्तेमाल करें

  • ✓जब कोई three.js मॉडल स्क्रीन पर काला, सपाट या गलत दिखे।
  • ✓जब आपको material चुनना हो, लाइट जोड़नी हो, या शैडो चालू करने हों।
  • ✓जब आप किसी environment इमेज से यथार्थ रिफ़्लेक्शन चाहें।

Skill का लिंक

https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/web-engines/threejs-materials-lighting/SKILL.md

इसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।

कैसे इस्तेमाल करें

सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/gamedev-skills/awesome-gamedev-agent-skills/blob/main/skills/web-engines/threejs-materials-lighting/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

AI से क्या माँगें: उदाहरण

“मेरी three.js कार पूरी तरह काली दिखती है, चमकदार दिखाने के लिए सही लाइट कैसे जोड़ूँ?”

हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।

यह कैसे काम करती है

यह बताती है कि हर ज़रूरत के लिए कौन सा material ठीक है, नरम fill लाइट को मुख्य directional लाइट के साथ कैसे मिलाएँ, नए संस्करणों में लाइट की तीव्रता कैसे काम करती है, और environment maps रिफ़्लेक्शन कैसे जोड़ते हैं।

तकनीकी सामग्री (मूल SKILL.md)

लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।

three.js Materials & Lighting

Make three.js surfaces look right: pick the correct material, light the scene, enable shadows, and add image-based lighting. Patterns target r186, verified against r186 (lighting is physically based by default since r155).

When to use

  • Use when a mesh renders black or flat, when choosing a material, adding lights, enabling shadows, or setting up environment-map reflections (IBL).
  • Use when code constructs MeshStandardMaterial, DirectionalLight, etc., or sets renderer.shadowMap.enabled or scene.environment.

When not to use: the renderer/camera/loop → threejs-scene-setup. Loading models (whose PBR materials this complements) → threejs-gltf-loading. Custom GLSL/ShaderMaterial is its own topic; for the portable concept see shader-programming.

Core workflow

  1. Pick a material by need. MeshStandardMaterial (PBR: roughness, metalness, reacts to lights/IBL) for realism; MeshPhysicalMaterial for clearcoat/transmission; MeshBasicMaterial (unlit, ignores lights) for UI/flat; MeshNormalMaterial/MeshDepthMaterial for debugging.
  2. Add light, or nothing shows. Lit materials need a light source and/or scene.environment. Combine a soft fill (AmbientLight/HemisphereLight) with a key DirectionalLight.
  3. Mind light intensity. Since r155, lighting is physically based; modern intensities are higher than old tutorials (a key DirectionalLight ≈ 1–3).
  4. Enable shadows in three places. renderer.shadowMap.enabled = true, the light's castShadow = true, and each mesh's castShadow/receiveShadow. Then fit the light's shadow camera to the scene.
  5. Use an environment map for grounded reflections. Assign an equirectangular or PMREM-processed texture to scene.environment; PBR materials pick it up automatically.
  6. Verify under real lighting — confirm the surface responds to the key light (highlights move), shadows land where expected, and reflections look plausible.

Patterns

1. PBR material under a 3-light rig

import * as THREE from 'three';

const material = new THREE.MeshStandardMaterial({
  color: 0xcc4444,
  roughness: 0.5,     // 0 = mirror, 1 = fully matte
  metalness: 0.0,     // 0 = dielectric (plastic/wood), 1 = metal
});
const mesh = new THREE.Mesh(new THREE.SphereGeometry(1, 32, 16), material);
scene.add(mesh);

// Soft sky/ground fill + a directional key light.
scene.add(new THREE.HemisphereLight(0xbbddff, 0x443322, 1.0)); // sky, ground, intensity
const key = new THREE.DirectionalLight(0xffffff, 2.5);
key.position.set(5, 10, 7);
scene.add(key);

2. Unlit material (no light needed)

// MeshBasicMaterial ignores lights — for flat color, UI, or sprites/labels.
const flat = new THREE.MeshBasicMaterial({ color: 0x44aa88 });
// A textured color map should be tagged sRGB so colors aren't washed out:
const tex = new THREE.TextureLoader().load('assets/logo.png');
tex.colorSpace = THREE.SRGBColorSpace;
const logo = new THREE.MeshBasicMaterial({ map: tex, transparent: true });

3. Shadows (the three required switches + camera fit)

renderer.shadowMap.enabled = true;
renderer.shadowMap.type = THREE.PCFShadowMap;         // soft by default since r182

const sun = new THREE.DirectionalLight(0xffffff, 3);
sun.position.set(8, 12, 6);
sun.castShadow = true;
sun.shadow.mapSize.set(2048, 2048);                   // default 512; raise for crisp
// DirectionalLight uses an OrthographicCamera — fit it tightly to the scene:
const cam = sun.shadow.camera;
cam.near = 1; cam.far = 40;
cam.left = -15; cam.right = 15; cam.top = 15; cam.bottom = -15;
scene.add(sun);

mesh.castShadow = true;
ground.receiveShadow = true;                          // a plane to catch the shadow

4. PBR textures on a material

const loader = new THREE.TextureLoader();
const colorMap = loader.load('assets/brick_color.jpg');
colorMap.colorSpace = THREE.SRGBColorSpace;           // color maps are sRGB
const normalMap = loader.load('assets/brick_normal.jpg'); // data maps stay linear
const roughMap  = loader.load('assets/brick_rough.jpg');

const brick = new THREE.MeshStandardMaterial({
  map: colorMap,
  normalMap,
  roughnessMap: roughMap,
  metalness: 0,
});

5. Image-based lighting from an HDR environment

import { HDRLoader } from 'three/addons/loaders/HDRLoader.js'; // RGBELoader before r180

new HDRLoader().load('assets/studio.hdr', (hdr) => {
अक्सर पूछे जाने वाले सवाल

मेरा मॉडल काला क्यों दिखता है?

स्किल कहती है कि प्रकाश वाले materials को रोशनी का स्रोत या environment map चाहिए, वरना सीन काला दिख सकता है।

environment map क्या है?

यह एक इमेज है जो पूरे सीन में रोशनी और रिफ़्लेक्शन देती है।

क्या यह मॉडल लोड करना कवर करती है?

नहीं। मॉडल लोड करना एक अलग glTF स्किल में कवर है।

जानकारी

लेखक का मूल विवरण

Light and shade a three.js scene: choose materials (MeshStandardMaterial PBR vs unlit MeshBasicMaterial), add ambient/hemisphere/directional/point/spot lights, turn on shadow maps, and use an environment map (IBL) for realistic reflections. Use when a three.js model looks black, flat, or wrong — when the user mentions three.js materials, MeshStandardMaterial, lights, shadows, envMap, or PBR. For renderer/loop setup use threejs-scene-setup; for loading models use threejs-gltf-loading.

repo: gamedev-skills/awesome-gamedev-agent-skills

लोकप्रियता

GitHub स्टार
6.6k
रैंकिंग में स्थान
#13862
लाइसेंस
Apache-2.0
अपडेट की गई
28/10/2026

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

router

6.6k

यह आपके एजेंट को इंजन और काम के प्रकार को पहचानकर किसी अनुरोध के लिए सही गेम डेवलपमेंट स्किल चुनने में मदद करती है।

कोडिंगसामान्य कोडिंग

ai-behavior-trees-utility-ai

6.6k

यह आपके एजेंट को दुश्मनों और किरदारों के लिए बिहेवियर ट्री और यूटिलिटी AI सिस्टम बनाने में मदद करती है, जो प्राथमिकता और स्कोर से कार्रवाई चुनें।

कोडिंगसामान्य कोडिंग

audio-design

6.6k

आपके एजेंट को गेम ऑडियो मिक्सिंग सिखाती है: बस, डेसिबल में वॉल्यूम, डायलॉग में म्यूज़िक धीमा करना और साउंड इफ़ेक्ट की विविधता।

वीडियो और ऑडियोऑडियो और आवाज़

camera-systems

6.6k

यह आपके एजेंट को ऐसे गेम कैमरा बनाने में मदद करती है जो सहजता से पीछा करें, लेवल के भीतर रहें, और 3D में घूम या देख सकें।

कोडिंगसामान्य कोडिंग

मिलती-जुलती skills