@spearwolf/twopoint5d
Version:
a library to create 2.5d realtime graphics and pixelart with three.js
38 lines • 1.39 kB
JavaScript
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