UNPKG

@spearwolf/twopoint5d

Version:

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

48 lines 1.65 kB
const toPascalCase = (str) => str.replace(/(^|_)([a-z])/g, (_match, _m0, m1) => m1.toUpperCase()); export class VertexAttributeDescriptor { constructor(name, description) { this.name = name; this.description = description; } get dataType() { return this.description.type ?? 'float32'; } get normalizedData() { return Boolean(this.description.normalized); } get usageType() { return this.description.usage ?? 'static'; } get autoTouch() { return this.description.autoTouch ?? this.usageType !== 'static'; } get size() { return this.description.size ?? this.description.components?.length ?? 1; } get hasComponents() { return this.description.components?.length > 0; } get components() { return this.description.components ?? []; } get bufferName() { return this.description.bufferName ?? `${this.usageType}_${this.dataType}${this.normalizedData ? 'N' : ''}`; } get getterName() { if ('getter' in this.description && !this.description.getter) { return undefined; } if (typeof this.description.getter === 'string') return this.description.getter; return `get${toPascalCase(this.name)}`; } get setterName() { if ('setter' in this.description && !this.description.setter) { return undefined; } if (typeof this.description.setter === 'string') return this.description.setter; return `set${toPascalCase(this.name)}`; } } //# sourceMappingURL=VertexAttributeDescriptor.js.map