threepipe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

GLTFKHRMaterialVariantsPlugin.md 1.7KB


prev:

text: 'ThreeFirstPersonControlsPlugin'
link: './ThreeFirstPersonControlsPlugin'

next:

text: 'Rhino3dmLoadPlugin'
link: './Rhino3dmLoadPlugin'

GLTFKHRMaterialVariantsPlugin

ExampleSource CodeAPI Reference

GLTFKHRMaterialVariantsPlugin adds support for importing and exporting glTF models with the KHR_materials_variants extension to load the model with different material variants/combinations. It also provides API and UI to change the current material variant.

The plugin automatically adds support for the extension when added to the viewer.

The materials are stored in object.userData._variantMaterials and are automatically loaded and saved when using the GLTFLoader.

Sample Usage

import {ThreeViewer, GLTFKHRMaterialVariantsPlugin, Mesh2} from 'threepipe'

const viewer = new ThreeViewer({...})

const variantsPlugin = viewer.addPluginSync(GLTFKHRMaterialVariantsPlugin)

// load some model
await viewer.load(model_url)

// list of all variants in the model (names and objects)
console.log(variantsPlugin.variants) 

// change the selected variant
variantsPlugin.selectedVariant = 'beach'