@hyperse-hub/glass-plugin-dimension
Vendure plugin: frame dimension overlays for eyewear—normalized polylines on Product and optional diagram assets per ProductVariant.
Features
- Product —
dimensionModelConfig (GraphQL object): bridge, lens width/height, total width, temple length. Each value is a polyline as [[x, y], ...] with coordinates as decimal strings in normalized space (typically 0–1 vs. a reference image).
- ProductVariant —
dimensionFrameAsset / dimensionTempleAsset (Asset relations), hydrated when requested in GraphQL.
Admin stores the model as JSON in a text custom field; the API always resolves to a structured object, using defaultDimensionModel from plugin options when the field is empty or invalid.
Install
Register the plugin in your Vendure config (same pattern as other @hyperse-hub/glass-* plugins):
import { GlassPluginDimension } from '@hyperse-hub/glass-plugin-dimension';
export const config: VendureConfig = {
plugins: [
GlassPluginDimension.init({
defaultDimensionModel: {},
}),
],
};
Import the package once so custom-field TypeScript merges apply:
import '@hyperse-hub/glass-plugin-dimension';
Configuration
| Option | Description |
|---|
defaultDimensionModel | Fallback when Product.customFields.dimensionModelConfig is missing or bad JSON. |
Invalid JSON is logged under the context GlassPluginDimension and the default model is returned.
GraphQL
Registered on Admin and Shop APIs. Example shop query:
query {
product(id: "1") {
dimensionModelConfig {
bridge
lensWidth
lensHeight
totalWidth
templeLength
}
variants {
dimensionFrameAsset {
preview
}
dimensionTempleAsset {
preview
}
}
}
}
Requirements
- Vendure ^3.6.0 (see
peerDependencies in package.json).