VertexElement Účel.Aspose.3D TypeScript Odkaz API
Balíček: @aspose/3d (v24.12.0)
VertexElement je abstraktní základní třída pro per-vertex attribute kanály připojené k Geometry.Každý kanál obsahuje typovaný datový soubor a mappingMode / referenceMode Metadata, která řídí vztah dat k geometrickým primitivům. Podtřídy jsou: VertexElementNormal, VertexElementUV,a) VertexElementVertexColor.
import { VertexElement, VertexElementNormal, VertexElementUV, VertexElementVertexColor } from '@aspose/3d';VertexElement (abstraktní základna)
export abstract class VertexElement implements IIndexedVertexElementKonstruktor
constructor(
elementType: VertexElementType,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)Předvoleně mappingMode je: MappingMode.CONTROL_POINT; výchozí platba referenceMode je: ReferenceMode.DIRECT.
Vlastnosti
| Vlastnictví | Typ: | Přístup | Popis: |
|---|---|---|---|
vertexElementType | VertexElementType | Čtěte. | Semantický typ této vrstvy. |
name | string | Čtení/psaní | Nepovinná označení této vrstvy. |
mappingMode | MappingMode | Čtení/psaní | Ovládají, s jakou primitivní geometrii je každá hodnota spojená. |
referenceMode | ReferenceMode | Čtení/psaní | Ovládá, zda jsou hodnoty adresovány přímo nebo prostřednictvím indexu. |
indices | number[] | Čtěte. | Indexové pole pro: IndexToDirect referenční režim. |
Metody
setIndices(data)
NOT IMPLEMENTED. Na základně.
VertexElementtřída, tato metoda vrháError('set_indices is not implemented')V běžném čase. PodtřídyVertexElementFVectora)VertexElementIntsTemplateposkytovat pracovní implementace.
Nahraďte index.
setIndices(data: number[]): voidclear()
NOT IMPLEMENTED. Na základně.
VertexElementtřída, tato metoda vrháError('clear is not implemented')V běžném čase. PodtřídyVertexElementFVectora)VertexElementIntsTemplateposkytovat pracovní implementace.
Odstraňte všechny údaje a indexy ze vrstvy.
clear(): voidVertexElementNormal
Většina rendererů vyžaduje normální data pro správné osvětlení.
export class VertexElementNormal extends VertexElementFVectorDědictví
VertexElement → VertexElementFVector → VertexElementNormal
Konstruktor
new VertexElementNormal(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType je pevně připevněn k: VertexElementType.NORMAL.
VertexElementUV
Skládá 2D texturní souřadnice. Mříž může mít pro různé kanály textury několik UV vrstev. textureMapping vlastnost identifikuje účel kanálu.
export class VertexElementUV extends VertexElementFVectorDědictví
VertexElement → VertexElementFVector → VertexElementUV
Konstruktor
new VertexElementUV(
textureMapping: TextureMapping | null = null,
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)Neplnění povinností TextureMapping.DIFFUSE kdy? textureMapping je: null.
Další majetek
| Vlastnictví | Typ: | Přístup | Popis: |
|---|---|---|---|
textureMapping | TextureMapping | Čtěte. | Kanál textury, se kterým je tato UV vrstva spojená. |
data | FVector4[] | Čtěte. | UV hodnoty vystavené jako: FVector4 položky (z a w jsou 0). |
uvData | FVector2[] | Čtěte. | UV hodnoty jako: FVector2 položky (pouze x, y). |
addData(data)
Přidání UV hodnot. FVector2[], FVector3[],nebo: FVector4[].
addData(data: FVector2[] | FVector3[] | FVector4[]): voidVertexElementVertexColor
Uložení barevných hodnot RGBA na vrchol. Komponenty jsou v rozmezí 01.
export class VertexElementVertexColor extends VertexElementFVectorDědictví
VertexElement → VertexElementFVector → VertexElementVertexColor
Konstruktor
new VertexElementVertexColor(
name: string = '',
mappingMode: MappingMode | null = null,
referenceMode: ReferenceMode | null = null,
)vertexElementType je pevně připevněn k: VertexElementType.VERTEX_COLOR.
Příklady:
Přidání normálů do trojúhelníkového okruhu:
import { Scene, Mesh, Vector4, VertexElementType, MappingMode, ReferenceMode, FVector4 } from '@aspose/3d';
const mesh = new Mesh();
mesh.controlPoints.push(new Vector4(0, 0, 0, 1));
mesh.controlPoints.push(new Vector4(1, 0, 0, 1));
mesh.controlPoints.push(new Vector4(0.5, 1, 0, 1));
mesh.createPolygon(0, 1, 2);
const normals = mesh.createElement(
VertexElementType.NORMAL,
MappingMode.CONTROL_POINT,
ReferenceMode.DIRECT,
);
normals.setData([
new FVector4(0, 0, 1, 0),
new FVector4(0, 0, 1, 0),
new FVector4(0, 0, 1, 0),
]);
const scene = new Scene();
scene.rootNode.createChildNode('tri', mesh);
scene.save('triangle_normals.glb');Přidejte UV souřadnice:
import { Scene, Mesh, Vector4, TextureMapping, MappingMode, ReferenceMode, FVector2 } from '@aspose/3d';
const mesh = new Mesh();
for (const [x, z] of [[0,0],[1,0],[1,1],[0,1]]) {
mesh.controlPoints.push(new Vector4(x, 0, z, 1));
}
mesh.createPolygon(0, 1, 2, 3);
const uv = mesh.createElementUV(TextureMapping.DIFFUSE, MappingMode.CONTROL_POINT, ReferenceMode.DIRECT);
uv.addData([
new FVector2(0, 0),
new FVector2(1, 0),
new FVector2(1, 1),
new FVector2(0, 1),
]);
const scene = new Scene();
scene.rootNode.createChildNode('quad', mesh);
scene.save('quad_uv.glb');