UNPKG

@spearwolf/twopoint5d

Version:

Create 2.5D realtime graphics and pixelart with WebGL and three.js

38 lines 1.39 kB
import { VertexAttributeDescriptor } from './VertexAttributeDescriptor.js'; export class VertexObjectDescriptor { constructor(description) { this.description = description; this.attributes = new Map(); this.bufferNames = new Set(); Object.entries(this.description.attributes).forEach(([attrName, attrDesc]) => { const descriptor = new VertexAttributeDescriptor(attrName, attrDesc); this.attributes.set(attrName, descriptor); this.bufferNames.add(descriptor.bufferName); }); this.basePrototype = description.basePrototype; this.methods = description.methods; } get vertexCount() { return this.description.vertexCount ?? 1; } get meshCount() { return this.description.meshCount ?? 1; } getInstanceCount(capacity) { const meshCount = this.description.meshCount ?? 1; return meshCount > 1 ? Math.ceil(capacity / meshCount) : capacity; } get hasIndices() { return this.description.indices != null && this.description.indices.length > 0; } get indices() { return this.description.indices ?? []; } get attributeNames() { return Array.from(this.attributes.keys()); } getAttribute(name) { return this.attributes.get(name); } } //# sourceMappingURL=VertexObjectDescriptor.js.map