threepipe
Version:
A modern 3D viewer framework built on top of three.js, written in TypeScript, designed to make creating high-quality, modular, and extensible 3D experiences on the web simple and enjoyable.
81 lines • 3.69 kB
TypeScript
import { Object3D } from 'three';
import { AViewerPluginSync, ThreeViewer } from '../../viewer';
import { UiObjectConfig } from 'uiconfig.js';
/**
* Switch Node Plugin (Base)
*
* This plugin allows you to configure object variations in a file and apply them in the scene.
* Each SwitchNode is a parent object with multiple direct children. Only one child is visible at a time.
* This works by toggling the `visible` property of the children of a parent object.
* The plugin interfaces with the picking plugin and also provides uiConfig to show and edit the variations.
* It also provides a function to create snapshot previews of individual variations. This creates a limited render of the object with the selected child visible.
* To get a proper render, it's better to render it offline and set the image as a preview.
*
* See `SwitchNodePlugin` in [plugin-configurator](https://threepipe.org/plugins/configurator/docs/index.html) for example on inheriting with a custom UI renderer.
*
* @category Plugins
*/
export declare class SwitchNodeBasePlugin extends AViewerPluginSync {
static readonly PluginType = "SwitchNodePlugin";
enabled: boolean;
private _picking;
private _uiNeedRefresh;
constructor();
onAdded(viewer: ThreeViewer): void;
onRemove(viewer: ThreeViewer): void;
protected _postFrame(): void;
/**
* Whether refreshScene should be called when a node is selected. Refreshing scene will notify the plugins about the update, like shadows can be baked.
* Disable this when nothing significant geometry/node changes happen when switch nodes are changed.
*/
refreshScene: boolean;
/**
* Select a switch node variation with name or uuid.
* @param node
* @param nameOrUuid
* @param setDirty - set dirty in the viewer after update.
*/
selectNode(node: ObjectSwitchNode, nameOrUuid: string | number, setDirty?: boolean): boolean | undefined;
/**
* Apply all variations(by selected index or first item) when a config is loaded
*/
applyOnLoad: boolean;
/**
* Reapply all selected variations again.
* Useful when the scene is loaded or changed and the variations are not applied.
*/
reapplyAll(): void;
fromJSON(data: any, meta?: any): this | Promise<this | null> | null;
refreshUi(): void;
protected _refreshUi(): boolean;
refreshUiConfig(): void;
variations: ObjectSwitchNode[];
protected _selectedSwitchNode: () => Object3D | undefined;
/**
* Get the preview for a switch node variation
* Should be called from preFrame ideally. (or preRender but set viewerSetDirty = false)
* @param child - Child Object to get the preview for
* @param variation - Switch node variation that contains the child.
* @param viewerSetDirty - call viewer.setDirty() after setting the preview. So that the preview is cleared from the canvas.
*/
getPreview(variation: ObjectSwitchNode, child: Object3D, viewerSetDirty?: boolean): string;
addNode(node: ObjectSwitchNode, refreshUi?: boolean): void;
/**
* If true, the plugin will automatically take snapshots of the icons in _refreshUi and put them in the object.userdata.__icon
* Otherwise, call {@link snapIcons} manually
*/
autoSnapIcons: boolean;
/**
* Snapshots icons and puts in the userdata.__icon
*/
snapIcons(): void;
uiConfig: UiObjectConfig;
}
export interface ObjectSwitchNode {
name: string;
title: string;
selected: string;
camView: 'top' | 'bottom' | 'front' | 'back' | 'left' | 'right' | string;
camDistance: number;
}
//# sourceMappingURL=SwitchNodeBasePlugin.d.ts.map