Skip to content

RingConfigurator Plugin API Reference

Ring Configurator Plugin

The RingConfiguratorPlugin is a iJewel3D plugin that enables dynamic ring configuration by managing multiple components (like heads, shanks, and bands) with interchangeable model variations. It provides the foundation for building interactive ring configurators.

RingConfiguratorPlugin

Plugin Type

typescript
RingConfiguratorPlugin.PluginType = 'RingConfigurator'

Properties

PropertyTypeDescription
enabledbooleanWhether the plugin is enabled
componentsComponent[]Array of ring components managed by the plugin
rootScalenumberScale factor applied to all models in the scene

Methods

setRootScale(value: number)

Sets the scale of the entire ring model root and refreshes the view.

typescript
const ringConfigurator = viewer.getPluginByType("RingConfigurator");
ringConfigurator.setRootScale(1.5);

matchBaseHeight(comp1: Component, comp2: Component, seperation?: number)

Aligns two components by matching their base heights and optionally setting separation distance. It can be used to add matching Bands to current Ring.

  • Parameters:
    • comp1: The reference component
    • comp2: The component to align
    • seperation: Optional distance between components (defaults to 2× width of comp1)
typescript
const shank = ringConfigurator.getComponent("Shank");
const band = ringConfigurator.getComponent("Band");
ringConfigurator.matchBaseHeight(shank, band, 0.5);

createComponent(name: string): Component

Creates a new component with the specified name and adds it to the plugin.

typescript
const headComponent = ringConfigurator.createComponent("Head");

removeComponent(name: string)

Removes and disposes of a component by name.

typescript
ringConfigurator.removeComponent("Head");

getComponent(name: string): Component | undefined

Retrieves a specific component by name.

typescript
const shank = ringConfigurator.getComponent("Shank");
if (shank) {
  await shank.applyVariation(shank.variations[0]);
}

getComponents(): Component[]

Returns all components managed by the plugin.

typescript
const allComponents = ringConfigurator.getComponents();
allComponents.forEach(comp => console.log(comp.name));

Events

EventDescription
componentProcessedFired when all components have finished loading their variations
typescript
ringConfigurator.addEventListener("componentProcessed", () => {
  console.log("All components are ready!");
});

Component Class

The Component class represents a single configurable part of the ring (e.g., head, shank, band).

Properties

PropertyTypeDescription
namestringUnique identifier for the component
titlestringDisplay title for UI
selectedIndexnumberIndex of the currently selected variation (-1 if none)
positionVector3Position offset of the component
rotationEulerRotation of the component
visiblebooleanVisibility state
variationsModelVariation[]Array of available model variations
fileIdstring | numberFile identifier for the component

Methods

setPosition(position: Vector3)

Sets the position of the component in 3D space.

typescript
import { Vector3 } from 'webgi';

component.setPosition(new Vector3(0, 1, 0));

setRotation(rotation: Euler)

Sets the rotation of the component.

typescript
import { Euler } from 'webgi';

component.setRotation(new Euler(0, Math.PI / 4, 0));

setVisible(visible: boolean)

Shows or hides the component.

typescript
component.setVisible(false); // Hide
component.setVisible(true);  // Show

isVisible(): boolean

Returns the current visibility state.

typescript
if (component.isVisible()) {
  console.log("Component is visible");
}

getBounds(): Box3B

Returns the bounding box of the component.

typescript
const bounds = component.getBounds();
const size = bounds.getSize(new Vector3());
console.log(`Width: ${size.x}, Height: ${size.y}, Depth: ${size.z}`);

addVariation(variation: ModelVariation)

Adds a model variation to the component's available options.

typescript
component.addVariation({
  name: "round-diamond",
  title: "Round Diamond",
  modelUrl: "https://cdn.example.com/models/round-diamond.glb",
  fileId: "abc123",
  iconUrl: "https://cdn.example.com/icons/round-diamond.png"
});

removeVariation(variation: ModelVariation)

Removes a variation from the component.

typescript
const variation = component.findVariationByName("round-diamond");
if (variation) {
  component.removeVariation(variation);
}

findVariationByName(name: string): ModelVariation | undefined

Finds a variation by its name.

typescript
const variation = component.findVariationByName("solitaire-head");

applyVariation(variation: ModelVariation, applyMaterial?: boolean): Promise<void>

Applies a variation to the component, loading the 3D model and optionally applying materials.

  • Parameters:
    • variation: The variation to apply
    • applyMaterial: Whether to reapply materials (default: true)
typescript
const variation = component.findVariationByName("princess-cut");
if (variation) {
  await component.applyVariation(variation);
}

dispose()

Disposes of the component and frees resources.

typescript
component.dispose();

ModelVariation Interface

Defines the structure for a model variation option.

typescript
interface ModelVariation {
  name: string;           // Unique identifier
  title?: string;         // Display name for UI
  tags?: string[];        // Tags for filtering/categorization
  selected?: string;      // Selection state identifier
  uuid?: string;          // Unique identifier
  modelUrl: string;       // URL to the 3D model file
  iconUrl?: string;       // URL to the thumbnail/icon
  fileId: string | number; // File identifier
}

Integration with MaterialConfiguratorPlugin

The RingConfiguratorPlugin works seamlessly with the MaterialConfiguratorPlugin to handle material changes. When a variation is applied, materials are automatically reapplied unless explicitly disabled:

typescript
// Apply variation without reapplying materials
await component.applyVariation(variation, false);

// Apply variation with materials (default behavior)
await component.applyVariation(variation, true);

TIP

For optimal performance, set applyMaterial to false when making multiple rapid changes, then manually trigger material application once all changes are complete.

Next Steps

Contact

For questions or assistance with the RingConfigurator integration, email us at [email protected]