Material

पैकेज: @aspose/3d (v24.12.0)

@aspose/3d तीन ठोस मैटेरियल क्लासेज़ प्रदान करता है जो एब्स्ट्रैक्ट बेस को विस्तारित करती हैं। Material वे 3D इंटरचेंज फॉर्मैट्स में सबसे अधिक पाए जाने वाले तीन शेडिंग मॉडलों को कवर करती हैं:

  • LambertMaterial — डिफ्यूज़ + एम्बिएंट + एमिसिव (OBJ/MTL और पुराने FBX एसेट्स द्वारा उपयोग किया जाता है)
  • PhongMaterial — लैम्बर्ट को स्पेक्यूलर हाइलाइट प्रॉपर्टीज़ के साथ विस्तारित करता है
  • PbrMaterial — फिजिकली-बेस्ड मॉडल जो glTF 2.0 मैटेरियल डिफिनिशन से मेल खाता है

सभी मैटेरियल क्लासेज़ मुख्य @aspose/3d एंट्री पॉइंट से एक्सपोर्ट की जाती हैं।.

import { LambertMaterial, PhongMaterial, PbrMaterial } from '@aspose/3d';

क्लास Material (एब्स्ट्रैक्ट बेस)

Material सभी मैटेरियल्स के लिए एब्स्ट्रैक्ट बेस क्लास है। यह विस्तारित करता है A3DObject, प्रदान करता है name प्रॉपर्टी और टेक्सचर स्लॉट API।.

export class Material extends A3DObject

ImageRenderOptions

NameTypeAccessDescription
MAP_SPECULAR``ReadGets the map specular.
MAP_DIFFUSE``ReadGets the map diffuse.
MAP_EMISSIVE``ReadGets the map emissive.
MAP_AMBIENT``ReadGets the map ambient.
MAP_NORMAL``ReadGets the map normal.

ImageRenderOptions

getTexture(slotName)

वापस देता है TextureBase नामित स्लॉट को असाइन किया गया, या null यदि कोई असाइन नहीं किया गया है।.

getTexture(slotName: string): TextureBase | null

setTexture(slotName, texture)

एक असाइन करता है TextureBase इंस्टेंस को नामित स्लॉट में।.

setTexture(slotName: string, texture: TextureBase): void

क्लास LambertMaterial

LambertMaterial विकिरण प्रतिबिंब को वैकल्पिक एंबिएंट और उत्सर्जन योगदान के साथ मॉडल करता है। यह वह सामग्री प्रकार है जो आमतौर पर OBJ फ़ाइलें लोड करते समय उत्पन्न होता है with .mtl लाइब्रेरीज़।.

export class LambertMaterial extends Material

ImageRenderOptions

A3DObject ← Material ← LambertMaterial

ImageRenderOptions

एक नोड को लाल डिफ्यूज़ सामग्री असाइन करें।.

import { Scene, LambertMaterial } from '@aspose/3d';
import { Vector3 } from '@aspose/3d/utilities';

const scene = new Scene();
scene.open('model.obj');

const mat = new LambertMaterial('RedSurface');
mat.diffuseColor = new Vector3(1, 0, 0);   // R=1, G=0, B=0
mat.ambientColor = new Vector3(0.1, 0, 0);
mat.transparency = 0;

// Assign material to the first child node's entity
const firstNode = scene.rootNode.childNodes[0];
if (firstNode && firstNode.entity) {
  (firstNode.entity as any).material = mat;
}
scene.save('output.fbx');

ImageRenderOptions

SignatureDescription
`constructor(name: stringnull)`
getTexture(_slotName: string) → `TextureBasenull`
setTexture(_slotName: string, _texture: TextureBase)Sets the texture value.

क्लास PhongMaterial

PhongMaterial विस्तारित करता है LambertMaterial स्पेक्युलर हाइलाइट समर्थन के साथ, क्लासिक फोंग शेडिंग मॉडल को लागू करता है। यह FBX और COLLADA एसेट्स में सामान्य है।.

export class PhongMaterial extends LambertMaterial

ImageRenderOptions

A3DObject ← Material ← LambertMaterial ← PhongMaterial

ImageRenderOptions

एक चमकदार नीला Phong सामग्री बनाएं।.

import { PhongMaterial } from '@aspose/3d';
import { Vector3 } from '@aspose/3d/utilities';

const mat = new PhongMaterial('ShinyBlue');
mat.diffuseColor = new Vector3(0, 0.2, 0.8);
mat.specularColor = new Vector3(1, 1, 1);
mat.shininess = 64;
mat.specularFactor = 0.8;
console.log(`Shininess: ${mat.shininess}`); // Shininess: 64

ImageRenderOptions


क्लास PbrMaterial

PbrMaterial glTF 2.0 मेटैलिक-रफ़नेस PBR मॉडल को लागू करता है। इस क्लास का उपयोग उन दृश्यों के लिए करें जो glTF/GLB के रूप में सहेजे जाएंगे, या जब स्रोत FBX एसेट में PBR सामग्री हो।.

export class PbrMaterial extends Material

ImageRenderOptions

A3DObject ← Material ← PbrMaterial

ImageRenderOptions

एक गोल्ड PBR सामग्री बनाएं और इसे glTF फ़ाइल में सहेजें।.

import { Scene, PbrMaterial } from '@aspose/3d';
import { Vector3 } from '@aspose/3d/utilities';
import { GltfSaveOptions } from '@aspose/3d/formats/gltf';

const scene = new Scene();
scene.open('base-mesh.obj');

const gold = new PbrMaterial('Gold');
gold.albedo = new Vector3(1.0, 0.766, 0.336);  // gold base color
gold.metallicFactor = 1.0;
gold.roughnessFactor = 0.3;

// Attach material to the first mesh node
const meshNode = scene.rootNode.childNodes[0];
if (meshNode && meshNode.entity) {
  (meshNode.entity as any).material = gold;
}

const opts = new GltfSaveOptions();
opts.binaryMode = true;
scene.save('gold-model.glb', opts);

ImageRenderOptions

स्थिर मेथड्स

PbrMaterial.fromMaterial(material)

एक नया बनाता है PbrMaterial एक सामान्य से Material उदाहरण, कॉपी कर रहा है name.

static fromMaterial(material: Material): PbrMaterial
 हिन्दी