Material

Paket: @aspose/3d (v24.12.0)

@aspose/3d soyut sınıfı genişleten üç somut malzeme sınıfı sunar Material temel. 3D değişim formatlarında en yaygın bulunan üç gölgelendirme modelini kapsarlar:

  • LambertMaterial — diffuse + ambient + emissive (OBJ/MTL ve eski FBX varlıkları tarafından kullanılır)
  • PhongMaterial — Lambert’ı speküler vurgulama özellikleriyle genişletir
  • PbrMaterial — glTF 2.0 malzeme tanımına uyan fiziksel temelli model

Tüm malzeme sınıfları ana @aspose/3d giriş noktasından dışa aktarılır.

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

Sınıf Material (soyut temel)

Material tüm malzemeler için soyut temel sınıftır. Şunu genişletir A3DObject, şu özelliği sağlayarak name özelliği ve doku yuvası API’sini.

export class Material extends A3DObject

Enumerations

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.

Enumerations

getTexture(slotName)

Belirtilen TextureBase adlandırılmış yuvaya atanmış olanı döndürür, ya da null eğer hiçbiri atanmadıysa.

getTexture(slotName: string): TextureBase | null

setTexture(slotName, texture)

Atar bir TextureBase örneği adlandırılmış yuvaya.

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

Sınıf LambertMaterial

LambertMaterial opsiyonel ortam ve ışınım katkılarıyla difüz yansımayı modeller. OBJ dosyaları yüklenirken yaygın olarak üretilen malzeme tipidir with .mtl kütüphaneler.

export class LambertMaterial extends Material

Enumerations

A3DObject ← Material ← LambertMaterial

Enumerations

Bir düğüme kırmızı difüz malzeme ata.

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');

Enumerations

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

Sınıf PhongMaterial

PhongMaterial genişletir LambertMaterial specular vurgulama desteğiyle, klasik Phong gölgelendirme modelini uygular. FBX ve COLLADA varlıklarında yaygındır.

export class PhongMaterial extends LambertMaterial

Enumerations

A3DObject ← Material ← LambertMaterial ← PhongMaterial

Enumerations

Parlak mavi bir Phong malzeme oluştur.

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

Enumerations


Sınıf PbrMaterial

PbrMaterial glTF 2.0 metalik-çözünürlük PBR modelini uygular. Bu sınıfı glTF/GLB olarak kaydedilecek sahneler için veya kaynak FBX varlığında PBR malzemeleri bulunduğunda kullanın.

export class PbrMaterial extends Material

Enumerations

A3DObject ← Material ← PbrMaterial

Enumerations

Altın bir PBR malzeme oluştur ve bir glTF dosyasına kaydet.

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);

Enumerations

Statik Yöntemler

PbrMaterial.fromMaterial(material)

Yeni bir şey oluşturur PbrMaterial genel bir Material örnek, kopyalayarak the name.

static fromMaterial(material: Material): PbrMaterial
 Türkçe